2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (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://www.tizenopensource.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.
22 #include "MsgUtilFile.h"
23 #include "MsgException.h"
24 #include "MsgMmsMessage.h"
25 #include "MsgTransportTypes.h"
26 #include "MsgGconfWrapper.h"
27 #include "MsgSoundPlayer.h"
28 #include "MsgStorageHandler.h"
29 #include "MmsPluginTypes.h"
30 #include "MmsPluginCodec.h"
31 #include "MmsPluginSetup.h"
32 #include "MmsPluginInternal.h"
33 #include "MmsPluginStorage.h"
34 #include "MmsPluginHttp.h"
35 #include "MmsPluginCodec.h"
37 #include "MsgNotificationWrapper.h"
38 #include "MmsPluginSmil.h"
42 /*==================================================================================================
43 IMPLEMENTATION OF MmsPluginInternal - Member Functions
44 ==================================================================================================*/
45 MmsPluginInternal *MmsPluginInternal::pInstance = NULL;
48 MmsPluginInternal::MmsPluginInternal()
53 MmsPluginInternal::~MmsPluginInternal()
58 MmsPluginInternal *MmsPluginInternal::instance()
61 pInstance = new MmsPluginInternal();
66 void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject)
68 MSG_DEBUG("processReceivedInd \r\n");
71 char fileName[MSG_FILENAME_LEN_MAX] = {0,};
73 if (pMsgInfo->bTextSms == true) {
74 char fullPath[MAX_FULL_PATH_SIZE+1] = {0,};
76 if(MsgCreateFileName(fileName) == false)
77 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
79 MSG_DEBUG(" File name = %s", fileName);
81 if(MsgWriteIpcFile(fileName, pMsgInfo->msgText, pMsgInfo->dataSize) == false)
82 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
84 snprintf(fullPath, MAX_FULL_PATH_SIZE+1, MSG_IPC_DATA_PATH"%s", fileName);
86 memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
87 memcpy(pMsgInfo->msgData, fullPath, strlen(fullPath));
88 pMsgInfo->bTextSms = false;
91 MSG_DEBUG("MMS File Path = %s", pMsgInfo->msgData);
94 _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
96 if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) {
97 MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData);
100 if (!MmsBinaryDecodeMsgHeader(pFile, pMsgInfo->dataSize))
101 MSG_DEBUG("Decoding Header Failed \r\n");
103 MsgDeleteFile(pMsgInfo->msgData + strlen(MSG_IPC_DATA_PATH));
105 switch (mmsHeader.type) {
106 case MMS_MSGTYPE_NOTIFICATION_IND:
107 MSG_DEBUG("MmsProcessNewMsgInd: process noti.ind\n");
108 // For Set Value pMsgInfo
109 if (processNotiInd(pMsgInfo, pRequest) == false)
115 case MMS_MSGTYPE_DELIVERY_IND:
116 MSG_DEBUG("MmsProcessNewMsgInd: process delivery.ind\n");
117 // For Set Value pMsgInfo
118 processDeliveryInd(pMsgInfo);
121 case MMS_MSGTYPE_READORG_IND:
122 MSG_DEBUG("MmsProcessNewMsgInd: process readorig.ind\n");
123 processReadOrgInd(pMsgInfo);
131 //Check Msg Type & Process(Save ...)
134 bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest)
136 MSG_DEBUG("MmsProcessNotiInd");
137 msg_error_t err = MSG_SUCCESS;
139 MSG_MMS_HOME_RETRIEVE_TYPE_T retrieveType;
144 MmsInitMsgAttrib(&attrib);
146 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
147 pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
148 pMsgInfo->priority = mmsHeader.priority;
149 strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
151 MSG_DEBUG("pMsgInfo->subject [%s]", pMsgInfo->subject);
153 if (strlen(pMsgInfo->subject) < 1)
154 snprintf(pMsgInfo->subject, MAX_SUBJECT_LEN, "MMS Notification Message.");
156 attrib.expiryTime = mmsHeader.expiryTime;
158 MmsPluginStorage *pStorage = MmsPluginStorage::instance();
159 err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType);
161 if (mmsHeader.pFrom) {
162 MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
164 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
169 roamState = MsgSettingGetInt(VCONFKEY_TELEPHONY_SVC_ROAM);
170 MsgSettingGetBool(MMS_SEND_REPORT_ALLOWED, &bReportAllowed);
172 if (checkRejectNotiInd(roamState, bReportAllowed, pMsgInfo->msgData)) {
173 MSG_DEBUG("MMS Message Rejected......");
175 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
176 pMsgInfo->bTextSms = true;
177 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
179 pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
184 if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_OFF) {
185 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
186 MSG_DEBUG("$$$$$$$$$$ MMS_RECV_HOME_NETWORK = %d $$$$$$$$$$$$$", retrieveType);
188 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
189 MSG_DEBUG("$$$$$$$$$$ MMS_RECV_ABROAD_NETWORK = %d $$$$$$$$$$$$$", retrieveType);
191 if (retrieveType == MSG_ABROAD_RESTRICTED) {
192 MSG_DEBUG("MMS Receiving Setting Restricted was selected.");
193 // m-notify-resp-ind encoding process
194 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
196 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData);
198 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
199 pMsgInfo->bTextSms = true;
200 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
202 pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
208 // should send http 'GET'
209 if (retrieveType == MSG_HOME_AUTO_DOWNLOAD || retrieveType == MSG_ABROAD_AUTO_DOWNLOAD) {
210 MSG_DEBUG("=========== START AUTO RETRIEVE MODE ============");
211 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
213 memcpy(pMsgInfo->msgData, mmsHeader.szContentLocation, strlen(mmsHeader.szContentLocation)) ;
215 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
217 pMsgInfo->bTextSms = true;
219 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
221 pRequest->msgInfo.msgType.subType = MSG_GET_MMS;
223 MSG_DEBUG("MSG SUBTYPE = %d msg data %s bTextsms %d", pRequest->msgInfo.msgType.subType, pRequest->msgInfo.msgData, pRequest->msgInfo.bTextSms);
225 // should send m-notify-resp-ind
226 MSG_DEBUG("=========== START MANUAL RETRIEVE MODE ===========");
227 // m-notify-resp-ind encoding process
228 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
230 if (retrieveType == MSG_HOME_MANUAL || retrieveType == MSG_ABROAD_MANUAL) {
231 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pMsgInfo->msgData);
234 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
235 pMsgInfo->bTextSms = true;
236 memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
238 pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
244 void MmsPluginInternal::processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo)
248 MmsMsgMultiStatus status;
249 memset(&status, 0x00, sizeof(MmsMsgMultiStatus));
251 status.msgStatus = mmsHeader.msgStatus;
252 status.handledTime = mmsHeader.date;
253 status.bDeliveryReportIsRead = false;
254 status.bDeliveyrReportIsLast= true;
256 MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
257 MSG_DEBUG("[INFO] [ADDR: %s, MMSID: %s]",mmsHeader.pTo->szAddr, mmsHeader.szMsgID);
259 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
260 pMsgInfo->msgType.subType = MSG_DELIVERYIND_MMS;
261 pMsgInfo->bTextSms = true;
262 pMsgInfo->dataSize = 0;
263 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
265 strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(status.msgStatus), MAX_MSG_DATA_LEN);
266 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
267 MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData);
269 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pTo->szAddr, MAX_ADDRESS_VAL_LEN);
271 int tmpId = (msg_message_id_t)MmsSearchMsgId(mmsHeader.pTo->szAddr, mmsHeader.szMsgID);
273 MSG_DEBUG("Found MSG_ID = %d", tmpId);
275 //Insert to Delievery DB
276 MmsPluginStorage::instance()->insertDeliveryReport(tmpId, mmsHeader.pTo->szAddr, &status);
278 pMsgInfo->msgId = (msg_message_id_t)tmpId;
281 MSG_DEBUG("Can not find MMS message in DB");
287 void MmsPluginInternal::processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo)
291 if (pMsgInfo == NULL) {
292 MSG_DEBUG("parameter err");
296 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
297 pMsgInfo->msgType.subType = MSG_READORGIND_MMS;
298 pMsgInfo->bTextSms = true;
300 MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
301 MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
303 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
304 pMsgInfo->dataSize = 0;
306 strncpy(pMsgInfo->msgData, getMmsReadStatus(mmsHeader.readStatus), MAX_MSG_DATA_LEN);
307 pMsgInfo->dataSize = strlen(pMsgInfo->msgData);
309 MSG_DEBUG("read Status = %s", pMsgInfo->msgData);
310 strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
312 int tmpId = MmsSearchMsgId(mmsHeader.pFrom->szAddr, mmsHeader.szMsgID);
314 pMsgInfo->msgId = (msg_message_id_t)tmpId;
316 MmsMsgMultiStatus Status;
317 memset(&Status, 0x00, sizeof(MmsMsgMultiStatus));
318 Status.readTime = mmsHeader.date;
319 Status.readStatus = mmsHeader.readStatus;
321 MmsPluginStorage::instance()->insertReadReport(pMsgInfo->msgId, mmsHeader.pFrom->szAddr, &Status);
324 MSG_DEBUG("Can't not find Message!");
330 void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest)
334 MMS_RECV_DATA_S recvData = {{0}, };
336 pMsgInfo->msgId = pRequest->msgId;
338 //Set only changed members
339 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
340 pMsgInfo->msgType.subType = MSG_SENDCONF_MMS;
342 pMsgInfo->folderId = MSG_OUTBOX_ID;
344 strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
346 if (mmsHeader.responseStatus == MMS_RESPSTATUS_OK) {
347 pMsgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
348 pMsgInfo->dataSize = pRequest->postDataLen;
350 pMsgInfo->networkStatus = MSG_NETWORK_SEND_FAIL;
352 char responseText[MMS_LOCALE_RESP_TEXT_LEN];
354 memset(responseText, 0x00, MMS_LOCALE_RESP_TEXT_LEN);
355 snprintf(responseText, MMS_LOCALE_RESP_TEXT_LEN, " %s [%d]", mmsHeader.szResponseText, mmsHeader.responseStatus);
357 memset(pMsgInfo->msgText, 0x00, MAX_MSG_TEXT_LEN + 1);
358 strncpy(pMsgInfo->msgText, responseText, MMS_LOCALE_RESP_TEXT_LEN);
361 // set message-id from mmsc
362 strncpy(recvData.szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN);
363 strncpy(recvData.szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN);
365 memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
366 memcpy(pMsgInfo->msgData, &recvData, sizeof(MMS_RECV_DATA_S));
369 curTime = time(NULL);
371 pMsgInfo->displayTime = curTime;
374 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
376 #ifdef __SUPPORT_DRM__
377 _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
379 _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
386 void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest, char *pRetrievedFilePath)
393 bool bMultipartRelated = false;
395 msg_error_t err = MSG_SUCCESS;
396 MMS_RECV_DATA_S recvData = {{0}, };
400 MmsInitMsgAttrib(&attrib);
402 attrib.priority = mmsHeader.priority;
403 attrib.bAskDeliveryReport = getMmsReport(mmsHeader.deliveryReport);
404 attrib.bAskReadReply = getMmsReport(mmsHeader.readReply);
406 //Set only changed members
407 pMsgInfo->msgId = pRequest->msgId;
408 MSG_DEBUG("@@@@@ msgId = %d @@@@@", pMsgInfo->msgId);
409 pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
411 if (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF)
412 pMsgInfo->msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
414 pMsgInfo->msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
416 strncpy(pMsgInfo->subject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
418 strncpy(pRequest->transactionId, mmsHeader.szTrID, MMS_TR_ID_LEN);
421 curTime = time(NULL);
423 pMsgInfo->displayTime = curTime;
425 if (mmsHeader.retrieveStatus == MMS_RETRSTATUS_OK) {
426 pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
427 pMsgInfo->folderId = MSG_INBOX_ID;
429 pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
430 pMsgInfo->folderId = MSG_INBOX_ID;
431 // If failed MMS Retrieve, then saved as MMS Noti Ind Message.
432 pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
435 pMsgInfo->dataSize = pRequest->getDataLen;
437 // set message-id & MMS TPDU file path
438 strcpy(recvData.szMsgID, mmsHeader.szMsgID);
439 if (pRetrievedFilePath)
440 strncpy(recvData.retrievedFilePath, pRetrievedFilePath, sizeof(recvData.retrievedFilePath));
442 #ifdef FEATURE_JAVA_MMS
443 if (mmsHeader.msgType.param.szApplicationID || mmsHeader.msgType.param.szReplyToApplicationID) {
444 recvData.msgAppId.valid = true;
445 if (mmsHeader.msgType.param.szApplicationID)
446 strncpy(recvData.msgAppId.appId, mmsHeader.msgType.param.szApplicationID, sizeof(recvData.msgAppId.appId));
447 if (mmsHeader.msgType.param.szReplyToApplicationID)
448 strncpy(recvData.msgAppId.replyToAppId, mmsHeader.msgType.param.szReplyToApplicationID, sizeof(recvData.msgAppId.replyToAppId));
450 char fullPath[MAX_FULL_PATH_SIZE+1] = {0, };
452 char *filename = NULL;
453 filename = strrchr(pRetrievedFilePath, '/');
455 snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, filename + 1);
457 int ret = rename(pRetrievedFilePath, fullPath);
459 MSG_DEBUG("File rename Error: %s", strerror(errno));
462 if (chmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) != 0) {
463 MSG_DEBUG("File Write Error: %s", strerror(errno));
466 if (chown(fullPath, 0, 6502 ) != 0) {
467 MSG_DEBUG("File Write Error: %s", strerror(errno));
471 memcpy(pMsgInfo->msgData, &recvData, sizeof(MMS_RECV_DATA_S));
473 MSG_DEBUG("@@@@@ MsgData = %s @@@@@", pMsgInfo->msgData);
474 MSG_DEBUG("@@@@@ retrievedFilePath = %s @@@@@", recvData.retrievedFilePath);
475 MSG_DEBUG("@@@@@ szMsgID = %s @@@@@", recvData.szMsgID);
476 //update delivery report, read reply
478 MmsPluginStorage *pStorage = MmsPluginStorage::instance();
480 MMS_MESSAGE_DATA_S msgData;
481 memset(&msgData, 0, sizeof(MMS_MESSAGE_DATA_S));
483 // Conversation is supported only Multipart Related message, Presentation info should be provided
484 if (mmsHeader.msgType.type == MIME_MULTIPART_RELATED || mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
485 char *pSmilDoc = NULL;
487 char szFileName[MSG_FILENAME_LEN_MAX] = {0, };
489 msgData.regionCnt = 0;
491 msgData.attachCnt = 0;
492 msgData.transitionCnt = 0;
494 memset(msgData.szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
496 pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId);
497 MmsSmilParseSmilDoc(&msgData, pSmilDoc);
498 MmsRemovePims(&msgData);
500 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
501 strcpy(szFileName, pMsg->szFileName);
503 err = pStorage->getMsgText(&msgData, pMsgInfo->msgText);
504 bMultipartRelated = true;
506 MSG_DEBUG("Multipart mixed message doesn't support mms conversation");
509 err = pStorage->updateMmsAttrib(pMsgInfo->msgId, &attrib, pMsgInfo->msgType.subType);
511 partCnt = MmsGetMediaPartCount(pMsgInfo->msgId);
512 MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt );
515 MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt );
517 for (int i = 0; i < partCnt; ++i) {
518 if (!MmsGetMediaPartHeader(i, &partHeader)) {
519 MSG_DEBUG("MmsUiGetMediaAttachInfo: MmsGetMediaPartHeader failed\n" );
523 if (partHeader.contentSize > 0) {
524 char szBuf[MSG_FILEPATH_LEN_MAX];
526 strcpy((char *)szBuf, partHeader.param.szFileName);
527 sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf);
528 if (!bMultipartRelated || MmsCheckAdditionalMedia(&msgData, &partHeader)) {
529 MMS_ATTACH_S *attachment = NULL;
532 attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1);
534 MsgGetTypeByFileName(&tempType, partHeader.param.szFileName);
535 attachment->mediatype = (MimeType)tempType;
537 strcpy(attachment->szFilePath, partHeader.param.szFileName);
539 strncpy(attachment->szFileName, partHeader.param.szName, MSG_FILENAME_LEN_MAX - 1);
541 attachment->fileSize = partHeader.contentSize;
543 _MsgMmsAddAttachment(&msgData, attachment);
552 MmsMakePreviewInfo(pMsgInfo->msgId, &msgData);
553 MSG_DEBUG("attachCount [%d]", attachCount);
554 err = pStorage->updateMmsAttachCount(pMsgInfo->msgId, attachCount);
556 if (bMultipartRelated) {
557 _MsgMmsReleasePageList(&msgData);
558 _MsgMmsReleaseRegionList(&msgData);
559 _MsgMmsReleaseAttachList(&msgData);
560 _MsgMmsReleaseTransitionList(&msgData);
561 _MsgMmsReleaseMetaList(&msgData);
565 pStorage->getMmsMessage(&pMsg);
567 #ifdef __SUPPORT_DRM__
568 _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
570 _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
575 void MmsPluginInternal::processForwardConf(MSG_MESSAGE_INFO_S *msgInfo, mmsTranQEntity *pRequest)
580 /* This function Send NotifyRespInd Msg
582 * @param pTrID [in] Specifies Transaction ID
583 * @param iStatus [in] Specifies Msg Status
584 * @param iReportAllowed [in] Specifies whether to send deliveryReport to sender or not
585 * @return This function returns true on success, or false on failure.
587 bool MmsPluginInternal::encodeNotifyRespInd(char *szTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed, char *pSendFilePath)
592 char pTempFileName[MSG_FILENAME_LEN_MAX+1] = {0};
593 char pTempFilePath[MAX_FULL_PATH_SIZE] = {0};
595 if (MsgCreateFileName(pTempFileName) == false)
598 snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.noti.ind", pTempFileName);
600 pFile = MsgOpenMMSFile(pTempFilePath);
603 MSG_DEBUG("[ERROR] MsgOpenMMSFile fail");
607 if (_MmsEncodeNotiRespInd(pFile, szTrID, iStatus, bReportAllowed) == false) {
608 MSG_DEBUG("MmsEncodeNotifyRespInd: _MmsEncodeNotiRespInd fail");
616 snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath);
618 MSG_DEBUG("[ERROR] pSendFilePath is NULL");
627 /* This function Send AcknowledgeInd Msg
629 * @param pTrID [in] Specifies Transaction ID
630 * @param iReportAllowed [in] Specifies whether to send deliveryReport to sender or not
631 * @return This function returns true on success, or false on failure.
633 bool MmsPluginInternal::encodeAckInd(char *szTrID, bool bReportAllowed, char *pSendFilePath)
637 char pTempFileName[MSG_FILENAME_LEN_MAX+1] = {0};
638 char pTempFilePath[MAX_FULL_PATH_SIZE] = {0};
640 if (MsgCreateFileName(pTempFileName) == false)
643 snprintf(pTempFilePath, MAX_FULL_PATH_SIZE, MSG_DATA_PATH"%s.ack.ind", pTempFileName);
645 pFile = MsgOpenMMSFile(pTempFilePath);
647 MSG_DEBUG("[ERROR] MsgOpenMMSFile fail \n" );
651 if (_MmsEncodeAckInd(pFile, szTrID, bReportAllowed) == false) {
652 MSG_DEBUG("MmsEncodeAckInd: _MmsEncodeAckInd fail \n" );
660 snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath);
662 MSG_DEBUG("[ERROR] pSendFilePath is NULL");
671 bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, char *pSendFilePath)
674 MSG_MMS_HOME_RETRIEVE_TYPE_T retrieveType;
675 bool bRejectAnonymous;
676 bool bRejectAdvertisement;
678 MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &bRejectAnonymous);
679 MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &bRejectAdvertisement);
682 if (bRejectAnonymous &&
683 (mmsHeader.pFrom == NULL || mmsHeader.pFrom->szAddr[0] == '\0')) {
684 MSG_DEBUG("Anonymous Reject... ");
685 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
690 // Advertisement Reject
691 if (bRejectAdvertisement && mmsHeader.msgClass == MMS_MSGCLASS_ADVERTISEMENT) {
692 MSG_DEBUG("Advertisement Reject... ");
693 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
698 // Message Reject - Roaming Case
699 if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_ON) {
700 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
701 if (retrieveType == MSG_ABROAD_REJECT) {
702 MSG_DEBUG("Abroad_Network : Notification Reject... ");
703 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
708 retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
709 if (retrieveType == MSG_HOME_REJECT) {
710 MSG_DEBUG("Home_Network : Notification Reject... ");
711 encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
723 bool MmsPluginInternal::getMmsReport(MmsReport mmsReport)
727 if (mmsReport == MMS_REPORT_YES)
729 else if (mmsReport == MMS_REPORT_NO)
735 const char *MmsPluginInternal::getMmsDeliveryStatus(msg_delivery_report_status_t deliveryStatus)
737 MSG_DEBUG("msgStatus= %d", deliveryStatus);
739 switch (deliveryStatus) {
740 case MSG_DELIVERY_REPORT_EXPIRED:
742 case MSG_DELIVERY_REPORT_REJECTED:
744 case MSG_DELIVERY_REPORT_UNREACHABLE:
745 return "unreachable.";
746 case MSG_DELIVERY_REPORT_UNRECOGNISED:
747 return "unrecognised.";
748 case MSG_DELIVERY_REPORT_SUCCESS:
751 return "delivery failed.";
755 const char *MmsPluginInternal::getMmsReadStatus(msg_read_report_status_t readStatus)
757 switch (readStatus) {
758 case MSG_READ_REPORT_IS_READ:
759 return "message is read.";
760 case MSG_READ_REPORT_IS_DELETED:
761 return "message is deleted.";
763 return "read status is none.";