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;
396 strncpy(pMsg->msgBody.szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1);
397 if (MsgGetFileSize(szOrgFilePath, &nFileSize) == false) {
398 MSG_DEBUG("MsgGetFileSize: failed");
402 pMsg->msgBody.offset = 0;
403 pMsg->msgBody.size = nFileSize;
404 pMsg->msgType.contentSize = nFileSize;
416 bool MmsIsMultipart(int type)
418 MSG_DEBUG("MmsIsMultipart");
419 if (type == MIME_MULTIPART_RELATED ||
420 type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED ||
421 type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED ||
422 type == MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC ||
423 type == MIME_MULTIPART_MIXED ||
424 type == MIME_MULTIPART_REPORT) {
431 bool MmsIsText(int type)
433 if (type == MIME_TEXT_PLAIN ||
434 type == MIME_TEXT_HTML ||
435 type == MIME_TEXT_VND_WAP_WML ||
436 type == MIME_TEXT_X_VCARD ||
437 type == MIME_TEXT_X_VCALENDAR ||
438 type == MIME_TEXT_X_VNOTE ||
439 type == MIME_APPLICATION_SMIL ||
440 type == MIME_TEXT_X_IMELODY) {
441 MSG_DEBUG("MmsIsText true.");
444 MSG_DEBUG("MmsIsText false.");
449 bool MmsIsVitemContent (int type, char *pszName)
454 * To make Encoding information right.
455 * case MIME_TEXT_X_VCARD :
456 * case MIME_TEXT_X_VCALENDAR :
457 * case MIME_TEXT_X_VNOTE : // vnt
459 * MSG_DEBUG("MmsIsVitemContent true.");
464 case MIME_TEXT_X_VCARD:
465 case MIME_TEXT_X_VCALENDAR:
466 case MIME_TEXT_X_VNOTE: // vnt
467 case MIME_TEXT_PLAIN: // vbm - It SHOULD be distinguished from a normal text file.
474 // search file extension.
475 if ((pszExt = strrchr(pszName, '.')) == NULL)
478 if (!strcasecmp(pszExt, ".vbm")) {
479 MSG_DEBUG("MmsIsVitemContent true.");
489 MSG_DEBUG("MmsIsVitemContent false.");
495 MsgMultipart *MmsAllocMultipart(void)
497 MsgMultipart *pMultipart = NULL;
499 pMultipart = (MsgMultipart *)malloc(sizeof(MsgMultipart));
501 if (pMultipart == NULL)
504 pMultipart->pBody = (MsgBody *)malloc(sizeof(MsgBody));
506 if (pMultipart->pBody == NULL)
509 MmsInitMsgType(&pMultipart->type);
510 MmsInitMsgBody(pMultipart->pBody);
512 pMultipart->pNext = NULL;
519 if (pMultipart->pBody) {
520 free(pMultipart->pBody);
521 pMultipart->pBody = NULL;
533 MsgMultipart *MmsMakeMultipart(MsgContentType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID)
535 MsgMultipart *pMultipart = NULL;
537 if ((pMultipart = MmsAllocMultipart()) == NULL)
540 pMultipart->type.type = mimeType;
542 if (szTitleName && szTitleName[0]) {
543 memset(pMultipart->type.param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1);
544 strncpy(pMultipart->type.param.szName, szTitleName, MSG_LOCALE_FILENAME_LEN_MAX);
547 if (szContentID && szContentID[0]) {
548 memset(pMultipart->type.szContentID, 0, MSG_MSG_ID_LEN + 1);
549 snprintf(pMultipart->type.szContentID, MSG_MSG_ID_LEN + 1, "<%s>", szContentID);
551 memset(pMultipart->type.szContentLocation, 0, MSG_MSG_ID_LEN + 1);
552 snprintf(pMultipart->type.szContentLocation, MSG_MSG_ID_LEN + 1, "%s", szContentID);
555 if (MmsIsText(mimeType) == true) {
556 if (!MmsIsVitemContent (mimeType, pMultipart->type.param.szName)) {
557 pMultipart->type.param.charset = MSG_CHARSET_UTF8;
559 pMultipart->type.encoding = MSG_ENCODING_8BIT;
561 pMultipart->type.encoding = MSG_ENCODING_BINARY;
564 if (szOrgFilePath == NULL) {
566 if (MmsIsText(mimeType) == true) {
567 pMultipart->pBody->body.pText = (char *)malloc(size + 1);
568 if (pMultipart->pBody->body.pText == NULL)
571 memset(pMultipart->pBody->body.pText, 0, size + 1);
573 pMultipart->pBody->body.pBinary = malloc(size);
574 if (pMultipart->pBody->body.pBinary == NULL)
577 memset(pMultipart->pBody->body.pBinary, 0, size);
580 memcpy(pMultipart->pBody->body.pBinary, pData, size);
581 pMultipart->pBody->size = size;
585 strncpy(pMultipart->pBody->szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1);
587 pMultipart->pBody->offset = offset;
588 pMultipart->pBody->size = size;
596 if (pMultipart->pBody) {
597 if (pMultipart->pBody->body.pText) {
598 free(pMultipart->pBody->body.pText);
599 pMultipart->pBody->body.pText = NULL;
601 free(pMultipart->pBody);
602 pMultipart->pBody = NULL;
612 bool MmsGetTypeByFileName(int *type, char *szFileName)
615 AvCodecType AvType = AV_CODEC_NONE;
617 /* AVMS unknown or text/image file format identify type from file extention */
619 pExt = strrchr(szFileName, '.');
620 if (pExt == NULL || pExt[0] == '\0')
625 if (strcasecmp(pExt, "mp4") == 0 || strcasecmp(pExt, "mpeg4") == 0 ||
626 strcasecmp(pExt, "3gp") == 0 || strcasecmp(pExt, "3gpp") == 0) {
627 /* Audio / Video format. If file exists already, AvGetFileCodecType() can identify the format */
628 if (szFileName[0] != '/')
631 AvType = AvGetFileCodecType(szFileName);
634 case AV_DEC_AUDIO_MPEG4:
635 *type = MIME_AUDIO_MP4;//*type = MIME_AUDIO_3GPP;
638 case AV_DEC_VIDEO_MPEG4:
639 *type = MIME_VIDEO_MP4;
643 *type = MIME_VIDEO_3GPP;
649 if (strcasecmp(pExt, "amr") == 0) {
650 *type = MIME_AUDIO_AMR;
652 } else if ((strcasecmp(pExt, "mid") == 0) || (strcasecmp(pExt, "midi") == 0)) {
653 *type = MIME_AUDIO_MIDI;
655 } else if (strcasecmp(pExt, "imy") == 0) {
656 *type = MIME_TEXT_X_IMELODY;
660 *type = MimeGetMimeFromExtInt((const char *)pExt);
666 *type = MIME_UNKNOWN;
671 bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMsgData, char *pFileData)
675 char *pRawData = NULL;
676 AutoPtr<char> buf(&pRawData);
678 struct tm *timeInfo = NULL;
680 time_t nTimeInSecs = 0;
682 msg_error_t err = MSG_SUCCESS;
684 // Initialize mmsMsg structure
685 MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
686 MmsInitMsgType(&pMmsMsg->msgType);
687 MmsInitMsgBody(&pMmsMsg->msgBody);
689 // setting mmsMsg structure
690 pMmsMsg->mailbox = pMsgInfo->folderId;
691 pMmsMsg->msgID = pMsgInfo->msgId;
693 memset(pMmsMsg->szTrID, 0, MMS_TR_ID_LEN + 1);
694 memset(pMmsMsg->szContentLocation, 0, MMS_LOCATION_LEN + 1);
695 memset(pMmsMsg->szMsgID, 0, MMS_MSG_ID_LEN + 1);
696 memset(pMmsMsg->szForwardMsgID, 0, MMS_MSG_ID_LEN + 1);
698 pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT;
700 MSG_DEBUG("## delivery = %d ##", pSendOptInfo->bDeliverReq);
701 MSG_DEBUG("## read = %d ##", pSendOptInfo->option.mmsSendOptInfo.bReadReq);
702 MSG_DEBUG("## priority = %d ##", pSendOptInfo->option.mmsSendOptInfo.priority);
703 MSG_DEBUG("## expiryTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.expiryTime.time);
705 if (pSendOptInfo->bSetting == false) {
706 unsigned int expiryTime;
707 MSG_MMS_DELIVERY_TIME_T deliveryTime;
709 pMmsMsg->mmsAttrib.priority = (MmsPriority)MsgSettingGetInt(MMS_SEND_PRIORITY);
711 MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &pMmsMsg->mmsAttrib.bAskDeliveryReport);
712 MsgSettingGetBool(MMS_SEND_READ_REPLY, &pMmsMsg->mmsAttrib.bAskReadReply);
713 MsgSettingGetBool(MSG_KEEP_COPY, &pMmsMsg->mmsAttrib.bLeaveCopy);
715 expiryTime = (unsigned int)MsgSettingGetInt(MMS_SEND_EXPIRY_TIME);
718 pMmsMsg->mmsAttrib.expiryTime.type = MMS_TIMETYPE_NONE;
720 pMmsMsg->mmsAttrib.expiryTime.type = MMS_TIMETYPE_RELATIVE;
721 pMmsMsg->mmsAttrib.expiryTime.time = expiryTime;
724 deliveryTime = (MSG_MMS_DELIVERY_TIME_T)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
726 if (deliveryTime == MSG_DELIVERY_TIME_CUSTOM) {
727 pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = true;
729 pMmsMsg->mmsAttrib.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
730 pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY);
732 pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = false;
734 pMmsMsg->mmsAttrib.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
735 pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)deliveryTime;
738 pMmsMsg->mmsAttrib.priority = (MmsPriority)pSendOptInfo->option.mmsSendOptInfo.priority;
739 pMmsMsg->mmsAttrib.bAskDeliveryReport = pSendOptInfo->bDeliverReq;
740 pMmsMsg->mmsAttrib.bAskReadReply = pSendOptInfo->option.mmsSendOptInfo.bReadReq;
741 pMmsMsg->mmsAttrib.expiryTime.type = pSendOptInfo->option.mmsSendOptInfo.expiryTime.type;
742 pMmsMsg->mmsAttrib.bLeaveCopy = pSendOptInfo->bKeepCopy;
744 if (pMmsMsg->mmsAttrib.expiryTime.type != MMS_TIMETYPE_NONE)
745 pMmsMsg->mmsAttrib.expiryTime.time = pSendOptInfo->option.mmsSendOptInfo.expiryTime.time;
747 pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime;
748 pMmsMsg->mmsAttrib.deliveryTime.type = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.type;
749 pMmsMsg->mmsAttrib.deliveryTime.time = pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time;
752 MSG_DEBUG("pSendOptInfo->bSetting = %d", pSendOptInfo->bSetting);
753 MSG_DEBUG("pMmsMsg->mmsAttrib.bLeaveCopy = %d", pMmsMsg->mmsAttrib.bLeaveCopy);
754 MSG_DEBUG("pMmsMsg->mmsAttrib.bUseDeliveryCustomTime = %d", pMmsMsg->mmsAttrib.bUseDeliveryCustomTime);
755 MSG_DEBUG("pMmsMsg->mmsAttrib.deliveryTime.type = %d", pMmsMsg->mmsAttrib.deliveryTime.type);
756 MSG_DEBUG("pMmsMsg->mmsAttrib.deliveryTime.time = %d", pMmsMsg->mmsAttrib.deliveryTime.time);
758 /* MMS-1.3-con-739 */
759 pMmsMsg->mmsAttrib.msgClass = (MmsMsgClass)MsgSettingGetInt(MMS_SEND_MSG_CLASS);
760 /* MMS-1.3-con-739 */
761 #ifdef MMS_13_CON_742_ENABLED
762 /* MMS-1.3-con-742 */
763 pMmsMsg->mmsAttrib.deliveryTime.time = (unsigned int)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
764 /* MMS-1.3-con-742 */
767 MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.bAskDeliveryReport = %d @@@", pMmsMsg->mmsAttrib.bAskDeliveryReport);
768 MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.bAskReadReply = %d @@@", pMmsMsg->mmsAttrib.bAskReadReply);
769 MSG_DEBUG("@@@ pMmsMsg->mmsAttrib.priority = %d @@@", pMmsMsg->mmsAttrib.priority);
773 timeInfo = localtime(&RawTime);
774 nTimeInSecs = mktime(timeInfo);
775 pMmsMsg->mmsAttrib.date = nTimeInSecs; // todo: need to subtract timeline value to make GMT+0 time
778 strcpy(pMmsMsg->mmsAttrib.szSubject, pMsgInfo->subject);
781 MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo);
782 MmsGetMsgBodyfromMsgInfo(pMsgInfo, pMsgData, pFileData);
784 int pageCnt = _MsgMmsGetPageCount(pMsgData);
786 if (pageCnt == 0) { // Multipart mixed
787 pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED;
788 pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED;
789 MmsMakePreviewInfo(pMsgInfo->msgId, pMsgData);
790 } else { // Multipart related
796 snprintf(pMsgData->szSmilFilePath, MSG_FILEPATH_LEN_MAX, "%lu", RawTime);
798 MsgMMSCreateSMIL(pMsgData);
800 RawDataSize = MmsGetSmilRawData(pMsgData, &pRawData);
801 if (RawDataSize < 0) {
802 MSG_DEBUG("Smil file size is less than 0");
805 MSG_DEBUG("%s", pRawData);
807 MmsInsertPresentation(pMmsMsg, MIME_APPLICATION_SMIL, pRawData, strlen(pRawData));
809 pMmsMsg->mmsAttrib.contentType = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED;
810 pMmsMsg->msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED;
812 for (int i = 0; i < pageCnt; ++i) {
813 MMS_PAGE_S *pPage = _MsgMmsGetPage(pMsgData, i);
814 int mediaCnt = pPage->mediaCnt;
815 MSG_DEBUG("PAGE %d's media Cnt: %d", i+1, mediaCnt);
817 for (int j = 0; j < mediaCnt; ++j) {
818 MMS_MEDIA_S *pMedia = _MsgMmsGetMedia(pPage, j);
820 switch (pMedia->mediatype) {
821 case MMS_SMIL_MEDIA_IMG:
822 case MMS_SMIL_MEDIA_VIDEO:
823 case MMS_SMIL_MEDIA_AUDIO:
824 case MMS_SMIL_MEDIA_TEXT:
825 if (pMedia->szFilePath[0] != 0) {
826 if (!MmsInsertPartFromFile(pMmsMsg, pMedia->szFileName, pMedia->szFilePath, pMedia->szContentID))
837 char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };;
838 snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%d.mms", pMsgInfo->msgId);
840 MmsPluginStorage *pStorage = MmsPluginStorage::instance();
841 err = pStorage->getMsgText(pMsgData, pMsgInfo->msgText);
842 MmsMakePreviewInfo(pMsgInfo->msgId, pMsgData);
845 #ifdef FEATURE_JAVA_MMS
846 MSG_DEBUG("msgAppId: valid:%d appId:%s replyToAppId:%s", pMsgData->msgAppId.valid, pMsgData->msgAppId.appId, pMsgData->msgAppId.replyToAppId);
847 if (pMsgData->msgAppId.valid) { // check if msgAppId.valid is true, both appId and replytoappId must have a meaning data
848 if (pMsgData->msgAppId.appId[0] != 0) {
849 pMmsMsg->msgType.param.szApplicationID = (char *)malloc(strlen(pMsgData->msgAppId.appId) + 1);
850 if (pMmsMsg->msgType.param.szApplicationID == NULL) {
851 MSG_DEBUG("Error: out of Memory");
854 memset(pMmsMsg->msgType.param.szApplicationID, 0, strlen(pMsgData->msgAppId.appId) + 1);
856 strcpy(pMmsMsg->msgType.param.szApplicationID, pMsgData->msgAppId.appId);
859 if (pMsgData->msgAppId.replyToAppId[0] != 0) {
860 pMmsMsg->msgType.param.szReplyToApplicationID = (char *)malloc(strlen(pMsgData->msgAppId.replyToAppId) + 1);
861 if (pMmsMsg->msgType.param.szReplyToApplicationID == NULL) {
862 MSG_DEBUG("Error: out of Memory");
865 memset(pMmsMsg->msgType.param.szReplyToApplicationID, 0, strlen(pMsgData->msgAppId.replyToAppId) + 1);
867 strcpy(pMmsMsg->msgType.param.szReplyToApplicationID, pMsgData->msgAppId.replyToAppId);
872 //Processing Attachment List
873 for (int i = 0; i < _MsgMmsGetAttachCount(pMsgData); ++i) {
874 MMS_ATTACH_S *pMedia = _MsgMmsGetAttachment(pMsgData, i);
875 if (pMedia->szFilePath[0] != 0) {
876 if (!MmsInsertPartFromFile(pMmsMsg, pMedia->szFileName, pMedia->szFilePath, NULL)) {
886 void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID)
890 struct tm *timeInfo = NULL;
892 time_t nTimeInSecs = 0;
894 MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
895 MmsInitMsgType(&pMmsMsg->msgType);
896 MmsInitMsgBody(&pMmsMsg->msgBody);
898 pMmsMsg->msgID = msgID;
900 pMmsMsg->mmsAttrib.version = mmsHeader.version;
904 timeInfo = localtime(&RawTime);
905 nTimeInSecs = mktime(timeInfo);
906 pMmsMsg->mmsAttrib.date = nTimeInSecs;
908 pMmsMsg->mmsAttrib.bReportAllowed = mmsHeader.reportAllowed;
909 pMmsMsg->mmsAttrib.bAskDeliveryReport = mmsHeader.deliveryReport;
911 MSG_DEBUG("######## Version = %d ########", pMmsMsg->mmsAttrib.version);
913 strncpy(pMmsMsg->szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN);
914 strncpy(pMmsMsg->szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN);
915 pMmsMsg->szForwardMsgID[0] = '\0';
917 if (mmsHeader.pFrom) {
918 MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr );
919 strncpy(pMmsMsg->mmsAttrib.szFrom, mmsHeader.pFrom->szAddr, MSG_LOCALE_ADDR_LEN + 9);
922 strncpy(pMmsMsg->mmsAttrib.szSubject, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN);
923 strncpy(pMmsMsg->szContentLocation, mmsHeader.szContentLocation, MMS_LOCATION_LEN);
925 pMmsMsg->mmsAttrib.msgClass = mmsHeader.msgClass;
926 pMmsMsg->mmsAttrib.msgSize = mmsHeader.msgSize;
927 pMmsMsg->mmsAttrib.expiryTime.type = mmsHeader.expiryTime.type;
928 pMmsMsg->mmsAttrib.expiryTime.time = mmsHeader.expiryTime.time;
929 pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_NOTIFY;
930 pMmsMsg->mmsAttrib.bRead = false;
931 pMmsMsg->mailbox = MSG_INBOX_ID;
933 pMmsMsg->mmsAttrib.replyCharge.chargeType = mmsHeader.replyCharge.chargeType;
934 pMmsMsg->mmsAttrib.replyCharge.deadLine.type = mmsHeader.replyCharge.deadLine.type;
935 pMmsMsg->mmsAttrib.replyCharge.deadLine.time = mmsHeader.replyCharge.deadLine.time;
936 pMmsMsg->mmsAttrib.replyCharge.chargeSize = mmsHeader.replyCharge.chargeSize;
938 strncpy(pMmsMsg->mmsAttrib.replyCharge.szChargeID, mmsHeader.replyCharge.szChargeID, MMS_MSG_ID_LEN);
943 bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath)
946 MsgMultipart *pMultipart = NULL;
947 int attachmax = MSG_ATTACH_MAX;
950 /* read from MMS raw file */
951 if (retrievedFilePath)
952 strncpy(pMmsMsg->szFileName, retrievedFilePath + strlen(MSG_DATA_PATH), strlen(retrievedFilePath + strlen(MSG_DATA_PATH)));
956 pFile = MsgOpenFile(retrievedFilePath, "rb");
959 MSG_DEBUG( "_MmsReadMsgBody: invalid mailbox\n");
963 if (MsgGetFileSize(retrievedFilePath, &nSize) == false) {
964 MSG_DEBUG("MsgGetFileSize: failed");
968 _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,
970 MSG_MMS_DECODE_BUFFER_MAX);
972 if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) {
973 MSG_DEBUG( "_MmsReadMsgBody: MmsBinaryDecodeMsgHeader fail...\n");
977 if (MmsBinaryDecodeMsgBody(pFile, retrievedFilePath, nSize) == false) {
978 MSG_DEBUG( "_MmsReadMsgBody: MmsBinaryDecodeMsgBody fail\n");
982 /* Set mmsHeader.msgType & msgBody to pMsg ----------- */
984 pMmsMsg->mmsAttrib.contentType = (MsgContentType)mmsHeader.msgType.type;
986 memcpy(&(pMmsMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType));
987 memcpy(&(pMmsMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody));
989 MSG_DEBUG("#############################");
990 MSG_DEBUG("## pMmsMsg->msgType.type = %d ##", pMmsMsg->msgType.type);
991 MSG_DEBUG("## pMmsMsg->msgType.szContentID = %s ##", pMmsMsg->msgType.szContentID);
992 MSG_DEBUG("## pMmsMsg->msgType.szContentLocation = %s ##", pMmsMsg->msgType.szContentLocation);
993 MSG_DEBUG("#############################");
995 if (pMmsMsg->msgBody.pPresentationBody) {
996 if(MsgFseek(pFile, pMmsMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0)
999 pMmsMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMmsMsg->msgBody.pPresentationBody->size + 1);
1000 if (pMmsMsg->msgBody.pPresentationBody->body.pText == NULL)
1003 memset(pMmsMsg->msgBody.pPresentationBody->body.pText, 0, pMmsMsg->msgBody.pPresentationBody->size + 1);
1005 nRead = MsgReadFile(pMmsMsg->msgBody.pPresentationBody->body.pText, sizeof(char), pMmsMsg->msgBody.pPresentationBody->size, pFile);
1011 MsgCloseFile(pFile);
1015 pMmsMsg->nPartCount = 0;
1017 if (MsgIsMultipart(mmsHeader.msgType.type) == true) {
1018 pMultipart = pMmsMsg->msgBody.body.pMultipart;
1019 while (pMultipart) {
1020 pMmsMsg->nPartCount++;
1022 if (pMultipart->type.type == MIME_TEXT_PLAIN)
1025 if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED) ||
1026 (mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) {
1027 if ((pMmsMsg->nPartCount >= attachmax ) && (pMultipart->pNext != NULL)) {
1028 _MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type);
1030 free(pMultipart->pNext->pBody);
1031 pMultipart->pNext->pBody = NULL;
1033 free(pMultipart->pNext);
1035 pMultipart->pNext = NULL;
1039 pMultipart = pMultipart->pNext;
1042 if (pMmsMsg->msgBody.size > 0)
1043 pMmsMsg->nPartCount++;
1046 //call before processing urgent event.
1048 _MmsUnregisterDecodeBuffer();
1055 _MmsUnregisterDecodeBuffer();
1057 if (pFile != NULL) {
1058 MsgCloseFile(pFile);
1062 _MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type);
1063 MSG_DEBUG("_MmsReadMsgBody: E N D ( fail ) ******************** \n");
1068 #ifdef MMS_DELIEVERY_IND_ENABLED
1069 MmsMsgMultiStatus *MmsComposeDeliveryIndMessage(MmsMsg *pMmsMsg, msg_message_id_t msgId)
1071 MmsMsgMultiStatus *pStatus = NULL;
1072 MmsMsgMultiStatus *pLastStatus = NULL;
1073 bool bFound = false;
1075 MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
1076 MmsInitMsgType(&pMmsMsg->msgType);
1077 MmsInitMsgBody(&pMmsMsg->msgBody);
1079 pMmsMsg->mmsAttrib.version = mmsHeader.version;
1081 pMmsMsg->mmsAttrib.pMultiStatus = MmsGetMultiStatus(msgId);
1083 pStatus = pMmsMsg->mmsAttrib.pMultiStatus;
1085 MSG_DEBUG("### pStatus->szTo = %s ###", pStatus->szTo);
1087 while (pStatus && !bFound) {
1088 MSG_DEBUG("### MmsAddrUtilCompareAddr ###");
1089 MSG_DEBUG("### mmsHeader.pTo->szAddr = %s ###", mmsHeader.pTo->szAddr);
1090 if (MmsAddrUtilCompareAddr(pStatus->szTo, mmsHeader.pTo->szAddr)) {
1095 pStatus = pStatus->pNext;
1098 if (bFound == false) {
1099 MSG_DEBUG("### bFound == false ###");
1100 /* Queue the delivery report --------------------------- */
1102 pStatus = (MmsMsgMultiStatus *)malloc(sizeof(MmsMsgMultiStatus));
1103 memset(pStatus, 0, sizeof(MmsMsgMultiStatus));
1105 pStatus->readStatus = MMS_READSTATUS_NONE;
1107 memset(pStatus->szTo, 0, MSG_ADDR_LEN + 1);
1108 strncpy(pStatus->szTo, mmsHeader.pTo->szAddr, MSG_ADDR_LEN);
1110 if (pMmsMsg->mmsAttrib.pMultiStatus == NULL) {
1111 /* first delivery report */
1112 pMmsMsg->mmsAttrib.pMultiStatus = pStatus;
1114 pLastStatus = pMmsMsg->mmsAttrib.pMultiStatus;
1115 while (pLastStatus->pNext) {
1116 pLastStatus = pLastStatus->pNext;
1119 pLastStatus->pNext = pStatus;
1120 pLastStatus = pStatus;
1124 pStatus->handledTime = mmsHeader.date;
1125 pStatus->msgStatus = mmsHeader.msgStatus;
1126 pStatus->bDeliveryReportIsRead = false;
1128 _MmsDataUpdateLastStatus(pMmsMsg);
1130 pStatus->bDeliveyrReportIsLast = true;
1136 void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, msg_message_id_t selectedMsgId)
1138 struct tm *timeInfo = NULL;
1140 time_t nTimeInSecs = 0;
1142 MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
1143 MmsInitMsgType(&pMmsMsg->msgType);
1144 MmsInitMsgBody(&pMmsMsg->msgBody);
1146 // setting mmsMsg structure
1147 pMmsMsg->mailbox = pMsgInfo->folderId;
1148 pMmsMsg->msgID = pMsgInfo->msgId;
1150 memset(pMmsMsg->szTrID, 0, MMS_TR_ID_LEN + 1);
1151 memset(pMmsMsg->szContentLocation, 0, MMS_LOCATION_LEN + 1);
1152 memset(pMmsMsg->szForwardMsgID, 0, MMS_MSG_ID_LEN + 1);
1154 pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT;
1158 timeInfo = localtime(&RawTime);
1159 nTimeInSecs = mktime(timeInfo);
1160 pMmsMsg->mmsAttrib.date = nTimeInSecs;
1163 MmsPluginStorage::instance()->getMmsMessageId(selectedMsgId, pMmsMsg);
1166 strcpy(pMmsMsg->mmsAttrib.szSubject, pMsgInfo->subject);
1169 MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo);
1171 if (pMmsMsg->mmsAttrib.szTo)
1172 strncpy(pMmsMsg->mmsAttrib.szFrom, pMmsMsg->mmsAttrib.szTo, strlen(pMmsMsg->mmsAttrib.szTo));
1175 int MmsSearchMsgId(char *toNumber, char *szMsgID)
1181 msgId = MmsPluginStorage::instance()->searchMsgId(toNumber, szMsgID);
1191 MmsMsgMultiStatus *MmsGetMultiStatus(msg_message_id_t msgId)
1193 MmsMsgMultiStatus *pMultiStatus;
1195 pMultiStatus = MmsPluginStorage::instance()->getMultiStatus(msgId);
1197 MSG_DEBUG("### szTo = %s ###", pMultiStatus->szTo);
1201 return pMultiStatus;
1204 bool MmsCheckAdditionalMedia(MMS_MESSAGE_DATA_S *pMsgData, MsgType *partHeader)
1206 if (_MsgMmsFindMatchedMedia(pMsgData, partHeader->param.szFileName))
1212 /*PIM objects SHALL be supported as attachments to an MM*/
1213 bool MmsRemovePims(MMS_MESSAGE_DATA_S *pMsgData)
1215 GList *cur_page = NULL;
1216 GList *cur_media = NULL;
1218 if (pMsgData == NULL)
1221 cur_page = pMsgData->pagelist;
1224 MMS_PAGE_S *page = (MMS_PAGE_S *)cur_page->data;
1226 cur_media = page->medialist;
1229 MMS_MEDIA_S *pMedia = (MMS_MEDIA_S *)cur_media->data;
1232 MsgGetTypeByFileName(&tempType, pMedia->szFilePath);
1233 if (tempType == MIME_TEXT_X_VCALENDAR || tempType == MIME_TEXT_X_VCARD) {
1234 page->medialist = g_list_remove_all(page->medialist, pMedia);
1235 page->mediaCnt = g_list_length(page->medialist);
1236 cur_media = page->medialist;
1239 cur_media = g_list_next(cur_media);
1242 cur_media = g_list_next(cur_media);
1244 } //cur_media while for remove pims file in list
1246 if (page->medialist == NULL) {//remove empty page
1247 pMsgData->pagelist = g_list_remove_all(pMsgData->pagelist, page);
1248 pMsgData->pageCnt = g_list_length(pMsgData->pagelist);
1249 cur_page = pMsgData->pagelist;
1252 cur_page = g_list_next(cur_page);
1262 #ifdef __SUPPORT_DRM__
1263 bool __MsgInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo)
1265 pMsgDrmInfo->contentType = MIME_UNKNOWN;
1266 pMsgDrmInfo->drmType = MSG_DRM_TYPE_NONE;
1268 pMsgDrmInfo->szContentName = NULL;
1269 pMsgDrmInfo->szContentURI = NULL;
1270 pMsgDrmInfo->szContentDescription = NULL;
1271 pMsgDrmInfo->szContentVendor = NULL;
1272 pMsgDrmInfo->szRightIssuer = NULL;
1273 pMsgDrmInfo->szDrm2FullPath = NULL;
1274 pMsgDrmInfo->roWaitingTimerMax = 0;
1275 pMsgDrmInfo->bFwdLock = false;
1276 pMsgDrmInfo->bNoScreen = false;
1277 pMsgDrmInfo->bNoRingTone = false;
1278 pMsgDrmInfo->pszContentType = NULL;
1284 msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg)
1286 MMS_PAGE_S *pPage = NULL;
1287 MMS_MEDIA_S *pMedia = NULL;
1289 if (pMmsMsg == NULL)
1290 return MSG_ERR_NULL_POINTER;
1292 if (pMmsMsg->pageCnt > 0) {
1294 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_PAGE, (char *)"pagecount", pMmsMsg->pageCnt);
1296 pPage = _MsgMmsGetPage(pMmsMsg, 0);
1297 for (int j = 0; j < pPage->mediaCnt; j++) {
1299 pMedia = _MsgMmsGetMedia(pPage, j);
1300 MSG_DEBUG("pMedia's Name: %s", pMedia->szFilePath);
1302 if (pMedia->mediatype == MMS_SMIL_MEDIA_IMG || pMedia->mediatype == MMS_SMIL_MEDIA_VIDEO) {
1303 char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };
1304 char thumbPath[MSG_FILEPATH_LEN_MAX+1] = {0, };
1306 memset(szFileName, 0x00, MSG_FILENAME_LEN_MAX+1);
1307 memset(thumbPath, 0x00, MSG_FILEPATH_LEN_MAX);
1309 snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%d.mms",msgId);
1310 snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, MSG_THUMBNAIL_PATH"/%s.jpg", szFileName);
1312 if (pMedia->mediatype == MMS_SMIL_MEDIA_IMG) {
1313 if (makeImageThumbnail(pMedia->szFilePath, thumbPath) == true) {
1314 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_IMG, thumbPath);
1316 MSG_DEBUG("Fail of generating thumbnail: %s to %s", pMedia->szFilePath, thumbPath);
1319 if (makeVideoThumbnail(pMedia->szFilePath, thumbPath) == true) {;
1320 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_VIDEO, thumbPath);
1322 MSG_DEBUG("Fail of generating thumbnail: %s to %s", pMedia->szFilePath, thumbPath);
1326 } else if (pMedia->mediatype == MMS_SMIL_MEDIA_AUDIO) {
1327 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_AUDIO, pMedia->szFileName);
1331 MSG_DEBUG("There is no page");
1334 int attachCnt = _MsgMmsGetAttachCount(pMmsMsg);
1335 if (attachCnt > 0) {
1336 MMS_ATTACH_S *pAttach = _MsgMmsGetAttachment(pMmsMsg, 0);
1337 MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_ATTACH, pAttach->szFileName, attachCnt);
1339 MSG_DEBUG("There is no attachment");