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.
24 #include "MsgCppTypes.h"
25 #include "MsgException.h"
26 #include "MsgStorageTypes.h"
27 #include "MsgSettingTypes.h"
28 #include "MmsPluginMessage.h"
29 #include "MmsPluginMIME.h"
30 #include "MmsPluginAvCodec.h"
31 #include "MsgUtilFile.h"
33 #include "MmsPluginCodec.h"
34 #include "MmsPluginStorage.h"
35 #include "MsgMmsMessage.h"
36 #include "MsgGconfWrapper.h"
37 #include "MmsPluginUtil.h"
38 #include "MmsPluginSMILValidate.h"
41 bool MmsInitMsgAttrib(MmsAttrib *pAttrib)
43 MSG_DEBUG("MmsInitMsgAttrib");
45 pAttrib->bAskDeliveryReport = false;
47 pAttrib->bAskReadReply = false;
48 pAttrib->bRead = false;
49 pAttrib->bReportAllowed = false;
50 pAttrib->readReportAllowedType = MMS_RECEIVE_READ_REPORT_ALLOWED;
51 pAttrib->readReportSendStatus = MMS_RECEIVE_READ_REPORT_NO_SEND;
52 pAttrib->bReadReportSent = false;
54 pAttrib->bHideAddress = false;
56 pAttrib->bUseDeliveryCustomTime = false;
57 pAttrib->deliveryTime.type = MMS_TIMETYPE_RELATIVE;
58 pAttrib->deliveryTime.time = 0;
59 pAttrib->bUseExpiryCustomTime = false;
60 pAttrib->expiryTime.type = MMS_TIMETYPE_RELATIVE;
61 pAttrib->expiryTime.time = 0;
62 memset(&pAttrib->expiryTime, 0, sizeof(MmsTimeStruct));
63 pAttrib->msgClass = MMS_MSGCLASS_PERSONAL;
64 pAttrib->msgStatus = MSG_DELIVERY_REPORT_NONE;
65 pAttrib->priority = MMS_PRIORITY_NORMAL;
66 pAttrib->responseStatus = MMS_RESPSTATUS_ERROR;
67 pAttrib->retrieveStatus = MMS_RETRSTATUS_ERROR;
68 pAttrib->contentType = MIME_UNKNOWN;
70 pAttrib->bLeaveCopy = true;
72 pAttrib->specialMsgType = MMS_SPECIAL_MSG_TYPE_NONE;
73 #ifdef __SUPPORT_DRM__
74 pAttrib->drmType = MSG_DRM_TYPE_NONE;
75 pAttrib->roWaitingTimerMax = 0;
76 pAttrib->pszDrmData = NULL;
78 pAttrib->version = MMS_VERSION;
80 memset(pAttrib->szFrom, 0, MSG_LOCALE_ADDR_LEN + 10);
81 memset(pAttrib->szResponseText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1);
82 memset(pAttrib->szRetrieveText, 0, MMS_LOCALE_RESP_TEXT_LEN + 1);
83 memset(pAttrib->szSubject, 0, MSG_LOCALE_SUBJ_LEN + 1);
86 pAttrib->szBcc = NULL;
88 pAttrib->pMultiStatus = NULL;
90 pAttrib->replyCharge.chargeType = MMS_REPLY_NONE;
91 memset(&pAttrib->replyCharge.deadLine , 0, sizeof(MmsTimeStruct));
92 pAttrib->replyCharge.chargeSize = 0;
93 memset(pAttrib->replyCharge.szChargeID, 0, MMS_MSG_ID_LEN);
98 bool MmsInitMsgType(MsgType *pMsgType)
100 MSG_DEBUG("MmsInitMsgType");
101 pMsgType->offset = 0;
103 pMsgType->contentSize = 0;
104 pMsgType->disposition = -1;
105 pMsgType->encoding = -1;
106 pMsgType->type = MIME_UNKNOWN;
107 pMsgType->section = -1;
109 pMsgType->szOrgFilePath[0] = '\0';
110 pMsgType->szContentID[0] = '\0';
111 pMsgType->szContentLocation[0] = '\0';
113 pMsgType->szContentRepPos[0] = '\0';
114 pMsgType->szContentRepSize[0] = '\0';
115 pMsgType->szContentRepIndex[0] = '\0';
117 MmsInitMsgContentParam(&pMsgType->param);
118 #ifdef __SUPPORT_DRM__
119 __MsgInitMsgDRMInfo(&pMsgType->drmInfo);
125 bool MmsInitMsgBody(MsgBody *pMsgBody)
127 MSG_DEBUG("MmsInitMsgBody");
128 pMsgBody->offset = 0;
130 pMsgBody->body.pText = NULL;
132 MmsInitMsgType(&pMsgBody->presentationType);
133 pMsgBody->pPresentationBody = NULL;
135 memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX);
140 bool MmsInitMsgContentParam(MsgContentParam *pMsgContentParam)
142 MSG_DEBUG("MmsInitMsgContentParam");
143 pMsgContentParam->charset = MSG_CHARSET_UNKNOWN;
144 pMsgContentParam->type = MIME_UNKNOWN;
145 pMsgContentParam->szBoundary[0] = '\0';
146 pMsgContentParam->szFileName[0] = '\0';
147 pMsgContentParam->szName[0] = '\0';
148 pMsgContentParam->szStart[0] = '\0';
149 pMsgContentParam->szStartInfo[0] = '\0';
150 pMsgContentParam->pPresentation = NULL;
151 pMsgContentParam->reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; // only used as parameter of Content-Type: multipart/report; report-type
152 #ifdef FEATURE_JAVA_MMS
153 pMsgContentParam->szApplicationID = NULL;
154 pMsgContentParam->szReplyToApplicationID = NULL;
159 bool MmsSetMsgAddressList(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S * pMsgInfo)
161 MSG_DEBUG("MmsSetMsgAddressList");
162 pAttrib->szTo = MmsComposeAddress(pMsgInfo, MSG_RECIPIENTS_TYPE_TO);
163 MSG_DEBUG("To address: %s", pAttrib->szTo);
164 pAttrib->szCc = MmsComposeAddress(pMsgInfo, MSG_RECIPIENTS_TYPE_CC);
165 MSG_DEBUG("Cc address: %s", pAttrib->szCc);
166 pAttrib->szBcc = MmsComposeAddress(pMsgInfo, MSG_RECIPIENTS_TYPE_BCC);
167 MSG_DEBUG("Bcc address: %s", pAttrib->szBcc);
172 void MmsSetMsgMultiStatus(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S *pMsgInfo)
176 nAddressCnt = pMsgInfo->nAddressCnt;
178 for (int i = 0; i < nAddressCnt; ++i) {
179 pAttrib->pMultiStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
181 memset(pAttrib->pMultiStatus->szTo, 0, MAX_ADDRESS_VAL_LEN + 1);
182 strncpy(pAttrib->pMultiStatus->szTo, pMsgInfo->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN);
184 MSG_DEBUG("### pMultistatus->szTo = %s ####", pAttrib->pMultiStatus->szTo);
185 pAttrib->pMultiStatus->bDeliveryReportIsRead = false;
186 pAttrib->pMultiStatus->bDeliveyrReportIsLast = false;
187 pAttrib->pMultiStatus->msgStatus = MMS_MSGSTATUS_NONE;
188 pAttrib->pMultiStatus->handledTime = 0;
189 pAttrib->pMultiStatus->bReadReplyIsRead = false;
190 pAttrib->pMultiStatus->bReadReplyIsLast = false;
191 pAttrib->pMultiStatus->readStatus = MMS_READSTATUS_NONE;
192 pAttrib->pMultiStatus->readTime = 0;
194 pAttrib->pMultiStatus = pAttrib->pMultiStatus->pNext;
198 char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType)
200 MSG_DEBUG("MmsComposeAddress");
204 char pString[MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3] = {0, };
207 nAddressCnt = pMsgInfo->nAddressCnt;
209 // Calculate allocated buffer size
210 for (int i = 0; i < nAddressCnt; ++i) {
211 MSG_DEBUG("recipientType: %d, address value: %s", pMsgInfo->addressList[i].recipientType, pMsgInfo->addressList[i].addressVal);
212 if (pMsgInfo->addressList[i].recipientType == recipientType) {
213 if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_PLMN) {
214 addrLen += strlen(MsgGetString(MSG_ADDR_TYPE, MSG_ADDR_TYPE_PHONE));
215 addrLen += strlen(pMsgInfo->addressList[i].addressVal);
216 } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) {
217 addrLen += strlen(pMsgInfo->addressList[i].addressVal);
219 ; // Need to consider IPV4, IPV6, and Alias formatted address
226 addrLen = addrLen + nRecpCnt - 1;
227 szCompose = (char *)calloc(addrLen + 1, 1);
229 // Address String copy
230 for (int i = 0; i < nAddressCnt; ++i) {
231 if (pMsgInfo->addressList[i].recipientType == recipientType) {
232 if (strlen(szCompose) > 0)
233 strcat(szCompose, MSG_STR_ADDR_DELIMETER);
235 memset(pString, 0x00, (MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3) * sizeof(char));
236 if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_PLMN) {
237 snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s%s", pMsgInfo->addressList[i].addressVal, MsgGetString(MSG_ADDR_TYPE, MSG_ADDR_TYPE_PHONE));
238 MSG_DEBUG("%s", pString);
239 } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) {
240 snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s", pMsgInfo->addressList[i].addressVal);
242 ; // Need to consider IPV4, IPV6, and Alias formatted address
244 strcat(szCompose, pString);
252 bool MmsGetMsgBodyfromMsgInfo(const MSG_MESSAGE_INFO_S *pMsgInfo, MMS_MESSAGE_DATA_S *pMsgBody, char *pFileData)
254 MSG_DEBUG("MmsGetMsgBodyfromMsgInfo");
255 memset(pMsgBody, 0, sizeof(MMS_MESSAGE_DATA_S));
257 if (pMsgInfo->bTextSms == false) { //if the message body was stored in file.
258 _MsgMmsDeserializeMessageData(pMsgBody, pFileData);
264 int MmsGetSmilRawData(MMS_MESSAGE_DATA_S *pMsgBody, char **pRawdata)
268 if (MsgReadSmilFile(pMsgBody->szSmilFilePath, pRawdata) < 0)
271 MsgDeleteSmilFile(pMsgBody->szSmilFilePath);
279 bool MmsInsertPresentation(MmsMsg *pMsg, MsgContentType mimeType, char *pData, int size)
281 MSG_DEBUG("MmsInsertPresentation");
284 MSG_DEBUG("pMsg is NULL");
288 if (pMsg->msgBody.pPresentationBody != NULL)
291 memset(&pMsg->msgBody.presentationType, 0, sizeof(MsgType));
292 pMsg->msgBody.pPresentationBody = (MsgBody *)malloc(sizeof(MsgBody));
293 if (pMsg->msgBody.pPresentationBody == NULL)
296 MmsInitMsgBody(pMsg->msgBody.pPresentationBody);
298 pMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(size + 1);
299 if (pMsg->msgBody.pPresentationBody->body.pText == NULL)
302 pMsg->msgBody.pPresentationBody->size = size;
303 pMsg->msgBody.presentationType.type = mimeType;
304 pMsg->msgBody.presentationType.param.charset = MSG_CHARSET_UTF8;
305 snprintf(pMsg->msgBody.presentationType.szContentID, MSG_MSG_ID_LEN + 1, "<_S_>");
307 snprintf(pMsg->msgType.param.szStart, MSG_MSG_ID_LEN + 1, "%s", pMsg->msgBody.presentationType.szContentID);
308 pMsg->msgType.param.type = mimeType;
310 memset(pMsg->msgBody.pPresentationBody->body.pText, 0, size + 1);
311 strncpy(pMsg->msgBody.pPresentationBody->body.pText, pData, size);
317 if (pMsg->msgBody.pPresentationBody != NULL) {
318 if (pMsg->msgBody.pPresentationBody->body.pText != NULL) {
319 free(pMsg->msgBody.pPresentationBody->body.pText);
320 pMsg->msgBody.pPresentationBody->body.pText = NULL;
323 free(pMsg->msgBody.pPresentationBody);
324 pMsg->msgBody.pPresentationBody = NULL;
331 bool MmsInsertPartFromFile(MmsMsg *pMsg, char *szTitleName, char *szOrgFilePath, char *szContentID)
333 MSG_DEBUG("MmsInsertPartFromFile");
335 MsgMultipart *pMultipart = NULL;
336 MsgMultipart *pLastPart = NULL;
338 MsgContentType mimeType = MIME_UNKNOWN;
341 pExt = strrchr(szOrgFilePath, '.');
343 if (pExt == NULL || pExt[0] == '\0' || strrchr(pExt, '/'))
344 mimeType = MIME_UNKNOWN;
346 if (strcasecmp(pExt, ".dcf") == 0)
347 mimeType = MIME_APPLICATION_VND_OMA_DRM_CONTENT;
349 if (MmsGetTypeByFileName((int *)&mimeType, szOrgFilePath) == false)
354 if (mimeType == MIME_UNKNOWN)
355 mimeType = MIME_APPLICATION_OCTET_STREAM;
357 if (MmsIsMultipart(pMsg->msgType.type) == true) {
358 /* Insert as a multipart */
359 if (MsgGetFileSize(szOrgFilePath, &nFileSize) == false) {
360 MSG_DEBUG("MsgGetFileSize: failed");
364 pMultipart = MmsMakeMultipart(mimeType, szTitleName, szOrgFilePath, NULL, 0, nFileSize, szContentID);
365 if (pMultipart == NULL)
368 if (pMsg->mmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED ||
369 pMsg->mmsAttrib.contentType == MIME_MULTIPART_MIXED)
370 pMultipart->type.disposition = MSG_DISPOSITION_ATTACHMENT;
372 if (pMsg->msgBody.body.pMultipart == NULL) {
373 pMsg->msgBody.body.pMultipart = pMultipart;
375 pLastPart = pMsg->msgBody.body.pMultipart;
376 while (pLastPart->pNext) {
377 pLastPart = pLastPart->pNext;
380 pLastPart->pNext = pMultipart;
383 pMsg->msgBody.size += pMultipart->pBody->size;
384 pMsg->msgType.contentSize += pMultipart->pBody->size;
386 /* Single part - Insert as a message body */
387 if (pMsg->mmsAttrib.contentType != mimeType || pMsg->msgType.type != mimeType)
390 strncpy(pMsg->msgType.param.szName, szTitleName, MSG_LOCALE_FILENAME_LEN_MAX);
392 if (MmsIsText(pMsg->msgType.type) == true) {
393 pMsg->msgType.param.charset = MSG_CHARSET_UTF8;
395 pMultipart->type.encoding = MSG_ENCODING_8BIT;
398 pMultipart->type.encoding = MSG_ENCODING_BINARY;
401 strncpy(pMsg->msgBody.szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1);
402 if (MsgGetFileSize(szOrgFilePath, &nFileSize) == false) {
403 MSG_DEBUG("MsgGetFileSize: failed");
407 pMsg->msgBody.offset = 0;
408 pMsg->msgBody.size = nFileSize;
409 pMsg->msgType.contentSize = nFileSize;
421 bool MmsIsMultipart(int type)
423 MSG_DEBUG("MmsIsMultipart");
424 if (type == MIME_MULTIPART_RELATED ||
425 type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED ||
426 type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED ||
427 type == MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC ||
428 type == MIME_MULTIPART_MIXED ||
429 type == MIME_MULTIPART_REPORT) {
436 bool MmsIsText(int type)
438 if (type == MIME_TEXT_PLAIN ||
439 type == MIME_TEXT_HTML ||
440 type == MIME_TEXT_VND_WAP_WML ||
441 type == MIME_TEXT_X_VCARD ||
442 type == MIME_TEXT_X_VCALENDAR ||
443 type == MIME_TEXT_X_VNOTE ||
444 type == MIME_APPLICATION_SMIL ||
445 type == MIME_TEXT_X_IMELODY) {
446 MSG_DEBUG("MmsIsText true.");
449 MSG_DEBUG("MmsIsText false.");
454 bool MmsIsVitemContent (int type, char *pszName)
459 * To make Encoding information right.
460 * case MIME_TEXT_X_VCARD :
461 * case MIME_TEXT_X_VCALENDAR :
462 * case MIME_TEXT_X_VNOTE : // vnt
464 * MSG_DEBUG("MmsIsVitemContent true.");
469 case MIME_TEXT_X_VCARD:
470 case MIME_TEXT_X_VCALENDAR:
471 case MIME_TEXT_X_VNOTE: // vnt
472 case MIME_TEXT_PLAIN: // vbm - It SHOULD be distinguished from a normal text file.
479 // search file extension.
480 if ((pszExt = strrchr(pszName, '.')) == NULL)
483 if (!strcasecmp(pszExt, ".vbm")) {
484 MSG_DEBUG("MmsIsVitemContent true.");
494 MSG_DEBUG("MmsIsVitemContent false.");
500 MsgMultipart *MmsAllocMultipart(void)
502 MsgMultipart *pMultipart = NULL;
504 pMultipart = (MsgMultipart *)malloc(sizeof(MsgMultipart));
506 if (pMultipart == NULL)
509 pMultipart->pBody = (MsgBody *)malloc(sizeof(MsgBody));
511 if (pMultipart == NULL)
514 MmsInitMsgType(&pMultipart->type);
515 MmsInitMsgBody(pMultipart->pBody);
517 pMultipart->pNext = NULL;
524 if (pMultipart->pBody) {
525 free(pMultipart->pBody);
526 pMultipart->pBody = NULL;
538 MsgMultipart *MmsMakeMultipart(MsgContentType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID)
540 MsgMultipart *pMultipart = NULL;
542 if ((pMultipart = MmsAllocMultipart()) == NULL)
545 pMultipart->type.type = mimeType;
547 if (szTitleName && szTitleName[0]) {
548 memset(pMultipart->type.param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1);
549 strncpy(pMultipart->type.param.szName, szTitleName, MSG_LOCALE_FILENAME_LEN_MAX);
552 if (szContentID && szContentID[0]) {
553 memset(pMultipart->type.szContentID, 0, MSG_MSG_ID_LEN + 1);
554 snprintf(pMultipart->type.szContentID, MSG_MSG_ID_LEN + 1, "<%s>", szContentID);
556 memset(pMultipart->type.szContentLocation, 0, MSG_MSG_ID_LEN + 1);
557 snprintf(pMultipart->type.szContentLocation, MSG_MSG_ID_LEN + 1, "%s", szContentID);
560 if (MmsIsText(mimeType) == true) {
561 if (!MmsIsVitemContent (mimeType, pMultipart->type.param.szName)) {
562 pMultipart->type.param.charset = MSG_CHARSET_UTF8;
564 pMultipart->type.encoding = MSG_ENCODING_8BIT;
566 pMultipart->type.encoding = MSG_ENCODING_BINARY;
569 if (szOrgFilePath == NULL) {
571 if (MmsIsText(mimeType) == true) {
572 pMultipart->pBody->body.pText = (char *)malloc(size + 1);
573 if (pMultipart->pBody->body.pText == NULL)
576 memset(pMultipart->pBody->body.pText, 0, size + 1);
578 pMultipart->pBody->body.pBinary = malloc(size);
579 if (pMultipart->pBody->body.pBinary == NULL)
582 memset(pMultipart->pBody->body.pBinary, 0, size);
585 memcpy(pMultipart->pBody->body.pBinary, pData, size);
586 pMultipart->pBody->size = size;
590 strncpy(pMultipart->pBody->szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1);
592 pMultipart->pBody->offset = offset;
593 pMultipart->pBody->size = size;
601 if (pMultipart->pBody) {
602 if (pMultipart->pBody->body.pText) {
603 free(pMultipart->pBody->body.pText);
604 pMultipart->pBody->body.pText = NULL;
606 free(pMultipart->pBody);
607 pMultipart->pBody = NULL;
617 bool MmsGetTypeByFileName(int *type, char *szFileName)
620 AvCodecType AvType = AV_CODEC_NONE;
622 /* AVMS unknown or text/image file format identify type from file extention */
624 pExt = strrchr(szFileName, '.');
625 if (pExt == NULL || pExt[0] == '\0')
630 if (strcasecmp(pExt, "mp4") == 0 || strcasecmp(pExt, "mpeg4") == 0 ||
631 strcasecmp(pExt, "3gp") == 0 || strcasecmp(pExt, "3gpp") == 0) {
632 /* Audio / Video format. If file exists already, AvGetFileCodecType() can identify the format */
633 if (szFileName[0] != '/')
636 AvType = AvGetFileCodecType(szFileName);
639 case AV_DEC_AUDIO_MPEG4:
640 *type = MIME_AUDIO_MP4;//*type = MIME_AUDIO_3GPP;
643 case AV_DEC_VIDEO_MPEG4:
644 *type = MIME_VIDEO_MP4;
648 *type = MIME_VIDEO_3GPP;
654 if (strcasecmp(pExt, "amr") == 0) {
655 *type = MIME_AUDIO_AMR;
657 } else if ((strcasecmp(pExt, "mid") == 0) || (strcasecmp(pExt, "midi") == 0)) {
658 *type = MIME_AUDIO_MIDI;
660 } else if (strcasecmp(pExt, "imy") == 0) {
661 *type = MIME_TEXT_X_IMELODY;
665 *type = MimeGetMimeFromExtInt((const char *)pExt);
671 *type = MIME_UNKNOWN;
676 bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMsgData, char *pFileData)
680 char *pRawData = NULL;
681 AutoPtr<char> buf(&pRawData);
683 struct tm *timeInfo = NULL;
685 time_t nTimeInSecs = 0;
687 msg_error_t err = MSG_SUCCESS;
689 // Initialize mmsMsg structure
690 MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
691 MmsInitMsgType(&pMmsMsg->msgType);
692 MmsInitMsgBody(&pMmsMsg->msgBody);
694 // setting mmsMsg structure
695 pMmsMsg->mailbox = pMsgInfo->folderId;
696 pMmsMsg->msgID = pMsgInfo->msgId;
698 memset(pMmsMsg->szTrID, 0, MMS_TR_ID_LEN + 1);
699 memset(pMmsMsg->szContentLocation, 0, MMS_LOCATION_LEN + 1);
700 memset(pMmsMsg->szMsgID, 0, MMS_MSG_ID_LEN + 1);
701 memset(pMmsMsg->szForwardMsgID, 0, MMS_MSG_ID_LEN + 1);
703 pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT;
705 MSG_DEBUG("## delivery = %d ##", pSendOptInfo->bDeliverReq);
706 MSG_DEBUG("## read = %d ##", pSendOptInfo->option.mmsSendOptInfo.bReadReq);
707 MSG_DEBUG("## priority = %d ##", pSendOptInfo->option.mmsSendOptInfo.priority);
708 MSG_DEBUG("## expiryTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.expiryTime.time);
710 if (pSendOptInfo->bSetting == false) {
711 unsigned int expiryTime;
712 MSG_MMS_DELIVERY_TIME_T deliveryTime;
714 pMmsMsg->mmsAttrib.priority = (MmsPriority)MsgSettingGetInt(MMS_SEND_PRIORITY);
716 MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &pMmsMsg->mmsAttrib.bAskDeliveryReport);
717 MsgSettingGetBool(MMS_SEND_READ_REPLY, &pMmsMsg->mmsAttrib.bAskReadReply);
718 MsgSettingGetBool(MSG_KEEP_COPY, &pMmsMsg->mmsAttrib.bLeaveCopy);
720 expiryTime = (unsigned int)MsgSettingGetInt(MMS_SEND_EXPIRY_TIME);
723 pMmsMsg->mmsAttrib.expiryTime.type = MMS_TIMETYPE_NONE;
725 pMmsMsg->mmsAttrib.expiryTime.type = MMS_TIMETYPE_RELATIVE;
726 pMmsMsg->mmsAttrib.expiryTime.time = expiryTime;
729 deliveryTime = (MSG_MMS_DELIVERY_TIME_T)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
731 if (deliveryTime == MSG_DELIVERY_TIME_CUSTOM) {
732 pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = true;
734 pMmsMsg->mmsAttrib.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
735 pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY);
737 pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = false;
739 pMmsMsg->mmsAttrib.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
740 pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)deliveryTime;
743 pMmsMsg->mmsAttrib.priority = (MmsPriority)pSendOptInfo->option.mmsSendOptInfo.priority;
744 pMmsMsg->mmsAttrib.bAskDeliveryReport = pSendOptInfo->bDeliverReq;
745 pMmsMsg->mmsAttrib.bAskReadReply = pSendOptInfo->option.mmsSendOptInfo.bReadReq;
746 pMmsMsg->mmsAttrib.expiryTime.type = pSendOptInfo->option.mmsSendOptInfo.expiryTime.type;
747 pMmsMsg->mmsAttrib.bLeaveCopy = pSendOptInfo->bKeepCopy;
749 if (pMmsMsg->mmsAttrib.expiryTime.type != MMS_TIMETYPE_NONE)
750 pMmsMsg->mmsAttrib.expiryTime.time = pSendOptInfo->option.mmsSendOptInfo.expiryTime.time;
752 pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime;
753 pMmsMsg->mmsAttrib.deliveryTime.type = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.type;
754 pMmsMsg->mmsAttrib.deliveryTime.time = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time;
757 MSG_DEBUG("pSendOptInfo->bSetting = %d", pSendOptInfo->bSetting);
758 MSG_DEBUG("pMmsMsg->mmsAttrib.bLeaveCopy = %d", pMmsMsg->mmsAttrib.bLeaveCopy);
759 MSG_DEBUG("pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = %d", pMmsMsg->mmsAttrib.bUseDeliveryCustomTime);
760 MSG_DEBUG("pMmsMsg->mmsAttrib.deliveryTime.type = %d", pMmsMsg->mmsAttrib.deliveryTime.type);
761 MSG_DEBUG("pMmsMsg->mmsAttrib.deliveryTime.time = %d", pMmsMsg->mmsAttrib.deliveryTime.time);
763 /* MMS-1.3-con-739 */
764 pMmsMsg->mmsAttrib.msgClass = (MmsMsgClass)MsgSettingGetInt(MMS_SEND_MSG_CLASS);
765 /* MMS-1.3-con-739 */
766 #ifdef MMS_13_CON_742_ENABLED
767 /* MMS-1.3-con-742 */
768 pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
769 /* MMS-1.3-con-742 */
772 MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.bAskDeliveryReport = %d @@@", pMmsMsg->mmsAttrib.bAskDeliveryReport);
773 MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.bAskReadReply = %d @@@", pMmsMsg->mmsAttrib.bAskReadReply);
774 MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.priority = %d @@@", pMmsMsg->mmsAttrib.priority);
778 timeInfo = localtime(&RawTime);
779 nTimeInSecs = mktime(timeInfo);
780 pMmsMsg->mmsAttrib.date = nTimeInSecs;
783 strcpy(pMmsMsg->mmsAttrib.szSubject, pMsgInfo->subject);
786 MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo);
787 MmsGetMsgBodyfromMsgInfo(pMsgInfo, pMsgData, pFileData);
789 int pageCnt = _MsgMmsGetPageCount(pMsgData);
791 if (pageCnt == 0) { // Multipart mixed
792 pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED;
793 pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED;
794 MmsMakePreviewInfo(pMsgInfo->msgId, pMsgData);
795 } else { // Multipart related
801 snprintf(pMsgData->szSmilFilePath, MSG_FILEPATH_LEN_MAX, "%lu", RawTime);
803 MsgMMSCreateSMIL(pMsgData);
805 RawDataSize = MmsGetSmilRawData(pMsgData, &pRawData);
806 if (RawDataSize < 0) {
807 MSG_DEBUG("Smil file size is less than 0");
810 MSG_DEBUG("%s", pRawData);
812 MmsInsertPresentation(pMmsMsg, MIME_APPLICATION_SMIL, pRawData, strlen(pRawData));
814 pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED;
815 pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED;
817 for (int i = 0; i < pageCnt; ++i) {
818 MMS_PAGE_S *pPage = _MsgMmsGetPage(pMsgData, i);
819 int mediaCnt = pPage->mediaCnt;
820 MSG_DEBUG("PAGE %d's media Cnt: %d", i+1, mediaCnt);
822 for (int j = 0; j < mediaCnt; ++j) {
823 MMS_MEDIA_S *pMedia = _MsgMmsGetMedia(pPage, j);
825 switch (pMedia->mediatype) {
826 case MMS_SMIL_MEDIA_IMG:
827 case MMS_SMIL_MEDIA_VIDEO:
828 case MMS_SMIL_MEDIA_AUDIO:
829 case MMS_SMIL_MEDIA_TEXT:
830 if (pMedia->szFilePath[0] != 0) {
831 if (!MmsInsertPartFromFile(pMmsMsg, pMedia->szFileName, pMedia->szFilePath, pMedia->szContentID))
842 char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };;
843 snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%d.mms", pMsgInfo->msgId);
845 MmsPluginStorage *pStorage = MmsPluginStorage::instance();
846 err = pStorage->getMsgText(pMsgData, pMsgInfo->msgText);
847 MmsMakePreviewInfo(pMsgInfo->msgId, pMsgData);
850 #ifdef FEATURE_JAVA_MMS
851 MSG_DEBUG("msgAppId: valid:%d appId:%s replyToAppId:%s", pMsgData->msgAppId.valid, pMsgData->msgAppId.appId, pMsgData->msgAppId.replyToAppId);
852 if (pMsgData->msgAppId.valid) { // check if msgAppId.valid is true, both appId and replytoappId must have a meaning data
853 if (pMsgData->msgAppId.appId[0] != 0) {
854 pMmsMsg->msgType.param.szApplicationID = (char *)malloc(strlen(pMsgData->msgAppId.appId) + 1);
855 if (pMmsMsg->msgType.param.szApplicationID == NULL) {
856 MSG_DEBUG("Error: out of Memory");
859 memset(pMmsMsg->msgType.param.szApplicationID, 0, strlen(pMsgData->msgAppId.appId) + 1);
861 strcpy(pMmsMsg->msgType.param.szApplicationID, pMsgData->msgAppId.appId);
864 if (pMsgData->msgAppId.replyToAppId[0] != 0) {
865 pMmsMsg->msgType.param.szReplyToApplicationID = (char *)malloc(strlen(pMsgData->msgAppId.replyToAppId) + 1);
866 if (pMmsMsg->msgType.param.szReplyToApplicationID == NULL) {
867 MSG_DEBUG("Error: out of Memory");
870 memset(pMmsMsg->msgType.param.szReplyToApplicationID, 0, strlen(pMsgData->msgAppId.replyToAppId) + 1);
872 strcpy(pMmsMsg->msgType.param.szReplyToApplicationID, pMsgData->msgAppId.replyToAppId);
877 //Processing Attachment List
878 for (int i = 0; i < _MsgMmsGetAttachCount(pMsgData); ++i) {
879 MMS_ATTACH_S *pMedia = _MsgMmsGetAttachment(pMsgData, i);
880 if (pMedia->szFilePath[0] != 0) {
881 if (!MmsInsertPartFromFile(pMmsMsg, pMedia->szFileName, pMedia->szFilePath, NULL))
889 void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID)
893 struct tm *timeInfo = NULL;
895 time_t nTimeInSecs = 0;
897 MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
898 MmsInitMsgType(&pMmsMsg->msgType);
899 MmsInitMsgBody(&pMmsMsg->msgBody);
901 pMmsMsg->msgID = msgID;
903 pMmsMsg->mmsAttrib.version = mmsHeader.version;
907 timeInfo = localtime(&RawTime);
908 nTimeInSecs = mktime(timeInfo);
909 pMmsMsg->mmsAttrib.date = nTimeInSecs;
911 pMmsMsg->mmsAttrib.bReportAllowed = mmsHeader.reportAllowed;
912 pMmsMsg->mmsAttrib.bAskDeliveryReport = mmsHeader.deliveryReport;
914 MSG_DEBUG("######## Version = %d ########", pMmsMsg->mmsAttrib.version);
916 strncpy(pMmsMsg->szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN);
917 strncpy(pMmsMsg->szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN);
918 pMmsMsg->szForwardMsgID[0] = '\0';
920 if (mmsHeader.pFrom) {
921 MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr );
922 strncpy(pMmsMsg->mmsAttrib.szFrom, mmsHeader.pFrom->szAddr, MSG_LOCALE_ADDR_LEN + 9);
925 strncpy(pMmsMsg->mmsAttrib.szSubject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
926 strncpy(pMmsMsg->szContentLocation, mmsHeader.szContentLocation, MMS_LOCATION_LEN);
928 pMmsMsg->mmsAttrib.msgClass = mmsHeader.msgClass;
929 pMmsMsg->mmsAttrib.msgSize = mmsHeader.msgSize;
930 pMmsMsg->mmsAttrib.expiryTime.type = mmsHeader.expiryTime.type;
931 pMmsMsg->mmsAttrib.expiryTime.time = mmsHeader.expiryTime.time;
932 pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_NOTIFY;
933 pMmsMsg->mmsAttrib.bRead = false;
934 pMmsMsg->mailbox = MSG_INBOX_ID;
936 pMmsMsg->mmsAttrib.replyCharge.chargeType = mmsHeader.replyCharge.chargeType;
937 pMmsMsg->mmsAttrib.replyCharge.deadLine.type = mmsHeader.replyCharge.deadLine.type;
938 pMmsMsg->mmsAttrib.replyCharge.deadLine.time = mmsHeader.replyCharge.deadLine.time;
939 pMmsMsg->mmsAttrib.replyCharge.chargeSize = mmsHeader.replyCharge.chargeSize;
941 strncpy(pMmsMsg->mmsAttrib.replyCharge.szChargeID, mmsHeader.replyCharge.szChargeID, MMS_MSG_ID_LEN);
946 bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath)
949 MsgMultipart *pMultipart = NULL;
950 int attachmax = MSG_ATTACH_MAX;
953 /* read from MMS raw file */
954 if (retrievedFilePath)
955 strncpy(pMmsMsg->szFileName, retrievedFilePath + strlen(MSG_DATA_PATH), strlen(retrievedFilePath + strlen(MSG_DATA_PATH)));
959 pFile = MsgOpenFile(retrievedFilePath, "rb");
962 MSG_DEBUG( "_MmsReadMsgBody: invalid mailbox\n");
966 if (MsgGetFileSize(retrievedFilePath, &nSize) == false) {
967 MSG_DEBUG("MsgGetFileSize: failed");
971 _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,
973 MSG_MMS_DECODE_BUFFER_MAX);
975 if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) {
976 MSG_DEBUG( "_MmsReadMsgBody: MmsBinaryDecodeMsgHeader fail...\n");
980 if (MmsBinaryDecodeMsgBody(pFile, retrievedFilePath, nSize) == false) {
981 MSG_DEBUG( "_MmsReadMsgBody: MmsBinaryDecodeMsgBody fail\n");
985 /* Set mmsHeader.msgType & msgBody to pMsg ----------- */
987 pMmsMsg->mmsAttrib.contentType = (MsgContentType)mmsHeader.msgType.type;
989 memcpy(&(pMmsMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType));
990 memcpy(&(pMmsMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody));
992 MSG_DEBUG("#############################");
993 MSG_DEBUG("## pMmsMsg->msgType.type = %d ##", pMmsMsg->msgType.type);
994 MSG_DEBUG("## pMmsMsg->msgType.szContentID = %s ##", pMmsMsg->msgType.szContentID);
995 MSG_DEBUG("## pMmsMsg->msgType.szContentLocation = %s ##", pMmsMsg->msgType.szContentLocation);
996 MSG_DEBUG("#############################");
998 if (pMmsMsg->msgBody.pPresentationBody) {
999 if(MsgFseek(pFile, pMmsMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0)
1002 pMmsMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMmsMsg->msgBody.pPresentationBody->size + 1);
1003 if (pMmsMsg->msgBody.pPresentationBody->body.pText == NULL)
1006 memset(pMmsMsg->msgBody.pPresentationBody->body.pText, 0, pMmsMsg->msgBody.pPresentationBody->size + 1);
1008 nRead = MsgReadFile(pMmsMsg->msgBody.pPresentationBody->body.pText, sizeof(char), pMmsMsg->msgBody.pPresentationBody->size, pFile);
1014 MsgCloseFile(pFile);
1018 pMmsMsg->nPartCount = 0;
1020 if (MsgIsMultipart(mmsHeader.msgType.type) == true) {
1021 pMultipart = pMmsMsg->msgBody.body.pMultipart;
1022 while (pMultipart) {
1023 pMmsMsg->nPartCount++;
1025 if (pMultipart->type.type == MIME_TEXT_PLAIN)
1028 if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED) ||
1029 (mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) {
1030 if ((pMmsMsg->nPartCount >= attachmax ) && (pMultipart->pNext != NULL)) {
1031 _MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type);
1033 free(pMultipart->pNext->pBody);
1034 pMultipart->pNext->pBody = NULL;
1036 free(pMultipart->pNext);
1038 pMultipart->pNext = NULL;
1042 pMultipart = pMultipart->pNext;
1045 if (pMmsMsg->msgBody.size > 0)
1046 pMmsMsg->nPartCount++;
1049 //call before processing urgent event.
1051 _MmsUnregisterDecodeBuffer();
1058 _MmsUnregisterDecodeBuffer();
1060 if (pFile != NULL) {
1061 MsgCloseFile(pFile);
1065 _MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type);
1066 MSG_DEBUG("_MmsReadMsgBody: E N D ( fail ) ******************** \n");
1071 #ifdef MMS_DELIEVERY_IND_ENABLED
1072 MmsMsgMultiStatus *MmsComposeDeliveryIndMessage(MmsMsg *pMmsMsg, msg_message_id_t msgId)
1074 MmsMsgMultiStatus *pStatus = NULL;
1075 MmsMsgMultiStatus *pLastStatus = NULL;
1076 bool bFound = false;
1078 MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
1079 MmsInitMsgType(&pMmsMsg->msgType);
1080 MmsInitMsgBody(&pMmsMsg->msgBody);
1082 pMmsMsg->mmsAttrib.version = mmsHeader.version;
1084 pMmsMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(msgId);
1086 pStatus = pMmsMsg->mmsAttrib.pMultiStatus;
1088 MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo);
1090 while (pStatus && !bFound) {
1091 MSG_DEBUG("### MmsAddrUtilCompareAddr ###");
1092 MSG_DEBUG("### mmsHeader.pTo->szAddr = %s ###", mmsHeader.pTo->szAddr);
1093 if (MmsAddrUtilCompareAddr(pStatus->szTo, mmsHeader.pTo->szAddr)) {
1098 pStatus = pStatus->pNext;
1101 if (bFound == false) {
1102 MSG_DEBUG("### bFound == false ###");
1103 /* Queue the delivery report --------------------------- */
1105 pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
1106 memset(pStatus, 0, sizeof(MmsMsgMultiStatus));
1108 pStatus->readStatus = MMS_READSTATUS_NONE;
1110 memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1);
1111 strncpy(pStatus->szTo, mmsHeader.pTo->szAddr, MSG_ADDR_LEN);
1113 if (pMmsMsg->mmsAttrib.pMultiStatus == NULL) {
1114 /* first delivery report */
1115 pMmsMsg->mmsAttrib.pMultiStatus = pStatus;
1117 pLastStatus = pMmsMsg->mmsAttrib.pMultiStatus;
1118 while (pLastStatus->pNext) {
1119 pLastStatus = pLastStatus->pNext;
1122 pLastStatus->pNext = pStatus;
1123 pLastStatus = pStatus;
1127 pStatus->handledTime = mmsHeader.date;
1128 pStatus->msgStatus = mmsHeader.msgStatus;
1129 pStatus->bDeliveryReportIsRead = false;
1131 _MmsDataUpdateLastStatus(pMmsMsg);
1133 pStatus->bDeliveyrReportIsLast = true;
1139 void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, msg_message_id_t selectedMsgId)
1141 struct tm *timeInfo = NULL;
1143 time_t nTimeInSecs = 0;
1145 MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
1146 MmsInitMsgType(&pMmsMsg->msgType);
1147 MmsInitMsgBody(&pMmsMsg->msgBody);
1149 // setting mmsMsg structure
1150 pMmsMsg->mailbox = pMsgInfo->folderId;
1151 pMmsMsg->msgID = pMsgInfo->msgId;
1153 memset(pMmsMsg->szTrID, 0, MMS_TR_ID_LEN + 1);
1154 memset(pMmsMsg->szContentLocation, 0, MMS_LOCATION_LEN + 1);
1155 memset(pMmsMsg->szForwardMsgID, 0, MMS_MSG_ID_LEN + 1);
1157 pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT;
1161 timeInfo = localtime(&RawTime);
1162 nTimeInSecs = mktime(timeInfo);
1163 pMmsMsg->mmsAttrib.date = nTimeInSecs;
1166 MmsPluginStorage::instance()->getMmsMessageId(selectedMsgId, pMmsMsg);
1169 strcpy(pMmsMsg->mmsAttrib.szSubject, pMsgInfo->subject);
1172 MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo);
1174 if (pMmsMsg->mmsAttrib.szTo)
1175 strncpy(pMmsMsg->mmsAttrib.szFrom, pMmsMsg->mmsAttrib.szTo, strlen(pMmsMsg->mmsAttrib.szTo));
1178 int MmsSearchMsgId(char *toNumber, char *szMsgID)
1184 msgId = MmsPluginStorage::instance()->searchMsgId(toNumber, szMsgID);
1194 MmsMsgMultiStatus *MmsGetMultiStatus(msg_message_id_t msgId)
1196 MmsMsgMultiStatus *pMultiStatus;
1198 pMultiStatus = MmsPluginStorage::instance()->getMultiStatus(msgId);
1200 MSG_DEBUG("### szTo = %s ###", pMultiStatus->szTo);
1204 return pMultiStatus;
1207 bool MmsCheckAdditionalMedia(MMS_MESSAGE_DATA_S *pMsgData, MsgType *partHeader)
1209 if (_MsgMmsFindMatchedMedia(pMsgData, partHeader->param.szFileName))
1215 #ifdef __SUPPORT_DRM__
1216 bool __MsgInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo)
1218 pMsgDrmInfo->contentType = MIME_UNKNOWN;
1219 pMsgDrmInfo->drmType = MSG_DRM_TYPE_NONE;
1221 pMsgDrmInfo->szContentName = NULL;
1222 pMsgDrmInfo->szContentURI = NULL;
1223 pMsgDrmInfo->szContentDescription = NULL;
1224 pMsgDrmInfo->szContentVendor = NULL;
1225 pMsgDrmInfo->szRightIssuer = NULL;
1226 pMsgDrmInfo->szDrm2FullPath = NULL;
1227 pMsgDrmInfo->roWaitingTimerMax = 0;
1228 pMsgDrmInfo->bFwdLock = false;
1229 pMsgDrmInfo->bNoScreen = false;
1230 pMsgDrmInfo->bNoRingTone = false;
1231 pMsgDrmInfo->pszContentType = NULL;
1237 msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg)
1239 MMS_PAGE_S *pPage = NULL;
1240 MMS_MEDIA_S *pMedia = NULL;
1242 if (pMmsMsg == NULL)
1243 return MSG_ERR_NULL_POINTER;
1245 if (pMmsMsg->pageCnt > 0) {
1247 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_PAGE, (char *)"pagecount", pMmsMsg->pageCnt);
1249 pPage = _MsgMmsGetPage(pMmsMsg, 0);
1250 for (int j = 0; j < pPage->mediaCnt; j++) {
1252 pMedia = _MsgMmsGetMedia(pPage, j);
1253 MSG_DEBUG("pMedia's Name: %s", pMedia->szFilePath);
1255 if (pMedia->mediatype == MMS_SMIL_MEDIA_IMG || pMedia->mediatype == MMS_SMIL_MEDIA_VIDEO) {
1256 char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };
1257 char thumbPath[MSG_FILEPATH_LEN_MAX+1] = {0, };
1259 memset(szFileName, 0x00, MSG_FILENAME_LEN_MAX+1);
1260 memset(thumbPath, 0x00, MSG_FILEPATH_LEN_MAX);
1262 snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%d.mms",msgId);
1263 snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, MSG_THUMBNAIL_PATH"/%s.jpg", szFileName);
1265 if (pMedia->mediatype == MMS_SMIL_MEDIA_IMG) {
1266 if (makeImageThumbnail(pMedia->szFilePath, thumbPath) == true) {
1267 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_IMG, thumbPath);
1269 MSG_DEBUG("Fail of generating thumbnail: %s to %s", pMedia->szFilePath, thumbPath);
1272 if (makeVideoThumbnail(pMedia->szFilePath, thumbPath) == true) {;
1273 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_VIDEO, thumbPath);
1275 MSG_DEBUG("Fail of generating thumbnail: %s to %s", pMedia->szFilePath, thumbPath);
1279 } else if (pMedia->mediatype == MMS_SMIL_MEDIA_AUDIO) {
1280 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_AUDIO, pMedia->szFileName);
1284 MSG_DEBUG("There is no page");
1287 int attachCnt = _MsgMmsGetAttachCount(pMmsMsg);
1288 if (attachCnt > 0) {
1289 MMS_ATTACH_S *pAttach = _MsgMmsGetAttachment(pMmsMsg, 0);
1290 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_ATTACH, pAttach->szFileName, attachCnt);
1292 MSG_DEBUG("There is no attachment");