3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
36 #include "MsgUtilFile.h"
37 #include "MsgException.h"
38 #include "MsgMmsMessage.h"
39 #include "MsgTransportTypes.h"
40 #include "MsgGconfWrapper.h"
41 #include "MsgSoundPlayer.h"
42 #include "MsgStorageHandler.h"
43 #include "MmsPluginTypes.h"
44 #include "MmsPluginCodec.h"
45 #include "MmsPluginSetup.h"
46 #include "MmsPluginInternal.h"
47 #include "MmsPluginStorage.h"
48 #include "MmsPluginHttp.h"
49 #include "MmsPluginCodec.h"
51 #include "MsgNotificationWrapper.h"
52 #include "MmsPluginSmil.h"
56 /*==================================================================================================
57 IMPLEMENTATION OF MmsPluginInternal - Member Functions
58 ==================================================================================================*/
59 MmsPluginInternal *MmsPluginInternal::pInstance = NULL;
62 MmsPluginInternal::MmsPluginInternal()
67 MmsPluginInternal::~MmsPluginInternal()
72 MmsPluginInternal *MmsPluginInternal::instance()
75 pInstance = new MmsPluginInternal();
80 void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject)
82 MSG_DEBUG("processReceivedInd \r\n");
85 char fileName[MSG_FILENAME_LEN_MAX] = {0,};
87 if (pMsgInfo->bTextSms == true) {
88 char fullPath[MAX_FULL_PATH_SIZE+1] = {0,};
90 if(MsgCreateFileName(fileName) == false)
91 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
93 MSG_DEBUG(" File name = %s", fileName);
95 if(MsgWriteIpcFile(fileName, pMsgInfo->msgText, pMsgInfo->dataSize) == false)
96 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
98 snprintf(fullPath, MAX_FULL_PATH_SIZE+1, MSG_IPC_DATA_PATH"%s", fileName);
100 memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
101 memcpy(pMsgInfo->msgData, fullPath, strlen(fullPath));
102 pMsgInfo->bTextSms = false;
105 MSG_DEBUG("MMS File Path = %s", pMsgInfo->msgData);
108 _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
110 if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) {
111 MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData);
114 if (!MmsBinaryDecodeMsgHeader(pFile, pMsgInfo->dataSize))
115 MSG_DEBUG("Decoding Header Failed \r\n");
117 MsgDeleteFile(pMsgInfo->msgData + strlen(MSG_IPC_DATA_PATH));
119 switch (mmsHeader.type) {
120 case MMS_MSGTYPE_NOTIFICATION_IND:
121 MSG_DEBUG("MmsProcessNewMsgInd: process noti.ind\n");
122 // For Set Value pMsgInfo
123 if (processNotiInd(pMsgInfo, pRequest) == false)
129 case MMS_MSGTYPE_DELIVERY_IND:
130 MSG_DEBUG("MmsProcessNewMsgInd: process delivery.ind\n");
131 // For Set Value pMsgInfo
132 processDeliveryInd(pMsgInfo);
135 case MMS_MSGTYPE_READORG_IND:
136 MSG_DEBUG("MmsProcessNewMsgInd: process readorig.ind\n");
137 processReadOrgInd(pMsgInfo);
145 //Check Msg Type & Process(Save ...)
148 bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest)
150 MSG_DEBUG("MmsProcessNotiInd");
151 MSG_ERROR_T err = MSG_SUCCESS;
153 MSG_MMS_HOME_RETRIEVE_TYPE_T retrieveType;
158 MmsInitMsgAttrib(&attrib);
160 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
161 pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
162 pMsgInfo->priority = mmsHeader.priority;
163 strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
165 MSG_DEBUG("pMsgInfo->subject [%s]", pMsgInfo->subject);
167 if (strlen(pMsgInfo->subject) < 1)
168 snprintf(pMsgInfo->subject, MAX_SUBJECT_LEN, "MMS Notification Message.");
170 attrib.expiryTime = mmsHeader.expiryTime;
172 MmsPluginStorage *pStorage = MmsPluginStorage::instance();
173 err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType);
175 if (mmsHeader.pFrom) {
176 MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
178 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
183 roamState = MsgSettingGetInt(VCONFKEY_TELEPHONY_SVC_ROAM);
184 MsgSettingGetBool(MMS_SEND_REPORT_ALLOWED, &bReportAllowed);
186 if (checkRejectNotiInd(roamState, bReportAllowed, pMsgInfo->msgData)) {
187 MSG_DEBUG("MMS Message Rejected......");
189 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
190 pMsgInfo->bTextSms = true;
191 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
193 pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
198 if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_OFF) {
199 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
200 MSG_DEBUG("$$$$$$$$$$ MMS_RECV_HOME_NETWORK = %d $$$$$$$$$$$$$", retrieveType);
202 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
203 MSG_DEBUG("$$$$$$$$$$ MMS_RECV_ABROAD_NETWORK = %d $$$$$$$$$$$$$", retrieveType);
205 if (retrieveType == MSG_ABROAD_RESTRICTED) {
206 MSG_DEBUG("MMS Receiving Setting Restricted was selected.");
207 // m-notify-resp-ind encoding process
208 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
210 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData);
212 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
213 pMsgInfo->bTextSms = true;
214 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
216 pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
222 // should send http 'GET'
223 if (retrieveType == MSG_HOME_AUTO_DOWNLOAD || retrieveType == MSG_ABROAD_AUTO_DOWNLOAD) {
224 MSG_DEBUG("=========== START AUTO RETRIEVE MODE ============");
225 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
227 memcpy(pMsgInfo->msgData, mmsHeader.szContentLocation, strlen(mmsHeader.szContentLocation)) ;
229 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
231 pMsgInfo->bTextSms = true;
233 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
235 pRequest->msgInfo.msgType.subType = MSG_GET_MMS;
237 MSG_DEBUG("MSG SUBTYPE = %d msg data %s bTextsms %d", pRequest->msgInfo.msgType.subType, pRequest->msgInfo.msgData, pRequest->msgInfo.bTextSms);
239 // should send m-notify-resp-ind
240 MSG_DEBUG("=========== START MANUAL RETRIEVE MODE ===========");
241 // m-notify-resp-ind encoding process
242 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
244 if (retrieveType == MSG_HOME_MANUAL || retrieveType == MSG_ABROAD_MANUAL) {
245 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData);
248 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
249 pMsgInfo->bTextSms = true;
250 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
252 pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
259 void MmsPluginInternal::processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo)
265 MmsMsgMultiStatus *pStatus = NULL;
266 MmsMsgMultiStatus *pLastStatus = NULL;
268 pMsg = (MmsMsg *)malloc(sizeof(MmsMsg));
271 MSG_DEBUG("fail to allocation memory.");
275 MmsInitMsgAttrib(&pMsg->mmsAttrib);
277 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
278 pMsgInfo->msgType.subType = MSG_DELIVERYIND_MMS;
279 pMsgInfo->bTextSms = true;
281 MSG_DEBUG("#### mmsHeader.szMsgID = %s : when received delivery ind####", mmsHeader.szMsgID);
283 int tmpId = (MSG_MESSAGE_ID_T)MmsSearchMsgId(mmsHeader.pTo->szAddr, mmsHeader.szMsgID);
286 MSG_DEBUG("tmpId [%d]", tmpId);
287 MSG_DEBUG("mmsHeader.pTo->szAddr [%s]", mmsHeader.pTo->szAddr);
290 pMsgInfo->msgId = (MSG_MESSAGE_ID_T)tmpId;
292 pMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(pMsgInfo->msgId);
294 pStatus = pMsg->mmsAttrib.pMultiStatus;
296 MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo);
298 while (pStatus && !bFound) {
299 MSG_DEBUG("### MmsAddrUtilCompareAddr ###");
300 MSG_DEBUG("### mmsHeader.pTo->szAddr = %s ###", mmsHeader.pTo->szAddr);
301 if (MmsAddrUtilCompareAddr( pStatus->szTo, mmsHeader.pTo->szAddr)) {
306 pStatus = pStatus->pNext;
309 if (bFound == false) {
310 MSG_DEBUG("### bFound == false ###");
311 /* Queue the delivery report --------------------------- */
313 pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
314 memset(pStatus, 0, sizeof(MmsMsgMultiStatus));
316 pStatus->readStatus = MMS_READSTATUS_NONE;
317 memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1);
318 strncpy(pStatus->szTo, mmsHeader.pTo->szAddr, MSG_ADDR_LEN);
320 if (pMsg->mmsAttrib.pMultiStatus == NULL) {
321 /* first delivery report */
322 pMsg->mmsAttrib.pMultiStatus = pStatus;
324 pLastStatus = pMsg->mmsAttrib.pMultiStatus;
326 while (pLastStatus->pNext) {
327 pLastStatus = pLastStatus->pNext;
330 pLastStatus->pNext = pStatus;
331 pLastStatus = pStatus;
335 pStatus->handledTime = mmsHeader.date;
336 pStatus->msgStatus = mmsHeader.msgStatus;
338 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
339 pMsgInfo->dataSize = 0;
340 strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(pStatus->msgStatus), MAX_MSG_DATA_LEN);
341 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
342 pMsgInfo->bTextSms = true;
343 MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData);
345 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
347 pStatus->bDeliveryReportIsRead = false;
349 _MmsDataUpdateLastStatus(pMsg);
351 pStatus->bDeliveyrReportIsLast= true;
353 MmsUpdateDeliveryReport(pMsgInfo->msgId, pStatus);
355 MmsPluginStorage::instance()->addMmsNoti(pMsgInfo);
357 MSG_DEBUG("Can't not find Message!");
358 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
359 pMsgInfo->dataSize = 0;
360 strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(mmsHeader.msgStatus), MAX_MSG_DATA_LEN);
362 MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData);
364 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
366 MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
368 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
371 MsgFreeAttrib(&pMsg->mmsAttrib);
378 void MmsPluginInternal::processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo)
384 MmsMsgMultiStatus *pStatus = NULL;
385 MmsMsgMultiStatus *pLastStatus = NULL;
387 pMsg = (MmsMsg *)malloc(sizeof(MmsMsg));
390 MSG_DEBUG("fail to allocation memory.");
394 MmsInitMsgAttrib(&pMsg->mmsAttrib);
396 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
397 pMsgInfo->msgType.subType = MSG_READORGIND_MMS;
398 pMsgInfo->bTextSms = true;
400 MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
401 MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
403 if (mmsHeader.readStatus != MSG_READ_REPORT_IS_DELETED || (strcmp(mmsHeader.pFrom->szAddr, mmsHeader.pTo->szAddr))) {
404 MSG_DEBUG("#### mmsHeader.szMsgID = %s : when received read orig ind####", mmsHeader.szMsgID);
406 int tmpId = MmsSearchMsgId(mmsHeader.pFrom->szAddr, mmsHeader.szMsgID);
409 pMsgInfo->msgId = (MSG_MESSAGE_ID_T)tmpId;
411 pMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(pMsgInfo->msgId);
413 pStatus = pMsg->mmsAttrib.pMultiStatus;
415 MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo);
417 while (pStatus && !bFound) {
418 MSG_DEBUG("### MmsAddrUtilCompareAddr ###");
419 MSG_DEBUG("### mmsHeader.pFrom->szAddr = %s ###", mmsHeader.pFrom->szAddr);
420 if (MmsAddrUtilCompareAddr(pStatus->szTo, mmsHeader.pFrom->szAddr)) {
425 pStatus = pStatus->pNext;
428 if (bFound == false) {
429 MSG_DEBUG("### bFound == false ###");
430 /* Queue the delivery report --------------------------- */
432 pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
433 memset(pStatus, 0, sizeof(MmsMsgMultiStatus));
435 pStatus->msgStatus = MMS_MSGSTATUS_NONE;
437 memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1);
438 strncpy(pStatus->szTo, mmsHeader.pFrom->szAddr, MSG_ADDR_LEN);
440 if (pMsg->mmsAttrib.pMultiStatus == NULL) {
441 /* first readOrg report */
442 pMsg->mmsAttrib.pMultiStatus = pStatus;
444 pLastStatus = pMsg->mmsAttrib.pMultiStatus;
446 while (pLastStatus->pNext) {
447 pLastStatus = pLastStatus->pNext;
450 pLastStatus->pNext = pStatus;
451 pLastStatus = pStatus;
455 pStatus->readTime = mmsHeader.date;
456 pStatus->readStatus = mmsHeader.readStatus;
458 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
459 pMsgInfo->dataSize = 0;
460 strncpy(pMsgInfo->msgData, getMmsReadStatus(pStatus->readStatus), MAX_MSG_DATA_LEN);
461 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
462 pMsgInfo->bTextSms = true;
463 MSG_DEBUG("read Status = %s", pMsgInfo->msgData);
465 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
467 pStatus->bReadReplyIsRead = false;
469 _MmsDataUpdateLastStatus(pMsg);
471 pStatus->bReadReplyIsLast= true;
473 MmsUpdateReadReport(pMsgInfo->msgId, pStatus);
475 MmsPluginStorage::instance()->addMmsNoti(pMsgInfo);
477 MSG_DEBUG("Can't not find Message!");
478 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
479 pMsgInfo->dataSize = 0;
480 strncpy(pMsgInfo->msgData, getMmsReadStatus(mmsHeader.readStatus), MAX_MSG_DATA_LEN);
481 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
482 MSG_DEBUG("read Status = %s", pMsgInfo->msgData);
484 MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
486 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
490 MsgFreeAttrib(&pMsg->mmsAttrib);
497 void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest)
501 MSG_ERROR_T err = MSG_SUCCESS;
503 MMS_RECV_DATA_S recvData = {{0}, };
505 pMsgInfo->msgId = pRequest->msgId;
507 //Set only changed members
508 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
509 pMsgInfo->msgType.subType = MSG_SENDCONF_MMS;
511 pMsgInfo->folderId = MSG_OUTBOX_ID;
513 strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
515 if (mmsHeader.responseStatus == MMS_RESPSTATUS_OK) {
516 pMsgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
518 pMsgInfo->networkStatus = MSG_NETWORK_SEND_FAIL;
520 char responseText[MMS_LOCALE_RESP_TEXT_LEN];
522 memset(responseText, 0x00, MMS_LOCALE_RESP_TEXT_LEN);
523 snprintf(responseText, MMS_LOCALE_RESP_TEXT_LEN, " %s [%d]", mmsHeader.szResponseText, mmsHeader.responseStatus);
525 memset(pMsgInfo->msgText, 0x00, MAX_MSG_TEXT_LEN + 1);
526 strncpy(pMsgInfo->msgText, responseText, MMS_LOCALE_RESP_TEXT_LEN);
529 // set message-id from mmsc
530 strncpy(recvData.szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN);
531 strncpy(recvData.szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN);
533 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
534 memcpy(pMsgInfo->msgData, &recvData, sizeof(MMS_RECV_DATA_S));
537 curTime = time(NULL);
539 pMsgInfo->displayTime = curTime;
542 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
544 #ifdef __SUPPORT_DRM__
545 _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
547 _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
554 void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest, char *pRetrievedFilePath)
561 bool bMultipartRelated = false;
563 MSG_ERROR_T err = MSG_SUCCESS;
564 MMS_RECV_DATA_S recvData = {{0}, };
568 MmsInitMsgAttrib(&attrib);
570 attrib.priority = mmsHeader.priority;
571 attrib.bAskDeliveryReport = getMmsReport(mmsHeader.deliveryReport);
572 attrib.bAskReadReply = getMmsReport(mmsHeader.readReply);
574 //Set only changed members
575 pMsgInfo->msgId = pRequest->msgId;
576 MSG_DEBUG("@@@@@ msgId = %d @@@@@", pMsgInfo->msgId);
577 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
579 if (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF)
580 pMsgInfo->msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
582 pMsgInfo->msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
584 strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
586 strncpy(pRequest->transactionId, mmsHeader.szTrID, MMS_TR_ID_LEN);
589 curTime = time(NULL);
591 pMsgInfo->displayTime = curTime;
593 if (mmsHeader.retrieveStatus == MMS_RETRSTATUS_OK) {
594 pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
595 pMsgInfo->folderId = MSG_INBOX_ID;
597 pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
598 pMsgInfo->folderId = MSG_INBOX_ID;
599 // If failed MMS Retrieve, then saved as MMS Noti Ind Message.
600 pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
603 pMsgInfo->dataSize = pRequest->getDataLen;
605 // set message-id & MMS TPDU file path
606 strcpy(recvData.szMsgID, mmsHeader.szMsgID);
607 if (pRetrievedFilePath)
608 strncpy(recvData.retrievedFilePath, pRetrievedFilePath, sizeof(recvData.retrievedFilePath));
610 #ifdef FEATURE_JAVA_MMS
611 if (mmsHeader.msgType.param.szApplicationID || mmsHeader.msgType.param.szReplyToApplicationID) {
612 recvData.msgAppId.valid = true;
613 if (mmsHeader.msgType.param.szApplicationID)
614 strncpy(recvData.msgAppId.appId, mmsHeader.msgType.param.szApplicationID, sizeof(recvData.msgAppId.appId));
615 if (mmsHeader.msgType.param.szReplyToApplicationID)
616 strncpy(recvData.msgAppId.replyToAppId, mmsHeader.msgType.param.szReplyToApplicationID, sizeof(recvData.msgAppId.replyToAppId));
618 char fullPath[MAX_FULL_PATH_SIZE+1] = {0, };
620 char *filename = NULL;
621 filename = strrchr(pRetrievedFilePath, '/');
623 snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, filename + 1);
625 rename(pRetrievedFilePath, fullPath);
627 if (chmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) != 0) {
628 MSG_DEBUG("File Write Error: %s", strerror(errno));
631 if (chown(fullPath, 0, 6502 ) != 0) {
632 MSG_DEBUG("File Write Error: %s", strerror(errno));
636 memcpy(pMsgInfo->msgData, &recvData, sizeof(MMS_RECV_DATA_S));
638 MSG_DEBUG("@@@@@ MsgData = %s @@@@@", pMsgInfo->msgData);
639 MSG_DEBUG("@@@@@ retrievedFilePath = %s @@@@@", recvData.retrievedFilePath);
640 MSG_DEBUG("@@@@@ szMsgID = %s @@@@@", recvData.szMsgID);
641 //update delivery report, read reply
643 MmsPluginStorage *pStorage = MmsPluginStorage::instance();
645 MMS_MESSAGE_DATA_S msgData;
646 memset(&msgData, 0, sizeof(MMS_MESSAGE_DATA_S));
648 // Conversation is supported only Multipart Related message, Presentation info should be provided
649 if (mmsHeader.msgType.type == MIME_MULTIPART_RELATED || mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
650 char *pSmilDoc = NULL;
652 char szFileName[MSG_FILENAME_LEN_MAX] = {0, };
654 msgData.regionCnt = 0;
656 msgData.attachCnt = 0;
657 msgData.transitionCnt = 0;
659 memset(msgData.szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
661 pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId);
662 MmsSmilParseSmilDoc(&msgData, pSmilDoc);
664 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
665 strcpy(szFileName, pMsg->szFileName);
667 err = pStorage->getMsgText(&msgData, pMsgInfo->msgText);
668 err = pStorage->makeThumbnail(&msgData, pMsgInfo->thumbPath, szFileName);
670 bMultipartRelated = true;
672 MSG_DEBUG("Multipart mixed message doesn't support mms conversation");
675 err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType);
677 partCnt = MmsGetMediaPartCount(pMsgInfo->msgId);
678 MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt );
681 MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt );
683 for (int i = 0; i < partCnt; ++i) {
684 if (!MmsGetMediaPartHeader(i, &partHeader)) {
685 MSG_DEBUG("MmsUiGetMediaAttachInfo: MmsGetMediaPartHeader failed\n" );
689 if (partHeader.contentSize > 0) {
690 char szBuf[MSG_FILEPATH_LEN_MAX];
692 strcpy((char *)szBuf, partHeader.param.szFileName);
693 sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf);
694 if (!bMultipartRelated || MmsCheckAdditionalMedia(&msgData, &partHeader))
699 MSG_DEBUG("attachCount [%d]", attachCount);
700 err = pStorage->updateMmsAttachCount(pMsgInfo->msgId, attachCount);
702 if (bMultipartRelated) {
703 _MsgMmsReleasePageList(&msgData);
704 _MsgMmsReleaseRegionList(&msgData);
705 _MsgMmsReleaseAttachList(&msgData);
706 _MsgMmsReleaseTransitionList(&msgData);
707 _MsgMmsReleaseMetaList(&msgData);
711 pStorage->getMmsMessage(&pMsg);
713 #ifdef __SUPPORT_DRM__
714 _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
716 _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
721 void MmsPluginInternal::processForwardConf(MSG_MESSAGE_INFO_S *msgInfo, mmsTranQEntity *pRequest)
726 /* This function Send NotifyRespInd Msg
728 * @param pTrID [in] Specifies Transaction ID
729 * @param iStatus [in] Specifies Msg Status
730 * @param iReportAllowed [in] Specifies whether to send deliveryReport to sender or not
731 * @return This function returns true on success, or false on failure.
733 bool MmsPluginInternal::encodeNotifyRespInd(char *szTrID, MSG_DELIVERY_REPORT_STATUS_T iStatus, bool bReportAllowed, char *pSendFilePath)
738 char pTempFileName[MSG_FILENAME_LEN_MAX+1] = {0};
739 char pTempFilePath[MAX_FULL_PATH_SIZE] = {0};
741 if (MsgCreateFileName(pTempFileName) == false)
744 snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.noti.ind", pTempFileName);
746 pFile = MsgOpenMMSFile(pTempFilePath);
749 MSG_DEBUG("[ERROR] MsgOpenMMSFile fail");
753 if (_MmsEncodeNotiRespInd(pFile, szTrID, iStatus, bReportAllowed) == false) {
754 MSG_DEBUG("MmsEncodeNotifyRespInd: _MmsEncodeNotiRespInd fail");
762 snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath);
764 MSG_DEBUG("[ERROR] pSendFilePath is NULL");
773 /* This function Send AcknowledgeInd Msg
775 * @param pTrID [in] Specifies Transaction ID
776 * @param iReportAllowed [in] Specifies whether to send deliveryReport to sender or not
777 * @return This function returns true on success, or false on failure.
779 bool MmsPluginInternal::encodeAckInd(char *szTrID, bool bReportAllowed, char *pSendFilePath)
783 char pTempFileName[MSG_FILENAME_LEN_MAX+1] = {0};
784 char pTempFilePath[MAX_FULL_PATH_SIZE] = {0};
786 if (MsgCreateFileName(pTempFileName) == false)
789 snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.ack.ind", pTempFileName);
791 pFile = MsgOpenMMSFile(pTempFilePath);
793 MSG_DEBUG("[ERROR] MsgOpenMMSFile fail \n" );
797 if (_MmsEncodeAckInd(pFile, szTrID, bReportAllowed) == false) {
798 MSG_DEBUG("MmsEncodeAckInd: _MmsEncodeAckInd fail \n" );
806 snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath);
808 MSG_DEBUG("[ERROR] pSendFilePath is NULL");
817 bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, char *pSendFilePath)
820 MSG_MMS_HOME_RETRIEVE_TYPE_T retrieveType;
821 bool bRejectAnonymous;
822 bool bRejectAdvertisement;
824 MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &bRejectAnonymous);
825 MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &bRejectAdvertisement);
828 if (bRejectAnonymous &&
829 (mmsHeader.pFrom == NULL || mmsHeader.pFrom->szAddr[0] == '\0')) {
830 MSG_DEBUG("Anonymous Reject... ");
831 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
836 // Advertisement Reject
837 if (bRejectAdvertisement && mmsHeader.msgClass == MMS_MSGCLASS_ADVERTISEMENT) {
838 MSG_DEBUG("Advertisement Reject... ");
839 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
844 // Message Reject - Roaming Case
845 if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_ON) {
846 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
847 if (retrieveType == MSG_ABROAD_REJECT) {
848 MSG_DEBUG("Abroad_Network : Notification Reject... ");
849 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
854 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
855 if (retrieveType == MSG_HOME_REJECT) {
856 MSG_DEBUG("Home_Network : Notification Reject... ");
857 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
869 bool MmsPluginInternal::getMmsReport(MmsReport mmsReport)
873 if (mmsReport == MMS_REPORT_YES)
875 else if (mmsReport == MMS_REPORT_NO)
881 const char *MmsPluginInternal::getMmsDeliveryStatus(MSG_DELIVERY_REPORT_STATUS_T deliveryStatus)
883 MSG_DEBUG("msgStatus= %d", deliveryStatus);
885 switch (deliveryStatus) {
886 case MSG_DELIVERY_REPORT_EXPIRED:
888 case MSG_DELIVERY_REPORT_REJECTED:
890 case MSG_DELIVERY_REPORT_UNREACHABLE:
891 return "unreachable.";
892 case MSG_DELIVERY_REPORT_UNRECOGNISED:
893 return "unrecognised.";
894 case MSG_DELIVERY_REPORT_SUCCESS:
897 return "delivery failed.";
901 const char *MmsPluginInternal::getMmsReadStatus(MSG_READ_REPORT_STATUS_T readStatus)
903 switch (readStatus) {
904 case MSG_READ_REPORT_IS_READ:
905 return "message is read.";
906 case MSG_READ_REPORT_IS_DELETED:
907 return "message is deleted.";
909 return "read status is none.";