diff options
author | seunggi.hong <seunggi.hong@samsung.com> | 2015-07-02 10:14:04 +0900 |
---|---|---|
committer | seunggi.hong <seunggi.hong@samsung.com> | 2015-07-02 19:02:46 +0900 |
commit | 7c25f680b3ce306040f174215ca8fb94b6935d23 (patch) | |
tree | 2dd3dacadc8ba0c41a9ccaae9c2c33683da39ca1 | |
parent | 0859ffeb3761c4a30f028e13f0af22088736df7b (diff) | |
download | msg-service-7c25f680b3ce306040f174215ca8fb94b6935d23.tar.gz msg-service-7c25f680b3ce306040f174215ca8fb94b6935d23.tar.bz2 msg-service-7c25f680b3ce306040f174215ca8fb94b6935d23.zip |
3.0 Migration
Change-Id: I7938878d56d94bb1152c05343cd420d10d6cd086
127 files changed, 4146 insertions, 5534 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 100ff2f..5456ff9 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +include(CheckCXXCompilerFlag) ########################################################## # Set Variables @@ -19,13 +20,22 @@ IF(_FEATURE_SMS_CDMA) ADD_DEFINITIONS("-DFEATURE_SMS_CDMA") ENDIF(_FEATURE_SMS_CDMA) -#IF(_MSG_WEARABLE_PROFILE) +IF(_MSG_WEARABLE_PROFILE) ADD_DEFINITIONS("-DMSG_WEARABLE_PROFILE") -#ENDIF(_MSG_WEARABLE_PROFILE) + ADD_DEFINITIONS("-DMSG_CONTACTS_SERVICE_NOT_SUPPORTED") +ENDIF(_MSG_WEARABLE_PROFILE) ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64") -ADD_DEFINITIONS("-DMSG_PENDING_PUSH_MESSAGE") -ADD_DEFINITIONS("-DMSG_CONTACTS_SERVICE_NOT_SUPPORTED") + +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 ########################################################## diff --git a/doc/msg_service_doc.h b/doc/msg_service_doc.h index 6617947..77be966 100644 --- a/doc/msg_service_doc.h +++ b/doc/msg_service_doc.h @@ -20,7 +20,6 @@ /** - * @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. diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index d2773e7..326fbb2 100755 --- a/externals/CMakeLists.txt +++ b/externals/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} -O2 -g -Wall") ########################################################## # Define Framework Utils @@ -18,7 +18,7 @@ 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/MsgLbs.cpp ${CMAKE_SOURCE_DIR}/externals/MsgSensorWrapper.cpp ${CMAKE_SOURCE_DIR}/externals/MsgAlarm.cpp ${CMAKE_SOURCE_DIR}/externals/MsgDevicedWrapper.cpp @@ -43,7 +43,7 @@ ADD_DEFINITIONS("-DFEATURE_JAVA_MMS") IF(_TIZEN_I586_ENABLED) ADD_DEFINITIONS("-DTIZEN_I586_ENABLED") ENDIF(_TIZEN_I586_ENABLED) -SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") diff --git a/externals/MsgNotificationWrapper.cpp b/externals/MsgNotificationWrapper.cpp index 64ac709..be0baa7 100755 --- a/externals/MsgNotificationWrapper.cpp +++ b/externals/MsgNotificationWrapper.cpp @@ -34,12 +34,14 @@ extern "C" { +#include <bundle_internal.h> +#include <app_control_internal.h> #ifndef MSG_WEARABLE_PROFILE -#include <app_control.h> -#include <notification.h> +#include <notification_list.h> +#include <notification_text_domain.h> #include <notification_internal.h> #include <feedback.h> -#include <badge.h> +#include <badge_internal.h> #endif // MSG_WEARABLE_PROFILE } @@ -337,6 +339,7 @@ msg_error_t MsgDeleteReportNotification(const char *addr) 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; @@ -375,10 +378,11 @@ msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeed { msg_error_t msg_err = MSG_SUCCESS; + #ifndef MSG_WEARABLE_PROFILE notification_h noti_h = NULL; bool bNotification = true; - bool bReplyPopup = false; +// bool bReplyPopup = false; MSG_NOTI_INFO_S noti_info; memset(¬i_info, 0x00, sizeof(MSG_NOTI_INFO_S)); @@ -409,7 +413,7 @@ msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeed if (bNotification == false) { MSG_DEBUG("Msg Alert notification is off."); - return msg_err; + goto __END_OF_REFRESH_NOTI; } createInfoData(¬i_info, bTicker); @@ -424,6 +428,7 @@ msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeed setNotification(noti_h, ¬i_info, bFeedback); +#if 0 if (MsgSettingGetBool(VCONFKEY_MESSAGE_POPUP_DISPLAY_ENABLE , &bReplyPopup) != MSG_SUCCESS) { MSG_DEBUG("MsgSettingGetBool is failed."); } @@ -432,6 +437,7 @@ msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeed MSG_DEBUG("Msg reply popup is on."); sendMsgReplyPopup(¬i_info); } +#endif __END_OF_REFRESH_NOTI : clearInfoData(noti_h, ¬i_info); @@ -443,6 +449,7 @@ __END_OF_REFRESH_NOTI : 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; @@ -550,7 +557,7 @@ bool isExistAddressInReportTable(const char *addr) 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) == MSG_SUCCESS) { + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) == MSG_SUCCESS) { dbHandle->freeTable(); return true; } @@ -559,7 +566,7 @@ bool isExistAddressInReportTable(const char *addr) 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) == MSG_SUCCESS) { + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) == MSG_SUCCESS) { dbHandle->freeTable(); return true; } @@ -573,6 +580,7 @@ bool isExistAddressInReportTable(const char *addr) void MsgInitReportNotiList() { MSG_BEGIN(); + #ifndef MSG_WEARABLE_PROFILE msg_report_notification_list = NULL; @@ -647,9 +655,10 @@ msg_error_t MsgInitNoti() 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)); - delNotiInfo->type = MSG_NOTI_TYPE_SIM; - delNotiInfo->sim_idx = -1; - + 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); @@ -667,8 +676,10 @@ msg_error_t MsgDeleteNoti(msg_notification_type_t noti_type, int simIndex) MSG_NOTI_INFO_S *delNotiInfo = (MSG_NOTI_INFO_S *)calloc(1, sizeof(MSG_NOTI_INFO_S)); - delNotiInfo->type = noti_type; - delNotiInfo->sim_idx = simIndex; + if (delNotiInfo) { + delNotiInfo->type = noti_type; + delNotiInfo->sim_idx = simIndex; + } bNotiSvcReady = notification_is_service_ready(); @@ -758,7 +769,7 @@ msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt) if (!exist) { /* create badge */ - err = badge_new(MSG_DEFAULT_APP_ID); + err = badge_create(MSG_DEFAULT_APP_ID, "/usr/bin/msg-server"); if (err != BADGE_ERROR_NONE) { MSG_DEBUG("Fail to badge_new : %d", err); return MSG_ERR_UNKNOWN; @@ -971,11 +982,12 @@ void createInfoData(MSG_NOTI_INFO_S *noti_info, bool bTicker) addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message"); +#if 0 bool bReplyPopup = false; if (MsgSettingGetBool(VCONFKEY_MESSAGE_POPUP_DISPLAY_ENABLE , &bReplyPopup) != MSG_SUCCESS) { MSG_DEBUG("MsgSettingGetBool is failed."); } - +#endif noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER; } break; @@ -1099,15 +1111,12 @@ void createInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info) 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); + if (noti_info->svc_h) { + char telnum[256] = {0,}; + app_control_set_operation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL); + snprintf(telnum, sizeof(telnum), "tel:%s", noti_info->number); + app_control_set_uri(noti_info->svc_h, telnum); + } MSG_FREE(voiceNumber); MSG_FREE(voiceAlphaId); @@ -1131,13 +1140,12 @@ void createInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info) 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); + if (noti_info->svc_h) { + char telnum[256] = {0,}; + app_control_set_operation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL); + snprintf(telnum, sizeof(telnum), "tel:%s", noti_info->number); + app_control_set_uri(noti_info->svc_h, telnum); + } } else { setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0"); @@ -1789,20 +1797,24 @@ msg_error_t MsgInsertInstantMessage(msg_notification_type_t noti_type) break; } - notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER); - notification_post(noti); + 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: - notification_delete(noti); - + if (notification_delete(noti) != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("Fail to notification_delete"); if (notiMsg) { free(notiMsg); notiMsg = NULL; } if (noti) { - notification_free(noti); + if (notification_free(noti) != NOTIFICATION_ERROR_NONE) + MSG_DEBUG("Fail to notification_free"); noti = NULL; } @@ -1867,7 +1879,7 @@ void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMa } char *msg_tone_file_path = NULL; - AutoPtr<char> buf(&msg_tone_file_path); + unique_ptr<char*, void(*)(char**)> buf(&msg_tone_file_path, unique_ptr_deleter); MsgSoundPlayer::instance()->MsgGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path); @@ -1895,7 +1907,7 @@ void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMa setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL); #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED } -#endif +#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED } else { setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); } @@ -2023,10 +2035,9 @@ msg_error_t getLatestMsgInfo(MSG_NOTI_INFO_S *noti_info, bool isForInstantMessag #endif MSG_DEBUG("sqlQuery [%s]", sqlQuery); - int rowCnt = 0; - int index = 2; + int rowCnt = 0, index = 0; - msg_err = dbhandler->getTable(sqlQuery, &rowCnt); + msg_err = dbhandler->getTable(sqlQuery, &rowCnt, &index); MSG_DEBUG("getTable() ret=[%d], rowCnt=[%d]", msg_err, rowCnt); //contacts-service is not used for gear @@ -2307,7 +2318,7 @@ msg_error_t getLatestMsgInfo(MSG_NOTI_INFO_S *noti_info, bool isForInstantMessag dbhandler->finalizeQuery(); - if (dbhandler->getTable(sqlQuery, ¬i_info->count) != MSG_SUCCESS) { + if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) { MSG_DEBUG("getTable is failed"); dbhandler->freeTable(); return MSG_ERR_DB_GETTABLE; diff --git a/externals/MsgSoundPlayer.cpp b/externals/MsgSoundPlayer.cpp index e9b14e1..254570e 100755 --- a/externals/MsgSoundPlayer.cpp +++ b/externals/MsgSoundPlayer.cpp @@ -113,11 +113,10 @@ void MsgSensorCBStop() // return FALSE; //} +#ifndef MSG_WEARABLE_PROFILE static int MsgSoundPlayCallback(int message, void *param, void *user_param) { - -#ifndef MSG_WEARABLE_PROFILE switch (message) { case MM_MESSAGE_BEGIN_OF_STREAM: @@ -140,11 +139,11 @@ static int MsgSoundPlayCallback(int message, void *param, void *user_param) break; } -#endif // MSG_WEARABLE_PROFILE - return 1; } +#endif // MSG_WEARABLE_PROFILE + /*================================================================================================== IMPLEMENTATION OF MsgSoundPlayer - Member Functions ==================================================================================================*/ @@ -449,7 +448,7 @@ void MsgSoundPlayer::MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_ #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED /* get ringtone file path */ char *msg_tone_file_path = NULL; - AutoPtr<char> buf(&msg_tone_file_path); + unique_ptr<char*, void(*)(char**)> 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]; diff --git a/externals/MsgSpamFilter.cpp b/externals/MsgSpamFilter.cpp index 86900c7..ec47690 100755 --- a/externals/MsgSpamFilter.cpp +++ b/externals/MsgSpamFilter.cpp @@ -101,7 +101,7 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo) 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); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); if (rowCnt > 0) { MSG_SEC_DEBUG("Msg is Filtered by Address : [%s]", pMsgInfo->addressList[0].addressVal); @@ -124,7 +124,7 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo) rowCnt = 0; - err = pDbHandle->getTable(sqlQuery, &rowCnt); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS) { MSG_DEBUG("Fail to getTable()."); @@ -135,7 +135,7 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo) char filterValue[MAX_FILTER_VALUE_LEN+1]; char* pData = NULL; - AutoPtr<char> buf(&pData); + unique_ptr<char*, void(*)(char**)> buf(&pData, unique_ptr_deleter); int fileSize = 0; bool bFiltered = false; @@ -281,7 +281,7 @@ bool MsgCheckFilterByWord(MsgDbHandler *pDbHandle, const char *pMsgText) 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); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS) { MSG_DEBUG("Fail to getTable()."); diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index 532620b..c096087 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} -O2 -g -Wall") ######################################################### # Define Plugin Manager @@ -32,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}\"") @@ -76,7 +76,7 @@ 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}\"") @@ -108,13 +108,13 @@ INCLUDE_DIRECTORIES( ) INCLUDE(FindPkgConfig) -pkg_check_modules(trans_manager_pkgs REQUIRED glib-2.0 dlog vconf cynara-client cynara-creds-socket cynara-session cynara-creds-commons) +pkg_check_modules(trans_manager_pkgs REQUIRED glib-2.0 dlog vconf bundle eventsystem cynara-client cynara-creds-socket cynara-session cynara-creds-commons) 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}\"") @@ -148,7 +148,7 @@ 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}\"") diff --git a/framework/deliver-handler/MsgDeliverHandler.cpp b/framework/deliver-handler/MsgDeliverHandler.cpp index 7b06a32..096f80a 100755 --- a/framework/deliver-handler/MsgDeliverHandler.cpp +++ b/framework/deliver-handler/MsgDeliverHandler.cpp @@ -277,6 +277,9 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques 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; @@ -323,8 +326,8 @@ msg_error_t MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) err = MsgHandleSMS(pMsgInfo, pSendNoti, &bOnlyNoti); if (err == MSG_SUCCESS && ((*pSendNoti)||bOnlyNoti)) { - bool isFavorites = false; #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED + bool isFavorites = false; if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { MsgPlayTTSMode(pMsgInfo->msgType.subType, pMsgInfo->msgId, isFavorites); } @@ -495,8 +498,8 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti, bool *bO } 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); #ifndef MSG_WEARABLE_PROFILE + MSG_PUSH_SERVICE_TYPE_T serviceType = (MSG_PUSH_SERVICE_TYPE_T)MsgSettingGetInt(PUSH_SERVICE_TYPE); app_control_h svc_handle = NULL; switch (pMsgInfo->msgType.subType) { diff --git a/framework/main.cpp b/framework/main.cpp index 12c48ee..d6e2695 100755 --- a/framework/main.cpp +++ b/framework/main.cpp @@ -34,7 +34,6 @@ #include "MsgUtilFile.h" #include "MsgUtilStorage.h" #include "MsgNotificationWrapper.h" -#include "MsgZoneManager.h" #include <errno.h> #include <glib.h> @@ -47,99 +46,17 @@ static GMainLoop* mainloop = NULL; FUNCTION IMPLEMENTATION ==================================================================================================*/ -msg_error_t InitMmsDir() -{ - if (mkdir(MSG_DATA_ROOT_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) - { - if (errno == EEXIST) - { - MSG_DEBUG("The %s already exists", MSG_DATA_ROOT_PATH); - } - else - { - MSG_DEBUG("Error while mkdir %s", MSG_DATA_ROOT_PATH); - return MSG_ERR_DB_MAKE_DIR; - } - } - - if (mkdir(MSG_SMIL_FILE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) - { - if (errno == EEXIST) - { - MSG_SEC_DEBUG("The %s already exists", MSG_SMIL_FILE_PATH); - } - else - { - MSG_SEC_DEBUG("Error while mkdir %s", MSG_SMIL_FILE_PATH); - return MSG_ERR_DB_MAKE_DIR; - } - } - - if (mkdir(MSG_DATA_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) - { - if (errno == EEXIST) - { - MSG_DEBUG("The %s already exists", MSG_DATA_PATH); - } - else - { - MSG_DEBUG("Error while mkdir %s", MSG_DATA_PATH); - return MSG_ERR_DB_MAKE_DIR; - } - } - - if (mkdir(MSG_THUMBNAIL_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) { - if (errno == EEXIST) { - MSG_DEBUG("The %s already exists.", MSG_THUMBNAIL_PATH); - } else { - MSG_DEBUG(" Error while mkdir %s", MSG_THUMBNAIL_PATH); - return MSG_ERR_DB_MAKE_DIR; - } - } - - if (mkdir(MSG_IPC_DATA_PATH, S_IRWXU ) < 0) - { - 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. - MsgRmRf((char *)MSG_IPC_DATA_PATH); - } - else - { - MSG_DEBUG("Error while mkdir %s", MSG_IPC_DATA_PATH); - return MSG_ERR_DB_MAKE_DIR; - } - } - - 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 (MsgChown(MSG_DATA_ROOT_PATH, 200, 5000) == 0) { - MSG_DEBUG("Fail to chown [%s].", MSG_DATA_ROOT_PATH); - } - if (MsgChown(MSG_DATA_PATH, 200, 5000) == 0) { - MSG_DEBUG("Fail to chown [%s].", MSG_DATA_PATH); - } - if (MsgChown(MSG_SMIL_FILE_PATH, 200, 5000) == 0) { - MSG_DEBUG("Fail to chown [%s].", MSG_SMIL_FILE_PATH); - } - if (MsgChown(MSG_IPC_DATA_PATH, 200, 5000) == 0) { - MSG_DEBUG("Fail to chown [%s].", MSG_IPC_DATA_PATH); - } - if (MsgChown(MSG_THUMBNAIL_PATH, 200, 5000) == 0) { - MSG_DEBUG("Fail to chown [%s].", MSG_THUMBNAIL_PATH); - } - - return MSG_SUCCESS; -} - void* InitMsgServer(void*) { msg_error_t err = MSG_SUCCESS; MSG_DEBUG("Start InitMsgServer."); +#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED + // Init contact digit number + MsgInitContactSvc(); +#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED + //CID 356902: Moving try block up to include MsgStoInitDB which also throws MsgException try { @@ -220,12 +137,6 @@ int main(void) if(MsgSettingSetBool(VCONFKEY_MSG_SERVER_READY, false) != MSG_SUCCESS) MSG_DEBUG("MsgSettingSetBool FAIL: VCONFKEY_MSG_SERVER_READY"); - // Connect to DB - // MsgStoConnectDB(); - - // Clean up mms dir - InitMmsDir(); - // init server InitMsgServer(NULL); @@ -234,7 +145,7 @@ int main(void) // 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; } diff --git a/framework/plugin-manager/MsgPluginManager.cpp b/framework/plugin-manager/MsgPluginManager.cpp index f734e63..836afce 100755 --- a/framework/plugin-manager/MsgPluginManager.cpp +++ b/framework/plugin-manager/MsgPluginManager.cpp @@ -73,7 +73,7 @@ void MsgSentStatusListener(MSG_SENT_STATUS_S *pSentStatus) MSG_DEBUG("Waiting result for SENT STATUS"); char *temp = NULL; - AutoPtr<char> wrap(&temp); + unique_ptr<char*, void(*)(char**)> wrap(&temp, unique_ptr_deleter); unsigned int len; client.read(&temp, &len); @@ -125,7 +125,7 @@ void MsgStorageChangeListener(msg_storage_change_type_t storageChangeType, MSG_M MSG_DEBUG("Waiting result for STORAGE CHANGE"); char *temp = NULL; - AutoPtr<char> wrap(&temp); + unique_ptr<char*, void(*)(char**)> wrap(&temp, unique_ptr_deleter); unsigned int len; client.read(&temp, &len); @@ -162,7 +162,7 @@ msg_error_t MsgIncomingMessageListener(MSG_MESSAGE_INFO_S *pMsg) // Allocate Memory to Command Data char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(pMsg, &encodedData); // composing command @@ -186,7 +186,7 @@ msg_error_t MsgIncomingMessageListener(MSG_MESSAGE_INFO_S *pMsg) client.write(cmdBuf, cmdSize); char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); @@ -249,7 +249,7 @@ msg_error_t MsgIncomingSyncMLMessageListener(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLD // Receive result from Transaction Manager char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); @@ -306,7 +306,7 @@ msg_error_t MsgIncomingPushMessageListener(MSG_PUSH_MESSAGE_DATA_S *pPushData) // Receive result from Transaction Manager char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); @@ -354,7 +354,7 @@ msg_error_t MsgIncomingCBMessageListener(MSG_CB_MSG_S *pCbMsg, MSG_MESSAGE_INFO_ // Allocate Memory to Command Data char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(pMsgInfo, &encodedData); // composing command @@ -384,7 +384,7 @@ msg_error_t MsgIncomingCBMessageListener(MSG_CB_MSG_S *pCbMsg, MSG_MESSAGE_INFO_ client.write(cmdBuf, cmdSize); char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); @@ -443,7 +443,7 @@ msg_error_t MsgIncomingLBSMessageListener(MSG_LBS_MESSAGE_DATA_S *pLBSData) // Receive result from Transaction Manager char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); @@ -496,7 +496,7 @@ msg_error_t MsgInitSimBySatListener() // Receive result from Transaction Manager char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); @@ -535,7 +535,7 @@ msg_error_t MsgMmsConfIncomingListener(MSG_MESSAGE_INFO_S *pMsg, msg_request_id_ // Allocate Memory to Command Data char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(pMsg, &encodedData); // composing command @@ -561,7 +561,7 @@ msg_error_t MsgMmsConfIncomingListener(MSG_MESSAGE_INFO_S *pMsg, msg_request_id_ // Receive result from Transaction Manager char *retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize = 0; client.read(&retBuf, &retSize); @@ -607,11 +607,11 @@ msg_error_t MsgSimMessageListener(MSG_MESSAGE_INFO_S *pMsg, int *simIdList, msg_ // Allocate Memory to Command Data char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(pMsg, &encodedData); char* encodedData2 = NULL; - AutoPtr<char> buf2(&encodedData2); + unique_ptr<char*, void(*)(char**)> buf2(&encodedData2, unique_ptr_deleter); encodedData2 = (char*)new char[dataSize + sizeof(int) + (sizeof(int)*size) + 1]; char *offset = NULL; @@ -649,7 +649,7 @@ msg_error_t MsgSimMessageListener(MSG_MESSAGE_INFO_S *pMsg, int *simIdList, msg_ client.write(cmdBuf, cmdSize); char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); @@ -706,7 +706,7 @@ msg_error_t MsgResendMessageListener(void) // Receive result from Transaction Manager char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); @@ -752,7 +752,7 @@ bool MsgCheckUniquenessListener(MSG_UNIQUE_INDEX_S *p_msg, msg_message_id_t msgI // Allocate Memory to Command Data char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = sizeof(bool) + sizeof(msg_message_id_t) + sizeof(MSG_UNIQUE_INDEX_S); @@ -794,7 +794,7 @@ bool MsgCheckUniquenessListener(MSG_UNIQUE_INDEX_S *p_msg, msg_message_id_t msgI client.write(cmdBuf, cmdSize); char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); @@ -854,7 +854,7 @@ msg_error_t MsgSimImsiListener(int sim_idx) // Receive result from Transaction Manager char* retBuf = NULL; - AutoPtr<char> wrap(&retBuf); + unique_ptr<char*, void(*)(char**)> wrap(&retBuf, unique_ptr_deleter); unsigned int retSize; client.read(&retBuf, &retSize); diff --git a/framework/setting-handler/MsgSettingHandler.cpp b/framework/setting-handler/MsgSettingHandler.cpp index f805bab..6f44866 100755 --- a/framework/setting-handler/MsgSettingHandler.cpp +++ b/framework/setting-handler/MsgSettingHandler.cpp @@ -326,14 +326,6 @@ msg_error_t MsgSetGeneralOpt(const MSG_SETTING_S *pSetting) } } - 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; } @@ -985,9 +977,6 @@ void MsgGetGeneralOpt(MSG_SETTING_S *pSetting) } pSetting->option.generalOpt.alertTone = (MSG_ALERT_TONE_T)MsgSettingGetInt(MSG_ALERT_REP_TYPE); - - pSetting->option.generalOpt.searchTags = MsgSettingGetInt(MSG_SEARCH_TAGS); - } @@ -1038,7 +1027,7 @@ 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); + MsgSettingGetBool(MMS_SEND_KEEP_COPY, &pSetting->option.mmsSendOpt.bKeepCopy); #endif /* __NOT_USED_BY_DESIGN_CHANGE__ */ MsgSettingGetBool(MMS_SEND_BODY_REPLYING, &pSetting->option.mmsSendOpt.bBodyReplying); diff --git a/framework/storage-handler/MsgStorageFilter.cpp b/framework/storage-handler/MsgStorageFilter.cpp index 9ae5e49..15641d9 100755 --- a/framework/storage-handler/MsgStorageFilter.cpp +++ b/framework/storage-handler/MsgStorageFilter.cpp @@ -196,7 +196,7 @@ msg_error_t MsgStoGetFilterList(msg_struct_list_s *pFilterList) return MSG_ERR_NULL_POINTER; } MsgDbHandler *dbHandle = getDbHandle(); - int rowCnt = 0, index = 4; + int rowCnt = 0, index = 0; char sqlQuery[MAX_QUERY_LEN+1]; @@ -207,7 +207,7 @@ msg_error_t MsgStoGetFilterList(msg_struct_list_s *pFilterList) 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; diff --git a/framework/storage-handler/MsgStorageFolder.cpp b/framework/storage-handler/MsgStorageFolder.cpp index b4375f2..d9261dd 100755 --- a/framework/storage-handler/MsgStorageFolder.cpp +++ b/framework/storage-handler/MsgStorageFolder.cpp @@ -113,8 +113,8 @@ msg_error_t MsgStoGetFolderList(msg_struct_list_s *pFolderList) 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]; @@ -122,7 +122,7 @@ 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) { + if (dbHandle->getTable(sqlQuery, &rowCnt, &index) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } diff --git a/framework/storage-handler/MsgStorageManager.cpp b/framework/storage-handler/MsgStorageManager.cpp index 5abbfaa..a3801ac 100755 --- a/framework/storage-handler/MsgStorageManager.cpp +++ b/framework/storage-handler/MsgStorageManager.cpp @@ -34,7 +34,6 @@ #include "MsgPluginManager.h" #include "MsgStorageHandler.h" - #define MSG_DB_VERSION 1 /*================================================================================================== @@ -198,6 +197,12 @@ void MsgInitMmapMutex(const char *shm_file_name) pthread_mutexattr_destroy(&mattr); close (fd); + + if (munmap((void *)mx, sizeof(pthread_mutex_t)) != 0) { + MSG_FATAL("munmap() failed! (errno: %d)", errno); + return; + } + MSG_END(); } @@ -251,7 +256,7 @@ msg_error_t MsgAddDefaultFolders() 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) { + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -274,7 +279,7 @@ 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) { + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -297,7 +302,7 @@ 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) { + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -320,7 +325,7 @@ 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) { + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -343,7 +348,7 @@ 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) { + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -366,7 +371,7 @@ 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) { + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -400,7 +405,7 @@ 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) { + if (dbHandle->getTable(sqlQuery, &nRowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -515,9 +520,8 @@ msg_error_t MsgStoBackupMessage(msg_message_backup_type_t type, const char *file char sqlQuery[MAX_QUERY_LEN+1]; int rowCnt = 0; - int index = 0; - MSG_MESSAGE_INFO_S msgInfo = {0, }; - char* encoded_data = NULL; + MSG_MESSAGE_INFO_S msgInfo = {0, }; + char* encoded_data = NULL; char fileName[MSG_FILENAME_LEN_MAX+1]; memset(fileName, 0x00, sizeof(fileName)); @@ -548,23 +552,27 @@ msg_error_t MsgStoBackupMessage(msg_message_backup_type_t type, const char *file } - err = dbHandle->getTable(sqlQuery, &rowCnt); + 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++) { - int msgid = dbHandle->getColumnToInt(++index); + msg_id[i] = dbHandle->getColumnToInt(i+1); + } + dbHandle->freeTable(); + for (int i = 0; i < rowCnt; i++) { msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); - err = MsgStoGetMessage(msgid, &msgInfo, NULL); + err = MsgStoGetMessage(msg_id[i], &msgInfo, NULL); if(err != MSG_SUCCESS) { - dbHandle->freeTable(); return err; } @@ -576,18 +584,21 @@ msg_error_t MsgStoBackupMessage(msg_message_backup_type_t type, const char *file } if (encoded_data != NULL) { if (MsgAppendFile(fileName, encoded_data, strlen(encoded_data)) == false) { - dbHandle->freeTable(); free(encoded_data); return MSG_ERR_STORAGE_ERROR; } free(encoded_data); + + if (chmod(fileName, 0666) == -1) { + MSG_FATAL("chmod: %s", g_strerror(errno)); + return MSG_ERR_UNKNOWN; + } } memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); } - dbHandle->freeTable(); MSG_END(); return MSG_SUCCESS; @@ -616,7 +627,7 @@ msg_error_t MsgStoUpdateMms(MSG_MESSAGE_INFO_S *pMsg) dbHandle->bindText(pMsg->thumbPath, 1); - if (pMsg->msgText[0] != '\0' && g_file_get_contents((gchar*)pMsg->msgText, (gchar**)&pFileData, (gsize*)&fileSize, NULL) == true) { + if (pMsg->msgText[0] != '\0' && g_file_get_contents(pMsg->msgText, &pFileData, &fileSize, NULL) == true) { dbHandle->bindText(pFileData, 2); } @@ -656,9 +667,14 @@ msg_error_t MsgStoUpdateMms(MSG_MESSAGE_INFO_S *pMsg) msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id_list) { + if (result_id_list == NULL) { + MSG_DEBUG("result_id_list is NULL"); + return MSG_ERR_NULL_POINTER; + } + msg_error_t err = MSG_SUCCESS; MSG_MESSAGE_INFO_S msgInfo = {0,}; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); VTree* vMsg = NULL; VObject* pObject = NULL; @@ -673,6 +689,8 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id 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); @@ -873,12 +891,20 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id 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; @@ -1008,8 +1034,8 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id #ifndef MSG_FOR_DEBUG } #endif - if (result_id_list) - *result_id_list = msgIdList; + *result_id_list = msgIdList; + __RETURN: if(pData) { @@ -1018,6 +1044,13 @@ __RETURN: pCurrent = NULL; } + if (*result_id_list == NULL && msgIdList) { + if (msgIdList->msgIdList) { + free(msgIdList->msgIdList); + } + free(msgIdList); + } + return err; } diff --git a/framework/storage-handler/MsgStorageMessage.cpp b/framework/storage-handler/MsgStorageMessage.cpp index 086d278..af405f4 100755 --- a/framework/storage-handler/MsgStorageMessage.cpp +++ b/framework/storage-handler/MsgStorageMessage.cpp @@ -37,7 +37,6 @@ #include "MsgMmsMessage.h" #include "MsgDevicedWrapper.h" - using namespace std; @@ -115,11 +114,11 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS gchar *contents = NULL; char *pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); char keyName[MAX_VCONFKEY_NAME_LEN]; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", MSG_SIM_SUBS_ID, pMsg->sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SUBS_ID, pMsg->sim_idx); char *imsi = MsgSettingGetString(keyName); @@ -129,7 +128,7 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS 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, (unsigned int)pMsg->displayTime, pMsg->dataSize, pMsg->networkStatus, pMsg->bRead, pMsg->bProtected, pMsg->priority, pMsg->direction, - 0, pMsg->bBackup, (int)pMsg->sim_idx, imsi); + 0, pMsg->bBackup, pMsg->sim_idx, imsi); MSG_DEBUG("QUERY : %s", sqlQuery); @@ -200,6 +199,10 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS 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) { @@ -235,7 +238,11 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS } } else if (pMsg->msgType.mainType == MSG_SMS_TYPE && pSendOptInfo != NULL) { MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); - if (plg) err = plg->addMessage(pMsg, pSendOptInfo, NULL); + 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; @@ -244,12 +251,17 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS #else if (pMsg->msgType.mainType == MSG_MMS_TYPE) { char *pMmsSerializedData = NULL; - AutoPtr<char> buf_mms(&pMmsSerializedData); + unique_ptr<char*, void(*)(char**)> 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 (plg == NULL) { + dbHandle->endTrans(false); + return MSG_ERR_NULL_POINTER; + } + if (pMmsSerializedData == NULL) { if (MsgOpenAndReadFile(pMsg->msgData, &pMmsSerializedData, &fileSize) == false) { dbHandle->endTrans(false); @@ -366,7 +378,7 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S int fileSize = 0; char *pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); // Get File Data if (pMsg->bTextSms == false) { @@ -412,7 +424,7 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S 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, (int)pMsg->msgId); + pMsg->networkStatus, pMsg->bRead, pMsg->bProtected, pMsg->priority, pMsg->direction, pMsg->bBackup, pMsg->msgId); if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { dbHandle->endTrans(false); @@ -459,6 +471,10 @@ msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S } } 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); @@ -578,8 +594,7 @@ msg_error_t MsgStoUpdateThreadReadStatus(msg_thread_id_t threadId, msg_id_list_s char sqlQuery[MAX_QUERY_LEN+1]; /*** Get msg id list **/ - int rowCnt = 0; - int index = 1; + int rowCnt = 0, index = 0; pMsgIdList->nCount = 0; MsgDbHandler *dbHandle = getDbHandle(); @@ -589,7 +604,7 @@ msg_error_t MsgStoUpdateThreadReadStatus(msg_thread_id_t threadId, msg_id_list_s 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) { MSG_DEBUG("Fail to getTable()."); @@ -735,7 +750,6 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication) if (plg == NULL) { MSG_DEBUG("SMS Plug-in is NULL"); - return MSG_ERR_NULL_POINTER; } @@ -1058,7 +1072,7 @@ 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("Fail to getTable()."); @@ -1092,9 +1106,9 @@ 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("Fail to getTable()."); @@ -1130,7 +1144,7 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD rowCnt = 0; - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); goto FREE_MEMORY; @@ -1202,7 +1216,7 @@ 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); - 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) { @@ -1434,7 +1448,7 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) 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); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { MSG_DEBUG("Fail to getTable()."); @@ -1489,7 +1503,7 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_SIM, MSGFW_TMP_MSGID_TABLE_NAME); rowCnt = 0; - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { MSG_DEBUG("Fail to getTable()."); @@ -1518,7 +1532,7 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) memset(sqlQuery, 0x00, sizeof(sqlQuery)); 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 && err != MSG_ERR_DB_NORECORD) { MSG_DEBUG("Fail to getTable()."); @@ -1556,7 +1570,7 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) 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); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { MSG_DEBUG("Fail to getTable()."); @@ -1583,7 +1597,7 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) 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); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { MSG_DEBUG("Fail to getTable()."); @@ -1608,7 +1622,7 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) memset(sqlQuery, 0x00, sizeof(sqlQuery)); 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); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { MSG_DEBUG("Fail to getTable()."); @@ -1739,6 +1753,10 @@ msg_error_t MsgStoMoveMessageToStorage(msg_message_id_t msgId, msg_storage_id_t 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; @@ -1785,7 +1803,7 @@ msg_error_t MsgStoMoveMessageToStorage(msg_message_id_t msgId, msg_storage_id_t snprintf(sqlQuery, sizeof(sqlQuery), "SELECT STORAGE_ID FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS) { MSG_DEBUG("Fail to getTable()."); @@ -1811,7 +1829,9 @@ msg_error_t MsgStoMoveMessageToStorage(msg_message_id_t msgId, msg_storage_id_t snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_SLOT_ID, SIM_ID FROM %s WHERE MSG_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, msgId); - err = dbHandle->getTable(sqlQuery, &rowCnt); + int index = 0; + + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS) { MSG_DEBUG("Fail to getTable()."); @@ -1821,7 +1841,11 @@ msg_error_t MsgStoMoveMessageToStorage(msg_message_id_t msgId, msg_storage_id_t //Delete messages in sim card MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); - int index = 2; + 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++); @@ -2076,7 +2100,7 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M //contactNameOrder is never used #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED MsgStoGetAddressByMsgId(dbHandle, pMsg->msgId, MsgGetContactNameOrder(), &pMsg->nAddressCnt, &pMsg->addressList); -#else +#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED // MsgStoGetAddressByMsgId(dbHandle, pMsg->msgId, &pMsg->nAddressCnt, &pMsg->addressList); #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED @@ -2090,6 +2114,10 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M // call mms plugin to get mms specific message data MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(pMsg->msgType.mainType); + 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) { @@ -2152,15 +2180,14 @@ msg_error_t MsgStoGetFailedMessage(int **failed_msg_list, int *count) msg_error_t err = MSG_SUCCESS; char sqlQuery[MAX_QUERY_LEN+1]; - int rowCnt = 0; - int index = 1; + int rowCnt = 0, index = 0; MsgDbHandler *dbHandle = getDbHandle(); memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE NETWORK_STATUS = %d AND FOLDER_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_PENDING, MSG_OUTBOX_ID); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if(err == MSG_ERR_DB_NORECORD){ dbHandle->freeTable(); @@ -2321,8 +2348,7 @@ msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t threadId, bool bInclud char sqlQuery[MAX_QUERY_LEN+1]; /*** Get msg id list **/ - int rowCnt = 0; - int index = 1; + int rowCnt = 0, index = 0; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -2348,7 +2374,7 @@ msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t threadId, bool bInclud } #endif - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { MSG_DEBUG("Fail to getTable()."); @@ -2461,17 +2487,17 @@ msg_error_t MsgStoGetSmsReportStatus(msg_message_id_t msgId, int *count, MSG_REP "order by TIME ASC;" , MSGFW_SMS_REPORT_TABLE_NAME, msgId); - int rowCnt; - err = dbHandle->getTable(sqlQuery, &rowCnt); + int rowCnt = 0, index = 0; + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS) { MSG_DEBUG("Fail to getTable()."); dbHandle->freeTable(); + if (err == MSG_ERR_DB_NORECORD) + return MSG_SUCCESS; return err; } - int index = 4; - *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); @@ -2523,17 +2549,17 @@ msg_error_t MsgStoGetMmsReportStatus(msg_message_id_t msgId, int *count, MSG_REP "order by ADDRESS_VAL DESC, STATUS_TYPE ASC;" , MSGFW_REPORT_TABLE_NAME, msgId); - int rowCnt; - msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt); + 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(); + if (err == MSG_ERR_DB_NORECORD) + return MSG_SUCCESS; return err; } - int index = 4; - - *count = rowCnt; + *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); @@ -2643,8 +2669,7 @@ msg_error_t MsgStoGetThreadInfo(msg_thread_id_t threadId, MSG_THREAD_VIEW_S *pTh MSG_BEGIN(); MsgDbHandler *dbHandle = getDbHandle(); - int rowCnt; - int index = 15; // numbers of index + int rowCnt = 0, index = 0; char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -2664,7 +2689,7 @@ msg_error_t MsgStoGetThreadInfo(msg_thread_id_t threadId, MSG_THREAD_VIEW_S *pTh 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(); @@ -2810,7 +2835,7 @@ msg_error_t MsgStoRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S int fileSize = 0; char *pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); // Get File Data if (pMsg->bTextSms == false) { @@ -2832,7 +2857,7 @@ msg_error_t MsgStoRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S 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, (int)pMsg->sim_idx, imsi); + pMsg->bBackup, pMsg->sim_idx, imsi); MSG_DEBUG("QUERY : %s", sqlQuery); @@ -2870,11 +2895,10 @@ msg_error_t MsgStoRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S /* 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->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); @@ -2985,7 +3009,7 @@ msg_error_t MsgCheckUniqueness(bool bInsert, msg_message_id_t msgId, MSG_UNIQUE_ 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); + dbHandle->getTable(sqlQuery, &nRowCnt, NULL); MSG_DEBUG("nRowCnt = [%d]", nRowCnt); dbHandle->freeTable(); @@ -3053,7 +3077,7 @@ msg_error_t MsgStoUpdateIMSI(int sim_idx) MSG_DEBUG("sim index is %d", sim_idx); memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", MSG_SIM_SUBS_ID, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SUBS_ID, sim_idx); char *imsi = MsgSettingGetString(keyName); diff --git a/framework/storage-handler/MsgStorageMms.cpp b/framework/storage-handler/MsgStorageMms.cpp index f11cb7c..91b5534 100755 --- a/framework/storage-handler/MsgStorageMms.cpp +++ b/framework/storage-handler/MsgStorageMms.cpp @@ -85,7 +85,7 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg) if( pMsg->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS ) { snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, FOLDER_ID = %d, DISPLAY_TIME = %lu, SUBJECT = ?, NETWORK_STATUS = %d, MSG_TEXT = ?, THUMB_PATH = '%s', DATA_SIZE = %d WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->displayTime, pMsg->networkStatus, pMsg->thumbPath, pMsg->dataSize, (int)pMsg->msgId); + 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) { return MSG_ERR_DB_PREPARE; @@ -93,7 +93,7 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg) dbHandle->bindText(pMsg->subject, 1); - if (pMsg->msgText[0] != '\0' && g_file_get_contents((const gchar*)pMsg->msgText, (gchar**)&pFileData, (gsize*)&fileSize, NULL) == true) { + if (pMsg->msgText[0] != '\0' && g_file_get_contents(pMsg->msgText, &pFileData, &fileSize, NULL) == true) { dbHandle->bindText(pFileData, 2); } else { dbHandle->bindText("", 2); @@ -109,13 +109,13 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg) } // if (MsgOpenAndReadFile(pMsg->msgText, &pFileData, &fileSize) == false) { - if (g_file_get_contents((gchar*)pMsg->msgText, (gchar**)&pFileData, (gsize*)&fileSize, NULL) == 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((gchar*)pMsg->msgText, (gchar**)&pFileData, (gsize*)&fileSize, NULL) == true) { + if (pMsg->msgText[0] != '\0' && g_file_get_contents(pMsg->msgText, &pFileData, &fileSize, NULL) == true) { dbHandle->bindText(pFileData, 2); } else { dbHandle->bindText("", 2); @@ -124,13 +124,13 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg) } else if (pMsg->msgType.subType == MSG_SENDREQ_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MMS) { snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_TEXT = ?, THUMB_PATH = '%s', DATA_SIZE = %d WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, pMsg->thumbPath, pMsg->dataSize, (int)pMsg->msgId); + MSGFW_MESSAGE_TABLE_NAME, pMsg->thumbPath, pMsg->dataSize, pMsg->msgId); if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { return MSG_ERR_DB_PREPARE; } - if (pMsg->msgText[0] != '\0' && g_file_get_contents((gchar*)pMsg->msgText, (gchar**)&pFileData, (gsize*)&fileSize, NULL) == true) { + if (pMsg->msgText[0] != '\0' && g_file_get_contents(pMsg->msgText, &pFileData, &fileSize, NULL) == true) { dbHandle->bindText(pFileData, 1); } else { dbHandle->bindText("", 1); @@ -292,19 +292,19 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg) } 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) { + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_PREPARE; } - if (row > 0) { + if (rowCnt > 0) { convId = dbHandle->getColumnToInt(1); MSG_DEBUG("Conversation id:[%d]", convId); @@ -394,8 +394,7 @@ 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 " @@ -407,7 +406,7 @@ msg_error_t MsgStoGetOrgAddressList(MSG_MESSAGE_INFO_S *pMsg) "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(); @@ -461,7 +460,7 @@ msg_error_t MsgStoGetRecipientList(msg_message_id_t msgId, MSG_RECIPIENTS_LIST_S return MSG_ERR_NULL_POINTER; } MsgDbHandler *dbHandle = getDbHandle(); - int rowCnt = 0, index = 3; + int rowCnt = 0, index = 0; char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -475,7 +474,7 @@ msg_error_t MsgStoGetRecipientList(msg_message_id_t msgId, MSG_RECIPIENTS_LIST_S MSGFW_MESSAGE_TABLE_NAME, MSGFW_ADDRESS_TABLE_NAME, msgId); - if (dbHandle->getTable(sqlQuery, &rowCnt) != MSG_SUCCESS) { + if (dbHandle->getTable(sqlQuery, &rowCnt, &index) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } diff --git a/framework/storage-handler/MsgStorageSim.cpp b/framework/storage-handler/MsgStorageSim.cpp index 80f9c2b..72c934a 100755 --- a/framework/storage-handler/MsgStorageSim.cpp +++ b/framework/storage-handler/MsgStorageSim.cpp @@ -53,7 +53,7 @@ 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("Fail to getTable()."); diff --git a/framework/storage-handler/MsgStorageUtil.cpp b/framework/storage-handler/MsgStorageUtil.cpp index 963e1a8..95cad90 100755 --- a/framework/storage-handler/MsgStorageUtil.cpp +++ b/framework/storage-handler/MsgStorageUtil.cpp @@ -113,7 +113,7 @@ 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); - if (dbHandle->getTable(sqlQuery, &rowCnt) != MSG_SUCCESS) { + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) { MSG_DEBUG("getTable is failed!!!"); } @@ -184,7 +184,7 @@ 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; @@ -196,7 +196,7 @@ 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(); @@ -280,8 +280,7 @@ msg_error_t MsgStoAutoDeleteConversation(msg_thread_id_t threadId, msg_id_list_s char sqlQuery[MAX_QUERY_LEN+1]; - int rowCnt = 0; - unsigned int index = 1; + int rowCnt = 0, index = 0; //memset(msgIdList, 0x00, sizeof(msg_id_list_s)); @@ -386,7 +385,7 @@ msg_error_t MsgStoAutoDeleteConversation(msg_thread_id_t threadId, msg_id_list_s 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); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { MSG_DEBUG("Fail to getTable()."); @@ -473,7 +472,7 @@ msg_error_t MsgStoAddWAPMsg(MSG_MESSAGE_INFO_S *pMsgInfo) int fileSize = 0; char* pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false) return MSG_ERR_STORAGE_ERROR; @@ -597,7 +596,7 @@ msg_error_t MsgStoAddCOWAPMsg(MSG_MESSAGE_INFO_S *pMsgInfo) int fileSize = 0; char* pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false) return MSG_ERR_STORAGE_ERROR; @@ -622,7 +621,7 @@ msg_error_t MsgStoAddCOWAPMsg(MSG_MESSAGE_INFO_S *pMsgInfo) if ((dbHandle->stepQuery() == MSG_ERR_DB_ROW) && err == MSG_SUCCESS) { - msgid = dbHandle->getColumnToInt(1); + 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); @@ -680,7 +679,7 @@ msg_error_t MsgStoAddCOWAPMsg(MSG_MESSAGE_INFO_S *pMsgInfo) if ((dbHandle->stepQuery() == MSG_ERR_DB_ROW) && err == MSG_SUCCESS) { - msgid = dbHandle->getColumnToInt(1); + 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); @@ -813,7 +812,7 @@ msg_error_t MsgStoCheckPushMsgValidation(MSG_PUSH_MESSAGE_S *pPushMsg, bool *pbP MSGFW_PUSH_MSG_TABLE_NAME, pPushMsg->id); } - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (rowCnt < 1) { dbHandle->freeTable(); @@ -838,14 +837,14 @@ msg_error_t MsgStoUpdateAllAddress() { msg_error_t err = MSG_SUCCESS; MsgDbHandler *dbHandle = getDbHandle(); - int rowCnt = 0, index = 1; + 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); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err == MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); diff --git a/framework/submit-handler/MsgSubmitHandler.cpp b/framework/submit-handler/MsgSubmitHandler.cpp index 7fdc83b..41e6825 100755 --- a/framework/submit-handler/MsgSubmitHandler.cpp +++ b/framework/submit-handler/MsgSubmitHandler.cpp @@ -82,7 +82,7 @@ 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 @@ -91,6 +91,8 @@ msg_error_t MsgSubmitReqSMS(MSG_REQUEST_INFO_S *pReqInfo) 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); @@ -107,7 +109,7 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo) MsgPlugin *sms_plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE); if (sms_plg == NULL){ - THROW(MsgException::PLUGIN_ERROR, "No plugin for %d type", MSG_SMS_TYPE); + return MSG_ERR_NULL_POINTER; } int defaultNetworkSimId = 0; @@ -316,18 +318,25 @@ 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 [%d]", bKeepCopy); + if (bKeepCopy == true) + err = MsgStoMoveMessageToFolder(MsgId, MSG_SENTBOX_ID); + } +#endif return err; } diff --git a/framework/transaction-manager/MsgCmdHandlerFilter.cpp b/framework/transaction-manager/MsgCmdHandlerFilter.cpp index 63198f1..614a9fa 100755 --- a/framework/transaction-manager/MsgCmdHandlerFilter.cpp +++ b/framework/transaction-manager/MsgCmdHandlerFilter.cpp @@ -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 @@ -115,6 +130,11 @@ 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 @@ -149,8 +169,13 @@ 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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -192,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 @@ -222,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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> 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 00c4229..7a25234 100755 --- a/framework/transaction-manager/MsgCmdHandlerSetting.cpp +++ b/framework/transaction-manager/MsgCmdHandlerSetting.cpp @@ -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,8 +95,13 @@ 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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0; int eventSize = 0; diff --git a/framework/transaction-manager/MsgCmdHandlerStorage.cpp b/framework/transaction-manager/MsgCmdHandlerStorage.cpp index 48386d5..d59b71e 100755 --- a/framework/transaction-manager/MsgCmdHandlerStorage.cpp +++ b/framework/transaction-manager/MsgCmdHandlerStorage.cpp @@ -61,8 +61,13 @@ 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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -72,7 +77,7 @@ int MsgAddMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo, &sendOptInfo); @@ -138,8 +143,13 @@ int MsgAddSyncMLMessageHandler(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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -149,7 +159,7 @@ int MsgAddSyncMLMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> 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)); @@ -196,6 +206,11 @@ 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; MSG_MESSAGE_INFO_S msgInfo; @@ -204,7 +219,7 @@ int MsgUpdateMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo, &sendOptInfo); @@ -242,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; @@ -286,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; @@ -354,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; @@ -396,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; @@ -439,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; @@ -474,12 +514,17 @@ 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); + memcpy(&msgIdList.nCount, pCmd->cmdData, sizeof(int)); MSG_DEBUG("msgIdList.nCount [%d]", msgIdList.nCount); @@ -513,6 +558,11 @@ 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; @@ -551,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; @@ -582,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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -618,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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -654,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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -670,7 +740,7 @@ int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); err = MsgStoGetMessage(*msgId, &msgInfo, &sendOptInfo); @@ -695,62 +765,15 @@ int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) } -int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) -{ - // Get Folder ID - msg_folder_id_t folderId; - MSG_SORT_RULE_S sortRule; - - memcpy(&folderId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_folder_id_t)); - 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<char> buf(&encodedData); - - int dataSize = 0, eventSize = 0; - -#if 0 - // Get Message Common Info - msg_struct_list_s folderViewList; - -// err = MsgStoGetFolderViewList(folderId, &sortRule, &folderViewList); - - if (err == MSG_SUCCESS) - { - MSG_DEBUG("Command Handle Success : MsgStoGetFolderViewList()"); - - // Encoding Folder View List Data -// dataSize = MsgEncodeFolderViewList(&folderViewList, &encodedData); - - MSG_DEBUG("dataSize [%d]", dataSize); - - 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 - { - MSG_DEBUG("Command Handle Fail : MsgStoGetFolderViewList()"); - return err; - } -#endif - // Make Event Data - eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_FOLDERVIEWLIST, MSG_SUCCESS, (void**)ppEvent); - - return eventSize; -} - - 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 @@ -779,6 +802,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 @@ -807,6 +835,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 @@ -835,8 +868,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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -878,6 +916,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 @@ -890,57 +933,21 @@ int MsgInitSimBySatHandler(const MSG_CMD_S *pCmd, char **ppEvent) } -int MsgGetMsgTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent) +int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; - char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); - - - int dataSize = 0, eventSize = 0; - - // Get Message ID - msg_message_id_t msgId; - - memcpy(&msgId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_id_t)); - - // Get Msg Type - MSG_MESSAGE_TYPE_S msgType; - - err = MsgStoGetMsgType(msgId, &msgType); - - if (err == MSG_SUCCESS) - { - MSG_DEBUG("Command Handle Success : MsgStoGetMsgType()"); - - // Encoding Storage List Data - dataSize = MsgEncodeMsgType(&msgType, &encodedData); - - } - else - { - MSG_DEBUG("Command Handle Fail : MsgStoGetMsgType()"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; } - // Make Event Data - eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_MSG_TYPE, err, (void**)ppEvent); - - return eventSize; -} - - -int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) -{ - - msg_error_t err = MSG_SUCCESS; - MSG_SORT_RULE_S sortRule = {0}; memcpy(&sortRule, pCmd->cmdData, sizeof(MSG_SORT_RULE_S)); char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; #if 0 @@ -981,57 +988,14 @@ int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) } -int MsgGetConversationViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent) +int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent) { msg_error_t err = MSG_SUCCESS; - 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<char> buf(&encodedData); - - int dataSize = 0, eventSize = 0; -#if 0 - msg_struct_list_s convViewList; - - //err = MsgStoGetConversationViewList(threadId, &convViewList); - - if (err == MSG_SUCCESS) - { - MSG_DEBUG("Command Handle Success : MsgStoGetConversationViewList()"); - - // Encoding Folder View List Data - dataSize = MsgEncodeConversationViewList(&convViewList, &encodedData); - - MSG_DEBUG("dataSize [%d]", dataSize); - - 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()"); + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; } -#endif - // Make Event Data - eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_GET_CONVERSATIONVIEWLIST, err, (void**)ppEvent); - - return eventSize; -} - - -int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent) -{ - msg_error_t err = MSG_SUCCESS; msg_thread_id_t threadId; bool bIncludeProtect = false; @@ -1079,13 +1043,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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1119,11 +1088,16 @@ 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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1132,7 +1106,7 @@ int MsgGetQuickPanelDataHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); err = MsgStoGetQuickPanelData(*type, &msgInfo); @@ -1159,6 +1133,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 @@ -1180,8 +1159,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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1203,6 +1187,11 @@ 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; @@ -1229,6 +1218,11 @@ 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,}; @@ -1267,12 +1261,17 @@ 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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1314,11 +1313,16 @@ 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; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); int *addrCnt = (int *)pCmd->cmdData; MSG_DEBUG("*addrCnt [%d]", *addrCnt); @@ -1331,7 +1335,7 @@ int MsgGetThreadIdByAddressHandler(const MSG_CMD_S *pCmd, char **ppEvent) memcpy(&msgInfo.addressList[i], (MSG_ADDRESS_INFO_S *)(pCmd->cmdData+sizeof(int)+(sizeof(MSG_ADDRESS_INFO_S)*i)), sizeof(MSG_ADDRESS_INFO_S)); char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1363,8 +1367,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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0; int eventSize = 0; @@ -1401,7 +1410,7 @@ int MsgCheckReadReportRequestedHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1437,7 +1446,7 @@ int MsgCheckReadReportIsSentHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1476,7 +1485,7 @@ int MsgSetReadReportSendStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1512,7 +1521,7 @@ int MsgGetMmsVersionHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1551,7 +1560,7 @@ int MsgGetMmsStatusInfoHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = 0, eventSize = 0; @@ -1587,6 +1596,11 @@ 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 @@ -1611,6 +1625,11 @@ 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 @@ -1635,6 +1654,10 @@ 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; @@ -1661,6 +1684,11 @@ 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; @@ -1669,7 +1697,7 @@ int MsgAddSimMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&sendOptInfo, 0x00, sizeof(MSG_SENDINGOPT_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo); @@ -1739,6 +1767,10 @@ 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; diff --git a/framework/transaction-manager/MsgCmdHandlerTransport.cpp b/framework/transaction-manager/MsgCmdHandlerTransport.cpp index 2b99744..fff6286 100755 --- a/framework/transaction-manager/MsgCmdHandlerTransport.cpp +++ b/framework/transaction-manager/MsgCmdHandlerTransport.cpp @@ -33,6 +33,7 @@ #include "MsgAlarm.h" #include "MsgCmdHandler.h" #include "MsgDevicedWrapper.h" +#include "MsgMmsMessage.h" /*================================================================================================== @@ -43,13 +44,18 @@ 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; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&reqInfo.msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&reqInfo.msgInfo.addressList, unique_ptr_deleter); // Get Message Request memcpy(&reqInfo.reqId, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_request_id_t)); @@ -59,6 +65,19 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent) MsgDecodeMsgInfo((char *)(pCmd->cmdData+sizeof(msg_request_id_t)+sizeof(MSG_PROXY_INFO_S)), &reqInfo.msgInfo, &reqInfo.sendOptInfo); + + if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE + && reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_MMS) { + int fd = 0; + memcpy(&fd, pCmd->cmdCookie, sizeof(int)); + if (reqInfo.msgInfo.bTextSms == false) { + err = MsgMmsCheckFilepathSmack(fd, reqInfo.msgInfo.msgData); + if (err != MSG_SUCCESS) { + return MsgMakeEvent(NULL, 0, MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent); + } + } + } + if (reqInfo.msgInfo.msgId > 0) bNewMsg = false; @@ -142,42 +161,17 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent) } -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); - - if (err == MSG_SUCCESS) - { - MSG_DEBUG("Command Handle Success : MsgSubCancelReq()"); - } - else - { - MSG_DEBUG("Command Handle Fail : MsgSubCancelReq()"); - } - - // Make Event Data - eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_CANCEL_REQ, err, (void**)ppEvent); - - return eventSize; -} - - 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); + int listenerFd = 0; + memcpy(&listenerFd, pCmd->cmdData, sizeof(int)); MSG_DEBUG("Registering sent status CB for %d", listenerFd); // storing dst fd in list @@ -193,8 +187,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; @@ -213,8 +209,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; @@ -232,8 +230,10 @@ int MsgRegIncomingMMSConfMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEven int MsgRegIncomingPushMsgCallbackHandler(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_PUSH_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S*) pCmd->cmdData; @@ -255,8 +255,10 @@ int MsgRegIncomingPushMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgRegIncomingCBMsgCallbackHandler(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_CB_MSG_CB_S *pCmdData = (MSG_CMD_REG_INCOMING_CB_MSG_CB_S*) pCmd->cmdData; @@ -275,8 +277,10 @@ int MsgRegIncomingCBMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) 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; @@ -295,8 +299,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; @@ -315,8 +321,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; @@ -335,11 +343,14 @@ 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); + int listenerFd = 0; + memcpy(&listenerFd, pCmd->cmdData, sizeof(int)); MSG_DEBUG("Registering storage change CB for %d", listenerFd); // storing dst fd in list @@ -355,11 +366,14 @@ int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgRegIncomingReportMsgCallbackHandler(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); + int listenerFd = 0; + memcpy(&listenerFd, pCmd->cmdData, sizeof(int)); MSG_DEBUG("Registering report msg incoming CB for %d", listenerFd); // storing dst fd in list @@ -375,8 +389,10 @@ int MsgRegIncomingReportMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent 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; @@ -391,21 +407,22 @@ int MsgSentStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent) return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent); } -// MSG_DEBUG("REQID %d, listenerFD %d, handleAddr %x, msgId %d", pStatus->reqId, prxInfo->listenerFd, prxInfo->handleAddr, prxInfo->sentMsgId); + MSG_DEBUG("REQID %d, listenerFD %d, handleAddr %x, msgId %d", pStatus->reqId, prxInfo->listenerFd, prxInfo->handleAddr, prxInfo->sentMsgId); // if APP send and quit(not exist at this time), don't send the data up. -// if (prxInfo->handleAddr == 0) -// { -// // just making data which will be passed to plugin. it indicates "handling evt success" -// MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId); -// -// return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent); -// } + if (prxInfo->handleAddr == 0) + { + // just making data which will be passed to plugin. it indicates "handling evt success" + MsgTransactionManager::instance()->delProxyInfo(pStatus->reqId); + + return MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent); + } unsigned int ret[3] = {0}; //3// reqid, status, object ret[0] = pStatus->reqId; ret[1] = pStatus->status; + ret[2] = prxInfo->handleAddr; // Make Event Data for APP int eventSize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_PLG_SENT_STATUS_CNF, MSG_SUCCESS, (void**)ppEvent); @@ -429,15 +446,17 @@ int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) 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)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo); @@ -513,6 +532,12 @@ int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) { MSG_BEGIN(); + + if (!pCmd || !ppEvent) { + MSG_DEBUG("pCmd or ppEvent is null"); + return 0; + } + msg_error_t err = MSG_SUCCESS; int eventsize = 0; @@ -522,7 +547,7 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> 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); @@ -674,15 +699,16 @@ __BYPASS_UPDATE: } if (prxInfo) { -// if (prxInfo->handleAddr == 0) { -// // just making data which will be passed to plugin. it indicates "handling evt success" -// MsgTransactionManager::instance()->delProxyInfo(reqID); -// } else { + if (prxInfo->handleAddr == 0) { + // just making data which will be passed to plugin. it indicates "handling evt success" + MsgTransactionManager::instance()->delProxyInfo(reqID); + } else { unsigned int ret[3] = {0}; //3// reqid, status, object 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); @@ -691,7 +717,7 @@ __BYPASS_UPDATE: MsgTransactionManager::instance()->write(prxInfo->listenerFd, *ppEvent, eventsize); MsgTransactionManager::instance()->delProxyInfo(reqID); -// } + } } eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_SUCCESS, (void**)ppEvent); @@ -715,8 +741,10 @@ int MsgIncomingPushMsgHandler(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_PUSH_MESSAGE_DATA_S pushData; memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S)); @@ -744,8 +772,10 @@ int MsgIncomingCBMsgHandler(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; + } // Get Incoming Message MSG_CB_MSG_S cbMsg; @@ -757,7 +787,7 @@ int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo((char *)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_CB_MSG_S), &msgInfo); @@ -778,7 +808,7 @@ int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) 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); + MsgTransactionManager::instance()->broadcastCBMsgCB(err, &cbMsg, msgInfo.msgId); eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)ppEvent); @@ -790,8 +820,10 @@ int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) 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)); @@ -816,8 +848,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)); @@ -840,7 +874,7 @@ int MsgSyncMLMsgOperationHandler(const MSG_CMD_S *pCmd, char **ppEvent) msg_error_t err = MSG_SUCCESS; char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int eventSize = 0; @@ -848,8 +882,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)); @@ -879,8 +915,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; @@ -891,7 +929,7 @@ 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<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int eventSize = 0; @@ -926,11 +964,15 @@ 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; - AutoPtr<int> failed_list(&failed_msg_list); + unique_ptr<int*, void(*)(int**)> failed_list(&failed_msg_list, unique_ptr_deleter); err = MsgStoGetFailedMessage(&failed_msg_list, &count); @@ -942,7 +984,7 @@ int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) { MSG_REQUEST_INFO_S reqInfo = {0}; reqInfo.msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&reqInfo.msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&reqInfo.msgInfo.addressList, unique_ptr_deleter); reqInfo.msgInfo.msgId = failed_msg_list[i]; err = MsgStoGetMessage(reqInfo.msgInfo.msgId, &(reqInfo.msgInfo), &(reqInfo.sendOptInfo)); @@ -979,27 +1021,6 @@ int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent) return eventSize; } -#ifdef MSG_PENDING_PUSH_MESSAGE -int MsgSendPendingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) -{ - MSG_BEGIN(); - - int eventSize = 0; - - // input check - if (!pCmd || !ppEvent) - THROW(MsgException::INVALID_PARAM, "pCmd or ppEvent is null"); - - MsgTransactionManager::instance()->sendPendingPushMsg(); - - // Make Event Data - eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SEND_PENDING_PUSH_MESSAGE, MSG_SUCCESS, (void**)ppEvent); - - MSG_END(); - return eventSize; -} -#endif - #ifdef FEATURE_SMS_CDMA int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent) { @@ -1009,8 +1030,10 @@ int MsgCheckUniquenessHandler(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; + } // Get Incoming Message bool bInsert; diff --git a/framework/transaction-manager/MsgTransManager.cpp b/framework/transaction-manager/MsgTransManager.cpp index c1f0e91..d4e7d87 100755 --- a/framework/transaction-manager/MsgTransManager.cpp +++ b/framework/transaction-manager/MsgTransManager.cpp @@ -20,6 +20,9 @@ #include <sys/stat.h> #include <pthread.h> +#include <bundle_internal.h> +#include <eventsystem.h> + #include "MsgDebug.h" #include "MsgMemory.h" #include "MsgException.h" @@ -37,7 +40,20 @@ #include "MsgTransManager.h" #define MSG_CHECK_PRIVILEGE +#define MSG_EVENT_MSG_ID_LEN (32) + +void MsgMakeErrorEvent(MSG_CMD_TYPE_T cmdType, msg_error_t errType, int *pEventSize, char **ppEvent) +{ + if (*ppEvent) delete [] *ppEvent; + + *pEventSize = sizeof(MSG_EVENT_S); + *ppEvent = new char[sizeof(MSG_EVENT_S)]; + MSG_EVENT_S* pMsgEvent = (MSG_EVENT_S*)*ppEvent; + + pMsgEvent->eventType = cmdType; + pMsgEvent->result = errType; +} /*================================================================================================== IMPLEMENTATION OF MsgTransactionManager - Member Functions @@ -49,9 +65,6 @@ MsgIpcServerSocket MsgTransactionManager::servSock; MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv(), eventQueue() { sentMsgMap.clear(); -#ifdef MSG_PENDING_PUSH_MESSAGE - pushMsgList.clear(); -#endif statusCBFdMap.clear(); newMsgCBList.clear(); newMMSConfMsgCBList.clear(); @@ -75,7 +88,6 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv(), eve handlerMap[MSG_CMD_MOVE_MSGTOSTORAGE] = &MsgMoveMessageToStorageHandler; handlerMap[MSG_CMD_COUNT_MSG] = &MsgCountMessageHandler; handlerMap[MSG_CMD_GET_MSG] = &MsgGetMessageHandler; - handlerMap[MSG_CMD_GET_FOLDERVIEWLIST] = &MsgGetFolderViewListHandler; handlerMap[MSG_CMD_ADD_FOLDER] = &MsgAddFolderHandler; handlerMap[MSG_CMD_UPDATE_FOLDER] = &MsgUpdateFolderHandler; @@ -90,10 +102,7 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv(), eve 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; @@ -118,7 +127,6 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv(), eve handlerMap[MSG_CMD_PLG_INIT_SIM_BY_SAT] = &MsgInitSimBySatHandler; handlerMap[MSG_CMD_GET_THREADVIEWLIST] = &MsgGetThreadViewListHandler; - handlerMap[MSG_CMD_GET_CONVERSATIONVIEWLIST] = &MsgGetConversationViewListHandler; handlerMap[MSG_CMD_DELETE_THREADMESSAGELIST] = &MsgDeleteThreadMessageListHandler; handlerMap[MSG_CMD_GET_CONTACT_COUNT] = &MsgCountMsgByContactHandler; @@ -163,9 +171,6 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv(), eve handlerMap[MSG_CMD_DELETE_MESSAGE_BY_LIST] = &MsgDeleteMessageByListHandler; handlerMap[MSG_CMD_ADD_SIM_MSG] = &MsgAddSimMessageHandler; handlerMap[MSG_CMD_PLG_RESEND_MESSAGE] = &MsgResendMessageHandler; -#ifdef MSG_PENDING_PUSH_MESSAGE - handlerMap[MSG_CMD_SEND_PENDING_PUSH_MESSAGE] = &MsgSendPendingPushMsgHandler; -#endif #ifdef FEATURE_SMS_CDMA handlerMap[MSG_CMD_PLG_CHECK_UNIQUENESS] = &MsgCheckUniquenessHandler; #endif @@ -225,7 +230,7 @@ void MsgTransactionManager::run() // setTMStatus(); if(select(nfds, &readfds, NULL, NULL, NULL) == -1) { - THROW(MsgException::SELECT_ERROR, "select error : %s", strerror(errno)); + THROW(MsgException::SELECT_ERROR, "select error : %s", g_strerror(errno)); } try @@ -310,9 +315,10 @@ void MsgTransactionManager::workerEventQueue() MSG_CMD_S* pCmd = NULL; int (*pfHandler)(const MSG_CMD_S*, char**) = NULL; char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); int fd = -1; + int eventSize = 0; while (1) { mx.lock(); @@ -337,17 +343,15 @@ void MsgTransactionManager::workerEventQueue() pfHandler = handlerMap[pCmd->cmdType]; if (!pfHandler) { MSG_FATAL("No handler for %d", pCmd->cmdType); - g_free (pCmd); pCmd = NULL; - continue; - } - - // run handler function - int eventSize = pfHandler(pCmd, &pEventData); + 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); - g_free (pCmd); pCmd = NULL; - continue; + 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); @@ -363,8 +367,8 @@ void MsgTransactionManager::handleRequest(int fd) MSG_DEBUG("Event from fd %d", fd); char* buf = NULL; - AutoPtr<char> wrap(&buf); - int len; + unique_ptr<char*, void(*)(char**)> 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) @@ -378,7 +382,7 @@ void MsgTransactionManager::handleRequest(int fd) THROW(MsgException::INVALID_RESULT, "read buffer size <= 0"); char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); int eventSize = 0; @@ -394,14 +398,7 @@ void MsgTransactionManager::handleRequest(int fd) if (checkPrivilege(fd, pCmd->cmdType) == false) { MSG_DEBUG("No Privilege rule. Not allowed."); #ifdef MSG_CHECK_PRIVILEGE - eventSize = sizeof(MSG_EVENT_S); - - pEventData = new char[eventSize]; - - MSG_EVENT_S* pMsgEvent = (MSG_EVENT_S*)pEventData; - - pMsgEvent->eventType = pCmd->cmdType; - pMsgEvent->result = MSG_ERR_PERMISSION_DENIED; + MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_PERMISSION_DENIED, &eventSize, &pEventData); MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize); servSock.write(fd, pEventData, eventSize); @@ -425,25 +422,32 @@ void MsgTransactionManager::handleRequest(int fd) case MSG_CMD_PLG_INCOMING_CB_IND: { MSG_CMD_S* pCmdDup = (MSG_CMD_S*) calloc (1, len); /* pCmdDup should be freed afterward */ - 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(); + 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) - THROW(MsgException::INVALID_PARAM, "No handler for %d", pCmd->cmdType); - - // run handler function - eventSize = pfHandler(pCmd, &pEventData); + if (!pfHandler) { + MSG_FATAL("No handler for %d", pCmd->cmdType); + MsgMakeErrorEvent(pCmd->cmdType, MSG_ERR_INVALID_PARAMETER, &eventSize, &pEventData); + } else { + // run handler function + memcpy (pCmd->cmdCookie, &fd, sizeof(int)); /* Now, cmdCookie keeps fd for return */ + eventSize = pfHandler(pCmd, &pEventData); - if (eventSize == 0 || pEventData == NULL) - THROW(MsgException::INVALID_RESULT, "event size = 0 or event data = NULL"); + 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); @@ -994,23 +998,23 @@ void MsgTransactionManager::broadcastIncomingMsgCB(const msg_error_t err, const int fileSize = 0; char* pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); -// if (MsgOpenAndReadFile(msgInfo->msgData, &pFileData, &fileSize) == true) -// MsgLbsSms(pFileData, fileSize); -// else + if (MsgOpenAndReadFile(msgInfo->msgData, &pFileData, &fileSize) == true) + MsgLbsSms(pFileData, fileSize); + else MSG_DEBUG("MsgOpenAndReadFile failed."); } else { -// MsgLbsSms(msgInfo->msgText, (int)msgInfo->dataSize); + MsgLbsSms(msgInfo->msgText, (int)msgInfo->dataSize); } return; } char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(msgInfo, &encodedData); int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)(&pEventData)); @@ -1032,6 +1036,22 @@ void MsgTransactionManager::broadcastIncomingMsgCB(const msg_error_t err, const } } + /* Send system event */ + bundle *b = NULL; + b = bundle_create(); + if (b) { + if (msgInfo->msgType.subType >= MSG_WAP_SI_SMS && msgInfo->msgType.subType <= MSG_WAP_CO_SMS) { + bundle_add(b, EVT_KEY_MSG_TYPE, EVT_VAL_PUSH); + } else { + bundle_add(b, EVT_KEY_MSG_TYPE, EVT_VAL_SMS); + } + char msgId[MSG_EVENT_MSG_ID_LEN] = {0,}; + snprintf(msgId, sizeof(msgId), "%u", msgInfo->msgId); + bundle_add(b, EVT_KEY_MSG_ID, msgId); + eventsystem_send_system_event(SYS_EVENT_INCOMMING_MSG, b); + bundle_free(b); + } + MSG_END(); } @@ -1041,10 +1061,10 @@ void MsgTransactionManager::broadcastMMSConfCB(const msg_error_t err, const MSG_ MSG_BEGIN(); char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(msgInfo, &encodedData); int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)(&pEventData)); @@ -1082,19 +1102,7 @@ void MsgTransactionManager::broadcastPushMsgCB(const msg_error_t err, const MSG_ MSG_BEGIN(); char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED -#ifdef MSG_PENDING_PUSH_MESSAGE - int bReady = MsgSettingGetInt(VCONFKEY_USER_SERVICE_READY); - if(!bReady) - { - MSG_PUSH_MESSAGE_DATA_S push_msg; - memcpy(&push_msg, pushData, sizeof(MSG_PUSH_MESSAGE_DATA_S)); - pushMsgList.push_back(push_msg); - return; - } -#endif -#endif + unique_ptr<char*, void(*)(char**)> 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)); @@ -1113,12 +1121,12 @@ void MsgTransactionManager::broadcastPushMsgCB(const msg_error_t err, const MSG_ MSG_END(); } -void MsgTransactionManager::broadcastCBMsgCB(const msg_error_t err, const MSG_CB_MSG_S *cbMsg) +void MsgTransactionManager::broadcastCBMsgCB(const msg_error_t err, const MSG_CB_MSG_S *cbMsg, msg_message_id_t cbMsgId) { MSG_BEGIN(); char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); int eventSize = MsgMakeEvent(cbMsg, sizeof(MSG_CB_MSG_S), MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)(&pEventData)); @@ -1130,6 +1138,18 @@ void MsgTransactionManager::broadcastCBMsgCB(const msg_error_t err, const MSG_CB write(it->listenerFd, pEventData, eventSize); } + /* Send system event */ + bundle *b = NULL; + b = bundle_create(); + if (b) { + bundle_add(b, EVT_KEY_MSG_TYPE, EVT_VAL_CB); + char msgId[MSG_EVENT_MSG_ID_LEN] = {0,}; + snprintf(msgId, sizeof(msgId), "%u", cbMsgId); + bundle_add(b, EVT_KEY_MSG_ID, msgId); + eventsystem_send_system_event(SYS_EVENT_INCOMMING_MSG, b); + bundle_free(b); + } + MSG_END(); } @@ -1138,7 +1158,7 @@ void MsgTransactionManager::broadcastSyncMLMsgCB(const msg_error_t err, const MS MSG_BEGIN(); char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> 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)); @@ -1160,7 +1180,7 @@ void MsgTransactionManager::broadcastLBSMsgCB(const msg_error_t err, const MSG_L #if 0 char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> 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)); @@ -1172,7 +1192,7 @@ void MsgTransactionManager::broadcastLBSMsgCB(const msg_error_t err, const MSG_L write(it->listenerFd, pEventData, eventSize); } #else -// MsgLbsWapPush(lbsData->pushHeader, lbsData->pushBody, lbsData->pushBodyLen); + MsgLbsWapPush(lbsData->pushHeader, lbsData->pushBody, lbsData->pushBodyLen); #endif MSG_END(); } @@ -1183,10 +1203,10 @@ void MsgTransactionManager::broadcastSyncMLMsgOperationCB(const msg_error_t err, MSG_BEGIN(); char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); // Encoding Storage Change Data int dataSize = MsgEncodeSyncMLOperationData(msgId, extId, &encodedData); @@ -1219,10 +1239,10 @@ void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, cons int dataSize = 0; char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); // Encoding Storage Change Data dataSize = MsgEncodeStorageChangeData(storageChangeType, pMsgIdList, &encodedData); @@ -1255,10 +1275,10 @@ void MsgTransactionManager::broadcastReportMsgCB(const msg_error_t err, const ms int dataSize = 0; char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); // Encoding Storage Change Data dataSize = MsgEncodeReportMsgData(reportMsgType, pMsgInfo, &encodedData); @@ -1348,24 +1368,3 @@ void MsgTransactionManager::finishCynara() p_cynara = NULL; } - - -#ifdef MSG_PENDING_PUSH_MESSAGE -void MsgTransactionManager::sendPendingPushMsg(void) -{ - - pushpending_list::iterator pushmsg_it = pushMsgList.begin(); - while(pushmsg_it != pushMsgList.end()) - { - MSG_PUSH_MESSAGE_DATA_S msg; - memset(&msg, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S)); - memcpy(msg.pushAppId, pushmsg_it->pushAppId, sizeof(msg.pushAppId)); - memcpy(msg.pushBody, pushmsg_it->pushBody, sizeof(msg.pushBody)); - memcpy(msg.pushContentType, pushmsg_it->pushContentType, sizeof(msg.pushContentType)); - memcpy(msg.pushHeader, pushmsg_it->pushHeader, sizeof(msg.pushHeader)); - msg.pushBodyLen = pushmsg_it->pushBodyLen; - MsgTransactionManager::instance()->broadcastPushMsgCB(MSG_SUCCESS, (const MSG_PUSH_MESSAGE_DATA_S *)&msg); - pushmsg_it = pushMsgList.erase(pushmsg_it); - } -} -#endif diff --git a/include/common/MsgCmdTypes.h b/include/common/MsgCmdTypes.h index 9b6ff41..ecab740 100755 --- a/include/common/MsgCmdTypes.h +++ b/include/common/MsgCmdTypes.h @@ -42,15 +42,15 @@ typedef unsigned int MSG_EVENT_TYPE_T; ==================================================================================================*/ typedef struct _MSG_CMD_S { - MSG_CMD_TYPE_T cmdType; + MSG_CMD_TYPE_T cmdType; char cmdCookie[MAX_COOKIE_LEN]; - char cmdData[2]; + char cmdData[2]; } MSG_CMD_S; typedef struct _MSG_EVENT_S { - MSG_EVENT_TYPE_T eventType; + MSG_EVENT_TYPE_T eventType; msg_error_t result; char data[2]; } MSG_EVENT_S; @@ -67,114 +67,99 @@ enum _MSG_CMD_TYPE_E MSG_CMD_GET_STORAGELIST, MSG_CMD_ADD_MSG, MSG_CMD_ADD_SYNCML_MSG, - +// 5 MSG_CMD_UPDATE_MSG, MSG_CMD_UPDATE_READ, MSG_CMD_UPDATE_PROTECTED, MSG_CMD_DELETE_MSG, MSG_CMD_DELALL_MSGINFOLDER, - // 10 MSG_CMD_MOVE_MSGTOFOLDER, MSG_CMD_MOVE_MSGTOSTORAGE, MSG_CMD_COUNT_MSG, MSG_CMD_GET_MSG, - MSG_CMD_GET_FOLDERVIEWLIST, - MSG_CMD_ADD_FOLDER, +// 15 MSG_CMD_UPDATE_FOLDER, MSG_CMD_DELETE_FOLDER, MSG_CMD_GET_FOLDERLIST, MSG_CMD_ADD_FILTER, - -// 20 MSG_CMD_UPDATE_FILTER, +// 20 MSG_CMD_DELETE_FILTER, MSG_CMD_GET_FILTERLIST, MSG_CMD_SET_FILTER_OPERATION, MSG_CMD_GET_FILTER_OPERATION, - - MSG_CMD_GET_MSG_TYPE, MSG_CMD_SUBMIT_REQ, - MSG_CMD_CANCEL_REQ, +// 25 MSG_CMD_REG_SENT_STATUS_CB, MSG_CMD_REG_STORAGE_CHANGE_CB, - -// 30 MSG_CMD_REG_INCOMING_MSG_CB, MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB, MSG_CMD_REG_INCOMING_SYNCML_MSG_CB, +// 30 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, +//35 MSG_CMD_PLG_INCOMING_SYNCML_IND, MSG_CMD_PLG_INCOMING_LBS_IND, - -// 40 MSG_CMD_PLG_INIT_SIM_BY_SAT, MSG_CMD_GET_THREADVIEWLIST, - MSG_CMD_GET_CONVERSATIONVIEWLIST, MSG_CMD_DELETE_THREADMESSAGELIST, +// 40 MSG_CMD_GET_CONTACT_COUNT, - MSG_CMD_GET_QUICKPANEL_DATA, MSG_CMD_COUNT_BY_MSGTYPE, MSG_CMD_RESET_DB, MSG_CMD_GET_MEMSIZE, +// 45 MSG_CMD_BACKUP_MESSAGE, - -// 50 MSG_CMD_RESTORE_MESSAGE, MSG_CMD_UPDATE_THREAD_READ, MSG_CMD_REG_SYNCML_MSG_OPERATION_CB, MSG_CMD_SYNCML_OPERATION, +// 50 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, +// 55 MSG_CMD_GET_SMS_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, +// 60 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, +// 65 MSG_CMD_SET_MMS_SEND_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, +// 70 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, +//75 MSG_CMD_ADD_PUSH_EVENT, - -// 80 MSG_CMD_DELETE_PUSH_EVENT, MSG_CMD_UPDATE_PUSH_EVENT, MSG_CMD_DELETE_MESSAGE_BY_LIST, MSG_CMD_SET_FILTER_ACTIVATION, +// 80 MSG_CMD_ADD_SIM_MSG, - -// 85 MSG_CMD_PLG_RESEND_MESSAGE, - MSG_CMD_SEND_PENDING_PUSH_MESSAGE, MSG_CMD_REG_REPORT_MSG_INCOMING_CB, MSG_CMD_UPDATE_IMSI, @@ -192,126 +177,114 @@ enum _MSG_EVENT_TYPE_E MSG_EVENT_GET_STORAGELIST, MSG_EVENT_ADD_MSG, MSG_EVENT_ADD_SYNCML_MSG, - +// 5 MSG_EVENT_UPDATE_MSG, MSG_EVENT_UPDATE_READ, MSG_EVENT_UPDATE_PROTECTED, MSG_EVENT_DELETE_MSG, MSG_EVENT_DELALL_MSGINFOLDER, - // 10 MSG_EVENT_MOVE_MSGTOFOLDER, MSG_EVENT_MOVE_MSGTOSTORAGE, MSG_EVENT_COUNT_MSG, MSG_EVENT_GET_MSG, - MSG_EVENT_GET_FOLDERVIEWLIST, - MSG_EVENT_ADD_FOLDER, +// 15 MSG_EVENT_UPDATE_FOLDER, MSG_EVENT_DELETE_FOLDER, MSG_EVENT_GET_FOLDERLIST, MSG_EVENT_ADD_FILTER, - -// 20 MSG_EVENT_UPDATE_FILTER, +// 20 MSG_EVENT_DELETE_FILTER, MSG_EVENT_GET_FILTERLIST, MSG_EVENT_SET_FILTER_OPERATION, MSG_EVENT_GET_FILTER_OPERATION, - - MSG_EVENT_GET_MSG_TYPE, MSG_EVENT_SUBMIT_REQ, - MSG_EVENT_CANCEL_REQ, +// 25 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, +// 30 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, +//35 MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, - -// 40 MSG_EVENT_PLG_INIT_SIM_BY_SAT, MSG_EVENT_GET_THREADVIEWLIST, - MSG_EVENT_GET_CONVERSATIONVIEWLIST, MSG_EVENT_DELETE_THREADMESSAGELIST, +// 40 MSG_EVENT_GET_CONTACT_COUNT, - MSG_EVENT_GET_QUICKPANEL_DATA, MSG_EVENT_COUNT_BY_MSGTYPE, MSG_EVENT_RESET_DB, MSG_EVENT_GET_MEMSIZE, +//45 MSG_EVENT_BACKUP_MESSAGE, - -// 50 MSG_EVENT_RESTORE_MESSAGE, MSG_EVENT_UPDATE_THREAD_READ, MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB, MSG_EVENT_SYNCML_OPERATION, +// 50 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, +// 55 MSG_EVENT_GET_SMS_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, +// 60 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, +// 65 MSG_EVENT_SET_MMS_SEND_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, +// 70 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, +// 75 MSG_EVENT_ADD_PUSH_EVENT, - -// 80 MSG_EVENT_DELETE_PUSH_EVENT, MSG_EVENT_UPDATE_PUSH_EVENT, MSG_EVENT_DELETE_MESSAGE_BY_LIST, MSG_EVENT_SET_FILTER_ACTIVATION, +// 80 MSG_EVENT_ADD_SIM_MSG, - -// 85 MSG_EVENT_PLG_RESEND_MESSAGE, - MSG_EVENT_SEND_PENDING_PUSH_MESSAGE, MSG_EVENT_REG_REPORT_MSG_INCOMING_CB, - MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND, + MSG_EVENT_UPDATE_IMSI, #ifdef FEATURE_SMS_CDMA MSG_EVENT_PLG_CHECK_UNIQUENESS, #endif - MSG_EVENT_UPDATE_IMSI, + +// 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 d4d63a1..746b7e7 100755 --- a/include/common/MsgCppTypes.h +++ b/include/common/MsgCppTypes.h @@ -21,9 +21,13 @@ INCLUDE FILES ==================================================================================================*/ #include <stdio.h> -#include <vector> +#include <memory> -typedef std::vector<char> CharVector; +template <typename T> +void unique_ptr_deleter( T **ptr ) { + if (ptr && *ptr ) + delete[] *ptr; +} template <class T> diff --git a/include/common/MsgInternalTypes.h b/include/common/MsgInternalTypes.h index 26a592f..ee2bf94 100755 --- a/include/common/MsgInternalTypes.h +++ b/include/common/MsgInternalTypes.h @@ -40,10 +40,7 @@ // 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 MAX_THREAD_ADDR_LEN 40 @@ -89,11 +86,10 @@ #define DEFAULT_SIM_COUNT_PATH DEFAULT_SETTING_PATH"/sim_count" #define MSG_KEEP_COPY DEFAULT_GENERAL_OPT_PATH"/keep_copy" -#define MSG_ALERT_REP_TYPE DEFAULT_GENERAL_OPT_PATH"/alert_rep_type" +//#define MSG_ALERT_REP_TYPE DEFAULT_GENERAL_OPT_PATH"/alert_rep_type" +#define MSG_ALERT_REP_TYPE "db/setting/sound/noti/msg_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" @@ -104,7 +100,6 @@ #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 @@ -189,9 +184,10 @@ #define MSG_DEFAULT_APP_ID "org.tizen.message" #define MSG_QUICKPANEL_APP_ID "org.tizen.quickpanel" +#define MSG_CALL_APP_ID "org.tizen.call" -#define MSG_TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony" -#define MSG_TELEPHONY_MMS_FEATURE "http://tizen.org/feature/network.telephony.mms" +#define MSG_TELEPHONY_SMS_FEATURE "http://tizen.org/feature/network.telephony.sms" +#define MSG_TELEPHONY_MMS_FEATURE "http://tizen.org/feature/network.telephony.mms" /*================================================================================================== TYPES @@ -214,28 +210,12 @@ 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. */ typedef unsigned char MSG_CLASS_TYPE_T; -/** - * @brief Represents a message class. \n - * The values for this type SHOULD be in _MSG_MMS_TRANSACTION_TYPE_E. - */ -typedef unsigned char MSG_MMS_TRANSACTION_TYPE_T; - - /*================================================================================================== STRUCTURES ==================================================================================================*/ @@ -387,16 +367,6 @@ typedef struct char szThumbFilePath[MSG_FILEPATH_LEN_MAX + 1]; /**< Indicates the thumbnail file path */ } MSG_MMS_MULTIPART_S; -/** - * @brief Represents sim message informatioin list. - */ -typedef struct -{ - int nIdxCnt; /**< The count of sim index */ - int nMsgCnt; /**< The count of sim message */ - MSG_MESSAGE_INFO_S *simMsgInfo; /**< The pointer to sim message informatioin */ -} MSG_SIM_MSG_INFO_LIST_S; - /** * @brief Represents a request in the framework. \n @@ -419,7 +389,7 @@ typedef struct typedef struct { int listenerFd; /**< Rx fd for status cnf */ - void* handleAddr; /**< Handle address for status cnf */ + unsigned int handleAddr; /**< Handle address for status cnf */ msg_message_id_t sentMsgId; /**< The ID of a sent message for updating message status */ } MSG_PROXY_INFO_S; @@ -515,12 +485,6 @@ typedef struct } MSG_CMD_REG_INCOMING_CB_MSG_CB_S; -typedef struct -{ - int alarm_id; - MSG_REQUEST_INFO_S reqInfo; -}MSG_SCHEDULED_MSG_S; - /** * @brief Represents a CB message in the framework. */ @@ -550,12 +514,6 @@ typedef struct _MSG_UNIQUE_INDEX_S int telesvc_id; } MSG_UNIQUE_INDEX_S; -typedef struct -{ - time_t receivedTime; - unsigned short serialNum; - unsigned short messageId; // Message Identifier -} MSG_CB_DUPLICATE_S; #endif @@ -641,17 +599,6 @@ enum _MSG_SUB_TYPE_E /** - * @brief Represents the values of a message transaction type. \n - * This enum is used as the value of MSG_MMS_TRANSACTION_TYPE_T. - */ -enum _MSG_MMS_TRANSACTION_TYPE_E -{ - MSG_MMS_SEND_COMPLETE = 0, - MSG_MMS_RETRIEVE_COMPLETE, - MSG_MMS_UNKNOWN, -}; - -/** * @brief Represents the values of File Type of MMS. \n * This enum is used as the value of . */ diff --git a/include/common/MsgSettingTypes.h b/include/common/MsgSettingTypes.h index 733096d..ab30fb0 100755 --- a/include/common/MsgSettingTypes.h +++ b/include/common/MsgSettingTypes.h @@ -284,7 +284,6 @@ typedef struct 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; diff --git a/include/common/MsgStorageTypes.h b/include/common/MsgStorageTypes.h index ca6c3d0..f882676 100755 --- a/include/common/MsgStorageTypes.h +++ b/include/common/MsgStorageTypes.h @@ -136,19 +136,6 @@ typedef struct /** - * @brief Represents search condition values. - */ -typedef struct -{ - msg_folder_id_t folderId; - msg_message_type_t msgType; - char *pAddressVal; - char *pSearchVal; - int reserved; -} MSG_SEARCH_CONDITION_S; - - -/** * @brief Represents Message list condition values. */ typedef struct diff --git a/include/externals/MsgNotificationWrapper.h b/include/externals/MsgNotificationWrapper.h index ed51127..2bd902c 100755 --- a/include/externals/MsgNotificationWrapper.h +++ b/include/externals/MsgNotificationWrapper.h @@ -156,7 +156,6 @@ #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" diff --git a/include/framework/MsgCmdHandler.h b/include/framework/MsgCmdHandler.h index 8add308..21a86a2 100755 --- a/include/framework/MsgCmdHandler.h +++ b/include/framework/MsgCmdHandler.h @@ -41,7 +41,6 @@ int MsgMoveMessageToStorageHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgCountMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgCountMsgByTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgGetMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetFolderViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgAddFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgUpdateFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent); @@ -49,10 +48,8 @@ int MsgDeleteFolderHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgGetFolderListHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgInitSimBySatHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetMsgTypeHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent); -int MsgGetConversationViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent); int MsgCountMsgByContactHandler(const MSG_CMD_S *pCmd, char **ppEvent); @@ -70,7 +67,6 @@ 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); @@ -108,9 +104,6 @@ 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 MSG_PENDING_PUSH_MESSAGE -int MsgSendPendingPushMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent); -#endif #ifdef FEATURE_SMS_CDMA int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent); #endif diff --git a/include/framework/MsgTransManager.h b/include/framework/MsgTransManager.h index 81a32af..9046eb3 100755 --- a/include/framework/MsgTransManager.h +++ b/include/framework/MsgTransManager.h @@ -42,9 +42,6 @@ ==================================================================================================*/ typedef std::map<MSG_CMD_TYPE_T, int (*)(const MSG_CMD_S*, char**)> handler_map; typedef std::map<int, MSG_PROXY_INFO_S> sentmsg_map; -#ifdef MSG_PENDING_PUSH_MESSAGE -typedef std::list<MSG_PUSH_MESSAGE_DATA_S> pushpending_list; -#endif typedef std::map<int, bool> fd_map; typedef std::list<MSG_CMD_REG_INCOMING_MSG_CB_S> newmsg_list; typedef std::list<MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S> mmsconf_list; @@ -84,16 +81,13 @@ public: void setSyncMLMsgOperationCB(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S *pCbinfo); void setStorageChangeCB(int listenerFd); void setReportMsgCB(int listenerFd); -#ifdef MSG_PENDING_PUSH_MESSAGE - void sendPendingPushMsg(void); -#endif 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 broadcastCBMsgCB(const msg_error_t err, const MSG_CB_MSG_S *cbMsg, msg_message_id_t cbMsgId); 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); @@ -120,9 +114,6 @@ private: bool running; handler_map handlerMap; -#ifdef MSG_PENDING_PUSH_MESSAGE - pushpending_list pushMsgList; -#endif sentmsg_map sentMsgMap; // req_id, listener_fd, msghandle_addr fd_map statusCBFdMap; // src_fd, true if registered diff --git a/include/mapi/msg.h b/include/mapi/msg.h index 7b2b7bb..ac6fa8d 100755 --- a/include/mapi/msg.h +++ b/include/mapi/msg.h @@ -48,12 +48,10 @@ extern "C" ==================================================================================================*/ /** - * @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. * - * @internal * @addtogroup MSG_SERVICE_FRAMEWORK_CONTROL_MODULE * @{ * @@ -69,6 +67,7 @@ extern "C" * @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 + * - http://tizen.org/feature/network.telephony.sms\n * * It is recommended to design feature related codes in your application for reliability.\n * @@ -152,6 +151,7 @@ int msg_close_msg_handle(msg_handle_t *handle); * * @retval #msg_struct_t Successfully created structure pointer * @retval NULL Invalid parameter + * @retval MSG_ERR_NOT_SUPPORTED Not supported * */ @@ -528,6 +528,7 @@ int msg_list_add_item(msg_struct_t msg_struct_handle, int field, msg_struct_t *i * * @retval #msg_struct_t Successfully done * @retval NULL Input parameter (list_handle) is not valid + * @retval MSG_ERR_NOT_SUPPORTED Not supported * */ @@ -576,6 +577,27 @@ 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 diff --git a/include/mapi/msg_private.h b/include/mapi/msg_private.h index 92168ba..2f9d00b 100755 --- a/include/mapi/msg_private.h +++ b/include/mapi/msg_private.h @@ -86,9 +86,9 @@ 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_get_filter_info_bool(void *filter, int field, bool *value); +int msg_get_filter_info_int(void *filter, int field, int *value); +int msg_get_filter_info_str(void *filter, int field, char *value, int size); 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); @@ -109,12 +109,9 @@ int msg_mms_set_int_value(msg_struct_s *msg_struct, int field, int value); int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int size); 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 @@ -127,103 +124,101 @@ int msg_setting_set_int_value(msg_struct_s *msg_struct, int field, int value); int msg_setting_set_str_value(msg_struct_s *msg_struct, int field, char *value, int size); int msg_setting_set_bool_value(msg_struct_s *msg_struct, int field, bool value); -int msg_get_smsc_opt_int(void *smsc_opt, int field); +int msg_get_smsc_opt_int(void *smsc_opt, int field, int *value); int msg_set_smsc_opt_int(void *smsc_opt, int field, int value); int msg_get_smsc_opt_list(void *smsc_opt, int field, void **value); -int msg_get_smsc_info_int(void *smsc_info, int field); +int msg_get_smsc_info_int(void *smsc_info, int field, int *value); int msg_set_smsc_info_int(void *smsc_info, int field, int value); -char* msg_get_smsc_info_str(void *smsc_info, int field); +int msg_get_smsc_info_str(void *smsc_info, int field, char *value, int size); int msg_set_smsc_info_str(void *smsc_info, int field, char *val, int size); -int msg_get_cb_option_int(void *cb_opt, int field); +int msg_get_cb_option_int(void *cb_opt, int field, int *value); int msg_set_cb_option_int(void *cb_opt, int field, int value); -bool msg_get_cb_option_bool(void *cb_opt, int field); +int msg_get_cb_option_bool(void *cb_opt, int field, bool *value); int msg_set_cb_option_bool(void *cb_opt, int field, bool value); int msg_get_cb_option_list(void *cb_opt, int field, void **value); -int msg_get_cb_channel_info_int(void *cb_ch_info, int field); +int msg_get_cb_channel_info_int(void *cb_ch_info, int field, int *value); int msg_set_cb_channel_info_int(void *cb_ch_info, int field, int value); -bool msg_get_cb_channel_info_bool(void *cb_ch_info, int field); +int msg_get_cb_channel_info_bool(void *cb_ch_info, int field, bool *value); int msg_set_cb_channel_info_bool(void *cb_ch_info, int field, bool value); -char *msg_get_cb_channel_info_str(void *cb_ch_info, int field); +int msg_get_cb_channel_info_str(void *cb_ch_info, int field, char *value, int size); int msg_set_cb_channel_info_str(void *cb_ch_info, int field, char *val, int size); -int msg_get_sms_send_opt_int(void *sms_send_opt, int field); +int msg_get_sms_send_opt_int(void *sms_send_opt, int field, int *value); int msg_set_sms_send_opt_int(void *sms_send_opt, int field, int value); -bool msg_get_sms_send_opt_bool(void *sms_send_opt, int field); +int msg_get_sms_send_opt_bool(void *sms_send_opt, int field, bool *value); int msg_set_sms_send_opt_bool(void *sms_send_opt, int field, bool value); -int msg_get_mms_send_opt_int(void *mms_send_opt, int field); +int msg_get_mms_send_opt_int(void *mms_send_opt, int field, int *value); int msg_set_mms_send_opt_int(void *mms_send_opt, int field, int value); -bool msg_get_mms_send_opt_bool(void *mms_send_opt, int field); +int msg_get_mms_send_opt_bool(void *mms_send_opt, int field, bool *value); int msg_set_mms_send_opt_bool(void *mms_send_opt, int field, bool value); -int msg_get_mms_recv_opt_int(void *mms_recv_opt, int field); +int msg_get_mms_recv_opt_int(void *mms_recv_opt, int field, int *value); int msg_set_mms_recv_opt_int(void *mms_recv_opt, int field, int value); -bool msg_get_mms_recv_opt_bool(void *mms_recv_opt, int field); +int msg_get_mms_recv_opt_bool(void *mms_recv_opt, int field, bool *value); int msg_set_mms_recv_opt_bool(void *mms_recv_opt, int field, bool value); -int msg_get_push_msg_opt_int(void *push_msg_opt, int field); +int msg_get_push_msg_opt_int(void *push_msg_opt, int field, int *value); 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_get_push_msg_opt_bool(void *push_msg_opt, int field, bool *value); 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_get_voice_msg_opt_int(void *voice_msg_opt, int field, int *value); 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_get_voice_msg_opt_str(void *voice_msg_opt, int field, char *value, int size); int msg_set_voice_msg_opt_str(void *voice_msg_opt, int field, char *val, int size); -int msg_get_general_opt_int(void *general_opt, int field); +int msg_get_general_opt_int(void *general_opt, int field, int *value); 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_get_general_opt_bool(void *general_opt, int field, bool *value); 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_get_general_opt_str(void *general_opt, int field, char *value, int size); 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_get_msgsize_opt_int(void *size_opt, int field, int *value); 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_get_str(void *event_info, int field, char *value, int size); +int msg_push_config_get_bool(void *event_info, int field, bool *value); 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); -int msg_thread_count_get_int(void *count_info, int field); -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_syncml_info_get_int(void *syncml_info, int field, int *value); +int msg_count_info_get_int(void *count_info, int field, int *value); +int msg_thread_count_get_int(void *count_info, int field, int *value); +int msg_thread_index_get_int(void *index_info, int field, int *value); +int msg_sortrule_get_int(void *sort_info, int field, int *value); +int msg_folder_info_get_int(void *folder_info, int field, int *value); +int msg_thread_info_get_int(void *data, int field, int *value); +int msg_conv_info_get_int(void *data, int field, int *value); +int msg_list_condition_get_int(void *condition_info, int field, int *value); +int msg_report_status_get_int(void *report_info, int field, int *value); +int msg_report_status_get_str(void *report_info, int field, char *value, int size); +int msg_folder_info_get_str(void *folder_info, int field, char *value, int size); +int msg_thread_info_get_str(void *data, int field, char *value, int size); +int msg_conv_info_get_str(void *data, int field, char *value, int size); +int msg_list_condition_get_str(void *condition_info, int field, char *value, int size); +int msg_sendopt_get_bool(void *send_opt, int field, bool *value); +int msg_sortrule_get_bool(void *sort_rule, int field, bool *value); +int msg_conv_get_bool(void *data, int field, bool *value); +int msg_thread_info_get_bool(void *data, int field, bool *value); +int msg_list_condition_get_bool(void *data, int field, bool *value); int msg_sendopt_get_struct_handle(msg_struct_s *msg_struct, int field, void **value); 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); -char* msg_address_info_get_str(void *addr_info, int field, int size); -char* msg_reject_message_get_str(void *msg_info, int field, int size); -bool msg_mms_sendopt_get_bool(void *opt_info, int field); -bool msg_sms_sendopt_get_bool(void *opt_info, int field); +int msg_address_info_get_int(void *addr_info, int field, int *value); +int msg_mms_sendopt_get_int(void *opt_info, int field, int *value); +int msg_reject_message_get_int(void *msg_info, int field, int *value); +int msg_address_info_get_str(void *addr_info, int field, char *value, int size); +int msg_reject_message_get_str(void *msg_info, int field, char *value, int size); +int msg_mms_sendopt_get_bool(void *opt_info, int field, bool *value); +int msg_sms_sendopt_get_bool(void *opt_info, int field, bool *value); int msg_syncml_info_set_int(void *syncml_info, int field, int value); int msg_count_info_set_int(void *count_info, int field, int value); @@ -231,11 +226,9 @@ int msg_thread_count_set_int(void *count_info, int field, int value); 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); @@ -254,13 +247,13 @@ int msg_mms_sendopt_set_bool(void *option, int field, bool value); int msg_sms_sendopt_set_bool(void *option, int field, bool value); /* added internal apis for new managed api (transport) */ -int msg_request_get_int(void *request_info, int field); +int msg_request_get_int(void *request_info, int field, int *value); int msg_request_get_struct_handle(msg_struct_s *msg_struct, int field, void **value); 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); +int msg_sent_status_get_int(MSG_SENT_STATUS_S *sent_status_info, int field, int *value); -char* msg_media_item_get_str(void *data, int field, int size); +int msg_media_item_get_str(void *data, int field, char *value, 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); diff --git a/include/mapi/msg_storage.h b/include/mapi/msg_storage.h index 837af02..2cd864f 100755 --- a/include/mapi/msg_storage.h +++ b/include/mapi/msg_storage.h @@ -30,12 +30,10 @@ extern "C" /** - * @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. * - * @internal * @addtogroup MSG_SERVICE_FRAMEWORK_STORAGE_MODULE * @{ * @@ -51,6 +49,7 @@ extern "C" * @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 + * - http://tizen.org/feature/network.telephony.sms\n * * It is recommended to design feature related codes in your application for reliability.\n * diff --git a/include/mapi/msg_storage_types.h b/include/mapi/msg_storage_types.h index 792d6ef..fb2504a 100755 --- a/include/mapi/msg_storage_types.h +++ b/include/mapi/msg_storage_types.h @@ -28,7 +28,6 @@ ==================================================================================================*/ /** - * @internal * @addtogroup MSG_SERVICE_FRAMEWORK_STORAGE_MODULE * @{ */ diff --git a/include/mapi/msg_transport.h b/include/mapi/msg_transport.h index 6dd003c..2e71c1d 100755 --- a/include/mapi/msg_transport.h +++ b/include/mapi/msg_transport.h @@ -29,12 +29,10 @@ extern "C" #endif /** - * @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. * - * @internal * @addtogroup MSG_SERVICE_FRAMEWORK_TRANSPORT_MODULE * @{ * @@ -55,6 +53,7 @@ extern "C" * @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.sms\n * - http://tizen.org/feature/network.telephony.mms\n * * It is recommended to design feature related codes in your application for reliability.\n @@ -373,7 +372,7 @@ int msg_reg_report_message_callback(msg_handle_t handle, msg_report_msg_incoming * @retval MSG_ERR_NOT_SUPPORTED Not supported */ -int msg_syncml_message_operation(msg_handle_t handle, msg_message_id_t msgId); +int msg_syncml_message_operation(msg_handle_t handle, msg_message_id_t msgId); /** @@ -395,6 +394,7 @@ int msg_syncml_message_operation(msg_handle_t handle, msg_message_id_t msgId); * * @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 * diff --git a/include/mapi/msg_transport_types.h b/include/mapi/msg_transport_types.h index d27811f..2bd4c2c 100755 --- a/include/mapi/msg_transport_types.h +++ b/include/mapi/msg_transport_types.h @@ -25,7 +25,6 @@ #include "msg_storage_types.h" /** - * @internal * @addtogroup MSG_SERVICE_FRAMEWORK_TRANSPORT_MODULE * @{ */ diff --git a/include/mapi/msg_types.h b/include/mapi/msg_types.h index 10e66a0..c26ade7 100755 --- a/include/mapi/msg_types.h +++ b/include/mapi/msg_types.h @@ -28,7 +28,6 @@ #endif /** - * @internal * @addtogroup MSG_SERVICE_FRAMEWORK * @{ */ @@ -492,7 +491,6 @@ enum _MSG_STRUCT_E { 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 */ @@ -535,7 +533,6 @@ enum _MSG_MESSAGE_INFO_E_ { 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 */ @@ -684,7 +681,7 @@ enum _MSG_STRUCT_SMS_SEND_OPT_E { * 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_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 */ @@ -728,7 +725,7 @@ enum _MSG_STRUCT_GENERAL_OPT_E { 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_TYPE_INT, /**< Indicates the message ringtone type. See enum _MSG_RINGTONE_TYPE_E */ MSG_GENERAL_RINGTONE_PATH_STR /**< Indicates the message ringtone path */ }; @@ -1020,18 +1017,6 @@ enum MSG_FOLDER_INFO_E { }; /** - * @brief Enumeration for the values of conditions for searching message. \n - * This enum is used as member of #msg_struct_t for MSG_STRUCT_SEARCH_CONDITION. - */ -enum MSG_SEARCH_CONDITION_E { - MSG_SEARCH_CONDITION_FOLDERID_INT = MSG_STRUCT_SEARCH_CONDITION+1, /**< The folder ID for searching messages. See enum _MSG_FOLDER_ID_E */ - MSG_SEARCH_CONDITION_MSGTYPE_INT, /**< The message type for searching messages. See enum _MSG_MESSAGE_TYPE_E */ - MSG_SEARCH_CONDITION_ADDRESS_VALUE_STR, /**< The address value for searching messages. */ - MSG_SEARCH_CONDITION_SEARCH_VALUE_STR, /**< The string to search */ - MSG_SEARCH_CONDITION_RESERVED_INT, /**< The search condition reserved*/ -}; - -/** * @brief Enumeration for the values of report message status. \n * This enum is used as member of #msg_struct_t for MSG_STRUCT_REPORT_STATUS_INFO. */ diff --git a/include/proxy/MsgHandle.h b/include/proxy/MsgHandle.h index eeb2204..831a4d4 100755 --- a/include/proxy/MsgHandle.h +++ b/include/proxy/MsgHandle.h @@ -48,7 +48,6 @@ class MsgHandle // Transport msg_error_t submitReq(MSG_REQUEST_S* pReq); - msg_error_t cancelReq(msg_request_id_t reqId); msg_error_t regSentStatusCallback(msg_sent_status_cb onStatusChanged, void *pUserParam); msg_error_t regSmsMessageCallback(msg_sms_incoming_cb onMsgIncoming, unsigned short port, void *pUserParam); @@ -79,7 +78,6 @@ class MsgHandle msg_error_t countMsgByContact(const MSG_THREAD_LIST_INDEX_INFO_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList); msg_error_t getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S *pMsg, MSG_SENDINGOPT_S *pSendOpt); msg_error_t getConversationViewItem(msg_message_id_t MsgId, MSG_CONVERSATION_VIEW_S *pConv); - msg_error_t getFolderViewList(msg_folder_id_t FolderId, const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pMsgFolderViewList); msg_error_t addFolder(const MSG_FOLDER_INFO_S *pFolderInfo); msg_error_t updateFolder(const MSG_FOLDER_INFO_S *pFolderInfo); msg_error_t deleteFolder(msg_folder_id_t FolderId); diff --git a/include/utils/MsgContact.h b/include/utils/MsgContact.h index 717d9d9..3ccd75e 100755 --- a/include/utils/MsgContact.h +++ b/include/utils/MsgContact.h @@ -24,7 +24,6 @@ #include "MsgInternalTypes.h" -typedef void (*MsgContactChangeCB)(); //contacts-service is not used for gear #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED @@ -34,27 +33,17 @@ typedef void (*MsgContactChangeCB)(); msg_error_t MsgOpenContactSvc(); msg_error_t MsgCloseContactSvc(); -msg_error_t MsgInitContactSvc(MsgContactChangeCB cb); +msg_error_t MsgInitContactSvc(); 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); -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); 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); #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED diff --git a/include/utils/MsgDebug.h b/include/utils/MsgDebug.h index 8cb07d5..8bd06c6 100755 --- a/include/utils/MsgDebug.h +++ b/include/utils/MsgDebug.h @@ -102,31 +102,31 @@ #define MSG_SMS_VLD_INFO(fmt, ...)\ do\ {\ - SLOG(LOG_DEBUG, MSG_SMS_VALID_TAG, "[SMS INFO]%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\ + SLOG(LOG_DEBUG, MSG_SMS_VALID_TAG, "[SMS INFO]%s, " fmt "\n", __TIMESTAMP__, ##__VA_ARGS__);\ } while (0) #define MSG_SMS_VLD_TXT(fmt, ...)\ do\ {\ - SLOG(LOG_DEBUG, MSG_SMS_VALID_TAG, "[SMS_TEXT]%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\ + SLOG(LOG_DEBUG, MSG_SMS_VALID_TAG, "[SMS_TEXT]%s, " fmt "\n", __TIMESTAMP__, ##__VA_ARGS__);\ } while (0) #define MSG_MMS_VLD_INFO(fmt, ...)\ do\ {\ - SLOG(LOG_DEBUG, MSG_MMS_VALID_TAG, "[MMS INFO]%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\ + 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__);\ + 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__);\ + SLOG(LOG_DEBUG, MSG_MMS_VALID_TAG, "[MMS FILE]%s, " fmt "\n", __TIMESTAMP__, ##__VA_ARGS__);\ } while (0) /*err & warn return message log macros*/ diff --git a/include/utils/MsgMmsMessage.h b/include/utils/MsgMmsMessage.h index e08e2bd..342a683 100755 --- a/include/utils/MsgMmsMessage.h +++ b/include/utils/MsgMmsMessage.h @@ -21,6 +21,7 @@ INCLUDE FILES ==================================================================================================*/ #include "MsgTypes.h" +#include "MsgInternalTypes.h" #include "MsgMmsTypes.h" msg_error_t _MsgMmsAddPage(MMS_MESSAGE_DATA_S *pMsgData, MMS_PAGE_S *pPage); @@ -91,4 +92,6 @@ void _MsgMmsMultipartPrint(MMS_MULTIPART_DATA_S *multipart); bool _MsgMmsRemoveEmptyObject(MMS_MESSAGE_DATA_S *pMmsMsg); +int MsgMmsCheckFilepathSmack(int fd, const char *ipc_filename); + #endif // MSG_MMS_MESSAGE_H diff --git a/include/utils/MsgSqliteWrapper.h b/include/utils/MsgSqliteWrapper.h index ef2e99a..24f56c8 100755 --- a/include/utils/MsgSqliteWrapper.h +++ b/include/utils/MsgSqliteWrapper.h @@ -93,7 +93,7 @@ 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); diff --git a/include/utils/MsgUtilFile.h b/include/utils/MsgUtilFile.h index 8600b2a..ecea9b5 100755 --- a/include/utils/MsgUtilFile.h +++ b/include/utils/MsgUtilFile.h @@ -60,6 +60,6 @@ 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); - +int MsgCheckFilepathSmack(const char *app_smack_label, char *file_path); #endif // MSG_UTIL_FILE_H diff --git a/include/utils/MsgUtilFunction.h b/include/utils/MsgUtilFunction.h index 5595a01..d7774c3 100755 --- a/include/utils/MsgUtilFunction.h +++ b/include/utils/MsgUtilFunction.h @@ -20,7 +20,7 @@ #define MSG_UTIL_CH_EMAIL_AT '@' /*================================================================================================== - INCLUDE FILES + INCLUDE FILES ==================================================================================================*/ #include "MsgStorageTypes.h" #include "MsgSettingTypes.h" @@ -29,7 +29,18 @@ #include "MsgCmdTypes.h" /*================================================================================================== - FUNCTION PROTOTYPES + DEFINES +==================================================================================================*/ + +#define MSG_TYPE_CHECK(a, b) \ + do {\ + if(a != (b & 0xff00)) {\ + return MSG_ERR_INVALID_PARAMETER; \ + } \ + }while(0) + +/*================================================================================================== + FUNCTION PROTOTYPES ==================================================================================================*/ bool MsgCheckFeatureSupport(const char *feature_name); @@ -57,8 +68,6 @@ int MsgEncodeFilterList(msg_struct_list_s *pFilterList, char **ppDest); int MsgEncodeFilterFlag(bool *pSetFlag, char **ppDest); -int MsgEncodeMsgType(MSG_MESSAGE_TYPE_S *pMsgType, char **ppDest); - int MsgEncodeThreadViewList(msg_struct_list_s *pThreadViewList, char **ppDest); int MsgEncodeConversationViewList(msg_struct_list_s *pConvViewList, char **ppDest); diff --git a/include/utils/MsgUtilStorage.h b/include/utils/MsgUtilStorage.h index 1a8cffd..14347aa 100755 --- a/include/utils/MsgUtilStorage.h +++ b/include/utils/MsgUtilStorage.h @@ -46,7 +46,7 @@ msg_error_t MsgStoAddAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S * 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); -#else +#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED //contactNameOrder is never used msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t msgId, int *nAddressCnt, MSG_ADDRESS_INFO_S **pAddress); msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t msgId, msg_struct_list_s *pAddress); @@ -74,17 +74,12 @@ 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 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); 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); diff --git a/include/utils/MsgZoneManager.h b/include/utils/MsgZoneManager.h deleted file mode 100755 index 4056ce5..0000000 --- a/include/utils/MsgZoneManager.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -* Copyright 2012-2013 Samsung Electronics Co., Ltd -* -* Licensed under the Flora License, Version 1.1 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://floralicense.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_ZONE_MANAGER_H -#define MSG_ZONE_MANAGER_H - -void MsgZoneInit(); -void MsgZoneClean(); - -char* MsgZoneGetName(int fd); -bool MsgZoneIsAllowed(int fd); - - -void MsgZoneChange(); -void MsgZoneRevert(); - -#endif // MSG_ZONE_MANAGER_H - diff --git a/mapi/CMakeLists.txt b/mapi/CMakeLists.txt index 7f9b391..a835dee 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} -O2 -g -Wall") ########################################################## # Define MAPI @@ -41,7 +41,7 @@ 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 8116e05..a396014 100755 --- a/mapi/msg_control.cpp +++ b/mapi/msg_control.cpp @@ -29,11 +29,11 @@ ==================================================================================================*/ EXPORT_API int msg_open_msg_handle(msg_handle_t *handle) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -78,11 +78,11 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } diff --git a/mapi/msg_filter.cpp b/mapi/msg_filter.cpp index 4871163..86f60c2 100755 --- a/mapi/msg_filter.cpp +++ b/mapi/msg_filter.cpp @@ -28,29 +28,24 @@ ==================================================================================================*/ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + 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) + if (handle == NULL || msg_struct_handle == NULL) { return MSG_ERR_INVALID_PARAMETER; } - if(msg_struct->type != MSG_STRUCT_FILTER) - { - return MSG_ERR_INVALID_PARAMETER; - } + msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; + MSG_TYPE_CHECK(msg_struct->type, MSG_STRUCT_FILTER); MsgHandle* pHandle = (MsgHandle*)handle; @@ -70,30 +65,24 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + 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) + if (handle == NULL || msg_struct_handle == NULL) { return MSG_ERR_INVALID_PARAMETER; } - - if(msg_struct->type != MSG_STRUCT_FILTER) - { - return MSG_ERR_INVALID_PARAMETER; - } + msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; + MSG_TYPE_CHECK(msg_struct->type, MSG_STRUCT_FILTER); MsgHandle* pHandle = (MsgHandle*)handle; @@ -113,13 +102,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -147,13 +136,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -181,13 +170,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -215,18 +204,18 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || set_flag == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -249,13 +238,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -281,72 +270,72 @@ EXPORT_API int msg_set_filter_active(msg_handle_t handle, msg_filter_id_t filter } -bool msg_get_filter_info_bool(void *filter, int field) +int msg_get_filter_info_bool(void *filter, int field, bool *value) { if (!filter) return MSG_ERR_NULL_POINTER; - int ret = 0; + int ret = MSG_SUCCESS; MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter; switch (field) { case MSG_FILTER_ACTIVE_BOOL : - ret = filter_data->bActive; + *value = filter_data->bActive; break; default : - return MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; + break; } return ret; } -int msg_get_filter_info_int(void *filter, int field) +int msg_get_filter_info_int(void *filter, int field, int *value) { if (!filter) return MSG_ERR_NULL_POINTER; - int ret = 0; + int ret = MSG_SUCCESS; MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter; switch (field) { case MSG_FILTER_ID_INT : - ret = filter_data->filterId; + *value = filter_data->filterId; break; case MSG_FILTER_TYPE_INT : - ret = filter_data->filterType; + *value = filter_data->filterType; break; default : - return MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; + break; } return ret; } -char *msg_get_filter_info_str(void *filter, int field) +int msg_get_filter_info_str(void *filter, int field, char *value, int size) { if (!filter) - return NULL; - - char *ret_str = NULL; + return MSG_ERR_NULL_POINTER; MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter; switch (field) { case MSG_FILTER_VALUE_STR : - ret_str = filter_data->filterValue; + strncpy(value, filter_data->filterValue, size); break; default : - return NULL; + return MSG_ERR_INVALID_PARAMETER; } - return ret_str; + return MSG_SUCCESS; } int msg_set_filter_info_bool(void *filter, int field, bool value) @@ -354,7 +343,7 @@ 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_error_t err = MSG_SUCCESS; MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter; switch (field) @@ -374,7 +363,7 @@ int msg_set_filter_info_int(void *filter, int field, int value) if (!filter) return MSG_ERR_NULL_POINTER; - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter; switch (field) @@ -397,7 +386,7 @@ int msg_set_filter_info_str(void *filter, int field, char *value, int size) if (!filter || !value) return MSG_ERR_NULL_POINTER; - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter; switch (field) diff --git a/mapi/msg_message.cpp b/mapi/msg_message.cpp index c4c8978..d46941a 100755 --- a/mapi/msg_message.cpp +++ b/mapi/msg_message.cpp @@ -85,16 +85,19 @@ void msg_message_create_struct(msg_struct_s *msg_struct) 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 *)calloc(MAX_TO_ADDRESS_CNT, sizeof(MSG_ADDRESS_INFO_S *)); - - 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]; - 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 = (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; @@ -221,6 +224,7 @@ int msg_message_get_int_value(void *data, int field, int *value) break; default : *value = MSG_TYPE_SMS; + break; } } else if (msg_data->mainType == MSG_MMS_TYPE) @@ -335,9 +339,6 @@ int msg_message_get_str_value(void *data, int field, char *value, int size) case MSG_MESSAGE_SUBJECT_STR : strncpy(value, msg_data->subject, size); break; - case MSG_MESSAGE_THUMBNAIL_PATH_STR : - strncpy(value, msg_data->thumbPath, size); - break; case MSG_MESSAGE_SMS_DATA_STR : case MSG_MESSAGE_MMS_TEXT_STR : if (msg_data->pData) @@ -540,9 +541,6 @@ int msg_message_set_str_value(void *data, int field, char *value, int size) case MSG_MESSAGE_SUBJECT_STR : snprintf(msg_data->subject, sizeof(msg_data->subject), "%s",value); break; - case MSG_MESSAGE_THUMBNAIL_PATH_STR : - snprintf(msg_data->thumbPath, sizeof(msg_data->thumbPath), "%s",value); - break; case MSG_MESSAGE_SMS_DATA_STR : { if (msg_data->pData) @@ -771,18 +769,18 @@ EXPORT_API int msg_get_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t m 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; - msg_struct_s *mms_struct = (msg_struct_s *)mms_struct_handle; - if (msg_struct == NULL || mms_struct == NULL) { + if (msg_struct_handle == NULL || mms_struct_handle == NULL) { return MSG_ERR_INVALID_PARAMETER; } - if (msg_struct->data == NULL || mms_struct->data == NULL) { - return MSG_ERR_INVALID_PARAMETER; - } + msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle; + msg_struct_s *mms_struct = (msg_struct_s *)mms_struct_handle; + + MSG_TYPE_CHECK(msg_struct->type, MSG_STRUCT_MESSAGE_INFO); + MSG_TYPE_CHECK(mms_struct->type, MSG_STRUCT_MMS); - if (msg_struct->type != MSG_STRUCT_MESSAGE_INFO || mms_struct->type != MSG_STRUCT_MMS) { + if (msg_struct->data == NULL || mms_struct->data == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -812,24 +810,26 @@ EXPORT_API int msg_set_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t m 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; - msg_struct_s *mms_struct = (msg_struct_s *)mms_struct_handle; - if (msg_struct == NULL || mms_struct == NULL) { + if (msg_struct_handle == NULL || mms_struct_handle == NULL) { return MSG_ERR_INVALID_PARAMETER; } - if (msg_struct->data == NULL || mms_struct->data == NULL) { - return MSG_ERR_INVALID_PARAMETER; - } + msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle; + msg_struct_s *mms_struct = (msg_struct_s *)mms_struct_handle; + + MSG_TYPE_CHECK(msg_struct->type, MSG_STRUCT_MESSAGE_INFO); + MSG_TYPE_CHECK(mms_struct->type, MSG_STRUCT_MMS); - if (msg_struct->type != MSG_STRUCT_MESSAGE_INFO || mms_struct->type != MSG_STRUCT_MMS) { + if (msg_struct->data == NULL || mms_struct->data == NULL) { return MSG_ERR_INVALID_PARAMETER; } MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data; MMS_DATA_S *mms_data = MsgMmsCreate(); + if (mms_data == NULL) + return MSG_ERR_MEMORY_ERROR; convert_from_hidden_mmsdata(mms_struct, mms_data); diff --git a/mapi/msg_mms.cpp b/mapi/msg_mms.cpp index 78815ce..1ffe9ab 100755 --- a/mapi/msg_mms.cpp +++ b/mapi/msg_mms.cpp @@ -16,6 +16,7 @@ #include <stdio.h> #include <string.h> +#include <sys/stat.h> #include <MsgHandle.h> #include <MsgException.h> @@ -23,6 +24,7 @@ #include "MsgMmsTypes.h" #include "MsgMmsMessage.h" #include "MsgDebug.h" +#include "MsgUtilFile.h" #include "msg.h" #include "msg_private.h" @@ -69,6 +71,7 @@ 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 ==================================================================================================*/ @@ -720,7 +723,7 @@ int msg_mms_get_str_value(msg_struct_s *msg_struct, int field, char *value, int break; default : - err = MSG_ERR_INVALID_PARAMETER; + err = MSG_ERR_INVALID_PARAMETER; break; } return err; @@ -1053,9 +1056,9 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int 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); + strncpy(mms_media_data->szContentLocation, value, MSG_MSG_ID_LEN); else if (field == MSG_MMS_MEDIA_CONTENT_TYPE_STR) - strncpy(mms_media_data->szContentType, value, MSG_FILEPATH_LEN_MAX); + strncpy(mms_media_data->szContentType, value, MSG_MSG_ID_LEN); else err = MSG_ERR_INVALID_PARAMETER; } @@ -1090,7 +1093,7 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int } else if (field == MSG_MMS_ATTACH_DRM_FULLPATH_STR) { strncpy(mms_attach_data->szDrm2FullPath, value, MSG_FILEPATH_LEN_MAX); } else if (field == MSG_MMS_ATTACH_CONTENT_TYPE_STR) { - strncpy(mms_attach_data->szContentType, value, MSG_FILEPATH_LEN_MAX); + strncpy(mms_attach_data->szContentType, value, MSG_MSG_ID_LEN); } else { err = MSG_ERR_INVALID_PARAMETER; } @@ -1183,9 +1186,10 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int break; default : - err = MSG_ERR_INVALID_PARAMETER; + err = MSG_ERR_INVALID_PARAMETER; break; } + return err; } @@ -1266,44 +1270,6 @@ int msg_mms_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s return err; } -int msg_mms_set_list_handle(msg_struct_s *msg_struct, int field, msg_list_handle_t value) -{ - 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_PAGE_LIST_HND) - mms_data->pagelist = (GList *)value; - else if (field == MSG_MMS_REGION_LIST_HND) - mms_data->regionlist = (GList *)value; - else if (field == MSG_MMS_ATTACH_LIST_HND) - mms_data->attachlist = (GList *)value; - else if (field == MSG_MMS_TRANSITION_LIST_HND) - mms_data->transitionlist = (GList *)value; - else if (field == MSG_MMS_META_LIST_HND) - mms_data->metalist = (GList *)value; - else - err = MSG_ERR_INVALID_PARAMETER; - } - break; - case MSG_STRUCT_MMS_PAGE: - { - MMS_PAGE_S *mms_page_data = (MMS_PAGE_S *)msg_struct->data; - if (field == MSG_MMS_PAGE_MEDIA_LIST_HND) - mms_page_data->medialist = (GList *)value; - else - err = MSG_ERR_INVALID_PARAMETER; - } - break; - default : - err = MSG_ERR_INVALID_PARAMETER; - break; - } - return err; -} - int msg_mms_list_append(msg_struct_t msg_struct_handle, int field, msg_struct_t *item) { msg_error_t err = MSG_SUCCESS; @@ -1423,156 +1389,6 @@ void convert_from_media_data(const MMS_MEDIA_S *pSrc, msg_struct_s *pDest) } } -void convert_to_mmsdata(const msg_struct_s *pSrc, 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)); - 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); - - 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)); - 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)); - 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)); - 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)); - 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++) - { - msg_struct_s *dst_media_s = msg_mms_create_struct(MSG_STRUCT_MMS_MEDIA); - - MMS_MEDIA_S *src_media = (MMS_MEDIA_S *)g_list_nth_data(src_page->medialist, j); - - convert_from_media_data(src_media, dst_media_s); - - page->medialist = g_list_append(page->medialist, dst_media_s); - } - - 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; - - 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; @@ -1583,26 +1399,30 @@ void convert_to_mmsdata2(MMS_DATA_HIDDEN_S *pSrcMms, 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)); - page->mediaCnt = g_list_length(src_page->medialist); + 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); + 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); - convert_to_media_data(src_media_s, dst_media); + if (dst_media) { + convert_to_media_data(src_media_s, dst_media); - page->medialist = g_list_append(page->medialist, 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; + 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->pagelist = g_list_append(pDest->pagelist, page); + } } pDest->regionCnt = g_list_length(pSrcMms->regionlist); @@ -1610,8 +1430,10 @@ void convert_to_mmsdata2(MMS_DATA_HIDDEN_S *pSrcMms, 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); @@ -1619,8 +1441,10 @@ void convert_to_mmsdata2(MMS_DATA_HIDDEN_S *pSrcMms, 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); @@ -1628,8 +1452,10 @@ void convert_to_mmsdata2(MMS_DATA_HIDDEN_S *pSrcMms, 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); @@ -1637,8 +1463,10 @@ void convert_to_mmsdata2(MMS_DATA_HIDDEN_S *pSrcMms, 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)); @@ -1771,15 +1599,15 @@ int msg_multipart_get_int_value(void *data, int field, int *value) 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; + 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; @@ -1806,6 +1634,7 @@ int msg_multipart_set_str_value(void *data, int field, char *value, int size) strncpy(msg_data->szFilePath, value, MSG_FILEPATH_LEN_MAX); break; case MSG_MMS_MULTIPART_THUMBNAIL_FILEPATH_STR: + strncpy(msg_data->szThumbFilePath, value, MSG_FILEPATH_LEN_MAX); break; case MSG_MMS_MULTIPART_CONTENT_ID_STR: strncpy(msg_data->szContentID, value, MSG_MSG_ID_LEN); @@ -1824,13 +1653,16 @@ 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 = {0}; + MMS_MESSAGE_DATA_S *MmsMessageData = NULL; + unique_ptr<MMS_MESSAGE_DATA_S*, void(*)(MMS_MESSAGE_DATA_S**)> 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); + MsgMmsConvertMmsDataToMmsMessageData(pSrc, MmsMessageData); - convert_from_mmsdata2(&MmsMessageData, pDestMms); + convert_from_mmsdata2(MmsMessageData, pDestMms); - MsgMmsReleaseMmsLists(&MmsMessageData); + MsgMmsReleaseMmsLists(MmsMessageData); if (pSrc->header) { memcpy(&pDestMms->header, pSrc->header, sizeof(MMS_HEADER_DATA_S)); @@ -1870,13 +1702,16 @@ 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 = {0}; + MMS_MESSAGE_DATA_S *MmsMessageData = NULL; + unique_ptr<MMS_MESSAGE_DATA_S*, void(*)(MMS_MESSAGE_DATA_S**)> 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); + convert_to_mmsdata2(pSrcMms, MmsMessageData); - MsgMmsConvertMmsMessageDataToMmsData(&MmsMessageData, pDest); + MsgMmsConvertMmsMessageDataToMmsData(MmsMessageData, pDest); - MsgMmsReleaseMmsLists(&MmsMessageData); + MsgMmsReleaseMmsLists(MmsMessageData); } void __msg_mms_data_struct_init(MMS_DATA_HIDDEN_S *pMmsDataHidden) diff --git a/mapi/msg_setting.cpp b/mapi/msg_setting.cpp index 4538163..f960133 100755 --- a/mapi/msg_setting.cpp +++ b/mapi/msg_setting.cpp @@ -33,37 +33,37 @@ int msg_setting_get_int_value(msg_struct_s *msg_struct, int field, int *value) switch (msg_struct->type) { case MSG_STRUCT_SETTING_SMSC_OPT : - *value = msg_get_smsc_opt_int(msg_struct->data, field); + err = msg_get_smsc_opt_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_SMSC_INFO : - *value = msg_get_smsc_info_int(msg_struct->data, field); + err = msg_get_smsc_info_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_CB_OPT : - *value = msg_get_cb_option_int(msg_struct->data, field); + err = msg_get_cb_option_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_CB_CHANNEL_INFO : - *value = msg_get_cb_channel_info_int(msg_struct->data, field); + err = msg_get_cb_channel_info_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_SMS_SEND_OPT : - *value = msg_get_sms_send_opt_int(msg_struct->data, field); + err = msg_get_sms_send_opt_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_MMS_SEND_OPT : - *value = msg_get_mms_send_opt_int(msg_struct->data, field); + err = msg_get_mms_send_opt_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_MMS_RECV_OPT : - *value = msg_get_mms_recv_opt_int(msg_struct->data, field); + err = msg_get_mms_recv_opt_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_PUSH_MSG_OPT : - *value = msg_get_push_msg_opt_int(msg_struct->data, field); + err = msg_get_push_msg_opt_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_GENERAL_OPT : - *value = msg_get_general_opt_int(msg_struct->data, field); + err = msg_get_general_opt_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_MSGSIZE_OPT : - *value = msg_get_msgsize_opt_int(msg_struct->data, field); + err = msg_get_msgsize_opt_int(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_VOICE_MSG_OPT : - *value = msg_get_voice_msg_opt_int(msg_struct->data, field); + err = msg_get_voice_msg_opt_int(msg_struct->data, field, value); break; default : err = MSG_ERR_INVALID_PARAMETER; @@ -76,30 +76,20 @@ int msg_setting_get_int_value(msg_struct_s *msg_struct, int field, int *value) int msg_setting_get_str_value(msg_struct_s *msg_struct, int field, char *src, int size) { int err = MSG_SUCCESS; - char *ret_str = NULL; switch (msg_struct->type) { case MSG_STRUCT_SETTING_SMSC_INFO : - ret_str = msg_get_smsc_info_str(msg_struct->data, field); - if (ret_str == NULL) - err = MSG_ERR_UNKNOWN; - else - strncpy(src, ret_str, size); + err = msg_get_smsc_info_str(msg_struct->data, field, src, size); break; case MSG_STRUCT_SETTING_CB_CHANNEL_INFO : - ret_str = msg_get_cb_channel_info_str(msg_struct->data, field); - if (ret_str == NULL) - err = MSG_ERR_UNKNOWN; - else - strncpy(src, ret_str, size); + err = msg_get_cb_channel_info_str(msg_struct->data, field, src, size); break; case MSG_STRUCT_SETTING_VOICE_MSG_OPT : - ret_str = msg_get_voice_msg_opt_str(msg_struct->data, field); - if (ret_str == NULL) - err = MSG_ERR_UNKNOWN; - else - strncpy(src, ret_str, size); + err = msg_get_voice_msg_opt_str(msg_struct->data, field, src, size); + break; + case MSG_STRUCT_SETTING_GENERAL_OPT : + err = msg_get_general_opt_str(msg_struct->data, field, src, size); break; default : err = MSG_ERR_INVALID_PARAMETER; @@ -115,25 +105,25 @@ int msg_setting_get_bool_value(msg_struct_s *msg_struct, int field, bool *value) switch (msg_struct->type) { case MSG_STRUCT_SETTING_CB_OPT : - *value = msg_get_cb_option_bool(msg_struct->data, field); + err = msg_get_cb_option_bool(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_CB_CHANNEL_INFO : - *value = msg_get_cb_channel_info_bool(msg_struct->data, field); + err = msg_get_cb_channel_info_bool(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_SMS_SEND_OPT : - *value = msg_get_sms_send_opt_bool(msg_struct->data, field); + err = msg_get_sms_send_opt_bool(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_MMS_SEND_OPT : - *value = msg_get_mms_send_opt_bool(msg_struct->data, field); + err = msg_get_mms_send_opt_bool(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_MMS_RECV_OPT : - *value = msg_get_mms_recv_opt_bool(msg_struct->data, field); + err = msg_get_mms_recv_opt_bool(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_PUSH_MSG_OPT : - *value = msg_get_push_msg_opt_bool(msg_struct->data, field); + err = msg_get_push_msg_opt_bool(msg_struct->data, field, value); break; case MSG_STRUCT_SETTING_GENERAL_OPT : - *value = msg_get_general_opt_bool(msg_struct->data, field); + err = msg_get_general_opt_bool(msg_struct->data, field, value); break; default : err = MSG_ERR_INVALID_PARAMETER; @@ -155,6 +145,7 @@ int msg_setting_get_list_handle(msg_struct_s *msg_struct, int field, void **valu err = msg_get_cb_option_list(msg_struct->data, field, value); break; default : + err = MSG_ERR_INVALID_PARAMETER; break; } @@ -222,6 +213,9 @@ int msg_setting_set_str_value(msg_struct_s *msg_struct, int field, char *value, case MSG_STRUCT_SETTING_VOICE_MSG_OPT : err = msg_set_voice_msg_opt_str(msg_struct->data, field, value, size); break; + case MSG_STRUCT_SETTING_GENERAL_OPT : + err = msg_set_general_opt_str(msg_struct->data, field, value, size); + break; default : err = MSG_ERR_INVALID_PARAMETER; break; @@ -267,19 +261,19 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); - msg_error_t err = MSG_SUCCESS; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_struct == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -301,14 +295,14 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); - msg_error_t err = MSG_SUCCESS; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -348,13 +342,14 @@ int msg_get_smsc_opt_list(void *smsc_opt, int field, void **value) *value = (void *)smsc_opt_data->smsc_list; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } return ret; } -int msg_get_smsc_opt_int(void *smsc_opt, int field) +int msg_get_smsc_opt_int(void *smsc_opt, int field, int *value) { if (!smsc_opt) return MSG_ERR_NULL_POINTER; @@ -366,13 +361,14 @@ int msg_get_smsc_opt_int(void *smsc_opt, int field) switch (field) { case MSG_SMSC_SELECTED_ID_INT : - ret = smsc_opt_data->selected; + *value = smsc_opt_data->selected; break; case MSG_SMSC_LIST_SIM_INDEX_INT : - ret = smsc_opt_data->simIndex; + *value = smsc_opt_data->simIndex; break; default : - return MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; + break; } return ret; @@ -406,7 +402,7 @@ int msg_set_smsc_opt_int(void *smsc_opt, int field, int value) return ret; } -int msg_get_smsc_info_int(void *smsc_info, int field) +int msg_get_smsc_info_int(void *smsc_info, int field, int *value) { if (!smsc_info) return MSG_ERR_NULL_POINTER; @@ -418,19 +414,20 @@ int msg_get_smsc_info_int(void *smsc_info, int field) switch (field) { case MSG_SMSC_ADDR_TON_INT : - ret = smsc_data->smscAddr.ton; + *value = smsc_data->smscAddr.ton; break; case MSG_SMSC_ADDR_NPI_INT : - ret = smsc_data->smscAddr.npi; + *value = smsc_data->smscAddr.npi; break; case MSG_SMSC_PID_INT : - ret = smsc_data->pid; + *value = smsc_data->pid; break; case MSG_SMSC_VAL_PERIOD_INT : - ret = smsc_data->valPeriod; + *value = smsc_data->valPeriod; break; default : - return MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; + break; } return ret; @@ -467,28 +464,26 @@ int msg_set_smsc_info_int(void *smsc_info, int field, int value) return err; } -char *msg_get_smsc_info_str(void *smsc_info, int field) +int msg_get_smsc_info_str(void *smsc_info, int field, char *value, int size) { if (!smsc_info) - return NULL; - - char *ret_str = NULL; + return MSG_ERR_NULL_POINTER; MSG_SMSC_DATA_S *smsc_data = (MSG_SMSC_DATA_S *)smsc_info; switch (field) { case MSG_SMSC_ADDR_STR : - ret_str = smsc_data->smscAddr.address; + strncpy(value, smsc_data->smscAddr.address, size); break; case MSG_SMSC_NAME_STR : - ret_str = smsc_data->name; + strncpy(value, smsc_data->name, size); break; default : - return NULL; + return MSG_ERR_INVALID_PARAMETER; } - return ret_str; + return MSG_SUCCESS; } int msg_set_smsc_info_str(void *smsc_info, int field, char *val, int size) @@ -520,19 +515,19 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); - msg_error_t err = MSG_SUCCESS; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_struct == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -554,14 +549,14 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); - msg_error_t err = MSG_SUCCESS; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -586,7 +581,7 @@ EXPORT_API int msg_set_cb_opt(msg_handle_t handle, msg_struct_t msg_struct) return err; } -int msg_get_cb_option_int(void *cb_opt, int field) +int msg_get_cb_option_int(void *cb_opt, int field, int *value) { if (!cb_opt) return MSG_ERR_NULL_POINTER; @@ -598,10 +593,10 @@ int msg_get_cb_option_int(void *cb_opt, int field) switch (field) { case MSG_CB_MAX_SIM_COUNT_INT : - ret = cb_opt_data->maxSimCnt; + *value = cb_opt_data->maxSimCnt; break; case MSG_CB_SIM_INDEX_INT : - ret = cb_opt_data->simIndex; + *value = cb_opt_data->simIndex; break; default : ret = MSG_ERR_INVALID_PARAMETER; @@ -637,51 +632,52 @@ int msg_set_cb_option_int(void *cb_opt, int field, int value) } -bool msg_get_cb_option_bool(void *cb_opt, int field) +int msg_get_cb_option_bool(void *cb_opt, int field, bool *value) { if (!cb_opt) - return false; + return MSG_ERR_NULL_POINTER; - bool ret = false; + int ret = MSG_SUCCESS; MSG_CBMSG_OPT_HIDDEN_S *cb_opt_data = (MSG_CBMSG_OPT_HIDDEN_S *)cb_opt; switch (field) { case MSG_CB_RECEIVE_BOOL : - ret = cb_opt_data->bReceive; + *value = cb_opt_data->bReceive; break; case MSG_CB_LANGUAGE_TYPE_ALL_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_ALL]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_ALL]; break; case MSG_CB_LANGUAGE_TYPE_ENG_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_ENG]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_ENG]; break; case MSG_CB_LANGUAGE_TYPE_GER_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_GER]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_GER]; break; case MSG_CB_LANGUAGE_TYPE_FRE_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_FRE]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_FRE]; break; case MSG_CB_LANGUAGE_TYPE_ITA_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_ITA]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_ITA]; break; case MSG_CB_LANGUAGE_TYPE_NED_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_NED]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_NED]; break; case MSG_CB_LANGUAGE_TYPE_SPA_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_SPA]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_SPA]; break; case MSG_CB_LANGUAGE_TYPE_POR_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_POR]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_POR]; break; case MSG_CB_LANGUAGE_TYPE_SWE_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_SWE]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_SWE]; break; case MSG_CB_LANGUAGE_TYPE_TUR_BOOL : - ret = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_TUR]; + *value = cb_opt_data->bLanguage[MSG_CBLANG_TYPE_TUR]; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -755,30 +751,32 @@ int msg_get_cb_option_list(void *cb_opt, int field, void **value) *value = (void *)cb_opt_data->channelData; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } return ret; } -int msg_get_cb_channel_info_int(void *cb_ch_info, int field) +int msg_get_cb_channel_info_int(void *cb_ch_info, int field, int *value) { if (!cb_ch_info) return MSG_ERR_NULL_POINTER; - int ret = MSG_ERR_INVALID_PARAMETER; + int ret = MSG_SUCCESS; MSG_CB_CHANNEL_INFO_S *cb_ch_data = (MSG_CB_CHANNEL_INFO_S *)cb_ch_info; switch (field) { case MSG_CB_CHANNEL_ID_FROM_INT : - ret = cb_ch_data->from; + *value = cb_ch_data->from; break; case MSG_CB_CHANNEL_ID_TO_INT : - ret = cb_ch_data->to; + *value = cb_ch_data->to; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -810,21 +808,22 @@ int msg_set_cb_channel_info_int(void *cb_ch_info, int field, int value) return ret; } -bool msg_get_cb_channel_info_bool(void *cb_ch_info, int field) +int msg_get_cb_channel_info_bool(void *cb_ch_info, int field, bool *value) { if (!cb_ch_info) - return false; + return MSG_ERR_NULL_POINTER; - bool ret = false; + int ret = MSG_SUCCESS; MSG_CB_CHANNEL_INFO_S *cb_ch_data = (MSG_CB_CHANNEL_INFO_S *)cb_ch_info; switch (field) { case MSG_CB_CHANNEL_ACTIVATE_BOOL : - ret = cb_ch_data->bActivate; + *value = cb_ch_data->bActivate; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -853,25 +852,23 @@ int msg_set_cb_channel_info_bool(void *cb_ch_info, int field, bool value) return ret; } -char *msg_get_cb_channel_info_str(void *cb_ch_info, int field) +int msg_get_cb_channel_info_str(void *cb_ch_info, int field, char *value, int size) { if (!cb_ch_info) - return NULL; - - char *ret_str = NULL; + return MSG_ERR_NULL_POINTER; MSG_CB_CHANNEL_INFO_S *cb_ch_data = (MSG_CB_CHANNEL_INFO_S *)cb_ch_info; switch (field) { case MSG_CB_CHANNEL_NAME_STR : - ret_str = cb_ch_data->name; + strncpy(value, cb_ch_data->name, size); break; default : - break; + return MSG_ERR_INVALID_PARAMETER; } - return ret_str; + return MSG_SUCCESS; } int msg_set_cb_channel_info_str(void *cb_ch_info, int field, char *val, int size) @@ -899,19 +896,19 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); - msg_error_t err = MSG_SUCCESS; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_struct == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -933,14 +930,14 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); - msg_error_t err = MSG_SUCCESS; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -965,27 +962,28 @@ EXPORT_API int msg_set_sms_send_opt(msg_handle_t handle, msg_struct_t msg_struct return err; } -int msg_get_sms_send_opt_int(void *sms_send_opt, int field) +int msg_get_sms_send_opt_int(void *sms_send_opt, int field, int *value) { if (!sms_send_opt) return MSG_ERR_NULL_POINTER; - int ret = MSG_ERR_INVALID_PARAMETER; + int ret = MSG_SUCCESS; MSG_SMS_SENDOPT_S *send_opt = (MSG_SMS_SENDOPT_S *)sms_send_opt; switch (field) { case MSG_SMS_SENDOPT_ENCODE_TYPE_INT : - ret = send_opt->dcs; + *value = send_opt->dcs; break; case MSG_SMS_SENDOPT_NETWORK_MODE_INT : - ret = send_opt->netMode; + *value = send_opt->netMode; break; case MSG_SMS_SENDOPT_SAVE_STORAGE_INT : - ret = send_opt->saveStorage; + *value = send_opt->saveStorage; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1020,24 +1018,25 @@ int msg_set_sms_send_opt_int(void *sms_send_opt, int field, int value) return ret; } -bool msg_get_sms_send_opt_bool(void *sms_send_opt, int field) +int msg_get_sms_send_opt_bool(void *sms_send_opt, int field, bool *value) { if (!sms_send_opt) - return false; + return MSG_ERR_NULL_POINTER; - bool ret = false; + int ret = MSG_SUCCESS; MSG_SMS_SENDOPT_S *send_opt = (MSG_SMS_SENDOPT_S *)sms_send_opt; switch (field) { case MSG_SMS_SENDOPT_REPLY_PATH_BOOL : - ret = send_opt->bReplyPath; + *value = send_opt->bReplyPath; break; case MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL : - ret = send_opt->bDeliveryReport; + *value = send_opt->bDeliveryReport; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1073,17 +1072,17 @@ 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_struct == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1107,12 +1106,12 @@ 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1138,45 +1137,46 @@ EXPORT_API int msg_set_mms_send_opt(msg_handle_t handle, msg_struct_t msg_struct } -int msg_get_mms_send_opt_int(void *mms_send_opt, int field) +int msg_get_mms_send_opt_int(void *mms_send_opt, int field, int *value) { if (!mms_send_opt) return MSG_ERR_NULL_POINTER; - int ret = MSG_ERR_INVALID_PARAMETER; + int ret = MSG_SUCCESS; MSG_MMS_SENDOPT_S *send_opt = (MSG_MMS_SENDOPT_S *)mms_send_opt; switch (field) { case MSG_MMS_SENDOPT_CLASS_TYPE_INT : - ret = send_opt->msgClass; + *value = send_opt->msgClass; break; case MSG_MMS_SENDOPT_PRIORITY_TYPE_INT : - ret = send_opt->priority; + *value = send_opt->priority; break; case MSG_MMS_SENDOPT_EXPIRY_TIME_INT : - ret = send_opt->expiryTime; + *value = send_opt->expiryTime; break; case MSG_MMS_SENDOPT_DELIVERY_TIME_INT : - ret = send_opt->deliveryTime; + *value = send_opt->deliveryTime; break; case MSG_MMS_SENDOPT_CUSTOM_DELIVERY_TIME_INT : - ret = send_opt->customDeliveryTime; + *value = send_opt->customDeliveryTime; break; case MSG_MMS_SENDOPT_REPLY_CHARGING_INT : - ret = send_opt->replyCharging; + *value = send_opt->replyCharging; break; case MSG_MMS_SENDOPT_REPLY_CHARGING_DEADLINE_INT : - ret = send_opt->replyChargingDeadline; + *value = send_opt->replyChargingDeadline; break; case MSG_MMS_SENDOPT_REPLY_CHARGING_SIZE_INT : - ret = send_opt->replyChargingSize; + *value = send_opt->replyChargingSize; break; case MSG_MMS_SENDOPT_CREATION_MODE_INT : - ret = send_opt->creationMode; + *value = send_opt->creationMode; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1229,36 +1229,37 @@ int msg_set_mms_send_opt_int(void *mms_send_opt, int field, int value) return ret; } -bool msg_get_mms_send_opt_bool(void *mms_send_opt, int field) +int msg_get_mms_send_opt_bool(void *mms_send_opt, int field, bool *value) { if (!mms_send_opt) - return false; + return MSG_ERR_NULL_POINTER; - bool ret = false; + int ret = MSG_SUCCESS; MSG_MMS_SENDOPT_S *send_opt = (MSG_MMS_SENDOPT_S *)mms_send_opt; switch (field) { case MSG_MMS_SENDOPT_SENDER_VISIBILITY_BOOL : - ret = send_opt->bSenderVisibility; + *value = send_opt->bSenderVisibility; break; case MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL : - ret = send_opt->bDeliveryReport; + *value = send_opt->bDeliveryReport; break; case MSG_MMS_SENDOPT_READ_REPLY_BOOL : - ret = send_opt->bReadReply; + *value = send_opt->bReadReply; break; case MSG_MMS_SENDOPT_KEEP_COPY_BOOL : - ret = send_opt->bKeepCopy; + *value = send_opt->bKeepCopy; break; case MSG_MMS_SENDOPT_BODY_REPLYING_BOOL : - ret = send_opt->bBodyReplying; + *value = send_opt->bBodyReplying; break; case MSG_MMS_SENDOPT_HIDE_RECIPIENTS_BOOL : - ret = send_opt->bHideRecipients; + *value = send_opt->bHideRecipients; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1306,17 +1307,17 @@ 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_struct == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1340,12 +1341,12 @@ 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1370,24 +1371,25 @@ EXPORT_API int msg_set_mms_recv_opt(msg_handle_t handle, msg_struct_t msg_struct return err; } -int msg_get_mms_recv_opt_int(void *mms_recv_opt, int field) +int msg_get_mms_recv_opt_int(void *mms_recv_opt, int field, int *value) { if (!mms_recv_opt) return MSG_ERR_NULL_POINTER; - int ret = MSG_ERR_INVALID_PARAMETER; + int ret = MSG_SUCCESS; MSG_MMS_RECVOPT_S *recv_opt = (MSG_MMS_RECVOPT_S *)mms_recv_opt; switch (field) { case MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT : - ret = recv_opt->homeNetwork; + *value = recv_opt->homeNetwork; break; case MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT : - ret = recv_opt->abroadNetwok; + *value = recv_opt->abroadNetwok; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1419,30 +1421,31 @@ int msg_set_mms_recv_opt_int(void *mms_recv_opt, int field, int value) return ret; } -bool msg_get_mms_recv_opt_bool(void *mms_recv_opt, int field) +int msg_get_mms_recv_opt_bool(void *mms_recv_opt, int field, bool *value) { if (!mms_recv_opt) - return false; + return MSG_ERR_NULL_POINTER; - bool ret = false; + int ret = MSG_SUCCESS; MSG_MMS_RECVOPT_S *recv_opt = (MSG_MMS_RECVOPT_S *)mms_recv_opt; switch (field) { case MSG_MMS_RECVOPT_READ_REPORT_BOOL : - ret = recv_opt->readReceipt; + *value = recv_opt->readReceipt; break; case MSG_MMS_RECVOPT_DELIVERY_REPORT_BOOL : - ret = recv_opt->bDeliveryReceipt; + *value = recv_opt->bDeliveryReceipt; break; case MSG_MMS_RECVOPT_REJECT_UNKNOWN_BOOL : - ret = recv_opt->bRejectUnknown; + *value = recv_opt->bRejectUnknown; break; case MSG_MMS_RECVOPT_REJECT_ADVERTISEMENT_BOOL : - ret = recv_opt->bRejectAdvertisement; + *value = recv_opt->bRejectAdvertisement; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1482,18 +1485,18 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_struct == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1515,13 +1518,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1546,21 +1549,22 @@ EXPORT_API int msg_set_push_msg_opt(msg_handle_t handle, msg_struct_t msg_struct return err; } -int msg_get_push_msg_opt_int(void *push_msg_opt, int field) +int msg_get_push_msg_opt_int(void *push_msg_opt, int field, int *value) { if (!push_msg_opt) return MSG_ERR_NULL_POINTER; - int ret = MSG_ERR_INVALID_PARAMETER; + int ret = MSG_SUCCESS; MSG_PUSHMSG_OPT_S *push_opt = (MSG_PUSHMSG_OPT_S *)push_msg_opt; switch (field) { case MSG_PUSHMSG_SERVICE_TYPE_INT : - ret = push_opt->serviceType; + *value = push_opt->serviceType; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1589,21 +1593,22 @@ int msg_set_push_msg_opt_int(void *push_msg_opt, int field, int value) return ret; } -bool msg_get_push_msg_opt_bool(void *push_msg_opt, int field) +int msg_get_push_msg_opt_bool(void *push_msg_opt, int field, bool *value) { if (!push_msg_opt) - return false; + return MSG_ERR_NULL_POINTER; - bool ret = false; + int ret = MSG_SUCCESS; MSG_PUSHMSG_OPT_S *push_opt = (MSG_PUSHMSG_OPT_S *)push_msg_opt; switch (field) { case MSG_PUSHMSG_RECEIVE_BOOL : - ret = push_opt->bReceive; + *value = push_opt->bReceive; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1634,18 +1639,18 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_struct == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1667,13 +1672,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1698,24 +1703,25 @@ 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) +int msg_get_voice_msg_opt_int(void *voice_msg_opt, int field, int *value) { if (!voice_msg_opt) return MSG_ERR_NULL_POINTER; - int ret = MSG_ERR_INVALID_PARAMETER; + 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 : - ret = voice_opt->simIndex; + *value = voice_opt->simIndex; break; case MSG_VOICEMSG_VOICE_COUNT_INT : - ret = voice_opt->voiceCnt; + *value = voice_opt->voiceCnt; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1744,28 +1750,26 @@ int msg_set_voice_msg_opt_int(void *voice_msg_opt, int field, int value) return ret; } -char *msg_get_voice_msg_opt_str(void *voice_msg_opt, int field) +int msg_get_voice_msg_opt_str(void *voice_msg_opt, int field, char *value, int size) { if (!voice_msg_opt) - return NULL; - - char *ret_str = NULL; + return MSG_ERR_NULL_POINTER; MSG_VOICEMAIL_OPT_S *voice_opt = (MSG_VOICEMAIL_OPT_S *)voice_msg_opt; switch (field) { case MSG_VOICEMSG_ADDRESS_STR : - ret_str = voice_opt->mailNumber; + strncpy(value, voice_opt->mailNumber, size); break; case MSG_VOICEMSG_ALPHA_ID_STR : - ret_str = voice_opt->alpahId; + strncpy(value, voice_opt->alpahId, size); break; default : - break; + return MSG_ERR_INVALID_PARAMETER; } - return ret_str; + return MSG_SUCCESS; } int msg_set_voice_msg_opt_str(void *voice_msg_opt, int field, char *val, int size) @@ -1793,18 +1797,18 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_struct == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1826,13 +1830,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1857,30 +1861,31 @@ EXPORT_API int msg_set_general_opt(msg_handle_t handle, msg_struct_t msg_struct) return err; } -int msg_get_general_opt_int(void *general_opt, int field) +int msg_get_general_opt_int(void *general_opt, int field, int *value) { if (!general_opt) return MSG_ERR_NULL_POINTER; - int ret = MSG_ERR_INVALID_PARAMETER; + int ret = MSG_SUCCESS; MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt; switch (field) { case MSG_GENERAL_ALERT_TONE_INT : - ret = opt->alertTone; + *value = opt->alertTone; break; case MSG_GENERAL_SMS_LIMIT_CNT_INT : - ret = opt->smsLimitCnt; + *value = opt->smsLimitCnt; break; case MSG_GENERAL_MMS_LIMIT_CNT_INT : - ret = opt->mmsLimitCnt; + *value = opt->mmsLimitCnt; break; case MSG_GENERAL_RINGTONE_TYPE_INT : - ret = opt->ringtoneType; + *value = opt->ringtoneType; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1918,36 +1923,37 @@ int msg_set_general_opt_int(void *general_opt, int field, int value) return ret; } -bool msg_get_general_opt_bool(void *general_opt, int field) +int msg_get_general_opt_bool(void *general_opt, int field, bool *value) { if (!general_opt) - return false; + return MSG_ERR_NULL_POINTER; - int ret = false; + int ret = MSG_SUCCESS; MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt; switch (field) { case MSG_GENERAL_KEEP_COPY_BOOL : - ret = opt->bKeepCopy; + *value = opt->bKeepCopy; break; case MSG_GENERAL_AUTO_ERASE_BOOL : - ret = opt->bAutoErase; + *value = opt->bAutoErase; break; case MSG_GENERAL_BLOCK_UNKNOWN_NUMBER_BOOL : - ret = opt->bBlockUnknownMsg; + *value = opt->bBlockUnknownMsg; break; case MSG_GENERAL_MSG_NOTIFICATION_BOOL : - ret = opt->bNotification; + *value = opt->bNotification; break; case MSG_GENERAL_MSG_VIBRATION_BOOL : - ret = opt->bVibration; + *value = opt->bVibration; break; case MSG_GENERAL_MSG_PREVIEW_BOOL : - ret = opt->bPreview; + *value = opt->bPreview; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } @@ -1991,25 +1997,23 @@ int msg_set_general_opt_bool(void *general_opt, int field, bool value) return ret; } -char *msg_get_general_opt_str(void *general_opt, int field) +int msg_get_general_opt_str(void *general_opt, int field, char *value, int size) { if (!general_opt) - return NULL; - - char *ret_str = NULL; + return MSG_ERR_NULL_POINTER; MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt; switch (field) { case MSG_GENERAL_RINGTONE_PATH_STR : - ret_str = opt->ringtonePath; + strncpy(value, opt->ringtonePath, size); break; default : - break; + return MSG_ERR_INVALID_PARAMETER; } - return ret_str; + return MSG_SUCCESS; } int msg_set_general_opt_str(void *general_opt, int field, char *val, int size) @@ -2038,18 +2042,18 @@ int msg_set_general_opt_str(void *general_opt, int field, char *val, int size) 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_struct == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -2071,13 +2075,13 @@ 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -2102,21 +2106,22 @@ EXPORT_API int msg_set_msgsize_opt(msg_handle_t handle, msg_struct_t msg_struct) return err; } -int msg_get_msgsize_opt_int(void *size_opt, int field) +int msg_get_msgsize_opt_int(void *size_opt, int field, int *value) { if (!size_opt) return MSG_ERR_NULL_POINTER; - int ret = MSG_ERR_INVALID_PARAMETER; + int ret = MSG_SUCCESS; MSG_MSGSIZE_OPT_S *msg_opt = (MSG_MSGSIZE_OPT_S *)size_opt; switch (field) { case MSG_MESSAGE_SIZE_INT : - ret = msg_opt->nMsgSize; + *value = msg_opt->nMsgSize; break; default : + ret = MSG_ERR_INVALID_PARAMETER; break; } diff --git a/mapi/msg_storage.cpp b/mapi/msg_storage.cpp index 618422e..5c7cf34 100755 --- a/mapi/msg_storage.cpp +++ b/mapi/msg_storage.cpp @@ -32,13 +32,13 @@ static int msg_get_msg_type(int mainType, int subType); ==================================================================================================*/ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -51,7 +51,10 @@ EXPORT_API int msg_add_message(msg_handle_t handle, msg_struct_t opq_msg, const MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pMsgStruct = (msg_struct_s *)opq_msg; + MSG_TYPE_CHECK(pMsgStruct->type, MSG_STRUCT_MESSAGE_INFO); + msg_struct_s *pStruct = (msg_struct_s *)send_opt; + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_SENDOPT); try { @@ -69,13 +72,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -87,6 +90,7 @@ EXPORT_API int msg_add_syncml_message(msg_handle_t handle, const msg_struct_t sy MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pStruct = (msg_struct_s *)syncml_msg; + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_SYNCML_INFO); try { @@ -104,13 +108,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -121,14 +125,18 @@ EXPORT_API int msg_update_message(msg_handle_t handle, const msg_struct_t opq_ms } MsgHandle* pHandle = (MsgHandle*)handle; + msg_struct_s *pMsgStruct = (msg_struct_s *)opq_msg; + MSG_TYPE_CHECK(pMsgStruct->type, MSG_STRUCT_MESSAGE_INFO); + msg_struct_s* pStruct = (msg_struct_s *)send_opt; + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_SENDOPT); MSG_MESSAGE_HIDDEN_S *msg = (MSG_MESSAGE_HIDDEN_S *)pMsgStruct->data; - + MSG_SENDINGOPT_S *sendingOpt = (MSG_SENDINGOPT_S *)pStruct->data; try { - err = pHandle->updateMessage(msg, (MSG_SENDINGOPT_S *)pStruct->data); + err = pHandle->updateMessage(msg, sendingOpt); } catch (MsgException& e) { @@ -142,13 +150,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -174,15 +182,15 @@ 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) +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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -210,13 +218,13 @@ EXPORT_API int msg_set_conversation_to_read(msg_handle_t handle, msg_thread_id_ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -243,13 +251,13 @@ EXPORT_API int msg_update_protected_status(msg_handle_t handle, msg_message_id_t 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -277,13 +285,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -311,18 +319,18 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_id_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -345,13 +353,13 @@ EXPORT_API int msg_delete_msgs_by_list(msg_handle_t handle, msg_id_list_s *msg_i 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -379,13 +387,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -419,24 +427,26 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || count_info == NULL) { return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pStruct = (msg_struct_s *)count_info; + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_COUNT_INFO); + try { err = pHandle->countMessage(folder_id, (MSG_COUNT_INFO_S *)pStruct->data); @@ -453,18 +463,18 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_count == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -488,6 +498,9 @@ EXPORT_API int msg_count_msg_by_type(msg_handle_t handle, msg_message_type_t msg msgType.mainType = MSG_MMS_TYPE; msgType.subType = MSG_SENDREQ_MMS; } + else { + return MSG_ERR_INVALID_PARAMETER; + } try { @@ -505,25 +518,29 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL || addr_info == NULL) + if (handle == NULL || addr_info == NULL || msg_thread_count_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; + msg_struct_s *pAddr = (msg_struct_s *)addr_info; + MSG_TYPE_CHECK(pAddr->type, MSG_STRUCT_THREAD_LIST_INDEX); + msg_struct_s *pCount = (msg_struct_s *)msg_thread_count_list; + MSG_TYPE_CHECK(pCount->type, MSG_STRUCT_THREAD_COUNT_INFO); try { @@ -541,18 +558,18 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL || !opq_msg) + if (handle == NULL || opq_msg == NULL || send_opt == NULL) { MSG_FATAL("handle or opq_msg is NULL"); return MSG_ERR_INVALID_PARAMETER; @@ -561,7 +578,10 @@ EXPORT_API int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pMsgStruct = (msg_struct_s *)opq_msg; + MSG_TYPE_CHECK(pMsgStruct->type, MSG_STRUCT_MESSAGE_INFO); + msg_struct_s *pStruct = (msg_struct_s *)send_opt; + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_SENDOPT); try { @@ -578,13 +598,13 @@ EXPORT_API int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -612,18 +632,18 @@ EXPORT_API int msg_get_vobject_data(msg_handle_t handle, msg_message_id_t msg_id 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL || !conv) + if (handle == NULL || conv == NULL) { MSG_FATAL("handle or opq_msg is NULL"); return MSG_ERR_INVALID_PARAMETER; @@ -632,6 +652,8 @@ EXPORT_API int msg_get_conversation(msg_handle_t handle, msg_message_id_t msg_id MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pMsgStruct = (msg_struct_s *)conv; + MSG_TYPE_CHECK(pMsgStruct->type, MSG_STRUCT_CONV_INFO); + try { err = pHandle->getConversationViewItem(msg_id, (MSG_CONVERSATION_VIEW_S *)pMsgStruct->data); @@ -647,28 +669,30 @@ EXPORT_API int msg_get_conversation(msg_handle_t handle, msg_message_id_t msg_id 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_thread_view_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pStruct =(msg_struct_s *)sort_rule; - + if (pStruct) { + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_SORT_RULE); + } try { - if (sort_rule == NULL) + if (pStruct == NULL) { MSG_SORT_RULE_S sortRule = {0}; @@ -694,18 +718,18 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_conv_view_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -728,13 +752,13 @@ 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, bool include_protected_msg) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); - msg_error_t err = MSG_SUCCESS; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -762,13 +786,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -780,6 +804,7 @@ EXPORT_API int msg_add_folder(msg_handle_t handle, const msg_struct_t folder_inf MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pStruct = (msg_struct_s *)folder_info; + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_FOLDER_INFO); try { @@ -797,13 +822,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -815,6 +840,7 @@ EXPORT_API int msg_update_folder(msg_handle_t handle, const msg_struct_t folder_ MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pStruct = (msg_struct_s *)folder_info; + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_FOLDER_INFO); try { @@ -832,13 +858,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -866,18 +892,18 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || folder_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -900,11 +926,11 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -915,6 +941,12 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_ return MSG_ERR_INVALID_PARAMETER; } + if (msg_type >= MSG_MESSAGE_TYPE_MAX) + { + MSG_DEBUG("msg_type is invalid [%d]", msg_type); + return MSG_ERR_INVALID_PARAMETER; + } + if (folder_id >= MSG_MAX_FOLDER_ID) { MSG_DEBUG("folderId is invalid [%d]", folder_id); @@ -942,6 +974,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; @@ -959,8 +994,8 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_ snprintf(strMsg, sizeof(strMsg), "test msg %d", i); msgInfo->dataSize = strlen(strMsg); msgInfo->pData = (void*)new char[msgInfo->dataSize+1]; - memcpy((char *)msgInfo->pData, strMsg, msgInfo->dataSize); - ((char*) msgInfo->pData)[msgInfo->dataSize] = '\0'; + memcpy((char *)msgInfo->pData, strMsg, msgInfo->dataSize); + ((char*) msgInfo->pData)[msgInfo->dataSize] = '\0'; } msgInfo->storageId = MSG_STORAGE_PHONE; @@ -972,7 +1007,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; @@ -995,6 +1030,11 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_ if(folder_id == MSG_INBOX_ID) msgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS; + msg_struct_t mms_data = msg_create_struct(MSG_STRUCT_MMS); + + msg_set_mms_struct((msg_struct_t)msg_s, mms_data); + + msg_release_struct(&mms_data); //MMS_MESSAGE_DATA_S* mms_data; //MMS_PAGE_S* page[2]; //MMS_MEDIA_S* media[5]; @@ -1043,9 +1083,6 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_ return MSG_ERR_STORAGE_ERROR; } - if (msg_type == MSG_TYPE_MMS && msgInfo->pMmsData) //free pMmsData directly. It is added to enhance performance - delete [] static_cast<char*>(msgInfo->pMmsData); - msg_release_struct((msg_struct_t *)&msg_s); if (err < 0) @@ -1061,25 +1098,31 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_ EXPORT_API int msg_get_quick_panel_data(msg_handle_t handle, msg_quickpanel_type_t type, msg_struct_t opq_msg) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); - msg_error_t err = MSG_SUCCESS; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL || !opq_msg ) + if (handle == NULL || opq_msg == NULL ) { MSG_FATAL("handle or opq_msg is NULL"); return MSG_ERR_INVALID_PARAMETER; } + if (type > MSG_QUICKPANEL_MMS_NOTI) { + MSG_FATAL("unsupported quickpanel type [%d]", type); + return MSG_ERR_INVALID_PARAMETER; + } + MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pMsg = (msg_struct_s *)opq_msg; + MSG_TYPE_CHECK(pMsg->type, MSG_STRUCT_MESSAGE_INFO); try { @@ -1097,13 +1140,13 @@ EXPORT_API int msg_get_quick_panel_data(msg_handle_t handle, msg_quickpanel_type EXPORT_API int msg_reset_database(msg_handle_t handle) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); - msg_error_t err = MSG_SUCCESS; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1131,18 +1174,18 @@ EXPORT_API int msg_reset_database(msg_handle_t handle) 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || memsize == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1165,13 +1208,13 @@ EXPORT_API int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize) 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1199,13 +1242,13 @@ EXPORT_API int msg_backup_message(msg_handle_t handle, msg_message_backup_type_t 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1233,18 +1276,18 @@ EXPORT_API int msg_restore_message(msg_handle_t handle, const char *backup_filep 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL || search_string == NULL) + if (handle == NULL || search_string == NULL || msg_thread_view_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1271,18 +1314,18 @@ EXPORT_API int msg_search_message_for_thread_view(msg_handle_t handle, const cha 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_reject_msg_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1305,13 +1348,13 @@ 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) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); - msg_error_t err = MSG_SUCCESS; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1341,13 +1384,13 @@ EXPORT_API int msg_reg_storage_change_callback(msg_handle_t handle, msg_storage_ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1374,18 +1417,18 @@ EXPORT_API int msg_get_report_status(msg_handle_t handle, msg_message_id_t msg_i 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) + if (handle == NULL || msg_address_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1408,13 +1451,13 @@ 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) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); - msg_error_t err = MSG_SUCCESS; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1445,13 +1488,13 @@ EXPORT_API int msg_get_thread_id_by_address(msg_handle_t handle, msg_struct_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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1479,13 +1522,13 @@ EXPORT_API int msg_get_thread_id_by_address2(msg_handle_t handle, msg_list_handl 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -1497,10 +1540,7 @@ EXPORT_API int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, ms 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_TYPE_CHECK(msgThread->type, MSG_STRUCT_THREAD_INFO); MSG_THREAD_VIEW_S* pThreadInfo = (MSG_THREAD_VIEW_S *)msgThread->data; @@ -1519,23 +1559,24 @@ EXPORT_API int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, ms 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) { + if (handle == NULL || msg_list_conditions == NULL || msg_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pStruct = (msg_struct_s *)msg_list_conditions; + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_MSG_LIST_CONDITION); try { @@ -1553,17 +1594,17 @@ EXPORT_API int msg_get_message_list2(msg_handle_t handle, const msg_struct_t msg 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL) { + if (handle == NULL || msg_list == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -1587,7 +1628,7 @@ static int msg_get_msg_type(int mainType, int subType) { if (mainType == MSG_SMS_TYPE) { - switch (subType) { + switch (subType) { case MSG_CB_SMS : return MSG_TYPE_SMS_CB; case MSG_JAVACB_SMS : @@ -1620,7 +1661,7 @@ static int msg_get_msg_type(int mainType, int subType) return MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED; default : return MSG_TYPE_SMS; - } + } } else if (mainType == MSG_MMS_TYPE) { @@ -1636,540 +1677,576 @@ static int msg_get_msg_type(int mainType, int subType) } -int msg_syncml_info_get_int(void *syncml_info, int field) +int msg_syncml_info_get_int(void *syncml_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!syncml_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_SYNCML_MESSAGE_S *pSync = (MSG_SYNCML_MESSAGE_S *)syncml_info; + switch(field) { case MSG_SYNCML_INFO_EXTID_INT: - result = pSync->extId; + *value = pSync->extId; break; case MSG_SYNCML_INFO_PINCODE_INT: - result = pSync->pinCode; + *value = pSync->pinCode; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_count_info_get_int(void *count_info, int field) +int msg_count_info_get_int(void *count_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!count_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_COUNT_INFO_S *pCount = (MSG_COUNT_INFO_S *)count_info; + switch(field) { case MSG_COUNT_INFO_READ_INT: - result = pCount->nReadCnt; + *value = pCount->nReadCnt; break; case MSG_COUNT_INFO_UNREAD_INT: - result = pCount->nUnreadCnt; + *value = pCount->nUnreadCnt; break; case MSG_COUNT_INFO_SMS_INT: - result = pCount->nSms; + *value = pCount->nSms; break; case MSG_COUNT_INFO_MMS_INT: - result = pCount->nMms; + *value = pCount->nMms; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_thread_count_get_int(void *count_info, int field) +int msg_thread_count_get_int(void *count_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!count_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_THREAD_COUNT_INFO_S *pCount = (MSG_THREAD_COUNT_INFO_S *)count_info; + switch(field) { case MSG_THREAD_COUNT_TOTAL_INT: - result = pCount->totalCount; + *value = pCount->totalCount; break; case MSG_THREAD_COUNT_UNREAD_INT: - result = pCount->unReadCount; + *value = pCount->unReadCount; break; case MSG_THREAD_COUNT_SMS_INT: - result = pCount->smsMsgCount; + *value = pCount->smsMsgCount; break; case MSG_THREAD_COUNT_MMS_INT: - result = pCount->mmsMsgCount; + *value = pCount->mmsMsgCount; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_thread_index_get_int(void *index_info, int field) +int msg_thread_index_get_int(void *index_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!index_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_THREAD_LIST_INDEX_S *pIndex = (MSG_THREAD_LIST_INDEX_S *)index_info; switch(field) { case MSG_THREAD_LIST_INDEX_CONTACTID_INT: - result = pIndex->contactId; + *value = pIndex->contactId; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_sortrule_get_int(void *sort_info, int field) +int msg_sortrule_get_int(void *sort_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!sort_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_info; + switch(field) { case MSG_SORT_RULE_SORT_TYPE_INT: - result = pSort->sortType; + *value = pSort->sortType; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_folder_info_get_int(void *folder_info, int field) +int msg_folder_info_get_int(void *folder_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!folder_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info; + switch(field) { case MSG_FOLDER_INFO_ID_INT: - result = pFolder->folderId; + *value = pFolder->folderId; break; case MSG_FOLDER_INFO_TYPE_INT: - result = pFolder->folderType; + *value = pFolder->folderType; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_thread_info_get_int(void *data, int field) +int msg_thread_info_get_int(void *data, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!data) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_THREAD_VIEW_S *pThread = (MSG_THREAD_VIEW_S *)data; switch(field) { case MSG_THREAD_ID_INT : - result = pThread->threadId; + *value = pThread->threadId; break; case MSG_THREAD_MSG_TYPE_INT : - result = msg_get_msg_type(pThread->mainType, pThread->subType); + *value = msg_get_msg_type(pThread->mainType, pThread->subType); break; case MSG_THREAD_MSG_TIME_INT : - result = pThread->threadTime; + *value = pThread->threadTime; break; case MSG_THREAD_DIRECTION_INT : - result = pThread->direction; + *value = pThread->direction; break; case MSG_THREAD_UNREAD_COUNT_INT : - result = pThread->unreadCnt; + *value = pThread->unreadCnt; break; case MSG_THREAD_SMS_COUNT_INT : - result = pThread->smsCnt; + *value = pThread->smsCnt; break; case MSG_THREAD_MMS_COUNT_INT : - result = pThread->mmsCnt; + *value = pThread->mmsCnt; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_conv_info_get_int(void *data, int field) +int msg_conv_info_get_int(void *data, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!data) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S *)data; switch(field) { case MSG_CONV_MSG_ID_INT : - result = pConv->msgId; + *value = pConv->msgId; break; case MSG_CONV_MSG_THREAD_ID_INT : - result = pConv->threadId; + *value = pConv->threadId; break; case MSG_CONV_MSG_FOLDER_ID_INT : - result = pConv->folderId; + *value = pConv->folderId; break; case MSG_CONV_MSG_TYPE_INT : - result = msg_get_msg_type(pConv->mainType, pConv->subType); + *value = msg_get_msg_type(pConv->mainType, pConv->subType); break; case MSG_CONV_MSG_STORAGE_ID_INT : - result = pConv->storageId; + *value = pConv->storageId; break; case MSG_CONV_MSG_DISPLAY_TIME_INT : - result = pConv->displayTime; + *value = pConv->displayTime; break; case MSG_CONV_MSG_SCHEDULED_TIME_INT : - result = pConv->scheduledTime; + *value = pConv->scheduledTime; break; case MSG_CONV_MSG_NETWORK_STATUS_INT : - result = pConv->networkStatus; + *value = pConv->networkStatus; break; case MSG_CONV_MSG_DIRECTION_INT : - result = pConv->direction; + *value = pConv->direction; break; case MSG_CONV_MSG_ATTACH_COUNT_INT : - result = pConv->attachCount; + *value = pConv->attachCount; break; case MSG_CONV_MSG_TEXT_SIZE_INT : - result = pConv->textSize; + *value = pConv->textSize; break; case MSG_CONV_MSG_PAGE_COUNT_INT : - result = pConv->pageCount; + *value = pConv->pageCount; break; case MSG_CONV_MSG_TCS_BC_LEVEL_INT : - result = pConv->tcs_bc_level; + *value = pConv->tcs_bc_level; break; case MSG_CONV_MSG_SIM_INDEX_INT : - result = pConv->simIndex; + *value = pConv->simIndex; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_search_condition_get_int(void *condition_info, int field) +int msg_list_condition_get_int(void *condition_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; - MSG_SEARCH_CONDITION_S *pCond = (MSG_SEARCH_CONDITION_S *)condition_info; - switch(field) - { - case MSG_SEARCH_CONDITION_FOLDERID_INT: - result = pCond->folderId; - break; - case MSG_SEARCH_CONDITION_MSGTYPE_INT: - result = pCond->msgType; - break; - case MSG_SEARCH_CONDITION_RESERVED_INT: - result = pCond->reserved; - break; - default: - result = MSG_ERR_INVALID_PARAMETER; - break; - } - return result; -} + if (!condition_info) + return MSG_ERR_NULL_POINTER; + int ret = MSG_SUCCESS; -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; + *value = pCond->folderId; break; case MSG_LIST_CONDITION_THREAD_ID_INT: - result = pCond->threadId; - break; + *value = pCond->threadId; + break; case MSG_LIST_CONDITION_STORAGE_ID_INT: - result = pCond->storageId; - break; + *value = pCond->storageId; + break; case MSG_LIST_CONDITION_MSGTYPE_INT: - result = pCond->msgType; + *value = pCond->msgType; break; case MSG_LIST_CONDITION_FROM_TIME_INT: - result = pCond->fromTime; + *value = pCond->fromTime; break; case MSG_LIST_CONDITION_TO_TIME_INT: - result = pCond->toTime; + *value = pCond->toTime; break; case MSG_LIST_CONDITION_OFFSET_INT: - result = pCond->offset; + *value = pCond->offset; break; case MSG_LIST_CONDITION_LIMIT_INT: - result = pCond->limit; + *value = pCond->limit; break; case MSG_LIST_CONDITION_SIM_INDEX_INT: - result = pCond->simIndex; + *value = pCond->simIndex; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_report_status_get_int(void *report_info, int field) +int msg_report_status_get_int(void *report_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!report_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_REPORT_STATUS_INFO_S *pReport = (MSG_REPORT_STATUS_INFO_S *)report_info; switch(field) { case MSG_REPORT_TYPE_INT: - result = pReport->type; + *value = pReport->type; break; case MSG_REPORT_STATUS_INT: - result = pReport->status; + *value = pReport->status; break; case MSG_REPORT_TIME_INT: - result = pReport->statusTime; + *value = pReport->statusTime; break; default: - result = MSG_ERR_INVALID_PARAMETER; + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -char* msg_report_status_get_str(void *report_info, int field) +int msg_report_status_get_str(void *report_info, int field, char *value, int size) { - 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; + strncpy(value, pReport->addressVal, size); break; - default: - break; + return MSG_ERR_INVALID_PARAMETER; } - return result; + return MSG_SUCCESS; } -char* msg_folder_info_get_str(void *folder_info, int field) +int msg_folder_info_get_str(void *folder_info, int field, char *value, int size) { - char *result = NULL; MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info; switch(field) { case MSG_FOLDER_INFO_NAME_STR: - result = pFolder->folderName; + strncpy(value, pFolder->folderName, size); break; default: - result = NULL; - break; + return MSG_ERR_INVALID_PARAMETER; } - return result; + return MSG_SUCCESS; } -char *msg_thread_info_get_str(void *data, int field) +int msg_thread_info_get_str(void *data, int field, char *value, int size) { - char *ret_str = NULL; MSG_THREAD_VIEW_S *pThread = (MSG_THREAD_VIEW_S *)data; switch(field) { case MSG_THREAD_NAME_STR : - ret_str = pThread->threadName; + strncpy(value, pThread->threadName, size); break; case MSG_THREAD_MSG_DATA_STR : - ret_str = pThread->threadData; + strncpy(value, pThread->threadData, size); break; default: - break; + return MSG_ERR_INVALID_PARAMETER; } - return ret_str; + return MSG_SUCCESS; } -char *msg_conv_info_get_str(void *data, int field) +int msg_conv_info_get_str(void *data, int field, char *value, int size) { - 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; + strncpy(value, pConv->subject, size); break; case MSG_CONV_MSG_ATTACH_NAME_STR : - ret_str = pConv->attachFileName; + strncpy(value, pConv->attachFileName, size); break; case MSG_CONV_MSG_AUDIO_NAME_STR : - ret_str = pConv->audioFileName; + strncpy(value, pConv->audioFileName, size); break; case MSG_CONV_MSG_IMAGE_THUMB_PATH_STR : - ret_str = pConv->imageThumbPath; + strncpy(value, pConv->imageThumbPath, size); break; case MSG_CONV_MSG_VIDEO_THUMB_PATH_STR : - ret_str = pConv->videoThumbPath; + strncpy(value, pConv->videoThumbPath, size); break; case MSG_CONV_MSG_TEXT_STR : - ret_str = pConv->pText; + if (pConv->pText) + strncpy(value, pConv->pText, size); break; case MSG_CONV_MSG_1ST_MEDIA_PATH_STR : - ret_str = pConv->firstMediaPath; + strncpy(value, pConv->firstMediaPath, size); break; default: - break; + return MSG_ERR_INVALID_PARAMETER; } - return ret_str; -} - - -char* msg_search_condition_get_str(void *condition_info, int field, int size) -{ - char *result = NULL; - MSG_SEARCH_CONDITION_S *search_cond = (MSG_SEARCH_CONDITION_S *)condition_info; - switch(field) - { - case MSG_SEARCH_CONDITION_ADDRESS_VALUE_STR: - result = search_cond->pAddressVal; - break; - case MSG_SEARCH_CONDITION_SEARCH_VALUE_STR: - result = search_cond->pSearchVal; - break; - default: - result = NULL; - break; - } - return result; + return MSG_SUCCESS; } -char* msg_list_condition_get_str(void *condition_info, int field, int size) +int msg_list_condition_get_str(void *condition_info, int field, char *value, 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; + if (cond->pAddressVal) + strncpy(value, cond->pAddressVal, size); break; case MSG_LIST_CONDITION_TEXT_VALUE_STR: - result = cond->pTextVal; + if (cond->pTextVal) + strncpy(value, cond->pTextVal, size); break; default: - result = NULL; - break; + return MSG_ERR_INVALID_PARAMETER; } - return result; + + return MSG_SUCCESS; } -bool msg_sendopt_get_bool(void *send_opt, int field) +int msg_sendopt_get_bool(void *send_opt, int field, bool *value) { - bool result = false; + if (!send_opt) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_SENDINGOPT_S *sendopt = (MSG_SENDINGOPT_S *)send_opt; switch(field) { case MSG_SEND_OPT_SETTING_BOOL: - result = sendopt->bSetting; + *value = sendopt->bSetting; break; case MSG_SEND_OPT_KEEPCOPY_BOOL: - result = sendopt->bKeepCopy; + *value = sendopt->bKeepCopy; break; case MSG_SEND_OPT_DELIVER_REQ_BOOL: - result = sendopt->bDeliverReq; + *value = sendopt->bDeliverReq; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } -bool msg_sortrule_get_bool(void *sort_rule, int field) +int msg_sortrule_get_bool(void *sort_rule, int field, bool *value) { - bool result = false; + if (!sort_rule) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_rule; switch(field) { case MSG_SORT_RULE_ACSCEND_BOOL: - result = pSort->bAscending; + *value = pSort->bAscending; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } -bool msg_conv_get_bool(void *data, int field) +int msg_conv_get_bool(void *data, int field, bool *value) { - bool result = false; + if (!data) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S *)data; + switch(field) { case MSG_CONV_MSG_READ_BOOL: - result = pConv->bRead; + *value = pConv->bRead; break; case MSG_CONV_MSG_PROTECTED_BOOL: - result = pConv->bProtected; + *value = pConv->bProtected; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } -bool msg_thread_info_get_bool(void *data, int field) +int msg_thread_info_get_bool(void *data, int field, bool *value) { - bool result = false; + if (!data) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_THREAD_VIEW_S *pthreadInfo = (MSG_THREAD_VIEW_S *)data; + switch(field) { case MSG_THREAD_PROTECTED_BOOL: - result = pthreadInfo->bProtected; + *value = pthreadInfo->bProtected; break; case MSG_THREAD_DRAFT_BOOL : - result = pthreadInfo->bDraft; + *value = pthreadInfo->bDraft; break; case MSG_THREAD_SEND_FAILED_BOOL : - result = pthreadInfo->bSendFailed; + *value = pthreadInfo->bSendFailed; break; case MSG_THREAD_SENDING_BOOL : - result = pthreadInfo->bSending; + *value = pthreadInfo->bSending; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } -bool msg_list_condition_get_bool(void *data, int field) +int msg_list_condition_get_bool(void *data, int field, bool *value) { - bool result = false; + if (!data) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)data; + switch(field) { case MSG_LIST_CONDITION_PROTECTED_BOOL: - result = pCond->bProtected; + *value = pCond->bProtected; break; case MSG_LIST_CONDITION_SCHEDULED_BOOL : - result = pCond->bScheduled; + *value = pCond->bScheduled; break; case MSG_LIST_CONDITION_AND_OPERATER_BOOL : - result = pCond->bAnd; + *value = pCond->bAnd; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } int msg_sendopt_get_struct_handle(msg_struct_s *msg_struct, int field, void **value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_struct || !value) return MSG_ERR_NULL_POINTER; @@ -2192,12 +2269,13 @@ int msg_sendopt_get_struct_handle(msg_struct_s *msg_struct, int field, void **va int msg_syncml_get_struct_handle(msg_struct_s *msg_struct, int field, void **value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_struct || !value) return MSG_ERR_NULL_POINTER; MSG_SYNCML_MESSAGE_S *pSync = (MSG_SYNCML_MESSAGE_S *)msg_struct->data; + switch(field) { case MSG_SYNCML_INFO_MESSAGE_HND: @@ -2206,19 +2284,19 @@ int msg_syncml_get_struct_handle(msg_struct_s *msg_struct, int field, void **val default: err = MSG_ERR_UNKNOWN; break; - } return err; } int msg_thread_index_get_struct_handle(msg_struct_s *msg_struct, int field, void **value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_struct || !value) return MSG_ERR_NULL_POINTER; MSG_THREAD_LIST_INDEX_INFO_S *pIndex = (MSG_THREAD_LIST_INDEX_INFO_S *)msg_struct->data; + switch(field) { case MSG_THREAD_LIST_INDEX_ADDR_INFO_HND: @@ -2235,12 +2313,13 @@ int msg_thread_index_get_struct_handle(msg_struct_s *msg_struct, int field, void int msg_list_condition_get_struct_handle(msg_struct_s *msg_struct, int field, void **value) { - msg_error_t err = MSG_SUCCESS; + 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: @@ -2255,296 +2334,298 @@ int msg_list_condition_get_struct_handle(msg_struct_s *msg_struct, int field, vo } -int msg_address_info_get_int(void *addr_info, int field) +int msg_address_info_get_int(void *addr_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!addr_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_ADDRESS_INFO_S *pAddr = (MSG_ADDRESS_INFO_S *)addr_info; + switch(field) { case MSG_ADDRESS_INFO_ADDRESS_TYPE_INT: - result = pAddr->addressType; + *value = pAddr->addressType; break; case MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT: - result = pAddr->recipientType; + *value = pAddr->recipientType; break; case MSG_ADDRESS_INFO_CONTACT_ID_INT: - result = pAddr->contactId; + *value = pAddr->contactId; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } -int msg_mms_sendopt_get_int(void *opt_info, int field) + +int msg_mms_sendopt_get_int(void *opt_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!opt_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MMS_SENDINGOPT_S *pOpt = (MMS_SENDINGOPT_S *)opt_info; + switch(field) { case MSG_MMS_SENDOPTION_EXPIRY_TIME_INT: - result = pOpt->expiryTime; + *value = pOpt->expiryTime; break; case MSG_MMS_SENDOPTION_DELIVERY_TIME_INT: - result = pOpt->deliveryTime; + *value = pOpt->deliveryTime; break; case MSG_MMS_SENDOPTION_PRIORITY_INT: - result = pOpt->priority; + *value = pOpt->priority; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } -int msg_reject_message_get_int(void *msg_info, int field) +int msg_reject_message_get_int(void *msg_info, int field, int *value) { - int result = MSG_ERR_INVALID_PARAMETER; + if (!msg_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_REJECT_MSG_INFO_S *pMsg = (MSG_REJECT_MSG_INFO_S *)msg_info; + switch(field) { case MSG_REJECT_MESSAGE_MSGID_INT: - result = pMsg->msgId; + *value = pMsg->msgId; break; case MSG_REJECT_MESSAGE_DISPLAY_TIME_INT: - result = pMsg->displayTime; + *value = pMsg->displayTime; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } -char* msg_address_info_get_str(void *addr_info, int field, int size) +int msg_address_info_get_str(void *addr_info, int field, char *value, int size) { - char *result = NULL; MSG_ADDRESS_INFO_S *pAddr = (MSG_ADDRESS_INFO_S *)addr_info; switch(field) { case MSG_ADDRESS_INFO_ADDRESS_VALUE_STR: - result = pAddr->addressVal; + strncpy(value, pAddr->addressVal, size); break; case MSG_ADDRESS_INFO_DISPLAYNAME_STR: - result = pAddr->displayName; + strncpy(value, pAddr->displayName, size); break; default: - result = NULL; - break; + return MSG_ERR_INVALID_PARAMETER; } - return result; + + return MSG_SUCCESS; } -char* msg_reject_message_get_str(void *msg_info, int field, int size) +int msg_reject_message_get_str(void *msg_info, int field, char *value, int size) { - char *result = NULL; MSG_REJECT_MSG_INFO_S *pMsg = (MSG_REJECT_MSG_INFO_S *)msg_info; switch(field) { case MSG_REJECT_MESSAGE_MSGTEXT_STR: - result = pMsg->msgText; + strncpy(value, pMsg->msgText, size); break; default: - result = NULL; - break; + return MSG_ERR_INVALID_PARAMETER; } - return result; + + return MSG_SUCCESS; } -bool msg_mms_sendopt_get_bool(void *opt_info, int field) +int msg_mms_sendopt_get_bool(void *opt_info, int field, bool *value) { - bool result = false; + if (!opt_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MMS_SENDINGOPT_S *pOpt = (MMS_SENDINGOPT_S *)opt_info; + switch(field) { case MSG_MMS_SENDOPTION_READ_REQUEST_BOOL: - result = pOpt->bReadReq; + *value = pOpt->bReadReq; break; case MSG_MMS_SENDOPTION_DELIVERY_CUSTOMTIME_BOOL: - result = pOpt->bUseDeliveryCustomTime; + *value = pOpt->bUseDeliveryCustomTime; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } -bool msg_sms_sendopt_get_bool(void *opt_info, int field) +int msg_sms_sendopt_get_bool(void *opt_info, int field, bool *value) { - bool result = false; + if (!opt_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + SMS_SENDINGOPT_S *pOpt = (SMS_SENDINGOPT_S *)opt_info; switch(field) { case MSG_SMS_SENDOPT_REPLYPATH_BOOL: - result = pOpt->bReplyPath; + *value = pOpt->bReplyPath; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } int msg_syncml_info_set_int(void *syncml_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!syncml_info) return MSG_ERR_NULL_POINTER; - MSG_SYNCML_MESSAGE_S *pSync = (MSG_SYNCML_MESSAGE_S *)syncml_info; - switch(field) - { - case MSG_SYNCML_INFO_EXTID_INT: + MSG_SYNCML_MESSAGE_S *pSync = (MSG_SYNCML_MESSAGE_S *)syncml_info; + switch(field) + { + case MSG_SYNCML_INFO_EXTID_INT: pSync->extId = value; break; - case MSG_SYNCML_INFO_PINCODE_INT: + case MSG_SYNCML_INFO_PINCODE_INT: pSync->pinCode = value; break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } int msg_count_info_set_int(void *count_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!count_info) return MSG_ERR_NULL_POINTER; - MSG_COUNT_INFO_S *pCount = (MSG_COUNT_INFO_S *)count_info; + MSG_COUNT_INFO_S *pCount = (MSG_COUNT_INFO_S *)count_info; - switch(field) - { - case MSG_COUNT_INFO_READ_INT: + switch(field) + { + case MSG_COUNT_INFO_READ_INT: pCount->nReadCnt = value; break; - case MSG_COUNT_INFO_UNREAD_INT: + case MSG_COUNT_INFO_UNREAD_INT: pCount->nUnreadCnt = value; break; - case MSG_COUNT_INFO_SMS_INT: + case MSG_COUNT_INFO_SMS_INT: pCount->nSms = value; break; - case MSG_COUNT_INFO_MMS_INT: + case MSG_COUNT_INFO_MMS_INT: pCount->nMms = value; break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } int msg_thread_count_set_int(void *count_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!count_info) return MSG_ERR_NULL_POINTER; - MSG_THREAD_COUNT_INFO_S *pCount = (MSG_THREAD_COUNT_INFO_S *)count_info; - switch(field) - { - case MSG_THREAD_COUNT_TOTAL_INT: + MSG_THREAD_COUNT_INFO_S *pCount = (MSG_THREAD_COUNT_INFO_S *)count_info; + switch(field) + { + case MSG_THREAD_COUNT_TOTAL_INT: pCount->totalCount = value; break; - case MSG_THREAD_COUNT_UNREAD_INT: + case MSG_THREAD_COUNT_UNREAD_INT: pCount->unReadCount = value; break; - case MSG_THREAD_COUNT_SMS_INT: + case MSG_THREAD_COUNT_SMS_INT: pCount->smsMsgCount = value; break; - case MSG_THREAD_COUNT_MMS_INT: + case MSG_THREAD_COUNT_MMS_INT: pCount->mmsMsgCount = value; break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } int msg_thread_index_set_int(void *index_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!index_info) return MSG_ERR_NULL_POINTER; - MSG_THREAD_LIST_INDEX_S *pIndex = (MSG_THREAD_LIST_INDEX_S *)index_info; - switch(field) - { - case MSG_THREAD_LIST_INDEX_CONTACTID_INT: + MSG_THREAD_LIST_INDEX_S *pIndex = (MSG_THREAD_LIST_INDEX_S *)index_info; + switch(field) + { + case MSG_THREAD_LIST_INDEX_CONTACTID_INT: pIndex->contactId = value; break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } int msg_sortrule_set_int(void *sort_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!sort_info) return MSG_ERR_NULL_POINTER; - MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_info; - switch(field) - { - case MSG_SORT_RULE_SORT_TYPE_INT: + MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_info; + switch(field) + { + case MSG_SORT_RULE_SORT_TYPE_INT: pSort->sortType = value; break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } int msg_folder_info_set_int(void *folder_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!folder_info) return MSG_ERR_NULL_POINTER; - MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info; - switch(field) - { - case MSG_FOLDER_INFO_ID_INT: - pFolder->folderId = value; - break; - case MSG_FOLDER_INFO_TYPE_INT: - pFolder->folderType = value; - break; - default: - err = MSG_ERR_UNKNOWN; - break; - } - - 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; + MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info; switch(field) { - case MSG_SEARCH_CONDITION_FOLDERID_INT: - pCond->folderId = value; - break; - case MSG_SEARCH_CONDITION_MSGTYPE_INT: - pCond->msgType = value; + case MSG_FOLDER_INFO_ID_INT: + pFolder->folderId = value; break; - case MSG_SEARCH_CONDITION_RESERVED_INT: - pCond->reserved = value; + case MSG_FOLDER_INFO_TYPE_INT: + pFolder->folderType = value; break; default: err = MSG_ERR_UNKNOWN; @@ -2557,7 +2638,7 @@ 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) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!condition_info) return MSG_ERR_NULL_POINTER; @@ -2602,81 +2683,54 @@ int msg_list_condition_set_int(void *condition_info, int field, int value) int msg_report_status_set_int(void *report_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + 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; + case MSG_REPORT_TYPE_INT: + pReport->type = value; break; - case MSG_REPORT_STATUS_INT: - pReport->status = value; + case MSG_REPORT_STATUS_INT: + pReport->status = value; break; - case MSG_REPORT_TIME_INT: - pReport->statusTime = value; + case MSG_REPORT_TIME_INT: + pReport->statusTime = value; break; - - default: + default: err = MSG_ERR_UNKNOWN; break; } - return err; } int msg_folder_info_set_str(void *folder_info, int field, char *value, int size) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!folder_info || !value) return MSG_ERR_NULL_POINTER; - MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info; - int _len = 0; - (size > MAX_FOLDER_NAME_SIZE)? _len = MAX_FOLDER_NAME_SIZE : _len = size; - switch(field) - { - case MSG_FOLDER_INFO_NAME_STR: - strncpy(pFolder->folderName, value, _len); - break; - default: - err = MSG_ERR_UNKNOWN; - break; - } - - return err; -} - -int msg_search_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_SEARCH_CONDITION_S *search_cond = (MSG_SEARCH_CONDITION_S *)condition_info; - + MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info; + int _len = 0; + (size > MAX_FOLDER_NAME_SIZE)? _len = MAX_FOLDER_NAME_SIZE : _len = size; switch(field) { - 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; + case MSG_FOLDER_INFO_NAME_STR: + strncpy(pFolder->folderName, value, _len); break; default: err = MSG_ERR_UNKNOWN; break; } + return err; } int msg_list_condition_set_str(void *condition_info, int field, char *value, int size) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!condition_info || !value) return MSG_ERR_NULL_POINTER; @@ -2702,32 +2756,32 @@ int msg_list_condition_set_str(void *condition_info, int field, char *value, int int msg_sendopt_set_bool(void *send_opt, int field, bool value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!send_opt) return MSG_ERR_NULL_POINTER; - MSG_SENDINGOPT_S *sendopt = (MSG_SENDINGOPT_S *)send_opt; - switch(field) - { - case MSG_SEND_OPT_SETTING_BOOL: + MSG_SENDINGOPT_S *sendopt = (MSG_SENDINGOPT_S *)send_opt; + switch(field) + { + case MSG_SEND_OPT_SETTING_BOOL: sendopt->bSetting = value; break; - case MSG_SEND_OPT_KEEPCOPY_BOOL: + case MSG_SEND_OPT_KEEPCOPY_BOOL: sendopt->bKeepCopy = value; break; - case MSG_SEND_OPT_DELIVER_REQ_BOOL: + case MSG_SEND_OPT_DELIVER_REQ_BOOL: sendopt->bDeliverReq = value; break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } int msg_sortrule_set_bool(void *sort_rule, int field, bool value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!sort_rule) return MSG_ERR_NULL_POINTER; @@ -2747,7 +2801,7 @@ int msg_sortrule_set_bool(void *sort_rule, int field, bool value) int msg_list_condition_set_bool(void *data, int field, bool value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!data) return MSG_ERR_NULL_POINTER; @@ -2773,7 +2827,7 @@ int msg_list_condition_set_bool(void *data, int field, bool value) int msg_sendopt_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_struct || !value) return MSG_ERR_NULL_POINTER; @@ -2799,7 +2853,7 @@ int msg_sendopt_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struc int msg_syncml_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_struct || !value) return MSG_ERR_NULL_POINTER; @@ -2820,14 +2874,13 @@ int msg_syncml_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct default: err = MSG_ERR_UNKNOWN; break; - } return err; } int msg_thread_index_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_struct || !value) return MSG_ERR_NULL_POINTER; @@ -2844,7 +2897,6 @@ int msg_thread_index_set_struct_handle(msg_struct_s *msg_struct, int field, msg_ default: err = MSG_ERR_UNKNOWN; break; - } return err; } @@ -2852,7 +2904,7 @@ int msg_thread_index_set_struct_handle(msg_struct_s *msg_struct, int field, msg_ int msg_list_condition_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_struct || !value) return MSG_ERR_NULL_POINTER; @@ -2869,7 +2921,6 @@ int msg_list_condition_set_struct_handle(msg_struct_s *msg_struct, int field, ms default: err = MSG_ERR_UNKNOWN; break; - } return err; } @@ -2877,7 +2928,7 @@ int msg_list_condition_set_struct_handle(msg_struct_s *msg_struct, int field, ms int msg_address_info_set_int(void *addrinfo, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!addrinfo) return MSG_ERR_NULL_POINTER; @@ -2895,7 +2946,7 @@ int msg_address_info_set_int(void *addrinfo, int field, int value) break; default: err = MSG_ERR_UNKNOWN; - break; + break; } return err; @@ -2904,7 +2955,7 @@ int msg_address_info_set_int(void *addrinfo, int field, int value) int msg_mms_sendopt_set_int(void *opt_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!opt_info) return MSG_ERR_NULL_POINTER; @@ -2922,7 +2973,7 @@ int msg_mms_sendopt_set_int(void *opt_info, int field, int value) break; default: err = MSG_ERR_UNKNOWN; - break; + break; } return err; @@ -2930,7 +2981,7 @@ int msg_mms_sendopt_set_int(void *opt_info, int field, int value) int msg_reject_message_set_int(void *msg_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_info) return MSG_ERR_NULL_POINTER; @@ -2945,7 +2996,7 @@ int msg_reject_message_set_int(void *msg_info, int field, int value) break; default: err = MSG_ERR_UNKNOWN; - break; + break; } return err; @@ -2953,126 +3004,129 @@ int msg_reject_message_set_int(void *msg_info, int field, int value) int msg_address_info_set_str(void *addr_info, int field, char *value, int size) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!addr_info || !value) return MSG_ERR_NULL_POINTER; - MSG_ADDRESS_INFO_S *pAddr = (MSG_ADDRESS_INFO_S *)addr_info; - int _len = 0; - - switch(field) - { - case MSG_ADDRESS_INFO_ADDRESS_VALUE_STR: - (size > MAX_ADDRESS_VAL_LEN)? _len = MAX_ADDRESS_VAL_LEN : _len = size; - memset(pAddr->addressVal, 0x00, sizeof(pAddr->addressVal)); + + MSG_ADDRESS_INFO_S *pAddr = (MSG_ADDRESS_INFO_S *)addr_info; + int _len = 0; + + switch(field) + { + case MSG_ADDRESS_INFO_ADDRESS_VALUE_STR: + (size > MAX_ADDRESS_VAL_LEN)? _len = MAX_ADDRESS_VAL_LEN : _len = size; + memset(pAddr->addressVal, 0x00, sizeof(pAddr->addressVal)); strncpy(pAddr->addressVal, value, _len); break; - case MSG_ADDRESS_INFO_DISPLAYNAME_STR: - (size > MAX_DISPLAY_NAME_LEN)? _len = MAX_DISPLAY_NAME_LEN : _len = size; - memset(pAddr->displayName, 0x00, sizeof(pAddr->displayName)); + case MSG_ADDRESS_INFO_DISPLAYNAME_STR: + (size > MAX_DISPLAY_NAME_LEN)? _len = MAX_DISPLAY_NAME_LEN : _len = size; + memset(pAddr->displayName, 0x00, sizeof(pAddr->displayName)); strncpy(pAddr->displayName, value, _len); break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } int msg_media_info_set_str(void *media_info, int field, char *value, int size) { - msg_error_t err = MSG_SUCCESS; + 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; + 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)); + 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: + 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; + msg_error_t err = MSG_SUCCESS; if(!msg_info || !value) return MSG_ERR_NULL_POINTER; - MSG_REJECT_MSG_INFO_S *pMsg = (MSG_REJECT_MSG_INFO_S *)msg_info; - int _len = 0; - (size > MAX_MSG_TEXT_LEN)? _len = MAX_MSG_TEXT_LEN : _len = size; - switch(field) - { - case MSG_REJECT_MESSAGE_MSGTEXT_STR: + + MSG_REJECT_MSG_INFO_S *pMsg = (MSG_REJECT_MSG_INFO_S *)msg_info; + int _len = 0; + (size > MAX_MSG_TEXT_LEN)? _len = MAX_MSG_TEXT_LEN : _len = size; + switch(field) + { + case MSG_REJECT_MESSAGE_MSGTEXT_STR: strncpy(pMsg->msgText, value, _len); break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } int msg_mms_sendopt_set_bool(void *option, int field, bool value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!option) return MSG_ERR_NULL_POINTER; - MMS_SENDINGOPT_S *pOpt = (MMS_SENDINGOPT_S *)option; - switch(field) - { - case MSG_MMS_SENDOPTION_READ_REQUEST_BOOL: + MMS_SENDINGOPT_S *pOpt = (MMS_SENDINGOPT_S *)option; + switch(field) + { + case MSG_MMS_SENDOPTION_READ_REQUEST_BOOL: pOpt->bReadReq = value; break; - case MSG_MMS_SENDOPTION_DELIVERY_CUSTOMTIME_BOOL: + case MSG_MMS_SENDOPTION_DELIVERY_CUSTOMTIME_BOOL: pOpt->bUseDeliveryCustomTime = value; break; - default: + default: err = MSG_ERR_UNKNOWN; break; - } + } return err; } int msg_sms_sendopt_set_bool(void *option, int field, bool value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!option) return MSG_ERR_NULL_POINTER; - SMS_SENDINGOPT_S *pOpt = (SMS_SENDINGOPT_S *)option; - switch(field) - { - case MSG_SMS_SENDOPT_REPLYPATH_BOOL: + SMS_SENDINGOPT_S *pOpt = (SMS_SENDINGOPT_S *)option; + switch(field) + { + case MSG_SMS_SENDOPT_REPLYPATH_BOOL: pOpt->bReplyPath = value; break; - default: - err = MSG_ERR_UNKNOWN; + default: + 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -3085,6 +3139,7 @@ EXPORT_API int msg_add_push_event(msg_handle_t handle, const msg_struct_t push_e MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pPush = (msg_struct_s *)push_event; + MSG_TYPE_CHECK(pPush->type, MSG_STRUCT_PUSH_CONFIG_INFO); try { @@ -3101,13 +3156,13 @@ EXPORT_API int msg_add_push_event(msg_handle_t handle, const msg_struct_t push_e 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -3120,6 +3175,7 @@ EXPORT_API int msg_delete_push_event(msg_handle_t handle, const msg_struct_t pus MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pPush = (msg_struct_s *)push_event; + MSG_TYPE_CHECK(pPush->type, MSG_STRUCT_PUSH_CONFIG_INFO); try { @@ -3136,13 +3192,13 @@ EXPORT_API int msg_delete_push_event(msg_handle_t handle, const msg_struct_t pus 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -3155,7 +3211,10 @@ EXPORT_API int msg_update_push_event(msg_handle_t handle, const msg_struct_t src MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pSrc = (msg_struct_s *)src_event; + MSG_TYPE_CHECK(pSrc->type, MSG_STRUCT_PUSH_CONFIG_INFO); + msg_struct_s *pDst = (msg_struct_s *)dst_event; + MSG_TYPE_CHECK(pDst->type, MSG_STRUCT_PUSH_CONFIG_INFO); try { @@ -3170,114 +3229,119 @@ EXPORT_API int msg_update_push_event(msg_handle_t handle, const msg_struct_t src return err; } -char* msg_push_config_get_str(void *event_info, int field, int size) +int msg_push_config_get_str(void *event_info, int field, char *value, 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; + case MSG_PUSH_CONFIG_CONTENT_TYPE_STR: + strncpy(value, pEvent->contentType, size); break; - case MSG_PUSH_CONFIG_APPLICATON_ID_STR: - result = pEvent->appId; + case MSG_PUSH_CONFIG_APPLICATON_ID_STR: + strncpy(value, pEvent->appId, size); break; - case MSG_PUSH_CONFIG_PACKAGE_NAME_STR: - result = pEvent->pkgName; + case MSG_PUSH_CONFIG_PACKAGE_NAME_STR: + strncpy(value, pEvent->pkgName, size); break; default: - result = NULL; - break; + return MSG_ERR_INVALID_PARAMETER; } - return result; + + return MSG_SUCCESS; } -bool msg_push_config_get_bool(void *event_info, int field) +int msg_push_config_get_bool(void *event_info, int field, bool *value) { - bool result = false; + if (!event_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_PUSH_EVENT_INFO_S *pEvent = (MSG_PUSH_EVENT_INFO_S *)event_info; + switch(field) { - case MSG_PUSH_CONFIG_LAUNCH_BOOL: - result = pEvent->bLaunch; + case MSG_PUSH_CONFIG_LAUNCH_BOOL: + *value = pEvent->bLaunch; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + return ret; } int msg_push_config_set_str(void *event_info, int field, char *value, int size) { - msg_error_t err = MSG_SUCCESS; + 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; + 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; + 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; + 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; + 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; + 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; + switch(field) + { + case MSG_PUSH_CONFIG_LAUNCH_BOOL: + pEvent->bLaunch = value; break; - default: - err = MSG_ERR_UNKNOWN; + default: + err = MSG_ERR_UNKNOWN; break; - } + } return err; } -char* msg_media_item_get_str(void *data, int field, int size) +int msg_media_item_get_str(void *data, int field, char *value, 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; + strncpy(value, pMedia->media_item, size); break; case MSG_MEDIA_MIME_TYPE_STR: - result = pMedia->mime_type; + strncpy(value, pMedia->mime_type, size); break; case MSG_MEDIA_THUMB_PATH_STR: - result = pMedia->thumb_path; + strncpy(value, pMedia->thumb_path, size); break; default: - result = NULL; - break; + return MSG_ERR_INVALID_PARAMETER; } - return result; + + return MSG_SUCCESS; } int msg_media_item_get_int(void *data, int field, int *value) @@ -3290,12 +3354,12 @@ int msg_media_item_get_int(void *data, int field, int *value) 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; + 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 4a322ca..c36a3ad 100755 --- a/mapi/msg_svc.cpp +++ b/mapi/msg_svc.cpp @@ -26,12 +26,6 @@ #include "msg_private.h" #include "msg.h" -#define MSG_TYPE_CHECK(a, b) \ - ({\ - if(a != (b & 0xff00)) return MSG_ERR_INVALID_PARAMETER; \ - })\ - - void __msg_release_list_item(gpointer data) { if (data == NULL) @@ -43,7 +37,7 @@ void __msg_release_list_item(gpointer data) EXPORT_API msg_struct_t msg_create_struct(int field) { - CHECK_MSG_SUPPORTED_RETURN_NULL(MSG_TELEPHONY_FEATURE); + CHECK_MSG_SUPPORTED_RETURN_NULL(MSG_TELEPHONY_SMS_FEATURE); msg_struct_s *msg_struct = new msg_struct_s; memset(msg_struct, 0x00, sizeof(msg_struct_s)); @@ -147,12 +141,6 @@ EXPORT_API msg_struct_t msg_create_struct(int field) memset(msg_struct->data, 0x00, sizeof(MSG_FOLDER_INFO_S)); break; } - case MSG_STRUCT_SEARCH_CONDITION: - { - msg_struct->data = new MSG_SEARCH_CONDITION_S; - 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; @@ -175,28 +163,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; - pTmp->simIndex = MSG_SIM_SLOT_ID_1; // default sim index + 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 *)calloc(SMSC_LIST_MAX, sizeof(msg_struct_t)); + 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 : @@ -207,28 +197,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_CBMSG_OPT_HIDDEN_S *pTmp = (MSG_CBMSG_OPT_HIDDEN_S *)msg_struct->data; - pTmp->simIndex = MSG_SIM_SLOT_ID_1; // default sim index + msg_struct->data = new MSG_CBMSG_OPT_HIDDEN_S; + memset(msg_struct->data, 0x00, sizeof(MSG_CBMSG_OPT_HIDDEN_S)); - pTmp->channelData = (msg_struct_list_s *)new msg_struct_list_s; - memset(pTmp->channelData, 0x00, sizeof(msg_struct_list_s)); + MSG_CBMSG_OPT_HIDDEN_S *pTmp = (MSG_CBMSG_OPT_HIDDEN_S *)msg_struct->data; + pTmp->simIndex = MSG_SIM_SLOT_ID_1; // default sim index - pTmp->channelData->msg_struct_info = (msg_struct_t *)calloc(CB_CHANNEL_MAX, sizeof(msg_struct_t)); + pTmp->channelData = (msg_struct_list_s *)new msg_struct_list_s; + memset(pTmp->channelData, 0x00, sizeof(msg_struct_list_s)); - msg_struct_s *pStructTmp = NULL; + pTmp->channelData->msg_struct_info = (msg_struct_t *)calloc(CB_CHANNEL_MAX, sizeof(msg_struct_t)); - 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; + if (pTmp->channelData->msg_struct_info != NULL) { + msg_struct_s *pStructTmp = NULL; - 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 : @@ -239,8 +230,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 : @@ -499,16 +490,6 @@ static int _release_msg_struct(msg_struct_t *msg_struct_handle) break; } - case MSG_STRUCT_SEARCH_CONDITION: - { - delete (MSG_SEARCH_CONDITION_S*)(msg_struct->data); - msg_struct->data = NULL; - - delete msg_struct; - *msg_struct_handle = NULL; - - break; - } case MSG_STRUCT_MSG_LIST_CONDITION: { MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S*)(msg_struct->data); @@ -766,7 +747,7 @@ static int _release_msg_struct(msg_struct_t *msg_struct_handle) EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); int ret = _release_msg_struct(msg_struct_handle); @@ -778,7 +759,7 @@ EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle) EXPORT_API int msg_release_list_struct(msg_struct_list_s *msg_struct_list) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_list == NULL) @@ -787,24 +768,12 @@ EXPORT_API int msg_release_list_struct(msg_struct_list_s *msg_struct_list) if (msg_struct_list->msg_struct_info == NULL) { if (msg_struct_list->nCount > 0) msg_struct_list->nCount = 0; - return err; + return MSG_ERR_NULL_POINTER; } if(msg_struct_list->nCount > 0) { - 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])); } @@ -824,11 +793,10 @@ EXPORT_API int msg_release_list_struct(msg_struct_list_s *msg_struct_list) EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int *value) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); - + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; - if (msg_struct_handle == NULL) + if (msg_struct_handle == NULL || value == NULL) return MSG_ERR_NULL_POINTER; msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; @@ -843,58 +811,55 @@ EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int err = msg_message_get_int_value(msg_struct->data, field, value); break; case MSG_STRUCT_FILTER: - *value = msg_get_filter_info_int(msg_struct->data, field); + err = msg_get_filter_info_int(msg_struct->data, field, value); break; case MSG_STRUCT_SYNCML_INFO : - *value = msg_syncml_info_get_int(msg_struct->data, field); + err = msg_syncml_info_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_COUNT_INFO : - *value = msg_count_info_get_int(msg_struct->data, field); + err = msg_count_info_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_THREAD_COUNT_INFO : - *value = msg_thread_count_get_int(msg_struct->data, field); + err = msg_thread_count_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_THREAD_LIST_INDEX : - *value = msg_thread_index_get_int(msg_struct->data, field); + err = msg_thread_index_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_SORT_RULE : - *value = msg_sortrule_get_int(msg_struct->data, field); + err = msg_sortrule_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_FOLDER_INFO : - *value = msg_folder_info_get_int(msg_struct->data, field); + err = msg_folder_info_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_THREAD_INFO : - *value = msg_thread_info_get_int(msg_struct->data, field); + err = msg_thread_info_get_int(msg_struct->data, field, value); 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); + err = msg_conv_info_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_MSG_LIST_CONDITION : - *value = msg_list_condition_get_int(msg_struct->data, field); + err = msg_list_condition_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_REPORT_STATUS_INFO : - *value = msg_report_status_get_int(msg_struct->data, field); + err = msg_report_status_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_ADDRESS_INFO : - *value = msg_address_info_get_int(msg_struct->data, field); + err = msg_address_info_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_MMS_SENDOPT : - *value = msg_mms_sendopt_get_int(msg_struct->data, field); + err = msg_mms_sendopt_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_REJECT_MSG_INFO : - *value = msg_reject_message_get_int(msg_struct->data, field); + err = msg_reject_message_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_REQUEST_INFO : - *value = msg_request_get_int(msg_struct->data, field); + err = msg_request_get_int(msg_struct->data, field, value); break; case MSG_STRUCT_SENT_STATUS_INFO : - *value = msg_sent_status_get_int((MSG_SENT_STATUS_S *)msg_struct->data, field); + err = msg_sent_status_get_int((MSG_SENT_STATUS_S *)msg_struct->data, field, value); break; case MSG_STRUCT_CB_MSG : - err = msg_cb_message_get_int_value (msg_struct->data, field, value); + err = msg_cb_message_get_int_value(msg_struct->data, field, value); break; case MSG_STRUCT_MMS: case MSG_STRUCT_MMS_PAGE: @@ -932,90 +897,52 @@ EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int return err; } -EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char *src, int size) +EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char *value, int size) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; - if (msg_struct_handle == NULL) + if (msg_struct_handle == NULL || value == NULL) return MSG_ERR_NULL_POINTER; + if (size < 0) + return MSG_ERR_INVALID_PARAMETER; + msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; if (msg_struct->data == NULL) return MSG_ERR_NULL_POINTER; - char *ret_str = NULL; - switch (msg_struct->type) { case MSG_STRUCT_MESSAGE_INFO : - err = msg_message_get_str_value(msg_struct->data, field, src, size); + err = msg_message_get_str_value(msg_struct->data, field, value, size); break; case MSG_STRUCT_FILTER: - ret_str = msg_get_filter_info_str(msg_struct->data, field); - if (ret_str == NULL) - err = MSG_ERR_UNKNOWN; - else - strncpy(src, ret_str, size); + err = msg_get_filter_info_str(msg_struct->data, field, value, size); break; case MSG_STRUCT_FOLDER_INFO : - ret_str = msg_folder_info_get_str(msg_struct->data, field); - if (ret_str == NULL) - err = MSG_ERR_UNKNOWN; - else - strncpy(src, ret_str, size); + err = msg_folder_info_get_str(msg_struct->data, field, value, size); break; case MSG_STRUCT_THREAD_INFO : - ret_str = msg_thread_info_get_str(msg_struct->data, field); - if (ret_str == NULL) - err = MSG_ERR_UNKNOWN; - else - strncpy(src, ret_str, size); + err = msg_thread_info_get_str(msg_struct->data, field, value, 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) - err = MSG_ERR_UNKNOWN; - else - strncpy(src, ret_str, size); + err = msg_conv_info_get_str(msg_struct->data, field, value, 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); + err = msg_list_condition_get_str(msg_struct->data, field, value, size); break; case MSG_STRUCT_ADDRESS_INFO : - ret_str = msg_address_info_get_str(msg_struct->data, field, size); - if (ret_str == NULL) - err = MSG_ERR_UNKNOWN; - else - strncpy(src, ret_str, size); + err = msg_address_info_get_str(msg_struct->data, field, value, size); break; case MSG_STRUCT_REJECT_MSG_INFO : - ret_str = msg_reject_message_get_str(msg_struct->data, field, size); - if (ret_str == NULL) - err = MSG_ERR_UNKNOWN; - else - strncpy(src, ret_str, size); + err = msg_reject_message_get_str(msg_struct->data, field, value, 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); + err = msg_media_item_get_str(msg_struct->data, field, value, size); break; case MSG_STRUCT_MMS: case MSG_STRUCT_MMS_PAGE: @@ -1027,30 +954,22 @@ EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char 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); + err = msg_mms_get_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_get_str_value(msg_struct, field, src, size); + err = msg_setting_get_str_value(msg_struct, field, value, 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); + err = msg_push_config_get_str(msg_struct->data, field, value, 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); + err = msg_report_status_get_str(msg_struct->data, field, value, size); break; case MSG_STRUCT_CB_MSG : - err = msg_cb_message_get_str_value(msg_struct->data, field, src, size); + err = msg_cb_message_get_str_value(msg_struct->data, field, value, size); break; default : err = MSG_ERR_INVALID_PARAMETER; @@ -1062,10 +981,10 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; - if (msg_struct_handle == NULL) + if (msg_struct_handle == NULL || value == NULL) return MSG_ERR_NULL_POINTER; msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; @@ -1076,31 +995,31 @@ 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); + err = msg_get_filter_info_bool(msg_struct->data, field, value); 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); + err = msg_thread_info_get_bool(msg_struct->data, field, value); break; case MSG_STRUCT_CONV_INFO: - *value = msg_conv_get_bool(msg_struct->data, field); + err = msg_conv_get_bool(msg_struct->data, field, value); break; case MSG_STRUCT_SENDOPT: - *value = msg_sendopt_get_bool(msg_struct->data, field); + err = msg_sendopt_get_bool(msg_struct->data, field, value); break; case MSG_STRUCT_SORT_RULE: - *value = msg_sortrule_get_bool(msg_struct->data, field); + err = msg_sortrule_get_bool(msg_struct->data, field, value); break; case MSG_STRUCT_MSG_LIST_CONDITION: - *value = msg_list_condition_get_bool(msg_struct->data, field); + err = msg_list_condition_get_bool(msg_struct->data, field, value); break; case MSG_STRUCT_MMS_SENDOPT: - *value = msg_mms_sendopt_get_bool(msg_struct->data, field); + err = msg_mms_sendopt_get_bool(msg_struct->data, field, value); break; case MSG_STRUCT_SMS_SENDOPT: - *value = msg_sms_sendopt_get_bool(msg_struct->data, field); + err = msg_sms_sendopt_get_bool(msg_struct->data, field, value); break; case MSG_STRUCT_MMS: case MSG_STRUCT_MMS_PAGE: @@ -1122,6 +1041,9 @@ EXPORT_API int msg_get_bool_value(msg_struct_t msg_struct_handle, int field, boo case MSG_STRUCT_SETTING_GENERAL_OPT : err = msg_setting_get_bool_value(msg_struct, field, value); break; + case MSG_STRUCT_PUSH_CONFIG_INFO: + err = msg_push_config_get_bool(msg_struct->data, field, value); + break; default : err = MSG_ERR_INVALID_PARAMETER; break; @@ -1132,10 +1054,10 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; - if (msg_struct_handle == NULL) + if (msg_struct_handle == NULL || value == NULL) return MSG_ERR_NULL_POINTER; msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; @@ -1176,10 +1098,10 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; - if (msg_struct_handle == NULL) + if (msg_struct_handle == NULL || value == NULL) return MSG_ERR_NULL_POINTER; msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; @@ -1213,7 +1135,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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -1250,9 +1172,6 @@ EXPORT_API int msg_set_int_value(msg_struct_t msg_struct_handle, int field, int case MSG_STRUCT_FOLDER_INFO : err = msg_folder_info_set_int(msg_struct->data, field, value); break; - 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; @@ -1305,12 +1224,15 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; - if (msg_struct_handle == NULL) + if (msg_struct_handle == NULL || value == NULL) return MSG_ERR_NULL_POINTER; + if (size < 0) + return MSG_ERR_INVALID_PARAMETER; + msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; if (msg_struct->data == NULL) @@ -1327,9 +1249,6 @@ EXPORT_API int msg_set_str_value(msg_struct_t msg_struct_handle, int field, char case MSG_STRUCT_FOLDER_INFO : err = msg_folder_info_set_str(msg_struct->data, field, value, size); break; - 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; @@ -1373,7 +1292,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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; if (msg_struct_handle == NULL) @@ -1440,10 +1359,10 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; - if (msg_struct_handle == NULL) + if (msg_struct_handle == NULL || value == NULL) return MSG_ERR_NULL_POINTER; msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; @@ -1484,10 +1403,10 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; - if (msg_struct_handle == NULL) + if (msg_struct_handle == NULL || value == NULL) return MSG_ERR_NULL_POINTER; msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle; @@ -1509,7 +1428,7 @@ EXPORT_API int msg_set_list_handle(msg_struct_t msg_struct_handle, int field, vo EXPORT_API int msg_list_add_item(msg_struct_t msg_struct_handle, int field, msg_struct_t *item) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); if (msg_struct_handle == NULL || item == NULL) { return MSG_ERR_NULL_POINTER; } @@ -1539,7 +1458,7 @@ EXPORT_API int msg_list_add_item(msg_struct_t msg_struct_handle, int field, msg_ EXPORT_API msg_struct_t msg_list_nth_data(msg_list_handle_t list_handle, int index) { - CHECK_MSG_SUPPORTED_RETURN_NULL(MSG_TELEPHONY_FEATURE); + CHECK_MSG_SUPPORTED_RETURN_NULL(MSG_TELEPHONY_SMS_FEATURE); if (list_handle == NULL) { return NULL; } @@ -1549,7 +1468,7 @@ EXPORT_API msg_struct_t msg_list_nth_data(msg_list_handle_t list_handle, int ind EXPORT_API int msg_list_length(msg_list_handle_t list_handle) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); if (list_handle == NULL) { return 0; } @@ -1559,7 +1478,7 @@ EXPORT_API int msg_list_length(msg_list_handle_t list_handle) EXPORT_API int msg_list_clear(msg_struct_t msg_struct_handle, int field) { - CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); if (msg_struct_handle == NULL) { return MSG_ERR_NULL_POINTER; } @@ -1587,15 +1506,35 @@ EXPORT_API int msg_list_clear(msg_struct_t msg_struct_handle, int field) return err; } +EXPORT_API int msg_list_free(msg_list_handle_t list_handle) +{ + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE); msg_error_t err = MSG_SUCCESS; - if (msg_text == NULL || text_size == NULL || segment_size == NULL) { - err = MSG_ERR_INVALID_PARAMETER; - return err; + if (msg_text == NULL || text_size == NULL || segment_size == NULL || msg_encode_type_in == NULL) { + return MSG_ERR_INVALID_PARAMETER; + } +#ifdef FEATURE_SMS_CDMA + if (msg_encode_type_to > MSG_ENCODE_ASCII7BIT) { +#else + if (msg_encode_type_to > MSG_ENCODE_GSM7BIT_ABNORMAL) { +#endif + MSG_FATAL("unsupported msg_encode_type [%d]", msg_encode_type_to); + return MSG_ERR_INVALID_PARAMETER; } msg_encode_type_t encodeType = MSG_ENCODE_AUTO; diff --git a/mapi/msg_transport.cpp b/mapi/msg_transport.cpp index c77b6fe..27af80f 100755 --- a/mapi/msg_transport.cpp +++ b/mapi/msg_transport.cpp @@ -32,18 +32,18 @@ ==================================================================================================*/ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL ||req == NULL) + if (handle == NULL || req == NULL) { return MSG_ERR_INVALID_PARAMETER; } @@ -51,6 +51,7 @@ EXPORT_API int msg_submit_req(msg_handle_t handle, msg_struct_t req) MsgHandle* pHandle = (MsgHandle*)handle; msg_struct_s *pStruct = (msg_struct_s *)req; + MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_REQUEST_INFO); try { @@ -68,13 +69,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -105,13 +106,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -143,12 +144,12 @@ 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -184,13 +185,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -221,13 +222,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -258,13 +259,13 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -295,13 +296,13 @@ EXPORT_API int msg_reg_syncml_message_operation_callback(msg_handle_t handle, m 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -336,13 +337,13 @@ EXPORT_API int msg_reg_push_message_callback(msg_handle_t handle, msg_push_msg_ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -373,13 +374,13 @@ EXPORT_API int msg_reg_cb_message_callback(msg_handle_t handle, msg_cb_incoming_ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -408,15 +409,15 @@ EXPORT_API int msg_reg_report_message_callback(msg_handle_t handle, msg_report_m } -EXPORT_API int msg_syncml_message_operation(msg_handle_t handle, msg_message_id_t msgId) +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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -518,12 +519,17 @@ static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_ addr_list.nCount = 1; addr_list.msg_struct_info = (msg_struct_t *)calloc(1, sizeof(msg_struct_t)); - 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; + 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_info.addr_list = (msg_struct_list_s *)&addr_list; @@ -585,11 +591,11 @@ 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); + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -602,13 +608,14 @@ EXPORT_API int msg_sms_send(const char *phone_num_list, const char *sms_text, ms 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) { @@ -630,28 +637,32 @@ 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; + CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL || !req) { + if (handle == NULL || req == NULL) + { MSG_FATAL("handle or req is NULL"); - return MSG_ERR_NULL_POINTER; + return MSG_ERR_INVALID_PARAMETER; } msg_struct_s *req_s = (msg_struct_s *)req; + MSG_TYPE_CHECK(req_s->type, MSG_STRUCT_REQUEST_INFO); + MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data; pReq->reqId = 1; msg_struct_s *msg_s = (msg_struct_s *)pReq->msg; + MSG_TYPE_CHECK(msg_s->type, MSG_STRUCT_MESSAGE_INFO); MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data; @@ -661,13 +672,13 @@ EXPORT_API int msg_sms_send_message(msg_handle_t handle, msg_struct_t req) } if (reqmsg->mainType != MSG_SMS_TYPE) { - MSG_DEBUG("mainType is not SMS [%d]", reqmsg->mainType); - reqmsg->mainType = MSG_SMS_TYPE; + MSG_FATAL("mainType is not SMS [%d]", reqmsg->mainType); + return MSG_ERR_INVALID_PARAMETER; } if (reqmsg->subType > MSG_CONCAT_SIM_SMS) { - MSG_DEBUG("subType is not SMS [%d]", reqmsg->subType); - reqmsg->subType = MSG_NORMAL_SMS; + MSG_FATAL("subType is not SMS [%d]", reqmsg->subType); + return MSG_ERR_INVALID_PARAMETER; } reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed @@ -689,28 +700,31 @@ 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL || !req) + if (handle == NULL || req == NULL) { MSG_FATAL("handle or req is NULL"); return MSG_ERR_INVALID_PARAMETER; } msg_struct_s *req_s = (msg_struct_s *)req; + MSG_TYPE_CHECK(req_s->type, MSG_STRUCT_REQUEST_INFO); + MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data; pReq->reqId = 1; msg_struct_s *msg_s = (msg_struct_s *)pReq->msg; + MSG_TYPE_CHECK(msg_s->type, MSG_STRUCT_MESSAGE_INFO); MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data; @@ -744,7 +758,7 @@ EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t ms //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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } @@ -754,7 +768,15 @@ EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t ms return MSG_ERR_INVALID_PARAMETER; } + if (mms_read_status < MSG_READ_REPORT_NONE || mms_read_status > MSG_READ_REPORT_REJECT_BY_USER) + { + MSG_FATAL("unsupported read report status [%d]", mms_read_status); + return MSG_ERR_INVALID_PARAMETER; + } + 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; @@ -803,28 +825,30 @@ 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; + 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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL || !req ) + if (handle == NULL || req == NULL ) { MSG_FATAL("handle or req is NULL"); return MSG_ERR_INVALID_PARAMETER; } msg_struct_s *req_s = (msg_struct_s *)req; - MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data; + MSG_TYPE_CHECK(req_s->type, MSG_STRUCT_REQUEST_INFO); + MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data; pReq->reqId = 1; msg_struct_s *msg_s = (msg_struct_s *)pReq->msg; + MSG_TYPE_CHECK(msg_s->type, MSG_STRUCT_MESSAGE_INFO); MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data; @@ -852,21 +876,25 @@ EXPORT_API int msg_mms_retrieve_message(msg_handle_t handle, msg_struct_t req) //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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if ( handle == NULL|| !req) + if (handle == NULL || req == NULL) { MSG_FATAL("handle or req is NULL"); return MSG_ERR_INVALID_PARAMETER; } msg_struct_s *req_s = (msg_struct_s *)req; + MSG_TYPE_CHECK(req_s->type, MSG_STRUCT_REQUEST_INFO); + MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data; msg_struct_s *msg_s = (msg_struct_s *)pReq->msg; + MSG_TYPE_CHECK(msg_s->type, MSG_STRUCT_MESSAGE_INFO); + MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data; reqmsg->mainType = MSG_MMS_TYPE; @@ -894,21 +922,25 @@ EXPORT_API int msg_mms_reject_message(msg_handle_t handle, msg_struct_t req) //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) + if (ret != PRIV_MGR_ERROR_SUCCESS) { return MSG_ERR_PERMISSION_DENIED; } - if (handle == NULL || !req ) + if (handle == NULL || req == NULL) { MSG_FATAL("handle or req is NULL"); return MSG_ERR_INVALID_PARAMETER; } msg_struct_s *req_s = (msg_struct_s *)req; + MSG_TYPE_CHECK(req_s->type, MSG_STRUCT_REQUEST_INFO); + MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data; msg_struct_s *msg_s = (msg_struct_s *)pReq->msg; + MSG_TYPE_CHECK(msg_s->type, MSG_STRUCT_MESSAGE_INFO); + MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data; reqmsg->mainType = MSG_MMS_TYPE; @@ -928,26 +960,33 @@ EXPORT_API int msg_mms_reject_message(msg_handle_t handle, msg_struct_t req) /* reject_msg_support */ -int msg_request_get_int(void *request_info, int field) +int msg_request_get_int(void *request_info, int field, int *value) { - int result = -1; + if (!request_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; + MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)request_info; + switch(field) { case MSG_REQUEST_REQUESTID_INT: - result = pRequest->reqId; + *value = pRequest->reqId; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } int msg_request_get_struct_handle(msg_struct_s *msg_struct, int field, void **value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_struct || !value) return MSG_ERR_NULL_POINTER; @@ -971,7 +1010,7 @@ int msg_request_get_struct_handle(msg_struct_s *msg_struct, int field, void **va int msg_request_set_int(void *request_info, int field, int value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!request_info) return MSG_ERR_NULL_POINTER; @@ -983,7 +1022,7 @@ int msg_request_set_int(void *request_info, int field, int value) break; default: err = MSG_ERR_UNKNOWN; - break; + break; } return err; @@ -991,7 +1030,7 @@ int msg_request_set_int(void *request_info, int field, int value) int msg_request_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; if(!msg_struct || !value) return MSG_ERR_NULL_POINTER; @@ -1040,20 +1079,25 @@ int msg_request_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struc } -int msg_sent_status_get_int(MSG_SENT_STATUS_S *sent_status_info, int field) +int msg_sent_status_get_int(MSG_SENT_STATUS_S *sent_status_info, int field, int *value) { - int result = -1; + if (!sent_status_info) + return MSG_ERR_NULL_POINTER; + + int ret = MSG_SUCCESS; switch(field) { case MSG_SENT_STATUS_REQUESTID_INT: - result = sent_status_info->reqId; + *value = sent_status_info->reqId; break; case MSG_SENT_STATUS_NETWORK_STATUS_INT: - result = sent_status_info->status; + *value = sent_status_info->status; break; default: + ret = MSG_ERR_INVALID_PARAMETER; break; } - return result; + + return ret; } diff --git a/msg-service.rule b/msg-service.rule index 69a6c9c..e25824a 100755 --- a/msg-service.rule +++ b/msg-service.rule @@ -1,10 +1,8 @@ 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 system::media r-x--- ------ +msg-service telephony_framework::api_network rw---- ------ msg-service telephony_framework::api_sms rwx--- ------ msg-service telephony_framework::api_sim rw---- ------ msg-service telephony_framework::api_sat --x--- ------ @@ -12,16 +10,13 @@ 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 rwx--- ------ +msg-service contacts-service::svc r----l ------ 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---- ------ @@ -30,14 +25,16 @@ msg-service connman::set rw---- ------ msg-service connman::profile rw---- ------ msg-service aul::launch --x--- ------ msg-service alarm-server::alarm rw---- ------ -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 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 rw---- ------ +msg-service device::sys_logging rw---- ------ +msg-service system::share rwx--- ------ +msg-service pkgmgr::db rw---l ------ +msg-service badge::db rw---l ------ +msg-service notification::db rw---l ------ +msg-service org.tizen.setting::default-resources r-x--l ------ net-config msg-service rw---- ------ connman msg-service rw---- ------ @@ -45,3 +42,14 @@ 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--- ------ +media-server msg-service r-x--- ------ + +msg-service tizen::vconf::camcorder r----l ------ +msg-service tizen::vconf::message rw---- ------ +msg-service tizen::vconf::public::r r----l ------ +msg-service tizen::vconf::platform::r r----l ------ +msg-service tizen::vconf::platform::rw rw---- ------ +msg-service tizen::vconf::public::r::platform::rw rw---- ------ +msg-service tizen::vconf::setting::admin r----l ------ +msg-service tizen::vconf::setting r----l ------ +msg-service tizen::vconf::telephony::admin r----l ------ diff --git a/packaging/msg-server.service b/packaging/msg-server.service index f21f414..9ea252a 100755 --- a/packaging/msg-server.service +++ b/packaging/msg-server.service @@ -1,7 +1,6 @@ [Unit] Description=Message server -After=tizen-runtime.target contacts-service.service -Requires=tizen-runtime.target contacts-service.service +After=contacts-service.service [Service] User=system diff --git a/packaging/msg-service.spec b/packaging/msg-service.spec index de041e4..59ba34a 100755 --- a/packaging/msg-service.spec +++ b/packaging/msg-service.spec @@ -8,12 +8,11 @@ Source0: %{name}-%{version}.tar.gz Source1: msg-server.service Source2: msg-server.socket -#%if "%{?tizen_profile_name}" == "wearable" -#ExcludeArch: %{arm} %ix86 x86_64 -#%endif +%if "%{?tizen_profile_name}" == "tv" +ExcludeArch: %{arm} %ix86 x86_64 +%endif Requires(post): /usr/bin/sqlite3 -Requires(post): /usr/bin/vconftool Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig Requires(post): systemd @@ -22,10 +21,11 @@ BuildRequires: cmake BuildRequires: pkgconfig(alarm-service) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(badge) +BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-network-connection) BuildRequires: pkgconfig(capi-system-info) -#BuildRequires: pkgconfig(capi-telephony) +BuildRequires: pkgconfig(capi-telephony) BuildRequires: pkgconfig(contacts-service2) BuildRequires: pkgconfig(cynara-client) BuildRequires: pkgconfig(cynara-creds-commons) @@ -34,6 +34,7 @@ BuildRequires: pkgconfig(cynara-session) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(deviced) BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(eventsystem) BuildRequires: pkgconfig(feedback) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(gobject-2.0) @@ -79,7 +80,6 @@ Summary: Messaging server application Requires: %{name} = %{version}-%{release} Group: TO_BU / FILL_IN Requires(post): /usr/bin/sqlite3 -Requires(post): /usr/bin/vconftool Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -120,13 +120,10 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ %else -D_TIZEN_I586_ENABLED:BOOL=OFF \ %endif -%if 0%{?sec_product_feature_container_enable} == 1 --D_FEATURE_CONTAINER_ENABLE:BOOL=ON \ -%endif %if "%{?tizen_profile_name}" == "wearable" --D_MSG_WEARABLE_PROFILE:BOOL=ON +-D_MSG_WEARABLE_PROFILE:BOOL=ON \ %else --D_MSG_WEARABLE_PROFILE:BOOL=OFF +-D_MSG_WEARABLE_PROFILE:BOOL=OFF \ %endif make %{?jobs:-j%jobs} @@ -162,9 +159,25 @@ chown 200:200 %{_libdir}/systemd/system/msg-server.socket chmod 660 /opt/usr/dbspace/.msg_service.db chmod 660 /opt/usr/dbspace/.msg_service.db-journal +mkdir -p -m 775 /opt/usr/data/msg-service +mkdir -p -m 775 /opt/usr/data/msg-service/msgdata +mkdir -p -m 775 /opt/usr/data/msg-service/smildata +mkdir -p -m 775 /opt/usr/data/msg-service/ipcdata +mkdir -p -m 775 /opt/usr/data/msg-service/msgdata/thumbnails + +chown 200:5000 /opt/usr/data/msg-service +chown 200:5000 /opt/usr/data/msg-service/msgdata +chown 200:5000 /opt/usr/data/msg-service/smildata +chown 200:5000 /opt/usr/data/msg-service/ipcdata +chown 200:5000 /opt/usr/data/msg-service/msgdata/thumbnails + if [ -f %{_libdir}/rpm-plugins/msm.so ] then chsmack -a 'msg-service::db' /opt/usr/dbspace/.msg_service.db* + chsmack -a 'msg-service' /opt/usr/data/msg-service/msgdata + chsmack -a 'msg-service' /opt/usr/data/msg-service/smildata + chsmack -a 'msg-service' /opt/usr/data/msg-service/ipcdata + chsmack -a 'msg-service' /opt/usr/data/msg-service/msgdata/thumbnails fi %post -n sms-plugin -p /sbin/ldconfig @@ -173,184 +186,6 @@ fi %post /sbin/ldconfig -mkdir -p /opt/usr/data/msg-service -chgrp db_msg_service /opt/usr/data/msg-service - - -########## Setting Config Value (Internal keys) ########## -# Message Server Status -vconftool set -t bool memory/msg/ready 0 -i -u 200 -g 5000 -s system::vconf_inhouse - -# SMS Send Options -vconftool set -t int db/msg/network_mode 2 -u 200 -g 5000 -s system::vconf_inhouse - -# New Message Count -vconftool set -t int db/msg/recv_sms 0 -u 200 -g 5000 -s system::vconf_inhouse -vconftool set -t int db/msg/recv_mms 0 -u 200 -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 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/general/auto_erase 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/general/block_msg 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/general/contact_sync_time 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/general/alert_rep_type 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/general/search_tags 31 -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t int db/private/msg-service/general/page_limit 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/general/sms_mms_threshold 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/general/max_recipient 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/general/sms_storage 0 -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t bool db/private/msg-service/general/block_unknown_msg 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/general/sms_limit 1000 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/general/mms_limit 100 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/general/notification 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/general/vibration 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/general/preview 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/general/ringtone_type 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string db/private/msg-service/general/ringtone_path "" -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t string db/private/msg-service/general/ua_profile "" -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t int db/private/msg-service/general/msg_id_counter 0 -s msg-service::vconf -u 200 -g 5000 - -# SMS Send Options -vconftool set -t int db/private/msg-service/sms_send/dcs 3 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/sms_send/reply_path 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/sms_send/delivery_report 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/sms_send/save_storage 1 -s msg-service::vconf -u 200 -g 5000 - -# MMS Send Options -vconftool set -t int db/private/msg-service/mms_send/msg_class 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_send/priority 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_send/expiry_time 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_send/custom_delivery 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_send/sender_visibility 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_send/delivery_report 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_send/read_reply 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_send/keep_copy 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_send/body_replying 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_send/hide_recipients 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_send/report_allowed 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_send/reply_charging 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_send/reply_charging_deadline 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_send/reply_charging_size 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_send/delivery_time 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_send/creation_mode 2 -s msg-service::vconf -u 200 -g 5000 - -# MMS Receive Options -vconftool set -t int db/private/msg-service/mms_recv/home_network 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_recv/abroad_network 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_recv/read_receipt 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_recv/delivery_receipt 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_recv/reject_unknown 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_recv/reject_advertisement 0 -s msg-service::vconf -u 200 -g 5000 - -# MMS Style Options -vconftool set -t int db/private/msg-service/mms_style/font_size 30 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_style/font_style/bold 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_style/font_style/italic 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/mms_style/font_style/underline 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/font_color/red 255 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/font_color/green 255 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/font_color/blue 255 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/font_color/hue 255 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/bg_color/red 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/bg_color/green 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/bg_color/blue 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/bg_color/hue 255 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/page_dur 2 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/page_custom_dur 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/mms_style/page_dur_manual 0 -s msg-service::vconf -u 200 -g 5000 - -# Push Msg Options -vconftool set -t bool db/private/msg-service/push_msg/recv_option 1 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/push_msg/service_load 1 -s msg-service::vconf -u 200 -g 5000 - -# CB Msg Options -vconftool set -t bool db/private/msg-service/cb_msg/receive/1 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/receive/2 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/save 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/cb_msg/max_sim_count/1 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/cb_msg/max_sim_count/2 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/cb_msg/max_sim_count/3 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/0 1 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/1 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/2 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/3 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/4 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/5 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/6 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/7 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/8 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool db/private/msg-service/cb_msg/language/9 0 -s msg-service::vconf -u 200 -g 5000 - -# Voice Mail Options -vconftool set -t string db/private/msg-service/voice_mail/voice_mail_number/1 "" -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/voice_mail/voice_mail_count/1 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string db/private/msg-service/voice_mail/voice_mail_alphaid/1 "" -f -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t string db/private/msg-service/voice_mail/voice_mail_number/2 "" -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/voice_mail/voice_mail_count/2 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string db/private/msg-service/voice_mail/voice_mail_alphaid/2 "" -f -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t string db/private/msg-service/voice_mail/voice_mail_number/3 "" -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/voice_mail/voice_mail_count/3 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string db/private/msg-service/voice_mail/voice_mail_alphaid/3 "" -f -s msg-service::vconf -u 200 -g 5000 - -# MMS Size Options -vconftool set -t int db/private/msg-service/size_opt/msg_size 300 -s msg-service::vconf -u 200 -g 5000 - -# SIM message count -vconftool set -t int db/private/msg-service/sim_count/used_cnt/1 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/sim_count/total_cnt/1 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/sim_count/used_cnt/2 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/sim_count/total_cnt/2 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/sim_count/used_cnt/3 0 -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/sim_count/total_cnt/3 0 -f -s msg-service::vconf -u 200 -g 5000 - -# SIM information -vconftool set -t int memory/private/msg-service/sim_changed/1 0 -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string memory/private/msg-service/sim_subs_id/1 "" -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool memory/private/msg-service/national_sim/1 0 -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string memory/private/msg-service/msisdn/1 "" -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string memory/private/msg-service/iccid/1 "" -i -f -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t int memory/private/msg-service/sim_changed/2 0 -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string memory/private/msg-service/sim_subs_id/2 "" -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool memory/private/msg-service/national_sim/2 0 -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string memory/private/msg-service/msisdn/2 "" -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string memory/private/msg-service/iccid/2 "" -i -f -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t int memory/private/msg-service/sim_changed/3 0 -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string memory/private/msg-service/sim_subs_id/3 "" -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool memory/private/msg-service/national_sim/3 0 -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string memory/private/msg-service/msisdn/3 "" -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t string memory/private/msg-service/iccid/3 "" -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int memory/private/msg-service/default_network_sim 0 -i -f -s msg-service::vconf -u 200 -g 5000 - -# SST information -vconftool set -t bool memory/private/msg-service/sim_st/1 1 -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool memory/private/msg-service/sim_mo_ctrl/1 0 -i -f -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t bool memory/private/msg-service/sim_st/2 1 -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool memory/private/msg-service/sim_mo_ctrl/2 0 -i -f -s msg-service::vconf -u 200 -g 5000 - -vconftool set -t bool memory/private/msg-service/sim_st/3 1 -i -f -s msg-service::vconf -u 200 -g 5000 -vconftool set -t bool memory/private/msg-service/sim_mo_ctrl/3 0 -i -f -s msg-service::vconf -u 200 -g 5000 - -# Notification -vconftool set -t int db/private/msg-service/notification_priv_id 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/voice_noti_id1 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/voice_noti_id2 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/cb_noti_priv_id 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/sim_msg_noti_priv_id 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/emergency_noti_id 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/sentfail_noti_id 0 -s msg-service::vconf -u 200 -g 5000 -vconftool set -t int db/private/msg-service/sim_full_noti_id 0 -s msg-service::vconf -u 200 -g 5000 - - %postun -p /sbin/ldconfig %postun tools -p /sbin/ldconfig @@ -379,7 +214,7 @@ vconftool set -t int db/private/msg-service/sim_full_noti_id 0 -s msg-service::v %files tools %manifest msg-service-tools.manifest %defattr(-,system,system,-) -%{_bindir}/msg-server +%caps(cap_chown,cap_dac_override,cap_lease=eip) %{_bindir}/msg-server %config(noreplace) /opt/usr/dbspace/.msg_service.db* %{_libdir}/systemd/system/msg-server.service %{_libdir}/systemd/system/multi-user.target.wants/msg-server.service diff --git a/plugin/mms_plugin/CMakeLists.txt b/plugin/mms_plugin/CMakeLists.txt index 0d8f267..d3ffda1 100755 --- a/plugin/mms_plugin/CMakeLists.txt +++ b/plugin/mms_plugin/CMakeLists.txt @@ -8,7 +8,6 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "") ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") - ########################################################## # Define MMS Plugin ########################################################## diff --git a/plugin/mms_plugin/MmsPluginAppBase.cpp b/plugin/mms_plugin/MmsPluginAppBase.cpp index ee87255..11e4a23 100755 --- a/plugin/mms_plugin/MmsPluginAppBase.cpp +++ b/plugin/mms_plugin/MmsPluginAppBase.cpp @@ -26,7 +26,10 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allow_malware, const char *raw_filepath); -MmsPluginAppBase::MmsPluginAppBase(){} +MmsPluginAppBase::MmsPluginAppBase() +{ + memset(&mmsMsgData, 0x00, sizeof(mmsMsgData)); +} MmsPluginAppBase::MmsPluginAppBase(MMS_DATA_S *pMmsData) { @@ -80,7 +83,7 @@ void MmsPluginAppBase::getFirstPageTextFilePath(char *textBuf, int textBufSize) pMedia = _MsgMmsGetMedia(pPage, j); - if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { + if (pMedia && pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { MimeType mimeType = MIME_UNKNOWN; diff --git a/plugin/mms_plugin/MmsPluginCodecCommon.cpp b/plugin/mms_plugin/MmsPluginCodecCommon.cpp index a307588..c8078d2 100755 --- a/plugin/mms_plugin/MmsPluginCodecCommon.cpp +++ b/plugin/mms_plugin/MmsPluginCodecCommon.cpp @@ -700,11 +700,13 @@ int extract_encoded_word_param(char *encoded_word, char **charset, char **encod char_set = (char*)calloc(1, q1_ptr - (start_ptr + 2) + 1); - strncpy(char_set, (char*)((start_ptr + 2)), q1_ptr - (start_ptr + 2)); - - MSG_DEBUG("character set [%s][%d]", char_set, strlen(char_set)); - - + 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; @@ -729,7 +731,8 @@ int extract_encoded_word_param(char *encoded_word, char **charset, char **encod //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)); @@ -1492,7 +1495,7 @@ bool MmsInitMsgBody(MsgBody *pMsgBody) MmsInitMsgType(&pMsgBody->presentationType); pMsgBody->pPresentationBody = NULL; - memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX); + memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX + 1); return true; } diff --git a/plugin/mms_plugin/MmsPluginComposer.cpp b/plugin/mms_plugin/MmsPluginComposer.cpp index f83e94b..dea1b2f 100755 --- a/plugin/mms_plugin/MmsPluginComposer.cpp +++ b/plugin/mms_plugin/MmsPluginComposer.cpp @@ -64,8 +64,10 @@ void MmsPluginComposer::composeSendReq(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDING pMmsData->header = MsgMmsCreateHeader(); } - composeSendReqHeader(pMsgInfo, pSendOptInfo, pMmsData); - //TODO:: apply MmsReplaceNonAsciiUtf8 to all multipart FileName; + if (pMmsData->header) { + composeSendReqHeader(pMsgInfo, pSendOptInfo, pMmsData); + //TODO:: apply MmsReplaceNonAsciiUtf8 to all multipart FileName; + } int len = g_list_length(pMmsData->multipartlist); @@ -132,7 +134,7 @@ bool composeSendReqHeader(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *p MmsTimeStruct deliveryTime; MmsMsgClass msgClass; - struct tm *timeInfo = NULL; + struct tm timeInfo; time_t RawTime = 0; time_t nTimeInSecs = 0; @@ -180,8 +182,8 @@ bool composeSendReqHeader(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *p //set Header time(&RawTime); - timeInfo = localtime(&RawTime); - nTimeInSecs = mktime(timeInfo); + localtime_r(&RawTime, &timeInfo); + nTimeInSecs = mktime(&timeInfo); pHeaderData->date = nTimeInSecs; pHeaderData->bDeliveryReport = bAskDeliveryReport; diff --git a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp index 59fc773..bb02aa6 100755 --- a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp +++ b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp @@ -410,6 +410,7 @@ MmsPluginCmAgent::MmsPluginCmAgent() MSG_BEGIN(); isCmOpened = false; + waitProfileOpen = false; home_url = NULL; interface_name = NULL; diff --git a/plugin/mms_plugin/MmsPluginDecode.cpp b/plugin/mms_plugin/MmsPluginDecode.cpp index e915561..d204d11 100755 --- a/plugin/mms_plugin/MmsPluginDecode.cpp +++ b/plugin/mms_plugin/MmsPluginDecode.cpp @@ -478,10 +478,10 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) goto __CATCH; } - pLimitData = (char *)malloc(MSG_LOCALE_SUBJ_LEN + 1); + pLimitData = (char *)calloc(1, MSG_LOCALE_SUBJ_LEN + 1); if (pLimitData == NULL) { - MSG_DEBUG("pLimitData malloc fail"); + MSG_DEBUG("pLimitData calloc fail"); goto __CATCH; } @@ -530,11 +530,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) 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; @@ -633,7 +633,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) goto __CATCH; } - MSG_SEC_INFO("Date = [%u][%s]", mmsHeader.date, ctime((const time_t *)&mmsHeader.date)); + MSG_SEC_INFO("Date = [%u][%d]", mmsHeader.date, (const time_t *)&mmsHeader.date); break; case MMS_CODE_DELIVERYREPORT: @@ -1088,7 +1088,7 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength) int offset = 0; 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 @@ -1352,15 +1352,19 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value 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_SEC_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_SEC_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 } @@ -1579,7 +1583,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head 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; @@ -1609,7 +1613,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head { 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; @@ -1688,7 +1692,9 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head 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); @@ -1774,7 +1780,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head case 0x30: //X-Wap-Content-URI skip this value MSG_DEBUG("X-Wap-Content-URI header."); - pLatinBuff = (char *)malloc(MMS_TEXT_LEN); + pLatinBuff = (char *)calloc(1, MMS_TEXT_LEN); if (pLatinBuff == NULL) goto __CATCH; @@ -1853,7 +1859,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false) goto __RETURN; - szTemp = (char *)malloc(valueLength); + szTemp = (char *)calloc(1, valueLength); if (szTemp == NULL) goto __CATCH; @@ -1923,7 +1929,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head { 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; @@ -1947,7 +1953,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head } 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; @@ -2262,7 +2268,7 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM /* Content Type */ if (szFilePath != NULL) - strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath)); + snprintf(pMsgType->szOrgFilePath, sizeof(pMsgType->szOrgFilePath), "%s", szFilePath); pMsgType->offset = __MmsGetDecodeOffset(); pMsgType->size = headerLength; @@ -2296,7 +2302,7 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM /* Part Body */ if (szFilePath != NULL) - strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath)); + snprintf(pMsgBody->szOrgFilePath, sizeof(pMsgBody->szOrgFilePath), "%s", szFilePath); pMsgBody->offset = __MmsGetDecodeOffset(); pMsgBody->size = bodyLength; @@ -2559,7 +2565,7 @@ static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int t if (length == 0) return 0; - pData = (char *)malloc(length + 1); + pData = (char *)calloc(1, length + 1); if (pData == NULL) { MSG_DEBUG("pData alloc fail"); goto __CATCH; @@ -2623,9 +2629,9 @@ static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen if (oneByte < 0x1F) /* long integer : WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.86) */ { - pData = (char *)malloc(oneByte + 1); + pData = (char *)calloc(1, oneByte + 1); if (pData == NULL) { - MSG_DEBUG("pData memalloc fail"); + MSG_DEBUG("pData calloc fail"); goto __CATCH; } memset(pData, 0, oneByte + 1); @@ -2848,7 +2854,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, goto __CATCH; } - pData = (char *)malloc(gMmsDecodeBufLen + 1); + pData = (char *)calloc(1, gMmsDecodeBufLen + 1); if (pData == NULL) goto __CATCH; @@ -2886,7 +2892,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, } /* while */ if (length > 0) { - pData = (char *)malloc(length); + pData = (char *)calloc(1, length); if (pData == NULL) goto __CATCH; @@ -2990,7 +2996,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota goto __CATCH; } - pData = (char *)malloc(gMmsDecodeBufLen + 1); + pData = (char *)calloc(1, gMmsDecodeBufLen + 1); if (pData == NULL) goto __CATCH; @@ -3029,7 +3035,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota } /* while */ if (length > 0) { - pData = (char *)malloc(length); + pData = (char *)calloc(1, length); if (pData == NULL) goto __CATCH; @@ -3136,7 +3142,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) goto __CATCH; } - pData = (char *)malloc(gMmsDecodeBufLen + 1); + pData = (char *)calloc(1, gMmsDecodeBufLen + 1); if (pData == NULL) goto __CATCH; @@ -3146,7 +3152,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) goto __CATCH; if (szBuff == NULL) { - szBuff = (char *)malloc(gMmsDecodeBufLen + 1); + szBuff = (char *)calloc(1, gMmsDecodeBufLen + 1); } else { szTempPtr = (char *)realloc(szBuff, curLen + gMmsDecodeBufLen + 1); @@ -3197,7 +3203,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) } /* while */ if (length > 0) { - pData = (char *)malloc(length); + pData = (char *)calloc(1, length); if (pData == NULL) { goto __CATCH; } @@ -3207,7 +3213,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) } if (szBuff == NULL) { - szBuff = (char *)malloc(length); + szBuff = (char *)calloc(1, length); } else { szTempPtr = (char *)realloc(szBuff, curLen + length); @@ -3374,7 +3380,7 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen if (nTemp < 0) { /* There can be some error in data - no NULL -> try again with value length */ - pData = (char *)malloc(valueLength - charSetLen); + pData = (char *)calloc(1, valueLength - charSetLen); if (pData == NULL) { MSG_DEBUG("pData alloc fail."); goto __CATCH; @@ -3502,7 +3508,7 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength) if (pAddrStr == NULL) { /* There can be some error in data - no NULL -> try again with value length */ - pAddrStr = (char *)malloc(valueLength - charSetLen); + pAddrStr = (char *)calloc(1, valueLength - charSetLen); if (pAddrStr == NULL) { MSG_DEBUG("pData alloc fail."); goto __CATCH; @@ -3519,7 +3525,7 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength) break; } - pAddr = (MsgHeaderAddress *)malloc(sizeof(MsgHeaderAddress)); + pAddr = (MsgHeaderAddress *)calloc(1, sizeof(MsgHeaderAddress)); if (pAddr == NULL) goto __CATCH; @@ -3624,7 +3630,7 @@ static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int tot if (utf8BufSize < 3) utf8BufSize = 3;//min value - pUTF8Buff = (char *)malloc(utf8BufSize + 1); + pUTF8Buff = (char *)calloc(1, utf8BufSize + 1); if (pUTF8Buff == NULL) { MSG_DEBUG("pUTF8Buff alloc fail"); goto __CATCH; @@ -3790,7 +3796,7 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0) goto __CATCH; - pMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMsg->msgBody.pPresentationBody->size + 1); + pMsg->msgBody.pPresentationBody->body.pText = (char *)calloc(1, pMsg->msgBody.pPresentationBody->size + 1); if (pMsg->msgBody.pPresentationBody->body.pText == NULL) goto __CATCH; @@ -3976,8 +3982,8 @@ static char *__MsgGetStringUntilDelimiter(char *pszString, char delimiter) bufLength = pszStrDelimiter - pszString; - if ((pszBuffer = (char*)malloc (bufLength + 1)) == NULL) { - MSG_DEBUG("malloc is failed"); + if ((pszBuffer = (char*)calloc (1, bufLength + 1)) == NULL) { + MSG_DEBUG("calloc is failed"); return NULL; } memset(pszBuffer, 0, bufLength + 1) ; @@ -4001,7 +4007,7 @@ char *MsgChangeHexString(char *pOrg) cLen = strlen(pOrg); - pNew = (char *)malloc(cLen + 1); + pNew = (char *)calloc(1, cLen + 1); if (pNew == NULL) return NULL; @@ -4086,158 +4092,158 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc) pDec = MsgDecodeText(pName); } - switch (MmsGetTextType(MmsCodeParameterCode, pSrc)) { - case MSG_PARAM_BOUNDARY: + if (pDec) { + switch (MmsGetTextType(MmsCodeParameterCode, pSrc)) { + case MSG_PARAM_BOUNDARY: - /* RFC 822: boundary := 0*69<bchars> bcharsnospace */ + /* RFC 822: boundary := 0*69<bchars> bcharsnospace */ - 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; + 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; - case MSG_PARAM_CHARSET: - pType->param.charset = MmsGetTextType(MmsCodeParameterCode, pDec); + case MSG_PARAM_CHARSET: + pType->param.charset = MmsGetTextType(MmsCodeParameterCode, pDec); - if (pType->param.charset == -1) - pType->param.charset = MSG_CHARSET_UNKNOWN; + if (pType->param.charset == -1) + pType->param.charset = MSG_CHARSET_UNKNOWN; - MSG_SEC_INFO("type = %d [charset] = %d", pType->type, pType->param.charset); - break; + MSG_SEC_INFO("type = %d [charset] = %d", pType->type, pType->param.charset); + break; + + case MSG_PARAM_NAME: - case MSG_PARAM_NAME: + memset (pType->param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1); - memset (pType->param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1); + pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec); - pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec); + 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); + } - 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); + strncpy(pType->param.szName, pUTF8Buff, nameLen); + g_strlcat(pType->param.szName, pExt, sizeof(pType->param.szName)); } else { - nameLen = strlen(pUTF8Buff) - strlen(pExt); + strncpy(pType->param.szName, pUTF8Buff, (MSG_LOCALE_FILENAME_LEN_MAX-1)); } + free(pUTF8Buff); + pUTF8Buff = NULL; - 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; + if (__MsgChangeSpace(pType->param.szName, &szSrc) == true) { + if (szSrc) + strncpy(pType->param.szName, szSrc , strlen(szSrc)); + } - if (__MsgChangeSpace(pType->param.szName, &szSrc) == true) { - if (szSrc) - strncpy(pType->param.szName, szSrc , strlen(szSrc)); - } + if (szSrc) { + free(szSrc); + szSrc = NULL; + } - if (szSrc) { - free(szSrc); - szSrc = NULL; + // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" + __MsgRemoveFilePath(pType->param.szName); + } else { + MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); } - // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" - __MsgRemoveFilePath(pType->param.szName); - } else { - MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); - } + MSG_SEC_INFO("szName = %s", pType->param.szName); + break; - MSG_SEC_INFO("szName = %s", pType->param.szName); - break; + case MSG_PARAM_FILENAME: - case MSG_PARAM_FILENAME: + memset (pType->param.szFileName, 0, MSG_FILENAME_LEN_MAX+1); - memset (pType->param.szFileName, 0, MSG_FILENAME_LEN_MAX+1); + pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec); - 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); + } - if (pUTF8Buff) { - if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { - if ((MSG_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) { - nameLen = (MSG_FILENAME_LEN_MAX-1) - strlen(pExt); + strncpy(pType->param.szFileName, pUTF8Buff, nameLen); + g_strlcat (pType->param.szFileName, pExt, sizeof(pType->param.szFileName)); } else { - nameLen = strlen(pUTF8Buff) - strlen(pExt); + strncpy(pType->param.szFileName, pUTF8Buff, (MSG_FILENAME_LEN_MAX-1)); } + free(pUTF8Buff); + pUTF8Buff = NULL; - 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; + if (__MsgChangeSpace(pType->param.szFileName, &szSrc) == true) { + snprintf(pType->param.szFileName, sizeof(pType->param.szFileName), "%s", szSrc); + } - if (__MsgChangeSpace(pType->param.szFileName, &szSrc) == true) { - snprintf(pType->param.szFileName, sizeof(pType->param.szFileName), "%s", szSrc); - } + if (szSrc) { + free(szSrc); + szSrc = NULL; + } - if (szSrc) { - free(szSrc); - szSrc = NULL; + // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" + __MsgRemoveFilePath(pType->param.szFileName); + } else { + MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); } - // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" - __MsgRemoveFilePath(pType->param.szFileName); - } else { - MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); - } - - MSG_SEC_INFO("szFileName = %s", pType->param.szFileName); + MSG_SEC_INFO("szFileName = %s", pType->param.szFileName); - break; + break; - case MSG_PARAM_TYPE: + case MSG_PARAM_TYPE: - /* type/subtype of root. Only if content-type is multipart/related */ + /* type/subtype of root. Only if content-type is multipart/related */ - pType->param.type = MimeGetMimeIntFromMimeString(pDec); - MSG_SEC_INFO("type = %d", pType->param.type); + pType->param.type = MimeGetMimeIntFromMimeString(pDec); + MSG_SEC_INFO("type = %d", pType->param.type); - break; + break; - case MSG_PARAM_START: + case MSG_PARAM_START: - /* Content-id. Only if content-type is multipart/related */ + /* 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); + memset (pType->param.szStart, 0, MSG_MSG_ID_LEN + 1); + strncpy(pType->param.szStart, pDec, MSG_MSG_ID_LEN); - MSG_SEC_INFO("szStart = %s", pType->param.szStart); + MSG_SEC_INFO("szStart = %s", pType->param.szStart); - break; + break; - case MSG_PARAM_START_INFO : + case MSG_PARAM_START_INFO : - /* Only if content-type is multipart/related */ + /* 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); + memset (pType->param.szStartInfo, 0, MSG_MSG_ID_LEN + 1); + strncpy(pType->param.szStartInfo, pDec, MSG_MSG_ID_LEN); - MSG_SEC_INFO("szStartInfo = %s", pType->param.szStartInfo); + MSG_SEC_INFO("szStartInfo = %s", pType->param.szStartInfo); - break; + break; - case MSG_PARAM_REPORT_TYPE : + case MSG_PARAM_REPORT_TYPE : - // only used as parameter of Content-Type: multipart/report; report-type=delivery-status; + // only used as parameter of Content-Type: multipart/report; report-type=delivery-status; - if (pDec != NULL && strcasecmp(pDec, "delivery-status") == 0) { - pType->param.reportType = MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS; - } else { - pType->param.reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; - } + 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_SEC_INFO("reportType = %s", pDec); - break; + MSG_SEC_INFO("reportType = %s", pDec); + break; - default: + default: - MSG_DEBUG("Unknown paremeter (%s)", pDec); - break; - } + MSG_DEBUG("Unknown paremeter (%s)", pDec); + break; + } - if (pDec) { free(pDec); pDec = NULL; } @@ -4321,7 +4327,7 @@ static char *__MsgConvertLatin2UTF8FileName(char *pSrc) if (utf8BufSize < 3) utf8BufSize = 3; //min value - pUTF8Buff = (char *)malloc(utf8BufSize + 1); + pUTF8Buff = (char *)calloc(1, utf8BufSize + 1); if (pUTF8Buff == NULL) { MSG_DEBUG("pUTF8Buff alloc fail"); @@ -4377,7 +4383,7 @@ static bool __MsgChangeSpace(char *pOrg, char **ppNew) cLen = strlen(pOrg); - pNew = (char *)malloc(cLen + 1); + pNew = (char *)calloc(1, cLen + 1); if (pNew == NULL) return false; @@ -4401,29 +4407,16 @@ static bool __MsgChangeSpace(char *pOrg, char **ppNew) static void __MsgRemoveFilePath(char *pSrc) { // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" - char *pPath = NULL; char *pTemp = NULL; - char szFileName[MSG_FILENAME_LEN_MAX] = {0}; - - if (pSrc == NULL) - return; + char *tmp_name = NULL; - pTemp = pSrc; - while ((pTemp = strchr(pTemp, '/')) != NULL) { - // Find the last '/' - pPath = pTemp; - pTemp++; + tmp_name = MsgGetFileName(pSrc); + if (tmp_name) { + snprintf(pSrc, strlen(tmp_name), "%s", tmp_name); + g_free(tmp_name); + tmp_name = NULL; } - if (pPath) { - MSG_SEC_DEBUG("filename(%s)", pSrc); - - // case : images/vf7.gif -> 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. @@ -4952,7 +4945,7 @@ char *MsgResolveContentURI(char *szSrc) length = strlen(szSrc) + 1; } - szTemp = (char *)malloc(length); + szTemp = (char *)calloc(1, length); if (szTemp == NULL) { MSG_DEBUG("memory full"); goto __CATCH; @@ -4988,7 +4981,7 @@ char *MsgRemoveQuoteFromFilename(char *pSrc) cLen = strlen(pSrc); - pBuff = (char *)malloc(cLen + 1); + pBuff = (char *)calloc(1, cLen + 1); if (pBuff == NULL) { MSG_DEBUG("pBuff mem alloc fail!"); @@ -5869,7 +5862,7 @@ char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int m *npRead = nTemp; } - pReturnData = (char *)malloc(*npRead); + pReturnData = (char *)calloc(1, *npRead); if (pReturnData == NULL) { MSG_DEBUG("pReturnData alloc fail."); goto __CATCH; @@ -6152,7 +6145,7 @@ void MmsPluginDecoder::decodeMmsPdu(MmsMsg *pMsg, msg_message_id_t msgID, const if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0) goto __CATCH; - pMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMsg->msgBody.pPresentationBody->size + 1); + pMsg->msgBody.pPresentationBody->body.pText = (char *)calloc(1, pMsg->msgBody.pPresentationBody->size + 1); if (pMsg->msgBody.pPresentationBody->body.pText == NULL) goto __CATCH; diff --git a/plugin/mms_plugin/MmsPluginEncode.cpp b/plugin/mms_plugin/MmsPluginEncode.cpp index 88676ac..abf59b1 100755 --- a/plugin/mms_plugin/MmsPluginEncode.cpp +++ b/plugin/mms_plugin/MmsPluginEncode.cpp @@ -19,7 +19,10 @@ #include <stdio.h> #include <errno.h> #include <sys/stat.h> + +#include "MsgCppTypes.h" #include "MsgUtilFile.h" + #include "MmsPluginDebug.h" #include "MmsPluginEncode.h" #include "MmsPluginCodecTypes.h" @@ -27,6 +30,7 @@ #include "MmsPluginMIME.h" #include "MmsPluginUtil.h" +using namespace std; /** Sending message related variables ------------------------ */ static char gszMmsEncodeBuf[MSG_MMS_ENCODE_BUFFER_MAX] = {0, }; @@ -505,13 +509,17 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m char *pText = NULL; MsgMultipart *pPart = NULL; MsgType msgType; - MsgBody msgBody; + + MsgBody *msgBody = NULL; + unique_ptr<MsgBody*, void(*)(MsgBody**)> 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; + struct tm dateTime; + time_t RawTime = 0; MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); @@ -523,18 +531,17 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m } 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("text body malloc fail"); + MSG_DEBUG("text body calloc fail"); goto __CATCH; } memset(pText, 0, MSG_STDSTR_LONG); time(&RawTime); - dateTime = localtime(&RawTime); + localtime_r(&RawTime, &dateTime); // get report message if (mmsReadStatus == MSG_READ_REPORT_IS_DELETED) { @@ -550,7 +557,7 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m 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 @@ -577,9 +584,9 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m 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) { + if (__MmsBinaryEncodeMsgBody(pFile, &msgType, msgBody, 1, false) == false) { MSG_DEBUG("MmsBinaryEncodeMsgBody fail"); goto __CATCH; } @@ -997,7 +1004,7 @@ static bool __MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read /* 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("szTo alloc fail"); goto __CATCH; @@ -1144,7 +1151,7 @@ static bool __MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read 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("szTo alloc fail"); @@ -1608,7 +1615,6 @@ static bool __MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLe if (MsgEncode2Base64(pszName, strlen(pszName), &tmpLength, tmpFileName) == true) { g_free(pszName); pszName = g_strdup_printf("=?UTF-8?B?%s?=", tmpFileName); - length = __MmsBinaryEncodeTextStringLen((UINT8*)pszName); MSG_DEBUG("base64 encode filename=[%s]", pszName); } } @@ -1823,7 +1829,7 @@ static bool __MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pTyp pFile2 = MsgOpenFile(pType->szOrgFilePath, "rb"); if (pFile != NULL) { - pData = (char *)malloc(pType->size); + pData = (char *)calloc(1, pType->size); if (pData == NULL) goto __CATCH; @@ -2794,13 +2800,14 @@ 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; if (fieldCode == 0xff) { @@ -2929,18 +2936,18 @@ __CATCH: 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) + if (inpDateSec > 0) dateSec = inpDateSec; else dateSec = time(NULL); - dateTime = localtime(&dateSec); + localtime_r(&dateSec, &dateTime); - 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); + 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; @@ -3192,17 +3199,17 @@ static bool __EncodeMmsMessage(MmsMsg *pMmsMsg, const char *raw_filepath) FILE *pFile = MsgOpenFile(raw_filepath, "wb+"); if (pFile == NULL) { - MSG_FATAL("File Open Error: %s", strerror(errno)); + MSG_FATAL("File Open Error: %s", g_strerror(errno)); goto __CATCH; } if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) { - MSG_DEBUG("File Fseek Error: %s", strerror(errno)); + MSG_DEBUG("File Fseek Error: %s", g_strerror(errno)); goto __CATCH; } if (fchmod(fileno(pFile), file_mode) < 0) { - MSG_DEBUG("File chmod Error: %s", strerror(errno)); + MSG_DEBUG("File chmod Error: %s", g_strerror(errno)); goto __CATCH; } @@ -3252,12 +3259,14 @@ void MmsPluginEncoder::encodeMmsPdu(MMS_DATA_S *pMmsData, msg_message_id_t msgID { MmsMsg *pMmsMsg = (MmsMsg *)calloc(1, sizeof(MmsMsg)); - if (MmsConvertMmsMsg(pMmsMsg, pMmsData) != true) { - MSG_DEBUG("Fail to Compose MMS Message"); - goto __CATCH; - } + if (pMmsMsg) { + if (MmsConvertMmsMsg(pMmsMsg, pMmsData) != true) { + MSG_DEBUG("Fail to Compose MMS Message"); + goto __CATCH; + } - encodeMmsPdu(pMmsMsg, msgID, pduFilePath); + encodeMmsPdu(pMmsMsg, msgID, pduFilePath); + } __CATCH: MmsReleaseMmsMsg(pMmsMsg); diff --git a/plugin/mms_plugin/MmsPluginHttp.cpp b/plugin/mms_plugin/MmsPluginHttp.cpp index b2a7dab..083880d 100755 --- a/plugin/mms_plugin/MmsPluginHttp.cpp +++ b/plugin/mms_plugin/MmsPluginHttp.cpp @@ -255,6 +255,7 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s case MMS_HH_USER_AGENT: { +#if 0 char szUserAgent[1024 + 1]; char *uagent = NULL; @@ -274,6 +275,9 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s free(uagent); uagent = NULL; } +#else + snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_USER_AGENT); +#endif result = true; } break; @@ -726,7 +730,7 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::httpRequest(http_request_info_s &request_in fclose(respfile); respfile = NULL; - if (g_file_get_contents(conf_filename, &request_info.response_data, (gsize*)&request_info.response_data_len, NULL) == false) { + 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"); } } diff --git a/plugin/mms_plugin/MmsPluginInternal.cpp b/plugin/mms_plugin/MmsPluginInternal.cpp index 2040e64..4343686 100755 --- a/plugin/mms_plugin/MmsPluginInternal.cpp +++ b/plugin/mms_plugin/MmsPluginInternal.cpp @@ -18,6 +18,7 @@ #include <errno.h> #include <sys/stat.h> +#include "MsgCppTypes.h" #include "MsgUtilFile.h" #include "MsgException.h" #include "MsgSettingTypes.h" @@ -26,6 +27,7 @@ #include "MsgStorageHandler.h" #include "MsgSerialize.h" #include "MsgSpamFilter.h" + #include "MmsPluginDebug.h" #include "MmsPluginTypes.h" #include "MmsPluginCodec.h" @@ -97,7 +99,8 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ MsgCloseFile(pFile); - remove(pMsgInfo->msgData); + if (remove(pMsgInfo->msgData) != 0) + MSG_DEBUG("Fail remove"); switch (mmsHeader.type) { case MMS_MSGTYPE_NOTIFICATION_IND: @@ -161,9 +164,15 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST } 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; @@ -181,7 +190,7 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST //Subject snprintf(pHeader->szSubject, sizeof(pHeader->szSubject), "%s", mmsHeader.szSubject); //Delivery Report - pHeader->bDeliveryReport = mmsHeader.deliveryReport; + pHeader->bDeliveryReport = (mmsHeader.deliveryReport != MMS_REPORT_YES); //Message Class pHeader->messageClass = mmsHeader.msgClass; @@ -607,17 +616,11 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, filename); - int ret = rename(pRetrievedFilePath, fullPath); - if (ret != 0) { - MSG_DEBUG("File rename Error: %s", strerror(errno)); - } - - if (MsgChmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == false) { - MSG_DEBUG("File Write Error: %s", strerror(errno)); - } - - if (MsgChown(fullPath, 0, 6502 ) == false) { - MSG_DEBUG("File Write Error: %s", strerror(errno)); + if (pRetrievedFilePath) { + int ret = rename(pRetrievedFilePath, fullPath); + if (ret != 0) { + MSG_DEBUG("File rename Error: %s", g_strerror(errno)); + } } } #endif @@ -639,6 +642,11 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra 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); @@ -666,9 +674,11 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra } {//make Preview info for APP - MmsPluginAppBase appBase(pMmsData); - appBase.makePreviewInfo(pMsgInfo->msgId, false, pRetrievedFilePath); - appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + MmsPluginAppBase *appBase; + appBase = new MmsPluginAppBase(pMmsData); + appBase->makePreviewInfo(pMsgInfo->msgId, false, pRetrievedFilePath); + appBase->getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + delete appBase; } MsgMmsRelease(&pMmsData); @@ -959,7 +969,6 @@ bool MmsPluginInternal::checkFilterMmsBody(MMS_DATA_S *pMmsData) return false; bool bFiltered = false; - MMS_MESSAGE_DATA_S mmsMsg; MMS_PAGE_S *pPage = NULL; MMS_MEDIA_S *pMedia = NULL; char filePath[MSG_FILEPATH_LEN_MAX + 1]; @@ -967,21 +976,25 @@ bool MmsPluginInternal::checkFilterMmsBody(MMS_DATA_S *pMmsData) MsgDbHandler *dbHandle = getDbHandle(); MimeType mimeType = MIME_UNKNOWN; - memset(&mmsMsg, 0x00, sizeof(MMS_MESSAGE_DATA_S)); - MsgMmsConvertMmsDataToMmsMessageData(pMmsData, &mmsMsg); + MMS_MESSAGE_DATA_S *mmsMsg = NULL; + unique_ptr<MMS_MESSAGE_DATA_S*, void(*)(MMS_MESSAGE_DATA_S**)> 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); + if (mmsMsg->pageCnt <= 0) { + MSG_WARN("pageCnt : %d", mmsMsg->pageCnt); + MsgMmsReleaseMmsLists(mmsMsg); return false; } - pPage = _MsgMmsGetPage(&mmsMsg, 0); + pPage = _MsgMmsGetPage(mmsMsg, 0); if (!pPage) { MSG_WARN("page is NULL"); - MsgMmsReleaseMmsLists(&mmsMsg); + MsgMmsReleaseMmsLists(mmsMsg); return false; } @@ -1010,7 +1023,7 @@ bool MmsPluginInternal::checkFilterMmsBody(MMS_DATA_S *pMmsData) } } - MsgMmsReleaseMmsLists(&mmsMsg); + MsgMmsReleaseMmsLists(mmsMsg); return bFiltered; } diff --git a/plugin/mms_plugin/MmsPluginMessage.cpp b/plugin/mms_plugin/MmsPluginMessage.cpp index 120529b..b774281 100755 --- a/plugin/mms_plugin/MmsPluginMessage.cpp +++ b/plugin/mms_plugin/MmsPluginMessage.cpp @@ -137,7 +137,7 @@ 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) + 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)); @@ -220,7 +220,7 @@ MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrg MsgMultipart *pMultipart = NULL; if ((pMultipart = MmsAllocMultipart()) == NULL) - goto __CATCH; + return NULL; pMultipart->type.type = mimeType; @@ -255,17 +255,13 @@ MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrg pMultipart->pBody->size = MsgGetFileSize(szOrgFilePath); } return pMultipart; - -__CATCH: - - return NULL; } void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID) { MSG_BEGIN(); - struct tm *timeInfo = NULL; + struct tm timeInfo; time_t RawTime = 0; time_t nTimeInSecs = 0; @@ -279,12 +275,13 @@ void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID) // setting date time(&RawTime); - timeInfo = localtime(&RawTime); - nTimeInSecs = mktime(timeInfo); + localtime_r(&RawTime, &timeInfo); + nTimeInSecs = mktime(&timeInfo); + pMmsMsg->mmsAttrib.date = nTimeInSecs; - pMmsMsg->mmsAttrib.bReportAllowed = mmsHeader.reportAllowed; - pMmsMsg->mmsAttrib.bAskDeliveryReport = mmsHeader.deliveryReport; + pMmsMsg->mmsAttrib.bReportAllowed = (mmsHeader.reportAllowed != MMS_REPORTALLOWED_YES); + pMmsMsg->mmsAttrib.bAskDeliveryReport = (mmsHeader.deliveryReport != MMS_REPORT_YES); MSG_DEBUG("######## Version = %d ########", pMmsMsg->mmsAttrib.version); @@ -320,7 +317,7 @@ void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID) void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, msg_message_id_t selectedMsgId) { - struct tm *timeInfo = NULL; + struct tm timeInfo; time_t RawTime = 0; time_t nTimeInSecs = 0; @@ -340,8 +337,8 @@ void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsg // setting date time(&RawTime); - timeInfo = localtime(&RawTime); - nTimeInSecs = mktime(timeInfo); + localtime_r(&RawTime, &timeInfo); + nTimeInSecs = mktime(&timeInfo); pMmsMsg->mmsAttrib.date = nTimeInSecs; // setting szMsgId @@ -354,7 +351,7 @@ void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsg MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo); if (pMmsMsg->mmsAttrib.szTo) - strncpy(pMmsMsg->mmsAttrib.szFrom, pMmsMsg->mmsAttrib.szTo, strlen(pMmsMsg->mmsAttrib.szTo)); + snprintf(pMmsMsg->mmsAttrib.szFrom, sizeof(pMmsMsg->mmsAttrib.szFrom), "%s", pMmsMsg->mmsAttrib.szTo); } msg_error_t MmsMakeMultipartThumbnailInfo(MMS_MULTIPART_DATA_S *pMultipart, char *thumbnail_path) @@ -555,22 +552,26 @@ bool MmsInsertPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DATA_S * if (isInsert == false) { MMS_ATTACH_S *attachment = NULL; attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1); - attachment->drmType = pMultipart->drmType; + if (attachment) { + attachment->drmType = pMultipart->drmType; - if (strlen(pMultipart->szContentType) > 0) { - snprintf(attachment->szContentType, sizeof(attachment->szContentType), "%s", pMultipart->szContentType); - attachment->mediatype = pMultipart->type; - } + if (strlen(pMultipart->szContentType) > 0) { + snprintf(attachment->szContentType, sizeof(attachment->szContentType), "%s", pMultipart->szContentType); + attachment->mediatype = pMultipart->type; + } - snprintf(attachment->szFilePath, sizeof(attachment->szFilePath), "%s", pMultipart->szFilePath); - snprintf(attachment->szFileName, sizeof(attachment->szFileName), "%s", pMultipart->szFileName); - attachment->fileSize = MsgGetFileSize(attachment->szFilePath); + 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); + 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); + if (_MsgMmsAddAttachment(pMsgData, attachment) != MSG_SUCCESS) { + g_free(attachment); + return false; + } + } else { return false; } } @@ -611,45 +612,52 @@ bool MmsInsertMixedPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DAT 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; + } - 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; - } - - if (_MsgMmsAddPage(pMsgData, pPage) != MSG_SUCCESS) { - g_free(pPage); - g_free(media); + 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 { MMS_ATTACH_S *attachment = NULL; attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1); - - 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); + 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; + } + } else { return false; } } @@ -768,7 +776,7 @@ bool MmsConvertMsgData(MmsMsg *pMsg, MMS_MESSAGE_DATA_S *pMmsMsg) snprintf(szBuf, sizeof(szBuf), "%s", partHeader.param.szFileName); snprintf(partHeader.param.szFileName, sizeof(partHeader.param.szFileName), "%s%s", MSG_DATA_PATH, szBuf); - page = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S)); + page = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S)); if (page == NULL) { MSG_FATAL("page allocation error"); goto FREE_CATCH; @@ -902,19 +910,21 @@ int MmsUpdatePreviewData(MSG_MESSAGE_INFO_S *pMsgInfo) MSG_BEGIN(); char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; - MmsMsg mmsMsg; - memset(&mmsMsg, 0, sizeof(MmsMsg)); + MmsMsg *mmsMsg = NULL; + unique_ptr<MmsMsg*, void(*)(MmsMsg**)> buf(&mmsMsg, unique_ptr_deleter); + mmsMsg = (MmsMsg *)new char[sizeof(MmsMsg)]; + memset(mmsMsg, 0x00, sizeof(MmsMsg)); MmsPluginStorage::instance()->getMmsRawFilePath(pMsgInfo->msgId, szFullPath, sizeof(szFullPath)); - MmsPluginDecoder::instance()->decodeMmsPdu(&mmsMsg, pMsgInfo->msgId, szFullPath); + MmsPluginDecoder::instance()->decodeMmsPdu(mmsMsg, pMsgInfo->msgId, szFullPath); {//make Preview info for APP - MmsPluginAppBase appBase(&mmsMsg); + MmsPluginAppBase appBase(mmsMsg); appBase.makePreviewInfo(pMsgInfo->msgId, true, szFullPath); appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); } - MmsReleaseMmsMsg(&mmsMsg); + MmsReleaseMmsMsg(mmsMsg); MSG_END(); return 0; } @@ -959,15 +969,16 @@ bool MmsConvertMmsData(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData) if (pMmsMsg->mmsAttrib.contentType == MIME_MULTIPART_RELATED || pMmsMsg->mmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); - - 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; + 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; + } } int partCnt = pMmsMsg->nPartCount; @@ -980,20 +991,22 @@ bool MmsConvertMmsData(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData) MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); - pMultipart->type = (MimeType)multipart->type.type; + 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); + 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; - } + if (multipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { + pMultipart->drmType = multipart->type.drmInfo.drmType; + } #endif - pMmsData->multipartlist = g_list_append(pMmsData->multipartlist, pMultipart); + pMmsData->multipartlist = g_list_append(pMmsData->multipartlist, pMultipart); + } } } @@ -1114,8 +1127,8 @@ bool MmsConvertMmsMsg(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData) char *MmsConvertAddressToOldStyle(MMSList *pAddressList) { MSG_BEGIN(); - int addrLen = 0; - int nAddressCnt = 0; + int addrLen = 0; + int nAddressCnt = 0; char pString[MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3] = {0, }; char *szCompose = NULL; @@ -1141,26 +1154,26 @@ char *MmsConvertAddressToOldStyle(MMSList *pAddressList) szCompose = (char *)calloc(addrLen + 1, 1); - // Address String copy - for (int i = 0; i < nAddressCnt; ++i) { + 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); - 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)); - if (pAddressData) { - if (strlen(szCompose) > 0) - strcat(szCompose, MSG_STR_ADDR_DELIMETER); + 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); + } - 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)); } - - strcat(szCompose, pString); } - } MSG_END(); diff --git a/plugin/mms_plugin/MmsPluginStorage.cpp b/plugin/mms_plugin/MmsPluginStorage.cpp index 81b85d9..2100138 100755 --- a/plugin/mms_plugin/MmsPluginStorage.cpp +++ b/plugin/mms_plugin/MmsPluginStorage.cpp @@ -18,6 +18,7 @@ #include <sys/stat.h> #include <errno.h> +#include "MsgCppTypes.h" #include "MsgException.h" #include "MsgUtilFile.h" #include "MsgMmsMessage.h" @@ -442,7 +443,7 @@ msg_error_t MmsPluginStorage::getMmsMessageId(msg_message_id_t selectedMsgId, Mm snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MESSAGE_ID FROM %s WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, selectedMsgId); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); @@ -467,9 +468,9 @@ msg_error_t MmsPluginStorage::getMmsMessageId(msg_message_id_t selectedMsgId, Mm int MmsPluginStorage::getMmsVersion(msg_message_id_t selectedMsgId) { msg_error_t err = MSG_SUCCESS; - int rowCnt = 0; - int version = 0; + int rowCnt = 0; + int version = 0; MsgDbHandler *dbHandle = getDbHandle(); @@ -480,7 +481,7 @@ int MmsPluginStorage::getMmsVersion(msg_message_id_t selectedMsgId) snprintf(sqlQuery, sizeof(sqlQuery), "SELECT VERSION FROM %s WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, selectedMsgId); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); @@ -653,7 +654,7 @@ msg_error_t MmsPluginStorage::getMsgText(MMS_MESSAGE_DATA_S *pMmsMsg, char *pMsg pMedia = _MsgMmsGetMedia(pPage, j); - if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { + if (pMedia && pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { MimeType mimeType = MIME_UNKNOWN; MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL); @@ -1012,8 +1013,7 @@ msg_error_t MmsPluginStorage::getMultipartList(msg_message_id_t msgId, MMSList * MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN + 1]; - int rowCnt; - int index = 8; + int rowCnt = 0, index = 0; memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), @@ -1021,7 +1021,7 @@ msg_error_t MmsPluginStorage::getMultipartList(msg_message_id_t msgId, MMSList * "FROM %s WHERE MSG_ID=%d;", MSGFW_MMS_MULTIPART_TABLE_NAME, msgId); - msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt); + msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err == MSG_SUCCESS) { @@ -1314,9 +1314,11 @@ msg_error_t MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDI } {//make Preview info for APP - MmsPluginAppBase appBase(pMmsData); - appBase.makePreviewInfo(pMsgInfo->msgId, true, raw_filepath); - appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + MmsPluginAppBase *appBase; + appBase = new MmsPluginAppBase(pMmsData); + appBase->makePreviewInfo(pMsgInfo->msgId, true, raw_filepath); + appBase->getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + delete appBase; } } else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) { @@ -1426,9 +1428,11 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE } {//make Preview info for APP - MmsPluginAppBase appBase(pMmsData); - appBase.makePreviewInfo(pMsgInfo->msgId, true, raw_filepath); - appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + MmsPluginAppBase *appBase; + appBase = new MmsPluginAppBase(pMmsData); + appBase->makePreviewInfo(pMsgInfo->msgId, true, raw_filepath); + appBase->getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + delete appBase; } } @@ -1538,16 +1542,21 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo) //update preview char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; - MmsMsg mmsMsg; - memset(&mmsMsg, 0, sizeof(MmsMsg)); + MmsMsg *mmsMsg = NULL; + unique_ptr<MmsMsg*, void(*)(MmsMsg**)> buf(&mmsMsg, unique_ptr_deleter); + mmsMsg = (MmsMsg *)new char[sizeof(MmsMsg)]; + memset(mmsMsg, 0x00, sizeof(MmsMsg)); + MmsPluginStorage::instance()->getMmsRawFilePath(pMsgInfo->msgId, szFullPath, sizeof(szFullPath)); - MmsPluginDecoder::instance()->decodeMmsPdu(&mmsMsg, pMsgInfo->msgId, szFullPath); + MmsPluginDecoder::instance()->decodeMmsPdu(mmsMsg, pMsgInfo->msgId, szFullPath); {//make Preview info for APP - MmsPluginAppBase appBase(&mmsMsg); - appBase.makePreviewInfo(pMsgInfo->msgId, true, szFullPath); - appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + MmsPluginAppBase *appBase; + appBase = new MmsPluginAppBase(mmsMsg); + appBase->makePreviewInfo(pMsgInfo->msgId, true, szFullPath); + appBase->getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + delete appBase; } - MmsReleaseMmsMsg(&mmsMsg); + MmsReleaseMmsMsg(mmsMsg); MSG_END(); return 0; @@ -1581,7 +1590,7 @@ int MmsPluginStorage::checkDuplicateNotification(char* pszTrID, char* pszContent MSG_DEBUG("sqlQuery [%s]", sqlQuery); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); diff --git a/plugin/mms_plugin/MmsPluginTextConvert.cpp b/plugin/mms_plugin/MmsPluginTextConvert.cpp index 58e1da4..bd79ac6 100755 --- a/plugin/mms_plugin/MmsPluginTextConvert.cpp +++ b/plugin/mms_plugin/MmsPluginTextConvert.cpp @@ -58,6 +58,11 @@ bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeset, cons if (((UINT8)pSrc[0] == 0xFF && (UINT8)pSrc[1] == 0xFE) || ((UINT8)pSrc[0] == 0xFE && (UINT8)pSrc[1] == 0xFF)) { char *pTemp = (char *)calloc(1, srcLen + 1); + if (pTemp == NULL) { + MSG_DEBUG("fail to calloc"); + goto __CATCH; + } + memcpy(pTemp, pSrc, srcLen); for (int i = 0; i < srcLen - 1; i++) { @@ -71,7 +76,8 @@ bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeset, cons if (MmsIsUtf8String((unsigned char *)pTemp+2, srcLen-2) == true) { MSG_DEBUG("UTF-8 string"); pDest = (char *)calloc(1, srcLen - 2 + 1); - strncpy(pDest, pTemp + 2, srcLen - 2); + if (pDest) + strncpy(pDest, pTemp + 2, srcLen - 2); bytes_written = srcLen - 2; if (pTemp) { diff --git a/plugin/mms_plugin/MmsPluginTransport.cpp b/plugin/mms_plugin/MmsPluginTransport.cpp index b055248..5af58cf 100755 --- a/plugin/mms_plugin/MmsPluginTransport.cpp +++ b/plugin/mms_plugin/MmsPluginTransport.cpp @@ -80,7 +80,8 @@ void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo) reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION; reqItem.getDataLen = pReqInfo->msgInfo.dataSize; reqItem.pGetData = (char *)malloc(reqItem.getDataLen); - memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen); + if (reqItem.pGetData) + memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen); MSG_MMS_VLD_INFO("%d, MMS Receive Auto Start %s->%s, Success", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.addressList[0].addressVal, (msisdn == NULL)?"ME":msisdn); break; @@ -104,7 +105,8 @@ void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo) reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION; reqItem.getDataLen = pReqInfo->msgInfo.dataSize; reqItem.pGetData = (char *)malloc(reqItem.getDataLen); - memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen); + if (reqItem.pGetData) + memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen); MSG_MMS_VLD_INFO("%d, MMS Receive Manual Start %s->%s, Success", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.addressList[0].addressVal, (msisdn == NULL)?"ME":msisdn); break; diff --git a/plugin/mms_plugin/MmsPluginUserAgent.cpp b/plugin/mms_plugin/MmsPluginUserAgent.cpp index 6e022d8..ff4d13b 100755 --- a/plugin/mms_plugin/MmsPluginUserAgent.cpp +++ b/plugin/mms_plugin/MmsPluginUserAgent.cpp @@ -288,7 +288,8 @@ MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity) http_url = (char *)calloc(1, qEntity->getDataLen + 1); - memcpy(http_url, qEntity->pGetData, qEntity->getDataLen); + if (http_url) + memcpy(http_url, qEntity->pGetData, qEntity->getDataLen); request_info.url = http_url; diff --git a/plugin/mms_plugin/MmsPluginUtil.cpp b/plugin/mms_plugin/MmsPluginUtil.cpp index 4bcb74b..6db2c2c 100755 --- a/plugin/mms_plugin/MmsPluginUtil.cpp +++ b/plugin/mms_plugin/MmsPluginUtil.cpp @@ -31,7 +31,6 @@ using namespace std; - Mutex g_mx; CndVar g_cv; @@ -218,7 +217,7 @@ FILE *MmsFileOpen(char *pFileName) mode_t file_mode = (S_IRUSR | S_IWUSR); if (!pFileName) { - MSG_DEBUG("pFileName NULL: %s", strerror(errno)); + MSG_DEBUG("pFileName NULL: %s", g_strerror(errno)); return NULL; } @@ -227,19 +226,19 @@ FILE *MmsFileOpen(char *pFileName) FILE *pFile = MsgOpenFile(pFileName, "wb+"); if (pFile == NULL) { - MSG_FATAL("File Open Error: %s", strerror(errno)); + MSG_FATAL("File Open Error: %s", g_strerror(errno)); return NULL; } if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File Read Error: %s", strerror(errno)); + MSG_DEBUG("File Read Error: %s", g_strerror(errno)); return NULL; } if (fchmod(fileno(pFile), file_mode) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File chmod Error: %s", strerror(errno)); + MSG_DEBUG("File chmod Error: %s", g_strerror(errno)); return NULL; } diff --git a/plugin/mms_plugin/include/MmsPluginCodecTypes.h b/plugin/mms_plugin/include/MmsPluginCodecTypes.h index d4b1566..0be998b 100755 --- a/plugin/mms_plugin/include/MmsPluginCodecTypes.h +++ b/plugin/mms_plugin/include/MmsPluginCodecTypes.h @@ -429,7 +429,7 @@ typedef struct _MsgType { int disposition; char szContentID[MSG_MSG_ID_LEN + 1]; char szContentLocation[MSG_MSG_ID_LEN + 1]; - char szOrgFilePath[MSG_FILEPATH_LEN_MAX]; + char szOrgFilePath[MSG_FILEPATH_LEN_MAX + 1]; MsgContentParam param; } MsgType; @@ -437,7 +437,7 @@ typedef struct _MsgType { struct _MsgBody { int offset; int size; - char szOrgFilePath[MSG_FILEPATH_LEN_MAX]; + char szOrgFilePath[MSG_FILEPATH_LEN_MAX + 1]; MsgType presentationType; MsgBody *pPresentationBody; diff --git a/plugin/sms_cdma_plugin/CMakeLists.txt b/plugin/sms_cdma_plugin/CMakeLists.txt index 82f9eef..bac61c7 100755 --- a/plugin/sms_cdma_plugin/CMakeLists.txt +++ b/plugin/sms_cdma_plugin/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 SMS Plugin diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp index de38121..81362c7 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp @@ -506,7 +506,7 @@ void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); /** convert to msgInfo */ convertTpduToMsginfo(p_p2p_msg, &msgInfo); @@ -688,7 +688,7 @@ void SmsPluginEventHandler::handleCbMsgIncoming(sms_trans_broadcast_msg_s *p_cb_ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); /** convert to msgInfo */ convertTpduToMsginfo(p_cb_msg, &msgInfo); @@ -852,13 +852,13 @@ void SmsPluginEventHandler::handleWapMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg) int dataSize = 0; char* pUserData = NULL; char* pTmpUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); - AutoPtr<char> dataBuf1(&pTmpUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); + unique_ptr<char*, void(*)(char**)> dataBuf1(&pTmpUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0,}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); dataSize = MakeWapUserData(msg.msgId, &pUserData); @@ -1092,7 +1092,8 @@ int SmsPluginEventHandler::MakeWapUserData(unsigned short msgId, char **ppTotalD MSG_DEBUG("totalSize [%d]", totalSize); - *ppTotalData = new char[totalSize]; + if (*ppTotalData == NULL) + *ppTotalData = new char[totalSize]; for (it = wapList[i].data.begin(); it != wapList[i].data.end(); it++) { memcpy(*ppTotalData+offset, it->second.data, it->second.length); diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp index 9ca4712..501b1ae 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp @@ -102,7 +102,6 @@ void* SmsPluginSetting::initSimInfo(void *data) MSG_SEC_DEBUG("IMSI [%s]", imsi); } else { MSG_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet); - MsgSettingSetBool(MSG_NATIONAL_SIM, false); } MsgSettingSetString(MSG_SIM_IMSI, imsi); diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp index a549b86..33ce7df 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp @@ -124,7 +124,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE MSG_ID = %d AND MSG_REF > 0;", MSGFW_SMS_REPORT_TABLE_NAME, msgId); - if (dbHandle->getTable(sqlQuery, &rowCnt) != MSG_SUCCESS) + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) return MSG_ERR_DB_GETTABLE; MSG_DEBUG("Selected row count = [%d]", rowCnt); @@ -561,7 +561,7 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou { msg_error_t err = MSG_SUCCESS; - int rowCnt = 0, index = 3; + int rowCnt = 0, index = 0; MsgDbHandler *dbHandle = getDbHandle(); @@ -571,7 +571,7 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONTENT_TYPE, APP_ID, APPCODE FROM %s", MSGFW_PUSH_CONFIG_TABLE_NAME); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); MSG_DEBUG("rowCnt: %d", rowCnt); if (err == MSG_ERR_DB_NORECORD) { diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp index 1518cba..986e6f6 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp @@ -61,7 +61,7 @@ void SmsPluginUAManager::run() unlock(); request.msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&request.msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter); try { diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp index 4a1524a..caec114 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp @@ -781,21 +781,21 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi unsigned long PDUTypeDataLen = DataSize; char* pPushHeader = NULL; - AutoPtr<char> pushHeaderBuf(&pPushHeader); + unique_ptr<char*, void(*)(char**)> pushHeaderBuf(&pPushHeader, unique_ptr_deleter); unsigned long pushHeaderLen = 0; char* pPushBody = NULL; - AutoPtr<char> PushBodyBuf(&pPushBody); + unique_ptr<char*, void(*)(char**)> PushBodyBuf(&pPushBody, unique_ptr_deleter); unsigned long pushBodyLen = 0; unsigned long iPDU = 1; char* pWspHeader = NULL; - AutoPtr<char> WspHeaderBuf(&pWspHeader); + unique_ptr<char*, void(*)(char**)> WspHeaderBuf(&pWspHeader, unique_ptr_deleter); unsigned long wspHeaderLen = 0; char* pWspBody = NULL; - AutoPtr<char> WspBodyBuf(&pWspBody); + unique_ptr<char*, void(*)(char**)> WspBodyBuf(&pWspBody, unique_ptr_deleter); unsigned long wspBodyLen = 0; /** pass PDU type */ @@ -1361,7 +1361,7 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1533,7 +1533,7 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1664,7 +1664,7 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1788,7 +1788,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1827,7 +1827,7 @@ void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen) #if MSG_DRM_SUPPORT int drmRt = DRM_RETURN_SUCCESS; char* cid = NULL; - AutoPtr<char> buf(&cid); + unique_ptr<char*, void(*)(char**)> buf(&cid, unique_ptr_deleter); MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message."); drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE; @@ -2150,12 +2150,12 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un unsigned long currentLength; char* encodedHeader = NULL; - AutoPtr<char> encodedHeaderbuf(&encodedHeader); + unique_ptr<char*, void(*)(char**)> encodedHeaderbuf(&encodedHeader, unique_ptr_deleter); char* outTemper = NULL; char* temper = NULL; - AutoPtr<char> temperbuf(&temper); + unique_ptr<char*, void(*)(char**)> temperbuf(&temper, unique_ptr_deleter); unsigned char track; unsigned long iEncodedHeader = 0; @@ -2181,7 +2181,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un for (loop = 0 ; loop<(int)encodedHeaderLen; loop++) { char szTempBuf[5]; szTempBuf[0] = 0x00; - sprintf( szTempBuf, "%2X ", sEncodedHeader[loop] ); + snprintf( szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop] ); if (AcStrlen( szBuf ) + 7 < 64) { strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 ); @@ -2389,7 +2389,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un /* If parameter exist */ if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, ¶m); strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } @@ -2496,7 +2496,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un /* If there is a parameter */ if (tempLen < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, ¶m); if (param != NULL) { strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1); @@ -2542,7 +2542,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (tempLen < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeQValue( fieldValueLen - tempLen, fieldValue + tempLen, ¶m ); strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } @@ -2568,7 +2568,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]); else */ - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2610,7 +2610,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]); else */ - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1); } break; @@ -2631,7 +2631,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x12 : { char* decodedString = NULL; - AutoPtr<char> decodedStringbuf(&decodedString); + unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString); strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 ); } @@ -2665,7 +2665,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x21 : if (fieldValue[0] == 0x80) { char* addString = NULL; - AutoPtr<char> addStringbuf(&addString); + unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter); wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString ); strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } else { @@ -2674,7 +2674,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m ); if (param != NULL) { strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2694,7 +2694,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un break; if (fieldValue[0] == 0x80) { char* addString = NULL; - AutoPtr<char> addStringbuf(&addString); + unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter); wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString ); strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } else { @@ -2711,7 +2711,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, ¶m ); if (param != NULL) { strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2737,7 +2737,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un */ last = first + contentsLength - 1; - sprintf( (char*)temp, "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len ); + snprintf( (char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2746,7 +2746,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x08 : { char* cacheString = NULL; - AutoPtr<char> cacheStringbuf(&cacheString); + unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter); wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString ); strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2760,7 +2760,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un } else { if (1 < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue, fieldValueLen, ¶m ); if (param != NULL) { @@ -2792,7 +2792,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un first = wspRetriveUintvarDecode( fieldValue, &iField ); last = wspRetriveUintvarDecode( fieldValue, &iField ); - sprintf( (char*)temp, "%u-%u", (unsigned int)first, (unsigned int)last ); + snprintf( (char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } if (fieldValue[0] == 0x81) { @@ -2801,7 +2801,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un suffix = wspRetriveUintvarDecode( fieldValue, &iField ); - sprintf( (char*)temp, "-%u", (unsigned int)suffix ); + snprintf( (char*)temp, sizeof(temp), "-%u", (unsigned int)suffix ); } break; @@ -2809,7 +2809,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x25 : if (fieldValue[0] == 0x80) { char* temp = NULL; - AutoPtr<char> tempbuf(&temp); + unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2818,7 +2818,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (fieldValue[0] == 0x81) { unsigned char temp[16]; - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2873,7 +2873,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (1 < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m ); if (param != NULL) { @@ -2902,7 +2902,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) { /* copy warn-date */ char* decodedString = NULL; - AutoPtr<char> decodedStringbuf(&decodedString); + unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString ); strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 ); } diff --git a/plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h b/plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h index 2abf4c9..54b304e 100755 --- a/plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h +++ b/plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h @@ -125,7 +125,6 @@ private: int MakeWapUserData(unsigned short msgId, char **ppTotalData); bool checkCbOpt(sms_trans_svc_ctg_t svc_ctg); - std::list<MSG_CB_DUPLICATE_S> duplicateCb; }; diff --git a/plugin/sms_plugin/CMakeLists.txt b/plugin/sms_plugin/CMakeLists.txt index d4129c9..32fc48c 100755 --- a/plugin/sms_plugin/CMakeLists.txt +++ b/plugin/sms_plugin/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} -O2 -g -Wall") ########################################################## # Define SMS Plugin @@ -42,8 +42,7 @@ INCLUDE_DIRECTORIES( ) INCLUDE(FindPkgConfig) -pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 db-util) -#capi-telephony +pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 db-util capi-telephony) FOREACH(flag ${sms_plugin_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/plugin/sms_plugin/SmsPluginCallback.cpp b/plugin/sms_plugin/SmsPluginCallback.cpp index e0fa5c6..b3b04ff 100755 --- a/plugin/sms_plugin/SmsPluginCallback.cpp +++ b/plugin/sms_plugin/SmsPluginCallback.cpp @@ -465,7 +465,7 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d msgInfo.storageId = MSG_STORAGE_SIM; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); SmsPluginEventHandler::instance()->convertTpduToMsginfo(&tpdu, &msgInfo); @@ -527,7 +527,7 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType); MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType); MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType); - MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime)); + MSG_DEBUG("msgInfo.displayTime : %d", msgInfo.displayTime); MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize); if (msgInfo.bTextSms == true) MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText); @@ -885,7 +885,7 @@ void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user cbOpt.bReceive = (bool)pCBConfig->CBEnabled; - cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount; + cbOpt.maxSimCnt = TAPI_NETTEXT_SMS_CBMI_LIST_SIZE_MAX; cbOpt.simIndex = simIndex; @@ -1085,30 +1085,34 @@ void TapiEventGetSimServiceTable(TapiHandle *handle, int result, void *data, voi } else { err = MsgSettingSetBool(sstKey, false); } + MSG_DEBUG("Setting result = [%d]", err); if (svct->table.sst.service[TAPI_SIM_SST_MO_SMS_CTRL_BY_SIM] == 1){ err = MsgSettingSetBool(moCtrlKey, true); } else { err = MsgSettingSetBool(moCtrlKey, false); } + MSG_DEBUG("Setting result = [%d]", err); + } else if (svct->sim_type == TAPI_SIM_CARD_TYPE_USIM) { if (svct->table.sst.service[TAPI_SIM_UST_SMS] == 1) { err = MsgSettingSetBool(sstKey, true); } else { err = MsgSettingSetBool(sstKey, false); } + MSG_DEBUG("Setting result = [%d]", err); if (svct->table.sst.service[TAPI_SIM_UST_MO_SMS_CTRL] == 1){ err = MsgSettingSetBool(moCtrlKey, true); } else { err = MsgSettingSetBool(moCtrlKey, false); } + MSG_DEBUG("Setting result = [%d]", err); + } else { MSG_DEBUG("Unknown SIM type value"); } - MSG_DEBUG("Setting result = [%d]", err); - SmsPluginSetting::instance()->setResultFromSim(bRet); } @@ -1253,7 +1257,7 @@ void TapiEventNetworkStatusChange(TapiHandle *handle, const char *noti_id, void TelNetworkServiceType_t *type = (TelNetworkServiceType_t *)data; - MSG_INFO("network status type [%d]", *type); + MSG_INFO("network status type [%d], simIndex [%d]", *type, (int)user_data); if (*type > TAPI_NETWORK_SERVICE_TYPE_SEARCH) { SmsPluginEventHandler::instance()->handleResendMessage(); // Call Event Handler @@ -1322,7 +1326,7 @@ void SmsPluginCallback::registerEvent() MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SAT_MO_SM_CONTROL_RESULT); if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SIM_STATUS, TapiEventSimStatusChange, NULL) != TAPI_API_SUCCESS) MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SIM_STATUS); - if (tel_register_noti_event(pTapiHandle, TAPI_PROP_NETWORK_SERVICE_TYPE, TapiEventNetworkStatusChange, NULL) != TAPI_API_SUCCESS) + if (tel_register_noti_event(pTapiHandle, TAPI_PROP_NETWORK_SERVICE_TYPE, TapiEventNetworkStatusChange, (void*)simIndex) != TAPI_API_SUCCESS) MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_PROP_NETWORK_SERVICE_TYPE); if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SIM_REFRESHED, TapiEventSimRefreshed, NULL) != TAPI_API_SUCCESS) MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SIM_REFRESHED); diff --git a/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp b/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp index ecacdf8..ce9e959 100755 --- a/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp +++ b/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp @@ -101,7 +101,7 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle); - if (!checkCbOpt(CbMsgPage, &bJavaMsg, simIndex)) + if (!checkCbOpt(&CbMsgPage, &bJavaMsg, simIndex)) { MSG_DEBUG("The CB Msg is not supported by option."); return; @@ -115,26 +115,30 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs // Check CB Pages - unsigned char pageCnt = checkCbPage(CbMsgPage); + unsigned char pageCnt = checkCbPage(&CbMsgPage); if (pageCnt == CbMsgPage.pageHeader.totalPages) { MSG_DEBUG("RECEIVED LAST MSG : %d", pageCnt); - SMS_CBMSG_S cbMsg = {0,}; + SMS_CBMSG_S *cbMsg = NULL; + unique_ptr<SMS_CBMSG_S*, void(*)(SMS_CBMSG_S**)> buf(&cbMsg, unique_ptr_deleter); + cbMsg = (SMS_CBMSG_S *)new char[sizeof(SMS_CBMSG_S)]; + memset(cbMsg, 0x00, sizeof(SMS_CBMSG_S)); + MSG_MESSAGE_INFO_S msgInfo; /** initialize msgInfo */ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); // Make CB Msg Structure - MakeCbMsg(CbMsgPage, &cbMsg); + MakeCbMsg(&CbMsgPage, cbMsg); // Convert to MSG_MESSAGE_INFO_S - convertCbMsgToMsginfo(&cbMsg, &msgInfo, simIndex); + convertCbMsgToMsginfo(cbMsg, &msgInfo, simIndex); // Add CB Msg into DB msg_error_t err = MSG_SUCCESS; @@ -146,13 +150,13 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs MSG_CB_MSG_S cbOutMsg = {0, }; cbOutMsg.type = MSG_CB_SMS; - cbOutMsg.receivedTime = cbMsg.recvTime; + cbOutMsg.receivedTime = cbMsg->recvTime; cbOutMsg.serialNum = encodeCbSerialNum (CbMsgPage.pageHeader.serialNum); - cbOutMsg.messageId = cbMsg.msgId; + cbOutMsg.messageId = cbMsg->msgId; cbOutMsg.dcs = CbMsgPage.pageHeader.dcs.rawData; memset (cbOutMsg.cbText, 0x00, sizeof(cbOutMsg.cbText)); - cbOutMsg.cbTextLen= convertTextToUtf8((unsigned char*)cbOutMsg.cbText, sizeof(cbOutMsg.cbText), &cbMsg); + cbOutMsg.cbTextLen= convertTextToUtf8((unsigned char*)cbOutMsg.cbText, sizeof(cbOutMsg.cbText), cbMsg); memset(cbOutMsg.language_type, 0x00, sizeof(cbOutMsg.language_type)); memcpy(cbOutMsg.language_type, CbMsgPage.pageHeader.dcs.iso639Lang, 3); err = SmsPluginEventHandler::instance()->callbackCBMsgIncoming(&cbOutMsg, &msgInfo); @@ -176,9 +180,7 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs } #endif // Remove From List - removeFromPageList(CbMsgPage); - - + removeFromPageList(&CbMsgPage); } MSG_END(); } @@ -200,7 +202,7 @@ void SmsPluginCbMsgHandler::handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *p return; } DecodeEtwsMsg(pEtwsMsg, &etwsPn); - //convertEtwsMsgToMsginfo(CbMsgPage, &msgInfo, simIndex); + //convertEtwsMsgToMsginfo(&CbMsgPage, &msgInfo, simIndex); cbOutMsg.type = MSG_ETWS_SMS; cbOutMsg.receivedTime = etwsPn.recvTime; @@ -565,7 +567,7 @@ int SmsPluginCbMsgHandler::CMAS_class(unsigned short message_id) return ret; } -bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex) +bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex) { bool bReceive = false; char keyName[MAX_VCONFKEY_NAME_LEN]; @@ -624,9 +626,9 @@ bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg, MsgId_from = cbChannelInfo.channelInfo[i].from; MsgId_to = cbChannelInfo.channelInfo[i].to; - if (bActivate == true && CbPage.pageHeader.msgId >= MsgId_from && CbPage.pageHeader.msgId <= MsgId_to) + if (bActivate == true && CbPage->pageHeader.msgId >= MsgId_from && CbPage->pageHeader.msgId <= MsgId_to) { - MSG_DEBUG("FIND CHANNEL = [%d]", CbPage.pageHeader.msgId); + MSG_DEBUG("FIND CHANNEL = [%d]", CbPage->pageHeader.msgId); return true; } } @@ -634,7 +636,7 @@ bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg, return false; } -unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) +unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S *CbPage) { unsigned char currPageCnt = 0; @@ -653,17 +655,17 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) } #endif - if (CbPage.pageHeader.totalPages > 0) + if (CbPage->pageHeader.totalPages > 0) { for (unsigned int i = 0; i < pageList.size(); i++) { - if (pageList[i].geoScope == CbPage.pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage.pageHeader.serialNum.msgCode) + if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) { MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode); - if (pageList[i].msgId == CbPage.pageHeader.msgId) + if (pageList[i].msgId == CbPage->pageHeader.msgId) { - int updateNum = CbPage.pageHeader.serialNum.updateNum - pageList[i].updateNum; + int updateNum = CbPage->pageHeader.serialNum.updateNum - pageList[i].updateNum; if (updateNum > 0) // New Message Content { @@ -671,20 +673,20 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) } else if (updateNum == 0) // Same Message Content { - if (pageList[i].data.count(CbPage.pageHeader.page) != 0) + if (pageList[i].data.count(CbPage->pageHeader.page) != 0) { - MSG_DEBUG("The Page Number already exists [%d]", CbPage.pageHeader.page); + MSG_DEBUG("The Page Number already exists [%d]", CbPage->pageHeader.page); return 0; } - pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage.pageHeader.page, CbPage); + pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage->pageHeader.page, *CbPage); pageList[i].data.insert(newData); - MSG_DEBUG("PAGE DATA : %s", CbPage.pageData); + MSG_DEBUG("PAGE DATA : %s", CbPage->pageData); MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.pageData); pageList[i].pageCnt++; - pageList[i].totalSize += CbPage.pageLength; + pageList[i].totalSize += CbPage->pageLength; currPageCnt = pageList[i].pageCnt; @@ -701,7 +703,7 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) } } - if (bFind == false || CbPage.pageHeader.totalPages == 1) + if (bFind == false || CbPage->pageHeader.totalPages == 1) { addToPageList(CbPage); return 1; @@ -711,24 +713,24 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) } -void SmsPluginCbMsgHandler::MakeCbMsg(SMS_CBMSG_PAGE_S CbPage, SMS_CBMSG_S *pCbMsg) +void SmsPluginCbMsgHandler::MakeCbMsg(SMS_CBMSG_PAGE_S *CbPage, SMS_CBMSG_S *pCbMsg) { - pCbMsg->cbMsgType = CbPage.cbMsgType; - pCbMsg->msgId = CbPage.pageHeader.msgId; - pCbMsg->classType = CbPage.pageHeader.dcs.classType; - pCbMsg->codingScheme = CbPage.pageHeader.dcs.codingScheme; - pCbMsg->recvTime = CbPage.pageHeader.recvTime; + pCbMsg->cbMsgType = CbPage->cbMsgType; + pCbMsg->msgId = CbPage->pageHeader.msgId; + pCbMsg->classType = CbPage->pageHeader.dcs.classType; + pCbMsg->codingScheme = CbPage->pageHeader.dcs.codingScheme; + pCbMsg->recvTime = CbPage->pageHeader.recvTime; cbPageMap::iterator it; int offset = 0; for (unsigned int i = 0; i < pageList.size(); i++) { - if (pageList[i].geoScope == CbPage.pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage.pageHeader.serialNum.msgCode) + if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) { MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode); - if (pageList[i].msgId == CbPage.pageHeader.msgId) + if (pageList[i].msgId == CbPage->pageHeader.msgId) { for (it = pageList[i].data.begin(); it != pageList[i].data.end(); it++) @@ -819,7 +821,7 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA pMsgInfo->msgPort.srcPort = 0; pMsgInfo->displayTime = pCbMsg->recvTime; - MSG_DEBUG("recvTime is %s", ctime(&pMsgInfo->displayTime)); + MSG_DEBUG("recvTime is %d", pMsgInfo->displayTime); int bufSize = pCbMsg->msgLength*2; @@ -872,16 +874,16 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA } -void SmsPluginCbMsgHandler::convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex) +void SmsPluginCbMsgHandler::convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S *EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex) { - pMsgInfo->msgId = (msg_message_id_t)EtwsMsg.pageHeader.msgId; + pMsgInfo->msgId = (msg_message_id_t)EtwsMsg->pageHeader.msgId; pMsgInfo->folderId = MSG_CBMSGBOX_ID; // Convert Type values pMsgInfo->msgType.mainType = MSG_SMS_TYPE; - if (EtwsMsg.cbMsgType == SMS_CBMSG_TYPE_ETWS) + if (EtwsMsg->cbMsgType == SMS_CBMSG_TYPE_ETWS) pMsgInfo->msgType.subType = MSG_ETWS_SMS; pMsgInfo->storageId = MSG_STORAGE_PHONE; @@ -897,20 +899,20 @@ void SmsPluginCbMsgHandler::convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S EtwsMsg, MS pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN; pMsgInfo->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN; - getDisplayName(EtwsMsg.pageHeader.msgId, pMsgInfo->addressList[0].addressVal, simIndex); + getDisplayName(EtwsMsg->pageHeader.msgId, pMsgInfo->addressList[0].addressVal, simIndex); MSG_SEC_DEBUG("%s", pMsgInfo->addressList[0].addressVal); pMsgInfo->msgPort.valid = false; pMsgInfo->msgPort.dstPort = 0; pMsgInfo->msgPort.srcPort = 0; - pMsgInfo->displayTime = EtwsMsg.pageHeader.recvTime; - MSG_DEBUG("recvTime is %s", ctime(&pMsgInfo->displayTime)); - MSG_DEBUG("LENGTH %d", EtwsMsg.pageLength); + pMsgInfo->displayTime = EtwsMsg->pageHeader.recvTime; + MSG_DEBUG("recvTime is %d", pMsgInfo->displayTime); + MSG_DEBUG("LENGTH %d", EtwsMsg->pageLength); pMsgInfo->bTextSms = true; - pMsgInfo->dataSize = EtwsMsg.pageLength; + pMsgInfo->dataSize = EtwsMsg->pageLength; memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData)); - memcpy(pMsgInfo->msgData, EtwsMsg.pageData, pMsgInfo->dataSize); + memcpy(pMsgInfo->msgData, EtwsMsg->pageData, pMsgInfo->dataSize); } int SmsPluginCbMsgHandler::convertTextToUtf8 (unsigned char* outBuf, int outBufSize, SMS_CBMSG_S* pCbMsg) @@ -939,40 +941,40 @@ int SmsPluginCbMsgHandler::convertTextToUtf8 (unsigned char* outBuf, int outBufS return convertedTextSize; } -void SmsPluginCbMsgHandler::addToPageList(SMS_CBMSG_PAGE_S CbPage) +void SmsPluginCbMsgHandler::addToPageList(SMS_CBMSG_PAGE_S *CbPage) { CB_PAGE_INFO_S tmpInfo; - tmpInfo.geoScope = CbPage.pageHeader.serialNum.geoScope; - tmpInfo.msgCode = CbPage.pageHeader.serialNum.msgCode; - tmpInfo.updateNum = CbPage.pageHeader.serialNum.updateNum; - tmpInfo.msgId = CbPage.pageHeader.msgId; - tmpInfo.totalPages = CbPage.pageHeader.totalPages; + tmpInfo.geoScope = CbPage->pageHeader.serialNum.geoScope; + tmpInfo.msgCode = CbPage->pageHeader.serialNum.msgCode; + tmpInfo.updateNum = CbPage->pageHeader.serialNum.updateNum; + tmpInfo.msgId = CbPage->pageHeader.msgId; + tmpInfo.totalPages = CbPage->pageHeader.totalPages; tmpInfo.pageCnt = 1; - tmpInfo.totalSize = CbPage.pageLength; + tmpInfo.totalSize = CbPage->pageLength; - pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage.pageHeader.page, CbPage); + pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage->pageHeader.page, *CbPage); tmpInfo.data.insert(newData); - MSG_DEBUG("MSG DATA : %s", CbPage.pageData); + MSG_DEBUG("MSG DATA : %s", CbPage->pageData); MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.pageData); pageList.push_back(tmpInfo); } -void SmsPluginCbMsgHandler::removeFromPageList(SMS_CBMSG_PAGE_S CbPage) +void SmsPluginCbMsgHandler::removeFromPageList(SMS_CBMSG_PAGE_S *CbPage) { unsigned int index; for (index = 0; index < pageList.size(); index++) { - if (pageList[index].geoScope == CbPage.pageHeader.serialNum.geoScope && pageList[index].msgCode == CbPage.pageHeader.serialNum.msgCode) + if (pageList[index].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[index].msgCode == CbPage->pageHeader.serialNum.msgCode) { MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[index].geoScope, pageList[index].msgCode); - if (pageList[index].msgId == CbPage.pageHeader.msgId) break; + if (pageList[index].msgId == CbPage->pageHeader.msgId) break; } } @@ -1186,6 +1188,6 @@ void SmsPluginCbMsgHandler::getDisplayName(unsigned short MsgId, char *pDisplayN } } - sprintf(pDisplayName, "[%d]", MsgId); + snprintf(pDisplayName, MAX_ADDRESS_VAL_LEN + 1, "[%d]", MsgId); } diff --git a/plugin/sms_plugin/SmsPluginConcatHandler.cpp b/plugin/sms_plugin/SmsPluginConcatHandler.cpp index 9d05c55..07101ac 100755 --- a/plugin/sms_plugin/SmsPluginConcatHandler.cpp +++ b/plugin/sms_plugin/SmsPluginConcatHandler.cpp @@ -145,12 +145,12 @@ void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPD int dataSize = 0; char* pUserData = NULL; bool simSlotSizeOver = false; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); msgInfo.sim_idx = msg.simIndex; dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData); @@ -189,7 +189,7 @@ void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPD (SmsPluginSimMsg::instance()->checkSimMsgFull(msg.simIndex, segCnt) == true)) { char keyName[MAX_VCONFKEY_NAME_LEN]; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_TOTAL_COUNT, msg.simIndex); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, msg.simIndex); int totalCnt = MsgSettingGetInt(keyName); if (segCnt > totalCnt) { @@ -285,12 +285,12 @@ void SmsPluginConcatHandler::handleSimConcatMsg(struct tapi_handle *handle, SMS_ int dataSize = 0; char* pUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); msgInfo.sim_idx = msg.simIndex; dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData); @@ -365,12 +365,12 @@ void SmsPluginConcatHandler::handleSimConcatMsg(struct tapi_handle *handle, SMS_ int dataSize = 0; char* pUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); msgInfo.sim_idx = msg.simIndex; dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData); @@ -472,7 +472,7 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim int dataSize = 0; char* pUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; @@ -551,7 +551,7 @@ void SmsPluginConcatHandler::handleBrokenMsg() { int index = 0, dataSize = 0; char* pUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; @@ -706,7 +706,8 @@ int SmsPluginConcatHandler::makeConcatUserData(unsigned short MsgRef, int simInd MSG_DEBUG("totalSize [%d]", totalSize); - *ppTotalData = new char[totalSize]; + if (*ppTotalData == NULL) + *ppTotalData = new char[totalSize]; for (it = concatList[i].data.begin(); it != concatList[i].data.end(); it++) { memcpy(*ppTotalData+offset, it->second.data, it->second.length); diff --git a/plugin/sms_plugin/SmsPluginDSHandler.cpp b/plugin/sms_plugin/SmsPluginDSHandler.cpp index 5339c13..64939ff 100755 --- a/plugin/sms_plugin/SmsPluginDSHandler.cpp +++ b/plugin/sms_plugin/SmsPluginDSHandler.cpp @@ -26,10 +26,8 @@ extern "C" #include <TelNetwork.h> #include <ITapiNetwork.h> #include <ITapiSim.h> -#if 0 #include <telephony_common.h> #include <telephony_sim.h> -#endif } /*================================================================================================== @@ -40,6 +38,8 @@ SmsPluginDSHandler* SmsPluginDSHandler::pInstance = NULL; SmsPluginDSHandler::SmsPluginDSHandler() { + cp_list = NULL; + memset(&handle_list, 0x00, sizeof(handle_list)); } @@ -130,7 +130,7 @@ int SmsPluginDSHandler::getSimIndex(struct tapi_handle *handle) void SmsPluginDSHandler::getDefaultNetworkSimId(int *simId) { - TelNetworkDefaultDataSubs_t defaultSimId; + TelNetworkDefaultDataSubs_t defaultSimId = TAPI_NETWORK_DEFAULT_DATA_SUBS_UNKNOWN; int tapi_ret = TAPI_API_SUCCESS; @@ -182,7 +182,6 @@ int SmsPluginDSHandler::getActiveSimCount() int SmsPluginDSHandler::getSubscriberId(unsigned int simIndex, char **subscriber_id) { -#if 0 if (simIndex <= 0 || simIndex > (unsigned int)handle_list.count) { MSG_DEBUG("Invalid SIM index"); return MSG_ERR_INVALID_PARAMETER; @@ -209,6 +208,5 @@ int SmsPluginDSHandler::getSubscriberId(unsigned int simIndex, char **subscriber MSG_DEBUG("Deinitialize failed!!!"); } -#endif return MSG_SUCCESS; } diff --git a/plugin/sms_plugin/SmsPluginEventHandler.cpp b/plugin/sms_plugin/SmsPluginEventHandler.cpp index 46956d8..7416749 100755 --- a/plugin/sms_plugin/SmsPluginEventHandler.cpp +++ b/plugin/sms_plugin/SmsPluginEventHandler.cpp @@ -14,9 +14,9 @@ * limitations under the License. */ -#include<time.h> -#include<stdio.h> -#include<stdlib.h> +#include <time.h> +#include <stdio.h> +#include <stdlib.h> #include <errno.h> #include "MsgDebug.h" @@ -45,6 +45,7 @@ SmsPluginEventHandler::SmsPluginEventHandler() { /** Initialize global parameters */ memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S)); + memset(&sentInfo, 0x00, sizeof(SMS_SENT_INFO_S)); pSimCnt = NULL; devStatus = false; @@ -132,7 +133,7 @@ void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TP memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); if (pTpdu->tpduType == SMS_TPDU_DELIVER) { @@ -251,7 +252,7 @@ void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TP MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType); MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType); MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType); - MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime)); + MSG_DEBUG("msgInfo.displayTime : %d", msgInfo.displayTime); MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid); MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType); MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize); @@ -512,15 +513,15 @@ void SmsPluginEventHandler::convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu /** What kind of time has to be saved?? (temporary store time) */ - time_t curTime; - localtime(&curTime); - - msgInfo->displayTime = curTime; +//CID 315780 (#1 of 1): Other violation (DC.SECURE_CODING_CRITICAL) +//dont_call: Calling localtime(time_t const *) is a DC.SECURE_CODING_CRITICAL defect. +// time_t curTime; +// localtime(&curTime); /** Convert Address values */ msgInfo->nAddressCnt = 1; - msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; + msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; memset(msgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S)); msgInfo->addressList[addressListCnt].addressType = MSG_ADDRESS_TYPE_PLMN; @@ -528,7 +529,7 @@ void SmsPluginEventHandler::convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu /**exception operation for none userdata */ if (pTpdu->userData.length == 0) { - sprintf(msgInfo->msgText, "[Broken Message]"); + snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "[Broken Message]"); msgInfo->dataSize = strlen(msgInfo->msgText); return; } @@ -575,7 +576,7 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp MSG_DEBUG("timezone : %d", pTpdu->timeStamp.time.absolute.timeZone); char displayTime[32]; - struct tm * timeTM; + struct tm timeTM; struct tm timeinfo; memset(&timeinfo, 0x00, sizeof(tm)); @@ -601,16 +602,16 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4)); - timeTM = localtime(&rawtime); + localtime_r(&rawtime, &timeTM); memset(displayTime, 0x00, sizeof(displayTime)); - strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM); + strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM); MSG_DEBUG("displayTime [%s]", displayTime); rawtime -= timezone; - timeTM = localtime(&rawtime); + localtime_r(&rawtime, &timeTM); memset(displayTime, 0x00, sizeof(displayTime)); - strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM); + strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM); MSG_DEBUG("displayTime [%s]", displayTime); } } @@ -748,7 +749,7 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp return; } else if (pTpdu->userData.length > MAX_MSG_TEXT_LEN) { - sprintf(msgInfo->msgText, "[Broken Message]"); + snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "[Broken Message]"); msgInfo->dataSize = strlen(msgInfo->msgData); return; } diff --git a/plugin/sms_plugin/SmsPluginMain.cpp b/plugin/sms_plugin/SmsPluginMain.cpp index 05cf72c..6cd6d0d 100755 --- a/plugin/sms_plugin/SmsPluginMain.cpp +++ b/plugin/sms_plugin/SmsPluginMain.cpp @@ -219,7 +219,7 @@ msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo) // Check SIM is present or not char keyName[MAX_VCONFKEY_NAME_LEN] = {0,}; - sprintf(keyName, "%s/%d", MSG_SIM_CHANGED, pReqInfo->msgInfo.sim_idx); + 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) @@ -292,7 +292,7 @@ msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMs { // Check SIM is present or not char keyName[MAX_VCONFKEY_NAME_LEN]={0,}; - sprintf(keyName, "%s/%d", MSG_SIM_CHANGED, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, sim_idx); MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { @@ -323,7 +323,7 @@ msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId { // Check SIM is present or not char keyName[MAX_VCONFKEY_NAME_LEN]={0,}; - sprintf(keyName, "%s/%d", MSG_SIM_CHANGED, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, sim_idx); MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { diff --git a/plugin/sms_plugin/SmsPluginSatHandler.cpp b/plugin/sms_plugin/SmsPluginSatHandler.cpp index ab75e1a..1ca9df7 100755 --- a/plugin/sms_plugin/SmsPluginSatHandler.cpp +++ b/plugin/sms_plugin/SmsPluginSatHandler.cpp @@ -550,7 +550,7 @@ int SmsPluginSatHandler::handleSatTpdu(unsigned char *pTpdu, unsigned char TpduL dcs.codingScheme = SMS_CHARSET_7BIT; char* pDcs = NULL; - AutoPtr<char> dcsBuf(&pDcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&pDcs, unique_ptr_deleter); SmsPluginParamCodec::encodeDCS(&dcs, &pDcs); diff --git a/plugin/sms_plugin/SmsPluginSetting.cpp b/plugin/sms_plugin/SmsPluginSetting.cpp index 32bf2d5..cf88ba7 100755 --- a/plugin/sms_plugin/SmsPluginSetting.cpp +++ b/plugin/sms_plugin/SmsPluginSetting.cpp @@ -73,6 +73,7 @@ SmsPluginSetting::SmsPluginSetting() bTapiResult = false; paramCnt = 0; selectedParam = 0; + selectedSimIndex = 0; for (int i = 0; i < MAX_TELEPHONY_HANDLE_CNT; i++) bMbdnEnable[i] = false; @@ -142,8 +143,6 @@ void SmsPluginSetting::updateSimStatus(struct tapi_handle *handle) tapiRet = tel_get_sim_imsi(handle, &imsiInfo); if (tapiRet != TAPI_API_SUCCESS) { MSG_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet); - snprintf(keyName, sizeof(keyName), "%s/%d", MSG_NATIONAL_SIM, simIndex); - MsgSettingSetBool(keyName, false); } /* Save Subcriber ID */ @@ -154,7 +153,8 @@ void SmsPluginSetting::updateSimStatus(struct tapi_handle *handle) MSG_DEBUG("getSubscriberId() is failed"); } else { snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SUBS_ID, simIndex); - MsgSettingSetString(keyName, subscriberId); + if (MsgSettingSetString(keyName, subscriberId) != MSG_SUCCESS) + MSG_DEBUG("Fail MsgSettingSetString"); } g_free(subscriberId); subscriberId = NULL; @@ -886,7 +886,7 @@ bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt) err = MsgStoAddCBChannelInfo(dbHandle, const_cast<MSG_CB_CHANNEL_S*>(&pCbOpt->channelData),i); if (err != MSG_SUCCESS) { MSG_DEBUG("MsgStoAddCBChannelInfo is failed [%d]", err); - return MSG_ERR_SET_SETTING; + return false; } } @@ -1728,7 +1728,7 @@ void SmsPluginSetting::deliverVoiceMsgNoti(int simIndex, int mwiCnt) MSG_MESSAGE_INFO_S msgInfo = {0,}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); msgInfo.addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; memset(msgInfo.addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S)); diff --git a/plugin/sms_plugin/SmsPluginSimMsg.cpp b/plugin/sms_plugin/SmsPluginSimMsg.cpp index 6ba9ac3..4a73e7b 100755 --- a/plugin/sms_plugin/SmsPluginSimMsg.cpp +++ b/plugin/sms_plugin/SmsPluginSimMsg.cpp @@ -49,6 +49,9 @@ SmsPluginSimMsg::SmsPluginSimMsg() bTapiResult = false; memset(&simMsgDataInfo, 0x00, sizeof(simMsgDataInfo)); memset(simIdList, 0, sizeof(int) * MAX_SIM_SMS_NUM); + memset(&simMsgCnt, 0x00, sizeof(simMsgCnt)); + memset(&simMsgInfo, 0x00, sizeof(simMsgInfo)); + memset(&simAddrInfo, 0x00, sizeof(simAddrInfo)); } @@ -297,7 +300,7 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, char keyName[MAX_VCONFKEY_NAME_LEN]; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx); usedCnt = MsgSettingGetInt(keyName); usedCnt++; @@ -442,26 +445,27 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD; MSG_MESSAGE_INFO_S *tmpSimMsgInfo = (MSG_MESSAGE_INFO_S *)calloc(1, sizeof(MSG_MESSAGE_INFO_S)); - memcpy(tmpSimMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); + if (tmpSimMsgInfo) { + memcpy(tmpSimMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); - tmpSimMsgInfo->msgId = replaceMsgId; + tmpSimMsgInfo->msgId = replaceMsgId; - tmpSimMsgInfo->addressList = NULL; - tmpSimMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; - memcpy(&tmpSimMsgInfo->addressList[0], &pMsgInfo->addressList[0], sizeof(MSG_ADDRESS_INFO_S)); + tmpSimMsgInfo->addressList = NULL; + tmpSimMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; + memcpy(&tmpSimMsgInfo->addressList[0], &pMsgInfo->addressList[0], sizeof(MSG_ADDRESS_INFO_S)); - tapiRet = tel_write_sms_in_sim(handle, &simSmsData, TapiEventSaveClass2Msg, tmpSimMsgInfo); + tapiRet = tel_write_sms_in_sim(handle, &simSmsData, TapiEventSaveClass2Msg, tmpSimMsgInfo); - if (tapiRet == TAPI_API_SUCCESS) { - MSG_DEBUG("######## tel_write_sms_in_sim Success !!!, segNum = [%d] #######", segCnt); - } else { - MSG_DEBUG("######## tel_write_sms_in_sim Fail !!! return : [%d] #######", tapiRet); + if (tapiRet == TAPI_API_SUCCESS) { + MSG_DEBUG("######## tel_write_sms_in_sim Success !!!, segNum = [%d] #######", segCnt); + } else { + MSG_DEBUG("######## tel_write_sms_in_sim Fail !!! return : [%d] #######", tapiRet); - SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_ERR_STORAGE_ERROR); + SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_ERR_STORAGE_ERROR); - return MSG_ERR_PLUGIN_STORAGE; + return MSG_ERR_PLUGIN_STORAGE; + } } - msg_sim_id_t retSimId; if (!getSimEvent(&retSimId)) return MSG_ERR_PLUGIN_STORAGE; @@ -499,10 +503,10 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t S MSG_DEBUG("######## Deleting Msg was Successful !!! SIM ID : [%d] #######", SimId); char keyName[MAX_VCONFKEY_NAME_LEN]; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_USED_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx); usedCnt = MsgSettingGetInt(keyName); memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_TOTAL_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx); totalCnt = MsgSettingGetInt(keyName); if (usedCnt == totalCnt) @@ -522,7 +526,7 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t S usedCnt--; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_USED_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx); if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS) { @@ -542,10 +546,10 @@ bool SmsPluginSimMsg::checkSimMsgFull(msg_sim_slot_id_t sim_idx, unsigned int Se char keyName[MAX_VCONFKEY_NAME_LEN]; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_USED_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx); usedCnt = MsgSettingGetInt(keyName); memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_TOTAL_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx); totalCnt = MsgSettingGetInt(keyName); MSG_DEBUG("Segment Count [%d]", SegCnt); @@ -908,7 +912,8 @@ void SmsPluginSimMsg::setSaveClass2MsgEvent(struct tapi_handle *handle, int simI if (isNewSimMsg == true) { char keyName[MAX_VCONFKEY_NAME_LEN]; - sprintf(keyName, "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx); + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx); usedCnt = MsgSettingGetInt(keyName); usedCnt++; diff --git a/plugin/sms_plugin/SmsPluginStorage.cpp b/plugin/sms_plugin/SmsPluginStorage.cpp index 33eafa4..5f42011 100755 --- a/plugin/sms_plugin/SmsPluginStorage.cpp +++ b/plugin/sms_plugin/SmsPluginStorage.cpp @@ -38,11 +38,8 @@ SmsPluginStorage* SmsPluginStorage::pInstance = NULL; SmsPluginStorage::SmsPluginStorage() { -/*** No need to connect DB anymore. - if (dbHandle->connect() != MSG_SUCCESS) { - MSG_DEBUG("DB Connect Fail"); - } -***/ + memset(&msgInfo, 0x00, sizeof(msgInfo)); + memset(&addrInfo, 0x00, sizeof(addrInfo)); } @@ -130,7 +127,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE MSG_ID = %d AND MSG_REF > 0;", MSGFW_SMS_REPORT_TABLE_NAME, msgId); - if (dbHandle->getTable(sqlQuery, &rowCnt) != MSG_SUCCESS) { + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -768,7 +765,7 @@ void* SmsPluginStorage::class2_thread(void *data) } MSG_END(); - return NULL; + return (void *)err; } @@ -940,7 +937,7 @@ msg_error_t SmsPluginStorage::isReceivedCBMessage(SMS_CBMSG_PAGE_S CbPage) MSGFW_RECEIVED_CB_MSG_TABLE_NAME, CbPage.pageHeader.serialNum.geoScope, CbPage.pageHeader.serialNum.msgCode,CbPage.pageHeader.msgId, CbPage.pageHeader.serialNum.updateNum); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); MSG_DEBUG("rowCnt: %d", rowCnt); dbHandle->freeTable(); @@ -982,7 +979,7 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou { msg_error_t err = MSG_SUCCESS; - int rowCnt = 0, index = 3; + int rowCnt = 0, index = 0; MsgDbHandler *dbHandle = getDbHandle(); @@ -992,7 +989,7 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONTENT_TYPE, APP_ID, APPCODE FROM %s", MSGFW_PUSH_CONFIG_TABLE_NAME); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); MSG_DEBUG("rowCnt: %d", rowCnt); if (err == MSG_ERR_DB_NORECORD) { diff --git a/plugin/sms_plugin/SmsPluginTpduCodec.cpp b/plugin/sms_plugin/SmsPluginTpduCodec.cpp index 2b17797..789f14b 100755 --- a/plugin/sms_plugin/SmsPluginTpduCodec.cpp +++ b/plugin/sms_plugin/SmsPluginTpduCodec.cpp @@ -104,13 +104,13 @@ int SmsPluginTpduCodec::encodeSubmit(const SMS_SUBMIT_S *pSubmit, char *pTpdu) int offset = 0, length = 0, encodeSize = 0; char* address = NULL; - AutoPtr<char> addressBuf(&address); + unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter); char* dcs = NULL; - AutoPtr<char> dcsBuf(&dcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter); char* vpTime = NULL; - AutoPtr<char> vpBuf(&vpTime); + unique_ptr<char*, void(*)(char**)> vpBuf(&vpTime, unique_ptr_deleter); //TP-MTI pTpdu[offset] = 0x01; @@ -213,13 +213,13 @@ int SmsPluginTpduCodec::encodeDeliver(const SMS_DELIVER_S *pDeliver, char *pTpdu int offset = 0, length = 0, encodeSize = 0; char* address = NULL; - AutoPtr<char> addressBuf(&address); + unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter); char* dcs = NULL; - AutoPtr<char> dcsBuf(&dcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter); char* scts = NULL; - AutoPtr<char> timeBuf(&scts); + unique_ptr<char*, void(*)(char**)> timeBuf(&scts, unique_ptr_deleter); // TP-MTI : 00 pTpdu[offset] = 0x00; @@ -303,7 +303,7 @@ int SmsPluginTpduCodec::encodeDeliverReport(const SMS_DELIVER_REPORT_S *pDeliver int length = 0; char* dcs = NULL; - AutoPtr<char> dcsBuf(&dcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter); length = SmsPluginParamCodec::encodeDCS(&pDeliverRep->dcs, &dcs); memcpy(&(pTpdu[offset]), dcs, length); @@ -334,13 +334,13 @@ int SmsPluginTpduCodec::encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep int offset = 0, length = 0; char* address = NULL; - AutoPtr<char> addressBuf(&address); + unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter); char* scts = NULL; - AutoPtr<char> sctsBuf(&scts); + unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter); char* dt = NULL; - AutoPtr<char> dtBuf(&dt); + unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter); // TP-MTI : 10 pTpdu[offset] = 0x02; @@ -393,7 +393,7 @@ int SmsPluginTpduCodec::encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep int length = 0; char* dcs = NULL; - AutoPtr<char> dcsBuf(&dcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter); length = SmsPluginParamCodec::encodeDCS(&pStatusRep->dcs, &dcs); memcpy(&(pTpdu[offset]), dcs, length); @@ -612,13 +612,13 @@ int SmsPluginTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduL int offset = 0, udLen = 0; char* address = NULL; - AutoPtr<char> addressBuf(&address); + unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter); char* scts = NULL; - AutoPtr<char> sctsBuf(&scts); + unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter); char* dt = NULL; - AutoPtr<char> dtBuf(&dt); + unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter); // TP-MMS if (pTpdu[offset] & 0x04) diff --git a/plugin/sms_plugin/SmsPluginTransport.cpp b/plugin/sms_plugin/SmsPluginTransport.cpp index 2a9b236..37d0675 100755 --- a/plugin/sms_plugin/SmsPluginTransport.cpp +++ b/plugin/sms_plugin/SmsPluginTransport.cpp @@ -53,6 +53,7 @@ SmsPluginTransport::SmsPluginTransport() msgRef = 0x00; msgRef8bit = 0x00; msgRef16bit = 0x0000; + curStatus = 0x00; memset(&curMoCtrlData, 0x00, sizeof(curMoCtrlData)); } @@ -104,7 +105,7 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo) //contacts-service is not used for gear #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, 0, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList); -#else +#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED //contactNameOrder is never used MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList); #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED @@ -861,7 +862,7 @@ void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, int fileSize = 0; char* pFileData = NULL; - AutoPtr<char> FileBuf(&pFileData); + unique_ptr<char*, void(*)(char**)> FileBuf(&pFileData, unique_ptr_deleter); // Read Message Data from File if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false) @@ -901,7 +902,7 @@ MSG_SEC_DEBUG("reply address : [%s]", pMsgInfo->replyAddress); int addrLen = 0; char* encodedAddr = NULL; - AutoPtr<char> addressBuf(&encodedAddr); + unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter); if (strlen(pMsgInfo->replyAddress) > 0) { @@ -922,6 +923,9 @@ MSG_SEC_DEBUG("reply address : [%s]", pMsgInfo->replyAddress); segSize = getSegmentSize(*pCharType, decodeLen, pMsgInfo->msgPort.valid, langId, addrLen); + if (segSize == 0) + THROW(MsgException::SMS_PLG_ERROR, "DIVIDE_BY_ZERO : %d", segSize); + pData->segCount = ceil((double)decodeLen/(double)segSize); MSG_DEBUG("segment size : [%d], pData->segCount : [%d]", segSize, pData->segCount); diff --git a/plugin/sms_plugin/SmsPluginUAManager.cpp b/plugin/sms_plugin/SmsPluginUAManager.cpp index b5b0892..fb72329 100755 --- a/plugin/sms_plugin/SmsPluginUAManager.cpp +++ b/plugin/sms_plugin/SmsPluginUAManager.cpp @@ -64,7 +64,7 @@ void SmsPluginUAManager::run() unlock(); request.msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&request.msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter); try { diff --git a/plugin/sms_plugin/SmsPluginUDCodec.cpp b/plugin/sms_plugin/SmsPluginUDCodec.cpp index 2b821be..d5b51e6 100755 --- a/plugin/sms_plugin/SmsPluginUDCodec.cpp +++ b/plugin/sms_plugin/SmsPluginUDCodec.cpp @@ -19,6 +19,7 @@ #include "SmsPluginParamCodec.h" #include "SmsPluginUDCodec.h" +using namespace std; /*================================================================================================== IMPLEMENTATION OF SmsPluginUDCodec - Member Functions @@ -519,7 +520,7 @@ int SmsPluginUDCodec::encodeHeader(const SMS_UDH_S header, char *pEncodeHeader) int offset = 0, addrLen = 0; char* encodedAddr = NULL; - AutoPtr<char> addressBuf(&encodedAddr); + unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter); switch (header.udhType) { diff --git a/plugin/sms_plugin/SmsPluginWapPushHandler.cpp b/plugin/sms_plugin/SmsPluginWapPushHandler.cpp index fb02f6e..58ac6ce 100755 --- a/plugin/sms_plugin/SmsPluginWapPushHandler.cpp +++ b/plugin/sms_plugin/SmsPluginWapPushHandler.cpp @@ -720,6 +720,7 @@ SmsPluginWapPushHandler* SmsPluginWapPushHandler::pInstance = NULL; SmsPluginWapPushHandler::SmsPluginWapPushHandler() { memset(&tmpAddress, 0x00, sizeof(tmpAddress)); + memset(&tmpTimeStamp, 0x00, sizeof(tmpTimeStamp)); } @@ -843,21 +844,21 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi unsigned long PDUTypeDataLen = DataSize; char* pPushHeader = NULL; - AutoPtr<char> pushHeaderBuf(&pPushHeader); + unique_ptr<char*, void(*)(char**)> pushHeaderBuf(&pPushHeader, unique_ptr_deleter); unsigned long pushHeaderLen = 0; char* pPushBody = NULL; - AutoPtr<char> PushBodyBuf(&pPushBody); + unique_ptr<char*, void(*)(char**)> PushBodyBuf(&pPushBody, unique_ptr_deleter); unsigned long pushBodyLen = 0; unsigned long iPDU = 1; char* pWspHeader = NULL; - AutoPtr<char> WspHeaderBuf(&pWspHeader); + unique_ptr<char*, void(*)(char**)> WspHeaderBuf(&pWspHeader, unique_ptr_deleter); unsigned long wspHeaderLen = 0; char* pWspBody = NULL; - AutoPtr<char> WspBodyBuf(&pWspBody); + unique_ptr<char*, void(*)(char**)> WspBodyBuf(&pWspBody, unique_ptr_deleter); unsigned long wspBodyLen = 0; /** pass PDU type */ @@ -1423,7 +1424,7 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1594,7 +1595,7 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1727,7 +1728,7 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1853,7 +1854,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1893,7 +1894,7 @@ void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen) #if MSG_DRM_SUPPORT int drmRt = DRM_RETURN_SUCCESS; char* cid = NULL; - AutoPtr<char> buf(&cid); + unique_ptr<char*, void(*)(char**)> buf(&cid, unique_ptr_deleter); MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message."); drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE; @@ -2215,12 +2216,12 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un unsigned long currentLength; char* encodedHeader = NULL; - AutoPtr<char> encodedHeaderbuf(&encodedHeader); + unique_ptr<char*, void(*)(char**)> encodedHeaderbuf(&encodedHeader, unique_ptr_deleter); char* outTemper = NULL; char* temper = NULL; - AutoPtr<char> temperbuf(&temper); + unique_ptr<char*, void(*)(char**)> temperbuf(&temper, unique_ptr_deleter); unsigned char track; unsigned long iEncodedHeader = 0; @@ -2246,7 +2247,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un for (loop = 0 ; loop<(int)encodedHeaderLen; loop++) { char szTempBuf[5]; szTempBuf[0] = 0x00; - sprintf( szTempBuf, "%2X ", sEncodedHeader[loop] ); + snprintf( szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop] ); if (AcStrlen( szBuf ) + 7 < 64) { strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 ); @@ -2453,7 +2454,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un /* If parameter exist */ if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, ¶m); strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } @@ -2560,7 +2561,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un /* If there is a parameter */ if (tempLen < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, ¶m); if (param != NULL) { strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1); @@ -2606,7 +2607,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (tempLen < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeQValue( fieldValueLen - tempLen, fieldValue + tempLen, ¶m ); strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } @@ -2632,7 +2633,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]); else */ - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2674,7 +2675,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]); else */ - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1); } break; @@ -2695,7 +2696,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x12 : { char* decodedString = NULL; - AutoPtr<char> decodedStringbuf(&decodedString); + unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString); strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 ); } @@ -2729,7 +2730,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x21 : if (fieldValue[0] == 0x80) { char* addString = NULL; - AutoPtr<char> addStringbuf(&addString); + unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter); wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString ); strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } else { @@ -2738,7 +2739,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m ); if (param != NULL) { strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2758,7 +2759,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un break; if (fieldValue[0] == 0x80) { char* addString = NULL; - AutoPtr<char> addStringbuf(&addString); + unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter); wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString ); strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } else { @@ -2775,7 +2776,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, ¶m ); if (param != NULL) { strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2801,7 +2802,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un */ last = first + contentsLength - 1; - sprintf( (char*)temp, "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len ); + snprintf( (char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2810,7 +2811,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x08 : { char* cacheString = NULL; - AutoPtr<char> cacheStringbuf(&cacheString); + unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter); wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString ); strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2824,7 +2825,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un } else { if (1 < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue, fieldValueLen, ¶m ); if (param != NULL) { @@ -2856,7 +2857,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un first = wspRetriveUintvarDecode( fieldValue, &iField ); last = wspRetriveUintvarDecode( fieldValue, &iField ); - sprintf( (char*)temp, "%u-%u", (unsigned int)first, (unsigned int)last ); + snprintf( (char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } if (fieldValue[0] == 0x81) { @@ -2865,7 +2866,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un suffix = wspRetriveUintvarDecode( fieldValue, &iField ); - sprintf( (char*)temp, "-%u", (unsigned int)suffix ); + snprintf( (char*)temp, sizeof(temp), "-%u", (unsigned int)suffix ); } break; @@ -2873,7 +2874,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x25 : if (fieldValue[0] == 0x80) { char* temp = NULL; - AutoPtr<char> tempbuf(&temp); + unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2882,7 +2883,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (fieldValue[0] == 0x81) { unsigned char temp[16]; - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen )); + snprintf( (char*)temp, 16, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2937,7 +2938,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (1 < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m ); if (param != NULL) { @@ -2966,7 +2967,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) { /* copy warn-date */ char* decodedString = NULL; - AutoPtr<char> decodedStringbuf(&decodedString); + unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString ); strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 ); } @@ -3058,7 +3059,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsig if (qValue > 100) { qValue = qValue - 100; qValue = qValue / 1000; - sprintf( (char*)*pDecodedString, "; q=%.3f", qValue ); + snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.3f", qValue ); } else { /* qValue variable is divided by 100. And it's multiplied by 100. It's to resolve problem of changed 0.01 of qValue. */ @@ -3067,9 +3068,9 @@ void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsig qValue = qValue / 100; qValueTemp = (unsigned long)(qValue * 100); if (0 == (qValueTemp % 10 )) - sprintf( (char*)*pDecodedString, "; q=%.1f", qValue ); + snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.1f", qValue ); else - sprintf( (char*)*pDecodedString, "; q=%.2f", qValue ); + snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.2f", qValue ); } return; } @@ -3138,7 +3139,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns } strncat( (char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 ); - strncat( (char*)param, (char*)(data + AcStrlen( (char*)param )), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1); + strncat( (char*)param, (char*)(data + strlen( (char*)param )), WSP_STANDARD_STR_LEN_MAX-strlen((char*)param)-1); *pParam = param; @@ -3164,7 +3165,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n"); return; } else { - sprintf( (char*)param, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 )); + snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 )); } break; case 0x08 : @@ -3174,7 +3175,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n"); return; } else { - sprintf( (char*)param, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 )); + snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 )); } break; case 0x05 : @@ -3241,31 +3242,41 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsigned char* data, char**pDecodedString) { - *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX]; + char* param = NULL; - if (*pDecodedString == NULL) { + param = new char[WSP_STANDARD_STR_LEN_MAX]; + + if (param == NULL) { MSG_DEBUG("WspLHeaderDecodeCharset:MemAlloc failed\n"); + *pDecodedString = NULL; return; } - strncpy( (char*)*pDecodedString, "charset=", WSP_STANDARD_STR_LEN_MAX-1); + strncpy( (char*)param, "charset=", WSP_STANDARD_STR_LEN_MAX-1); if (data[0] > 0x80) { unsigned long code = wspHeaderDecodeInteger(data ); unsigned long i = 0; while (wspCharset[i].charsetCode != code) { if (wspCharset[i].charsetCode == 0xffff) { + *pDecodedString = param; return; } i++; } - strncat( (char*)*pDecodedString, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pDecodedString)-1 ); + strncat( (char*)param, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 ); } else { - unsigned long lastLen = AcStrlen((char*)*pDecodedString); - memcpy( (char*)(*pDecodedString + lastLen), data, (size_t)length ); - *pDecodedString[length + lastLen] = '\0'; + unsigned long lastLen = AcStrlen((char*)param); + if (length + lastLen < WSP_STANDARD_STR_LEN_MAX - 1) { + memcpy( (char*)(param + lastLen), data, (size_t)length ); + param[length + lastLen] = '\0'; + } else { + memcpy( (char*)(param + lastLen), data, WSP_STANDARD_STR_LEN_MAX - lastLen - 1 ); + param[WSP_STANDARD_STR_LEN_MAX-1] = '\0'; + } } + *pDecodedString = param; return; } @@ -3287,7 +3298,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsi /* typed version */ unsigned char majorVer = ((data[0] & 0x7f ) >> 4 ); unsigned char minorVer = data[0] & 0x0f; - sprintf( (char*)*pDecodedString, "level=%u.%u", majorVer, minorVer ); + snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "level=%u.%u", majorVer, minorVer ); } return; @@ -3297,7 +3308,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsi void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, unsigned char* data, char** pDecodedString ) { time_t lTime; - struct tm* pTMData; + struct tm pTMData; MSG_DEBUG("WspLHeaderDecodeDateValue: \n" ); @@ -3310,19 +3321,13 @@ void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, un lTime = wspHeaderDecodeIntegerByLength(data, length); - pTMData = (struct tm*)gmtime((const time_t* )&lTime); - - if (pTMData == NULL) { - MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail \n" ); - strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1); - return; - } + (struct tm*)gmtime_r((const time_t* )&lTime, &pTMData); /* check date value validity */ { - if (( pTMData->tm_wday > 6 ) || (pTMData->tm_mon > 11 ) || (pTMData->tm_mday > 31 )) + if (( pTMData.tm_wday > 6 ) || (pTMData.tm_mon > 11 ) || (pTMData.tm_mday > 31 )) { - MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData->tm_wday, pTMData->tm_mon, pTMData->tm_mday ); + MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData.tm_wday, pTMData.tm_mon, pTMData.tm_mday ); strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1); return; } @@ -3334,25 +3339,25 @@ void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, un { /* UNIX asciitime function */ case UNIX_DATE_TYPE : - snprintf( (char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon], - pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 ); + snprintf( (char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon], + pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900 ); break; case RFC1123_DATE_TYPE : - snprintf( (char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData->tm_wday], pTMData->tm_mday, - wspMonth[pTMData->tm_mon], pTMData->tm_year + 1900, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec ); + snprintf( (char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData.tm_wday], pTMData.tm_mday, + wspMonth[pTMData.tm_mon], pTMData.tm_year + 1900, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec ); break; case RFC850_DATE_TYPE : /* Have some Y2K Problems */ /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used. */ - snprintf( (char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData->tm_wday], pTMData->tm_mday, - wspMonth[pTMData->tm_mon], pTMData->tm_year % CENTURY, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec ); + snprintf( (char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData.tm_wday], pTMData.tm_mday, + wspMonth[pTMData.tm_mon], pTMData.tm_year % CENTURY, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec ); break; } #endif /**UNIX_DATE_TYPE : */ - snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon], - pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 ); + snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon], + pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900 ); return; @@ -3401,11 +3406,11 @@ void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, u /* skip 'basic' code */ iField++; memset(authStr, 0x00, sizeof(authStr)); - snprintf(authStr, sizeof(authStr), "%%%us", sizeof(userId)); + snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId)); sscanf((char*)(fieldValue + iField), authStr, userId ); iField = iField + AcStrlen( (char*)userId ) + 1; memset(authStr, 0x00, sizeof(authStr)); - snprintf(authStr, sizeof(authStr), "%%%us", sizeof(passWd)); + snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(passWd)); sscanf( (char*)(fieldValue + iField), authStr, passWd ); iField = iField + AcStrlen( (char*)userId ) + 1; snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX*2), "basic %s/%s", userId, passWd ); @@ -3430,7 +3435,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueL /* skip 'basic' code */ iField++; memset(authStr, 0x00, sizeof(authStr)); - snprintf(authStr, sizeof(authStr), "%%%us", sizeof(userId)); + snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId)); sscanf( (char*)(fieldValue + iField), authStr, userId ); iField = iField + AcStrlen( (char*)userId ) + 1; diff --git a/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h b/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h index ae04ee5..c351889 100755 --- a/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h +++ b/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h @@ -80,14 +80,14 @@ private: unsigned short encodeCbSerialNum ( SMS_CBMSG_SERIAL_NUM_S snFields ); int CMAS_class(unsigned short message_id); - bool checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex); - unsigned char checkCbPage(SMS_CBMSG_PAGE_S CbPage); - void MakeCbMsg(SMS_CBMSG_PAGE_S CbPage, SMS_CBMSG_S *pCbMsg); + bool checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex); + unsigned char checkCbPage(SMS_CBMSG_PAGE_S *CbPage); + void MakeCbMsg(SMS_CBMSG_PAGE_S *CbPage, SMS_CBMSG_S *pCbMsg); void convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex); - void convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex); + void convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S *EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex); int convertTextToUtf8 (unsigned char* outBuf, int outBufSize, SMS_CBMSG_S* pCbMsg); - void addToPageList(SMS_CBMSG_PAGE_S CbPage); - void removeFromPageList(SMS_CBMSG_PAGE_S CbPage); + void addToPageList(SMS_CBMSG_PAGE_S *CbPage); + void removeFromPageList(SMS_CBMSG_PAGE_S *CbPage); void decodeCbMsgDCS(unsigned char dcsData, const unsigned char *pMsgData, SMS_CBMSG_DCS_S* pDcs); void convertLangType(SMS_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType); diff --git a/plugin/sms_plugin/include/SmsPluginSimMsg.h b/plugin/sms_plugin/include/SmsPluginSimMsg.h index fed6a1a..900ddcf 100755 --- a/plugin/sms_plugin/include/SmsPluginSimMsg.h +++ b/plugin/sms_plugin/include/SmsPluginSimMsg.h @@ -47,7 +47,6 @@ public: msg_error_t saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList); msg_error_t saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInfo); void deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId); - void getSimMessageList(MSG_SIM_MSG_INFO_LIST_S **ppSimMsgList); void setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId); bool checkSimMsgFull(msg_sim_slot_id_t sim_idx, unsigned int SegCnt); diff --git a/plugin/sms_plugin/include/SmsPluginUAManager.h b/plugin/sms_plugin/include/SmsPluginUAManager.h index a23e2d2..8a50cab 100755 --- a/plugin/sms_plugin/include/SmsPluginUAManager.h +++ b/plugin/sms_plugin/include/SmsPluginUAManager.h @@ -51,8 +51,6 @@ private: static SmsPluginUAManager* pInstance; - bool bRunning; - MsgSimpleQ <SMS_REQUEST_INFO_S> smsTranQ; Mutex mx; diff --git a/proxy/CMakeLists.txt b/proxy/CMakeLists.txt index 7fbd079..984fac0 100755 --- a/proxy/CMakeLists.txt +++ b/proxy/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} -O2 -g -Wall") ########################################################## # Define Transaction Proxy @@ -37,7 +37,7 @@ FOREACH(flag ${trans_proxy_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/proxy/MsgHandleControl.cpp b/proxy/MsgHandleControl.cpp index 423e017..06a3823 100755 --- a/proxy/MsgHandleControl.cpp +++ b/proxy/MsgHandleControl.cpp @@ -125,6 +125,7 @@ void MsgHandle::write(const char *pCmdData, int cmdSize, char **ppEvent) if(!CheckEventData(tmpEvent)) { delete [] tmpEvent; + tmpEvent = NULL; } else { *ppEvent = tmpEvent; break; @@ -137,9 +138,9 @@ void MsgHandle::read(char **ppEvent) { unsigned int dataSize = 0; - dataSize = mClientSock.read(ppEvent, &dataSize); + int ret = mClientSock.read(ppEvent, &dataSize); - if (dataSize == 0) { + if (ret == CLOSE_CONNECTION_BY_SIGNAL) { THROW(MsgException::IPC_ERROR, "Server closed connection"); } } @@ -287,9 +288,10 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I // change file extension in case of java MMS msg if (pSrc->subType == MSG_SENDREQ_JAVA_MMS) { - char* pFileNameExt; + char* pFileNameExt = NULL; pFileNameExt = strstr(fileName,"DATA"); - strncpy(pFileNameExt,"JAVA", MSG_FILENAME_LEN_MAX); + if (pFileNameExt) + snprintf(pFileNameExt, strlen("JAVA")+1, "JAVA"); } MSG_SEC_DEBUG("Save Message Data into file : size[%d] name[%s]", pSrc->mmsDataSize, fileName); @@ -394,7 +396,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_HID int fileSize = 0; char* pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); pDest->dataSize = pSrc->dataSize; diff --git a/proxy/MsgHandleFilter.cpp b/proxy/MsgHandleFilter.cpp index 903ef5c..04917b6 100755 --- a/proxy/MsgHandleFilter.cpp +++ b/proxy/MsgHandleFilter.cpp @@ -44,7 +44,7 @@ msg_error_t MsgHandle::addFilter(const MSG_FILTER_S *pFilter) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -80,7 +80,7 @@ msg_error_t MsgHandle::updateFilter(const MSG_FILTER_S *pFilter) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -116,7 +116,7 @@ msg_error_t MsgHandle::deleteFilter(msg_filter_id_t FilterId) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -149,7 +149,7 @@ msg_error_t MsgHandle::getFilterList(msg_struct_list_s *pFilterList) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -192,7 +192,7 @@ msg_error_t MsgHandle::setFilterOperation(bool bSetFlag) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -229,7 +229,7 @@ msg_error_t MsgHandle::getFilterOperation(bool *pSetFlag) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -274,7 +274,7 @@ msg_error_t MsgHandle::setFilterActivation(msg_filter_id_t filter_id, bool activ // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); diff --git a/proxy/MsgHandleSetting.cpp b/proxy/MsgHandleSetting.cpp index 2553a87..151fbb4 100755 --- a/proxy/MsgHandleSetting.cpp +++ b/proxy/MsgHandleSetting.cpp @@ -21,15 +21,12 @@ #include "MsgHandle.h" -#define MSG_TYPE_CHECK(a, b) \ - ({\ - if(a != b) return MSG_ERR_INVALID_PARAMETER; \ - })\ - #define MSG_NULL_CHECK(a) \ - ({\ - if(a == NULL) return MSG_ERR_NULL_POINTER; \ - })\ + do { \ + if(a == NULL) { \ + return MSG_ERR_NULL_POINTER; \ + } \ + } while(0) /*================================================================================================== IMPLEMENTATION OF MsgHandle - Setting Member Functions @@ -68,7 +65,7 @@ msg_error_t MsgHandle::getSMSCOption(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -162,7 +159,7 @@ msg_error_t MsgHandle::setSMSCOption(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -207,7 +204,7 @@ msg_error_t MsgHandle::getCBOption(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -297,7 +294,7 @@ msg_error_t MsgHandle::setCBOption(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -339,7 +336,7 @@ msg_error_t MsgHandle::getSmsSendOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -389,7 +386,7 @@ msg_error_t MsgHandle::setSmsSendOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -431,7 +428,7 @@ msg_error_t MsgHandle::getMmsSendOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -481,7 +478,7 @@ msg_error_t MsgHandle::setMmsSendOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -523,7 +520,7 @@ msg_error_t MsgHandle::getMmsRecvOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -573,7 +570,7 @@ msg_error_t MsgHandle::setMmsRecvOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -615,7 +612,7 @@ msg_error_t MsgHandle::getPushMsgOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -665,7 +662,7 @@ msg_error_t MsgHandle::setPushMsgOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -713,7 +710,7 @@ msg_error_t MsgHandle::getVoiceMsgOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -763,7 +760,7 @@ msg_error_t MsgHandle::setVoiceMsgOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -805,7 +802,7 @@ msg_error_t MsgHandle::getGeneralOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -855,7 +852,7 @@ msg_error_t MsgHandle::setGeneralOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -897,7 +894,7 @@ msg_error_t MsgHandle::getMsgSizeOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -947,7 +944,7 @@ msg_error_t MsgHandle::setMsgSizeOpt(msg_struct_t msg_struct) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); diff --git a/proxy/MsgHandleStorage.cpp b/proxy/MsgHandleStorage.cpp index fbcf2d4..8fa5659 100755 --- a/proxy/MsgHandleStorage.cpp +++ b/proxy/MsgHandleStorage.cpp @@ -32,7 +32,7 @@ int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pS MSG_SENDINGOPT_INFO_S sendOptInfo = {0,}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S convertMsgStruct(pMsg, &msgInfo); @@ -48,7 +48,7 @@ int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pS // Allocate Memory to Command Data char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(&msgInfo, &sendOptInfo, &encodedData); int cmdSize = sizeof(MSG_CMD_S) + dataSize; @@ -68,7 +68,7 @@ int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pS // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -101,7 +101,7 @@ msg_error_t MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S msg_struct_s *msg = (msg_struct_s *)pSyncMLMsg->msg; @@ -109,7 +109,7 @@ msg_error_t MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg) // Allocate Memory to Command Data char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(&msgInfo, &encodedData); int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(int) + dataSize; @@ -131,7 +131,7 @@ msg_error_t MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -164,7 +164,7 @@ msg_error_t MsgHandle::updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG MSG_SENDINGOPT_INFO_S sendOptInfo = {0, }; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S convertMsgStruct(pMsg, &msgInfo); @@ -181,7 +181,7 @@ msg_error_t MsgHandle::updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG // Allocate Memory to Command Data char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(&msgInfo, &sendOptInfo, &encodedData); int cmdSize = sizeof(MSG_CMD_S) + dataSize; @@ -201,7 +201,7 @@ msg_error_t MsgHandle::updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -241,7 +241,7 @@ msg_error_t MsgHandle::updateReadStatus(msg_message_id_t MsgId, bool bRead) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -280,7 +280,7 @@ msg_error_t MsgHandle::setConversationToRead(msg_thread_id_t ThreadId) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -320,7 +320,7 @@ msg_error_t MsgHandle::updateProtectedStatus(msg_message_id_t MsgId, bool bProte // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -359,7 +359,7 @@ msg_error_t MsgHandle::deleteMessage(msg_message_id_t MsgId) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -399,7 +399,7 @@ msg_error_t MsgHandle::deleteAllMessagesInFolder(msg_folder_id_t FolderId, bool // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -441,7 +441,7 @@ msg_error_t MsgHandle::deleteMessagesByList(msg_id_list_s *pMsgIdList) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -480,7 +480,7 @@ msg_error_t MsgHandle::moveMessageToFolder(msg_message_id_t MsgId, msg_folder_id // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -520,7 +520,7 @@ msg_error_t MsgHandle::moveMessageToStorage(msg_message_id_t MsgId, msg_storage_ // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -559,7 +559,7 @@ msg_error_t MsgHandle::countMessage(msg_folder_id_t FolderId, MSG_COUNT_INFO_S * // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -604,7 +604,7 @@ msg_error_t MsgHandle::countMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *p // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -651,7 +651,7 @@ msg_error_t MsgHandle::countMsgByContact(const MSG_THREAD_LIST_INDEX_INFO_S *pAd memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN + sizeof(msg_contact_id_t)), pAddr->data, sizeof(MSG_ADDRESS_INFO_S)); // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -696,7 +696,7 @@ msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S * // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -719,7 +719,7 @@ msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S * MSG_SENDINGOPT_INFO_S sendOptInfo; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo); @@ -747,32 +747,6 @@ msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S * } -msg_error_t MsgHandle::getFolderViewList(msg_folder_id_t FolderId, const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pMsgFolderViewList) -{ - msg_error_t err = MSG_SUCCESS; - -// err = MsgStoConnectDB(); -// -// if (err != MSG_SUCCESS) -// { -// MSG_DEBUG("MsgStoConnectDB() Error!!"); -// return err; -// } - - err = MsgStoGetFolderViewList(FolderId, (MSG_SORT_RULE_S *)pSortRule, pMsgFolderViewList); - - if (err != MSG_SUCCESS) - { - MSG_DEBUG("MsgStoGetFolderViewList() Error!!"); - return err; - } - -// MsgStoDisconnectDB(); - - return err; -} - - msg_error_t MsgHandle::addFolder(const MSG_FOLDER_INFO_S *pFolderInfo) { // Allocate Memory to Command Data @@ -793,7 +767,7 @@ msg_error_t MsgHandle::addFolder(const MSG_FOLDER_INFO_S *pFolderInfo) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -832,7 +806,7 @@ msg_error_t MsgHandle::updateFolder(const MSG_FOLDER_INFO_S *pFolderInfo) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -871,7 +845,7 @@ msg_error_t MsgHandle::deleteFolder(msg_folder_id_t FolderId) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -907,7 +881,7 @@ msg_error_t MsgHandle::getFolderList(msg_struct_list_s *pFolderList) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -934,7 +908,7 @@ msg_error_t MsgHandle::getFolderList(msg_struct_list_s *pFolderList) msg_error_t MsgHandle::getThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; // err = MsgStoConnectDB(); // @@ -970,7 +944,7 @@ msg_error_t MsgHandle::getThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_s // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -999,7 +973,7 @@ msg_error_t MsgHandle::getConversationViewItem(msg_message_id_t MsgId, MSG_CONVE { MSG_BEGIN(); - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; // MsgStoConnectDB(); err = MsgStoGetConversationViewItem(MsgId, pConv); @@ -1012,7 +986,7 @@ msg_error_t MsgHandle::getConversationViewList(msg_thread_id_t ThreadId, msg_str { MSG_BEGIN(); - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; // MsgStoConnectDB(); err = MsgStoGetConversationViewList(ThreadId, pConvViewList); @@ -1048,7 +1022,7 @@ msg_error_t MsgHandle::deleteThreadMessageList(msg_thread_id_t ThreadId, bool in // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1090,7 +1064,7 @@ msg_error_t MsgHandle::getQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1114,7 +1088,7 @@ msg_error_t MsgHandle::getQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo((char *)pEvent->data, &msgInfo); @@ -1149,7 +1123,7 @@ msg_error_t MsgHandle::resetDatabase() // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1185,7 +1159,7 @@ msg_error_t MsgHandle::getMemSize(unsigned int* memsize) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1217,6 +1191,7 @@ msg_error_t MsgHandle::backupMessage(msg_message_backup_type_t type, const char //Create an empty file for writing. //If a file with the same name already exists its content is erased //and the file is treated as a new empty file. + FILE *pFile = MsgOpenFile(backup_filepath, "w"); if (pFile == NULL) { MSG_DEBUG("File Open error"); @@ -1244,7 +1219,7 @@ msg_error_t MsgHandle::backupMessage(msg_message_backup_type_t type, const char // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1259,10 +1234,7 @@ msg_error_t MsgHandle::backupMessage(msg_message_backup_type_t type, const char THROW(MsgException::INVALID_RESULT, "Event Data Error"); } - if (pEvent->result != MSG_SUCCESS) - return pEvent->result; - - return MSG_SUCCESS; + return pEvent->result; } msg_error_t MsgHandle::restoreMessage(const char *backup_filepath) @@ -1294,7 +1266,7 @@ msg_error_t MsgHandle::restoreMessage(const char *backup_filepath) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1309,16 +1281,13 @@ msg_error_t MsgHandle::restoreMessage(const char *backup_filepath) THROW(MsgException::INVALID_RESULT, "Event Data Error"); } - if (pEvent->result != MSG_SUCCESS) - return pEvent->result; - - return MSG_SUCCESS; + return pEvent->result; } msg_error_t MsgHandle::searchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; // err = MsgStoConnectDB(); // @@ -1344,7 +1313,7 @@ msg_error_t MsgHandle::searchMessage(const char *pSearchString, msg_struct_list_ msg_error_t MsgHandle::getRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; // err = MsgStoConnectDB(); // @@ -1405,7 +1374,7 @@ msg_error_t MsgHandle::regStorageChangeCallback(msg_storage_change_cb onStorageC // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1446,7 +1415,7 @@ msg_error_t MsgHandle::getReportStatus(msg_message_id_t msg_id, msg_struct_list_ // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1473,7 +1442,7 @@ msg_error_t MsgHandle::getReportStatus(msg_message_id_t msg_id, msg_struct_list_ msg_error_t MsgHandle::getAddressList(const msg_thread_id_t threadId, msg_struct_list_s *pAddrList) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; // err = MsgStoConnectDB(); // @@ -1521,7 +1490,7 @@ msg_error_t MsgHandle::getThreadIdByAddress(msg_struct_list_s *pAddrList, msg_th // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1572,7 +1541,7 @@ msg_error_t MsgHandle::getThreadIdByAddress(msg_list_handle_t msg_address_list, // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1617,7 +1586,7 @@ msg_error_t MsgHandle::getThread(msg_thread_id_t threadId, MSG_THREAD_VIEW_S* pT // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1641,7 +1610,7 @@ msg_error_t MsgHandle::getThread(msg_thread_id_t threadId, MSG_THREAD_VIEW_S* pT msg_error_t MsgHandle::getMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pMsgList) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; // err = MsgStoConnectDB(); // @@ -1665,7 +1634,7 @@ msg_error_t MsgHandle::getMessageList(const MSG_LIST_CONDITION_S *pListCond, msg msg_error_t MsgHandle::getMediaList(const msg_thread_id_t thread_id, msg_list_handle_t *pMediaList) { - msg_error_t err = MSG_SUCCESS; + msg_error_t err = MSG_SUCCESS; err = MsgStoGetMediaList(thread_id, pMediaList); @@ -1698,7 +1667,7 @@ int MsgHandle::addPushEvent(MSG_PUSH_EVENT_INFO_S *pPushEvent) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1737,7 +1706,7 @@ int MsgHandle::deletePushEvent(MSG_PUSH_EVENT_INFO_S *pPushEvent) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1776,7 +1745,7 @@ int MsgHandle::updatePushEvent(MSG_PUSH_EVENT_INFO_S *pSrc, MSG_PUSH_EVENT_INFO_ // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1814,7 +1783,7 @@ msg_error_t MsgHandle::getVobject(msg_message_id_t MsgId, void** encodedData) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -1838,7 +1807,7 @@ msg_error_t MsgHandle::getVobject(msg_message_id_t MsgId, void** encodedData) MSG_SENDINGOPT_INFO_S sendOptInfo = {0,}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo); diff --git a/proxy/MsgHandleTransport.cpp b/proxy/MsgHandleTransport.cpp index 9ddbac1..782e516 100755 --- a/proxy/MsgHandleTransport.cpp +++ b/proxy/MsgHandleTransport.cpp @@ -44,7 +44,7 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq) char trId[MMS_TR_ID_LEN+1] = {0}; reqInfo.msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&reqInfo.msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&reqInfo.msgInfo.addressList, unique_ptr_deleter); msg_struct_s *msg_s = (msg_struct_s *)pReq->msg; @@ -86,7 +86,7 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq) time_t curTime = time(NULL); if (curTime < 0) - THROW(MsgException::INVALID_RESULT, "time error : %s", strerror(errno)); + THROW(MsgException::INVALID_RESULT, "time error : %s", g_strerror(errno)); reqmsg->displayTime = curTime; /* End : Setting default values for submit request */ @@ -118,9 +118,11 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq) chInfo.listenerFd = MsgProxyListener::instance()->getRemoteFd(); + chInfo.handleAddr = (unsigned int) this; + /* Allocate Memory to Command Data */ char* encodedData = NULL; - AutoPtr<char> buf(&encodedData); + unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter); int dataSize = MsgEncodeMsgInfo(&reqInfo.msgInfo, &reqInfo.sendOptInfo, &encodedData); int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_request_id_t) + dataSize + sizeof(MSG_PROXY_INFO_S); @@ -151,7 +153,7 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -173,44 +175,6 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq) } -msg_error_t MsgHandle::cancelReq(msg_request_id_t reqId) -{ - // Allocate Memory to Command Data - int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_request_id_t); - - char cmdBuf[cmdSize]; - bzero(cmdBuf, cmdSize); - - MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf; - - // Set Command Parameters - pCmd->cmdType = MSG_CMD_CANCEL_REQ; - - // Copy Cookie - memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN); - - // Copy Command Data - memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &reqId, sizeof(msg_request_id_t)); - - // Send Command to Messaging FW - char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); - - - write((char*)pCmd, cmdSize, &pEventData); - - // Get Return Data - MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData; - - if (pEvent->eventType != MSG_EVENT_CANCEL_REQ) - { - THROW(MsgException::INVALID_RESULT, "Event Data Error"); - } - - return pEvent->result; -} - - msg_error_t MsgHandle::regSentStatusCallback(msg_sent_status_cb onStatusChanged, void *pUserParam) { if (!onStatusChanged) @@ -248,7 +212,7 @@ msg_error_t MsgHandle::regSentStatusCallback(msg_sent_status_cb onStatusChanged, // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -307,7 +271,7 @@ msg_error_t MsgHandle::regSmsMessageCallback(msg_sms_incoming_cb onMsgIncoming, // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -369,7 +333,7 @@ msg_error_t MsgHandle::regMmsConfMessageCallback(msg_mms_conf_msg_incoming_cb on // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -428,7 +392,7 @@ msg_error_t MsgHandle::regSyncMLMessageCallback(msg_syncml_msg_incoming_cb onSyn // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -484,7 +448,7 @@ msg_error_t MsgHandle::regLBSMessageCallback(msg_lbs_msg_incoming_cb onLBSMsgInc // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -543,7 +507,7 @@ msg_error_t MsgHandle::regSyncMLMessageOperationCallback(msg_syncml_msg_operatio // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -604,7 +568,7 @@ msg_error_t MsgHandle::regPushMessageCallback(msg_push_msg_incoming_cb onPushMsg // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -663,7 +627,7 @@ msg_error_t MsgHandle::regCBMessageCallback(msg_cb_incoming_cb onCBIncoming, boo // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -717,7 +681,7 @@ msg_error_t MsgHandle::regReportMessageCallback(msg_report_msg_incoming_cb onRep // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -756,7 +720,7 @@ msg_error_t MsgHandle::operateSyncMLMessage(msg_message_id_t msgId) // Send Command to Messaging FW char* pEventData = NULL; - AutoPtr<char> eventBuf(&pEventData); + unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter); write((char*)pCmd, cmdSize, &pEventData); @@ -771,4 +735,3 @@ msg_error_t MsgHandle::operateSyncMLMessage(msg_message_id_t msgId) return pEvent->result; } - diff --git a/proxy/MsgProxyListener.cpp b/proxy/MsgProxyListener.cpp index 0e5f181..44195ef 100755 --- a/proxy/MsgProxyListener.cpp +++ b/proxy/MsgProxyListener.cpp @@ -76,8 +76,8 @@ gboolean readSocket(GIOChannel *source, GIOCondition condition, gpointer data) } char* buf = NULL; - AutoPtr<char> eventBuf(&buf); - unsigned int len; + unique_ptr<char*, void(*)(char**)> eventBuf(&buf, unique_ptr_deleter); + unsigned int len = 0; int n = MsgProxyListener::instance()->readFromSocket(&buf, &len); @@ -118,6 +118,9 @@ MsgProxyListener::MsgProxyListener() : running(0) newLBSMessageCBList.clear(); openHandleSet.clear(); MsgSettingRegVconfCBCommon(VCONFKEY_MSG_SERVER_READY, MsgServerRestartCb); + + channel = NULL; + eventSourceId = 0; } @@ -185,8 +188,6 @@ void MsgProxyListener::stop() } else if (running == 1) { - MutexLocker lock(mx); - running--; g_io_channel_unref(channel); // decrements ref_count = 1 @@ -643,7 +644,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo((char *)pMsgEvent->data, &msgInfo); @@ -680,6 +681,8 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent) addr_list->nCount = 0; addr_list->msg_struct_info = (msg_struct_t *)calloc(MAX_TO_ADDRESS_CNT, sizeof(MSG_ADDRESS_INFO_S *)); + if (addr_list->msg_struct_info == NULL) + continue; msg_struct_s *pTmp = NULL; @@ -742,7 +745,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); MsgDecodeMsgInfo((char *)pMsgEvent->data, &msgInfo); @@ -797,6 +800,8 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent) addr_list->nCount = 0; addr_list->msg_struct_info = (msg_struct_t *)calloc(MAX_TO_ADDRESS_CNT, sizeof(MSG_ADDRESS_INFO_S *)); + if (addr_list->msg_struct_info == NULL) + continue; msg_struct_s *pTmp = NULL; @@ -833,7 +838,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent) delete [] (char*)msgHidden.pMmsData; // address Memory Free - if (msgHidden.addr_list!= NULL) + if (msgHidden.addr_list != NULL) { for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) { msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i]; @@ -1075,6 +1080,7 @@ int MsgProxyListener::getRemoteFd() if (ret == ETIMEDOUT) { MSG_DEBUG("get listener fd TIME-OUT"); + mx.unlock(); return tmpFd; } diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index b03abb2..940adf1 100755 --- a/utils/CMakeLists.txt +++ b/utils/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} -O2 -g -Wall") ########################################################## # Define Framework Utils @@ -32,7 +32,6 @@ SET(UTILS-SRCS ${CMAKE_SOURCE_DIR}/utils/MsgJsonParser.cpp ${CMAKE_SOURCE_DIR}/utils/MsgSerialize.cpp ${CMAKE_SOURCE_DIR}/utils/MsgSmil.cpp - ${CMAKE_SOURCE_DIR}/utils/MsgZoneManager.cpp ) INCLUDE_DIRECTORIES( @@ -46,10 +45,6 @@ INCLUDE_DIRECTORIES( INCLUDE(FindPkgConfig) SET(PKG_MODULES glib-2.0 vconf db-util contacts-service2 dlog libxml-2.0 storage json-glib-1.0 capi-system-info) -IF(_FEATURE_CONTAINER_ENABLE) -ADD_DEFINITIONS("-DFEATURE_CONTAINER_ENABLE") -SET(PKG_MODULES ${PKG_MODULES} vasum) -ENDIF(_FEATURE_CONTAINER_ENABLE) pkg_check_modules(utils_pkgs REQUIRED ${PKG_MODULES}) FOREACH(flag ${utils_pkgs_CFLAGS}) @@ -59,7 +54,7 @@ ENDFOREACH(flag) ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DFEATURE_JAVA_MMS") -SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") diff --git a/utils/MsgContact.cpp b/utils/MsgContact.cpp index 01cf873..c038b9f 100755 --- a/utils/MsgContact.cpp +++ b/utils/MsgContact.cpp @@ -21,7 +21,6 @@ #include "MsgUtilFile.h" #include "MsgGconfWrapper.h" #include "MsgContact.h" -#include "MsgZoneManager.h" extern "C" { @@ -37,11 +36,6 @@ __thread bool isContactSvcConnected = false; MsgDbHandler ContactDbHandle; -MsgContactChangeCB cbFunction = NULL; - -#define CONTACT_CALLBACK_USER_DATA "contact" -#define ADDRESSBOOK_CALLBACK_USER_DATA "addressbook" - // phonenumber minimum match digit. #define PHONENUMBER_MIN_MATCH_DIGIT VCONFKEY_CONTACTS_SVC_PHONENUMBER_MIN_MATCH_DIGIT #define DEFAULT_MIN_MATCH_DIGIT 8 @@ -249,8 +243,6 @@ msg_error_t MsgOpenContactSvc() msg_error_t MsgCloseContactSvc() { - MsgZoneChange(); - int errCode = CONTACTS_ERROR_NONE; if (isContactSvcConnected) { @@ -261,27 +253,16 @@ msg_error_t MsgCloseContactSvc() isContactSvcConnected = false; } else { MSG_DEBUG("Disconnect to Contact Service Fail [%d]", errCode); - MsgZoneRevert(); return MSG_ERR_DB_DISCONNECT; } } - MsgZoneRevert(); - return MSG_SUCCESS; } -msg_error_t MsgInitContactSvc(MsgContactChangeCB cb) +msg_error_t MsgInitContactSvc() { - MsgZoneChange(); - -// msg_error_t err = MSG_SUCCESS; -// unsigned int retryCnt = 10; - - if (cb != NULL) - cbFunction = cb; - phonenumberMinMatchDigit = MsgSettingGetInt(PHONENUMBER_MIN_MATCH_DIGIT); MSG_DEBUG("phonenumberMinMatchDigit [%d]", phonenumberMinMatchDigit); @@ -289,49 +270,6 @@ msg_error_t MsgInitContactSvc(MsgContactChangeCB cb) phonenumberMinMatchDigit = DEFAULT_MIN_MATCH_DIGIT; } -#if 0 - do { - if ((err = MsgOpenContactSvc()) != MSG_SUCCESS) { - retryCnt--; - MSG_DEBUG("MsgOpenContactSvc fail. Retry count left [%d]", retryCnt); - usleep(100 * 1000); - } - } while (err != MSG_SUCCESS && retryCnt > 0); - - if (!isContactSvcConnected) { - MSG_DEBUG("Contact Service Not Opened."); - MsgZoneRevert(); - return MSG_ERR_UNKNOWN; - } - - // Sync contact first. - MsgSyncAddressbook(); -// MsgSyncContact(); - - int errCode = CONTACTS_ERROR_NONE; - - // Register callback function - errCode = contacts_db_add_changed_cb(_contacts_contact._uri, MsgContactSvcCallback, (void *)CONTACT_CALLBACK_USER_DATA); - - if (errCode == CONTACTS_ERROR_NONE) - MSG_DEBUG("Register Contact Service Callback [_contacts_contact]"); - else - MSG_DEBUG("Fail to Register Contact Service Callback [_contacts_contact] [%d]", errCode); - - // Register callback function - errCode = contacts_db_add_changed_cb(_contacts_address_book._uri, MsgContactSvcCallback, (void *)ADDRESSBOOK_CALLBACK_USER_DATA); - - if (errCode == CONTACTS_ERROR_NONE) - MSG_DEBUG("Register Contact Service Callback [_contacts_address_book]"); - else - MSG_DEBUG("Fail to Register Contact Service Callback [_contacts_address_book] [%d]", errCode); - - if (ContactDbHandle.disconnect() != MSG_SUCCESS) - MSG_DEBUG("DB Disconnect Fail"); -#endif - - MsgZoneRevert(); - return MSG_SUCCESS; } @@ -340,19 +278,15 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I { MSG_BEGIN(); - MsgZoneChange(); - msg_error_t err = MSG_SUCCESS; if ((err = MsgOpenContactSvc()) != MSG_SUCCESS) { MSG_DEBUG("MsgOpenContactSvc fail."); - MsgZoneRevert(); return err; } if (!isContactSvcConnected) { MSG_DEBUG("Contact Service Not Opened."); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -362,7 +296,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_PLMN && strlen(pAddrInfo->addressVal) > (MAX_PHONE_NUMBER_LEN+1)) { MSG_SEC_DEBUG("Phone Number is too long [%s]", pAddrInfo->addressVal); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -387,7 +320,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I } else { MSG_DEBUG("Invalid pAddrInfo->addressType."); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -398,7 +330,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I contacts_query_destroy(query); contacts_filter_destroy(filter); contacts_list_destroy(contacts, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -409,7 +340,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I contacts_query_destroy(query); contacts_filter_destroy(filter); contacts_list_destroy(contacts, true); - MsgZoneRevert(); return MSG_SUCCESS; } @@ -425,7 +355,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret); contacts_list_destroy(contacts, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -433,7 +362,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_record_get_int() Error [%d]", ret); contacts_list_destroy(contacts, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -441,7 +369,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_db_get_record() Error [%d]", ret); contacts_list_destroy(contacts, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } } else if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_EMAIL) { @@ -451,7 +378,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret); contacts_list_destroy(contacts, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -459,7 +385,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_record_get_int() Error [%d]", ret); contacts_list_destroy(contacts, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -467,79 +392,16 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_db_get_record() Error [%d]", ret); contacts_list_destroy(contacts, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } } contacts_list_destroy(contacts, true); -#if 0 - // Name Info - contacts_record_h name = NULL; - - ret = contacts_record_get_child_record_at_p(contact, _contacts_contact.name, 0, &name); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_child_record_at_p() Error [%d]", ret); - } else { - char* strName = NULL; - ret = contacts_record_get_str_p(name, _contacts_name.first, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(pContactInfo->firstName, strName, MAX_DISPLAY_NAME_LEN); - } - } - - ret = contacts_record_get_str_p(name, _contacts_name.last, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(pContactInfo->lastName, strName, MAX_DISPLAY_NAME_LEN); - } - } - - ret = contacts_record_get_str_p(name, _contacts_name.addition, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(pContactInfo->middleName, strName, MAX_DISPLAY_NAME_LEN); - } - } - - ret = contacts_record_get_str_p(name, _contacts_name.prefix, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(pContactInfo->prefix, strName, MAX_DISPLAY_NAME_LEN); - } - } - - ret = contacts_record_get_str_p(name, _contacts_name.suffix, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(pContactInfo->suffix, strName, MAX_DISPLAY_NAME_LEN); - } - } - } -#endif - ret = contacts_record_get_int(contact, _contacts_contact.id, (int*)&pContactInfo->contactId); if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_db_get_record() Error [%d]", ret); contacts_record_destroy(contact, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -549,7 +411,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_db_get_record() Error [%d]", ret); contacts_record_destroy(contact, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -639,8 +500,6 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I MSG_END(); - MsgZoneRevert(); - return MSG_SUCCESS; } @@ -649,33 +508,27 @@ msg_error_t MsgGetContactSearchList(const char *pSearchVal, MSG_ADDRESS_INFO_S * { MSG_BEGIN(); - MsgZoneChange(); - msg_error_t err = MSG_SUCCESS; *count = 0; if (pSearchVal == NULL) { MSG_DEBUG("pSearchVal is NULL."); - MsgZoneRevert(); return MSG_ERR_NULL_POINTER; } if (pAddrInfo == NULL) { MSG_DEBUG("pAddrInfo is NULL."); - MsgZoneRevert(); return MSG_ERR_NULL_POINTER; } if ((err = MsgOpenContactSvc()) != MSG_SUCCESS) { MSG_DEBUG("MsgOpenContactSvc fail."); - MsgZoneRevert(); return err; } if (!isContactSvcConnected) { MSG_DEBUG("Contact Service Not Opened."); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -699,7 +552,6 @@ msg_error_t MsgGetContactSearchList(const char *pSearchVal, MSG_ADDRESS_INFO_S * contacts_query_destroy(query); contacts_filter_destroy(filter); contacts_list_destroy(personNumbers, true); - MsgZoneRevert(); return MSG_ERR_UNKNOWN; } @@ -710,7 +562,6 @@ msg_error_t MsgGetContactSearchList(const char *pSearchVal, MSG_ADDRESS_INFO_S * contacts_query_destroy(query); contacts_filter_destroy(filter); contacts_list_destroy(personNumbers, true); - MsgZoneRevert(); return MSG_SUCCESS; } @@ -743,415 +594,14 @@ msg_error_t MsgGetContactSearchList(const char *pSearchVal, MSG_ADDRESS_INFO_S * MSG_END(); - MsgZoneRevert(); - return MSG_SUCCESS; } -void MsgSyncAddressbook() -{ - MsgZoneChange(); - - int ret = -1; - int changed_count = 0; - - contacts_list_h addrbookListHnd = NULL; - - ret = contacts_db_get_all_records(_contacts_address_book._uri, 0, 0, &addrbookListHnd); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_db_get_all_records() Error [%d]", ret); - contacts_list_destroy(addrbookListHnd, true); - MsgZoneRevert(); - return; - } - - ret = contacts_list_get_count(addrbookListHnd, &changed_count); - - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_list_get_count() Error [%d]", ret); - contacts_list_destroy(addrbookListHnd, true); - MsgZoneRevert(); - return; - } - - if (changed_count>0) { - int addrbookList[changed_count]; - - for (int i = 0; i < changed_count; i++) { - contacts_record_h addrbook = NULL; - int addrbookId = 0; - - ret = contacts_list_get_current_record_p(addrbookListHnd, &addrbook); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret); - contacts_list_destroy(addrbookListHnd, true); - MsgZoneRevert(); - return; - } - - ret = contacts_record_get_int(addrbook, _contacts_address_book.id, &addrbookId); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_int() Error [%d]", ret); - contacts_list_destroy(addrbookListHnd, true); - MsgZoneRevert(); - return; - } - - addrbookList[i] = addrbookId; - - ret = contacts_list_next(addrbookListHnd); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_list_next() Error [%d]", ret); - } - - } - - MsgStoClearContactInfoByAddrbookIdList(&ContactDbHandle, addrbookList, (int)changed_count); - } - - contacts_list_destroy(addrbookListHnd, true); - - MsgZoneRevert(); -} - - -void MsgSyncContact() -{ - MsgZoneChange(); - - int ret = -1; - int changed_count = 0; - int lastSyncTime = 0; - int finalSyncTime = 0; - - /* get contact sync time */ - lastSyncTime = MsgSettingGetInt(CONTACT_SYNC_TIME); - - if (lastSyncTime < 0) { - MSG_DEBUG("Fail to get CONTACT_SYNC_TIME."); - lastSyncTime = 0; - } - - contacts_list_h contactsList = NULL; - - ret = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, -1, lastSyncTime, &contactsList, &finalSyncTime); - - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_db_get_changes_by_version() Error [%d]", ret); - contacts_list_destroy(contactsList, true); - MsgZoneRevert(); - return; - } - - ret = contacts_list_get_count(contactsList, &changed_count); - - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_list_get_count() Error [%d]", ret); - contacts_list_destroy(contactsList, true); - MsgZoneRevert(); - return; - } - - for (int i = 0; i < changed_count; i++) - { - int index_num = 0; - int type = 0; - contacts_record_h event = NULL; - - ret = contacts_list_get_current_record_p(contactsList, &event); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret); - contacts_list_destroy(contactsList, true); - MsgZoneRevert(); - return; - } - - ret = contacts_record_get_int(event, _contacts_contact_updated_info.contact_id, &index_num); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_int() Error [%d]", ret); - contacts_list_destroy(contactsList, true); - MsgZoneRevert(); - return; - } - - MSG_DEBUG("index (%d)", index_num); - - ret = contacts_record_get_int(event, _contacts_contact_updated_info.type, &type); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_int() Error [%d]", ret); - contacts_list_destroy(contactsList, true); - MsgZoneRevert(); - return; - } - - MSG_DEBUG("type [%d]", type); - - if (type != CONTACTS_CHANGE_INSERTED) { - MsgDeleteContact(index_num); - } - - if (type != CONTACTS_CHANGE_DELETED) { - MsgUpdateContact(index_num, type); - } - - ret = contacts_list_next(contactsList); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_list_next() Error [%d]", ret); - } - } - - if(MsgSettingSetInt(CONTACT_SYNC_TIME, finalSyncTime) != MSG_SUCCESS) - MSG_DEBUG("MsgSettingSetInt fail : CONTACT_SYNC_TIME"); - MSG_DEBUG("lastSyncTime : %d", finalSyncTime); - - contacts_list_destroy(contactsList, true); - - if(changed_count > 0) { - if(cbFunction) cbFunction(); - } - - MsgZoneRevert(); -} - - -bool MsgInsertContact(MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber) -{ - MsgZoneChange(); - - if (!pNumber || strlen(pNumber) <= 0) - MsgZoneRevert(); - return false; - - if (MsgStoAddContactInfo(&ContactDbHandle, pContactInfo, pNumber) != MSG_SUCCESS) { - MSG_DEBUG("Fail to add contact info."); - MsgZoneRevert(); - return false; - } - - MsgZoneRevert(); - - return true; -} - - -bool MsgUpdateContact(int index, int type) -{ - MsgZoneChange(); - - int ret = CONTACTS_ERROR_NONE; - - contacts_record_h contact = NULL; - - ret = contacts_db_get_record(_contacts_contact._uri, index, &contact); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_db_get_record() Error [%d]", ret); - contacts_record_destroy(contact, true); - MsgZoneRevert(); - return false; - } - -#if 0 - MSG_CONTACT_INFO_S contactInfo; - memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - ret = contacts_record_get_int(contact, _contacts_contact.id, (int*)&contactInfo.contactId); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_db_get_record() Error [%d]", ret); - contacts_record_destroy(contact, true); - MsgZoneRevert(); - return false; - } - - MSG_DEBUG("Contact ID [%d]", contactInfo.contactId); - - ret = contacts_record_get_int(contact, _contacts_contact.address_book_id, (int*)&contactInfo.addrbookId); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_db_get_record() Error [%d]", ret); - } - - MSG_DEBUG("Addressbook ID [%d]", contactInfo.addrbookId); - - char* strImagePath = NULL; - ret = contacts_record_get_str_p(contact, _contacts_contact.image_thumbnail_path, &strImagePath); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } - - if (strImagePath != NULL) - strncpy(contactInfo.imagePath , strImagePath, MAX_IMAGE_PATH_LEN); - - MSG_DEBUG("Image Path [%s]", contactInfo.imagePath); - - // Name Info - contacts_record_h name = NULL; - - ret = contacts_record_get_child_record_at_p(contact, _contacts_contact.name, 0, &name); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_child_record_at_p() Error [%d]", ret); - } else { - char* strName = NULL; - ret = contacts_record_get_str_p(name, _contacts_name.first, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(contactInfo.firstName, strName, MAX_DISPLAY_NAME_LEN); - } - } - - ret = contacts_record_get_str_p(name, _contacts_name.last, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(contactInfo.lastName, strName, MAX_DISPLAY_NAME_LEN); - } - } - - ret = contacts_record_get_str_p(name, _contacts_name.addition, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(contactInfo.middleName, strName, MAX_DISPLAY_NAME_LEN); - } - } - - ret = contacts_record_get_str_p(name, _contacts_name.prefix, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(contactInfo.prefix, strName, MAX_DISPLAY_NAME_LEN); - } - } - - ret = contacts_record_get_str_p(name, _contacts_name.suffix, &strName); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - } else { - if (strName != NULL) { - MSG_DEBUG("strName [%s]", strName); - strncpy(contactInfo.suffix, strName, MAX_DISPLAY_NAME_LEN); - } - } - - MSG_SEC_DEBUG("First Name : [%s], Last Name : [%s]", contactInfo.firstName, contactInfo.lastName); - } - - MsgStoClearContactInfo(&ContactDbHandle, index); -#endif - - int count = 0; - ret = contacts_record_get_child_record_count(contact, _contacts_contact.number, &count); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_child_record_count() Error [%d]", ret); - contacts_record_destroy(contact, true); - MsgZoneRevert(); - return false; - } - - if (count > 0) { - for (int i=0; i < count; i++) { - MSG_DEBUG("Add Contact Data"); - - contacts_record_h number = NULL; - - ret = contacts_record_get_child_record_at_p(contact, _contacts_contact.number, i, &number); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_child_record_at_p() Error [%d]", ret); - contacts_record_destroy(contact, true); - MsgZoneRevert(); - return false; - } - - char* strNumber = NULL; - ret = contacts_record_get_str_p(number, _contacts_number.number, &strNumber); - if (ret != CONTACTS_ERROR_NONE) { - MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret); - contacts_record_destroy(contact, true); - MsgZoneRevert(); - return false; - } - - if (strNumber != NULL) { - MSG_DEBUG("Number [%s]", strNumber); - int strNumberLen = strlen(strNumber); - char normalizeNum[strNumberLen+1]; - memset(normalizeNum, 0x00, sizeof(normalizeNum)); - if (strNumberLen > 0) { - normalizeNumber(strNumber, normalizeNum, strNumberLen); - MSG_DEBUG("normalizeNum [%s]", normalizeNum); - } - - MSG_CONTACT_INFO_S contactInfo; - memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - MSG_ADDRESS_INFO_S addrInfo; - memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - strncpy(addrInfo.addressVal, normalizeNum, MAX_ADDRESS_VAL_LEN); - - if(MsgGetContactInfo(&addrInfo, &contactInfo) == MSG_SUCCESS) { - if (MsgInsertContact(&contactInfo, normalizeNum)) { - MsgStoSetConversationDisplayName(&ContactDbHandle, (int)contactInfo.contactId); - } else { - MSG_DEBUG("MsgInsertContact fail."); - } - } - } - } - } else {// No phone number in contact - contacts_record_destroy(contact, true); - MsgZoneRevert(); - return true; - } - -// MsgStoSetConversationDisplayName(&ContactDbHandle, index); - - contacts_record_destroy(contact, true); - - MsgZoneRevert(); - - return true; -} - - -bool MsgDeleteContact(int index) -{ -// if (MsgStoClearContactInfo(&ContactDbHandle, index) != MSG_SUCCESS) - if (MsgStoResetContactInfo(&ContactDbHandle, index) != MSG_SUCCESS) - return false; - - return true; -} - int MsgGetContactNameOrder() { - MsgZoneChange(); - -// int ret = CONTACTS_ERROR_NONE; contacts_name_display_order_e order = CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST; -// if (MsgOpenContactSvc() != MSG_SUCCESS) { -// MSG_DEBUG("MsgOpenContactSvc fail."); -// } -// -// if (!isContactSvcConnected) { -// MSG_DEBUG("Contact Service Not Opened."); -// } else { -// ret = contacts_setting_get_name_display_order(&order); -// if (ret != CONTACTS_ERROR_NONE) { -// MSG_DEBUG("contacts_setting_get_name_display_order() Error [%d]", ret); -// } -// } - - MsgZoneRevert(); - return (int)order; } @@ -1225,25 +675,20 @@ msg_error_t MsgGetContactStyleDisplayName(const char *first, const char *last, c void MsgAddPhoneLog(const MSG_MESSAGE_INFO_S *pMsgInfo) { - MsgZoneChange(); - msg_error_t err = MSG_SUCCESS; if ((err = MsgOpenContactSvc()) != MSG_SUCCESS) { MSG_DEBUG("MsgOpenContactSvc fail."); - MsgZoneRevert(); return; } if (!isContactSvcConnected) { MSG_DEBUG("Contact Service Not Opened."); - MsgZoneRevert(); return; } if (pMsgInfo->nAddressCnt < 1) { MSG_DEBUG("address count is [%d]", pMsgInfo->nAddressCnt); - MsgZoneRevert(); return; } @@ -1304,20 +749,15 @@ void MsgAddPhoneLog(const MSG_MESSAGE_INFO_S *pMsgInfo) contacts_record_destroy(plog, true); } - - MsgZoneRevert(); } void MsgDeletePhoneLog(msg_message_id_t msgId) { - MsgZoneChange(); - msg_error_t err = MSG_SUCCESS; if ((err = MsgOpenContactSvc()) != MSG_SUCCESS) { MSG_DEBUG("MsgOpenContactSvc fail."); - MsgZoneRevert(); return; } @@ -1325,7 +765,6 @@ void MsgDeletePhoneLog(msg_message_id_t msgId) if (!isContactSvcConnected) { MSG_DEBUG("Contact Service Not Opened."); - MsgZoneRevert(); return; } @@ -1374,29 +813,12 @@ void MsgDeletePhoneLog(msg_message_id_t msgId) contacts_filter_destroy(filter); contacts_list_destroy(plogs, true); - MsgZoneRevert(); -} - - -int MsgContactSVCBeginTrans() -{ - //return contacts_svc_begin_trans(); - return 0; -} - - -int MsgContactSVCEndTrans(bool bSuccess) -{ - //return contacts_svc_end_trans(bSuccess); - return 0; } bool checkBlockingMode(char *address, bool *pisFavorites) { #if 0 - MsgZoneChange(); - msg_error_t err = MSG_SUCCESS; if (pisFavorites != NULL) *pisFavorites = false; @@ -1418,13 +840,11 @@ bool checkBlockingMode(char *address, bool *pisFavorites) if ((err = MsgOpenContactSvc()) != MSG_SUCCESS) { MSG_DEBUG("MsgOpenContactSvc fail."); - MsgZoneRevert(); return isblock; } if (!isContactSvcConnected) { MSG_DEBUG("Contact Service Not Opened."); - MsgZoneRevert(); return isblock; } @@ -1432,7 +852,6 @@ bool checkBlockingMode(char *address, bool *pisFavorites) if (strlen(address) > (MAX_PHONE_NUMBER_LEN+1)) { MSG_SEC_DEBUG("Phone Number is too long [%s]", address); - MsgZoneRevert(); return isblock; } @@ -1458,7 +877,6 @@ bool checkBlockingMode(char *address, bool *pisFavorites) if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_db_get_records_with_query() Error [%d]", ret); contacts_list_destroy(personList, true); - MsgZoneRevert(); return isblock; } @@ -1467,7 +885,6 @@ bool checkBlockingMode(char *address, bool *pisFavorites) if (count == 0 || ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("No Serach Data from Contact Service."); contacts_list_destroy(personList, true); - MsgZoneRevert(); return isblock; } else if (ret == CONTACTS_ERROR_NONE && count > 0 && blockModeType == 1) { // For All contacts allow in blocking mode. @@ -1480,7 +897,6 @@ bool checkBlockingMode(char *address, bool *pisFavorites) if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret); contacts_list_destroy(personList, true); - MsgZoneRevert(); return isblock; } @@ -1488,7 +904,6 @@ bool checkBlockingMode(char *address, bool *pisFavorites) if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_record_get_int() Error [%d]", ret); contacts_list_destroy(personList, true); - MsgZoneRevert(); return isblock; } @@ -1498,7 +913,6 @@ bool checkBlockingMode(char *address, bool *pisFavorites) if (ret != CONTACTS_ERROR_NONE) { MSG_DEBUG("contacts_record_get_int() Error [%d]", ret); contacts_list_destroy(personList, true); - MsgZoneRevert(); return isblock; } @@ -1514,7 +928,8 @@ bool checkBlockingMode(char *address, bool *pisFavorites) case 3: // For Custom allow in blocking mode. { char *allowList = MsgSettingGetString(VCONFKEY_SETAPPL_BLOCKINGMODE_ALLOWED_CONTACT_LIST); - char *personIdStr = strtok (allowList," ,"); + char *temp = NULL; + char *personIdStr = strtok_r (allowList," ,", &temp); while (personIdStr != NULL) { MSG_DEBUG("personIdStr [%s]", personIdStr); @@ -1523,7 +938,7 @@ bool checkBlockingMode(char *address, bool *pisFavorites) isblock = false; break; } - personIdStr = strtok (NULL, " ,"); + personIdStr = strtok_r (NULL, " ,", &temp); } if (allowList) { @@ -1539,8 +954,6 @@ bool checkBlockingMode(char *address, bool *pisFavorites) if (pisFavorites != NULL) *pisFavorites = isFavorites; - MsgZoneRevert(); - return isblock; #else if (pisFavorites != NULL) diff --git a/utils/MsgDebug.cpp b/utils/MsgDebug.cpp index 7e1b30c..1e436f1 100755 --- a/utils/MsgDebug.cpp +++ b/utils/MsgDebug.cpp @@ -26,226 +26,198 @@ const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType) switch ( cmdType ) { // 0 - case MSG_CMD_OPEN_HANDLE: - return "MSG_CMD_OPEN_HANDLE"; - case MSG_CMD_CLOSE_HANDLE: - return "MSG_CMD_CLOSE_HANDLE"; - case MSG_CMD_GET_STORAGELIST: - return "MSG_CMD_GET_STORAGELIST"; - case MSG_CMD_ADD_MSG: - return "MSG_CMD_ADD_MSG"; - case MSG_CMD_ADD_SYNCML_MSG: - return "MSG_CMD_ADD_SYNCML_MSG"; - + case MSG_CMD_OPEN_HANDLE: + return "MSG_CMD_OPEN_HANDLE"; + case MSG_CMD_CLOSE_HANDLE: + return "MSG_CMD_CLOSE_HANDLE"; + case MSG_CMD_GET_STORAGELIST: + return "MSG_CMD_GET_STORAGELIST"; + case MSG_CMD_ADD_MSG: + return "MSG_CMD_ADD_MSG"; + case MSG_CMD_ADD_SYNCML_MSG: + return "MSG_CMD_ADD_SYNCML_MSG"; // 5 - case MSG_CMD_UPDATE_MSG: - return "MSG_CMD_UPDATE_MSG"; - case MSG_CMD_UPDATE_READ: - return "MSG_CMD_UPDATE_READ"; - case MSG_CMD_UPDATE_PROTECTED: - return "MSG_CMD_UPDATE_PROTECTED"; - case MSG_CMD_DELETE_MSG: - return "MSG_CMD_DELETE_MSG"; - case MSG_CMD_DELALL_MSGINFOLDER: - return "MSG_CMD_DELALL_MSGINFOLDER"; - + case MSG_CMD_UPDATE_MSG: + return "MSG_CMD_UPDATE_MSG"; + case MSG_CMD_UPDATE_READ: + return "MSG_CMD_UPDATE_READ"; + case MSG_CMD_UPDATE_PROTECTED: + return "MSG_CMD_UPDATE_PROTECTED"; + case MSG_CMD_DELETE_MSG: + return "MSG_CMD_DELETE_MSG"; + case MSG_CMD_DELALL_MSGINFOLDER: + return "MSG_CMD_DELALL_MSGINFOLDER"; // 10 - case MSG_CMD_MOVE_MSGTOFOLDER: - return "MSG_CMD_MOVE_MSGTOFOLDER"; - case MSG_CMD_MOVE_MSGTOSTORAGE: - return "MSG_CMD_MOVE_MSGTOSTORAGE"; - case MSG_CMD_COUNT_MSG: - return "MSG_CMD_COUNT_MSG"; - case MSG_CMD_GET_MSG: - return "MSG_CMD_GET_MSG"; - case MSG_CMD_GET_FOLDERVIEWLIST: - return "MSG_CMD_GET_FOLDERVIEWLIST"; - + case MSG_CMD_MOVE_MSGTOFOLDER: + return "MSG_CMD_MOVE_MSGTOFOLDER"; + case MSG_CMD_MOVE_MSGTOSTORAGE: + return "MSG_CMD_MOVE_MSGTOSTORAGE"; + case MSG_CMD_COUNT_MSG: + return "MSG_CMD_COUNT_MSG"; + case MSG_CMD_GET_MSG: + return "MSG_CMD_GET_MSG"; + case MSG_CMD_ADD_FOLDER: + return "MSG_CMD_ADD_FOLDER"; // 15 - case MSG_CMD_ADD_FOLDER: - return "MSG_CMD_ADD_FOLDER"; - case MSG_CMD_UPDATE_FOLDER: - return "MSG_CMD_UPDATE_FOLDER"; - case MSG_CMD_DELETE_FOLDER: - return "MSG_CMD_DELETE_FOLDER"; - case MSG_CMD_GET_FOLDERLIST: - return "MSG_CMD_GET_FOLDERLIST"; - case MSG_CMD_ADD_FILTER: - return "MSG_CMD_ADD_FILTER"; - + case MSG_CMD_UPDATE_FOLDER: + return "MSG_CMD_UPDATE_FOLDER"; + case MSG_CMD_DELETE_FOLDER: + return "MSG_CMD_DELETE_FOLDER"; + case MSG_CMD_GET_FOLDERLIST: + return "MSG_CMD_GET_FOLDERLIST"; + case MSG_CMD_ADD_FILTER: + return "MSG_CMD_ADD_FILTER"; + case MSG_CMD_UPDATE_FILTER: + return "MSG_CMD_UPDATE_FILTER"; // 20 - case MSG_CMD_UPDATE_FILTER: - return "MSG_CMD_UPDATE_FILTER"; - case MSG_CMD_DELETE_FILTER: - return "MSG_CMD_DELETE_FILTER"; - case MSG_CMD_GET_FILTERLIST: - return "MSG_CMD_GET_FILTERLIST"; - case MSG_CMD_SET_FILTER_OPERATION: - return "MSG_CMD_SET_FILTER_OPERATION"; - case MSG_CMD_GET_FILTER_OPERATION: - return "MSG_CMD_GET_FILTER_OPERATION"; - + case MSG_CMD_DELETE_FILTER: + return "MSG_CMD_DELETE_FILTER"; + case MSG_CMD_GET_FILTERLIST: + return "MSG_CMD_GET_FILTERLIST"; + case MSG_CMD_SET_FILTER_OPERATION: + return "MSG_CMD_SET_FILTER_OPERATION"; + case MSG_CMD_GET_FILTER_OPERATION: + return "MSG_CMD_GET_FILTER_OPERATION"; + case MSG_CMD_SUBMIT_REQ: + return "MSG_CMD_SUBMIT_REQ"; // 25 - case MSG_CMD_GET_MSG_TYPE: - return "MSG_CMD_GET_MSG_TYPE"; - case MSG_CMD_SUBMIT_REQ: - return "MSG_CMD_SUBMIT_REQ"; - case MSG_CMD_CANCEL_REQ: - return "MSG_CMD_CANCEL_REQ"; - case MSG_CMD_REG_SENT_STATUS_CB: - return "MSG_CMD_REG_SENT_STATUS_CB"; - case MSG_CMD_REG_STORAGE_CHANGE_CB: - return "MSG_CMD_REG_STORAGE_CHANGE_CB"; - + case MSG_CMD_REG_SENT_STATUS_CB: + return "MSG_CMD_REG_SENT_STATUS_CB"; + case MSG_CMD_REG_STORAGE_CHANGE_CB: + return "MSG_CMD_REG_STORAGE_CHANGE_CB"; + case MSG_CMD_REG_INCOMING_MSG_CB: + return "MSG_CMD_REG_INCOMING_MSG_CB"; + case MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB: + return "MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB"; + case MSG_CMD_REG_INCOMING_SYNCML_MSG_CB: + return "MSG_CMD_REG_INCOMING_SYNCML_MSG_CB"; // 30 - case MSG_CMD_REG_INCOMING_MSG_CB: - return "MSG_CMD_REG_INCOMING_MSG_CB"; - case MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB: - return "MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB"; - case MSG_CMD_REG_INCOMING_SYNCML_MSG_CB: - return "MSG_CMD_REG_INCOMING_SYNCML_MSG_CB"; - case MSG_CMD_REG_INCOMING_LBS_MSG_CB: - return "MSG_CMD_REG_INCOMING_LBS_MSG_CB"; - case MSG_CMD_PLG_SENT_STATUS_CNF: - return "MSG_CMD_PLG_SENT_STATUS_CNF"; - + case MSG_CMD_REG_INCOMING_LBS_MSG_CB: + return "MSG_CMD_REG_INCOMING_LBS_MSG_CB"; + case MSG_CMD_PLG_SENT_STATUS_CNF: + return "MSG_CMD_PLG_SENT_STATUS_CNF"; + case MSG_CMD_PLG_STORAGE_CHANGE_IND: + return "MSG_CMD_PLG_STORAGE_CHANGE_IND"; + case MSG_CMD_PLG_INCOMING_MSG_IND: + return "MSG_CMD_PLG_INCOMING_MSG_IND"; + case MSG_CMD_PLG_INCOMING_MMS_CONF: + return "MSG_CMD_PLG_INCOMING_MMS_CONF"; // 35 - case MSG_CMD_PLG_STORAGE_CHANGE_IND: - return "MSG_CMD_PLG_STORAGE_CHANGE_IND"; - case MSG_CMD_PLG_INCOMING_MSG_IND: - return "MSG_CMD_PLG_INCOMING_MSG_IND"; - case MSG_CMD_PLG_INCOMING_MMS_CONF: - return "MSG_CMD_PLG_INCOMING_MMS_CONF"; - case MSG_CMD_PLG_INCOMING_SYNCML_IND: - return "MSG_CMD_PLG_INCOMING_SYNCML_IND"; - case MSG_CMD_PLG_INCOMING_LBS_IND: - return "MSG_CMD_PLG_INCOMING_LBS_IND"; - + case MSG_CMD_PLG_INCOMING_SYNCML_IND: + return "MSG_CMD_PLG_INCOMING_SYNCML_IND"; + case MSG_CMD_PLG_INCOMING_LBS_IND: + return "MSG_CMD_PLG_INCOMING_LBS_IND"; + case MSG_CMD_PLG_INIT_SIM_BY_SAT: + return "MSG_CMD_PLG_INIT_SIM_BY_SAT"; + case MSG_CMD_GET_THREADVIEWLIST: + return "MSG_CMD_GET_THREADVIEWLIST"; + case MSG_CMD_DELETE_THREADMESSAGELIST: + return "MSG_CMD_DELETE_THREADMESSAGELIST"; // 40 - case MSG_CMD_PLG_INIT_SIM_BY_SAT: - return "MSG_CMD_PLG_INIT_SIM_BY_SAT"; - case MSG_CMD_GET_THREADVIEWLIST: - return "MSG_CMD_GET_THREADVIEWLIST"; - case MSG_CMD_GET_CONVERSATIONVIEWLIST: - return "MSG_CMD_GET_CONVERSATIONVIEWLIST"; - case MSG_CMD_DELETE_THREADMESSAGELIST: - return "MSG_CMD_DELETE_THREADMESSAGELIST"; - case MSG_CMD_GET_CONTACT_COUNT: - return "MSG_CMD_GET_CONTACT_COUNT"; - + case MSG_CMD_GET_CONTACT_COUNT: + return "MSG_CMD_GET_CONTACT_COUNT"; + case MSG_CMD_GET_QUICKPANEL_DATA: + return "MSG_CMD_GET_QUICKPANEL_DATA"; + case MSG_CMD_COUNT_BY_MSGTYPE: + return "MSG_CMD_COUNT_BY_MSGTYPE"; + case MSG_CMD_RESET_DB: + return "MSG_CMD_RESET_DB"; + case MSG_CMD_GET_MEMSIZE: + return "MSG_CMD_GET_MEMSIZE"; // 45 - case MSG_CMD_GET_QUICKPANEL_DATA: - return "MSG_CMD_GET_QUICKPANEL_DATA"; - case MSG_CMD_COUNT_BY_MSGTYPE: - return "MSG_CMD_COUNT_BY_MSGTYPE"; - case MSG_CMD_RESET_DB: - return "MSG_CMD_RESET_DB"; - case MSG_CMD_GET_MEMSIZE: - return "MSG_CMD_GET_MEMSIZE"; - case MSG_CMD_BACKUP_MESSAGE: - return "MSG_CMD_BACKUP_MESSAGE"; - + case MSG_CMD_BACKUP_MESSAGE: + return "MSG_CMD_BACKUP_MESSAGE"; + case MSG_CMD_RESTORE_MESSAGE: + return "MSG_CMD_RESTORE_MESSAGE"; + case MSG_CMD_UPDATE_THREAD_READ: + return "MSG_CMD_UPDATE_THREAD_READ"; + case MSG_CMD_REG_SYNCML_MSG_OPERATION_CB: + return "MSG_CMD_REG_SYNCML_MSG_OPERATION_CB"; + case MSG_CMD_SYNCML_OPERATION: + return "MSG_CMD_SYNCML_OPERATION"; // 50 - case MSG_CMD_RESTORE_MESSAGE: - return "MSG_CMD_RESTORE_MESSAGE"; - case MSG_CMD_UPDATE_THREAD_READ: - return "MSG_CMD_UPDATE_THREAD_READ"; - case MSG_CMD_REG_SYNCML_MSG_OPERATION_CB: - return "MSG_CMD_REG_SYNCML_MSG_OPERATION_CB"; - case MSG_CMD_SYNCML_OPERATION: - return "MSG_CMD_SYNCML_OPERATION"; - case MSG_CMD_GET_REPORT_STATUS: - return "MSG_CMD_GET_REPORT_STATUS"; - + case MSG_CMD_GET_REPORT_STATUS: + return "MSG_CMD_GET_REPORT_STATUS"; + case MSG_CMD_GET_THREAD_ID_BY_ADDRESS: + return "MSG_CMD_GET_THREAD_ID_BY_ADDRESS"; + case MSG_CMD_GET_THREAD_INFO: + return "MSG_CMD_GET_THREAD_INFO"; + case MSG_CMD_GET_SMSC_OPT: + return "MSG_CMD_GET_SMSC_OPT"; + case MSG_CMD_GET_CB_OPT: + return "MSG_CMD_GET_CB_OPT"; // 55 - case MSG_CMD_GET_THREAD_ID_BY_ADDRESS: - return "MSG_CMD_GET_THREAD_ID_BY_ADDRESS"; - case MSG_CMD_GET_THREAD_INFO: - return "MSG_CMD_GET_THREAD_INFO"; - case MSG_CMD_GET_SMSC_OPT: - return "MSG_CMD_GET_SMSC_OPT"; - case MSG_CMD_GET_CB_OPT: - return "MSG_CMD_GET_CB_OPT"; - + case MSG_CMD_GET_SMS_SEND_OPT: + return "MSG_CMD_GET_SMS_SEND_OPT"; + case MSG_CMD_GET_MMS_SEND_OPT: + return "MSG_CMD_GET_MMS_SEND_OPT"; + case MSG_CMD_GET_MMS_RECV_OPT: + return "MSG_CMD_GET_MMS_RECV_OPT"; + case MSG_CMD_GET_PUSH_MSG_OPT: + return "MSG_CMD_GET_PUSH_MSG_OPT"; + case MSG_CMD_GET_VOICE_MSG_OPT: + return "MSG_CMD_GET_VOICE_MSG_OPT"; // 60 - case MSG_CMD_GET_SMS_SEND_OPT: - return "MSG_CMD_GET_SMS_SEND_OPT"; - case MSG_CMD_GET_MMS_SEND_OPT: - return "MSG_CMD_GET_MMS_SEND_OPT"; - case MSG_CMD_GET_MMS_RECV_OPT: - return "MSG_CMD_GET_MMS_RECV_OPT"; - case MSG_CMD_GET_PUSH_MSG_OPT: - return "MSG_CMD_GET_PUSH_MSG_OPT"; - case MSG_CMD_GET_VOICE_MSG_OPT: - return "MSG_CMD_GET_VOICE_MSG_OPT"; - + case MSG_CMD_GET_GENERAL_MSG_OPT: + return "MSG_CMD_GET_GENERAL_MSG_OPT"; + case MSG_CMD_GET_MSG_SIZE_OPT: + return "MSG_CMD_GET_MSG_SIZE_OPT"; + case MSG_CMD_SET_SMSC_OPT: + return "MSG_CMD_SET_SMSC_OPT"; + case MSG_CMD_SET_CB_OPT: + return "MSG_CMD_SET_CB_OPT"; + case MSG_CMD_SET_SMS_SEND_OPT: + return "MSG_CMD_SET_SMS_SEND_OPT"; // 65 - case MSG_CMD_GET_GENERAL_MSG_OPT: - return "MSG_CMD_GET_GENERAL_MSG_OPT"; - case MSG_CMD_GET_MSG_SIZE_OPT: - return "MSG_CMD_GET_MSG_SIZE_OPT"; - case MSG_CMD_SET_SMSC_OPT: - return "MSG_CMD_SET_SMSC_OPT"; - - + case MSG_CMD_SET_MMS_SEND_OPT: + return "MSG_CMD_SET_MMS_SEND_OPT"; + case MSG_CMD_SET_MMS_RECV_OPT: + return "MSG_CMD_SET_MMS_RECV_OPT"; + case MSG_CMD_SET_PUSH_MSG_OPT: + return "MSG_CMD_SET_PUSH_MSG_OPT"; + case MSG_CMD_SET_VOICE_MSG_OPT: + return "MSG_CMD_SET_VOICE_MSG_OPT"; + case MSG_CMD_SET_GENERAL_MSG_OPT: + return "MSG_CMD_SET_GENERAL_MSG_OPT"; // 70 - case MSG_CMD_SET_CB_OPT: - return "MSG_CMD_SET_CB_OPT"; - case MSG_CMD_SET_SMS_SEND_OPT: - return "MSG_CMD_SET_SMS_SEND_OPT"; - case MSG_CMD_SET_MMS_SEND_OPT: - return "MSG_CMD_SET_MMS_SEND_OPT"; - case MSG_CMD_SET_MMS_RECV_OPT: - return "MSG_CMD_SET_MMS_RECV_OPT"; - case MSG_CMD_SET_PUSH_MSG_OPT: - return "MSG_CMD_SET_PUSH_MSG_OPT"; - + case MSG_CMD_SET_MSG_SIZE_OPT: + return "MSG_CMD_SET_MSG_SIZE_OPT"; + case MSG_CMD_REG_INCOMING_PUSH_MSG_CB: + return "MSG_CMD_REG_INCOMING_PUSH_MSG_CB"; + case MSG_CMD_PLG_INCOMING_PUSH_IND: + return "MSG_CMD_PLG_INCOMING_PUSH_IND"; + case MSG_CMD_REG_INCOMING_CB_MSG_CB: + return "MSG_CMD_REG_INCOMING_CB_MSG_CB"; + case MSG_CMD_PLG_INCOMING_CB_IND: + return "MSG_CMD_PLG_INCOMING_CB_IND"; // 75 - case MSG_CMD_SET_VOICE_MSG_OPT: - return "MSG_CMD_SET_VOICE_MSG_OPT"; - case MSG_CMD_SET_GENERAL_MSG_OPT: - return "MSG_CMD_SET_GENERAL_MSG_OPT"; - case MSG_CMD_SET_MSG_SIZE_OPT: - return "MSG_CMD_SET_MSG_SIZE_OPT"; -// 80 - case MSG_CMD_REG_INCOMING_PUSH_MSG_CB: - return "MSG_CMD_REG_INCOMING_PUSH_MSG_CB"; - case MSG_CMD_PLG_INCOMING_PUSH_IND: - return "MSG_CMD_PLG_INCOMING_PUSH_IND"; - case MSG_CMD_REG_INCOMING_CB_MSG_CB: - return "MSG_CMD_REG_INCOMING_CB_MSG_CB"; - case MSG_CMD_PLG_INCOMING_CB_IND: - return "MSG_CMD_PLG_INCOMING_CB_IND"; - case MSG_CMD_ADD_PUSH_EVENT: - return "MSG_CMD_ADD_PUSH_EVENT"; -//85 - case MSG_CMD_DELETE_PUSH_EVENT: - return "MSG_CMD_DELETE_PUSH_EVENT"; - case MSG_CMD_UPDATE_PUSH_EVENT: - return "MSG_CMD_UPDATE_PUSH_EVENT"; - case MSG_CMD_DELETE_MESSAGE_BY_LIST : - return "MSG_CMD_DELETE_MESSAGE_BY_LIST"; - case MSG_CMD_SET_FILTER_ACTIVATION : - return "MSG_CMD_SET_FILTER_ACTIVATION"; - case MSG_CMD_ADD_SIM_MSG : - return "MSG_CMD_ADD_SIM_MSG"; -//90 - case MSG_CMD_PLG_RESEND_MESSAGE: - return "MSG_CMD_PLG_RESEND_MESSAGE"; -#ifdef MSG_PENDING_PUSH_MESSAGE - case MSG_CMD_SEND_PENDING_PUSH_MESSAGE: - return "MSG_CMD_SEND_PENDING_PUSH_MESSAGE"; -#endif - case MSG_CMD_REG_REPORT_MSG_INCOMING_CB: - return "MSG_CMD_REG_REPORT_MSG_INCOMING_CB"; + case MSG_CMD_ADD_PUSH_EVENT: + return "MSG_CMD_ADD_PUSH_EVENT"; + case MSG_CMD_DELETE_PUSH_EVENT: + return "MSG_CMD_DELETE_PUSH_EVENT"; + case MSG_CMD_UPDATE_PUSH_EVENT: + return "MSG_CMD_UPDATE_PUSH_EVENT"; + case MSG_CMD_DELETE_MESSAGE_BY_LIST: + return "MSG_CMD_DELETE_MESSAGE_BY_LIST"; + case MSG_CMD_SET_FILTER_ACTIVATION: + return "MSG_CMD_SET_FILTER_ACTIVATION"; +//80 + case MSG_CMD_ADD_SIM_MSG: + return "MSG_CMD_ADD_SIM_MSG"; + case MSG_CMD_PLG_RESEND_MESSAGE: + return "MSG_CMD_PLG_RESEND_MESSAGE"; + case MSG_CMD_REG_REPORT_MSG_INCOMING_CB: + return "MSG_CMD_REG_REPORT_MSG_INCOMING_CB"; + case MSG_CMD_UPDATE_IMSI: + return "MSG_CMD_UPDATE_IMSI"; + #ifdef FEATURE_SMS_CDMA - case MSG_CMD_PLG_CHECK_UNIQUENESS: - return "MSG_CMD_PLG_CHECK_UNIQUENESS"; + case MSG_CMD_PLG_CHECK_UNIQUENESS: + return "MSG_CMD_PLG_CHECK_UNIQUENESS"; #endif - case MSG_CMD_UPDATE_IMSI: - return "MSG_CMD_UPDATE_IMSI"; - default: - return "Unknown Command Type!!!"; + + default: + return "Unknown Command Type!!!"; } return NULL; @@ -256,221 +228,201 @@ const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType) switch ( evtType ) { // 0 - case MSG_EVENT_OPEN_HANDLE: - return "MSG_EVENT_OPEN_HANDLE"; - case MSG_EVENT_CLOSE_HANDLE: - return "MSG_EVENT_CLOSE_HANDLE"; - case MSG_EVENT_GET_STORAGELIST: - return "MSG_EVENT_GET_STORAGELIST"; - case MSG_EVENT_ADD_MSG: - return "MSG_EVENT_ADD_MSG"; - case MSG_EVENT_ADD_SYNCML_MSG: - return "MSG_EVENT_ADD_SYNCML_MSG"; + case MSG_EVENT_OPEN_HANDLE: + return "MSG_EVENT_OPEN_HANDLE"; + case MSG_EVENT_CLOSE_HANDLE: + return "MSG_EVENT_CLOSE_HANDLE"; + case MSG_EVENT_GET_STORAGELIST: + return "MSG_EVENT_GET_STORAGELIST"; + case MSG_EVENT_ADD_MSG: + return "MSG_EVENT_ADD_MSG"; + case MSG_EVENT_ADD_SYNCML_MSG: + return "MSG_EVENT_ADD_SYNCML_MSG"; // 5 - case MSG_EVENT_UPDATE_MSG: - return "MSG_EVENT_UPDATE_MSG"; - case MSG_EVENT_UPDATE_READ: - return "MSG_EVENT_UPDATE_READ"; - case MSG_EVENT_UPDATE_PROTECTED: - return "MSG_EVENT_UPDATE_PROTECTED"; - case MSG_EVENT_DELETE_MSG: - return "MSG_EVENT_DELETE_MSG"; - case MSG_EVENT_DELALL_MSGINFOLDER: - return "MSG_EVENT_DELALL_MSGINFOLDER"; + case MSG_EVENT_UPDATE_MSG: + return "MSG_EVENT_UPDATE_MSG"; + case MSG_EVENT_UPDATE_READ: + return "MSG_EVENT_UPDATE_READ"; + case MSG_EVENT_UPDATE_PROTECTED: + return "MSG_EVENT_UPDATE_PROTECTED"; + case MSG_EVENT_DELETE_MSG: + return "MSG_EVENT_DELETE_MSG"; + case MSG_EVENT_DELALL_MSGINFOLDER: + return "MSG_EVENT_DELALL_MSGINFOLDER"; // 10 - case MSG_EVENT_MOVE_MSGTOFOLDER: - return "MSG_EVENT_MOVE_MSGTOFOLDER"; - case MSG_EVENT_MOVE_MSGTOSTORAGE: - return "MSG_EVENT_MOVE_MSGTOSTORAGE"; - case MSG_EVENT_COUNT_MSG: - return "MSG_EVENT_COUNT_MSG"; - case MSG_EVENT_GET_MSG: - return "MSG_EVENT_GET_MSG"; - case MSG_EVENT_GET_FOLDERVIEWLIST: - return "MSG_EVENT_GET_FOLDERVIEWLIST"; + case MSG_EVENT_MOVE_MSGTOFOLDER: + return "MSG_EVENT_MOVE_MSGTOFOLDER"; + case MSG_EVENT_MOVE_MSGTOSTORAGE: + return "MSG_EVENT_MOVE_MSGTOSTORAGE"; + case MSG_EVENT_COUNT_MSG: + return "MSG_EVENT_COUNT_MSG"; + case MSG_EVENT_GET_MSG: + return "MSG_EVENT_GET_MSG"; + case MSG_EVENT_ADD_FOLDER: + return "MSG_EVENT_ADD_FOLDER"; // 15 - case MSG_EVENT_ADD_FOLDER: - return "MSG_EVENT_ADD_FOLDER"; - case MSG_EVENT_UPDATE_FOLDER: - return "MSG_EVENT_UPDATE_FOLDER"; - case MSG_EVENT_DELETE_FOLDER: - return "MSG_EVENT_DELETE_FOLDER"; - case MSG_EVENT_GET_FOLDERLIST: - return "MSG_EVENT_GET_FOLDERLIST"; - case MSG_EVENT_ADD_FILTER: - return "MSG_EVENT_ADD_FILTER"; + case MSG_EVENT_UPDATE_FOLDER: + return "MSG_EVENT_UPDATE_FOLDER"; + case MSG_EVENT_DELETE_FOLDER: + return "MSG_EVENT_DELETE_FOLDER"; + case MSG_EVENT_GET_FOLDERLIST: + return "MSG_EVENT_GET_FOLDERLIST"; + case MSG_EVENT_ADD_FILTER: + return "MSG_EVENT_ADD_FILTER"; + case MSG_EVENT_UPDATE_FILTER: + return "MSG_EVENT_UPDATE_FILTER"; //20 - case MSG_EVENT_UPDATE_FILTER: - return "MSG_EVENT_UPDATE_FILTER"; - case MSG_EVENT_DELETE_FILTER: - return "MSG_EVENT_DELETE_FILTER"; - case MSG_EVENT_GET_FILTERLIST: - return "MSG_EVENT_GET_FILTERLIST"; - case MSG_EVENT_SET_FILTER_OPERATION: - return "MSG_EVENT_SET_FILTER_OPERATION"; - case MSG_EVENT_GET_FILTER_OPERATION: - return "MSG_EVENT_GET_FILTER_OPERATION"; + case MSG_EVENT_DELETE_FILTER: + return "MSG_EVENT_DELETE_FILTER"; + case MSG_EVENT_GET_FILTERLIST: + return "MSG_EVENT_GET_FILTERLIST"; + case MSG_EVENT_SET_FILTER_OPERATION: + return "MSG_EVENT_SET_FILTER_OPERATION"; + case MSG_EVENT_GET_FILTER_OPERATION: + return "MSG_EVENT_GET_FILTER_OPERATION"; + case MSG_EVENT_SUBMIT_REQ: + return "MSG_EVENT_SUBMIT_REQ"; //25 - case MSG_EVENT_GET_MSG_TYPE: - return "MSG_EVENT_GET_MSG_TYPE"; - case MSG_EVENT_SUBMIT_REQ: - return "MSG_EVENT_SUBMIT_REQ"; - case MSG_EVENT_CANCEL_REQ: - return "MSG_EVENT_CANCEL_REQ"; - case MSG_EVENT_REG_SENT_STATUS_CB: - return "MSG_EVENT_REG_SENT_STATUS_CB"; - case MSG_EVENT_REG_STORAGE_CHANGE_CB: - return "MSG_EVENT_REG_STORAGE_CHANGE_CB"; - + case MSG_EVENT_REG_SENT_STATUS_CB: + return "MSG_EVENT_REG_SENT_STATUS_CB"; + case MSG_EVENT_REG_STORAGE_CHANGE_CB: + return "MSG_EVENT_REG_STORAGE_CHANGE_CB"; + case MSG_EVENT_REG_INCOMING_MSG_CB: + return "MSG_EVENT_REG_INCOMING_MSG_CB"; + case MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB: + return "MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB"; + case MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB: + return "MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB"; // 30 - case MSG_EVENT_REG_INCOMING_MSG_CB: - return "MSG_EVENT_REG_INCOMING_MSG_CB"; - case MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB: - return "MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB"; - case MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB: - return "MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB"; - case MSG_EVENT_REG_INCOMING_LBS_MSG_CB: - return "MSG_EVENT_REG_INCOMING_LBS_MSG_CB"; - case MSG_EVENT_PLG_SENT_STATUS_CNF: - return "MSG_EVENT_PLG_SENT_STATUS_CNF"; - + case MSG_EVENT_REG_INCOMING_LBS_MSG_CB: + return "MSG_EVENT_REG_INCOMING_LBS_MSG_CB"; + case MSG_EVENT_PLG_SENT_STATUS_CNF: + return "MSG_EVENT_PLG_SENT_STATUS_CNF"; + case MSG_EVENT_PLG_STORAGE_CHANGE_IND: + return "MSG_EVENT_PLG_STORAGE_CHANGE_IND"; + case MSG_EVENT_PLG_INCOMING_MSG_IND: + return "MSG_EVENT_PLG_INCOMING_MSG_IND"; + case MSG_EVENT_PLG_INCOMING_MMS_CONF: + return "MSG_EVENT_PLG_INCOMING_MMS_CONF"; // 35 - case MSG_EVENT_PLG_STORAGE_CHANGE_IND: - return "MSG_EVENT_STORAGE_CHANGE_CB"; - case MSG_EVENT_PLG_INCOMING_MSG_IND: - return "MSG_EVENT_PLG_INCOMING_MSG_IND"; - case MSG_EVENT_PLG_INCOMING_MMS_CONF: - return "MSG_EVENT_PLG_INCOMING_MMS_CONF"; - case MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND: - return "MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND"; - case MSG_EVENT_PLG_INCOMING_LBS_MSG_IND: - return "MSG_EVENT_PLG_INCOMING_LBS_MSG_IND"; - + case MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND: + return "MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND"; + case MSG_EVENT_PLG_INCOMING_LBS_MSG_IND: + return "MSG_EVENT_PLG_INCOMING_LBS_MSG_IND"; + case MSG_EVENT_PLG_INIT_SIM_BY_SAT: + return "MSG_EVENT_PLG_INIT_SIM_BY_SAT"; + case MSG_EVENT_GET_THREADVIEWLIST: + return "MSG_EVENT_GET_THREADVIEWLIST"; + case MSG_EVENT_DELETE_THREADMESSAGELIST: + return "MSG_EVENT_DELETE_THREADMESSAGELIST"; // 40 - case MSG_EVENT_PLG_INIT_SIM_BY_SAT: - return "MSG_EVENT_PLG_INIT_SIM_BY_SAT"; - case MSG_EVENT_GET_THREADVIEWLIST: - return "MSG_EVENT_GET_THREADVIEWLIST"; - case MSG_EVENT_GET_CONVERSATIONVIEWLIST: - return "MSG_EVENT_GET_CONVERSATIONVIEWLIST"; - case MSG_EVENT_DELETE_THREADMESSAGELIST: - return "MSG_EVENT_DELETE_THREADMESSAGELIST"; - case MSG_EVENT_GET_CONTACT_COUNT: - return "MSG_EVENT_GET_CONTACT_COUNT"; - + case MSG_EVENT_GET_CONTACT_COUNT: + return "MSG_EVENT_GET_CONTACT_COUNT"; + case MSG_EVENT_GET_QUICKPANEL_DATA: + return "MSG_EVENT_GET_QUICKPANEL_DATA"; + case MSG_EVENT_COUNT_BY_MSGTYPE: + return "MSG_EVENT_COUNT_BY_MSGTYPE"; + case MSG_EVENT_RESET_DB: + return "MSG_EVENT_RESET_DB"; + case MSG_EVENT_GET_MEMSIZE: + return "MSG_EVENT_GET_MEMSIZE"; // 45 - case MSG_EVENT_GET_QUICKPANEL_DATA: - return "MSG_EVENT_GET_QUICKPANEL_DATA"; - case MSG_EVENT_COUNT_BY_MSGTYPE: - return "MSG_EVENT_COUNT_BY_MSGTYPE"; - case MSG_EVENT_RESET_DB: - return "MSG_EVENT_RESET_DB"; - case MSG_EVENT_GET_MEMSIZE: - return "MSG_EVENT_GET_MEMSIZE"; - case MSG_EVENT_BACKUP_MESSAGE: - return "MSG_EVENT_BACKUP_MESSAGE"; - + case MSG_EVENT_BACKUP_MESSAGE: + return "MSG_EVENT_BACKUP_MESSAGE"; + case MSG_EVENT_RESTORE_MESSAGE: + return "MSG_EVENT_RESTORE_MESSAGE"; + case MSG_EVENT_UPDATE_THREAD_READ: + return "MSG_EVENT_UPDATE_THREAD_READ"; + case MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB: + return "MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB"; + case MSG_EVENT_SYNCML_OPERATION: + return "MSG_EVENT_SYNCML_OPERATION"; // 50 - case MSG_EVENT_RESTORE_MESSAGE: - return "MSG_EVENT_RESTORE_MESSAGE"; - case MSG_EVENT_UPDATE_THREAD_READ: - return "MSG_EVENT_UPDATE_THREAD_READ"; - case MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB: - return "MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB"; - case MSG_EVENT_SYNCML_OPERATION: - return "MSG_EVENT_SYNCML_OPERATION"; - case MSG_EVENT_GET_REPORT_STATUS: - return "MSG_EVENT_GET_REPORT_STATUS"; - + case MSG_EVENT_GET_REPORT_STATUS: + return "MSG_EVENT_GET_REPORT_STATUS"; + case MSG_EVENT_GET_THREAD_ID_BY_ADDRESS: + return "MSG_EVENT_GET_THREAD_ID_BY_ADDRESS"; + case MSG_EVENT_GET_THREAD_INFO: + return "MSG_EVENT_GET_THREAD_INFO"; + case MSG_EVENT_GET_SMSC_OPT: + return "MSG_EVENT_GET_SMSC_OPT"; + case MSG_EVENT_GET_CB_OPT: + return "MSG_EVENT_GET_CB_OPT"; // 55 - case MSG_CMD_GET_THREAD_ID_BY_ADDRESS: - return "MSG_CMD_GET_THREAD_ID_BY_ADDRESS"; - case MSG_CMD_GET_THREAD_INFO: - return "MSG_CMD_GET_THREAD_INFO"; - case MSG_EVENT_GET_SMSC_OPT: - return "MSG_EVENT_GET_SMSC_OPT"; - case MSG_EVENT_GET_CB_OPT: - return "MSG_EVENT_GET_CB_OPT"; - + case MSG_EVENT_GET_SMS_SEND_OPT: + return "MSG_EVENT_GET_SMS_SEND_OPT"; + case MSG_EVENT_GET_MMS_SEND_OPT: + return "MSG_EVENT_GET_MMS_SEND_OPT"; + case MSG_EVENT_GET_MMS_RECV_OPT: + return "MSG_EVENT_GET_MMS_RECV_OPT"; + case MSG_EVENT_GET_PUSH_MSG_OPT: + return "MSG_EVENT_GET_PUSH_MSG_OPT"; + case MSG_EVENT_GET_VOICE_MSG_OPT: + return "MSG_EVENT_GET_VOICE_MSG_OPT"; // 60 - case MSG_EVENT_GET_SMS_SEND_OPT: - return "MSG_EVENT_GET_SMS_SEND_OPT"; - case MSG_EVENT_GET_MMS_SEND_OPT: - return "MSG_EVENT_GET_MMS_SEND_OPT"; - case MSG_EVENT_GET_MMS_RECV_OPT: - return "MSG_EVENT_GET_MMS_RECV_OPT"; - case MSG_EVENT_GET_PUSH_MSG_OPT: - return "MSG_EVENT_GET_PUSH_MSG_OPT"; - case MSG_EVENT_GET_VOICE_MSG_OPT: - return "MSG_EVENT_GET_VOICE_MSG_OPT"; - + case MSG_EVENT_GET_GENERAL_MSG_OPT: + return "MSG_EVENT_GET_GENERAL_MSG_OPT"; + case MSG_EVENT_GET_MSG_SIZE_OPT: + return "MSG_EVENT_GET_MSG_SIZE_OPT"; + case MSG_EVENT_SET_SMSC_OPT: + return "MSG_EVENT_SET_SMSC_OPT"; + case MSG_EVENT_SET_CB_OPT: + return "MSG_EVENT_SET_CB_OPT"; + case MSG_EVENT_SET_SMS_SEND_OPT: + return "MSG_EVENT_SET_SMS_SEND_OPT"; // 65 - case MSG_EVENT_GET_GENERAL_MSG_OPT: - return "MSG_EVENT_GET_GENERAL_MSG_OPT"; - case MSG_EVENT_GET_MSG_SIZE_OPT: - return "MSG_EVENT_GET_MSG_SIZE_OPT"; - case MSG_EVENT_SET_SMSC_OPT: - return "MSG_EVENT_SET_SMSC_OPT"; + case MSG_EVENT_SET_MMS_SEND_OPT: + return "MSG_EVENT_SET_MMS_SEND_OPT"; + case MSG_EVENT_SET_MMS_RECV_OPT: + return "MSG_EVENT_SET_MMS_RECV_OPT"; + case MSG_EVENT_SET_PUSH_MSG_OPT: + return "MSG_EVENT_SET_PUSH_MSG_OPT"; + case MSG_EVENT_SET_VOICE_MSG_OPT: + return "MSG_EVENT_SET_VOICE_MSG_OPT"; + case MSG_EVENT_SET_GENERAL_MSG_OPT: + return "MSG_EVENT_SET_GENERAL_MSG_OPT"; // 70 - case MSG_EVENT_SET_CB_OPT: - return "MSG_EVENT_SET_CB_OPT"; - case MSG_EVENT_SET_SMS_SEND_OPT: - return "MSG_EVENT_SET_SMS_SEND_OPT"; - case MSG_EVENT_SET_MMS_SEND_OPT: - return "MSG_EVENT_SET_MMS_SEND_OPT"; - case MSG_EVENT_SET_MMS_RECV_OPT: - return "MSG_EVENT_SET_MMS_RECV_OPT"; - case MSG_EVENT_SET_PUSH_MSG_OPT: - return "MSG_EVENT_SET_PUSH_MSG_OPT"; + case MSG_EVENT_SET_MSG_SIZE_OPT: + return "MSG_EVENT_SET_MSG_SIZE_OPT"; + case MSG_EVENT_REG_INCOMING_PUSH_MSG_CB: + return "MSG_EVENT_REG_INCOMING_PUSH_MSG_CB"; + case MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND: + return "MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND"; + case MSG_EVENT_REG_INCOMING_CB_MSG_CB: + return "MSG_EVENT_REG_INCOMING_CB_MSG_CB"; + case MSG_EVENT_PLG_INCOMING_CB_MSG_IND: + return "MSG_EVENT_PLG_INCOMING_CB_MSG_IND"; // 75 - case MSG_EVENT_SET_VOICE_MSG_OPT: - return "MSG_EVENT_SET_VOICE_MSG_OPT"; - case MSG_EVENT_SET_GENERAL_MSG_OPT: - return "MSG_EVENT_SET_GENERAL_MSG_OPT"; - case MSG_EVENT_SET_MSG_SIZE_OPT: - return "MSG_EVENT_SET_MSG_SIZE_OPT"; -//80 - case MSG_EVENT_REG_INCOMING_PUSH_MSG_CB: - return "MSG_EVENT_REG_INCOMING_PUSH_MSG_CB"; - case MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND: - return "MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND"; - case MSG_EVENT_REG_INCOMING_CB_MSG_CB: - return "MSG_EVENT_REG_INCOMING_CB_MSG_CB"; - case MSG_EVENT_PLG_INCOMING_CB_MSG_IND: - return "MSG_EVENT_PLG_INCOMING_CB_MSG_IND"; - case MSG_EVENT_ADD_PUSH_EVENT: - return "MSG_EVENT_ADD_PUSH_EVENT"; -//85 - case MSG_EVENT_DELETE_PUSH_EVENT: - return "MSG_EVENT_DELETE_PUSH_EVENT"; - case MSG_EVENT_UPDATE_PUSH_EVENT: - return "MSG_EVENT_UPDATE_PUSH_EVENT"; - case MSG_EVENT_DELETE_MESSAGE_BY_LIST : - return "MSG_EVENT_DELETE_MESSAGE_BY_LIST"; - case MSG_EVENT_SET_FILTER_ACTIVATION : - return "MSG_EVENT_SET_FILTER_ACTIVATION"; - case MSG_EVENT_ADD_SIM_MSG : - return "MSG_EVENT_ADD_SIM_MSG"; + case MSG_EVENT_ADD_PUSH_EVENT: + return "MSG_EVENT_ADD_PUSH_EVENT"; + case MSG_EVENT_DELETE_PUSH_EVENT: + return "MSG_EVENT_DELETE_PUSH_EVENT"; + case MSG_EVENT_UPDATE_PUSH_EVENT: + return "MSG_EVENT_UPDATE_PUSH_EVENT"; + case MSG_EVENT_DELETE_MESSAGE_BY_LIST: + return "MSG_EVENT_DELETE_MESSAGE_BY_LIST"; + case MSG_EVENT_SET_FILTER_ACTIVATION: + return "MSG_EVENT_SET_FILTER_ACTIVATION"; +// 80 + case MSG_EVENT_ADD_SIM_MSG: + return "MSG_EVENT_ADD_SIM_MSG"; + case MSG_EVENT_PLG_RESEND_MESSAGE: + return "MSG_EVENT_PLG_RESEND_MESSAGE"; + case MSG_EVENT_REG_REPORT_MSG_INCOMING_CB: + return "MSG_EVENT_REG_REPORT_MSG_INCOMING_CB"; + case MSG_EVENT_UPDATE_IMSI: + return "MSG_EVENT_UPDATE_IMSI"; -//90 - case MSG_EVENT_PLG_RESEND_MESSAGE: - return "MSG_EVENT_PLG_RESEND_MESSAGE"; -#ifdef MSG_PENDING_PUSH_MESSAGE - case MSG_EVENT_SEND_PENDING_PUSH_MESSAGE: - return "MSG_EVENT_SEND_PENDING_PUSH_MESSAGE"; -#endif - case MSG_EVENT_REG_REPORT_MSG_INCOMING_CB: - return "MSG_EVENT_REG_REPORT_MSG_INCOMING_CB"; - case MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND: - return "MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND"; #ifdef FEATURE_SMS_CDMA - case MSG_EVENT_PLG_CHECK_UNIQUENESS: - return "MSG_EVENT_PLG_CHECK_UNIQUENESS"; + case MSG_EVENT_PLG_CHECK_UNIQUENESS: + return "MSG_EVENT_PLG_CHECK_UNIQUENESS"; #endif - case MSG_EVENT_UPDATE_IMSI: - return "MSG_EVENT_UPDATE_IMSI"; - default: - return "Unknown Event Type!!!"; + + case MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND: + return "MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND"; + + default: + return "Unknown Event Type!!!"; } return NULL; diff --git a/utils/MsgIpcSocket.cpp b/utils/MsgIpcSocket.cpp index e081326..ca6cde2 100755 --- a/utils/MsgIpcSocket.cpp +++ b/utils/MsgIpcSocket.cpp @@ -19,17 +19,15 @@ #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> -#include <sys/smack.h> #include <errno.h> #include <unistd.h> #include <errno.h> - +#include <glib.h> #include "MsgDebug.h" #include "MsgException.h" #include "MsgIpcSocket.h" -#include "MsgZoneManager.h" /*================================================================================================== IMPLEMENTATION OF MsgIpcClientSocket - Member Functions @@ -51,7 +49,7 @@ msg_error_t MsgIpcClientSocket::connect(const char* path) sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd < 0) { - THROW(MsgException::IPC_ERROR,"socket not opened %s",strerror(errno)); + THROW(MsgException::IPC_ERROR,"socket not opened %s",g_strerror(errno)); } struct sockaddr_un serverSA = {0, }; @@ -64,9 +62,9 @@ msg_error_t MsgIpcClientSocket::connect(const char* path) if (::connect(sockfd, (struct sockaddr *)&serverSA, len) == CUSTOM_SOCKET_ERROR) { if(errno == EACCES) - THROW(MsgException::SECURITY_ERROR,"cannot connect server %s", strerror(errno)); + THROW(MsgException::SECURITY_ERROR,"cannot connect server %s", g_strerror(errno)); else - THROW(MsgException::IPC_ERROR,"cannot connect server %s", strerror(errno)); + THROW(MsgException::IPC_ERROR,"cannot connect server %s", g_strerror(errno)); } /* add fd for select() */ @@ -78,13 +76,13 @@ msg_error_t MsgIpcClientSocket::connect(const char* path) /* read remote fd for reg func */ char *rfd = NULL; - AutoPtr<char> wrap(&rfd); + unique_ptr<char*, void(*)(char**)> wrap(&rfd, unique_ptr_deleter); unsigned int rlen; read(&rfd, &rlen); if (rfd == NULL) { - THROW(MsgException::IPC_ERROR,"rfd is NULL %s", strerror(errno)); + THROW(MsgException::IPC_ERROR,"rfd is NULL %s", g_strerror(errno)); } memcpy(&remotefd, rfd, sizeof(rlen)); @@ -135,7 +133,7 @@ int MsgIpcClientSocket::writen (const char *buf, unsigned int len) while (nleft > 0) { nwrite = ::write(sockfd, (const void*) buf, nleft); if (nwrite < 0) { - MSG_FATAL("writen: sockfd [%d] error [%s]", sockfd, strerror(errno)); + MSG_FATAL("writen: sockfd [%d] error [%s]", sockfd, g_strerror(errno)); return nwrite; } else if (nwrite == 0) { break; @@ -185,7 +183,7 @@ int MsgIpcClientSocket::readn( char *buf, unsigned int len ) while (nleft > 0) { nread = ::read(sockfd, (void*) buf, nleft); if (nread < 0) { - MSG_FATAL("WARNING read value %d: %s", nread, strerror(errno)); + MSG_FATAL("WARNING read value %d: %s", nread, g_strerror(errno)); return nread; } else if( nread == 0 ) { break; @@ -245,12 +243,18 @@ int MsgIpcClientSocket::read(char** buf, unsigned int* len) return CUSTOM_SOCKET_ERROR; } + *len = 0; + char clen[sizeof(int)] = {0}; + /* read the data size first */ - int n = readn((char*) len, sizeof(int)); + int n = readn(clen, sizeof(int)); + memcpy(len, clen, sizeof(int)); + if (n == CLOSE_CONNECTION_BY_SIGNAL) { /* if msgfw gets down, it signals to all IPC clients */ MSG_FATAL("sockfd [%d] CLOSE_CONNECTION_BY_SIGNAL", sockfd); return n; - } else if (n != sizeof(int)) { + } + else if (n != sizeof(int)) { MSG_FATAL("WARNING: read header_size[%d] not matched [%d]", n, sizeof(int)); return CUSTOM_SOCKET_ERROR; } @@ -310,7 +314,7 @@ msg_error_t MsgIpcServerSocket::open(const char* path) sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd == CUSTOM_SOCKET_ERROR) { - MSG_FATAL("socket failed: %s", strerror(errno)); + MSG_FATAL("socket failed: %s", g_strerror(errno)); return MSG_ERR_UNKNOWN; } @@ -327,7 +331,7 @@ msg_error_t MsgIpcServerSocket::open(const char* path) int len = strlen(local.sun_path) + sizeof(local.sun_family); if (bind(sockfd, (struct sockaddr *)&local, len) == CUSTOM_SOCKET_ERROR) { - MSG_FATAL("bind: %s", strerror(errno)); + MSG_FATAL("bind: %s", g_strerror(errno)); return MSG_ERR_UNKNOWN; } @@ -345,22 +349,11 @@ msg_error_t MsgIpcServerSocket::open(const char* path) mode_t sock_mode = (S_IRWXU | S_IRWXG | S_IRWXO); /* has 777 permission */ if (chmod(path, sock_mode) == CUSTOM_SOCKET_ERROR) { - MSG_FATAL("chmod: %s", strerror(errno)); - return MSG_ERR_UNKNOWN; - } -#if 0 - if (smack_setlabel(path, "*", SMACK_LABEL_IPIN) != 0) { - MSG_FATAL("smack_setlabel error"); + MSG_FATAL("chmod: %s", g_strerror(errno)); return MSG_ERR_UNKNOWN; } - - if (smack_setlabel(path, "@", SMACK_LABEL_IPOUT) != 0) { - MSG_FATAL("smack_setlabel error"); - return MSG_ERR_UNKNOWN; - } -#endif if (listen(sockfd, CUSTOM_SOCKET_BACKLOG) == CUSTOM_SOCKET_ERROR) { - MSG_FATAL("listen: %s", strerror(errno)); + MSG_FATAL("listen: %s", g_strerror(errno)); return MSG_ERR_UNKNOWN; } @@ -385,14 +378,10 @@ msg_error_t MsgIpcServerSocket::accept() int t = sizeof(remote); int fd = ::accept(sockfd, (struct sockaddr *)&remote, (socklen_t*) &t); if (fd < 0) { - MSG_FATAL("accept: %s", strerror(errno)); + MSG_FATAL("accept: %s", g_strerror(errno)); return MSG_ERR_UNKNOWN; } - if(!MsgZoneIsAllowed(fd)) { - return MSG_ERR_NOT_ALLOWED_ZONE; - } - addfd(fd); MSG_DEBUG("%d is added", fd); @@ -443,7 +432,7 @@ int MsgIpcServerSocket::readn( int fd, char *buf, unsigned int len ) while (nleft > 0) { nread = ::read(fd, (void*)buf, nleft); if (nread < 0) { - MSG_FATAL("read: %s", strerror(errno)); + MSG_FATAL("read: %s", g_strerror(errno)); return nread; } else if (nread == 0) @@ -467,8 +456,12 @@ int MsgIpcServerSocket::read(int fd, char** buf, int* len ) return CUSTOM_SOCKET_ERROR; } + *len = 0; + char clen[sizeof(int)] = {0}; + /* read the data size first */ - int n = readn(fd, (char*) len, sizeof(int)); + int n = readn(fd, clen, sizeof(int)); + memcpy(len, clen, sizeof(int)); if (n == CLOSE_CONNECTION_BY_SIGNAL) { MSG_FATAL("fd %d CLOSE_CONNECTION_BY_SIGNAL", fd); @@ -481,6 +474,7 @@ int MsgIpcServerSocket::read(int fd, char** buf, int* len ) } MSG_DEBUG("MsgLen %d", *len); + if (*len == CLOSE_CONNECTION_BY_USER) return *len; @@ -513,7 +507,7 @@ int MsgIpcServerSocket::writen(int fd, const char *buf, unsigned int len) nwrite = ::send(fd, (const void*) buf, nleft, MSG_NOSIGNAL|MSG_DONTWAIT); if (nwrite < 0) { - MSG_FATAL("write: %s", strerror(errno)); + MSG_FATAL("write: %s", g_strerror(errno)); return nwrite; } else if (nwrite == 0) { /* Nothing is send. */ break; diff --git a/utils/MsgMmsMessage.cpp b/utils/MsgMmsMessage.cpp index eab6e22..615be28 100755 --- a/utils/MsgMmsMessage.cpp +++ b/utils/MsgMmsMessage.cpp @@ -19,6 +19,7 @@ #include <glib.h> #include <errno.h> #include <sys/stat.h> +#include <sys/smack.h> #include "MsgTypes.h" #include "MsgMmsTypes.h" @@ -27,6 +28,7 @@ #include "MsgUtilFile.h" #include "MsgSmil.h" #include "MsgDebug.h" +#include "MsgSerialize.h" static void __release_glist_element(gpointer data, gpointer user_data); static void __release_page_element(gpointer data, gpointer user_data); @@ -474,6 +476,9 @@ char* _MsgMmsSerializeMessageData(const MMS_MESSAGE_DATA_S *pMsgData, unsigned i buf = (char *)calloc(bufsize, 1); + if (buf == NULL) + return buf; + int serial_index = 0; memcpy(buf, &pMsgData->backup_type, sizeof(int)); @@ -664,6 +669,8 @@ bool _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S *pMsgData, const char *pDa for (int j = 0; j < pageCnt; ++j) { pPage = (MMS_PAGE_S *)calloc(sizeof(MMS_PAGE_S), 1); + if (pPage == NULL) + return false; memcpy(&pPage->mediaCnt, pData + offset, sizeof(int)); MSG_DEBUG("[#%2d][%5d][%d page] media count = %d", serial_index++, offset, j, pPage->mediaCnt); @@ -671,6 +678,10 @@ bool _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S *pMsgData, const char *pDa for (int i = 0; i < pPage->mediaCnt; ++i) { pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1); + if (pMedia == NULL) { + free(pPage); + return false; + } memcpy(pMedia, pData + offset, sizeof(MMS_MEDIA_S)); @@ -721,6 +732,8 @@ bool _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S *pMsgData, const char *pDa for (int i = 0; i < pMsgData->regionCnt; ++i) { pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1); + if (pRegion == NULL) + return false; memcpy(pRegion, pData + offset, sizeof(MMS_SMIL_REGION)); offset += sizeof(MMS_SMIL_REGION); @@ -735,6 +748,8 @@ bool _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S *pMsgData, const char *pDa for (int i = 0; i < pMsgData->attachCnt; ++i) { pAttach = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1); + if (pAttach == NULL) + return false; memcpy(pAttach, pData + offset, sizeof(MMS_ATTACH_S)); offset += sizeof(MMS_ATTACH_S); @@ -757,9 +772,10 @@ bool _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S *pMsgData, const char *pDa for (int i = 0; i < pMsgData->transitionCnt; ++i) { pTransition = (MMS_SMIL_TRANSITION *)calloc(sizeof(MMS_SMIL_TRANSITION), 1); + if (pTransition == NULL) + return false; memcpy(pTransition, pData + offset, sizeof(MMS_SMIL_TRANSITION)); - offset += sizeof(MMS_SMIL_TRANSITION); pMsgData->transitionlist = g_list_append(pMsgData->transitionlist, pTransition); @@ -772,9 +788,10 @@ bool _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S *pMsgData, const char *pDa for (int i = 0; i < pMsgData->metaCnt; ++i) { pMeta = (MMS_SMIL_META *)calloc(sizeof(MMS_SMIL_META), 1); + if (pMeta == NULL) + return false; memcpy(pMeta, pData + offset, sizeof(MMS_SMIL_META)); - offset += sizeof(MMS_SMIL_META); pMsgData->metalist = g_list_append(pMsgData->metalist, pMeta); @@ -923,8 +940,10 @@ void _MsgMmsPrint(MMS_MESSAGE_DATA_S *pMsgData) MMS_ADDRESS_DATA_S *MsgMmsCreateAddress(int addressType, const char *addressVal) { MMS_ADDRESS_DATA_S * pMmsAddressData = (MMS_ADDRESS_DATA_S * )calloc(1, sizeof(MMS_ADDRESS_DATA_S)); - pMmsAddressData->address_type = addressType; - pMmsAddressData->address_val = strdup(addressVal); + if (pMmsAddressData != NULL) { + pMmsAddressData->address_type = addressType; + pMmsAddressData->address_val = strdup(addressVal); + } return pMmsAddressData; } @@ -1028,72 +1047,74 @@ void MsgMmsInitHeader(MMS_HEADER_DATA_S *pMmsHeaderData) MMS_HEADER_DATA_S *MsgMmsCreateHeader() { - MMS_HEADER_DATA_S *pMmsHeaderData = (MMS_HEADER_DATA_S * )calloc(1, sizeof(MMS_HEADER_DATA_S)); - pMmsHeaderData->bcc = NULL;// Bcc - pMmsHeaderData->cc = NULL;// Cc - pMmsHeaderData->contentLocation[0] = '\0'; - pMmsHeaderData->szContentType[0] = '\0'; - pMmsHeaderData->date = 0; - pMmsHeaderData->bDeliveryReport = false; // X-Mms-Delivery-Report - pMmsHeaderData->delivery.type = MMS_TIMETYPE_NONE; - pMmsHeaderData->delivery.time = 0; - pMmsHeaderData->expiry.type = MMS_TIMETYPE_NONE; - pMmsHeaderData->expiry.time = 0; - pMmsHeaderData->szFrom[0] = '\0';// From - pMmsHeaderData->messageClass = -1;//Personal | Advertisement | Informational | Auto - pMmsHeaderData->messageID[0]= '\0'; - pMmsHeaderData->messageType = -1;//MmsMsgType : ex) sendreq - pMmsHeaderData->mmsVersion = -1;//1.0 1.3 - pMmsHeaderData->messageSize = 0; // X-Mms-Message-Size - pMmsHeaderData->mmsPriority = -1;//_MSG_PRIORITY_TYPE_E : Low | Normal | High - pMmsHeaderData->bReadReport = 0;// X-Mms-Read-Report - // X-Mms-Report-Allowed - // X-Mms-Response-Status - // X-Mms-Response-Text - pMmsHeaderData->bHideAddress = false;// X-Mms-Sender-Visibility - pMmsHeaderData->mmsStatus = MSG_DELIVERY_REPORT_NONE;// X-Mms-Status - pMmsHeaderData->szSubject[0] = '\0';// Subject - pMmsHeaderData->to = NULL;// To - pMmsHeaderData->trID[0] = '\0'; - // 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 - pMmsHeaderData->contentClass = -1;//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 + MMS_HEADER_DATA_S *pMmsHeaderData = (MMS_HEADER_DATA_S * )calloc(1, sizeof(MMS_HEADER_DATA_S)); + if (pMmsHeaderData) { + pMmsHeaderData->bcc = NULL;// Bcc + pMmsHeaderData->cc = NULL;// Cc + pMmsHeaderData->contentLocation[0] = '\0'; + pMmsHeaderData->szContentType[0] = '\0'; + pMmsHeaderData->date = 0; + pMmsHeaderData->bDeliveryReport = false; // X-Mms-Delivery-Report + pMmsHeaderData->delivery.type = MMS_TIMETYPE_NONE; + pMmsHeaderData->delivery.time = 0; + pMmsHeaderData->expiry.type = MMS_TIMETYPE_NONE; + pMmsHeaderData->expiry.time = 0; + pMmsHeaderData->szFrom[0] = '\0';// From + pMmsHeaderData->messageClass = -1;//Personal | Advertisement | Informational | Auto + pMmsHeaderData->messageID[0]= '\0'; + pMmsHeaderData->messageType = -1;//MmsMsgType : ex) sendreq + pMmsHeaderData->mmsVersion = -1;//1.0 1.3 + pMmsHeaderData->messageSize = 0; // X-Mms-Message-Size + pMmsHeaderData->mmsPriority = -1;//_MSG_PRIORITY_TYPE_E : Low | Normal | High + pMmsHeaderData->bReadReport = 0;// X-Mms-Read-Report + // X-Mms-Report-Allowed + // X-Mms-Response-Status + // X-Mms-Response-Text + pMmsHeaderData->bHideAddress = false;// X-Mms-Sender-Visibility + pMmsHeaderData->mmsStatus = MSG_DELIVERY_REPORT_NONE;// X-Mms-Status + pMmsHeaderData->szSubject[0] = '\0';// Subject + pMmsHeaderData->to = NULL;// To + pMmsHeaderData->trID[0] = '\0'; + // 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 + pMmsHeaderData->contentClass = -1;//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 + } return pMmsHeaderData; } @@ -1102,7 +1123,9 @@ void MsgMmsReleaseHeader(MMS_HEADER_DATA_S **ppMmHeadersData) { if (ppMmHeadersData && *ppMmHeadersData) { MMS_HEADER_DATA_S *pMmsHeaderData = *ppMmHeadersData; - + MsgMmsReleaseAddressList(&pMmsHeaderData->to); + MsgMmsReleaseAddressList(&pMmsHeaderData->cc); + MsgMmsReleaseAddressList(&pMmsHeaderData->bcc); free(pMmsHeaderData); *ppMmHeadersData = NULL; @@ -1112,6 +1135,11 @@ void MsgMmsReleaseHeader(MMS_HEADER_DATA_S **ppMmHeadersData) MMS_DATA_S *MsgMmsCreate() { MMS_DATA_S * mms_data = (MMS_DATA_S * )calloc(1, sizeof(MMS_DATA_S)); + if (mms_data) { + mms_data->header = NULL; + mms_data->multipartlist = NULL; + mms_data->smil = NULL; + } return mms_data; } @@ -1270,14 +1298,16 @@ static bool MmsInsertPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_D if (isInsert == false) { MMS_ATTACH_S *attachment = NULL; attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1); - attachment->drmType = pMultipart->drmType; - attachment->mediatype = pMultipart->type; - 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 (attachment) { + attachment->drmType = pMultipart->drmType; + attachment->mediatype = pMultipart->type; + 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); @@ -1341,7 +1371,8 @@ int MsgMmsConvertMmsMessageDataToMmsData(MMS_MESSAGE_DATA_S *pSrc, MMS_DATA_S *p int pageCnt = _MsgMmsGetPageCount(pSrc); if (pSrc->smil.szFilePath[0] != '\0') { MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); - memcpy(pMultipart, &pSrc->smil, sizeof(MMS_MULTIPART_DATA_S)); + if (pMultipart) + memcpy(pMultipart, &pSrc->smil, sizeof(MMS_MULTIPART_DATA_S)); pDst->smil = pMultipart; } else if (pageCnt > 0) { // Multipart related MsgSmilGenerateSmilDoc(pSrc, &pRawData); @@ -1349,13 +1380,13 @@ int MsgMmsConvertMmsMessageDataToMmsData(MMS_MESSAGE_DATA_S *pSrc, MMS_DATA_S *p MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); MSG_DEBUG("%s", pRawData); - - pMultipart->pMultipartData = pRawData; - pMultipart->nMultipartDataLen = strlen(pRawData); - pMultipart->type = MIME_APPLICATION_SMIL; - snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", "application/smil"); - pDst->smil = pMultipart; - + if (pMultipart) { + pMultipart->pMultipartData = pRawData; + pMultipart->nMultipartDataLen = strlen(pRawData); + pMultipart->type = MIME_APPLICATION_SMIL; + snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", "application/smil"); + pDst->smil = pMultipart; + } } else { MSG_DEBUG("Fail to Generate SmilDoc"); } @@ -1363,21 +1394,23 @@ int MsgMmsConvertMmsMessageDataToMmsData(MMS_MESSAGE_DATA_S *pSrc, MMS_DATA_S *p for (int i = 0; i < pageCnt; ++i) { MMS_PAGE_S *pPage = _MsgMmsGetPage(pSrc, 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); - if (pMedia->szFilePath[0] != 0) { - MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); - - snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", pMedia->szContentID); - snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", pMedia->szContentLocation); - snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", pMedia->szFileName); - snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", pMedia->szFilePath); - snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", pMedia->szContentType); - - pDst->multipartlist = g_list_append(pDst->multipartlist, pMultipart); + if (pPage) { + 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); + if ((pMedia) && (pMedia->szFilePath[0] != 0)) { + MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); + if (pMultipart) { + snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", pMedia->szContentID); + snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", pMedia->szContentLocation); + snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", pMedia->szFileName); + snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", pMedia->szFilePath); + snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", pMedia->szContentType); + pDst->multipartlist = g_list_append(pDst->multipartlist, pMultipart); + } + } } } } @@ -1389,14 +1422,15 @@ int MsgMmsConvertMmsMessageDataToMmsData(MMS_MESSAGE_DATA_S *pSrc, MMS_DATA_S *p MMS_ATTACH_S *pMedia = _MsgMmsGetAttachment(pSrc, i); if (pMedia->szFilePath[0] != 0) { MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); + if (pMultipart) { + snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", pMedia->szFileName); + snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", pMedia->szFileName); + snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", pMedia->szFileName); + snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", pMedia->szFilePath); + snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", pMedia->szContentType); - snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", pMedia->szFileName); - snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", pMedia->szFileName); - snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", pMedia->szFileName); - snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", pMedia->szFilePath); - snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", pMedia->szContentType); - - pDst->multipartlist = g_list_append(pDst->multipartlist, pMultipart); + pDst->multipartlist = g_list_append(pDst->multipartlist, pMultipart); + } } } @@ -1507,7 +1541,7 @@ int MsgMmsSetMultipartListFilePath(const char *dirPath, MMS_DATA_S *pMmsData) if (pMmsData->smil) { snprintf(pMmsData->smil->szFileName, sizeof(pMmsData->smil->szFileName), "%s", "smil.smil"); - MsgMmsSetMultipartFilePath(dirPath, pMmsData->smil); + MsgMmsSetMultipartFilePath(working_dir, pMmsData->smil); } if (multipart_list) { @@ -1517,7 +1551,7 @@ int MsgMmsSetMultipartListFilePath(const char *dirPath, MMS_DATA_S *pMmsData) MMS_MULTIPART_DATA_S *pMultipart = (MMS_MULTIPART_DATA_S *)g_list_nth_data(multipart_list, i); if (pMultipart) { - MsgMmsSetMultipartFilePath(dirPath, pMultipart);//data -> svc file + MsgMmsSetMultipartFilePath(working_dir, pMultipart);//data -> svc file } } } @@ -1656,3 +1690,52 @@ bool _MsgMmsRemoveEmptyObject(MMS_MESSAGE_DATA_S *pMmsMsg) return true; } + +int MsgMmsCheckFilepathSmack(int fd, const char* ipc_filename) +{ + int err = MSG_SUCCESS; + + char *app_smack_label = NULL; + smack_new_label_from_socket(fd, &app_smack_label); + if (app_smack_label == NULL) { + return MSG_ERR_PERMISSION_DENIED; + } + + MSG_DEBUG("app_smack_label [%s]", app_smack_label); + + char ipc_filepath[MSG_FILEPATH_LEN_MAX+1] = {0,}; + snprintf(ipc_filepath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_IPC_DATA_PATH, ipc_filename); + + gchar *serialized_data = NULL; + gsize serialized_len = 0; + MSG_DEBUG("ipc_path [%s]", ipc_filepath); + + if (!g_file_get_contents(ipc_filepath, &serialized_data, &serialized_len, NULL)) { + return MSG_ERR_PERMISSION_DENIED; + } + + MMS_DATA_S *mms_data = NULL; + + MsgDeserializeMmsData(serialized_data, serialized_len, &mms_data); + + if (mms_data) { + if (mms_data->multipartlist) { + int len = g_list_length(mms_data->multipartlist); + for (int i = 0; i < len; i++) { + MMS_MULTIPART_DATA_S *multipart = (MMS_MULTIPART_DATA_S *)g_list_nth_data(mms_data->multipartlist, i); + if (multipart) { + err = MsgCheckFilepathSmack(app_smack_label, multipart->szFilePath); + if (err != MSG_SUCCESS) + break; + } + } + } + MsgMmsRelease(&mms_data); + } else { + err = MSG_ERR_INVALID_PARAMETER; + } + + MSG_FREE(serialized_data); + MSG_FREE(app_smack_label); + return err; +} diff --git a/utils/MsgSerialize.cpp b/utils/MsgSerialize.cpp index 9c1e9ae..ca84e03 100755 --- a/utils/MsgSerialize.cpp +++ b/utils/MsgSerialize.cpp @@ -20,6 +20,8 @@ #include "MsgDebug.h" #include "MsgMmsMessage.h" + +#ifdef MSG_MMS_USE_JSON_DATA #include <glib.h> #include <glib-object.h> #include <json-glib/json-glib.h> @@ -347,19 +349,20 @@ int MsgParseMultipartListData(msg_json_parser_object *parse_obj, MMS_DATA_S *pMs while(msg_json_parser_get_next_child(parse_obj, &child, index_child)) { - if (child.value != NULL && child.type) { + if (child.value != NULL && child.type != MSG_JSON_PARSER_NULL) { MSG_PRINT_PARSER_OBJECT(index_child, child); MMS_MULTIPART_DATA_S *pMultipart= MsgMmsCreateMultipart(); - if (MsgParseMultipartData(&child, pMultipart) == 0) { - pMsgData->multipartlist = g_list_append(pMsgData->multipartlist, pMultipart); - } else { - free(pMultipart); - pMultipart = NULL; + if (pMultipart) { + if (MsgParseMultipartData(&child, pMultipart) == 0) { + pMsgData->multipartlist = g_list_append(pMsgData->multipartlist, pMultipart); + } else { + free(pMultipart); + pMultipart = NULL; + } } - } else { MSG_DEBUG("Get child : idx = %d, key = %s, type = %d, value = %p", index_child, child.key, child.type, child.value); } @@ -395,20 +398,23 @@ int MsgParseMmsData(msg_json_parser_object *parse_obj, MMS_DATA_S *pMsgData) MsgParseMultipartListData(&child, pMsgData); break; case MMS_HEADER: - pMsgData->header = MsgMmsCreateHeader(); - MsgParseHeader(&child, pMsgData->header); + if (pMsgData->header == NULL) { + pMsgData->header = MsgMmsCreateHeader(); + } + if (pMsgData->header) + MsgParseHeader(&child, pMsgData->header); break; case MMS_SMIL_MULTIPART: { MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); - - if (MsgParseMultipartData(&child, pMultipart) == 0) { - pMsgData->smil = pMultipart; - } else { - free(pMultipart); - pMultipart = NULL; + if (pMultipart) { + if (MsgParseMultipartData(&child, pMultipart) == 0) { + pMsgData->smil = pMultipart; + } else { + free(pMultipart); + pMultipart = NULL; + } } - break; } case MMS_BACKUP_TYPE: @@ -548,6 +554,7 @@ int MsgDeserializeMmsJsonData(char* value, int value_len, MMS_DATA_S **ppMmsData return ret; } +#endif int MsgSerializeMms(const MMS_DATA_S *pMsgData, char **pValue) @@ -629,6 +636,8 @@ int MsgSerializeMms(const MMS_DATA_S *pMsgData, char **pValue) MSG_DEBUG("Serialize bufsize = %d", bufsize); buf = (char *)calloc(1, bufsize); + if (buf == NULL) + return -1; int serial_index = 0; int offset = 0; @@ -774,6 +783,9 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData) pMmsData = MsgMmsCreate(); *ppMmsData = pMmsData; + if (pMmsData == NULL) + return -1; + // 1. Backup type memcpy(&(pMmsData->backup_type), value, sizeof(int)); @@ -786,6 +798,9 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData) if (isExistHeader) { pMmsData->header = (MMS_HEADER_DATA_S *)calloc(1, sizeof(MMS_HEADER_DATA_S)); + if (pMmsData->header == NULL) + return -1; + memcpy(pMmsData->header, value + offset, sizeof(MMS_HEADER_DATA_S)); offset += sizeof(MMS_HEADER_DATA_S); @@ -796,6 +811,8 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData) for (i = 0; i < addr_cnt; i++) { MMS_ADDRESS_DATA_S* to_addr = (MMS_ADDRESS_DATA_S*)calloc(1, sizeof(MMS_ADDRESS_DATA_S)); + if (to_addr == NULL) + return -1; memcpy(&(to_addr->address_type), value + offset, sizeof(int)); MSG_DEBUG("[#%2d][%5d] address type = %d", deserial_index++, offset, to_addr->address_type); @@ -815,6 +832,8 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData) for (i = 0; i < addr_cnt; i++) { MMS_ADDRESS_DATA_S* cc_addr = (MMS_ADDRESS_DATA_S*)calloc(1, sizeof(MMS_ADDRESS_DATA_S)); + if (cc_addr == NULL) + return -1; memcpy(&(cc_addr->address_type), value + offset, sizeof(int)); MSG_DEBUG("[#%2d][%5d] address type = %d", deserial_index++, offset, cc_addr->address_type); @@ -834,6 +853,8 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData) for (i = 0; i < addr_cnt; i++) { MMS_ADDRESS_DATA_S* bcc_addr = (MMS_ADDRESS_DATA_S*)calloc(1, sizeof(MMS_ADDRESS_DATA_S)); + if (bcc_addr == NULL) + return -1; memcpy(&(bcc_addr->address_type), value + offset, sizeof(int)); MSG_DEBUG("[#%2d][%5d] address type = %d", deserial_index++, offset, bcc_addr->address_type); @@ -853,6 +874,9 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData) if (isExistSmil) { pMmsData->smil = (MMS_MULTIPART_DATA_S *)calloc(1, sizeof(MMS_MULTIPART_DATA_S)); + if (pMmsData->smil == NULL) + return -1; + memcpy(pMmsData->smil, value + offset, sizeof(MMS_MULTIPART_DATA_S)); offset += sizeof(MMS_MULTIPART_DATA_S); @@ -861,6 +885,9 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData) if (pMmsData->smil->nMultipartDataLen > 0) { pMmsData->smil->pMultipartData = (char *)calloc(1, sizeof(char)*pMmsData->smil->nMultipartDataLen); + if (pMmsData->smil->pMultipartData == NULL) + return -1; + memcpy(pMmsData->smil->pMultipartData, value + offset, sizeof(char)*pMmsData->smil->nMultipartDataLen); MSG_DEBUG("[#%2d][%5d] smil data ptr = %p", deserial_index++, offset, pMmsData->smil->pMultipartData); offset += sizeof(char)*pMmsData->smil->nMultipartDataLen; @@ -883,6 +910,9 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData) for (i = 0; i < multipart_cnt; i++) { MMS_MULTIPART_DATA_S *multipart_data = (MMS_MULTIPART_DATA_S *)calloc(1, sizeof(MMS_MULTIPART_DATA_S)); + if (multipart_data == NULL) + return -1; + memcpy(multipart_data, value + offset, sizeof(MMS_MULTIPART_DATA_S)); offset += sizeof(MMS_MULTIPART_DATA_S); @@ -890,13 +920,17 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData) if (multipart_data->nMultipartDataLen > 0) { multipart_data->pMultipartData = (char *)calloc(1, sizeof(char)*multipart_data->nMultipartDataLen); + if (multipart_data->pMultipartData == NULL) { + free(multipart_data); + return -1; + } + memcpy(multipart_data->pMultipartData, value + offset, sizeof(char)*multipart_data->nMultipartDataLen); MSG_DEBUG("[#%2d][%5d] multipart_data ptr = %p", deserial_index++, offset, multipart_data->pMultipartData); offset += sizeof(char)*multipart_data->nMultipartDataLen; } else { multipart_data->pMultipartData = NULL; } - pMmsData->multipartlist = g_list_append(pMmsData->multipartlist, (void *)multipart_data); } } diff --git a/utils/MsgSmil.cpp b/utils/MsgSmil.cpp index bc8df8d..914bdee 100755 --- a/utils/MsgSmil.cpp +++ b/utils/MsgSmil.cpp @@ -866,7 +866,8 @@ bool MsgSmilAddRegion(HMsgSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion) // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%) // Validation should be done before this. if (pstSmilRegion->width.value >= 0 && - pstSmilRegion->width.value <= nRootWidth) { + pstSmilRegion->width.value <= nRootWidth && + nRootWidth != 0) { int iWidth = (pstSmilRegion->width.value * 100) / nRootWidth; snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iWidth); @@ -885,7 +886,8 @@ bool MsgSmilAddRegion(HMsgSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion) // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%) // Validation should be done before this. if (pstSmilRegion->height.value >= 0 && - pstSmilRegion->height.value <= nRootHeight) { + pstSmilRegion->height.value <= nRootHeight && + nRootHeight != 0) { int iHeight = (pstSmilRegion->height.value * 100) / nRootHeight; snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iHeight); @@ -905,7 +907,7 @@ bool MsgSmilAddRegion(HMsgSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion) } else { // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%) // Validation should be done before this. - if (pstSmilRegion->nLeft.value >= 0) { + if (pstSmilRegion->nLeft.value >= 0 && nRootWidth != 0) { int iLeft = (pstSmilRegion->nLeft.value * 100) / nRootWidth; snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iLeft); @@ -915,7 +917,8 @@ bool MsgSmilAddRegion(HMsgSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion) } if (true == pstSmilRegion->nTop.bUnitPercent) { - if (pstSmilRegion->nTop.value > 0) { + if (pstSmilRegion->nTop.value > 0 && + nRootHeight != 0) { snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nTop.value); xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf); MSG_DEBUG("[Set Attribute] : Top : [%s]", szBuf); @@ -923,7 +926,7 @@ bool MsgSmilAddRegion(HMsgSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion) } else { // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%) // Validation should be done before this. - if (pstSmilRegion->nTop.value >= 0) { + if (pstSmilRegion->nTop.value >= 0 && nRootHeight != 0) { int iTop = (pstSmilRegion->nTop.value * 100) / nRootHeight; snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iTop); diff --git a/utils/MsgSqliteWrapper.cpp b/utils/MsgSqliteWrapper.cpp index 4fabd97..374f842 100755 --- a/utils/MsgSqliteWrapper.cpp +++ b/utils/MsgSqliteWrapper.cpp @@ -119,7 +119,7 @@ bool MsgDbHandler::checkTableExist(const char *pTableName) memset(strQuery, 0x00, sizeof(strQuery)); snprintf(strQuery, sizeof(strQuery), "select count(name) from sqlite_master where name='%s'", pTableName); - if (getTable(strQuery, &nRowCnt) != MSG_SUCCESS) { + if (getTable(strQuery, &nRowCnt, NULL) != MSG_SUCCESS) { freeTable(); return false; } @@ -165,18 +165,20 @@ msg_error_t MsgDbHandler::execQuery(const char *pQuery) } -msg_error_t MsgDbHandler::getTable(const char *pQuery, int *pRowCnt) +msg_error_t MsgDbHandler::getTable(const char *pQuery, int *pRowCnt, int *pColumnCnt) { int ret = 0; *pRowCnt = 0; + if (pColumnCnt) + *pColumnCnt = 0; if(connect() != MSG_SUCCESS) return MSG_ERR_DB_DISCONNECT; freeTable(); MSG_DEBUG("[%s]", pQuery); - ret = sqlite3_get_table(handle, pQuery, &result, pRowCnt, 0, NULL); + ret = sqlite3_get_table(handle, pQuery, &result, pRowCnt, pColumnCnt, NULL); if (ret == SQLITE_OK) { if (*pRowCnt == 0) {// when the no record return 'MSG_ERR_DB_NORECORD' @@ -502,7 +504,7 @@ msg_error_t MsgDbHandler::getRowId(const char *pTableName, unsigned int *pRowId) memset(strQuery, 0x00, sizeof(strQuery)); snprintf(strQuery, sizeof(strQuery), "select max(rowid) from %s", pTableName); - ret = getTable(strQuery, &nRowCnt); + ret = getTable(strQuery, &nRowCnt, NULL); if (ret == SQLITE_OK) { nRowId = getColumnToInt(1); diff --git a/utils/MsgTextConvert.cpp b/utils/MsgTextConvert.cpp index 51abecb..53e9769 100755 --- a/utils/MsgTextConvert.cpp +++ b/utils/MsgTextConvert.cpp @@ -18,8 +18,9 @@ #include "MsgDebug.h" #include "MsgTextConvert.h" +#include "MsgCppTypes.h" - +using namespace std; /*================================================================================================== IMPLEMENTATION OF MsgConvertText - Member Functions ==================================================================================================*/ @@ -436,7 +437,7 @@ int MsgTextConvert::convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int ma int gsm7bitLength = 0; int ucs2Length = 0; - if (srcTextLen <= 0) { + if (srcTextLen <= 0 && pSrcText) { utf8Length = strlen((char*)pSrcText); srcTextLen = utf8Length; } else { @@ -444,7 +445,10 @@ int MsgTextConvert::convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int ma } int maxUCS2Length = utf8Length; // max # of UCS2 chars, NOT bytes. when all utf8 chars are only one byte, UCS2Length is maxUCS2 Length. otherwise (ex: 2 bytes of UTF8 is one char) UCS2Length must be less than utf8Length - WCHAR pUCS2Text[maxUCS2Length]; + + WCHAR *pUCS2Text = NULL; + unique_ptr<WCHAR*, void(*)(WCHAR**)> buf(&pUCS2Text, unique_ptr_deleter); + pUCS2Text = (WCHAR *)new char[maxUCS2Length * sizeof(WCHAR)]; memset(pUCS2Text, 0x00, maxUCS2Length * sizeof(WCHAR)); MSG_DEBUG("srcTextLen = %d", srcTextLen); diff --git a/utils/MsgUtilFile.cpp b/utils/MsgUtilFile.cpp index 57955fd..84714de 100755 --- a/utils/MsgUtilFile.cpp +++ b/utils/MsgUtilFile.cpp @@ -20,6 +20,7 @@ #include <stdlib.h> #include <errno.h> #include <sys/stat.h> +#include <sys/smack.h> #include <string.h> #include <dirent.h> #include <unistd.h> //sync() @@ -201,7 +202,7 @@ bool MsgCreateFileName(char *pFileName) try { if (clock_gettime(CLOCK_REALTIME, &ts) < 0) { - MSG_DEBUG("clock_gettime() error: %s", strerror(errno)); + MSG_DEBUG("clock_gettime() error: %s", g_strerror(errno)); return false; } @@ -237,17 +238,16 @@ bool MsgOpenAndReadFile(const char *pFileName, char **ppData, int *pDataSize) snprintf(fullPath, MAX_FULL_PATH_SIZE, "%s%s", MSG_IPC_DATA_PATH, pFileName); MSG_SEC_DEBUG("open file name: %s", fullPath); - pFile = MsgOpenFile(fullPath, "rb"); if (pFile == NULL) { - MSG_DEBUG("File Open Error: %s", strerror(errno)); + MSG_DEBUG("File Open Error: %s", g_strerror(errno)); return false; } if (MsgFseek(pFile, 0L, SEEK_END) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File Read Error: %s", strerror(errno)); + MSG_DEBUG("File Read Error: %s", g_strerror(errno)); return false; } @@ -265,13 +265,13 @@ bool MsgOpenAndReadFile(const char *pFileName, char **ppData, int *pDataSize) if (MsgFseek(pFile, 0L, SEEK_SET) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File seek Error: %s", strerror(errno)); + MSG_DEBUG("File seek Error: %s", g_strerror(errno)); return false; } if (MsgReadFile(*ppData, sizeof(char), FileSize, pFile) != (size_t)FileSize) { MsgCloseFile(pFile); - MSG_DEBUG("File Read Error: %s", strerror(errno)); + MSG_DEBUG("File Read Error: %s", g_strerror(errno)); return false; } @@ -288,7 +288,7 @@ bool MsgReadFileForDecode(FILE *pFile, char *pBuf, int length, int *nSize) MSG_BEGIN(); if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) { - MSG_DEBUG("File Seek Error: %s", strerror(errno)); + MSG_DEBUG("File Seek Error: %s", g_strerror(errno)); MsgCloseFile(pFile); return false; } @@ -314,33 +314,25 @@ bool MsgWriteIpcFile(const char *pFileName, const char *pData, int DataSize) FILE *pFile = MsgOpenFile(fullPath, "wb+"); if (pFile == NULL) { - MSG_DEBUG("File Open Error: %s", strerror(errno)); + MSG_DEBUG("File Open Error: %s", g_strerror(errno)); return false; } if (MsgFseek(pFile, 0L, SEEK_SET) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File Seek Error: %s", strerror(errno)); + MSG_DEBUG("File Seek Error: %s", g_strerror(errno)); return false; } if (MsgWriteFile(pData, sizeof(char), DataSize, pFile) != (size_t)DataSize) { MsgCloseFile(pFile); - MSG_DEBUG("File Write Error: %s", strerror(errno)); + MSG_DEBUG("File Write Error: %s", g_strerror(errno)); return false; } MsgFflush(pFile); MsgCloseFile(pFile); - if (MsgChmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP ) == false) { - MSG_DEBUG("File chmod Error: %s", strerror(errno)); - } - - if (MsgChown(fullPath, 0, 6502 ) == false) { - MSG_DEBUG("File chown Error: %s", strerror(errno)); - } - return true; } @@ -361,13 +353,13 @@ int MsgReadSmilFile(const char *pFileName, char **ppData) FILE *pFile = MsgOpenFile(fullPath, "rb"); if (pFile == NULL) { - MSG_DEBUG("File Open Error: %s", strerror(errno)); + MSG_DEBUG("File Open Error: %s", g_strerror(errno)); return -1; } if (MsgFseek(pFile, 0L, SEEK_END) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File Seek Error: %s", strerror(errno)); + MSG_DEBUG("File Seek Error: %s", g_strerror(errno)); return -1; } @@ -384,13 +376,13 @@ int MsgReadSmilFile(const char *pFileName, char **ppData) if (MsgFseek(pFile, 0L, SEEK_SET) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File Sead Error: %s", strerror(errno)); + MSG_DEBUG("File Sead Error: %s", g_strerror(errno)); return -1; } if (MsgReadFile(*ppData, sizeof(char), FileSize, pFile) != (size_t)FileSize) { MsgCloseFile(pFile); - MSG_DEBUG("File Read Error: %s", strerror(errno)); + MSG_DEBUG("File Read Error: %s", g_strerror(errno)); return -1; } @@ -410,6 +402,7 @@ bool MsgWriteSmilFile(const char *pFilePath,char *pData, int DataSize) return false; } +#if 0 if (mkdir(MSG_SMIL_FILE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) { if (errno == EEXIST) { MSG_SEC_DEBUG("The %s already exists", MSG_SMIL_FILE_PATH); @@ -417,23 +410,24 @@ bool MsgWriteSmilFile(const char *pFilePath,char *pData, int DataSize) MSG_SEC_DEBUG("Error while mkdir %s", MSG_SMIL_FILE_PATH); } } +#endif FILE *pFile = MsgOpenFile(pFilePath, "wb+"); if (pFile == NULL) { - MSG_DEBUG("File Open Error: %s", strerror(errno)); + MSG_DEBUG("File Open Error: %s", g_strerror(errno)); return false; } if (MsgFseek(pFile, 0L, SEEK_SET) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File Seek Error: %s", strerror(errno)); + MSG_DEBUG("File Seek Error: %s", g_strerror(errno)); return false; } if (MsgWriteFile(pData, sizeof(char), DataSize, pFile) != (size_t)DataSize) { MsgCloseFile(pFile); - MSG_DEBUG("File Write Error: %s", strerror(errno)); + MSG_DEBUG("File Write Error: %s", g_strerror(errno)); return false; } @@ -464,7 +458,7 @@ void MsgDeleteFile(const char *pFileName) MSG_DEBUG("%s", fullPath); if (remove(fullPath) != 0) - MSG_FATAL("File Delete Error [%s]: %s", fullPath, strerror(errno)); + MSG_FATAL("File Delete Error [%s]: %s", fullPath, g_strerror(errno)); } catch (exception &e) { MSG_FATAL ("%s", e.what()); } @@ -485,7 +479,7 @@ void MsgDeleteSmilFile(const char *pFileName) snprintf(fullPath, MAX_FULL_PATH_SIZE, "%s%s", MSG_SMIL_FILE_PATH, pFileName); if (remove(fullPath) != 0) - MSG_FATAL("File Delete Error [%s]: %s", fullPath, strerror(errno)); + MSG_FATAL("File Delete Error [%s]: %s", fullPath, g_strerror(errno)); } catch (exception &e) { MSG_FATAL("%s", e.what()); } @@ -504,13 +498,13 @@ bool MsgGetFileSize(const char *pFilePath, int *nSize) pFile = MsgOpenFile(pFilePath, "rb"); if (!pFile) { - MSG_DEBUG("File Open error: %s", strerror(errno)); + MSG_DEBUG("File Open error: %s", g_strerror(errno)); return false; } if (MsgFseek(pFile, 0L, SEEK_END) < 0) { MsgCloseFile(pFile); - MSG_FATAL("File Read Error: %s", strerror(errno)); + MSG_FATAL("File Read Error: %s", g_strerror(errno)); return false; } @@ -527,7 +521,7 @@ FILE *MsgOpenMMSFile(char *pFileName) int len; if (!pFileName) { - MSG_DEBUG("pFileName NULL: %s", strerror(errno)); + MSG_DEBUG("pFileName NULL: %s", g_strerror(errno)); return NULL; } @@ -550,13 +544,13 @@ FILE *MsgOpenMMSFile(char *pFileName) FILE *pFile = MsgOpenFile(fullPath, "wb+"); if (pFile == NULL) { - MSG_FATAL("File Open Error: %s", strerror(errno)); + MSG_FATAL("File Open Error: %s", g_strerror(errno)); return NULL; } if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File Read Error: %s", strerror(errno)); + MSG_DEBUG("File Read Error: %s", g_strerror(errno)); return NULL; } @@ -608,9 +602,6 @@ bool MsgWriteDataFromEncodeBuffer(FILE *pFile, char *pInBuffer, int *pPtr, int m bool MsgOpenCreateAndOverwriteFile(char *pFullPath, char *pBuff, int TotalLength) { FILE *pFile = NULL ; - mode_t file_mode; - - file_mode = (S_IRUSR | S_IWUSR); if ((pFile = MsgOpenFile(pFullPath, "wb+")) == NULL) { MSG_FATAL("MsgOpenFile errer"); @@ -626,9 +617,6 @@ bool MsgOpenCreateAndOverwriteFile(char *pFullPath, char *pBuff, int TotalLength MsgFflush(pFile); MsgCloseFile(pFile); - if (!MsgChmod(pFullPath, file_mode)) - MSG_FATAL("File chmod Error: %s", strerror(errno)); - return true; } @@ -649,7 +637,7 @@ char *MsgOpenAndReadMmsFile( const char *szFilePath, int offset, int size, int * pFile = MsgOpenFile( szFilePath, "rb" ); if (pFile == NULL) { - MSG_DEBUG("MsgOpenAndReadMmsFile: [ERROR] Can't open filepath", strerror(errno)); + MSG_DEBUG("MsgOpenAndReadMmsFile: [ERROR] Can't open filepath", g_strerror(errno)); goto __CATCH; } @@ -669,13 +657,13 @@ char *MsgOpenAndReadMmsFile( const char *szFilePath, int offset, int size, int * pData = (char *)malloc(readSize + 1); if ( NULL == pData ) { - MSG_DEBUG( "MsgOpenAndReadMmsFile: [ERROR] pData MemAlloc Fail", strerror(errno) ); + MSG_DEBUG( "MsgOpenAndReadMmsFile: [ERROR] pData MemAlloc Fail", g_strerror(errno) ); goto __CATCH; } memset( pData, 0, readSize + 1 ); if (MsgFseek( pFile, offset, SEEK_SET) < 0) { - MSG_DEBUG( "MsgOpenAndReadMmsFile: [ERROR] FmSeekFile failed", strerror(errno) ); + MSG_DEBUG( "MsgOpenAndReadMmsFile: [ERROR] FmSeekFile failed", g_strerror(errno) ); goto __CATCH; } @@ -709,13 +697,14 @@ __CATCH: // it is equivalent to "rm -rf pDirPath" int MsgRmRf(char *pDirPath) { - struct dirent *d; + struct dirent *d = NULL; + struct dirent entry; DIR *dir; dir = opendir(pDirPath); if (dir == NULL) { - MSG_FATAL("error opendir: %s", strerror(errno)); + MSG_FATAL("error opendir: %s", g_strerror(errno)); return -1; } @@ -731,7 +720,7 @@ int MsgRmRf(char *pDirPath) bzero(path, size); - while ((d = readdir(dir)) != NULL) { + for (readdir_r(dir, &entry, &d); d != NULL; readdir_r(dir, &entry, &d)) { if (d->d_type == DT_DIR) { snprintf(path, size, "%s/%s", pDirPath, d->d_name); @@ -747,7 +736,7 @@ int MsgRmRf(char *pDirPath) closedir(dir); - MSG_FATAL("error rmdir: %s", strerror(errno)); + MSG_FATAL("error rmdir: %s", g_strerror(errno)); return -1; } @@ -764,11 +753,12 @@ int MsgRmRf(char *pDirPath) closedir(dir); - MSG_FATAL("error remove: %s", strerror(errno)); + MSG_FATAL("error remove: %s", g_strerror(errno)); return -1; } } + d = NULL; } closedir(dir); @@ -785,7 +775,7 @@ int MsgGetFileSize(const char *pFileName) struct stat file_stat; if (lstat(pFileName, &file_stat)) { - MSG_FATAL("error lstat: %s", strerror(errno)); + MSG_FATAL("error lstat: %s", g_strerror(errno)); return -1; } @@ -796,23 +786,29 @@ int MsgGetFileSize(const char *pFileName) // it is equivalent to "du dir_path" unsigned int MsgDu(const char *pDirPath) { - struct dirent *d; + struct dirent *d = NULL; + struct dirent entry; DIR *dir; dir = opendir(pDirPath); if (dir == NULL) { - MSG_FATAL("error opendir: %s", strerror(errno)); + MSG_FATAL("error opendir: %s", g_strerror(errno)); return -1; } int size = strlen(pDirPath) + 256; char *path = (char*)malloc(size); + if (path == NULL) { + closedir(dir); + return -1; + } + bzero(path, size); unsigned int totalFileSize = 0; - while ((d = readdir(dir)) != NULL) { + for (readdir_r(dir, &entry, &d); d != NULL; readdir_r(dir, &entry, &d)) { if( d->d_type == DT_DIR) { snprintf(path, size, "%s/%s", pDirPath, d->d_name); @@ -842,6 +838,7 @@ unsigned int MsgDu(const char *pDirPath) totalFileSize += fileSize; } + d = NULL; } closedir(dir); @@ -866,19 +863,19 @@ bool MsgAppendFile(const char *pFilePath, const char *pData, int DataSize) FILE *pFile = MsgOpenFile(fullPath, "a+"); if (pFile == NULL) { - MSG_FATAL("File Open Error: %s", strerror(errno)); + MSG_FATAL("File Open Error: %s", g_strerror(errno)); return false; } if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) { MsgCloseFile(pFile); - MSG_FATAL("File Sead Error: %s", strerror(errno)); + MSG_FATAL("File Sead Error: %s", g_strerror(errno)); return false; } if (MsgWriteFile(pData, sizeof(char), DataSize, pFile) != (size_t)DataSize) { MsgCloseFile(pFile); - MSG_FATAL("File Write Error: %s", strerror(errno)); + MSG_FATAL("File Write Error: %s", g_strerror(errno)); return false; } @@ -891,17 +888,18 @@ bool MsgAppendFile(const char *pFilePath, const char *pData, int DataSize) void MsgMmsInitDir() { struct dirent *d = NULL; + struct dirent entry; DIR* dir = NULL; dir = opendir(MSG_DATA_PATH); if (dir == NULL) { - MSG_FATAL("error opendir: %s", strerror(errno)); + MSG_FATAL("error opendir: %s", g_strerror(errno)); return; } // Remove temporal Mms folder (/opt/usr/data/msg-service/msgdata/*.dir) - while ((d = readdir(dir)) != NULL) { + for (readdir_r(dir, &entry, &d); d != NULL; readdir_r(dir, &entry, &d)) { if (d->d_type == DT_DIR) { if ((strcmp(".", d->d_name) == 0) || (strcmp("..", d->d_name) == 0)) continue; @@ -914,6 +912,7 @@ void MsgMmsInitDir() rmdir(filePath); } } + d = NULL; } closedir(dir); @@ -944,6 +943,7 @@ bool MsgAccessFile(const char *filepath, int mode) bool MsgChmod(const char *filepath, int mode) { +#if 0 struct stat lstat_info; struct stat fstat_info; int fd; @@ -977,6 +977,7 @@ bool MsgChmod(const char *filepath, int mode) } close(fd); +#endif return true; } @@ -988,19 +989,19 @@ bool MsgChown(const char *filepath, int uid, int gid) int fd; if (lstat(filepath, &lstat_info) == -1) { - MSG_SEC_DEBUG("No such file as [%s].", filepath); + MSG_SEC_INFO("No such file as [%s].", filepath); return false; } fd = open(filepath, O_RDONLY); if (fd == -1) { - MSG_SEC_DEBUG("Fail to open [%s].", filepath); + MSG_SEC_INFO("Fail to open [%s].", filepath); return false; } if (fstat(fd, &fstat_info) == -1) { - MSG_SEC_DEBUG("Fail to fstat [%s].", filepath); + MSG_SEC_INFO("Fail to fstat [%s].", filepath); close(fd); return false; } @@ -1009,13 +1010,14 @@ bool MsgChown(const char *filepath, int uid, int gid) lstat_info.st_ino == fstat_info.st_ino && lstat_info.st_dev == fstat_info.st_dev) { if (fchown(fd, uid, gid) < 0) { - MSG_SEC_DEBUG("Fail to fchown [%s].", filepath); + MSG_SEC_INFO("Fail to fchown [%s].", filepath); close(fd); return false; } } close(fd); + return true; } @@ -1029,19 +1031,19 @@ bool MsgCreateFile(const char *pFilePath,char *pData, int DataSize) FILE *pFile = MsgOpenFile(pFilePath, "wb+"); if (pFile == NULL) { - MSG_DEBUG("File Open Error: %s", strerror(errno)); + MSG_DEBUG("File Open Error: %s", g_strerror(errno)); return false; } if (MsgFseek(pFile, 0L, SEEK_SET) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File Seek Error: %s", strerror(errno)); + MSG_DEBUG("File Seek Error: %s", g_strerror(errno)); return false; } if (MsgWriteFile(pData, sizeof(char), DataSize, pFile) != (size_t)DataSize) { MsgCloseFile(pFile); - MSG_DEBUG("File Write Error: %s", strerror(errno)); + MSG_DEBUG("File Write Error: %s", g_strerror(errno)); return false; } @@ -1054,27 +1056,72 @@ bool MsgCreateFile(const char *pFilePath,char *pData, int DataSize) char *MsgGetDirName(char *file_path) { - char *tmp_path = NULL; - tmp_path = g_strdup(file_path); - - char *ret_name = g_strdup(dirname(tmp_path)); + return g_path_get_dirname(file_path); +} - g_free(tmp_path); - tmp_path = NULL; - return ret_name; +char *MsgGetFileName(char *file_path) +{ + return g_path_get_basename(file_path); } -char *MsgGetFileName(char *file_path) +int MsgCheckFilepathSmack(const char *app_smack_label, char *file_path) { - char *tmp_path = NULL; - tmp_path = g_strdup(file_path); + int err = MSG_SUCCESS; + + char *path_smack_label = NULL; + char *dir_smack_label = NULL; + char *dir_name = NULL; + + struct stat st; + if (stat(file_path, &st) != 0) { + MSG_DEBUG("stat(%s, &st) != 0", file_path); + return MSG_ERR_PERMISSION_DENIED; + } + if (S_ISDIR(st.st_mode)) { + MSG_DEBUG("S_ISDIR(st.st_mode)"); + return MSG_ERR_INVALID_PARAMETER; + } - char *ret_name = g_strdup(basename(tmp_path)); + dir_name = MsgGetDirName(file_path); + if (!dir_name || !g_strcmp0(dir_name, file_path)) { + MSG_DEBUG("!dir_name || !g_strcmp0(dir_name, %s)", file_path); + err = MSG_ERR_INVALID_PARAMETER; + goto __RETURN; + } + + smack_getlabel(dir_name, &dir_smack_label, SMACK_LABEL_ACCESS); + if (dir_smack_label == NULL) { + MSG_DEBUG("smack_getlabel failed (dir_smack_label)"); + err = MSG_ERR_PERMISSION_DENIED; + goto __RETURN; + } + + if (smack_have_access(app_smack_label, dir_smack_label, "RX") < 1) { + MSG_DEBUG("smack_have_access failed (dir_smack_label)"); + err = MSG_ERR_PERMISSION_DENIED; + goto __RETURN; + } + + smack_getlabel(file_path, &path_smack_label, SMACK_LABEL_ACCESS); + if (path_smack_label == NULL) { + MSG_DEBUG("smack_getlabel failed (path_smack_label)"); + err = MSG_ERR_PERMISSION_DENIED; + goto __RETURN; + } + + if (smack_have_access(app_smack_label, path_smack_label, "R") < 1) { + MSG_DEBUG("smack_have_access failed (path_smack_label)"); + err = MSG_ERR_PERMISSION_DENIED; + goto __RETURN; + } - g_free(tmp_path); - tmp_path = NULL; + MSG_DEBUG("smack_have_access pass successfully"); - return ret_name; +__RETURN: + MSG_FREE(path_smack_label); + MSG_FREE(dir_smack_label); + MSG_FREE(dir_name); + return err; } diff --git a/utils/MsgUtilFunction.cpp b/utils/MsgUtilFunction.cpp index 1b0758a..1205e8b 100755 --- a/utils/MsgUtilFunction.cpp +++ b/utils/MsgUtilFunction.cpp @@ -21,7 +21,7 @@ #include <system_info.h> bool b_feature_check_flag = false; -bool b_feature_telephony = false; +bool b_feature_telephony_sms = false; bool b_feature_telephony_mms = false; /*================================================================================================== @@ -33,16 +33,19 @@ bool MsgCheckFeatureSupport(const char *feature_name) bool result = false; if (b_feature_check_flag == false) { - system_info_get_platform_bool(MSG_TELEPHONY_FEATURE, &b_feature_telephony); - system_info_get_platform_bool(MSG_TELEPHONY_MMS_FEATURE, &b_feature_telephony_mms); - MSG_INFO("[%s] feature is [%d]", MSG_TELEPHONY_FEATURE, b_feature_telephony); + if (system_info_get_platform_bool(MSG_TELEPHONY_SMS_FEATURE, &b_feature_telephony_sms) != SYSTEM_INFO_ERROR_NONE) + MSG_INFO("fail to system_info_get_platform_bool [%s]", MSG_TELEPHONY_SMS_FEATURE); + if (system_info_get_platform_bool(MSG_TELEPHONY_MMS_FEATURE, &b_feature_telephony_mms) != SYSTEM_INFO_ERROR_NONE) + MSG_INFO("fail to system_info_get_platform_bool [%s]", MSG_TELEPHONY_MMS_FEATURE); + + MSG_INFO("[%s] feature is [%d]", MSG_TELEPHONY_SMS_FEATURE, b_feature_telephony_sms); MSG_INFO("[%s] feature is [%d]", MSG_TELEPHONY_MMS_FEATURE, b_feature_telephony_mms); b_feature_check_flag = true; } - if (!g_strcmp0(feature_name, MSG_TELEPHONY_FEATURE)) { - result = b_feature_telephony; + if (!g_strcmp0(feature_name, MSG_TELEPHONY_SMS_FEATURE)) { + result = b_feature_telephony_sms; } else if (!g_strcmp0(feature_name, MSG_TELEPHONY_MMS_FEATURE)) { result = b_feature_telephony_mms; } else { @@ -245,22 +248,6 @@ int MsgEncodeFilterFlag(bool *pSetFlag, char **ppDest) } -int MsgEncodeMsgType(MSG_MESSAGE_TYPE_S *pMsgType, char **ppDest) -{ - int dataSize = 0; - - dataSize = (sizeof(MSG_MESSAGE_TYPE_S)); - - *ppDest = (char*)new char[dataSize]; - - void* p = (void*)*ppDest; - - memcpy(p, pMsgType, dataSize); - - return dataSize; -} - - int MsgEncodeThreadViewList(msg_struct_list_s *pThreadViewList, char **ppDest) { int count = 0, dataSize = 0; @@ -578,7 +565,11 @@ void MsgDecodeFolderList(char *pSrc, msg_struct_list_s *pFolderList) { pFolderList->nCount = count; pFolderList->msg_struct_info = (msg_struct_t *)calloc(count, sizeof(msg_struct_t)); - + if (pFolderList->msg_struct_info == NULL) + { + pFolderList->nCount = 0; + return; + } msg_struct_s *pInfoTmp = NULL; for (int i = 0; i < count; i++) @@ -611,6 +602,11 @@ void MsgDecodeFilterList(char *pSrc, msg_struct_list_s *pFilterList) pFilterList->nCount = count; pFilterList->msg_struct_info = (msg_struct_t *)calloc(count, sizeof(MSG_FILTER_S *)); + if (pFilterList->msg_struct_info == NULL) { + pFilterList->nCount = 0; + return; + } + msg_struct_s *pStructTmp = NULL; for (int i = 0; i < count; i++) @@ -1016,7 +1012,7 @@ msg_error_t MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort) //contacts-service is not used for gear #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED int nameOrder = MsgGetContactNameOrder(); -#else +#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED int nameOrder = 0; #endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED diff --git a/utils/MsgUtilStorage.cpp b/utils/MsgUtilStorage.cpp index b4d90f9..fc19a42 100755 --- a/utils/MsgUtilStorage.cpp +++ b/utils/MsgUtilStorage.cpp @@ -58,7 +58,7 @@ unsigned int MsgStoAddMessageTable(MsgDbHandler *pDbHandle, const MSG_MESSAGE_IN int fileSize = 0; char* pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); // Get File Data if (pMsgInfo->bTextSms == false) { @@ -442,8 +442,7 @@ msg_error_t MsgStoAddAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S * msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t msgId, int contactNameOrder, int *nAddressCnt, MSG_ADDRESS_INFO_S **pAddress) { char sqlQuery[MAX_QUERY_LEN+1]; - int index = 3; - int rowCnt = 0; + int rowCnt = 0, index = 0; *nAddressCnt = 0; @@ -458,7 +457,7 @@ msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t ms MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId); - msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt); + msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt, &index); if (err == MSG_ERR_DB_NORECORD) { pDbHandle->freeTable(); @@ -493,8 +492,7 @@ msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t ms { char sqlQuery[MAX_QUERY_LEN+1]; - int index = 3; - int rowCnt = 0; + int rowCnt = 0, index = 0; pAddress->nCount = 0; pAddress->msg_struct_info = NULL; @@ -503,6 +501,8 @@ msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t ms MSG_ADDRESS_INFO_S *pAddr = NULL; pAddress->msg_struct_info = (msg_struct_t *)calloc(MAX_TO_ADDRESS_CNT, sizeof(msg_struct_t)); + if (pAddress->msg_struct_info == NULL) + return MSG_ERR_MEMORY_ERROR; for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) { pAddress->msg_struct_info[i] = (msg_struct_t)new msg_struct_s; @@ -523,7 +523,7 @@ msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t ms MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId); - msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt); + msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt, &index); if (err == MSG_ERR_DB_NORECORD) { pDbHandle->freeTable(); @@ -558,8 +558,8 @@ msg_error_t MsgStoGetAddressByMsgId(MsgDbHandler *pDbHandle, msg_message_id_t ms msg_error_t MsgStoGetAddressByConvId(MsgDbHandler *pDbHandle, msg_thread_id_t convId, int contactNameOrder, msg_struct_list_s *pAddrlist) { char sqlQuery[MAX_QUERY_LEN+1]; - int index = 3; - int rowCnt = 0; + + int rowCnt = 0, index = 0; pAddrlist->nCount = 0; pAddrlist->msg_struct_info = NULL; @@ -572,7 +572,7 @@ msg_error_t MsgStoGetAddressByConvId(MsgDbHandler *pDbHandle, msg_thread_id_t co "FROM %s WHERE CONV_ID = %d;", MSGFW_ADDRESS_TABLE_NAME, convId); - msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt); + msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt, &index); if (err == MSG_ERR_DB_NORECORD) { pDbHandle->freeTable(); @@ -867,7 +867,7 @@ bool MsgExistAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg, ms int rowCnt = 0; int convId = 0; - err = pDbHandle->getTable(sqlQuery, &rowCnt); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); /* No record or other error */ if (err != MSG_SUCCESS) { @@ -935,234 +935,6 @@ int MsgStoGetUnreadCnt(MsgDbHandler *pDbHandle, MSG_MAIN_TYPE_T msgType) } -msg_error_t MsgStoAddContactInfo(MsgDbHandler *pDbHandle, MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber) -{ - - if (pDbHandle == NULL || pContactInfo == NULL || pNumber == NULL) { - MSG_DEBUG("pDbHandle == NULL || pContactInfo == NULL || pNumber == NULL"); - return MSG_ERR_NULL_POINTER; - } - - char sqlQuery[MAX_QUERY_LEN+1]; - char displayName[MAX_DISPLAY_NAME_LEN+1]; - memset(displayName, 0x00, sizeof(displayName)); - - if (strlen(pNumber) > (unsigned int)MsgContactGetMinMatchDigit()) { - int addrSize = strlen(pNumber); - char newPhoneNum[addrSize+1]; - memset(newPhoneNum, 0x00, sizeof(newPhoneNum)); - MsgConvertNumber(pNumber, newPhoneNum, addrSize); - - MSG_SEC_DEBUG("Phone Number to Compare : [%s]", newPhoneNum); - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET " - "CONTACT_ID = %d, " - "ADDR_BOOK_ID = %d, " - "FIRST_NAME = ?, " - "LAST_NAME = ?, " - "MIDDLE_NAME = ?, " - "PREFIX = ?, " - "SUFFIX = ?, " - "IMAGE_PATH = '%s' " - "WHERE ADDRESS_VAL LIKE '%%%%%s';", - MSGFW_ADDRESS_TABLE_NAME, pContactInfo->contactId, pContactInfo->addrbookId, pContactInfo->imagePath, newPhoneNum); - } else { - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET " - "CONTACT_ID = %d, " - "ADDR_BOOK_ID = %d, " - "FIRST_NAME = ?, " - "LAST_NAME = ?, " - "MIDDLE_NAME = ?, " - "PREFIX = ?, " - "SUFFIX = ?, " - "IMAGE_PATH = '%s' " - "WHERE ADDRESS_VAL = '%s';", - MSGFW_ADDRESS_TABLE_NAME, pContactInfo->contactId, pContactInfo->addrbookId, pContactInfo->imagePath, pNumber); - } - - if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - return MSG_ERR_DB_PREPARE; - } - - pDbHandle->bindText(pContactInfo->firstName, 1); - pDbHandle->bindText(pContactInfo->lastName, 2); - pDbHandle->bindText(pContactInfo->middleName, 3); - pDbHandle->bindText(pContactInfo->prefix, 4); - pDbHandle->bindText(pContactInfo->suffix, 5); - - if (pDbHandle->stepQuery() != MSG_ERR_DB_DONE) { - pDbHandle->finalizeQuery(); - MSG_DEBUG("Update contact Info. Fail [%s]", sqlQuery); - return MSG_ERR_DB_STEP; - } - - pDbHandle->finalizeQuery(); - - return MSG_SUCCESS; -} - - -msg_error_t MsgStoClearContactInfoByAddrbookIdList(MsgDbHandler *pDbHandle, int* addrbookList, int addrbookCnt) -{ - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; - int rowCnt = 0; - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT(CONTACT_ID) FROM %s WHERE ADDR_BOOK_ID NOT IN ( ", MSGFW_ADDRESS_TABLE_NAME); - - for (int i=0; i<(addrbookCnt-1); i++) { - snprintf(sqlQuery+strlen(sqlQuery), sizeof(sqlQuery)-strlen(sqlQuery), "%d, ", addrbookList[i]); - } - - snprintf(sqlQuery+strlen(sqlQuery), sizeof(sqlQuery)-strlen(sqlQuery), "%d );", addrbookList[addrbookCnt-1]); - - err = pDbHandle->getTable(sqlQuery, &rowCnt); - - if (err != MSG_SUCCESS) { - pDbHandle->freeTable(); - MSG_DEBUG("Fail to getTable()."); - return err; - } - - MsgDbHandler tmpDbHandle; - for (int i=1; i<=rowCnt; i++) - MsgStoClearContactInfo(&tmpDbHandle, pDbHandle->getColumnToInt(i)); - - pDbHandle->freeTable(); - - return err; -} - - -msg_error_t MsgStoClearContactInfo(MsgDbHandler *pDbHandle, int contactId) -{ - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; - int rowCnt = 0; - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT(CONV_ID) FROM %s WHERE CONTACT_ID = %d;", - MSGFW_ADDRESS_TABLE_NAME, contactId); - - err = pDbHandle->getTable(sqlQuery, &rowCnt); - - if (err != MSG_SUCCESS) { - pDbHandle->freeTable(); - MSG_DEBUG("[Error]Failed to Get Table"); - return err; - } - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET " - "CONTACT_ID = 0, " - "ADDR_BOOK_ID = 0, " - "FIRST_NAME = '', " - "LAST_NAME = '', " - "MIDDLE_NAME = '', " - "PREFIX = '', " - "SUFFIX = '', " - "IMAGE_PATH = '' " - "WHERE CONTACT_ID = %d;", - MSGFW_ADDRESS_TABLE_NAME, - contactId); - - if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { - pDbHandle->freeTable(); - MSG_DEBUG("Fail to execute query"); - return MSG_ERR_DB_EXEC; - } - - MsgDbHandler tmpDbHandle; - for (int i=1; i<=rowCnt; i++) - MsgStoSetConversationDisplayName(&tmpDbHandle, (msg_thread_id_t)pDbHandle->getColumnToInt(i)); - - pDbHandle->freeTable(); - - return err; -} - - -msg_error_t MsgStoResetContactInfo(MsgDbHandler *pDbHandle, int contactId) -{ - msg_error_t err = MSG_SUCCESS; - - char sqlQuery[MAX_QUERY_LEN+1]; - int rowCnt = 0; - int index = 2; - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ADDRESS_VAL, CONV_ID FROM %s WHERE CONTACT_ID = %d;", - MSGFW_ADDRESS_TABLE_NAME, contactId); - - err = pDbHandle->getTable(sqlQuery, &rowCnt); - - if (err != MSG_SUCCESS) { - pDbHandle->freeTable(); - MSG_DEBUG("[Error]Failed to Get Table"); - return err; - } - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET " - "CONTACT_ID = 0, " - "ADDR_BOOK_ID = 0, " - "FIRST_NAME = '', " - "LAST_NAME = '', " - "MIDDLE_NAME = '', " - "PREFIX = '', " - "SUFFIX = '', " - "IMAGE_PATH = '' " - "WHERE CONTACT_ID = %d;", - MSGFW_ADDRESS_TABLE_NAME, - contactId); - - if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) { - pDbHandle->freeTable(); - MSG_DEBUG("Fail to execute query"); - return MSG_ERR_DB_EXEC; - } - - MsgDbHandler tmpDbHandle; - for (int i=0; i<rowCnt; i++) { - - char *strNumber = pDbHandle->getColumnToString(index++); - MSG_CONTACT_INFO_S contactInfo; - memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - if (strNumber != NULL) { - MSG_SEC_DEBUG("Number [%s]", strNumber); - - MSG_ADDRESS_INFO_S addrInfo; - memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - strncpy(addrInfo.addressVal, strNumber, MAX_ADDRESS_VAL_LEN); - - //contacts-service is not used for gear -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - if(MsgGetContactInfo(&addrInfo, &contactInfo) == MSG_SUCCESS) { - if (!MsgInsertContact(&contactInfo, strNumber)) - MSG_DEBUG("MsgInsertContact fail."); - } -#endif - } - - MsgStoSetConversationDisplayName(&tmpDbHandle, (msg_thread_id_t)pDbHandle->getColumnToInt(index++)); - } - - pDbHandle->freeTable(); - - return err; -} - - msg_error_t MsgStoGetMmsRawFilePath(MsgDbHandler *pDbHandle, msg_message_id_t msgId, char *pFilePath) { char sqlQuery[MAX_QUERY_LEN+1]; @@ -1204,7 +976,7 @@ bool MsgStoCheckReadReportRequested(MsgDbHandler *pDbHandle, msg_message_id_t ms WHERE A.MSG_ID = B.MSG_ID AND B.MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId); - err = pDbHandle->getTable(sqlQuery, &rowCnt); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { pDbHandle->freeTable(); @@ -1241,7 +1013,7 @@ bool MsgStoCheckReadReportIsSent(MsgDbHandler *pDbHandle, msg_message_id_t msgId WHERE A.MSG_ID = B.MSG_ID AND B.MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId); - err = pDbHandle->getTable(sqlQuery, &rowCnt); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { pDbHandle->freeTable(); @@ -1299,7 +1071,7 @@ msg_error_t MsgStoSetConversationDisplayName(MsgDbHandler *pDbHandle, int contac snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT(CONV_ID) FROM %s WHERE CONTACT_ID = %d;", MSGFW_ADDRESS_TABLE_NAME, contactId); - err = pDbHandle->getTable(sqlQuery, &rowCnt); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { pDbHandle->freeTable(); @@ -1310,7 +1082,7 @@ msg_error_t MsgStoSetConversationDisplayName(MsgDbHandler *pDbHandle, int contac //contacts-service is not used for gear #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED int order = MsgGetContactNameOrder(); -#else +#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED int order = 0; #endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED msg_struct_s *pAddrInfo = NULL; @@ -1388,7 +1160,7 @@ msg_error_t MsgStoSetConversationDisplayName(MsgDbHandler *pDbHandle, msg_thread //contacts-service is not used for gear #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED int order = MsgGetContactNameOrder(); -#else +#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED int order = 0; #endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED @@ -1477,7 +1249,7 @@ bool MsgExistConversation(MsgDbHandler *pDbHandle, msg_thread_id_t convId) snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONV_ID FROM %s WHERE CONV_ID = %d;", MSGFW_CONVERSATION_TABLE_NAME, convId); - err = pDbHandle->getTable(sqlQuery, &rowCnt); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err == MSG_ERR_DB_NORECORD) { pDbHandle->freeTable(); @@ -1506,7 +1278,7 @@ bool MsgExistMessage(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsg) snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE CONV_ID = %ud AND DISPLAY_TIME = %ud;", MSGFW_MESSAGE_TABLE_NAME, pMsg->threadId, (int)pMsg->displayTime); - err = pDbHandle->getTable(sqlQuery, &rowCnt); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); if ( err != MSG_SUCCESS) { @@ -1550,7 +1322,7 @@ bool MsgExistAddress(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsg, msg_thr MSGFW_ADDRESS_TABLE_NAME, pMsg->addressList[index].addressVal, convId); } - err = pDbHandle->getTable(sqlQuery, &rowCnt); + err = pDbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err == MSG_ERR_DB_NORECORD) { pDbHandle->freeTable(); @@ -1652,14 +1424,14 @@ msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pC { MSG_BEGIN(); - int rowCnt = 0; - int index = 4; + int rowCnt = 0, index = 0; + char sqlQuery[MAX_QUERY_LEN] = {0,}; memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CHANNEL_ACTIVATION, CHANNEL_FROM, CHANNEL_TO, CHANNEL_NAME FROM %s WHERE SIM_INDEX = %d;", MSGFW_CB_CHANNEL_INFO_TABLE_NAME, simIndex); - msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt); + msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt, &index); pCBChannel->channelCnt = rowCnt; @@ -1733,14 +1505,14 @@ msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pC { MSG_BEGIN(); - int rowCnt = 0; - int index = 4; + int rowCnt = 0, index = 0; + char sqlQuery[MAX_QUERY_LEN] = {0,}; memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CHANNEL_ACTIVATION, CHANNEL_CATEGORY, CHANNEL_LANGUAGE, CHANNEL_NAME FROM %s;", MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME); - msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt); + msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt, &index); pCBChannel->channelCnt = rowCnt; @@ -1773,169 +1545,6 @@ msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pC } #endif -// Lists -msg_error_t MsgStoGetFolderViewList(msg_folder_id_t folderId, const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pMsgFolderViewList) -{ - if (pMsgFolderViewList == NULL) { - MSG_DEBUG("pMsgFolderViewList is NULL"); - return MSG_ERR_NULL_POINTER; - } - - MsgDbHandler *dbHandle = getDbHandle(); - - int rowCnt = 0; - int index = 19; // numbers of index - - - char sqlQuery[MAX_QUERY_LEN+1]; - char sqlSort[64]; - - // Get Name Order - //contacts-service is not used for gear -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - int order = MsgGetContactNameOrder(); -#else - int order = 0; -#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED - - // 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(); - - return MSG_SUCCESS; - } else if (err != MSG_SUCCESS) { - MSG_DEBUG("Fail to getTable()."); - dbHandle->freeTable(); - return err; - } - - pMsgFolderViewList->nCount = rowCnt; - - MSG_DEBUG("pMsgCommInfoList->nCount [%d]", pMsgFolderViewList->nCount); - - pMsgFolderViewList->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(msg_struct_t)); - - 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 msg_struct_s; - - msg = (msg_struct_s *)pMsgFolderViewList->msg_struct_info[i]; - - msg->type = MSG_STRUCT_MESSAGE_INFO; - msg->data = new MSG_MESSAGE_HIDDEN_S; - - pTmp = (MSG_MESSAGE_HIDDEN_S *)msg->data; - - pTmp->pData = NULL; - pTmp->pMmsData = NULL; - pTmp->addressList = 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); - } - - // get address information from db. - msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s; - - MsgDbHandler db; - MsgStoGetAddressByMsgId(&db, pTmp->msgId, order, addr_list); - - pTmp->addr_list = addr_list; - - // For GList *addressList - int nAddressCnt = 0; - MSG_ADDRESS_INFO_S *addressList = NULL; - MsgStoGetAddressByMsgId(&db, pTmp->msgId, order, &nAddressCnt, &addressList); - - for (int i = 0; i < nAddressCnt; i++) { - msg_struct_s *addr_info_s = NULL; - MSG_ADDRESS_INFO_S *addr_info = NULL; - - addr_info_s = new msg_struct_s; - memset(addr_info_s, 0x00, sizeof(msg_struct_s)); - - addr_info_s->type = MSG_STRUCT_ADDRESS_INFO; - addr_info_s->data = new MSG_ADDRESS_INFO_S; - memset(addr_info_s->data, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - - addr_info = (MSG_ADDRESS_INFO_S *)addr_info_s->data; - - addr_info->addressType = addressList[i].addressType; - addr_info->recipientType = addressList[i].recipientType; - addr_info->contactId = addressList[i].contactId; - strncpy(addr_info->addressVal, addressList[i].addressVal, MAX_ADDRESS_VAL_LEN); - strncpy(addr_info->displayName, addressList[i].displayName, MAX_DISPLAY_NAME_LEN); - addr_info->displayName[MAX_DISPLAY_NAME_LEN] = '\0'; - - pTmp->addressList = g_list_append(pTmp->addressList, addr_info_s); - } - - delete [] addressList; - - pTmp->attachCount = dbHandle->getColumnToInt(index++); - - dbHandle->getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pTmp->thumbPath); - } - - dbHandle->freeTable(); - - return MSG_SUCCESS; -} - - msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList) { MsgDbHandler *dbHandle = getDbHandle(); @@ -1943,8 +1552,7 @@ msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct pThreadViewList->nCount = 0; pThreadViewList->msg_struct_info = NULL; - int rowCnt = 0; - int index = 14; // numbers of index + int rowCnt = 0, index = 0; char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -1963,7 +1571,7 @@ msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct MSGFW_CONVERSATION_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME); - 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(); @@ -2045,8 +1653,7 @@ msg_error_t MsgStoGetConversationPreview(MSG_CONVERSATION_VIEW_S *pConv) MsgDbHandler dbHandleForInner; char sqlQuery[MAX_QUERY_LEN + 1]; - int rowCnt; - int index = 3; + int rowCnt = 0, index = 0; memset(sqlQuery, 0x00, sizeof(sqlQuery)); if (pConv == NULL) @@ -2060,7 +1667,7 @@ msg_error_t MsgStoGetConversationPreview(MSG_CONVERSATION_VIEW_S *pConv) "FROM %s WHERE MSG_ID=%d;", MSGFW_MMS_PREVIEW_TABLE_NAME, pConv->msgId); - msg_error_t err = dbHandleForInner.getTable(sqlQuery, &rowCnt); + msg_error_t err = dbHandleForInner.getTable(sqlQuery, &rowCnt, &index); if (err == MSG_SUCCESS) { for (int i = 0; i < rowCnt; i++) { int type = dbHandleForInner.getColumnToInt(index++); @@ -2100,8 +1707,7 @@ msg_error_t MsgStoGetConversationMultipart(MSG_CONVERSATION_VIEW_S *pConv) { MsgDbHandler dbHandleForInner; char sqlQuery[MAX_QUERY_LEN + 1]; - int rowCnt; - int index = 8; + int rowCnt = 0, index = 0; memset(sqlQuery, 0x00, sizeof(sqlQuery)); if (pConv == NULL) @@ -2112,7 +1718,7 @@ msg_error_t MsgStoGetConversationMultipart(MSG_CONVERSATION_VIEW_S *pConv) "FROM %s WHERE MSG_ID=%d;", MSGFW_MMS_MULTIPART_TABLE_NAME, pConv->msgId); - msg_error_t err = dbHandleForInner.getTable(sqlQuery, &rowCnt); + msg_error_t err = dbHandleForInner.getTable(sqlQuery, &rowCnt, &index); if (err == MSG_SUCCESS) { GList *multipart_list = NULL; for (int i = 0; i < rowCnt; i++) { @@ -2147,8 +1753,8 @@ msg_error_t MsgStoGetConversationViewItem(msg_message_id_t msgId, MSG_CONVERSATI { MsgDbHandler *dbHandle = getDbHandle(); - int rowCnt = 0; - int index = 17; /** numbers of index */ + int rowCnt = 0, index = 0; + char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -2159,7 +1765,7 @@ msg_error_t MsgStoGetConversationViewItem(msg_message_id_t msgId, MSG_CONVERSATI FROM %s WHERE MSG_ID=%d;", MSGFW_MESSAGE_TABLE_NAME, msgId); - 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(); @@ -2236,8 +1842,8 @@ msg_error_t MsgStoGetConversationViewList(msg_thread_id_t threadId, msg_struct_l pConvViewList->nCount = 0; pConvViewList->msg_struct_info = NULL; - int rowCnt = 0; - int index = 17; /** numbers of index */ + int rowCnt = 0, index = 0; + char sqlQuery[MAX_QUERY_LEN+1]; memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -2256,7 +1862,7 @@ msg_error_t MsgStoGetConversationViewList(msg_thread_id_t threadId, msg_struct_l MSGFW_MESSAGE_TABLE_NAME, threadId, MSG_ALLBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE); #endif - 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(); @@ -2365,7 +1971,7 @@ msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pT MSG_THREAD_VIEW_S threadView; MSG_ADDRESS_INFO_S *pAddrInfo = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> buf(&pAddrInfo); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter); int count = 0; //contacts-service is not used for gear @@ -2375,7 +1981,7 @@ msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pT MSG_DEBUG("MsgGetContactSearchList fail."); count = 0; } -#endif +#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED int iteration = (count / ITERATION_SIZE) + 1; int remaining = count; @@ -2502,6 +2108,8 @@ msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pT // Add data to Out Parameter pThreadViewList->nCount = searchList.size(); pThreadViewList->msg_struct_info = (msg_struct_t *)calloc(searchList.size(), sizeof(msg_struct_t)); + if (pThreadViewList->msg_struct_info == NULL) + return MSG_ERR_MEMORY_ERROR; MSG_THREAD_VIEW_S *pTmp = NULL; msg_struct_s *thread_t = NULL; @@ -2537,8 +2145,7 @@ msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pReje pRejectMsgList->nCount = 0; pRejectMsgList->msg_struct_info = NULL; - int rowCnt = 0; - int index = 3; // numbers of index + int rowCnt = 0, index = 0; char sqlQuery[MAX_QUERY_LEN+1]; @@ -2584,7 +2191,7 @@ msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pReje MSG_REJECT_SMS); } - msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt); + msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS) { MSG_DEBUG("Fail to getTable()."); @@ -2631,7 +2238,7 @@ msg_error_t MsgStoGetAddressList(const msg_thread_id_t threadId, msg_struct_list //contacts-service is not used for gear #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED int order = MsgGetContactNameOrder(); -#else +#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED int order = 0; #endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED @@ -2861,7 +2468,7 @@ msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_stru strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); MSG_ADDRESS_INFO_S *pAddrInfo = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> buf(&pAddrInfo); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter); int count = 0; //contacts-service is not used for gear @@ -2871,7 +2478,7 @@ msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_stru MSG_DEBUG("MsgGetContactSearchList fail."); count = 0; } -#endif +#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED if (count > 0) { dbHandle->beginTrans(); // reset address temp table @@ -2933,7 +2540,7 @@ msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_stru strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery)); MSG_ADDRESS_INFO_S *pAddrInfo = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> buf(&pAddrInfo); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter); int count = 0; //contacts-service is not used for gear @@ -2943,7 +2550,7 @@ msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_stru MSG_DEBUG("MsgGetContactSearchList fail."); count = 0; } -#endif +#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED if (count > 0) { dbHandle->beginTrans(); // reset address temp table @@ -3233,6 +2840,8 @@ msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_stru MSG_DEBUG("pMsgList->nCount [%d]", pMsgList->nCount); pMsgList->msg_struct_info = (msg_struct_t *)calloc(pMsgList->nCount, sizeof(msg_struct_t)); + if (pMsgList->msg_struct_info == NULL) + return MSG_ERR_MEMORY_ERROR; int offset = 0; while (!searchList.empty()) { @@ -3264,7 +2873,7 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t msg_error_t err = MSG_SUCCESS; MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN+1]; - int rowCnt = 0, msgIdCnt = 0; + int msgIdCnt = 0; memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE MAIN_TYPE = %d AND CONV_ID = %d;", @@ -3272,7 +2881,7 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t MSG_DEBUG("sqlQuery = [%s]", sqlQuery); - err = dbHandle->getTable(sqlQuery, &msgIdCnt); + err = dbHandle->getTable(sqlQuery, &msgIdCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); return err; @@ -3281,7 +2890,7 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t return MSG_SUCCESS; } - msg_message_id_t *msgIds = new msg_message_id_t[msgIdCnt]; + msg_message_id_t msgIds[msgIdCnt]; for (int i = 1; i <= msgIdCnt; i++) { msgIds[i-1] = dbHandle->getColumnToInt(i); @@ -3318,7 +2927,9 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t MSGFW_MMS_MULTIPART_TABLE_NAME, msgIds[i]); } - err = dbHandle->getTable(sqlQuery, &rowCnt); + int rowCnt = 0, msg_id = 0, index = 0; + + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); @@ -3326,7 +2937,6 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t } MSG_MEDIA_INFO_S *pMedia = NULL; - int msg_id = 0, index = 4; char mime_type[MAX_MIME_TYPE_LEN+1], media_item[MSG_FILEPATH_LEN_MAX+1], thumb_path[MSG_FILEPATH_LEN_MAX+1]; for (int j = 0; j < rowCnt; j++) { @@ -3360,11 +2970,8 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t *pMediaList = (msg_list_handle_t)media_list; } - if (msgIds) - delete [] msgIds; - MSG_END(); - return err; + return MSG_SUCCESS; } #ifdef FEATURE_SMS_CDMA diff --git a/utils/MsgVMessage.cpp b/utils/MsgVMessage.cpp index e269c7b..e621568 100755 --- a/utils/MsgVMessage.cpp +++ b/utils/MsgVMessage.cpp @@ -226,9 +226,9 @@ if(strlen(pMsg->subject) > 0) if (pMsg->bTextSms == false) { char* pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); - int fileSize = 0; + int fileSize = 0; char* msgText = NULL; if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) @@ -256,6 +256,7 @@ if(strlen(pMsg->subject) > 0) { //Insert VBody for mms raw data; char* pFileData = NULL; + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); MMS_DATA_S *pMmsData = NULL; int fileSize = 0; char* msgText = NULL; @@ -304,8 +305,6 @@ if(strlen(pMsg->subject) > 0) pFileData = NULL; } - MsgMmsSetMultipartListData(pMmsData);//app file -> data - int serializedDataSize = 0; if (pMmsData) { @@ -574,7 +573,7 @@ if(strlen(pMsg->subject) > 0) if (pMsg->bTextSms == false) { char* pFileData = NULL; - AutoPtr<char> buf(&pFileData); + unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter); int fileSize = 0; char* msgText = NULL; @@ -583,7 +582,9 @@ if(strlen(pMsg->subject) > 0) goto __CATCH_FAIL__; msgText = (char *)calloc(1, fileSize); - memcpy(msgText, pFileData, fileSize); + if (pFileData && msgText) + memcpy(msgText, pFileData, fileSize); + pObject->numOfBiData = fileSize; pObject->pszValue[0] = msgText; } @@ -621,8 +622,9 @@ if(strlen(pMsg->subject) > 0) } MSG_DEBUG("FILE SIZE IS %d", fileSize); msgText = (char *)calloc(1, fileSize); - if(pFileData) + if(pFileData && msgText) memcpy(msgText, pFileData, fileSize); + pObject->numOfBiData = fileSize; pObject->pszValue[0] = msgText; pObject->valueCount = 1; diff --git a/utils/MsgZoneManager.cpp b/utils/MsgZoneManager.cpp deleted file mode 100755 index e2bb438..0000000 --- a/utils/MsgZoneManager.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* -* Copyright 2012-2013 Samsung Electronics Co., Ltd -* -* Licensed under the Flora License, Version 1.1 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://floralicense.org/license/ -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include <glib.h> -#include <sys/socket.h> - -#include "MsgDebug.h" -#include "MsgZoneManager.h" - -#ifdef FEATURE_CONTAINER_ENABLE -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#define MSG_ZONE_KNOX "knox" -#define MSG_ZONE_PERSONAL "personal" - -#include <vasum.h> - -vsm_context_h vsm_ctx = NULL; -vsm_zone_h real_zone = NULL; -GIOChannel *gio_channel = NULL; - -int zone_ref_count = 0; - - -gboolean _zone_mainloop_cb(GIOChannel *channel, GIOCondition condition, void *data) -{ - MSG_BEGIN(); -#ifdef FEATURE_CONTAINER_ENABLE - struct vsm_context *ctx = (struct vsm_context *)data; - vsm_enter_eventloop(ctx, 0, 0); - MSG_END(); -#endif - return true; -} - - -int _get_peer_pid(int fd) -{ - struct ucred cred; - socklen_t cr_len = sizeof(cred); - if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &cr_len) < 0) { - return -1; - } - return cred.pid; -} - -#endif - -void MsgZoneInit() -{ - MSG_BEGIN(); -#ifdef FEATURE_CONTAINER_ENABLE - - MsgZoneClean(); - - vsm_ctx = vsm_create_context(); - if (vsm_ctx == NULL) { - MSG_FATAL("vsm_create_context failed"); - return; - } - - int fd = vsm_get_poll_fd(vsm_ctx); - gio_channel = g_io_channel_unix_new(fd); - if (gio_channel == NULL) { - MSG_FATAL("g_io_channel_unix_new failed"); - return; - } - - g_io_add_watch(gio_channel, G_IO_IN, _zone_mainloop_cb, vsm_ctx); - -#endif - MSG_END(); -} - - -void MsgZoneClean() -{ - MSG_BEGIN(); -#ifdef FEATURE_CONTAINER_ENABLE - if (vsm_ctx != NULL) { - vsm_cleanup_context(vsm_ctx); - vsm_ctx = NULL; - } - if (gio_channel != NULL) { - g_io_channel_unref(gio_channel); - gio_channel = NULL; - } -#endif - MSG_END(); -} - - -char* MsgZoneGetName(int fd) -{ - MSG_BEGIN(); -#ifdef FEATURE_CONTAINER_ENABLE - if (vsm_ctx == NULL) { - MsgZoneInit(); - } - int pid = _get_peer_pid(fd); - vsm_zone_h zone = vsm_lookup_zone_by_pid(vsm_ctx, pid); - if (zone == NULL) { - MSG_FATAL("vsm_lookup_zone_by_pid failed, PID = %d", pid); - return NULL; - } - MSG_END(); - return strdup(vsm_get_zone_name(zone)); -#endif - return NULL; -} - - -bool MsgZoneIsAllowed(int fd) -{ -#ifdef FEATURE_CONTAINER_ENABLE - char *zone_name = MsgZoneGetName(fd); - if (zone_name == NULL) { - return false; - } - - MSG_DEBUG("zone_name=[%s]", zone_name); - bool result = (!g_strcmp0(zone_name, MSG_ZONE_PERSONAL) || (!g_strcmp0(zone_name, ""))); - g_free(zone_name); - zone_name = NULL; - - return result; -#endif - return true; -} - - -void MsgZoneChange() -{ - MSG_BEGIN(); -#ifdef FEATURE_CONTAINER_ENABLE - if (vsm_ctx == NULL) { - MSG_DEBUG("vsm_ctx == NULL"); - return; - } - if (real_zone != NULL && zone_ref_count > 0) { - zone_ref_count++; - MSG_DEBUG("zone_ref_count++"); - return; - } - - vsm_zone_h current_zone = vsm_get_foreground(vsm_ctx); - vsm_zone_h effective_zone = vsm_lookup_zone_by_name(vsm_ctx, MSG_ZONE_PERSONAL); - if (!g_strcmp0(vsm_get_zone_name(current_zone), MSG_ZONE_KNOX) && real_zone == NULL) { - real_zone = vsm_join_zone(effective_zone); - MSG_DEBUG("Change Zone"); - zone_ref_count++; - } -#endif - MSG_END(); -} - - -void MsgZoneRevert() -{ - MSG_BEGIN(); -#ifdef FEATURE_CONTAINER_ENABLE - if (real_zone == NULL || zone_ref_count == 0) { - MSG_DEBUG("real_zone == NULL || zone_ref_count == 0"); - return; - } - zone_ref_count--; - if (zone_ref_count == 0) { - vsm_join_zone(real_zone); - real_zone = NULL; - MSG_DEBUG("Revert Zone"); - } -#endif - MSG_END(); -} diff --git a/vobject-engine/CMakeLists.txt b/vobject-engine/CMakeLists.txt index 4d875e2..f879cad 100755 --- a/vobject-engine/CMakeLists.txt +++ b/vobject-engine/CMakeLists.txt @@ -8,8 +8,8 @@ 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_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall") +#SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O2 -g -Wall") SET(VOBJECT-SRCS ${CMAKE_SOURCE_DIR}/vobject-engine/VCard.c @@ -30,7 +30,7 @@ ENDFOREACH(flag) ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -#SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") diff --git a/vobject-engine/VCard.c b/vobject-engine/VCard.c index a2469a6..f57dcf0 100755 --- a/vobject-engine/VCard.c +++ b/vobject-engine/VCard.c @@ -325,7 +325,7 @@ __VCardGetTypeName(char* pVCardRaw, int* pStatus, int* pDLen) else if ( c == VTYPE_TOKEN_DOT ) { #ifdef VDATA_GROUPNAME_SUPPORTED name[index] = '\0'; - szGroupName = ( char* ) malloc ( index+1 ); + szGroupName = ( char* ) calloc(1, index+1 ); if(szGroupName != NULL){ strncpy( szGroupName, name, index ); gszGroupName = szGroupName; @@ -601,7 +601,7 @@ __VCardGetParamVal( char* pVCardRaw, int* pStatus, int* pDLen ) //if (len < 1) //return NULL; - pBuf = (char *)malloc(len); + pBuf = (char *)calloc(1, len); if(pBuf == NULL) return NULL; @@ -650,7 +650,7 @@ __VCardGetTypeVal( char* pVCardRaw, int* pStatus, int* pDLen, int enc, VObject* /** This case means that there are more type's value. */ if ( c == VTYPE_TOKEN_SEMICOLON && bEscape == false ) { - if((pBuf = (char *)malloc(len)) == NULL) return NULL; + if((pBuf = (char *)calloc(1, len)) == NULL) return NULL; memset(pBuf, 0x00, len); memcpy(pBuf,pTemp,len-1); @@ -665,7 +665,7 @@ __VCardGetTypeVal( char* pVCardRaw, int* pStatus, int* pDLen, int enc, VObject* bufferCount = (len * 6 / 8) + 2; - if((pTmpBuf = (char *)malloc(bufferCount)) == NULL) { + if((pTmpBuf = (char *)calloc(1, bufferCount)) == NULL) { VFREE(pBuf); return NULL; } @@ -727,7 +727,7 @@ __VCardGetTypeVal( char* pVCardRaw, int* pStatus, int* pDLen, int enc, VObject* else if(__VCardGetTypeName(pVCardRaw, &Status, &Len) != UNKNOWN_NAME) { --len; - if((pBuf = (char *)malloc(len)) == NULL) return NULL; + if((pBuf = (char *)calloc(1, len)) == NULL) return NULL; memset(pBuf, 0x00, len); memcpy(pBuf,pTemp,len-1); @@ -748,7 +748,7 @@ __VCardGetTypeVal( char* pVCardRaw, int* pStatus, int* pDLen, int enc, VObject* bufferCount = (len * 6 / 8) + 5; - if((pTmpBuf = (char *)malloc(bufferCount)) == NULL) { + if((pTmpBuf = (char *)calloc(1, bufferCount)) == NULL) { VFREE(pBuf); return NULL; } @@ -871,6 +871,9 @@ vcard_decode( char *pCardRaw ) VDATA_TRACE("length of pCardRaw = %d", len); pCardRaw = _VUnfoldingNoSpecNew(pCardRaw); + if (pCardRaw == NULL) { + return NULL; + } pCardRawTmp = pCardRaw; len = _VManySpace2Space( pCardRaw ); @@ -907,7 +910,7 @@ vcard_decode( char *pCardRaw ) pVCard = NULL; } - if ( ( pVCard = ( VTree* )malloc( sizeof( VTree ) ) ) == NULL ) { + if ( ( pVCard = ( VTree* )calloc(1, sizeof( VTree ) ) ) == NULL ) { //start_status = 1; goto CATCH; } @@ -948,7 +951,7 @@ vcard_decode( char *pCardRaw ) break; } - if ( ( pTemp = ( VObject* )malloc( sizeof( VObject ) ) ) == NULL ) { + if ( ( pTemp = ( VObject* )calloc(1, sizeof( VObject ) ) ) == NULL ) { goto CATCH; } @@ -985,7 +988,7 @@ vcard_decode( char *pCardRaw ) if ( param_status != true ) { - if ( ( pTmpParam = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL ) + if ( ( pTmpParam = ( VParam* )calloc(1, sizeof( VParam ) ) ) == NULL ) goto CATCH; param_status = true; @@ -995,7 +998,7 @@ vcard_decode( char *pCardRaw ) } else { - if ( ( pTmpParam->pNext = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL ) + if ( ( pTmpParam->pNext = ( VParam* )calloc(1, sizeof( VParam ) ) ) == NULL ) goto CATCH; pTmpParam = pTmpParam->pNext; @@ -1130,16 +1133,16 @@ vcard_encode( VTree *pVCardRaw ) return NULL; } } - - if ( ( pVCardRes = ( char * )malloc( sizeof( char ) * ( total += 14 + 14 ) ) ) == NULL ) + total += sizeof(char) * (14 + 14); + if ( ( pVCardRes = ( char * )calloc(1, total ) ) == NULL ) { - VDATA_TRACE( "vcard_encode:malloc failed\n" ); + VDATA_TRACE( "vcard_encode:calloc failed\n" ); VDATA_TRACE_END return NULL; } memcpy( pVCardRes, "BEGIN:VCARD\r\n", 14 ); - strcat( pVCardRes, "VERSION:2.1\r\n" ); + g_strlcat( pVCardRes, "VERSION:2.1\r\n", total - strlen(pVCardRes)); pTmpObj = pVCardRaw->pTop; @@ -1151,8 +1154,8 @@ vcard_encode( VTree *pVCardRaw ) if ( ( pTemp = __VCardTypeEncode( pTmpObj, pszCardTypeList[pTmpObj->property] ) ) != NULL ) { len = strlen( pTemp ); - - if ( ( pVCardRes = ( char* )realloc( pVCardRes, ( total += len+10 ) ) ) == NULL ) + total += len + sizeof(char) * 10; + if ( ( pVCardRes = ( char* )realloc( pVCardRes, total ) ) == NULL ) { VDATA_TRACE( "vcard_encode():realloc failed\n"); VFREE( pTemp ); @@ -1162,7 +1165,7 @@ vcard_encode( VTree *pVCardRaw ) } if( strncmp(pTemp,"VERSION", strlen("VERSION")) != 0) - strncat(pVCardRes, pTemp, strlen(pTemp)); + g_strlcat(pVCardRes, pTemp, total - strlen(pVCardRes)); VDATA_TRACE("pTemp : %s", pTemp); @@ -1176,14 +1179,15 @@ vcard_encode( VTree *pVCardRaw ) break; } - if ( ( pVCardRes = ( char * )realloc( pVCardRes, ( total += 12 ) ) ) == NULL ) + total += sizeof(char) * 12; + if ( ( pVCardRes = ( char * )realloc( pVCardRes, total ) ) == NULL ) { VDATA_TRACE( "vcard_encode:realloc failed\n"); VDATA_TRACE_END return NULL; } - strcat( pVCardRes, "END:VCARD\r\n" ); - VDATA_TRACE_END + g_strlcat( pVCardRes, "END:VCARD\r\n", total - strlen(pVCardRes)); + VDATA_TRACE_END return pVCardRes; } @@ -1247,9 +1251,9 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) len += strlen( pTypeObj->pszGroupName ) + 1; } #endif // VDATA_GROUPNAME_SUPPORTED - if ( ( szTypeValue = ( char * )malloc( total += ( len+1 ) ) ) == NULL ) + if ( ( szTypeValue = ( char * )calloc(1, total += ( len+1 ) ) ) == NULL ) { - VDATA_TRACE( "__VCardTypeEncode():malloc failed\n"); + VDATA_TRACE( "__VCardTypeEncode():calloc failed\n"); VDATA_TRACE_END return NULL; } @@ -1257,11 +1261,11 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) #ifdef VDATA_GROUPNAME_SUPPORTED if ( pTypeObj->pszGroupName != NULL ) { - g_strlcat( szTypeValue, pTypeObj->pszGroupName, total); - g_strlcat( szTypeValue, ".", total); + g_strlcat( szTypeValue, pTypeObj->pszGroupName, total - strlen(szTypeValue)); + g_strlcat( szTypeValue, ".", total - strlen(szTypeValue)); } #endif // VDATA_GROUPNAME_SUPPORTED - g_strlcat( szTypeValue, pType, total); + g_strlcat( szTypeValue, pType, total - strlen(szTypeValue)); pTemp = __VCardParamEncode( pTypeObj, &enc ); if ( pTemp != NULL ) @@ -1275,7 +1279,7 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) VDATA_TRACE_END; return NULL; } - g_strlcat( szTypeValue, pTemp, total); + g_strlcat( szTypeValue, pTemp, total - strlen(szTypeValue)); VFREE( pTemp ); pTemp = NULL; } @@ -1286,7 +1290,7 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) return NULL; } - strcat( szTypeValue, ":" ); + g_strlcat( szTypeValue, ":", total - strlen(szTypeValue)); len = 0; @@ -1304,7 +1308,7 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) for ( i = 0; i < pTypeObj->valueCount; i++ ) { if ( i == 0 ) { - if ( ( pEncode = ( char * )malloc( len+20 ) ) == NULL ) { + if ( ( pEncode = ( char * )calloc(1, len+20 ) ) == NULL ) { VFREE(szTypeValue); VDATA_TRACE_END return NULL; @@ -1313,7 +1317,7 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) memset( pEncode, '\0', len+20 ); if(strcmp(pType, pszCardTypeList[19]) != 0) { - g_strlcat( pEncode, pTypeObj->pszValue[i], len+20); + g_strlcat( pEncode, pTypeObj->pszValue[i], len+20 - strlen(pEncode)); _VEscape(pEncode); } else @@ -1323,14 +1327,14 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) char buf[1000]; strncpy( buf, pTypeObj->pszValue[i], 999 ); _VEscape( buf ); - g_strlcat( pEncode, ";", len+20); - g_strlcat( pEncode, buf, len+20); + g_strlcat( pEncode, ";", len+20 - strlen(pEncode)); + g_strlcat( pEncode, buf, len+20 - strlen(pEncode)); } } if(strcmp(pType, pszCardTypeList[19]) != 0) { if (pEncode) { - strcat( pEncode, "\0\0" ); + g_strlcat( pEncode, "\0\0", len+20 - strlen(pEncode) ); len = strlen( pEncode ); } } @@ -1339,7 +1343,7 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) } if ( enc & pEncList[2].flag ) { - if((pRes = (char *)malloc(len * 6 + 10)) == NULL) { + if((pRes = (char *)calloc(1, len * 6 + 10)) == NULL) { VFREE(pEncode); VFREE(szTypeValue); VDATA_TRACE_END @@ -1350,7 +1354,7 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) VFREE(pEncode); } else if(enc & pEncList[1].flag ) { - if((pRes = (char *)malloc((len * 8 / 6) + 4)) == NULL){ + if((pRes = (char *)calloc(1, (len * 8 / 6) + 4)) == NULL){ VFREE(pEncode); VFREE(szTypeValue); VDATA_TRACE_END @@ -1362,7 +1366,7 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) VFREE(pEncode); } else { - if((pRes = (char *)malloc(len+30)) == NULL) { + if((pRes = (char *)calloc(1, len+30)) == NULL) { VFREE(pEncode); VFREE(szTypeValue); VDATA_TRACE_END @@ -1383,7 +1387,7 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) VDATA_TRACE_END return NULL; } - strncat( pRes, "\r\n", strlen(pRes) + 2); + g_strlcat( pRes, "\r\n", 2); len = strlen( pRes ); @@ -1394,7 +1398,7 @@ __VCardTypeEncode( VObject *pTypeObj, char *pType ) return NULL; } - strncat(szTypeValue, pRes, total - 1); + g_strlcat(szTypeValue, pRes, total - strlen(szTypeValue)); if(strcmp(pType, pszCardTypeList[19]) != 0) { _VRLSpace( szTypeValue ); @@ -1430,7 +1434,7 @@ __VCardParamEncode(VObject* pTypeObj, int* pEnc) /** Momory Allocation for parameter string. */ if(pTemp != NULL) { - if ((szParam = (char*)malloc(len+=2)) == NULL) + if ((szParam = (char*)calloc(1, len+=2)) == NULL) { VDATA_TRACE_END return NULL; @@ -1453,10 +1457,10 @@ __VCardParamEncode(VObject* pTypeObj, int* pEnc) } /** appending paramter name. */ - strcat( szParam, ";" ); + g_strlcat( szParam, ";", len - strlen(szParam) ); if(pTemp->parameter != VCARD_PARAM_TYPE) { - g_strlcat( szParam, pszCardParamList[pTemp->parameter], len); - g_strlcat( szParam, "=", len); + g_strlcat( szParam, pszCardParamList[pTemp->parameter], len - strlen(szParam)); + g_strlcat( szParam, "=", len - strlen(szParam)); } /** Set Parameter Value name. */ @@ -1485,7 +1489,7 @@ __VCardParamEncode(VObject* pTypeObj, int* pEnc) VDATA_TRACE_END return NULL; } - strcat( szParam, "NONE" ); + g_strlcat( szParam, "NONE", 5 - strlen(szParam) ); } /** exchage parameter value's to string.*/ @@ -1500,8 +1504,8 @@ __VCardParamEncode(VObject* pTypeObj, int* pEnc) return NULL; } - g_strlcat( szParam, pList[i].szName, len); - g_strlcat( szParam, "; ", len); + g_strlcat( szParam, pList[i].szName, len - strlen(szParam)); + g_strlcat( szParam, "; ", len - strlen(szParam)); } sNum <<= 1; diff --git a/vobject-engine/VCardCalUtil.c b/vobject-engine/VCardCalUtil.c index efafb75..ce2204e 100755 --- a/vobject-engine/VCardCalUtil.c +++ b/vobject-engine/VCardCalUtil.c @@ -178,25 +178,26 @@ _VUnescape( char *in ) int _VEscape( char *in ) { - int i; - int index; - int len; + int i; + int index; + int len; char *buf = NULL; - char c; + char c; - len = strlen(in); + len = strlen(in); buf = (char*) calloc(1, len*2+1); - - for ( i = 0, index = 0; i < len; i++ ){ - c = in[i]; - if ( c == ';' ) { - buf[index++] = '\\'; + if (buf) { + for ( i = 0, index = 0; i < len; i++ ){ + c = in[i]; + if ( c == ';' ) { + buf[index++] = '\\'; + } + buf[index++] = c; } - buf[index++] = c; - } - strncpy( in, buf, len*2+1 ); - free(buf); + strncpy( in, buf, len*2+1 ); + free(buf); + } return(0); } @@ -404,8 +405,8 @@ _VB64Encode( char *Dest, char *Src, int len ) int index; int res = 0; int base1 = 0, base2 = 0; - char Enbuffer[4]; - char Debuffer[3]; + char Enbuffer[4] = {0,}; + char Debuffer[3] = {0,}; int length = 0; for ( i = 0; i < 4; i++ ) @@ -668,7 +669,7 @@ _VUnfoldingNoSpecNew(char *string) len = strlen( string ); - if( !(newString = (char*) malloc(len+1) )) { + if( !(newString = (char*) calloc(1, len+1) )) { return NULL; } diff --git a/vobject-engine/VMessage.c b/vobject-engine/VMessage.c index 41c61f4..a3dc504 100755 --- a/vobject-engine/VMessage.c +++ b/vobject-engine/VMessage.c @@ -552,7 +552,7 @@ __VMsgGetParamVal( char* pVMsgRaw, int* pStatus, int* pDLen ) break; } - if(len < 1 || (pBuf = (char *)malloc(len)) == NULL) + if(len < 1 || (pBuf = (char *)calloc(1, len)) == NULL) return NULL; memset(pBuf, 0x00, len); memcpy( pBuf, pTemp, len-1 ); @@ -600,7 +600,7 @@ __VMsgGetTypeVal( char* pVMsgRaw, int* pStatus, int* pDLen, int enc, VObject* pT /** This case means that there are more type's value. */ if ( c == VTYPE_TOKEN_SEMICOLON && bEscape == false ) { - if((pBuf = (char *)malloc(len)) == NULL) + if((pBuf = (char *)calloc(1, len)) == NULL) return NULL; memset(pBuf, 0x00, len); @@ -617,7 +617,7 @@ __VMsgGetTypeVal( char* pVMsgRaw, int* pStatus, int* pDLen, int enc, VObject* pT bufferCount = (len * 6 / 8) + 2; - if((pTmpBuf = (char *)malloc(bufferCount)) == NULL) + if((pTmpBuf = (char *)calloc(1, bufferCount)) == NULL) { VFREE(pBuf); return NULL; @@ -684,7 +684,7 @@ __VMsgGetTypeVal( char* pVMsgRaw, int* pStatus, int* pDLen, int enc, VObject* pT } else if(__VMsgGetTypeName(pVMsgRaw, &Status, &Len) != UNKNOWN_NAME) { - if((pBuf = (char *)malloc(len)) == NULL) + if((pBuf = (char *)calloc(1, len)) == NULL) return NULL; memset(pBuf, 0x00, len); @@ -708,7 +708,7 @@ __VMsgGetTypeVal( char* pVMsgRaw, int* pStatus, int* pDLen, int enc, VObject* pT bufferCount = (len * 6 / 8) + 5; - if((pTmpBuf = (char *)malloc(bufferCount)) == NULL) + if((pTmpBuf = (char *)calloc(1, bufferCount)) == NULL) { VFREE(pBuf); return NULL; @@ -902,7 +902,7 @@ vmsg_decode( char *pMsgRaw ) if(!strncmp(szMsgBegin, "VMSG", strlen("VMSG"))) { - if ( ( pVMsg = ( VTree* )malloc( sizeof( VTree ) ) ) == NULL ) + if ( ( pVMsg = ( VTree* )calloc( 1, sizeof( VTree ) ) ) == NULL ) { start_status = 1; goto CATCH; @@ -918,7 +918,7 @@ vmsg_decode( char *pMsgRaw ) else if(!strncmp(szMsgBegin, "VBODY", strlen("VBODY"))) { - if ( ( pVBody = ( VTree* )malloc( sizeof( VTree ) ) ) == NULL ) + if ( ( pVBody = ( VTree* )calloc( 1, sizeof( VTree ) ) ) == NULL ) { start_status = 1; goto CATCH; @@ -965,7 +965,7 @@ vmsg_decode( char *pMsgRaw ) break; } - if ( ( pTemp = ( VObject* )malloc( sizeof( VObject ) ) ) == NULL ) + if ( ( pTemp = ( VObject* )calloc( 1, sizeof( VObject ) ) ) == NULL ) { goto CATCH; } @@ -998,7 +998,7 @@ vmsg_decode( char *pMsgRaw ) if ( param_status != true ) { - if ( ( pTmpParam = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL ) + if ( ( pTmpParam = ( VParam* )calloc( 1, sizeof( VParam ) ) ) == NULL ) goto CATCH; param_status = true; @@ -1008,7 +1008,7 @@ vmsg_decode( char *pMsgRaw ) } else { - if ( ( pTmpParam->pNext = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL ) + if ( ( pTmpParam->pNext = ( VParam* )calloc( 1, sizeof( VParam ) ) ) == NULL ) goto CATCH; pTmpParam = pTmpParam->pNext; @@ -1153,9 +1153,9 @@ vmsg_encode( VTree *pVMsgRaw ) pVMsgRes = NULL; } - if ( ( pVMsgRes = ( char * )malloc( sizeof( char ) * ( total += 13 ) ) ) == NULL ) + if ( ( pVMsgRes = ( char * )calloc( 1, sizeof( char ) * ( total += 13 ) ) ) == NULL ) { - VDATA_TRACE( "vmsg_encode:malloc failed\n" ); + VDATA_TRACE( "vmsg_encode:calloc failed\n" ); VDATA_TRACE_END return NULL; } @@ -1172,7 +1172,7 @@ vmsg_encode( VTree *pVMsgRaw ) } pVMsgRes = pTmpVMsgRes; - strncat( pVMsgRes, "BEGIN:VBODY\r\n", 13); + g_strlcat( pVMsgRes, "BEGIN:VBODY\r\n", 13); break; case VCARD: @@ -1212,7 +1212,7 @@ vmsg_encode( VTree *pVMsgRaw ) } pVMsgRes = pTmpVMsgRes; - strncat(pVMsgRes, encoded, len+10); + g_strlcat(pVMsgRes, encoded, len+10); VDATA_TRACE("pTemp : %s", encoded); VFREE( pTemp ); VFREE( encoded ); @@ -1231,7 +1231,7 @@ vmsg_encode( VTree *pVMsgRaw ) return NULL; } pVMsgRes = pTmpVMsgRes; - strncat(pVMsgRes, pTemp, len+10); + g_strlcat(pVMsgRes, pTemp, len+10); VDATA_TRACE("pTemp : %s", pTemp); VFREE( pTemp ); @@ -1256,7 +1256,7 @@ vmsg_encode( VTree *pVMsgRaw ) } pVMsgRes = pTmpVMsgRes; - strncat( pVMsgRes, "END:VBODY\r\n", 12); + g_strlcat( pVMsgRes, "END:VBODY\r\n", 12); break; case VCARD: @@ -1283,7 +1283,7 @@ vmsg_encode( VTree *pVMsgRaw ) } pVMsgRes = pTmpVMsgRes; - strncat( pVMsgRes, "END:VMSG\r\n", 11); + g_strlcat( pVMsgRes, "END:VMSG\r\n", 11); VDATA_TRACE_END return pVMsgRes; } @@ -1342,14 +1342,14 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) len = strlen( pType ); biLen = pTypeObj->numOfBiData; - if ( ( szTypeValue = ( char * )malloc( total += ( len+1 ) ) ) == NULL ) + if ( ( szTypeValue = ( char * )calloc( 1, total += ( len+1 ) ) ) == NULL ) { - VDATA_TRACE( "__VMsgTypeEncode():malloc failed\n"); + VDATA_TRACE( "__VMsgTypeEncode():calloc failed\n"); VDATA_TRACE_END return NULL; } memset( szTypeValue, '\0', ( len+1 ) ); - strncat( szTypeValue, pType, len+1); + g_strlcat( szTypeValue, pType, len+1); pTemp = __VMsgParamEncode( pTypeObj, &enc ); if ( pTemp != NULL ) @@ -1363,7 +1363,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) VDATA_TRACE_END; return NULL; } - strncat( szTypeValue, pTemp, len); + g_strlcat( szTypeValue, pTemp, len); VFREE( pTemp ); pTemp = NULL; } @@ -1374,7 +1374,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) return NULL; } - strncat( szTypeValue, ":", 2 ); + g_strlcat( szTypeValue, ":", 2 ); len = 0; @@ -1393,7 +1393,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) if ( i == 0 ) { - if ( ( pEncode = ( char * )malloc( len+20 ) ) == NULL ) + if ( ( pEncode = ( char * )calloc( 1, len+20 ) ) == NULL ) { VFREE(szTypeValue); VDATA_TRACE_END @@ -1404,7 +1404,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) if(strcmp(pType, pszMsgTypeList[6]) != 0) { - strncat( pEncode, pTypeObj->pszValue[i], 20 ); + g_strlcat( pEncode, pTypeObj->pszValue[i], 20 ); _VEscape(pEncode); } else @@ -1422,7 +1422,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) if(strcmp(pType, pszMsgTypeList[6]) != 0) { if (pEncode) { - strcat( pEncode, "\0\0" ); + g_strlcat( pEncode, "\0\0", 2); len = strlen( pEncode ); } } @@ -1431,7 +1431,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) } if ( enc & pMsgEncList[2].flag ) { - if((pRes = (char *)malloc(len * 6 + 10)) == NULL) { + if((pRes = (char *)calloc(1, len * 6 + 10)) == NULL) { VFREE(pEncode); VFREE(szTypeValue); VDATA_TRACE_END @@ -1443,7 +1443,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) } else if(enc & pMsgEncList[1].flag ) { - if((pRes = (char *)malloc((len * 8 / 6) + 48)) == NULL) + if((pRes = (char *)calloc(1, (len * 8 / 6) + 48)) == NULL) { VFREE(pEncode); VFREE(szTypeValue); @@ -1458,7 +1458,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) } else { - if((pRes = (char *)malloc(len+30)) == NULL) + if((pRes = (char *)calloc(1, len+30)) == NULL) { VFREE(pEncode); VFREE(szTypeValue); @@ -1480,7 +1480,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) VDATA_TRACE_END return NULL; } - strncat( pRes, "\r\n", strlen(pRes) + 2); + g_strlcat( pRes, "\r\n", strlen(pRes) + 2); len = strlen( pRes ); @@ -1491,7 +1491,7 @@ __VMsgTypeEncode( VObject *pTypeObj, char *pType ) return NULL; } - strncat(szTypeValue, pRes, total - 1); + g_strlcat(szTypeValue, pRes, total - 1); if(strcmp(pType, pszMsgTypeList[6]) != 0) { _VRLSpace( szTypeValue ); @@ -1528,7 +1528,7 @@ __VMsgParamEncode(VObject* pTypeObj, int* pEnc) /** Momory Allocation for parameter string. */ if(pTemp != NULL) { - if ((szParam = (char*)malloc(len+=2)) == NULL) + if ((szParam = (char*)calloc(1, len+=2)) == NULL) { VDATA_TRACE_END return NULL; @@ -1583,7 +1583,7 @@ __VMsgParamEncode(VObject* pTypeObj, int* pEnc) VDATA_TRACE_END return NULL; } - strcat( szParam, "NONE" ); + g_strlcat( szParam, "NONE", strlen("NONE")); } /** exchage parameter value's to string.*/ |