From: Seunghwan Lee Date: Thu, 22 Nov 2012 11:24:02 +0000 (+0900) Subject: merge with private about bug fix of MMS X-Git-Tag: submit/tizen_2.1/20130424.231644~14^2~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=001be70e2131ecc09c5a059625c8a0165b2602bd;p=platform%2Fcore%2Fmessaging%2Fmsg-service.git merge with private about bug fix of MMS --- diff --git a/framework/storage-handler/MsgStorageMessage.cpp b/framework/storage-handler/MsgStorageMessage.cpp index cd1d020..d8c27ff 100755 --- a/framework/storage-handler/MsgStorageMessage.cpp +++ b/framework/storage-handler/MsgStorageMessage.cpp @@ -1261,6 +1261,7 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) const char *tableList[] = {MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME, MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME, + MSGFW_MMS_PREVIEW_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME}; int listCnt = sizeof(tableList)/sizeof(char *); @@ -1378,20 +1379,36 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList) MsgRmRf(dirPath); rmdir(dirPath); - // delete thumbnail + } - char *fileName = NULL; - fileName = strrchr(filePath, '/'); + dbHandle.freeTable(); + } else if (!strcmp(tableList[i], MSGFW_MMS_PREVIEW_TABLE_NAME)) { + char filePath[MSG_FILEPATH_LEN_MAX] = {0,}; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT VALUE FROM %s " + "WHERE (TYPE=%d OR TYPE=%d) " + "AND ", + MSGFW_MMS_PREVIEW_TABLE_NAME, MSG_MMS_ITEM_TYPE_IMG, MSG_MMS_ITEM_TYPE_VIDEO); - snprintf(thumbnailPath, sizeof(thumbnailPath), MSG_THUMBNAIL_PATH"%s.jpg", fileName+1); + strncat(sqlQuery, whereQuery, MAX_QUERY_LEN-strlen(sqlQuery)); - if (remove(thumbnailPath) == -1) - MSG_DEBUG("Fail to delete thumbnail [%s]", thumbnailPath); + if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS) { + dbHandle.endTrans(false); + return MSG_ERR_DB_PREPARE; + } + + while (dbHandle.stepQuery() == MSG_ERR_DB_ROW) { + memset(filePath, 0x00, sizeof(filePath)); + + strncpy(filePath, (char *)dbHandle.columnText(0), MSG_FILEPATH_LEN_MAX); + if (remove(filePath) == -1) + MSG_DEBUG("Fail to delete file [%s]", filePath); else - MSG_DEBUG("Success to delete thumbnail [%s]", thumbnailPath); + MSG_DEBUG("Success to delete file [%s]", filePath); } - dbHandle.freeTable(); + dbHandle.finalizeQuery(); } memset(sqlQuery, 0x00, sizeof(sqlQuery)); @@ -1878,7 +1895,7 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M msg_error_t err = MSG_SUCCESS; MMS_MESSAGE_DATA_S mmsMsg; char *pDestMsg = NULL; - + int temp_size = pMsg->dataSize;//save raw file size; // call mms plugin to get mms specific message data MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(pMsg->msgType.mainType); memset(&mmsMsg, 0, sizeof(MMS_MESSAGE_DATA_S)); @@ -1924,6 +1941,8 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M pMsg->bTextSms = true; } + pMsg->dataSize = temp_size;//raw file size; + if (pDestMsg) { free(pDestMsg); pDestMsg = NULL; diff --git a/include/utils/MsgUtilFile.h b/include/utils/MsgUtilFile.h index 9d36330..b072cc1 100755 --- a/include/utils/MsgUtilFile.h +++ b/include/utils/MsgUtilFile.h @@ -57,7 +57,7 @@ int MsgRmRf(char *pDirPath); unsigned int MsgDu(const char *pDirPath); bool MsgAppendFile(const char *pFilePath, const char *pData, int DataSize); void MsgMmsInitDir(); - +bool MsgAccessFile(const char *filepath, int mode); #endif // MSG_UTIL_FILE_H diff --git a/include/utils/MsgUtilStorage.h b/include/utils/MsgUtilStorage.h index 65cce9a..50d51be 100755 --- a/include/utils/MsgUtilStorage.h +++ b/include/utils/MsgUtilStorage.h @@ -57,6 +57,6 @@ bool MsgStoCheckReadReportRequested(MsgDbHandler *pDbHandle, msg_message_id_t Ms 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); char *MsgStoReplaceString(const char *org_str, const char *old_str, const char *new_str); - +void MsgConvertNumber(const char* pSrcNum, char* pDestNum); #endif // MSG_UTIL_STORAGE_H diff --git a/plugin/mms_plugin/MmsPluginCodec.cpp b/plugin/mms_plugin/MmsPluginCodec.cpp index c55a5c1..173770e 100755 --- a/plugin/mms_plugin/MmsPluginCodec.cpp +++ b/plugin/mms_plugin/MmsPluginCodec.cpp @@ -623,3 +623,12 @@ bool _MmsSetVersion(int majorVer, int minorVer) return true; } +const char *MmsGetTextByCode(MmsCode i, UINT16 code) +{ + for (int j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) { + if (gMmsField[i][j].binary == code) { + return gMmsField[i][j].szText; + } + } + return NULL; +} diff --git a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp index d45e5b1..f0413a6 100755 --- a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp +++ b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp @@ -250,6 +250,7 @@ void MmsPluginCmAgent::close() } deregistration(); + isCmOpened = false; } else { MSG_DEBUG ("Network Connection is not opened."); return; diff --git a/plugin/mms_plugin/MmsPluginHttp.cpp b/plugin/mms_plugin/MmsPluginHttp.cpp index f37f8a3..a396728 100755 --- a/plugin/mms_plugin/MmsPluginHttp.cpp +++ b/plugin/mms_plugin/MmsPluginHttp.cpp @@ -22,7 +22,7 @@ #include static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *szHeaderBuffer); -static void __httpGetHost(char *szHost, int nBufferLen); +static void __httpGetHost(char *szUrl, char *szHost, int nBufferLen); static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int ulContentLen); static MMS_NET_ERROR_T __httpReceiveData(void *ptr, size_t size, size_t nmemb, void *userdata); @@ -114,28 +114,28 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int bool nResult = __httpGetHeaderField(MMS_HH_CONTENT_TYPE, szBuffer); if (nResult) { - strcat(pcheader,"Content-Type: "); - strcat(pcheader, szBuffer); + snprintf(pcheader, HTTP_REQUEST_LEN, "Content-Type: %s", szBuffer); MSG_DEBUG("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } - memset(szBuffer, 0, 1025); - memset(pcheader, 0, HTTP_REQUEST_LEN); - snprintf(szBuffer, 1024, "%d", ulContentLen); - if (nResult) { - strcat(pcheader, "Content-Length: "); - strcat(pcheader, szBuffer); - MSG_DEBUG("%s", pcheader); - *responseHeaders = curl_slist_append(*responseHeaders, pcheader); + if (ulContentLen > 0) { + memset(szBuffer, 0, 1025); + memset(pcheader, 0, HTTP_REQUEST_LEN); + snprintf(szBuffer, 1024, "%d", ulContentLen); + if (nResult) { + snprintf(pcheader, HTTP_REQUEST_LEN, "Content-Length: %s", szBuffer); + MSG_DEBUG("%s", pcheader); + *responseHeaders = curl_slist_append(*responseHeaders, pcheader); + } } memset(szBuffer, 0, 1025); memset(pcheader, 0, HTTP_REQUEST_LEN); - nResult = __httpGetHeaderField(MMS_HH_HOST, szBuffer); - if (nResult) { - strcat(pcheader, "HOST: "); - strcat(pcheader, szBuffer); + + __httpGetHost(szUrl, szBuffer, 1024); + if (strlen(szBuffer)){ + snprintf(pcheader, HTTP_REQUEST_LEN, "Host: %s", szBuffer); MSG_DEBUG("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } @@ -144,8 +144,7 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_ACCEPT, szBuffer); if (nResult) { - strcat(pcheader, "Accept: "); - strcat(pcheader, szBuffer); + snprintf(pcheader, HTTP_REQUEST_LEN, "Accept: %s", szBuffer); MSG_DEBUG("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } @@ -154,8 +153,7 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_ACCEPT_CHARSET, szBuffer); if (nResult) { - strcat(pcheader, "Accept-Charset: "); - strcat(pcheader, szBuffer); + snprintf(pcheader, HTTP_REQUEST_LEN, "Accept-Charset: %s", szBuffer); MSG_DEBUG("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } @@ -164,8 +162,7 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_ACCEPT_LANGUAGE, szBuffer); if (nResult) { - strcat(pcheader, "Accept-Language: "); - strcat(pcheader, szBuffer); + snprintf(pcheader, HTTP_REQUEST_LEN, "Accept-Language: %s", szBuffer); MSG_DEBUG("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } @@ -174,8 +171,7 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_USER_AGENT, szBuffer); if (nResult) { - strcat(pcheader, "User-Agent: "); - strcat(pcheader, szBuffer); + snprintf(pcheader, HTTP_REQUEST_LEN, "User-Agent: %s", szBuffer); MSG_DEBUG("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } @@ -184,11 +180,13 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int memset(pcheader, 0, HTTP_REQUEST_LEN); nResult = __httpGetHeaderField(MMS_HH_WAP_PROFILE, szBuffer); if (nResult) { - strcat(pcheader, "X-wap-profile: "); - strcat(pcheader, szBuffer); + snprintf(pcheader, HTTP_REQUEST_LEN, "X-wap-profile: %s", szBuffer); MSG_DEBUG("%s", pcheader); *responseHeaders = curl_slist_append(*responseHeaders, pcheader); } + + if (ulContentLen > 0)//if post transaction then Disable 'Expect: 100-contine' option + *responseHeaders = curl_slist_append(*responseHeaders, "Expect:"); } static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *szHeaderBuffer) @@ -203,14 +201,6 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s result = true; break; - case MMS_HH_HOST: - __httpGetHost(szHeaderBuffer, 1024); - if (strlen(szHeaderBuffer) > 0) - result = true; - else - result = false; - break; - case MMS_HH_ACCEPT: snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_ACCEPT); result = true; @@ -264,17 +254,17 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s return result; } -static void __httpGetHost(char *szHost, int nBufferLen) +static void __httpGetHost(char *szUrl, char *szHost, int nBufferLen) { - MmsPluginHttpAgent *pHttpAgent = MmsPluginHttpAgent::instance(); - MMS_PLUGIN_HTTP_DATA_S *httpConfigData = pHttpAgent->getHttpConfigData(); + if (szUrl == NULL || szHost == NULL) + return; const char *prefixString = "http://"; - const char *delim = ":/\\=@"; + const char *delim = "/\\=@"; int prefixLength = strlen(prefixString); - char *startPtr = &httpConfigData->mmscConfig.mmscUrl[0]; + char *startPtr = szUrl; char *movePtr = NULL; MSG_DEBUG("startPtr(%s)", startPtr); @@ -309,7 +299,6 @@ static void __httpGetHost(char *szHost, int nBufferLen) } } - static MMS_NET_ERROR_T __httpReceiveData(void *ptr, size_t size, size_t nmemb, void *userdata) { MMS_NET_ERROR_T httpRet = eMMS_UNKNOWN; @@ -592,10 +581,7 @@ int MmsPluginHttpAgent::setSession(mmsTranQEntity *qEntity) curl_slist *responseHeaders = NULL; - __httpAllocHeaderInfo(&responseHeaders, NULL, qEntity->postDataLen); - - //Disable 'Expect: 100-contine' option - responseHeaders = curl_slist_append(responseHeaders, "Expect:"); + __httpAllocHeaderInfo(&responseHeaders, httpConfigData.mmscConfig.mmscUrl, qEntity->postDataLen); MSG_DEBUG(" === MMSCURI = %s === ", httpConfigData.mmscConfig.mmscUrl); @@ -610,8 +596,8 @@ int MmsPluginHttpAgent::setSession(mmsTranQEntity *qEntity) curl_easy_setopt(httpConfigData.session, CURLOPT_POSTFIELDS, qEntity->pPostData); curl_easy_setopt(httpConfigData.session, CURLOPT_POSTFIELDSIZE, qEntity->postDataLen); curl_easy_setopt(httpConfigData.session, CURLOPT_WRITEFUNCTION, __httpPostTransactionCB); - curl_easy_setopt(httpConfigData.session, CURLOPT_TCP_NODELAY, 1); + } else if (qEntity->eHttpCmdType == eHTTP_CMD_GET_TRANSACTION) { MSG_DEBUG("MmsHttpInitTransactionGet %d pGetData (%s)", qEntity->getDataLen, qEntity->pGetData); MSG_DEBUG("MmsHttpInitTransactionGet mmscURL (%s) ", httpConfigData.mmscConfig.mmscUrl); @@ -624,7 +610,7 @@ int MmsPluginHttpAgent::setSession(mmsTranQEntity *qEntity) curl_slist *responseHeaders = NULL; - __httpAllocHeaderInfo(&responseHeaders, NULL, 0); + __httpAllocHeaderInfo(&responseHeaders, szUrl, 0); httpConfigData.sessionHeader = (void *)responseHeaders; diff --git a/plugin/mms_plugin/MmsPluginInternal.cpp b/plugin/mms_plugin/MmsPluginInternal.cpp index 724665a..e4c2dc9 100755 --- a/plugin/mms_plugin/MmsPluginInternal.cpp +++ b/plugin/mms_plugin/MmsPluginInternal.cpp @@ -310,7 +310,7 @@ void MmsPluginInternal::processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo) pMsgInfo->dataSize = strlen(pMsgInfo->msgData); MSG_DEBUG("read Status = %s", pMsgInfo->msgData); - strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN); + strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN); int tmpId = MmsSearchMsgId(mmsHeader.pFrom->szAddr, mmsHeader.szMsgID); if (tmpId > 0) { diff --git a/plugin/mms_plugin/MmsPluginMessage.cpp b/plugin/mms_plugin/MmsPluginMessage.cpp index 08132ea..b9e980a 100755 --- a/plugin/mms_plugin/MmsPluginMessage.cpp +++ b/plugin/mms_plugin/MmsPluginMessage.cpp @@ -1212,6 +1212,56 @@ bool MmsCheckAdditionalMedia(MMS_MESSAGE_DATA_S *pMsgData, MsgType *partHeader) return true; } +/*PIM objects SHALL be supported as attachments to an MM*/ +bool MmsRemovePims(MMS_MESSAGE_DATA_S *pMsgData) +{ + GList *cur_page = NULL; + GList *cur_media = NULL; + + if (pMsgData == NULL) + return false; + + cur_page = pMsgData->pagelist; + + while(cur_page) { + MMS_PAGE_S *page = (MMS_PAGE_S *)cur_page->data; + if (page) { + cur_media = page->medialist; + + while(cur_media) { + MMS_MEDIA_S *pMedia = (MMS_MEDIA_S *)cur_media->data; + if (pMedia) { + int tempType; + MsgGetTypeByFileName(&tempType, pMedia->szFilePath); + if (tempType == MIME_TEXT_X_VCALENDAR || tempType == MIME_TEXT_X_VCARD) { + page->medialist = g_list_remove_all(page->medialist, pMedia); + page->mediaCnt = g_list_length(page->medialist); + cur_media = page->medialist; + free(pMedia); + } else { + cur_media = g_list_next(cur_media); + } + } else { + cur_media = g_list_next(cur_media); + } + } //cur_media while for remove pims file in list + + if (page->medialist == NULL) {//remove empty page + pMsgData->pagelist = g_list_remove_all(pMsgData->pagelist, page); + pMsgData->pageCnt = g_list_length(pMsgData->pagelist); + cur_page = pMsgData->pagelist; + free(page); + } else { + cur_page = g_list_next(cur_page); + } + } + }//cur_page while + + + return true; +} + + #ifdef __SUPPORT_DRM__ bool __MsgInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo) { diff --git a/plugin/mms_plugin/MmsPluginStorage.cpp b/plugin/mms_plugin/MmsPluginStorage.cpp index a4431a9..57ba4bc 100755 --- a/plugin/mms_plugin/MmsPluginStorage.cpp +++ b/plugin/mms_plugin/MmsPluginStorage.cpp @@ -549,6 +549,7 @@ msg_error_t MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN } MmsSmilParseSmilDoc(pMmsMsg, pSmilDoc); + MmsRemovePims(pMmsMsg); bMultipartRelated = true; } @@ -624,6 +625,7 @@ FREE_CATCH: } L_CATCH: + MSG_END(); { MmsMsg *pMsg; MmsPluginStorage::instance()->getMmsMessage(&pMsg); @@ -637,7 +639,6 @@ L_CATCH: return MSG_ERR_STORAGE_ERROR; } - MSG_END(); } @@ -1374,6 +1375,7 @@ FREE_CATCH: } L_CATCH: + MSG_END(); { MmsMsg *pMsg; MmsPluginStorage::instance()->getMmsMessage(&pMsg); @@ -1387,7 +1389,6 @@ L_CATCH: return MSG_ERR_STORAGE_ERROR; } - MSG_END(); } /* This API is not used anywhere now */ diff --git a/plugin/mms_plugin/MmsPluginUserAgent.cpp b/plugin/mms_plugin/MmsPluginUserAgent.cpp index 15c61af..0f60d01 100755 --- a/plugin/mms_plugin/MmsPluginUserAgent.cpp +++ b/plugin/mms_plugin/MmsPluginUserAgent.cpp @@ -171,14 +171,12 @@ void updatePduType(mmsTranQEntity *qEntity) case eMMS_MBOX_DELETE_REQ: qEntity->eMmsPduType = eMMS_MBOX_DELETE_CONF; break; - - MSG_DEBUG("Update PDU Type:"); - PRINT_PDU_TYPE(qEntity->eMmsPduType); - default: break; } + MSG_DEBUG("Update PDU Type:"); + PRINT_PDU_TYPE(qEntity->eMmsPduType); } MmsPluginUaManager *MmsPluginUaManager::pInstance = NULL; diff --git a/plugin/mms_plugin/include/MmsPluginCodec.h b/plugin/mms_plugin/include/MmsPluginCodec.h index ebd8cca..0aaa4a0 100755 --- a/plugin/mms_plugin/include/MmsPluginCodec.h +++ b/plugin/mms_plugin/include/MmsPluginCodec.h @@ -241,6 +241,7 @@ UINT16 _MmsGetBinaryValue(MmsCode i, int j); int _MmsGetBinaryType(MmsCode i, UINT16 value); UINT8 _MmsGetVersion(MmsMsg *pMsg); bool _MmsSetVersion(int majorVer, int minorVer); +const char *MmsGetTextByCode(MmsCode i, UINT16 code); /* Decoding */ diff --git a/plugin/mms_plugin/include/MmsPluginMessage.h b/plugin/mms_plugin/include/MmsPluginMessage.h index 5f2f61a..ff0abf9 100755 --- a/plugin/mms_plugin/include/MmsPluginMessage.h +++ b/plugin/mms_plugin/include/MmsPluginMessage.h @@ -542,6 +542,7 @@ int MmsSearchMsgId(char *toNumber, char *szMsgID); MsgMultipart *MmsAllocMultipart(void); msg_error_t MmsAddAttachment(MMS_MESSAGE_DATA_S *pMsgData, MMS_MEDIA_S *pMedia); bool MmsCheckAdditionalMedia(MMS_MESSAGE_DATA_S *pMsgData, MsgType *partHeader); +bool MmsRemovePims(MMS_MESSAGE_DATA_S *pMsgData); #ifdef __SUPPORT_DRM__ bool __MsgInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo); #endif diff --git a/utils/MsgNotificationWrapper.cpp b/utils/MsgNotificationWrapper.cpp index 6b8c534..c5a1c6a 100755 --- a/utils/MsgNotificationWrapper.cpp +++ b/utils/MsgNotificationWrapper.cpp @@ -17,6 +17,7 @@ #include "MsgDebug.h" #include "MsgContact.h" #include "MsgStorageTypes.h" +#include "MsgUtilStorage.h" #include "MsgNotificationWrapper.h" extern "C" @@ -486,18 +487,35 @@ msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S MSG_ADDRESS_INFO_S *address_info_s = &pMsg->addressList[0]; MSG_DEBUG("address info : %s, type : %d", address_info_s->addressVal, address_info_s->addressType); - if (address_info_s->addressType == MSG_ADDRESS_TYPE_PLMN) {//FIXME: compare 10 char of address - snprintf(sqlQuery, sizeof(sqlQuery), - "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS " - "FROM %s A, %s B " - "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE \'%s\';" - , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal); + if (address_info_s->addressType == MSG_ADDRESS_TYPE_PLMN) { + + if (strlen(address_info_s->addressVal) > MAX_PRECONFIG_NUM) { + char newPhoneNum[MAX_PRECONFIG_NUM+1]; + + memset(newPhoneNum, 0x00, sizeof(newPhoneNum)); + + MsgConvertNumber(address_info_s->addressVal, newPhoneNum); + + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS " + "FROM %s A, %s B " + "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE '%%%s' AND B.ADDRESS_VAL LIKE \'%%%s\';" + , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, newPhoneNum, newPhoneNum); + } else { + + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS " + "FROM %s A, %s B " + "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE '%s' AND B.ADDRESS_VAL LIKE '%s';" + , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal, address_info_s->addressVal); + } + } else if (address_info_s->addressType == MSG_ADDRESS_TYPE_EMAIL) {//check full snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS " "FROM %s A, %s B " - "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL=\'%s\';" - , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal); + "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL=\'%s\' AND B.ADDRESS_VAL LIKE \'%s\';" + , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal, address_info_s->addressVal); } else { snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS " @@ -553,7 +571,7 @@ msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S } report_status_value = pDbHandle->columnInt(4); - + MSG_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value); } else { MSG_DEBUG("DB Query Result Fail"); pDbHandle->finalizeQuery(); diff --git a/utils/MsgUtilFile.cpp b/utils/MsgUtilFile.cpp index e64ee27..499ac32 100755 --- a/utils/MsgUtilFile.cpp +++ b/utils/MsgUtilFile.cpp @@ -905,3 +905,25 @@ void MsgMmsInitDir() closedir(dir); } + +//mode : R_OK, W_OK, X_OK, or the existence test F_OK. +bool MsgAccessFile(const char *filepath, int mode) +{ + int ret; + if (filepath == NULL) { + MSG_DEBUG("filepath is NULL"); + return false; + } + + MSG_DEBUG("request access path = %s, mode = %d", filepath, mode); + + ret = access(filepath, mode); + + + if (ret) { + MSG_DEBUG("Fail to access file, ret = %d", ret); + return false; + } + + return true; +}