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.
21 #include "MmsPluginSmil.h"
22 #include "MmsPluginMessage.h"
23 #include "MmsPluginStorage.h"
25 #include "MmsPluginCodec.h"
26 #include "MsgMmsMessage.h"
29 #include "MmsPluginSetup.h"
30 #include "MsgUtilFile.h"
32 /* static variables */
33 static char gszEmptyRawDoc[] = "<smil><head><layout></layout></head><body></body></smil>";
34 static MmsSmilDoc *__gpaMmsSmilDoc[MMS_SMIL_MAX_DOC]={NULL, };
35 static char gszColor[MMS_SMIL_COLOR_SIZE] = {0, };
38 char *MmsSmilGetPresentationData(msg_message_id_t msgId)
42 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
45 MSG_DEBUG("pMsg is NULL");
49 if (msgId != pMsg->msgID) {
50 MSG_DEBUG("Invalid Message Id");
54 if (!pMsg->msgBody.pPresentationBody)
57 if (!pMsg->msgBody.pPresentationBody->body.pText)
60 return pMsg->msgBody.pPresentationBody->body.pText;
66 bool MmsSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc)
70 MSG_DEBUG("%s", pSmilDoc);
71 doc = xmlParseMemory(pSmilDoc, strlen(pSmilDoc));
74 MSG_DEBUG("Document not parsed successfully. \n");
78 cur = xmlDocGetRootElement(doc);
81 MSG_DEBUG("empty document\n");
86 if (xmlStrcmp(cur->name, (const xmlChar *) "smil")) {
87 MSG_DEBUG("document of the wrong type, root node != smil");
92 MmsSmilGetElement(pMmsMsg, cur);
99 void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node)
105 MMS_SMIL_ROOTLAYOUT rootlayout = {};
106 static bool cmd[ELEMENT_MAX] = {false, };
107 static MMS_SMIL_REGION *pRegion;
108 static MMS_PAGE_S *pPage;
109 static MMS_MEDIA_S *pMedia;
110 static MMS_SMIL_TRANSITION *pTransition;
111 static MMS_SMIL_META *pMeta;
113 xmlNode *cur_node = NULL;
115 for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
116 MSG_DEBUG("******* node, name: %s ***\n", cur_node->name);
118 if (cur_node->type == XML_ELEMENT_NODE) {
119 // Get Smil Element =====================================================
120 MSG_DEBUG("*** node type: Element, name: %s ***\n", cur_node->name);
122 switch (elementType = MmsSmilGetElementID((char *)cur_node->name)) {
123 case ELEMENT_ROOTLAYOUT:
124 memset(cmd, 0, ELEMENT_MAX);
125 cmd[ELEMENT_ROOTLAYOUT] = true;
129 pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1);
130 memset(cmd, 0, ELEMENT_MAX);
131 cmd[ELEMENT_REGION] = true;
134 case ELEMENT_TRANSITION:
135 pTransition = (MMS_SMIL_TRANSITION *)calloc(sizeof(MMS_SMIL_TRANSITION), 1);
136 memset(cmd, 0, ELEMENT_MAX);
137 cmd[ELEMENT_TRANSITION] = true;
141 pMeta = (MMS_SMIL_META *)calloc(sizeof(MMS_SMIL_META), 1);
142 memset(cmd, 0, ELEMENT_MAX);
143 cmd[ELEMENT_META] = true;
147 pPage = (MMS_PAGE_S *)calloc(sizeof(MMS_PAGE_S), 1);
148 memset(cmd, 0, ELEMENT_MAX);
149 cmd[ELEMENT_PAR] = true;
152 case ELEMENT_PARAM: // Need to check the original element type
156 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
157 pMedia->mediatype = MMS_SMIL_MEDIA_TEXT;
158 memset(cmd, 0, ELEMENT_MAX);
159 cmd[ELEMENT_TEXT] = true;
163 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
164 pMedia->mediatype = MMS_SMIL_MEDIA_IMG;
165 memset(cmd, 0, ELEMENT_MAX);
166 cmd[ELEMENT_IMG] = true;
170 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
171 pMedia->mediatype = MMS_SMIL_MEDIA_AUDIO;
172 memset(cmd, 0, ELEMENT_MAX);
173 cmd[ELEMENT_AUDIO] = true;
177 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
178 pMedia->mediatype = MMS_SMIL_MEDIA_VIDEO;
179 memset(cmd, 0, ELEMENT_MAX);
180 cmd[ELEMENT_VIDEO] = true;
184 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
185 pMedia->mediatype = MMS_SMIL_MEDIA_IMG_OR_VIDEO;
186 memset(cmd, 0, ELEMENT_MAX);
187 cmd[ELEMENT_REF] = true;
190 case ELEMENT_ANIMATE:
191 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
192 pMedia->mediatype = MMS_SMIL_MEDIA_ANIMATE;
193 memset(cmd, 0, ELEMENT_MAX);
194 cmd[ELEMENT_ANIMATE] = true;
198 memset(cmd, 0, ELEMENT_MAX);
202 //Get Smil Attribute =====================================================
203 xmlAttr *pAttr = cur_node->properties;
204 SMIL_ATTRIBUTE_T paramType = ATTRIBUTE_UNKNOWN;
206 for ( ; pAttr; pAttr = pAttr->next) {
207 MSG_DEBUG("AttributeType: (%s, %s) ", pAttr->name, pAttr->children->content);
208 switch (attrType = MmsSmilGetAttrID((char *)pAttr->name)) {
211 if (cmd[ELEMENT_REGION]) {
212 strncpy(pRegion->szID, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
213 } else if (cmd[ELEMENT_TRANSITION]) {
214 strncpy(pTransition->szID, (char *)pAttr->children->content, MAX_SMIL_TRANSITION_ID - 1);
215 } else if (cmd[ELEMENT_META]) {
216 strncpy(pMeta->szID, (char *)pAttr->children->content, MAX_SMIL_META_ID - 1);
226 if (strchr((char *)pAttr->children->content, '%'))
229 bUnitPercent = false;
231 value = atoi((char *)pAttr->children->content);
233 if (cmd[ELEMENT_REGION]) {
234 pRegion->nTop.bUnitPercent = bUnitPercent;
235 pRegion->nTop.value = value;
245 if (strchr((char *)pAttr->children->content, '%'))
248 bUnitPercent = false;
250 value = atoi((char *)pAttr->children->content);
252 if (cmd[ELEMENT_REGION]) {
253 pRegion->nLeft.bUnitPercent = bUnitPercent;
254 pRegion->nLeft.value = value;
260 case ATTRIBUTE_WIDTH:
265 if (strchr((char *)pAttr->children->content, '%'))
268 bUnitPercent = false;
270 value = atoi((char *)pAttr->children->content);
272 if (cmd[ELEMENT_ROOTLAYOUT]) {
273 rootlayout.width.bUnitPercent = bUnitPercent;
274 rootlayout.width.value = value;
275 } else if (cmd[ELEMENT_REGION]) {
276 pRegion->width.bUnitPercent = bUnitPercent;
277 pRegion->width.value = value;
282 case ATTRIBUTE_HEIGHT:
287 if (strchr((char *)pAttr->children->content, '%'))
290 bUnitPercent = false;
292 value = atoi((char *)pAttr->children->content);
294 if (cmd[ELEMENT_ROOTLAYOUT]) {
295 rootlayout.height.bUnitPercent = bUnitPercent;
296 rootlayout.height.value = value;
297 } else if (cmd[ELEMENT_REGION]) {
298 pRegion->height.bUnitPercent = bUnitPercent;
299 pRegion->height.value = value;
305 if (cmd[ELEMENT_REGION]) {
306 if (!strcmp((char *)pAttr->children->content, "meet")) {
307 pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET;
309 pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN;
314 case ATTRIBUTE_BGCOLOR:
315 if (cmd[ELEMENT_ROOTLAYOUT])
316 rootlayout.bgColor = MmsSmilGetColorValue(pAttr->children->content);
317 else if (cmd[ELEMENT_REGION])
318 pRegion->bgColor = MmsSmilGetColorValue(pAttr->children->content);
319 else if (cmd[ELEMENT_TEXT])
320 pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
322 pMedia->sMedia.sAVI.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
327 if (cmd[ELEMENT_PAR])
328 pPage->nDur = MmsSmilGetTime((char *)pAttr->children->content);
329 else if (cmd[ELEMENT_TRANSITION])
330 pTransition->nDur = MmsSmilGetTime((char *)pAttr->children->content);
331 else if (cmd[ELEMENT_TEXT])
332 pMedia->sMedia.sText.nDurTime = MmsSmilGetTime((char *)pAttr->children->content);
334 pMedia->sMedia.sAVI.nDurTime = MmsSmilGetTime((char *)pAttr->children->content);
336 #ifdef MMS_SMIL_ANIMATE
337 if (cmd[ELEMENT_ANIMATE])
338 pMedia->sMedia.sAVI.nDur = MmsSmilGetTime((char *)pAttr->children->content);
345 char szTmpSrc[MSG_FILEPATH_LEN_MAX] = {0,};
346 char szOutBuf[MSG_FILEPATH_LEN_MAX] = {0, };
348 MsgMultipart *pPart = NULL;
351 szSrc = MsgChangeHexString((char *)pAttr->children->content);
355 memcpy(pMedia->szSrc, szSrc, strlen(szSrc) + 1);
358 cLen = strlen(pMedia->szSrc);
359 if (!strncasecmp(pMedia->szSrc, "cid:", 4)) {
360 strncpy(szTmpSrc, pMedia->szSrc + 4, cLen - 4);
361 szTmpSrc[cLen - 4] = '\0';
363 strncpy(szTmpSrc, pMedia->szSrc, cLen);
364 szTmpSrc[cLen] = '\0';
367 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
368 pPart = pMsg->msgBody.body.pMultipart;
369 #ifndef __SUPPORT_DRM__
370 MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart);
372 MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart, pMedia);
375 strcpy(pMedia->szSrc, szOutBuf);
376 MmsSmilGetMediaFilePath(pMedia, szTmpSrc, pMsg->msgID);
380 case ATTRIBUTE_COLOR:
381 if (cmd[ELEMENT_TEXT])
382 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
386 if (cmd[ELEMENT_TEXT])
387 pMedia->sMedia.sText.nSize = atoi((char *)pAttr->children->content);
391 if (cmd[ELEMENT_TEXT]) {
392 pMedia->sMedia.sText.bBold = MmsSmilGetFontAttrib((char *)pAttr->children->content);
396 case ATTRIBUTE_UNDERLINE:
397 if (cmd[ELEMENT_TEXT])
398 pMedia->sMedia.sText.bUnderLine = MmsSmilGetFontAttrib((char *)pAttr->children->content);
401 case ATTRIBUTE_ITALIC:
402 if (cmd[ELEMENT_TEXT])
403 pMedia->sMedia.sText.bItalic = MmsSmilGetFontAttrib((char *)pAttr->children->content);
406 case ATTRIBUTE_REVERSE:
407 if (cmd[ELEMENT_TEXT])
408 pMedia->sMedia.sText.bReverse = MmsSmilGetFontAttrib((char *)pAttr->children->content);
411 case ATTRIBUTE_DIRECTION:
412 if (cmd[ELEMENT_TEXT])
413 pMedia->sMedia.sText.nDirection = MmsSmilGetFontDirection((char *)pAttr->children->content);
415 case ATTRIBUTE_REGION:
416 strncpy(pMedia->regionId, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
419 case ATTRIBUTE_TRANSIN:
420 if (cmd[ELEMENT_TEXT])
421 strncpy(pMedia->sMedia.sText.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
423 strncpy(pMedia->sMedia.sAVI.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
426 case ATTRIBUTE_TRANSOUT:
427 if (cmd[ELEMENT_TEXT])
428 strncpy(pMedia->sMedia.sText.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
430 strncpy(pMedia->sMedia.sAVI.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
433 case ATTRIBUTE_BEGIN:
434 if (cmd[ELEMENT_TEXT])
435 pMedia->sMedia.sText.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
437 pMedia->sMedia.sAVI.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
441 if (cmd[ELEMENT_TEXT])
442 pMedia->sMedia.sText.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
444 pMedia->sMedia.sAVI.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
447 case ATTRIBUTE_REPEAT_COUNT:
448 if (cmd[ELEMENT_TEXT])
449 pMedia->sMedia.sText.nRepeat = atoi((char *)pAttr->children->content);
451 pMedia->sMedia.sAVI.nRepeat = atoi((char *)pAttr->children->content);
455 if (!strcmp((char *)pAttr->children->content, "foreground-color") || !strcmp((char *)pAttr->children->content, "foregroundcolor"))
456 paramType = ATTRIBUTE_FGCOLOR;
457 else if (!strcmp((char *)pAttr->children->content, "background-color") || !strcmp((char *)pAttr->children->content, "backgroundcolor"))
458 paramType = ATTRIBUTE_BGCOLOR;
459 else if (!strcmp((char *)pAttr->children->content, "textsize"))
460 paramType = ATTRIBUTE_SIZE;
461 else if (!strcmp((char *)pAttr->children->content, "textattribute"))
462 paramType = ATTRIBUTE_TEXTFORMAT;
464 if (cmd[ELEMENT_META])
465 strncpy(pMeta->szName, (char *)pAttr->children->content, MAX_SMIL_META_NAME - 1);
468 case ATTRIBUTE_VALUE:
469 if (paramType == ATTRIBUTE_SIZE && cmd[ELEMENT_TEXT])
470 pMedia->sMedia.sText.nSize = MmsSmilGetFontSizeValue((char *)pAttr->children->content);
471 else if (paramType == ATTRIBUTE_FGCOLOR && cmd[ELEMENT_TEXT])
472 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
473 else if (paramType == ATTRIBUTE_BGCOLOR && cmd[ELEMENT_TEXT])
474 pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
475 else if (paramType == ATTRIBUTE_TEXTFORMAT && cmd[ELEMENT_TEXT]) {
476 MmsSmilFontType fontType;
478 fontType = MmsSmilGetFontTypeValue((char *)pAttr->children->content);
480 if (fontType == MMS_SMIL_FONT_TYPE_BOLD)
481 pMedia->sMedia.sText.bBold = true;
483 pMedia->sMedia.sText.bBold = false;
485 if (fontType == MMS_SMIL_FONT_TYPE_ITALIC)
486 pMedia->sMedia.sText.bItalic = true;
488 pMedia->sMedia.sText.bItalic = false;
490 if (fontType == MMS_SMIL_FONT_TYPE_UNDERLINE)
491 pMedia->sMedia.sText.bUnderLine = true;
493 pMedia->sMedia.sText.bUnderLine = false;
498 strncpy(pMedia->szAlt, (char *)pAttr->children->content, MAX_SMIL_ALT_LEN - 1);
502 pTransition->nType = (MmsSmilTransType)atoi((char *)pAttr->children->content);
504 switch (pTransition->nType) {
505 case MMS_SMIL_TRANS_SLIDEWIPE:
506 pTransition->nSubType = MMS_SMIL_TRANS_SUB_FROM_LEFT;
508 case MMS_SMIL_TRANS_BARWIPE:
509 pTransition->nSubType = MMS_SMIL_TRANS_SUB_TOP_TO_BOTTOM;
511 case MMS_SMIL_TRANS_BARNDOORWIPE:
512 pTransition->nSubType = MMS_SMIL_TRANS_SUB_HORIZONTAL;
515 pTransition->nSubType = MMS_SMIL_TRANS_SUB_NONE;
521 case ATTRIBUTE_SUBTYPE:
522 pTransition->nSubType = (MmsSmilTransSubType)atoi((char *)pAttr->children->content);
525 case ATTRIBUTE_CONTENT:
526 strncpy(pMeta->szContent, (char *)pAttr->children->content, MAX_SMIL_META_CONTENT - 1);
528 #ifdef MMS_SMIL_ANIMATE
529 case ATTRIBUTE_ATTRIBUTE_NAME:
530 strcpy(pMedia->sMedia.sAVI.nAttributeName, (char *)pAttr->children->content);
533 case ATTRIBUTE_ATTRIBUTE_TYPE:
534 strcpy(pMedia->sMedia.sAVI.nAttributeType, (char *)pAttr->children->content);
537 case ATTRIBUTE_TARGET_ELEMENT:
538 strcpy(pMedia->sMedia.sAVI.nTargetElement, (char *)pAttr->children->content);
542 pMedia->sMedia.sAVI.nFrom = atoi((char *)pAttr->children->content);
546 pMedia->sMedia.sAVI.nTo = atoi((char *)pAttr->children->content);
550 pMedia->sMedia.sAVI.nBy = atoi((char *)pAttr->children->content);
553 case ATTRIBUTE_VALUES:
554 pMedia->sMedia.sAVI.nValues = atoi((char *)pAttr->children->content);
557 case ATTRIBUTE_CALCMODE:
558 strcpy(pMedia->sMedia.sAVI.nCalcMode, (char *)pAttr->children->content);
562 MSG_DEBUG("Undefined Attribute was found!!!!!");
566 if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_REGION]) {
567 // Insert a region to region list
568 _MsgMmsAddRegion(pMmsMsg, pRegion);
569 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_PAR]) {
570 //Insert a page to page list
571 _MsgMmsAddPage(pMmsMsg, pPage);
572 } else if (paramType == ATTRIBUTE_UNKNOWN && (cmd[ELEMENT_TEXT] ||cmd[ELEMENT_IMG] ||cmd[ELEMENT_AUDIO] ||cmd[ELEMENT_VIDEO] ||cmd[ELEMENT_ANIMATE])) {
573 //Insert a media to media list
574 _MsgMmsAddMedia(pPage, pMedia);
575 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_ROOTLAYOUT]) {
576 _MsgMmsSetRootLayout(pMmsMsg, &rootlayout);
577 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_TRANSITION]) {
578 //Insert a transition to transition list
579 _MsgMmsAddTransition(pMmsMsg, pTransition);
580 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_META]) {
581 //Insert a meta to meta list
582 _MsgMmsAddMeta(pMmsMsg, pMeta);
585 paramType = ATTRIBUTE_UNKNOWN;
588 MmsSmilGetElement(pMmsMsg, cur_node->children);
595 int MmsSmilGetColorValue(xmlChar *content)
599 if (content[0] == '#') // RGB value
600 color = MmsSmilAtoIHexa((char *)&content[1]);
601 else if (content[0] == '0' && (content[1] == 'x' || content[1] == 'X'))
602 color = MmsSmilAtoIHexa((char *)&content[2]);
604 MSG_DEBUG("Invalid Color Value");
611 int MmsSmilAtoIHexa(char *pInput)
618 char *pOutput = NULL;
620 MSG_DEBUG("__MmsSmilAtoIHexa() enter..\n");
622 len = strlen(pInput);
623 pOutput = (char *)malloc(len + 1);
625 if (pOutput == NULL) {
626 MSG_DEBUG("__MmsSmilAtoIHexa: Memory full \n");
630 memset(pOutput, 0, len + 1);
632 for (i = len - 1; i >= 0; i--) {
633 for (j = 0; j < (len - 1 - i); j++) {
709 res += (pOutput[i] * temp);
723 int MmsSmilGetTime(char *pValue)
731 if (pValue == NULL || pValue[0] == '\0')
734 len = strlen(pValue);
736 /* Default time unit -> millisecond */
737 if (strstr(pValue, "msec"))
740 if (strstr(pValue, "ms"))
743 pTemp = (char *)malloc(strlen(pValue) + 1);
746 MSG_DEBUG("__MmsSmilGetTime : malloc for <time> attribute is failed \n");
750 while (isdigit(pValue[i])) {
751 pTemp[i] = pValue[i];
756 /* Detect 's' and 'ms' here */
757 retVal = atoi(pTemp);
769 #ifndef __SUPPORT_DRM__
770 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart)
772 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart, MMS_MEDIA_S *pMedia)
775 char szContentID[MSG_MSG_ID_LEN + 1] = {0, };
776 char szContentLI[MSG_MSG_ID_LEN + 1] = {0, };
780 MSG_DEBUG("szInBuf: %s", szInBuf);
781 while (pPart && pPart->pBody) {
782 if (pPart->type.szContentID[0]) {
783 cLen = strlen(pPart->type.szContentID);
785 if (pPart->type.szContentID[0] == '<' && pPart->type.szContentID[cLen - 1] == '>') {
786 strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
787 szContentID[cLen - 2] = '\0';
788 } else if (pPart->type.szContentID[0] == MSG_CH_QUOT && pPart->type.szContentID[cLen-1] == MSG_CH_QUOT) {
789 strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
790 szContentID[cLen - 2] = '\0';
792 strncpy(szContentID, pPart->type.szContentID, cLen);
793 szContentID[cLen] = '\0';
796 szContentID[0] = '\0';
799 MSG_DEBUG("szContentID: %s", szContentID);
801 if (pPart->type.szContentLocation[0]) {
802 cLen = strlen(pPart->type.szContentLocation);
804 if (pPart->type.szContentLocation[0] == MSG_CH_QUOT &&
805 pPart->type.szContentLocation[cLen-1] == MSG_CH_QUOT) {
806 strncpy(szContentLI, &pPart->type.szContentLocation[1], cLen-2);
807 szContentLI[cLen-2] = '\0';
809 strncpy(szContentLI, pPart->type.szContentLocation, cLen);
810 szContentLI[cLen] = '\0';
813 szContentLI[0] = '\0';
816 MSG_DEBUG("szContentLocation: %s", szContentLI);
818 if (strcasecmp(szContentID, szInBuf) == 0) {
819 strcpy(szOutbuf, pPart->type.param.szFileName);
820 MSG_DEBUG("match with szContentID.");
823 char *szInFileName = strrchr(szInBuf, '/');
825 if (szInFileName == NULL) {
826 szInFileName = szInBuf;
830 if (strcasecmp(szContentLI, szInFileName) == 0) {
831 strcpy(szOutbuf, pPart->type.param.szFileName);
832 MSG_DEBUG("match with szContentLI.");
834 } else if (strcasecmp(pPart->type.param.szName, szInBuf) == 0) {
835 strcpy(szOutbuf, pPart->type.param.szFileName);
836 MSG_DEBUG("match with pPart->type.param.szName.");
838 } else if (strlen(szContentID) > 4) {
839 if (strcasecmp(strtok(szContentID, "."), strtok(szInBuf, ".")) == 0) {
840 strcpy(szOutbuf, pPart->type.param.szFileName);
841 MSG_DEBUG("only name is match with szContentID.");
844 } else if (strlen(szContentLI) > 4) {
845 if (strcasecmp(strtok(szContentLI, "."), strtok(szInBuf, ".")) == 0) {
846 strcpy(szOutbuf, pPart->type.param.szFileName);
847 MSG_DEBUG("only name is match with szContentLI.");
854 pPart = pPart->pNext;
860 #ifdef __SUPPORT_DRM__
861 pMedia->drmType = pPart->type.drmInfo.drmType;
863 if (pPart->type.drmInfo.szDrm2FullPath != NULL) {
864 MSG_DEBUG("szDrm2FullPath: %s", pPart->type.drmInfo.szDrm2FullPath);
865 strncpy(pMedia->szDrm2FullPath, pPart->type.drmInfo.szDrm2FullPath, MSG_FILEPATH_LEN_MAX - 1);
872 int MmsSmilGetElementID(char *pString)
874 if (!strcmp(pString, "smil"))
876 else if (!strcmp(pString, "head"))
878 else if (!strcmp(pString, "layout"))
879 return ELEMENT_LAYOUT;
880 else if (!strcmp(pString, "root-layout"))
881 return ELEMENT_ROOTLAYOUT;
882 else if (!strcmp(pString, "region"))
883 return ELEMENT_REGION;
884 else if (!strcmp(pString, "body"))
886 else if (!strcmp(pString, "par"))
888 else if (!strcmp(pString, "param"))
889 return ELEMENT_PARAM;
890 else if (!strcmp(pString, "text"))
892 else if (!strcmp(pString, "img"))
894 else if (!strcmp(pString, "audio"))
895 return ELEMENT_AUDIO;
896 else if (!strcmp(pString, "video"))
897 return ELEMENT_VIDEO;
898 else if (!strcmp(pString, "ref"))
900 else if (!strcmp(pString, "animate"))
901 return ELEMENT_ANIMATE;
902 else if (!strcmp(pString, "root-layout"))
904 else if (!strcmp(pString, "transition"))
905 return ELEMENT_TRANSITION;
906 else if (!strcmp(pString, "meta"))
912 int MmsSmilGetAttrID(char *pString)
914 if (!strcmp(pString, "id"))
916 else if (!strcmp(pString, "top"))
917 return ATTRIBUTE_TOP;
918 else if (!strcmp(pString, "left"))
919 return ATTRIBUTE_LEFT;
920 else if (!strcmp(pString, "width"))
921 return ATTRIBUTE_WIDTH;
922 else if (!strcmp(pString, "height"))
923 return ATTRIBUTE_HEIGHT;
924 else if (!strcmp(pString, "fit"))
925 return ATTRIBUTE_FIT;
926 else if (!strcmp(pString, "backgroundColor"))
927 return ATTRIBUTE_BGCOLOR;
928 else if (!strcmp(pString, "dur"))
929 return ATTRIBUTE_DUR;
930 else if (!strcmp(pString, "src"))
931 return ATTRIBUTE_SRC;
932 else if (!strcmp(pString, "color"))
933 return ATTRIBUTE_COLOR;
934 else if (!strcmp(pString, "bold"))
935 return ATTRIBUTE_BOLD;
936 else if (!strcmp(pString, "underline"))
937 return ATTRIBUTE_UNDERLINE;
938 else if (!strcmp(pString, "italic"))
939 return ATTRIBUTE_ITALIC;
940 else if (!strcmp(pString, "reverse"))
941 return ATTRIBUTE_REVERSE;
942 else if (!strcmp(pString, "direction"))
943 return ATTRIBUTE_DIRECTION;
944 else if (!strcmp(pString, "size"))
945 return ATTRIBUTE_SIZE;
946 else if (!strcmp(pString, "font"))
947 return ATTRIBUTE_FONT;
948 else if (!strcmp(pString, "region"))
949 return ATTRIBUTE_REGION;
950 else if (!strcmp(pString, "name"))
951 return ATTRIBUTE_NAME;
952 else if (!strcmp(pString, "value"))
953 return ATTRIBUTE_VALUE;
954 else if (!strcmp(pString, "alt"))
955 return ATTRIBUTE_ALT;
956 else if (!strcmp(pString, "type"))
957 return ATTRIBUTE_TYPE;
958 else if (!strcmp(pString, "subtype"))
959 return ATTRIBUTE_SUBTYPE;
960 else if (!strcmp(pString, "content"))
961 return ATTRIBUTE_CONTENT;
962 else if (!strcmp(pString, "transIn"))
963 return ATTRIBUTE_TRANSIN;
964 else if (!strcmp(pString, "transOut"))
965 return ATTRIBUTE_TRANSOUT;
966 else if (!strcmp(pString, "begin"))
967 return ATTRIBUTE_BEGIN;
968 else if (!strcmp(pString, "end"))
969 return ATTRIBUTE_END;
970 else if (!strcmp(pString, "repeatCount"))
971 return ATTRIBUTE_REPEAT_COUNT;
972 #ifdef MMS_SMIL_ANIMATE
973 else if (!strcmp(pString, "attributeName"))
974 return ATTRIBUTE_ATTRIBUTE_NAME;
975 else if (!strcmp(pString, "attributeType"))
976 return ATTRIBUTE_ATTRIBUTE_TYPE;
977 else if (!strcmp(pString, "targetElement"))
978 return ATTRIBUTE_TARGET_ELEMENT;
979 else if (!strcmp(pString, "from"))
980 return ATTRIBUTE_FROM;
981 else if (!strcmp(pString, "to"))
983 else if (!strcmp(pString, "by"))
985 else if (!strcmp(pString, "values"))
986 return ATTRIBUTE_VALUES;
987 else if (!strcmp(pString, "calcMode"))
988 return ATTRIBUTE_CALCMODE;
994 bool MmsSmilGetFontAttrib(char *pString)
996 if (!strcmp(pString, "true"))
1002 MmsTextDirection MmsSmilGetFontDirection(char *pString)
1004 MmsTextDirection direction = MMS_TEXT_DIRECTION_INVALID;
1006 if (!strcmp(pString, "right"))
1007 direction = MMS_TEXT_DIRECTION_RIGHT;
1008 else if (!strcmp(pString, "down"))
1009 direction = MMS_TEXT_DIRECTION_DOWN;
1014 int MmsSmilGetFontSizeValue(char *pString)
1016 MSG_DEBUG(" #### content = %s #### ", pString);
1017 if (!strcmp(pString, "small"))
1018 return MMS_SMIL_FONT_SIZE_SMALL;
1019 else if (!strcmp(pString, "normal"))
1020 return MMS_SMIL_FONT_SIZE_NORMAL;
1021 else if (!strcmp(pString, "large"))
1022 return MMS_SMIL_FONT_SIZE_LARGE;
1024 return atoi(pString);
1027 MmsSmilFontType MmsSmilGetFontTypeValue(char *pString)
1029 MSG_DEBUG(" #### content = %s #### ", pString);
1031 if (!strcmp(pString, "normal"))
1032 return MMS_SMIL_FONT_TYPE_NORMAL;
1033 else if (!strcmp(pString, "italic"))
1034 return MMS_SMIL_FONT_TYPE_ITALIC;
1035 else if (!strcmp(pString, "bold"))
1036 return MMS_SMIL_FONT_TYPE_BOLD;
1037 else if (!strcmp(pString, "underline"))
1038 return MMS_SMIL_FONT_TYPE_UNDERLINE;
1040 return MMS_SMIL_FONT_TYPE_NORMAL;
1043 bool MmsSmilGetMediaFilePath(MMS_MEDIA_S *pMedia, char *pszTemp, int msgID)
1046 MSG_DEBUG("pMedia is NULL");
1050 snprintf(pMedia->szFilePath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_DATA_PATH, pMedia->szSrc);
1051 MSG_DEBUG("pMedia's filePath: %s", pMedia->szFilePath);
1053 __MmsGetRealFileName(pMedia->mediatype, pMedia->szSrc, pMedia->szFileName, msgID);
1054 MSG_DEBUG("pMedia's fileName: %s", pMedia->szFileName);
1056 snprintf(pMedia->szContentID, MSG_MSG_ID_LEN+1, "%s", pszTemp);
1057 MSG_DEBUG("pMedia's ContentID: %s", pMedia->szContentID);
1063 /** @fn bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
1064 * @brief Forms Smil Buffer using pstMsgBody. \n
1065 * @param[in/out] pstMsgBody is Message handle. \n
1066 * @retval TRUE In case of Success. \n
1067 * @retval FALSE In case of failure. \n
1069 bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
1071 HMmsSmil hSmilDoc = INVALID_HOBJ;
1077 MMS_PAGE_S *pstPage;
1078 MMS_MEDIA_S *pstMedia;
1079 MMS_SMIL_REGION *pstRegion;
1084 hSmilDoc = MmsSmilCreateEmptySmilDoc();
1085 MSG_DEBUG("Smil Doc =%d",hSmilDoc);
1086 if (INVALID_HOBJ == hSmilDoc) {
1087 MSG_DEBUG("Invalid SmilDoc[%d]",hSmilDoc);
1090 // Add Root Layout to Smil Document
1091 if (false == MmsSmilAddRootLayout(hSmilDoc, &(pstMsgBody->rootlayout))) {
1092 MSG_DEBUG("MmsSmilAddRootLayout Failed");
1093 MmsSmilDestroyDoc(hSmilDoc);
1095 //Add Region list to Smil Document
1096 nRegionCount = pstMsgBody->regionCnt;
1097 MSG_DEBUG(" Region Count =%d",nRegionCount);
1098 for (nIndex = 0; nIndex < nRegionCount; nIndex++) {
1099 MSG_DEBUG("Calling _MsgMmsGetSmilRegion");
1100 pstRegion = _MsgMmsGetSmilRegion(pstMsgBody, nIndex);
1101 if (NULL == pstRegion) {
1102 MSG_DEBUG("pstRegion is NULL");
1103 MmsSmilDestroyDoc(hSmilDoc);
1106 MSG_DEBUG("Calling MmsSmilAddRegion");
1107 if (false == MmsSmilAddRegion(hSmilDoc, pstRegion)) {
1108 MSG_DEBUG("Adding Region to smil doc failed");
1109 MmsSmilDestroyDoc(hSmilDoc);
1113 // Add page list to Smil Document
1114 nTotalPageNum = pstMsgBody->pageCnt ;
1115 MSG_DEBUG(" Page Count =%d",nTotalPageNum);
1116 for (nIndex = 0; nIndex < nTotalPageNum; nIndex++) {
1117 MSG_DEBUG("Calling _MsgMmsGetPage");
1118 pstPage = _MsgMmsGetPage(pstMsgBody, nIndex);
1119 if (NULL == pstPage) {
1120 MSG_DEBUG("pstPage is NULL");
1121 MmsSmilDestroyDoc(hSmilDoc);
1124 // Add page to smil doc
1125 MSG_DEBUG("Calling MmsSmilAddPage");
1126 if (false == MmsSmilAddPage(hSmilDoc, pstPage)) {
1127 MSG_DEBUG("Adding page to smil doc failed");
1128 MmsSmilDestroyDoc(hSmilDoc);
1131 nTotalMediaNum = pstPage->mediaCnt;
1132 MSG_DEBUG(" Media Count =%d",nTotalMediaNum);
1133 for (nMediaIndex = 0; nMediaIndex < nTotalMediaNum; nMediaIndex++) {
1134 MSG_DEBUG("Calling _MsgMmsGetMedia");
1135 pstMedia = _MsgMmsGetMedia(pstPage, nMediaIndex);
1136 if (NULL == pstMedia) {
1137 MSG_DEBUG("pMedia is NULL");
1138 MmsSmilDestroyDoc(hSmilDoc);
1141 MSG_DEBUG("Calling MmsSmilAddMedia");
1142 if (false == MmsSmilAddMedia(hSmilDoc, nIndex, nMediaIndex, pstMedia, pstMedia->szContentID)) {
1143 MSG_DEBUG("MmsSmilAddMedia failed");
1144 MmsSmilDestroyDoc(hSmilDoc);
1149 MSG_DEBUG("MMSGenerateSmilBuffer: Start update template");
1150 pszRawData = MmsSmilGetRawData(hSmilDoc);
1151 if (NULL == pszRawData) {
1152 MSG_DEBUG("MMSGenerateSmilBuffer: MmsSmilGetRawData failed");
1153 MmsSmilDestroyDoc(hSmilDoc);
1157 char fullpath[MSG_FILEPATH_LEN_MAX] = {0,};
1158 snprintf(fullpath, MSG_FILEPATH_LEN_MAX, MSG_SMIL_FILE_PATH"%s", pstMsgBody->szSmilFilePath);
1160 if (MsgWriteSmilFile(fullpath, pszRawData, strlen(pszRawData) + 1) == false) {
1161 MSG_DEBUG("MMSGenerateSmilBuffer: MsgWriteSmilFile failed");
1162 xmlFree((xmlChar*)pszRawData);
1163 MmsSmilDestroyDoc(hSmilDoc);
1167 MSG_DEBUG("MMSGenerateSmilBuffer: complete update template\n");
1168 xmlFree((xmlChar*)pszRawData);
1169 MmsSmilDestroyDoc(hSmilDoc);
1174 /** @fn static HMmsSmil MmsSmilCreateEmptySmilDoc(void)
1175 * @brief Creates default Smil Doc based on input gszEmptyRawDoc. \n
1176 * @retval Returns Smil Document number. \n
1178 HMmsSmil MmsSmilCreateEmptySmilDoc(void)
1184 hMmsSmil = MmsSmilCreateSmilDoc(gszEmptyRawDoc);
1186 MSG_DEBUG("Create an empty smilDoc.(Handle = %d)", hMmsSmil);
1193 /** @fn static HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
1194 * @brief Creates Smil Doc based on input pszRawData. \n
1195 * @param[in] pszRawData is smil buffer. \n
1196 * @retval Returns Smil Document number. \n
1198 HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
1201 xmlNodePtr stRootNode;
1205 // Destroy smil doc if present
1206 if (NULL != __gpaMmsSmilDoc[nSmilDocNo]) {
1207 MSG_DEBUG("Calling MmsSmilDestroyDoc");
1208 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1209 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1213 for (nSmilDocNo = 0; nSmilDocNo < MMS_SMIL_MAX_DOC; nSmilDocNo++) {
1214 if (NULL == __gpaMmsSmilDoc[nSmilDocNo])
1218 if (MMS_SMIL_MAX_DOC == nSmilDocNo) {
1219 MSG_DEBUG("SmilDoc table is full. Can't create.");
1220 return INVALID_HOBJ;
1222 __gpaMmsSmilDoc[nSmilDocNo] = (MmsSmilDoc*)malloc(sizeof(MmsSmilDoc));
1223 if (NULL == __gpaMmsSmilDoc[nSmilDocNo]) {
1224 MSG_DEBUG("Memory Allocation Failed.");
1225 return INVALID_HOBJ;
1227 memset(__gpaMmsSmilDoc[nSmilDocNo], 0, sizeof(MmsSmilDoc));
1229 __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc = xmlParseMemory(pszRawData, strlen(pszRawData));
1230 if (NULL == __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1231 MSG_DEBUG("Document not parsed successfully.");
1232 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1233 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1235 return INVALID_HOBJ;
1237 stRootNode = xmlDocGetRootElement(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
1238 if (NULL == stRootNode) {
1239 MSG_DEBUG("Empty document\n");
1240 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1241 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1243 return INVALID_HOBJ;
1245 if (xmlStrcmp(stRootNode->name, (const xmlChar *) "smil")) {
1246 MSG_DEBUG("Document of the wrong type, root node != smil");
1247 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1248 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1250 return INVALID_HOBJ;
1253 __gpaMmsSmilDoc[nSmilDocNo]->pstRootNode = stRootNode;
1256 return ((HMmsSmil)nSmilDocNo);
1259 /** @fn static bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
1260 * @brief Destroys Smil Doc. \n
1261 * @param[in] hSmilDoc is smil doc number. \n
1262 * @retval TRUE In case of Success. \n
1263 * @retval FALSE In case of failure. \n
1265 bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
1267 int nSmilDocNo = (int)hSmilDoc;
1271 if (0 <= nSmilDocNo &&
1272 nSmilDocNo < MMS_SMIL_MAX_DOC &&
1273 __gpaMmsSmilDoc[nSmilDocNo]) {
1274 if (__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1275 xmlFreeDoc(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
1278 if (__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode) {
1281 free(__gpaMmsSmilDoc[nSmilDocNo]);
1282 __gpaMmsSmilDoc[nSmilDocNo] = NULL;
1284 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1292 /** @fn static bool IsValidSmilDocNo(int nSmilDocNo)
1293 * @brief Form Smil Doc. \n
1294 * @param[in] hSmilDoc is smil doc number. \n
1295 * @retval Returns Smil Buffer In case of success. \n
1296 * @retval Returns NULL In case of failure. \n
1298 bool IsValidSmilDocNo(int nSmilDocNo)
1300 bool bIsValidSmil = false;
1304 if (0 <= nSmilDocNo &&
1305 nSmilDocNo < MMS_SMIL_MAX_DOC &&
1306 __gpaMmsSmilDoc[nSmilDocNo] &&
1307 __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1308 bIsValidSmil = true;
1312 return bIsValidSmil;
1315 /** @fn static char MmsSmilGetRawData(HMmsSmil hSmilDoc)
1316 * @brief Form Smil Doc. \n
1317 * @param[in] hSmilDoc is smil doc number. \n
1318 * @retval Returns Smil Buffer In case of success. \n
1319 * @retval Returns NULL In case of failure. \n
1321 char *MmsSmilGetRawData(HMmsSmil hSmilDoc)
1323 int nSmilDocNo = (int)hSmilDoc;
1324 char *pszRawData = NULL;
1328 if (IsValidSmilDocNo(nSmilDocNo)) {
1329 xmlSaveFormatFileEnc("-", __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, "UTF-8", 1);
1330 xmlDocDumpMemory(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, (xmlChar **)(&pszRawData) , NULL);
1331 if (NULL == pszRawData) {
1332 MSG_DEBUG("Invalid pSmilDoc (now wellformed document)");
1336 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1341 /** @fn static bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
1342 * @brief Add Page to Smil Doc. \n
1343 * @param[in] hSmilDoc is smil doc number. \n
1344 * @param[in] pstSmilPage specifies page information. \n
1345 * @retval TRUE In case of Success. \n
1346 * @retval FALSE In case of failure. \n
1348 bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
1350 int nSmilDocNo = hSmilDoc;
1356 if (IsValidSmilDocNo(nSmilDocNo)) {
1357 xmlNodePtr pstParElement;
1358 xmlNodePtr pstBodyElement;
1359 xmlNodePtr pstParList;
1360 char szBuf[MSG_STDSTR_SHORT] = {0, };
1362 pstBodyElement = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"body");
1364 if (NULL == pstBodyElement) {
1365 MSG_DEBUG("There is no <body> node. Can't create <par> node.");
1368 MSG_DEBUG("Body Element Name = %s", (char *)pstBodyElement->name);
1369 /* Create "par" node and insert it */
1370 pstParElement = xmlNewNode(NULL, (xmlChar *)"par");
1372 if (NULL == pstParElement) {
1373 MSG_DEBUG("Can't create <par> node. (from XmlParser) \n");
1376 MSG_DEBUG("Par Element Name = %s", (char *)pstParElement->name);
1378 /* Add attributes to "par" */
1379 if (pstSmilPage->nDur > 0) {
1380 snprintf(szBuf, MSG_STDSTR_SHORT, "%dms", pstSmilPage->nDur);
1381 xmlSetProp(pstParElement, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1383 /* Find the insertion point : right sibling of the last <par> node or first child of <body> */
1385 pstParList = xmlGetLastChild(pstBodyElement);
1388 ret = __MmsSmilInsertNode(pstBodyElement, pstParList, pstParElement);
1390 ret = __MmsInsertFirstChild(pstBodyElement, pstParElement);
1393 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1400 /** @fn static bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
1401 * @brief Add Rootlayout to Smil Doc. \n
1402 * @param[in] hSmilDoc is smil doc number. \n
1403 * @param[in] pstSmilRootLayout specifies RootLayout information. \n
1404 * @retval TRUE In case of Success. \n
1405 * @retval FALSE In case of failure. \n
1407 bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
1409 int nSmilDocNo = hSmilDoc;
1410 xmlNodePtr pstRootLayout = NULL;
1411 xmlNodePtr pstLayoutList = NULL;
1412 xmlNodePtr pstRootLayoutList = NULL;
1413 char szBuf[MSG_STDSTR_SHORT] = {0, };
1417 if (IsValidSmilDocNo(nSmilDocNo)) {
1418 pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
1420 if (NULL == pstLayoutList) {
1421 MSG_DEBUG("There is no <layout> node. Can't create <root-layout> node.");
1424 MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
1426 pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
1428 if (NULL != pstRootLayoutList) {
1429 MSG_DEBUG("MmsSmilAddRootLayout: There is <root-layout> node already");
1430 MSG_DEBUG("Root Layout Element Name = %s type=%d\n", (char *)pstRootLayoutList->name);
1433 /* Create "root-layout" node and insert it */
1434 pstRootLayout = xmlNewNode(NULL, (xmlChar *)"root-layout");
1435 if (NULL == pstRootLayout) {
1436 MSG_DEBUG("Can't create <root-layout> node. (from XmlParser)");
1439 MSG_DEBUG("Root Layout Element Name = %s", (char *)pstRootLayout->name);
1441 if (pstSmilRootLayout->bgColor != SP_NO_COLOR_SET) { // Replace value later
1442 xmlSetProp(pstRootLayout, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRootLayout->bgColor));
1444 MSG_DEBUG(" Set Width");
1445 if (true == pstSmilRootLayout->width.bUnitPercent) {
1446 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->width.value);
1447 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
1449 if (pstSmilRootLayout->width.value > 0) {
1450 snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->width.value);
1451 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
1453 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)"100%");
1456 MSG_DEBUG(" Set Height");
1457 if (true == pstSmilRootLayout->height.bUnitPercent) {
1458 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->height.value);
1459 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
1461 if (pstSmilRootLayout->height.value > 0) {
1462 snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->height.value);
1463 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
1465 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)"100%");
1468 __MmsInsertFirstChild(pstLayoutList, pstRootLayout);
1472 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1479 /** @fn static bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
1480 * @brief Add Region to Smil Doc. \n
1481 * @param[in] hSmilDoc is smil doc number. \n
1482 * @param[in] pstSmilRegion specifies Region information. \n
1483 * @retval TRUE In case of Success. \n
1484 * @retval FALSE In case of failure. \n
1486 bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
1488 int nSmilDocNo = hSmilDoc;
1492 if (IsValidSmilDocNo(nSmilDocNo)) {
1494 int nRootHeight = 0;
1495 xmlNodePtr pstRegion;
1496 xmlNodePtr pstLayoutList;
1497 xmlNodePtr pstRootLayoutList;
1498 xmlAttrPtr pAttribute;
1499 char szBuf[MSG_STDSTR_SHORT] = {0, };
1501 pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
1502 if (NULL == pstLayoutList) {
1503 MSG_DEBUG(" There is no <layout> node. Can't create <region> node");
1506 MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
1508 /* Find the insertion point : right sibling of the last root-layout node or first child of pLayout */
1509 pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
1511 if (NULL == pstRootLayoutList) {
1512 MSG_DEBUG("There is no <root-layout> node. Can't create <root-layout> node.");
1515 MSG_DEBUG("Root Layout Element Name = %s ", (char *)pstRootLayoutList->name);
1516 pAttribute = pstRootLayoutList->properties;
1519 if (NULL == pAttribute) {
1520 MSG_DEBUG("There is no Attribute in <root-layout> node.");
1524 xmlAttrPtr pstAttr = pAttribute;
1525 for ( ; pstAttr; pstAttr = pstAttr->next) {
1527 MSG_DEBUG("AttributeType: (%s, %s) ", pstAttr->name, pstAttr->children->content);
1528 switch (attrType = MmsSmilGetAttrID((char *)pstAttr->name)) {
1529 case ATTRIBUTE_WIDTH:
1533 if (strchr((char *)pstAttr->children->content, '%'))
1534 bUnitPercent = true;
1536 bUnitPercent = false;
1538 nRootWidth = atoi((char *)pstAttr->children->content);
1542 case ATTRIBUTE_HEIGHT:
1546 if (strchr((char *)pstAttr->children->content, '%'))
1547 bUnitPercent = true;
1549 bUnitPercent = false;
1551 nRootHeight = atoi((char *)pstAttr->children->content);
1557 /* Create "region" node and insert it */
1558 MSG_DEBUG("Create Region Node");
1559 pstRegion = xmlNewNode(NULL, (xmlChar *)"region");
1560 if (NULL == pstRegion) {
1561 MSG_DEBUG("Can't create <region> node. (from XmlParser)");
1564 /* Add attributes */
1565 if (pstSmilRegion) {
1566 MSG_DEBUG(" [Set Attribute] : Region Id");
1567 if (strlen(pstSmilRegion->szID) > 0) {
1568 xmlSetProp(pstRegion, (const xmlChar *)"id", (const xmlChar *)pstSmilRegion->szID);
1570 MSG_DEBUG(" [Set Attribute] : BkGrd Color");
1571 // Default Color WHITE, always send
1572 if (pstSmilRegion->bgColor != SP_NO_COLOR_SET) {
1573 xmlSetProp(pstRegion, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRegion->bgColor));
1575 MSG_DEBUG(" [Set Attribute] : Width");
1577 if (true == pstSmilRegion->width.bUnitPercent) {
1578 if (pstSmilRegion->width.value > 0) {
1579 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->width.value);
1580 xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
1581 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width = %d \n", pstSmilRegion->width.value);
1584 // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
1585 // Validation should be done before this.
1586 if (pstSmilRegion->width.value >= 0 &&
1587 pstSmilRegion->width.value <= nRootWidth) {
1588 int iWidth = (pstSmilRegion->width.value * 100) / nRootWidth;
1590 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iWidth);
1591 xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
1592 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width= %d iWidth = %d \n", pstSmilRegion->width.value, iWidth);
1595 MSG_DEBUG(" [Set Attribute] : Height");
1596 if (true == pstSmilRegion->height.bUnitPercent) {
1597 if (pstSmilRegion->height.value > 0) {
1598 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->height.value);
1599 xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
1600 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d \n", pstSmilRegion->height.value);
1603 // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
1604 // Validation should be done before this.
1605 if (pstSmilRegion->height.value >= 0 &&
1606 pstSmilRegion->height.value <= nRootHeight) {
1607 int iHeight = (pstSmilRegion->height.value * 100) / nRootHeight;
1609 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iHeight);
1610 xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
1611 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d iHeight = %d \n", pstSmilRegion->height.value, iHeight);
1614 MSG_DEBUG(" [Set Attribute] : Left");
1615 if (true == pstSmilRegion->nLeft.bUnitPercent) {
1616 if (pstSmilRegion->nLeft.value > 0) {
1617 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nLeft.value);
1618 xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
1619 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->left = %d \n", pstSmilRegion->nLeft.value);
1622 // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
1623 // Validation should be done before this.
1624 if (pstSmilRegion->nLeft.value >= 0) {
1625 int iLeft = (pstSmilRegion->nLeft.value * 100) / nRootWidth;
1627 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iLeft);
1628 xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
1629 MSG_DEBUG("MmsSmilAddRegion: SmilRegion->iLeft = %d iLeft = %d \n", pstSmilRegion->nLeft.value, iLeft);
1632 MSG_DEBUG(" [Set Attribute] : Top");
1633 if (true == pstSmilRegion->nTop.bUnitPercent) {
1634 if (pstSmilRegion->nTop.value > 0) {
1635 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nTop.value);
1636 xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
1637 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d \n", pstSmilRegion->nTop.value);
1640 // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
1641 // Validation should be done before this.
1642 if (pstSmilRegion->nTop.value >= 0) {
1643 int iTop = (pstSmilRegion->nTop.value * 100) / nRootHeight;
1645 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iTop);
1646 xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
1647 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d iTop = %d \n", pstSmilRegion->nTop.value, iTop);
1650 MSG_DEBUG(" [Set Attribute] : Fit");
1652 if (MMSUI_IMAGE_REGION_FIT_MEET == pstSmilRegion->fit) {
1653 xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"meet");
1654 } else if (MMSUI_IMAGE_REGION_FIT_HIDDEN == pstSmilRegion->fit) {
1655 xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"hidden");
1658 __MmsSmilInsertNode(pstLayoutList, pstRootLayoutList, pstRegion);
1661 MSG_DEBUG("There is no attribute in <region> node\n");
1666 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
1671 /** @fn static bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1672 * @brief Add Media to Smil Doc. \n
1673 * @param[in] hSmilDoc is smil doc number. \n
1674 * @param[in] nPageNo specifies page number to which media belongs. \n
1675 * @param[in] pstSmilMedia specifies Media information. \n
1676 * @param[in] pszContentID specifies Content ID of media. \n
1677 * @retval TRUE In case of Success. \n
1678 * @retval FALSE In case of failure. \n
1680 bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1682 int nSmilDocNo = hSmilDoc;
1686 if (NULL == pszContentID) {
1687 MSG_DEBUG(" Content Id is NULL");
1690 memset(pszContentID, 0, MMS_CONTENT_ID_LEN + 1);
1691 if (IsValidSmilDocNo(nSmilDocNo)) {
1694 xmlNode *pstLastChild;
1695 xmlNodePtr pstParList;
1698 pstParList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"par");
1699 if (NULL == pstParList) {
1700 MSG_DEBUG("There is no <par> node. Can't create <media> node.");
1703 MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
1704 for (nIndex = 0; (pstParList && nIndex < nPageNo); nIndex++) {
1705 pstParList = pstParList->next;
1707 if (NULL == pstParList) {
1708 MSG_DEBUG("There is no such page node. Can't insert <media> node.");
1711 MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
1712 /* Find insertion point and make a contentID */
1714 pstLastChild = xmlGetLastChild(pstParList);
1716 pszExt = strrchr(pstSmilMedia->szFileName, '.');
1717 if (pszExt && !strrchr(pszExt, '/'))
1718 snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu%s", (ULONG)nPageNo, (ULONG)nMediaIdx, pszExt);
1720 snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu", (ULONG)nPageNo, (ULONG)nMediaIdx);
1722 /* Create <media> node and insert set attribute */
1723 MSG_DEBUG(" Create Media Node");
1724 switch (pstSmilMedia->mediatype) {
1725 case MMS_SMIL_MEDIA_TEXT:
1726 pstMedia = __MmsCreateTextNode(pstSmilMedia, pszContentID);
1728 case MMS_SMIL_MEDIA_AUDIO:
1729 case MMS_SMIL_MEDIA_VIDEO:
1730 case MMS_SMIL_MEDIA_IMG:
1731 pstMedia = __MmsCreateMMNode(pstSmilMedia, pszContentID);
1734 MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
1738 if (NULL == pstMedia) {
1739 MSG_DEBUG("Can't create <media> node. (from XmlParser) (media-type:%d)", pstSmilMedia->mediatype);
1743 /* Find the insertion point : the last child of <par> node */
1745 __MmsSmilInsertNode(pstParList, pstLastChild, pstMedia);
1747 __MmsInsertFirstChild(pstParList, pstMedia);
1752 MSG_DEBUG("MmsSmilAddMedia: Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
1757 /** @fn static xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1758 * @brief Create Text Element. \n
1759 * @param[in] pstSmilMedia specifies Media information. \n
1760 * @param[in] pszContentID specifies Content ID of media. \n
1761 * @retval Text Element node In case of Success. \n
1762 * @retval NULL In case of failure. \n
1764 xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1766 xmlNode *pstMedia = NULL;
1767 xmlNode *pstParam = NULL;
1768 char szBuf[MSG_STDSTR_SHORT] = {0, };
1769 char szSizeBuf[MSG_STDSTR_SHORT] = {0, };
1773 pstMedia = xmlNewNode(NULL, (xmlChar *)"text");
1774 if (NULL == pstMedia) {
1775 MSG_DEBUG("Can't create <Text> node.");
1778 MSG_DEBUG("Text Element Name = %s ", (char *)pstMedia->name);
1780 /* Add attributes */
1782 MSG_DEBUG("[Set Attribute] Region Id ");
1783 if (strlen(pstSmilMedia->regionId) > 0) {
1784 xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
1786 MSG_DEBUG("[Set Attribute] Begin ");
1787 if (pstSmilMedia->sMedia.sText.nBegin > 0) {
1788 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nBegin);
1789 xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *) szBuf);
1791 MSG_DEBUG("[Set Attribute] Duration");
1792 if (pstSmilMedia->sMedia.sText.nDurTime > 0) {
1793 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nDurTime);
1794 xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1796 MSG_DEBUG("[Set Attribute] Alternate");
1797 if (strlen(pstSmilMedia->szAlt) > 0) {
1798 snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
1799 xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
1801 MSG_DEBUG("[Set Attribute] Src");
1803 char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5]; // for "cid:"
1805 snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
1806 _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
1808 MSG_DEBUG("[Set Attribute] Font Foreground Color");
1810 if (pstSmilMedia->sMedia.sText.nColor!= SP_BLACK) { // Chnage after getting exact values
1811 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1813 if (NULL == pstParam) {
1814 MSG_DEBUG("Cannot create <param> node");
1817 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"foreground-color");
1818 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nColor));
1819 __MmsInsertFirstChild(pstMedia, pstParam);
1822 MSG_DEBUG("[Set Attribute] Font Background Color");
1824 if (pstSmilMedia->sMedia.sText.nBgColor != SP_BLACK) { // Chnage after getting exact values
1825 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1827 if (NULL == pstParam) {
1828 MSG_DEBUG("Cannot create <param> node");
1831 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"background-color");
1832 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nBgColor));
1833 __MmsInsertFirstChild(pstMedia, pstParam);
1836 MSG_DEBUG("[Set Attribute] Size");
1837 if (pstSmilMedia->sMedia.sText.nSize > 0) {
1838 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1839 if (NULL == pstParam) {
1840 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1844 if (pstSmilMedia->sMedia.sText.nSize <= MMS_SMIL_FONT_SIZE_SMALL)
1845 strcpy(szSizeBuf, "small");
1846 else if ((pstSmilMedia->sMedia.sText.nSize > MMS_SMIL_FONT_SIZE_SMALL) && (pstSmilMedia->sMedia.sText.nSize < MMS_SMIL_FONT_SIZE_LARGE))
1847 strcpy(szSizeBuf, "normal");
1849 strcpy(szSizeBuf, "large");
1851 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textsize");
1852 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1853 __MmsInsertFirstChild(pstMedia, pstParam);
1856 if (pstSmilMedia->sMedia.sText.bBold == true) {
1857 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1858 if (NULL == pstParam) {
1859 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1863 strcpy(szSizeBuf, "bold");
1865 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1866 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1867 __MmsInsertFirstChild(pstMedia, pstParam);
1870 if (pstSmilMedia->sMedia.sText.bItalic == true) {
1871 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1872 if (NULL == pstParam) {
1873 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1877 strcpy(szSizeBuf, "italic");
1879 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1880 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1881 __MmsInsertFirstChild(pstMedia, pstParam);
1884 if (pstSmilMedia->sMedia.sText.bUnderLine == true) {
1885 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1886 if (NULL == pstParam) {
1887 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1891 strcpy(szSizeBuf, "underline");
1893 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1894 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1895 __MmsInsertFirstChild(pstMedia, pstParam);
1903 /** @fn static xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1904 * @brief Create Image/Audio/Video Element. \n
1905 * @param[in] pstSmilMedia specifies Media information. \n
1906 * @param[in] pszContentID specifies Content ID of media. \n
1907 * @retval Image/Audio/Video Element node In case of Success. \n
1908 * @retval NULL In case of failure. \n
1910 xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1912 xmlNode *pstMedia = NULL;
1913 char szBuf[MSG_STDSTR_SHORT] = {0, };
1920 switch (pstSmilMedia->mediatype) {
1921 case MMS_SMIL_MEDIA_AUDIO:
1922 pstMedia = xmlNewNode(NULL, (xmlChar *)"audio");
1925 case MMS_SMIL_MEDIA_VIDEO:
1926 pstMedia = xmlNewNode(NULL, (xmlChar *)"video");
1929 case MMS_SMIL_MEDIA_IMG:
1930 pstMedia = xmlNewNode(NULL, (xmlChar *)"img");
1933 MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
1938 char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5]; // for "cid:"
1940 MSG_DEBUG("[Set Attribute] Region Id ");
1941 if (strlen(pstSmilMedia->regionId) > 0) {
1942 xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
1944 MSG_DEBUG("[Set Attribute] Src ");
1945 snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
1946 _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
1948 MSG_DEBUG("[Set Attribute] Begin ");
1949 if (pstSmilMedia->sMedia.sAVI.nBegin > 0) {
1950 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nBegin);
1951 xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *)szBuf);
1953 MSG_DEBUG("[Set Attribute] Duration ");
1954 if (pstSmilMedia->sMedia.sAVI.nDurTime > 0) {
1955 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nDurTime);
1956 xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1958 MSG_DEBUG("[Set Attribute] Alt ");
1959 if (strlen(pstSmilMedia->szAlt) > 0) {
1960 snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
1961 xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
1964 MSG_DEBUG("There is no attribute in such-<media> node");
1971 /** @fn static bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
1972 * @brief Inserts first child to parent node. \n
1973 * @param[in] pstParent specifies Parent node. \n
1974 * @param[in] pstCurr specifies Child node. \n
1975 * @retval TRUE In case of Success. \n
1976 * @retval FALSE In case of failure. \n
1978 bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
1984 if (NULL == xmlAddChild(pstParent, pstCurr)) {
1985 MSG_DEBUG("%s Node not added", pstCurr->name);
1994 /** @fn static bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
1995 * @brief Inserts node. \n
1996 * @param[in] pstParent specifies Parent node. \n
1997 * @param[in] pstLeftSibling specifies Left Sibling node. \n
1998 * @param[in] pstCurr specifies Child node. \n
1999 * @retval TRUE In case of Success. \n
2000 * @retval FALSE In case of failure. \n
2002 bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
2007 if (pstLeftSibling) {
2008 /* Parent Node is Unused */
2010 while (pstLeftSibling->next !=NULL)
2011 pstLeftSibling = pstLeftSibling->next;
2013 if (NULL == xmlAddNextSibling(pstLeftSibling, pstCurr)) {
2014 MSG_DEBUG("%s Node not added", pstCurr->name);
2018 if (NULL == xmlAddChild(pstParent, pstCurr)) {
2019 MSG_DEBUG("%s Node not added", pstCurr->name);
2028 bool __MmsGetRealFileName(MmsSmilMediaType mediaType, char *pszSrc, char *pszName, int msgID)
2034 MSG_DEBUG("__MmsUiGetRealFileName: mediaType[%d]", mediaType);
2035 MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
2038 MSG_DEBUG("__MmsUiGetRealFileName: pszName is null\n");
2042 if (mediaType == MMS_SMIL_MEDIA_TEXT || mediaType == MMS_SMIL_MEDIA_INVALID) {
2043 MSG_DEBUG("__MmsUiGetRealFileName: invalid mediaType(=%d)\n", mediaType);
2047 partCnt = MmsGetMediaPartCount(msgID);
2050 MSG_DEBUG("__MmsUiGetRealFileName: partCnt < 0, (=%d)\n", partCnt);
2054 for (i = 0; i < partCnt; i++) {
2055 MmsGetMediaPartHeader(i, &partHeader);
2057 if (mediaType == MMS_SMIL_MEDIA_AUDIO ||
2058 mediaType == MMS_SMIL_MEDIA_VIDEO ||
2059 mediaType == MMS_SMIL_MEDIA_IMG) {
2060 if (!strcmp(partHeader.param.szFileName , pszSrc)) {
2062 MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
2071 if (partHeader.param.szName[0] != '\0') {
2072 int nameLen = strlen(partHeader.param.szName);
2074 if (nameLen > MSG_FILENAME_LEN_MAX - 1) {
2077 strcpy(pszName, partHeader.param.szName);
2085 /** @fn static void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
2086 * @brief Sets Attribute. \n
2087 * @param[in] pNode specifies node. \n
2088 * @param[in] szField specifies attribute field. \n
2089 * @param[in] szValue specifies value of field \n
2091 void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
2095 if (pNode && szField && strlen(szField)) {
2096 if (szValue && strlen(szValue)) {
2097 xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)szValue);
2099 xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)"");
2106 /** @fn static char *__MmsSmilFindColorValue(int nValue)
2107 * @brief Converts color to RGB. \n
2108 * @param[in] nValue specifies color value. \n
2109 * @retval RGB value. \n
2111 char *__MmsSmilFindColorValue(int nValue)
2113 unsigned char red = (nValue & 0xFF0000) >> 16;
2114 unsigned char green = (nValue & 0x00FF00) >> 8;
2115 unsigned char blue = nValue & 0x0000FF;
2119 snprintf(gszColor,MMS_SMIL_COLOR_SIZE, "#%02x%02x%02x", red, green, blue);
2120 MSG_DEBUG("__MmsSmilFindColorValue: gszColor %s \n", gszColor);
2126 /** @fn static xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszValue)
2127 * @brief Get node based on pszValue. \n
2128 * @param[in] pNode specifies node. \n
2129 * @param[in] pszName specifies name field. \n
2130 * @retval RGB value. \n
2132 xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName)
2136 if ((NULL != pstNode) && (NULL != pszName)) {
2137 xmlNodePtr pstTempNode;
2138 xmlNodePtr pstReturnNode;
2140 pstTempNode = pstNode;
2142 for ( ; pstTempNode; pstTempNode = pstTempNode->next) {
2143 MSG_DEBUG("\n Node Name = %s[%p] children =%p \n", (char *)pstTempNode->name, pstTempNode, pstTempNode->children);
2144 MSG_DEBUG("\n Compare Parent Node = %s[%p] \n", (char *)pstTempNode->name, pstTempNode);
2145 if (0 == strcasecmp((char *)pstTempNode->name, pszName)) {
2149 if (pstTempNode->children) {
2150 MSG_DEBUG("\n Enter Inside\n");
2151 pstReturnNode = UtilxmlStringGetNodeList(pstTempNode->children, pszName);
2152 if (NULL != pstReturnNode) {
2153 return pstReturnNode;