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);
353 memcpy(pMedia->szSrc, szSrc, strlen(szSrc) + 1);
356 cLen = strlen(pMedia->szSrc);
357 if (!strncasecmp(pMedia->szSrc, "cid:", 4)) {
358 strncpy(szTmpSrc, pMedia->szSrc + 4, cLen - 4);
359 szTmpSrc[cLen - 4] = '\0';
361 strncpy(szTmpSrc, pMedia->szSrc, cLen);
362 szTmpSrc[cLen] = '\0';
365 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
366 pPart = pMsg->msgBody.body.pMultipart;
367 #ifndef __SUPPORT_DRM__
368 MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart);
370 MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart, pMedia);
373 strcpy(pMedia->szSrc, szOutBuf);
374 MmsSmilGetMediaFilePath(pMedia, szTmpSrc, pMsg->msgID);
378 case ATTRIBUTE_COLOR:
379 if (cmd[ELEMENT_TEXT])
380 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
384 if (cmd[ELEMENT_TEXT])
385 pMedia->sMedia.sText.nSize = atoi((char *)pAttr->children->content);
389 if (cmd[ELEMENT_TEXT]) {
390 pMedia->sMedia.sText.bBold = MmsSmilGetFontAttrib((char *)pAttr->children->content);
394 case ATTRIBUTE_UNDERLINE:
395 if (cmd[ELEMENT_TEXT])
396 pMedia->sMedia.sText.bUnderLine = MmsSmilGetFontAttrib((char *)pAttr->children->content);
399 case ATTRIBUTE_ITALIC:
400 if (cmd[ELEMENT_TEXT])
401 pMedia->sMedia.sText.bItalic = MmsSmilGetFontAttrib((char *)pAttr->children->content);
404 case ATTRIBUTE_REVERSE:
405 if (cmd[ELEMENT_TEXT])
406 pMedia->sMedia.sText.bReverse = MmsSmilGetFontAttrib((char *)pAttr->children->content);
409 case ATTRIBUTE_DIRECTION:
410 if (cmd[ELEMENT_TEXT])
411 pMedia->sMedia.sText.nDirection = MmsSmilGetFontDirection((char *)pAttr->children->content);
414 case ATTRIBUTE_REGION:
415 strncpy(pMedia->regionId, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
418 case ATTRIBUTE_TRANSIN:
419 if (cmd[ELEMENT_TEXT])
420 strncpy(pMedia->sMedia.sText.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
422 strncpy(pMedia->sMedia.sAVI.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
425 case ATTRIBUTE_TRANSOUT:
426 if (cmd[ELEMENT_TEXT])
427 strncpy(pMedia->sMedia.sText.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
429 strncpy(pMedia->sMedia.sAVI.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
432 case ATTRIBUTE_BEGIN:
433 if (cmd[ELEMENT_TEXT])
434 pMedia->sMedia.sText.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
436 pMedia->sMedia.sAVI.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
440 if (cmd[ELEMENT_TEXT])
441 pMedia->sMedia.sText.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
443 pMedia->sMedia.sAVI.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
446 case ATTRIBUTE_REPEAT_COUNT:
447 if (cmd[ELEMENT_TEXT])
448 pMedia->sMedia.sText.nRepeat = atoi((char *)pAttr->children->content);
450 pMedia->sMedia.sAVI.nRepeat = atoi((char *)pAttr->children->content);
454 if (!strcmp((char *)pAttr->children->content, "foreground-color") || !strcmp((char *)pAttr->children->content, "foregroundcolor"))
455 paramType = ATTRIBUTE_FGCOLOR;
456 else if (!strcmp((char *)pAttr->children->content, "background-color") || !strcmp((char *)pAttr->children->content, "backgroundcolor"))
457 paramType = ATTRIBUTE_BGCOLOR;
458 else if (!strcmp((char *)pAttr->children->content, "textsize"))
459 paramType = ATTRIBUTE_SIZE;
460 else if (!strcmp((char *)pAttr->children->content, "textattribute"))
461 paramType = ATTRIBUTE_TEXTFORMAT;
463 if (cmd[ELEMENT_META])
464 strncpy(pMeta->szName, (char *)pAttr->children->content, MAX_SMIL_META_NAME - 1);
467 case ATTRIBUTE_VALUE:
468 if (paramType == ATTRIBUTE_SIZE && cmd[ELEMENT_TEXT])
469 pMedia->sMedia.sText.nSize = MmsSmilGetFontSizeValue((char *)pAttr->children->content);
470 else if (paramType == ATTRIBUTE_FGCOLOR && cmd[ELEMENT_TEXT])
471 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
472 else if (paramType == ATTRIBUTE_BGCOLOR && cmd[ELEMENT_TEXT])
473 pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
474 else if (paramType == ATTRIBUTE_TEXTFORMAT && cmd[ELEMENT_TEXT]) {
475 MmsSmilFontType fontType;
477 fontType = MmsSmilGetFontTypeValue((char *)pAttr->children->content);
479 if (fontType == MMS_SMIL_FONT_TYPE_BOLD)
480 pMedia->sMedia.sText.bBold = true;
482 pMedia->sMedia.sText.bBold = false;
484 if (fontType == MMS_SMIL_FONT_TYPE_ITALIC)
485 pMedia->sMedia.sText.bItalic = true;
487 pMedia->sMedia.sText.bItalic = false;
489 if (fontType == MMS_SMIL_FONT_TYPE_UNDERLINE)
490 pMedia->sMedia.sText.bUnderLine = true;
492 pMedia->sMedia.sText.bUnderLine = false;
497 strncpy(pMedia->szAlt, (char *)pAttr->children->content, MAX_SMIL_ALT_LEN - 1);
501 pTransition->nType = (MmsSmilTransType)atoi((char *)pAttr->children->content);
503 switch (pTransition->nType) {
504 case MMS_SMIL_TRANS_SLIDEWIPE:
505 pTransition->nSubType = MMS_SMIL_TRANS_SUB_FROM_LEFT;
507 case MMS_SMIL_TRANS_BARWIPE:
508 pTransition->nSubType = MMS_SMIL_TRANS_SUB_TOP_TO_BOTTOM;
510 case MMS_SMIL_TRANS_BARNDOORWIPE:
511 pTransition->nSubType = MMS_SMIL_TRANS_SUB_HORIZONTAL;
514 pTransition->nSubType = MMS_SMIL_TRANS_SUB_NONE;
520 case ATTRIBUTE_SUBTYPE:
521 pTransition->nSubType = (MmsSmilTransSubType)atoi((char *)pAttr->children->content);
524 case ATTRIBUTE_CONTENT:
525 strncpy(pMeta->szContent, (char *)pAttr->children->content, MAX_SMIL_META_CONTENT - 1);
527 #ifdef MMS_SMIL_ANIMATE
528 case ATTRIBUTE_ATTRIBUTE_NAME:
529 strcpy(pMedia->sMedia.sAVI.nAttributeName, (char *)pAttr->children->content);
532 case ATTRIBUTE_ATTRIBUTE_TYPE:
533 strcpy(pMedia->sMedia.sAVI.nAttributeType, (char *)pAttr->children->content);
536 case ATTRIBUTE_TARGET_ELEMENT:
537 strcpy(pMedia->sMedia.sAVI.nTargetElement, (char *)pAttr->children->content);
541 pMedia->sMedia.sAVI.nFrom = atoi((char *)pAttr->children->content);
545 pMedia->sMedia.sAVI.nTo = atoi((char *)pAttr->children->content);
549 pMedia->sMedia.sAVI.nBy = atoi((char *)pAttr->children->content);
552 case ATTRIBUTE_VALUES:
553 pMedia->sMedia.sAVI.nValues = atoi((char *)pAttr->children->content);
556 case ATTRIBUTE_CALCMODE:
557 strcpy(pMedia->sMedia.sAVI.nCalcMode, (char *)pAttr->children->content);
561 MSG_DEBUG("Undefined Attribute was found!!!!!");
565 if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_REGION]) {
566 // Insert a region to region list
567 _MsgMmsAddRegion(pMmsMsg, pRegion);
568 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_PAR]) {
569 //Insert a page to page list
570 _MsgMmsAddPage(pMmsMsg, pPage);
571 } else if (paramType == ATTRIBUTE_UNKNOWN && (cmd[ELEMENT_TEXT] ||cmd[ELEMENT_IMG] ||cmd[ELEMENT_AUDIO] ||cmd[ELEMENT_VIDEO] ||cmd[ELEMENT_ANIMATE])) {
572 //Insert a media to media list
573 _MsgMmsAddMedia(pPage, pMedia);
574 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_ROOTLAYOUT]) {
575 _MsgMmsSetRootLayout(pMmsMsg, &rootlayout);
576 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_TRANSITION]) {
577 //Insert a transition to transition list
578 _MsgMmsAddTransition(pMmsMsg, pTransition);
579 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_META]) {
580 //Insert a meta to meta list
581 _MsgMmsAddMeta(pMmsMsg, pMeta);
584 paramType = ATTRIBUTE_UNKNOWN;
587 MmsSmilGetElement(pMmsMsg, cur_node->children);
594 int MmsSmilGetColorValue(xmlChar *content)
598 if (content[0] == '#') // RGB value
599 color = MmsSmilAtoIHexa((char *)&content[1]);
600 else if (content[0] == '0' && (content[1] == 'x' || content[1] == 'X'))
601 color = MmsSmilAtoIHexa((char *)&content[2]);
603 MSG_DEBUG("Invalid Color Value");
610 int MmsSmilAtoIHexa(char *pInput)
617 char *pOutput = NULL;
619 MSG_DEBUG("__MmsSmilAtoIHexa() enter..\n");
621 len = strlen(pInput);
622 pOutput = (char *)malloc(len + 1);
624 if (pOutput == NULL) {
625 MSG_DEBUG("__MmsSmilAtoIHexa: Memory full \n");
629 memset(pOutput, 0, len + 1);
631 for (i = len - 1; i >= 0; i--) {
632 for (j = 0; j < (len - 1 - i); j++) {
708 res += (pOutput[i] * temp);
722 int MmsSmilGetTime(char *pValue)
730 if (pValue == NULL || pValue[0] == '\0')
733 len = strlen(pValue);
735 /* Default time unit -> millisecond */
736 if (strstr(pValue, "msec"))
739 if (strstr(pValue, "ms"))
742 pTemp = (char *)malloc(strlen(pValue) + 1);
745 MSG_DEBUG("__MmsSmilGetTime : malloc for <time> attribute is failed \n");
749 while (isdigit(pValue[i])) {
750 pTemp[i] = pValue[i];
755 /* Detect 's' and 'ms' here */
756 retVal = atoi(pTemp);
768 #ifndef __SUPPORT_DRM__
769 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart)
771 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart, MMS_MEDIA_S *pMedia)
774 char szContentID[MSG_MSG_ID_LEN + 1] = {0, };
775 char szContentLI[MSG_MSG_ID_LEN + 1] = {0, };
779 MSG_DEBUG("szInBuf: %s", szInBuf);
780 while (pPart && pPart->pBody) {
781 if (pPart->type.szContentID[0]) {
782 cLen = strlen(pPart->type.szContentID);
784 if (pPart->type.szContentID[0] == '<' && pPart->type.szContentID[cLen - 1] == '>') {
785 strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
786 szContentID[cLen - 2] = '\0';
787 } else if (pPart->type.szContentID[0] == MSG_CH_QUOT && pPart->type.szContentID[cLen-1] == MSG_CH_QUOT) {
788 strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
789 szContentID[cLen - 2] = '\0';
791 strncpy(szContentID, pPart->type.szContentID, cLen);
792 szContentID[cLen] = '\0';
795 szContentID[0] = '\0';
798 MSG_DEBUG("szContentID: %s", szContentID);
800 if (pPart->type.szContentLocation[0]) {
801 cLen = strlen(pPart->type.szContentLocation);
803 if (pPart->type.szContentLocation[0] == MSG_CH_QUOT &&
804 pPart->type.szContentLocation[cLen-1] == MSG_CH_QUOT) {
805 strncpy(szContentLI, &pPart->type.szContentLocation[1], cLen-2);
806 szContentLI[cLen-2] = '\0';
808 strncpy(szContentLI, pPart->type.szContentLocation, cLen);
809 szContentLI[cLen] = '\0';
812 szContentLI[0] = '\0';
815 MSG_DEBUG("szContentLocation: %s", szContentLI);
817 if (strcasecmp(szContentID, szInBuf) == 0) {
818 strcpy(szOutbuf, pPart->type.param.szFileName);
819 MSG_DEBUG("match with szContentID.");
822 char *szInFileName = strrchr(szInBuf, '/');
824 if (szInFileName == NULL) {
825 szInFileName = szInBuf;
829 if (strcasecmp(szContentLI, szInFileName) == 0) {
830 strcpy(szOutbuf, pPart->type.param.szFileName);
831 MSG_DEBUG("match with szContentLI.");
833 } else if (strcasecmp(pPart->type.param.szName, szInBuf) == 0) {
834 strcpy(szOutbuf, pPart->type.param.szFileName);
835 MSG_DEBUG("match with pPart->type.param.szName.");
837 } else if (strlen(szContentID) > 4) {
838 if (strcasecmp(strtok(szContentID, "."), strtok(szInBuf, ".")) == 0) {
839 strcpy(szOutbuf, pPart->type.param.szFileName);
840 MSG_DEBUG("only name is match with szContentID.");
843 } else if (strlen(szContentLI) > 4) {
844 if (strcasecmp(strtok(szContentLI, "."), strtok(szInBuf, ".")) == 0) {
845 strcpy(szOutbuf, pPart->type.param.szFileName);
846 MSG_DEBUG("only name is match with szContentLI.");
853 pPart = pPart->pNext;
859 #ifdef __SUPPORT_DRM__
860 pMedia->drmType = pPart->type.drmInfo.drmType;
862 if (pPart->type.drmInfo.szDrm2FullPath != NULL) {
863 MSG_DEBUG("szDrm2FullPath: %s", pPart->type.drmInfo.szDrm2FullPath);
864 strncpy(pMedia->szDrm2FullPath, pPart->type.drmInfo.szDrm2FullPath, MSG_FILEPATH_LEN_MAX - 1);
871 int MmsSmilGetElementID(char *pString)
873 if (!strcmp(pString, "smil"))
875 else if (!strcmp(pString, "head"))
877 else if (!strcmp(pString, "layout"))
878 return ELEMENT_LAYOUT;
879 else if (!strcmp(pString, "root-layout"))
880 return ELEMENT_ROOTLAYOUT;
881 else if (!strcmp(pString, "region"))
882 return ELEMENT_REGION;
883 else if (!strcmp(pString, "body"))
885 else if (!strcmp(pString, "par"))
887 else if (!strcmp(pString, "param"))
888 return ELEMENT_PARAM;
889 else if (!strcmp(pString, "text"))
891 else if (!strcmp(pString, "img"))
893 else if (!strcmp(pString, "audio"))
894 return ELEMENT_AUDIO;
895 else if (!strcmp(pString, "video"))
896 return ELEMENT_VIDEO;
897 else if (!strcmp(pString, "ref"))
899 else if (!strcmp(pString, "animate"))
900 return ELEMENT_ANIMATE;
901 else if (!strcmp(pString, "root-layout"))
903 else if (!strcmp(pString, "transition"))
904 return ELEMENT_TRANSITION;
905 else if (!strcmp(pString, "meta"))
911 int MmsSmilGetAttrID(char *pString)
913 if (!strcmp(pString, "id"))
915 else if (!strcmp(pString, "top"))
916 return ATTRIBUTE_TOP;
917 else if (!strcmp(pString, "left"))
918 return ATTRIBUTE_LEFT;
919 else if (!strcmp(pString, "width"))
920 return ATTRIBUTE_WIDTH;
921 else if (!strcmp(pString, "height"))
922 return ATTRIBUTE_HEIGHT;
923 else if (!strcmp(pString, "fit"))
924 return ATTRIBUTE_FIT;
925 else if (!strcmp(pString, "backgroundColor"))
926 return ATTRIBUTE_BGCOLOR;
927 else if (!strcmp(pString, "dur"))
928 return ATTRIBUTE_DUR;
929 else if (!strcmp(pString, "src"))
930 return ATTRIBUTE_SRC;
931 else if (!strcmp(pString, "color"))
932 return ATTRIBUTE_COLOR;
933 else if (!strcmp(pString, "bold"))
934 return ATTRIBUTE_BOLD;
935 else if (!strcmp(pString, "underline"))
936 return ATTRIBUTE_UNDERLINE;
937 else if (!strcmp(pString, "italic"))
938 return ATTRIBUTE_ITALIC;
939 else if (!strcmp(pString, "reverse"))
940 return ATTRIBUTE_REVERSE;
941 else if (!strcmp(pString, "direction"))
942 return ATTRIBUTE_DIRECTION;
943 else if (!strcmp(pString, "size"))
944 return ATTRIBUTE_SIZE;
945 else if (!strcmp(pString, "font"))
946 return ATTRIBUTE_FONT;
947 else if (!strcmp(pString, "region"))
948 return ATTRIBUTE_REGION;
949 else if (!strcmp(pString, "name"))
950 return ATTRIBUTE_NAME;
951 else if (!strcmp(pString, "value"))
952 return ATTRIBUTE_VALUE;
953 else if (!strcmp(pString, "alt"))
954 return ATTRIBUTE_ALT;
955 else if (!strcmp(pString, "type"))
956 return ATTRIBUTE_TYPE;
957 else if (!strcmp(pString, "subtype"))
958 return ATTRIBUTE_SUBTYPE;
959 else if (!strcmp(pString, "content"))
960 return ATTRIBUTE_CONTENT;
961 else if (!strcmp(pString, "transIn"))
962 return ATTRIBUTE_TRANSIN;
963 else if (!strcmp(pString, "transOut"))
964 return ATTRIBUTE_TRANSOUT;
965 else if (!strcmp(pString, "begin"))
966 return ATTRIBUTE_BEGIN;
967 else if (!strcmp(pString, "end"))
968 return ATTRIBUTE_END;
969 else if (!strcmp(pString, "repeatCount"))
970 return ATTRIBUTE_REPEAT_COUNT;
971 #ifdef MMS_SMIL_ANIMATE
972 else if (!strcmp(pString, "attributeName"))
973 return ATTRIBUTE_ATTRIBUTE_NAME;
974 else if (!strcmp(pString, "attributeType"))
975 return ATTRIBUTE_ATTRIBUTE_TYPE;
976 else if (!strcmp(pString, "targetElement"))
977 return ATTRIBUTE_TARGET_ELEMENT;
978 else if (!strcmp(pString, "from"))
979 return ATTRIBUTE_FROM;
980 else if (!strcmp(pString, "to"))
982 else if (!strcmp(pString, "by"))
984 else if (!strcmp(pString, "values"))
985 return ATTRIBUTE_VALUES;
986 else if (!strcmp(pString, "calcMode"))
987 return ATTRIBUTE_CALCMODE;
993 bool MmsSmilGetFontAttrib(char *pString)
995 if (!strcmp(pString, "true"))
1001 MmsTextDirection MmsSmilGetFontDirection(char *pString)
1003 MmsTextDirection direction = MMS_TEXT_DIRECTION_INVALID;
1005 if (!strcmp(pString, "right"))
1006 direction = MMS_TEXT_DIRECTION_RIGHT;
1007 else if (!strcmp(pString, "down"))
1008 direction = MMS_TEXT_DIRECTION_DOWN;
1013 int MmsSmilGetFontSizeValue(char *pString)
1015 MSG_DEBUG(" #### content = %s #### ", pString);
1016 if (!strcmp(pString, "small"))
1017 return MMS_SMIL_FONT_SIZE_SMALL;
1018 else if (!strcmp(pString, "normal"))
1019 return MMS_SMIL_FONT_SIZE_NORMAL;
1020 else if (!strcmp(pString, "large"))
1021 return MMS_SMIL_FONT_SIZE_LARGE;
1023 return atoi(pString);
1026 MmsSmilFontType MmsSmilGetFontTypeValue(char *pString)
1028 MSG_DEBUG(" #### content = %s #### ", pString);
1030 if (!strcmp(pString, "normal"))
1031 return MMS_SMIL_FONT_TYPE_NORMAL;
1032 else if (!strcmp(pString, "italic"))
1033 return MMS_SMIL_FONT_TYPE_ITALIC;
1034 else if (!strcmp(pString, "bold"))
1035 return MMS_SMIL_FONT_TYPE_BOLD;
1036 else if (!strcmp(pString, "underline"))
1037 return MMS_SMIL_FONT_TYPE_UNDERLINE;
1039 return MMS_SMIL_FONT_TYPE_NORMAL;
1042 bool MmsSmilGetMediaFilePath(MMS_MEDIA_S *pMedia, char *pszTemp, int msgID)
1045 MSG_DEBUG("pMedia is NULL");
1049 snprintf(pMedia->szFilePath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_DATA_PATH, pMedia->szSrc);
1050 MSG_DEBUG("pMedia's filePath: %s", pMedia->szFilePath);
1052 __MmsGetRealFileName(pMedia->mediatype, pMedia->szSrc, pMedia->szFileName, msgID);
1053 MSG_DEBUG("pMedia's fileName: %s", pMedia->szFileName);
1055 snprintf(pMedia->szContentID, MSG_MSG_ID_LEN+1, "%s", pszTemp);
1056 MSG_DEBUG("pMedia's ContentID: %s", pMedia->szContentID);
1062 /** @fn bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
1063 * @brief Forms Smil Buffer using pstMsgBody. \n
1064 * @param[in/out] pstMsgBody is Message handle. \n
1065 * @retval TRUE In case of Success. \n
1066 * @retval FALSE In case of failure. \n
1068 bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
1070 HMmsSmil hSmilDoc = INVALID_HOBJ;
1076 MMS_PAGE_S *pstPage;
1077 MMS_MEDIA_S *pstMedia;
1078 MMS_SMIL_REGION *pstRegion;
1083 hSmilDoc = MmsSmilCreateEmptySmilDoc();
1084 MSG_DEBUG("Smil Doc =%d",hSmilDoc);
1085 if (INVALID_HOBJ == hSmilDoc) {
1086 MSG_DEBUG("Invalid SmilDoc[%d]",hSmilDoc);
1089 // Add Root Layout to Smil Document
1090 if (false == MmsSmilAddRootLayout(hSmilDoc, &(pstMsgBody->rootlayout))) {
1091 MSG_DEBUG("MmsSmilAddRootLayout Failed");
1092 MmsSmilDestroyDoc(hSmilDoc);
1094 //Add Region list to Smil Document
1095 nRegionCount = pstMsgBody->regionCnt;
1096 MSG_DEBUG(" Region Count =%d",nRegionCount);
1097 for (nIndex = 0; nIndex < nRegionCount; nIndex++) {
1098 MSG_DEBUG("Calling _MsgMmsGetSmilRegion");
1099 pstRegion = _MsgMmsGetSmilRegion(pstMsgBody, nIndex);
1100 if (NULL == pstRegion) {
1101 MSG_DEBUG("pstRegion is NULL");
1102 MmsSmilDestroyDoc(hSmilDoc);
1105 MSG_DEBUG("Calling MmsSmilAddRegion");
1106 if (false == MmsSmilAddRegion(hSmilDoc, pstRegion)) {
1107 MSG_DEBUG("Adding Region to smil doc failed");
1108 MmsSmilDestroyDoc(hSmilDoc);
1112 // Add page list to Smil Document
1113 nTotalPageNum = pstMsgBody->pageCnt ;
1114 MSG_DEBUG(" Page Count =%d",nTotalPageNum);
1115 for (nIndex = 0; nIndex < nTotalPageNum; nIndex++) {
1116 MSG_DEBUG("Calling _MsgMmsGetPage");
1117 pstPage = _MsgMmsGetPage(pstMsgBody, nIndex);
1118 if (NULL == pstPage) {
1119 MSG_DEBUG("pstPage is NULL");
1120 MmsSmilDestroyDoc(hSmilDoc);
1123 // Add page to smil doc
1124 MSG_DEBUG("Calling MmsSmilAddPage");
1125 if (false == MmsSmilAddPage(hSmilDoc, pstPage)) {
1126 MSG_DEBUG("Adding page to smil doc failed");
1127 MmsSmilDestroyDoc(hSmilDoc);
1130 nTotalMediaNum = pstPage->mediaCnt;
1131 MSG_DEBUG(" Media Count =%d",nTotalMediaNum);
1132 for (nMediaIndex = 0; nMediaIndex < nTotalMediaNum; nMediaIndex++) {
1133 MSG_DEBUG("Calling _MsgMmsGetMedia");
1134 pstMedia = _MsgMmsGetMedia(pstPage, nMediaIndex);
1135 if (NULL == pstMedia) {
1136 MSG_DEBUG("pMedia is NULL");
1137 MmsSmilDestroyDoc(hSmilDoc);
1140 MSG_DEBUG("Calling MmsSmilAddMedia");
1141 if (false == MmsSmilAddMedia(hSmilDoc, nIndex, nMediaIndex, pstMedia, pstMedia->szContentID)) {
1142 MSG_DEBUG("MmsSmilAddMedia failed");
1143 MmsSmilDestroyDoc(hSmilDoc);
1148 MSG_DEBUG("MMSGenerateSmilBuffer: Start update template");
1149 pszRawData = MmsSmilGetRawData(hSmilDoc);
1150 if (NULL == pszRawData) {
1151 MSG_DEBUG("MMSGenerateSmilBuffer: MmsSmilGetRawData failed");
1152 MmsSmilDestroyDoc(hSmilDoc);
1156 char fullpath[MSG_FILEPATH_LEN_MAX] = {0,};
1157 snprintf(fullpath, MSG_FILEPATH_LEN_MAX, MSG_SMIL_FILE_PATH"%s", pstMsgBody->szSmilFilePath);
1159 if (MsgWriteSmilFile(fullpath, pszRawData, strlen(pszRawData) + 1) == false) {
1160 MSG_DEBUG("MMSGenerateSmilBuffer: MsgWriteSmilFile failed");
1161 xmlFree((xmlChar*)pszRawData);
1162 MmsSmilDestroyDoc(hSmilDoc);
1166 MSG_DEBUG("MMSGenerateSmilBuffer: complete update template\n");
1167 xmlFree((xmlChar*)pszRawData);
1168 MmsSmilDestroyDoc(hSmilDoc);
1173 /** @fn static HMmsSmil MmsSmilCreateEmptySmilDoc(void)
1174 * @brief Creates default Smil Doc based on input gszEmptyRawDoc. \n
1175 * @retval Returns Smil Document number. \n
1177 HMmsSmil MmsSmilCreateEmptySmilDoc(void)
1183 hMmsSmil = MmsSmilCreateSmilDoc(gszEmptyRawDoc);
1185 MSG_DEBUG("Create an empty smilDoc.(Handle = %d)", hMmsSmil);
1192 /** @fn static HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
1193 * @brief Creates Smil Doc based on input pszRawData. \n
1194 * @param[in] pszRawData is smil buffer. \n
1195 * @retval Returns Smil Document number. \n
1197 HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
1200 xmlNodePtr stRootNode;
1204 // Destroy smil doc if present
1205 if (NULL != __gpaMmsSmilDoc[nSmilDocNo]) {
1206 MSG_DEBUG("Calling MmsSmilDestroyDoc");
1207 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1208 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1212 for (nSmilDocNo = 0; nSmilDocNo < MMS_SMIL_MAX_DOC; nSmilDocNo++) {
1213 if (NULL == __gpaMmsSmilDoc[nSmilDocNo])
1217 if (MMS_SMIL_MAX_DOC == nSmilDocNo) {
1218 MSG_DEBUG("SmilDoc table is full. Can't create.");
1219 return INVALID_HOBJ;
1221 __gpaMmsSmilDoc[nSmilDocNo] = (MmsSmilDoc*)malloc(sizeof(MmsSmilDoc));
1222 if (NULL == __gpaMmsSmilDoc[nSmilDocNo]) {
1223 MSG_DEBUG("Memory Allocation Failed.");
1224 return INVALID_HOBJ;
1226 memset(__gpaMmsSmilDoc[nSmilDocNo], 0, sizeof(MmsSmilDoc));
1228 __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc = xmlParseMemory(pszRawData, strlen(pszRawData));
1229 if (NULL == __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1230 MSG_DEBUG("Document not parsed successfully.");
1231 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1232 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1234 return INVALID_HOBJ;
1236 stRootNode = xmlDocGetRootElement(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
1237 if (NULL == stRootNode) {
1238 MSG_DEBUG("Empty document\n");
1239 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1240 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1242 return INVALID_HOBJ;
1244 if (xmlStrcmp(stRootNode->name, (const xmlChar *) "smil")) {
1245 MSG_DEBUG("Document of the wrong type, root node != smil");
1246 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1247 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1249 return INVALID_HOBJ;
1252 __gpaMmsSmilDoc[nSmilDocNo]->pstRootNode = stRootNode;
1255 return ((HMmsSmil)nSmilDocNo);
1258 /** @fn static bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
1259 * @brief Destroys Smil Doc. \n
1260 * @param[in] hSmilDoc is smil doc number. \n
1261 * @retval TRUE In case of Success. \n
1262 * @retval FALSE In case of failure. \n
1264 bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
1266 int nSmilDocNo = (int)hSmilDoc;
1270 if (0 <= nSmilDocNo &&
1271 nSmilDocNo < MMS_SMIL_MAX_DOC &&
1272 __gpaMmsSmilDoc[nSmilDocNo]) {
1273 if (__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1274 xmlFreeDoc(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
1277 if (__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode) {
1280 free(__gpaMmsSmilDoc[nSmilDocNo]);
1281 __gpaMmsSmilDoc[nSmilDocNo] = NULL;
1283 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1291 /** @fn static bool IsValidSmilDocNo(int nSmilDocNo)
1292 * @brief Form Smil Doc. \n
1293 * @param[in] hSmilDoc is smil doc number. \n
1294 * @retval Returns Smil Buffer In case of success. \n
1295 * @retval Returns NULL In case of failure. \n
1297 bool IsValidSmilDocNo(int nSmilDocNo)
1299 bool bIsValidSmil = false;
1303 if (0 <= nSmilDocNo &&
1304 nSmilDocNo < MMS_SMIL_MAX_DOC &&
1305 __gpaMmsSmilDoc[nSmilDocNo] &&
1306 __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1307 bIsValidSmil = true;
1311 return bIsValidSmil;
1314 /** @fn static char MmsSmilGetRawData(HMmsSmil hSmilDoc)
1315 * @brief Form Smil Doc. \n
1316 * @param[in] hSmilDoc is smil doc number. \n
1317 * @retval Returns Smil Buffer In case of success. \n
1318 * @retval Returns NULL In case of failure. \n
1320 char *MmsSmilGetRawData(HMmsSmil hSmilDoc)
1322 int nSmilDocNo = (int)hSmilDoc;
1323 char *pszRawData = NULL;
1327 if (IsValidSmilDocNo(nSmilDocNo)) {
1328 xmlSaveFormatFileEnc("-", __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, "UTF-8", 1);
1329 xmlDocDumpMemory(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, (xmlChar **)(&pszRawData) , NULL);
1330 if (NULL == pszRawData) {
1331 MSG_DEBUG("Invalid pSmilDoc (now wellformed document)");
1335 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1340 /** @fn static bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
1341 * @brief Add Page to Smil Doc. \n
1342 * @param[in] hSmilDoc is smil doc number. \n
1343 * @param[in] pstSmilPage specifies page information. \n
1344 * @retval TRUE In case of Success. \n
1345 * @retval FALSE In case of failure. \n
1347 bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
1349 int nSmilDocNo = hSmilDoc;
1355 if (IsValidSmilDocNo(nSmilDocNo)) {
1356 xmlNodePtr pstParElement;
1357 xmlNodePtr pstBodyElement;
1358 xmlNodePtr pstParList;
1359 char szBuf[MSG_STDSTR_SHORT] = {0, };
1361 pstBodyElement = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"body");
1363 if (NULL == pstBodyElement) {
1364 MSG_DEBUG("There is no <body> node. Can't create <par> node.");
1367 MSG_DEBUG("Body Element Name = %s", (char *)pstBodyElement->name);
1368 /* Create "par" node and insert it */
1369 pstParElement = xmlNewNode(NULL, (xmlChar *)"par");
1371 if (NULL == pstParElement) {
1372 MSG_DEBUG("Can't create <par> node. (from XmlParser) \n");
1375 MSG_DEBUG("Par Element Name = %s", (char *)pstParElement->name);
1377 /* Add attributes to "par" */
1378 if (pstSmilPage->nDur > 0) {
1379 snprintf(szBuf, MSG_STDSTR_SHORT, "%dms", pstSmilPage->nDur);
1380 xmlSetProp(pstParElement, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1382 /* Find the insertion point : right sibling of the last <par> node or first child of <body> */
1384 pstParList = xmlGetLastChild(pstBodyElement);
1387 ret = __MmsSmilInsertNode(pstBodyElement, pstParList, pstParElement);
1389 ret = __MmsInsertFirstChild(pstBodyElement, pstParElement);
1392 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1399 /** @fn static bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
1400 * @brief Add Rootlayout to Smil Doc. \n
1401 * @param[in] hSmilDoc is smil doc number. \n
1402 * @param[in] pstSmilRootLayout specifies RootLayout information. \n
1403 * @retval TRUE In case of Success. \n
1404 * @retval FALSE In case of failure. \n
1406 bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
1408 int nSmilDocNo = hSmilDoc;
1409 xmlNodePtr pstRootLayout = NULL;
1410 xmlNodePtr pstLayoutList = NULL;
1411 xmlNodePtr pstRootLayoutList = NULL;
1412 char szBuf[MSG_STDSTR_SHORT] = {0, };
1416 if (IsValidSmilDocNo(nSmilDocNo)) {
1417 pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
1419 if (NULL == pstLayoutList) {
1420 MSG_DEBUG("There is no <layout> node. Can't create <root-layout> node.");
1423 MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
1425 pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
1427 if (NULL != pstRootLayoutList) {
1428 MSG_DEBUG("MmsSmilAddRootLayout: There is <root-layout> node already");
1429 MSG_DEBUG("Root Layout Element Name = %s type=%d\n", (char *)pstRootLayoutList->name);
1432 /* Create "root-layout" node and insert it */
1433 pstRootLayout = xmlNewNode(NULL, (xmlChar *)"root-layout");
1434 if (NULL == pstRootLayout) {
1435 MSG_DEBUG("Can't create <root-layout> node. (from XmlParser)");
1438 MSG_DEBUG("Root Layout Element Name = %s", (char *)pstRootLayout->name);
1440 if (pstSmilRootLayout->bgColor != SP_NO_COLOR_SET) { // Replace value later
1441 xmlSetProp(pstRootLayout, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRootLayout->bgColor));
1443 MSG_DEBUG(" Set Width");
1444 if (true == pstSmilRootLayout->width.bUnitPercent) {
1445 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->width.value);
1446 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
1448 if (pstSmilRootLayout->width.value > 0) {
1449 snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->width.value);
1450 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
1452 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)"100%");
1455 MSG_DEBUG(" Set Height");
1456 if (true == pstSmilRootLayout->height.bUnitPercent) {
1457 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->height.value);
1458 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
1460 if (pstSmilRootLayout->height.value > 0) {
1461 snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->height.value);
1462 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
1464 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)"100%");
1467 __MmsInsertFirstChild(pstLayoutList, pstRootLayout);
1471 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1478 /** @fn static bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
1479 * @brief Add Region to Smil Doc. \n
1480 * @param[in] hSmilDoc is smil doc number. \n
1481 * @param[in] pstSmilRegion specifies Region information. \n
1482 * @retval TRUE In case of Success. \n
1483 * @retval FALSE In case of failure. \n
1485 bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
1487 int nSmilDocNo = hSmilDoc;
1491 if (IsValidSmilDocNo(nSmilDocNo)) {
1493 int nRootHeight = 0;
1494 xmlNodePtr pstRegion;
1495 xmlNodePtr pstLayoutList;
1496 xmlNodePtr pstRootLayoutList;
1497 xmlAttrPtr pAttribute;
1498 char szBuf[MSG_STDSTR_SHORT] = {0, };
1500 pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
1501 if (NULL == pstLayoutList) {
1502 MSG_DEBUG(" There is no <layout> node. Can't create <region> node");
1505 MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
1507 /* Find the insertion point : right sibling of the last root-layout node or first child of pLayout */
1508 pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
1510 if (NULL == pstRootLayoutList) {
1511 MSG_DEBUG("There is no <root-layout> node. Can't create <root-layout> node.");
1514 MSG_DEBUG("Root Layout Element Name = %s ", (char *)pstRootLayoutList->name);
1515 pAttribute = pstRootLayoutList->properties;
1518 if (NULL == pAttribute) {
1519 MSG_DEBUG("There is no Attribute in <root-layout> node.");
1523 xmlAttrPtr pstAttr = pAttribute;
1524 for ( ; pstAttr; pstAttr = pstAttr->next) {
1526 MSG_DEBUG("AttributeType: (%s, %s) ", pstAttr->name, pstAttr->children->content);
1527 switch (attrType = MmsSmilGetAttrID((char *)pstAttr->name)) {
1528 case ATTRIBUTE_WIDTH:
1532 if (strchr((char *)pstAttr->children->content, '%'))
1533 bUnitPercent = true;
1535 bUnitPercent = false;
1537 nRootWidth = atoi((char *)pstAttr->children->content);
1541 case ATTRIBUTE_HEIGHT:
1545 if (strchr((char *)pstAttr->children->content, '%'))
1546 bUnitPercent = true;
1548 bUnitPercent = false;
1550 nRootHeight = atoi((char *)pstAttr->children->content);
1556 /* Create "region" node and insert it */
1557 MSG_DEBUG("Create Region Node");
1558 pstRegion = xmlNewNode(NULL, (xmlChar *)"region");
1559 if (NULL == pstRegion) {
1560 MSG_DEBUG("Can't create <region> node. (from XmlParser)");
1563 /* Add attributes */
1564 if (pstSmilRegion) {
1565 MSG_DEBUG(" [Set Attribute] : Region Id");
1566 if (strlen(pstSmilRegion->szID) > 0) {
1567 xmlSetProp(pstRegion, (const xmlChar *)"id", (const xmlChar *)pstSmilRegion->szID);
1569 MSG_DEBUG(" [Set Attribute] : BkGrd Color");
1570 // Default Color WHITE, always send
1571 if (pstSmilRegion->bgColor != SP_NO_COLOR_SET) {
1572 xmlSetProp(pstRegion, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRegion->bgColor));
1574 MSG_DEBUG(" [Set Attribute] : Width");
1576 if (true == pstSmilRegion->width.bUnitPercent) {
1577 if (pstSmilRegion->width.value > 0) {
1578 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->width.value);
1579 xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
1580 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width = %d \n", pstSmilRegion->width.value);
1583 // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
1584 // Validation should be done before this.
1585 if (pstSmilRegion->width.value >= 0 &&
1586 pstSmilRegion->width.value <= nRootWidth) {
1587 int iWidth = (pstSmilRegion->width.value * 100) / nRootWidth;
1589 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iWidth);
1590 xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
1591 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width= %d iWidth = %d \n", pstSmilRegion->width.value, iWidth);
1594 MSG_DEBUG(" [Set Attribute] : Height");
1595 if (true == pstSmilRegion->height.bUnitPercent) {
1596 if (pstSmilRegion->height.value > 0) {
1597 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->height.value);
1598 xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
1599 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d \n", pstSmilRegion->height.value);
1602 // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
1603 // Validation should be done before this.
1604 if (pstSmilRegion->height.value >= 0 &&
1605 pstSmilRegion->height.value <= nRootHeight) {
1606 int iHeight = (pstSmilRegion->height.value * 100) / nRootHeight;
1608 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iHeight);
1609 xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
1610 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d iHeight = %d \n", pstSmilRegion->height.value, iHeight);
1613 MSG_DEBUG(" [Set Attribute] : Left");
1614 if (true == pstSmilRegion->nLeft.bUnitPercent) {
1615 if (pstSmilRegion->nLeft.value > 0) {
1616 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nLeft.value);
1617 xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
1618 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->left = %d \n", pstSmilRegion->nLeft.value);
1621 // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
1622 // Validation should be done before this.
1623 if (pstSmilRegion->nLeft.value >= 0) {
1624 int iLeft = (pstSmilRegion->nLeft.value * 100) / nRootWidth;
1626 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iLeft);
1627 xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
1628 MSG_DEBUG("MmsSmilAddRegion: SmilRegion->iLeft = %d iLeft = %d \n", pstSmilRegion->nLeft.value, iLeft);
1631 MSG_DEBUG(" [Set Attribute] : Top");
1632 if (true == pstSmilRegion->nTop.bUnitPercent) {
1633 if (pstSmilRegion->nTop.value > 0) {
1634 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nTop.value);
1635 xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
1636 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d \n", pstSmilRegion->nTop.value);
1639 // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
1640 // Validation should be done before this.
1641 if (pstSmilRegion->nTop.value >= 0) {
1642 int iTop = (pstSmilRegion->nTop.value * 100) / nRootHeight;
1644 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iTop);
1645 xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
1646 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d iTop = %d \n", pstSmilRegion->nTop.value, iTop);
1649 MSG_DEBUG(" [Set Attribute] : Fit");
1651 if (MMSUI_IMAGE_REGION_FIT_MEET == pstSmilRegion->fit) {
1652 xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"meet");
1653 } else if (MMSUI_IMAGE_REGION_FIT_HIDDEN == pstSmilRegion->fit) {
1654 xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"hidden");
1657 MSG_DEBUG("There is no attribute in <region> node\n");
1659 __MmsSmilInsertNode(pstLayoutList, pstRootLayoutList, pstRegion);
1664 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
1669 /** @fn static bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1670 * @brief Add Media to Smil Doc. \n
1671 * @param[in] hSmilDoc is smil doc number. \n
1672 * @param[in] nPageNo specifies page number to which media belongs. \n
1673 * @param[in] pstSmilMedia specifies Media information. \n
1674 * @param[in] pszContentID specifies Content ID of media. \n
1675 * @retval TRUE In case of Success. \n
1676 * @retval FALSE In case of failure. \n
1678 bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1680 int nSmilDocNo = hSmilDoc;
1684 if (NULL == pszContentID) {
1685 MSG_DEBUG(" Content Id is NULL");
1688 memset(pszContentID, 0, MMS_CONTENT_ID_LEN + 1);
1689 if (IsValidSmilDocNo(nSmilDocNo)) {
1692 xmlNode *pstLastChild;
1693 xmlNodePtr pstParList;
1696 pstParList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"par");
1697 if (NULL == pstParList) {
1698 MSG_DEBUG("There is no <par> node. Can't create <media> node.");
1701 MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
1702 for (nIndex = 0; (pstParList && nIndex < nPageNo); nIndex++) {
1703 pstParList = pstParList->next;
1705 if (NULL == pstParList) {
1706 MSG_DEBUG("There is no such page node. Can't insert <media> node.");
1709 MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
1710 /* Find insertion point and make a contentID */
1712 pstLastChild = xmlGetLastChild(pstParList);
1714 pszExt = strrchr(pstSmilMedia->szFileName, '.');
1715 if (pszExt && !strrchr(pszExt, '/'))
1716 snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu%s", (ULONG)nPageNo, (ULONG)nMediaIdx, pszExt);
1718 snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu", (ULONG)nPageNo, (ULONG)nMediaIdx);
1720 /* Create <media> node and insert set attribute */
1721 MSG_DEBUG(" Create Media Node");
1722 switch (pstSmilMedia->mediatype) {
1723 case MMS_SMIL_MEDIA_TEXT:
1724 pstMedia = __MmsCreateTextNode(pstSmilMedia, pszContentID);
1726 case MMS_SMIL_MEDIA_AUDIO:
1727 case MMS_SMIL_MEDIA_VIDEO:
1728 case MMS_SMIL_MEDIA_IMG:
1729 pstMedia = __MmsCreateMMNode(pstSmilMedia, pszContentID);
1732 MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
1736 if (NULL == pstMedia) {
1737 MSG_DEBUG("Can't create <media> node. (from XmlParser) (media-type:%d)", pstSmilMedia->mediatype);
1741 /* Find the insertion point : the last child of <par> node */
1743 __MmsSmilInsertNode(pstParList, pstLastChild, pstMedia);
1745 __MmsInsertFirstChild(pstParList, pstMedia);
1750 MSG_DEBUG("MmsSmilAddMedia: Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
1755 /** @fn static xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1756 * @brief Create Text Element. \n
1757 * @param[in] pstSmilMedia specifies Media information. \n
1758 * @param[in] pszContentID specifies Content ID of media. \n
1759 * @retval Text Element node In case of Success. \n
1760 * @retval NULL In case of failure. \n
1762 xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1764 xmlNode *pstMedia = NULL;
1765 xmlNode *pstParam = NULL;
1766 char szBuf[MSG_STDSTR_SHORT] = {0, };
1767 char szSizeBuf[MSG_STDSTR_SHORT] = {0, };
1771 pstMedia = xmlNewNode(NULL, (xmlChar *)"text");
1772 if (NULL == pstMedia) {
1773 MSG_DEBUG("Can't create <Text> node.");
1776 MSG_DEBUG("Text Element Name = %s ", (char *)pstMedia->name);
1778 /* Add attributes */
1780 MSG_DEBUG("[Set Attribute] Region Id ");
1781 if (strlen(pstSmilMedia->regionId) > 0) {
1782 xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
1784 MSG_DEBUG("[Set Attribute] Begin ");
1785 if (pstSmilMedia->sMedia.sText.nBegin > 0) {
1786 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nBegin);
1787 xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *) szBuf);
1789 MSG_DEBUG("[Set Attribute] Duration");
1790 if (pstSmilMedia->sMedia.sText.nDurTime > 0) {
1791 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nDurTime);
1792 xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1794 MSG_DEBUG("[Set Attribute] Alternate");
1795 if (strlen(pstSmilMedia->szAlt) > 0) {
1796 snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
1797 xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
1799 MSG_DEBUG("[Set Attribute] Src");
1801 char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5]; // for "cid:"
1803 snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
1804 _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
1806 MSG_DEBUG("[Set Attribute] Font Foreground Color");
1808 if (pstSmilMedia->sMedia.sText.nColor!= SP_BLACK) { // Chnage after getting exact values
1809 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1811 if (NULL == pstParam) {
1812 MSG_DEBUG("Cannot create <param> node");
1815 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"foreground-color");
1816 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nColor));
1817 __MmsInsertFirstChild(pstMedia, pstParam);
1820 MSG_DEBUG("[Set Attribute] Font Background Color");
1822 if (pstSmilMedia->sMedia.sText.nBgColor != 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 *)"background-color");
1830 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nBgColor));
1831 __MmsInsertFirstChild(pstMedia, pstParam);
1834 MSG_DEBUG("[Set Attribute] Size");
1835 if (pstSmilMedia->sMedia.sText.nSize > 0) {
1836 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1837 if (NULL == pstParam) {
1838 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1842 if (pstSmilMedia->sMedia.sText.nSize <= MMS_SMIL_FONT_SIZE_SMALL)
1843 strcpy(szSizeBuf, "small");
1844 else if ((pstSmilMedia->sMedia.sText.nSize > MMS_SMIL_FONT_SIZE_SMALL) && (pstSmilMedia->sMedia.sText.nSize < MMS_SMIL_FONT_SIZE_LARGE))
1845 strcpy(szSizeBuf, "normal");
1847 strcpy(szSizeBuf, "large");
1849 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textsize");
1850 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1851 __MmsInsertFirstChild(pstMedia, pstParam);
1854 if (pstSmilMedia->sMedia.sText.bBold == true) {
1855 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1856 if (NULL == pstParam) {
1857 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1861 strcpy(szSizeBuf, "bold");
1863 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1864 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1865 __MmsInsertFirstChild(pstMedia, pstParam);
1868 if (pstSmilMedia->sMedia.sText.bItalic == true) {
1869 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1870 if (NULL == pstParam) {
1871 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1875 strcpy(szSizeBuf, "italic");
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.bUnderLine == true) {
1883 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1884 if (NULL == pstParam) {
1885 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1889 strcpy(szSizeBuf, "underline");
1891 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1892 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1893 __MmsInsertFirstChild(pstMedia, pstParam);
1901 /** @fn static xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1902 * @brief Create Image/Audio/Video Element. \n
1903 * @param[in] pstSmilMedia specifies Media information. \n
1904 * @param[in] pszContentID specifies Content ID of media. \n
1905 * @retval Image/Audio/Video Element node In case of Success. \n
1906 * @retval NULL In case of failure. \n
1908 xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1910 xmlNode *pstMedia = NULL;
1911 char szBuf[MSG_STDSTR_SHORT] = {0, };
1918 switch (pstSmilMedia->mediatype) {
1919 case MMS_SMIL_MEDIA_AUDIO:
1920 pstMedia = xmlNewNode(NULL, (xmlChar *)"audio");
1923 case MMS_SMIL_MEDIA_VIDEO:
1924 pstMedia = xmlNewNode(NULL, (xmlChar *)"video");
1927 case MMS_SMIL_MEDIA_IMG:
1928 pstMedia = xmlNewNode(NULL, (xmlChar *)"img");
1932 MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
1937 char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5]; // for "cid:"
1939 MSG_DEBUG("[Set Attribute] Region Id ");
1940 if (strlen(pstSmilMedia->regionId) > 0) {
1941 xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
1943 MSG_DEBUG("[Set Attribute] Src ");
1944 snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
1945 _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
1947 MSG_DEBUG("[Set Attribute] Begin ");
1948 if (pstSmilMedia->sMedia.sAVI.nBegin > 0) {
1949 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nBegin);
1950 xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *)szBuf);
1952 MSG_DEBUG("[Set Attribute] Duration ");
1953 if (pstSmilMedia->sMedia.sAVI.nDurTime > 0) {
1954 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nDurTime);
1955 xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1957 MSG_DEBUG("[Set Attribute] Alt ");
1958 if (strlen(pstSmilMedia->szAlt) > 0) {
1959 snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
1960 xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
1963 MSG_DEBUG("There is no attribute in such-<media> node");
1970 /** @fn static bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
1971 * @brief Inserts first child to parent node. \n
1972 * @param[in] pstParent specifies Parent node. \n
1973 * @param[in] pstCurr specifies Child node. \n
1974 * @retval TRUE In case of Success. \n
1975 * @retval FALSE In case of failure. \n
1977 bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
1983 if (NULL == xmlAddChild(pstParent, pstCurr)) {
1984 MSG_DEBUG("%s Node not added", pstCurr->name);
1993 /** @fn static bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
1994 * @brief Inserts node. \n
1995 * @param[in] pstParent specifies Parent node. \n
1996 * @param[in] pstLeftSibling specifies Left Sibling node. \n
1997 * @param[in] pstCurr specifies Child node. \n
1998 * @retval TRUE In case of Success. \n
1999 * @retval FALSE In case of failure. \n
2001 bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
2006 if (pstLeftSibling) {
2007 /* Parent Node is Unused */
2009 while (pstLeftSibling->next !=NULL)
2010 pstLeftSibling = pstLeftSibling->next;
2012 if (NULL == xmlAddNextSibling(pstLeftSibling, pstCurr)) {
2013 MSG_DEBUG("%s Node not added", pstCurr->name);
2017 if (NULL == xmlAddChild(pstParent, pstCurr)) {
2018 MSG_DEBUG("%s Node not added", pstCurr->name);
2027 bool __MmsGetRealFileName(MmsSmilMediaType mediaType, char *pszSrc, char *pszName, int msgID)
2033 MSG_DEBUG("__MmsUiGetRealFileName: mediaType[%d]", mediaType);
2034 MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
2037 MSG_DEBUG("__MmsUiGetRealFileName: pszName is null\n");
2041 if (mediaType == MMS_SMIL_MEDIA_TEXT || mediaType == MMS_SMIL_MEDIA_INVALID) {
2042 MSG_DEBUG("__MmsUiGetRealFileName: invalid mediaType(=%d)\n", mediaType);
2046 partCnt = MmsGetMediaPartCount(msgID);
2049 MSG_DEBUG("__MmsUiGetRealFileName: partCnt < 0, (=%d)\n", partCnt);
2053 for (i = 0; i < partCnt; i++) {
2054 MmsGetMediaPartHeader(i, &partHeader);
2056 if (mediaType == MMS_SMIL_MEDIA_AUDIO ||
2057 mediaType == MMS_SMIL_MEDIA_VIDEO ||
2058 mediaType == MMS_SMIL_MEDIA_IMG) {
2059 if (!strcmp(partHeader.param.szFileName , pszSrc)) {
2061 MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
2070 if (partHeader.param.szName[0] != '\0') {
2071 int nameLen = strlen(partHeader.param.szName);
2073 if (nameLen > MSG_FILENAME_LEN_MAX - 1) {
2076 strcpy(pszName, partHeader.param.szName);
2084 /** @fn static void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
2085 * @brief Sets Attribute. \n
2086 * @param[in] pNode specifies node. \n
2087 * @param[in] szField specifies attribute field. \n
2088 * @param[in] szValue specifies value of field \n
2090 void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
2094 if (pNode && szField && strlen(szField)) {
2095 if (szValue && strlen(szValue)) {
2096 xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)szValue);
2098 xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)"");
2105 /** @fn static char *__MmsSmilFindColorValue(int nValue)
2106 * @brief Converts color to RGB. \n
2107 * @param[in] nValue specifies color value. \n
2108 * @retval RGB value. \n
2110 char *__MmsSmilFindColorValue(int nValue)
2112 unsigned char red = (nValue & 0xFF0000) >> 16;
2113 unsigned char green = (nValue & 0x00FF00) >> 8;
2114 unsigned char blue = nValue & 0x0000FF;
2118 snprintf(gszColor,MMS_SMIL_COLOR_SIZE, "#%02x%02x%02x", red, green, blue);
2119 MSG_DEBUG("__MmsSmilFindColorValue: gszColor %s \n", gszColor);
2125 /** @fn static xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszValue)
2126 * @brief Get node based on pszValue. \n
2127 * @param[in] pNode specifies node. \n
2128 * @param[in] pszName specifies name field. \n
2129 * @retval RGB value. \n
2131 xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName)
2135 if ((NULL != pstNode) && (NULL != pszName)) {
2136 xmlNodePtr pstTempNode;
2137 xmlNodePtr pstReturnNode;
2139 pstTempNode = pstNode;
2141 for ( ; pstTempNode; pstTempNode = pstTempNode->next) {
2142 MSG_DEBUG("\n Node Name = %s[%p] children =%p \n", (char *)pstTempNode->name, pstTempNode, pstTempNode->children);
2143 MSG_DEBUG("\n Compare Parent Node = %s[%p] \n", (char *)pstTempNode->name, pstTempNode);
2144 if (0 == strcasecmp((char *)pstTempNode->name, pszName)) {
2148 if (pstTempNode->children) {
2149 MSG_DEBUG("\n Enter Inside\n");
2150 pstReturnNode = UtilxmlStringGetNodeList(pstTempNode->children, pszName);
2151 if (NULL != pstReturnNode) {
2152 return pstReturnNode;