2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "MsgUtilFile.h"
22 #include "MsgException.h"
23 #include "MsgSettingTypes.h"
24 #include "MsgMmsMessage.h"
25 #include "MsgGconfWrapper.h"
26 #include "MsgStorageHandler.h"
27 #include "MmsPluginDebug.h"
28 #include "MmsPluginTypes.h"
29 #include "MmsPluginCodec.h"
30 #include "MmsPluginInternal.h"
31 #include "MmsPluginStorage.h"
32 #include "MmsPluginSmil.h"
33 /*==================================================================================================
34 IMPLEMENTATION OF MmsPluginInternal - Member Functions
35 ==================================================================================================*/
36 MmsPluginInternal *MmsPluginInternal::pInstance = NULL;
39 MmsPluginInternal::MmsPluginInternal()
44 MmsPluginInternal::~MmsPluginInternal()
49 MmsPluginInternal *MmsPluginInternal::instance()
52 pInstance = new MmsPluginInternal();
57 void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject)
62 char fileName[MSG_FILENAME_LEN_MAX] = {0,};
64 if (pMsgInfo->bTextSms == true) {
65 char fullPath[MAX_FULL_PATH_SIZE+1] = {0,};
67 if(MsgCreateFileName(fileName) == false)
68 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
70 MSG_DEBUG("File name = %s", fileName);
72 if(MsgWriteIpcFile(fileName, pMsgInfo->msgText, pMsgInfo->dataSize) == false)
73 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
75 snprintf(fullPath, MAX_FULL_PATH_SIZE+1, MSG_IPC_DATA_PATH"%s", fileName);
77 memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
78 memcpy(pMsgInfo->msgData, fullPath, strlen(fullPath));
79 pMsgInfo->bTextSms = false;
82 MSG_DEBUG("MMS File Path = %s", pMsgInfo->msgData);
85 MmsRegisterDecodeBuffer();
87 if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) {
88 MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData);
91 if (!MmsBinaryDecodeMsgHeader(pFile, pMsgInfo->dataSize))
92 MSG_DEBUG("Decoding Header Failed \r\n");
94 MsgDeleteFile(pMsgInfo->msgData + strlen(MSG_IPC_DATA_PATH));
96 switch (mmsHeader.type) {
97 case MMS_MSGTYPE_NOTIFICATION_IND:
98 MSG_DEBUG("process noti.ind\n");
99 // For Set Value pMsgInfo
100 if (processNotiInd(pMsgInfo, pRequest) == false)
106 case MMS_MSGTYPE_DELIVERY_IND:
107 MSG_DEBUG("process delivery.ind\n");
108 // For Set Value pMsgInfo
109 processDeliveryInd(pMsgInfo);
112 case MMS_MSGTYPE_READORG_IND:
113 MSG_DEBUG("process readorig.ind\n");
114 processReadOrgInd(pMsgInfo);
126 bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest)
128 MSG_DEBUG("MmsProcessNotiInd");
129 msg_error_t err = MSG_SUCCESS;
131 MSG_MMS_HOME_RETRIEVE_TYPE_T retrieveType;
136 MmsInitMsgAttrib(&attrib);
138 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
139 pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
140 pMsgInfo->priority = mmsHeader.priority;
141 strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
143 MSG_DEBUG("pMsgInfo->subject [%s]", pMsgInfo->subject);
145 if (strlen(pMsgInfo->subject) < 1)
146 snprintf(pMsgInfo->subject, MAX_SUBJECT_LEN, "MMS Notification Message.");
148 attrib.expiryTime = mmsHeader.expiryTime;
150 MmsPluginStorage *pStorage = MmsPluginStorage::instance();
151 err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType);
153 if (mmsHeader.pFrom) {
154 MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
156 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
161 roamState = MsgSettingGetInt(VCONFKEY_TELEPHONY_SVC_ROAM);
162 MsgSettingGetBool(MMS_SEND_REPORT_ALLOWED, &bReportAllowed);
164 if (checkRejectNotiInd(roamState, bReportAllowed, pMsgInfo->msgData)) {
165 MSG_DEBUG("MMS Message Rejected......");
167 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
168 pMsgInfo->bTextSms = true;
169 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
171 pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
176 if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_OFF) {
177 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
178 MSG_DEBUG("$$$$$$$$$$ MMS_RECV_HOME_NETWORK = %d $$$$$$$$$$$$$", retrieveType);
180 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
181 MSG_DEBUG("$$$$$$$$$$ MMS_RECV_ABROAD_NETWORK = %d $$$$$$$$$$$$$", retrieveType);
183 if (retrieveType == MSG_ABROAD_RESTRICTED) {
184 MSG_DEBUG("MMS Receiving Setting Restricted was selected.");
185 // m-notify-resp-ind encoding process
186 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
188 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData);
190 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
191 pMsgInfo->bTextSms = true;
192 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
194 pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
200 // should send http 'GET'
201 if (retrieveType == MSG_HOME_AUTO_DOWNLOAD || retrieveType == MSG_ABROAD_AUTO_DOWNLOAD) {
202 MSG_DEBUG("=========== START AUTO RETRIEVE MODE ============");
203 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
205 memcpy(pMsgInfo->msgData, mmsHeader.szContentLocation, strlen(mmsHeader.szContentLocation)) ;
207 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
209 pMsgInfo->bTextSms = true;
211 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
213 pRequest->msgInfo.msgType.subType = MSG_GET_MMS;
215 MSG_DEBUG("MSG SUBTYPE = %d msg data %s bTextsms %d", pRequest->msgInfo.msgType.subType, pRequest->msgInfo.msgData, pRequest->msgInfo.bTextSms);
217 // should send m-notify-resp-ind
218 MSG_DEBUG("=========== START MANUAL RETRIEVE MODE ===========");
219 // m-notify-resp-ind encoding process
220 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
222 if (retrieveType == MSG_HOME_MANUAL || retrieveType == MSG_ABROAD_MANUAL) {
223 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData);
226 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
227 pMsgInfo->bTextSms = true;
228 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
230 pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
236 void MmsPluginInternal::processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo)
240 MmsMsgMultiStatus status;
241 memset(&status, 0x00, sizeof(MmsMsgMultiStatus));
243 status.msgStatus = mmsHeader.msgStatus;
244 status.handledTime = mmsHeader.date;
245 status.bDeliveryReportIsRead = false;
246 status.bDeliveyrReportIsLast= true;
248 MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
249 MSG_DEBUG("[INFO] [ADDR: %s, MMSID: %s]",mmsHeader.pTo->szAddr, mmsHeader.szMsgID);
251 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
252 pMsgInfo->msgType.subType = MSG_DELIVERYIND_MMS;
253 pMsgInfo->bTextSms = true;
254 pMsgInfo->dataSize = 0;
255 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
257 strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(status.msgStatus), MAX_MSG_DATA_LEN);
258 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
259 MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData);
261 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
263 int tmpId = (msg_message_id_t)MmsPluginStorage::instance()->searchMsgId(mmsHeader.pTo->szAddr, mmsHeader.szMsgID);
265 MSG_DEBUG("Found MSG_ID = %d", tmpId);
267 //Insert to Delievery DB
268 MmsPluginStorage::instance()->insertDeliveryReport(tmpId, mmsHeader.pTo->szAddr, &status);
270 pMsgInfo->msgId = (msg_message_id_t)tmpId;
273 MSG_DEBUG("Can not find MMS message in DB");
279 void MmsPluginInternal::processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo)
283 if (pMsgInfo == NULL) {
284 MSG_DEBUG("parameter err");
288 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
289 pMsgInfo->msgType.subType = MSG_READORGIND_MMS;
290 pMsgInfo->bTextSms = true;
292 MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
293 MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
295 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
296 pMsgInfo->dataSize = 0;
298 strncpy(pMsgInfo->msgData, getMmsReadStatus(mmsHeader.readStatus), MAX_MSG_DATA_LEN);
299 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
301 MSG_DEBUG("read Status = %s", pMsgInfo->msgData);
302 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
304 int tmpId = MmsPluginStorage::instance()->searchMsgId(mmsHeader.pFrom->szAddr, mmsHeader.szMsgID);
306 pMsgInfo->msgId = (msg_message_id_t)tmpId;
308 MmsMsgMultiStatus Status;
309 memset(&Status, 0x00, sizeof(MmsMsgMultiStatus));
310 Status.readTime = mmsHeader.date;
311 Status.readStatus = mmsHeader.readStatus;
313 MmsPluginStorage::instance()->insertReadReport(pMsgInfo->msgId, mmsHeader.pFrom->szAddr, &Status);
316 MSG_DEBUG("Can't not find Message!");
322 void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest)
326 MMS_RECV_DATA_S recvData = {{0}, };
328 pMsgInfo->msgId = pRequest->msgId;
330 //Set only changed members
331 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
332 pMsgInfo->msgType.subType = MSG_SENDCONF_MMS;
334 pMsgInfo->folderId = MSG_OUTBOX_ID;
336 strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
338 if (mmsHeader.responseStatus == MMS_RESPSTATUS_OK) {
339 pMsgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
340 pMsgInfo->dataSize = pRequest->postDataLen;
342 pMsgInfo->networkStatus = MSG_NETWORK_SEND_FAIL;
344 char responseText[MMS_LOCALE_RESP_TEXT_LEN];
346 memset(responseText, 0x00, MMS_LOCALE_RESP_TEXT_LEN);
347 snprintf(responseText, MMS_LOCALE_RESP_TEXT_LEN, " %s [%d]", mmsHeader.szResponseText, mmsHeader.responseStatus);
349 memset(pMsgInfo->msgText, 0x00, MAX_MSG_TEXT_LEN + 1);
350 strncpy(pMsgInfo->msgText, responseText, MMS_LOCALE_RESP_TEXT_LEN);
353 MSG_ADDRESS_INFO_S addressinfo = {0,};
355 msisdn = MsgSettingGetString(MSG_SIM_MSISDN);
357 MmsPluginStorage::instance()->getAddressInfo(pMsgInfo->msgId, &addressinfo);
359 MSG_MMS_VLD_INFO("%d, MMS Send End %s->%s %s", pMsgInfo->msgId
360 , (msisdn == NULL)?"ME":msisdn
361 , addressinfo.addressVal
362 , (pMsgInfo->networkStatus == MSG_NETWORK_SEND_SUCCESS)?"Success":"Fail");
364 // set message-id from mmsc
365 strncpy(recvData.szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN);
366 strncpy(recvData.szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN);
368 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
369 memcpy(pMsgInfo->msgData, &recvData, sizeof(MMS_RECV_DATA_S));
372 curTime = time(NULL);
374 pMsgInfo->displayTime = curTime;
378 #if 0 // Not Need Release
380 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
381 #ifdef __SUPPORT_DRM__
382 MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo);
384 MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type);
391 void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest, char *pRetrievedFilePath)
398 bool bMultipartRelated = false;
400 msg_error_t err = MSG_SUCCESS;
401 MMS_RECV_DATA_S recvData = {{0}, };
405 MmsInitMsgAttrib(&attrib);
407 attrib.priority = mmsHeader.priority;
408 attrib.bAskDeliveryReport = getMmsReport(mmsHeader.deliveryReport);
409 attrib.bAskReadReply = getMmsReport(mmsHeader.readReply);
411 //Set only changed members
412 pMsgInfo->msgId = pRequest->msgId;
413 MSG_DEBUG("@@@@@ msgId = %d @@@@@", pMsgInfo->msgId);
414 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
416 if (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF)
417 pMsgInfo->msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
419 pMsgInfo->msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
421 strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
423 strncpy(pRequest->transactionId, mmsHeader.szTrID, MMS_TR_ID_LEN);
426 curTime = time(NULL);
428 pMsgInfo->displayTime = curTime;
430 if (mmsHeader.retrieveStatus == MMS_RETRSTATUS_OK) {
431 pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
432 pMsgInfo->folderId = MSG_INBOX_ID;
434 pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
435 pMsgInfo->folderId = MSG_INBOX_ID;
436 // If failed MMS Retrieve, then saved as MMS Noti Ind Message.
437 // It will changed in MsgHandleMmsConfIncomingMsg
438 //pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
442 msisdn = MsgSettingGetString(MSG_SIM_MSISDN);
445 MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
447 MSG_MMS_VLD_INFO("%d, MMS Receive %s End %s->%s %s", pMsgInfo->msgId
448 , (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF)?"Auto":"Manual"
449 , (mmsHeader.pFrom)?mmsHeader.pFrom->szAddr:"YOU"
450 , (msisdn == NULL)?"ME":msisdn
451 , (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS)?"Success":"Fail");
452 pMsgInfo->dataSize = pRequest->getDataLen;
454 // set message-id & MMS TPDU file path
455 strcpy(recvData.szMsgID, mmsHeader.szMsgID);
456 if (pRetrievedFilePath)
457 strncpy(recvData.retrievedFilePath, pRetrievedFilePath, sizeof(recvData.retrievedFilePath));
459 #ifdef FEATURE_JAVA_MMS
460 if (mmsHeader.msgType.param.szApplicationID || mmsHeader.msgType.param.szReplyToApplicationID) {
461 recvData.msgAppId.valid = true;
462 if (mmsHeader.msgType.param.szApplicationID)
463 strncpy(recvData.msgAppId.appId, mmsHeader.msgType.param.szApplicationID, sizeof(recvData.msgAppId.appId));
464 if (mmsHeader.msgType.param.szReplyToApplicationID)
465 strncpy(recvData.msgAppId.replyToAppId, mmsHeader.msgType.param.szReplyToApplicationID, sizeof(recvData.msgAppId.replyToAppId));
467 char fullPath[MAX_FULL_PATH_SIZE+1] = {0, };
469 char *filename = NULL;
470 filename = strrchr(pRetrievedFilePath, '/');
472 snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, filename + 1);
474 int ret = rename(pRetrievedFilePath, fullPath);
476 MSG_DEBUG("File rename Error: %s", strerror(errno));
479 if (chmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) != 0) {
480 MSG_DEBUG("File Write Error: %s", strerror(errno));
483 if (chown(fullPath, 0, 6502 ) != 0) {
484 MSG_DEBUG("File Write Error: %s", strerror(errno));
488 memcpy(pMsgInfo->msgData, &recvData, sizeof(MMS_RECV_DATA_S));
490 MSG_DEBUG("@@@@@ MsgData = %s @@@@@", pMsgInfo->msgData);
491 MSG_DEBUG("@@@@@ retrievedFilePath = %s @@@@@", recvData.retrievedFilePath);
492 MSG_DEBUG("@@@@@ szMsgID = %s @@@@@", recvData.szMsgID);
493 //update delivery report, read reply
495 MmsPluginStorage *pStorage = MmsPluginStorage::instance();
497 MMS_MESSAGE_DATA_S msgData;
498 memset(&msgData, 0, sizeof(MMS_MESSAGE_DATA_S));
500 // Conversation is supported only Multipart Related message, Presentation info should be provided
501 if (mmsHeader.msgType.type == MIME_MULTIPART_RELATED || mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
502 char *pSmilDoc = NULL;
504 char szFileName[MSG_FILENAME_LEN_MAX] = {0, };
506 msgData.regionCnt = 0;
508 msgData.attachCnt = 0;
509 msgData.transitionCnt = 0;
511 memset(msgData.szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
513 pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId);
514 MmsSmilParseSmilDoc(&msgData, pSmilDoc);
515 MmsRemovePims(&msgData);
517 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
518 strcpy(szFileName, pMsg->szFileName);
520 err = pStorage->getMsgText(&msgData, pMsgInfo->msgText);
521 bMultipartRelated = true;
523 MSG_DEBUG("Multipart mixed message doesn't support mms conversation");
526 err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType);
528 partCnt = MmsGetMediaPartCount(pMsgInfo->msgId);
529 MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt );
532 MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt );
534 for (int i = 0; i < partCnt; ++i) {
535 if (!MmsGetMediaPartHeader(i, &partHeader)) {
536 MSG_DEBUG("MmsUiGetMediaAttachInfo: MmsGetMediaPartHeader failed\n" );
540 if (partHeader.contentSize > 0) {
541 char szBuf[MSG_FILEPATH_LEN_MAX + 1];
543 strcpy((char *)szBuf, partHeader.param.szFileName);
544 sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf);
545 if (!bMultipartRelated || MmsCheckAdditionalMedia(&msgData, &partHeader)) {
546 MMS_ATTACH_S *attachment = NULL;
549 attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1);
551 MsgGetTypeByFileName(&tempType, partHeader.param.szFileName);
552 attachment->mediatype = (MimeType)tempType;
554 strcpy(attachment->szFilePath, partHeader.param.szFileName);
556 strncpy(attachment->szFileName, partHeader.param.szName, MSG_FILENAME_LEN_MAX - 1);
558 attachment->fileSize = partHeader.contentSize;
560 _MsgMmsAddAttachment(&msgData, attachment);
569 MmsMakePreviewInfo(pMsgInfo->msgId, &msgData);
570 MSG_DEBUG("attachCount [%d]", attachCount);
571 err = pStorage->updateMmsAttachCount(pMsgInfo->msgId, attachCount);
573 if (bMultipartRelated) {
574 MsgMmsReleaseMmsLists(&msgData);
578 pStorage->getMmsMessage(&pMsg);
580 #ifdef __SUPPORT_DRM__
581 MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo);
583 MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type);
588 void MmsPluginInternal::processForwardConf(MSG_MESSAGE_INFO_S *msgInfo, mmsTranQEntity *pRequest)
593 /* This function Send NotifyRespInd Msg
595 * @param pTrID [in] Specifies Transaction ID
596 * @param iStatus [in] Specifies Msg Status
597 * @param iReportAllowed [in] Specifies whether to send deliveryReport to sender or not
598 * @return This function returns true on success, or false on failure.
600 bool MmsPluginInternal::encodeNotifyRespInd(char *szTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed, char *pSendFilePath)
605 char pTempFileName[MSG_FILENAME_LEN_MAX+1] = {0};
606 char pTempFilePath[MAX_FULL_PATH_SIZE] = {0};
608 if (MsgCreateFileName(pTempFileName) == false)
611 snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.noti.ind", pTempFileName);
613 pFile = MsgOpenMMSFile(pTempFilePath);
616 MSG_DEBUG("[ERROR] MsgOpenMMSFile fail");
620 if (MmsEncodeNotiRespInd(pFile, szTrID, iStatus, bReportAllowed) == false) {
621 MSG_DEBUG("MmsEncodeNotifyRespInd: MmsEncodeNotiRespInd fail");
629 snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath);
631 MSG_DEBUG("[ERROR] pSendFilePath is NULL");
640 /* This function Send AcknowledgeInd Msg
642 * @param pTrID [in] Specifies Transaction ID
643 * @param iReportAllowed [in] Specifies whether to send deliveryReport to sender or not
644 * @return This function returns true on success, or false on failure.
646 bool MmsPluginInternal::encodeAckInd(char *szTrID, bool bReportAllowed, char *pSendFilePath)
650 char pTempFileName[MSG_FILENAME_LEN_MAX+1] = {0};
651 char pTempFilePath[MAX_FULL_PATH_SIZE] = {0};
653 if (MsgCreateFileName(pTempFileName) == false)
656 snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.ack.ind", pTempFileName);
658 pFile = MsgOpenMMSFile(pTempFilePath);
660 MSG_DEBUG("[ERROR] MsgOpenMMSFile fail \n" );
664 if (MmsEncodeAckInd(pFile, szTrID, bReportAllowed) == false) {
665 MSG_DEBUG("MmsEncodeAckInd: MmsEncodeAckInd fail \n" );
673 snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath);
675 MSG_DEBUG("[ERROR] pSendFilePath is NULL");
684 bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, char *pSendFilePath)
687 MSG_MMS_HOME_RETRIEVE_TYPE_T retrieveType;
688 bool bRejectAnonymous;
689 bool bRejectAdvertisement;
691 MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &bRejectAnonymous);
692 MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &bRejectAdvertisement);
695 if (bRejectAnonymous &&
696 (mmsHeader.pFrom == NULL || mmsHeader.pFrom->szAddr[0] == '\0')) {
697 MSG_DEBUG("Anonymous Reject... ");
698 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
703 // Advertisement Reject
704 if (bRejectAdvertisement && mmsHeader.msgClass == MMS_MSGCLASS_ADVERTISEMENT) {
705 MSG_DEBUG("Advertisement Reject... ");
706 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
711 // Message Reject - Roaming Case
712 if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_ON) {
713 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
714 if (retrieveType == MSG_ABROAD_REJECT) {
715 MSG_DEBUG("Abroad_Network : Notification Reject... ");
716 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
721 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
722 if (retrieveType == MSG_HOME_REJECT) {
723 MSG_DEBUG("Home_Network : Notification Reject... ");
724 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
736 bool MmsPluginInternal::getMmsReport(MmsReport mmsReport)
740 if (mmsReport == MMS_REPORT_YES)
742 else if (mmsReport == MMS_REPORT_NO)
748 const char *MmsPluginInternal::getMmsDeliveryStatus(msg_delivery_report_status_t deliveryStatus)
750 MSG_DEBUG("msgStatus= %d", deliveryStatus);
752 switch (deliveryStatus) {
753 case MSG_DELIVERY_REPORT_EXPIRED:
755 case MSG_DELIVERY_REPORT_REJECTED:
757 case MSG_DELIVERY_REPORT_UNREACHABLE:
758 return "unreachable.";
759 case MSG_DELIVERY_REPORT_UNRECOGNISED:
760 return "unrecognised.";
761 case MSG_DELIVERY_REPORT_SUCCESS:
764 return "delivery failed.";
768 const char *MmsPluginInternal::getMmsReadStatus(msg_read_report_status_t readStatus)
770 switch (readStatus) {
771 case MSG_READ_REPORT_IS_READ:
772 return "message is read.";
773 case MSG_READ_REPORT_IS_DELETED:
774 return "message is deleted.";
776 return "read status is none.";