3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
35 #include "MmsPluginSmil.h"
36 #include "MmsPluginMessage.h"
37 #include "MmsPluginStorage.h"
39 #include "MmsPluginCodec.h"
40 #include "MsgMmsMessage.h"
43 #include "MmsPluginSetup.h"
44 #include "MsgUtilFile.h"
46 /* static variables */
47 static char gszEmptyRawDoc[] = "<smil><head><layout></layout></head><body></body></smil>";
48 static MmsSmilDoc *__gpaMmsSmilDoc[MMS_SMIL_MAX_DOC]={NULL, };
49 static char gszColor[MMS_SMIL_COLOR_SIZE] = {0, };
52 char *MmsSmilGetPresentationData(MSG_MESSAGE_ID_T msgId)
56 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
59 MSG_DEBUG("pMsg is NULL");
63 if (msgId != pMsg->msgID) {
64 MSG_DEBUG("Invalid Message Id");
68 if (!pMsg->msgBody.pPresentationBody)
71 if (!pMsg->msgBody.pPresentationBody->body.pText)
74 return pMsg->msgBody.pPresentationBody->body.pText;
80 bool MmsSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc)
84 MSG_DEBUG("%s", pSmilDoc);
85 doc = xmlParseMemory(pSmilDoc, strlen(pSmilDoc));
88 MSG_DEBUG("Document not parsed successfully. \n");
92 cur = xmlDocGetRootElement(doc);
95 MSG_DEBUG("empty document\n");
100 if (xmlStrcmp(cur->name, (const xmlChar *) "smil")) {
101 MSG_DEBUG("document of the wrong type, root node != smil");
106 MmsSmilGetElement(pMmsMsg, cur);
113 void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node)
119 MMS_SMIL_ROOTLAYOUT rootlayout = {};
120 static bool cmd[ELEMENT_MAX] = {false, };
121 static MMS_SMIL_REGION *pRegion;
122 static MMS_PAGE_S *pPage;
123 static MMS_MEDIA_S *pMedia;
124 static MMS_SMIL_TRANSITION *pTransition;
125 static MMS_SMIL_META *pMeta;
127 xmlNode *cur_node = NULL;
129 for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
130 MSG_DEBUG("******* node, name: %s ***\n", cur_node->name);
132 if (cur_node->type == XML_ELEMENT_NODE) {
133 // Get Smil Element =====================================================
134 MSG_DEBUG("*** node type: Element, name: %s ***\n", cur_node->name);
136 switch (elementType = MmsSmilGetElementID((char *)cur_node->name)) {
137 case ELEMENT_ROOTLAYOUT:
138 memset(cmd, 0, ELEMENT_MAX);
139 cmd[ELEMENT_ROOTLAYOUT] = true;
143 pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1);
144 memset(cmd, 0, ELEMENT_MAX);
145 cmd[ELEMENT_REGION] = true;
148 case ELEMENT_TRANSITION:
149 pTransition = (MMS_SMIL_TRANSITION *)calloc(sizeof(MMS_SMIL_TRANSITION), 1);
150 memset(cmd, 0, ELEMENT_MAX);
151 cmd[ELEMENT_TRANSITION] = true;
155 pMeta = (MMS_SMIL_META *)calloc(sizeof(MMS_SMIL_META), 1);
156 memset(cmd, 0, ELEMENT_MAX);
157 cmd[ELEMENT_META] = true;
161 pPage = (MMS_PAGE_S *)calloc(sizeof(MMS_PAGE_S), 1);
162 memset(cmd, 0, ELEMENT_MAX);
163 cmd[ELEMENT_PAR] = true;
166 case ELEMENT_PARAM: // Need to check the original element type
170 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
171 pMedia->mediatype = MMS_SMIL_MEDIA_TEXT;
172 memset(cmd, 0, ELEMENT_MAX);
173 cmd[ELEMENT_TEXT] = true;
177 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
178 pMedia->mediatype = MMS_SMIL_MEDIA_IMG;
179 memset(cmd, 0, ELEMENT_MAX);
180 cmd[ELEMENT_IMG] = true;
184 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
185 pMedia->mediatype = MMS_SMIL_MEDIA_AUDIO;
186 memset(cmd, 0, ELEMENT_MAX);
187 cmd[ELEMENT_AUDIO] = true;
191 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
192 pMedia->mediatype = MMS_SMIL_MEDIA_VIDEO;
193 memset(cmd, 0, ELEMENT_MAX);
194 cmd[ELEMENT_VIDEO] = true;
198 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
199 pMedia->mediatype = MMS_SMIL_MEDIA_IMG_OR_VIDEO;
200 memset(cmd, 0, ELEMENT_MAX);
201 cmd[ELEMENT_REF] = true;
204 case ELEMENT_ANIMATE:
205 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
206 pMedia->mediatype = MMS_SMIL_MEDIA_ANIMATE;
207 memset(cmd, 0, ELEMENT_MAX);
208 cmd[ELEMENT_ANIMATE] = true;
212 memset(cmd, 0, ELEMENT_MAX);
216 //Get Smil Attribute =====================================================
217 xmlAttr *pAttr = cur_node->properties;
218 SMIL_ATTRIBUTE_T paramType = ATTRIBUTE_UNKNOWN;
220 for ( ; pAttr; pAttr = pAttr->next) {
221 MSG_DEBUG("AttributeType: (%s, %s) ", pAttr->name, pAttr->children->content);
222 switch (attrType = MmsSmilGetAttrID((char *)pAttr->name)) {
225 if (cmd[ELEMENT_REGION]) {
226 strncpy(pRegion->szID, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
227 } else if (cmd[ELEMENT_TRANSITION]) {
228 strncpy(pTransition->szID, (char *)pAttr->children->content, MAX_SMIL_TRANSITION_ID - 1);
229 } else if (cmd[ELEMENT_META]) {
230 strncpy(pMeta->szID, (char *)pAttr->children->content, MAX_SMIL_META_ID - 1);
240 if (strchr((char *)pAttr->children->content, '%'))
243 bUnitPercent = false;
245 value = atoi((char *)pAttr->children->content);
247 if (cmd[ELEMENT_REGION]) {
248 pRegion->nTop.bUnitPercent = bUnitPercent;
249 pRegion->nTop.value = value;
259 if (strchr((char *)pAttr->children->content, '%'))
262 bUnitPercent = false;
264 value = atoi((char *)pAttr->children->content);
266 if (cmd[ELEMENT_REGION]) {
267 pRegion->nLeft.bUnitPercent = bUnitPercent;
268 pRegion->nLeft.value = value;
274 case ATTRIBUTE_WIDTH:
279 if (strchr((char *)pAttr->children->content, '%'))
282 bUnitPercent = false;
284 value = atoi((char *)pAttr->children->content);
286 if (cmd[ELEMENT_ROOTLAYOUT]) {
287 rootlayout.width.bUnitPercent = bUnitPercent;
288 rootlayout.width.value = value;
289 } else if (cmd[ELEMENT_REGION]) {
290 pRegion->width.bUnitPercent = bUnitPercent;
291 pRegion->width.value = value;
296 case ATTRIBUTE_HEIGHT:
301 if (strchr((char *)pAttr->children->content, '%'))
304 bUnitPercent = false;
306 value = atoi((char *)pAttr->children->content);
308 if (cmd[ELEMENT_ROOTLAYOUT]) {
309 rootlayout.height.bUnitPercent = bUnitPercent;
310 rootlayout.height.value = value;
311 } else if (cmd[ELEMENT_REGION]) {
312 pRegion->height.bUnitPercent = bUnitPercent;
313 pRegion->height.value = value;
319 if (cmd[ELEMENT_REGION]) {
320 if (!strcmp((char *)pAttr->children->content, "meet")) {
321 pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET;
323 pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN;
328 case ATTRIBUTE_BGCOLOR:
329 if (cmd[ELEMENT_ROOTLAYOUT])
330 rootlayout.bgColor = MmsSmilGetColorValue(pAttr->children->content);
331 else if (cmd[ELEMENT_REGION])
332 pRegion->bgColor = MmsSmilGetColorValue(pAttr->children->content);
333 else if (cmd[ELEMENT_TEXT])
334 pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
336 pMedia->sMedia.sAVI.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
341 if (cmd[ELEMENT_PAR])
342 pPage->nDur = MmsSmilGetTime((char *)pAttr->children->content);
343 else if (cmd[ELEMENT_TRANSITION])
344 pTransition->nDur = MmsSmilGetTime((char *)pAttr->children->content);
345 else if (cmd[ELEMENT_TEXT])
346 pMedia->sMedia.sText.nDurTime = MmsSmilGetTime((char *)pAttr->children->content);
348 pMedia->sMedia.sAVI.nDurTime = MmsSmilGetTime((char *)pAttr->children->content);
350 #ifdef MMS_SMIL_ANIMATE
351 if (cmd[ELEMENT_ANIMATE])
352 pMedia->sMedia.sAVI.nDur = MmsSmilGetTime((char *)pAttr->children->content);
359 char szTmpSrc[MSG_FILEPATH_LEN_MAX] = {0,};
360 char szOutBuf[MSG_FILEPATH_LEN_MAX] = {0, };
362 MsgMultipart *pPart = NULL;
365 szSrc = MsgChangeHexString((char *)pAttr->children->content);
367 memcpy(pMedia->szSrc, szSrc, strlen(szSrc) + 1);
370 cLen = strlen(pMedia->szSrc);
371 if (!strncasecmp(pMedia->szSrc, "cid:", 4)) {
372 strncpy(szTmpSrc, pMedia->szSrc + 4, cLen - 4);
373 szTmpSrc[cLen - 4] = '\0';
375 strncpy(szTmpSrc, pMedia->szSrc, cLen);
376 szTmpSrc[cLen] = '\0';
379 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
380 pPart = pMsg->msgBody.body.pMultipart;
381 #ifndef __SUPPORT_DRM__
382 MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart);
384 MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart, pMedia);
387 strcpy(pMedia->szSrc, szOutBuf);
388 MmsSmilGetMediaFilePath(pMedia, szTmpSrc, pMsg->msgID);
392 case ATTRIBUTE_COLOR:
393 if (cmd[ELEMENT_TEXT])
394 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
398 if (cmd[ELEMENT_TEXT])
399 pMedia->sMedia.sText.nSize = atoi((char *)pAttr->children->content);
403 if (cmd[ELEMENT_TEXT]) {
404 pMedia->sMedia.sText.bBold = MmsSmilGetFontAttrib((char *)pAttr->children->content);
408 case ATTRIBUTE_UNDERLINE:
409 if (cmd[ELEMENT_TEXT])
410 pMedia->sMedia.sText.bUnderLine = MmsSmilGetFontAttrib((char *)pAttr->children->content);
413 case ATTRIBUTE_ITALIC:
414 if (cmd[ELEMENT_TEXT])
415 pMedia->sMedia.sText.bItalic = MmsSmilGetFontAttrib((char *)pAttr->children->content);
418 case ATTRIBUTE_REVERSE:
419 if (cmd[ELEMENT_TEXT])
420 pMedia->sMedia.sText.bReverse = MmsSmilGetFontAttrib((char *)pAttr->children->content);
423 case ATTRIBUTE_DIRECTION:
424 if (cmd[ELEMENT_TEXT])
425 pMedia->sMedia.sText.nDirection = MmsSmilGetFontDirection((char *)pAttr->children->content);
428 case ATTRIBUTE_REGION:
429 strncpy(pMedia->regionId, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
432 case ATTRIBUTE_TRANSIN:
433 if (cmd[ELEMENT_TEXT])
434 strncpy(pMedia->sMedia.sText.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
436 strncpy(pMedia->sMedia.sAVI.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
439 case ATTRIBUTE_TRANSOUT:
440 if (cmd[ELEMENT_TEXT])
441 strncpy(pMedia->sMedia.sText.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
443 strncpy(pMedia->sMedia.sAVI.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
446 case ATTRIBUTE_BEGIN:
447 if (cmd[ELEMENT_TEXT])
448 pMedia->sMedia.sText.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
450 pMedia->sMedia.sAVI.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
454 if (cmd[ELEMENT_TEXT])
455 pMedia->sMedia.sText.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
457 pMedia->sMedia.sAVI.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
460 case ATTRIBUTE_REPEAT_COUNT:
461 if (cmd[ELEMENT_TEXT])
462 pMedia->sMedia.sText.nRepeat = atoi((char *)pAttr->children->content);
464 pMedia->sMedia.sAVI.nRepeat = atoi((char *)pAttr->children->content);
468 if (!strcmp((char *)pAttr->children->content, "foreground-color") || !strcmp((char *)pAttr->children->content, "foregroundcolor"))
469 paramType = ATTRIBUTE_FGCOLOR;
470 else if (!strcmp((char *)pAttr->children->content, "background-color") || !strcmp((char *)pAttr->children->content, "backgroundcolor"))
471 paramType = ATTRIBUTE_BGCOLOR;
472 else if (!strcmp((char *)pAttr->children->content, "textsize"))
473 paramType = ATTRIBUTE_SIZE;
474 else if (!strcmp((char *)pAttr->children->content, "textattribute"))
475 paramType = ATTRIBUTE_TEXTFORMAT;
477 if (cmd[ELEMENT_META])
478 strncpy(pMeta->szName, (char *)pAttr->children->content, MAX_SMIL_META_NAME - 1);
481 case ATTRIBUTE_VALUE:
482 if (paramType == ATTRIBUTE_SIZE && cmd[ELEMENT_TEXT])
483 pMedia->sMedia.sText.nSize = MmsSmilGetFontSizeValue((char *)pAttr->children->content);
484 else if (paramType == ATTRIBUTE_FGCOLOR && cmd[ELEMENT_TEXT])
485 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
486 else if (paramType == ATTRIBUTE_BGCOLOR && cmd[ELEMENT_TEXT])
487 pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
488 else if (paramType == ATTRIBUTE_TEXTFORMAT && cmd[ELEMENT_TEXT]) {
489 MmsSmilFontType fontType;
491 fontType = MmsSmilGetFontTypeValue((char *)pAttr->children->content);
493 if (fontType == MMS_SMIL_FONT_TYPE_BOLD)
494 pMedia->sMedia.sText.bBold = true;
496 pMedia->sMedia.sText.bBold = false;
498 if (fontType == MMS_SMIL_FONT_TYPE_ITALIC)
499 pMedia->sMedia.sText.bItalic = true;
501 pMedia->sMedia.sText.bItalic = false;
503 if (fontType == MMS_SMIL_FONT_TYPE_UNDERLINE)
504 pMedia->sMedia.sText.bUnderLine = true;
506 pMedia->sMedia.sText.bUnderLine = false;
511 strncpy(pMedia->szAlt, (char *)pAttr->children->content, MAX_SMIL_ALT_LEN - 1);
515 pTransition->nType = (MmsSmilTransType)atoi((char *)pAttr->children->content);
517 switch (pTransition->nType) {
518 case MMS_SMIL_TRANS_SLIDEWIPE:
519 pTransition->nSubType = MMS_SMIL_TRANS_SUB_FROM_LEFT;
521 case MMS_SMIL_TRANS_BARWIPE:
522 pTransition->nSubType = MMS_SMIL_TRANS_SUB_TOP_TO_BOTTOM;
524 case MMS_SMIL_TRANS_BARNDOORWIPE:
525 pTransition->nSubType = MMS_SMIL_TRANS_SUB_HORIZONTAL;
528 pTransition->nSubType = MMS_SMIL_TRANS_SUB_NONE;
534 case ATTRIBUTE_SUBTYPE:
535 pTransition->nSubType = (MmsSmilTransSubType)atoi((char *)pAttr->children->content);
538 case ATTRIBUTE_CONTENT:
539 strncpy(pMeta->szContent, (char *)pAttr->children->content, MAX_SMIL_META_CONTENT - 1);
541 #ifdef MMS_SMIL_ANIMATE
542 case ATTRIBUTE_ATTRIBUTE_NAME:
543 strcpy(pMedia->sMedia.sAVI.nAttributeName, (char *)pAttr->children->content);
546 case ATTRIBUTE_ATTRIBUTE_TYPE:
547 strcpy(pMedia->sMedia.sAVI.nAttributeType, (char *)pAttr->children->content);
550 case ATTRIBUTE_TARGET_ELEMENT:
551 strcpy(pMedia->sMedia.sAVI.nTargetElement, (char *)pAttr->children->content);
555 pMedia->sMedia.sAVI.nFrom = atoi((char *)pAttr->children->content);
559 pMedia->sMedia.sAVI.nTo = atoi((char *)pAttr->children->content);
563 pMedia->sMedia.sAVI.nBy = atoi((char *)pAttr->children->content);
566 case ATTRIBUTE_VALUES:
567 pMedia->sMedia.sAVI.nValues = atoi((char *)pAttr->children->content);
570 case ATTRIBUTE_CALCMODE:
571 strcpy(pMedia->sMedia.sAVI.nCalcMode, (char *)pAttr->children->content);
575 MSG_DEBUG("Undefined Attribute was found!!!!!");
579 if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_REGION]) {
580 // Insert a region to region list
581 _MsgMmsAddRegion(pMmsMsg, pRegion);
582 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_PAR]) {
583 //Insert a page to page list
584 _MsgMmsAddPage(pMmsMsg, pPage);
585 } else if (paramType == ATTRIBUTE_UNKNOWN && (cmd[ELEMENT_TEXT] ||cmd[ELEMENT_IMG] ||cmd[ELEMENT_AUDIO] ||cmd[ELEMENT_VIDEO] ||cmd[ELEMENT_ANIMATE])) {
586 //Insert a media to media list
587 _MsgMmsAddMedia(pPage, pMedia);
588 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_ROOTLAYOUT]) {
589 _MsgMmsSetRootLayout(pMmsMsg, &rootlayout);
590 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_TRANSITION]) {
591 //Insert a transition to transition list
592 _MsgMmsAddTransition(pMmsMsg, pTransition);
593 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_META]) {
594 //Insert a meta to meta list
595 _MsgMmsAddMeta(pMmsMsg, pMeta);
598 paramType = ATTRIBUTE_UNKNOWN;
601 MmsSmilGetElement(pMmsMsg, cur_node->children);
608 int MmsSmilGetColorValue(xmlChar *content)
612 if (content[0] == '#') // RGB value
613 color = MmsSmilAtoIHexa((char *)&content[1]);
614 else if (content[0] == '0' && (content[1] == 'x' || content[1] == 'X'))
615 color = MmsSmilAtoIHexa((char *)&content[2]);
617 MSG_DEBUG("Invalid Color Value");
624 int MmsSmilAtoIHexa(char *pInput)
631 char *pOutput = NULL;
633 MSG_DEBUG("__MmsSmilAtoIHexa() enter..\n");
635 len = strlen(pInput);
636 pOutput = (char *)malloc(len + 1);
638 if (pOutput == NULL) {
639 MSG_DEBUG("__MmsSmilAtoIHexa: Memory full \n");
643 memset(pOutput, 0, len + 1);
645 for (i = len - 1; i >= 0; i--) {
646 for (j = 0; j < (len - 1 - i); j++) {
722 res += (pOutput[i] * temp);
736 int MmsSmilGetTime(char *pValue)
744 if (pValue == NULL || pValue[0] == '\0')
747 len = strlen(pValue);
749 /* Default time unit -> millisecond */
750 if (strstr(pValue, "msec"))
753 if (strstr(pValue, "ms"))
756 pTemp = (char *)malloc(strlen(pValue) + 1);
759 MSG_DEBUG("__MmsSmilGetTime : malloc for <time> attribute is failed \n");
763 while (isdigit(pValue[i])) {
764 pTemp[i] = pValue[i];
769 /* Detect 's' and 'ms' here */
770 retVal = atoi(pTemp);
782 #ifndef __SUPPORT_DRM__
783 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart)
785 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart, MMS_MEDIA_S *pMedia)
788 char szContentID[MSG_MSG_ID_LEN + 1] = {0, };
789 char szContentLI[MSG_MSG_ID_LEN + 1] = {0, };
793 MSG_DEBUG("szInBuf: %s", szInBuf);
794 while (pPart && pPart->pBody) {
795 if (pPart->type.szContentID[0]) {
796 cLen = strlen(pPart->type.szContentID);
798 if (pPart->type.szContentID[0] == '<' && pPart->type.szContentID[cLen - 1] == '>') {
799 strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
800 szContentID[cLen - 2] = '\0';
801 } else if (pPart->type.szContentID[0] == MSG_CH_QUOT && pPart->type.szContentID[cLen-1] == MSG_CH_QUOT) {
802 strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
803 szContentID[cLen - 2] = '\0';
805 strncpy(szContentID, pPart->type.szContentID, cLen);
806 szContentID[cLen] = '\0';
809 szContentID[0] = '\0';
812 MSG_DEBUG("szContentID: %s", szContentID);
814 if (pPart->type.szContentLocation[0]) {
815 cLen = strlen(pPart->type.szContentLocation);
817 if (pPart->type.szContentLocation[0] == MSG_CH_QUOT &&
818 pPart->type.szContentLocation[cLen-1] == MSG_CH_QUOT) {
819 strncpy(szContentLI, &pPart->type.szContentLocation[1], cLen-2);
820 szContentLI[cLen-2] = '\0';
822 strncpy(szContentLI, pPart->type.szContentLocation, cLen);
823 szContentLI[cLen] = '\0';
826 szContentLI[0] = '\0';
829 MSG_DEBUG("szContentLocation: %s", szContentLI);
831 if (strcasecmp(szContentID, szInBuf) == 0) {
832 strcpy(szOutbuf, pPart->type.param.szFileName);
833 MSG_DEBUG("match with szContentID.");
836 char *szInFileName = strrchr(szInBuf, '/');
838 if (szInFileName == NULL) {
839 szInFileName = szInBuf;
843 if (strcasecmp(szContentLI, szInFileName) == 0) {
844 strcpy(szOutbuf, pPart->type.param.szFileName);
845 MSG_DEBUG("match with szContentLI.");
847 } else if (strcasecmp(pPart->type.param.szName, szInBuf) == 0) {
848 strcpy(szOutbuf, pPart->type.param.szFileName);
849 MSG_DEBUG("match with pPart->type.param.szName.");
851 } else if (strlen(szContentID) > 4) {
852 if (strcasecmp(strtok(szContentID, "."), strtok(szInBuf, ".")) == 0) {
853 strcpy(szOutbuf, pPart->type.param.szFileName);
854 MSG_DEBUG("only name is match with szContentID.");
857 } else if (strlen(szContentLI) > 4) {
858 if (strcasecmp(strtok(szContentLI, "."), strtok(szInBuf, ".")) == 0) {
859 strcpy(szOutbuf, pPart->type.param.szFileName);
860 MSG_DEBUG("only name is match with szContentLI.");
867 pPart = pPart->pNext;
873 #ifdef __SUPPORT_DRM__
874 pMedia->drmType = pPart->type.drmInfo.drmType;
876 if (pPart->type.drmInfo.szDrm2FullPath != NULL) {
877 MSG_DEBUG("szDrm2FullPath: %s", pPart->type.drmInfo.szDrm2FullPath);
878 strncpy(pMedia->szDrm2FullPath, pPart->type.drmInfo.szDrm2FullPath, MSG_FILEPATH_LEN_MAX - 1);
885 int MmsSmilGetElementID(char *pString)
887 if (!strcmp(pString, "smil"))
889 else if (!strcmp(pString, "head"))
891 else if (!strcmp(pString, "layout"))
892 return ELEMENT_LAYOUT;
893 else if (!strcmp(pString, "root-layout"))
894 return ELEMENT_ROOTLAYOUT;
895 else if (!strcmp(pString, "region"))
896 return ELEMENT_REGION;
897 else if (!strcmp(pString, "body"))
899 else if (!strcmp(pString, "par"))
901 else if (!strcmp(pString, "param"))
902 return ELEMENT_PARAM;
903 else if (!strcmp(pString, "text"))
905 else if (!strcmp(pString, "img"))
907 else if (!strcmp(pString, "audio"))
908 return ELEMENT_AUDIO;
909 else if (!strcmp(pString, "video"))
910 return ELEMENT_VIDEO;
911 else if (!strcmp(pString, "ref"))
913 else if (!strcmp(pString, "animate"))
914 return ELEMENT_ANIMATE;
915 else if (!strcmp(pString, "root-layout"))
917 else if (!strcmp(pString, "transition"))
918 return ELEMENT_TRANSITION;
919 else if (!strcmp(pString, "meta"))
925 int MmsSmilGetAttrID(char *pString)
927 if (!strcmp(pString, "id"))
929 else if (!strcmp(pString, "top"))
930 return ATTRIBUTE_TOP;
931 else if (!strcmp(pString, "left"))
932 return ATTRIBUTE_LEFT;
933 else if (!strcmp(pString, "width"))
934 return ATTRIBUTE_WIDTH;
935 else if (!strcmp(pString, "height"))
936 return ATTRIBUTE_HEIGHT;
937 else if (!strcmp(pString, "fit"))
938 return ATTRIBUTE_FIT;
939 else if (!strcmp(pString, "backgroundColor"))
940 return ATTRIBUTE_BGCOLOR;
941 else if (!strcmp(pString, "dur"))
942 return ATTRIBUTE_DUR;
943 else if (!strcmp(pString, "src"))
944 return ATTRIBUTE_SRC;
945 else if (!strcmp(pString, "color"))
946 return ATTRIBUTE_COLOR;
947 else if (!strcmp(pString, "bold"))
948 return ATTRIBUTE_BOLD;
949 else if (!strcmp(pString, "underline"))
950 return ATTRIBUTE_UNDERLINE;
951 else if (!strcmp(pString, "italic"))
952 return ATTRIBUTE_ITALIC;
953 else if (!strcmp(pString, "reverse"))
954 return ATTRIBUTE_REVERSE;
955 else if (!strcmp(pString, "direction"))
956 return ATTRIBUTE_DIRECTION;
957 else if (!strcmp(pString, "size"))
958 return ATTRIBUTE_SIZE;
959 else if (!strcmp(pString, "font"))
960 return ATTRIBUTE_FONT;
961 else if (!strcmp(pString, "region"))
962 return ATTRIBUTE_REGION;
963 else if (!strcmp(pString, "name"))
964 return ATTRIBUTE_NAME;
965 else if (!strcmp(pString, "value"))
966 return ATTRIBUTE_VALUE;
967 else if (!strcmp(pString, "alt"))
968 return ATTRIBUTE_ALT;
969 else if (!strcmp(pString, "type"))
970 return ATTRIBUTE_TYPE;
971 else if (!strcmp(pString, "subtype"))
972 return ATTRIBUTE_SUBTYPE;
973 else if (!strcmp(pString, "content"))
974 return ATTRIBUTE_CONTENT;
975 else if (!strcmp(pString, "transIn"))
976 return ATTRIBUTE_TRANSIN;
977 else if (!strcmp(pString, "transOut"))
978 return ATTRIBUTE_TRANSOUT;
979 else if (!strcmp(pString, "begin"))
980 return ATTRIBUTE_BEGIN;
981 else if (!strcmp(pString, "end"))
982 return ATTRIBUTE_END;
983 else if (!strcmp(pString, "repeatCount"))
984 return ATTRIBUTE_REPEAT_COUNT;
985 #ifdef MMS_SMIL_ANIMATE
986 else if (!strcmp(pString, "attributeName"))
987 return ATTRIBUTE_ATTRIBUTE_NAME;
988 else if (!strcmp(pString, "attributeType"))
989 return ATTRIBUTE_ATTRIBUTE_TYPE;
990 else if (!strcmp(pString, "targetElement"))
991 return ATTRIBUTE_TARGET_ELEMENT;
992 else if (!strcmp(pString, "from"))
993 return ATTRIBUTE_FROM;
994 else if (!strcmp(pString, "to"))
996 else if (!strcmp(pString, "by"))
998 else if (!strcmp(pString, "values"))
999 return ATTRIBUTE_VALUES;
1000 else if (!strcmp(pString, "calcMode"))
1001 return ATTRIBUTE_CALCMODE;
1007 bool MmsSmilGetFontAttrib(char *pString)
1009 if (!strcmp(pString, "true"))
1015 MmsTextDirection MmsSmilGetFontDirection(char *pString)
1017 MmsTextDirection direction = MMS_TEXT_DIRECTION_INVALID;
1019 if (!strcmp(pString, "right"))
1020 direction = MMS_TEXT_DIRECTION_RIGHT;
1021 else if (!strcmp(pString, "down"))
1022 direction = MMS_TEXT_DIRECTION_DOWN;
1027 int MmsSmilGetFontSizeValue(char *pString)
1029 MSG_DEBUG(" #### content = %s #### ", pString);
1030 if (!strcmp(pString, "small"))
1031 return MMS_SMIL_FONT_SIZE_SMALL;
1032 else if (!strcmp(pString, "normal"))
1033 return MMS_SMIL_FONT_SIZE_NORMAL;
1034 else if (!strcmp(pString, "large"))
1035 return MMS_SMIL_FONT_SIZE_LARGE;
1037 return atoi(pString);
1040 MmsSmilFontType MmsSmilGetFontTypeValue(char *pString)
1042 MSG_DEBUG(" #### content = %s #### ", pString);
1044 if (!strcmp(pString, "normal"))
1045 return MMS_SMIL_FONT_TYPE_NORMAL;
1046 else if (!strcmp(pString, "italic"))
1047 return MMS_SMIL_FONT_TYPE_ITALIC;
1048 else if (!strcmp(pString, "bold"))
1049 return MMS_SMIL_FONT_TYPE_BOLD;
1050 else if (!strcmp(pString, "underline"))
1051 return MMS_SMIL_FONT_TYPE_UNDERLINE;
1053 return MMS_SMIL_FONT_TYPE_NORMAL;
1056 bool MmsSmilGetMediaFilePath(MMS_MEDIA_S *pMedia, char *pszTemp, int msgID)
1059 MSG_DEBUG("pMedia is NULL");
1063 snprintf(pMedia->szFilePath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_DATA_PATH, pMedia->szSrc);
1064 MSG_DEBUG("pMedia's filePath: %s", pMedia->szFilePath);
1066 __MmsGetRealFileName(pMedia->mediatype, pMedia->szSrc, pMedia->szFileName, msgID);
1067 MSG_DEBUG("pMedia's fileName: %s", pMedia->szFileName);
1069 snprintf(pMedia->szContentID, MSG_MSG_ID_LEN+1, "%s", pszTemp);
1070 MSG_DEBUG("pMedia's ContentID: %s", pMedia->szContentID);
1076 /** @fn bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
1077 * @brief Forms Smil Buffer using pstMsgBody. \n
1078 * @param[in/out] pstMsgBody is Message handle. \n
1079 * @retval TRUE In case of Success. \n
1080 * @retval FALSE In case of failure. \n
1082 bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
1084 HMmsSmil hSmilDoc = INVALID_HOBJ;
1090 MMS_PAGE_S *pstPage;
1091 MMS_MEDIA_S *pstMedia;
1092 MMS_SMIL_REGION *pstRegion;
1097 hSmilDoc = MmsSmilCreateEmptySmilDoc();
1098 MSG_DEBUG("Smil Doc =%d",hSmilDoc);
1099 if (INVALID_HOBJ == hSmilDoc) {
1100 MSG_DEBUG("Invalid SmilDoc[%d]",hSmilDoc);
1103 // Add Root Layout to Smil Document
1104 if (false == MmsSmilAddRootLayout(hSmilDoc, &(pstMsgBody->rootlayout))) {
1105 MSG_DEBUG("MmsSmilAddRootLayout Failed");
1106 MmsSmilDestroyDoc(hSmilDoc);
1108 //Add Region list to Smil Document
1109 nRegionCount = pstMsgBody->regionCnt;
1110 MSG_DEBUG(" Region Count =%d",nRegionCount);
1111 for (nIndex = 0; nIndex < nRegionCount; nIndex++) {
1112 MSG_DEBUG("Calling _MsgMmsGetSmilRegion");
1113 pstRegion = _MsgMmsGetSmilRegion(pstMsgBody, nIndex);
1114 if (NULL == pstRegion) {
1115 MSG_DEBUG("pstRegion is NULL");
1116 MmsSmilDestroyDoc(hSmilDoc);
1119 MSG_DEBUG("Calling MmsSmilAddRegion");
1120 if (false == MmsSmilAddRegion(hSmilDoc, pstRegion)) {
1121 MSG_DEBUG("Adding Region to smil doc failed");
1122 MmsSmilDestroyDoc(hSmilDoc);
1126 // Add page list to Smil Document
1127 nTotalPageNum = pstMsgBody->pageCnt ;
1128 MSG_DEBUG(" Page Count =%d",nTotalPageNum);
1129 for (nIndex = 0; nIndex < nTotalPageNum; nIndex++) {
1130 MSG_DEBUG("Calling _MsgMmsGetPage");
1131 pstPage = _MsgMmsGetPage(pstMsgBody, nIndex);
1132 if (NULL == pstPage) {
1133 MSG_DEBUG("pstPage is NULL");
1134 MmsSmilDestroyDoc(hSmilDoc);
1137 // Add page to smil doc
1138 MSG_DEBUG("Calling MmsSmilAddPage");
1139 if (false == MmsSmilAddPage(hSmilDoc, pstPage)) {
1140 MSG_DEBUG("Adding page to smil doc failed");
1141 MmsSmilDestroyDoc(hSmilDoc);
1144 nTotalMediaNum = pstPage->mediaCnt;
1145 MSG_DEBUG(" Media Count =%d",nTotalMediaNum);
1146 for (nMediaIndex = 0; nMediaIndex < nTotalMediaNum; nMediaIndex++) {
1147 MSG_DEBUG("Calling _MsgMmsGetMedia");
1148 pstMedia = _MsgMmsGetMedia(pstPage, nMediaIndex);
1149 if (NULL == pstMedia) {
1150 MSG_DEBUG("pMedia is NULL");
1151 MmsSmilDestroyDoc(hSmilDoc);
1154 MSG_DEBUG("Calling MmsSmilAddMedia");
1155 if (false == MmsSmilAddMedia(hSmilDoc, nIndex, nMediaIndex, pstMedia, pstMedia->szContentID)) {
1156 MSG_DEBUG("MmsSmilAddMedia failed");
1157 MmsSmilDestroyDoc(hSmilDoc);
1162 MSG_DEBUG("MMSGenerateSmilBuffer: Start update template");
1163 pszRawData = MmsSmilGetRawData(hSmilDoc);
1164 if (NULL == pszRawData) {
1165 MSG_DEBUG("MMSGenerateSmilBuffer: MmsSmilGetRawData failed");
1166 MmsSmilDestroyDoc(hSmilDoc);
1170 char fullpath[MSG_FILEPATH_LEN_MAX] = {0,};
1171 snprintf(fullpath, MSG_FILEPATH_LEN_MAX, MSG_SMIL_FILE_PATH"%s", pstMsgBody->szSmilFilePath);
1173 if (MsgWriteSmilFile(fullpath, pszRawData, strlen(pszRawData) + 1) == false) {
1174 MSG_DEBUG("MMSGenerateSmilBuffer: MsgWriteSmilFile failed");
1175 xmlFree((xmlChar*)pszRawData);
1176 MmsSmilDestroyDoc(hSmilDoc);
1180 MSG_DEBUG("MMSGenerateSmilBuffer: complete update template\n");
1181 xmlFree((xmlChar*)pszRawData);
1182 MmsSmilDestroyDoc(hSmilDoc);
1187 /** @fn static HMmsSmil MmsSmilCreateEmptySmilDoc(void)
1188 * @brief Creates default Smil Doc based on input gszEmptyRawDoc. \n
1189 * @retval Returns Smil Document number. \n
1191 HMmsSmil MmsSmilCreateEmptySmilDoc(void)
1197 hMmsSmil = MmsSmilCreateSmilDoc(gszEmptyRawDoc);
1199 MSG_DEBUG("Create an empty smilDoc.(Handle = %d)", hMmsSmil);
1206 /** @fn static HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
1207 * @brief Creates Smil Doc based on input pszRawData. \n
1208 * @param[in] pszRawData is smil buffer. \n
1209 * @retval Returns Smil Document number. \n
1211 HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
1214 xmlNodePtr stRootNode;
1218 // Destroy smil doc if present
1219 if (NULL != __gpaMmsSmilDoc[nSmilDocNo]) {
1220 MSG_DEBUG("Calling MmsSmilDestroyDoc");
1221 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1222 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1226 for (nSmilDocNo = 0; nSmilDocNo < MMS_SMIL_MAX_DOC; nSmilDocNo++) {
1227 if (NULL == __gpaMmsSmilDoc[nSmilDocNo])
1231 if (MMS_SMIL_MAX_DOC == nSmilDocNo) {
1232 MSG_DEBUG("SmilDoc table is full. Can't create.");
1233 return INVALID_HOBJ;
1235 __gpaMmsSmilDoc[nSmilDocNo] = (MmsSmilDoc*)malloc(sizeof(MmsSmilDoc));
1236 if (NULL == __gpaMmsSmilDoc[nSmilDocNo]) {
1237 MSG_DEBUG("Memory Allocation Failed.");
1238 return INVALID_HOBJ;
1240 memset(__gpaMmsSmilDoc[nSmilDocNo], 0, sizeof(MmsSmilDoc));
1242 __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc = xmlParseMemory(pszRawData, strlen(pszRawData));
1243 if (NULL == __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1244 MSG_DEBUG("Document not parsed successfully.");
1245 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1246 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1248 return INVALID_HOBJ;
1250 stRootNode = xmlDocGetRootElement(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
1251 if (NULL == stRootNode) {
1252 MSG_DEBUG("Empty document\n");
1253 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1254 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1256 return INVALID_HOBJ;
1258 if (xmlStrcmp(stRootNode->name, (const xmlChar *) "smil")) {
1259 MSG_DEBUG("Document of the wrong type, root node != smil");
1260 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1261 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1263 return INVALID_HOBJ;
1266 __gpaMmsSmilDoc[nSmilDocNo]->pstRootNode = stRootNode;
1269 return ((HMmsSmil)nSmilDocNo);
1272 /** @fn static bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
1273 * @brief Destroys Smil Doc. \n
1274 * @param[in] hSmilDoc is smil doc number. \n
1275 * @retval TRUE In case of Success. \n
1276 * @retval FALSE In case of failure. \n
1278 bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
1280 int nSmilDocNo = (int)hSmilDoc;
1284 if (0 <= nSmilDocNo &&
1285 nSmilDocNo < MMS_SMIL_MAX_DOC &&
1286 __gpaMmsSmilDoc[nSmilDocNo]) {
1287 if (__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1288 xmlFreeDoc(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
1291 if (__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode) {
1294 free(__gpaMmsSmilDoc[nSmilDocNo]);
1295 __gpaMmsSmilDoc[nSmilDocNo] = NULL;
1297 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1305 /** @fn static bool IsValidSmilDocNo(int nSmilDocNo)
1306 * @brief Form Smil Doc. \n
1307 * @param[in] hSmilDoc is smil doc number. \n
1308 * @retval Returns Smil Buffer In case of success. \n
1309 * @retval Returns NULL In case of failure. \n
1311 bool IsValidSmilDocNo(int nSmilDocNo)
1313 bool bIsValidSmil = false;
1317 if (0 <= nSmilDocNo &&
1318 nSmilDocNo < MMS_SMIL_MAX_DOC &&
1319 __gpaMmsSmilDoc[nSmilDocNo] &&
1320 __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1321 bIsValidSmil = true;
1325 return bIsValidSmil;
1328 /** @fn static char MmsSmilGetRawData(HMmsSmil hSmilDoc)
1329 * @brief Form Smil Doc. \n
1330 * @param[in] hSmilDoc is smil doc number. \n
1331 * @retval Returns Smil Buffer In case of success. \n
1332 * @retval Returns NULL In case of failure. \n
1334 char *MmsSmilGetRawData(HMmsSmil hSmilDoc)
1336 int nSmilDocNo = (int)hSmilDoc;
1337 char *pszRawData = NULL;
1341 if (IsValidSmilDocNo(nSmilDocNo)) {
1342 xmlSaveFormatFileEnc("-", __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, "UTF-8", 1);
1343 xmlDocDumpMemory(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, (xmlChar **)(&pszRawData) , NULL);
1344 if (NULL == pszRawData) {
1345 MSG_DEBUG("Invalid pSmilDoc (now wellformed document)");
1349 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1354 /** @fn static bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
1355 * @brief Add Page to Smil Doc. \n
1356 * @param[in] hSmilDoc is smil doc number. \n
1357 * @param[in] pstSmilPage specifies page information. \n
1358 * @retval TRUE In case of Success. \n
1359 * @retval FALSE In case of failure. \n
1361 bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
1363 int nSmilDocNo = hSmilDoc;
1369 if (IsValidSmilDocNo(nSmilDocNo)) {
1370 xmlNodePtr pstParElement;
1371 xmlNodePtr pstBodyElement;
1372 xmlNodePtr pstParList;
1373 char szBuf[MSG_STDSTR_SHORT] = {0, };
1375 pstBodyElement = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"body");
1377 if (NULL == pstBodyElement) {
1378 MSG_DEBUG("There is no <body> node. Can't create <par> node.");
1381 MSG_DEBUG("Body Element Name = %s", (char *)pstBodyElement->name);
1382 /* Create "par" node and insert it */
1383 pstParElement = xmlNewNode(NULL, (xmlChar *)"par");
1385 if (NULL == pstParElement) {
1386 MSG_DEBUG("Can't create <par> node. (from XmlParser) \n");
1389 MSG_DEBUG("Par Element Name = %s", (char *)pstParElement->name);
1391 /* Add attributes to "par" */
1392 if (pstSmilPage->nDur > 0) {
1393 snprintf(szBuf, MSG_STDSTR_SHORT, "%dms", pstSmilPage->nDur);
1394 xmlSetProp(pstParElement, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1396 /* Find the insertion point : right sibling of the last <par> node or first child of <body> */
1398 pstParList = xmlGetLastChild(pstBodyElement);
1401 ret = __MmsSmilInsertNode(pstBodyElement, pstParList, pstParElement);
1403 ret = __MmsInsertFirstChild(pstBodyElement, pstParElement);
1406 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1413 /** @fn static bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
1414 * @brief Add Rootlayout to Smil Doc. \n
1415 * @param[in] hSmilDoc is smil doc number. \n
1416 * @param[in] pstSmilRootLayout specifies RootLayout information. \n
1417 * @retval TRUE In case of Success. \n
1418 * @retval FALSE In case of failure. \n
1420 bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
1422 int nSmilDocNo = hSmilDoc;
1423 xmlNodePtr pstRootLayout = NULL;
1424 xmlNodePtr pstLayoutList = NULL;
1425 xmlNodePtr pstRootLayoutList = NULL;
1426 char szBuf[MSG_STDSTR_SHORT] = {0, };
1430 if (IsValidSmilDocNo(nSmilDocNo)) {
1431 pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
1433 if (NULL == pstLayoutList) {
1434 MSG_DEBUG("There is no <layout> node. Can't create <root-layout> node.");
1437 MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
1439 pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
1441 if (NULL != pstRootLayoutList) {
1442 MSG_DEBUG("MmsSmilAddRootLayout: There is <root-layout> node already");
1443 MSG_DEBUG("Root Layout Element Name = %s type=%d\n", (char *)pstRootLayoutList->name);
1446 /* Create "root-layout" node and insert it */
1447 pstRootLayout = xmlNewNode(NULL, (xmlChar *)"root-layout");
1448 if (NULL == pstRootLayout) {
1449 MSG_DEBUG("Can't create <root-layout> node. (from XmlParser)");
1452 MSG_DEBUG("Root Layout Element Name = %s", (char *)pstRootLayout->name);
1454 if (pstSmilRootLayout->bgColor != SP_NO_COLOR_SET) { // Replace value later
1455 xmlSetProp(pstRootLayout, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRootLayout->bgColor));
1457 MSG_DEBUG(" Set Width");
1458 if (true == pstSmilRootLayout->width.bUnitPercent) {
1459 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->width.value);
1460 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
1462 if (pstSmilRootLayout->width.value > 0) {
1463 snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->width.value);
1464 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
1466 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)"100%");
1469 MSG_DEBUG(" Set Height");
1470 if (true == pstSmilRootLayout->height.bUnitPercent) {
1471 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->height.value);
1472 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
1474 if (pstSmilRootLayout->height.value > 0) {
1475 snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->height.value);
1476 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
1478 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)"100%");
1481 __MmsInsertFirstChild(pstLayoutList, pstRootLayout);
1485 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1492 /** @fn static bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
1493 * @brief Add Region to Smil Doc. \n
1494 * @param[in] hSmilDoc is smil doc number. \n
1495 * @param[in] pstSmilRegion specifies Region information. \n
1496 * @retval TRUE In case of Success. \n
1497 * @retval FALSE In case of failure. \n
1499 bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
1501 int nSmilDocNo = hSmilDoc;
1505 if (IsValidSmilDocNo(nSmilDocNo)) {
1507 int nRootHeight = 0;
1508 xmlNodePtr pstRegion;
1509 xmlNodePtr pstLayoutList;
1510 xmlNodePtr pstRootLayoutList;
1511 xmlAttrPtr pAttribute;
1512 char szBuf[MSG_STDSTR_SHORT] = {0, };
1514 pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
1515 if (NULL == pstLayoutList) {
1516 MSG_DEBUG(" There is no <layout> node. Can't create <region> node");
1519 MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
1521 /* Find the insertion point : right sibling of the last root-layout node or first child of pLayout */
1522 pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
1524 if (NULL == pstRootLayoutList) {
1525 MSG_DEBUG("There is no <root-layout> node. Can't create <root-layout> node.");
1528 MSG_DEBUG("Root Layout Element Name = %s ", (char *)pstRootLayoutList->name);
1529 pAttribute = pstRootLayoutList->properties;
1532 if (NULL == pAttribute) {
1533 MSG_DEBUG("There is no Attribute in <root-layout> node.");
1537 xmlAttrPtr pstAttr = pAttribute;
1538 for ( ; pstAttr; pstAttr = pstAttr->next) {
1540 MSG_DEBUG("AttributeType: (%s, %s) ", pstAttr->name, pstAttr->children->content);
1541 switch (attrType = MmsSmilGetAttrID((char *)pstAttr->name)) {
1542 case ATTRIBUTE_WIDTH:
1546 if (strchr((char *)pstAttr->children->content, '%'))
1547 bUnitPercent = true;
1549 bUnitPercent = false;
1551 nRootWidth = atoi((char *)pstAttr->children->content);
1555 case ATTRIBUTE_HEIGHT:
1559 if (strchr((char *)pstAttr->children->content, '%'))
1560 bUnitPercent = true;
1562 bUnitPercent = false;
1564 nRootHeight = atoi((char *)pstAttr->children->content);
1570 /* Create "region" node and insert it */
1571 MSG_DEBUG("Create Region Node");
1572 pstRegion = xmlNewNode(NULL, (xmlChar *)"region");
1573 if (NULL == pstRegion) {
1574 MSG_DEBUG("Can't create <region> node. (from XmlParser)");
1577 /* Add attributes */
1578 if (pstSmilRegion) {
1579 MSG_DEBUG(" [Set Attribute] : Region Id");
1580 if (strlen(pstSmilRegion->szID) > 0) {
1581 xmlSetProp(pstRegion, (const xmlChar *)"id", (const xmlChar *)pstSmilRegion->szID);
1583 MSG_DEBUG(" [Set Attribute] : BkGrd Color");
1584 // Default Color WHITE, always send
1585 if (pstSmilRegion->bgColor != SP_NO_COLOR_SET) {
1586 xmlSetProp(pstRegion, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRegion->bgColor));
1588 MSG_DEBUG(" [Set Attribute] : Width");
1590 if (true == pstSmilRegion->width.bUnitPercent) {
1591 if (pstSmilRegion->width.value > 0) {
1592 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->width.value);
1593 xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
1594 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width = %d \n", pstSmilRegion->width.value);
1597 // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
1598 // Validation should be done before this.
1599 if (pstSmilRegion->width.value >= 0 &&
1600 pstSmilRegion->width.value <= nRootWidth) {
1601 int iWidth = (pstSmilRegion->width.value * 100) / nRootWidth;
1603 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iWidth);
1604 xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
1605 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width= %d iWidth = %d \n", pstSmilRegion->width.value, iWidth);
1608 MSG_DEBUG(" [Set Attribute] : Height");
1609 if (true == pstSmilRegion->height.bUnitPercent) {
1610 if (pstSmilRegion->height.value > 0) {
1611 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->height.value);
1612 xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
1613 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d \n", pstSmilRegion->height.value);
1616 // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
1617 // Validation should be done before this.
1618 if (pstSmilRegion->height.value >= 0 &&
1619 pstSmilRegion->height.value <= nRootHeight) {
1620 int iHeight = (pstSmilRegion->height.value * 100) / nRootHeight;
1622 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iHeight);
1623 xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
1624 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d iHeight = %d \n", pstSmilRegion->height.value, iHeight);
1627 MSG_DEBUG(" [Set Attribute] : Left");
1628 if (true == pstSmilRegion->nLeft.bUnitPercent) {
1629 if (pstSmilRegion->nLeft.value > 0) {
1630 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nLeft.value);
1631 xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
1632 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->left = %d \n", pstSmilRegion->nLeft.value);
1635 // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
1636 // Validation should be done before this.
1637 if (pstSmilRegion->nLeft.value >= 0) {
1638 int iLeft = (pstSmilRegion->nLeft.value * 100) / nRootWidth;
1640 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iLeft);
1641 xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
1642 MSG_DEBUG("MmsSmilAddRegion: SmilRegion->iLeft = %d iLeft = %d \n", pstSmilRegion->nLeft.value, iLeft);
1645 MSG_DEBUG(" [Set Attribute] : Top");
1646 if (true == pstSmilRegion->nTop.bUnitPercent) {
1647 if (pstSmilRegion->nTop.value > 0) {
1648 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nTop.value);
1649 xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
1650 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d \n", pstSmilRegion->nTop.value);
1653 // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
1654 // Validation should be done before this.
1655 if (pstSmilRegion->nTop.value >= 0) {
1656 int iTop = (pstSmilRegion->nTop.value * 100) / nRootHeight;
1658 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iTop);
1659 xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
1660 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d iTop = %d \n", pstSmilRegion->nTop.value, iTop);
1663 MSG_DEBUG(" [Set Attribute] : Fit");
1665 if (MMSUI_IMAGE_REGION_FIT_MEET == pstSmilRegion->fit) {
1666 xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"meet");
1667 } else if (MMSUI_IMAGE_REGION_FIT_HIDDEN == pstSmilRegion->fit) {
1668 xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"hidden");
1671 MSG_DEBUG("There is no attribute in <region> node\n");
1673 __MmsSmilInsertNode(pstLayoutList, pstRootLayoutList, pstRegion);
1678 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
1683 /** @fn static bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1684 * @brief Add Media to Smil Doc. \n
1685 * @param[in] hSmilDoc is smil doc number. \n
1686 * @param[in] nPageNo specifies page number to which media belongs. \n
1687 * @param[in] pstSmilMedia specifies Media information. \n
1688 * @param[in] pszContentID specifies Content ID of media. \n
1689 * @retval TRUE In case of Success. \n
1690 * @retval FALSE In case of failure. \n
1692 bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1694 int nSmilDocNo = hSmilDoc;
1698 if (NULL == pszContentID) {
1699 MSG_DEBUG(" Content Id is NULL");
1702 memset(pszContentID, 0, MMS_CONTENT_ID_LEN + 1);
1703 if (IsValidSmilDocNo(nSmilDocNo)) {
1706 xmlNode *pstLastChild;
1707 xmlNodePtr pstParList;
1710 pstParList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"par");
1711 if (NULL == pstParList) {
1712 MSG_DEBUG("There is no <par> node. Can't create <media> node.");
1715 MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
1716 for (nIndex = 0; (pstParList && nIndex < nPageNo); nIndex++) {
1717 pstParList = pstParList->next;
1719 if (NULL == pstParList) {
1720 MSG_DEBUG("There is no such page node. Can't insert <media> node.");
1723 MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
1724 /* Find insertion point and make a contentID */
1726 pstLastChild = xmlGetLastChild(pstParList);
1728 pszExt = strrchr(pstSmilMedia->szFileName, '.');
1729 if (pszExt && !strrchr(pszExt, '/'))
1730 snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu%s", (ULONG)nPageNo, (ULONG)nMediaIdx, pszExt);
1732 snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu", (ULONG)nPageNo, (ULONG)nMediaIdx);
1734 /* Create <media> node and insert set attribute */
1735 MSG_DEBUG(" Create Media Node");
1736 switch (pstSmilMedia->mediatype) {
1737 case MMS_SMIL_MEDIA_TEXT:
1738 pstMedia = __MmsCreateTextNode(pstSmilMedia, pszContentID);
1740 case MMS_SMIL_MEDIA_AUDIO:
1741 case MMS_SMIL_MEDIA_VIDEO:
1742 case MMS_SMIL_MEDIA_IMG:
1743 pstMedia = __MmsCreateMMNode(pstSmilMedia, pszContentID);
1746 MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
1750 if (NULL == pstMedia) {
1751 MSG_DEBUG("Can't create <media> node. (from XmlParser) (media-type:%d)", pstSmilMedia->mediatype);
1755 /* Find the insertion point : the last child of <par> node */
1757 __MmsSmilInsertNode(pstParList, pstLastChild, pstMedia);
1759 __MmsInsertFirstChild(pstParList, pstMedia);
1764 MSG_DEBUG("MmsSmilAddMedia: Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
1769 /** @fn static xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1770 * @brief Create Text Element. \n
1771 * @param[in] pstSmilMedia specifies Media information. \n
1772 * @param[in] pszContentID specifies Content ID of media. \n
1773 * @retval Text Element node In case of Success. \n
1774 * @retval NULL In case of failure. \n
1776 xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1778 xmlNode *pstMedia = NULL;
1779 xmlNode *pstParam = NULL;
1780 char szBuf[MSG_STDSTR_SHORT] = {0, };
1781 char szSizeBuf[MSG_STDSTR_SHORT] = {0, };
1785 pstMedia = xmlNewNode(NULL, (xmlChar *)"text");
1786 if (NULL == pstMedia) {
1787 MSG_DEBUG("Can't create <Text> node.");
1790 MSG_DEBUG("Text Element Name = %s ", (char *)pstMedia->name);
1792 /* Add attributes */
1794 MSG_DEBUG("[Set Attribute] Region Id ");
1795 if (strlen(pstSmilMedia->regionId) > 0) {
1796 xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
1798 MSG_DEBUG("[Set Attribute] Begin ");
1799 if (pstSmilMedia->sMedia.sText.nBegin > 0) {
1800 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nBegin);
1801 xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *) szBuf);
1803 MSG_DEBUG("[Set Attribute] Duration");
1804 if (pstSmilMedia->sMedia.sText.nDurTime > 0) {
1805 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nDurTime);
1806 xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1808 MSG_DEBUG("[Set Attribute] Alternate");
1809 if (strlen(pstSmilMedia->szAlt) > 0) {
1810 snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
1811 xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
1813 MSG_DEBUG("[Set Attribute] Src");
1815 char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5]; // for "cid:"
1817 snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
1818 _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
1820 MSG_DEBUG("[Set Attribute] Font Foreground Color");
1822 if (pstSmilMedia->sMedia.sText.nColor!= SP_BLACK) { // Chnage after getting exact values
1823 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1825 if (NULL == pstParam) {
1826 MSG_DEBUG("Cannot create <param> node");
1829 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"foreground-color");
1830 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nColor));
1831 __MmsInsertFirstChild(pstMedia, pstParam);
1834 MSG_DEBUG("[Set Attribute] Font Background Color");
1836 if (pstSmilMedia->sMedia.sText.nBgColor != SP_BLACK) { // Chnage after getting exact values
1837 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1839 if (NULL == pstParam) {
1840 MSG_DEBUG("Cannot create <param> node");
1843 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"background-color");
1844 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nBgColor));
1845 __MmsInsertFirstChild(pstMedia, pstParam);
1848 MSG_DEBUG("[Set Attribute] Size");
1849 if (pstSmilMedia->sMedia.sText.nSize > 0) {
1850 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1851 if (NULL == pstParam) {
1852 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1856 if (pstSmilMedia->sMedia.sText.nSize <= MMS_SMIL_FONT_SIZE_SMALL)
1857 strcpy(szSizeBuf, "small");
1858 else if ((pstSmilMedia->sMedia.sText.nSize > MMS_SMIL_FONT_SIZE_SMALL) && (pstSmilMedia->sMedia.sText.nSize < MMS_SMIL_FONT_SIZE_LARGE))
1859 strcpy(szSizeBuf, "normal");
1861 strcpy(szSizeBuf, "large");
1863 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textsize");
1864 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1865 __MmsInsertFirstChild(pstMedia, pstParam);
1868 if (pstSmilMedia->sMedia.sText.bBold == true) {
1869 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1870 if (NULL == pstParam) {
1871 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1875 strcpy(szSizeBuf, "bold");
1877 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1878 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1879 __MmsInsertFirstChild(pstMedia, pstParam);
1882 if (pstSmilMedia->sMedia.sText.bItalic == true) {
1883 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1884 if (NULL == pstParam) {
1885 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1889 strcpy(szSizeBuf, "italic");
1891 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1892 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1893 __MmsInsertFirstChild(pstMedia, pstParam);
1896 if (pstSmilMedia->sMedia.sText.bUnderLine == true) {
1897 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1898 if (NULL == pstParam) {
1899 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1903 strcpy(szSizeBuf, "underline");
1905 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1906 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1907 __MmsInsertFirstChild(pstMedia, pstParam);
1915 /** @fn static xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1916 * @brief Create Image/Audio/Video Element. \n
1917 * @param[in] pstSmilMedia specifies Media information. \n
1918 * @param[in] pszContentID specifies Content ID of media. \n
1919 * @retval Image/Audio/Video Element node In case of Success. \n
1920 * @retval NULL In case of failure. \n
1922 xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1924 xmlNode *pstMedia = NULL;
1925 char szBuf[MSG_STDSTR_SHORT] = {0, };
1932 switch (pstSmilMedia->mediatype) {
1933 case MMS_SMIL_MEDIA_AUDIO:
1934 pstMedia = xmlNewNode(NULL, (xmlChar *)"audio");
1937 case MMS_SMIL_MEDIA_VIDEO:
1938 pstMedia = xmlNewNode(NULL, (xmlChar *)"video");
1941 case MMS_SMIL_MEDIA_IMG:
1942 pstMedia = xmlNewNode(NULL, (xmlChar *)"img");
1946 MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
1951 char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5]; // for "cid:"
1953 MSG_DEBUG("[Set Attribute] Region Id ");
1954 if (strlen(pstSmilMedia->regionId) > 0) {
1955 xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
1957 MSG_DEBUG("[Set Attribute] Src ");
1958 snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
1959 _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
1961 MSG_DEBUG("[Set Attribute] Begin ");
1962 if (pstSmilMedia->sMedia.sAVI.nBegin > 0) {
1963 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nBegin);
1964 xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *)szBuf);
1966 MSG_DEBUG("[Set Attribute] Duration ");
1967 if (pstSmilMedia->sMedia.sAVI.nDurTime > 0) {
1968 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nDurTime);
1969 xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1971 MSG_DEBUG("[Set Attribute] Alt ");
1972 if (strlen(pstSmilMedia->szAlt) > 0) {
1973 snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
1974 xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
1977 MSG_DEBUG("There is no attribute in such-<media> node");
1984 /** @fn static bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
1985 * @brief Inserts first child to parent node. \n
1986 * @param[in] pstParent specifies Parent node. \n
1987 * @param[in] pstCurr specifies Child node. \n
1988 * @retval TRUE In case of Success. \n
1989 * @retval FALSE In case of failure. \n
1991 bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
1997 if (NULL == xmlAddChild(pstParent, pstCurr)) {
1998 MSG_DEBUG("%s Node not added", pstCurr->name);
2007 /** @fn static bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
2008 * @brief Inserts node. \n
2009 * @param[in] pstParent specifies Parent node. \n
2010 * @param[in] pstLeftSibling specifies Left Sibling node. \n
2011 * @param[in] pstCurr specifies Child node. \n
2012 * @retval TRUE In case of Success. \n
2013 * @retval FALSE In case of failure. \n
2015 bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
2020 if (pstLeftSibling) {
2021 /* Parent Node is Unused */
2023 while (pstLeftSibling->next !=NULL)
2024 pstLeftSibling = pstLeftSibling->next;
2026 if (NULL == xmlAddNextSibling(pstLeftSibling, pstCurr)) {
2027 MSG_DEBUG("%s Node not added", pstCurr->name);
2031 if (NULL == xmlAddChild(pstParent, pstCurr)) {
2032 MSG_DEBUG("%s Node not added", pstCurr->name);
2041 bool __MmsGetRealFileName(MmsSmilMediaType mediaType, char *pszSrc, char *pszName, int msgID)
2047 MSG_DEBUG("__MmsUiGetRealFileName: mediaType[%d]", mediaType);
2048 MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
2051 MSG_DEBUG("__MmsUiGetRealFileName: pszName is null\n");
2055 if (mediaType == MMS_SMIL_MEDIA_TEXT || mediaType == MMS_SMIL_MEDIA_INVALID) {
2056 MSG_DEBUG("__MmsUiGetRealFileName: invalid mediaType(=%d)\n", mediaType);
2060 partCnt = MmsGetMediaPartCount(msgID);
2063 MSG_DEBUG("__MmsUiGetRealFileName: partCnt < 0, (=%d)\n", partCnt);
2067 for (i = 0; i < partCnt; i++) {
2068 MmsGetMediaPartHeader(i, &partHeader);
2070 if (mediaType == MMS_SMIL_MEDIA_AUDIO ||
2071 mediaType == MMS_SMIL_MEDIA_VIDEO ||
2072 mediaType == MMS_SMIL_MEDIA_IMG) {
2073 if (!strcmp(partHeader.param.szFileName , pszSrc)) {
2075 MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
2084 if (partHeader.param.szName[0] != '\0') {
2085 int nameLen = strlen(partHeader.param.szName);
2087 if (nameLen > MSG_FILENAME_LEN_MAX - 1) {
2090 strcpy(pszName, partHeader.param.szName);
2098 /** @fn static void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
2099 * @brief Sets Attribute. \n
2100 * @param[in] pNode specifies node. \n
2101 * @param[in] szField specifies attribute field. \n
2102 * @param[in] szValue specifies value of field \n
2104 void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
2108 if (pNode && szField && strlen(szField)) {
2109 if (szValue && strlen(szValue)) {
2110 xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)szValue);
2112 xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)"");
2119 /** @fn static char *__MmsSmilFindColorValue(int nValue)
2120 * @brief Converts color to RGB. \n
2121 * @param[in] nValue specifies color value. \n
2122 * @retval RGB value. \n
2124 char *__MmsSmilFindColorValue(int nValue)
2126 unsigned char red = (nValue & 0xFF0000) >> 16;
2127 unsigned char green = (nValue & 0x00FF00) >> 8;
2128 unsigned char blue = nValue & 0x0000FF;
2132 snprintf(gszColor,MMS_SMIL_COLOR_SIZE, "#%02x%02x%02x", red, green, blue);
2133 MSG_DEBUG("__MmsSmilFindColorValue: gszColor %s \n", gszColor);
2139 /** @fn static xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszValue)
2140 * @brief Get node based on pszValue. \n
2141 * @param[in] pNode specifies node. \n
2142 * @param[in] pszName specifies name field. \n
2143 * @retval RGB value. \n
2145 xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName)
2149 if ((NULL != pstNode) && (NULL != pszName)) {
2150 xmlNodePtr pstTempNode;
2151 xmlNodePtr pstReturnNode;
2153 pstTempNode = pstNode;
2155 for ( ; pstTempNode; pstTempNode = pstTempNode->next) {
2156 MSG_DEBUG("\n Node Name = %s[%p] children =%p \n", (char *)pstTempNode->name, pstTempNode, pstTempNode->children);
2157 MSG_DEBUG("\n Compare Parent Node = %s[%p] \n", (char *)pstTempNode->name, pstTempNode);
2158 if (0 == strcasecmp((char *)pstTempNode->name, pszName)) {
2162 if (pstTempNode->children) {
2163 MSG_DEBUG("\n Enter Inside\n");
2164 pstReturnNode = UtilxmlStringGetNodeList(pstTempNode->children, pszName);
2165 if (NULL != pstReturnNode) {
2166 return pstReturnNode;