From 95ccae621779649fdbcf3c3c00fc3b101575b338 Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Tue, 8 Sep 2015 22:25:59 +0900 Subject: [PATCH] tizen 2.3.1 release --- AUTHORS | 8 +- CMakeLists.txt | 58 +- LICENSE | 75 - LICENSE.APLv2 | 203 + NOTICE | 3 + SLP_MessagingFW_PG.h | 869 -- config/alert_on_call.mp3 | Bin 50369 -> 0 bytes config/message_tone/Sherbet.wav | Bin 121140 -> 0 bytes config/msg-service-db.CDMA.sql | 327 + config/msg-service-db.sql | 301 + config/plugin.cfg | 7 - config/sysinfo-message.xml | 8 + doc/msg_service_doc.h | 47 + externals/CMakeLists.txt | 54 + externals/MsgAlarm.cpp | 167 + externals/MsgDevicedWrapper.cpp | 94 + externals/MsgLbs.cpp | 49 + externals/MsgNotificationWrapper.cpp | 2839 +++++++ {msg_helper => externals}/MsgSensorWrapper.cpp | 53 +- externals/MsgSoundPlayer.cpp | 793 ++ externals/MsgSpamFilter.cpp | 319 + framework/CMakeLists.txt | 38 +- framework/deliver-handler/MsgDeliverHandler.cpp | 593 +- framework/main.cpp | 357 +- framework/plugin-manager/MsgPluginConfig.cpp | 237 - framework/plugin-manager/MsgPluginManager.cpp | 777 +- framework/setting-handler/MsgSettingHandler.cpp | 862 +- framework/storage-handler/MsgStorageFilter.cpp | 169 +- framework/storage-handler/MsgStorageFolder.cpp | 78 +- framework/storage-handler/MsgStorageManager.cpp | 1300 +-- framework/storage-handler/MsgStorageMessage.cpp | 3724 ++++----- framework/storage-handler/MsgStorageMms.cpp | 503 +- framework/storage-handler/MsgStorageSim.cpp | 93 +- framework/storage-handler/MsgStorageUtil.cpp | 821 +- framework/submit-handler/MsgSubmitHandler.cpp | 175 +- .../transaction-manager/MsgCmdHandlerFilter.cpp | 109 +- .../transaction-manager/MsgCmdHandlerSetting.cpp | 62 +- .../transaction-manager/MsgCmdHandlerStorage.cpp | 973 ++- .../transaction-manager/MsgCmdHandlerTransport.cpp | 639 +- framework/transaction-manager/MsgTransManager.cpp | 630 +- image/messaging_image001.png | Bin 70483 -> 0 bytes include/common/MsgCmdTypes.h | 115 +- include/common/MsgCppTypes.h | 33 +- include/common/MsgFilterTypes.h | 29 +- include/common/MsgInternalTypes.h | 294 +- include/common/MsgMmsTypes.h | 210 +- include/common/MsgPluginInterface.h | 81 +- include/common/MsgQueue.h | 93 +- include/common/MsgSettingTypes.h | 73 +- include/common/MsgSmil.h | 40 + include/common/MsgStorageTypes.h | 77 +- include/common/MsgThread.h | 26 +- include/common/MsgTransportTypes.h | 26 +- include/common/MsgTypes.h | 93 +- include/externals/MsgAlarm.h | 35 + include/externals/MsgDevicedWrapper.h | 25 + include/externals/MsgLbs.h | 37 + include/externals/MsgNotificationWrapper.h | 209 + include/externals/MsgSensorWrapper.h | 37 + include/externals/MsgSoundPlayer.h | 77 + include/{utils => externals}/MsgSpamFilter.h | 27 +- include/framework/MsgCmdHandler.h | 55 +- include/framework/MsgDeliverHandler.h | 28 +- include/framework/MsgPluginConfig.h | 94 - include/framework/MsgPluginManager.h | 62 +- include/framework/MsgSettingHandler.h | 33 +- include/framework/MsgStorageHandler.h | 79 +- include/framework/MsgSubmitHandler.h | 26 +- include/framework/MsgTransManager.h | 51 +- include/mapi/msg.h | 1239 ++- include/mapi/msg_private.h | 98 +- include/mapi/msg_storage.h | 2529 ++---- include/mapi/msg_storage_types.h | 197 +- include/mapi/msg_transport.h | 1150 +-- include/mapi/msg_transport_types.h | 229 +- include/mapi/msg_types.h | 2402 ++++-- include/msg_helper/MsgHelper.h | 56 - include/proxy/MsgHandle.h | 75 +- include/proxy/MsgProxyListener.h | 73 +- include/utils/MsgContact.h | 37 +- include/utils/MsgDebug.h | 198 +- include/utils/MsgDrmWrapper.h | 27 +- include/utils/MsgException.h | 27 +- include/utils/MsgGconfWrapper.h | 30 +- include/utils/MsgIpcSocket.h | 41 +- include/utils/MsgJsonParser.h | 132 + include/utils/MsgMemory.h | 26 +- include/utils/MsgMmsMessage.h | 84 +- include/utils/MsgMutex.h | 43 +- include/utils/MsgNotificationWrapper.h | 60 - include/utils/MsgSerialize.h | 29 + include/utils/MsgSoundPlayer.h | 42 - include/utils/MsgSqliteWrapper.h | 77 +- .../utils/MsgTextConvert.h | 122 +- include/utils/MsgUtilFile.h | 38 +- include/utils/MsgUtilFunction.h | 49 +- include/utils/MsgUtilStorage.h | 66 +- include/utils/MsgVMessage.h | 37 + mapi/CMakeLists.txt | 7 +- mapi/msg_control.cpp | 58 +- mapi/msg_filter.cpp | 177 +- mapi/msg_message.cpp | 540 +- mapi/msg_mms.cpp | 901 +- mapi/msg_setting.cpp | 384 +- mapi/msg_storage.cpp | 1668 +++- mapi/msg_svc.cpp | 573 +- mapi/msg_transport.cpp | 416 +- mms-plugin.manifest | 5 + msg-server | 6 +- msg-service-tools.manifest | 10 + msg-service.manifest | 24 + msg-service.rule | 51 + msg_helper/CMakeLists.txt | 48 - msg_helper/MsgSoundPlayer.cpp | 429 - msg_helper/main.cpp | 95 - packaging/msg-server.service | 13 + packaging/msg-service.spec | 498 +- plugin/mms_plugin/CMakeLists.txt | 62 +- .../LanguagePack/MmsPluginWmLngLatinUni.cpp | 1131 --- .../LanguagePack/MmsPluginWmLngString.cpp | 38 - .../LanguagePack/MmsPluginWmLngUTF8Uni.cpp | 201 - .../LanguagePack/MmsPluginWmLngUniUTF8.cpp | 142 - plugin/mms_plugin/MmsPluginAppBase.cpp | 254 + plugin/mms_plugin/MmsPluginAvCodec.cpp | 211 - plugin/mms_plugin/MmsPluginCodec.cpp | 625 -- plugin/mms_plugin/MmsPluginCodecCommon.cpp | 1911 +++++ plugin/mms_plugin/MmsPluginComposer.cpp | 226 + plugin/mms_plugin/MmsPluginConnManWrapper.cpp | 898 +- plugin/mms_plugin/MmsPluginContentCodec.cpp | 1068 --- plugin/mms_plugin/MmsPluginDebug.cpp | 1365 --- plugin/mms_plugin/MmsPluginDecode.cpp | 8735 ++++++++------------ plugin/mms_plugin/MmsPluginDrm.cpp | 157 +- plugin/mms_plugin/MmsPluginEncode.cpp | 1680 ++-- plugin/mms_plugin/MmsPluginEventHandler.cpp | 66 +- plugin/mms_plugin/MmsPluginHttp.cpp | 787 +- plugin/mms_plugin/MmsPluginInternal.cpp | 873 +- plugin/mms_plugin/MmsPluginMIME.cpp | 809 +- plugin/mms_plugin/MmsPluginMain.cpp | 87 +- plugin/mms_plugin/MmsPluginMessage.cpp | 2089 ++--- plugin/mms_plugin/MmsPluginSMILValidate.cpp | 42 +- plugin/mms_plugin/MmsPluginSmil.cpp | 2101 ----- plugin/mms_plugin/MmsPluginStorage.cpp | 2125 ++--- plugin/mms_plugin/MmsPluginTcs.cpp | 85 + plugin/mms_plugin/MmsPluginTextConvert.cpp | 127 + plugin/mms_plugin/MmsPluginTransport.cpp | 81 +- plugin/mms_plugin/MmsPluginUserAgent.cpp | 430 +- plugin/mms_plugin/MmsPluginUtil.cpp | 457 + plugin/mms_plugin/include/MmsPluginAppBase.h | 39 + plugin/mms_plugin/include/MmsPluginAvCodec.h | 92 - plugin/mms_plugin/include/MmsPluginCodec.h | 390 +- plugin/mms_plugin/include/MmsPluginCodecCommon.h | 197 + plugin/mms_plugin/include/MmsPluginCodecTypes.h | 470 ++ plugin/mms_plugin/include/MmsPluginComposer.h | 46 + .../mms_plugin/include/MmsPluginConnManWrapper.h | 72 +- plugin/mms_plugin/include/MmsPluginData.h | 42 - plugin/mms_plugin/include/MmsPluginDebug.h | 75 +- plugin/mms_plugin/include/MmsPluginDecode.h | 123 + plugin/mms_plugin/include/MmsPluginDrm.h | 51 +- plugin/mms_plugin/include/MmsPluginEncode.h | 50 + plugin/mms_plugin/include/MmsPluginEventHandler.h | 36 +- plugin/mms_plugin/include/MmsPluginHttp.h | 140 +- plugin/mms_plugin/include/MmsPluginInternal.h | 41 +- plugin/mms_plugin/include/MmsPluginMIME.h | 281 +- plugin/mms_plugin/include/MmsPluginMain.h | 38 +- plugin/mms_plugin/include/MmsPluginMessage.h | 572 +- plugin/mms_plugin/include/MmsPluginSMILValidate.h | 177 - plugin/mms_plugin/include/MmsPluginSetup.h | 150 - plugin/mms_plugin/include/MmsPluginSmil.h | 266 - plugin/mms_plugin/include/MmsPluginStorage.h | 101 +- plugin/mms_plugin/include/MmsPluginTcs.h | 23 + plugin/mms_plugin/include/MmsPluginTextConvert.h | 24 + plugin/mms_plugin/include/MmsPluginTransport.h | 42 +- plugin/mms_plugin/include/MmsPluginTypes.h | 215 +- plugin/mms_plugin/include/MmsPluginUserAgent.h | 44 +- plugin/mms_plugin/include/MmsPluginUtil.h | 42 + plugin/mms_plugin/include/MmsPluginWmLngPack.h | 94 - plugin/sms_cdma_plugin/CMakeLists.txt | 57 + plugin/sms_cdma_plugin/SmsCdmaPluginCallback.cpp | 574 ++ plugin/sms_cdma_plugin/SmsCdmaPluginCodec.cpp | 2383 ++++++ .../sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp | 1210 +++ plugin/sms_cdma_plugin/SmsCdmaPluginMain.cpp | 442 + plugin/sms_cdma_plugin/SmsCdmaPluginParamCodec.cpp | 240 + plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp | 683 ++ plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp | 672 ++ plugin/sms_cdma_plugin/SmsCdmaPluginTransport.cpp | 563 ++ plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp | 106 + .../SmsCdmaPluginWapPushHandler.cpp | 3461 ++++++++ .../include/SmsCdmaPluginCallback.h | 80 + .../sms_cdma_plugin/include/SmsCdmaPluginCodec.h | 87 + .../include/SmsCdmaPluginEventHandler.h | 133 + plugin/sms_cdma_plugin/include/SmsCdmaPluginMain.h | 66 + .../include/SmsCdmaPluginParamCodec.h | 50 + .../sms_cdma_plugin/include/SmsCdmaPluginSetting.h | 93 + .../sms_cdma_plugin/include/SmsCdmaPluginStorage.h | 76 + .../include/SmsCdmaPluginTransport.h | 76 + .../sms_cdma_plugin/include/SmsCdmaPluginTypes.h | 1011 +++ .../include/SmsCdmaPluginUAManager.h | 63 + .../include/SmsCdmaPluginWapPushHandler.h | 101 + plugin/sms_plugin/CMakeLists.txt | 9 +- plugin/sms_plugin/SmsPluginCallback.cpp | 765 +- plugin/sms_plugin/SmsPluginCbMsgHandler.cpp | 795 +- plugin/sms_plugin/SmsPluginConcatHandler.cpp | 916 +- plugin/sms_plugin/SmsPluginDSHandler.cpp | 180 + plugin/sms_plugin/SmsPluginEventHandler.cpp | 596 +- plugin/sms_plugin/SmsPluginMain.cpp | 513 +- plugin/sms_plugin/SmsPluginParamCodec.cpp | 69 +- plugin/sms_plugin/SmsPluginSatHandler.cpp | 287 +- plugin/sms_plugin/SmsPluginSetting.cpp | 1717 +++- plugin/sms_plugin/SmsPluginSimMsg.cpp | 796 +- plugin/sms_plugin/SmsPluginStorage.cpp | 1271 +-- plugin/sms_plugin/SmsPluginTextConvert.cpp | 951 --- plugin/sms_plugin/SmsPluginTpduCodec.cpp | 153 +- plugin/sms_plugin/SmsPluginTransport.cpp | 748 +- plugin/sms_plugin/SmsPluginUAManager.cpp | 56 +- plugin/sms_plugin/SmsPluginUDCodec.cpp | 135 +- plugin/sms_plugin/SmsPluginWapPushHandler.cpp | 800 +- plugin/sms_plugin/include/SmsPluginCallback.h | 59 +- plugin/sms_plugin/include/SmsPluginCbMsgHandler.h | 54 +- plugin/sms_plugin/include/SmsPluginConcatHandler.h | 48 +- plugin/sms_plugin/include/SmsPluginDSHandler.h | 51 + plugin/sms_plugin/include/SmsPluginEventHandler.h | 47 +- plugin/sms_plugin/include/SmsPluginMain.h | 44 +- plugin/sms_plugin/include/SmsPluginParamCodec.h | 28 +- plugin/sms_plugin/include/SmsPluginSatHandler.h | 46 +- plugin/sms_plugin/include/SmsPluginSetting.h | 98 +- plugin/sms_plugin/include/SmsPluginSimMsg.h | 70 +- plugin/sms_plugin/include/SmsPluginStorage.h | 67 +- plugin/sms_plugin/include/SmsPluginTpduCodec.h | 26 +- plugin/sms_plugin/include/SmsPluginTransport.h | 55 +- plugin/sms_plugin/include/SmsPluginTypes.h | 334 +- plugin/sms_plugin/include/SmsPluginUAManager.h | 36 +- plugin/sms_plugin/include/SmsPluginUDCodec.h | 26 +- .../sms_plugin/include/SmsPluginWapPushHandler.h | 40 +- proxy/CMakeLists.txt | 9 +- proxy/MsgHandleControl.cpp | 372 +- proxy/MsgHandleFilter.cpp | 73 +- proxy/MsgHandleSetting.cpp | 99 +- proxy/MsgHandleStorage.cpp | 886 +- proxy/MsgHandleTransport.cpp | 385 +- proxy/MsgProxyListener.cpp | 518 +- sms-plugin.manifest | 5 + utils/CMakeLists.txt | 19 +- utils/MsgContact.cpp | 1468 +++- utils/MsgDebug.cpp | 135 +- utils/MsgDrmWrapper.cpp | 216 +- utils/MsgException.cpp | 26 +- utils/MsgGconfWrapper.cpp | 128 +- utils/MsgIpcSocket.cpp | 194 +- utils/MsgJsonParser.cpp | 553 ++ utils/MsgMemory.cpp | 26 +- utils/MsgMmsMessage.cpp | 1747 ++-- utils/MsgMutex.cpp | 26 +- utils/MsgNotificationWrapper.cpp | 622 -- utils/MsgSerialize.cpp | 853 ++ utils/MsgSmil.cpp | 2008 +++++ utils/MsgSoundPlayer.cpp | 303 - utils/MsgSpamFilter.cpp | 203 - utils/MsgSqliteWrapper.cpp | 396 +- utils/MsgTextConvert.cpp | 1190 +++ utils/MsgUtilFile.cpp | 326 +- utils/MsgUtilFunction.cpp | 469 +- utils/MsgUtilStorage.cpp | 3116 +++++-- utils/MsgVMessage.cpp | 667 ++ vobject-engine/CMakeLists.txt | 40 + vobject-engine/VCard.c | 1547 ++++ vobject-engine/VCardCalUtil.c | 1236 +++ vobject-engine/VMessage.c | 1639 ++++ vobject-engine/include/VCard.h | 231 + vobject-engine/include/VMessage.h | 209 + vobject-engine/include/VTypes.h | 115 + vobject-engine/include/vobject.h | 91 + 271 files changed, 75296 insertions(+), 39354 deletions(-) delete mode 100755 LICENSE create mode 100755 LICENSE.APLv2 create mode 100755 NOTICE delete mode 100755 SLP_MessagingFW_PG.h delete mode 100755 config/alert_on_call.mp3 delete mode 100755 config/message_tone/Sherbet.wav create mode 100755 config/msg-service-db.CDMA.sql create mode 100755 config/msg-service-db.sql delete mode 100755 config/plugin.cfg create mode 100755 config/sysinfo-message.xml create mode 100644 doc/msg_service_doc.h create mode 100755 externals/CMakeLists.txt create mode 100755 externals/MsgAlarm.cpp create mode 100644 externals/MsgDevicedWrapper.cpp create mode 100755 externals/MsgLbs.cpp create mode 100755 externals/MsgNotificationWrapper.cpp rename {msg_helper => externals}/MsgSensorWrapper.cpp (66%) create mode 100755 externals/MsgSoundPlayer.cpp create mode 100755 externals/MsgSpamFilter.cpp delete mode 100755 framework/plugin-manager/MsgPluginConfig.cpp delete mode 100755 image/messaging_image001.png create mode 100755 include/common/MsgSmil.h create mode 100755 include/externals/MsgAlarm.h create mode 100644 include/externals/MsgDevicedWrapper.h create mode 100755 include/externals/MsgLbs.h create mode 100755 include/externals/MsgNotificationWrapper.h create mode 100755 include/externals/MsgSensorWrapper.h create mode 100755 include/externals/MsgSoundPlayer.h rename include/{utils => externals}/MsgSpamFilter.h (56%) delete mode 100755 include/framework/MsgPluginConfig.h delete mode 100755 include/msg_helper/MsgHelper.h create mode 100755 include/utils/MsgJsonParser.h delete mode 100755 include/utils/MsgNotificationWrapper.h create mode 100755 include/utils/MsgSerialize.h delete mode 100755 include/utils/MsgSoundPlayer.h rename plugin/sms_plugin/include/SmsPluginTextConvert.h => include/utils/MsgTextConvert.h (82%) create mode 100755 include/utils/MsgVMessage.h create mode 100755 mms-plugin.manifest create mode 100755 msg-service-tools.manifest create mode 100755 msg-service.manifest create mode 100755 msg-service.rule delete mode 100755 msg_helper/CMakeLists.txt delete mode 100755 msg_helper/MsgSoundPlayer.cpp delete mode 100755 msg_helper/main.cpp create mode 100755 packaging/msg-server.service delete mode 100755 plugin/mms_plugin/LanguagePack/MmsPluginWmLngLatinUni.cpp delete mode 100755 plugin/mms_plugin/LanguagePack/MmsPluginWmLngString.cpp delete mode 100755 plugin/mms_plugin/LanguagePack/MmsPluginWmLngUTF8Uni.cpp delete mode 100755 plugin/mms_plugin/LanguagePack/MmsPluginWmLngUniUTF8.cpp create mode 100755 plugin/mms_plugin/MmsPluginAppBase.cpp delete mode 100755 plugin/mms_plugin/MmsPluginAvCodec.cpp delete mode 100755 plugin/mms_plugin/MmsPluginCodec.cpp create mode 100755 plugin/mms_plugin/MmsPluginCodecCommon.cpp create mode 100755 plugin/mms_plugin/MmsPluginComposer.cpp delete mode 100755 plugin/mms_plugin/MmsPluginContentCodec.cpp delete mode 100755 plugin/mms_plugin/MmsPluginDebug.cpp delete mode 100755 plugin/mms_plugin/MmsPluginSmil.cpp create mode 100755 plugin/mms_plugin/MmsPluginTcs.cpp create mode 100755 plugin/mms_plugin/MmsPluginTextConvert.cpp create mode 100755 plugin/mms_plugin/MmsPluginUtil.cpp create mode 100755 plugin/mms_plugin/include/MmsPluginAppBase.h delete mode 100755 plugin/mms_plugin/include/MmsPluginAvCodec.h create mode 100755 plugin/mms_plugin/include/MmsPluginCodecCommon.h create mode 100755 plugin/mms_plugin/include/MmsPluginCodecTypes.h create mode 100755 plugin/mms_plugin/include/MmsPluginComposer.h delete mode 100755 plugin/mms_plugin/include/MmsPluginData.h create mode 100755 plugin/mms_plugin/include/MmsPluginDecode.h create mode 100755 plugin/mms_plugin/include/MmsPluginEncode.h delete mode 100755 plugin/mms_plugin/include/MmsPluginSMILValidate.h delete mode 100755 plugin/mms_plugin/include/MmsPluginSetup.h delete mode 100755 plugin/mms_plugin/include/MmsPluginSmil.h create mode 100755 plugin/mms_plugin/include/MmsPluginTcs.h create mode 100755 plugin/mms_plugin/include/MmsPluginTextConvert.h create mode 100755 plugin/mms_plugin/include/MmsPluginUtil.h delete mode 100755 plugin/mms_plugin/include/MmsPluginWmLngPack.h create mode 100755 plugin/sms_cdma_plugin/CMakeLists.txt create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginCallback.cpp create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginCodec.cpp create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginMain.cpp create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginParamCodec.cpp create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginTransport.cpp create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp create mode 100755 plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginCallback.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginCodec.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginMain.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginParamCodec.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginSetting.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginStorage.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginTransport.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginTypes.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginUAManager.h create mode 100755 plugin/sms_cdma_plugin/include/SmsCdmaPluginWapPushHandler.h create mode 100755 plugin/sms_plugin/SmsPluginDSHandler.cpp delete mode 100755 plugin/sms_plugin/SmsPluginTextConvert.cpp create mode 100755 plugin/sms_plugin/include/SmsPluginDSHandler.h create mode 100755 sms-plugin.manifest create mode 100755 utils/MsgJsonParser.cpp delete mode 100755 utils/MsgNotificationWrapper.cpp create mode 100755 utils/MsgSerialize.cpp create mode 100755 utils/MsgSmil.cpp delete mode 100755 utils/MsgSoundPlayer.cpp delete mode 100755 utils/MsgSpamFilter.cpp create mode 100755 utils/MsgTextConvert.cpp create mode 100755 utils/MsgVMessage.cpp create mode 100755 vobject-engine/CMakeLists.txt create mode 100755 vobject-engine/VCard.c create mode 100755 vobject-engine/VCardCalUtil.c create mode 100755 vobject-engine/VMessage.c create mode 100755 vobject-engine/include/VCard.h create mode 100755 vobject-engine/include/VMessage.h create mode 100755 vobject-engine/include/VTypes.h create mode 100755 vobject-engine/include/vobject.h diff --git a/AUTHORS b/AUTHORS index fd16fcc..2ebd567 100755 --- a/AUTHORS +++ b/AUTHORS @@ -1,4 +1,4 @@ -Chang-Seok Oh -Sangkoo Kim -Seunghwan Lee -KeeBum Kim \ No newline at end of file +Sanghun Chung +Sangkoo Kim + + diff --git a/CMakeLists.txt b/CMakeLists.txt index d6b9892..f4d7bdb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,12 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +include(CheckCXXCompilerFlag) ########################################################## # Set Variables ########################################################## +SET(VOBJECT-LIB msg_vobject) SET(UTILS-LIB msg_utils) +SET(EXTERNALS-LIB msg_externals) SET(PLUGIN-MANAGER-LIB msg_plugin_manager) SET(FW-HANDLER-LIB msg_framework_handler) SET(TRANS-MANAGER-LIB msg_transaction_manager) @@ -10,19 +14,42 @@ 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) + +IF(_FEATURE_SMS_CDMA) + ADD_DEFINITIONS("-DFEATURE_SMS_CDMA") +ENDIF(_FEATURE_SMS_CDMA) + +IF(_MSG_WEARABLE_PROFILE) + ADD_DEFINITIONS("-DMSG_WEARABLE_PROFILE") +ENDIF(_MSG_WEARABLE_PROFILE) + +ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64") + +CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) +CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) +IF(COMPILER_SUPPORTS_CXX11) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +ELSEIF(COMPILER_SUPPORTS_CXX0X) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +ELSE() + MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") +ENDIF() ########################################################## # Add Subdirectories ########################################################## +ADD_SUBDIRECTORY(vobject-engine) ADD_SUBDIRECTORY(utils) +ADD_SUBDIRECTORY(externals) ADD_SUBDIRECTORY(framework) ADD_SUBDIRECTORY(proxy) ADD_SUBDIRECTORY(mapi) +IF(_FEATURE_SMS_CDMA) +ADD_SUBDIRECTORY(plugin/sms_cdma_plugin) +ELSE(_FEATURE_SMS_CDMA) ADD_SUBDIRECTORY(plugin/sms_plugin) +ENDIF(_FEATURE_SMS_CDMA) ADD_SUBDIRECTORY(plugin/mms_plugin) -ADD_SUBDIRECTORY(msg_helper) - ########################################################## # Install Header Files @@ -34,7 +61,7 @@ SET(MAPI-HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/mapi/msg_storage_types.h ${CMAKE_CURRENT_SOURCE_DIR}/include/mapi/msg_transport.h ${CMAKE_CURRENT_SOURCE_DIR}/include/mapi/msg_transport_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/SLP_MessagingFW_PG.h ) + ) INSTALL(FILES ${MAPI-HEADERS} DESTINATION include/msg-service) @@ -42,13 +69,7 @@ INSTALL(FILES ${MAPI-HEADERS} DESTINATION include/msg-service) # Install etc Files ########################################################## -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config/plugin.cfg DESTINATION /usr/share/msg-service) - -SET(RINGTONE-FILES - ${CMAKE_CURRENT_SOURCE_DIR}/config/message_tone/Sherbet.wav -) - -INSTALL(FILES ${RINGTONE-FILES} DESTINATION /usr/share/media/) +#INSTALL(FILES ${MMS-FILES} DESTINATION /opt/etc/msg-service) CONFIGURE_FILE(msg-service.pc.in msg-service.pc @ONLY) INSTALL(FILES ${CMAKE_BINARY_DIR}/msg-service.pc DESTINATION lib/pkgconfig) @@ -56,3 +77,18 @@ INSTALL(FILES ${CMAKE_BINARY_DIR}/msg-service.pc DESTINATION lib/pkgconfig) SET(RC_LOCAL_SCRIPT msg-server) INSTALL(PROGRAMS ${RC_LOCAL_SCRIPT} DESTINATION /etc/rc.d/init.d) +# systemd +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/msg-server.service DESTINATION /usr/lib/systemd/system) + +# LICENSE file +INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE.APLv2 DESTINATION /usr/share/license/msg-service) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/msg-service.rule DESTINATION /etc/smack/accesses.d/) + +#Install sysinfo file to provide which features are supported. +IF(_FEATURE_SMS_CDMA) + INSTALL(FILES ${CMAKE_SOURCE_DIR}/config/msg-service-db.CDMA.sql DESTINATION /usr/share/msg-service RENAME msg-service-db.sql) + INSTALL(FILES ${CMAKE_SOURCE_DIR}/config/sysinfo-message.xml DESTINATION /etc/config) +ELSE(_FEATURE_SMS_CDMA) + INSTALL(FILES ${CMAKE_SOURCE_DIR}/config/msg-service-db.sql DESTINATION /usr/share/msg-service RENAME msg-service-db.sql) + INSTALL(FILES ${CMAKE_SOURCE_DIR}/config/sysinfo-message.xml DESTINATION /etc/config) +ENDIF(_FEATURE_SMS_CDMA) diff --git a/LICENSE b/LICENSE deleted file mode 100755 index 7ccb5b5..0000000 --- a/LICENSE +++ /dev/null @@ -1,75 +0,0 @@ -Flora License - -Version 1.0, May, 2012 - -http://www.tizenopensource.org/license - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -"Tizen Certified Platform" shall mean a software platform that complies with the standards set forth in the Compatibility Definition Document and passes the Compatibility Test Suite as defined from time to time by the Tizen Technical Steering Group and certified by the Tizen Association or its designated agent. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work solely as incorporated into a Tizen Certified Platform, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work solely as incorporated into a Tizen Certified Platform to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof pursuant to the copyright license above, in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: - - 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and - - 2. You must cause any modified files to carry prominent notices stating that You changed the files; and - - 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and - - 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Flora License to your work - -To apply the Flora License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 new file mode 100755 index 0000000..74f474e --- /dev/null +++ b/LICENSE.APLv2 @@ -0,0 +1,203 @@ +Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100755 index 0000000..a718085 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE.APLv2 file for Apache License, Version 2 terms and conditions. diff --git a/SLP_MessagingFW_PG.h b/SLP_MessagingFW_PG.h deleted file mode 100755 index ecff3d7..0000000 --- a/SLP_MessagingFW_PG.h +++ /dev/null @@ -1,869 +0,0 @@ -/** - * - * @ingroup SLP_PG - * @defgroup MESSAGE MessagingFW -@{ -

Introduction

-

Purpose

-The purpose of this document is to describe how applications can use the Messaging Framework APIs to send and receive SMS and MMS messages. This document gives programming guidelines to application engineers. - -

Scope

-The scope of this document is limited to Messaging Framework APIs usage. - -

Abbreviations

- - -
APIApplication Programming Interface
-@} - -@defgroup Message_Architecture 1.Archtecture -@ingroup MESSAGE -@{ -

Messaging Framework Architecture

-The Messaging framework supports various messaging services such as SMS, MMS, Cell Broadcast, WAP Push, and Provisioning message. The Messaging framework architecture consists of a Messaging daemon and a library. The messaging library works on application process and provides various APIs to support transport, control, storage, filter and setting services for application. The messaging daemon has three components (transaction manager, transaction handler, and plug-in manager) to provide message services. The socket IPC is used to communicate (request & event) between Messaging daemon and library. -@image html messaging_image001.png - -- Transaction Manager - - Receive the IPC message (request) on socket. - - Manage list of pairs (request ID, transaction proxy) for synchronous return. - - Determine the transaction flow based on request/event information. (Mapping the request to one of the handlers) - - Store the transaction information for asynchronous events (Find which transaction proxy want to receive SMS) -- Transaction Handler - - Submit handler deals with submit requests. - - Deliver handler deals with the incoming message from plug-ins. - - Storage handler deals with the messages, accounts and folder requests - - Filter handler deals with the filter requests - - Setting handler deals with the service-specific attributes -- Plug-in Manager - - Initialize all plug-ins after loading plug-in configuration files - - Holding the list of plug-ins and the state of plug-ins - - Providing the interface between handlers and plug-ins -- Transaction Handlers - - Initialize all plug-ins after loading plug-in configuration files - - Receiving IPC messages from messaging daemon. - - Handling synchronous calls - - Condition variable is used for waiting the return from msg. server) - - Handling asynchronous calls or events - - Proxy listener is a component of transaction proxy - - Proxy listener is waiting for the event - - Invoking callback function in the msg. handle list - - i.e. calling incoming callback function of MSG APP handle, when incoming msg - - Holding list of message handles - - Message handle is created by MsgOpenMsgHandle(msgHandle) - - Message handle holds some info such as callback func -- Message API - - Transport & control API - - Storage API - - Filter API - - Setting API -@} - -@defgroup Message_Feature 2.Feature -@ingroup MESSAGE -@{ -

Messaging Framework Features

--# Message Control Features: - -# Open/Close message handle --# Message Transport Features: - -# Submit request to send, forward, reply, retrieve message. - -# Register callback functions to listen to invoked events from messaging daemon. (message status callback, incoming message callback) --# Message Storage Features: - -# Add / Update / Move / Delete / Count / Get message or message list. - -# Add / Update / Delete / Get folder or folder list. --# Message Filter Features: - -# Add / Update / Delete filter or filter list. --# Message Setting Features: - -# Set / Get various message setting (i.e. whether to send read/delivery report or not) -@} - -@defgroup MESSAGE_USECASES_1 Initialize/Finalization -@ingroup MESSAGE_USECASES -@{ -

Messaging Framework Functions

- -

Initialization / Finalization to use Messaging Service

-- int msg_open_msg_handle(MSG_HANDLE_T *handle); -@n msg_open_msg_handle() should be called before using the messaging service. This function opens a channel between the application and the messaging framework. -- int msg_close_msg_handle(MSG_HANDLE_T *handle); -@n msg_close_msg_handle() should be called after using the messaging service. This function closes a channel between the application and the messaging framework. -- int msg_reg_sent_status_callback(MSG_HANDLE_T handle, msg_sent_status_cb cb); -@n Application should implement a msg_sent_status_cb function and register it into message handle. If the application sends a message, this callback function will be called to report its sending status. msg_reg_set_status_callback function should be called after creation of message handle. -- int msg_reg_sms_message_callback(MSG_HANDLE_T handle, msg_sms_incoming_cb cb, unsigned short port); -@n Application should implement a msg_sms_incoming_cb function and register it into message handle. It’s used to listen to the SMS incoming event invoked by messaging daemon. The incoming message information structure (MSG_MESSAGE_S) can be delivered as a parameter of the callback function. -- int msg_reg_mms_conf_message_callback(MSG_HANDLE_T handle, msg_mms_conf_msg_incoming_cb cb, char *app_id); -@n Application should implement a msg_mms_conf_msg_incoming_cb function and register it into message handle. It’s used to listen to the MMS incoming event invoked by messaging daemon. The incoming message information structure (MSG_MESSAGE_S) can be delivered as a parameter of the callback function. -@code -#include -#include -#include -#include - -void sentStatusCB(MSG_HANDLE_T hMsgHandle, MSG_SENT_STATUS_S *pMsgStatus, void *user_param) -{ - // Application can handle message sent status event -} - -void incomingSmsMessageCB (MSG_HANDLE_T hMsgHandle, msg_message_t msg, void *user_param) -{ - // Application can handle SMS incoming message. -} - -void incomingMmsConfMessageCB(MSG_HANDLE_T hMsgHandle, msg_message_t msg, void *user_param) -{ - // Application can handle MMS incoming message. -} - -int main(void) -{ - MSG_HANDLE_T msgHandle = NULL; - - err = msg_open_msg_handle(&msgHandle); - - if (err != MSG_SUCCESS) - { - printf("msg_open_msg_handle() Fail [%d]", err); - return err; - } - - // Register sent status handler - err = msg_reg_sent_status_callback(msgHandle, &sentStatusCB, NULL); - - if (err != MSG_SUCCESS) - { - printf("msg_reg_sent_status_callback() Fail [%d]", err); - return err; - } - - // Register SMS incoming message handler - err = msg_reg_sms_message_callback(msgHandle, &incomingSmsMessageCB, 0, NULL); - - if (err != MSG_SUCCESS) - { - printf("msg_reg_sms_message_callback() Fail [%d]", err); - return err; - } - - // Register MMS incoming message handler - err = msg_reg_mms_conf_message_callback(msgHandle, &incomingMmsConfMessageCB, NULL, NULL); - - if (err != MSG_SUCCESS) - { - printf("msg_reg_mms_conf_message_callback() Fail [%d]", err); - return err; - } - - // g_main_loop should be used to listen CB event from messaging daemon - mainloop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(mainloop); - - msg_close_msg_handle(&msgHandle); - - return err; -} -@endcode -@} - -@defgroup MESSAGE_USECASES_2 Adding a SMS Message -@ingroup MESSAGE_USECASES -@{ -

Adding a SMS Message

-- msg_message_t msg_new_message(); -@n msg_new_message() is a function to create a message object which can store the message information. You should call this function to set the message that you want to add or send. -- int msg_set_message_type(msg_message_t msg, MSG_MESSAGE_TYPE_T msg_type); -@n msg_set_message_type() is a function to set the message type such as SMS or MMS. The first parameter is the message object which is created by msg_new_message(). The second parameter is the message type you want to set. It should be one of enum type ( _MSG_MESSAGE_TYPE_E). If setting is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E). -- int msg_sms_set_message_body(msg_message_t msg, const char* mdata, int size); -@n msg_sms_set_message_body() is a function to set the SMS body data. The first parameter is the message object which is created by msg_new_message(). The second parameter is the SMS body data you want to set. The third parameter is the length of SMS body data. If setting is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E). -- int msg_add_address(msg_message_t msg, const char* phone_num_list, MSG_RECIPIENT_TYPE_T to_type); -@n msg_add_address() is a function to add the phone numbers for the message. The first parameter is the message object which is created by msg_new_message(). The second parameter is the list of phone number you want to set. You can add several phone numbers at once. The phone numbers should be separated by ','. The third parameter is the recipient type of phone number. It should be one of enum type (_MSG_RECIPIENT_TYPE_E). If setting is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E). -- int msg_add_message(MSG_HANDLE_T handle, const msg_message_t msg, const MSG_SENDINGOPT_S *send_opt); -@n msg_add_message() is a function to add a composed message into the database of messaging framework. Before calling this function, the application should set the message object and the sending option structure and then pass them as parameters. If you don't want to change the current sending option, set the variable 'bSetting' to false. If saving a message is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E). -- int msg_release_message(msg_message_t *msg); -@n msg_release_message() is a function to free the memory of a message object which is create by msg_new_message(). If freeing the memory is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E). -@code -#include -#include -#include - -void test_add_sms_message(MSG_HANDLE_T hMsgHandle) -{ - MSG_ERROR_T err = MSG_SUCCESS; - - MSG_SENDINGOPT_S sendOpt = {0, }; - sendOpt.bSetting = false; - - msg_message_t msgInfo = msg_new_message(); - - // Set Message Type - err = msg_set_message_type(msgInfo, MSG_TYPE_SMS); - - if (err != MSG_SUCCESS) goto free_memory; - - char msgText[1024]; - - memset(msgText, 0x00, 1024); - strncpy(msgText, "Test SMS Message", sizeof(msgText)-1); - int dataSize = strlen(msgText); - - // Set SMS text - err = msg_sms_set_message_body(msgInfo, msgText, dataSize); - - if (err != MSG_SUCCESS) goto free_memory; - - char number[MAX_ADDRESS_VAL_LEN]; - - memset(number, 0x00, MAX_ADDRESS_VAL_LEN); - strncpy(number, "+821030011234", sizeof(number)-1); - - // Set Recipient Address - err = msg_add_address(msgInfo, number, MSG_RECIPIENTS_TYPE_TO); - - if (err != MSG_SUCCESS) goto free_memory; - - err = msg_add_message(hMsgHandle, msgInfo, &sendOpt); - - if (err == MSG_SUCCESS) - printf("Saving Message is OK!"); - else - printf("Saving Message is failed!"); - -free_memory: - msg_release_message(&msgInfo); -} -@endcode -@} - -@defgroup MESSAGE_USECASES_3 Adding a MMS Message -@ingroup MESSAGE_USECASES -@{ -

Adding a MMS Message

-- int msg_set_subject(msg_message_t msg, const char* subject); -@n msg_set_subject() is a function to set the subject of MMS. The first parameter is the message object which is created by msg_new_message(). The second parameter is the subject you want to set. If setting is successful, the function returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E). - -- MMS_MESSAGE_DATA_S* msg_mms_create_message(void); -@n msg_mms_create_message() allocates a MMS_MESSAGE_DATA_S structure and returns it’s address. MMS_MESSAGE_DATA_S is needed to represent mms specific data and transfer it to the messaging daemon in the pData parameter of the MSG_MESSAGE_S structure. - -- MMS_SMIL_ROOTLAYOUT* msg_mms_set_rootlayout(MMS_MESSAGE_DATA_S* msg, const int width, const int height, const int bgcolor); -@n msg_mms_set_rootlayout() is a function to set smil root layout. The parameters representing the size and background color of smil root layout should be set. - -- MMS_SMIL_REGION* msg_mms_add_region(MMS_MESSAGE_DATA_S *msg_data, const char* szID, const int x, const int y, const int width, const int height, const int bgcolor); -@n msg_mms_add_region() is a function to add a smil region. Smil region is needed to display text message, image, and video data (Each content has its own region). This function is called to allocate a region for each contents. - -- MMS_PAGE_S* msg_mms_add_page(MMS_MESSAGE_DATA_S *msg_data, const int duration); -@n msg_mms_add_page() is a function to add a smil page. - -- MMS_MEDIA_S* msg_mms_add_media(MMS_PAGE_S *page, const MmsSmilMediaType mediatype, const char* regionid, char* filepath); -@n msg_mms_add_media() is a function to add multimedia content to a mms message. If some content should be played with smil player, this function can be used. - -- MMS_ATTACH_S* msg_mms_add_attachment(MMS_MESSAGE_DATA_S *msg_data, char *filepath); -@n msg_mms_add_attachment() is a function to add a content as an attached file. With this function a content might be attached as a multipart mixed type. - -- int msg_mms_set_message_body(msg_message_t msg, const MMS_MESSAGE_DATA_S *msg_data); -@n msg_mms_set_message_body() is a function to set the MMS body data. The first parameter is the message object which is created by msg_new_message(). The second parameter is the structure which is allocated by msg_mms_create_message() and is set by the APIs for MMS. - -- int msg_mms_destroy_message(MMS_MESSAGE_DATA_S* msg); -@n msg_mms_destroy_message() should be called to deallocate the MMS_MESSAGE_DATA_S structure and internal region, page, media, and attach list. -@code -#include -#include -#include - -void test_add_mms_message(MSG_HANDLE_T hMsgHandle) -{ - MSG_ERROR_T err = MSG_SUCCESS; - - MSG_SENDINGOPT_S sendOpt = {0, }; - sendOpt.bSetting = false; - - msg_message_t msgInfo = msg_new_message(); - - // Set Message Type - err = msg_set_message_type(msgInfo, MSG_TYPE_MMS); - - if (err != MSG_SUCCESS) goto free_memory; - - MMS_MESSAGE_DATA_S* data; - MMS_PAGE_S* page; - MMS_MEDIA_S* media[3]; - MMS_ATTACH_S* attach; - int nSize = 0; - - // Set MMS subject - char subject[MAX_SUBJECT_LEN]; - - memset(subject, 0x00, MAX_SUBJECT_LEN); - strncpy(subject, "hello mms", sizeof(subject)-1); - - err = msg_set_subject(msgInfo, subject); - - if (err != MSG_SUCCESS) goto free_memory; - - // Set MMS Body data - data = msg_mms_create_message(); - msg_mms_set_rootlayout(data, 100, 100, 0xffffff); - msg_mms_add_region(data, "Image", 0, 50, 100, 50, 0xffffff); - msg_mms_add_region(data, "Text", 0, 0, 100, 50, 0xffffff); - page = msg_mms_add_page(data, 5000); - media[0] = msg_mms_add_media(page, MMS_SMIL_MEDIA_IMG, "Image", "/tmp/image.jpg"); - media[1] = msg_mms_add_media(page, MMS_SMIL_MEDIA_AUDIO, NULL, "/tmp/audio.amr"); - media[2] = msg_mms_add_media(page, MMS_SMIL_MEDIA_TEXT, "Text", "/tmp/message.txt"); - attach = msg_mms_add_attachment(data, "attachment.3gp"); - - err = msg_mms_set_message_body(msgInfo, data); - - if (err != MSG_SUCCESS) - { - msg_mms_destroy_message(data); - goto free_memory; - } - - msg_mms_destroy_message(data); - - // Set Recipient Address - char number[MAX_ADDRESS_VAL_LEN]; - - memset(number, 0x00, MAX_ADDRESS_VAL_LEN); - strncpy(number, "+821030011234", sizeof(number)-1); - - err = msg_add_address(msgInfo, number, MSG_RECIPIENTS_TYPE_TO); - - if (err != MSG_SUCCESS) goto free_memory; - - err = msg_add_message(hMsgHandle, msgInfo, &sendOpt); - - if (err == MSG_SUCCESS) - printf("Saving Message is OK!"); - else - printf("Saving Message is failed!"); - -free_memory: - msg_release_message(&msgInfo); -} -@endcode -@} - -@defgroup MESSAGE_USECASES_4 Sending a SMS/MMS Message -@ingroup MESSAGE_USECASES -@{ -

Sending a SMS/MMS Message

- -- bool msg_is_sms(msg_message_t msg); -@n msg_is_sms() is a function to check whether the message type of message object is SMS or not. The first parameter is the message object which is created by msg_new_message(). The function returns true if the message object is a SMS message. Otherwise, it returns false. - -- bool msg_is_mms(msg_message_t msg); -@n msg_is_mms() is a function to check whether the message type of message object is MMS or not. The first parameter is the message object which is created by msg_new_message(). The function returns true if the message object is a MMS message. Otherwise, it returns false. - -- int msg_sms_send_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req); -@n msg_sms_send_message() is a function to send SMS through messaging framework. The first parameter is the handle which is created by msg_open_msg_handle (). The second parameter is the structure that includes the message information to send. You can get the result of sending on sent status callback. - -- int msg_mms_send_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req); -@n msg_sms_send_message() is a function to send SMS through messaging framework. The first parameter is the handle which is created by msg_open_msg_handle (). The second parameter is the structure that includes the message information to send. You can get the result of sending on sent status callback. -@code -#include -#include - -int MsgTestSendMsg(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg) -{ - if (hMsgHandle == NULL) - { - printf("Handle is NULL\n"); - return MSG_ERR_NULL_MSGHANDLE; - } - - MSG_ERROR_T err = MSG_SUCCESS; - - MSG_REQUEST_S req = {0}; - - if (pMsg == NULL) - { - printf("Message is NULL\n"); - return MSG_ERR_NULL_MESSAGE; - } - - req.msg = pMsg; - - if (msg_is_sms(req.msg)) - err = msg_sms_send_message(hMsgHandle, &req); - else if (msg_is_mms(req.msg)) - err = msg_mms_send_message(hMsgHandle, &req); - - if (err == MSG_SUCCESS) - printf("Request to Send Message is successful!!!"); - else - printf("Request to Send Message is failed!!!"); - - return err; -} -@endcode -@} - -@defgroup MESSAGE_USECASES_5 Sending Simple SMS Message -@ingroup MESSAGE_USECASES -@{ -

Simple SMS Sending

-- int msg_sms_send(const char *phone_num_list, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param); -@n msg_sms_send() is a simple function to send an SMS message. Without this API, in order to send a message the application should allocate a channel with messaging daemon for IPC, register sent-status callback function to monitor the sending result, and fulfill many member variables of MSG_MESSAGE_S. This function implicitly makes a connection with messaging daemon and registers the callback function. In addition, member variables of the MSG_MESSAGE_S structure are filled with default values except for the recipient phone_number and sms_text. -@code -#include -#include -#include -#include - -GMainLoop *mainloop; - -typedef struct { - char number[256]; - char text[256]; - char userdata[256]; -} send_data; - -void sent_status_cb(MSG_SENT_STATUS_S *pMsgStatus, void *userData) -{ - if (pMsgStatus->status == MSG_NETWORK_SEND_SUCCESS) - printf("reqId : %d MSG SENT SUCCESS !!!\n", pMsgStatus->reqId); - else - printf("reqId : %d MSG SENT FAIL !!! [%d]\n", pMsgStatus->reqId, pMsgStatus->status); -} - -// count from here -gboolean send_func(gpointer data) -{ - send_data* sms_input = (send_data*)data; - - printf("Begin to send [%s] to [%s]\n", sms_input->number, sms_input->text); - MSG_ERROR_T err = msg_sms_send(sms_input->number, sms_input->text, &sent_status_cb, (void*)sms_input->userdata); - - if (err != MSG_SUCCESS) - printf("Send failed [%d]\n", err); - - return FALSE; -} -// end - -int main(int argc, char* argv[]) -{ - if (argc != 3 && argc != 4) - { - printf("Usage: %s {phone_num_list} {sms_text} [user_data]\n", argv[0]); - printf("phone_num_list: phone_num1, phone_num2, ..., phone_numN\n"); - return 0; - } - - // Set sms input parameters : phone numbers and text - send_data sms_input = {}; - strncpy(sms_input.number, argv[1], sizeof(sms_input.number)-1); - strncpy(sms_input.text, argv[2], sizeof(sms_input.text)-1); - if (argc == 4) - strncpy(sms_input.userdata, argv[3], sizeof(sms_input.userdata)-1); - - // Add Sending Function to GMainLoop - g_idle_add(&send_func, (gpointer) &sms_input); - - // start GMainLoop - mainloop = g_main_loop_new(NULL, FALSE); - - printf("Entering GMain Loop to Receive Notifications in Thread...\n"); - - g_main_loop_run(mainloop); - - printf("==== End Test App. Bye...===\n"); - - return 0; -} -@endcode -@} - -@defgroup MESSAGE_USECASES_6 Retrieving a MMS Message -@ingroup MESSAGE_USECASES -@{ -

Retrieving a MMS Message

-- int msg_mms_retrieve_message(MSG_HANDLE_T handle, MSG_REQUEST_S* req); -@n msg_mms_retrieve_message() is a function to submit a retrieve MMS request. -@code -void MsgTestRetrieveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId) -{ - if (hMsgHandle == NULL) - { - printf("Handle is NULL"); - return; - } - - MSG_ERROR_T err = MSG_SUCCESS; - - msg_message_t msg = msg_new_message(); - MSG_SENDINGOPT_S sendOpt = {0, }; - - err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)nMsgId, msg, &sendOpt); - - if (err != MSG_SUCCESS) - printf("Get Message Failed!"); - - MSG_REQUEST_S req = {0, msg, sendOpt}; - - err = msg_mms_retrieve_message(hMsgHandle, &req); - - if (err != MSG_SUCCESS) - printf("Retrieve MMS Message Failed!"); - - msg_release_message(&msg); -} -@endcode -@} - -@defgroup MESSAGE_USECASES_7 Getting a SMS Message -@ingroup MESSAGE_USECASES -@{ -

Getting a SMS Message

-- int msg_get_message(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id, msg_message_t msg, MSG_SENDINGOPT_S *send_opt); -@n msg_get_message() is a function to get a message. The first parameter is the handle which is created by msg_open_msg_handle (). The second parameter is the message ID you want to get. The third parameter is the message object to receive the message information. The last parameter is the structure to receive the message sending options. - -- int msg_get_message_id(msg_message_t msg); -@n msg_get_message_id() is a function to get the message ID. The parameter is the message object. If the function is successful, it returns the message ID. Otherwise it returns an error in enum type (_MSG_ERROR_E). - -- int msg_get_folder_id(msg_message_t msg); -@n msg_get_folder_id() is a function to get the ID of the folder that the message is saved within. The parameter is the message object. If the function is successful, it returns one of the enum type in (_MSG_FOLDER_ID_E) . Otherwise it returns an error in enum type (_MSG_ERROR_E). - -- int msg_get_message_type(msg_message_t msg); -@n msg_get_message_type() is a function to get the message type. The parameter is the message object. If the function is successful, it returns one of the enum type in (_MSG_MESSAGE_TYPE_E). Otherwise it returns an error in enum type (_MSG_ERROR_E). - -- int msg_get_address_count(msg_message_t msg); -@n msg_get_address_count() is a function to get the number of addresses. The parameter is the message object. If the function is successful, it returns the number of addresses. Otherwise it returns an error in enum type (_MSG_ERROR_E). - -- const char* msg_get_ith_address(msg_message_t msg, int ith); -@n msg_get_ith_address() is a function to get the ith address of message. The first parameter is the message object. The second parameter is the index of address you want to get. If the function is successful, it returns the address string. Otherwise it returns NULL. - -- time_t* msg_get_time(msg_message_t msg); -@n msg_get_time() is a function to get the time value of message. The parameter is the message object. If the function is successful, it returns the time value. Otherwise it returns NULL. - -- int msg_get_network_status(msg_message_t msg); -@n msg_get_network_status() is a function to get the network status of message. The parameter is the message object. If the function is successful, it returns one of the enum type in (_MSG_NETWORK_STATUS_E). Otherwise it returns an error in enum type (_MSG_ERROR_E). - -- bool msg_is_read(msg_message_t msg); -@n msg_is_read() is a function to check whether the message was read or not. The parameter is the message object. If the message was read, it returns true. Otherwise it returns false. - -- bool msg_is_protected(msg_message_t msg); -@n msg_is_protected() is a function to check whether the message is protected or not. The parameter is the message object. If the the message was protected, it returns true. Otherwise it returns false. - -- int msg_get_message_body_size(msg_message_t msg); -@n msg_get_message_body_size() is a function to get the byte size of message. The parameter is the message object. If the function is successful, it returns the byte size of message. Otherwise it returns an error in enum type (_MSG_ERROR_E). - -- const char* msg_sms_get_message_body(msg_message_t msg); -@n msg_sms_get_message_body() is a function to get the body data of message. The first parameter is the message object. If the function is successful, it returns the body data. Otherwise it returns NULL. -@code -void MsgTestGetSmsMessage(MSG_HANDLE_T hMsgHandle, int MsgId) -{ - if (hMsgHandle == NULL) - { - printf("Handle is NULL\n"); - return; - } - - MSG_ERROR_T err = MSG_SUCCESS; - - msg_message_t msg = msg_new_message(); - MSG_SENDINGOPT_S sendOpt = {0, }; - - // Get Message - err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)MsgId, msg, &sendOpt); - - if (err != MSG_SUCCESS) goto free_memory; - - printf("msgId = %d\n", msg_get_message_id(msg)); - printf("folderId = %d\n", msg_get_folder_id(msg)); - printf("msgType = %d\n", msg_get_message_type(msg)); - printf("phone number = %s\n", msg_get_ith_address(msg, 0)); - printf("displayTime = %s\n", ctime(msg_get_time(msg))); - printf("networkStatus = %d\n", msg_get_network_status(msg)); - printf("bRead = %d\n", msg_is_read(msg)); - printf("bProtected = %d\n", msg_is_protected(msg)); - printf("dataSize = %d\n", msg_get_message_body_size(msg)); - printf("msgData = %s\n", msg_sms_get_message_body(msg)); - -free_memory: - msg_release_message(&msg); -} -@endcode -@} - -@defgroup MESSAGE_USECASES_8 Getting a MMS Message -@ingroup MESSAGE_USECASES -@{ -

Getting a MMS Message

-- int msg_mms_get_message_body(msg_message_t msg, MMS_MESSAGE_DATA_S *body); -@n msg_get_address_count. The parameter is the message object. The second parameter is the structure to receive MMS data as output. If the function is successful, it returns MSG_SUCCESS. Otherwise it returns an error in enum type (_MSG_ERROR_E). -- MMS_SMIL_REGION* msg_mms_get_smil_region(MMS_MESSAGE_DATA_S msgBody, int region_idx); -@n msg_mms_get_smil_region() is a function to get a SMIL region information. The first parameter is the structure of MMS data. The second parameter is the index of SMIL region you want to get. If the function is successful, it returns the structure which contains the SMIL region information. Otherwise it returns NULL. -- MMS_PAGE_S* msg_mms_get_page(MMS_MESSAGE_DATA_S msgBody, int page_idx); -@n msg_mms_get_page() is a function to get a SMIL page information. The first parameter is the structure of MMS data. The second parameter is the index of SMIL page you want to get. If the function is successful, it returns the structure which contains the SMIL page information. Otherwise it returns NULL. -- MMS_MEDIA_S* msg_mms_get_media(MMS_PAGE_S *page, int media_idx); -@n msg_mms_get_media() is a function to get a media information in a SMIL page. The first parameter is the structure of SMIL page you want to get the media from. The second parameter is the index of media you want to get. If the function is successful, it returns the structure which contains the media information. Otherwise it returns NULL. -- MMS_ATTACH_S* msg_mms_get_attachment(MMS_MESSAGE_DATA_S msgBody, int attach_idx); -@n msg_mms_get_attachment() is a function to get the file information of an attachment. The first parameter is the structure of MMS data. The second parameter is the index of attachment you want to get. If the function is successful, it returns the structure which contains the attachment file information. Otherwise it returns NULL. -- const char* msg_get_subject(msg_message_t msg); -@n msg_get_subject() is a function to get the subject of MMS. The parameter is the message object. If the function is successful, it returns the subject string. Otherwise it returns NULL. -@code -void MsgTestGetMmsMessage(MSG_HANDLE_T hMsgHandle, int MsgId) -{ - if (hMsgHandle == NULL) - { - printf("Handle is NULL\n"); - return; - } - - MSG_ERROR_T err = MSG_SUCCESS; - - msg_message_t msg = msg_new_message(); - MSG_SENDINGOPT_S sendOpt = {0, }; - - // Get Message - err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)MsgId, msg, &sendOpt); - - if (err != MSG_SUCCESS) goto free_memory; - - if (msg_is_mms(msg) == false) - { - printf("It is not MMS Message!"); - goto free_memory; - } - - MMS_MESSAGE_DATA_S* msgBody = msg_mms_create_message(); - - // Get MMS Body Data - msg_mms_get_message_body(msg, msgBody); - - //Print root-layout info - printf("width: %d \n - height: %d \n - nbgColor:%x \n", - msgBody->rootlayout.width.value, - msgBody->rootlayout.height.value, - msgBody->rootlayout.bgColor); - - // Print Region Info - for (int i = 0; i < msgBody->regionCnt; ++i) - { - MMS_SMIL_REGION* pRegion = msg_mms_get_smil_region(msgBody, i); - - printf("region id: %s\n - region left : %d\n - region top : %d\n - region width : %d\n - region height : %d\n - region bgColor : %x\n - region fit : %d\n", - pRegion->szID,pRegion->nLeft.value, - pRegion->nTop.value,pRegion->width.value, - pRegion->height.value, pRegion->bgColor, - pRegion->fit); - } - - // Print Page info - for (int i = 0; i< msgBody->pageCnt; ++i) - { - MMS_PAGE_S* pPage = msg_mms_get_page(msgBody, i); - - printf("page's duration: %d msec\n - page's media count: %d\n", - pPage->nDur, pPage->mediaCnt); - - // Print Contents Info - for(int j = 0; j < pPage->mediaCnt; ++j) - { - MMS_MEDIA_S* pMedia = msg_mms_get_media(pPage, j); - printf("media's filename: %s\n - media's filepath: %s\n - media's regionId: %s\n - Bold: %d Italic: %d\n", - pMedia->szFileName, - pMedia->szFilePath, - pMedia->regionId, - pMedia->sMedia.sText.bBold, - pMedia->sMedia.sText.bItalic); - - if(pMedia->drmType != MSG_DRM_TYPE_NONE) - { - printf("media's drmtype: %d\n - media's drmpath: %s\n", - pMedia->drmType, pMedia->szDrm2FullPath); - } - } - } - - for (int i = 0; i < msgBody->attachCnt; ++i) - { - MMS_ATTACH_S* pAttach = msg_mms_get_attachment(msgBody, i); - - printf("Attachment file Name: %s\n - Attachment file Path: %s\n - Attached file size: %d\n", - pAttach->szFileName, - pAttach->szFilePath, - pAttach->fileSize); - - if(pAttach->drmType != MSG_DRM_TYPE_NONE) - printf("media's drmtype: %d\n - media's drmpath: %s\n", - pAttach->drmType, pAttach->szDrm2FullPath); - } - - printf("Subject: %s\n", msg_get_subject(pMsg)); - - printf("msgId = %d", msg_get_message_id(msg)); - printf("folderId = %d", msg_get_folder_id(msg)); - printf("phone number = %s", msg_get_ith_address(msg, 0)); - printf("displayTime = %s", ctime(msg_get_time(msg))); - printf("networkStatus = %d", msg_get_network_status(msg)); - printf("bRead = %d", msg_is_read(msg)); - printf("bProtected = %d", msg_is_protected(msg)); - -free_memory: - msg_mms_destroy_message(msgBody); - - msg_release_message(&msg); -} -@endcode -@} - -@defgroup MESSAGE_USECASES_9 Delete a Message -@ingroup MESSAGE_USECASES -@{ -

Delete a Message

-- int msg_delete_message(MSG_HANDLE_T handle, MSG_MESSAGE_ID_T msg_id); -@n msg_delete_message() is a function to delete a message from message box by msg_id. -@code -void MsgTestDeleteMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId) -{ - MSG_ERROR_T err; - - if (msg_delete_message(hMsgHandle, nMsgId) != MSG_SUCCESS) - printf("Failed to delete Message"); - -} -@endcode -@} - -@defgroup MESSAGE_USECASES_10 Set/Get Message Setting -@ingroup MESSAGE_USECASES -@{ -

Set / Get Message setting

-msg_set_config() and msg_get_cofig() is used to set or to get the message setting options. MSG_SETTING_S structure includes various setting information and is shared between message application and messaging daemon. - -- int msg_set_config(MSG_HANDLE_T handle, const MSG_SETTING_S *setting); -@n msg_set_config() sets a message option. -- int msg_get_config(MSG_HANDLE_T handle, MSG_SETTING_S *setting); -@n msg_get_config() gets a message option. -@code -void MsgTestSetGeneralOpt(MSG_HANDLE_T hMsgHandle) -{ - MSG_ERROR_T err = MSG_SUCCESS; - MSG_SETTING_S setting = {0, }; - - setting.type = MSG_GENERAL_OPT; - - setting.option.generalOpt.bKeepCopy = true; - setting.option.generalOpt.alertTone = MSG_ALERT_TONE_ONCE; - - err = msg_set_config(hMsgHandle, &setting); - - if (err == MSG_SUCCESS) - printf("Setting Config Data is OK!"); - else - printf("Setting Config Data is failed!"); -} - -void MsgTestGetGeneralOpt(MSG_HANDLE_T hMsgHandle) -{ - MSG_ERROR_T err = MSG_SUCCESS; - MSG_SETTING_S setting = {0, }; - - err = msg_get_config(hMsgHandle, &setting); - - if (err == MSG_SUCCESS) - { - printf("Setting Config Data is OK!\n"); - printf("bKeepCopy : [%d], AlertTone : [%d]\n", setting.option.generalOpt.bKeepCopy, setting.option.generalOpt.alertTone); - } - else - printf("Setting Config Data is failed!\n"); -} -@endcode -@} - -@defgroup MESSAGE_USECASES_11 Filtering a Message -@ingroup MESSAGE_USECASES -@{ -

Filtering a Message

-Messaging framework provides a filtering function for incoming message. New incoming message can be blocked (Move to spam-box or discard) by adding a filtering rule. A incoming message can be blocked by its originating address or by subject matching. If address matching filter rule is applied, only messages with exactly the same phone number can be blocked. Whereas, if a subject matching filter rule is applied, all messages that include the registered subject string might be blocked. An application can add or remove a filtering rule by calling msg_add_filter() or msg_delete_filter(). - -- int msg_add_filter(MSG_HANDLE_T handle, const MSG_FILTER_S *filter); -@n msg_add_filter() inserts a filtering rule to filter list and returns filter id. -- int msg_delete_filter(MSG_HANDLE_T handle, MSG_FILTER_ID_T filter_id); -@n msg_delete_filter()removes a filtering rule from filter list by filter id -@code -void MsgTestAddFilter(MSG_HANDLE_T hMsgHandle) -{ - if (hMsgHandle == NULL) - { - printf("Handle is NULL"); - return; - } - - MSG_ERROR_T err = MSG_SUCCESS; - MSG_FILTER_S filter[2]= {0, }; - - // Add filter by address - filter[0].filterType = MSG_FILTER_BY_ADDRESS; - strncpy(filter[0].filterValue, "+821234567890", MAX_FILTER_VALUE_LEN); - - err = msg_add_filter(hMsgHandle, &filter[0]); - - if (err == MSG_SUCCESS) - printf("msg_add_filter success"); - else - printf("msg_add_filter fail - err [%d]", err); - - // Add filter by subject - filter[1].filterType = MSG_FILTER_BY_SUBJECT; - strncpy(filter[1].filterValue, "test filter", MAX_FILTER_VALUE_LEN); - - err = msg_add_filter(hMsgHandle, &filter[1]); - - if (err == MSG_SUCCESS) - printf("msg_add_filter success"); - else - printf("msg_add_filter fail - err [%d]", err); - - return; -} - -void MsgTestDeleteFilter(MSG_HANDLE_T hMsgHandle, MSG_FILTER_ID_T filterId) -{ - if (hMsgHandle == NULL) - { - printf("Handle is NULL"); - return; - } - - MSG_ERROR_T err = MSG_SUCCESS; - err = msg_delete_filter(hMsgHandle, filterId); - - if (MSG_SUCCESS == err) - { - printf("msg_delete_filter success"); - } - else - { - printf("msg_delete_filter fail - err [%d]", err); - } - - return; -} -@endcode -@} -*/ - -/** -@addtogroup MESSAGE -@{ - @defgroup MESSAGE_USECASES Use Cases -@} -*/ diff --git a/config/alert_on_call.mp3 b/config/alert_on_call.mp3 deleted file mode 100755 index c7c77d13d4f04eb74c29d46be28d817c974d1e62..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 50369 zcmXV%1yCH%)36UXG(d0;4eoNdyB_ZD?(P=cA$V{-+}#Q85;Qo$g9i_Uz{l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QLb&Zr-0aW`(XK2^W9giQ8S9eFvMYC)jl_zT zl@wa(II#Pn#EoNeg}c4Po0|=kKVlh-{G%-lQ8^DDZ0|$|oTultsGh2|Pb-lB`RrbW z@3P(JRha&gyPoZidQ7~M#wPW5qtMG|Qyh=0Zr0xC7IQRW%c5$?=z==BkMF$o{r~%2 zqgT5^6Viiz+2{>_qi0-=twq1meIp-i%#M4qM#=ChNiC{A{mj@|5hot1MIBjUHJ{ob z6row!ps}V`D`aGnhd<*@y!~Lm6K$H^W{aLQa?lr7Q@KSE%B~=p@fv?(QO)kG7@b+} z&MS}xegQeOzP1cbt=zh4ylJF4UYt+TP9<~Xk2c&b)7Gf2(=6+Fqfw(%tg8Lj_q;!6 zub$3Yw5Q|M_Nl4aWY1%(z1q+E{%tXL4;g`Ls-CfU8l zkd+vQ8G?^J?olYoQfYd=;&o!mX9*VF2Kl28KA zeYf{}-e>O9x6V9c?~oFITYC1h`F+xi=|_Fx)oS4WB(6U`{^OuV>|_0y^L}=&=QFOK zp4O|0(`WT_ALkWM{p1_`KKs&4jdyA7p66cYyZi)uJ3akuK9lS|?{!vubf4$(it|k~ zPcwIWR5Q + + + + + + + diff --git a/doc/msg_service_doc.h b/doc/msg_service_doc.h new file mode 100644 index 0000000..6617947 --- /dev/null +++ b/doc/msg_service_doc.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + + +#ifndef __MSG_SERVICE_DOC_H__ +#define __MSG_SERVICE_DOC_H__ + + +/** + * @internal + * @ingroup CAPI_MESSAGING_FRAMEWORK + * @defgroup MSG_SERVICE_FRAMEWORK msg-service + * @brief The @ref MSG_SERVICE_FRAMEWORK API provides functions to create, set properties and send or receive a SMS/MMS message. + * + * @addtogroup MSG_SERVICE_FRAMEWORK + * + * @section MSG_SERVICE_FRAMEWORK_OVERVIEW Overview + * + * The Messages API provides the following functionalities: + * + * - Creating a message + * - Setting the message properties + * - Sending a message + * - Getting a message information(s) + * - Searching for messages + * - Registering/Unregistering a callback function to check whether a message is sent successfully or not + * - Registering/Unregistering a callback function to receive notifications when an incoming message is received + * + *
+ * + */ + + +#endif /* __MSG_SERVICE_DOC_H__ */ diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt new file mode 100755 index 0000000..10c4638 --- /dev/null +++ b/externals/CMakeLists.txt @@ -0,0 +1,54 @@ +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_CXX_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall") + +########################################################## +# Define Framework Utils +########################################################## + +SET(EXTERNALS-SRCS + ${CMAKE_SOURCE_DIR}/externals/MsgSoundPlayer.cpp + ${CMAKE_SOURCE_DIR}/externals/MsgNotificationWrapper.cpp + ${CMAKE_SOURCE_DIR}/externals/MsgSpamFilter.cpp + ${CMAKE_SOURCE_DIR}/externals/MsgLbs.cpp + ${CMAKE_SOURCE_DIR}/externals/MsgSensorWrapper.cpp + ${CMAKE_SOURCE_DIR}/externals/MsgAlarm.cpp + ${CMAKE_SOURCE_DIR}/externals/MsgDevicedWrapper.cpp +) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/include/mapi + ${CMAKE_SOURCE_DIR}/include/common + ${CMAKE_SOURCE_DIR}/include/utils + ${CMAKE_SOURCE_DIR}/include/externals +) + +INCLUDE(FindPkgConfig) +pkg_check_modules(externals_pkgs REQUIRED glib-2.0 deviced mm-session alarm-service notification badge iniparser capi-appfw-application lbs-dbus mm-fileinfo mm-player mm-sound sensor feedback db-util) + +FOREACH(flag ${externals_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DFEATURE_JAVA_MMS") +IF(_TIZEN_I586_ENABLED) +ADD_DEFINITIONS("-DTIZEN_I586_ENABLED") +ENDIF(_TIZEN_I586_ENABLED) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") + +ADD_LIBRARY(${EXTERNALS-LIB} SHARED ${EXTERNALS-SRCS}) +TARGET_LINK_LIBRARIES(${EXTERNALS-LIB} ${externals_pkgs_LDFLAGS} rt ${UTILS-LIB} ${VOBJECT-LIB}) + +INSTALL(TARGETS ${EXTERNALS-LIB} DESTINATION lib COMPONENT RuntimeLibraries) + diff --git a/externals/MsgAlarm.cpp b/externals/MsgAlarm.cpp new file mode 100755 index 0000000..1c53a3f --- /dev/null +++ b/externals/MsgAlarm.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + + +#include + +#include "MsgDebug.h" +#include "MsgAlarm.h" + +#include + + +/*================================================================================================== + DEFINES +==================================================================================================*/ +typedef std::map callBackMap; + +/*================================================================================================== + VARIABLES +==================================================================================================*/ +bool alarmInit = false; +callBackMap alarmCBMap; + +/*================================================================================================== + INTERNAL FUNCTION IMPLEMENTATION +==================================================================================================*/ +int MsgAlarmCB(int alarmId, void *pUserParam) +{ + MSG_DEBUG("MsgAlarmCB is called. alarmId [%d]", alarmId); + + callBackMap::iterator it = alarmCBMap.find(alarmId); + + if (it == alarmCBMap.end()) { + MSG_DEBUG("alarmId is not found."); + } else { + msg_alarm_cb alarmCBfunction = it->second; + if (alarmCBfunction) + alarmCBfunction(alarmId); + + alarmCBMap.erase(it); + } + + return 0; +} + + +msg_error_t MsgAlarmInit() +{ + MSG_BEGIN(); + + alarmCBMap.clear(); + + int retval = alarmmgr_init("msg-service-tools"); + if (retval != ALARMMGR_RESULT_SUCCESS) { + MSG_DEBUG("alarmmgr_init error [%d]", retval); + return MSG_ERR_UNKNOWN; + } + + retval = alarmmgr_set_cb(MsgAlarmCB, NULL); + if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_set_cb() [%d]", retval); + + alarmInit = true; + + MSG_END(); + return MSG_SUCCESS; +} + +/*================================================================================================== + FUNCTION IMPLEMENTATION +==================================================================================================*/ +msg_error_t MsgAlarmRegistration(struct tm *timeInfo, msg_alarm_cb userCB, int *alarmId) +{ + MSG_BEGIN(); + + if (!alarmInit) { + MSG_DEBUG("alarm manager is not initialized. Retry once."); + MsgAlarmInit(); + if (!alarmInit) { + MSG_DEBUG("alarm manager is still not initialized. So return error."); + return MSG_ERR_UNKNOWN; + } + } + + if (timeInfo == NULL || alarmId == NULL) { + MSG_DEBUG("(timeInfo == NULL || alarmId == NULL)"); + return MSG_ERR_INVALID_PARAMETER; + } + + *alarmId = 0; + alarm_info_t* alarm_info = NULL; + alarm_id_t alarm_id = -1; + alarm_date_t target_time; + + int retval = ALARMMGR_RESULT_SUCCESS; + + alarm_info = alarmmgr_create_alarm(); + if (alarm_info == NULL) { + MSG_DEBUG("alarmmgr_create_alarm error."); + return MSG_ERR_UNKNOWN; + } + + target_time.year = timeInfo->tm_year + 1900; + target_time.month = timeInfo->tm_mon + 1; + target_time.day = timeInfo->tm_mday; + target_time.hour = timeInfo->tm_hour; + target_time.min = timeInfo->tm_min; + target_time.sec = timeInfo->tm_sec; + + MSG_DEBUG( "Alarm Time : [%d-%d-%d %d:%d:%d] ", + target_time.year, target_time.month, target_time.day, + target_time.hour, target_time.min, target_time.sec); + + retval = alarmmgr_set_time(alarm_info, target_time); + if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_set_time ret[%d]", retval); + retval = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0); + if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_set_repeat_mode ret[%d]", retval); + retval = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT); + if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_set_type ret[%d]", retval); + retval = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id); + MSG_DEBUG("alarmmgr_add_alarm_with_localtime ret[%d], alarm_id[%d]", retval, alarm_id); + + retval = alarmmgr_free_alarm(alarm_info); + if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_free_alarm ret[%d]", retval); + + *alarmId = (int)alarm_id; + + alarmCBMap[*alarmId] = userCB; + + MSG_END(); + return MSG_SUCCESS; +} + + +msg_error_t MsgAlarmRemove(int alarmId) +{ + MSG_BEGIN(); + + if (!alarmInit) { + MSG_DEBUG("alarm manager is not initialized. Retry once."); + MsgAlarmInit(); + if (!alarmInit) { + MSG_DEBUG("alarm manager is still not initialized. So return error."); + return MSG_ERR_UNKNOWN; + } + } + + if (alarmmgr_remove_alarm(alarmId) != ALARMMGR_RESULT_SUCCESS) { + MSG_DEBUG("alarmmgr_remove_alarm faild."); + return MSG_ERR_UNKNOWN; + } + + MSG_END(); + return MSG_SUCCESS; +} diff --git a/externals/MsgDevicedWrapper.cpp b/externals/MsgDevicedWrapper.cpp new file mode 100644 index 0000000..005aa77 --- /dev/null +++ b/externals/MsgDevicedWrapper.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + + +#include + +#include "MsgDebug.h" +#include "MsgMutex.h" +#include "MsgGconfWrapper.h" +#include "MsgDevicedWrapper.h" + +int g_lock_cnt = 0; +Mutex mx; + +void MsgDisplayLock() +{ + MSG_BEGIN(); + + int ret = 0; + + mx.lock(); + + if (g_lock_cnt <= 0) { + ret = display_lock_state(LCD_OFF, STAY_CUR_STATE, 0); + if (ret < 0) { + MSG_DEBUG("display_lock_state() is failed [%d]", ret); + } + } + + g_lock_cnt++; + + mx.unlock(); + + MSG_DEBUG("Display lock count = [%d]", g_lock_cnt); + + MSG_END(); +} + + +void MsgDisplayUnlock() +{ + MSG_BEGIN(); + + int ret = 0; + + mx.lock(); + + g_lock_cnt--; + + MSG_DEBUG("Display lock count = [%d]", g_lock_cnt); + + if (g_lock_cnt <= 0) { + ret = display_unlock_state(LCD_OFF, PM_RESET_TIMER); + if (ret < 0) { + MSG_DEBUG("display_lock_state() is failed [%d]", ret); + } + } + + mx.unlock(); + + MSG_END(); +} + + +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 not activated. Turn on the lcd."); + display_change_state(LCD_NORMAL); + } + + MSG_END(); +} diff --git a/externals/MsgLbs.cpp b/externals/MsgLbs.cpp new file mode 100755 index 0000000..7ffe63d --- /dev/null +++ b/externals/MsgLbs.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + + +#include "MsgDebug.h" + +extern "C" +{ + #include +} + +/*================================================================================================== + FUNCTION IMPLEMENTATION +==================================================================================================*/ + + +void MsgLbsSms(const char *msgBody, int msgSize) { + + int ret = LBS_AGPS_ERROR_NONE; + + ret = lbs_agps_sms(msgBody, msgSize); + + if (ret != LBS_AGPS_ERROR_NONE) + MSG_DEBUG("lbs_agps_sms failed. [%d]", ret); +} + + +void MsgLbsWapPush(const char *pushHeader, const char *pushBody, int pushBodySize) { + + int ret = LBS_AGPS_ERROR_NONE; + + ret = lbs_agps_wap_push(pushHeader, pushBody, pushBodySize); + + if (ret != LBS_AGPS_ERROR_NONE) + MSG_DEBUG("lbs_agps_wap_push failed. [%d]", ret); +} diff --git a/externals/MsgNotificationWrapper.cpp b/externals/MsgNotificationWrapper.cpp new file mode 100755 index 0000000..01e781e --- /dev/null +++ b/externals/MsgNotificationWrapper.cpp @@ -0,0 +1,2839 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + + +#include "MsgDebug.h" +#include "MsgCppTypes.h" +#include "MsgDrmWrapper.h" +#include "MsgContact.h" +#include "MsgStorageTypes.h" +#include "MsgUtilFile.h" +#include "MsgUtilFunction.h" +#include "MsgUtilStorage.h" +#include "MsgAlarm.h" +#include "MsgGconfWrapper.h" +#include "MsgNotificationWrapper.h" +#include "MsgSoundPlayer.h" +#include "MsgDevicedWrapper.h" +#include +#include +#include + +extern "C" +{ +#include +#include +#include +#include +#include +} + + +/*======================================================================================*/ +/* VARIABLES AND STRUCTURES */ +/*======================================================================================*/ + +int g_alarmId = 0; +bool bFeedbackInit; + +GList *msg_report_notification_list; + + +typedef struct _msg_noti_info_s +{ + msg_notification_type_t type; + int id; + int layout; + int count; + time_t time; + char sender[MSG_NOTI_TEXT_LEN_S]; + char text[MSG_NOTI_TEXT_LEN]; + char number[MSG_NOTI_TEXT_LEN_S]; + char imagePath[MAX_IMAGE_PATH_LEN + 1]; /**< Indicates the image path of contact. */ + int applist; + app_control_h svc_h; + msg_message_id_t msg_id; + unsigned char extra_data; + int sim_idx; +}MSG_NOTI_INFO_S; + +typedef struct _report_notification_s +{ + int priv_id; + char addressVal[MAX_ADDRESS_VAL_LEN+1]; +}report_notification_s; + +/*======================================================================================*/ +/* FUNCTION DEFINE */ +/*======================================================================================*/ + +notification_h getHandle(int *noti_id); + +int getPrivId(msg_notification_type_t noti_type, int sim_idx); +void updatePrivId(msg_notification_type_t noti_type, int noti_id, int sim_idx); + +void createInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info); // For addNoti() +void createInfoData(MSG_NOTI_INFO_S *noti_info, bool bTicker); // For refreshNoti() +void clearInfoData(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); + +msg_error_t getLatestMsgInfo(MSG_NOTI_INFO_S *noti_info, bool isForInstantMessage); + +void setProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); +void setTextDomain(notification_h noti_h, msg_notification_type_t noti_type); +void setText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); +void setIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); +void setPkgName(notification_h noti_h, msg_notification_type_t noti_type); +void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail); + +void setNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info, bool bFeedback); + +void MsgDeleteNotiCb(void *data); +void MsgRefreshNotiCb(void *data); + +bool isExistAddressInReportTable(const char *addr); + +// Wrapper +void createServiceHandle(app_control_h *svc_h); +void setServiceAppId(app_control_h svc_h, const char* app_id); +void setServiceOperation(app_control_h svc_h, const char* operation); +void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val); +void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val); +void setServicePackageName(app_control_h svc_h, const char* pkg_name); +void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data); + +void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir); +void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key); +void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time); +void setNotiTime(notification_h noti_h, time_t time); +void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path); +void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path); +void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path); +void setFlashNoti(void); + + +// Alarm +void MsgNotiSoundRepeatAlarmCB(int alarmId); +void MsgSoundCreateRepeatAlarm(int RepeatTime); +void MsgSoundSetRepeatAlarm(); + +void sendMsgReplyPopup(MSG_NOTI_INFO_S *noti_info); + +/*======================================================================================*/ +/* FUNCTION IMPLEMENTATION */ +/*======================================================================================*/ + + +msg_error_t MsgInsertNotification(MSG_MESSAGE_INFO_S *msg_info) +{ + MSG_BEGIN(); + + msg_error_t err = MSG_SUCCESS; + +#ifndef MSG_WEARABLE_PROFILE + + msg_notification_type_t noti_type; + + switch (msg_info->msgType.subType) + { +#ifdef MSG_NOTI_INTEGRATION + case MSG_NORMAL_SMS : + case MSG_CB_SMS : + { + if (msg_info->msgType.classType == MSG_CLASS_0) { + noti_type = MSG_NOTI_TYPE_CLASS0; + } else { + noti_type = MSG_NOTI_TYPE_NORMAL; + } + } + break; +#else + case MSG_NORMAL_SMS : + { + if (msg_info->msgType.classType == MSG_CLASS_0) { + noti_type = MSG_NOTI_TYPE_CLASS0; + } else if (msg_info->msgType.classType == MSG_CLASS_2) { + noti_type = MSG_NOTI_TYPE_SIM; + } else { + noti_type = MSG_NOTI_TYPE_NORMAL; + } + } + break; + case MSG_CB_SMS : + noti_type = MSG_NOTI_TYPE_CB; + break; +#endif + case MSG_MWI_FAX_SMS : + case MSG_MWI_EMAIL_SMS : + case MSG_MWI_OTHER_SMS : + noti_type = MSG_NOTI_TYPE_MWI; + break; + case MSG_MWI_VOICE_SMS : + noti_type = MSG_NOTI_TYPE_VOICE_1; + break; + case MSG_MWI_VOICE2_SMS : + noti_type = MSG_NOTI_TYPE_VOICE_2; + break; + case MSG_STATUS_REPORT_SMS : + noti_type = MSG_NOTI_TYPE_SMS_DELIVERY_REPORT; + break; + case MSG_DELIVERYIND_MMS : + noti_type = MSG_NOTI_TYPE_MMS_DELIVERY_REPORT; + break; + case MSG_READORGIND_MMS : + noti_type = MSG_NOTI_TYPE_MMS_READ_REPORT; + break; + default : + { +#ifdef MSG_NOTI_INTEGRATION + noti_type = MSG_NOTI_TYPE_NORMAL; +#else + if (msg_info->msgType.classType == MSG_CLASS_2) { + noti_type = MSG_NOTI_TYPE_SIM; + } else { + noti_type = MSG_NOTI_TYPE_NORMAL; + } +#endif + } + break; + } + + MSG_DEBUG("Notification type = [%d]", noti_type); + + switch (noti_type) + { + case MSG_NOTI_TYPE_NORMAL : + case MSG_NOTI_TYPE_SIM : + case MSG_NOTI_TYPE_CB : + err = MsgRefreshNotification(noti_type, true, true); + break; + case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT : + case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT : + case MSG_NOTI_TYPE_MMS_READ_REPORT : + err = MsgAddReportNotification(noti_type, msg_info); + break; + case MSG_NOTI_TYPE_VOICE_1 : + case MSG_NOTI_TYPE_VOICE_2 : + case MSG_NOTI_TYPE_MWI : + case MSG_NOTI_TYPE_CLASS0 : + err = MsgAddNotification(noti_type, msg_info); + break; + default : + MSG_DEBUG("No matching type [%d]"); + break; + } + +#endif // MSG_WEARABLE_PROFILE + + MSG_END(); + + return err; + +} + +msg_error_t MsgDeleteReportNotification(const char *addr) +{ + MSG_BEGIN(); + + msg_error_t msg_err = MSG_SUCCESS; + +#ifndef MSG_WEARABLE_PROFILE + + notification_h noti_h = NULL; + bool bNotification = true; + + MSG_NOTI_INFO_S noti_info; + memset(¬i_info, 0x00, sizeof(MSG_NOTI_INFO_S)); + + if (MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bNotification) != MSG_SUCCESS) { + MSG_DEBUG("MsgSettingGetBool is failed."); + } + + if (bNotification == false) { + MSG_DEBUG("Msg Alert notification is off."); + return msg_err; + } + + char normalAddr[MAX_ADDRESS_VAL_LEN+1]; + unsigned int list_length = g_list_length(msg_report_notification_list); + bool isDelete = false; + + MSG_DEBUG("list length [%d]", list_length); + + if (list_length > 0) { + GList *iter = g_list_first(msg_report_notification_list); + + while (iter != NULL) + { + isDelete = false; + report_notification_s *info = (report_notification_s*)(iter->data); + if (info == NULL) { + MSG_DEBUG("info is NULL!"); + return MSG_ERR_UNKNOWN; + } + + MSG_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal); + + noti_h = notification_load(NULL, info->priv_id); + if (noti_h == NULL) + { + MSG_DEBUG("notification with priv_id [%d] is NULL", info->priv_id); + isDelete = true; + } else { + memset(normalAddr, 0x00, sizeof(normalAddr)); + MsgConvertNumber(info->addressVal, normalAddr, sizeof(normalAddr)); + MSG_SEC_DEBUG("normalized number = %s", normalAddr); + + if (g_str_has_suffix(addr, normalAddr)) { + if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) { + MSG_SEC_DEBUG("delete report notification address [%s]", info->addressVal); + isDelete = true; + } + else { + MSG_DEBUG("delete notification failed"); + } + } + + notification_free(noti_h); + noti_h = NULL; + } + + iter = g_list_next(iter); + + if (isDelete) { + msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info); + if(info) { + delete info; + info = NULL; + } + } + } + } + +#endif // MSG_WEARABLE_PROFILE + + MSG_END(); + + return msg_err; +} + +msg_error_t MsgAddReportNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info) +{ + msg_error_t msg_err = MSG_SUCCESS; +#ifndef MSG_WEARABLE_PROFILE + notification_h noti_h = NULL; + + MSG_NOTI_INFO_S noti_info; + memset(¬i_info, 0x00, sizeof(MSG_NOTI_INFO_S)); + + report_notification_s *info = new report_notification_s; + memset(info, 0x00, sizeof(report_notification_s)); + + noti_info.type = noti_type; + + createInfoData(¬i_info, msg_info); + + noti_h = getHandle(¬i_info.id); + + if (noti_h == NULL) { + MSG_DEBUG("Notification handle is NULL"); + msg_err = MSG_ERR_NULL_POINTER; + goto __END_OF_REFRESH_NOTI; + } + + setNotification(noti_h, ¬i_info, true); + + info->priv_id = noti_info.id; + snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressList->addressVal); + msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info); + MSG_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal); + +__END_OF_REFRESH_NOTI : + clearInfoData(noti_h, ¬i_info); +#endif // MSG_WEARABLE_PROFILE + return msg_err; +} + +msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeedback, bool bTicker) +{ + + msg_error_t msg_err = MSG_SUCCESS; +#ifndef MSG_WEARABLE_PROFILE + notification_h noti_h = NULL; + bool bNotification = true; + bool bReplyPopup = false; + + MSG_NOTI_INFO_S noti_info; + memset(¬i_info, 0x00, sizeof(MSG_NOTI_INFO_S)); + + noti_info.type = noti_type; + + noti_info.id = getPrivId(noti_info.type, -1); + + msg_err = getLatestMsgInfo(¬i_info, false); + + if (msg_err != MSG_SUCCESS) { + MSG_DEBUG("getLatestMsgInfo() err = [%d]", msg_err); + goto __END_OF_REFRESH_NOTI; + } + + if (bTicker) { + msg_err = MsgInsertInstantMessage(noti_type); + + if (msg_err != MSG_SUCCESS) { + MSG_DEBUG(" MsgInsertInstantMessage() err = [%d]", msg_err); + goto __END_OF_REFRESH_NOTI; + } + } + + if (MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bNotification) != MSG_SUCCESS) { + MSG_DEBUG("MsgSettingGetBool is failed."); + } + + if (bNotification == false) { + MSG_DEBUG("Msg Alert notification is off."); + return msg_err; + } + + createInfoData(¬i_info, bTicker); + + noti_h = getHandle(¬i_info.id); + + if (noti_h == NULL) { + MSG_DEBUG("Notification handle is NULL"); + msg_err = MSG_ERR_NULL_POINTER; + goto __END_OF_REFRESH_NOTI; + } + + setNotification(noti_h, ¬i_info, bFeedback); + + if (MsgSettingGetBool(VCONFKEY_MESSAGE_POPUP_DISPLAY_ENABLE , &bReplyPopup) != MSG_SUCCESS) { + MSG_DEBUG("MsgSettingGetBool is failed."); + } + + if (bReplyPopup == true && bFeedback == true && noti_info.type == MSG_NOTI_TYPE_NORMAL) { + MSG_DEBUG("Msg reply popup is on."); + sendMsgReplyPopup(¬i_info); + } + +__END_OF_REFRESH_NOTI : + clearInfoData(noti_h, ¬i_info); +#endif // MSG_WEARABLE_PROFILE + return msg_err; +} + + +msg_error_t MsgAddNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info) +{ + msg_error_t msg_err = MSG_SUCCESS; +#ifndef MSG_WEARABLE_PROFILE + notification_h noti_h = NULL; + + MSG_NOTI_INFO_S noti_info = {0,}; + + noti_info.type = noti_type; + + createInfoData(¬i_info, msg_info); + + noti_h = getHandle(¬i_info.id); + + if (noti_h == NULL) { + MSG_DEBUG("Notification handle is NULL"); + msg_err = MSG_ERR_NULL_POINTER; + goto __END_OF_ADD_NOTI; + } + + setNotification(noti_h, ¬i_info, true); + +__END_OF_ADD_NOTI : + clearInfoData(noti_h, ¬i_info); +#endif // MSG_WEARABLE_PROFILE + return msg_err; +} + + +void MsgRefreshAllNotification(bool bWithSimNoti, bool bFeedback, bool bTickerNoti) +{ + MSG_BEGIN(); + +#ifndef MSG_WEARABLE_PROFILE + msg_error_t err = MSG_SUCCESS; + +// MsgDeleteNotification(MSG_NOTI_TYPE_SIM); + +#ifdef MSG_NOTI_INTEGRATION + err = MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, bFeedback, bTickerNoti); + if (err != MSG_SUCCESS) + MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_NORMAL, err); +#else + err = MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, bFeedback, bTickerNoti); + if (err != MSG_SUCCESS) + MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_NORMAL, err); + + err = MsgRefreshNotification(MSG_NOTI_TYPE_CB, bFeedback, bTickerNoti); + if (err != MSG_SUCCESS) + MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_CB, err); + + if (bWithSimNoti) { + err = MsgRefreshNotification(MSG_NOTI_TYPE_SIM, bFeedback, bTickerNoti); + if (err != MSG_SUCCESS) + MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_SIM, err); + } +#endif + + err = MsgRefreshNotification(MSG_NOTI_TYPE_FAILED, bFeedback, bTickerNoti); + if (err != MSG_SUCCESS) + MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_FAILED, err); + +#endif // MSG_WEARABLE_PROFILE + MSG_END(); +} + + +void MsgDeleteNotification(msg_notification_type_t noti_type, int simIndex) +{ +#ifndef MSG_WEARABLE_PROFILE + int noti_err = NOTIFICATION_ERROR_NONE; + + if (noti_type == MSG_NOTI_TYPE_ALL) { + + noti_err = notification_delete_all_by_type(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI); + + } else if (noti_type == MSG_NOTI_TYPE_VOICE_1 || noti_type == MSG_NOTI_TYPE_VOICE_2 || noti_type == MSG_NOTI_TYPE_SIM) { + int notiId = 0; + + notiId = getPrivId(noti_type, simIndex); + MSG_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type); + + if (notiId > 0) + noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, notiId); + + } else { + MSG_DEBUG("No matching type [%d]", noti_type); + } + + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_delete_all_by_type noti_err [%d]", noti_err); + } + + updatePrivId(noti_type, 0, simIndex); +#endif // MSG_WEARABLE_PROFILE +} + + +bool isExistAddressInReportTable(const char *addr) +{ + char sqlQuery[MAX_QUERY_LEN+1]; + char normalAddr[MAX_ADDRESS_VAL_LEN+1]; + MsgDbHandler *dbHandle = getDbHandle(); + int rowCnt = 0; + + memset(normalAddr, 0x00, sizeof(normalAddr)); + MsgConvertNumber(addr, normalAddr, sizeof(normalAddr)); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normalAddr); + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) == MSG_SUCCESS) { + dbHandle->freeTable(); + return true; + } + + dbHandle->freeTable(); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normalAddr); + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) == MSG_SUCCESS) { + dbHandle->freeTable(); + return true; + } + + dbHandle->freeTable(); + + return false; +} + + +void MsgInitReportNotiList() +{ + MSG_BEGIN(); +#ifndef MSG_WEARABLE_PROFILE + msg_report_notification_list = NULL; + + notification_h noti = NULL; + notification_list_h noti_list = NULL; + notification_list_h head_noti_list = NULL; + int noti_err = NOTIFICATION_ERROR_NONE; + bundle *b = NULL; + + noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("notification_get_list() is failed!!"); + return; + } + + head_noti_list = noti_list; + + while (noti_list != NULL) { + noti = notification_list_get_data(noti_list); + + char tempAddr[MAX_ADDRESS_VAL_LEN+1]; + memset(tempAddr, 0x00, sizeof(tempAddr)); + + noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &b); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("notification_get_excute_option() failed!!"); + break; + } + + const char *bundle_addr = bundle_get_val(b, "address"); + + if (bundle_addr != NULL) { + if (isExistAddressInReportTable(bundle_addr)) { + report_notification_s *info = new report_notification_s; + memset(info, 0x00, sizeof(report_notification_s)); + + notification_get_id(noti, NULL, &(info->priv_id)); + snprintf(info->addressVal, sizeof(info->addressVal), "%s", bundle_addr); + + msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info); + MSG_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal); + } + } + + noti_list = notification_list_get_next(noti_list); + } + + if (head_noti_list) + notification_free_list(head_noti_list); + +#endif // MSG_WEARABLE_PROFILE + MSG_END(); +} + + +msg_error_t MsgInitNoti() +{ +#ifndef MSG_WEARABLE_PROFILE + bool bNotiSvcReady = false; + + bNotiSvcReady = notification_is_service_ready(); + + if (bNotiSvcReady == true) { + MSG_DEBUG("Notification server is available"); +#ifndef MSG_NOTI_INTEGRATION + MsgDeleteNotification(MSG_NOTI_TYPE_SIM, -1); +#endif + MsgRefreshAllNotification(false, true, true); // On Booting + MsgInitReportNotiList(); + } + else { + MSG_DEBUG("Notification server is not available. Init is defered"); +#ifndef MSG_NOTI_INTEGRATION + MSG_NOTI_INFO_S *delNotiInfo = (MSG_NOTI_INFO_S *)calloc(1, sizeof(MSG_NOTI_INFO_S)); + if (delNotiInfo) { + delNotiInfo->type = MSG_NOTI_TYPE_SIM; + delNotiInfo->sim_idx = -1; + } + notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo); +#endif + notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL); + } + +#endif // MSG_WEARABLE_PROFILE + return MSG_SUCCESS; +} + + +msg_error_t MsgDeleteNoti(msg_notification_type_t noti_type, int simIndex) +{ +#ifndef MSG_WEARABLE_PROFILE + bool bNotiSvcReady = false; + + MSG_NOTI_INFO_S *delNotiInfo = (MSG_NOTI_INFO_S *)calloc(1, sizeof(MSG_NOTI_INFO_S)); + + if (delNotiInfo) { + delNotiInfo->type = noti_type; + delNotiInfo->sim_idx = simIndex; + } + + bNotiSvcReady = notification_is_service_ready(); + + if (bNotiSvcReady == true) { + MSG_DEBUG("Notification server is available"); + MsgDeleteNotiCb((void *)delNotiInfo); + } else { + MSG_DEBUG("Notification server is not available. Delete is defered"); + notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo); + } +#endif // MSG_WEARABLE_PROFILE + return MSG_SUCCESS; +} + + +msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId) +{ +#ifndef MSG_WEARABLE_PROFILE + MSG_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg); + MSG_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId); + + MsgChangePmState(); + + char *notiMsg = NULL; + bool bTicker = false; + + notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg); + MSG_DEBUG("notiMsg %s", notiMsg); + + if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 && + g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 && + g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) { + if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) { + notification_status_message_post(pTickerMsg); + } else { + notification_status_message_post(notiMsg); + } + } else { + //Show ticker popup for sending failed msg. + bTicker = true; + } + + if (notiMsg) { + free(notiMsg); + notiMsg = NULL; + } + + if (bPlayFeedback) { + if (msgId > 0 && \ + (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) + { + msg_error_t err = MSG_SUCCESS; + err = MsgRefreshNotification(MSG_NOTI_TYPE_FAILED, true, bTicker); + if (err != MSG_SUCCESS) { + MSG_DEBUG("MsgRefreshFailedNoti err=[%d]", err); + } + } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) { + msg_error_t err = MSG_SUCCESS; + err = MsgRefreshNotification(MSG_NOTI_TYPE_SIM_FULL, true, false); + if (err != MSG_SUCCESS) { + MSG_DEBUG("MsgRefreshSimFullNoti err=[%d]", err); + } + } + else { + MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_DEFAULT); + } + } +#endif // MSG_WEARABLE_PROFILE + return MSG_SUCCESS; +} + + +msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt) +{ +#ifndef MSG_WEARABLE_PROFILE + MSG_DEBUG("Start to set badge to [%d].", unreadMsgCnt); + + int err = BADGE_ERROR_NONE; + bool exist = false; + + err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist); + + if (err != BADGE_ERROR_NONE) { + MSG_DEBUG("Fail to badge_is_existing : %d", err); + return MSG_ERR_UNKNOWN; + } + + if (!exist) { + /* create badge */ + err = badge_new(MSG_DEFAULT_APP_ID); + if (err != BADGE_ERROR_NONE) { + MSG_DEBUG("Fail to badge_new : %d", err); + return MSG_ERR_UNKNOWN; + } + } + + err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt); + + if (err != BADGE_ERROR_NONE) { + MSG_DEBUG("Fail to badge_set_count : %d", err); + return MSG_ERR_UNKNOWN; + } + +#endif // MSG_WEARABLE_PROFILE + return MSG_SUCCESS; +} + + +void MsgRefreshNotiCb(void *data) +{ + MsgRefreshAllNotification(false, true, true); + MsgInitReportNotiList(); + + if (data) { + free(data); + data = NULL; + } + + return; +} + + +void MsgDeleteNotiCb(void *data) +{ + if (data) { + MSG_NOTI_INFO_S *delNotiInfo = (MSG_NOTI_INFO_S *)data; + + MsgDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx); + + free(data); + data = NULL; + } + + return; +} + + +notification_h getHandle(int *noti_id) +{ + notification_h noti_h = NULL; + + if (*noti_id > 0) { + MSG_DEBUG("Notification load"); + noti_h = notification_load(NULL, *noti_id); + if (noti_h == NULL) + MSG_DEBUG("notification_load is failed."); + } + + if (noti_h == NULL) { + MSG_DEBUG("Notification create"); + noti_h = notification_create(NOTIFICATION_TYPE_NOTI); + if (noti_h == NULL) { + MSG_DEBUG("notification_create is failed."); + return NULL; + } + + *noti_id = 0; + } + + return noti_h; +} + + +int getPrivId(msg_notification_type_t noti_type, int sim_idx) +{ + MSG_BEGIN(); + + int noti_id = 0; + + switch (noti_type) + { +#ifdef MSG_NOTI_INTEGRATION + case MSG_NOTI_TYPE_NORMAL : + case MSG_NOTI_TYPE_SIM : + case MSG_NOTI_TYPE_CB : + noti_id = MsgSettingGetInt(NOTIFICATION_PRIV_ID); + break; +#else + case MSG_NOTI_TYPE_NORMAL : + noti_id = MsgSettingGetInt(NOTIFICATION_PRIV_ID); + break; + case MSG_NOTI_TYPE_SIM : + noti_id = MsgSettingGetInt(SIM_MSG_NOTI_PRIV_ID); + break; + case MSG_NOTI_TYPE_CB : + noti_id = MsgSettingGetInt(CB_NOTI_PRIV_ID); + break; +#endif + case MSG_NOTI_TYPE_FAILED : + noti_id = MsgSettingGetInt(MSG_SENTFAIL_NOTI_ID); + break; + case MSG_NOTI_TYPE_VOICE_1 : + { + char keyName[MAX_VCONFKEY_NAME_LEN] = {0,}; + snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx); + noti_id = MsgSettingGetInt(keyName); + } + break; + case MSG_NOTI_TYPE_VOICE_2 : + { + char keyName[MAX_VCONFKEY_NAME_LEN] = {0,}; + snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx); + noti_id = MsgSettingGetInt(keyName); + } + break; + case MSG_NOTI_TYPE_SIM_FULL : + noti_id = MsgSettingGetInt(SIM_FULL_NOTI_PRIV_ID); + break; + default : + MSG_DEBUG("No matching noti type [%d]", noti_type); + break; + } + + MSG_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx); + + MSG_END(); + + return noti_id; +} + + +void updatePrivId(msg_notification_type_t noti_type, int noti_id, int sim_idx) +{ + MSG_BEGIN(); + + msg_error_t err = MSG_SUCCESS; + + MSG_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx); + + switch (noti_type) + { +#ifdef MSG_NOTI_INTEGRATION + case MSG_NOTI_TYPE_NORMAL : + case MSG_NOTI_TYPE_SIM : + case MSG_NOTI_TYPE_CB : + err = MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_id); + break; +#else + case MSG_NOTI_TYPE_NORMAL : + err = MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_id); + break; + case MSG_NOTI_TYPE_SIM : + err = MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_id); + break; + case MSG_NOTI_TYPE_CB : + err = MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_id); + break; +#endif + case MSG_NOTI_TYPE_FAILED : + err = MsgSettingSetInt(MSG_SENTFAIL_NOTI_ID, noti_id); + break; + case MSG_NOTI_TYPE_VOICE_1 : + { + char keyName[MAX_VCONFKEY_NAME_LEN] = {0,}; + snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx); + err = MsgSettingSetInt(keyName, noti_id); + } + break; + case MSG_NOTI_TYPE_VOICE_2 : + { + char keyName[MAX_VCONFKEY_NAME_LEN] = {0,}; + snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx); + err = MsgSettingSetInt(keyName, noti_id); + } + break; + case MSG_NOTI_TYPE_SIM_FULL : + err = MsgSettingSetInt(SIM_FULL_NOTI_PRIV_ID, noti_id); + break; + default: + MSG_DEBUG("No matching type [%d]", noti_type); + break; + } + + if (err != MSG_SUCCESS) + MSG_INFO("MsgSettingSetInt fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx); + + MSG_END(); +} + + +void createInfoData(MSG_NOTI_INFO_S *noti_info, bool bTicker) +{ + MSG_BEGIN(); + + createServiceHandle(¬i_info->svc_h); + + switch (noti_info->type) + { + case MSG_NOTI_TYPE_NORMAL : + { + if (noti_info->count > 1) { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; + } else { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + } + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "type", "new_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message"); + + bool bReplyPopup = false; + if (MsgSettingGetBool(VCONFKEY_MESSAGE_POPUP_DISPLAY_ENABLE , &bReplyPopup) != MSG_SUCCESS) { + MSG_DEBUG("MsgSettingGetBool is failed."); + } + + noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER; + } + break; + + case MSG_NOTI_TYPE_CB : + { + if (noti_info->count > 1) { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; + } else { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + } + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "type", "new_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + + if (bTicker) + noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK; + else + noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; + } + break; + + case MSG_NOTI_TYPE_SIM : + { + if (noti_info->count > 1) { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; + } else { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + } + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "type", "new_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + + if (bTicker) + noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK; + else + noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; + } + break; + + case MSG_NOTI_TYPE_FAILED : + { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + + noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK; + } + break; + + case MSG_NOTI_TYPE_SIM_FULL : + { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting"); + + noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; + } + break; + + default : + break; + } + + MSG_END(); +} + + +void createInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info) +{ + MSG_BEGIN(); + + if (msg_info) { + noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx); + noti_info->msg_id = msg_info->msgId; + } else { + MSG_DEBUG("msg_info is NULL"); + return; + } + + noti_info->sim_idx = msg_info->sim_idx; + + createServiceHandle(¬i_info->svc_h); + char keyName[MAX_VCONFKEY_NAME_LEN]; + + switch (noti_info->type) + { + case MSG_NOTI_TYPE_VOICE_1 : + case MSG_NOTI_TYPE_VOICE_2 : + { + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx); + noti_info->count = MsgSettingGetInt(keyName); + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + noti_info->time = msg_info->displayTime; + + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx); + char *voiceNumber = MsgSettingGetString(keyName); + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx); + char *voiceAlphaId = MsgSettingGetString(keyName); + char *dialNumber = NULL; + + MSG_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber); + + if (voiceNumber && strlen(voiceNumber)) + dialNumber = voiceNumber; + + if (voiceAlphaId && strlen(voiceAlphaId) > 0) { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId); + } else if(dialNumber && strlen(dialNumber) > 0){ + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber); + } + + if (dialNumber && strlen(dialNumber) > 0) + snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber); + + setServiceAppId(noti_info->svc_h, "org.tizen.call"); + + addServiceExtraData(noti_info->svc_h, "launch-type", "MO"); + + addServiceExtraData(noti_info->svc_h, "number", "VOICEMAIL"); + + char slot_id[5] = {0,}; + snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1); + addServiceExtraData(noti_info->svc_h, "slot_id", slot_id); + + MSG_FREE(voiceNumber); + MSG_FREE(voiceAlphaId); + } + break; + + case MSG_NOTI_TYPE_MWI : + case MSG_NOTI_TYPE_CLASS0 : + { + noti_info->count = 1; + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + noti_info->time = msg_info->displayTime; + + if (msg_info->addressList[0].displayName[0] == '\0') + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].addressVal); + else + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].displayName); + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressList[0].addressVal); + + snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText); + + if (noti_info->type == MSG_NOTI_TYPE_MWI) { + setServiceAppId(noti_info->svc_h, "org.tizen.call"); + addServiceExtraData(noti_info->svc_h, "launch-type", "MO"); + addServiceExtraData(noti_info->svc_h, "number", "VOICEMAIL"); + + char slot_id[5] = {0,}; + snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1); + addServiceExtraData(noti_info->svc_h, "slot_id", slot_id); + + } else { + setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0"); + addServiceExtraData(noti_info->svc_h, "type", "new_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + } + } + break; + + case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT : + { + noti_info->count = 1; + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + noti_info->time = msg_info->displayTime; + noti_info->extra_data = msg_info->networkStatus; + + MSG_CONTACT_INFO_S contactInfo; + memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + if (MsgGetContactInfo(&(msg_info->addressList[0]), &contactInfo) != MSG_SUCCESS) { + MSG_DEBUG("MsgGetContactInfo() fail."); + } + + snprintf(msg_info->addressList[0].displayName, sizeof(msg_info->addressList[0].displayName), "%s", contactInfo.firstName); + + if (msg_info->addressList[0].displayName[0] == '\0') + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].addressVal); + else + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].displayName); + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressList[0].addressVal); + + if (noti_info->msg_id > 0) { + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "type", "new_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + addServiceExtraData(noti_info->svc_h, "address", msg_info->addressList[0].addressVal); + } + } + break; + case MSG_NOTI_TYPE_MMS_READ_REPORT : + case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT : + { + noti_info->count = 1; + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + noti_info->time = msg_info->displayTime; + + MSG_CONTACT_INFO_S contactInfo; + memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + if (MsgGetContactInfo(&(msg_info->addressList[0]), &contactInfo) != MSG_SUCCESS) { + MSG_DEBUG("MsgGetContactInfo() fail."); + } + + snprintf(msg_info->addressList[0].displayName, sizeof(msg_info->addressList[0].displayName), "%s", contactInfo.firstName); + + if (msg_info->addressList[0].displayName[0] == '\0') + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].addressVal); + else + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].displayName); + + snprintf(noti_info->number, sizeof(noti_info->number), "%s",msg_info->addressList[0].addressVal); + + MsgDbHandler *dbhandler = getDbHandle(); + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + int report_status_type; + int report_status_value; + + if (noti_info->type == MSG_NOTI_TYPE_MMS_READ_REPORT) { + report_status_type = MSG_REPORT_TYPE_READ; + } else { + report_status_type = MSG_REPORT_TYPE_DELIVERY; + } + + char *normalNum = NULL; + if (msg_info->addressList[0].addressVal[0] != '\0') { + normalNum = msg_normalize_number(msg_info->addressList[0].addressVal); + } + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "STATUS " + "FROM %s " + "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';", + MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, normalNum); + + MSG_DEBUG("sqlQuery = [%s]", sqlQuery); + + if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) { + MSG_DEBUG("prepareQuery is failed"); + return; + } + + if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { + report_status_value = dbhandler->columnInt(0); + MSG_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value); + } else { + MSG_DEBUG("DB Query Result Fail"); + dbhandler->finalizeQuery(); + return; + } + + dbhandler->finalizeQuery(); + + if (noti_info->msg_id > 0) { + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "type", "new_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + addServiceExtraData(noti_info->svc_h, "address", msg_info->addressList[0].addressVal); + } + + noti_info->extra_data = (unsigned char)report_status_value; + } + break; + + default: + MSG_DEBUG("No matching type [%d]", noti_info->type); + break; + } + + noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK; + + MSG_END(); +} + + +void clearInfoData(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) +{ + MSG_BEGIN(); + + if (noti_h) { + notification_free(noti_h); + noti_h = NULL; + } + + if (noti_info->svc_h) { + app_control_destroy(noti_info->svc_h); + noti_info->svc_h = NULL; + } + + MSG_END(); +} + + +void setProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) +{ + MSG_BEGIN(); + + int noti_err = NOTIFICATION_ERROR_NONE; + + // set layout + noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_set_layout : %d", noti_err); + } + + // set led + noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_set_led."); + } + + // set execute option + bundle *bundle_data = NULL; + bundle *reply_msg = NULL; + + app_control_to_bundle(noti_info->svc_h, &bundle_data); + + if (bundle_data == NULL) { + MSG_DEBUG("bundle is NULL"); + } + + // set execute option and property + switch (noti_info->type) + { + case MSG_NOTI_TYPE_NORMAL : + { + if (noti_info->count > 1) { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data); + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, NULL); + } else { + if (noti_info->svc_h){ // overwrite bundle key "type" + //addServiceExtraData(noti_info->svc_h, "type", "reply"); + addServiceExtraData(noti_info->svc_h, "show_list", "list_show"); + + app_control_to_bundle(noti_info->svc_h, &reply_msg); + } + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, reply_msg); + } + + notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE); + } + break; + + case MSG_NOTI_TYPE_CB : + case MSG_NOTI_TYPE_SIM : + { + if (noti_info->count > 1) { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data); + } else { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + } + + notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY); + } + break; + + case MSG_NOTI_TYPE_FAILED : + { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE); + } + break; + + case MSG_NOTI_TYPE_SIM_FULL : + { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + } + break; + + case MSG_NOTI_TYPE_VOICE_1 : + case MSG_NOTI_TYPE_VOICE_2 : + case MSG_NOTI_TYPE_MWI : + case MSG_NOTI_TYPE_CLASS0 : + case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT : + case MSG_NOTI_TYPE_MMS_READ_REPORT : + case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT : + { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + } + break; + default: + MSG_DEBUG("No matching type for notification_set_execute_option() [%d]", noti_info->type); + break; + } + + // set applist + noti_err = notification_set_display_applist(noti_h, noti_info->applist); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_set_display_applist"); + } + + + MSG_END(); +} + + +void setTextDomain(notification_h noti_h, msg_notification_type_t noti_type) +{ + MSG_BEGIN(); + + setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR); + MSG_END(); +} + + +void setText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) +{ + MSG_BEGIN(); + + char unreadMsgCntStr[10] = {0,}; + bool bPreview; + + if (MsgSettingGetBool(MSG_SETTING_PREVIEW, &bPreview) != MSG_SUCCESS) { + MSG_DEBUG("MsgSettingGetBool is failed."); + } + + // set title and content + switch (noti_info->type) + { +#ifdef MSG_NOTI_INTEGRATION + case MSG_NOTI_TYPE_NORMAL : + case MSG_NOTI_TYPE_CB : + case MSG_NOTI_TYPE_SIM : + { + if (noti_info->count > 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + + } else { + if (bPreview) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + } + setNotiTime(noti_h, noti_info->time); + } + } + break; +#else + case MSG_NOTI_TYPE_NORMAL : + { + if (noti_info->count > 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + + } else { + if (bPreview) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + } + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); + setNotiTime(noti_h, noti_info->time); + } + } + break; + + case MSG_NOTI_TYPE_CB : + { + if (noti_info->count > 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE); + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); + setNotiTime(noti_h, noti_info->time); + + if (bPreview) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + } + } + } + break; + + case MSG_NOTI_TYPE_SIM : + { + if (noti_info->count > 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE); + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); + setNotiTime(noti_h, noti_info->time); + + if (bPreview) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + } + } + } + break; +#endif + case MSG_NOTI_TYPE_FAILED : + { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE); + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + setNotiTime(noti_h, noti_info->time); + } + break; + + case MSG_NOTI_TYPE_VOICE_1 : + case MSG_NOTI_TYPE_VOICE_2 : + { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + + if (noti_info->count == 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); + } else if (noti_info->count > 1) { + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + } else { + MSG_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count); + } + } + break; + + case MSG_NOTI_TYPE_MWI : + { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + } + break; + + case MSG_NOTI_TYPE_CLASS0 : + { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + } + break; + + case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT : + { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + + if(noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE); + } else if(noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE); + } + + setNotiTime(noti_h, noti_info->time); + } + break; + + case MSG_NOTI_TYPE_MMS_READ_REPORT : + { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + + if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE); + } + //CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false +#if 0 + else if (noti_info->extra_data == MSG_READ_REPORT_NONE) { + //notification free + } +#endif + else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ); + } + + setNotiTime(noti_h, noti_info->time); + } + break; + + case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT : + { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + + if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL); + + //CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false +#if 0 + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_NONE) { + //notification free + } +#endif + else + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE); + + setNotiTime(noti_h, noti_info->time); + } + break; + + case MSG_NOTI_TYPE_SIM_FULL : + { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL); + } + break; + default: + MSG_DEBUG("No matching type [%d]", noti_info->type); + break; + } + + MSG_END(); + +} + + +void setIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) +{ + MSG_BEGIN(); + + switch(noti_info->type) + { +#ifdef MSG_NOTI_INTEGRATION + case MSG_NOTI_TYPE_NORMAL : + case MSG_NOTI_TYPE_CB : + case MSG_NOTI_TYPE_SIM : + { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + } + break; +#else + case MSG_NOTI_TYPE_NORMAL : + { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH); + + if (noti_info->count > 1) { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + } else { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH); + } + } + break; + case MSG_NOTI_TYPE_CB : + { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH); + } + break; + case MSG_NOTI_TYPE_SIM : + { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH); + } + break; +#endif + case MSG_NOTI_TYPE_FAILED : + { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + } + break; + case MSG_NOTI_TYPE_VOICE_1 : + case MSG_NOTI_TYPE_VOICE_2 : + case MSG_NOTI_TYPE_MWI : + { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH); + } + break; + case MSG_NOTI_TYPE_CLASS0 : + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + break; + case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT : + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + break; + case MSG_NOTI_TYPE_MMS_READ_REPORT : + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + break; + case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT : + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + break; + case MSG_NOTI_TYPE_SIM_FULL : + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + break; + default: + MSG_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type); + break; + } + + MSG_END(); +} + +msg_error_t MsgInsertInstantMessage(msg_notification_type_t noti_type) +{ + MSG_BEGIN(); + + msg_error_t msg_err = MSG_SUCCESS; + char *notiMsg = NULL; + + notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI); + + setPkgName(noti, noti_type); + + switch (noti_type) + { + case MSG_NOTI_TYPE_NORMAL : + case MSG_NOTI_TYPE_SIM : + case MSG_NOTI_TYPE_CB : + { + MSG_NOTI_INFO_S noti_info; + memset(¬i_info, 0x00, sizeof(MSG_NOTI_INFO_S)); + + noti_info.type = noti_type; + msg_err = getLatestMsgInfo(¬i_info, true); + + if (msg_err == MSG_SUCCESS) { + MSG_DEBUG("Unread count [%d]", noti_info.count); + if (noti_info.count == 1) { + MSG_SEC_DEBUG("noti_info.sender [%s]",noti_info.sender); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL); + } else if (noti_info.count > 1) { + gchar *cnt_string = g_strdup_printf("%i", noti_info.count); + + notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES); + gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL); + g_free(outString); + g_free(cnt_string); + } + + setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + } + } + break; + + case MSG_NOTI_TYPE_FAILED: + { + notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL); + setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + } + break; + + default: + MSG_DEBUG("No matching type for MsgNotiType%d]", noti_type); + goto _END_OF_INSTANT_NOTI; + break; + } + + if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("Fail to notification_set_display_applist"); + + if (notification_post(noti) != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("Fail to notification_post"); + +_END_OF_INSTANT_NOTI: + + if (notification_delete(noti) != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("Fail to notification_delete"); + if (notiMsg) { + free(notiMsg); + notiMsg = NULL; + } + + if (noti) { + if (notification_free(noti) != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("Fail to notification_free"); + noti = NULL; + } + + MSG_END(); + return MSG_SUCCESS; +} + +void setPkgName(notification_h noti_h, msg_notification_type_t noti_type) +{ + MSG_BEGIN(); + + int noti_err = NOTIFICATION_ERROR_NONE; + + switch (noti_type) + { + case MSG_NOTI_TYPE_NORMAL : + case MSG_NOTI_TYPE_CB : + case MSG_NOTI_TYPE_SIM : + case MSG_NOTI_TYPE_FAILED : + case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT : + case MSG_NOTI_TYPE_MMS_READ_REPORT : + case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT : + case MSG_NOTI_TYPE_SIM_FULL : + { + noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID); + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_ERR("notification_set_pkgname() is failed, [%d]", noti_err); + } + break; + default: + MSG_DEBUG("No matching type for notification_set_pkgname() [%d]", noti_type); + break; + } + + MSG_END(); +} + + +void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail) +{ + MSG_BEGIN(); + + bool bBlockingMode = false; + + MSG_ADDRESS_INFO_S addrInfo; + memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + + MSG_CONTACT_INFO_S contactInfo; + memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + if (addressVal != NULL) { + snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal); + // Get Contact Info + if (MsgGetContactInfo(&addrInfo, &contactInfo) != MSG_SUCCESS) { + MSG_DEBUG("MsgGetContactInfo() fail."); + } + bBlockingMode = checkBlockingMode(addressVal, NULL); + } else { + MSG_DEBUG("addressVal is NULL."); + } + + char *msg_tone_file_path = NULL; + unique_ptr buf(&msg_tone_file_path, unique_ptr_deleter); + + MsgSoundPlayer::instance()->MsgGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path); + + MSG_SEC_DEBUG("Sound File [%s]", msg_tone_file_path); + + bool bPlaySound = false; + bool bPlayVibration = false; + bool bOnCall = false; + + MsgSoundPlayer::instance()->MsgGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall); + + if (!bBlockingMode) { // check blocking mode. + if (bPlaySound) { + if (msg_tone_file_path) + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path); + else { + MSG_RINGTONE_TYPE_T ringtoneType = (MSG_RINGTONE_TYPE_T)MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE); + if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); + else + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL); + } + } else { + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); + } + + if (bPlayVibration) { + if (contactInfo.vibrationPath[0] == '\0') + setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL); + else + setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath); + } else { + setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL); + } + } else { + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); + setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL); + } + MSG_END(); +} + + +void setNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info, bool bFeedback) +{ + MSG_BEGIN(); + + int noti_err = NOTIFICATION_ERROR_NONE; + + setPkgName(noti_h, noti_info->type); + + setProperty(noti_h, noti_info); + + setTextDomain(noti_h, noti_info->type); + + setText(noti_h, noti_info); + + setIcon(noti_h, noti_info); + + if (bFeedback) { + setFlashNoti(); + + if (noti_info->type == MSG_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_NOTI_TYPE_VOICE_2) + setSoundAndVibration(noti_h, noti_info->number, true); + else + setSoundAndVibration(noti_h, noti_info->number, false); + + } else { + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); + setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL); + } + + if (noti_info->id > 0) { + MSG_DEBUG("Notification update"); + noti_err = notification_update(noti_h); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_update"); + } + } else { + MSG_DEBUG("Notification insert"); + noti_err = notification_insert(noti_h, ¬i_info->id); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_insert"); + } + + updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx); + } + + MSG_END(); +} + + +msg_error_t getLatestMsgInfo(MSG_NOTI_INFO_S *noti_info, bool isForInstantMessage) +{ + MSG_BEGIN(); + + MsgDbHandler *dbhandler = getDbHandle(); + int noti_err = NOTIFICATION_ERROR_NONE; + msg_error_t msg_err = MSG_SUCCESS; + + switch (noti_info->type) + { +#ifdef MSG_NOTI_INTEGRATION + case MSG_NOTI_TYPE_NORMAL : + case MSG_NOTI_TYPE_CB : + case MSG_NOTI_TYPE_SIM : +#else + case MSG_NOTI_TYPE_NORMAL : +#endif + { + int smsUnreadCnt = 0; + int mmsUnreadCnt = 0; + + char sqlQuery[MAX_QUERY_LEN+1]; + MSG_MAIN_TYPE_T mainType; + MSG_SUB_TYPE_T subType; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); +#ifdef MSG_NOTI_INTEGRATION + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT " + "A.ADDRESS_VAL, " + "B.SUB_TYPE " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) " + "AND B.STORAGE_ID = %d " + "GROUP BY A.ADDRESS_VAL " + "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;", + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, MSG_CBMSGBOX_ID, + MSG_STORAGE_PHONE); +#else + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT " + "A.ADDRESS_VAL, " + "B.SUB_TYPE " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "GROUP BY A.ADDRESS_VAL " + "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;", + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, + MSG_STORAGE_PHONE); +#endif + MSG_DEBUG("sqlQuery [%s]", sqlQuery); + + int rowCnt = 0, index = 0; + + msg_err = dbhandler->getTable(sqlQuery, &rowCnt, &index); + MSG_DEBUG("getTable() ret=[%d], rowCnt=[%d]", msg_err, rowCnt); + + MSG_ADDRESS_INFO_S tmpAddressInfo; + + for (int i = 1; i <= rowCnt; i++) { + memset(&tmpAddressInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + + char *address = dbhandler->getColumnToString(index++); + if (address) { + snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address); + if (msg_is_valid_email(address)) { + tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL; + } else { + tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN; + } + } + subType = dbhandler->getColumnToInt(index++); + + MSG_CONTACT_INFO_S tmpContact; + memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + MsgGetContactInfo(&tmpAddressInfo, &tmpContact); + + if (rowCnt == 1) { + snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath); + } + + if (i > 1) { + g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender)); + } + + if (tmpContact.firstName[0] != '\0') + g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender)); + else if (tmpAddressInfo.addressVal[0] == '\0') { + char *senderStr = NULL; + senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + } else { + char *senderStr = NULL; + if (subType == MSG_CB_SMS) { + senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) { + senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + } else { + g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender)); + } + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + } + } + + dbhandler->freeTable(); + + MSG_SEC_DEBUG("sender info = [%s]", noti_info->sender); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + +#ifdef MSG_NOTI_INTEGRATION + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.SUBJECT, " + "B.MSG_TEXT, " + "B.MAIN_TYPE, " + "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, " + "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSG_SMS_TYPE, + MSG_MMS_TYPE, + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, MSG_CBMSGBOX_ID, + MSG_STORAGE_PHONE); +#else + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.SUBJECT, " + "B.MSG_TEXT, " + "B.MAIN_TYPE, " + "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, " + "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSG_SMS_TYPE, + MSG_MMS_TYPE, + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, + MSG_STORAGE_PHONE); +#endif + MSG_DEBUG("sqlQuery [%s]", sqlQuery); + + if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { + + smsUnreadCnt = dbhandler->columnInt(6); + mmsUnreadCnt = dbhandler->columnInt(7); + + noti_info->count = smsUnreadCnt + mmsUnreadCnt; + + if (noti_info->count > 0) { + snprintf(noti_info->number, sizeof(noti_info->number), "%s", (char*)dbhandler->columnText(0)); + + noti_info->time = (time_t)dbhandler->columnInt(1); + + noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); + + mainType = (MSG_MAIN_TYPE_T)dbhandler->columnInt(5); + + if (mainType == MSG_MMS_TYPE) { + snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); + if (noti_info->text[0] == '\0') { + char *noti_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT); + snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text); + g_free(noti_text); + } + } else { + snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(4)); + } + + MSG_DEBUG("unread message ID [%d].", noti_info->msg_id); + + if (!isForInstantMessage) { + if (noti_info->id > 0 && noti_info->count == 1 ) { + noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); + } + noti_info->id = 0; + if (MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_info->id) != MSG_SUCCESS) + MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID"); + } + MsgSettingHandleNewMsg(smsUnreadCnt, mmsUnreadCnt); + MsgInsertBadge(noti_info->count); + MsgSoundSetRepeatAlarm(); + } + } else { + + MSG_DEBUG("No unread message."); + MSG_DEBUG("notiPrivId [%d]", noti_info->id); + + dbhandler->finalizeQuery(); + + if (!isForInstantMessage) { + // No unread message. + if (noti_info->id > 0) { + noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); + } + } + + noti_info->id = 0; + + if(MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_info->id) != MSG_SUCCESS) + MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID"); + + MsgSettingHandleNewMsg(0,0); + MsgInsertBadge(0); + MsgSoundSetRepeatAlarm(); + } + + return MSG_ERR_DB_STEP; + } + } else { + MSG_DEBUG("sqlQuery [%s]", sqlQuery); + dbhandler->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + + dbhandler->finalizeQuery(); + } + break; + +#ifndef MSG_NOTI_INTEGRATION + case MSG_NOTI_TYPE_CB : + { + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.MSG_TEXT " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 " + "AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_CBMSGBOX_ID, + MSG_STORAGE_PHONE); + + if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { + MSG_ADDRESS_INFO_S addrInfo; + memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + + if (dbhandler->columnText(0) != NULL) + snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0)); + + MSG_CONTACT_INFO_S tmpContact; + memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + MsgGetContactInfo(&addrInfo, &tmpContact); + + if (tmpContact.firstName[0] != '\0') { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName); + } else if (addrInfo.addressVal[0] == '\0') { + char *senderStr = NULL; + senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + } else { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal); + } + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal); + + noti_info->time = (time_t)dbhandler->columnInt(1); + + noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); + + snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); + + MSG_DEBUG("unread CB message [%d].", noti_info->msg_id); + } else { + + MSG_DEBUG("No unread CB message."); + MSG_DEBUG("notiCbId [%d]", noti_info->id); + + dbhandler->finalizeQuery(); + + if (!isForInstantMessage) { + // No unread message. + if (noti_info->id > 0) { + noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); + } + } + + noti_info->id = 0; + + if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS) + MSG_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID"); + } + + return MSG_ERR_DB_STEP; + } + + dbhandler->finalizeQuery(); + + if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) { + MSG_DEBUG("getTable is failed"); + dbhandler->freeTable(); + return MSG_ERR_DB_GETTABLE; + } + + dbhandler->freeTable(); + MSG_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count); + } + break; + + case MSG_NOTI_TYPE_SIM : + { + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.MSG_TEXT, " + "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSG_SMS_TYPE, + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, + MSG_STORAGE_SIM); + + MSG_DEBUG("sqlQuery [%s]", sqlQuery); + + if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { + + noti_info->count = dbhandler->columnInt(4); + + if (noti_info->count > 0) { + MSG_ADDRESS_INFO_S addrInfo; + memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + + if (dbhandler->columnText(0) != NULL) + snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0)); + + MSG_CONTACT_INFO_S tmpContact; + memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + MsgGetContactInfo(&addrInfo, &tmpContact); + + if (tmpContact.firstName[0] != '\0') { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName); + } else if (addrInfo.addressVal[0] == '\0') { + char *senderStr = NULL; + senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + } else { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal); + } + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal); + + noti_info->time = (time_t)dbhandler->columnInt(1); + + noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); + + snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); + + MSG_DEBUG("unread SIM message [%d].", noti_info->msg_id); + } else { + + MSG_DEBUG("No unread SIM message."); + MSG_DEBUG("notiPrivId [%d]", noti_info->id); + + dbhandler->finalizeQuery(); + + if (!isForInstantMessage) { + // No unread message. + if (noti_info->id > 0) { + noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); + } + } + + noti_info->id = 0; + + if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS) + MSG_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID"); + } + + return MSG_ERR_DB_STEP; + } + } else { + MSG_DEBUG("sqlQuery [%s]", sqlQuery); + dbhandler->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + + dbhandler->finalizeQuery(); + } + break; +#endif + case MSG_NOTI_TYPE_FAILED : + { + MSG_MAIN_TYPE_T mainType; + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.MSG_TEXT, " + "B.SUBJECT, " + "B.MAIN_TYPE, " + "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSG_NETWORK_SEND_FAIL, + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_OUTBOX_ID, + MSG_STORAGE_PHONE); + + MSG_DEBUG("sqlQuery [%s]", sqlQuery); + + if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { + + noti_info->count = dbhandler->columnInt(6); + + if (noti_info->count > 0) { + MSG_ADDRESS_INFO_S addrInfo; + memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + + if (dbhandler->columnText(0) != NULL) + snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0)); + + MSG_CONTACT_INFO_S tmpContact; + memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + MsgGetContactInfo(&addrInfo, &tmpContact); + + if (tmpContact.firstName[0] != '\0') { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName); + } else if (addrInfo.addressVal[0] == '\0') { + char *senderStr = NULL; + senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + } else { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal); + } + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal); + + noti_info->time = (time_t)dbhandler->columnInt(1); + + noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); + + mainType = (MSG_MAIN_TYPE_T)dbhandler->columnInt(5); + + if (mainType == MSG_TYPE_MMS) + snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(4)); + else + snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); + + MSG_DEBUG("Sent failed message ID [%d].", noti_info->msg_id); + } else { + + MSG_DEBUG("No sent failed message."); + MSG_DEBUG("failedNotiId [%d]", noti_info->id); + + dbhandler->finalizeQuery(); + + if (!isForInstantMessage) { + // No unread message. + if (noti_info->id > 0) { + noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); + } + } + + noti_info->id = 0; + + if (MsgSettingSetInt(MSG_SENTFAIL_NOTI_ID, noti_info->id) != MSG_SUCCESS) + MSG_DEBUG("MsgSettingSetInt fail : MSG_SENTFAIL_NOTI_ID"); + } + + return MSG_ERR_DB_STEP; + } + } else { + MSG_DEBUG("sqlQuery [%s]", sqlQuery); + dbhandler->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + + dbhandler->finalizeQuery(); + } + break; + + case MSG_NOTI_TYPE_SIM_FULL : + break; + + default: + { + MSG_DEBUG("No matching type [%d]", noti_info->type); + return MSG_ERR_UNKNOWN; + } + break; + } + + MSG_END(); + + return MSG_SUCCESS; +} + + +void setFlashNoti(void) +{ + MSG_BEGIN(); + + int ret = 0; + + if (!bFeedbackInit) { + int ret = feedback_initialize(); + + if (ret != FEEDBACK_ERROR_NONE) { + MSG_DEBUG("Fail to feedback_initialize : [%d]", ret); + bFeedbackInit = false; + return; + } else { + MSG_DEBUG("Success to feedback_initialize."); + bFeedbackInit = true; + } + } + + ret = feedback_play_type(FEEDBACK_TYPE_LED, FEEDBACK_PATTERN_MESSAGE); + if (ret != FEEDBACK_ERROR_NONE) + MSG_DEBUG("Fail to feedback_play_type"); + + MSG_END(); +} + + +void createServiceHandle(app_control_h *svc_h) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_create(svc_h); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_DEBUG("app_control_create() is failed, [%d]", svc_err); +} + + +void setServiceAppId(app_control_h svc_h, const char* app_id) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_set_app_id(svc_h, app_id); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err); +} + + +void setServiceOperation(app_control_h svc_h, const char* operation) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_set_operation(svc_h, operation); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_DEBUG("app_control_set_operation() was failed, [%d]", svc_err); +} + + +void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err); +} + + +void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + char tempId[10]; + memset(&tempId, 0x00, sizeof(tempId)); + snprintf(tempId, sizeof(tempId), "%d", bundle_val); + + svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err); +} + + +void setServicePackageName(app_control_h svc_h, const char* pkg_name) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_set_app_id(svc_h, pkg_name); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err); +} + + +void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_send_launch_request(svc_h, callback, user_data); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_DEBUG("app_control_send_launch_request() is failed : %d", svc_err); +} + + +void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err); + } +} + + +void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("notification_set_text() was failed. [%d]", noti_err); +} + + +void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_time_to_text(noti_h, type, time); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err); +} + + +void setNotiTime(notification_h noti_h, time_t time) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_time(noti_h, time); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("notification_set_time() was failed. [%d]", noti_err); +} + + + +void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_image(noti_h, type, image_path); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("notification_set_image() was failed. [%d]", noti_err); +} + + +void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_sound(noti_h, type, path); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("notification_set_sound() was failed. [%d]", noti_err); +} + + +void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_vibration(noti_h, type, path); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("notification_set_vibration() was failed. [%d]", noti_err); +} + + +char *getTranslateText(const char *pkg_name, const char *locale_dir, const char *text) +{ + char *notiMsg = NULL; + char *lang = NULL; + + lang = vconf_get_str(VCONFKEY_LANGSET); + + setlocale(LC_MESSAGES, lang); + + bindtextdomain(pkg_name, locale_dir); + + notiMsg = dgettext(pkg_name, text); + + if (lang) { + free(lang); + lang = NULL; + } + + return g_strdup(notiMsg); +} + +void MsgNotiSoundRepeatAlarmCB(int alarmId) +{ + MSG_BEGIN(); + + MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, true, true); + +#ifndef MSG_NOTI_INTEGRATION + MsgRefreshNotification(MSG_NOTI_TYPE_SIM, true, true); + MsgRefreshNotification(MSG_NOTI_TYPE_CB, true, true); +#endif + + MSG_END(); + return; +} + + +void MsgSoundCreateRepeatAlarm(int RepeatTime) +{ + MSG_BEGIN(); + + int tmpAlarmId = 0; + time_t tmp_time; + struct tm repeat_tm; + + time(&tmp_time); + + tmp_time += (RepeatTime*60); + tzset(); + localtime_r(&tmp_time, &repeat_tm); + + if (MsgAlarmRegistration(&repeat_tm, MsgNotiSoundRepeatAlarmCB, &tmpAlarmId) != MSG_SUCCESS) { + MSG_DEBUG("MsgAlarmRegistration fail."); + return; + } + + g_alarmId = tmpAlarmId; + MSG_DEBUG("Set alarmId to [%d]", g_alarmId); + + MSG_END(); + + return; +} + + +void MsgSoundSetRepeatAlarm() +{ + int nRepeatValue = 0; + long nRepeatTime = 0; + + nRepeatValue = MsgSettingGetInt(MSG_ALERT_REP_TYPE); + + switch (nRepeatValue) + { + case MSG_ALERT_TONE_ONCE: + nRepeatTime = 0; + break; + + case MSG_ALERT_TONE_2MINS: + nRepeatTime = 2; + break; + + case MSG_ALERT_TONE_5MINS: + nRepeatTime = 5; + break; + + case MSG_ALERT_TONE_10MINS: + nRepeatTime = 10; + break; + + default: + MSG_DEBUG("Invalid Repetition time"); + break; + } + + MSG_DEBUG("nRepeatTime = %d", nRepeatTime); + + if (nRepeatTime > 0) { + if (g_alarmId > 0) { + if (MsgAlarmRemove(g_alarmId) != MSG_SUCCESS) { + MSG_FATAL("MsgAlarmRemove fail."); + } + g_alarmId = 0; + } + MsgSoundCreateRepeatAlarm(nRepeatTime); + } + + return; +} + + +void sendMsgReplyPopup(MSG_NOTI_INFO_S *noti_info) +{ + app_control_h svc_h = NULL; + + createServiceHandle(&svc_h); + + if (svc_h) { + setServicePackageName(svc_h, "org.tizen.msg-ui-reply"); + + MSG_DEBUG("Reply-popup display - Msg Id = [%d]", noti_info->msg_id); + addServiceExtraData(svc_h, "msgId", noti_info->msg_id); + + sendServicelaunchRequest(svc_h, NULL, NULL); + + app_control_destroy(svc_h); + } +} diff --git a/msg_helper/MsgSensorWrapper.cpp b/externals/MsgSensorWrapper.cpp similarity index 66% rename from msg_helper/MsgSensorWrapper.cpp rename to externals/MsgSensorWrapper.cpp index 4e615ca..1dc502d 100755 --- a/msg_helper/MsgSensorWrapper.cpp +++ b/externals/MsgSensorWrapper.cpp @@ -1,32 +1,33 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + #include "MsgDebug.h" #include "MsgCppTypes.h" #include "MsgGconfWrapper.h" -#include "MsgHelper.h" +#include "MsgSensorWrapper.h" -#include +#include /*================================================================================================== VARIABLES ==================================================================================================*/ int sensorHandler = -1; -msg_sensor_cb cbFunction = NULL; +msg_sensor_cb SensorCBFunction = NULL; /*================================================================================================== FUNCTION IMPLEMENTATION @@ -42,8 +43,9 @@ void MsgSensorCB(unsigned int event_type, sensor_event_data_t *event_data , void if(*my_event_data == MOTION_ENGIEN_TOP_TO_BOTTOM_DETECTION) { MSG_DEBUG("top to bottom event detected."); if(MsgSettingGetInt(VCONFKEY_SETAPPL_MOTION_ACTIVATION)) - if(MsgSettingGetInt(VCONFKEY_SETAPPL_USE_TURN_OVER)) - cbFunction(); + if(MsgSettingGetInt(VCONFKEY_SETAPPL_USE_TURN_OVER)) { + if(SensorCBFunction) SensorCBFunction(); + } } } @@ -62,13 +64,20 @@ msg_error_t MsgSensorConnect() void MsgSensorDisconnect() { - if(cbFunction != NULL) - cbFunction = NULL; + if(SensorCBFunction != NULL) + SensorCBFunction = NULL; if (sensorHandler < 0) return; - sf_stop(sensorHandler); + try + { + sf_stop(sensorHandler); + } + catch(int exception) + { + MSG_FATAL("sf_stop error[%d]", exception); + } sf_disconnect(sensorHandler); } @@ -84,7 +93,7 @@ msg_error_t MsgRegSensorCB(msg_sensor_cb cb) if(cb != NULL) { // regist cb. - cbFunction = cb; + SensorCBFunction = cb; } else { MSG_DEBUG("cb is NULL."); return MSG_ERR_UNKNOWN; diff --git a/externals/MsgSoundPlayer.cpp b/externals/MsgSoundPlayer.cpp new file mode 100755 index 0000000..784f4e9 --- /dev/null +++ b/externals/MsgSoundPlayer.cpp @@ -0,0 +1,793 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#include + +#include "MsgDebug.h" +#include "MsgCppTypes.h" +#include "MsgGconfWrapper.h" +#include "MsgSettingTypes.h" +#include "MsgDrmWrapper.h" +#include "MsgSensorWrapper.h" +#include "MsgUtilFile.h" +#include "MsgStorageTypes.h" +#include "MsgContact.h" +#include "MsgAlarm.h" +#include "MsgNotificationWrapper.h" +#include "MsgSoundPlayer.h" + +#include +#include +#include +#include + +#include + +/*================================================================================================== + DEFINES +==================================================================================================*/ +#define MAX_SOUND_FILE_LEN 1024 + +#define DEFAULT_ALERT_FILE "/opt/usr/share/settings/Alerts/notification_sdk.wav" + +#define HAPTIC_TEST_ITERATION 1 +#define MSG_VIBRATION_INTERVAL 3000 +#define MSG_SOUND_TIMEOUT 5500 + + +/*================================================================================================== + VARIABLES +==================================================================================================*/ +MMHandleType hPlayerHandle = 0; + +pthread_mutex_t muMmPlay = PTHREAD_MUTEX_INITIALIZER; + +/*================================================================================================== + IMPLEMENTATION OF Functions +==================================================================================================*/ +void MsgSoundRepeatAlarmCB(int alarmId) +{ + MSG_BEGIN(); + + MsgSoundPlayer::instance()->MsgSoundInitRepeatAlarm(); + + MSG_END(); + return; +} + + +void MsgSensorCBStop() +{ + MSG_BEGIN(); + +#if 0 + MsgSoundPlayer::instance()->MsgSoundPlayStop(); +#else + MsgDeleteNotification(MSG_NOTI_TYPE_ALL, -1); + + MsgRefreshNotification(MSG_NOTI_TYPE_ALL, false, false); + +#ifndef MSG_NOTI_INTEGRATION + MsgRefreshNotification(MSG_NOTI_TYPE_SIM, false, false); +#endif + +#endif + + MSG_END(); +} + + +//static gboolean MsgSoundMelodyTimeout(gpointer data) +//{ +// MSG_BEGIN(); +// +// MsgSoundPlayer::instance()->MsgSoundPlayStop(); +// +// MSG_END(); +// +// return FALSE; +//} + + +static int MsgSoundPlayCallback(int message, void *param, void *user_param) +{ + switch (message) + { + case MM_MESSAGE_BEGIN_OF_STREAM: + MSG_DEBUG("Play is started."); + break; + case MM_MESSAGE_END_OF_STREAM: + case MM_MESSAGE_STATE_INTERRUPTED: + MSG_DEBUG("EOS or Interrupted."); + MsgSoundPlayer::instance()->MsgSoundPlayStop(); + break; + case MM_MESSAGE_FILE_NOT_SUPPORTED: + case MM_MESSAGE_FILE_NOT_FOUND: + case MM_MESSAGE_DRM_NOT_AUTHORIZED: + case MM_MESSAGE_ERROR: + MSG_DEBUG("message [%d] & play with default", message); + MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_DEFAULT); + break; + default: + MSG_DEBUG("message [%d]", message); + break; + } + + return 1; +} + +/*================================================================================================== + IMPLEMENTATION OF MsgSoundPlayer - Member Functions +==================================================================================================*/ +MsgSoundPlayer* MsgSoundPlayer::pInstance = NULL; + + +MsgSoundPlayer::MsgSoundPlayer() +{ + bPlaying = false; + bVibrating = false; + bFeedbackInit = false; + g_alarmId = 0; + + defaultRingtonePath = NULL; + + defaultRingtonePath = MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR); + + if (defaultRingtonePath == NULL || MsgGetFileSize(defaultRingtonePath) < 1) { + defaultRingtonePath = (char *)DEFAULT_ALERT_FILE; + } + + MSG_DEBUG("defaultRingtonePath [%s]", defaultRingtonePath); + + if (MsgSensorConnect() == MSG_SUCCESS) { + if (MsgRegSensorCB(&MsgSensorCBStop) != MSG_SUCCESS) { + MSG_DEBUG("Fail to MsgRegSensorCB."); + MsgSensorDisconnect(); + } + } else { + MSG_DEBUG("Fail to MsgSensorConnect."); + } +} + + +MsgSoundPlayer::~MsgSoundPlayer() +{ + +} + + +MsgSoundPlayer* MsgSoundPlayer::instance() +{ + if (!pInstance) { + MSG_DEBUG("pInstance is NULL. Now creating instance."); + pInstance = new MsgSoundPlayer(); + } + + return pInstance; +} + + +void MsgSoundPlayer::MsgGetRingtonePath(char *userRingtonePath, char **msg_tone_file_path_p) +{ + MSG_RINGTONE_TYPE_T ringtoneType = (MSG_RINGTONE_TYPE_T)MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE); + + MSG_DEBUG("Ringtone type = [%d]", ringtoneType); + + if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) { + *msg_tone_file_path_p = NULL; + return; + } + + char *tmpFilePath = NULL; + *msg_tone_file_path_p = new char[MSG_FILEPATH_LEN_MAX+1]; + + char *msg_tone_file_path = *msg_tone_file_path_p; + + bool bUserRingtone = userRingtonePath && userRingtonePath[0] != '\0'; + if (bUserRingtone) { + tmpFilePath = userRingtonePath; + } else { + if (ringtoneType == MSG_RINGTONE_TYPE_DEFAULT) { + tmpFilePath = MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR); + } else { + tmpFilePath = MsgSettingGetString(MSG_SETTING_RINGTONE_PATH); + } + } + + memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1)); + + if ((tmpFilePath == NULL || MsgGetFileSize(tmpFilePath) < 1) || // wrong ringtone file path + (MsgDrmIsDrmFile(tmpFilePath) && !MsgDrmCheckRingtone(tmpFilePath))) { // check DRM + if (tmpFilePath && (strcmp(tmpFilePath, "silent") == 0)) { + MSG_DEBUG("Set ringtone to NONE(Silent)"); + msg_tone_file_path = NULL; + } else { + MSG_DEBUG("Set ringtone to defaultRingtonePath."); + strncpy(msg_tone_file_path, defaultRingtonePath, MSG_FILEPATH_LEN_MAX); + } + } else { + MSG_DEBUG("Set ringtone to tmpFilePath."); + snprintf(msg_tone_file_path, MSG_FILEPATH_LEN_MAX, "%s", tmpFilePath); + } + + if (tmpFilePath && !bUserRingtone) { + free(tmpFilePath); + tmpFilePath = NULL; + } +} + + +bool MsgIsSoundPlayOnCall(void) +{ + bool bPlayOnCall = false; + int err = MM_ERROR_NONE; + + mm_sound_device_in soundIn = MM_SOUND_DEVICE_IN_NONE; + mm_sound_device_out soundOut = MM_SOUND_DEVICE_OUT_NONE; + + err = mm_sound_get_active_device(&soundIn, &soundOut); + + if (err == MM_ERROR_NONE) { + if (soundOut & (MM_SOUND_DEVICE_OUT_RECEIVER|MM_SOUND_DEVICE_OUT_SPEAKER|MM_SOUND_DEVICE_OUT_BT_SCO)) + bPlayOnCall = true; + else + bPlayOnCall = false; + + MSG_DEBUG("mm_sound_device_out=[0x%04x],bPlayOnCall=[%d]", soundOut, bPlayOnCall); + } else { + MSG_DEBUG("mm_sound_get_active_device() err=[%d]", err); + } + + return bPlayOnCall; +} + + +void MsgSoundPlayer::MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *bPlayVibration, bool *bOnCall) +{ + MSG_BEGIN(); + + if (!bPlaySound || !bPlayVibration || !bOnCall) { + MSG_DEBUG("IN parameter is NULL."); + return; + } + + *bPlaySound = false; + *bPlayVibration = false; + *bOnCall = false; + + /* Global setting */ + bool bSoundOn = false; // sound setting on notification panel + bool bVibrationOn = false; // vibration setting on notification panel + + /* Alert setting */ +#if 0 //not used value + bool bNotiVibrationOn = false; // alert vibration + MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, &bNotiVibrationOn); +#endif + + bool bMsgSettingNoti = true; // Alert for message notification + bool bMsgSettingVibration = false; // vibration for message notification + + MsgSettingGetBool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn); + MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn); + + MsgSettingGetBool(MSG_SETTING_VIBRATION, &bMsgSettingVibration); + MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bMsgSettingNoti); + + MSG_SEC_DEBUG("Sound status : Sound mode=[%d], Manner mode=[%d]", bSoundOn, bVibrationOn); + MSG_SEC_DEBUG("Msg Setting : Noti Alert=[%d], With vibration=[%d]", bMsgSettingNoti, bMsgSettingVibration); + + int callStatus = 0; + int alertOnCall = 0; + + callStatus = MsgSettingGetInt(VCONFKEY_CALL_STATE); + MSG_DEBUG("Call Status [%d]", callStatus); + + /* Check call status */ + if (callStatus > VCONFKEY_CALL_OFF && callStatus < VCONFKEY_CALL_STATE_MAX) { + /* 1. On Call */ + + *bOnCall = true; // set call status; + + alertOnCall = MsgSettingGetInt(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT); + MSG_DEBUG("Alert On Call [%d]", alertOnCall); + + if (alertOnCall == 0) { + MSG_DEBUG("Call is active & Alert on Call - Off"); + } else if (alertOnCall == 1) { + /* set default value to true, while on Call alert sound to be played and vibration to be off. */ + bool bPlayOnCall = true; + + if (!bSoundOn) { + /* check whther sound should be on when sound setting on notification panel is off */ + bPlayOnCall = MsgIsSoundPlayOnCall(); + } + + if (bVoiceMail) { /* 1-1. Voice message */ + if (bPlayOnCall && bMsgSettingNoti) { + MSG_DEBUG("On call, Play sound - voice message"); + *bPlaySound = true; + } else { + MSG_DEBUG("On call, It doesn't play sound - voice message"); + } + + MSG_DEBUG("On call, It doesn't play vibration - voice message"); + } else { /* 1-2. Normal message */ + if (bMsgSettingNoti) { + if (bPlayOnCall) { + MSG_DEBUG("On call, Play sound"); + *bPlaySound = true; + } else { + MSG_DEBUG("On call, It doesn't play sound"); + } + + MSG_DEBUG("On call, It doesn't play vibration"); + } + } + } + } else { + /* 2. Call is not active */ + + MSG_DEBUG("Call is not active."); + int voiceRecording = MsgSettingGetInt(VCONFKEY_VOICERECORDER_STATE); + + if (bVoiceMail) { /* 2-1. Voice message */ + if (bMsgSettingNoti) { + if (bSoundOn || bVibrationOn) { + MSG_DEBUG("Play vibration - voice message."); + *bPlayVibration = true; + } else { + MSG_DEBUG("It doesn't play vibration - voice message."); + } + + MSG_DEBUG("Play sound - voice message."); + *bPlaySound = true; + + } else { + MSG_DEBUG("It doesn't play sound/vibration - voice message."); + } + } else { /* 2-1. Normal message */ + if (bMsgSettingNoti) { + if (voiceRecording != VCONFKEY_VOICERECORDER_RECORDING) { + if (bSoundOn) { + MSG_DEBUG("Play sound."); + *bPlaySound = true; + } else { + MSG_DEBUG("It doesn't play vibration."); + } + + if ((bSoundOn || bVibrationOn) && bMsgSettingVibration) { + MSG_DEBUG("Play vibration."); + *bPlayVibration = true; + } else { + MSG_DEBUG("It doesn't play vibration."); + } + } else { + MSG_DEBUG("It doesn't play sound/vibration."); + } + } else { + MSG_DEBUG("It doesn't play sound/vibration."); + } + } + } + + MSG_END(); +} + + +void MsgSoundPlayer::MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_SOUND_TYPE_T soundType) +{ + MSG_BEGIN(); + MSG_DEBUG("soundType [%d]", soundType); + + /* check camera state */ + int cameraState = 0; // camera recording state + cameraState = MsgSettingGetInt(VCONFKEY_CAMERA_STATE); + MSG_SEC_DEBUG("Camera state [%d]", cameraState); + + if (cameraState == VCONFKEY_CAMERA_STATE_RECORDING) { + MSG_END(); + return; + } + + /* get contact information */ + MSG_CONTACT_INFO_S contactInfo; + memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + if(pAddrInfo) { + // Get Contact Info + if (MsgGetContactInfo(pAddrInfo, &contactInfo) != MSG_SUCCESS) { + MSG_DEBUG("MsgGetContactInfo() fail."); + } + } + + /* get ringtone file path */ + char *msg_tone_file_path = NULL; + unique_ptr buf(&msg_tone_file_path, unique_ptr_deleter); + + if (soundType == MSG_SOUND_PLAY_EMERGENCY) { + msg_tone_file_path = new char[MAX_SOUND_FILE_LEN+1]; + memset(msg_tone_file_path, 0x00, sizeof(char)*(MAX_SOUND_FILE_LEN+1)); + } else if (soundType == MSG_SOUND_PLAY_DEFAULT) { + msg_tone_file_path = new char[MAX_SOUND_FILE_LEN+1]; + memset(msg_tone_file_path, 0x00, sizeof(char)*(MAX_SOUND_FILE_LEN+1)); + strncpy(msg_tone_file_path, DEFAULT_ALERT_FILE, MAX_SOUND_FILE_LEN); + } else { + MsgGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path); + } + + MSG_SEC_DEBUG("soundType [%d], Sound File [%s]", soundType, msg_tone_file_path); + + /* get sound play status */ + bool bPlaySound = false; + bool bPlayVibration = false; + bool bVoiceMsg = (soundType == MSG_SOUND_PLAY_VOICEMAIL)?true:false; + bool bOnCall = false; + + MsgGetPlayStatus(bVoiceMsg, &bPlaySound, &bPlayVibration, &bOnCall); + + MSG_SEC_DEBUG("sound=[%d], vibration=[%d], voice_msg?[%d], on_call?[%d]", \ + bPlaySound, bPlayVibration, bVoiceMsg, bOnCall); + + /* play sound */ + if (bPlaySound) { + int err = MM_ERROR_NONE; + + if (soundType == MSG_SOUND_PLAY_EMERGENCY) + 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"); + else + MSG_DEBUG("MM Session Init Success : %d", err); + + + MsgSoundPlayMelody(msg_tone_file_path); + + err = mm_session_finish(); + + if (err != MM_ERROR_NONE) + MSG_DEBUG("MM Session Finish Failed."); + else + MSG_DEBUG("MM Session Finish Success : %d", err); + } + + /* play vibration */ + if (bPlayVibration) { + MsgSoundPlayVibration(contactInfo.vibrationPath, bOnCall); + } + + // For repeatition. +// MsgSoundSetRepeatAlarm(); + + MSG_END(); +} + + +void MsgSoundPlayer::MsgSoundPlayStop() +{ + MSG_BEGIN(); + + pthread_mutex_lock(&muMmPlay); + + if (bPlaying == true && hPlayerHandle != 0 ) { + MSG_DEBUG("stopping the player."); + /* Stop playing media contents */ + int err = mm_player_stop(hPlayerHandle); + + if (err != MM_ERROR_NONE) { + MSG_DEBUG("stopping the player handle failed"); + } + + } + + if (hPlayerHandle != 0) { + MSG_DEBUG("destroy the player."); + + /* Uninitializing the player module */ + mm_player_unrealize(hPlayerHandle); + + /* Destroying the player handle */ + mm_player_destroy(hPlayerHandle); + } + + hPlayerHandle = 0; + bPlaying = false; + + pthread_mutex_unlock(&muMmPlay); + + MSG_END(); +} + + +void MsgSoundPlayer::MsgSoundPlayMelody(char *pMsgToneFilePath) +{ + int err = MM_ERROR_NONE; + + if (!pMsgToneFilePath) { + MSG_DEBUG("Ringtone path is NULL"); + return; + } + + pthread_mutex_lock(&muMmPlay); + + if (hPlayerHandle != 0) { + mm_player_unrealize(hPlayerHandle); + mm_player_destroy(hPlayerHandle); + hPlayerHandle = 0; + } + + err = mm_player_create(&hPlayerHandle); + + pthread_mutex_unlock(&muMmPlay); + + if (err != MM_ERROR_NONE) { + MSG_DEBUG("creating the player handle failed"); + return; + } + + /* Setting the call back function msg_callback */ + mm_player_set_message_callback(hPlayerHandle, MsgSoundPlayCallback, NULL); + + do { + /* Setting fade in/out, Volume */ + err = mm_player_set_attribute(hPlayerHandle, NULL, + "sound_volume_type", MM_SOUND_VOLUME_TYPE_NOTIFICATION, + "profile_uri", pMsgToneFilePath, strlen(pMsgToneFilePath), + "sound_priority", 2, + NULL); + + if (err != MM_ERROR_NONE) { + MSG_DEBUG("error setting the profile attr [%d]", err); + } + + err = mm_player_realize(hPlayerHandle); + + if (err != MM_ERROR_NONE) { + MSG_DEBUG("mm_player_realize() error : [%d]", err); + if (pMsgToneFilePath != defaultRingtonePath) { + pMsgToneFilePath = defaultRingtonePath; + } else { + return; + } + } + } while(err != MM_ERROR_NONE); + + + pthread_mutex_lock(&muMmPlay); + MSG_DEBUG("mm_player_start with [%s]", pMsgToneFilePath); + err = mm_player_start(hPlayerHandle); + + if (err != MM_ERROR_NONE) { + MSG_DEBUG("mm_player_start, FAIL [%x]", err); + } else { + /* Add Timer to stop playing after 5 sec. */ +// int g_contact_timer = -1; +// g_contact_timer = g_timeout_add(MSG_SOUND_TIMEOUT, (GSourceFunc)MsgSoundMelodyTimeout, NULL); + + bPlaying = true; + } + pthread_mutex_unlock(&muMmPlay); + + return; +} + + +void MsgSoundPlayer::MsgSoundPlayVibration(char *vibrationPath, bool isOnCall) +{ + MSG_BEGIN(); + + int ret = 0; + + if (!bFeedbackInit) { + int ret = feedback_initialize(); + + if (ret != FEEDBACK_ERROR_NONE) { + MSG_DEBUG("Fail to feedback_initialize : [%d]", ret); + bFeedbackInit = false; + return; + } else { + MSG_DEBUG("Success to feedback_initialize."); + bFeedbackInit = true; + } + } + + if(vibrationPath && strlen(vibrationPath)) + { + MSG_DEBUG("vibrationPath: [%s]", vibrationPath); + ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, vibrationPath); + if (ret != FEEDBACK_ERROR_NONE) + MSG_DEBUG("Fail to feedback_set_resource_path"); + ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE); + + if (ret != FEEDBACK_ERROR_NONE) + MSG_DEBUG("Fail to feedback_play_type"); + } + else + { + if (isOnCall) + ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE_ON_CALL); + else + { + ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, NULL); + if (ret != FEEDBACK_ERROR_NONE) + MSG_DEBUG("Fail to feedback_set_resource_path"); + ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE); + } + + if (ret != FEEDBACK_ERROR_NONE) + MSG_DEBUG("Fail to feedback_play_type"); + } + + MSG_END(); +} + +void MsgSoundPlayer::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."); + } else { + MSG_DEBUG("play tone success."); + } + + MSG_END(); +} + + +void MsgSoundPlayer::MsgSoundSetRepeatAlarm() +{ + int nRepeatValue = 0; + long nRepeatTime = 0; + + nRepeatValue = MsgSettingGetInt(MSG_ALERT_REP_TYPE); + + switch (nRepeatValue) + { + case MSG_ALERT_TONE_ONCE: + nRepeatTime = 0; + break; + + case MSG_ALERT_TONE_2MINS: + nRepeatTime = 2; + break; + + case MSG_ALERT_TONE_5MINS: + nRepeatTime = 5; + break; + + case MSG_ALERT_TONE_10MINS: + nRepeatTime = 10; + break; + + default: + MSG_DEBUG("Invalid Repetition time"); + break; + } + + MSG_DEBUG("nRepeatTime = %d", nRepeatTime); + + if (nRepeatTime > 0) { + if (g_alarmId > 0) { + if (MsgAlarmRemove(g_alarmId) != MSG_SUCCESS) { + MSG_FATAL("MsgAlarmRemove fail."); + } + g_alarmId = 0; + } + MsgSoundCreateRepeatAlarm(nRepeatTime); + } + + return; +} + + +void MsgSoundPlayer::MsgSoundCreateRepeatAlarm(int RepeatTime) +{ + MSG_BEGIN(); + + int alarmId = 0; + time_t tmp_time; + struct tm repeat_tm; + + time(&tmp_time); + + tmp_time += (RepeatTime*60); + tzset(); + localtime_r(&tmp_time, &repeat_tm); + + if (MsgAlarmRegistration(&repeat_tm, MsgSoundRepeatAlarmCB, &alarmId) != MSG_SUCCESS) { + MSG_DEBUG("MsgAlarmRegistration fail."); + return; + } + + g_alarmId = alarmId; + MSG_DEBUG("Set g_alarmId to [%d]", alarmId); + + MSG_END(); + + return; +} + + +int MsgSoundPlayer::MsgSoundGetUnreadMsgCnt() +{ + int unreadCnt = 0; + + // Get SMS Count + unreadCnt = MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_SMS_STATE); + + // Get MMS Count + unreadCnt += MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE); + + MSG_DEBUG("unread count : [%d]", unreadCnt); + + return unreadCnt; +} + +void MsgSoundPlayer::MsgSoundInitRepeatAlarm() +{ + MSG_BEGIN(); + + int nRepeatValue = 0; + long nRepeatTime = 0; + + g_alarmId = 0; + + if (MsgSoundGetUnreadMsgCnt() <= 0) { + MSG_DEBUG("no unread msg"); + return; + } + + nRepeatValue = MsgSettingGetInt(MSG_ALERT_REP_TYPE); + + switch (nRepeatValue) + { + case MSG_ALERT_TONE_ONCE: + nRepeatTime = 0; + break; + + case MSG_ALERT_TONE_2MINS: + nRepeatTime = 2; + break; + + case MSG_ALERT_TONE_5MINS: + nRepeatTime = 5; + break; + + case MSG_ALERT_TONE_10MINS: + nRepeatTime = 10; + break; + + default: + MSG_DEBUG("Invalid Repetition time"); + break; + } + + MSG_DEBUG("nRepeatTime = %d", nRepeatTime); + + if (nRepeatTime > 0) + MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_USER); + + MSG_END(); +} diff --git a/externals/MsgSpamFilter.cpp b/externals/MsgSpamFilter.cpp new file mode 100755 index 0000000..ec47690 --- /dev/null +++ b/externals/MsgSpamFilter.cpp @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#include "MsgDebug.h" +#include "MsgUtilFile.h" +#include "MsgContact.h" +#include "MsgCppTypes.h" +#include "MsgGconfWrapper.h" +#include "MsgSpamFilter.h" + +/*================================================================================================== + FUNCTION IMPLEMENTATION +==================================================================================================*/ +msg_error_t MsgSetFilterOperation(bool bSetFlag) +{ + MSG_BEGIN(); + + if (MsgSettingSetBool(MSG_BLOCK_MESSAGE, bSetFlag) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_BLOCK_MESSAGE); + return MSG_ERR_SET_SETTING; + } + + MSG_END(); + + return MSG_SUCCESS; +} + + +msg_error_t MsgGetFilterOperation(bool *pSetFlag) +{ + MSG_BEGIN(); + + MsgSettingGetBool(MSG_BLOCK_MESSAGE, pSetFlag); + + MSG_END(); + + return MSG_SUCCESS; +} + + +bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo) +{ + MSG_BEGIN(); + + msg_error_t err = MSG_SUCCESS; + + // ======================================================================= + // Check Unknown Sender + // ======================================================================= + bool bBlockUnknown = false; + + if (MsgSettingGetBool(MSG_BLOCK_UNKNOWN_MSG, &bBlockUnknown) == MSG_SUCCESS) { + if (bBlockUnknown == true && pMsgInfo->addressList[0].addressVal[0] == '\0') { + MSG_DEBUG("Unknown sender message!!"); + return true; + } + } + + // ======================================================================= + // Check Filter Operation + // ======================================================================= + bool filterFlag = false; + + MsgGetFilterOperation(&filterFlag); + + if (filterFlag == false) { + MSG_DEBUG("filter operation is not working"); + return false; + } + + // ======================================================================= + // Check Filter by Address + // ======================================================================= + int rowCnt = 0; + + MSG_SEC_DEBUG("pMsg->addressList[0].addressVal [%s]", pMsgInfo->addressList[0].addressVal); + + char sqlQuery[MAX_QUERY_LEN+1]; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_ID FROM %s WHERE FILTER_TYPE = %d AND '%s' LIKE (CASE WHEN LENGTH(FILTER_VALUE)>%d-1 THEN '%%'||SUBSTR(FILTER_VALUE, LENGTH(FILTER_VALUE)-%d+1) ELSE FILTER_VALUE END) AND FILTER_ACTIVE = 1 \ + UNION SELECT FILTER_ID FROM %s WHERE FILTER_TYPE = %d AND '%s' LIKE SUBSTR(FILTER_VALUE,1)||'%%' AND FILTER_ACTIVE = 1 \ + UNION SELECT FILTER_ID FROM %s WHERE FILTER_TYPE = %d AND '%s' LIKE '%%'||SUBSTR(FILTER_VALUE,1)||'%%' AND FILTER_ACTIVE = 1 \ + UNION SELECT FILTER_ID FROM %s WHERE FILTER_TYPE = %d AND '%s' LIKE '%%'||SUBSTR(FILTER_VALUE,1) AND FILTER_ACTIVE = 1;", + MSGFW_FILTER_TABLE_NAME, MSG_FILTER_BY_ADDRESS_SAME, pMsgInfo->addressList[0].addressVal, MsgContactGetMinMatchDigit(), MsgContactGetMinMatchDigit(), + MSGFW_FILTER_TABLE_NAME, MSG_FILTER_BY_ADDRESS_START, pMsgInfo->addressList[0].addressVal, + MSGFW_FILTER_TABLE_NAME, MSG_FILTER_BY_ADDRESS_INCLUDE, pMsgInfo->addressList[0].addressVal, + MSGFW_FILTER_TABLE_NAME, MSG_FILTER_BY_ADDRESS_END, pMsgInfo->addressList[0].addressVal); + + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); + + if (rowCnt > 0) { + MSG_SEC_DEBUG("Msg is Filtered by Address : [%s]", pMsgInfo->addressList[0].addressVal); + pDbHandle->freeTable(); + pMsgInfo->folderId = MSG_SPAMBOX_ID; + return true; + } else { + MSG_SEC_DEBUG("Msg is NOT Filtered by Address : [%s]", pMsgInfo->addressList[0].addressVal); + pDbHandle->freeTable(); + } + + // ======================================================================= + // Check Filter by Subject + // ======================================================================= + // Get Filter List + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_VALUE FROM %s WHERE FILTER_TYPE = %d;", + MSGFW_FILTER_TABLE_NAME, MSG_FILTER_BY_WORD); + + rowCnt = 0; + + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); + + if (err != MSG_SUCCESS) { + MSG_DEBUG("Fail to getTable()."); + pDbHandle->freeTable(); + return false; + } + + char filterValue[MAX_FILTER_VALUE_LEN+1]; + + char* pData = NULL; + unique_ptr buf(&pData, unique_ptr_deleter); + + int fileSize = 0; + bool bFiltered = false; + + for (int i = 1; i <= rowCnt; i++) + { + memset(filterValue, 0x00, sizeof(filterValue)); + + pDbHandle->getColumnToString(i, MAX_FILTER_VALUE_LEN, filterValue); + + MSG_DEBUG("filterValue [%s]", filterValue); + + if (strlen(filterValue) <= 0) + continue; + + if (pMsgInfo->msgType.mainType == MSG_SMS_TYPE && pMsgInfo->msgType.subType == MSG_NORMAL_SMS) { + if (pMsgInfo->bTextSms == false) { + if (pData) { + delete[] pData; + pData = NULL; + } + + if (MsgOpenAndReadFile(pMsgInfo->msgData, &pData, &fileSize) == false) { + pDbHandle->freeTable(); + return false; + } + MSG_DEBUG("file data [%s]", pData); + } else { + if (pMsgInfo->dataSize > 0) { + if (pData) { + delete[] pData; + pData = NULL; + } + + pData = new char[pMsgInfo->dataSize+1]; + + strncpy(pData, pMsgInfo->msgText, pMsgInfo->dataSize); + pData[strlen(pMsgInfo->msgText)] = '\0'; + } + } + } else if(pMsgInfo->msgType.mainType == MSG_MMS_TYPE) { + if (strlen(pMsgInfo->subject) > 0) { + if (pData) { + delete[] pData; + pData = NULL; + } + + pData = new char[strlen(pMsgInfo->subject)+1]; + + strncpy(pData, pMsgInfo->subject, strlen(pMsgInfo->subject)); + pData[strlen(pMsgInfo->subject)] = '\0'; + } + } + + // NULL value check + if (pData == NULL) { + MSG_DEBUG("pData is NULL"); + + bFiltered = false; + break; + } + + MSG_DEBUG("pData [%s]", pData); + + if (strcasestr(pData, filterValue) != NULL) { +#if 0 + MSG_CONTACT_INFO_S contactInfo; + memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + // Get Contact Info + if (MsgGetContactInfo(&(pMsgInfo->addressList[0]), &contactInfo) == MSG_SUCCESS) { + if (contactInfo.contactId > 0) { + MSG_SEC_DEBUG("Msg is Filtered by Subject [%s] Data [%s], but address is in contact. Skip.", filterValue, pData); + } else { + MSG_DEBUG("Msg is Filtered by Subject [%s] Data [%s]", filterValue, pData); + bFiltered = true; + break; + } + } else { + MSG_DEBUG("MsgGetContactInfo() fail."); + } +#else + MSG_DEBUG("Msg is Filtered by Subject [%s] Data [%s]", filterValue, pData); + bFiltered = true; + break; +#endif + } + } + + pDbHandle->freeTable(); + + if (bFiltered == true) { + MSG_DEBUG("Msg is Filtered by Subject"); + + pMsgInfo->folderId = MSG_SPAMBOX_ID; + + return true; + } else { + MSG_DEBUG("Msg is NOT Filtered by Subject"); + } + + MSG_END(); + + return false; +} + + +bool MsgCheckFilterByWord(MsgDbHandler *pDbHandle, const char *pMsgText) +{ + MSG_BEGIN(); + + if (!pMsgText) { + MSG_DEBUG("pMsgText is NULL"); + return false; + } + + msg_error_t err = MSG_SUCCESS; + + // ======================================================================= + // Check Filter Operation + // ======================================================================= + bool filterFlag = false; + + MsgGetFilterOperation(&filterFlag); + + if (filterFlag == false) { + MSG_DEBUG("filter operation is not working"); + return false; + } + + int rowCnt = 0; + char sqlQuery[MAX_QUERY_LEN+1]; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + + // ======================================================================= + // Check Filter by Word + // ======================================================================= + // Get Filter List + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_VALUE FROM %s WHERE FILTER_TYPE = %d;", + MSGFW_FILTER_TABLE_NAME, MSG_FILTER_BY_WORD); + + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); + + if (err != MSG_SUCCESS) { + MSG_DEBUG("Fail to getTable()."); + pDbHandle->freeTable(); + return false; + } + + char filterValue[MAX_FILTER_VALUE_LEN+1]; + bool bFiltered = false; + + for (int i = 1; i <= rowCnt; i++) + { + memset(filterValue, 0x00, sizeof(filterValue)); + + pDbHandle->getColumnToString(i, MAX_FILTER_VALUE_LEN, filterValue); + + MSG_DEBUG("filterValue [%s]", filterValue); + + if (strlen(filterValue) <= 0) continue; + + if (strcasestr(pMsgText, filterValue) != NULL) { + MSG_DEBUG("Msg is Filtered by Word [%s] ", filterValue); + bFiltered = true; + break; + } + } + + pDbHandle->freeTable(); + + MSG_END(); + + return bFiltered; +} + + diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index 3494f19..596bba3 100755 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -8,7 +8,7 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "") 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_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall") ######################################################### # Define Plugin Manager @@ -16,11 +16,10 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall") SET(PLUGIN-MANAGER-SRCS ${CMAKE_SOURCE_DIR}/framework/plugin-manager/MsgPluginManager.cpp - ${CMAKE_SOURCE_DIR}/framework/plugin-manager/MsgPluginConfig.cpp ) INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/include/mapi + ${CMAKE_SOURCE_DIR}/include/mapi ${CMAKE_SOURCE_DIR}/include/common ${CMAKE_SOURCE_DIR}/include/framework ${CMAKE_SOURCE_DIR}/include/utils @@ -33,7 +32,7 @@ FOREACH(flag ${plugin_manager_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") @@ -62,27 +61,29 @@ SET(FW-HANDLER-SRCS ) INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/include/mapi + ${CMAKE_SOURCE_DIR}/include/mapi ${CMAKE_SOURCE_DIR}/include/common ${CMAKE_SOURCE_DIR}/include/framework ${CMAKE_SOURCE_DIR}/include/utils + ${CMAKE_SOURCE_DIR}/include/externals + ${CMAKE_SOURCE_DIR}/vobject-engine/include ) INCLUDE(FindPkgConfig) -pkg_check_modules(fw_handler_pkgs REQUIRED glib-2.0 dlog vconf capi-appfw-application) +pkg_check_modules(fw_handler_pkgs REQUIRED glib-2.0 gio-2.0 dlog vconf capi-appfw-application) FOREACH(flag ${fw_handler_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -std=c++0x") ENDFOREACH(flag) -SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") ADD_LIBRARY(${FW-HANDLER-LIB} SHARED ${FW-HANDLER-SRCS}) -TARGET_LINK_LIBRARIES(${FW-HANDLER-LIB} ${fw_handler_pkgs_LDFLAGS} ${UTILS-LIB} ${PLUGIN-MANAGER-LIB}) +TARGET_LINK_LIBRARIES(${FW-HANDLER-LIB} ${fw_handler_pkgs_LDFLAGS} ${UTILS-LIB} ${EXTERNALS-LIB} ${PLUGIN-MANAGER-LIB}) INSTALL(TARGETS ${FW-HANDLER-LIB} DESTINATION lib COMPONENT RuntimeLibraries) @@ -99,9 +100,10 @@ SET(TRANS-MANAGER-SRCS ) INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/include/mapi + ${CMAKE_SOURCE_DIR}/include/mapi ${CMAKE_SOURCE_DIR}/include/common ${CMAKE_SOURCE_DIR}/include/framework + ${CMAKE_SOURCE_DIR}/include/externals ${CMAKE_SOURCE_DIR}/include/utils ) @@ -112,14 +114,14 @@ FOREACH(flag ${trans_manager_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") ADD_LIBRARY(${TRANS-MANAGER-LIB} SHARED ${TRANS-MANAGER-SRCS}) -TARGET_LINK_LIBRARIES(${TRANS-MANAGER-LIB} ${trans_manager_pkgs_LDFLAGS} ${UTILS-LIB} ${FW-HANDLER-LIB}) +TARGET_LINK_LIBRARIES(${TRANS-MANAGER-LIB} ${trans_manager_pkgs_LDFLAGS} ${UTILS-LIB} ${EXTERNALS-LIB} ${FW-HANDLER-LIB}) INSTALL(TARGETS ${TRANS-MANAGER-LIB} DESTINATION lib COMPONENT RuntimeLibraries) @@ -132,27 +134,31 @@ SET(MAIN-SRCS ) INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/include/mapi + ${CMAKE_SOURCE_DIR}/include/mapi ${CMAKE_SOURCE_DIR}/include/common ${CMAKE_SOURCE_DIR}/include/framework + ${CMAKE_SOURCE_DIR}/include/externals ${CMAKE_SOURCE_DIR}/include/utils ) INCLUDE(FindPkgConfig) -pkg_check_modules(main_pkgs REQUIRED glib-2.0 dbus-glib-1 dlog vconf) +pkg_check_modules(main_pkgs REQUIRED glib-2.0 dlog vconf db-util) FOREACH(flag ${main_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") +SET(server_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") ADD_EXECUTABLE(${PROJECT_NAME} ${MAIN-SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${main_pkgs_LDFLAGS} ${UTILS-LIB} ${PLUGIN-MANAGER-LIB} ${TRANS-MANAGER-LIB} ${FW-HANDLER-LIB}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${main_pkgs_LDFLAGS} ${UTILS-LIB} ${EXTERNALS-LIB} ${PLUGIN-MANAGER-LIB} ${TRANS-MANAGER-LIB} ${FW-HANDLER-LIB}) + +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${server_CXX_FLAGS}") INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) diff --git a/framework/deliver-handler/MsgDeliverHandler.cpp b/framework/deliver-handler/MsgDeliverHandler.cpp index 8e0af31..0b4e336 100755 --- a/framework/deliver-handler/MsgDeliverHandler.cpp +++ b/framework/deliver-handler/MsgDeliverHandler.cpp @@ -1,21 +1,20 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -// for sl message browser launch -#include +#include #include "MsgDebug.h" #include "MsgUtilFile.h" @@ -28,36 +27,183 @@ #include "MsgStorageHandler.h" #include "MsgDeliverHandler.h" #include "MsgNotificationWrapper.h" +#include "MsgDevicedWrapper.h" /*================================================================================================== VARIABLES ==================================================================================================*/ -extern MsgDbHandler dbHandle; - /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ + +void MsgPlayTTSMode(MSG_SUB_TYPE_T msgSubType, msg_message_id_t msgId, bool isFavorites) +{ + MSG_BEGIN(); + + bool bNotification = true; + + if (MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bNotification) != MSG_SUCCESS) { + MSG_DEBUG("MsgSettingGetBool is failed."); + } + + if (bNotification == false) { + MSG_DEBUG("Msg Alert notification is off."); + return; + } + + bool isTTSOn = false; + MsgSettingGetBool(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, &isTTSOn); + MSG_DEBUG("VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE [%d]", isTTSOn); + + if(isTTSOn) { + + bool isVoiceMail = false; + + if (msgSubType == MSG_MWI_VOICE_SMS) { + bool isVoiceMailOn = false; + MsgSettingGetBool(VCONFKEY_SETAPPL_DRIVINGMODE_NEWVOICEMAILS, &isVoiceMailOn); + MSG_DEBUG("VCONFKEY_SETAPPL_DRIVINGMODE_NEWVOICEMAILS [%d]", isVoiceMailOn); + if (isVoiceMailOn) { + isVoiceMail = true; + } else { + return; + } + } else { + bool isTTSMsgOn = false; + MsgSettingGetBool(VCONFKEY_SETAPPL_DRIVINGMODE_MESSAGE, &isTTSMsgOn); + MSG_DEBUG("VCONFKEY_SETAPPL_DRIVINGMODE_MESSAGE [%d]", isTTSMsgOn); + if (!isTTSMsgOn || !isFavorites) { + return; + } + } + + app_control_h svc_h; + + int ret = APP_CONTROL_ERROR_NONE; + + ret = app_control_create(&svc_h); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_create() is failed : %d", ret); + app_control_destroy(svc_h); + return; + } + + ret = app_control_set_app_id(svc_h, "org.tizen.msg-ui-tts-play"); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_set_app_id() is failed : %d", ret); + app_control_destroy(svc_h); + return; + } + + if (isVoiceMail) { + ret = app_control_add_extra_data(svc_h, "type", "voicemail"); + } else { + char tmpStrMsgId[10]; + memset(&tmpStrMsgId, 0x00, sizeof(tmpStrMsgId)); + snprintf(tmpStrMsgId, sizeof(tmpStrMsgId), "%d", msgId); + MSG_DEBUG("tmpStrMsgId [%s]", tmpStrMsgId); + ret = app_control_add_extra_data(svc_h, "msgId", tmpStrMsgId); + } + + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_add_extra_data() is failed : %d", ret); + app_control_destroy(svc_h); + return; + } + + ret = app_control_send_launch_request(svc_h, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_send_launch_request() is failed : %d", ret); + app_control_destroy(svc_h); + return; + } + + app_control_destroy(svc_h); + } + + MsgChangePmState(); + + MSG_END(); +} + + +void MsgLaunchClass0(msg_message_id_t msgId) +{ + MSG_BEGIN(); + + app_control_h svc_h; + + int ret = APP_CONTROL_ERROR_NONE; + + ret = app_control_create(&svc_h); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_create() is failed : %d", ret); + app_control_destroy(svc_h); + return; + } + + ret = app_control_set_app_id(svc_h, "org.tizen.msg-ui-class0"); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_set_app_id() is failed : %d", ret); + app_control_destroy(svc_h); + return; + } + + ret = app_control_add_extra_data(svc_h, "type", "msg_id"); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_add_extra_data() is failed : %d", ret); + app_control_destroy(svc_h); + return; + } + + char tmpStrMsgId[10]; + memset(&tmpStrMsgId, 0x00, sizeof(tmpStrMsgId)); + snprintf(tmpStrMsgId, sizeof(tmpStrMsgId), "%d", msgId); + MSG_DEBUG("tmpStrMsgId [%s]", tmpStrMsgId); + ret = app_control_add_extra_data(svc_h, "msgId", tmpStrMsgId); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_add_extra_data() is failed : %d", ret); + app_control_destroy(svc_h); + return; + } + + ret = app_control_send_launch_request(svc_h, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_send_launch_request() is failed : %d", ret); + app_control_destroy(svc_h); + return; + } + + app_control_destroy(svc_h); + + MSG_END(); +} + + msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_request_id_t reqID) { MSG_BEGIN(); msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); MSG_DEBUG(" msgtype subtype is [%d]", pMsgInfo->msgType.subType); if (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { - // keep origianl subType + // keep original subType MSG_SUB_TYPE_T subType = pMsgInfo->msgType.subType; /* If Retrieve Failed, Msg SubType is remained as Notification Ind */ - if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_FAIL) + if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_FAIL) { + pMsgInfo->folderId = MSG_INBOX_ID; pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS; + } - err = MsgStoUpdateMMSMessage(pMsgInfo); - - if (err == MSG_SUCCESS) - MSG_DEBUG("Command Handle Success : MsgStoUpdateMessage()"); +// err = MsgStoUpdateMMSMessage(pMsgInfo); +// +// if (err == MSG_SUCCESS) +// MSG_DEBUG("Command Handle Success : MsgStoUpdateMessage()"); if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) { MSG_DEBUG("### MSG_NETWORK_RETRIEVE_SUCCESS ###"); @@ -65,6 +211,8 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques // MMS Received Ind Process Func MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(pMsgInfo->msgType.mainType); + if (plg == NULL) + return MSG_ERR_NULL_POINTER; //Contents of msg Data was removed and replaced to retrievedFilePath // NOTICE:: now it was moved to handleEvent in MsgListnerThread @@ -73,6 +221,12 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques return MSG_ERR_STORAGE_ERROR; } + err = MsgStoUpdateMMSMessage(pMsgInfo);//For Text Update + + if (err == MSG_SUCCESS) + MSG_DEBUG("Command Handle Success : MsgStoUpdateMessage()"); + + MSG_DEBUG(" ######################### MESSAGE UPDATE COMPLETED!!! ######################"); bool readStatus = false; @@ -80,47 +234,46 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques MsgStoGetReadStatus(pMsgInfo->msgId, &readStatus); MSG_DEBUG("### readStatus = %d ###", readStatus); - //Update Read Status to Unread beacaus Noti is Read + //Update Read Status to Unread because Noti is Read if (subType == MSG_RETRIEVE_MANUALCONF_MMS && pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) { MSG_DEBUG("###2. subType = %d ###", pMsgInfo->msgType.subType); - if (readStatus == true) - MsgStoSetReadStatus(&dbHandle, pMsgInfo->msgId, false); - } - - // update badge - if (subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) { - int smsCnt = 0; - int mmsCnt = 0; - - smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE); - mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE); - - MsgSettingHandleNewMsg(smsCnt, mmsCnt); + if (readStatus == true) { + MsgStoSetReadStatus(dbHandle, pMsgInfo->msgId, false); + MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, false, false); + } } if (subType == MSG_RETRIEVE_AUTOCONF_MMS) { - // play message-tone when MMS retrieved - MsgSoundPlayStart(); + bool isFavorites = false; + if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { + MsgPlayTTSMode(subType, pMsgInfo->msgId, isFavorites); + } // add phone log MSG_DEBUG("Enter MsgAddPhoneLog() for mms message."); MsgAddPhoneLog(pMsgInfo); - MsgInsertNoti(&dbHandle, pMsgInfo); + if (pMsgInfo->folderId == MSG_INBOX_ID) + MsgInsertNotification(pMsgInfo); + } else if (subType == MSG_RETRIEVE_MANUALCONF_MMS) { if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) { MSG_DEBUG("Manual success"); - MsgInsertTicker("Message Retrieved", MESSAGE_RETRIEVED); + if (pMsgInfo->folderId == MSG_INBOX_ID) + MsgInsertTicker("Message Retrieved", MESSAGE_RETRIEVED, true, 0); } else if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_FAIL) { MSG_DEBUG("Manual failed"); - MsgInsertTicker("Retrieving message failed", RETRIEVING_MESSAGE_FAILED); + MsgInsertTicker("Retrieving message failed", RETRIEVING_MESSAGE_FAILED, true, pMsgInfo->msgId); } } } else if (pMsgInfo->msgType.subType == MSG_SENDREQ_MMS || pMsgInfo->msgType.subType == MSG_SENDCONF_MMS) { MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(pMsgInfo->msgType.mainType); + if (plg == NULL) + return MSG_ERR_NULL_POINTER; + // change subType for storage update pMsgInfo->msgType.subType = MSG_SENDCONF_MMS; @@ -133,7 +286,7 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques return MSG_ERR_STORAGE_ERROR; MSG_DEBUG("pMsg->networkStatus : %d", pMsgInfo->networkStatus); - err = MsgStoUpdateNetworkStatus(pMsgInfo, pMsgInfo->networkStatus); + err = MsgStoUpdateNetworkStatus(dbHandle, pMsgInfo, pMsgInfo->networkStatus); if (err != MSG_SUCCESS) return MSG_ERR_STORAGE_ERROR; @@ -158,21 +311,20 @@ 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); + MsgDisplayLock(); - if (err == MSG_SUCCESS && *pSendNoti == true) - { - MsgSoundPlayStart(); + if (pMsgInfo->msgType.mainType == MSG_SMS_TYPE) { - int smsCnt = 0, mmsCnt = 0; + bool bOnlyNoti = false; - smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE); - mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE); + err = MsgHandleSMS(pMsgInfo, pSendNoti, &bOnlyNoti); - MsgSettingHandleNewMsg(smsCnt, mmsCnt); - MsgInsertNoti(&dbHandle, pMsgInfo); + if (err == MSG_SUCCESS && ((*pSendNoti)||bOnlyNoti)) { + bool isFavorites = false; + if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { + MsgPlayTTSMode(pMsgInfo->msgType.subType, pMsgInfo->msgId, isFavorites); + } + MsgInsertNotification(pMsgInfo); } } else if (pMsgInfo->msgType.mainType == MSG_MMS_TYPE) @@ -180,6 +332,8 @@ msg_error_t MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) err = MsgHandleMMS(pMsgInfo, pSendNoti); } + MsgDisplayUnlock(); + //Add Phone Log Data if ((err == MSG_SUCCESS) && (pMsgInfo->folderId == MSG_INBOX_ID || pMsgInfo->folderId == MSG_SPAMBOX_ID) && @@ -191,18 +345,123 @@ msg_error_t MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) MsgAddPhoneLog(pMsgInfo); } + // Auto delete + //MsgStoAutoDeleteConversation(pMsgInfo->threadId); + MSG_END(); return err; } -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; + MsgDbHandler *dbHandle = getDbHandle(); + + if (pMsgInfo->msgPort.valid == true) { + *pSendNoti = false; + *bOnlyNoti = false; + return MSG_SUCCESS; + } + + // Add SMS message + MSG_SENDINGOPT_INFO_S send_opt; + memset(&send_opt, 0x00, sizeof(MSG_SENDINGOPT_INFO_S)); + + if (pMsgInfo->msgType.classType == MSG_CLASS_2) { +#ifdef MSG_NOTI_INTEGRATION + MSG_DEBUG("Copy Class2 message to phone storage."); + pMsgInfo->msgType.classType = MSG_CLASS_NONE; + pMsgInfo->storageId = MSG_STORAGE_PHONE; + pMsgInfo->msgId = 0; +#else + MSG_DEBUG("Class2 message is already added."); + return MSG_SUCCESS; +#endif + } + + if (pMsgInfo->msgType.subType == MSG_NORMAL_SMS) { + MSG_DEBUG("Add Normal Message"); + err = MsgStoAddMessage(pMsgInfo, &send_opt); + } else if ((pMsgInfo->msgType.subType >= MSG_REPLACE_TYPE1_SMS) && (pMsgInfo->msgType.subType <= MSG_REPLACE_TYPE7_SMS)) { + MSG_DEBUG("Add Replace Message"); + + pMsgInfo->msgId = 0; + MsgStoGetReplaceMsgId(pMsgInfo); + + if (pMsgInfo->msgId > 0) { + err = MsgStoUpdateMessage(pMsgInfo, &send_opt); + } else { + err = MsgStoAddMessage(pMsgInfo, &send_opt); + pMsgInfo->msgType.subType = MSG_NORMAL_SMS; // To make 'insert' type for storage change callback. + } + } else if ((pMsgInfo->msgType.subType == MSG_WAP_SI_SMS) || (pMsgInfo->msgType.subType == MSG_WAP_CO_SMS) || (pMsgInfo->msgType.subType == MSG_WAP_SL_SMS)) { + MSG_DEBUG("Add WAP Push Message"); + switch (pMsgInfo->msgType.subType) + { + case MSG_WAP_SI_SMS: + case MSG_WAP_SL_SMS: + err = MsgStoAddWAPMsg(pMsgInfo); + break; + case MSG_WAP_CO_SMS: + err = MsgStoAddCOWAPMsg(pMsgInfo); + break; + default : + break; + } + } else if ((pMsgInfo->msgType.subType == MSG_CB_SMS) || (pMsgInfo->msgType.subType == MSG_JAVACB_SMS)) { + /** check add message option */ + } + else if (pMsgInfo->msgType.subType == MSG_STATUS_REPORT_SMS) { + MSG_DEBUG("Add Report Message"); + } + else if (pMsgInfo->msgType.subType >= MSG_MWI_VOICE_SMS && pMsgInfo->msgType.subType <= MSG_MWI_OTHER_SMS) { + char keyName[MAX_VCONFKEY_NAME_LEN]; + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, pMsgInfo->sim_idx); + char *number = MsgSettingGetString(keyName); + int addrSize = strlen(pMsgInfo->addressList[0].addressVal); + char newPhoneNum[addrSize+1]; + memset(newPhoneNum, 0x00, sizeof(newPhoneNum)); + MsgConvertNumber(pMsgInfo->addressList[0].addressVal, newPhoneNum, addrSize); + + if (g_str_has_suffix(number, newPhoneNum)) { + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, pMsgInfo->sim_idx); + char *alphaId = MsgSettingGetString(keyName); + if (alphaId) { + memset(pMsgInfo->addressList->displayName, 0x00, sizeof(pMsgInfo->addressList->displayName)); + memcpy(pMsgInfo->addressList->displayName, alphaId, sizeof(pMsgInfo->addressList->displayName)-1); + g_free(alphaId); + alphaId = NULL; + } + } + + if(number) + { + g_free(number); + number = NULL; + } + + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, pMsgInfo->sim_idx); + int voicecnt = MsgSettingGetInt(keyName); + memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText)); + snprintf(pMsgInfo->msgText, sizeof(pMsgInfo->msgText), "%d", voicecnt); + pMsgInfo->dataSize = strlen(pMsgInfo->msgText); + MSG_DEBUG("Add Voice or other Message"); + } + else { + MSG_DEBUG("No matching type [%d]", pMsgInfo->msgType.subType); + return err; + } + + if (err != MSG_SUCCESS) + MSG_DEBUG("Add message - Error : [%d]", err); if (pMsgInfo->msgType.subType == MSG_NORMAL_SMS) { - if (MsgCheckFilter(&dbHandle, pMsgInfo) == true) { + if (MsgCheckFilter(dbHandle, pMsgInfo) == true) { // Move to SpamBox err = MsgStoMoveMessageToFolder(pMsgInfo->msgId, MSG_SPAMBOX_ID); @@ -212,27 +471,31 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) pMsgInfo->folderId = MSG_SPAMBOX_ID; } - // Update Conversation table - err = MsgStoUpdateConversation(&dbHandle, pMsgInfo->threadId); - - if (err != MSG_SUCCESS) - MSG_DEBUG("MsgStoUpdateConversation() Error : [%d]", err); - *pSendNoti = false; + *bOnlyNoti = false; + } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) { + MsgLaunchClass0(pMsgInfo->msgId); + bool isFavorites = false; + if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { + MsgPlayTTSMode(pMsgInfo->msgType.subType, pMsgInfo->msgId, isFavorites); + MsgSoundPlayer::instance()->MsgSoundPlayStart(&(pMsgInfo->addressList[0]), MSG_SOUND_PLAY_USER); + } + *pSendNoti = false; + *bOnlyNoti = false; } } else if ((pMsgInfo->msgType.subType >= MSG_WAP_SI_SMS) && (pMsgInfo->msgType.subType <= MSG_WAP_CO_SMS)) { MSG_DEBUG("Starting WAP Message Incoming."); MSG_PUSH_SERVICE_TYPE_T serviceType = (MSG_PUSH_SERVICE_TYPE_T)MsgSettingGetInt(PUSH_SERVICE_TYPE); - service_h svc_handle = NULL; + app_control_h svc_handle = NULL; switch (pMsgInfo->msgType.subType) { case MSG_WAP_SL_SMS: { - *pSendNoti = false; + *pSendNoti = true; if (serviceType == MSG_PUSH_SERVICE_ALWAYS) { - if (service_create(&svc_handle) < 0) { + if (app_control_create(&svc_handle) < 0) { MSG_DEBUG("Fail to create service handle"); break; } @@ -240,58 +503,103 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) MSG_DEBUG("Service handle is NULL"); break; } - if (service_set_operation(svc_handle, SERVICE_OPERATION_VIEW) < 0) { + if (app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_VIEW) < 0) { MSG_DEBUG("Fail to create service handle"); - service_destroy(svc_handle); + app_control_destroy(svc_handle); break; } - if (service_set_uri(svc_handle, pMsgInfo->msgText) < 0) { + if (app_control_set_uri(svc_handle, pMsgInfo->msgText) < 0) { MSG_DEBUG("Fail to set uri"); - service_destroy(svc_handle); + app_control_destroy(svc_handle); break; } - if (service_set_package(svc_handle, MSG_SVC_PKG_NAME_BROWSER) < 0) { + if (app_control_set_app_id(svc_handle, MSG_SVC_PKG_NAME_BROWSER) < 0) { MSG_DEBUG("Fail to set package"); - service_destroy(svc_handle); + app_control_destroy(svc_handle); break; } - if (service_send_launch_request(svc_handle, NULL, NULL) < 0) { + if (app_control_send_launch_request(svc_handle, NULL, NULL) < 0) { MSG_DEBUG("Fail to launch browser"); - service_destroy(svc_handle); + app_control_destroy(svc_handle); break; } - service_destroy(svc_handle); + app_control_destroy(svc_handle); } else if (serviceType == MSG_PUSH_SERVICE_PROMPT) { - char urlString[MAX_COMMAND_LEN+1]; - memset(urlString, 0x00, sizeof(urlString)); - snprintf(urlString, MAX_COMMAND_LEN, "/opt/apps/org.tizen.message/bin/message-dialog -m PUSH_MSG_ALWAYS_ASK -u %s &", pMsgInfo->msgText); + MSG_DEBUG("WAP Message SL(Always Ask) start."); - system(urlString); - } + app_control_h svc_h; + int ret = APP_CONTROL_ERROR_NONE; + + ret = app_control_create(&svc_h); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_create() is failed : %d", ret); + break; + } + + ret = app_control_set_app_id(svc_h, "org.tizen.message-dialog"); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_set_app_id() is failed : %d", ret); + app_control_destroy(svc_h); + break; + } + + ret = app_control_add_extra_data(svc_h, "mode", "WAP_PUSH_SL"); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_add_extra_data() is failed : %d", ret); + app_control_destroy(svc_h); + break; + } + ret = app_control_add_extra_data(svc_h, "url", pMsgInfo->msgText); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_add_extra_data() is failed : %d", ret); + app_control_destroy(svc_h); + break; + } + + ret = app_control_add_extra_data(svc_h, "address", pMsgInfo->addressList[0].addressVal); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_add_extra_data() is failed : %d", ret); + app_control_destroy(svc_h); + break; + } + + ret = app_control_send_launch_request(svc_h, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + MSG_DEBUG("app_control_send_launch_request() is failed : %d", ret); + } + + app_control_destroy(svc_h); + MSG_DEBUG("app_control_destroy() returns : %d", ret); + } } break; case MSG_WAP_SI_SMS: + *pSendNoti = true; + break; case MSG_WAP_CO_SMS: - { *pSendNoti = false; - } - break; + 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); + // Update Conversation table + err = MsgStoUpdateConversation(dbHandle, pMsgInfo->threadId); - pMsgInfo->threadId = convId; - } + if (err != MSG_SUCCESS) + MSG_DEBUG("MsgStoUpdateConversation() Error : [%d]", err); return err; } @@ -300,7 +608,7 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) { msg_error_t err = MSG_SUCCESS; - + MsgDbHandler *dbHandle = getDbHandle(); MSG_REQUEST_INFO_S request = {0}; bool bReject = false; bool bFiltered = false; @@ -309,6 +617,32 @@ msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) MSG_MAIN_TYPE_T msgMainType = pMsgInfo->msgType.mainType; MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(msgMainType); + if (plg == NULL) + return MSG_ERR_NULL_POINTER; + + // Read the default network SIM + MsgPlugin *sms_plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); + + if (sms_plg == NULL) + return MSG_ERR_NULL_POINTER; + + int defaultNetworkSimId = 0; + + err = sms_plg->getDefaultNetworkSimId(&defaultNetworkSimId); + + MSG_DEBUG("######defaultNetworkSimId = %d, err = %d", defaultNetworkSimId, err); + + if (err != MSG_SUCCESS) { + MSG_ERR("getDefaultNetworkSimId is failed=[%d]", err); + return err; + } + + err = MsgSettingSetInt(MSG_NETWORK_SIM, (int)defaultNetworkSimId); + if (err != MSG_SUCCESS) { + MSG_ERR("Error to set config data [%s], err = %d", MSG_NETWORK_SIM, err); + return err; + } + // Need to process m-delivery-ind, m-notification-ind, m-read-orig-ind err = plg->processReceivedInd(pMsgInfo, &request, &bReject); @@ -316,16 +650,35 @@ msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) MSG_DEBUG("Process Message Success : processReceivedInd(), btextsms %d", pMsgInfo->bTextSms); } else { MSG_DEBUG("Process Message Fail : processReceivedInd()"); + *pSendNoti = false; return err; } // Add into DB if ((pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) && bReject == false) { - bFiltered = MsgCheckFilter(&dbHandle, pMsgInfo); + //bFiltered = MsgCheckFilter(dbHandle, pMsgInfo); + if (pMsgInfo->folderId == MSG_SPAMBOX_ID) { + bFiltered = true; + } if (bFiltered == true) { + err = MsgStoMoveMessageToFolder(pMsgInfo->msgId, MSG_SPAMBOX_ID); + + if (err != MSG_SUCCESS) { + MSG_DEBUG("MsgStoMoveMessageToFolder() Error : [%d]", err); + } else { + pMsgInfo->folderId = MSG_SPAMBOX_ID; + } + pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_FAIL; *pSendNoti = false; + } else {/* If it is not SPAM message, it should be check whether filter option is enable or not. */ + bool filterFlag = false; + MsgGetFilterOperation(&filterFlag); + if (filterFlag == true && request.msgInfo.msgType.subType == MSG_GET_MMS) { + /* Not to show MMS notification msg until it retrieves. */ + pMsgInfo->folderId = MSG_IOSBOX_ID; + } } err = MsgStoAddMessage(pMsgInfo, NULL); @@ -335,35 +688,55 @@ 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 (MsgInsertNotification(pMsgInfo) == MSG_SUCCESS) { + bool isFavorites = false; + if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { + MsgPlayTTSMode(pMsgInfo->msgType.subType, pMsgInfo->msgId, isFavorites); + } + *pSendNoti = false; + } } +#if 0 + if (pMsgInfo->bTextSms == false) { + MsgDeleteFile(pMsgInfo->msgData); //ipc + memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData)); + } +#endif //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(); + if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) { + if (request.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS && bReject == false && bFiltered == false) { + bool isFavorites = false; + if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { + MsgPlayTTSMode(pMsgInfo->msgType.subType, pMsgInfo->msgId, isFavorites); + } - int smsCnt = 0; - int mmsCnt = 0; + MsgInsertNotification(pMsgInfo); + } else { + *pSendNoti = false; + } - smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE); - mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE); + MSG_DEBUG("default_sim = %d, pMsgInfo->sim_idx = %d", defaultNetworkSimId, pMsgInfo->sim_idx); - MsgSettingHandleNewMsg(smsCnt, mmsCnt); - MsgInsertNoti(&dbHandle, pMsgInfo); - } + if (defaultNetworkSimId == pMsgInfo->sim_idx) { + request.msgInfo.msgId = pMsgInfo->msgId; - request.msgInfo.msgId = pMsgInfo->msgId; + MSG_DEBUG("-=====================[[[ %s ]]]] =========================", request.msgInfo.msgData); + err = plg->submitReq(&request); - MSG_DEBUG("-=====================[[[ %s ]]]] =========================", pMsgInfo->msgData); - err = plg->submitReq(&request); + if (err == MSG_SUCCESS) { + MSG_DEBUG("Process Message Success : processReceivedInd()"); + + if (request.msgInfo.msgType.subType == MSG_GET_MMS) { + MSG_DEBUG("Auto Retrieve Mode : update network status retrieving"); + MsgStoUpdateNetworkStatus(dbHandle, &(request.msgInfo), MSG_NETWORK_RETRIEVING); + } + + } else { + MSG_DEBUG("Process Message Fail : processReceivedInd()"); + } - if (err == MSG_SUCCESS) { - MSG_DEBUG("Process Message Success : processReceivedInd()"); - } else { - MSG_DEBUG("Process Message Fail : processReceivedInd()"); } } diff --git a/framework/main.cpp b/framework/main.cpp index 02c6ba4..cfd57d5 100755 --- a/framework/main.cpp +++ b/framework/main.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /*================================================================================================== @@ -30,25 +30,23 @@ #include "MsgTransManager.h" #include "MsgStorageTypes.h" #include "MsgSoundPlayer.h" +#include "MsgCmdHandler.h" +#include "MsgUtilFile.h" +#include "MsgUtilStorage.h" +#include "MsgNotificationWrapper.h" #include #include -#include +#include #include #include static GMainLoop* mainloop = NULL; - -/*================================================================================================== - DEFINES -==================================================================================================*/ -#define MSG_MOBILE_TRACKER_MSG "Mobile Tracker Alert" - - /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ + msg_error_t InitMmsDir() { if (mkdir(MSG_DATA_ROOT_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) @@ -68,11 +66,11 @@ msg_error_t InitMmsDir() { if (errno == EEXIST) { - MSG_DEBUG("The %s already exists", MSG_SMIL_FILE_PATH); + MSG_SEC_DEBUG("The %s already exists", MSG_SMIL_FILE_PATH); } else { - MSG_DEBUG("Error while mkdir %s", MSG_SMIL_FILE_PATH); + MSG_SEC_DEBUG("Error while mkdir %s", MSG_SMIL_FILE_PATH); return MSG_ERR_DB_MAKE_DIR; } } @@ -104,11 +102,8 @@ msg_error_t InitMmsDir() if (errno == EEXIST) { MSG_DEBUG("The %s already exists", MSG_IPC_DATA_PATH); - // if IPC data path is already exist, clear all files in folder. - char exeStr[1024]; - snprintf(exeStr, 1024, "rm %s*.DATA", MSG_IPC_DATA_PATH); - system(exeStr); + MsgRmRf((char *)MSG_IPC_DATA_PATH); } else { @@ -117,153 +112,47 @@ msg_error_t InitMmsDir() } } - chmod( MSG_IPC_DATA_PATH, S_IRWXU | S_IRWXG ); //public shared file: pass data by file - chown( MSG_IPC_DATA_PATH, 0, 6502 ); - - return MSG_SUCCESS; -} - - -void SendMobileTrackerMsg() -{ - MSG_BEGIN(); - - bool bEnabled = false; - - if (MsgSettingGetBool(VCONFKEY_SETAPPL_FIND_MY_MOBILE_SIM_CHANGE_ALERT_BOOL, &bEnabled) < 0) - { - MSG_DEBUG("Can't read VCONFKEY_SETAPPL_FIND_MY_MOBILE_SIM_CHANGE_ALERT_BOOL"); - return; + if (MsgChmod( 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); } - - if (bEnabled == false) - { - MSG_DEBUG("Mobile Tracker Option [%d]", bEnabled); - return; + if (MsgChown(MSG_DATA_ROOT_PATH, 0, 5000) == 0) { + MSG_DEBUG("Fail to chown [%s].", MSG_DATA_ROOT_PATH); } - // to wait modem init - // temporary code. - else - { - MSG_DEBUG("Waiting for modem ready, 22 sec."); - sleep(22); + if (MsgChown(MSG_DATA_PATH, 0, 5000) == 0) { + MSG_DEBUG("Fail to chown [%s].", MSG_DATA_PATH); } - - MSG_REQUEST_INFO_S req = {0}; - - req.sendOptInfo.bSetting = false; - - req.msgInfo.msgId = 0; - req.msgInfo.threadId = 0; - req.msgInfo.folderId = MSG_DRAFT_ID; - req.msgInfo.msgType.mainType = MSG_SMS_TYPE; - req.msgInfo.msgType.subType = MSG_NORMAL_SMS; - req.msgInfo.msgType.classType = MSG_CLASS_NONE; - req.msgInfo.storageId = MSG_STORAGE_PHONE; - req.msgInfo.displayTime = 0; - req.msgInfo.networkStatus = MSG_NETWORK_NOT_SEND; - req.msgInfo.encodeType = MSG_ENCODE_AUTO; - req.msgInfo.bRead = false; - req.msgInfo.bProtected = false; - req.msgInfo.priority = MSG_MESSAGE_PRIORITY_NORMAL; - req.msgInfo.direction = MSG_DIRECTION_TYPE_MO; - req.msgInfo.msgPort.valid = false; - req.msgInfo.bTextSms = true; - - // Get Message Text - char* msgText = NULL; - - msgText = MsgSettingGetString(VCONFKEY_SETAPPL_FIND_MY_MOBILE_MESSAGE_STR); - - if (msgText == NULL) - { - MSG_DEBUG("Assign Default Msg"); - msgText = strdup(MSG_MOBILE_TRACKER_MSG); + if (MsgChown(MSG_SMIL_FILE_PATH, 0, 5000) == 0) { + MSG_DEBUG("Fail to chown [%s].", MSG_SMIL_FILE_PATH); } - - MSG_DEBUG("mobile tracker msg : [%s]", msgText); - - req.msgInfo.dataSize = strlen(msgText); - strncpy(req.msgInfo.msgText, msgText, req.msgInfo.dataSize); - - // Get Address List - char *orgRecipientList = NULL; - - orgRecipientList = MsgSettingGetString(VCONFKEY_SETAPPL_FIND_MY_MOBILE_RECIPIENTS_STR); - - if (orgRecipientList == NULL) - { - MSG_DEBUG("recipient list is NULL"); - return; + if (MsgChown(MSG_IPC_DATA_PATH, 0, 5000) == 0) { + MSG_DEBUG("Fail to chown [%s].", MSG_IPC_DATA_PATH); + } + if (MsgChown(MSG_THUMBNAIL_PATH, 0, 5000) == 0) { + MSG_DEBUG("Fail to chown [%s].", MSG_THUMBNAIL_PATH); } - int len = strlen(orgRecipientList); - char recipientList[len + 1]; - - memset(recipientList, 0, len + 1); - memcpy(recipientList, orgRecipientList, len); - - MSG_DEBUG("recipient list : [%s]", recipientList); - - req.msgInfo.nAddressCnt = 1; - - char *token; - - token = strtok(recipientList, "|"); + return MSG_SUCCESS; +} - MSG_MAIN_TYPE_T mainType = MSG_SMS_TYPE; - MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType); +void* InitMsgServer(void*) +{ msg_error_t err = MSG_SUCCESS; + MSG_DEBUG("Start InitMsgServer."); - while (token) + //CID 356902: Moving try block up to include MsgStoInitDB which also throws MsgException + try { - req.msgInfo.addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN; - req.msgInfo.addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO; - - memset(req.msgInfo.addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN); - strncpy(req.msgInfo.addressList[0].addressVal, token, MAX_ADDRESS_VAL_LEN); - - MSG_DEBUG("address : [%s]", req.msgInfo.addressList[0].addressVal); - - if (plg != NULL) - { - MSG_DEBUG("mobile tracker msg : [%s]", msgText); - - err = plg->submitReq(&req); - - if (err != MSG_SUCCESS) - { - MSG_DEBUG("fail to send mobile tracker msg : [%d]", err); - break; - } + // storage handler initialize + err = MsgStoInitDB(false); + if (err != MSG_SUCCESS) { + MSG_ERR("FAIL TO INITIALIZE STORAGE HANDLER [%d]", err); } - token = strtok(NULL, "|"); - } - - if (msgText) { - free(msgText); - msgText = NULL; - } - - if (orgRecipientList) { - free(orgRecipientList); - orgRecipientList = NULL; - } - + MsgInitNoti(); - MSG_END(); - - return; -} - - -void* StartMsgServer(void*) -{ - try - { - MsgTransactionManager::instance()->run(); + // plugin manager initialize + MsgPluginManager::instance()->initialize(); } catch (MsgException& e) { @@ -274,21 +163,23 @@ void* StartMsgServer(void*) MSG_FATAL("%s", e.what()); } - if (g_main_loop_is_running(mainloop)) - g_main_loop_quit(mainloop); + +// MsgSoundPlayer::instance()->MsgSoundInitRepeatAlarm(); + + MsgStoDisconnectDB(); + + MsgReleaseMemory(); + MSG_DEBUG("End InitMsgServer."); return (void*)0; } -void* InitMsgServer(void*) +void* StartMsgServer(void*) { - msg_error_t err = MSG_SUCCESS; - try { - // plugin manager initialize - MsgPluginManager::instance()->initialize(); + MsgTransactionManager::instance()->run(); } catch (MsgException& e) { @@ -299,152 +190,53 @@ void* InitMsgServer(void*) MSG_FATAL("%s", e.what()); } - MSG_MAIN_TYPE_T mainType = MSG_SMS_TYPE; - MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType); - - // storage handler initialize - err = MsgStoInitDB(false); - - if (err != MSG_SUCCESS) { - MSG_DEBUG("FAIL TO INITIALIZE STORAGE HANDLER [%d]", err); - } - - // Set Msg FW Ready Flag - MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, true); - MSG_DEBUG("### VCONFKEY_MSG_SERVER_READY ###"); - - if (plg == NULL) { - MSG_DEBUG("No plugin for %d type", mainType); - - MsgReleaseMemory(); - return (void*)0; - } - - MSG_SIM_STATUS_T simStatus = MSG_SIM_STATUS_NORMAL; - - // Check Sim Status - if (plg->checkSimStatus(&simStatus) == MSG_SUCCESS) { - - // Add the change of SIM to vconf - if (MsgSettingSetInt(MSG_SIM_CHANGED, (int)simStatus) != MSG_SUCCESS) { - MSG_DEBUG("Error to set config data [%s]", MSG_SIM_CHANGED); - } - - if (simStatus != MSG_SIM_STATUS_NOT_FOUND) { - // Check Device Status - if (plg->checkDeviceStatus() != MSG_SUCCESS) { - MSG_DEBUG("checkDeviceStatus() error"); - - MsgReleaseMemory(); - - return (void*)0; - } - } - - // Init SIM Message - if (MsgInitSimMessage(simStatus) != MSG_SUCCESS) { - MSG_DEBUG("Fail to Initialize SIM Message"); - } - - // Init SIM Configuration - if (MsgInitSimConfig(simStatus) != MSG_SUCCESS) { - MSG_DEBUG("Fail to Initialize SIM Configuration"); - } - - // Add SendMobileTrackerMsg() to GMainLoop - if (simStatus == MSG_SIM_STATUS_CHANGED) { - MSG_DEBUG("Send Mobile Tracker Message"); - - SendMobileTrackerMsg(); - } - } else { - MSG_DEBUG("checkSimStatus() error"); - } - - MsgReleaseMemory(); - - // Try to connect contact server if it is not opened. - MsgOpenContactSvc(); - - // Register Callback to get the change of contact - MsgInitContactSvc(&MsgContactChangedCallback); - - MsgSoundInitRepeatAlarm(); + if (g_main_loop_is_running(mainloop)) + g_main_loop_quit(mainloop); return (void*)0; } -static gboolean InitThreadFunc(void* pData) -{ - MSG_BEGIN(); - - pthread_t initThreadId; - - // initialize msg fw - if (pthread_create(&initThreadId, NULL, InitMsgServer, NULL) != 0) - { - MSG_DEBUG("InitMsgFw not invoked: %s", strerror(errno)); - return -1; - } - - pthread_detach(initThreadId); - - MSG_END(); - - return FALSE; -} - - int main(void) { #if !GLIB_CHECK_VERSION(2, 31, 0) g_thread_init(NULL); #endif - dbus_g_thread_init(); - -//////////////////////////////////// - -/// set to ignore child process terminated signal. -signal( SIGCHLD, SIG_IGN ); - -//////////////////////////////////// + /* set to ignore child process terminated signal */ + signal(SIGCHLD, SIG_IGN); + MSG_INFO("===========START MESSAGING FRAMEWORK=========="); - MSG_DEBUG("===========START MESSAGING FRAMEWORK=========="); - +#if !GLIB_CHECK_VERSION(2, 36, 0) + g_type_init(); +#endif // Reset message server ready flag - MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, false); + if(MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, false) != MSG_SUCCESS) + MSG_DEBUG("MsgSettingSetBool FAIL: VCONFKEY_MSG_SERVER_READY"); // Connect to DB // MsgStoConnectDB(); - // Open Contact Service - MsgOpenContactSvc(); - // Clean up mms dir InitMmsDir(); - // Regist vconf CB. - MsgSettingRegVconfCB(); + // init server + InitMsgServer(NULL); pthread_t startThreadId; // start transaction manager if (pthread_create(&startThreadId, NULL, StartMsgServer, NULL) != 0) { - MSG_DEBUG("StartMsgServer not invoked: %s", strerror(errno)); + MSG_DEBUG("StartMsgServer not invoked: %s", g_strerror(errno)); return -1; } - MsgTransactionManager::instance()->getTMStatus(); + // Regist vconf CB. + MsgSettingRegVconfCB(); mainloop = g_main_loop_new(NULL, FALSE); - g_type_init(); - - g_idle_add(InitThreadFunc, NULL); - if (mainloop != NULL) { MSG_DEBUG("Start Messaging Framework!!!"); @@ -457,6 +249,9 @@ signal( SIGCHLD, SIG_IGN ); MSG_DEBUG("Fail to start Messaging Framework!!!"); } + // free MmapMutex + MsgfreeMmapMutex(); + // Remove vconf CB MsgSettingRemoveVconfCB(); diff --git a/framework/plugin-manager/MsgPluginConfig.cpp b/framework/plugin-manager/MsgPluginConfig.cpp deleted file mode 100755 index 057498b..0000000 --- a/framework/plugin-manager/MsgPluginConfig.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* -* 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 "MsgPluginConfig.h" -#include "MsgException.h" - - -/*================================================================================================== - IMPLEMENTATION OF MsgPlgToken - Member Functions -==================================================================================================*/ -int MsgPlgToken::tokenize(char *pStr) -{ - MSG_BEGIN(); - - if (pStr == NULL) - THROW(MsgException::INVALID_PARAM, "pstr is NULL"); - - char *pFirst = index(pStr, '['); - - if (pFirst) // title is enclosed by [ ] - { - pFirst++; // excluding '[' - - char *pEnd = index(pStr, ']'); - - if (pEnd) - { - pEnd--; - - tokenType = TOK_PLG_TITLE; - int len = pEnd-pFirst+1; - - memcpy(tokenVal, pFirst, len); - tokenVal[len] = '\0'; - - MSG_DEBUG("%s", tokenVal); - } - else - THROW(MsgException::INVALID_RESULT, "']' not found"); - } - else // (attribute, value) pair - { - char tokStr[strlen(pStr)+1]; - strncpy(tokStr, pStr, strlen(pStr)); - - char *attr = strtok(tokStr, "="); - char *val = strtok(NULL, "="); - - if (!attr || !val) - { - tokenType = TOK_UNDEFINED; - } - else - { - // trimming enter key - char *tmp = index(val,'\n'); - - if (tmp) - *tmp = '\0'; - - MSG_DEBUG("attr \"%s\", val \"%s\" ", attr, val); - - // classifying the attribute - if (strcmp(attr, "type") == 0) - { - tokenType = TOK_PLG_TYPE; - strncpy(tokenVal, val, 255); - } - else if (strcmp(attr, "path") == 0) - { - tokenType = TOK_PLG_PATH; - strncpy(tokenVal, val, 255); - } - else - { - tokenType = TOK_UNDEFINED; - } - } - } - - MSG_END(); - - return tokenType; -} - - -/*================================================================================================== - IMPLEMENTATION OF MsgPlgConfig - Member Functions -==================================================================================================*/ -MsgPlgConfig::MsgPlgConfig(FILE* fp) -{ - MSG_BEGIN(); - - if (fp == NULL) - THROW(MsgException::INVALID_PARAM, "fp is NULL"); - - MsgPlgToken tokTitle, tokMsgType, tokLibPath; - - char str[256]; - memset(str, 0x00, sizeof(str)); - - MsgPlgToken tok = MsgPlgToken(); - - while (fgets(str, 255, fp)) - { - tok.tokenize(str); // parsing the line into tokens - - switch ( tok.getType() ) - { - case MsgPlgToken::TOK_PLG_TITLE: - // processing previous items - if( tokTitle && tokMsgType && tokLibPath ) - { - insert(tokTitle, tokMsgType, tokLibPath); - } - - tokTitle = tok; - tokMsgType.reset(); - tokLibPath.reset(); - - break; - - case MsgPlgToken::TOK_PLG_TYPE: - tokMsgType = tok; - break; - - case MsgPlgToken::TOK_PLG_PATH: - tokLibPath = tok; - break; - - default: - MSG_DEBUG("the line \"%s\" is not accecpted", str); - break; - } - } - - if (tokTitle && tokMsgType && tokLibPath) - { - insert(tokTitle, tokMsgType, tokLibPath); - } - - MSG_END(); -} - - -void MsgPlgConfig::insert(const MsgPlgToken& tokTitle, const MsgPlgToken& tokMsgType, const MsgPlgToken& tokLibPath) -{ - MSG_BEGIN(); - - MsgPlgTokenVec item2add; - item2add.push_back(tokMsgType); - item2add.push_back(tokLibPath); - - CharVector titleVec; - tokTitle.getVal(titleVec); - MsgConfigMap::iterator it=configMap.find(titleVec); - - if (it == configMap.end()) - configMap.insert(std::make_pair(titleVec, item2add)); - else - THROW(MsgException::PLUGIN_ERROR, "duplicated plugin title"); - - MSG_DEBUG("item inserted"); - MSG_DEBUG("token:%d,value:%s", tokTitle.getType(), tokTitle.getVal()); - MSG_DEBUG("token:%d,value:%s", tokMsgType.getType(), tokMsgType.getVal()); - MSG_DEBUG("token:%d,value:%s", tokLibPath.getType(), tokLibPath.getVal()); - - MSG_END(); -} - - -const CharVector& MsgPlgConfig::title(unsigned int pos) -{ - if (pos >= configMap.size()) - THROW(MsgException::OUT_OF_RANGE, "Input Parameter is not valid [%d]", pos); - - MsgConfigMap::iterator it = configMap.begin(); - - unsigned int i=0; - - while (it != configMap.end()) - { - if (i++ == pos) break; - it++; - } - - if (it == configMap.end()) - THROW(MsgException::INVALID_RESULT, "no title"); - - MSG_DEBUG("searched title:%s", &(it->first)[0]); - - return it->first; -} - - -void MsgPlgConfig::token(const CharVector& key, unsigned int pos, MsgPlgToken& retTok) -{ - MsgConfigMap::iterator it = configMap.find(key); - - if (it != configMap.end()) //found - { - MSG_DEBUG("searched title:%s", &(it->first)[0]); - - MsgPlgTokenVec tokVec = it->second; - retTok = tokVec[pos]; - - MSG_DEBUG("searched token:%d,value:%s", retTok.getType(), retTok.getVal()); - } - else - { - THROW(MsgException::INVALID_RESULT, "no title"); - } -} - - -void MsgPlgConfig::token(int i, unsigned int pos, MsgPlgToken& retTok) -{ - const CharVector& key = title(i); - - token(key, pos, retTok); - - MSG_DEBUG("returned token:%d,value:%s", retTok.getType(), retTok.getVal()); -} - diff --git a/framework/plugin-manager/MsgPluginManager.cpp b/framework/plugin-manager/MsgPluginManager.cpp index 7c5bf38..3b5f174 100755 --- a/framework/plugin-manager/MsgPluginManager.cpp +++ b/framework/plugin-manager/MsgPluginManager.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include @@ -21,6 +21,7 @@ #include "MsgUtilFile.h" #include "MsgException.h" #include "MsgIpcSocket.h" +#include "MsgUtilFunction.h" #include "MsgCmdTypes.h" #include "MsgGconfWrapper.h" #include "MsgPluginManager.h" @@ -38,7 +39,17 @@ void MsgSentStatusListener(MSG_SENT_STATUS_S *pSentStatus) // establish connection to msgfw daemon MsgIpcClientSocket client; - client.connect(MSG_SOCKET_PATH); + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return; + } + + // composing command int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_SENT_STATUS_S); // cmd type, MSG_SENT_STATUS @@ -62,8 +73,8 @@ void MsgSentStatusListener(MSG_SENT_STATUS_S *pSentStatus) MSG_DEBUG("Waiting result for SENT STATUS"); char *temp = NULL; - AutoPtr wrap(&temp); - int len; + unique_ptr wrap(&temp, unique_ptr_deleter); + unsigned int len; client.read(&temp, &len); // close connection to msgfw daemon @@ -81,7 +92,15 @@ void MsgStorageChangeListener(msg_storage_change_type_t storageChangeType, MSG_M // establish connection to msgfw daemon MsgIpcClientSocket client; + try + { client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return; + } // composing command int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(msg_storage_change_type_t); @@ -106,8 +125,8 @@ void MsgStorageChangeListener(msg_storage_change_type_t storageChangeType, MSG_M MSG_DEBUG("Waiting result for STORAGE CHANGE"); char *temp = NULL; - AutoPtr wrap(&temp); - int len; + unique_ptr wrap(&temp, unique_ptr_deleter); + unsigned int len; client.read(&temp, &len); // close connection to msgfw daemon @@ -123,7 +142,15 @@ msg_error_t MsgIncomingMessageListener(MSG_MESSAGE_INFO_S *pMsg) // establish connection to msgfw daemon MsgIpcClientSocket client; - client.connect(MSG_SOCKET_PATH); + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } // Check Invalid Message Structure if (pMsg == NULL) @@ -133,8 +160,13 @@ msg_error_t MsgIncomingMessageListener(MSG_MESSAGE_INFO_S *pMsg) return MSG_ERR_NULL_MESSAGE; } + // Allocate Memory to Command Data + char* encodedData = NULL; + unique_ptr buf(&encodedData, unique_ptr_deleter); + int dataSize = MsgEncodeMsgInfo(pMsg, &encodedData); + // composing command - int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S); // cmd type, MSG_MESSAGE_INFO_S + int cmdSize = sizeof(MSG_CMD_S) + dataSize; // cmd type, MSG_MESSAGE_INFO_S MSG_DEBUG("cmdSize: %d", cmdSize); @@ -148,14 +180,14 @@ msg_error_t MsgIncomingMessageListener(MSG_MESSAGE_INFO_S *pMsg) memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); - memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsg, sizeof(MSG_MESSAGE_INFO_S)); + memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), encodedData, dataSize); // Send Command to Messaging FW client.write(cmdBuf, cmdSize); char* retBuf = NULL; - AutoPtr wrap(&retBuf); - int retSize; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; client.read(&retBuf, &retSize); @@ -167,7 +199,12 @@ msg_error_t MsgIncomingMessageListener(MSG_MESSAGE_INFO_S *pMsg) MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_MSG_IND) - THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + +#ifdef FEATURE_SMS_CDMA + memcpy(&(pMsg->msgId), pEvent->data, sizeof(msg_message_id_t)); +#endif MSG_END(); @@ -181,7 +218,15 @@ msg_error_t MsgIncomingSyncMLMessageListener(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLD // establish connection to msgfw daemon MsgIpcClientSocket client; - client.connect(MSG_SOCKET_PATH); + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } // composing command int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_SYNCML_MESSAGE_DATA_S); // cmd type, MSG_SYNCML_MESSAGE_DATA_S @@ -204,8 +249,8 @@ msg_error_t MsgIncomingSyncMLMessageListener(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLD // Receive result from Transaction Manager char* retBuf = NULL; - AutoPtr wrap(&retBuf); - int retSize; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; client.read(&retBuf, &retSize); // close connection to msgfw daemon @@ -216,7 +261,144 @@ msg_error_t MsgIncomingSyncMLMessageListener(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLD MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND) - THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + + MSG_END(); + + return (pEvent->result); +} + +msg_error_t MsgIncomingPushMessageListener(MSG_PUSH_MESSAGE_DATA_S *pPushData) +{ + MSG_BEGIN(); + + // establish connection to msgfw daemon + MsgIpcClientSocket client; + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } + + // composing command + int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_PUSH_MESSAGE_DATA_S); // cmd type, MSG_SYNCML_MESSAGE_DATA_S + + MSG_DEBUG("cmdSize: %d", cmdSize); + + char cmdBuf[cmdSize]; + bzero(cmdBuf, cmdSize); + MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf; + + // Set Command Parameters + pCmd->cmdType = MSG_CMD_PLG_INCOMING_PUSH_IND; + + memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); + + memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pPushData, sizeof(MSG_PUSH_MESSAGE_DATA_S)); + + // Send Command to Messaging FW + client.write(cmdBuf, cmdSize); + + // Receive result from Transaction Manager + char* retBuf = NULL; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; + client.read(&retBuf, &retSize); + + // close connection to msgfw daemon + client.close(); + + // Decoding the result from FW and Returning it to plugin + // the result is used for making delivery report + MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; + + if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND) + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + + MSG_END(); + + return (pEvent->result); +} + + +msg_error_t MsgIncomingCBMessageListener(MSG_CB_MSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo) +{ + MSG_BEGIN(); + + // establish connection to msgfw daemon + MsgIpcClientSocket client; + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } + + // Check Invalid Message Structure + if (pCbMsg == NULL) + { + MSG_DEBUG("pMsg is NULL !!"); + + return MSG_ERR_NULL_MESSAGE; + } + int cmdSize = 0; + + // Allocate Memory to Command Data + char* encodedData = NULL; + unique_ptr buf(&encodedData, unique_ptr_deleter); + int dataSize = MsgEncodeMsgInfo(pMsgInfo, &encodedData); + + // composing command + if(pCbMsg->type == MSG_ETWS_SMS) + cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CB_MSG_S); // cmd type, MSG_CB_MSG_S + else + cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CB_MSG_S) + dataSize; // cmd type, MSG_CB_MSG_S + + MSG_DEBUG("cmdSize: %d", cmdSize); + + char cmdBuf[cmdSize]; + bzero(cmdBuf, cmdSize); + + MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf; + + // Set Command Parameters + pCmd->cmdType = MSG_CMD_PLG_INCOMING_CB_IND; + + memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); + + memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pCbMsg, sizeof(MSG_CB_MSG_S)); + + if(pCbMsg->type != MSG_ETWS_SMS) + memcpy((void*)((char*)pCmd + sizeof(MSG_CMD_TYPE_T)+ MAX_COOKIE_LEN + sizeof(MSG_CB_MSG_S)), encodedData, dataSize); + + // Send Command to Messaging FW + client.write(cmdBuf, cmdSize); + + char* retBuf = NULL; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; + + client.read(&retBuf, &retSize); + + // close connection to msgfw daemon + client.close(); + + // Decoding the result from FW and Returning it to plugin + // the result is used for making delivery report + MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; + + if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_CB_MSG_IND) + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); MSG_END(); @@ -230,7 +412,15 @@ msg_error_t MsgIncomingLBSMessageListener(MSG_LBS_MESSAGE_DATA_S *pLBSData) // establish connection to msgfw daemon MsgIpcClientSocket client; - client.connect(MSG_SOCKET_PATH); + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } // composing command int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_LBS_MESSAGE_DATA_S); // cmd type, MSG_LBS_MESSAGE_DATA_S @@ -253,8 +443,8 @@ msg_error_t MsgIncomingLBSMessageListener(MSG_LBS_MESSAGE_DATA_S *pLBSData) // Receive result from Transaction Manager char* retBuf = NULL; - AutoPtr wrap(&retBuf); - int retSize; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; client.read(&retBuf, &retSize); // close connection to msgfw daemon @@ -265,7 +455,8 @@ msg_error_t MsgIncomingLBSMessageListener(MSG_LBS_MESSAGE_DATA_S *pLBSData) MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_LBS_MSG_IND) - THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); MSG_END(); @@ -279,7 +470,15 @@ msg_error_t MsgInitSimBySatListener() // establish connection to msgfw daemon MsgIpcClientSocket client; - client.connect(MSG_SOCKET_PATH); + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } // composing command int cmdSize = sizeof(MSG_CMD_S); @@ -297,8 +496,8 @@ msg_error_t MsgInitSimBySatListener() // Receive result from Transaction Manager char* retBuf = NULL; - AutoPtr wrap(&retBuf); - int retSize; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; client.read(&retBuf, &retSize); // close connection to msgfw daemon @@ -308,7 +507,8 @@ msg_error_t MsgInitSimBySatListener() MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; if (pEvent->eventType != MSG_EVENT_PLG_INIT_SIM_BY_SAT) - THROW(MsgException::INVALID_RESULT, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INVALID_RESULT, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); MSG_END(); @@ -319,14 +519,27 @@ msg_error_t MsgInitSimBySatListener() msg_error_t MsgMmsConfIncomingListener(MSG_MESSAGE_INFO_S *pMsg, msg_request_id_t *pReqId) { MSG_BEGIN(); - MSG_DEBUG("pMsg = %s, pReqId = %d ", pMsg->msgData, *pReqId); + MSG_SEC_DEBUG("pMsg = %s, pReqId = %d ", pMsg->msgData, *pReqId); // establish connection to msgfw daemon MsgIpcClientSocket client; - client.connect(MSG_SOCKET_PATH); + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } + + // Allocate Memory to Command Data + char* encodedData = NULL; + unique_ptr buf(&encodedData, unique_ptr_deleter); + int dataSize = MsgEncodeMsgInfo(pMsg, &encodedData); // composing command - int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(msg_request_id_t); // cmd type, MSG_MESSAGE_INFO_S, msg_request_id_t + int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_request_id_t) + dataSize; // cmd type, MSG_MESSAGE_INFO_S, msg_request_id_t MSG_DEBUG("cmdSize : %d", cmdSize); char cmdBuf[cmdSize]; @@ -340,27 +553,320 @@ msg_error_t MsgMmsConfIncomingListener(MSG_MESSAGE_INFO_S *pMsg, msg_request_id_ memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); // cmd cookie // cmd data - memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsg, sizeof(MSG_MESSAGE_INFO_S)); - memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), pReqId, sizeof(msg_request_id_t)); + memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pReqId, sizeof(msg_request_id_t)); + memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN + sizeof(msg_request_id_t)), encodedData, dataSize); // Send Command to Messaging FW client.write(cmdBuf, cmdSize); // Receive result from Transaction Manager char *retBuf = NULL; - AutoPtr wrap(&retBuf); - int retSize = 0; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize = 0; client.read(&retBuf, &retSize); // close connection to msgfw daemon client.close(); - //Decoding the result from FW and Returning it to plugin - // the result is used for making delivery report + // Decoding the result from FW and Returning it to plugin MSG_EVENT_S *pEvent = (MSG_EVENT_S *)retBuf; - if(pEvent->eventType != MSG_EVENT_PLG_INCOMING_MMS_CONF && pEvent->eventType != MSG_EVENT_PLG_SENT_STATUS_CNF) - THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + if(pEvent->eventType != MSG_EVENT_PLG_INCOMING_MMS_CONF) + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + + MSG_END(); + + return (pEvent->result); +} + + +msg_error_t MsgSimMessageListener(MSG_MESSAGE_INFO_S *pMsg, int *simIdList, msg_message_id_t *retMsgId, int size) +{ + MSG_BEGIN(); + + // establish connection to msgfw daemon + MsgIpcClientSocket client; + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } + + // Check Invalid Message Structure + if (pMsg == NULL) + { + MSG_DEBUG("pMsg is NULL !!"); + + return MSG_ERR_NULL_MESSAGE; + } + + // Allocate Memory to Command Data + char* encodedData = NULL; + unique_ptr buf(&encodedData, unique_ptr_deleter); + int dataSize = MsgEncodeMsgInfo(pMsg, &encodedData); + + char* encodedData2 = NULL; + unique_ptr buf2(&encodedData2, unique_ptr_deleter); + encodedData2 = (char*)new char[dataSize + sizeof(int) + (sizeof(int)*size) + 1]; + + char *offset = NULL; + memcpy(encodedData2, encodedData, dataSize); + offset = encodedData2+dataSize; + + memcpy(offset, &size, sizeof(int)); + offset += sizeof(int); + MSG_DEBUG("size [%d]", size); + + memcpy(offset, simIdList, (sizeof(int)*size)); + + MSG_DEBUG("simIdList[0] [%d]", simIdList[0]); + + dataSize += ((sizeof(int)*size) + 1); + + // composing command + int cmdSize = sizeof(MSG_CMD_S) + dataSize; // cmd type, MSG_MESSAGE_INFO_S + + MSG_DEBUG("cmdSize: %d", cmdSize); + + char cmdBuf[cmdSize]; + bzero(cmdBuf, cmdSize); + + MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf; + + // Set Command Parameters + pCmd->cmdType = MSG_CMD_ADD_SIM_MSG; + + memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); + + memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), encodedData2, dataSize); + + // Send Command to Messaging FW + client.write(cmdBuf, cmdSize); + + char* retBuf = NULL; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; + + client.read(&retBuf, &retSize); + + // close connection to msgfw daemon + client.close(); + + // Decoding the result from FW and Returning it to plugin + // the result is used for making delivery report + MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; + + if (pEvent->eventType != MSG_EVENT_ADD_SIM_MSG) + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + + //CID 48645: pEvent->data is an array hence null check is not required on it. + if (retMsgId) { + memcpy(retMsgId, pEvent->data, sizeof(msg_message_id_t)); + MSG_DEBUG("Saved SIM message ID = [%d]", *retMsgId); + } + + MSG_END(); + + return (pEvent->result); +} + +msg_error_t MsgResendMessageListener(void) +{ + // establish connection to msgfw daemon + MsgIpcClientSocket client; + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } + + // composing command + int cmdSize = sizeof(MSG_CMD_S); + + char cmdBuf[cmdSize]; + bzero(cmdBuf, cmdSize); + + MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf; + + // Set Command Parameters + pCmd->cmdType = MSG_CMD_PLG_RESEND_MESSAGE; + + // Send Command to Transaction Manager + client.write(cmdBuf, cmdSize); + + // Receive result from Transaction Manager + char* retBuf = NULL; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; + client.read(&retBuf, &retSize); + + // close connection to msgfw daemon + client.close(); + + // Decoding the result from FW and Returning it to plugin + MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; + + if (pEvent->eventType != MSG_EVENT_PLG_RESEND_MESSAGE) + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INVALID_RESULT, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + + MSG_END(); + + return (pEvent->result); +} + +#ifdef FEATURE_SMS_CDMA +bool MsgCheckUniquenessListener(MSG_UNIQUE_INDEX_S *p_msg, msg_message_id_t msgId, bool bInsert) +{ + MSG_BEGIN(); + + // establish connection to msgfw daemon + MsgIpcClientSocket client; + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } + + // Check Invalid Message Structure + if (p_msg == NULL) + { + MSG_DEBUG("p_msg is NULL !!"); + + return MSG_ERR_NULL_MESSAGE; + } + + // Allocate Memory to Command Data + char* encodedData = NULL; + unique_ptr buf(&encodedData, unique_ptr_deleter); + + int dataSize = sizeof(bool) + sizeof(msg_message_id_t) + sizeof(MSG_UNIQUE_INDEX_S); + + encodedData = (char*)new char[dataSize]; + + MSG_DEBUG("Encoded Teleservice Msg Id = [%d]", p_msg->tele_msgId); + MSG_DEBUG("Encoded Address = [%s]", p_msg->address); + MSG_DEBUG("Encoded Sub Address = [%s]", p_msg->sub_address); + + void* p = (void*)encodedData; + + memcpy(p, &(bInsert), sizeof(bool)); + p = (void*)((char*)p + sizeof(bool)); + + memcpy(p, &(msgId), sizeof(msg_message_id_t)); + p = (void*)((char*)p + sizeof(msg_message_id_t)); + + memcpy(p, p_msg, sizeof(MSG_UNIQUE_INDEX_S)); + p = (void*)((char*)p + sizeof(MSG_UNIQUE_INDEX_S)); + + // composing command + int cmdSize = sizeof(MSG_CMD_S) + dataSize; // cmd type, MSG_MESSAGE_INFO_S + + MSG_DEBUG("cmdSize: %d", cmdSize); + + char cmdBuf[cmdSize]; + bzero(cmdBuf, cmdSize); + + MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf; + + // Set Command Parameters + pCmd->cmdType = MSG_CMD_PLG_CHECK_UNIQUENESS; + + memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); + + memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), encodedData, dataSize); + + // Send Command to Messaging FW + client.write(cmdBuf, cmdSize); + + char* retBuf = NULL; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; + + client.read(&retBuf, &retSize); + + // close connection to msgfw daemon + client.close(); + + // Decoding the result from FW and Returning it to plugin + // the result is used for making delivery report + MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; + + if (pEvent->eventType != MSG_EVENT_PLG_CHECK_UNIQUENESS) + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + + MSG_END(); + + if (pEvent->result == MSG_SUCCESS) + return true; + else + return false; +} +#endif + +msg_error_t MsgSimImsiListener(int sim_idx) +{ + MSG_BEGIN(); + + // establish connection to msgfw daemon + MsgIpcClientSocket client; + try + { + client.connect(MSG_SOCKET_PATH); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_UNKNOWN; + } + + // composing command + int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); + + char cmdBuf[cmdSize]; + bzero(cmdBuf, cmdSize); + + MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf; + + // Set Command Parameters + pCmd->cmdType = MSG_CMD_UPDATE_IMSI; + + memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); + memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), (const void *)&sim_idx, sizeof(int)); + + // Send Command to Transaction Manager + client.write(cmdBuf, cmdSize); + + // Receive result from Transaction Manager + char* retBuf = NULL; + unique_ptr wrap(&retBuf, unique_ptr_deleter); + unsigned int retSize; + client.read(&retBuf, &retSize); + + // close connection to msgfw daemon + client.close(); + + // Decoding the result from FW and Returning it to plugin + MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf; + + if (pEvent->eventType != MSG_EVENT_UPDATE_IMSI) + MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); + //THROW(MsgException::INVALID_RESULT, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); MSG_END(); @@ -379,11 +885,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 @@ -392,40 +898,48 @@ 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(); if (error != NULL) - THROW(MsgException::PLUGIN_ERROR, "ERROR dlsym library : [%s]", dlerror()); + THROW(MsgException::PLUGIN_ERROR, "ERROR dlsym library : [%s]", error); - if ((*pFunc)(&mPlgHandler) != MSG_SUCCESS) + if (pFunc && (*pFunc)(&mPlgHandler) != MSG_SUCCESS) THROW(MsgException::PLUGIN_ERROR, "ERROR to create plugin handle"); - // Initialize Plug-in - if (initialize() != MSG_SUCCESS) - THROW(MsgException::PLUGIN_ERROR, "ERROR to initialize plugin"); - MSG_PLUGIN_LISTENER_S fwListener = {0}; - fwListener.pfSentStatusCb = &MsgSentStatusListener; - fwListener.pfStorageChangeCb = &MsgStorageChangeListener; - fwListener.pfMsgIncomingCb = &MsgIncomingMessageListener; - fwListener.pfInitSimBySatCb = &MsgInitSimBySatListener; + fwListener.pfSentStatusCb = &MsgSentStatusListener; + fwListener.pfStorageChangeCb = &MsgStorageChangeListener; + fwListener.pfMsgIncomingCb = &MsgIncomingMessageListener; + fwListener.pfInitSimBySatCb = &MsgInitSimBySatListener; fwListener.pfSyncMLMsgIncomingCb = &MsgIncomingSyncMLMessageListener; fwListener.pfLBSMsgIncomingCb = &MsgIncomingLBSMessageListener; - fwListener.pfMmsConfIncomingCb = &MsgMmsConfIncomingListener; + fwListener.pfMmsConfIncomingCb = &MsgMmsConfIncomingListener; + fwListener.pfPushMsgIncomingCb = &MsgIncomingPushMessageListener; + fwListener.pfCBMsgIncomingCb = &MsgIncomingCBMessageListener; + fwListener.pfSimMsgIncomingCb = &MsgSimMessageListener; + fwListener.pfResendMessageCb = &MsgResendMessageListener; +#ifdef FEATURE_SMS_CDMA + fwListener.pfCheckUniquenessCb = &MsgCheckUniquenessListener; +#endif + fwListener.pfSimInitImsiCb = &MsgSimImsiListener; if (registerListener(&fwListener) != MSG_SUCCESS) THROW(MsgException::PLUGIN_ERROR, "ERROR to register listener"); -// dlclose(libHandle); + // Initialize Plug-in + if (initialize() != MSG_SUCCESS) + THROW(MsgException::PLUGIN_ERROR, "ERROR to initialize plugin"); } MsgPlugin::~MsgPlugin() { - - + this->finalize(); + // close mLibHandler. + if (mLibHandler != NULL) + dlclose(mLibHandler); } @@ -463,42 +977,41 @@ msg_error_t MsgPlugin::registerListener(MSG_PLUGIN_LISTENER_S *pListener) } -msg_error_t MsgPlugin::checkSimStatus(MSG_SIM_STATUS_T *pStatus) +msg_error_t MsgPlugin::saveSimMessage(MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList) { - if (mPlgHandler.pfRegisterListener != NULL) - return mPlgHandler.pfCheckSimStatus(pStatus); + if (mPlgHandler.pfSaveSimMessage != NULL) + return mPlgHandler.pfSaveSimMessage(pMsgInfo, pSimIdList); else return MSG_ERR_INVALID_PLUGIN_HANDLE; } - -msg_error_t MsgPlugin::checkDeviceStatus() +#ifndef FEATURE_SMS_CDMA +msg_error_t MsgPlugin::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId) { - if (mPlgHandler.pfRegisterListener != NULL) - return mPlgHandler.pfCheckDeviceStatus(); + if (mPlgHandler.pfDeleteSimMessage != NULL) + return mPlgHandler.pfDeleteSimMessage(sim_idx, SimMsgId); else return MSG_ERR_INVALID_PLUGIN_HANDLE; } -msg_error_t MsgPlugin::initSimMessage() +msg_error_t MsgPlugin::setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId) { - if (mPlgHandler.pfInitSimMessage != NULL) - return mPlgHandler.pfInitSimMessage(); + if (mPlgHandler.pfSetReadStatus != NULL) + return mPlgHandler.pfSetReadStatus(sim_idx, SimMsgId); else return MSG_ERR_INVALID_PLUGIN_HANDLE; } -msg_error_t MsgPlugin::saveSimMessage(MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList) +msg_error_t MsgPlugin::setMemoryStatus(msg_sim_slot_id_t sim_idx, msg_error_t Error) { - if (mPlgHandler.pfSaveSimMessage != NULL) - return mPlgHandler.pfSaveSimMessage(pMsgInfo, pSimIdList); + if (mPlgHandler.pfSetMemoryStatus != NULL) + return mPlgHandler.pfSetMemoryStatus(sim_idx, Error); else return MSG_ERR_INVALID_PLUGIN_HANDLE; } - - +#else msg_error_t MsgPlugin::deleteSimMessage(msg_sim_id_t SimMsgId) { if (mPlgHandler.pfDeleteSimMessage != NULL) @@ -524,17 +1037,7 @@ msg_error_t MsgPlugin::setMemoryStatus(msg_error_t Error) else return MSG_ERR_INVALID_PLUGIN_HANDLE; } - - -msg_error_t MsgPlugin::initConfigData(MSG_SIM_STATUS_T SimStatus) -{ - if (mPlgHandler.pfInitConfigData != NULL) - return mPlgHandler.pfInitConfigData(SimStatus); - else - return MSG_ERR_INVALID_PLUGIN_HANDLE; -} - - +#endif msg_error_t MsgPlugin::setConfigData(const MSG_SETTING_S *pSetting) { if (mPlgHandler.pfSetConfigData != NULL) @@ -581,10 +1084,10 @@ msg_error_t MsgPlugin::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQU } -msg_error_t MsgPlugin::getMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg) +msg_error_t MsgPlugin::getMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char **pDestMsg) { if (mPlgHandler.pfGetMmsMessage != NULL) { - return mPlgHandler.pfGetMmsMessage(pMsg, pSendOptInfo, pMmsMsg, pDestMsg); + return mPlgHandler.pfGetMmsMessage(pMsg, pSendOptInfo, pDestMsg); } else { return MSG_ERR_INVALID_PLUGIN_HANDLE; } @@ -619,6 +1122,14 @@ msg_error_t MsgPlugin::restoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char* pRecvBody, return MSG_ERR_INVALID_PLUGIN_HANDLE; } +msg_error_t MsgPlugin::getDefaultNetworkSimId(int *SimId) +{ + if (mPlgHandler.pfGetDefaultNetworkSimId != NULL) + return mPlgHandler.pfGetDefaultNetworkSimId(SimId); + else + return MSG_ERR_INVALID_PLUGIN_HANDLE; +} + /*================================================================================================== IMPLEMENTATION OF MsgPluginManager - Member Functions @@ -643,12 +1154,31 @@ MsgPluginManager::MsgPluginManager() void MsgPluginManager::initialize() { - char path[64]; - - memset(path, 0x00, sizeof(path)); - snprintf(path, sizeof(path), "%s%s", MSG_PLUGIN_CFG_PATH, MSG_PLUGIN_CFG_NAME); + int plg_len = sizeof(__msg_plg_items)/sizeof(MSG_PLG_TABLE_T); + for (int i=0; i < plg_len; i++) { + MsgPlugin* pDupPlgCheck = checkPlugin(__msg_plg_items[i].type); + + if (pDupPlgCheck) { + MSG_DEBUG("Plugin for type %d is duplicated", __msg_plg_items[i].type); + continue; + } + + MsgPlugin *newPlg = NULL; + + try + { + newPlg = new MsgPlugin(__msg_plg_items[i].type, __msg_plg_items[i].path); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + continue; + } + + if (newPlg) + plgMap.insert(make_pair(__msg_plg_items[i].type, newPlg)); - loadPlugins(path); + } } @@ -658,56 +1188,37 @@ 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(); } -void MsgPluginManager::loadPlugins(const char* path) +MsgPlugin* MsgPluginManager::checkPlugin(MSG_MAIN_TYPE_T mainType) { - /* read plugins from configuration file */ - FILE* fp = MsgOpenFile(path, "rt"); - - MsgPlgConfig plgConf = MsgPlgConfig(fp); - - for (int i=0; i < plgConf.titleCount(); i++) - { - MsgPlgToken tok; - - plgConf.token(i, 0, tok); - const char* content = tok.getVal(); - - MSG_MAIN_TYPE_T mainType = strstr(content,"sms")? MSG_SMS_TYPE: - (strstr(content,"mms")? MSG_MMS_TYPE: MSG_UNKNOWN_TYPE); - - plgConf.token(i, 1, tok); - const char* libPath = tok.getVal(); - - MsgPlugin* pDupPlgCheck = getPlugin(mainType); - - if (pDupPlgCheck) - THROW(MsgException::PLUGIN_ERROR, "Plugin for type %d is duplicated", mainType); - - MsgPlugin newPlg(mainType, libPath); + /* Implementing the content */ + MsgPluginMap::iterator it = plgMap.find(mainType); - plgMap.insert(make_pair(mainType, newPlg)); - } + if (it == plgMap.end()) + return NULL; - MsgCloseFile(fp); + return it->second; } MsgPlugin* MsgPluginManager::getPlugin(MSG_MAIN_TYPE_T mainType) { - /* Implementing the content */ - MsgPluginMap::iterator it = plgMap.find(mainType); + MsgPlugin *plugin = NULL; - if (it == plgMap.end()) - return NULL; + if (plgMap.size() == 0) { + MSG_INFO("Msg plugin is initializing again"); + initialize(); + } + + plugin = checkPlugin(mainType); - return &(it->second); + return plugin; } diff --git a/framework/setting-handler/MsgSettingHandler.cpp b/framework/setting-handler/MsgSettingHandler.cpp index 247dd89..f805bab 100755 --- a/framework/setting-handler/MsgSettingHandler.cpp +++ b/framework/setting-handler/MsgSettingHandler.cpp @@ -1,23 +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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "MsgDebug.h" #include "MsgPluginManager.h" #include "MsgSettingHandler.h" #include "MsgGconfWrapper.h" +#include "MsgUtilFunction.h" +#include "MsgSqliteWrapper.h" +#include "MsgUtilStorage.h" #define DEF_BUF_LEN 128 @@ -25,42 +28,16 @@ /*================================================================================================== STATIC FUNCTION PROTOTYPES ==================================================================================================*/ -static char* msg_clean_country_code(char *src); -static char* msg_normalize_number(char *src); /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ -msg_error_t MsgInitSimConfig(MSG_SIM_STATUS_T SimStatus) -{ - MSG_DEBUG("Start to initialize SIM Configuration"); - - msg_error_t err = MSG_SUCCESS; - - if (SimStatus != MSG_SIM_STATUS_NOT_FOUND) - { - MSG_MAIN_TYPE_T mainType = MSG_SMS_TYPE; - MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType); - - if (plg == NULL) - { - MSG_DEBUG("No plugin for %d type", mainType); - return MSG_ERR_INVALID_PLUGIN_HANDLE; - } - - // Check SIM Status - MSG_DEBUG(" ** SIM is available - status : [%d] ** ", SimStatus); - - err = plg->initConfigData(SimStatus); - } - - return err; -} - - msg_error_t MsgSetConfigData(const MSG_SETTING_S *pSetting) { msg_error_t err = MSG_SUCCESS; + char keyName[MAX_VCONFKEY_NAME_LEN]; + memset(keyName, 0x00, sizeof(keyName)); + MSG_SIM_STATUS_T simStatus = MSG_SIM_STATUS_NOT_FOUND; #ifdef USE_GCONF err = MsgGconfGetClient(); @@ -82,9 +59,19 @@ msg_error_t MsgSetConfigData(const MSG_SETTING_S *pSetting) case MSG_SMS_SENDOPT : err = MsgSetSMSSendOpt(pSetting); break; +#ifndef FEATURE_SMS_CDMA case MSG_SMSC_LIST : + // Check SIM is present or not + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pSetting->option.smscList.simIndex); + simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); + + if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { + MSG_DEBUG("SIM is not present.."); + return MSG_ERR_NO_SIM; + } err = MsgSetSMSCList(pSetting, true); break; +#endif case MSG_MMS_SENDOPT : err = MsgSetMMSSendOpt(pSetting); break; @@ -98,10 +85,28 @@ msg_error_t MsgSetConfigData(const MSG_SETTING_S *pSetting) err = MsgSetPushMsgOpt(pSetting); break; case MSG_CBMSG_OPT : + if (pSetting->option.cbMsgOpt.simIndex != 0) { + // Check SIM is present or not + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pSetting->option.cbMsgOpt.simIndex); + simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); + + if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { + MSG_DEBUG("SIM is not present.."); + return MSG_ERR_NO_SIM; + } + } err = MsgSetCBMsgOpt(pSetting, true); break; case MSG_VOICEMAIL_OPT : - err = MsgSetVoiceMailOpt(pSetting); + // Check SIM is present or not + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pSetting->option.voiceMailOpt.simIndex); + simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); + + if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { + MSG_DEBUG("SIM is not present.."); + return MSG_ERR_NO_SIM; + } + err = MsgSetVoiceMailOpt(pSetting, true); break; case MSG_MSGSIZE_OPT: err = MsgSetMsgSizeOpt(pSetting); @@ -129,9 +134,8 @@ msg_error_t MsgGetConfigData(MSG_SETTING_S *pSetting) return MSG_ERR_NULL_POINTER; } #endif - - // Check SIM is present or not - MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(MSG_SIM_CHANGED); + char keyName[MAX_VCONFKEY_NAME_LEN] = {0,}; + MSG_SIM_STATUS_T simStatus = MSG_SIM_STATUS_NOT_FOUND; switch (pSetting->type) { @@ -143,6 +147,10 @@ msg_error_t MsgGetConfigData(MSG_SETTING_S *pSetting) break; case MSG_SMSC_LIST : { + // Check SIM is present or not + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pSetting->option.smscList.simIndex); + simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); + if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { MSG_DEBUG("SIM is not present.."); return MSG_ERR_NO_SIM; @@ -164,6 +172,10 @@ msg_error_t MsgGetConfigData(MSG_SETTING_S *pSetting) break; case MSG_CBMSG_OPT : { + // Check SIM is present or not + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pSetting->option.cbMsgOpt.simIndex); + simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); + if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { MSG_DEBUG("SIM is not present.."); return MSG_ERR_NO_SIM; @@ -172,6 +184,19 @@ msg_error_t MsgGetConfigData(MSG_SETTING_S *pSetting) } break; case MSG_VOICEMAIL_OPT : + // Check SIM is present or not + if (pSetting->option.voiceMailOpt.simIndex == 0) { + MSG_DEBUG("Invalid SIM Index [%d]", pSetting->option.voiceMailOpt.simIndex); + return MSG_ERR_INVALID_PARAMETER; + } + + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pSetting->option.voiceMailOpt.simIndex); + simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); + + if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { + MSG_DEBUG("SIM is not present.."); + return MSG_ERR_NO_SIM; + } MsgGetVoiceMailOpt(pSetting); break; case MSG_MSGSIZE_OPT : @@ -194,6 +219,8 @@ msg_error_t MsgSetGeneralOpt(const MSG_SETTING_S *pSetting) { MSG_GENERAL_OPT_S generalOpt; bool bValue = false; + int iValue = 0; + char *strValue = NULL; memcpy(&generalOpt, &(pSetting->option.generalOpt), sizeof(MSG_GENERAL_OPT_S)); @@ -213,6 +240,100 @@ msg_error_t MsgSetGeneralOpt(const MSG_SETTING_S *pSetting) } } + MsgSettingGetBool(MSG_BLOCK_UNKNOWN_MSG, &bValue); + if (bValue != generalOpt.bBlockUnknownMsg) { + if (MsgSettingSetBool(MSG_BLOCK_UNKNOWN_MSG, generalOpt.bBlockUnknownMsg) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_BLOCK_UNKNOWN_MSG); + return MSG_ERR_SET_SETTING; + } + } + + iValue = MsgSettingGetInt(MSG_SMS_LIMIT); + if (iValue != (int)generalOpt.smsLimitCnt) { + if (MsgSettingSetInt(MSG_SMS_LIMIT, (int)generalOpt.smsLimitCnt) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_SMS_LIMIT); + return MSG_ERR_SET_SETTING; + } + } + + iValue = MsgSettingGetInt(MSG_MMS_LIMIT); + if (iValue != (int)generalOpt.mmsLimitCnt) { + if (MsgSettingSetInt(MSG_MMS_LIMIT, (int)generalOpt.mmsLimitCnt) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_MMS_LIMIT); + return MSG_ERR_SET_SETTING; + } + } + + MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bValue); + if (bValue != generalOpt.bNotification) { + if (MsgSettingSetBool(MSG_SETTING_NOTIFICATION, generalOpt.bNotification) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_SETTING_NOTIFICATION); + return MSG_ERR_SET_SETTING; + } + } + + MsgSettingGetBool(MSG_SETTING_VIBRATION, &bValue); + if (bValue != generalOpt.bVibration) { + if (MsgSettingSetBool(MSG_SETTING_VIBRATION, generalOpt.bVibration) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_SETTING_VIBRATION); + return MSG_ERR_SET_SETTING; + } + } + + MsgSettingGetBool(MSG_SETTING_PREVIEW, &bValue); + if (bValue != generalOpt.bPreview) { + if (MsgSettingSetBool(MSG_SETTING_PREVIEW, generalOpt.bPreview) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_SETTING_PREVIEW); + return MSG_ERR_SET_SETTING; + } + } + + iValue = MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE); + if (iValue != generalOpt.ringtoneType) { + if (MsgSettingSetInt(MSG_SETTING_RINGTONE_TYPE, generalOpt.ringtoneType) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_SETTING_RINGTONE_TYPE); + return MSG_ERR_SET_SETTING; + } + } + + if (generalOpt.ringtoneType == MSG_RINGTONE_TYPE_SILENT) { + if (MsgSettingSetString(MSG_SETTING_RINGTONE_PATH, "") != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_SETTING_RINGTONE_PATH); + return MSG_ERR_SET_SETTING; + } + } else { + strValue = MsgSettingGetString(MSG_SETTING_RINGTONE_PATH); + MSG_DEBUG("strValue=[%s], ringtone=[%s]", strValue, generalOpt.ringtonePath); + + if (g_strcmp0(strValue, generalOpt.ringtonePath) != 0) { + if (MsgSettingSetString(MSG_SETTING_RINGTONE_PATH, generalOpt.ringtonePath) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_SETTING_RINGTONE_PATH); + return MSG_ERR_SET_SETTING; + } + } + } + + if (strValue) { + free(strValue); + strValue = NULL; + } + + iValue = MsgSettingGetInt(MSG_ALERT_REP_TYPE); + if (iValue != (int)generalOpt.alertTone) { + if (MsgSettingSetInt(MSG_ALERT_REP_TYPE, (int)generalOpt.alertTone) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_ALERT_REP_TYPE); + return MSG_ERR_SET_SETTING; + } + } + + iValue = MsgSettingGetInt(MSG_SEARCH_TAGS); + if (iValue != (int)generalOpt.searchTags) { + if (MsgSettingSetInt(MSG_SEARCH_TAGS, (int)generalOpt.searchTags) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", MSG_SEARCH_TAGS); + return MSG_ERR_SET_SETTING; + } + } + return MSG_SUCCESS; } @@ -273,96 +394,46 @@ msg_error_t MsgSetSMSCList(const MSG_SETTING_S *pSetting, bool bSetSim) { msg_error_t err = MSG_SUCCESS; - for (int index = 0; index < pSetting->option.smscList.totalCnt; index++) - { - if(strlen(pSetting->option.smscList.smscData[index].smscAddr.address) > SMSC_ADDR_MAX) - { - MSG_DEBUG("SMSC address is too long [%d]", strlen(pSetting->option.smscList.smscData[index].smscAddr.address)); - return MSG_ERR_SET_SIM_SET; - } - } - - if (bSetSim == true) - { - err = MsgSetConfigInSim(pSetting); - - if (err != MSG_SUCCESS) - { - MSG_DEBUG("Error to set config data in sim [%d]", err); - return err; - } - } - - MSG_SMSC_LIST_S smscList; + int addrLen = 0; + int index = 0; + MSG_SMSC_LIST_S smscList = {0,}; memcpy(&smscList, &(pSetting->option.smscList), sizeof(MSG_SMSC_LIST_S)); - char keyName[DEF_BUF_LEN] = {0, }; +// int sel_id = smscList.selected; - // No selected SMSC Info. in SIM. - if (bSetSim == true) - { - if (MsgSettingSetInt(SMSC_SELECTED, smscList.selected) != MSG_SUCCESS) - { - MSG_DEBUG("Error to set config data [%s]", SMSC_SELECTED); - return MSG_ERR_SET_SETTING; - } - } + index = smscList.index; - if (MsgSettingSetInt(SMSC_TOTAL_COUNT, smscList.totalCnt) != MSG_SUCCESS) - { - MSG_DEBUG("Error to set config data [%s]", SMSC_TOTAL_COUNT); - return MSG_ERR_SET_SETTING; + if (index < 0 || index >= smscList.totalCnt) { + MSG_DEBUG("Update SMSC index is invalid [id=%d]", index); + return MSG_ERR_INVALID_PARAMETER; } - for (int i = 0; i < smscList.totalCnt; i++) - { - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_PID, i); - - if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].pid)) != MSG_SUCCESS) - break; - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_VAL_PERIOD, i); - - if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].valPeriod)) != MSG_SUCCESS) - break; - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NAME, i); - - if ((err = MsgSettingSetString(keyName, smscList.smscData[i].name)) != MSG_SUCCESS) - break; - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_TON, i); - - if (smscList.smscData[i].smscAddr.address[0] == '+') - smscList.smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL; - else - smscList.smscData[i].smscAddr.ton = MSG_TON_NATIONAL; - - if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].smscAddr.ton)) != MSG_SUCCESS) - break; - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NPI, i); - - smscList.smscData[i].smscAddr.npi = MSG_NPI_ISDN; // app cannot set this value - - if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].smscAddr.npi)) != MSG_SUCCESS) - break; + if (pSetting->option.smscList.smscData[index].smscAddr.address[0] == '+') + addrLen = strlen(pSetting->option.smscList.smscData[index].smscAddr.address) - 1; + else + addrLen = strlen(pSetting->option.smscList.smscData[index].smscAddr.address); - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_ADDRESS, i); + if(addrLen > SMSC_ADDR_MAX) { + MSG_DEBUG("SMSC address is too long [%d]", strlen(pSetting->option.smscList.smscData[index].smscAddr.address)); + return MSG_ERR_SET_SIM_SET; + } else if(addrLen < 2) { + MSG_DEBUG("SMSC address is too short [%d]", addrLen); + return MSG_ERR_SET_SIM_SET; + } - if ((err = MsgSettingSetString(keyName, smscList.smscData[i].smscAddr.address)) != MSG_SUCCESS) - break; + if (pSetting->option.smscList.simIndex == 0) { + MSG_DEBUG("SIM Index for Setting SMSC List = 0"); + return MSG_ERR_INVALID_PARAMETER; } - if (err != MSG_SUCCESS) - { - MSG_DEBUG("Error to set config data [%s]", keyName); + if (bSetSim == true) { + err = MsgSetConfigInSim(pSetting); + + if (err != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data in sim [%d]", err); + return err; + } } return err; @@ -440,6 +511,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) { @@ -720,17 +798,28 @@ msg_error_t MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim) MSG_CBMSG_OPT_S cbOpt; int iValue = 0; bool bValue = false; + char keyName[MAX_VCONFKEY_NAME_LEN]; + msg_sim_slot_id_t simIndex; memcpy(&cbOpt, &(pSetting->option.cbMsgOpt), sizeof(MSG_CBMSG_OPT_S)); - if (bSetSim == true) { - cbOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT); + simIndex = cbOpt.simIndex; - if (cbOpt.channelData.channelCnt > cbOpt.maxSimCnt) { - MSG_DEBUG("Channel Count is over Max SIM Count [%d]", cbOpt.channelData.channelCnt); - return MSG_ERR_SET_SIM_SET; - } + MSG_DEBUG("SIM Index = [%d]", simIndex); + + if (bSetSim == true) {//if (bSetSim == true && simIndex != 0) { +#ifndef FEATURE_SMS_CDMA + if (simIndex != 0) { + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex); + cbOpt.maxSimCnt = MsgSettingGetInt(keyName); + if (cbOpt.channelData.channelCnt > cbOpt.maxSimCnt) { + MSG_DEBUG("Channel Count [%d] is over Max SIM Count [%d]", cbOpt.channelData.channelCnt,cbOpt.maxSimCnt); + return MSG_ERR_SET_SIM_SET; + } + } +#endif err = MsgSetConfigInSim(pSetting); if (err != MSG_SUCCESS) { MSG_DEBUG("Error to set config data in sim [%d]", err); @@ -738,58 +827,43 @@ msg_error_t MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim) } } - MsgSettingGetBool(CB_RECEIVE, &bValue); + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, simIndex); + MsgSettingGetBool(keyName, &bValue); if (bValue != cbOpt.bReceive) { - if (MsgSettingSetBool(CB_RECEIVE, cbOpt.bReceive) != MSG_SUCCESS) { - MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE); + if (MsgSettingSetBool(keyName, cbOpt.bReceive) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", keyName); return MSG_ERR_SET_SETTING; } } - iValue = MsgSettingGetInt(CB_MAX_SIM_COUNT); - if (iValue != cbOpt.maxSimCnt) { - if (MsgSettingSetInt(CB_MAX_SIM_COUNT, cbOpt.maxSimCnt) != MSG_SUCCESS) { - MSG_DEBUG("Error to set config data [%s]", CB_MAX_SIM_COUNT); - return MSG_ERR_SET_SETTING; - } +#ifndef FEATURE_SMS_CDMA + if (simIndex == 0) { + MSG_DEBUG("SIM Index for Setting CB Option = 0, Setting for CB_RECEIVE success"); + return MSG_SUCCESS; } - iValue = MsgSettingGetInt(CB_CHANNEL_COUNT); - if (iValue != cbOpt.channelData.channelCnt) { - if (MsgSettingSetInt(CB_CHANNEL_COUNT, cbOpt.channelData.channelCnt) != MSG_SUCCESS) { - MSG_DEBUG("Error to set config data [%s]", CB_CHANNEL_COUNT); + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex); + iValue = MsgSettingGetInt(keyName); + if (iValue != cbOpt.maxSimCnt) { + if (MsgSettingSetInt(keyName, cbOpt.maxSimCnt) != MSG_SUCCESS) { + MSG_DEBUG("Error to set config data [%s]", keyName); return MSG_ERR_SET_SETTING; } } +#endif - char keyName[DEF_BUF_LEN] = {0, }; - - for (int i = 0; i < cbOpt.channelData.channelCnt; i++) - { - snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ACTIVATE, i); - - if ((err = MsgSettingSetBool(keyName, cbOpt.channelData.channelInfo[i].bActivate)) != MSG_SUCCESS) - break; - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ID_FROM, i); - - if ((err = MsgSettingSetInt(keyName, cbOpt.channelData.channelInfo[i].from)) != MSG_SUCCESS) - break; - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ID_TO, i); - - if ((err = MsgSettingSetInt(keyName, cbOpt.channelData.channelInfo[i].to)) != MSG_SUCCESS) - break; - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_NAME, i); + MsgDbHandler *dbHandle = getDbHandle(); - if ((err = MsgSettingSetString(keyName, cbOpt.channelData.channelInfo[i].name)) != MSG_SUCCESS) - break; - } +#ifdef FEATURE_SMS_CDMA + err = MsgStoAddCBChannelInfo(dbHandle, &cbOpt.channelData); +#else + err = MsgStoAddCBChannelInfo(dbHandle, &cbOpt.channelData, simIndex); +#endif + MSG_DEBUG("MsgStoAddCBChannelInfo : err=[%d]", err); +#ifndef FEATURE_SMS_CDMA if (bSetSim == true) { for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) @@ -804,39 +878,59 @@ msg_error_t MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim) } } } +#endif 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; + char keyName[DEF_BUF_LEN]; + msg_sim_slot_id_t simIndex = 0; + msg_error_t err = MSG_SUCCESS; memcpy(&voiceMailOpt, &(pSetting->option.voiceMailOpt), sizeof(MSG_VOICEMAIL_OPT_S)); - pValue = MsgSettingGetString(VOICEMAIL_NUMBER); + simIndex = pSetting->option.voiceMailOpt.simIndex; + + if (simIndex == 0) { + MSG_DEBUG("SIM Index for Setting Voicemail Option = 0"); + return MSG_ERR_INVALID_PARAMETER; + } + + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex); + + pValue = MsgSettingGetString(keyName); + 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); + /* Even if err is not Success, no need to return error. */ + MSG_DEBUG("MsgSetConfigInSim return [%d]", err); + } - return MSG_ERR_SET_SETTING; + if (err != MSG_SUCCESS) { + goto _END_OF_SET_VOICE_OPT; } + + err = MsgSettingSetString(keyName, voiceMailOpt.mailNumber); + if (err != MSG_SUCCESS) + MSG_ERR("Error to set config data [%s]", keyName); } +_END_OF_SET_VOICE_OPT: if (pValue != NULL) { free(pValue); pValue = NULL; } - return MSG_SUCCESS; + return err; } @@ -861,85 +955,65 @@ msg_error_t MsgSetMsgSizeOpt(const MSG_SETTING_S *pSetting) void MsgGetGeneralOpt(MSG_SETTING_S *pSetting) { + char *tmpValue = NULL; + memset(&(pSetting->option.generalOpt), 0x00, sizeof(MSG_GENERAL_OPT_S)); MsgSettingGetBool(MSG_KEEP_COPY, &pSetting->option.generalOpt.bKeepCopy); -} + MsgSettingGetBool(MSG_BLOCK_UNKNOWN_MSG, &pSetting->option.generalOpt.bBlockUnknownMsg); -void MsgGetSMSSendOpt(MSG_SETTING_S *pSetting) -{ - memset(&(pSetting->option.smsSendOpt), 0x00, sizeof(MSG_SMS_SENDOPT_S)); + pSetting->option.generalOpt.smsLimitCnt = MsgSettingGetInt(MSG_SMS_LIMIT); - pSetting->option.smsSendOpt.dcs = (msg_encode_type_t)MsgSettingGetInt(SMS_SEND_DCS); + pSetting->option.generalOpt.mmsLimitCnt = MsgSettingGetInt(MSG_MMS_LIMIT); - pSetting->option.smsSendOpt.netMode = (MSG_SMS_NETWORK_MODE_T)MsgSettingGetInt(SMS_SEND_NETWORK_MODE); + MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &pSetting->option.generalOpt.bNotification); - MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSetting->option.smsSendOpt.bReplyPath); + MsgSettingGetBool(MSG_SETTING_VIBRATION, &pSetting->option.generalOpt.bVibration); - MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSetting->option.smsSendOpt.bDeliveryReport); + MsgSettingGetBool(MSG_SETTING_PREVIEW, &pSetting->option.generalOpt.bPreview); - pSetting->option.smsSendOpt.saveStorage = (MSG_SMS_SAVE_STORAGE_T)MsgSettingGetInt(SMS_SEND_SAVE_STORAGE); -} + MsgSettingGetBool(MSG_AUTO_ERASE, &pSetting->option.generalOpt.bAutoErase); + pSetting->option.generalOpt.ringtoneType = MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE); -void MsgGetSMSCList(MSG_SETTING_S *pSetting) -{ - char keyName[DEF_BUF_LEN] = {0, }; - char *tmpValue = NULL; - - memset(&(pSetting->option.smscList), 0x00, sizeof(MSG_SMSC_LIST_S)); - - pSetting->option.smscList.selected = MsgSettingGetInt(SMSC_SELECTED); - - pSetting->option.smscList.totalCnt = MsgSettingGetInt(SMSC_TOTAL_COUNT); + tmpValue = MsgSettingGetString(MSG_SETTING_RINGTONE_PATH); + if (tmpValue != NULL) { + strncpy(pSetting->option.generalOpt.ringtonePath, tmpValue, MSG_FILEPATH_LEN_MAX); + free(tmpValue); + tmpValue = NULL; + } - for (int i = 0; i < pSetting->option.smscList.totalCnt; i++) - { - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_PID, i); + pSetting->option.generalOpt.alertTone = (MSG_ALERT_TONE_T)MsgSettingGetInt(MSG_ALERT_REP_TYPE); - pSetting->option.smscList.smscData[i].pid = (MSG_SMS_PID_T)MsgSettingGetInt(keyName); + pSetting->option.generalOpt.searchTags = MsgSettingGetInt(MSG_SEARCH_TAGS); - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_VAL_PERIOD, i); +} - pSetting->option.smscList.smscData[i].valPeriod = (MSG_VAL_PERIOD_T)MsgSettingGetInt(keyName); - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NAME, i); +void MsgGetSMSSendOpt(MSG_SETTING_S *pSetting) +{ + memset(&(pSetting->option.smsSendOpt), 0x00, sizeof(MSG_SMS_SENDOPT_S)); - memset(pSetting->option.smscList.smscData[i].name, 0x00, SMSC_NAME_MAX+1); + pSetting->option.smsSendOpt.dcs = (msg_encode_type_t)MsgSettingGetInt(SMS_SEND_DCS); - tmpValue = MsgSettingGetString(keyName); - if (tmpValue != NULL) { - strncpy(pSetting->option.smscList.smscData[i].name, tmpValue, SMSC_NAME_MAX); - free(tmpValue); - tmpValue = NULL; - } + pSetting->option.smsSendOpt.netMode = (MSG_SMS_NETWORK_MODE_T)MsgSettingGetInt(SMS_SEND_NETWORK_MODE); - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_TON, i); + MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSetting->option.smsSendOpt.bReplyPath); - pSetting->option.smscList.smscData[i].smscAddr.ton = (MSG_SMS_TON_T)MsgSettingGetInt(keyName); + MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSetting->option.smsSendOpt.bDeliveryReport); - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NPI, i); + pSetting->option.smsSendOpt.saveStorage = (MSG_SMS_SAVE_STORAGE_T)MsgSettingGetInt(SMS_SEND_SAVE_STORAGE); +} - pSetting->option.smscList.smscData[i].smscAddr.npi = (MSG_SMS_NPI_T)MsgSettingGetInt(keyName); - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_ADDRESS, i); +void MsgGetSMSCList(MSG_SETTING_S *pSetting) +{ + MSG_BEGIN(); - memset(pSetting->option.smscList.smscData[i].smscAddr.address, 0x00, sizeof(pSetting->option.smscList.smscData[i].smscAddr.address)); + MsgGetConfigInSim(pSetting); - tmpValue = MsgSettingGetString(keyName); - if (tmpValue != NULL) { - strncpy(pSetting->option.smscList.smscData[i].smscAddr.address, tmpValue, SMSC_ADDR_MAX); - free(tmpValue); - tmpValue = NULL; - } - } + MSG_END(); } @@ -963,6 +1037,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); @@ -1043,46 +1121,43 @@ void MsgGetPushMsgOpt(MSG_SETTING_S *pSetting) void MsgGetCBMsgOpt(MSG_SETTING_S *pSetting) { + msg_error_t err = MSG_SUCCESS; + char keyName[DEF_BUF_LEN] = {0, }; - char *tmpValue = NULL; + MsgDbHandler *dbHandle = getDbHandle(); + msg_sim_slot_id_t simIndex = pSetting->option.cbMsgOpt.simIndex; memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S)); - MsgSettingGetBool(CB_RECEIVE, &pSetting->option.cbMsgOpt.bReceive); + MSG_DEBUG("Sim index = [%d]", simIndex); - pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT); + /* Keep simIndex */ + pSetting->option.cbMsgOpt.simIndex = simIndex; - pSetting->option.cbMsgOpt.channelData.channelCnt = MsgSettingGetInt(CB_CHANNEL_COUNT); + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, simIndex); + MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bReceive); - for (int i = 0; i < pSetting->option.cbMsgOpt.channelData.channelCnt; i++) - { - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ACTIVATE, i); - - MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.channelData.channelInfo[i].bActivate); - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ID_FROM, i); - pSetting->option.cbMsgOpt.channelData.channelInfo[i].from = MsgSettingGetInt(keyName); - MSG_DEBUG("channel[%d]: from: %d", i, pSetting->option.cbMsgOpt.channelData.channelInfo[i].from); - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ID_TO, i); - pSetting->option.cbMsgOpt.channelData.channelInfo[i].to = MsgSettingGetInt(keyName); - MSG_DEBUG("channel[%d]: to: %d", i, pSetting->option.cbMsgOpt.channelData.channelInfo[i].to); + if (simIndex == 0) { + MSG_DEBUG("SIM Index = 0, bReceive is gotten"); + return; + } - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_NAME, i); +#ifndef FEATURE_SMS_CDMA + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex); + pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(keyName); +#endif - tmpValue = MsgSettingGetString(keyName); - if (tmpValue != NULL) { - strncpy(pSetting->option.cbMsgOpt.channelData.channelInfo[i].name, tmpValue, CB_CHANNEL_NAME_MAX); - MSG_DEBUG("channel[%d]: channel_name: %s", i, pSetting->option.cbMsgOpt.channelData.channelInfo[i].name); - free(tmpValue); - tmpValue = NULL; - } - } +#ifdef FEATURE_SMS_CDMA + err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData); +#else + err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData, simIndex); +#endif + if (err != MSG_SUCCESS) + MSG_ERR("MsgStoGetCBChannelInfo : err=[%d]", err); +#ifndef FEATURE_SMS_CDMA for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) { memset(keyName, 0x00, sizeof(keyName)); @@ -1090,229 +1165,94 @@ void MsgGetCBMsgOpt(MSG_SETTING_S *pSetting) MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]); } +#endif } + void MsgGetVoiceMailOpt(MSG_SETTING_S *pSetting) { - char *tmpValue = NULL; - - memset(&(pSetting->option.voiceMailOpt), 0x00, sizeof(MSG_VOICEMAIL_OPT_S)); - - tmpValue = MsgSettingGetString(VOICEMAIL_NUMBER); - if (tmpValue != NULL) { - strncpy(pSetting->option.voiceMailOpt.mailNumber, tmpValue, MAX_PHONE_NUMBER_LEN); - free(tmpValue); - tmpValue = NULL; - } + char *tmpValue = NULL; + char keyName[DEF_BUF_LEN]; + msg_sim_slot_id_t simIndex; + + simIndex = pSetting->option.voiceMailOpt.simIndex; + MSG_DEBUG("sim index = [%d]", simIndex); + + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex); + tmpValue = MsgSettingGetString(keyName); + memset(pSetting->option.voiceMailOpt.mailNumber, 0x00, sizeof(pSetting->option.voiceMailOpt.mailNumber)); + if (tmpValue != NULL) { + strncpy(pSetting->option.voiceMailOpt.mailNumber, tmpValue, MAX_PHONE_NUMBER_LEN); + MSG_SEC_DEBUG("Voicemail number = [%s]", pSetting->option.voiceMailOpt.mailNumber); + free(tmpValue); + tmpValue = NULL; + } + + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, simIndex); + tmpValue = MsgSettingGetString(keyName); + memset(pSetting->option.voiceMailOpt.alpahId, 0x00, sizeof(pSetting->option.voiceMailOpt.alpahId)); + if (tmpValue != NULL) { + strncpy(pSetting->option.voiceMailOpt.alpahId, tmpValue, MAX_SIM_XDN_ALPHA_ID_LEN); + MSG_SEC_DEBUG("Voicemail alpha ID = [%s]", pSetting->option.voiceMailOpt.alpahId); + free(tmpValue); + tmpValue = NULL; + } + + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, simIndex); + pSetting->option.voiceMailOpt.voiceCnt = MsgSettingGetInt(keyName); } void MsgGetMsgSizeOpt(MSG_SETTING_S *pSetting) { - memset(&(pSetting->option.msgSizeOpt), 0x00, sizeof(MSG_MSGSIZE_OPT_S)); + memset(&(pSetting->option.msgSizeOpt), 0x00, sizeof(MSG_MSGSIZE_OPT_S)); - pSetting->option.msgSizeOpt.nMsgSize = MsgSettingGetInt(MSGSIZE_OPTION); + pSetting->option.msgSizeOpt.nMsgSize = MsgSettingGetInt(MSGSIZE_OPTION); } msg_error_t MsgSetConfigInSim(const MSG_SETTING_S *pSetting) { - msg_error_t err = MSG_SUCCESS; - - MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); - - // Get Setting Data from SIM - if (plg != NULL) - err = plg->setConfigData(pSetting); - else - err = MSG_ERR_NULL_POINTER; + msg_error_t err = MSG_SUCCESS; - if (err != MSG_SUCCESS) - { - MSG_DEBUG("Error. Error code is %d.", err); - return err; - } + MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); - return err; -} - -static char* msg_clean_country_code(char *src) -{ - int ret = 1; + // Get Setting Data from SIM + if (plg != NULL) + err = plg->setConfigData(pSetting); + else + err = MSG_ERR_NULL_POINTER; - switch (src[ret++]-'0') + if (err != MSG_SUCCESS) { - 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; + MSG_DEBUG("Error. Error code is %d.", err); + return err; } - return &src[ret]; + return err; } -static char* msg_normalize_number(char *src) + +msg_error_t MsgGetConfigInSim(MSG_SETTING_S *pSetting) { - char *normalized_number; + msg_error_t err = MSG_SUCCESS; + + MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); - if ('+' == src[0]) - normalized_number = msg_clean_country_code(src); - else if ('0' == src[0]) - normalized_number = src+1; + // Get Setting Data from SIM + if (plg != NULL) + err = plg->getConfigData(pSetting); else - normalized_number = src; + err = MSG_ERR_NULL_POINTER; - MSG_DEBUG("src = %s, normalized = %s", src, normalized_number); + if (err != MSG_SUCCESS) + { + MSG_DEBUG("Error. Error code is %d.", err); + return err; + } - return normalized_number; + return err; } diff --git a/framework/storage-handler/MsgStorageFilter.cpp b/framework/storage-handler/MsgStorageFilter.cpp index ac18aa6..15641d9 100755 --- a/framework/storage-handler/MsgStorageFilter.cpp +++ b/framework/storage-handler/MsgStorageFilter.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "MsgDebug.h" @@ -22,7 +22,6 @@ /*================================================================================================== VARIABLES ==================================================================================================*/ -extern MsgDbHandler dbHandle; /*================================================================================================== @@ -31,27 +30,41 @@ extern MsgDbHandler dbHandle; msg_error_t MsgStoCheckDuplicatedFilter(const MSG_FILTER_S *pFilter) { MSG_BEGIN(); - + MsgDbHandler *dbHandle = getDbHandle(); msg_error_t err = MSG_SUCCESS; - int rowCnt = 0; + char *filterStr = NULL; char sqlQuery[MAX_QUERY_LEN+1]; - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + MsgConvertStrWithEscape(pFilter->filterValue, &filterStr); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_ID FROM %s WHERE FILTER_TYPE = %d AND FILTER_VALUE = '%s';", - MSGFW_FILTER_TABLE_NAME, pFilter->filterType, pFilter->filterValue); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_ID FROM %s WHERE FILTER_TYPE = %d AND FILTER_VALUE = ?;", + MSGFW_FILTER_TABLE_NAME, pFilter->filterType); MSG_DEBUG("sql : %s", sqlQuery); - err = dbHandle.getTable(sqlQuery, &rowCnt); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + { + if (filterStr) + free(filterStr); + return MSG_ERR_DB_EXEC; + } + + dbHandle->bindText(filterStr, 1); + + err = dbHandle->stepQuery(); - if (err == MSG_SUCCESS) + if (err == MSG_ERR_DB_ROW) { err = MSG_ERR_FILTER_DUPLICATED; - else if (err == MSG_ERR_DB_NORECORD) + } else if (err == MSG_ERR_DB_DONE) { err = MSG_SUCCESS; + } + + dbHandle->finalizeQuery(); - dbHandle.freeTable(); + if (filterStr) + free(filterStr); MSG_END(); @@ -62,7 +75,7 @@ msg_error_t MsgStoCheckDuplicatedFilter(const MSG_FILTER_S *pFilter) msg_error_t MsgStoAddFilter(const MSG_FILTER_S *pFilter) { MSG_BEGIN(); - + MsgDbHandler *dbHandle = getDbHandle(); msg_error_t err = MSG_SUCCESS; //check duplication @@ -77,7 +90,7 @@ msg_error_t MsgStoAddFilter(const MSG_FILTER_S *pFilter) char sqlQuery[MAX_QUERY_LEN+1]; - err = dbHandle.getRowId(MSGFW_FILTER_TABLE_NAME, &rowId); + err = dbHandle->getRowId(MSGFW_FILTER_TABLE_NAME, &rowId); if (err != MSG_SUCCESS) return err; @@ -85,22 +98,22 @@ msg_error_t MsgStoAddFilter(const MSG_FILTER_S *pFilter) // Add Filter memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, ?);", + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, ?, 1);", MSGFW_FILTER_TABLE_NAME, rowId, pFilter->filterType); MSG_DEBUG("sql : %s", sqlQuery); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; - dbHandle.bindText(pFilter->filterValue, 1); + dbHandle->bindText(pFilter->filterValue, 1); - if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) { - dbHandle.finalizeQuery(); + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); return MSG_ERR_DB_EXEC; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); MSG_END(); @@ -111,7 +124,7 @@ msg_error_t MsgStoAddFilter(const MSG_FILTER_S *pFilter) msg_error_t MsgStoUpdateFilter(const MSG_FILTER_S *pFilter) { MSG_BEGIN(); - + MsgDbHandler *dbHandle = getDbHandle(); msg_error_t err = MSG_SUCCESS; //check duplication @@ -130,17 +143,17 @@ msg_error_t MsgStoUpdateFilter(const MSG_FILTER_S *pFilter) snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FILTER_TYPE = %d, FILTER_VALUE = ? WHERE FILTER_ID = %d;", MSGFW_FILTER_TABLE_NAME, pFilter->filterType, pFilter->filterId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - dbHandle.bindText(pFilter->filterValue, 1); + dbHandle->bindText(pFilter->filterValue, 1); - if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) { - dbHandle.finalizeQuery(); + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); return MSG_ERR_DB_EXEC; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); MSG_END(); @@ -153,20 +166,20 @@ msg_error_t MsgStoDeleteFilter(msg_filter_id_t filterId) MSG_BEGIN(); char sqlQuery[MAX_QUERY_LEN+1]; - - dbHandle.beginTrans(); + MsgDbHandler *dbHandle = getDbHandle(); + dbHandle->beginTrans(); memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE FILTER_ID = %d;", MSGFW_FILTER_TABLE_NAME, filterId); // Delete Filter - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } - dbHandle.endTrans(true); + dbHandle->endTrans(true); MSG_END(); @@ -182,29 +195,29 @@ msg_error_t MsgStoGetFilterList(msg_struct_list_s *pFilterList) MSG_DEBUG("pFilterList is NULL"); return MSG_ERR_NULL_POINTER; } - - int rowCnt = 0, index = 3; + MsgDbHandler *dbHandle = getDbHandle(); + int rowCnt = 0, index = 0; char sqlQuery[MAX_QUERY_LEN+1]; // Get filters from DB memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_ID, FILTER_TYPE, FILTER_VALUE FROM %s;", MSGFW_FILTER_TABLE_NAME); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_ID, FILTER_TYPE, FILTER_VALUE, FILTER_ACTIVE FROM %s;", MSGFW_FILTER_TABLE_NAME); msg_error_t err = MSG_SUCCESS; - err = dbHandle.getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err == MSG_ERR_DB_NORECORD) { pFilterList->nCount = 0; pFilterList->msg_struct_info = NULL; - dbHandle.freeTable(); + dbHandle->freeTable(); return MSG_SUCCESS; } else if (err != MSG_SUCCESS) { - dbHandle.freeTable(); + dbHandle->freeTable(); return err; } @@ -212,27 +225,53 @@ msg_error_t MsgStoGetFilterList(msg_struct_list_s *pFilterList) MSG_DEBUG("pMsgCommInfoList->nCount [%d]", pFilterList->nCount); - pFilterList->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_FILTER_S *)*rowCnt]; + pFilterList->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(MSG_FILTER_S *)); + + if (pFilterList->msg_struct_info != NULL) { + msg_struct_s* pTmp = NULL; + + for (int i = 0; i < rowCnt; i++) + { + pFilterList->msg_struct_info[i] = (msg_struct_t)new msg_struct_s; + + pTmp = (msg_struct_s *)pFilterList->msg_struct_info[i]; + pTmp->type = MSG_STRUCT_FILTER; + pTmp->data = new MSG_FILTER_S; + MSG_FILTER_S *pFilter = (MSG_FILTER_S *)pTmp->data; + memset(pFilter, 0x00, sizeof(MSG_FILTER_S)); + pFilter->filterId = dbHandle->getColumnToInt(index++); + pFilter->filterType = dbHandle->getColumnToInt(index++); + memset(pFilter->filterValue, 0x00, sizeof(pFilter->filterValue)); + dbHandle->getColumnToString(index++, MAX_FILTER_VALUE_LEN, pFilter->filterValue); + pFilter->bActive = dbHandle->getColumnToInt(index++); + } + } - msg_struct_s* pTmp = NULL; + dbHandle->freeTable(); - for (int i = 0; i < rowCnt; i++) - { - pFilterList->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)]; - - pTmp = (msg_struct_s *)pFilterList->msg_struct_info[i]; - pTmp->type = MSG_STRUCT_FILTER; - pTmp->data = new char [sizeof(MSG_FILTER_S)]; - MSG_FILTER_S *pFilter = (MSG_FILTER_S *)pTmp->data; - memset(pFilter, 0x00, sizeof(MSG_FILTER_S)); - pFilter->filterId = dbHandle.getColumnToInt(index++); - pFilter->filterType = dbHandle.getColumnToInt(index++); - memset(pFilter->filterValue, 0x00, sizeof(pFilter->filterValue)); - dbHandle.getColumnToString(index++, MAX_FILTER_VALUE_LEN, pFilter->filterValue); - } + MSG_END(); + + return MSG_SUCCESS; +} - dbHandle.freeTable(); +msg_error_t MsgStoSetFilterActivation(msg_filter_id_t filterId, bool bActive) +{ + MSG_BEGIN(); + MsgDbHandler *dbHandle = getDbHandle(); + char sqlQuery[MAX_QUERY_LEN+1]; + + // Set Filter Activation + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FILTER_ACTIVE = %d WHERE FILTER_ID = %d;", + MSGFW_FILTER_TABLE_NAME, bActive, filterId); + + MSG_DEBUG("sqlQuery [%s]", sqlQuery); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_EXEC; + } MSG_END(); diff --git a/framework/storage-handler/MsgStorageFolder.cpp b/framework/storage-handler/MsgStorageFolder.cpp index 841859e..d9261dd 100755 --- a/framework/storage-handler/MsgStorageFolder.cpp +++ b/framework/storage-handler/MsgStorageFolder.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "MsgDebug.h" @@ -23,8 +23,6 @@ /*================================================================================================== VARIABLES ==================================================================================================*/ -extern MsgDbHandler dbHandle; - /*================================================================================================== FUNCTION IMPLEMENTATION @@ -32,12 +30,12 @@ extern MsgDbHandler dbHandle; msg_error_t MsgStoAddFolder(const MSG_FOLDER_INFO_S *pFolderInfo) { msg_error_t err = MSG_SUCCESS; - + MsgDbHandler *dbHandle = getDbHandle(); unsigned int rowId = 0; char sqlQuery[MAX_QUERY_LEN+1]; - err = dbHandle.getRowId(MSGFW_FOLDER_TABLE_NAME, &rowId); + err = dbHandle->getRowId(MSGFW_FOLDER_TABLE_NAME, &rowId); if (err != MSG_SUCCESS) return err; @@ -47,7 +45,7 @@ msg_error_t MsgStoAddFolder(const MSG_FOLDER_INFO_S *pFolderInfo) snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, '%s', %d);", MSGFW_FOLDER_TABLE_NAME, rowId, pFolderInfo->folderName, pFolderInfo->folderType); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; return MSG_SUCCESS; @@ -57,13 +55,13 @@ msg_error_t MsgStoAddFolder(const MSG_FOLDER_INFO_S *pFolderInfo) msg_error_t MsgStoUpdateFolder(const MSG_FOLDER_INFO_S *pFolderInfo) { char sqlQuery[MAX_QUERY_LEN+1]; - + MsgDbHandler *dbHandle = getDbHandle(); // Update Folder memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FOLDER_NAME = '%s', FOLDER_TYPE = %d WHERE FOLDER_ID = %d;", MSGFW_FOLDER_TABLE_NAME, pFolderInfo->folderName, pFolderInfo->folderType, pFolderInfo->folderId); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; return MSG_SUCCESS; @@ -73,16 +71,16 @@ msg_error_t MsgStoUpdateFolder(const MSG_FOLDER_INFO_S *pFolderInfo) msg_error_t MsgStoDeleteFolder(const msg_folder_id_t folderId) { char sqlQuery[MAX_QUERY_LEN+1]; - - dbHandle.beginTrans(); + MsgDbHandler *dbHandle = getDbHandle(); + dbHandle->beginTrans(); memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE FOLDER_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, folderId); // Delete Message in the folder from msg table - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } @@ -91,18 +89,18 @@ msg_error_t MsgStoDeleteFolder(const msg_folder_id_t folderId) MSGFW_FOLDER_TABLE_NAME, folderId); // Delete Message in the folder from msg table - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } // Clear Conversation table - if (MsgStoClearConversationTable(&dbHandle) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } - dbHandle.endTrans(true); + dbHandle->endTrans(true); return MSG_SUCCESS; } @@ -114,9 +112,9 @@ msg_error_t MsgStoGetFolderList(msg_struct_list_s *pFolderList) MSG_DEBUG("pFolderList is NULL"); return MSG_ERR_NULL_POINTER; } + MsgDbHandler *dbHandle = getDbHandle(); - int rowCnt = 0; - int index = 3; + int rowCnt = 0, index = 0; char sqlQuery[MAX_QUERY_LEN+1]; @@ -124,8 +122,8 @@ msg_error_t MsgStoGetFolderList(msg_struct_list_s *pFolderList) snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FOLDER_ID, FOLDER_TYPE, FOLDER_NAME FROM %s;", MSGFW_FOLDER_TABLE_NAME); - if (dbHandle.getTable(sqlQuery, &rowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); + if (dbHandle->getTable(sqlQuery, &rowCnt, &index) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -133,29 +131,29 @@ msg_error_t MsgStoGetFolderList(msg_struct_list_s *pFolderList) MSG_DEBUG("pFolderList->nCount [%d]", pFolderList->nCount); - pFolderList->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_FOLDER_INFO_S *)*rowCnt]; + pFolderList->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(MSG_FOLDER_INFO_S *)); msg_struct_s* pTmp = NULL; for (int i = 0; i < rowCnt; i++) { - pFolderList->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)]; + pFolderList->msg_struct_info[i] = (msg_struct_t)new msg_struct_s; pTmp = (msg_struct_s *)pFolderList->msg_struct_info[i]; pTmp->type = MSG_STRUCT_FOLDER_INFO; - pTmp->data = new char[sizeof(MSG_FOLDER_INFO_S)]; + pTmp->data = new MSG_FOLDER_INFO_S; MSG_FOLDER_INFO_S * pFolder = (MSG_FOLDER_INFO_S *)pTmp->data; memset(pFolder, 0x00, sizeof(MSG_FOLDER_INFO_S)); - pFolder->folderId = dbHandle.getColumnToInt(index++); + pFolder->folderId = dbHandle->getColumnToInt(index++); - pFolder->folderType = dbHandle.getColumnToInt(index++); + pFolder->folderType = dbHandle->getColumnToInt(index++); memset(pFolder->folderName, 0x00, sizeof(pFolder->folderName)); - dbHandle.getColumnToString(index++, MAX_FOLDER_NAME_SIZE, pFolder->folderName); + dbHandle->getColumnToString(index++, MAX_FOLDER_NAME_SIZE, pFolder->folderName); } - dbHandle.freeTable(); + dbHandle->freeTable(); return MSG_SUCCESS; } diff --git a/framework/storage-handler/MsgStorageManager.cpp b/framework/storage-handler/MsgStorageManager.cpp index 944f234..6366cc7 100755 --- a/framework/storage-handler/MsgStorageManager.cpp +++ b/framework/storage-handler/MsgStorageManager.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include @@ -19,6 +19,12 @@ #include #include #include +#include +#include + +#include +#include +#include "MsgVMessage.h" #include "MsgDebug.h" #include "MsgUtilFile.h" @@ -29,11 +35,11 @@ #include "MsgStorageHandler.h" +#define MSG_DB_VERSION 1 + /*================================================================================================== VARIABLES ==================================================================================================*/ -MsgDbHandler dbHandle; - /*================================================================================================== FUNCTION IMPLEMENTATION @@ -46,7 +52,8 @@ msg_error_t MsgStoConnectDB() msg_error_t MsgStoDisconnectDB() { - if (dbHandle.disconnect() != MSG_SUCCESS) { + MsgDbHandler *dbHandle = getDbHandle(); + if (dbHandle->disconnect() != MSG_SUCCESS) { MSG_DEBUG("DB Disconnect Fail"); return MSG_ERR_DB_DISCONNECT; } @@ -57,447 +64,184 @@ msg_error_t MsgStoDisconnectDB() } -msg_error_t MsgStoInitDB(bool bSimChanged) +void MsgUpdateDBtoVer1() { - MSG_BEGIN(); - + MsgDbHandler *dbHandle = getDbHandle(); msg_error_t err = MSG_SUCCESS; - -#ifdef MSG_DB_CREATE - if (MsgCreateConversationTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateAddressTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateFolderTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateMsgTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateSimMessageTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateWAPMessageTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateCBMessageTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateSyncMLMessageTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateSmsSendOptTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateFilterTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - if (MsgCreateMmsTable() != MSG_SUCCESS) - return MSG_ERR_DB_STORAGE_INIT; - - // Add Default Folders - if (MsgAddDefaultFolders() != MSG_SUCCESS) { - MSG_DEBUG("Add Default Folders Fail"); - return MSG_ERR_DB_STORAGE_INIT; - } - - // Add Default Address - if (MsgAddDefaultAddress() != MSG_SUCCESS) { - MSG_DEBUG("Add Default Address Fail"); - return MSG_ERR_DB_STORAGE_INIT; - } -#endif - - // Delete Msgs in Hidden Folder - MsgStoDeleteAllMessageInFolder(0, true, NULL); - - // Reset network status - MsgStoResetNetworkStatus(); - - //clear abnormal mms message - MsgStoCleanAbnormalMmsData(); - - // Clear all old Sim data - MsgStoClearSimMessageInDB(); - - int smsCnt = 0, mmsCnt = 0; - - smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE); - mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE); - - // Set Indicator - MsgSettingSetIndicator(smsCnt, mmsCnt); - - MSG_END(); - - return err; -} - - -msg_error_t MsgCreateConversationTable() -{ - msg_error_t err = MSG_SUCCESS; - char sqlQuery[MAX_QUERY_LEN+1]; - if (!dbHandle.checkTableExist(MSGFW_ADDRESS_TABLE_NAME)) { + if (!dbHandle->checkTableExist(MSGFW_MMS_MULTIPART_TABLE_NAME)) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - 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 );", - MSGFW_CONVERSATION_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); + "CREATE TABLE %s ( " + "_ID INTEGER PRIMARY KEY AUTOINCREMENT, " + "MSG_ID INTEGER NOT NULL , " + "SEQ INTEGER DEFAULT 0, " + "CONTENT_TYPE TEXT, " + "NAME TEXT, " + "CHARSET INTEGER, " + "CONTENT_ID TEXT, " + "CONTENT_LOCATION TEXT, " + "FILE_PATH TEXT, " + "TEXT TEXT, " + "TCS_LEVEL INTEGER DEFAULT -1, " + "MALWARE_ALLOW INTEGER DEFAULT 0, " + "THUMB_FILE_PATH TEXT, " + "FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID));", + MSGFW_MMS_MULTIPART_TABLE_NAME); + + err = dbHandle->execQuery(sqlQuery); if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_CONVERSATION_TABLE_NAME); + MSG_SEC_DEBUG("SUCCESS : create %s.", MSGFW_MMS_MULTIPART_TABLE_NAME); else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_CONVERSATION_TABLE_NAME, err); + MSG_SEC_DEBUG("FAIL : create %s [%d].", MSGFW_MMS_MULTIPART_TABLE_NAME, err); } - - return err; } -msg_error_t MsgCreateAddressTable() +void MsgStoUpdateDBVersion() { - msg_error_t err = MSG_SUCCESS; - + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; - if (!dbHandle.checkTableExist(MSGFW_ADDRESS_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - 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 %s (CONV_ID) );", - MSGFW_ADDRESS_TABLE_NAME, MSGFW_CONVERSATION_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); + snprintf(sqlQuery, sizeof(sqlQuery), "PRAGMA user_version=%d;", MSG_DB_VERSION); - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_ADDRESS_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_ADDRESS_TABLE_NAME, err); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + MSG_DEBUG("Fail to prepareQuery."); + return; } - return err; -} - - -msg_error_t MsgCreateFolderTable() -{ - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; - - if (!dbHandle.checkTableExist(MSGFW_FOLDER_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - FOLDER_ID INTEGER PRIMARY KEY, \ - FOLDER_NAME TEXT NOT NULL, \ - FOLDER_TYPE INTEGER DEFAULT 0 );", - MSGFW_FOLDER_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); - - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_FOLDER_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_FOLDER_TABLE_NAME, err); + if (dbHandle->stepQuery() == MSG_ERR_DB_STEP) { + MSG_DEBUG("Fail to stepQuery."); + dbHandle->finalizeQuery(); + return; } - return err; + dbHandle->finalizeQuery(); } - -msg_error_t MsgCreateMsgTable() +msg_error_t MsgStoDBVerCheck() { - msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); + int dbVersion = 0; char sqlQuery[MAX_QUERY_LEN+1]; - if (!dbHandle.checkTableExist(MSGFW_MESSAGE_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "PRAGMA user_version;"); - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - 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 , \ - DELIVERY_REPORT_STATUS INTEGER DEFAULT 0 , \ - DELIVERY_REPORT_TIME DATETIME , \ - READ_REPORT_STATUS INTEGER DEFAULT 0 , \ - READ_REPORT_TIME DATETIME , \ - ATTACHMENT_COUNT INTEGER DEFAULT 0 , \ - FOREIGN KEY(CONV_ID) REFERENCES %s (CONV_ID) , \ - FOREIGN KEY(FOLDER_ID) REFERENCES %s (FOLDER_ID) );", - MSGFW_MESSAGE_TABLE_NAME, MSGFW_CONVERSATION_TABLE_NAME, MSGFW_FOLDER_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); - - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_MESSAGE_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_MESSAGE_TABLE_NAME, err); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + MSG_DEBUG("Fail to prepareQuery."); + return MSG_ERR_DB_EXEC; } - return err; -} - - -msg_error_t MsgCreateSimMessageTable() -{ - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; - - if (!dbHandle.checkTableExist(MSGFW_SIM_MSG_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - MSG_ID INTEGER , \ - SIM_ID INTEGER NOT NULL , \ - FOREIGN KEY(MSG_ID) REFERENCES %s (MSG_ID) );", - MSGFW_SIM_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); - - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_SIM_MSG_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_SIM_MSG_TABLE_NAME, err); + if (dbHandle->stepQuery() == MSG_ERR_DB_STEP) { + MSG_DEBUG("Fail to stepQuery."); + dbHandle->finalizeQuery(); + return MSG_ERR_DB_EXEC; } - return err; -} + dbVersion = dbHandle->columnInt(0); + dbHandle->finalizeQuery(); -msg_error_t MsgCreateWAPMessageTable() -{ - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; + MSG_DEBUG("dbVersion [%d]", dbVersion); - if (!dbHandle.checkTableExist(MSGFW_PUSH_MSG_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - MSG_ID INTEGER , \ - ACTION INTEGER , \ - CREATED INTEGER , \ - EXPIRES INTEGER , \ - ID TEXT , \ - HREF TEXT , \ - CONTENT TEXT , \ - FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID) );", - MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); - - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_PUSH_MSG_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_PUSH_MSG_TABLE_NAME, err); + switch (dbVersion) + { + case 0 : + MsgUpdateDBtoVer1(); + /* no break */ + default : + MsgStoUpdateDBVersion(); + /* no break */ } - return err; + return MSG_SUCCESS; } - -msg_error_t MsgCreateCBMessageTable() +void MsgInitMmapMutex(const char *shm_file_name) { - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; - - if (!dbHandle.checkTableExist(MSGFW_CB_MSG_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - MSG_ID INTEGER , \ - CB_MSG_ID INTEGER NOT NULL , \ - FOREIGN KEY(MSG_ID) REFERENCES %s (MSG_ID) );", - MSGFW_CB_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); + MSG_BEGIN(); - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_CB_MSG_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_CB_MSG_TABLE_NAME, err); + if(!shm_file_name) { + MSG_FATAL("EMAIL_ERROR_INVALID_PARAM"); + return; } - return err; -} - - -msg_error_t MsgCreateSyncMLMessageTable() -{ - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; - - if (!dbHandle.checkTableExist(MSGFW_SYNCML_MSG_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - MSG_ID INTEGER , \ - EXT_ID INTEGER NOT NULL , \ - PINCODE INTEGER NOT NULL , \ - FOREIGN KEY(MSG_ID) REFERENCES %s(MSG_ID) );", - MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); + int fd = shm_open (shm_file_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); /* note: permission is not working */ - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_SYNCML_MSG_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_SYNCML_MSG_TABLE_NAME, err); + if (fd < 0) { + MSG_FATAL("shm_open errno [%d]", errno); + return; } - return err; -} - -msg_error_t MsgCreateSmsSendOptTable() -{ - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; + fchmod(fd, 0666); + MSG_DEBUG("** Create SHM FILE **"); + if (ftruncate(fd, sizeof(pthread_mutex_t)) != 0) { + MSG_FATAL("ftruncate errno [%d]", errno); + return; + } - if (!dbHandle.checkTableExist(MSGFW_SMS_SENDOPT_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + pthread_mutex_t *mx = (pthread_mutex_t *)mmap(NULL, sizeof(pthread_mutex_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (mx == MAP_FAILED) { + MSG_FATAL("mmap errno [%d]", errno); + return ; + } - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - MSG_ID INTEGER , \ - DELREP_REQ INTEGER NOT NULL , \ - KEEP_COPY INTEGER NOT NULL , \ - REPLY_PATH INTEGER NOT NULL , \ - FOREIGN KEY(MSG_ID) REFERENCES %s (MSG_ID) );", - MSGFW_SMS_SENDOPT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME); + // initialize the data on mmap + pthread_mutexattr_t mattr; + pthread_mutexattr_init(&mattr); + pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED); + pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP); + pthread_mutex_init(mx, &mattr); + pthread_mutexattr_destroy(&mattr); - err = dbHandle.execQuery(sqlQuery); + close (fd); + MSG_END(); +} - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_SMS_SENDOPT_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_SMS_SENDOPT_TABLE_NAME, err); - } - return err; +void MsgfreeMmapMutex() +{ + MsgDbHandler *dbHandle = getDbHandle(); + dbHandle->freeMmapMutex(); } -msg_error_t MsgCreateFilterTable() +msg_error_t MsgStoInitDB(bool bSimChanged) { + MSG_BEGIN(); +// MsgDbHandler *dbHandle = getDbHandle(); msg_error_t err = MSG_SUCCESS; - char sqlQuery[MAX_QUERY_LEN+1]; - - if (!dbHandle.checkTableExist(MSGFW_FILTER_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + // Init mmap mutex for DB access + MsgInitMmapMutex(SHM_FILE_FOR_DB_LOCK); - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - FILTER_ID INTEGER PRIMARY KEY , \ - FILTER_TYPE INTEGER NOT NULL , \ - FILTER_VALUE TEXT NOT NULL );", - MSGFW_FILTER_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); + // Check DB version. + MsgStoDBVerCheck(); - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MSGFW_FILTER_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MSGFW_FILTER_TABLE_NAME, err); - } - - return err; -} + // Delete Msgs in Hidden Folder + MsgStoDeleteAllMessageInFolder(0, true, NULL); + // Reset network status + MsgStoResetNetworkStatus(); -msg_error_t MsgCreateMmsTable() -{ - msg_error_t err = MSG_SUCCESS; +#if 0 + // Reset Cb Message + MsgStoResetCBMessage(); +#endif - char sqlQuery[MAX_QUERY_LEN+1]; + //clear abnormal mms message + MsgStoCleanAbnormalMmsData(); - if (!dbHandle.checkTableExist(MMS_PLUGIN_MESSAGE_TABLE_NAME)) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + // Clear all old Sim data + MsgStoClearSimMessageInDB(); - snprintf(sqlQuery, sizeof(sqlQuery), - "CREATE TABLE %s ( \ - 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 %s (MSG_ID) );", - MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME); - - err = dbHandle.execQuery(sqlQuery); + //update sim index to 0 for all messages + MsgStoUpdateIMSI(0); - if (err == MSG_SUCCESS) - MSG_DEBUG("SUCCESS : create %s.", MMS_PLUGIN_MESSAGE_TABLE_NAME); - else - MSG_DEBUG("FAIL : create %s [%d].", MMS_PLUGIN_MESSAGE_TABLE_NAME, err); - } + MSG_END(); return err; } @@ -509,27 +253,27 @@ msg_error_t MsgAddDefaultFolders() int nResult = 0; char sqlQuery[MAX_QUERY_LEN+1]; - + MsgDbHandler *dbHandle = getDbHandle(); // INBOX memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;", MSGFW_FOLDER_TABLE_NAME, MSG_INBOX_ID); - if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } - nResult = dbHandle.getColumnToInt(1); + nResult = dbHandle->getColumnToInt(1); - dbHandle.freeTable(); + dbHandle->freeTable(); if (nResult == 0) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'INBOX', %d);", MSGFW_FOLDER_TABLE_NAME, MSG_INBOX_ID, MSG_FOLDER_TYPE_INBOX); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; } @@ -538,21 +282,21 @@ msg_error_t MsgAddDefaultFolders() snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;", MSGFW_FOLDER_TABLE_NAME, MSG_OUTBOX_ID); - if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } - nResult = dbHandle.getColumnToInt(1); + nResult = dbHandle->getColumnToInt(1); - dbHandle.freeTable(); + dbHandle->freeTable(); if (nResult == 0) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'OUTBOX', %d);", MSGFW_FOLDER_TABLE_NAME, MSG_OUTBOX_ID, MSG_FOLDER_TYPE_OUTBOX); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; } @@ -561,21 +305,21 @@ msg_error_t MsgAddDefaultFolders() snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;", MSGFW_FOLDER_TABLE_NAME, MSG_SENTBOX_ID); - if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } - nResult = dbHandle.getColumnToInt(1); + nResult = dbHandle->getColumnToInt(1); - dbHandle.freeTable(); + dbHandle->freeTable(); if (nResult == 0) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'SENTBOX', %d);", MSGFW_FOLDER_TABLE_NAME, MSG_SENTBOX_ID, MSG_FOLDER_TYPE_OUTBOX); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; } @@ -584,21 +328,21 @@ msg_error_t MsgAddDefaultFolders() snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;", MSGFW_FOLDER_TABLE_NAME, MSG_DRAFT_ID); - if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } - nResult = dbHandle.getColumnToInt(1); + nResult = dbHandle->getColumnToInt(1); - dbHandle.freeTable(); + dbHandle->freeTable(); if (nResult == 0) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'DRAFT', %d);", MSGFW_FOLDER_TABLE_NAME, MSG_DRAFT_ID, MSG_FOLDER_TYPE_DRAFT); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; } @@ -607,21 +351,21 @@ msg_error_t MsgAddDefaultFolders() snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;", MSGFW_FOLDER_TABLE_NAME, MSG_CBMSGBOX_ID); - if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } - nResult = dbHandle.getColumnToInt(1); + nResult = dbHandle->getColumnToInt(1); - dbHandle.freeTable(); + dbHandle->freeTable(); if (nResult == 0) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'CBMSGBOX', %d);", MSGFW_FOLDER_TABLE_NAME, MSG_CBMSGBOX_ID, MSG_FOLDER_TYPE_INBOX); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; } @@ -630,67 +374,21 @@ msg_error_t MsgAddDefaultFolders() snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;", MSGFW_FOLDER_TABLE_NAME, MSG_SPAMBOX_ID); - if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } - nResult = dbHandle.getColumnToInt(1); + nResult = dbHandle->getColumnToInt(1); - dbHandle.freeTable(); + dbHandle->freeTable(); if (nResult == 0) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'SPAMBOX', %d);", MSGFW_FOLDER_TABLE_NAME, MSG_SPAMBOX_ID, MSG_FOLDER_TYPE_SPAMBOX); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) - return MSG_ERR_DB_EXEC; - } - - // SMS TEMPLATE - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;", - MSGFW_FOLDER_TABLE_NAME, MSG_SMS_TEMPLATE_ID); - - if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); - return MSG_ERR_DB_GETTABLE; - } - - nResult = dbHandle.getColumnToInt(1); - - dbHandle.freeTable(); - - if (nResult == 0) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'SMS TEMPLATE', %d);", - MSGFW_FOLDER_TABLE_NAME, MSG_SMS_TEMPLATE_ID, MSG_FOLDER_TYPE_TEMPLATE); - - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) - return MSG_ERR_DB_EXEC; - } - - // MMS TEMPLATE - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE FOLDER_ID = %d;", - MSGFW_FOLDER_TABLE_NAME, MSG_MMS_TEMPLATE_ID); - - if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); - return MSG_ERR_DB_GETTABLE; - } - - nResult = dbHandle.getColumnToInt(1); - - dbHandle.freeTable(); - - if (nResult == 0) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, 'MMS TEMPLATE', %d);", - MSGFW_FOLDER_TABLE_NAME, MSG_MMS_TEMPLATE_ID, MSG_FOLDER_TYPE_TEMPLATE); - - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; } @@ -701,7 +399,7 @@ msg_error_t MsgAddDefaultFolders() msg_error_t MsgAddDefaultAddress() { MSG_BEGIN(); - + MsgDbHandler *dbHandle = getDbHandle(); int nRowCnt = 0, nResult = 0; char sqlQuery[MAX_QUERY_LEN+1]; @@ -710,23 +408,23 @@ msg_error_t MsgAddDefaultAddress() snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s WHERE ADDRESS_ID = 0;", MSGFW_ADDRESS_TABLE_NAME); - if (dbHandle.getTable(sqlQuery, &nRowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } - nResult = dbHandle.getColumnToInt(1); + nResult = dbHandle->getColumnToInt(1); - dbHandle.freeTable(); + dbHandle->freeTable(); if (nResult == 0) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (0, 0, 0, '', 0, '', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '');", + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (0, 0, 0, 0, '', 0, 0, '', '', '', '', '', '', 0);", MSGFW_ADDRESS_TABLE_NAME); MSG_DEBUG("%s", sqlQuery); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; } @@ -738,6 +436,7 @@ msg_error_t MsgAddDefaultAddress() msg_error_t MsgStoResetDatabase() { + MsgDbHandler *dbHandle = getDbHandle(); msg_error_t err = MSG_SUCCESS; char sqlQuery[MAX_QUERY_LEN+1]; @@ -749,7 +448,7 @@ msg_error_t MsgStoResetDatabase() int listCnt = sizeof(tableList)/sizeof(char*); - dbHandle.beginTrans(); + dbHandle->beginTrans(); // Delete Database for (int i = 0; i < listCnt; i++) @@ -757,8 +456,8 @@ msg_error_t MsgStoResetDatabase() memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", tableList[i]); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } } @@ -768,34 +467,34 @@ msg_error_t MsgStoResetDatabase() snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE STORAGE_ID <> %d;", MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_SIM); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } // Delete Conversation Table - err = MsgStoClearConversationTable(&dbHandle); + err = MsgStoClearConversationTable(dbHandle); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return err; } // Add Default Folders if (MsgAddDefaultFolders() != MSG_SUCCESS) { MSG_DEBUG("Add Default Folders Fail"); - dbHandle.endTrans(false); + dbHandle->endTrans(false); return MSG_ERR_DB_STORAGE_INIT; } // Add Default Address if (MsgAddDefaultAddress() != MSG_SUCCESS) { MSG_DEBUG("Add Default Address Fail"); - dbHandle.endTrans(false); + dbHandle->endTrans(false); return MSG_ERR_DB_STORAGE_INIT; } - dbHandle.endTrans(true); + dbHandle->endTrans(true); // Delete MMS Files MsgRmRf((char*)MSG_DATA_PATH); @@ -817,48 +516,649 @@ msg_error_t MsgStoResetDatabase() } -msg_error_t MsgStoBackupMessage() +msg_error_t MsgStoBackupMessage(msg_message_backup_type_t type, const char *filepath) { + MsgDbHandler *dbHandle = getDbHandle(); + msg_error_t err = MSG_SUCCESS; + + char sqlQuery[MAX_QUERY_LEN+1]; + int rowCnt = 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_SEC_DEBUG("Fail to delete [%s].", fileName); + } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + MSG_SEC_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, NULL); + + if (err != MSG_SUCCESS) { + dbHandle->freeTable(); + return err; + } + + MSG_DEBUG("backup number = %d", rowCnt); + + int msg_id[rowCnt]; + for (int i = 0; i < rowCnt; i++) { + msg_id[i] = dbHandle->getColumnToInt(i+1); + } + dbHandle->freeTable(); + + for (int i = 0; i < rowCnt; i++) { + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); + + err = MsgStoGetMessage(msg_id[i], &msgInfo, NULL); + if(err != MSG_SUCCESS) { + return err; + } + + encoded_data = MsgVMessageAddRecord(dbHandle, &msgInfo); + + if (msgInfo.bTextSms == false) + { + MsgDeleteFile(msgInfo.msgData); //ipc + } + if (encoded_data != NULL) { + if (MsgAppendFile(fileName, encoded_data, strlen(encoded_data)) == false) { + free(encoded_data); + return MSG_ERR_STORAGE_ERROR; + } + + free(encoded_data); + } + + memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); + } + + MSG_END(); return MSG_SUCCESS; + } msg_error_t MsgStoUpdateMms(MSG_MESSAGE_INFO_S *pMsg) { + MsgDbHandler *dbHandle = getDbHandle(); + msg_error_t err = MSG_SUCCESS; char sqlQuery[MAX_QUERY_LEN+1]; + unsigned int fileSize = 0; + char *pFileData = NULL; if (pMsg->msgType.subType == MSG_SENDCONF_MMS) { + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - dbHandle.beginTrans(); + dbHandle->beginTrans(); snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET THUMB_PATH = ?, MSG_TEXT = ? WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } + dbHandle->bindText(pMsg->thumbPath, 1); + + if (pMsg->msgText[0] != '\0' && g_file_get_contents(pMsg->msgText, &pFileData, &fileSize, NULL) == true) { + dbHandle->bindText(pFileData, 2); + } + + MSG_SEC_DEBUG("thumbPath = %s , msgText = %s" , pMsg->thumbPath, pFileData); - dbHandle.bindText(pMsg->thumbPath, 1); - dbHandle.bindText(pMsg->msgText, 2); - MSG_DEBUG("thumbPath = %s , msgText = %s" , pMsg->thumbPath, pMsg->msgText); MSG_DEBUG("%s", sqlQuery); - if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) { - dbHandle.finalizeQuery(); - dbHandle.endTrans(false); + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + if (pFileData) { + free(pFileData); + pFileData = NULL; + } + return MSG_ERR_DB_EXEC; } - dbHandle.finalizeQuery(); - dbHandle.endTrans(true); + dbHandle->finalizeQuery(); + dbHandle->endTrans(true); + + if (pFileData) { + free(pFileData); + pFileData = NULL; + } } else { - MsgStoUpdateMMSMessage(pMsg); + + err = MsgStoUpdateMMSMessage(pMsg); + if (err != MSG_SUCCESS) { + MSG_DEBUG("MsgStoUpdateMMSMessage() error : %d", err); + } + + } + + return err; +} + +msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id_list) +{ + if (result_id_list == NULL) { + MSG_DEBUG("result_id_list is NULL"); + return MSG_ERR_NULL_POINTER; + } + + msg_error_t err = MSG_SUCCESS; + MSG_MESSAGE_INFO_S msgInfo = {0,}; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); + + VTree* vMsg = NULL; + VObject* pObject = NULL; + + msg_id_list_s *msgIdList = NULL; + msgIdList = (msg_id_list_s *)calloc(1, sizeof(msg_id_list_s)); + + int dataSize = 0; + + char fileName[MSG_FILENAME_LEN_MAX+1]; + char *pData = NULL; + char *pCurrent = NULL; + char *pTemp = NULL; + + *result_id_list = 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) { + if (msgIdList) { + if (msgIdList->msgIdList) + free(msgIdList->msgIdList); + free(msgIdList); + } + 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); + if (vMsg == NULL) { + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + } +#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); + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + } + } + break; + + case VMSG_TYPE_MSGBOX : + { + if(!strncmp(pObject->pszValue[0], "INBOX", strlen("INBOX"))) { + msgInfo.folderId= MSG_INBOX_ID; + msgInfo.direction=MSG_DIRECTION_TYPE_MT; + + if (msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS) + msgInfo.networkStatus=MSG_NETWORK_RETRIEVE_SUCCESS; + else if (msgInfo.msgType.subType == MSG_SENDCONF_MMS) + msgInfo.networkStatus=MSG_NETWORK_SEND_SUCCESS; + else + 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); + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + } + } + 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); + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + } + } + break; + + case VMSG_TYPE_DATE : + { + struct tm displayTime; + + if (!_convert_vdata_str_to_tm(pObject->pszValue[0], &displayTime)) { + vmsg_free_vtree_memory( vMsg ); + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + } + + 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); + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + } + + if (MsgWriteIpcFile(fileName, pObject->pszValue[0], pObject->numOfBiData) == false) { + vmsg_free_vtree_memory(vMsg); + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + } + + strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN); + msgInfo.dataSize = pObject->numOfBiData; + } else { + msgInfo.bTextSms = true; + + if(pObject->numOfBiData > 0) { + memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText)); + memcpy(msgInfo.msgText, pObject->pszValue[0], pObject->numOfBiData); + + msgInfo.dataSize = pObject->numOfBiData; + } + } + } else { + msgInfo.bTextSms = true; +#if 0 + 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); + if (plg == NULL) { + vmsg_free_vtree_memory(vMsg); + return MSG_ERR_NULL_POINTER; + } + 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); + if (plg == NULL) { + vmsg_free_vtree_memory(vMsg); + return MSG_ERR_NULL_POINTER; + } + 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_SEC_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); +/////////////////////////// + } +#else + + msgInfo.bTextSms = false; + + char fileName[MAX_COMMON_INFO_SIZE+1]; + memset(fileName, 0x00, sizeof(fileName)); + + if (MsgCreateFileName(fileName) == false) { + vmsg_free_vtree_memory(vMsg); + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + } + + if (MsgWriteIpcFile(fileName, pObject->pszValue[0], pObject->numOfBiData) == false) { + vmsg_free_vtree_memory(vMsg); + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + } + + //set serialized mms data ipcfilename + strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN); +#endif + } + } + break; + + case VCARD_TYPE_TEL : + { + MSG_ADDRESS_INFO_S * addrInfo = NULL; + + msgInfo.nAddressCnt++; + + if (msgInfo.addressList == NULL) { + addrInfo = (MSG_ADDRESS_INFO_S *)calloc(1, sizeof(MSG_ADDRESS_INFO_S)); + } else { + addrInfo = (MSG_ADDRESS_INFO_S *)realloc(msgInfo.addressList, msgInfo.nAddressCnt * sizeof(MSG_ADDRESS_INFO_S)); + } + + if (addrInfo == NULL) { + vmsg_free_vtree_memory(vMsg); + err = MSG_ERR_STORAGE_ERROR; + goto __RETURN; + + } + + msgInfo.addressList = addrInfo; + + 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); + + if (msgIdList->nCount == 0) { + msgIdList->msgIdList = (msg_message_id_t*)calloc(1, sizeof(msg_message_id_t)); + } else { + msg_message_id_t * msg_id_list; + msg_id_list = (msg_message_id_t*)realloc(msgIdList->msgIdList, sizeof(msg_message_id_t)*(msgIdList->nCount+1)); + + if (msg_id_list) + msgIdList->msgIdList = msg_id_list; + else { + MSG_DEBUG("realloc failed"); + err = MSG_ERR_UNKNOWN; + goto __RETURN; + } + } + + msgIdList->msgIdList[msgIdList->nCount] = msgInfo.msgId; + msgIdList->nCount++; + + vmsg_free_vtree_memory(vMsg); + + vMsg = NULL; + pCurrent = pTemp + strlen("END:VMSG"); +#ifndef MSG_FOR_DEBUG + } +#endif + *result_id_list = msgIdList; + +__RETURN: + if(pData) + { + free( pData ); + pData = NULL; + pCurrent = NULL; + } + + if (*result_id_list == NULL && msgIdList) { + if (msgIdList->msgIdList) { + free(msgIdList->msgIdList); + } + free(msgIdList); + } + + return err; +} + +msg_error_t MsgStoAddPushEvent(MSG_PUSH_EVENT_INFO_S* pPushEvent) +{ + MsgDbHandler *dbHandle = getDbHandle(); + char sqlQuery[MAX_QUERY_LEN+1]; + unsigned int rowId = 0; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + // Check whether Same record exists or not. +#if 0 + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE CONTENT_TYPE LIKE '%s' AND APP_ID LIKE '%s' AND (PKG_NAME LIKE '%s' OR SECURE = 1);", + MSGFW_PUSH_CONFIG_TABLE_NAME, pPushEvent->contentType, pPushEvent->appId, pPushEvent->pkgName); +#else + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE CONTENT_TYPE LIKE '%s' AND APP_ID LIKE '%s';", + MSGFW_PUSH_CONFIG_TABLE_NAME, pPushEvent->contentType, pPushEvent->appId); +#endif + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + MSG_DEBUG("Query Failed [%s]", sqlQuery); + return MSG_ERR_DB_PREPARE; + } + + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_ROW; + } + dbHandle->finalizeQuery(); + + dbHandle->beginTrans(); + + if (dbHandle->getRowId(MSGFW_PUSH_CONFIG_TABLE_NAME, &rowId) != MSG_SUCCESS) { + MSG_DEBUG("getRowId is failed!!!"); } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, ?, ?, ?, %d, 0, 0);", + MSGFW_PUSH_CONFIG_TABLE_NAME, rowId, pPushEvent->bLaunch); + + + MSG_DEBUG("QUERY : %s", sqlQuery); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + dbHandle->bindText(pPushEvent->contentType, 1); + dbHandle->bindText(pPushEvent->appId, 2); + dbHandle->bindText(pPushEvent->pkgName, 3); + + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + dbHandle->finalizeQuery(); + dbHandle->endTrans(true); + + return MSG_SUCCESS; +} + + +msg_error_t MsgStoDeletePushEvent(MSG_PUSH_EVENT_INFO_S* pPushEvent) +{ + MsgDbHandler *dbHandle = getDbHandle(); + char sqlQuery[MAX_QUERY_LEN+1]; + dbHandle->beginTrans(); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE CONTENT_TYPE LIKE '%s' AND APP_ID LIKE '%s' AND PKG_NAME LIKE '%s';", + MSGFW_PUSH_CONFIG_TABLE_NAME, pPushEvent->contentType, pPushEvent->appId, pPushEvent->pkgName); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + dbHandle->endTrans(true); return MSG_SUCCESS; } -msg_error_t MsgStoRestoreMessage() +msg_error_t MsgStoUpdatePushEvent(MSG_PUSH_EVENT_INFO_S* pSrc, MSG_PUSH_EVENT_INFO_S* pDst) { + MsgDbHandler *dbHandle = getDbHandle(); + char sqlQuery[MAX_QUERY_LEN+1]; + dbHandle->beginTrans(); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET CONTENT_TYPE = ?, APP_ID = ?, PKG_NAME = ?, LAUNCH = %d WHERE CONTENT_TYPE LIKE '%s' AND APP_ID LIKE '%s' AND PKG_NAME LIKE '%s';", + MSGFW_PUSH_CONFIG_TABLE_NAME, pDst->bLaunch, pSrc->contentType, pSrc->appId, pSrc->pkgName); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + dbHandle->bindText(pDst->contentType, 1); + dbHandle->bindText(pDst->appId, 2); + dbHandle->bindText(pDst->pkgName, 3); + + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + dbHandle->finalizeQuery(); + dbHandle->endTrans(true); + return MSG_SUCCESS; } diff --git a/framework/storage-handler/MsgStorageMessage.cpp b/framework/storage-handler/MsgStorageMessage.cpp index 6630f54..06f9250 100755 --- a/framework/storage-handler/MsgStorageMessage.cpp +++ b/framework/storage-handler/MsgStorageMessage.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include @@ -35,6 +35,8 @@ #include "MsgStorageHandler.h" #include "MsgNotificationWrapper.h" #include "MsgMmsMessage.h" +#include "MsgDevicedWrapper.h" + using namespace std; @@ -42,7 +44,6 @@ using namespace std; /*================================================================================================== VARIABLES ==================================================================================================*/ -extern MsgDbHandler dbHandle; Mutex delNotiMx; CndVar delNoticv; @@ -56,115 +57,11 @@ 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) +static gboolean resetNotification(void *pVoid) { MSG_BEGIN(); - int smsCnt = 0; - int mmsCnt = 0; - - smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE); - mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE); - - MsgSettingSetIndicator(smsCnt, mmsCnt); + MsgRefreshAllNotification(true, false, false); MSG_END(); @@ -175,6 +72,7 @@ static gboolean updateUnreadMsgCount(void *pVoid) /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ + msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo) { MSG_BEGIN(); @@ -186,139 +84,225 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS char sqlQuery[MAX_QUERY_LEN+1]; - dbHandle.beginTrans(); + MsgDbHandler *dbHandle = getDbHandle(); + + dbHandle->beginTrans(); if (pMsg->nAddressCnt > 0) { - err = MsgStoAddAddress(&dbHandle, pMsg, &convId); + err = MsgStoAddAddress(dbHandle, pMsg, &convId); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return err; } pMsg->threadId = convId; } - - ///////// temporary code for draft message in conversation view. - if(convId > 0 && pMsg->folderId == MSG_DRAFT_ID) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), - "DELETE FROM %s WHERE CONV_ID = %d AND FOLDER_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, convId, MSG_DRAFT_ID); - - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - err = dbHandle.execQuery(sqlQuery); - + if (pMsg->msgId > 0) { + rowId = pMsg->msgId; + } else { + // get rowId + err = dbHandle->getRowId(MSGFW_MESSAGE_TABLE_NAME, &rowId); if (err != MSG_SUCCESS) { - MSG_DEBUG("fail to delete draft messages."); + dbHandle->endTrans(false); + return err; } + pMsg->msgId = (msg_message_id_t)rowId; } - //////// - - err = dbHandle.getRowId(MSGFW_MESSAGE_TABLE_NAME, &rowId); - - if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); - return err; - } - - pMsg->msgId = (msg_message_id_t)rowId; int fileSize = 0; + gchar *contents = NULL; char *pFileData = NULL; - AutoPtr buf(&pFileData); + unique_ptr buf(&pFileData, unique_ptr_deleter); - // Get File Data - if (pMsg->bTextSms == false) { - if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) { - dbHandle.endTrans(false); - return MSG_ERR_STORAGE_ERROR; - } - MSG_DEBUG("file size [%d]", fileSize); - } + char keyName[MAX_VCONFKEY_NAME_LEN]; + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_IMSI, pMsg->sim_idx); + + char *imsi = MsgSettingGetString(keyName); // Add Message memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d, %d, %ld, %d, %d, %d, %d, %d, %d, %ld, %d, ?, ?, ?, ?, %d, 0, %d, 0, 0);", + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d, %d, %u, %d, %d, %d, %d, %d, %d, %d, %d, ?, '', '', ?, 0, %d, '%s');", MSGFW_MESSAGE_TABLE_NAME, rowId, convId, pMsg->folderId, pMsg->storageId, pMsg->msgType.mainType, pMsg->msgType.subType, - pMsg->displayTime, pMsg->dataSize, pMsg->networkStatus, pMsg->bRead, pMsg->bProtected, pMsg->priority, pMsg->direction, - 0, pMsg->bBackup, MSG_DELIVERY_REPORT_NONE, MSG_READ_REPORT_NONE); + (unsigned int)pMsg->displayTime, pMsg->dataSize, pMsg->networkStatus, pMsg->bRead, pMsg->bProtected, pMsg->priority, pMsg->direction, + 0, pMsg->bBackup, pMsg->sim_idx, imsi); MSG_DEBUG("QUERY : %s", sqlQuery); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + g_free(imsi); + imsi = NULL; + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } - dbHandle.bindText(pMsg->subject, 1); + dbHandle->bindText(pMsg->subject, 1); - dbHandle.bindText(pMsg->msgData, 2); + if (pMsg->msgType.subType == MSG_NOTIFICATIONIND_MMS) { + dbHandle->bindText("", 2); + } else { + if (pMsg->bTextSms == false) { + //CID 47860: pMsg->msgData is an array, hence null check is not required + char fn[MSG_FILEPATH_LEN_MAX]; + memset(fn,0x00,MSG_FILEPATH_LEN_MAX); + snprintf(fn, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_IPC_DATA_PATH, pMsg->msgData); + + if (g_file_get_contents(fn, &contents, NULL, NULL)) { + MSG_DEBUG("g_file_get_contents() Success!!"); + dbHandle->bindText(contents, 2); + } else { + MSG_DEBUG("g_file_get_contents() Failed!!"); + dbHandle->bindText("", 2); + } - dbHandle.bindText(pMsg->thumbPath, 3); + } else + dbHandle->bindText(pMsg->msgText, 2); + } - if (pMsg->bTextSms == false) - dbHandle.bindText(pFileData, 4); - else - dbHandle.bindText(pMsg->msgText, 4); + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + //free contents + if (contents) { + g_free(contents); + contents = NULL; + } - if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) { - dbHandle.finalizeQuery(); - dbHandle.endTrans(false); return MSG_ERR_DB_EXEC; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); + + //free contents + if (contents) { + g_free(contents); + contents = NULL; + } if (pMsg->msgType.subType != MSG_SENDREQ_MMS) { - err = MsgStoUpdateConversation(&dbHandle, convId); + err = MsgStoUpdateConversation(dbHandle, convId); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return err; } } - dbHandle.endTrans(true); - +#if 0 /* In the case of MMS Message, load the MMS plugin to save MMS PDU */ if (pMsg->msgType.mainType == MSG_MMS_TYPE) { - MMS_MESSAGE_DATA_S mmsMsg; - memset(&mmsMsg, 0x00, sizeof(MMS_MESSAGE_DATA_S)); - - if (pMsg->dataSize == 0) { - MSG_DEBUG("pMsg->dataSize == 0, So Making emtpy MMS body."); - char * tempMmsBody = _MsgMmsSerializeMessageData(&mmsMsg, &(pMsg->dataSize)); - memcpy(&pMsg->msgText, tempMmsBody, pMsg->dataSize); - free(tempMmsBody); - } if (pMsg->msgType.subType != MSG_DELIVERYIND_MMS && pMsg->msgType.subType != MSG_READORGIND_MMS) { + MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_MMS_TYPE); + if (plg == NULL) { + dbHandle->endTrans(false); + return MSG_ERR_NULL_POINTER; + } + + if (pFileData == NULL) { + if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) { + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } - //pMsg->msgId = pMsg->refernceId; + MSG_DEBUG("file size [%d]", fileSize); + } err = plg->addMessage(pMsg, pSendOptInfo, pFileData); - if (err != MSG_SUCCESS) + if (err != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_STORAGE_ERROR; + } + + if (pMsg->msgType.subType == MSG_SENDREQ_MMS + || pMsg->msgType.subType == MSG_RETRIEVE_MMS + || pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS + || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { - if (pMsg->msgType.subType == MSG_SENDREQ_MMS) { MSG_DEBUG("pMsg->msgText: %s, pMsg->thumbPath: %s ", pMsg->msgText, pMsg->thumbPath); err = MsgStoUpdateMMSMessage(pMsg); - if (err != MSG_SUCCESS) + if (err != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } + + } + } + } else if (pMsg->msgType.mainType == MSG_SMS_TYPE && pSendOptInfo != NULL) { + MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); + if (plg == NULL) { + dbHandle->endTrans(false); + return MSG_ERR_NULL_POINTER; + } + err = plg->addMessage(pMsg, pSendOptInfo, NULL); + if (err != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } + } +#else + if (pMsg->msgType.mainType == MSG_MMS_TYPE) { + char *pMmsSerializedData = NULL; + unique_ptr buf_mms(&pMmsSerializedData, unique_ptr_deleter); + + if (pMsg->msgType.subType != MSG_DELIVERYIND_MMS && pMsg->msgType.subType != MSG_READORGIND_MMS) { + + MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_MMS_TYPE); + + if (pMmsSerializedData == NULL) { + if (MsgOpenAndReadFile(pMsg->msgData, &pMmsSerializedData, &fileSize) == false) { + dbHandle->endTrans(false); return MSG_ERR_STORAGE_ERROR; + } + + MSG_DEBUG("file size [%d]", fileSize); + } + + err = plg->addMessage(pMsg, pSendOptInfo, pMmsSerializedData); + if (err != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } + +// if (pMsg->msgText[0] != '\0') { +// g_file_get_contents(pMsg->msgText, &pFileData, (gsize *)&fileSize, NULL); +// MSG_DEBUG("file size [%d]", fileSize); +// } + + if (pMsg->msgType.subType == MSG_SENDREQ_MMS + || pMsg->msgType.subType == MSG_RETRIEVE_MMS + || pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS + || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) + { + MSG_DEBUG("pMsg->msgText: %s, pMsg->thumbPath: %s ", pMsg->msgText, pMsg->thumbPath); + + err = MsgStoUpdateMMSMessage(pMsg); } + + } + } else { + + // Get File Data + if (pMsg->bTextSms == false) { + if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) { + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } + MSG_DEBUG("file size [%d]", fileSize); } } +#endif + dbHandle->endTrans(true); MSG_END(); @@ -333,14 +317,56 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S char sqlQuery[MAX_QUERY_LEN+1]; msg_thread_id_t convId = 0; + MsgDbHandler *dbHandle = getDbHandle(); + dbHandle->beginTrans(); + + MSG_MAIN_TYPE_T prevType; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE FROM %s WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId); + + MSG_DEBUG("QUERY : %s", sqlQuery); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_PREPARE; + } + + if (dbHandle->stepQuery() != MSG_ERR_DB_ROW) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } + + prevType = dbHandle->columnInt(0); + dbHandle->finalizeQuery(); + + //check msg type with previous type + if (prevType != pMsg->msgType.mainType) { + MSG_DEBUG("different msg type to update [prev : %d], [current : %d]", prevType, pMsg->msgType.mainType); + + err = MsgStoDeleteMessage(pMsg->msgId, false); + if (err != MSG_SUCCESS) { + dbHandle->endTrans(false); + return err; + } + + err = MsgStoAddMessage(pMsg, pSendOptInfo); + if (err != MSG_SUCCESS) { + dbHandle->endTrans(false); + return err; + } - dbHandle.beginTrans(); + dbHandle->endTrans(false); + return err; + } if (pMsg->nAddressCnt > 0) { - err = MsgStoAddAddress(&dbHandle, pMsg, &convId); + pMsg->threadId = 0; + err = MsgStoAddAddress(dbHandle, pMsg, &convId); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return err; } } @@ -348,12 +374,12 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S int fileSize = 0; char *pFileData = NULL; - AutoPtr buf(&pFileData); + unique_ptr buf(&pFileData, unique_ptr_deleter); // Get File Data if (pMsg->bTextSms == false) { if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return MSG_ERR_STORAGE_ERROR; } } @@ -391,77 +417,95 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET CONV_ID = %d, FOLDER_ID = %d, STORAGE_ID = %d, MAIN_TYPE = %d, SUB_TYPE = %d, \ DISPLAY_TIME = %lu, DATA_SIZE = %d, NETWORK_STATUS = %d, READ_STATUS = %d, PROTECTED = %d, PRIORITY = %d, MSG_DIRECTION = %d, \ - BACKUP = %d, SUBJECT = ?, MSG_DATA = ?, THUMB_PATH = ?, MSG_TEXT = ? \ + BACKUP = %d, SUBJECT = ?, MSG_TEXT = ? \ WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, convId, pMsg->folderId, pMsg->storageId, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->displayTime, pMsg->dataSize, pMsg->networkStatus, pMsg->bRead, pMsg->bProtected, pMsg->priority, pMsg->direction, pMsg->bBackup, pMsg->msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } - dbHandle.bindText(pMsg->subject, 1); - - dbHandle.bindText(pMsg->msgData, 2); - - dbHandle.bindText(pMsg->thumbPath, 3); + dbHandle->bindText(pMsg->subject, 1); if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->bTextSms == false) - dbHandle.bindText(pFileData, 4); + dbHandle->bindText(pFileData, 2); else - dbHandle.bindText(pMsg->msgText, 4); + dbHandle->bindText(pMsg->msgText, 2); MSG_DEBUG("%s", sqlQuery); - if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) { - dbHandle.finalizeQuery(); - dbHandle.endTrans(false); + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); if (pMsg->msgType.mainType == MSG_SMS_TYPE && pSendOptInfo != NULL) { if (pSendOptInfo->bSetting == true) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET \ - DELREP_REQ = %d, KEEP_COPY = %d, REPLY_PATH = %d \ - WHERE MSG_ID = %d;", - MSGFW_SMS_SENDOPT_TABLE_NAME, pSendOptInfo->bDeliverReq, - pSendOptInfo->bKeepCopy, pSendOptInfo->option.smsSendOptInfo.bReplyPath, pMsg->msgId); - - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET " + "DELREP_REQ = %d, " + "KEEP_COPY = %d, " + "REPLY_PATH = %d, " + "ENCODE_TYPE = %d " + "WHERE MSG_ID = %d;", + MSGFW_SMS_SENDOPT_TABLE_NAME, + pSendOptInfo->bDeliverReq, + pSendOptInfo->bKeepCopy, + pSendOptInfo->option.smsSendOptInfo.bReplyPath, + pMsg->encodeType, + pMsg->msgId); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } } } else if (pMsg->msgType.mainType == MSG_MMS_TYPE) { MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_MMS_TYPE); + if (plg == NULL) { + dbHandle->endTrans(false); + return MSG_ERR_NULL_POINTER; + } err = plg->updateMessage(pMsg, pSendOptInfo, pFileData); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return MSG_ERR_STORAGE_ERROR; } + + if (pMsg->msgType.subType == MSG_SENDREQ_MMS) { + MSG_SEC_DEBUG("pMsg->msgText: %s, pMsg->thumbPath: %s ", pMsg->msgText, pMsg->thumbPath); + + err = MsgStoUpdateMMSMessage(pMsg); + + if (err != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } + } } - err = MsgStoUpdateConversation(&dbHandle, convId); + err = MsgStoUpdateConversation(dbHandle, convId); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return MSG_ERR_STORAGE_ERROR; } - err = MsgStoClearConversationTable(&dbHandle); + err = MsgStoClearConversationTable(dbHandle); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return MSG_ERR_STORAGE_ERROR; } - dbHandle.endTrans(true); + dbHandle->endTrans(true); return MSG_SUCCESS; } @@ -473,30 +517,34 @@ msg_error_t MsgStoUpdateReadStatus(msg_message_id_t msgId, bool bRead) msg_storage_id_t storageId; - if (MsgStoSetReadStatus(&dbHandle, msgId, bRead) != MSG_SUCCESS) { + MsgDbHandler *dbHandle = getDbHandle(); + if (MsgStoSetReadStatus(dbHandle, msgId, bRead) != MSG_SUCCESS) { MSG_DEBUG("MsgStoSetReadStatus() Error"); return MSG_ERR_STORAGE_ERROR; } + MsgRefreshAllNotification(true, false, false); + // Get STORAGE_ID memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT STORAGE_ID FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - storageId = dbHandle.columnInt(0); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + storageId = dbHandle->columnInt(0); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); MSG_DEBUG("StorageId:[%d]", storageId); +#ifndef FEATURE_SMS_CDMA // Update Read Status for SIM Msg if (storageId == MSG_STORAGE_SIM) { MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); @@ -508,122 +556,99 @@ msg_error_t MsgStoUpdateReadStatus(msg_message_id_t msgId, bool bRead) // Get SIM Msg ID memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_ID FROM %s WHERE MSG_ID = %d;", + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_SLOT_ID, SIM_ID FROM %s WHERE MSG_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; msg_sim_id_t simId; + msg_sim_slot_id_t sim_idx; - while (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - simId = dbHandle.columnInt(0); + while (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + sim_idx = dbHandle->columnInt(0); + simId = dbHandle->columnInt(1); - if (plg->setReadStatus(simId) != MSG_SUCCESS) { + if (plg->setReadStatus(sim_idx, simId) != MSG_SUCCESS) { MSG_DEBUG("Fail to Set Read Status for SIM SMS"); continue; } } - - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); } - +#endif return MSG_SUCCESS; } -msg_error_t MsgStoUpdateThreadReadStatus(msg_thread_id_t threadId) +msg_error_t MsgStoUpdateThreadReadStatus(msg_thread_id_t threadId, msg_id_list_s *pMsgIdList) { MSG_BEGIN(); 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 + /*** Get msg id list **/ + int rowCnt = 0, index = 0; + pMsgIdList->nCount = 0; + MsgDbHandler *dbHandle = getDbHandle(); + 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); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s " + "WHERE CONV_ID = %d AND READ_STATUS = 0 AND STORAGE_ID = %d AND FOLDER_ID < %d;", + MSGFW_MESSAGE_TABLE_NAME, + threadId, MSG_STORAGE_PHONE, MSG_SPAMBOX_ID); - err = dbHandle.getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); return err; } - pUnreadMsgIdList->nCount = rowCnt; + if (rowCnt <= 0) { + dbHandle->freeTable(); + return MSG_SUCCESS; + } - MSG_DEBUG("unreadMsgIdList.nCount [%d]", pUnreadMsgIdList->nCount); + pMsgIdList->nCount = rowCnt; + MSG_DEBUG("pMsgIdList->nCount [%d]", pMsgIdList->nCount); - pUnreadMsgIdList->msgIdList = (msg_message_id_t *)new char[sizeof(msg_message_id_t) * rowCnt]; + pMsgIdList->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 \ - WHERE CONV_ID = %d AND READ_STATUS = 0 AND STORAGE_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, threadId, MSG_STORAGE_SIM); + pMsgIdList->msgIdList[i] = dbHandle->getColumnToInt(index++); - rowCnt = 0; - err = dbHandle.getTable(sqlQuery, &rowCnt); - - if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); - return err; - } - - for (int i = 1; i <= rowCnt; i++) { - MsgStoUpdateReadStatus(dbHandle.getColumnToInt(i), true); - } - - dbHandle.freeTable(); + dbHandle->freeTable(); + /*** **/ // set read status + dbHandle->beginTrans(); memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET READ_STATUS = %d \ - WHERE CONV_ID = %d AND READ_STATUS = 0;", - MSGFW_MESSAGE_TABLE_NAME, 1, threadId); + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET READ_STATUS = %d " + "WHERE CONV_ID = %d AND READ_STATUS = 0 AND STORAGE_ID = %d AND FOLDER_ID < %d;", + MSGFW_MESSAGE_TABLE_NAME, 1, + threadId, MSG_STORAGE_PHONE, MSG_SPAMBOX_ID); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; + } - if (MsgStoUpdateConversation(&dbHandle, threadId) != MSG_SUCCESS) { + if (MsgStoUpdateConversation(dbHandle, threadId) != MSG_SUCCESS) { MSG_DEBUG("MsgStoUpdateConversation() Error"); + dbHandle->endTrans(false); return MSG_ERR_STORAGE_ERROR; } - if (g_idle_add(updateUnreadMsgCount, NULL) == 0) { - MSG_DEBUG("updateUnreadMsgCount() Error"); + dbHandle->endTrans(true); + if (g_idle_add(resetNotification, NULL) == 0) { + MSG_DEBUG("resetNotification() 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; - - delete [] pUnreadMsgIdList; - } - err = MSG_ERR_UNKNOWN; - } - } MSG_END(); return MSG_SUCCESS; @@ -633,12 +658,13 @@ msg_error_t MsgStoUpdateThreadReadStatus(msg_thread_id_t threadId) msg_error_t MsgStoUpdateProtectedStatus(msg_message_id_t msgId, bool bProtected) { char sqlQuery[MAX_QUERY_LEN+1]; + MsgDbHandler *dbHandle = getDbHandle(); memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET PROTECTED = %d WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, (int)bProtected, msgId); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; return MSG_SUCCESS; @@ -654,14 +680,37 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) msg_error_t err = MSG_SUCCESS; char sqlQuery[MAX_QUERY_LEN+1]; + MsgDbHandler *dbHandle = getDbHandle(); + + // delete report notification + char tempAddr[MAX_ADDRESS_VAL_LEN+1]; + memset(tempAddr, 0x00, sizeof(tempAddr)); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT B.ADDRESS_VAL FROM %s A, %s B WHERE A.CONV_ID = B.CONV_ID AND A.MSG_ID = %d;" + , MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, msgId); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbHandle->stepQuery() != MSG_ERR_DB_ROW) { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_DONE; + } + + snprintf(tempAddr, sizeof(tempAddr), "%s", dbHandle->columnText(0)); + + MSG_SEC_DEBUG("Updated address = %s", tempAddr); + + MsgDeleteReportNotification(tempAddr); + + dbHandle->finalizeQuery(); // Get SUB_TYPE, STORAGE_ID memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MAIN_TYPE, A.SUB_TYPE, A.FOLDER_ID, A.STORAGE_ID, A.READ_STATUS, B.CONV_ID \ - FROM %s A, %s B WHERE A.MSG_ID = %d AND A.CONV_ID = B.CONV_ID;", - MSGFW_MESSAGE_TABLE_NAME, MSGFW_CONVERSATION_TABLE_NAME, msgId); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE, SUB_TYPE, FOLDER_ID, STORAGE_ID, READ_STATUS, CONV_ID, SIM_INDEX \ + FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { MSG_DEBUG("Query Failed [%s]", sqlQuery); return MSG_ERR_DB_PREPARE; } @@ -670,80 +719,90 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) msg_folder_id_t folderId; msg_storage_id_t storageId; msg_thread_id_t convId; + msg_sim_slot_id_t simIndex; bool bRead; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - msgType.mainType = dbHandle.columnInt(0); - msgType.subType = dbHandle.columnInt(1); - folderId = dbHandle.columnInt(2); - storageId = dbHandle.columnInt(3); - bRead = dbHandle.columnInt(4); - convId = dbHandle.columnInt(5); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + msgType.mainType = dbHandle->columnInt(0); + msgType.subType = dbHandle->columnInt(1); + folderId = dbHandle->columnInt(2); + storageId = dbHandle->columnInt(3); + bRead = dbHandle->columnInt(4); + convId = dbHandle->columnInt(5); + simIndex = dbHandle->columnInt(6); - MSG_DEBUG("Main Type:[%d] SubType:[%d] FolderId:[%d] StorageId:[%d] ConversationId:[%d]", msgType.mainType, msgType.subType, folderId, storageId, convId); + MSG_DEBUG("Main Type:[%d] SubType:[%d] FolderId:[%d] StorageId:[%d] ReadStatus:[%d] ConversationId:[%d], simIndex=[%d]", msgType.mainType, msgType.subType, folderId, storageId, bRead, convId, simIndex); } else { MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery); - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); if (plg == NULL) { MSG_DEBUG("SMS Plug-in is NULL"); - return MSG_ERR_NULL_POINTER; } - dbHandle.beginTrans(); + dbHandle->beginTrans(); +#ifndef FEATURE_SMS_CDMA // Check sim message if (storageId == MSG_STORAGE_SIM) { - // get sim message id - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_ID FROM %s WHERE MSG_ID = %d;", - MSGFW_SIM_MSG_TABLE_NAME, msgId); + msg_sim_id_t simMsgId; + msg_sim_slot_id_t sim_idx; - MSG_DEBUG("sqlQuery is [%s]", sqlQuery); + while (true) { + // get sim message id + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_SLOT_ID, SIM_ID FROM %s WHERE MSG_ID = %d;", + MSGFW_SIM_MSG_TABLE_NAME, msgId); - msg_sim_id_t simMsgId; + MSG_DEBUG("sqlQuery is [%s]", sqlQuery); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); - return MSG_ERR_DB_PREPARE; - } + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_PREPARE; + } + + if (dbHandle->stepQuery() != MSG_ERR_DB_ROW) { + break; + } - while (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - simMsgId = dbHandle.columnInt(0); + sim_idx = dbHandle->columnInt(0); + simMsgId = dbHandle->columnInt(1); MSG_DEBUG("SIM Msg Id : [%d]", simMsgId); - err = plg->deleteSimMessage(simMsgId); + err = plg->deleteSimMessage(sim_idx, simMsgId); if (err != MSG_SUCCESS) { - dbHandle.finalizeQuery(); - dbHandle.endTrans(false); + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); return err; } + dbHandle->finalizeQuery(); + //Sim message delete in db table memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE SIM_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, simMsgId); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE SIM_ID = %d AND SIM_SLOT_ID =%d;", MSGFW_SIM_MSG_TABLE_NAME, simMsgId, sim_idx); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.finalizeQuery(); - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); } - +#endif /* each type has to be handled in plug in ? */ if (msgType.mainType == MSG_SMS_TYPE) { memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -751,8 +810,18 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) MSGFW_SMS_SENDOPT_TABLE_NAME, msgId); // Delete SMS Send Option - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", + MSGFW_SMS_REPORT_TABLE_NAME, msgId); + + // Delete Data from SMS_REPORT table + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } @@ -762,8 +831,8 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) MSGFW_CB_MSG_TABLE_NAME, msgId); // Delete Push Message from push table - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } } else if (msgType.subType >= MSG_WAP_SI_SMS && msgType.subType <= MSG_WAP_CO_SMS) { @@ -772,8 +841,8 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) MSGFW_PUSH_MSG_TABLE_NAME, msgId); // Delete Push Message from push table - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } } else if (msgType.subType == MSG_SYNCML_CP) { @@ -782,66 +851,129 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) MSGFW_SYNCML_MSG_TABLE_NAME, msgId); // Delete SyncML Message from syncML table - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } } } else if (msgType.mainType == MSG_MMS_TYPE) { - char filePath[MSG_FILEPATH_LEN_MAX] = {0,}; - char thumbnailpath[MSG_FILEPATH_LEN_MAX] = {0,}; - char dirPath[MSG_FILEPATH_LEN_MAX]= {0,}; + char filePath[MSG_FILEPATH_LEN_MAX + 1] = {0,}; + char dirPath[MSG_FILEPATH_LEN_MAX + 1]= {0,}; + + {//remove multipart + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE MSG_ID = %d;", + MSGFW_MMS_MULTIPART_TABLE_NAME, msgId); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_PREPARE; + } + + while (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + memset(filePath, 0x00, sizeof(filePath)); + strncpy(filePath, (char *)dbHandle->columnText(0), MSG_FILEPATH_LEN_MAX); + if (remove(filePath) == -1) + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); + else + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); + } + dbHandle->finalizeQuery(); + + // Delete Data from Multipart table + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", + MSGFW_MMS_MULTIPART_TABLE_NAME, msgId); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + } + memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_PREPARE; } - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - strncpy(filePath, (char *)dbHandle.columnText(0), MSG_FILEPATH_LEN_MAX); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + strncpy(filePath, (char *)dbHandle->columnText(0), MSG_FILEPATH_LEN_MAX); snprintf(dirPath, MSG_FILEPATH_LEN_MAX, "%s.dir", filePath); if (remove(filePath) == -1) - MSG_DEBUG("Fail to delete file [%s]", filePath); + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); else - MSG_DEBUG("Success to delete file [%s]", filePath); + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); MsgRmRf(dirPath); rmdir(dirPath); - // remove thumbnail file - char *fileName = NULL; - fileName = strrchr(filePath, '/'); - - snprintf(thumbnailpath, MSG_FILEPATH_LEN_MAX, MSG_THUMBNAIL_PATH"%s.jpg", fileName+1); - if(remove(thumbnailpath) == -1) - MSG_DEBUG("Fail to delete thumbnail [%s]", thumbnailpath); - else - MSG_DEBUG("Success to delete thumbnail [%s]", thumbnailpath); - } else { MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery); - dbHandle.finalizeQuery(); - dbHandle.endTrans(false); + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); + + // remove thumbnail file + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT VALUE FROM %s " + "WHERE MSG_ID = %d AND (TYPE=%d OR TYPE=%d);", + MSGFW_MMS_PREVIEW_TABLE_NAME, msgId, MSG_MMS_ITEM_TYPE_IMG, MSG_MMS_ITEM_TYPE_VIDEO); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_PREPARE; + } + + while (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + memset(filePath, 0x00, sizeof(filePath)); + strncpy(filePath, (char *)dbHandle->columnText(0), MSG_FILEPATH_LEN_MAX); + if (remove(filePath) == -1) + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); + else + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); + } + + dbHandle->finalizeQuery(); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", + MSGFW_MMS_PREVIEW_TABLE_NAME, msgId); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, msgId); // Delete Data from MMS table - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", + MSGFW_REPORT_TABLE_NAME, msgId); + + // Delete Data from MMS STATUS table + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } } @@ -850,53 +982,57 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); // Delete Message from msg table - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } - // Clear Conversation table - if (MsgStoClearConversationTable(&dbHandle) != MSG_SUCCESS) { - dbHandle.endTrans(false); +#ifdef FEATURE_SMS_CDMA + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_UNIQUENESS_INFO_TABLE_NAME, msgId); + + // Delete Message from uniqueness table + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } +#endif - // Update conversation table. - if (MsgStoUpdateConversation(&dbHandle, convId) != MSG_SUCCESS) { - dbHandle.endTrans(false); - return MSG_ERR_STORAGE_ERROR; - } + if (convId > 0) { + // Clear Conversation table + if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } - dbHandle.endTrans(true); + // Update conversation table. + if (MsgStoUpdateConversation(dbHandle, convId) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } + } + dbHandle->endTrans(true); if (msgType.mainType == MSG_SMS_TYPE && folderId == MSG_INBOX_ID) { msgType.classType = MSG_CLASS_NONE; // Set memory status in SIM - if (MsgStoCheckMsgCntFull(&dbHandle, &msgType, folderId) == MSG_SUCCESS) { + if (MsgStoCheckMsgCntFull(dbHandle, &msgType, folderId) == MSG_SUCCESS) { MSG_DEBUG("Set Memory Status"); +#ifndef FEATURE_SMS_CDMA + plg->setMemoryStatus(simIndex, MSG_SUCCESS); +#else plg->setMemoryStatus(MSG_SUCCESS); +#endif } } if (bCheckIndication == true) { MSG_DEBUG("bCheckIndication is true."); - - int smsCnt = 0; - int mmsCnt = 0; - - smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE); - mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE); - - MsgSettingSetIndicator(smsCnt, mmsCnt); - - MsgDeleteNotiByMsgId(msgId); + MsgRefreshAllNotification(true, false, false); } - //Delete phone log - MsgDeletePhoneLog(msgId); - return MSG_SUCCESS; } @@ -909,12 +1045,22 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD queue threadList; +#ifdef FEATURE_SMS_CDMA const char *tableList[] = {MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME, - MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, - MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME}; + MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, + MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME, + MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSGFW_UNIQUENESS_INFO_TABLE_NAME}; +#else + const char *tableList[] = {MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME, + MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, + MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME, + MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME}; +#endif int listCnt = sizeof(tableList)/sizeof(char *); int rowCnt = 0; + MsgDbHandler *dbHandle = getDbHandle(); // Get conversation ID from Folder memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -922,31 +1068,33 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT(CONV_ID) FROM %s WHERE FOLDER_ID = %d", MSGFW_MESSAGE_TABLE_NAME, folderId); - err = dbHandle.getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - MSG_DEBUG("sql query is %s.", sqlQuery); - - dbHandle.freeTable(); + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); return err; } if (rowCnt <= 0) { - dbHandle.freeTable(); - + dbHandle->freeTable(); return MSG_SUCCESS; } for (int i = 1; i <= rowCnt; i++) { - MSG_DEBUG("thread ID : %d", dbHandle.getColumnToInt(i)); - threadList.push((msg_thread_id_t)dbHandle.getColumnToInt(i)); + MSG_DEBUG("thread ID : %d", dbHandle->getColumnToInt(i)); + threadList.push((msg_thread_id_t)dbHandle->getColumnToInt(i)); } - dbHandle.freeTable(); + dbHandle->freeTable(); /*** 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)); @@ -954,20 +1102,18 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD MSGFW_MESSAGE_TABLE_NAME, folderId); rowCnt = 0; - int index = 1; + int index = 0; - err = dbHandle.getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - dbHandle.freeTable(); - + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); goto FREE_MEMORY; } if (rowCnt <= 0) { - dbHandle.freeTable(); + dbHandle->freeTable(); err = MSG_SUCCESS; goto FREE_MEMORY; @@ -980,9 +1126,9 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD pToDeleteMsgIdList->msgIdList = (msg_message_id_t *)new char[sizeof(msg_message_id_t) * rowCnt]; for (int i = 0; i < rowCnt; i++) - pToDeleteMsgIdList->msgIdList[i] = dbHandle.getColumnToInt(index++); + pToDeleteMsgIdList->msgIdList[i] = dbHandle->getColumnToInt(index++); - dbHandle.freeTable(); + dbHandle->freeTable(); /*** **/ /*** Delete Sim Message In Folder **/ @@ -992,37 +1138,33 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE FOLDER_ID = %d AND STORAGE_ID = %d", MSGFW_MESSAGE_TABLE_NAME, folderId, MSG_STORAGE_SIM); - MSG_DEBUG("sql query is %s.", sqlQuery); - rowCnt = 0; - err = dbHandle.getTable(sqlQuery, &rowCnt); - + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); - + dbHandle->freeTable(); goto FREE_MEMORY; } for (int i = 1; i <= rowCnt; i++) { - err = MsgStoDeleteMessage(dbHandle.getColumnToInt(i), false); + err = MsgStoDeleteMessage(dbHandle->getColumnToInt(i), false); if (err != MSG_SUCCESS) { MSG_DEBUG("MsgStoDeleteMessage() Error!!!"); - dbHandle.freeTable(); + dbHandle->freeTable(); goto FREE_MEMORY; } //Delete phone log - MsgDeletePhoneLog(dbHandle.getColumnToInt(i)); +// MsgDeletePhoneLog(dbHandle->getColumnToInt(i)); } - dbHandle.freeTable(); + dbHandle->freeTable(); } - dbHandle.beginTrans(); + dbHandle->beginTrans(); for (int i = 0; i < listCnt; i++) { if (!strcmp(tableList[i], MMS_PLUGIN_MESSAGE_TABLE_NAME)) { @@ -1031,7 +1173,38 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD char filePath[MSG_FILEPATH_LEN_MAX] = {0,}; char dirPath[MSG_FILEPATH_LEN_MAX] = {0,}; - char thumbnailPath[MSG_FILEPATH_LEN_MAX] = {0,}; + + {//remove multipart + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s;", + MSGFW_MMS_MULTIPART_TABLE_NAME); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_PREPARE; + } + + while (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + memset(filePath, 0x00, sizeof(filePath)); + strncpy(filePath, (char *)dbHandle->columnText(0), MSG_FILEPATH_LEN_MAX); + if (remove(filePath) == -1) + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); + else + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); + } + dbHandle->finalizeQuery(); + + // Delete Data from Multipart table + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", + MSGFW_MMS_MULTIPART_TABLE_NAME); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + err = MSG_ERR_DB_EXEC; + dbHandle->endTrans(false); + goto FREE_MEMORY; + } + } //get mms msg id list memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -1039,16 +1212,14 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD WHERE A.FOLDER_ID = %d AND A.MAIN_TYPE = %d AND A.MSG_ID = B.MSG_ID", MSGFW_MESSAGE_TABLE_NAME, MMS_PLUGIN_MESSAGE_TABLE_NAME, folderId, MSG_MMS_TYPE); - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - err = dbHandle.getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); MSG_DEBUG("rowCnt %d", rowCnt); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); + MSG_DEBUG("Fail to getTable()."); - dbHandle.freeTable(); - dbHandle.endTrans(false); + dbHandle->freeTable(); + dbHandle->endTrans(false); goto FREE_MEMORY; } @@ -1056,38 +1227,52 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD for (int i = 1; i <= rowCnt; i++) { memset(filePath, 0x00, sizeof(filePath)); - dbHandle.getColumnToString(i, MSG_FILEPATH_LEN_MAX, filePath); + dbHandle->getColumnToString(i, MSG_FILEPATH_LEN_MAX, filePath); - MSG_DEBUG("filePath [%s]", filePath); + MSG_SEC_DEBUG("filePath [%s]", filePath); //delete raw file snprintf(dirPath, sizeof(dirPath), "%s.dir", filePath); if (remove(filePath) == -1) - MSG_DEBUG("Fail to delete file [%s]", filePath); + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); else - MSG_DEBUG("Success to delete file [%s]", filePath); + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); MsgRmRf(dirPath); rmdir(dirPath); - // delete thumbnail - char *fileName = NULL; - fileName = strrchr(filePath, '/'); + } - snprintf(thumbnailPath, sizeof(thumbnailPath), MSG_THUMBNAIL_PATH"%s.jpg", fileName+1); + dbHandle->freeTable(); + } - if (remove(thumbnailPath) == -1) - MSG_DEBUG("Fail to delete thumbnail [%s]", thumbnailPath); - else - MSG_DEBUG("Success to delete thumbnail [%s]", thumbnailPath); + // delete thumbnail + char filePath[MSG_FILEPATH_LEN_MAX] = {0,}; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT VALUE FROM %s " + "WHERE (TYPE=%d OR TYPE=%d) " + "AND (MSG_ID IN (SELECT MSG_ID FROM %s WHERE FOLDER_ID = %d));", + MSGFW_MMS_PREVIEW_TABLE_NAME, MSG_MMS_ITEM_TYPE_IMG, MSG_MMS_ITEM_TYPE_VIDEO, MSGFW_MESSAGE_TABLE_NAME, folderId); - } + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_PREPARE; + } - dbHandle.freeTable(); + while (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + memset(filePath, 0x00, sizeof(filePath)); + strncpy(filePath, (char *)dbHandle->columnText(0), MSG_FILEPATH_LEN_MAX); + if (remove(filePath) == -1) + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); + else + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); } + dbHandle->finalizeQuery(); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID IN \ @@ -1095,9 +1280,9 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD tableList[i], MSGFW_MESSAGE_TABLE_NAME, folderId); // Delete Message in specific folder from table - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { MSG_DEBUG("sqlQuery [%s]", sqlQuery); - dbHandle.endTrans(false); + dbHandle->endTrans(false); err = MSG_ERR_DB_EXEC; goto FREE_MEMORY; @@ -1105,8 +1290,8 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD } // Clear Conversation table - if (MsgStoClearConversationTable(&dbHandle) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { + dbHandle->endTrans(false); err = MSG_ERR_DB_EXEC; goto FREE_MEMORY; @@ -1114,28 +1299,18 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD // Update Address while (!threadList.empty()) { - err = MsgStoUpdateConversation(&dbHandle, threadList.front()); + err = MsgStoUpdateConversation(dbHandle, threadList.front()); threadList.pop(); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); goto FREE_MEMORY; } } - dbHandle.endTrans(true); - - if (folderId == MSG_INBOX_ID) { - int smsCnt = 0; - int mmsCnt = 0; - - smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE); - mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE); - - MsgSettingSetIndicator(smsCnt, mmsCnt); - } + dbHandle->endTrans(true); /*** Set pMsgIdList **/ if (pMsgIdList != NULL && pToDeleteMsgIdList->nCount > 0) { @@ -1149,18 +1324,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 @@ -1169,21 +1334,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; - } + MsgRefreshAllNotification(true, false, false); } } /*** **/ @@ -1212,242 +1366,584 @@ FREE_MEMORY: } -msg_error_t MsgStoMoveMessageToFolder(msg_message_id_t msgId, msg_folder_id_t destFolderId) +msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) { - MSG_MESSAGE_TYPE_S msgType; - msg_thread_id_t convId; + std::string q; - MsgStoGetMsgType(msgId, &msgType); + MSG_BEGIN(); + + msg_error_t err = MSG_SUCCESS; + if (pMsgIdList->nCount < 1) { + MSG_DEBUG("pMsgIdList->nCount < 1"); + return err; + } char sqlQuery[MAX_QUERY_LEN+1]; - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + queue threadList1, threadList2; + +#ifdef FEATURE_SMS_CDMA + const char *tableList[] = {MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME, + MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME, + MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, + MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSGFW_SMS_REPORT_TABLE_NAME, MSGFW_MMS_MULTIPART_TABLE_NAME, + MSGFW_UNIQUENESS_INFO_TABLE_NAME}; +#else + const char *tableList[] = {MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME, + MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME, + MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, + MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSGFW_SMS_REPORT_TABLE_NAME, MSGFW_MMS_MULTIPART_TABLE_NAME}; +#endif - if (msgType.mainType == MSG_SMS_TYPE) - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FOLDER_ID = %d WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, destFolderId, msgId); - else - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FOLDER_ID = %d WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, destFolderId, msgId); + int listCnt = sizeof(tableList)/sizeof(char *); + int rowCnt = 0; + MsgDbHandler *dbHandle = getDbHandle(); + + dbHandle->beginTrans(); + // reset msgid temp table + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", MSGFW_TMP_MSGID_TABLE_NAME); + MSG_DEBUG("[%s]", sqlQuery); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; + } - /* get conversation id */ - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONV_ID FROM %s WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, msgId); + dbHandle->finalizeQuery(); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (?)", MSGFW_TMP_MSGID_TABLE_NAME); + MSG_DEBUG("[%s]", sqlQuery); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_PREPARE; + } - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) - convId = dbHandle.columnInt(0); + for (int i = 0; i < pMsgIdList->nCount; i++) { + dbHandle->resetQuery(); + dbHandle->bindInt(pMsgIdList->msgIdList[i], 1); + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + } - MSG_DEBUG("convId : %d", convId); + dbHandle->finalizeQuery(); + dbHandle->endTrans(true); - dbHandle.finalizeQuery(); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT(CONV_ID) FROM %s WHERE MSG_ID IN %s;", MSGFW_MESSAGE_TABLE_NAME, MSGFW_TMP_MSGID_TABLE_NAME); - /* update conversation table */ - MsgStoUpdateConversation(&dbHandle, convId); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); - return MSG_SUCCESS; -} + if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); + return err; + } + MSG_DEBUG("rowCnt [%d]", rowCnt); -msg_error_t MsgStoMoveMessageToStorage(msg_message_id_t msgId, msg_storage_id_t destStorageId) -{ - MSG_BEGIN(); + if (rowCnt < 1) { + dbHandle->freeTable(); + return MSG_SUCCESS; + } - msg_error_t err = MSG_SUCCESS; + for (int i = 1; i <= rowCnt; i++) { + MSG_DEBUG("thread ID : %d", dbHandle->getColumnToInt(i)); + threadList1.push((msg_thread_id_t)dbHandle->getColumnToInt(i)); + threadList2.push((msg_thread_id_t)dbHandle->getColumnToInt(i)); + } + dbHandle->freeTable(); - char sqlQuery[MAX_QUERY_LEN+1]; + // delete report notification + char tempAddr[MAX_ADDRESS_VAL_LEN+1]; + while (!threadList1.empty()) { + memset(tempAddr, 0x00, sizeof(tempAddr)); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT B.ADDRESS_VAL FROM %s A, %s B WHERE A.CONV_ID = B.CONV_ID AND A.CONV_ID = %d;" + , MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, threadList1.front()); - MSG_DEBUG("msgId : %d, destStorageId : %d", msgId, destStorageId); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; - switch (destStorageId) { - case MSG_STORAGE_SIM : // Move message to sim card - { - MSG_MESSAGE_INFO_S msgInfo; - SMS_SIM_ID_LIST_S simIdList; + if (dbHandle->stepQuery() != MSG_ERR_DB_ROW) { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_DONE; + } - memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); - memset(&simIdList, 0x00, sizeof(SMS_SIM_ID_LIST_S)); + snprintf(tempAddr, sizeof(tempAddr), "%s", dbHandle->columnText(0)); - if ((err = MsgStoGetMessage(msgId, &msgInfo, NULL)) != MSG_SUCCESS) - return err; + MSG_SEC_DEBUG("Updated address = %s", tempAddr); - MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); + MsgDeleteReportNotification(tempAddr); - if ((err = plg->saveSimMessage(&msgInfo, &simIdList)) != MSG_SUCCESS) - return err; + dbHandle->finalizeQuery(); - dbHandle.beginTrans(); + threadList1.pop(); + } - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET STORAGE_ID = %d WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, destStorageId, msgId); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); - return MSG_ERR_DB_EXEC; - } + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE STORAGE_ID = %d AND MSG_ID IN %s;", + MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_SIM, MSGFW_TMP_MSGID_TABLE_NAME); - for (unsigned int i = 0; i < simIdList.count; i++) { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);", - MSGFW_SIM_MSG_TABLE_NAME, msgId, simIdList.simId[i]); + rowCnt = 0; + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); - return MSG_ERR_DB_EXEC; - } - } + if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); + rowCnt = 0; + } - dbHandle.endTrans(true); + for (int i = 1; i <= rowCnt; i++) { + err = MsgStoDeleteMessage(dbHandle->getColumnToInt(i), false); + if (err != MSG_SUCCESS) { + MSG_DEBUG("MsgStoDeleteMessage() Error!!!"); } - break; + } + dbHandle->freeTable(); + /*** **/ - default: //Moving message to memory (when destination storage id is MSG_STORAGE_PHONE) - { - bool bSimMsg = false; - int rowCnt = 0; + dbHandle->beginTrans(); + for (int i = 0; i < listCnt; i++) { + if ( !i ) { + + char filePath[MSG_FILEPATH_LEN_MAX]; + char dirPath[MSG_FILEPATH_LEN_MAX]; + + rowCnt = 0; memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT STORAGE_ID FROM %s WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, msgId); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE MSG_ID IN %s;", MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_TMP_MSGID_TABLE_NAME); - err = dbHandle.getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); - if (err != MSG_SUCCESS) { - dbHandle.freeTable(); - return err; + if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { + MSG_DEBUG("Fail to getTable()."); + rowCnt = 0; } - if (dbHandle.getColumnToInt(1) == MSG_STORAGE_SIM) { - MSG_DEBUG("It is SIM Message"); - bSimMsg = true; + MSG_DEBUG("rowCnt %d", rowCnt); + + for (int i = 1; i <= rowCnt; i++) { + dbHandle->getColumnToString(i, MSG_FILEPATH_LEN_MAX, filePath); + + MSG_SEC_DEBUG("filePath [%s]", filePath); + + // Delete raw file. + snprintf(dirPath, sizeof(dirPath), "%s.dir", filePath); + + if (remove(filePath) == -1) + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); + else + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); + + MsgRmRf(dirPath); + + rmdir(dirPath); } + dbHandle->freeTable(); - dbHandle.freeTable(); + } else if (i == 1) { - if (bSimMsg == true) { - msg_sim_id_t simMsgId; + char filePath[MSG_FILEPATH_LEN_MAX] = {0,}; - // get sim message id - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + rowCnt = 0; - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_ID FROM %s WHERE MSG_ID = %d;", - MSGFW_SIM_MSG_TABLE_NAME, msgId); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT VALUE FROM %s WHERE (TYPE = %d OR TYPE = %d) AND MSG_ID IN %s;", + MSGFW_MMS_PREVIEW_TABLE_NAME, MSG_MMS_ITEM_TYPE_IMG, MSG_MMS_ITEM_TYPE_VIDEO, MSGFW_TMP_MSGID_TABLE_NAME); - MSG_DEBUG("sqlQuery is %s.", sqlQuery); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); - err = dbHandle.getTable(sqlQuery, &rowCnt); + if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { + MSG_DEBUG("Fail to getTable()."); + rowCnt = 0; + } - if (err != MSG_SUCCESS) { - dbHandle.freeTable(); - return err; - } + MSG_DEBUG("rowCnt %d", rowCnt); - //Delete messages in sim card - MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); + for (int i = 1; i <= rowCnt; i++) { + memset(filePath, 0x00, sizeof(filePath)); + dbHandle->getColumnToString(i, MSG_FILEPATH_LEN_MAX, filePath); + if (remove(filePath) == -1) + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); + else + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); + } + dbHandle->freeTable(); + } else if (!strcmp(tableList[i], MSGFW_MMS_MULTIPART_TABLE_NAME)) { + // MMS file path to delete. + char filePath[MSG_FILEPATH_LEN_MAX] = {0,}; - for (int i = 0; i < rowCnt; i++) { - simMsgId = dbHandle.getColumnToInt(i+1); + rowCnt = 0; - MSG_DEBUG("simMsgId is %d.", simMsgId); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE MSG_ID IN %s;", MSGFW_MMS_MULTIPART_TABLE_NAME, MSGFW_TMP_MSGID_TABLE_NAME); - if ((err = plg->deleteSimMessage(simMsgId)) != MSG_SUCCESS) { - dbHandle.freeTable(); - return err; - } + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); + + if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { + MSG_DEBUG("Fail to getTable()."); + rowCnt = 0; } - dbHandle.freeTable(); + MSG_DEBUG("rowCnt %d", rowCnt); - dbHandle.beginTrans(); + for (int i = 1; i <= rowCnt; i++) { + memset(filePath, 0x00, sizeof(filePath)); + dbHandle->getColumnToString(i, MSG_FILEPATH_LEN_MAX, filePath); + if (filePath[0] != '\0') { + if (remove(filePath) == -1) + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); + else + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); + } + } + dbHandle->freeTable(); - //Delete Messages in SIM Msg table + // MMS thumbnail path to delete memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", - MSGFW_SIM_MSG_TABLE_NAME, msgId); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT THUMB_FILE_PATH FROM %s WHERE MSG_ID IN %s;", MSGFW_MMS_MULTIPART_TABLE_NAME, MSGFW_TMP_MSGID_TABLE_NAME); - MSG_DEBUG("sqlQuery is %s.", sqlQuery); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); - return MSG_ERR_DB_EXEC; + if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { + MSG_DEBUG("Fail to getTable()."); + rowCnt = 0; } - //Move storage id - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET STORAGE_ID = %d WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, destStorageId, msgId); + MSG_DEBUG("rowCnt %d", rowCnt); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); - return MSG_ERR_DB_EXEC; + for (int i = 1; i <= rowCnt; i++) { + memset(filePath, 0x00, sizeof(filePath)); + dbHandle->getColumnToString(i, MSG_FILEPATH_LEN_MAX, filePath); + if (filePath[0] != '\0') { + if (remove(filePath) == -1) + MSG_SEC_DEBUG("Fail to delete file [%s]", filePath); + else + MSG_SEC_DEBUG("Success to delete file [%s]", filePath); + } } - dbHandle.endTrans(true); - } + dbHandle->freeTable(); } - } - return MSG_SUCCESS; -} + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID IN %s;", tableList[i], MSGFW_TMP_MSGID_TABLE_NAME); + // Delete Message in specific folder from table + err = dbHandle->execQuery(sqlQuery); + if (err != MSG_SUCCESS) { + MSG_DEBUG("Fail to execQuery()."); + } + } -msg_error_t MsgStoCountMessage(msg_folder_id_t folderId, MSG_COUNT_INFO_S *pCountInfo) -{ - if (pCountInfo == NULL) { + // Clear Conversation table + err = MsgStoClearConversationTable(dbHandle); + if (err != MSG_SUCCESS) MSG_DEBUG("Fail to MsgStoClearConversationTable()."); + + // Update Address + while (!threadList2.empty()) { + err = MsgStoUpdateConversation(dbHandle, threadList2.front()); + if (err != MSG_SUCCESS) MSG_DEBUG("Fail to MsgStoUpdateConversation()."); + threadList2.pop(); + } + err = dbHandle->endTrans(true); + if (err != MSG_SUCCESS) { + MSG_DEBUG("Fail to endTrans(true)."); + dbHandle->endTrans(false); + return err; + } + + if (g_idle_add(resetNotification, NULL) == 0) { + MSG_DEBUG("resetNotification() Error"); + } + + MSG_END(); + return MSG_SUCCESS; +} + + +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 = 0; + + MsgStoGetMsgType(msgId, &msgType); + + char sqlQuery[MAX_QUERY_LEN+1]; + MsgDbHandler *dbHandle = getDbHandle(); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + if (msgType.mainType == MSG_SMS_TYPE) + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FOLDER_ID = %d WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, destFolderId, msgId); + else + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET FOLDER_ID = %d WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, destFolderId, msgId); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_EXEC; + + /* get conversation id */ + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONV_ID FROM %s WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, msgId); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) + convId = dbHandle->columnInt(0); + + MSG_DEBUG("convId : %d", convId); + + dbHandle->finalizeQuery(); + + /* update conversation table */ + err = MsgStoUpdateConversation(dbHandle, convId); + + /* update notification */ + MsgRefreshAllNotification(true, false, false); + + return err; +} + + +msg_error_t MsgStoMoveMessageToStorage(msg_message_id_t msgId, msg_storage_id_t destStorageId) +{ + MSG_BEGIN(); + + msg_error_t err = MSG_SUCCESS; + + char sqlQuery[MAX_QUERY_LEN+1]; + MsgDbHandler *dbHandle = getDbHandle(); + + MSG_DEBUG("msgId : %d, destStorageId : %d", msgId, destStorageId); + + switch (destStorageId) { + case MSG_STORAGE_SIM : // Move message to sim card + case MSG_STORAGE_SIM2 : + { + MSG_MESSAGE_INFO_S msgInfo; + SMS_SIM_ID_LIST_S simIdList; + + memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); + memset(&simIdList, 0x00, sizeof(SMS_SIM_ID_LIST_S)); + + if ((err = MsgStoGetMessage(msgId, &msgInfo, NULL)) != MSG_SUCCESS) + return err; + + MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); + if (plg == NULL) { + MSG_DEBUG("SMS Plug-in is NULL"); + return MSG_ERR_NULL_POINTER; + } + + if (destStorageId == MSG_STORAGE_SIM) + msgInfo.sim_idx = 1; + else if (destStorageId == MSG_STORAGE_SIM2) + msgInfo.sim_idx = 2; + + if ((err = plg->saveSimMessage(&msgInfo, &simIdList)) != MSG_SUCCESS) + return err; + + dbHandle->beginTrans(); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET STORAGE_ID = %d, SIM_INDEX = %d WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_SIM, msgInfo.sim_idx, msgId); + MSG_DEBUG("SQL query=[%s]", sqlQuery); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + for (unsigned int i = 0; i < simIdList.count; i++) { + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d);", + MSGFW_SIM_MSG_TABLE_NAME, msgInfo.sim_idx, simIdList.simId[i], msgId); + MSG_DEBUG("SQL query=[%s]", sqlQuery); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + } + + dbHandle->endTrans(true); + } + break; + + default: //Moving message to memory (when destination storage id is MSG_STORAGE_PHONE) + { + bool bSimMsg = false; + int rowCnt = 0; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT STORAGE_ID FROM %s WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, msgId); + + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); + + if (err != MSG_SUCCESS) { + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); + return err; + } + + if (dbHandle->getColumnToInt(1) == MSG_STORAGE_SIM) { + MSG_DEBUG("It is SIM Message"); + bSimMsg = true; + } + + dbHandle->freeTable(); + +#ifndef FEATURE_SMS_CDMA + if (bSimMsg == true) { + msg_sim_id_t simMsgId; + msg_sim_slot_id_t sim_idx; + + // get sim message id + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_SLOT_ID, SIM_ID FROM %s WHERE MSG_ID = %d;", + MSGFW_SIM_MSG_TABLE_NAME, msgId); + + int index = 0; + + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); + + if (err != MSG_SUCCESS) { + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); + return err; + } + + //Delete messages in sim card + MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); + if (plg == NULL) { + MSG_DEBUG("SMS Plug-in is NULL"); + dbHandle->freeTable(); + return MSG_ERR_NULL_POINTER; + } + + for (int i = 0; i < rowCnt; i++) { + sim_idx = dbHandle->getColumnToInt(index++); + simMsgId = dbHandle->getColumnToInt(index++); + + MSG_DEBUG("simMsgId is %d.", simMsgId); + + if ((err = plg->deleteSimMessage(sim_idx, simMsgId)) != MSG_SUCCESS) { + dbHandle->freeTable(); + return err; + } + } + + dbHandle->freeTable(); + + dbHandle->beginTrans(); + + //Delete Messages in SIM Msg table + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", + MSGFW_SIM_MSG_TABLE_NAME, msgId); + MSG_DEBUG("SQL query=[%s]", sqlQuery); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + //Move storage id + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET STORAGE_ID = %d WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, destStorageId, msgId); + MSG_DEBUG("SQL query=[%s]", sqlQuery); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + dbHandle->endTrans(true); + } +#endif + } + break; + } + + return MSG_SUCCESS; +} + + +msg_error_t MsgStoCountMessage(msg_folder_id_t folderId, MSG_COUNT_INFO_S *pCountInfo) +{ + if (pCountInfo == NULL) { MSG_DEBUG("pCountInfo is NULL"); return MSG_ERR_NULL_POINTER; } char sqlQuery[MAX_QUERY_LEN+1]; + MsgDbHandler *dbHandle = getDbHandle(); memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND READ_STATUS = 1 \ - UNION ALL SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND READ_STATUS = 0 \ - UNION ALL SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d \ - UNION ALL SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d;", - MSGFW_MESSAGE_TABLE_NAME, folderId, - MSGFW_MESSAGE_TABLE_NAME, folderId, - MSGFW_MESSAGE_TABLE_NAME, folderId, MSG_SMS_TYPE, - MSGFW_MESSAGE_TABLE_NAME, folderId, MSG_MMS_TYPE); - - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND READ_STATUS = 1 AND STORAGE_ID = %d " + "UNION ALL SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND READ_STATUS = 0 AND STORAGE_ID = %d " + "UNION ALL SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d AND STORAGE_ID = %d " + "UNION ALL SELECT COUNT(MSG_ID) FROM %s WHERE FOLDER_ID = %d AND MAIN_TYPE = %d AND STORAGE_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, folderId, MSG_STORAGE_PHONE, + MSGFW_MESSAGE_TABLE_NAME, folderId, MSG_STORAGE_PHONE, + MSGFW_MESSAGE_TABLE_NAME, folderId, MSG_SMS_TYPE, MSG_STORAGE_PHONE, + MSGFW_MESSAGE_TABLE_NAME, folderId, MSG_MMS_TYPE, MSG_STORAGE_PHONE); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - pCountInfo->nReadCnt = dbHandle.columnInt(0); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + pCountInfo->nReadCnt = dbHandle->columnInt(0); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - pCountInfo->nUnreadCnt = dbHandle.columnInt(0); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + pCountInfo->nUnreadCnt = dbHandle->columnInt(0); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - pCountInfo->nSms = dbHandle.columnInt(0); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + pCountInfo->nSms = dbHandle->columnInt(0); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - pCountInfo->nMms = dbHandle.columnInt(0); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + pCountInfo->nMms = dbHandle->columnInt(0); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_SUCCESS; } @@ -1465,6 +1961,7 @@ msg_error_t MsgStoCountMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCo char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); + MsgDbHandler *dbHandle = getDbHandle(); // SMS if ((pMsgType->mainType == MSG_SMS_TYPE) && (pMsgType->subType == MSG_NORMAL_SMS || pMsgType->subType == MSG_STATUS_REPORT_SMS || pMsgType->subType == MSG_CONCAT_SIM_SMS)) { @@ -1484,17 +1981,17 @@ msg_error_t MsgStoCountMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCo return MSG_ERR_INVALID_PARAMETER; } - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - *pMsgCount = dbHandle.columnInt(0); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + *pMsgCount = dbHandle->columnInt(0); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_SUCCESS; } @@ -1503,36 +2000,35 @@ msg_error_t MsgStoCountMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCo msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo) { char sqlQuery[MAX_QUERY_LEN+1]; - - int order = MsgGetContactNameOrder(); - memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, CONV_ID, FOLDER_ID, STORAGE_ID, MAIN_TYPE, \ SUB_TYPE, DISPLAY_TIME, DATA_SIZE, NETWORK_STATUS, READ_STATUS, PROTECTED, \ - BACKUP, PRIORITY, MSG_DIRECTION, SCHEDULED_TIME, SUBJECT, MSG_TEXT, THUMB_PATH \ + BACKUP, PRIORITY, MSG_DIRECTION, SCHEDULED_TIME, SUBJECT, MSG_TEXT, THUMB_PATH, SIM_INDEX \ FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + MsgDbHandler *dbHandle = getDbHandle(); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - pMsg->msgId = dbHandle.columnInt(0); - pMsg->threadId = dbHandle.columnInt(1); - pMsg->folderId = dbHandle.columnInt(2); - pMsg->storageId = dbHandle.columnInt(3); - pMsg->msgType.mainType = dbHandle.columnInt(4); - pMsg->msgType.subType = dbHandle.columnInt(5); - pMsg->displayTime = (time_t)dbHandle.columnInt(6); - pMsg->dataSize = dbHandle.columnInt(7); - pMsg->networkStatus = dbHandle.columnInt(8); - pMsg->bRead = dbHandle.columnInt(9); - pMsg->bProtected = dbHandle.columnInt(10); - pMsg->bBackup = dbHandle.columnInt(11); - pMsg->priority = dbHandle.columnInt(12); - pMsg->direction= dbHandle.columnInt(13); - - strncpy(pMsg->subject, (char *)dbHandle.columnText(15), MAX_SUBJECT_LEN); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + pMsg->msgId = dbHandle->columnInt(0); + pMsg->threadId = dbHandle->columnInt(1); + pMsg->folderId = dbHandle->columnInt(2); + pMsg->storageId = dbHandle->columnInt(3); + pMsg->msgType.mainType = dbHandle->columnInt(4); + pMsg->msgType.subType = dbHandle->columnInt(5); + pMsg->displayTime = (time_t)dbHandle->columnInt(6); + pMsg->dataSize = dbHandle->columnInt(7); + pMsg->networkStatus = dbHandle->columnInt(8); + pMsg->bRead = dbHandle->columnInt(9); + pMsg->bProtected = dbHandle->columnInt(10); + pMsg->bBackup = dbHandle->columnInt(11); + pMsg->priority = dbHandle->columnInt(12); + pMsg->direction= dbHandle->columnInt(13); + + strncpy(pMsg->subject, (char *)dbHandle->columnText(15), MAX_SUBJECT_LEN); /* Temp_File_Handling */ if (pMsg->msgType.mainType == MSG_SMS_TYPE || pMsg->msgType.subType == MSG_NOTIFICATIONIND_MMS) { @@ -1540,21 +2036,21 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M char msgData[pMsg->dataSize+1]; memset(msgData, 0x00, sizeof(msgData)); - strncpy(msgData, (char *)dbHandle.columnText(16), pMsg->dataSize); + strncpy(msgData, (char *)dbHandle->columnText(16), pMsg->dataSize); // 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) { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_STORAGE_ERROR; } - MSG_DEBUG("Save Message Data into file : size[%d] name[%s]\n", pMsg->dataSize, fileName); + MSG_SEC_DEBUG("Save Message Data into file : size[%d] name[%s]\n", pMsg->dataSize, fileName); if (MsgWriteIpcFile(fileName, msgData, pMsg->dataSize) == false) { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_STORAGE_ERROR; } @@ -1563,53 +2059,57 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M pMsg->bTextSms = false; } else { memset(pMsg->msgText, 0x00, sizeof(pMsg->msgText)); - strncpy(pMsg->msgText, (char *)dbHandle.columnText(16), pMsg->dataSize); + strncpy(pMsg->msgText, (char *)dbHandle->columnText(16), pMsg->dataSize); // For WAP PUSH SI Message if (pMsg->msgType.subType == MSG_WAP_SI_SMS) { strncat(pMsg->msgText, "\n", MAX_MSG_TEXT_LEN-strlen(pMsg->msgText)); strncat(pMsg->msgText, pMsg->subject, MAX_MSG_TEXT_LEN-strlen(pMsg->msgText)); - MSG_DEBUG("pMsg->msgText : [%s]", pMsg->msgText); + MSG_SEC_DEBUG("pMsg->msgText : [%s]", pMsg->msgText); pMsg->dataSize = sizeof(pMsg->msgText); } pMsg->bTextSms = true; } } else { - if (dbHandle.columnText(16) != NULL) - strncpy(pMsg->msgText, (char *)dbHandle.columnText(16), MAX_MSG_TEXT_LEN); + if (dbHandle->columnText(16) != NULL) + strncpy(pMsg->msgText, (char *)dbHandle->columnText(16), MAX_MSG_TEXT_LEN); } // thumbnail path - if (dbHandle.columnText(17)!=NULL && ((char *)dbHandle.columnText(17))[0] != '\0') { - strncpy(pMsg->thumbPath, (char *)dbHandle.columnText(17), MSG_FILEPATH_LEN_MAX); + if (dbHandle->columnText(17)!= NULL && ((char *)dbHandle->columnText(17))[0] != '\0') { + strncpy(pMsg->thumbPath, (char *)dbHandle->columnText(17), MSG_FILEPATH_LEN_MAX); MSG_DEBUG("pMsg->thumbPath : [%s]", pMsg->thumbPath); } + pMsg->sim_idx = dbHandle->columnInt(18); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); MSG_DEBUG("%s", sqlQuery); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); // get address information. - MsgStoGetAddressByMsgId(&dbHandle, pMsg->msgId, order, &pMsg->nAddressCnt, pMsg->addressList); + MsgStoGetAddressByMsgId(dbHandle, pMsg->msgId, MsgGetContactNameOrder(), &pMsg->nAddressCnt, &pMsg->addressList); // Get MMS body if it is MMS. if ((pMsg->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS && - (pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS)) || - pMsg->msgType.subType == MSG_SENDREQ_MMS || pMsg->msgType.subType == MSG_SENDCONF_MMS) { + (pMsg->msgType.subType == MSG_RETRIEVE_MMS || pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS)) || + pMsg->msgType.subType == MSG_SENDREQ_MMS || pMsg->msgType.subType == MSG_SENDCONF_MMS || pMsg->msgType.subType == MSG_NOTIFICATIONIND_MMS) { msg_error_t err = MSG_SUCCESS; - MMS_MESSAGE_DATA_S mmsMsg; char *pDestMsg = NULL; + int temp_size = pMsg->dataSize;//save raw file size; // call mms plugin to get mms specific message data MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(pMsg->msgType.mainType); - memset(&mmsMsg, 0, sizeof(MMS_MESSAGE_DATA_S)); - err = plg->getMmsMessage(pMsg, pSendOptInfo, &mmsMsg, &pDestMsg); + if (plg == NULL) { + MSG_DEBUG("SMS Plug-in is NULL"); + return MSG_ERR_NULL_POINTER; + } + err = plg->getMmsMessage(pMsg, pSendOptInfo, &pDestMsg); if (err != MSG_SUCCESS) { if (pDestMsg) { free(pDestMsg); @@ -1623,7 +2123,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) { @@ -1633,7 +2133,7 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M } return MSG_ERR_STORAGE_ERROR; } - MSG_DEBUG("Save Message Data into file : size[%d] name[%s]\n", pMsg->dataSize, tempFileName); + MSG_SEC_DEBUG("Save Message Data into file : size[%d] name[%s]\n", pMsg->dataSize, tempFileName); if (MsgWriteIpcFile(tempFileName, pDestMsg, pMsg->dataSize) == false) { if(pDestMsg) { @@ -1643,13 +2143,14 @@ 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); pMsg->bTextSms = true; } + pMsg->dataSize = temp_size;//raw file size; + if (pDestMsg) { free(pDestMsg); pDestMsg = NULL; @@ -1658,134 +2159,43 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M // Get SMS Sending Options if (pMsg->msgType.mainType == MSG_SMS_TYPE && pSendOptInfo != NULL) - MsgStoGetSmsSendOpt(pMsg->msgId, pSendOptInfo); + MsgStoGetSmsSendOpt(pMsg, pSendOptInfo); return MSG_SUCCESS; } - -msg_error_t MsgStoGetFolderViewList(msg_folder_id_t folderId, const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pMsgFolderViewList) +msg_error_t MsgStoGetFailedMessage(int **failed_msg_list, int *count) { - if (pMsgFolderViewList == NULL) { - MSG_DEBUG("pMsgFolderViewList is NULL"); - return MSG_ERR_NULL_POINTER; - } - - int rowCnt = 0; - int index = 19; // numbers of index - + MSG_BEGIN(); + msg_error_t err = MSG_SUCCESS; char sqlQuery[MAX_QUERY_LEN+1]; - char sqlSort[64]; + int rowCnt = 0, index = 0; + MsgDbHandler *dbHandle = getDbHandle(); - // Get Name Order - int order = MsgGetContactNameOrder(); - - // Get Message In Folder memset(sqlQuery, 0x00, sizeof(sqlQuery)); - if (folderId == MSG_ALLBOX_ID) { - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, CONV_ID, FOLDER_ID, STORAGE_ID, MAIN_TYPE, SUB_TYPE, \ - DISPLAY_TIME, DATA_SIZE, NETWORK_STATUS, READ_STATUS, PROTECTED, BACKUP, PRIORITY, \ - MSG_DIRECTION, SCHEDULED_TIME, SUBJECT, MSG_TEXT, ATTACHMENT_COUNT, THUMB_PATH \ - FROM %s WHERE FOLDER_ID < %d ", - MSGFW_MESSAGE_TABLE_NAME, MSG_SPAMBOX_ID); - } else { - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, CONV_ID, FOLDER_ID, STORAGE_ID, MAIN_TYPE, SUB_TYPE, \ - DISPLAY_TIME, DATA_SIZE, NETWORK_STATUS, READ_STATUS, PROTECTED, BACKUP, PRIORITY, \ - MSG_DIRECTION, SCHEDULED_TIME, SUBJECT, MSG_TEXT, ATTACHMENT_COUNT, THUMB_PATH \ - FROM %s WHERE FOLDER_ID = %d ", - MSGFW_MESSAGE_TABLE_NAME, folderId); - } - - memset(sqlSort, 0x00, sizeof(sqlSort)); - MsgMakeSortRule(pSortRule, sqlSort); - strncat(sqlQuery, sqlSort, strlen(sqlSort)); - - msg_error_t err = dbHandle.getTable(sqlQuery, &rowCnt); - - if (err == MSG_ERR_DB_NORECORD) { - pMsgFolderViewList->nCount = 0; - pMsgFolderViewList->msg_struct_info = NULL; - - dbHandle.freeTable(); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE NETWORK_STATUS = %d AND FOLDER_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_PENDING, MSG_OUTBOX_ID); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); + if(err == MSG_ERR_DB_NORECORD){ + dbHandle->freeTable(); return MSG_SUCCESS; - } else if (err != MSG_SUCCESS) { - MSG_DEBUG("sqlQuery is - %s", sqlQuery); - dbHandle.freeTable(); - return err; } + *count = rowCnt; + int *list = new int[rowCnt]; - pMsgFolderViewList->nCount = rowCnt; - - MSG_DEBUG("pMsgCommInfoList->nCount [%d]", pMsgFolderViewList->nCount); - - pMsgFolderViewList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t) * rowCnt]; - - msg_struct_s *msg = NULL; - MSG_MESSAGE_HIDDEN_S *pTmp = NULL; - - for (int i = 0; i < rowCnt; i++) { - pMsgFolderViewList->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];; - - msg = (msg_struct_s *)pMsgFolderViewList->msg_struct_info[i]; - - msg->type = MSG_STRUCT_MESSAGE_INFO; - msg->data = new char[sizeof(MSG_MESSAGE_HIDDEN_S)]; - - pTmp = (MSG_MESSAGE_HIDDEN_S *)msg->data; - - pTmp->pData = NULL; - pTmp->pMmsData = NULL; - - pTmp->msgId = dbHandle.getColumnToInt(index++); - pTmp->threadId = dbHandle.getColumnToInt(index++); - pTmp->folderId = dbHandle.getColumnToInt(index++); - pTmp->storageId = dbHandle.getColumnToInt(index++); - pTmp->mainType = dbHandle.getColumnToInt(index++); - pTmp->subType = dbHandle.getColumnToInt(index++); - pTmp->displayTime = (time_t)dbHandle.getColumnToInt(index++); - pTmp->dataSize = dbHandle.getColumnToInt(index++); - pTmp->networkStatus = dbHandle.getColumnToInt(index++); - pTmp->bRead = dbHandle.getColumnToInt(index++); - pTmp->bProtected = dbHandle.getColumnToInt(index++); - pTmp->bBackup = dbHandle.getColumnToInt(index++); - pTmp->priority = dbHandle.getColumnToInt(index++); - pTmp->direction= dbHandle.getColumnToInt(index++); - index++; // This field is reserved. - - dbHandle.getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject); - - if (pTmp->mainType == MSG_MMS_TYPE && - (pTmp->networkStatus == MSG_NETWORK_RETRIEVING || pTmp->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pTmp->subType == MSG_NOTIFICATIONIND_MMS)) { - pTmp->pData = NULL; - index++; - } else { - pTmp->pData = (void *)new char[pTmp->dataSize + 2]; - memset(pTmp->pData, 0x00, sizeof(pTmp->pData)); - - dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData); - } - - // get address information from db. - msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s; - - MsgStoGetAddressByMsgId(&dbHandle, pTmp->msgId, order, addr_list); - - pTmp->addr_list = addr_list; - - pTmp->attachCount = dbHandle.getColumnToInt(index++); - - dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath); + for(int i=0; igetColumnToInt(index++); } + *failed_msg_list = list; + dbHandle->freeTable(); - dbHandle.freeTable(); - - return MSG_SUCCESS; + MSG_END(); + return err; } - msg_error_t MsgStoAddSyncMLMessage(MSG_MESSAGE_INFO_S *pMsgInfo, int extId, int pinCode) { MSG_BEGIN(); @@ -1796,24 +2206,25 @@ msg_error_t MsgStoAddSyncMLMessage(MSG_MESSAGE_INFO_S *pMsgInfo, int extId, int unsigned int rowId = 0; msg_thread_id_t convId = 0; + MsgDbHandler *dbHandle = getDbHandle(); - dbHandle.beginTrans(); + dbHandle->beginTrans(); if (pMsgInfo->nAddressCnt > 0) { - err = MsgStoAddAddress(&dbHandle, pMsgInfo, &convId); + err = MsgStoAddAddress(dbHandle, pMsgInfo, &convId); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return err; } } // Add Message Table pMsgInfo->threadId = convId; - rowId = MsgStoAddMessageTable(&dbHandle, pMsgInfo); + rowId = MsgStoAddMessageTable(dbHandle, pMsgInfo); if (rowId <= 0) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return MSG_ERR_DB_ROW; } @@ -1821,31 +2232,22 @@ msg_error_t MsgStoAddSyncMLMessage(MSG_MESSAGE_INFO_S *pMsgInfo, int extId, int snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d);", MSGFW_SYNCML_MSG_TABLE_NAME, rowId, extId, pinCode); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } - if (MsgStoUpdateConversation(&dbHandle, convId) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (MsgStoUpdateConversation(dbHandle, convId) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_STORAGE_ERROR; } - dbHandle.endTrans(true); + dbHandle->endTrans(true); pMsgInfo->msgId = (msg_message_id_t)rowId; - MsgSoundPlayStart(); - - int smsCnt = 0; - int mmsCnt = 0; - - smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE); - mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE); - - MsgSettingHandleNewMsg(smsCnt, mmsCnt); - - MsgInsertNoti(&dbHandle, pMsgInfo); + MsgInsertNotification(pMsgInfo); + MsgChangePmState(); MSG_END(); @@ -1855,6 +2257,7 @@ msg_error_t MsgStoAddSyncMLMessage(MSG_MESSAGE_INFO_S *pMsgInfo, int extId, int msg_error_t MsgStoGetMsgType(msg_message_id_t msgId, MSG_MESSAGE_TYPE_S *pMsgType) { + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -1862,15 +2265,15 @@ msg_error_t MsgStoGetMsgType(msg_message_id_t msgId, MSG_MESSAGE_TYPE_S *pMsgTyp snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE, SUB_TYPE FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - pMsgType->mainType = dbHandle.columnInt(0); - pMsgType->subType = dbHandle.columnInt(1); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + pMsgType->mainType = dbHandle->columnInt(0); + pMsgType->subType = dbHandle->columnInt(1); } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_SUCCESS; } @@ -1880,6 +2283,7 @@ msg_error_t MsgStoGetQuickPanelData(msg_quickpanel_type_t QPtype, MSG_MESSAGE_IN { msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -1907,17 +2311,17 @@ msg_error_t MsgStoGetQuickPanelData(msg_quickpanel_type_t QPtype, MSG_MESSAGE_IN // Get Message ID msg_message_id_t msgId; - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - msgId = dbHandle.columnInt(0); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + msgId = dbHandle->columnInt(0); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); // Get Message Info err = MsgStoGetMessage(msgId, pMsg, NULL); @@ -1926,1038 +2330,266 @@ msg_error_t MsgStoGetQuickPanelData(msg_quickpanel_type_t QPtype, MSG_MESSAGE_IN } -msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList) +msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t threadId, bool bIncludeProtect, msg_id_list_s *pMsgIdList) { - pThreadViewList->nCount = 0; - pThreadViewList->msg_struct_info = NULL; - - int rowCnt = 0; - int index = 10; // numbers of index + msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONV_ID, UNREAD_CNT, SMS_CNT, MMS_CNT, \ - MAIN_TYPE, SUB_TYPE, MSG_DIRECTION, DISPLAY_TIME, DISPLAY_NAME, MSG_TEXT \ - FROM %s WHERE SMS_CNT > 0 OR MMS_CNT > 0 ORDER BY DISPLAY_TIME DESC;", - MSGFW_CONVERSATION_TABLE_NAME); + /*** Get msg id list **/ + int rowCnt = 0, index = 0; - msg_error_t err = dbHandle.getTable(sqlQuery, &rowCnt); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - if (err == MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); - return MSG_SUCCESS; - } else if (err != MSG_SUCCESS) { - MSG_DEBUG("%s", sqlQuery); - dbHandle.freeTable(); - return err; +#ifdef MSG_NOTI_INTEGRATION + if (bIncludeProtect) { + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE \ + CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, threadId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE); + } else { + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE \ + CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND PROTECTED = 0;", + MSGFW_MESSAGE_TABLE_NAME, threadId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE); + } +#else + if (bIncludeProtect) { + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE \ + CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, threadId, MSG_ALLBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE); + } else { + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE \ + CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND PROTECTED = 0;", + MSGFW_MESSAGE_TABLE_NAME, threadId, MSG_ALLBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE); } +#endif - if (rowCnt < 1) { - MSG_DEBUG("rowCnt is %d", rowCnt); - dbHandle.freeTable(); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); + + if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); return err; } - pThreadViewList->nCount = rowCnt; - - MSG_DEBUG("pThreadViewList->nCount [%d]", pThreadViewList->nCount); - - pThreadViewList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t)*rowCnt]; - - MSG_THREAD_VIEW_S *pTmp = NULL; - msg_struct_s *thread_t = NULL; - - for (int i = 0; i < rowCnt; i++) { - thread_t = (msg_struct_s *)new msg_struct_s; - pThreadViewList->msg_struct_info[i] = (msg_struct_t)thread_t; - - thread_t->type = MSG_STRUCT_THREAD_INFO; - thread_t->data = new MSG_THREAD_VIEW_S; - - pTmp = (MSG_THREAD_VIEW_S *)thread_t->data; - memset(pTmp, 0x00, sizeof(MSG_THREAD_VIEW_S)); - - pTmp->threadId = dbHandle.getColumnToInt(index++); + if (rowCnt <= 0) { +// dbHandle->freeTable(); + err = MSG_SUCCESS; + } - pTmp->unreadCnt = dbHandle.getColumnToInt(index++); - pTmp->smsCnt = dbHandle.getColumnToInt(index++); - pTmp->mmsCnt = dbHandle.getColumnToInt(index++); + pMsgIdList->nCount = rowCnt; - pTmp->mainType = dbHandle.getColumnToInt(index++); - pTmp->subType = dbHandle.getColumnToInt(index++); + MSG_DEBUG("pMsgIdList->nCount [%d]", pMsgIdList->nCount); - pTmp->direction = dbHandle.getColumnToInt(index++); - pTmp->threadTime = (time_t)dbHandle.getColumnToInt(index++); + pMsgIdList->msgIdList = (msg_message_id_t *)new char[sizeof(msg_message_id_t) * rowCnt]; - memset(pTmp->threadName, 0x00, sizeof(pTmp->threadName)); - dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, pTmp->threadName); + for (int i = 0; i < rowCnt; i++) + pMsgIdList->msgIdList[i] = dbHandle->getColumnToInt(index++); - memset(pTmp->threadData, 0x00, sizeof(pTmp->threadData)); - dbHandle.getColumnToString(index++, MAX_THREAD_DATA_LEN, pTmp->threadData); - } + dbHandle->freeTable(); + /*** **/ - dbHandle.freeTable(); + err = MsgStoDeleteMessageByList(pMsgIdList); - return MSG_SUCCESS; + return err; } -msg_error_t MsgStoGetConversationViewList(msg_thread_id_t threadId, msg_struct_list_s *pConvViewList) +msg_error_t MsgStoCountMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pThreadCountInfo) { - MSG_BEGIN(); - - pConvViewList->nCount = 0; - pConvViewList->msg_struct_info = NULL; - - int rowCnt = 0; - int index = 19; /** numbers of index */ - int order = 0; - char sqlQuery[MAX_QUERY_LEN+1]; - - // get address information. - order = MsgGetContactNameOrder(); - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, CONV_ID, FOLDER_ID, STORAGE_ID, MAIN_TYPE, SUB_TYPE, \ - DISPLAY_TIME, DATA_SIZE, NETWORK_STATUS, READ_STATUS, PROTECTED, BACKUP, PRIORITY, \ - MSG_DIRECTION, SCHEDULED_TIME, SUBJECT, MSG_TEXT, ATTACHMENT_COUNT, THUMB_PATH \ - FROM %s WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d ORDER BY DISPLAY_TIME, MSG_ID ASC;", - MSGFW_MESSAGE_TABLE_NAME, threadId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID); - - msg_error_t err = dbHandle.getTable(sqlQuery, &rowCnt); - - if (err == MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); - return MSG_SUCCESS; - } else if (err != MSG_SUCCESS) { - MSG_DEBUG("%s", sqlQuery); - dbHandle.freeTable(); - return err; - } - - pConvViewList->nCount = rowCnt; - - MSG_DEBUG("pConvViewList->nCount [%d]", pConvViewList->nCount); - - pConvViewList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t) * rowCnt]; - - msg_struct_s *msg = NULL; - MSG_MESSAGE_HIDDEN_S *pTmp = NULL; - - for (int i = 0; i < rowCnt; i++) { - pConvViewList->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];; - - msg = (msg_struct_s *)pConvViewList->msg_struct_info[i]; - - msg->type = MSG_STRUCT_MESSAGE_INFO; - msg->data = new char[sizeof(MSG_MESSAGE_HIDDEN_S)]; - - pTmp = (MSG_MESSAGE_HIDDEN_S *)msg->data; - - pTmp->pData = NULL; - pTmp->pMmsData = NULL; - - pTmp->msgId = dbHandle.getColumnToInt(index++); - pTmp->threadId = dbHandle.getColumnToInt(index++); - pTmp->folderId = dbHandle.getColumnToInt(index++); - pTmp->storageId = dbHandle.getColumnToInt(index++); - pTmp->mainType = dbHandle.getColumnToInt(index++); - pTmp->subType = dbHandle.getColumnToInt(index++); - pTmp->displayTime = (time_t)dbHandle.getColumnToInt(index++); - pTmp->dataSize = dbHandle.getColumnToInt(index++); - pTmp->networkStatus = dbHandle.getColumnToInt(index++); - pTmp->bRead = dbHandle.getColumnToInt(index++); - pTmp->bProtected = dbHandle.getColumnToInt(index++); - pTmp->bBackup = dbHandle.getColumnToInt(index++); - pTmp->priority = dbHandle.getColumnToInt(index++); - pTmp->direction = dbHandle.getColumnToInt(index++); - index++; // This field is reserved. - - dbHandle.getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject); - - if (pTmp->mainType == MSG_MMS_TYPE && - (pTmp->networkStatus == MSG_NETWORK_RETRIEVING || pTmp->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pTmp->subType == MSG_NOTIFICATIONIND_MMS)) { - pTmp->pData = NULL; - index++; - } else { - pTmp->pData = (void *)new char[pTmp->dataSize+2]; - memset(pTmp->pData, 0x00, pTmp->dataSize+2); - - dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData); - } - - pTmp->attachCount = dbHandle.getColumnToInt(index++); - - dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath); - - // set address list handle. - msg_struct_list_s *addrlist = (msg_struct_list_s *)new msg_struct_list_s; - memset(addrlist, 0x00, sizeof(msg_struct_list_s)); - MsgDbHandler dbHandleForInner; - MsgStoGetAddressByConvId(&dbHandleForInner, threadId, order, addrlist); - - pTmp->addr_list = addrlist; - - } - - dbHandle.freeTable(); - - MSG_END(); - - return MSG_SUCCESS; -} - - -msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t threadId, msg_id_list_s *pMsgIdList) -{ - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; - /*** Get msg id list **/ - msg_id_list_s *pToDeleteMsgIdList = NULL; - - int rowCnt = 0; - int index = 1; - // Set Indicator - int smsCnt = 0; - int mmsCnt = 0; - - const char *tableList[] = {MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME, - MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, - MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME}; - - int listCnt = sizeof(tableList)/sizeof(char *); - - pToDeleteMsgIdList = (msg_id_list_s *)new char[sizeof(msg_id_list_s)]; - memset(pToDeleteMsgIdList, 0x00, sizeof(msg_id_list_s)); - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE CONV_ID = %d", MSGFW_MESSAGE_TABLE_NAME, threadId); - - err = dbHandle.getTable(sqlQuery, &rowCnt); - - if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - dbHandle.freeTable(); - - goto FREE_MEMORY; - } - - if (rowCnt <= 0) { - dbHandle.freeTable(); - err = MSG_SUCCESS; - - goto FREE_MEMORY; - } - - pToDeleteMsgIdList->nCount = rowCnt; - - MSG_DEBUG("pToDeleteMsgIdList->nCount [%d]", pToDeleteMsgIdList->nCount); - - pToDeleteMsgIdList->msgIdList = (msg_message_id_t *)new char[sizeof(msg_message_id_t) * rowCnt]; - - for (int i = 0; i < rowCnt; i++) - pToDeleteMsgIdList->msgIdList[i] = dbHandle.getColumnToInt(index++); - - dbHandle.freeTable(); - /*** **/ - - /*** Delete Sim Message **/ - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE CONV_ID = %d AND STORAGE_ID = %d", - MSGFW_MESSAGE_TABLE_NAME, threadId, MSG_STORAGE_SIM); - - rowCnt = 0; - - err = dbHandle.getTable(sqlQuery, &rowCnt); - - if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - dbHandle.freeTable(); - - goto FREE_MEMORY; - } - - for (int i = 1; i <= rowCnt; i++) { - err = MsgStoDeleteMessage(dbHandle.getColumnToInt(i), false); - - if (err != MSG_SUCCESS) { - MSG_DEBUG("MsgStoDeleteMessage() Error!!!"); - - dbHandle.freeTable(); - - goto FREE_MEMORY; - } - } - - dbHandle.freeTable(); - /*** **/ - - dbHandle.beginTrans(); - - for (int i = 0; i < listCnt; i++) { - if (!strcmp(tableList[i], MMS_PLUGIN_MESSAGE_TABLE_NAME)) { - - int rowCnt = 0; - - //get mms msg id list - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s A, %s B\ - WHERE A.CONV_ID = %d AND A.MAIN_TYPE = %d AND A.MSG_ID = B.MSG_ID;", - MSGFW_MESSAGE_TABLE_NAME, MMS_PLUGIN_MESSAGE_TABLE_NAME, threadId, MSG_MMS_TYPE); - - err = dbHandle.getTable(sqlQuery, &rowCnt); - MSG_DEBUG("rowCnt %d", rowCnt); - - if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - dbHandle.freeTable(); - dbHandle.endTrans(false); - - goto FREE_MEMORY; - } - - for (int i = 1; i <= rowCnt; i++) { - - char filePath[MSG_FILEPATH_LEN_MAX] = {0,}; - char dirPath[MSG_FILEPATH_LEN_MAX] = {0,}; - char thumbnailPath[MSG_FILEPATH_LEN_MAX] = {0,}; - - dbHandle.getColumnToString(i, MSG_FILEPATH_LEN_MAX, filePath); - - MSG_DEBUG("filePath [%s]", filePath); - - //delete raw file - snprintf(dirPath, sizeof(dirPath), "%s.dir", filePath); - - if (remove(filePath) == -1) - MSG_DEBUG("Fail to delete file [%s]", filePath); - else - MSG_DEBUG("Success to delete file [%s]", filePath); - - MsgRmRf(dirPath); - - // remove directory also - rmdir(dirPath); - - // delete thumbnail - char *fileName = NULL; - fileName = strrchr(filePath, '/'); - - snprintf(thumbnailPath, sizeof(thumbnailPath), MSG_THUMBNAIL_PATH"%s.jpg", fileName+1); - - if (remove(thumbnailPath) == -1) - MSG_DEBUG("Fail to delete thumbnail [%s]", thumbnailPath); - else - MSG_DEBUG("Success to delete thumbnail [%s]", thumbnailPath); - } - - dbHandle.freeTable(); - } - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID IN \ - (SELECT MSG_ID FROM %s WHERE CONV_ID = %d);", - tableList[i], MSGFW_MESSAGE_TABLE_NAME, threadId); - - // Delete Message in specific folder from table - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - dbHandle.endTrans(false); - err = MSG_ERR_DB_EXEC; - - goto FREE_MEMORY; - } - } - - // Clear Conversation table - if (MsgStoClearConversationTable(&dbHandle) != MSG_SUCCESS) { - dbHandle.endTrans(false); - err = MSG_ERR_DB_EXEC; - - goto FREE_MEMORY; - } - - dbHandle.endTrans(true); - - MSG_MESSAGE_TYPE_S msgType; - - msgType.mainType = MSG_SMS_TYPE; - msgType.subType = MSG_NORMAL_SMS; - msgType.classType = MSG_CLASS_NONE; - - // Set memory status in SIM - if (MsgStoCheckMsgCntFull(&dbHandle, &msgType, MSG_INBOX_ID) == MSG_SUCCESS) { - MSG_DEBUG("Set Memory Status"); - - MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); - - if (plg == NULL) { - MSG_DEBUG("SMS Plug-in is NULL"); - err = MSG_ERR_NULL_POINTER; - - goto FREE_MEMORY; - } - - plg->setMemoryStatus(MSG_SUCCESS); - } - - // Set Indicator - smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE); - mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE); - - MsgSettingSetIndicator(smsCnt, mmsCnt); - -/*** Set pMsgIdList **/ - if (pMsgIdList != NULL && pToDeleteMsgIdList->nCount > 0) { - pMsgIdList->nCount = pToDeleteMsgIdList->nCount; - - pMsgIdList->msgIdList = (msg_message_id_t *)new char[sizeof(msg_message_id_t)*pToDeleteMsgIdList->nCount]; - memcpy(pMsgIdList->msgIdList, pToDeleteMsgIdList->msgIdList, sizeof(msg_message_id_t)*pToDeleteMsgIdList->nCount); - } -/*** **/ - - /*** Create thread for noti and phone log delete. **/ - 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)); - // memory free - if (pToDeleteMsgIdList != NULL) { - //free peer info list - if (pToDeleteMsgIdList->msgIdList != NULL) - delete [] pToDeleteMsgIdList->msgIdList; - - 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; - - delete [] pToDeleteMsgIdListCpy; - } - err = MSG_ERR_UNKNOWN; - } - } - /*** **/ - - return MSG_SUCCESS; - -FREE_MEMORY: - MSG_DEBUG("Error case Free Memory"); - // memory free - if (pToDeleteMsgIdList != NULL) { - //free peer info list - if (pToDeleteMsgIdList->msgIdList != NULL) { - delete [] pToDeleteMsgIdList->msgIdList; - pToDeleteMsgIdList->msgIdList = NULL; - } - - delete [] pToDeleteMsgIdList; - pToDeleteMsgIdList = NULL; - } - - return err; -} - - -msg_error_t MsgStoCountMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pThreadCountInfo) -{ - char sqlQuery[MAX_QUERY_LEN+1]; - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - if (pAddrInfo->contactId > 0) { - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) AS TOTAL, \ - SUM(CASE WHEN READ_STATUS=0 AND FOLDER_ID=%d THEN 1 ELSE 0 END), \ - SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END), \ - SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END) \ - FROM (SELECT * FROM %s A JOIN %s B ON A.ADDRESS_ID = B.ADDRESS_ID WHERE B.CONTACT_ID = %d)", - MSG_INBOX_ID, MSG_SMS_TYPE, MSG_MMS_TYPE, MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, pAddrInfo->contactId); - } else { - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) AS TOTAL, \ - SUM(CASE WHEN READ_STATUS=0 AND FOLDER_ID=%d THEN 1 ELSE 0 END), \ - SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END), \ - SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END) \ - FROM (SELECT * FROM %s A JOIN %s B ON A.ADDRESS_ID = B.ADDRESS_ID WHERE B.ADDRESS_VAL = '%s')", - MSG_INBOX_ID, MSG_SMS_TYPE, MSG_MMS_TYPE, MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, pAddrInfo->msgAddrInfo.addressVal); - } - - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) - return MSG_ERR_DB_PREPARE; - - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - pThreadCountInfo->totalCount = dbHandle.columnInt(0); - pThreadCountInfo->unReadCount = dbHandle.columnInt(1); - pThreadCountInfo->smsMsgCount = dbHandle.columnInt(2); - pThreadCountInfo->mmsMsgCount = dbHandle.columnInt(3); - } else { - dbHandle.finalizeQuery(); - return MSG_ERR_DB_STEP; - } - - dbHandle.finalizeQuery(); - - return MSG_SUCCESS; -} - - -msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList) -{ - if (!pSearchString) - return MSG_ERR_NULL_POINTER; - - // Clear Out Parameter - pThreadViewList->nCount = 0; - pThreadViewList->msg_struct_info = NULL; - - tr1::unordered_set IdList; - queue searchList; - - MSG_THREAD_VIEW_S threadView; - - char sqlQuery[MAX_QUERY_LEN+1]; - - // Replace string for '%' and '_' character - char *ext1_str = NULL; - char *ext2_str = NULL; - - ext1_str = MsgStoReplaceString(pSearchString, "_", "\\_"); - ext2_str = MsgStoReplaceString(ext1_str, "%", "\\%"); - - // 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); - - - if (ext1_str) { - free(ext1_str); - ext1_str = NULL; - } - - if (ext2_str) { - free(ext2_str); - ext2_str = NULL; - } - - MSG_DEBUG("[%s]", sqlQuery); - - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - MSG_DEBUG("Prepare query fail. [%s]", sqlQuery); - return MSG_ERR_DB_PREPARE; - } - - while (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - memset(&threadView, 0x00, sizeof(threadView)); - - threadView.threadId = dbHandle.columnInt(0); - threadView.unreadCnt = dbHandle.columnInt(1); - threadView.smsCnt = dbHandle.columnInt(2); - threadView.mmsCnt = dbHandle.columnInt(3); - - strncpy(threadView.threadName, (char *)dbHandle.columnText(4), MAX_THREAD_NAME_LEN); - - threadView.mainType = dbHandle.columnInt(5); - threadView.subType = dbHandle.columnInt(6); - - threadView.direction = dbHandle.columnInt(7); - threadView.threadTime = (time_t)dbHandle.columnInt(8); - - strncpy(threadView.threadData, (char *)dbHandle.columnText(9), MAX_THREAD_DATA_LEN); - - tr1::unordered_set::iterator it; - - it = IdList.find(threadView.threadId); - - if (it == IdList.end()) { - IdList.insert(threadView.threadId); - searchList.push(threadView); - } - - } - - dbHandle.finalizeQuery(); - - // Add data to Out Parameter - pThreadViewList->nCount = searchList.size(); - pThreadViewList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t) * searchList.size()]; - - MSG_THREAD_VIEW_S *pTmp = NULL; - msg_struct_s *thread_t = NULL; - - int index = 0; - - while (!searchList.empty()) { - thread_t = (msg_struct_s *)new msg_struct_s; - pThreadViewList->msg_struct_info[index] = (msg_struct_t)thread_t; - - thread_t->type = MSG_STRUCT_THREAD_INFO; - thread_t->data = new MSG_THREAD_VIEW_S; - - pTmp = (MSG_THREAD_VIEW_S *)thread_t->data; - memset(pTmp, 0x00, sizeof(MSG_THREAD_VIEW_S)); - - memcpy(pTmp, &(searchList.front()), sizeof(MSG_THREAD_VIEW_S)); - - searchList.pop(); - - index++; - } - - return MSG_SUCCESS; -} - - -msg_error_t MsgStoSearchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, msg_struct_list_s *pMsgList) -{ - // Clear Out Parameter - pMsgList->nCount = 0; - pMsgList->msg_struct_info = NULL; - - int rowCnt = 0; - int index = 26; // numbers of index - - char sqlQuery[MAX_QUERY_LEN+1]; - char sqlQuerySubset[(MAX_QUERY_LEN/5)+1]; - - char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1]; - char displayName[MAX_DISPLAY_NAME_LEN+1]; - - char *ext1_str = NULL; - char *ext2_str = NULL; - - // Get Name Order - int order = MsgGetContactNameOrder(); - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MSG_ID, A.CONV_ID, A.FOLDER_ID, A.STORAGE_ID, A.MAIN_TYPE, A.SUB_TYPE, \ - A.DISPLAY_TIME, A.DATA_SIZE, A.NETWORK_STATUS, A.READ_STATUS, A.PROTECTED, A.BACKUP, A.PRIORITY, \ - A.MSG_DIRECTION, A.SCHEDULED_TIME, A.SUBJECT, A.MSG_TEXT, B.ADDRESS_TYPE, B.RECIPIENT_TYPE, \ - B.CONTACT_ID, B.ADDRESS_VAL, B.DISPLAY_NAME, B.FIRST_NAME, B.LAST_NAME, A.ATTACHMENT_COUNT, A.THUMB_PATH \ - FROM %s A, %s B \ - WHERE A.CONV_ID = B.CONV_ID AND B.ADDRESS_ID <> 0 ", - MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME); - - //// folder - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); - - if (pSearchCon->folderId == MSG_ALLBOX_ID) - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.FOLDER_ID > 0 AND A.FOLDER_ID < %d ", MSG_CBMSGBOX_ID); - else if (pSearchCon->folderId == MSG_IOSBOX_ID) - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.FOLDER_ID > 0 AND A.FOLDER_ID < %d ", MSG_DRAFT_ID); - else - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.FOLDER_ID = %d ", pSearchCon->folderId); - - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); - - - //// msg type - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); - - switch (pSearchCon->msgType) { - case MSG_TYPE_SMS: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d AND A.SUB_TYPE = %d ", MSG_SMS_TYPE, MSG_NORMAL_SMS); - break; - - case MSG_TYPE_MMS: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d ", MSG_MMS_TYPE); - break; - - case MSG_TYPE_MMS_JAVA: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d AND A.SUB_TYPE = %d ", MSG_MMS_TYPE, MSG_SENDREQ_JAVA_MMS); - break; - - case MSG_TYPE_SMS_SYNCML: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d AND A.SUB_TYPE = %d ", MSG_SMS_TYPE, MSG_SYNCML_CP); - break; - - case MSG_TYPE_SMS_REJECT: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND A.MAIN_TYPE = %d AND A.SUB_TYPE = %d ", MSG_SMS_TYPE, MSG_REJECT_SMS); - break; - - default: - MSG_DEBUG("msg type is not set."); - break; - } - - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); - - /// string - if (pSearchCon->pSearchVal != NULL) { - - // Replace string for '%' and '_' character - ext1_str = MsgStoReplaceString(pSearchCon->pSearchVal, "_", "\\_"); - ext2_str = MsgStoReplaceString(ext1_str, "%", "\\%"); - - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND ( A.MSG_TEXT LIKE '%%%s%%' ESCAPE '\\' \ - OR A.SUBJECT LIKE '%%%s%%' ESCAPE '\\' \ - OR B.ADDRESS_VAL LIKE '%%%s%%' ESCAPE '\\' \ - OR B.DISPLAY_NAME LIKE '%%%s%%' ESCAPE '\\' \ - OR B.FIRST_NAME LIKE '%%%s%%' ESCAPE '\\' \ - OR B.LAST_NAME LIKE '%%%s%%' ESCAPE '\\') ", - ext2_str, ext2_str, ext2_str, ext2_str, ext2_str, ext2_str); - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); - - if (ext1_str) { - free(ext1_str); - ext1_str = NULL; - } - - if (ext2_str) { - free(ext2_str); - ext2_str = NULL; - } - } - - /// address - if (pSearchCon->pAddressVal != NULL) { - - // Replace string for '%' and '_' character - ext1_str = MsgStoReplaceString(pSearchCon->pAddressVal, "_", "\\_"); - ext2_str = MsgStoReplaceString(ext1_str, "%", "\\%"); - - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND B.ADDRESS_VAL LIKE '%%%s%%' ESCAPE '\\' ", ext2_str); - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); - - if (ext1_str) { - free(ext1_str); - ext1_str = NULL; - } - - if (ext2_str) { - free(ext2_str); - ext2_str = NULL; - } - } - - /// limit, offset - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); - - if (offset >= 0 && limit > 0) - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "ORDER BY A.DISPLAY_TIME DESC LIMIT %d OFFSET %d;", limit, offset); - else - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "ORDER BY A.DISPLAY_TIME DESC;"); - - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); - - msg_error_t err = dbHandle.getTable(sqlQuery, &rowCnt); - - if (err == MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); - - return MSG_SUCCESS; - } else if (err != MSG_SUCCESS) { - MSG_DEBUG("Get table fail. [%s]", sqlQuery); - - dbHandle.freeTable(); - - return err; - } - - pMsgList->nCount = rowCnt; - - MSG_DEBUG("pMsgList->nCount [%d]", pMsgList->nCount); - - pMsgList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t) * rowCnt]; - - MSG_MESSAGE_HIDDEN_S *pTmp = NULL; - msg_struct_s *msg = NULL; - - for (int i = 0; i < rowCnt; i++) { - pMsgList->msg_struct_info[i] = (msg_struct_t)new msg_struct_s; - - msg = (msg_struct_s *)pMsgList->msg_struct_info[i]; - - msg->type = MSG_STRUCT_MESSAGE_INFO; - msg->data = (int *)new char[sizeof(MSG_MESSAGE_HIDDEN_S)]; - - pTmp = (MSG_MESSAGE_HIDDEN_S *)msg->data; - - memset(pTmp, 0x00, sizeof(MSG_MESSAGE_HIDDEN_S)); - - pTmp->pData = NULL; - pTmp->pMmsData = NULL; - - pTmp->msgId = dbHandle.getColumnToInt(index++); - pTmp->threadId = dbHandle.getColumnToInt(index++); - pTmp->folderId = dbHandle.getColumnToInt(index++); - pTmp->storageId = dbHandle.getColumnToInt(index++); - pTmp->mainType = dbHandle.getColumnToInt(index++); - pTmp->subType = dbHandle.getColumnToInt(index++); - pTmp->displayTime = (time_t)dbHandle.getColumnToInt(index++); - pTmp->dataSize = dbHandle.getColumnToInt(index++); - pTmp->networkStatus = dbHandle.getColumnToInt(index++); - pTmp->bRead = dbHandle.getColumnToInt(index++); - pTmp->bProtected = dbHandle.getColumnToInt(index++); - pTmp->bBackup = dbHandle.getColumnToInt(index++); - pTmp->priority = dbHandle.getColumnToInt(index++); - pTmp->direction= dbHandle.getColumnToInt(index++); - index++; // This field is reserved. - - dbHandle.getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject); - - if (pTmp->mainType == MSG_MMS_TYPE && - (pTmp->networkStatus == MSG_NETWORK_RETRIEVING || pTmp->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pTmp->subType == MSG_NOTIFICATIONIND_MMS)) { - pTmp->pData = NULL; - index++; - } else { - MSG_DEBUG("pTmp->dataSize [%d]", pTmp->dataSize); - pTmp->pData = (void *)new char[pTmp->dataSize + 2]; - memset(pTmp->pData, 0x00, sizeof(pTmp->pData)); - - dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData); - } - - msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s; - msg_struct_s *addr_info = NULL; - MSG_ADDRESS_INFO_S *address = NULL; - - addr_list->nCount = 1; - addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t *)*MAX_TO_ADDRESS_CNT]; - - msg_struct_s *pTmpAddr = NULL; - - for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) { - addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)]; - pTmpAddr = (msg_struct_s *)addr_list->msg_struct_info[i]; - pTmpAddr->type = MSG_STRUCT_ADDRESS_INFO; - pTmpAddr->data = new MSG_ADDRESS_INFO_S; - memset(pTmpAddr->data, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - - addr_list->msg_struct_info[i] = (msg_struct_t)pTmpAddr; - } - - addr_info = (msg_struct_s *)addr_list->msg_struct_info[0]; - address = (MSG_ADDRESS_INFO_S *)addr_info->data; - address->addressType = dbHandle.getColumnToInt(index++); - address->recipientType = dbHandle.getColumnToInt(index++); - address->contactId = dbHandle.getColumnToInt(index++); + MsgDbHandler *dbHandle = getDbHandle(); + char sqlQuery[MAX_QUERY_LEN+1]; - dbHandle.getColumnToString(index++, MAX_ADDRESS_VAL_LEN, address->addressVal); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - memset(displayName, 0x00, sizeof(displayName)); - dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, displayName); + if (pAddrInfo->contactId > 0) { + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) AS TOTAL, \ + SUM(CASE WHEN READ_STATUS=0 AND FOLDER_ID=%d THEN 1 ELSE 0 END), \ + SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END), \ + SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END) \ + FROM (SELECT * FROM %s A JOIN %s B ON A.CONV_ID = B.CONV_ID WHERE B.CONTACT_ID = %d)", + MSG_INBOX_ID, MSG_SMS_TYPE, MSG_MMS_TYPE, MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, pAddrInfo->contactId); + } else { + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) AS TOTAL, \ + SUM(CASE WHEN READ_STATUS=0 AND FOLDER_ID=%d THEN 1 ELSE 0 END), \ + SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END), \ + SUM(CASE WHEN MAIN_TYPE=%d THEN 1 ELSE 0 END) \ + FROM (SELECT * FROM %s A JOIN %s B ON A.CONV_ID = B.CONV_ID WHERE B.ADDRESS_VAL = '%s')", + MSG_INBOX_ID, MSG_SMS_TYPE, MSG_MMS_TYPE, MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, pAddrInfo->msgAddrInfo.addressVal); + } - memset(firstName, 0x00, sizeof(firstName)); - dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, firstName); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; - memset(lastName, 0x00, sizeof(lastName)); - dbHandle.getColumnToString(index++, MAX_DISPLAY_NAME_LEN, lastName); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + pThreadCountInfo->totalCount = dbHandle->columnInt(0); + pThreadCountInfo->unReadCount = dbHandle->columnInt(1); + pThreadCountInfo->smsMsgCount = dbHandle->columnInt(2); + pThreadCountInfo->mmsMsgCount = dbHandle->columnInt(3); + } else { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_STEP; + } - if (strlen(displayName) <= 0) { - if (order == 0) { - if (firstName[0] != '\0') { - strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN); - } + dbHandle->finalizeQuery(); - 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)); - } + return MSG_SUCCESS; +} - if (firstName[0] != '\0') { - strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName)); - } - } - } - strncpy(address->displayName, displayName, MAX_DISPLAY_NAME_LEN); +msg_error_t MsgStoGetSyncMLExtId(msg_message_id_t msgId, int *extId) +{ + MsgDbHandler *dbHandle = getDbHandle(); + char sqlQuery[MAX_QUERY_LEN+1]; - pTmp->addr_list = addr_list; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - pTmp->attachCount = dbHandle.getColumnToInt(index++); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT EXT_ID FROM %s WHERE MSG_ID = %d;", + MSGFW_SYNCML_MSG_TABLE_NAME, msgId); - dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + *extId = dbHandle->columnInt(0); + } else { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_STEP; } - dbHandle.freeTable(); - - return MSG_SUCCESS; -} - - -void MsgConvertNumber(const char *pSrcNum, char *pDestNum) -{ - int overLen = 0; - int i = 0; - - overLen = strlen(pSrcNum) - MAX_PRECONFIG_NUM; - for (i = 0; i < MAX_PRECONFIG_NUM; i++) - pDestNum[i] = pSrcNum[i+overLen]; + dbHandle->finalizeQuery(); - pDestNum[i] = '\0'; + return MSG_SUCCESS; } -msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList) +msg_error_t MsgStoGetSmsReportStatus(msg_message_id_t msgId, int *count, MSG_REPORT_STATUS_INFO_S **pReportStatus) { - // Clear Out Parameter - pRejectMsgList->nCount = 0; - pRejectMsgList->msg_struct_info = NULL; - - int rowCnt = 0; - int index = 3; // numbers of index - + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; + msg_error_t err = MSG_SUCCESS; - // Search Reject Msg memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT ADDRESS_VAL, STATUS_TYPE, STATUS, TIME " + "FROM %s " + "WHERE MSG_ID = %d " + "order by TIME ASC;" + , MSGFW_SMS_REPORT_TABLE_NAME, msgId); - if (pNumber != NULL) { - char phoneNumber[MAX_PRECONFIG_NUM+1]; - memset(phoneNumber, 0x00, sizeof(phoneNumber)); - - if (strlen(pNumber) > MAX_PRECONFIG_NUM) - MsgConvertNumber(pNumber, phoneNumber); - else - strncpy(phoneNumber, pNumber, MAX_PRECONFIG_NUM); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT B.MSG_ID, B.MSG_TEXT, B.DISPLAY_TIME \ - FROM %s A, %s B \ - WHERE A.CONV_ID = B.CONV_ID AND B.MAIN_TYPE = %d \ - AND B.SUB_TYPE = %d AND A.ADDRESS_VAL LIKE '%%%s' \ - ORDER BY B.DISPLAY_TIME DESC;", - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSG_SMS_TYPE, MSG_REJECT_SMS, phoneNumber); - } else { - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT B.MSG_ID, B.MSG_TEXT, B.DISPLAY_TIME \ - FROM %s A, %s B \ - WHERE A.CONV_ID = B.CONV_ID AND B.MAIN_TYPE = %d AND B.SUB_TYPE = %d \ - ORDER BY B.DISPLAY_TIME DESC;", - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSG_SMS_TYPE, MSG_REJECT_SMS); - } - - msg_error_t err = dbHandle.getTable(sqlQuery, &rowCnt); + int rowCnt = 0, index = 0; + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS) { - MSG_DEBUG("%s", sqlQuery); - - dbHandle.freeTable(); - + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); return err; } - pRejectMsgList->nCount = rowCnt; - - MSG_DEBUG("pRejectMsgList->nCount [%d]", pRejectMsgList->nCount); - - pRejectMsgList->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_REJECT_MSG_INFO_S *)*rowCnt]; - - msg_struct_s* pTmp = NULL; + *count = rowCnt; + MSG_REPORT_STATUS_INFO_S *report_status = (MSG_REPORT_STATUS_INFO_S*)new char[sizeof(MSG_REPORT_STATUS_INFO_S)*rowCnt]; + memset(report_status, 0x00, sizeof(MSG_REPORT_STATUS_INFO_S)*rowCnt); for (int i = 0; i < rowCnt; i++) { - pRejectMsgList->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)]; + dbHandle->getColumnToString(index++, MAX_ADDRESS_VAL_LEN, report_status[i].addressVal); + report_status[i].type = dbHandle->getColumnToInt(index++); + report_status[i].status = dbHandle->getColumnToInt(index++); + report_status[i].statusTime = (time_t)dbHandle->getColumnToInt(index++); - pTmp = (msg_struct_s *)pRejectMsgList->msg_struct_info[i]; - pTmp->type = MSG_STRUCT_REJECT_MSG_INFO; - pTmp->data = new char[sizeof(MSG_FOLDER_INFO_S)]; - MSG_REJECT_MSG_INFO_S * pMsg = (MSG_REJECT_MSG_INFO_S *)pTmp->data; - memset(pMsg, 0x00, sizeof(MSG_REJECT_MSG_INFO_S)); - - pMsg->msgId = dbHandle.getColumnToInt(index++); - memset(pMsg->msgText, 0x00, sizeof(pMsg->msgText)); - dbHandle.getColumnToString(index++, MAX_MSG_TEXT_LEN, pMsg->msgText); - - pMsg->displayTime = (time_t)dbHandle.getColumnToInt(index++); + MSG_SEC_DEBUG("(%d/%d) address = %s, report_type = %d, report_status = %d, report_time = %d", i+1, rowCnt, report_status[i].addressVal, report_status[i].type, report_status[i].status, report_status[i].statusTime); } - dbHandle.freeTable(); + *pReportStatus = report_status; + + dbHandle->freeTable(); return MSG_SUCCESS; } - -msg_error_t MsgStoGetSyncMLExtId(msg_message_id_t msgId, int *extId) +msg_error_t MsgStoGetMmsReportStatus(msg_message_id_t msgId, int *count, MSG_REPORT_STATUS_INFO_S **pReportStatus) { + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + msg_direction_type_t direction = MSG_DIRECTION_TYPE_MO; - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT EXT_ID FROM %s WHERE MSG_ID = %d;", - MSGFW_SYNCML_MSG_TABLE_NAME, msgId); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_DIRECTION FROM %s WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - *extId = dbHandle.columnInt(0); - } else { - dbHandle.finalizeQuery(); - return MSG_ERR_DB_STEP; + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + direction = dbHandle->columnInt(0); } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); - return MSG_SUCCESS; -} + if (direction == MSG_DIRECTION_TYPE_MO) {//get received report list of MO message + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + //MSG_ID INTEGER , ADDRESS_VAL TEXT , STATUS_TYPE INTEGER , STATUS INTEGER DEFAULT 0 , TIME DATETIME) + //select * from MSG_REPORT_TABLE where MSG_ID=38 order by ADDRESS_VAL DESC, STATUS_TYPE ASC; + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT ADDRESS_VAL, STATUS_TYPE, STATUS, TIME " + "FROM %s " + "WHERE MSG_ID = %d " + "order by ADDRESS_VAL DESC, STATUS_TYPE ASC;" + , MSGFW_REPORT_TABLE_NAME, msgId); + + int rowCnt = 0, index = 0; + msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt, &index); + if (err != MSG_SUCCESS) { + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); + return err; + } -msg_error_t MsgStoGetReportStatus(msg_message_id_t msgId, MSG_REPORT_STATUS_INFO_S *pReportStatus) -{ - char sqlQuery[MAX_QUERY_LEN+1]; + *count = rowCnt; + MSG_REPORT_STATUS_INFO_S *report_status = (MSG_REPORT_STATUS_INFO_S*)new char[sizeof(MSG_REPORT_STATUS_INFO_S)*rowCnt]; + memset(report_status, 0x00, sizeof(MSG_REPORT_STATUS_INFO_S)*rowCnt); - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + for (int i = 0; i < rowCnt; i++) { + dbHandle->getColumnToString(index++, MAX_ADDRESS_VAL_LEN, report_status[i].addressVal); + report_status[i].type = dbHandle->getColumnToInt(index++); + report_status[i].status = dbHandle->getColumnToInt(index++); + report_status[i].statusTime = (time_t)dbHandle->getColumnToInt(index++); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DELIVERY_REPORT_STATUS, \ - DELIVERY_REPORT_TIME, READ_REPORT_STATUS, READ_REPORT_TIME \ - FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); + MSG_DEBUG("(%d/%d) addr = %s, report_type = %d, report_status = %d, report_time = %d", i+1, rowCnt, report_status[i].addressVal, report_status[i].type, report_status[i].status, report_status[i].statusTime ); + } - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) - return MSG_ERR_DB_PREPARE; + *pReportStatus = report_status; + + dbHandle->freeTable(); + + } else if (direction == MSG_DIRECTION_TYPE_MT) {//read report sent status of MT message + + int readReportSentStatus; + + if (MsgStoCheckReadReportRequested(dbHandle, msgId) == false) { + *count = 0; + *pReportStatus = NULL; + return MSG_ERR_READREPORT_NOT_REQUESTED; + } + + MsgStoGetReadReportSendStatus(msgId, &readReportSentStatus); + + *count = 1; + + MSG_REPORT_STATUS_INFO_S *report_status = (MSG_REPORT_STATUS_INFO_S*)new char[sizeof(MSG_REPORT_STATUS_INFO_S)]; + memset(report_status, 0x00, sizeof(MSG_REPORT_STATUS_INFO_S)); + + report_status->addressVal[0] = '\0'; + report_status->type = MSG_REPORT_TYPE_READ_REPORT_SENT; + report_status->status = readReportSentStatus; + report_status->statusTime = 0; + + MSG_DEBUG("report_type = %d, report_status = %d", report_status->type, report_status->status); + + *pReportStatus = report_status; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - pReportStatus->deliveryStatus = (msg_delivery_report_status_t)dbHandle.columnInt(0); - pReportStatus->deliveryStatusTime = (time_t)dbHandle.columnInt(1); - pReportStatus->readStatus = (msg_read_report_status_t)dbHandle.columnInt(2); - pReportStatus->readStatusTime = (time_t)dbHandle.columnInt(3); - } - dbHandle.finalizeQuery(); + } return MSG_SUCCESS; } @@ -2965,16 +2597,23 @@ msg_error_t MsgStoGetReportStatus(msg_message_id_t msgId, MSG_REPORT_STATUS_INFO msg_error_t MsgStoGetThreadIdByAddress(const MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t *pThreadId) { + MsgDbHandler *dbHandle = getDbHandle(); if(pMsg->nAddressCnt > 0) { - if (MsgExistAddress(&dbHandle, pMsg, pThreadId) == true) { + if (MsgExistAddress(dbHandle, pMsg, pThreadId) == true) { MSG_DEBUG("Conversation ID : [%d]", *pThreadId); - } else { - *pThreadId = 0; - return MSG_ERR_STORAGE_ERROR; + + // check thread count + MSG_THREAD_VIEW_S threadInfo; + memset(&threadInfo, 0x00, sizeof(MSG_THREAD_VIEW_S)); + MsgStoGetThreadInfo(*pThreadId, &threadInfo); + MSG_DEBUG("threadInfo.smsCnt [%d], threadInfo.mmsCnt [%d]", threadInfo.smsCnt, threadInfo.mmsCnt); + if ((threadInfo.smsCnt + threadInfo.mmsCnt) > 0) { + return MSG_SUCCESS; + } } - } else { - *pThreadId = 0; } + + *pThreadId = 0; return MSG_SUCCESS; } @@ -2983,26 +2622,25 @@ msg_error_t MsgStoGetThreadUnreadCnt(msg_thread_id_t threadId, int *cnt) { MSG_BEGIN(); + MsgDbHandler *dbHandle = getDbHandle(); int msgCnt = 0; *cnt = 0; char sqlQuery[MAX_QUERY_LEN+1]; - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - // Get MSG_ID memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(MSG_ID) FROM %s A \ WHERE CONV_ID = %d AND READ_STATUS = 0;", MSGFW_MESSAGE_TABLE_NAME, threadId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - msgCnt = dbHandle.columnInt(0); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + msgCnt = dbHandle->columnInt(0); } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); *cnt = msgCnt; @@ -3012,69 +2650,85 @@ 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 err = MSG_SUCCESS; - - int order = MsgGetContactNameOrder(); - - err = MsgStoGetAddressByConvId(&dbHandle, threadId, order, pAddrList); - - return err; -} - - msg_error_t MsgStoGetThreadInfo(msg_thread_id_t threadId, MSG_THREAD_VIEW_S *pThreadInfo) { MSG_BEGIN(); - int rowCnt; - int index = 10; // numbers of index + MsgDbHandler *dbHandle = getDbHandle(); + int rowCnt = 0, index = 0; char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONV_ID, UNREAD_CNT, SMS_CNT, MMS_CNT, \ - MAIN_TYPE, SUB_TYPE, MSG_DIRECTION, DISPLAY_TIME, DISPLAY_NAME, MSG_TEXT \ - FROM %s WHERE CONV_ID = %d;", + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.CONV_ID, A.UNREAD_CNT, A.SMS_CNT, A.MMS_CNT, " + "A.MAIN_TYPE, A.SUB_TYPE, A.MSG_DIRECTION, A.DISPLAY_TIME, A.DISPLAY_NAME, A.MSG_TEXT, " + "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.PROTECTED = 1) AS PROTECTED, " + "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.FOLDER_ID = %d) AS DRAFT, " + "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.NETWORK_STATUS = %d) AS FAILED, " + "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.NETWORK_STATUS = %d) AS SENDING, " + "(SELECT SIM_INDEX FROM %s B WHERE B.CONV_ID = A.CONV_ID) " + "FROM %s A WHERE A.CONV_ID = %d AND A.SMS_CNT + A.MMS_CNT > 0;", + MSGFW_MESSAGE_TABLE_NAME, + MSGFW_MESSAGE_TABLE_NAME, MSG_DRAFT_ID, + MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_FAIL, + MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SENDING, + MSGFW_MESSAGE_TABLE_NAME, MSGFW_CONVERSATION_TABLE_NAME, threadId); - msg_error_t err = dbHandle.getTable(sqlQuery, &rowCnt); + msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err == MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); + dbHandle->freeTable(); return MSG_SUCCESS; } else if (err != MSG_SUCCESS) { - MSG_DEBUG("%s", sqlQuery); - dbHandle.freeTable(); + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); return err; } if (rowCnt < 1) { MSG_DEBUG("rowCnt is %d", rowCnt); - dbHandle.freeTable(); + dbHandle->freeTable(); return err; } else { - pThreadInfo->threadId = dbHandle.getColumnToInt(index++); + pThreadInfo->threadId = dbHandle->getColumnToInt(index++); - pThreadInfo->unreadCnt = dbHandle.getColumnToInt(index++); - pThreadInfo->smsCnt = dbHandle.getColumnToInt(index++); - pThreadInfo->mmsCnt = dbHandle.getColumnToInt(index++); + pThreadInfo->unreadCnt = dbHandle->getColumnToInt(index++); + pThreadInfo->smsCnt = dbHandle->getColumnToInt(index++); + pThreadInfo->mmsCnt = dbHandle->getColumnToInt(index++); - pThreadInfo->mainType = dbHandle.getColumnToInt(index++); - pThreadInfo->subType = dbHandle.getColumnToInt(index++); + pThreadInfo->mainType = dbHandle->getColumnToInt(index++); + pThreadInfo->subType = dbHandle->getColumnToInt(index++); - pThreadInfo->direction = dbHandle.getColumnToInt(index++); - pThreadInfo->threadTime = (time_t)dbHandle.getColumnToInt(index++); + pThreadInfo->direction = dbHandle->getColumnToInt(index++); + pThreadInfo->threadTime = (time_t)dbHandle->getColumnToInt(index++); memset(pThreadInfo->threadName, 0x00, sizeof(pThreadInfo->threadName)); - dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, pThreadInfo->threadName); + dbHandle->getColumnToString(index++, MAX_THREAD_NAME_LEN, pThreadInfo->threadName); memset(pThreadInfo->threadData, 0x00, sizeof(pThreadInfo->threadData)); - dbHandle.getColumnToString(index++, MAX_THREAD_DATA_LEN, pThreadInfo->threadData); + dbHandle->getColumnToString(index++, MAX_THREAD_DATA_LEN, pThreadInfo->threadData); + + int protectedCnt = dbHandle->getColumnToInt(index++); + if (protectedCnt > 0) + pThreadInfo->bProtected = true; + + int draftCnt = dbHandle->getColumnToInt(index++); + if (draftCnt > 0) + pThreadInfo->bDraft = true; + + int failedCnt = dbHandle->getColumnToInt(index++); + if (failedCnt > 0) + pThreadInfo->bSendFailed = true; + + int sendingCnt = dbHandle->getColumnToInt(index++); + if (sendingCnt > 0) + pThreadInfo->bSending = true; + + pThreadInfo->simIndex = dbHandle->getColumnToInt(index++); } - dbHandle.freeTable(); + dbHandle->freeTable(); MSG_END(); @@ -3082,176 +2736,366 @@ msg_error_t MsgStoGetThreadInfo(msg_thread_id_t threadId, MSG_THREAD_VIEW_S *pTh } -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) +msg_error_t MsgStoRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo) { - // Clear Out Parameter - pMsgList->nCount = 0; - pMsgList->msg_struct_info = NULL; - - int rowCnt = 0; - int index = 19; // numbers of index + MSG_BEGIN(); + MsgDbHandler *dbHandle = getDbHandle(); + msg_error_t err = MSG_SUCCESS; char sqlQuery[MAX_QUERY_LEN+1]; - char sqlQuerySubset[(MAX_QUERY_LEN/5)+1]; - // Get Name Order - int order = MsgGetContactNameOrder(); + if(MsgExistConversation(dbHandle, pMsg->threadId)) + { + // add message to address table which having same thread_id and datetime; + for (int i=0; inAddressCnt; i++) { + if(MsgExistAddress(dbHandle, pMsg, pMsg->threadId, i) == false) + { + unsigned int addrId; + MSG_CONTACT_INFO_S contactInfo; + memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + // Get Contact Info +// if (MsgGetContactInfo(&(pMsg->addressList[i]), &contactInfo) != MSG_SUCCESS) { +// MSG_DEBUG("MsgGetContactInfo() fail."); +// } + err = dbHandle->getRowId(MSGFW_ADDRESS_TABLE_NAME, &addrId); + if (err != MSG_SUCCESS) { + MSG_DEBUG("pDbHandle->getRowId fail. [%d]", err); + return err; + } - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + // Add Address + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, '%s', %d, %d, ?, ?, ?, ?, ?, '%s', 0);", + MSGFW_ADDRESS_TABLE_NAME, addrId, pMsg->threadId, pMsg->addressList[i].addressType, pMsg->addressList[i].recipientType, pMsg->addressList[i].addressVal, + contactInfo.contactId, contactInfo.addrbookId, contactInfo.imagePath); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, CONV_ID, FOLDER_ID, STORAGE_ID, MAIN_TYPE, SUB_TYPE, \ - DISPLAY_TIME, DATA_SIZE, NETWORK_STATUS, READ_STATUS, PROTECTED, BACKUP, PRIORITY, \ - MSG_DIRECTION, SCHEDULED_TIME, SUBJECT, MSG_TEXT, ATTACHMENT_COUNT, THUMB_PATH \ - FROM %s WHERE ", MSGFW_MESSAGE_TABLE_NAME); + MSG_SEC_DEBUG("Add Address Info. [%s]", sqlQuery); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; - //// folder - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); + dbHandle->bindText(contactInfo.firstName, 1); + dbHandle->bindText(contactInfo.lastName, 2); + dbHandle->bindText(contactInfo.middleName, 3); + dbHandle->bindText(contactInfo.prefix, 4); + dbHandle->bindText(contactInfo.suffix, 5); - if (folderId == MSG_ALLBOX_ID) - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "FOLDER_ID > 0 AND FOLDER_ID < %d ", MSG_CBMSGBOX_ID); - else if (folderId == MSG_IOSBOX_ID) - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "FOLDER_ID > 0 AND FOLDER_ID < %d ", MSG_DRAFT_ID); - else - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "FOLDER_ID = %d ", folderId); + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + + dbHandle->finalizeQuery(); - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); + // set conversation display name by conv id + MsgStoSetConversationDisplayName(dbHandle, pMsg->threadId); + } + } - //// thread - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); + if(!MsgExistMessage(dbHandle, pMsg)) + { + unsigned int rowId = 0; - if (threadId > 0) - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND CONV_ID = %d ", threadId); + if(pMsg->threadId > 0 && pMsg->folderId == MSG_DRAFT_ID) { + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "DELETE FROM %s WHERE CONV_ID = %d AND FOLDER_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, pMsg->threadId, MSG_DRAFT_ID); + MSG_DEBUG("sqlQuery [%s]", sqlQuery); - //// msg type - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); + err = dbHandle->execQuery(sqlQuery); - switch (msgType) { - case MSG_TYPE_SMS: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND MAIN_TYPE = %d AND SUB_TYPE = %d ", MSG_SMS_TYPE, MSG_NORMAL_SMS); - break; + if (err != MSG_SUCCESS) { + MSG_DEBUG("fail to delete draft messages."); + } + } - case MSG_TYPE_MMS: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND MAIN_TYPE = %d ", MSG_MMS_TYPE); - break; + err = dbHandle->getRowId(MSGFW_MESSAGE_TABLE_NAME, &rowId); - case MSG_TYPE_MMS_JAVA: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND MAIN_TYPE = %d AND SUB_TYPE = %d ", MSG_MMS_TYPE, MSG_SENDREQ_JAVA_MMS); - break; + pMsg->msgId = (msg_message_id_t)rowId; - case MSG_TYPE_SMS_SYNCML: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND MAIN_TYPE = %d AND SUB_TYPE = %d ", MSG_SMS_TYPE, MSG_SYNCML_CP); - break; + int fileSize = 0; - case MSG_TYPE_SMS_REJECT: - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND MAIN_TYPE = %d AND SUB_TYPE = %d ", MSG_SMS_TYPE, MSG_REJECT_SMS); - break; + char *pFileData = NULL; + unique_ptr buf(&pFileData, unique_ptr_deleter); - default: - MSG_DEBUG("msg type is not set."); - } + // Get File Data + if (pMsg->bTextSms == false) { + if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) { + return MSG_ERR_STORAGE_ERROR; + } + MSG_DEBUG("file size [%d]", fileSize); + } - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); + char keyName[MAX_VCONFKEY_NAME_LEN]; + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_IMSI, pMsg->sim_idx); - //// storage - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); + char *imsi = MsgSettingGetString(keyName); - if (storageId > MSG_STORAGE_UNKNOWN) - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "AND STORAGE_ID = %d ", storageId); + // Add Message + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d, %d, %ld, %d, %d, %d, %d, %d, %d, 0, %d, ?, '', '', ?, 0, %d, '%s');", + MSGFW_MESSAGE_TABLE_NAME, rowId, pMsg->threadId, pMsg->folderId, pMsg->storageId, pMsg->msgType.mainType, pMsg->msgType.subType, + pMsg->displayTime, pMsg->dataSize, pMsg->networkStatus, pMsg->bRead, pMsg->bProtected, pMsg->priority, pMsg->direction, + pMsg->bBackup, pMsg->sim_idx, imsi); - /// order - memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset)); - snprintf(sqlQuerySubset, sizeof(sqlQuerySubset), "ORDER BY DISPLAY_TIME DESC;"); + MSG_DEBUG("QUERY : %s", sqlQuery); - strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); + if (imsi) { + free(imsi); + imsi = NULL; + } - msg_error_t err = dbHandle.getTable(sqlQuery, &rowCnt); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_EXEC; + } - if (err == MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); + dbHandle->bindText(pMsg->subject, 1); - return MSG_SUCCESS; - } else if (err != MSG_SUCCESS) { - MSG_DEBUG("Get table fail. [%s]", sqlQuery); + if (pMsg->bTextSms == false) + dbHandle->bindText(pFileData, 2); + else + dbHandle->bindText(pMsg->msgText, 2); - dbHandle.freeTable(); + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_EXEC; + } - return err; + dbHandle->finalizeQuery(); + + if (pMsg->msgType.subType != MSG_SENDREQ_MMS) { + err = MsgStoUpdateConversation(dbHandle, pMsg->threadId); + + if (err != MSG_SUCCESS) { + return err; + } + } + + /* In the case of MMS Message, load the MMS plugin to save MMS PDU */ + if (pMsg->msgType.mainType == MSG_MMS_TYPE) { + if (pMsg->msgType.subType != MSG_DELIVERYIND_MMS && pMsg->msgType.subType != MSG_READORGIND_MMS) { + MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_MMS_TYPE); + if (plg == NULL) + return MSG_ERR_NULL_POINTER; + + err = plg->addMessage(pMsg, pSendOptInfo, pFileData); + + if (err != MSG_SUCCESS) + return MSG_ERR_STORAGE_ERROR; + + if (pMsg->msgType.subType == MSG_SENDREQ_MMS) { + MSG_SEC_DEBUG("pMsg->msgText: %s, pMsg->thumbPath: %s ", pMsg->msgText, pMsg->thumbPath); + + err = MsgStoUpdateMMSMessage(pMsg); + + if (err != MSG_SUCCESS) + return MSG_ERR_STORAGE_ERROR; + + } + } + } + + } + } + else + { + // add message to conversation, message, address table; + pMsg->msgId = 0; + err = MsgStoAddMessage(pMsg, pSendOptInfo); } - pMsgList->nCount = rowCnt; + MSG_END(); - MSG_DEBUG("pMsgList->nCount [%d]", pMsgList->nCount); + return err; +} - pMsgList->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t) * rowCnt]; - MSG_MESSAGE_HIDDEN_S *pTmp = NULL; - msg_struct_s *msg = NULL; +msg_message_id_t MsgStoAddSimMessage(MSG_MESSAGE_INFO_S *pMsg, int *simIdList, int listSize) +{ + MSG_BEGIN(); + MsgDbHandler *dbHandle = getDbHandle(); + if (pMsg == NULL || pMsg->msgType.mainType == MSG_MMS_TYPE) { + MSG_DEBUG("pMsg == NULL || pMsg->msgType.mainType == MSG_MMS_TYPE"); + return 0; + } - for (int i = 0; i < rowCnt; i++) { - pMsgList->msg_struct_info[i] = (msg_struct_t)new msg_struct_s; - - msg = (msg_struct_s *)pMsgList->msg_struct_info[i]; - - msg->type = MSG_STRUCT_MESSAGE_INFO; - msg->data = (int *)new char[sizeof(MSG_MESSAGE_HIDDEN_S)]; - - pTmp = (MSG_MESSAGE_HIDDEN_S *)msg->data; - - memset(pTmp, 0x00, sizeof(MSG_MESSAGE_HIDDEN_S)); - - pTmp->pData = NULL; - pTmp->pMmsData = NULL; - - pTmp->msgId = dbHandle.getColumnToInt(index++); - pTmp->threadId = dbHandle.getColumnToInt(index++); - pTmp->folderId = dbHandle.getColumnToInt(index++); - pTmp->storageId = dbHandle.getColumnToInt(index++); - pTmp->mainType = dbHandle.getColumnToInt(index++); - pTmp->subType = dbHandle.getColumnToInt(index++); - pTmp->displayTime = (time_t)dbHandle.getColumnToInt(index++); - pTmp->dataSize = dbHandle.getColumnToInt(index++); - pTmp->networkStatus = dbHandle.getColumnToInt(index++); - pTmp->bRead = dbHandle.getColumnToInt(index++); - pTmp->bProtected = dbHandle.getColumnToInt(index++); - pTmp->bBackup = dbHandle.getColumnToInt(index++); - pTmp->priority = dbHandle.getColumnToInt(index++); - pTmp->direction = dbHandle.getColumnToInt(index++); - index++; // This field is reserved. - - dbHandle.getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject); - - if (pTmp->mainType == MSG_MMS_TYPE && - (pTmp->networkStatus == MSG_NETWORK_RETRIEVING || pTmp->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pTmp->subType == MSG_NOTIFICATIONIND_MMS)) { - pTmp->pData = NULL; - index++; + if ((pMsg->msgType.subType >= MSG_REPLACE_TYPE1_SMS) && (pMsg->msgType.subType <= MSG_REPLACE_TYPE7_SMS)) { + if (pMsg->msgId > 0) { + pMsg->bRead = false; + if (MsgStoUpdateMessage(pMsg, NULL) != MSG_SUCCESS) { + MSG_DEBUG("MsgStoUpdateMessage is failed!!!"); + } } else { - pTmp->pData = (void *)new char[pTmp->dataSize+2]; - memset(pTmp->pData, 0x00, pTmp->dataSize+2); + if (MsgStoAddMessage(pMsg, NULL) != MSG_SUCCESS) { + MSG_DEBUG("MsgStoAddMessage is failed!!!"); + } + } + } else { + pMsg->msgId = 0; + if (MsgStoAddMessage(pMsg, NULL) != MSG_SUCCESS) { + MSG_DEBUG("MsgStoAddMessage is failed!!!"); + } + } + + if(simIdList) { + dbHandle->beginTrans(); + + MSG_DEBUG("simIdList exist."); + int simId = 0; + for(int i=0; i < listSize; ++i) + { + if(simIdList[i]) { + simId = simIdList[i] - 1; + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d);", + MSGFW_SIM_MSG_TABLE_NAME, pMsg->sim_idx, simId, pMsg->msgId); - dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData); + MSG_DEBUG("QUERY : %s", sqlQuery); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return 0; + } + } else { + break; + } + } + + dbHandle->endTrans(true); + } + + MSG_END(); + + return pMsg->msgId; +} + +#ifdef FEATURE_SMS_CDMA +msg_error_t MsgCheckUniqueness(bool bInsert, msg_message_id_t msgId, MSG_UNIQUE_INDEX_S *p_msg) +{ + MSG_BEGIN(); + + MsgDbHandler *dbHandle = getDbHandle(); + int nRowCnt = 0; + + char sqlQuery[MAX_QUERY_LEN+1]; + + if (!bInsert) { + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + dbHandle->beginTrans(); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE TELE_MSG_ID = %d AND ADDRESS = '%s' AND SUB_ADDRESS = '%s' AND TIME_STAMP = '%s' AND TELESVC_ID = %d;", + MSGFW_UNIQUENESS_INFO_TABLE_NAME, p_msg->tele_msgId, p_msg->address, p_msg->sub_address, p_msg->time_stamp, p_msg->telesvc_id); + + dbHandle->getTable(sqlQuery, &nRowCnt, NULL); + MSG_DEBUG("nRowCnt = [%d]", nRowCnt); + + dbHandle->freeTable(); + dbHandle->endTrans(true); + + if (nRowCnt == 0) { + MSG_DEBUG("<<<>>>"); + return MSG_SUCCESS; + } + else { + MSG_DEBUG("<<<>>>"); + return MSG_ERR_UNKNOWN; + } + } + else { + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + dbHandle->beginTrans(); + + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, '%s', '%s', '%s', %d);", + MSGFW_UNIQUENESS_INFO_TABLE_NAME, msgId, p_msg->tele_msgId, p_msg->address, p_msg->sub_address, p_msg->time_stamp, p_msg->telesvc_id); + + dbHandle->execQuery(sqlQuery); + dbHandle->endTrans(true); + } + + MSG_END(); + + return MSG_SUCCESS; +} +#endif + +msg_error_t MsgStoUpdateIMSI(int sim_idx) +{ + MSG_BEGIN(); + MSG_DEBUG("sim_idx = %d", sim_idx); + +// msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); + + char sqlQuery[MAX_QUERY_LEN+1]; + char keyName[MAX_VCONFKEY_NAME_LEN]; + + dbHandle->beginTrans(); + + if(sim_idx == 0){ + MSG_DEBUG("sim index is 0"); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET SIM_INDEX = 0;", + MSGFW_MESSAGE_TABLE_NAME); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; } + } + else + { + MSG_DEBUG("sim index is %d", sim_idx); - pTmp->attachCount = dbHandle.getColumnToInt(index++); + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_IMSI, sim_idx); + + char *imsi = MsgSettingGetString(keyName); + + MSG_DEBUG("imsi value exist -> %s", imsi); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath); + snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET SIM_INDEX = %d \ + WHERE SIM_IMSI LIKE '%s';", + MSGFW_MESSAGE_TABLE_NAME, sim_idx, imsi); - // add address information. - order = MsgGetContactNameOrder(); + if (imsi) { + free(imsi); + imsi = NULL; + } - msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s; - MsgStoGetAddressByMsgId(&dbHandle, pTmp->msgId, order, addr_list); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } - pTmp->addr_list = addr_list; + if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } } - dbHandle.freeTable(); + + dbHandle->finalizeQuery(); + dbHandle->endTrans(true); + + MSG_END(); return MSG_SUCCESS; } diff --git a/framework/storage-handler/MsgStorageMms.cpp b/framework/storage-handler/MsgStorageMms.cpp index dd2f5c0..91b5534 100755 --- a/framework/storage-handler/MsgStorageMms.cpp +++ b/framework/storage-handler/MsgStorageMms.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "MsgDebug.h" @@ -26,7 +26,6 @@ /*================================================================================================== VARIABLES ==================================================================================================*/ -extern MsgDbHandler dbHandle; /*================================================================================================== @@ -34,6 +33,7 @@ extern MsgDbHandler dbHandle; ==================================================================================================*/ msg_error_t MsgStoGetText(msg_message_id_t msgId, char *pSubject, char *pMsgText) { + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -41,24 +41,24 @@ msg_error_t MsgStoGetText(msg_message_id_t msgId, char *pSubject, char *pMsgText snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SUBJECT, MSG_TEXT FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); - if(dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if(dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if(dbHandle.stepQuery() == MSG_ERR_DB_ROW) { + if(dbHandle->stepQuery() == MSG_ERR_DB_ROW) { - char *subject = (char*)dbHandle.columnText(0); - char *text = (char*)dbHandle.columnText(1); + char *subject = (char*)dbHandle->columnText(0); + char *text = (char*)dbHandle->columnText(1); if(subject) strncpy(pSubject, subject, MAX_SUBJECT_LEN); if(text) strncpy(pMsgText, text, MAX_MSG_TEXT_LEN); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_SUCCESS; @@ -70,105 +70,262 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg) { MSG_BEGIN(); + MSG_SEC_DEBUG("pMsg->msgText [%s]", pMsg->msgText); + MsgDbHandler *dbHandle = getDbHandle(); + msg_error_t err = MSG_SUCCESS; + + unsigned int fileSize = 0; + char *pFileData = NULL; + char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); - dbHandle.beginTrans(); - if(pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { if( pMsg->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS ) { snprintf(sqlQuery, sizeof(sqlQuery), - "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, DISPLAY_TIME = %lu, SUBJECT = ?, NETWORK_STATUS = %d, MSG_TEXT = ?, THUMB_PATH = '%s', DATA_SIZE = %d WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->displayTime, pMsg->networkStatus, pMsg->thumbPath, pMsg->dataSize, pMsg->msgId); + "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, FOLDER_ID = %d, DISPLAY_TIME = %lu, SUBJECT = ?, NETWORK_STATUS = %d, MSG_TEXT = ?, THUMB_PATH = '%s', DATA_SIZE = %d WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->displayTime, pMsg->networkStatus, pMsg->thumbPath, pMsg->dataSize, pMsg->msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { return MSG_ERR_DB_PREPARE; } - dbHandle.bindText(pMsg->subject, 1); - dbHandle.bindText(pMsg->msgText, 2); - } else if( pMsg->networkStatus == MSG_NETWORK_RETRIEVE_FAIL) { + dbHandle->bindText(pMsg->subject, 1); + + if (pMsg->msgText[0] != '\0' && g_file_get_contents(pMsg->msgText, &pFileData, &fileSize, NULL) == true) { + dbHandle->bindText(pFileData, 2); + } else { + dbHandle->bindText("", 2); + } + + } else if (pMsg->networkStatus == MSG_NETWORK_RETRIEVE_FAIL) { snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, SUBJECT = ?, NETWORK_STATUS = %d, MSG_TEXT = ?, THUMB_PATH = '%s' WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->networkStatus, pMsg->thumbPath, pMsg->msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { return MSG_ERR_DB_PREPARE; } - dbHandle.bindText(pMsg->subject, 1); - dbHandle.bindText(pMsg->msgText, 2); +// if (MsgOpenAndReadFile(pMsg->msgText, &pFileData, &fileSize) == false) { + if (g_file_get_contents(pMsg->msgText, &pFileData, &fileSize, NULL) == false) { + return MSG_ERR_STORAGE_ERROR; + } + + dbHandle->bindText(pMsg->subject, 1); + + if (pMsg->msgText[0] != '\0' && g_file_get_contents(pMsg->msgText, &pFileData, &fileSize, NULL) == true) { + dbHandle->bindText(pFileData, 2); + } else { + dbHandle->bindText("", 2); + } } - } else if (pMsg->msgType.subType == MSG_SENDREQ_MMS) { + } else if (pMsg->msgType.subType == MSG_SENDREQ_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MMS) { snprintf(sqlQuery, sizeof(sqlQuery), - "UPDATE %s SET MSG_DATA = '%s', MSG_TEXT = ?, THUMB_PATH = '%s' WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, pMsg->msgData, pMsg->thumbPath, pMsg->msgId); + "UPDATE %s SET MSG_TEXT = ?, THUMB_PATH = '%s', DATA_SIZE = %d WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, pMsg->thumbPath, pMsg->dataSize, pMsg->msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { return MSG_ERR_DB_PREPARE; } - dbHandle.bindText(pMsg->msgText, 1); + if (pMsg->msgText[0] != '\0' && g_file_get_contents(pMsg->msgText, &pFileData, &fileSize, NULL) == true) { + dbHandle->bindText(pFileData, 1); + } else { + dbHandle->bindText("", 1); + } } else { - snprintf(sqlQuery, sizeof(sqlQuery), - "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, FOLDER_ID = %d, NETWORK_STATUS = %d WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->networkStatus, pMsg->msgId); + if (pMsg->msgType.subType == MSG_SENDCONF_MMS && pMsg->networkStatus == MSG_NETWORK_SEND_FAIL) { + snprintf(sqlQuery, sizeof(sqlQuery), + "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, FOLDER_ID = %d, NETWORK_STATUS = %d, DISPLAY_TIME = %lu, READ_STATUS = 0 WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->networkStatus, pMsg->displayTime, pMsg->msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + } else { + snprintf(sqlQuery, sizeof(sqlQuery), + "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, FOLDER_ID = %d, NETWORK_STATUS = %d, DISPLAY_TIME = %lu WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->networkStatus, pMsg->displayTime, pMsg->msgId); + } + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { return MSG_ERR_DB_PREPARE; } } - if (dbHandle.stepQuery() != MSG_ERR_DB_DONE) { - dbHandle.finalizeQuery(); - dbHandle.endTrans(false); - MSG_DEBUG("Update MMS Message. Fail [%s]", sqlQuery); + MSG_DEBUG("[%s]", sqlQuery); + + err = dbHandle->stepQuery(); + + if (pFileData != NULL) { + g_free(pFileData); + } + + if (err != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + MSG_DEBUG("Update MMS Message. Fail."); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); + + /* PLM P141008-05143 : Notification.Ind address is 1, but MMS retreived Conf address is correct. + * So adding code for comparing exist address and new address and replace with new address(MMSconf) address */ + + if(pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { + if (pMsg->nAddressCnt == 1 && pMsg->addressList) { + char tmpAddressVal[MAX_ADDRESS_VAL_LEN+1] = {0,}; + msg_address_type_t tmpAddressType; + msg_recipient_type_t tmpRecipientType; + int tmpConvId; + + //compare stored address and currnt address + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "A.CONV_ID, " + "A.ADDRESS_TYPE, " + "A.RECIPIENT_TYPE, " + "A.ADDRESS_VAL " + "FROM %s A, %s B " + "WHERE A.CONV_ID = B.CONV_ID " + "AND B.MSG_ID = %d;", + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + pMsg->msgId); + + MSG_DEBUG("[%s]", sqlQuery); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_PREPARE; + } + + err = dbHandle->stepQuery(); + + if (err == MSG_ERR_DB_ROW) { + tmpConvId = dbHandle->columnInt(0); + tmpAddressType = dbHandle->columnInt(1); + tmpRecipientType = dbHandle->columnInt(2); + strncpy(tmpAddressVal, (char*)dbHandle->columnText(3), MAX_ADDRESS_VAL_LEN); + + dbHandle->finalizeQuery(); + + //compare stored addressList and current addressList + if (tmpAddressType != pMsg->addressList->addressType || + tmpRecipientType != pMsg->addressList->recipientType || + (strncmp(tmpAddressVal, pMsg->addressList->addressVal, MAX_ADDRESS_VAL_LEN) != 0)) { + + MSG_WARN("AddressList of NotiInd and MMSConf are different!!, Replace AddressList to MMSConf data"); + MSG_WARN("AddType [NotiInd : %d], [MMSConf : %d]", tmpAddressType, pMsg->addressList->addressType); + MSG_WARN("RcptType [NotiInd : %d], [MMSConf : %d]", tmpRecipientType, pMsg->addressList->recipientType); + MSG_SEC_INFO("AddressVal [NotiInd : %s], [MMSConf : %s]", tmpAddressVal, pMsg->addressList->addressVal); + + // If MMSConf AddressList is already exist, Replace exist ConvId with matching msgId + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT CONV_ID FROM %s WHERE ADDRESS_VAL = '%s'", + MSGFW_ADDRESS_TABLE_NAME, pMsg->addressList->addressVal); + + MSG_DEBUG("[%s]", sqlQuery); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_PREPARE; + } + + err = dbHandle->stepQuery(); + + if (err == MSG_ERR_DB_ROW) { + tmpConvId = dbHandle->columnInt(0); + + dbHandle->finalizeQuery(); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), + "UPDATE %s SET CONV_ID = %d WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, tmpConvId, pMsg->msgId); + + MSG_DEBUG("[%s]", sqlQuery); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_PREPARE; + } + + err = dbHandle->stepQuery(); + + if (err != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + MSG_ERR("Replacing CONV_ID with exist one. Fail."); + return MSG_ERR_DB_STEP; + } + + dbHandle->finalizeQuery(); + } else { + dbHandle->finalizeQuery(); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), + "UPDATE %s SET ADDRESS_TYPE = %d, RECIPIENT_TYPE = %d, ADDRESS_VAL = '%s' WHERE CONV_ID = %d;", + MSGFW_ADDRESS_TABLE_NAME, pMsg->addressList->addressType, pMsg->addressList->recipientType, pMsg->addressList->addressVal, tmpConvId); + + MSG_DEBUG("[%s]", sqlQuery); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_PREPARE; + } + + err = dbHandle->stepQuery(); + + if (err != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + MSG_ERR("Replacing Address with MMSConf Address. Fail."); + return MSG_ERR_DB_STEP; + } + + dbHandle->finalizeQuery(); + } + } + } else { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + } + } msg_thread_id_t convId = 0; - int row = 0; + int rowCnt = 0; // Get SUB_TYPE, STORAGE_ID memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONV_ID FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId); - if (dbHandle.getTable(sqlQuery, &row) != MSG_SUCCESS) { - dbHandle.freeTable(); - dbHandle.endTrans(false); + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_PREPARE; } - if (row > 0) { - convId = dbHandle.getColumnToInt(1); + if (rowCnt > 0) { + convId = dbHandle->getColumnToInt(1); MSG_DEBUG("Conversation id:[%d]", convId); - if (MsgStoUpdateConversation(&dbHandle, convId) != MSG_SUCCESS) { + if (MsgStoUpdateConversation(dbHandle, convId) != MSG_SUCCESS) { MSG_DEBUG("MsgStoUpdateConversation() Error"); - dbHandle.freeTable(); - dbHandle.endTrans(false); + dbHandle->freeTable(); return MSG_ERR_STORAGE_ERROR; } + if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { + MSG_DEBUG("MsgStoClearConversationTable() Error"); + } + } else { - MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery); - dbHandle.freeTable(); - dbHandle.endTrans(false); + dbHandle->freeTable(); return MSG_ERR_DB_STEP; } - dbHandle.freeTable(); - dbHandle.endTrans(true); + dbHandle->freeTable(); MSG_END(); @@ -178,6 +335,7 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg) msg_error_t MsgStoGetContentLocation(MSG_MESSAGE_INFO_S* pMsgInfo) { + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -185,23 +343,23 @@ msg_error_t MsgStoGetContentLocation(MSG_MESSAGE_INFO_S* pMsgInfo) snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONTENTS_LOCATION FROM %s WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, pMsgInfo->msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - if (dbHandle.columnText(0) != NULL) { - strncpy(pMsgInfo->msgData, (char*)dbHandle.columnText(0), MAX_MSG_DATA_LEN); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + if (dbHandle->columnText(0) != NULL) { + strncpy(pMsgInfo->msgData, (char*)dbHandle->columnText(0), MAX_MSG_DATA_LEN); pMsgInfo->dataSize = strlen(pMsgInfo->msgData); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_NORECORD; } } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_SUCCESS; } @@ -209,6 +367,7 @@ msg_error_t MsgStoGetContentLocation(MSG_MESSAGE_INFO_S* pMsgInfo) msg_error_t MsgStoSetReadReportSendStatus(msg_message_id_t msgId, int readReportSendStatus) { + MsgDbHandler *dbHandle = getDbHandle(); bool bReadReportSent = false; if((MmsRecvReadReportSendStatus)readReportSendStatus == MMS_RECEIVE_READ_REPORT_SENT) @@ -223,7 +382,7 @@ msg_error_t MsgStoSetReadReportSendStatus(msg_message_id_t msgId, int readReport snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET READ_REPORT_SEND_STATUS = %d, READ_REPORT_SENT = %d WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, (MmsRecvReadReportSendStatus)readReportSendStatus, (int)bReadReportSent, msgId); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; return MSG_SUCCESS; @@ -232,33 +391,38 @@ msg_error_t MsgStoSetReadReportSendStatus(msg_message_id_t msgId, int readReport msg_error_t MsgStoGetOrgAddressList(MSG_MESSAGE_INFO_S *pMsg) { + MsgDbHandler *dbHandle = getDbHandle(); msg_error_t err = MSG_SUCCESS; char sqlQuery[MAX_QUERY_LEN+1]; - int rowCnt = 0; - int index = 3; + int rowCnt = 0, index = 0; memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_TYPE, A.RECIPIENT_TYPE, A.ADDRESS_VAL FROM %s A, %s B \ - WHERE A.CONV_ID = B.CONV_ID AND B.MSG_ID = %d;", + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "A.ADDRESS_TYPE, " + "A.RECIPIENT_TYPE, " + "A.ADDRESS_VAL " + "FROM %s A, %s B " + "WHERE A.CONV_ID = B.CONV_ID " + "AND B.MSG_ID = %d;", MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId); - err = dbHandle.getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); + dbHandle->freeTable(); return err; } for(int i = 0; i < rowCnt; i++) { - pMsg->addressList[i].addressType = dbHandle.getColumnToInt(index++); - pMsg->addressList[i].recipientType = dbHandle.getColumnToInt(index++); - dbHandle.getColumnToString(index++, MAX_ADDRESS_VAL_LEN, pMsg->addressList[i].addressVal); + pMsg->addressList[i].addressType = dbHandle->getColumnToInt(index++); + pMsg->addressList[i].recipientType = dbHandle->getColumnToInt(index++); + dbHandle->getColumnToString(index++, MAX_ADDRESS_VAL_LEN, pMsg->addressList[i].addressVal); } pMsg->nAddressCnt = rowCnt; - dbHandle.freeTable(); + dbHandle->freeTable(); return MSG_SUCCESS; } @@ -266,6 +430,7 @@ msg_error_t MsgStoGetOrgAddressList(MSG_MESSAGE_INFO_S *pMsg) msg_error_t MsgStoGetSubject(msg_message_id_t msgId, char *pSubject) { + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -273,63 +438,44 @@ msg_error_t MsgStoGetSubject(msg_message_id_t msgId, char *pSubject) snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SUBJECT FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - strncpy(pSubject, (char*)dbHandle.columnText(0), MAX_SUBJECT_LEN); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + strncpy(pSubject, (char*)dbHandle->columnText(0), MAX_SUBJECT_LEN); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); 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) { MSG_DEBUG("pRecipientList is NULL"); return MSG_ERR_NULL_POINTER; } - - int rowCnt = 0, index = 7; - + MsgDbHandler *dbHandle = getDbHandle(); + int rowCnt = 0, index = 0; char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT B.ADDRESS_TYPE, B.RECIPIENT_TYPE, \ - B.ADDRESS_VAL, B.CONTACT_ID, B.DISPLAY_NAME, B.FIRST_NAME, B.LAST_NAME \ - FROM %s A, %s B WHERE A.MSG_ID = %d AND A.CONV_ID = B.CONV_ID;", - MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, msgId); - - if (dbHandle.getTable(sqlQuery, &rowCnt) != MSG_SUCCESS) { - dbHandle.freeTable(); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "B.ADDRESS_TYPE, " + "B.RECIPIENT_TYPE, " + "B.ADDRESS_VAL " + "FROM %s A, %s B " + "WHERE A.MSG_ID = %d " + "AND A.CONV_ID = B.CONV_ID;", + MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, + msgId); + + if (dbHandle->getTable(sqlQuery, &rowCnt, &index) != MSG_SUCCESS) { + dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -341,57 +487,20 @@ msg_error_t MsgStoGetRecipientList(msg_message_id_t msgId, MSG_RECIPIENTS_LIST_S MSG_ADDRESS_INFO_S* pTmp = pRecipientList->recipientAddr; - char firstName[MAX_THREAD_NAME_LEN+1], lastName[MAX_THREAD_NAME_LEN+1]; - char displayName[MAX_DISPLAY_NAME_LEN+1]; - - int order = MsgGetContactNameOrder(); - for (int i = 0; i < rowCnt; i++) { - pTmp->addressType = dbHandle.getColumnToInt(index++); - pTmp->recipientType= dbHandle.getColumnToInt(index++); + pTmp->addressType = dbHandle->getColumnToInt(index++); + pTmp->recipientType= dbHandle->getColumnToInt(index++); memset(pTmp->addressVal, 0x00, sizeof(pTmp->addressVal)); - dbHandle.getColumnToString(index++, MAX_ADDRESS_VAL_LEN, pTmp->addressVal); + dbHandle->getColumnToString(index++, MAX_ADDRESS_VAL_LEN, pTmp->addressVal); - pTmp->contactId= dbHandle.getColumnToInt(index++); - - memset(displayName, 0x00, sizeof(displayName)); - dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, displayName); - - memset(firstName, 0x00, sizeof(firstName)); - dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, firstName); - - memset(lastName, 0x00, sizeof(lastName)); - dbHandle.getColumnToString(index++, MAX_THREAD_NAME_LEN, lastName); - - if (strlen(displayName) <= 0) { - 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)); - } - } - - memset(pTmp->displayName, 0x00, sizeof(pTmp->displayName)); - strncpy(pTmp->displayName, displayName, MAX_DISPLAY_NAME_LEN); + strncpy(pTmp->displayName, pTmp->addressVal, MAX_DISPLAY_NAME_LEN); pTmp++; } - dbHandle.freeTable(); + dbHandle->freeTable(); return MSG_SUCCESS; } @@ -399,6 +508,7 @@ msg_error_t MsgStoGetRecipientList(msg_message_id_t msgId, MSG_RECIPIENTS_LIST_S msg_error_t MsgStoGetReadStatus(msg_message_id_t msgId, bool *pReadStatus) { + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -406,17 +516,17 @@ msg_error_t MsgStoGetReadStatus(msg_message_id_t msgId, bool *pReadStatus) snprintf(sqlQuery, sizeof(sqlQuery), "SELECT READ_STATUS FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - *pReadStatus = (bool)dbHandle.columnInt(0); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + *pReadStatus = (bool)dbHandle->columnInt(0); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_SUCCESS; } @@ -424,30 +534,69 @@ msg_error_t MsgStoGetReadStatus(msg_message_id_t msgId, bool *pReadStatus) msg_error_t MsgStoGetAddrInfo(msg_message_id_t msgId, MSG_ADDRESS_INFO_S *pAddrInfo) { + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; // Add Address memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_TYPE, A.RECIPIENT_TYPE, A.CONTACT_ID, A.ADDRESS_VAL \ - FROM %s A, %s B WHERE A.CONV_ID = B.CONV_ID AND B.MSG_ID = %d;", - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "A.ADDRESS_TYPE, " + "A.RECIPIENT_TYPE, " + "A.CONTACT_ID, " + "A.ADDRESS_VAL " + "FROM %s A, %s B " + "WHERE A.CONV_ID = B.CONV_ID " + "AND B.MSG_ID = %d;", + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + msgId); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + pAddrInfo->addressType = dbHandle->columnInt(0); + pAddrInfo->recipientType = dbHandle->columnInt(1); + pAddrInfo->contactId = dbHandle->columnInt(2); + + strncpy(pAddrInfo->addressVal, (char*)dbHandle->columnText(3), MAX_ADDRESS_VAL_LEN); + } else { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + + dbHandle->finalizeQuery(); + + return MSG_SUCCESS; +} + +msg_error_t MsgStoGetReadReportSendStatus(msg_message_id_t msgId, int *pReadReportSendStatus) +{ + MmsRecvReadReportSendStatus readReportSendStatus = MMS_RECEIVE_READ_REPORT_NO_SEND; + MsgDbHandler *dbHandle = getDbHandle(); + char sqlQuery[MAX_QUERY_LEN+1]; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "READ_REPORT_SEND_STATUS " + "FROM %s WHERE MSG_ID = %d;", + MMS_PLUGIN_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { - pAddrInfo->addressType = dbHandle.columnInt(0); - pAddrInfo->recipientType = dbHandle.columnInt(1); - pAddrInfo->contactId = dbHandle.columnInt(2); + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + readReportSendStatus = (MmsRecvReadReportSendStatus)dbHandle->columnInt(0); + + *pReadReportSendStatus = readReportSendStatus; - strncpy(pAddrInfo->addressVal, (char*)dbHandle.columnText(3), MAX_ADDRESS_VAL_LEN); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_SUCCESS; } diff --git a/framework/storage-handler/MsgStorageSim.cpp b/framework/storage-handler/MsgStorageSim.cpp index 7e1895e..72c934a 100755 --- a/framework/storage-handler/MsgStorageSim.cpp +++ b/framework/storage-handler/MsgStorageSim.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include @@ -31,48 +31,14 @@ using namespace std; /*================================================================================================== VARIABLES ==================================================================================================*/ -extern MsgDbHandler dbHandle; /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ -msg_error_t MsgInitSimMessage(MSG_SIM_STATUS_T SimStatus) -{ - MSG_DEBUG("Start SIM Message Initialization"); - - msg_error_t err = MSG_SUCCESS; - - // Set SIM count of vconf to 0 - if (MsgSettingSetInt(SIM_USED_COUNT, 0) != MSG_SUCCESS) { - MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT); - } - - if (MsgSettingSetInt(SIM_TOTAL_COUNT, 0) != MSG_SUCCESS) { - MSG_DEBUG("Error to set config data [%s]", SIM_TOTAL_COUNT); - } - - if (SimStatus != MSG_SIM_STATUS_NOT_FOUND) { - MSG_MAIN_TYPE_T mainType = MSG_SMS_TYPE; - MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType); - - if (plg == NULL) { - MSG_DEBUG("No plugin for %d type", mainType); - return MSG_ERR_INVALID_PLUGIN_HANDLE; - } - - // Check SIM Status - MSG_DEBUG(" ** SIM is available - status : [%d] ** ", SimStatus); - - err = plg->initSimMessage(); - } - - return err; -} - - msg_error_t MsgStoClearSimMessageInDB() { + MsgDbHandler *dbHandle = getDbHandle(); msg_error_t err = MSG_SUCCESS; char sqlQuery[MAX_QUERY_LEN+1]; @@ -87,33 +53,32 @@ msg_error_t MsgStoClearSimMessageInDB() int rowCnt = 0; - err = dbHandle.getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { - MSG_DEBUG("sql query is %s.", sqlQuery); - - dbHandle.freeTable(); + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); return err; } if (rowCnt <= 0) { - dbHandle.freeTable(); + dbHandle->freeTable(); return MSG_SUCCESS; } for (int i = 1; i <= rowCnt; i++) { - MSG_DEBUG("thread ID : %d", dbHandle.getColumnToInt(i)); - threadList.push((msg_thread_id_t)dbHandle.getColumnToInt(i)); + MSG_DEBUG("thread ID : %d", dbHandle->getColumnToInt(i)); + threadList.push((msg_thread_id_t)dbHandle->getColumnToInt(i)); } - dbHandle.freeTable(); + dbHandle->freeTable(); const char* tableList[] = {MSGFW_SMS_SENDOPT_TABLE_NAME, MSGFW_SIM_MSG_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME}; int listCnt = sizeof(tableList)/sizeof(char*); - dbHandle.beginTrans(); + dbHandle->beginTrans(); for (int i = 0; i < listCnt; i++) { @@ -124,32 +89,32 @@ msg_error_t MsgStoClearSimMessageInDB() tableList[i], MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_SIM); // Delete SIM Message in tables - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } } // Clear Conversation table - if (MsgStoClearConversationTable(&dbHandle) != MSG_SUCCESS) { - dbHandle.endTrans(false); + if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { + dbHandle->endTrans(false); return MSG_ERR_DB_EXEC; } // Update Address while (!threadList.empty()) { - err = MsgStoUpdateConversation(&dbHandle, threadList.front()); + err = MsgStoUpdateConversation(dbHandle, threadList.front()); threadList.pop(); if (err != MSG_SUCCESS) { - dbHandle.endTrans(false); + dbHandle->endTrans(false); return err; } } - dbHandle.endTrans(true); + dbHandle->endTrans(true); return MSG_SUCCESS; } diff --git a/framework/storage-handler/MsgStorageUtil.cpp b/framework/storage-handler/MsgStorageUtil.cpp index 52fa76f..e6925aa 100755 --- a/framework/storage-handler/MsgStorageUtil.cpp +++ b/framework/storage-handler/MsgStorageUtil.cpp @@ -1,22 +1,23 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include #include #include +#include #include "MsgDebug.h" #include "MsgCppTypes.h" @@ -29,103 +30,41 @@ #include "MsgUtilStorage.h" #include "MsgStorageHandler.h" +using namespace std; /*================================================================================================== VARIABLES ==================================================================================================*/ -extern MsgDbHandler dbHandle; /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ -msg_error_t MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort) -{ - char sql[128]; - char order[6]; - - memset(sql, 0x00, sizeof(sql)); - memset(order, 0x00, sizeof(order)); - - if (pSortRule->bAscending == true) - strncpy(order, "ASC", 5); - else - strncpy(order, "DESC", 5); - - int nameOrder = MsgGetContactNameOrder(); - - switch (pSortRule->sortType) - { - case MSG_SORT_BY_DISPLAY_FROM : - if (nameOrder == 0) - snprintf(sql, sizeof(sql), "ORDER BY B.FIRST_NAME %s, B.LAST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order); - else - snprintf(sql, sizeof(sql), "ORDER BY B.LAST_NAME %s, B.FIRST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order); - break; - case MSG_SORT_BY_DISPLAY_TO : - if (nameOrder == 0) - snprintf(sql, sizeof(sql), "ORDER BY B.FIRST_NAME %s, B.LAST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order); - else - snprintf(sql, sizeof(sql), "ORDER BY B.LAST_NAME %s, B.FIRST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order); - break; - case MSG_SORT_BY_DISPLAY_TIME : - snprintf(sql, sizeof(sql), "ORDER BY DISPLAY_TIME %s;", order); - break; - case MSG_SORT_BY_MSG_TYPE : - snprintf(sql, sizeof(sql), "ORDER BY MAIN_TYPE %s, DISPLAY_TIME DESC;", order); - break; - case MSG_SORT_BY_READ_STATUS : - snprintf(sql, sizeof(sql), "ORDER BY READ_STATUS %s, DISPLAY_TIME DESC;", order); - break; - case MSG_SORT_BY_STORAGE_TYPE : - snprintf(sql, sizeof(sql), "ORDER BY A.STORAGE_ID %s, A.DISPLAY_TIME DESC;", order); - break; - case MSG_SORT_BY_THREAD_NAME : - if (nameOrder == 0) - snprintf(sql, sizeof(sql), "ORDER BY FIRST_NAME %s, LAST_NAME %s;", order, order); - else - snprintf(sql, sizeof(sql), "ORDER BY LAST_NAME %s, FIRST_NAME %s;", order, order); - break; - case MSG_SORT_BY_THREAD_DATE : - snprintf(sql, sizeof(sql), "ORDER BY MSG_TIME %s;", order); - break; - case MSG_SORT_BY_THREAD_COUNT : - snprintf(sql, sizeof(sql), "ORDER BY UNREAD_CNT %s;", order); - break; - default : - snprintf(sql, sizeof(sql), "ORDER BY A.DISPLAY_TIME %s;", order); - break; - } - - memcpy(pSqlSort, sql, strlen(sql)); - - return MSG_SUCCESS; -} - - -msg_error_t MsgStoGetSmsSendOpt(msg_message_id_t msgId, MSG_SENDINGOPT_INFO_S* pSendOpt) +msg_error_t MsgStoGetSmsSendOpt(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOpt) { + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DELREP_REQ, KEEP_COPY, REPLY_PATH FROM %s WHERE MSG_ID = %d;", - MSGFW_SMS_SENDOPT_TABLE_NAME, msgId); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DELREP_REQ, KEEP_COPY, REPLY_PATH, ENCODE_TYPE FROM %s WHERE MSG_ID = %d;", + MSGFW_SMS_SENDOPT_TABLE_NAME, pMsg->msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { pSendOpt->bSetting = true; - pSendOpt->bDeliverReq = (bool)dbHandle.columnInt(0); - pSendOpt->bKeepCopy = (bool)dbHandle.columnInt(1); - pSendOpt->option.smsSendOptInfo.bReplyPath = (bool)dbHandle.columnInt(2); + pSendOpt->bDeliverReq = (bool)dbHandle->columnInt(0); + pSendOpt->bKeepCopy = (bool)dbHandle->columnInt(1); + pSendOpt->option.smsSendOptInfo.bReplyPath = (bool)dbHandle->columnInt(2); + pMsg->encodeType = dbHandle->columnInt(3); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_SUCCESS; } @@ -133,6 +72,7 @@ msg_error_t MsgStoGetSmsSendOpt(msg_message_id_t msgId, MSG_SENDINGOPT_INFO_S* p msg_error_t MsgStoGetMmsSendOpt(msg_message_id_t msgId, MSG_SENDINGOPT_INFO_S* pSendOpt) { + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -140,32 +80,32 @@ msg_error_t MsgStoGetMmsSendOpt(msg_message_id_t msgId, MSG_SENDINGOPT_INFO_S* p snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ASK_DELIVERY_REPORT, KEEP_COPY, ASK_READ_REPLY, EXPIRY_TIME, PRIORITY FROM %s WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, msgId); - if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_PREPARE; - if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { pSendOpt->bSetting = true; - pSendOpt->bDeliverReq = (bool)dbHandle.columnInt(0); - pSendOpt->bKeepCopy = (bool)dbHandle.columnInt(1); - pSendOpt->option.mmsSendOptInfo.bReadReq = (bool)dbHandle.columnInt(2); - pSendOpt->option.mmsSendOptInfo.expiryTime.time = (unsigned int)dbHandle.columnInt(3); - pSendOpt->option.mmsSendOptInfo.priority = (msg_priority_type_t)dbHandle.columnInt(4); + pSendOpt->bDeliverReq = (bool)dbHandle->columnInt(0); + pSendOpt->bKeepCopy = (bool)dbHandle->columnInt(1); + pSendOpt->option.mmsSendOptInfo.bReadReq = (bool)dbHandle->columnInt(2); + pSendOpt->option.mmsSendOptInfo.expiryTime.time = (unsigned int)dbHandle->columnInt(3); + pSendOpt->option.mmsSendOptInfo.priority = (msg_priority_type_t)dbHandle->columnInt(4); } else { - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_ERR_DB_STEP; } - dbHandle.finalizeQuery(); + dbHandle->finalizeQuery(); return MSG_SUCCESS; } + bool MsgStoCheckSyncMLMsgInThread(msg_thread_id_t threadId) { - msg_error_t err = MSG_SUCCESS; int rowCnt = 0; bool isSyncMLMsg = false; - + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -173,15 +113,15 @@ bool MsgStoCheckSyncMLMsgInThread(msg_thread_id_t threadId) snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE SUB_TYPE = %d AND CONV_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, MSG_SYNCML_CP, threadId); - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - err = dbHandle.getTable(sqlQuery, &rowCnt); + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) { + MSG_DEBUG("getTable is failed!!!"); + } if (rowCnt > 0) isSyncMLMsg = true; MSG_DEBUG("rowCnt [%d]", rowCnt); - dbHandle.freeTable(); + dbHandle->freeTable(); return isSyncMLMsg; } @@ -190,17 +130,27 @@ bool MsgStoCheckSyncMLMsgInThread(msg_thread_id_t threadId) msg_error_t MsgStoResetNetworkStatus() { MSG_BEGIN(); - + MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), - "UPDATE %s SET NETWORK_STATUS = %d WHERE NETWORK_STATUS = %d; UPDATE %s SET NETWORK_STATUS = %d WHERE NETWORK_STATUS = %d;", - MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_FAIL, MSG_NETWORK_SENDING, + "UPDATE %s SET NETWORK_STATUS = %d WHERE NETWORK_STATUS = %d;", + MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_FAIL, MSG_NETWORK_SENDING); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + //continue reset process for MSG_NETWORK_RETRIEVE_FAIL case + MSG_INFO("execQuery is failed"); + } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), + "UPDATE %s SET NETWORK_STATUS = %d WHERE NETWORK_STATUS = %d;", MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_RETRIEVE_FAIL, MSG_NETWORK_RETRIEVING); - if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) return MSG_ERR_DB_EXEC; MSG_END(); @@ -208,13 +158,34 @@ msg_error_t MsgStoResetNetworkStatus() return MSG_SUCCESS; } +#if 0 +msg_error_t MsgStoResetCBMessage() +{ + MSG_BEGIN(); + char sqlQuery[MAX_QUERY_LEN+1]; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s", + MSGFW_RECEIVED_CB_MSG_TABLE_NAME); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + MSG_DEBUG("Delete Received CB Msg Fail!!"); + return MSG_ERR_DB_EXEC; + } + + MSG_END(); + return MSG_SUCCESS; +} +#endif + msg_error_t MsgStoCleanAbnormalMmsData() { MSG_BEGIN(); - int rowCnt = 0, index = 2; // numbers of index - + int rowCnt = 0, index = 0; // numbers of index + MsgDbHandler *dbHandle = getDbHandle(); msg_message_id_t msgId; char sqlQuery[MAX_QUERY_LEN+1]; @@ -225,14 +196,14 @@ msg_error_t MsgStoCleanAbnormalMmsData() snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.MSG_ID, A.FILE_PATH FROM %s A, %s B WHERE A.MSG_ID = B.MSG_ID AND (B.SUB_TYPE = %d OR B.SUB_TYPE = %d OR B.SUB_TYPE = %d);", MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSG_SENDCONF_MMS, MSG_RETRIEVE_AUTOCONF_MMS, MSG_RETRIEVE_MANUALCONF_MMS); - msg_error_t err = dbHandle.getTable(sqlQuery, &rowCnt); + msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err == MSG_ERR_DB_NORECORD) { - dbHandle.freeTable(); + dbHandle->freeTable(); return MSG_SUCCESS; } else if (err != MSG_SUCCESS) { - MSG_DEBUG("%s", sqlQuery); - dbHandle.freeTable(); + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); return err; } @@ -241,13 +212,13 @@ msg_error_t MsgStoCleanAbnormalMmsData() { memset(filePath, 0x00, sizeof(filePath)); - msgId = dbHandle.getColumnToInt(index++); + msgId = dbHandle->getColumnToInt(index++); - dbHandle.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, filePath); + dbHandle->getColumnToString(index++, MSG_FILEPATH_LEN_MAX, filePath); if(strlen(filePath) > 1) { MSG_DEBUG("strlen(filePath) [%d]", strlen(filePath)); - MSG_DEBUG("filePath [%s]", filePath); + MSG_SEC_DEBUG("filePath [%s]", filePath); if(MsgGetFileSize(filePath) < 0) { // abnormal mms message @@ -259,25 +230,26 @@ msg_error_t MsgStoCleanAbnormalMmsData() } } - dbHandle.freeTable(); + dbHandle->freeTable(); MSG_END(); return MSG_SUCCESS; } + msg_error_t MsgStoCheckReadReportStatus(msg_message_id_t msgId) { MSG_BEGIN(); bool bReadReportRequested; bool bReadReportIsSent; - - bReadReportRequested = MsgStoCheckReadReportRequested(&dbHandle, msgId); + MsgDbHandler *dbHandle = getDbHandle(); + bReadReportRequested = MsgStoCheckReadReportRequested(dbHandle, msgId); if(bReadReportRequested == false) return MSG_ERR_READREPORT_NOT_REQUESTED; - bReadReportIsSent = MsgStoCheckReadReportIsSent(&dbHandle, msgId); + bReadReportIsSent = MsgStoCheckReadReportIsSent(dbHandle, msgId); if(bReadReportIsSent == true) return MSG_ERR_READREPORT_ALEADY_SENT; @@ -286,3 +258,612 @@ msg_error_t MsgStoCheckReadReportStatus(msg_message_id_t msgId) return MSG_SUCCESS; } + +msg_error_t MsgStoAutoDeleteConversation(msg_thread_id_t threadId, msg_id_list_s *msgIdList) +{ + MSG_BEGIN(); + MsgDbHandler *dbHandle = getDbHandle(); + msg_error_t err = MSG_SUCCESS; + + bool bAutoErase = false; + MsgSettingGetBool(MSG_AUTO_ERASE, &bAutoErase); + + if (bAutoErase) { + + MSG_DEBUG("threadId [%d]", threadId); + + //msg_id_list_s msgIdList; + int currentSmsCnt = 0; + int currentMmsCnt = 0; + int limitSmsCnt = 0; + int limitMmsCnt = 0; + + char sqlQuery[MAX_QUERY_LEN+1]; + + int rowCnt = 0, index = 0; + + //memset(msgIdList, 0x00, sizeof(msg_id_list_s)); + + // Get current count of messages + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + +#ifdef MSG_NOTI_INTEGRATION + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT COUNT(MSG_ID) FROM %s " + "WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND MAIN_TYPE = %d " + "UNION ALL " + "SELECT COUNT(MSG_ID) FROM %s " + "WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND MAIN_TYPE = %d AND SUB_TYPE NOT IN (%d, %d, %d);", + MSGFW_MESSAGE_TABLE_NAME, + threadId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE, MSG_SMS_TYPE, + MSGFW_MESSAGE_TABLE_NAME, + threadId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE, MSG_MMS_TYPE, MSG_DELIVERYIND_MMS, MSG_READRECIND_MMS, MSG_READORGIND_MMS); +#else + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT COUNT(MSG_ID) FROM %s " + "WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND MAIN_TYPE = %d " + "UNION ALL " + "SELECT COUNT(MSG_ID) FROM %s " + "WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND MAIN_TYPE = %d AND SUB_TYPE NOT IN (%d, %d, %d);", + MSGFW_MESSAGE_TABLE_NAME, + threadId, MSG_ALLBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE, MSG_SMS_TYPE, + MSGFW_MESSAGE_TABLE_NAME, + threadId, MSG_ALLBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE, MSG_MMS_TYPE, MSG_DELIVERYIND_MMS, MSG_READRECIND_MMS, MSG_READORGIND_MMS); +#endif + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + MSG_DEBUG("sqlQuery [%s]", sqlQuery); + return MSG_ERR_DB_PREPARE; + } + + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + currentSmsCnt = dbHandle->columnInt(0); + } else { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + currentMmsCnt = dbHandle->columnInt(0); + } else { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + + dbHandle->finalizeQuery(); + + MSG_DEBUG("currentSmsCnt [%d], currentMmsCnt [%d]", currentSmsCnt, currentMmsCnt); + + if (currentSmsCnt > 0 || currentMmsCnt > 0) { + limitSmsCnt = MsgSettingGetInt(MSG_SMS_LIMIT); + limitMmsCnt = MsgSettingGetInt(MSG_MMS_LIMIT); + + if (limitSmsCnt < 0 || limitMmsCnt < 0) { + MSG_DEBUG("limitSmsCnt [%d], limitMmsCnt [%d]", limitSmsCnt, limitMmsCnt); + return MSG_SUCCESS; + } + } else { // !(currentSmsCnt > 0 || currentMmsCnt > 0) + return MSG_SUCCESS; + } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + +#ifdef MSG_NOTI_INTEGRATION + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT DISTINCT(MSG_ID) FROM %s " + "WHERE MSG_ID IN " + "(SELECT MSG_ID FROM %s " + "WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND PROTECTED = 0 " + "AND MAIN_TYPE = %d ORDER BY MSG_ID ASC LIMIT %d) " + "OR MSG_ID IN " + "(SELECT MSG_ID FROM %s " + "WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND PROTECTED = 0 " + "AND MAIN_TYPE = %d AND SUB_TYPE NOT IN (%d, %d, %d) ORDER BY MSG_ID ASC LIMIT %d);", + MSGFW_MESSAGE_TABLE_NAME, + MSGFW_MESSAGE_TABLE_NAME, + threadId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE, + MSG_SMS_TYPE, ((currentSmsCnt-limitSmsCnt)>0)?(currentSmsCnt-limitSmsCnt):0, + MSGFW_MESSAGE_TABLE_NAME, + threadId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE, + MSG_MMS_TYPE, MSG_DELIVERYIND_MMS, MSG_READRECIND_MMS, MSG_READORGIND_MMS, ((currentMmsCnt-limitMmsCnt)>0)?(currentMmsCnt-limitMmsCnt):0); +#else + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT DISTINCT(MSG_ID) FROM %s " + "WHERE MSG_ID IN " + "(SELECT MSG_ID FROM %s " + "WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND PROTECTED = 0 " + "AND MAIN_TYPE = %d ORDER BY MSG_ID ASC LIMIT %d) " + "OR MSG_ID IN " + "(SELECT MSG_ID FROM %s " + "WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND PROTECTED = 0 " + "AND MAIN_TYPE = %d AND SUB_TYPE NOT IN (%d, %d, %d) ORDER BY MSG_ID ASC LIMIT %d);", + MSGFW_MESSAGE_TABLE_NAME, + MSGFW_MESSAGE_TABLE_NAME, + threadId, MSG_ALLBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE, + MSG_SMS_TYPE, ((currentSmsCnt-limitSmsCnt)>0)?(currentSmsCnt-limitSmsCnt):0, + MSGFW_MESSAGE_TABLE_NAME, + threadId, MSG_ALLBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE, + MSG_MMS_TYPE, MSG_DELIVERYIND_MMS, MSG_READRECIND_MMS, MSG_READORGIND_MMS, ((currentMmsCnt-limitMmsCnt)>0)?(currentMmsCnt-limitMmsCnt):0); +#endif + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); + + if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { + MSG_DEBUG("Fail to getTable()."); + dbHandle->freeTable(); + return err; + } + + if (rowCnt <= 0) { + MSG_DEBUG("rowCnt <= 0"); + dbHandle->freeTable(); + return MSG_SUCCESS; + } + + msgIdList->nCount = rowCnt; + + MSG_DEBUG("msgIdList.nCount [%d]", msgIdList->nCount); + + msgIdList->msgIdList = (msg_message_id_t *)new char[sizeof(msg_message_id_t) * rowCnt]; + + for (int i = 0; i < rowCnt; i++) { + msgIdList->msgIdList[i] = dbHandle->getColumnToInt(index++); + } + + dbHandle->freeTable(); + + // delete message + err = MsgStoDeleteMessageByList(msgIdList); + + //delete [] (char*)msgIdList.msgIdList; + + } else { + MSG_DEBUG("bAutoErase [%d]", bAutoErase); + } + + MSG_END(); + + return err; +} + + +msg_error_t MsgStoGetReplaceMsgId(MSG_MESSAGE_INFO_S *pMsgInfo) +{ + msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); + char sqlQuery[MAX_QUERY_LEN+1]; + + msg_thread_id_t convId = 0; + + /** Check if new address or not */ + if (MsgExistAddress(dbHandle, pMsgInfo, &convId) == true) { + MSG_DEBUG("Address Info. exists [%d]", convId); + + /** Find Replace Type Msg : Same Replace Type, Same Origin Address, Same Storage ID */ + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE SUB_TYPE = %d AND CONV_ID = %d AND STORAGE_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, pMsgInfo->msgType.subType, convId, pMsgInfo->storageId); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) { + pMsgInfo->msgId = dbHandle->columnInt(0); + } else { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + + dbHandle->finalizeQuery(); + } + + return err; +} + + +msg_error_t MsgStoAddWAPMsg(MSG_MESSAGE_INFO_S *pMsgInfo) +{ + msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); + MSG_PUSH_MESSAGE_S pushMsg = {}; + + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + int fileSize = 0; + + char* pFileData = NULL; + unique_ptr buf(&pFileData, unique_ptr_deleter); + + if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false) + return MSG_ERR_STORAGE_ERROR; + + MSG_DEBUG("fileSize : %d", fileSize); + + memcpy(&pushMsg, pFileData, fileSize); + + /** Delete temporary file */ + MsgDeleteFile(pMsgInfo->msgData); + + /** check pPushMsg data */ + + MSG_DEBUG("check pushMsg data"); + MSG_DEBUG("pushMsg.action : [%d]", pushMsg.action); + MSG_DEBUG("pushMsg.received : [%d]", pushMsg.received); + MSG_DEBUG("pushMsg.created : [%d]", pushMsg.created); + MSG_DEBUG("pushMsg.expires : [%d]", pushMsg.expires); + MSG_SEC_DEBUG("pushMsg.id : [%s]", pushMsg.id); + MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href); + MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents); + + bool bProceed = true; + + /** check validation of contents */ + if (MsgStoCheckPushMsgValidation(&pushMsg, &bProceed) != MSG_SUCCESS) { + MSG_DEBUG("Fail to check Push Message validation."); + } + + /** if validation check value is false */ + /** return and drop message. */ + if (bProceed == false) + return MSG_ERR_INVALID_MESSAGE; + + + /** Update Msg Text - remove */ + strncpy(pMsgInfo->msgText, pushMsg.href, MAX_MSG_TEXT_LEN); + + if (pushMsg.contents[0] != '\0') { + strncat(pMsgInfo->msgText, " ", MAX_MSG_TEXT_LEN - strlen(pMsgInfo->msgText)); + strncat(pMsgInfo->msgText, pushMsg.contents, MAX_MSG_TEXT_LEN - strlen(pMsgInfo->msgText)); + } + + pMsgInfo->dataSize = strlen(pMsgInfo->msgText); + + pMsgInfo->bTextSms = true; + pMsgInfo->folderId = MSG_INBOX_ID; + pMsgInfo->storageId = MSG_STORAGE_PHONE; + + msg_thread_id_t convId = 0; + + dbHandle->beginTrans(); + + if (pMsgInfo->nAddressCnt > 0) { + + err = MsgStoAddAddress(dbHandle, pMsgInfo, &convId); + + if (err != MSG_SUCCESS) { + dbHandle->endTrans(false); + return err; + } + + pMsgInfo->threadId = convId; + } + + /** get last row count for Message id */ + unsigned int rowId = 0; + + /** Add Message Table */ + rowId = MsgStoAddMessageTable(dbHandle, pMsgInfo); + + if (rowId <= 0) { + dbHandle->endTrans(false); + return MSG_ERR_DB_ROW; + } + + pMsgInfo->msgId = (msg_message_id_t)rowId; + + /** add msg_push_table */ + snprintf (sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %lu, %lu, ?, ?, ?)", + MSGFW_PUSH_MSG_TABLE_NAME, pMsgInfo->msgId, pushMsg.action, pushMsg.created, pushMsg.expires); + + if ((err = dbHandle->prepareQuery(sqlQuery)) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return err; + } + + dbHandle->bindText(pushMsg.id, 1); + + dbHandle->bindText(pushMsg.href, 2); + + dbHandle->bindText(pushMsg.contents, 3); + + if ((err = dbHandle->stepQuery()) != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + return err; + } + + dbHandle->finalizeQuery(); + + /** Update conversation table. */ + if (MsgStoUpdateConversation(dbHandle, convId) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } + + dbHandle->endTrans(true); + + return MSG_SUCCESS; +} + + +msg_error_t MsgStoAddCOWAPMsg(MSG_MESSAGE_INFO_S *pMsgInfo) +{ + msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); + char href[MAX_PUSH_CACHEOP_MAX_URL_LEN+1]; + char sqlQuery[MAX_QUERY_LEN+1]; + + int fileSize = 0; + + char* pFileData = NULL; + unique_ptr buf(&pFileData, unique_ptr_deleter); + + if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false) + return MSG_ERR_STORAGE_ERROR; + + MSG_PUSH_CACHEOP_S *pPushMsg; + + pPushMsg = (MSG_PUSH_CACHEOP_S*)pFileData; + + for (int i = 0; i < pPushMsg->invalObjectCnt; i++) { + + int msgid = -1; + + memset(href, 0x00, sizeof(href)); + strncpy(href, &(pPushMsg->invalObjectUrl[i][0]), MAX_PUSH_CACHEOP_MAX_URL_LEN); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf (sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE HREF LIKE '%%%s%%';", MSGFW_PUSH_MSG_TABLE_NAME, href); + + dbHandle->beginTrans(); + + err = dbHandle->prepareQuery(sqlQuery); + + if ((dbHandle->stepQuery() == MSG_ERR_DB_ROW) && err == MSG_SUCCESS) { + + msgid = dbHandle->columnInt(0); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID= %d;", MSGFW_PUSH_MSG_TABLE_NAME, msgid); + + /** Delete Message from Push table */ + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + continue; + } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgid); + + /** Delete Message from msg table */ + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + continue; + } + + /** Update all Address */ + if (MsgStoUpdateAllAddress() != MSG_SUCCESS) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + continue; + } + + /** Clear Conversation table */ + if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + continue; + } + } + + dbHandle->finalizeQuery(); + + dbHandle->endTrans(true); + } + + for (int i = 0; i < pPushMsg->invalServiceCnt; i++) { + + int msgid = -1; + + memset(href, 0x00, sizeof(href)); + strncpy(href, &(pPushMsg->invalObjectUrl[i][0]), MAX_PUSH_CACHEOP_MAX_URL_LEN); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE HREF LIKE '%%%s%%'", MSGFW_PUSH_MSG_TABLE_NAME, href); + + dbHandle->beginTrans(); + + err = dbHandle->prepareQuery(sqlQuery); + + if ((dbHandle->stepQuery() == MSG_ERR_DB_ROW) && err == MSG_SUCCESS) { + + msgid = dbHandle->columnInt(0); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID='%d'", MSGFW_PUSH_MSG_TABLE_NAME, msgid); + + /** Delete Message from Push table */ + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + continue; + } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgid); + + /** Delete Message from msg table */ + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + continue; + } + + /** Update all Address */ + if (MsgStoUpdateAllAddress() != MSG_SUCCESS) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + continue; + } + + /** Clear Address table */ + if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { + dbHandle->finalizeQuery(); + dbHandle->endTrans(false); + continue; + } + } + + dbHandle->finalizeQuery(); + + dbHandle->endTrans(true); + } + + /** delete temporary file */ + MsgDeleteFile(pMsgInfo->msgData); + + return MSG_SUCCESS; +} + + +msg_error_t MsgStoAddCBMsg(MSG_MESSAGE_INFO_S *pMsgInfo) +{ + msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); + unsigned int rowId = 0; + msg_thread_id_t convId = 0; + + char sqlQuery[MAX_QUERY_LEN+1]; + + dbHandle->beginTrans(); + + if (pMsgInfo->nAddressCnt > 0) { + err = MsgStoAddAddress(dbHandle, pMsgInfo, &convId); + + if (err != MSG_SUCCESS) { + dbHandle->endTrans(false); + return err; + } + + pMsgInfo->threadId = convId; + } + + /** Add Message Table */ + rowId = MsgStoAddMessageTable(dbHandle, pMsgInfo); + + if (rowId <= 0) { + dbHandle->endTrans(false); + return MSG_ERR_DB_ROW; + } + + /** Get CB Msg ID */ + unsigned short cbMsgId = (unsigned short)pMsgInfo->msgId; + + /** Add CB Msg in MSG_CBMSG_TABLE */ + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);", + MSGFW_CB_MSG_TABLE_NAME, rowId, cbMsgId); + + if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_DB_EXEC; + } + + /** Update conversation table. */ + if (MsgStoUpdateConversation(dbHandle, convId) != MSG_SUCCESS) { + dbHandle->endTrans(false); + return MSG_ERR_STORAGE_ERROR; + } + + dbHandle->endTrans(true); + + /** Assign Msg ID */ + pMsgInfo->msgId = (msg_message_id_t)rowId; + + return err; +} + + +msg_error_t MsgStoCheckPushMsgValidation(MSG_PUSH_MESSAGE_S *pPushMsg, bool *pbProceed) +{ + msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); + unsigned long oldExpireTime = 0; + int rowCnt = 0; + + char sqlQuery[MAX_QUERY_LEN+1]; + + /** is push message is expired?? */ + if (pPushMsg->received > pPushMsg->expires) { + MSG_DEBUG("Push Message is expired."); + pbProceed = false; + return err; + } + + if (pPushMsg->action == MSG_PUSH_SL_ACTION_EXECUTE_LOW) { + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT EXPIRES FROM %s WHERE ID = '%s' AND ACTION = %d", + MSGFW_PUSH_MSG_TABLE_NAME, pPushMsg->id, pPushMsg->action); + } else { + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT EXPIRES FROM %s WHERE ID = '%s'", + MSGFW_PUSH_MSG_TABLE_NAME, pPushMsg->id); + } + + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); + + if (rowCnt < 1) { + dbHandle->freeTable(); + return MSG_SUCCESS; + } + + oldExpireTime = dbHandle->getColumnToInt(1); + + dbHandle->freeTable(); + + if (pPushMsg->created < oldExpireTime) { + MSG_DEBUG("Push Message is expired."); + pbProceed = false; + return err; + } + + return err; +} + + +msg_error_t MsgStoUpdateAllAddress() +{ + msg_error_t err = MSG_SUCCESS; + MsgDbHandler *dbHandle = getDbHandle(); + int rowCnt = 0, index = 0; + char sqlQuery[MAX_QUERY_LEN+1]; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ADDRESS_ID FROM %s", MSGFW_ADDRESS_TABLE_NAME); + + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); + + if (err == MSG_ERR_DB_NORECORD) { + dbHandle->freeTable(); + return MSG_SUCCESS; + } else if ( err != MSG_SUCCESS) { + dbHandle->freeTable(); + return err; + } + + for (int i = 0; i < rowCnt; i++) { + + err = MsgStoUpdateConversation(dbHandle, index++); + + if (err != MSG_SUCCESS) + break; + } + + dbHandle->freeTable(); + + return err; +} + diff --git a/framework/submit-handler/MsgSubmitHandler.cpp b/framework/submit-handler/MsgSubmitHandler.cpp index 3fde433..fa0aff2 100755 --- a/framework/submit-handler/MsgSubmitHandler.cpp +++ b/framework/submit-handler/MsgSubmitHandler.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include @@ -19,6 +19,7 @@ #include "MsgDebug.h" #include "MsgUtilFile.h" +#include "MsgUtilStorage.h" #include "MsgException.h" #include "MsgGconfWrapper.h" #include "MsgPluginManager.h" @@ -26,13 +27,13 @@ #include "MsgSubmitHandler.h" + /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ msg_error_t MsgSubmitReq(MSG_REQUEST_INFO_S *pReqInfo, bool bScheduled) { msg_error_t err = MSG_SUCCESS; - static int reqId = 1; pReqInfo->reqId = reqId; @@ -40,11 +41,12 @@ msg_error_t MsgSubmitReq(MSG_REQUEST_INFO_S *pReqInfo, bool bScheduled) MSG_DEBUG("==== Msg ID = [%d] ====", pReqInfo->msgInfo.msgId); MSG_DEBUG("==== Folder ID = [%d] ====", pReqInfo->msgInfo.folderId); - MSG_DEBUG("==== Main Type = [%d] ====", pReqInfo->msgInfo.msgType.mainType); - MSG_DEBUG("==== Sub Type = [%d] ====", pReqInfo->msgInfo.msgType.subType); + MSG_INFO("==== Main Type = [%d] ====", pReqInfo->msgInfo.msgType.mainType); + MSG_INFO("==== Sub Type = [%d] ====", pReqInfo->msgInfo.msgType.subType); MSG_DEBUG("==== Class Type = [%d] ====", pReqInfo->msgInfo.msgType.classType); MSG_DEBUG("==== Message Data = [%s] ====", pReqInfo->msgInfo.msgData); - MSG_DEBUG("==== Message Text = [%s] ====", pReqInfo->msgInfo.msgText); + MSG_SEC_DEBUG("==== Message Text = [%s] ====", pReqInfo->msgInfo.msgText); + MSG_INFO("==== SIM Index = [%d] ====", pReqInfo->msgInfo.sim_idx); MSG_DEBUG("==== bSetting = [%d] ====", pReqInfo->sendOptInfo.bSetting); @@ -80,15 +82,17 @@ msg_error_t MsgSubmitReqSMS(MSG_REQUEST_INFO_S *pReqInfo) MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType); if (plg == NULL) - THROW(MsgException::PLUGIN_ERROR, "No plugin for %d type", mainType); + return MSG_ERR_NULL_POINTER; // If MSG ID > 0 -> MSG in DRAFT // Move Folder to OUTBOX if (pReqInfo->msgInfo.msgPort.valid == false) { pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID; - if (pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID)) - err = MsgStoUpdateMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo)); + if (pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID)) + err = MsgStoUpdateMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo)); + if (err != MSG_SUCCESS) + return err; } err = plg->submitReq(pReqInfo); @@ -96,19 +100,36 @@ msg_error_t MsgSubmitReqSMS(MSG_REQUEST_INFO_S *pReqInfo) return err; } - msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo) { msg_error_t err = MSG_SUCCESS; - + MsgDbHandler *dbHandle = getDbHandle(); MSG_RECIPIENTS_LIST_S pRecipientList; + MsgPlugin *sms_plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); + + if (sms_plg == NULL){ + return MSG_ERR_NULL_POINTER; + } + + int defaultNetworkSimId = 0; + + err = sms_plg->getDefaultNetworkSimId(&defaultNetworkSimId); + if (err != MSG_SUCCESS) { + MSG_ERR("getDefaultNetworkSimId is failed=[%d]", err); + return err; + } else if (pReqInfo->msgInfo.sim_idx != defaultNetworkSimId) { + MSG_ERR("It is not default network SIM ID, request SIM=[%d], activated SIM=[%d]", pReqInfo->msgInfo.sim_idx, defaultNetworkSimId); + return MSG_ERR_INVALID_PARAMETER; + + } + MSG_MAIN_TYPE_T msgMainType = pReqInfo->msgInfo.msgType.mainType; MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(msgMainType); if(!plg) { - MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL); + MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL); MSG_DEBUG("No Plugin for %d type", msgMainType); return MSG_ERR_INVALID_PLUGIN_HANDLE; @@ -126,82 +147,69 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo) // copy whole of MMS PDU filepath to msgData strncpy(fileName, pReqInfo->msgInfo.msgData, MAX_COMMON_INFO_SIZE); memset(pReqInfo->msgInfo.msgData, 0x00, MAX_MSG_DATA_LEN+1); - snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, MSG_IPC_DATA_PATH"%s", fileName); + snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, "%s%s", MSG_IPC_DATA_PATH, fileName); - MSG_DEBUG("JAVA MMS PDU filepath:%s", pReqInfo->msgInfo.msgData); + MSG_SEC_DEBUG("JAVA MMS PDU filepath:%s", pReqInfo->msgInfo.msgData); // submit request - plg->submitReq(pReqInfo); + err = plg->submitReq(pReqInfo); if(err != MSG_SUCCESS) { MSG_DEBUG("Update Network Status : [%d]", err); - MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo),MSG_NETWORK_SEND_FAIL); + MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo),MSG_NETWORK_SEND_FAIL); } return err; } else if((pReqInfo->msgInfo.msgType.subType == MSG_SENDREQ_MMS) || (pReqInfo->msgInfo.msgType.subType == MSG_FORWARD_MMS)) { - // update address list in the ase of existing message - if(pReqInfo->msgInfo.msgId > 0) - { - err = MsgStoGetOrgAddressList(&(pReqInfo->msgInfo)); - - if(err != MSG_SUCCESS) - MSG_DEBUG("[WARNING]MsgStoGetOrgAddressList returned not a MSG_SUCCESS"); - } - if(pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID)) { - MSG_ADDRESS_INFO_S addrInfo = {0,}; - int addrIdx = 0; - - err = MsgStoGetAddrInfo(pReqInfo->msgInfo.msgId, &addrInfo); - - if (err == MSG_SUCCESS) { - for (int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++) { - //if (pReqInfo->msgInfo.addressList[i].threadId == addrInfo.threadId) { - if (!strcmp(pReqInfo->msgInfo.addressList[i].addressVal, addrInfo.addressVal)) { - addrIdx = i; - MSG_DEBUG("addrIdx = %d, address = [%s]", addrIdx, pReqInfo->msgInfo.addressList[i].addressVal); - break; - } - } - } else { - MSG_DEBUG("[Error]MsgStoGetAddrInfo is failed"); - } - + MSG_DEBUG("Not New Message."); pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID; err = MsgStoUpdateMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo)); - - MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), pReqInfo->msgInfo.networkStatus); } else { - //new message case - MSG_DEBUG("New Message"); + MSG_DEBUG("New Message."); + pReqInfo->msgInfo.msgId = 0; pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID; err = MsgStoAddMessage(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo)); - //pReqInfo->msgInfo.msgId = 0; } } else if(pReqInfo->msgInfo.msgType.subType == MSG_READREPLY_MMS) { + msg_read_report_status_t readStatus; + err = MsgStoCheckReadReportStatus(pReqInfo->msgInfo.msgId); - if(err != MSG_SUCCESS) + if(err != MSG_SUCCESS) { + + MSG_INFO("msg id [%d], read report could NOT send [%d]", pReqInfo->msgInfo.msgId, err); return err; + } + + memcpy(&readStatus, pReqInfo->msgInfo.msgData, sizeof(msg_read_report_status_t)); + if (readStatus == MSG_READ_REPORT_REJECT_BY_USER) { + + MSG_INFO("msg id [%d], read report reject by user", pReqInfo->msgInfo.msgId); + + err = MsgStoSetReadReportSendStatus(pReqInfo->msgInfo.msgId, MMS_RECEIVE_READ_REPORT_NO_SENT); + + return err; + } err = MsgStoGetRecipientList(pReqInfo->msgInfo.msgId, &pRecipientList); if(err != MSG_SUCCESS) return MSG_ERR_PLUGIN_STORAGE; pReqInfo->msgInfo.nAddressCnt = pRecipientList.recipientCnt; + pReqInfo->msgInfo.addressList = pRecipientList.recipientAddr; - for(int i = 0; i < pRecipientList.recipientCnt; i++) - { - pReqInfo->msgInfo.addressList[i].addressType = pRecipientList.recipientAddr[i].addressType; - pReqInfo->msgInfo.addressList[i].recipientType = MSG_RECIPIENTS_TYPE_TO; - pReqInfo->msgInfo.addressList[i].contactId = pRecipientList.recipientAddr[i].contactId; - strncpy(pReqInfo->msgInfo.addressList[i].addressVal, pRecipientList.recipientAddr[i].addressVal, MAX_ADDRESS_VAL_LEN); - } +// for(int i = 0; i < pRecipientList.recipientCnt; i++) +// { +// pReqInfo->msgInfo.addressList[i].addressType = pRecipientList.recipientAddr[i].addressType; +// pReqInfo->msgInfo.addressList[i].recipientType = MSG_RECIPIENTS_TYPE_TO; +// pReqInfo->msgInfo.addressList[i].contactId = pRecipientList.recipientAddr[i].contactId; +// strncpy(pReqInfo->msgInfo.addressList[i].addressVal, pRecipientList.recipientAddr[i].addressVal, MAX_ADDRESS_VAL_LEN); +// } char subject[MAX_SUBJECT_LEN+1]; @@ -215,7 +223,7 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo) } else if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS) { - MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), pReqInfo->msgInfo.networkStatus); + MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), pReqInfo->msgInfo.networkStatus); } /* reject_msg_support */ @@ -232,7 +240,7 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo) case MSG_FORWARD_MMS: MsgDeleteFile(pReqInfo->msgInfo.msgData); memset(pReqInfo->msgInfo.msgData, 0x00, MAX_MSG_DATA_LEN+1); - snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pReqInfo->msgInfo.msgId); + snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, "%s%d.mms", MSG_DATA_PATH, pReqInfo->msgInfo.msgId); break; case MSG_READREPLY_MMS: @@ -251,12 +259,15 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo) /* reject_msg_support */ // Check SIM is present or not - MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(MSG_SIM_CHANGED); + char keyName[MAX_VCONFKEY_NAME_LEN]; + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pReqInfo->msgInfo.sim_idx); + MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); if(simStatus == MSG_SIM_STATUS_NOT_FOUND) { MSG_DEBUG("SIM is not present..."); - MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL); + MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL); return MSG_ERR_NO_SIM; } @@ -270,16 +281,15 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo) if (err != MSG_SUCCESS) { if(pReqInfo->msgInfo.msgType.subType == MSG_RETRIEVE_MMS ) - MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), MSG_NETWORK_RETRIEVE_FAIL); + MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_RETRIEVE_FAIL); else - MsgStoUpdateNetworkStatus(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL); + MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL); } return err; } - msg_error_t MsgCancelReq(msg_request_id_t reqId) { msg_error_t err = MSG_SUCCESS; @@ -292,9 +302,9 @@ msg_error_t MsgUpdateSentMsg(msg_message_id_t MsgId, msg_network_status_t Status { msg_error_t err = MSG_SUCCESS; +#ifdef MSG_MMS_KEEPCOPY bool bKeepCopy = true; -#ifdef MSG_MMS_KEEPCOPY MSG_SENDINGOPT_INFO_S sendOpt = {}; if (msgType.mainType == MSG_MMS_TYPE) @@ -308,18 +318,23 @@ msg_error_t MsgUpdateSentMsg(msg_message_id_t MsgId, msg_network_status_t Status ret = MsgSettingGetBool(MSG_KEEP_COPY, &bKeepCopy); } } -#endif - // Move Msg to SENTBOX if (Status == MSG_NETWORK_SEND_SUCCESS) { - MSG_DEBUG(" In Status == MSG_NETWORK_SEND_SUCCESS and bKeepCopy is [%d]", bKeepCopy); + MSG_DEBUG("In Status == MSG_NETWORK_SEND_SUCCESS and bKeepCopy is [%d]", bKeepCopy); if (bKeepCopy == true) err = MsgStoMoveMessageToFolder(MsgId, MSG_SENTBOX_ID); else err = MsgStoDeleteMessage(MsgId, false); } - +#else + // Move Msg to SENTBOX + if (Status == MSG_NETWORK_SEND_SUCCESS) + { + MSG_DEBUG("In Status == MSG_NETWORK_SEND_SUCCESS and bKeepCopy is true"); + err = MsgStoMoveMessageToFolder(MsgId, MSG_SENTBOX_ID); + } +#endif return err; } @@ -328,7 +343,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; diff --git a/framework/transaction-manager/MsgCmdHandlerFilter.cpp b/framework/transaction-manager/MsgCmdHandlerFilter.cpp index 7034931..614a9fa 100755 --- a/framework/transaction-manager/MsgCmdHandlerFilter.cpp +++ b/framework/transaction-manager/MsgCmdHandlerFilter.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "MsgDebug.h" @@ -29,6 +29,11 @@ int MsgAddFilterHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; // Get Filter Structure @@ -57,6 +62,11 @@ int MsgUpdateFilterHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; // Get Filter Structure @@ -85,6 +95,11 @@ int MsgDeleteFilterHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; // Get Filter Structure @@ -111,12 +126,56 @@ int MsgDeleteFilterHandler(const MSG_CMD_S *pCmd, char **ppEvent) } +int MsgSetFilterActivationHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + msg_error_t err = MSG_SUCCESS; + + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + int eventSize = 0; + + // Get Filter Structure + msg_filter_id_t *pFilterId = (msg_filter_id_t *)pCmd->cmdData; + + bool setFlag = false; + + memcpy(&setFlag, pCmd->cmdData+sizeof(msg_filter_id_t), sizeof(bool)); + + MSG_DEBUG("Filter id : %d", *pFilterId); + + // Delete Filter + err = MsgStoSetFilterActivation(*pFilterId, setFlag); + + if (err == MSG_SUCCESS) + { + MSG_DEBUG("Command Handle Success : MsgStoSetFilterActivation()"); + } + else + { + MSG_DEBUG("Command Handle Fail : MsgStoSetFilterActivation()"); + } + + // Make Event Data + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SET_FILTER_ACTIVATION, err, (void**)ppEvent); + + return eventSize; +} + + int MsgGetFilterListHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -132,7 +191,15 @@ int MsgGetFilterListHandler(const MSG_CMD_S *pCmd, char **ppEvent) // Encoding Filter List Data dataSize = MsgEncodeFilterList(&filterList, &encodedData); - delete [] filterList.msg_struct_info; + if (filterList.msg_struct_info) { + msg_struct_s *msg_struct; + for (int i = 0; i < filterList.nCount; i++) { + msg_struct = (msg_struct_s *)filterList.msg_struct_info[i]; + delete (MSG_FILTER_S *)msg_struct->data; + delete msg_struct; + } + g_free(filterList.msg_struct_info); + } } else { @@ -150,6 +217,11 @@ int MsgSetFilterOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; // Get Filter Flag @@ -180,8 +252,13 @@ int MsgGetFilterOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; diff --git a/framework/transaction-manager/MsgCmdHandlerSetting.cpp b/framework/transaction-manager/MsgCmdHandlerSetting.cpp index 5304c11..7a25234 100755 --- a/framework/transaction-manager/MsgCmdHandlerSetting.cpp +++ b/framework/transaction-manager/MsgCmdHandlerSetting.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "MsgDebug.h" @@ -20,6 +20,7 @@ #include "MsgUtilFunction.h" #include "MsgCppTypes.h" +using namespace std; /*================================================================================================== FUNCTION IMPLEMENTATION @@ -28,6 +29,11 @@ int MsgSetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; int eventType = -1; @@ -89,19 +95,43 @@ int MsgGetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0; int eventSize = 0; int eventType = -1; // Get Option Type - MSG_OPTION_TYPE_T* type = (MSG_OPTION_TYPE_T*)pCmd->cmdData; + MSG_OPTION_TYPE_T type = 0; + memcpy((void *)&type, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_OPTION_TYPE_T)); // Get Config Data MSG_SETTING_S setting; - setting.type = *type; + setting.type = type; + + msg_sim_slot_id_t simIndex = 0; + switch(setting.type) { + case MSG_CBMSG_OPT : + memcpy(&simIndex, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_OPTION_TYPE_T)), sizeof(msg_sim_slot_id_t)); + setting.option.cbMsgOpt.simIndex = simIndex; + break; + case MSG_VOICEMAIL_OPT : + memcpy(&simIndex, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_OPTION_TYPE_T)), sizeof(msg_sim_slot_id_t)); + setting.option.voiceMailOpt.simIndex = simIndex; + break; + case MSG_SMSC_LIST : + memcpy(&simIndex, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_OPTION_TYPE_T)), sizeof(msg_sim_slot_id_t)); + setting.option.smscList.simIndex = simIndex; + break; + default : + break; + } err = MsgGetConfigData(&setting); diff --git a/framework/transaction-manager/MsgCmdHandlerStorage.cpp b/framework/transaction-manager/MsgCmdHandlerStorage.cpp index a661a90..e28ce3d 100755 --- a/framework/transaction-manager/MsgCmdHandlerStorage.cpp +++ b/framework/transaction-manager/MsgCmdHandlerStorage.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include @@ -26,41 +26,88 @@ #include "MsgPluginManager.h" #include "MsgTransManager.h" #include "MsgCmdHandler.h" - +#include "MsgNotificationWrapper.h" +#include "MsgMutex.h" +#include /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ + +Mutex mx; +int g_job_cnt = 0; + +static gboolean __refresh_noti(void *data) +{ + mx.lock(); + + g_job_cnt--; + + if (g_job_cnt <= 0) { + MSG_DEBUG("## Refresh notification ##"); + if (MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, false, false) != MSG_SUCCESS) { + MSG_DEBUG("MsgRefreshNoti is failed"); + } + g_job_cnt = 0; + } + + mx.unlock(); + + return FALSE; + +} + int MsgAddMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; - // Get Message Info - MSG_MESSAGE_INFO_S* pMsgInfo = (MSG_MESSAGE_INFO_S*)pCmd->cmdData; + MSG_MESSAGE_INFO_S msgInfo; + MSG_SENDINGOPT_INFO_S sendOptInfo; + memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); + memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S)); - // Get Sending Option - MSG_SENDINGOPT_INFO_S* pSendOptInfo = (MSG_SENDINGOPT_INFO_S*)(pCmd->cmdData + sizeof(MSG_MESSAGE_INFO_S)); + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); - // Add Message - err = MsgStoAddMessage(pMsgInfo, pSendOptInfo); + MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo, &sendOptInfo); - if (err == MSG_SUCCESS) { - MSG_DEBUG("Command Handle Success : MsgStoAddMessage()"); + if(msgInfo.threadId) // threadId is not 0 : message restore from S-Cloud + { + err = MsgStoRestoreMessage(&msgInfo, &sendOptInfo); + + if (err == MSG_SUCCESS) { + MSG_DEBUG("Command Handle Success : MsgStoRestoreMessage()"); + + // Encoding Message ID + dataSize = MsgEncodeMsgId(&(msgInfo.msgId), &encodedData); + } else { + MSG_DEBUG("Command Handle Fail : MsgStoRestoreMessage()"); + } + } + else + { + // Add Message + msgInfo.msgId = 0; + err = MsgStoAddMessage(&msgInfo, &sendOptInfo); + if (err == MSG_SUCCESS) { + MSG_DEBUG("Command Handle Success : MsgStoAddMessage()"); // Encoding Message ID - dataSize = MsgEncodeMsgId(&(pMsgInfo->msgId), &encodedData); + dataSize = MsgEncodeMsgId(&(msgInfo.msgId), &encodedData); } else { MSG_DEBUG("Command Handle Fail : MsgStoAddMessage()"); } - - // Delete Temp File for Message Data - if (pMsgInfo->bTextSms == false) - MsgDeleteFile(pMsgInfo->msgData); //ipc + } //storage change CB msg_id_list_s msgIdList; @@ -68,11 +115,23 @@ int MsgAddMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); msgIdList.nCount = 1; - msgIds[0] = pMsgInfo->msgId; + msgIds[0] = msgInfo.msgId; msgIdList.msgIdList = msgIds; MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList); + // Update unread message status + if (msgInfo.folderId == MSG_INBOX_ID && msgInfo.bRead == false) { + mx.lock(); + g_job_cnt++; + g_timeout_add(300, __refresh_noti, NULL); + mx.unlock(); + } + + // Delete Temp File for Message Data + if (msgInfo.bTextSms == false) + MsgDeleteFile(msgInfo.msgData); //ipc + // Make Event Data eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_ADD_MSG, err, (void**)ppEvent); @@ -84,16 +143,30 @@ int MsgAddSyncMLMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; - int eventSize = 0; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + char* encodedData = NULL; + unique_ptr buf(&encodedData, unique_ptr_deleter); + + int dataSize = 0, eventSize = 0; int extId = 0, pinCode = 0; - MSG_MESSAGE_INFO_S msgInfo = {}; + MSG_MESSAGE_INFO_S msgInfo; + memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); + + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); memcpy(&extId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int)); memcpy(&pinCode, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), sizeof(int)); - memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(int)), sizeof(MSG_MESSAGE_INFO_S)); + MsgDecodeMsgInfo((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(int), &msgInfo); + + msgInfo.msgId = 0; // Add Message err = MsgStoAddSyncMLMessage(&msgInfo, extId, pinCode); @@ -101,6 +174,9 @@ int MsgAddSyncMLMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { MSG_DEBUG("Command Handle Success : MsgStoAddSyncMLMessage()"); + // Encoding Message ID + dataSize = MsgEncodeMsgId(&(msgInfo.msgId), &encodedData); + // broadcast to listener threads, here MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo); //storage change CB @@ -120,7 +196,7 @@ int MsgAddSyncMLMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) } // Make Event Data - eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_SYNCML_MSG, err, (void**)ppEvent); + eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_ADD_SYNCML_MSG, err, (void**)ppEvent); return eventSize; } @@ -130,16 +206,25 @@ int MsgUpdateMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; - // Get Message Info - MSG_MESSAGE_INFO_S* pMsgInfo = (MSG_MESSAGE_INFO_S*)pCmd->cmdData; + MSG_MESSAGE_INFO_S msgInfo; + MSG_SENDINGOPT_INFO_S sendOptInfo; + memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); + memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S)); + + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); - // Get Sending Option - MSG_SENDINGOPT_INFO_S* pSendOptInfo = (MSG_SENDINGOPT_INFO_S*)(pCmd->cmdData + sizeof(MSG_MESSAGE_INFO_S)); + MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo, &sendOptInfo); // Update Message - err = MsgStoUpdateMessage(pMsgInfo, pSendOptInfo); + err = MsgStoUpdateMessage(&msgInfo, &sendOptInfo); if (err == MSG_SUCCESS) MSG_DEBUG("Command Handle Success : MsgStoUpdateMessage()"); @@ -147,8 +232,8 @@ int MsgUpdateMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) MSG_DEBUG("Command Handle Fail : MsgStoUpdateMessage()"); // Delete Temp File for Message Data - if (pMsgInfo->bTextSms == false) - MsgDeleteFile(pMsgInfo->msgData); //ipc + if (msgInfo.bTextSms == false) + MsgDeleteFile(msgInfo.msgData); //ipc //storage change CB msg_id_list_s msgIdList; @@ -156,7 +241,7 @@ int MsgUpdateMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); msgIdList.nCount = 1; - msgIds[0] = pMsgInfo->msgId; + msgIds[0] = msgInfo.msgId; msgIdList.msgIdList = msgIds; MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); @@ -172,6 +257,11 @@ int MsgUpdateReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; msg_message_id_t msgId; @@ -183,6 +273,8 @@ int MsgUpdateReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) // Update Read Status err = MsgStoUpdateReadStatus(msgId, readStatus); + MSG_DEBUG("message id = [%d], readStatus = [%d]", msgId, readStatus); + if (err == MSG_SUCCESS) { MSG_DEBUG("Command Handle Success : MsgStoUpdateReadStatus()"); @@ -192,6 +284,17 @@ int MsgUpdateReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) MSG_DEBUG("Command Handle Fail : MsgStoUpdateReadStatus()"); } + //storage change CB + msg_id_list_s msgIdList; + msg_message_id_t msgIds[1]; + memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); + + msgIdList.nCount = 1; + msgIds[0] = msgId; + msgIdList.msgIdList = msgIds; + + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + // Make Event Data eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_READ, err, (void**)ppEvent); @@ -203,6 +306,11 @@ int MsgUpdateThreadReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; msg_thread_id_t threadId; @@ -216,12 +324,47 @@ int MsgUpdateThreadReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) if (unReadCnt > 0) { - err = MsgStoUpdateThreadReadStatus(threadId); + msg_id_list_s msgIdList; + memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); + + err = MsgStoUpdateThreadReadStatus(threadId, &msgIdList); - if (err == MSG_SUCCESS) + if (err == MSG_SUCCESS) { MSG_DEBUG("Command Handle Success : MsgStoUpdateThreadReadStatus()"); - else + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + } else { MSG_DEBUG("Command Handle Fail : MsgStoUpdateThreadReadStatus()"); + } + + if(msgIdList.msgIdList != NULL) + delete [] (char*)msgIdList.msgIdList; + } + + // delete report notification + if (err == MSG_SUCCESS) { + MsgDbHandler *dbHandle = getDbHandle(); + char tempAddr[MAX_ADDRESS_VAL_LEN+1]; + char sqlQuery[MAX_QUERY_LEN+1]; + + memset(tempAddr, 0x00, sizeof(tempAddr)); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT B.ADDRESS_VAL FROM %s A, %s B WHERE A.CONV_ID = B.CONV_ID AND A.CONV_ID = %d;" + , MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, threadId); + + err = dbHandle->prepareQuery(sqlQuery); + + if (err == MSG_SUCCESS) { + err = dbHandle->stepQuery(); + + if (err == MSG_ERR_DB_ROW) { + snprintf(tempAddr, sizeof(tempAddr), "%s", dbHandle->columnText(0)); + MSG_SEC_DEBUG("Updated address = %s", tempAddr); + MsgDeleteReportNotification(tempAddr); + err = MSG_SUCCESS; + } + } + + dbHandle->finalizeQuery(); } // Make Event Data @@ -236,6 +379,11 @@ int MsgUpdateProtectedStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; msg_message_id_t msgId; @@ -256,6 +404,17 @@ int MsgUpdateProtectedStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) MSG_DEBUG("Command Handle Fail : MsgStoUpdateProtectedStatus()"); } + //storage change CB + msg_id_list_s msgIdList; + msg_message_id_t msgIds[1]; + memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); + + msgIdList.nCount = 1; + msgIds[0] = msgId; + msgIdList.msgIdList = msgIds; + + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + // Make Event Data eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_PROTECTED, err, (void**)ppEvent); @@ -267,6 +426,11 @@ int MsgDeleteMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; int extId = 0; @@ -310,6 +474,11 @@ int MsgDeleteAllMessageInFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; msg_folder_id_t* folderId = (msg_folder_id_t*)pCmd->cmdData; @@ -341,10 +510,59 @@ int MsgDeleteAllMessageInFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent) } +int MsgDeleteMessageByListHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + msg_error_t err = MSG_SUCCESS; + + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + int eventSize = 0; + + msg_id_list_s msgIdList; + memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); + + msgIdList.nCount = *((int *)pCmd->cmdData); + + MSG_DEBUG("msgIdList.nCount [%d]", msgIdList.nCount); + + msg_message_id_t msgIds[msgIdList.nCount]; + memset(msgIds, 0x00, sizeof(msgIds)); + + msgIdList.msgIdList = msgIds; + + for (int i=0; icmdData) + (sizeof(int)*(i+1))); + } + + // Delete Message + err = MsgStoDeleteMessageByList(&msgIdList); + + if (err == MSG_SUCCESS) { + MSG_DEBUG("Command Handle Success : MsgStoDeleteMessageByList()"); + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList); + } else { + MSG_DEBUG("Command Handle Fail : MsgStoDeleteMessageByList()"); + } + + // Make Event Data + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_MESSAGE_BY_LIST, err, (void**)ppEvent); + + return eventSize; +} + + int MsgMoveMessageToFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; msg_message_id_t msgId; @@ -383,6 +601,11 @@ int MsgMoveMessageToStorageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; msg_message_id_t msgId; @@ -414,8 +637,13 @@ int MsgCountMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -450,8 +678,13 @@ int MsgCountMsgByTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -486,11 +719,16 @@ int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + // Get Message ID msg_message_id_t* msgId = (msg_message_id_t*)pCmd->cmdData; char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -501,6 +739,9 @@ int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S)); + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); + err = MsgStoGetMessage(*msgId, &msgInfo, &sendOptInfo); if (err == MSG_SUCCESS) @@ -526,7 +767,10 @@ int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) { - msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Folder ID msg_folder_id_t folderId; @@ -536,14 +780,15 @@ int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) memcpy(&sortRule, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_folder_id_t)), sizeof(MSG_SORT_RULE_S)); char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; +#if 0 // Get Message Common Info msg_struct_list_s folderViewList; - err = MsgStoGetFolderViewList(folderId, &sortRule, &folderViewList); +// err = MsgStoGetFolderViewList(folderId, &sortRule, &folderViewList); if (err == MSG_SUCCESS) { @@ -554,10 +799,14 @@ int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) MSG_DEBUG("dataSize [%d]", dataSize); - if (folderViewList.msg_struct_info != NULL) - { - delete [] folderViewList.msg_struct_info; - folderViewList.msg_struct_info = NULL; + if (folderViewList.msg_struct_info) { + msg_struct_s *msg_struct; + for (int i = 0; i < folderViewList.nCount; i++) { + msg_struct = (msg_struct_s *)folderViewList.msg_struct_info[i]; + delete (MSG_MESSAGE_HIDDEN_S *)msg_struct->data; + delete msg_struct; + } + g_free(folderViewList.msg_struct_info); } } else @@ -565,7 +814,7 @@ int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) MSG_DEBUG("Command Handle Fail : MsgStoGetFolderViewList()"); return err; } - +#endif // Make Event Data eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_FOLDERVIEWLIST, MSG_SUCCESS, (void**)ppEvent); @@ -577,6 +826,11 @@ int MsgAddFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; // Get Folder Info @@ -605,6 +859,11 @@ int MsgUpdateFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; // Get Folder Info @@ -633,6 +892,11 @@ int MsgDeleteFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; // Get Folder Info @@ -661,8 +925,13 @@ int MsgGetFolderListHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -678,7 +947,15 @@ int MsgGetFolderListHandler(const MSG_CMD_S *pCmd, char **ppEvent) // Encoding Folder List Data dataSize = MsgEncodeFolderList(&folderList, &encodedData); - delete [] folderList.msg_struct_info; + if (folderList.msg_struct_info) { + msg_struct_s *msg_struct; + for (int i = 0; i < folderList.nCount; i++) { + msg_struct = (msg_struct_s *)folderList.msg_struct_info[i]; + delete (MSG_FOLDER_INFO_S *)msg_struct->data; + delete msg_struct; + } + g_free(folderList.msg_struct_info); + } } else { @@ -696,6 +973,11 @@ int MsgInitSimBySatHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; // Sim Init - Later @@ -712,8 +994,13 @@ int MsgGetMsgTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -750,21 +1037,27 @@ int MsgGetMsgTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) { + msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + MSG_SORT_RULE_S sortRule = {0}; memcpy(&sortRule, pCmd->cmdData, sizeof(MSG_SORT_RULE_S)); char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; - +#if 0 // Get Thread View List msg_struct_list_s msgThreadViewList; - err = MsgStoGetThreadViewList(&sortRule, &msgThreadViewList); + //err = MsgStoGetThreadViewList(&sortRule, &msgThreadViewList); if (err == MSG_SUCCESS) { @@ -775,10 +1068,14 @@ int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) MSG_DEBUG("dataSize [%d]", dataSize); - if (msgThreadViewList.msg_struct_info != NULL) - { - delete [] msgThreadViewList.msg_struct_info; - msgThreadViewList.msg_struct_info = NULL; + if (msgThreadViewList.msg_struct_info) { + msg_struct_s *msg_struct; + for (int i = 0; i < folderList.nCount; i++) { + msg_struct = (msg_struct_s *)msgThreadViewList.msg_struct_info[i]; + delete (MSG_THREAD_VIEW_S *)msg_struct->data; + delete msg_struct; + } + g_free(msgThreadViewList.msg_struct_info); } } else @@ -786,7 +1083,7 @@ int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) MSG_DEBUG("Command Handle Fail : MsgStoGetThreadViewList()"); return err; } - +#endif // Make Event Data eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_THREADVIEWLIST, err, (void**)ppEvent); @@ -798,18 +1095,23 @@ int MsgGetConversationViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + msg_thread_id_t threadId; memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_thread_id_t)); char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; - +#if 0 msg_struct_list_s convViewList; - err = MsgStoGetConversationViewList(threadId, &convViewList); + //err = MsgStoGetConversationViewList(threadId, &convViewList); if (err == MSG_SUCCESS) { @@ -820,17 +1122,21 @@ int MsgGetConversationViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) MSG_DEBUG("dataSize [%d]", dataSize); - if (convViewList.msg_struct_info != NULL) - { - delete [] convViewList.msg_struct_info; - convViewList.msg_struct_info = NULL; + if (convViewList.msg_struct_info) { + msg_struct_s *msg_struct; + for (int i = 0; i < convViewList.nCount; i++) { + msg_struct = (msg_struct_s *)convViewList.msg_struct_info[i]; + delete (MSG_CONVERSATION_VIEW_S *)msg_struct->data; + delete msg_struct; + } + g_free(convViewList.msg_struct_info); } } else { MSG_DEBUG("Command Handle Fail : MsgStoGetConversationViewList()"); } - +#endif // Make Event Data eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_CONVERSATIONVIEWLIST, err, (void**)ppEvent); @@ -842,10 +1148,17 @@ int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + msg_thread_id_t threadId; + bool bIncludeProtect = false; bool isSyncMLMsg = false; memcpy(&threadId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_thread_id_t)); + memcpy(&bIncludeProtect, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_thread_id_t)), sizeof(bool)); int eventSize = 0; @@ -854,7 +1167,7 @@ int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_id_list_s msgIdList; memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); - err = MsgStoDeleteThreadMessageList(threadId, &msgIdList); + err = MsgStoDeleteThreadMessageList(threadId, bIncludeProtect, &msgIdList); if (err == MSG_SUCCESS) { MSG_DEBUG("Command Handle Success : MsgStoDeleteThreadMessageList()"); @@ -871,6 +1184,8 @@ int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent) else { MSG_DEBUG("Command Handle Fail : MsgStoDeleteThreadMessageList()"); + if(msgIdList.msgIdList != NULL) + delete [] (char*)msgIdList.msgIdList; } // Make Event Data @@ -884,13 +1199,18 @@ int MsgCountMsgByContactHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + // Get From address MSG_THREAD_LIST_INDEX_S addrInfo; memcpy(&addrInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_THREAD_LIST_INDEX_S)); char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -924,19 +1244,26 @@ int MsgGetQuickPanelDataHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + // Get Message ID msg_quickpanel_type_t* type = (msg_quickpanel_type_t*)pCmd->cmdData; char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; // Get Message MSG_MESSAGE_INFO_S msgInfo; - memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); + err = MsgStoGetQuickPanelData(*type, &msgInfo); if (err == MSG_SUCCESS) @@ -962,6 +1289,11 @@ int MsgResetDatabaseHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; // Reset DB @@ -983,8 +1315,13 @@ int MsgGetMemSizeHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1006,10 +1343,21 @@ int MsgBackupMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; + char path[MSG_FILEPATH_LEN_MAX+1] = {0,}; + msg_message_backup_type_t type; + + 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)); - err = MsgStoBackupMessage(); + MSG_DEBUG("type = %d, path = %s", type, path); + err = MsgStoBackupMessage(type, path); if (err == MSG_SUCCESS) MSG_DEBUG("Command Handle Success : MsgBackupMessageHandler()"); else @@ -1026,14 +1374,36 @@ int MsgRestoreMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; + msg_id_list_s *msgIdList = NULL; + 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, &msgIdList); - if (err == MSG_SUCCESS) + if (err == MSG_SUCCESS) { MSG_DEBUG("Command Handle Success : MsgStoRestoreMessage()"); - else + + if (msgIdList) { + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, msgIdList); + + if (msgIdList->msgIdList) + free(msgIdList->msgIdList); + + free(msgIdList); + msgIdList = NULL; + } else { + MSG_DEBUG("Not Exist msg id list to restore"); + } + + } else MSG_DEBUG("Command Handle Fail : MsgStoRestoreMessage()"); // Make Event Data @@ -1047,26 +1417,41 @@ int MsgGetReportStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + // Get Message ID msg_message_id_t* msgId = (msg_message_id_t*)pCmd->cmdData; + MSG_MESSAGE_TYPE_S msgType = {0,}; char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; - MSG_REPORT_STATUS_INFO_S reportStatus; + MSG_REPORT_STATUS_INFO_S *reportStatus = NULL; + int report_count = 0; - memset(&reportStatus, 0x00, sizeof(MSG_REPORT_STATUS_INFO_S)); + if (MsgStoGetMsgType(*msgId, &msgType) != MSG_SUCCESS) + MSG_DEBUG("MsgStoGetMsgType is failed"); - err = MsgStoGetReportStatus(*msgId, &reportStatus); + if (msgType.mainType == MSG_SMS_TYPE) { + err = MsgStoGetSmsReportStatus(*msgId, &report_count, &reportStatus); + } else if (msgType.mainType == MSG_MMS_TYPE) { + err = MsgStoGetMmsReportStatus(*msgId, &report_count, &reportStatus); + } else { + MSG_DEBUG("Message Type is unknown!"); + err = MSG_ERR_INVALID_MSG_TYPE; + } if (err == MSG_SUCCESS) { MSG_DEBUG("Command Handle Success : MsgGetReportStatusHandler()"); // Encoding Report Status Data - dataSize = MsgEncodeReportStatus(&reportStatus, &encodedData); + dataSize = MsgEncodeReportStatus(reportStatus, report_count, &encodedData); } else { @@ -1084,18 +1469,29 @@ int MsgGetThreadIdByAddressHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + MSG_MESSAGE_INFO_S msgInfo; memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); + int *addrCnt = (int *)pCmd->cmdData; MSG_DEBUG("*addrCnt [%d]", *addrCnt); msgInfo.nAddressCnt = *addrCnt; - for(int i=0; i<(*addrCnt); i++) + + msgInfo.addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S) * msgInfo.nAddressCnt]; + + for(int i=0; icmdData+sizeof(int)+(sizeof(MSG_ADDRESS_INFO_S)*i)), sizeof(MSG_ADDRESS_INFO_S)); char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1127,8 +1523,13 @@ int MsgGetThreadInfoHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int dataSize = 0; int eventSize = 0; @@ -1156,3 +1557,393 @@ 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; + unique_ptr buf(&encodedData, unique_ptr_deleter); + + 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; + unique_ptr buf(&encodedData, unique_ptr_deleter); + + 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; + unique_ptr buf(&encodedData, unique_ptr_deleter); + + 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; + unique_ptr buf(&encodedData, unique_ptr_deleter); + + 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; + unique_ptr buf(&encodedData, unique_ptr_deleter); + + 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; + + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + int eventSize = 0; + + // Get Message Info + MSG_PUSH_EVENT_INFO_S* pPushEvent = (MSG_PUSH_EVENT_INFO_S*)pCmd->cmdData; + + // Add Message + err = MsgStoAddPushEvent(pPushEvent); + + if (err == MSG_SUCCESS) { + MSG_DEBUG("Command Handle Success : MsgStoAddPushEvent()"); + } else { + MSG_DEBUG("Command Handle Fail : MsgStoAddPushEvent()"); + } + + // Make Event Data + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_PUSH_EVENT, err, (void**)ppEvent); + + return eventSize; +} + +int MsgDeletePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + msg_error_t err = MSG_SUCCESS; + + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + int eventSize = 0; + + // Get Message Info + MSG_PUSH_EVENT_INFO_S* pPushEvent = (MSG_PUSH_EVENT_INFO_S*)pCmd->cmdData; + + // Add Message + err = MsgStoDeletePushEvent(pPushEvent); + + if (err == MSG_SUCCESS) { + MSG_DEBUG("Command Handle Success : MsgStoDeletePushEvent()"); + } else { + MSG_DEBUG("Command Handle Fail : MsgStoDeletePushEvent()"); + } + + // Make Event Data + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_PUSH_EVENT, err, (void**)ppEvent); + + return eventSize; +} + +int MsgUpdatePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + msg_error_t err = MSG_SUCCESS; + + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + int eventSize = 0; + + // Get Message Info + MSG_PUSH_EVENT_INFO_S* pSrc = (MSG_PUSH_EVENT_INFO_S*)pCmd->cmdData; + MSG_PUSH_EVENT_INFO_S* pDst = (MSG_PUSH_EVENT_INFO_S*)(pCmd->cmdData + sizeof(MSG_PUSH_EVENT_INFO_S)); + + // Add Message + err = MsgStoUpdatePushEvent(pSrc, pDst); + + if (err == MSG_SUCCESS) { + MSG_DEBUG("Command Handle Success : MsgStoUpdatePushEvent()"); + } else { + MSG_DEBUG("Command Handle Fail : MsgStoUpdatePushEvent()"); + } + + // Make Event Data + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_PUSH_EVENT, err, (void**)ppEvent); + + return eventSize; +} + +int MsgAddSimMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + msg_error_t err = MSG_SUCCESS; + + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + int eventSize = 0; + + MSG_MESSAGE_INFO_S msgInfo; + MSG_SENDINGOPT_INFO_S sendOptInfo; + memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); + memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S)); + + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); + + MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo); + + int *simIdList = NULL; + int listSize = 0; + char *offset = NULL; + offset = ((char *)pCmd->cmdData) + sizeof(MSG_MESSAGE_INFO_S) + (sizeof(MSG_ADDRESS_INFO_S) * msgInfo.nAddressCnt); + + listSize = *(int*)offset; + offset += sizeof(int); + MSG_DEBUG("listSize [%d]", listSize); + + simIdList = (int *)offset; + + MSG_DEBUG("simIdList[0] [%d]", simIdList[0]); + + // Add Message +#if 0 // Not to broadcast callback here. + bool isReplaceMsg = false; + + if (msgInfo.msgId <= 0) + msgInfo.msgId = 0; + else + isReplaceMsg = true; +#else + if (msgInfo.msgId <= 0) + msgInfo.msgId = 0; +#endif + + msg_message_id_t msg_id = MsgStoAddSimMessage(&msgInfo, simIdList, listSize); + + if (msg_id > 0) { + MSG_DEBUG("Command Handle Success : MsgStoAddSimMessage()"); + +#if 0 // Not to broadcast callback here. + //storage change CB + msg_id_list_s msgIdList; + msg_message_id_t msgIds[1]; + memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); + + msgIdList.nCount = 1; + msgIds[0] = msgInfo.msgId; + msgIdList.msgIdList = msgIds; + + if (isReplaceMsg) + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + else + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList); +#endif + } else { + MSG_DEBUG("Command Handle Fail : MsgStoAddSimMessage()"); + err = MSG_ERR_INVALID_MESSAGE; + } + + // Delete Temp File for Message Data + if (msgInfo.bTextSms == false) + MsgDeleteFile(msgInfo.msgData); //ipc + + // Make Event Data + eventSize = MsgMakeEvent((const void *)&msg_id, sizeof(msg_message_id_t), MSG_EVENT_ADD_SIM_MSG, err, (void**)ppEvent); + + return eventSize; +} + + +int MsgUpdateIMSIHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + msg_error_t err = MSG_SUCCESS; + + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + int eventSize = 0; + + int sim_idx = 0; + memcpy(&sim_idx, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int)); + + // Add Message + err = MsgStoUpdateIMSI(sim_idx); + + if (err == MSG_SUCCESS) { + MSG_DEBUG("Command Handle Success : MsgStoUpdatePushEvent()"); + } else { + MSG_DEBUG("Command Handle Fail : MsgStoUpdatePushEvent()"); + } + + // Make Event Data + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_UPDATE_IMSI, err, (void**)ppEvent); + + return eventSize; +} diff --git a/framework/transaction-manager/MsgCmdHandlerTransport.cpp b/framework/transaction-manager/MsgCmdHandlerTransport.cpp index 113e6ff..7d5e884 100755 --- a/framework/transaction-manager/MsgCmdHandlerTransport.cpp +++ b/framework/transaction-manager/MsgCmdHandlerTransport.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include @@ -29,9 +29,11 @@ #include "MsgStorageHandler.h" #include "MsgTransManager.h" #include "MsgPluginManager.h" +#include "MsgUtilStorage.h" +#include "MsgAlarm.h" #include "MsgCmdHandler.h" +#include "MsgDevicedWrapper.h" -#include /*================================================================================================== FUNCTION IMPLEMENTATION @@ -41,16 +43,26 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; bool bNewMsg = true; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + int eventSize = 0; MSG_REQUEST_INFO_S reqInfo = {0,}; MSG_PROXY_INFO_S proxyInfo = {0,}; + reqInfo.msgInfo.addressList = NULL; + unique_ptr addressListBuf(&reqInfo.msgInfo.addressList, unique_ptr_deleter); + // Get Message Request - memcpy(&reqInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_REQUEST_INFO_S)); + memcpy(&reqInfo.reqId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_request_id_t)); // Storing Request ID, Proxy Info for Sent Status CNF - memcpy(&proxyInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_REQUEST_INFO_S)), sizeof(MSG_PROXY_INFO_S)); + memcpy(&proxyInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_request_id_t)), sizeof(MSG_PROXY_INFO_S)); + + MsgDecodeMsgInfo((char *)(pCmd->cmdData+sizeof(msg_request_id_t)+sizeof(MSG_PROXY_INFO_S)), &reqInfo.msgInfo, &reqInfo.sendOptInfo); if (reqInfo.msgInfo.msgId > 0) bNewMsg = false; @@ -89,7 +101,7 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent) pFileName = strstr(reqInfo.msgInfo.msgData, "MSG_"); strncpy(trId.pduFileName, pFileName, MAX_COMMON_INFO_SIZE); - MSG_DEBUG("java MMS msg trId:%s filepath:%s ",trId.id, reqInfo.msgInfo.msgData); + MSG_SEC_DEBUG("java MMS msg trId:%s filepath:%s ",trId.id, reqInfo.msgInfo.msgData); MsgTransactionManager* tm = MsgTransactionManager::instance(); tm->setJavaMMSList(&trId); @@ -99,50 +111,37 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent) eventSize = MsgMakeEvent(&reqId, sizeof(reqId), MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent); /* reject_msg_support */ - if(((reqInfo.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS) && + if (((reqInfo.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS) && (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE))) 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; - MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList); + if ((err == MSG_SUCCESS || err != MSG_ERR_PLUGIN_STORAGE) && reqInfo.msgInfo.msgPort.valid == false) { + if (bNewMsg) { + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList); + } else { + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + } + } else { + MSG_DEBUG("No need to broadcast storage change CB"); } - return eventSize; -} - -int MsgCancelReqHandler(const MSG_CMD_S *pCmd, char **ppEvent) -{ - msg_error_t err = MSG_SUCCESS; - - int eventSize = 0; - - // Get Request ID - msg_request_id_t* reqId = (msg_request_id_t*)pCmd->cmdData; - - // Cancel Request - err = MsgCancelReq(*reqId); + memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); - if (err == MSG_SUCCESS) + MsgStoAutoDeleteConversation(reqInfo.msgInfo.threadId, &msgIdList); + if (msgIdList.msgIdList) { - MSG_DEBUG("Command Handle Success : MsgSubCancelReq()"); + MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_DELETE, &msgIdList); + delete [] (char*)msgIdList.msgIdList; } - else - { - MSG_DEBUG("Command Handle Fail : MsgSubCancelReq()"); - } - - // Make Event Data - eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_CANCEL_REQ, err, (void**)ppEvent); return eventSize; } @@ -151,8 +150,10 @@ int MsgCancelReqHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if( !pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Message Request int listenerFd = *((int*) pCmd->cmdData); @@ -171,8 +172,10 @@ int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if( !pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Message Request MSG_CMD_REG_INCOMING_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MSG_CB_S*) pCmd->cmdData; @@ -191,8 +194,10 @@ int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if( !pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Message Request MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S*) pCmd->cmdData; @@ -207,12 +212,60 @@ int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEven return eventSize; } +int MsgRegIncomingPushMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + // input check + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + // Get Message Request + MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S*) pCmd->cmdData; + MSG_DEBUG("Registering incoming Push Msg CB for fd:%d mType:%d appId:%s", pCmdData->listenerFd, pCmdData->msgType, pCmdData->appId); + + // storing dst fd in list + MsgTransactionManager::instance()->setPushMsgCB(pCmdData); + //MsgTransactionManager::instance()->sendPendigPushMsg(pCmdData); + + + // Make Event Data + int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_PUSH_MSG_CB, MSG_SUCCESS, (void**)ppEvent); + + return eventSize; +} + + + +int MsgRegIncomingCBMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + // input check + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + // Get Message Request + MSG_CMD_REG_INCOMING_CB_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_CB_MSG_CB_S*) pCmd->cmdData; + MSG_DEBUG("Registering incoming CB Msg CB for fd:%d mType:%d: bSave: %d", pCmdData->listenerFd, pCmdData->msgType, pCmdData->bsave); + + // storing dst fd in list + MsgTransactionManager::instance()->setCBMsgCB(pCmdData); + + // Make Event Data + int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_INCOMING_CB_MSG_CB, MSG_SUCCESS, (void**)ppEvent); + + return eventSize; +} + int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if( !pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Message Request MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S*) pCmd->cmdData; @@ -231,8 +284,10 @@ int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if( !pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Message Request MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_LBS_MSG_CB_S*) pCmd->cmdData; @@ -251,8 +306,10 @@ int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if( !pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Message Request MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCmdData = (MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S*) pCmd->cmdData; @@ -271,8 +328,10 @@ int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEven int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if( !pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Message Request int listenerFd = *((int*) pCmd->cmdData); @@ -288,11 +347,35 @@ int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) } +int MsgRegIncomingReportMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + // input check + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + // Get Message Request + int listenerFd = *((int*) pCmd->cmdData); + MSG_DEBUG("Registering report msg incoming CB for %d", listenerFd); + + // storing dst fd in list + MsgTransactionManager::instance()->setReportMsgCB(listenerFd); + + // Make Event Data + int eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_REG_REPORT_MSG_INCOMING_CB, MsgException::SUCCESS, (void**)ppEvent); + + return eventSize; +} + + int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if (!pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Message Request MSG_SENT_STATUS_S* pStatus = (MSG_SENT_STATUS_S*) pCmd->cmdData; @@ -302,9 +385,8 @@ int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) // storing dst fd in list MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(pStatus->reqId); - // when no sent status cb is found (in case of mobile tracker) - if (!prxInfo) - { + // when no sent status cb is found + if (!prxInfo) { return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent); } @@ -344,37 +426,86 @@ int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; int eventSize = 0; bool sendNoti = true; + bool isClass2msg = false; // input check - if (!pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Incoming Message MSG_MESSAGE_INFO_S msgInfo; memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); - memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S)); + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); - // normal process - err = MsgHandleIncomingMsg(&msgInfo, &sendNoti); + MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo); // broadcast to listener threads, here msg_id_list_s msgIdList; - msg_message_id_t msgIds[1]; + msg_message_id_t msgIds[2]; + msg_message_id_t class2msgId = 0; memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); - msgIdList.nCount = 1; - msgIds[0] = msgInfo.msgId; - msgIdList.msgIdList = msgIds; +#ifdef MSG_NOTI_INTEGRATION + if (msgInfo.msgType.classType == MSG_CLASS_2) { + class2msgId = msgInfo.msgId; + isClass2msg = true; + } +#endif + + // normal process + err = MsgHandleIncomingMsg(&msgInfo, &sendNoti); + + if (isClass2msg == true) { + msgIdList.nCount = 2; + msgIds[0] = class2msgId; + msgIds[1] = msgInfo.msgId; + msgIdList.msgIdList = msgIds; + isClass2msg = false; + } else { + msgIdList.nCount = 1; + msgIds[0] = msgInfo.msgId; + msgIdList.msgIdList = msgIds; + } if (sendNoti == true) { MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo); - MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList); + if (msgInfo.msgType.subType > MSG_TYPE0_SMS && msgInfo.msgType.subType < MSG_WAP_SI_SMS) { // if it is replacement message. + MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + } else { + MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList); + } + } else if (msgInfo.msgPort.valid || (msgInfo.msgType.subType >= MSG_MWI_VOICE_SMS && msgInfo.msgType.subType <= MSG_MWI_OTHER_SMS)) { + MsgTransactionManager::instance()->broadcastIncomingMsgCB(err, &msgInfo); } else if (msgInfo.folderId == MSG_SPAMBOX_ID) { MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList); + } else if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS || msgInfo.msgType.subType == MSG_DELIVERYIND_MMS) { + MsgTransactionManager::instance()->broadcastReportMsgCB(err, MSG_REPORT_TYPE_DELIVERY, &msgInfo); + } else if (msgInfo.msgType.subType == MSG_READORGIND_MMS) { + MsgTransactionManager::instance()->broadcastReportMsgCB(err, MSG_REPORT_TYPE_READ, &msgInfo); } + memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); + MsgStoAutoDeleteConversation(msgInfo.threadId, &msgIdList); + if (msgIdList.msgIdList) + { + MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_DELETE, &msgIdList); + delete [] (char*)msgIdList.msgIdList; + } + +#ifdef FEATURE_SMS_CDMA + eventSize = MsgMakeEvent(&msgInfo.msgId, sizeof(msg_message_id_t), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent); +#else eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent); +#endif + + if (msgInfo.bTextSms == false) { + MsgDeleteFile(msgInfo.msgData); //ipc + memset(msgInfo.msgData, 0x00, sizeof(msgInfo.msgData)); + } MSG_END(); @@ -387,11 +518,21 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; int eventsize = 0; - MSG_MESSAGE_INFO_S msgInfo = {0}; + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + MSG_MESSAGE_INFO_S msgInfo; msg_request_id_t reqID; - memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S)); - memcpy(&reqID, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_request_id_t)); + memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); + + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); + + memcpy(&reqID, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_request_id_t)); + MsgDecodeMsgInfo((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_request_id_t), &msgInfo); MSG_DEBUG(" pMsg = %s, pReqId = %d ", msgInfo.msgData, reqID); MSG_DEBUG(" msgtype subtype is [%d]", msgInfo.msgType.subType); @@ -405,21 +546,43 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) msgIds[0] = msgInfo.msgId; msgIdList.msgIdList = msgIds; - err = MsgStoGetAddrInfo(msgInfo.msgId, &(msgInfo.addressList[0])); + MSG_ADDRESS_INFO_S *tmpAddr = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; + memset(tmpAddr, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + err = MsgStoGetAddrInfo(msgInfo.msgId, tmpAddr); if (err == MSG_SUCCESS) { MSG_DEBUG("MmsStoGetAddrInfo() success."); msgInfo.nAddressCnt = 1; } else { + msgInfo.nAddressCnt = 0; MSG_DEBUG("MmsStoGetAddrInfo() fail."); } - if(msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { + if (msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { + + /* PLM P141008-05143 : Notification.Ind address is 1, but MMS retreived Conf address is correct. + So adding code for comparing exist address and new address and replace with new address(MMSconf) address */ + if (msgInfo.nAddressCnt == 1 && msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS && (g_strcmp0(tmpAddr->addressVal, msgInfo.addressList[0].addressVal) != 0)) { + MSG_WARN("Address of NotiInd and MMSConf are different!!, Replace [NotiInd : %s] from [MMSConf : %s]", tmpAddr->addressVal, msgInfo.addressList[0].addressVal); + memset(tmpAddr->addressVal, 0x00, MAX_ADDRESS_VAL_LEN); + strncpy(tmpAddr->addressVal, msgInfo.addressList[0].addressVal, MAX_ADDRESS_VAL_LEN); + } + + if (msgInfo.addressList) { + delete[] msgInfo.addressList; + msgInfo.addressList = NULL; + } + + msgInfo.addressList = tmpAddr; + + MSG_SUB_TYPE_T recv_sub_type = msgInfo.msgType.subType; // Check retrieve mode to determine broadcast type err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID); - if(err != MSG_SUCCESS) - return err; + if (err != MSG_SUCCESS) { + MSG_DEBUG("MsgHandleMmsConfIncomingMsg failed."); + return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)ppEvent); + } MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData; @@ -431,19 +594,30 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(msgInfo.msgData, 0x00, sizeof(MMS_RECV_DATA_S)); } - eventsize = MsgMakeEvent(&msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, msgInfo.networkStatus, (void**)ppEvent); - // broadcast to listener threads, here MsgTransactionManager::instance()->broadcastMMSConfCB(msgInfo.networkStatus, &msgInfo, pMmsRecvData); - MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + + // determine broadcast type with retrieve mode + if (recv_sub_type == MSG_RETRIEVE_AUTOCONF_MMS) + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList); + else + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + + // make return event + eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_SUCCESS, (void**)ppEvent); + } else if (msgInfo.msgType.subType == MSG_SENDREQ_MMS || msgInfo.msgType.subType == MSG_SENDCONF_MMS) { + if (msgInfo.addressList) { + delete[] msgInfo.addressList; + msgInfo.addressList = NULL; + } + + msgInfo.addressList = tmpAddr; + MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(reqID); - // when no sent status cb is found (in case of mobile tracker) - if (!prxInfo) { - MSG_DEBUG("prxInfo is NULL"); - eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent); - } else { + // when no sent status cb is found + if (prxInfo) { // No need to update javaMMS sent messages javamms_list& listenerList = MsgTransactionManager::instance()->getJavaMMSList(); javamms_list::iterator it = listenerList.begin(); @@ -453,7 +627,7 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL && msgInfo.msgType.subType == MSG_SENDREQ_MMS) { for ( ; it != listenerList.end() ; it++) { if (strstr(it->pduFileName, "JAVA")) { - MSG_DEBUG("JAVA MMS fileName:%s", it->pduFileName); + MSG_SEC_DEBUG("JAVA MMS fileName:%s", it->pduFileName); MsgDeleteFile(it->pduFileName); // ipc listenerList.erase(it); goto __BYPASS_UPDATE; @@ -464,30 +638,43 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) MMS_RECV_DATA_S* pMmsRecvData = (MMS_RECV_DATA_S*)msgInfo.msgData; for ( ; it != listenerList.end() ; it++) { - if(!strcmp(it->id, pMmsRecvData->szTrID)) { - MSG_DEBUG("find sent JAVA MMS message trId:%s from listener list trId:%s",pMmsRecvData->szTrID, it->id); + if (!strcmp(it->id, pMmsRecvData->szTrID)) { + MSG_SEC_DEBUG("find sent JAVA MMS message trId:%s from listener list trId:%s",pMmsRecvData->szTrID, it->id); MsgDeleteFile(it->pduFileName); // ipc listenerList.erase(it); goto __BYPASS_UPDATE; } } } + } else { + MSG_DEBUG("prxInfo is NULL"); } err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID); - if(err != MSG_SUCCESS) - return err; + if (err != MSG_SUCCESS) { + return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)ppEvent); + } __BYPASS_UPDATE: if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL) { MSG_DEBUG("message-dialog: send fail"); - MsgInsertTicker("Sending multimedia message failed.", SENDING_MULTIMEDIA_MESSAGE_FAILED); + MsgInsertTicker("Sending multimedia message failed.", SENDING_MULTIMEDIA_MESSAGE_FAILED, true, msgInfo.msgId); +// MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_NORMAL_SOUND_PLAY); } else { MSG_DEBUG("message-dialog: send success"); - MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT); - MSG_DEBUG("Enter MsgAddPhoneLog() : msgInfo.addressList[0].addressVal [%s]", msgInfo.addressList[0].addressVal); + bool bTTS = false; + + if (MsgSettingGetBool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &bTTS) != MSG_SUCCESS) { + MSG_DEBUG("MsgSettingGetBool is failed."); + } + + if (bTTS) { + MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT, false, 0); + } + + MSG_SEC_DEBUG("Enter MsgAddPhoneLog() : msgInfo.addressList[0].addressVal [%s]", msgInfo.addressList[0].addressVal); MsgAddPhoneLog(&msgInfo); } @@ -495,39 +682,128 @@ __BYPASS_UPDATE: if (prxInfo->handleAddr == 0) { // just making data which will be passed to plugin. it indicates "handling evt success" MsgTransactionManager::instance()->delProxyInfo(reqID); + } else { - return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent); - } - - unsigned int ret[3] = {0}; //3// reqid, status, object + unsigned int ret[3] = {0}; //3// reqid, status, object - ret[0] = reqID; - ret[1] = msgInfo.networkStatus; - ret[2] = prxInfo->handleAddr; + ret[0] = reqID; + ret[1] = msgInfo.networkStatus; + ret[2] = prxInfo->handleAddr; - // Make Event Data for APP - eventsize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent); + // Make Event Data for APP + eventsize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent); - // Send to listener thread, here - MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize); + // Send to listener thread, here + MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize); - MsgTransactionManager::instance()->delProxyInfo(reqID); + MsgTransactionManager::instance()->delProxyInfo(reqID); + } } - msgInfo.bTextSms = true; + eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_SUCCESS, (void**)ppEvent); MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + } else { + //To avoid prevent memory leak.. this case will not occur. eventsize will be return as 0. + if (tmpAddr) { + delete[] tmpAddr; + tmpAddr = NULL; + } } MSG_END(); return eventsize; } +int MsgIncomingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + MSG_BEGIN(); + + int eventSize = 0; + + // input check + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + MSG_PUSH_MESSAGE_DATA_S pushData; + memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S)); + + // Get Incoming Message + memcpy(&pushData, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_PUSH_MESSAGE_DATA_S)); + + + + // broadcast to listener threads, here + MsgTransactionManager::instance()->broadcastPushMsgCB(MSG_SUCCESS, &pushData); + + // Make Event Data + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, MSG_SUCCESS, (void**)ppEvent); + + MSG_END(); + return eventSize; +} + +int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + MSG_BEGIN(); + + msg_error_t err = MSG_SUCCESS; + int eventSize = 0; + + // input check + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + // Get Incoming Message + MSG_CB_MSG_S cbMsg; + memset(&cbMsg, 0x00, sizeof(MSG_CB_MSG_S)); + + memcpy(&cbMsg, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_CB_MSG_S)); + + MSG_MESSAGE_INFO_S msgInfo; + memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); + + msgInfo.addressList = NULL; + unique_ptr addressListBuf(&msgInfo.addressList, unique_ptr_deleter); + + MsgDecodeMsgInfo((char *)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_CB_MSG_S), &msgInfo); + + MSG_DEBUG("CB MSG ADDRESS COUNT=%d", msgInfo.nAddressCnt); + + if (MsgStoAddCBMsg(&msgInfo) != MSG_SUCCESS) { + MSG_DEBUG("MsgStoAddCBMsg is fail"); + } + + MsgInsertNotification(&msgInfo); + MsgChangePmState(); + + msg_id_list_s msgIdList; + msg_message_id_t msgIds[1]; + memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); + + msgIdList.nCount = 1; + msgIds[0] = (msg_message_id_t)msgInfo.msgId; + msgIdList.msgIdList = msgIds; + MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_INSERT, &msgIdList); + MsgTransactionManager::instance()->broadcastCBMsgCB(err, &cbMsg); + + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)ppEvent); + + MSG_END(); + + return eventSize; +} int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if (!pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } MSG_SYNCML_MESSAGE_DATA_S syncMLData; memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S)); @@ -552,8 +828,10 @@ int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) int eventSize = 0; // input check - if (!pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } MSG_LBS_MESSAGE_DATA_S lbsData; memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S)); @@ -576,7 +854,7 @@ int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int eventSize = 0; @@ -584,8 +862,10 @@ int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent) int extId = 0; // input check - if (!pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } // Get Data memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t)); @@ -615,8 +895,10 @@ int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent) { // input check - if (!pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } msg_storage_change_type_t storageChangeType; @@ -627,12 +909,19 @@ int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent) memcpy(&storageChangeType, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_storage_change_type_t)); char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); int eventSize = 0; MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgInfo.msgId); + if (msgInfo.msgType.mainType == MSG_TYPE_SMS) { + if (storageChangeType == MSG_STORAGE_CHANGE_UPDATE) + MsgStoUpdateMessage(&msgInfo, NULL); + else if (storageChangeType == MSG_STORAGE_CHANGE_DELETE) + MsgStoDeleteMessage(msgInfo.msgId, true); + } + // broadcast to listener threads, here msg_id_list_s msgIdList; msg_message_id_t msgIds[1]; @@ -649,3 +938,103 @@ int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent) return eventSize; } + +int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + msg_error_t err = MSG_SUCCESS; + int eventSize = 0; + + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + // Get the msgIdList of sending failed message. + int *failed_msg_list = NULL; + int count = 0; + unique_ptr failed_list(&failed_msg_list, unique_ptr_deleter); + + + err = MsgStoGetFailedMessage(&failed_msg_list, &count); + if (err != MSG_SUCCESS) { + MSG_DEBUG("MsgStoGetFailedMessage() Error!! [%d]", err); + } + + for(int i=0; i < count ; ++i) + { + MSG_REQUEST_INFO_S reqInfo = {0}; + reqInfo.msgInfo.addressList = NULL; + unique_ptr addressListBuf(&reqInfo.msgInfo.addressList, unique_ptr_deleter); + reqInfo.msgInfo.msgId = failed_msg_list[i]; + err = MsgStoGetMessage(reqInfo.msgInfo.msgId, &(reqInfo.msgInfo), &(reqInfo.sendOptInfo)); + + if (err != MSG_SUCCESS) { + MSG_DEBUG("MsgStoGetMessage() Error!! [%d]", err); + } + + reqInfo.msgInfo.networkStatus = MSG_NETWORK_SENDING; + + 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; + + err = MsgSubmitReq(&reqInfo, false); + + if (err == MSG_SUCCESS) { + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + if (err == MSG_SUCCESS) + MSG_DEBUG("MsgSubmitReq() Success"); + else + MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err); + } else { + MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err); + } + } + + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_RESEND_MESSAGE, err, (void**)ppEvent); + + MSG_END(); + return eventSize; +} + +#ifdef FEATURE_SMS_CDMA +int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent) +{ + MSG_BEGIN(); + + msg_error_t err = MSG_SUCCESS; + int eventSize = 0; + + // input check + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + + // Get Incoming Message + bool bInsert; + memcpy(&bInsert, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(bool)); + + msg_message_id_t msgId; + memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(bool)), sizeof(msg_message_id_t)); + + MSG_UNIQUE_INDEX_S p_msg; + memcpy(&p_msg, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(bool)+sizeof(msg_message_id_t)), sizeof(MSG_UNIQUE_INDEX_S)); + + MSG_DEBUG("Decoded Teleservice Msg Id = [%d]", p_msg.tele_msgId); + MSG_DEBUG("Decoded Address = [%s]", p_msg.address); + MSG_DEBUG("Decoded Sub Address = [%s]", p_msg.sub_address); + + err = MsgCheckUniqueness(bInsert, msgId, &p_msg); + + eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_CHECK_UNIQUENESS, err, (void**)ppEvent); + + MSG_END(); + + return eventSize; +} +#endif diff --git a/framework/transaction-manager/MsgTransManager.cpp b/framework/transaction-manager/MsgTransManager.cpp index 6e23018..e6ffc38 100755 --- a/framework/transaction-manager/MsgTransManager.cpp +++ b/framework/transaction-manager/MsgTransManager.cpp @@ -1,23 +1,24 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include #include #include #include +#include #include @@ -29,21 +30,27 @@ #include "MsgIpcSocket.h" #include "MsgGconfWrapper.h" #include "MsgUtilFunction.h" +#include "MsgUtilFile.h" +#include "MsgLbs.h" #include "MsgCmdHandler.h" #include "MsgSettingHandler.h" #include "MsgStorageHandler.h" #include "MsgPluginManager.h" #include "MsgTransManager.h" -/*================================================================================================== - FUNCTION IMPLEMENTATION -==================================================================================================*/ -void MsgContactChangedCallback() +#define MSG_CHECK_PRIVILEGE + +void MsgMakeErrorEvent(MSG_CMD_TYPE_T cmdType, msg_error_t errType, int *pEventSize, char **ppEvent) { - msg_id_list_s msgIdList; - memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); + if (*ppEvent) delete [] *ppEvent; + + *pEventSize = sizeof(MSG_EVENT_S); + *ppEvent = new char[sizeof(MSG_EVENT_S)]; - MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_CONTACT, &msgIdList); + MSG_EVENT_S* pMsgEvent = (MSG_EVENT_S*)*ppEvent; + + pMsgEvent->eventType = cmdType; + pMsgEvent->result = errType; } /*================================================================================================== @@ -53,10 +60,9 @@ MsgTransactionManager* MsgTransactionManager::pInstance = NULL; MsgIpcServerSocket MsgTransactionManager::servSock; -MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv() +MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv(), eventQueue() { sentMsgMap.clear(); - statusCBFdMap.clear(); newMsgCBList.clear(); newMMSConfMsgCBList.clear(); @@ -93,24 +99,29 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv() handlerMap[MSG_CMD_GET_FILTERLIST] = &MsgGetFilterListHandler; handlerMap[MSG_CMD_SET_FILTER_OPERATION] = &MsgSetFilterOperationHandler; handlerMap[MSG_CMD_GET_FILTER_OPERATION] = &MsgGetFilterOperationHandler; + handlerMap[MSG_CMD_SET_FILTER_ACTIVATION] = &MsgSetFilterActivationHandler; handlerMap[MSG_CMD_GET_MSG_TYPE] = &MsgGetMsgTypeHandler; handlerMap[MSG_CMD_SUBMIT_REQ] = &MsgSubmitReqHandler; - handlerMap[MSG_CMD_CANCEL_REQ] = &MsgCancelReqHandler; handlerMap[MSG_CMD_REG_SENT_STATUS_CB] = &MsgRegSentStatusCallbackHandler; handlerMap[MSG_CMD_REG_STORAGE_CHANGE_CB] = &MsgRegStorageChangeCallbackHandler; handlerMap[MSG_CMD_REG_INCOMING_MSG_CB] = &MsgRegIncomingMsgCallbackHandler; handlerMap[MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB] = &MsgRegIncomingMMSConfMsgCallbackHandler; handlerMap[MSG_CMD_REG_INCOMING_SYNCML_MSG_CB] = &MsgRegIncomingSyncMLMsgCallbackHandler; + handlerMap[MSG_CMD_REG_INCOMING_PUSH_MSG_CB] = &MsgRegIncomingPushMsgCallbackHandler; + handlerMap[MSG_CMD_REG_INCOMING_CB_MSG_CB] = &MsgRegIncomingCBMsgCallbackHandler; handlerMap[MSG_CMD_REG_INCOMING_LBS_MSG_CB] = &MsgRegIncomingLBSMsgCallbackHandler; handlerMap[MSG_CMD_REG_SYNCML_MSG_OPERATION_CB] = &MsgRegSyncMLMsgOperationCallbackHandler; + handlerMap[MSG_CMD_REG_REPORT_MSG_INCOMING_CB] = &MsgRegIncomingReportMsgCallbackHandler; handlerMap[MSG_CMD_PLG_SENT_STATUS_CNF] = &MsgSentStatusHandler; handlerMap[MSG_CMD_PLG_STORAGE_CHANGE_IND] = &MsgStorageChangeHandler; handlerMap[MSG_CMD_PLG_INCOMING_MSG_IND] = &MsgIncomingMsgHandler; handlerMap[MSG_CMD_PLG_INCOMING_MMS_CONF] = &MsgIncomingMMSConfMsgHandler; + handlerMap[MSG_CMD_PLG_INCOMING_PUSH_IND] = &MsgIncomingPushMsgHandler; + handlerMap[MSG_CMD_PLG_INCOMING_CB_IND] = &MsgIncomingCBMsgHandler; handlerMap[MSG_CMD_PLG_INCOMING_SYNCML_IND] = &MsgIncomingSyncMLMsgHandler; handlerMap[MSG_CMD_PLG_INCOMING_LBS_IND] = &MsgIncomingLBSMsgHandler; @@ -136,7 +147,6 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv() handlerMap[MSG_CMD_GET_THREAD_ID_BY_ADDRESS] = &MsgGetThreadIdByAddressHandler; handlerMap[MSG_CMD_GET_THREAD_INFO] = &MsgGetThreadInfoHandler; - handlerMap[MSG_CMD_GET_SMSC_OPT] = &MsgGetConfigHandler; handlerMap[MSG_CMD_GET_CB_OPT] = &MsgGetConfigHandler; handlerMap[MSG_CMD_GET_SMS_SEND_OPT] = &MsgGetConfigHandler; @@ -156,6 +166,17 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv() handlerMap[MSG_CMD_SET_VOICE_MSG_OPT] = &MsgSetConfigHandler; handlerMap[MSG_CMD_SET_GENERAL_MSG_OPT] = &MsgSetConfigHandler; handlerMap[MSG_CMD_SET_MSG_SIZE_OPT] = &MsgSetConfigHandler; + + handlerMap[MSG_CMD_ADD_PUSH_EVENT] = &MsgAddPushEventHandler; + handlerMap[MSG_CMD_DELETE_PUSH_EVENT] = &MsgDeletePushEventHandler; + handlerMap[MSG_CMD_UPDATE_PUSH_EVENT] = &MsgUpdatePushEventHandler; + handlerMap[MSG_CMD_DELETE_MESSAGE_BY_LIST] = &MsgDeleteMessageByListHandler; + handlerMap[MSG_CMD_ADD_SIM_MSG] = &MsgAddSimMessageHandler; + handlerMap[MSG_CMD_PLG_RESEND_MESSAGE] = &MsgResendMessageHandler; +#ifdef FEATURE_SMS_CDMA + handlerMap[MSG_CMD_PLG_CHECK_UNIQUENESS] = &MsgCheckUniquenessHandler; +#endif + handlerMap[MSG_CMD_UPDATE_IMSI] = &MsgUpdateIMSIHandler; } @@ -174,6 +195,11 @@ MsgTransactionManager* MsgTransactionManager::instance() return pInstance; } +static void* worker_event_queue(void* arg) +{ + MsgTransactionManager::instance()->workerEventQueue(); + return NULL; +} void MsgTransactionManager::run() { @@ -184,6 +210,17 @@ void MsgTransactionManager::run() MSG_DEBUG("Start Transaction Manager"); + // Set Msg FW Ready Flag + if(MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, true) != MSG_SUCCESS) + MSG_DEBUG("MsgSettingSetBool FAIL : VCONFKEY_MSG_SERVER_READY"); + MSG_INFO("### VCONFKEY_MSG_SERVER_READY ###"); + + /* running worker for plg task */ + pthread_t tv; + if (pthread_create (&tv, NULL, &worker_event_queue, NULL) != 0) { + THROW(MsgException::SERVER_READY_ERROR, "cannot create thread [%d]", errno); + } + while(1) { readfds = servSock.fdSet(); @@ -192,11 +229,10 @@ void MsgTransactionManager::run() MSG_DEBUG("Wait For Select() : nfds %d", nfds); // set Status; - setTMStatus(); +// setTMStatus(); - if( select(nfds, &readfds, NULL, NULL, NULL) == -1) - { - THROW(MsgException::SELECT_ERROR, strerror(errno)); + if(select(nfds, &readfds, NULL, NULL, NULL) == -1) { + THROW(MsgException::SELECT_ERROR, "select error : %s", g_strerror(errno)); } try @@ -256,8 +292,7 @@ MSG_PROXY_INFO_S* MsgTransactionManager::getProxyInfo(int reqId) if (it == sentMsgMap.end()) { - //THROW(MsgException::SENT_STATUS_ERROR, "No submit request for %d", reqId); - MSG_DEBUG("No sent status cb found (exception: mobile tracker)"); + MSG_DEBUG("No sent status cb found"); return NULL; } @@ -277,6 +312,55 @@ void MsgTransactionManager::delProxyInfo(int reqId) sentMsgMap.erase(it); } +void MsgTransactionManager::workerEventQueue() +{ + MSG_CMD_S* pCmd = NULL; + int (*pfHandler)(const MSG_CMD_S*, char**) = NULL; + char* pEventData = NULL; + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); + + int fd = -1; + int eventSize = 0; + + while (1) { + mx.lock(); + while (!eventQueue.front(&pCmd)) { /* if no item, wait */ + MSG_DEBUG ("waiting for task"); + cv.wait(mx.pMutex()); + } + eventQueue.pop_front(); /* pop it from queue*/ + mx.unlock(); + + if (!pCmd) { + MSG_FATAL("pCmd NULL"); + continue; + } + + memcpy (&fd, pCmd->cmdCookie, sizeof(int)); + if (fd < 0 ) { + MSG_FATAL("fd [%d] < 0", fd); + g_free (pCmd); pCmd = NULL; + continue; + } + pfHandler = handlerMap[pCmd->cmdType]; + if (!pfHandler) { + MSG_FATAL("No handler for %d", pCmd->cmdType); + MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_INVALID_PARAMETER, &eventSize, &pEventData); + } else { + // run handler function + eventSize = pfHandler(pCmd, &pEventData); + + if (eventSize == 0 || pEventData == NULL) { + MSG_FATAL("event size[%d] = 0 or event data = NULL", eventSize); + MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_INVALID_PARAMETER, &eventSize, &pEventData); + } + } + + MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize); + servSock.write(fd, pEventData, eventSize); + g_free (pCmd); pCmd = NULL; + } +} void MsgTransactionManager::handleRequest(int fd) { @@ -285,8 +369,9 @@ void MsgTransactionManager::handleRequest(int fd) MSG_DEBUG("Event from fd %d", fd); char* buf = NULL; - AutoPtr wrap(&buf); - int len; + unique_ptr wrap(&buf, unique_ptr_deleter); + + int len = 0; int ret = servSock.read(fd, &buf, &len); if( ret == CLOSE_CONNECTION_BY_SIGNAL || ret == CLOSE_CONNECTION_BY_USER || ret < 0) @@ -296,11 +381,11 @@ void MsgTransactionManager::handleRequest(int fd) return; } - if (len == 0) - THROW(MsgException::INVALID_RESULT, "read buffer size = 0"); + if (len <= 0) + THROW(MsgException::INVALID_RESULT, "read buffer size <= 0"); char* pEventData = NULL; - AutoPtr eventBuf(&pEventData); + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); int eventSize = 0; @@ -311,46 +396,64 @@ void MsgTransactionManager::handleRequest(int fd) if (pCmd->cmdType > MSG_CMD_NUM) THROW(MsgException::OUT_OF_RANGE, "request CMD is not defined"); - if (pCmd->cmdType < MSG_CMD_GET_REPORT_STATUS) - { - // check privilege - if (checkPrivilege(pCmd->cmdType, pCmd->cmdCookie) == false) - { + // check privilege +// if (checkPrivilege(pCmd->cmdType, pCmd->cmdCookie) == false) { + if (checkPrivilege(fd, pCmd->cmdType) == false) { + MSG_DEBUG("No Privilege rule. Not allowed."); #ifdef MSG_CHECK_PRIVILEGE - eventSize = sizeof(MSG_EVENT_S); + MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_PERMISSION_DENIED, &eventSize, &pEventData); - pEventData = new char[eventSize]; + MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize); + servSock.write(fd, pEventData, eventSize); - MSG_EVENT_S* pMsgEvent = (MSG_EVENT_S*)pEventData; - - pMsgEvent->eventType = pCmd->cmdType; - pMsgEvent->result = MSG_ERR_SECURITY_ERROR; - - MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize); - servSock.write(fd, pEventData, eventSize); - - return; + return; #endif - } } // determine the handler based on pCmd->cmdType int (*pfHandler)(const MSG_CMD_S*, char**) = NULL; - pfHandler = handlerMap[pCmd->cmdType]; - - if (!pfHandler) - THROW(MsgException::INVALID_PARAM, "No handler for %d", pCmd->cmdType); - - // run handler function - eventSize = pfHandler(pCmd, &pEventData); - - if (eventSize == 0 || pEventData == NULL) - THROW(MsgException::INVALID_RESULT, "event size = 0 or event data = NULL"); - - MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize); + switch (pCmd->cmdType) { + case MSG_CMD_PLG_SENT_STATUS_CNF: + case MSG_CMD_PLG_STORAGE_CHANGE_IND: + case MSG_CMD_PLG_INCOMING_MSG_IND: + case MSG_CMD_PLG_INCOMING_MMS_CONF: + case MSG_CMD_PLG_INCOMING_SYNCML_IND: + case MSG_CMD_PLG_INCOMING_LBS_IND: + case MSG_CMD_PLG_INIT_SIM_BY_SAT: + case MSG_CMD_PLG_INCOMING_PUSH_IND: + case MSG_CMD_PLG_INCOMING_CB_IND: { + + MSG_CMD_S* pCmdDup = (MSG_CMD_S*) calloc (1, len); /* pCmdDup should be freed afterward */ + if (pCmdDup != NULL) { + memcpy (pCmdDup, pCmd, len); + memcpy (pCmdDup->cmdCookie, &fd, sizeof(int)); /* Now, cmdCookie keeps fd for return */ + + mx.lock(); /* aquire lock before adding cmd */ + eventQueue.push_back(pCmdDup); + cv.signal(); /* wake up worker */ + mx.unlock(); + } + break; + } + default: + pfHandler = handlerMap[pCmd->cmdType]; + if (!pfHandler) { + MSG_FATAL("No handler for %d", pCmd->cmdType); + MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_INVALID_PARAMETER, &eventSize, &pEventData); + } else { + // run handler function + eventSize = pfHandler(pCmd, &pEventData); + + if (eventSize == 0 || pEventData == NULL) { + MSG_FATAL("event size[%d] = 0 or event data = NULL", eventSize); + MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_INVALID_PARAMETER, &eventSize, &pEventData); + } + } - servSock.write(fd, pEventData, eventSize); + MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize); + servSock.write(fd, pEventData, eventSize); + } MSG_END(); } @@ -380,6 +483,11 @@ void MsgTransactionManager::cleanup(int fd) // remove sent status callback for fd statusCBFdMap.erase(fd); + MSG_DEBUG("After erase fd [%d], statusCBFdMap has below.", fd); + fd_map::iterator it = statusCBFdMap.begin(); + for (; it!=statusCBFdMap.end(); ++it) + MSG_DEBUG("[%d]", it->first); + // remove all newMsgCBs for fd newmsg_list::iterator newmsg_it = newMsgCBList.begin(); @@ -440,6 +548,39 @@ void MsgTransactionManager::cleanup(int fd) } } + // remove all newPushMsgCBs for fd + pushmsg_list::iterator pushmsg_it = newPushMsgCBList.begin(); + + while (pushmsg_it != newPushMsgCBList.end()) + { + if (pushmsg_it->listenerFd == fd) + { + pushmsg_it = newPushMsgCBList.erase(pushmsg_it); + } + else + { + ++pushmsg_it; + } + } + + // remove all newCBMsgCBs for fd + cbmsg_list::iterator cbmsg_it = newCBMsgCBList.begin(); + //bool bSave = false; + + while (cbmsg_it != newCBMsgCBList.end()) + { + if (cbmsg_it->listenerFd == fd) + { + cbmsg_it = newCBMsgCBList.erase(cbmsg_it); + } + else + { + //if (cbmsg_it->bsave == true) + // bSave = true; + ++cbmsg_it; + } + } + // remove all operationSyncMLMsgCBs for fd syncmlop_list::iterator syncmlop_it = operationSyncMLMsgCBList.begin(); @@ -458,75 +599,115 @@ void MsgTransactionManager::cleanup(int fd) // remove storage change callback for fd storageChangeFdMap.erase(fd); - MSG_END(); -} + MSG_DEBUG("After erase fd [%d], storageChangeFdMap has below.", fd); + it = storageChangeFdMap.begin(); + for (; it!=storageChangeFdMap.end(); ++it) + MSG_DEBUG("[%d]", it->first); + // remove report msg incoming callback for fd + reportMsgCBFdMap.erase(fd); -bool MsgTransactionManager::checkPrivilege(MSG_CMD_TYPE_T CmdType, const char *pCookie) -{ - if (CmdType >= MSG_CMD_PLG_SENT_STATUS_CNF && CmdType <= MSG_CMD_PLG_INIT_SIM_BY_SAT) - { - MSG_DEBUG("Request from Plug-in"); - return true; - } + MSG_DEBUG("After erase fd [%d], reportMsgCBFdMap has below.", fd); + it = reportMsgCBFdMap.begin(); + for (; it!=reportMsgCBFdMap.end(); ++it) + MSG_DEBUG("[%d]", it->first); - // Get Cookie from APP - if (pCookie == NULL) - { - MSG_DEBUG("Cookie is NULL"); - return false; - } - - // Check Cookie - size_t cookieSize; - gid_t gid; - - cookieSize = security_server_get_cookie_size(); - - MSG_DEBUG("cookie size : [%d]", cookieSize); + MSG_END(); +} -// char cookie[MAX_COOKIE_LEN]; - // Get GID - if (CmdType == MSG_CMD_REG_INCOMING_SYNCML_MSG_CB) - { - MSG_DEBUG("get GID for message_sync"); - gid = security_server_get_gid("message_sync"); - } - else if (CmdType == MSG_CMD_REG_INCOMING_LBS_MSG_CB) +bool MsgTransactionManager::checkPrivilege(int fd, MSG_CMD_TYPE_T CmdType) +{ + bool bAllowed = true; + switch(CmdType) { - MSG_DEBUG("get GID for message_lbs"); - gid = security_server_get_gid("message_lbs"); - } - else + case MSG_CMD_GET_MSG: + case MSG_CMD_COUNT_MSG: + case MSG_CMD_COUNT_BY_MSGTYPE: + case MSG_CMD_REG_INCOMING_MSG_CB: + case MSG_CMD_REG_INCOMING_CB_MSG_CB: + case MSG_CMD_REG_INCOMING_PUSH_MSG_CB: + case MSG_CMD_REG_SENT_STATUS_CB: + case MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB: + case MSG_CMD_REG_INCOMING_SYNCML_MSG_CB: + case MSG_CMD_REG_INCOMING_LBS_MSG_CB: + case MSG_CMD_REG_SYNCML_MSG_OPERATION_CB: + case MSG_CMD_REG_REPORT_MSG_INCOMING_CB: + case MSG_CMD_GET_CONTACT_COUNT: + case MSG_CMD_GET_FOLDERLIST: + case MSG_CMD_GET_QUICKPANEL_DATA: + case MSG_CMD_GET_MEMSIZE: + case MSG_CMD_BACKUP_MESSAGE: + case MSG_CMD_REG_STORAGE_CHANGE_CB: + case MSG_CMD_GET_REPORT_STATUS: + case MSG_CMD_GET_THREAD_ID_BY_ADDRESS: + case MSG_CMD_GET_THREAD_INFO: + case MSG_CMD_SYNCML_OPERATION: + case MSG_CMD_GET_FILTERLIST: + case MSG_CMD_GET_FILTER_OPERATION: + case MSG_CMD_GET_SMSC_OPT: + case MSG_CMD_GET_CB_OPT: + case MSG_CMD_GET_SMS_SEND_OPT: + case MSG_CMD_GET_MMS_SEND_OPT: + case MSG_CMD_GET_MMS_RECV_OPT: + case MSG_CMD_GET_PUSH_MSG_OPT: + case MSG_CMD_GET_VOICE_MSG_OPT: + case MSG_CMD_GET_GENERAL_MSG_OPT: + case MSG_CMD_GET_MSG_SIZE_OPT: { - MSG_DEBUG("get GID for message"); - gid = security_server_get_gid("message"); + int ret = security_server_check_privilege_by_sockfd(fd, "msg-service::read", "rw"); + if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) { + MSG_DEBUG("No msg-service::read rw rule."); + bAllowed = false; + } } - - MSG_DEBUG("gid [%d]", gid); - - int retVal = 0; - - retVal = security_server_check_privilege(pCookie, gid); - - if (retVal < 0) + break; + case MSG_CMD_SUBMIT_REQ: + case MSG_CMD_SET_CB_OPT: + case MSG_CMD_ADD_PUSH_EVENT: + case MSG_CMD_DELETE_PUSH_EVENT: + case MSG_CMD_UPDATE_PUSH_EVENT: + case MSG_CMD_ADD_MSG: + case MSG_CMD_ADD_SYNCML_MSG: + case MSG_CMD_UPDATE_MSG: + case MSG_CMD_UPDATE_READ: + case MSG_CMD_UPDATE_PROTECTED: + case MSG_CMD_DELETE_MSG: + case MSG_CMD_DELALL_MSGINFOLDER: + case MSG_CMD_MOVE_MSGTOFOLDER: + case MSG_CMD_MOVE_MSGTOSTORAGE: + case MSG_CMD_DELETE_THREADMESSAGELIST: + case MSG_CMD_ADD_FOLDER: + case MSG_CMD_UPDATE_FOLDER: + case MSG_CMD_DELETE_FOLDER: + case MSG_CMD_RESET_DB: + case MSG_CMD_RESTORE_MESSAGE: + case MSG_CMD_DELETE_MESSAGE_BY_LIST: + case MSG_CMD_UPDATE_THREAD_READ: + case MSG_CMD_ADD_FILTER: + case MSG_CMD_UPDATE_FILTER: + case MSG_CMD_DELETE_FILTER: + case MSG_CMD_SET_FILTER_OPERATION: + case MSG_CMD_SET_FILTER_ACTIVATION: + case MSG_CMD_SET_SMSC_OPT: + case MSG_CMD_SET_SMS_SEND_OPT: + case MSG_CMD_SET_MMS_SEND_OPT: + case MSG_CMD_SET_MMS_RECV_OPT: + case MSG_CMD_SET_PUSH_MSG_OPT: + case MSG_CMD_SET_VOICE_MSG_OPT: + case MSG_CMD_SET_GENERAL_MSG_OPT: + case MSG_CMD_SET_MSG_SIZE_OPT: { - if (retVal == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) - { - MSG_DEBUG("access denied !! [%d]", retVal); + int ret = security_server_check_privilege_by_sockfd(fd, "msg-service::write", "rw"); + if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) { + MSG_DEBUG("No msg-service::write rw rule."); + bAllowed = false; } - else - { - MSG_DEBUG("fail to check privilege [%d]", retVal); - } - - return false; + } + break; } - MSG_DEBUG("privilege check success !!"); - - return true; + return bAllowed; } @@ -585,6 +766,60 @@ void MsgTransactionManager::setMMSConfMsgCB(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB } +void MsgTransactionManager::setPushMsgCB(MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S *pCbInfo) +{ + if (!pCbInfo) + { + MSG_FATAL("cbinfo NULL"); + return; + } + + pushmsg_list::iterator it = newPushMsgCBList.begin(); + + for (; it != newPushMsgCBList.end(); it++) + { + if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType) && !strncmp(it->appId, pCbInfo->appId, MAX_WAPPUSH_ID_LEN)) + { + MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType); + return; + } + } + + newPushMsgCBList.push_back(*pCbInfo); +} + +void MsgTransactionManager::setCBMsgCB(MSG_CMD_REG_INCOMING_CB_MSG_CB_S *pCbInfo) +{ + MSG_BEGIN(); + if (!pCbInfo) + { + MSG_FATAL("cbinfo NULL"); + return; + } + + cbmsg_list::iterator it = newCBMsgCBList.begin(); + + for (; it != newCBMsgCBList.end(); it++) + { + if ((it->listenerFd == pCbInfo->listenerFd) && (it->msgType == pCbInfo->msgType)) + { + MSG_DEBUG("Duplicated messageCB info fd %d, mType %d", it->listenerFd, it->msgType); + return; + } + } + MSG_DEBUG("bSave : [%d]", pCbInfo->bsave); + + if(pCbInfo->bsave) + if(MsgSettingSetBool(CB_SAVE, pCbInfo->bsave) != MSG_SUCCESS) + MSG_DEBUG("MsgSettingSetBool FAIL: CB_SAVE"); + + + newCBMsgCBList.push_back(*pCbInfo); + + MSG_END(); +} + + void MsgTransactionManager::setSyncMLMsgCB(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCbInfo) { if (!pCbInfo) @@ -645,7 +880,7 @@ void MsgTransactionManager::setJavaMMSList(MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S * { if (!strcmp(it->id, pTrId->id)) { - MSG_DEBUG("Duplicated javaMMS transaction Id:%s", it->id); + MSG_SEC_DEBUG("Duplicated javaMMS transaction Id:%s", it->id); return; } } @@ -686,6 +921,15 @@ void MsgTransactionManager::setStorageChangeCB(int listenerFd) } +void MsgTransactionManager::setReportMsgCB(int listenerFd) +{ + if (listenerFd <= 0) + THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d", listenerFd); + + reportMsgCBFdMap[listenerFd] = true; +} + + javamms_list& MsgTransactionManager::getJavaMMSList() { return javaMMSList; @@ -696,10 +940,35 @@ void MsgTransactionManager::broadcastIncomingMsgCB(const msg_error_t err, const { MSG_BEGIN(); + if ((msgInfo->msgPort.valid == true) && (msgInfo->msgPort.dstPort == MSG_LBS_PORT)) { + MSG_DEBUG("Message for LBS."); + + if (msgInfo->bTextSms == false) { + MSG_DEBUG("msgInfo->bTextSms == false"); + + int fileSize = 0; + + char* pFileData = NULL; + unique_ptr buf(&pFileData, unique_ptr_deleter); + + if (MsgOpenAndReadFile(msgInfo->msgData, &pFileData, &fileSize) == true) + MsgLbsSms(pFileData, fileSize); + else + MSG_DEBUG("MsgOpenAndReadFile failed."); + } else { + MsgLbsSms(msgInfo->msgText, (int)msgInfo->dataSize); + } + return; + } + char* pEventData = NULL; - AutoPtr eventBuf(&pEventData); + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); - int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)(&pEventData)); + char* encodedData = NULL; + unique_ptr buf(&encodedData, unique_ptr_deleter); + int dataSize = MsgEncodeMsgInfo(msgInfo, &encodedData); + + int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)(&pEventData)); MSG_DEBUG("valid %d dstport %d", msgInfo->msgPort.valid, msgInfo->msgPort.dstPort); @@ -709,13 +978,10 @@ void MsgTransactionManager::broadcastIncomingMsgCB(const msg_error_t err, const { MSG_DEBUG("fd %d dstport %d",it->listenerFd, it->port); - if ((msgInfo->msgPort.valid == false) && (it->port == 0)) - { + if ((msgInfo->msgPort.valid == false) && (it->port == 0)) { MSG_DEBUG("Send incoming normal msg to listener %d", it->listenerFd); write(it->listenerFd, pEventData, eventSize); - } - else if ((msgInfo->msgPort.valid == true) && (it->port == msgInfo->msgPort.dstPort)) - { + } else if ((msgInfo->msgPort.valid == true) && (it->port == msgInfo->msgPort.dstPort)) { MSG_DEBUG("Send incoming port msg to listener %d", it->listenerFd); write(it->listenerFd, pEventData, eventSize); } @@ -730,9 +996,13 @@ void MsgTransactionManager::broadcastMMSConfCB(const msg_error_t err, const MSG_ MSG_BEGIN(); char* pEventData = NULL; - AutoPtr eventBuf(&pEventData); + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); + + char* encodedData = NULL; + unique_ptr buf(&encodedData, unique_ptr_deleter); + int dataSize = MsgEncodeMsgInfo(msgInfo, &encodedData); - int eventSize = MsgMakeEvent(msgInfo, sizeof(MSG_MESSAGE_INFO_S), MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)(&pEventData)); + int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)(&pEventData)); mmsconf_list::iterator it = newMMSConfMsgCBList.begin(); @@ -762,13 +1032,56 @@ void MsgTransactionManager::broadcastMMSConfCB(const msg_error_t err, const MSG_ MSG_END(); } +void MsgTransactionManager::broadcastPushMsgCB(const msg_error_t err, const MSG_PUSH_MESSAGE_DATA_S *pushData) +{ + MSG_BEGIN(); + + char* pEventData = NULL; + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); + + int eventSize = MsgMakeEvent(pushData, sizeof(MSG_PUSH_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, err, (void**)(&pEventData)); + + pushmsg_list::iterator it = newPushMsgCBList.begin(); + + for (; it != newPushMsgCBList.end(); it++) + { + MSG_DEBUG("registered_appid : %s, incoming_appid: %s", it->appId, pushData->pushAppId); + if (!strcmp(it->appId, pushData->pushAppId)) + { + MSG_DEBUG("Send incoming Push information to listener %d", it->listenerFd); + write(it->listenerFd, pEventData, eventSize); + } + } + + MSG_END(); +} + +void MsgTransactionManager::broadcastCBMsgCB(const msg_error_t err, const MSG_CB_MSG_S *cbMsg) +{ + MSG_BEGIN(); + + char* pEventData = NULL; + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); + + int eventSize = MsgMakeEvent(cbMsg, sizeof(MSG_CB_MSG_S), MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)(&pEventData)); + + cbmsg_list::iterator it = newCBMsgCBList.begin(); + + for (; it != newCBMsgCBList.end(); it++) + { + MSG_DEBUG("Send incoming CB information to listener %d", it->listenerFd); + write(it->listenerFd, pEventData, eventSize); + } + + MSG_END(); +} void MsgTransactionManager::broadcastSyncMLMsgCB(const msg_error_t err, const MSG_SYNCML_MESSAGE_DATA_S *syncMLData) { MSG_BEGIN(); char* pEventData = NULL; - AutoPtr eventBuf(&pEventData); + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); int eventSize = MsgMakeEvent(syncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, err, (void**)(&pEventData)); @@ -788,8 +1101,9 @@ void MsgTransactionManager::broadcastLBSMsgCB(const msg_error_t err, const MSG_L { MSG_BEGIN(); +#if 0 char* pEventData = NULL; - AutoPtr eventBuf(&pEventData); + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); int eventSize = MsgMakeEvent(lbsData, sizeof(MSG_LBS_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, err, (void**)(&pEventData)); @@ -800,7 +1114,9 @@ void MsgTransactionManager::broadcastLBSMsgCB(const msg_error_t err, const MSG_L MSG_DEBUG("Send incoming LBS msg to listener %d", it->listenerFd); write(it->listenerFd, pEventData, eventSize); } - +#else + MsgLbsWapPush(lbsData->pushHeader, lbsData->pushBody, lbsData->pushBodyLen); +#endif MSG_END(); } @@ -810,10 +1126,10 @@ void MsgTransactionManager::broadcastSyncMLMsgOperationCB(const msg_error_t err, MSG_BEGIN(); char* pEventData = NULL; - AutoPtr eventBuf(&pEventData); + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); // Encoding Storage Change Data int dataSize = MsgEncodeSyncMLOperationData(msgId, extId, &encodedData); @@ -846,10 +1162,10 @@ void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, cons int dataSize = 0; char* pEventData = NULL; - AutoPtr eventBuf(&pEventData); + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); char* encodedData = NULL; - AutoPtr buf(&encodedData); + unique_ptr buf(&encodedData, unique_ptr_deleter); // Encoding Storage Change Data dataSize = MsgEncodeStorageChangeData(storageChangeType, pMsgIdList, &encodedData); @@ -868,6 +1184,42 @@ void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, cons } +void MsgTransactionManager::broadcastReportMsgCB(const msg_error_t err, const msg_report_type_t reportMsgType, const MSG_MESSAGE_INFO_S *pMsgInfo) +{ + MSG_BEGIN(); + + if(pMsgInfo == NULL) { + MSG_DEBUG("pMsgInfo is NULL."); + return; + } + + MSG_DEBUG("reportMsgType [%d]", reportMsgType); + + int dataSize = 0; + + char* pEventData = NULL; + unique_ptr eventBuf(&pEventData, unique_ptr_deleter); + + char* encodedData = NULL; + unique_ptr buf(&encodedData, unique_ptr_deleter); + + // Encoding Storage Change Data + dataSize = MsgEncodeReportMsgData(reportMsgType, pMsgInfo, &encodedData); + + int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND, err, (void**)(&pEventData)); + + fd_map::iterator it = reportMsgCBFdMap.begin(); + + for (; it != reportMsgCBFdMap.end(); it++) + { + MSG_DEBUG("Send Report Message Incoming Callback to listener %d", it->first); + write(it->first, pEventData, eventSize); + } + + MSG_END(); +} + + void MsgTransactionManager::setTMStatus() { MSG_BEGIN(); diff --git a/image/messaging_image001.png b/image/messaging_image001.png deleted file mode 100755 index 0c575c4e8c3dacf60dad2043a43c32722a827ab3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 70483 zcmd@5XH*nH_b-f+nGpmA6eQ;$abUf5hTfw;cee@&RUPp|J=3ir~BouZn3AUx@uR|PPO;1;tch*Zr)(Hfrp28Q~RF! zLp(e}6doRd6^I0QW4oXD7Wfa}=b@G=UezemPv8fUlZu`S9$sw<*@Z1J@SDy4-a|b+ zyq7$9cwtd^cxS+?uuVL?7f?LBEgL*MSp*&)-P4?w2l7Ax_~|_}AK*9S??3!6Jcmkn zc-H~i>MD=?t+sQC5lsCv(R6+wA_5gcB5e@YN&k}2y{BOCZ;QpqR6O>kRv&Lazni~* zQ_y96xH`nGd~TdX{T|(ZKK5uV=tzEp{#R95NO^H%L`wixgEM50ub1=BKmRyWj%4Ne_4Eeq!HLBms zk2xF^8}=W!G7V%e;?znG%ZQFHNp5cq?!atYAPu+?=0DRo5tB@P%=|8W6%z_P$F5=?RPP?mG zS92|J8lI3{NT@-po@YZW<|~{gQ^>{l1E!3dB29h<#u;xDPu=-T078ZT&+W`WUw`Vb zdob0O5_+rcMx)MMrrl0=i^lIAl*M0cjMTrS!;98~SZYoB-mg^q<*?b@;$9#mxI=1y4XS2JOq^y(>!|aZwk=E$FccU)RRF~-O!l=#p-sNi>To(QE zqCHBpZ?^<#5+x8|%^WHY)h+9S02lWo{8%$k#C@P$G!?_J5{p!0zo}3vS{EA=)MSVAEXJ5ray`lUC6b^ zDtrU^bp%c)LIeB-88%>6ZP%-~8!7haWl^=0^>p5eciUrj9u*OaJ>+ka3yRSv6#9XK z3x^R@g94O<@(X|Px&OzApZs0Y94fn61iPz~q&X(BzY8R!DIbvH^0hY+sx}pD*N~4< zghwd`j`6ZDadn(eZr_EqbwxcrkGj{lFs#U%y;>`rZd%Ehax4jtMC}D3Q>HrBW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gq4FPsoJAWs-HpY7I*BP}RCzANX(I!spQc{C_r;3)M3C22|B{6u~n4ySk~k0qK8 znG{9i3QS4^1XP0_6w@lH%6Hs}HO_9&3og=6p9D3UdBtihUOvMUk+!!7X(;G4zpN5L= K-OAh0i2nmq1^YAr diff --git a/include/common/MsgCmdTypes.h b/include/common/MsgCmdTypes.h index 4439c7b..9710252 100755 --- a/include/common/MsgCmdTypes.h +++ b/include/common/MsgCmdTypes.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_CMD_TYPES_H @@ -96,74 +96,93 @@ enum _MSG_CMD_TYPE_E MSG_CMD_GET_MSG_TYPE, MSG_CMD_SUBMIT_REQ, - MSG_CMD_CANCEL_REQ, MSG_CMD_REG_SENT_STATUS_CB, MSG_CMD_REG_STORAGE_CHANGE_CB, + MSG_CMD_REG_INCOMING_MSG_CB, // 30 - MSG_CMD_REG_INCOMING_MSG_CB, MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB, MSG_CMD_REG_INCOMING_SYNCML_MSG_CB, MSG_CMD_REG_INCOMING_LBS_MSG_CB, MSG_CMD_PLG_SENT_STATUS_CNF, - MSG_CMD_PLG_STORAGE_CHANGE_IND, + MSG_CMD_PLG_INCOMING_MSG_IND, MSG_CMD_PLG_INCOMING_MMS_CONF, MSG_CMD_PLG_INCOMING_SYNCML_IND, MSG_CMD_PLG_INCOMING_LBS_IND, + MSG_CMD_PLG_INIT_SIM_BY_SAT, // 40 - MSG_CMD_PLG_INIT_SIM_BY_SAT, MSG_CMD_GET_THREADVIEWLIST, MSG_CMD_GET_CONVERSATIONVIEWLIST, MSG_CMD_DELETE_THREADMESSAGELIST, MSG_CMD_GET_CONTACT_COUNT, - MSG_CMD_GET_QUICKPANEL_DATA, + MSG_CMD_COUNT_BY_MSGTYPE, MSG_CMD_RESET_DB, MSG_CMD_GET_MEMSIZE, MSG_CMD_BACKUP_MESSAGE, + MSG_CMD_RESTORE_MESSAGE, // 50 - MSG_CMD_RESTORE_MESSAGE, MSG_CMD_UPDATE_THREAD_READ, MSG_CMD_REG_SYNCML_MSG_OPERATION_CB, MSG_CMD_SYNCML_OPERATION, MSG_CMD_GET_REPORT_STATUS, - MSG_CMD_GET_THREAD_ID_BY_ADDRESS, + MSG_CMD_GET_THREAD_INFO, MSG_CMD_GET_SMSC_OPT, MSG_CMD_GET_CB_OPT, MSG_CMD_GET_SMS_SEND_OPT, + MSG_CMD_GET_MMS_SEND_OPT, // 60 - MSG_CMD_GET_MMS_SEND_OPT, MSG_CMD_GET_MMS_RECV_OPT, MSG_CMD_GET_PUSH_MSG_OPT, MSG_CMD_GET_VOICE_MSG_OPT, MSG_CMD_GET_GENERAL_MSG_OPT, - MSG_CMD_GET_MSG_SIZE_OPT, + MSG_CMD_SET_SMSC_OPT, MSG_CMD_SET_CB_OPT, MSG_CMD_SET_SMS_SEND_OPT, MSG_CMD_SET_MMS_SEND_OPT, + MSG_CMD_SET_MMS_RECV_OPT, // 70 - MSG_CMD_SET_MMS_RECV_OPT, MSG_CMD_SET_PUSH_MSG_OPT, MSG_CMD_SET_VOICE_MSG_OPT, MSG_CMD_SET_GENERAL_MSG_OPT, MSG_CMD_SET_MSG_SIZE_OPT, - + MSG_CMD_REG_INCOMING_PUSH_MSG_CB, + + MSG_CMD_PLG_INCOMING_PUSH_IND, + MSG_CMD_REG_INCOMING_CB_MSG_CB, + MSG_CMD_PLG_INCOMING_CB_IND, + MSG_CMD_ADD_PUSH_EVENT, + MSG_CMD_DELETE_PUSH_EVENT, + +// 80 + MSG_CMD_UPDATE_PUSH_EVENT, + MSG_CMD_DELETE_MESSAGE_BY_LIST, + MSG_CMD_SET_FILTER_ACTIVATION, + MSG_CMD_ADD_SIM_MSG, + MSG_CMD_PLG_RESEND_MESSAGE, + +// 85 + MSG_CMD_REG_REPORT_MSG_INCOMING_CB, + MSG_CMD_UPDATE_IMSI, + +#ifdef FEATURE_SMS_CDMA + MSG_CMD_PLG_CHECK_UNIQUENESS, +#endif // end of MSG_CMD; new CMD should be defined before MSG_CMD_NUM MSG_CMD_NUM }; - enum _MSG_EVENT_TYPE_E { MSG_EVENT_OPEN_HANDLE = 0, @@ -200,72 +219,98 @@ enum _MSG_EVENT_TYPE_E MSG_EVENT_GET_MSG_TYPE, MSG_EVENT_SUBMIT_REQ, - MSG_EVENT_CANCEL_REQ, MSG_EVENT_REG_SENT_STATUS_CB, + MSG_EVENT_REG_STORAGE_CHANGE_CB, MSG_EVENT_REG_INCOMING_MSG_CB, // 30 MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB, MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB, MSG_EVENT_REG_INCOMING_LBS_MSG_CB, - MSG_EVENT_REG_STORAGE_CHANGE_CB, MSG_EVENT_PLG_SENT_STATUS_CNF, - MSG_EVENT_PLG_STORAGE_CHANGE_IND, + MSG_EVENT_PLG_INCOMING_MSG_IND, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, + MSG_EVENT_PLG_INIT_SIM_BY_SAT, // 40 - MSG_EVENT_PLG_INIT_SIM_BY_SAT, MSG_EVENT_GET_THREADVIEWLIST, MSG_EVENT_GET_CONVERSATIONVIEWLIST, MSG_EVENT_DELETE_THREADMESSAGELIST, MSG_EVENT_GET_CONTACT_COUNT, - MSG_EVENT_GET_QUICKPANEL_DATA, + MSG_EVENT_COUNT_BY_MSGTYPE, MSG_EVENT_RESET_DB, MSG_EVENT_GET_MEMSIZE, MSG_EVENT_BACKUP_MESSAGE, + MSG_EVENT_RESTORE_MESSAGE, // 50 - MSG_EVENT_RESTORE_MESSAGE, MSG_EVENT_UPDATE_THREAD_READ, MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB, MSG_EVENT_SYNCML_OPERATION, MSG_EVENT_GET_REPORT_STATUS, - MSG_EVENT_GET_THREAD_ID_BY_ADDRESS, + MSG_EVENT_GET_THREAD_INFO, MSG_EVENT_GET_SMSC_OPT, MSG_EVENT_GET_CB_OPT, MSG_EVENT_GET_SMS_SEND_OPT, + MSG_EVENT_GET_MMS_SEND_OPT, // 60 - MSG_EVENT_GET_MMS_SEND_OPT, MSG_EVENT_GET_MMS_RECV_OPT, MSG_EVENT_GET_PUSH_MSG_OPT, MSG_EVENT_GET_VOICE_MSG_OPT, MSG_EVENT_GET_GENERAL_MSG_OPT, - MSG_EVENT_GET_MSG_SIZE_OPT, + MSG_EVENT_SET_SMSC_OPT, MSG_EVENT_SET_CB_OPT, MSG_EVENT_SET_SMS_SEND_OPT, MSG_EVENT_SET_MMS_SEND_OPT, + MSG_EVENT_SET_MMS_RECV_OPT, // 70 - MSG_EVENT_SET_MMS_RECV_OPT, MSG_EVENT_SET_PUSH_MSG_OPT, MSG_EVENT_SET_VOICE_MSG_OPT, MSG_EVENT_SET_GENERAL_MSG_OPT, MSG_EVENT_SET_MSG_SIZE_OPT, + MSG_EVENT_REG_INCOMING_PUSH_MSG_CB, + + MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, + MSG_EVENT_REG_INCOMING_CB_MSG_CB, + MSG_EVENT_PLG_INCOMING_CB_MSG_IND, + MSG_EVENT_ADD_PUSH_EVENT, + MSG_EVENT_DELETE_PUSH_EVENT, + +// 80 + MSG_EVENT_UPDATE_PUSH_EVENT, + MSG_EVENT_DELETE_MESSAGE_BY_LIST, + MSG_EVENT_SET_FILTER_ACTIVATION, + MSG_EVENT_ADD_SIM_MSG, + MSG_EVENT_PLG_RESEND_MESSAGE, + +// 85 + MSG_EVENT_REG_REPORT_MSG_INCOMING_CB, + MSG_EVENT_UPDATE_IMSI, + +#ifdef FEATURE_SMS_CDMA + MSG_EVENT_PLG_CHECK_UNIQUENESS, +#endif + +// Enums that does not match _MSG_CMD_TYPE_E + MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND, // end of MSG_EVENT; new EVENT should be defined before MSG_EVENT_NUM MSG_EVENT_NUM }; + + #endif // MSG_CMD_TYPES_H diff --git a/include/common/MsgCppTypes.h b/include/common/MsgCppTypes.h index 04fbd80..1e5f4a2 100755 --- a/include/common/MsgCppTypes.h +++ b/include/common/MsgCppTypes.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef __MSG_CPP_TYPES_H__ @@ -21,9 +21,12 @@ INCLUDE FILES ==================================================================================================*/ #include -#include +#include -typedef std::vector CharVector; +template +void unique_ptr_deleter( T **ptr ) { + if (ptr && *ptr ) delete[] *ptr; +} template diff --git a/include/common/MsgFilterTypes.h b/include/common/MsgFilterTypes.h index 047f0b1..cb453eb 100755 --- a/include/common/MsgFilterTypes.h +++ b/include/common/MsgFilterTypes.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_FILTER_TYPES_H @@ -54,7 +54,8 @@ typedef struct { msg_filter_id_t filterId; /**< Indicates the filter ID. */ msg_filter_type_t filterType; /**< Indicates the filter type. */ - char filterValue[MAX_FILTER_VALUE_LEN+1]; /**< The value of a filter. */ + char filterValue[MAX_FILTER_VALUE_LEN+1]; /**< The value of a filter. */ + bool bActive; } MSG_FILTER_S; diff --git a/include/common/MsgInternalTypes.h b/include/common/MsgInternalTypes.h index cb208ea..13cae23 100755 --- a/include/common/MsgInternalTypes.h +++ b/include/common/MsgInternalTypes.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_INTERNAL_TYPES_H @@ -32,27 +32,46 @@ /*================================================================================================== DEFINES ==================================================================================================*/ -#define MSG_DATA_ROOT_PATH "/opt/data/msg-service/" +#define MSG_DATA_ROOT_PATH "/opt/usr/data/msg-service/" #define MSG_DATA_PATH MSG_DATA_ROOT_PATH"msgdata/" #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 MSG_NATIONAL_SIM "memory/private/msg-service/national_sim" +#define MSG_SIM_MSISDN "memory/private/msg-service/msisdn" +#define MSG_SIM_ICCID "memory/private/msg-service/iccid" +#define MSG_FMM_SIM_CHANGE_NUM "db/SyncML/oma-dm-service/fmmSimChangeNum" + #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 #define MAX_THREAD_DATA_LEN 128 - -#define SMS_MINIMUM_SPACE (3 * 1024) -#define MMS_MINIMUM_SPACE (600 * 1024) +#define MAX_CB_MSG_TEXT_LEN 4200 // 1page max char(93)*max page(15)*max bytes of UTF8 1 char(3) +#define MAX_CB_MSG_LANGUAGE_TYPE_LEN 3 +#define MAX_ETWS_WARNING_SECURITY_INFO_LEN 50 +#define MAX_ME_IMEI_LEN 20 +#define MAX_SIM_MSISDN_LEN 26 +#define MAX_COMMON_INFO_SIZE 20 +#define MAX_VCONFKEY_NAME_LEN 128 +#define MAX_SIM_IMSI_LEN 16 +#define MAX_TAPI_SIM_API_TIMEOUT 70 + +#define SMS_MINIMUM_SPACE (1 * 1024 * 1024) +#define MMS_MINIMUM_SPACE (1 * 1024 * 1024) /*vconf keys*/ -#define MSG_SIM_IMSI "memory/private/msg-service/sim_imsi" -#define MSG_SIM_CHANGED "memory/private/msg-service/sim_changed" +#define DEFAULT_SETTING_PATH "db/private/msg-service" +#define DEFAULT_MSG_MEMORY_PATH "memory/private/msg-service" +#define MSG_SIM_IMSI DEFAULT_MSG_MEMORY_PATH"/sim_imsi" +#define MSG_SIM_CHANGED DEFAULT_MSG_MEMORY_PATH"/sim_changed" -#define DEFAULT_SETTING_PATH "db/private/msg-service" +#define MSG_SIM_SERVICE_TABLE DEFAULT_MSG_MEMORY_PATH"/sim_st" +#define MSG_SIM_MO_CONTROL DEFAULT_MSG_MEMORY_PATH"/sim_mo_ctrl" +#define MSG_NETWORK_SIM DEFAULT_MSG_MEMORY_PATH"/default_network_sim" #define DEFAULT_GENERAL_OPT_PATH DEFAULT_SETTING_PATH"/general" #define DEFAULT_SMS_SEND_OPT_PATH DEFAULT_SETTING_PATH"/sms_send" @@ -67,10 +86,22 @@ #define DEFAULT_SIM_COUNT_PATH DEFAULT_SETTING_PATH"/sim_count" #define MSG_KEEP_COPY DEFAULT_GENERAL_OPT_PATH"/keep_copy" -#define MSG_ALERT_TONE VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT +#define MSG_ALERT_REP_TYPE DEFAULT_GENERAL_OPT_PATH"/alert_rep_type" #define MSG_AUTO_ERASE DEFAULT_GENERAL_OPT_PATH"/auto_erase" #define MSG_BLOCK_MESSAGE DEFAULT_GENERAL_OPT_PATH"/block_msg" #define CONTACT_SYNC_TIME DEFAULT_GENERAL_OPT_PATH"/contact_sync_time" +#define MSG_SEARCH_TAGS DEFAULT_GENERAL_OPT_PATH"/search_tags" + +#define MSG_BLOCK_UNKNOWN_MSG DEFAULT_GENERAL_OPT_PATH"/block_unknown_msg" +#define MSG_SMS_LIMIT DEFAULT_GENERAL_OPT_PATH"/sms_limit" +#define MSG_MMS_LIMIT DEFAULT_GENERAL_OPT_PATH"/mms_limit" +#define MSG_SETTING_NOTIFICATION DEFAULT_GENERAL_OPT_PATH"/notification" +#define MSG_SETTING_VIBRATION DEFAULT_GENERAL_OPT_PATH"/vibration" +#define MSG_SETTING_PREVIEW DEFAULT_GENERAL_OPT_PATH"/preview" +#define MSG_SETTING_RINGTONE_PATH DEFAULT_GENERAL_OPT_PATH"/ringtone_path" +#define MSG_SETTING_RINGTONE_TYPE DEFAULT_GENERAL_OPT_PATH"/ringtone_type" +#define MSG_MMS_UA_PROFILE DEFAULT_GENERAL_OPT_PATH"/ua_profile" +#define MSG_MMS_UA_AGENT DEFAULT_GENERAL_OPT_PATH"/ua_agent" #define SMS_SEND_DCS DEFAULT_SMS_SEND_OPT_PATH"/dcs" #define SMS_SEND_NETWORK_MODE VCONFKEY_MESSAGE_NETWORK_MODE @@ -131,9 +162,8 @@ #define PUSH_SERVICE_TYPE DEFAULT_PUSH_MSG_OPT_PATH"/service_load" #define CB_RECEIVE DEFAULT_CB_MSG_OPT_PATH"/receive" -#define CB_ALL_CHANNEL DEFAULT_CB_MSG_OPT_PATH"/all_channel" +#define CB_SAVE DEFAULT_CB_MSG_OPT_PATH"/save" #define CB_MAX_SIM_COUNT DEFAULT_CB_MSG_OPT_PATH"/max_sim_count" -#define CB_CHANNEL_COUNT DEFAULT_CB_MSG_OPT_PATH"/channel_count" #define CB_CHANNEL_ACTIVATE DEFAULT_CB_MSG_OPT_PATH"/channel_activate" #define CB_CHANNEL_ID_FROM DEFAULT_CB_MSG_OPT_PATH"/channel_id_from" #define CB_CHANNEL_ID_TO DEFAULT_CB_MSG_OPT_PATH"/channel_id_to" @@ -141,12 +171,24 @@ #define CB_LANGUAGE DEFAULT_CB_MSG_OPT_PATH"/language" #define VOICEMAIL_NUMBER DEFAULT_VOICE_MAIL_OPT_PATH"/voice_mail_number" +#define VOICEMAIL_COUNT DEFAULT_VOICE_MAIL_OPT_PATH"/voice_mail_count" +#define VOICEMAIL_ALPHA_ID DEFAULT_VOICE_MAIL_OPT_PATH"/voice_mail_alphaid" +#define VOICEMAIL_DEFAULT_NUMBER "" +#define VOICEMAIL_DEFAULT_ALPHA_ID "" #define MSGSIZE_OPTION DEFAULT_MSGSIZE_OPT_PATH"/msg_size" #define SIM_USED_COUNT DEFAULT_SIM_COUNT_PATH"/used_cnt" #define SIM_TOTAL_COUNT DEFAULT_SIM_COUNT_PATH"/total_cnt" +#ifdef FEATURE_SMS_CDMA +#define MSG_MESSAGE_ID_COUNTER DEFAULT_GENERAL_OPT_PATH"/msg_id_counter" +#endif + +#define MSG_DEFAULT_APP_ID "org.tizen.message" +#define MSG_QUICKPANEL_APP_ID "org.tizen.quickpanel" +#define MSG_TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony" +#define MSG_TELEPHONY_MMS_FEATURE "http://tizen.org/feature/network.telephony.mms" /*================================================================================================== TYPES @@ -169,6 +211,15 @@ typedef unsigned char MSG_SUB_TYPE_T; /** + * @brief Represents a message tag type. \n + * Each main type of a message can be divided into some tag types. \n + * For instance of SMS, the message sub type can be one of the Priority, Finance, and so on. \n + * The values for this type SHOULD be in _MSG_SUB_TYPE_E. + */ +typedef unsigned int MSG_TAG_TYPE_T; + + +/** * @brief Represents a message class. \n * The values for this type SHOULD be in _MSG_CLASS_TYPE_E. */ @@ -202,31 +253,35 @@ typedef struct */ typedef struct { - msg_message_id_t msgId; /**< Indicates the message ID of this message. */ - msg_thread_id_t threadId; /**< Indicates the thread ID. */ - msg_folder_id_t folderId; /**< Indicates the folder ID. */ - MSG_MESSAGE_TYPE_S msgType; /**< Indicates the message type such as SMS and MMS */ - 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 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. */ - 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]; + msg_message_id_t msgId; /**< Indicates the message ID of this message. */ + msg_thread_id_t threadId; /**< Indicates the thread ID. */ + msg_folder_id_t folderId; /**< Indicates the folder ID. */ + MSG_MESSAGE_TYPE_S msgType; /**< Indicates the message type such as SMS and MMS */ + 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. */ + MSG_ADDRESS_INFO_S *addressList; /**< Indicates the address information list. */ + 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. */ + 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+1]; + bool bStore; /**< Indicates whether the message is stored or not if it is MWI message. */ + int sim_idx; } MSG_MESSAGE_INFO_S; + typedef struct { msg_message_id_t msgId; /**< Indicates the message ID of this message. */ @@ -237,6 +292,7 @@ typedef struct MSG_CLASS_TYPE_T classType; /**< Message class type. See enum _MSG_CLASS_TYPE_E */ msg_storage_id_t storageId; /**< Indicates where the message is saved. see enum _MSG_FOLDER_TYPE_E*/ msg_struct_list_s *addr_list; + GList *addressList; 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. */ @@ -251,12 +307,15 @@ typedef struct unsigned short dstPort; /**< Recipient port number, not greater than 16 bit */ unsigned short srcPort; /**< Sender port number, not greater than 16 bit */ int attachCount; /**< Indicates the count of attached files in mms. */ - char thumbPath[MSG_FILEPATH_LEN_MAX]; + char thumbPath[MSG_FILEPATH_LEN_MAX+1]; size_t dataSize; /**< Indicates the data size. The unit is byte. */ void *pData; /**< Indicates the message payload information as a body. default character encoding is UTF-8*/ void *pMmsData; /**< Indicates the message payload information as a body. default character encoding is UTF-8*/ + size_t mmsDataSize; + int simIndex; } MSG_MESSAGE_HIDDEN_S; + /** * @brief Represents message information for thread view. */ @@ -272,10 +331,60 @@ typedef struct int unreadCnt; /**< Indicates the unread messages from the Peer. */ int smsCnt; /**< Indicates the SMS messages from the Peer. */ int mmsCnt; /**< Indicates the MMS messages from the Peer. */ + bool bProtected; /**< Indicates whether the thread includes protected messages. */ + bool bDraft; + bool bSendFailed; + bool bSending; + int simIndex; } MSG_THREAD_VIEW_S; /** + * @brief Represents message information for conversation view. + */ +typedef struct +{ + msg_message_id_t msgId; /**< Indicates the message ID of this message. */ + msg_thread_id_t threadId; /**< Indicates the thread ID of this peer. */ + MSG_MAIN_TYPE_T mainType; /**< Message main type. See enum _MSG_MAIN_TYPE_E */ + MSG_SUB_TYPE_T subType; /**< Message sub type. See enum _MSG_SUB_TYPE_E */ + msg_folder_id_t folderId; /**< Indicates the folder ID. see enum _MSG_FOLDER_TYPE_E */ + msg_storage_id_t storageId; /**< Indicates where the message is saved. see enum _MSG_FOLDER_TYPE_E*/ + time_t displayTime; /**< Indicates the display time related to the specific operation. */ + time_t scheduledTime; /**< Indicates the time to send scheduled message. */ + msg_network_status_t networkStatus; /**< Indicates the network status of the message. */ + bool bRead; /**< Indicates whether the message is read or not. */ + bool bProtected; /**< Indicates whether the message is protected or not. */ + msg_direction_type_t direction; /**< Indicates whether the message is MO or MT, affecting address. */ + int pageCount; /**< Indicates the count of pageCount in mms. */ + int attachCount; /**< Indicates the count of attached files in mms. */ + char attachFileName[MSG_FILENAME_LEN_MAX+1]; /**< Indicates the thumbnail path. */ + char audioFileName[MSG_FILENAME_LEN_MAX+1]; /**< Indicates the thumbnail path. */ + char imageThumbPath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the thumbnail path. */ + char videoThumbPath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the thumbnail path. */ + char subject[MAX_SUBJECT_LEN+1]; /**< Indicates the message subject. */ + size_t textSize; /**< Indicates the data size. The unit is byte. */ + char *pText; /**< Indicates the message payload information as a body. default character encoding is UTF-8*/ + int tcs_bc_level; + char firstMediaPath[MSG_FILEPATH_LEN_MAX+1]; // First Media Path in mms; + msg_list_handle_t multipart_list; + int simIndex; +} MSG_CONVERSATION_VIEW_S; + +typedef struct +{ + MimeType type; /**< Indicates the multipart mime type. see enum MimeType */ + char szContentType[MSG_MSG_ID_LEN + 1]; /**< Indicates the content type */ + 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 szContentLocation[MSG_MSG_ID_LEN + 1]; /**< Indicates the content Location */ + + int tcs_bc_level; /** detect malware type **/ + char szThumbFilePath[MSG_FILEPATH_LEN_MAX + 1]; /**< Indicates the thumbnail file path */ +} MSG_MMS_MULTIPART_S; + +/** * @brief Represents sim message informatioin list. */ typedef struct @@ -323,6 +432,13 @@ typedef struct unsigned short port; } MSG_CMD_REG_INCOMING_MSG_CB_S; +typedef struct +{ + int listenerFd; + MSG_MAIN_TYPE_T msgType; + bool bsave; +} MSG_CMD_REG_CB_INCOMING_MSG_CB_S; + /** * @brief Aux data structure for MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB. \n @@ -380,6 +496,21 @@ typedef struct MSG_MAIN_TYPE_T msgType; } MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S; +typedef struct +{ + int listenerFd; + MSG_MAIN_TYPE_T msgType; + char appId[MAX_WAPPUSH_ID_LEN+1]; + char content_type[MAX_WAPPUSH_CONTENT_TYPE_LEN+1]; +} MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S; + +typedef struct +{ + int listenerFd; + MSG_MAIN_TYPE_T msgType; + bool bsave; +} MSG_CMD_REG_INCOMING_CB_MSG_CB_S; + typedef struct { @@ -387,6 +518,43 @@ typedef struct MSG_REQUEST_INFO_S reqInfo; }MSG_SCHEDULED_MSG_S; +/** + * @brief Represents a CB message in the framework. + */ +typedef struct +{ + MSG_SUB_TYPE_T type; + time_t receivedTime; + + unsigned short serialNum; + unsigned short messageId; // Message Identifier + unsigned char dcs; // data coding scheme + int cbTextLen; // length of cbText + unsigned char cbText[MAX_CB_MSG_TEXT_LEN];// cb message text (UTF8) + + unsigned short etwsWarningType; + unsigned char etwsWarningSecurityInfo[MAX_ETWS_WARNING_SECURITY_INFO_LEN]; + unsigned char language_type[MAX_CB_MSG_LANGUAGE_TYPE_LEN]; +} MSG_CB_MSG_S; + +#ifdef FEATURE_SMS_CDMA +typedef struct _MSG_UNIQUE_INDEX_S +{ + unsigned short tele_msgId; + char address[MAX_ADDRESS_VAL_LEN+1]; + char sub_address[MAX_ADDRESS_VAL_LEN+1]; + char time_stamp[MAX_COMMON_INFO_SIZE+1]; + int telesvc_id; +} MSG_UNIQUE_INDEX_S; + +typedef struct +{ + time_t receivedTime; + unsigned short serialNum; + unsigned short messageId; // Message Identifier +} MSG_CB_DUPLICATE_S; +#endif + /*================================================================================================== ENUMS @@ -455,8 +623,20 @@ enum _MSG_SUB_TYPE_E MSG_FORWARDCONF_MMS, /**< MMS Forward Confirm message */ MSG_READREPLY_MMS, /**< MMS Read Reply message */ MSG_SENDREQ_JAVA_MMS, /**< MMS Send Request message for JAVA MMS */ + + MSG_ETWS_SMS, + MSG_MWI_VOICE2_SMS, /**< MWI Message Voice for line 2(CPHS)*/ + + MSG_CMAS_PRESIDENTIAL, /**< CMAS CLASS */ + MSG_CMAS_EXTREME, + MSG_CMAS_SEVERE, + MSG_CMAS_AMBER, + MSG_CMAS_TEST, + MSG_CMAS_EXERCISE, + MSG_CMAS_OPERATOR_DEFINED, }; + /** * @brief Represents the values of a message transaction type. \n * This enum is used as the value of MSG_MMS_TRANSACTION_TYPE_T. @@ -468,5 +648,21 @@ enum _MSG_MMS_TRANSACTION_TYPE_E MSG_MMS_UNKNOWN, }; +/** + * @brief Represents the values of File Type of MMS. \n + * This enum is used as the value of . + */ +enum _MSG_MMS_ITEM_TYPE_E +{ + MSG_MMS_ITEM_TYPE_IMG, /**< Indicates the image media */ + MSG_MMS_ITEM_TYPE_AUDIO, /**< Indicates the audio media */ + MSG_MMS_ITEM_TYPE_VIDEO, /**< Indicates the video media */ + MSG_MMS_ITEM_TYPE_ATTACH, /**< Indicates the attach file */ + MSG_MMS_ITEM_TYPE_PAGE, /**< Indicates the page count */ + MSG_MMS_ITEM_TYPE_MALWARE, /**< Indicates the tcs bc level*/ + MSG_MMS_ITEM_TYPE_1ST_MEDIA, /**< Indicates the 1st media path*/ +}; + + #endif diff --git a/include/common/MsgMmsTypes.h b/include/common/MsgMmsTypes.h index df41c2d..2ce1da6 100755 --- a/include/common/MsgMmsTypes.h +++ b/include/common/MsgMmsTypes.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_MMS_TYPES_H @@ -45,6 +45,7 @@ * @{ */ +typedef GList MMSList; /*================================================================================================== STRUCTURES @@ -54,8 +55,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 +75,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,19 +91,22 @@ 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 */ } sMedia; -}MMS_MEDIA_S; + + char szContentType[MSG_MSG_ID_LEN + 1]; + char szContentLocation[MSG_MSG_ID_LEN + 1]; +} MMS_MEDIA_S; /** * @brief Represents attachment information. @@ -110,12 +114,14 @@ 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 */ -}MMS_ATTACH_S; + char szDrm2FullPath[MSG_FILEPATH_LEN_MAX + 1]; /**< Indicates the fullpath of the DRM */ + char szContentType[MSG_MSG_ID_LEN + 1]; + +} MMS_ATTACH_S; /** * @brief Represents SMIL page information. @@ -140,22 +146,23 @@ typedef struct { bool bUnitPercent; /**< Indicates the length is in percentage(%) or not */ int value; /**< Indicates the value for length */ -}MMS_LENGTH; +} MMS_LENGTH; /** * @brief Represents SMIL region information. */ 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 */ MMS_LENGTH height; /**< Indicates the width of the region */ // '%' rate should be supported + bool bBgColor; /**< Indicates the background color set in the region */ int bgColor; /**< Indicates the background color of the region */ REGION_FIT_TYPE_T fit; /**< Indicates the fit type. see enum REGION_FIT_TYPE_T */ -}MMS_SMIL_REGION; +} MMS_SMIL_REGION; /** * @brief Represents SMIL root layout information. @@ -164,6 +171,7 @@ typedef struct { MMS_LENGTH width; /**< Indicates the width of the root layout */ MMS_LENGTH height; /**< Indicates the height of the root layout */ // '%' rate should be supported + bool bBgColor; /**< Indicates the background color set in the root layout */ int bgColor; /**< Indicates the background color of the root layout */ }MMS_SMIL_ROOTLAYOUT; @@ -173,10 +181,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 +193,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 +205,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,19 +215,117 @@ 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; +typedef struct _MMS_ADDRESS_DATA_S { + int address_type; + char *address_val; +} MMS_ADDRESS_DATA_S; + +/** + * @brief Represents MMS header data. + */ +typedef struct _MMS_HEADER_DATA_S +{ + MMSList *bcc;// Bcc + MMSList *cc;// Cc + char contentLocation[MMS_LOCATION_LEN + 1]; + char szContentType[MSG_MSG_ID_LEN + 1];//string : ex) application/vnd.wap.multipart.related + unsigned long int date; + bool bDeliveryReport; // X-Mms-Delivery-Report + MmsTimeStruct delivery; // X-Mms-Delivery-Time + MmsTimeStruct expiry; + char szFrom[254 * 3 + 11]; //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6" // From + int messageClass;//Personal | Advertisement | Informational | Auto + char messageID[MSG_MSG_ID_LEN + 1]; + int messageType;//MmsMsgType : ex) sendreq + int mmsVersion;//1.0 1.3 + int messageSize; //X-Mms-Message-Size + int mmsPriority;//_MSG_PRIORITY_TYPE_E : Low | Normal | High + bool bReadReport;// X-Mms-Read-Report +// X-Mms-Report-Allowed +// X-Mms-Response-Status +// X-Mms-Response-Text + bool bHideAddress;// X-Mms-Sender-Visibility + msg_delivery_report_status_t mmsStatus;// X-Mms-Status + char szSubject[MAX_SUBJECT_LEN + 1];// Subject + MMSList *to;// Cc// To + char trID[MSG_MSG_ID_LEN + 1]; +// X-Mms-Retrieve-Status +// X-Mms-Retrieve-Text +// X-Mms-Read-Status +// X-Mms-Reply-Charging +// X-Mms-Reply-Charging-Deadline +// X-Mms-Reply-Charging-ID +// X-Mms-Reply-Charging-Size +// X-Mms-Previously-Sent-By +// X-Mms-Previously-Sent-Date +// X-Mms-Store +// X-Mms-MM-State +// X-Mms-MM-Flags +// X-Mms-Store-Status +// X-Mms-Store-Status-Text +// X-Mms-Stored +// X-Mms-Attributes +// X-Mms-Totals +// X-Mms-Mbox-Totals +// X-Mms-Quotas +// X-Mms-Mbox-Quotas +// X-Mms-Message-Count +// Content +// X-Mms-Start +// Additional-headers +// X-Mms-Distribution-Indicator +// X-Mms-Element-Descriptor +// X-Mms-Limit +// X-Mms-Recommended-Retrieval-Mode +// X-Mms-Recommended-Retrieval-Mode-Text +// X-Mms-Status-Text +// X-Mms-Applic-ID +// X-Mms-Reply-Applic-ID +// X-Mms-Aux-Applic-Info + int contentClass;//text | image-basic| image-rich | video-basic | video-rich | megapixel | content-basic | content-rich +// X-Mms-DRM-Content +// X-Mms-Adaptation-Allowed +// X-Mms-Replace-ID +// X-Mms-Cancel-ID +// X-Mms-Cancel-Status +//------------------------------------------------------------------ + int contentType;//MimeType : ex) application/vnd.wap.multipart.related + +} MMS_HEADER_DATA_S; + +/** + * @brief Represents MMS multipart data. + */ +typedef struct +{ + MimeType type; /**< Indicates the multipart mime type. see enum MimeType */ + char szContentType[MSG_MSG_ID_LEN + 1]; /**< Indicates the content type */ + char szFileName[MSG_FILENAME_LEN_MAX + 1]; /**< Indicates the file name */ + char szContentID[MSG_MSG_ID_LEN + 1]; /**< Indicates the content id */ + char szContentLocation[MSG_MSG_ID_LEN + 1]; /**< Indicates the content Location */ + MsgDrmType drmType; /**< Indicates the drm type. see enum MsgDrmType */ + + char szFilePath[MSG_FILEPATH_LEN_MAX + 1]; /**< Indicates the file path */ + char *pMultipartData; + size_t nMultipartDataLen; + int tcs_bc_level; /** detect malware type **/ + int malware_allow; + char szThumbFilePath[MSG_FILEPATH_LEN_MAX + 1]; /**< Indicates the thubnail file path */ +} MMS_MULTIPART_DATA_S; /** * @brief Represents MMS message data. */ typedef struct _MMS_MESSAGE_DATA_S { - char szSmilFilePath[MSG_FILEPATH_LEN_MAX]; /**< Indicates the SMIL file path */ + int backup_type; //normal = 0|| backup = 1; + 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 */ @@ -232,13 +338,19 @@ typedef struct _MMS_MESSAGE_DATA_S GList *metalist; /**< The pointer to SMIL meta list */ MMS_SMIL_ROOTLAYOUT rootlayout; /**< Indicates the root layout information */ MMS_APPID_INFO_S msgAppId; -}MMS_MESSAGE_DATA_S; + MMS_HEADER_DATA_S header;//use for scloud + MMS_MULTIPART_DATA_S smil;//use for scloud +} MMS_MESSAGE_DATA_S; /** - * @} + * @brief Represents MMS message data. */ - - +typedef struct +{ + int backup_type; //none = 0 || scloud backup = 1 || kies backup = 2; + MMS_HEADER_DATA_S *header; /**< The header struct of MMS*/ + MMS_MULTIPART_DATA_S *smil; + MMSList *multipartlist; /**< list of MMS_MULTIPART_DATA_S*/ +} MMS_DATA_S; #endif - diff --git a/include/common/MsgPluginInterface.h b/include/common/MsgPluginInterface.h index efdf960..a761501 100755 --- a/include/common/MsgPluginInterface.h +++ b/include/common/MsgPluginInterface.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /** @@ -524,7 +524,11 @@ typedef msg_error_t (*MsgPlgSaveSimMessage)(const MSG_MESSAGE_INFO_S *pMsgInfo, * */ /*================================================================================================*/ +#ifdef FEATURE_SMS_CDMA typedef msg_error_t (*MsgPlgDeleteSimMessage)(msg_sim_id_t SimMsgId); +#else +typedef msg_error_t (*MsgPlgDeleteSimMessage)(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId); +#endif /** @@ -565,8 +569,11 @@ typedef msg_error_t (*MsgPlgDeleteSimMessage)(msg_sim_id_t SimMsgId); * */ /*================================================================================================*/ +#ifdef FEATURE_SMS_CDMA typedef msg_error_t (*MsgPlgSetReadStatus)(msg_sim_id_t SimMsgId); - +#else +typedef msg_error_t (*MsgPlgSetReadStatus)(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId); +#endif /** @@ -606,8 +613,11 @@ typedef msg_error_t (*MsgPlgSetReadStatus)(msg_sim_id_t SimMsgId); * */ /*================================================================================================*/ +#ifdef FEATURE_SMS_CDMA typedef msg_error_t (*MsgPlgSetMemoryStatus)(msg_error_t Error); - +#else +typedef msg_error_t (*MsgPlgSetMemoryStatus)(msg_sim_slot_id_t sim_idx, msg_error_t Error); +#endif // Setting API /** @@ -891,7 +901,6 @@ typedef msg_error_t (*MsgPlgUpdateMessage)(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SEN * * \param output - pMsg is information of MMS message. * \param output - pSendOptInfo is information of sending options. -* \param output - pMmsMsg is information of MMS messages detail data. * \param output - pDestMsg is file path of MMS message. * * \return Return Type (int(msg_error_t)) \n @@ -909,7 +918,7 @@ typedef msg_error_t (*MsgPlgUpdateMessage)(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SEN * */ /*================================================================================================*/ -typedef msg_error_t (*MsgPlgGetMmsMessage)(MSG_MESSAGE_INFO_S* pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo, MMS_MESSAGE_DATA_S* pMmsMsg, char** pDestMsg); +typedef msg_error_t (*MsgPlgGetMmsMessage)(MSG_MESSAGE_INFO_S* pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo, char** pDestMsg); /** @@ -1035,6 +1044,10 @@ typedef msg_error_t (*MsgPlgComposeReadReport)(MSG_MESSAGE_INFO_S *pMsgInfo); /*================================================================================================*/ typedef msg_error_t (*MsgPlgRestoreMsg)(MSG_MESSAGE_INFO_S *pMsg, char* pRcvdBody, int rcvdBodyLen, char* filePath); +typedef msg_error_t (*MsgPlgGetMeImei) (char *pImei); + +typedef msg_error_t (*MsgPlgGetDefaultNetworkSimId) (int *simId); + // framework defined callbacks. typedef void (*MsgPlgOnSentStatus)(MSG_SENT_STATUS_S *pSentStatus); @@ -1043,21 +1056,36 @@ typedef msg_error_t (*MsgPlgOnMsgIncoming)(MSG_MESSAGE_INFO_S *pMsgInfo); typedef msg_error_t (*MsgPlgOnInitSimBySat)(void); typedef msg_error_t (*MsgPlgOnSyncMLMsgIncoming)(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLData); typedef msg_error_t (*MsgPlgOnLBSMsgIncoming)(MSG_LBS_MESSAGE_DATA_S *pLBSData); +typedef msg_error_t (*MsgPlgOnPushMsgIncoming)(MSG_PUSH_MESSAGE_DATA_S *pPushData); +typedef msg_error_t (*MsgPlgOnCBMsgIncoming)(MSG_CB_MSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo); typedef msg_error_t (*MsgPlgOnMmsConfIncoming)(MSG_MESSAGE_INFO_S *pMsgInfo, msg_request_id_t *pRequest); - +typedef msg_error_t (*MsgPlgOnSimMessageIncoming)(MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList, msg_message_id_t *retMsgId, int listSize); +typedef msg_error_t (*MsgPlgOnResendMessage)(void); +#ifdef FEATURE_SMS_CDMA +typedef bool (*MsgPlgCheckUniqueness)(MSG_UNIQUE_INDEX_S *p_msg, msg_message_id_t msgId, bool ischecked); +#endif +typedef msg_error_t (*MsgPlgOnInitImsi)(int sim_idx); /*================================================================================================== STRUCTURES ==================================================================================================*/ struct _MSG_PLUGIN_LISTENER_S { - MsgPlgOnSentStatus pfSentStatusCb; /** The function pointer of sent status callback. */ - MsgPlgOnStorageChange pfStorageChangeCb; /** The function pointer of storage change callback. */ - MsgPlgOnMsgIncoming pfMsgIncomingCb; /** The function pointer of receive message callback. */ - MsgPlgOnInitSimBySat pfInitSimBySatCb; /** The function pointer of init SIM callback. */ + MsgPlgOnSentStatus pfSentStatusCb; /** The function pointer of sent status callback. */ + MsgPlgOnStorageChange pfStorageChangeCb; /** The function pointer of storage change callback. */ + MsgPlgOnMsgIncoming pfMsgIncomingCb; /** The function pointer of receive message callback. */ + MsgPlgOnInitSimBySat pfInitSimBySatCb; /** The function pointer of init SIM callback. */ MsgPlgOnSyncMLMsgIncoming pfSyncMLMsgIncomingCb; /** The function pointer of receive syncML message callback. */ - MsgPlgOnLBSMsgIncoming pfLBSMsgIncomingCb; /** The function pointer of receive LBS message callback. */ - MsgPlgOnMmsConfIncoming pfMmsConfIncomingCb; /** The function pointer of receive MMS conf */ + MsgPlgOnLBSMsgIncoming pfLBSMsgIncomingCb; /** The function pointer of receive LBS message callback. */ + MsgPlgOnPushMsgIncoming pfPushMsgIncomingCb; /** The function pointer of receive Push message callback. */ + MsgPlgOnCBMsgIncoming pfCBMsgIncomingCb; /** The function pointer of receive cb message callback. */ + MsgPlgOnMmsConfIncoming pfMmsConfIncomingCb; /** The function pointer of receive MMS conf */ + MsgPlgOnSimMessageIncoming pfSimMsgIncomingCb; /** The function pointer of sim message callback */ + MsgPlgOnResendMessage pfResendMessageCb; +#ifdef FEATURE_SMS_CDMA + MsgPlgCheckUniqueness pfCheckUniquenessCb; +#endif + MsgPlgOnInitImsi pfSimInitImsiCb; }; @@ -1066,15 +1094,11 @@ struct _MSG_PLUGIN_HANDLER_S MsgPlgInitialize pfInitialize; /**< The function pointer of initialize. */ MsgPlgFinalize pfFinalize; /**< The function pointer of finalize. */ MsgPlgRegisterListener pfRegisterListener; /**< The function pointer of register listener. */ - MsgPlgCheckSimStatus pfCheckSimStatus; /**< The function pointer of check SIM status. */ - MsgPlgCheckDeviceStatus pfCheckDeviceStatus; /**< The function pointer of check device status. */ MsgPlgSubmitRequest pfSubmitRequest; /**< The function pointer of submit request. */ - MsgPlgInitSimMessage pfInitSimMessage; /**< The function pointer of initialize SIM msg. */ MsgPlgSaveSimMessage pfSaveSimMessage; /**< The function pointer of save SIM msg. */ MsgPlgDeleteSimMessage pfDeleteSimMessage; /**< The function pointer of delete SIM msg. */ MsgPlgSetReadStatus pfSetReadStatus; /**< The function pointer of set read status. */ MsgPlgSetMemoryStatus pfSetMemoryStatus; /**< The function pointer of set memory status. */ - MsgPlgInitConfigData pfInitConfigData; /**< The function pointer of initialize of setting. */ MsgPlgSetConfigData pfSetConfigData; /**< The function pointer of save setting. */ MsgPlgGetConfigData pfGetConfigData; /**< The function pointer of get setting. */ MsgPlgRestoreMsg pfRestoreMsg; @@ -1084,6 +1108,7 @@ struct _MSG_PLUGIN_HANDLER_S MsgPlgGetMmsMessage pfGetMmsMessage; MsgPlgUpdateRejectStatus pfUpdateRejectStatus; MsgPlgComposeReadReport pfComposeReadReport; + MsgPlgGetDefaultNetworkSimId pfGetDefaultNetworkSimId; }; #ifdef __cplusplus diff --git a/include/common/MsgQueue.h b/include/common/MsgQueue.h index 3869ddc..69cb8f2 100755 --- a/include/common/MsgQueue.h +++ b/include/common/MsgQueue.h @@ -1,30 +1,31 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef __MsgThdSafeQ_H__ #define __MsgThdSafeQ_H__ -#include #include "MsgMutex.h" #include -template class MsgThdSafeQ + +template +class MsgSimpleQ { public: - MsgThdSafeQ(){}; + MsgSimpleQ(){}; void pop_front (); bool front(T* qItem); void push_front(T const & input); @@ -32,28 +33,23 @@ public: int size(); bool empty(); void clear(); + bool checkExist(T const & qItem, bool(cmp)(T const &, T const &)); + void remove(T const & qItem, bool(cmp)(T const &, T const &) ); private: - Mutex mx; std::list q; }; -/* - mx variable guarantees atomic operation in multi-threaded environment. - For example, when a thread is executing Pop(), other threads - trying to execute one of Pop, Push, Size, Empty are locked. -*/ - -template void MsgThdSafeQ::pop_front() +template +void MsgSimpleQ::pop_front() { - MutexLocker lock(mx); if( q.empty() ) return; q.pop_front(); } -template bool MsgThdSafeQ::front(T* qItem) +template +bool MsgSimpleQ::front(T* qItem) { - MutexLocker lock(mx); if( qItem == NULL || q.empty() ) return false; // Fail @@ -63,36 +59,59 @@ template bool MsgThdSafeQ::front(T* qItem) } -template void MsgThdSafeQ::push_back(T const & qItem) +template +void MsgSimpleQ::push_back(T const & qItem) { - MutexLocker lock(mx); q.push_back(qItem); } -template void MsgThdSafeQ::push_front(T const & qItem) +template void +MsgSimpleQ::push_front(T const & qItem) { - MutexLocker lock(mx); q.push_front(qItem); } -template int MsgThdSafeQ::size() +template +int MsgSimpleQ::size() { - MutexLocker lock(mx); return q.size(); } -template bool MsgThdSafeQ::empty() +template +bool MsgSimpleQ::empty() { - MutexLocker lock(mx); return q.empty(); } -template void MsgThdSafeQ::clear() +template +void MsgSimpleQ::clear() { - MutexLocker lock(mx); q.clear(); } +template +bool MsgSimpleQ::checkExist(T const & qItem, bool(cmp)(T const &, T const &)) +{ + for(typename list::iterator iterPos = q.begin(); iterPos != q.end(); ++iterPos) { + + if (cmp(qItem, *iterPos) == true) + return true; + } + + return false; +} + +template +void MsgSimpleQ::remove(T const & qItem, bool(cmp)(T const &, T const &)) +{ + for(typename list::iterator iterPos = q.begin(); iterPos != q.end(); ) { + + if (cmp(qItem, *iterPos) == true) + q.erase(iterPos++); + else + ++iterPos; + } +} #endif // __MsgThdSafeQ_H__ diff --git a/include/common/MsgSettingTypes.h b/include/common/MsgSettingTypes.h index 9b5bd40..733096d 100755 --- a/include/common/MsgSettingTypes.h +++ b/include/common/MsgSettingTypes.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_SETTING_TYPES_H @@ -34,6 +34,7 @@ INCLUDE FILES ==================================================================================================*/ #include "MsgTypes.h" +#include "MsgStorageTypes.h" /** * @ingroup MESSAGING_FRAMEWORK @@ -179,11 +180,18 @@ typedef unsigned char MSG_CB_LANGUAGE_TYPE_T; /** * @brief Represents the SIM status from telephony. \n - * The values for this type SHOULD be in \ref _MSG_SIM_STATUS_E. + * The values for this type SHOULD be in _MSG_SIM_STATUS_E. */ typedef unsigned char MSG_SIM_STATUS_T; +/** + * @brief Represents the ringtone type of message. \n + * The values for this type SHOULD be in _MSG_RINGTONE_TYPE_E. + */ +typedef int MSG_RINGTONE_TYPE_T; + + /*================================================================================================== STRUCTURES ==================================================================================================*/ @@ -210,25 +218,32 @@ typedef struct MSG_SMSC_ADDRESS_S smscAddr; /**< SMSC address structure */ } MSG_SMSC_DATA_S; + /** * @brief Represents an SMSC list. */ typedef struct { - int selected; /**< Selected SMSC index */ + int index; /**< SMSC index for Updating information */ + int selected; /**< Selected SMSC index */ int totalCnt; /**< The count of total SMSC addresses */ - MSG_SMSC_DATA_S smscData[SMSC_LIST_MAX]; /**< SMSC data information list*/ + MSG_SMSC_DATA_S smscData[SMSC_LIST_MAX]; /**< SMSC data information list*/ + msg_sim_slot_id_t simIndex; }MSG_SMSC_LIST_S; + /** * @brief Represents an SMSC list. */ typedef struct { + int index; /**< SMSC index for Updating information */ int selected; /**< Selected SMSC index */ - msg_struct_list_s *smsc_list; /**< SMSC data information list*/ + msg_struct_list_s *smsc_list; /**< SMSC data information list*/ + msg_sim_slot_id_t simIndex; }MSG_SMSC_LIST_HIDDEN_S; + /** * @brief Represents the information of a cell broadcasting channel. */ @@ -237,6 +252,8 @@ typedef struct bool bActivate; /**< Indicates whether the CB channel is activate or passive. */ unsigned int from; /**< Indicates the start ID of a CB channel range. */ unsigned int to; /**< Indicates the end ID of a CB channel range. */ + unsigned short ctg; /**< Indicates the category of a CB. (for 3gpp2)*/ + unsigned short lang; /**< Indicates the language of a CB. (for 3gpp2)*/ char name[CB_CHANNEL_NAME_MAX+1]; /**< Indicates the name of a CB channel. */ } MSG_CB_CHANNEL_INFO_S; @@ -250,14 +267,24 @@ typedef struct MSG_CB_CHANNEL_INFO_S channelInfo[CB_CHANNEL_MAX]; /**< The structure of CB channel information */ } MSG_CB_CHANNEL_S; + /** * @brief Represents an general option. */ typedef struct { - bool bKeepCopy; /**< Indicates whether the SMS message copy is kept or not. */ - MSG_ALERT_TONE_T alertTone; /**< Indicates the period of playing alert tone. */ - bool bAutoErase; /**< Indicates whether the auto-erase option is enabled or not. */ + bool bKeepCopy; /**< Indicates whether the SMS message copy is kept or not. */ + MSG_ALERT_TONE_T alertTone; /**< Indicates the period of playing alert tone. */ + bool bAutoErase; /**< Indicates whether the auto-erase option is enabled or not. */ + bool bBlockUnknownMsg; /**< Indicates whether unknown sender message is blocked or not. */ + int smsLimitCnt; /**< Indicates the count limitation of sms messages in one conversation */ + int mmsLimitCnt; /**< Indicates the count limitation of sms messages in one conversation */ + bool bNotification; /**< Indicates whether notification for incoming message is shown or not. */ + bool bVibration; /**< Indicates whether vibration for incoming message is run or not. */ + bool bPreview; /**< Indicates whether preview for incoming message is shown or not. */ + char ringtonePath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the message ringtone path */ + int ringtoneType; /**< Indicates the message ringtone type. */ + int searchTags; /**< Indicates the tags to be enabled for search ex) MSG_MESSAGE_TAG_PRIMARY | MSG_MESSAGE_TAG_PROMOTION. See enum _MSG_TAG_TYPE_E */ }MSG_GENERAL_OPT_S; @@ -356,6 +383,7 @@ typedef struct int maxSimCnt; /**< Indicates the number of channels which can be stored in SIM. */ MSG_CB_CHANNEL_S channelData; /**< Indicates the cell broadcasting channel information. */ bool bLanguage[CB_LANG_TYPE_MAX]; /**< Indicates whether the language name of a cell broadcasting message is set or not. */ + msg_sim_slot_id_t simIndex; } MSG_CBMSG_OPT_S; typedef struct @@ -364,14 +392,19 @@ typedef struct int maxSimCnt; /**< Indicates the number of channels which can be stored in SIM. */ msg_struct_list_s *channelData; /**< Indicates the cell broadcasting channel information. */ bool bLanguage[CB_LANG_TYPE_MAX]; /**< Indicates whether the language name of a cell broadcasting message is set or not. */ + msg_sim_slot_id_t simIndex; } MSG_CBMSG_OPT_HIDDEN_S; + /** * @brief Represents a voice mail number option. */ typedef struct { char mailNumber[MAX_PHONE_NUMBER_LEN+1]; + char alpahId[MAX_SIM_XDN_ALPHA_ID_LEN+1]; + msg_sim_slot_id_t simIndex; + int voiceCnt; } MSG_VOICEMAIL_OPT_S; diff --git a/include/common/MsgSmil.h b/include/common/MsgSmil.h new file mode 100755 index 0000000..6537e0e --- /dev/null +++ b/include/common/MsgSmil.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef MSG_SMIL_H +#define MSG_SMIL_H + +#include "MsgMmsTypes.h" + +/** @fn bool MsgSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pstMsgMmsBody, const char *pSmilDoc) + * @brief Parse Smil Document using MMS_MESSAGE_DATA_S struct. + * @param[in] pstMsgMmsBody + * @param[in] pSmilDoc + * @retval TRUE In case of Success. + * @retval FALSE In case of failure. + */ +bool MsgSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pstMsgMmsBody, const char *pSmilDoc); + +/** @fn bool MsgSmilGenerateSmilDoc(MMS_MESSAGE_DATA_S *pstMsgMmsBody, char **ppSmilDoc) + * @brief Generate Smil Document using MMS_MESSAGE_DATA_S struct. + * @param[in] pstMsgMmsBody + * @param[out] ppSmilDoc + * @retval TRUE In case of Success. + * @retval FALSE In case of failure. + */ +bool MsgSmilGenerateSmilDoc(MMS_MESSAGE_DATA_S *pstMsgMmsBody, char **ppSmilDoc); + +#endif//MSG_SMIL_H diff --git a/include/common/MsgStorageTypes.h b/include/common/MsgStorageTypes.h index aef5f1e..ca6c3d0 100755 --- a/include/common/MsgStorageTypes.h +++ b/include/common/MsgStorageTypes.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_STORAGE_TYPES_H @@ -47,13 +47,6 @@ * @defgroup MESSAGING_STORAGE_TYPES Messaging Storage Types * @{ */ - -/*================================================================================================== - DEFINES -==================================================================================================*/ -#define MAX_SEGMENT_NUM 15 - - /*================================================================================================== STRUCTURES ==================================================================================================*/ @@ -98,10 +91,15 @@ typedef struct typedef struct { msg_contact_id_t contactId; /**< Indicates the unique contact ID. */ - char displayName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the display name of contact. */ - char firstName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the first name of contact. */ - char lastName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the last name of contact. */ - char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */ + int addrbookId; /**< Indicates the address book ID. */ + char firstName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the first name of contact. */ + char lastName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the last name of contact. */ + char middleName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the middle name of contact. */ + char prefix[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the prefix of contact. */ + char suffix[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the suffix of contact. */ + char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */ + char alerttonePath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the message alert tone path of contact. */ + char vibrationPath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the vibration path of contact. */ } MSG_CONTACT_INFO_S; @@ -112,7 +110,7 @@ typedef struct */ typedef struct { - msg_sort_type_t sortType; /**< Indicates the sort type */ + msg_sort_type_t sortType; /**< Indicates the sort type, See enum _MSG_SORT_TYPE_E */ bool bAscending; /**< Indicates the sort order which is ascending or descending */ }MSG_SORT_RULE_S; @@ -150,5 +148,34 @@ typedef struct } MSG_SEARCH_CONDITION_S; +/** + * @brief Represents Message list condition values. + */ +typedef struct +{ + msg_folder_id_t folderId; + msg_thread_id_t threadId; + msg_storage_id_t storageId; + msg_message_type_t msgType; + bool bProtected; + bool bScheduled; + char *pAddressVal; + char *pTextVal; + bool bAnd; + time_t fromTime; + time_t toTime; + int offset; + int limit; + msg_struct_t sortRule; + int simIndex; +} MSG_LIST_CONDITION_S; + + +typedef struct +{ + int appcode; + char appid[MAX_WAPPUSH_ID_LEN]; +} PUSH_APPLICATION_INFO_S; + #endif // MSG_STORAGE_TYPES_H diff --git a/include/common/MsgThread.h b/include/common/MsgThread.h index 454d1b5..c3c5ed6 100755 --- a/include/common/MsgThread.h +++ b/include/common/MsgThread.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef __MSG_THREAD_H__ diff --git a/include/common/MsgTransportTypes.h b/include/common/MsgTransportTypes.h index 2ecd7fc..e4cf048 100755 --- a/include/common/MsgTransportTypes.h +++ b/include/common/MsgTransportTypes.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_TRANSPORT_TYPES_H diff --git a/include/common/MsgTypes.h b/include/common/MsgTypes.h index fd33621..ae49fde 100755 --- a/include/common/MsgTypes.h +++ b/include/common/MsgTypes.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_TYPES_H @@ -55,16 +55,16 @@ */ #define MMS_V1_2 // MMS Version : MMS_V1_0 / MMS_V1_1 / MMS_V1_2 + /** - * @brief Defines the enabled DRM support + * @brief Defines the notification method */ -#define __SUPPORT_DRM__ +#define MSG_NOTI_INTEGRATION /** - * @brief Defines the enabled JAVA MMS Application Id + * @brief Defines the enabled drm */ -#define FEATURE_JAVA_MMS - +#define MSG_DRM_SUPPORT (0) /** * @brief Defines message struct handle. @@ -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,10 @@ 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]; + int simIndex; }MSG_SYNCML_MESSAGE_DATA_S; @@ -294,23 +295,49 @@ 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 + 1]; + int pushBodyLen; + char pushBody[MAX_WAPPUSH_CONTENTS_LEN + 1]; + char pushAppId[MAX_WAPPUSH_ID_LEN + 1]; + char pushContentType[MAX_WAPPUSH_CONTENT_TYPE_LEN + 1]; +}MSG_PUSH_MESSAGE_DATA_S; + /** * @brief Represents the Report Status Data. */ - typedef struct +typedef struct { - msg_delivery_report_status_t deliveryStatus; /**< Indicates the message ID of this message. */ - time_t deliveryStatusTime; /**< Indicates the display time related to the specific operation. */ //MAX_DISPLAY_TIME_LEN - msg_read_report_status_t readStatus; /**< Indicates the message ID of this message. */ - time_t readStatusTime; /**< Indicates the display time related to the specific operation. */ //MAX_DISPLAY_TIME_LEN -}MSG_REPORT_STATUS_INFO_S; + char addressVal[MAX_ADDRESS_VAL_LEN + 1]; + int type; + int status; + time_t statusTime; +} MSG_REPORT_STATUS_INFO_S; + + +typedef struct +{ + 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; + +typedef struct +{ + msg_message_id_t msg_id; + char mime_type[MAX_MIME_TYPE_LEN+1]; + char media_item[MSG_FILEPATH_LEN_MAX+1]; + char thumb_path[MSG_FILEPATH_LEN_MAX+1]; +} MSG_MEDIA_INFO_S; /** * @} diff --git a/include/externals/MsgAlarm.h b/include/externals/MsgAlarm.h new file mode 100755 index 0000000..954b147 --- /dev/null +++ b/include/externals/MsgAlarm.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef MSG_ALARM_H +#define MSG_ALARM_H + +#include +#include "MsgTypes.h" + +/*================================================================================================== + DEFINES +==================================================================================================*/ + +typedef void (*msg_alarm_cb)(int alarmId); + +/*================================================================================================== + FUNCTION PROTOTYPES +==================================================================================================*/ +msg_error_t MsgAlarmRegistration(struct tm *timeInfo, msg_alarm_cb userCB, int *alarmId); +msg_error_t MsgAlarmRemove(int alarmId); + +#endif // MSG_ALARM_H diff --git a/include/externals/MsgDevicedWrapper.h b/include/externals/MsgDevicedWrapper.h new file mode 100644 index 0000000..e405e3d --- /dev/null +++ b/include/externals/MsgDevicedWrapper.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef MSG_DEVICED_WRAPPER_H +#define MSG_DEVICED_WRAPPER_H + + +void MsgDisplayLock(); +void MsgDisplayUnlock(); +void MsgChangePmState(); + +#endif /* MSG_DEVICED_WRAPPER_H */ diff --git a/include/externals/MsgLbs.h b/include/externals/MsgLbs.h new file mode 100755 index 0000000..ff24ebf --- /dev/null +++ b/include/externals/MsgLbs.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef MSGLBS_H_ +#define MSGLBS_H_ + +/*================================================================================================== + INCLUDE FILES +==================================================================================================*/ + +/*================================================================================================== + DEFINES +==================================================================================================*/ +#define MSG_LBS_PORT 7275 + + +/*================================================================================================== + FUNCTION PROTOTYPES +==================================================================================================*/ +void MsgLbsSms(const char *msgBody, int msgSize); +void MsgLbsWapPush(const char *pushHeader, const char *pushBody, int pushBodySize); + + +#endif /* MSGLBS_H_ */ diff --git a/include/externals/MsgNotificationWrapper.h b/include/externals/MsgNotificationWrapper.h new file mode 100755 index 0000000..85ab130 --- /dev/null +++ b/include/externals/MsgNotificationWrapper.h @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef MSG_NOTIFICATION_WRAPPER_H +#define MSG_NOTIFICATION_WRAPPER_H + +/*================================================================================================== + INCLUDE FILES +==================================================================================================*/ +#include "MsgInternalTypes.h" +#include "MsgSqliteWrapper.h" + +/*================================================================================================== + DEFINES +==================================================================================================*/ +#define MSG_APP_PACKAGE_NAME "message" + +#define MSG_APP_LOCALEDIR "/usr/apps/"MSG_DEFAULT_APP_ID"/res/locale" + +#define MSG_NOTIFICATION_ICON_DIR MSG_QUICKPANEL_APP_ID"/shared/res/noti_icons/Message" + +// notification icon +#define MSG_NORMAL_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_message.png" +#define MSG_SIM_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_message_sim-card.png" +#define MSG_VOICE_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_voice_mail.png" +#define MSG_CB_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_message_cb-msg.png" +#define MSG_READ_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_message_read_report.png" +#define MSG_DELIVERY_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_message_delivery_report.png" +#define MSG_REPLY_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_message_reply.png" +#define MSG_SMS_SENDING_FAILED_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_message_failed.png" +#define MSG_MMS_SENDING_FAILED_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_message_mms_failed.png" +#define MSG_MMS_RETRIVE_FAILED_ICON_PATH "/usr/apps/"MSG_NOTIFICATION_ICON_DIR"/noti_message_mms_problem.png" +#define MSG_EMERGENCY_ICON_PATH "/usr/apps/"MSG_DEFAULT_APP_ID"/res/icons/default/small/noti_emergency_mode.png" + +// status bar icon +#define MSG_NORMAL_STATUS_ICON "/usr/apps/"MSG_DEFAULT_APP_ID"/res/icons/default/small/status_bar_message.png" +#define MSG_FAILED_STATUS_ICON "/usr/apps/"MSG_DEFAULT_APP_ID"/res/icons/default/small/status_bar_cancel_message.png" +#define MSG_DELIVER_REPORT_STATUS_ICON "/usr/apps/"MSG_DEFAULT_APP_ID"/res/icons/default/small/status_bar_delivery_report_message.png" +#define MSG_READ_REPORT_STATUS_ICON "/usr/apps/"MSG_DEFAULT_APP_ID"/res/icons/default/small/status_bar_read_report_message.png" +#define MSG_VOICE_MSG_STATUS_ICON "/usr/apps/"MSG_DEFAULT_APP_ID"/res/icons/default/small/status_bar_voicemail.png" +#define MSG_SIM_FULL_STATUS_ICON "/usr/apps/"MSG_DEFAULT_APP_ID"/res/icons/default/small/status_bar_sim_card_full.png" + +#ifndef TIZEN_I586_ENABLED +// system string +#define NEW_MESSAGE "IDS_MSGF_POP_NEW_MESSAGE" +#define NEW_MESSAGES "IDS_MSGF_POP_NEW_MESSAGES" +#define MSG_UNKNOWN_SENDER "IDS_MSGF_BODY_UNKNOWN" +#define MSG_NO_SUBJECT "IDS_MSGF_BODY_NO_SUBJECT" + + +// message app string for ticker noti +#define SENDING_MULTIMEDIA_MESSAGE_FAILED "IDS_MSGF_POP_SENDING_MULTIMEDIA_MESSAGE_FAILED" +#define MULTIMEDIA_MESSAGE_SENT "IDS_MSGF_POP_MULTIMEDIA_MESSAGE_SENT" +#define RETRIEVING_MESSAGE_FAILED "IDS_MSGF_POP_RETRIEVING_MESSAGE_FAILED" +#define MESSAGE_RETRIEVED "IDS_MSGF_BODY_MESSAGE_RETRIEVED" +#define SMS_MESSAGE_SENT "IDS_MSGC_POP_MESSAGESENT" +#define SMS_MESSAGE_SENDING_FAIL "IDS_MSGF_POP_SENDING_MESSAGE_FAILED" +#define SMS_MESSAGE_SENDING_PENDING "IDS_MSG_POP_UNABLE_TO_SEND_MESSAGE_IT_WILL_BE_SENT_WHEN_SERVICE_AVAILABLE" +#define SMS_MESSAGE_SIM_MESSAGE_FULL "IDS_MSGF_BODY_SIM_MEMORY_FULL_DELETE_SOME_ITEMS" +#define SMS_MESSAGE_MEMORY_FULL "IDS_MSGF_POP_NOT_ENOUGH_MEMORY_DELETE_SOME_ITEMS" +#define SMS_FDN_RESTRICTED "IDS_MSGF_POP_FDN_ENABLED_CANT_SEND_MSG" +#define SMS_SIM_CARD_FULL "IDS_MSG_HEADER_SIM_CARD_FULL" +#define SMS_MESSAGE_SIZE_OVER_SIM_SLOT_SIZE "IDS_MSGF_BODY_MESSAGE_IS_TOO_LARGE_TO_STORE_AS_A_SINGLE_MESSAGE_TO_SIM_CARD" + +// message app string for quickpanel noti +#define MSG_MESSAGE "IDS_MSGF_BODY_MESSAGE" +#define VOICE_MAIL "IDS_MSGF_BODY_VOICEMAIL" +#define NEW_VOICE_MAIL "IDS_MSGF_BODY_NEW_VOICEMAIL" +#define APP_NEW_MESSAGE "IDS_MSGF_POP_NEW_MESSAGE" +#define APP_NEW_MESSAGES "IDS_MSGF_POP_NEW_MESSAGES" +#define CB_MESSAGE "IDS_MSGF_BODY_CB_MESSAGES" +#define PUSH_MESSAGE "IDS_MSGF_BODY_PUSH_MESSAGES" +#define DELIVERY_MESSAGE "IDS_MSGF_BODY_DELIVERY_REPORT" +#define READ_REPORT_MESSAGE "IDS_MSGF_POP_READ_REPORT" +#define EXPIRED_MESSAGE "IDS_MSGF_BODY_MESSAGE_HAS_EXPIRED" +#define REJECTED_MESSAGE "IDS_MSGF_BODY_MMSDELIVERYMSGREJECTED" +#define DEFERRED_MESSAGE "IDS_MSGF_POP_MESSAGE_DEFERRED" +#define UNRECOGNISED_MESSAGE "IDS_MSGF_POP_MESSAGE_UNRECOGNISED" +#define INDETEMINATE_MESSAGE "IDS_MSGF_POP_INDETERMINATE" +#define UNREACHABLE_MESSAGE "IDS_MSGF_POP_UNREACHABLE" +#define DELIVERED_MESSAGE "IDS_MSGF_BODY_MESSAGE_DELIVERED" +#define VOICE_1_MESSAGE "IDS_MSGF_BODY_1_MESSAGE" +#define VOICE_N_MESSAGE "IDS_MSGF_BODY_PD_MESSAGES" +#define SIM_CARD_MESSAGE "IDS_MSGF_BODY_SIM_CARD_MESSAGES" +#define READ_REPORT_READ "IDS_COM_BODY_READ" +#define READ_REPORT_DELETE "IDS_COM_POP_DELETED" +#define FAILED_MSG_EXIST "IDS_MSG_BODY_FAILED_MESSAGES_EXIST" +#define ENABLE_EMERGENCY_MODE "IDS_MSG_BODY_ENABLE_EMERGENCY_MODE_JPN_DCM" +#define EMERGENCY_MODE_DESCRIPTION "IDS_MSG_SBODY_TAP_HERE_TO_ENABLE_EMERGENCY_MODE_TO_SAVE_BATTERY_POWER_JPN_DCM" +#define FAILED_TO_SEND_MESSAGE "IDS_MSG_TPOP_FAILED_TO_SEND_MESSAGE_ABB" +#else +// system string +#define NEW_MESSAGE "New message" +#define NEW_MESSAGES "New messages" +#define MSG_UNKNOWN_SENDER "New message from Unknown." +#define MSG_NO_SUBJECT "No subject" + + +// message app string for ticker noti +#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 SMS_MESSAGE_SENDING_PENDING "Unable to send message. It will be sent when service available." +#define SMS_MESSAGE_SIM_MESSAGE_FULL "SIM memory full. Delete some items." +#define SMS_MESSAGE_MEMORY_FULL "Not enough memory. Delete some items." +#define SMS_FDN_RESTRICTED "Unable to send the message while Fixed dialling mode is enabled." +#define SMS_SIM_CARD_FULL "SIM card full" +#define SMS_MESSAGE_SIZE_OVER_SIM_SLOT_SIZE "Message is too large to store as a single message to SIM card." // + +// message app string for quickpanel noti +#define MSG_MESSAGE "Message" +#define VOICE_MAIL "Voicemail" +#define NEW_VOICE_MAIL "New voicemail" +#define APP_NEW_MESSAGE "New message" +#define APP_NEW_MESSAGES "New messages" +#define CB_MESSAGE "CB messages" +#define PUSH_MESSAGE "Push messages" +#define DELIVERY_MESSAGE "Delivery report" +#define READ_REPORT_MESSAGE "Read report" +#define EXPIRED_MESSAGE "Message expired." +#define REJECTED_MESSAGE "Message rejected." +#define DEFERRED_MESSAGE "Message deferred" +#define UNRECOGNISED_MESSAGE "Message unrecognised" +#define INDETEMINATE_MESSAGE "Indeterminate." +#define UNREACHABLE_MESSAGE "Unreachable" +#define DELIVERED_MESSAGE "Message delivered" +#define VOICE_1_MESSAGE "1 message" +#define VOICE_N_MESSAGE "%d messages" +#define SIM_CARD_MESSAGE "SIM card messages" +#define READ_REPORT_READ "Read" +#define READ_REPORT_DELETE "Deleted." +#define FAILED_MSG_EXIST "Failed messages exist." +#define ENABLE_EMERGENCY_MODE "Enable Emergency mode" +#define EMERGENCY_MODE_DESCRIPTION "Tap here to enable Emergency mode to save battery power." +#define FAILED_TO_SEND_MESSAGE "Failed to send message." // +#endif + +#define NOTIFICATION_PRIV_ID DEFAULT_SETTING_PATH"/notification_priv_id" +#define VOICE_NOTI_ID_1 DEFAULT_SETTING_PATH"/voice_noti_id1" +#define VOICE_NOTI_ID_2 DEFAULT_SETTING_PATH"/voice_noti_id2" +#define CB_NOTI_PRIV_ID DEFAULT_SETTING_PATH"/cb_noti_priv_id" +#define SIM_MSG_NOTI_PRIV_ID DEFAULT_SETTING_PATH"/sim_msg_noti_priv_id" +#define EMERGENCY_MODE_NOTI_ID DEFAULT_SETTING_PATH"/emergency_noti_id" +#define MSG_SENTFAIL_NOTI_ID DEFAULT_SETTING_PATH"/sentfail_noti_id" +#define SIM_FULL_NOTI_PRIV_ID DEFAULT_SETTING_PATH"/sim_full_noti_id" + +#define MSG_NOTI_TEXT_LEN (512) +#define MSG_NOTI_TEXT_LEN_S (256) + +enum _msg_notification_type_e +{ + MSG_NOTI_TYPE_ALL = 0x00, + + // Refresh single/multiple notification + MSG_NOTI_TYPE_NORMAL, + MSG_NOTI_TYPE_CB, + MSG_NOTI_TYPE_SIM, + MSG_NOTI_TYPE_FAILED, + + // Add only single notification + MSG_NOTI_TYPE_VOICE_1, + MSG_NOTI_TYPE_VOICE_2, + MSG_NOTI_TYPE_MWI, + MSG_NOTI_TYPE_CLASS0, + MSG_NOTI_TYPE_SMS_DELIVERY_REPORT, + MSG_NOTI_TYPE_MMS_READ_REPORT, + MSG_NOTI_TYPE_MMS_DELIVERY_REPORT, + + MSG_NOTI_TYPE_SIM_FULL, +}; + +typedef unsigned char msg_notification_type_t; //_msg_notification_type_e + +msg_error_t MsgInsertNotification(MSG_MESSAGE_INFO_S *msg_info); + +msg_error_t MsgAddNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info); +msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeedback, bool bTicker); +msg_error_t MsgAddReportNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info); +msg_error_t MsgDeleteReportNotification(const char *addr); + +msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId); +msg_error_t MsgInsertInstantMessage(msg_notification_type_t noti_type); +msg_error_t MsgInitNoti(); +msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt); +msg_error_t MsgDeleteNoti(msg_notification_type_t noti_type, int simIndex); + +void MsgRefreshAllNotification(bool bWithSimNoti, bool bFeedback, bool bTickerNoti); +void MsgDeleteNotification(msg_notification_type_t noti_type, int simIndex); +void MsgInitReportNotiList(); + +char *getTranslateText(const char *pkg_name, const char *locale_dir, const char *text); + +#endif diff --git a/include/externals/MsgSensorWrapper.h b/include/externals/MsgSensorWrapper.h new file mode 100755 index 0000000..ab1e279 --- /dev/null +++ b/include/externals/MsgSensorWrapper.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef MSG_SENSOR_H +#define MSG_SENSOR_H + + +#include "MsgTypes.h" + +/*================================================================================================== + DEFINES +==================================================================================================*/ + +typedef void (*msg_sensor_cb)(); + +/*================================================================================================== + FUNCTION PROTOTYPES +==================================================================================================*/ + +msg_error_t MsgSensorConnect(); +void MsgSensorDisconnect(); +msg_error_t MsgRegSensorCB(msg_sensor_cb cb); + +#endif // MSG_SENSOR_H diff --git a/include/externals/MsgSoundPlayer.h b/include/externals/MsgSoundPlayer.h new file mode 100755 index 0000000..0aec565 --- /dev/null +++ b/include/externals/MsgSoundPlayer.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef MSG_SOUND_PLAYER_H +#define MSG_SOUND_PLAYER_H + + +/*================================================================================================== + TYPES +==================================================================================================*/ +typedef unsigned char MSG_SOUND_TYPE_T; + +/*================================================================================================== + ENUMS +==================================================================================================*/ +enum _MSG_SOUND_TYPE_E +{ + MSG_SOUND_PLAY_DEFAULT = 0, + MSG_SOUND_PLAY_USER, + MSG_SOUND_PLAY_EMERGENCY, + MSG_SOUND_PLAY_VOICEMAIL, +}; + +/*================================================================================================== + CLASS DEFINITIONS +==================================================================================================*/ +class MsgSoundPlayer +{ +public: + static MsgSoundPlayer* instance(); + + void MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_SOUND_TYPE_T soundType); + void MsgSoundPlayStop(); + + void MsgSoundInitRepeatAlarm(); + void MsgSoundPlayDtmf(); + + void MsgGetRingtonePath(char *userRingtonePath, char **msg_tone_file_path_p); + void MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *bPlayVibration, bool *bOnCall); + +private: + MsgSoundPlayer(); + ~MsgSoundPlayer(); + + void MsgSoundPlayMelody(char *pMsgToneFilePath); + void MsgSoundPlayVibration(char *vibrationPath, bool isOnCall); + + void MsgSoundSetRepeatAlarm(); + void MsgSoundCreateRepeatAlarm(int RepeatTime); + int MsgSoundGetUnreadMsgCnt(); + + static MsgSoundPlayer* pInstance; + + bool bPlaying; + bool bVibrating; + bool bFeedbackInit; + + int g_alarmId; + + char *defaultRingtonePath; +}; + +#endif // MSG_SOUND_PLAYER_H + diff --git a/include/utils/MsgSpamFilter.h b/include/externals/MsgSpamFilter.h similarity index 56% rename from include/utils/MsgSpamFilter.h rename to include/externals/MsgSpamFilter.h index d776c8e..ea67d8e 100755 --- a/include/utils/MsgSpamFilter.h +++ b/include/externals/MsgSpamFilter.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_SPAM_FILTER_H @@ -33,5 +33,6 @@ msg_error_t MsgSetFilterOperation(bool bSetFlag); msg_error_t MsgGetFilterOperation(bool *pSetFlag); bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo); +bool MsgCheckFilterByWord(MsgDbHandler *pDbHandle, const char *pMsgText); #endif // MSG_SPAM_FILTER_H diff --git a/include/framework/MsgCmdHandler.h b/include/framework/MsgCmdHandler.h index 1906581..eb8fe6d 100755 --- a/include/framework/MsgCmdHandler.h +++ b/include/framework/MsgCmdHandler.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_CMD_HANDLER_H @@ -35,6 +35,7 @@ int MsgUpdateThreadReadStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgUpdateProtectedStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgDeleteMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgDeleteAllMessageInFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgDeleteMessageByListHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgMoveMessageToFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgMoveMessageToStorageHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgCountMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent); @@ -69,19 +70,23 @@ int MsgSetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgGetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgCancelReqHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgRegIncomingMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgRegIncomingPushMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgRegIncomingCBMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgRegIncomingSyncMLMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgRegIncomingLBSMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgRegSyncMLMsgOperationCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgRegIncomingReportMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgIncomingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgIncomingSyncMLMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgIncomingLBSMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent); @@ -93,14 +98,16 @@ int MsgDeleteFilterHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgGetFilterListHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgSetFilterOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgGetFilterOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent); - -int MsgGetSMSCListHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetCBInfoHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetSmsSendOptHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetMmsSendOptHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetMmsRecvOptHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetPushMsgOptHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetVoiceMsgOptHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetGeneralOptHandler(const MSG_CMD_S *pCmd, char **ppEvent); - +int MsgSetFilterActivationHandler(const MSG_CMD_S *pCmd, char **ppEvent); + +int MsgAddPushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgDeletePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgUpdatePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent); + +int MsgAddSimMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent); +int MsgUpdateIMSIHandler(const MSG_CMD_S *pCmd, char **ppEvent); +#ifdef FEATURE_SMS_CDMA +int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent); +#endif #endif // MSG_CMD_HANDLER_H diff --git a/include/framework/MsgDeliverHandler.h b/include/framework/MsgDeliverHandler.h index 0f0100b..c8f3cb8 100755 --- a/include/framework/MsgDeliverHandler.h +++ b/include/framework/MsgDeliverHandler.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_DELIVER_HANDLER_H @@ -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); /*================================================================================================== diff --git a/include/framework/MsgPluginConfig.h b/include/framework/MsgPluginConfig.h deleted file mode 100755 index d07d2e3..0000000 --- a/include/framework/MsgPluginConfig.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -* 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_PLUGIN_CONFIG_H -#define MSG_PLUGIN_CONFIG_H - - -/*================================================================================================== - INCLUDE FILES -==================================================================================================*/ -#include -#include -#include -#include -#include "MsgDebug.h" -#include "MsgTypes.h" -#include "MsgCppTypes.h" - -class MsgPlgToken -{ - int tokenType; // not defined 0, title: 1, msgtype: 2, libpath: 3 - char tokenVal[256]; // null-terminated char array - -public: - MsgPlgToken(char* pstr=NULL) : tokenType(TOK_UNDEFINED) - { - if(pstr) - { - tokenize(pstr); - } - else - { - bzero(tokenVal, 256); - } - } - - MsgPlgToken& operator = (const MsgPlgToken& rhs) - { - if (this != &rhs) - { - tokenType = rhs.tokenType; - strncpy(tokenVal, rhs.tokenVal, 255); - } - - return *this; - } - - int getType() const { return tokenType; } // not defined 0, title: 1, msgtype: 2, libpath: 3 - const char* getVal(void) const { return tokenVal; } - void getVal(CharVector& vec) const { vec.assign(tokenVal, tokenVal+strlen(tokenVal));} - int tokenize(char* pStr); - - enum { TOK_UNDEFINED=0, TOK_PLG_TITLE, TOK_PLG_TYPE, TOK_PLG_PATH }; - - void reset() { tokenType = TOK_UNDEFINED; } - operator void*() const { - return (tokenType==TOK_UNDEFINED)? NULL:(void*) this; - } -}; - -typedef std::vector MsgPlgTokenVec; -typedef std::map MsgConfigMap; - -class MsgPlgConfig -{ - MsgConfigMap configMap; - void insert(const MsgPlgToken& tokTitle, const MsgPlgToken& tokMsgType, const MsgPlgToken& tokLibPath); - -public: - MsgPlgConfig(FILE* fp); - - /* access method for tokens */ - const CharVector& title(unsigned int pos);// const; // iteration with ith position i=0, .. , itemCount-1 - inline int titleCount() const { return configMap.size(); } - - void token(const CharVector& key, unsigned int pos, MsgPlgToken& retTok);// const; - void token(int i, unsigned int pos, MsgPlgToken& retTok);// const; - int tokenCount(const CharVector& key) { return configMap[key].size(); } // const leads to error why? -}; - -#endif // MSG_PLUGIN_CONFIG_H diff --git a/include/framework/MsgPluginManager.h b/include/framework/MsgPluginManager.h index 551efb9..9d49a33 100755 --- a/include/framework/MsgPluginManager.h +++ b/include/framework/MsgPluginManager.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_PLUGIN_MANAGER_H @@ -24,14 +24,11 @@ #include "MsgTypes.h" #include "MsgPluginInterface.h" -#include "MsgPluginConfig.h" - +#include "MsgCppTypes.h" /*================================================================================================== DEFINES ==================================================================================================*/ -#define MSG_PLUGIN_CFG_PATH "/usr/share/msg-service/" -#define MSG_PLUGIN_CFG_NAME "plugin.cfg" /*================================================================================================== @@ -48,24 +45,27 @@ public: msg_error_t submitReq(MSG_REQUEST_INFO_S *pReqInfo); msg_error_t registerListener(MSG_PLUGIN_LISTENER_S *pListener); - msg_error_t checkSimStatus(MSG_SIM_STATUS_T *pStatus); - msg_error_t checkDeviceStatus(); - msg_error_t initSimMessage(); msg_error_t saveSimMessage(MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList); +#ifndef FEATURE_SMS_CDMA + msg_error_t deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId); + msg_error_t setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId); + msg_error_t setMemoryStatus(msg_sim_slot_id_t sim_idx, msg_error_t Error); +#else msg_error_t deleteSimMessage(msg_sim_id_t SimMsgId); msg_error_t setReadStatus(msg_sim_id_t SimMsgId); msg_error_t setMemoryStatus(msg_error_t Error); - - msg_error_t initConfigData(MSG_SIM_STATUS_T SimStatus); +#endif msg_error_t setConfigData(const MSG_SETTING_S *pSetting); msg_error_t getConfigData(MSG_SETTING_S *pSetting); + msg_error_t getDefaultNetworkSimId(int *simId); + // MMS handlers msg_error_t addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData); msg_error_t updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData); msg_error_t processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject); - msg_error_t getMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg); + msg_error_t getMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char **pDestMsg); msg_error_t updateRejectStatus(MSG_MESSAGE_INFO_S *pMsgInfo); msg_error_t composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo); @@ -79,14 +79,24 @@ 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 MsgPluginMap; +typedef std::map MsgPluginMap; + +typedef struct { + MSG_MAIN_TYPE_T type; + const char *path; +} MSG_PLG_TABLE_T; + +const static MSG_PLG_TABLE_T __msg_plg_items[] = { + { MSG_SMS_TYPE, "/usr/lib/libmsg_sms_plugin.so" }, + { MSG_MMS_TYPE, "/usr/lib/libmsg_mms_plugin.so" } +}; /*================================================================================================== @@ -99,8 +109,8 @@ public: void initialize(); void finalize(); + MsgPlugin* checkPlugin(MSG_MAIN_TYPE_T mainType); MsgPlugin* getPlugin(MSG_MAIN_TYPE_T mainType); - void loadPlugins(const char* path); private: MsgPluginManager(); diff --git a/include/framework/MsgSettingHandler.h b/include/framework/MsgSettingHandler.h index 7b6823d..54ba7ba 100755 --- a/include/framework/MsgSettingHandler.h +++ b/include/framework/MsgSettingHandler.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_SETTING_HANDLER_H @@ -27,8 +27,6 @@ /*================================================================================================== FUNCTION PROTOTYPES ==================================================================================================*/ -msg_error_t MsgInitSimConfig(MSG_SIM_STATUS_T SimStatus); - msg_error_t MsgSetConfigData(const MSG_SETTING_S *pSetting); msg_error_t MsgGetConfigData(MSG_SETTING_S *pSetting); @@ -40,7 +38,8 @@ msg_error_t MsgSetMMSRecvOpt(const MSG_SETTING_S *pSetting); 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); @@ -51,10 +50,12 @@ void MsgGetMMSRecvOpt(MSG_SETTING_S *pSetting); void MsgGetMMSStyleOpt(MSG_SETTING_S *pSetting); void MsgGetPushMsgOpt(MSG_SETTING_S *pSetting); void MsgGetCBMsgOpt(MSG_SETTING_S *pSetting); + void MsgGetVoiceMailOpt(MSG_SETTING_S *pSetting); void MsgGetMsgSizeOpt(MSG_SETTING_S *pSetting); msg_error_t MsgSetConfigInSim(const MSG_SETTING_S *pSetting); +msg_error_t MsgGetConfigInSim(MSG_SETTING_S *pSetting); //void MsgSetDefaultConfig(); diff --git a/include/framework/MsgStorageHandler.h b/include/framework/MsgStorageHandler.h index 68d97fd..a6dae82 100755 --- a/include/framework/MsgStorageHandler.h +++ b/include/framework/MsgStorageHandler.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_STORAGE_HANDLER_H @@ -34,6 +34,7 @@ msg_error_t MsgStoConnectDB(); msg_error_t MsgStoDisconnectDB(); msg_error_t MsgStoInitDB(bool bSimChanged); +void MsgfreeMmapMutex(); msg_error_t MsgCreateConversationTable(); msg_error_t MsgCreateAddressTable(); @@ -50,39 +51,35 @@ 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_id_list_s**result_id_list); msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo); +msg_error_t MsgStoRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo); msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo); msg_error_t MsgStoUpdateReadStatus(msg_message_id_t MsgId, bool bRead); -msg_error_t MsgStoUpdateThreadReadStatus(msg_thread_id_t ThreadId); +msg_error_t MsgStoUpdateThreadReadStatus(msg_thread_id_t ThreadId, msg_id_list_s *pMsgIdList); msg_error_t MsgStoUpdateProtectedStatus(msg_message_id_t MsgId, bool bProtected); msg_error_t MsgStoDeleteMessage(msg_message_id_t MsgId, bool bCheckIndication); msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t FolderId, bool bOnlyDB, msg_id_list_s *pMsgIdList); +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 MsgStoMoveMessageToStorage(const msg_message_id_t MsgId, const msg_storage_id_t DestStorageId); msg_error_t MsgStoCountMessage(msg_folder_id_t FolderId, MSG_COUNT_INFO_S *pCountInfo); msg_error_t MsgStoCountMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount); msg_error_t MsgStoGetMessage(msg_message_id_t MsgId, MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo); -msg_error_t MsgStoGetFolderViewList(msg_folder_id_t FolderId, const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pMsgFolderViewList); msg_error_t MsgStoAddSyncMLMessage(MSG_MESSAGE_INFO_S *pMsgInfo, int ExtId, int PinCode); msg_error_t MsgStoGetMsgType(msg_message_id_t msgId, MSG_MESSAGE_TYPE_S* pMsgType); msg_error_t MsgStoGetText(msg_message_id_t MsgId, char *pSubject, char *pMsgText); msg_error_t MsgStoGetQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE_INFO_S *pMsg); -msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList); -msg_error_t MsgStoGetConversationViewList(msg_thread_id_t ThreadId, msg_struct_list_s *pConvViewList); -msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t ThreadId, msg_id_list_s *pMsgIdList); +msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t ThreadId, bool bIncludeProtect, msg_id_list_s *pMsgIdList); msg_error_t MsgStoCountMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pThreadCountInfo); -msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList); -msg_error_t MsgStoSearchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, msg_struct_list_s *pMsgList); -msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList); -msg_error_t MsgStoGetReportStatus(msg_message_id_t msgId, MSG_REPORT_STATUS_INFO_S* pReportStatus); +msg_error_t MsgStoGetSmsReportStatus(msg_message_id_t msgId, int *count, MSG_REPORT_STATUS_INFO_S **pReportStatus); +msg_error_t MsgStoGetMmsReportStatus(msg_message_id_t msgId, int *count, MSG_REPORT_STATUS_INFO_S **pReportStatus); 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); // Folder msg_error_t MsgStoAddFolder(const MSG_FOLDER_INFO_S *pFolderInfo); @@ -95,14 +92,13 @@ msg_error_t MsgStoAddFilter(const MSG_FILTER_S *pFilter); msg_error_t MsgStoUpdateFilter(const MSG_FILTER_S *pFilter); msg_error_t MsgStoDeleteFilter(msg_filter_id_t FilterId); msg_error_t MsgStoGetFilterList(msg_struct_list_s *pFilterList); +msg_error_t MsgStoSetFilterActivation(msg_filter_id_t filterId, bool bActive); // Sim Operation related Functions -msg_error_t MsgInitSimMessage(MSG_SIM_STATUS_T SimStatus); msg_error_t MsgStoClearSimMessageInDB(); // Internal Function -msg_error_t MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort); -msg_error_t MsgStoGetSmsSendOpt(msg_message_id_t MsgId, MSG_SENDINGOPT_INFO_S* pSendOpt); +msg_error_t MsgStoGetSmsSendOpt(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOpt); msg_error_t MsgStoGetMmsSendOpt(msg_message_id_t MsgId, MSG_SENDINGOPT_INFO_S* pSendOpt); // SyncML Msg @@ -112,12 +108,11 @@ bool MsgStoCheckSyncMLMsgInThread(msg_thread_id_t threadId); msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg); msg_error_t MsgStoGetContentLocation(MSG_MESSAGE_INFO_S* pMsgInfo); msg_error_t MsgStoSetReadReportSendStatus(msg_message_id_t msgId, int readReportSendStatus); - +msg_error_t MsgStoGetReadReportSendStatus(msg_message_id_t msgId, int *pReadReportSendStatus); /////////////////////////////////////////////////////////////////////////////////// // For MMS - will be removed msg_error_t MsgStoGetOrgAddressList(MSG_MESSAGE_INFO_S *pMsg); -msg_error_t MsgStoUpdateNetworkStatus(MSG_MESSAGE_INFO_S *pMsgInfo, msg_network_status_t Status); msg_error_t MsgStoGetSubject(msg_message_id_t MsgId, char* pSubject); msg_error_t MsgStoGetRecipientList(msg_message_id_t msgId, MSG_RECIPIENTS_LIST_S *pRecipientList); msg_error_t MsgStoGetReadStatus(msg_message_id_t MsgId, bool *pReadStatus); @@ -126,8 +121,30 @@ msg_error_t MsgStoGetAddrInfo(msg_message_id_t MsgId, MSG_ADDRESS_INFO_S *pAddrI /////////////////////////////////////////////////////////////////////////////////// msg_error_t MsgStoResetNetworkStatus(); +#if 0 +msg_error_t MsgStoResetCBMessage(); +#endif msg_error_t MsgStoCleanAbnormalMmsData(); msg_error_t MsgStoCheckReadReportStatus(msg_message_id_t msgId); +msg_error_t MsgStoAutoDeleteConversation(msg_thread_id_t threadId, msg_id_list_s *msgIdList); + +msg_error_t MsgStoAddPushEvent(MSG_PUSH_EVENT_INFO_S* pPushEvent); +msg_error_t MsgStoDeletePushEvent(MSG_PUSH_EVENT_INFO_S* pPushEvent); +msg_error_t MsgStoUpdatePushEvent(MSG_PUSH_EVENT_INFO_S* pSrc, MSG_PUSH_EVENT_INFO_S* pDst); + +msg_message_id_t MsgStoAddSimMessage(MSG_MESSAGE_INFO_S *pMsg, int *simIdList, int listSize); +msg_error_t MsgStoGetFailedMessage(int **failed_msg_list, int *count); + +msg_error_t MsgStoGetReplaceMsgId(MSG_MESSAGE_INFO_S *pMsgInfo); +msg_error_t MsgStoAddWAPMsg(MSG_MESSAGE_INFO_S *pMsgInfo); +msg_error_t MsgStoAddCOWAPMsg(MSG_MESSAGE_INFO_S *pMsgInfo); +msg_error_t MsgStoAddCBMsg(MSG_MESSAGE_INFO_S *pMsgInfo); +msg_error_t MsgStoCheckPushMsgValidation(MSG_PUSH_MESSAGE_S *pPushMsg, bool *pbProceed); +msg_error_t MsgStoUpdateAllAddress(); +#ifdef FEATURE_SMS_CDMA +msg_error_t MsgCheckUniqueness(bool bInsert, msg_message_id_t msgId, MSG_UNIQUE_INDEX_S *p_msg); +#endif +msg_error_t MsgStoUpdateIMSI(int sim_idx); #endif // MSG_STORAGE_HANDLER_H diff --git a/include/framework/MsgSubmitHandler.h b/include/framework/MsgSubmitHandler.h index c3f42b9..d3d9591 100755 --- a/include/framework/MsgSubmitHandler.h +++ b/include/framework/MsgSubmitHandler.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_SUBMIT_HANDLER_H diff --git a/include/framework/MsgTransManager.h b/include/framework/MsgTransManager.h index 554b7d6..e8294a6 100755 --- a/include/framework/MsgTransManager.h +++ b/include/framework/MsgTransManager.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_TRANSACTION_MANAGER_H @@ -25,6 +25,7 @@ #include #include "MsgMutex.h" +#include "MsgQueue.h" #include "MsgIpcSocket.h" #include "MsgCmdTypes.h" #include "MsgInternalTypes.h" @@ -32,6 +33,7 @@ + /*================================================================================================== DEFINITION ==================================================================================================*/ @@ -40,6 +42,8 @@ typedef std::map sentmsg_map; typedef std::map fd_map; typedef std::list newmsg_list; typedef std::list mmsconf_list; +typedef std::list pushmsg_list; +typedef std::list cbmsg_list; typedef std::list syncmlmsg_list; typedef std::list lbsmsg_list; typedef std::list javamms_list; @@ -47,11 +51,6 @@ typedef std::list syncmlop_list; /*================================================================================================== - FUNCTION PROTOTYPES -==================================================================================================*/ -void MsgContactChangedCallback(); - -/*================================================================================================== CLASS DEFINITIONS ==================================================================================================*/ class MsgTransactionManager @@ -60,6 +59,7 @@ public: static MsgTransactionManager* instance(); void run(); + void workerEventQueue(); void write(int fd, const char* buf, int len); // methods for sent status event @@ -70,21 +70,26 @@ public: void setSentStatusCB(int listenerFd); void setIncomingMsgCB(MSG_CMD_REG_INCOMING_MSG_CB_S *pCbInfo); void setMMSConfMsgCB(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S *pCbinfo); + void setPushMsgCB(MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S *pCbinfo); + void setCBMsgCB(MSG_CMD_REG_INCOMING_CB_MSG_CB_S *pCbInfo); void setSyncMLMsgCB(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S *pCbinfo); void setLBSMsgCB(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCbinfo); void setJavaMMSList(MSG_CMD_REG_INCOMING_JAVAMMS_TRID_S *pTrId); void setSyncMLMsgOperationCB(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCbinfo); void setStorageChangeCB(int listenerFd); + void setReportMsgCB(int listenerFd); javamms_list& getJavaMMSList(); void broadcastIncomingMsgCB(const msg_error_t err, const MSG_MESSAGE_INFO_S *msgInfo); void broadcastMMSConfCB(const msg_error_t err, const MSG_MESSAGE_INFO_S *msgInfo, const MMS_RECV_DATA_S *mmsRecvData); + void broadcastPushMsgCB(const msg_error_t err, const MSG_PUSH_MESSAGE_DATA_S *pushData); + void broadcastCBMsgCB(const msg_error_t err, const MSG_CB_MSG_S *cbMsg); void broadcastSyncMLMsgCB(const msg_error_t err, const MSG_SYNCML_MESSAGE_DATA_S *syncMLData); void broadcastLBSMsgCB(const msg_error_t err, const MSG_LBS_MESSAGE_DATA_S *lbsData); void broadcastSyncMLMsgOperationCB(const msg_error_t err, const int msgId, const int extId); void broadcastStorageChangeCB(const msg_error_t err, const msg_storage_change_type_t storageChangeType, const msg_id_list_s *pMsgIdList); - + void broadcastReportMsgCB(const msg_error_t err, const msg_report_type_t reportMsgType, const MSG_MESSAGE_INFO_S *pMsgInfo); void setTMStatus(); void getTMStatus(); @@ -94,7 +99,8 @@ private: void handleRequest(int fd); void cleanup(int fd); - bool checkPrivilege(MSG_CMD_TYPE_T CmdType, const char *pCookie); +// bool checkPrivilege(MSG_CMD_TYPE_T CmdType, const char *pCookie); + bool checkPrivilege(int fd, MSG_CMD_TYPE_T CmdType); static MsgTransactionManager* pInstance; @@ -102,21 +108,24 @@ private: bool running; handler_map handlerMap; - sentmsg_map sentMsgMap; // req_id, listener_fd, msghandle_addr fd_map statusCBFdMap; // src_fd, true if registered newmsg_list newMsgCBList; // src_fd, msgType, port if registered mmsconf_list newMMSConfMsgCBList; // src_fd, msgType, port if registered + pushmsg_list newPushMsgCBList; // src_fd, msgType, port if registered + cbmsg_list newCBMsgCBList; // src_fd, msgType, port if registered syncmlmsg_list newSyncMLMsgCBList; // src_fd, msgType, port if registered lbsmsg_list newLBSMsgCBList; // src_fd, msgType, port if registered javamms_list javaMMSList; // trId list to distinguish sent Java MMS msg when sendconf received syncmlop_list operationSyncMLMsgCBList; // src_fd, msgType, port if registered fd_map storageChangeFdMap; // src_fd, true if registered + fd_map reportMsgCBFdMap; // src_fd, true if registered Mutex mx; CndVar cv; + MsgSimpleQ eventQueue; }; #endif //MSG_TRANSACTION_MANAGER_H diff --git a/include/mapi/msg.h b/include/mapi/msg.h index cf23937..4ded743 100755 --- a/include/mapi/msg.h +++ b/include/mapi/msg.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_H_ @@ -24,214 +24,1223 @@ #include "msg_types.h" +/*================================================================================================== + DEFINES +==================================================================================================*/ + +/** + * @brief Defines macro for privilege name http://tizen.org/privilege/message.read + */ +#define MSG_SERVICE_READ_PRIV_NAME "http://tizen.org/privilege/message.read" + +/** + * @brief Defines macro for privilege name http://tizen.org/privilege/message.write + */ +#define MSG_SERVICE_WRITE_PRIV_NAME "http://tizen.org/privilege/message.write" + #ifdef __cplusplus extern "C" { #endif -/** - * @ingroup MESSAGING_FRAMEWORK - * @defgroup MESSAGING_CONTROL_API Messaging Control API - * @{ - */ - /*================================================================================================== FUNCTION PROTOTYPES ==================================================================================================*/ /** - - * \par Description: - * Opens a channel between an application and messaging framework. + * @internal + * @ingroup MSG_SERVICE_FRAMEWORK + * @defgroup MSG_SERVICE_FRAMEWORK_CONTROL_MODULE Control API + * @brief The Control API provides functions to manage message handle and set or get each structure. * - * \par Purpose: - * For application to utilize the services of Messaging Framework, this API should be called to establish connection between the application and Messaging Framework. + * @internal + * @addtogroup MSG_SERVICE_FRAMEWORK_CONTROL_MODULE + * @{ * - * \par Typical use case: - * Any application which utilizes the services of Messaging Framework needs to call this API. + * @section MSG_SERVICE_FRAMEWORK_CONTROL_MODULE_HEADER Required Header + * \#include * - * \par Method of function operation: - * Check for Message Server ready status. If ready connect to the Messaging Server socket and pass the handle application. + * @section MSG_SERVICE_FRAMEWORK_CONTROL_MODULE_OVERVIEW Overview * - * \par Sync (or) Async: - * This is a Synchronous API. + * The CONTROL API provides the following functionalities: + * - Handles message handle + * - Get/Set message and setting values * - * \par Important notes: - * - The handle parameter returned must be used by application for further API calls to Messaging Service \n - * - memory for the handle need not be allocated by the application \n - * - An error will be returned in case Messaging Service is not running. + * @section MSG_SERVICE_FRAMEWORK_CONTROL_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.telephony\n * - * \param msg_handle_t input - handle to be passed for all Messaging Services . + * It is recommended to design feature related codes in your application for reliability.\n * - * \return Return Type (int) \n - * - MSG_SUCCESS - Successfully connected to Messaging Service \n - * - MSG_ERR_NULL_POINTER - Input parameter is NULL. - * - MSG_ERR_MEMORY_ERROR - Memory error. - * - MSG_ERR_COMMUNICATION_ERROR - Communication error between client and server \n + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * - * \par Related functions: - * None + * More details on featuring your application can be found from
Feature Element. * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * msg_error_t err = MSG_SUCCESS; + */ + +/** + * @brief Opens a channel between an application and messaging framework. + * @details For application to utilize the services of Messaging Framework, this API should be called to establish + * connection between the application and Messaging Framework. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * err = msg_open_msg_handle(&msgHandle); + * @remarks The handle parameter returned must be used by application for further API calls to Messaging Service. + * @remarks The memory for the handle need not be allocated by the application. + * @remarks An error will be returned in case Messaging Service is not running. * - * if (err != MSG_SUCCESS) - * { - * sprintf(str, "msg_open_msg_handle() Fail [%d]", err); - * print(str); + * @param[in] handle The Message handle to be passed for all messaging services * - * return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code. - * } + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_MEMORY_ERROR Memory error + * @retval MSG_ERR_COMMUNICATION_ERROR Communication error between client and server + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_open_msg_handle(msg_handle_t *handle); /** - - * \par Description: - * Closes the channel between application and messaging framework. + * @brief Closes the channel between application and messaging framework. + * @details Once application utilizes services of Messaging Service, this API needs to be invoked + * to close the channel between application and Messaging Service. * - * \par Purpose: - * Once application utilizes services of Messaging Service, this API needs to be invoked the close the channel between application and Messaging Service. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Typical use case: - * Any application which has completed using services of Messaging Framework needs to call this API. + * @remarks The handle parameter returned must be used by application for further API calls to Messaging Service. + * @remarks The memory for the handle need not be allocated by the application \n + * @remarks An error will be returned in case Messaging Service is not running. * - * \par Method of function operation: - * Closes the connection to Messaging Service and deleted the reference to the handle object + * @param[in] handle The Message handle to be passed for all messaging services * - * \par Sync (or) Async: - * This is a Synchronous API. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Important notes: - * - The handle parameter returned must be used by application for further API calls to Messaging Service \n - * - memory for the handle need not be allocated by the application \n - * - An error will be returned in case Messaging Service is not running. + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_COMMUNICATION_ERROR Communication error between client and server + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_close_msg_handle(msg_handle_t *handle); + + +/** + * @brief Create structure pointer to get/set message framework data. + * @details Get/set message framework data with this structure pointer. * - * \param msg_handle_t input - handle to be passed for all Messaging Services . + * @since_tizen 2.3 * - * \return Return Type (int) \n - * - MSG_SUCCESS - Successfully connected to Messaging Service \n - * - MSG_ERR_NULL_POINTER - Input parameter is NULL. - * - MSG_ERR_COMMUNICATION_ERROR - Communication error between client and server \n + * @remarks It should use defined enumerations. + * @remarks You must release handle after operations. * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @param[in] field The enumerations to create the structure pointer * - * \par Related functions: - * None + * @return The created structure pointer on success, + * otherwise null value * - * \par Known issues/bugs: - * None + * @retval #msg_struct_t Successfully created structure pointer + * @retval NULL Invalid parameter + * @retval MSG_ERR_NOT_SUPPORTED Not supported * - * \par Sample code: - * \code - * ... + */ + +msg_struct_t msg_create_struct(int field); + + +/** + * @brief Release memory for message data structure. + * @details You must release memory of message data structure that is allocated by msg_create_struct(). + * + * @since_tizen 2.3 + * + * @remarks It should not be used after this API. + * + * @param[in] msg_struct_handle The structure pointer to release * - * msg_handle_t msgHandle = NULL; - * msg_error_t err = MSG_SUCCESS; + * @return @c 0 on success, + * otherwise a negative error value * - * ... + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_NULL_POINTER Input parameter is NULL + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + +int msg_release_struct(msg_struct_t *msg_struct_handle); + + +/** + * @brief Release memory for list structure. + * @details You must release memory of list structure that is allocated by getting list API. * - * err = msg_open_msg_handle(&msgHandle); + * @since_tizen 2.3 * - * ... + * @remarks It should not be used after this API * - * err = msg_close_msg_handle(&msgHandle); + * @param[in] msg_struct_list The list structure pointer to release * - * if (err != MSG_SUCCESS) - * { - * sprintf(str, "msg_close_msg_handle() Fail [%d]", err); - * print(str); + * @return @c 0 on success, + * otherwise a negative error value * - * return err; // if success, return OPERATION_SUCCESS. Or if fail, return related error code. - * } + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_NULL_POINTER Input parameter is NULL + * @retval MSG_ERR_NOT_SUPPORTED Not supported * - * ... - * \endcode */ -/*================================================================================================*/ -int msg_close_msg_handle(msg_handle_t *handle); +int msg_release_list_struct(msg_struct_list_s *msg_struct_list); -msg_struct_t msg_create_struct(int field); -int msg_release_struct(msg_struct_t *msg_struct_handle); -int msg_release_list_struct(msg_struct_list_s *msg_struct_list); +/** + * @brief Get a specific integer value from message structure data. + * + * @since_tizen 2.3 + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested integer value + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int *value); + + +/** + * @brief Gets a specific string value from message structure data. + * + * @since_tizen 2.3 + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested string value + * @param[in] size The allocated buffer size of application side + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char *value, int size); + + +/** + * @brief Gets a specific boolean value from message structure data. + * + * @since_tizen 2.3 + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested boolean value + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_get_bool_value(msg_struct_t msg_struct_handle, int field, bool *value); + + +/** + * @brief Gets an inner structure handle from message structure data. + * + * @since_tizen 2.3 + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested structure handle + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_get_struct_handle(msg_struct_t msg_struct_handle, int field, msg_struct_t *value); + + +/** + * @brief Gets a list handle from message structure data. + * + * @since_tizen 2.3 + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested list handle + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ +/*================================================================================================*/ int msg_get_list_handle(msg_struct_t msg_struct_handle, int field, void **value); + +/** + * @brief Sets a specific integer value to message structure data. + * + * @since_tizen 2.3 + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested integer value + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_set_int_value(msg_struct_t msg_struct_handle, int field, int value); + + +/** + * @brief Sets a specific string to message structure data. + * + * @since_tizen 2.3 + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested string + * @param[in] size The requested size of string to set + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_set_str_value(msg_struct_t msg_struct_handle, int field, char *value, int size); + + +/** + * @brief Sets a specific boolean value to message structure data. + * + * @since_tizen 2.3 + * + * @details Set a specific boolean value to message structure data. + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested boolean value + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_set_bool_value(msg_struct_t msg_struct_handle, int field, bool value); + + +/** + * @brief Sets a inner structure handle to message structure data. + * + * @since_tizen 2.3 + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested structure handle to set + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_set_struct_handle(msg_struct_t msg_struct_handle, int field, msg_struct_t value); + + +/** + * @brief Set a list handle to message structure data. + * + * @since_tizen 2.3 + * + * @remarks Use valid enumerations. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to get a value of specific field + * @param[out] value The requested list handle to set + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter (msg_struct_handle/value) is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter (field) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_set_list_handle(msg_struct_t msg_struct_handle, int field, void *value); -int msg_mms_add_item(msg_struct_t msg_struct_handle, int field, msg_struct_t *item); + +/** + * @brief Gets a MMS structure handle from message structure. + * + * @since_tizen 2.3 + * + * @remarks Use valid structure handle. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[out] mms_struct_handle The MMS structure handle to get + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ int msg_get_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t mms_struct_handle); + + +/** + * @brief Sets a MMS structure handle to message structure. + * + * @since_tizen 2.3 + * + * @remarks Use valid structure handle. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[out] mms_struct_handle The MMS structure handle to set + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_set_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t mms_struct_handle); -//list + +/** + * @brief Adds an item to list handle of message structure type. + * + * @since_tizen 2.3 + * + * @remarks Use valid list_handle. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The field to set item + * @param[in] item The #msg_struct_t structure to be added to list handle + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + +int msg_list_add_item(msg_struct_t msg_struct_handle, int field, msg_struct_t *item); + + +/** + * @brief Gets n-th data from list handle. + * + * @since_tizen 2.3 + * + * @remarks Use valid list_handle. + * + * @param[in] list_handle A pointer of message structure type + * @param[in] index The index of list structure + * + * @return #msg_struct_t value on success, + * otherwise @c NULL value + * + * @retval #msg_struct_t Successfully done + * @retval NULL Input parameter (list_handle) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + msg_struct_t msg_list_nth_data(msg_list_handle_t list_handle, int index); + + +/** + * @brief Gets the length(count) of list handle. + * + * @since_tizen 2.3 + * + * @remarks Use valid list_handle. + * If there is an error, it will be returned as below values. + * + * @param[in] list_handle A pointer of message structure type + * + * @return The length of message list (int) + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + int msg_list_length(msg_list_handle_t list_handle); -// filter + +/** + * @brief Releases entire data of list handle in message structure. + * + * @since_tizen 2.3 + * + * @remarks Use valid msg_struct_handle and enumeration. + * + * @param[in] msg_struct_handle A pointer of message structure type + * @param[in] field The enumeration to release (list handle) + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter is NULL + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + +int msg_list_clear(msg_struct_t msg_struct_handle, int field); + + +/** + * @brief Releases entire data of a list handle and the list. + * + * @since_tizen 2.3.1 + * + * @remarks #msg_list_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] list_handle A pointer of message structure type + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_NULL_POINTER Input parameter is NULL + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + +int msg_list_free(msg_list_handle_t list_handle); + + +/** + * @brief Adds a filter to block messages by address or word. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_struct_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] filter A pointer to message filter structure + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_FILTER_ERROR Filter operation error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_add_filter(msg_handle_t handle, const msg_struct_t filter); + + +/** + * @brief Updates filter to block messages by address or word. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * @remarks #msg_struct_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] filter A pointer to message filter structure + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_FILTER_ERROR Filter operation error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_update_filter(msg_handle_t handle, const msg_struct_t filter); + + +/** + * @brief Deletes the filter to block messages by address or word. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @param[in] handle The message handle + * @param[in] filter_id The filter index to delete from filter DB + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_FILTER_ERROR Filter operation error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_delete_filter(msg_handle_t handle, msg_filter_id_t filter_id); + + +/** + * @brief Gets all filter list. + * @details This API is used to get a filter list that is already added filter set. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[out] filter_list A pointer to list of message filter structure + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_FILTER_ERROR Filter operation error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_filter_list(msg_handle_t handle, msg_struct_list_s *filter_list); + + +/** + * @brief Sets the flag of message blocking. + * @details This API is used to set a flag of block operation. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] set_flag Set @c true to enable block operation, + * otherwise set @c false to disable block operation + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_FILTER_ERROR Filter operation error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_filter_operation(msg_handle_t handle, bool set_flag); + + +/** + * @brief Gets the flag value of message blocking. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[out] set_flag @c true if message blocking is enabled, + * otherwise @c false if message blocking is not enabled + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_FILTER_ERROR Filter operation error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_filter_operation(msg_handle_t handle, bool *set_flag); -//setting + +/** + * @brief Sets the flag of message blocking for specific filter. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] filter_id The specific index to set flag + * @param[in] active Set @c true to enable the block operation, + * otherwise @c false to not enable the block operation + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_FILTER_ERROR Filter operation error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_set_filter_active(msg_handle_t handle, msg_filter_id_t filter_id, bool active); + + +/** + * @brief Gets SMSC list and informations. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of SMSC data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_smsc_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Sets SMSC list and informations. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of SMSC data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_smsc_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Gets CB channel list and informations. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of CB data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_cb_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Sets CB channel list and informations. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of CB data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_cb_opt(msg_handle_t handle, msg_struct_t msg_struct); + +/** + * @brief Gets SMS sending options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of sending option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_sms_send_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Sets SMS sending options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of sending option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_sms_send_opt(msg_handle_t handle, msg_struct_t msg_struct); + +/** + * @brief Gets MMS sending options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of sending option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_mms_send_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Sets MMS sending options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of sending option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_mms_send_opt(msg_handle_t handle, msg_struct_t msg_struct); + +/** + * @brief Gets MMS receiving options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of receiving option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_mms_recv_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Sets MMS receiving options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of receiving option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_mms_recv_opt(msg_handle_t handle, msg_struct_t msg_struct); + +/** + * @brief Gets push message options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of push message option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_push_msg_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Sets push message options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of push message option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_push_msg_opt(msg_handle_t handle, msg_struct_t msg_struct); + +/** + * @brief Gets voice message options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of voice message option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_voice_msg_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Sets voice message options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of voice message option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_voice_msg_opt(msg_handle_t handle, msg_struct_t msg_struct); + +/** + * @brief Gets message general options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of message general option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_general_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Sets message general options. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of message general option data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_general_opt(msg_handle_t handle, msg_struct_t msg_struct); + +/** + * @brief Gets message size. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of message size data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_get_msgsize_opt(msg_handle_t handle, msg_struct_t msg_struct); + + +/** + * @brief Sets message size. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] handle The message handle + * @param[in] msg_struct A structure pointer of message size data + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + int msg_set_msgsize_opt(msg_handle_t handle, msg_struct_t msg_struct); + +/** + * @brief Calculates input text length by encode type. + * + * @since_tizen 2.3 + * + * @remarks #msg_handle_t MUST be valid, otherwise the function will fail. + * + * @param[in] msg_text The string to calculate length + * @param[in] msg_encode_type_to The current encode type + * @param[out] text_size The calculated text size + * @param[out] segment_size The message segment size + * @param[out] msg_encode_type_in The encode type it should be changed to + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Successfully done + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is not valid. + * @retval MSG_ERR_NOT_SUPPORTED Not supported + * + */ + +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 } #endif diff --git a/include/mapi/msg_private.h b/include/mapi/msg_private.h index 13e0312..92168ba 100755 --- a/include/mapi/msg_private.h +++ b/include/mapi/msg_private.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_PRIVATE_H_ @@ -21,13 +21,39 @@ INCLUDE FILES ==================================================================================================*/ +#include "MsgDebug.h" +#include "MsgGconfWrapper.h" #include "MsgTypes.h" #include "MsgStorageTypes.h" #include "MsgTransportTypes.h" #include "MsgMmsTypes.h" #include "MsgFilterTypes.h" #include "MsgSettingTypes.h" +#include "MsgUtilFunction.h" +/*================================================================================================== + DEFINES +==================================================================================================*/ + +#define CHECK_MSG_SUPPORTED(feature_name) \ + do { \ + bool bSupported = false; \ + bSupported = MsgCheckFeatureSupport(feature_name); \ + if (bSupported == false) {\ + MSG_ERR("Feature [%s] not supported", feature_name);\ + return MSG_ERR_NOT_SUPPORTED; \ + } \ + } while(0) + +#define CHECK_MSG_SUPPORTED_RETURN_NULL(feature_name) \ + do { \ + bool bSupported = false; \ + bSupported = MsgCheckFeatureSupport(feature_name); \ + if (bSupported == false) {\ + MSG_ERR("Feature [%s] not supported", feature_name);\ + return NULL; \ + } \ + } while(0) /*================================================================================================== FUNCTION PROTOTYPES @@ -50,10 +76,20 @@ int msg_message_set_struct_hnd(void *data, int field, void *value); void msg_message_copy_message(MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_HIDDEN_S *pDst); +int msg_cb_message_get_int_value(void *data, int field, int *value); +int msg_cb_message_get_str_value(void *data, int field, char *value, int size); + +int msg_message_list_append(msg_struct_t msg_struct_handle, int field, msg_struct_t *item); +int msg_message_list_clear(msg_struct_t msg_struct_handle, int field); + + + // filter +bool msg_get_filter_info_bool(void *filter, int field); int msg_get_filter_info_int(void *filter, int field); char *msg_get_filter_info_str(void *filter, int field); +int msg_set_filter_info_bool(void *filter, int field, bool value); int msg_set_filter_info_int(void *filter, int field, int value); int msg_set_filter_info_str(void *filter, int field, char *value, int size); @@ -75,9 +111,12 @@ int msg_mms_set_bool_value(msg_struct_s *msg_struct, int field, bool value); int msg_mms_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value); int msg_mms_set_list_handle(msg_struct_s *msg_struct, int field, msg_list_handle_t value); +int msg_mms_list_append(msg_struct_t msg_struct_handle, int field, msg_struct_t *item); + void convert_to_mmsdata(const msg_struct_s *pSrc, MMS_MESSAGE_DATA_S *pDest); void convert_from_mmsdata(const MMS_MESSAGE_DATA_S *pSrc, msg_struct_s *pDest); - +void convert_to_hidden_mmsdata(MMS_DATA_S *pSrc, msg_struct_s *pDest); +void convert_from_hidden_mmsdata(msg_struct_s *pSrc, MMS_DATA_S *pDest); // setting int msg_setting_get_int_value(msg_struct_s *msg_struct, int field, int *value); int msg_setting_get_str_value(msg_struct_s *msg_struct, int field, char *src, int size); @@ -130,6 +169,8 @@ int msg_set_push_msg_opt_int(void *push_msg_opt, int field, int value); bool msg_get_push_msg_opt_bool(void *push_msg_opt, int field); int msg_set_push_msg_opt_bool(void *push_msg_opt, int field, bool value); +int msg_get_voice_msg_opt_int(void *voice_msg_opt, int field); +int msg_set_voice_msg_opt_int(void *voice_msg_opt, int field, int value); char *msg_get_voice_msg_opt_str(void *voice_msg_opt, int field); int msg_set_voice_msg_opt_str(void *voice_msg_opt, int field, char *val, int size); @@ -137,11 +178,18 @@ int msg_get_general_opt_int(void *general_opt, int field); int msg_set_general_opt_int(void *general_opt, int field, int value); bool msg_get_general_opt_bool(void *general_opt, int field); int msg_set_general_opt_bool(void *general_opt, int field, bool value); - +char *msg_get_general_opt_str(void *general_opt, int field); +int msg_set_general_opt_str(void *general_opt, int field, char *val, int size); int msg_get_msgsize_opt_int(void *size_opt, int field); int msg_set_msgsize_opt_int(void *size_opt, int field, int value); +/* Wap Push */ +char* msg_push_config_get_str(void *event_info, int field, int size); +bool msg_push_config_get_bool(void *event_info, int field); +int msg_push_config_set_str(void *event_info, int field, char *value, int size); +int msg_push_config_set_bool(void *event, int field, bool value); + /* added internal apis for new managed api (storage) */ int msg_syncml_info_get_int(void *syncml_info, int field); int msg_count_info_get_int(void *count_info, int field); @@ -150,16 +198,25 @@ int msg_thread_index_get_int(void *index_info, int field); int msg_sortrule_get_int(void *sort_info, int field); int msg_folder_info_get_int(void *folder_info, int field); int msg_thread_info_get_int(void *data, int field); +int msg_conv_info_get_int(void *data, int field); int msg_search_condition_get_int(void *condition_info, int field); +int msg_list_condition_get_int(void *condition_info, int field); int msg_report_status_get_int(void *report_info, int field); +char* msg_report_status_get_str(void *report_info, int field); char* msg_folder_info_get_str(void *folder_info, int field); char *msg_thread_info_get_str(void *data, int field); +char *msg_conv_info_get_str(void *data, int field); char* msg_search_condition_get_str(void *condition_info, int field, int size); +char* msg_list_condition_get_str(void *condition_info, int field, int size); bool msg_sendopt_get_bool(void *send_opt, int field); bool msg_sortrule_get_bool(void *sort_rule, int field); +bool msg_conv_get_bool(void *data, int field); +bool msg_thread_info_get_bool(void *data, int field); +bool msg_list_condition_get_bool(void *data, int field); int msg_sendopt_get_struct_handle(msg_struct_s *msg_struct, int field, void **value); int msg_syncml_get_struct_handle(msg_struct_s *msg_struct, int field, void **value); int msg_thread_index_get_struct_handle(msg_struct_s *msg_struct, int field, void **value); +int msg_list_condition_get_struct_handle(msg_struct_s *msg_struct, int field, void **value); int msg_address_info_get_int(void *addr_info, int field); int msg_mms_sendopt_get_int(void *opt_info, int field); int msg_reject_message_get_int(void *msg_info, int field); @@ -175,18 +232,23 @@ int msg_thread_index_set_int(void *index_info, int field, int value); int msg_sortrule_set_int(void *sort_info, int field, int value); int msg_folder_info_set_int(void *folder_info, int field, int value); int msg_search_condition_set_int(void *condition_info, int field, int value); +int msg_list_condition_set_int(void *condition_info, int field, int value); int msg_report_status_set_int(void *report_info, int field, int value); int msg_folder_info_set_str(void *folder_info, int field, char *value, int size); int msg_search_condition_set_str(void *condition_info, int field, char *value, int size); +int msg_list_condition_set_str(void *condition_info, int field, char *value, int size); int msg_sendopt_set_bool(void *send_opt, int field, bool value); int msg_sortrule_set_bool(void *sort_rule, int field, bool value); +int msg_list_condition_set_bool(void *data, int field, bool value); int msg_sendopt_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value); int msg_syncml_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value); int msg_thread_index_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value); +int msg_list_condition_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value); int msg_address_info_set_int(void *addrinfo, int field, int value); int msg_mms_sendopt_set_int(void *opt_info, int field, int value); int msg_reject_message_set_int(void *msg_info, int field, int value); int msg_address_info_set_str(void *addr_info, int field, char *value, int size); +int msg_media_info_set_str(void *media_info, int field, char *value, int size); int msg_reject_message_set_str(void *msg_info, int field, char *value, int size); int msg_mms_sendopt_set_bool(void *option, int field, bool value); int msg_sms_sendopt_set_bool(void *option, int field, bool value); @@ -198,5 +260,11 @@ int msg_request_set_int(void *request_info, int field, int value); int msg_request_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value); int msg_sent_status_get_int(MSG_SENT_STATUS_S *sent_status_info, int field); +char* msg_media_item_get_str(void *data, int field, int size); +int msg_media_item_get_int(void *data, int field, int *value); +int msg_conversation_get_list_hnd(void *data, int field, void **value); +int msg_multipart_get_str_value(void *data, int field, char *value, int size); +int msg_multipart_get_int_value(void *data, int field, int *value); +int msg_multipart_set_str_value(void *data, int field, char *value, int size); #endif /* MSG_PRIVATE_H_ */ diff --git a/include/mapi/msg_storage.h b/include/mapi/msg_storage.h index 796f70f..837af02 100755 --- a/include/mapi/msg_storage.h +++ b/include/mapi/msg_storage.h @@ -1,35 +1,22 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -/** - * @file MapiStorage.h - * @brief Defines storage API of messaging framework - * @version 1.0 - */ - #ifndef MAPI_STORAGE_H #define MAPI_STORAGE_H -/** - * @section Introduction - * - Introduction : Overview on Messaging Storage API - * @section Program - * - Program : Messaging Storage API Reference - */ - /*================================================================================================== INCLUDE FILES ==================================================================================================*/ @@ -41,2059 +28,1103 @@ extern "C" { #endif -/** - * @ingroup MESSAGING_FRAMEWORK - * @defgroup MESSAGING_STORAGE_API Messaging Storage API - * @{ - */ - -/*================================================================================================== - FUNCTION PROTOTYPES -==================================================================================================*/ /** - - * \par Description: - * Saves a message to the database. - * - * \par Purpose: - * This API is used to save Message object to the database. + * @internal + * @ingroup MSG_SERVICE_FRAMEWORK + * @defgroup MSG_SERVICE_FRAMEWORK_STORAGE_MODULE Storage API + * @brief The Storage API provides functions to get message information with multiple types. * - * \par Typical use case: - * Save Message feature is used when the message is to be stored to persistent memory for later reference. + * @internal + * @addtogroup MSG_SERVICE_FRAMEWORK_STORAGE_MODULE + * @{ * - * \par Method of function operation: - * Sets up the database connection and inserts the message to message table. + * @section MSG_SERVICE_FRAMEWORK_STORAGE_MODULE_HEADER Required Header + * \#include * - * \par Sync (or) Async: - * This is a Synchronous API. + * @section MSG_SERVICE_FRAMEWORK_STORAGE_MODULE_OVERVIEW Overview * - * \par Important notes: - * - Mandatory fields of a message structure MUST be valid, otherwise the function will be failed. + * The Storage API provides the following functionalities: * - * \param input - msg_handle_t handle is Message handle. - * \param input - msg_message_t msg is a pointer to an msg_message_t structure. - * \param input - send_opt is a pointer to an MSG_SENDINGOPT_S structure. + * - Get message information * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Successfully connected to Messaging Service \n - * - MSG_ERR_NULL_POINTER - Input parameter is NULL. - * - MSG_ERR_STORAGE_ERROR - Storage is error. + * @section MSG_SERVICE_FRAMEWORK_STORAGE_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.telephony\n * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * It is recommended to design feature related codes in your application for reliability.\n * - * \par Related functions: - * None + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n * - * \par Known issues/bugs: - * None + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * - * \par Sample code: - * \code - * ... + * More details on featuring your application can be found from Feature Element. * - * msg_handle_t msgHandle = NULL; - * msg_message_t msg; - * MSG_SENDINGOPT_S sendingOpt = {0}; + */ + + +/*================================================================================================== + FUNCTION PROTOTYPES +==================================================================================================*/ + +/** + * @brief Saves a message to the database. * - * ... + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * err = msg_open_msg_handle(&msgHandle); + * @remarks Mandatory fields of a message structure MUST be valid, otherwise the function will fail. * - * ... + * @param[in] handle The Message handle + * @param[in] msg A pointer to a message structure + * @param[in] send_opt A pointer to a message structure for sending option * - * err = msg_add_message(handle, (msg_message_t) &msg, &sendingOpt); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } + * @return The message ID on success, + * otherwise a negative error value * - * ... - * \endcode + * @retval MESSAGE_ID Success in operation + * @retval MSG_ERR_INVALID_PARAMETER(-9) Invalid parameter + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_add_message(msg_handle_t handle, const msg_struct_t msg, const msg_struct_t send_opt); /** - - * \par Description: - * Adds a SyncML message to the database. - * - * \par Purpose: - * This API is used to save a SyncML message to the database. - * - * \par Typical use case: - * Save Message feature is used when the message is to be stored to persistent memory for later reference. + * @brief Adds a SyncML message to the database. * - * \par Method of function operation: - * Sets up the database connection and inserts the syncml message to message table. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Sync (or) Async: - * This is a Synchronous API. + * @remarks Mandatory fields of a message structure MUST be valid, otherwise the function will fail. * - * \par Important notes: - * - Mandatory fields of a message structure MUST be valid, otherwise the function will be failed. + * @param[in] handle The Message handle + * @param[in] syncml_msg A pointer to a syncml message structure * - * \param input - msg_handle_t handle is Message handle. - * \param input - MSG_SYNCML_MESSAGE_S syncml_msg is a pointer to an MSG_SYNCML_MESSAGE_S structure. + * @return @c 0 on success, + * otherwise a negative error value * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_NULL_POINTER - pMsg is NULL. - * - MSG_ERR_INVALID_MSGHANDLE - Message handle is invalid. - * - MSG_ERR_MSGHANDLE_NOT_CONNECTED - Message handle is not connected. - * - MSG_ERR_STORAGE_FULL - Storage is FULL. - * - MSG_ERR_COMMUNICATION_ERROR - Communication between client and server is error. - * - MSG_ERR_MEMORY_ERROR - Memory is error. - * - MSG_ERR_MAX_NUMBER_REACHED - Max number is reached. - * - MSG_ERR_PLUGIN - Generic error code for plugin. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * MSG_SYNCML_MESSAGE_S syncMLMsg; - * - * ... - * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * int err = msg_add_syncml_message(msgHandle, &syncMLMsg); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_add_syncml_message(msg_handle_t handle, const msg_struct_t syncml_msg); /** - - * \par Description: - * Updates a message in the database. - * - * \par Purpose: - * This API is used to update a message in the database. - * - * \par Typical use case: - * Update message feature is used when a previously saved message is to be updated. - * - * \par Method of function operation: - * Sets up the database connection and set the message's new values to message table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - The function is to update message data for the message indentified by the given msgId as long as the given values are valid. - * - msg->msgId MUST NOT be updated because msg->msgId is a unique Id on platform. - * - If applications want to move a message between folders, applications SHOULD call msg_move_to_folder. - * - msg->storageId MUST NOT be updated. - * - The function will return MSG_ERR_INVALID_MESSAGE, if inputting a new msg->storageId. - * - If applications want to move the message between storages, applications SHOULD call msg_move_to_storage. - * - * \param input - handle is Message handle. - * \param input - msg is a pointer to an msg_message_t structure. - * \param input - send_opt is a pointer to an MSG_SENDINGOPT_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * MSG_SYNCML_MESSAGE_S syncMLMsg; - * MSG_SENDINGOPT_S sendingOpt = {0}; - * - * ... - * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * err = msg_update_message(hMsgHandle, pMsg, &sendOpt); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @brief Updates a message in the database. + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @remarks The function is to update message data for the message identified by the given msgId as long as the given values are valid. + * @remarks Message ID MUST NOT be updated because that is a unique ID on platform. + * @remarks If applications want to move a message between folders, applications SHOULD call msg_move_to_folder(). + * @remarks Storage ID MUST NOT be updated. + * @remarks If applications want to move the message between storages, applications SHOULD call msg_move_to_storage(). + * + * @param[in] handle The Message handle + * @param[in] msg A pointer to a message structure + * @param[in] send_opt A pointer to a message sending option structure + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_update_message(msg_handle_t handle, const msg_struct_t msg, const msg_struct_t send_opt); /** - - * \par Description: - * Updates a message's read status in the database. - * - * \par Purpose: - * This API is used to Updates a message's read status in the database. - * - * \par Typical use case: - * Update message's read status for a previously saved message. - * - * \par Method of function operation: - * Sets up the database connection and updates the message's read status to message table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - msg_id is Message ID. - * \parem input - read is boolean for indicating whether a message is read or not. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * MSG_SYNCML_MESSAGE_S syncMLMsg; - * MSG_SENDINGOPT_S sendingOpt = {0}; + * @brief Updates a message's read status in the database. * - * ... + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * err = msg_open_msg_handle(&msgHandle); + * @param[in] handle The message handle + * @param[in] msg_id The message ID + * @param[in] read Set @c true if the message is read, + * otherwise set @c false if the message is not read * - * ... + * @return @c 0 on success, + * otherwise a negative error value * - * err = msg_update_message(hMsgHandle, pMsg, &sendOpt); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_update_read_status(msg_handle_t handle, msg_message_id_t msg_id, bool read); /** - - * \par Description: - * Updates a message's protected status in the database. - * - * \par Purpose: - * This API is used to Updates a message's protected status in the database. - * - * \par Typical use case: - * Update message's protected status for a previously saved message. - * - * \par Method of function operation: - * Sets up the database connection and updates the message's protected status to message table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - msg_id is Message ID. - * \parem input - is_protected is boolean for indicating whether a message is protected or not. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... + * @brief Updates a message's protected status in the database. * - * msg_handle_t msgHandle = NULL; - * MSG_SYNCML_MESSAGE_S syncMLMsg; - * MSG_SENDINGOPT_S sendingOpt = {0}; + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * ... + * @param[in] handle The message handle + * @param[in] msg_id The message ID + * @parem[in] is_protected Set @c true if a message is protected, + * otherwise set @c false if message is not protected * - * err = msg_open_msg_handle(&msgHandle); + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * - * err = msg_update_protected_status(hMsgHandle, 0, true); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_update_protected_status(msg_handle_t handle, msg_message_id_t msg_id, bool is_protected); /** - - * \par Description: - * Deletes a message by Message ID from the database. - * - * \par Purpose: - * This API is used to delete a message by Message ID from the database. - * - * \par Typical use case: - * Deletes a previously saved message from the database. - * - * \par Method of function operation: - * Sets up the database connection and deletes a message by Message ID from the message table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - msg_id is the ID of the Message to be deleted. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None + * @brief Deletes a message by Message ID from the database. * - * \par Sample code: - * \code - * ... + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * msg_handle_t msgHandle = NULL; - * MSG_SYNCML_MESSAGE_S syncMLMsg; - * MSG_SENDINGOPT_S sendingOpt = {0}; + * @param[in] handle The message handle + * @param[in] msg_id The message ID of the message to be deleted * - * ... + * @return @c 0 on success, + * otherwise a negative error value * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * err = msg_delete_message(msgHandle, 0); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_delete_message(msg_handle_t handle, msg_message_id_t msg_id); /** - - * \par Description: - * Deletes all messages in the specified folder from the database. - * - * \par Purpose: - * This API is used to delete all messages in the specified folder from the database. - * - * \par Typical use case: - * Deletes all messages in the specified folder from the database. - * - * \par Method of function operation: - * Sets up the database connection and Deletes all messages in the specified folder from the message table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - folder_id is the ID of the folder to be deleted. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None + * @brief Deletes all messages in the specified folder from the database. * - * \par Known issues/bugs: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Sample code: - * \code - * ... + * @param[in] handle Message handle + * @param[in] msg_id Message ID of the message to be deleted + * @param[in] bOnlyDB Set @c true to not delete messages in SIM, + * otherwise set @c false to delete messages in SIM * - * msg_handle_t msgHandle = NULL; - * MSG_SYNCML_MESSAGE_S syncMLMsg; - * MSG_SENDINGOPT_S sendingOpt = {0}; + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * err = msg_delete_all_msgs_in_folder(msgHandle, MSG_DRAFT_ID); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_delete_all_msgs_in_folder(msg_handle_t handle, msg_folder_id_t folder_id, bool bOnlyDB); /** - - * \par Description: - * Moves a message to the specified folder in the database. - * - * \par Purpose: - * This API is used to move a message to the specified folder the database. - * - * \par Typical use case: - * Deletes all messages in the specified folder from the database. - * - * \par Method of function operation: - * Sets up the database connection and Deletes all messages in the specified folder from the message table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - msg_id is the ID of the message to be moved. - * \param input - dest_folder_id is the ID of the destination folder. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None + * @brief Moves a message to the specified folder in the database. * - * \par Known issues/bugs: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Sample code: - * \code - * ... + * @param[in] handle The message handle + * @param[in] msg_id The message ID of the message to be moved + * @param[in] dest_folder_id The ID of the destination folder * - * msg_handle_t msgHandle = NULL; - * MSG_SYNCML_MESSAGE_S syncMLMsg; - * MSG_SENDINGOPT_S sendingOpt = {0}; + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * err = msg_move_msg_to_folder(hMsgHandle, 0, MSG_OUTBOX_ID); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_move_msg_to_folder(msg_handle_t handle, msg_message_id_t msg_id, msg_folder_id_t dest_folder_id); /** - - * \par Description: - * Moves a message to the other storage. - * - * \par Purpose: - * This API is usd to move a message to the other storage. - * - * \par Typical use case: - * Moves a message to the other storage type. - * - * \par Method of function operation: - * Sets up the database connection and moves a messages to specified storage type. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - msg_id is the ID of the message to be moved. - * \param input - storage_id is the ID of the destination storage. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @brief Moves a message to the other storage. * - * \par Related functions: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Known issues/bugs: - * None + * @param[in] handle The message handle + * @param[in] msg_id The message ID of the message to be moved + * @param[in] storage_id The ID of the destination storage * - * \par Sample code: - * \code - * ... + * @return @c 0 on success, + * otherwise a negative error value * - * msg_handle_t msgHandle = NULL; - * MSG_SYNCML_MESSAGE_S syncMLMsg; - * MSG_SENDINGOPT_S sendingOpt = {0}; - * - * ... - * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * err = msg_move_msg_to_storage( msgHandle, 0, MSG_STORAGE_PHONE); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_move_msg_to_storage(msg_handle_t handle, msg_message_id_t msg_id, msg_storage_id_t storage_id); /** - - * \par Description: - * Gets the number of messages in the specified folder from the database. - * - * \par Purpose: - * This API is used to get the number of messages in the specified folder from the database. - * - * \par Typical use case: - * Gets the number of messages in the specified folder from the database. - * - * \par Method of function operation: - * Sets up the database connection and Gets the number of messages in the specified folder from the message table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - folder_id is the ID of the folder to be counted. - * \param output - count_info is a pointer to an MSG_COUNT_INFO_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. + * @brief Gets the number of messages in the specified folder from the database. * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Related functions: - * None + * @param[in] handle The message handle + * @param[in] msg_id The message ID of the message to be counted + * @param[out] count_info A pointer to an #MSG_COUNT_INFO_S structure * - * \par Known issues/bugs: - * None + * @return @c 0 on success, + * otherwise a negative error value * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * MSG_COUNT_INFO_S countInfo; - * - * ... - * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * err = msg_count_message(msgHandle, MSG_OUTBOX_ID, &countInfo) -* if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_count_message(msg_handle_t handle, msg_folder_id_t folder_id, msg_struct_t count_info); /** - - * \par Description: - * Gets the number of messages of specific message type. - * - * \par Purpose: - * This API is used to get the number of messages of specific type. - * - * \par Typical use case: - * Gets the count of message of specific types such as SMS, MMS. - * - * \par Method of function operation: - * Sets up the database connection and queries the number of messages in the specified folder from the message table based on required message type. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - msg_type is the message type to be counted. - * \param output - msg_count is a pointer to the number of message. + * @brief Gets the number of messages of specific message type. * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @param[in] handle The message handle + * @param[in] msg_type The message type to be counted + * @param[out] msg_count A pointer to the number of message * - * \par Related functions: - * None + * @return @c 0 on success, + * otherwise a negative error value * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * MSG_COUNT_INFO_S countInfo; - * - * ... - * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * err = msg_count_msg_by_type(msgHandle, MSG_TYPE_SMS, &countInfo); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_count_msg_by_type(msg_handle_t handle, msg_message_type_t msg_type, int *msg_count); /** - - * \par Description: - * Gets the number of messages of specific address. - * - * \par Purpose: - * This API is used to get the number of messages from a specific address. - * - * \par Typical use case: - * Get the count of messages from the specified address - * - * \par Method of function operation: - * Sets up the database connection and queries the number of messages based on address from the message table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - If addr_info is NULL, nothing happens. + * @brief Gets the number of messages of specific address. * - * \param input - handle is Message handle. - * \param input - addr_info is a pointer to an MSG_ADDRESS_INFO_LIST_S structure. - * \param input - msg_thread_count_list is a pointer to an MSG_THREAD_COUNT_INFO_S structure. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. + * @remarks If @a addr_info is @c NULL, nothing happens. * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @param[in] handle The message handle + * @param[in] addr_info A pointer to an address list information structure + * @param[in] msg_thread_count_list A pointer to an thread count information structure * - * \par Related functions: - * None + * @return @c 0 on success, + * otherwise a negative error value * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * MSG_COUNT_INFO_S countInfo; - * - * ... - * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * err = msg_count_msg_by_type(msgHandle, MSG_TYPE_SMS, &countInfo); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_count_msg_by_contact(msg_handle_t handle, const msg_struct_t addr_info, msg_struct_t msg_thread_count_list); /** - - * \par Description: - * Gets the detail information of a message from the database. - * - * \par Purpose: - * This API is used to get the number of messages from a specific address. - * - * \par Typical use case: - * Get the count of messages from the specified address - * - * \par Method of function operation: - * Sets up the database connection and queries the number of messages based on address from the message table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - If addr_info is NULL, nothing happens. - * - Applications need to call msg_release_message to free the memory. - * - However, if this function is failed, the memory for the message is NOT allocated in this function. + * @brief Gets the detail information of a message from the database. + * @details This API is used to get the detail information of message by message ID. * -handle is Message handle. - * \param input - handle is Message handle. - * \param input - msg_id is the ID of the Message to be returned. - * \param output - msg is a pointer to an msg_message_t structure. - * \param input - send_opt is a pointer to an MSG_SENDINGOPT_S structure. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. + * @remarks Applications need to call msg_release_struct() to free the memory. + * @remarks However, if this function fails, the memory for the message is NOT allocated in this function. * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @param[in] handle The Message handle + * @param[in] msg_id The ID of the Message to be returned + * @param[out] msg A pointer to a #msg_struct_t message structure + * @param[in] send_opt A pointer to a #msg_struct_t sending option structure * - * \par Related functions: - * - None + * @return @c 0 on success, + * otherwise a negative error value * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * - * ... - * msg_message_t msg = msg_new_message(); - * MSG_SENDINGOPT_S sendOpt = {0, }; - * ... - * err = msg_get_message(msgHandle, 0, msg, &sendOpt); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t msg, msg_struct_t send_opt); /** - - * \par Description: - * Returns the common information list of messages with selected folder id. - * - * \par Purpose: - * This API is used to get the common information list of messages with selected folder id from database. + * @brief Gets the detail information of a message on conversation list. + * @details This API is used to get the conversation informations of message by message ID. * - * \par Typical use case: - * Get the common information from the specified folder from database. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Method of function operation: - * Sets up the database connection and queries the common information based on selected folder id from the message and folder tables. + * @param[in] handle The Message handle + * @param[in] msg_id The ID of the Message to be returned + * @param[out] conv A pointer to a #msg_struct_t of message structure * - * \par Sync (or) Async: - * This is a Synchronous API. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Important notes: - * - The memory for a message will be allocated in this function. - * - Applications need to call msg_release_folder_view_list to free the memory. - * - However, if this function is failed, the memory for the message is NOT allocated in this function. - * - * \param input - handle is Message handle. - * \param input - folder_id is the ID of the folder to be returned. - * \param input - sort_rule indicates a sort type and sort order for querying messages. - * \param output - msg_folder_view_list is a pointer to an MSG_FOLDER_VIEW_LIST_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * - None - * - * \par Known issues/bugs: - * None + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_get_conversation(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t conv); + + +/** + * @brief Gets the v-object data of message. + * @details This API is used to get the v-object data of message by message ID. * - * \par Sample code: - * \code - * ... + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * msg_handle_t msgHandle = NULL; + * @param[in] handle The Message handle + * @param[in] msg_id The ID of the Message to be returned + * @param[out] encoded_data A pointer to a encoded v-object data of message * - * ... - * MSG_FOLDER_VIEW_LIST_S folderViewList; - * ... - * err = msg_get_folder_view_list(hMsgHandle, 0, NULL, &folderViewList); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_get_folder_view_list(msg_handle_t handle, msg_folder_id_t folder_id, const msg_struct_t sort_rule, msg_struct_list_s *msg_folder_view_list); +int msg_get_vobject_data(msg_handle_t handle, msg_message_id_t msg_id, void** encoded_data); -/** - * \par Description: - * Returns the information of all peers to whom messages have been sent or recieved. - * - * \par Purpose: - * This API is used to get the information of all peers to whom messages have been sent or recieved. - * - * \par Typical use case: - * Get the common information from the specified folder from database. - * - * \par Method of function operation: - * Frees the memory occupied by MSG_FOLDER_VIEW_LIST_S object and its members. +/** + * @brief Gets the information of all peers to whom messages have been sent or received. * - * \par Sync (or) Async: - * This is a Synchronous API. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Important notes: - * - The memory for a list will be allocated in this function. - * - Applications need to call msg_release_thread_view_list to free the memory. - * - However, if this function is failed, the memory for a list is NOT allocated in this function. + * @remarks The memory for a list will be allocated in this function. + * @remarks Applications need to call msg_release_thread_view_list() to free the memory. + * @remarks However, if this function fails, the memory for a list is NOT allocated in this function. * - * \param input - handle is Message handle. - * \param input - sort_rule indicates a sort type and sort order for querying messages. - * \param output - msg_thread_view_list is a pointer to an msg_struct_list_s structure. + * @param[in] handle The Message handle + * @param[in] sourt_rule This indicates a sort type and sort order for querying messages + * @param[out] msg_thread_view_list A pointer to an #msg_struct_list_s structure * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_get_thread_view_list(msg_handle_t handle, const msg_struct_t sort_rule, msg_struct_list_s *msg_thread_view_list); + + +/** + * @briefs Gets the common information list of messages with the selected thread ID. * - * \par Related functions: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Known issues/bugs: - * None + * @remarks The memory for a list will be allocated in this function. + * @remarks Applications need to call msg_release_conversation_view_list() to free the memory. + * @remarks However, if this function is failed, the memory for a list is NOT allocated in this function. * - * \par Sample code: - * \code - * ... + * @param[in] hMsgHandle The Message handle + * @param[in] thread_id The ID of the thread to be returned + * @param[out] msg_conv_view_list A pointer to a structure of conversational message list * - * msg_handle_t msgHandle = NULL; + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * msg_struct_list_s threadViewList; - * ... - * err = msg_get_thread_view_list(hMsgHandle, NULL, &threadViewList); - * ... - * msg_release_thread_view_list(&threadViewList); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_get_thread_view_list(msg_handle_t handle, const msg_struct_t sort_rule, msg_struct_list_s *msg_thread_view_list); - - -/** - * \par Description: - * Returns the common information list of messages with selected thread_id. - * - * \par Purpose: - * This API is used to get the common information list of messages with selected thread_id. - * - * \par Typical use case: - * Gets the common information list of messages with the selected thread id from the database. - * - * \par Method of function operation: - * Connects to the database and queries the common infomation of list messages with the provided thread id. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - The memory for a list will be allocated in this function. - * - Applications need to call msg_release_conversation_view_list to free the memory. - * - However, if this function is failed, the memory for a list is NOT allocated in this function. - * - * \param input - hMsgHandle is Message handle. - * \param input - thread_id is the ID of the thread to be returned. - * \param output - msg_conv_view_list is a pointer to an MSG_CONV_VIEW_LIST_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * - None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * msg_error_t err = MSG_SUCCESS; - * ... - * MSG_CONV_VIEW_LIST_S convViewList; - * ... - * err = msg_get_conversation_view_list(hMsgHandle, ThreadId, &convViewList); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * msg_release_conversation_view_list(&convViewList); - * ... - * \endcode - */ -/*================================================================================================*/ int msg_get_conversation_view_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_list_s *msg_conv_view_list); /** - - * \par Description: - * Deletes all the Messages Sent/Received from the selected list. - * - * \par Purpose: - * This API is used to delete all the Messages Sent/Received from the selected list. - * - * \par Typical use case: - * Deletes all messages sent/received from the selected list. - * - * \par Method of function operation: - * Sets up the database connection and deletes all messages sent/received from a selected list. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - If addr_info is NULL, nothing happens. - * - * \param input - handle is Message handle. - * \param input - thread_id is the ID of the thread to be deleted. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None + * @brief Deletes all the Messages Sent/Received from the selected list. * - * \par Known issues/bugs: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Sample code: - * \code - * ... + * @param[in] handle The Message handle + * @param[in] thread_id The ID of the thread to be deleted + * @param[in] include_protected_msg Set @c true to delete protected messages, + * otherwise @c false to not delete protected messages * - * msg_handle_t msgHandle = NULL; - * MSG_SYNCML_MESSAGE_S syncMLMsg; - * MSG_SENDINGOPT_S sendingOpt = {0}; + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * - * err = msg_delete_thread_message_list(hMsgHandle, 0); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_delete_thread_message_list(msg_handle_t handle, msg_thread_id_t thread_id); +int msg_delete_thread_message_list(msg_handle_t handle, msg_thread_id_t thread_id, bool include_protected_msg); -/** - * \par Description: - * Adds a new folder. - * - * \par Purpose: - * This API is used to add a new folder. - * - * \par Typical use case: - * Adds a new folder with the specified folder info - * - * \par Method of function operation: - * Sets up the database connection and add a new folder to the folder table. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None. - * - * \param - handle is Message handle. - * \param - folder_info is a pointer to an MSG_FOLDER_INFO_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None +/** + * @brief Adds a new folder. * - * \par Sample code: - * \code - * ... + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * msg_handle_t msgHandle = NULL; - * Make Folder - * MSG_FOLDER_INFO_S folderInfo; - * ... - * err = msg_open_msg_handle(&msgHandle); + * @param[in] handle The Message handle + * @param[in] folder_info A pointer to an #MSG_FOLDER_INFO_S structure * - * folderInfo.folderId = 1; - * folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF; - * ... + * @return @c 0 on success, + * otherwise a negative error value * - * err = msg_add_folder(hMsgHandle, &folderInfo); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_add_folder(msg_handle_t handle, const msg_struct_t folder_info); /** - - * \par Description: - * Updates the folder info. - * - * \par Purpose: - * This API is used to add a new folder. - * - * \par Typical use case: - * Adds a new folder with the specified folder info - * - * \par Method of function operation: - * Sets up the database connection and add a new folder to the folder table. - * - * \par Sync (or) Async: - * This is a Synchronous API. + * @brief Updates the folder info. * - * \par Important notes: - * - None. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \param - handle is Message handle. - * \param - folder_info is a pointer to an MSG_FOLDER_INFO_S structure. + * @param[in] handle The Message handle + * @param[in] folder_info A pointer to an #MSG_FOLDER_INFO_S structure * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * Make Folder - * MSG_FOLDER_INFO_S folderInfo; - * ... - * err = msg_open_msg_handle(&msgHandle); - * - * folderInfo.folderId = 2; - * folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF; - * ... - * err = msg_update_folder(msgHandle, &folderInfo); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_update_folder(msg_handle_t handle, const msg_struct_t folder_info); /** - - * \par Description: - * Deletes an exisiting folder. + * @brief Deletes an existing folder. * - * \par Purpose: - * This API is used to delete an existing folder. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Typical use case: - * Deletes an existing folder. + * @param[in] handle The Message handle + * @param[in] folder_id The ID of the folder to be deleted * - * \par Method of function operation: - * Sets up the database connection and deletes an existing folder to the folder table. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None. - * - * \param input - handle is Message handle. - * \param input - folder_id is the ID of the folder to be deleted. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * err = msg_delete_folder(hMsgHandle, MSG_INBOX_ID); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_delete_folder(msg_handle_t handle, msg_folder_id_t folder_id); /** - - * \par Description: - * Returns the information list of folders. - * - * \par Purpose: - * This API is used to get the information list of folders. - * - * \par Typical use case: - * Gets the folder list information. - * - * \par Method of function operation: - * Sets up the database connection and queries for the folder list information. + * @brief Gets the information list of folders. * - * \par Sync (or) Async: - * This is a Synchronous API. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Important notes: - * - None. + * @param[in] handle The Message handle + * @param[out] folder_list A pointer to a #msg_struct_list_s structure * - * \param input - handle is Message handle. - * \param output - folder_list is a pointer to an msg_struct_list_s structure. + * @return @c 0 on success, + * otherwise a negative error value * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * msg_struct_list_s folderList; - - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * err = msg_get_folder_list(msgHandle, &folderList); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * msg_release_folder_list(&folderList); - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_get_folder_list(msg_handle_t handle, msg_struct_list_s *folder_list); /** - - * \par Description: - * Creates the specified number of messages in database. - * - * \par Purpose: - * This API is used to generate specified number of messages in the database - * - * \par Typical use case: - * Generate large number of messages in the database. - * - * \par Method of function operation: - * Creates the specified number of messages in database for specified message type in the specified folder - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - msg_type is one of enum _MSG_MESSAGE_TYPE_E. - * \param input - folder_id is the folder for the test messages. - * \param input - num_msg is the number of messages. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_MSGHANDLE Parameter is invalid. - * - MSG_ERR_INVALID_FOLDER_ID Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * msg_struct_list_s folderList; - - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * err = msg_generate_message(msgHandle, MSG_TYPE_SMS, MSG_INBOX_ID, 100); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @brief Creates the specified number of messages in database. + * @details This API is used to generate specified number of messages in the database + * + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write + * + * @param[in] handle The Message handle + * @param[in] msg_type The message type \n + * One of enum _MSG_MESSAGE_TYPE_E. + * @param[in] folder_id The folder for the test messages + * @param[in] num_msg The number of messages + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_MSGHANDLE Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_type, msg_folder_id_t folder_id, unsigned int num_msg); -int msg_generate_sms(msg_handle_t handle, msg_folder_id_t folder_id, unsigned int num_msg) DEPRECATED; /** - - * \par Description: - * Returns the Message Data to be used by the Quick Panel. - * - * \par Purpose: - * This API is used to get the Message Datato be used by the Quick Panel. - * - * \par Typical use case: - * Quick panel needs the message information to show new message notification. - * - * \par Method of function operation: - * Connects to database and queries for information needed by the quick panel. - * - * \par Sync (or) Async: - * This is a Synchronous API. + * @brief Returns the Message Data to be used by the Quick Panel. * - * \par Important notes: - * - None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \param input - handle is Message handle. - * \param input - type is the type of message that Quick Panel need. - * \param output - msg is a pointer to an msg_message_t structure. + * @param[in] handle The Message handle + * @param[in] type The type of message that Quick Panel needs + * @param[out] msg A pointer to a #msg_struct_t structure * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_MSGHANDLE Parameter is invalid. - * - MSG_ERR_INVALID_FOLDER_ID Storage is error. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * msg_message_t msgInfo; - - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * err = msg_get_quick_panel_data(msgHandle, MSG_QUICKPANEL_SMS, msgInfo); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_DB_STEP There is no Quick Panel message + * @retval MSG_ERR_INVALID_PARAMETER(-9) Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_get_quick_panel_data(msg_handle_t handle, msg_quickpanel_type_t type, msg_struct_t msg); /** - - * \par Description: - * Resets the Messaging database. - * - * \par Purpose: - * This API is used to reset the messaging database. - * - * \par Typical use case: - * Completely delete the messaging database. - * - * \par Method of function operation: - * Connects to database and deletes all the messaging tables. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. + * @brief Resets the Messaging database. * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_PARAMETER Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR Storage is error. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @param[in] handle The Message handle * - * \par Related functions: - * None + * @return @c 0 on success, + * otherwise a negative error value * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * msg_error_t err = MSG_SUCCESS; - * err = msg_open_msg_handle(&msgHandle); - * - * ... - * err = msg_reset_database(msgHandle); - * if (err != MSG_SUCCESS) - *{ - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_reset_database(msg_handle_t handle); /** - - * \par Description: - * Returns the total size used for message contents. - * - * \par Purpose: - * This API is used to get the total size used for message contents. - * - * \par Typical use case: - * To get the total space used by message contents. - * - * \par Method of function operation: - * Uses linux system calls to query the space used by message contents. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param output - memsize is a pointer to the size. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_PARAMETER Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None + * @brief Gets the total size used for message contents. * - * \par Known issues/bugs: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Sample code: - * \code - * ... + * @param[in] handle The Message handle + * @param[out] memsize A pointer to the size * - * msg_handle_t msgHandle = NULL; - * int memsize = 0; - * err = msg_open_msg_handle(&msgHandle); + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * err = msg_get_mem_size(msgHandle, &memsize); - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize); /** - - * \par Description: - * Backup messages to storage. - * - * \par Purpose: - * This API is used to backup messages to storage. - * - * \par Typical use case: - * Backup messages to storage. - * - * \par Method of function operation: - * Reads all the messages from Messaging database and writes to storage in V-Message format - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * None - * - * \param input - msg_handle_t handle is Message handle. + * @brief Backs up messages to storage. * - * \return Return Type int (msg_error_t) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_PARAMETER Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR Storage is error. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @param[in] handle The Message handle + * @param[in] type The backup type + * @param[in] backup_filepath The path to backup message * - * \par Related functions: - * None + * @return @c 0 on success, + * otherwise a negative error value * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * msg_handle_t msgHandle = NULL; - * msg_error_t err; - * - * ... - * err = msg_backup_message(&msgHandle); - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -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); -/** - * \par Description: - * Restore messages from backed up messages. - * - * \par Purpose: - * This API is used to restore messages from backed up messages. - * - * \par Typical use case: - * Restore messages from previously backed up messages. - * - * \par Method of function operation: - * Reads the previously backup up messages and restores the database. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * None - * - * \param input - msg_handle_t handle is Message handle. - * - * \return Return Type int (msg_error_t) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_PARAMETER Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. +/** + * @brief Restores messages from backed up messages. * - * \par Related functions: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Known issues/bugs: - * None + * @param[in] handle The Message handle + * @param[in] backup_filepath The path to backup message * - * \par Sample code: - * \code - * ... + * @return @c 0 on success, + * otherwise a negative error value * - * msg_handle_t msgHandle = NULL; - * msg_error_t err; - * ... - * err = msg_restore_message(&msgHandle); - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_restore_message(msg_handle_t handle); +int msg_restore_message(msg_handle_t handle, const char *backup_filepath); -/** - * \par Description: - * Search messages or addresses which including a string that applcation want to find. +/** + * @brief Searches messages or addresses for the specified string. + * @details This API is used to search messages or addresses from storage. * - * \par Purpose: - * This API is used to search messages or addresses from storage. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Typical use case: - * Search messages or addresses from storage. + * @param[in] handle The Message handle + * @param[in] search_string The string to search + * @param[out] msg_thread_view_list A pointer to an #msg_struct_list_s structure * - * \par Method of function operation: - * search messages or addresses from storage. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Sync (or) Async: - * This is a Synchronous API. + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_search_message_for_thread_view(msg_handle_t handle, const char *search_string, msg_struct_list_s *msg_thread_view_list); + + +/** + * @brief Gets reject message list by phone number. + * @details This API is used to get reject message list from storage. * - * \par Important notes: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \param input - msg_handle_t handle is Message handle. - * \param input - search_string is the string to search. - * \param output - msg_thread_view_list is a pointer to an msg_struct_list_s structure. + * @param[in] handle The Message handle + * @param[in] phone_num The string of phone number to find + * @param[out] msg_reject_msg_list A pointer to a #msg_struct_list_s structure * - * \return Return Type int (msg_error_t) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_PARAMETER Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR Storage is error. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_get_reject_msg_list(msg_handle_t handle, const char* phone_num, msg_struct_list_s *msg_reject_msg_list); + + +/** + * @brief Registers a callback function about the change of storage status to Message handle. + * @details This API is used to register a callback function about the change of storage status "msg_storage_change_cb" to Message handle. * - * \par Related functions: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Known issues/bugs: - * None + * @remarks This function MUST be called after Message handle is opened. * - * \par Sample code: - * \code - * ... + * @param[in] handle The Message handle + * @param[in] cb The function to be called + * @param[in] user_param A pointer to user data * - * msg_handle_t msgHandle = NULL; - * msg_error_t err = MSG_SUCCESS; - * ... - * char* search_string = "hello"; - * msg_struct_list_s threadViewList; - * ... - * err = msg_search_message_for_thread_view(&msgHandle, search_string, &threadViewList); + * @return @c 0 on success, + * otherwise a negative error value * - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_MSGHANDLE_NOT_CONNECTED Message handle is not connected + * @retval MSG_ERR_MEMORY_ERROR Memory is error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_search_message_for_thread_view(msg_handle_t handle, const char *search_string, msg_struct_list_s *msg_thread_view_list); +int msg_reg_storage_change_callback(msg_handle_t handle, msg_storage_change_cb cb, void *user_param); -/** - * \par Description: - * Search messages or addresses which including a string that applcation want to find. - * - * \par Purpose: - * This API is used to search messages or addresses from storage. - * - * \par Typical use case: - * Search messages or addresses from storage. - * - * \par Method of function operation: - * search messages or addresses from storage. - * - * \par Sync (or) Async: - * This is a Synchronous API. +/** + * @brief Gets the report status information of message. * - * \par Important notes: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \param input - msg_handle_t handle is Message handle. - * \param input - search_string is the string to search. - * \param input - offset is the offset of the search result. - * \param input - limit is the limit of the search result. - * \param output - msg_list is a pointer to an msg_struct_list_s structure. + * @param[in] handle The Message handle + * @param[in] msg_id The ID of the message + * @param[out] report_status A pointer to a #msg_struct_list_s structure * - * \return Return Type int (msg_error_t) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_PARAMETER Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR Storage is error. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_get_report_status(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_list_s *report_list); + + +/** + * @brief Gets the address list for specific thread ID. * - * \par Related functions: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Known issues/bugs: - * None + * @param[in] handle The Message handle + * @param[in] msg_id The ID of the message + * @param[out] msg_address_list A pointer to a #msg_struct_list_s structure * - * \par Sample code: - * \code - * ... + * @return @c 0 on success, + * otherwise a negative error value * - * msg_handle_t msgHandle = NULL; - * msg_error_t err = MSG_SUCCESS; - * ... - * msg_struct_list_s msg_list; - * int offset = 0; - * int limit = 10; + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_get_address_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_list_s *msg_address_list); + + +/** + * @brief Gets the thread ID by address. * - * MSG_SEARCH_CONDITION_S searchCon; + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * searchCon.msgType = MSG_TYPE_SMS; - * searchCon.folderId = MSG_INBOX_ID; - * searchCon.pSearchVal = "keyString"; - * searchCon.pAddressVal = "01000000000"; + * @param[in] handle The Message handle + * @param[in] msg_address_list A pointer to a #msg_struct_list_s structure + * @param[out] thread_id The thread ID of the message * - * ... - * err = msg_search_message(hMsgHandle, &searchCon, offset, limit, &msgList); + * @return @c 0 on success, + * otherwise a negative error value * - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_search_message(msg_handle_t handle, const msg_struct_t msg_search_conditions, int offset, int limit, msg_struct_list_s *msg_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); - * \par Description: - * Get reject message list that application wants to find by phone number. - * - * \par Purpose: - * This API is used to get reject message list from storage. - * - * \par Typical use case: - * Get reject message list from storage. +/** + * @brief Gets the thread ID by address. * - * \par Method of function operation: - * Get reject message list from storage. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Sync (or) Async: - * This is a Synchronous API. + * @param[in] handle The Message handle + * @param[in] msg_address_list A pointer to a #msg_list_handle structure + * @param[out] thread_id The thread ID of the message * - * \par Important notes: - * None + * @return @c 0 on success, + * otherwise a negative error value * - * \param input - msg_handle_t handle is Message handle. - * \param input - phone_num is the string of phone number to find. - * \param output - msg_reject_msg_list is a pointer to an msg_struct_list_s structure. + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ - * \return Return Type int (msg_error_t) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_PARAMETER Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR Storage is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None +int msg_get_thread_id_by_address2(msg_handle_t handle, msg_list_handle_t msg_address_list, msg_thread_id_t *thread_id); + + + +/** + * @brief Gets the thread information. * - * \par Known issues/bugs: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Sample code: - * \code - * ... + * @param[in] handle The Message handle + * @param[in] thread_id The ID of the thread + * @param[out] msg_thread A pointer to a #msg_struct_t structure * - * msg_handle_t msgHandle = NULL; - * msg_error_t err = MSG_SUCCESS; - * ... - * char* phone_num = "01030016057"; - * msg_struct_list_s rejectMsgList; - * ... - * err = msg_get_reject_msg_list(hMsgHandle, phone_num, &rejectMsgList); + * @return @c 0 on success, + * otherwise a negative error value * - * if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_get_reject_msg_list(msg_handle_t handle, const char* phone_num, msg_struct_list_s *msg_reject_msg_list); +int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_t msg_thread); -/** - * \par Description: - * Registers a callback function about the change of storage status to Message handle. - * - * \par Purpose: - * This API is used to register a callback function about the change of storage status "msg_storage_change_cb" to Message handle. +/** + * @brief Gets the information list of messages. * - * \par Typical use case: - * Register a callback function about the change of storage status. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Method of function operation: - * Adds the msg_storage_change_cb API to a callback function list. + * @param[in] handle The Message handle + * @param[in] msg_list_conditions A pointer to a #msg_struct_t structure for getting conditions + * @param[out] msg_list A pointer to a #msg_struct_list_s structure * - * \par Sync (or) Async: - * This is a Synchronous API. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Important notes: - * This function MUST be called after Message handle is opened. + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_get_message_list2(msg_handle_t handle, const msg_struct_t msg_list_conditions, msg_struct_list_s *msg_list); + + +/** + * @brief A function to get media list of a chat room. * - * \param input - handle is Message handle. - * \param input - cb is a function to be called. - * \param input - user_param is a pointer to user data. + * @since_tizen 2.3.1 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_MSGHANDLE_NOT_CONNECTED Message handle is not connected. - * - MSG_ERR_MEMORY_ERROR Memory is error. + * @remarks This function MUST be called after Message handle is opened. * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @param[in] handle The Message handle + * @param[in] thread_id The thread id of conversation to get media list + * @param[out] msg_list The media file list in a conversation * - * \par Related functions: - * None + * @return @c 0 on success, + * otherwise a negative error value * - * \par Known issues/bugs: - * None + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + */ + +int msg_get_media_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_list_handle_t *msg_list); + + +/** + * @brief Adds a new push event. * - * \par Sample code: - * \code - * ... + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * int err = MSG_SUCCESS; + * @param[in] handle The Message handle + * @param[in] push_event A pointer to a #msg_struct_t structure for push event * - * err = msg_reg_storage_change_callback(msgHandle, &storageCB, NULL); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * return; - * } + * @return @c 0 on success, + * otherwise a negative error value * - * void storageCB(msg_handle_t handle, msg_thread_id_t threadId, msg_message_id_t msgId, void *user_param) - * { - * ... - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_reg_storage_change_callback(msg_handle_t handle, msg_storage_change_cb cb, void *user_param); +int msg_add_push_event(msg_handle_t handle, const msg_struct_t push_event); -/** - * \par Description: - * Gets the report status information of message. - * - * \par Purpose: - * This API is used to get the report status information of specified message. +/** + * @brief Deletes a push event. * - * \par Typical use case: - * Gets the report status information of specified message from the database. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Method of function operation: - * Sets up the database connection and Gets the report status information of specified message from the report table. + * @param[in] handle The Message handle + * @param[in] push_event A pointer to a #msg_struct_t structure for push event * - * \par Sync (or) Async: - * This is a Synchronous API. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Important notes: - * - None + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_delete_push_event(msg_handle_t handle, const msg_struct_t push_event); + + +/** + * @brief Updates a push event. * - * \param input - handle is Message handle. - * \param input - msg_id is the ID of the message. - * \param output - report_status is a pointer to a MSG_REPORT_STATUS_INFO_S structure. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS - Success in operation. - * - MSG_ERR_INVALID_PARAMETER - Parameter is invalid. - * - MSG_ERR_STORAGE_ERROR - Storage is error. + * @param[in] handle The Message handle + * @param[in] src_event A pointer to a #msg_struct_t structure for source push event + * @param[in] dst_event A pointer to a #msg_struct_t structure for destination push event * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Related functions: - * None + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_update_push_event(msg_handle_t handle, const msg_struct_t src_event, const msg_struct_t dst_event); + + +/** + * @brief Deletes messages by Message ID list from the database. * - * \par Known issues/bugs: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Sample code: - * \code - * ... + * @param[in] handle sThe Message handle + * @param[in] msg_id_list The message ID list to be deleted * - * msg_handle_t msgHandle = NULL; - * MSG_REPORT_STATUS_INFO_S reportStatus; + * @return @c 0 on success, + * otherwise a negative error value * - * ... + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_delete_msgs_by_list(msg_handle_t handle, msg_id_list_s *msg_id_list); + + +/** + * @brief Marks a conversation given by thread ID as read. * - * err = msg_open_msg_handle(&msgHandle); + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * ... + * @param[in] handle The Message handle + * @param[in] thread_id The thread ID to be updated * - * err = msg_get_report_status(msgHandle, msgID, &reportStatus) -* if( err != MSG_SUCCESS ) - * { - * printf("err [%d]", err); - * return err; - * } + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid + * @retval MSG_ERR_STORAGE_ERROR Storage error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_get_report_status(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t report_status); - - - - -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); +int msg_set_conversation_to_read(msg_handle_t handle, msg_thread_id_t thread_id); /** * @} */ diff --git a/include/mapi/msg_storage_types.h b/include/mapi/msg_storage_types.h index 7f0c9ba..792d6ef 100755 --- a/include/mapi/msg_storage_types.h +++ b/include/mapi/msg_storage_types.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_STORAGE_TYPES_H_ @@ -28,12 +28,19 @@ ==================================================================================================*/ /** - * @brief Represents message id list. + * @internal + * @addtogroup MSG_SERVICE_FRAMEWORK_STORAGE_MODULE + * @{ + */ + + +/** + * @brief The structure type that represents message ID list. */ typedef struct { - int nCount; /**< The count of message id informatioin */ - msg_message_id_t *msgIdList; /**< The pointer to message id informatioin */ + int nCount; /**< The count of message ID informatioin */ + msg_message_id_t *msgIdList; /**< The pointer to message ID informatioin */ }msg_id_list_s; @@ -42,46 +49,50 @@ typedef struct ==================================================================================================*/ /** - * @brief Represents a folder type. \n - * The values for this type SHOULD be in _MSG_FOLDER_TYPE_E. + * @brief The structure type that represents a folder type. \n + * The values for this type SHOULD be in @ref _MSG_FOLDER_TYPE_E. */ typedef unsigned char msg_folder_type_t; /** - * @brief Represents a sort type. \n - * The values for this type SHOULD be in \ref _MSG_SORT_TYPE_E. + * @brief The structure type that represents a sort type. \n + * The values for this type SHOULD be in @ref _MSG_SORT_TYPE_E. */ typedef unsigned char msg_sort_type_t; /** - * @brief Represents a Saved SIM message ID. + * @brief The structure type that represents a saved SIM message ID. */ typedef signed short msg_sim_id_t; +/** + * @brief The structure type that represents a Saved SIM slot ID. + */ +typedef int msg_sim_slot_id_t; + /** - * @brief Represents a message type for quick panel. \n - * The values for this type SHOULD be in \ref _MSG_QUICKPANEL_TYPE_E. + * @brief The structure type that represents a message type for quick panel. \n + * The values for this type SHOULD be in @ref _MSG_QUICKPANEL_TYPE_E. */ typedef unsigned char msg_quickpanel_type_t; /** - * @brief Represents a storage change CB type. \n - * The values for this type SHOULD be in \ref _MSG_STORAGE_CHANGE_TYPE_E. + * @brief The structure type that represents a storage change CB type. \n + * The values for this type SHOULD be in @ref _MSG_STORAGE_CHANGE_TYPE_E. */ typedef unsigned char msg_storage_change_type_t; -/** @brief Prototype of the function that will be called when the database of message framework is changed. - * Applications SHOULD implement this callback function and register it into Message handle. - * For how to register this callback function, please refer to msg_reg_storage_change_callback. - * The callback function runs in the application process, not in the framework process. - * @param[in] handle is Message handle. - * @param[in] user_param is a pointer to user data. - * @return void +/** @brief Called when the database of message framework is changed. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_storage_change_callback(). + * The callback function runs in the application process, not in the framework process. + * @param[in] handle The Message handle. + * @param[in] user_param A pointer to user data */ typedef void (*msg_storage_change_cb)(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList, void *user_param); @@ -91,121 +102,129 @@ typedef void (*msg_storage_change_cb)(msg_handle_t handle, msg_storage_change_ty ==================================================================================================*/ /** - * @brief Represents the values of a storage type. \n - * This enum is used as the value of msg_storage_id_t. + * @brief Enumeration for the values of a storage type. \n + * This enum is used as the value of msg_storage_id_t. */ enum _MSG_STORAGE_ID_E { - MSG_STORAGE_UNKNOWN = 0, /**< Storage Id is unknown. */ - MSG_STORAGE_PHONE, /**< Storage Id is Phone. */ - MSG_STORAGE_SIM, /**< Storage Id is SIM card. */ + MSG_STORAGE_UNKNOWN = 0, /**< Storage ID is unknown. */ + MSG_STORAGE_PHONE, /**< Storage ID is Phone. */ + MSG_STORAGE_SIM, /**< Storage ID is SIM card in slot 1. */ + MSG_STORAGE_SIM2, /**< Storage ID is SIM card in slot 2. */ }; /** - * @brief Represents the values of a storage type. \n - * This enum is used as the value of msg_folder_id_t. + * @brief Enumeration for the values of a storage type. \n + * This enum is used as the value of msg_folder_id_t. */ enum _MSG_FOLDER_ID_E { - MSG_IOSBOX_ID = -1, /**< Indicates INBOX, OUTBOX and SENTBOX group folder id. (Only for search option.) */ - MSG_ALLBOX_ID = 0, /**< Indicates INBOX, OUTBOX, SENTBOX and DRAFTBOX group folder id. (Only for search option.) */ - MSG_INBOX_ID = 1, - MSG_OUTBOX_ID = 2, - MSG_SENTBOX_ID = 3, - MSG_DRAFT_ID = 4, - MSG_CBMSGBOX_ID = 5, - MSG_SPAMBOX_ID = 6, - MSG_SMS_TEMPLATE_ID = 7, - MSG_MMS_TEMPLATE_ID = 8, - - // new folder should be placed here - - MSG_MAX_FOLDER_ID + MSG_IOSBOX_ID = -1, /**< Indicates INBOX, OUTBOX and SENTBOX group folder ID. (Only for search option.) */ + MSG_ALLBOX_ID = 0, /**< Indicates INBOX, OUTBOX, SENTBOX and DRAFTBOX group folder ID. (Only for search option.) */ + MSG_INBOX_ID = 1, /**< Indicates INBOX folder ID */ + MSG_OUTBOX_ID = 2, /**< Indicates OUTBOX folder ID */ + MSG_SENTBOX_ID = 3, /**< Indicates SENTBOX folder ID */ + MSG_DRAFT_ID = 4, /**< Indicates DRAFT folder ID */ + MSG_CBMSGBOX_ID = 5, /**< Indicates CALLBACK message folder ID */ + MSG_SPAMBOX_ID = 6, /**< Indicates SPAM message folder ID */ + MSG_MAX_FOLDER_ID /**< Indicates MAX folder ID. Folder ID to be accessed should be smaller than this */ }; /** - * @brief Represents the values of a folder type. \n - * This enum is used as the value of msg_folder_type_t. + * @brief Enumeration for the values of a folder type. \n + * This enum is used as the value of msg_folder_type_t. */ enum _MSG_FOLDER_TYPE_E { MSG_FOLDER_TYPE_INBOX = 1, /**< Inbox folder */ - MSG_FOLDER_TYPE_OUTBOX, /**< Outbox folder */ - MSG_FOLDER_TYPE_DRAFT, /**< Draft folder */ + MSG_FOLDER_TYPE_OUTBOX, /**< Outbox folder */ + MSG_FOLDER_TYPE_DRAFT, /**< Draft folder */ MSG_FOLDER_TYPE_SPAMBOX, /**< Spambox folder */ - MSG_FOLDER_TYPE_TEMPLATE, /**< Template folder */ MSG_FOLDER_TYPE_USER_DEF /**< Folder which is created by a user */ }; /** - * @brief Represents the values of a sort type. \n - * This enum is used as the value of msg_sort_type_t. + * @brief Enumeration for the values of a sort type. \n + * This enum is used as the value of msg_sort_type_t. */ enum _MSG_SORT_TYPE_E { MSG_SORT_BY_UNKNOWN = 0, /**< Unknown sort type */ - MSG_SORT_BY_DISPLAY_FROM, /**< Sort by display from */ - MSG_SORT_BY_DISPLAY_TO, /**< Sort by display to */ + MSG_SORT_BY_DISPLAY_FROM, /**< Sort by display from */ + MSG_SORT_BY_DISPLAY_TO, /**< Sort by display to */ MSG_SORT_BY_DISPLAY_TIME, /**< Sort by display time */ MSG_SORT_BY_MSG_TYPE, /**< Sort by msg type */ MSG_SORT_BY_READ_STATUS, /**< Sort by read status */ - MSG_SORT_BY_STORAGE_TYPE, /**< Sort by storage type */ + MSG_SORT_BY_STORAGE_TYPE, /**< Sort by storage type */ MSG_SORT_BY_THREAD_NAME, /**< Sort by name for thread view*/ MSG_SORT_BY_THREAD_DATE, /**< Sort by date for thread view*/ - MSG_SORT_BY_THREAD_COUNT, /**< Sort by count for thread view*/ + MSG_SORT_BY_THREAD_COUNT, /**< Sort by count for thread view*/ }; /** - * @brief Represents the values of a message type for quick panel. \n - * This enum is used as the value of msg_quickpanel_type_t. + * @brief Enumeration for the values of a message type for quick panel. \n + * This enum is used as the value of msg_quickpanel_type_t. */ enum _MSG_QUICKPANEL_TYPE_E { - MSG_QUICKPANEL_SMS = 0, - MSG_QUICKPANEL_MMS, - MSG_QUICKPANEL_DELIVER_REP, - MSG_QUICKPANEL_READ_REP, - MSG_QUICKPANEL_VOICEMAIL, - MSG_QUICKPANEL_MMS_NOTI, + MSG_QUICKPANEL_SMS = 0, /**< Quickpanel SMS */ + MSG_QUICKPANEL_MMS, /**< Quickpanel MMS */ + MSG_QUICKPANEL_DELIVER_REP, /**< Quickpanel delivery report */ + MSG_QUICKPANEL_READ_REP, /**< Quickpanel message read report */ + MSG_QUICKPANEL_VOICEMAIL, /**< Quickpanel voicemail */ + MSG_QUICKPANEL_MMS_NOTI, /**< Quickpanel MMS notification */ }; + /** - * @} + * @brief Enumeration for the values of a count limit for each mailbox. */ enum _MSG_COUNT_LIMIT_MAILBOX_TYPE_E { - MSG_COUNT_LIMIT_INBOX_TYPE, - MSG_COUNT_LIMIT_OUTBOX_TYPE, - MSG_COUNT_LIMIT_SENTBOX_TYPE, - MSG_COUNT_LIMIT_DRAFTBOX_TYPE, - MSG_COUNT_LIMIT_CBMSGBOX_TYPE, - MSG_COUNT_LIMIT_MAILBOX_TYPE_MAX, + MSG_COUNT_LIMIT_INBOX_TYPE, /**< Message count limit of inbox folder*/ + MSG_COUNT_LIMIT_OUTBOX_TYPE, /**< Message count limit of outbox folder*/ + MSG_COUNT_LIMIT_SENTBOX_TYPE, /**< Message count limit of sentbox folder*/ + MSG_COUNT_LIMIT_DRAFTBOX_TYPE, /**< Message count limit of draftbox folder*/ + MSG_COUNT_LIMIT_CBMSGBOX_TYPE, /**< Message count limit of call-back-message-box folder */ + MSG_COUNT_LIMIT_MAILBOX_TYPE_MAX, /**< Indicates the maximum number of types of folder message count limits */ }; + +/** + * @brief Enumeration for the values of a count limit for each message type. + */ enum _MSG_COUNT_LIMIT_MSG_TYPE_E { - MSG_COUNT_LIMIT_SMS_TYPE, - MSG_COUNT_LIMIT_MMS_TYPE, - MSG_COUNT_LIMIT_CB_TYPE, - MSG_COUNT_LIMIT_WAPPUSH_TYPE, - MSG_COUNT_LIMIT_PROVISION_TYPE, - MSG_COUNT_LIMIT_MSG_TYPE_MAX, + MSG_COUNT_LIMIT_SMS_TYPE, /**< Message count limit for SMS */ + MSG_COUNT_LIMIT_MMS_TYPE, /**< Message count limit for MMS */ + MSG_COUNT_LIMIT_CB_TYPE, /**< Message count limit for callback messages */ + MSG_COUNT_LIMIT_WAPPUSH_TYPE, /**< Message count limit for wappush messages */ + MSG_COUNT_LIMIT_PROVISION_TYPE, /**< Message count limit for provision messages */ + MSG_COUNT_LIMIT_MSG_TYPE_MAX, /**< Indicates maximum number of types of message count limits */ }; + +/** + * @brief Enumeration for the values of a storage change type. \n + * This enum is used with storage change callback functions. + */ enum _MSG_STORAGE_CHANGE_TYPE_E { // msg data - MSG_STORAGE_CHANGE_INSERT = 1, - MSG_STORAGE_CHANGE_UPDATE, - MSG_STORAGE_CHANGE_DELETE, + MSG_STORAGE_CHANGE_INSERT = 1, /**< Indicates storage change by an INSERT operation*/ + MSG_STORAGE_CHANGE_UPDATE, /**< Indicates storage change by an UPDATE operation*/ + MSG_STORAGE_CHANGE_DELETE, /**< Indicates storage change by a DELETE operation*/ // thread data - MSG_STORAGE_CHANGE_CONTACT, + MSG_STORAGE_CHANGE_CONTACT, /**< Indicates storage change by a CHANGE CONTACT operation*/ }; +/** + * @} + */ #endif /* MSG_STORAGE_TYPES_H_ */ diff --git a/include/mapi/msg_transport.h b/include/mapi/msg_transport.h index f5b9e0d..16c1ec4 100755 --- a/include/mapi/msg_transport.h +++ b/include/mapi/msg_transport.h @@ -1,35 +1,22 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -/** - * @file MapiTransport.h - * @brief Defines transport API of messaging framework - * @version 1.0 - */ - #ifndef MAPI_TRANSPORT_H #define MAPI_TRANSPORT_H -/** - * @section Introduction - * - Introduction : Overview on Messaging Transport API - * @section Program - * - Program : Messaging Transport API Reference - */ - /*================================================================================================== INCLUDE FILES ==================================================================================================*/ @@ -42,933 +29,522 @@ extern "C" #endif /** - * @ingroup MESSAGING_FRAMEWORK - * @defgroup MESSAGING_TRANSPORT_API Messaging Transport API - * @{ - */ - -/*================================================================================================== - FUNCTION PROTOTYPES -==================================================================================================*/ - -/** - - * \par Description: - * Submits a request to the Messaging Framework. - * - * \par Purpose: - * This API is used to submit a request to the Messaging Framework. + * @internal + * @ingroup MSG_SERVICE_FRAMEWORK + * @defgroup MSG_SERVICE_FRAMEWORK_TRANSPORT_MODULE Transport API + * @brief The Transport API provides functions to send SMS/MMS and register incoming/sending/syncML/report callback. * - * \par Typical use case: - * Submit a request to Messaging Service such as Send Message, Forward etc. + * @internal + * @addtogroup MSG_SERVICE_FRAMEWORK_TRANSPORT_MODULE + * @{ * - * \par Method of function operation: - * Sets up the database connection and inserts the message to message table. + * @section MSG_SERVICE_FRAMEWORK_TRANSPORT_MODULE_HEADER Required Header + * \#include * - * \par Sync (or) Async: - * This is a Synchronous API. + * @section MSG_SERVICE_FRAMEWORK_TRANSPORT_MODULE_OVERVIEW Overview * - * \par Important notes: - * - The result information will be sent back by using the callback function, msg_sent_status_cb. - * - Applications MUST fill in the valid message type. - * - reqId will be filled in the framework. + * The Transport API provides the following functionalities: * - * \param input - handle is Message handle. - * \param input - req is a pointer to an MSG_REQUEST_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid. - * - MSG_ERR_NULL_POINTER Pointer is NULL. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * - Sending SMS/MMS messages + * - Register incoming message callback + * - Register sent status callback + * - Register push message application + * - Register syncML message callback + * - Managing the registration * - * \par Related functions: - * None + * @section MSG_SERVICE_FRAMEWORK_TRANSPORT_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.telephony\n + * - http://tizen.org/feature/network.telephony.mms\n * - * \par Known issues/bugs: - * None + * It is recommended to design feature related codes in your application for reliability.\n * - * \par Sample code: - * \code - * ... + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n * - * int err = MSG_SUCCESS; - * MSG_REQUEST_S req; + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * - * req.msg = msg; - * req.sendOpt = sendOpt; - - * err = msg_submit_req(msgHandle, &req); - * if (err != MSG_SUCCESS) - * { - * ... - * } + * More details on featuring your application can be found from Feature Element. * - * ... - * \endcode */ -/*================================================================================================*/ -int msg_submit_req(msg_handle_t handle, msg_struct_t req); +/*================================================================================================== + FUNCTION PROTOTYPES +==================================================================================================*/ /** - - * \par Description: - * Registers sent status callback function to Message handle. + * @brief Submits a request to the Messaging Framework. * - * \par Purpose: - * This API is used to register sent status callback function "msg_sent_status_cb" to Message handle. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Typical use case: - * Register for sent status callback. + * @remarks The result information will be sent back by using the callback function, msg_sent_status_cb(). + * @remarks Applications MUST fill in the valid message type. + * @remarks reqId will be filled in the framework. * - * \par Method of function operation: - * Adds the msg_sent_status_cb API to sent status callback list. + * @param[in] handle The message handle + * @param[in] req The pointer to an #MSG_REQUEST_S structure * - * \par Sync (or) Async: - * This is a Synchronous API. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Important notes: - * This function MUST be called after Message handle is opened. - * - * \param input - handle is Message handle. - * \param input - cb is a function to be called. - * \param input - user_param is a pointer to user data. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_TRANSPORT_ERROR Transport error + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_submit_req(msg_handle_t handle, msg_struct_t req); + + +/** + * @brief Registers sent status callback function to Message handle. + * @details This API is used to register sent status callback function msg_sent_status_cb() to Message handle. * - * \par Related functions: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Known issues/bugs: - * None + * @remarks This function MUST be called after Message handle is opened. * - * \par Sample code: - * \code - * ... + * @param[in] handle The message handle + * @param[in] cb The function to be called + * @param[in] user_param A pointer to user data * - * int err = MSG_SUCCESS; - * MSG_REQUEST_S req; + * @return @c 0 on success, + * otherwise a negative error value * - * req.msg = msg; - * req.sendOpt = sendOpt; - - * err = msg_reg_sent_status_callback(msgHandle, &sentStatusCB, (void*)"sent status callback"); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * return; - * } - - * void sentStatusCB(msg_handle_t Handle, MSG_SENT_STATUS_S *pStatus, void *pUserParam) - * { - * ... - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_reg_sent_status_callback(msg_handle_t handle, msg_sent_status_cb cb, void *user_param); /** - - * \par Description: - * Registers incoming SMS callback to Message handle. - * - * \par Purpose: - * This API is used to Registers incoming SMS callback function "msg_sms_incoming_cb" to Message handle. - * - * \par Typical use case: - * Register incoming SMS message callback. - * - * \par Method of function operation: - * Adds the msg_sms_incoming_cb API to incoming SMS callback list. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * This function MUST be called after Message handle is opened. - * - * \param input - handle is Message handle. - * \param input - cb is a function to be called. - * \param input - port is used for listening. If port is not used, please assign 0 to it. - * \param input - user_param is a pointer to user data. + * @brief Registers incoming SMS callback to Message handle. + * @details This API is used to Registers incoming SMS callback function msg_sms_incoming_cb() to Message handle. * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None + * @remarks This function MUST be called after Message handle is opened. * - * \par Sample code: - * \code - * ... + * @param[in] handle The message handle + * @param[in] cb The function to be called + * @param[in] port The port used for listening \n + * If port is not used, set to @c 0. + * @param[in] user_param A pointer to user data * - * int err = MSG_SUCCESS; - * MSG_REQUEST_S req; + * @return @c 0 on success, + * otherwise a negative error value * - * req.msg = msg; - * req.sendOpt = sendOpt; - - * err = msg_reg_sms_message_callback(msgHandle, &incomingSmsCB, 0, (void*)"sms message callback"); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * return; - * } - * - * void incomingSmsCB(msg_handle_t Handle, msg_message_t msg, void *pUserParam) - * { - * ... - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_reg_sms_message_callback(msg_handle_t handle, msg_sms_incoming_cb cb, unsigned short port, void *user_param); /** - - * \par Description: - * Registers incoming MMS callback to Message handle. - * - * \par Purpose: - * This API is used to Registers incoming MMS callback function "msg_mms_conf_msg_incoming_cb" to Message handle. - * - * \par Typical use case: - * Register incoming SMS message callback. - * - * \par Method of function operation: - * Adds the msg_mms_conf_msg_incoming_cb API to incoming MMS callback list. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * This function MUST be called after Message handle is opened. - * - * \param input - handle is Message handle. - * \param input - handle is Message handle. - * \param input - cb is a function to be called. - * \param input - app_id is used for listening. If appId is not used, please assign NULL to it. - * \param input - user_param is a pointer to user data. + * @brief Registers incoming MMS conf callback to Message handle. + * @details This API is used to Registers incoming MMS conf callback function msg_mms_conf_msg_incoming_cb() to Message handle. * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None + * @remarks This function MUST be called after Message handle is opened. * - * \par Sample code: - * \code - * ... + * @param[in] handle The message handle + * @param[in] cb The function to be called + * @param[in] app_id The app ID used for listening \n + * If appId is not used, set to @c NULL. + * @param[in] user_param A pointer to user data * - * int err = MSG_SUCCESS; - * MSG_REQUEST_S req; + * @return @c 0 on success, + * otherwise a negative error value * - * req.msg = msg; - * req.sendOpt = sendOpt; - - * err = msg_reg_mms_conf_message_callback(msgHandle, &incomingMmsConfCB, NULL, NULL); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * return; - * } - * - * void incomingMmsConfCB(msg_handle_t Handle, msg_message_t msg, void *pUserParam) - * { - * ... - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_reg_mms_conf_message_callback(msg_handle_t handle, msg_mms_conf_msg_incoming_cb cb, const char *app_id, void *user_param); /** - - * \par Description: - * Registers incoming SyncML Message callback to Message handle. - * - * \par Purpose: - * This API is used to Registers incoming SyncML Message callback function "msg_syncml_msg_incoming_cb" to Message handle. - * - * \par Typical use case: - * Register incoming SMS message callback. - * - * \par Method of function operation: - * Adds the msg_syncml_msg_incoming_cb API to incoming SyncML callback list. - * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * This function MUST be called after Message handle is opened. - * - * \param input - handle is Message handle. - * \param input - cb is a function to be called. - * \param input - user_param is a pointer to user data. + * @brief Registers incoming SyncML Message callback to Message handle. + * @details This API is used to register incoming SyncML Message callback function msg_syncml_msg_incoming_cb() to Message handle. * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_MSGHANDLE_NOT_CONNECTED Message handle is not connected. - * - MSG_ERR_MEMORY_ERROR Memory is error. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None + * @remarks This function MUST be called after Message handle is opened. * - * \par Sample code: - * \code - * ... + * @param[in] handle The message handle + * @param[in] cb The function to be called + * @param[in] user_param A pointer to user data * - * int err = MSG_SUCCESS; + * @return @c 0 on success, + * otherwise a negative error value * - * err = err = msg_reg_syncml_message_callback(msgHandle, &syncMLCB, NULL); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * return; - * } - * - * void syncMLCB(msg_handle_t hMsgHandle, msg_syncml_message_type_t msgType, const char* pPushHeader, int PushHeaderLen, const char* pPushBody, int PushBodyLen, void *pUserParam) - * { - * ... - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_reg_syncml_message_callback(msg_handle_t handle, msg_syncml_msg_incoming_cb cb, void *user_param); /** - - * \par Description: - * Registers incoming LBS Message callback to Message handle. + * @brief Registers incoming LBS Message callback to Message handle. + * @details This API is used to register incoming LBS Message callback function msg_lbs_msg_incoming_cb() to Message handle. * - * \par Purpose: - * This API is used to Registers incoming LBS Message callback function "msg_lbs_msg_incoming_cb" to Message handle. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Typical use case: - * Register incoming SMS message callback. + * @remarks This function MUST be called after Message handle is opened. * - * \par Method of function operation: - * Adds the msg_lbs_msg_incoming_cb API to incoming LBS Message callback list. + * @param[in] handle The message handle + * @param[in] cb The function to be called + * @param[in] user_param A pointer to user data * - * \par Sync (or) Async: - * This is a Synchronous API. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Important notes: - * This function MUST be called after Message handle is opened. - * - * \param input - handle is Message handle. - * \param input - cb is a function to be called. - * \param input - user_param is a pointer to user data. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_MSGHANDLE_NOT_CONNECTED Message handle is not connected. - * - MSG_ERR_MEMORY_ERROR Memory is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * int err = MSG_SUCCESS; - * - * err = msg_reg_lbs_message_callback(msgHandle, &lbsCB, NULL); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * return; - * } - * - * void lbsCB(msg_handle_t hMsgHandle, const char* pPushHeader, const char* pPushBody, int pushBodyLen, void *pUserParam) - * { - * ... - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_reg_lbs_message_callback(msg_handle_t handle, msg_lbs_msg_incoming_cb cb, void *user_param); /** - - * \par Description: - * Registers incoming LBS Message callback to Message handle. - * - * \par Purpose: - * This API is used to Registers incoming LBS Message callback function "msg_lbs_msg_incoming_cb" to Message handle. + * @brief Registers SyncML operation callback to Message handle. + * @details This API is used to register SyncML operation callback function msg_syncml_msg_operation_cb() to Message handle. * - * \par Typical use case: - * Register incoming SMS message callback. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Method of function operation: - * Adds the msg_lbs_msg_incoming_cb API to incoming LBS Message callback list. + * @remarks This function MUST be called after Message handle is opened. * - * \par Sync (or) Async: - * This is a Synchronous API. + * @param[in] handle The message handle + * @param[in] cb The function to be called + * @param[in] user_param A pointer to user data * - * \par Important notes: - * This function MUST be called after Message handle is opened. + * @return @c 0 on success, + * otherwise a negative error value * - * \param input - handle is Message handle. - * \param input - cb is a function to be called. - * \param input - user_param is a pointer to user data. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_MSGHANDLE_NOT_CONNECTED Message handle is not connected. - * - MSG_ERR_MEMORY_ERROR Memory is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * int err = MSG_SUCCESS; - * - * err = msg_reg_lbs_message_callback(msgHandle, &lbsCB, NULL); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * return; - * } - * - * void lbsCB(msg_handle_t hMsgHandle, const char* pPushHeader, const char* pPushBody, int pushBodyLen, void *pUserParam) - * { - * ... - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_reg_syncml_message_operation_callback(msg_handle_t handle, msg_syncml_msg_operation_cb cb, void *user_param); /** - - * \par Description: - * Registers incoming LBS Message callback to Message handle. - * - * \par Purpose: - * This API is used to Registers incoming LBS Message callback function "msg_lbs_msg_incoming_cb" to Message handle. - * - * \par Typical use case: - * Register incoming SMS message callback. + * @brief Registers incoming push Message callback to Message handle. + * @details This API is used to register incoming push Message callback function msg_push_msg_incoming_cb() to Message handle. * - * \par Method of function operation: - * Adds the msg_lbs_msg_incoming_cb API to incoming LBS Message callback list. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Sync (or) Async: - * This is a Synchronous API. + * @remarks This function MUST be called after Message handle is opened. * - * \par Important notes: - * This function MUST be called after Message handle is opened. + * @param[in] handle The message handle + * @param[in] cb The function to be called + * @param[in] app_id The app ID for listening \n + * If appId is not used, set to @c NULL. + * @param[in] user_param A pointer to user data * - * \param input - handle is Message handle. - * \param input - cb is a function to be called. - * \param input - user_param is a pointer to user data. + * @return @c 0 on success, + * otherwise a negative error value * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_MSGHANDLE_NOT_CONNECTED Message handle is not connected. - * - MSG_ERR_MEMORY_ERROR Memory is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_reg_push_message_callback(msg_handle_t handle, msg_push_msg_incoming_cb cb, const char *app_id, void *user_param); + + +/** + * @brief Registers incoming CB Message callback to Message handle. + * @details This API is used to register incoming CB Message callback function msg_cb_incoming_cb() to Message handle. * - * \par Known issues/bugs: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Sample code: - * \code - * ... + * @remarks This function MUST be called after Message handle is opened. * - * int err = MSG_SUCCESS; + * @param[in] handle The message handle + * @param[in] cb The function to be called + * @param[in] bsave A bool flag to indicate whether CB message is to be saved or not \n + * CB message will be saved if this flag is true + * @param[in] user_param A pointer to user data * - * err = msg_reg_lbs_message_callback(msgHandle, &lbsCB, NULL); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * return; - * } + * @return @c 0 on success, + * otherwise a negative error value * - * void lbsCB(msg_handle_t hMsgHandle, const char* pPushHeader, const char* pPushBody, int pushBodyLen, void *pUserParam) - * { - * ... - * } - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_syncml_message_operation(msg_handle_t handle, msg_message_id_t msgId); +int msg_reg_cb_message_callback(msg_handle_t handle, msg_cb_incoming_cb cb, bool bsave, void *user_param); -/** - * \par Description: - * Sends SMS. It is a synchronous API which has been blocked until sent status arrives. - * - * \par Purpose: - * This API is used to sends SMS. - * - * \par Typical use case: - * Sends a SMS Message - * - * \par Method of function operation: - * It is a synchronous API which has been blocked until sent status arrives. + +/** + * @brief Registers incoming Report Message callback to Message handle. + * @details This API is used to register incoming Report Message callback function msg_report_msg_incoming_cb() to Message handle. * - * \par Sync (or) Async: - * This is a Synchronous API. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Important notes: - * - None + * @remarks This function MUST be called after Message handle is opened. * - * \param input - phone_num is the list of phone numbers. It is separated by ",". - * \param input - sms_text is a SMS text. - * \param input - cb is a function to be called. - * \param input - user_param is for user data. + * @param[in] handle The message handle + * @param[in] cb The function to be called + * @param[in] user_param A pointer to user data * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_NULL_POINTER Invalid parameter. - * - MSG_ERR_MEMORY_ERROR Memory is error. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_CALLBACK_ERROR Callback registration error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported + */ + +int msg_reg_report_message_callback(msg_handle_t handle, msg_report_msg_incoming_cb cb, void *user_param); + + +/** + * @brief Operates SyncML message. + * @details This API is used to run SyncML operation. * - * \par Known issues/bugs: - * None + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.read * - * \par Sample code: - * \code - * ... + * @remarks This function MUST be called after Message handle is opened. * - * int err = MSG_SUCCESS; + * @param[in] handle The message handle + * @param[in] msgId The message ID to run SycnML operation * - * err = msg_sms_send("01000000000,01000000000", "1234567890", sentStatusCB, NULL); - * if (err != MSG_SUCCESS) - * { - * ... - * } + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_TRANSPORT_ERROR Transport error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ -int msg_sms_send(const char *phone_num, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param); +int msg_syncml_message_operation(msg_handle_t handle, msg_message_id_t msgId); -/** - * \par Description: - * Submits request to send SMS message. - * - * \par Purpose: - * This API is used to submit request to send SMS message. - * - * \par Typical use case: - * Submits request to send SMS message. - * - * \par Method of function operation: - * Submits a request to send SMS. +/** + * @brief Sends SMS. + * @details This API is used to send SMS. It is a synchronous API which has been blocked until sent status arrives. * - * \par Sync (or) Async: - * This is a Synchronous API. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Important notes: - * - None + * @param[in] phone_num The list of phone numbers \n + * It is separated by ",". + * @param[in] sms_text The SMS text + * @param[in] cb The function to be called + * @param[in] user_param The user data * - * \param input - phone_num is the list of phone numbers. It is separated by ",". - * \param input - sms_text is a SMS text. - * \param input - cb is a function to be called. - * \param input - user_param is for user data. + * @return @c 0 on success, + * otherwise a negative error value * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_NULL_POINTER Invalid parameter. - * - MSG_ERR_MEMORY_ERROR Memory is error. + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_MEMORY_ERROR Memory error + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported * * \par Prospective clients: * External/Native Apps using Messaging Services. * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... + */ + +int msg_sms_send(const char *phone_num, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param); + + +/** + * @brief Submits request to send SMS message. + * @details This API is used to submit request to send SMS message. * - * int err = MSG_SUCCESS; - * MSG_REQUEST_S req; + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * req.msg = msg; - * req.sendOpt = sendOpt; + * @param[in] handle The message handle + * @param[in] req A pointer to #msg_struct_t structure for SMS request information * - * err = msg_sms_send_message(msgHandle, &req); - * if (err != MSG_SUCCESS) - * { - * ... - * } + * @return @c 0 on success, + * otherwise a negative error value * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_NULL_POINTER Null parameter + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_sms_send_message(msg_handle_t handle, msg_struct_t req); /** - - * \par Description: - * Submits request to send MMS message. - * - * \par Purpose: - * This API is used to submit request to send MMS message. + * @brief Submits request to send MMS message. + * @details This API is used to submit request to send MMS message. * - * \par Typical use case: - * Submits request to send MMS message. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Method of function operation: - * Submits a request to send MMS. + * @param[in] handle The message handle + * @param[in] req A pointer to #msg_struct_t structure for MMS request information * - * \par Sync (or) Async: - * This is a Synchronous API. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - req is a pointer to an MSG_REQUEST_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_NULL_POINTER Invalid parameter. - * - MSG_ERR_MEMORY_ERROR Memory is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * int err = MSG_SUCCESS; - * MSG_REQUEST_S req; - * - * req.msg = msg; - * req.sendOpt = sendOpt; - * - * err = msg_mms_send_message(msgHandle, &req); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_mms_send_message(msg_handle_t handle, msg_struct_t req); /** - - * \par Description: - * Submits request to send MMS read report request. + * @brief Submits request to send MMS read report request. + * @details This API is used to submit request to send MMS read report request. * - * \par Purpose: - * This API is used to submit request to send MMS read report request. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Typical use case: - * Submits request to send MMS read report request. + * @param[in] handle The message handle + * @param[in] msg_id The message ID \n + * This is a positive integer. + * @param[in] mms_read_status This is status whether message was read or not * - * \par Method of function operation: - * Submits a request to send MMS read report request. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - msg_id is a message id, which is a positive integer. - * \param input - mms_read_status is status whether message was read or not. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_NULL_POINTER Invalid parameter. - * - MSG_ERR_MEMORY_ERROR Memory is error. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * int err = MSG_SUCCESS; - * - * err = err = msg_mms_send_read_report(NULL, 0, MSG_READ_REPORT_IS_READ); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t msgId, msg_read_report_status_t mms_read_status); /** - - * \par Description: - * Submits request to send forward MMS request. + * @brief Submits request to send forward MMS request. + * @details This API is used to submit request to send forward MMS request. * - * \par Purpose: - * This API is used to submit request to send forward MMS request. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Typical use case: - * Submits request to send forward MMS request. + * @param[in] handle The message handle + * @param[in] req A pointer to #msg_struct_t structure for MMS * - * \par Method of function operation: - * Submits a request to send forward MMS request. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - req is a pointer to an MSG_REQUEST_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid. - * - MSG_ERR_NULL_POINTER Pointer is NULL. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * int err = MSG_SUCCESS; - * - * err = err = msg_mms_send_read_report(NULL, 0, MSG_READ_REPORT_IS_READ); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_mms_forward_message(msg_handle_t handle, msg_struct_t req); /** - - * \par Description: - * Submits request to retrieve MMS request. + * @brief Submits request to retrieve MMS request. + * @details This API is used to submit request to retrieve MMS request. * - * \par Purpose: - * This API is used to submit request to retrieve MMS request. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Typical use case: - * Submits request to retrieve MMS request. + * @param[in] handle The message handle + * @param[in] req A pointer to #msg_struct_t structure for MMS * - * \par Method of function operation: - * Submits a request to send forward MMS request. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - req is a pointer to an MSG_REQUEST_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid. - * - MSG_ERR_NULL_POINTER Pointer is NULL. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * int err = MSG_SUCCESS; - * - * err = msg_mms_retrieve_message(handle, &req); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_mms_retrieve_message(msg_handle_t handle, msg_struct_t req); -/* reject_msg_support */ /** - - * \par Description: - * Submits request to reject MMS message. + * @brief Submits request to reject MMS message. + * @details This API is used to submit request to reject MMS message. * - * \par Purpose: - * This API is used to submit request to reject MMS message. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/message.write * - * \par Typical use case: - * Submits request to reject MMS message. + * @param[in] handle The message handle + * @param[in] req A pointer to #msg_struct_t structure for MMS * - * \par Method of function operation: - * Submits a request to send forward reject MMS message. + * @return @c 0 on success, + * otherwise a negative error value * - * \par Sync (or) Async: - * This is a Synchronous API. - * - * \par Important notes: - * - None - * - * \param input - handle is Message handle. - * \param input - req is a pointer to an MSG_REQUEST_S structure. - * - * \return Return Type (int(msg_error_t)) \n - * - MSG_SUCCESS Success in operation. - * - MSG_ERR_INVALID_MSGHANDLE Message handle is invalid. - * - MSG_ERR_NULL_POINTER Pointer is NULL. - * - * \par Prospective clients: - * External/Native Apps using Messaging Services. - * - * \par Related functions: - * None - * - * \par Known issues/bugs: - * None - * - * \par Sample code: - * \code - * ... - * - * int err = MSG_SUCCESS; - * - * err = msg_mms_reject_message(handle, &req); - * if (err != MSG_SUCCESS) - * { - * ... - * } - * - * ... - * \endcode + * @retval MSG_SUCCESS Success in operation + * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid + * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -/*================================================================================================*/ + int msg_mms_reject_message(msg_handle_t handle, msg_struct_t req); /** diff --git a/include/mapi/msg_transport_types.h b/include/mapi/msg_transport_types.h index 58229a5..d27811f 100755 --- a/include/mapi/msg_transport_types.h +++ b/include/mapi/msg_transport_types.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_TRANSPORT_TYPES_H_ @@ -24,109 +24,164 @@ #include "msg_types.h" #include "msg_storage_types.h" +/** + * @internal + * @addtogroup MSG_SERVICE_FRAMEWORK_TRANSPORT_MODULE + * @{ + */ + /*================================================================================================== DEFINES ==================================================================================================*/ -/** @brief Prototype of the function that will be called when the status of the message which is already sent is changed. - * Applications SHOULD implement this callback function and register it into Message handle. - * For how to register this callback function, please refer to msg_reg_sent_status_callback. - * If the application sends a message, this callback function will be called to report its sending status. - * The application can get the request ID from sent_status to know which request is bound. - * The callback function runs in the application process, not in the framework process. - * The memory of sent_status is managed by MAPI, when the callback function is finished. - * @param[in] handle is Message handle. - * @param[in] sent_status is a pointer to an MSG_SENT_STATUS_S structure. - * @param[in] user_param is a pointer to user data. - * @return void +/** @brief Called when the status of the message which is already sent is changed. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_sent_status_callback(). + * If the application sends a message, this callback function will be called to report its sending status. + * The application can get the request ID from sent_status to know which request is bound. + * The callback function runs in the application process, not in the framework process. + * The memory of @a sent_status is managed by MAPI, when the callback function is finished. + * + * @param[in] handle The Message handle + * @param[in] sent_status A pointer to #msg_struct_t structure for sent status + * @param[in] user_param The user data */ typedef void (*msg_sent_status_cb)(msg_handle_t handle, msg_struct_t sent_status, void *user_param); -/** @brief Prototype of the function that will be called when the status of the message which is already sent is changed. - * Applications SHOULD implement this callback function and register it into Message handle. - * For how to register this callback function, please refer to msg_reg_sent_status_callback. - * If the application sends a message, this callback function will be called to report its sending status. - * The application can get the request ID from sent_status to know which request is bound. - * The callback function runs in the application process, not in the framework process. - * The memory of sent_status is managed by MAPI, when the callback function is finished. - * @param[in] sent_status is a pointer to an MSG_SENT_STATUS_S structure. - * @param[in] user_param is a pointer to user data. - * @return void +/** @brief Called when the status of the message which is already sent is changed. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_sent_status_callback(). + * If the application sends a message, this callback function will be called to report its sending status. + * The application can get the request ID from sent_status to know which request is bound. + * The callback function runs in the application process, not in the framework process. + * The memory of @a sent_status is managed by MAPI, when the callback function is finished. + * + * @param[in] sent_status A pointer to #msg_struct_t structure for sent status + * @param[in] user_param The pointer to user data */ typedef void (*msg_simple_sent_status_cb)(msg_struct_t sent_status, void *user_param); -/** @brief Prototype of the function that will be called when a new message is received. - * Applications SHOULD implement this callback function and register it into Message handle. - * For how to register this callback function, please refer to msg_reg_sms_message_callback. - * This callback function will be called when a new message is received and the message satisfies the filter list. - * The callback function runs in the application process, not in the framework process. - * The memory for msg is managed by MAPI, when the callback function is finished. - * @param[in] handle is Message handle. - * @param[in] msg is a pointer to an msg_message_t structure. - * @param[in] user_param is a pointer to user data. - * @return void +/** @brief Called when a new message is received. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_sms_message_callback(). + * This callback function will be called when a new message is received and the message satisfies the filter list. + * The callback function runs in the application process, not in the framework process. + * The memory for msg is managed by MAPI, when the callback function is finished. + * + * @param[in] handle The Message handle + * @param[in] msg A pointer to #msg_struct_t structure for message details + * @param[in] user_param The user data */ typedef void (*msg_sms_incoming_cb)(msg_handle_t handle, msg_struct_t msg, void *user_param); -/** @brief Prototype of the function that will be called when a new MMS message is received. - * Applications SHOULD implement this callback function and register it into Message handle. - * For how to register this callback function, please refer to msg_reg_mms_conf_message_callback. - * This callback function will be called when a new MMS message is received and the message satisfies the filter list. - * The callback function runs in the application process, not in the framework process. - * The memory for msg is managed by MAPI, when the callback function is finished. - * @param[in] handle is Message handle. - * @param[in] msg is a pointer to an msg_message_t structure. - * @param[in] user_param is a pointer to user data. - * @return void +/** @brief Called when a new MMS message is received. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_mms_conf_message_callback(). + * This callback function will be called when a new MMS message is received and the message satisfies the filter list. + * The callback function runs in the application process, not in the framework process. + * The memory for @a msg is managed by MAPI, when the callback function is finished. + * + * @param[in] handle The Message handle + * @param[in] msg A pointer to #msg_struct_t structure for message details + * @param[in] user_param The user data */ typedef void (*msg_mms_conf_msg_incoming_cb)(msg_handle_t handle, msg_struct_t msg, void *user_param); -/** @brief Prototype of the function that will be called when a new SyncML message is received. - * Applications SHOULD implement this callback function and register it into Message handle. - * For how to register this callback function, please refer to msg_reg_syncml_message_callback. - * This callback function will be called when a new message is received and the message satisfies the filter list. - * The callback function runs in the application process, not in the framework process. - * @param[in] handle is Message handle. - * @param[in] msg_type is msg_syncml_message_type_t structure. - * @param[in] push_body is WAP Push body data. - * @param[in] push_body_len is the length of WAP Push body data. - * @param[in] user_param is a pointer to user data. - * @return void +/** @brief Called when a new SyncML message is received. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_syncml_message_callback(). + * This callback function will be called when a new message is received and the message satisfies the filter list. + * The callback function runs in the application process, not in the framework process. + * + * @param[in] handle The Message handle + * @param[in] msg_type The #msg_syncml_message_type_t structure + * @param[in] push_body The WAP Push body data + * @param[in] push_body_len The length of WAP Push body data + * @param[in] sim_index The index of the sim on which message is received. + * @param[in] user_param The user data */ -typedef void (*msg_syncml_msg_incoming_cb)(msg_handle_t handle, msg_syncml_message_type_t msg_type, const char *push_body, int push_body_len, const char* wsp_header, int wsp_header_len, void *user_param); - - -/** @brief Prototype of the function that will be called when a new LBS message is received. - * Applications SHOULD implement this callback function and register it into Message handle. - * For how to register this callback function, please refer to msg_reg_lbs_message_callback. - * This callback function will be called when a new message is received and the message satisfies the filter list. - * The callback function runs in the application process, not in the framework process. - * @param[in] hMsgHandle is Message handle. - * @param[in] push_header is push message header data. - * @param[in] push_body is push message body data. - * @param[in] push_body_len is push message body length. - * @param[in] user_param is a pointer to user data. - * @return void +typedef void (*msg_syncml_msg_incoming_cb)(msg_handle_t handle, msg_syncml_message_type_t msg_type, const char *push_body, int push_body_len, const char* wsp_header, int wsp_header_len, int sim_index, void *user_param); + + +/** @brief Called when a new LBS message is received. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_lbs_message_callback(). + * This callback function will be called when a new message is received and the message satisfies the filter list. + * The callback function runs in the application process, not in the framework process. + * + * @param[in] hMsgHandle The Message handle + * @param[in] push_header The push message header data + * @param[in] push_body The push message body data + * @param[in] push_body_len The push message body length + * @param[in] user_param The user data */ typedef void (*msg_lbs_msg_incoming_cb)(msg_handle_t handle, const char *push_header, const char *push_body, int push_body_len, void *user_param); -/** @brief Prototype of the function that will be called when a new SyncML message is received. - * Applications SHOULD implement this callback function and register it into Message handle. - * For how to register this callback function, please refer to msg_reg_syncml_message_callback. - * This callback function will be called when a new message is received and the message satisfies the filter list. - * The callback function runs in the application process, not in the framework process. - * @param[in] handle is Message handle. - * @param[in] user_param is a pointer to user data. - * @return void +/** @brief Called when a new SyncML message is received. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_syncml_message_callback(). + * This callback function will be called when a new message is received and the message satisfies the filter list. + * The callback function runs in the application process, not in the framework process. + * + * @param[in] handle The Message handle + * @param[in] msgId The message ID + * @param[in] extId The external ID + * @param[in] user_param The user data */ typedef void (*msg_syncml_msg_operation_cb)(msg_handle_t handle, int msgId, int extId, void *user_param); +/** @brief Called when a new push message is received. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_push_message_callback(). + * This callback function will be called when a new message is received and the message satisfies the filter list. + * The callback function runs in the application process, not in the framework process. + * + * @param[in] handle The Message handle + * @param[in] push_header The push message header data + * @param[in] push_body The push message body data + * @param[in] push_body_len The push message body length + * @param[in] user_param The user data + */ +typedef void (*msg_push_msg_incoming_cb)(msg_handle_t handle, const char *push_header, const char *push_body, int push_body_len, void *user_param); + + +/** @brief Called when a new CB message is received. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_cb_message_callback(). + * This callback function will be called when a new message is received and the message satisfies the filter list. + * The callback function runs in the application process, not in the framework process. + * + * @param[in] handle The Message handle + * @param[in] msg A pointer to #msg_struct_t structure for message details + * @param[in] user_param The user data + */ +typedef void (*msg_cb_incoming_cb)(msg_handle_t handle, msg_struct_t msg, void *user_param); + + +/** @brief Called when a report message is received. + * Applications SHOULD implement this callback function and register it into Message handle. + * For how to register this callback function, please refer to msg_reg_report_message_callback(). + * This callback function will be called when a new message is received and the message satisfies the filter list. + * The callback function runs in the application process, not in the framework process. + * + * @param[in] handle The Message handle + * @param[in] reportMsgType The message type of incoming report message + * @param[in] MsgId The message ID of reported message + * @param[in] addr_len The incoming report message's address length + * @param[in] addr_val The incoming report message's address value + * @param[in] user_param The user data + */ +typedef void (*msg_report_msg_incoming_cb)(msg_handle_t handle, msg_report_type_t reportMsgType, msg_message_id_t MsgId, int addr_len, const char *addr_val, void *user_param); + +/** + * @} + */ #endif /* MSG_TRANSPORT_TYPES_H_ */ diff --git a/include/mapi/msg_types.h b/include/mapi/msg_types.h index 491c2f6..3cfa5ab 100755 --- a/include/mapi/msg_types.h +++ b/include/mapi/msg_types.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_TYPES_H_ @@ -27,284 +27,424 @@ #define EXPORT_API __attribute__ ((visibility("default"))) #endif -#define MAX_TO_ADDRESS_CNT 10 -#define MAX_PHONE_NUMBER_LEN 20 +/** + * @internal + * @addtogroup MSG_SERVICE_FRAMEWORK + * @{ + */ + +/** + * @brief Definition for maximum address count + */ +#define MAX_TO_ADDRESS_CNT 10 + +/** + * @brief Definition for maximum phone number length + */ +#define MAX_PHONE_NUMBER_LEN 20 + +/** + * @brief Definition for maximum XDN alpha ID length + */ +#define MAX_SIM_XDN_ALPHA_ID_LEN 30 +/** + * @brief Definition for maximum address value length + */ #define MAX_ADDRESS_VAL_LEN 254 -#define MAX_SIGN_VAL_LEN 128 -#define MAX_SUBJECT_LEN 120 -#define MAX_DISPLAY_NAME_LEN 195 -#define MAX_IMAGE_PATH_LEN 1024 -#define MAX_MSG_DATA_LEN 320 -#define MAX_MSG_TEXT_LEN 1530 -#define MAX_FILTER_VALUE_LEN 40 -#define MAX_COMMAND_LEN 1024 -#define MAX_FOLDER_NAME_SIZE 20 - -#define MAX_WAPPUSH_ID_LEN 40 -#define MAX_WAPPUSH_HREF_LEN 300 -#define MAX_WAPPUSH_CONTENTS_LEN 2048 +/** + * @brief Definition for maximum subject length + */ +#define MAX_SUBJECT_LEN 120 + +/** + * @brief Definition for maximum display length length + */ +#define MAX_DISPLAY_NAME_LEN 195 + +/** + * @brief Definition for maximum image path length + */ +#define MAX_IMAGE_PATH_LEN 1024 + +/** + * @brief Definition for maximum message data length + */ +#define MAX_MSG_DATA_LEN 320 + +/** + * @brief Definition for maximum message text length + */ +#define MAX_MSG_TEXT_LEN 1530 + +/** + * @brief Definition for maximum filter value length + */ +#define MAX_FILTER_VALUE_LEN 128 + +/** + * @brief Definition for maximum command length + */ +#define MAX_COMMAND_LEN 1024 + +/** + * @brief Definition for maximum folder name size + */ +#define MAX_FOLDER_NAME_SIZE 20 + +/** + * @brief Definition for maximum ID length of push message + */ +#define MAX_WAPPUSH_ID_LEN 100 + +/** + * @brief Definition for maximum content type length of push message + */ +#define MAX_WAPPUSH_CONTENT_TYPE_LEN 100 + +/** + * @brief Definition for maximum href length of push message + */ +#define MAX_WAPPUSH_HREF_LEN 300 + +/** + * @brief Definition for maximum contents length of push message + */ +#define MAX_WAPPUSH_CONTENTS_LEN 2048 + +/** + * @brief Definition for maximum invalid object count of push message(CO) + */ #define MAX_PUSH_CACHEOP_INVALID_OBJECT_MAX 5 -#define MAX_PUSH_CACHEOP_INVALID_SERVICE_MAX 5 -#define MAX_PUSH_CACHEOP_MAX_URL_LEN 200 -#define MAX_COMMON_INFO_SIZE 20 +/** + * @brief Definition for maximum invalid service count of push message(CO) + */ +#define MAX_PUSH_CACHEOP_INVALID_SERVICE_MAX 5 /** - * @brief Defines the maximum file path length + * @brief Definition for maximum URL length of push message(CO) */ -#define MSG_FILEPATH_LEN_MAX 1024 +#define MAX_PUSH_CACHEOP_MAX_URL_LEN 200 + +/** + * @brief Definition for maximum segment count + */ +#define MAX_SEGMENT_NUM 15 + +/** + * @brief Definition for maximum file path length + */ +#define MSG_FILEPATH_LEN_MAX 1024 // setting -#define SMSC_NAME_MAX 127 /* Max SMSC Name Length */ -#define SMSC_ADDR_MAX 20 /* Max SMSC Adress Length */ -#define SMSC_LIST_MAX 5 /* Max List Count of SMSC */ -#define CB_CHANNEL_NAME_MAX 32 /* cb channel name max size */ -#define CB_CHANNEL_MAX 30 /* cb channel max count */ -#define CB_LANG_TYPE_MAX 10 +/** + * @brief Definition for maximum SMSC name length + */ +#define SMSC_NAME_MAX 127 /** - * @brief Defines the maximum file name length + * @brief Definition for maximum SMSC address length */ -#define MSG_FILENAME_LEN_MAX 255 +#define SMSC_ADDR_MAX 21 /** - * @brief Defines the maximum message id length + * @brief Definition for maximum SMSC list count */ -#define MSG_MSG_ID_LEN 100 +#define SMSC_LIST_MAX 5 /** - * @brief Defines the maximum in transition id length + * @brief Definition for maximum CB channel name length */ -#define MAX_SMIL_TRANSIN_ID 100 +#define CB_CHANNEL_NAME_MAX 32 /** - * @brief Defines the maximum out transition id length + * @brief Definition for maximum CB channel count */ -#define MAX_SMIL_TRANSOUT_ID 100 +#define CB_CHANNEL_MAX 30 /** - * @brief Defines the maximum region id length + * @brief Definition for maximum CB language type count */ -#define MAX_SMIL_REGION_ID 151 +#define CB_LANG_TYPE_MAX 10 /** - * @brief Defines the maximum transition id length + * @brief Definition for maximum file name length */ -#define MAX_SMIL_TRANSITION_ID 151 +#define MSG_FILENAME_LEN_MAX 1024 /** - * @brief Defines the maximum meta id length + * @brief Definition for maximum message id length */ -#define MAX_SMIL_META_ID 151 +#define MSG_MSG_ID_LEN 1024 /** - * @brief Defines the maximum meta name length + * @brief Definition for maximum in transition id length */ -#define MAX_SMIL_META_NAME 100 +#define MAX_SMIL_TRANSIN_ID 100 /** - * @brief Defines the maximum meta content length + * @brief Definition for maximum out transition id length */ -#define MAX_SMIL_META_CONTENT 255 +#define MAX_SMIL_TRANSOUT_ID 100 /** - * @brief Defines the maximum fit size + * @brief Definition for maximum region id length */ -#define MAX_SMIL_FIT_SIZE 31 +#define MAX_SMIL_REGION_ID 151 /** - * @brief Defines the maximum pages in a MMS + * @brief Definition for maximum transition id length */ -#define MMS_PAGE_MAX 20 +#define MAX_SMIL_TRANSITION_ID 151 /** - * @brief Defines the maximum media in a MMS + * @brief Definition for maximum meta id length */ -#define MMS_MEDIA_MAX 60 +#define MAX_SMIL_META_ID 151 /** - * @brief Defines the maximum alternate text length + * @brief Definition for maximum meta name length */ -#define MAX_SMIL_ALT_LEN 255 +#define MAX_SMIL_META_NAME 100 +/** + * @brief Definition for maximum meta content length + */ +#define MAX_SMIL_META_CONTENT 255 + +/** + * @brief Definition for maximum fit size + */ +#define MAX_SMIL_FIT_SIZE 31 + +/** + * @brief Definition for maximum pages in a MMS + */ +#define MMS_PAGE_MAX 20 + +/** + * @brief Definition for maximum media in a MMS + */ +#define MMS_MEDIA_MAX 60 -//font size /** - * @brief Defines the small font size + * @brief Definition for maximum alternate text length */ -#define MMS_SMIL_FONT_SIZE_SMALL 24 +#define MAX_SMIL_ALT_LEN 255 + +//font size /** - * @brief Defines the normal font size + * @brief Definition for small font size */ -#define MMS_SMIL_FONT_SIZE_NORMAL 30 +#define MMS_SMIL_FONT_SIZE_SMALL 24 /** - * @brief Defines the large font size + * @brief Definition for normal font size */ -#define MMS_SMIL_FONT_SIZE_LARGE 36 +#define MMS_SMIL_FONT_SIZE_NORMAL 30 -#define MAX_SMIL_ANIMATE_ATTRIBUTE_NAME 100 -#define MAX_SMIL_ANIMATE_ATTRIBUTE_TYPE 100 -#define MAX_SMIL_ANIMATE_TARGET_ELEMENT 100 -#define MAX_SMIL_ANIMATE_CALC_MODE 100 +/** + * @brief Definition for large font size + */ +#define MMS_SMIL_FONT_SIZE_LARGE 36 +/** + * @brief Definition for maximum length of java app ID + */ #define MAX_MMS_JAVA_APPID_LEN 32 -#define CONV_THUMB_WIDTH 250 -#define CONV_THUMB_HEIGHT 170 +/** + * @brief Definition for maximum length of MMS transaction ID + */ +#define MMS_TR_ID_LEN 40 + +/** + * @brief Definition for maximum length of MMS message ID + */ +#define MMS_MSG_ID_LEN 40 + +/** + * @brief Definition for maximum length of MMS contents location + */ +#define MMS_LOCATION_LEN 100 + +/** + * @brief Definition for maximum mimeType length + */ +#define MAX_MIME_TYPE_LEN 64 -#define MMS_TR_ID_LEN 40 -#define MMS_MSG_ID_LEN 40 -#define MMS_LOCATION_LEN 100 /*================================================================================================== TYPES ==================================================================================================*/ -typedef struct opq_msg_svc_s * msg_handle_t; -typedef struct opq_struct_s * msg_struct_t; +/** + * @brief The structure type representing an opaque pointer to message handle. + */ +typedef struct opq_msg_svc_s *msg_handle_t; +/** + * @brief The structure type representing an opaque pointer to message structure type. + */ +typedef struct opq_struct_s *msg_struct_t; +/** + * @brief The structure type representing a pointer to message list handle. + */ typedef struct msg_list_handle *msg_list_handle_t; - +/** + * @brief The structure type representing a message structure list. + */ typedef struct { - int nCount; /**< Indicates the count of msg_struct_t. */ - msg_struct_t *msg_struct_info; /**< Indicates the msg_struct_t information list. */ + int nCount; /**< The count of #msg_struct_t */ + msg_struct_t *msg_struct_info; /**< The #msg_struct_t information list */ }msg_struct_list_s; /** - * @brief Represents a messsage ID. + * @brief The message ID. */ typedef unsigned int msg_message_id_t; /** - * @brief Represents a storage type. - See enum _MSG_STORAGE_ID_E + * @brief The storage type. + * See enum _MSG_STORAGE_ID_E. */ typedef unsigned char msg_storage_id_t; /** - * @brief Represents a folder ID. - See enum _MSG_FOLDER_ID_E + * @brief The folder ID. + * See enum _MSG_FOLDER_ID_E. */ typedef char msg_folder_id_t; /** - * @brief Represents a request ID, which is unique for each request. + * @brief The request ID, which is unique for each request. */ typedef unsigned int msg_request_id_t; /** - * @brief Represents a message priority. \n - * The values for this type SHOULD be in _MSG_PRIORITY_TYPE_E. + * @brief The message priority. \n + * The values for this type SHOULD be in _MSG_PRIORITY_TYPE_E. */ typedef unsigned char msg_priority_type_t; /** - * @brief Represents the network status of a message. \n - * The values for this type SHOULD be in _MSG_NETWORK_STATUS_E. + * @brief The network status of a message. \n + * The values for this type SHOULD be in _MSG_NETWORK_STATUS_E. */ typedef unsigned char msg_network_status_t; /** - * @brief Represents an address type. \n - * The values for this type SHOULD be in _MSG_ADDRESS_TYPE_E. + * @brief The address type. \n + * The values for this type SHOULD be in _MSG_ADDRESS_TYPE_E. */ typedef unsigned char msg_address_type_t; /** - * @brief Represents an recipient type. \n - * The values for this type SHOULD be in _MSG_RECIPIENT_TYPE_E. + * @brief The recipient type. \n + * The values for this type SHOULD be in _MSG_RECIPIENT_TYPE_E. */ typedef unsigned char msg_recipient_type_t; /** - * @brief Represents the type of a message direction. \n - * The values for this type SHOULD be in _MSG_DIRECTION_TYPE_E. + * @brief The type of a message direction. \n + * The values for this type SHOULD be in _MSG_DIRECTION_TYPE_E. */ typedef unsigned char msg_direction_type_t; /** - * @brief Represents an encoding type. \n - * The values for this type SHOULD be in _MSG_ENCODE_TYPE_E. + * @brief The encoding type. \n + * The values for this type SHOULD be in _MSG_ENCODE_TYPE_E. */ typedef unsigned char msg_encode_type_t; /** - * @brief Represents an error code. \n - * The values for this type SHOULD be in _MSG_ERROR_E + * @brief The error code. \n + * The values for this type SHOULD be in _MSG_ERROR_E. */ typedef int msg_error_t; /** -\brief Represents WAP Push App Code. +* @brief The WAP Push App Code. */ typedef unsigned char msg_push_action_t; /** -\brief Represents SyncML Message Type. +* @brief The SyncML Message Type. */ typedef unsigned short msg_syncml_message_type_t; /** - * @brief Represents a Contact ID. + * @brief The Contact ID. */ typedef unsigned int msg_contact_id_t; /** - * @brief Represents a Delivery Report Status. - * The values for this type SHOULD be in _MSG_DELIVERY_REPORT_STATUS_E - */ + * @brief The Report Type. \n + * The values for this type SHOULD be in _MSG_REPORT_TYPE_E. + */ +typedef int msg_report_type_t; + + +/** + * @brief The Delivery Report Status. \n + * The values for this type SHOULD be in _MSG_DELIVERY_REPORT_STATUS_E. + */ typedef int msg_delivery_report_status_t; /** - * @brief Represents a Read Report Status. - * The values for this type SHOULD be in _MSG_READ_REPORT_STATUS_E + * @brief The Read Report Status.\n + * The values for this type SHOULD be in _MSG_READ_REPORT_STATUS_E */ typedef int msg_read_report_status_t; /** - * @brief Represents a Message Type. - * The values for this type SHOULD be in _MSG_MESSAGE_TYPE_E + * @brief The Message Type. \n + * The values for this type SHOULD be in _MSG_MESSAGE_TYPE_E. */ typedef unsigned short msg_message_type_t; +/** + * @brief The Message Backup Type. \n + * 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 + * @brief The thread ID. */ typedef unsigned int msg_thread_id_t; // filter /** - * @brief Represents a filter ID. + * @brief The filter ID. */ typedef unsigned char msg_filter_id_t; /** - * @brief Represents a filter Type. \n - * The filter Type represents a unique filter type. \n - * The values for this type SHOULD be in _MSG_FILTER_TYPE_E. + * @brief The filter Type. \n + * The filter type represents a unique filter type. \n + * The values for this type SHOULD be in _MSG_FILTER_TYPE_E. */ typedef unsigned char msg_filter_type_t; @@ -314,392 +454,708 @@ typedef unsigned char msg_filter_type_t; ENUMS ==================================================================================================*/ +/** + * @brief Enumeration for the values of a structure type for #msg_sturuct_t. \n + */ enum _MSG_STRUCT_E { - MSG_STRUCT_FILTER = 0X0000, /**< Indicates the MSG_STRUCT_FILTER */ - - MSG_STRUCT_MESSAGE_INFO = 0x0200, /**< Indicates the MSG_STRUCT_MESSAGE_INFO */ - MSG_STRUCT_THREAD_INFO = 0x0300, - - MSG_STRUCT_MMS = 0x0500, /**< Indicates the MSG_STRUCT_MMS */ - MSG_STRUCT_MMS_PAGE = 0x0600, /**< Indicates the MSG_STRUCT_MMS_PAGE */ - MSG_STRUCT_MMS_MEDIA = 0x0700, /**< Indicates the MSG_STRUCT_MMS_MEDIA */ - MSG_STRUCT_MMS_ATTACH = 0x0800, /**< Indicates the MSG_STRUCT_MMS_ATTACH */ - MSG_STRUCT_MMS_REGION = 0x0900, /**< Indicates the MSG_STRUCT_MMS_REGION */ - MSG_STRUCT_MMS_TRANSITION = 0x0a00, /**< Indicates the MSG_STRUCT_MMS_TRANSITION */ - MSG_STRUCT_MMS_META = 0x0b00, /**< Indicates the MSG_STRUCT_MMS_META */ - MSG_STRUCT_MMS_SMIL_TEXT = 0x0c00, /**< Indicates the MSG_STRUCT_MMS_SMIL_TEXT */ - MSG_STRUCT_MMS_SMIL_AVI = 0x0d00, /**< Indicates the MSG_STRUCT_MMS_SMIL_AVI */ - - MSG_STRUCT_SETTING_SMSC_OPT = 0x2000, - MSG_STRUCT_SETTING_SMSC_INFO = 0x2100, /**< Indicates the MSG_STRUCT_SETTING_SMSC_INFO */ - MSG_STRUCT_SETTING_CB_OPT = 0x2200, /**< Indicates the MSG_STRUCT_SETTING_CB_OPT */ - MSG_STRUCT_SETTING_CB_CHANNEL_INFO = 0x2300, /**< Indicates the MSG_STRUCT_CB_CHANNEL_INFO */ - MSG_STRUCT_SETTING_SMS_SEND_OPT = 0x2400, /**< Indicates the MSG_STRUCT_SETTING_SMS_SEND_OPT */ - MSG_STRUCT_SETTING_MMS_SEND_OPT = 0x2500, /**< Indicates the MSG_STRUCT_SETTING_MMS_SEND_OPT */ - MSG_STRUCT_SETTING_MMS_RECV_OPT = 0x2600, /**< Indicates the MSG_STRUCT_SETTING_MMS_RECV_OPT */ - MSG_STRUCT_SETTING_PUSH_MSG_OPT = 0x2700, /**< Indicates the MSG_STRUCT_SETTING_PUSH_MSG_OPT */ - MSG_STRUCT_SETTING_VOICE_MSG_OPT = 0x2800, /**< Indicates the MSG_STRUCT_SETTING_VOICE_MSG_OPT */ - 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 */ - MSG_STRUCT_THREAD_LIST_INDEX = 0x3400, /**< Indicates the MSG_STRUCT_THREAD_LIST_INDEX */ - MSG_STRUCT_SORT_RULE = 0x3500, /**< Indicates the MSG_STRUCT_SORT_RULE */ - MSG_STRUCT_FOLDER_INFO = 0x3600, /**< Indicates the MSG_STRUCT_FOLDER_INFO */ - MSG_STRUCT_SEARCH_CONDITION = 0x3700, /**< Indicates the MSG_STRUCT_SEARCH_CONDITION */ - MSG_STRUCT_REPORT_STATUS_INFO = 0x3800, /**< Indicates the MSG_STRUCT_REPORT_STATUS_INFO */ - - MSG_STRUCT_ADDRESS_INFO = 0x4000, /**< Indicates the MSG_STRUCT_ADDRESS_INFO */ - MSG_STRUCT_SENDOPT = 0x4100, /**< Indicates the MSG_STRUCT_SENDOPT */ - MSG_STRUCT_MMS_SENDOPT = 0x4200, /**< Indicates the MSG_STRUCT_MMS_SENDOPT */ - MSG_STRUCT_SMS_SENDOPT = 0x4300, /**< Indicates the MSG_STRUCT_SMS_SENDOPT */ - MSG_STRUCT_REJECT_MSG_INFO = 0x4400, /**< Indicates the MSG_STRUCT_REJECT_MSG_INFO */ - MSG_STRUCT_REQUEST_INFO = 0x4500, /**< Indicates the MSG_STRUCT_REQUEST_INFO */ - MSG_STRUCT_SENT_STATUS_INFO = 0x4600, /**< Indicates the MSG_STRUCT_SENT_STATUS_INFO */ -}; - + MSG_STRUCT_FILTER = 0X0000, /**< Indicates the MSG_STRUCT_FILTER */ + + MSG_STRUCT_MESSAGE_INFO = 0x0200, /**< Indicates the MSG_STRUCT_MESSAGE_INFO */ + MSG_STRUCT_THREAD_INFO = 0x0300, /**< Indicates the MSG_STRUCT_THREAD_INFO*/ + MSG_STRUCT_CONV_INFO = 0x0400, /**< Indicates the MSG_STRUCT_CONV_INFO*/ + MSG_STRUCT_MMS = 0x0500, /**< Indicates the MSG_STRUCT_MMS */ + MSG_STRUCT_MMS_PAGE = 0x0600, /**< Indicates the MSG_STRUCT_MMS_PAGE */ + MSG_STRUCT_MMS_MEDIA = 0x0700, /**< Indicates the MSG_STRUCT_MMS_MEDIA */ + MSG_STRUCT_MMS_ATTACH = 0x0800, /**< Indicates the MSG_STRUCT_MMS_ATTACH */ + MSG_STRUCT_MMS_REGION = 0x0900, /**< Indicates the MSG_STRUCT_MMS_REGION */ + MSG_STRUCT_MMS_TRANSITION = 0x0a00, /**< Indicates the MSG_STRUCT_MMS_TRANSITION */ + MSG_STRUCT_MMS_META = 0x0b00, /**< Indicates the MSG_STRUCT_MMS_META */ + MSG_STRUCT_MMS_SMIL_TEXT = 0x0c00, /**< Indicates the MSG_STRUCT_MMS_SMIL_TEXT */ + MSG_STRUCT_MMS_SMIL_AVI = 0x0d00, /**< Indicates the MSG_STRUCT_MMS_SMIL_AVI */ + + MSG_STRUCT_SETTING_SMSC_OPT = 0x2000, /**< Indicates the MSG_STRUCT_SETTING_SMSC_OPT */ + MSG_STRUCT_SETTING_SMSC_INFO = 0x2100, /**< Indicates the MSG_STRUCT_SETTING_SMSC_INFO */ + MSG_STRUCT_SETTING_CB_OPT = 0x2200, /**< Indicates the MSG_STRUCT_SETTING_CB_OPT */ + MSG_STRUCT_SETTING_CB_CHANNEL_INFO = 0x2300, /**< Indicates the MSG_STRUCT_CB_CHANNEL_INFO */ + MSG_STRUCT_SETTING_SMS_SEND_OPT = 0x2400, /**< Indicates the MSG_STRUCT_SETTING_SMS_SEND_OPT */ + MSG_STRUCT_SETTING_MMS_SEND_OPT = 0x2500, /**< Indicates the MSG_STRUCT_SETTING_MMS_SEND_OPT */ + MSG_STRUCT_SETTING_MMS_RECV_OPT = 0x2600, /**< Indicates the MSG_STRUCT_SETTING_MMS_RECV_OPT */ + MSG_STRUCT_SETTING_PUSH_MSG_OPT = 0x2700, /**< Indicates the MSG_STRUCT_SETTING_PUSH_MSG_OPT */ + MSG_STRUCT_SETTING_VOICE_MSG_OPT = 0x2800, /**< Indicates the MSG_STRUCT_SETTING_VOICE_MSG_OPT */ + 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 */ + MSG_STRUCT_THREAD_LIST_INDEX = 0x3400, /**< Indicates the MSG_STRUCT_THREAD_LIST_INDEX */ + MSG_STRUCT_SORT_RULE = 0x3500, /**< Indicates the MSG_STRUCT_SORT_RULE */ + MSG_STRUCT_FOLDER_INFO = 0x3600, /**< Indicates the MSG_STRUCT_FOLDER_INFO */ + MSG_STRUCT_SEARCH_CONDITION = 0x3700, /**< Indicates the MSG_STRUCT_SEARCH_CONDITION */ + MSG_STRUCT_REPORT_STATUS_INFO = 0x3800, /**< Indicates the MSG_STRUCT_REPORT_STATUS_INFO */ + MSG_STRUCT_MSG_LIST_CONDITION = 0x3900, /**< Indicates the MSG_LIST_CONDITION */ + + MSG_STRUCT_ADDRESS_INFO = 0x4000, /**< Indicates the MSG_STRUCT_ADDRESS_INFO */ + MSG_STRUCT_SENDOPT = 0x4100, /**< Indicates the MSG_STRUCT_SENDOPT */ + MSG_STRUCT_MMS_SENDOPT = 0x4200, /**< Indicates the MSG_STRUCT_MMS_SENDOPT */ + MSG_STRUCT_SMS_SENDOPT = 0x4300, /**< Indicates the MSG_STRUCT_SMS_SENDOPT */ + MSG_STRUCT_REJECT_MSG_INFO = 0x4400, /**< Indicates the MSG_STRUCT_REJECT_MSG_INFO */ + MSG_STRUCT_REQUEST_INFO = 0x4500, /**< Indicates the MSG_STRUCT_REQUEST_INFO */ + MSG_STRUCT_SENT_STATUS_INFO = 0x4600, /**< Indicates the MSG_STRUCT_SENT_STATUS_INFO */ + MSG_STRUCT_PUSH_CONFIG_INFO = 0x4700, /**< Indicates the MSG_STRUCT_PUSH_CONFIG_INFO */ + MSG_STRUCT_CB_MSG = 0x4800, /**< Indicates the MSG_STRUCT_CB_MSG */ + MSG_STRUCT_MULTIPART_INFO = 0x4a00, /**< Indicates the MSG_STRUCT_MULTIPART_INFO */ + MSG_STRUCT_MEDIA_INFO = 0x5000, /**< Indicates the MSG_STRUCT_MEDIA_INFO*/ +}; + +/** + * @brief Enumeration for the values of message detail information. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_MESSAGE_INFO. + */ enum _MSG_MESSAGE_INFO_E_ { - MSG_MESSAGE_ID_INT = MSG_STRUCT_MESSAGE_INFO+1, /**< Indicates the message ID of this message. */ - MSG_MESSAGE_THREAD_ID_INT, /**< Indicates the thread ID. */ - MSG_MESSAGE_FOLDER_ID_INT, /**< Indicates the folder ID. see enum _MSG_FOLDER_TYPE_E */ - MSG_MESSAGE_TYPE_INT, /**< Indicates the message type. See enum _MSG_MESSAGE_TYPE_E */ - MSG_MESSAGE_CLASS_TYPE_INT, /**< Message class type. See enum _MSG_CLASS_TYPE_E */ - MSG_MESSAGE_STORAGE_ID_INT, /**< Indicates where the message is saved. see enum _MSG_STORAGE_ID_E*/ - MSG_MESSAGE_ADDR_LIST_STRUCT, /**< Indicates the address information list. */ - MSG_MESSAGE_REPLY_ADDR_STR, /**< Indicates the reply address. */ - MSG_MESSAGE_SUBJECT_STR, /**< Indicates the message subject. */ - MSG_MESSAGE_DISPLAY_TIME_INT, /**< Indicates the display time related to the specific operation. */ - MSG_MESSAGE_NETWORK_STATUS_INT, /**< Indicates the network status of the message. See enum _MSG_NETWORK_STATUS_E */ - MSG_MESSAGE_ENCODE_TYPE_INT, /**< Indicates the string encoding type. See enum _MSG_ENCODE_TYPE_E */ - MSG_MESSAGE_READ_BOOL, /**< Indicates whether the message is read or not. */ - MSG_MESSAGE_PROTECTED_BOOL, /**< Indicates whether the message is protected or not. */ - MSG_MESSAGE_BACKUP_BOOL, /**< Indicates whether the message was restored from PC. */ - MSG_MESSAGE_PRIORITY_INT, /**< Indicates the priority of the message. See enum _MSG_PRIORITY_TYPE_E */ - MSG_MESSAGE_DIRECTION_INT, /**< Indicates whether the message is MO or MT, affecting address. See enum _MSG_DIRECTION_TYPE_E */ - MSG_MESSAGE_PORT_VALID_BOOL, /**< Indicates whether port information is used or not. */ - MSG_MESSAGE_DEST_PORT_INT, /**< Recipient port number, not greater than 16 bit */ - MSG_MESSAGE_SRC_PORT_INT, /**< Sender port number, not greater than 16 bit */ - MSG_MESSAGE_ATTACH_COUNT_INT, /**< Indicates the count of attached files in mms. */ - MSG_MESSAGE_THUMBNAIL_PATH_STR, /**< Indicates the thumbnail path of message. */ - MSG_MESSAGE_DATA_SIZE_INT, /**< Indicates the data size. The unit is byte. */ - MSG_MESSAGE_SMS_DATA_STR, /**< Indicates the message payload information as a body. default character encoding is UTF-8*/ - MSG_MESSAGE_MMS_TEXT_STR, -}; - + MSG_MESSAGE_ID_INT = MSG_STRUCT_MESSAGE_INFO+1, /**< Indicates the message ID of this message. */ + MSG_MESSAGE_THREAD_ID_INT, /**< Indicates the thread ID. */ + MSG_MESSAGE_FOLDER_ID_INT, /**< Indicates the folder ID. See enum _MSG_FOLDER_ID_E */ + MSG_MESSAGE_TYPE_INT, /**< Indicates the message type. See enum _MSG_MESSAGE_TYPE_E */ + MSG_MESSAGE_CLASS_TYPE_INT, /**< Indicates the message class type. See enum _MSG_CLASS_TYPE_E */ + MSG_MESSAGE_STORAGE_ID_INT, /**< Indicates where the message is saved. See enum _MSG_STORAGE_ID_E*/ + MSG_MESSAGE_ADDR_LIST_STRUCT, /**< Indicates the address information list. **DEPRECATED** */ + MSG_MESSAGE_REPLY_ADDR_STR, /**< Indicates the reply address. */ + MSG_MESSAGE_SUBJECT_STR, /**< Indicates the message subject. */ + MSG_MESSAGE_DISPLAY_TIME_INT, /**< Indicates the display time related to the specific operation. */ + MSG_MESSAGE_NETWORK_STATUS_INT, /**< Indicates the network status of the message. See enum _MSG_NETWORK_STATUS_E */ + MSG_MESSAGE_ENCODE_TYPE_INT, /**< Indicates the string encoding type. See enum _MSG_ENCODE_TYPE_E */ + MSG_MESSAGE_READ_BOOL, /**< Indicates whether the message is read or not. */ + MSG_MESSAGE_PROTECTED_BOOL, /**< Indicates whether the message is protected or not. */ + MSG_MESSAGE_BACKUP_BOOL, /**< Indicates whether the message was restored from PC. */ + MSG_MESSAGE_PRIORITY_INT, /**< Indicates the priority of the message. See enum _MSG_PRIORITY_TYPE_E */ + MSG_MESSAGE_DIRECTION_INT, /**< Indicates whether the message is MO or MT, affecting address. See enum _MSG_DIRECTION_TYPE_E */ + MSG_MESSAGE_PORT_VALID_BOOL, /**< Indicates whether port information is used or not. */ + MSG_MESSAGE_DEST_PORT_INT, /**< Indicates the recipient port number, not greater than 16 bit */ + MSG_MESSAGE_SRC_PORT_INT, /**< Indicates the sender port number, not greater than 16 bit */ + MSG_MESSAGE_ATTACH_COUNT_INT, /**< Indicates the count of attached files in MMS. */ + MSG_MESSAGE_THUMBNAIL_PATH_STR, /**< Indicates the thumbnail path of message. */ + MSG_MESSAGE_DATA_SIZE_INT, /**< Indicates the data size. The unit is byte. */ + MSG_MESSAGE_SMS_DATA_STR, /**< Indicates the message payload information as a body. default character encoding is UTF-8*/ + MSG_MESSAGE_MMS_TEXT_STR, /**< Indicates the text part of MMS message payload. default character encoding is UTF-8 */ + MSG_MESSAGE_ADDR_LIST_HND, /**< Indicates the address information list. */ + MSG_MESSAGE_REPLACE_BOOL, /**< Indicates whether the message is replace or not */ + MSG_MESSAGE_SIM_INDEX_INT, /**< Indicates the sim index */ + MSG_MESSAGE_INFO_MAX, /**< Placeholder for max value of this enum*/ +}; + +/** + * @brief Enumeration for the values of message filter information. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_FILTER. + */ enum MSG_FILTER_INFO_E { - MSG_FILTER_ID_INT = MSG_STRUCT_FILTER+1, /**< Indicates the filter ID. */ - MSG_FILTER_TYPE_INT, /**< Indicates the filter type. See enum _MSG_FILTER_TYPE_E */ - MSG_FILTER_VALUE_STR, /**< The value of a filter. */ + MSG_FILTER_ID_INT = MSG_STRUCT_FILTER+1, /**< Indicates the filter ID. */ + MSG_FILTER_TYPE_INT, /**< Indicates the filter type. See enum _MSG_FILTER_TYPE_E */ + MSG_FILTER_VALUE_STR, /**< Indicates the value of the filter. */ + MSG_FILTER_ACTIVE_BOOL, /**< Indicates the activation of the filter. */ }; +/** + * @brief Enumeration for the values of thread information. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_THREAD_INFO. + */ enum MSG_STRUCT_THREAD_INFO_E { - MSG_THREAD_ID_INT = MSG_STRUCT_THREAD_INFO+1, /**< Indicates the message thread ID. */ - MSG_THREAD_NAME_STR, /**< Indicates the message thread name */ - MSG_THREAD_MSG_TYPE_INT, /**< Indicates the message type. See enum _MSG_MESSAGE_TYPE_E */ - MSG_THREAD_MSG_DATA_STR, /**< The latest message text. */ - MSG_THREAD_MSG_TIME_INT, /**< The latest message time */ - MSG_THREAD_DIRECTION_INT, /**< The latest message direction See enum _MSG_DIRECTION_TYPE_E */ - MSG_THREAD_UNREAD_COUNT_INT, /**< Indicates unread count of thread */ - MSG_THREAD_SMS_COUNT_INT, /**< Indicates sms message count of thread */ - MSG_THREAD_MMS_COUNT_INT /**< Indicates mms message count of thread */ -}; - + MSG_THREAD_ID_INT = MSG_STRUCT_THREAD_INFO+1, /**< Indicates the message thread ID. */ + MSG_THREAD_NAME_STR, /**< Indicates the message thread name */ + MSG_THREAD_MSG_TYPE_INT, /**< Indicates the message type. See enum _MSG_MESSAGE_TYPE_E */ + MSG_THREAD_MSG_DATA_STR, /**< The latest message text. */ + MSG_THREAD_MSG_TIME_INT, /**< The latest message time */ + MSG_THREAD_DIRECTION_INT, /**< The latest message direction See enum _MSG_DIRECTION_TYPE_E */ + MSG_THREAD_UNREAD_COUNT_INT, /**< Indicates unread count of thread */ + MSG_THREAD_SMS_COUNT_INT, /**< Indicates SMS message count of thread */ + MSG_THREAD_MMS_COUNT_INT, /**< Indicates MMS message count of thread */ + MSG_THREAD_PROTECTED_BOOL, /**< Indicates whether thread includes protected message. */ + MSG_THREAD_DRAFT_BOOL, /**< Indicates whether thread includes draft message. */ + MSG_THREAD_SEND_FAILED_BOOL, /**< Indicates whether thread includes send failed message. */ + MSG_THREAD_SENDING_BOOL, /**< Indicates whether thread includes sending message. */ + + MSG_THREAD_INFO_MAX /**< Placeholder for max value of this enum */ +}; + +/** + * @brief Enumeration for the values of conversation information. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_CONV_INFO. + */ +enum MSG_STRUCT_CONV_INFO_E { + MSG_CONV_MSG_ID_INT = MSG_STRUCT_CONV_INFO+1, /**< Indicates the message ID of this message. */ + MSG_CONV_MSG_THREAD_ID_INT, /**< Indicates the thread ID. */ + MSG_CONV_MSG_TYPE_INT, /**< Indicates the message type. See enum _MSG_MESSAGE_TYPE_E */ + MSG_CONV_MSG_FOLDER_ID_INT, /**< Indicates the folder ID. See enum _MSG_FOLDER_TYPE_E */ + MSG_CONV_MSG_STORAGE_ID_INT, /**< Indicates where the message is saved. See enum _MSG_STORAGE_ID_E*/ + MSG_CONV_MSG_SUBJECT_STR, /**< Indicates the message subject. */ + MSG_CONV_MSG_DISPLAY_TIME_INT, /**< Indicates the display time related to the specific operation. */ + MSG_CONV_MSG_SCHEDULED_TIME_INT, /**< Indicates the time to send scheduled message. */ + MSG_CONV_MSG_NETWORK_STATUS_INT, /**< Indicates the network status of the message. See enum _MSG_NETWORK_STATUS_E */ + MSG_CONV_MSG_READ_BOOL, /**< Indicates whether the message is read or not. */ + MSG_CONV_MSG_PROTECTED_BOOL, /**< Indicates whether the message is protected or not. */ + MSG_CONV_MSG_DIRECTION_INT, /**< Indicates whether the message is MO or MT, affecting address. See enum _MSG_DIRECTION_TYPE_E */ + MSG_CONV_MSG_PAGE_COUNT_INT, /**< Indicates the count of pages in MMS. */ + MSG_CONV_MSG_ATTACH_COUNT_INT, /**< Indicates the count of attached files in MMS. */ + MSG_CONV_MSG_ATTACH_NAME_STR, /**< Indicates the attached file name of message. */ + MSG_CONV_MSG_AUDIO_NAME_STR, /**< Indicates the audio file name of message. */ + MSG_CONV_MSG_IMAGE_THUMB_PATH_STR, /**< Indicates the image thumbnail path of message. */ + MSG_CONV_MSG_VIDEO_THUMB_PATH_STR, /**< Indicates the video thumbnail path of message. */ + MSG_CONV_MSG_TEXT_SIZE_INT, /**< Indicates the data size. The unit is byte. */ + MSG_CONV_MSG_TEXT_STR, /**< Indicates the message payload information as a body. default character encoding is UTF-8*/ + MSG_CONV_MSG_TCS_BC_LEVEL_INT, /**< Indicates the Behavior Level of malware. @c -1 is None*/ + MSG_CONV_MSG_1ST_MEDIA_PATH_STR, /**< Indicates the First Media path of MMS */ + MSG_CONV_MSG_MULTIPART_HND, + MSG_CONV_MSG_SIM_INDEX_INT, /**< Indicates the sim index */ + + MSG_CONV_INFO_MAX /**< Placeholder for max value of this enum */ +}; + +/** + * @brief Enumeration for the values of setting for SMSC options. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_SMSC_OPT. + */ enum _MSG_STRUCT_SETTING_SMSC_OPT_E { - MSG_SMSC_SELECTED_ID_INT = MSG_STRUCT_SETTING_SMSC_OPT+1, - MSG_SMSC_LIST_STRUCT + MSG_SMSC_SELECTED_ID_INT = MSG_STRUCT_SETTING_SMSC_OPT+1, /**< Indicates Selected SMSC index option */ + MSG_SMSC_LIST_STRUCT, /**< Indicates SMSC data information list option*/ + MSG_SMSC_LIST_INDEX_INT, /**< Indicates SMSC index option for Updating information */ + MSG_SMSC_LIST_SIM_INDEX_INT /**< Indicates the sim index */ }; +/** + * @brief Enumeration for the values of setting for SMSC informations. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_SMSC_INFO. + */ enum _MSG_STRUCT_SETTING_SMSC_INFO_E { - MSG_SMSC_ADDR_TON_INT = MSG_STRUCT_SETTING_SMSC_INFO+1, /**< Type of number. See enum _MSG_SMS_TON_E */ - MSG_SMSC_ADDR_NPI_INT, /**< Numbering plan ID. See enum _MSG_SMS_NPI_E */ - MSG_SMSC_ADDR_STR, /**< SMSC address */ - MSG_SMSC_NAME_STR, /**< SMSC name */ - MSG_SMSC_PID_INT, /**< Protocol idendifier See enum _MSG_SMS_PID_E */ - MSG_SMSC_VAL_PERIOD_INT /**< Validity period value. See enum _MSG_VAL_PERIOD_E*/ + MSG_SMSC_ADDR_TON_INT = MSG_STRUCT_SETTING_SMSC_INFO+1, /**< Type of number. See enum _MSG_SMS_TON_E */ + MSG_SMSC_ADDR_NPI_INT, /**< Numbering plan ID. See enum _MSG_SMS_NPI_E */ + MSG_SMSC_ADDR_STR, /**< SMSC address */ + MSG_SMSC_NAME_STR, /**< SMSC name */ + MSG_SMSC_PID_INT, /**< Protocol idendifier See enum _MSG_SMS_PID_E */ + MSG_SMSC_VAL_PERIOD_INT /**< Validity period value. See enum _MSG_VAL_PERIOD_E*/ }; +/** + * @brief Enumeration for the values of setting for CB channel options. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_CB_OPT. + */ enum _MSG_STRUCT_CB_OPT_E { - MSG_CB_RECEIVE_BOOL = MSG_STRUCT_SETTING_CB_OPT+1, /**< Indicates whether the CB message is received or not. */ - MSG_CB_RECEIVE_ALL_CHANNEL_BOOL, /**< Indicates whether All Channel's CB message is received or not. */ - MSG_CB_MAX_SIM_COUNT_INT, /**< Indicates the number of channels which can be stored in SIM. */ - MSG_CB_CHANNEL_LIST_STRUCT, /**< Indicates the cell broadcasting channel information. */ - MSG_CB_LANGUAGE_TYPE_ALL_BOOL, - MSG_CB_LANGUAGE_TYPE_ENG_BOOL, /**< CB message English */ - MSG_CB_LANGUAGE_TYPE_GER_BOOL, /**< CB message Germany */ - MSG_CB_LANGUAGE_TYPE_FRE_BOOL, /**< CB message France */ - MSG_CB_LANGUAGE_TYPE_ITA_BOOL, /**< CB message Italy */ - MSG_CB_LANGUAGE_TYPE_NED_BOOL, /**< CB message Netherland */ - MSG_CB_LANGUAGE_TYPE_SPA_BOOL, /**< CB message Spain */ - MSG_CB_LANGUAGE_TYPE_POR_BOOL, /**< CB message Portugal */ - MSG_CB_LANGUAGE_TYPE_SWE_BOOL, /**< CB message Sweden */ - MSG_CB_LANGUAGE_TYPE_TUR_BOOL, /**< CB message Turkey */ -}; - + MSG_CB_RECEIVE_BOOL = MSG_STRUCT_SETTING_CB_OPT+1, /**< Indicates whether the CB message is received or not. */ + MSG_CB_MAX_SIM_COUNT_INT, /**< Indicates the number of channels which can be stored in SIM. */ + MSG_CB_CHANNEL_LIST_STRUCT, /**< Indicates the cell broadcasting channel information. */ + MSG_CB_LANGUAGE_TYPE_ALL_BOOL, /**< CB message all languages */ + MSG_CB_LANGUAGE_TYPE_ENG_BOOL, /**< CB message English */ + MSG_CB_LANGUAGE_TYPE_GER_BOOL, /**< CB message Germany */ + MSG_CB_LANGUAGE_TYPE_FRE_BOOL, /**< CB message France */ + MSG_CB_LANGUAGE_TYPE_ITA_BOOL, /**< CB message Italy */ + MSG_CB_LANGUAGE_TYPE_NED_BOOL, /**< CB message Netherland */ + MSG_CB_LANGUAGE_TYPE_SPA_BOOL, /**< CB message Spain */ + MSG_CB_LANGUAGE_TYPE_POR_BOOL, /**< CB message Portugal */ + MSG_CB_LANGUAGE_TYPE_SWE_BOOL, /**< CB message Sweden */ + MSG_CB_LANGUAGE_TYPE_TUR_BOOL, /**< CB message Turkey */ + MSG_CB_SIM_INDEX_INT, /**< Indicates the sim index */ +}; + +/** + * @brief Enumeration for the values of setting for CB channel informations. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_CB_CHANNEL_INFO. + */ enum _MSG_STRUCT_CB_CHANNEL_INFO_E { - MSG_CB_CHANNEL_ACTIVATE_BOOL = MSG_STRUCT_SETTING_CB_CHANNEL_INFO+1, /**< Indicates whether the CB channel is activate or passive. */ - MSG_CB_CHANNEL_ID_FROM_INT, /**< Indicates the ID of a CB channel. */ - MSG_CB_CHANNEL_ID_TO_INT, /**< Indicates the ID of a CB channel. */ - MSG_CB_CHANNEL_NAME_STR /**< Indicates the name of a CB channel. */ + MSG_CB_CHANNEL_ACTIVATE_BOOL = MSG_STRUCT_SETTING_CB_CHANNEL_INFO+1, /**< Indicates whether the CB channel is activate or passive. */ + MSG_CB_CHANNEL_ID_FROM_INT, /**< Indicates the From ID of a CB channel. */ + MSG_CB_CHANNEL_ID_TO_INT, /**< Indicates the To ID of a CB channel. */ + MSG_CB_CHANNEL_NAME_STR /**< Indicates the name of a CB channel. */ }; +/** + * @brief Enumeration for the values of setting for SMS sending options. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_SMS_SEND_OPT. + */ enum _MSG_STRUCT_SMS_SEND_OPT_E { - MSG_SMS_SENDOPT_ENCODE_TYPE_INT = MSG_STRUCT_SETTING_SMS_SEND_OPT+1, /**< Indicates the string encoding type. See enum _MSG_ENCODE_TYPE_E*/ - MSG_SMS_SENDOPT_NETWORK_MODE_INT, /**< Indicates the network mode (CS/PS) to send SMS. See enum _MSG_SMS_NETWORK_MODE_E*/ - MSG_SMS_SENDOPT_REPLY_PATH_BOOL, /**< Indicates whether the SMS reply path is set or not. */ - MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, /**< Indicates whether the SMS delivery report will be sent or not. */ - MSG_SMS_SENDOPT_SAVE_STORAGE_INT /**< Indicates the default storage to save SMS. See enum _MSG_SMS_SAVE_STORAGE_E */ + MSG_SMS_SENDOPT_ENCODE_TYPE_INT = MSG_STRUCT_SETTING_SMS_SEND_OPT+1, /**< Indicates the string encoding type. See enum _MSG_ENCODE_TYPE_E*/ + MSG_SMS_SENDOPT_NETWORK_MODE_INT, /**< Indicates the network mode (CS/PS) to send SMS. See enum _MSG_SMS_NETWORK_MODE_E*/ + MSG_SMS_SENDOPT_REPLY_PATH_BOOL, /**< Indicates whether the SMS reply path is set or not. */ + MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, /**< Indicates whether the SMS delivery report will be sent or not. */ + MSG_SMS_SENDOPT_SAVE_STORAGE_INT /**< Indicates the default storage to save SMS. See enum _MSG_SMS_SAVE_STORAGE_E */ }; +/** + * @brief Enumeration for the values of setting for MMS sending options. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_MMS_SEND_OPT. + */ enum _MSG_STRUCT_MMS_SEND_OPT_E { - MSG_MMS_SENDOPT_CLASS_TYPE_INT = MSG_STRUCT_SETTING_MMS_SEND_OPT+1, /**< Indicates the class type of message. See enum _MSG_MMS_MSG_CLASS_TYPE_E */ - MSG_MMS_SENDOPT_PRIORITY_TYPE_INT, /**< Indicates the priority of the message. See enum _MSG_PRIORITY_TYPE_E */ - MSG_MMS_SENDOPT_EXPIRY_TIME_INT, /**< Indicates the time when the message is to be removed from the MMSC. See enum _MSG_MMS_EXPIRY_TIME_E */ - MSG_MMS_SENDOPT_DELIVERY_TIME_INT, /**< Indicates the message transmission time which is set in the MMSC. See enum _MSG_MMS_DELIVERY_TIME_E */ - MSG_MMS_SENDOPT_CUSTOM_DELIVERY_TIME_INT, /**< Indicates the message transmission time which is set in the MMSC. */ - MSG_MMS_SENDOPT_SENDER_VISIBILITY_BOOL, /**< Indicates whether the address is hidden or not. */ - MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, /**< Indicates whether the delivery report will be sent or not. */ - MSG_MMS_SENDOPT_READ_REPLY_BOOL, /**< Indicates whether the read report will be sent or not. */ - MSG_MMS_SENDOPT_KEEP_COPY_BOOL, /**< Indicates whether the message copy is kept or not. */ - MSG_MMS_SENDOPT_BODY_REPLYING_BOOL, /**< Indicates whether the body is included when replying or not. */ - MSG_MMS_SENDOPT_HIDE_RECIPIENTS_BOOL, /**< Indicates whether the recipients are hidden or not. */ - MSG_MMS_SENDOPT_REPLY_CHARGING_INT, /**< Indicates the reply charging type of message. See enum _MSG_MMS_REPLY_CHARGING_TYPE_E */ - MSG_MMS_SENDOPT_REPLY_CHARGING_DEADLINE_INT, /**< Indicates the deadline for replying charging. is set in the MMSC. */ - MSG_MMS_SENDOPT_REPLY_CHARGING_SIZE_INT, /**< Indicates the reply charging size. */ - MSG_MMS_SENDOPT_CREATION_MODE_INT /**< Indicates the creation mode of MMS. See enum _MSG_MMS_CREATION_MODE_E */ -}; - + MSG_MMS_SENDOPT_CLASS_TYPE_INT = MSG_STRUCT_SETTING_MMS_SEND_OPT+1, /**< Indicates the class type of message. See enum _MSG_MMS_MSG_CLASS_TYPE_E */ + MSG_MMS_SENDOPT_PRIORITY_TYPE_INT, /**< Indicates the priority of the message. See enum _MSG_PRIORITY_TYPE_E */ + MSG_MMS_SENDOPT_EXPIRY_TIME_INT, /**< Indicates the time when the message is to be removed from the MMSC. See enum _MSG_MMS_EXPIRY_TIME_E */ + MSG_MMS_SENDOPT_DELIVERY_TIME_INT, /**< Indicates the message transmission time which is set in the MMSC. See enum _MSG_MMS_DELIVERY_TIME_E */ + MSG_MMS_SENDOPT_CUSTOM_DELIVERY_TIME_INT, /**< Indicates the message transmission time which is set in the MMSC. */ + MSG_MMS_SENDOPT_SENDER_VISIBILITY_BOOL, /**< Indicates whether the address is hidden or not. */ + MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, /**< Indicates whether the delivery report will be sent or not. */ + MSG_MMS_SENDOPT_READ_REPLY_BOOL, /**< Indicates whether the read report will be sent or not. */ + MSG_MMS_SENDOPT_KEEP_COPY_BOOL, /**< Indicates whether the message copy is kept or not. */ + MSG_MMS_SENDOPT_BODY_REPLYING_BOOL, /**< Indicates whether the body is included when replying or not. */ + MSG_MMS_SENDOPT_HIDE_RECIPIENTS_BOOL, /**< Indicates whether the recipients are hidden or not. */ + MSG_MMS_SENDOPT_REPLY_CHARGING_INT, /**< Indicates the reply charging type of message. See enum _MSG_MMS_REPLY_CHARGING_TYPE_E */ + MSG_MMS_SENDOPT_REPLY_CHARGING_DEADLINE_INT, /**< Indicates the deadline for replying charging. is set in the MMSC. */ + MSG_MMS_SENDOPT_REPLY_CHARGING_SIZE_INT, /**< Indicates the reply charging size. */ + MSG_MMS_SENDOPT_CREATION_MODE_INT /**< Indicates the creation mode of MMS. See enum _MSG_MMS_CREATION_MODE_E */ +}; + +/** + * @brief Enumeration for the values of setting for MMS receiving options. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_MMS_RECV_OPT. + */ enum _MSG_STRUCT_MMS_RECV_OPT_E { - MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT = MSG_STRUCT_SETTING_MMS_RECV_OPT+1, /**< Indicates the retrieve type for MMS home network. See enum _MSG_MMS_HOME_RETRIEVE_TYPE_E */ - MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, /**< Indicates the retrieve type for MMS abroad network. See enum _MSG_MMS_ABROAD_RETRIEVE_TYPE_E */ - MSG_MMS_RECVOPT_READ_REPORT_BOOL, /**< Indicates whether the read report will be sent or not. */ - MSG_MMS_RECVOPT_DELIVERY_REPORT_BOOL, /**< Indicates whether the delivery report will be sent or not. */ - MSG_MMS_RECVOPT_REJECT_UNKNOWN_BOOL, /**< Indicates whether unknown addresses are rejected or not. */ - MSG_MMS_RECVOPT_REJECT_ADVERTISEMENT_BOOL /**< Indicates whether advertisement is rejected or not. */ + MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT = MSG_STRUCT_SETTING_MMS_RECV_OPT+1, /**< Indicates the retrieve type for MMS home network. See enum _MSG_MMS_HOME_RETRIEVE_TYPE_E */ + MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, /**< Indicates the retrieve type for MMS abroad network. See enum _MSG_MMS_ABROAD_RETRIEVE_TYPE_E */ + MSG_MMS_RECVOPT_READ_REPORT_BOOL, /**< Indicates whether the read report will be sent or not. */ + MSG_MMS_RECVOPT_DELIVERY_REPORT_BOOL, /**< Indicates whether the delivery report will be sent or not. */ + MSG_MMS_RECVOPT_REJECT_UNKNOWN_BOOL, /**< Indicates whether unknown addresses are rejected or not. */ + MSG_MMS_RECVOPT_REJECT_ADVERTISEMENT_BOOL /**< Indicates whether advertisement is rejected or not. */ }; +/** + * @brief Enumeration for the values of setting for general options. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_GENERAL_OPT. + */ enum _MSG_STRUCT_GENERAL_OPT_E { - MSG_GENERAL_KEEP_COPY_BOOL = MSG_STRUCT_SETTING_GENERAL_OPT+1, /**< Indicates whether the SMS message copy is kept or not. */ - MSG_GENERAL_ALERT_TONE_INT, /**< Indicates the period of playing alert tone. See enum _MSG_ALERT_TONE_E */ - MSG_GENERAL_AUTO_ERASE_BOOL /**< Indicates whether the auto-erase option is enabled or not. */ + MSG_GENERAL_KEEP_COPY_BOOL = MSG_STRUCT_SETTING_GENERAL_OPT+1, /**< Indicates whether the SMS message copy is kept or not. */ + MSG_GENERAL_ALERT_TONE_INT, /**< Indicates the period of playing alert tone. See enum _MSG_ALERT_TONE_E */ + MSG_GENERAL_AUTO_ERASE_BOOL, /**< Indicates whether the auto-erase option is enabled or not. */ + MSG_GENERAL_BLOCK_UNKNOWN_NUMBER_BOOL, /**< Indicates whether unknown sender message is blocked or not. */ + MSG_GENERAL_SMS_LIMIT_CNT_INT, /**< Indicates the count limitation of SMS messages in one conversation */ + MSG_GENERAL_MMS_LIMIT_CNT_INT, /**< Indicates the count limitation of MMS messages in one conversation */ + MSG_GENERAL_MSG_NOTIFICATION_BOOL, /**< Indicates whether notification for incoming message is shown or not. */ + MSG_GENERAL_MSG_VIBRATION_BOOL, /**< Indicates whether vibration for incoming message is run or not. */ + MSG_GENERAL_MSG_PREVIEW_BOOL, /**< Indicates whether preview for incoming message is shown or not. */ + MSG_GENERAL_RINGTONE_TYPE_INT, /**< Indicates the message ringtone type. */ + MSG_GENERAL_RINGTONE_PATH_STR /**< Indicates the message ringtone path */ }; +/** + * @brief Enumeration for the values of setting for push message options. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_PUSH_MSG_OPT. + */ enum _MSG_STRUCT_PUSH_MSG_OPT_E { - MSG_PUSHMSG_RECEIVE_BOOL = MSG_STRUCT_SETTING_PUSH_MSG_OPT+1, /**< Indicates whether the push message is received or not. */ - MSG_PUSHMSG_SERVICE_TYPE_INT /**< Indicates the service type of a push message. See enum _MSG_PUSH_SERVICE_TYPE_E */ + MSG_PUSHMSG_RECEIVE_BOOL = MSG_STRUCT_SETTING_PUSH_MSG_OPT+1, /**< Indicates whether the push message is received or not. */ + MSG_PUSHMSG_SERVICE_TYPE_INT /**< Indicates the service type of a push message. See enum _MSG_PUSH_SERVICE_TYPE_E */ }; +/** + * @brief Enumeration for the values of setting for voice message options. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_VOICE_MSG_OPT. + */ enum _MSG_STRUCT_VOICE_MSG_OPT_E { - MSG_VOICEMSG_ADDRESS_STR = MSG_STRUCT_SETTING_VOICE_MSG_OPT+1, /**< Indicates the address for voice message. */ + MSG_VOICEMSG_ADDRESS_STR = MSG_STRUCT_SETTING_VOICE_MSG_OPT+1, /**< Indicates the address for voice message. */ + MSG_VOICEMSG_ALPHA_ID_STR, /**< Indicates the alpha id for voice message address. */ + MSG_VOICEMSG_SIM_INDEX_INT, /**< Indicates the SIM index for voice message. */ + MSG_VOICEMSG_VOICE_COUNT_INT, /**< Indicates the count of voice messages. */ }; + +/** + * @brief Enumeration for the values of setting for message size option. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_SETTING_MSGSIZE_OPT. + */ enum _MSG_STRUCT_MSGSISE_OPT_E { - MSG_MESSAGE_SIZE_INT = MSG_STRUCT_SETTING_MSGSIZE_OPT+1, /**< Indicates the message size */ + MSG_MESSAGE_SIZE_INT = MSG_STRUCT_SETTING_MSGSIZE_OPT+1, /**< Indicates the message size */ }; -//MSG_MMS_DATA +/** + * @brief Enumeration for the values of MMS detail informations. \n + * This enum is used as member of #msg_struct_t for MSG_STRUCT_MMS. + */ enum MSG_MMS_INFO_E { - MSG_MMS_PAGE_LIST_HND = MSG_STRUCT_MMS+1, /**< The pointer to SMIL pages list */ - MSG_MMS_REGION_LIST_HND, /**< The pointer to SMIL regions list */ - MSG_MMS_ATTACH_LIST_HND, /**< The pointer to attachment list */ - MSG_MMS_TRANSITION_LIST_HND, /**< The pointer to SMIL transitions list */ - MSG_MMS_META_LIST_HND, /**< The pointer to SMIL meta list */ - MSG_MMS_ROOTLAYOUT_WIDTH_INT, /**< Indicates the width of the root layout */ - MSG_MMS_ROOTLAYOUT_WIDTH_PERCENT_BOOL, /**< Indicates the length is in percentage(%) or not */ - MSG_MMS_ROOTLAYOUT_HEIGHT_INT, /**< Indicates the height of the root layout */ - MSG_MMS_ROOTLAYOUT_HEIGHT_PERCENT_BOOL, /**< Indicates the length is in percentage(%) or not */ - MSG_MMS_ROOTLAYOUT_BGCOLOR_INT, /**< Indicates the background color of the root layout */ -}; - -//MSG_MMS_PAGE + MSG_MMS_PAGE_LIST_HND = MSG_STRUCT_MMS+1, /**< The pointer to SMIL pages list */ + MSG_MMS_REGION_LIST_HND, /**< The pointer to SMIL regions list */ + MSG_MMS_ATTACH_LIST_HND, /**< The pointer to attachment list */ + MSG_MMS_TRANSITION_LIST_HND, /**< The pointer to SMIL transitions list */ + MSG_MMS_META_LIST_HND, /**< The pointer to SMIL meta list */ + MSG_MMS_ROOTLAYOUT_WIDTH_INT, /**< Indicates the width of the root layout */ + MSG_MMS_ROOTLAYOUT_WIDTH_PERCENT_BOOL, /**< Indicates the length is in percentage(%) or not */ + MSG_MMS_ROOTLAYOUT_HEIGHT_INT, /**< Indicates the height of the root layout */ + MSG_MMS_ROOTLAYOUT_HEIGHT_PERCENT_BOOL, /**< Indicates the length is in percentage(%) or not */ + MSG_MMS_ROOTLAYOUT_BGCOLOR_INT, /**< Indicates the background color of the root layout */ + MSG_MMS_ROOTLAYOUT_BGCOLOR_BOOL, /**< Indicates the background color is set in the root layout */ + MSG_MMS_HEADER_BCC_ADDRESS_LIST_HND, /**< The pointer to BCC address list */ + MSG_MMS_HEADER_CC_ADDRESS_LIST_HND, /**< The pointer to CC address list */ + MSG_MMS_HEADER_CONTENT_LOCATION_STR, /**< Indicates contentLocation in MMS header */ + MSG_MMS_HEADER_CONTENT_TYPE_STR, /**< Indicates szContentType in MMS header. ex) application/vnd.wap.multipart.related */ + MSG_MMS_HEADER_DATE_INT, /**< Indicates date in MMS header */ + MSG_MMS_HEADER_DELIVERY_REPORT_INT, /**< Indicates X-Mms-Delivery-Report */ + MSG_MMS_HEADER_DELIVERY_TIME_INT, /**< Indicates X-Mms-Delivery-Time */ + MSG_MMS_HEADER_EXPIRY_TIME_INT, /**< Indicates X-Mms-Expiry-Time */ + MSG_MMS_HEADER_FROM_STR, /**< Indicates FROM address in header */ + MSG_MMS_HEADER_MESSAGE_CLASS_INT, /**< Indicates messageClassin in header. ex) Personal | Advertisement | Informational | Auto */ + MSG_MMS_HEADER_MESSAGE_ID_STR, /**< Indicates messageID in header*/ + MSG_MMS_HEADER_MESSAGE_TYPE_INT, /**< Indicates MmsMsgTypein header. ex) sendreq */ + MSG_MMS_HEADER_VERSION_INT, /**< Indicates mmsVersion in header. ex) 1.0 1.3 etc */ + MSG_MMS_HEADER_SIZE_INT, /**< Indicates X-Mms-Message-Size */ + MSG_MMS_HEADER_PRIORITY_INT, /**< Indicates _MSG_PRIORITY_TYPE_E in header: Low | Normal | High */ + MSG_MMS_HEADER_READ_REPORT_INT, /**< Indicates X-Mms-Read-Report */ + MSG_MMS_HEADER_HIDE_ADDRESS_INT, /**< Indicates X-Mms-Sender-Visibility */ + MSG_MMS_HEADER_MMS_STATUS_INT, /**< Indicates X-Mms-Status */ + MSG_MMS_HEADER_TO_ADDRESS_LIST_HND, /**< The pointer to 'TO' address list in header*/ + MSG_MMS_HEADER_TR_ID_STR, /**< Indicates thread ID in header */ + MSG_MMS_HEADER_CONTENT_CLASS_INT, /**< Indicates contentClass in header. ex) text | image-basic| image-rich | video-basic | video-rich | megapixel | content-basic | content-rich */ + MSG_MMS_SMIL_MULTIPART_CONTENT_TYPE_STR, /**< Indicates multipart content type in header*/ + MSG_MMS_SMIL_MULTIPART_NAME_STR, /** +#include #include #include @@ -60,6 +60,22 @@ typedef struct typedef struct { MsgHandle* hAddr; + msg_push_msg_incoming_cb pfPushIncomingCB; + char appId[MAX_WAPPUSH_ID_LEN+1]; + void* userParam; +} MSG_PUSH_INCOMING_CB_ITEM_S; + +typedef struct +{ + MsgHandle* hAddr; + msg_cb_incoming_cb pfCBIncomingCB; + bool bsave; + void* userParam; +} MSG_CB_INCOMING_CB_ITEM_S; + +typedef struct +{ + MsgHandle* hAddr; msg_syncml_msg_incoming_cb pfSyncMLIncomingCB; void* userParam; } MSG_SYNCML_INCOMING_CB_ITEM_S; @@ -86,14 +102,25 @@ typedef struct } MSG_STORAGE_CHANGE_CB_ITEM_S; +typedef struct +{ + MsgHandle* hAddr; + msg_report_msg_incoming_cb pfReportMsgIncomingCB; + void* userParam; +} MSG_REPORT_INCOMING_CB_ITEM_S; + + typedef std::list MsgSentStatusCBList; typedef std::list MsgNewMessageCBList; typedef std::list MsgNewMMSConfMessageCBList; +typedef std::list MsgNewPushMessageCBList; +typedef std::list MsgNewCBMessageCBList; typedef std::list MsgNewSyncMLMessageCBList; typedef std::list MsgNewLBSMessageCBList; typedef std::list MsgOperationSyncMLMessageCBList; typedef std::list MsgStorageChangeCBList; - +typedef std::list MsgReportMessageCBList; +typedef std::set handle_set; /*================================================================================================== CLASS DEFINITIONS @@ -103,23 +130,30 @@ class MsgProxyListener public: static MsgProxyListener* instance(); - void start(); + void start(MsgHandle* pMsgHandle); void stop(); bool regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_status_cb pfSentStatus, void *pUserParam); bool regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam); bool regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam); + bool regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_push_msg_incoming_cb pfNewPushMessage, const char *pAppId, void *pUserParam); + bool regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_cb_incoming_cb pfNewCBMessage, bool bSave, void *pUserParam); bool regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam); bool regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam); bool regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam); bool regStorageChangeEventCB(MsgHandle* pMsgHandle, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam); + bool regReportMsgIncomingCB(MsgHandle* pMsgHandle, msg_report_msg_incoming_cb pfReportMessage, void *pUserParam); void clearListOfClosedHandle(MsgHandle* pMsgHandle); void handleEvent(const MSG_EVENT_S* ptr); int getRemoteFd(); - int readFromSocket(char** buf, int* len); + int readFromSocket(char** buf, unsigned int* len); + void resetProxyListener(); +#ifdef CHECK_SENT_STATUS_CALLBACK + int getSentStatusCbCnt(); +#endif private: MsgProxyListener(); @@ -129,6 +163,8 @@ private: unsigned int running; + handle_set openHandleSet; + MsgIpcClientSocket cliSock; Mutex mx; @@ -137,10 +173,13 @@ private: MsgSentStatusCBList sentStatusCBList; MsgNewMessageCBList newMessageCBList; MsgNewMMSConfMessageCBList newMMSConfMessageCBList; + MsgNewPushMessageCBList newPushMessageCBList; + MsgNewCBMessageCBList newCBMessageCBList; MsgNewSyncMLMessageCBList newSyncMLMessageCBList; MsgNewLBSMessageCBList newLBSMessageCBList; MsgOperationSyncMLMessageCBList operationSyncMLMessageCBList; MsgStorageChangeCBList storageChangeCBList; + MsgReportMessageCBList reportMessageCBList; GIOChannel *channel; guint eventSourceId; diff --git a/include/utils/MsgContact.h b/include/utils/MsgContact.h index 49c7a0b..e12e1fb 100755 --- a/include/utils/MsgContact.h +++ b/include/utils/MsgContact.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_CONTACT_H @@ -35,7 +35,9 @@ msg_error_t MsgCloseContactSvc(); msg_error_t MsgInitContactSvc(MsgContactChangeCB cb); msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_INFO_S *pContactInfo); +msg_error_t MsgGetContactSearchList(const char *pSearchVal, MSG_ADDRESS_INFO_S **pAddrInfo, int *count); +void MsgSyncAddressbook(); void MsgSyncContact(); bool MsgInsertContact(MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber); @@ -43,13 +45,18 @@ bool MsgUpdateContact(int index, int type); bool MsgDeleteContact(int index); int MsgGetContactNameOrder(); +msg_error_t MsgGetContactStyleDisplayName(const char *first, const char *last, const char *middle, const char *prefix, const char *suffix, int contactNameOrder, char *displayName, unsigned int size); -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); +bool checkBlockingMode(char *address, bool *pisFavorites); +int MsgContactGetMinMatchDigit(); +void MsgConvertNumber(const char* pSrcNum, char* pDestNum, int destSize); +bool MsgIsNumber(const char* pSrc); #endif //MSG_CONTACT_H diff --git a/include/utils/MsgDebug.h b/include/utils/MsgDebug.h index 952805c..8cb07d5 100755 --- a/include/utils/MsgDebug.h +++ b/include/utils/MsgDebug.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef __MSG_DEBUG_H__ @@ -25,64 +25,144 @@ #include #include #include +#include -#include "MsgTypes.h" #include "MsgCmdTypes.h" -#include "MsgFilterTypes.h" - -extern "C"{ - #include -}; - /*================================================================================================== DEFINES ==================================================================================================*/ #define USER_TAG "MSG_FW" +#undef LOG_TAG +#define LOG_TAG "MSG_SERVICE" +#define MSG_SMS_VALID_TAG "VLD_SMS" +#define MSG_MMS_VALID_TAG "VLD_MMS" #define DLOG_ENABLE -//#define LOG_ENABLE +#if defined(DLOG_ENABLE) -/*================================================================================================== - FUNCTION PROTOTYPES -==================================================================================================*/ -int get_tid(); +/*log macros*/ +#define MSG_BEGIN()\ + do\ + {\ + SLOGD(" BEGIN >>>> \n");\ + } while(0) +#define MSG_END()\ + do\ + {\ + SLOGD(" END <<<< \n");\ + } while(0) -#if defined(DLOG_ENABLE) +#define MSG_DEBUG(fmt, ...)\ + do\ + {\ + SLOGD(fmt"\n", ##__VA_ARGS__);\ + } while(0) -#define MSG_FATAL(fmt, ...) \ - do \ +#define MSG_INFO(fmt, ...)\ + do\ {\ - SLOG(LOG_ERROR, USER_TAG, "[%s: %s(): %d] ERROR << " fmt " >>\n\n", rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\ + SLOGI("* Info * " fmt "\n", ##__VA_ARGS__);\ + } while(0) + +#define MSG_WARN(fmt, ...)\ + do\ + {\ + SLOGW("* Warning * " fmt "\n", ##__VA_ARGS__);\ + } while(0) + +#define MSG_ERR(fmt, ...)\ + do\ + {\ + SLOGE("* Error * " fmt "\n", ##__VA_ARGS__);\ + } while(0) + +#define MSG_FATAL(fmt, ...)\ + do\ + {\ + SLOGE(" ERROR << " fmt " >>\n", ##__VA_ARGS__);\ + } while(0) + +/*secure log macros*/ +#define MSG_SEC_DEBUG(fmt, ...)\ + do\ + {\ + SECURE_SLOGD(fmt"\n", ##__VA_ARGS__);\ } while (0) -#define MSG_DEBUG(fmt, ...)\ +#define MSG_SEC_INFO(fmt, ...)\ do\ {\ - SLOG(LOG_DEBUG, USER_TAG, "[%s: %s(): %d] " fmt"\n\n", rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\ + SECURE_SLOGI("* Info * " fmt"\n", ##__VA_ARGS__);\ } while (0) -#define MSG_BEGIN() \ +/*valid data log macros*/ +#define MSG_SMS_VLD_INFO(fmt, ...)\ do\ - {\ - SLOG(LOG_DEBUG, USER_TAG, "[%s: %s(): %d] BEGIN >>>> \n\n", rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__ );\ - } while( 0 ) + {\ + SLOG(LOG_DEBUG, MSG_SMS_VALID_TAG, "[SMS INFO]%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\ + } while (0) -#define MSG_END() \ +#define MSG_SMS_VLD_TXT(fmt, ...)\ do\ - {\ - SLOG(LOG_DEBUG, USER_TAG, "[%s: %s(): %d] END <<<< \n\n", rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__ );\ - } \ - while( 0 ) + {\ + 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) + +/*err & warn return message log macros*/ +#define MSG_ERR_RET_VM(expr, val, fmt, ...)\ + do\ + {\ + if (expr) {\ + MSG_ERR(fmt, ##__VA_ARGS__);\ + return (val);\ + }\ + } while(0) + +#define MSG_ERR_RET_M(expr, fmt, ...)\ + do\ + {\ + if (expr) {\ + MSG_ERR(fmt, ##__VA_ARGS__);\ + return;\ + }\ + } while(0) + +#define MSG_WARN_M(expr, fmt, ...)\ + do\ + {\ + if (expr) {\ + MSG_WARN(fmt, ##__VA_ARGS__);\ + }\ + } while(0) + +/*profile log macros*/ #define MSG_PROFILE_BEGIN(pfid) \ - unsigned int __prf_l1_##pfid = __LINE__; \ - struct timeval __prf_1_##pfid; \ - struct timeval __prf_2_##pfid; \ - do { \ - gettimeofday(&__prf_1_##pfid, 0); \ + unsigned int __prf_l1_##pfid = __LINE__;\ + struct timeval __prf_1_##pfid;\ + struct timeval __prf_2_##pfid;\ + do {\ + gettimeofday(&__prf_1_##pfid, 0);\ } while (0) #define MSG_PROFILE_END(pfid) \ @@ -92,18 +172,19 @@ int get_tid(); long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\ long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\ if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \ - SLOG(LOG_DEBUG, USER_TAG, "**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid \ - " -> Elapsed Time: %u.%06u seconds\n", \ - rindex(__FILE__, '/')+1, \ + SLOGD("**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid " -> Elapsed Time: %u.%06u seconds\n",\ + rindex(__FILE__, '/')+1,\ __FUNCTION__, \ - __prf_l1_##pfid, \ - __prf_l2_##pfid, \ - (unsigned int)(__ds), \ - (unsigned int)(__dm)); \ + __prf_l1_##pfid,\ + __prf_l2_##pfid,\ + (unsigned int)(__ds),\ + (unsigned int)(__dm));\ } while (0) #elif defined(LOG_ENABLE) +int get_tid(); + #define MSG_FATAL(fmt, ...) \ do \ {\ @@ -188,6 +269,19 @@ int get_tid(); #endif + +#define MSG_FREE(x) \ + ({\ + if (x != NULL){\ + free(x);\ + x = NULL;}\ + }) + + +/*================================================================================================== + FUNCTION PROTOTYPES +==================================================================================================*/ + const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType); const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType); diff --git a/include/utils/MsgDrmWrapper.h b/include/utils/MsgDrmWrapper.h index 09d83ef..b1a8779 100755 --- a/include/utils/MsgDrmWrapper.h +++ b/include/utils/MsgDrmWrapper.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef __MSG_DRM_WRAPPER_H_ @@ -41,6 +41,7 @@ bool MsgDrmGetMimeTypeEx(const char *szFileName, char *szMimeType, int nMimeType bool MsgDrmGetContentID(const char *szFileName, char *szContentID, int nContentIDLen); bool MsgDrmGetDrmType(const char *szFileName, MSG_DRM_TYPE *eDRMType); bool MsgDrmConvertDmtoDcfType(char *inputFile, char *outputFile); +bool MsgDrmCheckRingtone(const char *ringtonePath); #ifdef __cplusplus } diff --git a/include/utils/MsgException.h b/include/utils/MsgException.h index 50ce5b7..5d4c73f 100755 --- a/include/utils/MsgException.h +++ b/include/utils/MsgException.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_EXCEPTION_H @@ -69,6 +69,7 @@ public: SECURITY_ERROR, SERVER_READY_ERROR = 13, + REQ_EXIST_ERROR, // dont erase NUM_ERRORS. place a new error code in ahead of NUM_ERRORS NUM_ERRORS }; diff --git a/include/utils/MsgGconfWrapper.h b/include/utils/MsgGconfWrapper.h index 6aee579..9ff1c8b 100755 --- a/include/utils/MsgGconfWrapper.h +++ b/include/utils/MsgGconfWrapper.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_GCONF_WRAPPER_H @@ -57,11 +57,13 @@ int MsgSettingGetBool(const char *pKey, bool *pVal); msg_error_t MsgSettingHandleNewMsg(int SmsCnt, int MmsCnt); msg_error_t MsgSettingSetIndicator(int SmsCnt, int MmsCnt); -bool MsgSettingGetAutoReject(); +int MsgSettingGetAutoReject(); bool MsgSettingGetUnknownAutoReject(); void MsgSettingRegVconfCB(); void MsgSettingRemoveVconfCB(); + void MsgSettingRegVconfCBCommon(const char *pKey, _vconf_change_cb pCb); +void MsgSettingRemoveVconfCBCommon(const char *pKey, _vconf_change_cb pCb); #endif // MSG_GCONF_WRAPPER_H diff --git a/include/utils/MsgIpcSocket.h b/include/utils/MsgIpcSocket.h index 683f26e..8795d48 100755 --- a/include/utils/MsgIpcSocket.h +++ b/include/utils/MsgIpcSocket.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef __IPCSocket_H__ @@ -65,14 +65,15 @@ public: msg_error_t connect(const char *path); msg_error_t close(); /* write msg to ipc server */ - int write(const char* buf, int len); + int write(const char* buf, unsigned int len); /* read msg from ipc server */ - int read(char** buf, int* len); + int read(char** buf, unsigned int* len); void addfd(int fd); int getRemoteFd() {return remotefd; } private: - int readn(char *buf, int len ); - int writen (const char *buf, int len); + int readn(char *buf, unsigned int len ); + int writen (const char *buf, unsigned int len); + bool wait_for_reply(); int sockfd, remotefd, maxfd; fd_set fds; @@ -95,13 +96,13 @@ public: /* read msg from client of fd */ int read(int fd, char** buf, int* len ); /* write msg to ipc client */ - int write(int fd, const char* buf, int len); + int write(int fd, const char* buf, unsigned int len); void addfd(int fd); void setSockfd(int fd) { sockfd = fd; } private: - int readn(int fd, char *buf, int len ); - int writen (int fd, const char *buf, int len); + int readn(int fd, char *buf, unsigned int len ); + int writen (int fd, const char *buf, unsigned int len); /* server socket fd */ int sockfd; diff --git a/include/utils/MsgJsonParser.h b/include/utils/MsgJsonParser.h new file mode 100755 index 0000000..9cebec0 --- /dev/null +++ b/include/utils/MsgJsonParser.h @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef __MSG_JSON_PARSER_H__ +#define __MSG_JSON_PARSER_H__ + +#include +#include "MsgDebug.h" + +#define MSG_JSON_OBJ_SET_STR(json_obj, key, val)\ + if(json_obj && key && val){\ + json_object_set_string_member(json_obj, key, val);\ + } else {\ + MSG_DEBUG("Error : json_obj = %p, key = %s, val = %s", json_obj, key, val);\ + } + +#define MSG_JSON_OBJ_SET_INT(json_obj, key, val)\ + if(json_obj && key){\ + json_object_set_int_member(json_obj, key, val);\ + } else {\ + MSG_DEBUG("Error : json_obj = %p, key = %s, val = %d", json_obj, key, val);\ + } + +#define MSG_JSON_OBJ_SET_OBJ(json_obj, key, val)\ + if(json_obj && key){\ + json_object_set_object_member(json_obj, key, val);\ + } else {\ + MSG_DEBUG("Error : json_obj = %p, key = %s, val = %p", json_obj, key, val);\ + } + +#define MSG_JSON_OBJ_SET_ARRAY(json_obj, key, json_array)\ + if(json_obj && key && json_array){\ + json_object_set_array_member(json_obj, key, json_array);\ + } else {\ + MSG_DEBUG("Error : json_obj = %p, key = %s, json_array = %p", json_obj, key, json_array);\ + } + +#define MSG_JSON_ARRAY_ADD_OBJECT(json_array, json_obj)\ + if(json_array && json_obj){\ + json_array_add_object_element(json_array, json_obj);\ + } else {\ + MSG_DEBUG("Error : json_array = %p, json_obj = %p", json_array, json_obj);\ + } + +#define MSG_PRINT_PARSER_OBJECT(index, obj) {\ + switch(obj.type) {\ + case MSG_JSON_PARSER_NULL:\ + MSG_DEBUG("parse obj : idx = %d, key =[%s], type = [%d], value = [%p], value num = [%f]", index, obj.key, obj.type, obj.value, obj.number_value);\ + break;\ + case MSG_JSON_PARSER_INT:\ + MSG_DEBUG("parse obj : idx = [%d], key = [%s], type = [%s], value = [%d]", index, obj.key, "MSG_JSON_PARSER_INT", (int)obj.number_value);\ + break;\ + case MSG_JSON_PARSER_UINT:\ + MSG_DEBUG("parse obj : idx = [%d], key = [%s], type = [%s], value = [%u]", index, obj.key, "MSG_JSON_PARSER_UINT", (unsigned int)obj.number_value);\ + break;\ + case MSG_JSON_PARSER_REAL:\ + MSG_DEBUG("parse obj : idx = [%d], key = [%s], type = [%s], value = [%f]", index, obj.key, "MSG_JSON_PARSER_REAL", obj.number_value);\ + break;\ + case MSG_JSON_PARSER_STRING:\ + MSG_DEBUG("parse obj : idx = [%d], key = [%s], type = [%s], value = [%s]", index, obj.key, "MSG_JSON_PARSER_STRING", (char *)obj.value);\ + break;\ + case MSG_JSON_PARSER_BOOLEAN:\ + MSG_DEBUG("parse obj : idx = [%d], key = [%s], type = [%s], value = [%s]", index, obj.key, "MSG_JSON_PARSER_BOOLEAN", obj.number_value == 0 ? "TRUE" : "FALSE");\ + break;\ + case MSG_JSON_PARSER_ARRAY:\ + MSG_DEBUG("parse obj : idx = [%d], key = [%s], type = [%s]", index, obj.key, "MSG_JSON_PARSER_ARRAY");\ + break;\ + case MSG_JSON_PARSER_OBJECT:\ + MSG_DEBUG("parse obj : idx = [%d], key = [%s], type = [%s]", index, obj.key, "MSG_JSON_PARSER_OBJECT");\ + break;\ + default:\ + MSG_DEBUG("parse obj : idx = %d, key =[%s], type = [%d], value = [%p], value num = [%f]", index, obj.key, obj.type, obj.value, obj.number_value);\ + break;\ + }\ +} +/** +*@enum msg_json_parser_value_type +* This enumerates json-node types. +*/ +typedef enum { + MSG_JSON_PARSER_NULL = 0, /** 0 +#include "MsgMutex.h" /*================================================================================================== DEFINES ==================================================================================================*/ -#define MSGFW_DB_NAME "/opt/dbspace/.msg_service.db" +#define MSGFW_DB_NAME "/opt/usr/dbspace/.msg_service.db" #define MSGFW_MESSAGE_TABLE_NAME "MSG_MESSAGE_TABLE" #define MSGFW_FOLDER_TABLE_NAME "MSG_FOLDER_TABLE" @@ -38,17 +39,44 @@ #define MSGFW_CB_MSG_TABLE_NAME "MSG_CBMSG_TABLE" #define MMS_PLUGIN_MESSAGE_TABLE_NAME "MSG_MMS_MESSAGE_TABLE" #define MSGFW_SYNCML_MSG_TABLE_NAME "MSG_SYNCML_TABLE" + +#if 0 +#define MSGFW_RECEIVED_CB_MSG_TABLE_NAME "MSG_CB_MESSAGE_TABLE" +#endif + +#define MSGFW_CB_CHANNEL_INFO_TABLE_NAME "MSG_CB_CHANNEL_INFO_TABLE" +#ifdef FEATURE_SMS_CDMA +#define MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME "MSG_CDMA_CB_CHANNEL_INFO_TABLE" +#endif + #define MSGFW_SMS_SENDOPT_TABLE_NAME "MSG_SMS_SENDOPT_TABLE" +#define MSGFW_SMS_REPORT_TABLE_NAME "MSG_SMS_REPORT_TABLE" +#define MSGFW_REPORT_TABLE_NAME "MSG_REPORT_TABLE" +#define MSGFW_PUSH_CONFIG_TABLE_NAME "MSG_PUSHCFG_TABLE" +#define MSGFW_MMS_PREVIEW_TABLE_NAME "MSG_MMS_PREVIEW_INFO_TABLE" +#define MSGFW_MMS_MULTIPART_TABLE_NAME "MSG_MULTIPART_TABLE" + +#ifdef FEATURE_SMS_CDMA +#define MSGFW_UNIQUENESS_INFO_TABLE_NAME "MSG_UNIQUENESS_INFO_TABLE" +#endif + +#define MSGFW_TMP_MSGID_TABLE_NAME "MSG_TMP_MSGID_TABLE" + +#define MSGFW_ADDRESS_TEMP_TABLE_NAME "MSG_ADDRESS_TEMP_TABLE" #define MAX_QUERY_LEN 3072 #define MAX_FOLDER_NAME_LEN 20 #define MAX_ACCOUNT_NAME_LEN 51 +#define MSGFW_DB_ESCAPE_CHAR '\\' + +#define SHM_FILE_FOR_DB_LOCK "/.msg_shm_db_lock" /*================================================================================================== FUNCTION PROTOTYPES ==================================================================================================*/ void MsgReleaseMemoryDB(); +msg_error_t MsgConvertStrWithEscape(const char *input, char **output); /*================================================================================================== @@ -65,12 +93,14 @@ public: bool checkTableExist(const char *pTableName); msg_error_t execQuery(const char *pQuery); - msg_error_t getTable(const char *pQuery, int *pRowCnt); + msg_error_t getTable(const char *pQuery, int *pRowCnt, int *pColumnCnt); void freeTable(); msg_error_t bindText(const char *pBindStr, int index); + msg_error_t bindInt(const int pBindint, int index); msg_error_t bindBlob(const void * pBindBlob, int size, int index); msg_error_t prepareQuery(const char *pQuery); msg_error_t stepQuery(); + void resetQuery(); void finalizeQuery(); int columnInt(int ColumnIndex); const unsigned char* columnText(int ColumnIndex); @@ -79,14 +109,25 @@ public: msg_error_t endTrans(bool Success); int getColumnToInt(int RowIndex); char getColumnToChar(int RowIndex); + char* getColumnToString(int RowIndex); void getColumnToString(int RowIndex, int Length, char *pString); msg_error_t getRowId(const char *pTableName, unsigned int *pRowId); + void getMmapMutex(const char *shm_file_name); + void freeMmapMutex(); + void shm_mutex_timedlock (int sec); + void shm_mutex_unlock(); private: - char **result; - + sqlite3 *handle; + sqlite3_stmt *stmt; + pthread_mutex_t *mmapMx; + int shm_fd; + static Mutex mx; }; + +MsgDbHandler *getDbHandle(); +void removeDbHandle(); #endif // MSG_SQLITE_WRAPPER_H diff --git a/plugin/sms_plugin/include/SmsPluginTextConvert.h b/include/utils/MsgTextConvert.h similarity index 82% rename from plugin/sms_plugin/include/SmsPluginTextConvert.h rename to include/utils/MsgTextConvert.h index 08cee2b..3401874 100755 --- a/plugin/sms_plugin/include/SmsPluginTextConvert.h +++ b/include/utils/MsgTextConvert.h @@ -1,21 +1,21 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -#ifndef SMS_PLUGIN_TEXT_CONVERT_H -#define SMS_PLUGIN_TEXT_CONVERT_H +#ifndef MSG_TEXT_CONVERT_H +#define MSG_TEXT_CONVERT_H /*================================================================================================== @@ -23,7 +23,7 @@ ==================================================================================================*/ #include -#include "SmsPluginTypes.h" +//#include "SmsPluginTypes.h" /*================================================================================================== @@ -35,27 +35,69 @@ #define MAX_DUMP_COLUMN 16 -typedef unsigned short WCHAR; +typedef unsigned long WCHAR; -typedef unsigned char SMS_CHAR_TYPE_T; +typedef unsigned char MSG_CHAR_TYPE_T; + +typedef unsigned char MSG_LANGUAGE_ID_T; /*================================================================================================== ENUMS ==================================================================================================*/ -enum _SMS_CHAR_TYPE_E +enum _MSG_CHAR_TYPE_E { - SMS_CHAR_DEFAULT = 0, - SMS_CHAR_GSM7EXT, - SMS_CHAR_TURKISH, - SMS_CHAR_SPANISH, - SMS_CHAR_PORTUGUESE + MSG_CHAR_DEFAULT = 0, + MSG_CHAR_GSM7EXT, + MSG_CHAR_TURKISH, + MSG_CHAR_SPANISH, + MSG_CHAR_PORTUGUESE }; +enum _MSG_LANGUAGE_ID_E +{ + MSG_LANG_ID_RESERVED = 0, + MSG_LANG_ID_TURKISH, + MSG_LANG_ID_SPANISH, + MSG_LANG_ID_PORTUGUESE, + MSG_LANG_ID_BENGALI, + MSG_LANG_ID_GUJARATI, + MSG_LANG_ID_HINDI, + MSG_LANG_ID_KANNADA, + MSG_LANG_ID_MALAYALAM, + MSG_LANG_ID_ORIYA, + MSG_LANG_ID_PUNJABI, + MSG_LANG_ID_TAMIL, + MSG_LANG_ID_TELUGU, + MSG_LANG_ID_URDU, +}; /*================================================================================================== STRUCTURES ==================================================================================================*/ + +typedef struct _MSG_LANG_INFO_S +{ + bool bSingleShift; + bool bLockingShift; + + MSG_LANGUAGE_ID_T singleLang; + MSG_LANGUAGE_ID_T lockingLang; +} MSG_LANG_INFO_S; + + +typedef struct _MSG_SINGLE_SHIFT_S +{ + MSG_LANGUAGE_ID_T langId; +} MSG_SINGLE_SHIFT_S; + + +typedef struct _MSG_LOCKING_SHIFT_S +{ + MSG_LANGUAGE_ID_T langId; +} MSG_LOCKING_SHIFT_S; + + // ETSI GSM 03.38 GSM 7 bit Default Alphabet Table -> UCS2 static const WCHAR g_GSM7BitToUCS2[] = { @@ -209,39 +251,47 @@ static const WCHAR g_PortuLockingToUCS2[] = /*================================================================================================== CLASS DEFINITIONS ==================================================================================================*/ -class SmsPluginTextConvert +class MsgTextConvert { public: - static SmsPluginTextConvert* instance(); + static MsgTextConvert* instance(); - int convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT SMS_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); +#ifndef FEATURE_SMS_CDMA + int convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId, OUT msg_encode_type_t *pCharType); +#else int convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT msg_encode_type_t *pCharType); +#endif - int convertGSM7bitToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN SMS_LANG_INFO_S *pLangInfo); + int convertGSM7bitToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN MSG_LANG_INFO_S *pLangInfo); int convertUCS2ToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen); int convertEUCKRToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen); + int convertSHIFTJISToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen); private: - SmsPluginTextConvert(); - virtual ~SmsPluginTextConvert(); + MsgTextConvert(); + ~MsgTextConvert(); - static SmsPluginTextConvert* pInstance; + 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 convertUCS2ToASCII(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown); - int convertUCS2ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT SMS_LANGUAGE_ID_T *pLangId); - 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 SMS_LANG_INFO_S *pLangInfo); + int convertGSM7bitToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN MSG_LANG_INFO_S *pLangInfo); void convertDumpTextToHex(const unsigned char *pText, int length); + static MsgTextConvert* pInstance; + std::map extCharList; std::map ucs2toGSM7DefList; std::map ucs2toGSM7ExtList; std::map ucs2toTurkishList; std::map ucs2toSpanishList; std::map ucs2toPortuList; + + std::map replaceCharList; + }; -#endif //SMS_PLUGIN_TEXT_CONVERT_H +#endif //MSG_TEXT_CONVERT_H diff --git a/include/utils/MsgUtilFile.h b/include/utils/MsgUtilFile.h index 9d36330..8600b2a 100755 --- a/include/utils/MsgUtilFile.h +++ b/include/utils/MsgUtilFile.h @@ -1,31 +1,28 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_UTIL_FILE_H #define MSG_UTIL_FILE_H - +#include /*================================================================================================== DEFINES ==================================================================================================*/ #define FM_READ_WRITE_BUFFER_MAX (1024*1024*3) -#define TPDU_LOG_FILE "/opt/etc/msg-service/tpduLog.txt" - - /*================================================================================================== FUNCTION PROTOTYPES ==================================================================================================*/ @@ -57,7 +54,12 @@ int MsgRmRf(char *pDirPath); unsigned int MsgDu(const char *pDirPath); bool MsgAppendFile(const char *pFilePath, const char *pData, int DataSize); void MsgMmsInitDir(); - +bool MsgAccessFile(const char *filepath, int mode); +bool MsgChmod(const char *filepath, int mode); +bool MsgChown(const char *filepath, int uid, int gid); +bool MsgCreateFile(const char *pFilePath,char *pData, int DataSize); +char *MsgGetDirName(char *file_path); +char *MsgGetFileName(char *file_path); #endif // MSG_UTIL_FILE_H diff --git a/include/utils/MsgUtilFunction.h b/include/utils/MsgUtilFunction.h index 0d11260..5595a01 100755 --- a/include/utils/MsgUtilFunction.h +++ b/include/utils/MsgUtilFunction.h @@ -1,22 +1,23 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_UTIL_FUNCTION_H #define MSG_UTIL_FUNCTION_H +#define MSG_UTIL_CH_EMAIL_AT '@' /*================================================================================================== INCLUDE FILES @@ -31,6 +32,8 @@ FUNCTION PROTOTYPES ==================================================================================================*/ +bool MsgCheckFeatureSupport(const char *feature_name); + // Encoders int MsgEncodeCountInfo(MSG_COUNT_INFO_S *pCountInfo, char **ppDest); @@ -40,7 +43,7 @@ int MsgEncodeRecipientList(MSG_RECIPIENTS_LIST_S *pRecipientList, char **ppDest) int MsgEncodeMsgId(msg_message_id_t *pMsgId, char **ppDest); -int MsgEncodeMsgInfo(MSG_MESSAGE_INFO_S *pMsgInfo, char **ppDest); +int MsgEncodeMsgInfo(const MSG_MESSAGE_INFO_S *pMsgInfo, char **ppDest); int MsgEncodeMsgInfo(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo, char **ppDest); @@ -68,7 +71,9 @@ int MsgEncodeSyncMLOperationData(int msgId, int extId, char **ppDest); int MsgEncodeStorageChangeData(const msg_storage_change_type_t storageChangeType, const msg_id_list_s *pMsgIdList, char **ppDest); -int MsgEncodeReportStatus(MSG_REPORT_STATUS_INFO_S* pReportStatus, char **ppDest); +int MsgEncodeReportMsgData(const msg_report_type_t msgReportType, const MSG_MESSAGE_INFO_S *pMsgInfo, char **ppDest); + +int MsgEncodeReportStatus(MSG_REPORT_STATUS_INFO_S* pReportStatus, int count, char **ppDest); int MsgEncodeThreadId(msg_thread_id_t *pThreadId, char **ppDest); @@ -80,6 +85,8 @@ void MsgDecodeMsgId(char *pSrc, msg_message_id_t *pMsgId); void MsgDecodeCountInfo(char *pSrc, MSG_COUNT_INFO_S *pCountInfo); +void MsgDecodeMsgInfo(char *pSrc, MSG_MESSAGE_INFO_S *pMsgInfo); + void MsgDecodeMsgInfo(char *pSrc, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo); void MsgDecodeFolderViewList(char *pSrc, msg_struct_list_s *pFolderViewList); @@ -96,11 +103,11 @@ 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); -void MsgDecodeReportStatus(char *pSrc, MSG_REPORT_STATUS_INFO_S *pReportStatus); +void MsgDecodeReportStatus(char *pSrc, msg_struct_list_s *report_list); void MsgDecodeThreadId(char *pSrc, msg_thread_id_t *pThreadId); @@ -111,8 +118,16 @@ void MsgDecodeThreadInfo(char *pSrc, MSG_THREAD_VIEW_S *pThreadInfo); int MsgMakeEvent(const void *pData, int DataSize, MSG_EVENT_TYPE_T MsgEvent, msg_error_t MsgError, void **ppEvent); +// Utin functions int msg_verify_number(const char *raw, char *trimmed); int msg_verify_email(const char *raw); +char* msg_clean_country_code(char *src); + +char* msg_normalize_number(char *src); + +msg_error_t MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort); + +bool msg_is_valid_email(char *pAddress); #endif // MSG_UTIL_FUNCTION_H diff --git a/include/utils/MsgUtilStorage.h b/include/utils/MsgUtilStorage.h index d0ab5d9..56bce45 100755 --- a/include/utils/MsgUtilStorage.h +++ b/include/utils/MsgUtilStorage.h @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #ifndef MSG_UTIL_STORAGE_H @@ -24,38 +24,70 @@ #include "MsgInternalTypes.h" #include "MsgStorageTypes.h" #include "MsgSqliteWrapper.h" - +#include "MsgSettingTypes.h" /*================================================================================================== FUNCTION PROTOTYPES ==================================================================================================*/ // Common Function + unsigned int MsgStoAddMessageTable(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsgInfo); msg_error_t MsgStoSetReadStatus(MsgDbHandler *pDbHandle, msg_message_id_t MsgId, bool bRead); msg_error_t MsgStoGetOldestMessage(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsgInfo, msg_message_id_t *pMsgId); msg_error_t MsgStoCheckMsgCntFull(MsgDbHandler *pDbHandle, const MSG_MESSAGE_TYPE_S* pMsgType, msg_folder_id_t FolderId); msg_error_t MsgStoCountMsgByLimitCategory(MsgDbHandler *pDbHandle, const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount, msg_folder_id_t folderId ); +msg_error_t MsgStocheckMemoryStatus(); int MsgStoCheckMsgCntLimit(const MSG_MESSAGE_TYPE_S* pMsgType, msg_folder_id_t FolderId); msg_error_t MsgStoAddAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t *pConvId); -msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t msgId, int contactNameOrder, int *nAddressCnt, MSG_ADDRESS_INFO_S *pAddress); +msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t msgId, int contactNameOrder, int *nAddressCnt, MSG_ADDRESS_INFO_S **pAddress); msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t msgId, int contactNameOrder, msg_struct_list_s *pAddress); msg_error_t MsgStoGetAddressByConvId(MsgDbHandler *pDbHandle, msg_thread_id_t convId, int contactNameOrder, msg_struct_list_s *pAddrlist); +void MsgStoUpdateAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t convId); msg_error_t MsgStoAddConversation(MsgDbHandler *pDbHandle, msg_thread_id_t *pConvId); msg_error_t MsgStoUpdateConversation(MsgDbHandler *pDbHandle, msg_thread_id_t convId); msg_error_t MsgStoSetConversationDisplayName(MsgDbHandler *pDbHandle, int contactId); msg_error_t MsgStoSetConversationDisplayName(MsgDbHandler *pDbHandle, msg_thread_id_t convId); msg_error_t MsgStoClearConversationTable(MsgDbHandler *pDbHandle); + +#ifdef FEATURE_SMS_CDMA +msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel); +msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel); +#else +msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel, msg_sim_slot_id_t simIndex); +msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel, msg_sim_slot_id_t simIndex); +#endif + bool MsgExistAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t *pConvId); +bool MsgExistAddress(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t convId, int index); +bool MsgExistConversation(MsgDbHandler *pDbHandle, msg_thread_id_t convId); +bool MsgExistMessage(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsg); int MsgStoGetUnreadCnt(MsgDbHandler *pDbHandle, MSG_MAIN_TYPE_T MsgType); msg_error_t MsgStoAddContactInfo(MsgDbHandler *pDbHandle, MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber); +msg_error_t MsgStoClearContactInfoByAddrbookIdList(MsgDbHandler *pDbHandle, int* addrbookList, int addrbookCnt); msg_error_t MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int ContactId); -msg_error_t MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int ContactId, const char *pNumber); +msg_error_t MsgStoResetContactInfo(MsgDbHandler *pDbHandle, int contactId); msg_error_t MsgStoGetMmsRawFilePath(MsgDbHandler *pDbHandle, msg_message_id_t msgId, char *pFilePath); bool MsgStoCheckReadReportRequested(MsgDbHandler *pDbHandle, msg_message_id_t MsgId); bool MsgStoCheckReadReportIsSent(MsgDbHandler *pDbHandle, msg_message_id_t MsgId); -char *MsgStoReplaceString(const char *org_str, const char *old_str, const char *new_str); +msg_error_t MsgStoUpdateNetworkStatus(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo, msg_network_status_t status); + +// Lists +msg_error_t MsgStoGetFolderViewList(msg_folder_id_t FolderId, const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pMsgFolderViewList); +msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList); +msg_error_t MsgStoGetConversationViewItem(msg_message_id_t msgId, MSG_CONVERSATION_VIEW_S *pConv); +msg_error_t MsgStoGetConversationViewList(msg_thread_id_t ThreadId, msg_struct_list_s *pConvViewList); +msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList); + +msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList); +msg_error_t MsgStoGetAddressList(const msg_thread_id_t threadId, msg_struct_list_s *pAddrList); +msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pMsgList); +msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t *pMediaList); + +#ifdef FEATURE_SMS_CDMA +msg_error_t MsgStoClearUniquenessTable(); +#endif #endif // MSG_UTIL_STORAGE_H diff --git a/include/utils/MsgVMessage.h b/include/utils/MsgVMessage.h new file mode 100755 index 0000000..ad9f3e3 --- /dev/null +++ b/include/utils/MsgVMessage.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef MSG_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 + diff --git a/mapi/CMakeLists.txt b/mapi/CMakeLists.txt index 6af422f..3f56ff7 100755 --- a/mapi/CMakeLists.txt +++ b/mapi/CMakeLists.txt @@ -10,7 +10,7 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "") 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_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall") ########################################################## # Define MAPI @@ -29,20 +29,19 @@ SET(MAPI-SRCS INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include/common - ${CMAKE_SOURCE_DIR}/include/framework ${CMAKE_SOURCE_DIR}/include/proxy ${CMAKE_SOURCE_DIR}/include/utils ${CMAKE_SOURCE_DIR}/include/mapi ) INCLUDE(FindPkgConfig) -pkg_check_modules(mapi_pkgs REQUIRED glib-2.0 dlog) +pkg_check_modules(mapi_pkgs REQUIRED glib-2.0 dlog privacy-manager-client vconf) FOREACH(flag ${mapi_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") diff --git a/mapi/msg_control.cpp b/mapi/msg_control.cpp index cf24235..8116e05 100755 --- a/mapi/msg_control.cpp +++ b/mapi/msg_control.cpp @@ -1,20 +1,21 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include +#include #include "MsgHandle.h" #include "MsgDebug.h" @@ -28,19 +29,27 @@ ==================================================================================================*/ EXPORT_API int msg_open_msg_handle(msg_handle_t *handle) { - MsgHandle* pHandle = new MsgHandle(); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } if (handle == NULL) { MSG_FATAL("Input Paramter is NULL"); - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } + MsgHandle* pHandle = new MsgHandle(); // Create MsgHandle *handle = (msg_handle_t)pHandle; if (*handle == NULL) - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; try { @@ -51,8 +60,14 @@ EXPORT_API int msg_open_msg_handle(msg_handle_t *handle) { MSG_FATAL("%s", e.what()); + // Destroy MsgHandle + delete (MsgHandle*)(*handle); + (*handle) = NULL; + if (e.errorCode() == MsgException::SERVER_READY_ERROR) return MSG_ERR_SERVER_NOT_READY; + else if(e.errorCode() == MsgException::SECURITY_ERROR) + return MSG_ERR_PERMISSION_DENIED; else return MSG_ERR_COMMUNICATION_ERROR; } @@ -63,10 +78,19 @@ EXPORT_API int msg_open_msg_handle(msg_handle_t *handle) EXPORT_API int msg_close_msg_handle(msg_handle_t *handle) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || *handle == NULL) { MSG_FATAL("Input Paramter is NULL"); - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)(*handle); diff --git a/mapi/msg_filter.cpp b/mapi/msg_filter.cpp index cf862e0..4871163 100755 --- a/mapi/msg_filter.cpp +++ b/mapi/msg_filter.cpp @@ -1,24 +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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include +#include #include "MsgException.h" #include "MsgDebug.h" #include "MsgHandle.h" +#include "msg_private.h" #include "msg.h" /*================================================================================================== @@ -26,19 +28,28 @@ ==================================================================================================*/ EXPORT_API int msg_add_filter(msg_handle_t handle, const msg_struct_t msg_struct_handle) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + // TODO : check NULL in msg_struct_handle msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } if(msg_struct->type != MSG_STRUCT_FILTER) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -59,20 +70,29 @@ EXPORT_API int msg_add_filter(msg_handle_t handle, const msg_struct_t msg_struct EXPORT_API int msg_update_filter(msg_handle_t handle, const msg_struct_t msg_struct_handle) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + // TODO : check NULL in msg_struct_handle msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } if(msg_struct->type != MSG_STRUCT_FILTER) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -93,11 +113,20 @@ EXPORT_API int msg_update_filter(msg_handle_t handle, const msg_struct_t msg_str EXPORT_API int msg_delete_filter(msg_handle_t handle, msg_filter_id_t filter_id) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -118,11 +147,20 @@ EXPORT_API int msg_delete_filter(msg_handle_t handle, msg_filter_id_t filter_id) EXPORT_API int msg_get_filter_list(msg_handle_t handle, msg_struct_list_s *filter_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || filter_list == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -143,11 +181,20 @@ EXPORT_API int msg_get_filter_list(msg_handle_t handle, msg_struct_list_s *filte EXPORT_API int msg_set_filter_operation(msg_handle_t handle, bool set_flag) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -168,11 +215,20 @@ EXPORT_API int msg_set_filter_operation(msg_handle_t handle, bool set_flag) EXPORT_API int msg_get_filter_operation(msg_handle_t handle, bool *set_flag) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -191,6 +247,60 @@ EXPORT_API int msg_get_filter_operation(msg_handle_t handle, bool *set_flag) } +EXPORT_API int msg_set_filter_active(msg_handle_t handle, msg_filter_id_t filter_id, bool active) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + MsgHandle* pHandle = (MsgHandle*)handle; + + try + { + err = pHandle->setFilterActivation(filter_id, active); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_FILTER_ERROR; + } + + return err; +} + + +bool msg_get_filter_info_bool(void *filter, int field) +{ + if (!filter) + return MSG_ERR_NULL_POINTER; + + int ret = 0; + + MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter; + + switch (field) + { + case MSG_FILTER_ACTIVE_BOOL : + ret = filter_data->bActive; + break; + default : + return MSG_ERR_INVALID_PARAMETER; + } + + return ret; +} int msg_get_filter_info_int(void *filter, int field) @@ -239,6 +349,26 @@ char *msg_get_filter_info_str(void *filter, int field) return ret_str; } +int msg_set_filter_info_bool(void *filter, int field, bool value) +{ + if (!filter) + return MSG_ERR_NULL_POINTER; + + msg_error_t err = MSG_SUCCESS; + MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter; + + switch (field) + { + case MSG_FILTER_ACTIVE_BOOL : + filter_data->bActive = value; + break; + default : + return MSG_ERR_INVALID_PARAMETER; + } + + return err; +} + int msg_set_filter_info_int(void *filter, int field, int value) { if (!filter) @@ -273,8 +403,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; } diff --git a/mapi/msg_message.cpp b/mapi/msg_message.cpp index 23fabc4..0a73738 100755 --- a/mapi/msg_message.cpp +++ b/mapi/msg_message.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include @@ -20,10 +20,38 @@ #include "MsgStorageTypes.h" #include "MsgInternalTypes.h" #include "MsgMmsMessage.h" - +#include "MsgSerialize.h" #include "msg.h" #include "msg_private.h" +msg_struct_s *__msg_message_create_address_struct() +{ + msg_struct_s *msg_struct = new msg_struct_s; + bzero(msg_struct, sizeof(msg_struct_s)); + + msg_struct->type = MSG_STRUCT_ADDRESS_INFO; + msg_struct->data = new MSG_ADDRESS_INFO_S; + memset(msg_struct->data, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + + return msg_struct; +} + +void __msg_message_release_address_struct(gpointer data) +{ + if (data == NULL) + return; + + msg_struct_s *addr_struct = (msg_struct_s *)data; + MSG_ADDRESS_INFO_S *addrInfo = (MSG_ADDRESS_INFO_S *)addr_struct->data; + + delete (MSG_ADDRESS_INFO_S *)addrInfo; + + addr_struct->data = NULL; + + delete addr_struct; +} + + void msg_message_create_struct(msg_struct_s *msg_struct) { MSG_MESSAGE_HIDDEN_S *msg = (MSG_MESSAGE_HIDDEN_S *)new MSG_MESSAGE_HIDDEN_S; @@ -50,27 +78,32 @@ void msg_message_create_struct(msg_struct_s *msg_struct) msg->dataSize = 0; msg->pData = NULL; msg->pMmsData = NULL; + msg->mmsDataSize = 0; + msg->simIndex = MSG_SIM_SLOT_ID_1; /* Allocate memory for address list of message */ msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s; addr_list->nCount = 0; - addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT]; - - msg_struct_s *pTmp = NULL; - - for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) { - addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)]; - pTmp = (msg_struct_s *)addr_list->msg_struct_info[i]; - pTmp->type = MSG_STRUCT_ADDRESS_INFO; - pTmp->data = new MSG_ADDRESS_INFO_S; - memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - - addr_list->msg_struct_info[i] = (msg_struct_t)pTmp; + addr_list->msg_struct_info = (msg_struct_t *)calloc(MAX_TO_ADDRESS_CNT, sizeof(msg_struct_s *)); + + if (addr_list->msg_struct_info != NULL) { + msg_struct_s *pTmp = NULL; + + for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) { + addr_list->msg_struct_info[i] = (msg_struct_t)new msg_struct_s; + pTmp = (msg_struct_s *)addr_list->msg_struct_info[i]; + memset(pTmp, 0x00, sizeof(msg_struct_s)); + pTmp->type = MSG_STRUCT_ADDRESS_INFO; + pTmp->data = new MSG_ADDRESS_INFO_S; + memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + } } msg->addr_list = addr_list; + msg->addressList = NULL; + msg_struct->data = (int *)msg; } @@ -86,10 +119,11 @@ int msg_message_release(msg_struct_s **msg_struct) if (msg->pMmsData) { delete [] static_cast(msg->pMmsData); msg->pMmsData = NULL; + msg->mmsDataSize = 0; } // Memory Free - if (msg->addr_list!= NULL) + if (msg->addr_list != NULL) { for(int i=0; iaddr_list->msg_struct_info[i]; @@ -99,12 +133,18 @@ int msg_message_release(msg_struct_s **msg_struct) msg->addr_list->msg_struct_info[i] = NULL; } - delete [] msg->addr_list->msg_struct_info; + g_free(msg->addr_list->msg_struct_info); delete msg->addr_list; msg->addr_list = NULL; } + // Free GList *addressList + if (msg->addressList) { + g_list_free_full(msg->addressList, __msg_message_release_address_struct); + msg->addressList = NULL; + } + delete msg; (*msg_struct)->data = NULL; @@ -138,35 +178,67 @@ int msg_message_get_int_value(void *data, int field, int *value) { if (msg_data->mainType == MSG_SMS_TYPE) { - if (msg_data->subType == MSG_CB_SMS) - *value = MSG_TYPE_SMS_CB; - else if (msg_data->subType == MSG_JAVACB_SMS) - *value = MSG_TYPE_SMS_JAVACB; - else if (msg_data->subType == MSG_WAP_SI_SMS || msg_data->subType == MSG_WAP_SL_SMS) - *value = MSG_TYPE_SMS_WAPPUSH; - else if (msg_data->subType == MSG_MWI_VOICE_SMS || msg_data->subType == MSG_MWI_FAX_SMS - || msg_data->subType == MSG_MWI_EMAIL_SMS || msg_data->subType == MSG_MWI_OTHER_SMS) - *value = MSG_TYPE_SMS_MWI; - else if (msg_data->subType == MSG_SYNCML_CP) - *value = MSG_TYPE_SMS_SYNCML; - else if (msg_data->subType == MSG_REJECT_SMS) - *value = MSG_TYPE_SMS_REJECT; - else - *value = MSG_TYPE_SMS; - } - else if (msg_data->mainType == MSG_MMS_TYPE) - { + switch (msg_data->subType) { + case MSG_CB_SMS : + *value = MSG_TYPE_SMS_CB; + break; + case MSG_JAVACB_SMS : + *value = MSG_TYPE_SMS_JAVACB; + break; + case MSG_WAP_SI_SMS : + case MSG_WAP_SL_SMS : + *value = MSG_TYPE_SMS_WAPPUSH; + break; + case MSG_MWI_VOICE_SMS : + case MSG_MWI_FAX_SMS : + case MSG_MWI_EMAIL_SMS : + case MSG_MWI_OTHER_SMS : + *value = MSG_TYPE_SMS_MWI; + break; + case MSG_SYNCML_CP : + *value = MSG_TYPE_SMS_SYNCML; + break; + case MSG_REJECT_SMS : + *value = MSG_TYPE_SMS_REJECT; + break; + case MSG_ETWS_SMS : + *value = MSG_TYPE_SMS_ETWS_PRIMARY; + break; + case MSG_CMAS_PRESIDENTIAL : + *value = MSG_TYPE_SMS_CMAS_PRESIDENTIAL; + break; + case MSG_CMAS_EXTREME : + *value = MSG_TYPE_SMS_CMAS_EXTREME; + break; + case MSG_CMAS_SEVERE : + *value = MSG_TYPE_SMS_CMAS_SEVERE; + break; + case MSG_CMAS_AMBER : + *value = MSG_TYPE_SMS_CMAS_AMBER; + break; + case MSG_CMAS_TEST : + *value = MSG_TYPE_SMS_CMAS_TEST; + break; + case MSG_CMAS_OPERATOR_DEFINED : + *value = MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED; + break; + default : + *value = MSG_TYPE_SMS; + } + } + else if (msg_data->mainType == MSG_MMS_TYPE) + { if (msg_data->subType == MSG_NOTIFICATIONIND_MMS) *value = MSG_TYPE_MMS_NOTI; else if (msg_data->subType == MSG_SENDREQ_JAVA_MMS) *value = MSG_TYPE_MMS_JAVA; else *value = MSG_TYPE_MMS; - } - else - *value = MSG_TYPE_INVALID; + } + else + *value = MSG_TYPE_INVALID; - break; + break; } case MSG_MESSAGE_CLASS_TYPE_INT : *value = msg_data->classType; @@ -201,6 +273,9 @@ int msg_message_get_int_value(void *data, int field, int *value) case MSG_MESSAGE_DATA_SIZE_INT : *value = msg_data->dataSize; break; + case MSG_MESSAGE_SIM_INDEX_INT : + *value = msg_data->simIndex; + break; default : ret = MSG_ERR_INVALID_PARAMETER; break; @@ -231,6 +306,14 @@ int msg_message_get_bool_value(void *data, int field, bool *value) case MSG_MESSAGE_PORT_VALID_BOOL : *value = msg_data->bPortValid; break; + case MSG_MESSAGE_REPLACE_BOOL : + { + if (msg_data->subType >= MSG_REPLACE_TYPE1_SMS && msg_data->subType <= MSG_REPLACE_TYPE7_SMS) + *value = true; + else + *value = false; + break; + } default : ret = MSG_ERR_INVALID_PARAMETER; break; @@ -260,9 +343,20 @@ int msg_message_get_str_value(void *data, int field, char *value, int size) break; case MSG_MESSAGE_SMS_DATA_STR : case MSG_MESSAGE_MMS_TEXT_STR : - if (msg_data->pData != NULL) - strncpy(value, (char *)msg_data->pData, size); + if (msg_data->pData) + { + 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; @@ -278,8 +372,6 @@ int msg_message_get_struct_hnd(void *data, int field, void **value) int ret = MSG_SUCCESS; - MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data; - switch (field) { default : ret = MSG_ERR_INVALID_PARAMETER; @@ -302,6 +394,9 @@ int msg_message_get_list_hnd(void *data, int field, void **value) case MSG_MESSAGE_ADDR_LIST_STRUCT : *value = (void *)msg_data->addr_list; break; + case MSG_MESSAGE_ADDR_LIST_HND : + *value = (msg_list_handle_t)msg_data->addressList; + break; default : ret = MSG_ERR_INVALID_PARAMETER; break; @@ -332,22 +427,30 @@ 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_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; + } break; } case MSG_MESSAGE_CLASS_TYPE_INT : @@ -383,6 +486,9 @@ int msg_message_set_int_value(void *data, int field, int value) case MSG_MESSAGE_DATA_SIZE_INT : msg_data->dataSize = value; break; + case MSG_MESSAGE_SIM_INDEX_INT : + msg_data->simIndex = value; + break; default : ret = MSG_ERR_INVALID_PARAMETER; break; @@ -442,16 +548,13 @@ int msg_message_set_str_value(void *data, int field, char *value, int size) break; case MSG_MESSAGE_SMS_DATA_STR : { - if (msg_data->pData) - delete [] static_cast(msg_data->pData); - - msg_data->dataSize = size; - - msg_data->pData = (void*)new char[msg_data->dataSize+1]; - - memcpy((char *)msg_data->pData, value, msg_data->dataSize); + if (msg_data->pData) + delete [] static_cast(msg_data->pData); - ((char*) msg_data->pData)[msg_data->dataSize] = '\0'; + msg_data->dataSize = size; + msg_data->pData = (void*)new char[msg_data->dataSize+1]; + memcpy((char *)msg_data->pData, value, msg_data->dataSize); + ((char*) msg_data->pData)[msg_data->dataSize] = '\0'; } break; default : @@ -469,8 +572,6 @@ int msg_message_set_struct_hnd(void *data, int field, void *value) int ret = MSG_SUCCESS; - MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data; - switch (field) { default : ret = MSG_ERR_INVALID_PARAMETER; @@ -500,21 +601,24 @@ void msg_message_copy_message(MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_HIDDEN_S * pDst->direction = pSrc->direction; pDst->bPortValid = pSrc->bPortValid; pDst->dataSize = pSrc->dataSize; + pDst->mmsDataSize = pSrc->mmsDataSize; + pDst->simIndex = pSrc->simIndex; memcpy(pDst->subject, pSrc->subject, sizeof(pDst->subject)); - if(pSrc->dataSize) + + if(pSrc->pMmsData && pSrc->mmsDataSize) { - if(pSrc->pMmsData) - { - pDst->pMmsData = new char[pSrc->dataSize + 1]; - memcpy(pDst->pMmsData, pSrc->pMmsData, pSrc->dataSize); - } - if(pSrc->pData) - { - int data_len = strlen((const char *)pSrc->pData); - pDst->pData = new char[data_len + 1]; - strncpy((char *)pDst->pData, (const char *)pSrc->pData, data_len); - } + pDst->pMmsData = new char[pSrc->mmsDataSize]; + memcpy(pDst->pMmsData, pSrc->pMmsData, pSrc->mmsDataSize); } + + if(pSrc->dataSize && pSrc->pData) + { + int data_len = strlen((const char *)pSrc->pData); + pDst->pData = new char[data_len + 1]; + memset(pDst->pData, 0x00, data_len + 1); + strncpy((char *)pDst->pData, (const char *)pSrc->pData, data_len); + } + msg_struct_list_s *src_addrlist = pSrc->addr_list; msg_struct_list_s *dst_addrlist = pDst->addr_list; dst_addrlist->nCount = src_addrlist->nCount; @@ -525,10 +629,149 @@ 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)); + } + + for (unsigned int i=0; i < g_list_length(pSrc->addressList); i++) { + msg_struct_s *addr_struct = __msg_message_create_address_struct(); + MSG_ADDRESS_INFO_S *addrInfo = (MSG_ADDRESS_INFO_S *)addr_struct->data; + + msg_struct_s *addr_info = (msg_struct_s *)g_list_nth_data(pSrc->addressList,(guint)i); + MSG_ADDRESS_INFO_S *address = (MSG_ADDRESS_INFO_S *)addr_info->data; + + addrInfo->addressType = address->addressType; + addrInfo->recipientType = address->recipientType; + addrInfo->contactId = address->contactId; + strncpy(addrInfo->addressVal, address->addressVal, MAX_ADDRESS_VAL_LEN); + strncpy(addrInfo->displayName, address->displayName, MAX_DISPLAY_NAME_LEN); + addrInfo->displayName[MAX_DISPLAY_NAME_LEN] = '\0'; + + pDst->addressList = g_list_append(pDst->addressList, addr_struct); + } } +int msg_cb_message_get_int_value(void *data, int field, int *value) +{ + if (!data) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + + MSG_CB_MSG_S *cb_msg = (MSG_CB_MSG_S *)data; + + *value = 0; + + switch (field) + { + case MSG_CB_MSG_TYPE_INT : + { + switch (cb_msg->type) { + case MSG_ETWS_SMS : + *value = MSG_TYPE_SMS_ETWS_PRIMARY; + break; + case MSG_CB_SMS: + *value = ((cb_msg->messageId & 0xFFF8) == 0x1100 ) ? MSG_TYPE_SMS_ETWS_SECONDARY : MSG_TYPE_SMS_CB; + break; + case MSG_CMAS_PRESIDENTIAL : + *value = MSG_TYPE_SMS_CMAS_PRESIDENTIAL; + break; + case MSG_CMAS_EXTREME : + *value = MSG_TYPE_SMS_CMAS_EXTREME; + break; + case MSG_CMAS_SEVERE : + *value = MSG_TYPE_SMS_CMAS_SEVERE; + break; + case MSG_CMAS_AMBER : + *value = MSG_TYPE_SMS_CMAS_AMBER; + break; + case MSG_CMAS_TEST : + *value = MSG_TYPE_SMS_CMAS_TEST; + break; + case MSG_CMAS_OPERATOR_DEFINED : + *value = MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED; + break; + default : + ret = MSG_ERR_UNKNOWN; + } + } + break; + case MSG_CB_MSG_RECV_TIME_INT : + *value = cb_msg->receivedTime; + break; + case MSG_CB_MSG_SERIAL_NUM_INT : + *value = cb_msg->serialNum; + break; + case MSG_CB_MSG_MSG_ID_INT : + *value = cb_msg->messageId; + break; + case MSG_CB_MSG_DCS_INT : + *value = (int)cb_msg->dcs; + break; + case MSG_CB_MSG_CB_TEXT_LEN_INT : + *value = cb_msg->cbTextLen; + break; + case MSG_CB_MSG_ETWS_WARNING_TYPE_INT : + *value = cb_msg->etwsWarningType; + break; + default : + ret = MSG_ERR_INVALID_PARAMETER; + break; + } + + return ret; +} + +int msg_cb_message_get_str_value(void *data, int field, char *value, int size) +{ + if (!data || !value) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + + MSG_CB_MSG_S *cb_msg = (MSG_CB_MSG_S *)data; + + switch (field) { + case MSG_CB_MSG_CB_TEXT_STR: + { + int copylen = 0; + copylen = (size > cb_msg->cbTextLen) ? cb_msg->cbTextLen : size - 1; + memcpy (value, cb_msg->cbText, copylen); + value[copylen] = '\0'; + } + break; + case MSG_CB_MSG_LANGUAGE_TYPE_STR: + { + int copylen = 0; + copylen = ((size_t)size > strlen((const char*)cb_msg->language_type)) ? strlen((const char*)cb_msg->language_type) : size - 1; + memcpy (value, cb_msg->language_type, copylen); + value[copylen] = '\0'; + } + break; + case MSG_CB_MSG_ETWS_WARNING_SECU_INFO_STR: + { + if ((size_t)size < sizeof(cb_msg->etwsWarningSecurityInfo)) + ret = MSG_ERR_INVALID_PARAMETER; + else + memcpy (value, cb_msg->etwsWarningSecurityInfo, sizeof(cb_msg->etwsWarningSecurityInfo)); + } + break; + + default : + ret = MSG_ERR_INVALID_PARAMETER; + break; + } + + return ret; +} + + + EXPORT_API int msg_get_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t mms_struct_handle) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); //TODO :: check message type is MMS int ret = MSG_SUCCESS; msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle; @@ -548,24 +791,28 @@ EXPORT_API int msg_get_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t m MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data; - MMS_MESSAGE_DATA_S *tmp_mms_data = (MMS_MESSAGE_DATA_S *)calloc(1, sizeof(MMS_MESSAGE_DATA_S)); + if (msg_data->pMmsData == NULL) { + return MSG_ERR_INVALID_PARAMETER; + } - _MsgMmsDeserializeMessageData(tmp_mms_data, (char*)msg_data->pMmsData); + MMS_DATA_S *mms_data = NULL; - convert_from_mmsdata(tmp_mms_data, mms_struct); + MsgDeserializeMmsData((char*)msg_data->pMmsData, msg_data->mmsDataSize, &mms_data); - _MsgMmsReleasePageList(tmp_mms_data); - _MsgMmsReleaseRegionList(tmp_mms_data); - _MsgMmsReleaseAttachList(tmp_mms_data); - _MsgMmsReleaseTransitionList(tmp_mms_data); - _MsgMmsReleaseMetaList(tmp_mms_data); - free(tmp_mms_data); + if (mms_data) { + convert_to_hidden_mmsdata(mms_data, mms_struct); + + MsgMmsRelease(&mms_data); + } else { + return MSG_ERR_INVALID_PARAMETER; + } return ret; } EXPORT_API int msg_set_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t mms_struct_handle) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); //TODO :: check message type is MMS int ret = MSG_SUCCESS; msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle; @@ -585,18 +832,91 @@ EXPORT_API int msg_set_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t m MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data; - MMS_MESSAGE_DATA_S *tmp_mms_data = (MMS_MESSAGE_DATA_S *)calloc(1,sizeof(MMS_MESSAGE_DATA_S)); + MMS_DATA_S *mms_data = MsgMmsCreate(); + if (mms_data == NULL) + return MSG_ERR_MEMORY_ERROR; + + convert_from_hidden_mmsdata(mms_struct, mms_data); + + int mmsDataSize = MsgSerializeMms(mms_data, (char **)&msg_data->pMmsData); - convert_to_mmsdata(mms_struct, tmp_mms_data); + if (mmsDataSize > 0) + msg_data->mmsDataSize = mmsDataSize; - msg_data->pMmsData = _MsgMmsSerializeMessageData(tmp_mms_data, &(msg_data->dataSize)); + //TODO:: set subtype + + MsgMmsRelease(&mms_data); + + return ret; +} + + +int msg_message_list_append(msg_struct_t msg_struct_handle, int field, msg_struct_t *item) +{ + msg_error_t err = MSG_SUCCESS; + msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle; + MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data; + + msg_struct_s *msg_struct_item = NULL; + switch(field) { + case MSG_MESSAGE_ADDR_LIST_HND: + { + msg_struct_item = __msg_message_create_address_struct(); + msg_data->addressList = g_list_append(msg_data->addressList, msg_struct_item); + *item = (msg_struct_t)msg_struct_item; + } + break; + default : + err = MSG_ERR_INVALID_PARAMETER; + break; + } + + return err; +} + + +int msg_message_list_clear(msg_struct_t msg_struct_handle, int field) +{ + msg_error_t err = MSG_SUCCESS; + msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle; + MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data; + + switch(field) { + case MSG_MESSAGE_ADDR_LIST_HND: + { + // Free GList *addressList + if (msg_data->addressList) { + g_list_free_full(msg_data->addressList, __msg_message_release_address_struct); + msg_data->addressList = NULL; + } + } + break; + default : + err = MSG_ERR_INVALID_PARAMETER; + break; + } + + return err; +} + +int msg_conversation_get_list_hnd(void *data, int field, void **value) +{ + if (!data) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + + MSG_CONVERSATION_VIEW_S *msg_data = (MSG_CONVERSATION_VIEW_S *)data; + + switch (field) { + case MSG_CONV_MSG_MULTIPART_HND : + *value = (void *)msg_data->multipart_list; + break; + default : + ret = MSG_ERR_INVALID_PARAMETER; + break; + } - _MsgMmsReleasePageList(tmp_mms_data); - _MsgMmsReleaseRegionList(tmp_mms_data); - _MsgMmsReleaseAttachList(tmp_mms_data); - _MsgMmsReleaseTransitionList(tmp_mms_data); - _MsgMmsReleaseMetaList(tmp_mms_data); - free(tmp_mms_data); return ret; } diff --git a/mapi/msg_mms.cpp b/mapi/msg_mms.cpp index 218f643..e4f157c 100755 --- a/mapi/msg_mms.cpp +++ b/mapi/msg_mms.cpp @@ -1,17 +1,17 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include @@ -22,13 +22,13 @@ #include "MsgTypes.h" #include "MsgMmsTypes.h" #include "MsgMmsMessage.h" -#include "MsgDebug.h" +#include "MsgDebug.h" #include "msg.h" #include "msg_private.h" //Internel Struct -typedef struct _MMS_DATA_S +typedef struct { GList *pagelist; GList *regionlist; @@ -37,24 +37,30 @@ typedef struct _MMS_DATA_S GList *metalist; MMS_SMIL_ROOTLAYOUT rootlayout; MMS_APPID_INFO_S msgAppId; + MMS_HEADER_DATA_S header; + MMS_MULTIPART_DATA_S smil; + GList *multipartlist;//MMS_MULTIPART_DATA_S } MMS_DATA_HIDDEN_S; 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; + char szContentType[MSG_MSG_ID_LEN + 1]; + char szContentLocation[MSG_MSG_ID_LEN + 1]; } MMS_MEDIA_HIDDEN_S; +static void __msg_mms_data_struct_init(MMS_DATA_HIDDEN_S *pMmsDataHidden); static void __msg_mms_release_mms(msg_struct_s *mms_struct); static void __msg_mms_release_page(msg_struct_s *page_struct); static void __msg_mms_release_media(msg_struct_s *media_struct); @@ -62,10 +68,32 @@ static void __msg_mms_release_region(msg_struct_s *region_struct); static void __msg_mms_release_attach(msg_struct_s *attach_struct); static void __msg_mms_release_transition(msg_struct_s *transition_struct); static void __msg_mms_release_meta(msg_struct_s *meta_struct); - +static void __msg_mms_release_multipart(msg_struct_s *multipart_struct); /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ +static void __removeLessGreaterMark(const char *szSrcID, char *szDest, int destSize) +{ + char szBuf[MSG_MSG_ID_LEN + 1] = {0, }; + int cLen = strlen(szSrcID); + + if (cLen == 0) + return; + + if (cLen > 1 && szSrcID[0] == '<' && szSrcID[cLen - 1] == '>') { + strncpy(szBuf, &szSrcID[1], cLen - 2); + szBuf[cLen - 2] = '\0'; + } else if (cLen > 1 && szSrcID[0] == '"' && szSrcID[cLen-1] == '"') { + strncpy(szBuf, &szSrcID[1], cLen - 2); + szBuf[cLen - 2] = '\0'; + } else { + strncpy(szBuf, szSrcID, cLen); + szBuf[cLen] = '\0'; + } + + snprintf(szDest, destSize, "%s", szBuf); +} + static inline void *get_msg_struct_data(msg_struct_s *msg_struct) { if (msg_struct == NULL) @@ -94,6 +122,7 @@ void *msg_mms_create_struct_data(int field) case MSG_STRUCT_MMS: data = (void *)new MMS_DATA_HIDDEN_S; bzero(data, sizeof(MMS_DATA_HIDDEN_S)); + __msg_mms_data_struct_init((MMS_DATA_HIDDEN_S *)data); break; case MSG_STRUCT_MMS_PAGE: data = (void *)new MMS_PAGE_S; @@ -134,6 +163,11 @@ void *msg_mms_create_struct_data(int field) data = (void *)new MmsSmilAVI; bzero(data, sizeof(MmsSmilAVI)); break; + case MSG_STRUCT_MULTIPART_INFO: + data = new MMS_MULTIPART_DATA_S; + bzero(data, sizeof(MMS_MULTIPART_DATA_S)); + MsgMmsInitMultipart((MMS_MULTIPART_DATA_S *)data); + break; } return data; @@ -154,81 +188,120 @@ void msg_mms_list_item_free_func(gpointer data) __msg_mms_release_transition(msg_struct); } else if (msg_struct->type == MSG_STRUCT_MMS_META) { __msg_mms_release_meta(msg_struct); + } else if (msg_struct->type == MSG_STRUCT_MULTIPART_INFO) { + __msg_mms_release_multipart(msg_struct); } } void __msg_mms_release_page(msg_struct_s *page_struct) { - MMS_PAGE_S *page = (MMS_PAGE_S *)page_struct->data; - if (page->medialist) { - g_list_free_full(page->medialist, msg_mms_list_item_free_func); - } + if (page_struct) { + MMS_PAGE_S *page = (MMS_PAGE_S *)page_struct->data; + + if (page) { + if (page->medialist) { + g_list_free_full(page->medialist, msg_mms_list_item_free_func); + } - delete (MMS_PAGE_S *)page; - page_struct->data = NULL; + delete (MMS_PAGE_S *)page; + page_struct->data = NULL; + } - delete page_struct; + delete page_struct; + } } void __msg_mms_release_media(msg_struct_s *media_struct) { - MMS_MEDIA_HIDDEN_S *media = (MMS_MEDIA_HIDDEN_S *)media_struct->data; + if (media_struct) { + MMS_MEDIA_HIDDEN_S *media = (MMS_MEDIA_HIDDEN_S *)media_struct->data; - if (media->pText) - msg_mms_release_struct(&media->pText); + if (media) { + if (media->pText) + msg_mms_release_struct(&media->pText); - if (media->pAVI) - msg_mms_release_struct(&media->pAVI); + if (media->pAVI) + msg_mms_release_struct(&media->pAVI); - delete (MMS_MEDIA_HIDDEN_S *)media; + delete (MMS_MEDIA_HIDDEN_S *)media; - media_struct->data = NULL; + media_struct->data = NULL; + } - delete media_struct; + delete media_struct; + } } void __msg_mms_release_attach(msg_struct_s *attach_struct) { - MMS_ATTACH_S *attach = (MMS_ATTACH_S *)attach_struct->data; + if (attach_struct) { + MMS_ATTACH_S *attach = (MMS_ATTACH_S *)attach_struct->data; - delete (MMS_ATTACH_S *)attach; + if (attach) + delete (MMS_ATTACH_S *)attach; - attach_struct->data = NULL; + attach_struct->data = NULL; - delete attach_struct; + delete attach_struct; + } } void __msg_mms_release_region(msg_struct_s *region_struct) { - MMS_SMIL_REGION *region = (MMS_SMIL_REGION *)region_struct->data; + if (region_struct) { + MMS_SMIL_REGION *region = (MMS_SMIL_REGION *)region_struct->data; - delete (MMS_SMIL_REGION *)region; + if (region) + delete (MMS_SMIL_REGION *)region; - region_struct->data = NULL; + region_struct->data = NULL; - delete region_struct; + delete region_struct; + } } void __msg_mms_release_transition(msg_struct_s *transition_struct) { - MMS_SMIL_TRANSITION *transition = (MMS_SMIL_TRANSITION *)transition_struct->data; + if (transition_struct) { + MMS_SMIL_TRANSITION *transition = (MMS_SMIL_TRANSITION *)transition_struct->data; - delete (MMS_SMIL_TRANSITION *)transition; + if (transition) + delete (MMS_SMIL_TRANSITION *)transition; - transition_struct->data = NULL; + transition_struct->data = NULL; - delete transition_struct; + delete transition_struct; + } } void __msg_mms_release_meta(msg_struct_s *meta_struct) { - MMS_SMIL_META *meta = (MMS_SMIL_META *)meta_struct->data; + if (meta_struct) { + MMS_SMIL_META *meta = (MMS_SMIL_META *)meta_struct->data; - delete (MMS_SMIL_META *)meta; + if (meta) + delete (MMS_SMIL_META *)meta; - meta_struct->data = NULL; + meta_struct->data = NULL; - delete meta_struct; + delete meta_struct; + } +} + +void __msg_mms_release_multipart(msg_struct_s *multipart_struct) +{ + if (multipart_struct) { + MMS_MULTIPART_DATA_S *multipart = (MMS_MULTIPART_DATA_S *)multipart_struct->data; + + if (multipart) { + g_free(multipart->pMultipartData); multipart->pMultipartData = NULL; + delete (MMS_MULTIPART_DATA_S *)multipart; + } + + multipart_struct->data = NULL; + + delete multipart_struct; + } } void __msg_mms_release_mms(msg_struct_s *mms_struct) @@ -260,6 +333,16 @@ void __msg_mms_release_mms(msg_struct_s *mms_struct) mms->metalist = NULL; } + if (mms->multipartlist) { + g_list_free_full(mms->multipartlist, msg_mms_list_item_free_func); + mms->multipartlist = NULL; + } + + if (mms->smil.pMultipartData) { + g_free(mms->smil.pMultipartData); + mms->smil.pMultipartData = NULL; + } + delete (MMS_DATA_HIDDEN_S *)mms; mms_struct->data = NULL; @@ -303,16 +386,32 @@ int msg_mms_release_struct(msg_struct_s **msg_struct_data) *msg_struct_data = NULL; break; case MSG_STRUCT_MMS_SMIL_TEXT: - delete (MmsSmilText*)msg_struct->data; + if (msg_struct->data) { + delete (MmsSmilText*)msg_struct->data; + msg_struct->data = NULL; + } delete msg_struct; *msg_struct_data = NULL; break; case MSG_STRUCT_MMS_SMIL_AVI: - delete (MmsSmilAVI*)msg_struct->data; + if (msg_struct->data) { + delete (MmsSmilAVI*)msg_struct->data; + msg_struct->data = NULL; + } + delete msg_struct; + *msg_struct_data = NULL; + break; + case MSG_STRUCT_MULTIPART_INFO: + { + if (msg_struct->data) { + delete (MMS_MULTIPART_DATA_S *)(msg_struct->data); + msg_struct->data = NULL; + } delete msg_struct; *msg_struct_data = NULL; break; } + } return 0; } @@ -325,12 +424,39 @@ int msg_mms_get_int_value(msg_struct_s *msg_struct, int field, int *value) case MSG_STRUCT_MMS: { MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data; - if (field == MSG_MMS_ROOTLAYOUT_WIDTH_INT) + if (field == MSG_MMS_ROOTLAYOUT_WIDTH_INT) { *value = mms_data->rootlayout.width.value; - else if (field == MSG_MMS_ROOTLAYOUT_HEIGHT_INT) + } else if (field == MSG_MMS_ROOTLAYOUT_HEIGHT_INT) { *value = mms_data->rootlayout.height.value; - else if (field == MSG_MMS_ROOTLAYOUT_BGCOLOR_INT) + } else if (field == MSG_MMS_ROOTLAYOUT_BGCOLOR_INT) { *value = mms_data->rootlayout.bgColor; + } else if (field == MSG_MMS_HEADER_DATE_INT) { + *value = mms_data->header.date; + } else if (field == MSG_MMS_HEADER_DELIVERY_REPORT_INT) { + *value = mms_data->header.bDeliveryReport; + } else if (field == MSG_MMS_HEADER_DELIVERY_TIME_INT) { + *value = mms_data->header.delivery.time; + } else if (field == MSG_MMS_HEADER_EXPIRY_TIME_INT) { + *value = mms_data->header.expiry.time; + } else if (field == MSG_MMS_HEADER_MESSAGE_CLASS_INT) { + *value = mms_data->header.messageClass; + } else if (field == MSG_MMS_HEADER_MESSAGE_TYPE_INT) { + *value = mms_data->header.messageType; + } else if (field == MSG_MMS_HEADER_VERSION_INT) { + *value = mms_data->header.mmsVersion; + } else if (field == MSG_MMS_HEADER_SIZE_INT) { + *value = mms_data->header.messageSize; + } else if (field == MSG_MMS_HEADER_PRIORITY_INT) { + *value = mms_data->header.mmsPriority; + } else if (field == MSG_MMS_HEADER_READ_REPORT_INT) { + *value = mms_data->header.bReadReport; + } else if (field == MSG_MMS_HEADER_HIDE_ADDRESS_INT) { + *value = mms_data->header.bHideAddress; + } else if (field == MSG_MMS_HEADER_MMS_STATUS_INT) { + *value = mms_data->header.mmsStatus; + } else if (field == MSG_MMS_HEADER_CONTENT_CLASS_INT) { + *value = mms_data->header.contentClass; + } else err = MSG_ERR_INVALID_PARAMETER; } @@ -356,7 +482,7 @@ int msg_mms_get_int_value(msg_struct_s *msg_struct, int field, int *value) break; case MSG_STRUCT_MMS_MEDIA: { - MMS_MEDIA_S *mms_media_data = (MMS_MEDIA_S *)msg_struct->data; + MMS_MEDIA_HIDDEN_S *mms_media_data = (MMS_MEDIA_HIDDEN_S *)msg_struct->data; if (field == MSG_MMS_MEDIA_TYPE_INT) *value = mms_media_data->mediatype; else if (field == MSG_MMS_MEDIA_DRM_TYPE_INT) @@ -450,11 +576,15 @@ int msg_mms_get_int_value(msg_struct_s *msg_struct, int field, int *value) err = MSG_ERR_INVALID_PARAMETER; } break; + case MSG_STRUCT_MULTIPART_INFO: + err = msg_multipart_get_int_value(msg_struct->data, field, value); + break; + default : err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } int msg_mms_get_str_value(msg_struct_s *msg_struct, int field, char *value, int size) @@ -462,23 +592,57 @@ int msg_mms_get_str_value(msg_struct_s *msg_struct, int field, char *value, int msg_error_t err = MSG_SUCCESS; switch(msg_struct->type) { + case MSG_STRUCT_MMS: + { + MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data; + if (field == MSG_MMS_HEADER_CONTENT_LOCATION_STR) {// mms header + strncpy(value, mms_data->header.contentLocation, size); + } else if (field == MSG_MMS_HEADER_CONTENT_TYPE_STR) { + strncpy(value, mms_data->header.szContentType, size); + } else if (field == MSG_MMS_HEADER_FROM_STR) { + strncpy(value, mms_data->header.szFrom, size); + } else if (field == MSG_MMS_HEADER_MESSAGE_ID_STR) { + strncpy(value, mms_data->header.messageID, size); + } else if (field == MSG_MMS_HEADER_TR_ID_STR) { + strncpy(value, mms_data->header.trID, size); + + } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_TYPE_STR) { // smil + strncpy(value, mms_data->smil.szContentType, size); + } else if (field == MSG_MMS_SMIL_MULTIPART_NAME_STR) { + strncpy(value, mms_data->smil.szFileName, size); + } else if (field == MSG_MMS_SMIL_MULTIPART_FILEPATH_STR) { + strncpy(value, mms_data->smil.szFilePath, size); + } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_ID_STR) { + strncpy(value, mms_data->smil.szContentID, size); + } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_LOCATION_STR) { + strncpy(value, mms_data->smil.szContentLocation, size); + } + else + err = MSG_ERR_INVALID_PARAMETER; + } + break; case MSG_STRUCT_MMS_MEDIA: { - MMS_MEDIA_S *mms_media_data = (MMS_MEDIA_S *)msg_struct->data; + MMS_MEDIA_HIDDEN_S *mms_media_data = (MMS_MEDIA_HIDDEN_S *)msg_struct->data; if (field == MSG_MMS_MEDIA_SRC_STR) strncpy(value, mms_media_data->szSrc, size); else if (field == MSG_MMS_MEDIA_FILENAME_STR) strncpy(value, mms_media_data->szFileName, size); else if (field == MSG_MMS_MEDIA_FILEPATH_STR) strncpy(value, mms_media_data->szFilePath, size); - else if (field == MSG_MMS_MEDIA_CONTENT_ID_STR) - strncpy(value, mms_media_data->szContentID, size); - else if (field == MSG_MMS_MEDIA_REGION_ID_STR) + else if (field == MSG_MMS_MEDIA_CONTENT_ID_STR) { + if (strlen(mms_media_data->szContentID) > 0) + snprintf(value, size, "<%s>", mms_media_data->szContentID); + }else if (field == MSG_MMS_MEDIA_REGION_ID_STR) strncpy(value, mms_media_data->regionId, size); else if (field == MSG_MMS_MEDIA_ALTERNATIVE_STR) strncpy(value, mms_media_data->szAlt, size); else if (field == MSG_MMS_MEDIA_DRM_FULLPATH_STR) strncpy(value, mms_media_data->szDrm2FullPath, size); + else if (field == MSG_MMS_MEDIA_CONTENT_LOCATION_STR) + strncpy(value, mms_media_data->szContentLocation, size); + else if (field == MSG_MMS_MEDIA_CONTENT_TYPE_STR) + strncpy(value, mms_media_data->szContentType, size); else err = MSG_ERR_INVALID_PARAMETER; } @@ -492,6 +656,8 @@ int msg_mms_get_str_value(msg_struct_s *msg_struct, int field, char *value, int strncpy(value, mms_attach_data->szFilePath, size); else if (field == MSG_MMS_ATTACH_DRM_FULLPATH_STR) strncpy(value, mms_attach_data->szDrm2FullPath, size); + else if (field == MSG_MMS_ATTACH_CONTENT_TYPE_STR) + strncpy(value, mms_attach_data->szContentType, size); else err = MSG_ERR_INVALID_PARAMETER; } @@ -549,11 +715,15 @@ int msg_mms_get_str_value(msg_struct_s *msg_struct, int field, char *value, int err = MSG_ERR_INVALID_PARAMETER; } break; + case MSG_STRUCT_MULTIPART_INFO: + err = msg_multipart_get_str_value(msg_struct->data, field, value, size); + break; + default : err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } int msg_mms_get_bool_value(msg_struct_s *msg_struct, int field, bool *value) @@ -568,6 +738,8 @@ int msg_mms_get_bool_value(msg_struct_s *msg_struct, int field, bool *value) *value = mms_data->rootlayout.width.bUnitPercent; else if (field == MSG_MMS_ROOTLAYOUT_HEIGHT_PERCENT_BOOL) *value = mms_data->rootlayout.height.bUnitPercent; + else if (field == MSG_MMS_ROOTLAYOUT_BGCOLOR_BOOL) + *value = mms_data->rootlayout.bBgColor; else err = MSG_ERR_INVALID_PARAMETER; } @@ -583,6 +755,8 @@ int msg_mms_get_bool_value(msg_struct_s *msg_struct, int field, bool *value) *value = mms_region_data->width.bUnitPercent; else if (field == MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL) *value = mms_region_data->height.bUnitPercent; + else if (field == MSG_MMS_REGION_BGCOLOR_BOOL) + *value = mms_region_data->bBgColor; else err = MSG_ERR_INVALID_PARAMETER; } @@ -606,7 +780,7 @@ int msg_mms_get_bool_value(msg_struct_s *msg_struct, int field, bool *value) err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } int msg_mms_get_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s **value) @@ -629,7 +803,7 @@ int msg_mms_get_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } int msg_mms_get_list_handle(msg_struct_s *msg_struct, int field, msg_list_handle_t *value) @@ -650,6 +824,8 @@ int msg_mms_get_list_handle(msg_struct_s *msg_struct, int field, msg_list_handle *value = (msg_list_handle_t)mms_data->transitionlist; else if (field == MSG_MMS_META_LIST_HND) *value = (msg_list_handle_t)mms_data->metalist; + else if (field == MSG_MMS_MULTIPART_LIST_HND) + *value = (msg_list_handle_t)mms_data->multipartlist; else err = MSG_ERR_INVALID_PARAMETER; } @@ -667,7 +843,7 @@ int msg_mms_get_list_handle(msg_struct_s *msg_struct, int field, msg_list_handle err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } /*SET*/ int msg_mms_set_int_value(msg_struct_s *msg_struct, int field, int value) @@ -682,8 +858,36 @@ int msg_mms_set_int_value(msg_struct_s *msg_struct, int field, int value) mms_data->rootlayout.width.value = value; else if (field == MSG_MMS_ROOTLAYOUT_HEIGHT_INT) mms_data->rootlayout.height.value = value; - else if (field == MSG_MMS_ROOTLAYOUT_BGCOLOR_INT) + else if (field == MSG_MMS_ROOTLAYOUT_BGCOLOR_INT) { + mms_data->rootlayout.bBgColor = true; mms_data->rootlayout.bgColor = value; + } else if (field == MSG_MMS_HEADER_DATE_INT) { + mms_data->header.date = value; + } else if (field == MSG_MMS_HEADER_DELIVERY_REPORT_INT) { + mms_data->header.bDeliveryReport = (bool)value; + } else if (field == MSG_MMS_HEADER_DELIVERY_TIME_INT) { + mms_data->header.delivery.time = value; + } else if (field == MSG_MMS_HEADER_EXPIRY_TIME_INT) { + mms_data->header.expiry.time = value; + } else if (field == MSG_MMS_HEADER_MESSAGE_CLASS_INT) { + mms_data->header.messageClass = value; + } else if (field == MSG_MMS_HEADER_MESSAGE_TYPE_INT) { + mms_data->header.messageType = value; + } else if (field == MSG_MMS_HEADER_VERSION_INT) { + mms_data->header.mmsVersion = value; + } else if (field == MSG_MMS_HEADER_SIZE_INT) { + mms_data->header.messageSize = value; + } else if (field == MSG_MMS_HEADER_PRIORITY_INT) { + mms_data->header.mmsPriority = value; + } else if (field == MSG_MMS_HEADER_READ_REPORT_INT) { + mms_data->header.bReadReport = (bool)value; + } else if (field == MSG_MMS_HEADER_HIDE_ADDRESS_INT) { + mms_data->header.bHideAddress = value; + } else if (field == MSG_MMS_HEADER_MMS_STATUS_INT) { + mms_data->header.mmsStatus = value; + } else if (field == MSG_MMS_HEADER_CONTENT_CLASS_INT) { + mms_data->header.contentClass = value; + } else err = MSG_ERR_INVALID_PARAMETER; } @@ -709,7 +913,7 @@ int msg_mms_set_int_value(msg_struct_s *msg_struct, int field, int value) break; case MSG_STRUCT_MMS_MEDIA: { - MMS_MEDIA_S *mms_media_data = (MMS_MEDIA_S *)msg_struct->data; + MMS_MEDIA_HIDDEN_S *mms_media_data = (MMS_MEDIA_HIDDEN_S *)msg_struct->data; if (field == MSG_MMS_MEDIA_TYPE_INT) mms_media_data->mediatype = (MmsSmilMediaType)value; else if (field == MSG_MMS_MEDIA_DRM_TYPE_INT) @@ -742,9 +946,10 @@ int msg_mms_set_int_value(msg_struct_s *msg_struct, int field, int value) mms_region_data->width.value = value; else if (field == MSG_MMS_REGION_LENGTH_HEIGHT_INT) mms_region_data->height.value = value; - else if (field == MSG_MMS_REGION_BGCOLOR_INT) + else if (field == MSG_MMS_REGION_BGCOLOR_INT) { + mms_region_data->bBgColor = true; mms_region_data->bgColor = value; - else if (field == MSG_MMS_REGION_FIT_TYPE_INT) + } else if (field == MSG_MMS_REGION_FIT_TYPE_INT) mms_region_data->fit = (REGION_FIT_TYPE_T)value; else err = MSG_ERR_INVALID_PARAMETER; @@ -807,7 +1012,7 @@ int msg_mms_set_int_value(msg_struct_s *msg_struct, int field, int value) err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int size) @@ -817,36 +1022,40 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int switch(msg_struct->type) { case MSG_STRUCT_MMS_MEDIA: { - MMS_MEDIA_S *mms_media_data = (MMS_MEDIA_S *)msg_struct->data; + MMS_MEDIA_HIDDEN_S *mms_media_data = (MMS_MEDIA_HIDDEN_S *)msg_struct->data; if (field == MSG_MMS_MEDIA_SRC_STR) strncpy(mms_media_data->szSrc, value, MSG_FILEPATH_LEN_MAX); else if (field == MSG_MMS_MEDIA_FILENAME_STR) { strncpy(mms_media_data->szFileName, value, MSG_FILEPATH_LEN_MAX); } else if (field == MSG_MMS_MEDIA_FILEPATH_STR) { char *filename = NULL; - 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-1); - strncpy(mms_media_data->szContentID, filename + 1, MSG_MSG_ID_LEN); - } else { - strncpy(mms_media_data->szFileName, value + 1, MSG_FILENAME_LEN_MAX-1); - strncpy(mms_media_data->szContentID, value + 1, MSG_MSG_ID_LEN); - } - } else { - MSG_DEBUG("media file path is NULL"); - err = MSG_ERR_INVALID_PARAMETER; - } + if (value != NULL) { + MSG_SEC_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) + __removeLessGreaterMark(value, mms_media_data->szContentID, MSG_MSG_ID_LEN); + else if (field == MSG_MMS_MEDIA_REGION_ID_STR) strncpy(mms_media_data->regionId, value, MAX_SMIL_REGION_ID); else if (field == MSG_MMS_MEDIA_ALTERNATIVE_STR) strncpy(mms_media_data->szAlt, value, MAX_SMIL_ALT_LEN); else if (field == MSG_MMS_MEDIA_DRM_FULLPATH_STR) strncpy(mms_media_data->szDrm2FullPath, value, MSG_FILEPATH_LEN_MAX); + else if (field == MSG_MMS_MEDIA_CONTENT_LOCATION_STR) + strncpy(mms_media_data->szContentLocation, value, MSG_FILEPATH_LEN_MAX); + else if (field == MSG_MMS_MEDIA_CONTENT_TYPE_STR) + strncpy(mms_media_data->szContentType, value, MSG_FILEPATH_LEN_MAX); else err = MSG_ERR_INVALID_PARAMETER; } @@ -854,34 +1063,37 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int case MSG_STRUCT_MMS_ATTACH: { MMS_ATTACH_S *mms_attach_data = (MMS_ATTACH_S *)msg_struct->data; - if (field == MSG_MMS_ATTACH_FILENAME_STR) + if (field == MSG_MMS_ATTACH_FILENAME_STR) { strncpy(mms_attach_data->szFileName, value, MSG_FILENAME_LEN_MAX); - else if (field == MSG_MMS_ATTACH_FILEPATH_STR) { + } else if (field == MSG_MMS_ATTACH_FILEPATH_STR) { char *filename = NULL; char *filepath = value; - 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-1); - - filename = strrchr(filepath, '/'); - if (filename != NULL) { - strncpy(mms_attach_data->szFileName, filename + 1, MSG_FILENAME_LEN_MAX-1); - } else { - strncpy(mms_attach_data->szFileName, filepath, MSG_FILENAME_LEN_MAX-1); - } - - } else { - MSG_DEBUG("attach file path is NULL"); - err = MSG_ERR_INVALID_PARAMETER; - } - } else if (field == MSG_MMS_ATTACH_DRM_FULLPATH_STR) + if (filepath != NULL) { + MSG_SEC_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 + } else if (field == MSG_MMS_ATTACH_CONTENT_TYPE_STR) { + strncpy(mms_attach_data->szContentType, value, MSG_FILEPATH_LEN_MAX); + } else { err = MSG_ERR_INVALID_PARAMETER; + } } break; case MSG_STRUCT_MMS_REGION: @@ -908,9 +1120,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; } @@ -937,11 +1149,44 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int err = MSG_ERR_INVALID_PARAMETER; } break; + case MSG_STRUCT_MMS: + { + MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data; + if (field == MSG_MMS_HEADER_CONTENT_LOCATION_STR) {// mms header + strncpy(mms_data->header.contentLocation, value, sizeof(mms_data->header.contentLocation) - 1 ); + } else if (field == MSG_MMS_HEADER_CONTENT_TYPE_STR) { + strncpy(mms_data->header.szContentType, value, sizeof(mms_data->header.szContentType) - 1 ); + } else if (field == MSG_MMS_HEADER_FROM_STR) { + strncpy(mms_data->header.szFrom, value, sizeof(mms_data->header.szFrom) - 1 ); + } else if (field == MSG_MMS_HEADER_MESSAGE_ID_STR) { + strncpy(mms_data->header.messageID, value, sizeof(mms_data->header.messageID) - 1 ); + } else if (field == MSG_MMS_HEADER_TR_ID_STR) { + strncpy(mms_data->header.trID, value, sizeof(mms_data->header.trID) - 1 ); + + } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_TYPE_STR) { // smil + strncpy(mms_data->smil.szContentType, value, sizeof(mms_data->smil.szContentType) - 1 ); + } else if (field == MSG_MMS_SMIL_MULTIPART_NAME_STR) { + strncpy(mms_data->smil.szFileName, value, sizeof(mms_data->smil.szFileName) - 1 ); + } else if (field == MSG_MMS_SMIL_MULTIPART_FILEPATH_STR) { + strncpy(mms_data->smil.szFilePath, value, sizeof(mms_data->smil.szFilePath) - 1 ); + } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_ID_STR) { + strncpy(mms_data->smil.szContentID, value, sizeof(mms_data->smil.szContentID) - 1 ); + } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_LOCATION_STR) { + strncpy(mms_data->smil.szContentLocation, value, sizeof(mms_data->smil.szContentLocation) - 1 ); + } + else + err = MSG_ERR_INVALID_PARAMETER; + } + break; + case MSG_STRUCT_MULTIPART_INFO: + err = msg_multipart_set_str_value(msg_struct->data, field, value, size); + break; + default : err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } int msg_mms_set_bool_value(msg_struct_s *msg_struct, int field, bool value) @@ -994,7 +1239,7 @@ int msg_mms_set_bool_value(msg_struct_s *msg_struct, int field, bool value) err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } int msg_mms_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value) @@ -1018,7 +1263,7 @@ int msg_mms_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } int msg_mms_set_list_handle(msg_struct_s *msg_struct, int field, msg_list_handle_t value) @@ -1056,16 +1301,15 @@ int msg_mms_set_list_handle(msg_struct_s *msg_struct, int field, msg_list_handle err = MSG_ERR_INVALID_PARAMETER; break; } - return MSG_SUCCESS; + return err; } -EXPORT_API int msg_mms_add_item(msg_struct_t msg_struct_handle, int field, msg_struct_t *item) +int msg_mms_list_append(msg_struct_t msg_struct_handle, int field, msg_struct_t *item) { msg_error_t err = MSG_SUCCESS; msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle; msg_struct_s *msg_struct_item = NULL; - void *data = NULL; switch(msg_struct->type) { case MSG_STRUCT_MMS: { @@ -1073,25 +1317,29 @@ EXPORT_API int msg_mms_add_item(msg_struct_t msg_struct_handle, int field, msg_s MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data; if (field == MSG_STRUCT_MMS_PAGE) { - msg_struct_item = msg_mms_create_struct(field); + msg_struct_item = msg_mms_create_struct(MSG_STRUCT_MMS_PAGE); mms_data->pagelist = g_list_append(mms_data->pagelist, msg_struct_item); *item = (msg_struct_t)msg_struct_item; } else if (field == MSG_STRUCT_MMS_REGION) { - msg_struct_item = msg_mms_create_struct(field); + msg_struct_item = msg_mms_create_struct(MSG_STRUCT_MMS_REGION); mms_data->regionlist = g_list_append(mms_data->regionlist, msg_struct_item); *item = (msg_struct_t)msg_struct_item; } else if (field == MSG_STRUCT_MMS_ATTACH) { - msg_struct_item = msg_mms_create_struct(field); + msg_struct_item = msg_mms_create_struct(MSG_STRUCT_MMS_ATTACH); mms_data->attachlist = g_list_append(mms_data->attachlist, msg_struct_item); *item = (msg_struct_t)msg_struct_item; } else if (field == MSG_STRUCT_MMS_TRANSITION) { - msg_struct_item = msg_mms_create_struct(field); + msg_struct_item = msg_mms_create_struct(MSG_STRUCT_MMS_TRANSITION); mms_data->transitionlist = g_list_append(mms_data->transitionlist, msg_struct_item); *item = (msg_struct_t)msg_struct_item; } else if (field == MSG_STRUCT_MMS_META) { - msg_struct_item = msg_mms_create_struct(field); + msg_struct_item = msg_mms_create_struct(MSG_STRUCT_MMS_META); mms_data->metalist = g_list_append(mms_data->metalist, msg_struct_item); *item = (msg_struct_t)msg_struct_item; + } else if (field == MSG_MMS_MULTIPART_LIST_HND) { + msg_struct_item = (msg_struct_s *)msg_create_struct(MSG_STRUCT_MULTIPART_INFO); + mms_data->multipartlist = g_list_append(mms_data->multipartlist, msg_struct_item); + *item = (msg_struct_t)msg_struct_item; } else { err = MSG_ERR_INVALID_PARAMETER; } @@ -1128,11 +1376,12 @@ 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); - memcpy(dst_media->szDrm2FullPath, src_media->szDrm2FullPath, MSG_FILEPATH_LEN_MAX); + memcpy(dst_media->szContentType, src_media->szContentType, MSG_MSG_ID_LEN); + memcpy(dst_media->szContentLocation, src_media->szContentLocation, MSG_MSG_ID_LEN); dst_media->drmType = src_media->drmType; if (src_media->mediatype == MMS_SMIL_MEDIA_TEXT) { @@ -1155,11 +1404,12 @@ 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); - memcpy(dst_media->szDrm2FullPath, src_media->szDrm2FullPath, MSG_FILEPATH_LEN_MAX); + memcpy(dst_media->szContentType, src_media->szContentType, MSG_MSG_ID_LEN); + memcpy(dst_media->szContentLocation, src_media->szContentLocation, MSG_MSG_ID_LEN); dst_media->drmType = src_media->drmType; if (src_media->mediatype == MMS_SMIL_MEDIA_TEXT) { @@ -1182,17 +1432,104 @@ void convert_to_mmsdata(const msg_struct_s *pSrc, MMS_MESSAGE_DATA_S *pDest) for (i = 0; i < pDest->pageCnt; i++) { MMS_PAGE_S *page = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S)); - MMS_PAGE_S *src_page = (MMS_PAGE_S *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->pagelist, i)); + if (page) { + MMS_PAGE_S *src_page = (MMS_PAGE_S *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->pagelist, i)); + page->mediaCnt = g_list_length(src_page->medialist); + + for (j = 0; j < page->mediaCnt; j++) + { + MMS_MEDIA_S *dst_media = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S)); + msg_struct_s *src_media_s = (msg_struct_s *)g_list_nth_data(src_page->medialist, j); + + if (dst_media) + convert_to_media_data(src_media_s, dst_media); + + page->medialist = g_list_append(page->medialist, dst_media); + } + + page->nDur = src_page->nDur; + page->nBegin = src_page->nBegin; + page->nEnd = src_page->nEnd; + page->nMin = src_page->nMin; + page->nMax = src_page->nMax; + page->nRepeat = src_page->nRepeat; + + pDest->pagelist = g_list_append(pDest->pagelist, page); + } + } + + pDest->regionCnt = g_list_length(pSrcMms->regionlist); + + for (i = 0; i < pDest->regionCnt; i++) { + MMS_SMIL_REGION *region = (MMS_SMIL_REGION *)calloc(1, sizeof(MMS_SMIL_REGION)); + if (region) { + MMS_SMIL_REGION *src_region = (MMS_SMIL_REGION *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->regionlist, i)); + memcpy(region, src_region, sizeof(MMS_SMIL_REGION)); + pDest->regionlist = g_list_append(pDest->regionlist, region); + } + } + + pDest->attachCnt = g_list_length(pSrcMms->attachlist); + + for (i = 0; i < pDest->attachCnt; i++) { + MMS_ATTACH_S *attach = (MMS_ATTACH_S *)calloc(1, sizeof(MMS_ATTACH_S)); + if (attach) { + MMS_ATTACH_S *src_attach = (MMS_ATTACH_S *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->attachlist, i)); + memcpy(attach, src_attach, sizeof(MMS_ATTACH_S)); + pDest->attachlist = g_list_append(pDest->attachlist, attach); + } + } + + pDest->transitionCnt = g_list_length(pSrcMms->transitionlist); + + for (i = 0; i < pDest->transitionCnt; i++) { + MMS_SMIL_TRANSITION *transition = (MMS_SMIL_TRANSITION *)calloc(1, sizeof(MMS_SMIL_TRANSITION)); + if (transition) { + MMS_SMIL_TRANSITION *src_transition = (MMS_SMIL_TRANSITION *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->transitionlist, i)); + memcpy(transition, src_transition, sizeof(MMS_SMIL_TRANSITION)); + pDest->transitionlist = g_list_append(pDest->transitionlist, transition); + } + } + + pDest->metaCnt = g_list_length(pSrcMms->metalist); + + for (i = 0; i < pDest->metaCnt; i++) { + MMS_SMIL_META *meta = (MMS_SMIL_META *)calloc(1, sizeof(MMS_SMIL_META)); + if (meta) { + MMS_SMIL_META *src_meta = (MMS_SMIL_META *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->metalist, i)); + memcpy(meta, src_meta, sizeof(MMS_SMIL_META)); + pDest->metalist = g_list_append(pDest->metalist, meta); + } + } + + memcpy(&pDest->rootlayout, &pSrcMms->rootlayout, sizeof(MMS_SMIL_ROOTLAYOUT)); + + memcpy(&pDest->msgAppId, &pSrcMms->msgAppId, sizeof(MMS_APPID_INFO_S)); + memcpy(&pDest->header, &pSrcMms->header, sizeof(MMS_HEADER_DATA_S)); + memcpy(&pDest->smil, &pSrcMms->smil, sizeof(MMS_MULTIPART_DATA_S)); +} + +void convert_from_mmsdata(const MMS_MESSAGE_DATA_S *pSrc, msg_struct_s *pDest) +{ + int i, j; + MMS_DATA_HIDDEN_S *pDestMms = (MMS_DATA_HIDDEN_S *)pDest->data; + + for (i = 0; i < pSrc->pageCnt; i++) { + msg_struct_s *page_struct = msg_mms_create_struct(MSG_STRUCT_MMS_PAGE); + MMS_PAGE_S *page = (MMS_PAGE_S *)page_struct->data; + + MMS_PAGE_S *src_page = (MMS_PAGE_S *)g_list_nth_data(pSrc->pagelist, i); page->mediaCnt = g_list_length(src_page->medialist); for (j = 0; j < page->mediaCnt; j++) { - MMS_MEDIA_S *dst_media = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S)); - msg_struct_s *src_media_s = (msg_struct_s *)g_list_nth_data(src_page->medialist, j); + msg_struct_s *dst_media_s = msg_mms_create_struct(MSG_STRUCT_MMS_MEDIA); - convert_to_media_data(src_media_s, dst_media); + MMS_MEDIA_S *src_media = (MMS_MEDIA_S *)g_list_nth_data(src_page->medialist, j); - page->medialist = g_list_append(page->medialist, dst_media); + convert_from_media_data(src_media, dst_media_s); + + page->medialist = g_list_append(page->medialist, dst_media_s); } page->nDur = src_page->nDur; @@ -1202,7 +1539,85 @@ void convert_to_mmsdata(const msg_struct_s *pSrc, MMS_MESSAGE_DATA_S *pDest) page->nMax = src_page->nMax; page->nRepeat = src_page->nRepeat; - pDest->pagelist = g_list_append(pDest->pagelist, page); + pDestMms->pagelist = g_list_append(pDestMms->pagelist, page_struct); + } + + for (i = 0; i < pSrc->regionCnt; i++) { + msg_struct_s *region_struct = msg_mms_create_struct(MSG_STRUCT_MMS_REGION); + MMS_SMIL_REGION *region = (MMS_SMIL_REGION *)region_struct->data; + MMS_SMIL_REGION *src_region = (MMS_SMIL_REGION *)g_list_nth_data(pSrc->regionlist, i); + memcpy(region, src_region, sizeof(MMS_SMIL_REGION)); + pDestMms->regionlist = g_list_append(pDestMms->regionlist, region_struct); + } + + for (i = 0; i < pSrc->attachCnt; i++) { + msg_struct_s *attach_struct = msg_mms_create_struct(MSG_STRUCT_MMS_ATTACH); + MMS_ATTACH_S *attach = (MMS_ATTACH_S *)attach_struct->data; + MMS_ATTACH_S *src_attach = (MMS_ATTACH_S *)g_list_nth_data(pSrc->attachlist, i); + memcpy(attach, src_attach, sizeof(MMS_ATTACH_S)); + pDestMms->attachlist = g_list_append(pDestMms->attachlist, attach_struct); + } + + for (i = 0; i < pSrc->transitionCnt; i++) { + msg_struct_s *transition_struct = msg_mms_create_struct(MSG_STRUCT_MMS_TRANSITION); + MMS_SMIL_TRANSITION *transition = (MMS_SMIL_TRANSITION *)transition_struct->data; + MMS_SMIL_TRANSITION *src_transition = (MMS_SMIL_TRANSITION *)g_list_nth_data(pSrc->transitionlist, i); + memcpy(transition, src_transition, sizeof(MMS_SMIL_TRANSITION)); + pDestMms->transitionlist = g_list_append(pDestMms->transitionlist, transition_struct); + } + + for (i = 0; i < pSrc->metaCnt; i++) { + msg_struct_s *meta_struct = msg_mms_create_struct(MSG_STRUCT_MMS_META); + MMS_SMIL_META *meta = (MMS_SMIL_META *)meta_struct->data; + MMS_SMIL_META *src_meta = (MMS_SMIL_META *)g_list_nth_data(pSrc->metalist, i); + + memcpy(meta, src_meta, sizeof(MMS_SMIL_META)); + pDestMms->metalist = g_list_append(pDestMms->metalist, meta_struct); + } + + memcpy(&pDestMms->rootlayout, &pSrc->rootlayout, sizeof(MMS_SMIL_ROOTLAYOUT)); + + memcpy(&pDestMms->msgAppId, &pSrc->msgAppId, sizeof(MMS_APPID_INFO_S)); + + memcpy(&pDestMms->header, &pSrc->header, sizeof(MMS_HEADER_DATA_S)); + memcpy(&pDestMms->smil, &pSrc->smil, sizeof(MMS_MULTIPART_DATA_S)); + +} + +void convert_to_mmsdata2(MMS_DATA_HIDDEN_S *pSrcMms, MMS_MESSAGE_DATA_S *pDest) +{ + int i, j; + //MMS_DATA_HIDDEN_S *pSrcMms = (MMS_DATA_HIDDEN_S *)pSrc->data; + + pDest->pageCnt = g_list_length(pSrcMms->pagelist); + + for (i = 0; i < pDest->pageCnt; i++) { + MMS_PAGE_S *page = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S)); + MMS_PAGE_S *src_page = (MMS_PAGE_S *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->pagelist, i)); + if (page) { + page->mediaCnt = g_list_length(src_page->medialist); + + for (j = 0; j < page->mediaCnt; j++) + { + MMS_MEDIA_S *dst_media = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S)); + msg_struct_s *src_media_s = (msg_struct_s *)g_list_nth_data(src_page->medialist, j); + + if (dst_media) { + convert_to_media_data(src_media_s, dst_media); + + page->medialist = g_list_append(page->medialist, dst_media); + } + } + + page->nDur = src_page->nDur; + page->nBegin = src_page->nBegin; + page->nEnd = src_page->nEnd; + page->nMin = src_page->nMin; + page->nMax = src_page->nMax; + page->nRepeat = src_page->nRepeat; + + pDest->pagelist = g_list_append(pDest->pagelist, page); + } } pDest->regionCnt = g_list_length(pSrcMms->regionlist); @@ -1210,8 +1625,10 @@ void convert_to_mmsdata(const msg_struct_s *pSrc, MMS_MESSAGE_DATA_S *pDest) for (i = 0; i < pDest->regionCnt; i++) { MMS_SMIL_REGION *region = (MMS_SMIL_REGION *)calloc(1, sizeof(MMS_SMIL_REGION)); MMS_SMIL_REGION *src_region = (MMS_SMIL_REGION *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->regionlist, i)); - memcpy(region, src_region, sizeof(MMS_SMIL_REGION)); - pDest->regionlist = g_list_append(pDest->regionlist, region); + if (region) { + memcpy(region, src_region, sizeof(MMS_SMIL_REGION)); + pDest->regionlist = g_list_append(pDest->regionlist, region); + } } pDest->attachCnt = g_list_length(pSrcMms->attachlist); @@ -1219,8 +1636,10 @@ void convert_to_mmsdata(const msg_struct_s *pSrc, MMS_MESSAGE_DATA_S *pDest) for (i = 0; i < pDest->attachCnt; i++) { MMS_ATTACH_S *attach = (MMS_ATTACH_S *)calloc(1, sizeof(MMS_ATTACH_S)); MMS_ATTACH_S *src_attach = (MMS_ATTACH_S *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->attachlist, i)); - memcpy(attach, src_attach, sizeof(MMS_ATTACH_S)); - pDest->attachlist = g_list_append(pDest->attachlist, attach); + if (attach) { + memcpy(attach, src_attach, sizeof(MMS_ATTACH_S)); + pDest->attachlist = g_list_append(pDest->attachlist, attach); + } } pDest->transitionCnt = g_list_length(pSrcMms->transitionlist); @@ -1228,8 +1647,10 @@ void convert_to_mmsdata(const msg_struct_s *pSrc, MMS_MESSAGE_DATA_S *pDest) for (i = 0; i < pDest->transitionCnt; i++) { MMS_SMIL_TRANSITION *transition = (MMS_SMIL_TRANSITION *)calloc(1, sizeof(MMS_SMIL_TRANSITION)); MMS_SMIL_TRANSITION *src_transition = (MMS_SMIL_TRANSITION *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->transitionlist, i)); - memcpy(transition, src_transition, sizeof(MMS_SMIL_TRANSITION)); - pDest->transitionlist = g_list_append(pDest->transitionlist, transition); + if (transition) { + memcpy(transition, src_transition, sizeof(MMS_SMIL_TRANSITION)); + pDest->transitionlist = g_list_append(pDest->transitionlist, transition); + } } pDest->metaCnt = g_list_length(pSrcMms->metalist); @@ -1237,19 +1658,23 @@ void convert_to_mmsdata(const msg_struct_s *pSrc, MMS_MESSAGE_DATA_S *pDest) for (i = 0; i < pDest->metaCnt; i++) { MMS_SMIL_META *meta = (MMS_SMIL_META *)calloc(1, sizeof(MMS_SMIL_META)); MMS_SMIL_META *src_meta = (MMS_SMIL_META *)get_msg_struct_data((msg_struct_s *)g_list_nth_data(pSrcMms->metalist, i)); - memcpy(meta, src_meta, sizeof(MMS_SMIL_META)); - pDest->metalist = g_list_append(pDest->metalist, meta); + if (meta) { + memcpy(meta, src_meta, sizeof(MMS_SMIL_META)); + pDest->metalist = g_list_append(pDest->metalist, meta); + } } memcpy(&pDest->rootlayout, &pSrcMms->rootlayout, sizeof(MMS_SMIL_ROOTLAYOUT)); memcpy(&pDest->msgAppId, &pSrcMms->msgAppId, sizeof(MMS_APPID_INFO_S)); + memcpy(&pDest->header, &pSrcMms->header, sizeof(MMS_HEADER_DATA_S)); + memcpy(&pDest->smil, &pSrcMms->smil, sizeof(MMS_MULTIPART_DATA_S)); } -void convert_from_mmsdata(const MMS_MESSAGE_DATA_S *pSrc, msg_struct_s *pDest) +void convert_from_mmsdata2(const MMS_MESSAGE_DATA_S *pSrc, MMS_DATA_HIDDEN_S *pDestMms) { int i, j; - MMS_DATA_HIDDEN_S *pDestMms = (MMS_DATA_HIDDEN_S *)pDest->data; + //MMS_DATA_HIDDEN_S *pDestMms = (MMS_DATA_HIDDEN_S *)pDest->data; for (i = 0; i < pSrc->pageCnt; i++) { msg_struct_s *page_struct = msg_mms_create_struct(MSG_STRUCT_MMS_PAGE); @@ -1315,4 +1740,186 @@ void convert_from_mmsdata(const MMS_MESSAGE_DATA_S *pSrc, msg_struct_s *pDest) memcpy(&pDestMms->rootlayout, &pSrc->rootlayout, sizeof(MMS_SMIL_ROOTLAYOUT)); memcpy(&pDestMms->msgAppId, &pSrc->msgAppId, sizeof(MMS_APPID_INFO_S)); + + memcpy(&pDestMms->header, &pSrc->header, sizeof(MMS_HEADER_DATA_S)); + memcpy(&pDestMms->smil, &pSrc->smil, sizeof(MMS_MULTIPART_DATA_S)); + +} + + +int msg_multipart_get_str_value(void *data, int field, char *value, int size) +{ + if (!data || !value) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + + MMS_MULTIPART_DATA_S *msg_data = (MMS_MULTIPART_DATA_S *)data; + + switch (field) { + case MSG_MMS_MULTIPART_CONTENT_TYPE_STR: + strncpy(value, msg_data->szContentType, size); + break; + case MSG_MMS_MULTIPART_NAME_STR: + strncpy(value, msg_data->szFileName, size); + break; + case MSG_MMS_MULTIPART_FILEPATH_STR: + strncpy(value, msg_data->szFilePath, size); + break; + case MSG_MMS_MULTIPART_THUMBNAIL_FILEPATH_STR: + strncpy(value, msg_data->szThumbFilePath, size); + break; + case MSG_MMS_MULTIPART_CONTENT_ID_STR: + strncpy(value, msg_data->szContentID, size); + break; + case MSG_MMS_MULTIPART_CONTENT_LOCATION_STR: + strncpy(value, msg_data->szContentLocation, size); + break; + + default : + ret = MSG_ERR_INVALID_PARAMETER; + break; + } + + return ret; +} + +int msg_multipart_get_int_value(void *data, int field, int *value) +{ + if (!data || !value) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + + MMS_MULTIPART_DATA_S *msg_data = (MMS_MULTIPART_DATA_S *)data; + + switch (field) { + case MSG_MMS_MULTIPART_TCS_LEVEL_INT: + *value = msg_data->tcs_bc_level; + break; + case MSG_MMS_MULTIPART_MALWARE_ALLOW_INT: + *value = msg_data->malware_allow; + break; + default : + ret = MSG_ERR_INVALID_PARAMETER; + break; + } + + return ret; +} + +int msg_multipart_set_str_value(void *data, int field, char *value, int size) +{ + if (!data || !value) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + + MMS_MULTIPART_DATA_S *msg_data = (MMS_MULTIPART_DATA_S *)data; + + //CID 41980: Reducing the size argument to strncpy calls to accomodate string termination '\0' in case source string is larger than size + switch (field) { + case MSG_MMS_MULTIPART_CONTENT_TYPE_STR: + strncpy(msg_data->szContentType, value, MSG_MSG_ID_LEN); + break; + case MSG_MMS_MULTIPART_NAME_STR: + strncpy(msg_data->szFileName, value, MSG_FILENAME_LEN_MAX); + break; + case MSG_MMS_MULTIPART_FILEPATH_STR: + strncpy(msg_data->szFilePath, value, MSG_FILEPATH_LEN_MAX); + break; + case MSG_MMS_MULTIPART_THUMBNAIL_FILEPATH_STR: + break; + case MSG_MMS_MULTIPART_CONTENT_ID_STR: + strncpy(msg_data->szContentID, value, MSG_MSG_ID_LEN); + break; + case MSG_MMS_MULTIPART_CONTENT_LOCATION_STR: + strncpy(msg_data->szContentLocation, value, MSG_MSG_ID_LEN); + break; + default : + ret = MSG_ERR_INVALID_PARAMETER; + break; + } + + return ret; +} +void convert_to_hidden_mmsdata(MMS_DATA_S *pSrc, msg_struct_s *pDest) +{ + MMS_DATA_HIDDEN_S *pDestMms = (MMS_DATA_HIDDEN_S *)pDest->data; + + MMS_MESSAGE_DATA_S *MmsMessageData = NULL; + unique_ptr buf(&MmsMessageData, unique_ptr_deleter); + MmsMessageData = (MMS_MESSAGE_DATA_S *)new char[sizeof(MMS_MESSAGE_DATA_S)]; + memset(MmsMessageData, 0x00, sizeof(MMS_MESSAGE_DATA_S)); + + MsgMmsConvertMmsDataToMmsMessageData(pSrc, MmsMessageData); + + convert_from_mmsdata2(MmsMessageData, pDestMms); + + MsgMmsReleaseMmsLists(MmsMessageData); + + if (pSrc->header) { + memcpy(&pDestMms->header, pSrc->header, sizeof(MMS_HEADER_DATA_S)); + } + + if (pSrc->smil) { + memcpy(&pDestMms->smil, pSrc->smil, sizeof(MMS_MULTIPART_DATA_S)); + pDestMms->smil.type = MIME_APPLICATION_SMIL; + pDestMms->smil.pMultipartData = (char *)calloc(1, pDestMms->smil.nMultipartDataLen+1); + if (pDestMms->smil.pMultipartData) + memcpy(pDestMms->smil.pMultipartData, pSrc->smil->pMultipartData,pDestMms->smil.nMultipartDataLen); + } + + if (pSrc->multipartlist) { + + int list_cnt = g_list_length(pSrc->multipartlist); + + for (int i = 0; i < list_cnt; i++) { + MMS_MULTIPART_DATA_S *src_multipart = (MMS_MULTIPART_DATA_S *)g_list_nth_data(pSrc->multipartlist, i); + + if (src_multipart) { + msg_struct_s *multipart_struct = (msg_struct_s *)msg_create_struct(MSG_STRUCT_MULTIPART_INFO); + + MMS_MULTIPART_DATA_S *dst_multipart = (MMS_MULTIPART_DATA_S*)multipart_struct->data; + + memcpy(dst_multipart, src_multipart, sizeof(MMS_MULTIPART_DATA_S)); + + pDestMms->multipartlist = g_list_append(pDestMms->multipartlist, multipart_struct); + } + } + } + +} + +void convert_from_hidden_mmsdata(msg_struct_s *pSrc, MMS_DATA_S *pDest) +{ + + MMS_DATA_HIDDEN_S *pSrcMms = (MMS_DATA_HIDDEN_S *)pSrc->data; + + MMS_MESSAGE_DATA_S *MmsMessageData = NULL; + unique_ptr buf(&MmsMessageData, unique_ptr_deleter); + MmsMessageData = (MMS_MESSAGE_DATA_S *)new char[sizeof(MMS_MESSAGE_DATA_S)]; + memset(MmsMessageData, 0x00, sizeof(MMS_MESSAGE_DATA_S)); + + convert_to_mmsdata2(pSrcMms, MmsMessageData); + + MsgMmsConvertMmsMessageDataToMmsData(MmsMessageData, pDest); + + MsgMmsReleaseMmsLists(MmsMessageData); +} + +void __msg_mms_data_struct_init(MMS_DATA_HIDDEN_S *pMmsDataHidden) +{ + if (pMmsDataHidden) { + pMmsDataHidden->pagelist = NULL; + pMmsDataHidden->regionlist = NULL; + pMmsDataHidden->attachlist = NULL; + pMmsDataHidden->transitionlist = NULL; + pMmsDataHidden->metalist = NULL; + + MsgMmsInitHeader(&pMmsDataHidden->header); + MsgMmsInitMultipart(&pMmsDataHidden->smil); + pMmsDataHidden->smil.type = MIME_APPLICATION_SMIL; + snprintf(pMmsDataHidden->smil.szContentType, sizeof(pMmsDataHidden->smil.szContentType), "%s", "application/smil"); + } } diff --git a/mapi/msg_setting.cpp b/mapi/msg_setting.cpp index 6240ef5..4538163 100755 --- a/mapi/msg_setting.cpp +++ b/mapi/msg_setting.cpp @@ -1,20 +1,21 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include +#include #include #include "MsgHandle.h" #include "MsgDebug.h" @@ -61,6 +62,9 @@ int msg_setting_get_int_value(msg_struct_s *msg_struct, int field, int *value) case MSG_STRUCT_SETTING_MSGSIZE_OPT : *value = msg_get_msgsize_opt_int(msg_struct->data, field); break; + case MSG_STRUCT_SETTING_VOICE_MSG_OPT : + *value = msg_get_voice_msg_opt_int(msg_struct->data, field); + break; default : err = MSG_ERR_INVALID_PARAMETER; break; @@ -192,6 +196,9 @@ int msg_setting_set_int_value(msg_struct_s *msg_struct, int field, int value) case MSG_STRUCT_SETTING_MSGSIZE_OPT : err = msg_set_msgsize_opt_int(msg_struct->data, field, value); break; + case MSG_STRUCT_SETTING_VOICE_MSG_OPT : + err = msg_set_voice_msg_opt_int(msg_struct->data, field, value); + break; default : err = MSG_ERR_INVALID_PARAMETER; break; @@ -260,12 +267,21 @@ int msg_setting_set_bool_value(msg_struct_s *msg_struct, int field, bool value) EXPORT_API int msg_get_smsc_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -285,12 +301,21 @@ EXPORT_API int msg_get_smsc_opt(msg_handle_t handle, msg_struct_t msg_struct) EXPORT_API int msg_set_smsc_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -343,6 +368,9 @@ int msg_get_smsc_opt_int(void *smsc_opt, int field) case MSG_SMSC_SELECTED_ID_INT : ret = smsc_opt_data->selected; break; + case MSG_SMSC_LIST_SIM_INDEX_INT : + ret = smsc_opt_data->simIndex; + break; default : return MSG_ERR_INVALID_PARAMETER; } @@ -362,7 +390,13 @@ 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; + case MSG_SMSC_LIST_INDEX_INT : + smsc_opt_data->index = value; + break; + case MSG_SMSC_LIST_SIM_INDEX_INT : + smsc_opt_data->simIndex = value; break; default : ret = MSG_ERR_INVALID_PARAMETER; @@ -486,12 +520,21 @@ int msg_set_smsc_info_str(void *smsc_info, int field, char *val, int size) EXPORT_API int msg_get_cb_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -511,12 +554,21 @@ EXPORT_API int msg_get_cb_opt(msg_handle_t handle, msg_struct_t msg_struct) EXPORT_API int msg_set_cb_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -548,6 +600,9 @@ int msg_get_cb_option_int(void *cb_opt, int field) case MSG_CB_MAX_SIM_COUNT_INT : ret = cb_opt_data->maxSimCnt; break; + case MSG_CB_SIM_INDEX_INT : + ret = cb_opt_data->simIndex; + break; default : ret = MSG_ERR_INVALID_PARAMETER; break; @@ -570,6 +625,9 @@ int msg_set_cb_option_int(void *cb_opt, int field, int value) case MSG_CB_MAX_SIM_COUNT_INT : cb_opt_data->maxSimCnt = value; break; + case MSG_CB_SIM_INDEX_INT : + cb_opt_data->simIndex = value; + break; default : ret = MSG_ERR_INVALID_PARAMETER; break; @@ -841,12 +899,21 @@ int msg_set_cb_channel_info_str(void *cb_ch_info, int field, char *val, int size EXPORT_API int msg_get_sms_send_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -866,12 +933,21 @@ EXPORT_API int msg_get_sms_send_opt(msg_handle_t handle, msg_struct_t msg_struct EXPORT_API int msg_set_sms_send_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -995,12 +1071,21 @@ int msg_set_sms_send_opt_bool(void *sms_send_opt, int field, bool value) EXPORT_API int msg_get_mms_send_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1020,12 +1105,21 @@ EXPORT_API int msg_get_mms_send_opt(msg_handle_t handle, msg_struct_t msg_struct EXPORT_API int msg_set_mms_send_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1210,12 +1304,21 @@ int msg_set_mms_send_opt_bool(void *mms_send_opt, int field, bool value) EXPORT_API int msg_get_mms_recv_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1235,12 +1338,21 @@ EXPORT_API int msg_get_mms_recv_opt(msg_handle_t handle, msg_struct_t msg_struct EXPORT_API int msg_set_mms_recv_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1370,11 +1482,20 @@ int msg_set_mms_recv_opt_bool(void *mms_recv_opt, int field, bool value) EXPORT_API int msg_get_push_msg_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1394,11 +1515,20 @@ EXPORT_API int msg_get_push_msg_opt(msg_handle_t handle, msg_struct_t msg_struct EXPORT_API int msg_set_push_msg_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1504,11 +1634,20 @@ int msg_set_push_msg_opt_bool(void *push_msg_opt, int field, bool value) EXPORT_API int msg_get_voice_msg_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1528,11 +1667,20 @@ EXPORT_API int msg_get_voice_msg_opt(msg_handle_t handle, msg_struct_t msg_struc EXPORT_API int msg_set_voice_msg_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1550,6 +1698,52 @@ EXPORT_API int msg_set_voice_msg_opt(msg_handle_t handle, msg_struct_t msg_struc return err; } +int msg_get_voice_msg_opt_int(void *voice_msg_opt, int field) +{ + if (!voice_msg_opt) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_ERR_INVALID_PARAMETER; + + MSG_VOICEMAIL_OPT_S *voice_opt = (MSG_VOICEMAIL_OPT_S *)voice_msg_opt; + + switch (field) + { + case MSG_VOICEMSG_SIM_INDEX_INT : + ret = voice_opt->simIndex; + break; + case MSG_VOICEMSG_VOICE_COUNT_INT : + ret = voice_opt->voiceCnt; + break; + default : + break; + } + + return ret; +} + +int msg_set_voice_msg_opt_int(void *voice_msg_opt, int field, int value) +{ + if (!voice_msg_opt) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + + MSG_VOICEMAIL_OPT_S *voice_opt = (MSG_VOICEMAIL_OPT_S *)voice_msg_opt; + + switch (field) + { + case MSG_VOICEMSG_SIM_INDEX_INT : + voice_opt->simIndex = value; + break; + default : + ret = MSG_ERR_INVALID_PARAMETER; + break; + } + + return ret; +} + char *msg_get_voice_msg_opt_str(void *voice_msg_opt, int field) { if (!voice_msg_opt) @@ -1564,6 +1758,9 @@ char *msg_get_voice_msg_opt_str(void *voice_msg_opt, int field) case MSG_VOICEMSG_ADDRESS_STR : ret_str = voice_opt->mailNumber; break; + case MSG_VOICEMSG_ALPHA_ID_STR : + ret_str = voice_opt->alpahId; + break; default : break; } @@ -1596,11 +1793,20 @@ int msg_set_voice_msg_opt_str(void *voice_msg_opt, int field, char *val, int siz EXPORT_API int msg_get_general_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1620,11 +1826,20 @@ EXPORT_API int msg_get_general_opt(msg_handle_t handle, msg_struct_t msg_struct) EXPORT_API int msg_set_general_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1656,6 +1871,15 @@ int msg_get_general_opt_int(void *general_opt, int field) case MSG_GENERAL_ALERT_TONE_INT : ret = opt->alertTone; break; + case MSG_GENERAL_SMS_LIMIT_CNT_INT : + ret = opt->smsLimitCnt; + break; + case MSG_GENERAL_MMS_LIMIT_CNT_INT : + ret = opt->mmsLimitCnt; + break; + case MSG_GENERAL_RINGTONE_TYPE_INT : + ret = opt->ringtoneType; + break; default : break; } @@ -1677,6 +1901,15 @@ int msg_set_general_opt_int(void *general_opt, int field, int value) case MSG_GENERAL_ALERT_TONE_INT : opt->alertTone = value; break; + case MSG_GENERAL_SMS_LIMIT_CNT_INT : + opt->smsLimitCnt = value; + break; + case MSG_GENERAL_MMS_LIMIT_CNT_INT : + opt->mmsLimitCnt = value; + break; + case MSG_GENERAL_RINGTONE_TYPE_INT : + opt->ringtoneType = value; + break; default : ret = MSG_ERR_INVALID_PARAMETER; break; @@ -1702,6 +1935,18 @@ bool msg_get_general_opt_bool(void *general_opt, int field) case MSG_GENERAL_AUTO_ERASE_BOOL : ret = opt->bAutoErase; break; + case MSG_GENERAL_BLOCK_UNKNOWN_NUMBER_BOOL : + ret = opt->bBlockUnknownMsg; + break; + case MSG_GENERAL_MSG_NOTIFICATION_BOOL : + ret = opt->bNotification; + break; + case MSG_GENERAL_MSG_VIBRATION_BOOL : + ret = opt->bVibration; + break; + case MSG_GENERAL_MSG_PREVIEW_BOOL : + ret = opt->bPreview; + break; default : break; } @@ -1726,6 +1971,62 @@ int msg_set_general_opt_bool(void *general_opt, int field, bool value) case MSG_GENERAL_AUTO_ERASE_BOOL : opt->bAutoErase = value; break; + case MSG_GENERAL_BLOCK_UNKNOWN_NUMBER_BOOL : + opt->bBlockUnknownMsg = value; + break; + case MSG_GENERAL_MSG_NOTIFICATION_BOOL : + opt->bNotification = value; + break; + case MSG_GENERAL_MSG_VIBRATION_BOOL : + opt->bVibration = value; + break; + case MSG_GENERAL_MSG_PREVIEW_BOOL : + opt->bPreview = value; + break; + default : + ret = MSG_ERR_INVALID_PARAMETER; + break; + } + + return ret; +} + +char *msg_get_general_opt_str(void *general_opt, int field) +{ + if (!general_opt) + return NULL; + + char *ret_str = NULL; + + MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt; + + switch (field) + { + case MSG_GENERAL_RINGTONE_PATH_STR : + ret_str = opt->ringtonePath; + break; + default : + break; + } + + return ret_str; +} + +int msg_set_general_opt_str(void *general_opt, int field, char *val, int size) +{ + if (!general_opt) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + + MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt; + + switch (field) + { + case MSG_GENERAL_RINGTONE_PATH_STR : + bzero(opt->ringtonePath, sizeof(opt->ringtonePath)); + snprintf(opt->ringtonePath, sizeof(opt->ringtonePath), "%s", val); + break; default : ret = MSG_ERR_INVALID_PARAMETER; break; @@ -1734,13 +2035,23 @@ int msg_set_general_opt_bool(void *general_opt, int field, bool value) return ret; } + EXPORT_API int msg_get_msgsize_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -1760,11 +2071,20 @@ EXPORT_API int msg_get_msgsize_opt(msg_handle_t handle, msg_struct_t msg_struct) EXPORT_API int msg_set_msgsize_opt(msg_handle_t handle, msg_struct_t msg_struct) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msg_struct == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; diff --git a/mapi/msg_storage.cpp b/mapi/msg_storage.cpp index c729773..2a90a66 100755 --- a/mapi/msg_storage.cpp +++ b/mapi/msg_storage.cpp @@ -1,20 +1,21 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include +#include #include "MsgHandle.h" #include "MsgDebug.h" @@ -25,17 +26,26 @@ #include "msg_storage.h" -static int msg_thread_get_msg_type(int mainType, int subType); +static int msg_get_msg_type(int mainType, int subType); /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ EXPORT_API int msg_add_message(msg_handle_t handle, msg_struct_t opq_msg, const msg_struct_t send_opt) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || opq_msg == NULL || send_opt == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -59,11 +69,20 @@ EXPORT_API int msg_add_message(msg_handle_t handle, msg_struct_t opq_msg, const EXPORT_API int msg_add_syncml_message(msg_handle_t handle, const msg_struct_t syncml_msg) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || syncml_msg == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -85,11 +104,20 @@ EXPORT_API int msg_add_syncml_message(msg_handle_t handle, const msg_struct_t sy EXPORT_API int msg_update_message(msg_handle_t handle, const msg_struct_t opq_msg, const msg_struct_t send_opt) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || opq_msg == NULL || send_opt == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -98,12 +126,6 @@ EXPORT_API int msg_update_message(msg_handle_t handle, const msg_struct_t opq_ms MSG_MESSAGE_HIDDEN_S *msg = (MSG_MESSAGE_HIDDEN_S *)pMsgStruct->data; - if (msg->addr_list->nCount > 1) - { - MSG_DEBUG("Multiple Address cannot be updated [%d]", msg->addr_list->nCount); - return -EINVAL; - } - try { err = pHandle->updateMessage(msg, (MSG_SENDINGOPT_S *)pStruct->data); @@ -120,11 +142,20 @@ EXPORT_API int msg_update_message(msg_handle_t handle, const msg_struct_t opq_ms EXPORT_API int msg_update_read_status(msg_handle_t handle, msg_message_id_t msg_id, bool read) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -143,13 +174,56 @@ EXPORT_API int msg_update_read_status(msg_handle_t handle, msg_message_id_t msg_ } +EXPORT_API int msg_set_conversation_to_read(msg_handle_t handle, msg_thread_id_t thread_id) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + MsgHandle* pHandle = (MsgHandle*)handle; + + try + { + err = pHandle->setConversationToRead(thread_id); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_STORAGE_ERROR; + } + + return err; +} + + EXPORT_API int msg_update_protected_status(msg_handle_t handle, msg_message_id_t msg_id, bool is_protected) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -167,14 +241,22 @@ EXPORT_API int msg_update_protected_status(msg_handle_t handle, msg_message_id_t return err; } - EXPORT_API int msg_delete_message(msg_handle_t handle, msg_message_id_t msg_id) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -195,11 +277,20 @@ EXPORT_API int msg_delete_message(msg_handle_t handle, msg_message_id_t msg_id) EXPORT_API int msg_delete_all_msgs_in_folder(msg_handle_t handle, msg_folder_id_t folder_id, bool bOnlyDB) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -218,13 +309,56 @@ EXPORT_API int msg_delete_all_msgs_in_folder(msg_handle_t handle, msg_folder_id_ } +EXPORT_API int msg_delete_msgs_by_list(msg_handle_t handle, msg_id_list_s *msg_id_list) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + MsgHandle* pHandle = (MsgHandle*)handle; + + try + { + err = pHandle->deleteMessagesByList(msg_id_list); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_STORAGE_ERROR; + } + + return err; +} + + EXPORT_API int msg_move_msg_to_folder(msg_handle_t handle, msg_message_id_t msg_id, msg_folder_id_t dest_folder_id) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -245,14 +379,23 @@ EXPORT_API int msg_move_msg_to_folder(msg_handle_t handle, msg_message_id_t msg_ EXPORT_API int msg_move_msg_to_storage(msg_handle_t handle, msg_message_id_t msg_id, msg_storage_id_t storage_id) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } - if (storage_id != MSG_STORAGE_PHONE && storage_id != MSG_STORAGE_SIM) + if (storage_id < MSG_STORAGE_PHONE || storage_id > MSG_STORAGE_SIM2) { MSG_FATAL("unsupported storage [%d]", storage_id); return MSG_ERR_INVALID_PARAMETER; @@ -276,11 +419,20 @@ EXPORT_API int msg_move_msg_to_storage(msg_handle_t handle, msg_message_id_t msg EXPORT_API int msg_count_message(msg_handle_t handle, msg_folder_id_t folder_id, msg_struct_t count_info) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -301,11 +453,20 @@ EXPORT_API int msg_count_message(msg_handle_t handle, msg_folder_id_t folder_id, EXPORT_API int msg_count_msg_by_type(msg_handle_t handle, msg_message_type_t msg_type, int *msg_count) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -344,11 +505,20 @@ EXPORT_API int msg_count_msg_by_type(msg_handle_t handle, msg_message_type_t msg EXPORT_API int msg_count_msg_by_contact(msg_handle_t handle, const msg_struct_t addr_info, msg_struct_t msg_thread_count_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || addr_info == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -371,12 +541,21 @@ EXPORT_API int msg_count_msg_by_contact(msg_handle_t handle, const msg_struct_t EXPORT_API int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t opq_msg, msg_struct_t send_opt) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || !opq_msg) { MSG_FATAL("handle or opq_msg is NULL"); - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -397,34 +576,65 @@ EXPORT_API int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg return err; } - -EXPORT_API int msg_get_folder_view_list(msg_handle_t handle, msg_folder_id_t folder_id, const msg_struct_t sort_rule, msg_struct_list_s *msg_folder_view_list) +EXPORT_API int msg_get_vobject_data(msg_handle_t handle, msg_message_id_t msg_id, void** result_data) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || result_data == NULL) { - return -EINVAL; + MSG_FATAL("handle or result_data is NULL"); + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; - msg_struct_s *pStruct = (msg_struct_s *)sort_rule; try { - if (sort_rule == NULL) - { - MSG_SORT_RULE_S sortRule = {0}; + err = pHandle->getVobject(msg_id, result_data); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_STORAGE_ERROR; + } - sortRule.sortType = MSG_SORT_BY_READ_STATUS; - sortRule.bAscending = true; + return err; +} - err = pHandle->getFolderViewList(folder_id, &sortRule, msg_folder_view_list); - } - else - { - err = pHandle->getFolderViewList(folder_id, (MSG_SORT_RULE_S *)pStruct->data, msg_folder_view_list); +EXPORT_API int msg_get_conversation(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t conv) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || !conv) + { + MSG_FATAL("handle or opq_msg is NULL"); + return MSG_ERR_INVALID_PARAMETER; } + + MsgHandle* pHandle = (MsgHandle*)handle; + + msg_struct_s *pMsgStruct = (msg_struct_s *)conv; + try + { + err = pHandle->getConversationViewItem(msg_id, (MSG_CONVERSATION_VIEW_S *)pMsgStruct->data); } catch (MsgException& e) { @@ -435,14 +645,22 @@ EXPORT_API int msg_get_folder_view_list(msg_handle_t handle, msg_folder_id_t fol return err; } - EXPORT_API int msg_get_thread_view_list(msg_handle_t handle, const msg_struct_t sort_rule, msg_struct_list_s *msg_thread_view_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -476,11 +694,20 @@ EXPORT_API int msg_get_thread_view_list(msg_handle_t handle, const msg_struct_t EXPORT_API int msg_get_conversation_view_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_list_s *msg_conv_view_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -499,20 +726,29 @@ EXPORT_API int msg_get_conversation_view_list(msg_handle_t handle, msg_thread_id } -EXPORT_API int msg_delete_thread_message_list(msg_handle_t handle, msg_thread_id_t thread_id) +EXPORT_API int msg_delete_thread_message_list(msg_handle_t handle, msg_thread_id_t thread_id, bool include_protected_msg) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->deleteThreadMessageList(thread_id); + err = pHandle->deleteThreadMessageList(thread_id, include_protected_msg); } catch (MsgException& e) { @@ -526,11 +762,20 @@ EXPORT_API int msg_delete_thread_message_list(msg_handle_t handle, msg_thread_id EXPORT_API int msg_add_folder(msg_handle_t handle, const msg_struct_t folder_info) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || folder_info == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -552,11 +797,20 @@ EXPORT_API int msg_add_folder(msg_handle_t handle, const msg_struct_t folder_inf EXPORT_API int msg_update_folder(msg_handle_t handle, const msg_struct_t folder_info) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || folder_info == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -578,11 +832,20 @@ EXPORT_API int msg_update_folder(msg_handle_t handle, const msg_struct_t folder_ EXPORT_API int msg_delete_folder(msg_handle_t handle, msg_folder_id_t folder_id) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -603,11 +866,20 @@ EXPORT_API int msg_delete_folder(msg_handle_t handle, msg_folder_id_t folder_id) EXPORT_API int msg_get_folder_list(msg_handle_t handle, msg_struct_list_s *folder_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -628,16 +900,25 @@ EXPORT_API int msg_get_folder_list(msg_handle_t handle, msg_struct_list_s *folde EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_type, msg_folder_id_t folder_id, unsigned int num_msg) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { MSG_DEBUG("Handle is NULL"); - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } if (folder_id >= MSG_MAX_FOLDER_ID) { MSG_DEBUG("folderId is invalid [%d]", folder_id); - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MSG_DEBUG("type : %d, folder : %d, num_msg : %d", msg_type, folder_id, num_msg); @@ -661,6 +942,9 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_ for (unsigned int i = 0; i < num_msg; i++) { msg_s = (msg_struct_s *)msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + if (msg_s == NULL) + return MSG_ERR_NOT_SUPPORTED; + msgInfo = (MSG_MESSAGE_HIDDEN_S *)msg_s->data; msgInfo->folderId = folder_id; @@ -691,7 +975,7 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_ addrInfo = (MSG_ADDRESS_INFO_S *)addr_s->data; addrInfo->addressType = MSG_ADDRESS_TYPE_PLMN; - postfix = rand()%10000; + postfix = random()%10000; snprintf(addrInfo->addressVal, MAX_ADDRESS_VAL_LEN+1, "%s%04d", prefix, postfix); addrInfo->recipientType = MSG_RECIPIENTS_TYPE_TO; @@ -758,134 +1042,119 @@ 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(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; } -EXPORT_API int msg_generate_sms(msg_handle_t handle, msg_folder_id_t folder_id, unsigned int num_msg) +EXPORT_API int msg_get_quick_panel_data(msg_handle_t handle, msg_quickpanel_type_t type, msg_struct_t opq_msg) { - MSG_DEBUG("folder %d, num_msg %d", folder_id, num_msg); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; - if (handle == NULL) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) { - MSG_DEBUG("Handle is NULL"); - return -EINVAL; + return MSG_ERR_PERMISSION_DENIED; } - if (folder_id >= MSG_MAX_FOLDER_ID) + if (handle == NULL || !opq_msg ) { - MSG_DEBUG("folderId is invalid"); - return -EINVAL; + MSG_FATAL("handle or opq_msg is NULL"); + return MSG_ERR_INVALID_PARAMETER; } - int err = 0; - char strMsg[20] = {0}; - char prefix[10] ="0103001"; - int postfix = 0; + MsgHandle* pHandle = (MsgHandle*)handle; + msg_struct_s *pMsg = (msg_struct_s *)opq_msg; - MSG_SENDINGOPT_S sendingOpt = {0}; - sendingOpt.bSetting = false; + try + { + err = pHandle->getQuickPanelData(type, (MSG_MESSAGE_HIDDEN_S *)pMsg->data); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_STORAGE_ERROR; + } - srand(getpid()); + return err; +} - msg_struct_s *msg_s = NULL; - msg_struct_s *addr_s = NULL; - MSG_MESSAGE_HIDDEN_S *msgInfo = NULL; - MSG_ADDRESS_INFO_S *addrInfo = NULL; - for (unsigned int i = 0; i < num_msg; i++) +EXPORT_API int msg_reset_database(msg_handle_t handle) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) { - msg_s = (msg_struct_s *)msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - msgInfo = (MSG_MESSAGE_HIDDEN_S *)msg_s->data; + return MSG_ERR_PERMISSION_DENIED; + } - msgInfo->msgId = 0; // It should be set 0 - msgInfo->folderId = folder_id; + if (handle == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } - msgInfo->mainType = MSG_SMS_TYPE; - msgInfo->subType = 0; + MsgHandle* pHandle = (MsgHandle*)handle; - msgInfo->storageId = MSG_STORAGE_PHONE; + try + { + err = pHandle->resetDatabase(); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_STORAGE_ERROR; + } - snprintf(strMsg, sizeof(strMsg), "test %d", i); - msgInfo->dataSize = strlen(strMsg); - msgInfo->pData = strMsg; + return err; +} - msgInfo->addr_list->nCount = 1; - addr_s = (msg_struct_s *)msgInfo->addr_list->msg_struct_info[0]; +EXPORT_API int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; - addrInfo = (MSG_ADDRESS_INFO_S *)addr_s->data; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } - addrInfo->addressType = MSG_ADDRESS_TYPE_PLMN; - postfix = rand()%10000; - snprintf(addrInfo->addressVal, MAX_ADDRESS_VAL_LEN+1, "%s%04d", prefix, postfix); + if (handle == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } - addrInfo->recipientType = MSG_RECIPIENTS_TYPE_TO; - - time(&(msgInfo->displayTime)); - - msgInfo->networkStatus = MSG_NETWORK_NOT_SEND; - msgInfo->bRead = false; - msgInfo->bProtected = false; - msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL; - msgInfo->direction = MSG_DIRECTION_TYPE_MO; - -// err = msg_add_message(handle, (msg_message_t) &msgInfo, &sendingOpt); - try - { - MsgHandle* pHandle = (MsgHandle*)handle; - err = pHandle->addMessage(msgInfo, &sendingOpt); - } - catch (MsgException& e) - { - MSG_FATAL("%s", e.what()); - return MSG_ERR_STORAGE_ERROR; - } - - if (err < 0) - { - MSG_DEBUG("err [%d]", err); - return err; - } - - msg_release_struct((msg_struct_t *)&msg_s); - } - - return MSG_SUCCESS; -} - - -EXPORT_API int msg_get_quick_panel_data(msg_handle_t handle, msg_quickpanel_type_t type, msg_struct_t opq_msg) -{ - msg_error_t err = MSG_SUCCESS; - - if (handle == NULL || !opq_msg ) - { - MSG_FATAL("handle or opq_msg is NULL"); - return -EINVAL; - } - - MsgHandle* pHandle = (MsgHandle*)handle; - msg_struct_s *pMsg = (msg_struct_s *)opq_msg; + MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->getQuickPanelData(type, (MSG_MESSAGE_HIDDEN_S *)pMsg->data); + err = pHandle->getMemSize(memsize); } catch (MsgException& e) { @@ -894,23 +1163,32 @@ EXPORT_API int msg_get_quick_panel_data(msg_handle_t handle, msg_quickpanel_type } return err; -} +} -EXPORT_API int msg_reset_database(msg_handle_t handle) +EXPORT_API int msg_backup_message(msg_handle_t handle, msg_message_backup_type_t type, const char *backup_filepath) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) { - return -EINVAL; + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || backup_filepath == NULL) + { + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->resetDatabase(); + err = pHandle->backupMessage(type, backup_filepath); } catch (MsgException& e) { @@ -922,20 +1200,29 @@ EXPORT_API int msg_reset_database(msg_handle_t handle) } -EXPORT_API int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize) +EXPORT_API int msg_restore_message(msg_handle_t handle, const char *backup_filepath) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || backup_filepath == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->getMemSize(memsize); + err = pHandle->restoreMessage(backup_filepath); } catch (MsgException& e) { @@ -944,23 +1231,37 @@ EXPORT_API int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize) } return err; - } -EXPORT_API int msg_backup_message(msg_handle_t handle) + +EXPORT_API int msg_search_message_for_thread_view(msg_handle_t handle, const char *search_string, msg_struct_list_s *msg_thread_view_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) { - return -EINVAL; + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || search_string == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + if (strlen(search_string) <= 0 || strlen(search_string) > MAX_MSG_TEXT_LEN) + { + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->backupMessage(); + err = pHandle->searchMessage(search_string, msg_thread_view_list); } catch (MsgException& e) { @@ -971,21 +1272,29 @@ EXPORT_API int msg_backup_message(msg_handle_t handle) return err; } - -EXPORT_API int msg_restore_message(msg_handle_t handle) +EXPORT_API int msg_get_reject_msg_list(msg_handle_t handle, const char *phone_num, msg_struct_list_s *msg_reject_msg_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->restoreMessage(); + err = pHandle->getRejectMsgList(phone_num, msg_reject_msg_list); } catch (MsgException& e) { @@ -997,51 +1306,65 @@ EXPORT_API int msg_restore_message(msg_handle_t handle) } -EXPORT_API int msg_search_message_for_thread_view(msg_handle_t handle, const char *search_string, msg_struct_list_s *msg_thread_view_list) +EXPORT_API int msg_reg_storage_change_callback(msg_handle_t handle, msg_storage_change_cb cb, void *user_param) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL || search_string == NULL) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) { - return -EINVAL; + return MSG_ERR_PERMISSION_DENIED; } - if (strlen(search_string) <= 0 || strlen(search_string) > MAX_MSG_TEXT_LEN) + if (handle == NULL || cb == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->searchMessage(search_string, msg_thread_view_list); + err = pHandle->regStorageChangeCallback(cb, user_param); } catch (MsgException& e) { MSG_FATAL("%s", e.what()); - return MSG_ERR_STORAGE_ERROR; + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; } return err; } - -EXPORT_API int msg_search_message(msg_handle_t handle, const msg_struct_t msg_search_conditions, int offset, int limit, msg_struct_list_s *msg_list) +EXPORT_API int msg_get_report_status(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_list_s *report_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL || msg_search_conditions == NULL) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || msg_id < 1 || report_list == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; - msg_struct_s *pStruct = (msg_struct_s *)msg_search_conditions; try { - err = pHandle->searchMessage((MSG_SEARCH_CONDITION_S *)pStruct->data, offset, limit, msg_list); + err = pHandle->getReportStatus(msg_id, report_list); } catch (MsgException& e) { @@ -1052,20 +1375,29 @@ EXPORT_API int msg_search_message(msg_handle_t handle, const msg_struct_t msg_se return err; } -EXPORT_API int msg_get_reject_msg_list(msg_handle_t handle, const char *phone_num, msg_struct_list_s *msg_reject_msg_list) +EXPORT_API int msg_get_address_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_list_s *msg_address_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->getRejectMsgList(phone_num, msg_reject_msg_list); + err = pHandle->getAddressList(thread_id, msg_address_list); } catch (MsgException& e) { @@ -1077,46 +1409,32 @@ EXPORT_API int msg_get_reject_msg_list(msg_handle_t handle, const char *phone_nu } -EXPORT_API int msg_reg_storage_change_callback(msg_handle_t handle, msg_storage_change_cb cb, void *user_param) +EXPORT_API int msg_get_thread_id_by_address(msg_handle_t handle, msg_struct_list_s *msg_address_list, msg_thread_id_t *thread_id) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL || cb == NULL) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) { - return -EINVAL; + return MSG_ERR_PERMISSION_DENIED; } - MsgHandle* pHandle = (MsgHandle*)handle; - - try - { - err = pHandle->regStorageChangeCallback(cb, user_param); - } - catch (MsgException& e) - { - MSG_FATAL("%s", e.what()); - return MSG_ERR_CALLBACK_ERROR; + if (handle == NULL || msg_address_list == NULL || thread_id == NULL) { + return MSG_ERR_INVALID_PARAMETER; } - return err; -} - - -EXPORT_API int msg_get_report_status(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t report_status) -{ - msg_error_t err = MSG_SUCCESS; - - if (handle == NULL || msg_id < 1) - { - return -EINVAL; + if (msg_address_list->nCount < 1 ) { + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; - msg_struct_s *pStruct = (msg_struct_s *)report_status; try { - err = pHandle->getReportStatus(msg_id, (MSG_REPORT_STATUS_INFO_S *)pStruct->data); + err = pHandle->getThreadIdByAddress(msg_address_list, thread_id); } catch (MsgException& e) { @@ -1127,20 +1445,30 @@ EXPORT_API int msg_get_report_status(msg_handle_t handle, msg_message_id_t msg_i return err; } -EXPORT_API int msg_get_address_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_list_s *msg_address_list) + +EXPORT_API int msg_get_thread_id_by_address2(msg_handle_t handle, msg_list_handle_t msg_address_list, msg_thread_id_t *thread_id) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || msg_address_list == NULL || thread_id == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->getAddressList(thread_id, msg_address_list); + err = pHandle->getThreadIdByAddress(msg_address_list, thread_id); } catch (MsgException& e) { @@ -1152,20 +1480,36 @@ EXPORT_API int msg_get_address_list(msg_handle_t handle, msg_thread_id_t thread_ } -EXPORT_API int msg_get_thread_id_by_address(msg_handle_t handle, msg_struct_list_s *msg_address_list, msg_thread_id_t *thread_id) +EXPORT_API int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_t msg_thread) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL || msg_address_list->nCount < 1) + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) { - return -EINVAL; + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || msg_thread == NULL ) { + MSG_FATAL("handle or msg_thread is NULL"); + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; + msg_struct_s *msgThread = (msg_struct_s *)msg_thread; + if (msgThread->type != MSG_STRUCT_THREAD_INFO) { + MSG_FATAL("Invaild type. type [%d]", msgThread->type); + return MSG_ERR_INVALID_PARAMETER; + } + + MSG_THREAD_VIEW_S* pThreadInfo = (MSG_THREAD_VIEW_S *)msgThread->data; try { - err = pHandle->getThreadIdByAddress(msg_address_list, thread_id); + err = pHandle->getThread(thread_id, pThreadInfo); } catch (MsgException& e) { @@ -1176,28 +1520,29 @@ EXPORT_API int msg_get_thread_id_by_address(msg_handle_t handle, msg_struct_list return err; } - -EXPORT_API int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_t msg_thread) +EXPORT_API int msg_get_message_list2(msg_handle_t handle, const msg_struct_t msg_list_conditions, msg_struct_list_s *msg_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; - if (handle == NULL || msg_thread == NULL ) { - MSG_FATAL("handle or msg_thread is NULL"); - return -EINVAL; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; } - MsgHandle* pHandle = (MsgHandle*)handle; - msg_struct_s *msgThread = (msg_struct_s *)msg_thread; - if (msgThread->type != MSG_STRUCT_THREAD_INFO) { - MSG_FATAL("Invaild type. type [%d]", msgThread->type); + if (handle == NULL) { return MSG_ERR_INVALID_PARAMETER; } - MSG_THREAD_VIEW_S* pThreadInfo = (MSG_THREAD_VIEW_S *)msgThread->data; + MsgHandle* pHandle = (MsgHandle*)handle; + msg_struct_s *pStruct = (msg_struct_s *)msg_list_conditions; try { - err = pHandle->getThread(thread_id, pThreadInfo); + err = pHandle->getMessageList((MSG_LIST_CONDITION_S *)pStruct->data, msg_list); } catch (MsgException& e) { @@ -1208,20 +1553,28 @@ EXPORT_API int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, ms return err; } - -EXPORT_API 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) +EXPORT_API int msg_get_media_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_list_handle_t *msg_list) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; try { - err = pHandle->getMessageList(folder_id, thread_id, msg_type, storage_id, msg_list); + err = pHandle->getMediaList(thread_id, msg_list); } catch (MsgException& e) { @@ -1229,28 +1582,48 @@ EXPORT_API int msg_get_message_list(msg_handle_t handle, msg_folder_id_t folder_ return MSG_ERR_STORAGE_ERROR; } + return err; } -static int msg_thread_get_msg_type(int mainType, int subType) +static int msg_get_msg_type(int mainType, int subType) { if (mainType == MSG_SMS_TYPE) { - if (subType == MSG_CB_SMS) - return MSG_TYPE_SMS_CB; - else if (subType == MSG_JAVACB_SMS) - return MSG_TYPE_SMS_JAVACB; - else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) - return MSG_TYPE_SMS_WAPPUSH; - else if (subType == MSG_MWI_VOICE_SMS || subType == MSG_MWI_FAX_SMS - || subType == MSG_MWI_EMAIL_SMS || subType == MSG_MWI_OTHER_SMS) - return MSG_TYPE_SMS_MWI; - else if (subType == MSG_SYNCML_CP) - return MSG_TYPE_SMS_SYNCML; - else if (subType == MSG_REJECT_SMS) - return MSG_TYPE_SMS_REJECT; - else - return MSG_TYPE_SMS; + switch (subType) { + case MSG_CB_SMS : + return MSG_TYPE_SMS_CB; + case MSG_JAVACB_SMS : + return MSG_TYPE_SMS_JAVACB; + case MSG_WAP_SI_SMS : + case MSG_WAP_SL_SMS : + return MSG_TYPE_SMS_WAPPUSH; + case MSG_MWI_VOICE_SMS : + case MSG_MWI_FAX_SMS : + case MSG_MWI_EMAIL_SMS : + case MSG_MWI_OTHER_SMS : + return MSG_TYPE_SMS_MWI; + case MSG_SYNCML_CP : + return MSG_TYPE_SMS_SYNCML; + case MSG_REJECT_SMS : + return MSG_TYPE_SMS_REJECT; + case MSG_ETWS_SMS : + return MSG_TYPE_SMS_ETWS_PRIMARY; + case MSG_CMAS_PRESIDENTIAL : + return MSG_TYPE_SMS_CMAS_PRESIDENTIAL; + case MSG_CMAS_EXTREME : + return MSG_TYPE_SMS_CMAS_EXTREME; + case MSG_CMAS_SEVERE : + return MSG_TYPE_SMS_CMAS_SEVERE; + case MSG_CMAS_AMBER : + return MSG_TYPE_SMS_CMAS_AMBER; + case MSG_CMAS_TEST : + return MSG_TYPE_SMS_CMAS_TEST; + case MSG_CMAS_OPERATOR_DEFINED : + return MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED; + default : + return MSG_TYPE_SMS; + } } else if (mainType == MSG_MMS_TYPE) { @@ -1268,7 +1641,7 @@ static int msg_thread_get_msg_type(int mainType, int subType) int msg_syncml_info_get_int(void *syncml_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_SYNCML_MESSAGE_S *pSync = (MSG_SYNCML_MESSAGE_S *)syncml_info; switch(field) { @@ -1279,7 +1652,7 @@ int msg_syncml_info_get_int(void *syncml_info, int field) result = pSync->pinCode; break; default: - result = -1; + result = MSG_ERR_INVALID_PARAMETER; break; } return result; @@ -1287,7 +1660,7 @@ int msg_syncml_info_get_int(void *syncml_info, int field) int msg_count_info_get_int(void *count_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_COUNT_INFO_S *pCount = (MSG_COUNT_INFO_S *)count_info; switch(field) { @@ -1304,7 +1677,7 @@ int msg_count_info_get_int(void *count_info, int field) result = pCount->nMms; break; default: - result = -1; + result = MSG_ERR_INVALID_PARAMETER; break; } return result; @@ -1312,7 +1685,7 @@ int msg_count_info_get_int(void *count_info, int field) int msg_thread_count_get_int(void *count_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_THREAD_COUNT_INFO_S *pCount = (MSG_THREAD_COUNT_INFO_S *)count_info; switch(field) { @@ -1329,7 +1702,7 @@ int msg_thread_count_get_int(void *count_info, int field) result = pCount->mmsMsgCount; break; default: - result = -1; + result = MSG_ERR_INVALID_PARAMETER; break; } return result; @@ -1337,7 +1710,7 @@ int msg_thread_count_get_int(void *count_info, int field) int msg_thread_index_get_int(void *index_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_THREAD_LIST_INDEX_S *pIndex = (MSG_THREAD_LIST_INDEX_S *)index_info; switch(field) { @@ -1345,7 +1718,7 @@ int msg_thread_index_get_int(void *index_info, int field) result = pIndex->contactId; break; default: - result = -1; + result = MSG_ERR_INVALID_PARAMETER; break; } return result; @@ -1353,7 +1726,7 @@ int msg_thread_index_get_int(void *index_info, int field) int msg_sortrule_get_int(void *sort_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_info; switch(field) { @@ -1361,7 +1734,7 @@ int msg_sortrule_get_int(void *sort_info, int field) result = pSort->sortType; break; default: - result = -1; + result = MSG_ERR_INVALID_PARAMETER; break; } return result; @@ -1369,7 +1742,7 @@ int msg_sortrule_get_int(void *sort_info, int field) int msg_folder_info_get_int(void *folder_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info; switch(field) { @@ -1380,7 +1753,7 @@ int msg_folder_info_get_int(void *folder_info, int field) result = pFolder->folderType; break; default: - result = -1; + result = MSG_ERR_INVALID_PARAMETER; break; } return result; @@ -1388,7 +1761,7 @@ int msg_folder_info_get_int(void *folder_info, int field) int msg_thread_info_get_int(void *data, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_THREAD_VIEW_S *pThread = (MSG_THREAD_VIEW_S *)data; switch(field) @@ -1397,7 +1770,7 @@ int msg_thread_info_get_int(void *data, int field) result = pThread->threadId; break; case MSG_THREAD_MSG_TYPE_INT : - result = msg_thread_get_msg_type(pThread->mainType, pThread->subType); + result = msg_get_msg_type(pThread->mainType, pThread->subType); break; case MSG_THREAD_MSG_TIME_INT : result = pThread->threadTime; @@ -1415,15 +1788,73 @@ int msg_thread_info_get_int(void *data, int field) result = pThread->mmsCnt; break; default: - result = -1; + result = MSG_ERR_INVALID_PARAMETER; + break; + } + return result; +} + + +int msg_conv_info_get_int(void *data, int field) +{ + int result = MSG_ERR_INVALID_PARAMETER; + MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S *)data; + + switch(field) + { + case MSG_CONV_MSG_ID_INT : + result = pConv->msgId; + break; + case MSG_CONV_MSG_THREAD_ID_INT : + result = pConv->threadId; + break; + case MSG_CONV_MSG_FOLDER_ID_INT : + result = pConv->folderId; + break; + case MSG_CONV_MSG_TYPE_INT : + result = msg_get_msg_type(pConv->mainType, pConv->subType); + break; + case MSG_CONV_MSG_STORAGE_ID_INT : + result = pConv->storageId; + break; + case MSG_CONV_MSG_DISPLAY_TIME_INT : + result = pConv->displayTime; + break; + case MSG_CONV_MSG_SCHEDULED_TIME_INT : + result = pConv->scheduledTime; + break; + case MSG_CONV_MSG_NETWORK_STATUS_INT : + result = pConv->networkStatus; + break; + case MSG_CONV_MSG_DIRECTION_INT : + result = pConv->direction; + break; + case MSG_CONV_MSG_ATTACH_COUNT_INT : + result = pConv->attachCount; + break; + case MSG_CONV_MSG_TEXT_SIZE_INT : + result = pConv->textSize; + break; + case MSG_CONV_MSG_PAGE_COUNT_INT : + result = pConv->pageCount; + break; + case MSG_CONV_MSG_TCS_BC_LEVEL_INT : + result = pConv->tcs_bc_level; + break; + case MSG_CONV_MSG_SIM_INDEX_INT : + result = pConv->simIndex; + break; + default: + result = MSG_ERR_INVALID_PARAMETER; break; } return result; } + int msg_search_condition_get_int(void *condition_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_SEARCH_CONDITION_S *pCond = (MSG_SEARCH_CONDITION_S *)condition_info; switch(field) { @@ -1437,32 +1868,89 @@ int msg_search_condition_get_int(void *condition_info, int field) result = pCond->reserved; break; default: - result = -1; + result = MSG_ERR_INVALID_PARAMETER; + break; + } + return result; +} + + +int msg_list_condition_get_int(void *condition_info, int field) +{ + int result = MSG_ERR_INVALID_PARAMETER; + MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)condition_info; + switch(field) + { + case MSG_LIST_CONDITION_FOLDER_ID_INT: + result = pCond->folderId; + break; + case MSG_LIST_CONDITION_THREAD_ID_INT: + result = pCond->threadId; + break; + case MSG_LIST_CONDITION_STORAGE_ID_INT: + result = pCond->storageId; + break; + case MSG_LIST_CONDITION_MSGTYPE_INT: + result = pCond->msgType; + break; + case MSG_LIST_CONDITION_FROM_TIME_INT: + result = pCond->fromTime; + break; + case MSG_LIST_CONDITION_TO_TIME_INT: + result = pCond->toTime; + break; + case MSG_LIST_CONDITION_OFFSET_INT: + result = pCond->offset; + break; + case MSG_LIST_CONDITION_LIMIT_INT: + result = pCond->limit; + break; + case MSG_LIST_CONDITION_SIM_INDEX_INT: + result = pCond->simIndex; + break; + default: + result = MSG_ERR_INVALID_PARAMETER; break; } return result; } + int msg_report_status_get_int(void *report_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_REPORT_STATUS_INFO_S *pReport = (MSG_REPORT_STATUS_INFO_S *)report_info; switch(field) { - case MSG_REPORT_STATUS_DELIVERY_STATUS_INT: - result = pReport->deliveryStatus; + case MSG_REPORT_TYPE_INT: + result = pReport->type; + break; + case MSG_REPORT_STATUS_INT: + result = pReport->status; break; - case MSG_REPORT_STATUS_DELIVERY_TIME_INT: - result = pReport->deliveryStatusTime; + case MSG_REPORT_TIME_INT: + result = pReport->statusTime; break; - case MSG_REPORT_STATUS_READ_STATUS_INT: - result = pReport->readStatus; + + default: + result = MSG_ERR_INVALID_PARAMETER; break; - case MSG_REPORT_STATUS_READ_TIME_INT: - result = pReport->readStatusTime; + } + return result; +} + +char* msg_report_status_get_str(void *report_info, int field) +{ + char *result = NULL; + MSG_REPORT_STATUS_INFO_S *pReport = (MSG_REPORT_STATUS_INFO_S *)report_info; + switch(field) + { + + case MSG_REPORT_ADDRESS_STR: + result = pReport->addressVal; break; + default: - result = -1; break; } return result; @@ -1504,6 +1992,43 @@ char *msg_thread_info_get_str(void *data, int field) return ret_str; } + +char *msg_conv_info_get_str(void *data, int field) +{ + char *ret_str = NULL; + MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S *)data; + + switch(field) + { + case MSG_CONV_MSG_SUBJECT_STR : + ret_str = pConv->subject; + break; + case MSG_CONV_MSG_ATTACH_NAME_STR : + ret_str = pConv->attachFileName; + break; + case MSG_CONV_MSG_AUDIO_NAME_STR : + ret_str = pConv->audioFileName; + break; + case MSG_CONV_MSG_IMAGE_THUMB_PATH_STR : + ret_str = pConv->imageThumbPath; + break; + case MSG_CONV_MSG_VIDEO_THUMB_PATH_STR : + ret_str = pConv->videoThumbPath; + break; + case MSG_CONV_MSG_TEXT_STR : + ret_str = pConv->pText; + break; + case MSG_CONV_MSG_1ST_MEDIA_PATH_STR : + ret_str = pConv->firstMediaPath; + break; + default: + break; + } + + return ret_str; +} + + char* msg_search_condition_get_str(void *condition_info, int field, int size) { char *result = NULL; @@ -1516,7 +2041,6 @@ char* msg_search_condition_get_str(void *condition_info, int field, int size) case MSG_SEARCH_CONDITION_SEARCH_VALUE_STR: result = search_cond->pSearchVal; break; - default: result = NULL; break; @@ -1524,17 +2048,38 @@ char* msg_search_condition_get_str(void *condition_info, int field, int size) return result; } -bool msg_sendopt_get_bool(void *send_opt, int field) + +char* msg_list_condition_get_str(void *condition_info, int field, int size) +{ + char *result = NULL; + MSG_LIST_CONDITION_S *cond = (MSG_LIST_CONDITION_S *)condition_info; + switch(field) + { + case MSG_LIST_CONDITION_ADDRESS_VALUE_STR: + result = cond->pAddressVal; + break; + case MSG_LIST_CONDITION_TEXT_VALUE_STR: + result = cond->pTextVal; + break; + default: + result = NULL; + break; + } + return result; +} + + +bool msg_sendopt_get_bool(void *send_opt, int field) { bool result = false; MSG_SENDINGOPT_S *sendopt = (MSG_SENDINGOPT_S *)send_opt; switch(field) { case MSG_SEND_OPT_SETTING_BOOL: - result = sendopt->bDeliverReq; + result = sendopt->bSetting; break; case MSG_SEND_OPT_KEEPCOPY_BOOL: - result = sendopt->bDeliverReq; + result = sendopt->bKeepCopy; break; case MSG_SEND_OPT_DELIVER_REQ_BOOL: result = sendopt->bDeliverReq; @@ -1560,6 +2105,71 @@ bool msg_sortrule_get_bool(void *sort_rule, int field) return result; } +bool msg_conv_get_bool(void *data, int field) +{ + bool result = false; + MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S *)data; + switch(field) + { + case MSG_CONV_MSG_READ_BOOL: + result = pConv->bRead; + break; + case MSG_CONV_MSG_PROTECTED_BOOL: + result = pConv->bProtected; + break; + default: + break; + } + return result; +} + +bool msg_thread_info_get_bool(void *data, int field) +{ + bool result = false; + MSG_THREAD_VIEW_S *pthreadInfo = (MSG_THREAD_VIEW_S *)data; + switch(field) + { + case MSG_THREAD_PROTECTED_BOOL: + result = pthreadInfo->bProtected; + break; + case MSG_THREAD_DRAFT_BOOL : + result = pthreadInfo->bDraft; + break; + case MSG_THREAD_SEND_FAILED_BOOL : + result = pthreadInfo->bSendFailed; + break; + case MSG_THREAD_SENDING_BOOL : + result = pthreadInfo->bSending; + break; + default: + break; + } + return result; +} + + +bool msg_list_condition_get_bool(void *data, int field) +{ + bool result = false; + MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)data; + switch(field) + { + case MSG_LIST_CONDITION_PROTECTED_BOOL: + result = pCond->bProtected; + break; + case MSG_LIST_CONDITION_SCHEDULED_BOOL : + result = pCond->bScheduled; + break; + case MSG_LIST_CONDITION_AND_OPERATER_BOOL : + result = pCond->bAnd; + break; + default: + break; + } + return result; +} + + int msg_sendopt_get_struct_handle(msg_struct_s *msg_struct, int field, void **value) { msg_error_t err = MSG_SUCCESS; @@ -1614,7 +2224,7 @@ int msg_thread_index_get_struct_handle(msg_struct_s *msg_struct, int field, void MSG_THREAD_LIST_INDEX_INFO_S *pIndex = (MSG_THREAD_LIST_INDEX_INFO_S *)msg_struct->data; switch(field) { - case MSG_SYNCML_INFO_MESSAGE_HND: + case MSG_THREAD_LIST_INDEX_ADDR_INFO_HND: *value = (void *)pIndex->msgAddrInfo; break; default: @@ -1625,9 +2235,32 @@ int msg_thread_index_get_struct_handle(msg_struct_s *msg_struct, int field, void return err; } + +int msg_list_condition_get_struct_handle(msg_struct_s *msg_struct, int field, void **value) +{ + msg_error_t err = MSG_SUCCESS; + + if(!msg_struct || !value) + return MSG_ERR_NULL_POINTER; + + MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)msg_struct->data; + switch(field) + { + case MSG_LIST_CONDITION_SORT_RULE_HND: + *value = (void *)pCond->sortRule; + break; + default: + err = MSG_ERR_UNKNOWN; + break; + + } + return err; +} + + int msg_address_info_get_int(void *addr_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_ADDRESS_INFO_S *pAddr = (MSG_ADDRESS_INFO_S *)addr_info; switch(field) { @@ -1647,7 +2280,7 @@ int msg_address_info_get_int(void *addr_info, int field) } int msg_mms_sendopt_get_int(void *opt_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MMS_SENDINGOPT_S *pOpt = (MMS_SENDINGOPT_S *)opt_info; switch(field) { @@ -1668,7 +2301,7 @@ int msg_mms_sendopt_get_int(void *opt_info, int field) int msg_reject_message_get_int(void *msg_info, int field) { - int result = -1; + int result = MSG_ERR_INVALID_PARAMETER; MSG_REJECT_MSG_INFO_S *pMsg = (MSG_REJECT_MSG_INFO_S *)msg_info; switch(field) { @@ -1897,57 +2530,102 @@ int msg_folder_info_set_int(void *folder_info, int field, int value) return err; } + int msg_search_condition_set_int(void *condition_info, int field, int value) { msg_error_t err = MSG_SUCCESS; if(!condition_info) return MSG_ERR_NULL_POINTER; - MSG_SEARCH_CONDITION_S *pCond = (MSG_SEARCH_CONDITION_S *)condition_info; - switch(field) - { - case MSG_SEARCH_CONDITION_FOLDERID_INT: + MSG_SEARCH_CONDITION_S *pCond = (MSG_SEARCH_CONDITION_S *)condition_info; + switch(field) + { + case MSG_SEARCH_CONDITION_FOLDERID_INT: pCond->folderId = value; break; - case MSG_SEARCH_CONDITION_MSGTYPE_INT: + case MSG_SEARCH_CONDITION_MSGTYPE_INT: pCond->msgType = value; break; - case MSG_SEARCH_CONDITION_RESERVED_INT: + case MSG_SEARCH_CONDITION_RESERVED_INT: pCond->reserved = value; break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } -int msg_report_status_set_int(void *report_info, int field, int value) + +int msg_list_condition_set_int(void *condition_info, int field, int value) { msg_error_t err = MSG_SUCCESS; - if(!report_info) + if(!condition_info) return MSG_ERR_NULL_POINTER; - MSG_REPORT_STATUS_INFO_S *pReport = (MSG_REPORT_STATUS_INFO_S *)report_info; - switch(field) - { - case MSG_REPORT_STATUS_DELIVERY_STATUS_INT: - pReport->deliveryStatus = value; + MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)condition_info; + switch(field) + { + case MSG_LIST_CONDITION_FOLDER_ID_INT: + pCond->folderId = value; + break; + case MSG_LIST_CONDITION_THREAD_ID_INT: + pCond->threadId = value; break; - case MSG_REPORT_STATUS_DELIVERY_TIME_INT: - pReport->deliveryStatusTime = value; + case MSG_LIST_CONDITION_STORAGE_ID_INT: + pCond->storageId = value; break; - case MSG_REPORT_STATUS_READ_STATUS_INT: - pReport->readStatus = value; + case MSG_LIST_CONDITION_MSGTYPE_INT: + pCond->msgType = value; break; - case MSG_REPORT_STATUS_READ_TIME_INT: - pReport->readStatusTime = value; + case MSG_LIST_CONDITION_FROM_TIME_INT: + pCond->fromTime = value; break; - default: + case MSG_LIST_CONDITION_TO_TIME_INT: + pCond->toTime = value; + break; + case MSG_LIST_CONDITION_OFFSET_INT: + pCond->offset = value; + break; + case MSG_LIST_CONDITION_LIMIT_INT: + pCond->limit = value; + break; + case MSG_LIST_CONDITION_SIM_INDEX_INT: + pCond->simIndex = value; + break; + default: err = MSG_ERR_UNKNOWN; break; - } + } + + return err; +} + + +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; + + MSG_REPORT_STATUS_INFO_S *pReport = (MSG_REPORT_STATUS_INFO_S *)report_info; + switch(field) + { + case MSG_REPORT_TYPE_INT: + pReport->type = value; + break; + case MSG_REPORT_STATUS_INT: + pReport->status = value; + break; + case MSG_REPORT_TIME_INT: + pReport->statusTime = value; + break; + + default: + err = MSG_ERR_UNKNOWN; + break; + } return err; } @@ -1979,24 +2657,52 @@ int msg_search_condition_set_str(void *condition_info, int field, char *value, i if(!condition_info || !value) return MSG_ERR_NULL_POINTER; - MSG_SEARCH_CONDITION_S *search_cond = (MSG_SEARCH_CONDITION_S *)condition_info; + MSG_SEARCH_CONDITION_S *search_cond = (MSG_SEARCH_CONDITION_S *)condition_info; - switch(field) - { - case MSG_SEARCH_CONDITION_ADDRESS_VALUE_STR: - search_cond->pAddressVal = value; + switch(field) + { + case MSG_SEARCH_CONDITION_ADDRESS_VALUE_STR: + if(size) + search_cond->pAddressVal = value; + break; + case MSG_SEARCH_CONDITION_SEARCH_VALUE_STR: + if(size) + search_cond->pSearchVal = value; break; - case MSG_SEARCH_CONDITION_SEARCH_VALUE_STR: - search_cond->pSearchVal = value; + default: + err = MSG_ERR_UNKNOWN; break; + } + return err; +} - default: + +int msg_list_condition_set_str(void *condition_info, int field, char *value, int size) +{ + msg_error_t err = MSG_SUCCESS; + if(!condition_info || !value) + return MSG_ERR_NULL_POINTER; + + MSG_LIST_CONDITION_S *cond = (MSG_LIST_CONDITION_S *)condition_info; + + switch(field) + { + case MSG_LIST_CONDITION_ADDRESS_VALUE_STR: + if(size) + cond->pAddressVal = value; + break; + case MSG_LIST_CONDITION_TEXT_VALUE_STR: + if(size) + cond->pTextVal = value; + break; + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } + int msg_sendopt_set_bool(void *send_opt, int field, bool value) { msg_error_t err = MSG_SUCCESS; @@ -2007,10 +2713,10 @@ int msg_sendopt_set_bool(void *send_opt, int field, bool value) switch(field) { case MSG_SEND_OPT_SETTING_BOOL: - sendopt->bDeliverReq = value; + sendopt->bSetting = value; break; case MSG_SEND_OPT_KEEPCOPY_BOOL: - sendopt->bDeliverReq = value; + sendopt->bKeepCopy = value; break; case MSG_SEND_OPT_DELIVER_REQ_BOOL: sendopt->bDeliverReq = value; @@ -2028,19 +2734,46 @@ int msg_sortrule_set_bool(void *sort_rule, int field, bool value) if(!sort_rule) return MSG_ERR_NULL_POINTER; - MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_rule; - switch(field) - { - case MSG_SORT_RULE_ACSCEND_BOOL: + MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_rule; + switch(field) + { + case MSG_SORT_RULE_ACSCEND_BOOL: pSort->bAscending = value; break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } + return err; +} + + +int msg_list_condition_set_bool(void *data, int field, bool value) +{ + msg_error_t err = MSG_SUCCESS; + if(!data) + return MSG_ERR_NULL_POINTER; + + MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)data; + switch(field) + { + case MSG_LIST_CONDITION_PROTECTED_BOOL: + pCond->bProtected = value; + break; + case MSG_LIST_CONDITION_SCHEDULED_BOOL: + pCond->bScheduled = value; + break; + case MSG_LIST_CONDITION_AND_OPERATER_BOOL: + pCond->bAnd = value; + break; + default: + err = MSG_ERR_UNKNOWN; + break; + } return err; } + int msg_sendopt_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value) { msg_error_t err = MSG_SUCCESS; @@ -2119,6 +2852,32 @@ int msg_thread_index_set_struct_handle(msg_struct_s *msg_struct, int field, msg_ return err; } + +int msg_list_condition_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value) +{ + msg_error_t err = MSG_SUCCESS; + + if(!msg_struct || !value) + return MSG_ERR_NULL_POINTER; + + MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)msg_struct->data; + msg_struct_s *pTmp = NULL; + + switch(field) + { + case MSG_LIST_CONDITION_SORT_RULE_HND: + pTmp = (msg_struct_s *)pCond->sortRule; + memcpy(pTmp->data, value->data, sizeof(MSG_SORT_RULE_S)); + break; + default: + err = MSG_ERR_UNKNOWN; + break; + + } + return err; +} + + int msg_address_info_set_int(void *addrinfo, int field, int value) { msg_error_t err = MSG_SUCCESS; @@ -2222,6 +2981,30 @@ int msg_address_info_set_str(void *addr_info, int field, char *value, int size) return err; } + +int msg_media_info_set_str(void *media_info, int field, char *value, int size) +{ + msg_error_t err = MSG_SUCCESS; + if(!media_info || !value) + return MSG_ERR_NULL_POINTER; + MSG_MEDIA_INFO_S *pAddr = (MSG_MEDIA_INFO_S *)media_info; + int _len = 0; + + switch(field) + { + case MSG_MEDIA_ITEM_STR: + (size > MSG_FILEPATH_LEN_MAX)? _len = MSG_FILEPATH_LEN_MAX : _len = size; + memset(pAddr->media_item, 0x00, sizeof(pAddr->media_item)); + strncpy(pAddr->media_item, value, _len); + break; + default: + err = MSG_ERR_UNKNOWN; + break; + } + + return err; +} + int msg_reject_message_set_str(void *msg_info, int field, char *value, int size) { msg_error_t err = MSG_SUCCESS; @@ -2278,8 +3061,245 @@ int msg_sms_sendopt_set_bool(void *option, int field, bool value) pOpt->bReplyPath = value; break; default: - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_UNKNOWN; + break; + } + return err; +} + +EXPORT_API int msg_add_push_event(msg_handle_t handle, const msg_struct_t push_event) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || push_event == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + MsgHandle* pHandle = (MsgHandle*)handle; + + msg_struct_s *pPush = (msg_struct_s *)push_event; + + try + { + err = pHandle->addPushEvent((MSG_PUSH_EVENT_INFO_S *)pPush->data); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_STORAGE_ERROR; + } + + return err; +} + +EXPORT_API int msg_delete_push_event(msg_handle_t handle, const msg_struct_t push_event) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || push_event == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + MsgHandle* pHandle = (MsgHandle*)handle; + + msg_struct_s *pPush = (msg_struct_s *)push_event; + + try + { + err = pHandle->deletePushEvent((MSG_PUSH_EVENT_INFO_S *)pPush->data); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_STORAGE_ERROR; + } + + return err; +} + +EXPORT_API int msg_update_push_event(msg_handle_t handle, const msg_struct_t src_event, const msg_struct_t dst_event) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || src_event == NULL || dst_event == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + MsgHandle* pHandle = (MsgHandle*)handle; + + msg_struct_s *pSrc = (msg_struct_s *)src_event; + msg_struct_s *pDst = (msg_struct_s *)dst_event; + + try + { + err = pHandle->updatePushEvent((MSG_PUSH_EVENT_INFO_S *)pSrc->data, (MSG_PUSH_EVENT_INFO_S *)pDst->data); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + return MSG_ERR_STORAGE_ERROR; + } + + return err; +} + +char* msg_push_config_get_str(void *event_info, int field, int size) +{ + char *result = NULL; + MSG_PUSH_EVENT_INFO_S *pEvent = (MSG_PUSH_EVENT_INFO_S *)event_info; + switch(field) + { + case MSG_PUSH_CONFIG_CONTENT_TYPE_STR: + result = pEvent->contentType; + break; + case MSG_PUSH_CONFIG_APPLICATON_ID_STR: + result = pEvent->appId; + break; + case MSG_PUSH_CONFIG_PACKAGE_NAME_STR: + result = pEvent->pkgName; + break; + + default: + result = NULL; + break; + } + return result; +} + +bool msg_push_config_get_bool(void *event_info, int field) +{ + bool result = false; + MSG_PUSH_EVENT_INFO_S *pEvent = (MSG_PUSH_EVENT_INFO_S *)event_info; + switch(field) + { + case MSG_PUSH_CONFIG_LAUNCH_BOOL: + result = pEvent->bLaunch; + break; + default: + break; + } + return result; +} + +int msg_push_config_set_str(void *event_info, int field, char *value, int size) +{ + msg_error_t err = MSG_SUCCESS; + if(!event_info || !value) + return MSG_ERR_NULL_POINTER; + MSG_PUSH_EVENT_INFO_S *pEvent = (MSG_PUSH_EVENT_INFO_S *)event_info; + int _len = 0; + + switch(field) + { + case MSG_PUSH_CONFIG_CONTENT_TYPE_STR: + (size > MAX_WAPPUSH_CONTENT_TYPE_LEN)? _len = MAX_WAPPUSH_CONTENT_TYPE_LEN : _len = size; + strncpy(pEvent->contentType, value, _len); + break; + case MSG_PUSH_CONFIG_APPLICATON_ID_STR: + (size > MAX_WAPPUSH_ID_LEN)? _len = MAX_WAPPUSH_ID_LEN : _len = size; + strncpy(pEvent->appId, value, _len); + break; + case MSG_PUSH_CONFIG_PACKAGE_NAME_STR: + (size > MSG_FILEPATH_LEN_MAX)? _len = MSG_FILEPATH_LEN_MAX : _len = size; + strncpy(pEvent->pkgName, value, _len); + break; + default: + err = MSG_ERR_UNKNOWN; + break; + } + + return err; +} + +int msg_push_config_set_bool(void *event, int field, bool value) +{ + msg_error_t err = MSG_SUCCESS; + if(!event) + return MSG_ERR_NULL_POINTER; + + MSG_PUSH_EVENT_INFO_S *pEvent = (MSG_PUSH_EVENT_INFO_S *)event; + switch(field) + { + case MSG_PUSH_CONFIG_LAUNCH_BOOL: + pEvent->bLaunch = value; + break; + default: + err = MSG_ERR_UNKNOWN; break; } return err; } + +char* msg_media_item_get_str(void *data, int field, int size) +{ + char *result = NULL; + MSG_MEDIA_INFO_S *pMedia = (MSG_MEDIA_INFO_S *)data; + + switch(field) + { + case MSG_MEDIA_ITEM_STR: + result = pMedia->media_item; + break; + case MSG_MEDIA_MIME_TYPE_STR: + result = pMedia->mime_type; + break; + case MSG_MEDIA_THUMB_PATH_STR: + result = pMedia->thumb_path; + break; + default: + result = NULL; + break; + } + return result; +} + +int msg_media_item_get_int(void *data, int field, int *value) +{ + if (!data || !value) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + + MSG_MEDIA_INFO_S *pMedia = (MSG_MEDIA_INFO_S *)data; + + switch (field) { + case MSG_MEDIA_MESSAGE_ID_INT: + *value = pMedia->msg_id; + break; + default : + ret = MSG_ERR_INVALID_PARAMETER; + break; + } + + return ret; +} diff --git a/mapi/msg_svc.cpp b/mapi/msg_svc.cpp index 7a269e0..8e8be87 100755 --- a/mapi/msg_svc.cpp +++ b/mapi/msg_svc.cpp @@ -1,24 +1,27 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include +#include "MsgDebug.h" #include "MsgTypes.h" #include "MsgHandle.h" +#include "MsgTextConvert.h" #include "MsgException.h" +#include "MsgMemory.h" #include "msg_private.h" #include "msg.h" @@ -29,19 +32,35 @@ })\ +void __msg_release_list_item(gpointer data) +{ + if (data == NULL) + return; + + msg_release_struct((msg_struct_t*)(&data)); +} + EXPORT_API msg_struct_t msg_create_struct(int field) { + CHECK_MSG_SUPPORTED_RETURN_NULL(MSG_TELEPHONY_FEATURE); msg_struct_s *msg_struct = new msg_struct_s; memset(msg_struct, 0x00, sizeof(msg_struct_s)); msg_struct->type = field; + msg_struct->data = NULL; switch(field) { case MSG_STRUCT_MESSAGE_INFO : msg_message_create_struct(msg_struct); break; + case MSG_STRUCT_CONV_INFO: + { + msg_struct->data = (void *)new MSG_CONVERSATION_VIEW_S; + memset(msg_struct->data, 0x00, sizeof(MSG_CONVERSATION_VIEW_S)); + break; + } case MSG_STRUCT_FILTER: { msg_struct->data = (void *)new MSG_FILTER_S; @@ -134,6 +153,20 @@ EXPORT_API msg_struct_t msg_create_struct(int field) memset(msg_struct->data, 0x00, sizeof(MSG_SEARCH_CONDITION_S)); break; } + case MSG_STRUCT_MSG_LIST_CONDITION: + { + msg_struct->data = new MSG_LIST_CONDITION_S; + memset(msg_struct->data, 0x00, sizeof(MSG_LIST_CONDITION_S)); + + msg_struct_s *pStruct = new msg_struct_s; + ((MSG_LIST_CONDITION_S *)msg_struct->data)->sortRule = (msg_struct_t)pStruct; + + pStruct->type = MSG_STRUCT_SORT_RULE; + pStruct->data = new MSG_SORT_RULE_S; + memset(pStruct->data, 0x00, sizeof(MSG_SORT_RULE_S)); + + break; + } case MSG_STRUCT_REPORT_STATUS_INFO: { msg_struct->data = new MSG_REPORT_STATUS_INFO_S; @@ -142,27 +175,30 @@ EXPORT_API msg_struct_t msg_create_struct(int field) } case MSG_STRUCT_SETTING_SMSC_OPT : { - msg_struct->data = new MSG_SMSC_LIST_HIDDEN_S; - memset(msg_struct->data, 0x00, sizeof(MSG_SMSC_LIST_HIDDEN_S)); + msg_struct->data = new MSG_SMSC_LIST_HIDDEN_S; + memset(msg_struct->data, 0x00, sizeof(MSG_SMSC_LIST_HIDDEN_S)); - MSG_SMSC_LIST_HIDDEN_S *pTmp = (MSG_SMSC_LIST_HIDDEN_S *)msg_struct->data; + MSG_SMSC_LIST_HIDDEN_S *pTmp = (MSG_SMSC_LIST_HIDDEN_S *)msg_struct->data; + pTmp->simIndex = MSG_SIM_SLOT_ID_1; // default sim index - msg_struct_list_s *smsc_list = (msg_struct_list_s *)new msg_struct_list_s; - memset(smsc_list, 0x00, sizeof(msg_struct_list_s)); + msg_struct_list_s *smsc_list = (msg_struct_list_s *)new msg_struct_list_s; + memset(smsc_list, 0x00, sizeof(msg_struct_list_s)); - pTmp->smsc_list = smsc_list; + pTmp->smsc_list = smsc_list; - smsc_list->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t)*SMSC_LIST_MAX]; + smsc_list->msg_struct_info = (msg_struct_t *)calloc(SMSC_LIST_MAX, sizeof(msg_struct_t)); - msg_struct_s *pStructTmp = NULL; + if (smsc_list->msg_struct_info != NULL) { + msg_struct_s *pStructTmp = NULL; - for (int i = 0; i < SMSC_LIST_MAX; i++) { - pStructTmp = (msg_struct_s *)new msg_struct_s; - pStructTmp->type = MSG_STRUCT_SETTING_SMSC_INFO; - pStructTmp->data = new MSG_SMSC_DATA_S; - memset(pStructTmp->data, 0x00, sizeof(MSG_SMSC_DATA_S)); - smsc_list->msg_struct_info[i] = (msg_struct_t)pStructTmp; - } + for (int i = 0; i < SMSC_LIST_MAX; i++) { + pStructTmp = (msg_struct_s *)new msg_struct_s; + pStructTmp->type = MSG_STRUCT_SETTING_SMSC_INFO; + pStructTmp->data = new MSG_SMSC_DATA_S; + memset(pStructTmp->data, 0x00, sizeof(MSG_SMSC_DATA_S)); + smsc_list->msg_struct_info[i] = (msg_struct_t)pStructTmp; + } + } break; } case MSG_STRUCT_SETTING_SMSC_INFO : @@ -173,27 +209,29 @@ EXPORT_API msg_struct_t msg_create_struct(int field) } case MSG_STRUCT_SETTING_CB_OPT : { - msg_struct->data = new MSG_CBMSG_OPT_HIDDEN_S; - memset(msg_struct->data, 0x00, sizeof(MSG_CBMSG_OPT_HIDDEN_S)); + msg_struct->data = new MSG_CBMSG_OPT_HIDDEN_S; + memset(msg_struct->data, 0x00, sizeof(MSG_CBMSG_OPT_HIDDEN_S)); - MSG_CBMSG_OPT_HIDDEN_S *pTmp = (MSG_CBMSG_OPT_HIDDEN_S *)msg_struct->data; + MSG_CBMSG_OPT_HIDDEN_S *pTmp = (MSG_CBMSG_OPT_HIDDEN_S *)msg_struct->data; + pTmp->simIndex = MSG_SIM_SLOT_ID_1; // default sim index - pTmp->channelData = (msg_struct_list_s *)new msg_struct_list_s; - memset(pTmp->channelData, 0x00, sizeof(msg_struct_list_s)); + pTmp->channelData = (msg_struct_list_s *)new msg_struct_list_s; + memset(pTmp->channelData, 0x00, sizeof(msg_struct_list_s)); - pTmp->channelData->msg_struct_info = (msg_struct_t *)new char[sizeof(msg_struct_t)*CB_CHANNEL_MAX]; + pTmp->channelData->msg_struct_info = (msg_struct_t *)calloc(CB_CHANNEL_MAX, sizeof(msg_struct_t)); - msg_struct_s *pStructTmp = NULL; + if (pTmp->channelData->msg_struct_info != NULL) { + msg_struct_s *pStructTmp = NULL; - for (int i = 0; i < CB_CHANNEL_MAX; i++) { - pStructTmp = (msg_struct_s *)new msg_struct_s; - pStructTmp->type = MSG_STRUCT_SETTING_CB_CHANNEL_INFO; - pStructTmp->data = new MSG_CB_CHANNEL_INFO_S; - - memset(pStructTmp->data, 0x00, sizeof(MSG_CB_CHANNEL_INFO_S)); - pTmp->channelData->msg_struct_info[i] = (msg_struct_t)pStructTmp; - } + for (int i = 0; i < CB_CHANNEL_MAX; i++) { + pStructTmp = (msg_struct_s *)new msg_struct_s; + pStructTmp->type = MSG_STRUCT_SETTING_CB_CHANNEL_INFO; + pStructTmp->data = new MSG_CB_CHANNEL_INFO_S; + memset(pStructTmp->data, 0x00, sizeof(MSG_CB_CHANNEL_INFO_S)); + pTmp->channelData->msg_struct_info[i] = (msg_struct_t)pStructTmp; + } + } break; } case MSG_STRUCT_SETTING_CB_CHANNEL_INFO : @@ -204,8 +242,8 @@ EXPORT_API msg_struct_t msg_create_struct(int field) } case MSG_STRUCT_SETTING_SMS_SEND_OPT : { - msg_struct->data = new MSG_SMS_SENDOPT_S; - memset(msg_struct->data, 0x00, sizeof(MSG_SMS_SENDOPT_S)); + msg_struct->data = new MSG_SMS_SENDOPT_S; + memset(msg_struct->data, 0x00, sizeof(MSG_SMS_SENDOPT_S)); break; } case MSG_STRUCT_SETTING_MMS_SEND_OPT : @@ -230,6 +268,8 @@ EXPORT_API msg_struct_t msg_create_struct(int field) { msg_struct->data = new MSG_VOICEMAIL_OPT_S; memset(msg_struct->data, 0x00, sizeof(MSG_VOICEMAIL_OPT_S)); + MSG_VOICEMAIL_OPT_S *pTmp = (MSG_VOICEMAIL_OPT_S *)msg_struct->data; + pTmp->simIndex = MSG_SIM_SLOT_ID_1; // default sim index break; } case MSG_STRUCT_SETTING_GENERAL_OPT : @@ -300,15 +340,24 @@ EXPORT_API msg_struct_t msg_create_struct(int field) case MSG_STRUCT_MMS_META: case MSG_STRUCT_MMS_SMIL_TEXT: case MSG_STRUCT_MMS_SMIL_AVI: + case MSG_STRUCT_MULTIPART_INFO: msg_struct->data = msg_mms_create_struct_data(field); break; + case MSG_STRUCT_PUSH_CONFIG_INFO: + msg_struct->data = new MSG_PUSH_EVENT_INFO_S; + memset(msg_struct->data, 0x00, sizeof(MSG_PUSH_EVENT_INFO_S)); + break; + default : + delete msg_struct; + return NULL; + break; } return (msg_struct_t) msg_struct; } -EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) +static int _release_msg_struct(msg_struct_t *msg_struct_handle) { msg_error_t err = MSG_SUCCESS; @@ -335,6 +384,27 @@ EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) *msg_struct_handle = NULL; break; } + case MSG_STRUCT_CONV_INFO: + { + MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S*)(msg_struct->data); + + if (pConv->multipart_list) { + g_list_free_full((GList *)pConv->multipart_list, __msg_release_list_item); + pConv->multipart_list = NULL; + } + + if (pConv->pText) { + delete [] pConv->pText; + pConv->pText = NULL; + } + + delete pConv; + msg_struct->data = NULL; + + delete msg_struct; + *msg_struct_handle = NULL; + break; + } case MSG_STRUCT_THREAD_INFO: { delete (MSG_THREAD_VIEW_S*)(msg_struct->data); @@ -442,6 +512,24 @@ EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) break; } + case MSG_STRUCT_MSG_LIST_CONDITION: + { + MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S*)(msg_struct->data); + MSG_SORT_RULE_S *pSortRule = (MSG_SORT_RULE_S *)(((msg_struct_s *)pCond->sortRule)->data); + + delete (MSG_SORT_RULE_S *)pSortRule; + ((msg_struct_s *)pCond->sortRule)->data = NULL; + delete (msg_struct_s *)pCond->sortRule; + pCond->sortRule = NULL; + + delete (MSG_LIST_CONDITION_S*)(msg_struct->data); + msg_struct->data = NULL; + + delete msg_struct; + *msg_struct_handle = NULL; + + break; + } case MSG_STRUCT_REPORT_STATUS_INFO: { delete (MSG_REPORT_STATUS_INFO_S*)(msg_struct->data); @@ -514,6 +602,7 @@ EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) case MSG_STRUCT_MMS_META: case MSG_STRUCT_MMS_SMIL_TEXT: case MSG_STRUCT_MMS_SMIL_AVI: + case MSG_STRUCT_MULTIPART_INFO: { msg_mms_release_struct(&msg_struct); *msg_struct_handle = NULL; @@ -530,13 +619,15 @@ EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) for (int i = 0; i < SMSC_LIST_MAX; i++) { smsc_info = (msg_struct_s *)smsc_list->msg_struct_info[i]; - delete [] (MSG_SMSC_DATA_S*)(smsc_info->data); - delete [] smsc_info; + delete (MSG_SMSC_DATA_S*)(smsc_info->data); + delete smsc_info; } - delete [] smsc_list->msg_struct_info; + g_free(smsc_list->msg_struct_info); + + delete smsc_list; - delete [] (MSG_SMSC_LIST_HIDDEN_S*)pTmp; + delete pTmp; msg_struct->data = NULL; delete msg_struct; @@ -563,13 +654,15 @@ EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) for (int i = 0; i < CB_CHANNEL_MAX; i++) { cb_info = (msg_struct_s *)cb_list->msg_struct_info[i]; - delete [] (MSG_CB_CHANNEL_INFO_S*)(cb_info->data); - delete [] cb_info; + delete (MSG_CB_CHANNEL_INFO_S*)(cb_info->data); + delete cb_info; } - delete [] cb_list->msg_struct_info; + g_free(cb_list->msg_struct_info); - delete [] (MSG_CBMSG_OPT_HIDDEN_S*)pTmp; + delete cb_list; + + delete pTmp; msg_struct->data = NULL; delete msg_struct; @@ -639,6 +732,33 @@ EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) *msg_struct_handle = NULL; break; } + case MSG_STRUCT_ADDRESS_INFO : + { + delete (MSG_ADDRESS_INFO_S*)(msg_struct->data); + msg_struct->data = NULL; + + delete msg_struct; + *msg_struct_handle = NULL; + break; + } + case MSG_STRUCT_PUSH_CONFIG_INFO: + { + delete (MSG_PUSH_EVENT_INFO_S*)(msg_struct->data); + msg_struct->data = NULL; + + delete msg_struct; + *msg_struct_handle = NULL; + break; + } + case MSG_STRUCT_MEDIA_INFO: + { + delete (MSG_MEDIA_INFO_S*)(msg_struct->data); + msg_struct->data = NULL; + + delete msg_struct; + *msg_struct_handle = NULL; + break; + } default : err = MSG_ERR_INVALID_PARAMETER; break; @@ -647,8 +767,21 @@ EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) return err; } -int msg_release_list_struct(msg_struct_list_s *msg_struct_list) +EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + + int ret = _release_msg_struct(msg_struct_handle); + + // Release Memory + MsgReleaseMemory(); + + return ret; +} + +EXPORT_API int msg_release_list_struct(msg_struct_list_s *msg_struct_list) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_list == NULL) @@ -661,20 +794,40 @@ int msg_release_list_struct(msg_struct_list_s *msg_struct_list) } if(msg_struct_list->nCount > 0) { - for(int i = 0; i < msg_struct_list->nCount; i++) { - msg_release_struct(&(msg_struct_list->msg_struct_info[i])); + int structType = ((msg_struct_s *)msg_struct_list->msg_struct_info[0])->type; + int listCnt = msg_struct_list->nCount; + + switch (structType) + { +// case MSG_STRUCT_ADDRESS_INFO : +// { +// listCnt = MAX_TO_ADDRESS_CNT; +// break; +// } + default : + break; + } + + for(int i = 0; i < listCnt; i++) { + _release_msg_struct(&(msg_struct_list->msg_struct_info[i])); } } //free peer info list - delete [] msg_struct_list->msg_struct_info; + g_free(msg_struct_list->msg_struct_info); msg_struct_list->msg_struct_info = NULL; + msg_struct_list->nCount = 0; + + // Release Memory + MsgReleaseMemory(); + return err; } EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int *value) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; @@ -716,9 +869,15 @@ EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int case MSG_STRUCT_THREAD_INFO : *value = msg_thread_info_get_int(msg_struct->data, field); break; + case MSG_STRUCT_CONV_INFO : + *value = msg_conv_info_get_int(msg_struct->data, field); + break; case MSG_STRUCT_SEARCH_CONDITION : *value = msg_search_condition_get_int(msg_struct->data, field); break; + case MSG_STRUCT_MSG_LIST_CONDITION : + *value = msg_list_condition_get_int(msg_struct->data, field); + break; case MSG_STRUCT_REPORT_STATUS_INFO : *value = msg_report_status_get_int(msg_struct->data, field); break; @@ -737,6 +896,9 @@ EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int case MSG_STRUCT_SENT_STATUS_INFO : *value = msg_sent_status_get_int((MSG_SENT_STATUS_S *)msg_struct->data, field); break; + case MSG_STRUCT_CB_MSG : + err = msg_cb_message_get_int_value (msg_struct->data, field, value); + break; case MSG_STRUCT_MMS: case MSG_STRUCT_MMS_PAGE: case MSG_STRUCT_MMS_MEDIA: @@ -746,6 +908,7 @@ EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int case MSG_STRUCT_MMS_META: case MSG_STRUCT_MMS_SMIL_TEXT: case MSG_STRUCT_MMS_SMIL_AVI: + case MSG_STRUCT_MULTIPART_INFO: err = msg_mms_get_int_value(msg_struct, field, value); break; case MSG_STRUCT_SETTING_SMSC_OPT : @@ -758,8 +921,12 @@ EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int case MSG_STRUCT_SETTING_PUSH_MSG_OPT : case MSG_STRUCT_SETTING_GENERAL_OPT : case MSG_STRUCT_SETTING_MSGSIZE_OPT : + case MSG_STRUCT_SETTING_VOICE_MSG_OPT : err = msg_setting_get_int_value(msg_struct, field, value); break; + case MSG_STRUCT_MEDIA_INFO : + err = msg_media_item_get_int(msg_struct->data, field, value); + break; default : err = MSG_ERR_INVALID_PARAMETER; break; @@ -770,6 +937,7 @@ EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char *src, int size) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -808,6 +976,13 @@ EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char else strncpy(src, ret_str, size); break; + case MSG_STRUCT_CONV_INFO : + ret_str = msg_conv_info_get_str(msg_struct->data, field); + if (ret_str == NULL) + err = MSG_ERR_UNKNOWN; + else + strncpy(src, ret_str, size); + break; case MSG_STRUCT_SEARCH_CONDITION : ret_str = msg_search_condition_get_str(msg_struct->data, field, size); if (ret_str == NULL) @@ -815,6 +990,13 @@ EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char else strncpy(src, ret_str, size); break; + case MSG_STRUCT_MSG_LIST_CONDITION : + ret_str = msg_list_condition_get_str(msg_struct->data, field, size); + if (ret_str == NULL) + err = MSG_ERR_UNKNOWN; + else + strncpy(src, ret_str, size); + break; case MSG_STRUCT_ADDRESS_INFO : ret_str = msg_address_info_get_str(msg_struct->data, field, size); @@ -831,6 +1013,13 @@ EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char else strncpy(src, ret_str, size); break; + case MSG_STRUCT_MEDIA_INFO : + ret_str = msg_media_item_get_str(msg_struct->data, field, size); + if (ret_str == NULL) + err = MSG_ERR_UNKNOWN; + else + strncpy(src, ret_str, size); + break; case MSG_STRUCT_MMS: case MSG_STRUCT_MMS_PAGE: case MSG_STRUCT_MMS_MEDIA: @@ -840,13 +1029,32 @@ EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char case MSG_STRUCT_MMS_META: case MSG_STRUCT_MMS_SMIL_TEXT: case MSG_STRUCT_MMS_SMIL_AVI: + case MSG_STRUCT_MULTIPART_INFO: err = msg_mms_get_str_value(msg_struct, field, src, size); break; + case MSG_STRUCT_SETTING_GENERAL_OPT : case MSG_STRUCT_SETTING_SMSC_INFO : case MSG_STRUCT_SETTING_CB_CHANNEL_INFO : case MSG_STRUCT_SETTING_VOICE_MSG_OPT : err = msg_setting_get_str_value(msg_struct, field, src, size); break; + case MSG_STRUCT_PUSH_CONFIG_INFO : + ret_str = msg_push_config_get_str(msg_struct->data, field, size); + if (ret_str == NULL) + err = MSG_ERR_UNKNOWN; + else + strncpy(src, ret_str, size); + break; + case MSG_STRUCT_REPORT_STATUS_INFO: + ret_str = msg_report_status_get_str(msg_struct->data, field); + if (ret_str == NULL) + err = MSG_ERR_UNKNOWN; + else + strncpy(src, ret_str, size); + break; + case MSG_STRUCT_CB_MSG : + err = msg_cb_message_get_str_value(msg_struct->data, field, src, size); + break; default : err = MSG_ERR_INVALID_PARAMETER; break; @@ -857,6 +1065,7 @@ EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char EXPORT_API int msg_get_bool_value(msg_struct_t msg_struct_handle, int field, bool *value) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -869,15 +1078,27 @@ EXPORT_API int msg_get_bool_value(msg_struct_t msg_struct_handle, int field, boo switch (msg_struct->type) { + case MSG_STRUCT_FILTER : + *value = msg_get_filter_info_bool(msg_struct->data, field); + break; case MSG_STRUCT_MESSAGE_INFO : err = msg_message_get_bool_value(msg_struct->data, field, value); break; + case MSG_STRUCT_THREAD_INFO : + *value = msg_thread_info_get_bool(msg_struct->data, field); + break; + case MSG_STRUCT_CONV_INFO: + *value = msg_conv_get_bool(msg_struct->data, field); + break; case MSG_STRUCT_SENDOPT: *value = msg_sendopt_get_bool(msg_struct->data, field); break; case MSG_STRUCT_SORT_RULE: *value = msg_sortrule_get_bool(msg_struct->data, field); break; + case MSG_STRUCT_MSG_LIST_CONDITION: + *value = msg_list_condition_get_bool(msg_struct->data, field); + break; case MSG_STRUCT_MMS_SENDOPT: *value = msg_mms_sendopt_get_bool(msg_struct->data, field); break; @@ -914,6 +1135,7 @@ EXPORT_API int msg_get_bool_value(msg_struct_t msg_struct_handle, int field, boo EXPORT_API int msg_get_struct_handle(msg_struct_t msg_struct_handle, int field, msg_struct_t *value) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -938,6 +1160,9 @@ EXPORT_API int msg_get_struct_handle(msg_struct_t msg_struct_handle, int field, case MSG_STRUCT_THREAD_LIST_INDEX: err = msg_thread_index_get_struct_handle(msg_struct, field, (void **)value); break; + case MSG_STRUCT_MSG_LIST_CONDITION: + err = msg_list_condition_get_struct_handle(msg_struct, field, (void **)value); + break; case MSG_STRUCT_MMS_MEDIA: err = msg_mms_get_struct_handle(msg_struct, field, (msg_struct_s**)value); break; @@ -954,6 +1179,7 @@ EXPORT_API int msg_get_struct_handle(msg_struct_t msg_struct_handle, int field, EXPORT_API int msg_get_list_handle(msg_struct_t msg_struct_handle, int field, void **value) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -969,6 +1195,9 @@ EXPORT_API int msg_get_list_handle(msg_struct_t msg_struct_handle, int field, vo case MSG_STRUCT_MESSAGE_INFO : err = msg_message_get_list_hnd(msg_struct->data, field, value); break; + case MSG_STRUCT_CONV_INFO: + err = msg_conversation_get_list_hnd(msg_struct->data, field, value); + break; case MSG_STRUCT_MMS: case MSG_STRUCT_MMS_PAGE: err = msg_mms_get_list_handle(msg_struct, field, (msg_list_handle_t *)value); @@ -987,6 +1216,7 @@ EXPORT_API int msg_get_list_handle(msg_struct_t msg_struct_handle, int field, vo EXPORT_API int msg_set_int_value(msg_struct_t msg_struct_handle, int field, int value) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -1026,6 +1256,9 @@ EXPORT_API int msg_set_int_value(msg_struct_t msg_struct_handle, int field, int case MSG_STRUCT_SEARCH_CONDITION : err = msg_search_condition_set_int(msg_struct->data, field, value); break; + case MSG_STRUCT_MSG_LIST_CONDITION : + err = msg_list_condition_set_int(msg_struct->data, field, value); + break; case MSG_STRUCT_REPORT_STATUS_INFO : err = msg_report_status_set_int(msg_struct->data, field, value); break; @@ -1062,6 +1295,7 @@ EXPORT_API int msg_set_int_value(msg_struct_t msg_struct_handle, int field, int case MSG_STRUCT_SETTING_PUSH_MSG_OPT : case MSG_STRUCT_SETTING_GENERAL_OPT : case MSG_STRUCT_SETTING_MSGSIZE_OPT : + case MSG_STRUCT_SETTING_VOICE_MSG_OPT : err = msg_setting_set_int_value(msg_struct, field, value); break; default : @@ -1074,6 +1308,7 @@ EXPORT_API int msg_set_int_value(msg_struct_t msg_struct_handle, int field, int EXPORT_API int msg_set_str_value(msg_struct_t msg_struct_handle, int field, char *value, int size) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -1098,6 +1333,9 @@ EXPORT_API int msg_set_str_value(msg_struct_t msg_struct_handle, int field, char case MSG_STRUCT_SEARCH_CONDITION : err = msg_search_condition_set_str(msg_struct->data, field, value, size); break; + case MSG_STRUCT_MSG_LIST_CONDITION : + err = msg_list_condition_set_str(msg_struct->data, field, value, size); + break; case MSG_STRUCT_ADDRESS_INFO : err = msg_address_info_set_str(msg_struct->data, field, value, size); break; @@ -1113,13 +1351,21 @@ EXPORT_API int msg_set_str_value(msg_struct_t msg_struct_handle, int field, char case MSG_STRUCT_MMS_META: case MSG_STRUCT_MMS_SMIL_TEXT: case MSG_STRUCT_MMS_SMIL_AVI: + case MSG_STRUCT_MULTIPART_INFO: err = msg_mms_set_str_value(msg_struct, field, value, size); break; + case MSG_STRUCT_SETTING_GENERAL_OPT : case MSG_STRUCT_SETTING_SMSC_INFO : case MSG_STRUCT_SETTING_CB_CHANNEL_INFO : case MSG_STRUCT_SETTING_VOICE_MSG_OPT : err = msg_setting_set_str_value(msg_struct, field, value, size); break; + case MSG_STRUCT_PUSH_CONFIG_INFO: + err = msg_push_config_set_str(msg_struct->data, field, value, size); + break; + case MSG_STRUCT_MEDIA_INFO : + err = msg_media_info_set_str(msg_struct->data, field, value, size); + break; default : err = MSG_ERR_INVALID_PARAMETER; break; @@ -1130,6 +1376,7 @@ EXPORT_API int msg_set_str_value(msg_struct_t msg_struct_handle, int field, char EXPORT_API int msg_set_bool_value(msg_struct_t msg_struct_handle, int field, bool value) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -1142,6 +1389,9 @@ EXPORT_API int msg_set_bool_value(msg_struct_t msg_struct_handle, int field, boo switch (msg_struct->type) { + case MSG_STRUCT_FILTER : + err = msg_set_filter_info_bool(msg_struct->data, field, value); + break; case MSG_STRUCT_MESSAGE_INFO : err = msg_message_set_bool_value(msg_struct->data, field, value); break; @@ -1151,6 +1401,9 @@ EXPORT_API int msg_set_bool_value(msg_struct_t msg_struct_handle, int field, boo case MSG_STRUCT_SORT_RULE: err = msg_sortrule_set_bool(msg_struct->data, field, value); break; + case MSG_STRUCT_MSG_LIST_CONDITION: + err = msg_list_condition_set_bool(msg_struct->data, field, value); + break; case MSG_STRUCT_MMS_SENDOPT: err = msg_mms_sendopt_set_bool(msg_struct->data, field, value); break; @@ -1177,6 +1430,9 @@ EXPORT_API int msg_set_bool_value(msg_struct_t msg_struct_handle, int field, boo case MSG_STRUCT_SETTING_GENERAL_OPT : err = msg_setting_set_bool_value(msg_struct, field, value); break; + case MSG_STRUCT_PUSH_CONFIG_INFO: + err = msg_push_config_set_bool(msg_struct->data, field, value); + break; default : err = MSG_ERR_INVALID_PARAMETER; break; @@ -1187,6 +1443,7 @@ EXPORT_API int msg_set_bool_value(msg_struct_t msg_struct_handle, int field, boo EXPORT_API int msg_set_struct_handle(msg_struct_t msg_struct_handle, int field, msg_struct_t value) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -1211,6 +1468,9 @@ EXPORT_API int msg_set_struct_handle(msg_struct_t msg_struct_handle, int field, case MSG_STRUCT_THREAD_LIST_INDEX: err = msg_thread_index_set_struct_handle(msg_struct, field, (msg_struct_s *)value); break; + case MSG_STRUCT_MSG_LIST_CONDITION: + err = msg_list_condition_set_struct_handle(msg_struct, field, (msg_struct_s *)value); + break; case MSG_STRUCT_MMS_MEDIA: err = msg_mms_set_struct_handle(msg_struct, field, (msg_struct_s *)value); break; @@ -1227,6 +1487,7 @@ EXPORT_API int msg_set_struct_handle(msg_struct_t msg_struct_handle, int field, EXPORT_API int msg_set_list_handle(msg_struct_t msg_struct_handle, int field, void *value) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -1237,21 +1498,217 @@ EXPORT_API int msg_set_list_handle(msg_struct_t msg_struct_handle, int field, vo if (msg_struct->data == NULL) return MSG_ERR_NULL_POINTER; +#if 0 // No operations switch (msg_struct->type) { default : err = MSG_ERR_INVALID_PARAMETER; break; } +#endif + + return err; +} + +EXPORT_API int msg_list_add_item(msg_struct_t msg_struct_handle, int field, msg_struct_t *item) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + if (msg_struct_handle == NULL || item == NULL) { + return MSG_ERR_NULL_POINTER; + } + + msg_error_t err = MSG_SUCCESS; + msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle; + + switch(msg_struct->type) { + case MSG_STRUCT_MESSAGE_INFO: + { + err = msg_message_list_append(msg_struct_handle, field, item); + } + break; + case MSG_STRUCT_MMS: + case MSG_STRUCT_MMS_PAGE: + { + err = msg_mms_list_append(msg_struct_handle, field, item); + } + break; + default : + err = MSG_ERR_INVALID_PARAMETER; + break; + } + return err; } EXPORT_API msg_struct_t msg_list_nth_data(msg_list_handle_t list_handle, int index) { + CHECK_MSG_SUPPORTED_RETURN_NULL(MSG_TELEPHONY_FEATURE); + if (list_handle == NULL) { + return NULL; + } + return (msg_struct_t)g_list_nth_data((GList *)list_handle,(guint)index); } EXPORT_API int msg_list_length(msg_list_handle_t list_handle) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + if (list_handle == NULL) { + return 0; + } + return (int)g_list_length((GList *)list_handle); } + +EXPORT_API int msg_list_clear(msg_struct_t msg_struct_handle, int field) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + if (msg_struct_handle == NULL) { + return MSG_ERR_NULL_POINTER; + } + + msg_error_t err = MSG_SUCCESS; + msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle; + + switch(msg_struct->type) { + case MSG_STRUCT_MESSAGE_INFO: + { + err = msg_message_list_clear(msg_struct_handle, field); + } + break; +// case MSG_STRUCT_MMS: +// case MSG_STRUCT_MMS_PAGE: +// { +// err = msg_mms_list_append(msg_struct_handle, field, item); +// } +// break; + default : + err = MSG_ERR_INVALID_PARAMETER; + break; + } + + return err; +} + + +EXPORT_API int msg_list_free(msg_list_handle_t list_handle) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + if (list_handle == NULL) { + return MSG_ERR_NULL_POINTER; + } + + g_list_free_full((GList *)list_handle, __msg_release_list_item); + list_handle = NULL; + + return MSG_SUCCESS; +} + + +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) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + if (msg_text == NULL || text_size == NULL || segment_size == NULL) { + err = MSG_ERR_INVALID_PARAMETER; + return err; + } + + msg_encode_type_t encodeType = MSG_ENCODE_AUTO; + MSG_LANGUAGE_ID_T langId = MSG_LANG_ID_RESERVED; + + int decodeLen = 0; + int bufSize = 0; + int textSize = 0; + + bool bAbnormal = false; + + textSize = strlen(msg_text); + + bufSize = textSize * 4; + + unsigned char decodeData[bufSize+1]; + memset(decodeData, 0x00, sizeof(decodeData)); + + MsgTextConvert *textCvt = MsgTextConvert::instance(); + + *text_size = 0; + *segment_size = 0; + + switch (msg_encode_type_to) + { + case MSG_ENCODE_GSM7BIT : + 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); + break; + case MSG_ENCODE_AUTO : +#ifndef FEATURE_SMS_CDMA + decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (const unsigned char*)msg_text, textSize, &langId, &encodeType); +#else + decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (const unsigned char*)msg_text, textSize, &encodeType); +#endif + break; + default : + err = MSG_ERR_INVALID_PARAMETER; + return err; + break; + } + + // calculate segment size. + int headerLen = 0; + int concat = 5; + int lang = 3; + + int headerSize = 0; + int segSize = 0; + + if (langId != MSG_LANG_ID_RESERVED) { + MSG_DEBUG("National Language Exists"); + headerSize += lang; + headerLen = 1; + } + + if (msg_encode_type_to == MSG_ENCODE_GSM7BIT || encodeType == MSG_ENCODE_GSM7BIT) { + MSG_DEBUG("MSG_ENCODE_GSM7BIT"); + + if ((decodeLen + headerSize) > 160) { + headerLen = 1; + segSize = ((140 - (headerLen + concat + headerSize)) * 8)/7; + } + else + segSize = ((140 - headerLen - headerSize) * 8) / 7; + + 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 > 140) { + headerLen = 1; + 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; + return err; + } + + MSG_DEBUG("decodeLen [%d] segSize [%d]", decodeLen, segSize); + + *text_size = decodeLen; + *segment_size = segSize; + + return err; +} diff --git a/mapi/msg_transport.cpp b/mapi/msg_transport.cpp index ec6dfd6..b386331 100755 --- a/mapi/msg_transport.cpp +++ b/mapi/msg_transport.cpp @@ -1,20 +1,21 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include +#include #include "MsgHandle.h" #include "MsgDebug.h" @@ -31,11 +32,20 @@ ==================================================================================================*/ EXPORT_API int msg_submit_req(msg_handle_t handle, msg_struct_t req) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL ||req == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -58,11 +68,20 @@ EXPORT_API int msg_submit_req(msg_handle_t handle, msg_struct_t req) EXPORT_API int msg_reg_sent_status_callback(msg_handle_t handle, msg_sent_status_cb cb, void *user_param) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || cb == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -74,7 +93,10 @@ EXPORT_API int msg_reg_sent_status_callback(msg_handle_t handle, msg_sent_status catch (MsgException& e) { MSG_FATAL("%s", e.what()); - return MSG_ERR_CALLBACK_ERROR; + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; } return err; @@ -83,11 +105,20 @@ EXPORT_API int msg_reg_sent_status_callback(msg_handle_t handle, msg_sent_status EXPORT_API int msg_reg_sms_message_callback(msg_handle_t handle, msg_sms_incoming_cb cb, unsigned short port, void *user_param) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || cb == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -99,7 +130,10 @@ EXPORT_API int msg_reg_sms_message_callback(msg_handle_t handle, msg_sms_incomin catch (MsgException& e) { MSG_FATAL("%s", e.what()); - return MSG_ERR_CALLBACK_ERROR; + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; } return err; @@ -108,16 +142,25 @@ EXPORT_API int msg_reg_sms_message_callback(msg_handle_t handle, msg_sms_incomin EXPORT_API int msg_reg_mms_conf_message_callback(msg_handle_t handle, msg_mms_conf_msg_incoming_cb cb, const char *app_id, void *user_param) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || cb == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } if (app_id && strlen(app_id) > MAX_MMS_JAVA_APPID_LEN) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -129,7 +172,10 @@ EXPORT_API int msg_reg_mms_conf_message_callback(msg_handle_t handle, msg_mms_co catch (MsgException& e) { MSG_FATAL("%s", e.what()); - return MSG_ERR_CALLBACK_ERROR; + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; } return err; @@ -138,11 +184,20 @@ EXPORT_API int msg_reg_mms_conf_message_callback(msg_handle_t handle, msg_mms_co EXPORT_API int msg_reg_syncml_message_callback(msg_handle_t handle, msg_syncml_msg_incoming_cb cb, void *user_param) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || cb == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -154,7 +209,10 @@ EXPORT_API int msg_reg_syncml_message_callback(msg_handle_t handle, msg_syncml_ catch (MsgException& e) { MSG_FATAL("%s", e.what()); - return MSG_ERR_CALLBACK_ERROR; + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; } return err; @@ -163,11 +221,20 @@ EXPORT_API int msg_reg_syncml_message_callback(msg_handle_t handle, msg_syncml_ EXPORT_API int msg_reg_lbs_message_callback(msg_handle_t handle, msg_lbs_msg_incoming_cb cb, void *user_param) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || cb == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -179,7 +246,10 @@ EXPORT_API int msg_reg_lbs_message_callback(msg_handle_t handle, msg_lbs_msg_inc catch (MsgException& e) { MSG_FATAL("%s", e.what()); - return MSG_ERR_CALLBACK_ERROR; + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; } return err; @@ -188,11 +258,20 @@ EXPORT_API int msg_reg_lbs_message_callback(msg_handle_t handle, msg_lbs_msg_inc EXPORT_API int msg_reg_syncml_message_operation_callback(msg_handle_t handle, msg_syncml_msg_operation_cb cb, void *user_param) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || cb == NULL) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -204,7 +283,125 @@ EXPORT_API int msg_reg_syncml_message_operation_callback(msg_handle_t handle, m catch (MsgException& e) { MSG_FATAL("%s", e.what()); - return MSG_ERR_CALLBACK_ERROR; + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; + } + + return err; +} + + +EXPORT_API int msg_reg_push_message_callback(msg_handle_t handle, msg_push_msg_incoming_cb cb, const char *app_id, void *user_param) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || cb == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + if (app_id && strlen(app_id) > MAX_WAPPUSH_ID_LEN) + { + return MSG_ERR_INVALID_PARAMETER; + } + + MsgHandle* pHandle = (MsgHandle*)handle; + + try + { + err = pHandle->regPushMessageCallback(cb, app_id, user_param); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; + } + + return err; +} + +EXPORT_API int msg_reg_cb_message_callback(msg_handle_t handle, msg_cb_incoming_cb cb, bool bsave, void *user_param) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || cb == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + MsgHandle* pHandle = (MsgHandle*)handle; + + try + { + err = pHandle->regCBMessageCallback(cb, bsave, user_param); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; + } + + return err; +} + + +EXPORT_API int msg_reg_report_message_callback(msg_handle_t handle, msg_report_msg_incoming_cb cb, void *user_param) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + msg_error_t err = MSG_SUCCESS; + + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + + if (handle == NULL || cb == NULL) + { + return MSG_ERR_INVALID_PARAMETER; + } + + MsgHandle* pHandle = (MsgHandle*)handle; + + try + { + err = pHandle->regReportMessageCallback(cb, user_param); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + if (e.errorCode() == MsgException::SERVER_READY_ERROR) + return MSG_ERR_PERMISSION_DENIED; + else + return MSG_ERR_CALLBACK_ERROR; } return err; @@ -213,11 +410,20 @@ EXPORT_API int msg_reg_syncml_message_operation_callback(msg_handle_t handle, m EXPORT_API int msg_syncml_message_operation(msg_handle_t handle, msg_message_id_t msgId) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || msgId < 1) { - return -EINVAL; + return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; @@ -261,14 +467,14 @@ static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_ { if (phone_num == NULL || sms_text == NULL || cb == NULL) { - MSG_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num, sms_text, cb); - return -EINVAL; + MSG_SEC_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num, sms_text, cb); + return MSG_ERR_INVALID_PARAMETER; } if (strlen(phone_num) > MAX_PHONE_NUMBER_LEN) { - MSG_DEBUG("Phone Number is too long [%s]", phone_num); - return -EINVAL; + MSG_SEC_DEBUG("Phone Number is too long [%s]", phone_num); + return MSG_ERR_INVALID_PARAMETER; } msg_struct_s req = {0,}; @@ -298,37 +504,56 @@ static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_ msg_info.subType = MSG_NORMAL_SMS; msg_info.msgId = 0; msg_info.folderId = MSG_OUTBOX_ID; + msg_info.simIndex = MSG_SIM_SLOT_ID_1; /* fill the destination number in msgReq */ + MSG_ADDRESS_INFO_S address = {0,}; + memset(&address, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + + address.addressType = MSG_ADDRESS_TYPE_PLMN; + address.recipientType = MSG_RECIPIENTS_TYPE_TO; + snprintf(address.addressVal, MAX_ADDRESS_VAL_LEN, "%s", phone_num); + msg_struct_list_s addr_list = {0,}; addr_list.nCount = 1; + addr_list.msg_struct_info = (msg_struct_t *)calloc(1, sizeof(msg_struct_t)); + if (addr_list.msg_struct_info) { + addr_list.msg_struct_info[0] = (msg_struct_t)new msg_struct_s; + msg_struct_s *pTmp; + pTmp = (msg_struct_s *)addr_list.msg_struct_info[0]; + pTmp->type = MSG_STRUCT_ADDRESS_INFO; + pTmp->data = &address; + } else { + MSG_ERR("Memory error"); + msg_close_msg_handle(&msgHandle); + return MSG_ERR_MEMORY_ERROR; + } - msg_struct_s addr_info[addr_list.nCount]; - memset(addr_info, 0, sizeof(msg_struct_s) * addr_list.nCount); - addr_list.msg_struct_info = (msg_struct_t *)&addr_info; + msg_info.addr_list = (msg_struct_list_s *)&addr_list; - MSG_ADDRESS_INFO_S address[addr_list.nCount]; - memset(address, 0, sizeof(MSG_ADDRESS_INFO_S) * addr_list.nCount); + msg_info.bPortValid = false; - for (int i = 0; i < addr_list.nCount; i++) { - addr_info[i].type = MSG_STRUCT_ADDRESS_INFO; - addr_info[i].data = (void *)&address[i]; + /* fill the msg text in msgReq */ + msg_info.dataSize = strlen(sms_text); + msg_info.pData = (void*)sms_text; - address[i].addressType = MSG_ADDRESS_TYPE_PLMN; - snprintf(address[i].addressVal, MAX_ADDRESS_VAL_LEN+1, "%s", phone_num); + /* Send option */ + msg_struct_s sendOpt = {0,}; + MSG_SENDINGOPT_S send_info; + memset(&send_info, 0x00, sizeof(MSG_SENDINGOPT_S)); - address[i].recipientType = MSG_RECIPIENTS_TYPE_TO; - } + sendOpt.type = MSG_STRUCT_SENDOPT; + sendOpt.data = (void *)&send_info; - msg_info.addr_list = &addr_list; + msg_struct_s smsSendOpt = {0,}; + SMS_SENDINGOPT_INFO_S sms_send_opt = {0,}; + memset(&sms_send_opt, 0x00, sizeof(SMS_SENDINGOPT_INFO_S)); - msg_info.bPortValid = false; + smsSendOpt.type = MSG_STRUCT_SMS_SENDOPT; + smsSendOpt.data = (void *)&sms_send_opt; - /* fill the msg text in msgReq */ - msg_info.dataSize = strlen(sms_text); - msg_info.pData = (void*)malloc(msg_info.dataSize+1); - strncpy((char *)msg_info.pData, sms_text, msg_info.dataSize); + send_info.smsSendOpt = (msg_struct_t)&smsSendOpt; sentStatusCallback = cb; @@ -344,9 +569,15 @@ static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_ // sending message request msgReq.msg = (msg_struct_t)&msg; + msgReq.sendOpt = (msg_struct_t)&sendOpt; retVal = msg_submit_req(msgHandle, (msg_struct_t)&req); + if (addr_list.msg_struct_info) { + g_free(addr_list.msg_struct_info); + addr_list.msg_struct_info = NULL; + } + if (retVal != MSG_SUCCESS) { MSG_DEBUG("msg_submit_req() is failed. Error Code = %d", retVal); @@ -359,30 +590,40 @@ static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_ EXPORT_API int msg_sms_send(const char *phone_num_list, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (phone_num_list == NULL || sms_text == NULL || cb == NULL) { - MSG_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num_list, sms_text, cb); - return -EINVAL; + MSG_SEC_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num_list, sms_text, cb); + return MSG_ERR_INVALID_PARAMETER; } char trimmed_num[strlen(phone_num_list)+1]; bzero(trimmed_num, strlen(phone_num_list)+1); + char *temp = NULL; msg_error_t retVal = msg_verify_number(phone_num_list, trimmed_num); if ( retVal != MSG_SUCCESS ) return retVal; - for( char* cur_num = strtok(trimmed_num,", "); cur_num ; cur_num = strtok(NULL,", ")) + for( char* cur_num = strtok_r(trimmed_num,", ", &temp); cur_num ; cur_num = strtok_r(NULL,", ", &temp)) { if (strlen(cur_num) > MAX_PHONE_NUMBER_LEN) { - MSG_DEBUG("Phone number is too long [%s], and sending is skipped", cur_num); + MSG_SEC_DEBUG("Phone number is too long [%s], and sending is skipped", cur_num); continue; } - MSG_DEBUG("phone number: [%s]", cur_num); - MSG_DEBUG("text: [%s]", sms_text); + MSG_SEC_DEBUG("phone number: [%s]", cur_num); + MSG_SEC_DEBUG("text: [%s]", sms_text); retVal = msg_send_single_sms(cur_num, sms_text, cb, user_param); if (retVal != MSG_SUCCESS) @@ -395,8 +636,17 @@ EXPORT_API int msg_sms_send(const char *phone_num_list, const char *sms_text, ms EXPORT_API int msg_sms_send_message(msg_handle_t handle, msg_struct_t req) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || !req) { MSG_FATAL("handle or req is NULL"); return MSG_ERR_NULL_POINTER; @@ -429,6 +679,8 @@ EXPORT_API int msg_sms_send_message(msg_handle_t handle, msg_struct_t req) reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed reqmsg->networkStatus = MSG_NETWORK_SENDING; + MSG_DEBUG("Coding Scheme From App. = [%d]", reqmsg->encodeType); + err = msg_submit_req(handle, req); if (err == MSG_SUCCESS) @@ -442,8 +694,17 @@ EXPORT_API int msg_sms_send_message(msg_handle_t handle, msg_struct_t req) EXPORT_API int msg_mms_send_message(msg_handle_t handle, msg_struct_t req) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || !req) { MSG_FATAL("handle or req is NULL"); @@ -459,7 +720,7 @@ EXPORT_API int msg_mms_send_message(msg_handle_t handle, msg_struct_t req) MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data; - if (reqmsg->dataSize <= 0) + if (reqmsg->mmsDataSize <= 0) { MSG_FATAL("MMS data size is invalid"); return MSG_ERR_INVALID_PARAMETER; @@ -483,14 +744,25 @@ EXPORT_API int msg_mms_send_message(msg_handle_t handle, msg_struct_t req) EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t msgId, msg_read_report_status_t mms_read_status) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL) { return MSG_ERR_INVALID_PARAMETER; } msg_struct_t req_t = msg_create_struct(MSG_STRUCT_REQUEST_INFO); + if (req_t == NULL) + return MSG_ERR_NOT_SUPPORTED; msg_struct_s *req_s = (msg_struct_s *)req_t; MSG_REQUEST_S *req = (MSG_REQUEST_S *)req_s->data; @@ -502,6 +774,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; } @@ -516,7 +789,7 @@ EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t ms reqmsg->mainType = MSG_MMS_TYPE; reqmsg->subType = MSG_READREPLY_MMS; - reqmsg->dataSize = read_report_datasize; + reqmsg->mmsDataSize = read_report_datasize; reqmsg->pMmsData = read_report_data; err = msg_submit_req(handle, req_t); @@ -537,8 +810,17 @@ EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t ms EXPORT_API int msg_mms_forward_message(msg_handle_t handle, msg_struct_t req) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || !req ) { MSG_FATAL("handle or req is NULL"); @@ -572,8 +854,17 @@ EXPORT_API int msg_mms_forward_message(msg_handle_t handle, msg_struct_t req) EXPORT_API int msg_mms_retrieve_message(msg_handle_t handle, msg_struct_t req) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if ( handle == NULL|| !req) { MSG_FATAL("handle or req is NULL"); @@ -605,8 +896,17 @@ EXPORT_API int msg_mms_retrieve_message(msg_handle_t handle, msg_struct_t req) /* reject_msg_support */ EXPORT_API int msg_mms_reject_message(msg_handle_t handle, msg_struct_t req) { + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE); msg_error_t err = MSG_SUCCESS; + //Privilege check + int ret = PRIV_MGR_ERROR_SUCCESS; + ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME); + if(ret != PRIV_MGR_ERROR_SUCCESS) + { + return MSG_ERR_PERMISSION_DENIED; + } + if (handle == NULL || !req ) { MSG_FATAL("handle or req is NULL"); diff --git a/mms-plugin.manifest b/mms-plugin.manifest new file mode 100755 index 0000000..2a0cec5 --- /dev/null +++ b/mms-plugin.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/msg-server b/msg-server index 0c9ab19..d8f67c9 100755 --- a/msg-server +++ b/msg-server @@ -1,7 +1,7 @@ #!/bin/sh ## A script for running msg-server in booting time. - -if [ ! -e /opt/etc/.hib_capturing ]; then +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin +#For log +# Launch msg-server /usr/bin/msg-server & -fi diff --git a/msg-service-tools.manifest b/msg-service-tools.manifest new file mode 100755 index 0000000..c987f54 --- /dev/null +++ b/msg-service-tools.manifest @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/msg-service.manifest b/msg-service.manifest new file mode 100755 index 0000000..138d9d6 --- /dev/null +++ b/msg-service.manifest @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/msg-service.rule b/msg-service.rule new file mode 100755 index 0000000..c273e71 --- /dev/null +++ b/msg-service.rule @@ -0,0 +1,51 @@ +msg-service msg-service::db rw---- ------ +msg-service msg-service::vconf rw---- ------ +msg-service system::use_internet rw---- ------ +msg-service media-server rw---- ------ +msg-service system::vconf rwxat- ------ +msg-service system::vconf_inhouse rw---- ------ +msg-service system::vconf_setting r----- ------ +msg-service telephony_framework::api_sms rwx--- ------ +msg-service telephony_framework::api_sim rw---- ------ +msg-service telephony_framework::api_sat --x--- ------ +msg-service telephony_framework::api_ps_public rw---- ------ +msg-service telephony_framework::api_ps_private rw---- ------ +msg-service telephony_framework::api_ps_profile rw---- ------ +msg-service telephony_framework::properties rw---- ------ +msg-service contacts-service::svc r----- ------ +msg-service contacts-service::phonelog rw---- ------ +msg-service ug-setting-call-efl::vconf r----- ------ +msg-service org.tizen.browser::vconf_public r----- ------ +msg-service testmode::vconf r----- ------ +msg-service data-provider-master::notification rw---- ------ +msg-service data-provider-master::notification.client -w---- ------ +msg-service data-provider-master::badge rw---- ------ +msg-service data-provider-master::badge.client -w---- ------ +msg-service oma-dm-agent::vconf_external r----- ------ +msg-service deviced::display rw---- ------ +msg-service net-config rw---- ------ +msg-service connman rw---- ------ +msg-service connman::get rw---- ------ +msg-service connman::set rw---- ------ +msg-service connman::profile rw---- ------ +msg-service aul::launch --x--- ------ +msg-service alarm-server::alarm rw---- ------ +msg-service security-server::api-get-gid -w---- ------ +msg-service security-server::api-cookie-check -w---- ------ +msg-service security-server::api-privilege-by-pid -w---- ------ +msg-service device::app_logging -w---- ------ +msg-service device::sys_logging -w---- ------ +msg-service system::share -wx--- ------ +msg-service system::vconf_system r----l ------ +msg-service pkgmgr::db r----l ------ +msg-service ail::db r----- ------ +msg-service badge::db r----l ------ +msg-service notification::db r----l ------ +msg-service org.tizen.setting::default-resources r----l ------ + +net-config msg-service rw---- ------ +connman msg-service rw---- ------ +system::use_internet msg-service rw---- ------ +org.tizen.quickpanel msg-service r-x--- ------ +org.tizen.indicator msg-service rwx--- ------ +org.tizen.lockscreen msg-service r-x--- ------ diff --git a/msg_helper/CMakeLists.txt b/msg_helper/CMakeLists.txt deleted file mode 100755 index 893f0ce..0000000 --- a/msg_helper/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -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") - -########################################################## -# Define Test App -########################################################## - -SET(MSG-HELPER-SRCS - ${CMAKE_SOURCE_DIR}/msg_helper/MsgSensorWrapper.cpp - ${CMAKE_SOURCE_DIR}/msg_helper/MsgSoundPlayer.cpp - ${CMAKE_SOURCE_DIR}/msg_helper/main.cpp -) - -INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/include/mapi - ${CMAKE_SOURCE_DIR}/include/common - ${CMAKE_SOURCE_DIR}/include/framework - ${CMAKE_SOURCE_DIR}/include/msg_helper - ${CMAKE_SOURCE_DIR}/include/utils -) - -INCLUDE(FindPkgConfig) -pkg_check_modules(msg_helper_pkgs REQUIRED glib-2.0 dlog vconf devman_haptic mm-player mm-fileinfo mm-player svi sensor) - -FOREACH(flag ${msg_helper_pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") - -ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") - -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") - -ADD_EXECUTABLE(msg-helper ${MSG-HELPER-SRCS}) -TARGET_LINK_LIBRARIES(msg-helper ${msg_helper_pkgs_LDFLAGS} ${UTILS-LIB}) - -INSTALL(TARGETS msg-helper DESTINATION bin) - diff --git a/msg_helper/MsgSoundPlayer.cpp b/msg_helper/MsgSoundPlayer.cpp deleted file mode 100755 index 10da84f..0000000 --- a/msg_helper/MsgSoundPlayer.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/* -* 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 - -#include "MsgDebug.h" -#include "MsgCppTypes.h" -#include "MsgSettingTypes.h" -#include "MsgGconfWrapper.h" -#include "MsgUtilFile.h" -#include "MsgHelper.h" - -#include -#include - -#include -#include -#include - - -extern void worker_done(); - -/*================================================================================================== - VARIABLES -==================================================================================================*/ -static MMHandleType hPlayerHandle = 0; -static bool bPlaying = false; -static bool bVibrating = false; -static int dev_handle; - -pthread_mutex_t muMmPlay = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t cvMmPlay = PTHREAD_COND_INITIALIZER; - -/*================================================================================================== - FUNCTION IMPLEMENTATION -==================================================================================================*/ - -static gboolean MsgStopAndExit(void* data) -{ - MsgSoundPlayStop(); - if(!bPlaying && !bVibrating) - worker_done(); - - return FALSE; -} - -static gboolean MsgUninitAndExit(void* data) -{ - MsgSoundPlayUninit(); - if(!bPlaying && !bVibrating) - worker_done(); - - return FALSE; -} - -static gboolean MsgSoundMelodyTimeout(gpointer data) -{ - MSG_BEGIN(); - - MsgSoundPlayStop(); - if(!bPlaying && !bVibrating) - worker_done(); - - MSG_END(); - - return FALSE; -} - - -static gboolean MsgSoundVibTimeout(gpointer data) -{ - MSG_BEGIN(); - - int ret = 0; - - if (bVibrating == true) { - ret = device_haptic_stop_play(dev_handle); - - if (ret != 0) { - MSG_DEBUG("Fail to stop haptic : [%d]", ret); - } - - ret = device_haptic_close(dev_handle); - - if (ret != 0) { - MSG_DEBUG("Fail to close haptic : [%d]", ret); - } - - bVibrating = false; - } - - if(!bPlaying && !bVibrating) - worker_done(); - - MSG_END(); - - return FALSE; -} - - -static int MsgSoundPlayCallback(int message, void *param, void *user_param) -{ - switch (message) - { - case MM_MESSAGE_ERROR: - MSG_DEBUG("ERROR is happened."); - g_idle_add (MsgUninitAndExit, NULL); - break; - case MM_MESSAGE_BEGIN_OF_STREAM: - MSG_DEBUG("Play is started."); - break; - case MM_MESSAGE_END_OF_STREAM: - case MM_MESSAGE_STATE_INTERRUPTED: - MSG_DEBUG("EOS or Interrupted."); - g_idle_add (MsgStopAndExit, NULL); - break; - default: - MSG_DEBUG("message = %d", message); - break; - } - - return 1; -} - - -void* MsgPlayThread(void *data) -{ - MSG_BEGIN(); - - bool bSoundOn = false; - bool bVibrationOn = false; - int callStatus = 0; /* 0 - off, 1 - sound, 2 - vibration */ - int alertOnCall = 0; - - char *msg_tone_file_path = NULL; - AutoPtr buf(&msg_tone_file_path); - - char *tmpFileFath = NULL; - - 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); - } 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; - } - - MSG_DEBUG("Sound File [%s]", 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(err != MM_ERROR_NONE) - MSG_DEBUG("MM Session Init Failed"); - else - MSG_DEBUG("MM Session Init Success : %d", err); - - hPlayerHandle = 0; - - err = mm_player_create(&hPlayerHandle); - - if (err != MM_ERROR_NONE) { - MSG_DEBUG("creating the player handle failed"); - return NULL; - } - - /* Setting the call back function msg_callback */ - mm_player_set_message_callback(hPlayerHandle, MsgSoundPlayCallback, (void *)hPlayerHandle); - - callStatus = MsgSettingGetInt(VCONFKEY_CALL_STATE); - MSG_DEBUG("Call Status = %d", callStatus); - - if (callStatus > VCONFKEY_CALL_OFF && callStatus < VCONFKEY_CALL_STATE_MAX) { - alertOnCall = MsgSettingGetInt(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT); - MSG_DEBUG("Alert On Call = %d", alertOnCall); - - if (alertOnCall == 0) { - MSG_DEBUG("Call is active & Alert on Call - Off"); - } else if (alertOnCall == 1) { - MSG_DEBUG("Call is active & Alert on Call - Sound"); - - if (bSoundOn) - MsgSoundPlayMelody(msg_tone_file_path, false); - } else if (alertOnCall == 2) { - MSG_DEBUG("Call is active & Alert on Call - Vibration"); - - if (bVibrationOn) - MsgSoundPlayVibration(); - } - } else{ - MSG_DEBUG("Call is not active"); - - if (bVibrationOn) { - MSG_DEBUG("Play vibration."); - MsgSoundPlayVibration(); - } - - if (bSoundOn) { - MSG_DEBUG("Play sound."); - MsgSoundPlayMelody(msg_tone_file_path, false); - } - } - - err = mm_session_finish(); - - if (err != MM_ERROR_NONE) - MSG_DEBUG("MM Session Finish Failed"); - else - MSG_DEBUG("MM Session Finish Success : %d", err); - - if(!bPlaying && !bVibrating) - worker_done(); - - MSG_END(); - - return NULL; -} - - -msg_error_t MsgSoundPlayUninit() -{ - MSG_BEGIN(); - - int err = MM_ERROR_NONE; - - /* Uninitializing the player module */ - err = mm_player_unrealize(hPlayerHandle); - - /* Destroying the player handle */ - err = mm_player_destroy(hPlayerHandle); - - pthread_mutex_lock(&muMmPlay); - - bPlaying = false; - - pthread_mutex_unlock(&muMmPlay); - - pthread_cond_signal(&cvMmPlay); - - hPlayerHandle = 0; - - MSG_END(); - - return MSG_SUCCESS; -} - - -void MsgSoundPlayStart() -{ - MSG_BEGIN(); - - pthread_mutex_lock(&muMmPlay); - - if (bPlaying == true) { - MSG_DEBUG("Ringtone is Playing..."); - pthread_mutex_unlock(&muMmPlay); - return; - } - - pthread_mutex_unlock(&muMmPlay); - - pthread_t tid; - - if (pthread_create(&tid, NULL, &MsgPlayThread, (void*)NULL) == 0) { - MSG_DEBUG("Ring alert thread created = %d", tid); - } else { - MSG_DEBUG("Creating Thread was failed"); - return; - } - - MSG_END(); -} - - -void MsgSoundPlayStop() -{ - MSG_BEGIN(); - - pthread_mutex_lock(&muMmPlay); - - if (bPlaying == false) { - MSG_DEBUG("Ringtone is Not Playing..."); - pthread_mutex_unlock(&muMmPlay); - return; - } - - pthread_mutex_unlock(&muMmPlay); - - /* Stop playing media contents */ - MSG_DEBUG("Before mm_player_stop, %p", hPlayerHandle); - - int err = mm_player_stop(hPlayerHandle); - - MSG_DEBUG("After mm_player_stop"); - - if (err != MM_ERROR_NONE) { - MSG_DEBUG("stopping the player handle failed"); - } - - MsgSoundPlayUninit(); - - MSG_END(); -} - - -int MsgSoundPlayMelody(char *pMsgToneFilePath, bool bIncreasing) -{ - int err = MM_ERROR_NONE; - - /* Setting fade in,out */ - err = mm_player_set_attribute(hPlayerHandle, NULL, "sound_priority", 2, NULL); - - if (err != MM_ERROR_NONE) { - MSG_DEBUG("error setting the profile attr"); - return err; - } - - /* Setting the Volume */ - err = mm_player_set_attribute(hPlayerHandle, NULL, "sound_volume_type", MM_SOUND_VOLUME_TYPE_NOTIFICATION, - "profile_uri", pMsgToneFilePath, strlen(pMsgToneFilePath), NULL); - - if (err != MM_ERROR_NONE) { - MSG_DEBUG("error setting the profile attr"); - return err; - } - - err = mm_player_realize(hPlayerHandle); - - if (err != MM_ERROR_NONE) { - MSG_DEBUG("mm_player_realize() error : [%d]", err); - return err; - } - - /* Add Timer to stop playing after 5 sec. */ - int g_contact_timer = -1; - g_contact_timer = g_timeout_add(5500, (GSourceFunc)MsgSoundMelodyTimeout, NULL); - - err = mm_player_start(hPlayerHandle); - - if (err != MM_ERROR_NONE) { - MSG_DEBUG("mm_player_start, FAIL [%x]", err); - bPlaying = false; - - return err; - } - - bPlaying = true; - - pthread_mutex_lock(&muMmPlay); - - while (bPlaying) - { - MSG_DEBUG("Ring Alert Playing"); - pthread_cond_wait(&cvMmPlay, &muMmPlay); - } - - pthread_mutex_unlock(&muMmPlay); - - MSG_DEBUG("Ring Alert Idle"); - - return err; -} - - -void MsgSoundPlayVibration() -{ - MSG_BEGIN(); - - int ret = 0; - int vibLevel = 0; - char ivtFilePath[MAX_SOUND_FILE_LEN] = {0,}; - - vibLevel = MsgSettingGetInt(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT); - - if (vibLevel > 0) { - bVibrating = true; - - dev_handle = device_haptic_open(DEV_IDX_0, 0); - - g_timeout_add(MSG_VIBRATION_INTERVAL , MsgSoundVibTimeout, NULL); - - /* 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); - - if (ret != 0) { - MSG_DEBUG("Fail to play haptic : [%d]", ret); - } - } - - MSG_END(); -} - - -int MsgSoundGetUnreadMsgCnt() -{ - int unreadCnt = 0; - - /* Get SMS Count */ - unreadCnt = MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_SMS_STATE); - - /* Get MMS Count */ - unreadCnt += MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE); - - MSG_DEBUG("unread count : [%d]", unreadCnt); - - return unreadCnt; -} diff --git a/msg_helper/main.cpp b/msg_helper/main.cpp deleted file mode 100755 index 94115aa..0000000 --- a/msg_helper/main.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -* 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 -#include -#include -#include - -#include "MsgHelper.h" -#include "MsgUtilFile.h" -#include "MsgCppTypes.h" -#include "MsgDebug.h" - -static GMainLoop *loop; - -static gboolean _worker_done(void* data) -{ - if (g_main_loop_is_running(loop)) - g_main_loop_quit(loop); - - return 0; -} - -// may called by threads -void worker_done() -{ - g_idle_add(_worker_done,NULL); -} - -int main(int argc, char** argv) -{ - - MSG_DEBUG("############### Start msg_helper ###############"); - -#if !GLIB_CHECK_VERSION(2, 31, 0) - g_thread_init(NULL); -#endif - - bool notEnd = false; - - if(argc < 1) - { - MSG_DEBUG("No arguments to run msg_helper."); - return 0; - } - - MSG_DEBUG("argv[0] [%s] ", argv[0]); - - if(strcmp(argv[0],MSG_SOUND_START)==0) - { - MsgSoundPlayStart(); - notEnd = true; - } - else if(strcmp(argv[0],MSG_SOUND_STOP)==0) - { - MsgSoundPlayStop(); - } - - if(notEnd) - { - loop = g_main_loop_new(NULL, FALSE); - - if (MsgSensorConnect() == MSG_SUCCESS) - if (MsgRegSensorCB(&worker_done) != MSG_SUCCESS) - MsgSensorDisconnect(); - - if (loop != NULL) - { - MSG_DEBUG("Waiting for working jobs to be finished!!!"); - - // Run GMainLoop - g_main_loop_run(loop); - } - else - { - MSG_DEBUG("Fail to create g_main_loop!!!"); - MsgSensorDisconnect(); - } - } - - return 0; -} diff --git a/packaging/msg-server.service b/packaging/msg-server.service new file mode 100755 index 0000000..458cbf6 --- /dev/null +++ b/packaging/msg-server.service @@ -0,0 +1,13 @@ +[Unit] +Description=Message server +After=tizen-runtime.target contacts-service.service +Requires=tizen-runtime.target contacts-service.service + +[Service] +Type=forking +ExecStart=/etc/rc.d/init.d/msg-server +Restart=always +MemoryLimit=10M + +[Install] +WantedBy=multi-user.target diff --git a/packaging/msg-service.spec b/packaging/msg-service.spec index b626d5a..ba533a4 100755 --- a/packaging/msg-service.spec +++ b/packaging/msg-service.spec @@ -1,7 +1,7 @@ Name: msg-service -Version: 0.9.0 +Version: 1.0.0 Release: 1 -License: Samsung +License: Apache-2.0 Summary: Messaging Framework Library Group: System/Libraries Source0: %{name}-%{version}.tar.gz @@ -10,16 +10,27 @@ Requires(post): /usr/bin/sqlite3 Requires(post): /usr/bin/vconftool Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig +Requires(post): systemd +Requires(postun): systemd BuildRequires: cmake BuildRequires: pkgconfig(alarm-service) BuildRequires: pkgconfig(aul) +BuildRequires: pkgconfig(badge) BuildRequires: pkgconfig(capi-appfw-application) -BuildRequires: pkgconfig(contacts-service) +BuildRequires: pkgconfig(capi-network-connection) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(capi-telephony) +BuildRequires: pkgconfig(contacts-service2) +BuildRequires: pkgconfig(csr-framework) BuildRequires: pkgconfig(db-util) -BuildRequires: pkgconfig(devman_haptic) +BuildRequires: pkgconfig(deviced) BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(drm-client) -BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(feedback) +BuildRequires: pkgconfig(gio-2.0) +BuildRequires: pkgconfig(gobject-2.0) +BuildRequires: pkgconfig(iniparser) +BuildRequires: pkgconfig(json-glib-1.0) +BuildRequires: pkgconfig(lbs-dbus) BuildRequires: pkgconfig(libcurl) BuildRequires: pkgconfig(libsystemd-daemon) BuildRequires: pkgconfig(libxml-2.0) @@ -28,14 +39,14 @@ BuildRequires: pkgconfig(media-thumbnail) BuildRequires: pkgconfig(mm-fileinfo) BuildRequires: pkgconfig(mm-player) BuildRequires: pkgconfig(mm-session) -BuildRequires: pkgconfig(network) -BuildRequires: pkgconfig(notification) -BuildRequires: pkgconfig(pmapi) +BuildRequires: pkgconfig(mm-sound) BuildRequires: pkgconfig(mmutil-imgp) BuildRequires: pkgconfig(mmutil-jpeg) +BuildRequires: pkgconfig(notification) +BuildRequires: pkgconfig(privacy-manager-client) BuildRequires: pkgconfig(security-server) BuildRequires: pkgconfig(sensor) -BuildRequires: pkgconfig(svi) +BuildRequires: pkgconfig(storage) BuildRequires: pkgconfig(tapi) BuildRequires: pkgconfig(vconf) @@ -44,7 +55,7 @@ Description: Messaging Framework Library %package devel -License: Apache License v2.0 +License: Apache-2.0 Summary: Messaging Framework Library (development) Requires: %{name} = %{version}-%{release} Group: Development/Libraries @@ -54,7 +65,7 @@ Description: Messaging Framework Library (development) %package tools -License: Apache License v2.0 +License: Apache-2.0 Summary: Messaging server application Requires: %{name} = %{version}-%{release} Group: TO_BU / FILL_IN @@ -68,7 +79,7 @@ Description: Messaging server application %package -n sms-plugin -License: Apache License v2.0 +License: Apache-2.0 Summary: SMS plugin library Requires: %{name} = %{version}-%{release} Group: System/Libraries @@ -79,7 +90,7 @@ Requires(postun): /sbin/ldconfig Description: SMS plugin library %package -n mms-plugin -License: Apache License v2.0 +License: Apache-2.0 Summary: MMS plugin library Requires: %{name} = %{version}-%{release} Group: System/Libraries @@ -92,195 +103,232 @@ Description: MMS plugin library %prep %setup -q - %build -cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} + +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ +%ifarch i586 +-D_TIZEN_I586_ENABLED:BOOL=ON +%else +-D_TIZEN_I586_ENABLED:BOOL=OFF +%endif + make %{?jobs:-j%jobs} %install - rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license +mkdir -p %{buildroot}/etc/config + %make_install -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d -ln -s %{_sysconfdir}/rc.d/init.d/msg-server %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S70msg-server -mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d -ln -s %{_sysconfdir}/rc.d/init.d/msg-server %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S70msg-server +mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants +ln -s ../msg-server.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/msg-server.service + +mkdir -p %{buildroot}/opt/usr/dbspace +sqlite3 %{buildroot}/opt/usr/dbspace/.msg_service.db "PRAGMA journal_mode = PERSIST;" +sqlite3 %{buildroot}/opt/usr/dbspace/.msg_service.db < %{buildroot}/usr/share/msg-service/msg-service-db.sql + +rm %{buildroot}/usr/share/msg-service/msg-service-db.sql +%post tools +/sbin/ldconfig +chown :5000 /opt/usr/dbspace/.msg_service.db +chown :5000 /opt/usr/dbspace/.msg_service.db-journal +chmod 660 /opt/usr/dbspace/.msg_service.db +chmod 660 /opt/usr/dbspace/.msg_service.db-journal -mkdir -p %{buildroot}/opt/data/msg-service +if [ -f /usr/lib/rpm-plugins/msm.so ] +then + chsmack -a 'msg-service::db' /opt/usr/dbspace/.msg_service.db* +fi -%post tools -p /sbin/ldconfig %post -n sms-plugin -p /sbin/ldconfig %post -n mms-plugin -p /sbin/ldconfig %post /sbin/ldconfig -if [ ! -f /opt/dbspace/.msg_service.db ] +mkdir -p /opt/usr/data/msg-service +chgrp db_msg_service /opt/usr/data/msg-service + +if [ -f /usr/lib/rpm-plugins/msm.so ] then - sqlite3 /opt/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 , DELIVERY_REPORT_STATUS INTEGER DEFAULT 0 , DELIVERY_REPORT_TIME DATETIME , READ_REPORT_STATUS INTEGER DEFAULT 0 , READ_REPORT_TIME DATETIME , 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 ); - 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 INDEX MSG_CONVERSATION_INDEX ON MSG_CONVERSATION_TABLE(CONV_ID); - CREATE INDEX MSG_FOLDER_INDEX ON MSG_FOLDER_TABLE(FOLDER_ID); - CREATE INDEX MSG_MESSAGE_INDEX ON MSG_MESSAGE_TABLE(MSG_ID, CONV_ID, FOLDER_ID); - - INSERT INTO MSG_FOLDER_TABLE VALUES (1, 'INBOX', 1); - INSERT INTO MSG_FOLDER_TABLE VALUES (2, 'OUTBOX', 2); - INSERT INTO MSG_FOLDER_TABLE VALUES (3, 'SENTBOX', 2); - INSERT INTO MSG_FOLDER_TABLE VALUES (4, 'DRAFT', 3); - INSERT INTO MSG_FOLDER_TABLE VALUES (5, 'CBMSGBOX', 1); - INSERT INTO MSG_FOLDER_TABLE VALUES (6, 'SPAMBOX', 4); - INSERT INTO MSG_FOLDER_TABLE VALUES (7, 'SMS TEMPLATE', 5); - INSERT INTO MSG_FOLDER_TABLE VALUES (8, 'MMS TEMPLATE', 5);" + chsmack -a "_" -e "_" /etc/rc.d/init.d/msg-server fi -chown :6011 /opt/dbspace/.msg_service.db -chown :6011 /opt/dbspace/.msg_service.db-journal - - -chmod 660 /opt/dbspace/.msg_service.db -chmod 660 /opt/dbspace/.msg_service.db-journal - - ########## Setting Config Value (Internal keys) ########## # Message Server Status -vconftool set -t bool memory/msg/ready 0 -i +vconftool set -t bool memory/msg/ready 0 -i -g 5000 -s system::vconf_inhouse # SMS Send Options -vconftool set -t int db/msg/network_mode 2 +vconftool set -t int db/msg/network_mode 2 -g 5000 -s system::vconf_inhouse # New Message Count -vconftool set -t int db/msg/recv_sms 0 -vconftool set -t int db/msg/recv_mms 0 +vconftool set -t int db/msg/recv_sms 0 -g 5000 -s system::vconf_inhouse +vconftool set -t int db/msg/recv_mms 0 -g 5000 -s system::vconf_inhouse ########## Setting Config Value (Private keys) ########## # General Options -vconftool set -t bool db/private/msg-service/general/keep_copy 1 -vconftool set -t bool db/private/msg-service/general/auto_erase 0 -vconftool set -t bool db/private/msg-service/general/block_msg 0 -vconftool set -t int db/private/msg-service/general/contact_sync_time 0 +vconftool set -t bool db/private/msg-service/general/keep_copy 1 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/general/auto_erase 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/general/block_msg 1 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/general/contact_sync_time 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/general/alert_rep_type 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/general/search_tags 31 -s msg-service::vconf -g 5000 + +vconftool set -t int db/private/msg-service/general/page_limit 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/general/sms_mms_threshold 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/general/max_recipient 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/general/sms_storage 0 -s msg-service::vconf -g 5000 + +vconftool set -t bool db/private/msg-service/general/block_unknown_msg 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/general/sms_limit 1000 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/general/mms_limit 100 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/general/notification 1 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/general/vibration 1 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/general/preview 1 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/general/ringtone_type 0 -s msg-service::vconf -g 5000 +vconftool set -t string db/private/msg-service/general/ringtone_path "" -s msg-service::vconf -g 5000 + +vconftool set -t string db/private/msg-service/general/ua_profile "" -s msg-service::vconf -g 5000 + +vconftool set -t int db/private/msg-service/general/msg_id_counter 0 -s msg-service::vconf -g 5000 # SMS Send Options -vconftool set -t int db/private/msg-service/sms_send/dcs 3 -vconftool set -t bool db/private/msg-service/sms_send/reply_path 0 -vconftool set -t bool db/private/msg-service/sms_send/delivery_report 0 -vconftool set -t int db/private/msg-service/sms_send/save_storage 1 - -# SMSC -vconftool set -t int db/private/msg-service/smsc/total_count 1 -vconftool set -t int db/private/msg-service/smsc/selected 0 - -vconftool set -t int db/private/msg-service/smsc/pid/0 1 -vconftool set -t int db/private/msg-service/smsc/val_period/0 255 -vconftool set -t string db/private/msg-service/smsc/name/0 "" -vconftool set -t int db/private/msg-service/smsc/ton/0 1 -vconftool set -t int db/private/msg-service/smsc/npi/0 1 -vconftool set -t string db/private/msg-service/smsc/address/0 "" - -vconftool set -t int db/private/msg-service/smsc/pid/1 0 -vconftool set -t int db/private/msg-service/smsc/val_period/1 0 -vconftool set -t string db/private/msg-service/smsc/name/1 "" -vconftool set -t int db/private/msg-service/smsc/ton/1 0 -vconftool set -t int db/private/msg-service/smsc/npi/1 0 -vconftool set -t string db/private/msg-service/smsc/address/1 "" - -vconftool set -t int db/private/msg-service/smsc/pid/2 0 -vconftool set -t int db/private/msg-service/smsc/val_period/2 0 -vconftool set -t string db/private/msg-service/smsc/name/2 "" -vconftool set -t int db/private/msg-service/smsc/ton/2 0 -vconftool set -t int db/private/msg-service/smsc/npi/2 0 -vconftool set -t string db/private/msg-service/smsc/address/2 "" +vconftool set -t int db/private/msg-service/sms_send/dcs 3 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/sms_send/reply_path 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/sms_send/delivery_report 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/sms_send/save_storage 1 -s msg-service::vconf -g 5000 # MMS Send Options -vconftool set -t int db/private/msg-service/mms_send/msg_class 0 -vconftool set -t int db/private/msg-service/mms_send/priority 1 -vconftool set -t int db/private/msg-service/mms_send/expiry_time 0 -vconftool set -t int db/private/msg-service/mms_send/custom_delivery 0 -vconftool set -t bool db/private/msg-service/mms_send/sender_visibility 0 -vconftool set -t bool db/private/msg-service/mms_send/delivery_report 1 -vconftool set -t bool db/private/msg-service/mms_send/read_reply 1 -vconftool set -t bool db/private/msg-service/mms_send/keep_copy 0 -vconftool set -t bool db/private/msg-service/mms_send/body_replying 0 -vconftool set -t bool db/private/msg-service/mms_send/hide_recipients 0 -vconftool set -t bool db/private/msg-service/mms_send/report_allowed 1 -vconftool set -t int db/private/msg-service/mms_send/reply_charging 0 -vconftool set -t int db/private/msg-service/mms_send/reply_charging_deadline 0 -vconftool set -t int db/private/msg-service/mms_send/reply_charging_size 0 -vconftool set -t int db/private/msg-service/mms_send/delivery_time 0 -vconftool set -t int db/private/msg-service/mms_send/creation_mode 2 - -# MMS Receive Options -vconftool set -t int db/private/msg-service/mms_recv/home_network 0 -vconftool set -t int db/private/msg-service/mms_recv/abroad_network 0 -vconftool set -t bool db/private/msg-service/mms_recv/read_receipt 1 -vconftool set -t bool db/private/msg-service/mms_recv/delivery_receipt 1 -vconftool set -t bool db/private/msg-service/mms_recv/reject_unknown 0 -vconftool set -t bool db/private/msg-service/mms_recv/reject_advertisement 0 +vconftool set -t int db/private/msg-service/mms_send/msg_class 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_send/priority 1 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_send/expiry_time 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_send/custom_delivery 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_send/sender_visibility 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_send/delivery_report 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_send/read_reply 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_send/keep_copy 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_send/body_replying 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_send/hide_recipients 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_send/report_allowed 1 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_send/reply_charging 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_send/reply_charging_deadline 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_send/reply_charging_size 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_send/delivery_time 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_send/creation_mode 2 -s msg-service::vconf -g 5000 # MMS Receive Options -vconftool set -t int db/private/msg-service/mms_style/font_size 30 -vconftool set -t bool db/private/msg-service/mms_style/font_style/bold 0 -vconftool set -t bool db/private/msg-service/mms_style/font_style/italic 0 -vconftool set -t bool db/private/msg-service/mms_style/font_style/underline 0 -vconftool set -t int db/private/msg-service/mms_style/font_color/red 255 -vconftool set -t int db/private/msg-service/mms_style/font_color/green 255 -vconftool set -t int db/private/msg-service/mms_style/font_color/blue 255 -vconftool set -t int db/private/msg-service/mms_style/font_color/hue 255 -vconftool set -t int db/private/msg-service/mms_style/bg_color/red 0 -vconftool set -t int db/private/msg-service/mms_style/bg_color/green 0 -vconftool set -t int db/private/msg-service/mms_style/bg_color/blue 0 -vconftool set -t int db/private/msg-service/mms_style/bg_color/hue 255 -vconftool set -t int db/private/msg-service/mms_style/page_dur 2 -vconftool set -t int db/private/msg-service/mms_style/page_custom_dur 0 -vconftool set -t int db/private/msg-service/mms_style/page_dur_manual 0 +vconftool set -t int db/private/msg-service/mms_recv/home_network 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_recv/abroad_network 1 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_recv/read_receipt 1 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_recv/delivery_receipt 1 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_recv/reject_unknown 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_recv/reject_advertisement 0 -s msg-service::vconf -g 5000 + +# MMS Style Options +vconftool set -t int db/private/msg-service/mms_style/font_size 30 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_style/font_style/bold 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_style/font_style/italic 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/mms_style/font_style/underline 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/font_color/red 255 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/font_color/green 255 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/font_color/blue 255 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/font_color/hue 255 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/bg_color/red 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/bg_color/green 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/bg_color/blue 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/bg_color/hue 255 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/page_dur 2 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/page_custom_dur 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/mms_style/page_dur_manual 0 -s msg-service::vconf -g 5000 # Push Msg Options -vconftool set -t bool db/private/msg-service/push_msg/recv_option 1 -vconftool set -t int db/private/msg-service/push_msg/service_load 1 +vconftool set -t bool db/private/msg-service/push_msg/recv_option 1 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/push_msg/service_load 1 -s msg-service::vconf -g 5000 # CB Msg Options -vconftool set -t bool db/private/msg-service/cb_msg/receive 1 -f -vconftool set -t int db/private/msg-service/cb_msg/max_sim_count 0 -vconftool set -t int db/private/msg-service/cb_msg/channel_count 0 -vconftool set -t bool db/private/msg-service/cb_msg/language/0 1 -f -vconftool set -t bool db/private/msg-service/cb_msg/language/1 0 -vconftool set -t bool db/private/msg-service/cb_msg/language/2 0 -vconftool set -t bool db/private/msg-service/cb_msg/language/3 0 -vconftool set -t bool db/private/msg-service/cb_msg/language/4 0 -vconftool set -t bool db/private/msg-service/cb_msg/language/5 0 -vconftool set -t bool db/private/msg-service/cb_msg/language/6 0 -vconftool set -t bool db/private/msg-service/cb_msg/language/7 0 -vconftool set -t bool db/private/msg-service/cb_msg/language/8 0 -vconftool set -t bool db/private/msg-service/cb_msg/language/9 0 +vconftool set -t bool db/private/msg-service/cb_msg/receive 0 -f -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/save 0 -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/cb_msg/max_sim_count/1 0 -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/cb_msg/max_sim_count/2 0 -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/cb_msg/max_sim_count/3 0 -f -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/0 1 -f -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/1 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/2 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/3 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/4 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/5 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/6 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/7 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/8 0 -s msg-service::vconf -g 5000 +vconftool set -t bool db/private/msg-service/cb_msg/language/9 0 -s msg-service::vconf -g 5000 # Voice Mail Options -vconftool set -t string db/private/msg-service/voice_mail/voice_mail_number "" +vconftool set -t string db/private/msg-service/voice_mail/voice_mail_number/1 "" -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/voice_mail/voice_mail_count/1 0 -f -s msg-service::vconf -g 5000 +vconftool set -t string db/private/msg-service/voice_mail/voice_mail_alphaid/1 "" -f -s msg-service::vconf -g 5000 + +vconftool set -t string db/private/msg-service/voice_mail/voice_mail_number/2 "" -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/voice_mail/voice_mail_count/2 0 -f -s msg-service::vconf -g 5000 +vconftool set -t string db/private/msg-service/voice_mail/voice_mail_alphaid/2 "" -f -s msg-service::vconf -g 5000 + +vconftool set -t string db/private/msg-service/voice_mail/voice_mail_number/3 "" -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/voice_mail/voice_mail_count/3 0 -f -s msg-service::vconf -g 5000 +vconftool set -t string db/private/msg-service/voice_mail/voice_mail_alphaid/3 "" -f -s msg-service::vconf -g 5000 # MMS Size Options -vconftool set -t int db/private/msg-service/size_opt/msg_size 300 +vconftool set -t int db/private/msg-service/size_opt/msg_size 300 -s msg-service::vconf -g 5000 # SIM message count -vconftool set -t int db/private/msg-service/sim_count/used_cnt 0 -vconftool set -t int db/private/msg-service/sim_count/total_cnt 0 +vconftool set -t int db/private/msg-service/sim_count/used_cnt/1 0 -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/sim_count/total_cnt/1 0 -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/sim_count/used_cnt/2 0 -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/sim_count/total_cnt/2 0 -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/sim_count/used_cnt/3 0 -f -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/sim_count/total_cnt/3 0 -f -s msg-service::vconf -g 5000 # SIM information -vconftool set -t int memory/private/msg-service/sim_changed 0 -i -vconftool set -t string memory/private/msg-service/sim_imsi "" -i -vconftool set -t bool memory/private/msg-service/national_sim 0 -i +vconftool set -t int memory/private/msg-service/sim_changed/1 0 -i -f -s msg-service::vconf -g 5000 +vconftool set -t string memory/private/msg-service/sim_imsi/1 "" -i -f -s msg-service::vconf -g 5000 +vconftool set -t bool memory/private/msg-service/national_sim/1 0 -i -f -s msg-service::vconf -g 5000 +vconftool set -t string memory/private/msg-service/msisdn/1 "" -i -f -s msg-service::vconf -g 5000 +vconftool set -t string memory/private/msg-service/iccid/1 "" -i -f -s msg-service::vconf -g 5000 + +vconftool set -t int memory/private/msg-service/sim_changed/2 0 -i -f -s msg-service::vconf -g 5000 +vconftool set -t string memory/private/msg-service/sim_imsi/2 "" -i -f -s msg-service::vconf -g 5000 +vconftool set -t bool memory/private/msg-service/national_sim/2 0 -i -f -s msg-service::vconf -g 5000 +vconftool set -t string memory/private/msg-service/msisdn/2 "" -i -f -s msg-service::vconf -g 5000 +vconftool set -t string memory/private/msg-service/iccid/2 "" -i -f -s msg-service::vconf -g 5000 + +vconftool set -t int memory/private/msg-service/sim_changed/3 0 -i -f -s msg-service::vconf -g 5000 +vconftool set -t string memory/private/msg-service/sim_imsi/3 "" -i -f -s msg-service::vconf -g 5000 +vconftool set -t bool memory/private/msg-service/national_sim/3 0 -i -f -s msg-service::vconf -g 5000 +vconftool set -t string memory/private/msg-service/msisdn/3 "" -i -f -s msg-service::vconf -g 5000 +vconftool set -t string memory/private/msg-service/iccid/3 "" -i -f -s msg-service::vconf -g 5000 +vconftool set -t int memory/private/msg-service/default_network_sim 0 -i -f -s msg-service::vconf -g 5000 + +# SST information +vconftool set -t bool memory/private/msg-service/sim_st/1 1 -i -f -s msg-service::vconf -g 5000 +vconftool set -t bool memory/private/msg-service/sim_mo_ctrl/1 0 -i -f -s msg-service::vconf -g 5000 + +vconftool set -t bool memory/private/msg-service/sim_st/2 1 -i -f -s msg-service::vconf -g 5000 +vconftool set -t bool memory/private/msg-service/sim_mo_ctrl/2 0 -i -f -s msg-service::vconf -g 5000 + +vconftool set -t bool memory/private/msg-service/sim_st/3 1 -i -f -s msg-service::vconf -g 5000 +vconftool set -t bool memory/private/msg-service/sim_mo_ctrl/3 0 -i -f -s msg-service::vconf -g 5000 + +# Notification +vconftool set -t int db/private/msg-service/notification_priv_id 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/voice_noti_id1 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/voice_noti_id2 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/cb_noti_priv_id 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/sim_msg_noti_priv_id 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/emergency_noti_id 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/sentfail_noti_id 0 -s msg-service::vconf -g 5000 +vconftool set -t int db/private/msg-service/sim_full_noti_id 0 -s msg-service::vconf -g 5000 + %postun -p /sbin/ldconfig @@ -289,17 +337,17 @@ vconftool set -t bool memory/private/msg-service/national_sim 0 -i %postun -n mms-plugin -p /sbin/ldconfig %files +%manifest msg-service.manifest %defattr(-,root,root,-) -%dir /opt/data/msg-service %{_libdir}/libmsg_plugin_manager.so %{_libdir}/libmsg_mapi.so.* %{_libdir}/libmsg_framework_handler.so %{_libdir}/libmsg_transaction_manager.so %{_libdir}/libmsg_utils.so +%{_libdir}/libmsg_externals.so %{_libdir}/libmsg_transaction_proxy.so -%{_sysconfdir}/rc.d/init.d/msg-server -%{_sysconfdir}/rc.d/rc3.d/S70msg-server -%{_sysconfdir}/rc.d/rc5.d/S70msg-server +%{_libdir}/libmsg_vobject.so +/usr/share/license/msg-service/LICENSE.APLv2 %files devel %defattr(-,root,root,-) @@ -308,133 +356,27 @@ vconftool set -t bool memory/private/msg-service/national_sim 0 -i %{_includedir}/msg-service/* %files tools +%manifest msg-service-tools.manifest %defattr(-,root,root,-) -%{_bindir}/msg-helper %{_bindir}/msg-server -%{_datadir}/media/Sherbet.wav -%attr(0644,root,root)/usr/share/msg-service/plugin.cfg +%config(noreplace) /opt/usr/dbspace/.msg_service.db* +%{_sysconfdir}/rc.d/init.d/msg-server +%{_libdir}/systemd/system/msg-server.service +%{_libdir}/systemd/system/multi-user.target.wants/msg-server.service +/usr/share/license/msg-service/LICENSE.APLv2 +/etc/smack/accesses.d/msg-service.rule +/etc/config/* %files -n sms-plugin +%manifest sms-plugin.manifest %defattr(-,root,root,-) %{_libdir}/libmsg_sms_plugin.so +/usr/share/license/msg-service/LICENSE.APLv2 %files -n mms-plugin +%manifest mms-plugin.manifest %defattr(-,root,root,-) %{_libdir}/libmsg_mms_plugin.so -%{_libdir}/libmsg_mms_language_pack.so +/usr/share/license/msg-service/LICENSE.APLv2 %changelog -* Wed Aug 8 2012 KeeBum Kim -- Apply New TAPI. -- Modify transaction data size of sos recipient list. - -* Tue Aug 7 2012 KeeBum Kim -- Fix contact sync defect. -- New MessageFW API. - -* Fri Jul 27 2012 KeeBum Kim -- Change devman_haptic.h to devman_managed.h. -- Modify to set MSG_SERVER_READY before sim status check. -- Fix bug in sim message save related operations. -- Limit sim related APIs not to work on sim not available status. -- Modify indicator icon image path & related. - -* Tue Jul 17 2012 KeeBum Kim -- Modify MAX_SEGMENT_NUM to 15. -- Modify MMplayer related to support interrupted event. -- Fix bug in storage change callback which could cause on submit request. - -* Fri Jun 29 2012 Sangkoo Kim -- Modify vconf key path for sos sending option. - -* Mon Jun 18 2012 Seunghwan Lee -- Storage change callback for scheduled message -- code chage to support glib2-2.32 -- Apply Backup && Restore of Mms Type - -* Fri Jun 15 2012 Sangkoo Kim -- Update display time for scheduled message when it is sent. - -* Thu Jun 14 2012 Seunghwan Lee -- Comment the test app in CMakefile. -- Modify MMS BG color of vconf value. -- Bug fixed wrong query in MsgStoCheckReadReportIsSent -- Add '-i' option for vconf keys of memory type -- Add smsc vconf keys(default value). -- To avoid msg incoming sound and notification on SOS - -* Fri Jun 8 2012 Sangkoo Kim -- Add '-i' option for vconf keys of memory type. -- Add smsc vconf keys(default value). -- To avoid msg incoming sound and notification on SOS state. -- Change BGcolor to black && font colore to white. - -* Wed May 31 2012 Keebum Kim -- Apply Mdm policy. -- SOS message. -- Fix horizontality development problem. -- Remove vconf key for new message count. (db/badge/com.samsung.message) -- Change vconf key path of "mms_send/msg_class" to private. - -* Thu May 24 2012 Keebum Kim -- Add new MAPI. - -* Fri May 18 2012 Sangkoo Kim -- Modify to support new DRM service. -- Rename private vconf keys. -- Modify .postinst and .spec file to pre-install used vconf keys. -- Remove compile warnings. -- Fix bug in manual retrieve operation. - -* Fri May 11 2012 Jaeyun Jeong -- Fix DB conflict which cause db lock. -- Fix bug in Find My Mobile function. -- Add '*' and '#' symbol as valid number. - -* Wed May 9 2012 Keebum Kim -- Change mobile tracker related vconf key define values. -- Apply MDM policy for allowing text messaging. -- Fix bug for getting thumbnail path. -- Enable functionality of scheduled message. -- Change alarm setting of scheduled message from volatile type to non-volatile. -- Fix error in search query. - -* Thu May 3 2012 Keebum Kim -- Change some thread list related APIs to support DB change. -- DB change to support multiple recipient. - -* Thu Apr 19 2012 Keebum Kim -- Modify to manage contact sync time by vconf. -- Use g_idle_add() routine for updating unread message count(vconf values). -- apply try{}catch{} code for handling unexpected exception to avoid thread terminating. -- Fix bug for allocated size of replacing string. -- Resolve search problem for special characters. -- add xmlFree. - -* Tue Apr 10 2012 Keebum Kim -- Remove unused vconf keys. -- Initialize SMSC selected_index. -- Remove systemd related. - -* Thu Apr 05 2012 Jaeyun Jeong -- Add notification property(NOTIFICATION_PROP_DISPLAY_ONLY_SIMMODE) -- Fix S1-2397/2417/2418/2419. -- Remove sent status callback check during submit request. -- Modify offset and limit operation on search. -- Remove invalid folder and file. -- Change browser launching API from aul to service-capi. -- Remove unused file. -- Invalid type checking is fixed. - -* Fri Mar 16 2012 Jaeyun Jeong -- Add #include to support chmod related defines. -- Fix DRM content issue(unregistered mo content) - -* Wed Mar 14 2012 Jaeyun Jeong -- Modify plugin configuration file location for FOTA. -- Remove the db query which create sample data. - -* Wed Feb 29 2012 Jaeyun Jeong -- Update msg-service.spec for OBS. -- Fix TC execute failure. -- Fix S1-1419(Removed mms raw file issue after rebooting) diff --git a/plugin/mms_plugin/CMakeLists.txt b/plugin/mms_plugin/CMakeLists.txt index f8c8eca..b0e1341 100755 --- a/plugin/mms_plugin/CMakeLists.txt +++ b/plugin/mms_plugin/CMakeLists.txt @@ -8,79 +8,44 @@ 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 + MmsPluginCodecCommon.cpp + MmsPluginDecode.cpp + MmsPluginEncode.cpp + MmsPluginTextConvert.cpp MmsPluginTransport.cpp MmsPluginMain.cpp MmsPluginEventHandler.cpp MmsPluginStorage.cpp MmsPluginMessage.cpp MmsPluginMIME.cpp - MmsPluginDecode.cpp - MmsPluginAvCodec.cpp - MmsPluginDebug.cpp MmsPluginConnManWrapper.cpp MmsPluginUserAgent.cpp MmsPluginHttp.cpp - MmsPluginEncode.cpp - MmsPluginCodec.cpp MmsPluginInternal.cpp - MmsPluginContentCodec.cpp - MmsPluginSmil.cpp - MmsPluginSMILValidate.cpp MmsPluginDrm.cpp + MmsPluginUtil.cpp + MmsPluginTcs.cpp + MmsPluginComposer.cpp + MmsPluginAppBase.cpp ) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include/common ${CMAKE_SOURCE_DIR}/include/framework - ${CMAKE_SOURCE_DIR}/include/msg_helper ${CMAKE_SOURCE_DIR}/include/utils + ${CMAKE_SOURCE_DIR}/include/externals + ${CMAKE_SOURCE_DIR}/include/mapi ${CMAKE_CURRENT_SOURCE_DIR}/include ) INCLUDE(FindPkgConfig) -pkg_check_modules(mms_plugin_pkgs REQUIRED glib-2.0 network libxml-2.0 drm-client libcurl mm-fileinfo mmutil-jpeg vconf dlog media-thumbnail) +pkg_check_modules(mms_plugin_pkgs REQUIRED glib-2.0 libcurl mm-fileinfo mmutil-imgp mmutil-jpeg vconf dlog media-thumbnail csr-framework capi-network-connection db-util) FOREACH(flag ${mms_plugin_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") @@ -90,12 +55,13 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") -#ADD_DEFINITIONS("-DWno-write-strings") +ADD_DEFINITIONS("-DFEATURE_JAVA_MMS") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") +SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined") 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} ${EXTERNALS-LIB}) INSTALL(TARGETS ${MMS-PLUGIN-LIB} LIBRARY DESTINATION lib) diff --git a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngLatinUni.cpp b/plugin/mms_plugin/LanguagePack/MmsPluginWmLngLatinUni.cpp deleted file mode 100755 index 1a34a55..0000000 --- a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngLatinUni.cpp +++ /dev/null @@ -1,1131 +0,0 @@ -/* -* 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 "MsgDebug.h" -#include "MmsPluginWmLngPack.h" -#include "MmsPluginMessage.h" -#include - - -#define MAX_ASCII 256 -#define MAX_ASCII_NUM 255 - -static void __WmLngReverseKeyCode(UCHAR *pOutStr, MCHAR *pInputStr, UINT len); -static UINT __WmLngLatin12UnicodeN(MCHAR *pOutStr, UCHAR *pInputStr, UINT len); -static int __WmLngConvertLatin12Unicode (MCHAR *des, UCHAR *str, UINT len); - -#define tabLatin2UniMax 93 -#define tabLatin3UniMax 87 -#define tabLatin4UniMax 96 -#define tabLatin8UniMax 60 -#define tabLatin15UniMax 96 -#define tabLatin5UniMax 96 -#define tabWin1251UniMax 128 -#define tabKoi8rUniMax 128 -#define tabKoi8uUniMax 128 - -#define SIM_SMSP_ALPHA_ID_MAX_LEN 30 -#define SMS_MCHAR_TO_SIM_ALPHA_MASK 0x80 -#define SMS_SIM_ALPHA_TO_MCHAR_MASK 0x7F - - -/* latin2 table */ -typedef struct { - UCHAR latin2; - MCHAR unicode; -}Latin2UniTable; - -const Latin2UniTable tabLatin2Uni[] = { - {0xA0,0x0020},{0xA1,0x0104},{0xA3,0x0141},{0xA4,0x00A4},{0xA5,0x013D}, - {0xA6,0x015A},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x0160},{0xAA,0x015E}, - {0xAB,0x0164},{0xAC,0x0179},{0xAD,0x00AD},{0xAE,0x017D},{0xAF,0x017B}, - {0xB0,0x00B0},{0xB1,0x0105},{0xB2,0x00B8},{0xB3,0x0142},{0xB4,0x00B4}, - {0xB5,0x012D},{0xB7,0x015B},{0xB8,0x00B8},{0xB9,0x0161},{0xBA,0x015F}, - {0xBB,0x0165},{0xBC,0x017A},{0xBE,0x017E},{0xBF,0x017C},{0xC0,0x0154}, - {0xC1,0x00C1},{0xC2,0x00C2},{0xC3,0x0102},{0xC4,0x00C4},{0xC5,0x0139}, - {0xC6,0x0106},{0xC7,0x00C7},{0xC8,0x010C},{0xC9,0x00C9},{0xCA,0x0118}, - {0xCB,0x00CB},{0xCC,0x0114},{0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x010E}, - {0xD0,0x00D0},{0xD1,0x0143},{0xD2,0x0147},{0xD3,0x00D3},{0xD4,0x00D4}, - {0xD5,0x0150},{0xD6,0x00D6},{0xD7,0x00D7},{0xD8,0x0158},{0xD9,0x016E}, - {0xDA,0x00DA},{0xDB,0x0170},{0xDC,0x00DC},{0xDD,0x00DD},{0xDE,0x0162}, - {0xDF,0x00DF},{0xE0,0x0155},{0xE1,0x00E1},{0xE2,0x00E2},{0xE3,0x0103}, - {0xE4,0x00E4},{0xE5,0x013A},{0xE6,0x0107},{0xE7,0x00E7},{0xE8,0x010D}, - {0xE9,0x00E9},{0xEA,0x0119},{0xEB,0x00EB},{0xEC,0x011B},{0xED,0x00ED}, - {0xEE,0x00EE},{0xEF,0x010F},{0xF0,0x0111},{0xF1,0x0144},{0xF2,0x0148}, - {0xF3,0x00F3},{0xF4,0x00F4},{0xF5,0x0151},{0xF6,0x00F6},{0xF7,0x00F7}, - {0xF8,0x0159},{0xF9,0x016F},{0xFA,0x00FA},{0xFB,0x0171},{0xFC,0x00FC}, - {0xFD,0x00FD},{0xFE,0x0163},{0xFF,0x00B7}, -}; - -/* latin3 table */ -typedef struct { - UCHAR latin3; - MCHAR unicode; -}Latin3UniTable; - -const Latin3UniTable tabLatin3Uni[] = { - {0xA0,0x0020},{0xA1,0x0126},{0xA2,0x02D8},{0xA3,0x00A3},{0xA4,0x00A4}, - {0xA6,0x0124},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x0130},{0xAA,0x015E}, - {0xAB,0x011E},{0xAC,0x0134},{0xAD,0x00AD},{0xAF,0x017B},{0xB0,0x00B0}, - {0xB1,0x0127},{0xB2,0x00B2},{0xB3,0x00B3},{0xB4,0x00B4},{0xB5,0x00B5}, - {0xB6,0x0125},{0xB7,0x00B7},{0xB8,0x00B8},{0xB9,0x0131},{0xBA,0x015F}, - {0xBB,0x011F},{0xBC,0x0135},{0xBD,0x00BD},{0xBF,0x017C},{0xC0,0x00C0}, - {0xC1,0x00C1},{0xC2,0x00C2},{0xC4,0x00C4},{0xC5,0x010A},{0xC6,0x0108}, - {0xC7,0x00C7},{0xC8,0x00C8},{0xC9,0x00C9},{0xCA,0x00CA},{0xCB,0x00CB}, - {0xCC,0x00CC},{0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x00CF},{0xD1,0x00D1}, - {0xD2,0x00D2},{0xD3,0x00D3},{0xD4,0x00D4},{0xD6,0x00D6},{0xD7,0x00D7}, - {0xD8,0x011C},{0xD9,0x00D9},{0xDA,0x00DA},{0xDB,0x00DB},{0xDC,0x00DC}, - {0xDE,0x015C},{0xDF,0x00DF},{0xE0,0x00E0},{0xE1,0x00E1},{0xE2,0x00E2}, - {0xE4,0x00E4},{0xE5,0x010B},{0xE6,0x0109},{0xE7,0x00E7},{0xE8,0x00E8}, - {0xE9,0x00E9},{0xEA,0x00EA},{0xEB,0x00EB},{0xEC,0x00EC},{0xED,0x00ED}, - {0xEE,0x00EE},{0xEF,0x00EF},{0xF1,0x00F1},{0xF2,0x00F2},{0xF3,0x00F3}, - {0xF4,0x00F4},{0xF5,0x0121},{0xF6,0x00F6},{0xF7,0x00F7},{0xF8,0x011D}, - {0xF9,0x00F9},{0xFA,0x00FA},{0xFB,0x00FB},{0xFC,0x00FC},{0xFD,0x016D}, - {0xFE,0x015D},{0xFF,0x02D9}, -}; -/* latin4 table */ -typedef struct { - UCHAR latin4; - MCHAR unicode; -}Latin4UniTable; - -const Latin4UniTable tabLatin4Uni[] = { - {0xA0,0x0020},{0xA1,0x0104},{0xA2,0x0138},{0xA3,0x0156},{0xA4,0x00A4}, - {0xA5,0x0128},{0xA6,0x013B},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x0160}, - {0xAA,0x0112},{0xAB,0x0122},{0xAC,0x0166},{0xAD,0x00AD},{0xAE,0x017D}, - {0xAF,0x00AF},{0xB0,0x00B0},{0xB1,0x0105},{0xB2,0x02DB},{0xB3,0x0157}, - {0xB4,0x00B4},{0xB5,0x0129},{0xB6,0x013C},{0xB7,0x02C7},{0xB8,0x00B8}, - {0xB9,0x0161},{0xBA,0x0113},{0xBB,0x0123},{0xBC,0x0167},{0xBD,0x014A}, - {0xBE,0x017E},{0xBF,0x014B},{0xC0,0x0100},{0xC1,0x00C1},{0xC2,0x00C2}, - {0xC3,0x00C3},{0xC4,0x00C4},{0xC5,0x00C5},{0xC6,0x00C6},{0xC7,0x012E}, - {0xC8,0x010C},{0xC9,0x00C9},{0xCA,0x0118},{0xCB,0x00CB},{0xCC,0x0116}, - {0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x012A},{0xD0,0x0110},{0xD1,0x0145}, - {0xD2,0x014C},{0xD3,0x0136},{0xD4,0x00D4},{0xD5,0x00D5},{0xD6,0x00D6}, - {0xD7,0x00D7},{0xD8,0x00D8},{0xD9,0x0172},{0xDA,0x00DA},{0xDB,0x00DB}, - {0xDC,0x00DC},{0xDD,0x0168},{0xDE,0x016A},{0xDF,0x00DF},{0xE0,0x0101}, - {0xE1,0x00E1},{0xE2,0x00E2},{0xE3,0x00E3},{0xE4,0x00E4},{0xE5,0x00E5}, - {0xE6,0x00E6},{0xE7,0x012F},{0xE8,0x010D},{0xE9,0x00E9},{0xEA,0x0119}, - {0xEB,0x00EB},{0xEC,0x0117},{0xED,0x00ED},{0xEE,0x00EE},{0xEF,0x012B}, - {0xF0,0x0111},{0xF1,0x0146},{0xF2,0x014D},{0xF3,0x0137},{0xF4,0x00F4}, - {0xF5,0x00F5},{0xF6,0x00F6},{0xF7,0x00F7},{0xF8,0x00F8},{0xF9,0x0173}, - {0xFA,0x00FA},{0xFB,0x00FB},{0xFC,0x00FC},{0xFD,0x0169},{0xFE,0x016B}, - {0xFF,0x02D9}, - -}; -/* latin8 table */ -typedef struct { - UCHAR latin8; - MCHAR unicode; -}Latin8UniTable; - -const Latin8UniTable tabLatin8Uni[] = { - {0xA0,0x0020},{0xA2,0x00A2},{0xA3,0x00A3},{0xA4,0x00A4},{0xA5,0x00A5}, - {0xA6,0x00A6},{0xA7,0x00A7},{0xA8,0x00A8},{0xA9,0x00A9},{0xAA,0x00D7}, - {0xAB,0x00AB},{0xAC,0x00AC},{0xAD,0x00AD},{0xAE,0x00AE},{0xAF,0x203E}, - {0xB0,0x00B0},{0xB1,0x00B1},{0xB2,0x00B2},{0xB3,0x00B3},{0xB4,0x00B4}, - {0xB5,0x00B5},{0xB6,0x00B6},{0xB7,0x00B7},{0xB8,0x00B8},{0xB9,0x00B9}, - {0xBA,0x00F7},{0xBB,0x00BB},{0xBC,0x00BC},{0xBD,0x00BD},{0xBE,0x00BE}, - {0xDF,0x2017},{0xE0,0x05D0},{0xE1,0x05D1},{0xE2,0x05D2},{0xE3,0x05D3}, - {0xE4,0x05D4},{0xE5,0x05D5},{0xE6,0x05D6},{0xE7,0x05D7},{0xE8,0x05D8}, - {0xE9,0x05D9},{0xEA,0x05DA},{0xEB,0x05DB},{0xEC,0x05DC},{0xED,0x05DD}, - {0xEE,0x05DE},{0xEF,0x05DF},{0xF0,0x05E0},{0xF1,0x05E1},{0xF2,0x05E2}, - {0xF3,0x05E3},{0xF4,0x05E4},{0xF5,0x05E5},{0xF6,0x05E6},{0xF7,0x05E7}, - {0xF8,0x05E8},{0xF9,0x05E9},{0xFA,0x05EA},{0xFD,0x200E},{0xFE,0x200F}, -}; - -/* latin15 table */ -typedef struct { - UCHAR latin15; - MCHAR unicode; -}Latin15UniTable; - -const Latin15UniTable tabLatin15Uni[] = { - {0xA0,0x0020},{0xA1,0x00A1},{0xA2,0x00A2},{0xA3,0x00A3},{0xA4,0x20AC}, - {0xA5,0x00A5},{0xA6,0x0160},{0xA7,0x00A7},{0xA8,0x0161},{0xA9,0x00A9}, - {0xAA,0x00AA},{0xAB,0x00AB},{0xAC,0x00AC},{0xAD,0x00AD},{0xAE,0x00AE}, - {0xAF,0x00AF},{0xB0,0x00B0},{0xB1,0x00B1},{0xB2,0x00B2},{0xB3,0x00B3}, - {0xB4,0x017D},{0xB5,0x00B5},{0xB6,0x00B6},{0xB7,0x00B7},{0xB8,0x017E}, - {0xB9,0x00B9},{0xBA,0x00BA},{0xBB,0x00BB},{0xBC,0x0152},{0xBD,0x0153}, - {0xBE,0x0178},{0xBF,0x00BF},{0xC0,0x00C0},{0xC1,0x00C1},{0xC2,0x00C2}, - {0xC3,0x00C3},{0xC4,0x00C4},{0xC5,0x00C5},{0xC6,0x00C6},{0xC7,0x00C7}, - {0xC8,0x00C8},{0xC9,0x00C9},{0xCA,0x00CA},{0xCB,0x00CB},{0xCC,0x00CC}, - {0xCD,0x00CD},{0xCE,0x00CE},{0xCF,0x00CF},{0xD0,0x00D0},{0xD1,0x00D1}, - {0xD2,0x00D2},{0xD3,0x00D3},{0xD4,0x00D4},{0xD5,0x00D5},{0xD6,0x00D6}, - {0xD7,0x00D7},{0xD8,0x00D8},{0xD9,0x00D9},{0xDA,0x00DA},{0xDB,0x00DB}, - {0xDC,0x00DC},{0xDD,0x00DD},{0xDE,0x00DE},{0xDF,0x00DF},{0xE0,0x00E0}, - {0xE1,0x00E1},{0xE2,0x00E2},{0xE3,0x00E3},{0xE4,0x00E4},{0xE5,0x00E5}, - {0xE6,0x00E6},{0xE7,0x00E7},{0xE8,0x00E8},{0xE9,0x00E9},{0xEA,0x00EA}, - {0xEB,0x00EB},{0xEC,0x00EC},{0xED,0x00ED},{0xEE,0x00EE},{0xEF,0x00EF}, - {0xF0,0x00F0},{0xF1,0x00F1},{0xF2,0x00F2},{0xF3,0x00F3},{0xF4,0x00F4}, - {0xF5,0x00F5},{0xF6,0x00F6},{0xF7,0x00F7},{0xF8,0x00F8},{0xF9,0x00F9}, - {0xFA,0x00FA},{0xFB,0x00FB},{0xFC,0x00FC},{0xFD,0x00FD},{0xFE,0x00FE}, - {0xFF,0x00FF}, -}; - - -/* Win1251 table */ -typedef struct { - UCHAR win1251; - MCHAR unicode; -}Win1251UniTable; -const Win1251UniTable tabWin1251Uni[] = { - {0x80,0x0402},{0x81,0x0403},{0x82,0x201A},{0x83,0x0453},{0x84,0x201E}, - {0x85,0x2026},{0x86,0x2020},{0x87,0x2021},{0x88,0x20AC},{0x89,0x2030}, - {0x8A,0x0409},{0x8B,0x2039},{0x8C,0x040A},{0x8D,0x040C},{0x8E,0x040B}, - {0x8F,0x040F},{0x90,0x0452},{0x91,0x2018},{0x92,0x2019},{0x93,0x201C}, - {0x94,0x201D},{0x95,0x2022},{0x96,0x2013},{0x97,0x2014},{0x98,0x0000}, - {0x99,0x2122},{0x9A,0x0459},{0x9B,0x203A},{0x9C,0x045A},{0x9D,0x045C}, - {0x9E,0x045B},{0x9F,0x045F},{0xA0,0x00a0},{0xA1,0x040e},{0xA2,0x045e}, - {0xA3,0x0408},{0xA4,0x00a4},{0xA5,0x0490},{0xA6,0x00a6},{0xA7,0x00a7}, - {0xA8,0x0401},{0xA9,0x00a9},{0xAA,0x0404},{0xAB,0x00ab},{0xAC,0x00ac}, - {0xAD,0x00ad},{0xAE,0x00ae},{0xAF,0x0407},{0xB0,0x00b0},{0xB1,0x00b1}, - {0xB2,0x0406},{0xB3,0x0456},{0xB4,0x0491},{0xB5,0x00b5},{0xB6,0x00b6}, - {0xB7,0x00b7},{0xB8,0x0451},{0xB9,0x2116},{0xBA,0x0454},{0xBB,0x00bb}, - {0xBC,0x0458},{0xBD,0x0405},{0xBE,0x0455},{0xBF,0x0457},{0xC0,0x0410}, - {0xC1,0x0411},{0xC2,0x0412},{0xC3,0x0413},{0xC4,0x0414},{0xC5,0x0415}, - {0xC6,0x0416},{0xC7,0x0417},{0xC8,0x0418},{0xC9,0x0419},{0xCA,0x041a}, - {0xCB,0x041b},{0xCC,0x041c},{0xCD,0x041d},{0xCE,0x041e},{0xCF,0x041f}, - {0xD0,0x0420},{0xD1,0x0421},{0xD2,0x0422},{0xD3,0x0423},{0xD4,0x0424}, - {0xD5,0x0425},{0xD6,0x0426},{0xD7,0x0427},{0xD8,0x0428},{0xD9,0x0429}, - {0xDA,0x042a},{0xDB,0x042b},{0xDC,0x042c},{0xDD,0x042d},{0xDE,0x042e}, - {0xDF,0x042f},{0xE0,0x0430},{0xE1,0x0431},{0xE2,0x0432},{0xE3,0x0433}, - {0xE4,0x0434},{0xE5,0x0435},{0xE6,0x0436},{0xE7,0x0437},{0xE8,0x0438}, - {0xE9,0x0439},{0xEA,0x043a},{0xEB,0x043b},{0xEC,0x043c},{0xED,0x043d}, - {0xEE,0x043e},{0xEF,0x043f},{0xF0,0x0440},{0xF1,0x0441},{0xF2,0x0442}, - {0xF3,0x0443},{0xF4,0x0444},{0xF5,0x0445},{0xF6,0x0446},{0xF7,0x0447}, - {0xF8,0x0448},{0xF9,0x0449},{0xFA,0x044a},{0xFB,0x044b},{0xFC,0x044c}, - {0xFD,0x044d},{0xFE,0x044e},{0xFF,0x044f} -}; - - -/* Koi8-r table */ -typedef struct { - UCHAR koi8r; - MCHAR unicode; -}Koi8rUniTable; -const Koi8rUniTable tabKoi8rUni[] = { - {0x80,0x2500},{0x81,0x2502},{0x82,0x250C},{0x83,0x2510},{0x84,0x2514}, - {0x85,0x2518},{0x86,0x251C},{0x87,0x2524},{0x88,0x252C},{0x89,0x2534}, - {0x8A,0x253C},{0x8B,0x2580},{0x8C,0x2584},{0x8D,0x2588},{0x8E,0x258C}, - {0x8F,0x2590},{0x90,0x2591},{0x91,0x2592},{0x92,0x2593},{0x93,0x2320}, - {0x94,0x25A0},{0x95,0x2219},{0x96,0x221A},{0x97,0x2248},{0x98,0x2264}, - {0x99,0x2265},{0x9A,0x00A0},{0x9B,0x2321},{0x9C,0x00B0},{0x9D,0x00B2}, - {0x9E,0x00B7},{0x9F,0x00F7},{0xA0,0x2550},{0xA1,0x2551},{0xA2,0x2552}, - {0xA3,0x0451},{0xA4,0x2553},{0xA5,0x2554},{0xA6,0x2555},{0xA7,0x2556}, - {0xA8,0x2557},{0xA9,0x2558},{0xAA,0x2559},{0xAB,0x255A},{0xAC,0x255B}, - {0xAD,0x255C},{0xAE,0x255D},{0xAF,0x255E},{0xB0,0x255F},{0xB1,0x2560}, - {0xB2,0x2561},{0xB3,0x0401},{0xB4,0x2562},{0xB5,0x2563},{0xB6,0x2564}, - {0xB7,0x2565},{0xB8,0x2566},{0xB9,0x2567},{0xBA,0x2568},{0xBB,0x2569}, - {0xBC,0x256A},{0xBD,0x256B},{0xBE,0x256C},{0xBF,0x00A9},{0xC0,0x044E}, - {0xC1,0x0430},{0xC2,0x0431},{0xC3,0x0446},{0xC4,0x0434},{0xC5,0x0435}, - {0xC6,0x0444},{0xC7,0x0433},{0xC8,0x0445},{0xC9,0x0438},{0xCA,0x0439}, - {0xCB,0x043A},{0xCC,0x043B},{0xCD,0x043C},{0xCE,0x043D},{0xCF,0x043E}, - {0xD0,0x043F},{0xD1,0x044F},{0xD2,0x0440},{0xD3,0x0441},{0xD4,0x0442}, - {0xD5,0x0443},{0xD6,0x0436},{0xD7,0x0432},{0xD8,0x044C},{0xD9,0x044B}, - {0xDA,0x0437},{0xDB,0x0448},{0xDC,0x044D},{0xDD,0x0449},{0xDE,0x0447}, - {0xDF,0x044A},{0xE0,0x042E},{0xE1,0x0410},{0xE2,0x0411},{0xE3,0x0426}, - {0xE4,0x0414},{0xE5,0x0415},{0xE6,0x0424},{0xE7,0x0413},{0xE8,0x0425}, - {0xE9,0x0418},{0xEA,0x0419},{0xEB,0x041A},{0xEC,0x041B},{0xED,0x041C}, - {0xEE,0x041D},{0xEF,0x041E},{0xF0,0x041F},{0xF1,0x042F},{0xF2,0x0420}, - {0xF3,0x0421},{0xF4,0x0422},{0xF5,0x0423},{0xF6,0x0416},{0xF7,0x0412}, - {0xF8,0x042C},{0xF9,0x042B},{0xFA,0x0417},{0xFB,0x0428},{0xFC,0x042D}, - {0xFD,0x0429},{0xFE,0x0427},{0xFF,0x042A} -}; - - - -/* Koi8-u table */ -typedef struct { - UCHAR koi8u; - MCHAR unicode; -}Koi8uUniTable; - -const Koi8uUniTable tabKoi8uUni[] = { - {0x80,0x2500},{0x81,0x2502},{0x82,0x250C},{0x83,0x2510},{0x84,0x2514}, - {0x85,0x2518},{0x86,0x251C},{0x87,0x2524},{0x88,0x252C},{0x89,0x2534}, - {0x8A,0x253C},{0x8B,0x2580},{0x8C,0x2584},{0x8D,0x2588},{0x8E,0x258C}, - {0x8F,0x2590},{0x90,0x2591},{0x91,0x2592},{0x92,0x2593},{0x93,0x2320}, - {0x94,0x25A0},{0x95,0x2219},{0x96,0x221A},{0x97,0x2248},{0x98,0x2264}, - {0x99,0x2265},{0x9A,0x00A0},{0x9B,0x2321},{0x9C,0x00B0},{0x9D,0x00B2}, - {0x9E,0x00B7},{0x9F,0x00F7},{0xA0,0x2550},{0xA1,0x2551},{0xA2,0x2552}, - {0xA3,0x0451},{0xA4,0x0454},{0xA5,0x2554},{0xA6,0x0456},{0xA7,0x0457}, - {0xA8,0x2557},{0xA9,0x2558},{0xAA,0x2559},{0xAB,0x255A},{0xAC,0x255B}, - {0xAD,0x0491},{0xAE,0x255D},{0xAF,0x255E},{0xB0,0x255F},{0xB1,0x2560}, - {0xB2,0x2561},{0xB3,0x0401},{0xB4,0x0404},{0xB5,0x2563},{0xB6,0x0406}, - {0xB7,0x0407},{0xB8,0x2566},{0xB9,0x2567},{0xBA,0x2568},{0xBB,0x2569}, - {0xBC,0x256A},{0xBD,0x0490},{0xBE,0x256C},{0xBF,0x00A9},{0xC0,0x044E}, - {0xC1,0x0430},{0xC2,0x0431},{0xC3,0x0446},{0xC4,0x0434},{0xC5,0x0435}, - {0xC6,0x0444},{0xC7,0x0433},{0xC8,0x0445},{0xC9,0x0438},{0xCA,0x0439}, - {0xCB,0x043A},{0xCC,0x043B},{0xCD,0x043C},{0xCE,0x043D},{0xCF,0x043E}, - {0xD0,0x043F},{0xD1,0x044F},{0xD2,0x0440},{0xD3,0x0441},{0xD4,0x0442}, - {0xD5,0x0443},{0xD6,0x0436},{0xD7,0x0432},{0xD8,0x044C},{0xD9,0x044B}, - {0xDA,0x0437},{0xDB,0x0448},{0xDC,0x044D},{0xDD,0x0449},{0xDE,0x0447}, - {0xDF,0x044A},{0xE0,0x042E},{0xE1,0x0410},{0xE2,0x0411},{0xE3,0x0426}, - {0xE4,0x0414},{0xE5,0x0415},{0xE6,0x0424},{0xE7,0x0413},{0xE8,0x0425}, - {0xE9,0x0418},{0xEA,0x0419},{0xEB,0x041A},{0xEC,0x041B},{0xED,0x041C}, - {0xEE,0x041D},{0xEF,0x041E},{0xF0,0x041F},{0xF1,0x042F},{0xF2,0x0420}, - {0xF3,0x0421},{0xF4,0x0422},{0xF5,0x0423},{0xF6,0x0416},{0xF7,0x0412}, - {0xF8,0x042C},{0xF9,0x042B},{0xFA,0x0417},{0xFB,0x0428},{0xFC,0x042D}, - {0xFD,0x0429},{0xFE,0x0427},{0xFF,0x042A} -}; - - -/* Latin5 table */ -typedef struct { - UCHAR Latin5; - MCHAR unicode; -}Latin5UniTable; - -const Latin5UniTable tabLatin5Uni[] = { - {0xA0,0x00A0},{0xA1,0x0401},{0xA2,0x0402},{0xA3,0x0403},{0xA4,0x0404}, - {0xA5,0x0405},{0xA6,0x0406},{0xA7,0x0407},{0xA8,0x0408},{0xA9,0x0409}, - {0xAA,0x040A},{0xAB,0x040B},{0xAC,0x040C},{0xAD,0x00AD},{0xAE,0x040E}, - {0xAF,0x040F},{0xB0,0x0410},{0xB1,0x0411},{0xB2,0x0412},{0xB3,0x0413}, - {0xB4,0x0414},{0xB5,0x0415},{0xB6,0x0416},{0xB7,0x0417},{0xB8,0x0418}, - {0xB9,0x0419},{0xBA,0x041A},{0xBB,0x041B},{0xBC,0x041C},{0xBD,0x041D}, - {0xBE,0x041E},{0xBF,0x041F},{0xC0,0x0420},{0xC1,0x0421},{0xC2,0x0422}, - {0xC3,0x0423},{0xC4,0x0424},{0xC5,0x0425},{0xC6,0x0426},{0xC7,0x0427}, - {0xC8,0x0428},{0xC9,0x0429},{0xCA,0x042A},{0xCB,0x042B},{0xCC,0x042C}, - {0xCD,0x042D},{0xCE,0x042E},{0xCF,0x042F},{0xD0,0x0430},{0xD1,0x0431}, - {0xD2,0x0432},{0xD3,0x0433},{0xD4,0x0434},{0xD5,0x0435},{0xD6,0x0436}, - {0xD7,0x0437},{0xD8,0x0438},{0xD9,0x0439},{0xDA,0x043A},{0xDB,0x043B}, - {0xDC,0x043C},{0xDD,0x043D},{0xDE,0x043E},{0xDF,0x043F},{0xE0,0x0440}, - {0xE1,0x0441},{0xE2,0x0442},{0xE3,0x0443},{0xE4,0x0444},{0xE5,0x0445}, - {0xE6,0x0446},{0xE7,0x0447},{0xE8,0x0448},{0xE9,0x0449},{0xEA,0x044A}, - {0xEB,0x044B},{0xEC,0x044C},{0xED,0x044D},{0xEE,0x044E},{0xEF,0x044F}, - {0xF0,0x2116},{0xF1,0x0451},{0xF2,0x0452},{0xF3,0x0453},{0xF4,0x0454}, - {0xF5,0x0455},{0xF6,0x0456},{0xF7,0x0457},{0xF8,0x0458},{0xF9,0x0459}, - {0xFA,0x045A},{0xFB,0x045B},{0xFC,0x045C},{0xFD,0x00A7},{0xFE,0x045E}, - {0xFF,0x045F}, - -}; - -#define __LOCALCODE_TO_UTF8 - -#ifdef __LOCALCODE_TO_UTF8 - -bool __WmConvertCodeBufferSizeCheck (char *ftnName, int outBufSize, int requiredBufSize) -{ - if (outBufSize < requiredBufSize) { - - if (outBufSize == sizeof(void*)) { // if it is not array - MSG_DEBUG("__WmConvertCodeBufferSizeCheck: Out buffer size seems to be small (%s)\n",ftnName); - } else { - MSG_DEBUG("__WmConvertCodeBufferSizeCheck: Buffer size is too small %s: OutBuffer(%d), RequiredBufSize(%d)\n",ftnName,outBufSize,requiredBufSize); - } - return false; - } - return true; -} - - - -MCHAR __WmLngSwapShort(MCHAR aShort) -{ - return ((aShort << 8) + (aShort >> 8)); -} - -/** - * converting byte ordering between Network and device - * - * @param mszOutput [out] converted[destination] MCHAR buffer - * @param mszInput [in] source MCHAR buffer - * @param length [in] source MCHAR's string length (not byte count) - * - * @return This function returns a true on success, or false on failure. - */ -MCHAR* __WmLngSwapPCode(MCHAR *mszOutput, MCHAR *mszInput, int length) -{ - int i; - - for (i = 0; i < length; i++) { - if (mszInput[i] == (MCHAR)NULL) - break; - - mszOutput[i] = __WmLngSwapShort(mszInput[i]); - } - - mszOutput[i] = '\0'; - - return mszOutput; -} - - -/** - * This function convert character Processcode(Unicode) to Localcode(UTF8) - * - * @param pszOutText : Output Buffer Pointer to LocalCode(UTF8) - * @param mszInText : Input Buffer Pointer to ProcessCode(UniCode) - * @return This function returns true on success, or false on failure. - * @see WmConvert2LCodeN - */ -bool WmConvert2LCode(char *pszOutText, int outBufSize, MCHAR *mszInText) -{ - int charCount; - charCount = WmStrlen(mszInText); - if (charCount == 0) - pszOutText[0] = '\0'; - - if ((WmConvertPCode2UTF((UCHAR*)pszOutText, outBufSize, mszInText, charCount) == true)) { - return true; - } else { - MSG_DEBUG("WmConvert2LCode: Converting Unicode(%x) to utf8 code failed\n",mszInText); - return false; - } -} - -/** - * This function convert character Localcode(UTF8) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to LocalCode(UTF8) - * @return This function returns true on success, or false on failure. - * @see WmConvert2PCodeN - */ -bool WmConvert2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int byteCount; - - byteCount = strlen((char*) szInText); - - if (byteCount == 0) - pmszOutText[0] = '\0'; - - if((WmConvertUTF2PCode(pmszOutText, outBufSize,(UCHAR*)szInText, byteCount) == true)) { - return true; - } else { - MSG_DEBUG("WmConvert2PCode: Converting UTF8code(%x) to Unicode failed\n",szInText); - return false; - } -} - -/** - * This function convert N'th byte Localcode(UTF8) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to LocalCode(KSC5601) - * @param byteCount : byte number for converting character - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCode - */ -bool WmConvert2PCodeN(MCHAR *pmszOutText, int outBufSize, char *szInText, int byteCount) -{ - if ((WmConvertUTF2PCode (pmszOutText, outBufSize, (UCHAR*)szInText, byteCount) == true)) { - return true; - } else { - MSG_DEBUG("WmConvert2PCodeN: Converting UTF8code(%x) to Unicode failed\n",szInText); - return false; - } -} - -/** - * This function convert N'th character Processcode(Unicode) to Localcode(UTF8) - * - * @param pszOutText : Output Buffer Pointer to LocalCode(UTF8) - * @param mszInText : Input Buffer Pointer to ProcessCode(UniCode) - * @param charCount : number for convert n'th chararcter - * @return This function returns true on success, or false on failure. - * - * @see WmConvert2LCode - */ -bool WmConvert2LCodeN(char *pszOutText, int outBufSize, MCHAR *mszInText, int charCount) -{ - if ( (WmConvertPCode2UTF((UCHAR*)pszOutText, outBufSize, mszInText, charCount) == true)) { - return true; - } else { - MSG_DEBUG("WmConvert2LCodeN: Converting Unicode(%x) to utf8 code failed\n",mszInText); - return false; - } -} - -/** - * This function return output LocalCode Buffer Size - * - * @param mszText : Input ProcessCode String Pointer - * @return This function returns BufferSize for LocalCode - * - * @see WmGetPcodeSize - */ -int WmGetLCodeSize(MCHAR *mszText) -{ - int nBuffSize = 0; - - if (mszText[0] == '\0') - return 0; - - while (*mszText != '\0') { - - if (0x0001 <= *mszText && *mszText <= 0x007F) { - nBuffSize++; - mszText++; - } else if ((*mszText == 0x0000) || (0x0080 <= *mszText && *mszText <= 0x07FF)) { - nBuffSize += 2; - mszText++; - } else { - nBuffSize += 3; - mszText++; - } - } - return nBuffSize; -} - - -/** - * This function return output LocalCode Buffer Size - * - * @param mszText : Input ProcessCode String Pointer - * @return This function returns BufferSize for LocalCode - * - * @see WmGetPcodeSize - */ -int WmGetLCodeSizeN(MCHAR *mszText, int charCount) -{ - int nBuffSize = 0; - int i = 0; - - if (mszText[0] == '\0') - return 0; - - while ((*mszText != '\0') && (i < charCount)) { - - if (0x0001 <= *mszText && *mszText <= 0x007F) { - nBuffSize++; - mszText++; - } else if ((*mszText == 0x0000) || (0x0080 <= *mszText && *mszText <= 0x07FF)) { - nBuffSize += 2; - mszText++; - } else { - nBuffSize += 3; - mszText++; - } - i++; - } - return nBuffSize; -} -#endif - - -/** - * This function convert character Localcode(Latin2) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to Latin2 code - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertLatin2Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int i = 0; - int j = 0; - int strLen = 0; - bool bInLatin2Table = false; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n"); - return false; - } - - for (i = 0; i < strLen; i++) { - bInLatin2Table = false; - for (j = 0; j < tabLatin2UniMax; j++) { - if ((UCHAR)szInText[i] == tabLatin2Uni[j].latin2) { - pmszOutText[i] = tabLatin2Uni[j].unicode; - bInLatin2Table = true; - } - } - if (bInLatin2Table == false) - pmszOutText[i] = (MCHAR)(UCHAR)szInText[i]; - } - /* Latin2 -> UNICODE */ - pmszOutText[strLen] = '\0'; - - return true; -} - - -/** - * This function convert character Localcode(Latin3) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to Latin2 code - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertLatin3Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int i = 0; - int j = 0; - int strLen = 0; - bool bInLatin3Table = false; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n"); - return false; - } - - for (i = 0; i < strLen; i++) { - bInLatin3Table = false; - for (j = 0; j < tabLatin3UniMax; j++) { - if ((UCHAR)szInText[i] == tabLatin3Uni[j].latin3) { - pmszOutText[i] = tabLatin3Uni[j].unicode; - bInLatin3Table = true; - } - } - if (bInLatin3Table == false) - pmszOutText[i] = (MCHAR)(UCHAR)szInText[i]; - } - /* Latin3 -> UNICODE */ - pmszOutText[strLen] = '\0'; - - return true; -} - -/** - * This function convert character Localcode(Latin4) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to Latin2 code - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertLatin4Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int i = 0; - int j = 0; - int strLen = 0; - bool bInLatin4Table = false; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n"); - return false; - } - - for (i = 0; i < strLen; i++) { - bInLatin4Table = false; - for (j = 0; j < tabLatin4UniMax; j++) { - if ((UCHAR)szInText[i] == tabLatin4Uni[j].latin4) { - pmszOutText[i] = tabLatin4Uni[j].unicode; - bInLatin4Table = true; - } - } - if (bInLatin4Table == false) - pmszOutText[i] = (MCHAR)(UCHAR)szInText[i]; - } - /* Latin4 -> UNICODE */ - pmszOutText[strLen] = '\0'; - - return true; -} - -/** - * This function convert character Localcode(Latin8) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to Latin2 code - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertLatin8Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int i = 0; - int j = 0; - int strLen = 0; - bool bInLatin8Table = false; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n"); - return false; - } - - for (i = 0; i < strLen; i++) { - bInLatin8Table = false; - for (j = 0; j < tabLatin8UniMax; j++) { - if ((UCHAR)szInText[i] == tabLatin8Uni[j].latin8) { - pmszOutText[i] = tabLatin8Uni[j].unicode; - bInLatin8Table = true; - } - } - if (bInLatin8Table == false) - pmszOutText[i] = (MCHAR)(UCHAR)szInText[i]; - } - /* Latin8 -> UNICODE */ - pmszOutText[strLen] = '\0'; - - return true; -} - - -/** - * This function convert character Localcode(Win1251) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to Win1251 code - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertWin1251Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int i = 0; - int j = 0; - int strLen = 0; - bool bInWin1251Table = false; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertWin1251Code2PCode: Out buffer size seems to be small!\n"); - return false; - } - - for (i = 0; i < strLen; i++) { - bInWin1251Table = false; - for (j = 0; j < tabWin1251UniMax; j++) { - if ((UCHAR)szInText[i] == tabWin1251Uni[j].win1251) { - pmszOutText[i] = tabWin1251Uni[j].unicode; - bInWin1251Table = true; - } - } - if (bInWin1251Table == false) - pmszOutText[i] = (MCHAR)(UCHAR)szInText[i]; - } - /* Win1251 -> UNICODE */ - pmszOutText[strLen] = '\0'; - - return true; -} - - -/** - * This function convert character Localcode(Koi8-r) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to Koi8-r code - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertKoi8rCode2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int i = 0; - int j = 0; - int strLen = 0; - bool bInKoi8rTable = false; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertKoi8rCode2PCode: Out buffer size seems to be small!\n"); - return false; - } - - for (i = 0; i < strLen; i++) { - bInKoi8rTable = false; - for (j = 0; j < tabKoi8rUniMax; j++) { - if ((UCHAR)szInText[i] == tabKoi8rUni[j].koi8r) { - pmszOutText[i] = tabKoi8rUni[j].unicode; - bInKoi8rTable = true; - } - } - if (bInKoi8rTable == false) - pmszOutText[i] = (MCHAR)(UCHAR)szInText[i]; - } - /* bInKoi8-rTable -> UNICODE */ - pmszOutText[strLen] = '\0'; - - return true; -} - - -/** - * This function convert character Localcode(Koi8-u) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to Koi8-u code - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertKoi8uCode2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int i = 0; - int j = 0; - int strLen = 0; - bool bInKoi8uTable = false; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertKoi8uCode2PCode: Out buffer size seems to be small!\n"); - return false; - } - - for (i = 0; i < strLen; i++) { - bInKoi8uTable = false; - for (j = 0; j < tabKoi8uUniMax; j++) { - if ((UCHAR)szInText[i] == tabKoi8uUni[j].koi8u) { - pmszOutText[i] = tabKoi8uUni[j].unicode; - bInKoi8uTable = true; - } - } - if (bInKoi8uTable == false) - pmszOutText[i] = (MCHAR)(UCHAR)szInText[i]; - } - /* bInKoi8uTable -> UNICODE */ - pmszOutText[strLen] = '\0'; - - return true; -} - - -/** - * This function convert character Localcode(Latin15) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to Latin2 code - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertLatin15Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int i = 0; - int j = 0; - int strLen = 0; - bool bInLatin15Table = false; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n"); - return false; - } - - for (i = 0; i < strLen; i++) { - bInLatin15Table = false; - for (j = 0; j < tabLatin15UniMax; j++) { - if ((UCHAR)szInText[i] == tabLatin15Uni[j].latin15) { - pmszOutText[i] = tabLatin15Uni[j].unicode; - bInLatin15Table = true; - } - } - if (bInLatin15Table == false) - pmszOutText[i] = (MCHAR)(UCHAR)szInText[i]; - } - /* Latin15 -> UNICODE */ - pmszOutText[strLen] = '\0'; - - return true; -} - - - - -/** - * This function convert character Localcode(Latin5) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to Latin5 code - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertLatin5Code2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - int i = 0; - int j = 0; - int strLen = 0; - bool bInLatin5Table = false; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n"); - return false; - } - - for (i = 0; i < strLen; i++) { - bInLatin5Table = false; - for (j = 0; j < tabLatin5UniMax; j++) { - if ((UCHAR)szInText[i] == tabLatin5Uni[j].Latin5) { - pmszOutText[i] = tabLatin5Uni[j].unicode; - bInLatin5Table = true; - } - } - if (bInLatin5Table == false) - pmszOutText[i] = (MCHAR)(UCHAR)szInText[i]; - } - /* Latin5 -> UNICODE */ - pmszOutText[strLen] = '\0'; - - return true; -} - - -int WmGetLatin32UTFCodeSize(unsigned char *szSrc, int nChar) -{ - int bufferSize = 0; - int latin3Size = -1; - MCHAR *pmszText; - - bufferSize = nChar*3+1; - pmszText = (MCHAR *)malloc(bufferSize); - if (!pmszText) { - MSG_DEBUG("WmGetLatin32UTFCodeSize: memory allocation is failed!\n"); - return -1; - } - WmConvertLatin3Code2PCode(pmszText, bufferSize, (char*)szSrc); - latin3Size = WmGetLCodeSize(pmszText); - free(pmszText); - return latin3Size; -} - - -int WmGetLatin42UTFCodeSize(unsigned char *szSrc, int nChar) -{ - int bufferSize = 0; - int latin4Size = -1; - MCHAR *pmszText; - - bufferSize = nChar*3+1; - pmszText = (MCHAR *)malloc(bufferSize); - if (!pmszText) { - MSG_DEBUG("WmGetLatin42UTFCodeSize: memory allocation is failed!\n"); - return -1; - } - WmConvertLatin4Code2PCode(pmszText, bufferSize, (char*)szSrc); - latin4Size = WmGetLCodeSize(pmszText); - free(pmszText); - return latin4Size; -} - - -int WmGetLatin82UTFCodeSize(unsigned char *szSrc, int nChar) -{ - int bufferSize = 0; - int latin8Size = -1; - MCHAR *pmszText; - - bufferSize = nChar*3+1; - pmszText = (MCHAR *)malloc(bufferSize); - if (!pmszText) { - MSG_DEBUG("WmGetLatin82UTFCodeSize: memory allocation is failed!\n"); - return -1; - } - WmConvertLatin8Code2PCode(pmszText, bufferSize, (char*)szSrc); - latin8Size = WmGetLCodeSize(pmszText); - free(pmszText); - return latin8Size; -} - -int WmGetLatin152UTFCodeSize(unsigned char *szSrc, int nChar) -{ - int bufferSize = 0; - int latin15Size = -1; - MCHAR *pmszText; - - bufferSize = nChar*3+1; - pmszText = (MCHAR *)malloc(bufferSize); - if (!pmszText) { - MSG_DEBUG("WmGetLatin152UTFCodeSize: memory allocation is failed!\n"); - return -1; - } - WmConvertLatin15Code2PCode(pmszText, bufferSize, (char*)szSrc); - latin15Size = WmGetLCodeSize(pmszText); - free(pmszText); - return latin15Size; -} - -int WmGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar) -{ - int bufferSize = 0; - int latin5Size = -1; - MCHAR *pmszText; - - bufferSize = nChar*3+1; - pmszText = (MCHAR *)malloc(bufferSize); - if (!pmszText) { - MSG_DEBUG("WmGetLatin52UTFCodeSize: memory allocation is failed!\n"); - return -1; - } - WmConvertLatin5Code2PCode(pmszText, bufferSize, (char*)szSrc); - latin5Size = WmGetLCodeSize(pmszText); - free(pmszText); - return latin5Size; -} - - -/** - * This function convert character Localcode(Latin1) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to LocalCode(KSC5601) - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCodeN - */ -bool WmConvertLatinCode2PCode(MCHAR *pmszOutText, int outBufSize, char *szInText) -{ - UINT strLen; - - strLen = strlen((char *)szInText); - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, strLen) == false) { - MSG_DEBUG("WmConvertLatinCode2PCode: Out buffer size seems to be small!\n"); - return false; - } - - /* Latin1 -> UNICODE */ - __WmLngConvertLatin12Unicode(pmszOutText,(UCHAR*)szInText,strLen); - pmszOutText[strLen] = '\0'; - - return true; -} - -/** - * This function convert N'th character Localcode(Latin1) to Processcode(Unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to LocalCode(KSC5601) - * @param charCount : number for convert n'th chararcter - * @return This function returns true on success, or false - * on failure. - * @see WmConvert2PCode - */ -bool WmConvertLatinCode2PCodeN(MCHAR *pmszOutText, int outBufSize, char *szInText, int charCount) -{ - int strLen; - - if (charCount == 0) { - MSG_DEBUG("WmConvert2PCodeN: charCount is0\n"); - pmszOutText[charCount] = '\0'; - } - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, charCount) == false) { - MSG_DEBUG("WmConvertLatinCode2PCodeN: Out buffer size seems to be small!\n"); - return false; - } - - /* Latin1 -> UNICODE */ - __WmLngLatin12UnicodeN (pmszOutText, (UCHAR*)szInText, charCount); - - strLen = strlen((char *)szInText); - if(strLen < charCount) { - pmszOutText[strLen] = '\0'; - } else { - pmszOutText[charCount] = '\0'; - } - - return true; -} - -/* - * This function convert character Processcode(Unicode) to Localcode(Latin1) - * - * @param pOutStr : Output Buffer Pointer to LocalCode(Latin1) - * @param pInputStr : Input Buffer Pointer to ProcessCode(UniCode) - * @param len : number for convert n'th chararcter - * @return void - * - * @see - */ -static void __WmLngReverseKeyCode(UCHAR *pOutStr, MCHAR *pInputStr, UINT len) -{ - UCHAR *rear=NULL; - MCHAR *p; - UCHAR temp; - - rear = pOutStr; - - for (p = pInputStr; len > 0 && p; len--) { - if (*pInputStr < MAX_ASCII_NUM) { // ASCII String - if (*p == 0) - *rear = '\0'; - temp = (UCHAR)(*p); - *rear = temp; - rear++; - p++; - if(len == 1) - *rear = '\0'; - } else { - *rear = 0x3F; - rear++; - p++; - if(len == 1) - *rear = '\0'; - } - pInputStr = p; - } -} - - -/* - * This function convert character Localcode(Latin1) to Processcode(Unicode) - * - * @param des[in] : Output Buffer Pointer to ProcessCode(UniCode) - * @param str[in] : Input Buffer Pointer to LocalCode(Latin1) - * @param len[in] : number for convert n'th chararcter - * @return This function returns number for convert n'th chararcter on success - * - * @see - */ -static int __WmLngConvertLatin12Unicode (MCHAR *des, UCHAR *str, UINT len) -{ - MCHAR *org; - org = des; - while (len>0) { - *des++ = *str++; - len--; - } - - return (des - org) ; -} - -/* - * This function convert N'th character Localcode(Latin1) to Processcode(Unicode) - * - * @param pOutStr : Output Buffer Pointer to ProcessCode(UniCode) - * @param pInputStr : Input Buffer Pointer to LocalCode(Latin1) - * @param len : number for convert n'th chararcter - * @return This function returns true on success, or false on failure. - * - * @see - */ -static UINT __WmLngLatin12UnicodeN(MCHAR *pOutStr, UCHAR *pInputStr, UINT len) -{ - UINT n; - - n = strlen((char*)pInputStr); - - if(len > n) - len = n; - - return __WmLngConvertLatin12Unicode (pOutStr, pInputStr, len); -} - diff --git a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngString.cpp b/plugin/mms_plugin/LanguagePack/MmsPluginWmLngString.cpp deleted file mode 100755 index 3fc2214..0000000 --- a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngString.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -* 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 "MsgDebug.h" -#include "MmsPluginWmLngPack.h" - - -/** - * return length of a string (character count of a string) - * @param mszInText [in] input string pointer - * @return lenght of string - * - */ -int WmStrlen(const MCHAR *mszInText) -{ - register int n; - - n=0; - - while(*(mszInText+n) != '\0') - n++; - - return n; -} - diff --git a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUTF8Uni.cpp b/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUTF8Uni.cpp deleted file mode 100755 index 315cee3..0000000 --- a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUTF8Uni.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* -* 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 "MsgDebug.h" -#include "MmsPluginWmLngPack.h" - - -/* Local function */ -int __WmLngUTF2Unicode (unsigned short *des,unsigned char *src, int nChar); - - -int __WmLngStrlenByByte(UCHAR *szInText, int byteCount) -{ - int nCount = 0; - while (byteCount > 0 && (*szInText != '\0')) { - if (*szInText < 0x80) { - szInText++; - byteCount--; - } else if (((0xC0 <= *szInText) && (*szInText < 0xE0)) && (*(szInText+1) >= 0x80)) { - szInText += 2; - byteCount -= 2; - } else if ((*szInText >= 0xE0) && (*(szInText+1) >= 0x80) && (*(szInText+2) >= 0x80)) { - szInText += 3; - byteCount -= 3; - } else { - szInText++; - byteCount--; - MSG_DEBUG("__WmLngStrlenByByte: utf8 incorrect range!\n"); - } - nCount++; - } - return (nCount+1)*sizeof(MCHAR); -} - -/** - * This function convert character n'th byte UTF8 character to ProcessCode(unicode) - * - * @param pmszOutText : Output Buffer Pointer to ProcessCode(UniCode) - * @param szInText : Input Buffer Pointer to UTF8 - * @param byteCount : byte number for converting the character - * @return : This function returns true on success, or false - * on failure. - * - * @see WmConvertPCode2UTF - */ -bool WmConvertUTF2PCode (MCHAR *pmszOutText, int outBufSize, UCHAR *szInText, int byteCount) -{ - int length; - if (byteCount == 0) { - pmszOutText[0] = '\0'; - return true; - } - - if (__WmConvertCodeBufferSizeCheck((char*)pmszOutText, outBufSize, __WmLngStrlenByByte((UCHAR*)szInText, byteCount)) == false) { - MSG_DEBUG("WmConvertUTF2PCode: Out buffer size seems to be small!\n"); - return false; - } - - length = __WmLngUTF2Unicode (pmszOutText, szInText, byteCount); - if (length == -1) { - MSG_DEBUG("WmConvertUTF2PCode: __WmLngUTF2Unicode returns false!\n"); - return false; - } else { - return true; - } -} - - -/* - * change 1byte-encoded-UTF8 character to Unicode - * @param byte1 : 1byte character code - * @return : result of bit operation - * - * - * @see - */ -unsigned short __WmLngConvert1ByteChar (unsigned char byte1) -{ - unsigned short result; - - result = 0; - result = (byte1 & 0x7F); - - return result; -} - -/* - * change 2byte-encoded-UTF8 character to Unicode - * @param byte1 : 1'st byte character code - * @param byte2 : 2'st byte character code - * @return : result of bit operation - * - * @see - */ -unsigned short __WmLngConvert2ByteChar (unsigned char byte1, unsigned char byte2) -{ - unsigned short result; - unsigned char hi; - unsigned char lo; - - result = 0; - - hi = byte1 & 0x1F; - lo = byte2 & 0x3F; - - result = (hi << 6) | lo; - - return result; -} - -/* - * change 3byte-encoded-UTF8 character to Unicode - * @param byte1 : 1'st character code - * @param byte2 : 2'st character code - * @param byte3 : 3'st character code - * @return : result of bit operation - * - * @see - */ -unsigned short __WmLngConvert3ByteChar (unsigned char byte1, unsigned char byte2, unsigned char byte3) -{ - unsigned short result; - unsigned char hi; - unsigned char mid; - unsigned char lo; - - result = 0; - - hi = byte1 & 0x0F; - mid = byte2 & 0x3F; - lo = byte3 & 0x3F; - - result = (hi << 12) | (mid << 6) | lo; - - return result; -} - -/* - * This function convert character UTF8 to ProcessCode(unicode) - * - * @param des : Output Buffer Pointer to ProcessCode(UniCode) - * @param src : Input Buffer Pointer to UTF8 - * @param nChar : number for convert n'th chararcter - * @return : This function returns number for convert n'th chararcter on success, or -1 - * on failure. - * - * @see - */ - -int __WmLngUTF2Unicode (unsigned short *des,unsigned char *src, int nChar) -{ - unsigned short *org; - - org = des; - - while (nChar > 0 && (*src != '\0')) { - if (*src < 0x80) { - *des = __WmLngConvert1ByteChar (*src); - - des++; - src++; - nChar--; - } else if (((0xC0 <= *src) && (*src < 0xE0)) && (*(src+1) >= 0x80)) { - *des = __WmLngConvert2ByteChar (*src, *(src+1)); - - des++; - src += 2; - nChar -= 2; - } else if ((*src >= 0xE0) && (*(src+1) >= 0x80) && (*(src+2) >= 0x80)) { - *des = __WmLngConvert3ByteChar (*src, *(src+1), *(src+2)); - - des++; - - src += 3; - nChar -= 3; - } else { - *des = __WmLngConvert1ByteChar (*src); - des++; - src++; - nChar--; - MSG_DEBUG("__WmLngUTF2Unicode: utf8 incorrect range!\n"); - } - } - *des = 0; - return (des - org); -} - - diff --git a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUniUTF8.cpp b/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUniUTF8.cpp deleted file mode 100755 index 1fd9d14..0000000 --- a/plugin/mms_plugin/LanguagePack/MmsPluginWmLngUniUTF8.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -* 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 "MsgDebug.h" -#include "MmsPluginWmLngPack.h" - - -/* Local function */ -int __WmLngUnicode2UTF (unsigned char *des, unsigned short *src, int nChar); - - -int __WmLngGetLCodeSizeN(MCHAR *mszText, int charCount) -{ - int nBuffSize = 0; - - if (mszText[0] == '\0') - return 0; - - while (charCount > 0 && *mszText != '\0') { - - if (0x0001 <= *mszText && *mszText <= 0x007F) { - nBuffSize++; - mszText++; - charCount--; - } else if((*mszText == 0x0000) || (0x0080 <= *mszText && *mszText <= 0x07FF)) { - nBuffSize += 2; - mszText++; - charCount--; - } else { - nBuffSize += 3; - mszText++; - charCount--; - } - } - return nBuffSize+1; /* include NULL */ -} - -/** - * This function convert character ProcessCode(unicode) to UTF8 - * - * @param pszOutText : Output Buffer Pointer to UTF8 - * @param mszInText : Input Buffer Pointer to ProcessCode(UniCode) - * @param charCount : number for convert n'th chararcter - * @return This function returns true on success, or false - * on failure. - * - * @see WmConvertPCode2UTF - */ -bool WmConvertPCode2UTF(UCHAR *pszOutText, int outBufSize, MCHAR *mszInText, int charCount) -{ - int length; - - if (charCount == 0) { - pszOutText[0] = '\0'; - return true; - } - - if (__WmConvertCodeBufferSizeCheck((char*)pszOutText, outBufSize, __WmLngGetLCodeSizeN(mszInText, charCount)) == false) { - MSG_DEBUG("WmConvertPCode2UTF: Out buffer size seems to be small!\n"); - return false; - } - - length = __WmLngUnicode2UTF(pszOutText, mszInText, charCount); - if(length == -1) { - MSG_DEBUG("WmConvertPCode2UTF: __WmLngUnicode2UTF returns false!\n"); - return false; - } else { - return true; - } -} - -/* - * This function convert character ProcessCode(unicode) to UTF8 - * - * @param des : Output Buffer Pointer to UTF8 - * @param src : Input Buffer Pointer to ProcessCode(UniCode) - * @param nChar : number for convert n'th chararcter - * @return This function returns number for convert n'th chararcter on success, or -1 - * on failure. - * - * @see WmConvertPCode2UTF - */ -int __WmLngUnicode2UTF (unsigned char *des, unsigned short *src, int nChar) -{ - unsigned char *org; - unsigned char t1; - unsigned char t2; - unsigned char t3; - - org = des; - - while (nChar > 0 && *src != '\0') { - if (0x0001 <= *src && *src <= 0x007F) { - *des = (unsigned char) (*src & 0x007F); - - des++; - src++; - nChar--; - } else if ((*src == 0x0000) || (0x0080 <= *src && *src <= 0x07FF)) { - t2 = (unsigned char) (*src & 0x003F); // right most 6 bit - t1 = (unsigned char) ((*src & 0x07C0) >> 6); // right most 5 bit - - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); - - des += 2; - src += 1; - nChar -= 1; - } else { - t3 = (unsigned char) (*src & 0x003F); // right most 6 bit - t2 = (unsigned char) ((*src & 0x0FC0) >> 6); // right most 6 bit - t1 = (unsigned char) ((*src & 0xF000) >> 12); // right most 4 bit - - *des = 0xE0 | (t1 & 0x0F); - *(des+1) = 0x80 | (t2 & 0x3F); - *(des+2) = 0x80 | (t3 & 0x3F); - - des += 3; - src += 1; - nChar -= 1; - } - } - - *des = 0; - return (des - org); -} - - - diff --git a/plugin/mms_plugin/MmsPluginAppBase.cpp b/plugin/mms_plugin/MmsPluginAppBase.cpp new file mode 100755 index 0000000..c30d61a --- /dev/null +++ b/plugin/mms_plugin/MmsPluginAppBase.cpp @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#include "MsgMmsMessage.h" +#include "MmsPluginDebug.h" +#include "MmsPluginStorage.h" +#include "MmsPluginMessage.h" +#include "MmsPluginMIME.h" +#include "MmsPluginAppBase.h" +#include "MmsPluginUtil.h" +#include "MmsPluginTcs.h" +#include "MsgUtilFile.h" + +msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allow_malware, const char *raw_filepath); + +MmsPluginAppBase::MmsPluginAppBase() +{ + memset(&mmsMsgData, 0x00, sizeof(mmsMsgData)); +} + +MmsPluginAppBase::MmsPluginAppBase(MMS_DATA_S *pMmsData) +{ + setMmsData(pMmsData); +} + +MmsPluginAppBase::MmsPluginAppBase(MmsMsg *pMmsMsg) +{ + setMmsData(pMmsMsg); +} + +MmsPluginAppBase::~MmsPluginAppBase() +{ + MsgMmsReleaseMmsLists(&mmsMsgData); +} + +void MmsPluginAppBase::setMmsData(MmsMsg *pMmsMsg) +{ + MmsConvertMsgData(pMmsMsg, &mmsMsgData); +} + +void MmsPluginAppBase::setMmsData(MMS_DATA_S *pMmsData) +{ + MsgMmsConvertMmsDataToMmsMessageData(pMmsData, &mmsMsgData); +} + +void MmsPluginAppBase::makePreviewInfo(msg_message_id_t msgId, bool allow_malware, const char *raw_filepath) +{ + MmsMakePreviewInfo(msgId, &mmsMsgData, allow_malware, raw_filepath); +} + +void MmsPluginAppBase::getFirstPageTextFilePath(char *textBuf, int textBufSize) +{ + + MMS_PAGE_S *pPage = NULL; + MMS_MEDIA_S *pMedia = NULL; + + MMS_MESSAGE_DATA_S *pMmsMsgData = &mmsMsgData; + + if (pMmsMsgData == NULL) + return; + + // Get the text data from the 1st slide. + if (pMmsMsgData->pageCnt > 0) { + + pPage = _MsgMmsGetPage(pMmsMsgData, 0); + + if (pPage) { + + for (int j = 0; j < pPage->mediaCnt; ++j) { + + pMedia = _MsgMmsGetMedia(pPage, j); + + if (pMedia && pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { + + MimeType mimeType = MIME_UNKNOWN; + + MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL); + + if (mimeType == MIME_TEXT_X_VCALENDAR || mimeType == MIME_TEXT_X_VCARD || mimeType == MIME_TEXT_X_VTODO || mimeType == MIME_TEXT_X_VNOTE) { + MSG_DEBUG("Media Type is Text, but Vobject file [%s]", pMedia->szFilePath); + } else { + MSG_DEBUG("Text path : [%s]", pMedia->szFilePath); + snprintf(textBuf, textBufSize, "%s", pMedia->szFilePath);//Set Text Filepath of First Pages + } + break; + } + } + } + } + + return; +} + + +//FIXME::need to move AppBase +msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allow_malware, const char *raw_filepath) +{ + MMS_PAGE_S *pPage = NULL; + MMS_MEDIA_S *pMedia = NULL; + int bc_level = -1; + + int ref_attach_count = 0; + const char * attachment_name = NULL; + + if (pMmsMsg == NULL) + return MSG_ERR_NULL_POINTER; + + MmsPluginStorage::instance()->removePreviewInfo(msgId); //remove exist previnfo + + //scan malware in raw file + if (raw_filepath && strlen(raw_filepath) > 0 && MsgAccessFile(raw_filepath, F_OK) == true) { + int tcs_ret = MmsPluginTcsScanFile(raw_filepath, &bc_level); + if (tcs_ret == 0) { + if (bc_level > -1) { + MSG_DEBUG("malware exist, level = %d", bc_level); + MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_MALWARE, "malware", bc_level); + } + } + } + + //check ref type and increase attach count + if (pMmsMsg->pageCnt > 0) { + for (int i = 0; i < pMmsMsg->pageCnt; i++) { + pPage = _MsgMmsGetPage(pMmsMsg, i); + if (pPage) { + for (int j = 0; j < pPage->mediaCnt; j++) { + pMedia = _MsgMmsGetMedia(pPage, j); + if (pMedia) { //IF Vobject type add to Attach in Preview data + + MimeType mimeType = MIME_UNKNOWN; + MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL); + if (mimeType == MIME_TEXT_X_VCALENDAR || mimeType == MIME_TEXT_X_VCARD) { + + MSG_DEBUG("Unsupported File [%s] It will be add to attach list", pMedia->szFilePath); + + ref_attach_count++; + + if (attachment_name == NULL) { + attachment_name = pMedia->szFileName; + } + } + + } + } + } + } + } + + + if (pMmsMsg->pageCnt > 0) { + + MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_PAGE, (char *)"pagecount", pMmsMsg->pageCnt); + + pPage = _MsgMmsGetPage(pMmsMsg, 0); + + if (pPage) { + for (int j = 0; j < pPage->mediaCnt; j++) { + + pMedia = _MsgMmsGetMedia(pPage, j); + + if (pMedia == NULL) { + MSG_ERR("[%d]th pMedia is NULL", j); + continue; + } + + MSG_SEC_DEBUG("pMedia's Name: %s", pMedia->szFilePath); + + if (allow_malware == false && bc_level > -1) { + if (pMedia->mediatype == MMS_SMIL_MEDIA_AUDIO) { + MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_AUDIO, pMedia->szFileName); + } + } else { + + if (j == 0) { //First Page, First Media + MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_1ST_MEDIA, pMedia->szFilePath); + } + + if (pMedia->mediatype == MMS_SMIL_MEDIA_IMG || pMedia->mediatype == MMS_SMIL_MEDIA_VIDEO) { + char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, }; + char thumbPath[MSG_FILEPATH_LEN_MAX+1] = {0, }; + char *pszExt = NULL; + + memset(szFileName, 0x00, MSG_FILENAME_LEN_MAX+1); + memset(thumbPath, 0x00, MSG_FILEPATH_LEN_MAX); + + MSG_DEBUG("drm type = %d, %s", pMedia->drmType, pMedia->szFilePath); + + if (pMedia->drmType == MSG_DRM_TYPE_NONE) { + + snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%d.mms",msgId); + + if ((pszExt = strrchr(pMedia->szFilePath, '.')) != NULL && !strcasecmp(pszExt, ".png")) { + snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, "%s%s.png", MSG_THUMBNAIL_PATH, szFileName); + } else { + snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, "%s%s.jpg", MSG_THUMBNAIL_PATH, szFileName); + } + + if (MmsMakeImageThumbnail(pMedia->szFilePath, thumbPath) == true) { + if (pMedia->mediatype == MMS_SMIL_MEDIA_IMG) { + MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_IMG, thumbPath); + } else { + MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_VIDEO, thumbPath); + } + } else { + MSG_DEBUG("Fail of generating thumbnail: %s to %s", pMedia->szFilePath, thumbPath); + } + } + } else if (pMedia->mediatype == MMS_SMIL_MEDIA_AUDIO) { + MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_AUDIO, pMedia->szFileName); + } + } + } + } // end for + } else { + MSG_DEBUG("There is no page"); + } + + int attachCnt = _MsgMmsGetAttachCount(pMmsMsg); + if (attachCnt > 0) { + + MMS_ATTACH_S *pAttach = _MsgMmsGetAttachment(pMmsMsg, 0); + + MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_ATTACH, pAttach->szFileName, attachCnt); + MmsPluginStorage::instance()->updateMmsAttachCount(msgId, attachCnt); // for Get Message + + if (attachment_name == NULL) { + attachment_name = pAttach->szFileName; + } + + } else { + MSG_DEBUG("There is no attachment"); + } + + if (attachCnt + ref_attach_count > 0 && attachment_name) { + + MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_ATTACH, attachment_name, attachCnt + ref_attach_count); + MmsPluginStorage::instance()->updateMmsAttachCount(msgId, attachCnt + ref_attach_count); + } + + return MSG_SUCCESS; +} diff --git a/plugin/mms_plugin/MmsPluginAvCodec.cpp b/plugin/mms_plugin/MmsPluginAvCodec.cpp deleted file mode 100755 index 0631bdd..0000000 --- a/plugin/mms_plugin/MmsPluginAvCodec.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* -* 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 "MmsPluginAvCodec.h" -#include - -AvCodecType AvGetFileCodecType(const char *szFileName) -{ - char szFileExt[FILEEXT_MAX] = {0, }; - int iPos = 0; - int iStrLen = 0; - bool bMIME = false; - - iStrLen = strlen(szFileName); - - iPos = iStrLen; - - while (iPos > 0) { - iPos--; - - if (szFileName[iPos] == '.') - break; - if (szFileName[iPos] == '/') { - bMIME = true; - break; - } - } - - if (iPos == 0) { - return AV_CODEC_NONE; - } - - if (FILEEXT_MAX > (iStrLen - iPos - 1)) { - strncpy(szFileExt, szFileName + iPos + 1, (iStrLen - iPos - 1)); - szFileExt[iStrLen - iPos - 1] = '\0'; - } else - return AV_CODEC_NONE; - - if (strcasecmp(szFileExt, "mp3") == 0 || strcasecmp(szFileExt, "MP3") == 0) - return AV_DEC_AUDIO_MP3; - - if (strcasecmp(szFileExt, "pvx") == 0 || strcasecmp(szFileExt, "PVX") == 0) - return AV_DEC_VIDEO_PVX; - else if (strcasecmp(szFileExt, "wav") == 0 || strcasecmp(szFileExt, "WAV") == 0) { -#ifdef AV_DEBUG_MODE - if (!bMIME) { - if (__AvValidWAVE(szFileName) == true) - return AV_DEC_AUDIO_WAVE; - else - return AV_CODEC_NONE; - } else -#endif - return AV_DEC_AUDIO_WAVE; - } else if (strcasecmp(szFileExt, "aac") == 0 || strcasecmp(szFileExt, "AAC") == 0) - return AV_DEC_AUDIO_AAC; -#ifdef AV_DEBUG_MODE - else if (strcasecmp(szFileExt, "wma") == 0 || strcasecmp(szFileExt, "WMA") == 0) - return AvWMFFGetFileType(szFileName); - else if (strcasecmp(szFileExt, "wmv") == 0 || strcasecmp(szFileExt, "WMV") == 0) - return AvWMFFGetFileType(szFileName); - else if (strcasecmp(szFileExt, "asf") == 0 || strcasecmp(szFileExt, "ASF") == 0) - return AvWMFFGetFileType(szFileName); -#endif - else if (strcasecmp(szFileExt, "amr") == 0 || strcasecmp(szFileExt, "AMR") == 0 || - strcasecmp(szFileExt, "x-amr") == 0 || strcasecmp(szFileExt, "X-AMR") == 0) { -#ifdef AV_DEBUG_MODE - if (!bMIME) { - if (__AvValidAMR(szFileName) == true) - return AV_DEC_AUDIO_AMR; - else - return AV_CODEC_NONE; - } else -#endif - return AV_DEC_AUDIO_AMR; - } else if (strcasecmp(szFileExt, "g7231") == 0 || strcasecmp(szFileExt, "G7231") == 0) - return AV_DEC_AUDIO_G723_1; - else if ((strcasecmp(szFileExt, "mid") == 0 || strcasecmp(szFileExt, "MID") == 0) || - (strcasecmp(szFileExt, "midi") == 0 || strcasecmp(szFileExt, "MIDI") == 0)) { -#ifdef AV_DEBUG_MODE - if (!bMIME) { - if (__AvValidMIDI(szFileName) == true) - return AV_DEC_AUDIO_MIDI; - else - return AV_CODEC_NONE; - } else -#endif - return AV_DEC_AUDIO_MIDI; - } else if (strcasecmp(szFileExt, "mmf") == 0 || strcasecmp(szFileExt, "MMF") == 0 || strcasecmp(szFileExt, "x-mmf") == 0) { -#ifdef AV_DEBUG_MODE - if (!bMIME) { - if (__AvValidMMF(szFileName) == true) - return AV_DEC_AUDIO_MMF; - else - return AV_CODEC_NONE; - } else -#endif - return AV_DEC_AUDIO_MMF; - } else if (strcasecmp(szFileExt, "pmd") == 0 || strcasecmp(szFileExt, "PMD") == 0) { - return AV_DEC_AUDIO_MIDI; - } else if (strcasecmp(szFileExt, "xmf") == 0 || strcasecmp(szFileExt, "XMF") == 0 || - strcasecmp(szFileExt, "mxmf") == 0 || strcasecmp(szFileExt, "MXMF") == 0) { - return AV_DEC_AUDIO_XMF; - } else if (strcasecmp(szFileExt, "smp") == 0 || strcasecmp(szFileExt, "SMP") == 0) { -#ifdef AV_DEBUG_MODE - if (!bMIME) { - if (__AvValidSMP(szFileName) == true) - return AV_DEC_AUDIO_ADPCM; - else - return AV_CODEC_NONE; - } else -#endif - return AV_DEC_AUDIO_ADPCM; - } else if (strcasecmp(szFileExt, "spm") == 0 || strcasecmp(szFileExt, "SPM") == 0) { -#ifdef AV_DEBUG_MODE - if (!bMIME) { - if (__AvValidMIDI(szFileName) == true) - return AV_DEC_AUDIO_SPM; - else - return AV_CODEC_NONE; - } else -#endif - return AV_DEC_AUDIO_SPM; - } else if (strcasecmp(szFileExt, "spf") == 0 || strcasecmp(szFileExt, "SPF") == 0) { -#ifdef AV_DEBUG_MODE - if (!bMIME) { - if (__AvValidMMF(szFileName) == true) - return AV_DEC_AUDIO_MMF_PHRASE_L1; - else - return AV_CODEC_NONE; - } else -#endif - return AV_DEC_AUDIO_MMF_PHRASE_L1; - } else if (strcasecmp(szFileExt, "imy") == 0 || strcasecmp(szFileExt, "IMY") == 0 || - strcasecmp(szFileExt, "iMelody") == 0 || strcasecmp(szFileExt, "x-iMelody") == 0 || - strcasecmp(szFileExt, "Melody") == 0) { -#ifdef AV_DEBUG_MODE - if (!bMIME) { - if (__AvValidIMELODY(szFileName) == true) - return AV_DEC_AUDIO_IMELODY; - else - return AV_CODEC_NONE; - } else -#endif - return AV_DEC_AUDIO_IMELODY; - } else if (strcasecmp(szFileExt, "dtmf") == 0) - return AV_DEC_AUDIO_DTMF_TONE; - else if (strcasecmp(szFileExt, "h263") == 0 || strcasecmp(szFileExt, "H263") == 0) - return AV_DEC_VIDEO_H263; - else if (strcasecmp(szFileExt, "mp4") == 0 || strcasecmp(szFileExt, "MP4") == 0 || - strcasecmp(szFileExt, "mpeg4") == 0 || strcasecmp(szFileExt, "MPEG4") == 0 || - strcasecmp(szFileExt, "m4a") == 0 || strcasecmp(szFileExt, "M4A") == 0) { -#ifdef AV_DEBUG_MODE - if (!bMIME) { - AvCodecType avCodecType = AV_CODEC_NONE; - FmFileAttribute fileAttrib; - size_t strLen; - UINT32 dateTime = 0; - - if (!DrmGetFileAttributes(szFileName, &fileAttrib)) { - return AV_CODEC_NONE; - } else { - dateTime = TmDateTimeToSeconds(&fileAttrib.dt); - strLen = strlen(szFileName); - if ((strnicmp(lastAccessFileInfo.szFileName, szFileName, strLen) == 0) && - (lastAccessFileInfo.fileSize == fileAttrib.fileSize) && - (lastAccessFileInfo.dateTime == dateTime)) { - return lastAccessFileInfo.codecType; - } else { - avCodecType = AvMP4FFGetFileType(szFileName); - - if (strcasecmp(szFileExt, "3ga") == 0 || strcasecmp(szFileExt, "3GA") == 0 || - strcasecmp(szFileExt, "m4a") == 0 || strcasecmp(szFileExt, "M4A") == 0) { - if (avCodecType | AV_DEC_AUDIO_MPEG4) - avCodecType = AV_DEC_AUDIO_MPEG4; - } - - if (avCodecType != AV_CODEC_NONE) { - strncpy(lastAccessFileInfo.szFileName, szFileName, strLen); - lastAccessFileInfo.szFileName[strLen] = '\0'; - lastAccessFileInfo.fileSize = fileAttrib.fileSize; - lastAccessFileInfo.dateTime = dateTime; - lastAccessFileInfo.codecType = avCodecType; - } - return avCodecType; - } - } - } -#endif - return AV_DEC_VIDEO_MPEG4; - } else if (strcasecmp(szFileExt, "3gp") == 0 || strcasecmp(szFileExt, "3GP") == 0 || - strcasecmp(szFileExt, "3ga") == 0 || strcasecmp(szFileExt, "3GA") == 0 || - strcasecmp(szFileExt, "3gpp") == 0 || strcasecmp(szFileExt, "3GPP") == 0) { - return AV_CODEC_NONE; - } else if (strcasecmp(szFileExt, "sdp") == 0 || strcasecmp(szFileExt, "SDP") == 0) - return AV_DEC_VIDEO_MPEG4; - else - return AV_CODEC_NONE; -} diff --git a/plugin/mms_plugin/MmsPluginCodec.cpp b/plugin/mms_plugin/MmsPluginCodec.cpp deleted file mode 100755 index c55a5c1..0000000 --- a/plugin/mms_plugin/MmsPluginCodec.cpp +++ /dev/null @@ -1,625 +0,0 @@ -/* -* 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 "MmsPluginCodec.h" -#include "MsgMmsTypes.h" -#include "MmsPluginMessage.h" -#include "MmsPluginMIME.h" -#include "MsgDebug.h" - -/* Reference : MMS-209-Encapsulation & WAP-203-WSP-20000504.pdf Table 39 */ -const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] = -{ - /* MMS Specific (MsgMmsMsg.h / MsgMmsUA.h) -----------------------*/ - - /* MmsCodeFieldCode */ - { - {"Bcc", 0x01}, //0 - {"Cc", 0x02}, - {"X-Mms-Content-Location", 0x03}, - {"Content-Type", 0x04}, - {"Date", 0x05}, - {"X-Mms-Delivery-Report", 0x06}, - {"X-Mms-Delivery-Time", 0x07}, - {"X-Mms-Expiry", 0x08}, - {"From", 0x09}, - {"X-Mms-Message-Class", 0x0A}, - {"Message-ID", 0x0B}, // 10 - {"X-Mms-Message-Type", 0x0C}, - {"X-Mms-MMS-Version", 0x0D}, - {"X-Mms-Message-Size", 0x0E}, - {"X-Mms-Priority", 0x0F}, - {"X-Mms-Read-Reply", 0x10}, - {"X-Mms-Report-Allowed", 0x11}, - {"X-Mms-Response-Status", 0x12}, - {"X-Mms-Retrieve-Status", 0x19}, /* Add by MMSENC v1.1 */ - {"X-Mms-Response-Text", 0x13}, - {"X-Mms-Retrieve-Text", 0x1A}, // 20 /* Add by MMSENC v1.1 */ - {"X-Mms-Sender-Visibility", 0x14}, - {"X-Mms-Status", 0x15}, - {"Subject", 0x16}, - {"To", 0x17}, - {"X-Mms-Transaction-ID", 0x18}, - - /* Add by MMSENC v1.1 */ - {"X-Mms-Read-Status", 0x1B}, - {"X-Mms-Reply-Charging", 0x1C}, - {"X-Mms-Reply-Charging-Deadline", 0x1D}, // 30 - {"X-Mms-Reply-Charging-ID", 0x1E}, - {"X-Mms-Reply-Charging-Size", 0x1F}, - {"X-Mms-Previously-Sent-By", 0x20}, - {"X-Mms-Previously-Sent-Date", 0x21}, - }, - - /* MmsCodeParameterCode ( By WSP Table 38. Wellknown parameter Assignments ) */ - { - {"Charset", 0x01}, // v1.1 base - {"Name", 0x05}, // v1.1 base. 0x17 at v1.4 - {"FileName", 0x06}, // v1.1 base. ox18 at v1.4 - {"Type", 0x09}, // v1.2 base - {"Start", 0x0A}, // v1.2 base. 0x19 at v1.4 - {"Start-Info", 0x0B}, // v1.2 base. 0x1A at v1.4 - {"boundary", 0xFF}, //laconic_javaParamFix - {"report-type", 0xFF}, // only used as parameter of Content-Type: multipart/report; report-type=delivery-status; -#ifdef FEATURE_JAVA_MMS - {"Application-ID", 0xFF}, - {"Reply-To-Application-ID", 0xFF}, -#endif - }, - - /* MmsCodeMsgBodyHeaderCode ( By WSP Table 39. Header Field Name Assignments ) */ - { - {"Content-Transfer-Encoding", 0xFFFF}, // only text encoding, no binary number - {"Content-Disposition", 0x2E}, // v1.1 base. 0x45 at v1.4 - {"Content-ID", 0x40}, // v1.3 base - {"Content-Location", 0x0E}, // v1.3 base - {"X-Oma-Drm-Separate-Delivery", 0xFF }, // DRM RO WAITING - }, - - /* MmsCodeMsgType */ - { - {"m-send-req", 0x00}, - {"m-send-conf", 0x01}, - {"m-notification-ind", 0x02}, - {"m-notifyresp-ind", 0x03}, - {"m-retrieve-conf", 0x04}, - {"m-acknowledge-ind", 0x05}, - {"m-delivery-ind", 0x06}, - - /* Add by MMSENC v1.1 */ - {"m-read-rec-ind", 0x07}, - {"m-read-orig-ind", 0x08}, - {"m-forward-req", 0x09}, - {"m-forward-conf", 0x0A} - }, - - /* MmsCodeDeliveryReport */ - { - { "Yes", 0x00 }, { "No", 0x01 } - }, - - /* MmsCodeTimeType */ - { - { "relative", 0x01 }, { "absolute", 0x00 } - }, - - /* MmsCodeMsgClass */ - { - {"Personal", 0x00}, - {"Advertisement", 0x01}, - {"Informational", 0x02}, - {"Auto", 0x03} - }, - - /* MmsCodePriority */ - { - { "Low", 0x00 }, { "Normal", 0x01 }, { "High", 0x02 } - }, - - /* MmsCodeResponseStatus */ - { - {"Ok", 0x00}, - {"Error-unspecified", 0x01}, - {"Error-service-denied", 0x02}, - {"Error-message-format-corrupt", 0x03}, - {"Error-sending-address-unresolved", 0x04}, - {"Error-message-not-found", 0x05}, - {"Error-network-problem", 0x06}, - {"Error-content-not-accepted", 0x07}, - {"Error-unsupported-message", 0x08}, - - {"Error-transient-failure", 0x40}, - {"Error-transient-sending-address-unresolved", 0x41}, - {"Error-transient-message-not-found", 0x42}, - {"Error-transient-network-problem", 0x43}, - - {"Error-transient-failure", 0x44}, //reserved for future - {"Error-transient-failure", 0x45}, - {"Error-transient-failure", 0x46}, - {"Error-transient-failure", 0x47}, - {"Error-transient-failure", 0x48}, - {"Error-transient-failure", 0x49}, - {"Error-transient-failure", 0x4A}, - {"Error-transient-failure", 0x4B}, - {"Error-transient-failure", 0x4C}, - {"Error-transient-failure", 0x4D}, - {"Error-transient-failure", 0x4E}, - {"Error-transient-failure", 0x4F}, - {"Error-transient-failure", 0x50}, - {"Error-transient-failure", 0x51}, - {"Error-transient-failure", 0x52}, - {"Error-transient-failure", 0x53}, - {"Error-transient-failure", 0x54}, - {"Error-transient-failure", 0x55}, - {"Error-transient-failure", 0x56}, - {"Error-transient-failure", 0x57}, - {"Error-transient-failure", 0x58}, - {"Error-transient-failure", 0x59}, - {"Error-transient-failure", 0x5A}, - {"Error-transient-failure", 0x5B}, - {"Error-transient-failure", 0x5C}, - {"Error-transient-failure", 0x5D}, - {"Error-transient-failure", 0x5E}, - {"Error-transient-failure", 0x5F}, - - {"Error-permanent-failure", 0x60}, - {"Error-permanent-service-denied", 0x61}, - {"Error-permanent-message-format-corrupt", 0x62}, - {"Error-permanent-sending-address-unresolved", 0x63}, - {"Error-permanent-message-not-found", 0x64}, - {"Error-permanent-content-not-accepted", 0x65}, - {"Error-permanent-reply-charging-limitations-not-met", 0x66}, - {"Error-permanent-reply-charging-request-not-accepted", 0x67}, - {"Error-permanent-reply-charging-forwarding-denied", 0x68}, - {"Error-permanent-reply-charging-not-supported", 0x69}, - - {"Error-permanent-failure", 0x6A}, //reserved for future - {"Error-permanent-failure", 0x6B}, - {"Error-permanent-failure", 0x6C}, - {"Error-permanent-failure", 0x6D}, - {"Error-permanent-failure", 0x6E}, - {"Error-permanent-failure", 0x6F}, - {"Error-permanent-failure", 0x70}, - {"Error-permanent-failure", 0x71}, - {"Error-permanent-failure", 0x72}, - {"Error-permanent-failure", 0x73}, - {"Error-permanent-failure", 0x74}, - {"Error-permanent-failure", 0x75}, - {"Error-permanent-failure", 0x76}, - {"Error-permanent-failure", 0x77}, - {"Error-permanent-failure", 0x78}, - {"Error-permanent-failure", 0x79}, - {"Error-permanent-failure", 0x7A}, - {"Error-permanent-failure", 0x7B}, - {"Error-permanent-failure", 0x7C}, - {"Error-permanent-failure", 0x7D}, - {"Error-permanent-failure", 0x7E}, - {"Error-permanent-failure", 0x7F} - - - }, - - /* MmsCodeRetrieveStatus */ - { - {"Ok", 0x00}, - {"Error-transient-failure", 0x40}, - {"Error-transient-message-not-found", 0x41}, - {"Error-transient-network-problem", 0x42}, - - {"Error-transient-failure", 0x43}, //reserved for future - {"Error-transient-failure", 0x44}, - {"Error-transient-failure", 0x45}, - {"Error-transient-failure", 0x46}, - {"Error-transient-failure", 0x47}, - {"Error-transient-failure", 0x48}, - {"Error-transient-failure", 0x49}, - {"Error-transient-failure", 0x4A}, - {"Error-transient-failure", 0x4B}, - {"Error-transient-failure", 0x4C}, - {"Error-transient-failure", 0x4D}, - {"Error-transient-failure", 0x4E}, - {"Error-transient-failure", 0x4F}, - {"Error-transient-failure", 0x50}, - {"Error-transient-failure", 0x51}, - {"Error-transient-failure", 0x52}, - {"Error-transient-failure", 0x53}, - {"Error-transient-failure", 0x54}, - {"Error-transient-failure", 0x55}, - {"Error-transient-failure", 0x56}, - {"Error-transient-failure", 0x57}, - {"Error-transient-failure", 0x58}, - {"Error-transient-failure", 0x59}, - {"Error-transient-failure", 0x5A}, - {"Error-transient-failure", 0x5B}, - {"Error-transient-failure", 0x5C}, - {"Error-transient-failure", 0x5D}, - {"Error-transient-failure", 0x5E}, - {"Error-transient-failure", 0x5F}, - - {"Error-permanent-failure", 0x60}, - {"Error-permanent-service-denied", 0x61}, - {"Error-permanent-message-not-found", 0x62}, - {"Error-permanent-content-unsupported", 0x63}, - - {"Error-permanent-failure", 0x64}, //reserved for future - {"Error-permanent-failure", 0x65}, - {"Error-permanent-failure", 0x66}, - {"Error-permanent-failure", 0x67}, - {"Error-permanent-failure", 0x68}, - {"Error-permanent-failure", 0x69}, - {"Error-permanent-failure", 0x6A}, - {"Error-permanent-failure", 0x6B}, - {"Error-permanent-failure", 0x6C}, - {"Error-permanent-failure", 0x6D}, - {"Error-permanent-failure", 0x6E}, - {"Error-permanent-failure", 0x6F}, - {"Error-permanent-failure", 0x70}, - {"Error-permanent-failure", 0x71}, - {"Error-permanent-failure", 0x72}, - {"Error-permanent-failure", 0x73}, - {"Error-permanent-failure", 0x74}, - {"Error-permanent-failure", 0x75}, - {"Error-permanent-failure", 0x76}, - {"Error-permanent-failure", 0x77}, - {"Error-permanent-failure", 0x78}, - {"Error-permanent-failure", 0x79}, - {"Error-permanent-failure", 0x7A}, - {"Error-permanent-failure", 0x7B}, - {"Error-permanent-failure", 0x7C}, - {"Error-permanent-failure", 0x7D}, - {"Error-permanent-failure", 0x7E}, - {"Error-permanent-failure", 0x7F} - - }, - - /* MmsCodeReadReply */ - { - { "Yes", 0x00 }, { "No", 0x01 } - }, - - /* MmsCodeReportAllowed */ - { - { "Yes", 0x00 }, { "No", 0x01 } - }, - - /* MmsCodeSenderVisibility */ - { - { "Show", 0x01 }, { "Hide", 0x00 } - }, - - /* MmsCodeMsgStatus */ - { - {"Expired", 0x00}, - {"Retrieved", 0x01}, - {"Rejected", 0x02}, - {"Deferred", 0x03}, - {"Unrecognised", 0x04}, - - /* Add by MMSENC v1.1 */ - {"Indeterminate ", 0x05}, - {"Forwarded", 0x06}, - - /* Add by MMSENC v1.2 */ - {"Unreachable", 0x07 } - - }, - - /* MmsCodeReadStatus */ - { - {"Read", 0x00}, {"Deleted", 0x01} - }, - - /* MmsCodeAddressType */ - { - {"present", 0x00}, {"insert", 0x01} - }, - - - /* MSG Specific (MsgMIMEExtern.h) -----------------------*/ - - /* MmsCodeCharSet */ - { - {"us-ascii", 0x03}, - {"UTF-16", 0x03F7}, - {"ISO-10646-UCS-2", 0x03E8}, - {"UTF-8", 0x6A}, - - {"ISO-2022-KR", 0x25}, - {"KS_C_5601-1987", 0x24}, - {"EUC-KR", 0x26}, - {"ISO-2022-JP", 0x27}, - {"ISO-2022-JP-2", 0x28}, - - {"ISO_8859-1", 0x04}, - {"ISO_8859-2", 0x05}, - {"ISO-8859-3", 0x06}, - {"ISO-8859-4", 0x07}, - {"ISO-8859-5", 0x08}, - {"ISO-8859-6", 0x09}, - {"ISO-8859-6-E", 0x51}, - {"ISO-8859-6-I", 0x52}, - {"ISO-8859-7", 0x0a}, - {"ISO-8859-8", 0x0b}, - {"ISO-8859-8-I", 0x85}, - {"ISO-8859-9", 0x0c}, - {"ISO-8859-10", 0x0d}, - {"ISO-8859-15", 0x6F}, - - {"Shift_JIS", 0x11}, - {"EUC-JP", 0x13}, - {"GB2312", 0x07E9}, - {"BIG5", 0x0d}, - {"WIN1251", 0xFF}, - {"WINDOW-1251", 0xFF}, - {"WINDOWS-1251", 0xFF}, - {"KOI8-R", 0x0824}, - {"KOI8-U", 0x0828}, - }, - - /* MmsCodeReplyCharging, */ - { - { "Requested", 0x00 }, - { "Requested text only", 0x01 }, - { "Accepted", 0x02 }, - { "Accepted text only", 0x03 } - }, - - - /* MSG Specific (MsgMIMEExtern.h) -----------------------*/ - - /* Content-Type (http://www.wapforum.org/wina/wsp-content-type.htm) */ - /* this group(Content-Type) will be replaced by utyMime */ - { - // {"Text/txt", 0x01}, - {"Text/html", 0x02}, - {"Text/plain", 0x03}, - {"Text/vnd.wap.wml", 0x08}, - {"Text/x-vCalendar", 0x06}, - {"Text/x-vCard", 0x07}, - - {"Application/vnd.wap.multipart.*", 0x22}, - {"Application/vnd.wap.multipart.mixed", 0x23}, - {"Application/vnd.wap.multipart.related", 0x33}, - {"Application/vnd.wap.multipart.alternative", 0x26}, - - {"application/vnd.oma.drm.message", 0x48}, // 10 - {"application/vnd.oma.drm.content", 0x49}, - {"application/vnd.oma.drm.rights+xml", 0x4A}, - {"application/vnd.oma.drm.rights+wbxml", 0x4B}, - - {"application/smil", 0xFFFF}, - {"Multipart/mixed", 0x0c}, - {"Multipart/related", 0x0B}, - {"Multipart/alternative", 0x0F}, - - {"multipart/report", 0xffff}, - {"Message/rfc822", 0xffff}, - - // T E X T - {"Image/gif", 0x1D}, // 20 - {"Image/jpeg", 0x1E}, - {"Image/jpg", 0xFFFF}, - {"image/tiff", 0x1f}, - {"Image/png", 0x20}, - - - {"Image/vnd.wap.wbmp", 0x21}, - - {"Image/wbmp", 0xFFFF}, - {"Image/pjpeg", 0xFFFF}, - - {"Image/bmp", 0xFFFF}, - - // A U D I O - {"Audio/basic", 0xFFFF}, - {"Audio/mpeg", 0xFFFF}, // 30 - {"Audio/x-mpeg", 0xFFFF}, - {"Audio/mp3", 0xFFFF}, - {"audio/x-mp3", 0xFFFF}, - {"audio/mpeg3", 0xFFFF}, - {"audio/x-mpeg3", 0xFFFF}, - {"audio/mpg", 0xFFFF}, - {"audio/x-mpg", 0xFFFF}, - {"audio/x-mpegaudio", 0xFFFF}, - {"Audio/aac", 0xFFFF}, // 39 - {"Audio/g72", 0xFFFF}, - {"Audio/amr", 0xFFFF}, - {"audio/x-amr", 0xFFFF}, - {"audio/x-mmf", 0xFFFF}, - {"application/vnd.smaf", 0xffff}, - {"application/x-smaf", 0xFFFF}, - {"audio/mmf", 0xFFFF}, - - {"text/x-iMelody", 0xffff}, - {"audio/x-iMelody", 0xffff}, - {"audio/iMelody", 0xffff}, // 49 - {"audio/mid",0xffff}, - {"audio/midi", 0xffff}, - {"audio/x-midi", 0xffff}, - {"audio/sp-midi", 0xffff}, - {"audio/wave", 0xffff}, - {"audio/3gpp", 0xffff}, - {"audio/vnd.rn-realaudio", 0xffff}, - {"audio/x-pn-realaudio", 0xffff}, - {"audio/mp4", 0xffff}, - - // V I D E O - {"video/mpeg4", 0xFFFF}, - {"video/mp4", 0xffff}, - {"video/x-mp4", 0xFFFF}, - {"video/x-vp-mp4", 0xffff}, - {"Video/h263", 0xFFFF}, - - {"video/3gpp", 0xffff}, - {"video/3gp", 0xffff}, - {"Video/avi", 0xFFFF}, - - {"video/sdp", 0xffff}, // 70 - {"application/vnd.rn-realmedia", 0xffff}, - {"video/vnd.rn-realvideo", 0xffff}, - - {"application/octet-stream", 0xFFFF } - }, - - /* MmsCodeMsgDisposition : Wsp Header (By Wsp 8.4.2.53) */ - { - {"form-data", 0x00}, - {"attachment", 0x01}, - {"inline", 0x02} - }, - - /* Content-transfer-encoding : HTTP Header(Binary Value is not assigned) */ - { - {"7bit", 0x00}, - {"8bit", 0x00}, - {"binary", 0x00}, - {"base64", 0x00}, - {"quoted-printable", 0x00} - } -}; - -/* global variables */ -static char gszMmsVersion[5] = {0, }; - -char *_MmsGetTextValue(MmsCode i, int j) -{ - if (i == MmsCodeContentType) { - //apply UtyMime - return MimeGetMimeStringFromMimeInt(j); - } - - return (char *)gMmsField[i][j].szText; -} - -char *_MmsGetTextValuebyField(int field, int value) -{ - char *szValue = NULL; - - switch (field) { - case MMS_CODE_MSGTYPE: - szValue = _MmsGetTextValue(MmsCodeMsgType, value); - break; - - case MMS_CODE_MSGCLASS: - szValue = _MmsGetTextValue(MmsCodeMsgClass, value); - break; - - case MMS_CODE_PRIORITY: - szValue = _MmsGetTextValue(MmsCodePriority, value); - break; - - case MMS_CODE_SENDERVISIBILLITY: - szValue = _MmsGetTextValue(MmsCodeSenderVisibility, value); - break; - - case MMS_CODE_DELIVERYREPORT: - szValue = _MmsGetTextValue(MmsCodeDeliveryReport, value); - break; - - case MMS_CODE_READREPLY: - szValue = _MmsGetTextValue(MmsCodeReadReply, value); - break; - - case MMS_CODE_MSGSTATUS: - szValue = _MmsGetTextValue(MmsCodeMsgStatus, value); - break; - - case MMS_CODE_REPORTALLOWED: - szValue = _MmsGetTextValue(MmsCodeReportAllowed, value); - break; - - case MMS_CODE_RESPONSESTATUS: - szValue = _MmsGetTextValue(MmsCodeResponseStatus, value); - break; - - /* Add by MMSENC v1.1 */ - case MMS_CODE_READSTATUS: - szValue = _MmsGetTextValue(MmsCodeReadStatus, value); - break; - - default: - szValue = NULL; - break; - } - - return szValue; -} - -UINT16 _MmsGetBinaryValue(MmsCode i, int j) -{ - if (i == MmsCodeContentType) { - return MimeGetBinaryValueFromMimeInt((MimeType)j); - } - - return gMmsField[i][j].binary; -} - -// getting mime type (int) by binary type -int _MmsGetBinaryType(MmsCode i, UINT16 value) -{ - MSG_BEGIN(); - - if (i == MmsCodeContentType) { - //apply UtyMime - return MimeGetMimeIntFromBi(value); - } - - for (int j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) { - if (gMmsField[i][j].binary == value) { - return j; - } - } - - MSG_END(); - - return MIME_UNKNOWN; -} - -int _MmsGetTextType(MmsCode i, char *pValue) -{ - int j = 0; - - if (i == MmsCodeContentType) { - /*apply UtyMime */ - return MimeGetMimeIntFromMimeString( pValue ); - } - - for (j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) { - if (gMmsField[i][j].szText != NULL) { - if (strcasecmp( gMmsField[i][j].szText, pValue ) == 0) { - return j; - } - } - } - - return -1; -} - -UINT8 _MmsGetVersion(MmsMsg *pMsg) -{ - if (pMsg == NULL) { - return MMS_VERSION; - } - - return pMsg->mmsAttrib.version; -} - -bool _MmsSetVersion(int majorVer, int minorVer) -{ - snprintf(gszMmsVersion, sizeof(gszMmsVersion), "%d.%d", majorVer, minorVer); - return true; -} - diff --git a/plugin/mms_plugin/MmsPluginCodecCommon.cpp b/plugin/mms_plugin/MmsPluginCodecCommon.cpp new file mode 100755 index 0000000..c8078d2 --- /dev/null +++ b/plugin/mms_plugin/MmsPluginCodecCommon.cpp @@ -0,0 +1,1911 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#include +#include "MmsPluginDebug.h" +#include "MmsPluginCodecCommon.h" +#include "MmsPluginMIME.h" +#include "MmsPluginUtil.h" +#include "MmsPluginTextConvert.h" + +#include +using namespace std; + +#define MMS_MAX_FIELD_VALUE_COUNT 74 +#define MMS_MAX_FIELD_TYPE_COUNT 21 + +typedef struct { + const char *szText; + UINT16 binary; +} MmsField; + +/* Reference : MMS-209-Encapsulation & WAP-203-WSP-20000504.pdf Table 39 */ +const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] = +{ + /* MMS Specific (MsgMmsMsg.h / MsgMmsUA.h) -----------------------*/ + + /* MmsCodeFieldCode */ + { + {"Bcc", 0x01}, //0 + {"Cc", 0x02}, + {"X-Mms-Content-Location", 0x03}, + {"Content-Type", 0x04}, + {"Date", 0x05}, + {"X-Mms-Delivery-Report", 0x06}, + {"X-Mms-Delivery-Time", 0x07}, + {"X-Mms-Expiry", 0x08}, + {"From", 0x09}, + {"X-Mms-Message-Class", 0x0A}, + {"Message-ID", 0x0B}, // 10 + {"X-Mms-Message-Type", 0x0C}, + {"X-Mms-MMS-Version", 0x0D}, + {"X-Mms-Message-Size", 0x0E}, + {"X-Mms-Priority", 0x0F}, + {"X-Mms-Read-Reply", 0x10}, + {"X-Mms-Report-Allowed", 0x11}, + {"X-Mms-Response-Status", 0x12}, + {"X-Mms-Retrieve-Status", 0x19}, /* Add by MMSENC v1.1 */ + {"X-Mms-Response-Text", 0x13}, + {"X-Mms-Retrieve-Text", 0x1A}, // 20 /* Add by MMSENC v1.1 */ + {"X-Mms-Sender-Visibility", 0x14}, + {"X-Mms-Status", 0x15}, + {"Subject", 0x16}, + {"To", 0x17}, + {"X-Mms-Transaction-ID", 0x18}, + + /* Add by MMSENC v1.1 */ + {"X-Mms-Read-Status", 0x1B}, + {"X-Mms-Reply-Charging", 0x1C}, + {"X-Mms-Reply-Charging-Deadline", 0x1D}, // 30 + {"X-Mms-Reply-Charging-ID", 0x1E}, + {"X-Mms-Reply-Charging-Size", 0x1F}, + {"X-Mms-Previously-Sent-By", 0x20}, + {"X-Mms-Previously-Sent-Date", 0x21}, + }, + + /* MmsCodeParameterCode ( By WSP Table 38. Wellknown parameter Assignments ) */ + { + {"Charset", 0x01}, // v1.1 base + {"Name", 0x05}, // v1.1 base. 0x17 at v1.4 + {"FileName", 0x06}, // v1.1 base. ox18 at v1.4 + {"Type", 0x09}, // v1.2 base + {"Start", 0x0A}, // v1.2 base. 0x19 at v1.4 + {"Start-Info", 0x0B}, // v1.2 base. 0x1A at v1.4 + {"boundary", 0xFF}, //laconic_javaParamFix + {"report-type", 0xFF}, // only used as parameter of Content-Type: multipart/report; report-type=delivery-status; +#ifdef FEATURE_JAVA_MMS + {"Application-ID", 0xFF}, + {"Reply-To-Application-ID", 0xFF}, +#endif + }, + + /* MmsCodeMsgBodyHeaderCode ( By WSP Table 39. Header Field Name Assignments ) */ + { + {"Content-Transfer-Encoding", 0xFFFF}, // only text encoding, no binary number + {"Content-Disposition", 0x2E}, // v1.1 base. 0x45 at v1.4 + {"Content-ID", 0x40}, // v1.3 base + {"Content-Location", 0x0E}, // v1.3 base + {"X-Oma-Drm-Separate-Delivery", 0xFF }, // DRM RO WAITING + }, + + /* MmsCodeMsgType */ + { + {"m-send-req", 0x00}, + {"m-send-conf", 0x01}, + {"m-notification-ind", 0x02}, + {"m-notifyresp-ind", 0x03}, + {"m-retrieve-conf", 0x04}, + {"m-acknowledge-ind", 0x05}, + {"m-delivery-ind", 0x06}, + + /* Add by MMSENC v1.1 */ + {"m-read-rec-ind", 0x07}, + {"m-read-orig-ind", 0x08}, + {"m-forward-req", 0x09}, + {"m-forward-conf", 0x0A} + }, + + /* MmsCodeDeliveryReport */ + { + { "Yes", 0x00 }, { "No", 0x01 } + }, + + /* MmsCodeTimeType */ + { + { "relative", 0x01 }, { "absolute", 0x00 } + }, + + /* MmsCodeMsgClass */ + { + {"Personal", 0x00}, + {"Advertisement", 0x01}, + {"Informational", 0x02}, + {"Auto", 0x03} + }, + + /* MmsCodePriority */ + { + { "Low", 0x00 }, { "Normal", 0x01 }, { "High", 0x02 } + }, + + /* MmsCodeResponseStatus */ + { + {"Ok", 0x00}, + {"Error-unspecified", 0x01}, + {"Error-service-denied", 0x02}, + {"Error-message-format-corrupt", 0x03}, + {"Error-sending-address-unresolved", 0x04}, + {"Error-message-not-found", 0x05}, + {"Error-network-problem", 0x06}, + {"Error-content-not-accepted", 0x07}, + {"Error-unsupported-message", 0x08}, + + {"Error-transient-failure", 0x40}, + {"Error-transient-sending-address-unresolved", 0x41}, + {"Error-transient-message-not-found", 0x42}, + {"Error-transient-network-problem", 0x43}, + + {"Error-permanent-failure", 0x60}, + {"Error-permanent-service-denied", 0x61}, + {"Error-permanent-message-format-corrupt", 0x62}, + {"Error-permanent-sending-address-unresolved", 0x63}, + {"Error-permanent-message-not-found", 0x64}, + {"Error-permanent-content-not-accepted", 0x65}, + {"Error-permanent-reply-charging-limitations-not-met", 0x66}, + {"Error-permanent-reply-charging-request-not-accepted", 0x67}, + {"Error-permanent-reply-charging-forwarding-denied", 0x68}, + {"Error-permanent-reply-charging-not-supported", 0x69}, + }, + + /* MmsCodeRetrieveStatus */ + { + {"Ok", 0x00}, + {"Error-transient-failure", 0x40}, + {"Error-transient-message-not-found", 0x41}, + {"Error-transient-network-problem", 0x42}, + + {"Error-permanent-failure", 0x60}, + {"Error-permanent-service-denied", 0x61}, + {"Error-permanent-message-not-found", 0x62}, + {"Error-permanent-content-unsupported", 0x63}, + }, + + /* MmsCodeReadReply */ + { + { "Yes", 0x00 }, { "No", 0x01 } + }, + + /* MmsCodeReportAllowed */ + { + { "Yes", 0x00 }, { "No", 0x01 } + }, + + /* MmsCodeSenderVisibility */ + { + { "Show", 0x01 }, { "Hide", 0x00 } + }, + + /* MmsCodeMsgStatus */ + { + {"Expired", 0x00}, + {"Retrieved", 0x01}, + {"Rejected", 0x02}, + {"Deferred", 0x03}, + {"Unrecognised", 0x04}, + + /* Add by MMSENC v1.1 */ + {"Indeterminate ", 0x05}, + {"Forwarded", 0x06}, + + /* Add by MMSENC v1.2 */ + {"Unreachable", 0x07 } + + }, + + /* MmsCodeReadStatus */ + { + {"Read", 0x00}, {"Deleted", 0x01} + }, + + /* MmsCodeAddressType */ + { + {"present", 0x00}, {"insert", 0x01} + }, + + + /* MSG Specific (MsgMIMEExtern.h) -----------------------*/ + + /* MmsCodeCharSet */ + { + {"US-ASCII", 0x03}, + {"UTF-16", 0x03F7}, + {"CSUNICODE", 0x03E8}, + {"UTF-8", 0x6A}, + {"ISO-2022-KR", 0x25}, + {"KS_C_5601-1987", 0x24}, + {"EUC-KR", 0x26}, + {"ISO-2022-JP", 0x27}, + {"ISO-2022-JP-2", 0x28}, + {"ISO_8859-1", 0x04}, + {"ISO_8859-2", 0x05}, + {"ISO-8859-3", 0x06}, + {"ISO-8859-4", 0x07}, + {"ISO-8859-5", 0x08}, + {"ISO-8859-6", 0x09}, + {"ISO-8859-7", 0x0a}, + {"ISO-8859-8", 0x0b}, + {"ISO-8859-9", 0x0c}, + {"ISO-8859-10", 0x0d}, + {"ISO-8859-15", 0x6F}, + {"SHIFT_JIS", 0x11}, + {"EUC-JP", 0x13}, + {"GB2312", 0x07E9}, + {"BIG5", 0x0d}, + {"WINDOWS-1251", 0x08CB}, + {"KOI8-R", 0x0824}, + {"KOI8-U", 0x0828}, + }, + + /* MmsCodeReplyCharging, */ + { + { "Requested", 0x00 }, + { "Requested text only", 0x01 }, + { "Accepted", 0x02 }, + { "Accepted text only", 0x03 } + }, + + +// OMNA WSP Content Type Numbers +// http://technical.openmobilealliance.org/tech/omna/omna-wsp-content-type.aspx + { + //NOT USED THIS TABLE + }, + + /* MmsCodeMsgDisposition : Wsp Header (By Wsp 8.4.2.53) */ + { + {"form-data", 0x00}, + {"attachment", 0x01}, + {"inline", 0x02} + }, + + /* Content-transfer-encoding : HTTP Header(Binary Value is not assigned) */ + { + {"7bit", 0x00}, + {"8bit", 0x00}, + {"binary", 0x00}, + {"base64", 0x00}, + {"quoted-printable", 0x00} + } +}; + +const char *MmsGetTextValue(MmsCode i, int j) +{ + if (i == MmsCodeContentType) { + //apply UtyMime + return MimeGetMimeStringFromMimeInt(j); + } + + return (const char *)gMmsField[i][j].szText; +} + +const char *MmsGetTextValuebyField(int field, int value) +{ + const char *szValue = NULL; + + switch (field) { + case MMS_CODE_MSGTYPE: + szValue = MmsGetTextValue(MmsCodeMsgType, value); + break; + + case MMS_CODE_MSGCLASS: + szValue = MmsGetTextValue(MmsCodeMsgClass, value); + break; + + case MMS_CODE_PRIORITY: + szValue = MmsGetTextValue(MmsCodePriority, value); + break; + + case MMS_CODE_SENDERVISIBILLITY: + szValue = MmsGetTextValue(MmsCodeSenderVisibility, value); + break; + + case MMS_CODE_DELIVERYREPORT: + szValue = MmsGetTextValue(MmsCodeDeliveryReport, value); + break; + + case MMS_CODE_READREPLY: + szValue = MmsGetTextValue(MmsCodeReadReply, value); + break; + + case MMS_CODE_MSGSTATUS: + szValue = MmsGetTextValue(MmsCodeMsgStatus, value); + break; + + case MMS_CODE_REPORTALLOWED: + szValue = MmsGetTextValue(MmsCodeReportAllowed, value); + break; + + case MMS_CODE_RESPONSESTATUS: + szValue = MmsGetTextValue(MmsCodeResponseStatus, value); + break; + + /* Add by MMSENC v1.1 */ + case MMS_CODE_READSTATUS: + szValue = MmsGetTextValue(MmsCodeReadStatus, value); + break; + + default: + szValue = NULL; + break; + } + + return szValue; +} + +UINT16 MmsGetBinaryValue(MmsCode i, int j) +{ + if (i == MmsCodeContentType) { + return MimeGetBinaryValueFromMimeInt((MimeType)j); + } + + return gMmsField[i][j].binary; +} + +int MmsGetBinaryType(MmsCode i, UINT16 value) +{ + + for (int j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) { + if (gMmsField[i][j].binary == value) { + MSG_DEBUG("code [%d], value [0x%02x], ret type [%d]", i, value, j); + return j; + } + } + + MSG_DEBUG("code [%d], value [0x%02x], ret type [Unknown]", i, value); + return -1; +} + +int MmsGetTextType(MmsCode i, char *pValue) +{ + int j = 0; + + if (i == MmsCodeContentType) { + /*apply UtyMime */ + return MimeGetMimeIntFromMimeString( pValue ); + } + + for (j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) { + if (gMmsField[i][j].szText != NULL) { + if (strcasecmp( gMmsField[i][j].szText, pValue ) == 0) { + return j; + } + } + } + + return -1; +} + +const char *MmsGetTextByCode(MmsCode i, UINT16 code) +{ + for (int j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) { + if (gMmsField[i][j].binary == code) { + return gMmsField[i][j].szText; + } + } + return NULL; +} + + + +/* ================================================================== + * Decode/Encode inline base64 string + * + * base64 : 3*8bit -> 4*6bit & convert the value into A~Z, a~z, 0~9, +, or / + * pad(=) is needed when the end of the string is < 24bit. + * + * Value Encoding Value Encoding Value Encoding Value Encoding + * 0 A 17 R 34 i 51 z + * 1 B 18 S 35 j 52 '0' + * 2 C 19 T 36 k 53 1 + * 3 D 20 U 37 l 54 2 + * 4 E 21 V 38 m 55 3 + * 5 F 22 W 39 n 56 4 + * 6 G 23 X 40 o 57 5 + * 7 H 24 Y 41 p 58 6 + * 8 I 25 Z 42 q 59 7 + * 9 J 26 a 43 r 60 8 + * 10 K 27 b 44 s 61 9 + * 11 L 28 c 45 t 62 + + * 12 M 29 d 46 u 63 / + * 13 N 30 e 47 v + * 14 O 31 f 48 w (pad) = + * 15 P 32 g 49 x + * 16 Q 33 h 50 y + * + * (1) the final quantum = 24 bits : no "=" padding, + * (2) the final quantum = 8 bits : two "=" + two characters + * (3) the final quantum = 16 bits : one "=" + three characters + * ================================================================== */ + +void *MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *len) +{ + char c; + void *ret = NULL; + char *d = NULL; + short e = 0; + + ret = malloc((size_t)(*len = 4 + ((srcLen * 3) / 4))); + d = (char *)ret; + + if (ret == NULL) { + MSG_DEBUG("_MsgDecodeBase64: ret malloc Fail \n"); + return NULL; + } + + memset(ret, 0, (size_t)*len); + *len = 0; + + while (srcLen-- > 0) { + c = *pSrc++; + + /* Convert base64 character into original value */ + + if (isupper(c)) + c -= 'A'; + else if (islower(c)) + c -= 'a' - 26; + else if (isdigit(c)) + c -= '0' - 52; + else if (c == '+') + c = 62; + else if (c == '/') + c = 63; + else if (c == '=') { + switch (e++) { + case 2: + if (*pSrc != '=') { + *len = d - (char *)ret; + return ret; + } + break; + case 3: + e = 0; + break; + default: + *len = d - (char *)ret; + return ret; + } + continue; + } else + continue; // Actually, never get here + + /* Pad 4*6bit character into 3*8bit character */ + + switch (e++) { + case 0: + *d = c << 2; // byte 1: high 6 bits + break; + + case 1: + *d++ |= c >> 4; // byte 1: low 2 bits + *d = c << 4; // byte 2: high 4 bits + break; + + case 2: + *d++ |= c >> 2; // byte 2: low 4 bits + *d = c << 6; // byte 3: high 2 bits + break; + + case 3: + *d++ |= c; // byte 3: low 6 bits + e = 0; // Calculate next unit. + break; + + default: + MSG_DEBUG("_MsgDecodeBase64: Unknown paremeter\n"); + break; + } + } + + *len = d - (char *)ret; // Calculate the size of decoded string. + + return ret; +} + + + +/* ========================================== + * Decode/Encode inline base64 string + * + * quoted-printable := ([*(ptext / SPACE / TAB) ptext] ["="] CRLF) + * ; Maximum line length of 76 characters excluding CRLF + * + * ptext := octet / 127, =, SPACE, or TAB. + * + * ==========================================*/ + + +unsigned char *MsgDecodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len) +{ + unsigned char *ret = NULL; + unsigned char *d = NULL; + unsigned char *s = NULL; /* last non-blank */ + unsigned char c; + unsigned char e; + + d = s = ret = (unsigned char *)malloc((size_t)srcLen + 1); + if (ret == NULL) { + MSG_DEBUG("_MsgDecodeQuotePrintable: ret malloc Fail \n"); + return NULL; + } + + *len = 0; + pSrc[srcLen] = '\0'; + + while ((c = *pSrc++)!= '\0') { + switch (c) { + case '=': /* octet characters (> 127, =, SPACE, or TAB) */ + switch (c = *pSrc++) { + case '\0': /* end of string -> postpone to while */ + break; + + case '\015': /* CRLF */ + if (*pSrc == '\012') + pSrc++; + break; + + default: /* two hexes */ + if (!isxdigit(c)) { + *d = '\0'; + *len = d - ret; + return ret; + } + + if (isdigit(c)) + e = c - '0'; + else + e = c - (isupper(c) ? 'A' - 10 : 'a' - 10); + + c = *pSrc++; + if (!isxdigit(c)) { + *d = '\0'; + *len = d - ret; + return ret; + } + + if (isdigit(c)) + c -= '0'; + else + c -= (isupper(c) ? 'A' - 10 : 'a' - 10); + + *d++ = c + (e << 4); + s = d; + break; + } + break; + + case ' ': /* skip the blank */ + *d++ = c; + break; + + case '\015': /* Line Feedback : to last non-blank character */ + d = s; + break; + + default: + *d++ = c; /* ASCII character */ + s = d; + break; + } + } + + *d = '\0'; + *len = d - ret; + + return ret; +} + + +/* ======================================== + * Decode/Encode inline base64 string + * Inline base64 has no "\r\n" in it, + * and has charset and encoding sign in it + * ======================================== */ +bool MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret) +{ + unsigned char *d = NULL; + unsigned char *s = (unsigned char *)pSrc; + char *v = (char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + unsigned long i = ((srcLen + 2) / 3) * 4; + + i += 2 * ((i / 60) + 1); + *len = i; + + if (ret == NULL) { + MSG_DEBUG("_MsgEncode2Base64: ret Memory Alloc Fail \n"); + return false; + } + memset(ret, 0, i); + + d = ret; + + /* Convert 3*8bit into 4*6bit */ + for (i = 0; srcLen > 0; s += 3) { + *d++ = v[s[0] >> 2]; // byte 1: high 6 bits of character-1 + *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f]; // byte 2: low 2 bits of character-1 and high 4 bits of character-2 + *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '='; // byte 3: low 4 bits of charcter-2 and high 2 bits of character-3 + *d++ = srcLen ? v[s[2] & 0x3f] : '='; // byte 4: low 6 bits of character-3 + + if (srcLen) + srcLen--; + } + + *d = '\0'; + + if (((unsigned long)(d - ret)) != *len) { + *len = d - ret; + MSG_DEBUG("base64 encoding length = %d \n", *len); + } + + return true; +} + +int extract_encoded_word_param(char *encoded_word, char **charset, char **encoding, char **encoded_text, unsigned int *encoded_word_size) +{ + char *start_ptr = NULL; + char *end_ptr = NULL; + char *q1_ptr = NULL; + char *q2_ptr = NULL; + + char *char_set = NULL; + char *l_encoded_text = NULL; + + char l_encoding[2] = {0,}; + + if (encoded_word == NULL) + goto __CATCH; + + if ( 6 > strlen(encoded_word)) { + goto __CATCH; + } + + start_ptr = encoded_word; + + if ( (encoded_word[0] == '=' && encoded_word[1] == '?') //"=?" + && ((q1_ptr = strchr(start_ptr + 2, MSG_CH_QUESTION)) != NULL) // '?' + && ((q2_ptr = strchr(q1_ptr + 1, MSG_CH_QUESTION))!= NULL) // '?' + && ((end_ptr = strstr(q2_ptr + 1, MSG_STR_DEC_END))!= NULL)) //"?=" + { + + //extract character set + if ( q1_ptr - (start_ptr + 2) > 0 ) { + + char_set = (char*)calloc(1, q1_ptr - (start_ptr + 2) + 1); + + if (char_set) { + strncpy(char_set, (char*)((start_ptr + 2)), q1_ptr - (start_ptr + 2)); + MSG_DEBUG("character set [%s][%d]", char_set, strlen(char_set)); + } else { + MSG_DEBUG("fail to calloc"); + goto __CATCH; + } + } else { + MSG_DEBUG("character set is NULL"); + goto __CATCH; + } + + //extract encode type + if ((*(q2_ptr - 1) == MSG_CH_BASE64_UPPER) || (*(q2_ptr - 1) == MSG_CH_BASE64_LOWER) + || (*(q1_ptr + 1) == MSG_CH_BASE64_UPPER) || (*(q1_ptr + 1) == MSG_CH_BASE64_LOWER)) + { + l_encoding[0] = MSG_CH_BASE64_UPPER; + } else if ((*(q2_ptr-1) == MSG_CH_QPRINT_UPPER) || (*(q2_ptr-1) == MSG_CH_QPRINT_LOWER) + || (*(q1_ptr+1) == MSG_CH_QPRINT_UPPER) || (*(q1_ptr+1) == MSG_CH_QPRINT_LOWER)) + { + //QPRINT + l_encoding[0] = MSG_CH_QPRINT_UPPER; + + } else { + MSG_DEBUG("unknown encoding"); + goto __CATCH; + } + + //extract encoded text + if (end_ptr - q2_ptr > 1) { + l_encoded_text = (char*)calloc(1, end_ptr - q2_ptr); + if (l_encoded_text == NULL) + goto __CATCH; + strncpy(l_encoded_text, (char*)(q2_ptr + 1), end_ptr - q2_ptr -1); + + MSG_DEBUG("encoded text [%s][%d]", l_encoded_text, strlen(l_encoded_text)); + } else { + MSG_DEBUG("encoded text is NULL"); + goto __CATCH; + } + + *charset = char_set; + *encoding = g_strdup(l_encoding); + *encoded_text = l_encoded_text; + *encoded_word_size = end_ptr - start_ptr + 2; + + } else { + MSG_DEBUG("It is not encoded word type"); + return -1; + } + + return 0; + +__CATCH: + MSG_FREE(char_set); + MSG_FREE(l_encoded_text); + return -1; +} + +char *MsgDecodeText(const char *pOri) +{ + MSG_BEGIN(); + + char *pSrc = NULL; + + char *encoded_word_start_ptr = NULL; + char *normal_word_start_ptr = NULL; + + char *charset = NULL; + char *encoding = NULL; + char *encoded_text = NULL; + char *decoded_text = NULL; + + char *return_string= NULL; + string result_string; + + bool b_encoded_word = false; + + unsigned int encoded_word_size = 0; + unsigned int total_len = 0; + unsigned int decoded_len = 0; + + // copy original string + if (pOri == NULL || strlen(pOri) <= 0) { + MSG_DEBUG("Invalid parameter : [%s]", pOri); + return NULL; + } + + pSrc = g_strdup(pOri); + total_len = strlen(pOri); + + MSG_DEBUG("input text : [%s][%d]", pSrc, total_len); + + normal_word_start_ptr = pSrc; + + while (normal_word_start_ptr < pSrc + total_len) { + + encoded_word_start_ptr = strstr(normal_word_start_ptr, MSG_STR_DEC_START); + + b_encoded_word = false; + + //Find encoded word + while (b_encoded_word == false && encoded_word_start_ptr != NULL ) { + + if (extract_encoded_word_param(encoded_word_start_ptr, &charset, &encoding, &encoded_text, &encoded_word_size) == 0) { + + if (charset && encoding && encoded_text && encoded_word_size > 0) { + b_encoded_word = true; + MSG_DEBUG("charset [%s], encoding [%s], encoded_text [%s], encoded_word_size [%d]", charset, encoding, encoded_text, encoded_word_size); + break; + } + + MSG_FREE(charset); + MSG_FREE(encoding); + MSG_FREE(encoded_text); + encoded_word_size = 0; + } + + encoded_word_start_ptr = strstr(encoded_word_start_ptr+1, MSG_STR_DEC_START); //find next encoded_start_ptr + + } // end of while + + if (b_encoded_word) { + + //copy normal text + if (encoded_word_start_ptr - normal_word_start_ptr > 0) { + result_string.append(normal_word_start_ptr, encoded_word_start_ptr - normal_word_start_ptr); + MSG_DEBUG("copy normal text : [%s]", result_string.c_str()); + } + + if (strcasecmp(encoding, "B") == 0) { + + MSG_DEBUG("Base64 encoded text [%s][%d]", encoded_text, strlen(encoded_text)); + + decoded_text = (char *)MsgDecodeBase64((unsigned char *)encoded_text, strlen(encoded_text), (ULONG *)&decoded_len); + + if (decoded_text && decoded_len > 0) { + + char *result_text = NULL; + int result_text_len = 0; + + MSG_DEBUG("Base64 decoded text [%s][%d], outlen [%d]", decoded_text, strlen(decoded_text), decoded_len); + + if (MmsPluginTextConvert("UTF-8", charset, decoded_text, decoded_len, &result_text, &result_text_len) == false) { + MSG_DEBUG("MmsPluginTextConvert Fail"); + } + + if(result_text) { + MSG_DEBUG("Text convert result [%s][%d]", result_text, strlen(result_text)); + + result_string.append(result_text, result_text_len); + + MSG_FREE(result_text); + } + + } else { + MSG_DEBUG("Fail base64 decode"); + } + + MSG_FREE(decoded_text); + + } else if (strcasecmp(encoding, "Q") == 0) { + + char *result_text = NULL; + int result_text_len = 0; + + MSG_DEBUG("Qprint encoded text [%s][%d]", encoded_text, strlen(encoded_text)); + + decoded_text = (char *)MsgDecodeQuotePrintable((unsigned char *)encoded_text, strlen(encoded_text), (ULONG *)&decoded_len); + + if (decoded_text && decoded_len > 0) { + + MSG_DEBUG("Qprint decoded text [%s][%d], outlen [%d]", decoded_text, strlen(decoded_text), decoded_len); + + if (MmsPluginTextConvert("UTF-8", charset, decoded_text, decoded_len, &result_text, &result_text_len) == false) { + MSG_DEBUG("MmsPluginTextConvert Fail"); + } + + if(result_text) { + MSG_DEBUG("Text convert result [%s][%d]", result_text, strlen(result_text)); + + result_string.append(result_text, result_text_len); + + MSG_FREE(result_text); + } + + } else { + MSG_DEBUG("Fail Qprint decode"); + } + + MSG_FREE(decoded_text); + } + + normal_word_start_ptr = encoded_word_start_ptr+encoded_word_size; //next + + MSG_FREE(charset); + MSG_FREE(encoding); + MSG_FREE(encoded_text); + encoded_word_size = 0; + + } else { + //copy remain normal text + + MSG_DEBUG("last text : [%s]", normal_word_start_ptr); + + result_string.append(normal_word_start_ptr); + + break; + } + + } //end of while + + if (result_string.length() > 0) { + return_string = g_strdup(result_string.c_str()); + MSG_DEBUG("return string: [%s]", return_string); + } + + MSG_FREE(pSrc); + + MSG_END(); + return return_string; +} + +static char gszDebugStringBuf[50]; + +static char *MmsDebugPrintUnknownValue(int value) +{ + snprintf(gszDebugStringBuf, sizeof(gszDebugStringBuf), "unknown value(%d)", value); + return gszDebugStringBuf; +} + + +const char *MmsDebugGetMimeType(MimeType mimeType) +{ + switch (mimeType) { + case MIME_APPLICATION_XML: + return "MIME_APPLICATION_XML"; + case MIME_APPLICATION_WML_XML: + return "MIME_APPLICATION_WML_XML"; + case MIME_APPLICATION_XHTML_XML: + return "MIME_APPLICATION_XHTML_XML"; + case MIME_APPLICATION_JAVA_VM: + return "MIME_APPLICATION_JAVA_VM"; + case MIME_APPLICATION_SMIL: + return "MIME_APPLICATION_SMIL"; + case MIME_APPLICATION_JAVA_ARCHIVE: + return "MIME_APPLICATION_JAVA_ARCHIVE"; + case MIME_APPLICATION_JAVA: + return "MIME_APPLICATION_JAVA"; + case MIME_APPLICATION_OCTET_STREAM: + return "MIME_APPLICATION_OCTET_STREAM"; + case MIME_APPLICATION_STUDIOM: + return "MIME_APPLICATION_STUDIOM"; + case MIME_APPLICATION_FUNMEDIA: + return "MIME_APPLICATION_FUNMEDIA"; + case MIME_APPLICATION_MSWORD: + return "MIME_APPLICATION_MSWORD"; + case MIME_APPLICATION_PDF: + return "MIME_APPLICATION_PDF"; + case MIME_APPLICATION_ASTERIC: + return "MIME_APPLICATION_ASTERIC"; + case MIME_APPLICATION_VND_WAP_XHTMLXML: + return "MIME_APPLICATION_VND_WAP_XHTMLXML"; + case MIME_APPLICATION_VND_WAP_WMLC: + return "MIME_APPLICATION_VND_WAP_WMLC"; + case MIME_APPLICATION_VND_WAP_WMLSCRIPTC: + return "MIME_APPLICATION_VND_WAP_WMLSCRIPTC"; + case MIME_APPLICATION_VND_WAP_WTA_EVENTC: + return "MIME_APPLICATION_VND_WAP_WTA_EVENTC"; + case MIME_APPLICATION_VND_WAP_UAPROF: + return "MIME_APPLICATION_VND_WAP_UAPROF"; + case MIME_APPLICATION_VND_WAP_SIC: + return "MIME_APPLICATION_VND_WAP_SIC"; + case MIME_APPLICATION_VND_WAP_SLC: + return "MIME_APPLICATION_VND_WAP_SLC"; + case MIME_APPLICATION_VND_WAP_COC: + return "MIME_APPLICATION_VND_WAP_COC"; + case MIME_APPLICATION_VND_WAP_SIA: + return "MIME_APPLICATION_VND_WAP_SIA"; + case MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML: + return "MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML"; + case MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA: + return "MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA"; + case MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES: + return "MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES"; + case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED: + return "MIME_APPLICATION_VND_WAP_MULTIPART_MIXED"; + case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED: + return "MIME_APPLICATION_VND_WAP_MULTIPART_RELATED"; + case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE: + return "MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE"; + case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC: + return "MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC"; + case MIME_APPLICATION_VND_OMA_DD_XML: + return "MIME_APPLICATION_VND_OMA_DD_XML"; + case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: + return "MIME_APPLICATION_VND_OMA_DRM_MESSAGE"; + case MIME_APPLICATION_VND_OMA_DRM_CONTENT: + return "MIME_APPLICATION_VND_OMA_DRM_CONTENT"; + case MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML: + return "MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML"; + case MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML: + return "MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML"; + case MIME_APPLICATION_VND_SMAF: + return "MIME_APPLICATION_VND_SMAF"; + case MIME_APPLICATION_VND_RN_REALMEDIA: + 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: + return "MIME_APPLICATION_X_HDMLC"; + case MIME_APPLICATION_X_X968_USERCERT: + return "MIME_APPLICATION_X_X968_USERCERT"; + case MIME_APPLICATION_X_WWW_FORM_URLENCODED: + return "MIME_APPLICATION_X_WWW_FORM_URLENCODED"; + case MIME_APPLICATION_X_SMAF: + return "MIME_APPLICATION_X_SMAF"; + case MIME_APPLICATION_X_FLASH: + return "MIME_APPLICATION_X_FLASH"; + case MIME_APPLICATION_X_EXCEL: + return "MIME_APPLICATION_X_EXCEL"; + case MIME_APPLICATION_X_POWERPOINT: + return "MIME_APPLICATION_X_POWERPOINT"; + + case MIME_AUDIO_BASIC: + return "MIME_AUDIO_BASIC"; + case MIME_AUDIO_MPEG: + return "MIME_AUDIO_MPEG"; + case MIME_AUDIO_MP3: + return "MIME_AUDIO_MP3"; + case MIME_AUDIO_MPG3: + return "MIME_AUDIO_MPG3"; + case MIME_AUDIO_MPEG3: + return "MIME_AUDIO_MPEG3"; + case MIME_AUDIO_MPG: + return "MIME_AUDIO_MPG"; + case MIME_AUDIO_AAC: + return "MIME_AUDIO_AAC"; + case MIME_AUDIO_G72: + return "MIME_AUDIO_G72"; + case MIME_AUDIO_AMR: + return "MIME_AUDIO_AMR"; + case MIME_AUDIO_AMR_WB: + return "MIME_AUDIO_AMR_WB"; + case MIME_AUDIO_MMF: + return "MIME_AUDIO_MMF"; + case MIME_AUDIO_SMAF: + return "MIME_AUDIO_SMAF"; + case MIME_AUDIO_IMELODY: + return "MIME_AUDIO_IMELODY"; + case MIME_AUDIO_MELODY: + return "MIME_AUDIO_MELODY"; + case MIME_AUDIO_MID: + return "MIME_AUDIO_MID"; + case MIME_AUDIO_MIDI: + return "MIME_AUDIO_MIDI"; + case MIME_AUDIO_X_MID: + return "MIME_AUDIO_X_MID"; + case MIME_AUDIO_SP_MIDI: + return "MIME_AUDIO_SP_MIDI"; + case MIME_AUDIO_WAVE: + return "MIME_AUDIO_WAVE"; + case MIME_AUDIO_3GPP: + return "MIME_AUDIO_3GPP"; + case MIME_AUDIO_MP4: + return "MIME_AUDIO_MP4"; + case MIME_AUDIO_MP4A_LATM: + return "MIME_AUDIO_MP4A_LATM"; + case MIME_AUDIO_VND_RN_REALAUDIO: + return "MIME_AUDIO_VND_RN_REALAUDIO"; + case MIME_AUDIO_X_MPEG: + return "MIME_AUDIO_X_MPEG"; + case MIME_AUDIO_X_MP3: + return "MIME_AUDIO_X_MP3"; + case MIME_AUDIO_X_MPEG3: + return "MIME_AUDIO_X_MPEG3"; + case MIME_AUDIO_X_MPG: + return "MIME_AUDIO_X_MPG"; + case MIME_AUDIO_X_AMR: + return "MIME_AUDIO_X_AMR"; + case MIME_AUDIO_X_MMF: + return "MIME_AUDIO_X_MMF"; + case MIME_AUDIO_X_SMAF: + return "MIME_AUDIO_X_SMAF"; + case MIME_AUDIO_X_IMELODY: + return "MIME_AUDIO_X_IMELODY"; + case MIME_AUDIO_X_MIDI: + return "MIME_AUDIO_X_MIDI"; + case MIME_AUDIO_X_MPEGAUDIO: + return "MIME_AUDIO_X_MPEGAUDIO"; + case MIME_AUDIO_X_PN_REALAUDIO: + return "MIME_AUDIO_X_PN_REALAUDIO"; + case MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO: + return "MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO"; + case MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE: + return "MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE"; + case MIME_AUDIO_X_WAV: + return "MIME_AUDIO_X_WAV"; + + case MIME_IMAGE_GIF: + return "MIME_IMAGE_GIF"; + case MIME_IMAGE_JPEG: + return "MIME_IMAGE_JPEG"; + case MIME_IMAGE_JPG: + return "MIME_IMAGE_JPG"; + case MIME_IMAGE_TIFF: + return "MIME_IMAGE_TIFF"; + case MIME_IMAGE_TIF: + return "MIME_IMAGE_TIF"; + case MIME_IMAGE_PNG: + return "MIME_IMAGE_PNG"; + case MIME_IMAGE_WBMP: + return "MIME_IMAGE_WBMP"; + case MIME_IMAGE_PJPEG: + return "MIME_IMAGE_PJPEG"; + case MIME_IMAGE_BMP: + return "MIME_IMAGE_BMP"; + case MIME_IMAGE_SVG: + return "MIME_IMAGE_SVG"; + case MIME_IMAGE_SVG1: + return "MIME_IMAGE_SVG1"; + case MIME_IMAGE_VND_WAP_WBMP: + return "MIME_IMAGE_VND_WAP_WBMP"; + + case MIME_IMAGE_X_BMP: + return "MIME_IMAGE_X_BMP"; + + case MIME_MESSAGE_RFC822: + return "MIME_MESSAGE_RFC822"; + + case MIME_MULTIPART_MIXED: + return "MIME_MULTIPART_MIXED"; + case MIME_MULTIPART_RELATED: + return "MIME_MULTIPART_RELATED"; + case MIME_MULTIPART_ALTERNATIVE: + return "MIME_MULTIPART_ALTERNATIVE"; + case MIME_MULTIPART_FORM_DATA: + return "MIME_MULTIPART_FORM_DATA"; + case MIME_MULTIPART_BYTERANGE: + return "MIME_MULTIPART_BYTERANGE"; + case MIME_MULTIPART_REPORT: + return "MIME_MULTIPART_REPORT"; + + case MIME_TEXT_TXT: + return "MIME_TEXT_TXT"; + case MIME_TEXT_HTML: + return "MIME_TEXT_HTML"; + case MIME_TEXT_PLAIN: + return "MIME_TEXT_PLAIN"; + case MIME_TEXT_CSS: + return "MIME_TEXT_CSS"; + case MIME_TEXT_XML: + return "MIME_TEXT_XML"; + case MIME_TEXT_IMELODY: + return "MIME_TEXT_IMELODY"; + case MIME_TEXT_CALENDAR: + return "MIME_TEXT_CALENDAR"; + case MIME_TEXT_VND_WAP_WMLSCRIPT: + return "MIME_TEXT_VND_WAP_WMLSCRIPT"; + case MIME_TEXT_VND_WAP_WML: + return "MIME_TEXT_VND_WAP_WML"; + case MIME_TEXT_VND_WAP_WTA_EVENT: + return "MIME_TEXT_VND_WAP_WTA_EVENT"; + case MIME_TEXT_VND_WAP_CONNECTIVITY_XML: + return "MIME_TEXT_VND_WAP_CONNECTIVITY_XML"; + case MIME_TEXT_VND_WAP_SI: + return "MIME_TEXT_VND_WAP_SI"; + case MIME_TEXT_VND_WAP_SL: + return "MIME_TEXT_VND_WAP_SL"; + case MIME_TEXT_VND_WAP_CO: + return "MIME_TEXT_VND_WAP_CO"; + case MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR: + return "MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR"; + case MIME_TEXT_X_HDML: + return "MIME_TEXT_X_HDML"; + case MIME_TEXT_X_VCALENDAR: + return "MIME_TEXT_X_VCALENDAR"; + case MIME_TEXT_X_VCARD: + return "MIME_TEXT_X_VCARD"; + case MIME_TEXT_X_IMELODY: + return "MIME_TEXT_X_IMELODY"; + case MIME_TEXT_X_VTODO: + return "MIME_TEXT_X_VTODO"; + + + case MIME_VIDEO_MPEG4: + return "MIME_VIDEO_MPEG4"; + case MIME_VIDEO_MP4: + return "MIME_VIDEO_MP4"; + case MIME_VIDEO_H263: + return "MIME_VIDEO_H263"; + case MIME_VIDEO_3GPP: + return "MIME_VIDEO_3GPP"; + case MIME_VIDEO_3GP: + return "MIME_VIDEO_3GP"; + case MIME_VIDEO_AVI: + return "MIME_VIDEO_AVI"; + case MIME_VIDEO_SDP: + return "MIME_VIDEO_SDP"; + case MIME_VIDEO_MP4_ES: + return "MIME_VIDEO_MP4_ES"; + case MIME_VIDEO_MPEG: + return "MIME_VIDEO_MPEG"; + case MIME_VIDEO_VND_RN_REALVIDEO: + return "MIME_VIDEO_VND_RN_REALVIDEO"; + case MIME_VIDEO_X_MP4: + return "MIME_VIDEO_X_MP4"; + case MIME_VIDEO_X_PV_MP4: + return "MIME_VIDEO_X_PV_MP4"; + case MIME_VIDEO_X_PN_REALVIDEO: + return "MIME_VIDEO_X_PN_REALVIDEO"; + case MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO: + return "MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO"; + default: + return MmsDebugPrintUnknownValue(mimeType); + } +} + + +/* MsgMmsMsg.h */ +const char *MmsDebugGetMmsReport(MmsReport report) +{ + switch (report) { + case MMS_REPORT_ERROR: + return "MMS_REPORT_ERROR"; + case MMS_REPORT_YES: + return "MMS_REPORT_YES"; + case MMS_REPORT_NO: + return "MMS_REPORT_NO"; + } + + return MmsDebugPrintUnknownValue(report); +} + + +const char *MmsDebugGetMmsReportAllowed(MmsReportAllowed reportAllowed) +{ + switch (reportAllowed) { + case MMS_REPORTALLOWED_ERROR: + return "MMS_REPORTALLOWED_ERROR"; + case MMS_REPORTALLOWED_YES: + return "MMS_REPORTALLOWED_YES"; + case MMS_REPORTALLOWED_NO: + return "MMS_REPORTALLOWED_NO"; + } + + return MmsDebugPrintUnknownValue(reportAllowed); +} + + +const char *MmsDebugGetMmsReadStatus(msg_read_report_status_t readStatus) +{ + _MSG_READ_REPORT_STATUS_E readReport = (_MSG_READ_REPORT_STATUS_E)readStatus; + + switch (readReport) { + case MSG_READ_REPORT_NONE: + return "MMS_READSTATUS_NONE"; + case MSG_READ_REPORT_IS_READ: + return "MMS_IS_READ"; + case MSG_READ_REPORT_IS_DELETED: + return "MMS_IS_DELETED"; + default: + break; + } + + return MmsDebugPrintUnknownValue(readStatus); +} + +const char *MmsDebugGetMsgType(MmsMsgType msgType) +{ + switch (msgType) { + case MMS_MSGTYPE_ERROR: + return "error"; + case MMS_MSGTYPE_SEND_REQ: + return "send.req"; + case MMS_MSGTYPE_SEND_CONF: + return "send.conf"; + case MMS_MSGTYPE_NOTIFICATION_IND: + return "notification.ind"; + case MMS_MSGTYPE_NOTIFYRESP_IND: + return "notifyResp.ind"; + case MMS_MSGTYPE_RETRIEVE_CONF: + return "retrieve conf"; + case MMS_MSGTYPE_ACKNOWLEDGE_IND: + return "acknowledge ind"; + case MMS_MSGTYPE_DELIVERY_IND: + return "delivery ind"; + case MMS_MSGTYPE_READREC_IND: + return "read rec ind"; + case MMS_MSGTYPE_READORG_IND: + return "read org ind"; + case MMS_MSGTYPE_FORWARD_REQ: + return "forward req"; + case MMS_MSGTYPE_FORWARD_CONF: + return "forward conf"; + case MMS_MSGTYPE_READ_REPLY: + return "read reply"; + default: + return MmsDebugPrintUnknownValue(msgType); + } +} + +const char *MmsDebugGetResponseStatus(MmsResponseStatus responseStatus) +{ + switch (responseStatus) { + case MMS_RESPSTATUS_ERROR: + return "error"; + case MMS_RESPSTATUS_OK: + return "ok"; + case MMS_RESPSTAUTS_ERROR_UNSPECIFIED: + return "unspecified"; + case MMS_RESPSTAUTS_ERROR_SERVICEDENIED: + return "service denied"; + case MMS_RESPSTAUTS_ERROR_MESSAGEFORMATCORRUPT: + return "message format corrupt"; + case MMS_RESPSTAUTS_ERROR_SENDINGADDRESSUNRESOLVED: + return "sending address unresolved"; + case MMS_RESPSTAUTS_ERROR_MESSAGENOTFOUND: + return "message not found"; + case MMS_RESPSTAUTS_ERROR_NETWORKPROBLEM: + return "network problem"; + case MMS_RESPSTAUTS_ERROR_CONTENTNOTACCEPTED: + return "content not accepted"; + case MMS_RESPSTAUTS_ERROR_UNSUPPORTEDMESSAGE: + return "unsupported message"; + case MMS_RESPSTAUTS_ERROR_TRANSIENT_FAILURE: + return "transient failure"; + case MMS_RESPSTAUTS_ERROR_TRANSIENT_SENDING_ADDRESS_UNRESOLVED: + return "transient sending address unresolved"; + case MMS_RESPSTAUTS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND: + return "transient message not found"; + case MMS_RESPSTAUTS_ERROR_TRANSIENT_NETWORK_PROBLEM: + return "transient network problem"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_FAILURE: + return "permanent failure"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_SERVICE_DENIED: + return "permanent service denied"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT: + return "permanent message format corrupt"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_SENDING_ADDRESS_UNRESOLVED: + return "permanent sending address unresolved"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_NOT_FOUND: + return "permanent message not found"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED: + return "permanent content not accepted"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_LIMITATIONS_NOT_MET: + return "permanent reply charging limitations not met"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_REQUEST_NOT_ACCEPTED: + return "permanent reply charging request not accepted"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_FORWARDING_DENIED: + return "permanent reply charging forwarding denied"; + case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_NOT_SUPPORTED: + return "permanent reply charging not supported"; + } + + return MmsDebugPrintUnknownValue(responseStatus); +} + + +const char *MmsDebugGetRetrieveStatus(MmsRetrieveStatus retrieveStatus) +{ + switch (retrieveStatus) { + case MMS_RETRSTATUS_ERROR: + return "error"; + case MMS_RETRSTATUS_OK: + return "ok"; + case MMS_RETRSTATUS_TRANSIENT_FAILURE: + return "transient failure"; + case MMS_RETRSTATUS_TRANSIENT_MESSAGE_NOT_FOUND: + return "transient message not found"; + case MMS_RETRSTATUS_TRANSIENT_NETWORK_PROBLEM: + return "transient network problem"; + case MMS_RETRSTATUS_PERMANENT_FAILURE: + return "permanent failure"; + case MMS_RETRSTATUS_PERMANENT_SERVICE_DENIED: + return "permanent service denied"; + case MMS_RETRSTATUS_PERMANENT_MESSAGE_NOT_FOUND: + return "permanent message not found"; + case MMS_RETRSTATUS_PERMANENT_CONTENT_UNSUPPORT: + return "permanent content unsupport"; + } + + return MmsDebugPrintUnknownValue(retrieveStatus); +} + + +const char *MmsDebugGetMsgStatus(msg_delivery_report_status_t msgStatus) +{ + switch (msgStatus) { + case MSG_DELIVERY_REPORT_ERROR: + return "error"; + case MSG_DELIVERY_REPORT_EXPIRED: + return "expired"; + case MSG_DELIVERY_REPORT_SUCCESS: + return "retrieved"; + case MSG_DELIVERY_REPORT_REJECTED: + return "rejected"; + case MSG_DELIVERY_REPORT_DEFERRED: + return "deferred"; + case MSG_DELIVERY_REPORT_UNRECOGNISED: + return "unrecognised"; + case MSG_DELIVERY_REPORT_INDETERMINATE: + return "indeterminate"; + case MSG_DELIVERY_REPORT_FORWARDED: + return "forwarded"; + case MSG_DELIVERY_REPORT_UNREACHABLE: + return "unreachable"; + } + + return MmsDebugPrintUnknownValue(msgStatus); +} + + +const char *MmsDebugGetMsgClass(MmsMsgClass msgClass) +{ + switch (msgClass) { + case MMS_MSGCLASS_ERROR: + return "error"; + case MMS_MSGCLASS_PERSONAL: + return "personal"; + case MMS_MSGCLASS_ADVERTISEMENT: + return "advertisement"; + case MMS_MSGCLASS_INFORMATIONAL: + return "information"; + case MMS_MSGCLASS_AUTO: + return "auto"; + } + + return MmsDebugPrintUnknownValue(msgClass); +} + + +const char *MmsDebugGetDataType(MmsDataType dataType) +{ + switch (dataType) { + case MMS_DATATYPE_NONE: + return "MMS_DATATYPE_NONE"; + case MMS_DATATYPE_READ: + return "MMS_DATATYPE_READ"; + case MMS_DATATYPE_SENT: + return "MMS_DATATYPE_SENT"; + case MMS_DATATYPE_NOTIFY: + return "MMS_DATATYPE_NOTIFY"; + case MMS_DATATYPE_UNSENT: + return "MMS_DATATYPE_UNSENT"; + case MMS_DATATYPE_DRAFT: + return "MMS_DATATYPE_DRAFT"; + case MMS_DATATYPE_SENDING: + return "MMS_DATATYPE_SENDING"; + case MMS_DATATYPE_DRM_RO_WAITING: + return "MMS_DATATYPE_DRM_RO_WAITING"; + case MMS_DATATYPE_RETRIEVING: + return "MMS_DATATYPE_RETRIEVING"; + case MMS_DATATYPE_UNRETV: + return "MMS_DATATYPE_UNRETV"; + default: + return MmsDebugPrintUnknownValue(dataType); + } +} + +bool MmsInitMsgType(MsgType *pMsgType) +{ + MSG_DEBUG("ptr : [%p]", pMsgType); + pMsgType->offset = 0; + pMsgType->size = 0; + pMsgType->contentSize = 0; + pMsgType->disposition = -1; + pMsgType->encoding = -1; + pMsgType->type = MIME_UNKNOWN; + pMsgType->section = -1; + + pMsgType->szOrgFilePath[0] = '\0'; + pMsgType->szContentID[0] = '\0'; + pMsgType->szContentLocation[0] = '\0'; + + MmsInitMsgContentParam(&pMsgType->param); + MmsInitMsgDRMInfo(&pMsgType->drmInfo); + + return true; +} + +bool MmsInitMsgBody(MsgBody *pMsgBody) +{ + MSG_DEBUG("ptr : [%p]", pMsgBody); + pMsgBody->offset = 0; + pMsgBody->size = 0; + pMsgBody->body.pText = NULL; + + MmsInitMsgType(&pMsgBody->presentationType); + pMsgBody->pPresentationBody = NULL; + + memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX + 1); + + return true; +} + +bool MmsInitMsgContentParam(MsgContentParam *pMsgContentParam) +{ + MSG_DEBUG("ptr : [%p]", pMsgContentParam); + pMsgContentParam->charset = MSG_CHARSET_UNKNOWN; + pMsgContentParam->type = MIME_UNKNOWN; + pMsgContentParam->szBoundary[0] = '\0'; + pMsgContentParam->szFileName[0] = '\0'; + pMsgContentParam->szName[0] = '\0'; + pMsgContentParam->szStart[0] = '\0'; + pMsgContentParam->szStartInfo[0] = '\0'; + pMsgContentParam->pPresentation = NULL; + pMsgContentParam->reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; // only used as parameter of Content-Type: multipart/report; report-type +#ifdef FEATURE_JAVA_MMS + pMsgContentParam->szApplicationID = NULL; + pMsgContentParam->szReplyToApplicationID = NULL; +#endif + return true; +} + +bool MmsInitMsgAttrib(MmsAttrib *pAttrib) +{ + MSG_DEBUG("MmsInitMsgAttrib"); + + pAttrib->bAskDeliveryReport = false; + + pAttrib->bAskReadReply = false; + pAttrib->bRead = false; + pAttrib->bReportAllowed = false; + pAttrib->readReportAllowedType = MMS_RECEIVE_READ_REPORT_ALLOWED; + pAttrib->readReportSendStatus = MMS_RECEIVE_READ_REPORT_NO_SEND; + pAttrib->bReadReportSent = false; + + pAttrib->bHideAddress = false; + pAttrib->date = 0; + + pAttrib->deliveryTime.type = MMS_TIMETYPE_RELATIVE; + pAttrib->deliveryTime.time = 0; + + pAttrib->expiryTime.type = MMS_TIMETYPE_RELATIVE; + pAttrib->expiryTime.time = 0; + + memset(&pAttrib->expiryTime, 0, sizeof(MmsTimeStruct)); + pAttrib->msgClass = MMS_MSGCLASS_PERSONAL; + pAttrib->msgStatus = MSG_DELIVERY_REPORT_NONE; + pAttrib->priority = MMS_PRIORITY_NORMAL; + pAttrib->responseStatus = MMS_RESPSTATUS_ERROR; + pAttrib->retrieveStatus = MMS_RETRSTATUS_ERROR; + pAttrib->contentType = MIME_UNKNOWN; + pAttrib->msgSize = 0; + pAttrib->bLeaveCopy = true; + pAttrib->version = MMS_VERSION; + + memset(pAttrib->szFrom, 0, MSG_LOCALE_ADDR_LEN + 10); + memset(pAttrib->szResponseText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1); + memset(pAttrib->szRetrieveText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1); + memset(pAttrib->szSubject, 0, MSG_LOCALE_SUBJ_LEN + 1); + pAttrib->szTo = NULL; + pAttrib->szCc = NULL; + pAttrib->szBcc = NULL; + + pAttrib->pMultiStatus = NULL; + + pAttrib->replyCharge.chargeType = MMS_REPLY_NONE; + memset(&pAttrib->replyCharge.deadLine , 0, sizeof(MmsTimeStruct)); + pAttrib->replyCharge.chargeSize = 0; + memset(pAttrib->replyCharge.szChargeID, 0, MMS_MSG_ID_LEN); + + return true; +} + + +bool MmsInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo) +{ + MSG_DEBUG("ptr : [%p]", pMsgDrmInfo); + pMsgDrmInfo->contentType = MIME_UNKNOWN; + pMsgDrmInfo->drmType = MSG_DRM_TYPE_NONE; + + pMsgDrmInfo->szContentName = NULL; + pMsgDrmInfo->szContentURI = NULL; + pMsgDrmInfo->szContentDescription = NULL; + pMsgDrmInfo->szContentVendor = NULL; + pMsgDrmInfo->szRightIssuer = NULL; + pMsgDrmInfo->szDrm2FullPath = NULL; + pMsgDrmInfo->roWaitingTimerMax = 0; + pMsgDrmInfo->bFwdLock = false; + pMsgDrmInfo->bNoScreen = false; + pMsgDrmInfo->bNoRingTone = false; + pMsgDrmInfo->pszContentType = NULL; + + return true; +} + +void MmsReleaseMsgDRMInfo(MsgDRMInfo *pDrmInfo) +{ + MSG_DEBUG("_MsgFreeDRMInfo: S T A R T !!! \n"); + + if (pDrmInfo == NULL) { + MSG_DEBUG("pDrmInfo is NULL"); + return; + } + + if (pDrmInfo->szContentDescription) { + free(pDrmInfo->szContentDescription); + pDrmInfo->szContentDescription = NULL; + } + + if (pDrmInfo->szContentVendor) { + free(pDrmInfo->szContentVendor); + pDrmInfo->szContentVendor = NULL; + } + + if (pDrmInfo->szContentName) { + free(pDrmInfo->szContentName); + pDrmInfo->szContentName = NULL; + } + + if (pDrmInfo->szContentURI) { + free(pDrmInfo->szContentURI); + pDrmInfo->szContentURI = NULL; + } + + if (pDrmInfo->szRightIssuer) { + free(pDrmInfo->szRightIssuer); + pDrmInfo->szRightIssuer = NULL; + } + + if (pDrmInfo->szDrm2FullPath) { + free(pDrmInfo->szDrm2FullPath); + pDrmInfo->szDrm2FullPath = NULL; + } + + pDrmInfo->contentType = MIME_UNKNOWN; + pDrmInfo->drmType = MSG_DRM_TYPE_NONE; +} + + +bool MmsReleaseMmsAttrib(MmsAttrib *pAttrib) +{ + MSG_BEGIN(); + + if (pAttrib == NULL) { + MSG_DEBUG("pAttrib is NULL"); + return false; + } + + if (pAttrib->szTo) { + free(pAttrib->szTo); + pAttrib->szTo = NULL; + } + + if (pAttrib->szCc) { + free(pAttrib->szCc); + pAttrib->szCc = NULL; + } + + if (pAttrib->szBcc) { + free(pAttrib->szBcc); + pAttrib->szBcc = NULL; + } + + //check if pMultiStatus should be freed or not, because pMultiStatus is not allocated + if (pAttrib->pMultiStatus) { + MmsMsgMultiStatus *pMultiStatus = pAttrib->pMultiStatus; + MmsMsgMultiStatus *pCurStatus = NULL; + + while (pMultiStatus != NULL ) { + pCurStatus = pMultiStatus; + pMultiStatus = pMultiStatus->pNext; + + if (pCurStatus) { + free(pCurStatus); + pCurStatus = NULL; + } + } + + pAttrib->pMultiStatus = NULL; + } + + + MSG_END(); + + return true; +} + +bool MmsReleaseMsgBody(MsgBody *pBody, int type) +{ + MSG_BEGIN(); + + if (pBody == NULL) { + MSG_DEBUG("pBody == NULL \n" ); + MSG_END(); + + return false; + } + + switch (type) { + case MIME_MULTIPART_REPORT: + case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: + case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED: + case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED: + case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC: + case MIME_MULTIPART_MIXED: + case MIME_MULTIPART_RELATED: + case MIME_MULTIPART_ALTERNATIVE: + case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE: + { + MsgMultipart *pMulti = pBody->body.pMultipart; + MsgMultipart *pCurrPart = NULL; + MsgBody *pPresentation = pBody->pPresentationBody; + while (pMulti != NULL) { + pCurrPart = pMulti; + + pMulti = pMulti->pNext; + + if (pCurrPart) { + MmsReleaseMsgDRMInfo(&pCurrPart->type.drmInfo); + + if (pCurrPart->pBody) { + if (pCurrPart->pBody->body.pText) { + free(pCurrPart->pBody->body.pText); + pCurrPart->pBody->body.pText = NULL; + } + + free(pCurrPart->pBody); + pCurrPart->pBody = NULL; + } + free(pCurrPart); + pCurrPart = NULL; + } + } + + pBody->body.pMultipart = NULL; + + if (pPresentation) { + if (pPresentation->body.pText) { + free(pPresentation->body.pText); + pPresentation->body.pText = NULL; + } + free(pPresentation); + pBody->pPresentationBody = NULL; + } + + MmsInitMsgType(&pBody->presentationType); + + break; + } + + default: + /* Any single part */ + if (pBody->body.pText) { + free(pBody->body.pText); + pBody->body.pText = NULL; + } + + break; + } + + MSG_END(); + return true; +} + +void MmsReleaseMmsMsg(MmsMsg *pMmsMsg) +{ + if (pMmsMsg) { + MmsReleaseMsgBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type); + MmsReleaseMmsAttrib(&pMmsMsg->mmsAttrib); + bzero(pMmsMsg, sizeof(MmsMsg)); + } +} + +bool MmsPrintMulitpart(MsgMultipart *pMultipart, int index) +{ + MSG_DEBUG("------------------------------"); + MSG_INFO("[%dth] multipart info", index); + MSG_INFO("header size [%d], body size [%d]", pMultipart->type.size, pMultipart->type.contentSize); + MSG_SEC_INFO("content type [%s]", MmsDebugGetMimeType((MimeType)pMultipart->type.type)); + MSG_SEC_INFO("content ID [%s]", pMultipart->type.szContentID); + MSG_SEC_INFO("content location [%s]", pMultipart->type.szContentLocation); + MSG_SEC_INFO("parameter Name [%s]", pMultipart->type.param.szName); + MSG_SEC_INFO("parameter Filename[%s]", pMultipart->type.param.szFileName); + + if (pMultipart->type.type == MIME_TEXT_PLAIN) { + MSG_SEC_INFO("text info : charset [%d], name [%s]", pMultipart->type.param.charset, pMultipart->type.param.szName); + } + + if (pMultipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { + MSG_INFO("drm info"); + MSG_INFO("drm type [%d] (0: NONE 1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery)", pMultipart->type.drmInfo.drmType); + MSG_SEC_INFO("drm content type [%s]", MmsDebugGetMimeType((MimeType)pMultipart->type.drmInfo.contentType)); + MSG_SEC_INFO("drm content URI [%s]", pMultipart->type.drmInfo.szContentURI); + MSG_INFO("drm2FullPath [%s]", pMultipart->type.drmInfo.szDrm2FullPath); + } + + MSG_DEBUG("------------------------------"); + return true; +} + +bool MmsIsTextType(int type) +{ + if (type == MIME_TEXT_PLAIN + || type == MIME_TEXT_HTML + || type == MIME_TEXT_VND_WAP_WML + || type == MIME_TEXT_X_VNOTE + || type == MIME_APPLICATION_SMIL + || type == MIME_TEXT_X_IMELODY) + { + return true; + } else { + return false; + } +} + +bool MmsIsMultipart(int type) +{ + if (type == MIME_MULTIPART_RELATED + || type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED + || type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED + || type == MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC + || type == MIME_MULTIPART_MIXED + || type == MIME_MULTIPART_REPORT) { + return true; + } else { + return false; + } +} + +bool MmsIsVitemContent(int type, char *pszName) +{ + switch (type) { + case MIME_TEXT_X_VCARD: + case MIME_TEXT_X_VCALENDAR: + case MIME_TEXT_X_VNOTE: // vnt + case MIME_TEXT_X_VTODO: + case MIME_TEXT_PLAIN: // vbm - It SHOULD be distinguished from a normal text file. + { + char *pszExt = NULL; + + if (!pszName) + break; + + // search file extension. + if ((pszExt = strrchr(pszName, '.')) == NULL) + break; + + if (!strcasecmp(pszExt, ".vbm")) { + return true; + } + + if (!strcasecmp(pszExt, ".vcs")) { + return true; + } + + if (!strcasecmp(pszExt, ".vcf")) { + return true; + } + + if (!strcasecmp(pszExt, ".vnt")) { + return true; + } + + if (!strcasecmp(pszExt, ".vts")) { + return true; + } + + break; + } + default: + break; + } + + MSG_DEBUG("MmsIsVitemContent false."); + return false; +} + +MsgMultipart *MmsAllocMultipart(void) +{ + MsgMultipart *pMultipart = NULL; + + pMultipart = (MsgMultipart *)malloc(sizeof(MsgMultipart)); + + if (pMultipart == NULL) + goto __CATCH; + + pMultipart->pBody = (MsgBody *)malloc(sizeof(MsgBody)); + + if (pMultipart->pBody == NULL) + goto __CATCH; + + MmsInitMsgType(&pMultipart->type); + MmsInitMsgBody(pMultipart->pBody); + + pMultipart->pNext = NULL; + + return pMultipart; + +__CATCH: + + if (pMultipart) { + if (pMultipart->pBody) { + free(pMultipart->pBody); + pMultipart->pBody = NULL; + } + + free(pMultipart); + pMultipart = NULL; + } + + return NULL; +} diff --git a/plugin/mms_plugin/MmsPluginComposer.cpp b/plugin/mms_plugin/MmsPluginComposer.cpp new file mode 100755 index 0000000..20f9c49 --- /dev/null +++ b/plugin/mms_plugin/MmsPluginComposer.cpp @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include + +#include "MsgCppTypes.h" +#include "MsgStorageTypes.h" +#include "MsgSettingTypes.h" +#include "MsgUtilFile.h" +#include "MsgGconfWrapper.h" +#include "MsgMmsMessage.h" +#include "MmsPluginTypes.h" +#include "MmsPluginDebug.h" +#include "MmsPluginMessage.h" +#include "MmsPluginMIME.h" +#include "MmsPluginStorage.h" +#include "MmsPluginUtil.h" +#include "MmsPluginTcs.h" +#include "MsgSmil.h" + + +#include "MmsPluginComposer.h" +#include "MsgSerialize.h" + +bool composeSendReqHeader(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_DATA_S *pMsgData); + +MmsPluginComposer *MmsPluginComposer::pInstance = NULL; + +MmsPluginComposer *MmsPluginComposer::instance() +{ + if (!MmsPluginComposer::pInstance) + MmsPluginComposer::pInstance = new MmsPluginComposer(); + + return MmsPluginComposer::pInstance; +} + +MmsPluginComposer::MmsPluginComposer(){} +MmsPluginComposer::~MmsPluginComposer(){} + +void MmsPluginComposer::composeSendReq(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_DATA_S *pMmsData) +{ + + if (pMsgInfo->msgType.subType == MSG_SENDREQ_MMS) { + + if (pMmsData->header == NULL) {//send req from user + pMmsData->header = MsgMmsCreateHeader(); + } + + if (pMmsData->header) { + composeSendReqHeader(pMsgInfo, pSendOptInfo, pMmsData); + //TODO:: apply MmsReplaceNonAsciiUtf8 to all multipart FileName; + } + + int len = g_list_length(pMmsData->multipartlist); + + for (int i = 0; i < len; i++) { + + MMS_MULTIPART_DATA_S *multipart = (MMS_MULTIPART_DATA_S *)g_list_nth_data(pMmsData->multipartlist, i); + + if (multipart) { + if (multipart->type == MIME_UNKNOWN && strlen(multipart->szContentType) == 0) { + const char *content_type = NULL; + MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, multipart->szFileName, &multipart->type, &content_type); + snprintf(multipart->szContentType, sizeof(multipart->szContentType), "%s", content_type); + } + } + } //end for + } +} + +MMSList *getAddressList(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType) +{ + MSG_BEGIN(); + + MMSList * addressList = NULL; + + int nAddressCnt = 0; + + nAddressCnt = pMsgInfo->nAddressCnt; + + // Calculate allocated buffer size + for (int i = 0; i < nAddressCnt; ++i) { + + MSG_SEC_DEBUG("recipientType: %d, address value: %s", pMsgInfo->addressList[i].recipientType, pMsgInfo->addressList[i].addressVal); + + if (pMsgInfo->addressList[i].recipientType == MSG_RECIPIENTS_TYPE_UNKNOWN) + pMsgInfo->addressList[i].recipientType = MSG_RECIPIENTS_TYPE_TO; + + if (pMsgInfo->addressList[i].recipientType == recipientType) { + + MMS_ADDRESS_DATA_S * pAddressData = NULL; + if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_PLMN) { + pAddressData = MsgMmsCreateAddress(MSG_ADDRESS_TYPE_PLMN, pMsgInfo->addressList[i].addressVal); + } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) { + pAddressData = MsgMmsCreateAddress(MSG_ADDRESS_TYPE_EMAIL, pMsgInfo->addressList[i].addressVal); + } else + ; // Need to consider IPV4, IPV6, and Alias formatted address + + if (pAddressData) + addressList = g_list_append(addressList, pAddressData); + } + } + + MSG_END(); + return addressList; +} + +bool composeSendReqHeader(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_DATA_S *pMsgData) +{ + MSG_BEGIN(); + + bool bAskDeliveryReport = false; + bool bAskReadReply = false; + MmsPriority priority; + MmsTimeStruct expiryTime; + MmsTimeStruct deliveryTime; + MmsMsgClass msgClass; + + struct tm timeInfo; + time_t RawTime = 0; + time_t nTimeInSecs = 0; + + MMS_HEADER_DATA_S *pHeaderData = pMsgData->header; + if (pSendOptInfo) { + if (pSendOptInfo->bSetting == false) { + unsigned int settingTime; + + priority = (MmsPriority)MsgSettingGetInt(MMS_SEND_PRIORITY); + + settingTime = (unsigned int)MsgSettingGetInt(MMS_SEND_EXPIRY_TIME); + if (settingTime == 0) { + expiryTime.type = MMS_TIMETYPE_NONE; + expiryTime.time = 0; + } else { + expiryTime.type = MMS_TIMETYPE_RELATIVE; + expiryTime.time = settingTime; + } + + settingTime = (unsigned int)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME); + if (settingTime == 0) { + deliveryTime.type = MMS_TIMETYPE_NONE; + deliveryTime.time = 0; + } else { + deliveryTime.type = MMS_TIMETYPE_RELATIVE; + deliveryTime.time = (unsigned int)settingTime; + } + + MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &bAskDeliveryReport); + MsgSettingGetBool(MMS_SEND_READ_REPLY, &bAskReadReply); + } else { + priority = (MmsPriority)pSendOptInfo->option.mmsSendOptInfo.priority; + + expiryTime.type = pSendOptInfo->option.mmsSendOptInfo.expiryTime.type; + expiryTime.time = pSendOptInfo->option.mmsSendOptInfo.expiryTime.time; + + deliveryTime.type = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.type; + deliveryTime.time = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time; + + bAskDeliveryReport = pSendOptInfo->bDeliverReq; + bAskReadReply = pSendOptInfo->option.mmsSendOptInfo.bReadReq; + } + + msgClass = (MmsMsgClass)MsgSettingGetInt(MMS_SEND_MSG_CLASS); + + //set Header + time(&RawTime); + localtime_r(&RawTime, &timeInfo); + nTimeInSecs = mktime(&timeInfo); + + pHeaderData->date = nTimeInSecs; + + pHeaderData->bDeliveryReport = bAskDeliveryReport; + pHeaderData->delivery.type = deliveryTime.type; + pHeaderData->delivery.time = deliveryTime.time; + + pHeaderData->expiry.type = expiryTime.type; + pHeaderData->expiry.time = expiryTime.time; + + pHeaderData->messageClass = msgClass; + pHeaderData->messageType = MMS_MSGTYPE_SEND_REQ; + pHeaderData->mmsVersion = MMS_VERSION; + pHeaderData->mmsPriority = priority; + pHeaderData->bReadReport = bAskReadReply; + pHeaderData->bHideAddress = false; + } + + if (pMsgData->smil) { + pHeaderData->contentType = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED; + } else { + pHeaderData->contentType = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED; + } + + char *content_type = MimeGetMimeStringFromMimeInt(pHeaderData->contentType); + if (content_type) { + snprintf(pHeaderData->szContentType, sizeof(pHeaderData->szContentType), "%s", content_type); + } + + snprintf(pHeaderData->szSubject, sizeof(pHeaderData->szSubject), "%s", pMsgInfo->subject); + + //setting adddress + pHeaderData->to = getAddressList(pMsgInfo, MSG_RECIPIENTS_TYPE_TO); + pHeaderData->cc = getAddressList(pMsgInfo, MSG_RECIPIENTS_TYPE_CC); + pHeaderData->bcc = getAddressList(pMsgInfo, MSG_RECIPIENTS_TYPE_BCC); + + //snprintf(pHeaderData->szFrom, sizeof(pHeaderData->szFrom), "%s", pMmsMsg->mmsAttrib.szFrom); + + return true; +} diff --git a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp index d45e5b1..bb02aa6 100755 --- a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp +++ b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp @@ -1,223 +1,490 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#include +#include #include "MmsPluginConnManWrapper.h" +#include "MmsPluginDebug.h" +#include "MmsPluginHttp.h" +#include "net_connection.h" +#include "MmsPluginUtil.h" -void network_print_profile(net_profile_info_t *ProfInfo) +#define MMS_CONTEXT_INVOKE_WAIT_TIME 30 +#define MMS_CONNECTION_API_WAIT_TIME 420 + +static Mutex g_mx; +static CndVar g_cv; +static connection_h g_connection = NULL; +static connection_profile_h g_profile = NULL; + +void __connection_profile_print(connection_profile_h profile) { - int di = 0; - - unsigned char *ipaddr; - unsigned char *netmaskaddr; - unsigned char *gwaddr; - net_dev_info_t *net_info; - - if (ProfInfo->profile_type == NET_DEVICE_CELLULAR) { - ipaddr = (unsigned char *)&ProfInfo->ProfileInfo.Pdp.net_info.IpAddr.Data.Ipv4.s_addr; - netmaskaddr = (unsigned char *)&ProfInfo->ProfileInfo.Pdp.net_info.SubnetMask.Data.Ipv4.s_addr; - gwaddr = (unsigned char *)&ProfInfo->ProfileInfo.Pdp.net_info.GatewayAddr.Data.Ipv4.s_addr; - net_info = &(ProfInfo->ProfileInfo.Pdp.net_info); + int ret; + char *profile_id = NULL; + char *profile_name = NULL; + char *interface_name = NULL; + char *ip_address = NULL; + char *subnet_mask = NULL; + char *gateway_address = NULL; + char *dns_address = NULL; + char *proxy_address = NULL; + char *apn = NULL; + char *user_name = NULL; + char *password = NULL; + char *home_url = NULL; + bool is_roaming; + + connection_profile_type_e profile_type; + connection_profile_state_e profile_state; + connection_ip_config_type_e ip_type = CONNECTION_IP_CONFIG_TYPE_NONE; + connection_proxy_type_e proxy_type; + connection_cellular_service_type_e service_type = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN; + connection_cellular_auth_type_e auth_type = CONNECTION_CELLULAR_AUTH_TYPE_NONE; + + MSG_DEBUG("**************************************************************************************************"); + ret = connection_profile_get_id(profile, &profile_id); + MSG_DEBUG("return value of connection_profile_get_id [%d]", ret); + MSG_SEC_INFO("Profile Id = [%s]", profile_id); + + ret = connection_profile_get_name(profile, &profile_name); + MSG_SEC_INFO("Profile Name = [%s]", profile_name); + + ret = connection_profile_get_type(profile, &profile_type); + + if (profile_type == CONNECTION_PROFILE_TYPE_CELLULAR) { + MSG_SEC_INFO("Profile Type = [CELLULAR]"); + } else if (profile_type == CONNECTION_PROFILE_TYPE_WIFI) { + MSG_SEC_INFO("Profile Type = [WIFI]"); + } else if (profile_type == CONNECTION_PROFILE_TYPE_ETHERNET) { + MSG_SEC_INFO("Profile Type = [ETHERNET]"); + } else if (profile_type == CONNECTION_PROFILE_TYPE_BT) { + MSG_SEC_INFO("Profile Type = [BT]"); } else { - MSG_DEBUG("Error!!! Invalid profile type\n"); - return; + MSG_SEC_INFO("Profile Type = Unknown [%d]", profile_type); } - MSG_DEBUG("**************************************************************************************************"); + ret = connection_profile_get_network_interface_name(profile, &interface_name); + MSG_SEC_INFO("Profile Interface Name = [%s]", interface_name); + + ret = connection_profile_get_state(profile, &profile_state); + if (profile_state == CONNECTION_PROFILE_STATE_DISCONNECTED) { + MSG_SEC_INFO("Profile State = [DISCONNECTED]"); + } else if (profile_state == CONNECTION_PROFILE_STATE_ASSOCIATION) { + MSG_SEC_INFO("Profile State = [ASSOCIATION]"); + } else if (profile_state == CONNECTION_PROFILE_STATE_CONFIGURATION) { + MSG_SEC_INFO("Profile State = [CONFIGURATION]"); + } else if (profile_state == CONNECTION_PROFILE_STATE_CONNECTED) { + MSG_SEC_INFO("Profile State = [CONNECTED]"); + } else { + MSG_SEC_INFO("Profile State = Unknown [%d]", profile_state); + } - MSG_DEBUG("Profile Name = [%s]\n", ProfInfo->ProfileName); - - if (ProfInfo->ProfileState == NET_STATE_TYPE_IDLE) - MSG_DEBUG("Profile State = [idle]\n"); - else if (ProfInfo->ProfileState == NET_STATE_TYPE_FAILURE) - MSG_DEBUG("Profile State = [failure]\n"); - else if (ProfInfo->ProfileState == NET_STATE_TYPE_ASSOCIATION) - MSG_DEBUG("Profile State = [association]\n"); - else if (ProfInfo->ProfileState == NET_STATE_TYPE_CONFIGURATION) - MSG_DEBUG("Profile State = [configuration]\n"); - else if (ProfInfo->ProfileState == NET_STATE_TYPE_READY) - MSG_DEBUG("Profile State = [ready]\n"); - else if (ProfInfo->ProfileState == NET_STATE_TYPE_ONLINE) - MSG_DEBUG("Profile State = [online]\n"); - else if (ProfInfo->ProfileState == NET_STATE_TYPE_DISCONNECT) - MSG_DEBUG("Profile State = [disconnect]\n"); - else - MSG_DEBUG("Profile State = [unknown]\n"); + ret = connection_profile_get_ip_config_type(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_type); + MSG_SEC_INFO("Profile Ip Config Type = [%d]", ip_type); - MSG_DEBUG("Profile Type = [pdp]\n"); + ret = connection_profile_get_ip_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_address); + MSG_SEC_INFO("Profile Ip Address = [%s]", ip_address); - if (ProfInfo->ProfileInfo.Pdp.ProtocolType == NET_PDP_TYPE_GPRS) - MSG_DEBUG("Profile Protocol Type = [GPRS]\n"); - else if (ProfInfo->ProfileInfo.Pdp.ProtocolType == NET_PDP_TYPE_EDGE) - MSG_DEBUG("Profile Protocol Type = [EDGE]\n"); - else if (ProfInfo->ProfileInfo.Pdp.ProtocolType == NET_PDP_TYPE_UMTS) - MSG_DEBUG("Profile Protocol Type = [UMTS]\n"); - else - MSG_DEBUG("Profile Protocol Type = [NONE]\n"); + ret = connection_profile_get_subnet_mask(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &subnet_mask); + MSG_SEC_INFO("Profile Subnet Mask = [%s]", subnet_mask); - MSG_DEBUG("Profile APN = [%s]\n", ProfInfo->ProfileInfo.Pdp.Apn); + ret = connection_profile_get_gateway_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &gateway_address); + MSG_SEC_INFO("Profile Gateway Address = [%s]", gateway_address); - if (ProfInfo->ProfileInfo.Pdp.AuthInfo.AuthType == NET_PDP_AUTH_PAP) - MSG_DEBUG("Profile Auth Type = [PAP]\n"); - else if (ProfInfo->ProfileInfo.Pdp.AuthInfo.AuthType == NET_PDP_AUTH_CHAP) - MSG_DEBUG("Profile Auth Type = [CHAP]\n"); - else - MSG_DEBUG("Profile Auth Type = [NONE]\n"); - - MSG_DEBUG("Profile Auth UserName = [%s]\n", ProfInfo->ProfileInfo.Pdp.AuthInfo.UserName); - MSG_DEBUG("Profile Auth Password = [%s]\n", ProfInfo->ProfileInfo.Pdp.AuthInfo.Password); - MSG_DEBUG("Profile Home URL = [%s]\n", ProfInfo->ProfileInfo.Pdp.HomeURL); - MSG_DEBUG("Profile MCC = [%s]\n", ProfInfo->ProfileInfo.Pdp.Mcc); - MSG_DEBUG("Profile MNC = [%s]\n", ProfInfo->ProfileInfo.Pdp.Mnc); - MSG_DEBUG("Profile Roaming = [%d]\n", (int)ProfInfo->ProfileInfo.Pdp.Roaming); - MSG_DEBUG("Profile Setup Required = [%d]\n", (int)ProfInfo->ProfileInfo.Pdp.SetupRequired); - MSG_DEBUG("Profile Favourite = [%d]\n", (int)ProfInfo->Favourite); - MSG_DEBUG("Profile Device Name = [%s]\n", net_info->DevName); - MSG_DEBUG("Profile DNS Count = [%d]\n", net_info->DnsCount); - for (di = 0; di < net_info->DnsCount; di++) { - unsigned char *dns = (unsigned char *)&net_info->DnsAddr[di].Data.Ipv4.s_addr; - MSG_DEBUG("Profile DNS Address %d = [%d.%d.%d.%d]\n", di+1, dns[0], dns[1], dns[2], dns[3]); + ret = connection_profile_get_dns_address(profile, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &dns_address); + MSG_SEC_INFO("Profile Dns Address = [%s]", dns_address); + + ret = connection_profile_get_proxy_type(profile, &proxy_type); + MSG_SEC_INFO("Profile Proxy Type = [%d]", proxy_type); + + ret = connection_profile_get_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_address); + MSG_SEC_INFO("Profile Proxy Address = [%s]", proxy_address); + + ret = connection_profile_get_cellular_service_type(profile, &service_type); + if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET) { + MSG_SEC_INFO("Profile Service Type = [INTERNET]"); + } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_MMS) { + MSG_SEC_INFO("Profile Service Type = [MMS]"); + } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET) { + MSG_SEC_INFO("Profile Service Type = [PREPAID_INTERNET]"); + } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS) { + MSG_SEC_INFO("Profile Service Type = [PREPAID_MMS]"); + } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING) { + MSG_SEC_INFO("Profile Service Type = [TETHERING]"); + } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION) { + MSG_SEC_INFO("Profile Service Type = [APPLICATION]"); + } else { + MSG_SEC_INFO("Profile Service Type = [Unknown][%d]", service_type); } - if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_DYNAMIC) - MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_DYNAMIC]\n"); - else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC) - MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_STATIC]\n"); - else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_FIXED) - MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_FIXED]\n"); - else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_OFF) - MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_OFF]\n"); + ret = connection_profile_get_cellular_apn(profile, &apn); + MSG_SEC_INFO("Profile Apn = [%s]", apn); + + ret = connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password); + MSG_SEC_INFO("Profile Auth Type = [%d]", &auth_type); + MSG_SEC_INFO("Profile Auth Name = [%s]", &user_name); + MSG_SEC_INFO("Profile Auth Passward = [%s]", &password); + + ret = connection_profile_get_cellular_home_url(profile, &home_url); + MSG_SEC_INFO("Profile Home Url = [%s]", home_url); + + ret = connection_profile_is_cellular_roaming(profile, &is_roaming); + MSG_SEC_INFO("Profile Roaming = [%d]", is_roaming); + MSG_DEBUG("**************************************************************************************************"); + + MSG_FREE(profile_id); + MSG_FREE(profile_name); + MSG_FREE(interface_name); + MSG_FREE(ip_address); + MSG_FREE(subnet_mask); + MSG_FREE(gateway_address); + MSG_FREE(dns_address); + MSG_FREE(proxy_address); + MSG_FREE(apn); + MSG_FREE(user_name); + MSG_FREE(password); + MSG_FREE(home_url); +} + +static void __connection_type_changed_cb(connection_type_e type, void* user_data) +{ + MSG_INFO("Type changed callback, connection type : %d", type); +} + +static void __connection_ip_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data) +{ + MSG_INFO("IP changed callback, IPv4 address : %s, IPv6 address : %s", + ipv4_address, (ipv6_address ? ipv6_address : "NULL")); +} + +static void __connection_proxy_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data) +{ + MSG_INFO("Proxy changed callback, IPv4 address : %s, IPv6 address : %s", + ipv4_address, (ipv6_address ? ipv6_address : "NULL")); +} + +static void __connection_profile_opened_cb(connection_error_e result, void* user_data) +{ + if (result == CONNECTION_ERROR_NONE || result == CONNECTION_ERROR_ALREADY_EXISTS) + MSG_INFO("Connection open Succeeded [%d]", result); else - MSG_DEBUG("Profile IPv4 Method = [UNKNOWN]\n"); - - MSG_DEBUG("Profile IP Address = [%d.%d.%d.%d]\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]); - MSG_DEBUG("Profile Netmask = [%d.%d.%d.%d]\n", netmaskaddr[0], netmaskaddr[1], netmaskaddr[2], netmaskaddr[3]); - MSG_DEBUG("Profile Gateway = [%d.%d.%d.%d]\n", gwaddr[0], gwaddr[1], gwaddr[2], gwaddr[3]); - - if (net_info->ProxyMethod == NET_PROXY_TYPE_DIRECT) - MSG_DEBUG("Proxy Method = [direct]\n"); - else if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO) - MSG_DEBUG("Proxy Method = [auto]\n"); - else if (net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL) - MSG_DEBUG("Proxy Method = [manual]\n"); + MSG_ERR("Connection open Failed, err : %d", result); + + MmsPluginCmAgent *cmAgent = MmsPluginCmAgent::instance(); + + cmAgent->connection_profile_open_callback(result, user_data); +} + +static void __connection_profile_closed_cb(connection_error_e result, void* user_data) +{ + if (result == CONNECTION_ERROR_NONE) + MSG_INFO("Connection close Succeeded"); else - MSG_DEBUG("Proxy Method = [unknown]\n"); + MSG_ERR("Connection close Failed, err : %d", result); - MSG_DEBUG("Profile Proxy = [%s]\n", net_info->ProxyAddr); + MmsPluginCmAgent *cmAgent = MmsPluginCmAgent::instance(); - MSG_DEBUG("**************************************************************************************************"); + cmAgent->connection_profile_close_callback(result, user_data); } +void __connection_profile_state_changed_cb(connection_profile_state_e state, void* user_data) +{ + MmsPluginCmAgent *cmAgent = MmsPluginCmAgent::instance(); + + cmAgent->connection_profile_state_changed_cb(state, user_data); + +} -void network_evt_cb (net_event_info_t *event_cb, void *user_data) +static gboolean __connection_create(void *pVoid) { MSG_BEGIN(); - MmsPluginCmAgent::instance()->processCBdatas(event_cb, user_data); + bool ret = false; + bool *ret_val = (bool *)pVoid; + + if (g_connection) { + MSG_INFO("connection already exist"); + ret = true; + } else { + int err = connection_create(&g_connection); + + if (CONNECTION_ERROR_NONE == err) { + + connection_cellular_state_e cellular_state; + connection_type_e net_state; + + err = connection_get_cellular_state(g_connection, &cellular_state); + + err = connection_get_type(g_connection, &net_state); + + if (cellular_state == CONNECTION_CELLULAR_STATE_AVAILABLE + || cellular_state == CONNECTION_CELLULAR_STATE_CONNECTED) { + + MSG_INFO("Client registration success [%p], cellular_state [%d], net_state [%d]", g_connection, cellular_state, net_state); + + err = connection_set_type_changed_cb(g_connection, __connection_type_changed_cb, NULL); + + err = connection_set_ip_address_changed_cb(g_connection, __connection_ip_changed_cb, NULL); + + err = connection_set_proxy_address_changed_cb(g_connection, __connection_proxy_changed_cb, NULL); + + ret = true; + } else { + + MSG_INFO("Client registration Failed, cellular state [%d], net_state [%d]", cellular_state, net_state); + connection_destroy(g_connection); + g_connection = NULL; + } + + } else { + MSG_WARN("Client registration failed %d", err); + } + } + + if (ret_val) { + *ret_val = ret; + } MSG_END(); + return FALSE; } +static gboolean __connection_destroy(void *pVoid) +{ + MSG_BEGIN(); -MmsPluginCmAgent *MmsPluginCmAgent::pInstance = NULL; + int rv; -MmsPluginCmAgent *MmsPluginCmAgent::instance() + if (g_connection != NULL) { + rv = connection_destroy(g_connection); + g_connection = NULL; + MSG_INFO("connection destory !!"); + } else { + MSG_ERR("Cannot connection destroy : Handle is NULL"); + rv = CONNECTION_ERROR_INVALID_OPERATION; + } + + MSG_DEBUG("return value of connection destroy [%d]", rv); + + MSG_END(); + return FALSE; +} + +static gboolean __connection_profile_open(void *pVoid) { - if (!pInstance) - pInstance = new MmsPluginCmAgent(); + MSG_BEGIN(); - return pInstance; + int netOpenResult = MSG_CM_ERR_NONE; + int *ret_val = (int *)pVoid; + int err; + + if (g_profile) { + MSG_WARN("connection profile Already exist!!, It will destroy"); + connection_profile_unset_state_changed_cb(g_profile); + connection_profile_destroy(g_profile); + g_profile = NULL; + } + + err = connection_get_default_cellular_service_profile(g_connection, CONNECTION_CELLULAR_SERVICE_TYPE_MMS, &g_profile); + + if (err != CONNECTION_ERROR_NONE) { + MSG_ERR("connection_get_default_cellular_service_profile Failed!! [%d]", err); + netOpenResult = MSG_CM_ERR_UNKNOWN; + } else { + + err = connection_profile_set_state_changed_cb(g_profile, __connection_profile_state_changed_cb, g_profile); + + if (connection_open_profile(g_connection, g_profile, __connection_profile_opened_cb, NULL) != CONNECTION_ERROR_NONE) { + MSG_ERR("Connection open Failed!!"); + netOpenResult = MSG_CM_ERR_UNKNOWN; + } + + + } + + if (ret_val) { + *ret_val = netOpenResult; + MSG_DEBUG("[%d]", netOpenResult); + } + + MSG_END(); + + return FALSE; } -MmsPluginCmAgent::MmsPluginCmAgent() +static gboolean __connection_profile_close(void *pVoid) { MSG_BEGIN(); - isCmOpened = false; - bzero(&mmsProfile, sizeof (net_profile_info_t)); + int netOpenResult = MSG_CM_ERR_NONE; + + int *ret_val = (int *)pVoid; + + if (g_profile) { + connection_profile_unset_state_changed_cb(g_profile); + + if (connection_close_profile(g_connection, g_profile, __connection_profile_closed_cb, NULL) != CONNECTION_ERROR_NONE) { + MSG_ERR("Connection close Failed!!"); + netOpenResult = MSG_CM_ERR_UNKNOWN; + } + + connection_profile_destroy(g_profile); + g_profile = NULL; + } + + if (ret_val) { + *ret_val = netOpenResult; + } MSG_END(); + + return FALSE; } -MmsPluginCmAgent::~MmsPluginCmAgent() + +void context_invoke_end_cb(gpointer data) { + g_mx.lock(); + MSG_INFO("@@ SIGNAL @@"); + + g_cv.signal(); + + g_mx.unlock(); } -bool MmsPluginCmAgent::registration() +/* + * Network api should run at g_main_loop to receive callback + * */ +void context_invoke(GSourceFunc func, void *ret) { MSG_BEGIN(); - bool registResult = true; + int time_ret = 0; - if (net_register_client((net_event_cb_t) network_evt_cb, NULL) != NET_ERR_NONE) { - MSG_DEBUG("Error!! net_register_client() failed.\n"); - registResult = false; + g_mx.lock(); + + g_main_context_invoke_full(NULL, G_PRIORITY_DEFAULT, func, ret, context_invoke_end_cb); + + MSG_INFO("@@ WAIT @@"); + + time_ret = g_cv.timedwait(g_mx.pMutex(), MMS_CONTEXT_INVOKE_WAIT_TIME); + + g_mx.unlock(); + + if (time_ret == ETIMEDOUT) { + MSG_INFO("@@ WAKE by timeout@@"); + } else { + MSG_INFO("@@ WAKE by signal@@"); } MSG_END(); +} - return registResult; +MmsPluginCmAgent *MmsPluginCmAgent::pInstance = NULL; + +MmsPluginCmAgent *MmsPluginCmAgent::instance() +{ + if (!pInstance) + pInstance = new MmsPluginCmAgent(); + + return pInstance; +} + +MmsPluginCmAgent::MmsPluginCmAgent() +{ + MSG_BEGIN(); + + isCmOpened = false; + waitProfileOpen = false; + + home_url = NULL; + interface_name = NULL; + proxy_address = NULL; + MSG_END(); +} + +MmsPluginCmAgent::~MmsPluginCmAgent() +{ + MSG_FREE(home_url); + MSG_FREE(interface_name); + MSG_FREE(proxy_address); } bool MmsPluginCmAgent::open() { MSG_BEGIN(); - if (!isCmOpened) { - if (!registration()) - return false; + int netOpenResult = MSG_CM_ERR_NONE; + int bConnection = false; + int time_ret = 0; + lock(); - int netOpenResult = NET_ERR_NONE; - net_service_type_t service_type = NET_SERVICE_MMS; + //create connection + context_invoke(__connection_create, &bConnection); - netOpenResult = net_open_connection_with_preference(service_type); - if (netOpenResult != NET_ERR_NONE) { - MSG_DEBUG("Error!! net_open_connection_with_profile() failed. [%d]", netOpenResult); - deregistration(); - return false; - } + if (bConnection == false || g_connection == NULL) { + MSG_ERR("Failed __connection_create"); + goto __ERR_RETURN; + } - MSG_DEBUG("WAITING UNTIL Network Connection Open."); + if (g_profile) { + MSG_WARN("connection profile already exist"); + //TODO:: get data; + //goto __RETURN; + } - lock(); + waitProfileOpen = true; - int time_ret = 0; - time_ret = cv.timedwait(mx.pMutex(), 50); + context_invoke(__connection_profile_open, &netOpenResult); - unlock(); + if (netOpenResult != MSG_CM_ERR_NONE) { + MSG_ERR("Failed __connection_profile_open. [%d]", netOpenResult); + goto __ERR_RETURN; + } - if (time_ret == ETIMEDOUT) { - MSG_DEBUG("Network Connection Open Time Out."); - deregistration(); - return false; - } else { - if(!isCmOpened) { - MSG_DEBUG("Network connection open failed"); - deregistration(); - return false; - } - } + MSG_INFO("## WAITING UNTIL __connection_profile_state CONNECT. ##"); + +// cv.wait(mx.pMutex()); +// MSG_INFO("## WAKE by SIGNAL ##"); + + time_ret = cv.timedwait(mx.pMutex(), MMS_CONNECTION_API_WAIT_TIME); // isCmOpened will changed by processCBdatas + + if (time_ret == ETIMEDOUT) { + MSG_WARN("## WAKE by timeout ##"); } else { - MSG_DEBUG("Network is already opened."); - return false; + MSG_INFO("## WAKE by SIGNAL ##"); } + if(isCmOpened == false) { + MSG_WARN(""); + goto __ERR_RETURN; + } + +//__RETURN: + unlock(); MSG_END(); + return isCmOpened; +__ERR_RETURN: + context_invoke(__connection_profile_close, NULL); + context_invoke( __connection_destroy, NULL); + unlock(); + MSG_END(); return isCmOpened; } @@ -226,222 +493,255 @@ void MmsPluginCmAgent::close() { MSG_BEGIN(); - if (isCmOpened) { - int netOpenResult = NET_ERR_NONE; + lock(); - netOpenResult = net_close_connection(mmsProfile.ProfileName); - if (netOpenResult != NET_ERR_NONE) { - MSG_DEBUG("Error!! net_close_connection() failed.\n"); - deregistration(); - return; - } + int netOpenResult = MSG_CM_ERR_NONE; + int time_ret = 0; - MSG_DEBUG("WAITING UNTIL Network Connection Close."); + isCmOpened = false; - lock(); + if (g_profile == NULL) { + MSG_INFO("connection profile is NULL"); + goto __RETURN; + } - int time_ret = 0; - time_ret = cv.timedwait(mx.pMutex(), 50); + context_invoke(__connection_profile_close, &netOpenResult); - unlock(); + if (netOpenResult != MSG_CM_ERR_NONE) { + MSG_ERR("Failed __connection_profile_close. [%d]", netOpenResult); + goto __RETURN; + } - if (time_ret == ETIMEDOUT) { - MSG_DEBUG("Network Connection Close Timed Out."); - } + MSG_INFO("## WAITING UNTIL connection_profile_close_callback ##"); + + time_ret = cv.timedwait(mx.pMutex(), MMS_CONNECTION_API_WAIT_TIME); - deregistration(); + if (time_ret == ETIMEDOUT) { + MSG_WARN("## WAKE by timeout ##"); } else { - MSG_DEBUG ("Network Connection is not opened."); - return; + MSG_INFO("## WAKE by SIGNAL ##"); } -} -void MmsPluginCmAgent::deregistration() -{ - MSG_BEGIN(); +__RETURN: + if (g_connection) + context_invoke(__connection_destroy, NULL); - int netOpenResult = NET_ERR_NONE; + g_profile = NULL; + g_connection = NULL; - netOpenResult = net_deregister_client(); - if (netOpenResult != NET_ERR_NONE) - MSG_DEBUG("Error!! net_deregister_client() failed. [%d]", netOpenResult); - else - MSG_DEBUG ("net_deregister_client() Success."); + MSG_FREE(this->home_url); + MSG_FREE(this->interface_name); + MSG_FREE(this->proxy_address); + + unlock(); MSG_END(); } - -void MmsPluginCmAgent::processCBdatas(net_event_info_t *event_cb, void *user_data) +//profile open callback +void MmsPluginCmAgent::connection_profile_open_callback(connection_error_e result, void* user_data) { - MSG_BEGIN(); + lock(); - net_dev_info_t *dev_info = NULL; - net_profile_info_t *prof_info = NULL; - - switch (event_cb->Event) { - case NET_EVENT_NET_CONFIGURE_RSP: - MSG_DEBUG("Received Network Configuration response: %d \n", event_cb->Error); - dev_info = (net_dev_info_t *)event_cb->Data; - - /*Successful PDP Activation*/ - if (event_cb->Error == NET_ERR_NONE) { - char *ip = (char *)&dev_info->IpAddr.Data.Ipv4; - char *netmask = (char *)&dev_info->SubnetMask.Data.Ipv4; - char *gateway = (char *)&dev_info->GatewayAddr.Data.Ipv4; - char *dns1 = (char *)&dev_info->DnsAddr[0].Data.Ipv4.s_addr; - char *dns2 = (char *)&dev_info->DnsAddr[1].Data.Ipv4.s_addr; - - MSG_DEBUG("= IP address [%d.%d.%d.%d]\n", - (int)ip[0], ip[1], ip[2], ip[3]); - MSG_DEBUG("= Netmask [%d.%d.%d.%d]\n", - (int)netmask[0], netmask[1], netmask[2], netmask[3]); - MSG_DEBUG("= Gateway [%d.%d.%d.%d]\n", - (int)gateway[0], gateway[1], gateway[2], gateway[3]); - MSG_DEBUG("= DNS address [%d.%d.%d.%d]\n", - (int)dns1[0], dns1[1], dns1[2], dns1[3]); - MSG_DEBUG("= DNS2 address [%d.%d.%d.%d]\n", - (int)dns2[0], dns2[1], dns2[2], dns2[3]); - MSG_DEBUG("= Device name [%s]\n", dev_info->DevName); - MSG_DEBUG("= Profile name [%s]\n", dev_info->ProfileName); - } else { - MSG_DEBUG("Error!!! Network Configuration Failed %d \n", event_cb->Error); + connection_cellular_state_e state; + connection_profile_h profile = NULL; + connection_profile_state_e profile_state; + int err = CONNECTION_ERROR_NONE; + + if (result == CONNECTION_ERROR_NONE || result == CONNECTION_ERROR_ALREADY_EXISTS) { + + err = connection_get_cellular_state(g_connection, &state); + + MSG_INFO("connection_get_cellular_state ret [%d], state [%d]", err, state); + + err = connection_get_default_cellular_service_profile(g_connection, CONNECTION_CELLULAR_SERVICE_TYPE_MMS, &profile); + if (err != CONNECTION_ERROR_NONE || profile == NULL) { + + MSG_ERR("Failed connection_get_default_cellular_service_profile. err [%d], profile [%p]", err, profile); + goto __SIGNAL_RETURN; } - break; - /*Response from Datacom for PDP Activation Request*/ - case NET_EVENT_OPEN_IND: - MSG_DEBUG("Got Open Indication\n"); - MSG_DEBUG("Received ACTIVATION response: %d \n", event_cb->Error); - break; - case NET_EVENT_OPEN_RSP: - MSG_DEBUG("Got Open RSP\n"); - MSG_DEBUG("Received ACTIVATION response: %d \n", event_cb->Error); - prof_info = (net_profile_info_t *)event_cb->Data; + err = connection_profile_get_state(profile, &profile_state); + + MSG_DEBUG("profile state [%d]", profile_state); + + if (profile_state == CONNECTION_PROFILE_STATE_CONNECTED && waitProfileOpen == true) { - /*Successful PDP Activation*/ - if (event_cb->Error == NET_ERR_NONE || event_cb->Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) { - network_print_profile(prof_info); + __connection_profile_print(profile); - lock(); + MSG_FREE(this->home_url); + MSG_FREE(this->interface_name); + MSG_FREE(this->proxy_address); + + err = connection_profile_get_cellular_home_url(profile, &this->home_url); + if (err != CONNECTION_ERROR_NONE) { + MSG_ERR("Failed connection_profile_get_cellular_home_url"); + } + + err = connection_profile_get_network_interface_name(profile, &this->interface_name); + if (err != CONNECTION_ERROR_NONE) { + MSG_ERR("Failed connection_profile_get_cellular_home_url"); + } + + err = connection_profile_get_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &this->proxy_address); + if (err != CONNECTION_ERROR_NONE) { + MSG_ERR("Failed connection_profile_get_cellular_home_url"); + } - memcpy(&mmsProfile, prof_info, sizeof(net_profile_info_t)); isCmOpened = true; - signal(); - unlock(); + goto __SIGNAL_RETURN; //open success + } else { - MSG_DEBUG("Activation Failed %d \n", event_cb->Error); // open failed - lock(); - isCmOpened = false; - signal(); - unlock(); + goto __NO_SIGNAL_RETURN; //Just open success } - break; - - case NET_EVENT_CLOSE_RSP: - MSG_DEBUG("Got Close RSP\n"); - lock(); - - bzero(&mmsProfile, sizeof(net_profile_info_t)); + } else { + MSG_ERR("connection open profile Failed!! [%d]", result); isCmOpened = false; - signal(); + goto __SIGNAL_RETURN; - unlock(); - break; - - case NET_EVENT_CLOSE_IND: - MSG_DEBUG("Got Close IND\n"); - break; - case NET_EVENT_PROFILE_MODIFY_IND: - MSG_DEBUG("Received Profile modified Indication\n"); - MSG_DEBUG("No. of profile [%d]\n", event_cb->Datalength); - break; - case NET_EVENT_NET_STATE_IND: - MSG_DEBUG("Received NET_EVENT_NET_STATE_IND\n"); - break; - default : - MSG_DEBUG("Error! Unknown Event = %d\n\n", event_cb->Event); - break; } - MSG_END(); +__NO_SIGNAL_RETURN: //Just Open + if (profile) + connection_profile_destroy(profile); + unlock(); + return; + +__SIGNAL_RETURN: //Error or Already connected + if (profile) + connection_profile_destroy(profile); + + if (waitProfileOpen == true) {//open fail + waitProfileOpen = false; + MSG_INFO("## SIGNAL ##"); + signal(); + } + unlock(); + return; } -bool MmsPluginCmAgent::getDeviceName(char *deviceName) +void MmsPluginCmAgent::connection_profile_close_callback(connection_error_e result, void* user_data) { - if (!isCmOpened) - return false; + lock(); + MSG_INFO("result [%d]", result); + MSG_INFO("## SIGNAL ##"); + signal(); + + unlock(); +} + +void MmsPluginCmAgent::connection_profile_state_changed_cb(connection_profile_state_e state, void* user_data) +{ + MSG_BEGIN(); + + lock(); - int deviceNameLength = strlen(mmsProfile.ProfileInfo.Pdp.net_info.DevName); + int err; + connection_profile_h profile = NULL; - if (deviceNameLength > 0) { - strncpy(deviceName, mmsProfile.ProfileInfo.Pdp.net_info.DevName, deviceNameLength); - deviceName[deviceNameLength] = '\0'; - return true; + MSG_INFO("state [%d]", state); + + if (state != CONNECTION_PROFILE_STATE_CONNECTED) { + isCmOpened = false; + goto __NO_SIGNAL_RETURN; } - return false; -} + if (isCmOpened == true) { + MSG_INFO("already opened"); + goto __SIGNAL_RETURN; + } + /* Should get profile to get latest profile info*/ + err = connection_get_default_cellular_service_profile(g_connection, CONNECTION_CELLULAR_SERVICE_TYPE_MMS, &profile); + if (err != CONNECTION_ERROR_NONE || profile == NULL) { -bool MmsPluginCmAgent::getHomeURL(char *homeURL) -{ - if (!isCmOpened) - return false; + MSG_ERR("Failed connection_get_default_cellular_service_profile. err [%d], profile [%p]", err, profile); + goto __SIGNAL_RETURN; + } + + if (state == CONNECTION_PROFILE_STATE_CONNECTED ) { + __connection_profile_print(profile); + + MSG_FREE(this->home_url); + MSG_FREE(this->interface_name); + MSG_FREE(this->proxy_address); + + err = connection_profile_get_cellular_home_url(profile, &this->home_url); + if (err != CONNECTION_ERROR_NONE) { + MSG_ERR("Failed connection_profile_get_cellular_home_url"); + } - int homeURLLength = strlen(mmsProfile.ProfileInfo.Pdp.HomeURL); + err = connection_profile_get_network_interface_name(profile, &this->interface_name); + if (err != CONNECTION_ERROR_NONE) { + MSG_ERR("Failed connection_profile_get_cellular_home_url"); + } + + err = connection_profile_get_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &this->proxy_address); + if (err != CONNECTION_ERROR_NONE) { + MSG_ERR("Failed connection_profile_get_cellular_home_url"); + } - if (homeURLLength > 0) { - strncpy(homeURL, mmsProfile.ProfileInfo.Pdp.HomeURL, homeURLLength); - homeURL[homeURLLength] = '\0'; - return true; + isCmOpened = true; + goto __SIGNAL_RETURN; } - return false; -} +__NO_SIGNAL_RETURN://Default + unlock(); + return; +__SIGNAL_RETURN: //Error or connected + if (profile) + connection_profile_destroy(profile); + + if (waitProfileOpen == true) { + waitProfileOpen = false; + MSG_INFO("## SIGNAL ##"); + signal(); + } + unlock(); + return; +} -bool MmsPluginCmAgent::getProxyAddr(char *proxyAddr) +bool MmsPluginCmAgent::getInterfaceName(const char **deviceName) { if (!isCmOpened) return false; - int proxyAddrLength = strlen(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr); + if (deviceName == NULL) + return false; - if (proxyAddrLength > 0) { - if (strchr(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, ':') == NULL) - return false; + *deviceName = interface_name; - proxyAddrLength = proxyAddrLength - strlen(strchr(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, ':')); - strncpy(proxyAddr, mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, proxyAddrLength); - proxyAddr[proxyAddrLength] = '\0'; + return true; +} - return true; - } +bool MmsPluginCmAgent::getHomeUrl(const char **homeURL) +{ + if (!isCmOpened) + return false; - return false; + if (homeURL == NULL) + return false; + + *homeURL = home_url; + + return true; } -int MmsPluginCmAgent::getProxyPort() +bool MmsPluginCmAgent::getProxyAddr(const char **proxyAddr) { if (!isCmOpened) - return -1; + return false; - int proxyAddrLength = strlen(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr); + if (proxyAddr == NULL) + return false; - if (proxyAddrLength > 0) { - char *pPort = strchr(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, ':') + 1; - if (pPort) - return atoi(pPort); - else - return -1; - } + *proxyAddr = proxy_address; - return -1; + return true; } - diff --git a/plugin/mms_plugin/MmsPluginContentCodec.cpp b/plugin/mms_plugin/MmsPluginContentCodec.cpp deleted file mode 100755 index b372ecf..0000000 --- a/plugin/mms_plugin/MmsPluginContentCodec.cpp +++ /dev/null @@ -1,1068 +0,0 @@ -/* -* 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 -#include -#include "MsgDebug.h" -#include "MmsPluginCodec.h" -#include "MmsPluginCodec.h" -#include "MmsPluginMIME.h" -#include "MmsPluginMessage.h" -#include "MmsPluginWmLngPack.h" - -const int MSG_MAX_CH_PER_LINE = 75; - -/* ================================================================== - * Decode/Encode inline base64 string - * - * base64 : 3*8bit -> 4*6bit & convert the value into A~Z, a~z, 0~9, +, or / - * pad(=) is needed when the end of the string is < 24bit. - * - * Value Encoding Value Encoding Value Encoding Value Encoding - * 0 A 17 R 34 i 51 z - * 1 B 18 S 35 j 52 '0' - * 2 C 19 T 36 k 53 1 - * 3 D 20 U 37 l 54 2 - * 4 E 21 V 38 m 55 3 - * 5 F 22 W 39 n 56 4 - * 6 G 23 X 40 o 57 5 - * 7 H 24 Y 41 p 58 6 - * 8 I 25 Z 42 q 59 7 - * 9 J 26 a 43 r 60 8 - * 10 K 27 b 44 s 61 9 - * 11 L 28 c 45 t 62 + - * 12 M 29 d 46 u 63 / - * 13 N 30 e 47 v - * 14 O 31 f 48 w (pad) = - * 15 P 32 g 49 x - * 16 Q 33 h 50 y - * - * (1) the final quantum = 24 bits : no "=" padding, - * (2) the final quantum = 8 bits : two "=" + two characters - * (3) the final quantum = 16 bits : one "=" + three characters - * ================================================================== */ - -bool _MsgEncodeBase64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret) -{ - unsigned char *d = NULL; - unsigned char *s = (unsigned char *)pSrc; - - char *v = (char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - unsigned long i = ((srcLen + 2) / 3) * 4; - - i += 2 * ((i / 60) + 1); - *len = i; - - if (ret == NULL) { - MSG_DEBUG("_MsgEncodeBase64: ret Memory Alloc Fail \n"); - return false; - } - memset(ret, 0, i); - - d = ret; - - /* Convert 3*8bit into 4*6bit */ - for (i = 0; srcLen > 0; s += 3) { - *d++ = v[s[0] >> 2]; // byte 1: high 6 bits of character-1 - *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f]; // byte 2: low 2 bits of character-1 and high 4 bits of character-2 - *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '='; // byte 3: low 4 bits of charcter-2 and high 2 bits of character-3 - *d++ = srcLen ? v[s[2] & 0x3f] : '='; // byte 4: low 6 bits of character-3 - - if (srcLen) - srcLen--; - - /* Insert CRLF at every 60 characters */ - if ((++i) == 15) { - i = 0; - *d++ = '\015'; - *d++ = '\012'; - } - } - - if (i == 15) { - *d++ = '\015'; - *d++ = '\012'; - } - *d = '\0'; - - if (((unsigned long)(d - ret)) != *len) { - *len = d - ret; - MSG_DEBUG("base64 encoding length = %d \n", *len); - } - - return true; -} - - -void *_MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *len) -{ - char c; - void *ret = NULL; - char *d = NULL; - short e = 0; - - ret = malloc((size_t)(*len = 4 + ((srcLen * 3) / 4))); - d = (char *)ret; - - if (ret == NULL) { - MSG_DEBUG("_MsgDecodeBase64: ret malloc Fail \n"); - return NULL; - } - - memset(ret, 0, (size_t)*len); - *len = 0; - - while (srcLen-- > 0) { - c = *pSrc++; - - /* Convert base64 character into original value */ - - if (isupper(c)) - c -= 'A'; - else if (islower(c)) - c -= 'a' - 26; - else if (isdigit(c)) - c -= '0' - 52; - else if (c == '+') - c = 62; - else if (c == '/') - c = 63; - else if (c == '=') { - switch (e++) { - case 2: - if (*pSrc != '=') { - *len = d - (char *)ret; - return ret; - } - break; - case 3: - e = 0; - break; - default: - *len = d - (char *)ret; - return ret; - } - continue; - } else - continue; // Actually, never get here - - /* Pad 4*6bit character into 3*8bit character */ - - switch (e++) { - case 0: - *d = c << 2; // byte 1: high 6 bits - break; - - case 1: - *d++ |= c >> 4; // byte 1: low 2 bits - *d = c << 4; // byte 2: high 4 bits - break; - - case 2: - *d++ |= c >> 2; // byte 2: low 4 bits - *d = c << 6; // byte 3: high 2 bits - break; - - case 3: - *d++ |= c; // byte 3: low 6 bits - e = 0; // Calculate next unit. - break; - - default: - MSG_DEBUG("_MsgDecodeBase64: Unknown paremeter\n"); - break; - } - } - - *len = d - (char *)ret; // Calculate the size of decoded string. - - return ret; -} - - - -/* ========================================== - * Decode/Encode inline base64 string - * - * quoted-printable := ([*(ptext / SPACE / TAB) ptext] ["="] CRLF) - * ; Maximum line length of 76 characters excluding CRLF - * - * ptext := octet / 127, =, SPACE, or TAB. - * - * ==========================================*/ - -bool _MsgEncodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret) -{ - unsigned long lp = 0; - unsigned char *d = ret; - char *hex = (char *)"0123456789ABCDEF"; - unsigned char c; - - if (ret == NULL) { - MSG_DEBUG("_MsgEncodeQuotePrintable: ret malloc Fail \n"); - return false; - } - - d = ret; - - /* - * The type of srcLen is unsigned long - * The value of srcLen is decreased by 1 -> We can't check by "srcLen > 0". - */ - while (srcLen-- > 0) { - /* Just copy CRLF */ - if (((c = *pSrc++) == '\015') && (*pSrc == '\012') && srcLen) { - *d++ = '\015'; - *d++ = *pSrc++; - srcLen--; - lp = 0; - } else { - if (iscntrl(c) || (c == 0x7f) || (c & 0x80) || (c == '=') || ((c == ' ') && (*pSrc == '\015'))) { - if ((lp += 3) > (unsigned long)MSG_MAX_CH_PER_LINE) { - *d++ = '='; - *d++ = '\015'; - *d++ = '\012'; - lp = 3; - } - - *d++ = '='; /* quote character */ - *d++ = hex[c >> 4]; /* high order 4 bits */ - *d++ = hex[c & 0xf]; /* low order 4 bits */ - } else { - /* Just copy ASCII character */ - if ((++lp) > (unsigned long)MSG_MAX_CH_PER_LINE) { - *d++ = '='; - *d++ = '\015'; - *d++ = '\012'; - lp = 1; - } - *d++ = c; - } - } - } - - *d = '\0'; - *len = d - ret; - - return true; -} - - -unsigned char *_MsgDecodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len) -{ - unsigned char *ret = NULL; - unsigned char *d = NULL; - unsigned char *s = NULL; /* last non-blank */ - unsigned char c; - unsigned char e; - - d = s = ret = (unsigned char *)malloc((size_t)srcLen + 1); - if (ret == NULL) { - MSG_DEBUG("_MsgDecodeQuotePrintable: ret malloc Fail \n"); - return NULL; - } - - *len = 0; - pSrc[srcLen] = '\0'; - - while ((c = *pSrc++)!= '\0') { - switch (c) { - case '=': /* octet characters (> 127, =, SPACE, or TAB) */ - switch (c = *pSrc++) { - case '\0': /* end of string -> postpone to while */ - break; - - case '\015': /* CRLF */ - if (*pSrc == '\012') - pSrc++; - break; - - default: /* two hexes */ - if (!isxdigit(c)) { - *d = '\0'; - *len = d - ret; - return ret; - } - - if (isdigit(c)) - e = c - '0'; - else - e = c - (isupper(c) ? 'A' - 10 : 'a' - 10); - - c = *pSrc++; - if (!isxdigit(c)) { - *d = '\0'; - *len = d - ret; - return ret; - } - - if (isdigit(c)) - c -= '0'; - else - c -= (isupper(c) ? 'A' - 10 : 'a' - 10); - - *d++ = c + (e << 4); - s = d; - break; - } - break; - - case ' ': /* skip the blank */ - *d++ = c; - break; - - case '\015': /* Line Feedback : to last non-blank character */ - d = s; - break; - - default: - *d++ = c; /* ASCII character */ - s = d; - break; - } - } - - *d = '\0'; - *len = d - ret; - - return ret; -} - - -/* ======================================== - * Decode/Encode inline base64 string - * Inline base64 has no "\r\n" in it, - * and has charset and encoding sign in it - * ======================================== */ -bool _MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret) -{ - unsigned char *d = NULL; - unsigned char *s = (unsigned char *)pSrc; - char *v = (char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - unsigned long i = ((srcLen + 2) / 3) * 4; - - i += 2 * ((i / 60) + 1); - *len = i; - - if (ret == NULL) { - MSG_DEBUG("_MsgEncode2Base64: ret Memory Alloc Fail \n"); - return false; - } - memset(ret, 0, i); - - d = ret; - - /* Convert 3*8bit into 4*6bit */ - for (i = 0; srcLen > 0; s += 3) { - *d++ = v[s[0] >> 2]; // byte 1: high 6 bits of character-1 - *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f]; // byte 2: low 2 bits of character-1 and high 4 bits of character-2 - *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '='; // byte 3: low 4 bits of charcter-2 and high 2 bits of character-3 - *d++ = srcLen ? v[s[2] & 0x3f] : '='; // byte 4: low 6 bits of character-3 - - if (srcLen) - srcLen--; - } - - *d = '\0'; - - if (((unsigned long)(d - ret)) != *len) { - *len = d - ret; - MSG_DEBUG("base64 encoding length = %d \n", *len); - } - - return true; -} - - -char *_MsgDecodeText(char *pOri) -{ - MSG_BEGIN(); - - int size = 0; - int cnt = 0; - char *pSrc = NULL; - char *pTemp = NULL; - char *pRe = NULL; - char *pStrEnd = NULL; - char *pDecStart = NULL; - char *pDecEnd = NULL; - char *pDecQ = NULL; - 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}; - - // copy original string - if (strlen(pOri) >= MSG_LOCAL_TEMP_BUF_SIZE) { - pSrc = MsgStrCopy( pOri ); - } else { - memset(szTempBuf, 0, MSG_LOCAL_TEMP_BUF_SIZE); - strcpy(szTempBuf, pOri); - - pSrc = szTempBuf; - } - - // it can be one or more encoding methods in a line - while (1) { - cnt++; - - bEncoding = false; - - /* - (ex) "=?euc-kr?B?Y2NqMjEyMw==?=" - - pDecStart: charset (=?euc-kr?B?Y2NqMjEyMw==?=) - pDecQ : Encoding type (B?Y2NqMjEyMw==?=) - pDecQ2 : Encoded text (Y2NqMjEyMw==?=) - pDecEnd : Encoded of text (?=) - */ - if (pSrc == NULL) - goto __CATCH; - - if (((pDecStart = strstr(pSrc, MSG_STR_DEC_START)) != NULL) //"=?" - && ((pDecQ = strchr(pDecStart + 2, MSG_CH_QUESTION)) != NULL) // '?' - && ((pDecQ2 = strchr(pDecQ + 1, MSG_CH_QUESTION))!= NULL) // '?' - && ((pDecEnd = strstr(pDecQ2 + 1, MSG_STR_DEC_END))!= NULL)) { //"=?" - bEncoding = true; - - /* charset problem - * pDecStart ~ pDecQ : charSet & MSG_CHARSET_USC2 ~ MSG_CHARSET_UTF8 & LATIN - */ - - *pDecQ = '\0'; - nCharset = _MsgGetCode(MSG_CHARSET, pDecStart + 2); - *pDecQ = MSG_CH_QUESTION; - } - - // End of encoding - if (!bEncoding) - goto __RETURN; - - // find end of string - pStrEnd = pSrc + strlen(pSrc); - - // Decoding - if ((*(pDecQ2 - 1) == MSG_CH_BASE64_UPPER) || - (*(pDecQ2 - 1) == MSG_CH_BASE64_LOWER) || - (*(pDecQ + 1) == MSG_CH_BASE64_UPPER) || - (*(pDecQ + 1) == MSG_CH_BASE64_LOWER)) { - pTemp = (char *)_MsgDecodeBase64((UCHAR *)(pDecQ2 + 1), (ULONG)(pDecEnd - pDecQ2 - 1), (ULONG *)&size); - - if (pTemp != NULL) { - pTemp[size] = MSG_CH_NULL; - - if(pRe) { - free(pRe); - pRe = NULL; - } - - pRe = (char *)malloc((pDecStart-pSrc) + size + (pStrEnd - (pDecEnd + 2)) + 1); - if (pRe == NULL) { - MSG_DEBUG("_MsgDecodeText: pRemalloc fail \n"); - free(pTemp); - pTemp = NULL; - - goto __RETURN; - } - - memcpy(pRe, pSrc, pDecStart - pSrc); - memcpy(&pRe[pDecStart-pSrc], pTemp, size); - memcpy(&pRe[(pDecStart - pSrc) + size], pDecEnd + 2, pStrEnd - (pDecEnd + 2)); - pRe[(pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2))] = MSG_CH_NULL; - - free(pTemp); - pTemp = NULL; - - if (pSrc != NULL && pSrc != szTempBuf) { - free(pSrc); - pSrc = NULL; - } - } - } else if ((*(pDecQ2-1) == MSG_CH_QPRINT_UPPER) || - (*(pDecQ2-1) == MSG_CH_QPRINT_LOWER) || - (*(pDecQ+1) == MSG_CH_QPRINT_UPPER) || - (*(pDecQ+1) == MSG_CH_QPRINT_LOWER)) { - - pTemp = (char *)_MsgDecodeQuotePrintable((UCHAR *)( pDecQ2 + 1 ), (ULONG)(pDecEnd - pDecQ2 - 1), (ULONG *)&size); - - if (pTemp != NULL) { - int i; - pTemp[size] = MSG_CH_NULL; - - for (i = 0; i < size; i++) { - if (pTemp[i] == MSG_CH_UNDERLINE) { - pTemp[i] = MSG_CH_SP; // change '_' to ' ' - } - } - - if(pRe) { - free(pRe); - pRe = NULL; - } - - pRe = (char *)malloc((pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2)) + 1); - if (pRe == NULL) { - MSG_DEBUG("_MsgDecodeText: pRemalloc fail \n"); - free(pTemp); - pTemp = NULL; - - goto __RETURN; - } - - memcpy(pRe, pSrc, pDecStart - pSrc); - memcpy(&pRe[pDecStart - pSrc], pTemp, size); - memcpy(&pRe[(pDecStart - pSrc) + size], pDecEnd + 2, pStrEnd - (pDecEnd + 2)); - pRe[(pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2))] = MSG_CH_NULL; - - if (pTemp) { - free(pTemp); - pTemp = NULL; - } - - if (pSrc != NULL && pSrc != szTempBuf) { - free(pSrc); - pSrc = NULL; - } - } - } else { - goto __RETURN; - } - } - -__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); - - if (nChar == 0) { - nChar = 2; - } - - // Re check char-set - if (MsgIsUTF8String((unsigned char *)pTemp, nTemp)) { - 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: 2. Memory Full !!! \n"); - goto __CATCH; - } - - memcpy(mszTempStr, ((unsigned short *)pTemp), nChar * sizeof(unsigned short)); - - nByte = MsgGetUnicode2UTFCodeSize(((unsigned short *)pTemp), nChar); - - pConvertedStr = (char *)malloc(nByte + 1); - if (pConvertedStr) { - MsgUnicode2UTF ((unsigned char *)pConvertedStr, nByte + 1, mszTempStr, nChar); - } - } - } - - 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); - } - - pTemp = pConvertedStr; - nTemp = nByte; - - break; - } - - pReturnStr = (char *)malloc(nTemp + 1); - if (pReturnStr == NULL) { - goto __CATCH; - } - memset(pReturnStr, 0, nTemp + 1); - - if (pTemp) - memcpy(pReturnStr, pTemp, nTemp); - - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; - } - - if (mszTempStr) { - free(mszTempStr); - mszTempStr = NULL; - } - - if(pRe) { - free(pRe); - pRe = NULL; - } - - if (pSrc != NULL && pSrc != szTempBuf) { - free(pSrc); - pSrc = NULL; - } - - return pReturnStr; - -__CATCH: - - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; - } - - if (mszTempStr) { - free(mszTempStr); - mszTempStr = NULL; - } - - if(pRe) { - free(pRe); - pRe = NULL; - } - - if (pSrc != NULL && pSrc != szTempBuf) { - free(pSrc); - pSrc = NULL; - } - - return NULL; -} - - -char *MsgEncodeText(char *pOri) -{ - ULONG nLen = 0; - char *szBuff = NULL; - int length = 0; - - length = (strlen(pOri) * 4) / 3 + 2 + 12 + 1 + 30; - szBuff = (char *)malloc(length + 1); - - if (szBuff == NULL) { - // error handling - MSG_DEBUG("_MsgEncodeText: szBuff alloc is failed \n"); - goto __CATCH; - } - - memset(szBuff, 0 , length + 1); - - snprintf(szBuff, length+1, "%s%s%c%c%c", MSG_STR_DEC_START, "utf-8", MSG_CH_QUESTION, MSG_CH_BASE64_LOWER, MSG_CH_QUESTION); - - if (_MsgEncode2Base64((unsigned char *)pOri, strlen(pOri), &nLen, (unsigned char *)szBuff + 10) == false) { - MSG_DEBUG("_MsgEncodeText: MsgEncodeBase64() is failed \n"); - goto __CATCH; - } - - strcat(szBuff, MSG_STR_DEC_END); - - return szBuff; - -__CATCH: - if (szBuff) { - free(szBuff); - } - - return false; -} - diff --git a/plugin/mms_plugin/MmsPluginDebug.cpp b/plugin/mms_plugin/MmsPluginDebug.cpp deleted file mode 100755 index c27fd33..0000000 --- a/plugin/mms_plugin/MmsPluginDebug.cpp +++ /dev/null @@ -1,1365 +0,0 @@ -/* -* 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 -#include "MmsPluginMIME.h" -#include "MmsPluginMessage.h" - -static char gszDebugStringBuf[50]; - -static char *MmsDebugPrintUnknownValue(int value) -{ - printf(gszDebugStringBuf, "unknown value(%d)", value); - return gszDebugStringBuf; -} - - -const char *MmsDebugGetMimeType(MimeType mimeType) -{ - switch (mimeType) { - case MIME_APPLICATION_XML: - return "MIME_APPLICATION_XML"; - case MIME_APPLICATION_WML_XML: - return "MIME_APPLICATION_WML_XML"; - case MIME_APPLICATION_XHTML_XML: - return "MIME_APPLICATION_XHTML_XML"; - case MIME_APPLICATION_JAVA_VM: - return "MIME_APPLICATION_JAVA_VM"; - case MIME_APPLICATION_SMIL: - return "MIME_APPLICATION_SMIL"; - case MIME_APPLICATION_JAVA_ARCHIVE: - return "MIME_APPLICATION_JAVA_ARCHIVE"; - case MIME_APPLICATION_JAVA: - return "MIME_APPLICATION_JAVA"; - case MIME_APPLICATION_OCTET_STREAM: - return "MIME_APPLICATION_OCTET_STREAM"; - case MIME_APPLICATION_STUDIOM: - return "MIME_APPLICATION_STUDIOM"; - case MIME_APPLICATION_FUNMEDIA: - return "MIME_APPLICATION_FUNMEDIA"; - case MIME_APPLICATION_MSWORD: - return "MIME_APPLICATION_MSWORD"; - case MIME_APPLICATION_PDF: - return "MIME_APPLICATION_PDF"; - case MIME_APPLICATION_ASTERIC: - return "MIME_APPLICATION_ASTERIC"; - case MIME_APPLICATION_VND_WAP_XHTMLXML: - return "MIME_APPLICATION_VND_WAP_XHTMLXML"; - case MIME_APPLICATION_VND_WAP_WMLC: - return "MIME_APPLICATION_VND_WAP_WMLC"; - case MIME_APPLICATION_VND_WAP_WMLSCRIPTC: - return "MIME_APPLICATION_VND_WAP_WMLSCRIPTC"; - case MIME_APPLICATION_VND_WAP_WTA_EVENTC: - return "MIME_APPLICATION_VND_WAP_WTA_EVENTC"; - case MIME_APPLICATION_VND_WAP_UAPROF: - return "MIME_APPLICATION_VND_WAP_UAPROF"; - case MIME_APPLICATION_VND_WAP_SIC: - return "MIME_APPLICATION_VND_WAP_SIC"; - case MIME_APPLICATION_VND_WAP_SLC: - return "MIME_APPLICATION_VND_WAP_SLC"; - case MIME_APPLICATION_VND_WAP_COC: - return "MIME_APPLICATION_VND_WAP_COC"; - case MIME_APPLICATION_VND_WAP_SIA: - return "MIME_APPLICATION_VND_WAP_SIA"; - case MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML: - return "MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML"; - case MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA: - return "MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA"; - case MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES: - return "MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES"; - case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED: - return "MIME_APPLICATION_VND_WAP_MULTIPART_MIXED"; - case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED: - return "MIME_APPLICATION_VND_WAP_MULTIPART_RELATED"; - case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE: - return "MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE"; - case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC: - return "MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC"; - case MIME_APPLICATION_VND_OMA_DD_XML: - return "MIME_APPLICATION_VND_OMA_DD_XML"; - case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: - return "MIME_APPLICATION_VND_OMA_DRM_MESSAGE"; - case MIME_APPLICATION_VND_OMA_DRM_CONTENT: - return "MIME_APPLICATION_VND_OMA_DRM_CONTENT"; - case MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML: - return "MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML"; - case MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML: - return "MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML"; - case MIME_APPLICATION_VND_SMAF: - return "MIME_APPLICATION_VND_SMAF"; - case MIME_APPLICATION_VND_RN_REALMEDIA: - 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_EXCEL: - return "MIME_APPLICATION_VND_EXCEL"; - case MIME_APPLICATION_X_HDMLC: - return "MIME_APPLICATION_X_HDMLC"; - case MIME_APPLICATION_X_X968_USERCERT: - return "MIME_APPLICATION_X_X968_USERCERT"; - case MIME_APPLICATION_X_WWW_FORM_URLENCODED: - return "MIME_APPLICATION_X_WWW_FORM_URLENCODED"; - case MIME_APPLICATION_X_SMAF: - return "MIME_APPLICATION_X_SMAF"; - case MIME_APPLICATION_X_FLASH: - return "MIME_APPLICATION_X_FLASH"; - case MIME_APPLICATION_X_EXCEL: - return "MIME_APPLICATION_X_EXCEL"; - case MIME_APPLICATION_X_POWERPOINT: - return "MIME_APPLICATION_X_POWERPOINT"; - - case MIME_AUDIO_BASIC: - return "MIME_AUDIO_BASIC"; - case MIME_AUDIO_MPEG: - return "MIME_AUDIO_MPEG"; - case MIME_AUDIO_MP3: - return "MIME_AUDIO_MP3"; - case MIME_AUDIO_MPG3: - return "MIME_AUDIO_MPG3"; - case MIME_AUDIO_MPEG3: - return "MIME_AUDIO_MPEG3"; - case MIME_AUDIO_MPG: - return "MIME_AUDIO_MPG"; - case MIME_AUDIO_AAC: - return "MIME_AUDIO_AAC"; - case MIME_AUDIO_G72: - return "MIME_AUDIO_G72"; - case MIME_AUDIO_AMR: - return "MIME_AUDIO_AMR"; - case MIME_AUDIO_AMR_WB: - return "MIME_AUDIO_AMR_WB"; - case MIME_AUDIO_MMF: - return "MIME_AUDIO_MMF"; - case MIME_AUDIO_SMAF: - return "MIME_AUDIO_SMAF"; - case MIME_AUDIO_IMELODY: - return "MIME_AUDIO_IMELODY"; - case MIME_AUDIO_MELODY: - return "MIME_AUDIO_MELODY"; - case MIME_AUDIO_MID: - return "MIME_AUDIO_MID"; - case MIME_AUDIO_MIDI: - return "MIME_AUDIO_MIDI"; - case MIME_AUDIO_X_MID: - return "MIME_AUDIO_X_MID"; - case MIME_AUDIO_SP_MIDI: - return "MIME_AUDIO_SP_MIDI"; - case MIME_AUDIO_WAVE: - return "MIME_AUDIO_WAVE"; - case MIME_AUDIO_3GPP: - return "MIME_AUDIO_3GPP"; - case MIME_AUDIO_MP4: - return "MIME_AUDIO_MP4"; - case MIME_AUDIO_MP4A_LATM: - return "MIME_AUDIO_MP4A_LATM"; - case MIME_AUDIO_VND_RN_REALAUDIO: - return "MIME_AUDIO_VND_RN_REALAUDIO"; - case MIME_AUDIO_X_MPEG: - return "MIME_AUDIO_X_MPEG"; - case MIME_AUDIO_X_MP3: - return "MIME_AUDIO_X_MP3"; - case MIME_AUDIO_X_MPEG3: - return "MIME_AUDIO_X_MPEG3"; - case MIME_AUDIO_X_MPG: - return "MIME_AUDIO_X_MPG"; - case MIME_AUDIO_X_AMR: - return "MIME_AUDIO_X_AMR"; - case MIME_AUDIO_X_MMF: - return "MIME_AUDIO_X_MMF"; - case MIME_AUDIO_X_SMAF: - return "MIME_AUDIO_X_SMAF"; - case MIME_AUDIO_X_IMELODY: - return "MIME_AUDIO_X_IMELODY"; - case MIME_AUDIO_X_MIDI: - return "MIME_AUDIO_X_MIDI"; - case MIME_AUDIO_X_MPEGAUDIO: - return "MIME_AUDIO_X_MPEGAUDIO"; - case MIME_AUDIO_X_PN_REALAUDIO: - return "MIME_AUDIO_X_PN_REALAUDIO"; - case MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO: - return "MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO"; - case MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE: - return "MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE"; - case MIME_AUDIO_X_WAV: - return "MIME_AUDIO_X_WAV"; - - case MIME_IMAGE_GIF: - return "MIME_IMAGE_GIF"; - case MIME_IMAGE_JPEG: - return "MIME_IMAGE_JPEG"; - case MIME_IMAGE_JPG: - return "MIME_IMAGE_JPG"; - case MIME_IMAGE_TIFF: - return "MIME_IMAGE_TIFF"; - case MIME_IMAGE_TIF: - return "MIME_IMAGE_TIF"; - case MIME_IMAGE_PNG: - return "MIME_IMAGE_PNG"; - case MIME_IMAGE_WBMP: - return "MIME_IMAGE_WBMP"; - case MIME_IMAGE_PJPEG: - return "MIME_IMAGE_PJPEG"; - case MIME_IMAGE_BMP: - return "MIME_IMAGE_BMP"; - case MIME_IMAGE_SVG: - return "MIME_IMAGE_SVG"; - case MIME_IMAGE_SVG1: - return "MIME_IMAGE_SVG1"; - case MIME_IMAGE_VND_WAP_WBMP: - return "MIME_IMAGE_VND_WAP_WBMP"; - - case MIME_IMAGE_X_BMP: - return "MIME_IMAGE_X_BMP"; - - case MIME_MESSAGE_RFC822: - return "MIME_MESSAGE_RFC822"; - - case MIME_MULTIPART_MIXED: - return "MIME_MULTIPART_MIXED"; - case MIME_MULTIPART_RELATED: - return "MIME_MULTIPART_RELATED"; - case MIME_MULTIPART_ALTERNATIVE: - return "MIME_MULTIPART_ALTERNATIVE"; - case MIME_MULTIPART_FORM_DATA: - return "MIME_MULTIPART_FORM_DATA"; - case MIME_MULTIPART_BYTERANGE: - return "MIME_MULTIPART_BYTERANGE"; - case MIME_MULTIPART_REPORT: - return "MIME_MULTIPART_REPORT"; - - case MIME_TEXT_TXT: - return "MIME_TEXT_TXT"; - case MIME_TEXT_HTML: - return "MIME_TEXT_HTML"; - case MIME_TEXT_PLAIN: - return "MIME_TEXT_PLAIN"; - case MIME_TEXT_CSS: - return "MIME_TEXT_CSS"; - case MIME_TEXT_XML: - return "MIME_TEXT_XML"; - case MIME_TEXT_IMELODY: - return "MIME_TEXT_IMELODY"; - case MIME_TEXT_VND_WAP_WMLSCRIPT: - return "MIME_TEXT_VND_WAP_WMLSCRIPT"; - case MIME_TEXT_VND_WAP_WML: - return "MIME_TEXT_VND_WAP_WML"; - case MIME_TEXT_VND_WAP_WTA_EVENT: - return "MIME_TEXT_VND_WAP_WTA_EVENT"; - case MIME_TEXT_VND_WAP_CONNECTIVITY_XML: - return "MIME_TEXT_VND_WAP_CONNECTIVITY_XML"; - case MIME_TEXT_VND_WAP_SI: - return "MIME_TEXT_VND_WAP_SI"; - case MIME_TEXT_VND_WAP_SL: - return "MIME_TEXT_VND_WAP_SL"; - case MIME_TEXT_VND_WAP_CO: - return "MIME_TEXT_VND_WAP_CO"; - case MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR: - return "MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR"; - case MIME_TEXT_X_HDML: - return "MIME_TEXT_X_HDML"; - case MIME_TEXT_X_VCALENDAR: - return "MIME_TEXT_X_VCALENDAR"; - case MIME_TEXT_X_VCARD: - return "MIME_TEXT_X_VCARD"; - case MIME_TEXT_X_IMELODY: - return "MIME_TEXT_X_IMELODY"; - - case MIME_VIDEO_MPEG4: - return "MIME_VIDEO_MPEG4"; - case MIME_VIDEO_MP4: - return "MIME_VIDEO_MP4"; - case MIME_VIDEO_H263: - return "MIME_VIDEO_H263"; - case MIME_VIDEO_3GPP: - return "MIME_VIDEO_3GPP"; - case MIME_VIDEO_3GP: - return "MIME_VIDEO_3GP"; - case MIME_VIDEO_AVI: - return "MIME_VIDEO_AVI"; - case MIME_VIDEO_SDP: - return "MIME_VIDEO_SDP"; - case MIME_VIDEO_VND_RN_REALVIDEO: - return "MIME_VIDEO_VND_RN_REALVIDEO"; - case MIME_VIDEO_X_MP4: - return "MIME_VIDEO_X_MP4"; - case MIME_VIDEO_X_PV_MP4: - return "MIME_VIDEO_X_PV_MP4"; - case MIME_VIDEO_X_PN_REALVIDEO: - return "MIME_VIDEO_X_PN_REALVIDEO"; - case MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO: - return "MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO"; - default: - return MmsDebugPrintUnknownValue(mimeType); - } -} - - -/* MsgMmsMsg.h */ -const char *MmsDebugGetMmsReport(MmsReport report) -{ - switch (report) { - case MMS_REPORT_ERROR: - return "MMS_REPORT_ERROR"; - case MMS_REPORT_YES: - return "MMS_REPORT_YES"; - case MMS_REPORT_NO: - return "MMS_REPORT_NO"; - } - - return MmsDebugPrintUnknownValue(report); -} - - -const char *MmsDebugGetMmsReportAllowed(MmsReportAllowed reportAllowed) -{ - switch (reportAllowed) { - case MMS_REPORTALLOWED_ERROR: - return "MMS_REPORTALLOWED_ERROR"; - case MMS_REPORTALLOWED_YES: - return "MMS_REPORTALLOWED_YES"; - case MMS_REPORTALLOWED_NO: - return "MMS_REPORTALLOWED_NO"; - } - - return MmsDebugPrintUnknownValue(reportAllowed); -} - - -const char *MmsDebugGetMmsReadStatus(msg_read_report_status_t readStatus) -{ - _MSG_READ_REPORT_STATUS_E readReport = (_MSG_READ_REPORT_STATUS_E)readStatus; - - switch (readReport) { - case MSG_READ_REPORT_NONE: - return "MMS_READSTATUS_NONE"; - case MSG_READ_REPORT_IS_READ: - return "MMS_IS_READ"; - case MSG_READ_REPORT_IS_DELETED: - return "MMS_IS_DELETED"; - } - - return MmsDebugPrintUnknownValue(readStatus); -} - -const char *MmsDebugGetMsgType(MmsMsgType msgType) -{ - switch (msgType) { - case MMS_MSGTYPE_ERROR: - return "error"; - case MMS_MSGTYPE_SEND_REQ: - return "send.req"; - case MMS_MSGTYPE_SEND_CONF: - return "send.conf"; - case MMS_MSGTYPE_NOTIFICATION_IND: - return "notification.ind"; - case MMS_MSGTYPE_NOTIFYRESP_IND: - return "notifyResp.ind"; - case MMS_MSGTYPE_RETRIEVE_CONF: - return "retrieve conf"; - case MMS_MSGTYPE_ACKNOWLEDGE_IND: - return "acknowledge ind"; - case MMS_MSGTYPE_DELIVERY_IND: - return "delivery ind"; - case MMS_MSGTYPE_READREC_IND: - return "read rec ind"; - case MMS_MSGTYPE_READORG_IND: - return "read org ind"; - case MMS_MSGTYPE_FORWARD_REQ: - return "forward req"; - case MMS_MSGTYPE_FORWARD_CONF: - return "forward conf"; - case MMS_MSGTYPE_READ_REPLY: - return "read reply"; - default: - return MmsDebugPrintUnknownValue(msgType); - } -} - -const char *MmsDebugGetResponseStatus(MmsResponseStatus responseStatus) -{ - switch (responseStatus) { - case MMS_RESPSTATUS_ERROR: - return "error"; - case MMS_RESPSTATUS_OK: - return "ok"; - case MMS_RESPSTAUTS_ERROR_UNSPECIFIED: - return "unspecified"; - case MMS_RESPSTAUTS_ERROR_SERVICEDENIED: - return "service denied"; - case MMS_RESPSTAUTS_ERROR_MESSAGEFORMATCORRUPT: - return "message format corrupt"; - case MMS_RESPSTAUTS_ERROR_SENDINGADDRESSUNRESOLVED: - return "sending address unresolved"; - case MMS_RESPSTAUTS_ERROR_MESSAGENOTFOUND: - return "message not found"; - case MMS_RESPSTAUTS_ERROR_NETWORKPROBLEM: - return "network problem"; - case MMS_RESPSTAUTS_ERROR_CONTENTNOTACCEPTED: - return "content not accepted"; - case MMS_RESPSTAUTS_ERROR_UNSUPPORTEDMESSAGE: - return "unsupported message"; - case MMS_RESPSTAUTS_ERROR_TRANSIENT_FAILURE: - return "transient failure"; - case MMS_RESPSTAUTS_ERROR_TRANSIENT_SENDING_ADDRESS_UNRESOLVED: - return "transient sending address unresolved"; - case MMS_RESPSTAUTS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND: - return "transient message not found"; - case MMS_RESPSTAUTS_ERROR_TRANSIENT_NETWORK_PROBLEM: - return "transient network problem"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_FAILURE: - return "permanent failure"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_SERVICE_DENIED: - return "permanent service denied"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT: - return "permanent message format corrupt"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_SENDING_ADDRESS_UNRESOLVED: - return "permanent sending address unresolved"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_NOT_FOUND: - return "permanent message not found"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED: - return "permanent content not accepted"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_LIMITATIONS_NOT_MET: - return "permanent reply charging limitations not met"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_REQUEST_NOT_ACCEPTED: - return "permanent reply charging request not accepted"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_FORWARDING_DENIED: - return "permanent reply charging forwarding denied"; - case MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_NOT_SUPPORTED: - return "permanent reply charging not supported"; - } - - return MmsDebugPrintUnknownValue(responseStatus); -} - - -const char *MmsDebugGetRetrieveStatus(MmsRetrieveStatus retrieveStatus) -{ - switch (retrieveStatus) { - case MMS_RETRSTATUS_ERROR: - return "error"; - case MMS_RETRSTATUS_OK: - return "ok"; - case MMS_RETRSTATUS_TRANSIENT_FAILURE: - return "transient failure"; - case MMS_RETRSTATUS_TRANSIENT_MESSAGE_NOT_FOUND: - return "transient message not found"; - case MMS_RETRSTATUS_TRANSIENT_NETWORK_PROBLEM: - return "transient network problem"; - case MMS_RETRSTATUS_PERMANENT_FAILURE: - return "permanent failure"; - case MMS_RETRSTATUS_PERMANENT_SERVICE_DENIED: - return "permanent service denied"; - case MMS_RETRSTATUS_PERMANENT_MESSAGE_NOT_FOUND: - return "permanent message not found"; - case MMS_RETRSTATUS_PERMANENT_CONTENT_UNSUPPORT: - return "permanent content unsupport"; - } - - return MmsDebugPrintUnknownValue(retrieveStatus); -} - - -const char *MmsDebugGetMsgStatus(msg_delivery_report_status_t msgStatus) -{ - switch (msgStatus) { - case MSG_DELIVERY_REPORT_ERROR: - return "error"; - case MSG_DELIVERY_REPORT_EXPIRED: - return "expired"; - case MSG_DELIVERY_REPORT_SUCCESS: - return "retrieved"; - case MSG_DELIVERY_REPORT_REJECTED: - return "rejected"; - case MSG_DELIVERY_REPORT_DEFERRED: - return "deferred"; - case MSG_DELIVERY_REPORT_UNRECOGNISED: - return "unrecognised"; - case MSG_DELIVERY_REPORT_INDETERMINATE: - return "indeterminate"; - case MSG_DELIVERY_REPORT_FORWARDED: - return "forwarded"; - case MSG_DELIVERY_REPORT_UNREACHABLE: - return "unreachable"; - } - - return MmsDebugPrintUnknownValue(msgStatus); -} - - -const char *MmsDebugGetMsgClass(MmsMsgClass msgClass) -{ - switch (msgClass) { - case MMS_MSGCLASS_ERROR: - return "error"; - case MMS_MSGCLASS_PERSONAL: - return "personal"; - case MMS_MSGCLASS_ADVERTISEMENT: - return "advertisement"; - case MMS_MSGCLASS_INFORMATIONAL: - return "information"; - case MMS_MSGCLASS_AUTO: - return "auto"; - } - - return MmsDebugPrintUnknownValue(msgClass); -} - - -const char *MmsDebugGetDataType(MmsDataType dataType) -{ - switch (dataType) { - case MMS_DATATYPE_NONE: - return "MMS_DATATYPE_NONE"; - case MMS_DATATYPE_READ: - return "MMS_DATATYPE_READ"; - case MMS_DATATYPE_SENT: - return "MMS_DATATYPE_SENT"; - case MMS_DATATYPE_NOTIFY: - return "MMS_DATATYPE_NOTIFY"; - case MMS_DATATYPE_UNSENT: - return "MMS_DATATYPE_UNSENT"; - case MMS_DATATYPE_DRAFT: - return "MMS_DATATYPE_DRAFT"; - case MMS_DATATYPE_SENDING: - return "MMS_DATATYPE_SENDING"; - case MMS_DATATYPE_DRM_RO_WAITING: - return "MMS_DATATYPE_DRM_RO_WAITING"; - case MMS_DATATYPE_RETRIEVING: - return "MMS_DATATYPE_RETRIEVING"; - case MMS_DATATYPE_UNRETV: - return "MMS_DATATYPE_UNRETV"; - default: - return MmsDebugPrintUnknownValue(dataType); - } -} - -#ifdef MMS_PLUGIN_DEBUG_ENABLE -bool -MmsDebugPrintMsgAttributes(char *pszFunc, MmsAttrib *pAttrib, bool bAll) -{ - SysRequireEx(pAttrib != NULL, false); - - if (pszFunc) - SysDebug((MID_MMS|DBG_MMS_COMMON,"%s ========= \n", pszFunc)); - - SysDebug((MID_MMS|DBG_MMS_COMMON, "szSubject = %s \n", pAttrib->szSubject)); - SysDebug((MID_MMS|DBG_MMS_COMMON, "contentType=%s \n", MmsDebugGetMimeType(pAttrib->contentType))); - SysDebug((MID_MMS|DBG_MMS_COMMON, "dataType=%s \n", MmsDebugGetDataType(pAttrib->dataType))); - - if (pAttrib->specialMsgType != MMS_SPECIAL_MSG_TYPE_NONE) - SysDebug((MID_MMS|DBG_MMS_COMMON, "spcialMsgType = %lu \n", pAttrib->specialMsgType)); - - SysDebug((MID_MMS|DBG_MMS_COMMON, "date=%lu, msgSize=%lu, bRead=%lu\n", pAttrib->date, pAttrib->msgSize, pAttrib->bRead)); - - if (!bAll) - return true; - - SysDebug((MID_MMS|DBG_MMS_COMMON, "msgClass=%s, priority=%lu \n", MmsDebugGetMsgClass(pAttrib->msgClass), pAttrib->priority )); - SysDebug((MID_MMS|DBG_MMS_COMMON, "deliveryTime.type = %lu, time = %lu\n", pAttrib->deliveryTime.type, pAttrib->deliveryTime.time)); - SysDebug((MID_MMS|DBG_MMS_COMMON, "expiryTime.type = %lu, time = %lu\n", pAttrib->expiryTime.type, pAttrib->expiryTime.time)); - - if (pAttrib->szTo && pAttrib->szTo[0] != 0) - SysDebug((MID_MMS|DBG_MMS_COMMON, "szTo = %s \n", pAttrib->szTo)); - if (pAttrib->szCc && pAttrib->szCc[0] != 0) - SysDebug((MID_MMS|DBG_MMS_COMMON, "szCc = %s \n", pAttrib->szCc)); - if (pAttrib->szBcc && pAttrib->szBcc[0] != 0) - SysDebug((MID_MMS|DBG_MMS_COMMON, "szBcc = %s \n", pAttrib->szBcc)); - -#if defined(_MMS_SUPPORT_RECEIVING_OPTION_PROMPT) - SysDebug((MID_MMS|DBG_MMS_COMMON, "readReportAllowedType = %lu \n", pAttrib->readReportAllowedType)); -#endif - SysDebug((MID_MMS|DBG_MMS_COMMON, "bAskDeliveryReport=%lu, bReportAllowed=%lu, bAskReadReply=%lu, bLeaveCopy=%lu \n", - pAttrib->bAskDeliveryReport, pAttrib->bReportAllowed, pAttrib->bAskReadReply, pAttrib->bLeaveCopy)); - - if (pAttrib->bHideAddress) - SysDebug((MID_MMS|DBG_MMS_COMMON, "bHideAddress=true\n")); - - SysDebug((MID_MMS|DBG_MMS_COMMON, "msgStatus = %s \n", MmsDebugGetMsgStatus(pAttrib->msgStatus))); - SysDebug((MID_MMS|DBG_MMS_COMMON, "responseStatus = %s \n", MmsDebugGetResponseStatus(pAttrib->responseStatus))); - SysDebug((MID_MMS|DBG_MMS_COMMON, "retrieveStatus = %s \n", MmsDebugGetRetrieveStatus(pAttrib->retrieveStatus))); - - if (pAttrib->szResponseText && pAttrib->szResponseText[0] != 0) - SysDebug((MID_MMS|DBG_MMS_COMMON, "szResponseText = %s \n", pAttrib->szResponseText)); - - if (pAttrib->szRetrieveText && pAttrib->szRetrieveText[0] != 0) - SysDebug((MID_MMS|DBG_MMS_COMMON, "szRetrieveText = %s \n", pAttrib->szRetrieveText)); - - return true; -} - -char *MmsDebugGetMsgDrmType(MsgDrmType drmType) -{ - switch (drmType) { - case MSG_DRM_TYPE_NONE: - return "MSG_DRM_TYPE_NONE"; - case MSG_DRM_TYPE_FL: - return "MSG_DRM_TYPE_FL"; - case MSG_DRM_TYPE_CD: - return "MSG_DRM_TYPE_CD"; - case MSG_DRM_TYPE_SD: - return "MSG_DRM_TYPE_SD"; - case MSG_DRM_TYPE_SSD: - return "MSG_DRM_TYPE_SSD"; - } - - return MmsDebugPrintUnknownValue(drmType); -} - -char *MmsDebugGetDrmDeliveryMode(DrmDeliveryMode deliveryMode) -{ - switch (deliveryMode) { - case DRM_DELIVERYMODE_FORWARD_LOCK: - return "DRM_DELIVERYMODE_FORWARD_LOCK"; - case DRM_DELIVERYMODE_COMBINED_DELIVERY: - return "DRM_DELIVERYMODE_COMBINED_DELIVERY"; - case DRM_DELIVERYMODE_SEPARATE_DELIVERY: - return "DRM_DELIVERYMODE_SEPARATE_DELIVERY"; - case DRM_DELIVERYMODE_SPECIAL_SEPARATE: - return "DRM_DELIVERYMODE_SPECIAL_SEPARATE"; - } - - return MmsDebugPrintUnknownValue(deliveryMode); -} - -char *MmsDebugGetDrmRightState(DrmRightState rightState) -{ - switch (rightState) { - case DRMRIGHT_STATE_NORIGHTS: - return "DRMRIGHT_STATE_NORIGHTS"; - case DRMRIGHT_STATE_INVALID_RIGHTS: - return "DRMRIGHT_STATE_INVALID_RIGHTS"; - case DRMRIGHT_STATE_VALID_RIGHTS: - return "DRMRIGHT_STATE_VALID_RIGHTS"; - case DRMRIGHT_STATE_EXPIRED_RIGHTS: - return "DRMRIGHT_STATE_EXPIRED_RIGHTS"; - } - - return MmsDebugPrintUnknownValue(rightState); -} - - -bool MmsDebugPrintDrmRight(DrmRight *pDrmRight) -{ - if (!pDrmRight) - return true; - - if (pDrmRight->rightStatus == DRMRIGHT_STATE_NORIGHTS) { - SysDebug((MID_MMS|DBG_MMS_COMMON, "rightStatus = %s \n", MmsDebugGetDrmRightState(pDrmRight->rightStatus))); - return true; - } - - SysDebug((MID_MMS|DBG_MMS_COMMON, "iDeliveryType = %s \n", MmsDebugGetDrmDeliveryMode(pDrmRight->iDeliveryType))); - SysDebug((MID_MMS|DBG_MMS_COMMON, "bestConstraint = %s \n", MmsDebugGetDrmConsumeMode(pDrmRight->bestConstraint))); - SysDebug((MID_MMS|DBG_MMS_COMMON, "bFirstIntervalRender = %d \n", pDrmRight->bFirstIntervalRender)); - SysDebug((MID_MMS|DBG_MMS_COMMON, "rightStatus = %s \n", MmsDebugGetDrmRightState(pDrmRight->rightStatus))); - - SysDebug((MID_MMS|DBG_MMS_COMMON, "bValidIssuer = %d \n", pDrmRight->bValidIssuer)); - - return true; -} - -char *MmsDebugPrintMsgDRMStatus(MsgDRMStatus status) -{ - switch (status) { - case MSG_DRM_STATUS_INVALID: - return "MSG_DRM_STATUS_INVALID"; - case MSG_DRM_STATUS_VALID: - return "MSG_DRM_STATUS_VALID"; - case MSG_DRM_STATUS_EXPIRED: - return "MSG_DRM_STATUS_EXPIRED"; - } - - return MmsDebugPrintUnknownValue(status); -} - - -bool MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index) -{ - SysDebug((MID_MMS|DBG_MMS_COMMON, "------------------------------\n")); - SysDebug((MID_MMS|DBG_MMS_COMMON, "%dth multipart info\n", index)); - SysDebug((MID_MMS|DBG_MMS_COMMON, "header size=%d\n", pMultipart->type.size)); - SysDebug((MID_MMS|DBG_MMS_COMMON, "body size=%d\n", pMultipart->type.contentSize)); - SysDebug((MID_MMS|DBG_MMS_COMMON, "content type=%s\n", MmsDebugGetMimeType(pMultipart->type.type))); - SysDebug((MID_MMS|DBG_MMS_COMMON, "content ID=%s\n", pMultipart->type.szContentID)); - SysDebug((MID_MMS|DBG_MMS_COMMON, "content location=%s\n", pMultipart->type.szContentLocation)); - - if (pMultipart->type.type == MIME_TEXT_PLAIN) { - SysDebug((MID_MMS|DBG_MMS_COMMON, "text info\n")); - SysDebug((MID_MMS|DBG_MMS_COMMON, "charset=%d\n", pMultipart->type.param.charset)); - SysDebug((MID_MMS|DBG_MMS_COMMON, "text file name=%s\n", pMultipart->type.param.szName)); - } - - if (pMultipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { - SysDebug((MID_MMS|DBG_MMS_COMMON, "drm info\n")); - SysDebug((MID_MMS|DBG_MMS_COMMON, "drm type=%s\n", MmsDebugGetMsgDrmType(pMultipart->type.drmInfo.drmType))); - SysDebug((MID_MMS|DBG_MMS_COMMON, "drm content type=%s\n", MmsDebugGetMimeType(pMultipart->type.drmInfo.contentType))); - SysDebug((MID_MMS|DBG_MMS_COMMON, "drm content URI=%s\n", pMultipart->type.drmInfo.szContentURI)); - } - SysDebug((MID_MMS|DBG_MMS_COMMON, "------------------------------\n")); - return true; -} - - -bool MmsDebugPrintCurrentEventHandler(char *pszFunc, MmsDebugEvType evType) -{ - HEventHandler hMmsEH; - HEventHandler hSmsEH; - HEventHandler hEmailEH; - HEventHandler hCommonEH; - HEventHandler hCurrentEH; - - hMmsEH = WmGetEventHandlerByName(EHN_MMS); - hSmsEH = WmGetEventHandlerByName(EHN_SMS); - hEmailEH = WmGetEventHandlerByName(EHN_EMAIL); - hCommonEH = WmGetEventHandlerByName(EHN_MESSENGER); - hCurrentEH = WmGetCurrentEventHandler(); - - switch (evType) { - case MMS_DEBUG_EV_MMS: - SysRequireExf(hCurrentEH == hMmsEH, false, ("%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n", \ - pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH)); - break; - - case MMS_DEBUG_EV_SMS: - SysRequireExf(hCurrentEH == hSmsEH, false, ("%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n", \ - pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH)); - break; - - case MMS_DEBUG_EV_COMMON: - SysRequireExf(hCurrentEH == hCommonEH, false, ("%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n", \ - pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH)); - break; - - case MMS_DEBUG_EV_EMAIL: - SysRequireExf(hCurrentEH == hEmailEH, false, ("%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n", \ - pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH)); - break; - - case MMS_DEBUG_EV_NONE: - default: - SysDebug((MID_MMS,"%s, hMmsEH=%d, hSmsEH=%d, hEmailEH=%d, hCommonEH=%d, hCurrentEH=%d\n", \ - pszFunc, hMmsEH, hSmsEH, hEmailEH, hCommonEH, hCurrentEH)); - break; - } - return true; -} - - -char *DebugPrintGetRmResultInd(MmsRmResultInd indType) -{ - switch (indType) { - case RM_RESULTIND_NONE: - return "RM_RESULTIND_NONE"; - - case RM_RESULTIND_MANUAL_SEND: - return "RM_RESULTIND_MANUAL_SEND"; - - case RM_RESULTIND_AUTO_SEND: - return "RM_RESULTIND_AUTO_SEND"; - - case RM_RESULTIND_MANUAL_GET: - return "RM_RESULTIND_MANUAL_GET"; - - case RM_RESULTIND_AUTO_GET: - return "RM_RESULTIND_AUTO_GET"; - - case RM_RESULTIND_MANUAL_FORWARD: - return "RM_RESULTIND_MANUAL_FORWARD"; - } - - return MmsDebugPrintUnknownValue(indType); -} - - -char *DebugPrintHttpStatusCode(int status) -{ - switch (status) { - case HTTP_STATUS_100: - return "HTTP_STATUS_100"; - case HTTP_STATUS_101: - return "HTTP_STATUS_101"; - - case HTTP_STATUS_200: - return "HTTP_STATUS_200"; - case HTTP_STATUS_201: - return "HTTP_STATUS_201"; - case HTTP_STATUS_202: - return "HTTP_STATUS_202"; - case HTTP_STATUS_203: - return "HTTP_STATUS_203"; - case HTTP_STATUS_204: - return "HTTP_STATUS_204"; - case HTTP_STATUS_205: - return "HTTP_STATUS_205"; - case HTTP_STATUS_206: - return "HTTP_STATUS_206"; - - case HTTP_STATUS_300: - return "HTTP_STATUS_300"; - case HTTP_STATUS_301: - return "HTTP_STATUS_301"; - case HTTP_STATUS_302: - return "HTTP_STATUS_302"; - case HTTP_STATUS_303: - return "HTTP_STATUS_303"; - case HTTP_STATUS_304: - return "HTTP_STATUS_304"; - case HTTP_STATUS_305: - return "HTTP_STATUS_305"; - - case HTTP_STATUS_400: - return "HTTP_STATUS_400"; - case HTTP_STATUS_401: - return "HTTP_STATUS_401"; - case HTTP_STATUS_402: - return "HTTP_STATUS_402"; - case HTTP_STATUS_403: - return "HTTP_STATUS_403"; - case HTTP_STATUS_404: - return "HTTP_STATUS_404"; - case HTTP_STATUS_405: - return "HTTP_STATUS_405"; - case HTTP_STATUS_406: - return "HTTP_STATUS_406"; - case HTTP_STATUS_407: - return "HTTP_STATUS_407"; - case HTTP_STATUS_408: - return "HTTP_STATUS_408"; - case HTTP_STATUS_409: - return "HTTP_STATUS_409"; - case HTTP_STATUS_410: - return "HTTP_STATUS_410"; - case HTTP_STATUS_411: - return "HTTP_STATUS_411"; - case HTTP_STATUS_412: - return "HTTP_STATUS_412"; - case HTTP_STATUS_413: - return "HTTP_STATUS_413"; - case HTTP_STATUS_414: - return "HTTP_STATUS_414"; - case HTTP_STATUS_415: - return "HTTP_STATUS_415"; - - case HTTP_STATUS_500: - return "HTTP_STATUS_500"; - case HTTP_STATUS_501: - return "HTTP_STATUS_501"; - case HTTP_STATUS_502: - return "HTTP_STATUS_502"; - case HTTP_STATUS_503: - return "HTTP_STATUS_503"; - case HTTP_STATUS_504: - return "HTTP_STATUS_504"; - case HTTP_STATUS_505: - return "HTTP_STATUS_505"; - - case REASON_WTP_UNKNOWN: - return "REASON_WTP_UNKNOWN"; - case REASON_WTP_PROTO_ERR: - return "REASON_WTP_PROTO_ERR"; - case REASON_WTP_INVALID_TID: - return "REASON_WTP_INVALID_TID"; - case REASON_WTP_NOT_IMPLEMENTED_CL2: - return "REASON_WTP_NOT_IMPLEMENTED_CL2"; - case REASON_WTP_NOT_IMPLEMENTED_SAR: - return "REASON_WTP_NOT_IMPLEMENTED_SAR"; - case REASON_WTP_NOT_IMPLEMENTEDU_ACK: - return "REASON_WTP_NOT_IMPLEMENTEDU_ACK"; - case REASON_WTP_VERSIONONE: - return "REASON_WTP_VERSIONONE"; - case REASON_WTP_CAPTEMP_EXCEED: - return "REASON_WTP_CAPTEMP_EXCEED"; - case REASON_WTP_NO_RESPONSE: - return "REASON_WTP_NO_RESPONSE"; - case REASON_WTP_MESSAGE_TOO_LARGE: - return "REASON_WTP_MESSAGE_TOO_LARGE"; - - case REASON_PROTOERR: - return "REASON_PROTOERR"; // = 0xE0 - case REASON_DISCONNECT: - return "REASON_DISCONNECT"; - case REASON_SUSPEND: - return "REASON_SUSPEND"; - case REASON_RESUME: - return "REASON_RESUME"; - case REASON_CONGESTION: - return "REASON_CONGESTION"; - case REASON_CONNECTERR: - return "REASON_CONNECTERR"; - case REASON_MRUEXCEEDED: - return "REASON_MRUEXCEEDED"; - case REASON_MOREXCEEDED: - return "REASON_MOREXCEEDED"; - case REASON_PEERREQ: - return "REASON_PEERREQ"; - case REASON_NETERR: - return "REASON_NETERR"; - case REASON_USERREQ: - return "REASON_USERREQ"; - /* added for ver 1.2 */ - case REASON_USERRFS: - return "REASON_USERRFS"; - case REASON_PND: - return "REASON_PND"; - case REASON_USERDCR: - return "REASON_USERDCR"; - case REASON_USERDCU: - return "REASON_USERDCU"; - } - - return MmsDebugPrintUnknownValue(status); -} - - -char *DebugPrintRmMethodType(MmsRmMethodType method) -{ - switch (method) { - case RM_METHOD_NONE: - return "RM_METHOD_NONE"; - case RM_METHOD_GET: - return "RM_METHOD_GET"; - case RM_METHOD_POST: - return "RM_METHOD_POST"; - } - - return MmsDebugPrintUnknownValue(method); -} - - -char *DebugPrintGetMmsRmNetState(MmsRmNetState state) -{ - switch (state) { - case RM_PROTO_IDLE: - return "RM_PROTO_IDLE"; - case RM_PROTO_STARTING: - return "RM_PROTO_STARTING"; - case RM_PROTO_STARTED: - return "RM_PROTO_STARTED"; - case RM_PROTO_STOPPING: - return "RM_PROTO_STOPPING"; - - case RM_PROTO_WAITING: - return "RM_PROTO_WAITING"; - case RM_PROTO_DISCONNECTING_OTHER_APP: - return "RM_PROTO_DISCONNECTING_OTHER_APP"; - case RM_PROTO_DISCONNECTED_BY_OTHER_APP: - return "RM_PROTO_DISCONNECTED_BY_OTHER_APP"; - - case RM_PROTO_FAILED: - return "RM_PROTO_FAILED"; - } - - return MmsDebugPrintUnknownValue(state); -} - - -char *DebugPrintGetMmsRmEntityState(MmsRmExEntityState stateEx) -{ - switch (stateEx) { - case RM_ENTITY_IDLE: - return "RM_ENTITY_IDLE"; - case RM_ENTITY_PROTO_STARTING: - return "RM_ENTITY_PROTO_STARTING"; - - case RM_ENTITY_CNXN_ESTABLISHING: - return "RM_ENTITY_CNXN_ESTABLISHING"; - case RM_ENTITY_CNXN_ESTABLISHED: - return "RM_ENTITY_CNXN_ESTABLISHED"; - - case RM_ENTITY_SENDING_REQUEST: - return "RM_ENTITY_SENDING_REQUEST"; - case RM_ENTITY_SENDING_REQ_N_NO_RESPONSE: - return "RM_ENTITY_SENDING_REQ_N_NO_RESPONSE"; - - case RM_ENTITY_SENDING_REQ_COMPLETED: - return "RM_ENTITY_SENDING_REQ_COMPLETED"; - - case RM_ENTITY_SENDING_REQ_FAILED: - return "RM_ENTITY_SENDING_REQ_FAILED"; - case RM_ENTITY_SENDING_REQ_CANCELLED_BY_USER_CONFIRMED: - return "RM_ENTITY_SENDING_REQ_CANCELLED_BY_USER_CONFIRMED"; - } - - return MmsDebugPrintUnknownValue(stateEx); -} - - -char *MmsDebugPrintMmsRmResult(MmsRmResult result) -{ - switch (result) { - case MMS_RM_RESULT_SUCCESSED: - return "MMS_RM_RESULT_SUCCESSED"; - case MMS_RM_RESULT_FAIL: - return "MMS_RM_RESULT_FAIL"; - case MMS_RM_RESULT_FAIL_N_RETRY: - return "MMS_RM_RESULT_FAIL_N_RETRY"; - - case MMS_RM_RESULT_PROTO_STARTING_FAILED: - return "MMS_RM_RESULT_PROTO_STARTING_FAILED"; - - case MMS_RM_RESULT_DISCONNECT_MMS: - return "MMS_RM_RESULT_DISCONNECT_MMS"; - case MMS_RM_RESULT_CLOSING_OTHER_APP_FAILED: - return "MMS_RM_RESULT_CLOSING_OTHER_APP_FAILED"; - - case MMS_RM_RESULT_SENDING_REQ_FAILED: - return "MMS_RM_RESULT_SENDING_REQ_FAILED"; - case MMS_RM_RESULT_CANCELED_BY_USER: - return "MMS_RM_RESULT_CANCELED_BY_USER"; - case MMS_RM_RESULT_CANCELED_FROM_RETRY_POPUP: - return "MMS_RM_RESULT_CANCELED_FROM_RETRY_POPUP"; - - case MMS_RM_RESULT_PROTO_FAILED: - return "MMS_RM_RESULT_PROTO_FAILED"; - case MMS_RM_RESULT_DISCONNECTED_BY_OTHER: - return "MMS_RM_RESULT_DISCONNECTED_BY_OTHER"; - - case MMS_RM_RESULT_MEMORY_FULL: - return "MMS_RM_RESULT_MEMORY_FULL"; - } - - return MmsDebugPrintUnknownValue(result); -} - -void MmsDebugPrintReqEntityInfo(MmsRmRequest *pEntity) -{ - SysDebug((MID_MMS," - proto state=%s\n", DebugPrintGetMmsRmNetState(_MmsRmNetGetState()))); - - if (_MmsRmNetGetProtoType() == MMS_RM_WAP_CONNORIENTED || _MmsRmNetGetProtoType() == MMS_RM_WTLS) { - SysDebug((MID_MMS," - wap cnxn state=%s\n", DebugPrintWspState(MmsRmWspGetCnxnState()))); - } - - if (!pEntity) { - SysDebug((MID_EXCEPTION, "MmsDebugPrintReqEntityInfo : pEntity is NULL. \n")); - return; - } - - SysDebug((MID_MMS," - entity state=%s\n", DebugPrintGetMmsRmEntityState(pEntity->stateEx))); - - if (pEntity->cb.result.bSend) { - if (pEntity->pduType == MMS_RM_READ_REPORT_V10) { - SysDebug((MID_MMS," - sending read report v10\n")); - } else if (pEntity->pduType == MMS_RM_READ_REPORT_V11) { - SysDebug((MID_MMS," - sending read report v11\n")); - } else { - SysDebug((MID_MMS," - sending msg\n")); - } - } else { // then receiving.. - if (pEntity->cb.result.bAutoRetrieving) { - SysDebug((MID_MMS," - retrieving(auto)\n")); - } else { - SysDebug((MID_MMS," - retrieving(manual)\n")); - } - } - - SysDebug((MID_MMS," - msgID=%d, trID=0x%x, pduType=%s\n", pEntity->msgID, pEntity->trId, MmsDebugPrintRmPduType(pEntity->pduType))); - - if (pEntity->protoActvCount > 1) { - SysDebug((MID_MMS," - protoActvCount=%d\n", pEntity->protoActvCount)); - } - - if (pEntity->reqCount > 1) { - SysDebug((MID_MMS," - reqCount=%d\n", pEntity->reqCount)); - } - - if (pEntity->fullRetryCount > 1) { - SysDebug((MID_MMS," - fullRetryCount=%d\n", pEntity->fullRetryCount)); - } -} - -char *MmsDebugPrintHttpErrorCode(int errCode) -{ - switch (errCode) { - case HTTPERR_INVALID_PARAM: - return "HTTPERR_INVALID_PARAM"; - case HTTPERR_UNKNOWN: - return "HTTPERR_UNKNOWN"; - case HTTPERR_INVALID_PROXY: - return "HTTPERR_INVALID_PROXY"; - case HTTPERR_OUT_OF_MEMORY: - return "HTTPERR_OUT_OF_MEMORY"; - case HTTPERR_NO_RESPONSE: - return "HTTPERR_NO_RESPONSE"; - case HTTPERR_INIT: - return "HTTPERR_INIT"; - case HTTPERR_NETDOWN: - return "HTTPERR_NETDOWN"; - case HTTPERR_TIMEOUT: - return "HTTPERR_TIMEOUT"; - case HTTPERR_HOST_UNREACH: - return "HTTPERR_HOST_UNREACH"; - case HTTPERR_CONN_RESET: - return "HTTPERR_CONN_RESET"; - case HTTPERR_INTERNAL: - return "HTTPERR_INTERNAL"; - case HTTPERR_CHUNKEDTR: - return "HTTPERR_CHUNKEDTR"; - case HTTPERR_USER: - return "HTTPERR_USER"; - case HTTPERR_TOO_BIG: - return "HTTPERR_TOO_BIG"; - case HTTPERR_NOT_SUPPORTED_SVC: - return "HTTPERR_NOT_SUPPORTED_SVC"; - case HTTPERR_NO_CONTENT: - return "HTTPERR_NO_CONTENT"; - case HTTPERR_WRITEFAIL: - return "HTTPERR_WRITEFAIL"; - case HTTPERR_AUTHFAIL: - return "HTTPERR_AUTHFAIL"; - - case HTTPERR_DNSFAIL: - return "HTTPERR_DNSFAIL"; - case HTTPERR_UAGENT_NOT_ALLOWED: - return "HTTPERR_UAGENT_NOT_ALLOWED"; - - } - return MmsDebugPrintUnknownValue(errCode); -} - -char *MmsDebugPrintProtoErrorCode(int errCode) -{ - switch (errCode) { - case PROTO_ERROR_NONE: - return "PROTO_ERROR_NONE"; - /* Wireless stack errors */ - case PROTO_ERROR_NO_SERVICE: - return "PROTO_ERROR_NO_SERVICE"; - case PROTO_ERROR_INVALID_PARAM: - return "PROTO_ERROR_INVALID_PARAM"; - case PROTO_ERROR_INVALID_APN: - return "PROTO_ERROR_INVALID_APN"; - case PROTO_ERROR_INVALID_OP_MODE: - return "PROTO_ERROR_INVALID_OP_MODE"; - case PROTO_ERROR_INVALID_PROTO_TYPE: - return "PROTO_ERROR_INVALID_PROTO_TYPE"; - case PROTO_ERROR_INVALID_SERVICE_DOMAIN: - return "PROTO_ERROR_INVALID_SERVICE_DOMAIN"; - case PROTO_ERROR_INVALID_PDP_DATA: - return "PROTO_ERROR_INVALID_PDP_DATA"; - case PROTO_ERROR_INVALID_QOS: - return "PROTO_ERROR_INVALID_QOS"; - case PROTO_ERROR_SESSION_DEACTIVATED: - return "PROTO_ERROR_SESSION_DEACTIVATED"; - case PROTO_ERROR_AUTHENTICATION_FAILED: - return "PROTO_ERROR_AUTHENTICATION_FAILED"; - case PROTO_ERROR_MOBILE_FAILURE: - return "PROTO_ERROR_MOBILE_FAILURE"; - case PROTO_ERROR_NETWORK_FAILURE: - return "PROTO_ERROR_NETWORK_FAILURE"; - case PROTO_ERROR_TIMEOUT: - return "PROTO_ERROR_TIMEOUT"; - case PROTO_ERROR_NO_RESOURCE: - return "PROTO_ERROR_NO_RESOURCE"; - case PROTO_ERROR_INVALID_CONTEXT_ID: - return "PROTO_ERROR_INVALID_CONTEXT_ID"; - case PROTO_ERROR_MODEM_IN_USE: - return "PROTO_ERROR_MODEM_IN_USE"; - case PROTO_ERROR_INVALID_SIM_STATE: - return "PROTO_ERROR_INVALID_SIM_STATE:"; - case PROTO_ERROR_SERVICE_NOT_SUBSCRIBED: - return "PROTO_ERROR_SERVICE_NOT_SUBSCRIBED"; - case PROTO_ERROR_SERVICE_NOT_IMPLEMENTED: - return "PROTO_ERROR_SERVICE_NOT_IMPLEMENTED"; - case PROTO_ERROR_FDN_NOT_ALLOWED: - return "PROTO_ERROR_FDN_NOT_ALLOWED"; - case PROTO_ERROR_CALL_INCOME: - return "PROTO_ERROR_CALL_INCOME"; - case PROTO_ERROR_NOT_SUPPORT_3GCSD: - return "PROTO_ERROR_NOT_SUPPORT_3GCSD"; - case PROTO_ERROR_UNKNOWN: - return "PROTO_ERROR_UNKNOWN"; - case PROTO_ERROR_SI_OFFLINE: - return "PROTO_ERROR_SI_OFFLINE"; - /* TCP/IP/PPP stack errors */ - case PROTO_ERROR_TCPIP_UP: - return "PROTO_ERROR_TCPIP_UP"; - case PROTO_ERROR_TCPIP_DOWN: - return "PROTO_ERROR_TCPIP_DOWN"; - case PROTO_ERROR_PPP_UP: - return "PROTO_ERROR_PPP_UP"; - case PROTO_ERROR_PPP_DOWN: - return "PROTO_ERROR_PPP_DOWN"; - case PROTO_ERROR_WDP_INIT: - return "PROTO_ERROR_WDP_INIT"; - /* ProtoMgr API call errors */ - case PROTO_ERROR_ACTIVE_CONNECTIONS: - return "PROTO_ERROR_ACTIVE_CONNECTIONS"; - case PROTO_ERROR_MAX_CONNECTIONS: - return "PROTO_ERROR_MAX_CONNECTIONS"; - case PROTO_ERROR_INVALID_HANDLE: - return "PROTO_ERROR_INVALID_HANDLE"; - case PROTO_ERROR_INVALID_CONTEXT: - return "PROTO_ERROR_INVALID_CONTEXT"; - case PROTO_ERROR_INVALID_CALLBACK: - return "PROTO_ERROR_INVALID_CALLBACK"; - case PROTO_ERROR_INVALID_EHN: - return "PROTO_ERROR_INVALID_EHN"; - case PROTO_ERROR_INVALID_EVENTCLASS: - return "PROTO_ERROR_INVALID_EVENTCLASS"; - case PROTO_ERROR_INVALID_REFTYPE: - return "PROTO_ERROR_INVALID_REFTYPE"; - case PROTO_ERROR_INVALID_TIMEOUT: - return "PROTO_ERROR_INVALID_TIMEOUT"; - case PROTO_ERROR_MAX_CLIENT: - return "PROTO_ERROR_MAX_CLIENT"; - case PROTO_ERROR_MAX_ACCOUNT: - return "PROTO_ERROR_MAX_ACCOUNT"; - case PROTO_ERROR_ACCESS_DENIED: - return "PROTO_ERROR_ACCESS_DENIED"; - case PROTO_ERROR_REGISTRY_LOAD: - return "PROTO_ERROR_REGISTRY_LOAD"; - - case PROTO_ERROR_PCBROWSING_ON: - return "PROTO_ERROR_PCBROWSING_ON"; - case PROTO_ERROR_REACTIVATION_REQ: - return "PROTO_ERROR_REACTIVATION_REQ"; - case PROTO_ERROR_NO_PDP_ACTIVATED: - return "PROTO_ERROR_NO_PDP_ACTIVATED"; - - case PROTO_ERROR_MAX: - return "PROTO_ERROR_MAX"; - - } - - return MmsDebugPrintUnknownValue(errCode); -} - - -char *DebugPrintWspResult(WspResult wspResult) -{ - switch (wspResult) { - case WSP_RESULT_NO_ERROR: - return "WSP_RESULT_NO_ERROR"; - case WSP_RESULT_NO_SESSION: - return "WSP_RESULT_NO_SESSION"; - case WSP_RESULT_NOT_SUITABLE: - return "WSP_RESULT_NOT_SUITABLE"; - - case WSP_RESULT_NOT_RESPONDING: - return "WSP_RESULT_NOT_RESPONDING"; - case WSP_RESULT_MOP_EXCEED: - return "WSP_RESULT_MOP_EXCEED"; - case WSP_RESULT_MOM_EXCEED: - return "WSP_RESULT_MOM_EXCEED"; - - case WSP_RESULT_UNABLE: - return "WSP_RESULT_UNABLE"; - case WSP_RESULT_UNKNOWN: - return "WSP_RESULT_UNKNOWN"; - case WSP_RESULT_WRONG_PARAM: - return "WSP_RESULT_WRONG_PARAM"; - - case WSP_RESULT_NO_MEMORY: - return "WSP_RESULT_NO_MEMORY"; - case WSP_RESULT_NO_HANDLE: - return "WSP_RESULT_NO_HANDLE"; - - case WSP_RESULT_CAPABILITY_UNABLE: - return "WSP_RESULT_CAPABILITY_UNABLE"; - case WSP_RESULT_UAGENT_NOT_ALLOWED: - return "WSP_RESULT_UAGENT_NOT_ALLOWED"; - } - - return MmsDebugPrintUnknownValue(wspResult); -} - - -char *DebugPrintWspState(MmsRmWapState wspState) -{ - switch (wspState) { //gMmsRmWapState - case RM_WAP_IDLE: - return "RM_WAP_IDLE"; - case RM_WAP_CONNECTING: - return "RM_WAP_CONNECTING"; - case RM_WAP_CONNECTED: - return "RM_WAP_CONNECTED"; - case RM_WAP_DISCONNECTING: - return "RM_WAP_DISCONNECTING"; - case RM_WAP_SECURE_REDIRECT: - return "RM_WAP_SECURE_REDIRECT"; - case RM_WAP_FAILED: - return "RM_WAP_FAILED"; - case RM_WAP_WTLS_HANDSHAKING: - return "RM_WAP_WTLS_HANDSHAKING"; - case RM_WAP_WTLS_HANDSHAKE_COMPLETED: - return "RM_WAP_WTLS_HANDSHAKE_COMPLETED"; - } - - return MmsDebugPrintUnknownValue(wspState); -} - - -char *MmsDebugPrintRmPduType(MmsRmPduType pduType) -{ - switch (pduType) { - case MMS_RM_PDU_TYPE: - return "MMS_RM_PDU_TYPE"; - - case MMS_RM_SEND_REQ: - return "MMS_RM_SEND_REQ"; - case MMS_RM_GET_REQ_AUTO: - return "MMS_RM_GET_REQ_AUTO"; - case MMS_RM_GET_REQ_MANUAL: - return "MMS_RM_GET_REQ_MANUAL"; - case MMS_RM_NOTIFY_RESP_IND: - return "MMS_RM_NOTIFY_RESP_IND"; - case MMS_RM_ACK_IND: - return "MMS_RM_ACK_IND"; - - case MMS_RM_NOTI_IND: - return "MMS_RM_NOTI_IND"; - case MMS_RM_RETRIEVE_CONF: - return "MMS_RM_RETRIEVE_CONF"; - - case MMS_RM_READ_REPORT_V10: - return "MMS_RM_READ_REPORT_V10"; - case MMS_RM_READ_REPORT_V11: - return "MMS_RM_READ_REPORT_V11"; - } - - return MmsDebugPrintUnknownValue(pduType); -} - - -char *MmsDebugPrintMailboxType(MsgMailboxType mailboxType) -{ - switch (mailboxType) { - case MSG_MAILBOX_WRITE: - return "MSG_MAILBOX_WRITE"; - case MSG_MAILBOX_INBOX: - return "MSG_MAILBOX_INBOX"; - case MSG_MAILBOX_DRAFT: - return "MSG_MAILBOX_DRAFT"; - case MSG_MAILBOX_SENT: - return "MSG_MAILBOX_SENT"; - case MSG_MAILBOX_MAILBOX: - return "MSG_MAILBOX_MAILBOX"; - case MSG_MAILBOX_OUTBOX: - return "MSG_MAILBOX_OUTBOX"; - case MSG_MAILBOX_TEMPLATE: - return "MSG_MAILBOX_TEMPLATE"; - case MSG_MAILBOX_MYFOLDER: - return "MSG_MAILBOX_MYFOLDER"; - case MSG_MAILBOX_MYFOLDER_LIST: - return "MSG_MAILBOX_MYFOLDER_LIST"; - case MSG_MAILBOX_PRESET: - return "MSG_MAILBOX_PRESET"; - } - - return MmsDebugPrintUnknownValue(mailboxType); -} -#endif - diff --git a/plugin/mms_plugin/MmsPluginDecode.cpp b/plugin/mms_plugin/MmsPluginDecode.cpp index 5a2700d..4940178 100755 --- a/plugin/mms_plugin/MmsPluginDecode.cpp +++ b/plugin/mms_plugin/MmsPluginDecode.cpp @@ -1,94 +1,134 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -#include +#include #include #include #include #include -#include "MsgDebug.h" -#include "MsgException.h" -#include "MmsPluginMessage.h" -#include "MmsPluginStorage.h" #include "MsgUtilFile.h" -#include "MmsPluginCodec.h" +#include "MsgSmil.h" +#include "MsgMmsMessage.h" + #include "MmsPluginDebug.h" -#include "MsgSettingTypes.h" -#include "MsgSettingHandler.h" -#include "MmsPluginInternal.h" -#include "MmsPluginAvCodec.h" +#include "MmsPluginDecode.h" +#include "MmsPluginCodecCommon.h" #include "MmsPluginStorage.h" -#include "MmsPluginSmil.h" -#ifdef __SUPPORT_DRM__ +#include "MmsPluginDebug.h" +#include "MmsPluginMIME.h" +#include "MmsPluginTextConvert.h" +#include "MmsPluginUtil.h" + #include "MmsPluginDrm.h" #include "MsgDrmWrapper.h" -#endif +/*Decode wsp*/ +static int __MmsGetDecodeOffset(void); +static bool __MmsDecodeInitialize(void); +static void __MmsCleanDecodeBuff(void); +static bool __MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength); +static bool __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLength); + +static bool __MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength); /* bufLen < gMmsDecodeMaxLen */ +static bool __MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength); /* no bufLen limit */ +static bool __MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength); -static bool _MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength); /* bufLen < gMmsDecodeMaxLen */ -static bool _MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength); /* no bufLen limit */ -static bool _MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength); +static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int totalLength); +static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen, int totalLength); +static bool __MmsDecodeLongInteger(FILE *pFile, UINT32 *pLongInteger, int totalLength); static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLength); static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLength); static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalLength); +static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int totalLength); +static char *__MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength); static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, int totalLength); static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen, int totalLength); -static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen, int totalLength); + static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSetLen, int totalLength); -static char *__MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength); -static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int totalLength); -static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int totalLength); -static bool __MmsDecodeLongInteger(FILE *pFile, UINT32 *pLongInteger, int totalLength); static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int totalLength); static MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength); -#ifdef __SUPPORT_DRM__ -bool __MmsParseDCFInfo(FILE *pFile, MsgDRMInfo *pDrmInfo, int totalLength); -bool __MmsParseDCFHdr(FILE *pFile, MsgDRMInfo *pDrmInfo, UINT32 headerLen, int totalLength); -bool MmsBinaryDecodeDRMMessage(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int fullBodyLength, int totalLength); -bool MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int bodyLength, int totalLength); -#endif +static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength); +static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength); +static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, int totalLength); +static bool __MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength); +static bool __MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength); +static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, int totalLength); -static bool MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength); -bool MmsBinaryIsTextEncodedPart(FILE *pFile, int totalLength); -static bool __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLength); +static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength); -bool __MmsTextDecodeMsgHeader(FILE *pFile); -bool MmsTextDecodeMsgBody(FILE *pFile); -char gszMmsLoadBuf1[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, }; -char gszMmsLoadBuf2[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, }; +//util funcion +static void __MsgRemoveFilePath(char *pSrc); +static bool __MsgChangeSpace(char *pOrg, char **ppNew); +static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo); +static MsgPresentationFactor __MsgIsPresentationEx(MsgType *multipartType, char* szStart, MimeType typeParam); +static bool __MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffset, char *pInBuf1, char *pInBuf2, int maxLen, int *npRead, int endOfFile); +static bool __MsgFreeHeaderAddress(MsgHeaderAddress *pAddr); +static bool __MsgCheckFileNameHasInvalidChar(char *szName); -static char *gpCurMmsDecodeBuff = NULL; -static int gCurMmsDecodeBuffPos = 0; /* next decoding position in gpCurMmsDecodeBuff */ -static int gMmsDecodeMaxLen = 0; -static int gMmsDecodeCurOffset = 0; /* current offset in file (last read) */ -static int gMmsDecodeBufLen = 0; /* number of last read characters */ +static bool __MsgReplaceInvalidFileNameChar(char *szInText, char replaceChar); +static char *__MsgGetStringUntilDelimiter(char *pszString, char delimiter); +static bool __MsgParseParameter(MsgType *pType, char *pSrc); +static char *__MsgSkipWS(char *s); +static char *__MsgSkipComment(char *s, long trim); -static char *gpMmsDecodeBuf1 = NULL; -static char *gpMmsDecodeBuf2 = NULL; +static char *__MsgConvertLatin2UTF8FileName(char *pSrc); -MmsHeader mmsHeader = -{ - false, //bActive - NULL, //pszOwner - -1, //msgID +//static bool __MsgIsPercentSign(char *pSrc); +static bool __MsgIsMultipartRelated(int type); +static bool __MsgIsPresentablePart(int type); +static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody); +static bool __MsgIsHexChar(char *pSrc); +static char __MsgConvertHexValue(char *pSrc); +static int __MsgConvertCharToInt(char ch); +static bool __MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2); +static bool __MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2); +static bool __MsgIsMultipartMixed(int type); + +static bool __MsgIsInvalidFileNameChar(char ch); + +static int __MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar); +static int __MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar); +static int __MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar); +static void __MsgMIMERemoveQuote(char *szSrc); +static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave); + +static bool __MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE *pFile); +static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msgTypeValue, int msgCharsetValue, int *npRead); + +static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex, char *outBuf, int outBufLen); + + +__thread char gszMmsLoadBuf1[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, }; +__thread char gszMmsLoadBuf2[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, }; +__thread char *gpCurMmsDecodeBuff = NULL; +__thread int gCurMmsDecodeBuffPos = 0; /* next decoding position in gpCurMmsDecodeBuff */ +__thread int gMmsDecodeMaxLen = 0; +__thread int gMmsDecodeCurOffset = 0; /* current offset in file (last read) */ +__thread int gMmsDecodeBufLen = 0; /* number of last read characters */ + +__thread char *gpMmsDecodeBuf1 = NULL; +__thread char *gpMmsDecodeBuf2 = NULL; + +__thread MmsHeader mmsHeader = +{ (MmsMsgType)MMS_MSGTYPE_ERROR, //MmsMsgType iType; "", //char[] szTrID; //"", //short int version; @@ -136,54 +176,19 @@ MmsHeader mmsHeader = 0, //UINT32 msgSize; }; -#ifdef __SUPPORT_DRM__ - #define MMS_DRM2_CONVERT_BUFFER_MAX 4*1024 const UINT32 MMS_UINTVAR_LENGTH_1 = 0x0000007f; //7bit const UINT32 MMS_UINTVAR_LENGTH_2 = 0x00003fff; //14bit const UINT32 MMS_UINTVAR_LENGTH_3 = 0x001fffff; //21bit -#endif - - -bool _MmsDecodeInitialize(void) +static bool __MmsDecodeInitialize(void) { MmsInitMsgType(&mmsHeader.msgType); MmsInitMsgBody(&mmsHeader.msgBody); - - return true; -} - -bool __MmsSetMmsHeaderOwner(int msgID, char* pszNewOwner) -{ - if (pszNewOwner) { - // set new owner - MSG_DEBUG("__MmsSetMmsHeaderOwner: set (%s, msgID=%d)\n", pszNewOwner, msgID); - - if ((mmsHeader.pszOwner = (char*)malloc(strlen(pszNewOwner) + 1)) == NULL) - return false; - - memset (mmsHeader.pszOwner, 0, strlen(pszNewOwner) + 1) ; - - strcpy(mmsHeader.pszOwner, pszNewOwner); - mmsHeader.bActive = true; - mmsHeader.msgID = msgID; - } else { - // delete current owner - if (mmsHeader.pszOwner) { - MSG_DEBUG("__MmsSetMmsHeaderOwner: free (%s %d)\n", mmsHeader.pszOwner, msgID); - free(mmsHeader.pszOwner); - mmsHeader.pszOwner = NULL; - } - mmsHeader.bActive = false; - mmsHeader.msgID = -1; - } - return true; } - -void _MmsInitHeader() +void MmsInitHeader() { mmsHeader.type = MMS_MSGTYPE_ERROR; @@ -191,10 +196,10 @@ void _MmsInitHeader() mmsHeader.version = MMS_VERSION; mmsHeader.date = 0; - MsgFreeHeaderAddress(mmsHeader.pFrom); - MsgFreeHeaderAddress(mmsHeader.pTo); - MsgFreeHeaderAddress(mmsHeader.pCc); - MsgFreeHeaderAddress(mmsHeader.pBcc); + __MsgFreeHeaderAddress(mmsHeader.pFrom); + __MsgFreeHeaderAddress(mmsHeader.pTo); + __MsgFreeHeaderAddress(mmsHeader.pCc); + __MsgFreeHeaderAddress(mmsHeader.pBcc); mmsHeader.pFrom = NULL; mmsHeader.pTo = NULL; @@ -234,16 +239,26 @@ void _MmsInitHeader() memset(mmsHeader.szMsgID, 0, MMS_MSG_ID_LEN + 1); mmsHeader.msgSize = 0; -#ifdef __SUPPORT_DRM__ mmsHeader.drmType = MSG_DRM_TYPE_NONE; -#endif - _MmsDecodeInitialize(); + __MmsDecodeInitialize(); } +void MmsReleaseHeader(MmsHeader *mms) +{ + __MsgFreeHeaderAddress(mms->pFrom); + __MsgFreeHeaderAddress(mms->pTo); + __MsgFreeHeaderAddress(mms->pCc); + __MsgFreeHeaderAddress(mms->pBcc); + + mmsHeader.pFrom = NULL; + mmsHeader.pTo = NULL; + mmsHeader.pCc = NULL; + mmsHeader.pBcc = NULL; +} -void _MmsCleanDecodeBuff(void) +static void __MmsCleanDecodeBuff(void) { memset(gpMmsDecodeBuf1, 0, gMmsDecodeMaxLen + 1); memset(gpMmsDecodeBuf2, 0, gMmsDecodeMaxLen + 1); @@ -252,19 +267,18 @@ void _MmsCleanDecodeBuff(void) gMmsDecodeBufLen = 0; } - -void _MmsRegisterDecodeBuffer(char *pInBuff1, char *pInBuff2, int maxLen) +void MmsRegisterDecodeBuffer() { - gpMmsDecodeBuf1 = pInBuff1; - gpMmsDecodeBuf2 = pInBuff2; + gpMmsDecodeBuf1 = gszMmsLoadBuf1; + gpMmsDecodeBuf2 = gszMmsLoadBuf2; gpCurMmsDecodeBuff = NULL; gCurMmsDecodeBuffPos = 0; - gMmsDecodeMaxLen = maxLen; + gMmsDecodeMaxLen = MSG_MMS_DECODE_BUFFER_MAX; gMmsDecodeCurOffset = 0; gMmsDecodeBufLen = 0; } -void _MmsUnregisterDecodeBuffer(void) +void MmsUnregisterDecodeBuffer(void) { gpMmsDecodeBuf1 = NULL; gpMmsDecodeBuf2 = NULL; @@ -276,12 +290,11 @@ void _MmsUnregisterDecodeBuffer(void) } -int _MmsGetDecodeOffset(void) +static int __MmsGetDecodeOffset(void) { return (gMmsDecodeCurOffset - gMmsDecodeBufLen + gCurMmsDecodeBuffPos); } - static bool __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLength) { if (*pLength <= valueLength) { @@ -336,6 +349,7 @@ static bool __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLengt */ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) { + MSG_BEGIN(); UINT16 fieldCode = 0xffff; UINT16 fieldValue = 0xffff; UINT8 oneByte = 0xff; @@ -355,124 +369,124 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) char *pLimitData = NULL; int nRead = 0; - MSG_DEBUG("MmsBinaryDecodeMsgHeader: pFile=%d, total len=%d\n", pFile, totalLength); + MSG_DEBUG("pFile ptr : [%p], total len = [%d]", pFile, totalLength); - _MmsCleanDecodeBuff(); + __MmsCleanDecodeBuff(); - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: fail to load to buffer \n"); + MSG_FATAL("fail to load to buffer"); goto __CATCH; } - while (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength)) { + while (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength)) { fieldCode = oneByte & 0x7f; - switch (_MmsGetBinaryType(MmsCodeFieldCode, fieldCode)) { + switch (MmsGetBinaryType(MmsCodeFieldCode, fieldCode)) { case MMS_CODE_RESPONSESTATUS: + { + MmsResponseStatus resposeStatus = MMS_RESPSTATUS_ERROR; - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: responseStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("responseStatus GetOneByte fail"); goto __CATCH; } - fieldValue = _MmsGetBinaryType(MmsCodeResponseStatus, (UINT16)(oneByte & 0x7F)); - - if (fieldValue == 0xFFFF) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: responseStatus error\n"); - goto __CATCH; - } + fieldValue = oneByte; - if (fieldValue >= 0x0044 && fieldValue <= 0x005F) { - fieldValue = 0x0040; - } else if (fieldValue >= 0x006A && fieldValue <= 0x007F) { - fieldValue = 0x0060; + // range 197 to 223 as it does to the value 192 (Error-transient-failure). + // range 236 to 255 as it does to the value 224 (Error-permanent-failure). + if (fieldValue >= 197 && fieldValue <= 223) { + fieldValue = 192; + } else if (fieldValue >= 236 && fieldValue <= 255) { + fieldValue = 224; } - mmsHeader.responseStatus = (MmsResponseStatus)fieldValue; + resposeStatus = (MmsResponseStatus)MmsGetBinaryType(MmsCodeResponseStatus, (UINT16)(fieldValue & 0x7F)); - MSG_DEBUG("MmsBinaryDecodeMsgHeader: response status = %s\n", MmsDebugGetResponseStatus(mmsHeader.responseStatus)); + mmsHeader.responseStatus = (MmsResponseStatus)resposeStatus; + MSG_SEC_INFO("X-Mms-Response-Status = [0x%02x][0x%02x][%s]", oneByte, fieldValue, MmsDebugGetResponseStatus(mmsHeader.responseStatus)); break; - + } case MMS_CODE_RETRIEVESTATUS: + { + MmsRetrieveStatus RetrieveStatus = MMS_RETRSTATUS_ERROR; - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieveStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("retrieveStatus GetOneByte fail"); goto __CATCH; } - fieldValue = _MmsGetBinaryType(MmsCodeRetrieveStatus, (UINT16)(oneByte & 0x7F)); + fieldValue = oneByte; - if (fieldValue == 0xFFFF) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieveStatus error\n"); - goto __CATCH; + //195 to 223 as it does to the value 192 (Error-transient-failure). + //228 to 255 as it does to the value 224 (Error-permanent-failure). + if (fieldValue >= 195 && fieldValue <= 223) { + fieldValue = 192; // 192; Error-transient-failure + } else if (fieldValue >= 228 && fieldValue <= 255) { + fieldValue = 224; //224; Error-permanent-failure } - if (fieldValue >= 0x0043 && fieldValue <= 0x005F) { - fieldValue = 0x0040; // 192; Error-transient-failure - } else if (fieldValue >= 0x0064 && fieldValue <= 0x007F) { - fieldValue = 0x0060; //224; Error-permanent-failure - } + RetrieveStatus = (MmsRetrieveStatus)MmsGetBinaryType(MmsCodeRetrieveStatus, (UINT16)(fieldValue & 0x7F)); - mmsHeader.retrieveStatus = (MmsRetrieveStatus)fieldValue; + mmsHeader.retrieveStatus = (MmsRetrieveStatus)RetrieveStatus; - MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieve status = %s\n", - MmsDebugGetRetrieveStatus(mmsHeader.retrieveStatus)); + MSG_SEC_INFO("X-Mms-Retrieve-Status = [0x%02x][0x%02x][%s]", oneByte, fieldValue, MmsDebugGetRetrieveStatus(mmsHeader.retrieveStatus)); break; - + } case MMS_CODE_RESPONSETEXT: if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szResponseText, MMS_LOCALE_RESP_TEXT_LEN + 1, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_RESPONSETEXT \n"); + MSG_DEBUG("invalid MMS_CODE_RESPONSETEXT"); goto __CATCH; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: response text = %s\n", mmsHeader.szResponseText); + MSG_SEC_INFO("X-Mms-Response-Text = [%s]", mmsHeader.szResponseText); break; case MMS_CODE_RETRIEVETEXT: if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szRetrieveText, MMS_LOCALE_RESP_TEXT_LEN + 1, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_RETRIEVETEXT \n"); + MSG_DEBUG("invalid MMS_CODE_RETRIEVETEXT"); goto __CATCH; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieve text = %s\n", mmsHeader.szResponseText); + MSG_SEC_INFO("X-Mms-Retrieve-Text = [%s]", mmsHeader.szRetrieveText); break; case MMS_CODE_MSGID: if (__MmsBinaryDecodeText(pFile, mmsHeader.szMsgID, MMS_MSG_ID_LEN + 1, totalLength) < 0) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_MSGID is invalid\n"); + MSG_DEBUG("MMS_CODE_MSGID is invalid"); goto __CATCH; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg id = %s\n", mmsHeader.szMsgID); + MSG_SEC_INFO("Message-ID =[%s]", mmsHeader.szMsgID); - if (MsgStrlen (mmsHeader.szMsgID) > 2) - MsgMIMERemoveQuote (mmsHeader.szMsgID); + if (strlen(mmsHeader.szMsgID) > 2) + __MsgMIMERemoveQuote (mmsHeader.szMsgID); break; case MMS_CODE_SUBJECT: if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN + 1, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_SUBJECT \n"); + MSG_DEBUG("invalid MMS_CODE_SUBJECT"); goto __CATCH; } - pLimitData = (char *)malloc(MSG_LOCALE_SUBJ_LEN + 1); + pLimitData = (char *)calloc(1, MSG_LOCALE_SUBJ_LEN + 1); if (pLimitData == NULL) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : pLimitData malloc fail \n"); + MSG_DEBUG("pLimitData calloc fail"); goto __CATCH; } - nRead = MsgCutUTFString((unsigned char*)pLimitData, MSG_LOCALE_SUBJ_LEN + 1, (unsigned char*)mmsHeader.szSubject, MSG_SUBJ_LEN); - MSG_DEBUG("MmsBinaryDecodeMsgHeader : Subject edit.. \n"); + nRead = __MsgCutUTFString((unsigned char*)pLimitData, MSG_LOCALE_SUBJ_LEN + 1, (unsigned char*)mmsHeader.szSubject, MSG_SUBJ_LEN); + MSG_DEBUG("Subject edit.."); if (nRead > MSG_LOCALE_SUBJ_LEN) { memset(mmsHeader.szSubject, 0 , sizeof(mmsHeader.szSubject)); @@ -487,7 +501,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) pLimitData = NULL; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: subject = %s\n", mmsHeader.szSubject); + MSG_SEC_INFO("Subject = [%s]", mmsHeader.szSubject); break; case MMS_CODE_FROM: @@ -495,12 +509,12 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) /* Value-length (Address-present-token Encoded-string-value | Insert-address-token) */ if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_FROM is invalid\n"); + MSG_DEBUG("MMS_CODE_FROM is invalid"); goto __CATCH; } - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: MMS_CODE_FROM GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("MMS_CODE_FROM GetOneByte fail"); goto __CATCH; } @@ -508,19 +522,19 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) valueLength--; - if (oneByte == (_MmsGetBinaryValue(MmsCodeAddressType, MMS_ADDRESS_PRESENT_TOKEN)|0x80)) { + if (oneByte == (MmsGetBinaryValue(MmsCodeAddressType, MMS_ADDRESS_PRESENT_TOKEN)|0x80)) { if (valueLength > 0) { mmsHeader.pFrom = __MmsDecodeEncodedAddress(pFile, totalLength); if (mmsHeader.pFrom == NULL) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_FROM __MmsDecodeEncodedAddress fail\n"); + MSG_DEBUG("MMS_CODE_FROM __MmsDecodeEncodedAddress fail"); goto __CATCH; } } else { - mmsHeader.pFrom = (MsgHeaderAddress *)malloc(sizeof(MsgHeaderAddress)); + mmsHeader.pFrom = (MsgHeaderAddress *)calloc(1, sizeof(MsgHeaderAddress)); if (mmsHeader.pFrom == NULL) goto __CATCH; - mmsHeader.pFrom->szAddr = (char *)malloc(1); + mmsHeader.pFrom->szAddr = (char *)calloc(1, 1); if (mmsHeader.pFrom->szAddr == NULL) { free(mmsHeader.pFrom); mmsHeader.pFrom = NULL; @@ -531,14 +545,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) mmsHeader.pFrom->pNext = NULL; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: from = %s\n", mmsHeader.pFrom->szAddr); + MSG_SEC_INFO("From = [%s]", mmsHeader.pFrom->szAddr); // DRM_TEMPLATE - end - } else if (oneByte == (_MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN)|0x80)) { + } else if (oneByte == (MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN)|0x80)) { /* Present Token only */ - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_FROM insert token\n"); + MSG_SEC_INFO("From = [insert token]"); } else { /* from data broken */ - MSG_DEBUG("MmsBinaryDecodeMsgHeader: from addr broken\n"); + MSG_WARN("from addr broken"); gCurMmsDecodeBuffPos--; goto __CATCH; } @@ -548,7 +562,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) pAddr = __MmsDecodeEncodedAddress(pFile, totalLength); if (pAddr == NULL) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_TO __MmsDecodeEncodedAddress fail\n"); + MSG_DEBUG("MMS_CODE_TO __MmsDecodeEncodedAddress fail"); goto __CATCH; } @@ -561,14 +575,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) pLastTo = pAddr; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: to = %s\n", mmsHeader.pTo->szAddr); + MSG_SEC_INFO("To = [%s]", pAddr->szAddr); break; case MMS_CODE_BCC: pAddr = __MmsDecodeEncodedAddress(pFile, totalLength); if (pAddr == NULL) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_BCC __MmsDecodeEncodedAddress fail\n"); + MSG_DEBUG("MMS_CODE_BCC __MmsDecodeEncodedAddress fail"); goto __CATCH; } @@ -581,14 +595,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) pLastBcc = pAddr; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: bcc = %s\n", mmsHeader.pBcc->szAddr); + MSG_SEC_INFO("Bcc = [%s]", pAddr->szAddr); break; case MMS_CODE_CC: pAddr = __MmsDecodeEncodedAddress(pFile, totalLength); if (pAddr == NULL) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_CC __MmsDecodeEncodedAddress fail\n"); + MSG_DEBUG("MMS_CODE_CC __MmsDecodeEncodedAddress fail"); goto __CATCH; } @@ -600,44 +614,45 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) pLastCc->pNext = pAddr; pLastCc = pAddr; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: cc = %s\n", mmsHeader.pCc->szAddr); + MSG_SEC_INFO("Cc = [%s]", pAddr->szAddr); break; case MMS_CODE_CONTENTLOCATION: if (__MmsBinaryDecodeText(pFile, mmsHeader.szContentLocation, MMS_LOCATION_LEN + 1, totalLength) < 0) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_CONTENTLOCATION is invalid\n"); + MSG_DEBUG("MMS_CODE_CONTENTLOCATION is invalid"); goto __CATCH; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: content location = %s\n", mmsHeader.szContentLocation); + MSG_SEC_DEBUG("X-Mms-Content-Location = [%s]", mmsHeader.szContentLocation); break; case MMS_CODE_DATE: if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.date, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_DATE is invalid\n"); + MSG_DEBUG("MMS_CODE_DATE is invalid"); goto __CATCH; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: date = %d\n", mmsHeader.date); + + MSG_SEC_INFO("Date = [%u][%d]", mmsHeader.date, (const time_t *)&mmsHeader.date); break; case MMS_CODE_DELIVERYREPORT: - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: deliveryReport GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("deliveryReport GetOneByte fail"); goto __CATCH; } - fieldValue = _MmsGetBinaryType(MmsCodeDeliveryReport, (UINT16)(oneByte & 0x7F)); + fieldValue = MmsGetBinaryType(MmsCodeDeliveryReport, (UINT16)(oneByte & 0x7F)); if (fieldValue == 0xFFFF) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: deliveryReport error\n"); + MSG_DEBUG("deliveryReport error"); goto __CATCH; } mmsHeader.deliveryReport = (MmsReport)fieldValue; - MSG_DEBUG("MmsBinaryDecodeMsgHeader: delivery report=%s\n", MmsDebugGetMmsReport(mmsHeader.deliveryReport)); + MSG_SEC_INFO("X-Mms-Delivery-Report =[0x%02x][%s]", oneByte, MmsDebugGetMmsReport(mmsHeader.deliveryReport)); break; case MMS_CODE_DELIVERYTIME: @@ -645,24 +660,24 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) /* value_length (absolute-token Long-integer | Relative-token Long-integer) */ if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_DELIVERYTIME \n"); + MSG_DEBUG("invalid MMS_CODE_DELIVERYTIME"); goto __CATCH; } - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: delivery time GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("delivery time GetOneByte fail"); goto __CATCH; } //DRM_TEMPLATE - start valueLength--; - if (oneByte == (_MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) { + if (oneByte == (MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) { mmsHeader.deliveryTime.type = MMS_TIMETYPE_ABSOLUTE; if (valueLength > 0) { if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.deliveryTime.time, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_DELIVERYTIME\n"); + MSG_DEBUG("invalid MMS_CODE_DELIVERYTIME"); goto __CATCH; } } @@ -671,11 +686,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) mmsHeader.deliveryTime.type = MMS_TIMETYPE_RELATIVE; if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&mmsHeader.deliveryTime.time, &tmpIntLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : __MmsBinaryDecodeInteger fail...\n"); + MSG_DEBUG("__MmsBinaryDecodeInteger fail..."); goto __CATCH; } } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: delivery type=%d, time=%d\n", mmsHeader.deliveryTime.type, mmsHeader.deliveryTime.time); + MSG_SEC_INFO("X-Mms-Delivery-Time : type = [%d], time= [%u]", mmsHeader.deliveryTime.type, mmsHeader.deliveryTime.time); break; case MMS_CODE_EXPIRYTIME: @@ -683,24 +698,24 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) /* value_length(absolute-token Long-integer | Relative-token Long-integer) */ if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_EXPIRYTIME \n"); + MSG_DEBUG("invalid MMS_CODE_EXPIRYTIME"); goto __CATCH; } - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: expiry time GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("expiry time GetOneByte fail"); goto __CATCH; } // DRM_TEMPLATE - start valueLength--; - if (oneByte == (_MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) { + if (oneByte == (MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) { mmsHeader.expiryTime.type = MMS_TIMETYPE_ABSOLUTE; if (valueLength > 0) { if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.expiryTime.time, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_EXPIRYTIME is invalid\n"); + MSG_DEBUG("MMS_CODE_EXPIRYTIME is invalid"); goto __CATCH; } } @@ -709,122 +724,125 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) mmsHeader.expiryTime.type = MMS_TIMETYPE_RELATIVE; if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&mmsHeader.expiryTime.time, &tmpIntLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : __MmsBinaryDecodeInteger fail...\n"); + MSG_INFO("__MmsBinaryDecodeInteger fail..."); goto __CATCH; } } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: expiry = %d\n", mmsHeader.expiryTime.time); + + MSG_DEBUG("X-Mms-Expiry : type = [%d], time = [%u]", mmsHeader.expiryTime.type, mmsHeader.expiryTime.time); break; case MMS_CODE_MSGCLASS: /* Class-value = Class-identifier | Token Text */ - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgClass GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgClass GetOneByte fail"); goto __CATCH; } if (oneByte > 0x7f) { /* Class-identifier */ - mmsHeader.msgClass = (MmsMsgClass)_MmsGetBinaryType(MmsCodeMsgClass, (UINT16)(oneByte & 0x7F)); + mmsHeader.msgClass = (MmsMsgClass)MmsGetBinaryType(MmsCodeMsgClass, (UINT16)(oneByte & 0x7F)); } else { if (__MmsBinaryDecodeText(pFile, szGarbageBuff, MSG_STDSTR_LONG, totalLength) < 0) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: 1. __MmsBinaryDecodeText fail. (class)\n"); + MSG_DEBUG("1. __MmsBinaryDecodeText fail. (class)"); goto __CATCH; } } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg class=%s\n", MmsDebugGetMsgClass(mmsHeader.msgClass)); + + MSG_SEC_INFO("X-Mms-Message-Class =[%s]", MmsDebugGetMsgClass(mmsHeader.msgClass)); break; case MMS_CODE_MSGSIZE: if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.msgSize, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_MSGSIZE is invalid\n"); + MSG_DEBUG("MMS_CODE_MSGSIZE is invalid"); goto __CATCH; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg size = %d\n", mmsHeader.msgSize); + + MSG_SEC_INFO("X-Mms-Message-Size = [%d]", mmsHeader.msgSize); break; case MMS_CODE_MSGSTATUS: - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } - mmsHeader.msgStatus = (msg_delivery_report_status_t)_MmsGetBinaryType(MmsCodeMsgStatus, (UINT16)(oneByte & 0x7F)); - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg status=%s \n", MmsDebugGetMsgStatus(mmsHeader.msgStatus)) ; + mmsHeader.msgStatus = (msg_delivery_report_status_t)MmsGetBinaryType(MmsCodeMsgStatus, (UINT16)(oneByte & 0x7F)); + MSG_SEC_INFO("X-Mms-Status = [%s]", MmsDebugGetMsgStatus(mmsHeader.msgStatus)); break; case MMS_CODE_MSGTYPE: - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } - mmsHeader.type = (MmsMsgType)_MmsGetBinaryType(MmsCodeMsgType, (UINT16)(oneByte & 0x7F)); - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg type=%s\n", MmsDebugGetMsgType(mmsHeader.type)); + mmsHeader.type = (MmsMsgType)MmsGetBinaryType(MmsCodeMsgType, (UINT16)(oneByte & 0x7F)); + MSG_SEC_INFO("X-Mms-Message-Type = [%s]", MmsDebugGetMsgType(mmsHeader.type)); break; case MMS_CODE_PRIORITY: - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } - mmsHeader.priority = (MmsPriority)_MmsGetBinaryType(MmsCodePriority, (UINT16)(oneByte & 0x7F)); - MSG_DEBUG("MmsBinaryDecodeMsgHeader: priority=%d\n", mmsHeader.priority); + mmsHeader.priority = (MmsPriority)MmsGetBinaryType(MmsCodePriority, (UINT16)(oneByte & 0x7F)); + MSG_SEC_INFO("X-Mms-Priority = [%d]", mmsHeader.priority); break; case MMS_CODE_READREPLY: - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } - mmsHeader.readReply = (MmsReport)_MmsGetBinaryType(MmsCodeReadReply, (UINT16)(oneByte & 0x7F)); - MSG_DEBUG("MmsBinaryDecodeMsgHeader: read reply=%s \n", MmsDebugGetMmsReport(mmsHeader.readReply)); + mmsHeader.readReply = (MmsReport)MmsGetBinaryType(MmsCodeReadReply, (UINT16)(oneByte & 0x7F)); + MSG_SEC_INFO("X-Mms-Read-Report = [0x%02x][%s]", oneByte, MmsDebugGetMmsReport(mmsHeader.readReply)); break; case MMS_CODE_REPORTALLOWED: - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } - mmsHeader.reportAllowed = (MmsReportAllowed)_MmsGetBinaryType(MmsCodeReportAllowed, (UINT16)(oneByte & 0x7F)); - MSG_DEBUG("MmsBinaryDecodeMsgHeader: mmsHeader.reportAllowed=%d\n", MmsDebugGetMmsReportAllowed(mmsHeader.reportAllowed)); + mmsHeader.reportAllowed = (MmsReportAllowed)MmsGetBinaryType(MmsCodeReportAllowed, (UINT16)(oneByte & 0x7F)); + MSG_SEC_INFO("X-Mms-Report-Allowed = [%d]", MmsDebugGetMmsReportAllowed(mmsHeader.reportAllowed)); break; case MMS_CODE_SENDERVISIBILLITY: - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } - mmsHeader.hideAddress= (MmsSenderVisible)!(_MmsGetBinaryType(MmsCodeSenderVisibility, (UINT16)(oneByte &0x7F))); - MSG_DEBUG("MmsBinaryDecodeMsgHeader: sender visible=%d \n", mmsHeader.hideAddress); + mmsHeader.hideAddress= (MmsSenderVisible)!(MmsGetBinaryType(MmsCodeSenderVisibility, (UINT16)(oneByte &0x7F))); + MSG_SEC_INFO("X-Mms-Sender-Visibility = [%d]", mmsHeader.hideAddress); break; case MMS_CODE_TRID: if (__MmsBinaryDecodeText(pFile, mmsHeader.szTrID, MMS_TR_ID_LEN + 1, totalLength) < 0) { - MSG_DEBUG("Transaction ID Too Long \n"); + MSG_DEBUG("Transaction ID Too Long"); goto __CATCH; } - MSG_DEBUG("MmsBinaryDecodeMsgHeader: trID = %s\n", mmsHeader.szTrID); + MSG_SEC_INFO("X-Mms-Transaction-Id = [%s]", mmsHeader.szTrID); break; case MMS_CODE_VERSION: - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } mmsHeader.version = oneByte; - MSG_DEBUG("MmsBinaryDecodeMsgHeader: ver = 0x%x\n", mmsHeader.version); + MSG_SEC_INFO("X-Mms-MMS-Version = [0x%02x]", mmsHeader.version); break; case MMS_CODE_CONTENTTYPE: @@ -843,26 +861,26 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) /* Read-status-value = Read | Deleted without being read */ - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } - mmsHeader.readStatus = (msg_read_report_status_t)_MmsGetBinaryType(MmsCodeReadStatus, (UINT16)(oneByte & 0x7F)); - MSG_DEBUG("MmsBinaryDecodeMsgHeader: read status=%s\n", MmsDebugGetMmsReadStatus(mmsHeader.readStatus)); + mmsHeader.readStatus = (msg_read_report_status_t)MmsGetBinaryType(MmsCodeReadStatus, (UINT16)(oneByte & 0x7F)); + MSG_SEC_INFO("X-Mms-Read-Status = [%s]", MmsDebugGetMmsReadStatus(mmsHeader.readStatus)); break; case MMS_CODE_REPLYCHARGING: /* Reply-charging-value = Requested | Requested text only | Accepted | Accepted text only */ - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } - mmsHeader.replyCharge.chargeType = (MmsReplyChargeType)_MmsGetBinaryType(MmsCodeReplyCharging, (UINT16)(oneByte & 0x7F)); - MSG_DEBUG("MmsBinaryDecodeMsgHeader: mmsHeader.reply charge=%d\n", mmsHeader.replyCharge.chargeType); + mmsHeader.replyCharge.chargeType = (MmsReplyChargeType)MmsGetBinaryType(MmsCodeReplyCharging, (UINT16)(oneByte & 0x7F)); + MSG_SEC_INFO("X-Mms-Reply-Charging = [%d]", mmsHeader.replyCharge.chargeType); break; case MMS_CODE_REPLYCHARGINGDEADLINE: @@ -870,16 +888,16 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) /* Reply-charging-deadline-value = Value-length (Absolute-token Date-value | Relative-token Delta-seconds-value) */ if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_REPLYCHARGINGDEADLINE \n"); + MSG_DEBUG("invalid MMS_CODE_REPLYCHARGINGDEADLINE"); goto __CATCH; } - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("msgStatus GetOneByte fail"); goto __CATCH; } - if (oneByte == (_MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80)) { + if (oneByte == (MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80)) { mmsHeader.replyCharge.deadLine.type = MMS_TIMETYPE_ABSOLUTE; } else { mmsHeader.replyCharge.deadLine.type = MMS_TIMETYPE_RELATIVE; @@ -890,31 +908,33 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) if (valueLength > 0) { if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.replyCharge.deadLine.time, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_REPLYCHARGINGDEADLINE is invalid\n"); + MSG_DEBUG("MMS_CODE_REPLYCHARGINGDEADLINE is invalid"); goto __CATCH; } } + + MSG_SEC_INFO("X-Mms-Reply-Charging-Deadline : type = [%d], time = [%u]", mmsHeader.replyCharge.deadLine.type, mmsHeader.replyCharge.deadLine.time); // DRM_TEMPLATE - end break; case MMS_CODE_REPLYCHARGINGID: /* Reply-charging-ID-value = Text-string */ - if (__MmsBinaryDecodeText(pFile, mmsHeader.replyCharge.szChargeID, MMS_MSG_ID_LEN + 1, totalLength) < 0) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: 1. __MmsBinaryDecodeText fail. (szReplyChargingID)\n"); + MSG_DEBUG("1. __MmsBinaryDecodeText fail. (szReplyChargingID)"); goto __CATCH; } + SECURE_SLOGD("X-Mms-Reply-Charging-ID = [%s]", mmsHeader.replyCharge.szChargeID); break; case MMS_CODE_REPLYCHARGINGSIZE: /* Reply-charging-size-value = Long-integer */ - if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.replyCharge.chargeSize, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_REPLYCHARGINGSIZE is invalid\n"); + MSG_DEBUG("MMS_CODE_REPLYCHARGINGSIZE is invalid"); goto __CATCH; } + MSG_SEC_INFO("X-Mms-Reply-Charging-Size = [%d]", mmsHeader.replyCharge.chargeSize); break; case MMS_CODE_PREVIOUSLYSENTBY: @@ -925,18 +945,23 @@ 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"); + MSG_DEBUG("1. invalid MMS_CODE_PREVIOUSLYSENTBY"); goto __CATCH; } if (__MmsBinaryDecodeInteger(pFile, &tmpInteger, &tmpIntLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : 2. invalid MMS_CODE_PREVIOUSLYSENTBY \n"); + MSG_DEBUG("2. invalid MMS_CODE_PREVIOUSLYSENTBY"); goto __CATCH; } if (__MmsBinaryDecodeEncodedString(pFile, szGarbageBuff, MSG_STDSTR_LONG, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_RETRIEVETEXT \n"); + MSG_DEBUG("invalid MMS_CODE_RETRIEVETEXT"); goto __CATCH; } break; @@ -949,23 +974,27 @@ 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"); + MSG_DEBUG("1. invalid MMS_CODE_PREVIOUSLYSENTDATE"); goto __CATCH; } if (__MmsBinaryDecodeInteger(pFile, &tmpInteger, &tmpIntLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : 2. invalid MS_CODE_PREVIOUSLYSENTDATE \n"); + MSG_DEBUG("2. invalid MS_CODE_PREVIOUSLYSENTDATE"); goto __CATCH; } if (__MmsDecodeLongInteger(pFile, (UINT32*)&tmpInteger, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader : 3. invalid MMS_CODE_PREVIOUSLYSENTDATE \n"); + MSG_DEBUG("3. invalid MMS_CODE_PREVIOUSLYSENTDATE"); goto __CATCH; } break; - default: /* @@ -983,7 +1012,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) oneByte = 0x00; - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; @@ -991,11 +1020,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) while ((oneByte < 0x80) && (remainLength > 0)) { if (__MmsBinaryDecodeCheckAndDecreaseLength(&remainLength, 1) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: __MmsBinaryDecodeCheckAndDecreaseLength fail\n"); + MSG_DEBUG("__MmsBinaryDecodeCheckAndDecreaseLength fail"); goto __CATCH; } - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgHeader: responseStatus GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("responseStatus GetOneByte fail"); goto __CATCH; } } @@ -1006,7 +1035,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) break; } /* switch */ - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; @@ -1015,83 +1044,71 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) __RETURN: - MSG_DEBUG("MmsBinaryDecodeMsgHeader: success\n"); - return true; - + if (mmsHeader.pTo == NULL && pLastTo) { + free(pLastTo); + } -__CATCH: - MSG_DEBUG("MmsBinaryDecodeMsgHeader: failed\n"); + if (mmsHeader.pCc == NULL && pLastCc) { + free(pLastCc); + } - return false; -} + if (mmsHeader.pBcc == NULL && pLastBcc) { + free(pLastBcc); + } -#ifdef FEATURE_JAVA_MMS -// for JAVA MMS AppId - check later whether it can be handled by MmsBinaryDecodeMsgHeader -bool MmsBinaryDecodeContentType(FILE *pFile, char *szFilePath, int totalLength) -{ - int length = 0; + MSG_INFO("## Decode Header Success ##"); + MSG_END(); + return true; - MSG_DEBUG("MmsBinaryDecodeContentType:\n"); - if (szFilePath != NULL) - strncpy(mmsHeader.msgType.szOrgFilePath, szFilePath, strlen(szFilePath)); - mmsHeader.msgType.offset = _MmsGetDecodeOffset() - 1; // + Content-Type code value +__CATCH: - // read data(2K) from msg file(/User/Msg/Inbox/5) to gpCurMmsDecodeBuff for decoding - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, - &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2, - gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeContentType: fail to load to buffer \n"); - goto __CATCH; + if (mmsHeader.pTo == NULL && pLastTo) { + free(pLastTo); } - // msg's type [ex] related, mixed, single part (jpg, amr and etc) - length = MmsBinaryDecodeContentType(pFile, &mmsHeader.msgType, totalLength); - if (length == -1) { - MSG_DEBUG("MmsBinaryDecodeContentType: MMS_CODE_CONTENTTYPE is fail\n"); - goto __CATCH; + if (mmsHeader.pCc == NULL && pLastCc) { + free(pLastCc); } - MSG_DEBUG("Content-Type: Application-ID:%s Reply-To-Application-ID:%s",mmsHeader.msgType.param.szApplicationID, mmsHeader.msgType.param.szReplyToApplicationID); - - return true; -__CATCH: + if (mmsHeader.pBcc == NULL && pLastBcc) { + free(pLastBcc); + } + MSG_FATAL("## Decode Header Fail ##"); + MSG_END(); return false; } -#endif bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength) { + MSG_BEGIN(); + int length = 0; int offset = 0; - MsgMultipart *pMultipart = NULL; - - MSG_DEBUG("MmsBinaryDecodeMsgBody:\n"); - if (szFilePath != NULL) - strncpy(mmsHeader.msgType.szOrgFilePath, szFilePath , strlen(szFilePath)); + snprintf(mmsHeader.msgType.szOrgFilePath, sizeof(mmsHeader.msgType.szOrgFilePath), "%s", szFilePath); - mmsHeader.msgType.offset = _MmsGetDecodeOffset() - 1; // + Content-Type code value + mmsHeader.msgType.offset = __MmsGetDecodeOffset() - 1; // + Content-Type code value // read data(2K) from msg file(/User/Msg/Inbox/5) to gpCurMmsDecodeBuff for decoding - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMsgBody: fail to load to buffer \n"); + MSG_DEBUG("fail to load to buffer"); goto __CATCH; } // msg's type [ex] related, mixed, single part (jpg, amr and etc) - length = MmsBinaryDecodeContentType(pFile, &mmsHeader.msgType, totalLength); + length = __MmsBinaryDecodeContentType(pFile, &mmsHeader.msgType, totalLength); if (length == -1) { - MSG_DEBUG("MmsBinaryDecodeMsgBody: MMS_CODE_CONTENTTYPE is fail\n"); + MSG_DEBUG("MMS_CODE_CONTENTTYPE is fail"); goto __CATCH; } - mmsHeader.msgType.size = length + 1; // + Content-Type code value - mmsHeader.msgBody.offset = _MmsGetDecodeOffset(); + mmsHeader.msgType.size = length + 1; // + Content-Type code value + mmsHeader.msgBody.offset = __MmsGetDecodeOffset(); switch (mmsHeader.msgType.type) { case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED: @@ -1105,14 +1122,14 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength) case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: case MIME_APPLICATION_VND_OMA_DRM_CONTENT: - MSG_DEBUG("__MmsBinaryMsgBodyDecode: Decode multipart\n"); + MSG_DEBUG("Decode Multipart"); - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; - if (MmsBinaryDecodeMultipart(pFile, szFilePath, &mmsHeader.msgType, &mmsHeader.msgBody, totalLength) == false) { - MSG_DEBUG("__MmsBinaryMsgBodyDecode: MmsBinaryDecodeMultipart is fail.\n"); + if (__MmsBinaryDecodeMultipart(pFile, szFilePath, &mmsHeader.msgType, &mmsHeader.msgBody, totalLength) == false) { + MSG_DEBUG("MmsBinaryDecodeMultipart is fail."); goto __CATCH; } break; @@ -1120,15 +1137,14 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength) default: /* Single part message ---------------------------------------------- */ + MSG_DEBUG("Decode Singlepart"); - strcpy(mmsHeader.msgBody.szOrgFilePath, szFilePath); - - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; - if (MmsBinaryDecodePartBody(pFile, totalLength - mmsHeader.msgBody.offset, totalLength) == false) { - MSG_DEBUG("__MmsBinaryMsgBodyDecode: MmsBinaryDecodePartBody is fail.(Single Part)\n"); + if (__MmsBinaryDecodePartBody(pFile, totalLength - mmsHeader.msgBody.offset, totalLength) == false) { + MSG_DEBUG("MmsBinaryDecodePartBody is fail.(Single Part)"); goto __CATCH; } @@ -1138,48 +1154,17 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength) break; } -#ifdef __SUPPORT_DRM__ - mmsHeader.drmType = MsgGetDRMType(&mmsHeader.msgType, &mmsHeader.msgBody); -#endif - __RETURN: - + MSG_END(); return true; __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; } -#if MMS_ENABLE_EXTEND_CFM -// DRM (Extended)CFM -// Get Extended CFM value. -static bool __MmsConvertString2Bool(char *pszValue) -{ - if (!strcasecmp(pszValue, "no")) - return true; - - return false; -} -#endif - -bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, int totalLength) +static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, int totalLength) { + MSG_BEGIN(); UINT8 oneByte = 0; int charSetLen = 0; char *szTypeString = NULL; @@ -1195,11 +1180,9 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i * WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.107) */ - MSG_DEBUG("MmsBinaryDecodeParameter: \n"); - while (valueLength > 0) { - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeContentType: paramCode _MmsBinaryDecodeGetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("paramCode _MmsBinaryDecodeGetOneByte fail"); goto __CATCH; } @@ -1210,7 +1193,7 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i case 0x81: // charset if (__MmsBinaryDecodeCharset(pFile, (UINT32*)&(pMsgType->param.charset), &charSetLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeContentType : __MmsBinaryDecodeCharset fail.\n"); + MSG_DEBUG("__MmsBinaryDecodeCharset fail."); goto __CATCH; } @@ -1226,12 +1209,12 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i MSG_FILENAME_LEN_MAX -5, // MSG_LOCALE_FILENAME_LEN_MAX + 1, : change @ 110(Ui code have to change for this instead of DM) totalLength); if (length < 0) { - MSG_DEBUG("MmsBinaryDecodeContentType : __MmsDecodeGetFilename fail. (name parameter)\n"); + MSG_DEBUG("__MmsDecodeGetFilename fail. (name parameter)"); goto __CATCH; } - if (MsgCheckFileNameHasInvalidChar(pMsgType->param.szName)) { - _MsgReplaceInvalidFileNameChar(pMsgType->param.szName, '_'); + if (__MsgCheckFileNameHasInvalidChar(pMsgType->param.szName)) { + __MsgReplaceInvalidFileNameChar(pMsgType->param.szName, '_'); } if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, length) == false) @@ -1244,12 +1227,12 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i memset(pMsgType->param.szFileName, 0, sizeof(pMsgType->param.szFileName)); length = __MmsDecodeGetFilename(pFile, pMsgType->param.szFileName, MSG_FILENAME_LEN_MAX -5, totalLength); if (length < 0) { - MSG_DEBUG("MmsBinaryDecodeContentType : __MmsDecodeGetFilename fail. (filename parameter)\n"); + MSG_DEBUG("__MmsDecodeGetFilename fail. (filename parameter)"); goto __CATCH; } - if (MsgCheckFileNameHasInvalidChar(pMsgType->param.szFileName)) { - _MsgReplaceInvalidFileNameChar(pMsgType->param.szFileName, '_'); + if (__MsgCheckFileNameHasInvalidChar(pMsgType->param.szFileName)) { + __MsgReplaceInvalidFileNameChar(pMsgType->param.szFileName, '_'); } if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, length) == false) @@ -1259,14 +1242,13 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i case 0x89: //type = Constrained-encoding = Extension-Media | Short-integer - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeContentType: type _MmsBinaryDecodeGetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("type _MmsBinaryDecodeGetOneByte fail"); goto __CATCH; } if (oneByte > 0x7f) { - pMsgType->param.type = _MmsGetBinaryType(MmsCodeContentType, - (UINT16)(oneByte & 0x7f)); + pMsgType->param.type = MimeGetMimeIntFromBi((UINT16)(oneByte & 0x7f));//MmsGetBinaryType(MmsCodeContentType,(UINT16)(oneByte & 0x7f)); if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, 1) == false) goto __RETURN; } else { @@ -1274,8 +1256,7 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i textLength = 0; szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); - pMsgType->param.type = _MmsGetTextType(MmsCodeContentType, szTypeString); - + pMsgType->param.type = MimeGetMimeIntFromMimeString(szTypeString); if (szTypeString) { free(szTypeString); szTypeString = NULL; @@ -1326,7 +1307,7 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i default: if (paramCode > 0x7F) { - MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter\n"); + MSG_DEBUG("Unsupported parameter"); // In case of the last byte of Parameter field, it should be returned without decreasing the gCurMmsDecodeBuffPos value. valueLength++; @@ -1357,7 +1338,7 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i /* Text-value */ if (__MmsBinaryDecodeInteger(pFile, &integer, &intLen, totalLength) == true) { - MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter(%d)\n", integer); + MSG_DEBUG("Unsupported parameter(%d)\n", integer); if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, intLen) == false) goto __RETURN; } else { @@ -1371,28 +1352,33 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i strncpy(pMsgType->param.szBoundary, szTypeValue, MSG_BOUNDARY_LEN); #ifdef FEATURE_JAVA_MMS } else if (strcasecmp(szTypeString, "Application-ID") == 0) { - pMsgType->param.szApplicationID = (char*) malloc(textLength + 1); - memset(pMsgType->param.szApplicationID, 0, textLength + 1); - strncpy(pMsgType->param.szApplicationID, szTypeValue, textLength); - MSG_DEBUG("Application-ID:%s",pMsgType->param.szApplicationID); + pMsgType->param.szApplicationID = (char*) calloc(1, textLength + 1); + if (pMsgType->param.szApplicationID) { + memset(pMsgType->param.szApplicationID, 0, textLength + 1); + strncpy(pMsgType->param.szApplicationID, szTypeValue, textLength); + MSG_SEC_DEBUG("Application-ID:%s",pMsgType->param.szApplicationID); + } } else if (strcasecmp(szTypeString,"Reply-To-Application-ID") == 0) { - pMsgType->param.szReplyToApplicationID= (char*) malloc(textLength + 1); - memset(pMsgType->param.szReplyToApplicationID, 0, textLength + 1); - strncpy(pMsgType->param.szReplyToApplicationID, szTypeValue, textLength); - MSG_DEBUG("ReplyToApplication-ID:%s",pMsgType->param.szReplyToApplicationID); + pMsgType->param.szReplyToApplicationID = (char*) calloc(1, textLength + 1); + if (pMsgType->param.szReplyToApplicationID) { + memset(pMsgType->param.szReplyToApplicationID, 0, textLength + 1); + strncpy(pMsgType->param.szReplyToApplicationID, szTypeValue, textLength); + MSG_SEC_DEBUG("ReplyToApplication-ID:%s",pMsgType->param.szReplyToApplicationID); + } #endif } + + MSG_DEBUG("Unsupported parameter(%s)\n", szTypeValue); free(szTypeValue); szTypeValue = NULL; - MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter(%s)\n", szTypeValue); if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, textLength) == false) goto __RETURN; } } if (szTypeString) { - MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter(%s)\n", szTypeString); + MSG_DEBUG("Unsupported parameter(%s)\n", szTypeString); free(szTypeString); szTypeString = NULL; } @@ -1410,19 +1396,14 @@ __RETURN: szTypeString = NULL; } + MSG_END(); return true; __CATCH: - - if (szTypeString) { - free(szTypeString); - szTypeString = NULL; - } + MSG_END(); return false; } - - /** * Decode Encoded Content type * @@ -1430,8 +1411,9 @@ __CATCH: * @param pMsgType [out] Decoded MsgType * @return Decoded address list */ -int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength) +static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength) { + MSG_BEGIN(); UINT8 oneByte = 0; char *szTypeString = NULL; int valueLength = 0; @@ -1449,9 +1431,6 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength) * Media-type = (Well-known-media | Extension-Media) *(Parameter) */ - MSG_DEBUG("MmsBinaryDecodeContentType: decoding content type..\n"); - - length = __MmsDecodeValueLength(pFile, (UINT32*)&valueLength, totalLength); if (length <= 0) { /* @@ -1461,14 +1440,17 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength) * Short-integer = OCTET(1xxx xxxx) */ - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeContentType: Constrained-media _MmsBinaryDecodeGetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("Constrained-media _MmsBinaryDecodeGetOneByte fail"); goto __CATCH; } if (oneByte > 0x7F) { /* Short-integer */ - pMsgType->type = _MmsGetBinaryType(MmsCodeContentType, (UINT16)(oneByte & 0x7F)); + pMsgType->type = MimeGetMimeIntFromBi((UINT16)(oneByte & 0x7f)); + + MSG_SEC_DEBUG("Constrained-media : Short-integer : Content Type = [0x%04x], MimeType = [0x%04x]", oneByte, pMsgType->type); + length = 1; } else { char *pszTemp = NULL; @@ -1480,14 +1462,19 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength) szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); if (szTypeString && (strchr(szTypeString, ';')) != NULL) { - pszTemp = _MsgGetStringUntilDelimiter(szTypeString, ';'); + + MSG_SEC_DEBUG("Constrained-media : Extension-Media : Content Type with delimiter = [%s]", szTypeString); + + pszTemp = __MsgGetStringUntilDelimiter(szTypeString, ';'); if (pszTemp) { free(szTypeString); szTypeString = pszTemp; } } - pMsgType->type = _MmsGetTextType(MmsCodeContentType, szTypeString); + pMsgType->type = MimeGetMimeIntFromMimeString(szTypeString); + + MSG_SEC_DEBUG("Constrained-media : Extension-Media : Content Type = [%s], MimeType = [0x%04x]", szTypeString, pMsgType->type); length = textLength; @@ -1504,14 +1491,15 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength) length += valueLength; - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeContentType: Well-known-media _MmsBinaryDecodeGetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("Well-known-media _MmsBinaryDecodeGetOneByte fail"); goto __CATCH; } if (oneByte > 0x7F) { /* Well-known-media */ - pMsgType->type = _MmsGetBinaryType(MmsCodeContentType, (UINT16)(oneByte & 0x7F)); + pMsgType->type = MimeGetMimeIntFromBi((UINT16)(oneByte & 0x7f)); + MSG_SEC_DEBUG("Content-general-form : Well-known-media : Content Type = [0x%04x], MimeType = [0x%04x]", oneByte, pMsgType->type); valueLength--; } else { /* Extension-Media */ @@ -1519,7 +1507,11 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength) textLength = 0; szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); - pMsgType->type = _MmsGetTextType(MmsCodeContentType, szTypeString); + + pMsgType->type = MimeGetMimeIntFromMimeString(szTypeString); + + MSG_SEC_DEBUG("Content-general-form : Extension-Media : Content Type = [%s], MimeType = [0x%04x]", szTypeString, pMsgType->type); + valueLength -= textLength; if (szTypeString) { @@ -1528,23 +1520,23 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength) } } - MSG_DEBUG("MmsBinaryDecodeContentType: content type=%s\n", MmsDebugGetMimeType((MimeType)pMsgType->type)); - + MSG_SEC_DEBUG("Content-Type = [%s]", MmsDebugGetMimeType((MimeType)pMsgType->type)); - if (MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeContentType: Content-Type parameter fail\n"); + if (__MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) { + MSG_DEBUG("Content-Type parameter fail"); goto __CATCH; } } + MSG_END(); return length; __CATCH: + MSG_END(); return -1; } - -bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, int totalLength) +static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, int totalLength) { UINT8 fieldCode = 0xff; int length = 0; @@ -1574,8 +1566,8 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in */ while (headerLen > 0) { - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodePartHeader: field code GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("field code GetOneByte fail"); goto __CATCH; } @@ -1590,72 +1582,64 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in switch (fieldCode) { case 0x0E: //Content-Location case 0x04: //Content-Location - - pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1); + { + pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1); if (pLatinBuff == NULL) goto __CATCH; length = __MmsBinaryDecodeText(pFile, pLatinBuff, MMS_CONTENT_ID_LEN + 1, totalLength); if (length == -1) { - MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeQuotedString fail.\n"); + MSG_DEBUG("__MmsBinaryDecodeQuotedString fail."); goto __CATCH; } - szSrc = MsgChangeHexString(pLatinBuff); - + szSrc = __MsgConvertLatin2UTF8FileName(pLatinBuff); if (szSrc) { - strcpy(pLatinBuff, szSrc); + snprintf(pMsgType->szContentLocation, sizeof(pMsgType->szContentLocation), "%s", szSrc); + MSG_DEBUG("Content Location : [%s]", pMsgType->szContentLocation); free(szSrc); szSrc = NULL; } - textLength = strlen(pLatinBuff); - - if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) { - MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n"); - goto __CATCH; - } - free(pLatinBuff); pLatinBuff = NULL; if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false) goto __RETURN; - + } break; case 0x40: // Content-ID + { + char szContentID[MMS_CONTENT_ID_LEN + 1] = {0, }; - pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1); + pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1); if (pLatinBuff == NULL) goto __CATCH; length = __MmsBinaryDecodeQuotedString(pFile, pLatinBuff, MMS_CONTENT_ID_LEN + 1, totalLength); if (length == -1) { - MSG_DEBUG("MmsBinaryDecodePartHeader : Content-ID __MmsBinaryDecodeQuotedString fail.\n"); + MSG_DEBUG("Content-ID __MmsBinaryDecodeQuotedString fail."); goto __CATCH; } - szSrc = MsgChangeHexString(pLatinBuff); - + szSrc = __MsgConvertLatin2UTF8FileName(pLatinBuff); if (szSrc) { - strcpy(pLatinBuff, szSrc); + snprintf(szContentID, sizeof(szContentID), "%s", szSrc); + MSG_DEBUG("Content ID : [%s]", szContentID); free(szSrc); szSrc = NULL; } - textLength = strlen(pLatinBuff); - if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) { - MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n"); - goto __CATCH; - } free(pLatinBuff); pLatinBuff = NULL; + MmsRemoveLessGreaterChar(szContentID, pMsgType->szContentID, sizeof(pMsgType->szContentID));//remove "< >" + if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false) goto __RETURN; - + } break; case 0x2E: // Content-Disposition @@ -1677,8 +1661,8 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in } - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition value GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("Disposition value GetOneByte fail"); goto __CATCH; } @@ -1686,18 +1670,18 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in valueLength--; if (oneByte >= 0x80) { - pMsgType->disposition = _MmsGetBinaryType(MmsCodeMsgDisposition, (UINT16)(oneByte & 0x7F)); + pMsgType->disposition = MmsGetBinaryType(MmsCodeMsgDisposition, (UINT16)(oneByte & 0x7F)); - if (pMsgType->disposition == INVALID_HOBJ) { - MSG_DEBUG("MmsBinaryDecodePartHeader : Content-Disposition _MmsGetBinaryType fail.\n"); + if (pMsgType->disposition == -1) { + MSG_DEBUG("Content-Disposition MmsGetBinaryType fail."); pMsgType->disposition = MSG_DISPOSITION_ATTACHMENT; // default } if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, 1) == false) goto __RETURN; - if (MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition parameter fail\n"); + if (__MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) { + MSG_DEBUG("Disposition parameter fail"); goto __CATCH; } @@ -1708,14 +1692,16 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in gCurMmsDecodeBuffPos--; valueLength++; - pLatinBuff = (char *)malloc(MSG_FILENAME_LEN_MAX); + pLatinBuff = (char *)calloc(1, MSG_FILENAME_LEN_MAX); + if (pLatinBuff == NULL) + goto __CATCH; memset(pLatinBuff, 0, MSG_FILENAME_LEN_MAX); textLength = __MmsBinaryDecodeText(pFile, pLatinBuff, MSG_FILENAME_LEN_MAX-1, totalLength); if (textLength < 0) { - MSG_DEBUG("MmsBinaryDecodePartHeader : Content-Disposition decodingfail. \n"); + MSG_DEBUG("Content-Disposition decodingfail."); goto __CATCH; } free(pLatinBuff); @@ -1726,9 +1712,9 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in valueLength -= textLength; - if (MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) + if (__MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition parameter fail\n"); + MSG_DEBUG("Disposition parameter fail"); goto __CATCH; } @@ -1741,8 +1727,8 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in case 0x0B: //Content-Encoding - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition value GetOneByte fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("Disposition value GetOneByte fail"); goto __CATCH; } @@ -1762,7 +1748,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in cTemp = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); if (cTemp == NULL) { - MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeText2 fail...\n"); + MSG_DEBUG("__MmsBinaryDecodeText2 fail..."); goto __CATCH; } @@ -1782,7 +1768,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in case 0x0D: //Content-Length if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&tmpInt, &tmpIntLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeInteger fail...\n"); + MSG_DEBUG("__MmsBinaryDecodeInteger fail..."); goto __CATCH; } @@ -1793,26 +1779,26 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in case 0x30: //X-Wap-Content-URI skip this value - MSG_DEBUG("MmsBinaryDecodePartHeader : X-Wap-Content-URI header.\n"); - pLatinBuff = (char *)malloc(MMS_TEXT_LEN); + MSG_DEBUG("X-Wap-Content-URI header."); + pLatinBuff = (char *)calloc(1, MMS_TEXT_LEN); if (pLatinBuff == NULL) goto __CATCH; length = __MmsBinaryDecodeText(pFile, pLatinBuff, MMS_TEXT_LEN, totalLength); if (length == -1) { - MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeQuotedString fail.\n"); + MSG_DEBUG(" __MmsBinaryDecodeQuotedString fail."); goto __CATCH; } - MSG_DEBUG("MmsBinaryDecodePartHeader : X-Wap-Content-URI header decoded. Value length %d\n", length); + MSG_DEBUG("X-Wap-Content-URI header decoded. Value length %d\n", length); free(pLatinBuff); pLatinBuff = NULL; if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false) goto __RETURN; - MSG_DEBUG("MmsBinaryDecodePartHeader : X-Wap-Content-URI header skipped.\n"); + MSG_DEBUG("X-Wap-Content-URI header skipped."); break; @@ -1828,13 +1814,13 @@ 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 = - ; Equivalent to the special RFC2616 charset value ¡°*¡± + ; Equivalent to the special RFC2616 charset value ��*�� */ int charset = 0; int charSetLen = 0; - MSG_DEBUG("MmsBinaryDecodePartHeader : Accept-charset. \n"); + MSG_DEBUG("Accept-charset."); length = __MmsDecodeValueLength(pFile, &valueLength, totalLength); if (length > 0) { @@ -1845,12 +1831,12 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&charset, &charSetLen, totalLength) == false) { // We only support the well-known-charset format - MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeInteger fail...\n"); + MSG_DEBUG("__MmsBinaryDecodeInteger fail..."); goto __CATCH; } if (charset > 0) - _MmsGetBinaryType(MmsCodeCharSet, (UINT16)charset); + MmsGetBinaryType(MmsCodeCharSet, (UINT16)charset); if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, charSetLen) == false) goto __RETURN; @@ -1862,23 +1848,23 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in /* Other Content-xxx headers : Have valueLength */ - MSG_DEBUG("MmsBinaryDecodePartHeader : unknown Value = 0x%x\n", oneByte); + MSG_WARN("unknown Value = 0x%x\n", oneByte); length = __MmsDecodeValueLength(pFile, &valueLength, totalLength); if (length <= 0) { - MSG_DEBUG("MmsBinaryDecodePartHeader : 1. invalid MMS_CODE_PREVIOUSLYSENTDATE \n"); + MSG_WARN("invalid MMS_CODE_PREVIOUSLYSENTDATE"); goto __CATCH; } if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false) goto __RETURN; - szTemp = (char *)malloc(valueLength); + szTemp = (char *)calloc(1, valueLength); if (szTemp == NULL) goto __CATCH; - if (_MmsBinaryDecodeGetBytes(pFile, szTemp, valueLength, totalLength) < 0) { - MSG_DEBUG("MmsBinaryDecodePartHeader : default _MmsBinaryDecodeGetBytes() fail\n"); + if (__MmsBinaryDecodeGetBytes(pFile, szTemp, valueLength, totalLength) == false) { + MSG_WARN("default _MmsBinaryDecodeGetBytes() fail"); if (szTemp) { free(szTemp); szTemp = NULL; @@ -1897,7 +1883,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in * Application-specific-value = Text-string */ - MSG_DEBUG(" MmsBinaryDecodePartHeader: Application-header = Token-text Application-specific-value \n"); + MSG_DEBUG(" Application-header = Token-text Application-specific-value"); gCurMmsDecodeBuffPos--; @@ -1906,14 +1892,14 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in textLength = 0; pCode = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); if (pCode == NULL) { - MSG_DEBUG("MmsBinaryDecodePartHeader: pCode is null\n"); + MSG_DEBUG("pCode is null"); goto __CATCH; } if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, textLength) == false) goto __RETURN; - MSG_DEBUG(" MmsBinaryDecodePartHeader: Token-text (%s) \n", pCode); + MSG_DEBUG(" Token-text (%s) \n", pCode); /* Application-specific-value */ @@ -1921,11 +1907,11 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in textLength = 0; pValue = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); if (pValue == NULL) { - MSG_DEBUG("MmsBinaryDecodePartHeader: pValue is null\n"); + MSG_DEBUG("pValue is null"); goto __CATCH; } - MSG_DEBUG(" MmsBinaryDecodePartHeader: Application-specific-value (%s) \n", pValue); + MSG_DEBUG(" Application-specific-value (%s) \n", pValue); pParam = strchr(pValue, MSG_CH_ADDR_DELIMETER); @@ -1934,44 +1920,48 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in *pParam = '\0'; } - switch (_MmsGetTextType(MmsCodeMsgBodyHeaderCode, pCode)) { + switch (MmsGetTextType(MmsCodeMsgBodyHeaderCode, pCode)) { case MMS_BODYHDR_TRANSFERENCODING: // Content-Transfer-Encoding - pMsgType->encoding = _MmsGetTextType(MmsCodeContentTransferEncoding, pValue); + pMsgType->encoding = MmsGetTextType(MmsCodeContentTransferEncoding, pValue); break; case MMS_BODYHDR_CONTENTID: // Content-ID + { + char szContentID[MMS_CONTENT_ID_LEN + 1]; - pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1); + pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1); if (pLatinBuff == NULL) { goto __CATCH; } - MsgMIMERemoveQuote (pValue); + __MsgMIMERemoveQuote (pValue); strncpy(pLatinBuff, pValue, MMS_MSG_ID_LEN); length = strlen(pLatinBuff); - if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0) + if (__MsgLatin2UTF ((unsigned char*)szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0) { - MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n"); + MSG_DEBUG("MsgLatin2UTF fail"); goto __CATCH; } + MmsRemoveLessGreaterChar(szContentID, pMsgType->szContentID, sizeof(pMsgType->szContentID));//remove "< >" + free(pLatinBuff); pLatinBuff = NULL; break; - + } case MMS_BODYHDR_CONTENTLOCATION: // Content-Location - pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1); + pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1); if (pLatinBuff == NULL) goto __CATCH; strncpy(pLatinBuff, pValue, MMS_MSG_ID_LEN); length = strlen(pLatinBuff); - if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0) { - MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n"); + if (__MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0) { + MSG_DEBUG("MsgLatin2UTF fail"); goto __CATCH; } @@ -1980,7 +1970,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in break; case MMS_BODYHDR_DISPOSITION: // Content-Disposition - pMsgType->disposition = _MmsGetTextType(MmsCodeMsgDisposition, pValue); + pMsgType->disposition = MmsGetTextType(MmsCodeMsgDisposition, pValue); break; case MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY: // DRM RO WAITING @@ -1992,7 +1982,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in } if (pParam) { - _MsgParseParameter(pMsgType, pParam + 1); + __MsgParseParameter(pMsgType, pParam + 1); *pParam = ch; } if (pCode) { @@ -2012,11 +2002,6 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in __RETURN: - if (pLatinBuff) { - free(pLatinBuff); - pLatinBuff = NULL; - } - if (szTemp) { free(szTemp); szTemp = NULL; @@ -2052,8 +2037,7 @@ __CATCH: return false; } - -bool MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength) +static bool __MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength) { int length = 0; @@ -2062,7 +2046,7 @@ bool MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength) goto __CATCH; } - MSG_DEBUG("MmsBinaryDecodeEntries: Number of Entries = %d\n", *npEntries); + MSG_INFO("Number of Entries = [%d]", *npEntries); return true; @@ -2070,9 +2054,7 @@ __CATCH: return false; } - - -bool MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength) +static bool __MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength) { int offset = 0; @@ -2081,27 +2063,26 @@ bool MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength) * the only information used with msgBody. * If you need, add here more information */ + MSG_BEGIN(); - MSG_DEBUG("MmsBinaryDecodePartBody: \n"); - - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); offset += bodyLength; if (MsgFseek(pFile, offset, SEEK_SET) < 0) { - MSG_DEBUG("MmsBinaryDecodePartBody: fail to seek file pointer \n"); + MSG_DEBUG("fail to seek file pointer"); goto __CATCH; } - _MmsCleanDecodeBuff(); + __MmsCleanDecodeBuff(); gMmsDecodeCurOffset = offset; if (offset >= totalLength) goto __RETURN; - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("_MmsBinaryDecodeGetOneByte: fail to load to buffer \n"); + MSG_DEBUG("fail to load to buffer"); goto __CATCH; } @@ -2114,195 +2095,148 @@ __CATCH: return false; } - -static bool MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength) +static bool __MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength) { if (offset > totalLength) goto __RETURN; if (MsgFseek(pFile, offset, SEEK_SET) < 0) { - MSG_DEBUG("MmsBinaryDecodeMovePointer: fail to seek file pointer \n"); + MSG_DEBUG("fail to seek file pointer"); goto __CATCH; } - _MmsCleanDecodeBuff(); + __MmsCleanDecodeBuff(); gMmsDecodeCurOffset = offset; if (offset == totalLength) goto __RETURN; - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMovePointer: fail to load to buffer \n"); - goto __CATCH; - } - -__RETURN: - return true; - -__CATCH: - return false; -} - - -bool MmsBinaryIsTextEncodedPart(FILE *pFile, int totalLength) -{ - UINT8 oneByte = 0; - int byteCount = 0; - - byteCount++; //check 0x0D - - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) + MSG_DEBUG("fail to load to buffer"); goto __CATCH; - - if (oneByte != 0x0D) { - //it can be started "--" without 0x0D 0x0A - if (oneByte != 0x2D) { - goto __CATCH; - } else { - byteCount++; // check 0x2D ('-') - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) - goto __CATCH; - - if (oneByte != 0x2D) { - goto __CATCH; - } else { - goto __RETURN; - } - } - } else { - byteCount++; //check 0x0A - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) - goto __CATCH; - - if (oneByte != 0x0A) { - goto __CATCH; - } else { - byteCount++; // check 0x2D ('-') - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) - goto __CATCH; - - if (oneByte != 0x2D) { - goto __CATCH; - } else { - byteCount++; // check 0x2D ('-') - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) - goto __CATCH; - - if (oneByte != 0x2D) { - goto __CATCH; - } else { - goto __RETURN; - } - } - } } __RETURN: - gCurMmsDecodeBuffPos -= byteCount; return true; __CATCH: - gCurMmsDecodeBuffPos -= byteCount; return false; } - -bool MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength) +static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength) { UINT32 nEntries = 0; MsgMultipart *pMultipart = NULL; MsgMultipart *pLastMultipart = NULL; - MsgMultipart *pPreMultipart = NULL; +// MsgMultipart *pPreMultipart = NULL; int offset = 0; int index = 0; MsgPresentationFactor factor = MSG_PRESENTATION_NONE; MsgPresentaionInfo presentationInfo; - MSG_DEBUG("MmsBinaryDecodeMultipart: total length=%d\n", totalLength); + MSG_DEBUG("pdu length = [%d]", totalLength); presentationInfo.factor = MSG_PRESENTATION_NONE; presentationInfo.pCurPresentation = NULL; presentationInfo.pPrevPart = NULL; - if (MmsBinaryDecodeEntries(pFile, &nEntries, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMultipart: MmsBinaryDecodeEntries is fail.\n"); + if (__MmsBinaryDecodeEntries(pFile, &nEntries, totalLength) == false) { + MSG_DEBUG("MmsBinaryDecodeEntries is fail."); goto __CATCH; } - while (nEntries) { - MSG_DEBUG("MmsBinaryDecodeMultipart: decoding %dth multipart\n", index); - - offset = _MmsGetDecodeOffset(); - if (offset >= totalLength) - goto __RETURN; + if (pMsgBody->body.pMultipart != NULL) { + pLastMultipart = pMsgBody->body.pMultipart; + MSG_DEBUG("previous multipart exist [%p]", pMsgBody->body.pMultipart); + } else { + MSG_DEBUG("first multipart"); + } + + while (nEntries) { + MSG_DEBUG("decoding [%d]th multipart", index); + + offset = __MmsGetDecodeOffset(); + if (offset >= totalLength) { + MSG_DEBUG("offset is over totalLength"); + break; + } - if ((pMultipart = MsgAllocMultipart()) == NULL) { - MSG_DEBUG("MmsBinaryDecodeMultipart: MsgAllocMultipart Fail \n"); + if ((pMultipart = MmsAllocMultipart()) == NULL) { + MSG_DEBUG("MsgAllocMultipart Fail"); goto __CATCH; } - if (MmsBinaryDecodeEachPart(pFile, szFilePath, &(pMultipart->type), pMultipart->pBody, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeMultipart: MmsBinaryDecodeEachPart is fail.(nEntries = %d)\n", nEntries); + if (__MmsBinaryDecodeEachPart(pFile, szFilePath, &(pMultipart->type), pMultipart->pBody, totalLength) == false) { + MSG_DEBUG("MmsBinaryDecodeEachPart is fail.(nEntries = %d)\n", nEntries); goto __CATCH; } - if (pMsgType->param.type == MIME_APPLICATION_SMIL) { - factor = MsgIsPresentationEx(&(pMultipart->type), pMsgType->param.szStart, (MimeType)pMsgType->param.type); + if (pMultipart->type.type == MIME_APPLICATION_SMIL) { + factor = __MsgIsPresentationEx(&(pMultipart->type), pMsgType->param.szStart, (MimeType)pMsgType->param.type); + if (factor == MSG_PRESENTATION_NONE) { + factor = MSG_PRESENTATION_TYPE_BASE; + } } else { factor = MSG_PRESENTATION_NONE; } + // priority 1 : content type match, 2: content location, 3: type if (presentationInfo.factor < factor) { // Presentation part presentationInfo.factor = factor; - presentationInfo.pPrevPart = pPreMultipart; + presentationInfo.pPrevPart = pLastMultipart; presentationInfo.pCurPresentation = pMultipart; } - if (pMsgBody->body.pMultipart == NULL) { - /* first multipart */ + /* first multipart */ + if (pLastMultipart == NULL) { pMsgBody->body.pMultipart = pMultipart; - pLastMultipart = pMultipart; - pPreMultipart = NULL; - } else if (pLastMultipart != NULL) { - pPreMultipart = pLastMultipart; - - pLastMultipart->pNext = pMultipart; - pLastMultipart = pMultipart; + pLastMultipart = pMultipart; +// pPreMultipart = NULL; + } else { + pLastMultipart->pNext = pMultipart; + pLastMultipart = pMultipart; +// pPreMultipart = pMultipart; } pMsgType->contentSize += pMultipart->pBody->size; nEntries--; - pPreMultipart = pMultipart; - MmsDebugPrintMulitpartEntry(pMultipart, index++); + + MmsPrintMulitpart(pMultipart, index++); } pMsgBody->size = totalLength - pMsgBody->offset; -#ifdef __SUPPORT_DRM__ - if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_REQUIRED) -#endif - MsgConfirmPresentationPart(pMsgType, pMsgBody, &presentationInfo); + __MsgConfirmPresentationPart(pMsgType, pMsgBody, &presentationInfo); - if (MsgResolveNestedMultipart(pMsgType, pMsgBody) == false) { - MSG_DEBUG("MmsBinaryDecodeMultipart : MsgResolveNestedMultipart failed \n"); + if (__MsgResolveNestedMultipart(pMsgType, pMsgBody) == false) { + MSG_DEBUG("MsgResolveNestedMultipart failed"); goto __CATCH; } -__RETURN: +//__RETURN: return true; __CATCH: + if (pMultipart) { + if (pMultipart->pBody) { + free(pMultipart->pBody); + pMultipart->pBody = NULL; + } + + free(pMultipart); + pMultipart = NULL; + } + return false; } - -bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength) +static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength) { int length = 0; bool bSuccess = false; @@ -2310,72 +2244,67 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M UINT32 bodyLength = 0; int offset = 0; - MSG_DEBUG("MmsBinaryDecodeEachPart: total length=%d\n", totalLength); + MSG_DEBUG("pdu length = [%d]", totalLength); /* header length */ - if (__MmsBinaryDecodeUintvar(pFile, &headerLength, totalLength) <= 0) { - MSG_DEBUG("MmsBinaryDecodeEachPart: Get header length fail \n"); + MSG_DEBUG("Get header length fail"); goto __CATCH; } - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; - /* body length */ - if (__MmsBinaryDecodeUintvar(pFile, &bodyLength, totalLength) <= 0) { - MSG_DEBUG("MmsBinaryDecodeEachPart: Get body length fail\n"); + MSG_DEBUG("Get body length fail"); goto __CATCH; } - - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; - /* Content Type */ if (szFilePath != NULL) - strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath)); + snprintf(pMsgType->szOrgFilePath, sizeof(pMsgType->szOrgFilePath), "%s", szFilePath); - pMsgType->offset = _MmsGetDecodeOffset(); + pMsgType->offset = __MmsGetDecodeOffset(); pMsgType->size = headerLength; pMsgType->contentSize = bodyLength; if (pMsgType->offset > totalLength) goto __RETURN; - length = MmsBinaryDecodeContentType(pFile, pMsgType, totalLength); + length = __MmsBinaryDecodeContentType(pFile, pMsgType, totalLength); if (length <= 0) { - MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentType Fail \n"); + MSG_DEBUG("Decode contentType Fail"); goto __CATCH; } - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; /* Part Header */ - if (MmsBinaryDecodePartHeader(pFile, pMsgType, headerLength - length, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentHeader Fail \n"); + if (__MmsBinaryDecodePartHeader(pFile, pMsgType, headerLength - length, totalLength) == false) { + MSG_DEBUG("Decode contentHeader Fail"); goto __CATCH; } - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; /* Part Body */ if (szFilePath != NULL) - strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath)); + snprintf(pMsgBody->szOrgFilePath, sizeof(pMsgBody->szOrgFilePath), "%s", szFilePath); - pMsgBody->offset = _MmsGetDecodeOffset(); + pMsgBody->offset = __MmsGetDecodeOffset(); pMsgBody->size = bodyLength; if (pMsgBody->offset > totalLength) @@ -2391,1183 +2320,1114 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M case MIME_MULTIPART_RELATED: case MIME_MULTIPART_ALTERNATIVE: - MSG_DEBUG("MmsBinaryDecodeEachPart: Decode multipart\n"); - - if (MmsBinaryDecodeMultipart(pFile, szFilePath, pMsgType, pMsgBody, totalLength) == false) { - MSG_DEBUG("MmsBinaryDecodeEachPart: MmsBinaryDecodeMultipart is fail.\n"); + MSG_DEBUG("Multipart"); + if (__MmsBinaryDecodeMultipart(pFile, szFilePath, pMsgType, pMsgBody, totalLength) == false) { + MSG_DEBUG("MmsBinaryDecodeMultipart is fail"); goto __CATCH; } - offset = _MmsGetDecodeOffset(); - if (offset >= totalLength) - goto __RETURN; - - break; - - -#ifdef __SUPPORT_DRM__ - - case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: /* Contains forwardLock OR combined-delivery media part */ - MSG_DEBUG("MmsBinaryDecodeEachPart: MIME_APPLICATION_VND_OMA_DRM_MESSAGE Part \n"); - - if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_NOT_FIXED && MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_REQUIRED) { - - if (MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false) - goto __CATCH; - } else { - MmsDrm2SetConvertState(MMS_DRM2_CONVERT_REQUIRED); - - bSuccess = MmsBinaryDecodePartBody(pFile, bodyLength, totalLength); - if (bSuccess == false) { - MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentBody Fail \n"); - goto __CATCH; - } - } - offset = _MmsGetDecodeOffset(); - if (offset >= totalLength) - goto __RETURN; - - break; - - case MIME_APPLICATION_VND_OMA_DRM_CONTENT: /* Contains seperate-delivery media part (DCF) */ - - MSG_DEBUG("MmsBinaryDecodeEachPart: MIME_APPLICATION_VND_OMA_DRM_CONTENT Part \n"); - - if (MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false) - goto __CATCH; - - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; break; -#endif default: - MSG_DEBUG("MmsBinaryDecodeEachPart: Other normal Part \n"); + MSG_DEBUG("Normal Part"); - bSuccess = MmsBinaryDecodePartBody(pFile, bodyLength, totalLength); + bSuccess = __MmsBinaryDecodePartBody(pFile, bodyLength, totalLength); if (bSuccess == false) { - MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentBody Fail \n"); + MSG_DEBUG("Decode contentBody Fail"); goto __CATCH; } - offset = _MmsGetDecodeOffset(); + offset = __MmsGetDecodeOffset(); if (offset >= totalLength) goto __RETURN; break; } + MSG_END(); return true; __RETURN: - + MSG_END(); return true; __CATCH: - + MSG_END(); return false; } -#ifdef __SUPPORT_DRM__ -bool __MmsParseDCFInfo(FILE *pFile, MsgDRMInfo *pDrmInfo, int totalLength) +/* -------------------------------------------------------------------- + * + * B I N A R Y D E C D E U T I L I T Y + * + * --------------------------------------------------------------------*/ + +bool __MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength) { - UINT8 version = 0; - UINT8 contentTypeLen = 0; - UINT8 contentURILen = 0; - char *szContentType = NULL; - char *szContentURI = NULL; - - if (_MmsBinaryDecodeGetOneByte(pFile, &version, totalLength) == false) { - MSG_DEBUG("__MmsParseDCFInfo: [version] GetOneByte fail\n"); - goto __CATCH; - } + int length = gMmsDecodeMaxLen - gCurMmsDecodeBuffPos; - if (_MmsBinaryDecodeGetOneByte(pFile, &contentTypeLen, totalLength) == false) { - MSG_DEBUG("__MmsParseDCFInfo: [contentTypeLen] GetOneByte fail\n"); + if (pFile == NULL || pOneByte == NULL) + { + MSG_DEBUG("invalid file or buffer"); goto __CATCH; } - if (_MmsBinaryDecodeGetOneByte(pFile, &contentURILen, totalLength) == false) { - MSG_DEBUG("__MmsParseDCFInfo: [contentURILen] GetOneByte fail\n"); - goto __CATCH; + if (length < 1) { + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { + MSG_DEBUG("fail to load to buffer"); + goto __CATCH; + } } - //Get media content-type (mime-type) - szContentType = (char *)malloc(contentTypeLen + 1); - if (szContentType == NULL) - goto __CATCH; - - memset(szContentType, 0, contentTypeLen + 1); + *pOneByte = gpCurMmsDecodeBuff[gCurMmsDecodeBuffPos++]; - if (_MmsBinaryDecodeGetBytes(pFile, szContentType, contentTypeLen + 1, totalLength) < 0) { - MSG_DEBUG("__MmsParseDCFInfo : contentType is invalid\n"); - goto __CATCH; - } - gCurMmsDecodeBuffPos--; - pDrmInfo->contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szContentType); + return true; +__CATCH: + return false; +} - //Get content-ID - 1.remover "cid:", 2.resolve "%hexa", 3.and copy the string - szContentURI = (char *)malloc(contentURILen + 1); - if (szContentURI == NULL) - goto __CATCH; +/* + * @remark: bufLen < gMmsDecodeMaxLen + */ +bool __MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength) +{ + int length = gMmsDecodeMaxLen - gCurMmsDecodeBuffPos; + int i = 0; - memset(szContentURI, 0, contentURILen + 1); - if (_MmsBinaryDecodeGetBytes(pFile, szContentURI, contentURILen + 1, totalLength) < 0) { - MSG_DEBUG("__MmsParseDCFInfo : contentType is invalid\n"); + if (pFile == NULL || szBuff == NULL || bufLen == 0 || bufLen > gMmsDecodeMaxLen) goto __CATCH; - } - gCurMmsDecodeBuffPos--; - pDrmInfo->szContentURI = MsgResolveContentURI(szContentURI); + memset(szBuff, 0, bufLen); - if (szContentType) { - free(szContentType); - szContentType = NULL; + if (length < bufLen) { + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { + MSG_DEBUG("fail to load to buffer"); + goto __CATCH; + } } - if (szContentURI) { - free(szContentURI); - szContentURI = NULL; + for (i = 0; i < bufLen - 1; i++) { + szBuff[i] = gpCurMmsDecodeBuff[gCurMmsDecodeBuffPos++]; } - return true; + gCurMmsDecodeBuffPos++; //NULL -__CATCH: - - if (szContentType) { - free(szContentType); - szContentType = NULL; - } + return true; - if (szContentURI) { - free(szContentURI); - szContentURI = NULL; - } +__CATCH: return false; - } - -bool __MmsParseDCFHdr(FILE *pFile, MsgDRMInfo *pDrmInfo, UINT32 headerLen, int totalLength) +bool __MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength) { - char *szDCFHdr = NULL; - MsgType partType; - ULONG nRead = 0; - int offset = 0; - - /* add to parse DCF header such as, - * Right-Issuer, Content-Name, and Content-Description. - */ + int iPos = 0; - szDCFHdr = (char *)malloc(headerLen + 1); - if (szDCFHdr == NULL) { - MSG_DEBUG("__MmsParseDCFHdr: szDCFHdr alloc fail\n"); + if (pFile == NULL || szBuff == NULL || bufLen == 0) goto __CATCH; - } - memset(szDCFHdr, 0, headerLen + 1); - - offset = _MmsGetDecodeOffset(); - if (offset >= totalLength) - goto __RETURN; - if (MsgFseek(pFile, offset, SEEK_SET) < 0) - goto __CATCH; + memset(szBuff, 0, bufLen); - if ((nRead = MsgReadFile(szDCFHdr, sizeof(char), headerLen, pFile)) == 0){ + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { + MSG_DEBUG("fail to load to buffer"); goto __CATCH; } - szDCFHdr[nRead] = '\0'; - - _MsgInitMsgType(&partType); - _MsgParsePartHeader(&partType, szDCFHdr, headerLen); - pDrmInfo->szContentName = partType.drmInfo.szContentName; - pDrmInfo->szContentVendor = partType.drmInfo.szContentVendor; - pDrmInfo->szContentDescription = partType.drmInfo.szContentDescription; - pDrmInfo->szRightIssuer = partType.drmInfo.szRightIssuer; + while ((bufLen - iPos) >= gMmsDecodeMaxLen) { + if (__MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, gMmsDecodeMaxLen, totalLength) == false) { + MSG_DEBUG("__MmsBinaryDecodeGetBytes fail"); + goto __CATCH; + } - if (MmsBinaryDecodeMovePointer(pFile, offset + headerLen, totalLength) == false) - goto __CATCH; + iPos += gMmsDecodeMaxLen; + } -__RETURN: + if ((bufLen - iPos) > 0) { + if (__MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, (bufLen - iPos), totalLength) == false) { + MSG_DEBUG("__MmsBinaryDecodeGetBytes fail"); + goto __CATCH; + } - if (szDCFHdr) { - free(szDCFHdr); - szDCFHdr = NULL; + iPos += (bufLen - iPos); } return true; __CATCH: - - if (szDCFHdr) { - free(szDCFHdr); - szDCFHdr = NULL; - } - return false; } +/** + * Decode uintvar to 32bit unsigned integer + * + * @param pEncodedData [in] encoded data + * @param pUintVar [out] Decode uintvar (32bit unsigned integer) + * @return The length of uintvar (-1, if cannot be converted to a uintvar) + * + * 0 XXXXXXX -> 0-bit: continue bit & 1~7bit: integer value + * - ------- + */ +static const UINT32 uintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00100000, 0x08000000 }; -bool MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int bodyLength, int totalLength) +static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLength) { - int offset = 0; - char szTempFilePath[MSG_FILEPATH_LEN_MAX] = MSG_DATA_PATH"drm.dcf"; - char *pRawData = NULL; - bool isFileCreated = false; - - MSG_DEBUG("bodyLength: %d\n", bodyLength); - - offset = _MmsGetDecodeOffset(); + UINT8 count = 0; + UINT8 oneByte = 0; + UINT32 decodedUintvar = 0; + UINT8 iBuff[5] = {0}; + int length = MSG_MMS_DECODE_BUFFER_MAX - gCurMmsDecodeBuffPos; - if (offset >= totalLength) - goto __RETURN; - if (szFilePath != NULL) - strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath)); - if (szFilePath != NULL) - strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath)); + if (pFile == NULL || pUintVar == NULL) + return -1; - pRawData = (char *)malloc(bodyLength); - if (pRawData == NULL) { - MSG_DEBUG("pRawData alloc FAIL \n"); - goto __CATCH; + if (length < 5) { + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { + MSG_DEBUG("fail to load to buffer"); + goto __CATCH; + } } - if (MsgFseek(pFile, offset, SEEK_SET) < 0) { - MSG_DEBUG("MsgFseek() returns -1 \n"); - goto __CATCH; - } - if (MsgReadFile(pRawData, sizeof(char), bodyLength, pFile) != (size_t)bodyLength) { - MSG_DEBUG("FmReadFile() returns false \n"); - goto __CATCH; - } - if (MsgOpenCreateAndOverwriteFile(szTempFilePath, pRawData, bodyLength) == false) { - MSG_DEBUG("MsgOpenCreateAndOverwriteFile() returns false \n"); - goto __CATCH; - } + while (true) { + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) + goto __CATCH; - isFileCreated = true; - MSG_DEBUG("MmsDrm2GetConvertState() [%d]", MmsDrm2GetConvertState()); + if (oneByte > 0x7f) { + iBuff[count++] = oneByte; + } else { + iBuff[count++] = oneByte; + break; + } - if (pMsgType->type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE && (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_FINISH)) { - MmsDrm2SetConvertState(MMS_DRM2_CONVERT_REQUIRED); - } else { - if (MsgDRM2GetDRMInfo(szTempFilePath, pMsgType) == false) { - MSG_DEBUG("MsgDRM2GetDRMInfo() returns false \n"); + if (count > 4) { + MSG_DEBUG("legnth is too long"); goto __CATCH; } } - remove(szTempFilePath); - isFileCreated = false; - - if (MmsBinaryDecodeMovePointer(pFile, offset + bodyLength, totalLength) == false) - goto __CATCH; - -__RETURN: + for (int i = 0; i < count; i++) + decodedUintvar += (uintvarDecodeTable[i] * (iBuff[count-(i+1)]&0x7f)); - if (pRawData) { - free(pRawData); - pRawData = NULL; - } + *pUintVar = decodedUintvar; - return true; + return count; __CATCH: - if (isFileCreated) - remove(szTempFilePath); - - if (pRawData) { - free(pRawData); - pRawData = NULL; - } - - return false; + gCurMmsDecodeBuffPos -= count; + return -1; } - -bool MmsBinaryDecodeDRMMessage(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int fullBodyLength, int totalLength) +/** + * Decode uintvar to 32bit unsigned integer by uintvar length + * + * @param pEncodedData [in] uintvar encoded data + * @param length [in] length of integer value + * @return unsigned integer value + */ +static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int totalLength) { - int offset = 0; - char szTempFilePath[MSG_FILEPATH_LEN_MAX] = "/User/Msg/Mms/Temp/drm.dm"; - char *pRawData = NULL; - bool isFileCreated = false; + UINT32 i = 0; + UINT8 oneByte = 0; + char *pData = NULL; + union { + UINT32 integer; + UINT8 seg[4]; + } returner; - offset = _MmsGetDecodeOffset(); - if (offset >= totalLength) - goto __RETURN; + returner.integer = 0; - if (szFilePath != NULL) - strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath)); - if (szFilePath != NULL) - strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath)); + if (length > 4) + length = 4; - pRawData = (char *)malloc(fullBodyLength); - if (pRawData == NULL) { - MSG_DEBUG("pRawData alloc FAIL \n"); - goto __CATCH; - } + if (length == 1) + { + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("_MmsBinaryDecodeGetOneByte fail"); + return oneByte; + } - if (MsgFseek(pFile, offset, SEEK_SET) < 0) { - MSG_DEBUG("MsgFseek() returns -1 \n"); - goto __CATCH; + if (oneByte > 0x7f) { + return (oneByte & 0x7f); + } else { + return oneByte; + } } - if (MsgReadFile(pRawData, sizeof(char), fullBodyLength, pFile)!= (size_t)fullBodyLength) { - MSG_DEBUG("FmReadFile() returns false \n"); + if (length == 0) + return 0; + + pData = (char *)calloc(1, length + 1); + if (pData == NULL) { + MSG_DEBUG("pData alloc fail"); goto __CATCH; } + memset(pData, 0, length + 1); - if (MsgOpenCreateAndOverwriteFile(szTempFilePath, pRawData, fullBodyLength) == false) { - MSG_DEBUG("MsgOpenCreateAndOverwriteFile() returns false \n"); + if (__MmsBinaryDecodeGetBytes(pFile, pData, length + 1, totalLength) == false) { + MSG_DEBUG("_MmsBinaryDecodeGetOneByte fail"); goto __CATCH; } - isFileCreated = true; - if (strstr(szTempFilePath, ".dm")) { - char szConvertedFilePath[MSG_FILEPATH_LEN_MAX] = {0,}; + gCurMmsDecodeBuffPos--; // - NULL - if (MsgDrmConvertDmtoDcfType(szTempFilePath, szConvertedFilePath)) { - remove(szTempFilePath); - memset(szTempFilePath, 0, MSG_FILEPATH_LEN_MAX); - strncpy(szTempFilePath, szConvertedFilePath, MSG_FILEPATH_LEN_MAX-1); - } + for (i= 0; i < length; i++) + returner.seg[length - (i+1)] = pData[i]; + + if (pData) { + free(pData); + pData = NULL; } - if (MsgDRM2GetDRMInfo(szTempFilePath, pMsgType) == false) { - MSG_DEBUG("MsgDRM2GetDRMInfo() returns false \n"); - goto __CATCH; - } - - remove(szTempFilePath); - isFileCreated = false; - - if (MmsBinaryDecodeMovePointer(pFile, offset + fullBodyLength, totalLength) == false) - goto __CATCH; - -__RETURN: - - if (pRawData) { - free(pRawData); - pRawData = NULL; - } - return true; + return returner.integer; __CATCH: - if (isFileCreated) - remove(szTempFilePath); - - if (pRawData) { - free(pRawData); - pRawData = NULL; - } - return false; -} - -static int __MmsDrm2BinaryEncodeUintvarLen(UINT32 integer) -{ - UINT32 length = 0; - /* Find encoded unitvar length */ - if (integer <= MMS_UINTVAR_LENGTH_1) { - length = 1; - } else { - if (integer <= MMS_UINTVAR_LENGTH_2) { - length = 2; - } else { - if (integer <= MMS_UINTVAR_LENGTH_3) { - length = 3; - } else { - length = 4; - } - } + if (pData) { + free(pData); + pData = NULL; } - return length; + return returner.integer; } - -static bool __MmsDrm2BinaryEncodeUintvar(UINT32 integer, int length, char *pszOutput) +/** + * Decode uintvar to 32bit unsigned integer by uintvar length + * + * @param pEncodedData [in] uintvar encoded data + * @param pInteger [out] Decode integer value (long/short) + * @return unsigned integer value (-1, if cannot be converted to unsigned integer value) + */ +static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen, int totalLength) { - const char ZERO = 0x00; - int i = 2; - char szReverse[MSG_STDSTR_LONG] = {0, }; - + UINT8 oneByte = 0; + char *pData = NULL; union { - UINT32 integer; - char bytes[4]; - } source; - source.integer = integer; - memset(szReverse, 0, MSG_STDSTR_LONG); - - /* Seperate integer to 4 1 byte integer */ - szReverse[3] = source.bytes[3] & 0x0f; - szReverse[0] = source.bytes[0]; - szReverse[0] = szReverse[0] & 0x7f; - - while (length >= i) {// initially, i = 2 - /* Move integer bit to proper position */ - source.integer = source.integer << 1; - source.integer = source.integer >> 8; - source.bytes[3] = ZERO; - - /* Retrive 1 encode uintvar */ - szReverse[i-1] = source.bytes[0]; - szReverse[i-1] = szReverse[i-1] | 0x80; - i++; - } - - for (i=0; i < length; i++) - pszOutput[i] = szReverse[length - i - 1]; + UINT32 integer; + UINT8 seg[4]; + } returner; - return true; -} + if (pInteger == NULL) + return false; -static int __MmsDrm2GetEntriesValueLength(FILE *pFile, int orgOffset) -{ - char szEntries[5] = {0, }; - UINT8 oneByte = 0; - int j = 0; //j is the length of nEntries value + returner.integer = 0; + *pIntLen = 0; - if (MsgReadFile(szEntries, sizeof(char), 4, pFile) != (size_t)4) { - MSG_DEBUG("__MmsDrm2GetEntriesValueLength: FmReadFile() returns false \n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + MSG_DEBUG("GetOneByte fail"); return false; } - while (true) { - oneByte = szEntries[j++]; + if (oneByte < 0x1F) /* long integer : WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.86) */ + { + pData = (char *)calloc(1, oneByte + 1); + if (pData == NULL) { + MSG_DEBUG("pData mecalloc fail"); + goto __CATCH; + } + memset(pData, 0, oneByte + 1); - if (oneByte <= 0x7f) - break; - } + // Even NULL is copied in the _MmsBinaryDecodeGetBytes + if (__MmsBinaryDecodeGetBytes(pFile, pData, oneByte + 1, totalLength) == false) { + MSG_DEBUG("GetBytes fail"); + goto __CATCH; + } - //move file pointer to point nEntries - if (MsgFseek(pFile, orgOffset, SEEK_SET) < 0) { - MSG_DEBUG("__MmsDrm2GetEntriesValueLength: fail to seek file pointer\n"); - return false; - } + gCurMmsDecodeBuffPos--; // - NULL - return j; -} + int length = 0; + if (oneByte > 4) { + length = 4; + } else { + length = oneByte; + } + int i = 0; + for (i = 0; i < length; i++) + returner.seg[length - (i+1)] = pData[i]; -static bool __MmsDrm2WriteDataToConvertedFile(FILE *pSrcFile, FILE *pDestinationFile, char *pszMmsLoadTempBuf, int length, int bufLen) -{ - int loadLen = 0, totalLoadLen = 0, nRead = 0; + *pInteger = returner.integer; + *pIntLen = oneByte + 1; + } else if (oneByte >= 0x80) { + /* short integer : WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.86) */ + *pInteger = oneByte & 0x7f; + *pIntLen = 1; + } else { + goto __CATCH; + } - for (int i=0; i<(length/bufLen)+1; i++) { - loadLen = (length-totalLoadLen < bufLen) ? length-totalLoadLen : bufLen; + if (pData) { + free(pData); + pData = NULL; + } - memset(pszMmsLoadTempBuf, 0, MMS_DRM2_CONVERT_BUFFER_MAX + 1); + return true; - if (MsgReadFile(pszMmsLoadTempBuf, sizeof(char), loadLen, pSrcFile) != (size_t)loadLen) { - MSG_DEBUG("__MmsDrm2WriteDataToConvertedFile: FmReadFile() returns false \n"); - return false; - } +__CATCH: - if (MsgWriteFile(pszMmsLoadTempBuf, sizeof(char), loadLen, pDestinationFile) != (size_t)loadLen) { - MSG_DEBUG("__MmsDrm2WriteDataToConvertedFile: File Writing is failed.\n"); - return false; - } + gCurMmsDecodeBuffPos--; - totalLoadLen += nRead; + if (pData) { + free(pData); + pData = NULL; } - return true; + return false; } - -/************************************************************************* - * description : make new message file converting CD & FL part of original message file to SD type - * argument : void - * return value - - bool : result of converting -**************************************************************************/ -bool MmsDrm2ConvertMsgBody(char *szOriginFilePath) +/** + * Decode uintvar to 32bit unsigned integer by uintvar length + * + * @return 1 : Success + * 0 : This is not Value Length type data + * -1 : Requires System error report + */ +static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLength) { - FILE *pFile = NULL; - FILE *hConvertedFile = NULL; - FILE *hTempFile = NULL; - FILE *hFile = NULL; - MsgMultipart *pMultipart = NULL; - char szTempFilePath[MSG_FILEPATH_LEN_MAX] = MSG_DATA_PATH"Drm_Convert"; - char szTempFile[MSG_FILEPATH_LEN_MAX] = MSG_DATA_PATH"temp.dm"; - char *pszMmsLoadTempBuf = NULL; - char *pszOrgData = NULL; int length = 0; - int bufLen = MMS_DRM2_CONVERT_BUFFER_MAX; - int curOffset = 0; + UINT32 uintvar = 0; + UINT8 oneByte = 0; - MSG_DEBUG("start convert~~~~~~\n"); - pFile = MsgOpenFile(szOriginFilePath, "rb"); - if (pFile == NULL) { - MSG_DEBUG("Open decode temporary file fail\n"); - goto __CATCH; - } + /* + * value-length = short-length | (Length-quote Length) + * = 0~30 | 31 + Uintvar-length + */ - hConvertedFile = MsgOpenFile(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, "wb+"); - if (hConvertedFile == NULL) { - MSG_DEBUG("Open decode temporary file fail\n"); + if (pFile == NULL || pValueLength == NULL) goto __CATCH; - } - pszMmsLoadTempBuf = (char*)malloc(MMS_DRM2_CONVERT_BUFFER_MAX + 1); - if (pszMmsLoadTempBuf == NULL) { - MSG_DEBUG("malloc for pszMmsLoadTempBuf failed\n"); - goto __CATCH; - } - memset(pszMmsLoadTempBuf, 0, MMS_DRM2_CONVERT_BUFFER_MAX + 1); + *pValueLength = 0; - // MMS Header copy - length = mmsHeader.msgBody.offset; - if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) { - MSG_DEBUG("Write header data fail\n"); + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + gCurMmsDecodeBuffPos--; goto __CATCH; } - curOffset += length; //change offset + if (0x00 < oneByte && oneByte < 0x1F) { + /* short-length */ - // MMS Body copy - if (MsgIsMultipart(mmsHeader.msgType.type) == true) - { - // nEntries copy - length = __MmsDrm2GetEntriesValueLength(pFile, curOffset); // getting nEntries value's length + *pValueLength = oneByte; + length = 1; + } else if (oneByte == 0x1F) { + /* Length-quote = 0x1F */ - if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) { - MSG_DEBUG("Write nEntries fail\n"); + length = __MmsBinaryDecodeUintvar(pFile, &uintvar, totalLength); + if (length == -1) { + MSG_DEBUG(" __MmsBinaryDecodeUintvar fail.."); goto __CATCH; } + length ++; // + length-quote + *pValueLength = uintvar; + } else { + MSG_DEBUG("not a value length type data"); + gCurMmsDecodeBuffPos--; + return 0; + } - curOffset += length; //change offset + return length; - // each Multipart entry copy - pMultipart = mmsHeader.msgBody.body.pMultipart; +__CATCH: + MSG_DEBUG("getting data fail"); + return -1; +} - while (pMultipart) { - if (pMultipart->type.type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE) { - int orgDataLen = pMultipart->pBody->size; - int nSize = 0; +/** + * Decode uintvar to 32bit unsigned integer by uintvar length + * + * @return 1 : Success + * 0 : This is not Value Length type data + * -1 : Requires System error report + * @ defference : if there is not length-quote, consider it as short length. + */ +static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalLength) +{ + int length = 0; + UINT32 uintvar = 0; + UINT8 oneByte = 0; - MSG_DEBUG("Write MIME_APPLICATION_VND_OMA_DRM_MESSAGE multipart data(orgDataLen = %d).\n", orgDataLen); - pszOrgData = (char *)malloc(orgDataLen + 1); - if (pszOrgData == NULL) { - MSG_DEBUG("pszOrgData is NULL \n"); - goto __CATCH; - } - memset(pszOrgData, 0, orgDataLen + 1); + /* + * value-length = short-length | (Length-quote Length) + * = 0~30 | 31 + Uintvar-length + */ - // move file pointer to data - if (MsgFseek(pFile, pMultipart->pBody->offset, SEEK_SET) < 0) { - MSG_DEBUG("fail to seek file pointer 1\n"); - goto __CATCH; - } + if (pFile == NULL || pValueLength == NULL) + goto __CATCH; - if (MsgReadFile(pszOrgData, sizeof(char), orgDataLen, pFile) != (size_t)orgDataLen) { - MSG_DEBUG("FmReadFile() returns false for orgData\n"); - goto __CATCH; - } + *pValueLength = 0; - if((hFile = MsgOpenFile(szTempFile, "wb+")) == NULL) { - MSG_DEBUG("file open failed [%s]", szTempFile); - goto __CATCH; - } + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { + gCurMmsDecodeBuffPos--; + goto __CATCH; + } - if (MsgWriteFile(pszOrgData, sizeof(char), orgDataLen, hFile) != (size_t)orgDataLen) { - MSG_DEBUG("File write error"); - goto __CATCH; - } + if (0x00 < oneByte && oneByte < 0x1F) { + /* short-length */ - MsgFflush(hFile); - MsgCloseFile(hFile); + *pValueLength = oneByte; + length = 1; + } else if (oneByte == 0x1F) { + /* Length-quote = 0x1F */ - hFile = NULL; + length = __MmsBinaryDecodeUintvar(pFile, &uintvar, totalLength); + if (length == -1) { + MSG_DEBUG("__MmsBinaryDecodeUintvar fail.."); + goto __CATCH; + } + length ++; // + length-quote + *pValueLength = uintvar; + } else { + MSG_DEBUG("there is not length-quote, consider it as short length."); + *pValueLength = oneByte; + length = 1; + } - // --> invoking drm agent api, converting data part start - MSG_DEBUG("start data part convert by callling drm agent api\n"); + return length; - int ret = 0; - ret = MsgDrmConvertDmtoDcfType(szTempFile, szTempFilePath); - MSG_DEBUG("MsgDrmConvertDmtoDcfType returned %s", ret ? "true": "false"); +__CATCH: + MSG_DEBUG("getting data fail"); + return -1; +} - if (MsgGetFileSize(szTempFilePath, &nSize) == false) { - MSG_DEBUG("MsgGetFileSize error"); - goto __CATCH; - } - MSG_DEBUG("end data part convert(converted data len = %d)\n", nSize); +/** + * Decode QuotedString + * + * @param pEncodedData [in] QuotedString encoded data + * @param szBuff [out] Decoded quoted string + * @param bufLen [out] Buffer length + * @return length of quoted string + */ +static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, int totalLength) +{ + int iPos = 0; + int length = 0; + int readBytes = 0; + char *pData = NULL; + int returnLength = 0; - // move file pointer to the head of multipart - if (MsgFseek(pFile, curOffset, SEEK_SET) < 0) { - MSG_DEBUG("fail to seek file pointer 2\n"); - goto __CATCH; - } + /* + * Quoted-string = *TEXT End-of-string + * The TEXT encodes an RFC2616 Quoted-string with the enclosing quotation-marks <"> removed + */ - // read headerLen, dataLen - length = pMultipart->type.offset - curOffset; - memset(pszMmsLoadTempBuf, 0, MMS_DRM2_CONVERT_BUFFER_MAX + 1); - if (MsgReadFile(pszMmsLoadTempBuf, sizeof(char), length, pFile) != (size_t)length) { - MSG_DEBUG("FmReadFile() returns false for headerLen, dataLen\n"); - goto __CATCH; - } + if (pFile == NULL || szBuff == NULL || bufLen <= 0) + return -1; - curOffset += length; + memset(szBuff, 0, bufLen); - // change dataLen based on converted data - { - UINT8 oneByte = 0; - int j = 0; - int encodeLen = 0; - char szOutput[MSG_STDSTR_LONG] = {0, }; + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { + MSG_DEBUG("fail to load to buffer"); + goto __CATCH; + } - while (true) { - oneByte = pszMmsLoadTempBuf[j++]; + length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL - if (oneByte <= 0x7f) - break; - } + if (length == 0) + goto __RETURN; - encodeLen = __MmsDrm2BinaryEncodeUintvarLen((UINT32)nSize); - __MmsDrm2BinaryEncodeUintvar((UINT32)nSize, encodeLen, szOutput); + while (length > gMmsDecodeBufLen) { + if (gMmsDecodeBufLen <= 0) { + MSG_DEBUG("gMmsDecodeBufLen <= 0"); + MSG_DEBUG("%x %x %x %x %x", + gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2], + gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]); + MSG_DEBUG("%x %x %x %x %x", + gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7], + gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]); + MSG_DEBUG("%x %x %x %x %x", + gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12], + gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]); + MSG_DEBUG("%x %x %x %x %x", + gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17], + gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]); + goto __CATCH; + } - strncpy(&(pszMmsLoadTempBuf[j]), szOutput, encodeLen); - pszMmsLoadTempBuf[j+encodeLen] = '\0'; + pData = (char *)calloc(1, gMmsDecodeBufLen + 1); + if (pData == NULL) + goto __CATCH; - if (MsgWriteFile(pszMmsLoadTempBuf, sizeof(char), length, hConvertedFile) != (size_t)length) { - MSG_DEBUG("Drm2WriteConvertData: FmWriteFile() returns false for dateLen\n"); - goto __CATCH; - } - } - - - length = pMultipart->pBody->offset - pMultipart->type.offset; - - if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) { - MSG_DEBUG("Drm2WriteConvertData: Write content type, headers fail\n"); - goto __CATCH; - } + memset(pData, 0, gMmsDecodeBufLen + 1); - curOffset += length; + if (__MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false) + goto __CATCH; - // write converted data - hTempFile = MsgOpenFile(szTempFilePath, "rb"); - if (hTempFile == NULL) { - MSG_DEBUG("Open decode temporary file fail\n"); - goto __CATCH; - } + returnLength += gMmsDecodeBufLen; - length = nSize; + if ((bufLen - iPos) > 0) { + readBytes = (gMmsDecodeBufLen < (bufLen - iPos)) ? gMmsDecodeBufLen : (bufLen - iPos); + if (iPos == 0 && (pData[0] == MARK)) { + /* MARK: check first time only */ - if (__MmsDrm2WriteDataToConvertedFile(hTempFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) { - MSG_DEBUG("Write converted data fail\n"); - goto __CATCH; - } + strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1); + iPos += (readBytes - 1); + } else { + strncpy(szBuff + iPos, (char*)pData, readBytes); + iPos += readBytes; + } + } - if (hTempFile != NULL) { - MsgCloseFile(hTempFile); - hTempFile = NULL; - } + if (pData) { + free(pData); + pData = NULL; + } - curOffset += pMultipart->pBody->size; + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { + MSG_DEBUG("fail to load to buffer"); + goto __CATCH; + } + length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL + } /* while */ - // move file pointer to the head of multipart - if (MsgFseek(pFile, curOffset, SEEK_SET) < 0) { - MSG_DEBUG("fail to seek file pointer \n"); - goto __CATCH; - } - } else { // it doesn't need to convert if it is not CD or FL - MSG_DEBUG("Write normal multipart data\n"); + if (length > 0) { + pData = (char *)calloc(1, length); + if (pData == NULL) + goto __CATCH; - length = pMultipart->pBody->offset + pMultipart->pBody->size - curOffset; + if (__MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false) + goto __CATCH; - if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) { - MSG_DEBUG("Write multipart data fail \n"); - goto __CATCH; - } + returnLength += length; - curOffset += length; + if ((bufLen - iPos) > 0) { + /* read until NULL from raw data, and copy only string */ + readBytes = (length < (bufLen - iPos)) ? length : (bufLen - iPos); + if (iPos == 0 && (pData[0] == MARK)) { + /* MARK: check first time only */ + strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1); + iPos += (readBytes - 1); + } else { + strncpy(szBuff + iPos, (char*)pData, readBytes - 1); // + NULL + iPos += readBytes; } + } - pMultipart = pMultipart->pNext; + if (pData) { + free(pData); + pData = NULL; } } - MSG_DEBUG("end convert~~~~~~\n"); + szBuff[bufLen - 1] = '\0'; - if (pFile != NULL) { - MsgCloseFile(pFile); - pFile = NULL; - } + return returnLength; - if (hConvertedFile != NULL) { - MsgCloseFile(hConvertedFile); - hConvertedFile = NULL; - } +__RETURN: - if (hTempFile != NULL) { - MsgCloseFile(hTempFile); - hTempFile = NULL; - } + return length; - if (pszMmsLoadTempBuf) { - free(pszMmsLoadTempBuf); - pszMmsLoadTempBuf = NULL; - } +__CATCH: - if (pszOrgData) { - free(pszOrgData); - pszOrgData = NULL; + if (pData) { + free(pData); + pData = NULL; } - if (hFile != NULL) { - MsgCloseFile(hFile); - hFile = NULL; - } + return -1; +} - remove(szTempFile); - remove(szTempFilePath); +/** + * Decode Text + * + * @param pEncodedData [in] QuotedString encoded data + * @param szBuff [out] Decoded quoted string + * @param bufLen [out] Buffer length + * @return length of decode text string + */ +static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int totalLength) +{ + int length = 0; + int readBytes = 0; + int iPos = 0; + int returnLength = 0; + char *pData = NULL; + bool bQuote = false; + int offset = 0; - return true; + /* + * Text-String = [QUOTE]*TEXT end_of_string + * [QUOTE]*(128~255)\0 + * *(32~126)\0 + */ -__CATCH: + if (pFile == NULL || szBuff == NULL || bufLen <= 0) + return -1; - if (pFile != NULL) { - MsgCloseFile(pFile); - pFile = NULL; - } + offset = __MmsGetDecodeOffset(); + if (offset >= totalLength) + goto __RETURN; - if (hConvertedFile != NULL) { - MsgCloseFile(hConvertedFile); - hConvertedFile = NULL; - } + memset(szBuff, 0, bufLen); - if (hTempFile != NULL) { - MsgCloseFile(hTempFile); - hTempFile = NULL; + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { + MSG_DEBUG("fail to load to buffer"); + goto __CATCH; } - if (pszMmsLoadTempBuf) { - free(pszMmsLoadTempBuf); - pszMmsLoadTempBuf = NULL; - } + length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL - if (pszOrgData) { - free(pszOrgData); - pszOrgData = NULL; - } + if (length == 0) + goto __RETURN; - if (hFile != NULL) - { - MsgCloseFile(hFile); - hFile = NULL; - } + while (length > gMmsDecodeBufLen) { + if (gMmsDecodeBufLen <= 0) { + MSG_DEBUG("gMmsDecodeBufLen <= 0"); + MSG_DEBUG("%x %x %x %x %x", gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2], + gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]); + MSG_DEBUG("%x %x %x %x %x", gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7], + gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]); + MSG_DEBUG("%x %x %x %x %x", gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12], + gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]); + MSG_DEBUG("%x %x %x %x %x", gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17], + gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]); + goto __CATCH; + } - remove(szTempFile); - remove(szTempFilePath); - remove(MMS_DECODE_DRM_CONVERTED_TEMP_FILE); //remove convertin result if it goes to __CATCH + pData = (char *)calloc(1, gMmsDecodeBufLen + 1); + if (pData == NULL) + goto __CATCH; - return false; -} + memset(pData, 0, gMmsDecodeBufLen + 1); + if (__MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false) + goto __CATCH; -/************************************************************************* - * description : Function for decoding a converted file - * argument : void - * return value - - bool : result of converting -**************************************************************************/ -bool MmsDrm2DecodeConvertedMsg(int msgID, char *pszFullPath) -{ - FILE *hConvertedFile = NULL; - int nSize = 0; + if ((bufLen - iPos) > 0) { + readBytes = (gMmsDecodeBufLen < (bufLen - iPos)) ? gMmsDecodeBufLen : (bufLen - iPos); + if (iPos == 0 && (pData[0] == QUOTE) && (bQuote == false)) { + /* QUOTE: check first time only */ - MSG_DEBUG("MmsDrm2DecodeConvertedMsg: start re-decoding~~~~~~\n"); + strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1); + iPos += (readBytes - 1); + bQuote = true; + } else { + strncpy(szBuff + iPos, (char*)pData, readBytes); + iPos += readBytes; + } + } - // free - _MsgFreeDRMInfo(&mmsHeader.msgType.drmInfo); - _MsgFreeBody(&mmsHeader.msgBody, mmsHeader.msgType.type); + if (pData) { + free(pData); + pData = NULL; + } - _MmsInitHeader(); - _MmsUnregisterDecodeBuffer(); + returnLength += gMmsDecodeBufLen; - // start decoding - _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX); + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { + MSG_DEBUG("fail to load to buffer"); + goto __CATCH; + } + length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL + } /* while */ - // open converted file - if ((hConvertedFile = MsgOpenFile(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, "rb")) == NULL) { - MSG_DEBUG("MmsDrm2ReDecodeMsg: opening temporary file failed\n"); - goto __CATCH; - } + if (length > 0) { + pData = (char *)calloc(1, length); + if (pData == NULL) + goto __CATCH; - if (MsgGetFileSize(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, &nSize) == false) { - MSG_DEBUG("MsgGetFileSize: failed\n"); - goto __CATCH; - } + memset(pData, 0, length); - if (!MmsBinaryDecodeMsgHeader(hConvertedFile, nSize)) { - MSG_DEBUG("MmsDrm2ReDecodeMsg: decoding header(binary mode) failed\n"); - goto __CATCH; - } + if (__MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false) + goto __CATCH; - if (!MmsBinaryDecodeMsgBody(hConvertedFile, pszFullPath, nSize)) { - MSG_DEBUG("MmsDrm2ReDecodeMsg: decoding body failed\n"); - goto __CATCH; - } + if ((bufLen - iPos) > 0) { + readBytes = (length < (bufLen - iPos)) ? length : (bufLen - iPos); + if (iPos == 0 && (pData[0] == QUOTE) && (bQuote == false)) { + /* QUOTE: check first time only */ + + strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1); + iPos += (readBytes - 1); + bQuote = true; + } else { + strncpy(szBuff + iPos, (char*)pData, readBytes - 1); // + NULL + iPos += readBytes; + } + } - if (hConvertedFile != NULL) { - MsgCloseFile(hConvertedFile); - hConvertedFile = NULL; + if (pData) { + free(pData); + pData = NULL; + } + + returnLength += length; // + NULL } - return true; + szBuff[bufLen - 1] = '\0'; -__CATCH: + return returnLength; - if (hConvertedFile != NULL) { - MsgCloseFile(hConvertedFile); - remove(MMS_DECODE_DRM_CONVERTED_TEMP_FILE); - hConvertedFile = NULL; - } +__RETURN: - return false; -} + szBuff[0] = '\0'; + length = 0; + __MmsBinaryDecodeMovePointer(pFile, offset, totalLength); -bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath) -{ - MmsMsg *pMmsMsg; - MmsPluginStorage::instance()->getMmsMessage(&pMmsMsg); - _MmsUnregisterDecodeBuffer(); -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pMmsMsg->msgType.drmInfo); -#endif - _MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type); + return length; - if (_MmsReadMsgBody(pMsg->msgId, bSavePartsAsTempFiles, bRetrieved, retrievedPath) == false) { - MSG_DEBUG("MmsDrm2ReadMsgConvertedBody: _MmsReadMsgBody with converted file is failed\n"); - return false; +__CATCH: + + if (pData) { + free(pData); + pData = NULL; } - return true; + return -1; } -#endif - -/* -------------------------------------------------------------------- - * - * B I N A R Y D E C D E U T I L I T Y - * - * --------------------------------------------------------------------*/ - -bool _MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength) +static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) { - int length = gMmsDecodeMaxLen - gCurMmsDecodeBuffPos; + int length = 0; + int curLen = 0; + char *pData = NULL; + char *szBuff = NULL; + char *szTempPtr = NULL; + bool bQuote = false; + int offset = 0; - if (pFile == NULL || pOneByte == NULL) - { - MSG_DEBUG("_MmsBinaryDecodeGetOneByte: invalid file or buffer\n"); + /* + * Text-String = [QUOTE]*TEXT end_of_string + * [QUOTE]*(128~255)\0 + * *(32~126)\0 + */ + + if (pFile == NULL || pLength == NULL) goto __CATCH; - } - if (length < 1) { - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("_MmsBinaryDecodeGetOneByte: fail to load to buffer \n"); - goto __CATCH; - } + *pLength = 0; + offset = __MmsGetDecodeOffset(); + if (offset >= totalLength) + goto __RETURN; + + if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { + MSG_DEBUG("fail to load to buffer"); + goto __CATCH; } - *pOneByte = gpCurMmsDecodeBuff[gCurMmsDecodeBuffPos++]; + length = strlen(gpCurMmsDecodeBuff) + 1; - return true; + if (length == 0) + goto __CATCH; -__CATCH: - return false; -} - - -/* - * @remark: bufLen < gMmsDecodeMaxLen - */ -bool _MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength) -{ - int length = gMmsDecodeMaxLen - gCurMmsDecodeBuffPos; - int i = 0; - - - if (pFile == NULL || szBuff == NULL || bufLen == 0 || bufLen > gMmsDecodeMaxLen) - goto __CATCH; - - memset(szBuff, 0, bufLen); - - if (length < bufLen) { - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("_MmsBinaryDecodeGetBytes: fail to load to buffer \n"); + while (length > gMmsDecodeBufLen) { + if (gMmsDecodeBufLen <= 0) { + MSG_DEBUG("gMmsDecodeBufLen <= 0"); + MSG_DEBUG("%x %x %x %x %x", + gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2], + gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]); + MSG_DEBUG("%x %x %x %x %x", + gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7], + gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]); + MSG_DEBUG("%x %x %x %x %x", + gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12], + gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]); + MSG_DEBUG("%x %x %x %x %x\n", + gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17], + gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]); goto __CATCH; } - } - - for (i = 0; i < bufLen - 1; i++) - szBuff[i] = gpCurMmsDecodeBuff[gCurMmsDecodeBuffPos++]; - - gCurMmsDecodeBuffPos++; //NULL - - return true; + pData = (char *)calloc(1, gMmsDecodeBufLen + 1); + if (pData == NULL) + goto __CATCH; -__CATCH: - return false; -} + memset(pData, 0, gMmsDecodeBufLen + 1); + if (__MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false) + goto __CATCH; + if (szBuff == NULL) { + szBuff = (char *)calloc(1, gMmsDecodeBufLen + 1); + } else { + szTempPtr = (char *)realloc(szBuff, curLen + gMmsDecodeBufLen + 1); -bool _MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength) -{ - int iPos = 0; + //NULL pointer check for realloc + if (szTempPtr == NULL) { + goto __CATCH; + } else { + szBuff = szTempPtr; + } + } + if (szBuff == NULL) + goto __CATCH; - if (pFile == NULL || szBuff == NULL || bufLen == 0) - goto __CATCH; + memset(szBuff + curLen, 0, gMmsDecodeBufLen + 1); - memset(szBuff, 0, bufLen); + if (curLen == 0 && (pData[0] == QUOTE) && (bQuote == false)) { + /* QUOTE: check first time only */ - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: fail to load to buffer \n"); - goto __CATCH; - } + strncpy(szBuff + curLen, (char*)pData + 1, gMmsDecodeBufLen - 1); + curLen += (gMmsDecodeBufLen - 1); + bQuote = true; + } else { + strncpy(szBuff + curLen, (char*)pData, gMmsDecodeBufLen); + curLen += gMmsDecodeBufLen; + } - while ((bufLen - iPos) >= gMmsDecodeMaxLen) { - if (_MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, gMmsDecodeMaxLen, totalLength) == false) { - MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: 1. _MmsBinaryDecodeGetBytes fail \n"); - goto __CATCH; + if (pData) { + free(pData); + pData = NULL; } - iPos += gMmsDecodeMaxLen; - } + *pLength += gMmsDecodeBufLen; - if ((bufLen - iPos) > 0) { - if (_MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, (bufLen - iPos), totalLength) == false) { - MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: 2. _MmsBinaryDecodeGetBytes fail \n"); + if (__MsgLoadDataToDecodeBuffer(pFile, + &gpCurMmsDecodeBuff, + &gCurMmsDecodeBuffPos, + &gMmsDecodeCurOffset, + gpMmsDecodeBuf1, + gpMmsDecodeBuf2, + gMmsDecodeMaxLen, + &gMmsDecodeBufLen, + totalLength) == false) + { + MSG_DEBUG("fail to load to buffer"); goto __CATCH; } + length = strlen(gpCurMmsDecodeBuff) + 1; + } /* while */ - iPos += (bufLen - iPos); - } - - return true; - -__CATCH: - return false; -} - - -/** - * Decode uintvar to 32bit unsigned integer - * - * @param pEncodedData [in] encoded data - * @param pUintVar [out] Decode uintvar (32bit unsigned integer) - * @return The length of uintvar (-1, if cannot be converted to a uintvar) - * - * 0 XXXXXXX -> 0-bit: continue bit & 1~7bit: integer value - * - ------- - */ -static const UINT32 uintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00100000, 0x08000000 }; - -static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLength) -{ - UINT8 count = 0; - UINT8 oneByte = 0; - UINT32 decodedUintvar = 0; - UINT8 iBuff[5] = {0}; - int length = MSG_MMS_DECODE_BUFFER_MAX - gCurMmsDecodeBuffPos; - - - if (pFile == NULL || pUintVar == NULL) - return -1; - - if (length < 5) { - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeUintvar: fail to load to buffer \n"); + if (length > 0) { + pData = (char *)calloc(1, length); + if (pData == NULL) { goto __CATCH; } - } - while (true) { - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) + if (__MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false) { goto __CATCH; + } - if (oneByte > 0x7f) { - iBuff[count++] = oneByte; + if (szBuff == NULL) { + szBuff = (char *)calloc(1, length); } else { - iBuff[count++] = oneByte; - break; + szTempPtr = (char *)realloc(szBuff, curLen + length); + + //NULL pointer check for realloc + if (szTempPtr == NULL) + goto __CATCH; + else + szBuff = szTempPtr; } - if (count > 5) { - MSG_DEBUG("__MmsBinaryDecodeUintvar : legnth is too long\n"); + if (szBuff == NULL) { goto __CATCH; } - } - - for (int i = 0; i < count; i++) - decodedUintvar += (uintvarDecodeTable[i] * (iBuff[count-(i+1)]&0x7f)); - - *pUintVar = decodedUintvar; - - return count; - -__CATCH: - gCurMmsDecodeBuffPos -= count; - return -1; -} - -/** - * Decode uintvar to 32bit unsigned integer by uintvar length - * - * @param pEncodedData [in] uintvar encoded data - * @param length [in] length of integer value - * @return unsigned integer value - */ -static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int totalLength) -{ - UINT32 i = 0; - UINT8 oneByte = 0; - char *pData = NULL; - union { - UINT32 integer; - UINT8 seg[4]; - } returner; - - returner.integer = 0; - - if (length > 4) - length = 4; + memset(szBuff + curLen, 0, length); - if (length == 1) - { - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: _MmsBinaryDecodeGetOneByte fail\n"); - return oneByte; - } + if (curLen == 0 && (pData[0] == QUOTE) && (bQuote == false)) { + /* QUOTE: check first time only */ - if (oneByte > 0x7f) { - return (oneByte & 0x7f); + strncpy(szBuff + curLen, (char*)pData + 1, length - 2); + curLen += (length - 1); + bQuote = true; } else { - return oneByte; + strncpy(szBuff + curLen, (char*)pData, length - 1); + curLen += length; } - } - if (length == 0) - return 0; + if (pData) { + free(pData); + pData = NULL; + } - pData = (char *)malloc(length + 1); - if (pData == NULL) { - MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: pData alloc fail\n"); - goto __CATCH; + *pLength += length; // + NULL } - memset(pData, 0, length + 1); - if (_MmsBinaryDecodeGetBytes(pFile, pData, length + 1, totalLength) == false) { - MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: _MmsBinaryDecodeGetOneByte fail\n"); - goto __CATCH; - } + return szBuff; - gCurMmsDecodeBuffPos--; // - NULL +__RETURN: - for (i= 0; i < length; i++) - returner.seg[length - (i+1)] = pData[i]; + *pLength = 1; - if (pData) { - free(pData); - pData = NULL; - } + __MmsBinaryDecodeMovePointer(pFile, offset, totalLength); - return returner.integer; + return szBuff; __CATCH: + if (szBuff) { + free(szBuff); + szBuff = NULL; + } + if (pData) { free(pData); pData = NULL; } - return returner.integer; + return NULL; } - /** - * Decode uintvar to 32bit unsigned integer by uintvar length + * Decode Charset * - * @param pEncodedData [in] uintvar encoded data - * @param pInteger [out] Decode integer value (long/short) - * @return unsigned integer value (-1, if cannot be converted to unsigned integer value) + * @param pEncodedData [in] QuotedString encoded data + * @param nCharSet [out] Decoded character set + * @return length of charset value */ -static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen, int totalLength) +static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSetLen, int totalLength) { - UINT8 oneByte = 0; - char *pData = NULL; - union { - UINT32 integer; - UINT8 seg[4]; - } returner; + UINT32 integer = 0; + /* + * Charset v1.1 0x01 Well-known-charset + * Well-known-charset = Any-charset | Integer-value + * ; Both are encoded using values from + * Character Set Assignments table in Assigned Numbers + * Any-charset = + * ; Equivalent to the special RFC2616 charset value ��*�� + */ - if (pInteger == NULL) + if (pFile == NULL || nCharSet == NULL || pCharSetLen == NULL) return false; - returner.integer = 0; - *pIntLen = 0; + if (__MmsBinaryDecodeInteger(pFile, &integer, pCharSetLen, totalLength) == false) { + MSG_DEBUG("__MmsBinaryDecodeInteger fail..."); + goto __CATCH; + } - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeInteger: GetOneByte fail\n"); - return false; + if (integer == 0) { + /* AnyCharSet : return MSG_CHARSET_UTF8 */ + *nCharSet = MSG_CHARSET_UTF8; + return true; } - if (oneByte < 0x1F) /* long integer : WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.86) */ - { - pData = (char *)malloc(oneByte + 1); - if (pData == NULL) { - MSG_DEBUG("__MmsBinaryDecodeInteger: pData memalloc fail\n"); + *nCharSet = MmsGetBinaryType(MmsCodeCharSet, (UINT16)integer); + MSG_DEBUG("Decoded charset MIBenum = [%d], charset enum = [%d]", integer, *nCharSet); + if (*nCharSet == MIME_UNKNOWN) { + MSG_DEBUG("MmsGetBinaryType fail.."); + *nCharSet = MSG_CHARSET_UNKNOWN; + } + + return true; + +__CATCH: + return false; +} + +/** + * Decode EncodedString + * + * @param pEncodedData [in] QuotedString encoded data + * @param szBuff [out] Decoded string buffer + * @param bufLen [in] Decoded buffer length + * @return length of decoded string length + */ +static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen, int totalLength) +{ + UINT32 valueLength = 0; + UINT32 charSet = 0; + int charSetLen = 0; + int nTemp = 0; + char *pData = NULL; + + MSG_DEBUG(" decode string.."); + + if (pFile == NULL || szBuff == NULL || bufLen <= 0) { + MSG_DEBUG("invalid file or buffer"); + goto __CATCH; + } + + /* + * Encoded_string_value = Text-string | Value-length Char-set Text-String + * Text-string = [Quote]*TEXT End-of-string + * Value-length = 0 ~ 31 + */ + + memset(szBuff, 0, bufLen); + + switch (__MmsDecodeValueLength(pFile, &valueLength, totalLength)) { + case -1: + goto __CATCH; + + case 0: + + /* Text-string = [Quote]*TEXT End-of-string */ + + if (__MmsBinaryDecodeText(pFile, szBuff, bufLen, totalLength) < 0) { + MSG_DEBUG("__MmsBinaryDecodeText fail."); goto __CATCH; } - memset(pData, 0, oneByte + 1); + break; - // Even NULL is copied in the _MmsBinaryDecodeGetBytes - if (_MmsBinaryDecodeGetBytes(pFile, pData, oneByte + 1, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeInteger: GetBytes fail\n"); - goto __CATCH; + default: + + /* Value-length Charset Text_string */ + + if (__MmsBinaryDecodeCharset(pFile, &charSet, &charSetLen, totalLength) == false) { + MSG_DEBUG(" __MmsBinaryDecodeCharset error"); + goto __CATCH; /* (valueLength + valueLengthLen) */ } - gCurMmsDecodeBuffPos--; // - NULL + nTemp = __MmsBinaryDecodeText(pFile, szBuff, bufLen, totalLength); - int length = 0; - if (oneByte > 4) { - length = 4; - } else { - length = oneByte; + if (nTemp < 0) { + /* There can be some error in data - no NULL -> try again with value length */ + + pData = (char *)calloc(1, valueLength - charSetLen); + if (pData == NULL) { + MSG_DEBUG("pData alloc fail."); + goto __CATCH; + } + + if (__MmsBinaryDecodeGetLongBytes(pFile, pData, valueLength - charSetLen, totalLength) == false) { + MSG_DEBUG("_MmsBinaryDecodeGetLongBytes fail."); + goto __CATCH; + } + + strncpy(szBuff, pData, bufLen - 1); } - int i = 0; - for (i = 0; i < length; i++) - returner.seg[length - (i+1)] = pData[i]; + {//temp brace - *pInteger = returner.integer; - *pIntLen = oneByte + 1; - } else if (oneByte >= 0x80) { - /* short integer : WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.86) */ - *pInteger = oneByte & 0x7f; - *pIntLen = 1; - } else { - goto __CATCH; + nTemp = strlen(szBuff); + + const char *pToCharSet = "UTF-8"; + + UINT16 charset_code = MmsGetBinaryValue(MmsCodeCharSet, charSet); + + const char *pFromCharSet = MmsPluginTextConvertGetCharSet(charset_code); + if (pFromCharSet == NULL || !strcmp(pFromCharSet, pToCharSet)) { + if (pData) { + free(pData); + pData = NULL; + } + return true; + } + + char *pDest = NULL; + int destLen = 0; + + if (MmsPluginTextConvert(pToCharSet, pFromCharSet, szBuff, nTemp, &pDest, &destLen) == false) { + MSG_DEBUG("MmsPluginTextConvert Fail"); + + } else { + memset(szBuff, 0x00, bufLen); + snprintf(szBuff, destLen+1, "%s", pDest); + } + + if (pDest) { + free(pDest); + pDest = NULL; + } + } + break; } if (pData) { @@ -3579,8 +3439,6 @@ static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen __CATCH: - gCurMmsDecodeBuffPos--; - if (pData) { free(pData); pData = NULL; @@ -3590,3943 +3448,1796 @@ __CATCH: } + /** - * Decode uintvar to 32bit unsigned integer by uintvar length + * Decode Encoded Addresses * - * @return 1 : Success - * 0 : This is not Value Length type data - * -1 : Requires System error report + * @param pEncodedData [in] QuotedString encoded data + * @param pAddrLength [out] Decoded address length + * @return Decoded address list */ -static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLength) +MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength) { - int length = 0; - UINT32 uintvar = 0; - UINT8 oneByte = 0; + UINT32 valueLength = 0; + UINT32 charSet = 0; + int charSetLen = 0; + int textLength = 0; + char *pAddrStr = NULL; + MsgHeaderAddress *pAddr = NULL; + + MSG_DEBUG("decoding address.."); + if (pFile == NULL) { + MSG_DEBUG("invalid file or buffer"); + goto __CATCH; + } /* - * value-length = short-length | (Length-quote Length) - * = 0~30 | 31 + Uintvar-length + * Encoded_string_value = Text-string | Value-length Char-set Text-String + * Text-string = [Quote]*TEXT End-of-string + * Value-length = 0 ~ 31 */ - if (pFile == NULL || pValueLength == NULL) + switch (__MmsDecodeValueLength(pFile, &valueLength, totalLength)) { + case -1: goto __CATCH; - *pValueLength = 0; + case 0: - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - gCurMmsDecodeBuffPos--; - goto __CATCH; - } + /* Text-string = [Quote]*TEXT End-of-string */ - if (0x00 < oneByte && oneByte < 0x1F) { - /* short-length */ + textLength = 0; + pAddrStr = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); + if (pAddrStr == NULL) { + MSG_DEBUG(" __MmsBinaryDecodeText2 fail."); + goto __CATCH; + } + break; - *pValueLength = oneByte; - length = 1; - } else if (oneByte == 0x1F) { - /* Length-quote = 0x1F */ + default: - length = __MmsBinaryDecodeUintvar(pFile, &uintvar, totalLength); - if (length == -1) { - MSG_DEBUG("__MmsDecodeValueLength: __MmsBinaryDecodeUintvar fail..\n"); + /* Value-length Charset Text_string */ + + if (__MmsBinaryDecodeCharset(pFile, &charSet, &charSetLen, totalLength) == false) { + MSG_DEBUG(" __MmsBinaryDecodeCharset error"); goto __CATCH; } - length ++; // + length-quote - *pValueLength = uintvar; - } else { - MSG_DEBUG("__MmsDecodeValueLength: not a value length type data\n"); - gCurMmsDecodeBuffPos--; - return 0; + + textLength = 0; + pAddrStr = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); + if (pAddrStr == NULL) { + /* There can be some error in data - no NULL -> try again with value length */ + + pAddrStr = (char *)calloc(1, valueLength - charSetLen); + if (pAddrStr == NULL) { + MSG_DEBUG("pData alloc fail."); + goto __CATCH; + } + + if (__MmsBinaryDecodeGetLongBytes(pFile, pAddrStr, valueLength - charSetLen, totalLength) == false) { + MSG_DEBUG(" _MmsBinaryDecodeGetLongBytes fail."); + goto __CATCH; + } + } + + /* fixme: charset transformation */ + + break; } - return length; + pAddr = (MsgHeaderAddress *)calloc(1, sizeof(MsgHeaderAddress)); + if (pAddr == NULL) + goto __CATCH; + + memset(pAddr, 0, sizeof(MsgHeaderAddress)); + pAddr->szAddr = pAddrStr; + + return pAddr; __CATCH: - MSG_DEBUG("__MmsDecodeValueLength: getting data fail\n"); - return -1; -} + if (pAddrStr) { + free(pAddrStr); + pAddrStr = NULL; + } + + return NULL; +} /** - * Decode uintvar to 32bit unsigned integer by uintvar length + * Decode Encoded Pointer String * - * @return 1 : Success - * 0 : This is not Value Length type data - * -1 : Requires System error report - * @ defference : if there is not length-quote, consider it as short length. + * @param pEncodedData [in] Long integer encoded data + * @param pLongInteger [out] Decoded long integer + * @return Decoded address list */ -static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalLength) +static bool __MmsDecodeLongInteger(FILE *pFile, UINT32 *pLongInteger, int totalLength) { - int length = 0; - UINT32 uintvar = 0; UINT8 oneByte = 0; - /* - * value-length = short-length | (Length-quote Length) - * = 0~30 | 31 + Uintvar-length + * Long-integer = Short-length Multi-octet-integer + * Short-length = 0~30 + * Multi-octet-integer */ - if (pFile == NULL || pValueLength == NULL) - goto __CATCH; + if (pFile == NULL || pLongInteger == NULL) + return false; - *pValueLength = 0; + *pLongInteger = 0; - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) { - gCurMmsDecodeBuffPos--; + if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) goto __CATCH; - } - if (0x00 < oneByte && oneByte < 0x1F) { - /* short-length */ + if (oneByte > 31) + goto __CATCH; - *pValueLength = oneByte; - length = 1; - } else if (oneByte == 0x1F) { - /* Length-quote = 0x1F */ + *pLongInteger = __MmsHeaderDecodeIntegerByLength(pFile, oneByte, totalLength); - length = __MmsBinaryDecodeUintvar(pFile, &uintvar, totalLength); - if (length == -1) { - MSG_DEBUG("__MmsDecodeValueLength2: __MmsBinaryDecodeUintvar fail..\n"); - goto __CATCH; - } - length ++; // + length-quote - *pValueLength = uintvar; - } else { - MSG_DEBUG("__MmsDecodeValueLength2: there is not length-quote, consider it as short length.\n"); - *pValueLength = oneByte; - length = 1; - } - - return length; + return true; __CATCH: - MSG_DEBUG("__MmsDecodeValueLength2: getting data fail\n"); - return -1; + return false; } - -/** - * Decode QuotedString - * - * @param pEncodedData [in] QuotedString encoded data - * @param szBuff [out] Decoded quoted string - * @param bufLen [out] Buffer length - * @return length of quoted string +/* + * @param pEncodedData [in] filename encoded data + * @param szBuff [out] filename output buffer + * @param fullLength [in] full filename length + * @param bufLen [in] buffer length + * CAUTION: bufLen - 1 */ -static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, int totalLength) +static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int totalLength) { - int iPos = 0; + char *pUTF8Buff = NULL; + char *pLatinBuff = NULL; + char *pExt = NULL; + char *szSrc = NULL; + char *szSrc2 = NULL; int length = 0; - int readBytes = 0; - char *pData = NULL; - int returnLength = 0; - - /* - * Quoted-string = *TEXT End-of-string - * The TEXT encodes an RFC2616 Quoted-string with the enclosing quotation-marks <"> removed - */ - - if (pFile == NULL || szBuff == NULL || bufLen <= 0) - return -1; - - memset(szBuff, 0, bufLen); + int textLength = 0; - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeQuotedString: 1. fail to load to buffer \n"); - goto __CATCH; - } + char *pTmpBuff = NULL; - length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL + memset (szBuff, 0, bufLen); - if (length == 0) - goto __RETURN; + textLength = 0; + pLatinBuff = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); - while (length > gMmsDecodeBufLen) { - if (gMmsDecodeBufLen <= 0) { - MSG_DEBUG("__MmsBinaryDecodeQuotedString: gMmsDecodeBufLen <= 0 \n"); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", - gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2], - gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", - gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7], - gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", - gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12], - gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", - gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17], - gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]); - goto __CATCH; + //remove "" + if (pLatinBuff) { + szSrc = MsgRemoveQuoteFromFilename(pLatinBuff); + if (szSrc) { + strncpy(pLatinBuff, szSrc, textLength); + free(szSrc); + szSrc = NULL; } - pData = (char *)malloc(gMmsDecodeBufLen + 1); - if (pData == NULL) - goto __CATCH; - - memset(pData, 0, gMmsDecodeBufLen + 1); + szSrc2 = MsgChangeHexString(pLatinBuff); + if (szSrc2) { + strncpy(pLatinBuff, szSrc2, textLength); + free(szSrc2); + szSrc2 = NULL; + } - if (_MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false) - goto __CATCH; + if (MmsIsUtf8String((unsigned char*)pLatinBuff, strlen(pLatinBuff)) == false) { + length = strlen(pLatinBuff); - returnLength += gMmsDecodeBufLen; + int utf8BufSize = 0; + utf8BufSize = __MsgGetLatin2UTFCodeSize((unsigned char*)pLatinBuff, length); + if (utf8BufSize < 3) + utf8BufSize = 3;//min value - if ((bufLen - iPos) > 0) { - readBytes = (gMmsDecodeBufLen < (bufLen - iPos)) ? gMmsDecodeBufLen : (bufLen - iPos); - if (iPos == 0 && (pData[0] == MARK)) { - /* MARK: check first time only */ + pUTF8Buff = (char *)calloc(1, utf8BufSize + 1); + if (pUTF8Buff == NULL) { + MSG_DEBUG("pUTF8Buff alloc fail"); + goto __CATCH; + } - strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1); - iPos += (readBytes - 1); - } else { - strncpy(szBuff + iPos, (char*)pData, readBytes); - iPos += readBytes; + if (__MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pLatinBuff, length) < 0) { + MSG_DEBUG("MsgLatin2UTF fail"); + goto __CATCH; } + free(pLatinBuff); + pLatinBuff = NULL; + } else { + pTmpBuff = MsgDecodeText(pLatinBuff); + pUTF8Buff = pTmpBuff; + free (pLatinBuff); + pLatinBuff = NULL; } + } - if (pData) { - free(pData); - pData = NULL; - } + if (pUTF8Buff) { + /* + * keeping extension + * it should be kept extention even if the file name is shorten + */ - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n"); - goto __CATCH; + length = strlen(pUTF8Buff); + if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { + int nameLength = 0; + nameLength = (length < bufLen) ? (length - strlen(pExt)) : (bufLen - strlen(pExt)); + strncpy(szBuff, pUTF8Buff, nameLength); + g_strlcat(szBuff, pExt,(gsize)bufLen); + + } else { + strncpy(szBuff, pUTF8Buff, bufLen - 1); } - length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL - } /* while */ - if (length > 0) { - pData = (char *)malloc(length); - if (pData == NULL) - goto __CATCH; + free(pUTF8Buff); + pUTF8Buff = NULL; - if (_MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false) - goto __CATCH; + return textLength; + } - returnLength += length; +__CATCH: - if ((bufLen - iPos) > 0) { - /* read until NULL from raw data, and copy only string */ - readBytes = (length < (bufLen - iPos)) ? length : (bufLen - iPos); - if (iPos == 0 && (pData[0] == MARK)) { - /* MARK: check first time only */ - strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1); - iPos += (readBytes - 1); - } else { - strncpy(szBuff + iPos, (char*)pData, readBytes - 1); // + NULL - iPos += readBytes; - } - } + if (pLatinBuff) { + free(pLatinBuff); + pLatinBuff = NULL; + } - if (pData) { - free(pData); - pData = NULL; - } + if (pUTF8Buff) { + free(pUTF8Buff); + pUTF8Buff = NULL; } - szBuff[bufLen - 1] = '\0'; + return -1; +} - return returnLength; +/* ========================================================== -__RETURN: + M M S D E C O D I N G - if (pData) { - free(pData); - pData = NULL; - } + ==========================================================*/ - return length; +// to get message body this function should be modified from message raw file. +bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath) +{ + FILE *pFile = NULL; + MmsMsg *pMsg = NULL; + MsgMultipart *pMultipart = NULL; + int nSize = 0; + char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; + char szTempMediaDir[MSG_FILEPATH_LEN_MAX] = {0, }; -__CATCH: + MSG_BEGIN(); - if (pData) { - free(pData); - pData = NULL; + MmsPluginStorage::instance()->getMmsMessage(&pMsg); + memset(pMsg, 0, sizeof(MmsMsg)); + + MmsInitHeader(); + + if (bRetrieved && (retrievedPath != NULL)) { + strncpy(szFullPath, retrievedPath, (strlen(retrievedPath) > MSG_FILEPATH_LEN_MAX ? MSG_FILEPATH_LEN_MAX:strlen(retrievedPath))); + } else { + MmsPluginStorage::instance()->getMmsRawFilePath(msgID, szFullPath, sizeof(szFullPath)); } - return -1; -} + pMsg->msgID = msgID; + /* read from MMS raw file */ + strncpy(pMsg->szFileName, szFullPath + strlen(MSG_DATA_PATH), strlen(szFullPath + strlen(MSG_DATA_PATH))); -/** - * Decode Text - * - * @param pEncodedData [in] QuotedString encoded data - * @param szBuff [out] Decoded quoted string - * @param bufLen [out] Buffer length - * @return length of decode text string - */ -static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int totalLength) -{ - int length = 0; - int readBytes = 0; - int iPos = 0; - int returnLength = 0; - char *pData = NULL; - bool bQuote = false; - int offset = 0; + MSG_SEC_DEBUG("msg_id = [%d]", msgID); + MSG_SEC_DEBUG("raw file path = [%s]", szFullPath); - /* - * Text-String = [QUOTE]*TEXT end_of_string - * [QUOTE]*(128~255)\0 - * *(32~126)\0 - */ + if (MsgGetFileSize(szFullPath, &nSize) == false) { + MSG_FATAL("Fail MsgGetFileSize"); + goto __CATCH; + } - if (pFile == NULL || szBuff == NULL || bufLen <= 0) - return -1; + pFile = MsgOpenFile(szFullPath, "rb"); + if (pFile == NULL) { + MSG_SEC_DEBUG("Fail MsgOpenFile [%s]", szFullPath); + goto __CATCH; + } - offset = _MmsGetDecodeOffset(); - if (offset >= totalLength) - goto __RETURN; + MmsRegisterDecodeBuffer(); - memset(szBuff, 0, bufLen); + if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) { + MSG_FATAL("Fail to MmsBinaryDecodeMsgHeader"); + goto __CATCH; + } - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeText: 1. fail to load to buffer \n"); + if (MmsBinaryDecodeMsgBody(pFile, szFullPath, nSize) == false) { + MSG_FATAL("Fail to MmsBinaryDecodeMsgBody"); goto __CATCH; } - length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL + /* Set mmsHeader.msgType & msgBody to pMsg ----------- */ - if (length == 0) - goto __RETURN; + memcpy(&(pMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType)); + memcpy(&(pMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody)); - while (length > gMmsDecodeBufLen) { - if (gMmsDecodeBufLen <= 0) { - MSG_DEBUG("__MmsBinaryDecodeQuotedString: gMmsDecodeBufLen <= 0 \n"); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2], - gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7], - gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12], - gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17], - gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]); - goto __CATCH; - } +{//attribute convert mmsHeader -> mmsAttribute - pData = (char *)malloc(gMmsDecodeBufLen + 1); - if (pData == NULL) - goto __CATCH; + pMsg->mmsAttrib.contentType = (MimeType)mmsHeader.msgType.type; - memset(pData, 0, gMmsDecodeBufLen + 1); + pMsg->mmsAttrib.date = mmsHeader.date; - if (_MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false) - goto __CATCH; + if (mmsHeader.deliveryReport == MMS_REPORT_YES) { + pMsg->mmsAttrib.bAskDeliveryReport = true; + } - if ((bufLen - iPos) > 0) { - readBytes = (gMmsDecodeBufLen < (bufLen - iPos)) ? gMmsDecodeBufLen : (bufLen - iPos); - if (iPos == 0 && (pData[0] == QUOTE) && (bQuote == false)) { - /* QUOTE: check first time only */ + memcpy(&pMsg->mmsAttrib.deliveryTime, &mmsHeader.deliveryTime, sizeof(MmsTimeStruct)); - strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1); - iPos += (readBytes - 1); - bQuote = true; - } else { - strncpy(szBuff + iPos, (char*)pData, readBytes); - iPos += readBytes; - } - } - - if (pData) { - free(pData); - pData = NULL; - } - - returnLength += gMmsDecodeBufLen; - - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n"); - goto __CATCH; - } - length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL - } /* while */ - - if (length > 0) { - pData = (char *)malloc(length); - if (pData == NULL) - goto __CATCH; - - memset(pData, 0, length); - - if (_MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false) - goto __CATCH; - - if ((bufLen - iPos) > 0) { - readBytes = (length < (bufLen - iPos)) ? length : (bufLen - iPos); - if (iPos == 0 && (pData[0] == QUOTE) && (bQuote == false)) { - /* QUOTE: check first time only */ + memcpy(&pMsg->mmsAttrib.expiryTime, &mmsHeader.expiryTime, sizeof(MmsTimeStruct)); - strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1); - iPos += (readBytes - 1); - bQuote = true; - } else { - strncpy(szBuff + iPos, (char*)pData, readBytes - 1); // + NULL - iPos += readBytes; - } - } + pMsg->mmsAttrib.msgClass = mmsHeader.msgClass; - if (pData) { - free(pData); - pData = NULL; - } + snprintf(pMsg->szMsgID, sizeof(pMsg->szMsgID), "%s", mmsHeader.szMsgID); - returnLength += length; // + NULL - } + pMsg->mmsAttrib.msgType = mmsHeader.type; - szBuff[bufLen - 1] = '\0'; + pMsg->mmsAttrib.version = mmsHeader.version; - return returnLength; + pMsg->mmsAttrib.msgSize = mmsHeader.msgSize; -__RETURN: + pMsg->mmsAttrib.priority = mmsHeader.priority; - if (pData) { - free(pData); - pData = NULL; + if (mmsHeader.readReply == MMS_REPORT_YES) { + pMsg->mmsAttrib.bAskReadReply = true; } - szBuff[0] = '\0'; - length = 0; - - MmsBinaryDecodeMovePointer(pFile, offset, totalLength); - - return length; + snprintf(pMsg->mmsAttrib.szSubject, sizeof(pMsg->mmsAttrib.szSubject), "%s", mmsHeader.szSubject); -__CATCH: + snprintf(pMsg->szTrID, sizeof(pMsg->szTrID), "%s", mmsHeader.szTrID); - if (pData) { - free(pData); - pData = NULL; - } + pMsg->mmsAttrib.retrieveStatus = mmsHeader.retrieveStatus; - return -1; + //FIXME:: mmsHeader will release after delete global mmsHeader + //memset(&(mmsHeader.msgBody), 0x00, sizeof(MsgBody));//After copy to MmsMsg } + if (pMsg->msgBody.pPresentationBody) { + if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0) + goto __CATCH; + pMsg->msgBody.pPresentationBody->body.pText = (char *)calloc(1, pMsg->msgBody.pPresentationBody->size + 1); + if (pMsg->msgBody.pPresentationBody->body.pText == NULL) + goto __CATCH; -static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) -{ - int length = 0; - int curLen = 0; - char *pData = NULL; - char *szBuff = NULL; - char *szTempPtr = NULL; - bool bQuote = false; - int offset = 0; - - /* - * Text-String = [QUOTE]*TEXT end_of_string - * [QUOTE]*(128~255)\0 - * *(32~126)\0 - */ - - if (pFile == NULL || pLength == NULL) - goto __CATCH; + memset(pMsg->msgBody.pPresentationBody->body.pText, 0, pMsg->msgBody.pPresentationBody->size + 1); - *pLength = 0; - offset = _MmsGetDecodeOffset(); - if (offset >= totalLength) - goto __RETURN; + ULONG nRead = 0; + nRead = MsgReadFile(pMsg->msgBody.pPresentationBody->body.pText, sizeof(char), pMsg->msgBody.pPresentationBody->size, pFile); + if (nRead == 0) + goto __CATCH; - if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeTextLen: 1. fail to load to buffer \n"); - goto __CATCH; } - length = strlen(gpCurMmsDecodeBuff) + 1; - - if (length == 0) - goto __CATCH; + MsgCloseFile(pFile); + pFile = NULL; + /* nPartCount */ + pMsg->nPartCount = 0; - while (length > gMmsDecodeBufLen) { - if (gMmsDecodeBufLen <= 0) { - MSG_DEBUG("__MmsBinaryDecodeQuotedString: gMmsDecodeBufLen <= 0 \n"); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", - gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2], - gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", - gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7], - gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", - gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12], - gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]); - MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", - gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17], - gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]); - goto __CATCH; + if (MsgIsMultipart(mmsHeader.msgType.type) == true) { + pMultipart = pMsg->msgBody.body.pMultipart; + while (pMultipart) { + pMsg->nPartCount++; + pMultipart = pMultipart->pNext; } + } else { + if (pMsg->msgBody.size > 0) + pMsg->nPartCount++; + } - pData = (char *)malloc(gMmsDecodeBufLen + 1); - if (pData == NULL) - goto __CATCH; - - memset(pData, 0, gMmsDecodeBufLen + 1); - - if (_MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false) - goto __CATCH; + /* make temporary */ + snprintf(szTempMediaDir, MSG_FILEPATH_LEN_MAX, "%s%s.dir", MSG_DATA_PATH, pMsg->szFileName); - if (szBuff == NULL) { - szBuff = (char *)malloc(gMmsDecodeBufLen + 1); - } else { - szTempPtr = (char *)realloc(szBuff, curLen + gMmsDecodeBufLen + 1); + if (MsgIsMultipart(pMsg->msgType.type) == true) { + int partIndex = 0; + pMultipart = pMsg->msgBody.body.pMultipart; - //NULL pointer check for realloc - if (szTempPtr == NULL) { - goto __CATCH; + if (bSavePartsAsTempFiles) { + if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) { + if (errno == EEXIST) { + MSG_SEC_DEBUG("exist dir : [%s]", szTempMediaDir); + } else { + MSG_SEC_DEBUG("Fail to Create Dir [%s]", szTempMediaDir); + goto __CATCH; + } } else { - szBuff = szTempPtr; + MSG_SEC_DEBUG("make dir : [%s]", szTempMediaDir); } } - if (szBuff == NULL) - goto __CATCH; - - memset(szBuff + curLen, 0, gMmsDecodeBufLen + 1); - - if (curLen == 0 && (pData[0] == QUOTE) && (bQuote == false)) { - /* QUOTE: check first time only */ - strncpy(szBuff + curLen, (char*)pData + 1, gMmsDecodeBufLen - 1); - curLen += (gMmsDecodeBufLen - 1); - bQuote = true; - } else { - strncpy(szBuff + curLen, (char*)pData, gMmsDecodeBufLen); - curLen += gMmsDecodeBufLen; + if (pMsg->msgBody.pPresentationBody) { + if (__MmsMultipartSaveAsTempFile(&pMsg->msgBody.presentationType, pMsg->msgBody.pPresentationBody, + (char*)MSG_DATA_PATH, pMsg->szFileName, 0, bSavePartsAsTempFiles) == false) + goto __CATCH; } - if (pData) { - free(pData); - pData = NULL; - } + while (pMultipart) { - *pLength += gMmsDecodeBufLen; + if (__MmsMultipartSaveAsTempFile(&pMultipart->type, pMultipart->pBody, + (char*)MSG_DATA_PATH, pMsg->szFileName, partIndex, bSavePartsAsTempFiles) == false) + goto __CATCH; - if (MsgLoadDataToDecodeBuffer(pFile, - &gpCurMmsDecodeBuff, - &gCurMmsDecodeBuffPos, - &gMmsDecodeCurOffset, - gpMmsDecodeBuf1, - gpMmsDecodeBuf2, - gMmsDecodeMaxLen, - &gMmsDecodeBufLen, - totalLength) == false) - { - MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n"); - goto __CATCH; - } - length = strlen(gpCurMmsDecodeBuff) + 1; - } /* while */ + MmsPrintMulitpart(pMultipart, partIndex); - if (length > 0) { - pData = (char *)malloc(length); - if (pData == NULL) { - goto __CATCH; + pMultipart = pMultipart->pNext; + partIndex ++; } - if (_MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false) { - goto __CATCH; - } + } else { //single part + if (pMsg->nPartCount > 0) { - if (szBuff == NULL) { - szBuff = (char *)malloc(length); - } else { - szTempPtr = (char *)realloc(szBuff, curLen + length); + if (bSavePartsAsTempFiles) { + if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) { + if (errno == EEXIST) { + MSG_DEBUG("exist dir : [%s]", szTempMediaDir); + } else { + MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir); + goto __CATCH; + } + } else { + MSG_DEBUG("make dir : [%s]", szTempMediaDir); + } + } - //NULL pointer check for realloc - if (szTempPtr == NULL) + if (__MmsMultipartSaveAsTempFile(&pMsg->msgType, &pMsg->msgBody, + (char*)MSG_DATA_PATH, pMsg->szFileName, 0, bSavePartsAsTempFiles) == false) goto __CATCH; - else - szBuff = szTempPtr; - } - - if (szBuff == NULL) { - goto __CATCH; } + } + MSG_DEBUG("### Success ###"); + MSG_END(); + return true; - memset(szBuff + curLen, 0, length); - - if (curLen == 0 && (pData[0] == QUOTE) && (bQuote == false)) { - /* QUOTE: check first time only */ - - strncpy(szBuff + curLen, (char*)pData + 1, length - 2); - curLen += (length - 1); - bQuote = true; - } else { - strncpy(szBuff + curLen, (char*)pData, length - 1); - curLen += length; - } +__CATCH: - if (pData) { - free(pData); - pData = NULL; - } + MmsInitHeader(); + MmsUnregisterDecodeBuffer(); - *pLength += length; // + NULL + if (pFile != NULL) { + MsgCloseFile(pFile); + pFile = NULL; } - return szBuff; -__RETURN: - if (pData) { - free(pData); - pData = NULL; - } + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); - *pLength = 1; + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); - MmsBinaryDecodeMovePointer(pFile, offset, totalLength); + MSG_DEBUG("### Fail ###"); + MSG_END(); + return false; +} - return szBuff; +static bool __MsgFreeHeaderAddress(MsgHeaderAddress *pAddr) +{ + MsgHeaderAddress *pTempAddr = NULL; -__CATCH: + while (pAddr != NULL) { + pTempAddr = pAddr; + pAddr = pAddr->pNext; - if (szBuff) { - free(szBuff); - szBuff = NULL; - } + if (pTempAddr->szAddr) { + free(pTempAddr->szAddr); + pTempAddr->szAddr = NULL; + } - if (pData) { - free(pData); - pData = NULL; + free(pTempAddr); + pTempAddr = NULL; } - return NULL; + return true; } - -/** - * Decode Charset - * - * @param pEncodedData [in] QuotedString encoded data - * @param nCharSet [out] Decoded character set - * @return length of charset value - */ -static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSetLen, int totalLength) +static bool __MsgCheckFileNameHasInvalidChar(char *szName) { - UINT32 integer = 0; - - /* - * Charset v1.1 0x01 Well-known-charset - * Well-known-charset = Any-charset | Integer-value - * ; Both are encoded using values from - * Character Set Assignments table in Assigned Numbers - * Any-charset = - * ; Equivalent to the special RFC2616 charset value ¡°*¡± - */ + int strLen = 0; + int i = 0; - if (pFile == NULL || nCharSet == NULL || pCharSetLen == NULL) - return false; + strLen = strlen(szName); - if (__MmsBinaryDecodeInteger(pFile, &integer, pCharSetLen, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeCharset : __MmsBinaryDecodeInteger fail...\n"); - goto __CATCH; + for (i=0; i try again with value length */ + for (cIndex = 0; cIndex< cLen ; cIndex++) { + if (pOrg[cIndex] == '%') { + if (pOrg[cIndex+1] != 0 && pOrg[cIndex+2] != 0) { + snprintf(szBuf, sizeof(szBuf), "%c%c", pOrg[cIndex+1], pOrg[cIndex+2]); // read two chars after '%' - pData = (char *)malloc(valueLength - charSetLen); - if (pData == NULL) { - MSG_DEBUG("__MmsBinaryDecodeEncodedString : pData alloc fail.\n"); - goto __CATCH; - } + if (__MsgIsHexChar(szBuf) == true) { // check the two character is between 0 ~ F + OneChar = __MsgConvertHexValue(szBuf); - if (_MmsBinaryDecodeGetLongBytes(pFile, pData, valueLength - charSetLen, totalLength) == false) { - MSG_DEBUG("__MmsBinaryDecodeEncodedString : _MmsBinaryDecodeGetLongBytes fail.\n"); - goto __CATCH; + pNew[index] = OneChar; + index++; + cIndex+= 2; + continue; + } } + } + pNew[index++] = pOrg[cIndex]; + } + return pNew; +} - strncpy(szBuff, pData, bufLen - 1); +static bool __MsgParseParameter(MsgType *pType, char *pSrc) +{ + char *pName = NULL; + char *pValue = NULL; + char *pDec = NULL; + char *pTest = NULL; + char *pNextParam = NULL; + char *pExt = NULL; + int nameLen = 0; + int count; + char *pTempNextParam = NULL; + char *pCh = NULL; + char *szSrc = NULL; + char *pUTF8Buff = NULL; + + while (pSrc != NULL) { + pSrc = __MsgSkipWS(pSrc); + if (pSrc == NULL) { + /* End of parse parameter */ + return true; } - switch (charSet) { - case MSG_CHARSET_UTF16: - case MSG_CHARSET_USC2: + pNextParam = NULL; + pTempNextParam = strchr(pSrc, MSG_CH_SEMICOLON); + pCh = pSrc; - MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_USC2 \n"); + if (*pCh == MSG_CH_QUOT) { + count = 1; + } else { + count = 0; + } - nTemp = strlen(szBuff); - pTempData = (char *)malloc(nTemp + 1); - if (pTempData == NULL) { - MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n"); - goto __CATCH; - } + pCh++; + for (; pCh<=pTempNextParam ; pCh++) { + if (*pCh == MSG_CH_QUOT) + if (*(pCh - 1) != '\\') + count++; + } - memset(pTempData, 0, nTemp + 1); - memcpy(pTempData, szBuff, nTemp + 1); + if (count%2 == 0) + pNextParam = pTempNextParam; - 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 ; - } + if (pNextParam) + *pNextParam++ = MSG_CH_NULL; - mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short)); - if (mszTempStr == NULL) { - MSG_DEBUG("MmsGetMediaPartData : 1. Memory Full !!! \n"); - goto __CATCH; - } + if ((pName = strchr(pSrc, MSG_CH_EQUAL)) != NULL) { + *pName++ = MSG_CH_NULL; - memcpy(mszTempStr, ((unsigned short*)pTempData + 1), nChar * sizeof(unsigned short)); + if ((pValue = strchr(pName, MSG_CH_QUOT))!= NULL) { + *pValue++ = MSG_CH_NULL; - nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTempData + 1), nChar); + if ((pTest = strchr(pValue, MSG_CH_QUOT)) != NULL) + *pTest = MSG_CH_NULL; - pConvertedStr = (char *)malloc(nByte + 1); - if (pConvertedStr) - MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar); + pDec = MsgDecodeText(pValue); // Api is to long, consider Add to another file (MsgMIMECodec.c) } else { - if ((nChar = (nTemp / 2)) <= 0) { - MSG_DEBUG("__MmsBinaryDecodeEncodedString(%d) : nChar is invalid value (%d), charset(%d)\n", __LINE__, nChar, charSet); - goto __CATCH ; - } + pDec = MsgDecodeText(pName); + } - mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short)); - if (mszTempStr == NULL) { - MSG_DEBUG("__MmsBinaryDecodeEncodedString: 2. Memory Full !!! \n"); - goto __CATCH; - } + if (pDec) { + switch (MmsGetTextType(MmsCodeParameterCode, pSrc)) { + case MSG_PARAM_BOUNDARY: - memcpy(mszTempStr, ((unsigned short*)pTempData), nChar * sizeof(unsigned short)); + /* RFC 822: boundary := 0*69 bcharsnospace */ - nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTempData), nChar); + memset (pType->param.szBoundary, 0, MSG_BOUNDARY_LEN + 1); + strncpy(pType->param.szBoundary, pDec, MSG_BOUNDARY_LEN); + MSG_SEC_INFO("szBoundary = [%s]", pType->param.szBoundary); + break; - pConvertedStr = (char *)malloc(nByte + 1); - if (pConvertedStr != NULL) - MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar); - } + case MSG_PARAM_CHARSET: + if (pDec != NULL) { + pType->param.charset = MmsGetTextType(MmsCodeParameterCode, pDec); - if (pConvertedStr != NULL) { - pNewData = pConvertedStr; - nRead2 = nByte; + if (pType->param.charset == -1) + pType->param.charset = MSG_CHARSET_UNKNOWN; + } else { + pType->param.charset = MSG_CHARSET_UNKNOWN; + } + MSG_SEC_INFO("type = %d [charset] = %d", pType->type, pType->param.charset); + break; - strncpy(szBuff, pNewData, bufLen - 1); - } + case MSG_PARAM_NAME: - break; + memset (pType->param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1); - case MSG_CHARSET_US_ASCII: + pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec); - MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_US_ASCII \n"); + if (pUTF8Buff) { + if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { + if ((MSG_LOCALE_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) { + nameLen = (MSG_LOCALE_FILENAME_LEN_MAX-1) - strlen(pExt); + } else { + nameLen = strlen(pUTF8Buff) - strlen(pExt); + } - case MSG_CHARSET_UTF8: + strncpy(pType->param.szName, pUTF8Buff, nameLen); + g_strlcat(pType->param.szName, pExt, sizeof(pType->param.szName)); + } else { + strncpy(pType->param.szName, pUTF8Buff, (MSG_LOCALE_FILENAME_LEN_MAX-1)); + } + free(pUTF8Buff); + pUTF8Buff = NULL; - MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_UTF8 or Others \n"); + if (__MsgChangeSpace(pType->param.szName, &szSrc) == true) { + if (szSrc) + strncpy(pType->param.szName, szSrc , strlen(szSrc)); + } - pNewData = pTempData; - nRead2 = nTemp; + if (szSrc) { + free(szSrc); + szSrc = NULL; + } - break; + // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" + __MsgRemoveFilePath(pType->param.szName); + } else { + MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); + } - case MSG_CHARSET_ISO_8859_7: /* Greek */ + MSG_SEC_INFO("szName = %s", pType->param.szName); + break; - MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_ISO_8859_7 \n"); + case MSG_PARAM_FILENAME: - nTemp = strlen(szBuff); - pTempData = (char *)malloc(nTemp + 1); - if (pTempData == NULL) - { - MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n"); - goto __CATCH; - } + memset (pType->param.szFileName, 0, MSG_FILENAME_LEN_MAX+1); - memset(pTempData, 0 , nTemp + 1); - memcpy(pTempData, szBuff, nTemp + 1); + pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec); - nByte = MsgGetLatin72UTFCodeSize((unsigned char*)pTempData, nTemp); - pConvertedStr = (char *)malloc(nByte + 1); + if (pUTF8Buff) { + if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { + if ((MSG_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) { + nameLen = (MSG_FILENAME_LEN_MAX-1) - strlen(pExt); + } else { + nameLen = strlen(pUTF8Buff) - strlen(pExt); + } - if (pConvertedStr != NULL) { - MsgLatin7code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTempData, nTemp); + strncpy(pType->param.szFileName, pUTF8Buff, nameLen); + g_strlcat (pType->param.szFileName, pExt, sizeof(pType->param.szFileName)); + } else { + strncpy(pType->param.szFileName, pUTF8Buff, (MSG_FILENAME_LEN_MAX-1)); + } + free(pUTF8Buff); + pUTF8Buff = NULL; - pNewData = pConvertedStr; - nRead2 = nByte; + if (__MsgChangeSpace(pType->param.szFileName, &szSrc) == true) { + snprintf(pType->param.szFileName, sizeof(pType->param.szFileName), "%s", szSrc); + } - strncpy(szBuff, pNewData, bufLen - 1); - } + if (szSrc) { + free(szSrc); + szSrc = NULL; + } - break; + // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" + __MsgRemoveFilePath(pType->param.szFileName); + } else { + MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); + } - case MSG_CHARSET_ISO_8859_9: /* Turkish */ + MSG_SEC_INFO("szFileName = %s", pType->param.szFileName); - MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_ISO_8859_9 \n"); + break; - nTemp = strlen(szBuff); - pTempData = (char *)malloc(nTemp + 1); - if (pTempData == NULL) { - MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n"); - goto __CATCH; - } + case MSG_PARAM_TYPE: - memset(pTempData, 0 , nTemp + 1); - memcpy(pTempData, szBuff, nTemp + 1); + /* type/subtype of root. Only if content-type is multipart/related */ - nByte = MsgGetLatin52UTFCodeSize((unsigned char*)pTempData, nTemp); - pConvertedStr = (char *)malloc(nByte + 1); + pType->param.type = MimeGetMimeIntFromMimeString(pDec); + MSG_SEC_INFO("type = %d", pType->param.type); - if (pConvertedStr != NULL) { - MsgLatin5code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTempData, nTemp); + break; - pNewData = pConvertedStr; - nRead2 = nByte; + case MSG_PARAM_START: - strncpy(szBuff, pNewData, bufLen - 1); - } + /* Content-id. Only if content-type is multipart/related */ - break; + memset (pType->param.szStart, 0, MSG_MSG_ID_LEN + 1); + strncpy(pType->param.szStart, pDec, MSG_MSG_ID_LEN); - default: + MSG_SEC_INFO("szStart = %s", pType->param.szStart); - MSG_DEBUG("__MmsBinaryDecodeEncodedString: Other charsets \n"); + break; - nTemp = strlen(szBuff); - pTempData = (char *)malloc(nTemp + 1); - if (pTempData == NULL) { - MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n"); - goto __CATCH; - } + case MSG_PARAM_START_INFO : - memset(pTempData, 0, nTemp + 1); - memcpy(pTempData, szBuff, nTemp + 1); + /* Only if content-type is multipart/related */ - nByte = MsgGetLatin2UTFCodeSize((unsigned char*)pTempData, nTemp); - pConvertedStr = (char *)malloc(nByte + 1); + memset (pType->param.szStartInfo, 0, MSG_MSG_ID_LEN + 1); + strncpy(pType->param.szStartInfo, pDec, MSG_MSG_ID_LEN); - if (pConvertedStr != NULL) { - MsgLatin2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTempData, nTemp); + MSG_SEC_INFO("szStartInfo = %s", pType->param.szStartInfo); - pNewData = pConvertedStr; - nRead2 = nByte; + break; - strncpy(szBuff, pNewData, bufLen - 1); - } + case MSG_PARAM_REPORT_TYPE : - break; + // only used as parameter of Content-Type: multipart/report; report-type=delivery-status; - } //switch (charset) - - } //switch (__MmsDecodeValueLength....) + if (pDec != NULL && strcasecmp(pDec, "delivery-status") == 0) { + pType->param.reportType = MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS; + } else { + pType->param.reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; + } - if (pData) { - free(pData); - pData = NULL; - } + MSG_SEC_INFO("reportType = %s", pDec); + break; - if (pTempData) { - free(pTempData); - pTempData = NULL; - } + default: - if (mszTempStr) { - free(mszTempStr); - mszTempStr = NULL; - } + MSG_DEBUG("Unknown paremeter (%s)", pDec); + break; + } - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; + free(pDec); + pDec = NULL; + } + } + pSrc = pNextParam; } - - return true; +} -__CATCH: - - if (pData) { - free(pData); - pData = NULL; - } - - if (pTempData) { - free(pTempData); - pTempData = NULL; +static char *__MsgSkipWS(char *s) +{ + while (true) { + if ((*s == MSG_CH_CR) || (*s == MSG_CH_LF) || (*s == MSG_CH_SP) || (*s == MSG_CH_TAB)) { + ++s; + } else if ((*s != '(') || (__MsgSkipComment(s,(long)NULL)==NULL)) { + return s; + } } +} - if (mszTempStr) { - free(mszTempStr); - mszTempStr = NULL; - } +static char *__MsgSkipComment (char *s,long trim) +{ - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; - } + char *ret; + char *s1 = s; + char *t = NULL; - return false; -} + // ignore empty space + for (ret = ++s1; *ret == ' '; ret++) + ; + // handle '(', ')', '\', '\0' + do { + switch (*s1) { + case '(': + if (!__MsgSkipComment (s1,(long)NULL)) + goto __NULL_RETURN; + t = --s1; + break; + case ')': + s = ++s1; + if (trim) { + if (t) { + t[1] = '\0'; + } else { + *ret = '\0'; + } + } + return ret; + case '\\': + if (*++s1) + break; + case '\0': + *s = '\0'; + goto __NULL_RETURN; + case ' ': + break; + default: + t = s1; + break; + } + } while (s1++); +__NULL_RETURN: + return NULL; +} -/** - * Decode Encoded Addresses - * - * @param pEncodedData [in] QuotedString encoded data - * @param pAddrLength [out] Decoded address length - * @return Decoded address list - */ -MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength) +static char *__MsgConvertLatin2UTF8FileName(char *pSrc) { - UINT32 valueLength = 0; - UINT32 charSet = 0; - int charSetLen = 0; - int textLength = 0; - char *pAddrStr = NULL; - MsgHeaderAddress *pAddr = NULL; - - MSG_DEBUG("__MmsDecodeEncodedAddress: decoding address..\n"); - - if (pFile == NULL) { - MSG_DEBUG("__MmsDecodeEncodedAddress: invalid file or buffer\n"); - goto __CATCH; - } + char *pUTF8Buff = NULL; +// char *pData = NULL; - /* - * Encoded_string_value = Text-string | Value-length Char-set Text-String - * Text-string = [Quote]*TEXT End-of-string - * Value-length = 0 ~ 31 - */ - switch (__MmsDecodeValueLength(pFile, &valueLength, totalLength)) { - case -1: - goto __CATCH; + //convert utf8 string + if (MmsIsUtf8String((unsigned char*)pSrc, strlen(pSrc)) == false) { + int length = 0; + int utf8BufSize = 0; - case 0: + length = strlen(pSrc); + utf8BufSize = __MsgGetLatin2UTFCodeSize((unsigned char*)pSrc, length); + if (utf8BufSize < 3) + utf8BufSize = 3; //min value - /* Text-string = [Quote]*TEXT End-of-string */ + pUTF8Buff = (char *)calloc(1, utf8BufSize + 1); - textLength = 0; - pAddrStr = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); - if (pAddrStr == NULL) { - MSG_DEBUG("__MmsDecodeEncodedAddress : 1. __MmsBinaryDecodeText2 fail.\n"); + if (pUTF8Buff == NULL) { + MSG_DEBUG("pUTF8Buff alloc fail"); goto __CATCH; } - break; - - default: - - /* Value-length Charset Text_string */ - if (__MmsBinaryDecodeCharset(pFile, &charSet, &charSetLen, totalLength) == false) { - MSG_DEBUG("__MmsDecodeEncodedAddress : __MmsBinaryDecodeCharset error\n"); + if (__MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pSrc, length) < 0) { + MSG_DEBUG("MsgLatin2UTF fail"); goto __CATCH; } + } else { + int length = strlen(pSrc); + pUTF8Buff = (char *)calloc(1, length+1); - textLength = 0; - pAddrStr = __MmsBinaryDecodeText2(pFile, totalLength, &textLength); - if (pAddrStr == NULL) { - /* There can be some error in data - no NULL -> try again with value length */ - - pAddrStr = (char *)malloc(valueLength - charSetLen); - if (pAddrStr == NULL) { - MSG_DEBUG("__MmsDecodeEncodedAddress : pData alloc fail.\n"); - goto __CATCH; - } - - if (_MmsBinaryDecodeGetLongBytes(pFile, pAddrStr, valueLength - charSetLen, totalLength) == false) { - MSG_DEBUG("__MmsDecodeEncodedAddress : _MmsBinaryDecodeGetLongBytes fail.\n"); - goto __CATCH; - } + if (pUTF8Buff == NULL) { + MSG_DEBUG("pUTF8Buff alloc fail"); + goto __CATCH; } - break; + memcpy(pUTF8Buff, pSrc, length); } - pAddr = (MsgHeaderAddress *)malloc(sizeof(MsgHeaderAddress)); - if (pAddr == NULL) - goto __CATCH; - - memset(pAddr, 0, sizeof(MsgHeaderAddress)); - pAddr->szAddr = pAddrStr; + //convert hex string +// if (__MsgIsPercentSign(pUTF8Buff) == true) { +// pData = MsgChangeHexString(pUTF8Buff); +// if (pData) { +// free(pUTF8Buff); +// pUTF8Buff = pData; +// } +// } - return pAddr; + return pUTF8Buff; __CATCH: - if (pAddrStr) { - free(pAddrStr); - pAddrStr = NULL; + if (pUTF8Buff) { + free(pUTF8Buff); + pUTF8Buff = NULL; } return NULL; } - -/** - * Decode Encoded Pointer String - * - * @param pEncodedData [in] Long integer encoded data - * @param pLongInteger [out] Decoded long integer - * @return Decoded address list - */ -static bool __MmsDecodeLongInteger(FILE *pFile, UINT32 *pLongInteger, int totalLength) +static bool __MsgChangeSpace(char *pOrg, char **ppNew) { - UINT8 oneByte = 0; - - /* - * Long-integer = Short-length Multi-octet-integer - * Short-length = 0~30 - * Multi-octet-integer - */ + char *pNew = NULL; + int cLen = 0; + int cIndex =0; + int index = 0; - if (pFile == NULL || pLongInteger == NULL) + if (pOrg == NULL) return false; - *pLongInteger = 0; + cLen = strlen(pOrg); - if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) - goto __CATCH; + pNew = (char *)calloc(1, cLen + 1); + if (pNew == NULL) + return false; - if (oneByte > 31) - goto __CATCH; + memset(pNew, 0, cLen + 1); - *pLongInteger = __MmsHeaderDecodeIntegerByLength(pFile, oneByte, totalLength); + for (cIndex=0; cIndex' in Start Param : contentID ex] <0_1.jpg> or <1233445> + if (szStart && szStart[0]) { + int startLen = 0; + startLen = strlen(szStart); + if (szStart[0] == '<' && szStart[startLen - 1] == '>') { + strncpy(szTmpStart, &szStart[1], startLen - 2); } else { - pTmpBuff = _MsgDecodeText(pLatinBuff); - pUTF8Buff = pTmpBuff; - free (pLatinBuff); - pLatinBuff = NULL; + strncpy(szTmpStart, szStart, startLen); } } - if (pUTF8Buff) { - /* - * keeping extension - * it should be kept extention even if the file name is shorten - */ - - length = strlen(pUTF8Buff); - if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { - int nameLength = 0; - nameLength = (length < bufLen) ? (length - strlen(pExt)) : (bufLen - strlen(pExt)); - strncpy(szBuff, pUTF8Buff, nameLength); - strcat (szBuff, pExt); + // remove '<' and '>' in ContentID : contentID ex] <0_1.jpg> or <1233445> + if (multipartType->szContentID[0]) { + strLen = strlen(multipartType->szContentID); + if (multipartType->szContentID[0] == '<' && multipartType->szContentID[strLen - 1] == '>') { + strncpy(szTmpContentID, &(multipartType->szContentID[1]), strLen - 2); } else { - strncpy(szBuff, pUTF8Buff, bufLen - 1); + strncpy(szTmpContentID, multipartType->szContentID, strLen); } - free(pUTF8Buff); - pUTF8Buff = NULL; - - return textLength; - } - -__CATCH: - - if (pLatinBuff) { - free(pLatinBuff); - pLatinBuff = NULL; } - if (pUTF8Buff) { - free(pUTF8Buff); - pUTF8Buff = NULL; + // remove '<' and '>' in ContentLocation : contentID ex] <0_1.jpg> or <1233445> + if (multipartType->szContentLocation[0]) { + strLen = strlen(multipartType->szContentLocation); + if (multipartType->szContentLocation[0] == '<' && multipartType->szContentLocation[strLen - 1] == '>') { + strncpy(szTmpContentLO, &multipartType->szContentLocation[1], strLen - 2); + } else { + strncpy(szTmpContentLO, multipartType->szContentLocation, strLen); + } } - return -1; -} - - -/* ========================================================== - - T E X T D E C O D I N G - - ==========================================================*/ - - -bool MmsTextDecodeMsgBody(FILE *pFile) -{ - MSG_DEBUG("MmsTextDecodeMsgBody: \n"); - return false; -} - -bool __MmsTextDecodeMsgHeader(FILE *pFile) -{ - return true; -} - - -/* ========================================================== - - M M S D E C O D I N G - - ==========================================================*/ - -// to get message body this function should be modified from message raw file. -bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath) -{ - FILE *pFile = NULL; - MmsMsg *pMsg = NULL; - MsgMultipart *pMultipart = NULL; - int nSize = 0; - char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; - char szTempMediaDir[MSG_FILEPATH_LEN_MAX] = {0, }; - int attachmax = MSG_ATTACH_MAX; - - MSG_DEBUG("_MmsReadMsgBody: start read msg(msgID=%d)\n", msgID); - - MmsPluginStorage::instance()->getMmsMessage(&pMsg); - memset(pMsg, 0, sizeof(MmsMsg)); - - _MmsInitHeader(); + if ((szTmpContentID[0] == '\0') && (szTmpContentLO[0] == '\0') && (multipartType->type == MIME_UNKNOWN)) + return MSG_PRESENTATION_NONE; - if (bRetrieved && (retrievedPath != NULL)) { - strncpy(szFullPath, retrievedPath, (strlen(retrievedPath) > MSG_FILEPATH_LEN_MAX ? MSG_FILEPATH_LEN_MAX:strlen(retrievedPath))); + // exception handling + if (szTmpStart[0] != '\0') { + // presentation part : 1.compare with contentID 2.compare with content Location 3. compare with type + if (strcmp(szTmpStart, szTmpContentID) == 0) { + return MSG_PRESENTATION_ID; + } else if (strcmp(szTmpStart, szTmpContentLO) == 0) { + return MSG_PRESENTATION_LOCATION; + } else if (multipartType->type == typeParam) { + return MSG_PRESENTATION_TYPE_BASE; + } else { + return MSG_PRESENTATION_NONE; + } } else { - MmsPluginStorage::instance()->getMmsRawFilePath(msgID, szFullPath); - } - - 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))); - - MSG_DEBUG("szFullPath = (%s)", szFullPath); - - if (MsgGetFileSize(szFullPath, &nSize) == false) { - MSG_DEBUG("MsgGetFileSize: failed"); - goto __CATCH; - } - - pFile = MsgOpenFile(szFullPath, "rb"); - - if (pFile == NULL) { - MSG_DEBUG("_MmsReadMsgBody: invalid mailbox\n"); - goto __CATCH; - } - - _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX); - - if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) { - MSG_DEBUG("_MmsReadMsgBody: MmsBinaryDecodeMsgHeader fail...\n"); - goto __CATCH; - } - -#ifdef __SUPPORT_DRM__ - if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_FINISH) - MmsDrm2SetConvertState(MMS_DRM2_CONVERT_NONE); //initialize convertState -#endif - - if (MmsBinaryDecodeMsgBody(pFile, szFullPath, nSize) == false) { - MSG_DEBUG("_MmsReadMsgBody: MmsBinaryDecodeMsgBody fail\n"); - goto __CATCH; - } - -#ifdef __SUPPORT_DRM__ - if (MmsDrm2GetConvertState() == MMS_DRM2_CONVERT_REQUIRED) { - MSG_DEBUG("_MmsReadMsgBody: MmsDrm2GetConvertState returns MMS_DRM2_CONVERT_REQUIRED.\n"); - goto RETURN; + if (multipartType->type == typeParam && typeParam != MIME_UNKNOWN) { + return MSG_PRESENTATION_TYPE_BASE; + } else { + return MSG_PRESENTATION_NONE; + } } -#endif - - /* Set mmsHeader.msgType & msgBody to pMsg ----------- */ - - pMsg->mmsAttrib.contentType = (MsgContentType)mmsHeader.msgType.type; - - memcpy(&(pMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType)); - memcpy(&(pMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody)); - - if (pMsg->msgBody.pPresentationBody) { - if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0) - goto __CATCH; - - pMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMsg->msgBody.pPresentationBody->size + 1); - if (pMsg->msgBody.pPresentationBody->body.pText == NULL) - goto __CATCH; - - memset(pMsg->msgBody.pPresentationBody->body.pText, 0, pMsg->msgBody.pPresentationBody->size + 1); +} - ULONG nRead = 0; - nRead = MsgReadFile(pMsg->msgBody.pPresentationBody->body.pText, sizeof(char), pMsg->msgBody.pPresentationBody->size, pFile); - if (nRead == 0) - goto __CATCH; +static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo) +{ + MSG_BEGIN(); + MsgMultipart *pNextPart = NULL; + MsgMultipart *pRemovePart = NULL; - } + if (__MsgIsMultipartRelated(pMsgType->type)) { + // assign the multipart to presentation part + // remove the multipart(pCurPresentation) which is presentation part from the linked list. + // if there is no presentation part -> assign first multipart to presentation part by force. + if (pPresentationInfo->pCurPresentation == NULL) { + pPresentationInfo->pCurPresentation = pMsgBody->body.pMultipart; + pPresentationInfo->pPrevPart = NULL; + pPresentationInfo->factor = MSG_PRESENTATION_NONE; + } - MsgCloseFile(pFile); - pFile = NULL; + if (pPresentationInfo->pCurPresentation != NULL && __MsgIsPresentablePart(pPresentationInfo->pCurPresentation->type.type)) { + /* Presentable Part is some MARK-UP page, such as SMIL, HTML, WML, XHTML. + * In this case, COPY the Presentation part and leave other multiparts. + */ + memcpy(&pMsgBody->presentationType, &pPresentationInfo->pCurPresentation->type, sizeof(MsgType)); + pMsgBody->pPresentationBody = pPresentationInfo->pCurPresentation->pBody; - /* nPartCount */ - pMsg->nPartCount = 0; + // remove pCurPresentation from multipart linked list + if ((pPresentationInfo->factor == MSG_PRESENTATION_NONE)||(pPresentationInfo->pPrevPart == NULL)) { + // first part + pMsgBody->body.pMultipart = pPresentationInfo->pCurPresentation->pNext; + pMsgType->contentSize -= pPresentationInfo->pCurPresentation->pBody->size; + pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size; + if (pPresentationInfo->pCurPresentation) { - if (MsgIsMultipart(mmsHeader.msgType.type) == true) { - pMultipart = pMsg->msgBody.body.pMultipart; - while (pMultipart) { - pMsg->nPartCount++; + MmsReleaseMsgDRMInfo(&pPresentationInfo->pCurPresentation->type.drmInfo); - if (pMultipart->type.type == MIME_TEXT_PLAIN) - attachmax++; + free(pPresentationInfo->pCurPresentation); + pPresentationInfo->pCurPresentation = NULL; + } + } else { + // not a first part + pPresentationInfo->pPrevPart->pNext = pPresentationInfo->pCurPresentation->pNext; + pMsgType->contentSize -= pPresentationInfo->pCurPresentation->pBody->size; + pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size; + if (pPresentationInfo->pCurPresentation) { + free(pPresentationInfo->pCurPresentation); + pPresentationInfo->pCurPresentation = NULL; + } + } + } else if (pPresentationInfo->pCurPresentation != NULL && MmsIsTextType(pPresentationInfo->pCurPresentation->type.type)) { + /* NON-Presentable Part is some PLAIN part such as, text/plain, multipart/alternative. + * In this case, leave the Presentation part as a multipart and remove other multiparts. + */ - if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED)||(mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) { - if ((pMsg->nPartCount >= attachmax)&&(pMultipart->pNext != NULL)) { - _MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type); + // Backup the multipart link information + pNextPart = pMsgBody->body.pMultipart; - free(pMultipart->pNext->pBody); - pMultipart->pNext->pBody= NULL; + // Copy presentation part as a main part + memcpy(pMsgType, &pPresentationInfo->pCurPresentation->type, sizeof(MsgType)); + memcpy(pMsgBody, pPresentationInfo->pCurPresentation->pBody, sizeof(MsgBody)); - free(pMultipart->pNext); + // Remove multipart linked list + while (pNextPart) { + pRemovePart = pNextPart; + pNextPart = pNextPart->pNext; - pMultipart->pNext = NULL; - break; + if (pRemovePart->pBody) { + MmsReleaseMsgBody(pRemovePart->pBody, pRemovePart->type.type); + free(pRemovePart->pBody); + pRemovePart->pBody = NULL; } - } - pMultipart = pMultipart->pNext; - } - } else { - if (pMsg->msgBody.size > 0) - pMsg->nPartCount++; - } - - /* make temporary */ - snprintf(szTempMediaDir, MSG_FILEPATH_LEN_MAX, MSG_DATA_PATH"%s.dir", pMsg->szFileName); - /////////////////////////////////////////////// - // call before processing urgent event. - //_MmsInitHeader(); - //_MmsUnregisterDecodeBuffer(); - /////////////////////////////////////////////// + free(pRemovePart); + pRemovePart = NULL; + } + } else { - if (MsgIsMultipart(pMsg->msgType.type) == true) { - int partIndex = 0; - pMultipart = pMsg->msgBody.body.pMultipart; - - if (bSavePartsAsTempFiles) { - if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) { - if (errno == EEXIST) { - MSG_DEBUG("The %s already exists", szTempMediaDir); - } else { - MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir); - goto __CATCH; - } - } - } - - while (pMultipart) { - - if (_MmsMultipartSaveAsTempFile(&pMultipart->type, pMultipart->pBody, - (char*)MSG_DATA_PATH, pMsg->szFileName, partIndex, bSavePartsAsTempFiles) == false) - goto __CATCH; - - pMultipart = pMultipart->pNext; - partIndex ++; - } - - } else { //single part - if (pMsg->nPartCount > 0) { - - if (bSavePartsAsTempFiles) { - if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) { - if (errno == EEXIST) { - MSG_DEBUG("The %s already exists", szTempMediaDir); - } else { - MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir); - goto __CATCH; - } - } - } - - if (_MmsMultipartSaveAsTempFile( &pMsg->msgType, &pMsg->msgBody, - (char*)MSG_DATA_PATH, pMsg->szFileName, 0, bSavePartsAsTempFiles) == false) - goto __CATCH; - } - } - MSG_DEBUG("**** _MmsReadMsgBody: E N D (Success) ***\n"); - return true; - -#ifdef __SUPPORT_DRM__ - -RETURN: - - if (pFile != NULL) { - MsgCloseFile(pFile); - pFile = NULL; - } - - return false; - -#endif - -__CATCH: - - _MmsInitHeader(); - _MmsUnregisterDecodeBuffer(); - - if (pFile != NULL) { - MsgCloseFile(pFile); - pFile = NULL; - } - -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pMsg->msgType.drmInfo); -#endif - - _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type); - MSG_DEBUG("_MmsReadMsgBody: E N D (fail) ******************** \n"); - - return false; -} - - -bool MsgFreeHeaderAddress(MsgHeaderAddress *pAddr) -{ - MsgHeaderAddress *pTempAddr = NULL; - - while (pAddr != NULL) { - pTempAddr = pAddr; - pAddr = pAddr->pNext; - - if (pTempAddr->szAddr) { - free(pTempAddr->szAddr); - pTempAddr->szAddr = NULL; - } - - free(pTempAddr); - pTempAddr = NULL; - } - - return true; -} - -bool MsgCheckFileNameHasInvalidChar(char *szName) -{ - int strLen = 0; - int i = 0; - - strLen = strlen(szName); - - for (i=0; i bcharsnospace */ - - memset (pType->param.szBoundary, 0, MSG_BOUNDARY_LEN + 1); - strncpy(pType->param.szBoundary, pDec, MSG_BOUNDARY_LEN); - MSG_DEBUG("_MsgParseParameter: szBoundary = %s \n", pType->param.szBoundary); - break; - - case MSG_PARAM_CHARSET: - pType->param.charset = _MsgGetCode(MSG_CHARSET, pDec); - - if (pType->param.charset == INVALID_HOBJ) - pType->param.charset = MSG_CHARSET_UNKNOWN; - - MSG_DEBUG("_MsgParseParameter: type = %d [charset] = %d \n", pType->type, pType->param.charset); - break; - - case MSG_PARAM_NAME: - - memset (pType->param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1); - - pUTF8Buff = MsgConvertLatin2UTF8FileName(pDec); - - if (pUTF8Buff) { - if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { - if ((MSG_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) { - nameLen = (MSG_FILENAME_LEN_MAX-1) - strlen(pExt); - } else { - nameLen = strlen(pUTF8Buff) - strlen(pExt); - } - - strncpy(pType->param.szName, pUTF8Buff, nameLen); - strcat (pType->param.szName, pExt); - } else { - strncpy(pType->param.szName, pUTF8Buff, (MSG_FILENAME_LEN_MAX-1)); - } - free(pUTF8Buff); - pUTF8Buff = NULL; - - if (_MsgChangeSpace(pType->param.szName, &szSrc) == true) { - if (szSrc) - strncpy(pType->param.szName, szSrc , strlen(szSrc)); - } - - if (szSrc) { - free(szSrc); - szSrc = NULL; - } - - // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" - _MsgRemoveFilePath(pType->param.szName); - } else { - MSG_DEBUG("_MsgParseParameter: MsgConvertLatin2UTF8FileName(%s) return NULL\n", pDec); - } - - MSG_DEBUG("_MsgParseParameter: szName = %s \n", pType->param.szName); - break; - - case MSG_PARAM_FILENAME: - - memset (pType->param.szFileName, 0, MSG_FILENAME_LEN_MAX+1); - - pUTF8Buff = MsgConvertLatin2UTF8FileName(pDec); - - if (pUTF8Buff) { - if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { - if ((MSG_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) { - nameLen = (MSG_FILENAME_LEN_MAX-1) - strlen(pExt); - } else { - nameLen = strlen(pUTF8Buff) - strlen(pExt); - } - - strncpy(pType->param.szFileName, pUTF8Buff, nameLen); - strcat (pType->param.szFileName, pExt); - } else { - strncpy(pType->param.szFileName, pUTF8Buff, (MSG_FILENAME_LEN_MAX-1)); - } - free(pUTF8Buff); - pUTF8Buff = NULL; - - if (_MsgChangeSpace(pType->param.szFileName, &szSrc) == true) - strcpy(pType->param.szFileName, szSrc); - - if (szSrc) { - free(szSrc); - szSrc = NULL; - } - - // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" - _MsgRemoveFilePath(pType->param.szFileName); - } else { - MSG_DEBUG("_MsgParseParameter: MsgConvertLatin2UTF8FileName(%s) return NULL\n", pDec); - } - - MSG_DEBUG("_MsgParseParameter: szFileName = %s \n", pType->param.szFileName); - - break; - - case MSG_PARAM_TYPE: - - /* type/subtype of root. Only if content-type is multipart/related */ - - pType->param.type = _MsgGetCode(MSG_TYPE, pDec); - MSG_DEBUG("_MsgParseParameter: type = %d \n", pType->param.type); - - break; - - case MSG_PARAM_START: - - /* Content-id. Only if content-type is multipart/related */ - - memset (pType->param.szStart, 0, MSG_MSG_ID_LEN + 1); - strncpy(pType->param.szStart, pDec, MSG_MSG_ID_LEN); - - MSG_DEBUG("_MsgParseParameter: szStart = %s \n", pType->param.szStart); - - break; - - case MSG_PARAM_START_INFO : - - /* Only if content-type is multipart/related */ - - memset (pType->param.szStartInfo, 0, MSG_MSG_ID_LEN + 1); - strncpy(pType->param.szStartInfo, pDec, MSG_MSG_ID_LEN); - - MSG_DEBUG("_MsgParseParameter: szStartInfo = %s \n", pType->param.szStartInfo); - - break; - - case MSG_PARAM_REPORT_TYPE : - - // only used as parameter of Content-Type: multipart/report; report-type=delivery-status; - - if (pDec != NULL && strcasecmp(pDec, "delivery-status") == 0) { - pType->param.reportType = MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS; - } else { - pType->param.reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; - } - - MSG_DEBUG("_MsgParseParameter: reportType = %s \n", pDec); - break; - - default: - - MSG_DEBUG("_MsgParseParameter: Unknown paremeter (%s)\n", pDec); - break; - } - - if (pDec) { - free(pDec); - pDec = NULL; - } - } - pSrc = pNextParam; - } - return true; -} - -char *_MsgSkipWS(char *s) -{ - while (true) { - if ((*s == MSG_CH_CR) || (*s == MSG_CH_LF) || (*s == MSG_CH_SP) || (*s == MSG_CH_TAB)) { - ++s; - } else if ((*s != '(') || (__MsgSkipComment(s,(long)NULL)==NULL)) { - return s; - } - } -} - -char *__MsgSkipComment (char *s,long trim) -{ - - char *ret; - char *s1 = s; - char *t = NULL; - - // ignore empty space - for (ret = ++s1; *ret == ' '; ret++) - ; - - // handle '(', ')', '\', '\0' - do { - switch (*s1) { - case '(': - if (!__MsgSkipComment (s1,(long)NULL)) - return NULL; - t = --s1; - break; - case ')': - s = ++s1; - if (trim) { - if (t) { - t[1] = '\0'; - } else { - *ret = '\0'; - } - } - return ret; - case '\\': - if (*++s1) - break; - case '\0': - *s = '\0'; - return NULL; - case ' ': - break; - default: - t = s1; - break; - } - }while (s1++); - - return NULL; -} - -char *MsgConvertLatin2UTF8FileName(char *pSrc) -{ - char *pUTF8Buff = NULL; - char *pData = NULL; - - - //convert utf8 string - if (MsgIsUTF8String((unsigned char*)pSrc, strlen(pSrc)) == false) { - int length = 0; - int utf8BufSize = 0; - - length = strlen(pSrc); - utf8BufSize = MsgGetLatin2UTFCodeSize((unsigned char*)pSrc, length); - pUTF8Buff = (char *)malloc(utf8BufSize + 1); - - if (pUTF8Buff == NULL) { - MSG_DEBUG("MsgConvertLatin2UTF8FileName: pUTF8Buff alloc fail \n"); - goto __CATCH; - } - - if (MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pSrc, length) < 0) { - MSG_DEBUG("MsgConvertLatin2UTF8FileName: MsgLatin2UTF fail \n"); - goto __CATCH; - } - } else { - int length = strlen(pSrc); - pUTF8Buff = (char *)calloc(1, length+1); - - if (pUTF8Buff == NULL) { - MSG_DEBUG("MsgConvertLatin2UTF8FileName: pUTF8Buff alloc fail \n"); - goto __CATCH; - } - - memcpy(pUTF8Buff, pSrc, length); - } - - //convert hex string - if (MsgIsPercentSign(pUTF8Buff) == true) { - pData = MsgChangeHexString(pUTF8Buff); - if (pData) { - strcpy(pUTF8Buff, pData); - free(pData); - pData = NULL; - } - } - - return pUTF8Buff; - -__CATCH: - - if (pUTF8Buff) { - free(pUTF8Buff); - pUTF8Buff = NULL; - } - if (pData) { - free(pData); - pData = NULL; - } - return NULL; -} - -bool _MsgChangeSpace(char *pOrg, char **ppNew) -{ - char *pNew = NULL; - int cLen = 0; - int cIndex =0; - int index = 0; - - if (pOrg == NULL) - return false; - - cLen = strlen(pOrg); - - pNew = (char *)malloc(cLen + 1); - if (pNew == NULL) - return false; - - memset(pNew, 0, cLen + 1); - - for (cIndex=0; cIndex vf7.gif - if (pPath != NULL && *(pPath+1) != '\0') { - strncpy(szFileName, pPath+1, strlen(pPath+1)); - strncpy(pSrc, szFileName , strlen(szFileName)); - } - } - // Remove additional file information - // ex) Content-type: application/octet-stream; name="060728gibson_210.jpg?size=s" - // if "?size=" exist, insert NULL char. - { - pTemp = strcasestr(pSrc, "?size="); - if (pTemp != NULL) - *pTemp = '\0'; - } -} - -bool MsgIsUTF8String(unsigned char *szSrc, int nChar) -{ - MSG_DEBUG("MsgIsUTF8String: --------------- \n"); - - if (szSrc == NULL) { - MSG_DEBUG("MsgIsUTF8String: szSrc is NULL !!!! --------------- \n"); - return true; - } - - while (nChar > 0 && (*szSrc != '\0')) { - if (*szSrc < 0x80) { - szSrc++; - nChar--; - } else if ((0xC0 <= *szSrc) && (*szSrc < 0xE0)) { - if (*(szSrc + 1) >= 0x80) { - szSrc += 2; - nChar -= 2; - } else { - MSG_DEBUG("MsgIsUTF8String: 1. NOT utf8 range!\n"); - goto __CATCH; - } - } else if (*szSrc >= 0xE0) { - if (*(szSrc + 1) >= 0x80) { - if (*(szSrc + 2) >= 0x80) { - szSrc += 3; - nChar -= 3; - } else { - MSG_DEBUG("MsgIsUTF8String: 2. NOT utf8 range!\n"); - goto __CATCH; - } - } else { - MSG_DEBUG("MsgIsUTF8String: 3. NOT utf8 range!\n"); - goto __CATCH; - } - } else { - MSG_DEBUG("MsgIsUTF8String: 4. NOT utf8 range!\n"); - goto __CATCH; - } - } - - return true; - -__CATCH: - return false; -} - -bool MsgIsPercentSign(char *pSrc) -{ - char *pCh = NULL; - bool bRet = false; - - pCh = strchr(pSrc , '%'); - - if (pCh != NULL) { - bRet = true; - } else { - bRet = false; - } - - return bRet; -} - -MsgMultipart *MsgAllocMultipart(void) -{ - MsgMultipart *pMultipart = NULL; - - MSG_DEBUG("MsgAllocMultipart: --------- \n"); - - pMultipart = (MsgMultipart*)malloc(sizeof(MsgMultipart)); - if (pMultipart == NULL) { - MSG_DEBUG("MsgAllocMultipart: pMultipart malloc Fail \n"); - goto __CATCH; - } - - pMultipart->pBody = (MsgBody*)malloc(sizeof(MsgBody)); - if (pMultipart->pBody == NULL) { - MSG_DEBUG("MsgAllocMultipart: pMultipart->pBody malloc Fail \n"); - goto __CATCH; - } - - _MsgInitMsgType(&pMultipart->type); - _MsgInitMsgBody(pMultipart->pBody); - - pMultipart->pNext = NULL; - - return pMultipart; - -__CATCH: - - if (pMultipart) { - if (pMultipart->pBody) { - free(pMultipart->pBody); - pMultipart->pBody = NULL; - } - - free(pMultipart); - pMultipart = NULL; - } - - return NULL; -} - -bool _MsgInitMsgType(MsgType *pMsgType) -{ - pMsgType->offset = 0; - pMsgType->size = 0; - pMsgType->contentSize = 0; - pMsgType->disposition = 0; - pMsgType->encoding = 0; - pMsgType->type = MIME_UNKNOWN; -#ifdef FEATURE_JAVA_MMS_MIME - pMsgType->szMimeString[0] ='\0'; -#endif - pMsgType->section = 0; - - pMsgType->szOrgFilePath[0] = '\0'; - pMsgType->szContentID[0] = '\0'; - pMsgType->szContentLocation[0] = '\0'; - - pMsgType->szContentRepPos[0] = '\0'; - pMsgType->szContentRepSize[0] = '\0'; - pMsgType->szContentRepIndex[0] = '\0'; - - __MsgInitMsgContentParam(&pMsgType->param); -#ifdef __SUPPORT_DRM__ - __MsgInitMsgDRMInfo(&pMsgType->drmInfo); -#endif - - return true; -} - - -bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam) -{ - pMsgContentParam->charset = MSG_CHARSET_UNKNOWN; - pMsgContentParam->type = MIME_UNKNOWN; - pMsgContentParam->szBoundary[0] = '\0'; - pMsgContentParam->szFileName[0] = '\0'; - pMsgContentParam->szName[0] = '\0'; -#ifdef FEATURE_JAVA_MMS - pMsgContentParam->szApplicationID = NULL; - pMsgContentParam->szReplyToApplicationID = NULL; -#endif - pMsgContentParam->szStart[0] = '\0'; - pMsgContentParam->szStartInfo[0] = '\0'; - pMsgContentParam->pPresentation = NULL; - - pMsgContentParam->reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; // add only used as parameter of Content-Type: multipart/report; report-type - - return true; -} - - -bool _MsgInitMsgBody(MsgBody *pMsgBody) -{ - pMsgBody->offset = 0; - pMsgBody->size = 0; - pMsgBody->body.pText = NULL; - pMsgBody->szOrgFilePath[0] = '\0'; - - _MsgInitMsgType(&pMsgBody->presentationType); - pMsgBody->pPresentationBody = NULL; - - memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX); - - return true; -} - - -MsgPresentationFactor MsgIsPresentationEx(MsgType *multipartType, char* szStart, MsgContentType typeParam) -{ - char szTmpStart[MSG_MSG_ID_LEN + 3] = { 0, }; - char szTmpContentID[MSG_MSG_ID_LEN + 3] = { 0, }; - char szTmpContentLO[MSG_MSG_ID_LEN + 3] = { 0, }; - int strLen = 0; - - // remove '<' and '>' in Start Param : contentID ex] <0_1.jpg> or <1233445> - if (szStart && szStart[0]) { - int startLen = 0; - startLen = strlen(szStart); - if (szStart[0] == '<' && szStart[startLen - 1] == '>') { - strncpy(szTmpStart, &szStart[1], startLen - 2); - } else { - strncpy(szTmpStart, szStart, startLen); - } - } - - // remove '<' and '>' in ContentID : contentID ex] <0_1.jpg> or <1233445> - if (multipartType->szContentID[0]) { - strLen = strlen(multipartType->szContentID); - if (multipartType->szContentID[0] == '<' && multipartType->szContentID[strLen - 1] == '>') { - strncpy(szTmpContentID, &(multipartType->szContentID[1]), strLen - 2); - } else { - strncpy(szTmpContentID, multipartType->szContentID, strLen); - } - } - - // remove '<' and '>' in ContentLocation : contentID ex] <0_1.jpg> or <1233445> - if (multipartType->szContentLocation[0]) { - strLen = strlen(multipartType->szContentLocation); - if (multipartType->szContentLocation[0] == '<' && multipartType->szContentLocation[strLen - 1] == '>') { - strncpy(szTmpContentLO, &multipartType->szContentLocation[1], strLen - 2); - } else { - strncpy(szTmpContentLO, multipartType->szContentLocation, strLen); - } - } - - if ((szTmpContentID[0] == '\0') && (szTmpContentLO[0] == '\0') && (multipartType->type == MIME_UNKNOWN)) - return MSG_PRESENTATION_NONE; - - // exception handling - if (szTmpStart[0] != '\0') { - // presentation part : 1.compare with contentID 2.compare with content Location 3. compare with type - if (strcmp(szTmpStart, szTmpContentID) == 0) { - return MSG_PRESENTATION_ID; - } else if (strcmp(szTmpStart, szTmpContentLO) == 0) { - return MSG_PRESENTATION_LOCATION; - } else if (multipartType->type == typeParam) { - return MSG_PRESENTATION_TYPE_BASE; - } else { - return MSG_PRESENTATION_NONE; - } - } else { - if (multipartType->type == typeParam && typeParam != MIME_UNKNOWN) { - return MSG_PRESENTATION_TYPE_BASE; - } else { - return MSG_PRESENTATION_NONE; - } - } -} - -void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo) -{ - MSG_BEGIN(); - MsgMultipart *pNextPart = NULL; - MsgMultipart *pRemovePart = NULL; - - if (MsgIsMultipartRelated(pMsgType->type)) { - // assign the multipart to presentation part - // remove the multipart(pCurPresentation) which is presentation part from the linked list. - // if there is no presentation part -> assign first multipart to presentation part by force. - if (pPresentationInfo->pCurPresentation == NULL) { - pPresentationInfo->pCurPresentation = pMsgBody->body.pMultipart; - pPresentationInfo->pPrevPart = NULL; - pPresentationInfo->factor = MSG_PRESENTATION_NONE; - } - - if (pPresentationInfo->pCurPresentation != NULL && MsgIsPresentablePart(pPresentationInfo->pCurPresentation->type.type)) { - /* Presentable Part is some MARK-UP page, such as SMIL, HTML, WML, XHTML. - * In this case, COPY the Presentation part and leave other multiparts. - */ - memcpy(&pMsgBody->presentationType, &pPresentationInfo->pCurPresentation->type, sizeof(MsgType)); - pMsgBody->pPresentationBody = pPresentationInfo->pCurPresentation->pBody; - - // remove pCurPresentation from multipart linked list - if ((pPresentationInfo->factor == MSG_PRESENTATION_NONE)||(pPresentationInfo->pPrevPart == NULL)) { - // first part - pMsgBody->body.pMultipart = pPresentationInfo->pCurPresentation->pNext; - pMsgType->contentSize -= pPresentationInfo->pCurPresentation->pBody->size; - pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size; - if (pPresentationInfo->pCurPresentation) { -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pPresentationInfo->pCurPresentation->type.drmInfo); -#endif - free(pPresentationInfo->pCurPresentation); - pPresentationInfo->pCurPresentation = NULL; - } - } else { - // not a first part - pPresentationInfo->pPrevPart->pNext = pPresentationInfo->pCurPresentation->pNext; - pMsgType->contentSize -= pPresentationInfo->pCurPresentation->pBody->size; - pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size; - if (pPresentationInfo->pCurPresentation) { - free(pPresentationInfo->pCurPresentation); - pPresentationInfo->pCurPresentation = NULL; - } - } - } else if (pPresentationInfo->pCurPresentation != NULL && MsgIsText(pPresentationInfo->pCurPresentation->type.type)) { - /* NON-Presentable Part is some PLAIN part such as, text/plain, multipart/alternative. - * In this case, leave the Presentation part as a multipart and remove other multiparts. - */ - - // Backup the multipart link information - pNextPart = pMsgBody->body.pMultipart; - - // Copy presentation part as a main part - memcpy(pMsgType, &pPresentationInfo->pCurPresentation->type, sizeof(MsgType)); - memcpy(pMsgBody, pPresentationInfo->pCurPresentation->pBody, sizeof(MsgBody)); - - // Remove multipart linked list - while (pNextPart) { - pRemovePart = pNextPart; - pNextPart = pNextPart->pNext; - - if (pRemovePart->pBody) { - _MsgFreeBody(pRemovePart->pBody, pRemovePart->type.type); - free(pRemovePart->pBody); - pRemovePart->pBody = NULL; - } - - free(pRemovePart); - pRemovePart = NULL; - } - } else { -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pMsgBody->presentationType.drmInfo); -#endif - _MsgInitMsgType(&pMsgBody->presentationType); - pMsgBody->pPresentationBody = NULL; - } - } - MSG_END(); -} - -bool MsgIsMultipartRelated(int type) -{ - if (type == MIME_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { - return true; - } else { - return false; - } -} - -bool MsgIsPresentablePart(int type) -{ - if (type == MIME_TEXT_HTML || type == MIME_TEXT_VND_WAP_WML || type == MIME_APPLICATION_SMIL) { - return true; - } else { - return false; - } -} - -#ifdef __SUPPORT_DRM__ -void _MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo) -{ - MSG_DEBUG("_MsgFreeDRMInfo: S T A R T !!! \n"); - - if (pDrmInfo == NULL) { - MSG_DEBUG("pDrmInfo is NULL"); - return; - } - - if (pDrmInfo->szContentDescription) { - free(pDrmInfo->szContentDescription); - pDrmInfo->szContentDescription = NULL; - } - - if (pDrmInfo->szContentVendor) { - free(pDrmInfo->szContentVendor); - pDrmInfo->szContentVendor = NULL; - } - - if (pDrmInfo->szContentName) { - free(pDrmInfo->szContentName); - pDrmInfo->szContentName = NULL; - } - - if (pDrmInfo->szContentURI) { - free(pDrmInfo->szContentURI); - pDrmInfo->szContentURI = NULL; - } - - if (pDrmInfo->szRightIssuer) { - free(pDrmInfo->szRightIssuer); - pDrmInfo->szRightIssuer = NULL; - } - - if (pDrmInfo->szDrm2FullPath) { - free(pDrmInfo->szDrm2FullPath); - pDrmInfo->szDrm2FullPath = NULL; - } - -#if MMS_ENABLE_EXTEND_CFM - // DRM (Extended)CFM - if (pDrmInfo->pszContentType) { - free(pDrmInfo->pszContentType); - pDrmInfo->pszContentType = NULL; - } -#endif - - pDrmInfo->contentType = MIME_UNKNOWN; - pDrmInfo->drmType = MSG_DRM_TYPE_NONE; -} - -bool MsgCopyDrmInfo(MsgType *pPartType) -{ - char *pExt = NULL; - char *pTmpBuf = NULL; - - //convert application/vnd.oma.drm.content to media type - pPartType->type = pPartType->drmInfo.contentType; - - // fix wrong file name presentation on save media screen. - if (pPartType->szContentID[0] == '\0' && pPartType->drmInfo.szContentURI) - strncpy(pPartType->szContentID, pPartType->drmInfo.szContentURI, MSG_MSG_ID_LEN); - - /* set title name (content name) */ - if (pPartType->param.szName[0] == '\0') { - /* szName is vitual name, real filename is *.dcf or *.dm */ - if (pPartType->drmInfo.szContentName && pPartType->drmInfo.szContentName[0] != '\0') { - /* In case of szContentName retrieved from DRM agent is exist. */ - pTmpBuf = pPartType->drmInfo.szContentName; - } else if (pPartType->szContentLocation[0] != '\0') { - /* In case of szContentLocation parsed from MMS header */ - pTmpBuf = strrchr(pPartType->szContentLocation, '/'); - if (pTmpBuf == NULL) - pTmpBuf = pPartType->szContentLocation; - } else { - /* use another name */ - /* possible NULL pointer assignment*/ - pTmpBuf = strdup("untitled"); - } - - if ((pExt = strrchr(pTmpBuf, '.')) != NULL) { - int extLen = 0; - int fileNameLen = 0; - int tmpLen = 0; - - extLen = strlen(pExt); - tmpLen = strlen(pTmpBuf); - fileNameLen = (tmpLen - extLen < MSG_LOCALE_FILENAME_LEN_MAX - extLen)?(tmpLen - extLen):(MSG_LOCALE_FILENAME_LEN_MAX - extLen); - strncpy(pPartType->param.szName, pTmpBuf, fileNameLen); - strcpy (pPartType->param.szName + fileNameLen, pExt); - } else { - strncpy(pPartType->param.szName, pTmpBuf, MSG_LOCALE_FILENAME_LEN_MAX); - MsgMakeFileName(pPartType->type, pPartType->param.szName, MSG_DRM_TYPE_NONE, 0); - } - } - - return true; -} - -#endif - -bool MsgIsText(int type) -{ - if (type == MIME_TEXT_PLAIN || type == MIME_TEXT_HTML || type == MIME_TEXT_VND_WAP_WML || - type == MIME_TEXT_X_VNOTE || type == MIME_APPLICATION_SMIL || type == MIME_TEXT_X_IMELODY) { - return true; - } else { - return false; - } -} - -bool MsgFreeAttrib(MmsAttrib *pAttrib) -{ - MSG_BEGIN(); - - if (pAttrib == NULL) { - MSG_DEBUG("pAttrib is NULL"); - return false; - } - - if (pAttrib->szTo) { - free(pAttrib->szTo); - pAttrib->szTo = NULL; - } - - if (pAttrib->szCc) { - free(pAttrib->szCc); - pAttrib->szCc = NULL; - } - - if (pAttrib->szBcc) { - free(pAttrib->szBcc); - pAttrib->szBcc = NULL; - } - - //check if pMultiStatus should be freed or not, because pMultiStatus is not allocated - if (pAttrib->pMultiStatus) { - MmsMsgMultiStatus *pMultiStatus = pAttrib->pMultiStatus; - MmsMsgMultiStatus *pCurStatus = NULL; - - while (pMultiStatus != NULL ) { - pCurStatus = pMultiStatus; - pMultiStatus = pMultiStatus->pNext; - - if (pCurStatus) { - free(pCurStatus); - pCurStatus = NULL; - } - } - - pAttrib->pMultiStatus = NULL; - } - - - MSG_END(); - - return true; -} - -bool _MsgFreeBody(MsgBody *pBody, int type) -{ - MSG_DEBUG("_MsgFreeBody: S T A R T !!! \n") ; - - if (pBody == NULL) { - MSG_DEBUG("_MsgFreeBody: pBody == NULL \n" ); - MSG_DEBUG("_MsgFreeBody: E N D (End)!!! \n") ; - - return false; - } - - switch (type) { - case MIME_MULTIPART_REPORT: - case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: - case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED: - case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED: - case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC: - case MIME_MULTIPART_MIXED: - case MIME_MULTIPART_RELATED: - case MIME_MULTIPART_ALTERNATIVE: - case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE: - { - MsgMultipart *pMulti = pBody->body.pMultipart; - MsgMultipart *pCurrPart = NULL; - MsgBody *pPresentation = pBody->pPresentationBody; - while (pMulti != NULL) { - pCurrPart = pMulti; - - pMulti = pMulti->pNext; - - if (pCurrPart) { -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pCurrPart->type.drmInfo); -#endif - - if (pCurrPart->pBody) { - if (pCurrPart->pBody->body.pBinary) { - free(pCurrPart->pBody->body.pBinary); - pCurrPart->pBody->body.pBinary = NULL; - } - free(pCurrPart->pBody); - pCurrPart->pBody = NULL; - } - free(pCurrPart); - pCurrPart = NULL; - } - } - - pBody->body.pMultipart = NULL; - - if (pPresentation) { - if (pPresentation->body.pText) { - free(pPresentation->body.pText); - pPresentation->body.pText = NULL; - } - free(pPresentation); - pBody->pPresentationBody = NULL; - } - - _MsgInitMsgType(&pBody->presentationType); - - break; - } - - default: - /* Any single part */ - - if (pBody->body.pBinary) { - free(pBody->body.pBinary); - pBody->body.pBinary = NULL; - } - - break; - } - - MSG_DEBUG("_MsgFreeBody: E N D (Successfully) !!! \n") ; - - return true; - -} - -bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) -{ - MSG_BEGIN(); - MsgMultipart *pTmpMultipart = NULL; - MsgMultipart *pSelectedPart = NULL; - MsgMultipart *pPrevPart = NULL; - MsgMultipart *pFirstPart = NULL; - MsgMultipart *pLastPart = NULL; - MsgMultipart *pRemoveList = NULL; - MsgMultipart *pNextRemovePart = NULL; - - switch (pPartType->type) { - case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE: - case MIME_MULTIPART_ALTERNATIVE: - - /* - * Policy: multipart/alternative - * multipart/alternative message has only several parts of media. - * You should choose one of them and make the alternative part - * to the selected media part. - */ - - MSG_DEBUG("MsgResolveNestedMultipart : MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE\n"); - - pSelectedPart = pPartBody->body.pMultipart; - - // NULL Pointer check!! - if (pSelectedPart == NULL) { - MSG_DEBUG("MsgResolveNestedMultipart : multipart(ALTERNATIVE) does not exist\n"); - break; - } - - pTmpMultipart = pPartBody->body.pMultipart->pNext; - - while (pTmpMultipart) { - if (pSelectedPart->type.type <= pTmpMultipart->type.type) - pSelectedPart = pTmpMultipart; - - pTmpMultipart = pTmpMultipart->pNext; - } - - pTmpMultipart = pPartBody->body.pMultipart; - pPrevPart = NULL; - - while (pTmpMultipart) { - if (pSelectedPart == pTmpMultipart) - break; - - pPrevPart = pTmpMultipart; - pTmpMultipart = pTmpMultipart->pNext; - } - - if (pPrevPart == NULL) { - /* selected part is the first part */ - pRemoveList = pSelectedPart->pNext; - } else { - pPrevPart->pNext = pSelectedPart->pNext; - pRemoveList = pPartBody->body.pMultipart; - pPartBody->body.pMultipart = pSelectedPart; - } - - pSelectedPart->pNext = NULL; - - if (pRemoveList) { -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pRemoveList->type.drmInfo); -#endif - _MsgFreeBody(pRemoveList->pBody, pRemoveList->type.type); - - free(pRemoveList->pBody); - free(pRemoveList); - } - - if (MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) { - MSG_DEBUG("MsgResolveNestedMultipart : MsgPriorityCopyMsgType failed \n"); - goto __CATCH; - } - - if (pSelectedPart->pBody != NULL) - memcpy(pPartBody, pSelectedPart->pBody, sizeof(MsgBody)); - - if (pSelectedPart != NULL) { -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo); -#endif - - if (pSelectedPart->pBody != NULL) { - free(pSelectedPart->pBody); - pSelectedPart->pBody = NULL; - } - free(pSelectedPart); - pSelectedPart = NULL; - } - - break; - - case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED: - case MIME_MULTIPART_RELATED: - - MSG_DEBUG("MsgResolveNestedMultipart : MIME_APPLICATION_VND_WAP_MULTIPART_RELATED\n"); - - pSelectedPart = pPartBody->body.pMultipart; - - while (pSelectedPart) { - if (MsgIsMultipartMixed(pSelectedPart->type.type)) { - - if (pSelectedPart->pBody == NULL) { - MSG_DEBUG("MsgResolveNestedMultipart :pSelectedPart->pBody(1) is NULL\n"); - break; - } - - pFirstPart = pSelectedPart->pBody->body.pMultipart; - - if (pFirstPart == NULL) { - MSG_DEBUG("MsgResolveNestedMultipart : multipart(RELATED) does not exist\n"); - break; - } - - if (pFirstPart->pNext) { - pLastPart = pFirstPart->pNext; - while (pLastPart->pNext) - pLastPart = pLastPart->pNext; - } else { - pLastPart = pFirstPart; - } - - if (pPrevPart == NULL) { - /* the first part */ - pTmpMultipart = pPartBody->body.pMultipart->pNext; - pPartBody->body.pMultipart = pFirstPart; - pLastPart->pNext = pTmpMultipart; - } else { - pTmpMultipart = pSelectedPart->pNext; - pPrevPart->pNext = pFirstPart; - pLastPart->pNext = pTmpMultipart; - } - - if (pSelectedPart) { -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo); -#endif - free(pSelectedPart->pBody); - free(pSelectedPart); - } - pSelectedPart = pTmpMultipart; - } else if (MsgIsMultipartRelated(pSelectedPart->type.type) && pPrevPart != NULL) { - pPrevPart->pNext = pTmpMultipart = pSelectedPart->pNext; - _MsgFreeBody(pSelectedPart->pBody, pSelectedPart->type.type); - - free(pSelectedPart->pBody); - free(pSelectedPart); - pSelectedPart = pTmpMultipart; - } else { - pPrevPart = pSelectedPart; - pSelectedPart = pSelectedPart->pNext; - } - } - - break; - - - case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED: - case MIME_MULTIPART_MIXED: - - MSG_DEBUG("MsgResolveNestedMultipart : MIME_APPLICATION_VND_WAP_MULTIPART_MIXED\n"); - - pPrevPart = NULL; - pSelectedPart = pPartBody->body.pMultipart; - - while (pSelectedPart) { - if (MsgIsMultipart(pSelectedPart->type.type)) { - if (pSelectedPart->pBody == NULL) { - MSG_DEBUG("MsgResolveNestedMultipart :pSelectedPart->pBody(2) is NULL\n"); - break; - } - - pFirstPart = pSelectedPart->pBody->body.pMultipart; - - // NULL Pointer check!! - if (pFirstPart == NULL) { - MSG_DEBUG("MsgResolveNestedMultipart : multipart does not exist\n"); - break; - } - - if (pFirstPart->pNext) { - pLastPart = pFirstPart->pNext; - while (pLastPart->pNext) - pLastPart = pLastPart->pNext; - } else { - pLastPart = pFirstPart; - } - - if (pPrevPart == NULL) { - /* the first part */ - pTmpMultipart = pPartBody->body.pMultipart->pNext; - pPartBody->body.pMultipart = pFirstPart; - pLastPart->pNext = pTmpMultipart; - } else { - pTmpMultipart = pSelectedPart->pNext; - pPrevPart->pNext = pFirstPart; - pLastPart->pNext = pTmpMultipart; - } - - if (pSelectedPart->pBody->pPresentationBody) - pPartBody->pPresentationBody = pSelectedPart->pBody->pPresentationBody; - - memcpy(&pPartBody->presentationType, - &pSelectedPart->pBody->presentationType, sizeof(MsgType)); - - pPartType->type = pSelectedPart->type.type; - -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo); -#endif - free(pSelectedPart->pBody); - free(pSelectedPart); - - pSelectedPart = pTmpMultipart; - } else { - pPrevPart = pSelectedPart; - pSelectedPart = pSelectedPart->pNext; - } - } - - break; - - case MIME_MULTIPART_REPORT: - - MSG_DEBUG("MsgResolveNestedMultipart : MIME_MULTIPART_REPORT \n"); - - pTmpMultipart = pPartBody->body.pMultipart; - pPrevPart = NULL; - - if (pTmpMultipart == NULL) { - MSG_DEBUG("MsgResolveNestedMultipart : pTmpMultipart == NULL \n"); - return false; - } - - while (pTmpMultipart) { - if (pTmpMultipart->type.type == MIME_TEXT_PLAIN) { - pSelectedPart = pTmpMultipart; - break; - } - - pPrevPart = pTmpMultipart; - pTmpMultipart = pTmpMultipart->pNext; - } - - 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; - } else { - if (pPrevPart == NULL) { - // first part is selected - pRemoveList = pPartBody->body.pMultipart->pNext; - } else { - pRemoveList = pPartBody->body.pMultipart->pNext; - pPrevPart->pNext = pSelectedPart->pNext; - } - - pSelectedPart->pNext = NULL; - pPartBody->body.pMultipart = pSelectedPart; - } - - pTmpMultipart = pRemoveList; - - while (pTmpMultipart) { -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pTmpMultipart->type.drmInfo); -#endif - _MsgFreeBody(pTmpMultipart->pBody, pTmpMultipart->type.type); - pNextRemovePart = pTmpMultipart->pNext; - - free(pTmpMultipart->pBody); - free(pTmpMultipart); - pTmpMultipart = pNextRemovePart; - } - - if (MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) { - MSG_DEBUG("MsgResolveNestedMultipart : MsgPriorityCopyMsgType failed \n"); - goto __CATCH; - } - - if (pSelectedPart->pBody != NULL) - memcpy(pPartBody, pSelectedPart->pBody, sizeof(MsgBody)); - - if (pSelectedPart != NULL) { -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo); -#endif - if (pSelectedPart->pBody != NULL) { - free(pSelectedPart->pBody); - pSelectedPart->pBody = NULL; - } - free(pSelectedPart); - pSelectedPart = NULL; - } - - break; - - default: - break; - } - MSG_END(); - - return true; - -__CATCH: - return false; - -} - -char *MsgResolveContentURI(char *szSrc) -{ - char *szTemp = NULL; - char *szReturn = NULL; - int length = 0; - - if (szSrc == NULL) { - goto __CATCH; - } - - if (szSrc[0] == '\0') - goto __CATCH; - - - if (!strncasecmp(szSrc, "cid:", 4)) { - length = strlen(szSrc) - 3; - szSrc += 4; - } else { - length = strlen(szSrc) + 1; - } - - szTemp = (char *)malloc(length); - if (szTemp == NULL) { - MSG_DEBUG("MsgResolveContentURI: memory full\n"); - goto __CATCH; - } - - memset(szTemp, 0, length); - strcpy(szTemp, szSrc); - - szReturn = MsgChangeHexString(szTemp); - - if (szTemp) { - free(szTemp); - szTemp = NULL; - } - - return szReturn; - -__CATCH: - if (szTemp) { - free(szTemp); - szTemp = NULL; - } - - return NULL; -} - -bool _MsgParsePartHeader(MsgType *pType, const char *pRawData, int nRawData) -{ - char ch = '\0'; - int cRaw = nRawData; - char *pFieldLine = NULL; - char *pFieldValue = NULL; - char *szFieldValue = NULL; - char *szSrc = NULL; - int nLen = 0; - char fieldLine[MSG_LINE_LEN] = {0, }; //temporary line buffer - int length = 0; - - char szTempBuf[MSG_LOCAL_TEMP_BUF_SIZE]; - - while ((cRaw > 0) && *pRawData != MSG_CH_LF) { - memset(fieldLine, 0, MSG_LINE_LEN); - pFieldLine = fieldLine; - - ch = MSG_CH_SP; //remember previous character. - - while (ch) { - switch (ch = *pRawData++) { - case MSG_CH_CR: //'\r' - if (*pRawData == MSG_CH_LF) - break; - - case MSG_CH_LF: //'\n' - if (*pRawData != MSG_CH_SP && *pRawData != MSG_CH_TAB) { - ch = MSG_CH_NULL; - *pFieldLine = ch; - pFieldLine++; - } - break; - - case MSG_CH_TAB: //'\t' - *pFieldLine = MSG_CH_SP; - pFieldLine++; - break; - - default: - *pFieldLine = ch; - pFieldLine++; - break; - } - - if (--cRaw <= 0) { //If is the last character of header - *pFieldLine = MSG_CH_NULL; - pFieldLine++; - } - } - - - if ((pFieldValue = strchr(fieldLine, MSG_CH_COLON)) != NULL) { - char* pTemp = pFieldValue; - char* pValue = NULL; - - *pFieldValue++ = MSG_CH_NULL; //remove ':' - - while (*pFieldValue == MSG_CH_SP) //remove space ' ' - pFieldValue++; - - while ((fieldLine < pTemp--) && (*pTemp == MSG_CH_SP)) - *pTemp = MSG_CH_NULL; - - nLen = strlen(pFieldValue); - - if (nLen >= MSG_LOCAL_TEMP_BUF_SIZE) { - szFieldValue = (char *)malloc(nLen + 1); - memset(szFieldValue, 0 , nLen + 1); - memcpy(szFieldValue, pFieldValue, nLen + 1); - } else { - memset(szTempBuf, 0, MSG_LOCAL_TEMP_BUF_SIZE); - strcpy(szTempBuf, pFieldValue); - szFieldValue = szTempBuf; - } - - if (MsgStrcpyWithoutCRLF(szFieldValue, &szSrc) == true) { - if (szSrc != NULL) - strncpy(szFieldValue, szSrc, strlen(szSrc)); - } - if (szSrc) { - free(szSrc); - szSrc = NULL; - } - - switch (_MsgGetCode(MSG_FIELD, fieldLine)) { - case MSG_FIELD_CONTENT_ID: - if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) != NULL) - *pTemp++ = MSG_CH_NULL; - - pValue = _MsgDecodeText(szFieldValue); - memset (pType->szContentID, 0, MSG_MSG_ID_LEN + 1); - - if (pValue) { - // support CD & SD - length = MsgStrlen(pValue); - if (pValue[0] == '<' && pValue[length-1] == '>') { - strncpy(pType->szContentID, pValue + 1, length - 2); - } else { - strncpy(pType->szContentID, pValue, MSG_MSG_ID_LEN); - } - - MSG_DEBUG("_MsgParsePartHeader: Content-ID = %s %s\n", pFieldValue, pType->szContentID); - - if (pTemp != NULL) - _MsgParseParameter(pType, pTemp); - - free(pValue); - pValue = NULL; - } - - break; - - case MSG_FIELD_CONTENT_LOCATION: - if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) != NULL) - *pTemp++ = MSG_CH_NULL; - - pValue = _MsgDecodeText(szFieldValue); - memset (pType->szContentLocation, 0, MSG_MSG_ID_LEN + 1); - - if (pValue) { - strncpy(pType->szContentLocation, pValue, MSG_MSG_ID_LEN); - - MSG_DEBUG("_MsgParsePartHeader: Content-Location = %s %s\n", pFieldValue, pType->szContentLocation); - - if (pTemp != NULL) - _MsgParseParameter(pType, pTemp); - - free(pValue); - pValue = NULL; - } - - break; - - case MSG_FIELD_CONTENT_TYPE: - if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) == NULL) { - if ((pTemp = strchr(szFieldValue, MSG_CH_SP)) != NULL) - *pTemp++ = MSG_CH_NULL; - } else { - *pTemp++ = MSG_CH_NULL; - } - - pType->type = _MsgGetCode(MSG_TYPE, szFieldValue); - - MSG_DEBUG("_MsgParsePartHeader: Content-Type = %s %d\n", pFieldValue, pType->type); - - if (pType->type == INVALID_HOBJ) - pType->type = MIME_UNKNOWN; - - if (pTemp != NULL) - _MsgParseParameter(pType, pTemp); - - break; - - case MSG_FIELD_CONTENT_TRANSFER_ENCODING: - if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) == NULL) { - if ((pTemp = strchr(szFieldValue, MSG_CH_SP)) != NULL) - *pTemp++ = MSG_CH_NULL; - } else { - *pTemp++ = MSG_CH_NULL; - } - - pType->encoding = _MsgGetCode(MSG_ENCODING, szFieldValue); - - MSG_DEBUG("_MsgParsePartHeader: Content-Encoding = %s %d\n", pFieldValue, pType->encoding); - - if (pTemp != NULL) - _MsgParseParameter(pType, pTemp); - - break; - - case MSG_FIELD_CONTENT_DISPOSITION: - if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) == NULL) { - if ((pTemp = strchr(szFieldValue, MSG_CH_SP)) != NULL) - *pTemp++ = MSG_CH_NULL; - } else { - *pTemp++ = MSG_CH_NULL; - } - - pType->disposition = _MsgGetCode(MSG_DISPOSITION, szFieldValue); - - MSG_DEBUG("_MsgParsePartHeader: Content-Disposition = %s %d\n", pFieldValue, pType->disposition); - - if (pTemp != NULL) - _MsgParseParameter(pType, pTemp); - - break; - -#ifdef __SUPPORT_DRM__ - - case MSG_FIELD_CONTENT_NAME: - /* add to parse DCF header such as, - * Right-Issuer, Content-Name, and Content-Description. - */ - MsgMIMERemoveQuote(szFieldValue); - pType->drmInfo.szContentName = MsgStrCopy(szFieldValue); - break; - - case MSG_FIELD_CONTENT_DESCRIPTION: - MsgMIMERemoveQuote(szFieldValue); - pType->drmInfo.szContentDescription = MsgStrCopy(szFieldValue); - break; - - case MSG_FIELD_CONTENT_VENDOR: - MsgMIMERemoveQuote(szFieldValue); - pType->drmInfo.szContentVendor = MsgStrCopy(szFieldValue); - break; - - case MSG_FIELD_RIGHT_ISSUER: - MsgMIMERemoveQuote(szFieldValue); - pType->drmInfo.szRightIssuer = MsgStrCopy(szFieldValue); - break; - - - case MSG_FIELD_DRM_CONVERTED: - MsgMIMERemoveQuote(szFieldValue); - pType->nDrmConvertedStatus = atoi(szFieldValue); - break; - -#endif - case MSG_FILED_CONTENT_REPLACE_POS: - MsgMIMERemoveQuote(szFieldValue); - strncpy(pType->szContentRepPos, szFieldValue, sizeof(pType->szContentRepPos)); - break; - - case MSG_FILED_CONTENT_REPLACE_SIZE: - MsgMIMERemoveQuote(szFieldValue); - strncpy(pType->szContentRepSize, szFieldValue, sizeof(pType->szContentRepSize)); - break; - - case MSG_FILED_CONTENT_REPLACE_INDEX: - MsgMIMERemoveQuote(szFieldValue); - strncpy(pType->szContentRepIndex, szFieldValue, sizeof(pType->szContentRepIndex)); - break; - - default: - MSG_DEBUG("_MsgParsePartHeader: Unhandled field \n"); - break; - } - } - - if (szFieldValue != NULL && szFieldValue != szTempBuf) { - free(szFieldValue); - szFieldValue = NULL; - } - - } - - return true; -} - -char *MsgRemoveQuoteFromFilename(char *pSrc) -{ - int cLen = 0; // length of pBuff - char *pBuff = NULL; - - if (pSrc == NULL) { - MSG_DEBUG("MsgRemoveQuoteFromFilename: pSrc is Null\n"); - return NULL; - } - - cLen = strlen(pSrc); - - pBuff = (char *)malloc(cLen + 1); - - if (pBuff == NULL) { - MSG_DEBUG("MsgRemoveQuoteFromFilename: pBuff mem alloc fail!\n"); - return NULL; - } - memset(pBuff, 0 , sizeof(char)*(cLen + 1)); - - // remove front quote - if (pSrc[0] == MSG_CH_QUOT) { - cLen--; - strncpy(pBuff, &pSrc[1], cLen); - pBuff[cLen] = '\0'; - } - - if (pSrc[0] == MSG_CH_LF) { - cLen--; - strncpy(pBuff, &pSrc[1], cLen); - } else { - strcpy(pBuff, pSrc); - } - - // remove last qoute - if (pBuff[cLen-1] == MSG_CH_QUOT) { - pBuff[cLen-1] = '\0'; - } - - return pBuff; -} - -bool MsgIsMultipart(int type) -{ - if (type == MIME_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED || - type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC || - type == MIME_MULTIPART_MIXED || type == MIME_MULTIPART_REPORT) { - return true; - } else { - return false; - } -} - - -bool MsgIsHexChar(char *pSrc) -{ - int cIndex = 0; - int cLen = 0; - bool bRet = false; - - cLen = strlen(pSrc); - - for (cIndex = 0; cIndex < cLen ; cIndex++) { - if ((pSrc[cIndex] >= '0' && pSrc[cIndex] <= '9') || (pSrc[cIndex] >= 'A'&& pSrc[cIndex] <= 'F') || - (pSrc[cIndex] >= 'a' && pSrc[cIndex] <= 'f')) { - bRet = true; - } else { - return false; - } - } - - return bRet; -} - -char _MsgConvertHexValue(char *pSrc) -{ - int ch = 0; - int cIndex = 0; - int cLen = 0; - char ResultChar; - unsigned char uCh[2] = {0,}; - - cLen = strlen(pSrc); - - for (cIndex = 0; cIndex < cLen ; cIndex += 2) { - uCh[0] = __MsgConvertCharToInt(pSrc[cIndex]); - uCh[1] = __MsgConvertCharToInt(pSrc[cIndex+1]); - ch = (int)uCh[0]<<4|uCh[1]; - } - ResultChar = (char)ch; + MmsReleaseMsgDRMInfo(&pMsgBody->presentationType.drmInfo); - return ResultChar; + MmsInitMsgType(&pMsgBody->presentationType); + pMsgBody->pPresentationBody = NULL; + } + } + MSG_END(); } -int __MsgConvertCharToInt(char ch) +static bool __MsgIsMultipartRelated(int type) { - if (ch>='0' && ch<='9') { - return ch - '0'; - } else if (ch>='a'&& ch <='f') { - return ch -'a'+10; - } else if (ch>='A'&& ch <='F') { - return ch -'A'+10; + if (type == MIME_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { + return true; } else { - return 0; + return false; } } -bool MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2) +static bool __MsgIsPresentablePart(int type) { - if (pMsgType1->section == INVALID_HOBJ) - pMsgType1->section = pMsgType2->section; - -#ifdef __SUPPORT_DRM__ - int length = 0; - - if (pMsgType1->drmInfo.drmType == MSG_DRM_TYPE_NONE) - pMsgType1->drmInfo.drmType = pMsgType2->drmInfo.drmType; - - - if (pMsgType1->szContentID[0] == '\0') { - strcpy(pMsgType1->szContentID, pMsgType2->szContentID); - - if (pMsgType2->szContentID[0]) { - length = MsgStrlen(pMsgType2->szContentID); - if (pMsgType2->szContentID[0] == '<' && pMsgType2->szContentID[length - 1] == '>') { - pMsgType1->drmInfo.szContentURI = MsgStrNCopy(pMsgType2->szContentID + 1, length - 2); - } else { - pMsgType1->drmInfo.szContentURI = MsgStrCopy(pMsgType2->szContentID); - } - } + if (type == MIME_TEXT_HTML || type == MIME_TEXT_VND_WAP_WML || type == MIME_APPLICATION_SMIL) { + return true; } else { - length = MsgStrlen(pMsgType1->szContentID); - if (pMsgType1->szContentID[0] == '<' && pMsgType1->szContentID[length - 1] == '>') { - pMsgType1->drmInfo.szContentURI = MsgStrNCopy(pMsgType1->szContentID + 1, length - 2); - } else { - pMsgType1->drmInfo.szContentURI = MsgStrCopy(pMsgType1->szContentID); - } + return false; } -#endif - - if (pMsgType1->szContentLocation[0] == '\0') - strcpy(pMsgType1->szContentLocation, pMsgType2->szContentLocation); - - /* Copy informations - we shoud open the pMsgType2's orgFile - * concerning its offset and size. - */ - if (pMsgType2->szOrgFilePath[0] != '\0') - strcpy(pMsgType1->szOrgFilePath, pMsgType2->szOrgFilePath); - - if (pMsgType2->disposition != INVALID_HOBJ) - pMsgType1->disposition = pMsgType2->disposition; +} - if ((pMsgType1->type != MIME_APPLICATION_VND_OMA_DRM_MESSAGE && pMsgType1->type != MIME_APPLICATION_VND_OMA_DRM_CONTENT) && - pMsgType2->encoding != INVALID_HOBJ) - pMsgType1->encoding = pMsgType2->encoding; +static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) +{ + MSG_BEGIN(); + MsgMultipart *pTmpMultipart = NULL; + MsgMultipart *pSelectedPart = NULL; + MsgMultipart *pPrevPart = NULL; + MsgMultipart *pFirstPart = NULL; + MsgMultipart *pLastPart = NULL; + MsgMultipart *pRemoveList = NULL; + MsgMultipart *pNextRemovePart = NULL; - pMsgType1->contentSize = pMsgType2->contentSize; - pMsgType1->offset = pMsgType2->offset; - pMsgType1->size = pMsgType2->size; - pMsgType1->type = pMsgType2->type; + switch (pPartType->type) { + case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE: + case MIME_MULTIPART_ALTERNATIVE: - MsgCopyNestedMsgParam(&(pMsgType1->param), &(pMsgType2->param)); + /* fixme: + * Policy: multipart/alternative + * multipart/alternative message has only several parts of media. + * You should choose one of them and make the alternative part + * to the selected media part. + */ - if (pMsgType1->param.szName[0]) { -#ifdef __SUPPORT_DRM__ - pMsgType1->drmInfo.szContentName = MsgStrCopy(pMsgType2->param.szName); -#endif - } + MSG_DEBUG("MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE"); - return true; -} + pSelectedPart = pPartBody->body.pMultipart; + // NULL Pointer check!! + if (pSelectedPart == NULL) { + MSG_DEBUG("multipart(ALTERNATIVE) does not exist"); + break; + } -bool MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2) -{ - if (pParam1->charset == MSG_CHARSET_UNKNOWN) - pParam1->charset = pParam2->charset; + pTmpMultipart = pPartBody->body.pMultipart->pNext; - if (pParam1->type == MIME_UNKNOWN) - pParam1->type = pParam2->type; + while (pTmpMultipart) { + if (pSelectedPart->type.type <= pTmpMultipart->type.type) + pSelectedPart = pTmpMultipart; - /* Don't copy pParam2->pPresentation */ + pTmpMultipart = pTmpMultipart->pNext; + } - /* For alternative: copy the boundary string */ - if (pParam2->szBoundary[0] !='\0') - strcpy(pParam1->szBoundary, pParam2->szBoundary); + pTmpMultipart = pPartBody->body.pMultipart; + pPrevPart = NULL; - if (pParam1->szFileName[0] =='\0') - strcpy(pParam1->szFileName, pParam2->szFileName); + while (pTmpMultipart) { + if (pSelectedPart == pTmpMultipart) + break; - if (pParam1->szName[0] =='\0') - strcpy(pParam1->szName, pParam2->szName); + pPrevPart = pTmpMultipart; + pTmpMultipart = pTmpMultipart->pNext; + } - if (pParam1->szStart[0] =='\0') - strcpy(pParam1->szStart, pParam2->szStart); + if (pPrevPart == NULL) { + /* selected part is the first part */ + pRemoveList = pSelectedPart->pNext; + } else { + pPrevPart->pNext = pSelectedPart->pNext; + pRemoveList = pPartBody->body.pMultipart; + pPartBody->body.pMultipart = pSelectedPart; + } - if (pParam1->szStartInfo[0] =='\0') - strcpy(pParam1->szStartInfo, pParam2->szStartInfo); + pSelectedPart->pNext = NULL; - return true; -} + if (pRemoveList) { -bool MsgIsMultipartMixed(int type) -{ - if (type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED || type == MIME_MULTIPART_MIXED) { - return true; - } else { - return false; - } -} + MmsReleaseMsgDRMInfo(&pRemoveList->type.drmInfo); -bool MsgStrcpyWithoutCRLF(char *pOrg, char **ppNew) -{ - int nLen = 0; - int i = 0; - int index = 0; - char* pDest = NULL; + MmsReleaseMsgBody(pRemoveList->pBody, pRemoveList->type.type); + free(pRemoveList->pBody); + free(pRemoveList); + } - nLen = strlen(pOrg); + if (__MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) { + MSG_DEBUG("MsgPriorityCopyMsgType failed"); + goto __CATCH; + } - pDest = (char *)malloc(nLen + 1); + if (pSelectedPart->pBody != NULL) + memcpy(pPartBody, pSelectedPart->pBody, sizeof(MsgBody)); - if (pDest == NULL) { - MSG_DEBUG("MsgStrcpyWithoutCRLF: malloc is failed\n"); - return false; - } + if (pSelectedPart != NULL) { - memset(pDest, 0 , (nLen + 1)); + MmsReleaseMsgDRMInfo(&pSelectedPart->type.drmInfo); - for (i = 0; i < nLen ; i++) { - if (i < nLen - 2) { - if ((pOrg[i] == MSG_CH_CR && pOrg[i+1] == MSG_CH_LF && pOrg[i+2] == MSG_CH_TAB) || - (pOrg[i] == MSG_CH_CR && pOrg[i+1] == MSG_CH_LF && pOrg[i+2] == MSG_CH_SP)) { - i+=2; - continue; + if (pSelectedPart->pBody != NULL) { + free(pSelectedPart->pBody); + pSelectedPart->pBody = NULL; } + free(pSelectedPart); + pSelectedPart = NULL; } - pDest[index++] = pOrg[i]; - } - *ppNew = pDest; - return true; -} - -bool MmsGetMsgAttrib(MmsMsgID msgID, MmsAttrib* pAttrib) -{ - MmsMsg *pMsg = NULL; + break; - memset(pAttrib, 0, sizeof(MmsAttrib)); - MmsPluginStorage::instance()->getMmsMessage(&pMsg); - memcpy(pAttrib, &(pMsg->mmsAttrib), sizeof(MmsAttrib)); + case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED: + case MIME_MULTIPART_RELATED: - MSG_DEBUG("MmsGetMsgAttrib: msgID = %lu ---------------------\n", msgID); + MSG_DEBUG("MIME_APPLICATION_VND_WAP_MULTIPART_RELATED"); - if ('\0' != pMsg->szTrID[0]) - MSG_DEBUG("szTrID = %s \n", pMsg->szTrID); + pSelectedPart = pPartBody->body.pMultipart; - MSG_END(); - return true; -} + while (pSelectedPart) { + if (__MsgIsMultipartMixed(pSelectedPart->type.type)) { -bool __MsgIsInvalidFileNameChar(char ch) -{ - if ((ch == 0x5C /* \ */) || - (ch == 0x2F /* / */) || - (ch == 0x3A /* : */) || - (ch == 0x2A /* * */) || - (ch == 0x3F /* ? */) || - (ch == 0x22 /* " */) || - (ch == 0x3C /* < */) || - (ch == 0x3E /* > */) || - (ch == 0x7C /* | */)) - return true; + if (pSelectedPart->pBody == NULL) { + MSG_DEBUG("pSelectedPart->pBody(1) is NULL"); + break; + } - return false; -} + pFirstPart = pSelectedPart->pBody->body.pMultipart; -bool _MmsDataUpdateLastStatus(MmsMsg *pMsg) -{ - MmsMsgMultiStatus* pStatus = NULL; + if (pFirstPart == NULL) { + MSG_DEBUG("multipart(RELATED) does not exist"); + break; + } - pStatus = pMsg->mmsAttrib.pMultiStatus; + if (pFirstPart->pNext) { + pLastPart = pFirstPart->pNext; + while (pLastPart->pNext) + pLastPart = pLastPart->pNext; + } else { + pLastPart = pFirstPart; + } - while (pStatus != NULL) { - pStatus->bDeliveyrReportIsLast = false; - pStatus->bReadReplyIsLast = false; - pStatus = pStatus->pNext; - } + if (pPrevPart == NULL) { + /* the first part */ + pTmpMultipart = pPartBody->body.pMultipart->pNext; + pPartBody->body.pMultipart = pFirstPart; + pLastPart->pNext = pTmpMultipart; + } else { + pTmpMultipart = pSelectedPart->pNext; + pPrevPart->pNext = pFirstPart; + pLastPart->pNext = pTmpMultipart; + } - return true; -} + if (pSelectedPart) { + MmsReleaseMsgDRMInfo(&pSelectedPart->type.drmInfo); -bool MmsAddrUtilCompareAddr(char *pszAddr1, char *pszAddr2) -{ - int len1; - int len2; - char *p; + free(pSelectedPart->pBody); + free(pSelectedPart); + } + pSelectedPart = pTmpMultipart; + } else if (__MsgIsMultipartRelated(pSelectedPart->type.type) && pPrevPart != NULL) { + pPrevPart->pNext = pTmpMultipart = pSelectedPart->pNext; + MmsReleaseMsgBody(pSelectedPart->pBody, pSelectedPart->type.type); - MmsAddrUtilRemovePlmnString(pszAddr1); - MmsAddrUtilRemovePlmnString(pszAddr2); + free(pSelectedPart->pBody); + free(pSelectedPart); + pSelectedPart = pTmpMultipart; + } else { + pPrevPart = pSelectedPart; + pSelectedPart = pSelectedPart->pNext; + } + } - MSG_DEBUG("##### pszAddr1 = %s #####", pszAddr1); - MSG_DEBUG("##### pszAddr2 = %s #####", pszAddr2); - if (!strcmp(pszAddr1, pszAddr2)) - return true; + break; - len1 = strlen(pszAddr1); - len2 = strlen(pszAddr2); - if (len1 > len2) { - p = strstr(pszAddr1, pszAddr2); - } else { - p = strstr(pszAddr2, pszAddr1); - } + case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED: + case MIME_MULTIPART_MIXED: - if (p) - return true; + MSG_DEBUG("MIME_APPLICATION_VND_WAP_MULTIPART_MIXED"); - return false; -} + pPrevPart = NULL; + pSelectedPart = pPartBody->body.pMultipart; -int MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar) -{ - int nCount = 0; + while (pSelectedPart) { + if (MsgIsMultipart(pSelectedPart->type.type)) { + if (pSelectedPart->pBody == NULL) { + MSG_DEBUG("pSelectedPart->pBody(2) is NULL"); + break; + } - MSG_DEBUG("MsgGetLatin2UTFCodeSize: --------------- \n"); + pFirstPart = pSelectedPart->pBody->body.pMultipart; - if ((szSrc == NULL) || (nChar <= 0)) { - MSG_DEBUG("MsgGetLatin2UTFCodeSize: szSrc is NULL !!!! --------------- \n"); - return 0; - } + // NULL Pointer check!! + if (pFirstPart == NULL) { + MSG_DEBUG("multipart does not exist"); + break; + } - while ((nChar > 0) && (*szSrc != '\0')) { - if (0x01 <= *szSrc && *szSrc <= 0x7F) { - nCount += 1; - szSrc++; - nChar--; - } else { - nCount += 2; - szSrc++; - nChar--; - } - } + if (pFirstPart->pNext) { + pLastPart = pFirstPart->pNext; + while (pLastPart->pNext) + pLastPart = pLastPart->pNext; + } else { + pLastPart = pFirstPart; + } - return nCount; -} + if (pPrevPart == NULL) { + /* the first part */ + pTmpMultipart = pPartBody->body.pMultipart->pNext; + pPartBody->body.pMultipart = pFirstPart; + pLastPart->pNext = pTmpMultipart; + } else { + pTmpMultipart = pSelectedPart->pNext; + pPrevPart->pNext = pFirstPart; + pLastPart->pNext = pTmpMultipart; + } -int MsgLatin5code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar) -{ - unsigned char *org; - unsigned char t1; - unsigned char t2; - unsigned short temp = 0; + if (pSelectedPart->pBody->pPresentationBody) + pPartBody->pPresentationBody = pSelectedPart->pBody->pPresentationBody; - org = des; - outBufSize--; //Null Character + memcpy(&pPartBody->presentationType, + &pSelectedPart->pBody->presentationType, sizeof(MsgType)); - while ((nChar > 0) && (*szSrc != '\0')) { + pPartType->type = pSelectedPart->type.type; - if (*szSrc >= 0x01 && *szSrc <= 0x7F) { //basic common - temp = (unsigned short)(*szSrc); + MmsReleaseMsgDRMInfo(&pSelectedPart->type.drmInfo); - outBufSize --; - if (outBufSize < 0) - goto __RETURN; + free(pSelectedPart->pBody); + free(pSelectedPart); - *des = (unsigned char) ((*szSrc) & 0x007F); + pSelectedPart = pTmpMultipart; + } else { + pPrevPart = pSelectedPart; + pSelectedPart = pSelectedPart->pNext; + } + } - des++; - szSrc++; - nChar--; - } else if ((*szSrc == 0x00) || (*szSrc >= 0x80 && *szSrc <= 0x9F) || - (*szSrc >= 0xA0 && *szSrc <= 0xCF) || (*szSrc >= 0xD1 && *szSrc <= 0xDC) || - (*szSrc >= 0xDF && *szSrc <= 0xEF) || (*szSrc >= 0xF1 && *szSrc <= 0xFC) || - (*szSrc == 0xFF)) {//uni 0x00A0 ~ 0x00CF + break; - temp = (unsigned short)(*szSrc); + case MIME_MULTIPART_REPORT: - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + MSG_DEBUG("MIME_MULTIPART_REPORT"); - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0x07C0) >> 6); // right most 5 bit + pTmpMultipart = pPartBody->body.pMultipart; + pPrevPart = NULL; - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); + if (pTmpMultipart == NULL) { + MSG_DEBUG("pTmpMultipart == NULL"); + return false; + } - des += 2; - szSrc += 1; - nChar -= 1; - } else if (*szSrc == 0xD0) {//empty section OR vendor specific codes. + while (pTmpMultipart) { + if (pTmpMultipart->type.type == MIME_TEXT_PLAIN) { + pSelectedPart = pTmpMultipart; + break; + } - temp = 0x011E; + pPrevPart = pTmpMultipart; + pTmpMultipart = pTmpMultipart->pNext; + } - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + if (pSelectedPart == NULL) { + MSG_DEBUG("MIME_MULTIPART_REPORT [no selected part]"); - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0x07C0) >> 6); // right most 5 bit + pRemoveList = pPartBody->body.pMultipart->pNext; + if (pPartBody->body.pMultipart != NULL) { + pSelectedPart = pPartBody->body.pMultipart; + pSelectedPart->pNext = NULL; + } + } else { + if (pPrevPart == NULL) { + // first part is selected + pRemoveList = pPartBody->body.pMultipart->pNext; + } else { + pRemoveList = pPartBody->body.pMultipart->pNext; + pPrevPart->pNext = pSelectedPart->pNext; + } - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); + pSelectedPart->pNext = NULL; + pPartBody->body.pMultipart = pSelectedPart; + } - des += 2; - szSrc += 1; - nChar -= 1; - } else if (*szSrc == 0xDD) { - temp = 0x0130; + pTmpMultipart = pRemoveList; - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + while (pTmpMultipart) { - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0x07C0) >> 6); // right most 5 bit + MmsReleaseMsgDRMInfo(&pTmpMultipart->type.drmInfo); - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); + MmsReleaseMsgBody(pTmpMultipart->pBody, pTmpMultipart->type.type); + pNextRemovePart = pTmpMultipart->pNext; - des += 2; - szSrc += 1; - nChar -= 1; - } else if (*szSrc == 0xDE) { - temp = 0x015E; + free(pTmpMultipart->pBody); + free(pTmpMultipart); + pTmpMultipart = pNextRemovePart; + } - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + if (__MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) { + MSG_DEBUG("MsgPriorityCopyMsgType failed"); + goto __CATCH; + } - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0x07C0) >> 6); // right most 5 bit + if (pSelectedPart != NULL) { - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); + if (pSelectedPart->pBody != NULL) + memcpy(pPartBody, pSelectedPart->pBody, sizeof(MsgBody)); - des += 2; - szSrc += 1; - nChar -= 1; - } else if (*szSrc == 0xF0) { - temp = 0x011F; - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + MmsReleaseMsgDRMInfo(&pSelectedPart->type.drmInfo); - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0x07C0) >> 6); // right most 5 bit + if (pSelectedPart->pBody != NULL) { + free(pSelectedPart->pBody); + pSelectedPart->pBody = NULL; + } + free(pSelectedPart); + pSelectedPart = NULL; + } - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); + break; - des += 2; - szSrc += 1; - nChar -= 1; - } else if (*szSrc == 0xFD) { - temp = 0x0131; + default: + break; + } + MSG_END(); - outBufSize -= 2; + return true; - if (outBufSize < 0) - goto __RETURN; +__CATCH: + return false; - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0x07C0) >> 6); // right most 5 bit +} - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); +char *MsgResolveContentURI(char *szSrc) +{ + char *szTemp = NULL; + char *szReturn = NULL; + int length = 0; - des += 2; - szSrc += 1; - nChar -= 1; - } else if (*szSrc == 0xFE) { - temp = 0x015F; + if (szSrc == NULL) { + goto __CATCH; + } - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + if (szSrc[0] == '\0') + goto __CATCH; - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0x07C0) >> 6); // right most 5 bit - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); + if (!strncasecmp(szSrc, "cid:", 4)) { + length = strlen(szSrc) - 3; + szSrc += 4; + } else { + length = strlen(szSrc) + 1; + } - des += 2; - szSrc += 1; - nChar -= 1; - } else { - return -1; - } + szTemp = (char *)calloc(1, length); + if (szTemp == NULL) { + MSG_DEBUG("memory full"); + goto __CATCH; } -__RETURN: - *des = 0; - return(des-org); -} -int MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar) -{ - int nCount = 0; + memset(szTemp, 0, length); - MSG_DEBUG("MsgGetLatin52UTFCodeSize: --------------- \n"); + strncpy(szTemp, szSrc, length - 1); - if ((szSrc == NULL) || (nChar <= 0)) - return 0; + szReturn = MsgChangeHexString(szTemp); - while ((nChar > 0) && (*szSrc != '\0')) { - if (*szSrc >= 0x01 && *szSrc <= 0x7F) { - nCount += 1; - szSrc++; - nChar--; - } else if (*szSrc == 0x00 || (*szSrc >= 0x80 && *szSrc <= 0x9F) || - (*szSrc >= 0xA0 && *szSrc <= 0xCF) || (*szSrc >= 0xD1 && *szSrc <= 0xDC) | - (*szSrc >= 0xDF && *szSrc <= 0xEF) || (*szSrc >= 0xF1 && *szSrc <= 0xFC) || - *szSrc == 0xD0 || *szSrc == 0xDD || *szSrc == 0xDE || *szSrc == 0xF0 || - *szSrc == 0xFD || *szSrc == 0xFE || *szSrc == 0xFF) { //uni 0x00A0 ~ 0x00CF - nCount += 2; - szSrc++; - nChar--; - } else { - return -1; - } + if (szTemp) { + free(szTemp); + szTemp = NULL; } - return nCount; -} - -int MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar) -{ - unsigned char* org; - unsigned char t1, t2; - MSG_DEBUG("MsgLatin2UTF: --------------- \n"); + return szReturn; - org = des; - outBufSize--; // NULL character +__CATCH: - while ((nChar > 0) && (*szSrc != '\0')) { - if (0x01 <= *szSrc && *szSrc <= 0x7F) { - /* check outbuffer's room for this UTF8 character */ + return NULL; +} - outBufSize --; - if (outBufSize < 0) - goto __RETURN; +char *MsgRemoveQuoteFromFilename(char *pSrc) +{ + int cLen = 0; // length of pBuff + char *pBuff = NULL; - *des = (unsigned char) (*szSrc & 0x007F); + if (pSrc == NULL) { + MSG_DEBUG("pSrc is Null"); + return NULL; + } - des++; - szSrc++; - nChar--; - } else { - /* check outbuffer's room for this UTF8 character */ + cLen = strlen(pSrc); - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + pBuff = (char *)calloc(1, cLen + 1); - t2 = (unsigned char) (*szSrc & 0x003F); // right most 6 bit - t1 = (unsigned char) ((*szSrc & 0xC0) >> 6); // right most 2 bit + if (pBuff == NULL) { + MSG_DEBUG("pBuff mem alloc fail!"); + return NULL; + } + memset(pBuff, 0 , sizeof(char)*(cLen + 1)); - *des = 0xC0 | (t1 & 0x1F); - *(des + 1) = 0x80 | (t2 & 0x3F); + // remove front quote + if (pSrc[0] == MSG_CH_QUOT) { + cLen--; + strncpy(pBuff, &pSrc[1], cLen); + pBuff[cLen] = '\0'; + } - des += 2; - szSrc += 1; - nChar -= 1; - } + if (pSrc[0] == MSG_CH_LF) { + cLen--; + strncpy(pBuff, &pSrc[1], cLen); + } else { + strncpy(pBuff, pSrc, cLen); } -__RETURN: + // remove last qoute + if (pBuff[cLen-1] == MSG_CH_QUOT) { + pBuff[cLen-1] = '\0'; + } - *des = 0; - return (des - org); + return pBuff; } - -int MsgLatin7code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar) +bool MsgIsMultipart(int type) { - unsigned char *org; - unsigned char t1; - unsigned char t2; - unsigned char t3; - unsigned short temp = 0; - - MSG_DEBUG("MsgUnicode2UTF: --------------- \n"); - - org = des; - outBufSize--; //Null Character - - while ((nChar > 0) && (*szSrc != '\0')) { - if (*szSrc >= 0x01 && *szSrc <= 0x7F) { - temp = (unsigned short)(*szSrc); - - outBufSize --; - if (outBufSize < 0) - goto __RETURN; - - *des = (unsigned char) (temp & 0x007F); - - des++; - szSrc++; - nChar--; + if (type == MIME_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED || + type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC || + type == MIME_MULTIPART_MIXED || type == MIME_MULTIPART_REPORT) { + return true; + } else { + return false; + } +} - } else if ((*szSrc == 0x00) || (*szSrc >= 0x80 && *szSrc <= 0x9F) || - (*szSrc >= 0xA3 && *szSrc <= 0xAD) || (*szSrc == 0xBB)) { // consider 0xA4, 0xA5 - temp = (unsigned short)(*szSrc); +static bool __MsgIsHexChar(char *pSrc) +{ + int cIndex = 0; + int cLen = 0; + bool bRet = false; - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + cLen = strlen(pSrc); - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0xC0) >> 6); // right most 2 bit + for (cIndex = 0; cIndex < cLen ; cIndex++) { + if ((pSrc[cIndex] >= '0' && pSrc[cIndex] <= '9') || (pSrc[cIndex] >= 'A'&& pSrc[cIndex] <= 'F') || + (pSrc[cIndex] >= 'a' && pSrc[cIndex] <= 'f')) { + bRet = true; + } else { + return false; + } + } - *des = 0xC0 | (t1 & 0x1F); - *(des + 1) = 0x80 | (t2 & 0x3F); + return bRet; +} - des += 2; - szSrc += 1; - nChar -= 1; - } else if (*szSrc == 0xA0) { - temp = 0x0020; - //*des = temp to utf-8 - outBufSize--; - if (outBufSize < 0) - goto __RETURN; +static char __MsgConvertHexValue(char *pSrc) +{ + int ch = 0; + int cIndex = 0; + int cLen = 0; + char ResultChar; + unsigned char uCh[2] = {0,}; - *des = (unsigned char) (temp & 0x007F); + cLen = strlen(pSrc); - des++; - szSrc++; - nChar--; + for (cIndex = 0; cIndex < cLen ; cIndex += 2) { + uCh[0] = __MsgConvertCharToInt(pSrc[cIndex]); + uCh[1] = __MsgConvertCharToInt(pSrc[cIndex+1]); + ch = (int)uCh[0]<<4|uCh[1]; + } - } else if (*szSrc == 0xA1) { - temp = 0x2018; + ResultChar = (char)ch; - outBufSize -= 3; - if (outBufSize < 0) - goto __RETURN; + return ResultChar; +} - t3 = (unsigned char) (temp & 0x003F); // right most 6 bit - t2 = (unsigned char) ((temp & 0x0FC0) >> 6); // right most 6 bit - t1 = (unsigned char) ((temp & 0xF000) >> 12); // right most 4 bit +static int __MsgConvertCharToInt(char ch) +{ + if (ch>='0' && ch<='9') { + return ch - '0'; + } else if (ch>='a'&& ch <='f') { + return ch -'a'+10; + } else if (ch>='A'&& ch <='F') { + return ch -'A'+10; + } else { + return 0; + } +} - *des = 0xE0 | (t1 & 0x0F); - *(des+1) = 0x80 | (t2 & 0x3F); - *(des+2) = 0x80 | (t3 & 0x3F); +static bool __MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2) +{ + if(!pMsgType1 || !pMsgType2) + return false; - des += 3; - szSrc += 1; - nChar -= 1; + //if (pMsgType1->section == INVALID_HOBJ) + pMsgType1->section = pMsgType2->section; - } else if (*szSrc == 0xA2) { - temp = 0x2019; + int length = 0; - outBufSize -= 3; - if (outBufSize < 0) - goto __RETURN; + if (pMsgType1->drmInfo.drmType == MSG_DRM_TYPE_NONE) + pMsgType1->drmInfo.drmType = pMsgType2->drmInfo.drmType; - t3 = (unsigned char) (temp & 0x003F); // right most 6 bit - t2 = (unsigned char) ((temp & 0x0FC0) >> 6); // right most 6 bit - t1 = (unsigned char) ((temp & 0xF000) >> 12); // right most 4 bit - *des = 0xE0 | (t1 & 0x0F); - *(des+1) = 0x80 | (t2 & 0x3F); - *(des+2) = 0x80 | (t3 & 0x3F); + if (pMsgType1->szContentID[0] == '\0') { + snprintf(pMsgType1->szContentID, sizeof(pMsgType1->szContentID), "%s", pMsgType2->szContentID); + } - des += 3; - szSrc += 1; - nChar -= 1; + if (pMsgType1->szContentID[0] != '\0') { - } else if (*szSrc == 0xAF) { - temp = 0x2015; + length = strlen(pMsgType1->szContentID); + if (pMsgType1->szContentID[0] == '<' && pMsgType1->szContentID[length - 1] == '>') { + char szTempString[MSG_MSG_ID_LEN + 1]; + MmsRemoveLessGreaterChar(pMsgType1->szContentID, szTempString, sizeof(szTempString)); + pMsgType1->drmInfo.szContentURI = g_strdup(szTempString); + } else { + pMsgType1->drmInfo.szContentURI = g_strdup(pMsgType1->szContentID); + } + } - outBufSize -= 3; - if (outBufSize < 0) - goto __RETURN; + if (pMsgType1->szContentLocation[0] == '\0') { + strncpy(pMsgType1->szContentLocation, pMsgType2->szContentLocation, MSG_MSG_ID_LEN); + } - t3 = (unsigned char) (temp & 0x003F); // right most 6 bit - t2 = (unsigned char) ((temp & 0x0FC0) >> 6); // right most 6 bit - t1 = (unsigned char) ((temp & 0xF000) >> 12); // right most 4 bit + /* Copy informations - we shoud open the pMsgType2's orgFile + * concerning its offset and size. + */ + if (pMsgType2->szOrgFilePath[0] != '\0') { + strncpy(pMsgType1->szOrgFilePath, pMsgType2->szOrgFilePath, MSG_FILEPATH_LEN_MAX-1); + } - *des = 0xE0 | (t1 & 0x0F); - *(des+1) = 0x80 | (t2 & 0x3F); - *(des+2) = 0x80 | (t3 & 0x3F); + if (pMsgType2->disposition != -1) + pMsgType1->disposition = pMsgType2->disposition; - des += 3; - szSrc += 1; - nChar -= 1; + if ((pMsgType1->type != MIME_APPLICATION_VND_OMA_DRM_MESSAGE && pMsgType1->type != MIME_APPLICATION_VND_OMA_DRM_CONTENT) && + pMsgType2->encoding != -1) + pMsgType1->encoding = pMsgType2->encoding; - } else if (0xB0 <= *szSrc && *szSrc <= 0xB4) { //0x00B0 ~ 0x00B4 + pMsgType1->contentSize = pMsgType2->contentSize; + pMsgType1->offset = pMsgType2->offset; + pMsgType1->size = pMsgType2->size; + pMsgType1->type = pMsgType2->type; - temp = (unsigned short)(*szSrc); + __MsgCopyNestedMsgParam(&(pMsgType1->param), &(pMsgType2->param)); - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + if (pMsgType1->param.szName[0]) { + pMsgType1->drmInfo.szContentName = g_strdup(pMsgType2->param.szName); + } - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0x07C0) >> 6); // right most 5 bit + return true; +} - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); +static bool __MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2) +{ + if (pParam1->charset == MSG_CHARSET_UNKNOWN) + pParam1->charset = pParam2->charset; - des += 2; - szSrc += 1; - nChar -= 1; + if (pParam1->type == MIME_UNKNOWN) + pParam1->type = pParam2->type; - } else if ((0xB5 <= *szSrc && *szSrc <= 0xBA) || - (0xBC <= *szSrc && *szSrc <= 0xD1) || - (0xD3 <= *szSrc && *szSrc <= 0xFE)) { - temp= (unsigned short)(*szSrc + 0x02D0); + /* Don't copy pParam2->pPresentation */ - outBufSize -= 2; - if (outBufSize < 0) - goto __RETURN; + /* For alternative: copy the boundary string */ + if (pParam2->szBoundary[0] !='\0') { + strncpy(pParam1->szBoundary, pParam2->szBoundary, MSG_BOUNDARY_LEN); + } - t2 = (unsigned char) (temp & 0x003F); // right most 6 bit - t1 = (unsigned char) ((temp & 0x07C0) >> 6); // right most 5 bit + if (pParam1->szFileName[0] =='\0') { + strncpy(pParam1->szFileName, pParam2->szFileName, MSG_FILENAME_LEN_MAX); + } - *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); + if (pParam1->szName[0] =='\0') { + strncpy(pParam1->szName, pParam2->szName, MSG_LOCALE_FILENAME_LEN_MAX); + } - des += 2; - szSrc += 1; - nChar -= 1; + if (pParam1->szStart[0] =='\0') { + strncpy(pParam1->szStart, pParam2->szStart, MSG_MSG_ID_LEN); + } - } else { - return -1; - } + if (pParam1->szStartInfo[0] =='\0') { + strncpy(pParam1->szStartInfo, pParam2->szStartInfo, MSG_MSG_ID_LEN); + } + return true; +} +static bool __MsgIsMultipartMixed(int type) +{ + if (type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED || type == MIME_MULTIPART_MIXED) { + return true; + } else { + return false; } +} -__RETURN: - *des = 0; - return(des - org); +static bool __MsgIsInvalidFileNameChar(char ch) +{ + if ((ch == 0x5C /* \ */) || + (ch == 0x2F /* / */) || + (ch == 0x3A /* : */) || + (ch == 0x2A /* * */) || + (ch == 0x3F /* ? */) || + (ch == 0x22 /* " */) || + (ch == 0x3C /* < */) || + (ch == 0x3E /* > */) || + (ch == 0x7C /* | */)) + return true; + + return false; } -int MsgGetLatin72UTFCodeSize(unsigned char *szSrc, int nChar) +static int __MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar) { int nCount = 0; - MSG_DEBUG("MsgGetLatin72UTFCodeSize: --------------- \n"); + MSG_DEBUG("---------------"); - if ((szSrc == NULL) || (nChar <= 0)) + if ((szSrc == NULL) || (nChar <= 0)) { + MSG_DEBUG("szSrc is NULL !!!! ---------------"); return 0; + } while ((nChar > 0) && (*szSrc != '\0')) { - - if ((*szSrc >= 0x01 && *szSrc <= 0x7F) || (*szSrc == 0xA0)) { + if (0x01 <= *szSrc && *szSrc <= 0x7F) { nCount += 1; szSrc++; nChar--; - } else if (*szSrc == 0x00 || (0x80 <= *szSrc && *szSrc <= 0x9F) || (0xA3 <= *szSrc && *szSrc <= 0xAD) || - (0xB0 <= *szSrc && *szSrc <= 0xB4) || (0xB5 <= *szSrc && *szSrc <= 0xFE)) { + } else { nCount += 2; szSrc++; nChar--; - } else if (*szSrc == 0xA1 ||*szSrc == 0xA2 || *szSrc == 0xAF) { - nCount += 3; - szSrc += 1; - nChar -= 1; - - } else { - return -1; } } + return nCount; } -int MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *szSrc, int nChar) +static int __MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar) { - unsigned char *org; - unsigned char t1; - unsigned char t2; - unsigned char t3; + unsigned char* org; + unsigned char t1, t2; - MSG_DEBUG("MsgUnicode2UTF: --------------- \n"); + MSG_DEBUG("---------------"); org = des; outBufSize--; // NULL character while ((nChar > 0) && (*szSrc != '\0')) { - if (0x0001 <= *szSrc && *szSrc <= 0x007F) { + if (0x01 <= *szSrc && *szSrc <= 0x7F) { /* check outbuffer's room for this UTF8 character */ outBufSize --; @@ -7538,7 +5249,7 @@ int MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *szSrc, in des++; szSrc++; nChar--; - } else if ((*szSrc == 0x0000) || (0x0080 <= *szSrc && *szSrc <= 0x07FF)) { + } else { /* check outbuffer's room for this UTF8 character */ outBufSize -= 2; @@ -7546,32 +5257,14 @@ int MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *szSrc, in goto __RETURN; t2 = (unsigned char) (*szSrc & 0x003F); // right most 6 bit - t1 = (unsigned char) ((*szSrc & 0x07C0) >> 6); // right most 5 bit + t1 = (unsigned char) ((*szSrc & 0xC0) >> 6); // right most 2 bit *des = 0xC0 | (t1 & 0x1F); - *(des+1) = 0x80 | (t2 & 0x3F); + *(des + 1) = 0x80 | (t2 & 0x3F); des += 2; szSrc += 1; nChar -= 1; - } else { - /* check outbuffer's room for this UTF8 character */ - - outBufSize -= 3; - if (outBufSize < 0) - goto __RETURN; - - t3 = (unsigned char) (*szSrc & 0x003F); // right most 6 bit - t2 = (unsigned char) ((*szSrc & 0x0FC0) >> 6); // right most 6 bit - t1 = (unsigned char) ((*szSrc & 0xF000) >> 12); // right most 4 bit - - *des = 0xE0 | (t1 & 0x0F); - *(des+1) = 0x80 | (t2 & 0x3F); - *(des+2) = 0x80 | (t3 & 0x3F); - - des += 3; - szSrc += 1; - nChar -= 1; } } @@ -7581,36 +5274,6 @@ __RETURN: return (des - org); } -int MsgGetUnicode2UTFCodeSize(unsigned short *szSrc, int nChar) -{ - int nCount = 0; - - MSG_DEBUG("MsgGetUnicode2UTFCodeSize: --------------- \n"); - - if ((szSrc == NULL) || (nChar <= 0)) { - MSG_DEBUG("MsgGetUnicode2UTFCodeSize: szSrc is NULL !!!! --------------- \n"); - return 0; - } - - while ((nChar > 0) && (*szSrc != '\0')) { - if (0x0001 <= *szSrc && *szSrc <= 0x007F) { - nCount += 1; - szSrc++; - nChar--; - } else if ((*szSrc == 0x0000) || (0x0080 <= *szSrc && *szSrc <= 0x07FF)) { - nCount += 2; - szSrc++; - nChar--; - } else { - nCount += 3; - szSrc++; - nChar--; - } - } - - return nCount; -} - bool MmsAddrUtilCheckEmailAddress(char *pszAddr) { if (!pszAddr || pszAddr[0] == 0) @@ -7630,7 +5293,7 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr) int strLen = 0; if ((!pszAddr) || (pszAddr[0] == 0)) { - MSG_DEBUG("MmsAddrUtilRemovePlmnString: pszAddr is null or zero\n"); + MSG_DEBUG("pszAddr is null or zero"); return false; } @@ -7638,19 +5301,18 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr) pszAddrCopy = (char*)calloc(1,strLen + 1); if (!pszAddrCopy) { - MSG_DEBUG("MmsAddrUtilRemovePlmnString: pszAddrCopy is NULL, mem alloc failed\n"); + MSG_DEBUG("pszAddrCopy is NULL, mem alloc failed"); return false; } - strcpy(pszAddrCopy, pszAddr); - + strncpy(pszAddrCopy, pszAddr, strLen); pszAddr[0] = 0; pszStrStart = pszAddrCopy; while (true) { char* pszStrEnd = NULL; - int addressLen = 0; + int addressLen = 0; if (MmsAddrUtilCheckEmailAddress(pszAddrCopy)) pszStrEnd = strstr(pszStrStart, "/TYPE=PLMN"); @@ -7658,6 +5320,8 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr) pszStrEnd = strstr(pszStrStart, "/"); if (!pszStrEnd) { + char *pszStart = NULL; + char *pszEnd = NULL; // "/TYPE=PLMN" not found int remainedLen = strlen(pszStrStart); @@ -7665,8 +5329,21 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr) if (remainedLen <= 0) break; - strcat(pszAddr, pszStrStart); + //Email address can occur with Sender Name format + //remove the Sender name and only retain the email address. + pszStart = strstr(pszStrStart, "<"); + if (pszStart) { + pszEnd = strstr(pszStrStart, ">"); + + if (pszEnd) { + pszStart++; //skip "<" + g_strlcat(pszAddr, pszStart, pszEnd - pszStart + 1); + break; + } + } + //strcat(pszAddr, pszStrStart); + g_strlcat(pszAddr, pszStrStart, strLen + 1); break; } @@ -7691,23 +5368,23 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr) break; - strcat(pszAddr, MSG_MMS_STR_ADDR_DELIMETER); // add ';' + g_strlcat(pszAddr, MSG_MMS_STR_ADDR_DELIMETER, strLen + 1); // add ';' pszStrStart++; // remove ';' } if (pszAddr[0] == 0) - strcpy(pszAddr, pszAddrCopy); + strncpy(pszAddr, pszAddrCopy, strLen); free(pszAddrCopy); return true; } -int MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar) +static int __MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar) { unsigned char *org; - MSG_DEBUG("MsgCutUTFString: --------------- \n"); + MSG_DEBUG("---------------"); org = des; outBufSize--; // NULL character @@ -7750,7 +5427,7 @@ int MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, in *des = *szSrc; des++; szSrc++; - MSG_DEBUG("MsgCutUTFString: utf8 incorrect range!\n"); + MSG_DEBUG("utf8 incorrect range!"); } nChar--; @@ -7762,11 +5439,11 @@ __RETURN: return (des - org); } -void MsgMIMERemoveQuote(char *szSrc) +static void __MsgMIMERemoveQuote(char *szSrc) { - int length = 0; + int length = 0; - length = MsgStrlen(szSrc); + length = strlen(szSrc); if (szSrc[0] == MSG_CH_QUOT && szSrc[length-1] == MSG_CH_QUOT) { int index = 0; @@ -7776,14 +5453,12 @@ void MsgMIMERemoveQuote(char *szSrc) } } -bool MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffset, char *pInBuf1, char *pInBuf2, int maxLen, int *pBufLen, int endOfFile) +static bool __MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffset, char *pInBuf1, char *pInBuf2, int maxLen, int *pBufLen, int endOfFile) { MSG_BEGIN(); int nRead = 0; int length= 0; - MSG_DEBUG("MsgLoadDataToDecodeBuffer: \n"); - if (pFile == NULL) { MSG_DEBUG("Error"); @@ -7843,77 +5518,15 @@ bool MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffse } if ((*pOffset = MsgFtell(pFile)) == -1L) { - MSG_DEBUG("MsgFtell Error"); - return false; - } - - MSG_END(); - - return true; -} - - -bool MsgGetTypeByFileName(int *type, char *szFileName) -{ - char *pExt = NULL; - AvCodecType AvType = AV_CODEC_NONE; - - pExt = strrchr(szFileName, '.'); - if (pExt == NULL || pExt[0] == '\0') - goto __CATCH; - - pExt++; - - if (strcasecmp(pExt, "mp4") == 0 ||strcasecmp(pExt, "mpeg4") == 0 ||strcasecmp(pExt, "3gp") == 0 ||strcasecmp(pExt, "3gpp") == 0) { - - if (szFileName[0] != '/') - goto __CATCH; - - AvType = AvGetFileCodecType(szFileName); - MSG_DEBUG("MsgGetTypeByFileName:AvType(0x%x)\n", AvType); - - switch (AvType) { - case AV_DEC_AUDIO_MPEG4: - *type = MIME_AUDIO_MP4; - break; - - case AV_DEC_VIDEO_MPEG4: - *type = MIME_VIDEO_MP4; - break; - - default: - *type = MIME_VIDEO_3GPP; - break; - } - return true; - } - - if (strcasecmp(pExt, "amr") == 0) { - *type = MIME_AUDIO_AMR; - return true; - } else if ((strcasecmp(pExt, "mid") == 0) || (strcasecmp(pExt, "midi") == 0)) { - *type = MIME_AUDIO_MIDI; - return true; - } else if (strcasecmp(pExt, "imy") == 0) { - *type = MIME_TEXT_X_IMELODY; - return true; - } - - *type = MimeGetMimeFromExtInt((const char*)pExt); - MSG_DEBUG("MsgGetTypeByFileName: szFileName = %s type = %d \n", szFileName, type); - return true; - - -__CATCH: - - *type = MIME_UNKNOWN; - MSG_DEBUG("MsgGetTypeByFileName: szFileName = %s type = %d \n", szFileName, type); + MSG_DEBUG("MsgFtell Error"); + return false; + } - return false; + MSG_END(); + return true; } - /* * This function write media data from raw data to file. * @param pMsg @@ -7923,72 +5536,142 @@ __CATCH: * @param index : used for file naming * @param bSave : if true, file will be save otherwise just filename will be stored. */ -bool _MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave) +static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave) { FILE *pFile = NULL; - char *pExt = NULL; char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, }; // file name of temp file char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; // full absolute path of temp file. - - MSG_DEBUG("**** _MmsSaveMediaData: [Multi part] START ***\n"); + bool bFileExist = false; + MSG_BEGIN(); if (!pPartType) { - MSG_DEBUG("pPartType is NULL\n"); - return true; // why true value is retured ??? ; false; + MSG_DEBUG("pPartType is NULL"); + return false; } - if (pPartType->param.szName[0] == '\0' && pPartType->param.szFileName[0] == '\0') - strcpy(pPartType->param.szName, pPartType->param.szFileName); - - if (pPartType->param.szName) { - strcpy(szFileName, pPartType->param.szName); + if (pPartType->type == MIME_APPLICATION_SMIL) { + snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", "smil.txt"); } else { - snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%lu", (unsigned long)index); - } - -#ifndef __SUPPORT_DRM__ - MsgMakeFileName(pPartType->type, szFileName, 0); //FL & CD -> extension(.dm) SD -> extension(.dcf) -#else - MsgMakeFileName(pPartType->type, szFileName, pPartType->drmInfo.drmType, 0); //FL & CD -> extension(.dm) SD -> extension(.dcf) - if (MsgDRMIsForwardLockType(pPartType->drmInfo.drmType)) - MsgChangeDrm2FileName(szFileName); -#endif + if (pPartType->param.szName[0] != '\0') { + snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", pPartType->param.szName); + } else if (pPartType->param.szFileName[0] != '\0') { + snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", pPartType->param.szFileName); + } else if (pPartType->szContentLocation[0] != '\0') { + snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", pPartType->szContentLocation); + } else { + snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%lu", (unsigned long)index); + } + } + // make full path for save + __MsgMakeFileName(pPartType->type, szFileName, pPartType->drmInfo.drmType, 0, szFileName, sizeof(szFileName)); //FL & CD -> extension(.dm) SD -> extension(.dcf) snprintf(szFullPath, MSG_FILEPATH_LEN_MAX, "%s%s.dir/%s", pszMailboxPath, pszMsgFilename, szFileName); // get absolute path of each temp file of each part - snprintf(pPartType->param.szFileName, MSG_FILENAME_LEN_MAX+1, "%s.dir/%s", pszMsgFilename, szFileName); // store relative path of each temp file of each part including sub folder. if (pPartType->type == MIME_APPLICATION_OCTET_STREAM) - MsgGetTypeByFileName(&pPartType->type, szFullPath); + MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, szFullPath, (MimeType *)&pPartType->type, NULL); // save file - if (bSave) { + bFileExist = MsgAccessFile(szFullPath, F_OK); + + MSG_SEC_DEBUG("save flag [%d], filepath [%s], file exist [%d]", bSave, szFullPath, bFileExist); + + if (bSave == true && bFileExist == false) { + if ((pFile = MsgOpenFile(szFullPath, "wb+")) == NULL) { MSG_DEBUG("MsgOpenFile failed"); goto __CATCH; } - if (MmsGetMediaPartData(pPartType, pPartBody, pFile) == false) { + if (__MmsGetMediaPartData(pPartType, pPartBody, pFile) == false) { MSG_DEBUG("MmsGetMediaPartData fail [index:%d]\n", index); goto __CATCH; } MsgCloseFile(pFile); pFile = NULL; + + snprintf(pPartBody->szOrgFilePath, sizeof(pPartBody->szOrgFilePath), "%s", szFullPath); + + //IF DRM type Convert to dcf + if (pPartType->type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE + || pPartType->type == MIME_APPLICATION_VND_OMA_DRM_CONTENT) + { + char destDrmPath[MSG_FILEPATH_LEN_MAX] = {0,}; + + if (MsgDrmConvertDmtoDcfType(pPartBody->szOrgFilePath, destDrmPath) == true) { + MSG_INFO("Success Convert to Dcf"); + + bFileExist = MsgAccessFile(destDrmPath, F_OK); + + if (bFileExist) { + snprintf(pPartBody->szOrgFilePath, sizeof(pPartBody->szOrgFilePath), "%s", destDrmPath); + MsgGetFileName(pPartBody->szOrgFilePath, szFileName, MSG_FILENAME_LEN_MAX); + } + + } else { + MSG_INFO("Fail Convert to Dcf"); + } + + if (MsgDrmIsDrmFile(pPartBody->szOrgFilePath) == true) + MmsPluginDrmGetInfo(pPartBody->szOrgFilePath, pPartType); + + MSG_SEC_INFO("Drm File Path [%s] isdrm [%d]", pPartBody->szOrgFilePath, MsgDrmIsDrmFile(pPartBody->szOrgFilePath)); + } + + pPartBody->offset = 0; + pPartBody->size = MsgGetFileSize(pPartBody->szOrgFilePath); + if (pPartType->drmInfo.drmType != MSG_DRM_TYPE_NONE) { - MsgDrmRegisterFile(MSG_MODE_FILE, szFullPath, strlen(szFullPath)); + MsgDrmRegisterFile(MSG_MODE_FILE, pPartBody->szOrgFilePath, strlen(pPartBody->szOrgFilePath)); /* change szDrm2FullPath as current content path*/ if (pPartType->drmInfo.szDrm2FullPath) { free(pPartType->drmInfo.szDrm2FullPath); - pPartType->drmInfo.szDrm2FullPath = MsgStrCopy(szFullPath); + pPartType->drmInfo.szDrm2FullPath = g_strdup(pPartBody->szOrgFilePath); + } + } + + MSG_SEC_DEBUG("Save Part File to [%s]", pPartBody->szOrgFilePath); + + } else { + snprintf(pPartBody->szOrgFilePath, sizeof(pPartBody->szOrgFilePath), "%s", szFullPath); + + //IF DRM type check dcf exist + if (pPartType->type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE + || pPartType->type == MIME_APPLICATION_VND_OMA_DRM_CONTENT) + { + char destDrmPath[MSG_FILEPATH_LEN_MAX] = {0,}; + + MsgGetFileNameWithoutExtension(destDrmPath, pPartBody->szOrgFilePath); + strncat(destDrmPath, ".dcf", 4); + + bFileExist = MsgAccessFile(destDrmPath, F_OK); + + if (bFileExist) { + snprintf(pPartBody->szOrgFilePath, sizeof(pPartBody->szOrgFilePath), "%s", destDrmPath); + MsgGetFileName(pPartBody->szOrgFilePath, szFileName, MSG_FILENAME_LEN_MAX); } + + if (MsgDrmIsDrmFile(pPartBody->szOrgFilePath) == true) + MmsPluginDrmGetInfo(pPartBody->szOrgFilePath, pPartType); } + pPartBody->offset = 0; + pPartBody->size = MsgGetFileSize(pPartBody->szOrgFilePath); + + MSG_SEC_DEBUG("Set Part File to [%s]", pPartBody->szOrgFilePath); } - MSG_DEBUG("**** MmsGetMediaPartData: [Multi part] E N D (Successfully) ***\n"); + //file name fix + if (szFileName[0] != '\0') { + snprintf(pPartType->param.szFileName, MSG_FILENAME_LEN_MAX+1, "%s.dir/%s", pszMsgFilename, szFileName);// store relative path of each temp file of each part including sub folder. + snprintf(pPartType->param.szName, MSG_LOCALE_FILENAME_LEN_MAX+1, "%s", szFileName); + MSG_SEC_DEBUG("Set Name : %s", pPartType->param.szName); + } + + MSG_END(); return true; __CATCH: @@ -7997,13 +5680,11 @@ __CATCH: MsgCloseFile(pFile); pFile = NULL; } - + MSG_END(); return false; } - - -bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile) +bool __MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile) { int nRead = 0; int nRead2 = 0; @@ -8013,8 +5694,7 @@ bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile) int msgEncodingValue = 0; int msgTypeValue = 0; int msgCharsetValue = 0; - int cidLen = 0; - char *szCid = NULL; + int offset = 0; int size = 0; @@ -8022,8 +5702,6 @@ bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile) msgTypeValue = pPartType->type; msgCharsetValue = pPartType->param.charset; - cidLen = MsgStrlen(szCid); - offset = pPartBody->offset; size = pPartBody->size; @@ -8031,7 +5709,7 @@ bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile) pTempData = MsgOpenAndReadMmsFile(pPartBody->szOrgFilePath, offset, size, &nRead); if (pTempData == NULL) { - MSG_DEBUG("MmsGetMediaPartData : pTempData read fail\n"); + MSG_DEBUG("pTempData read fail"); goto __CATCH; } @@ -8042,20 +5720,28 @@ bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile) } if (pData == NULL) { - MSG_DEBUG("MmsGetMediaPartData : there is no data \n"); + MSG_DEBUG("there is no data"); goto __RETURN; } - pNewData = MmsGetBinaryUTF8Data(pData, nRead, msgEncodingValue, msgTypeValue, msgCharsetValue, &nRead2); - pPartType->encoding = MSG_ENCODING_BINARY; + pNewData = __MmsGetBinaryUTF8Data(pData, nRead, msgEncodingValue, msgTypeValue, msgCharsetValue, &nRead2); - if (MsgIsText(msgTypeValue)) - pPartType->param.charset = MSG_CHARSET_UTF8; + if (pNewData) { + pPartType->encoding = MSG_ENCODING_BINARY; - if (MsgWriteFile(pNewData, sizeof(char), nRead2, pFile) != (size_t)nRead2) { - MSG_DEBUG("MmsGetMediaPartData: file writing fail \n"); + if (MmsIsTextType(msgTypeValue)) + pPartType->param.charset = MSG_CHARSET_UTF8; - goto __CATCH; + if (MsgWriteFile(pNewData, sizeof(char), nRead2, pFile) != (size_t)nRead2) { + MSG_DEBUG("file writing fail"); + goto __CATCH; + } + + } else { + if (MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) { + MSG_DEBUG("file writing fail"); + goto __CATCH; + } } __RETURN: @@ -8087,24 +5773,25 @@ __CATCH: return false; } -char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msgTypeValue, int msgCharsetValue, int *npRead) +char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msgTypeValue, int msgCharsetValue, int *npRead) { - int nChar = 0; int nByte = 0; int nTemp = 0; char *pTemp = NULL; - unsigned short *mszTempStr = NULL; + char *pConvertedStr = NULL; char *pConvertedData = NULL; char *pNewData = NULL; char *pReturnData = NULL; + const char *pToCodeSet = "UTF-8"; + const char *pFromCodeSet = NULL; switch (msgEncodingValue) { case MSG_ENCODING_BASE64: - pConvertedData = (char*)_MsgDecodeBase64((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte); - MSG_DEBUG("MmsGetBinaryUTF8Data : MSG_ENCODING_BASE64 bodyLength = %d \n", nByte); + pConvertedData = (char*)MsgDecodeBase64((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte); + MSG_DEBUG("MSG_ENCODING_BASE64 bodyLength [%d]", nByte); pTemp = pConvertedData; nTemp = nByte; @@ -8113,8 +5800,8 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg case MSG_ENCODING_QUOTE_PRINTABLE: - pConvertedData = (char*)_MsgDecodeQuotePrintable((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte); - MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_ENCODING_QUOTE_PRINTABLE bodyLength = %d \n", nByte); + pConvertedData = (char*)MsgDecodeQuotePrintable((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte); + MSG_DEBUG("MSG_ENCODING_QUOTE_PRINTABLE bodyLength [%d]", nByte); pTemp = pConvertedData; nTemp = nByte; @@ -8123,436 +5810,602 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg default: - MSG_DEBUG("MmsGetBinaryUTF8Data: 8bit OR Binary bodyLength = %d \n", nRead); - + MSG_DEBUG("encoding val [%d] bodyLength [%d]", msgEncodingValue, nRead); pTemp = pData; nTemp = nRead; - break; + break; + } + + if (MmsIsTextType(msgTypeValue)) { + + if (msgCharsetValue == MSG_CHARSET_US_ASCII) { + pNewData = pTemp; + *npRead = nTemp; + } else if (msgCharsetValue == MSG_CHARSET_UTF8) { + + // skip BOM (Byte Order Mark) bytes .. (Please refer to the http://www.unicode.org/faq/utf_bom.html#BOM) + if (nTemp >= 3) { + if (((UINT8)pTemp[0]) == 0xEF && ((UINT8)pTemp[1]) == 0xBB && ((UINT8)pTemp[2]) == 0xBF) { + pTemp += 3; + nTemp -= 3; + } + } + + pNewData = pTemp; + *npRead = nTemp; + } else { + + UINT16 MIBenum = MmsGetBinaryValue(MmsCodeCharSet, msgCharsetValue); + + pFromCodeSet = MmsGetTextByCode(MmsCodeCharSet, MIBenum); + + MSG_DEBUG("char set enum = [%d], MIBenum = [%d], str = [%s]", msgCharsetValue, MIBenum, pFromCodeSet); + + if (pFromCodeSet) { + MSG_DEBUG("Convert to UTF-8"); + + if (MmsPluginTextConvert(pToCodeSet, pFromCodeSet, pTemp, nTemp, &pConvertedStr, npRead) == true) { + pNewData = pConvertedStr; + } else { + MSG_DEBUG("Failed MmsPluginTextConvert"); + pNewData = pTemp; + *npRead = nTemp; + } + + } else {//unsupported charset + MSG_DEBUG("unsupported charset"); + pNewData = pTemp; + *npRead = nTemp; + } + } + + } else { + pNewData = pTemp; + *npRead = nTemp; + } + + pReturnData = (char *)calloc(1, *npRead); + if (pReturnData == NULL) { + MSG_DEBUG("pReturnData alloc fail."); + goto __CATCH; + } + + if (pNewData != NULL) { + memset(pReturnData, 0, *npRead); + memcpy(pReturnData, pNewData, *npRead); + } + + if (pConvertedData) { + free(pConvertedData); + pConvertedData = NULL; + } + + if (pConvertedStr) { + free(pConvertedStr); + pConvertedStr = NULL; + } + + return pReturnData; + +__CATCH: + + if (pConvertedData) { + free(pConvertedData); + pConvertedData = NULL; + } + + if (pConvertedStr) { + free(pConvertedStr); + pConvertedStr = NULL; + } + + return NULL; +} + +static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex, char *outBuf, int outBufLen) +{ + char szTemp[MSG_FILENAME_LEN_MAX+1]={0,}; + char szTempFileName[MSG_FILENAME_LEN_MAX+1]={0,}; + const char *pExt = NULL; + + SECURE_SLOGD("Input : type [0x%x], drmType [%d], filename [%s]", iMsgType, drmType, szFileName); + + if (szFileName == NULL) + return false; + + //Filename + int inp_len = strlen(szFileName); + if (inp_len > 0) { + + pExt = strrchr(szFileName, '.'); + + if (pExt != NULL && *(pExt + 1) != '\0') { + pExt = pExt +1; + } else { + pExt = NULL; + } + + MsgGetFileNameWithoutExtension(szTempFileName, szFileName); + } else { + if (nUntitleIndex >= 1) { + snprintf(szTempFileName, sizeof(szTempFileName), "%s_%d", "untitled", nUntitleIndex); + } else { + snprintf(szTempFileName, sizeof(szTempFileName), "%s", "untitled"); + } + } + + //extension + if (iMsgType == MIME_APPLICATION_VND_OMA_DRM_MESSAGE) + pExt = "dm"; + else if (iMsgType == MIME_APPLICATION_VND_OMA_DRM_CONTENT) + pExt = "dcf"; + + if (pExt == NULL) { // find ext from content type + + if (iMsgType == MIME_APPLICATION_OCTET_STREAM || iMsgType == MIME_UNKNOWN) { + MSG_DEBUG("unsupported MsgType [%d]", iMsgType); + goto __CATCH; + } + + pExt = MimeGetExtFromMimeInt((MimeType)iMsgType); + } + + //Filename + extension + if (pExt) { + snprintf(szTemp, sizeof(szTemp), "%s.%s", szTempFileName, pExt); + } else { + MSG_DEBUG("Failed to get extension of that mime data file."); + goto __CATCH; + } + + snprintf(outBuf, outBufLen, "%s", szTemp); + SECURE_SLOGD("Result : filename [%s]", outBuf); + return true; + +__CATCH: + return false; +} + +bool MsgGetFileNameWithoutExtension (char *szOutputName, char *szName) +{ + char *pszExt = NULL; + + if (szOutputName == NULL) { + MSG_DEBUG("szOutputName is NULL"); + return false; + } + + strncpy(szOutputName, szName, strlen(szName)); + + if ((pszExt = strrchr(szOutputName, '.'))) { + if (pszExt[0] == '.') + pszExt[0] = '\0'; + } + + return true; +} + +bool MsgGetFileName(char *szFilePath, char *szFileName, int size) +{ + char *filename = NULL; + if (szFilePath) { + filename = strrchr(szFilePath, '/'); + if (filename != NULL) { + snprintf(szFileName, size, "%s", filename + 1); + } else { + snprintf(szFileName, size, "%s", szFilePath); + } + } else { + return false; + } + + return true; +} + +bool MmsGetMediaPartHeader(int index, MsgType *pHeader) +{ + MmsMsg *pMsg = NULL; + MsgMultipart *pPart = NULL; + + if (pHeader == NULL) { + MSG_DEBUG("Invalid pHeader input. It's null"); + return false; + } + + MmsPluginStorage::instance()->getMmsMessage(&pMsg); + + MmsInitMsgType(pHeader); + + + /* Requires header of non-presentation */ + if (MsgIsMultipart(pMsg->msgType.type)) { + MSG_DEBUG("Multipart header [index = %d] \n", index); + + pPart = pMsg->msgBody.body.pMultipart; + + while (pPart && index--) + pPart = pPart->pNext; + + if (pPart == NULL) { + MSG_DEBUG("There is no such msg part."); + return false; + } + + memcpy(pHeader, &pPart->type, sizeof(MsgType)); + } else { + MSG_DEBUG("Requires singlepart header"); + memcpy(pHeader, &pMsg->msgType, sizeof(MsgType)); + } + + return true; +} + + +/////////////////////////////////////////////////////////////////////////////// + +MmsPluginDecoder *MmsPluginDecoder::pInstance = NULL; + +MmsPluginDecoder *MmsPluginDecoder::instance() +{ + if (!MmsPluginDecoder::pInstance) + MmsPluginDecoder::pInstance = new MmsPluginDecoder(); + + return MmsPluginDecoder::pInstance; +} + +MmsPluginDecoder::MmsPluginDecoder(){} +MmsPluginDecoder::~MmsPluginDecoder(){} + +void MmsPluginDecoder::decodeMmsPdu(MmsMsg *pMsg, msg_message_id_t msgID, const char *pduFilePath) +{ + MSG_BEGIN(); + + FILE *pFile = NULL; + MsgMultipart *pMultipart = NULL; + int nSize = 0; + char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; + char szTempMediaDir[MSG_FILEPATH_LEN_MAX] = {0, }; + + MmsInitHeader(); + + pMsg->msgID = msgID; + + snprintf(szFullPath, sizeof(szFullPath), "%s", pduFilePath); + + MsgGetFileName(szFullPath, pMsg->szFileName, sizeof(pMsg->szFileName)); + + if (MsgGetFileSize(szFullPath, &nSize) == false) { + MSG_FATAL("Fail MsgGetFileSize"); + goto __CATCH; } - if (MsgIsText(msgTypeValue)) { - /* charset converting */ + pFile = MsgOpenFile(szFullPath, "rb"); + if (pFile == NULL) { + MSG_SEC_DEBUG("Fail MsgOpenFile [%s]", szFullPath); + goto __CATCH; + } - switch (msgCharsetValue) { - case MSG_CHARSET_UTF16: - case MSG_CHARSET_USC2: + MmsRegisterDecodeBuffer(); - MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_USC2 \n"); + if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) { + MSG_FATAL("Fail to MmsBinaryDecodeMsgHeader"); + goto __CATCH; + } - if (((UINT8)pTemp[0]) == 0xFF && ((UINT8)pTemp[1]) == 0xFE) { - nChar = (nTemp / 2 - 1); + if (MmsBinaryDecodeMsgBody(pFile, szFullPath, nSize) == false) { + MSG_FATAL("Fail to MmsBinaryDecodeMsgBody"); + goto __CATCH; + } - mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short)); - if (mszTempStr == NULL) { - MSG_DEBUG("MmsGetBinaryUTF8Data : 1. Memory Full !!! \n"); - goto __CATCH; - } + /* Set mmsHeader.msgType & msgBody to pMsg ----------- */ - memcpy(mszTempStr, ((unsigned short*)pTemp + 1), nChar * sizeof(unsigned short)); + memcpy(&(pMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType)); + memcpy(&(pMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody)); - nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTemp + 1), nChar); +{//attribute convert mmsHeader -> mmsAttribute - pConvertedStr = (char *)malloc(nByte + 1); - if (pConvertedStr != NULL) - MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar); - } else { - nChar = (nTemp / 2); + pMsg->mmsAttrib.contentType = (MimeType)mmsHeader.msgType.type; - mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short)); - if (mszTempStr == NULL) { - MSG_DEBUG("MmsGetBinaryUTF8Data: 2. Memory Full !!! \n"); - goto __CATCH; - } + pMsg->mmsAttrib.date = mmsHeader.date; - memcpy(mszTempStr, ((unsigned short*)pTemp), nChar * sizeof(unsigned short)); + if (mmsHeader.deliveryReport == MMS_REPORT_YES) { + pMsg->mmsAttrib.bAskDeliveryReport = true; + } - nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTemp), nChar); + memcpy(&pMsg->mmsAttrib.deliveryTime, &mmsHeader.deliveryTime, sizeof(MmsTimeStruct)); - pConvertedStr = (char *)malloc(nByte + 1); - if (pConvertedStr) - MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar); - } + memcpy(&pMsg->mmsAttrib.expiryTime, &mmsHeader.expiryTime, sizeof(MmsTimeStruct)); - if (pConvertedStr != NULL) - pNewData = pConvertedStr; + MSG_DEBUG("@@@@@pMsg->mmsAttrib.deliveryTime=[%d]", pMsg->mmsAttrib.deliveryTime); - *npRead = nByte + 1; + pMsg->mmsAttrib.msgClass = mmsHeader.msgClass; - break; + snprintf(pMsg->szMsgID, sizeof(pMsg->szMsgID), "%s", mmsHeader.szMsgID); - case MSG_CHARSET_US_ASCII: + pMsg->mmsAttrib.msgType = mmsHeader.type; - MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_US_ASCII \n"); + pMsg->mmsAttrib.version = mmsHeader.version; - /* fall through */ + pMsg->mmsAttrib.msgSize = mmsHeader.msgSize; - case MSG_CHARSET_UTF8: + pMsg->mmsAttrib.priority = mmsHeader.priority; - MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_UTF8 or Others \n"); + if (mmsHeader.readReply == MMS_REPORT_YES) { + pMsg->mmsAttrib.bAskReadReply = true; + } - // skip BOM (Byte Order Mark) bytes .. (Please refer to the http://www.unicode.org/faq/utf_bom.html#BOM) - if (nTemp >= 3) { - if (((UINT8)pTemp[0]) == 0xEF && ((UINT8)pTemp[1]) == 0xBB && ((UINT8)pTemp[2]) == 0xBF) { - pTemp += 3; - nTemp -= 3; - } - } - pNewData = pTemp; - *npRead = nTemp; + snprintf(pMsg->mmsAttrib.szSubject, sizeof(pMsg->mmsAttrib.szSubject), "%s", mmsHeader.szSubject); - break; + snprintf(pMsg->szTrID, sizeof(pMsg->szTrID), "%s", mmsHeader.szTrID); - case MSG_CHARSET_ISO_8859_7: + pMsg->mmsAttrib.retrieveStatus = mmsHeader.retrieveStatus; - /* Greek */ + //FIXME:: mmsHeader will release after delete global mmsHeader + //memset(&(mmsHeader.msgBody), 0x00, sizeof(MsgBody));//After copy to MmsMsg +} + if (pMsg->msgBody.pPresentationBody) { + if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0) + goto __CATCH; - MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_ISO_8859_7 \n"); + pMsg->msgBody.pPresentationBody->body.pText = (char *)calloc(1, pMsg->msgBody.pPresentationBody->size + 1); + if (pMsg->msgBody.pPresentationBody->body.pText == NULL) + goto __CATCH; - nByte = MsgGetLatin72UTFCodeSize((unsigned char*)pTemp, nTemp); - pConvertedStr = (char *)malloc(nByte + 1); - if (pConvertedStr) - MsgLatin7code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp); + memset(pMsg->msgBody.pPresentationBody->body.pText, 0, pMsg->msgBody.pPresentationBody->size + 1); - pNewData = pConvertedStr; - *npRead = nByte + 1; + ULONG nRead = 0; + nRead = MsgReadFile(pMsg->msgBody.pPresentationBody->body.pText, sizeof(char), pMsg->msgBody.pPresentationBody->size, pFile); + if (nRead == 0) + goto __CATCH; - break; + } - case MSG_CHARSET_ISO_8859_9: + MsgCloseFile(pFile); + pFile = NULL; + /* nPartCount */ + pMsg->nPartCount = 0; - /* Turkish */ - MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_ISO_8859_9 \n"); + if (MsgIsMultipart(mmsHeader.msgType.type) == true) { + pMultipart = pMsg->msgBody.body.pMultipart; + while (pMultipart) { + pMsg->nPartCount++; + pMultipart = pMultipart->pNext; + } + } else { + if (pMsg->msgBody.size > 0) + pMsg->nPartCount++; + } - nByte = MsgGetLatin52UTFCodeSize((unsigned char*)pTemp, nTemp); - pConvertedStr = (char *)malloc(nByte + 1); - if (pConvertedStr) - MsgLatin5code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp); + /* make temporary */ + snprintf(szTempMediaDir, MSG_FILEPATH_LEN_MAX, "%s%s.dir", MSG_DATA_PATH, pMsg->szFileName); - pNewData = pConvertedStr; - *npRead = nByte + 1; + if (MsgIsMultipart(pMsg->msgType.type) == true) { + int partIndex = 0; + pMultipart = pMsg->msgBody.body.pMultipart; - break; + //if (bSavePartsAsTempFiles) { + if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) { + if (errno == EEXIST) { + MSG_SEC_DEBUG("exist dir : [%s]", szTempMediaDir); + } else { + MSG_SEC_DEBUG("Fail to Create Dir [%s]", szTempMediaDir); + goto __CATCH; + } + } else { + MSG_SEC_DEBUG("make dir : [%s]", szTempMediaDir); + } + //} - default: + if (pMsg->msgBody.pPresentationBody) { + if (__MmsMultipartSaveAsTempFile(&pMsg->msgBody.presentationType, pMsg->msgBody.pPresentationBody, + (char*)MSG_DATA_PATH, pMsg->szFileName, 0, true) == false) + goto __CATCH; + } - MSG_DEBUG("MmsGetBinaryUTF8Data: Other charsets \n"); + while (pMultipart) { - nByte = MsgGetLatin2UTFCodeSize((unsigned char*)pTemp, nTemp); - pConvertedStr = (char *)malloc(nByte + 1); - if (pConvertedStr) - MsgLatin2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp); + if (__MmsMultipartSaveAsTempFile(&pMultipart->type, pMultipart->pBody, + (char*)MSG_DATA_PATH, pMsg->szFileName, partIndex, true) == false) + goto __CATCH; - pNewData = pConvertedStr; - *npRead = nByte + 1; + MmsPrintMulitpart(pMultipart, partIndex); - break; + pMultipart = pMultipart->pNext; + partIndex ++; } - } else { - pNewData = pTemp; - *npRead = nTemp; - } - pReturnData = (char *)malloc(*npRead); - if (pReturnData == NULL) { - MSG_DEBUG("MmsGetBinaryUTF8Data : pReturnData alloc fail. \n"); + } else { //single part + if (pMsg->nPartCount > 0) { - goto __CATCH; - } + //if (bSavePartsAsTempFiles) { + if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) { + if (errno == EEXIST) { + MSG_DEBUG("exist dir : [%s]", szTempMediaDir); + } else { + MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir); + goto __CATCH; + } + } else { + MSG_DEBUG("make dir : [%s]", szTempMediaDir); + } + //} - if (pNewData != NULL) { - memset(pReturnData, 0, *npRead); - memcpy(pReturnData, pNewData, *npRead); + if (__MmsMultipartSaveAsTempFile(&pMsg->msgType, &pMsg->msgBody, + (char*)MSG_DATA_PATH, pMsg->szFileName, 0, true) == false) + goto __CATCH; + } } + MSG_DEBUG("### Success ###"); + MSG_END(); + return; - if (pConvertedData) { - free(pConvertedData); - pConvertedData = NULL; - } +__CATCH: - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; - } + MmsInitHeader(); + MmsUnregisterDecodeBuffer(); - if (mszTempStr) { - free(mszTempStr); - mszTempStr = NULL; + if (pFile != NULL) { + MsgCloseFile(pFile); + pFile = NULL; } - return pReturnData; - -__CATCH: - if (pConvertedData) { - free(pConvertedData); - pConvertedData = NULL; - } + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; - } + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); - if (mszTempStr) { - free(mszTempStr); - mszTempStr = NULL; - } + MSG_DEBUG("### Fail ###"); + MSG_END(); + return; - return NULL; } -#ifndef __SUPPORT_DRM__ -bool MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex) +//CID 41989: Removed function decodeMmsPdu which is unused. +#if 0 +void MmsPluginDecoder::decodeMmsPdu(MMS_DATA_S *pMmsData, const char *pduFilePath) { - char szText[MSG_FILENAME_LEN_MAX+1]={0,}; - char szTemp[MSG_FILENAME_LEN_MAX+1]={0,}; - char szTempFileName[MSG_FILENAME_LEN_MAX+1]={0,}; - char *pExt = NULL; + MSG_BEGIN(); + FILE *pFile = NULL; + MsgMultipart * iter_multipart = NULL; + int nSize = 0; + char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; - MSG_DEBUG("MsgMakeFileName: iMsgType = %d szFileName = %s \n", iMsgType, szFileName); + MmsInitHeader(); - if (szFileName == NULL) - return false; + //pMsg->msgID = msgID; - if (szFileName && (szFileName[0] != '\0')) { - MsgGetFileNameWithoutExtension (szTempFileName, szFileName); + snprintf(szFullPath, sizeof(szFullPath), "%s", pduFilePath); - pExt = strrchr(szTempFileName, '.'); - if (pExt == NULL) { - memset (szText, 0, MSG_FILENAME_LEN_MAX+1); - strncpy(szText, szTempFileName, MSG_FILEPATH_LEN_MAX - 1); - strcat(szText, "."); // add '.' - } else { - memset (szText, 0, MSG_FILENAME_LEN_MAX+1); - strncpy(szText, szTempFileName, pExt+1 - szFileName); // add '.' - } - } else { - if (nUntitleIndex >= 1) { - snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s_%d.", "Untitled", nUntitleIndex); - } else { - snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s.", "Untitled"); - } - } + //MsgGetFileName(szFullPath, pMsg->szFileName, sizeof(pMsg->szFileName)); - if (iMsgType == MIME_APPLICATION_OCTET_STREAM) { - MSG_DEBUG("MsgMakeFileName: unsupported MsgType\n"); + if (MsgGetFileSize(szFullPath, &nSize) == false) { + MSG_FATAL("Fail MsgGetFileSize"); goto __CATCH; - } else { - int nLen = 0; - strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 5); - if (iMsgType == MIME_UNKNOWN || (pExt = MimeGetExtFromMimeInt((MimeType)iMsgType)) == NULL) { - MSG_DEBUG("MsgMakeFileName: Failed to get extension of that mime data file. \n"); - goto __CATCH; - } - nLen = MSG_FILENAME_LEN_MAX - strlen(szTemp); - strncat(szTemp, pExt, nLen); } + pFile = MsgOpenFile(szFullPath, "rb"); + if (pFile == NULL) { + MSG_SEC_DEBUG("Fail MsgOpenFile [%s]", szFullPath); + goto __CATCH; + } - strcpy(szFileName, szTemp); - - MSG_DEBUG("MsgMakeFileName: made szFileName = %s \n", szFileName); + MmsRegisterDecodeBuffer(); - return true; + if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) { + MSG_FATAL("Fail to MmsBinaryDecodeMsgHeader"); + goto __CATCH; + } -__CATCH: - { - char *p = NULL; - p = strrchr(szText, '.'); - if (p != NULL) - *p = 0; - snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", szText); + if (MmsBinaryDecodeMsgBody(pFile, szFullPath, nSize) == false) { + MSG_FATAL("Fail to MmsBinaryDecodeMsgBody"); + goto __CATCH; + } - return false; + //set header + if (pMmsData->header == NULL) { + pMmsData->header = MsgMmsCreateHeader(); } -} -#else -bool MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex) -{ - char szText[MSG_FILENAME_LEN_MAX+1]={0,}; - char szTemp[MSG_FILENAME_LEN_MAX+1]={0,}; - char szTempFileName[MSG_FILENAME_LEN_MAX+1]={0,}; - char *pExt = NULL; - MSG_DEBUG("MsgMakeFileName: iMsgType = 0x%x, drmType = %d, szFileName = %s \n", iMsgType, drmType, szFileName); + pMmsData->header->messageType = mmsHeader.type; - if (szFileName == NULL) - return false; + pMmsData->header->mmsVersion = mmsHeader.version; - if (szFileName && (szFileName[0] != '\0')) { - MsgGetFileNameWithoutExtension (szTempFileName, szFileName); + pMmsData->header->contentType = mmsHeader.msgType.type; - if (drmType != MSG_DRM_TYPE_NONE) { - pExt = strrchr(szTempFileName, '.'); - if (pExt == NULL) { - memset(szText, 0, MSG_FILENAME_LEN_MAX+1); - strncpy(szText, szTempFileName, MSG_FILENAME_LEN_MAX - 1); - strcat(szText, "."); // add '.' - } else { - memset(szText, 0, MSG_FILENAME_LEN_MAX+1); - strncpy(szText, szTempFileName, pExt+1 - szFileName); - } - } else { - if (strrchr(szTempFileName, '.')) - return true; + pMmsData->header->date = mmsHeader.date; - memset(szText, 0, MSG_FILENAME_LEN_MAX+1); - strncpy(szText, szTempFileName, MSG_FILENAME_LEN_MAX - 1); - //temporary commented to save file as original name. - pExt = strrchr(szFileName, '.'); - } - } else { - if (nUntitleIndex >= 1) { - snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s_%d.", "untitled", nUntitleIndex); - } else { - snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s.", "untitled"); - } - } + pMmsData->header->messageSize = mmsHeader.msgSize; - if (drmType == MSG_DRM_TYPE_SD) { - strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 5); - strcat(szTemp, "dcf"); - } else if (MsgDRMIsForwardLockType(drmType)) { - strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 4); - strcat(szTemp, "dm"); - } else { - if (iMsgType == MIME_APPLICATION_OCTET_STREAM) { - MSG_DEBUG("MsgMakeFileName: unsupported MsgType\n"); - goto __CATCH; - } else { - int nLen = 0; - strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 5); - //temporary commented to save file as original name. - if (pExt == NULL) { + pMmsData->header->mmsPriority = mmsHeader.priority; - if (iMsgType == MIME_UNKNOWN || (pExt = MimeGetExtFromMimeInt((MimeType)iMsgType)) == NULL) { - MSG_DEBUG("MsgMakeFileName: Failed to get extension of that mime data file. \n"); - goto __CATCH; - } - } + pMmsData->header->messageClass = mmsHeader.msgClass; - nLen = MSG_FILENAME_LEN_MAX - strlen(szTemp); - strncat(szTemp, pExt, nLen); - } + if (mmsHeader.deliveryReport == MMS_REPORT_YES) { + pMmsData->header->bDeliveryReport = true; } - strcpy(szFileName, szTemp); + if (mmsHeader.readReply == MMS_REPORT_YES) { + pMmsData->header->bReadReport = true; + } - MSG_DEBUG("MsgMakeFileName: made szFileName = %s \n", szFileName); + memcpy(&pMmsData->header->delivery, &mmsHeader.deliveryTime, sizeof(MmsTimeStruct)); - return true; + memcpy(&pMmsData->header->expiry, &mmsHeader.expiryTime, sizeof(MmsTimeStruct)); -__CATCH: - { - char *p = NULL; - p = strrchr(szText, '.'); - if (p != NULL) - *p = 0; - snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", szText); - return false; - } -} -#endif + snprintf(pMmsData->header->messageID, sizeof(pMmsData->header->messageID), "%s", mmsHeader.szMsgID); -bool MsgGetFileNameWithoutExtension (char *szOutputName, char *szName) -{ - char *pszExt = NULL; + snprintf(pMmsData->header->szSubject, sizeof(pMmsData->header->szSubject), "%s", mmsHeader.szSubject); - if (szOutputName == NULL) { - MSG_DEBUG("szOutputName is NULL"); - return false; - } + snprintf(pMmsData->header->trID, sizeof(pMmsData->header->trID), "%s", mmsHeader.szTrID); - strncpy(szOutputName, szName, strlen(szName)); + //CID 41989: Moving assignment of iter_multipart before its de-referencing. + iter_multipart = mmsHeader.msgBody.body.pMultipart; + //set multipart + if (pMmsData->header->contentType == MIME_MULTIPART_RELATED || pMmsData->header->contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { - if ((pszExt = strrchr(szOutputName, '.'))) { - if (pszExt[0] == '.') - pszExt[0] = '\0'; - } + MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); - return true; -} + pMultipart->type = MIME_APPLICATION_SMIL; + snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", "application/smil"); + snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", mmsHeader.msgBody.presentationType.szContentID); + snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", mmsHeader.msgBody.presentationType.szContentLocation); + snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", mmsHeader.msgBody.presentationType.param.szName); -int MmsGetMediaPartCount(msg_message_id_t msgId) -{ - MmsMsg *pMsg; + //snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), MSG_DATA_PATH"%s", mmsHeader.msgBody.presentationType.param.szFileName); - MmsPluginStorage::instance()->getMmsMessage(&pMsg); + MsgBody *pBody = iter_multipart->pBody; + pMultipart->pMultipartData = MsgOpenAndReadMmsFile(pBody->szOrgFilePath, pBody->offset, pBody->size, (int*)&pMultipart->nMultipartDataLen); - if (msgId != pMsg->msgID) { - MSG_DEBUG("Invalid Message Id"); - return -1; + pMmsData->smil = pMultipart; } - return pMsg->nPartCount; -} - -bool MmsGetMediaPartHeader(int index, MsgType *pHeader) -{ - MmsMsg *pMsg = NULL; - MsgMultipart *pPart = NULL; - if (pHeader == NULL) { - MSG_DEBUG("MmsGetMediaPartHeader: Invalid pHeader input. It's null \n"); - return false; - } + while (iter_multipart) { - MmsPluginStorage::instance()->getMmsMessage(&pMsg); + MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); - _MsgInitMsgType(pHeader); + pMultipart->type = (MimeType)iter_multipart->type.type; + snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s",MimeGetMimeStringFromMimeInt(iter_multipart->type.type)); + snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", iter_multipart->type.szContentID); + snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", iter_multipart->type.szContentLocation); + snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", iter_multipart->type.param.szName); - /* Requires header of non-presentation */ - if (MsgIsMultipart(pMsg->msgType.type)) { - MSG_DEBUG("MmsGetMediaPartHeader: Multipart header [index = %d] \n", index); + //snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", iter_multipart->pBody->szOrgFilePath); - pPart = pMsg->msgBody.body.pMultipart; + MsgBody *pBody = iter_multipart->pBody; + pMultipart->pMultipartData = MsgOpenAndReadMmsFile(pBody->szOrgFilePath, pBody->offset, pBody->size, (int*)&pMultipart->nMultipartDataLen); - while (pPart && index--) - pPart = pPart->pNext; - if (pPart == NULL) { - MSG_DEBUG("MmsGetMediaPartHeader: There is no such msg part.\n"); - return false; +#ifdef __SUPPORT_DRM__ + if (iter_multipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { + pMultipart->drmType = iter_multipart->type.drmInfo.drmType; } +#endif - memcpy(pHeader, &pPart->type, sizeof(MsgType)); - } else { - MSG_DEBUG("MmsGetMediaPartHeader: Requires singlepart header \n"); - memcpy(pHeader, &pMsg->msgType, sizeof(MsgType)); + pMmsData->multipartlist = g_list_append(pMmsData->multipartlist, pMultipart); + iter_multipart = iter_multipart->pNext; } - return true; -} -bool MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index) -{ - MSG_DEBUG("------------------------------\n"); - MSG_DEBUG("%dth multipart info\n", index); - MSG_DEBUG("header size=%d\n", pMultipart->type.size); - MSG_DEBUG("body size=%d\n", pMultipart->type.contentSize); - MSG_DEBUG("content type=%s\n", MmsDebugGetMimeType((MimeType)pMultipart->type.type)); - MSG_DEBUG("content ID=%s\n", pMultipart->type.szContentID); - MSG_DEBUG("content location=%s\n", pMultipart->type.szContentLocation); - - if (pMultipart->type.type == MIME_TEXT_PLAIN) { - MSG_DEBUG("text info\n"); - MSG_DEBUG("charset=%d\n", pMultipart->type.param.charset); - MSG_DEBUG("text file name=%s\n", pMultipart->type.param.szName); - } -#ifdef __SUPPORT_DRM__ - if (pMultipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { - MSG_DEBUG("drm info\n"); - MSG_DEBUG("drm type=%d (0: NONE 1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery)\n", pMultipart->type.drmInfo.drmType); - MSG_DEBUG("drm content type=%s\n", MmsDebugGetMimeType((MimeType)pMultipart->type.drmInfo.contentType)); - MSG_DEBUG("drm content URI=%s\n", pMultipart->type.drmInfo.szContentURI); - MSG_DEBUG("drm2FullPath=%s\n", pMultipart->type.drmInfo.szDrm2FullPath); + MSG_DEBUG("### SUCCESS ###"); + MSG_END(); + return; +__CATCH: + + MmsInitHeader(); + MmsUnregisterDecodeBuffer(); + + if (pFile != NULL) { + MsgCloseFile(pFile); + pFile = NULL; } -#endif - MSG_DEBUG("------------------------------\n"); - return true; -} + MSG_DEBUG("### Fail ###"); + MSG_END(); + return; +} +#endif diff --git a/plugin/mms_plugin/MmsPluginDrm.cpp b/plugin/mms_plugin/MmsPluginDrm.cpp index ac0630a..160abdb 100755 --- a/plugin/mms_plugin/MmsPluginDrm.cpp +++ b/plugin/mms_plugin/MmsPluginDrm.cpp @@ -1,88 +1,55 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include + +#if MSG_DRM_SUPPORT #include #include +#endif + +#include "MsgDrmWrapper.h" #include "MmsPluginDrm.h" #include "MmsPluginCodec.h" -#include "MsgMmsTypes.h" -#include "MsgDrmWrapper.h" -#include "MsgDebug.h" - - -#ifdef __SUPPORT_DRM__ +#include "MmsPluginMIME.h" +#include "MmsPluginDebug.h" -MmsDrm2ConvertState mmsDrm2ConvertState; - -MsgDrmType MsgGetDRMType(MsgType *pMsgType, MsgBody *pMsgBody) -{ - MsgDrmType drmType = MSG_DRM_TYPE_NONE; - MsgMultipart *pMultipart = NULL; - - if (MsgIsMultipart(pMsgType->type)) { - pMultipart = pMsgBody->body.pMultipart; - while (pMultipart) { - if (drmType < pMultipart->type.drmInfo.drmType) - drmType = pMultipart->type.drmInfo.drmType; - - pMultipart = pMultipart->pNext; - } - } else { - drmType = pMsgType->drmInfo.drmType; - } - - return drmType; -} - -void MmsDrm2SetConvertState(MmsDrm2ConvertState newConvertState) -{ - mmsDrm2ConvertState = newConvertState; - MSG_DEBUG("MmsDrm2SetConvertState: mmsDrm2ConvertState = %d\n", mmsDrm2ConvertState); -} - -MmsDrm2ConvertState MmsDrm2GetConvertState(void) -{ - return mmsDrm2ConvertState; -} - -bool MsgDRM2GetDRMInfo(char *szFilePath, MsgType *pMsgType) +bool MmsPluginDrmGetInfo(const char *szFilePath, MsgType *pMsgType) { +#if MSG_DRM_SUPPORT if (szFilePath == NULL || pMsgType == NULL) { MSG_DEBUG("Param is NULL szFilePath = %d, pMsgType = %d", szFilePath, pMsgType); return false; } - char szMimeType[DRM_MAX_LEN_MIME + 1]; - char szContentID[DRM_MAX_LEN_CID + 1]; + char szMimeType[DRM_MAX_LEN_MIME + 1] = {0,}; + char szContentID[DRM_MAX_LEN_CID + 1] = {0,}; MSG_DRM_TYPE drmType = MSG_DRM_NONE; + int ret = 0; MsgDrmGetDrmType(szFilePath, &drmType); MsgDrmGetMimeTypeEx(szFilePath, szMimeType, sizeof(szMimeType)); MsgDrmGetContentID(szFilePath, szContentID, sizeof(szContentID)); - MSG_DEBUG("drmType: %d", drmType); + + MSG_DEBUG("drmType: [%d], mimetype: [%s], contentID: [%s]", drmType, szMimeType, szContentID); switch (drmType) { case MSG_DRM_FORWARD_LOCK: pMsgType->drmInfo.drmType = MSG_DRM_TYPE_FL; - pMsgType->drmInfo.contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szMimeType); - if (MsgCopyDrmInfo(pMsgType) == false) { - MSG_DEBUG("MsgDRM2GetDRMInfo : MsgCopyDrmInfo failed"); - return false; - } + pMsgType->drmInfo.contentType = MimeGetMimeIntFromMimeString(szMimeType); break; case MSG_DRM_COMBINED_DELIVERY: @@ -92,20 +59,23 @@ bool MsgDRM2GetDRMInfo(char *szFilePath, MsgType *pMsgType) case MSG_DRM_SEPARATE_DELIVERY: pMsgType->drmInfo.drmType = MSG_DRM_TYPE_SD; - - pMsgType->drmInfo.contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szMimeType); + pMsgType->drmInfo.contentType = MimeGetMimeIntFromMimeString(szMimeType); drm_content_info_s dcfHdrInfo; bzero(&dcfHdrInfo, sizeof(drm_content_info_s)); - drm_get_content_info(szFilePath, &dcfHdrInfo); + ret = drm_get_content_info(szFilePath, &dcfHdrInfo); + if (ret != DRM_RETURN_SUCCESS) + MSG_DEBUG("drm_get_content_info is failed, ret=[%d]", ret); drm_file_info_s fileInfo; bzero(&fileInfo, sizeof(drm_file_info_s)); - drm_get_file_info(szFilePath,&fileInfo); + ret = drm_get_file_info(szFilePath, &fileInfo); + if (ret != DRM_RETURN_SUCCESS) + MSG_DEBUG("drm_get_file_info is failed, ret=[%d]", ret); if (fileInfo.oma_info.version == DRM_OMA_DRMV1_RIGHTS) { pMsgType->drmInfo.szContentName = MsgRemoveQuoteFromFilename(dcfHdrInfo.title); - pMsgType->drmInfo.szContentDescription = MsgStrCopy(dcfHdrInfo.description); + pMsgType->drmInfo.szContentDescription = g_strdup(dcfHdrInfo.description); } break; @@ -114,60 +84,9 @@ bool MsgDRM2GetDRMInfo(char *szFilePath, MsgType *pMsgType) break; } - pMsgType->drmInfo.szDrm2FullPath = MsgStrCopy(szFilePath); + pMsgType->drmInfo.szDrm2FullPath = g_strdup(szFilePath); MSG_DEBUG("pMsgType->drmInfo.szDrm2FullPath: %s", pMsgType->drmInfo.szDrm2FullPath); +#endif return true; } - -bool MsgDRMIsForwardLockType(MsgDrmType drmType) -{ - switch (drmType) { - case MSG_DRM_TYPE_FL: - case MSG_DRM_TYPE_CD: - return true; - - case MSG_DRM_TYPE_NONE: //SD & plain can be forwarded - case MSG_DRM_TYPE_SD: - default: - return false; - } -} - -bool MsgChangeDrm2FileName(char *szFileName) -{ - char szTempFileName[MSG_FILENAME_LEN_MAX] = {0,}; - - if (szFileName == NULL || szFileName[0] == '\0') - return false; - - MsgGetFileNameWithoutExtension(szTempFileName, szFileName); - - if (strrchr(szTempFileName, '.')) - return true; - - strcat(szTempFileName, ".dcf"); - strcpy(szFileName, szTempFileName); - - MSG_DEBUG("MsgChangeDrm2FileName: made szFileName = %s \n", szFileName); - - return true; -} - -bool MsgIsDCFFile(char *szFilePath) -{ - int length = 0; - - MSG_DEBUG("MsgIsDCFFile: szFilePath = %s \n", szFilePath); - - length = MsgStrlen(szFilePath); - if (szFilePath[length - 4] == '.' && - (szFilePath[length - 3] == 'd' || szFilePath[length - 3] == 'D') && - (szFilePath[length - 2] == 'c' || szFilePath[length - 2] == 'C') && - (szFilePath[length - 1] == 'f' || szFilePath[length - 1] == 'F')) - return true; - - return false; -} - -#endif diff --git a/plugin/mms_plugin/MmsPluginEncode.cpp b/plugin/mms_plugin/MmsPluginEncode.cpp index ca26649..abf59b1 100755 --- a/plugin/mms_plugin/MmsPluginEncode.cpp +++ b/plugin/mms_plugin/MmsPluginEncode.cpp @@ -1,99 +1,108 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include #include +#include +#include +#include -#include "MmsPluginMessage.h" -#include "MmsPluginCodec.h" -#include "MsgDebug.h" +#include "MsgCppTypes.h" #include "MsgUtilFile.h" + +#include "MmsPluginDebug.h" +#include "MmsPluginEncode.h" +#include "MmsPluginCodecTypes.h" +#include "MmsPluginCodecCommon.h" #include "MmsPluginMIME.h" +#include "MmsPluginUtil.h" -gint _g_time_rev_set = 0; -gint _g_time_rev = 0; +using namespace std; /** Sending message related variables ------------------------ */ - static char gszMmsEncodeBuf[MSG_MMS_ENCODE_BUFFER_MAX] = {0, }; static int gCurMmsEncodeBuffPos = 0; /* number of characters on gpMmsEncodeBuf */ static int gMmsEncodeMaxLen = 0; static int gMmsEncodeCurOffset = 0; /* offset in file */ static char *gpMmsEncodeBuf = NULL; - /* Acknowledge.ind & NotifyResp.ind related variables ------------------------ */ - static char gszMmsEncodeBuf2[MSG_MMS_ENCODE_BUFFER_MAX] = {0, }; static int gCurMmsEncodeBuffPos2 = 0; /* number of characters on gpMmsEncodeBuf */ static int gMmsEncodeMaxLen2 = 0; static int gMmsEncodeCurOffset2 = 0; /* offset in file */ static char *gpMmsEncodeBuf2 = NULL; - -bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg); -bool _MmsBinaryEncodeAckIndHdr(FILE *pFile, char *pTrID, bool bReportAllowed); -bool _MmsBinaryEncodeNotiRespIndHdr(FILE* pFile, char *pTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed); -bool _MmsBinaryEncodeForwardReqHdr(FILE *pFile, char *szContentLocation, char *szForwardTo, char *szForwardCc, char *szForwardBcc); -bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus); -bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus); - -static bool __MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg, bool bIncludeSendReqHeader); -static int MmsBinaryEncodeUintvarLen(UINT32 integer); -static bool MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length); -static int MmsBinaryEncodeValueLengthLen(UINT32 integer); -static bool MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length); -static int MmsBinaryEncodeIntegerLen(UINT32 integer); -static bool MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length); -static int MmsBinaryEncodeLongIntegerLen(UINT32 integer); -static bool MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length); -static int MmsBinaryEncodeTextStringLen(UINT8 *source); -static bool MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length); -static int MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc); -static bool MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length); -static int MmsBinaryEncodeEncodedStringLen(UINT8 *source); -static bool MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length); -bool MmsBinaryEncodeSendReqHdrwithinBufRegi(FILE *pFile, MmsMsg *pMsg); -bool MmsBinaryEncodeSendReqHdrContTypeFildCode(FILE *pFile, int msgID); - -static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue); +static int __MmsGetEncodeOffset(void); +static void __MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen); +static void __MmsUnregisterEncodeBuffer2(void); + +static int __MmsBinaryEncodeUintvarLen(UINT32 integer); +static bool __MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length); +static int __MmsBinaryEncodeValueLengthLen(UINT32 integer); +static bool __MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length); +static int __MmsBinaryEncodeIntegerLen(UINT32 integer); +static bool __MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length); +static int __MmsBinaryEncodeLongIntegerLen(UINT32 integer); +static bool __MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length); +static int __MmsBinaryEncodeTextStringLen(UINT8 *source); +static bool __MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length); +static int __MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc); +static bool __MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length); +static int __MmsBinaryEncodeEncodedStringLen(UINT8 *source); +static bool __MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length); + +static int __MmsBinaryEncodeContentTypeLen(MsgType *pType); +static bool __MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength); +static int __MmsBinaryEncodeContentHeaderLen(MimeType contentType, MsgType *pType, bool bMultipart); +static bool __MmsBinaryEncodeContentHeader(FILE *pFile, MimeType contentType, MsgType *pType, bool bMultipart); + +static bool __MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody); +static bool __MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody); static bool __MmsBinaryEncodeMmsVersion(FILE *pFile); static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen); static bool __MmsBinaryEncodeMsgID(FILE *pFile, const char *szMsgID); /** 2005-05-24, added for read-reply PDU 1.2 */ static bool __MmsBinaryEncodeFrom(FILE *pFile); static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeStruct time); -static bool __MmsBinaryEncodeDate(FILE *pFile); +static bool __MmsBinaryEncodeDate(FILE *pFile, time_t inpDateSec); static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char *szAddrStr); static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *szAddr); +static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue); +static bool __MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg); +static bool __MmsBinaryEncodeAckIndHdr(FILE *pFile, char *pTrID, bool bReportAllowed); +static bool __MmsBinaryEncodeNotiRespIndHdr(FILE* pFile, char *pTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed); +static bool __MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus); +static bool __MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus); + +static bool __MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate);//NEW_TEMPLATE +static bool __MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg, bool bIncludeSendReqHeader); /* Functions for Acknowledge.ind & NotifyResp.ind ------------------------ */ - -static bool MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length); +static bool __MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length); static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile); static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue); -extern int MsgProcessUrgentEvent(int iMode); +static char *_MsgSkipWS3(char *s); /** ----------------------------------------------------------------- * M M S E N C O D E * * -----------------------------------------------------------------*/ - static void __MmsCleanEncodeBuff(void) { memset(gpMmsEncodeBuf, 0, MSG_MMS_ENCODE_BUFFER_MAX); @@ -101,7 +110,7 @@ static void __MmsCleanEncodeBuff(void) } -void _MmsRegisterEncodeBuffer(char *pInBuff, int maxLen) +void MmsRegisterEncodeBuffer(char *pInBuff, int maxLen) { gpMmsEncodeBuf = pInBuff; gCurMmsEncodeBuffPos = 0; @@ -109,7 +118,7 @@ void _MmsRegisterEncodeBuffer(char *pInBuff, int maxLen) gMmsEncodeCurOffset = 0; } -void _MmsUnregisterEncodeBuffer(void) +void MmsUnregisterEncodeBuffer(void) { gpMmsEncodeBuf = NULL; gCurMmsEncodeBuffPos = 0; @@ -117,53 +126,42 @@ void _MmsUnregisterEncodeBuffer(void) gMmsEncodeCurOffset = 0; } -int _MmsGetEncodeOffset(void) +static int __MmsGetEncodeOffset(void) { return (gMmsEncodeCurOffset + gCurMmsEncodeBuffPos); } - -bool _MmsEncodeMsg(void) -{ - MSG_DEBUG("_MmsEncodeMsg: Start Binary Encoding now ============= \n"); - return true; -} - - -bool _MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg) +bool MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg) { return __MmsEncodeSendReq(pFile, pMsg, true); } - -bool _MmsEncodeTemplate(FILE *pFile, MmsMsg *pMsg) +bool MmsEncodeTemplate(FILE *pFile, MmsMsg *pMsg) { return __MmsEncodeSendReq(pFile, pMsg, false); } - static bool __MmsEncodeSendReq(FILE* pFile, MmsMsg* pMsg, bool bIncludeSendReqHeader) { - _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); + MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); if (bIncludeSendReqHeader) { - if (_MmsBinaryEncodeSendReqHdr(pFile, pMsg) == false) { - _MmsUnregisterEncodeBuffer(); + if (__MmsBinaryEncodeSendReqHdr(pFile, pMsg) == false) { + MmsUnregisterEncodeBuffer(); return false; } } - if (MmsBinaryEncodeMsgBody(pFile, &pMsg->msgType, &pMsg->msgBody, pMsg->nPartCount, !bIncludeSendReqHeader) == false) { - _MmsUnregisterEncodeBuffer(); + if (__MmsBinaryEncodeMsgBody(pFile, &pMsg->msgType, &pMsg->msgBody, pMsg->nPartCount, !bIncludeSendReqHeader) == false) { + MmsUnregisterEncodeBuffer(); return false; } - _MmsUnregisterEncodeBuffer(); + MmsUnregisterEncodeBuffer(); return true; } - /* Functions for Acknowledge.ind & NotifyResp.ind ------------------------ */ static void __MmsCleanEncodeBuff2(void) @@ -172,8 +170,7 @@ static void __MmsCleanEncodeBuff2(void) gCurMmsEncodeBuffPos2 = 0; } - -void _MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen) +static void __MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen) { gpMmsEncodeBuf2 = pInBuff; gCurMmsEncodeBuffPos2 = 0; @@ -181,7 +178,7 @@ void _MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen) gMmsEncodeCurOffset2 = 0; } -void _MmsUnregisterEncodeBuffer2(void) +static void __MmsUnregisterEncodeBuffer2(void) { gpMmsEncodeBuf2 = NULL; gCurMmsEncodeBuffPos2 = 0; @@ -189,17 +186,14 @@ void _MmsUnregisterEncodeBuffer2(void) gMmsEncodeCurOffset2 = 0; } - /** * @param source [in] originam string * @param length [in] gotten from MmsBinaryEncodeTextStringLen() * @param dest [in] buffer to store quted string * @return changed string length */ -static bool MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length) +static bool __MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length) { - MSG_DEBUG("MmsBinaryEncodeTextString2: \n"); - /** * make text string * Text-string = [Quote] *TEXT End-of-string @@ -210,14 +204,14 @@ static bool MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length) */ if (pFile == NULL || source == NULL) { - MSG_DEBUG("MmsBinaryEncodeTextString2: source == NULL \n"); + MSG_DEBUG("source == NULL"); goto __CATCH; } if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < length) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2, gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) { - MSG_DEBUG("MmsBinaryEncodeTextString2: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } @@ -237,24 +231,23 @@ __CATCH: return false; } - static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue) { if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < 2) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2, gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) { - MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } if (fieldCode == 0xff) { - MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: invalid fieldCode \n"); + MSG_DEBUG("invalid fieldCode"); goto __CATCH; } if (fieldValue == 0xff) { - MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: invalid fieldValue \n"); + MSG_DEBUG("invalid fieldValue"); return true; } @@ -267,33 +260,25 @@ __CATCH: return false; } - static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile) { UINT8 majorVer = MMS_MAJOR_VERSION; UINT8 minorVer = MMS_MINOR_VERSION; - MSG_DEBUG("__MmsBinaryEncodeMmsVersion2: \n"); - if (pFile == NULL) { - MSG_DEBUG("__MmsBinaryEncodeMmsVersion2: invalid input file \n"); - goto __CATCH; - } - - if (majorVer < 1) { - MSG_DEBUG("__MmsBinaryEncodeMmsVersion2: invalid major version (%d)\n", majorVer); + MSG_DEBUG("invalid input file"); goto __CATCH; } if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < 2) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2, gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) { - MSG_DEBUG("__MmsBinaryEncodeMmsVersion2: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80; + gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80; gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2] = (majorVer << 4) | (minorVer & 0x0f) | MSB; if (gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2] < 0x80) { @@ -308,73 +293,72 @@ __CATCH: return false; } - -bool _MmsBinaryEncodeAckIndHdr(FILE *pFile, char *szTrID, bool bReportAllowed) +static bool __MmsBinaryEncodeAckIndHdr(FILE *pFile, char *szTrID, bool bReportAllowed) { int length = 0; UINT8 fieldCode = 0xff; UINT8 fieldValue = 0xff; - MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: szTrID = %s\n", szTrID); - MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: bReportAllowed = %d\n", bReportAllowed); + MSG_DEBUG("szTrID = %s", szTrID); + MSG_DEBUG("bReportAllowed = %d", bReportAllowed); __MmsCleanEncodeBuff2(); /* msgType */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_ACKNOWLEDGE_IND) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_ACKNOWLEDGE_IND) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: msgType error\n"); + MSG_DEBUG("msgType error"); goto __CATCH; } /* trID (other type of message) */ - length = MmsBinaryEncodeTextStringLen((UINT8*)szTrID); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szTrID); if (length == -1) { - MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < (length + 1)) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2, gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) { - MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80; + gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80; - if (MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) { - MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: MmsBinaryEncodeTextString fail\n"); + if (__MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) { + MSG_DEBUG("MmsBinaryEncodeTextString fail"); goto __CATCH; } if (__MmsBinaryEncodeMmsVersion2(pFile) == false) { - MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: __MmsBinaryEncodeMmsVersion error\n"); + MSG_DEBUG("__MmsBinaryEncodeMmsVersion error"); goto __CATCH; } /* Report Allowed */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80; if (bReportAllowed) { - fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80; } else { - fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80; } if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: Report Allowed error\n"); + MSG_DEBUG("Report Allowed error"); goto __CATCH; } /* flush remained data on encoding file */ if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2, gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) { - MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: remained data MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("remained data MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } @@ -385,89 +369,87 @@ __CATCH: return false; } - - -bool _MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed) +static bool __MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed) { int length = 0; UINT8 fieldCode = 0xff; UINT8 fieldValue = 0xff; - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: szTrID = %s\n", szTrID); - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: iStatus = %d\n", iStatus); - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: bReportAllowed = %d\n", bReportAllowed); + MSG_DEBUG("szTrID = %s", szTrID); + MSG_DEBUG("iStatus = %d", iStatus); + MSG_DEBUG("bReportAllowed = %d", bReportAllowed); __MmsCleanEncodeBuff2(); /* msgType */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_NOTIFYRESP_IND) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_NOTIFYRESP_IND) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: msgType error\n"); + MSG_DEBUG("msgType error"); goto __CATCH; } /* trID (other type of message) */ - length = MmsBinaryEncodeTextStringLen((UINT8*)szTrID); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szTrID); if (length == -1) { - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < (length + 1)) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2, gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) { - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80; - if (MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) { - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MmsBinaryEncodeTextString fail\n"); + gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80; + if (__MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) { + MSG_DEBUG("MmsBinaryEncodeTextString fail"); goto __CATCH; } if (__MmsBinaryEncodeMmsVersion2(pFile) == false) { - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: __MmsBinaryEncodeMmsVersion error\n"); + MSG_DEBUG("__MmsBinaryEncodeMmsVersion error"); goto __CATCH; } /* MsgStatus */ - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MsgStatus = %d\n", iStatus); + MSG_DEBUG("MsgStatus = %d", iStatus); if (iStatus != MSG_DELIVERY_REPORT_NONE) { - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGSTATUS) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeMsgStatus, iStatus) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGSTATUS) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeMsgStatus, iStatus) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MsgStatus error\n"); + MSG_DEBUG("MsgStatus error"); goto __CATCH; } } /* Report Allowed */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80; if (bReportAllowed) { - fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80; } else { - fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80; } if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: Report Allowed error\n"); + MSG_DEBUG("Report Allowed error"); goto __CATCH; } /* flush remained data on encoding file */ if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2, gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) { - MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: remained data MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("remained data MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } @@ -478,44 +460,41 @@ __CATCH: return false; } - -bool _MmsEncodeAckInd(FILE *pFile, char *pTrID, bool bReportAllowed) +bool MmsEncodeAckInd(FILE *pFile, char *pTrID, bool bReportAllowed) { - _MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX); + __MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX); - MSG_DEBUG("_MmsEncodeAckInd: Start Binary Encoding now ============= \n"); + MSG_DEBUG("Start Binary Encoding now ============="); - if (_MmsBinaryEncodeAckIndHdr(pFile, pTrID, bReportAllowed) == false) { - MSG_DEBUG("_MmsEncodeAckInd: SendReq Binary encoding fail \n"); + if (__MmsBinaryEncodeAckIndHdr(pFile, pTrID, bReportAllowed) == false) { + MSG_DEBUG("SendReq Binary encoding fail"); goto __CATCH; } - _MmsUnregisterEncodeBuffer2(); + __MmsUnregisterEncodeBuffer2(); return true; __CATCH: - MSG_DEBUG("## _MmsEncodeAckInd: failed"); - _MmsUnregisterEncodeBuffer2(); + MSG_DEBUG("Failed"); + __MmsUnregisterEncodeBuffer2(); return false; } - - -bool _MmsEncodeNotiRespInd(FILE *pFile, char *pTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed) +bool MmsEncodeNotiRespInd(FILE *pFile, char *pTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed) { - _MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX); + __MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX); - MSG_DEBUG("_MmsEncodeNotiRespInd: Start Binary Encoding now ============= \n"); + MSG_DEBUG("Start Binary Encoding now ============="); - if (_MmsBinaryEncodeNotiRespIndHdr(pFile, pTrID, iStatus, bReportAllowed) == false) { - MSG_DEBUG("_MmsEncodeNotiRespInd: SendReq Binary encoding fail \n"); + if (__MmsBinaryEncodeNotiRespIndHdr(pFile, pTrID, iStatus, bReportAllowed) == false) { + MSG_DEBUG("SendReq Binary encoding fail"); goto __CATCH; } - _MmsUnregisterEncodeBuffer2(); + __MmsUnregisterEncodeBuffer2(); return true; @@ -524,45 +503,45 @@ __CATCH: return false; } - /* Functions for Acknowledge.ind & NotifyResp.ind (END) ------------------------ */ -bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus) +bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus) { char *pText = NULL; MsgMultipart *pPart = NULL; MsgType msgType; - MsgBody msgBody; + + MsgBody *msgBody = NULL; + unique_ptr buf(&msgBody, unique_ptr_deleter); + msgBody = (MsgBody *)new char[sizeof(MsgBody)]; + memset(msgBody, 0x00, sizeof(MsgBody)); char *pszReportMsg = NULL; - int maxLen = 0; + int maxLen = 0; - struct tm *dateTime = NULL; - time_t RawTime = 0; - time_t dateSec = 0; + struct tm dateTime; + time_t RawTime = 0; - _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); + MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); - MSG_DEBUG("_MmsEncodeMsg: Start Binary Encoding now V1.0============= \n"); + MSG_DEBUG("Start Binary Encoding now V1.0============="); - if (_MmsBinaryEncodeReadReport10Hdr(pFile, pMsg, mmsReadStatus) == false) { - MSG_DEBUG("_MmsEncodeReadReport10: SendReq Binary encoding fail \n"); + if (__MmsBinaryEncodeReadReport10Hdr(pFile, pMsg, mmsReadStatus) == false) { + MSG_DEBUG("SendReq Binary encoding fail"); goto __CATCH; } memset(&msgType, 0, sizeof(MsgType)); - memset(&msgBody, 0, sizeof(MsgBody)); - pText = (char *)malloc(MSG_STDSTR_LONG); + pText = (char *)calloc(1, MSG_STDSTR_LONG); if (pText == NULL) { - MSG_DEBUG("__MmsSendReadReportV10: text body malloc fail \n"); + MSG_DEBUG("text body calloc fail"); goto __CATCH; } memset(pText, 0, MSG_STDSTR_LONG); time(&RawTime); - dateTime = localtime(&RawTime); - dateSec = mktime(dateTime); + localtime_r(&RawTime, &dateTime); // get report message if (mmsReadStatus == MSG_READ_REPORT_IS_DELETED) { @@ -575,10 +554,10 @@ bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t maxLen = strlen (pszReportMsg) +16 /* date string */ + 8 /* enter chars */ ; if (maxLen > MSG_STDSTR_LONG) { - snprintf (pText, MSG_STDSTR_LONG, "%s\n", pszReportMsg); + snprintf (pText, MSG_STDSTR_LONG, "%s", pszReportMsg); } else { snprintf(pText, MSG_STDSTR_LONG, "%s\r\n\r\n%.4d/%.2d/%.2d %.2d:%.2d\r\n", - pszReportMsg, dateTime->tm_year+1900, dateTime->tm_mon+1, dateTime->tm_mday, dateTime->tm_hour, dateTime->tm_min); + pszReportMsg, dateTime.tm_year+1900, dateTime.tm_mon+1, dateTime.tm_mday, dateTime.tm_hour, dateTime.tm_min); } // make header @@ -588,7 +567,7 @@ bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t // make body if ((pPart = MmsAllocMultipart()) == NULL) { - MSG_DEBUG("__MmsSendReadReportV10: MsgAllocMultipart Fail \n"); + MSG_DEBUG("MsgAllocMultipart Fail"); goto __CATCH; } @@ -598,21 +577,21 @@ bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t pPart->type.param.charset = MSG_CHARSET_UTF8; if (pPart->pBody == NULL) { - MSG_DEBUG("__MmsSendReadReportV10: pPart->pBody is NULL \n"); + MSG_DEBUG("pPart->pBody is NULL"); goto __CATCH; } pPart->pBody->size = strlen(pText); pPart->pBody->body.pText = pText; - msgBody.body.pMultipart = pPart; + msgBody->body.pMultipart = pPart; - if (MmsBinaryEncodeMsgBody(pFile, &msgType, &msgBody, 1, false) == false) { - MSG_DEBUG("__MmsSendReadReportV10: MmsBinaryEncodeMsgBody fail \n"); + if (__MmsBinaryEncodeMsgBody(pFile, &msgType, msgBody, 1, false) == false) { + MSG_DEBUG("MmsBinaryEncodeMsgBody fail"); goto __CATCH; } - MSG_DEBUG("__MmsSendReadReportV10: Send To RM ReadReport Msg \n"); + MSG_DEBUG(" Send To RM ReadReport Msg"); if (pText) { free(pText); @@ -628,7 +607,7 @@ bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t pPart = NULL; } - _MmsUnregisterEncodeBuffer(); + MmsUnregisterEncodeBuffer(); return true; @@ -648,35 +627,32 @@ __CATCH: pPart = NULL; } - _MmsUnregisterEncodeBuffer(); + MmsUnregisterEncodeBuffer(); return false; } - -bool _MmsEncodeReadReport11(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus) +bool MmsEncodeReadReport11(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus) { - _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); + MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); - MSG_DEBUG("_MmsEncodeMsg: Start Binary Encoding now V1.1============= \n"); + MSG_DEBUG("Start Binary Encoding now V1.1============="); - if (_MmsBinaryEncodeReadReport11Hdr(pFile, pMsg, mmsReadStatus) == false) { - MSG_DEBUG("_MmsEncodeMsg: SendReq Binary encoding fail \n"); + if (__MmsBinaryEncodeReadReport11Hdr(pFile, pMsg, mmsReadStatus) == false) { + MSG_DEBUG("SendReq Binary encoding fail"); goto __CATCH; } - _MmsUnregisterEncodeBuffer(); + MmsUnregisterEncodeBuffer(); return true; __CATCH: - _MmsUnregisterEncodeBuffer(); + MmsUnregisterEncodeBuffer(); return false; } - - /* ========================================================== B I N A R Y E N C O D I N G @@ -715,8 +691,7 @@ __CATCH: * | Data | | Data Length * ----------------------------- - */ - -bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg) +static bool __MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg) { UINT8 fieldCode = 0xff; UINT8 fieldValue = 0xff; @@ -725,29 +700,29 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg) __MmsCleanEncodeBuff(); /* msgType */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: msgType error\n"); + MSG_DEBUG("msgType error"); goto __CATCH; } + MSG_SEC_INFO("X-Mms-Message-Type = [%s]", MmsDebugGetMsgType(MMS_MSGTYPE_SEND_REQ)); + /* trID (other type of message) */ if (__MmsBinaryEncodeTrID(pFile, pMsg->szTrID, MMS_TR_ID_LEN + 1) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: trID error\n"); + MSG_DEBUG("trID error"); goto __CATCH; } - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: pMsg->szTrID = %s\n", pMsg->szTrID); - if (__MmsBinaryEncodeMmsVersion(pFile) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: __MmsBinaryEncodeMmsVersion error\n"); + MSG_DEBUG("__MmsBinaryEncodeMmsVersion error"); goto __CATCH; } /* From : Insert Token mode */ if (__MmsBinaryEncodeFrom(pFile) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: __MmsBinaryEncodeFrom fail\n"); + MSG_DEBUG("__MmsBinaryEncodeFrom fail"); goto __CATCH; } @@ -755,143 +730,145 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg) /* To = Encoded-string-value */ if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, pMsg->mmsAttrib.szTo) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: To __MmsBinaryEncodeAddress fail\n"); + MSG_DEBUG("To __MmsBinaryEncodeAddress fail"); goto __CATCH; } /* Cc = Encoded-string-value */ if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_CC, pMsg->mmsAttrib.szCc) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: Cc __MmsBinaryEncodeAddress fail\n"); + MSG_DEBUG("Cc __MmsBinaryEncodeAddress fail"); goto __CATCH; } /* Bcc = Encoded-string-value */ - if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_BCC, pMsg->mmsAttrib.szBcc) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: Bcc __MmsBinaryEncodeAddress fail\n"); + MSG_DEBUG("Bcc __MmsBinaryEncodeAddress fail"); goto __CATCH; } - - MSG_DEBUG("_MmsBinaryEnocdeSendReqHdr() pMsg->mmsAttrib.szSubject =%s\n",pMsg->mmsAttrib.szSubject); + MSG_SEC_INFO("Subject = [%s]", pMsg->mmsAttrib.szSubject); /* Subject = Encoded-string-value */ if (pMsg->mmsAttrib.szSubject[0]) { - length = MmsBinaryEncodeEncodedStringLen((UINT8*)pMsg->mmsAttrib.szSubject); + length = __MmsBinaryEncodeEncodedStringLen((UINT8*)pMsg->mmsAttrib.szSubject); if (length == -1) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: subject MmsBinaryEncodeEncodedStringLen fail \n"); + MSG_DEBUG("subject MmsBinaryEncodeEncodedStringLen fail"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length + 1) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: subject MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("subject MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80; gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode; - if (MmsBinaryEncodeEncodedString(pFile, (UINT8*)pMsg->mmsAttrib.szSubject, length) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: subject MmsBinaryEncodeEncodedString fail \n"); + if (__MmsBinaryEncodeEncodedString(pFile, (UINT8*)pMsg->mmsAttrib.szSubject, length) == false) { + MSG_DEBUG("subject MmsBinaryEncodeEncodedString fail"); goto __CATCH; } } /* MMS-1.3-con-739 */ /* Msg class */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeMsgClass, (int)pMsg->mmsAttrib.msgClass) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeMsgClass, (int)pMsg->mmsAttrib.msgClass) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: msgClass error\n"); + MSG_DEBUG("msgClass error"); goto __CATCH; } + + MSG_SEC_INFO("X-Mms-Message-Class = [%s]", MmsDebugGetMsgClass(pMsg->mmsAttrib.msgClass)); + /* MMS-1.3-con-739 */ /* MMS-1.3-con-733 */ /* Date = Long-integer */ - if (!__MmsBinaryEncodeDate(pFile)) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: __MmsBinaryEncodeDate error\n"); - goto __CATCH; + if (!__MmsBinaryEncodeDate(pFile, 0)) { + MSG_DEBUG("__MmsBinaryEncodeDate error"); + goto __CATCH; } /* MMS-1.3-con-733 */ /* Expiry Time : Value-length Absolute-token Date-value */ - if (pMsg->mmsAttrib.bUseExpiryCustomTime == true) { - if (__MmsBinaryEncodeTime(pFile, MMS_CODE_EXPIRYTIME, pMsg->mmsAttrib.expiryCustomTime) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: expiryTime __MmsBinaryEncodeTime fail\n"); - goto __CATCH; - } - } else if (pMsg->mmsAttrib.expiryTime.type != MMS_TIMETYPE_NONE) { // for avoiding the creation of the expiry field in case the user selects the maximum + if (pMsg->mmsAttrib.expiryTime.type != MMS_TIMETYPE_NONE) { // for avoiding the creation of the expiry field in case the user selects the maximum if (__MmsBinaryEncodeTime(pFile, MMS_CODE_EXPIRYTIME, pMsg->mmsAttrib.expiryTime) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: expiryTime __MmsBinaryEncodeTime fail\n"); + MSG_DEBUG("expiryTime __MmsBinaryEncodeTime fail"); goto __CATCH; } + + MSG_DEBUG("X-Mms-Expiry : type = [%d], time = [%u]", pMsg->mmsAttrib.expiryTime.type, pMsg->mmsAttrib.expiryTime.time); } - /* Use Custom time for Delivery Time */ - if (pMsg->mmsAttrib.bUseDeliveryCustomTime == true) { - if (__MmsBinaryEncodeTime(pFile, MMS_CODE_DELIVERYTIME, pMsg->mmsAttrib.deliveryCustomTime) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: deliveryTime __MmsBinaryEncodeTime fail\n"); - goto __CATCH; - } - } else { + if (pMsg->mmsAttrib.deliveryTime.type != MMS_TIMETYPE_NONE) { if (__MmsBinaryEncodeTime(pFile, MMS_CODE_DELIVERYTIME, pMsg->mmsAttrib.deliveryTime) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: deliveryTime __MmsBinaryEncodeTime fail\n"); + MSG_DEBUG("deliveryTime __MmsBinaryEncodeTime fail"); goto __CATCH; } + + MSG_DEBUG("X-Mms-Delivery-Time : type = [%d], time = [%u]", pMsg->mmsAttrib.deliveryTime.type, pMsg->mmsAttrib.deliveryTime.time); } /* Priority */ if (pMsg->mmsAttrib.priority!= MMS_PRIORITY_ERROR && pMsg->mmsAttrib.priority!= MMS_PRIORITY_NORMAL) { /* MMS_PRIORITY_NORMAL is default : don't send optional field */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_PRIORITY)|0x80; - fieldValue = _MmsGetBinaryValue(MmsCodePriority, pMsg->mmsAttrib.priority)|0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_PRIORITY)|0x80; + fieldValue = MmsGetBinaryValue(MmsCodePriority, pMsg->mmsAttrib.priority)|0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: priority error\n"); + MSG_DEBUG("priority error"); goto __CATCH; } + + MSG_SEC_INFO("X-Mms-Priority = [%d]", pMsg->mmsAttrib.priority); } /* Sender Visible (hide | show) */ if (pMsg->mmsAttrib.bHideAddress == true) { - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | MSB; - fieldValue = _MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_HIDE) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | MSB; + fieldValue = MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_HIDE) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: sender visibility error\n"); + MSG_DEBUG("sender visibility error"); goto __CATCH; } } + MSG_SEC_INFO("X-Mms-Sender-Visibility = [%d]", pMsg->mmsAttrib.bHideAddress); + /* Delivery Report (yes | no) */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT)|0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT)|0x80; if (pMsg->mmsAttrib.bAskDeliveryReport) { - fieldValue = _MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_YES) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_YES) | 0x80; } else { - fieldValue = _MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80; } + MSG_SEC_INFO("X-Mms-Delivery-Report = [%d]", pMsg->mmsAttrib.bAskDeliveryReport); + if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: sender visibility error\n"); + MSG_DEBUG("sender visibility error"); goto __CATCH; } /* Read Reply (Yes | no) */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY)|0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY)|0x80; if (pMsg->mmsAttrib.bAskReadReply) { - fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_YES)|0x80; + fieldValue = MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_YES)|0x80; } else { - fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO)|0x80; + fieldValue = MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO)|0x80; } + MSG_SEC_INFO("X-Mms-Read-Report = [%d]", pMsg->mmsAttrib.bAskReadReply); + if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: read reply error\n"); + MSG_DEBUG("read reply error"); goto __CATCH; } @@ -899,59 +876,62 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg) (pMsg->mmsAttrib.replyCharge.chargeType == MMS_REPLY_REQUESTED_TEXT_ONLY)) { // reply charging - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGING)|0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, pMsg->mmsAttrib.replyCharge.chargeType)|0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGING)|0x80; + fieldValue = MmsGetBinaryValue(MmsCodeReadReply, pMsg->mmsAttrib.replyCharge.chargeType)|0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: replyCharging error\n"); + MSG_DEBUG("replyCharging error"); 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"); + MSG_DEBUG("replyCharging __MmsBinaryEncodeTime fail"); goto __CATCH; } } + /** fixme: Reply-charging-size */ if (pMsg->mmsAttrib.replyCharge.chargeSize > 0) { - length = MmsBinaryEncodeIntegerLen(pMsg->mmsAttrib.replyCharge.chargeSize); + length = __MmsBinaryEncodeIntegerLen(pMsg->mmsAttrib.replyCharge.chargeSize); if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGSIZE) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGSIZE) | 0x80; - if (MmsBinaryEncodeInteger(pFile, pMsg->mmsAttrib.replyCharge.chargeSize, length) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: replyChargingSize MmsBinaryEncodeInteger error\n"); + if (__MmsBinaryEncodeInteger(pFile, pMsg->mmsAttrib.replyCharge.chargeSize, length) == false) { + MSG_DEBUG("replyChargingSize MmsBinaryEncodeInteger error"); goto __CATCH; } } + /** fixme: Reply-charging-ID ----> used only when reply message */ if (pMsg->mmsAttrib.replyCharge.szChargeID[0]) { - length = MmsBinaryEncodeTextStringLen((UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID); if (length == -1) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: szReplyChargingID MmsBinaryEncodeTextStringLen fail\n"); + MSG_DEBUG("szReplyChargingID MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGID) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGID) | 0x80; - if (MmsBinaryEncodeTextString(pFile, (UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID, length) == false) { - MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: szContentLocation MmsBinaryEncodeTextString fail\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID, length) == false) { + MSG_DEBUG("szContentLocation MmsBinaryEncodeTextString fail"); goto __CATCH; } } @@ -959,7 +939,7 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg) /* flush remained data on encoding file */ if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: remained data MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("remained data MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } @@ -967,56 +947,11 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg) __CATCH: - MSG_DEBUG("## _MmsBinaryEncodeSendReqHdr: failed"); + MSG_DEBUG("Failed"); return false; } -bool MmsBinaryEncodeSendReqHdrwithinBufRegi(FILE *pFile, MmsMsg *pMsg) -{ - bool ret = false; - - _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); - ret = _MmsBinaryEncodeSendReqHdr(pFile, pMsg); - _MmsUnregisterEncodeBuffer(); - - return ret; -} - -bool _MmsBinaryEncodeContentTypeFieldCode(FILE *pFile, int msgID) -{ - if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) { - if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, - gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("__MmsBinaryEncodeMmsVersion: MsgWriteDataFromEncodeBuffer fail \n"); - return false; - } - } - - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_CONTENTTYPE) | 0x80; - - if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: remained data MsgWriteDataFromEncodeBuffer fail \n"); - return false; - } - - return true; -} - -bool MmsBinaryEncodeSendReqHdrContTypeFildCode(FILE *pFile, int msgID) -{ - bool ret = false; - - _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); - - ret = _MmsBinaryEncodeContentTypeFieldCode(pFile, msgID); - - _MmsUnregisterEncodeBuffer(); - - - return ret; -} - -bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus) +static bool __MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus) { int length = 0; char *szTo = NULL; @@ -1029,57 +964,57 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_ goto __CATCH; } - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: mmsReadStatus = %d\n", mmsReadStatus); + MSG_DEBUG("mmsReadStatus = %d", mmsReadStatus); __MmsCleanEncodeBuff(); /* msgType */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: msgType error\n"); + MSG_DEBUG("msgType error"); goto __CATCH; } /* trID (other type of message) */ if (__MmsBinaryEncodeTrID(pFile, NULL, 0) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: __MmsBinaryEncodeTrID error\n"); + MSG_DEBUG("__MmsBinaryEncodeTrID error"); goto __CATCH; } if (__MmsBinaryEncodeMmsVersion(pFile) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: __MmsBinaryEncodeMmsVersion error\n"); + MSG_DEBUG("__MmsBinaryEncodeMmsVersion error"); goto __CATCH; } /* Date = Long-integer */ - if (!__MmsBinaryEncodeDate(pFile)) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: date __MmsBinaryEncodeDate error\n"); + if (!__MmsBinaryEncodeDate(pFile, 0)) { + MSG_DEBUG("date __MmsBinaryEncodeDate error"); goto __CATCH; } /* From : Insert Token mode */ if (__MmsBinaryEncodeFrom(pFile) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: __MmsBinaryEncodeFrom fail\n"); + MSG_DEBUG("__MmsBinaryEncodeFrom fail"); goto __CATCH; } - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To = %s\n", pMsg->mmsAttrib.szFrom); + MSG_DEBUG("To = %s", pMsg->mmsAttrib.szFrom); /* To = Encoded-string */ if (pMsg && (strchr(pMsg->mmsAttrib.szFrom, '/') == NULL)) { length = strlen(pMsg->mmsAttrib.szFrom); - szTo = (char *)malloc(length + 11); + szTo = (char *)calloc(1, length + 11); if (szTo == NULL) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: szTo alloc fail\n"); + MSG_DEBUG("szTo alloc fail"); goto __CATCH; } snprintf(szTo, length + 11, "%s/TYPE=PLMN", pMsg->mmsAttrib.szFrom); - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To = %s\n", szTo); + MSG_DEBUG("To = %s", szTo); if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, szTo) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To __MmsBinaryEncodeAddress fail\n"); + MSG_DEBUG("To __MmsBinaryEncodeAddress fail"); goto __CATCH; } @@ -1089,7 +1024,7 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_ } } else { if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, pMsg->mmsAttrib.szFrom) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To __MmsBinaryEncodeAddress fail\n"); + MSG_DEBUG("To __MmsBinaryEncodeAddress fail"); goto __CATCH; } } @@ -1110,65 +1045,69 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_ } } - length = MmsBinaryEncodeEncodedStringLen((UINT8*)szSubject); + length = __MmsBinaryEncodeEncodedStringLen((UINT8*)szSubject); if (length == -1) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: subject MmsBinaryEncodeEncodedStringLen fail \n"); + MSG_DEBUG("subject MmsBinaryEncodeEncodedStringLen fail"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length + 1) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: subject MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("subject MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80; gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode; - if (MmsBinaryEncodeEncodedString(pFile, (UINT8*)szSubject, length) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: subject MmsBinaryEncodeEncodedString fail \n"); + if (__MmsBinaryEncodeEncodedString(pFile, (UINT8*)szSubject, length) == false) { + MSG_DEBUG("subject MmsBinaryEncodeEncodedString fail"); goto __CATCH; } /* Msg class */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeMsgClass, MMS_MSGCLASS_AUTO) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeMsgClass, MMS_MSGCLASS_AUTO) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: msgClass error\n"); + MSG_DEBUG("msgClass error"); goto __CATCH; } /* Delivery Report (yes | no) */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: Delivery Report error\n"); + MSG_DEBUG("Delivery Report error"); goto __CATCH; } /* Read Reply (Yes | no) */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: Read Reply error\n"); + MSG_DEBUG("Read Reply error"); goto __CATCH; } /* Sender Visible (hide | show) */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_SHOW) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_SHOW) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: Sender Visible error\n"); + MSG_DEBUG("Sender Visible error"); goto __CATCH; } + /* fixme: MimeType */ + /* fixme: msgHeader */ + /* fixme: msgBody */ + /* flush remained data on encoding file */ if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: remained data MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("remained data MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } @@ -1183,9 +1122,7 @@ __CATCH: return false; } - - -bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus) +static bool __MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus) { UINT8 fieldCode = 0xff; UINT8 fieldValue = 0xff; @@ -1194,16 +1131,16 @@ bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_ __MmsCleanEncodeBuff(); /* msgType */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_READREC_IND) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_READREC_IND) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: msgType error\n"); + MSG_DEBUG("msgType error"); goto __CATCH; } /* MMS version */ if (__MmsBinaryEncodeMmsVersion(pFile) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: __MmsBinaryEncodeMmsVersion error\n"); + MSG_DEBUG("__MmsBinaryEncodeMmsVersion error"); goto __CATCH; } @@ -1214,18 +1151,18 @@ bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_ if (strchr(pMsg->mmsAttrib.szFrom, '/') == NULL) { int length = 0; length = strlen(pMsg->mmsAttrib.szFrom); - szTo = (char *)malloc(length + 11); + szTo = (char *)calloc(1, length + 11); if (szTo == NULL) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: szTo alloc fail\n"); + MSG_DEBUG("szTo alloc fail"); goto __CATCH; } snprintf(szTo, length + 11,"%s/TYPE=PLMN", pMsg->mmsAttrib.szFrom); - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To = %s\n", szTo); + MSG_DEBUG("To = %s", szTo); if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, szTo) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: To __MmsBinaryEncodeAddress fail\n"); + MSG_DEBUG("To __MmsBinaryEncodeAddress fail"); goto __CATCH; } @@ -1235,35 +1172,35 @@ bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_ } } else { if (__MmsBinaryEncodeAddress(pFile, MMS_CODE_TO, pMsg->mmsAttrib.szFrom) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: To __MmsBinaryEncodeAddress fail\n"); + MSG_DEBUG("To __MmsBinaryEncodeAddress fail"); goto __CATCH; } } /* From : Insert Token mode */ if (__MmsBinaryEncodeFrom(pFile) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: __MmsBinaryEncodeFrom fail\n"); + MSG_DEBUG("__MmsBinaryEncodeFrom fail"); goto __CATCH; } /* Date = Long-integer */ - if (!__MmsBinaryEncodeDate(pFile)) { - MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: __MmsBinaryEncodeDate error\n"); + if (!__MmsBinaryEncodeDate(pFile, 0)) { + MSG_DEBUG("__MmsBinaryEncodeDate error"); goto __CATCH; } /* Read Status (Yes | no) */ - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READSTATUS) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeReadStatus, mmsReadStatus) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READSTATUS) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeReadStatus, mmsReadStatus) | 0x80; if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: Read Status error\n"); + MSG_DEBUG("Read Status error"); goto __CATCH; }; if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: remained data MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("remained data MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } @@ -1278,15 +1215,16 @@ __CATCH: return false; } -bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate) +static bool __MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate) { int length = 0; + int index = 0; MsgMultipart *pMultipart = NULL; - MSG_DEBUG("MmsBinaryEncodeMsgBody: nPartCount = %d\n", nPartCount); + MSG_DEBUG("nPartCount = %d", nPartCount); if (pFile == NULL || pType == NULL) { - MSG_DEBUG("MmsBinaryEncodeMsgBody: invalid file handle\n"); + MSG_DEBUG("invalid file handle"); goto __CATCH; } @@ -1297,23 +1235,23 @@ bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPa * Multipart message * ---------------------------*/ - pType->offset = _MmsGetEncodeOffset(); + pType->offset = __MmsGetEncodeOffset(); /* Content type */ - length = MmsBinaryEncodeContentTypeLen(pType); + length = __MmsBinaryEncodeContentTypeLen(pType); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeMsgBody: MmsBinaryEncodeContentTypeLen fail \n"); + MSG_DEBUG("MmsBinaryEncodeContentTypeLen fail"); goto __CATCH; } if (bTemplate == false) - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_CONTENTTYPE) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_CONTENTTYPE) | 0x80; - if (MmsBinaryEncodeContentType(pFile, pType, length) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgBody: MmsBinaryEncodeContentType fail \n"); + if (__MmsBinaryEncodeContentType(pFile, pType, length) == false) { + MSG_DEBUG("MmsBinaryEncodeContentType fail"); goto __CATCH; } - pBody->offset = _MmsGetEncodeOffset(); + pBody->offset = __MmsGetEncodeOffset(); /* nEntries */ if (pBody->pPresentationBody) { @@ -1323,23 +1261,23 @@ bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPa } if (nEntries >= 0) { - length = MmsBinaryEncodeUintvarLen(nEntries); + length = __MmsBinaryEncodeUintvarLen(nEntries); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeMsgBody: nEntries MmsBinaryEncodeUintvarLen fail \n"); + MSG_DEBUG("nEntries MmsBinaryEncodeUintvarLen fail"); goto __CATCH; } - if (MmsBinaryEncodeUintvar(pFile, nEntries, length) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgBody: nEntries MmsBinaryEncodeUintvar fail \n"); + if (__MmsBinaryEncodeUintvar(pFile, nEntries, length) == false) { + MSG_DEBUG("nEntries MmsBinaryEncodeUintvar fail"); goto __CATCH; } - pType->size = _MmsGetEncodeOffset() - pType->offset; + pType->size = __MmsGetEncodeOffset() - pType->offset; } if (nEntries > 0) { if (nEntries && pBody->pPresentationBody) { - if (MmsBinaryEncodeMsgPart(pFile, pType->type, &pBody->presentationType, pBody->pPresentationBody) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgBody: __MmsBinaryEncodeMsgPart fail \n"); + if (__MmsBinaryEncodeMsgPart(pFile, pType->type, &pBody->presentationType, pBody->pPresentationBody) == false) { + MSG_DEBUG("__MmsBinaryEncodeMsgPart fail"); goto __CATCH; } @@ -1348,64 +1286,68 @@ bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPa pMultipart = pBody->body.pMultipart; while (nEntries && pMultipart) { - if (MmsBinaryEncodeMsgPart(pFile, pType->type, &pMultipart->type, pMultipart->pBody) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgBody: __MmsBinaryEncodeMsgPart fail \n"); + if (__MmsBinaryEncodeMsgPart(pFile, pType->type, &pMultipart->type, pMultipart->pBody) == false) { + MSG_DEBUG("__MmsBinaryEncodeMsgPart fail"); goto __CATCH; } + + MmsPrintMulitpart(pMultipart, index++); + pMultipart = pMultipart->pNext; nEntries--; } } else { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgBody: Empty message body MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("Empty message body MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - pBody->size = _MmsGetEncodeOffset() - pBody->offset; + pBody->size = __MmsGetEncodeOffset() - pBody->offset; } else { /* --------------------------- * Singlepart message * ---------------------------*/ - pType->offset = _MmsGetEncodeOffset(); + pType->offset = __MmsGetEncodeOffset(); - if (MmsBinaryEncodeContentHeader(pFile, (MimeType)pType->type, pType, false) == false) + if (__MmsBinaryEncodeContentHeader(pFile, (MimeType)pType->type, pType, false) == false) goto __CATCH; - length = MmsBinaryEncodeContentTypeLen(pType); + length = __MmsBinaryEncodeContentTypeLen(pType); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeMsgBody: Singlepart MmsBinaryEncodeContentTypeLen fail \n"); + MSG_DEBUG("Singlepart MmsBinaryEncodeContentTypeLen fail"); goto __CATCH; } - if (MmsBinaryEncodeContentType(pFile, pType, length) == false) + if (__MmsBinaryEncodeContentType(pFile, pType, length) == false) goto __CATCH; - pType->size = _MmsGetEncodeOffset() - pType->offset; + pType->size = __MmsGetEncodeOffset() - pType->offset; - if (MmsBinaryEncodeContentBody(pFile, pBody) == false) + if (__MmsBinaryEncodeContentBody(pFile, pBody) == false) goto __CATCH; } return true; __CATCH: - MSG_DEBUG("## MmsBinaryEncodeMsgBody: failed\n"); + MSG_DEBUG("Failed"); return false; } - -int MmsBinaryEncodeContentTypeLen(MsgType *pType) +static int __MmsBinaryEncodeContentTypeLen(MsgType *pType) { int length = 0; int totalLength = 0; UINT16 fieldValue = 0xffff; - char *szTextType = NULL; + const char *szTextType = NULL; int contentType = MIME_UNKNOWN; - MSG_DEBUG("MSmsBinaryEncodeContentTypeLen: type\n"); + bool isAscii = true; + unsigned long tmpLength = 0; + unsigned char tmpFileName[MSG_LOCALE_FILENAME_LEN_MAX+1]; /* * Content-type-value = Constrained-media | Content-general-form @@ -1421,14 +1363,14 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType) contentType = pType->type; - fieldValue = _MmsGetBinaryValue(MmsCodeContentType, contentType); + fieldValue = MmsGetBinaryValue(MmsCodeContentType, contentType); if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) { /* Extension-media type */ - szTextType = _MmsGetTextValue(MmsCodeContentType, contentType); + szTextType = MmsGetTextValue(MmsCodeContentType, contentType); if (szTextType != NULL) { - length = MmsBinaryEncodeTextStringLen((UINT8*)szTextType); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szTextType); if (length == -1) { - MSG_DEBUG("MSmsBinaryEncodeContentTypeLen: szTextType MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("szTextType MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } totalLength += length; @@ -1441,20 +1383,18 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType) /* Parameters -------------------------------------------------------------- */ - MSG_DEBUG("MSmsBinaryEncodeContentTypeLen: parameters \n\n"); - /* Well-known-charset = Any-charset | Integer-value ----------------------- */ if (pType->param.charset != MSG_CHARSET_UNKNOWN) { - fieldValue = _MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset); - length = MmsBinaryEncodeIntegerLen(fieldValue); + fieldValue = MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset); + length = __MmsBinaryEncodeIntegerLen(fieldValue); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: charSet MmsBinaryEncodeIntegerLen fail \n"); + MSG_DEBUG("charSet MmsBinaryEncodeIntegerLen fail"); goto __CATCH; } totalLength += (length + 1); } else { - if (MmsIsText(contentType)) { // Any-charset + if (MmsIsTextType(contentType)) { // Any-charset if (!MmsIsVitemContent (contentType, pType->param.szName)) totalLength += 2; } @@ -1465,79 +1405,64 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType) if (pType->param.szName[0]) { char* pszName = NULL; - - if (_MsgIsASCII (pType->param.szName)) { - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName is consisted of ascii char-set chars. \n"); - - pszName = (char *)malloc(strlen(pType->param.szName) +1); - memset(pszName, 0, (strlen(pType->param.szName)+1)); - strcpy(pszName, pType->param.szName); + if (MmsIsAsciiString (pType->param.szName)) { + MSG_DEBUG("Name is consisted of ascii char-set chars."); } else { - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName is not consisted of ascii char-set chars. \n"); - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: pType->param.szName : %s\n", pType->param.szName); - - /* if msg-server can't support non ascii, then convert non-ascii to '_' by using _MsgReplaceNonAscii*/ - int filelen = strlen(pType->param.szName); - - pszName = (char *)malloc(filelen + 1); - memset(pszName, 0, (filelen + 1)); - strncpy(pszName, pType->param.szName, filelen); - - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: pszName : %s\n", pszName); + isAscii = false; + MSG_DEBUG("Name is NOT consisted of ascii char-set chars."); } - //change empty space to '_' in the file name - if (_MsgIsSpace(pszName)) { - char *pszTempName = NULL; - - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName has space(' '). \n"); + pszName = g_strdup(pType->param.szName); - _MsgReplaceSpecialChar(pszName, &pszTempName, ' '); + //change empty space to '_' in the file name + MmsReplaceSpaceChar(pszName); - if (pszTempName) { - free(pszName); - pszName = pszTempName; + if (isAscii == false) { + if (MsgEncode2Base64(pszName, strlen(pszName), &tmpLength, tmpFileName) == true) { + g_free(pszName); + pszName = g_strdup_printf("=?UTF-8?B?%s?=", tmpFileName); + MSG_DEBUG("base64 encode filename=[%s]", pszName); } - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: pszName : %s\n", pszName); } - length = MmsBinaryEncodeTextStringLen((UINT8*)pszName); - free(pszName); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pszName); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName MmsBinaryEncodeIntegerLen fail \n"); + MSG_DEBUG("szName MmsBinaryEncodeIntegerLen fail"); goto __CATCH; } + g_free(pszName); + totalLength += (length + 1); } #ifdef FEATURE_JAVA_MMS if (pType->param.szApplicationID) { - length = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szApplicationID); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szApplicationID); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szApplicationID MmsBinaryEncodeTextStrinLen fail \n"); + MSG_DEBUG("szApplicationID MmsBinaryEncodeTextStrinLen fail"); goto __CATCH; } totalLength += (length); - if (_MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID) == UNDEFINED_BINARY) { - totalLength += strlen(_MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID)) + 1; /* NULL */ + if (MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID) == UNDEFINED_BINARY) { + totalLength += strlen(MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID)) + 1; /* NULL */ } else { totalLength++; } } if (pType->param.szReplyToApplicationID) { - length = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szReplyToApplicationID); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szReplyToApplicationID); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szApplicationID MmsBinaryEncodeTextStrinLen fail \n"); + MSG_DEBUG("szApplicationID MmsBinaryEncodeTextStrinLen fail"); goto __CATCH; } totalLength += (length); - if (_MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID) == UNDEFINED_BINARY) { - totalLength += strlen(_MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID)) + 1; /* NULL */ + if (MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID) == UNDEFINED_BINARY) { + totalLength += strlen(MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID)) + 1; /* NULL */ } else { totalLength++; } @@ -1547,14 +1472,14 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType) /* type, start, & startInfo : multipart/related only parameters -------------- */ if (contentType == MIME_MULTIPART_RELATED || contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { /* type ------------------------------------- */ - fieldValue = _MmsGetBinaryValue(MmsCodeContentType, pType->param.type); + fieldValue = MmsGetBinaryValue(MmsCodeContentType, pType->param.type); if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) { /* Extension-media type */ - szTextType = _MmsGetTextValue(MmsCodeContentType, pType->param.type); + szTextType = MmsGetTextValue(MmsCodeContentType, pType->param.type); if (szTextType != NULL) { - length = MmsBinaryEncodeTextStringLen((UINT8*)szTextType); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szTextType); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: type param MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("type param MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } totalLength += (length + 1); @@ -1568,9 +1493,9 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType) /* start = Text-string ----------------------- */ if (pType->param.szStart[0]) { /* start = Text-string */ - length = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentType: szStart MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("szStart MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } @@ -1581,9 +1506,9 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType) /* startInfo = Text-string -------------------- */ if (pType->param.szStartInfo[0]) { /* StartInfo (with multipart/related) = Text-string */ - length = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentType: szStartInfo MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("szStartInfo MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } @@ -1595,26 +1520,24 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType) __CATCH: - MSG_DEBUG("## MmsBinaryEncodeContentTypeLen: failed"); + MSG_DEBUG("Failed"); return -1; } - - -bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) +static bool __MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) { int length = 0; UINT16 fieldValue = 0xffff; - char *szTextType = NULL; + const char *szTextType = NULL; int contentType = MIME_UNKNOWN; + bool isAscii = true; + unsigned long tmpLength = 0; + unsigned char tmpFileName[MSG_LOCALE_FILENAME_LEN_MAX+1]; + #ifdef FEATURE_JAVA_MMS - char *szParameter = NULL; + const char *szParameter = NULL; #endif - - MSG_DEBUG("************************************************************************************\n"); - MSG_DEBUG("MmsBinaryEncodeContentType: C O N T E N T T Y P E \n\n"); - /* * Content-type-value = Constrained-media | Content-general-form * Constrained-media = Constrained-encoding @@ -1625,30 +1548,32 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) */ if (pFile == NULL) { - MSG_DEBUG("MmsBinaryEncodeContentType: invalid file handle\n"); + MSG_DEBUG("invalid file handle"); goto __CATCH; } /* Content-Type = Content-general-form ------------------------------- */ - length = MmsBinaryEncodeValueLengthLen(typeLength); + length = __MmsBinaryEncodeValueLengthLen(typeLength); if (length == -1) { - MSG_DEBUG("MSmsBinaryEncodeContentType : MmsBinaryEncodeValueLengthLen fail.\n"); + MSG_DEBUG("MmsBinaryEncodeValueLengthLen fail."); goto __CATCH; } - if (MmsBinaryEncodeValueLength(pFile, typeLength, length) == false) { - MSG_DEBUG("MSmsBinaryEncodeContentType : MmsBinaryEncodeValueLength fail.\n"); + if (__MmsBinaryEncodeValueLength(pFile, typeLength, length) == false) { + MSG_DEBUG("MmsBinaryEncodeValueLength fail."); goto __CATCH; } contentType = pType->type; - fieldValue = _MmsGetBinaryValue(MmsCodeContentType, (int)contentType); + MSG_SEC_DEBUG("Content Type : %s", MmsGetTextValue(MmsCodeContentType, (int)contentType)); + + fieldValue = MmsGetBinaryValue(MmsCodeContentType, (int)contentType); if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) { /* Extension-media type */ - szTextType = _MmsGetTextValue(MmsCodeContentType, (int)contentType); + szTextType = MmsGetTextValue(MmsCodeContentType, (int)contentType); if (szTextType == NULL) fieldValue = 0x00; } @@ -1656,95 +1581,77 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) if (szTextType == NULL) { gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80; } else { - length = MmsBinaryEncodeTextStringLen((UINT8*)szTextType); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szTextType); if (length == -1) { - MSG_DEBUG("MSmsBinaryEncodeContentType: szTextType MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("szTextType MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } - if (MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentType: szTextType MmsBinaryEncodeTextString fail \n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) { + MSG_DEBUG("szTextType MmsBinaryEncodeTextString fail"); goto __CATCH; } } - /* Parameters -------------------------------------------------------------- */ - - MSG_DEBUG("MmsBinaryEncodeContentType: P A R M E T E R S \n\n"); - /* Name = Text-string ------------------------------------------------------ */ - if (pType->param.szName[0]) { - char* pszName = NULL; - - if (_MsgIsASCII (pType->param.szName)) { - - MSG_DEBUG("MmsBinaryEncodeContentType: szName is consisted of ascii char-set chars. \n"); - - pszName = (char *)malloc(strlen(pType->param.szName) +1); - memset(pszName, 0, (strlen(pType->param.szName)+1)); - strcpy(pszName, pType->param.szName); + MSG_SEC_DEBUG("Parameter Name : %s", pType->param.szName); + char *pszName = NULL; + if (MmsIsAsciiString (pType->param.szName)) { + MSG_DEBUG("Name is consisted of ascii char-set chars."); } else { - MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szName is not consisted of ascii char-set chars. \n"); - - /* if msg-server can't support non ascii, then convert non-ascii to '_' by using _MsgReplaceNonAscii*/ - int filelen = strlen(pType->param.szName); - - pszName = (char *)malloc(filelen + 1); - memset(pszName, 0, (filelen + 1)); - strncpy(pszName, pType->param.szName, filelen); - - MSG_DEBUG("MmsBinaryEncodeContentType: pszName : %s\n", pszName); + isAscii = false; + MSG_DEBUG("Name is NOT consisted of ascii char-set chars."); } - //change empty space to '_' in the file name - if (_MsgIsSpace(pszName)) { - char* pszTempName = NULL; + pszName = g_strdup(pType->param.szName); - MSG_DEBUG("MmsBinaryEncodeContentType: szName has space(' '). \n"); + //change empty space to '_' in the file name + MmsReplaceSpaceChar(pszName); - _MsgReplaceSpecialChar(pszName, &pszTempName, ' '); + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_NAME) | 0x80; - if (pszTempName) { - free(pszName); - pszName = pszTempName; + if (isAscii == false) { + if (MsgEncode2Base64(pszName, strlen(pszName), &tmpLength, tmpFileName) == true) { + g_free(pszName); + pszName = g_strdup_printf("=?UTF-8?B?%s?=", tmpFileName); + MSG_DEBUG("base64 encode filename=[%s]", pszName); } - MSG_DEBUG("MmsBinaryEncodeContentType: pszName : %s\n", pszName); } - length = MmsBinaryEncodeTextStringLen((UINT8*)pszName); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pszName); + if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentType: szName MmsBinaryEncodeIntegerLen fail \n"); + MSG_DEBUG("szName MmsBinaryEncodeIntegerLen fail"); free(pszName); goto __CATCH; } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_NAME) | 0x80; - if (MmsBinaryEncodeTextString(pFile, (UINT8*)pszName, length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentType: szName MmsBinaryEncodeTextString fail\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pszName, length) == false) { + MSG_DEBUG("szName MmsBinaryEncodeTextString fail"); free(pszName); goto __CATCH; } free(pszName); } #ifdef FEATURE_JAVA_MMS - MSG_DEBUG(" MmsBinaryEncodeContentType: Application-ID \n"); /* Application-ID: Text-string */ if (pType->param.szApplicationID) { - length = MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szApplicationID); + MSG_SEC_DEBUG("Parameter Application ID : %s", pType->param.szApplicationID); + length = __MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szApplicationID); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentType: szApplicationID MmsBinaryEncodeIntegerLen Fail \n"); + MSG_DEBUG("szApplicationID MmsBinaryEncodeIntegerLen Fail"); goto __CATCH; } - fieldValue = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID); + fieldValue = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID); if (fieldValue == UNDEFINED_BINARY) - szParameter = _MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID); + szParameter = MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID); if (szParameter == NULL) { - MSG_DEBUG("MmsBinaryEncodeContentType: szParameter is NULL \n"); + MSG_DEBUG("szParameter is NULL"); goto __CATCH; } @@ -1752,8 +1659,8 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) gCurMmsEncodeBuffPos += strlen(szParameter); gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] =(UINT8)NULL; - if (MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szApplicationID, length) == false) { - MSG_DEBUG(" MmsBinaryEncodeContentType: szApplicationID MmsBinaryEncodeTextString fail\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szApplicationID, length) == false) { + MSG_DEBUG(" szApplicationID MmsBinaryEncodeTextString fail"); goto __CATCH; } @@ -1761,19 +1668,20 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) /* ReplyToApplicationID: Text-string */ if (pType->param.szReplyToApplicationID) { - length = MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szReplyToApplicationID); + MSG_SEC_DEBUG("Parameter Reply To Application-ID : %s", pType->param.szReplyToApplicationID); + length = __MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szReplyToApplicationID); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentType: szReplyToApplicationID MmsBinaryEncodeIntegerLen Fail \n"); + MSG_DEBUG("szReplyToApplicationID MmsBinaryEncodeIntegerLen Fail"); goto __CATCH; } - fieldValue = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID); + fieldValue = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID); if (fieldValue == UNDEFINED_BINARY) - szParameter = _MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID); + szParameter = MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID); if (szParameter == NULL) { - MSG_DEBUG("MmsBinaryEncodeContentType: szParameter is NULL \n"); + MSG_DEBUG("szParameter is NULL"); goto __CATCH; } @@ -1781,8 +1689,8 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) gCurMmsEncodeBuffPos += strlen(szParameter); gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] =(UINT8)NULL; - if (MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szReplyToApplicationID, length) == false) { - MSG_DEBUG(" MmsBinaryEncodeContentType: szApplicationID MmsBinaryEncodeTextString fail\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szReplyToApplicationID, length) == false) { + MSG_DEBUG("szApplicationID MmsBinaryEncodeTextString fail"); goto __CATCH; } } @@ -1791,23 +1699,24 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) /* Well-known-charset = Any-charset | Integer-value ----------------------- */ if (pType->param.charset != MSG_CHARSET_UNKNOWN) { - fieldValue = _MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset); - length = MmsBinaryEncodeIntegerLen(fieldValue); + MSG_DEBUG("Parameter Charset : %d", pType->param.charset); + fieldValue = MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset); + length = __MmsBinaryEncodeIntegerLen(fieldValue); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentType: charSet MmsBinaryEncodeIntegerLen fail \n"); + MSG_DEBUG("charSet MmsBinaryEncodeIntegerLen fail"); goto __CATCH; } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80; - if (MmsBinaryEncodeInteger(pFile, fieldValue, length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentType: charSet MmsBinaryEncodeInteger fail\n"); + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80; + if (__MmsBinaryEncodeInteger(pFile, fieldValue, length) == false) { + MSG_DEBUG("charSet MmsBinaryEncodeInteger fail"); goto __CATCH; } } else { /* Any-charset */ - if (MmsIsText(contentType)) { + if (MmsIsTextType(contentType)) { if (!MmsIsVitemContent (contentType, pType->param.szName)) { - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80; fieldValue = 0x0000; //laconic_warning, just to remove warning message gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80; } @@ -1816,45 +1725,47 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) /* type, start, & startInfo : multipart/related only parameters -------------- */ if (contentType == MIME_MULTIPART_RELATED || contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { + MSG_SEC_DEBUG("Parameter Content Type : %s", MmsGetTextValue(MmsCodeContentType, pType->param.type)); /* type ------------------------------------- */ - fieldValue = _MmsGetBinaryValue(MmsCodeContentType, pType->param.type); + fieldValue = MmsGetBinaryValue(MmsCodeContentType, pType->param.type); if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) { /* Extension-media type */ - szTextType = _MmsGetTextValue(MmsCodeContentType, pType->param.type); + szTextType = MmsGetTextValue(MmsCodeContentType, pType->param.type); if (szTextType == NULL) fieldValue = 0x00; } if (szTextType == NULL) { gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80; - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80; } else { - length = MmsBinaryEncodeTextStringLen((UINT8*)szTextType); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szTextType); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentType: type param MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("type param MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80; - if (MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentType: type param MmsBinaryEncodeTextString fail \n"); + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80; + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) { + MSG_DEBUG("type param MmsBinaryEncodeTextString fail"); goto __CATCH; } } /* 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); + MSG_DEBUG("Parameter Start: %s", pType->param.szStart); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentType: szStart MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("szStart MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_START) | 0x80; - if (MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStart, length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentType: szStart MmsBinaryEncodeTextString fail \n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStart, length) == false) { + MSG_DEBUG("szStart MmsBinaryEncodeTextString fail"); goto __CATCH; } } @@ -1862,15 +1773,16 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) /* startInfo = Text-string -------------------- */ if (pType->param.szStartInfo[0]) { /* StartInfo (with multipart/related) = Text-string */ - length = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo); + MSG_DEBUG("Parameter StartInfo: %s", pType->param.szStartInfo); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentType: szStartInfo MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("szStartInfo MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_START_INFO) | 0x80; - if (MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStartInfo, length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentType: szStartInfo MmsBinaryEncodeTextString fail \n"); + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_START_INFO) | 0x80; + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStartInfo, length) == false) { + MSG_DEBUG("szStartInfo MmsBinaryEncodeTextString fail"); goto __CATCH; } } @@ -1879,13 +1791,11 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength) return true; __CATCH: - MSG_DEBUG("## MmsBinaryEncodeContentType: failed"); + MSG_DEBUG("Failed"); return false; } - - -bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody) +static bool __MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody) { FILE *pFile2 = NULL; char *pData = NULL; @@ -1895,36 +1805,36 @@ bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBod if (pType->offset && pType->size) { /* header length & body length --------------------------- */ - length = MmsBinaryEncodeUintvarLen(pType->size); + length = __MmsBinaryEncodeUintvarLen(pType->size); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. headerLeng MmsBinaryEncodeUintvarLen fail \n"); + MSG_DEBUG("1. headerLeng MmsBinaryEncodeUintvarLen fail"); goto __CATCH; } - if (MmsBinaryEncodeUintvar(pFile, pType->size, length) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. eaderLeng fail \n"); + if (__MmsBinaryEncodeUintvar(pFile, pType->size, length) == false) { + MSG_DEBUG("1. eaderLeng fail"); goto __CATCH; } - length = MmsBinaryEncodeUintvarLen(pBody->size); + length = __MmsBinaryEncodeUintvarLen(pBody->size); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. bodyLeng MmsBinaryEncodeUintvarLen fail \n"); + MSG_DEBUG("1. bodyLeng MmsBinaryEncodeUintvarLen fail"); goto __CATCH; } - if (MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. bodyLeng fail \n"); + if (__MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) { + MSG_DEBUG("1. bodyLeng fail"); goto __CATCH; } pFile2 = MsgOpenFile(pType->szOrgFilePath, "rb"); if (pFile != NULL) { - pData = (char *)malloc(pType->size); + pData = (char *)calloc(1, pType->size); if (pData == NULL) goto __CATCH; if (MsgFseek(pFile2, pType->offset, SEEK_SET) < 0) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: MsgFseek fail \n"); + MSG_DEBUG("MsgFseek fail"); goto __CATCH; } @@ -1933,10 +1843,10 @@ bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBod if ((nRead = MsgReadFile(pData, sizeof(char), pType->size, pFile2)) == 0) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. header MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("1. header MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } - pType->offset = _MmsGetEncodeOffset(); + pType->offset = __MmsGetEncodeOffset(); if(MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) { MSG_DEBUG("MsgWriteFile failed"); goto __CATCH; @@ -1957,68 +1867,68 @@ bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBod int contentHdrLen = 0; /* header length & body length --------------------------- */ - contentTypeLen = MmsBinaryEncodeContentTypeLen(pType); - length = MmsBinaryEncodeValueLengthLen(contentTypeLen); - contentHdrLen = MmsBinaryEncodeContentHeaderLen((MimeType)contentType, pType, true); + contentTypeLen = __MmsBinaryEncodeContentTypeLen(pType); + length = __MmsBinaryEncodeValueLengthLen(contentTypeLen); + contentHdrLen = __MmsBinaryEncodeContentHeaderLen((MimeType)contentType, pType, true); if (contentTypeLen == -1 || length == -1 || contentHdrLen == -1) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: headerLeng calculation fail \n"); + MSG_DEBUG("headerLeng calculation fail"); goto __CATCH; } headerLeng = contentTypeLen + contentHdrLen + length; - length = MmsBinaryEncodeUintvarLen(headerLeng); + length = __MmsBinaryEncodeUintvarLen(headerLeng); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: headerLeng MmsBinaryEncodeUintvarLen fail \n"); + MSG_DEBUG("headerLeng MmsBinaryEncodeUintvarLen fail"); goto __CATCH; } - if (MmsBinaryEncodeUintvar(pFile, headerLeng, length) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: headerLeng fail \n"); + if (__MmsBinaryEncodeUintvar(pFile, headerLeng, length) == false) { + MSG_DEBUG("headerLeng fail"); goto __CATCH; } - length = MmsBinaryEncodeUintvarLen(pBody->size); + length = __MmsBinaryEncodeUintvarLen(pBody->size); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: bodyLeng MmsBinaryEncodeUintvarLen fail \n"); + MSG_DEBUG("bodyLeng MmsBinaryEncodeUintvarLen fail"); goto __CATCH; } - if (MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: bodyLeng fail \n"); + if (__MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) { + MSG_DEBUG("bodyLeng fail"); goto __CATCH; } if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: 2. header MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("2. header MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } /* content-type & header --------------------------- */ - pType->offset = _MmsGetEncodeOffset(); + pType->offset = __MmsGetEncodeOffset(); - if (MmsBinaryEncodeContentType(pFile, pType, contentTypeLen) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: MmsBinaryEncodeContentType fail \n"); + if (__MmsBinaryEncodeContentType(pFile, pType, contentTypeLen) == false) { + MSG_DEBUG("MmsBinaryEncodeContentType fail"); goto __CATCH; } - if (MmsBinaryEncodeContentHeader(pFile, (MsgContentType)contentType, pType, true) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: MmsBinaryEncodeContentHeader fail \n"); + if (__MmsBinaryEncodeContentHeader(pFile, (MimeType)contentType, pType, true) == false) { + MSG_DEBUG("MmsBinaryEncodeContentHeader fail"); goto __CATCH; } - pType->size = _MmsGetEncodeOffset() - pType->offset; + pType->size = __MmsGetEncodeOffset() - pType->offset; } if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: contentBody MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("contentBody MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } /* content-body --------------------------- */ - if (MmsBinaryEncodeContentBody(pFile, pBody) == false) { - MSG_DEBUG("MmsBinaryEncodeMsgPart: MmsBinaryEncodeContentBody fail \n"); + if (__MmsBinaryEncodeContentBody(pFile, pBody) == false) { + MSG_DEBUG("__MmsBinaryEncodeContentBody fail"); goto __CATCH; } @@ -2036,7 +1946,7 @@ __CATCH: pData = NULL; } - MSG_DEBUG("## MmsBinaryEncodeMsgPart: failed\n"); + MSG_DEBUG("Failed"); if (pFile2) { MsgCloseFile(pFile2); pFile2 = NULL; @@ -2045,15 +1955,11 @@ __CATCH: return false; } - -int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType, bool bMultipart) +static int __MmsBinaryEncodeContentHeaderLen(MimeType contentType, MsgType *pType, bool bMultipart) { int length = 0; int totalLength = 0; - char *szTextValue = NULL; - - - MSG_DEBUG("MmsBinaryEncodeContentHeaderLen: S T A R T \n\n"); + const char *szTextValue = NULL; /* content-id ------------------------------------------------- */ if (pType->szContentID[0]) { @@ -2061,18 +1967,18 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType, totalLength++; } else { /* content-id = Quoted-string */ - length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID"); + length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID"); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeaderLen: Content-ID MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("Content-ID MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } totalLength += length; } - length = MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID); + length = __MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentID MmsBinaryEncodeQuotedStringLen fail.\n"); + MSG_DEBUG("pType->szContentID MmsBinaryEncodeQuotedStringLen fail."); goto __CATCH; } totalLength += length; @@ -2084,18 +1990,18 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType, totalLength++; } else { /* content-location = Quoted-string */ - length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location"); + length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location"); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Location MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("Content-Location MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } totalLength += length; } - length = MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentLocation MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("pType->szContentLocation MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } @@ -2121,20 +2027,20 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType, totalLength += 3; } else { /* content-disposition = Quoted-string */ - szTextValue = _MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition); + szTextValue = MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition); if (szTextValue) { - length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition"); + length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition"); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("Content-Disposition MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } totalLength += length; - length = MmsBinaryEncodeTextStringLen((UINT8*)szTextValue); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szTextValue); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("Content-Disposition MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } totalLength += length; @@ -2145,85 +2051,87 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType, return totalLength; __CATCH: - MSG_DEBUG("## MmsBinaryEncodeContentHeadeLen: failed"); - + MSG_DEBUG("Failed"); return -1; } - - -bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgType *pType, bool bMultipart) +static bool __MmsBinaryEncodeContentHeader(FILE *pFile, MimeType contentType, MsgType *pType, bool bMultipart) { int length = 0; - char *szTextValue = NULL; - - MSG_DEBUG("MmsBinaryEncodeContentHeader: S T A R T \n\n"); + const char *szTextValue = NULL; /* content-id ------------------------------------------------- */ if (pType->szContentID[0]) { + + MSG_SEC_DEBUG("Content ID : %s", pType->szContentID); + if (bMultipart) { //Binary Encoding - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTID) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTID) | 0x80; } else { /* content-id = Quoted-string */ - length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID"); + length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID"); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-ID MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("Content-ID MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } - if (MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-ID", length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-ID MmsBinaryEncodeTextString fail.\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-ID", length) == false) { + MSG_DEBUG("Content-ID MmsBinaryEncodeTextString fail."); goto __CATCH; } } - length = MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID); + length = __MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentID MmsBinaryEncodeQuotedStringLen fail.\n"); + MSG_DEBUG("pType->szContentID MmsBinaryEncodeQuotedStringLen fail."); goto __CATCH; } - if (MmsBinaryEncodeQuotedString(pFile, (UINT8*)pType->szContentID, length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentID MmsBinaryEncodeQuotedString fail.\n"); + if (__MmsBinaryEncodeQuotedString(pFile, (UINT8*)pType->szContentID, length) == false) { + MSG_DEBUG("pType->szContentID MmsBinaryEncodeQuotedString fail."); goto __CATCH; } } if (pType->szContentLocation[0]) { + + MSG_SEC_DEBUG("Content Location : %s", pType->szContentLocation); + if (bMultipart) { //Binary Encoding - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTLOCATION) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTLOCATION) | 0x80; } else { /* content-location = Quoted-string */ - length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location"); + length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location"); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Location MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("Content-Location MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } - if (MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Location", length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Location MmsBinaryEncodeTextString fail.\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Location", length) == false) { + MSG_DEBUG("Content-Location MmsBinaryEncodeTextString fail."); goto __CATCH; } } - length = MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation); + length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentLocation MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("pType->szContentLocation MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } - if (MmsBinaryEncodeTextString(pFile, (UINT8*)pType->szContentLocation, length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentLocation MmsBinaryEncodeTextString fail.\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pType->szContentLocation, length) == false) { + MSG_DEBUG("pType->szContentLocation MmsBinaryEncodeTextString fail."); goto __CATCH; } } - /* MIME_APPLICATION_VND_WAP_MULTIPART_RELATEDrequires always "inline" */ + /* MIME_APPLICATION_VND_WAP_MULTIPART_RELATED requires always "inline" */ if (contentType != MIME_APPLICATION_VND_WAP_MULTIPART_RELATED && contentType != MIME_MULTIPART_RELATED && pType->disposition != INVALID_VALUE) { + MSG_DEBUG("Content Disposition : %d", pType->disposition); /* * Content-disposition-value = Value-length Disposition *(Parameter) * Disposition = Form-data | Attachment | Inline | Token-text @@ -2235,9 +2143,9 @@ bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgTy if (bMultipart) {//Binary Encoding UINT8 fieldValue = 0xff; - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_DISPOSITION) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_DISPOSITION) | 0x80; - fieldValue = _MmsGetBinaryValue(MmsCodeMsgDisposition, pType->disposition) | 0x80; + fieldValue = MmsGetBinaryValue(MmsCodeMsgDisposition, pType->disposition) | 0x80; if (fieldValue == 0xff) fieldValue = 0x81; @@ -2247,28 +2155,28 @@ bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgTy } else { /* content-disposition = Disposition (no support parameter) */ - szTextValue = _MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition); + szTextValue = MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition); if (szTextValue) { - length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition"); + length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition"); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("Content-Disposition MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } - if (MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Disposition", length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextString fail.\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Disposition", length) == false) { + MSG_DEBUG("Content-Disposition MmsBinaryEncodeTextString fail."); goto __CATCH; } - length = MmsBinaryEncodeTextStringLen((UINT8*)szTextValue); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szTextValue); if (length == -1) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG("Content-Disposition MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } - if (MmsBinaryEncodeTextString(pFile, (UINT8*)szTextValue, length) == false) { - MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextString fail.\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szTextValue, length) == false) { + MSG_DEBUG("Content-Disposition MmsBinaryEncodeTextString fail."); goto __CATCH; } } @@ -2278,13 +2186,11 @@ bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgTy return true; __CATCH: - MSG_DEBUG("## MmsBinaryEncodeContentHeader: failed"); + MSG_DEBUG("Failed"); return false; } - - -bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody) +static bool __MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody) { int nRead = 0; char *pData = NULL; @@ -2301,8 +2207,8 @@ bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody) if (pData == NULL) goto __CATCH; - pBody->offset = _MmsGetEncodeOffset(); - if(MsgWriteFile(pData, sizeof(char), nRead, pFile) != nRead) { + pBody->offset = __MmsGetEncodeOffset(); + if(MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) { MSG_DEBUG("MsgWriteFile failed"); goto __CATCH; } @@ -2318,8 +2224,8 @@ bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody) pData = NULL; } } else if (pBody->body.pText && pBody->size) { - pBody->offset = _MmsGetEncodeOffset(); - if (MsgWriteFile(pBody->body.pText, sizeof(char),pBody->size, pFile) != pBody->size) { + pBody->offset = __MmsGetEncodeOffset(); + if (MsgWriteFile(pBody->body.pText, sizeof(char),(size_t)pBody->size, pFile) != (size_t)pBody->size) { MSG_DEBUG("MsgWriteFile failed"); goto __CATCH; } @@ -2334,7 +2240,7 @@ bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody) return true; __CATCH: - MSG_DEBUG("## MmsBinaryEncodeContentBody: failed\n"); + MSG_DEBUG("##failed"); if (pData) { free(pData); pData = NULL; @@ -2343,15 +2249,12 @@ __CATCH: return false; } - - /* ========================================================================= B I N A R Y E N C O D I N G U T I L I T Y =========================================================================*/ - -static int MmsBinaryEncodeIntegerLen(UINT32 integer) +static int __MmsBinaryEncodeIntegerLen(UINT32 integer) { if (integer < 0x80) { /* short-integer */ @@ -2381,7 +2284,7 @@ static int MmsBinaryEncodeIntegerLen(UINT32 integer) * * @param length [in] gotten from MmsBinaryEncodeIntegerLen() */ -static bool MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length) +static bool __MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length) { union { UINT32 integer; @@ -2390,14 +2293,14 @@ static bool MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length) if (pFile == NULL) { - MSG_DEBUG("MmsBinaryEncodeInteger: source == NULL \n"); + MSG_DEBUG("source == NULL"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeInteger: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } @@ -2428,8 +2331,7 @@ __CATCH: return false; } - -static int MmsBinaryEncodeLongIntegerLen(UINT32 integer) +static int __MmsBinaryEncodeLongIntegerLen(UINT32 integer) { int length = 0; @@ -2451,13 +2353,12 @@ static int MmsBinaryEncodeLongIntegerLen(UINT32 integer) return length; } - /* * This makes value-length by specified integer value * * @param length [in] gotten from MmsBinaryEncodeIntegerLen() */ -static bool MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length) +static bool __MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length) { int i = 0; union { @@ -2472,14 +2373,14 @@ static bool MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length) */ if (pFile == NULL) { - MSG_DEBUG("MmsBinaryEncodeLongInteger: source == NULL \n"); + MSG_DEBUG("pFile == NULL"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeLongInteger: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } @@ -2500,16 +2401,12 @@ __CATCH: return false; } - - -static int MmsBinaryEncodeTextStringLen(UINT8 *source) +static int __MmsBinaryEncodeTextStringLen(UINT8 *source) { int length = 0; - MSG_DEBUG("MmsBinaryEncodeTextStringLen: \n"); - if (source == NULL) { - MSG_DEBUG("MmsBinaryEncodeTextStringLen: source == NULL \n"); + MSG_DEBUG("source == NULL"); return -1; } @@ -2523,18 +2420,14 @@ static int MmsBinaryEncodeTextStringLen(UINT8 *source) return length; } - /* * @param source [in] originam string * @param length [in] gotten from MmsBinaryEncodeTextStringLen() * @param dest [in] buffer to store quted string * @return changed string length */ -static bool MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length) +static bool __MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length) { - - MSG_DEBUG("MmsBinaryEncodeTextString: \n"); - /* * make text string * Text-string = [Quote] *TEXT End-of-string @@ -2545,14 +2438,14 @@ static bool MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length) */ if (pFile == NULL || source == NULL) { - MSG_DEBUG("MmsBinaryEncodeTextString: source == NULL \n"); + MSG_DEBUG("pFile == %p, source = %p", pFile, source); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeTextString: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } @@ -2572,8 +2465,6 @@ __CATCH: return false; } - - /* * Encode 28bit unsigned integer(Maximum) to uintvar * @@ -2585,7 +2476,7 @@ const UINT32 UINTVAR_LENGTH_2 = 0x00003fff; //14bit const UINT32 UINTVAR_LENGTH_3 = 0x001fffff; //21bit -static int MmsBinaryEncodeUintvarLen(UINT32 integer) +static int __MmsBinaryEncodeUintvarLen(UINT32 integer) { UINT32 length = 0; @@ -2607,8 +2498,7 @@ static int MmsBinaryEncodeUintvarLen(UINT32 integer) return length; } - -static bool MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length) +static bool __MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length) { const char ZERO = 0x00; int i = 2; @@ -2620,14 +2510,14 @@ static bool MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length) } source; if (pFile == NULL) { - MSG_DEBUG("MmsBinaryEncodeUintvar: pFile == INVALID_HBOJ \n"); + MSG_DEBUG("pFile == INVALID_HBOJ"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeUintvar: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } @@ -2661,29 +2551,26 @@ __CATCH: return false; } - - -static int MmsBinaryEncodeValueLengthLen(UINT32 integer) +static int __MmsBinaryEncodeValueLengthLen(UINT32 integer) { int length = 0; if (integer < 0x1f) { length = 1; } else { - length = MmsBinaryEncodeUintvarLen(integer) + 1; //LENGTH_QUOTE + length = __MmsBinaryEncodeUintvarLen(integer) + 1; //LENGTH_QUOTE } return length; } - /* * This makes value-length by specified integer value * * @param length [in] from MmsBinaryEncodeValueLengthLen() * @return encoded value-length */ -static bool MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length) +static bool __MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length) { /* * Value-length = Short-length | (Length-quote Length) @@ -2694,14 +2581,14 @@ static bool MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length) */ if (pFile == NULL) { - MSG_DEBUG("MmsBinaryEncodeValueLength: pFile == INVALID_HBOJ \n"); + MSG_DEBUG("pFile == INVALID_HBOJ"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeValueLength: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } @@ -2710,8 +2597,8 @@ static bool MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length) gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)integer; } else { gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)LENGTH_QUOTE; - if (MmsBinaryEncodeUintvar(pFile, integer, length - 1) == false) { // LENGTH_QUOTE - MSG_DEBUG("MmsBinaryEncodeValueLength: MmsBinaryEncodeUintvar fail\n"); + if (__MmsBinaryEncodeUintvar(pFile, integer, length - 1) == false) { // LENGTH_QUOTE + MSG_DEBUG("MmsBinaryEncodeUintvar fail"); goto __CATCH; } } @@ -2722,11 +2609,10 @@ __CATCH: return false; } - -static int MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc) +static int __MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc) { if (pSrc == NULL) { - MSG_DEBUG("MmsBinaryEncodeQuotedStringLen: invalid file\n"); + MSG_DEBUG("invalid file"); goto __CATCH; } @@ -2736,7 +2622,6 @@ __CATCH: return -1; } - /* * make quoted string * Quoted-string = *TEXT End-of-string @@ -2746,17 +2631,17 @@ __CATCH: * @param dest [out] buffer to store quted string * @return changed string length */ -static bool MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length) +static bool __MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length) { if (source == NULL || pFile == NULL) { - MSG_DEBUG("MmsBinaryEncodeQuotedString: invalid file\n"); + MSG_DEBUG("invalid file"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeQuotedString: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } @@ -2772,35 +2657,30 @@ __CATCH: return false; } - - -static int MmsBinaryEncodeEncodedStringLen(UINT8 *source) +static int __MmsBinaryEncodeEncodedStringLen(UINT8 *source) { UINT32 charset = 0x6A; // default = utf-8 int charLeng = 0; int textLeng = 0; int valueLengthLen = 0; - - MSG_DEBUG("MmsBinaryEncodeEncodedStringLen: \n"); - /* value-length charSet text-string */ /* Estimate charset value length and text string length */ - charLeng = MmsBinaryEncodeIntegerLen(charset); + charLeng = __MmsBinaryEncodeIntegerLen(charset); if (charLeng == -1) { - MSG_DEBUG("MmsBinaryEncodeEncodedStringLen : charLeng MmsBinaryEncodeTextStringLen fail.\n"); - goto __CATCH;; + MSG_DEBUG(" charLeng MmsBinaryEncodeTextStringLen fail."); + goto __CATCH; } - textLeng = MmsBinaryEncodeTextStringLen((UINT8*)source); + textLeng = __MmsBinaryEncodeTextStringLen((UINT8*)source); if (textLeng == -1) { - MSG_DEBUG("MmsBinaryEncodeEncodedStringLen : textLeng MmsBinaryEncodeTextStringLen fail.\n"); - goto __CATCH;; + MSG_DEBUG(" textLeng MmsBinaryEncodeTextStringLen fail."); + goto __CATCH; } - valueLengthLen = MmsBinaryEncodeValueLengthLen(charLeng + textLeng); + valueLengthLen = __MmsBinaryEncodeValueLengthLen(charLeng + textLeng); if (valueLengthLen == -1) { - MSG_DEBUG("MmsBinaryEncodeEncodedStringLen : valLengthLen MmsBinaryEncodeTextStringLen fail.\n"); + MSG_DEBUG(" valLengthLen MmsBinaryEncodeTextStringLen fail."); goto __CATCH; } @@ -2810,79 +2690,73 @@ __CATCH: return -1; } - /* * This makes value-length by specified integer value * * @param length [in] from MmsBinaryEncodeEncodedStringLen() * @return encoded encoded-string */ -static bool MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length) +static bool __MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length) { UINT32 charset = 0x6A; // default = utf-8 int charLeng = 0; int textLeng = 0; int valLengthLen = 0; - - MSG_DEBUG("MmsBinaryEncodeEncodedString: \n"); - /* value-length charSet text-string */ - if (pFile == NULL || source == NULL) { - MSG_DEBUG("MmsBinaryEncodeEncodedString: invalid input parameter\n"); + MSG_DEBUG("invalid input parameter"); goto __CATCH; } /* Estimate charset value length and text string length */ - charLeng = MmsBinaryEncodeIntegerLen(charset); + charLeng = __MmsBinaryEncodeIntegerLen(charset); if (charLeng == -1) { - MSG_DEBUG("MmsBinaryEncodeEncodedString : charLeng MmsBinaryEncodeTextStringLen fail.\n"); - goto __CATCH;; + MSG_DEBUG("charLeng MmsBinaryEncodeTextStringLen fail."); + goto __CATCH; } - textLeng = MmsBinaryEncodeTextStringLen((UINT8*)source); + textLeng = __MmsBinaryEncodeTextStringLen((UINT8*)source); if (textLeng == -1) { - MSG_DEBUG("MmsBinaryEncodeEncodedString : textLeng MmsBinaryEncodeTextStringLen fail.\n"); - goto __CATCH;; + MSG_DEBUG("textLeng MmsBinaryEncodeTextStringLen fail."); + goto __CATCH; } - valLengthLen = MmsBinaryEncodeValueLengthLen(charLeng + textLeng); + valLengthLen = __MmsBinaryEncodeValueLengthLen(charLeng + textLeng); if (valLengthLen == -1) { - MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeValueLengthLen fail.\n"); + MSG_DEBUG("MmsBinaryEncodeValueLengthLen fail."); goto __CATCH; } if (length != (charLeng + textLeng + valLengthLen)) { - MSG_DEBUG("MmsBinaryEncodeEncodedString: invalid length\n"); + MSG_DEBUG("invalid length"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("MmsBinaryEncodeEncodedString: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } /* Value length of charset value and text string */ - if (MmsBinaryEncodeValueLength(pFile, charLeng + textLeng, valLengthLen) == false) { - MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeValueLength fail.\n"); + if (__MmsBinaryEncodeValueLength(pFile, charLeng + textLeng, valLengthLen) == false) { + MSG_DEBUG("MmsBinaryEncodeValueLength fail."); goto __CATCH; } - /* Write charset on buffer -> integer value not long-integer */ - if (MmsBinaryEncodeInteger(pFile, charset, charLeng) == false) { - MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeInteger fail.\n"); + /* fixme: Write charset on buffer -> integer value not long-integer */ + if (__MmsBinaryEncodeInteger(pFile, charset, charLeng) == false) { + MSG_DEBUG("MmsBinaryEncodeInteger fail."); goto __CATCH; } - /* Write text string on buffer */ - if (MmsBinaryEncodeTextString(pFile, (UINT8*)source, textLeng) == false) { - MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeTextString fail.\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)source, textLeng) == false) { + MSG_DEBUG("MmsBinaryEncodeTextString fail."); goto __CATCH; } @@ -2892,24 +2766,23 @@ __CATCH: return false; } - static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue) { if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } if (fieldCode == 0xff) { - MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: invalid fieldCode \n"); + MSG_DEBUG("invalid fieldCode"); goto __CATCH; } if (fieldValue == 0xff) { - MSG_DEBUG("__MmsBinaryEncodeFieldCodeAndValue: invalid fieldValue \n"); + MSG_DEBUG("invalid fieldValue"); return true; } @@ -2922,49 +2795,50 @@ __CATCH: return false; } - - static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen) { int length = 0; UINT8 fieldCode = 0xff; char szBuff[MMS_TR_ID_LEN + 1] = {0, }; - struct tm *dateTime = NULL; - time_t RawTime = 0; - time_t dateSec = 0; + struct tm dateTime; + time_t RawTime = 0; + time_t dateSec = 0; time(&RawTime); - dateTime = localtime(&RawTime); - dateSec = mktime(dateTime); + localtime_r(&RawTime, &dateTime); + dateSec = mktime(&dateTime); - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80; if (fieldCode == 0xff) { - MSG_DEBUG("__MmsBinaryEncodeTrID: invalid fieldCode \n"); + MSG_DEBUG("Invalid fieldCode[0x%02x]", fieldCode & 0x7F); goto __CATCH; } - snprintf(szBuff, MMS_TR_ID_LEN + 1, "%lu.%lu", dateSec, (unsigned long)random()); - MSG_DEBUG("__MmsBinaryEncodeTrID: 2. szBuff = %s\n", szBuff); + if (szTrID && strlen(szTrID)) { + snprintf(szBuff, MMS_TR_ID_LEN + 1, "%s", szTrID); + } else { + snprintf(szBuff, MMS_TR_ID_LEN + 1, "%lu.%lu", dateSec, (unsigned long)random()); + MSG_SEC_DEBUG("Generated Transaction ID = %s", szBuff); + } - length = MmsBinaryEncodeTextStringLen((UINT8*)szBuff); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szBuff); if (length == -1) { - MSG_DEBUG("__MmsBinaryEncodeTrID: MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("__MmsBinaryEncodeTrID: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode; - if (MmsBinaryEncodeTextString(pFile, (UINT8*)szBuff, length) == false) { - MSG_DEBUG("__MmsBinaryEncodeTrID: MmsBinaryEncodeTextString fail\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szBuff, length) == false) { + MSG_DEBUG("MmsBinaryEncodeTextString fail"); goto __CATCH; } @@ -2973,6 +2847,7 @@ static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen) strncpy(szTrID, szBuff, bufLen - 1); } + MSG_SEC_INFO("X-Mms-Transaction-Id = [%s]", szBuff); return true; __CATCH: @@ -2985,31 +2860,31 @@ static bool __MmsBinaryEncodeMsgID(FILE *pFile, const char *szMsgID) int length = 0; UINT8 fieldCode = 0xff; - fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGID) | 0x80; + fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGID) | 0x80; if (fieldCode == 0xff) { - MSG_DEBUG("__MmsBinaryEncodeTrID: invalid fieldCode \n"); + MSG_DEBUG("invalid fieldCode"); goto __CATCH; } - MSG_DEBUG("__MmsBinaryEncodeMsgID: 2. szBuff = %s\n", szMsgID); + MSG_DEBUG("2. szBuff = %s", szMsgID); - length = MmsBinaryEncodeTextStringLen((UINT8*)szMsgID); + length = __MmsBinaryEncodeTextStringLen((UINT8*)szMsgID); if (length == -1) { - MSG_DEBUG("__MmsBinaryEncodeMsgID: MmsBinaryEncodeTextStringLen fail \n"); + MSG_DEBUG("MmsBinaryEncodeTextStringLen fail"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("__MmsBinaryEncodeTrID: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode; - if (MmsBinaryEncodeTextString(pFile, (UINT8*)szMsgID, length) == false) { - MSG_DEBUG("__MmsBinaryEncodeTrID: MmsBinaryEncodeTextString fail\n"); + if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szMsgID, length) == false) { + MSG_DEBUG("MmsBinaryEncodeTextString fail"); goto __CATCH; } @@ -3020,40 +2895,33 @@ __CATCH: return false; } - - static bool __MmsBinaryEncodeMmsVersion(FILE *pFile) { UINT8 majorVer = MMS_MAJOR_VERSION; UINT8 minorVer = MMS_MINOR_VERSION; - MSG_DEBUG("__MmsBinaryEncodeMmsVersion: \n"); - if (pFile == NULL) { - MSG_DEBUG("__MmsBinaryEncodeMmsVersion: invalid input file \n"); - goto __CATCH; - } - - if (majorVer < 1) { - MSG_DEBUG("__MmsBinaryEncodeMmsVersion: invalid major version (%d)\n", majorVer); + MSG_DEBUG("invalid input file"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("__MmsBinaryEncodeMmsVersion: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80; - MSG_DEBUG("__MmsBinaryEncodeMmsVersion: major version (%d)\n", majorVer); - MSG_DEBUG("__MmsBinaryEncodeMmsVersion: minor version (%d)\n", minorVer); + MSG_DEBUG("major version (%d)", majorVer); + MSG_DEBUG("minor version (%d)", minorVer); gpMmsEncodeBuf[gCurMmsEncodeBuffPos] = (majorVer << 4) | (minorVer & 0x0f) | MSB; + MSG_SEC_INFO("X-Mms-MMS-Version = [0x%02x]", gpMmsEncodeBuf[gCurMmsEncodeBuffPos]); + if (gpMmsEncodeBuf[gCurMmsEncodeBuffPos] < 0x80) { gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] |= 0x80; } else { @@ -3066,39 +2934,42 @@ __CATCH: return false; } - - -static bool __MmsBinaryEncodeDate(FILE *pFile) +static bool __MmsBinaryEncodeDate(FILE *pFile, time_t inpDateSec) { - struct tm *dateTime = NULL; - time_t dateSec = 0; + struct tm dateTime; + time_t dateSec = 0; + + if (inpDateSec > 0) + dateSec = inpDateSec; + else + dateSec = time(NULL); - dateSec = time(NULL); - dateTime = localtime(&dateSec); + localtime_r(&dateSec, &dateTime); - MSG_DEBUG("%d - %d - %d, %d : %d (SYSTEM)", dateTime->tm_year + 1900, dateTime->tm_mon + 1, dateTime->tm_mday - , dateTime->tm_hour, dateTime->tm_min); + MSG_SEC_INFO("%d - %d - %d, %d : %d (SYSTEM)", dateTime.tm_year + 1900, dateTime.tm_mon + 1, dateTime.tm_mday + , dateTime.tm_hour, dateTime.tm_min); if (dateSec > 0) { int length = 0; - length = MmsBinaryEncodeLongIntegerLen(dateSec); + length = __MmsBinaryEncodeLongIntegerLen(dateSec); if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) { // + fieldCode if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("__MmsBinaryEncodeDate: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DATE) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DATE) | 0x80; - if (MmsBinaryEncodeLongInteger(pFile, dateSec, length) == false) { - MSG_DEBUG("__MmsBinaryEncodeDate: date MmsBinaryEncodeLongInteger error\n"); + if (__MmsBinaryEncodeLongInteger(pFile, dateSec, length) == false) { + MSG_DEBUG("date MmsBinaryEncodeLongInteger error"); goto __CATCH; } + } else { - MSG_DEBUG("__MmsBinaryEncodeDate: date has a negative value (%d) \n", dateSec); + MSG_DEBUG("date has a negative value (%d)", dateSec); goto __CATCH; } return true; @@ -3107,81 +2978,87 @@ __CATCH: return false; } - - static bool __MmsBinaryEncodeFrom(FILE *pFile) { if (pFile == NULL) { - MSG_DEBUG("__MmsBinaryEncodeFrom: invalid input file \n"); + MSG_DEBUG("invalid input file"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 3) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("__MmsBinaryEncodeFrom: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_FROM) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_FROM) | 0x80; /* length of MMS_INSERT_ADDRESS_TOKEN value */ gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = 0x01; - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN) | 0x80; + + MSG_SEC_INFO("From = [INSERT_ADDRESS_TOKEN]"); return true; __CATCH: return false; } - static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char *szAddrStr) { int length = 0; if (pFile == NULL) { - MSG_DEBUG("__MmsBinaryEncodeOneAddress: invalid input file \n"); + MSG_DEBUG("invalid input file"); goto __CATCH; } /* EncodedString */ - length = MmsBinaryEncodeEncodedStringLen((UINT8*)szAddrStr); + length = __MmsBinaryEncodeEncodedStringLen((UINT8*)szAddrStr); if (length == -1) { - MSG_DEBUG("__MmsBinaryEncodeOneAddress: MmsBinaryEncodeEncodedStringLen fail \n"); + MSG_DEBUG("MmsBinaryEncodeEncodedStringLen fail"); goto __CATCH; } if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < length + 1) { if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("__MmsBinaryEncodeOneAddress: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, addrType) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, addrType) | 0x80; - if (MmsBinaryEncodeEncodedString(pFile, (UINT8*)szAddrStr, length) == false) { - MSG_DEBUG("__MmsBinaryEncodeOneAddress: MmsBinaryEncodeEncodedString fail \n"); + if (__MmsBinaryEncodeEncodedString(pFile, (UINT8*)szAddrStr, length) == false) { + MSG_DEBUG("MmsBinaryEncodeEncodedString fail"); goto __CATCH; } + if (addrType == MMS_CODE_TO ) + MSG_SEC_INFO("To = [%s]", szAddrStr); + else if (addrType == MMS_CODE_CC) + MSG_SEC_INFO("CC = [%s]", szAddrStr); + else if (addrType == MMS_CODE_BCC) + MSG_SEC_INFO("Bcc = [%s]", szAddrStr); + + return true; __CATCH: return false; } - static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *szAddr) { char *pSingleAddr = NULL; if (pFile == NULL) { - MSG_DEBUG("__MmsBinaryEncodeAddress: invalid input file \n"); + MSG_DEBUG("invalid input file"); goto __CATCH; } @@ -3195,7 +3072,7 @@ static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *s *pSingleAddr = MSG_CH_NULL; if (__MmsBinaryEncodeOneAddress(pFile, addrType, szAddr) == false) { - MSG_DEBUG("__MmsBinaryEncodeAddress: __MmsBinaryEncodeAddress fail\n"); + MSG_DEBUG("__MmsBinaryEncodeAddress fail"); goto __CATCH; } *pSingleAddr = MSG_CH_SEMICOLON; @@ -3204,7 +3081,7 @@ static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *s pSingleAddr = NULL; } else { if (__MmsBinaryEncodeOneAddress(pFile, addrType, szAddr) == false) { - MSG_DEBUG("__MmsBinaryEncodeAddress: __MmsBinaryEncodeAddress fail\n"); + MSG_DEBUG("__MmsBinaryEncodeAddress fail"); goto __CATCH; } @@ -3218,22 +3095,20 @@ __CATCH: return false; } - - static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeStruct time) { int timeLen = 0; int length = 0; if (pFile == NULL) { - MSG_DEBUG("__MmsBinaryEncodeTime: invalid input file \n"); + MSG_DEBUG("invalid input file"); goto __CATCH; } if (time.time == 0 || (fieldCode != MMS_CODE_EXPIRYTIME && fieldCode != MMS_CODE_DELIVERYTIME && fieldCode != MMS_CODE_REPLYCHARGINGDEADLINE) || (time.type != MMS_TIMETYPE_ABSOLUTE && time.type != MMS_TIMETYPE_RELATIVE)) { - MSG_DEBUG("__MmsBinaryEncodeTime: time.type = %d \n", time.type); + MSG_DEBUG("time.type = %d", time.type); return true; } @@ -3243,19 +3118,19 @@ static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeSt */ if (time.type == MMS_TIMETYPE_RELATIVE) { - timeLen = MmsBinaryEncodeIntegerLen(time.time); + timeLen = __MmsBinaryEncodeIntegerLen(time.time); } else { - timeLen = MmsBinaryEncodeLongIntegerLen(time.time); + timeLen = __MmsBinaryEncodeLongIntegerLen(time.time); } if (timeLen <= 0) { - MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeLongIntegerLen fail \n"); + MSG_DEBUG("MmsBinaryEncodeLongIntegerLen fail"); goto __CATCH; } - length = MmsBinaryEncodeValueLengthLen(timeLen + 1); //time length + time type token + length = __MmsBinaryEncodeValueLengthLen(timeLen + 1); //time length + time type token if (length == -1) { - MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeValueLengthLen fail \n"); + MSG_DEBUG("MmsBinaryEncodeValueLengthLen fail"); goto __CATCH; } @@ -3263,31 +3138,31 @@ static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeSt if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) { - MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: MsgWriteDataFromEncodeBuffer fail \n"); + MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail"); goto __CATCH; } } /* fieldCode */ - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, fieldCode) | 0x80; + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, fieldCode) | 0x80; /* value length */ - if (MmsBinaryEncodeValueLength(pFile, timeLen + 1, length) == false) { - MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeValueLength fail \n"); + if (__MmsBinaryEncodeValueLength(pFile, timeLen + 1, length) == false) { + MSG_DEBUG("MmsBinaryEncodeValueLength fail"); goto __CATCH; } /* time type & value */ if (time.type == MMS_TIMETYPE_RELATIVE) { - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_RELATIVE) | 0x80; - if (MmsBinaryEncodeInteger(pFile, time.time, timeLen) == false) { - MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeLongInteger fail \n"); + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_RELATIVE) | 0x80; + if (__MmsBinaryEncodeInteger(pFile, time.time, timeLen) == false) { + MSG_DEBUG("MmsBinaryEncodeLongInteger fail"); goto __CATCH; } } else { - gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80; - if (MmsBinaryEncodeLongInteger(pFile, time.time, timeLen) == false) { - MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeLongInteger fail \n"); + gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80; + if (__MmsBinaryEncodeLongInteger(pFile, time.time, timeLen) == false) { + MSG_DEBUG("MmsBinaryEncodeLongInteger fail"); goto __CATCH; } } @@ -3298,3 +3173,110 @@ __CATCH: return false; } +char *_MsgSkipWS3(char *s) +{ + while (true) { + if ((*s == MSG_CH_CR) || + (*s == MSG_CH_LF) || + (*s == MSG_CH_SP) || + (*s == MSG_CH_TAB)) + ++s; + else + return s; + } +} +////////////////////////////////////////////////////////////////////////////// +static bool __EncodeMmsMessage(MmsMsg *pMmsMsg, const char *raw_filepath) +{ + bool encode_ret = false; + mode_t file_mode = (S_IRUSR | S_IWUSR); + + if (pMmsMsg == NULL || raw_filepath == NULL) { + MSG_DEBUG("Invalid Parameter pMmsMsg = %p , raw_filepath = %p", pMmsMsg, raw_filepath); + return false; + } + + FILE *pFile = MsgOpenFile(raw_filepath, "wb+"); + + if (pFile == NULL) { + MSG_FATAL("File Open Error: %s", g_strerror(errno)); + goto __CATCH; + } + + if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) { + MSG_DEBUG("File Fseek Error: %s", g_strerror(errno)); + goto __CATCH; + } + + if (fchmod(fileno(pFile), file_mode) < 0) { + MSG_DEBUG("File chmod Error: %s", g_strerror(errno)); + goto __CATCH; + } + + switch(pMmsMsg->mmsAttrib.msgType) + { + case MMS_MSGTYPE_SEND_REQ: + case MMS_MSGTYPE_SEND_CONF: + encode_ret = MmsEncodeSendReq(pFile, pMmsMsg); + if (encode_ret == false) { + MSG_DEBUG("Fail to MmsEncodeSendReq"); + goto __CATCH; + } + break; + default: + MSG_DEBUG("Not Support msg type : %d", pMmsMsg->mmsAttrib.msgType); + goto __CATCH; + break; + } + + MsgFsync(pFile); //file is written to device immediately, it prevents missing file data from unexpected power off + MsgCloseFile(pFile); + + return true; + +__CATCH: + if (pFile) { + MsgCloseFile(pFile); + } + + return false; +} + +MmsPluginEncoder *MmsPluginEncoder::pInstance = NULL; + +MmsPluginEncoder *MmsPluginEncoder::instance() +{ + if (!MmsPluginEncoder::pInstance) + MmsPluginEncoder::pInstance = new MmsPluginEncoder(); + + return MmsPluginEncoder::pInstance; +} + +MmsPluginEncoder::MmsPluginEncoder(){} +MmsPluginEncoder::~MmsPluginEncoder(){} + +void MmsPluginEncoder::encodeMmsPdu(MMS_DATA_S *pMmsData, msg_message_id_t msgID, const char *pduFilePath) +{ + MmsMsg *pMmsMsg = (MmsMsg *)calloc(1, sizeof(MmsMsg)); + + if (pMmsMsg) { + if (MmsConvertMmsMsg(pMmsMsg, pMmsData) != true) { + MSG_DEBUG("Fail to Compose MMS Message"); + goto __CATCH; + } + + encodeMmsPdu(pMmsMsg, msgID, pduFilePath); + } + +__CATCH: + MmsReleaseMmsMsg(pMmsMsg); + MSG_FREE(pMmsMsg); + +} + +void MmsPluginEncoder::encodeMmsPdu(MmsMsg *pMmsMsg, msg_message_id_t msgID, const char *pduFilePath) +{ + pMmsMsg->msgID = msgID; + + __EncodeMmsMessage(pMmsMsg, pduFilePath); +} diff --git a/plugin/mms_plugin/MmsPluginEventHandler.cpp b/plugin/mms_plugin/MmsPluginEventHandler.cpp index 120ae45..15c4490 100755 --- a/plugin/mms_plugin/MmsPluginEventHandler.cpp +++ b/plugin/mms_plugin/MmsPluginEventHandler.cpp @@ -1,37 +1,29 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -#include -#include +#include +#include -#include "MsgDebug.h" -#include "MsgUtilFile.h" -#include "MsgMmsTypes.h" -#include "MsgSoundPlayer.h" -#include "MsgStorageHandler.h" -#include "MmsPluginTransport.h" +#include "MmsPluginTypes.h" +#include "MmsPluginDebug.h" #include "MmsPluginEventHandler.h" -#include "MmsPluginCodec.h" #include "MmsPluginInternal.h" -#include "MmsPluginSmil.h" -#include "MsgMmsMessage.h" - /*================================================================================================== - IMPLEMENTATION OF SmsPluginEventHandler - Member Functions + IMPLEMENTATION OF MmsPluginEventHandler - Member Functions ==================================================================================================*/ MmsPluginEventHandler *MmsPluginEventHandler::pInstance = NULL; @@ -76,12 +68,17 @@ 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 case eMMS_RETRIEVE_AUTO_CONF: case eMMS_RETRIEVE_MANUAL_CONF: + MSG_ADDRESS_INFO_S addrInfo; + memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + msgInfo.addressList = &addrInfo; + MmsPluginInternal::instance()->processRetrieveConf(&msgInfo, pRequest, pRetrievedFilePath); // callback to MSG FW @@ -92,6 +89,10 @@ void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char MmsPluginInternal::instance()->processForwardConf(&msgInfo, pRequest); break; + case eMMS_READREPORT_CONF: + if (remove(pRetrievedFilePath) != 0) + MSG_DEBUG("remove fail"); + break; default: break; } @@ -104,11 +105,16 @@ void MmsPluginEventHandler::handleMmsError(mmsTranQEntity *pRequest) msg_error_t err = MSG_SUCCESS; - MSG_MESSAGE_INFO_S msgInfo = {}; - MMS_RECV_DATA_S recvData = {{0}, }; + MSG_MESSAGE_INFO_S msgInfo; + memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); MSG_DEBUG("pRequest->msgId [%d]", pRequest->msgId); + time_t curTime; + curTime = time(NULL); + + msgInfo.displayTime = curTime; + switch (pRequest->eMmsPduType) { case eMMS_SEND_REQ: case eMMS_SEND_CONF: @@ -160,6 +166,8 @@ void MmsPluginEventHandler::handleMmsError(mmsTranQEntity *pRequest) break; } + MSG_DEBUG("Error value of MsgMmsConfIncomingListner [%d]", err); + MSG_END(); } diff --git a/plugin/mms_plugin/MmsPluginHttp.cpp b/plugin/mms_plugin/MmsPluginHttp.cpp index e38f675..3028e1c 100755 --- a/plugin/mms_plugin/MmsPluginHttp.cpp +++ b/plugin/mms_plugin/MmsPluginHttp.cpp @@ -1,43 +1,58 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#include +#include +#include +#include "MmsPluginDebug.h" #include "MmsPluginHttp.h" #include "MmsPluginUserAgent.h" -#include "stdlib.h" -#include #include "MmsPluginConnManWrapper.h" -#include - -static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *szHeaderBuffer); -static void __httpGetHost(char *szHost, int nBufferLen); -static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int ulContentLen); - -static MMS_NET_ERROR_T __httpReceiveData(void *ptr, size_t size, size_t nmemb, void *userdata); -static size_t __httpGetTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata); -static size_t __httpPostTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata); - -static int __httpCmdInitSession(MMS_PLUGIN_HTTP_DATA_S *httpConfig); -static int __httpCmdPostTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig); -static int __httpCmdGetTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig); +#include "MsgGconfWrapper.h" +#include "MmsPluginUtil.h" static void __http_print_profile(CURL *curl); +static int __http_debug_cb (CURL *input_curl, curl_infotype input_info_type, char *input_data , size_t input_size, void *input_void); + +static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int ulContentLen); +static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *szHeaderBuffer); +static void __httpGetHost(char *szUrl, char *szHost, int nBufferLen); /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ +//static int __http_progress_cb(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) +//{ +// MSG_INFO("download(%.0f/%.0f) : upload(%.0f/%.0f)", dlnow, dltotal, ulnow, ultotal); +// return 0; +//} + +static int __http_debug_cb (CURL *input_curl, curl_infotype input_info_type, char *input_data , size_t input_size, void *input_void) +{ + MSG_INFO("curl_infotype [%d] : %s", input_info_type, input_data); + return 0; +} + +static size_t __http_write_response_cb(void *ptr, size_t size, size_t nmemb, void *data) +{ + MSG_BEGIN(); + FILE *writehere = (FILE *)data; + return fwrite(ptr, size, nmemb, writehere); +} + static void __http_print_profile(CURL *curl) { double speed_upload, speed_download, total_time; @@ -55,54 +70,55 @@ static void __http_print_profile(CURL *curl) //time curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total_time); - MSG_DEBUG("profile http Time: total %.3f seconds", total_time); + MSG_SEC_INFO("profile http Time: total %.3f seconds", total_time); //url curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url); - MSG_DEBUG("profile http Url: %s", url); + MSG_SEC_INFO("profile http Url: %s", url); //size curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &size_up); - MSG_DEBUG("profile http Size: upload %.3f bytes", size_up); + MSG_SEC_INFO("profile http Size: upload %.3f bytes", size_up); curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &size_down); - MSG_DEBUG("profile http Size: download %.3f bytes", size_down); + MSG_SEC_INFO("profile http Size: download %.3f bytes", size_down); curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &size); - MSG_DEBUG("profile http Size: header %ld bytes", size); + MSG_SEC_INFO("profile http Size: header %ld bytes", size); curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &size); - MSG_DEBUG("profile http Size: request %ld bytes", size); + MSG_SEC_INFO("profile http Size: request %ld bytes", size); //speed curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed_upload); - MSG_DEBUG("profile http Speed: upload %.3f bytes/sec", speed_upload); + MSG_SEC_INFO("profile http Speed: upload %.3f bytes/sec", speed_upload); curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &speed_download); - MSG_DEBUG("profile http Speed: download %.3f bytes/sec", speed_download); + MSG_SEC_INFO("profile http Speed: download %.3f bytes/sec", speed_download); //content curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &content_type); - MSG_DEBUG("profile http Content: type %s", content_type); + MSG_SEC_INFO("profile http Content: type %s", content_type); curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &content_length); - MSG_DEBUG("profile http Content: length download %.3f", content_length); + MSG_SEC_INFO("profile http Content: length download %.3f", content_length); curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &content_length); - MSG_DEBUG("profile http Content: length upload %.3f", content_length); + MSG_SEC_INFO("profile http Content: length upload %.3f", content_length); //ip & port curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip); - MSG_DEBUG("profile http primary: ip %s", ip); + MSG_SEC_INFO("profile http primary: ip %s", ip); curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT, &port); - MSG_DEBUG("profile http primary: port %ld", port); + MSG_SEC_INFO("profile http primary: port %ld", port); curl_easy_getinfo(curl, CURLINFO_LOCAL_IP, &ip); - MSG_DEBUG("profile http local: ip %s", ip); + MSG_SEC_INFO("profile http local: ip %s", ip); curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &port); - MSG_DEBUG("profile http local: port %ld", port); + MSG_SEC_INFO("profile http local: port %ld", port); + MSG_DEBUG("**************************************************************************************************"); } @@ -111,32 +127,31 @@ 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) { - strcat(pcheader,"Content-Type: "); - strcat(pcheader, szBuffer); - MSG_DEBUG("%s", pcheader); + snprintf(pcheader, HTTP_REQUEST_LEN, "Content-Type: %s", szBuffer); + MSG_INFO("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } - memset(szBuffer, 0, 1025); - memset(pcheader, 0, HTTP_REQUEST_LEN); - snprintf(szBuffer, 1024, "%d", ulContentLen); - if (nResult) { - strcat(pcheader, "Content-Length: "); - strcat(pcheader, szBuffer); - MSG_DEBUG("%s", pcheader); - *responseHeaders = curl_slist_append(*responseHeaders, pcheader); + if (ulContentLen > 0) { + memset(szBuffer, 0, 1025); + memset(pcheader, 0, HTTP_REQUEST_LEN); + snprintf(szBuffer, 1024, "%d", ulContentLen); + if (nResult) { + snprintf(pcheader, HTTP_REQUEST_LEN, "Content-Length: %s", szBuffer); + MSG_INFO("%s", pcheader); + *responseHeaders = curl_slist_append(*responseHeaders, pcheader); + } } memset(szBuffer, 0, 1025); memset(pcheader, 0, HTTP_REQUEST_LEN); - nResult = __httpGetHeaderField(MMS_HH_HOST, szBuffer); - if (nResult) { - strcat(pcheader, "HOST: "); - strcat(pcheader, szBuffer); - MSG_DEBUG("%s", pcheader); + + __httpGetHost(szUrl, szBuffer, 1024); + if (strlen(szBuffer)){ + snprintf(pcheader, HTTP_REQUEST_LEN, "Host: %s", szBuffer); + MSG_INFO("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } @@ -144,9 +159,8 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_ACCEPT, szBuffer); if (nResult) { - strcat(pcheader, "Accept: "); - strcat(pcheader, szBuffer); - MSG_DEBUG("%s", pcheader); + snprintf(pcheader, HTTP_REQUEST_LEN, "Accept: %s", szBuffer); + MSG_INFO("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } @@ -154,9 +168,8 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_ACCEPT_CHARSET, szBuffer); if (nResult) { - strcat(pcheader, "Accept-Charset: "); - strcat(pcheader, szBuffer); - MSG_DEBUG("%s", pcheader); + snprintf(pcheader, HTTP_REQUEST_LEN, "Accept-Charset: %s", szBuffer); + MSG_INFO("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } @@ -164,41 +177,48 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_ACCEPT_LANGUAGE, szBuffer); if (nResult) { - strcat(pcheader, "Accept-Language: "); - strcat(pcheader, szBuffer); - MSG_DEBUG("%s", pcheader); + snprintf(pcheader, HTTP_REQUEST_LEN, "Accept-Language: %s", szBuffer); + MSG_INFO("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } - +/* NOW not support gzip, deflate encoding in MMS Plugin memset(szBuffer, 0, 1025); memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_ACCEPT_ENCODING, szBuffer); if (nResult) { - strcat(pcheader, "Accept-Encoding: "); - strcat(pcheader, szBuffer); + snprintf(pcheader, HTTP_REQUEST_LEN, "Accept-Encoding: %s", szBuffer); MSG_DEBUG("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } - +*/ memset(szBuffer, 0, 1025); memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_USER_AGENT, szBuffer); if (nResult) { - strcat(pcheader, "User-Agent: "); - strcat(pcheader, szBuffer); - MSG_DEBUG("%s", pcheader); + snprintf(pcheader, HTTP_REQUEST_LEN, "User-Agent: %s", szBuffer); + MSG_INFO("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } memset(szBuffer, 0, 1025); memset(pcheader, 0, HTTP_REQUEST_LEN); - nResult = __httpGetHeaderField(MMS_HH_WAP_PROFILE, szBuffer); + nResult = __httpGetHeaderField(MMS_HH_UA_PROFILE, szBuffer); if (nResult) { - strcat(pcheader, "X-wap-profile: "); - strcat(pcheader, szBuffer); - MSG_DEBUG("%s", pcheader); + snprintf(pcheader, HTTP_REQUEST_LEN, "X-wap-profile: %s", szBuffer); + MSG_INFO("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } + +#if defined(FEATURE_SMS_CDMA) + memset(szBuffer, 0, 1025); + memset(pcheader, 0, HTTP_REQUEST_LEN); + nResult = __httpGetHeaderField(MMS_HH_MDN, szBuffer); + + // TODO : if it needs to check http header mdn value, add code to below. +#endif + + if (ulContentLen > 0)//if post transaction then Disable 'Expect: 100-contine' option + *responseHeaders = curl_slist_append(*responseHeaders, "Expect:"); } static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *szHeaderBuffer) @@ -213,14 +233,6 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s result = true; break; - case MMS_HH_HOST: - __httpGetHost(szHeaderBuffer, 1024); - if (strlen(szHeaderBuffer) > 0) - result = true; - else - result = false; - break; - case MMS_HH_ACCEPT: snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_ACCEPT); result = true; @@ -243,30 +255,62 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s case MMS_HH_USER_AGENT: { - char szUserAgent[1024 + 1] = {0,}; - - memset(szUserAgent, 0x00, (sizeof(char) * (1024 + 1) )); - snprintf(szUserAgent, 1024, "%s", MSG_MMS_HH_USER_AGENT); + char szUserAgent[1024 + 1]; + char *uagent = NULL; + + uagent = MsgSettingGetString(VCONFKEY_BROWSER_USER_AGENT); + if (uagent && strlen(uagent) > 0) { + MSG_SEC_INFO("Get UserAgent : %s = %s", VCONFKEY_BROWSER_USER_AGENT, uagent); + memset(szUserAgent, 0x00, sizeof(szUserAgent)); + MmsRemoveMarkup(uagent, szUserAgent, sizeof(szUserAgent)); + } else { + memset(szUserAgent, 0x00, sizeof(szUserAgent)); + MSG_SEC_INFO("Get Default UserAgent : %s", MSG_MMS_HH_USER_AGENT); + snprintf(szUserAgent, 1024, "%s", MSG_MMS_HH_USER_AGENT); + } snprintf((char *)szHeaderBuffer, 1024, "%s", szUserAgent); + if (uagent) { + free(uagent); + uagent = NULL; + } result = true; } break; - case MMS_HH_WAP_PROFILE: + case MMS_HH_UA_PROFILE: { - char szUAProfile[1024 + 1] = {0,}; - - memset(szUAProfile, 0x00, (sizeof(char)*(1024+1) )); - snprintf(szUAProfile, 1024, "%s", MSG_MMS_WAP_PROFILE); + char *szUAProfile = MsgSettingGetString(MSG_MMS_UA_PROFILE); snprintf((char *)szHeaderBuffer, 1024, "%s", szUAProfile); + if (szUAProfile) { + free(szUAProfile); + szUAProfile = NULL; + } result = true; } break; +#if defined(FEATURE_SMS_CDMA) + case MMS_HH_MDN: +// { +// char *mdn = MsgSettingGetString(MSG_SIM_MSISDN); +// +// if (mdn != NULL && strlen(mdn) > 0) { +// result = true; +// snprintf((char *)szHeaderBuffer, 1024, "%s", mdn); +// } else { +// result = false; +// } +// if (mdn) { +// free(mdn); +// mdn = NULL; +// } +// } + break; +#endif default: - MSG_DEBUG("invalid param"); + MSG_WARN("invalid param [%d]", httpHeaderItem); break; } } @@ -274,17 +318,17 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s return result; } -static void __httpGetHost(char *szHost, int nBufferLen) +static void __httpGetHost(char *szUrl, char *szHost, int nBufferLen) { - MmsPluginHttpAgent *pHttpAgent = MmsPluginHttpAgent::instance(); - MMS_PLUGIN_HTTP_DATA_S *httpConfigData = pHttpAgent->getHttpConfigData(); + if (szUrl == NULL || szHost == NULL) + return; const char *prefixString = "http://"; - const char *delim = ":/\\=@"; + const char *delim = "/\\=@"; int prefixLength = strlen(prefixString); - char *startPtr = &httpConfigData->mmscConfig.mmscUrl[0]; + char *startPtr = szUrl; char *movePtr = NULL; MSG_DEBUG("startPtr(%s)", startPtr); @@ -319,215 +363,123 @@ static void __httpGetHost(char *szHost, int nBufferLen) } } - -static MMS_NET_ERROR_T __httpReceiveData(void *ptr, size_t size, size_t nmemb, void *userdata) +static int __http_multi_perform(void *session) { - MMS_NET_ERROR_T httpRet = eMMS_UNKNOWN; - - MmsPluginHttpAgent *pHttpAgent = MmsPluginHttpAgent::instance(); - MMS_PLUGIN_HTTP_CONTEXT_S *pMmsPlgCd = pHttpAgent->getMmsPldCd(); - long length_received = size * nmemb; - - if (length_received) { - //Save the received buffer in a safe place. - 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)); - 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, - (pMmsPlgCd->bufOffset + length_received + 1) * sizeof(unsigned char)); - 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 - if (pMmsPlgCd->final_content_buf != NULL) { - memcpy( pMmsPlgCd->final_content_buf + pMmsPlgCd->bufOffset, ptr, length_received); - MSG_DEBUG("Current g_bufOffset =%d", pMmsPlgCd->bufOffset); - /* Content Received */ - MSG_DEBUG("Total Content received PTR =%0X, Content Size =%d", pMmsPlgCd->final_content_buf, - pMmsPlgCd->bufOffset); - pMmsPlgCd->bufOffset = pMmsPlgCd->bufOffset + length_received; - httpRet = eMMS_UNKNOWN; - } - } else { - MSG_DEBUG("End of Data transfer"); - MSG_DEBUG("MmsHttpReadData Buffer Size = %d", pMmsPlgCd->bufOffset); - MSG_DEBUG("MmsHttpReadData Buffer = %s", pMmsPlgCd->final_content_buf); - - if (pMmsPlgCd->bufOffset == 0) { - /* This is applicable when - M-ReadRec.inf,M-Ack.ind, M-NotifyResp.ind posted */ - MSG_DEBUG(" Content Size is Zero"); - - if (pMmsPlgCd->final_content_buf != NULL) { - free(pMmsPlgCd->final_content_buf ); - pMmsPlgCd->final_content_buf = NULL; - } - - httpRet = eMMS_HTTP_EVENT_SENT_ACK_COMPLETED; - } else if (pMmsPlgCd->final_content_buf != NULL && pMmsPlgCd->bufOffset != 0) { - // Process Http Data - MSG_DEBUG(" Send Received Data to UA"); - httpRet = eMMS_HTTP_RECV_DATA; // eMMS_HTTP_RECV_DATA; - } else { - httpRet = eMMS_UNKNOWN; // check later - } - - return httpRet; - } - - return httpRet; -} - - -static size_t __httpPostTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata) -{ - MSG_DEBUG(" ====== HTTP_EVENT_SENT ========"); - long length_received = size * nmemb; - __httpReceiveData(ptr, size, nmemb, userdata); - - return length_received; -} - -static size_t __httpGetTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata) -{ - MSG_DEBUG(" ====== HTTP_EVENT_RECEIVED ========"); - long length_received = size * nmemb; - __httpReceiveData(ptr, size, nmemb, userdata); - - return length_received; -} - -static int __httpCmdInitSession(MMS_PLUGIN_HTTP_DATA_S *httpConfig) -{ - MSG_DEBUG("HttpCmd Init Session"); - - char proxyAddr[MAX_IPV4_LENGTH + 1] = {0}; - - snprintf(proxyAddr, MAX_IPV4_LENGTH + 1, "%s:%d", httpConfig->mmscConfig.httpProxyIpAddr, httpConfig->mmscConfig.proxyPortNo); - MSG_DEBUG("profileId [%d], proxyAddr [%s]", httpConfig->currentProfileId, proxyAddr); - - CURL *curl_session = curl_easy_init(); - if (NULL == curl_session) { - MSG_DEBUG("curl_easy_init() failed"); - return eMMS_HTTP_SESSION_OPEN_FAILED; - } - - int curl_status = curl_easy_setopt(curl_session, CURLOPT_PROXY, proxyAddr); - if (curl_status != CURLM_OK) { - MSG_DEBUG("curl_easy_setopt(): CURLOPT_PROXY failed"); - curl_easy_cleanup(curl_session); - return eMMS_HTTP_SESSION_OPEN_FAILED; - } - - httpConfig->session = curl_session; - - return eMMS_HTTP_SESSION_INIT; -} - - -static int __httpCmdPostTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig) -{ - int trId; - - MSG_DEBUG("HttpCmd Post Transaction"); - MSG_DEBUG(" === HTTP Agent Thread : Signal ==> eMMS_HTTP_SIGNAL_POST_TRANSACTION"); + MSG_BEGIN(); - char deviceName[1024] = {0,}; + CURLM *multi_handle; + CURLMcode rcm; - MmsPluginCmAgent::instance()->getDeviceName(deviceName); + int still_running; + int ret = 0; + bool connection_open_flag = false; - MSG_DEBUG("deviceName: [%s]", deviceName); - int curl_status = curl_easy_setopt(httpConfig->session, CURLOPT_INTERFACE, deviceName); + CURLMsg *msg; + int msgs_left; - if (curl_status != CURLM_OK) { - MSG_DEBUG("curl_easy_setopt(): CURLOPT_INTERFACE failed"); + multi_handle = curl_multi_init(); - return eMMS_EXCEPTIONAL_ERROR; + if (curl_multi_add_handle(multi_handle, session) != 0) { + MSG_ERR("curl_multi_add_handle is failed"); + curl_multi_cleanup(multi_handle); + return -1; } - CURLcode rc = curl_easy_perform(httpConfig->session); - - __http_print_profile(httpConfig->session); + /* we start some action by calling perform right away */ + rcm = curl_multi_perform(multi_handle, &still_running); + MSG_INFO("curl_multi_perform first end : rcm = %d, still_running = %d", rcm, still_running); - MmsPluginHttpAgent* httpAgent = MmsPluginHttpAgent::instance(); - MMS_PLUGIN_HTTP_DATA_S *httpConfigData = httpAgent->getHttpConfigData(); - if (httpConfigData->sessionHeader) { - curl_slist_free_all((curl_slist *)httpConfigData->sessionHeader); - httpConfigData->sessionHeader = NULL; - } - - if (CURLE_OK != rc) { - MSG_DEBUG("curl_easy_perform return error rc[%d]", rc); + do { + struct timeval timeout; + int rc; /* select() return code */ - return eMMS_HTTP_ERROR_NETWORK; - } + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + int maxfd = -1; - MSG_DEBUG("## End Transaction ##"); - MSG_DEBUG("############ trID = %d ###########", trId); +// long curl_timeo = -1; - srandom((unsigned int) time(NULL)); - trId = random() % 1000000000 + 1; + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); - httpConfig->transactionId = trId; + /* set a suitable timeout to play around with */ + timeout.tv_sec = 120; + timeout.tv_usec = 0; - return eMMS_HTTP_SENT_SUCCESS; -} +// curl_multi_timeout(multi_handle, &curl_timeo); +// if(curl_timeo >= 0) { +// MSG_DEBUG("curl_timeo = %ld", curl_timeo); +// timeout.tv_sec = curl_timeo / 1000; +// if(timeout.tv_sec > 1) +// timeout.tv_sec = 1; +// else +// timeout.tv_usec = (curl_timeo % 1000) * 1000; +// } -static int __httpCmdGetTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig) -{ - int trId; + curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); - MSG_DEBUG("HttpCmd Get Transaction"); - MSG_DEBUG(" === HTTP Agent Thread : Signal ==> eMMS_HTTP_SIGNAL_GET_TRANSACTION"); + /* In a real-world program you OF COURSE check the return code of the + function calls. On success, the value of maxfd is guaranteed to be + greater or equal than -1. We call select(maxfd + 1, ...), specially in + case of (maxfd == -1), we call select(0, ...), which is basically equal + to sleep. */ - char deviceName[1024] = {0,}; - MmsPluginCmAgent::instance()->getDeviceName(deviceName); - MSG_DEBUG("deviceName: [%s]", deviceName); + rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); - int curl_status = curl_easy_setopt(httpConfig->session, CURLOPT_INTERFACE, deviceName); - if (curl_status != CURLM_OK) { - MSG_DEBUG("curl_easy_setopt(): CURLOPT_INTERFACE failed"); + if (rc == -1){/* select error */ + MSG_ERR("select error"); + ret = -1; + break; + } else if (rc == 0){ /* timeout */ + MSG_ERR("time out"); + ret = -1; + break; + } else {/* action */ + MSG_DEBUG("rc = %d", rc); + rcm = curl_multi_perform(multi_handle, &still_running); + } - return eMMS_EXCEPTIONAL_ERROR; - } + connection_open_flag = MmsPluginCmAgent::instance()->getCmStatus(); + if (connection_open_flag == false) { + MSG_DEBUG("Connection Closed"); + ret = -1; + } - CURLcode rc = curl_easy_perform(httpConfig->session); + MSG_INFO("curl_multi_perform end : rcm = %d, still_running = %d, cm_open = %d", rcm, still_running, connection_open_flag); - __http_print_profile(httpConfig->session); + } while(still_running && (connection_open_flag == true)); - MmsPluginHttpAgent* httpAgent = MmsPluginHttpAgent::instance(); - MMS_PLUGIN_HTTP_DATA_S *httpConfigData = httpAgent->getHttpConfigData(); - if (httpConfigData->sessionHeader) { - curl_slist_free_all((curl_slist *)httpConfigData->sessionHeader); - httpConfigData->sessionHeader = NULL; - } + while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) { + if (msg->msg == CURLMSG_DONE) { - if (CURLE_OK != rc) { - MSG_DEBUG("curl_easy_perform return error = %d", rc); + if (msg->easy_handle == session) { + MSG_INFO("HTTP transfer completed with status %d", msg->data.result); + if (msg->data.result != 0) { + ret = msg->data.result; + } - return eMMS_HTTP_ERROR_NETWORK; + curl_multi_remove_handle(multi_handle, session); + } else { + MSG_WARN("Unknown handle HTTP transfer completed with status %d", msg->data.result); + } + } } - MSG_DEBUG("## End Transaction ##"); - MSG_DEBUG("############ trID = %d ###########", trId); - srandom((unsigned int) time(NULL)); - trId = random() % 1000000000 + 1; - httpConfig->transactionId = trId; + curl_multi_cleanup(multi_handle); - return eMMS_HTTP_SENT_SUCCESS; + MSG_END(); + return ret; } MmsPluginHttpAgent *MmsPluginHttpAgent::pInstance = NULL; MmsPluginHttpAgent *MmsPluginHttpAgent::instance() { if (!pInstance) + { pInstance = new MmsPluginHttpAgent(); + } return pInstance; } @@ -535,139 +487,264 @@ MmsPluginHttpAgent *MmsPluginHttpAgent::instance() MmsPluginHttpAgent::MmsPluginHttpAgent() { - MSG_DEBUG("MmsPluginHttpAgent()"); - - bzero(&httpConfigData, sizeof(httpConfigData)); - bzero(&mmsPlgCd, sizeof(mmsPlgCd)); + MSG_BEGIN(); - httpCmdHandler.clear(); + abort = false; + respfile = NULL; + session_header = NULL; + session_option = NULL; - httpCmdHandler[eHTTP_CMD_INIT_SESSION] = &__httpCmdInitSession; - httpCmdHandler[eHTTP_CMD_POST_TRANSACTION] = &__httpCmdPostTransaction; - httpCmdHandler[eHTTP_CMD_GET_TRANSACTION] = &__httpCmdGetTransaction; + transaction_type = MMS_HTTP_TRANSACTION_TYPE_UNKNOWN; + MSG_END(); } MmsPluginHttpAgent::~MmsPluginHttpAgent() { + MSG_BEGIN(); + if (session_header) { + MSG_DEBUG("session header is exist : free session header"); + curl_slist_free_all((curl_slist *)session_header); + session_header = NULL; + } + + if (session_option) { + MSG_DEBUG("session is exist : cleanup session"); + curl_easy_cleanup(session_option); + session_option = NULL; + } + + MSG_END(); } -void MmsPluginHttpAgent::SetMMSProfile() +void MmsPluginHttpAgent::initSession() { MSG_BEGIN(); - MMSC_CONFIG_DATA_S *mmscConfig = &(httpConfigData.mmscConfig); + this->transaction_type = MMS_HTTP_TRANSACTION_TYPE_UNKNOWN; + + if (session_header) { + MSG_DEBUG("session header is exist : free session header"); + curl_slist_free_all((curl_slist *)session_header); + session_header = NULL; + } + + if (session_option) { + MSG_DEBUG("session is exist : cleanup session"); + curl_easy_cleanup(session_option); + session_option = NULL; + } - MmsPluginCmAgent::instance()->getHomeURL(mmscConfig->mmscUrl); - if (strlen(mmscConfig->mmscUrl) < 1) { - strcpy(mmscConfig->mmscUrl, DEFAULT_MMSC_URL); + if (respfile) { + fclose(respfile); + respfile = NULL; } - MmsPluginCmAgent::instance()->getProxyAddr(mmscConfig->httpProxyIpAddr); - mmscConfig->proxyPortNo = MmsPluginCmAgent::instance()->getProxyPort(); + initAbortFlag(); MSG_END(); } -int MmsPluginHttpAgent::cmdRequest(MMS_HTTP_CMD_TYPE_T cmdType) +void MmsPluginHttpAgent::clearSession() { - MSG_DEBUG("cmdRequest:%x", cmdType); + MSG_BEGIN(); - int ret = 0; + this->transaction_type = MMS_HTTP_TRANSACTION_TYPE_UNKNOWN; - ret = httpCmdHandler[cmdType](&httpConfigData); + if (session_header) { + MSG_DEBUG("session header is exist : free session header"); + curl_slist_free_all((curl_slist *)session_header); + session_header = NULL; + } - return ret; -} + if (session_option) { + MSG_DEBUG("session is exist : cleanup session"); + curl_easy_cleanup(session_option); + session_option = NULL; + } -MMS_PLUGIN_HTTP_CONTEXT_S* MmsPluginHttpAgent::getMmsPldCd() -{ - return &mmsPlgCd; -} + if (respfile) { + fclose(respfile); + respfile = NULL; + } -MMS_PLUGIN_HTTP_DATA_S *MmsPluginHttpAgent::getHttpConfigData() -{ - return &httpConfigData; + initAbortFlag(); + MSG_END(); } -int MmsPluginHttpAgent::setSession(mmsTranQEntity *qEntity) +MMS_HTTP_ERROR_E MmsPluginHttpAgent::setSession(http_request_info_s &request_info) { - MSG_DEBUG("%s %d", qEntity->pPostData, qEntity->postDataLen); + MSG_BEGIN(); + MMS_HTTP_ERROR_E http_error = MMS_HTTP_ERROR_NONE; + int content_len = 0; + char *url = NULL; - if (qEntity->eHttpCmdType == eHTTP_CMD_POST_TRANSACTION) { - MSG_DEBUG("HttpCmd Post Transaction"); - MSG_DEBUG(" === HTTP Agent Thread : Signal ==> eMMS_HTTP_SIGNAL_POST_TRANSACTION"); + // Verify request info + if (request_info.transaction_type != MMS_HTTP_TRANSACTION_TYPE_GET + && request_info.transaction_type != MMS_HTTP_TRANSACTION_TYPE_POST) + { + MSG_ERR("transaction_type of request_info is Invaild [%d]", request_info.transaction_type); + http_error = MMS_HTTP_ERROR_TRANSACTION_TYPE; + goto __CATCH; + } - curl_slist *responseHeaders = NULL; + if (request_info.transaction_type == MMS_HTTP_TRANSACTION_TYPE_POST) { - __httpAllocHeaderInfo(&responseHeaders, NULL, qEntity->postDataLen); + if (request_info.post_data == NULL || request_info.post_data_len == 0) { + MSG_ERR("post data info is Invaild"); + http_error = MMS_HTTP_ERROR_SESSION; + goto __CATCH; + } + } - //Disable 'Expect: 100-contine' option - responseHeaders = curl_slist_append(responseHeaders, "Expect:"); + if (request_info.url == NULL || request_info.proxy == NULL || request_info.interface == NULL) { + MSG_ERR("request_info parameter invalid url [%s], proxy [%s] interface [%s]", request_info.url, request_info.proxy, request_info.interface); + http_error = MMS_HTTP_ERROR_SESSION; + goto __CATCH; + } - MSG_DEBUG(" === MMSCURI = %s === ", httpConfigData.mmscConfig.mmscUrl); + //Set type + this->transaction_type = request_info.transaction_type; + MSG_DEBUG("set transaction type [%d]", this->transaction_type); - httpConfigData.sessionHeader = (void *)responseHeaders; + //Set http Headers + if (this->transaction_type == MMS_HTTP_TRANSACTION_TYPE_POST) { + content_len = request_info.post_data_len; + } else { //MMS_HTTP_TRANSACTION_TYPE_GET + content_len = 0; + } - MSG_DEBUG("## Start Transaction : Post ##"); - curl_easy_setopt(httpConfigData.session, CURLOPT_VERBOSE, true); - curl_easy_setopt(httpConfigData.session, CURLOPT_POST, true); - curl_easy_setopt(httpConfigData.session, CURLOPT_URL, httpConfigData.mmscConfig.mmscUrl); - curl_easy_setopt(httpConfigData.session, CURLOPT_NOPROGRESS, true); - curl_easy_setopt(httpConfigData.session, CURLOPT_HTTPHEADER, responseHeaders); - curl_easy_setopt(httpConfigData.session, CURLOPT_POSTFIELDS, qEntity->pPostData); - curl_easy_setopt(httpConfigData.session, CURLOPT_POSTFIELDSIZE, qEntity->postDataLen); - curl_easy_setopt(httpConfigData.session, CURLOPT_WRITEFUNCTION, __httpPostTransactionCB); + url = g_strdup(request_info.url); - curl_easy_setopt(httpConfigData.session, CURLOPT_TCP_NODELAY, 1); - } else if (qEntity->eHttpCmdType == eHTTP_CMD_GET_TRANSACTION) { - MSG_DEBUG("MmsHttpInitTransactionGet %d pGetData (%s)", qEntity->getDataLen, qEntity->pGetData); - MSG_DEBUG("MmsHttpInitTransactionGet mmscURL (%s) ", httpConfigData.mmscConfig.mmscUrl); + if (url) { + __httpAllocHeaderInfo((curl_slist**)&session_header, url, content_len); + if (session_header == NULL) { + MSG_ERR("Failed to httpAllocHeaderInfo"); + http_error = MMS_HTTP_ERROR_SESSION; + goto __CATCH; + } - char szUrl[MAX_MMSC_URL_LEN] = {0, }; + free(url); + url = NULL; + } else { + MSG_ERR("Failed to strdup"); + goto __CATCH; + } - memcpy(szUrl, qEntity->pGetData, qEntity->getDataLen); - MSG_DEBUG("MmsHttpInitTransactionGet szURL (%s)", szUrl); + //Set curl option + session_option = curl_easy_init(); + if (session_option == NULL) { + MSG_ERR("curl_easy_init() failed"); + http_error = MMS_HTTP_ERROR_SESSION; + goto __CATCH; + } - curl_slist *responseHeaders = NULL; + curl_easy_setopt(session_option, CURLOPT_PROXY, request_info.proxy); + curl_easy_setopt(session_option, CURLOPT_VERBOSE, true); + curl_easy_setopt(session_option, CURLOPT_URL, request_info.url); + curl_easy_setopt(session_option, CURLOPT_NOPROGRESS, true); + curl_easy_setopt(session_option, CURLOPT_HTTPHEADER, session_header); + curl_easy_setopt(session_option, CURLOPT_DEBUGFUNCTION , __http_debug_cb); + curl_easy_setopt(session_option, CURLOPT_INTERFACE, request_info.interface); + //curl_easy_setopt(httpConfigData.session, CURLOPT_PROGRESSFUNCTION, __http_progress_cb); //for debug + + if (respfile) { + curl_easy_setopt(session_option, CURLOPT_WRITEFUNCTION, __http_write_response_cb); + curl_easy_setopt(session_option, CURLOPT_WRITEDATA, respfile); + } - __httpAllocHeaderInfo(&responseHeaders, NULL, 0); + if (transaction_type == MMS_HTTP_TRANSACTION_TYPE_POST) { + curl_easy_setopt(session_option, CURLOPT_POST, true); + curl_easy_setopt(session_option, CURLOPT_POSTFIELDS, request_info.post_data); + curl_easy_setopt(session_option, CURLOPT_POSTFIELDSIZE, request_info.post_data_len); + // curl_easy_setopt(session_option, CURLOPT_TCP_NODELAY, 1); + } - httpConfigData.sessionHeader = (void *)responseHeaders; + MSG_END(); + return http_error; - MSG_DEBUG("## Start Transaction : Get ##"); - curl_easy_setopt(httpConfigData.session, CURLOPT_VERBOSE, true); - curl_easy_setopt(httpConfigData.session, CURLOPT_URL, szUrl); - curl_easy_setopt(httpConfigData.session, CURLOPT_NOPROGRESS, true); - curl_easy_setopt(httpConfigData.session, CURLOPT_HTTPHEADER, responseHeaders); - curl_easy_setopt(httpConfigData.session, CURLOPT_WRITEFUNCTION, __httpGetTransactionCB); - } else { - MSG_DEBUG("Unknown eHttpCmdType [%d]", qEntity->eHttpCmdType); - return -1; +__CATCH: + //CID 338211: freeing url (with check) in case of error + if (url) { + free(url); + url = NULL; } + clearSession(); - return 0; + MSG_END(); + return http_error; } +MMS_HTTP_ERROR_E MmsPluginHttpAgent::startTransaction() +{ + MSG_BEGIN(); + MMS_HTTP_ERROR_E http_error = MMS_HTTP_ERROR_NONE; -void MmsPluginHttpAgent::clearSession() + int rc = __http_multi_perform(session_option); + + __http_print_profile(session_option); + + if (rc != 0) { + MSG_ERR("curl_easy_perform return error rc [%d]", rc); + http_error = MMS_HTTP_ERROR_TRANSACTION; + } + + MSG_END(); + return http_error; +} + +MMS_HTTP_ERROR_E MmsPluginHttpAgent::httpRequest(http_request_info_s &request_info) { MSG_BEGIN(); - if (httpConfigData.sessionHeader) { - curl_slist_free_all((curl_slist *)httpConfigData.sessionHeader); - httpConfigData.sessionHeader = NULL; + const char *conf_filename = MSG_DATA_PATH"mms.conf"; + MMS_HTTP_ERROR_E http_error = MMS_HTTP_ERROR_NONE; + + this->initSession(); + + respfile = fopen(conf_filename, "wb"); + + //set session + http_error = this->setSession(request_info); + if (http_error != MMS_HTTP_ERROR_NONE) { + MSG_ERR("Fail to setSession"); + goto __CATCH; } - if (httpConfigData.session == NULL) { - MSG_DEBUG("[Error]httpConfigData.session is NULL"); - return; + //transaction + http_error = this->startTransaction(); + + if (http_error != MMS_HTTP_ERROR_NONE) { + MSG_ERR("Fail to startTransaction"); + goto __CATCH; + } + + //close conf file & load response data + if (respfile) { + + fclose(respfile); + respfile = NULL; + + if (g_file_get_contents(conf_filename, &request_info.response_data, &request_info.response_data_len, NULL) == false) { + MSG_WARN("Fail to g_file_get_contents"); + } } - curl_easy_cleanup(httpConfigData.session); + this->clearSession(); + + MSG_END(); + return http_error; + +__CATCH: + + if (respfile) { + fclose(respfile); + respfile = NULL; + } - httpConfigData.session = NULL; + this->clearSession(); MSG_END(); + return http_error; } diff --git a/plugin/mms_plugin/MmsPluginInternal.cpp b/plugin/mms_plugin/MmsPluginInternal.cpp index 7e3d831..cc4c0c3 100755 --- a/plugin/mms_plugin/MmsPluginInternal.cpp +++ b/plugin/mms_plugin/MmsPluginInternal.cpp @@ -1,43 +1,40 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include #include #include -#include "MsgDebug.h" +#include "MsgCppTypes.h" #include "MsgUtilFile.h" #include "MsgException.h" +#include "MsgSettingTypes.h" #include "MsgMmsMessage.h" -#include "MsgTransportTypes.h" #include "MsgGconfWrapper.h" -#include "MsgSoundPlayer.h" #include "MsgStorageHandler.h" +#include "MsgSerialize.h" +#include "MsgSpamFilter.h" + +#include "MmsPluginDebug.h" #include "MmsPluginTypes.h" #include "MmsPluginCodec.h" -#include "MmsPluginSetup.h" #include "MmsPluginInternal.h" #include "MmsPluginStorage.h" -#include "MmsPluginHttp.h" -#include "MmsPluginCodec.h" - -#include "MsgNotificationWrapper.h" -#include "MmsPluginSmil.h" - -MmsSetup gMmsSetup; +#include "MmsPluginAppBase.h" +#include "MmsPluginMIME.h" /*================================================================================================== IMPLEMENTATION OF MmsPluginInternal - Member Functions @@ -65,7 +62,7 @@ MmsPluginInternal *MmsPluginInternal::instance() void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject) { - MSG_DEBUG("processReceivedInd \r\n"); + MSG_BEGIN(); FILE *pFile = NULL; char fileName[MSG_FILENAME_LEN_MAX] = {0,}; @@ -76,22 +73,22 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ if(MsgCreateFileName(fileName) == false) THROW(MsgException::FILE_ERROR, "MsgCreateFileName error"); - MSG_DEBUG(" File name = %s", fileName); + MSG_SEC_DEBUG("File name = %s", fileName); if(MsgWriteIpcFile(fileName, pMsgInfo->msgText, pMsgInfo->dataSize) == false) THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error"); - snprintf(fullPath, MAX_FULL_PATH_SIZE+1, MSG_IPC_DATA_PATH"%s", fileName); + snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, fileName); memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData)); memcpy(pMsgInfo->msgData, fullPath, strlen(fullPath)); pMsgInfo->bTextSms = false; } - MSG_DEBUG("MMS File Path = %s", pMsgInfo->msgData); + MSG_SEC_DEBUG("MMS File Path = %s", pMsgInfo->msgData); - _MmsInitHeader(); - _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX); + MmsInitHeader(); + MmsRegisterDecodeBuffer(); if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) { MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData); @@ -100,11 +97,15 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ if (!MmsBinaryDecodeMsgHeader(pFile, pMsgInfo->dataSize)) MSG_DEBUG("Decoding Header Failed \r\n"); - MsgDeleteFile(pMsgInfo->msgData + strlen(MSG_IPC_DATA_PATH)); + MsgCloseFile(pFile); + + if (remove(pMsgInfo->msgData) != 0) + MSG_DEBUG("Fail remove"); + switch (mmsHeader.type) { case MMS_MSGTYPE_NOTIFICATION_IND: - MSG_DEBUG("MmsProcessNewMsgInd: process noti.ind\n"); + MSG_DEBUG("process noti.ind\n"); // For Set Value pMsgInfo if (processNotiInd(pMsgInfo, pRequest) == false) *bReject = true; @@ -113,33 +114,32 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ break; case MMS_MSGTYPE_DELIVERY_IND: - MSG_DEBUG("MmsProcessNewMsgInd: process delivery.ind\n"); + MSG_DEBUG("process delivery.ind\n"); // For Set Value pMsgInfo processDeliveryInd(pMsgInfo); break; case MMS_MSGTYPE_READORG_IND: - MSG_DEBUG("MmsProcessNewMsgInd: process readorig.ind\n"); + MSG_DEBUG("process readorig.ind\n"); processReadOrgInd(pMsgInfo); break; default: break; } - - MsgCloseFile(pFile); } - //Check Msg Type & Process(Save ...) + + MSG_END(); } bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest) { MSG_DEBUG("MmsProcessNotiInd"); - msg_error_t err = MSG_SUCCESS; MSG_MMS_HOME_RETRIEVE_TYPE_T retrieveType; bool bReportAllowed; MmsAttrib attrib; + MsgDbHandler *dbHandle = getDbHandle(); MmsInitMsgAttrib(&attrib); @@ -155,32 +155,135 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST attrib.expiryTime = mmsHeader.expiryTime; - MmsPluginStorage *pStorage = MmsPluginStorage::instance(); - err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType); - if (mmsHeader.pFrom) { MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr); // From strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN); + if (MmsAddrUtilCheckEmailAddress(pMsgInfo->addressList[0].addressVal)) { + pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_EMAIL; + } + } + + MMS_DATA_S *mms_data = MsgMmsCreate(); + if (mms_data == NULL) return false; + { + mms_data->header = MsgMmsCreateHeader(); + + if (mms_data->header == NULL) { + MsgMmsRelease(&mms_data); + return false; + } + + MMS_HEADER_DATA_S *pHeader = mms_data->header; + + pHeader->messageType = mmsHeader.type; + + snprintf(pHeader->trID, sizeof(pHeader->trID), "%s", mmsHeader.szTrID); + + pHeader->mmsVersion = mmsHeader.version; + + //From + if (mmsHeader.pFrom) { + MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr); + snprintf(pHeader->szFrom, sizeof(pHeader->szFrom), "%s", mmsHeader.pFrom->szAddr); + } + + //Subject + snprintf(pHeader->szSubject, sizeof(pHeader->szSubject), "%s", mmsHeader.szSubject); + //Delivery Report + pHeader->bDeliveryReport = (mmsHeader.deliveryReport != MMS_REPORT_YES); + //Message Class + pHeader->messageClass = mmsHeader.msgClass; + + //Priority + pHeader->mmsPriority = mmsHeader.priority; + + //Message Size : pMmsMsg->mmsAttrib.msgSize = mmsHeader.msgSize; + //Expiry + pHeader->expiry.type = mmsHeader.expiryTime.type; + pHeader->expiry.time = mmsHeader.expiryTime.time; + + time_t curTime = time(NULL); + + if (pHeader->expiry.type == MMS_TIMETYPE_RELATIVE) { + pHeader->expiry.type = MMS_TIMETYPE_ABSOLUTE; + pHeader->expiry.time += curTime; + } + + //Charge + //contentclass + //int contentClass;//text | image-basic| image-rich | video-basic | video-rich | megapixel | content-basic | content-rich + strncpy(pHeader->contentLocation, mmsHeader.szContentLocation, MMS_LOCATION_LEN); + + pHeader->messageSize = mmsHeader.msgSize; + + MSG_DEBUG("Message size = [%d]", pHeader->messageSize); + + char *pSerializedMms = NULL; + int serializeDataSize = 0; + + char pTempFileName[MSG_FILENAME_LEN_MAX+1] = {0}; + char pTempFilePath[MSG_FILEPATH_LEN_MAX+1] = {0}; + + serializeDataSize = MsgSerializeMms(mms_data, &pSerializedMms); + + if (pSerializedMms) { + if (MsgCreateFileName(pTempFileName) == true) { + pMsgInfo->bTextSms = false; + + snprintf(pTempFilePath, sizeof(pTempFilePath), MSG_IPC_DATA_PATH"%s", pTempFileName); + + MsgOpenCreateAndOverwriteFile(pTempFilePath, pSerializedMms, serializeDataSize); + + //set file name + snprintf(pMsgInfo->msgData, sizeof(pMsgInfo->msgData), "%s", pTempFileName); + } + + free(pSerializedMms); + } + } + MsgMmsRelease(&mms_data); + + // Check contents-location is in noti.ind + if (mmsHeader.szContentLocation[0] == '\0') { + THROW(MsgException::INCOMING_MSG_ERROR, "######## Contents-location is empty in MMS-Noti-Ind #######"); + return false; } int roamState = 0; + char pPduFilePath[MAX_FULL_PATH_SIZE] = {0}; roamState = MsgSettingGetInt(VCONFKEY_TELEPHONY_SVC_ROAM); MsgSettingGetBool(MMS_SEND_REPORT_ALLOWED, &bReportAllowed); - if (checkRejectNotiInd(roamState, bReportAllowed, pMsgInfo->msgData)) { + if (checkRejectNotiInd(roamState, bReportAllowed, pPduFilePath)) { MSG_DEBUG("MMS Message Rejected......"); - pMsgInfo->dataSize = strlen(pMsgInfo->msgData); - pMsgInfo->bTextSms = true; + pMsgInfo->dataSize = strlen(pPduFilePath); memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); - + snprintf(pRequest->msgInfo.msgData, sizeof(pRequest->msgInfo.msgData), "%s", pPduFilePath); pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS; return false; } + if (MsgCheckFilter(dbHandle, pMsgInfo)){ + encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pPduFilePath); + + pMsgInfo->dataSize = strlen(pPduFilePath); + + pRequest->msgInfo.bTextSms = false; + + memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); + + snprintf(pRequest->msgInfo.msgData, sizeof(pRequest->msgInfo.msgData), "%s", pPduFilePath); + MSG_DEBUG("pRequest->msgInfo.msgData = %s", pRequest->msgInfo.msgData); + pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS; + pRequest->msgInfo.folderId = MSG_SPAMBOX_ID; + + return true; + } + if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_OFF) { retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK); MSG_DEBUG("$$$$$$$$$$ MMS_RECV_HOME_NETWORK = %d $$$$$$$$$$$$$", retrieveType); @@ -191,14 +294,16 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST if (retrieveType == MSG_ABROAD_RESTRICTED) { MSG_DEBUG("MMS Receiving Setting Restricted was selected."); // m-notify-resp-ind encoding process - memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1); + encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pPduFilePath); + + pMsgInfo->dataSize = strlen(pPduFilePath); - encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData); + pRequest->msgInfo.bTextSms = false; - pMsgInfo->dataSize = strlen(pMsgInfo->msgData); - pMsgInfo->bTextSms = true; memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); + snprintf(pRequest->msgInfo.msgData, sizeof(pRequest->msgInfo.msgData), "%s", pPduFilePath); + pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS; return true; @@ -207,157 +312,103 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST // should send http 'GET' if (retrieveType == MSG_HOME_AUTO_DOWNLOAD || retrieveType == MSG_ABROAD_AUTO_DOWNLOAD) { - MSG_DEBUG("=========== START AUTO RETRIEVE MODE ============"); - memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1); + //Check if current request sim index is different from default network SIM + //Convert auto-retrieve to manual retrieve in case sim indexes are different + int default_sim = 0; + default_sim = MsgSettingGetInt(MSG_NETWORK_SIM); - memcpy(pMsgInfo->msgData, mmsHeader.szContentLocation, strlen(mmsHeader.szContentLocation)) ; + MSG_DEBUG("default_sim = %d, pMsgInfo->sim_idx = %d", default_sim, pMsgInfo->sim_idx); - pMsgInfo->dataSize = strlen(pMsgInfo->msgData); + if (default_sim == (int)pMsgInfo->sim_idx) { + MSG_DEBUG("=========== START AUTO RETRIEVE MODE ============"); - pMsgInfo->bTextSms = true; + pMsgInfo->dataSize = strlen(mmsHeader.szContentLocation); - memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); + pRequest->msgInfo.bTextSms = true; + + memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); + + snprintf(pRequest->msgInfo.msgData, sizeof(pRequest->msgInfo.msgData), "%s", mmsHeader.szContentLocation); + + pRequest->msgInfo.msgType.subType = MSG_GET_MMS; + + MSG_SEC_DEBUG("MSG SUBTYPE = %d msg data %s bTextsms %d", pRequest->msgInfo.msgType.subType, pRequest->msgInfo.msgData, pRequest->msgInfo.bTextSms); + } else { + encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pPduFilePath); + + pMsgInfo->dataSize = strlen(pPduFilePath); - pRequest->msgInfo.msgType.subType = MSG_GET_MMS; + pRequest->msgInfo.bTextSms = false; - MSG_DEBUG("MSG SUBTYPE = %d msg data %s bTextsms %d", pRequest->msgInfo.msgType.subType, pRequest->msgInfo.msgData, pRequest->msgInfo.bTextSms); + memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); + + snprintf(pRequest->msgInfo.msgData, sizeof(pRequest->msgInfo.msgData), "%s", pPduFilePath); + MSG_SEC_DEBUG("pRequest->msgInfo.msgData = %s", pRequest->msgInfo.msgData); + pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS; + } } else { - // should send m-notify-resp-ind + // should send m-notify-resp-ind MSG_DEBUG("=========== START MANUAL RETRIEVE MODE ==========="); // m-notify-resp-ind encoding process - memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1); if (retrieveType == MSG_HOME_MANUAL || retrieveType == MSG_ABROAD_MANUAL) { - encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData); + encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pPduFilePath); } - pMsgInfo->dataSize = strlen(pMsgInfo->msgData); - pMsgInfo->bTextSms = true; + pMsgInfo->dataSize = strlen(pPduFilePath); + + pRequest->msgInfo.bTextSms = false; + memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); + snprintf(pRequest->msgInfo.msgData, sizeof(pRequest->msgInfo.msgData), "%s", pPduFilePath); + MSG_DEBUG("pRequest->msgInfo.msgData = %s", pRequest->msgInfo.msgData); pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS; } return true; } - void MmsPluginInternal::processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo) { MSG_BEGIN(); - MmsMsg *pMsg = NULL; - bool bFound = false; - MmsMsgMultiStatus *pStatus = NULL; - MmsMsgMultiStatus *pLastStatus = NULL; - - pMsg = (MmsMsg *)malloc(sizeof(MmsMsg)); + MmsMsgMultiStatus status; + memset(&status, 0x00, sizeof(MmsMsgMultiStatus)); - if (pMsg == NULL) { - MSG_DEBUG("fail to allocation memory."); - return; - } + status.msgStatus = mmsHeader.msgStatus; + status.handledTime = mmsHeader.date; + status.bDeliveryReportIsRead = false; + status.bDeliveyrReportIsLast= true; - MmsInitMsgAttrib(&pMsg->mmsAttrib); + MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr); + MSG_DEBUG("[INFO] [ADDR: %s, MMSID: %s]",mmsHeader.pTo->szAddr, mmsHeader.szMsgID); - pMsgInfo->msgType.mainType = MSG_MMS_TYPE; - pMsgInfo->msgType.subType = MSG_DELIVERYIND_MMS; + pMsgInfo->msgType.mainType = MSG_MMS_TYPE; + pMsgInfo->msgType.subType = MSG_DELIVERYIND_MMS; pMsgInfo->bTextSms = true; + pMsgInfo->dataSize = 0; + memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1); - MSG_DEBUG("#### mmsHeader.szMsgID = %s : when received delivery ind####", mmsHeader.szMsgID); - - int tmpId = (msg_message_id_t)MmsSearchMsgId(mmsHeader.pTo->szAddr, mmsHeader.szMsgID); - + strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(status.msgStatus), MAX_MSG_DATA_LEN); + pMsgInfo->dataSize = strlen(pMsgInfo->msgData); + MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData); - MSG_DEBUG("tmpId [%d]", tmpId); - MSG_DEBUG("mmsHeader.pTo->szAddr [%s]", mmsHeader.pTo->szAddr); + strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN); + int tmpId = (msg_message_id_t)MmsPluginStorage::instance()->searchMsgId(mmsHeader.pTo->szAddr, mmsHeader.szMsgID); if (tmpId > 0) { - pMsgInfo->msgId = (msg_message_id_t)tmpId; - - pMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(pMsgInfo->msgId); - - pStatus = pMsg->mmsAttrib.pMultiStatus; - - MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo); - - while (pStatus && !bFound) { - MSG_DEBUG("### MmsAddrUtilCompareAddr ###"); - MSG_DEBUG("### mmsHeader.pTo->szAddr = %s ###", mmsHeader.pTo->szAddr); - if (MmsAddrUtilCompareAddr( pStatus->szTo, mmsHeader.pTo->szAddr)) { - bFound = true; - break; - } - - pStatus = pStatus->pNext; - } - - if (bFound == false) { - MSG_DEBUG("### bFound == false ###"); - /* Queue the delivery report --------------------------- */ - - pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus)); - memset(pStatus, 0, sizeof(MmsMsgMultiStatus)); - - pStatus->readStatus = MMS_READSTATUS_NONE; - memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1); - strncpy(pStatus->szTo, mmsHeader.pTo->szAddr, MSG_ADDR_LEN); - - if (pMsg->mmsAttrib.pMultiStatus == NULL) { - /* first delivery report */ - pMsg->mmsAttrib.pMultiStatus = pStatus; - } else { - pLastStatus = pMsg->mmsAttrib.pMultiStatus; - - while (pLastStatus->pNext) { - pLastStatus = pLastStatus->pNext; - } - - pLastStatus->pNext = pStatus; - pLastStatus = pStatus; - } - } - - pStatus->handledTime = mmsHeader.date; - pStatus->msgStatus = mmsHeader.msgStatus; - - memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1); - pMsgInfo->dataSize = 0; - strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(pStatus->msgStatus), MAX_MSG_DATA_LEN); - pMsgInfo->dataSize = strlen(pMsgInfo->msgData); - pMsgInfo->bTextSms = true; - MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData); - - strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN); - - pStatus->bDeliveryReportIsRead = false; + MSG_DEBUG("Found MSG_ID = %d", tmpId); - _MmsDataUpdateLastStatus(pMsg); + //Insert to Delievery DB + MmsPluginStorage::instance()->insertDeliveryReport(tmpId, mmsHeader.pTo->szAddr, &status); - pStatus->bDeliveyrReportIsLast= true; - - MmsUpdateDeliveryReport(pMsgInfo->msgId, pStatus); + pMsgInfo->msgId = (msg_message_id_t)tmpId; - MmsPluginStorage::instance()->addMmsNoti(pMsgInfo); } else { - MSG_DEBUG("Can't not find Message!"); - memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1); - pMsgInfo->dataSize = 0; - strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(mmsHeader.msgStatus), MAX_MSG_DATA_LEN); - - MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData); - - pMsgInfo->dataSize = strlen(pMsgInfo->msgData); - - MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr); - - strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN); + MSG_DEBUG("Can not find MMS message in DB"); } - MsgFreeAttrib(&pMsg->mmsAttrib); - - free(pMsg); - MSG_END(); } @@ -365,20 +416,11 @@ void MmsPluginInternal::processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo) { MSG_BEGIN(); - MmsMsg *pMsg = NULL; - bool bFound = false; - MmsMsgMultiStatus *pStatus = NULL; - MmsMsgMultiStatus *pLastStatus = NULL; - - pMsg = (MmsMsg *)malloc(sizeof(MmsMsg)); - - if (pMsg == NULL) { - MSG_DEBUG("fail to allocation memory."); + if (pMsgInfo == NULL) { + MSG_DEBUG("parameter err"); return; } - MmsInitMsgAttrib(&pMsg->mmsAttrib); - pMsgInfo->msgType.mainType = MSG_MMS_TYPE; pMsgInfo->msgType.subType = MSG_READORGIND_MMS; pMsgInfo->bTextSms = true; @@ -386,97 +428,30 @@ void MmsPluginInternal::processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo) MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr); MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr); - if (mmsHeader.readStatus != MSG_READ_REPORT_IS_DELETED || (strcmp(mmsHeader.pFrom->szAddr, mmsHeader.pTo->szAddr))) { - MSG_DEBUG("#### mmsHeader.szMsgID = %s : when received read orig ind####", mmsHeader.szMsgID); - - int tmpId = MmsSearchMsgId(mmsHeader.pFrom->szAddr, mmsHeader.szMsgID); - - if (tmpId > 0) { - pMsgInfo->msgId = (msg_message_id_t)tmpId; - - pMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(pMsgInfo->msgId); - - pStatus = pMsg->mmsAttrib.pMultiStatus; - - MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo); - - while (pStatus && !bFound) { - MSG_DEBUG("### MmsAddrUtilCompareAddr ###"); - MSG_DEBUG("### mmsHeader.pFrom->szAddr = %s ###", mmsHeader.pFrom->szAddr); - if (MmsAddrUtilCompareAddr(pStatus->szTo, mmsHeader.pFrom->szAddr)) { - bFound = true; - break; - } - - pStatus = pStatus->pNext; - } - - if (bFound == false) { - MSG_DEBUG("### bFound == false ###"); - /* Queue the delivery report --------------------------- */ - - pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus)); - memset(pStatus, 0, sizeof(MmsMsgMultiStatus)); - - pStatus->msgStatus = MMS_MSGSTATUS_NONE; - - memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1); - strncpy(pStatus->szTo, mmsHeader.pFrom->szAddr, MSG_ADDR_LEN); - - if (pMsg->mmsAttrib.pMultiStatus == NULL) { - /* first readOrg report */ - pMsg->mmsAttrib.pMultiStatus = pStatus; - } else { - pLastStatus = pMsg->mmsAttrib.pMultiStatus; - - while (pLastStatus->pNext) { - pLastStatus = pLastStatus->pNext; - } - - pLastStatus->pNext = pStatus; - pLastStatus = pStatus; - } - } - - pStatus->readTime = mmsHeader.date; - pStatus->readStatus = mmsHeader.readStatus; - - memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1); - pMsgInfo->dataSize = 0; - strncpy(pMsgInfo->msgData, getMmsReadStatus(pStatus->readStatus), MAX_MSG_DATA_LEN); - pMsgInfo->dataSize = strlen(pMsgInfo->msgData); - pMsgInfo->bTextSms = true; - MSG_DEBUG("read Status = %s", pMsgInfo->msgData); - - strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN); - - pStatus->bReadReplyIsRead = false; + memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1); + pMsgInfo->dataSize = 0; - _MmsDataUpdateLastStatus(pMsg); + strncpy(pMsgInfo->msgData, getMmsReadStatus(mmsHeader.readStatus), MAX_MSG_DATA_LEN); + pMsgInfo->dataSize = strlen(pMsgInfo->msgData); - pStatus->bReadReplyIsLast= true; + MSG_DEBUG("read Status = %s", pMsgInfo->msgData); + strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN); - MmsUpdateReadReport(pMsgInfo->msgId, pStatus); + int tmpId = MmsPluginStorage::instance()->searchMsgId(mmsHeader.pFrom->szAddr, mmsHeader.szMsgID); + if (tmpId > 0) { + pMsgInfo->msgId = (msg_message_id_t)tmpId; - MmsPluginStorage::instance()->addMmsNoti(pMsgInfo); - } else { - MSG_DEBUG("Can't not find Message!"); - memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1); - pMsgInfo->dataSize = 0; - strncpy(pMsgInfo->msgData, getMmsReadStatus(mmsHeader.readStatus), MAX_MSG_DATA_LEN); - pMsgInfo->dataSize = strlen(pMsgInfo->msgData); - MSG_DEBUG("read Status = %s", pMsgInfo->msgData); + MmsMsgMultiStatus Status; + memset(&Status, 0x00, sizeof(MmsMsgMultiStatus)); + Status.readTime = mmsHeader.date; + Status.readStatus = mmsHeader.readStatus; - MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr); + MmsPluginStorage::instance()->insertReadReport(pMsgInfo->msgId, mmsHeader.pFrom->szAddr, &Status); - strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN); - } + } else { + MSG_DEBUG("Can't not find Message!"); } - MsgFreeAttrib(&pMsg->mmsAttrib); - - free(pMsg); - MSG_END(); } @@ -484,8 +459,6 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn { MSG_BEGIN(); - msg_error_t err = MSG_SUCCESS; - MMS_RECV_DATA_S recvData = {{0}, }; pMsgInfo->msgId = pRequest->msgId; @@ -500,6 +473,7 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn if (mmsHeader.responseStatus == MMS_RESPSTATUS_OK) { pMsgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS; + pMsgInfo->dataSize = pRequest->postDataLen; } else { pMsgInfo->networkStatus = MSG_NETWORK_SEND_FAIL; @@ -512,6 +486,22 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn strncpy(pMsgInfo->msgText, responseText, MMS_LOCALE_RESP_TEXT_LEN); } + MSG_ADDRESS_INFO_S addressinfo = {0,}; + char *msisdn = NULL; + msisdn = MsgSettingGetString(MSG_SIM_MSISDN); + + MmsPluginStorage::instance()->getAddressInfo(pMsgInfo->msgId, &addressinfo); + + MSG_MMS_VLD_INFO("%d, MMS Send End %s->%s %s", pMsgInfo->msgId + , (msisdn == NULL)?"ME":msisdn + , addressinfo.addressVal + , (pMsgInfo->networkStatus == MSG_NETWORK_SEND_SUCCESS)?"Success":"Fail"); + + if (msisdn) { + free(msisdn); + msisdn = NULL; + } + // set message-id from mmsc strncpy(recvData.szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN); strncpy(recvData.szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN); @@ -526,26 +516,18 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn MmsMsg *pMsg = NULL; MmsPluginStorage::instance()->getMmsMessage(&pMsg); - _MmsInitHeader(); -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pMsg->msgType.drmInfo); -#endif - _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type); - + MmsInitHeader(); + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); MSG_END(); } - +#if 1 void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest, char *pRetrievedFilePath) { MSG_BEGIN(); - int partCnt = 0; - int attachCount = 0; - MsgType partHeader; - bool bMultipartRelated = false; - msg_error_t err = MSG_SUCCESS; MMS_RECV_DATA_S recvData = {{0}, }; @@ -583,15 +565,43 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_FAIL; pMsgInfo->folderId = MSG_INBOX_ID; // If failed MMS Retrieve, then saved as MMS Noti Ind Message. - pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS; + // It will changed in MsgHandleMmsConfIncomingMsg + //pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS; + } + + char *msisdn = NULL; + msisdn = MsgSettingGetString(MSG_SIM_MSISDN); + + if (mmsHeader.pFrom) + MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr); + + MSG_MMS_VLD_INFO("%d, MMS Receive %s End %s->%s %s", pMsgInfo->msgId + , (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF)?"Auto":"Manual" + , (mmsHeader.pFrom)?mmsHeader.pFrom->szAddr:"YOU" + , (msisdn == NULL)?"ME":msisdn + , (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS)?"Success":"Fail"); + + /* PLM P141008-05143 : Notification.Ind address is 1, but MMS retreived Conf address is correct. + So adding correct address to addressList buf to compare address in DB while MsgStoUpdateMMSMessage */ + if (mmsHeader.pFrom) { + pMsgInfo->nAddressCnt = 1; + strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN); + } + + if (msisdn) { + free(msisdn); + msisdn = NULL; } pMsgInfo->dataSize = pRequest->getDataLen; // set message-id & MMS TPDU file path - strcpy(recvData.szMsgID, mmsHeader.szMsgID); + snprintf(recvData.szMsgID, sizeof(recvData.szMsgID), "%s", mmsHeader.szMsgID); + if (pRetrievedFilePath) - strncpy(recvData.retrievedFilePath, pRetrievedFilePath, sizeof(recvData.retrievedFilePath)); + strncpy(recvData.retrievedFilePath, pRetrievedFilePath, sizeof(recvData.retrievedFilePath)-1); + + char *filename = NULL; #ifdef FEATURE_JAVA_MMS if (mmsHeader.msgType.param.szApplicationID || mmsHeader.msgType.param.szReplyToApplicationID) { @@ -603,19 +613,23 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra char fullPath[MAX_FULL_PATH_SIZE+1] = {0, }; - char *filename = NULL; - filename = strrchr(pRetrievedFilePath, '/'); + filename = MsgGetFileName(pRetrievedFilePath); - snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, filename + 1); + snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, filename); - rename(pRetrievedFilePath, fullPath); + if (pRetrievedFilePath) { + int ret = rename(pRetrievedFilePath, fullPath); + if (ret != 0) { + MSG_DEBUG("File rename Error: %s", g_strerror(errno)); + } - if (chmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) != 0) { - MSG_DEBUG("File Write Error: %s", strerror(errno)); - } + if (MsgChmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == false) { + MSG_DEBUG("File Write Error: %s", g_strerror(errno)); + } - if (chown(fullPath, 0, 6502 ) != 0) { - MSG_DEBUG("File Write Error: %s", strerror(errno)); + if (MsgChown(fullPath, 0, 6502 ) == false) { + MSG_DEBUG("File Write Error: %s", g_strerror(errno)); + } } } #endif @@ -628,82 +642,177 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra MmsPluginStorage *pStorage = MmsPluginStorage::instance(); - MMS_MESSAGE_DATA_S msgData; - memset(&msgData, 0, sizeof(MMS_MESSAGE_DATA_S)); + err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType); + + MSG_DEBUG("Error value of updateMmsAttrib [%d]", err); - // Conversation is supported only Multipart Related message, Presentation info should be provided - if (mmsHeader.msgType.type == MIME_MULTIPART_RELATED || mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { - char *pSmilDoc = NULL; + {//make MmsData & insert multipart + MmsMsg *pMmsMsg = NULL; + MmsPluginStorage::instance()->getMmsMessage(&pMmsMsg); + + MMS_DATA_S *pMmsData = MsgMmsCreate(); + if (pMmsData == NULL) { + MSG_SEC_DEBUG("Fail to create mms"); + goto __CATCH; + } + + pMmsData->header = MsgMmsCreateHeader(); + + MmsConvertMmsData(pMmsMsg, pMmsData); + //CID 41996 : MmsConvertMmsData always returns true + /*if (MmsConvertMmsData(pMmsMsg, pMmsData) != true) { + MSG_DEBUG("Fail to Compose MMS Message"); + goto __CATCH; + }*/ + + bool bFiltered = checkFilterMmsBody(pMmsData); + if (bFiltered == true) { + pMsgInfo->folderId = MSG_SPAMBOX_ID; + } + + MMS_MULTIPART_DATA_S *pSmilMultipart = pMmsData->smil; + if (pSmilMultipart) { + MmsPluginStorage::instance()->insertMultipart(pMsgInfo->msgId, pSmilMultipart); + } + + MMSList *multipart_list = pMmsData->multipartlist; + + for (int i = 0; i < (int)g_list_length(multipart_list); i++) { + MMS_MULTIPART_DATA_S *pMultipart = (MMS_MULTIPART_DATA_S *)g_list_nth_data(multipart_list, i); + MmsPluginStorage::instance()->insertMultipart(pMsgInfo->msgId, pMultipart); + } + + {//make Preview info for APP + MmsPluginAppBase *appBase; + appBase = new MmsPluginAppBase(pMmsData); + appBase->makePreviewInfo(pMsgInfo->msgId, false, pRetrievedFilePath); + appBase->getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + delete appBase; + } + + MsgMmsRelease(&pMmsData); + + if (MsgGetFileSize(pRetrievedFilePath, (int *)&pMsgInfo->dataSize) == false) { + MSG_SEC_DEBUG("Fail to get mms file size [%s]", pRetrievedFilePath); + goto __CATCH; + } + }//make MmsData & insert multipart + +__CATCH: + { MmsMsg *pMsg = NULL; - char szFileName[MSG_FILENAME_LEN_MAX] = {0, }; + pStorage->getMmsMessage(&pMsg); + MmsInitHeader(); + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); + g_free(filename); filename = NULL; + } + MSG_END(); +} +#else //NEW process RetrieveConf +void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest, char *pRetrievedFilePath) +{ + MSG_BEGIN(); - msgData.regionCnt = 0; - msgData.pageCnt = 0; - msgData.attachCnt = 0; - msgData.transitionCnt = 0; - msgData.metaCnt = 0; - memset(msgData.szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX); + msg_error_t err = MSG_SUCCESS; - pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId); - MmsSmilParseSmilDoc(&msgData, pSmilDoc); + pMsgInfo->msgId = pRequest->msgId; - MmsPluginStorage::instance()->getMmsMessage(&pMsg); - strcpy(szFileName, pMsg->szFileName); + pMsgInfo->msgType.mainType = MSG_MMS_TYPE; + if (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF) + pMsgInfo->msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS; + else + pMsgInfo->msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS; - err = pStorage->getMsgText(&msgData, pMsgInfo->msgText); - err = pStorage->makeThumbnail(&msgData, pMsgInfo->thumbPath, szFileName); + strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN); + strncpy(pRequest->transactionId, mmsHeader.szTrID, MMS_TR_ID_LEN); + + time_t curTime; + curTime = time(NULL); - bMultipartRelated = true; + pMsgInfo->displayTime = curTime; + + if (mmsHeader.retrieveStatus == MMS_RETRSTATUS_OK) { + pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS; + pMsgInfo->folderId = MSG_INBOX_ID; } else { - MSG_DEBUG("Multipart mixed message doesn't support mms conversation"); + pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_FAIL; + pMsgInfo->folderId = MSG_INBOX_ID; + // If failed MMS Retrieve, then saved as MMS Noti Ind Message. + // It will changed in MsgHandleMmsConfIncomingMsg + //pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS; } - err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType); + char *msisdn = NULL; + msisdn = MsgSettingGetString(MSG_SIM_MSISDN); - partCnt = MmsGetMediaPartCount(pMsgInfo->msgId); - MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt ); + if (mmsHeader.pFrom) + MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr); - if (partCnt < 0) { - MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt ); - } else { - for (int i = 0; i < partCnt; ++i) { - if (!MmsGetMediaPartHeader(i, &partHeader)) { - MSG_DEBUG("MmsUiGetMediaAttachInfo: MmsGetMediaPartHeader failed\n" ); - break; - } + MSG_MMS_VLD_INFO("%d, MMS Receive %s End %s->%s %s", pMsgInfo->msgId + , (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF)?"Auto":"Manual" + , (mmsHeader.pFrom)?mmsHeader.pFrom->szAddr:"YOU" + , (msisdn == NULL)?"ME":msisdn + , (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS)?"Success":"Fail"); - if (partHeader.contentSize > 0) { - char szBuf[MSG_FILEPATH_LEN_MAX]; + if (msisdn) { + free(msisdn); + msisdn = NULL; + } - strcpy((char *)szBuf, partHeader.param.szFileName); - sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf); - if (!bMultipartRelated || MmsCheckAdditionalMedia(&msgData, &partHeader)) - attachCount++; - } + pMsgInfo->dataSize = pRequest->getDataLen; + + + { + MmsMsg *pMmsMsg = NULL; + MmsPluginStorage::instance()->getMmsMessage(&pMmsMsg); + + MMS_DATA_S *pMmsData = MsgMmsCreate(); + pMmsData->header = MsgMmsCreateHeader(); + + if (MmsConvertMmsData(pMmsMsg, pMmsData) != true) { + MSG_DEBUG("Fail to Compose MMS Message"); + goto __CATCH; } - } - MSG_DEBUG("attachCount [%d]", attachCount); - err = pStorage->updateMmsAttachCount(pMsgInfo->msgId, attachCount); - if (bMultipartRelated) { - _MsgMmsReleasePageList(&msgData); - _MsgMmsReleaseRegionList(&msgData); - _MsgMmsReleaseAttachList(&msgData); - _MsgMmsReleaseTransitionList(&msgData); - _MsgMmsReleaseMetaList(&msgData); - } + char *pSerializedData = NULL; - MmsMsg *pMsg = NULL; - pStorage->getMmsMessage(&pMsg); - _MmsInitHeader(); -#ifdef __SUPPORT_DRM__ - _MsgFreeDRMInfo(&pMsg->msgType.drmInfo); -#endif - _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type); + MsgSerializeMms(pMmsData, &pSerializedData); + + MsgMmsRelease(&pMmsData); + + + char fileName[MSG_FILENAME_LEN_MAX] = {0}; + char fileFilePath[MSG_FILEPATH_LEN_MAX] = {0}; + + if (MsgCreateFileName(fileName) == false) + goto __CATCH; + snprintf(fileFilePath, sizeof(fileFilePath), "%s%s", MSG_DATA_PATH, fileName); + + if (!MsgOpenCreateAndOverwriteFile(fileFilePath, (char *)pSerializedData, (int)strlen(pSerializedData))) { + goto __CATCH; + } + + snprintf(pMsgInfo->msgData, sizeof(pMsgInfo->msgData), "%s", fileFilePath); + + if (MsgGetFileSize(pRetrievedFilePath, (int *)&pMsgInfo->dataSize) == false) { + MSG_SEC_DEBUG("Fail to get mms file size [%s]", pRetrievedFilePath); + goto __CATCH; + } + } + +__CATCH: + { + MmsMsg *pMsg = NULL; + MmsPluginStorage::instance()->getMmsMessage(&pMsg); + MmsInitHeader(); + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); + } MSG_END(); } - +#endif void MmsPluginInternal::processForwardConf(MSG_MESSAGE_INFO_S *msgInfo, mmsTranQEntity *pRequest) { @@ -727,7 +836,7 @@ bool MmsPluginInternal::encodeNotifyRespInd(char *szTrID, msg_delivery_report_st if (MsgCreateFileName(pTempFileName) == false) return false; - snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.noti.ind", pTempFileName); + snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, "%s%s.noti.ind", MSG_DATA_PATH, pTempFileName); pFile = MsgOpenMMSFile(pTempFilePath); @@ -736,8 +845,8 @@ bool MmsPluginInternal::encodeNotifyRespInd(char *szTrID, msg_delivery_report_st return false; } - if (_MmsEncodeNotiRespInd(pFile, szTrID, iStatus, bReportAllowed) == false) { - MSG_DEBUG("MmsEncodeNotifyRespInd: _MmsEncodeNotiRespInd fail"); + if (MmsEncodeNotiRespInd(pFile, szTrID, iStatus, bReportAllowed) == false) { + MSG_DEBUG("MmsEncodeNotifyRespInd: MmsEncodeNotiRespInd fail"); MsgCloseFile(pFile); return false; } @@ -745,7 +854,8 @@ bool MmsPluginInternal::encodeNotifyRespInd(char *szTrID, msg_delivery_report_st MsgCloseFile(pFile); if (pSendFilePath) { - snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath); + //CID 41993: replaced size 'MAX_MSG_DATA_LEN+1' with MAX_FULL_PATH_SIZE + snprintf(pSendFilePath, MAX_FULL_PATH_SIZE, "%s.mms", pTempFilePath); } else { MSG_DEBUG("[ERROR] pSendFilePath is NULL"); return false; @@ -772,7 +882,7 @@ bool MmsPluginInternal::encodeAckInd(char *szTrID, bool bReportAllowed, char *pS if (MsgCreateFileName(pTempFileName) == false) return false; - snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.ack.ind", pTempFileName); + snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, "%s%s.ack.ind", MSG_DATA_PATH, pTempFileName); pFile = MsgOpenMMSFile(pTempFilePath); if (!pFile) { @@ -780,8 +890,8 @@ bool MmsPluginInternal::encodeAckInd(char *szTrID, bool bReportAllowed, char *pS return false; } - if (_MmsEncodeAckInd(pFile, szTrID, bReportAllowed) == false) { - MSG_DEBUG("MmsEncodeAckInd: _MmsEncodeAckInd fail \n" ); + if (MmsEncodeAckInd(pFile, szTrID, bReportAllowed) == false) { + MSG_DEBUG("MmsEncodeAckInd: MmsEncodeAckInd fail \n" ); MsgCloseFile(pFile); return false; } @@ -846,12 +956,87 @@ bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, c } } + //Duplicate MMS notification + int msgId = 0; + + msgId = MmsPluginStorage::instance()->checkDuplicateNotification(mmsHeader.szTrID, mmsHeader.szContentLocation); + + MSG_DEBUG("Msg Id = %d", msgId); + if (msgId > 0) + return true; + // Not Rejected MSG_END(); return false; } + +bool MmsPluginInternal::checkFilterMmsBody(MMS_DATA_S *pMmsData) +{ + if (pMmsData == NULL) + return false; + + bool bFiltered = false; + MMS_PAGE_S *pPage = NULL; + MMS_MEDIA_S *pMedia = NULL; + char filePath[MSG_FILEPATH_LEN_MAX + 1]; + gchar *fileContent = NULL; + MsgDbHandler *dbHandle = getDbHandle(); + MimeType mimeType = MIME_UNKNOWN; + + MMS_MESSAGE_DATA_S *mmsMsg = NULL; + unique_ptr buf(&mmsMsg, unique_ptr_deleter); + mmsMsg = (MMS_MESSAGE_DATA_S *)new char[sizeof(MMS_MESSAGE_DATA_S)]; + memset(mmsMsg, 0x00, sizeof(MMS_MESSAGE_DATA_S)); + + MsgMmsConvertMmsDataToMmsMessageData(pMmsData, mmsMsg); + + // Get the text data from the 1st slide. + if (mmsMsg->pageCnt <= 0) { + MSG_WARN("pageCnt : %d", mmsMsg->pageCnt); + MsgMmsReleaseMmsLists(mmsMsg); + return false; + } + + pPage = _MsgMmsGetPage(mmsMsg, 0); + + if (!pPage) { + MSG_WARN("page is NULL"); + MsgMmsReleaseMmsLists(mmsMsg); + return false; + } + + for (int j = 0; j < pPage->mediaCnt; ++j) { + pMedia = _MsgMmsGetMedia(pPage, j); + + if (pMedia && pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { + + MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL); + + if (mimeType == MIME_TEXT_X_VCALENDAR || mimeType == MIME_TEXT_X_VCARD || mimeType == MIME_TEXT_X_VTODO || mimeType == MIME_TEXT_X_VNOTE) { + MSG_DEBUG("Media Type is Text, but Vobject file [%s]", pMedia->szFilePath); + } else { + strncpy(filePath, pMedia->szFilePath, MSG_FILEPATH_LEN_MAX); + + g_file_get_contents((const gchar *)filePath, &fileContent, NULL, NULL); + + bFiltered = MsgCheckFilterByWord(dbHandle, (const char *)fileContent); + + g_free(fileContent); + fileContent = NULL; + + if (bFiltered == true) + break; + } + } + } + + MsgMmsReleaseMmsLists(mmsMsg); + + return bFiltered; +} + bool MmsPluginInternal::getMmsReport(MmsReport mmsReport) { bool result = false; diff --git a/plugin/mms_plugin/MmsPluginMIME.cpp b/plugin/mms_plugin/MmsPluginMIME.cpp index 02796d2..af59880 100755 --- a/plugin/mms_plugin/MmsPluginMIME.cpp +++ b/plugin/mms_plugin/MmsPluginMIME.cpp @@ -1,140 +1,58 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include #include #include "MmsPluginMIME.h" -#include "MsgDebug.h" +#include "MmsPluginDebug.h" -#include "MmsPluginSmil.h" -#ifndef NULL -#define NULL 0 -#endif +typedef enum _MimeAppType { + MIME_APPLICATION_NONE, + MIME_APPLICATION_CAMERA, + MIME_APPLICATION_VIDEORECORDER, -/* Header field */ -static const char *szMsgField[MSG_FIELD_NUM] = -{ - "Return-Path", - "Message-ID", - "From" , - "To" , - "Cc" , - "Subject", - "Date", - "Mime-Version", - "Content-Type", - "Content-Transfer-Encoding", - "Content-Disposition", //If start param is given in multipart/related, this field will be ignored - "Content-ID", //for start part of multipart/related body - "Content-Location", - "Content-Name", - "Content-Description", - "Content-Vendor", - "Rights-Issuer", - "Return-Receipt-To", /* Delivery confirm */ - "Disposition-Notification-To", /* Read confirm */ - "Content-Rep-Pos", - "Content-Rep-Size", - "Content-Rep-Index" -}; + MIME_APPLICATION_IMAGEVIEWER, + MIME_APPLICATION_FLASHVIEWER, + MIME_APPLICATION_IMAGEEDITOR, + MIME_APPLICATION_THEMEVIEWER, -/* MIME header field parameter */ -static const char *szMsgParam[MSG_PARAM_NUM] = -{ - "charset", - "name", - "filename", - "type", //Only if content-type is multipart/related, - "start", //Only if content-type is multipart/related - "start-info", //Only if content-type is multipart/related - "boundary", - "report-type", // only used as parameter of Content-Type: multipart/report; report-type=delivery-status; -#ifdef FEATURE_JAVA_MMS - "Application-ID", //laconic_javaParamFix - "Reply-To-Application-ID", //laconic_javaParamFix -#endif -}; + MIME_APPLICATION_SOUNDPLAYER, + MIME_APPLICATION_MEDIAPLAYER, + MIME_APPLICATION_VOICEMEMO, -/* Content-Transfer-Encoding header value */ -static const char *szMsgEncoding[MSG_ENCODING_NUM] = -{ - "7bit", - "8bit", - "binary", - "base64", - "quoted-printable" -}; + MIME_APPLICATION_PICSELVIEWER, -/* Content-Disposition header value */ -static const char *szMsgDisposition[MSG_DISPOSITION_NUM] = -{ - "form-data", - "attachment", - "inline" -}; + MIME_APPLICATION_CONTACT, + MIME_APPLICATION_ORGANIZER, -static const char *szMsgAddrType[MSG_ADDR_TYPE_NUM] = -{ - "/TYPE=PLMN", - "", - "/TYPE=IPV4", - "/TYPE=IPV6", - "" -}; + MIME_APPLICATION_MAX +} MimeAppType; -/* character-set value */ -static const char *szMsgCharset [MSG_CHARSET_NUM] = -{ - "us-ascii", - "utf-16", - "usc-2", - "utf-8", - /* MIME character-set value */ - - "iso-2022-kr", - "ks_c_5601-1987", - "euc_kr", - "iso-2022-jp", - "iso-2022-jp-2", - "iso-8859-1", - "iso-8859-2", - "iso-8859-3", - "iso-8859-4", - "iso-8859-5", - "iso-8859-6", - "iso-8859-6-e", - "iso-8859-6-i", - "iso-8859-7", - "iso-8859-8", - "iso-8859-8-i", - "iso-8859-9", - "iso-8859-10", - "iso-8859-15", - "Shift_jis", - "euc-jp", - "gb2312", - "big5", - "win1251", - "window-1251", - "windows-1251", - "koi8-r", - "koi8-u" -}; +typedef struct _MimeTable { + const char *szMIME; + const char *szExt; + bool bDownloadable; + MimeType mime; /* index of mime type */ + MimeType contentType; /* representative mime type */ + MimeAppType appType; + MimeMainType mainType; + int binary; +} MimeTable; /************************************************** MIME definition ***************************************************/ static const MimeTable mimeTable[] = { @@ -188,6 +106,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 }, @@ -215,8 +134,8 @@ static const MimeTable mimeTable[] = { {"audio/amr-wb", "amr", true, MIME_AUDIO_AMR_WB, MIME_AUDIO_AMR_WB, MIME_APPLICATION_VOICEMEMO, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, {"audio/mmf", "mmf", true, MIME_AUDIO_MMF, MIME_AUDIO_MMF, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, {"audio/smaf", "mmf", true, MIME_AUDIO_SMAF, MIME_AUDIO_SMAF, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, - {"audio/iMelody", "imy", true, MIME_AUDIO_IMELODY, MIME_AUDIO_IMELODY, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, - {"audio/imelody", "imy", true, MIME_AUDIO_IMELODY2, MIME_AUDIO_IMELODY, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, + {"audio/imelody", "imy", true, MIME_AUDIO_IMELODY, MIME_AUDIO_IMELODY, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, + {"audio/iMelody", "imy", true, MIME_AUDIO_IMELODY2, MIME_AUDIO_IMELODY, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, {"audio/melody", "imy", true, MIME_AUDIO_MELODY, MIME_AUDIO_IMELODY, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, {"audio/mid", "mid", true, MIME_AUDIO_MID, MIME_AUDIO_MID, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, {"audio/midi", "mid"/*,midi"*/, true, MIME_AUDIO_MIDI, MIME_AUDIO_MID, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, @@ -272,11 +191,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 }, @@ -286,14 +210,15 @@ static const MimeTable mimeTable[] = { {"multipart/voice-message", "", false, MIME_MULTIPART_VOICE_MESSAGE, MIME_MULTIPART_VOICE_MESSAGE, MIME_APPLICATION_NONE, MIME_MAINTYPE_APPLICATION, UNDEFINED_BINARY }, //128 - {"text/txt", "txt", false, MIME_TEXT_TXT, MIME_TEXT_TXT, MIME_APPLICATION_PICSELVIEWER, MIME_MAINTYPE_TEXT, UNDEFINED_BINARY }, + {"text/txt", "", false, MIME_TEXT_TXT, MIME_TEXT_TXT, MIME_APPLICATION_PICSELVIEWER, MIME_MAINTYPE_TEXT, UNDEFINED_BINARY }, {"text/html", "html"/*,htm"*/, false, MIME_TEXT_HTML, MIME_TEXT_HTML, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, 0x02 }, {"text/plain", "txt"/*,vbm,url"*/, false, MIME_TEXT_PLAIN, MIME_TEXT_PLAIN, MIME_APPLICATION_PICSELVIEWER, MIME_MAINTYPE_TEXT, 0x03 }, {"text/css", "", false, MIME_TEXT_CSS, MIME_TEXT_CSS, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, 0x3d }, {"text/xml", "", false, MIME_TEXT_XML, MIME_TEXT_XML, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, 0x28 }, {"text/iMelody", "imy", true, MIME_TEXT_IMELODY, MIME_TEXT_IMELODY, MIME_APPLICATION_SOUNDPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, + {"text/calendar", "ics", true, MIME_TEXT_CALENDAR, MIME_TEXT_CALENDAR, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, UNDEFINED_BINARY }, - //134 + //135 {"text/vnd.wap.wmlscript", "", false, MIME_TEXT_VND_WAP_WMLSCRIPT, MIME_TEXT_VND_WAP_WMLSCRIPT, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, 0x09 }, {"text/vnd.wap.wml", "wml", false, MIME_TEXT_VND_WAP_WML, MIME_TEXT_VND_WAP_WML, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, 0x08 }, {"text/vnd.wap.wta-event", "", false, MIME_TEXT_VND_WAP_WTA_EVENT, MIME_TEXT_VND_WAP_WTA_EVENT, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, 0x0a }, @@ -304,30 +229,32 @@ static const MimeTable mimeTable[] = { {"text/vnd.sun.j2me.app-descriptor", "jad", true, MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR, MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR, MIME_APPLICATION_NONE, MIME_MAINTYPE_ETC, UNDEFINED_BINARY }, - //142 + //143 {"text/x-hdml", "", false, MIME_TEXT_X_HDML, MIME_TEXT_X_HDML, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, 0x04 }, - {"text/x-vCalendar", "vcs", true, MIME_TEXT_X_VCALENDAR, MIME_TEXT_X_VCALENDAR, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, 0x06 }, - {"text/x-vCard", "vcf", true, MIME_TEXT_X_VCARD, MIME_TEXT_X_VCARD, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, 0x07 }, + {"text/x-vCalendar", "vcs", true, MIME_TEXT_X_VCALENDAR, MIME_TEXT_X_VCALENDAR, MIME_APPLICATION_NONE, MIME_MAINTYPE_ETC, 0x06 }, + {"text/x-vCard", "vcf", true, MIME_TEXT_X_VCARD, MIME_TEXT_X_VCARD, MIME_APPLICATION_NONE, MIME_MAINTYPE_ETC, 0x07 }, {"text/x-iMelody", "imy", true, MIME_TEXT_X_IMELODY, MIME_TEXT_X_IMELODY, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, {"text/x-imelody", "imy", true, MIME_TEXT_X_IMELODY2, MIME_TEXT_X_IMELODY, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_AUDIO, UNDEFINED_BINARY }, {"text/x-vnote", "vnt", true, MIME_TEXT_X_VNOTE, MIME_TEXT_X_VNOTE, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, UNDEFINED_BINARY }, + {"text/x-vtodo", "vts", true, MIME_TEXT_X_VTODO, MIME_TEXT_X_VNOTE, MIME_APPLICATION_NONE, MIME_MAINTYPE_TEXT, UNDEFINED_BINARY }, - //148 + //150 {"video/mpeg4", "mp4", true, MIME_VIDEO_MPEG4, MIME_VIDEO_MP4, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/mp4", "mp4", true, MIME_VIDEO_MP4, MIME_VIDEO_MP4, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, - {"video/h263", "3gp"/*,3gpp,mp4"*/,true, MIME_VIDEO_H263, MIME_VIDEO_H263, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, + {"video/h263", ""/*,3gpp,mp4"*/,true, MIME_VIDEO_H263, MIME_VIDEO_H263, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/3gpp", "3gp"/*,3gpp"*/, true, MIME_VIDEO_3GPP, MIME_VIDEO_3GPP, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/3gp", "3gp"/*,3gpp"*/, true, MIME_VIDEO_3GP, MIME_VIDEO_3GP, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/avi", "avi", false, MIME_VIDEO_AVI, MIME_VIDEO_AVI, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/sdp", "sdp", true, MIME_VIDEO_SDP, MIME_APPLICATION_SDP, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/mp4v-es", "3gp", true, MIME_VIDEO_MP4_ES, MIME_VIDEO_3GP, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/mpeg", "3gp", true, MIME_VIDEO_MPEG, MIME_VIDEO_3GP, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, + {"video/quicktime", "mov", true, MIME_VIDEO_MOV, MIME_VIDEO_3GP, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, - // 157 + // 160 {"video/vnd.rn-realvideo", "rm", true, MIME_VIDEO_VND_RN_REALVIDEO, MIME_VIDEO_VND_RN_REALVIDEO, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/vnd.rn-realmedia", "rm", true, MIME_VIDEO_VND_RN_REALMEDIA, MIME_VIDEO_VND_RN_REALMEDIA, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, - //159 + //162 {"video/x-mp4", "mp4", true, MIME_VIDEO_X_MP4, MIME_VIDEO_MP4, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/x-pv-mp4", "mp4", true, MIME_VIDEO_X_PV_MP4, MIME_VIDEO_MP4, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, {"video/x-pn-realvideo", "rv", true, MIME_VIDEO_X_PN_REALVIDEO, MIME_VIDEO_VND_RN_REALVIDEO, MIME_APPLICATION_MEDIAPLAYER, MIME_MAINTYPE_VIDEO, UNDEFINED_BINARY }, @@ -345,83 +272,10 @@ static const int mimeTableIndex[] = { 105, 116, 119, 120, 120, 120, 121, 121, 121, - 128, 134, 142, - 148, 157, 159 + 128, 135, 143, + 150, 160, 162 }; - -/***************** Extension definition *****************/ -static const ExtTable extTable[] = { - - {"txt", MIME_TEXT_PLAIN}, - {"html", MIME_TEXT_HTML}, - {"htm", MIME_TEXT_HTML}, - {"xhtml", MIME_APPLICATION_XHTML_XML}, - {"wml", MIME_TEXT_VND_WAP_WML}, - {"vcs", MIME_TEXT_X_VCALENDAR}, - {"vcf", MIME_TEXT_X_VCARD}, - {"vnt", MIME_TEXT_X_VNOTE}, - {"smil", MIME_APPLICATION_SMIL}, - {"eml", MIME_MESSAGE_RFC822}, - {"gif", MIME_IMAGE_GIF}, - {"jpeg", MIME_IMAGE_JPEG}, - {"jpg", MIME_IMAGE_JPEG}, - {"jpe", MIME_IMAGE_JPEG}, - {"jpz", MIME_IMAGE_JPEG}, - {"tiff", MIME_IMAGE_TIFF}, - {"tif", MIME_IMAGE_TIFF}, - {"png", MIME_IMAGE_PNG}, - {"pnz", MIME_IMAGE_PNG}, - {"wbmp", MIME_IMAGE_VND_WAP_WBMP}, - {"bmp", MIME_IMAGE_BMP}, - {"au", MIME_AUDIO_BASIC}, - {"snd", MIME_AUDIO_BASIC}, - {"mp3", MIME_AUDIO_MP3}, - {"aac", MIME_AUDIO_AAC}, - {"mp4", MIME_AUDIO_MP4}, - {"m4a", MIME_AUDIO_M4A}, - {"amr", MIME_AUDIO_X_AMR}, - {"mmf", MIME_APPLICATION_VND_SMAF}, - {"imy", MIME_AUDIO_X_IMELODY}, - {"mid", MIME_AUDIO_MID}, - {"midi", MIME_AUDIO_MID}, - {"spm", MIME_AUDIO_SP_MIDI}, - {"wav", MIME_AUDIO_WAVE}, - {"3gp", MIME_AUDIO_3GPP}, - {"3gpp", MIME_VIDEO_3GPP}, - {"rm", MIME_VIDEO_VND_RN_REALVIDEO}, - {"ra", MIME_AUDIO_VND_RN_REALAUDIO}, - {"ram", MIME_AUDIO_VND_RN_REALAUDIO}, - {"wma", MIME_AUDIO_X_MS_WMA}, - {"smp", MIME_APPLICATION_STUDIOM}, - {"avi", MIME_VIDEO_AVI}, - {"sdp", MIME_APPLICATION_SDP}, - {"vbm", MIME_TEXT_PLAIN}, - {"url", MIME_TEXT_PLAIN}, - {"jad", MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR}, - {"jar", MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE}, - {"dd", MIME_APPLICATION_VND_OMA_DD_XML}, - {"dm", MIME_APPLICATION_VND_OMA_DRM_MESSAGE}, - {"dcf", MIME_APPLICATION_VND_OMA_DRM_CONTENT}, - {"rv", MIME_VIDEO_X_PN_REALVIDEO}, - {"ro", MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML}, - {"xls", MIME_APPLICATION_X_EXCEL}, - {"pdf", MIME_APPLICATION_PDF}, - {"ppt", MIME_APPLICATION_X_POWERPOINT}, - {"swf", MIME_APPLICATION_X_FLASH}, - {"svg", MIME_IMAGE_SVG}, - {"doc", MIME_APPLICATION_MSWORD}, - {"wmv", MIME_VIDEO_X_MS_WMV}, - {"asf", MIME_VIDEO_X_MS_ASF}, - {"3ga", MIME_AUDIO_M4A}, - {"xmf", MIME_AUDIO_XMF}, - {"mxmf", MIME_AUDIO_MOBILE_XMF}, - {"pvx", MIME_VIDEO_X_PV_PVX}, - {"oro", MIME_APPLICATION_VND_OMA_DRM_RO_XML}, - {"odf", MIME_APPLICATION_VND_OMA_DRM_DCF} -}; - - static int mimeTableEnum[] = { MIME_ASTERISK , @@ -472,6 +326,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 +408,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 , @@ -574,6 +431,7 @@ static int mimeTableEnum[] = MIME_TEXT_CSS , MIME_TEXT_XML , MIME_TEXT_IMELODY , + MIME_TEXT_CALENDAR, MIME_TEXT_VND_WAP_WMLSCRIPT , MIME_TEXT_VND_WAP_WML , MIME_TEXT_VND_WAP_WTA_EVENT , @@ -588,7 +446,7 @@ static int mimeTableEnum[] = MIME_TEXT_X_IMELODY , MIME_TEXT_X_IMELODY2 , MIME_TEXT_X_VNOTE , - + MIME_TEXT_X_VTODO, MIME_VIDEO_MPEG4 , MIME_VIDEO_MP4 , @@ -599,6 +457,7 @@ static int mimeTableEnum[] = MIME_VIDEO_SDP , MIME_VIDEO_MP4_ES, MIME_VIDEO_MPEG , + MIME_VIDEO_MOV , MIME_VIDEO_VND_RN_REALVIDEO , MIME_VIDEO_VND_RN_REALMEDIA , MIME_VIDEO_X_MP4 , @@ -613,8 +472,8 @@ static int mimeTableEnum[] = }; -#define MIME_MAX_NUM 166 -#define EXT_MAX 67 +#define MIME_MAX_NUM 167 +#define EXT_MAX 68 #define MIME_SUB_TYPE_VND 1 #define MIME_SUB_TYPE_X 2 @@ -622,41 +481,6 @@ int __MimeGetTableIndexInt(MimeType mime); int __MimeGetTableIndexString(const char *szMime); MimeMainType __MimeGetMainTypeName(const char *szType); - -/* - * This function checks whether a mime is downloadable or not. - * - * @param mime [in] Enumeration number for a MIME type. - * @return This function returns true if downloadable, or false. - */ -bool MimeIsDownloadableInt(MimeType mime) -{ - int index; - - index = __MimeGetTableIndexInt(mime); - if (index == MIME_UNKNOWN) - return false; - - return mimeTable[index].bDownloadable; -} - -/* - * This function checks whether a mime is downloadable or not. - * - * @param mime [in] MIME string. - * @return This function returns true if downloadable, or false. - */ -bool MimeIsDownloadableString(const char *szMime) -{ - int index; - - index = __MimeGetTableIndexString(szMime); - if (index == MIME_UNKNOWN) - return false; - - return mimeTable[index].bDownloadable; -} - /* * This function checks main type of a MIME. * @@ -674,22 +498,6 @@ MimeMainType MimeGetMainTypeInt(MimeType mime) return mimeTable[index].mainType; } -/* - * This function checks main type of a MIME. - * - * @param mime [in] MIME string. - * @return This function returns main type of a MIME. - */ -MimeMainType MimeGetMainTypeString(const char *szMime) -{ - int index; - - index = __MimeGetTableIndexString(szMime); - if (index == MIME_UNKNOWN) - return MIME_MAINTYPE_ETC; - - return mimeTable[index].mainType; -} /* * This function returns a extension name for a specified MIME. @@ -709,67 +517,6 @@ char *MimeGetExtFromMimeInt(MimeType mime) } /* - * This function returns a extension name for a specified MIME. - * - * @param mime [in] MIME string. - * @return This function returns Extension string. - */ -char *MimeGetExtFromMimeString(const char *szMime) -{ - int index; - - index = __MimeGetTableIndexString(szMime); - if (index == MIME_UNKNOWN) - return NULL; - - return (char *)mimeTable[index].szExt; -} - - -/* - * This function returns a MIME type for a specified Extension. - * - * @param mime [in] Extension string. - * @return This function returns MIME string. - */ -char *MimeGetMimeFromExtString(const char *szExt) -{ - int i; - - for (i = 0; i < EXT_MAX; i++) { - if (!strcasecmp( extTable[i].szExt, szExt)) { - int index; - - index = __MimeGetTableIndexInt(extTable[i].mimeType); - if (index == MIME_UNKNOWN) - return NULL; - - return (char *)mimeTable[index].szMIME; - } - } - - return NULL; -} - -/* - * This function returns a MIME type for a specified Extension. - * - * @param mime [in] Extension string. - * @return This function returns MIME string. - */ -MimeType MimeGetMimeFromExtInt(const char *szExt) -{ - int i; - - for (i = 0; i < EXT_MAX; i++) { - if (!strcasecmp( extTable[i].szExt, szExt)) - return extTable[i].mimeType; - } - - return MIME_UNKNOWN; -} - -/* * This function returns index number in MIME definition table with MIME enumeration. * Internal function. */ @@ -797,8 +544,6 @@ int __MimeGetTableIndexInt(MimeType mime) return tableIndex; } - -#define MIME_MAX_LEN 43 /* * This function returns index number in MIME definition table with MIME string. * Internal function. @@ -836,7 +581,8 @@ int __MimeGetTableIndexString(const char *szMime) free(szMIMEType); return 0; } - strcpy(szMIMEType, szMime); + + strncpy(szMIMEType, szMime, strlen(szMime)); type = 0; subtype = 0; @@ -939,7 +685,7 @@ MimeMainType __MimeGetMainTypeName(const char *szType) } - +//For Decode // MimeString -> MimeInt MimeType MimeGetMimeIntFromMimeString(char *szMimeStr) { @@ -979,22 +725,6 @@ MimeType MimeGetMimeIntFromBi(int binCode) return MIME_UNKNOWN; } -// BinaryCode -> MimeInt -char *MimeGetMimeStringFromBi(int binCode) -{ - int index; - - if (binCode < 0x00 || binCode > 0x4b) - return NULL; - - for (index = 0; index < MIME_MAX_NUM; index++) { - if (binCode == mimeTable[index].binary) - return (char *)mimeTable[index].szMIME; - } - - return NULL; -} - // Mimeint -> Binary Value int MimeGetBinaryValueFromMimeInt(MimeType mime) { @@ -1007,309 +737,146 @@ int MimeGetBinaryValueFromMimeInt(MimeType mime) return mimeTable[index].binary; } -// MimeString -> Binary value -int MimeGetBinaryValueFromMimeString(const char *szMime) -{ - int index; - - index = __MimeGetTableIndexString(szMime); - if (index == MIME_UNKNOWN) - return UNDEFINED_BINARY; - - return mimeTable[index].binary; -} +typedef struct { + const char *szExt; + int mainType; + int enumMime; + const char *szContentType; +} ExtTableItem; + +#define EXT_TABLE_SIZE (56) + +const ExtTableItem extTable[EXT_TABLE_SIZE] = { + + //text + {"txt", MIME_MAINTYPE_TEXT, MIME_TEXT_PLAIN, "text/plain"}, + {"html", MIME_MAINTYPE_TEXT, MIME_TEXT_HTML, "text/html"}, + {"xhtml", MIME_MAINTYPE_TEXT, MIME_APPLICATION_XHTML_XML, "application/xhtml+xml"}, + {"vcs", MIME_MAINTYPE_TEXT, MIME_TEXT_X_VCALENDAR, "text/x-vCalendar"}, + {"vcf", MIME_MAINTYPE_TEXT, MIME_TEXT_X_VCARD, "text/x-vCard"}, + {"vnt", MIME_MAINTYPE_TEXT, MIME_TEXT_X_VNOTE, "text/x-vnote"}, + {"vts", MIME_MAINTYPE_TEXT, MIME_TEXT_X_VTODO, "text/x-vtodo"}, + {"ics", MIME_MAINTYPE_TEXT, MIME_TEXT_CALENDAR, "text/calendar"}, + + //image + {"gif", MIME_MAINTYPE_IMAGE, MIME_IMAGE_GIF, "image/gif"}, + //{"jpg", MIME_MAINTYPE_IMAGE, MIME_IMAGE_JPG, "image/jpg"}, + {"jpg", MIME_MAINTYPE_IMAGE, MIME_IMAGE_JPEG, "image/jpeg"}, + {"jpeg", MIME_MAINTYPE_IMAGE, MIME_IMAGE_JPEG, "image/jpeg"}, + {"tiff", MIME_MAINTYPE_IMAGE, MIME_IMAGE_TIFF, "image/tiff"}, + {"tif", MIME_MAINTYPE_IMAGE, MIME_IMAGE_TIF, "image/tif"}, + {"png", MIME_MAINTYPE_IMAGE, MIME_IMAGE_PNG, "image/png"}, + {"wbmp", MIME_MAINTYPE_IMAGE, MIME_IMAGE_VND_WAP_WBMP, "image/vnd.wap.wbmp"}, + {"bmp", MIME_MAINTYPE_IMAGE, MIME_IMAGE_BMP, "image/bmp"}, + {"svg", MIME_MAINTYPE_IMAGE, MIME_IMAGE_SVG, "image/svg+xml"}, + + //audio + {"snd", MIME_MAINTYPE_AUDIO, MIME_AUDIO_BASIC, "audio/basic"}, + {"amr", MIME_MAINTYPE_AUDIO, MIME_AUDIO_AMR, "audio/amr"}, + {"m4a", MIME_MAINTYPE_AUDIO, MIME_AUDIO_M4A, "audio/m4a"}, + {"3gp", MIME_MAINTYPE_AUDIO, MIME_AUDIO_3GPP, "audio/3gpp"}, + {"3gpp", MIME_MAINTYPE_AUDIO, MIME_AUDIO_3GPP, "audio/3gpp"}, + {"mp3", MIME_MAINTYPE_AUDIO, MIME_AUDIO_MPEG, "audio/mpeg"}, + {"aac", MIME_MAINTYPE_AUDIO, MIME_AUDIO_AAC, "audio/aac"}, + {"imy", MIME_MAINTYPE_AUDIO, MIME_AUDIO_IMELODY, "audio/imelody"}, + {"mid", MIME_MAINTYPE_AUDIO, MIME_AUDIO_MID, "audio/mid"}, + {"mmf", MIME_MAINTYPE_AUDIO, MIME_AUDIO_MMF, "audio/mmf"}, + {"spm", MIME_MAINTYPE_AUDIO, MIME_AUDIO_SP_MIDI, "audio/sp-midi"}, + {"wav", MIME_MAINTYPE_AUDIO, MIME_AUDIO_WAV, "audio/wav"}, + {"mp4", MIME_MAINTYPE_AUDIO, MIME_AUDIO_MP4, "audio/mp4"}, + {"wma", MIME_MAINTYPE_AUDIO, MIME_AUDIO_X_MS_WMA, "audio/x-ms-wma"}, + {"rm", MIME_MAINTYPE_AUDIO, MIME_AUDIO_VND_RN_REALAUDIO, "audio/vnd.rn-realaudio"}, + {"ra", MIME_MAINTYPE_AUDIO, MIME_AUDIO_VND_RN_REALAUDIO, "audio/vnd.rn-realaudio"}, + + //video + {"3gp", MIME_MAINTYPE_VIDEO, MIME_VIDEO_3GPP, "video/3gpp"}, + {"3gpp", MIME_MAINTYPE_VIDEO, MIME_VIDEO_3GPP, "video/3gpp"}, + {"mp4", MIME_MAINTYPE_VIDEO, MIME_VIDEO_MP4, "video/mp4"}, + {"rm", MIME_MAINTYPE_VIDEO, MIME_VIDEO_VND_RN_REALVIDEO, "video/vnd.rn-realvideo"}, + {"rv", MIME_MAINTYPE_VIDEO, MIME_VIDEO_VND_RN_REALVIDEO, "video/vnd.rn-realvideo"}, + {"avi", MIME_MAINTYPE_VIDEO, MIME_VIDEO_AVI, "video/avi"}, + {"asf", MIME_MAINTYPE_VIDEO, MIME_VIDEO_X_MS_ASF, "video/x-ms-asf"}, + {"mov", MIME_MAINTYPE_VIDEO, MIME_VIDEO_MOV, "video/quicktime"}, + + //application + {"smil", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_SMIL, "application/smil"}, + {"rm", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_RN_REALMEDIA, "application/vnd.rn-realmedia"}, + {"ram", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_RAM, "application/ram"}, + {"ppt", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_POWERPOINT, "application/vnd.ms-powerpoint"}, + {"xls", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_EXCEL, "application/vnd.ms-excel"}, + {"doc", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_MSWORD, "applcation/vnd.ms-word"}, + {"pdf", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_PDF, "application/pdf"}, + {"swf", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_X_FLASH, "application/x-shockwave-flash"}, + {"dm", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_OMA_DRM_MESSAGE, "application/vnd.oma.drm.message"}, + {"dcf", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_OMA_DRM_CONTENT, "application/vnd.oma.drm.content"}, + {"dd", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_OMA_DD_XML, "application/vnd.oma.dd+xml"}, + {"ro", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML, "application/vnd.oma.drm.rights+xml"}, + {"ro", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML, "application/vnd.oma.drm.rights+wbxml"}, + {"oro", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_OMA_DRM_RO_XML, "application/vnd.oma.drm.ro+xml"}, + {"odf", MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_OMA_DRM_DCF, "application/vnd.oma.drm.dcf"}, +}; -/* - * This function checks main type of a MIME. - * - * @param mime [in] Enumeration number for a MIME type. - * @return This function returns application type of a MIME. - */ -MimeAppType MimeGetAppTypeFromInt(MimeType mime) +//GetMimeType from File Extension +bool MmsGetMimeTypeFromExt(MimeMainType mainType, const char *pExt, MimeType *pMimeType, const char **ppszMimeType) { - int index; - - index = __MimeGetTableIndexInt(mime); - if (index == MIME_UNKNOWN) - return MIME_APPLICATION_NONE; - - return mimeTable[index].appType; -} + const ExtTableItem *matchedItem = NULL; -/* - * This function checks main type of a MIME. - * - * @param mime [in] MIME string. - * @return This function returns application type of a MIME. - */ -MimeAppType MimeGetAppTypeFromString(const char *szMime) -{ - int index; + if (pExt == NULL) + return false; - index = __MimeGetTableIndexString(szMime); - if (index == MIME_UNKNOWN) - return MIME_APPLICATION_NONE; + if (pMimeType == NULL && ppszMimeType == NULL) + return false; - return mimeTable[index].appType; -} + int extTableMainSize = sizeof(extTable)/sizeof(ExtTableItem); + for (int i = 0; i < extTableMainSize; i++) { -/* - * This function returns a application type for a specified Extension. - * - * @param mime [in] Extension string. - * @return This function returns application type. - */ -MimeAppType MimeGetAppTypeFromExtString(const char *szExt) -{ - int i; + if (strcasecmp(extTable[i].szExt, pExt) == 0) { - for (i = 0; i < EXT_MAX; i++) { - if (!strcasecmp( extTable[i].szExt, szExt)) { - int index; + matchedItem = &extTable[i]; - index = __MimeGetTableIndexInt(extTable[i].mimeType); - if (index == MIME_UNKNOWN) - return MIME_APPLICATION_NONE; - return mimeTable[index].appType; + if (mainType == extTable[i].mainType) { + break; + } } } - return MIME_APPLICATION_NONE; -} + if (matchedItem) { + MSG_DEBUG("Found ext = [%s], mainType = [%d], mimeType = [0x%04x], ContentType = [%s]" + , matchedItem->szExt + , matchedItem->mainType + , matchedItem->enumMime + , matchedItem->szContentType); -/* - * This function gets the representative mime type from MimeType - * - * @param mime [in] Enumeration number for a MIME type. - * @return representative mime type Enumeration number - */ + if (pMimeType) + *pMimeType = (MimeType)matchedItem->enumMime; -MimeType MimeGetContentTypeFromInt(MimeType mime) -{ - int index; + if (ppszMimeType) + *ppszMimeType = matchedItem->szContentType; - for (index = 0; index < MIME_MAX_NUM; index++) { - if (mime == mimeTable[index].mime) - return mimeTable[index].contentType; + return true; } - return MIME_UNKNOWN; + return false; } -/* - * This function gets the representative mime type from mime string - * - * @param szMime - string name of MimeType - * @return representative mime type Enumeration number - */ - -MimeType MimeGetContentTypeFromString(const char *szMime) -{ - int index; - - for (index = 0; index < MIME_MAX_NUM; index++) { - if (!strcasecmp(szMime, mimeTable[index].szMIME)) - return mimeTable[index].contentType; - } - - return MIME_UNKNOWN; -} - -/* - * This function gets the index from mime string - * - * @param szMime - string name of MimeType - * @return Enumeration number for a MIME type. - */ - -MimeType MimeGetMimeTypeFromString(const char *szMime) +bool MmsGetMimeTypeFromFileName(MimeMainType mainType, const char *pFileName, MimeType *pMimeType, const char **ppszMimeType) { - int index; - - for (index = 0; index < MIME_MAX_NUM; index++) { - if (!strcasecmp(szMime, mimeTable[index].szMIME)) - return mimeTable[index].mime; - } + const char *pExt = NULL; - return MIME_UNKNOWN; -} - - -int MsgGetCode(MsgHeaderField tableId, char *pStr) -{ - int cCode = 0; - int nNum = MSG_FIELD_UNKNOWN; - char **pTable = NULL; - - switch (tableId) { - case MSG_FIELD: - nNum = MSG_FIELD_NUM; - pTable = (char **)szMsgField; - break; - - case MSG_PARAM: - nNum = MSG_PARAM_NUM; - pTable = (char **)szMsgParam; - break; - - case MSG_TYPE: - return MimeGetMimeIntFromMimeString(pStr); - - case MSG_CHARSET: - nNum = MSG_CHARSET_NUM; - pTable = (char **)szMsgCharset; - break; - - case MSG_ENCODING: - nNum = MSG_ENCODING_NUM; - pTable = (char **)szMsgEncoding; - break; - - case MSG_DISPOSITION: - nNum = MSG_DISPOSITION_NUM; - pTable = (char **)szMsgDisposition; - break; - - case MSG_ADDR_TYPE: - nNum = MSG_ADDR_TYPE_NUM; - pTable = (char **)szMsgAddrType; - break; - - default: - break; - } - - for (cCode = 0; cCode < nNum; cCode++) { - if (!strcasecmp(pStr, pTable[cCode])) { - return cCode; - } - } - - return -1; -} - - -char *MsgGetString(MsgHeaderField tableId, int code) -{ - int nNum = MSG_FIELD_UNKNOWN; - char **pTable = NULL; - - switch (tableId) { - case MSG_FIELD: - nNum = MSG_FIELD_NUM; - pTable = (char **)szMsgField; - break; - - case MSG_PARAM: - nNum = MSG_PARAM_NUM; - pTable = (char **)szMsgParam; - break; - - case MSG_TYPE: - if (code != MIME_UNKNOWN && code != -1) - return MimeGetMimeStringFromMimeInt(code); - else - return (char *)MSG_UNKNOWN_TYPE_STRING; - - case MSG_CHARSET: - nNum = MSG_CHARSET_NUM; - pTable = (char **)szMsgCharset; - break; - - case MSG_ENCODING: - nNum = MSG_ENCODING_NUM; - pTable = (char **)szMsgEncoding; - break; - - case MSG_DISPOSITION: - nNum = MSG_DISPOSITION_NUM; - pTable = (char **)szMsgDisposition; - break; - - case MSG_ADDR_TYPE: - nNum = MSG_ADDR_TYPE_NUM; - pTable = (char **)szMsgAddrType; - break; - - default: - break; - } - - if (code < 0 || code >= nNum || !pTable) - return (char *)MSG_UNKNOWN_TYPE_STRING; - - return pTable[code]; -} + if (pFileName == NULL) + return false; -char *_MsgSkipWS3(char *s) -{ - while (true) { - if ((*s == MSG_CH_CR) || - (*s == MSG_CH_LF) || - (*s == MSG_CH_SP) || - (*s == MSG_CH_TAB)) - ++s; - else - return s; - } -} + if (pMimeType == NULL && ppszMimeType == NULL) + return false; + pExt = strrchr(pFileName, '.'); -int _MsgGetCode(MsgHeaderField tableId, char *pStr) -{ - int cCode = 0; - int nNum = MSG_FIELD_UNKNOWN; - char **pTable = NULL; - - switch (tableId) { - case MSG_FIELD: - nNum = MSG_FIELD_NUM; - pTable = (char **)szMsgField; - break; - - case MSG_PARAM: - nNum = MSG_PARAM_NUM; - pTable = (char **)szMsgParam; - break; - - case MSG_TYPE: - return MimeGetMimeIntFromMimeString(pStr); - - case MSG_CHARSET: - nNum = MSG_CHARSET_NUM; - pTable = (char **)szMsgCharset; - break; - - case MSG_ENCODING: - nNum = MSG_ENCODING_NUM; - pTable = (char **)szMsgEncoding; - break; - - case MSG_DISPOSITION: - nNum = MSG_DISPOSITION_NUM; - pTable = (char **)szMsgDisposition; - break; - - case MSG_ADDR_TYPE: - nNum = MSG_ADDR_TYPE_NUM; - pTable = (char **)szMsgAddrType; - break; - - default: - MSG_DEBUG("_MsgGetCode: Invalid tableId [%d] \n", tableId); - break; - } + if (pExt == NULL || *(pExt + 1) == '\0') + return false; - for (cCode = 0; cCode < nNum; cCode++) { - if (pTable[cCode] != NULL) { - if (!strcasecmp( pStr, pTable[cCode])) { - return cCode; - } - } - } + pExt = pExt + 1; - return INVALID_HOBJ; + return MmsGetMimeTypeFromExt(mainType, pExt, pMimeType, ppszMimeType); } - diff --git a/plugin/mms_plugin/MmsPluginMain.cpp b/plugin/mms_plugin/MmsPluginMain.cpp index 6d29df9..f3db2cf 100755 --- a/plugin/mms_plugin/MmsPluginMain.cpp +++ b/plugin/mms_plugin/MmsPluginMain.cpp @@ -1,40 +1,33 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -#include -#include #include -#include - +#include "MsgException.h" +#include "MsgGconfWrapper.h" +#include "MsgUtilFile.h" +#include "MsgMmsMessage.h" +#include "MsgSerialize.h" +#include "MmsPluginDebug.h" #include "MmsPluginTypes.h" #include "MmsPluginMain.h" #include "MmsPluginTransport.h" -#include "MsgDebug.h" -#include "MsgException.h" - -#include "MmsPluginMain.h" -#include "MmsPluginMessage.h" #include "MmsPluginStorage.h" #include "MmsPluginInternal.h" #include "MmsPluginEventHandler.h" -#include "MsgGconfWrapper.h" #include "MmsPluginCodec.h" -#include "MsgUtilFile.h" -#include "MmsPluginUserAgent.h" - /*================================================================================================== FUNCTION IMPLEMENTATION @@ -85,7 +78,7 @@ msg_error_t MmsInitialize() MSG_BEGIN(); // remove temp files - MsgMmsInitDir(); + //MsgMmsInitDir(); MSG_END(); @@ -123,6 +116,10 @@ msg_error_t MmsSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo) MmsPluginTransport::instance()->submitRequest(pReqInfo); } catch (MsgException& e) { MSG_FATAL("%s", e.what()); + + if (e.errorCode() == MsgException::REQ_EXIST_ERROR) + return MSG_SUCCESS; + return MSG_ERR_PLUGIN_TRANSPORT; } catch (exception& e) { MSG_FATAL("%s", e.what()); @@ -184,14 +181,14 @@ msg_error_t MmsUpdateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S msg_error_t err = MSG_SUCCESS; try { - if (pMsgInfo->networkStatus == MSG_NETWORK_NOT_SEND) { + if (pMsgInfo->networkStatus == MSG_NETWORK_NOT_SEND || pMsgInfo->networkStatus == MSG_NETWORK_SENDING) { //draft update err = MmsPluginStorage::instance()->updateMessage(pMsgInfo, pSendOptInfo, pFileData); } else { //[Update Message ID & File path only in case of retrieve. Else update Message ID] - if (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { + if (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { //retrieve conf err = MmsPluginStorage::instance()->updateConfMessage(pMsgInfo); } else { - err = MmsPluginStorage::instance()->updateMsgServerID(pMsgInfo, pSendOptInfo); + err = MmsPluginStorage::instance()->updateMsgServerID(pMsgInfo, pSendOptInfo); //update send conf } } } catch (MsgException& e) { @@ -208,14 +205,14 @@ msg_error_t MmsUpdateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S } -msg_error_t MmsGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg) +msg_error_t MmsGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char **pDestMsg) { MSG_BEGIN(); msg_error_t err = MSG_SUCCESS; try { - err = MmsPluginStorage::instance()->plgGetMmsMessage(pMsg, pSendOptInfo, pMmsMsg, pDestMsg); + err = MmsPluginStorage::instance()->getMessage(pMsg, pSendOptInfo, pDestMsg); } catch (MsgException& e) { MSG_FATAL("%s", e.what()); return MSG_ERR_PLUGIN_STORAGE; @@ -288,15 +285,16 @@ msg_error_t MmsComposeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo) return MSG_SUCCESS; } - +//FIXME::It used for kies but not now msg_error_t MmsRestoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char *pRcvBody, int rcvdBodyLen, char *filePath) { MSG_BEGIN(); if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) { FILE *pFile; - _MmsInitHeader(); - _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX); + + MmsInitHeader(); + MmsRegisterDecodeBuffer(); if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) { MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData); @@ -311,7 +309,7 @@ msg_error_t MmsRestoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char *pRcvBody, int rcvd MSG_DEBUG(":::%d :%s ",rcvdBodyLen, pRcvBody); if (filePath) { - snprintf(filePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"BODY_%lu.DATA", random() % 1000000000 + 1); + snprintf(filePath, MAX_FULL_PATH_SIZE, "%sBODY_%lu.DATA", MSG_DATA_PATH, random() % 1000000000 + 1); } else { return MSG_ERR_NULL_POINTER; } @@ -326,3 +324,20 @@ msg_error_t MmsRestoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char *pRcvBody, int rcvd return MSG_SUCCESS; } +msg_error_t MmsDeleteMessage(msg_message_id_t msgId) +{ + MSG_BEGIN(); + + try { + MmsPluginStorage::instance()->deleteMmsMessage(msgId); + } catch (MsgException& e) { + MSG_FATAL("%s", e.what()); + return MSG_ERR_PLUGIN_STORAGE; + } catch (exception& e) { + MSG_FATAL("%s", e.what()); + return MSG_ERR_PLUGIN_STORAGE; + } + + MSG_END(); + return MSG_SUCCESS; +} diff --git a/plugin/mms_plugin/MmsPluginMessage.cpp b/plugin/mms_plugin/MmsPluginMessage.cpp index 46c1c36..a6060c7 100755 --- a/plugin/mms_plugin/MmsPluginMessage.cpp +++ b/plugin/mms_plugin/MmsPluginMessage.cpp @@ -1,217 +1,125 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include #include #include #include -#include +#include +#include -#include "MsgTypes.h" #include "MsgCppTypes.h" -#include "MsgException.h" #include "MsgStorageTypes.h" #include "MsgSettingTypes.h" +#include "MsgUtilFile.h" +#include "MsgGconfWrapper.h" +#include "MsgMmsMessage.h" +#include "MmsPluginTypes.h" +#include "MmsPluginDebug.h" #include "MmsPluginMessage.h" #include "MmsPluginMIME.h" -#include "MmsPluginAvCodec.h" -#include "MsgUtilFile.h" -#include "MsgDebug.h" -#include "MmsPluginCodec.h" #include "MmsPluginStorage.h" -#include "MsgMmsMessage.h" -#include "MsgGconfWrapper.h" - -#include "MmsPluginSMILValidate.h" - - -bool MmsInitMsgAttrib(MmsAttrib *pAttrib) -{ - MSG_DEBUG("MmsInitMsgAttrib"); - - pAttrib->bAskDeliveryReport = false; - - pAttrib->bAskReadReply = false; - pAttrib->bRead = false; - pAttrib->bReportAllowed = false; - pAttrib->readReportAllowedType = MMS_RECEIVE_READ_REPORT_ALLOWED; - pAttrib->readReportSendStatus = MMS_RECEIVE_READ_REPORT_NO_SEND; - pAttrib->bReadReportSent = false; - - pAttrib->bHideAddress = false; - pAttrib->date = 0; - pAttrib->bUseDeliveryCustomTime = false; - pAttrib->deliveryTime.type = MMS_TIMETYPE_RELATIVE; - pAttrib->deliveryTime.time = 0; - pAttrib->bUseExpiryCustomTime = false; - pAttrib->expiryTime.type = MMS_TIMETYPE_RELATIVE; - pAttrib->expiryTime.time = 0; - memset(&pAttrib->expiryTime, 0, sizeof(MmsTimeStruct)); - pAttrib->msgClass = MMS_MSGCLASS_PERSONAL; - pAttrib->msgStatus = MSG_DELIVERY_REPORT_NONE; - pAttrib->priority = MMS_PRIORITY_NORMAL; - pAttrib->responseStatus = MMS_RESPSTATUS_ERROR; - pAttrib->retrieveStatus = MMS_RETRSTATUS_ERROR; - pAttrib->contentType = MIME_UNKNOWN; - pAttrib->msgSize = 0; - pAttrib->bLeaveCopy = true; - - pAttrib->specialMsgType = MMS_SPECIAL_MSG_TYPE_NONE; -#ifdef __SUPPORT_DRM__ - pAttrib->drmType = MSG_DRM_TYPE_NONE; - pAttrib->roWaitingTimerMax = 0; - pAttrib->pszDrmData = NULL; -#endif - pAttrib->version = MMS_VERSION; - - memset(pAttrib->szFrom, 0, MSG_LOCALE_ADDR_LEN + 10); - memset(pAttrib->szResponseText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1); - memset(pAttrib->szRetrieveText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1); - memset(pAttrib->szSubject, 0, MSG_LOCALE_SUBJ_LEN + 1); - pAttrib->szTo = NULL; - pAttrib->szCc = NULL; - pAttrib->szBcc = NULL; - - pAttrib->pMultiStatus = NULL; - - pAttrib->replyCharge.chargeType = MMS_REPLY_NONE; - memset(&pAttrib->replyCharge.deadLine , 0, sizeof(MmsTimeStruct)); - pAttrib->replyCharge.chargeSize = 0; - memset(pAttrib->replyCharge.szChargeID, 0, MMS_MSG_ID_LEN); - - return true; -} - -bool MmsInitMsgType(MsgType *pMsgType) -{ - MSG_DEBUG("MmsInitMsgType"); - pMsgType->offset = 0; - pMsgType->size = 0; - pMsgType->contentSize = 0; - pMsgType->disposition = -1; - pMsgType->encoding = -1; - pMsgType->type = MIME_UNKNOWN; - pMsgType->section = -1; - - pMsgType->szOrgFilePath[0] = '\0'; - pMsgType->szContentID[0] = '\0'; - pMsgType->szContentLocation[0] = '\0'; - - pMsgType->szContentRepPos[0] = '\0'; - pMsgType->szContentRepSize[0] = '\0'; - pMsgType->szContentRepIndex[0] = '\0'; - - MmsInitMsgContentParam(&pMsgType->param); -#ifdef __SUPPORT_DRM__ - __MsgInitMsgDRMInfo(&pMsgType->drmInfo); -#endif - - return true; -} - -bool MmsInitMsgBody(MsgBody *pMsgBody) -{ - MSG_DEBUG("MmsInitMsgBody"); - pMsgBody->offset = 0; - pMsgBody->size = 0; - pMsgBody->body.pText = NULL; - - MmsInitMsgType(&pMsgBody->presentationType); - pMsgBody->pPresentationBody = NULL; - - memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX); - - return true; -} - -bool MmsInitMsgContentParam(MsgContentParam *pMsgContentParam) +#include "MmsPluginUtil.h" +#include "MmsPluginTcs.h" +#include "MsgSmil.h" +#include "MmsPluginAppBase.h" + +#define PRINT_KEY_VAL_STR(key, val)\ +if (val) {\ +MSG_DEBUG("%-20s: %s", key, val);\ +}\ + +#define PRINT_KEY_VAL_INT(key, val)\ +if (val) {\ +MSG_DEBUG("%-20s: %d", key, val);\ +}\ + +static MsgMultipart *MmsGetNthMultipart(MmsMsg *pMsg, int index); +static MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrgFilePath, char *szContentID, char *szContentLocation); +static bool MmsSetMsgAddressList(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S *pMsgInfo); +static char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType); +static bool MmsInsertPresentation(MmsMsg *pMsg, MimeType mimeType, const char *content_id, char *pData, int size); +static bool MmsInsertPartFromMultipart(MmsMsg *pMsg, MMS_MULTIPART_DATA_S *pNewMultipart); +static bool MmsInsertPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DATA_S *pMultipart); +static bool MmsInsertMixedPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DATA_S *pMultipart); +static void printMmsAttribute(MmsAttrib *pAttrib); + +bool convertMediaToMultipart(MMS_MEDIA_S *pSrcMedia, MMS_MULTIPART_DATA_S *pDestMultipart); +bool convertAttachToMultipart(MMS_ATTACH_S *pSrcMedia, MMS_MULTIPART_DATA_S *pDestMultipart); +MMSList * MmsConvertAddressToNewStyle(const char *szAddr); +char *MmsConvertAddressToOldStyle(MMSList *pAddressList); + +void printMmsAttribute(MmsAttrib *pAttrib) { - MSG_DEBUG("MmsInitMsgContentParam"); - pMsgContentParam->charset = MSG_CHARSET_UNKNOWN; - pMsgContentParam->type = MIME_UNKNOWN; - pMsgContentParam->szBoundary[0] = '\0'; - pMsgContentParam->szFileName[0] = '\0'; - pMsgContentParam->szName[0] = '\0'; - pMsgContentParam->szStart[0] = '\0'; - pMsgContentParam->szStartInfo[0] = '\0'; - pMsgContentParam->pPresentation = NULL; - pMsgContentParam->reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; // only used as parameter of Content-Type: multipart/report; report-type -#ifdef FEATURE_JAVA_MMS - pMsgContentParam->szApplicationID = NULL; - pMsgContentParam->szReplyToApplicationID = NULL; -#endif - return true; + MSG_ERR_RET_M(pAttrib == NULL, "attribute is NULL"); + + MSG_DEBUG("# LeaveCopy [%d]", pAttrib->bLeaveCopy); + MSG_DEBUG("# DeliveryTime type [%d], time [%d]", pAttrib->deliveryTime.type, pAttrib->deliveryTime.time); + MSG_DEBUG("# ExpiryTime type [%d], time [%d]", pAttrib->expiryTime.type, pAttrib->expiryTime.time); + MSG_DEBUG("# Priority [%d]", pAttrib->priority); + MSG_DEBUG("# AskDeliveryReport [%d]", pAttrib->bAskDeliveryReport); + MSG_DEBUG("# AskReadReply [%d]", pAttrib->bAskReadReply); } bool MmsSetMsgAddressList(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S * pMsgInfo) { - MSG_DEBUG("MmsSetMsgAddressList"); + MSG_BEGIN(); + pAttrib->szTo = MmsComposeAddress(pMsgInfo, MSG_RECIPIENTS_TYPE_TO); - MSG_DEBUG("To address: %s", pAttrib->szTo); + if (pAttrib->szTo) { + MSG_SEC_DEBUG("To address: %s", pAttrib->szTo); + } + pAttrib->szCc = MmsComposeAddress(pMsgInfo, MSG_RECIPIENTS_TYPE_CC); - MSG_DEBUG("Cc address: %s", pAttrib->szCc); + if (pAttrib->szCc) { + MSG_SEC_DEBUG("Cc address: %s", pAttrib->szCc); + } + pAttrib->szBcc = MmsComposeAddress(pMsgInfo, MSG_RECIPIENTS_TYPE_BCC); - MSG_DEBUG("Bcc address: %s", pAttrib->szBcc); + if (pAttrib->szBcc) { + MSG_SEC_DEBUG("Bcc address: %s", pAttrib->szBcc); + } + MSG_END(); return true; } -void MmsSetMsgMultiStatus(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S *pMsgInfo) -{ - int nAddressCnt = 0; - - nAddressCnt = pMsgInfo->nAddressCnt; - - for (int i = 0; i < nAddressCnt; ++i) { - pAttrib->pMultiStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus)); - - memset(pAttrib->pMultiStatus->szTo, 0, MAX_ADDRESS_VAL_LEN + 1); - strncpy(pAttrib->pMultiStatus->szTo, pMsgInfo->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN); - - MSG_DEBUG("### pMultistatus->szTo = %s ####", pAttrib->pMultiStatus->szTo); - pAttrib->pMultiStatus->bDeliveryReportIsRead = false; - pAttrib->pMultiStatus->bDeliveyrReportIsLast = false; - pAttrib->pMultiStatus->msgStatus = MMS_MSGSTATUS_NONE; - pAttrib->pMultiStatus->handledTime = 0; - pAttrib->pMultiStatus->bReadReplyIsRead = false; - pAttrib->pMultiStatus->bReadReplyIsLast = false; - pAttrib->pMultiStatus->readStatus = MMS_READSTATUS_NONE; - pAttrib->pMultiStatus->readTime = 0; - - pAttrib->pMultiStatus = pAttrib->pMultiStatus->pNext; - } -} - char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType) { - MSG_DEBUG("MmsComposeAddress"); + MSG_BEGIN(); int addrLen = 0; int nAddressCnt = 0; int nRecpCnt = 0; char pString[MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3] = {0, }; char *szCompose; + const char *typePlmn = "/TYPE=PLMN"; nAddressCnt = pMsgInfo->nAddressCnt; // Calculate allocated buffer size for (int i = 0; i < nAddressCnt; ++i) { - MSG_DEBUG("recipientType: %d, address value: %s", pMsgInfo->addressList[i].recipientType, pMsgInfo->addressList[i].addressVal); + + MSG_SEC_DEBUG("recipientType: %d, address value: %s", pMsgInfo->addressList[i].recipientType, pMsgInfo->addressList[i].addressVal); + + if (pMsgInfo->addressList[i].recipientType == MSG_RECIPIENTS_TYPE_UNKNOWN) + pMsgInfo->addressList[i].recipientType = MSG_RECIPIENTS_TYPE_TO; + if (pMsgInfo->addressList[i].recipientType == recipientType) { if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_PLMN) { - addrLen += strlen(MsgGetString(MSG_ADDR_TYPE, MSG_ADDR_TYPE_PHONE)); + addrLen += strlen(typePlmn); addrLen += strlen(pMsgInfo->addressList[i].addressVal); } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) { addrLen += strlen(pMsgInfo->addressList[i].addressVal); @@ -229,57 +137,30 @@ char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType) // Address String copy for (int i = 0; i < nAddressCnt; ++i) { if (pMsgInfo->addressList[i].recipientType == recipientType) { - if (strlen(szCompose) > 0) - strcat(szCompose, MSG_STR_ADDR_DELIMETER); + if (szCompose && strlen(szCompose) > 0) + g_strlcat(szCompose, MSG_STR_ADDR_DELIMETER, addrLen + 1); memset(pString, 0x00, (MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3) * sizeof(char)); if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_PLMN) { - snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s%s", pMsgInfo->addressList[i].addressVal, MsgGetString(MSG_ADDR_TYPE, MSG_ADDR_TYPE_PHONE)); + snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s%s", pMsgInfo->addressList[i].addressVal, typePlmn); MSG_DEBUG("%s", pString); } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) { snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s", pMsgInfo->addressList[i].addressVal); } else ; // Need to consider IPV4, IPV6, and Alias formatted address - strcat(szCompose, pString); + g_strlcat(szCompose, pString, addrLen + 1); } } + MSG_END(); return szCompose; } - -bool MmsGetMsgBodyfromMsgInfo(const MSG_MESSAGE_INFO_S *pMsgInfo, MMS_MESSAGE_DATA_S *pMsgBody, char *pFileData) -{ - MSG_DEBUG("MmsGetMsgBodyfromMsgInfo"); - memset(pMsgBody, 0, sizeof(MMS_MESSAGE_DATA_S)); - - if (pMsgInfo->bTextSms == false) { //if the message body was stored in file. - _MsgMmsDeserializeMessageData(pMsgBody, pFileData); - } - - return true; -} - -int MmsGetSmilRawData(MMS_MESSAGE_DATA_S *pMsgBody, char **pRawdata) +bool MmsInsertPresentation(MmsMsg *pMsg, MimeType mimeType, const char *content_id, char *pData, int size) { MSG_BEGIN(); - if (MsgReadSmilFile(pMsgBody->szSmilFilePath, pRawdata) < 0) - return false; - - MsgDeleteSmilFile(pMsgBody->szSmilFilePath); - - MSG_END(); - - return true; -} - - -bool MmsInsertPresentation(MmsMsg *pMsg, MsgContentType mimeType, char *pData, int size) -{ - MSG_DEBUG("MmsInsertPresentation"); - if (pMsg == NULL) { MSG_DEBUG("pMsg is NULL"); return false; @@ -302,14 +183,21 @@ bool MmsInsertPresentation(MmsMsg *pMsg, MsgContentType mimeType, char *pData, i pMsg->msgBody.pPresentationBody->size = size; pMsg->msgBody.presentationType.type = mimeType; pMsg->msgBody.presentationType.param.charset = MSG_CHARSET_UTF8; - snprintf(pMsg->msgBody.presentationType.szContentID, MSG_MSG_ID_LEN + 1, "<_S_>"); - snprintf(pMsg->msgType.param.szStart, MSG_MSG_ID_LEN + 1, pMsg->msgBody.presentationType.szContentID); + if (content_id && strlen(content_id) > 0) { + snprintf(pMsg->msgBody.presentationType.szContentID, MSG_MSG_ID_LEN + 1, "%s", content_id); + } else { + snprintf(pMsg->msgBody.presentationType.szContentID, MSG_MSG_ID_LEN + 1, "<_S_>");//default + } + + snprintf(pMsg->msgType.param.szStart, MSG_MSG_ID_LEN + 1, "%s", pMsg->msgBody.presentationType.szContentID); + pMsg->msgType.param.type = mimeType; memset(pMsg->msgBody.pPresentationBody->body.pText, 0, size + 1); strncpy(pMsg->msgBody.pPresentationBody->body.pText, pData, size); + MSG_END(); return true; __CATCH: @@ -327,1139 +215,1262 @@ __CATCH: return false; } - -bool MmsInsertPartFromFile(MmsMsg *pMsg, char *szTitleName, char *szOrgFilePath, char *szContentID) +MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrgFilePath, char *szContentID, char *szContentLocation) { - MSG_DEBUG("MmsInsertPartFromFile"); - MsgMultipart *pMultipart = NULL; - MsgMultipart *pLastPart = NULL; - int nFileSize; - MsgContentType mimeType = MIME_UNKNOWN; - char *pExt = NULL; - - pExt = strrchr(szOrgFilePath, '.'); - - if (pExt == NULL || pExt[0] == '\0' || strrchr(pExt, '/')) - mimeType = MIME_UNKNOWN; - else { - if (strcasecmp(pExt, ".dcf") == 0) - mimeType = MIME_APPLICATION_VND_OMA_DRM_CONTENT; - else { - if (MmsGetTypeByFileName((int *)&mimeType, szOrgFilePath) == false) - goto __CATCH; - } - } - if (mimeType == MIME_UNKNOWN) - mimeType = MIME_APPLICATION_OCTET_STREAM; + if ((pMultipart = MmsAllocMultipart()) == NULL) + return NULL; - if (MmsIsMultipart(pMsg->msgType.type) == true) { - /* Insert as a multipart */ - if (MsgGetFileSize(szOrgFilePath, &nFileSize) == false) { - MSG_DEBUG("MsgGetFileSize: failed"); - goto __CATCH; - } + pMultipart->type.type = mimeType; - pMultipart = MmsMakeMultipart(mimeType, szTitleName, szOrgFilePath, NULL, 0, nFileSize, szContentID); - if (pMultipart == NULL) - goto __CATCH; + if (szTitleName && szTitleName[0]) { + memset(pMultipart->type.param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1); + strncpy(pMultipart->type.param.szName, szTitleName, MSG_LOCALE_FILENAME_LEN_MAX); + } - if (pMsg->mmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED || - pMsg->mmsAttrib.contentType == MIME_MULTIPART_MIXED) - pMultipart->type.disposition = MSG_DISPOSITION_ATTACHMENT; + if (szContentID && szContentID[0]) { + memset(pMultipart->type.szContentID, 0, MSG_MSG_ID_LEN + 1); + snprintf(pMultipart->type.szContentID, MSG_MSG_ID_LEN + 1, "<%s>", szContentID); + } - if (pMsg->msgBody.body.pMultipart == NULL) { - pMsg->msgBody.body.pMultipart = pMultipart; - } else { - pLastPart = pMsg->msgBody.body.pMultipart; - while (pLastPart->pNext) { - pLastPart = pLastPart->pNext; - } + if (szContentLocation && szContentLocation[0]) { + memset(pMultipart->type.szContentLocation, 0, MSG_MSG_ID_LEN + 1); + snprintf(pMultipart->type.szContentLocation, MSG_MSG_ID_LEN + 1, "%s", szContentLocation); + } - pLastPart->pNext = pMultipart; + if (MmsIsTextType(mimeType) == true) { + if (!MmsIsVitemContent (mimeType, pMultipart->type.param.szName)) { + pMultipart->type.param.charset = MSG_CHARSET_UTF8; } - - pMsg->msgBody.size += pMultipart->pBody->size; - pMsg->msgType.contentSize += pMultipart->pBody->size; + pMultipart->type.encoding = MSG_ENCODING_8BIT; } else { - /* Single part - Insert as a message body */ - if (pMsg->mmsAttrib.contentType != mimeType || pMsg->msgType.type != mimeType) - goto __CATCH; + pMultipart->type.encoding = MSG_ENCODING_BINARY; + } + + if (szOrgFilePath) { + strncpy(pMultipart->pBody->szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1); + strncpy(pMultipart->type.szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1); + pMultipart->pBody->offset = 0; + pMultipart->pBody->size = MsgGetFileSize(szOrgFilePath); + } + return pMultipart; +} - strncpy(pMsg->msgType.param.szName, szTitleName, MSG_LOCALE_FILENAME_LEN_MAX); +void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID) +{ + MSG_BEGIN(); - 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; - } + struct tm timeInfo; + time_t RawTime = 0; + time_t nTimeInSecs = 0; - strncpy(pMsg->msgBody.szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1); - if (MsgGetFileSize(szOrgFilePath, &nFileSize) == false) { - MSG_DEBUG("MsgGetFileSize: failed"); - goto __CATCH; - } + MmsInitMsgAttrib(&pMmsMsg->mmsAttrib); + MmsInitMsgType(&pMmsMsg->msgType); + MmsInitMsgBody(&pMmsMsg->msgBody); - pMsg->msgBody.offset = 0; - pMsg->msgBody.size = nFileSize; - pMsg->msgType.contentSize = nFileSize; - } + pMmsMsg->msgID = msgID; - pMsg->nPartCount++; + pMmsMsg->mmsAttrib.version = mmsHeader.version; - return true; + // setting date + time(&RawTime); + localtime_r(&RawTime, &timeInfo); + nTimeInSecs = mktime(&timeInfo); -__CATCH: - return false; + pMmsMsg->mmsAttrib.date = nTimeInSecs; -} + pMmsMsg->mmsAttrib.bReportAllowed = (mmsHeader.reportAllowed != MMS_REPORTALLOWED_YES); + pMmsMsg->mmsAttrib.bAskDeliveryReport = (mmsHeader.deliveryReport != MMS_REPORT_YES); -bool MmsIsMultipart(int type) -{ - MSG_DEBUG("MmsIsMultipart"); - if (type == MIME_MULTIPART_RELATED || - type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED || - type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED || - type == MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC || - type == MIME_MULTIPART_MIXED || - type == MIME_MULTIPART_REPORT) { - return true; - } else { - return false; - } -} + MSG_DEBUG("######## Version = %d ########", pMmsMsg->mmsAttrib.version); -bool MmsIsText(int type) -{ - if (type == MIME_TEXT_PLAIN || - type == MIME_TEXT_HTML || - type == MIME_TEXT_VND_WAP_WML || - type == MIME_TEXT_X_VCARD || - type == MIME_TEXT_X_VCALENDAR || - type == MIME_TEXT_X_VNOTE || - type == MIME_APPLICATION_SMIL || - type == MIME_TEXT_X_IMELODY) { - MSG_DEBUG("MmsIsText true."); - return true; - } else { - MSG_DEBUG("MmsIsText false."); - return false; + strncpy(pMmsMsg->szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN); + strncpy(pMmsMsg->szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN); + pMmsMsg->szForwardMsgID[0] = '\0'; + + if (mmsHeader.pFrom) { + MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr ); + strncpy(pMmsMsg->mmsAttrib.szFrom, mmsHeader.pFrom->szAddr, MSG_LOCALE_ADDR_LEN + 9); } -} -bool MmsIsVitemContent (int type, char *pszName) -{ - switch (type) { + strncpy(pMmsMsg->mmsAttrib.szSubject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN); + strncpy(pMmsMsg->szContentLocation, mmsHeader.szContentLocation, MMS_LOCATION_LEN); -/* -* To make Encoding information right. -* case MIME_TEXT_X_VCARD : -* case MIME_TEXT_X_VCALENDAR : -* case MIME_TEXT_X_VNOTE : // vnt -* { -* MSG_DEBUG("MmsIsVitemContent true."); -* return true; -* } -* -*/ - case MIME_TEXT_X_VCARD: - case MIME_TEXT_X_VCALENDAR: - case MIME_TEXT_X_VNOTE: // vnt - case MIME_TEXT_PLAIN: // vbm - It SHOULD be distinguished from a normal text file. - { - char *pszExt = NULL; - - if (!pszName) - break; - - // search file extension. - if ((pszExt = strrchr(pszName, '.')) == NULL) - break; - - if (!strcasecmp(pszExt, ".vbm")) { - MSG_DEBUG("MmsIsVitemContent true."); - return true; - } - } - break; + pMmsMsg->mmsAttrib.msgClass = mmsHeader.msgClass; + pMmsMsg->mmsAttrib.msgSize = mmsHeader.msgSize; + pMmsMsg->mmsAttrib.expiryTime.type = mmsHeader.expiryTime.type; + pMmsMsg->mmsAttrib.expiryTime.time = mmsHeader.expiryTime.time; + pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_NOTIFY; + pMmsMsg->mmsAttrib.bRead = false; + pMmsMsg->mailbox = MSG_INBOX_ID; - default: - break; - } + pMmsMsg->mmsAttrib.replyCharge.chargeType = mmsHeader.replyCharge.chargeType; + pMmsMsg->mmsAttrib.replyCharge.deadLine.type = mmsHeader.replyCharge.deadLine.type; + pMmsMsg->mmsAttrib.replyCharge.deadLine.time = mmsHeader.replyCharge.deadLine.time; + pMmsMsg->mmsAttrib.replyCharge.chargeSize = mmsHeader.replyCharge.chargeSize; - MSG_DEBUG("MmsIsVitemContent false."); - return false; + strncpy(pMmsMsg->mmsAttrib.replyCharge.szChargeID, mmsHeader.replyCharge.szChargeID, MMS_MSG_ID_LEN); + + MSG_END(); } -bool _MsgIsASCII(char *pszText) +void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, msg_message_id_t selectedMsgId) { - int length = strlen(pszText); - - for (int i = 0; i < length; ++i) { - if (!isascii(pszText[i])) { - MSG_DEBUG("_MsgIsASCII false."); - return false; - } - } + struct tm timeInfo; + time_t RawTime = 0; + time_t nTimeInSecs = 0; - MSG_DEBUG("_MsgIsASCII true."); - return true; -} + MmsInitMsgAttrib(&pMmsMsg->mmsAttrib); + MmsInitMsgType(&pMmsMsg->msgType); + MmsInitMsgBody(&pMmsMsg->msgBody); + // setting mmsMsg structure + pMmsMsg->mailbox = pMsgInfo->folderId; + pMmsMsg->msgID = pMsgInfo->msgId; -bool _MsgReplaceNonAscii(char *szInText, char **szOutText, char replaceChar) -{ - MSG_DEBUG("_MsgReplaceNonAscii"); - int nCount = 0; - int index = 0; - int cLen = 0; - char *pNew = NULL; + memset(pMmsMsg->szTrID, 0, MMS_TR_ID_LEN + 1); + memset(pMmsMsg->szContentLocation, 0, MMS_LOCATION_LEN + 1); + memset(pMmsMsg->szForwardMsgID, 0, MMS_MSG_ID_LEN + 1); - cLen = strlen(szInText); + pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT; - pNew = (char *)malloc(cLen + 1); + // setting date + time(&RawTime); + localtime_r(&RawTime, &timeInfo); + nTimeInSecs = mktime(&timeInfo); + pMmsMsg->mmsAttrib.date = nTimeInSecs; - if (pNew == NULL) - return false; + // setting szMsgId + MmsPluginStorage::instance()->getMmsMessageId(selectedMsgId, pMmsMsg); - memset(pNew, 0, cLen + 1); + //setting subject + snprintf(pMmsMsg->mmsAttrib.szSubject, sizeof(pMmsMsg->mmsAttrib.szSubject), "%s", pMsgInfo->subject); - while (*(szInText+nCount) != '\0') { - if (0x0001 <= *(szInText+nCount) && *(szInText+nCount) <= 0x007F) { - MSG_DEBUG("_MsgReplaceNonAscii: non ascii characters (1bytes). \n"); - pNew[index] = szInText[nCount]; - nCount += 1; - index += 1; - } else { - MSG_DEBUG("_MsgReplaceNonAscii: UTF-8 characters (2bytes). \n"); - pNew[index] = replaceChar; - nCount += 1; - index +=1; - } - } + //setting adddress + MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo); - *szOutText = pNew; - return true; + if (pMmsMsg->mmsAttrib.szTo) + snprintf(pMmsMsg->mmsAttrib.szFrom, sizeof(pMmsMsg->mmsAttrib.szFrom), "%s", pMmsMsg->mmsAttrib.szTo); } -bool _MsgIsSpace(char *pszText) +msg_error_t MmsMakeMultipartThumbnailInfo(MMS_MULTIPART_DATA_S *pMultipart, char *thumbnail_path) { - MSG_DEBUG("_MsgIsSpace"); - if (!pszText) { - MSG_DEBUG("_MsgIsSpace: pszText == NULL!\n"); - return false; - } + if (pMultipart == NULL || thumbnail_path == NULL) + return MSG_ERR_NULL_POINTER; - if (strchr(pszText, ' ') != NULL) - return true; - else - return false; -} +// if (MimeGetMainTypeString(MimeGetMimeStringFromMimeInt(pMultipart->type)) != MIME_MAINTYPE_VIDEO) +// return MSG_ERR_INVALID_PARAMETER; -bool _MsgReplaceSpecialChar(char *szInText, char **szOutText, char specialChar) -{ - MSG_DEBUG("_MsgReplaceSpecialChar"); - char *pszOutText = NULL; - char szBuf[10] = {0, }; - char temp[5] = {0, }; - int cLen = 0; - int i = 0; - - if (!szInText) { - MSG_DEBUG("_MsgReplaceSpecialChar: szInText == NULL! \n"); - return false; - } + char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, }; + char szFileNameWoExt[MSG_FILENAME_LEN_MAX+1] = {0, }; + char thumbPath[MSG_FILEPATH_LEN_MAX+1] = {0, }; + char *pszExt = NULL; + char *pszOrgFileName = NULL; - if (!szOutText) - return false; + memset(szFileName, 0x00, MSG_FILENAME_LEN_MAX+1); + memset(thumbPath, 0x00, MSG_FILEPATH_LEN_MAX); - cLen = strlen(szInText); + MSG_DEBUG("drm type = %d, %s", pMultipart->drmType, pMultipart->szFilePath); - if (specialChar == ' ') { - if ((pszOutText = (char *)malloc(cLen + 1)) == NULL) { - MSG_DEBUG("_MsgReplaceSpecialChar : %d line. MemAlloc failed.\n", __LINE__); - return false; + if (pMultipart->drmType == MSG_DRM_TYPE_NONE) { + pszOrgFileName = strrchr(pMultipart->szFilePath, '/'); + pszExt = strrchr(pMultipart->szFilePath, '.'); + + if (NULL == pszOrgFileName || NULL == pszExt) { + MSG_DEBUG("Fail in getting filename without extension string"); + return MSG_ERR_PLUGIN_STORAGE; } - memset(pszOutText, 0, cLen + 1); - *szOutText = pszOutText; - } + strncpy(szFileNameWoExt, pszOrgFileName + 1, strlen(pszOrgFileName + 1) - strlen(pszExt)); + snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "thumb_msg_%s", szFileNameWoExt); - for (i = 0; iszFilePath, thumbPath) == true) { + memcpy(thumbnail_path, &thumbPath, strlen(thumbPath)); + MSG_DEBUG("Generated thumbnail: %s ", thumbnail_path); + return MSG_SUCCESS; + } else { + MSG_DEBUG("Fail of generating thumbnail: %s to %s", pMultipart->szFilePath, thumbPath); } } - MSG_DEBUG("_MsgReplaceSpecialChar : output text : [%s]\n", pszOutText); - - return true; + return MSG_ERR_PLUGIN_STORAGE; } -char *MsgStrAppend(char *szInputStr1, char *szInputStr2) +void MmsPrintFileInfoForVLD(MMS_MESSAGE_DATA_S *pMmsMsg) { - MSG_DEBUG("MsgStrAppend"); - char *szOutputStr = NULL; + MMS_PAGE_S *pPage = NULL; + MMS_MEDIA_S *pMedia = NULL; - if (szInputStr1 == NULL) { - szOutputStr = MsgStrCopy(szInputStr2); - } else { - int length1 = 0; - int length2 = 0; - length1 = MsgStrlen(szInputStr1); - length2 = MsgStrlen(szInputStr2); + if (pMmsMsg == NULL) + return; - szOutputStr = (char *)malloc(length1 + length2 + 1); + if (pMmsMsg->pageCnt > 0) { + for (int i = 0; i < pMmsMsg->pageCnt; i++) { - if (szOutputStr == NULL) - goto __CATCH; + pPage = _MsgMmsGetPage(pMmsMsg, i); - memset(szOutputStr, 0, length1 + length2 + 1); + if (pPage == NULL) + continue; - strncpy(szOutputStr, szInputStr1, length1); + for (int j = 0; j < pPage->mediaCnt; j++) { - if (length2 > 0) - strcat(szOutputStr, szInputStr2); + pMedia = _MsgMmsGetMedia(pPage, j); + if (pMedia == NULL) + continue; - free(szInputStr1); - szInputStr1 = NULL; + MSG_MMS_VLD_FILE("[%s], %d", pMedia->szFilePath, MsgGetFileSize(pMedia->szFilePath)); + } + } } - return szOutputStr; - -__CATCH: - return NULL; + int attachCnt = _MsgMmsGetAttachCount(pMmsMsg); + if (attachCnt > 0) { + for (int i = 0; i < pMmsMsg->attachCnt; i++) { + MMS_ATTACH_S *pAttach = _MsgMmsGetAttachment(pMmsMsg, i); + MSG_MMS_VLD_FILE("[%s], %d", pAttach->szFilePath, MsgGetFileSize(pAttach->szFilePath)); + } + } } -char *MsgStrCopy(const char *string) +bool IsMatchedMedia(MMS_MEDIA_S *media, MMS_MULTIPART_DATA_S *pMultipart) { - char *pDst = NULL; + if (strlen(pMultipart->szContentID) > 0) { - if (string) { - pDst = (char *)malloc(1 + strlen(string)); - if (pDst == NULL) { - MSG_DEBUG("MsgStrCopy: pDst MemAlloc Fail \n"); - return NULL; + char szTempContentID[MSG_MSG_ID_LEN + 1] = {0,}; + MmsRemoveLessGreaterChar(pMultipart->szContentID, szTempContentID, sizeof(szTempContentID)); + + if (strcmp(media->szContentID, szTempContentID) == 0) { + return true; } - memset(pDst, 0, strlen(string) + 1); + if (strcmp(media->szContentLocation, szTempContentID) == 0) { + return true; + } + } - strcpy(pDst,string); + if (strlen(pMultipart->szContentLocation) > 0) { + if (strcmp(media->szContentID, pMultipart->szContentLocation) == 0) { + return true; + } - return pDst; + if (strcmp(media->szContentLocation, pMultipart->szContentLocation) == 0) { + return true; + } } - return NULL; + MSG_DEBUG("There is not matched media cid [%s], cl, [%s], multipart cid [%s], cl, [%s]", media->szContentID, media->szContentLocation, pMultipart->szContentID, pMultipart->szContentLocation); + return false; } -char *MsgStrNCopy(const char *string, int length) +MsgMultipart *MmsGetNthMultipart(MmsMsg *pMsg, int index) { - char *pDst = NULL; + MsgMultipart *pPart = NULL; - if (string) { - pDst = (char *)malloc(1 + length); - if (pDst == NULL) { - MSG_DEBUG("MsgStrNCopy: pDst MemAlloc Fail \n"); - return NULL; - } + if (MsgIsMultipart(pMsg->msgType.type) == true) { + + pPart = pMsg->msgBody.body.pMultipart; - memset(pDst, 0, length + 1); - strncpy(pDst,string, length); + while (pPart && index--) { + pPart = pPart->pNext; + } - return pDst; + if (pPart == NULL) { + MSG_DEBUG("There is no such Multipart [index = %d].", index); + return NULL; + } else { + return pPart; + } + } else { + MSG_DEBUG("This Msg is not Multipart"); } return NULL; } -int MsgStrlen(char * pStr) +bool MmsFindAndInsertPart(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DATA_S *pMultipart) { - if (pStr == NULL) - return 0; + bool insert_media = false; - return strlen(pStr); -} + if (pMsgData->pagelist) { + for (int pageIdx = 0; pageIdx < pMsgData->pageCnt; pageIdx++) { -bool _MsgConvertCharToHex(char pSrc, char *pDest) -{ - static unsigned char saucHex[] = "0123456789ABCDEF"; + MMS_PAGE_S *page = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, pageIdx); - pDest[0] = saucHex[pSrc >> 4]; - pDest[1] = saucHex[pSrc & 0xF]; - pDest[2] = 0; + if (page && page->medialist) { - return true; -} + for (int mediaIdx = 0; mediaIdx < page->mediaCnt; mediaIdx++) { -MsgMultipart *MmsAllocMultipart(void) -{ - MsgMultipart *pMultipart = NULL; + MMS_MEDIA_S *media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, mediaIdx); - pMultipart = (MsgMultipart *)malloc(sizeof(MsgMultipart)); + if (media) { // add media + if (IsMatchedMedia(media, pMultipart) == true) { //matched media - if (pMultipart == NULL) - goto __CATCH; - - pMultipart->pBody = (MsgBody *)malloc(sizeof(MsgBody)); - - if (pMultipart == NULL) - goto __CATCH; +// if (media->mediatype == MMS_SMIL_MEDIA_IMG_OR_VIDEO) { // ref type is not insert part +// MSG_DEBUG("## Matched but media type is ref ##"); +// return false; +// } - MmsInitMsgType(&pMultipart->type); - MmsInitMsgBody(pMultipart->pBody); + insert_media = true; + media->drmType = pMultipart->drmType; + snprintf(media->szFilePath, sizeof(media->szFilePath), "%s", pMultipart->szFilePath); + snprintf(media->szFileName, sizeof(media->szFileName), "%s", pMultipart->szFileName); + snprintf(media->szContentID, sizeof(media->szContentID), "%s", pMultipart->szContentID); + snprintf(media->szContentLocation, sizeof(media->szContentLocation), "%s", pMultipart->szContentLocation); + snprintf(media->szContentType, sizeof(media->szContentType), "%s", pMultipart->szContentType); - pMultipart->pNext = NULL; + MSG_SEC_DEBUG("InsertPart to pageIndx [%d] mediaIdx[%d] media[%p] : path = [%s], name = [%s], cid = [%s], cl = [%s], ct = [%s]"\ + , pageIdx, mediaIdx, media, media->szFilePath, media->szFileName, media->szContentID, media->szContentLocation, media->szContentType); + } + } + } //end for media list + } + } //end for page list + } - return pMultipart; + return insert_media; +} -__CATCH: +bool MmsInsertPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DATA_S *pMultipart) +{ + MSG_BEGIN(); - if (pMultipart) { - if (pMultipart->pBody) { - free(pMultipart->pBody); - pMultipart->pBody = NULL; - } + bool isInsert = false; - free(pMultipart); - pMultipart = NULL; + if (pMsgData == NULL || pMultipart == NULL) { + return false; } - return NULL; -} + isInsert = MmsFindAndInsertPart(pMsgData, pMultipart); + if (isInsert == false) { + MMS_ATTACH_S *attachment = NULL; + attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1); + if (attachment) { + attachment->drmType = pMultipart->drmType; + if (strlen(pMultipart->szContentType) > 0) { + snprintf(attachment->szContentType, sizeof(attachment->szContentType), "%s", pMultipart->szContentType); + attachment->mediatype = pMultipart->type; + } -MsgMultipart *MmsMakeMultipart(MsgContentType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID) -{ - MsgMultipart *pMultipart = NULL; + snprintf(attachment->szFilePath, sizeof(attachment->szFilePath), "%s", pMultipart->szFilePath); + snprintf(attachment->szFileName, sizeof(attachment->szFileName), "%s", pMultipart->szFileName); + attachment->fileSize = MsgGetFileSize(attachment->szFilePath); - if ((pMultipart = MmsAllocMultipart()) == NULL) - goto __CATCH; - - pMultipart->type.type = mimeType; + MSG_SEC_DEBUG("Insert Attach to attachment[%p] : path = [%s], name = [%s], ct = [%s], size = [%d]"\ + , attachment, attachment->szFilePath, attachment->szFileName, attachment->szContentType, attachment->fileSize); - if (szTitleName && szTitleName[0]) { - memset(pMultipart->type.param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1); - strncpy(pMultipart->type.param.szName, szTitleName, MSG_LOCALE_FILENAME_LEN_MAX); + if (_MsgMmsAddAttachment(pMsgData, attachment) != MSG_SUCCESS) { + g_free(attachment); + return false; + } + } else { + return false; + } } - if (szContentID && szContentID[0]) { - memset(pMultipart->type.szContentID, 0, MSG_MSG_ID_LEN + 1); - snprintf(pMultipart->type.szContentID, MSG_MSG_ID_LEN + 1, "<%s>", szContentID); + MSG_END(); + return true; +} - memset(pMultipart->type.szContentLocation, 0, MSG_MSG_ID_LEN + 1); - snprintf(pMultipart->type.szContentLocation, MSG_MSG_ID_LEN + 1, "%s", szContentID); - } +bool MmsInsertMixedPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DATA_S *pMultipart) +{ + MSG_BEGIN(); - if (MmsIsText(mimeType) == true) { - if (!MmsIsVitemContent (mimeType, pMultipart->type.param.szName)) { - pMultipart->type.param.charset = MSG_CHARSET_UTF8; - } - pMultipart->type.encoding = MSG_ENCODING_8BIT; - } else { - pMultipart->type.encoding = MSG_ENCODING_BINARY; + if (pMsgData == NULL || pMultipart == NULL) { + return false; } - if (szOrgFilePath == NULL) { - if (pData != NULL) { - if (MmsIsText(mimeType) == true) { - pMultipart->pBody->body.pText = (char *)malloc(size + 1); - if (pMultipart->pBody->body.pText == NULL) - goto __CATCH; + MimeMainType mainType = MimeGetMainTypeInt(pMultipart->type); + MmsSmilMediaType mediatype = MMS_SMIL_MEDIA_INVALID; - memset(pMultipart->pBody->body.pText, 0, size + 1); - } else { - pMultipart->pBody->body.pBinary = malloc(size); - if (pMultipart->pBody->body.pBinary == NULL) - goto __CATCH; + switch(mainType) { + case MIME_MAINTYPE_AUDIO: + mediatype = MMS_SMIL_MEDIA_AUDIO; + break; + case MIME_MAINTYPE_IMAGE: + mediatype = MMS_SMIL_MEDIA_IMG; + break; + case MIME_MAINTYPE_TEXT: + mediatype = MMS_SMIL_MEDIA_TEXT; + break; + case MIME_MAINTYPE_VIDEO: + mediatype = MMS_SMIL_MEDIA_VIDEO; + break; + default : + mediatype = MMS_SMIL_MEDIA_INVALID; + break; + } - memset(pMultipart->pBody->body.pBinary, 0, size); + if (mediatype != MMS_SMIL_MEDIA_INVALID) { + MMS_PAGE_S *pPage = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S)); + MMS_MEDIA_S *media = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S)); + if (pPage && media) { + media->mediatype = mediatype; + media->drmType = pMultipart->drmType; + snprintf(media->szFilePath, sizeof(media->szFilePath), "%s", pMultipart->szFilePath); + snprintf(media->szFileName, sizeof(media->szFileName), "%s", pMultipart->szFileName); + snprintf(media->szContentID, sizeof(media->szContentID), "%s", pMultipart->szContentID); + snprintf(media->szContentLocation, sizeof(media->szContentLocation), "%s", pMultipart->szContentLocation); + snprintf(media->szContentType, sizeof(media->szContentType), "%s", pMultipart->szContentType); + + MSG_SEC_DEBUG("InsertPart to media[%p] type[%d] : path = [%s], name = [%s], cid = [%s], cl = [%s], ct = [%s]"\ + , media, mediatype, media->szFilePath, media->szFileName, media->szContentID, media->szContentLocation, media->szContentType); + + if (_MsgMmsAddMedia(pPage, media) != MSG_SUCCESS) { + g_free(pPage); + g_free(media); + return false; } - memcpy(pMultipart->pBody->body.pBinary, pData, size); - pMultipart->pBody->size = size; + if (_MsgMmsAddPage(pMsgData, pPage) != MSG_SUCCESS) { + g_free(pPage); + g_free(media); + return false; + } + } else { + if (pPage) g_free(pPage); + if (media) g_free(media); + return false; } } else { - if (szOrgFilePath) - strncpy(pMultipart->pBody->szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1); - - pMultipart->pBody->offset = offset; - pMultipart->pBody->size = size; - } - - return pMultipart; - -__CATCH: - - if (pMultipart) { - if (pMultipart->pBody) { - if (pMultipart->pBody->body.pText) { - free(pMultipart->pBody->body.pText); - pMultipart->pBody->body.pText = NULL; + MMS_ATTACH_S *attachment = NULL; + attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1); + if (attachment) { + attachment->mediatype = pMultipart->type; + attachment->drmType = pMultipart->drmType; + snprintf(attachment->szContentType, sizeof(attachment->szContentType), "%s", pMultipart->szContentType); + snprintf(attachment->szFilePath, sizeof(attachment->szFilePath), "%s", pMultipart->szFilePath); + snprintf(attachment->szFileName, sizeof(attachment->szFileName), "%s", pMultipart->szFileName); + attachment->fileSize = MsgGetFileSize(attachment->szFilePath); + MSG_SEC_DEBUG("Insert Attach to attachment[%p] : path = [%s], name = [%s], ct = [%s], size = [%d]"\ + , attachment, attachment->szFilePath, attachment->szFileName, attachment->szContentType, attachment->fileSize); + + if (_MsgMmsAddAttachment(pMsgData, attachment) != MSG_SUCCESS) { + g_free(attachment); + return false; } - free(pMultipart->pBody); - pMultipart->pBody = NULL; + } else { + return false; } - free(pMultipart); - pMultipart = NULL; } - return NULL; + MSG_END(); + return true; } - -bool MmsGetTypeByFileName(int *type, char *szFileName) +bool MmsInsertPartFromMultipart(MmsMsg *pMsg, MMS_MULTIPART_DATA_S *pNewMultipart) { - char *pExt = NULL; - AvCodecType AvType = AV_CODEC_NONE; + MsgMultipart *pMultipart = NULL; + MsgMultipart *pLastPart = NULL; - /* AVMS unknown or text/image file format identify type from file extention */ + if (MmsIsMultipart(pMsg->msgType.type) == true) { + /* Insert as a multipart */ + pMultipart = MmsMakeMultipart(pNewMultipart->type, pNewMultipart->szFileName, pNewMultipart->szFilePath, pNewMultipart->szContentID, pNewMultipart->szContentLocation); - pExt = strrchr(szFileName, '.'); - if (pExt == NULL || pExt[0] == '\0') - goto __CATCH; + if (pMultipart == NULL) + goto __CATCH; - pExt++; + if (pMsg->mmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED || + pMsg->mmsAttrib.contentType == MIME_MULTIPART_MIXED) + pMultipart->type.disposition = MSG_DISPOSITION_ATTACHMENT; - if (strcasecmp(pExt, "mp4") == 0 || strcasecmp(pExt, "mpeg4") == 0 || - strcasecmp(pExt, "3gp") == 0 || strcasecmp(pExt, "3gpp") == 0) { - /* Audio / Video format. If file exists already, AvGetFileCodecType() can identify the format */ - if (szFileName[0] != '/') - goto __CATCH; + if (pMsg->msgBody.body.pMultipart == NULL) { + pMsg->msgBody.body.pMultipart = pMultipart; + } else { + pLastPart = pMsg->msgBody.body.pMultipart; + while (pLastPart->pNext) { + pLastPart = pLastPart->pNext; + } - AvType = AvGetFileCodecType(szFileName); + pLastPart->pNext = pMultipart; + } - switch (AvType) { - case AV_DEC_AUDIO_MPEG4: - *type = MIME_AUDIO_MP4;//*type = MIME_AUDIO_3GPP; - break; + pMsg->msgBody.size += pMultipart->pBody->size; + pMsg->msgType.contentSize += pMultipart->pBody->size; + } else { + /* Single part - Insert as a message body */ + if (pMsg->mmsAttrib.contentType != pNewMultipart->type || pMsg->msgType.type != pNewMultipart->type) + goto __CATCH; - case AV_DEC_VIDEO_MPEG4: - *type = MIME_VIDEO_MP4; - break; + strncpy(pMsg->msgType.param.szName, pNewMultipart->szFileName, MSG_LOCALE_FILENAME_LEN_MAX); - default: - *type = MIME_VIDEO_3GPP; - break; + if (MmsIsTextType(pMsg->msgType.type) == true) { + pMsg->msgType.param.charset = MSG_CHARSET_UTF8; } - return true; - } - if (strcasecmp(pExt, "amr") == 0) { - *type = MIME_AUDIO_AMR; - return true; - } else if ((strcasecmp(pExt, "mid") == 0) || (strcasecmp(pExt, "midi") == 0)) { - *type = MIME_AUDIO_MIDI; - return true; - } else if (strcasecmp(pExt, "imy") == 0) { - *type = MIME_TEXT_X_IMELODY; - return true; + strncpy(pMsg->msgBody.szOrgFilePath, pNewMultipart->szFilePath, MSG_FILEPATH_LEN_MAX - 1); + pMsg->msgBody.offset = 0; + pMsg->msgBody.size = MsgGetFileSize(pNewMultipart->szFilePath); + pMsg->msgType.contentSize = MsgGetFileSize(pNewMultipart->szFilePath); } - *type = MimeGetMimeFromExtInt((const char *)pExt); + pMsg->nPartCount++; return true; __CATCH: - - *type = MIME_UNKNOWN; return false; } -bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMsgData, char *pFileData) +bool MmsConvertMsgData(MmsMsg *pMsg, MMS_MESSAGE_DATA_S *pMmsMsg) { MSG_BEGIN(); - char *pRawData = NULL; - AutoPtr buf(&pRawData); + //bzero(pMmsMsg, sizeof(MMS_MESSAGE_DATA_S)); + pMmsMsg->regionCnt = 0; + pMmsMsg->pageCnt = 0; + pMmsMsg->attachCnt = 0; + pMmsMsg->transitionCnt = 0; + pMmsMsg->metaCnt = 0; + memset(pMmsMsg->szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX); + + if (pMsg->mmsAttrib.contentType == MIME_MULTIPART_RELATED || pMsg->mmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { + char *pSmilDoc = NULL; + if (pMsg->msgBody.pPresentationBody) { + if (pMsg->msgBody.pPresentationBody->body.pText) { + pSmilDoc = pMsg->msgBody.pPresentationBody->body.pText; + if (pSmilDoc) { + MsgSmilParseSmilDoc(pMmsMsg, pSmilDoc); + } - struct tm *timeInfo = NULL; - time_t RawTime = 0; - time_t nTimeInSecs = 0; + pMmsMsg->smil.type = MIME_APPLICATION_SMIL; + snprintf(pMmsMsg->smil.szContentType, MSG_MSG_ID_LEN, "%s", MimeGetMimeStringFromMimeInt(pMsg->msgBody.presentationType.type)); + snprintf(pMmsMsg->smil.szContentID, MSG_MSG_ID_LEN, "%s", pMsg->msgBody.presentationType.szContentID); + snprintf(pMmsMsg->smil.szContentLocation, MSG_MSG_ID_LEN, "%s", pMsg->msgBody.presentationType.szContentLocation); + snprintf(pMmsMsg->smil.szFileName, MSG_FILENAME_LEN_MAX, "%s", pMsg->msgBody.presentationType.param.szName); + snprintf(pMmsMsg->smil.szFilePath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_DATA_PATH, pMsg->msgBody.presentationType.param.szFileName); + } + } else { + MSG_DEBUG("Not Exist pPresentationBody"); + } + } - msg_error_t err = MSG_SUCCESS; + /*If mms content type is TEXTPLAN add to First Page*/ + if (pMsg->mmsAttrib.contentType == MIME_TEXT_PLAIN) { + MsgType partHeader; + int partCnt = pMsg->nPartCount; - // Initialize mmsMsg structure - MmsInitMsgAttrib(&pMmsMsg->mmsAttrib); - MmsInitMsgType(&pMmsMsg->msgType); - MmsInitMsgBody(&pMmsMsg->msgBody); + if (partCnt <= 0) { + MSG_DEBUG("partCnt=%d\n", partCnt ); + } else { - // setting mmsMsg structure - pMmsMsg->mailbox = pMsgInfo->folderId; - pMmsMsg->msgID = pMsgInfo->msgId; + if (MmsGetMediaPartHeader(0, &partHeader) == false) { + MSG_DEBUG("Failed to get MediaPart MmsGetMediaPartHeader" ); + goto FREE_CATCH; + } - memset(pMmsMsg->szTrID, 0, MMS_TR_ID_LEN + 1); - memset(pMmsMsg->szContentLocation, 0, MMS_LOCATION_LEN + 1); - memset(pMmsMsg->szMsgID, 0, MMS_MSG_ID_LEN + 1); - memset(pMmsMsg->szForwardMsgID, 0, MMS_MSG_ID_LEN + 1); + if (partHeader.contentSize > 0) { + char szBuf[MSG_FILEPATH_LEN_MAX + 1] = {0,}; + MMS_PAGE_S *page = NULL; + MMS_MEDIA_S *media = NULL; - pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT; + snprintf(szBuf, sizeof(szBuf), "%s", partHeader.param.szFileName); + snprintf(partHeader.param.szFileName, sizeof(partHeader.param.szFileName), "%s%s", MSG_DATA_PATH, szBuf); - MSG_DEBUG("## delivery = %d ##", pSendOptInfo->bDeliverReq); - MSG_DEBUG("## read = %d ##", pSendOptInfo->option.mmsSendOptInfo.bReadReq); - MSG_DEBUG("## priority = %d ##", pSendOptInfo->option.mmsSendOptInfo.priority); - MSG_DEBUG("## expiryTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.expiryTime.time); + page = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S)); + if (page == NULL) { + MSG_FATAL("page allocation error"); + goto FREE_CATCH; + } - if (pSendOptInfo->bSetting == false) { - unsigned int expiryTime; - MSG_MMS_DELIVERY_TIME_T deliveryTime; + media = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S)); + if (media == NULL) { + MSG_FATAL("media allocation error"); + free(page); + goto FREE_CATCH; + } - pMmsMsg->mmsAttrib.priority = (MmsPriority)MsgSettingGetInt(MMS_SEND_PRIORITY); + media->mediatype = MMS_SMIL_MEDIA_TEXT; + snprintf(media->szFilePath, sizeof(media->szFilePath), "%s", partHeader.param.szFileName); + snprintf(media->szFileName, sizeof(media->szFileName), "%s", partHeader.param.szName); + snprintf(media->szContentID, sizeof(media->szContentID), "%s", partHeader.szContentID); + snprintf(media->szContentLocation, sizeof(media->szContentLocation), "%s", partHeader.szContentLocation); - MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &pMmsMsg->mmsAttrib.bAskDeliveryReport); - MsgSettingGetBool(MMS_SEND_READ_REPLY, &pMmsMsg->mmsAttrib.bAskReadReply); - MsgSettingGetBool(MSG_KEEP_COPY, &pMmsMsg->mmsAttrib.bLeaveCopy); + _MsgMmsAddMedia(page, media); - expiryTime = (unsigned int)MsgSettingGetInt(MMS_SEND_EXPIRY_TIME); + _MsgMmsAddPage(pMmsMsg, page); + } - if (expiryTime == 0) - pMmsMsg->mmsAttrib.expiryTime.type = MMS_TIMETYPE_NONE; - else { - pMmsMsg->mmsAttrib.expiryTime.type = MMS_TIMETYPE_RELATIVE; - pMmsMsg->mmsAttrib.expiryTime.time = expiryTime; } + } else { - deliveryTime = (MSG_MMS_DELIVERY_TIME_T)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME); + int partCnt = pMsg->nPartCount; - if (deliveryTime == MSG_DELIVERY_TIME_CUSTOM) { - pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = true; + for (int i = 0; i < partCnt; ++i) { - pMmsMsg->mmsAttrib.deliveryTime.type = MMS_TIMETYPE_RELATIVE; - pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY); - } else { - pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = false; + MsgMultipart *multipart = MmsGetNthMultipart(pMsg, i); + MMS_MULTIPART_DATA_S pMultipart; + + if (multipart == NULL) { + MSG_DEBUG("multipart is NULL [%d]", i); + goto FREE_CATCH; + } + + bzero(&pMultipart, sizeof(MMS_MULTIPART_DATA_S)); + + pMultipart.type = (MimeType)multipart->type.type; + MSG_DEBUG("Mime Type : %s :%d", MimeGetMimeStringFromMimeInt(multipart->type.type), multipart->type.type); + snprintf(pMultipart.szContentID, sizeof(pMultipart.szContentID), "%s", multipart->type.szContentID); + snprintf(pMultipart.szContentLocation, sizeof(pMultipart.szContentLocation), "%s", multipart->type.szContentLocation); + snprintf(pMultipart.szFileName, sizeof(pMultipart.szFileName), "%s", multipart->type.param.szName); + snprintf(pMultipart.szFilePath, sizeof(pMultipart.szFilePath), "%s", multipart->pBody->szOrgFilePath); + snprintf(pMultipart.szContentType, sizeof(pMultipart.szContentType), "%s",MimeGetMimeStringFromMimeInt(multipart->type.type)); + + if (multipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { + pMultipart.drmType = multipart->type.drmInfo.drmType; + } - pMmsMsg->mmsAttrib.deliveryTime.type = MMS_TIMETYPE_RELATIVE; - pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)deliveryTime; + _MsgMmsMultipartPrint(&pMultipart); + + if (pMsg->mmsAttrib.contentType == MIME_MULTIPART_RELATED || pMsg->mmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { + if (MmsInsertPartToMmsData(pMmsMsg, &pMultipart) == false) { + MSG_DEBUG("Fail to MmsSetMultipartToMmsData"); + goto FREE_CATCH; + } + } else { + if (MmsInsertMixedPartToMmsData(pMmsMsg, &pMultipart) == false) { + MSG_DEBUG("Fail to MmsSetMultipartToMmsData"); + goto FREE_CATCH; + } + } } - } else { - pMmsMsg->mmsAttrib.priority = (MmsPriority)pSendOptInfo->option.mmsSendOptInfo.priority; - pMmsMsg->mmsAttrib.bAskDeliveryReport = pSendOptInfo->bDeliverReq; - pMmsMsg->mmsAttrib.bAskReadReply = pSendOptInfo->option.mmsSendOptInfo.bReadReq; - pMmsMsg->mmsAttrib.expiryTime.type = pSendOptInfo->option.mmsSendOptInfo.expiryTime.type; - pMmsMsg->mmsAttrib.bLeaveCopy = pSendOptInfo->bKeepCopy; - - if (pMmsMsg->mmsAttrib.expiryTime.type != MMS_TIMETYPE_NONE) - pMmsMsg->mmsAttrib.expiryTime.time = pSendOptInfo->option.mmsSendOptInfo.expiryTime.time; - - pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime; - pMmsMsg->mmsAttrib.deliveryTime.type = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.type; - pMmsMsg->mmsAttrib.deliveryTime.time = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time; } - MSG_DEBUG("pSendOptInfo->bSetting = %d", pSendOptInfo->bSetting); - MSG_DEBUG("pMmsMsg->mmsAttrib.bLeaveCopy = %d", pMmsMsg->mmsAttrib.bLeaveCopy); - MSG_DEBUG("pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = %d", pMmsMsg->mmsAttrib.bUseDeliveryCustomTime); - MSG_DEBUG("pMmsMsg->mmsAttrib.deliveryTime.type = %d", pMmsMsg->mmsAttrib.deliveryTime.type); - MSG_DEBUG("pMmsMsg->mmsAttrib.deliveryTime.time = %d", pMmsMsg->mmsAttrib.deliveryTime.time); - - /* MMS-1.3-con-739 */ - pMmsMsg->mmsAttrib.msgClass = (MmsMsgClass)MsgSettingGetInt(MMS_SEND_MSG_CLASS); - /* MMS-1.3-con-739 */ -#ifdef MMS_13_CON_742_ENABLED - /* MMS-1.3-con-742 */ - pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME); - /* MMS-1.3-con-742 */ -#endif + _MsgMmsRemoveEmptyObject(pMmsMsg); - MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.bAskDeliveryReport = %d @@@", pMmsMsg->mmsAttrib.bAskDeliveryReport); - MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.bAskReadReply = %d @@@", pMmsMsg->mmsAttrib.bAskReadReply); - MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.priority = %d @@@", pMmsMsg->mmsAttrib.priority); + MSG_END(); + return true; +FREE_CATCH: + return false; +} - // setting date - time(&RawTime); - timeInfo = localtime(&RawTime); - nTimeInSecs = mktime(timeInfo); - pMmsMsg->mmsAttrib.date = nTimeInSecs; +void MmsPrintMmsMsg(const MmsMsg *pMmsMsg) +{ + MmsMsgType msgType = pMmsMsg->mmsAttrib.msgType; + if (msgType == MMS_MSGTYPE_SEND_REQ) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_SEND_REQ"); + } else if (msgType == MMS_MSGTYPE_SEND_CONF) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_SEND_CONF"); + } else if (msgType == MMS_MSGTYPE_NOTIFICATION_IND) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_NOTIFICATION_IND"); + } else if (msgType == MMS_MSGTYPE_NOTIFYRESP_IND) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_NOTIFYRESP_IND"); + } else if (msgType == MMS_MSGTYPE_RETRIEVE_CONF) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_RETRIEVE_CONF"); + } else if (msgType == MMS_MSGTYPE_ACKNOWLEDGE_IND) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_ACKNOWLEDGE_IND"); + } else if (msgType == MMS_MSGTYPE_DELIVERY_IND) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_DELIVERY_IND"); + } else if (msgType == MMS_MSGTYPE_READREC_IND) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_READREC_IND"); + } else if (msgType == MMS_MSGTYPE_READORG_IND) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_READORG_IND"); + } else if (msgType == MMS_MSGTYPE_FORWARD_REQ) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_FORWARD_REQ"); + } else if (msgType == MMS_MSGTYPE_FORWARD_CONF) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_FORWARD_CONF"); + } else if (msgType == MMS_MSGTYPE_READ_REPLY) { + PRINT_KEY_VAL_STR("mms type", "MMS_MSGTYPE_READ_REPLY"); + } else { + PRINT_KEY_VAL_STR("mms type", "Unknown"); + } - //setting subject - strcpy(pMmsMsg->mmsAttrib.szSubject, pMsgInfo->subject); + PRINT_KEY_VAL_STR("mms ver", pMmsMsg->mmsAttrib.version); - //setting adddress - MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo); - MmsGetMsgBodyfromMsgInfo(pMsgInfo, pMsgData, pFileData); +} - int pageCnt = _MsgMmsGetPageCount(pMsgData); +int MmsUpdateMultipartList(MSG_MESSAGE_INFO_S *pMsgInfo) +{ + MSG_BEGIN(); + MMSList *multipart_list = NULL; - if (pageCnt == 0) { // Multipart mixed - pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED; - pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED; - } else { // Multipart related + if (MmsPluginStorage::instance()->getMultipartList(pMsgInfo->msgId, &multipart_list) != MSG_SUCCESS) + return -1; - int RawDataSize = 0; + for (int i = 0; i < (int)g_list_length(multipart_list); i++) { + MMS_MULTIPART_DATA_S *pMultipart = (MMS_MULTIPART_DATA_S *)g_list_nth_data(multipart_list, i); + MmsPluginStorage::instance()->updateMultipart(pMsgInfo->msgId, true, pMultipart); + } - time_t RawTime = 0; - time(&RawTime); - snprintf(pMsgData->szSmilFilePath, MSG_FILEPATH_LEN_MAX, "%lu", RawTime); + MSG_END(); + return 0; +} - MsgMMSCreateSMIL(pMsgData); +int MmsUpdatePreviewData(MSG_MESSAGE_INFO_S *pMsgInfo) +{ + MSG_BEGIN(); - RawDataSize = MmsGetSmilRawData(pMsgData, &pRawData); - if (RawDataSize < 0) { - MSG_DEBUG("Smil file size is less than 0"); - return false; - } - MSG_DEBUG("%s", pRawData); - if (pRawData) - MmsInsertPresentation(pMmsMsg, MIME_APPLICATION_SMIL, pRawData, strlen(pRawData)); - - pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED; - pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED; - - for (int i = 0; i < pageCnt; ++i) { - MMS_PAGE_S *pPage = _MsgMmsGetPage(pMsgData, i); - int mediaCnt = pPage->mediaCnt; - MSG_DEBUG("PAGE %d's media Cnt: %d", i+1, mediaCnt); - - for (int j = 0; j < mediaCnt; ++j) { - MMS_MEDIA_S *pMedia = _MsgMmsGetMedia(pPage, j); - - switch (pMedia->mediatype) { - case MMS_SMIL_MEDIA_IMG: - case MMS_SMIL_MEDIA_VIDEO: - case MMS_SMIL_MEDIA_AUDIO: - case MMS_SMIL_MEDIA_TEXT: - if (pMedia->szFilePath[0] != 0) { - if (!MmsInsertPartFromFile(pMmsMsg, pMedia->szFileName, pMedia->szFilePath, pMedia->szContentID)) - return false; - } - break; + char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; - default: - break; - } - } - } + MmsMsg *mmsMsg = NULL; + unique_ptr buf(&mmsMsg, unique_ptr_deleter); + mmsMsg = (MmsMsg *)new char[sizeof(MmsMsg)]; + memset(mmsMsg, 0x00, sizeof(MmsMsg)); - char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };; - snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%d.mms", pMsgInfo->msgId); + MmsPluginStorage::instance()->getMmsRawFilePath(pMsgInfo->msgId, szFullPath, sizeof(szFullPath)); + MmsPluginDecoder::instance()->decodeMmsPdu(mmsMsg, pMsgInfo->msgId, szFullPath); - MmsPluginStorage *pStorage = MmsPluginStorage::instance(); - err = pStorage->getMsgText(pMsgData, pMsgInfo->msgText); - err = pStorage->makeThumbnail(pMsgData, pMsgInfo->thumbPath, szFileName); + {//make Preview info for APP + MmsPluginAppBase appBase(mmsMsg); + appBase.makePreviewInfo(pMsgInfo->msgId, true, szFullPath); + appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); } + MmsReleaseMmsMsg(mmsMsg); + MSG_END(); + return 0; +} -#ifdef FEATURE_JAVA_MMS - MSG_DEBUG("msgAppId: valid:%d appId:%s replyToAppId:%s", pMsgData->msgAppId.valid, pMsgData->msgAppId.appId, pMsgData->msgAppId.replyToAppId); - if (pMsgData->msgAppId.valid) { // check if msgAppId.valid is true, both appId and replytoappId must have a meaning data - if (pMsgData->msgAppId.appId[0] != 0) { - pMmsMsg->msgType.param.szApplicationID = (char *)malloc(strlen(pMsgData->msgAppId.appId) + 1); - if (pMmsMsg->msgType.param.szApplicationID == NULL) { - MSG_DEBUG("Error: out of Memory"); - return false; - } - memset(pMmsMsg->msgType.param.szApplicationID, 0, strlen(pMsgData->msgAppId.appId) + 1); +//MmsMsg -> MMS_DATA_S +bool MmsConvertMmsData(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData) +{ + MSG_BEGIN(); - strcpy(pMmsMsg->msgType.param.szApplicationID, pMsgData->msgAppId.appId); - } + MMS_HEADER_DATA_S *pHeaderData = pMmsData->header; + if (pHeaderData) { - if (pMsgData->msgAppId.replyToAppId[0] != 0) { - pMmsMsg->msgType.param.szReplyToApplicationID = (char *)malloc(strlen(pMsgData->msgAppId.replyToAppId) + 1); - if (pMmsMsg->msgType.param.szReplyToApplicationID == NULL) { - MSG_DEBUG("Error: out of Memory"); - return false; - } - memset(pMmsMsg->msgType.param.szReplyToApplicationID, 0, strlen(pMsgData->msgAppId.replyToAppId) + 1); + snprintf(pHeaderData->messageID, sizeof(pHeaderData->messageID), "%s", pMmsMsg->szMsgID); + snprintf(pHeaderData->trID, sizeof(pHeaderData->trID), "%s", pMmsMsg->szTrID); + snprintf(pHeaderData->contentLocation, sizeof(pHeaderData->contentLocation), "%s", pMmsMsg->szContentLocation); + snprintf(pHeaderData->szContentType, sizeof(pHeaderData->szContentType), "%s", MimeGetMimeStringFromMimeInt(pMmsMsg->mmsAttrib.contentType)); + + pHeaderData->messageType = pMmsMsg->mmsAttrib.msgType; + pHeaderData->mmsVersion = pMmsMsg->mmsAttrib.version; + pHeaderData->messageClass = pMmsMsg->mmsAttrib.msgClass; + pHeaderData->contentClass = 0; + pHeaderData->mmsPriority = pMmsMsg->mmsAttrib.priority; + pHeaderData->expiry.type = pMmsMsg->mmsAttrib.expiryTime.type; + pHeaderData->expiry.time = pMmsMsg->mmsAttrib.expiryTime.time; + + pHeaderData->bDeliveryReport = pMmsMsg->mmsAttrib.bAskDeliveryReport; + pHeaderData->date = pMmsMsg->mmsAttrib.date; + pHeaderData->mmsVersion = pMmsMsg->mmsAttrib.version; - strcpy(pMmsMsg->msgType.param.szReplyToApplicationID, pMsgData->msgAppId.replyToAppId); + pHeaderData->bReadReport = pMmsMsg->mmsAttrib.bAskReadReply; + pHeaderData->bHideAddress = pMmsMsg->mmsAttrib.bHideAddress; + + snprintf(pHeaderData->szSubject, sizeof(pHeaderData->szSubject), "%s", pMmsMsg->mmsAttrib.szSubject); + + pHeaderData->to = MmsConvertAddressToNewStyle(pMmsMsg->mmsAttrib.szTo); + pHeaderData->cc = MmsConvertAddressToNewStyle(pMmsMsg->mmsAttrib.szCc); + pHeaderData->bcc = MmsConvertAddressToNewStyle(pMmsMsg->mmsAttrib.szBcc); + + snprintf(pHeaderData->szFrom, sizeof(pHeaderData->szFrom), "%s", pMmsMsg->mmsAttrib.szFrom); + } + + if (pMmsMsg->mmsAttrib.contentType == MIME_MULTIPART_RELATED || pMmsMsg->mmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { + + MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); + if (pMultipart) { + pMultipart->type = MIME_APPLICATION_SMIL; + snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", "application/smil"); + snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", pMmsMsg->msgBody.presentationType.szContentID); + snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", pMmsMsg->msgBody.presentationType.szContentLocation); + snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", pMmsMsg->msgBody.presentationType.param.szName); + snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), MSG_DATA_PATH"%s", pMmsMsg->msgBody.presentationType.param.szFileName); + + pMmsData->smil = pMultipart; } } -#endif - //Processing Attachment List - 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)) - return false; + int partCnt = pMmsMsg->nPartCount; + + for (int i = 0; i < partCnt; ++i) { + + MsgMultipart *multipart = MmsGetNthMultipart(pMmsMsg, i); + + if (multipart) { + + MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); + + if (pMultipart) { + pMultipart->type = (MimeType)multipart->type.type; + + snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s",MimeGetMimeStringFromMimeInt(multipart->type.type)); + snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", multipart->type.szContentID); + snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", multipart->type.szContentLocation); + snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", multipart->type.param.szName); + snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", multipart->pBody->szOrgFilePath); + +#ifdef __SUPPORT_DRM__ + if (multipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { + pMultipart->drmType = multipart->type.drmInfo.drmType; + } +#endif + pMmsData->multipartlist = g_list_append(pMmsData->multipartlist, pMultipart); + } } } + MSG_END(); return true; } -void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID) +//For Encode raw file +bool MmsConvertMmsMsg(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData) { MSG_BEGIN(); - struct tm *timeInfo = NULL; - time_t RawTime = 0; - time_t nTimeInSecs = 0; - + // Initialize mmsMsg structure MmsInitMsgAttrib(&pMmsMsg->mmsAttrib); MmsInitMsgType(&pMmsMsg->msgType); MmsInitMsgBody(&pMmsMsg->msgBody); - pMmsMsg->msgID = msgID; + pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT; - pMmsMsg->mmsAttrib.version = mmsHeader.version; + MMS_HEADER_DATA_S *pHeaderData = pMmsData->header; - // setting date - time(&RawTime); - timeInfo = localtime(&RawTime); - nTimeInSecs = mktime(timeInfo); - pMmsMsg->mmsAttrib.date = nTimeInSecs; + if (pHeaderData) { - pMmsMsg->mmsAttrib.bReportAllowed = mmsHeader.reportAllowed; - pMmsMsg->mmsAttrib.bAskDeliveryReport = mmsHeader.deliveryReport; + if (strlen(pHeaderData->contentLocation) > 0) { + snprintf(pMmsMsg->szContentLocation, sizeof(pMmsMsg->szContentLocation), "%s", pHeaderData->contentLocation); + } - MSG_DEBUG("######## Version = %d ########", pMmsMsg->mmsAttrib.version); + pMmsMsg->mmsAttrib.contentType = (MimeType)pHeaderData->contentType; + pMmsMsg->msgType.type = pHeaderData->contentType; + pMmsMsg->mmsAttrib.date = pHeaderData->date; + pMmsMsg->mmsAttrib.bAskDeliveryReport = pHeaderData->bDeliveryReport; + pMmsMsg->mmsAttrib.deliveryTime.type = pHeaderData->delivery.type; + pMmsMsg->mmsAttrib.deliveryTime.time = pHeaderData->delivery.time; + pMmsMsg->mmsAttrib.expiryTime.type = pHeaderData->expiry.type; + pMmsMsg->mmsAttrib.expiryTime.time = pHeaderData->expiry.time; + pMmsMsg->mmsAttrib.msgClass = (MmsMsgClass)pHeaderData->messageClass; + + if (strlen(pHeaderData->messageID) > 0) { + snprintf(pMmsMsg->szMsgID, sizeof(pMmsMsg->szMsgID), "%s", pHeaderData->messageID); + } - strncpy(pMmsMsg->szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN); - strncpy(pMmsMsg->szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN); - pMmsMsg->szForwardMsgID[0] = '\0'; + pMmsMsg->mmsAttrib.msgType = (MmsMsgType)pHeaderData->messageType; + pMmsMsg->mmsAttrib.version = pHeaderData->mmsVersion; + pMmsMsg->mmsAttrib.priority = (MmsPriority)pHeaderData->mmsPriority; + pMmsMsg->mmsAttrib.bAskReadReply = pHeaderData->bReadReport; + pMmsMsg->mmsAttrib.bHideAddress = pHeaderData->bHideAddress; - if (mmsHeader.pFrom) { - MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr ); - strncpy(pMmsMsg->mmsAttrib.szFrom, mmsHeader.pFrom->szAddr, MSG_LOCALE_ADDR_LEN + 9); - } + if (strlen(pHeaderData->trID) > 0) { + snprintf(pMmsMsg->szTrID, sizeof(pMmsMsg->szTrID), "%s", pHeaderData->trID); + } - strncpy(pMmsMsg->mmsAttrib.szSubject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN); - strncpy(pMmsMsg->szContentLocation, mmsHeader.szContentLocation, MMS_LOCATION_LEN); - pMmsMsg->mmsAttrib.msgClass = mmsHeader.msgClass; - pMmsMsg->mmsAttrib.msgSize = mmsHeader.msgSize; - pMmsMsg->mmsAttrib.expiryTime.type = mmsHeader.expiryTime.type; - pMmsMsg->mmsAttrib.expiryTime.time = mmsHeader.expiryTime.time; - pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_NOTIFY; - pMmsMsg->mmsAttrib.bRead = false; - pMmsMsg->mailbox = MSG_INBOX_ID; + snprintf(pMmsMsg->mmsAttrib.szSubject, sizeof(pMmsMsg->mmsAttrib.szSubject), "%s", pHeaderData->szSubject); - pMmsMsg->mmsAttrib.replyCharge.chargeType = mmsHeader.replyCharge.chargeType; - pMmsMsg->mmsAttrib.replyCharge.deadLine.type = mmsHeader.replyCharge.deadLine.type; - pMmsMsg->mmsAttrib.replyCharge.deadLine.time = mmsHeader.replyCharge.deadLine.time; - pMmsMsg->mmsAttrib.replyCharge.chargeSize = mmsHeader.replyCharge.chargeSize; + pMmsMsg->mmsAttrib.szTo = MmsConvertAddressToOldStyle(pHeaderData->to); + pMmsMsg->mmsAttrib.szCc = MmsConvertAddressToOldStyle(pHeaderData->cc); + pMmsMsg->mmsAttrib.szBcc = MmsConvertAddressToOldStyle(pHeaderData->bcc); - strncpy(pMmsMsg->mmsAttrib.replyCharge.szChargeID, mmsHeader.replyCharge.szChargeID, MMS_MSG_ID_LEN); + snprintf(pMmsMsg->mmsAttrib.szFrom, sizeof(pMmsMsg->mmsAttrib.szFrom), "%s", pHeaderData->szFrom); + } //CID 41988: Moving all de-referencing of pHeaderData inside null-check block - MSG_END(); -} + printMmsAttribute(&pMmsMsg->mmsAttrib); -bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath) -{ - FILE *pFile = NULL; - MsgMultipart *pMultipart = NULL; - int attachmax = MSG_ATTACH_MAX; - int nSize = 0; + if (pMmsData->multipartlist) { - /* read from MMS raw file */ - if (retrievedFilePath) - strncpy(pMmsMsg->szFileName, retrievedFilePath + strlen(MSG_DATA_PATH), strlen(retrievedFilePath + strlen(MSG_DATA_PATH))); - else - goto __CATCH; + if (pMmsData->smil) { - pFile = MsgOpenFile(retrievedFilePath, "rb"); + MMS_MULTIPART_DATA_S *smil_multipart = pMmsData->smil; - if (pFile == NULL) { - MSG_DEBUG( "_MmsReadMsgBody: invalid mailbox\n"); - goto __CATCH; - } + if (smil_multipart) { - if (MsgGetFileSize(retrievedFilePath, &nSize) == false) { - MSG_DEBUG("MsgGetFileSize: failed"); - goto __CATCH; - } + pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED; + pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED; - _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, - gszMmsLoadBuf2, - MSG_MMS_DECODE_BUFFER_MAX); + gchar *contents = NULL; + gsize length = 0; - if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) { - MSG_DEBUG( "_MmsReadMsgBody: MmsBinaryDecodeMsgHeader fail...\n"); - goto __CATCH; - } + if (MsgAccessFile(smil_multipart->szFilePath, F_OK)) { + g_file_get_contents(smil_multipart->szFilePath, &contents, &length, NULL); - if (MmsBinaryDecodeMsgBody(pFile, retrievedFilePath, nSize) == false) { - MSG_DEBUG( "_MmsReadMsgBody: MmsBinaryDecodeMsgBody fail\n"); - goto __CATCH; - } + MmsInsertPresentation(pMmsMsg, MIME_APPLICATION_SMIL, NULL, contents, length); - /* Set mmsHeader.msgType & msgBody to pMsg ----------- */ + g_free(contents); - pMmsMsg->mmsAttrib.contentType = (MsgContentType)mmsHeader.msgType.type; + } else { + contents = smil_multipart->pMultipartData; + length = smil_multipart->nMultipartDataLen; - memcpy(&(pMmsMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType)); - memcpy(&(pMmsMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody)); + MmsInsertPresentation(pMmsMsg, MIME_APPLICATION_SMIL, NULL, contents, length); + } + } + } else { + pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED; + pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED; + } - MSG_DEBUG("#############################"); - MSG_DEBUG("## pMmsMsg->msgType.type = %d ##", pMmsMsg->msgType.type); - MSG_DEBUG("## pMmsMsg->msgType.szContentID = %s ##", pMmsMsg->msgType.szContentID); - MSG_DEBUG("## pMmsMsg->msgType.szContentLocation = %s ##", pMmsMsg->msgType.szContentLocation); - MSG_DEBUG("#############################"); + int len = g_list_length(pMmsData->multipartlist); - if (pMmsMsg->msgBody.pPresentationBody) { - if(MsgFseek(pFile, pMmsMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0) - goto __CATCH; + for (int i = 0; i < len; i++) { - pMmsMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMmsMsg->msgBody.pPresentationBody->size + 1); - if (pMmsMsg->msgBody.pPresentationBody->body.pText == NULL) - goto __CATCH; + MMS_MULTIPART_DATA_S *multipart = (MMS_MULTIPART_DATA_S *)g_list_nth_data(pMmsData->multipartlist, i); - memset(pMmsMsg->msgBody.pPresentationBody->body.pText, 0, pMmsMsg->msgBody.pPresentationBody->size + 1); - ULONG nRead = 0; - nRead = MsgReadFile(pMmsMsg->msgBody.pPresentationBody->body.pText, sizeof(char), pMmsMsg->msgBody.pPresentationBody->size, pFile); + if (multipart) { + if (multipart->type == MIME_UNKNOWN) + multipart->type = MimeGetMimeIntFromMimeString(multipart->szContentType); - if (nRead == 0) - goto __CATCH; + if (MmsInsertPartFromMultipart(pMmsMsg, multipart) == false) { + return false; + } + } + } //end for } - MsgCloseFile(pFile); - pFile = NULL; + MSG_END(); + return true; +} - /* nPartCount */ - pMmsMsg->nPartCount = 0; +char *MmsConvertAddressToOldStyle(MMSList *pAddressList) +{ + MSG_BEGIN(); + int addrLen = 0; + int nAddressCnt = 0; + char pString[MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3] = {0, }; + char *szCompose = NULL; - if (MsgIsMultipart(mmsHeader.msgType.type) == true) { - pMultipart = pMmsMsg->msgBody.body.pMultipart; - while (pMultipart) { - pMmsMsg->nPartCount++; + nAddressCnt = g_list_length(pAddressList); - if (pMultipart->type.type == MIME_TEXT_PLAIN) - attachmax++; + // Calculate allocated buffer size + for (int i = 0; i < nAddressCnt; ++i) { - if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED) || - (mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) { - if ((pMmsMsg->nPartCount >= attachmax ) && (pMultipart->pNext != NULL)) { - _MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type); + MMS_ADDRESS_DATA_S * pAddressData = (MMS_ADDRESS_DATA_S *)g_list_nth_data(pAddressList, i); + if (pAddressData) { + MSG_SEC_DEBUG("address type : %d, address value: %s", pAddressData->address_type, pAddressData->address_val); + if (pAddressData->address_type == MSG_ADDRESS_TYPE_PLMN) { + addrLen += strlen("/TYPE=PLMN"); + addrLen += strlen(pAddressData->address_val); + } else { + addrLen += strlen(pAddressData->address_val); + } + } + } - free(pMultipart->pNext->pBody); - pMultipart->pNext->pBody = NULL; + if (nAddressCnt > 1) + addrLen = addrLen + nAddressCnt - 1; - free(pMultipart->pNext); + szCompose = (char *)calloc(addrLen + 1, 1); - pMultipart->pNext = NULL; - break; + if (szCompose) { + // Address String copy + for (int i = 0; i < nAddressCnt; ++i) { + MMS_ADDRESS_DATA_S * pAddressData = (MMS_ADDRESS_DATA_S *)g_list_nth_data(pAddressList, i); + + if (pAddressData) { + if (strlen(szCompose) > 0) + g_strlcat(szCompose, MSG_STR_ADDR_DELIMETER, addrLen + 1 - strlen(szCompose)); + + memset(pString, 0x00, (MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3) * sizeof(char)); + if (pAddressData->address_type == MSG_ADDRESS_TYPE_PLMN) { + snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s%s", pAddressData->address_val, "/TYPE=PLMN"); + MSG_DEBUG("%s", pString); + } else { + snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s", pAddressData->address_val); } + + g_strlcat(szCompose, pString, addrLen + 1 - strlen(szCompose)); } - pMultipart = pMultipart->pNext; } - } else { - if (pMmsMsg->msgBody.size > 0) - pMmsMsg->nPartCount++; } - //call before processing urgent event. - _MmsInitHeader(); - _MmsUnregisterDecodeBuffer(); + MSG_END(); + return szCompose; - return true; +} -__CATCH: +MMSList * MmsConvertAddressToNewStyle(const char *szAddr) +{ + MMSList *pAddressList = NULL; + MMS_ADDRESS_DATA_S *pAddressData = NULL; - _MmsInitHeader(); - _MmsUnregisterDecodeBuffer(); + char *pTempChar = NULL; + char *pStartPtr= NULL; + char *pEndPtr= NULL; - if (pFile != NULL) { - MsgCloseFile(pFile); - pFile = NULL; - } + if (szAddr == NULL) + return NULL; - _MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type); - MSG_DEBUG("_MmsReadMsgBody: E N D ( fail ) ******************** \n"); + pTempChar = strdup(szAddr); - return false; -} + pStartPtr = pTempChar; -#ifdef MMS_DELIEVERY_IND_ENABLED -MmsMsgMultiStatus *MmsComposeDeliveryIndMessage(MmsMsg *pMmsMsg, msg_message_id_t msgId) -{ - MmsMsgMultiStatus *pStatus = NULL; - MmsMsgMultiStatus *pLastStatus = NULL; - bool bFound = false; + while (pStartPtr && pStartPtr[0]) { - MmsInitMsgAttrib(&pMmsMsg->mmsAttrib); - MmsInitMsgType(&pMmsMsg->msgType); - MmsInitMsgBody(&pMmsMsg->msgBody); + int addLen = 0; + char tempAddress[512] = {0,}; + char tempAddress2[512] = {0,}; - pMmsMsg->mmsAttrib.version = mmsHeader.version; + pEndPtr = strchr(pStartPtr, MSG_CH_SEMICOLON); - pMmsMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(msgId); + if (pEndPtr) { + addLen = pEndPtr - pStartPtr; + } else { + addLen = strlen(pStartPtr); + } - pStatus = pMmsMsg->mmsAttrib.pMultiStatus; + if (addLen) { + strncpy(tempAddress, pStartPtr, addLen); + int addr_type; + int addLen2; + char *pSlash = strchr(tempAddress, '/'); - MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo); + if (pSlash) { + addLen2 = pSlash - tempAddress; + addr_type = MSG_ADDRESS_TYPE_PLMN; + } else { + addLen2 = strlen(tempAddress); + addr_type = MSG_ADDRESS_TYPE_EMAIL; + } - while (pStatus && !bFound) { - MSG_DEBUG("### MmsAddrUtilCompareAddr ###"); - MSG_DEBUG("### mmsHeader.pTo->szAddr = %s ###", mmsHeader.pTo->szAddr); - if (MmsAddrUtilCompareAddr(pStatus->szTo, mmsHeader.pTo->szAddr)) { - bFound = true; + if (addLen2) { + strncpy(tempAddress2, tempAddress, addLen2); + pAddressData = MsgMmsCreateAddress(addr_type, tempAddress2); + } + + if (pAddressData) + pAddressList = g_list_append(pAddressList, pAddressData); + + pStartPtr = pStartPtr + addLen + 1; + } else { break; } - - pStatus = pStatus->pNext; } - if (bFound == false) { - MSG_DEBUG("### bFound == false ###"); - /* Queue the delivery report --------------------------- */ + if (pTempChar) + free(pTempChar); + + MSG_END(); + return pAddressList; +} + +bool convertMediaToMultipart(MMS_MEDIA_S *pSrcMedia, MMS_MULTIPART_DATA_S *pDestMultipart) +{ + bzero(pDestMultipart, sizeof(MMS_MULTIPART_DATA_S)); - pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus)); - memset(pStatus, 0, sizeof(MmsMsgMultiStatus)); + snprintf(pDestMultipart->szContentID, sizeof(pDestMultipart->szContentID), "%s", pSrcMedia->szContentID); + snprintf(pDestMultipart->szContentLocation, sizeof(pDestMultipart->szContentLocation), "%s", pSrcMedia->szContentLocation); + snprintf(pDestMultipart->szFileName, sizeof(pDestMultipart->szFileName), "%s", pSrcMedia->szFileName); + snprintf(pDestMultipart->szFilePath, sizeof(pDestMultipart->szFilePath), "%s", pSrcMedia->szFilePath); - pStatus->readStatus = MMS_READSTATUS_NONE; - memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1); - strncpy(pStatus->szTo, mmsHeader.pTo->szAddr, MSG_ADDR_LEN); + if (strlen(pSrcMedia->szContentType) > 0) { + snprintf(pDestMultipart->szContentType, sizeof(pDestMultipart->szContentType), "%s", pSrcMedia->szContentType); + pDestMultipart->type = MimeGetMimeIntFromMimeString(pSrcMedia->szContentType); - if (pMmsMsg->mmsAttrib.pMultiStatus == NULL) { - /* first delivery report */ - pMmsMsg->mmsAttrib.pMultiStatus = pStatus; + } else { + MimeMainType mainType = MIME_MAINTYPE_UNKNOWN; + MimeType pMimeType = MIME_UNKNOWN; + const char *pszMimeType = NULL; + + if (pSrcMedia->mediatype == MMS_SMIL_MEDIA_IMG) + mainType = MIME_MAINTYPE_IMAGE; + else if (pSrcMedia->mediatype == MMS_SMIL_MEDIA_AUDIO) + mainType = MIME_MAINTYPE_AUDIO; + else if (pSrcMedia->mediatype == MMS_SMIL_MEDIA_VIDEO) + mainType = MIME_MAINTYPE_VIDEO; + else if (pSrcMedia->mediatype == MMS_SMIL_MEDIA_TEXT) + mainType = MIME_MAINTYPE_TEXT; + + MmsGetMimeTypeFromFileName(mainType, pSrcMedia->szFilePath, &pMimeType, &pszMimeType); + + if (pszMimeType) { + snprintf(pDestMultipart->szContentType, sizeof(pDestMultipart->szContentType), "%s", pszMimeType); + pDestMultipart->type = pMimeType; } else { - pLastStatus = pMmsMsg->mmsAttrib.pMultiStatus; - while (pLastStatus->pNext) { - pLastStatus = pLastStatus->pNext; - } + snprintf(pDestMultipart->szContentType, sizeof(pDestMultipart->szContentType), "%s", "application/octet-stream"); + pDestMultipart->type = MIME_APPLICATION_OCTET_STREAM; + } + } + + return true; +} + +bool convertAttachToMultipart(MMS_ATTACH_S *pSrcMedia, MMS_MULTIPART_DATA_S *pDestMultipart) +{ + bzero(pDestMultipart, sizeof(MMS_MULTIPART_DATA_S)); - pLastStatus->pNext = pStatus; - pLastStatus = pStatus; + snprintf(pDestMultipart->szFileName, sizeof(pDestMultipart->szFileName), "%s", pSrcMedia->szFileName); + snprintf(pDestMultipart->szFilePath, sizeof(pDestMultipart->szFilePath), "%s", pSrcMedia->szFilePath); + + if (strlen(pSrcMedia->szContentType) > 0) { + snprintf(pDestMultipart->szContentType, sizeof(pDestMultipart->szContentType), "%s", pSrcMedia->szContentType); + pDestMultipart->type = MimeGetMimeIntFromMimeString(pSrcMedia->szContentType); + } else { + + MimeMainType mainType = MIME_MAINTYPE_UNKNOWN; + MimeType pMimeType = MIME_UNKNOWN; + const char *pszMimeType = NULL; + + MmsGetMimeTypeFromFileName(mainType, pSrcMedia->szFilePath, &pMimeType, &pszMimeType); + + if (pszMimeType) { + snprintf(pDestMultipart->szContentType, sizeof(pDestMultipart->szContentType), "%s", pszMimeType); + pDestMultipart->type = pMimeType; + } else { + snprintf(pDestMultipart->szContentType, sizeof(pDestMultipart->szContentType), "%s", "application/octet-stream"); + pDestMultipart->type = MIME_APPLICATION_OCTET_STREAM; } } - pStatus->handledTime = mmsHeader.date; - pStatus->msgStatus = mmsHeader.msgStatus; - pStatus->bDeliveryReportIsRead = false; + return true; +} + +bool convertMsgMultipartToMultipart(MsgMultipart *pSrcMultipart, MMS_MULTIPART_DATA_S *pDestMultipart) +{ + pDestMultipart->type = (MimeType)pSrcMultipart->type.type; - _MmsDataUpdateLastStatus(pMmsMsg); + MSG_DEBUG("Mime Type : %s :%d", MimeGetMimeStringFromMimeInt(pSrcMultipart->type.type), pSrcMultipart->type.type); + snprintf(pDestMultipart->szContentID, sizeof(pDestMultipart->szContentID), "%s", pSrcMultipart->type.szContentID); + snprintf(pDestMultipart->szContentLocation, sizeof(pDestMultipart->szContentLocation), "%s", pSrcMultipart->type.szContentLocation); + snprintf(pDestMultipart->szFileName, sizeof(pDestMultipart->szFileName), "%s", pSrcMultipart->type.param.szName); + snprintf(pDestMultipart->szFilePath, sizeof(pDestMultipart->szFilePath), "%s", pSrcMultipart->pBody->szOrgFilePath); - pStatus->bDeliveyrReportIsLast = true; + snprintf(pDestMultipart->szContentType, sizeof(pDestMultipart->szContentType), "%s", MimeGetMimeStringFromMimeInt(pSrcMultipart->type.type)); - return pStatus; + if (pSrcMultipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { + pDestMultipart->drmType = pSrcMultipart->type.drmInfo.drmType; + } + + return true; } -#endif -void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, msg_message_id_t selectedMsgId) +gint __compare_str(gconstpointer a, gconstpointer b) { - struct tm *timeInfo = NULL; - time_t RawTime = 0; - time_t nTimeInSecs = 0; + return g_strcmp0((char *)a, (char *)b); +} - MmsInitMsgAttrib(&pMmsMsg->mmsAttrib); - MmsInitMsgType(&pMmsMsg->msgType); - MmsInitMsgBody(&pMmsMsg->msgBody); +// change file name to Ascii & space -> '_' +// If replaced filename is duplicated, then it append number +bool MmsChangeFileNameToAscii(MMS_MESSAGE_DATA_S *pMsgData) +{ + int pageCnt; + int mediaCnt; + int attachCnt; - // setting mmsMsg structure - pMmsMsg->mailbox = pMsgInfo->folderId; - pMmsMsg->msgID = pMsgInfo->msgId; + GList *r_list = NULL;//renamed file list - memset(pMmsMsg->szTrID, 0, MMS_TR_ID_LEN + 1); - memset(pMmsMsg->szContentLocation, 0, MMS_LOCATION_LEN + 1); - memset(pMmsMsg->szForwardMsgID, 0, MMS_MSG_ID_LEN + 1); + pageCnt = g_list_length(pMsgData->pagelist); - pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT; + for (int i = 0; i < pageCnt; i++) { + MMS_PAGE_S *pPage = NULL; + pPage = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, i); + if (pPage == NULL) { + //CID 355351: Freeing r_list in case of error too to prevent memory leak + if (r_list != NULL) + g_list_free(r_list); + return false; + } - // setting date - time(&RawTime); - timeInfo = localtime(&RawTime); - nTimeInSecs = mktime(timeInfo); - pMmsMsg->mmsAttrib.date = nTimeInSecs; + mediaCnt = g_list_length(pPage->medialist); + for (int j = 0; j < mediaCnt; j++) { + MMS_MEDIA_S *pMedia = NULL; + pMedia = (MMS_MEDIA_S *)g_list_nth_data(pPage->medialist, j); + if (pMedia == NULL) { + //CID 355351: Freeing r_list in case of error too to prevent memory leak + if (r_list != NULL) + g_list_free(r_list); + return false; + } - // setting szMsgId - MmsPluginStorage::instance()->getMmsMessageId(selectedMsgId, pMmsMsg); + if (strlen(pMedia->szFileName) > 0) { + char *str = NULL; - //setting subject - strcpy(pMmsMsg->mmsAttrib.szSubject, pMsgInfo->subject); + MmsReplaceSpaceChar(pMedia->szFileName); - //setting adddress - MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo); + str = MmsReplaceNonAsciiUtf8(pMedia->szFileName, '_'); - if (pMmsMsg->mmsAttrib.szTo) - strncpy(pMmsMsg->mmsAttrib.szFrom, pMmsMsg->mmsAttrib.szTo, strlen(pMmsMsg->mmsAttrib.szTo)); -} + if (str) { + int count = 1; + char *str2 = g_strdup(str); + char *ext = strrchr(str, '.'); -int MmsSearchMsgId(char *toNumber, char *szMsgID) -{ - MSG_BEGIN(); + if (ext == NULL || *(ext + 1) == '\0') { + ext = NULL; + } else { + *ext = '\0'; + ext = ext + 1; + } - int msgId; + while (g_list_find_custom(r_list, str2, __compare_str) != NULL) { - msgId = MmsPluginStorage::instance()->searchMsgId(toNumber, szMsgID); + g_free(str2); - if (msgId < 0) - return 0; + if (ext) + str2 = g_strdup_printf("%s_%d.%s", str, count++, ext); + else + str2 = g_strdup_printf("%s_%d", str, count++); + } - MSG_END(); + g_free(str); - return msgId; -} + snprintf(pMedia->szFileName, sizeof(pMedia->szFileName), "%s", str2); -void MmsUpdateDeliveryReport(msg_message_id_t msgId, MmsMsgMultiStatus *pStatus) -{ - MSG_BEGIN(); + MSG_DEBUG("replace filename [%s]", pMedia->szFileName); - MmsPluginStorage::instance()->updateDeliveryReport(msgId, pStatus); + r_list = g_list_append(r_list, pMedia->szFileName); - MSG_END(); -} + g_free(str2); + } + } + }//end for media + }//end for page + + attachCnt = g_list_length(pMsgData->attachlist); + for (int i = 0; i < attachCnt; i++) { + MMS_ATTACH_S *pAttach = NULL; + pAttach = (MMS_ATTACH_S *)g_list_nth_data(pMsgData->attachlist, i); + if (pAttach == NULL) { + //CID 355351: Freeing r_list in case of error too to prevent memory leak + if(r_list != NULL) + g_list_free(r_list); + return false; + } -void MmsUpdateReadReport(msg_message_id_t msgId, MmsMsgMultiStatus *pStatus) -{ - MSG_BEGIN(); + if (strlen(pAttach->szFileName) > 0) { + char *str = NULL; - MmsPluginStorage::instance()->updateReadReport(msgId, pStatus); + MmsReplaceSpaceChar(pAttach->szFileName); - MSG_END(); -} + str = MmsReplaceNonAsciiUtf8(pAttach->szFileName, '_'); + if (str) { + int count = 1; + char *str2 = g_strdup(str); + char *ext = strrchr(str, '.'); -MmsMsgMultiStatus *MmsGetMultiStatus(msg_message_id_t msgId) -{ - MmsMsgMultiStatus *pMultiStatus; + if (ext == NULL || *(ext + 1) == '\0') { + ext = NULL; + } else { + *ext = '\0'; + ext = ext + 1; + } - pMultiStatus = MmsPluginStorage::instance()->getMultiStatus(msgId); + while (g_list_find_custom(r_list, str2, __compare_str) != NULL) { - MSG_DEBUG("### szTo = %s ###", pMultiStatus->szTo); + g_free(str2); - MSG_END(); + if (ext) + str2 = g_strdup_printf("%s_%d.%s", str, count++, ext); + else + str2 = g_strdup_printf("%s_%d", str, count++); + } - return pMultiStatus; -} + g_free(str); -bool MmsCheckAdditionalMedia(MMS_MESSAGE_DATA_S *pMsgData, MsgType *partHeader) -{ - if (_MsgMmsFindMatchedMedia(pMsgData, partHeader->param.szFileName)) - return false; - else - return true; -} + snprintf(pAttach->szFileName, sizeof(pAttach->szFileName), "%s", str2); -#ifdef __SUPPORT_DRM__ -bool __MsgInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo) -{ - pMsgDrmInfo->contentType = MIME_UNKNOWN; - pMsgDrmInfo->drmType = MSG_DRM_TYPE_NONE; - - pMsgDrmInfo->szContentName = NULL; - pMsgDrmInfo->szContentURI = NULL; - pMsgDrmInfo->szContentDescription = NULL; - pMsgDrmInfo->szContentVendor = NULL; - pMsgDrmInfo->szRightIssuer = NULL; - pMsgDrmInfo->szDrm2FullPath = NULL; - pMsgDrmInfo->roWaitingTimerMax = 0; - pMsgDrmInfo->bFwdLock = false; - pMsgDrmInfo->bNoScreen = false; - pMsgDrmInfo->bNoRingTone = false; - pMsgDrmInfo->pszContentType = NULL; + MSG_DEBUG("replace filename [%s]", pAttach->szFileName); + + g_free(str2); + } + } + + }//end for attach + + g_list_free(r_list); return true; } -#endif + diff --git a/plugin/mms_plugin/MmsPluginSMILValidate.cpp b/plugin/mms_plugin/MmsPluginSMILValidate.cpp index 38df2aa..3c5ab54 100755 --- a/plugin/mms_plugin/MmsPluginSMILValidate.cpp +++ b/plugin/mms_plugin/MmsPluginSMILValidate.cpp @@ -1,28 +1,28 @@ /* -* 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. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ +#include "MsgMmsMessage.h" +#include "MmsPluginDebug.h" #include "MmsPluginSMILValidate.h" -#include "MsgDebug.h" -#include "MsgUtilFile.h" #include "MmsPluginSmil.h" -#include "MsgMmsMessage.h" + #define MSG_RETURN_VAL_IF_FAIL(Expr, Val) \ if (!(Expr)) { \ - MSG_DEBUG("%s:[%s] Failed - %d\n", __FUNCTION__, __LINE__, Val); \ + MSG_DEBUG("%s:[%d] Failed - %d\n", __FUNCTION__, __LINE__, Val); \ return Val; \ }; @@ -103,7 +103,7 @@ MSG_SMIL_ERR_E _MsgMMSAddDefaultSMILRootLayout(MMS_MESSAGE_DATA_S *pMsgData) pMsgData->rootlayout.height.value = MSG_SMIL_ROOT_LAYOUT_HEIGHT; pMsgData->rootlayout.height.bUnitPercent = MSG_SMIL_ROOT_LAYOUT_IN_PERCENT; - pMsgData->rootlayout.bgColor = MmsSmilAtoIHexa((char *)&pContent[1]); + pMsgData->rootlayout.bgColor = MsgSmilAtoIHexa((char *)&pContent[1]); MSG_END(); return MSG_SMIL_SUCCESS; @@ -235,7 +235,7 @@ MSG_SMIL_ERR_E _MsgMMSAddDefaultFirstSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, bo pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET; else pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN; - pRegion->bgColor = MmsSmilAtoIHexa((char *)&pContent[1]); + pRegion->bgColor = MsgSmilAtoIHexa((char *)&pContent[1]); pRegion->nLeft.value = MSG_SMIL_FIRST_REG_LEFT; pRegion->nLeft.bUnitPercent = true; @@ -285,7 +285,7 @@ MSG_SMIL_ERR_E _MsgMMSAddDefaultSecondSMILRegion(MMS_MESSAGE_DATA_S *pMsgData, b pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET; else pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN; - pRegion->bgColor = MmsSmilAtoIHexa((char *)&pContent[1]); + pRegion->bgColor = MsgSmilAtoIHexa((char *)&pContent[1]); pRegion->nLeft.value = MSG_SMIL_SECOND_REG_LEFT; pRegion->nLeft.bUnitPercent = true; @@ -335,7 +335,7 @@ MSG_SMIL_ERR_E _MsgMMSAddDefaultFullSMILRegion(MMS_MESSAGE_DATA_S *pMsgData) pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET; else pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN; - pRegion->bgColor = MmsSmilAtoIHexa((char *)&pContent[1]); + pRegion->bgColor = MsgSmilAtoIHexa((char *)&pContent[1]); pRegion->nLeft.value = MSG_SMIL_FULL_REG_LEFT; pRegion->nLeft.bUnitPercent = true; diff --git a/plugin/mms_plugin/MmsPluginSmil.cpp b/plugin/mms_plugin/MmsPluginSmil.cpp deleted file mode 100755 index 5ef0bbc..0000000 --- a/plugin/mms_plugin/MmsPluginSmil.cpp +++ /dev/null @@ -1,2101 +0,0 @@ -/* -* 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 -#include -#include -#include -#include "MmsPluginSmil.h" -#include "MmsPluginMessage.h" -#include "MmsPluginStorage.h" -#include "MsgDebug.h" -#include "MmsPluginCodec.h" -#include "MsgMmsMessage.h" - -#include "MsgTypes.h" -#include "MmsPluginSetup.h" -#include "MsgUtilFile.h" - -/* static variables */ -static char gszEmptyRawDoc[] = ""; -static MmsSmilDoc *__gpaMmsSmilDoc[MMS_SMIL_MAX_DOC]={NULL, }; -static char gszColor[MMS_SMIL_COLOR_SIZE] = {0, }; - - -char *MmsSmilGetPresentationData(msg_message_id_t msgId) -{ - MmsMsg *pMsg; - - MmsPluginStorage::instance()->getMmsMessage(&pMsg); - - if (pMsg == NULL) { - MSG_DEBUG("pMsg is NULL"); - goto _LCATCH; - } - - if (msgId != pMsg->msgID) { - MSG_DEBUG("Invalid Message Id"); - return NULL; - } - - if (!pMsg->msgBody.pPresentationBody) - goto _LCATCH; - - if (!pMsg->msgBody.pPresentationBody->body.pText) - goto _LCATCH; - else - return pMsg->msgBody.pPresentationBody->body.pText; - -_LCATCH: - return NULL; -} - -bool MmsSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc) -{ - xmlDocPtr doc; - xmlNodePtr cur; - MSG_DEBUG("%s", pSmilDoc); - doc = xmlParseMemory(pSmilDoc, strlen(pSmilDoc)); - - if (doc == NULL) { - MSG_DEBUG("Document not parsed successfully. \n"); - return false; - } - - cur = xmlDocGetRootElement(doc); - - if (cur == NULL) { - MSG_DEBUG("empty document\n"); - xmlFreeDoc(doc); - return false; - } - - if (xmlStrcmp(cur->name, (const xmlChar *) "smil")) { - MSG_DEBUG("document of the wrong type, root node != smil"); - xmlFreeDoc(doc); - return false; - } - - MmsSmilGetElement(pMmsMsg, cur); - - xmlFreeDoc(doc); - - return true; -} - -void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node) -{ - MSG_BEGIN(); - - int elementType; - int attrType; - MMS_SMIL_ROOTLAYOUT rootlayout = {}; - static bool cmd[ELEMENT_MAX] = {false, }; - static MMS_SMIL_REGION *pRegion; - static MMS_PAGE_S *pPage; - static MMS_MEDIA_S *pMedia; - static MMS_SMIL_TRANSITION *pTransition; - static MMS_SMIL_META *pMeta; - - xmlNode *cur_node = NULL; - - for (cur_node = a_node; cur_node; cur_node = cur_node->next) { - MSG_DEBUG("******* node, name: %s ***\n", cur_node->name); - - if (cur_node->type == XML_ELEMENT_NODE) { - // Get Smil Element ===================================================== - MSG_DEBUG("*** node type: Element, name: %s ***\n", cur_node->name); - - switch (elementType = MmsSmilGetElementID((char *)cur_node->name)) { - case ELEMENT_ROOTLAYOUT: - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_ROOTLAYOUT] = true; - break; - - case ELEMENT_REGION: - pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1); - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_REGION] = true; - break; - - case ELEMENT_TRANSITION: - pTransition = (MMS_SMIL_TRANSITION *)calloc(sizeof(MMS_SMIL_TRANSITION), 1); - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_TRANSITION] = true; - break; - - case ELEMENT_META: - pMeta = (MMS_SMIL_META *)calloc(sizeof(MMS_SMIL_META), 1); - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_META] = true; - break; - - case ELEMENT_PAR: - pPage = (MMS_PAGE_S *)calloc(sizeof(MMS_PAGE_S), 1); - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_PAR] = true; - break; - - case ELEMENT_PARAM: // Need to check the original element type - break; - - case ELEMENT_TEXT: - pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1); - pMedia->mediatype = MMS_SMIL_MEDIA_TEXT; - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_TEXT] = true; - break; - - case ELEMENT_IMG: - pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1); - pMedia->mediatype = MMS_SMIL_MEDIA_IMG; - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_IMG] = true; - break; - - case ELEMENT_AUDIO: - pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1); - pMedia->mediatype = MMS_SMIL_MEDIA_AUDIO; - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_AUDIO] = true; - break; - - case ELEMENT_VIDEO: - pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1); - pMedia->mediatype = MMS_SMIL_MEDIA_VIDEO; - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_VIDEO] = true; - break; - - case ELEMENT_REF: - pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1); - pMedia->mediatype = MMS_SMIL_MEDIA_IMG_OR_VIDEO; - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_REF] = true; - break; - - case ELEMENT_ANIMATE: - pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1); - pMedia->mediatype = MMS_SMIL_MEDIA_ANIMATE; - memset(cmd, 0, ELEMENT_MAX); - cmd[ELEMENT_ANIMATE] = true; - break; - - default: - memset(cmd, 0, ELEMENT_MAX); - break; - } - - //Get Smil Attribute ===================================================== - xmlAttr *pAttr = cur_node->properties; - SMIL_ATTRIBUTE_T paramType = ATTRIBUTE_UNKNOWN; - - for ( ; pAttr; pAttr = pAttr->next) { - MSG_DEBUG("AttributeType: (%s, %s) ", pAttr->name, pAttr->children->content); - switch (attrType = MmsSmilGetAttrID((char *)pAttr->name)) { - case ATTRIBUTE_ID: - { - if (cmd[ELEMENT_REGION]) { - strncpy(pRegion->szID, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1); - } else if (cmd[ELEMENT_TRANSITION]) { - strncpy(pTransition->szID, (char *)pAttr->children->content, MAX_SMIL_TRANSITION_ID - 1); - } else if (cmd[ELEMENT_META]) { - strncpy(pMeta->szID, (char *)pAttr->children->content, MAX_SMIL_META_ID - 1); - } - } - break; - - case ATTRIBUTE_TOP: - { - int bUnitPercent; - int value; - - if (strchr((char *)pAttr->children->content, '%')) - bUnitPercent = true; - else - bUnitPercent = false; - - value = atoi((char *)pAttr->children->content); - - if (cmd[ELEMENT_REGION]) { - pRegion->nTop.bUnitPercent = bUnitPercent; - pRegion->nTop.value = value; - } - } - break; - - case ATTRIBUTE_LEFT: - { - int bUnitPercent; - int value; - - if (strchr((char *)pAttr->children->content, '%')) - bUnitPercent = true; - else - bUnitPercent = false; - - value = atoi((char *)pAttr->children->content); - - if (cmd[ELEMENT_REGION]) { - pRegion->nLeft.bUnitPercent = bUnitPercent; - pRegion->nLeft.value = value; - } - } - break; - - - case ATTRIBUTE_WIDTH: - { - int bUnitPercent; - int value; - - if (strchr((char *)pAttr->children->content, '%')) - bUnitPercent = true; - else - bUnitPercent = false; - - value = atoi((char *)pAttr->children->content); - - if (cmd[ELEMENT_ROOTLAYOUT]) { - rootlayout.width.bUnitPercent = bUnitPercent; - rootlayout.width.value = value; - } else if (cmd[ELEMENT_REGION]) { - pRegion->width.bUnitPercent = bUnitPercent; - pRegion->width.value = value; - } - } - break; - - case ATTRIBUTE_HEIGHT: - { - int bUnitPercent; - int value; - - if (strchr((char *)pAttr->children->content, '%')) - bUnitPercent = true; - else - bUnitPercent = false; - - value = atoi((char *)pAttr->children->content); - - if (cmd[ELEMENT_ROOTLAYOUT]) { - rootlayout.height.bUnitPercent = bUnitPercent; - rootlayout.height.value = value; - } else if (cmd[ELEMENT_REGION]) { - pRegion->height.bUnitPercent = bUnitPercent; - pRegion->height.value = value; - } - } - break; - - case ATTRIBUTE_FIT: - if (cmd[ELEMENT_REGION]) { - if (!strcmp((char *)pAttr->children->content, "meet")) { - pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET; - } else { - pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN; - } - } - break; - - case ATTRIBUTE_BGCOLOR: - if (cmd[ELEMENT_ROOTLAYOUT]) - rootlayout.bgColor = MmsSmilGetColorValue(pAttr->children->content); - else if (cmd[ELEMENT_REGION]) - pRegion->bgColor = MmsSmilGetColorValue(pAttr->children->content); - else if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content); - else - pMedia->sMedia.sAVI.nBgColor = MmsSmilGetColorValue(pAttr->children->content); - - break; - - case ATTRIBUTE_DUR: - if (cmd[ELEMENT_PAR]) - pPage->nDur = MmsSmilGetTime((char *)pAttr->children->content); - else if (cmd[ELEMENT_TRANSITION]) - pTransition->nDur = MmsSmilGetTime((char *)pAttr->children->content); - else if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nDurTime = MmsSmilGetTime((char *)pAttr->children->content); - else - pMedia->sMedia.sAVI.nDurTime = MmsSmilGetTime((char *)pAttr->children->content); - - break; - - case ATTRIBUTE_SRC: - { - char *szSrc; - char szTmpSrc[MSG_FILEPATH_LEN_MAX] = {0,}; - char szOutBuf[MSG_FILEPATH_LEN_MAX] = {0, }; - int cLen; - MsgMultipart *pPart = NULL; - MmsMsg *pMsg; - - szSrc = MsgChangeHexString((char *)pAttr->children->content); - - memcpy(pMedia->szSrc, szSrc, strlen(szSrc) + 1); - free(szSrc); - - cLen = strlen(pMedia->szSrc); - if (!strncasecmp(pMedia->szSrc, "cid:", 4)) { - strncpy(szTmpSrc, pMedia->szSrc + 4, cLen - 4); - szTmpSrc[cLen - 4] = '\0'; - } else { - strncpy(szTmpSrc, pMedia->szSrc, cLen); - szTmpSrc[cLen] = '\0'; - } - - MmsPluginStorage::instance()->getMmsMessage(&pMsg); - pPart = pMsg->msgBody.body.pMultipart; -#ifndef __SUPPORT_DRM__ - MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart); -#else - MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart, pMedia); -#endif - - strcpy(pMedia->szSrc, szOutBuf); - MmsSmilGetMediaFilePath(pMedia, szTmpSrc, pMsg->msgID); - } - break; - - case ATTRIBUTE_COLOR: - if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content); - break; - - case ATTRIBUTE_SIZE: - if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nSize = atoi((char *)pAttr->children->content); - break; - - case ATTRIBUTE_BOLD: - if (cmd[ELEMENT_TEXT]) { - pMedia->sMedia.sText.bBold = MmsSmilGetFontAttrib((char *)pAttr->children->content); - } - break; - - case ATTRIBUTE_UNDERLINE: - if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.bUnderLine = MmsSmilGetFontAttrib((char *)pAttr->children->content); - break; - - case ATTRIBUTE_ITALIC: - if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.bItalic = MmsSmilGetFontAttrib((char *)pAttr->children->content); - break; - - case ATTRIBUTE_REVERSE: - if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.bReverse = MmsSmilGetFontAttrib((char *)pAttr->children->content); - break; - - case ATTRIBUTE_DIRECTION: - if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nDirection = MmsSmilGetFontDirection((char *)pAttr->children->content); - break; - case ATTRIBUTE_REGION: - strncpy(pMedia->regionId, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1); - break; - - case ATTRIBUTE_TRANSIN: - if (cmd[ELEMENT_TEXT]) - strncpy(pMedia->sMedia.sText.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1); - else - strncpy(pMedia->sMedia.sAVI.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1); - break; - - case ATTRIBUTE_TRANSOUT: - if (cmd[ELEMENT_TEXT]) - strncpy(pMedia->sMedia.sText.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1); - else - strncpy(pMedia->sMedia.sAVI.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1); - break; - - case ATTRIBUTE_BEGIN: - if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nBegin = MmsSmilGetTime((char *)pAttr->children->content); - else - pMedia->sMedia.sAVI.nBegin = MmsSmilGetTime((char *)pAttr->children->content); - break; - - case ATTRIBUTE_END: - if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nEnd = MmsSmilGetTime((char *)pAttr->children->content); - else - pMedia->sMedia.sAVI.nEnd = MmsSmilGetTime((char *)pAttr->children->content); - break; - - case ATTRIBUTE_REPEAT_COUNT: - if (cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nRepeat = atoi((char *)pAttr->children->content); - else - pMedia->sMedia.sAVI.nRepeat = atoi((char *)pAttr->children->content); - break; - - case ATTRIBUTE_NAME: - if (!strcmp((char *)pAttr->children->content, "foreground-color") || !strcmp((char *)pAttr->children->content, "foregroundcolor")) - paramType = ATTRIBUTE_FGCOLOR; - else if (!strcmp((char *)pAttr->children->content, "background-color") || !strcmp((char *)pAttr->children->content, "backgroundcolor")) - paramType = ATTRIBUTE_BGCOLOR; - else if (!strcmp((char *)pAttr->children->content, "textsize")) - paramType = ATTRIBUTE_SIZE; - else if (!strcmp((char *)pAttr->children->content, "textattribute")) - paramType = ATTRIBUTE_TEXTFORMAT; - - if (cmd[ELEMENT_META]) - strncpy(pMeta->szName, (char *)pAttr->children->content, MAX_SMIL_META_NAME - 1); - break; - - case ATTRIBUTE_VALUE: - if (paramType == ATTRIBUTE_SIZE && cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nSize = MmsSmilGetFontSizeValue((char *)pAttr->children->content); - else if (paramType == ATTRIBUTE_FGCOLOR && cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content); - else if (paramType == ATTRIBUTE_BGCOLOR && cmd[ELEMENT_TEXT]) - pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content); - else if (paramType == ATTRIBUTE_TEXTFORMAT && cmd[ELEMENT_TEXT]) { - MmsSmilFontType fontType; - - fontType = MmsSmilGetFontTypeValue((char *)pAttr->children->content); - - if (fontType == MMS_SMIL_FONT_TYPE_BOLD) - pMedia->sMedia.sText.bBold = true; - else - pMedia->sMedia.sText.bBold = false; - - if (fontType == MMS_SMIL_FONT_TYPE_ITALIC) - pMedia->sMedia.sText.bItalic = true; - else - pMedia->sMedia.sText.bItalic = false; - - if (fontType == MMS_SMIL_FONT_TYPE_UNDERLINE) - pMedia->sMedia.sText.bUnderLine = true; - else - pMedia->sMedia.sText.bUnderLine = false; - } - break; - - case ATTRIBUTE_ALT: - strncpy(pMedia->szAlt, (char *)pAttr->children->content, MAX_SMIL_ALT_LEN - 1); - break; - - case ATTRIBUTE_TYPE: - pTransition->nType = (MmsSmilTransType)atoi((char *)pAttr->children->content); - - switch (pTransition->nType) { - case MMS_SMIL_TRANS_SLIDEWIPE: - pTransition->nSubType = MMS_SMIL_TRANS_SUB_FROM_LEFT; - break; - case MMS_SMIL_TRANS_BARWIPE: - pTransition->nSubType = MMS_SMIL_TRANS_SUB_TOP_TO_BOTTOM; - break; - case MMS_SMIL_TRANS_BARNDOORWIPE: - pTransition->nSubType = MMS_SMIL_TRANS_SUB_HORIZONTAL; - break; - default: - pTransition->nSubType = MMS_SMIL_TRANS_SUB_NONE; - break; - } - - break; - - case ATTRIBUTE_SUBTYPE: - pTransition->nSubType = (MmsSmilTransSubType)atoi((char *)pAttr->children->content); - break; - - case ATTRIBUTE_CONTENT: - strncpy(pMeta->szContent, (char *)pAttr->children->content, MAX_SMIL_META_CONTENT - 1); - break; - default: - MSG_DEBUG("Undefined Attribute was found!!!!!"); - } - } - - if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_REGION]) { - // Insert a region to region list - _MsgMmsAddRegion(pMmsMsg, pRegion); - } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_PAR]) { - //Insert a page to page list - _MsgMmsAddPage(pMmsMsg, pPage); - } else if (paramType == ATTRIBUTE_UNKNOWN && (cmd[ELEMENT_TEXT] ||cmd[ELEMENT_IMG] ||cmd[ELEMENT_AUDIO] ||cmd[ELEMENT_VIDEO] ||cmd[ELEMENT_ANIMATE])) { - //Insert a media to media list - _MsgMmsAddMedia(pPage, pMedia); - } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_ROOTLAYOUT]) { - _MsgMmsSetRootLayout(pMmsMsg, &rootlayout); - } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_TRANSITION]) { - //Insert a transition to transition list - _MsgMmsAddTransition(pMmsMsg, pTransition); - } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_META]) { - //Insert a meta to meta list - _MsgMmsAddMeta(pMmsMsg, pMeta); - } - - paramType = ATTRIBUTE_UNKNOWN; - } - - MmsSmilGetElement(pMmsMsg, cur_node->children); - } - - MSG_END(); -} - - -int MmsSmilGetColorValue(xmlChar *content) -{ - int color; - - if (content[0] == '#') // RGB value - color = MmsSmilAtoIHexa((char *)&content[1]); - else if (content[0] == '0' && (content[1] == 'x' || content[1] == 'X')) - color = MmsSmilAtoIHexa((char *)&content[2]); - else { - MSG_DEBUG("Invalid Color Value"); - color = -1; - } - - return color; -} - -int MmsSmilAtoIHexa(char *pInput) -{ - int res = 0; - int len = 0; - int temp = 1; - int i = 0; - int j = 0; - char *pOutput = NULL; - - MSG_DEBUG("__MmsSmilAtoIHexa() enter..\n"); - - len = strlen(pInput); - pOutput = (char *)malloc(len + 1); - - if (pOutput == NULL) { - MSG_DEBUG("__MmsSmilAtoIHexa: Memory full \n"); - goto __CATCH; - } - - memset(pOutput, 0, len + 1); - - for (i = len - 1; i >= 0; i--) { - for (j = 0; j < (len - 1 - i); j++) { - temp *= 16; - } - - switch (pInput[i]) { - case '0': - pOutput[i] = 0; - break; - - case '1': - pOutput[i] = 1; - break; - - case '2': - pOutput[i] = 2; - break; - - case '3': - pOutput[i] = 3; - break; - - case '4': - pOutput[i] = 4; - break; - - case '5': - pOutput[i] = 5; - break; - - case '6': - pOutput[i] = 6; - break; - - case '7': - pOutput[i] = 7; - break; - - case '8': - pOutput[i] = 8; - break; - - case '9': - pOutput[i] = 9; - break; - - case 'a': - case 'A': - pOutput[i] = 10; - break; - - case 'b': - case 'B': - pOutput[i] = 11; - break; - - case 'c': - case 'C': - pOutput[i] = 12; - break; - - case 'd': - case 'D': - pOutput[i] = 13; - break; - - case 'e': - case 'E': - pOutput[i] = 14; - break; - - case 'f': - case 'F': - pOutput[i] = 15; - break; - } - - res += (pOutput[i] * temp); - temp = 1; - } - -__CATCH: - - if (pOutput) { - free(pOutput); - pOutput = NULL; - } - - return res; -} - -int MmsSmilGetTime(char *pValue) -{ - char *pTemp = NULL; - bool bMSec = false; - int retVal = 0; - int i = 0; - int len = 0; - - if (pValue == NULL || pValue[0] == '\0') - return 0; - - len = strlen(pValue); - - /* Default time unit -> millisecond */ - if (strstr(pValue, "msec")) - bMSec = true; - - if (strstr(pValue, "ms")) - bMSec = true; - - pTemp = (char *)malloc(strlen(pValue) + 1); - - if (NULL == pTemp) { - MSG_DEBUG("__MmsSmilGetTime : malloc for