From 2c089e51bde847c66cfc0a2582cfda46f52b1aa4 Mon Sep 17 00:00:00 2001 From: Kyeonghun Lee Date: Tue, 1 Dec 2015 13:29:13 +0900 Subject: [PATCH] add code for to/cc feature Change-Id: Ib0c2f36ae97533e4d9edafe12e7a8492a706a69f Signed-off-by: Kyeonghun Lee --- externals/MsgNotificationWrapper.cpp | 4 +- framework/storage-handler/MsgStorageMms.cpp | 225 +++++++++++---------- .../transaction-manager/MsgCmdHandlerTransport.cpp | 67 +++--- include/utils/MsgUtilStorage.h | 2 + plugin/mms_plugin/MmsPluginDecode.cpp | 2 + plugin/mms_plugin/MmsPluginEventHandler.cpp | 8 +- plugin/mms_plugin/MmsPluginInternal.cpp | 106 +++++++++- utils/MsgUtilStorage.cpp | 30 ++- 8 files changed, 292 insertions(+), 152 deletions(-) diff --git a/externals/MsgNotificationWrapper.cpp b/externals/MsgNotificationWrapper.cpp index 8011813..aaa3bff 100755 --- a/externals/MsgNotificationWrapper.cpp +++ b/externals/MsgNotificationWrapper.cpp @@ -2460,8 +2460,8 @@ msg_error_t getLatestMsgInfo(MSG_NOTI_INFO_S *noti_info, bool isForInstantMessag "B.SUBJECT, " "B.MSG_TEXT, " "B.MAIN_TYPE, " - "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, " - "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT, " + "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, " + "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, " "(CASE WHEN B.MAIN_TYPE = %d AND B.NETWORK_STATUS = %d THEN (SELECT C.MSG_SIZE FROM %s C WHERE B.MSG_ID = C.MSG_ID) ELSE -1 END) " "FROM %s A, %s B " "WHERE A.CONV_ID=B.CONV_ID " diff --git a/framework/storage-handler/MsgStorageMms.cpp b/framework/storage-handler/MsgStorageMms.cpp index 82ce2d7..1da8154 100755 --- a/framework/storage-handler/MsgStorageMms.cpp +++ b/framework/storage-handler/MsgStorageMms.cpp @@ -178,143 +178,166 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg) * So adding code for comparing exist address and new address and replace with new address(MMSconf) address */ if(pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { - if (pMsg->nAddressCnt == 1 && pMsg->addressList) { - char tmpAddressVal[MAX_ADDRESS_VAL_LEN+1] = {0,}; - msg_address_type_t tmpAddressType; - msg_recipient_type_t tmpRecipientType; - int tmpConvId; - - //compare stored address and currnt address - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " - "A.CONV_ID, " - "A.ADDRESS_TYPE, " - "A.RECIPIENT_TYPE, " - "A.ADDRESS_VAL " - "FROM %s A, %s B " - "WHERE A.CONV_ID = B.CONV_ID " - "AND B.MSG_ID = %d;", - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - pMsg->msgId); - - MSG_DEBUG("[%s]", sqlQuery); + if (pMsg->addressList) { + if (pMsg->nAddressCnt == 1) { + char tmpAddressVal[MAX_ADDRESS_VAL_LEN+1] = {0,}; + msg_address_type_t tmpAddressType; + msg_recipient_type_t tmpRecipientType; + int tmpConvId; + + /* compare stored address and currnt address */ + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " + "A.CONV_ID, " + "A.ADDRESS_TYPE, " + "A.RECIPIENT_TYPE, " + "A.ADDRESS_VAL " + "FROM %s A, %s B " + "WHERE A.CONV_ID = B.CONV_ID " + "AND B.MSG_ID = %d;", + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + pMsg->msgId); + + MSG_DEBUG("[%s]", sqlQuery); + + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_PREPARE; + } - if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { - return MSG_ERR_DB_PREPARE; - } + err = dbHandle->stepQuery(); - err = dbHandle->stepQuery(); + if (err == MSG_ERR_DB_ROW) { + tmpConvId = dbHandle->columnInt(0); + tmpAddressType = dbHandle->columnInt(1); + tmpRecipientType = dbHandle->columnInt(2); + strncpy(tmpAddressVal, (char*)dbHandle->columnText(3), MAX_ADDRESS_VAL_LEN); - if (err == MSG_ERR_DB_ROW) { - tmpConvId = dbHandle->columnInt(0); - tmpAddressType = dbHandle->columnInt(1); - tmpRecipientType = dbHandle->columnInt(2); - strncpy(tmpAddressVal, (char*)dbHandle->columnText(3), MAX_ADDRESS_VAL_LEN); + dbHandle->finalizeQuery(); - dbHandle->finalizeQuery(); + /* compare stored addressList and current addressList */ + if (tmpAddressType != pMsg->addressList->addressType || + tmpRecipientType != pMsg->addressList->recipientType || + (strncmp(tmpAddressVal, pMsg->addressList->addressVal, MAX_ADDRESS_VAL_LEN) != 0)) { - //compare stored addressList and current addressList - if (tmpAddressType != pMsg->addressList->addressType || - tmpRecipientType != pMsg->addressList->recipientType || - (strncmp(tmpAddressVal, pMsg->addressList->addressVal, MAX_ADDRESS_VAL_LEN) != 0)) { + MSG_WARN("AddressList of NotiInd and MMSConf are different!!, Replace AddressList to MMSConf data"); + MSG_WARN("AddType [NotiInd : %d], [MMSConf : %d]", tmpAddressType, pMsg->addressList->addressType); + MSG_WARN("RcptType [NotiInd : %d], [MMSConf : %d]", tmpRecipientType, pMsg->addressList->recipientType); + MSG_SEC_INFO("AddressVal [NotiInd : %s], [MMSConf : %s]", tmpAddressVal, pMsg->addressList->addressVal); - MSG_WARN("AddressList of NotiInd and MMSConf are different!!, Replace AddressList to MMSConf data"); - MSG_WARN("AddType [NotiInd : %d], [MMSConf : %d]", tmpAddressType, pMsg->addressList->addressType); - MSG_WARN("RcptType [NotiInd : %d], [MMSConf : %d]", tmpRecipientType, pMsg->addressList->recipientType); - MSG_SEC_INFO("AddressVal [NotiInd : %s], [MMSConf : %s]", tmpAddressVal, pMsg->addressList->addressVal); + /* If MMSConf AddressList is already exist, Replace exist ConvId with matching msgId */ + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - // If MMSConf AddressList is already exist, Replace exist ConvId with matching msgId - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "SELECT CONV_ID FROM %s WHERE ADDRESS_VAL = '%s'", + MSGFW_ADDRESS_TABLE_NAME, pMsg->addressList->addressVal); - snprintf(sqlQuery, sizeof(sqlQuery), - "SELECT CONV_ID FROM %s WHERE ADDRESS_VAL = '%s'", - MSGFW_ADDRESS_TABLE_NAME, pMsg->addressList->addressVal); + MSG_DEBUG("[%s]", sqlQuery); - MSG_DEBUG("[%s]", sqlQuery); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_PREPARE; + } - if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { - return MSG_ERR_DB_PREPARE; - } + err = dbHandle->stepQuery(); - err = dbHandle->stepQuery(); + if (err == MSG_ERR_DB_ROW) { + tmpConvId = dbHandle->columnInt(0); - if (err == MSG_ERR_DB_ROW) { - tmpConvId = dbHandle->columnInt(0); + dbHandle->finalizeQuery(); - dbHandle->finalizeQuery(); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "UPDATE %s SET CONV_ID = %d WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, tmpConvId, pMsg->msgId); - snprintf(sqlQuery, sizeof(sqlQuery), - "UPDATE %s SET CONV_ID = %d WHERE MSG_ID = %d;", - MSGFW_MESSAGE_TABLE_NAME, tmpConvId, pMsg->msgId); + MSG_DEBUG("[%s]", sqlQuery); - MSG_DEBUG("[%s]", sqlQuery); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_PREPARE; + } - if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { - return MSG_ERR_DB_PREPARE; - } + err = dbHandle->stepQuery(); - err = dbHandle->stepQuery(); + if (err != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + MSG_ERR("Replacing CONV_ID with exist one. Fail."); + return MSG_ERR_DB_STEP; + } - if (err != MSG_ERR_DB_DONE) { dbHandle->finalizeQuery(); - MSG_ERR("Replacing CONV_ID with exist one. Fail."); - return MSG_ERR_DB_STEP; - } + } else { + dbHandle->finalizeQuery(); - dbHandle->finalizeQuery(); - } else { - dbHandle->finalizeQuery(); + memset(sqlQuery, 0x00, sizeof(sqlQuery)); - memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "UPDATE %s SET ADDRESS_TYPE = %d, RECIPIENT_TYPE = %d, ADDRESS_VAL = '%s' WHERE CONV_ID = %d;", + MSGFW_ADDRESS_TABLE_NAME, pMsg->addressList->addressType, pMsg->addressList->recipientType, pMsg->addressList->addressVal, tmpConvId); - snprintf(sqlQuery, sizeof(sqlQuery), - "UPDATE %s SET ADDRESS_TYPE = %d, RECIPIENT_TYPE = %d, ADDRESS_VAL = '%s' WHERE CONV_ID = %d;", - MSGFW_ADDRESS_TABLE_NAME, pMsg->addressList->addressType, pMsg->addressList->recipientType, pMsg->addressList->addressVal, tmpConvId); + MSG_DEBUG("[%s]", sqlQuery); - MSG_DEBUG("[%s]", sqlQuery); + if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { + return MSG_ERR_DB_PREPARE; + } - if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) { - return MSG_ERR_DB_PREPARE; - } + err = dbHandle->stepQuery(); - err = dbHandle->stepQuery(); + if (err != MSG_ERR_DB_DONE) { + dbHandle->finalizeQuery(); + MSG_ERR("Replacing Address with MMSConf Address. Fail."); + return MSG_ERR_DB_STEP; + } - if (err != MSG_ERR_DB_DONE) { dbHandle->finalizeQuery(); - MSG_ERR("Replacing Address with MMSConf Address. Fail."); - return MSG_ERR_DB_STEP; } + } + } else { + dbHandle->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + } else if (pMsg->nAddressCnt > 1) { + msg_thread_id_t conv_id = 0; + msg_thread_id_t prev_conv_id = MsgGetThreadId(dbHandle, pMsg->msgId); + + err = MsgStoAddAddress(dbHandle, pMsg, &conv_id); + if (err != MSG_SUCCESS) { + MSG_ERR("MsgStoAddAddress is failed"); + return err; + } + pMsg->threadId = conv_id; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), + "UPDATE %s SET CONV_ID = %d WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, conv_id, pMsg->msgId); + + err = dbHandle->execQuery(sqlQuery); + if (err != MSG_SUCCESS) { + MSG_ERR("execQuery is failed"); + return err; + } + + MSG_DEBUG("prev_conv_id[%d] conv_id[%d]", prev_conv_id, conv_id); + if (prev_conv_id != 0 && prev_conv_id != conv_id) { + if (MsgStoUpdateConversation(dbHandle, prev_conv_id) != MSG_SUCCESS) { + MSG_DEBUG("MsgStoUpdateConversation() Error"); + return MSG_ERR_STORAGE_ERROR; + } - dbHandle->finalizeQuery(); + if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { + MSG_DEBUG("MsgStoClearConversationTable() Error"); } } - } else { - dbHandle->finalizeQuery(); - return MSG_ERR_DB_STEP; } } } - msg_thread_id_t convId = 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, &rowCnt, NULL) != MSG_SUCCESS) { - dbHandle->freeTable(); - return MSG_ERR_DB_PREPARE; - } + msg_thread_id_t convId = MsgGetThreadId(dbHandle, pMsg->msgId); - if (rowCnt > 0) { - convId = dbHandle->getColumnToInt(1); + MSG_DEBUG("Conversation id:[%d]", convId); - MSG_DEBUG("Conversation id:[%d]", convId); + if (convId > 0) { if (MsgStoUpdateConversation(dbHandle, convId) != MSG_SUCCESS) { MSG_DEBUG("MsgStoUpdateConversation() Error"); @@ -326,14 +349,10 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg) if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) { MSG_DEBUG("MsgStoClearConversationTable() Error"); } - } else { - dbHandle->freeTable(); return MSG_ERR_DB_STEP; } - dbHandle->freeTable(); - MSG_END(); return MSG_SUCCESS; diff --git a/framework/transaction-manager/MsgCmdHandlerTransport.cpp b/framework/transaction-manager/MsgCmdHandlerTransport.cpp index 868f410..890ecf8 100755 --- a/framework/transaction-manager/MsgCmdHandlerTransport.cpp +++ b/framework/transaction-manager/MsgCmdHandlerTransport.cpp @@ -560,7 +560,7 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) MSG_DEBUG(" pMsg = %s, pReqId = %d ", msgInfo.msgData, reqID); MSG_DEBUG(" msgtype subtype is [%d]", msgInfo.msgType.subType); - // For Storage change callback + /* For Storage change callback */ msg_id_list_s msgIdList; msg_message_id_t msgIds[1]; memset(&msgIdList, 0x00, sizeof(msg_id_list_s)); @@ -569,38 +569,33 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) msgIds[0] = msgInfo.msgId; msgIdList.msgIdList = msgIds; - MSG_ADDRESS_INFO_S *tmpAddr = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; - memset(tmpAddr, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - - err = MsgStoGetAddrInfo(msgInfo.msgId, tmpAddr); - if (err == MSG_SUCCESS) { - MSG_DEBUG("MmsStoGetAddrInfo() success."); - msgInfo.nAddressCnt = 1; - } else { - msgInfo.nAddressCnt = 0; - MSG_DEBUG("MmsStoGetAddrInfo() fail."); + MsgDbHandler *dbHandle = getDbHandle(); + int tmpAddrCnt = 0; + MSG_ADDRESS_INFO_S *tmpAddr = NULL; + int order = MsgGetContactNameOrder(); + err = MsgStoGetAddressByMsgId(dbHandle, msgInfo.msgId, order, &tmpAddrCnt, &tmpAddr); + if (err != MSG_SUCCESS) { + MSG_DEBUG("MsgStoGetAddressByMsgId() fail."); } if (msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { + if (msgInfo.networkStatus != MSG_NETWORK_RETRIEVE_SUCCESS) { + if (msgInfo.addressList) { + delete[] msgInfo.addressList; + msgInfo.addressList = NULL; + } - /* PLM P141008-05143 & P150710-01521 : Notification.Ind address and MMS retreived Conf address are different. - Replace Notification.Ind address with MMS retreived Conf address if and only if MMS retreived Conf address is a valid address not junk*/ - if (msgInfo.nAddressCnt == 1 && msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS && MsgIsNumber(msgInfo.addressList[0].addressVal) - && strlen(msgInfo.addressList[0].addressVal) >= (unsigned int)MsgContactGetMinMatchDigit() && msgInfo.addressList[0].addressType != MSG_ADDRESS_TYPE_EMAIL - && (g_strcmp0(tmpAddr->addressVal, msgInfo.addressList[0].addressVal) != 0)) { - MSG_WARN("Address of NotiInd and MMSConf are different!!, Replace [NotiInd address: %s] from [MMSConf address: %s]", tmpAddr->addressVal, msgInfo.addressList[0].addressVal); - memset(tmpAddr->addressVal, 0x00, MAX_ADDRESS_VAL_LEN); - strncpy(tmpAddr->addressVal, msgInfo.addressList[0].addressVal, MAX_ADDRESS_VAL_LEN); - } - - if (msgInfo.addressList) { - delete[] msgInfo.addressList; - msgInfo.addressList = NULL; + msgInfo.addressList = tmpAddr; + msgInfo.nAddressCnt = tmpAddrCnt; + } else { + if (tmpAddr) { + delete [] tmpAddr; + tmpAddr = NULL; + } } - msgInfo.addressList = tmpAddr; - - MSG_SUB_TYPE_T recv_sub_type = msgInfo.msgType.subType; // Check retrieve mode to determine broadcast type + msg_thread_id_t prev_conv_id = MsgGetThreadId(dbHandle, msgInfo.msgId); + MSG_SUB_TYPE_T recv_sub_type = msgInfo.msgType.subType; /* Check retrieve mode to determine broadcast type */ err = MsgHandleMmsConfIncomingMsg(&msgInfo, reqID); @@ -619,14 +614,21 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) memset(msgInfo.msgData, 0x00, sizeof(MMS_RECV_DATA_S)); } - // broadcast to listener threads, here + /* broadcast to listener threads, here */ MsgTransactionManager::instance()->broadcastMMSConfCB(msgInfo.networkStatus, &msgInfo, pMmsRecvData); - // determine broadcast type with retrieve mode - if (recv_sub_type == MSG_RETRIEVE_AUTOCONF_MMS) + /* determine broadcast type with retrieve mode */ + if (recv_sub_type == MSG_RETRIEVE_AUTOCONF_MMS) { MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList); - else - MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + } else { + if (prev_conv_id == msgInfo.threadId + || msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_FAIL || msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_PENDING) { + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList); + } else { + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList); + MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList); + } + } // make return event eventsize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MMS_CONF, MSG_SUCCESS, (void**)ppEvent); @@ -638,6 +640,7 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) } msgInfo.addressList = tmpAddr; + msgInfo.nAddressCnt = tmpAddrCnt; MSG_PROXY_INFO_S* prxInfo = MsgTransactionManager::instance()->getProxyInfo(reqID); diff --git a/include/utils/MsgUtilStorage.h b/include/utils/MsgUtilStorage.h index cb2cf0e..01a57ef 100755 --- a/include/utils/MsgUtilStorage.h +++ b/include/utils/MsgUtilStorage.h @@ -60,6 +60,8 @@ msg_error_t MsgStoSetConversationDisplayName(MsgDbHandler *pDbHandle, int contac msg_error_t MsgStoSetConversationDisplayName(MsgDbHandler *pDbHandle, msg_thread_id_t convId); msg_error_t MsgStoClearConversationTable(MsgDbHandler *pDbHandle); +msg_thread_id_t MsgGetThreadId(MsgDbHandler *pDbHandle, msg_message_id_t msgId); + #ifdef FEATURE_SMS_CDMA msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel); msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel); diff --git a/plugin/mms_plugin/MmsPluginDecode.cpp b/plugin/mms_plugin/MmsPluginDecode.cpp index 73c0f85..785b85f 100755 --- a/plugin/mms_plugin/MmsPluginDecode.cpp +++ b/plugin/mms_plugin/MmsPluginDecode.cpp @@ -6157,6 +6157,8 @@ void MmsPluginDecoder::decodeMmsPdu(MmsMsg *pMsg, msg_message_id_t msgID, const pMsg->mmsAttrib.bAskReadReply = true; } + /* TODO : fill pMsg->mmsAttrib.szCc and pMsg->mmsAttrib.szTo field */ + snprintf(pMsg->mmsAttrib.szSubject, sizeof(pMsg->mmsAttrib.szSubject), "%s", mmsHeader.szSubject); snprintf(pMsg->szTrID, sizeof(pMsg->szTrID), "%s", mmsHeader.szTrID); diff --git a/plugin/mms_plugin/MmsPluginEventHandler.cpp b/plugin/mms_plugin/MmsPluginEventHandler.cpp index 0a4893d..4df7231 100755 --- a/plugin/mms_plugin/MmsPluginEventHandler.cpp +++ b/plugin/mms_plugin/MmsPluginEventHandler.cpp @@ -130,6 +130,7 @@ TapiHandle *MmsPluginEventHandler::getTelHandle(int sim_idx) void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char *pRetrievedFilePath) { MSG_MESSAGE_INFO_S msgInfo = {0,}; + msgInfo.sim_idx = pRequest->simId; switch (pRequest->eMmsPduType) { /* received data is send-conf */ @@ -146,14 +147,13 @@ void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char /* received data is retrieve-conf */ case eMMS_RETRIEVE_AUTO_CONF: case eMMS_RETRIEVE_MANUAL_CONF: - MSG_ADDRESS_INFO_S addrInfo; - memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - msgInfo.addressList = &addrInfo; - MmsPluginInternal::instance()->processRetrieveConf(&msgInfo, pRequest, pRetrievedFilePath); /* callback to MSG FW */ listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID); + + if (msgInfo.addressList) + delete [] msgInfo.addressList; break; case eMMS_FORWARD_CONF: diff --git a/plugin/mms_plugin/MmsPluginInternal.cpp b/plugin/mms_plugin/MmsPluginInternal.cpp index e704e72..c3337af 100755 --- a/plugin/mms_plugin/MmsPluginInternal.cpp +++ b/plugin/mms_plugin/MmsPluginInternal.cpp @@ -28,6 +28,7 @@ #include "MsgSerialize.h" #include "MsgSpamFilter.h" #include "MsgUtilMime.h" +#include "MsgUtilFunction.h" #include "MmsPluginDebug.h" #include "MmsPluginTypes.h" @@ -584,9 +585,105 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, pMsgInfo->sim_idx); char *msisdn = MsgSettingGetString(keyName); + char *normal_msisdn = NULL; + if (msisdn) + normal_msisdn = msg_normalize_number(msisdn); - if (mmsHeader.pFrom) + /* get setting value of group message */ + bool is_group_on = false; + + if (is_group_on) { + int addr_cnt = 0; + MsgHeaderAddress *iter = NULL; + + iter = mmsHeader.pFrom; + while (iter) { + addr_cnt++; + iter = iter->pNext; + } + + iter = mmsHeader.pTo; + while (iter) { + if (normal_msisdn == NULL || !g_str_has_suffix(iter->szAddr, normal_msisdn)) + addr_cnt++; + iter = iter->pNext; + } + + iter = mmsHeader.pCc; + while (iter) { + if (normal_msisdn == NULL || !g_str_has_suffix(iter->szAddr, normal_msisdn)) + addr_cnt++; + iter = iter->pNext; + } + + MSG_ADDRESS_INFO_S *tmp_addr_info = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)*addr_cnt]; + memset(tmp_addr_info, 0x00, sizeof(MSG_ADDRESS_INFO_S)*addr_cnt); + if (mmsHeader.pFrom == NULL) { + strncpy(tmp_addr_info[0].addressVal, pMsgInfo->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN); + } + + pMsgInfo->nAddressCnt = addr_cnt; + pMsgInfo->addressList = tmp_addr_info; + } else { + pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; + memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + pMsgInfo->nAddressCnt = 1; + } + + if (mmsHeader.pFrom) { + MSG_DEBUG("FROM : [%s]", mmsHeader.pFrom->szAddr); MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr); + /* From */ + strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN); + if (MmsAddrUtilCheckEmailAddress(pMsgInfo->addressList[0].addressVal)) { + pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_EMAIL; + } + } + + if (is_group_on) { + int addr_idx = 0; + if (mmsHeader.pTo) { + MsgHeaderAddress *iter = mmsHeader.pTo; + while (iter) { + addr_idx++; + MSG_DEBUG("TO : [%s]", mmsHeader.pTo->szAddr); + MmsAddrUtilRemovePlmnString(iter->szAddr); + /* To */ + if (normal_msisdn == NULL || !g_str_has_suffix(iter->szAddr, normal_msisdn)) { + strncpy(pMsgInfo->addressList[addr_idx].addressVal, iter->szAddr, MAX_ADDRESS_VAL_LEN); + pMsgInfo->addressList[addr_idx].recipientType = MSG_RECIPIENTS_TYPE_TO; + if (MmsAddrUtilCheckEmailAddress(pMsgInfo->addressList[addr_idx].addressVal)) { + pMsgInfo->addressList[addr_idx].addressType = MSG_ADDRESS_TYPE_EMAIL; + } + } else { + addr_idx--; + } + + iter = iter->pNext; + } + } + + if (mmsHeader.pCc) { + MsgHeaderAddress *iter = mmsHeader.pCc; + while (iter) { + addr_idx++; + MSG_DEBUG("CC : [%s]", mmsHeader.pCc->szAddr); + MmsAddrUtilRemovePlmnString(iter->szAddr); + /* Cc */ + if (normal_msisdn == NULL || !g_str_has_suffix(iter->szAddr, normal_msisdn)) { + strncpy(pMsgInfo->addressList[addr_idx].addressVal, iter->szAddr, MAX_ADDRESS_VAL_LEN); + pMsgInfo->addressList[addr_idx].recipientType = MSG_RECIPIENTS_TYPE_CC; + if (MmsAddrUtilCheckEmailAddress(pMsgInfo->addressList[addr_idx].addressVal)) { + pMsgInfo->addressList[addr_idx].addressType = MSG_ADDRESS_TYPE_EMAIL; + } + } else { + addr_idx--; + } + + iter = iter->pNext; + } + } + } MSG_SEC_DEBUG("%d, MMS Receive %s End %s->%s %s", pMsgInfo->msgId , (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF)?"Auto":"Manual" @@ -594,13 +691,6 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra , (msisdn == NULL)?"ME":msisdn , (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS)?"Success":"Fail"); - /* PLM P141008-05143 : Notification.Ind address is 1, but MMS retreived Conf address is correct. - So adding correct address to addressList buf to compare address in DB while MsgStoUpdateMMSMessage */ - if (mmsHeader.pFrom) { - pMsgInfo->nAddressCnt = 1; - strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN); - } - if (msisdn) { free(msisdn); msisdn = NULL; diff --git a/utils/MsgUtilStorage.cpp b/utils/MsgUtilStorage.cpp index 37135e1..c424c99 100755 --- a/utils/MsgUtilStorage.cpp +++ b/utils/MsgUtilStorage.cpp @@ -379,7 +379,7 @@ msg_error_t MsgStoAddAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S * *pConvId = 0; - if(pMsg->threadId) + if (pMsg->threadId) *pConvId = pMsg->threadId; /* conversation insert */ @@ -863,6 +863,27 @@ msg_error_t MsgStoClearConversationTable(MsgDbHandler *pDbHandle) } +msg_thread_id_t MsgGetThreadId(MsgDbHandler *pDbHandle, msg_message_id_t msgId) +{ + msg_thread_id_t conv_id = 0; + + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONV_ID FROM %s WHERE MSG_ID = %d;", + MSGFW_MESSAGE_TABLE_NAME, msgId); + + if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) + return 0; + + if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) { + conv_id = pDbHandle->columnInt(0); + } + + pDbHandle->finalizeQuery(); + + return conv_id; +} + /* Change the function name to conversation related. */ bool MsgExistAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t *pConvId) { @@ -1414,10 +1435,13 @@ void MsgStoUpdateAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET " - "ADDRESS_VAL = '%s' " + "ADDRESS_VAL = '%s', " + "ADDRESS_TYPE = %d, " + "RECIPIENT_TYPE = %d " "WHERE CONV_ID = %d " "AND ADDRESS_VAL LIKE '%%%%%s';", - MSGFW_ADDRESS_TABLE_NAME, pMsg->addressList[i].addressVal, convId, newPhoneNum); + MSGFW_ADDRESS_TABLE_NAME, pMsg->addressList[i].addressVal, + pMsg->addressList[i].addressType, pMsg->addressList[i].recipientType, convId, newPhoneNum); err = pDbHandle->execQuery(sqlQuery); if (err != MSG_SUCCESS) MSG_DEBUG("Fail to execQuery(). [%s]", sqlQuery); -- 2.7.4