2 * Copyright 2012-2013 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://floralicense.org
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.
22 #include "MsgMmsMessage.h"
23 #include "MsgUtilFile.h"
24 #include "MmsPluginTypes.h"
25 #include "MmsPluginSmil.h"
26 #include "MmsPluginMIME.h"
27 #include "MmsPluginStorage.h"
28 #include "MmsPluginDebug.h"
29 #include "MmsPluginCodec.h"
31 #define MSG_STDSTR_SHORT 0x7F
33 /* static variables */
34 static char gszEmptyRawDoc[] = "<smil><head><layout></layout></head><body></body></smil>";
35 static MmsSmilDoc *__gpaMmsSmilDoc[MMS_SMIL_MAX_DOC]={NULL, };
36 static char gszColor[MMS_SMIL_COLOR_SIZE] = {0, };
39 char *MmsSmilGetPresentationData(msg_message_id_t msgId)
43 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
46 MSG_DEBUG("pMsg is NULL");
50 if (msgId != pMsg->msgID) {
51 MSG_DEBUG("Invalid Message Id");
55 if (!pMsg->msgBody.pPresentationBody)
58 if (!pMsg->msgBody.pPresentationBody->body.pText)
61 return pMsg->msgBody.pPresentationBody->body.pText;
67 bool MmsSmilParseSmilDoc(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc)
71 MSG_DEBUG("%s", pSmilDoc);
72 doc = xmlParseMemory(pSmilDoc, strlen(pSmilDoc));
75 MSG_DEBUG("Document not parsed successfully. \n");
79 cur = xmlDocGetRootElement(doc);
82 MSG_DEBUG("empty document\n");
87 if (xmlStrcmp(cur->name, (const xmlChar *) "smil")) {
88 MSG_DEBUG("document of the wrong type, root node != smil");
93 MmsSmilGetElement(pMmsMsg, cur);
100 void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node)
106 MMS_SMIL_ROOTLAYOUT rootlayout = {};
107 static bool cmd[ELEMENT_MAX] = {false, };
108 static MMS_SMIL_REGION *pRegion;
109 static MMS_PAGE_S *pPage;
110 static MMS_MEDIA_S *pMedia;
111 static MMS_SMIL_TRANSITION *pTransition;
112 static MMS_SMIL_META *pMeta;
114 xmlNode *cur_node = NULL;
116 for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
117 MSG_DEBUG("******* node, name: %s ***\n", cur_node->name);
119 if (cur_node->type == XML_ELEMENT_NODE) {
120 // Get Smil Element =====================================================
121 MSG_DEBUG("*** node type: Element, name: %s ***\n", cur_node->name);
123 switch (elementType = MmsSmilGetElementID((char *)cur_node->name)) {
124 case ELEMENT_ROOTLAYOUT:
125 memset(cmd, 0, ELEMENT_MAX);
126 cmd[ELEMENT_ROOTLAYOUT] = true;
130 pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1);
131 memset(cmd, 0, ELEMENT_MAX);
132 cmd[ELEMENT_REGION] = true;
135 case ELEMENT_TRANSITION:
136 pTransition = (MMS_SMIL_TRANSITION *)calloc(sizeof(MMS_SMIL_TRANSITION), 1);
137 memset(cmd, 0, ELEMENT_MAX);
138 cmd[ELEMENT_TRANSITION] = true;
142 pMeta = (MMS_SMIL_META *)calloc(sizeof(MMS_SMIL_META), 1);
143 memset(cmd, 0, ELEMENT_MAX);
144 cmd[ELEMENT_META] = true;
148 pPage = (MMS_PAGE_S *)calloc(sizeof(MMS_PAGE_S), 1);
149 memset(cmd, 0, ELEMENT_MAX);
150 cmd[ELEMENT_PAR] = true;
153 case ELEMENT_PARAM: // Need to check the original element type
157 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
158 pMedia->mediatype = MMS_SMIL_MEDIA_TEXT;
159 memset(cmd, 0, ELEMENT_MAX);
160 cmd[ELEMENT_TEXT] = true;
164 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
165 pMedia->mediatype = MMS_SMIL_MEDIA_IMG;
166 memset(cmd, 0, ELEMENT_MAX);
167 cmd[ELEMENT_IMG] = true;
171 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
172 pMedia->mediatype = MMS_SMIL_MEDIA_AUDIO;
173 memset(cmd, 0, ELEMENT_MAX);
174 cmd[ELEMENT_AUDIO] = true;
178 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
179 pMedia->mediatype = MMS_SMIL_MEDIA_VIDEO;
180 memset(cmd, 0, ELEMENT_MAX);
181 cmd[ELEMENT_VIDEO] = true;
185 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
186 pMedia->mediatype = MMS_SMIL_MEDIA_IMG_OR_VIDEO;
187 memset(cmd, 0, ELEMENT_MAX);
188 cmd[ELEMENT_REF] = true;
191 case ELEMENT_ANIMATE:
192 pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
193 pMedia->mediatype = MMS_SMIL_MEDIA_ANIMATE;
194 memset(cmd, 0, ELEMENT_MAX);
195 cmd[ELEMENT_ANIMATE] = true;
199 memset(cmd, 0, ELEMENT_MAX);
203 //Get Smil Attribute =====================================================
204 xmlAttr *pAttr = cur_node->properties;
205 SMIL_ATTRIBUTE_T paramType = ATTRIBUTE_UNKNOWN;
207 for ( ; pAttr; pAttr = pAttr->next) {
208 MSG_DEBUG("AttributeType: (%s, %s) ", pAttr->name, pAttr->children->content);
209 switch (attrType = MmsSmilGetAttrID((char *)pAttr->name)) {
212 if (cmd[ELEMENT_REGION]) {
213 strncpy(pRegion->szID, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
214 } else if (cmd[ELEMENT_TRANSITION]) {
215 strncpy(pTransition->szID, (char *)pAttr->children->content, MAX_SMIL_TRANSITION_ID - 1);
216 } else if (cmd[ELEMENT_META]) {
217 strncpy(pMeta->szID, (char *)pAttr->children->content, MAX_SMIL_META_ID - 1);
227 if (strchr((char *)pAttr->children->content, '%'))
230 bUnitPercent = false;
232 value = atoi((char *)pAttr->children->content);
234 if (cmd[ELEMENT_REGION]) {
235 pRegion->nTop.bUnitPercent = bUnitPercent;
236 pRegion->nTop.value = value;
246 if (strchr((char *)pAttr->children->content, '%'))
249 bUnitPercent = false;
251 value = atoi((char *)pAttr->children->content);
253 if (cmd[ELEMENT_REGION]) {
254 pRegion->nLeft.bUnitPercent = bUnitPercent;
255 pRegion->nLeft.value = value;
261 case ATTRIBUTE_WIDTH:
266 if (strchr((char *)pAttr->children->content, '%'))
269 bUnitPercent = false;
271 value = atoi((char *)pAttr->children->content);
273 if (cmd[ELEMENT_ROOTLAYOUT]) {
274 rootlayout.width.bUnitPercent = bUnitPercent;
275 rootlayout.width.value = value;
276 } else if (cmd[ELEMENT_REGION]) {
277 pRegion->width.bUnitPercent = bUnitPercent;
278 pRegion->width.value = value;
283 case ATTRIBUTE_HEIGHT:
288 if (strchr((char *)pAttr->children->content, '%'))
291 bUnitPercent = false;
293 value = atoi((char *)pAttr->children->content);
295 if (cmd[ELEMENT_ROOTLAYOUT]) {
296 rootlayout.height.bUnitPercent = bUnitPercent;
297 rootlayout.height.value = value;
298 } else if (cmd[ELEMENT_REGION]) {
299 pRegion->height.bUnitPercent = bUnitPercent;
300 pRegion->height.value = value;
306 if (cmd[ELEMENT_REGION]) {
307 if (!strcmp((char *)pAttr->children->content, "meet")) {
308 pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET;
310 pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN;
315 case ATTRIBUTE_BGCOLOR:
316 if (cmd[ELEMENT_ROOTLAYOUT]) {
317 rootlayout.bBgColor = true;
318 rootlayout.bgColor = MmsSmilGetColorValue(pAttr->children->content);
319 } else if (cmd[ELEMENT_REGION]) {
320 pRegion->bBgColor = true;
321 pRegion->bgColor = MmsSmilGetColorValue(pAttr->children->content);
322 } else if (cmd[ELEMENT_TEXT])
323 pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
325 pMedia->sMedia.sAVI.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
330 if (cmd[ELEMENT_PAR])
331 pPage->nDur = MmsSmilGetTime((char *)pAttr->children->content);
332 else if (cmd[ELEMENT_TRANSITION])
333 pTransition->nDur = MmsSmilGetTime((char *)pAttr->children->content);
334 else if (cmd[ELEMENT_TEXT])
335 pMedia->sMedia.sText.nDurTime = MmsSmilGetTime((char *)pAttr->children->content);
337 pMedia->sMedia.sAVI.nDurTime = MmsSmilGetTime((char *)pAttr->children->content);
339 #ifdef MMS_SMIL_ANIMATE
340 if (cmd[ELEMENT_ANIMATE])
341 pMedia->sMedia.sAVI.nDur = MmsSmilGetTime((char *)pAttr->children->content);
348 char szTmpSrc[MSG_FILEPATH_LEN_MAX] = {0,};
349 char szOutBuf[MSG_FILEPATH_LEN_MAX] = {0, };
352 MsgMultipart *pPart = NULL;
355 szSrc = MsgChangeHexString((char *)pAttr->children->content);
359 memcpy(pMedia->szSrc, szSrc, strlen(szSrc) + 1);
362 cLen = strlen(pMedia->szSrc);
363 if (!strncasecmp(pMedia->szSrc, "cid:", 4)) {
364 strncpy(szTmpSrc, pMedia->szSrc + 4, cLen - 4);
365 szTmpSrc[cLen - 4] = '\0';
367 strncpy(szTmpSrc, pMedia->szSrc, cLen);
368 szTmpSrc[cLen] = '\0';
371 MmsPluginStorage::instance()->getMmsMessage(&pMsg);
372 pPart = pMsg->msgBody.body.pMultipart;
373 #ifndef __SUPPORT_DRM__
374 ret = MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart);
376 ret = MmsSmilGetMediaSrcForNormalMsg(szOutBuf, szTmpSrc, pPart, pMedia);
378 if (ret >= 0 && strlen(szOutBuf) > 0) {
379 strcpy(pMedia->szSrc, szOutBuf);
380 MmsSmilGetMediaFilePath(pMedia, szTmpSrc, pMsg->msgID);
384 case ATTRIBUTE_COLOR:
385 if (cmd[ELEMENT_TEXT])
386 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
390 if (cmd[ELEMENT_TEXT])
391 pMedia->sMedia.sText.nSize = atoi((char *)pAttr->children->content);
395 if (cmd[ELEMENT_TEXT]) {
396 pMedia->sMedia.sText.bBold = MmsSmilGetFontAttrib((char *)pAttr->children->content);
400 case ATTRIBUTE_UNDERLINE:
401 if (cmd[ELEMENT_TEXT])
402 pMedia->sMedia.sText.bUnderLine = MmsSmilGetFontAttrib((char *)pAttr->children->content);
405 case ATTRIBUTE_ITALIC:
406 if (cmd[ELEMENT_TEXT])
407 pMedia->sMedia.sText.bItalic = MmsSmilGetFontAttrib((char *)pAttr->children->content);
410 case ATTRIBUTE_REVERSE:
411 if (cmd[ELEMENT_TEXT])
412 pMedia->sMedia.sText.bReverse = MmsSmilGetFontAttrib((char *)pAttr->children->content);
415 case ATTRIBUTE_DIRECTION:
416 if (cmd[ELEMENT_TEXT])
417 pMedia->sMedia.sText.nDirection = MmsSmilGetFontDirection((char *)pAttr->children->content);
419 case ATTRIBUTE_REGION:
420 strncpy(pMedia->regionId, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
423 case ATTRIBUTE_TRANSIN:
424 if (cmd[ELEMENT_TEXT])
425 strncpy(pMedia->sMedia.sText.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
427 strncpy(pMedia->sMedia.sAVI.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
430 case ATTRIBUTE_TRANSOUT:
431 if (cmd[ELEMENT_TEXT])
432 strncpy(pMedia->sMedia.sText.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
434 strncpy(pMedia->sMedia.sAVI.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
437 case ATTRIBUTE_BEGIN:
438 if (cmd[ELEMENT_TEXT])
439 pMedia->sMedia.sText.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
441 pMedia->sMedia.sAVI.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
445 if (cmd[ELEMENT_TEXT])
446 pMedia->sMedia.sText.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
448 pMedia->sMedia.sAVI.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
451 case ATTRIBUTE_REPEAT_COUNT:
452 if (cmd[ELEMENT_TEXT])
453 pMedia->sMedia.sText.nRepeat = atoi((char *)pAttr->children->content);
455 pMedia->sMedia.sAVI.nRepeat = atoi((char *)pAttr->children->content);
459 if (!strcmp((char *)pAttr->children->content, "foreground-color") || !strcmp((char *)pAttr->children->content, "foregroundcolor"))
460 paramType = ATTRIBUTE_FGCOLOR;
461 else if (!strcmp((char *)pAttr->children->content, "background-color") || !strcmp((char *)pAttr->children->content, "backgroundcolor"))
462 paramType = ATTRIBUTE_BGCOLOR;
463 else if (!strcmp((char *)pAttr->children->content, "textsize"))
464 paramType = ATTRIBUTE_SIZE;
465 else if (!strcmp((char *)pAttr->children->content, "textattribute"))
466 paramType = ATTRIBUTE_TEXTFORMAT;
468 if (cmd[ELEMENT_META])
469 strncpy(pMeta->szName, (char *)pAttr->children->content, MAX_SMIL_META_NAME - 1);
472 case ATTRIBUTE_VALUE:
473 if (paramType == ATTRIBUTE_SIZE && cmd[ELEMENT_TEXT])
474 pMedia->sMedia.sText.nSize = MmsSmilGetFontSizeValue((char *)pAttr->children->content);
475 else if (paramType == ATTRIBUTE_FGCOLOR && cmd[ELEMENT_TEXT])
476 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
477 else if (paramType == ATTRIBUTE_BGCOLOR && cmd[ELEMENT_TEXT])
478 pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
479 else if (paramType == ATTRIBUTE_TEXTFORMAT && cmd[ELEMENT_TEXT]) {
480 MmsSmilFontType fontType;
482 fontType = MmsSmilGetFontTypeValue((char *)pAttr->children->content);
484 if (fontType == MMS_SMIL_FONT_TYPE_BOLD)
485 pMedia->sMedia.sText.bBold = true;
487 pMedia->sMedia.sText.bBold = false;
489 if (fontType == MMS_SMIL_FONT_TYPE_ITALIC)
490 pMedia->sMedia.sText.bItalic = true;
492 pMedia->sMedia.sText.bItalic = false;
494 if (fontType == MMS_SMIL_FONT_TYPE_UNDERLINE)
495 pMedia->sMedia.sText.bUnderLine = true;
497 pMedia->sMedia.sText.bUnderLine = false;
502 strncpy(pMedia->szAlt, (char *)pAttr->children->content, MAX_SMIL_ALT_LEN - 1);
506 pTransition->nType = (MmsSmilTransType)atoi((char *)pAttr->children->content);
508 switch (pTransition->nType) {
509 case MMS_SMIL_TRANS_SLIDEWIPE:
510 pTransition->nSubType = MMS_SMIL_TRANS_SUB_FROM_LEFT;
512 case MMS_SMIL_TRANS_BARWIPE:
513 pTransition->nSubType = MMS_SMIL_TRANS_SUB_TOP_TO_BOTTOM;
515 case MMS_SMIL_TRANS_BARNDOORWIPE:
516 pTransition->nSubType = MMS_SMIL_TRANS_SUB_HORIZONTAL;
519 pTransition->nSubType = MMS_SMIL_TRANS_SUB_NONE;
525 case ATTRIBUTE_SUBTYPE:
526 pTransition->nSubType = (MmsSmilTransSubType)atoi((char *)pAttr->children->content);
529 case ATTRIBUTE_CONTENT:
530 strncpy(pMeta->szContent, (char *)pAttr->children->content, MAX_SMIL_META_CONTENT - 1);
532 #ifdef MMS_SMIL_ANIMATE
533 case ATTRIBUTE_ATTRIBUTE_NAME:
534 strcpy(pMedia->sMedia.sAVI.nAttributeName, (char *)pAttr->children->content);
537 case ATTRIBUTE_ATTRIBUTE_TYPE:
538 strcpy(pMedia->sMedia.sAVI.nAttributeType, (char *)pAttr->children->content);
541 case ATTRIBUTE_TARGET_ELEMENT:
542 strcpy(pMedia->sMedia.sAVI.nTargetElement, (char *)pAttr->children->content);
546 pMedia->sMedia.sAVI.nFrom = atoi((char *)pAttr->children->content);
550 pMedia->sMedia.sAVI.nTo = atoi((char *)pAttr->children->content);
554 pMedia->sMedia.sAVI.nBy = atoi((char *)pAttr->children->content);
557 case ATTRIBUTE_VALUES:
558 pMedia->sMedia.sAVI.nValues = atoi((char *)pAttr->children->content);
561 case ATTRIBUTE_CALCMODE:
562 strcpy(pMedia->sMedia.sAVI.nCalcMode, (char *)pAttr->children->content);
566 MSG_DEBUG("Undefined Attribute was found!!!!!");
570 if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_REGION]) {
571 // Insert a region to region list
572 _MsgMmsAddRegion(pMmsMsg, pRegion);
573 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_PAR]) {
574 //Insert a page to page list
575 _MsgMmsAddPage(pMmsMsg, pPage);
576 } else if (paramType == ATTRIBUTE_UNKNOWN && (cmd[ELEMENT_TEXT] ||cmd[ELEMENT_IMG] ||cmd[ELEMENT_AUDIO] ||cmd[ELEMENT_VIDEO] ||cmd[ELEMENT_ANIMATE])) {
577 //Insert a media to media list
578 _MsgMmsAddMedia(pPage, pMedia);
579 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_ROOTLAYOUT]) {
580 _MsgMmsSetRootLayout(pMmsMsg, &rootlayout);
581 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_TRANSITION]) {
582 //Insert a transition to transition list
583 _MsgMmsAddTransition(pMmsMsg, pTransition);
584 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_META]) {
585 //Insert a meta to meta list
586 _MsgMmsAddMeta(pMmsMsg, pMeta);
589 paramType = ATTRIBUTE_UNKNOWN;
592 MmsSmilGetElement(pMmsMsg, cur_node->children);
599 int MmsSmilGetColorValue(xmlChar *content)
603 if (content[0] == '#') // RGB value
604 color = MmsSmilAtoIHexa((char *)&content[1]);
605 else if (content[0] == '0' && (content[1] == 'x' || content[1] == 'X'))
606 color = MmsSmilAtoIHexa((char *)&content[2]);
608 MSG_DEBUG("Invalid Color Value");
615 int MmsSmilAtoIHexa(char *pInput)
622 char *pOutput = NULL;
624 MSG_DEBUG("__MmsSmilAtoIHexa() enter..\n");
626 len = strlen(pInput);
627 pOutput = (char *)malloc(len + 1);
629 if (pOutput == NULL) {
630 MSG_DEBUG("__MmsSmilAtoIHexa: Memory full \n");
634 memset(pOutput, 0, len + 1);
636 for (i = len - 1; i >= 0; i--) {
637 for (j = 0; j < (len - 1 - i); j++) {
713 res += (pOutput[i] * temp);
727 int MmsSmilGetTime(char *pValue)
735 if (pValue == NULL || pValue[0] == '\0')
738 len = strlen(pValue);
740 /* Default time unit -> millisecond */
741 if (strstr(pValue, "msec"))
744 if (strstr(pValue, "ms"))
747 pTemp = (char *)malloc(strlen(pValue) + 1);
750 MSG_DEBUG("__MmsSmilGetTime : malloc for <time> attribute is failed \n");
754 while (isdigit(pValue[i])) {
755 pTemp[i] = pValue[i];
760 /* Detect 's' and 'ms' here */
761 retVal = atoi(pTemp);
773 #ifndef __SUPPORT_DRM__
774 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart)
776 int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart *pPart, MMS_MEDIA_S *pMedia)
779 char szContentID[MSG_MSG_ID_LEN + 1] = {0, };
780 char szContentLI[MSG_MSG_ID_LEN + 1] = {0, };
784 MSG_DEBUG("szInBuf: %s", szInBuf);
785 while (pPart && pPart->pBody) {
786 if (pPart->type.szContentID[0]) {
787 cLen = strlen(pPart->type.szContentID);
789 if (pPart->type.szContentID[0] == '<' && pPart->type.szContentID[cLen - 1] == '>') {
790 strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
791 szContentID[cLen - 2] = '\0';
792 } else if (pPart->type.szContentID[0] == MSG_CH_QUOT && pPart->type.szContentID[cLen-1] == MSG_CH_QUOT) {
793 strncpy(szContentID, &pPart->type.szContentID[1], cLen - 2);
794 szContentID[cLen - 2] = '\0';
796 strncpy(szContentID, pPart->type.szContentID, cLen);
797 szContentID[cLen] = '\0';
800 szContentID[0] = '\0';
803 MSG_DEBUG("szContentID: %s", szContentID);
805 if (pPart->type.szContentLocation[0]) {
806 cLen = strlen(pPart->type.szContentLocation);
808 if (pPart->type.szContentLocation[0] == MSG_CH_QUOT &&
809 pPart->type.szContentLocation[cLen-1] == MSG_CH_QUOT) {
810 strncpy(szContentLI, &pPart->type.szContentLocation[1], cLen-2);
811 szContentLI[cLen-2] = '\0';
813 strncpy(szContentLI, pPart->type.szContentLocation, cLen);
814 szContentLI[cLen] = '\0';
817 szContentLI[0] = '\0';
820 MSG_DEBUG("szContentLocation: %s", szContentLI);
822 if (strcasecmp(szContentID, szInBuf) == 0) {
823 strcpy(szOutbuf, pPart->type.param.szFileName);
824 MSG_DEBUG("match with szContentID");
826 } else if (strcasecmp(szContentLI, szInBuf) == 0) {
827 strcpy(szOutbuf, pPart->type.param.szFileName);
828 MSG_DEBUG("match with szContentLocation");
830 } else if (strcasecmp(pPart->type.param.szName, szInBuf) == 0) {
831 strcpy(szOutbuf, pPart->type.param.szFileName);
832 MSG_DEBUG("match with Parameter Name");
837 pPart = pPart->pNext;
843 #ifdef __SUPPORT_DRM__
844 pMedia->drmType = pPart->type.drmInfo.drmType;
846 if (pPart->type.drmInfo.szDrm2FullPath != NULL) {
847 MSG_DEBUG("szDrm2FullPath: %s", pPart->type.drmInfo.szDrm2FullPath);
848 strncpy(pMedia->szDrm2FullPath, pPart->type.drmInfo.szDrm2FullPath, MSG_FILEPATH_LEN_MAX - 1);
855 int MmsSmilGetElementID(char *pString)
857 if (!strcmp(pString, "smil"))
859 else if (!strcmp(pString, "head"))
861 else if (!strcmp(pString, "layout"))
862 return ELEMENT_LAYOUT;
863 else if (!strcmp(pString, "root-layout"))
864 return ELEMENT_ROOTLAYOUT;
865 else if (!strcmp(pString, "region"))
866 return ELEMENT_REGION;
867 else if (!strcmp(pString, "body"))
869 else if (!strcmp(pString, "par"))
871 else if (!strcmp(pString, "param"))
872 return ELEMENT_PARAM;
873 else if (!strcmp(pString, "text"))
875 else if (!strcmp(pString, "img"))
877 else if (!strcmp(pString, "audio"))
878 return ELEMENT_AUDIO;
879 else if (!strcmp(pString, "video"))
880 return ELEMENT_VIDEO;
881 else if (!strcmp(pString, "ref"))
883 else if (!strcmp(pString, "animate"))
884 return ELEMENT_ANIMATE;
885 else if (!strcmp(pString, "root-layout"))
887 else if (!strcmp(pString, "transition"))
888 return ELEMENT_TRANSITION;
889 else if (!strcmp(pString, "meta"))
895 int MmsSmilGetAttrID(char *pString)
897 if (!strcmp(pString, "id"))
899 else if (!strcmp(pString, "top"))
900 return ATTRIBUTE_TOP;
901 else if (!strcmp(pString, "left"))
902 return ATTRIBUTE_LEFT;
903 else if (!strcmp(pString, "width"))
904 return ATTRIBUTE_WIDTH;
905 else if (!strcmp(pString, "height"))
906 return ATTRIBUTE_HEIGHT;
907 else if (!strcmp(pString, "fit"))
908 return ATTRIBUTE_FIT;
909 else if (!strcmp(pString, "backgroundColor") || !strcmp(pString, "background-color"))
910 return ATTRIBUTE_BGCOLOR;
911 else if (!strcmp(pString, "dur"))
912 return ATTRIBUTE_DUR;
913 else if (!strcmp(pString, "src"))
914 return ATTRIBUTE_SRC;
915 else if (!strcmp(pString, "color"))
916 return ATTRIBUTE_COLOR;
917 else if (!strcmp(pString, "bold"))
918 return ATTRIBUTE_BOLD;
919 else if (!strcmp(pString, "underline"))
920 return ATTRIBUTE_UNDERLINE;
921 else if (!strcmp(pString, "italic"))
922 return ATTRIBUTE_ITALIC;
923 else if (!strcmp(pString, "reverse"))
924 return ATTRIBUTE_REVERSE;
925 else if (!strcmp(pString, "direction"))
926 return ATTRIBUTE_DIRECTION;
927 else if (!strcmp(pString, "size"))
928 return ATTRIBUTE_SIZE;
929 else if (!strcmp(pString, "font"))
930 return ATTRIBUTE_FONT;
931 else if (!strcmp(pString, "region"))
932 return ATTRIBUTE_REGION;
933 else if (!strcmp(pString, "name"))
934 return ATTRIBUTE_NAME;
935 else if (!strcmp(pString, "value"))
936 return ATTRIBUTE_VALUE;
937 else if (!strcmp(pString, "alt"))
938 return ATTRIBUTE_ALT;
939 else if (!strcmp(pString, "type"))
940 return ATTRIBUTE_TYPE;
941 else if (!strcmp(pString, "subtype"))
942 return ATTRIBUTE_SUBTYPE;
943 else if (!strcmp(pString, "content"))
944 return ATTRIBUTE_CONTENT;
945 else if (!strcmp(pString, "transIn"))
946 return ATTRIBUTE_TRANSIN;
947 else if (!strcmp(pString, "transOut"))
948 return ATTRIBUTE_TRANSOUT;
949 else if (!strcmp(pString, "begin"))
950 return ATTRIBUTE_BEGIN;
951 else if (!strcmp(pString, "end"))
952 return ATTRIBUTE_END;
953 else if (!strcmp(pString, "repeatCount"))
954 return ATTRIBUTE_REPEAT_COUNT;
955 #ifdef MMS_SMIL_ANIMATE
956 else if (!strcmp(pString, "attributeName"))
957 return ATTRIBUTE_ATTRIBUTE_NAME;
958 else if (!strcmp(pString, "attributeType"))
959 return ATTRIBUTE_ATTRIBUTE_TYPE;
960 else if (!strcmp(pString, "targetElement"))
961 return ATTRIBUTE_TARGET_ELEMENT;
962 else if (!strcmp(pString, "from"))
963 return ATTRIBUTE_FROM;
964 else if (!strcmp(pString, "to"))
966 else if (!strcmp(pString, "by"))
968 else if (!strcmp(pString, "values"))
969 return ATTRIBUTE_VALUES;
970 else if (!strcmp(pString, "calcMode"))
971 return ATTRIBUTE_CALCMODE;
977 bool MmsSmilGetFontAttrib(char *pString)
979 if (!strcmp(pString, "true"))
985 MmsTextDirection MmsSmilGetFontDirection(char *pString)
987 MmsTextDirection direction = MMS_TEXT_DIRECTION_INVALID;
989 if (!strcmp(pString, "right"))
990 direction = MMS_TEXT_DIRECTION_RIGHT;
991 else if (!strcmp(pString, "down"))
992 direction = MMS_TEXT_DIRECTION_DOWN;
997 int MmsSmilGetFontSizeValue(char *pString)
999 MSG_DEBUG(" #### content = %s #### ", pString);
1000 if (!strcmp(pString, "small"))
1001 return MMS_SMIL_FONT_SIZE_SMALL;
1002 else if (!strcmp(pString, "normal"))
1003 return MMS_SMIL_FONT_SIZE_NORMAL;
1004 else if (!strcmp(pString, "large"))
1005 return MMS_SMIL_FONT_SIZE_LARGE;
1007 return atoi(pString);
1010 MmsSmilFontType MmsSmilGetFontTypeValue(char *pString)
1012 MSG_DEBUG(" #### content = %s #### ", pString);
1014 if (!strcmp(pString, "normal"))
1015 return MMS_SMIL_FONT_TYPE_NORMAL;
1016 else if (!strcmp(pString, "italic"))
1017 return MMS_SMIL_FONT_TYPE_ITALIC;
1018 else if (!strcmp(pString, "bold"))
1019 return MMS_SMIL_FONT_TYPE_BOLD;
1020 else if (!strcmp(pString, "underline"))
1021 return MMS_SMIL_FONT_TYPE_UNDERLINE;
1023 return MMS_SMIL_FONT_TYPE_NORMAL;
1026 bool MmsSmilGetMediaFilePath(MMS_MEDIA_S *pMedia, char *pszTemp, int msgID)
1029 MSG_DEBUG("pMedia is NULL");
1033 snprintf(pMedia->szFilePath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_DATA_PATH, pMedia->szSrc);
1034 MSG_DEBUG("pMedia's filePath: %s", pMedia->szFilePath);
1036 __MmsGetRealFileName(pMedia->mediatype, pMedia->szSrc, pMedia->szFileName, msgID);
1037 MSG_DEBUG("pMedia's fileName: %s", pMedia->szFileName);
1039 snprintf(pMedia->szContentID, MSG_MSG_ID_LEN+1, "%s", pszTemp);
1040 MSG_DEBUG("pMedia's ContentID: %s", pMedia->szContentID);
1046 /** @fn bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
1047 * @brief Forms Smil Buffer using pstMsgBody. \n
1048 * @param[in/out] pstMsgBody is Message handle. \n
1049 * @retval TRUE In case of Success. \n
1050 * @retval FALSE In case of failure. \n
1052 bool MMSGenerateSmilBuffer(MMS_MESSAGE_DATA_S *pstMsgBody)
1054 HMmsSmil hSmilDoc = INVALID_HOBJ;
1060 MMS_PAGE_S *pstPage;
1061 MMS_MEDIA_S *pstMedia;
1062 MMS_SMIL_REGION *pstRegion;
1067 hSmilDoc = MmsSmilCreateEmptySmilDoc();
1068 MSG_DEBUG("Smil Doc =%d",hSmilDoc);
1069 if (INVALID_HOBJ == hSmilDoc) {
1070 MSG_DEBUG("Invalid SmilDoc[%d]",hSmilDoc);
1073 // Add Root Layout to Smil Document
1074 if (false == MmsSmilAddRootLayout(hSmilDoc, &(pstMsgBody->rootlayout))) {
1075 MSG_DEBUG("MmsSmilAddRootLayout Failed");
1076 MmsSmilDestroyDoc(hSmilDoc);
1078 //Add Region list to Smil Document
1079 nRegionCount = pstMsgBody->regionCnt;
1080 MSG_DEBUG(" Region Count =%d",nRegionCount);
1081 for (nIndex = 0; nIndex < nRegionCount; nIndex++) {
1082 MSG_DEBUG("Calling _MsgMmsGetSmilRegion");
1083 pstRegion = _MsgMmsGetSmilRegion(pstMsgBody, nIndex);
1084 if (NULL == pstRegion) {
1085 MSG_DEBUG("pstRegion is NULL");
1086 MmsSmilDestroyDoc(hSmilDoc);
1089 MSG_DEBUG("Calling MmsSmilAddRegion");
1090 if (false == MmsSmilAddRegion(hSmilDoc, pstRegion)) {
1091 MSG_DEBUG("Adding Region to smil doc failed");
1092 MmsSmilDestroyDoc(hSmilDoc);
1096 // Add page list to Smil Document
1097 nTotalPageNum = pstMsgBody->pageCnt ;
1098 MSG_DEBUG(" Page Count =%d",nTotalPageNum);
1099 for (nIndex = 0; nIndex < nTotalPageNum; nIndex++) {
1100 MSG_DEBUG("Calling _MsgMmsGetPage");
1101 pstPage = _MsgMmsGetPage(pstMsgBody, nIndex);
1102 if (NULL == pstPage) {
1103 MSG_DEBUG("pstPage is NULL");
1104 MmsSmilDestroyDoc(hSmilDoc);
1107 // Add page to smil doc
1108 MSG_DEBUG("Calling MmsSmilAddPage");
1109 if (false == MmsSmilAddPage(hSmilDoc, pstPage)) {
1110 MSG_DEBUG("Adding page to smil doc failed");
1111 MmsSmilDestroyDoc(hSmilDoc);
1114 nTotalMediaNum = pstPage->mediaCnt;
1115 MSG_DEBUG(" Media Count =%d",nTotalMediaNum);
1116 for (nMediaIndex = 0; nMediaIndex < nTotalMediaNum; nMediaIndex++) {
1117 MSG_DEBUG("Calling _MsgMmsGetMedia");
1118 pstMedia = _MsgMmsGetMedia(pstPage, nMediaIndex);
1119 if (NULL == pstMedia) {
1120 MSG_DEBUG("pMedia is NULL");
1121 MmsSmilDestroyDoc(hSmilDoc);
1124 MSG_DEBUG("Calling MmsSmilAddMedia");
1125 if (false == MmsSmilAddMedia(hSmilDoc, nIndex, nMediaIndex, pstMedia, pstMedia->szContentID)) {
1126 MSG_DEBUG("MmsSmilAddMedia failed");
1127 MmsSmilDestroyDoc(hSmilDoc);
1132 MSG_DEBUG("MMSGenerateSmilBuffer: Start update template");
1133 pszRawData = MmsSmilGetRawData(hSmilDoc);
1134 if (NULL == pszRawData) {
1135 MSG_DEBUG("MMSGenerateSmilBuffer: MmsSmilGetRawData failed");
1136 MmsSmilDestroyDoc(hSmilDoc);
1140 char fullpath[MSG_FILEPATH_LEN_MAX] = {0,};
1141 snprintf(fullpath, MSG_FILEPATH_LEN_MAX, MSG_SMIL_FILE_PATH"%s", pstMsgBody->szSmilFilePath);
1143 if (MsgWriteSmilFile(fullpath, pszRawData, strlen(pszRawData) + 1) == false) {
1144 MSG_DEBUG("MMSGenerateSmilBuffer: MsgWriteSmilFile failed");
1145 xmlFree((xmlChar*)pszRawData);
1146 MmsSmilDestroyDoc(hSmilDoc);
1150 MSG_DEBUG("MMSGenerateSmilBuffer: complete update template\n");
1151 xmlFree((xmlChar*)pszRawData);
1152 MmsSmilDestroyDoc(hSmilDoc);
1157 /** @fn static HMmsSmil MmsSmilCreateEmptySmilDoc(void)
1158 * @brief Creates default Smil Doc based on input gszEmptyRawDoc. \n
1159 * @retval Returns Smil Document number. \n
1161 HMmsSmil MmsSmilCreateEmptySmilDoc(void)
1167 hMmsSmil = MmsSmilCreateSmilDoc(gszEmptyRawDoc);
1169 MSG_DEBUG("Create an empty smilDoc.(Handle = %d)", hMmsSmil);
1176 /** @fn static HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
1177 * @brief Creates Smil Doc based on input pszRawData. \n
1178 * @param[in] pszRawData is smil buffer. \n
1179 * @retval Returns Smil Document number. \n
1181 HMmsSmil MmsSmilCreateSmilDoc(char *pszRawData)
1184 xmlNodePtr stRootNode;
1188 // Destroy smil doc if present
1189 if (NULL != __gpaMmsSmilDoc[nSmilDocNo]) {
1190 MSG_DEBUG("Calling MmsSmilDestroyDoc");
1191 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1192 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1196 for (nSmilDocNo = 0; nSmilDocNo < MMS_SMIL_MAX_DOC; nSmilDocNo++) {
1197 if (NULL == __gpaMmsSmilDoc[nSmilDocNo])
1201 if (MMS_SMIL_MAX_DOC == nSmilDocNo) {
1202 MSG_DEBUG("SmilDoc table is full. Can't create.");
1203 return INVALID_HOBJ;
1205 __gpaMmsSmilDoc[nSmilDocNo] = (MmsSmilDoc*)malloc(sizeof(MmsSmilDoc));
1206 if (NULL == __gpaMmsSmilDoc[nSmilDocNo]) {
1207 MSG_DEBUG("Memory Allocation Failed.");
1208 return INVALID_HOBJ;
1210 memset(__gpaMmsSmilDoc[nSmilDocNo], 0, sizeof(MmsSmilDoc));
1212 __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc = xmlParseMemory(pszRawData, strlen(pszRawData));
1213 if (NULL == __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1214 MSG_DEBUG("Document not parsed successfully.");
1215 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1216 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1218 return INVALID_HOBJ;
1220 stRootNode = xmlDocGetRootElement(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
1221 if (NULL == stRootNode) {
1222 MSG_DEBUG("Empty document\n");
1223 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1224 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1226 return INVALID_HOBJ;
1228 if (xmlStrcmp(stRootNode->name, (const xmlChar *) "smil")) {
1229 MSG_DEBUG("Document of the wrong type, root node != smil");
1230 if (false == MmsSmilDestroyDoc(nSmilDocNo)) {
1231 MSG_DEBUG("MmsSmilDestroyDoc: Failed!");
1233 return INVALID_HOBJ;
1236 __gpaMmsSmilDoc[nSmilDocNo]->pstRootNode = stRootNode;
1239 return ((HMmsSmil)nSmilDocNo);
1242 /** @fn static bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
1243 * @brief Destroys Smil Doc. \n
1244 * @param[in] hSmilDoc is smil doc number. \n
1245 * @retval TRUE In case of Success. \n
1246 * @retval FALSE In case of failure. \n
1248 bool MmsSmilDestroyDoc(HMmsSmil hSmilDoc)
1250 int nSmilDocNo = (int)hSmilDoc;
1254 if (0 <= nSmilDocNo &&
1255 nSmilDocNo < MMS_SMIL_MAX_DOC &&
1256 __gpaMmsSmilDoc[nSmilDocNo]) {
1257 if (__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1258 xmlFreeDoc(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc);
1261 if (__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode) {
1264 free(__gpaMmsSmilDoc[nSmilDocNo]);
1265 __gpaMmsSmilDoc[nSmilDocNo] = NULL;
1267 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1275 /** @fn static bool IsValidSmilDocNo(int nSmilDocNo)
1276 * @brief Form Smil Doc. \n
1277 * @param[in] hSmilDoc is smil doc number. \n
1278 * @retval Returns Smil Buffer In case of success. \n
1279 * @retval Returns NULL In case of failure. \n
1281 bool IsValidSmilDocNo(int nSmilDocNo)
1283 bool bIsValidSmil = false;
1287 if (0 <= nSmilDocNo &&
1288 nSmilDocNo < MMS_SMIL_MAX_DOC &&
1289 __gpaMmsSmilDoc[nSmilDocNo] &&
1290 __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc) {
1291 bIsValidSmil = true;
1295 return bIsValidSmil;
1298 /** @fn static char MmsSmilGetRawData(HMmsSmil hSmilDoc)
1299 * @brief Form Smil Doc. \n
1300 * @param[in] hSmilDoc is smil doc number. \n
1301 * @retval Returns Smil Buffer In case of success. \n
1302 * @retval Returns NULL In case of failure. \n
1304 char *MmsSmilGetRawData(HMmsSmil hSmilDoc)
1306 int nSmilDocNo = (int)hSmilDoc;
1307 char *pszRawData = NULL;
1311 if (IsValidSmilDocNo(nSmilDocNo)) {
1312 xmlSaveFormatFileEnc("-", __gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, "UTF-8", 1);
1313 xmlDocDumpMemory(__gpaMmsSmilDoc[nSmilDocNo]->pSmilDoc, (xmlChar **)(&pszRawData) , NULL);
1314 if (NULL == pszRawData) {
1315 MSG_DEBUG("Invalid pSmilDoc (now wellformed document)");
1319 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1324 /** @fn static bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
1325 * @brief Add Page to Smil Doc. \n
1326 * @param[in] hSmilDoc is smil doc number. \n
1327 * @param[in] pstSmilPage specifies page information. \n
1328 * @retval TRUE In case of Success. \n
1329 * @retval FALSE In case of failure. \n
1331 bool MmsSmilAddPage(HMmsSmil hSmilDoc, MMS_PAGE_S *pstSmilPage)
1333 int nSmilDocNo = hSmilDoc;
1339 if (IsValidSmilDocNo(nSmilDocNo)) {
1340 xmlNodePtr pstParElement;
1341 xmlNodePtr pstBodyElement;
1342 xmlNodePtr pstParList;
1343 char szBuf[MSG_STDSTR_SHORT] = {0, };
1345 pstBodyElement = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"body");
1347 if (NULL == pstBodyElement) {
1348 MSG_DEBUG("There is no <body> node. Can't create <par> node.");
1351 MSG_DEBUG("Body Element Name = %s", (char *)pstBodyElement->name);
1352 /* Create "par" node and insert it */
1353 pstParElement = xmlNewNode(NULL, (xmlChar *)"par");
1355 if (NULL == pstParElement) {
1356 MSG_DEBUG("Can't create <par> node. (from XmlParser) \n");
1359 MSG_DEBUG("Par Element Name = %s", (char *)pstParElement->name);
1361 /* Add attributes to "par" */
1362 if (pstSmilPage->nDur > 0) {
1363 snprintf(szBuf, MSG_STDSTR_SHORT, "%dms", pstSmilPage->nDur);
1364 xmlSetProp(pstParElement, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1366 /* Find the insertion point : right sibling of the last <par> node or first child of <body> */
1368 pstParList = xmlGetLastChild(pstBodyElement);
1371 ret = __MmsSmilInsertNode(pstBodyElement, pstParList, pstParElement);
1373 ret = __MmsInsertFirstChild(pstBodyElement, pstParElement);
1376 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1383 /** @fn static bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
1384 * @brief Add Rootlayout to Smil Doc. \n
1385 * @param[in] hSmilDoc is smil doc number. \n
1386 * @param[in] pstSmilRootLayout specifies RootLayout information. \n
1387 * @retval TRUE In case of Success. \n
1388 * @retval FALSE In case of failure. \n
1390 bool MmsSmilAddRootLayout(HMmsSmil hSmilDoc, MMS_SMIL_ROOTLAYOUT *pstSmilRootLayout)
1392 int nSmilDocNo = hSmilDoc;
1393 xmlNodePtr pstRootLayout = NULL;
1394 xmlNodePtr pstLayoutList = NULL;
1395 xmlNodePtr pstRootLayoutList = NULL;
1396 char szBuf[MSG_STDSTR_SHORT] = {0, };
1400 if (IsValidSmilDocNo(nSmilDocNo)) {
1401 pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
1403 if (NULL == pstLayoutList) {
1404 MSG_DEBUG("There is no <layout> node. Can't create <root-layout> node.");
1407 MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
1409 pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
1411 if (NULL != pstRootLayoutList) {
1412 MSG_DEBUG("MmsSmilAddRootLayout: There is <root-layout> node already");
1413 MSG_DEBUG("Root Layout Element Name = %s type=%d\n", (char *)pstRootLayoutList->name);
1416 /* Create "root-layout" node and insert it */
1417 pstRootLayout = xmlNewNode(NULL, (xmlChar *)"root-layout");
1418 if (NULL == pstRootLayout) {
1419 MSG_DEBUG("Can't create <root-layout> node. (from XmlParser)");
1422 MSG_DEBUG("Root Layout Element Name = %s", (char *)pstRootLayout->name);
1424 if (pstSmilRootLayout->bBgColor == true) { // Replace value later
1425 xmlSetProp(pstRootLayout, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRootLayout->bgColor));
1428 MSG_DEBUG(" Set Width");
1429 if (true == pstSmilRootLayout->width.bUnitPercent) {
1430 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->width.value);
1431 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
1433 if (pstSmilRootLayout->width.value > 0) {
1434 snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->width.value);
1435 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)szBuf);
1437 xmlSetProp(pstRootLayout, (const xmlChar *)"width", (const xmlChar *)"100%");
1440 MSG_DEBUG(" Set Height");
1441 if (true == pstSmilRootLayout->height.bUnitPercent) {
1442 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRootLayout->height.value);
1443 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
1445 if (pstSmilRootLayout->height.value > 0) {
1446 snprintf(szBuf, MSG_STDSTR_SHORT, "%d", pstSmilRootLayout->height.value);
1447 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)szBuf);
1449 xmlSetProp(pstRootLayout, (const xmlChar *)"height", (const xmlChar *)"100%");
1452 __MmsInsertFirstChild(pstLayoutList, pstRootLayout);
1456 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)", nSmilDocNo);
1463 /** @fn static bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
1464 * @brief Add Region to Smil Doc. \n
1465 * @param[in] hSmilDoc is smil doc number. \n
1466 * @param[in] pstSmilRegion specifies Region information. \n
1467 * @retval TRUE In case of Success. \n
1468 * @retval FALSE In case of failure. \n
1470 bool MmsSmilAddRegion(HMmsSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
1472 int nSmilDocNo = hSmilDoc;
1476 if (IsValidSmilDocNo(nSmilDocNo)) {
1478 int nRootHeight = 0;
1479 xmlNodePtr pstRegion;
1480 xmlNodePtr pstLayoutList;
1481 xmlNodePtr pstRootLayoutList;
1482 xmlAttrPtr pAttribute;
1483 char szBuf[MSG_STDSTR_SHORT] = {0, };
1485 pstLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"layout");
1486 if (NULL == pstLayoutList) {
1487 MSG_DEBUG(" There is no <layout> node. Can't create <region> node");
1490 MSG_DEBUG("Layout Element Name = %s ", (char *)pstLayoutList->name);
1492 /* Find the insertion point : right sibling of the last root-layout node or first child of pLayout */
1493 pstRootLayoutList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"root-layout");
1495 if (NULL == pstRootLayoutList) {
1496 MSG_DEBUG("There is no <root-layout> node. Can't create <root-layout> node.");
1499 MSG_DEBUG("Root Layout Element Name = %s ", (char *)pstRootLayoutList->name);
1500 pAttribute = pstRootLayoutList->properties;
1503 if (NULL == pAttribute) {
1504 MSG_DEBUG("There is no Attribute in <root-layout> node.");
1508 xmlAttrPtr pstAttr = pAttribute;
1509 for ( ; pstAttr; pstAttr = pstAttr->next) {
1511 MSG_DEBUG("AttributeType: (%s, %s) ", pstAttr->name, pstAttr->children->content);
1512 switch (attrType = MmsSmilGetAttrID((char *)pstAttr->name)) {
1513 case ATTRIBUTE_WIDTH:
1517 if (strchr((char *)pstAttr->children->content, '%'))
1518 bUnitPercent = true;
1520 bUnitPercent = false;
1522 nRootWidth = atoi((char *)pstAttr->children->content);
1526 case ATTRIBUTE_HEIGHT:
1530 if (strchr((char *)pstAttr->children->content, '%'))
1531 bUnitPercent = true;
1533 bUnitPercent = false;
1535 nRootHeight = atoi((char *)pstAttr->children->content);
1541 /* Create "region" node and insert it */
1542 MSG_DEBUG("Create Region Node");
1543 pstRegion = xmlNewNode(NULL, (xmlChar *)"region");
1544 if (NULL == pstRegion) {
1545 MSG_DEBUG("Can't create <region> node. (from XmlParser)");
1548 /* Add attributes */
1549 if (pstSmilRegion) {
1550 MSG_DEBUG(" [Set Attribute] : Region Id");
1551 if (strlen(pstSmilRegion->szID) > 0) {
1552 xmlSetProp(pstRegion, (const xmlChar *)"id", (const xmlChar *)pstSmilRegion->szID);
1555 if (pstSmilRegion->bBgColor == true) {
1556 MSG_DEBUG(" [Set Attribute] : BkGrd Color");
1557 xmlSetProp(pstRegion, (const xmlChar *)"backgroundColor", (const xmlChar *)__MmsSmilFindColorValue(pstSmilRegion->bgColor));
1560 MSG_DEBUG(" [Set Attribute] : Width");
1562 if (true == pstSmilRegion->width.bUnitPercent) {
1563 if (pstSmilRegion->width.value > 0) {
1564 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->width.value);
1565 xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
1566 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width = %d \n", pstSmilRegion->width.value);
1569 // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
1570 // Validation should be done before this.
1571 if (pstSmilRegion->width.value >= 0 &&
1572 pstSmilRegion->width.value <= nRootWidth) {
1573 int iWidth = (pstSmilRegion->width.value * 100) / nRootWidth;
1575 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iWidth);
1576 xmlSetProp(pstRegion, (const xmlChar *)"width", (const xmlChar *)szBuf);
1577 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->width= %d iWidth = %d \n", pstSmilRegion->width.value, iWidth);
1580 MSG_DEBUG(" [Set Attribute] : Height");
1581 if (true == pstSmilRegion->height.bUnitPercent) {
1582 if (pstSmilRegion->height.value > 0) {
1583 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->height.value);
1584 xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
1585 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d \n", pstSmilRegion->height.value);
1588 // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
1589 // Validation should be done before this.
1590 if (pstSmilRegion->height.value >= 0 &&
1591 pstSmilRegion->height.value <= nRootHeight) {
1592 int iHeight = (pstSmilRegion->height.value * 100) / nRootHeight;
1594 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iHeight);
1595 xmlSetProp(pstRegion, (const xmlChar *)"height", (const xmlChar *)szBuf);
1596 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->height = %d iHeight = %d \n", pstSmilRegion->height.value, iHeight);
1599 MSG_DEBUG(" [Set Attribute] : Left");
1600 if (true == pstSmilRegion->nLeft.bUnitPercent) {
1601 if (pstSmilRegion->nLeft.value > 0) {
1602 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nLeft.value);
1603 xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
1604 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->left = %d \n", pstSmilRegion->nLeft.value);
1607 // Note: nRootWidth should be in terms of value(pixel) not unitpercent(%)
1608 // Validation should be done before this.
1609 if (pstSmilRegion->nLeft.value >= 0) {
1610 int iLeft = (pstSmilRegion->nLeft.value * 100) / nRootWidth;
1612 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iLeft);
1613 xmlSetProp(pstRegion, (const xmlChar *)"left", (const xmlChar *)szBuf);
1614 MSG_DEBUG("MmsSmilAddRegion: SmilRegion->iLeft = %d iLeft = %d \n", pstSmilRegion->nLeft.value, iLeft);
1617 MSG_DEBUG(" [Set Attribute] : Top");
1618 if (true == pstSmilRegion->nTop.bUnitPercent) {
1619 if (pstSmilRegion->nTop.value > 0) {
1620 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", pstSmilRegion->nTop.value);
1621 xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
1622 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d \n", pstSmilRegion->nTop.value);
1625 // Note: nRootHeight should be in terms of value(pixel) not unitpercent(%)
1626 // Validation should be done before this.
1627 if (pstSmilRegion->nTop.value >= 0) {
1628 int iTop = (pstSmilRegion->nTop.value * 100) / nRootHeight;
1630 snprintf(szBuf, MSG_STDSTR_SHORT, "%d%%", iTop);
1631 xmlSetProp(pstRegion, (const xmlChar *)"top", (const xmlChar *)szBuf);
1632 MSG_DEBUG("MmsSmilAddRegion: pstSmilRegion->nTop= %d iTop = %d \n", pstSmilRegion->nTop.value, iTop);
1635 MSG_DEBUG(" [Set Attribute] : Fit");
1637 if (MMSUI_IMAGE_REGION_FIT_MEET == pstSmilRegion->fit) {
1638 xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"meet");
1639 } else if (MMSUI_IMAGE_REGION_FIT_HIDDEN == pstSmilRegion->fit) {
1640 xmlSetProp(pstRegion, (const xmlChar *)"fit", (const xmlChar *)"hidden");
1643 __MmsSmilInsertNode(pstLayoutList, pstRootLayoutList, pstRegion);
1646 MSG_DEBUG("There is no attribute in <region> node\n");
1651 MSG_DEBUG("Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
1656 /** @fn static bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1657 * @brief Add Media to Smil Doc. \n
1658 * @param[in] hSmilDoc is smil doc number. \n
1659 * @param[in] nPageNo specifies page number to which media belongs. \n
1660 * @param[in] pstSmilMedia specifies Media information. \n
1661 * @param[in] pszContentID specifies Content ID of media. \n
1662 * @retval TRUE In case of Success. \n
1663 * @retval FALSE In case of failure. \n
1665 bool MmsSmilAddMedia( HMmsSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1667 int nSmilDocNo = hSmilDoc;
1671 if (NULL == pszContentID) {
1672 MSG_DEBUG(" Content Id is NULL");
1675 memset(pszContentID, 0, MMS_CONTENT_ID_LEN + 1);
1676 if (IsValidSmilDocNo(nSmilDocNo)) {
1679 xmlNode *pstLastChild;
1680 xmlNodePtr pstParList;
1683 pstParList = UtilxmlStringGetNodeList(__gpaMmsSmilDoc[nSmilDocNo]->pstRootNode, (char *)"par");
1684 if (NULL == pstParList) {
1685 MSG_DEBUG("There is no <par> node. Can't create <media> node.");
1688 MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
1689 for (nIndex = 0; (pstParList && nIndex < nPageNo); nIndex++) {
1690 pstParList = pstParList->next;
1692 if (NULL == pstParList) {
1693 MSG_DEBUG("There is no such page node. Can't insert <media> node.");
1696 MSG_DEBUG("Par Element Name = %s ", (char *)pstParList->name);
1697 /* Find insertion point and make a contentID */
1699 pstLastChild = xmlGetLastChild(pstParList);
1701 pszExt = strrchr(pstSmilMedia->szFileName, '.');
1702 if (pszExt && !strrchr(pszExt, '/'))
1703 snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu%s", (ULONG)nPageNo, (ULONG)nMediaIdx, pszExt);
1705 snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu", (ULONG)nPageNo, (ULONG)nMediaIdx);
1707 /* Create <media> node and insert set attribute */
1708 MSG_DEBUG(" Create Media Node");
1709 switch (pstSmilMedia->mediatype) {
1710 case MMS_SMIL_MEDIA_TEXT:
1711 pstMedia = __MmsCreateTextNode(pstSmilMedia, pszContentID);
1713 case MMS_SMIL_MEDIA_AUDIO:
1714 case MMS_SMIL_MEDIA_VIDEO:
1715 case MMS_SMIL_MEDIA_IMG:
1716 pstMedia = __MmsCreateMMNode(pstSmilMedia, pszContentID);
1719 MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
1723 if (NULL == pstMedia) {
1724 MSG_DEBUG("Can't create <media> node. (from XmlParser) (media-type:%d)", pstSmilMedia->mediatype);
1728 /* Find the insertion point : the last child of <par> node */
1730 __MmsSmilInsertNode(pstParList, pstLastChild, pstMedia);
1732 __MmsInsertFirstChild(pstParList, pstMedia);
1737 MSG_DEBUG("MmsSmilAddMedia: Invalid SmilDoc(hSmilDoc:%d)\n", nSmilDocNo);
1742 /** @fn static xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1743 * @brief Create Text Element. \n
1744 * @param[in] pstSmilMedia specifies Media information. \n
1745 * @param[in] pszContentID specifies Content ID of media. \n
1746 * @retval Text Element node In case of Success. \n
1747 * @retval NULL In case of failure. \n
1749 xmlNode *__MmsCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1751 xmlNode *pstMedia = NULL;
1752 xmlNode *pstParam = NULL;
1753 char szBuf[MSG_STDSTR_SHORT] = {0, };
1754 char szSizeBuf[MSG_STDSTR_SHORT] = {0, };
1758 pstMedia = xmlNewNode(NULL, (xmlChar *)"text");
1759 if (NULL == pstMedia) {
1760 MSG_DEBUG("Can't create <Text> node.");
1763 MSG_DEBUG("Text Element Name = %s ", (char *)pstMedia->name);
1765 /* Add attributes */
1767 MSG_DEBUG("[Set Attribute] Region Id ");
1768 if (strlen(pstSmilMedia->regionId) > 0) {
1769 xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
1771 MSG_DEBUG("[Set Attribute] Begin ");
1772 if (pstSmilMedia->sMedia.sText.nBegin > 0) {
1773 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nBegin);
1774 xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *) szBuf);
1776 MSG_DEBUG("[Set Attribute] Duration");
1777 if (pstSmilMedia->sMedia.sText.nDurTime > 0) {
1778 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sText.nDurTime);
1779 xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1781 MSG_DEBUG("[Set Attribute] Alternate");
1782 if (strlen(pstSmilMedia->szAlt) > 0) {
1783 snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
1784 xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
1786 MSG_DEBUG("[Set Attribute] Src");
1788 char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5]; // for "cid:"
1790 snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
1791 _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
1793 MSG_DEBUG("[Set Attribute] Font Foreground Color");
1795 if (pstSmilMedia->sMedia.sText.nColor!= SP_BLACK) { // Chnage after getting exact values
1796 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1798 if (NULL == pstParam) {
1799 MSG_DEBUG("Cannot create <param> node");
1802 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"foreground-color");
1803 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nColor));
1804 __MmsInsertFirstChild(pstMedia, pstParam);
1807 MSG_DEBUG("[Set Attribute] Font Background Color");
1809 if (pstSmilMedia->sMedia.sText.nBgColor != SP_BLACK) { // Chnage after getting exact values
1810 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1812 if (NULL == pstParam) {
1813 MSG_DEBUG("Cannot create <param> node");
1816 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"background-color");
1817 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)__MmsSmilFindColorValue(pstSmilMedia->sMedia.sText.nBgColor));
1818 __MmsInsertFirstChild(pstMedia, pstParam);
1821 MSG_DEBUG("[Set Attribute] Size");
1822 if (pstSmilMedia->sMedia.sText.nSize > 0) {
1823 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1824 if (NULL == pstParam) {
1825 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1829 if (pstSmilMedia->sMedia.sText.nSize <= MMS_SMIL_FONT_SIZE_SMALL)
1830 strcpy(szSizeBuf, "small");
1831 else if ((pstSmilMedia->sMedia.sText.nSize > MMS_SMIL_FONT_SIZE_SMALL) && (pstSmilMedia->sMedia.sText.nSize < MMS_SMIL_FONT_SIZE_LARGE))
1832 strcpy(szSizeBuf, "normal");
1834 strcpy(szSizeBuf, "large");
1836 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textsize");
1837 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1838 __MmsInsertFirstChild(pstMedia, pstParam);
1841 if (pstSmilMedia->sMedia.sText.bBold == true) {
1842 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1843 if (NULL == pstParam) {
1844 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1848 strcpy(szSizeBuf, "bold");
1850 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1851 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1852 __MmsInsertFirstChild(pstMedia, pstParam);
1855 if (pstSmilMedia->sMedia.sText.bItalic == true) {
1856 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1857 if (NULL == pstParam) {
1858 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1862 strcpy(szSizeBuf, "italic");
1864 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1865 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1866 __MmsInsertFirstChild(pstMedia, pstParam);
1869 if (pstSmilMedia->sMedia.sText.bUnderLine == true) {
1870 pstParam = xmlNewNode(NULL, (xmlChar *)"param");
1871 if (NULL == pstParam) {
1872 MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node \n");
1876 strcpy(szSizeBuf, "underline");
1878 xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"textattribute");
1879 xmlSetProp(pstParam, (const xmlChar *)"value", (const xmlChar *)szSizeBuf);
1880 __MmsInsertFirstChild(pstMedia, pstParam);
1888 /** @fn static xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1889 * @brief Create Image/Audio/Video Element. \n
1890 * @param[in] pstSmilMedia specifies Media information. \n
1891 * @param[in] pszContentID specifies Content ID of media. \n
1892 * @retval Image/Audio/Video Element node In case of Success. \n
1893 * @retval NULL In case of failure. \n
1895 xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
1897 xmlNode *pstMedia = NULL;
1898 char szBuf[MSG_STDSTR_SHORT] = {0, };
1905 switch (pstSmilMedia->mediatype) {
1906 case MMS_SMIL_MEDIA_AUDIO:
1907 pstMedia = xmlNewNode(NULL, (xmlChar *)"audio");
1910 case MMS_SMIL_MEDIA_VIDEO:
1911 pstMedia = xmlNewNode(NULL, (xmlChar *)"video");
1914 case MMS_SMIL_MEDIA_IMG:
1915 pstMedia = xmlNewNode(NULL, (xmlChar *)"img");
1918 MSG_DEBUG("Invalid media type. Can't insert such-<media> node.");
1923 char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5]; // for "cid:"
1925 MSG_DEBUG("[Set Attribute] Region Id ");
1926 if (strlen(pstSmilMedia->regionId) > 0) {
1927 xmlSetProp(pstMedia, (const xmlChar *)"region", (const xmlChar *)pstSmilMedia->regionId);
1929 MSG_DEBUG("[Set Attribute] Src ");
1930 snprintf (szFilePathWithCid, sizeof(szFilePathWithCid), "cid:%s", pszContentID);
1931 _MmsSmilSetAttribute(pstMedia, (char *)"src", szFilePathWithCid);
1933 MSG_DEBUG("[Set Attribute] Begin ");
1934 if (pstSmilMedia->sMedia.sAVI.nBegin > 0) {
1935 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nBegin);
1936 xmlSetProp(pstMedia, (const xmlChar *)"begin", (const xmlChar *)szBuf);
1938 MSG_DEBUG("[Set Attribute] Duration ");
1939 if (pstSmilMedia->sMedia.sAVI.nDurTime > 0) {
1940 snprintf (szBuf, sizeof(szBuf), "%dms", pstSmilMedia->sMedia.sAVI.nDurTime);
1941 xmlSetProp(pstMedia, (const xmlChar *)"dur", (const xmlChar *)szBuf);
1943 MSG_DEBUG("[Set Attribute] Alt ");
1944 if (strlen(pstSmilMedia->szAlt) > 0) {
1945 snprintf (szBuf, sizeof(szBuf), "%s", pstSmilMedia->szAlt);
1946 xmlSetProp(pstMedia, (const xmlChar *)"alt", (const xmlChar *)szBuf);
1949 MSG_DEBUG("There is no attribute in such-<media> node");
1956 /** @fn static bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
1957 * @brief Inserts first child to parent node. \n
1958 * @param[in] pstParent specifies Parent node. \n
1959 * @param[in] pstCurr specifies Child node. \n
1960 * @retval TRUE In case of Success. \n
1961 * @retval FALSE In case of failure. \n
1963 bool __MmsInsertFirstChild(xmlNode *pstParent, xmlNode *pstCurr)
1969 if (NULL == xmlAddChild(pstParent, pstCurr)) {
1970 MSG_DEBUG("%s Node not added", pstCurr->name);
1979 /** @fn static bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
1980 * @brief Inserts node. \n
1981 * @param[in] pstParent specifies Parent node. \n
1982 * @param[in] pstLeftSibling specifies Left Sibling node. \n
1983 * @param[in] pstCurr specifies Child node. \n
1984 * @retval TRUE In case of Success. \n
1985 * @retval FALSE In case of failure. \n
1987 bool __MmsSmilInsertNode(xmlNode *pstParent, xmlNode *pstLeftSibling, xmlNode *pstCurr)
1992 if (pstLeftSibling) {
1993 /* Parent Node is Unused */
1995 while (pstLeftSibling->next !=NULL)
1996 pstLeftSibling = pstLeftSibling->next;
1998 if (NULL == xmlAddNextSibling(pstLeftSibling, pstCurr)) {
1999 MSG_DEBUG("%s Node not added", pstCurr->name);
2003 if (NULL == xmlAddChild(pstParent, pstCurr)) {
2004 MSG_DEBUG("%s Node not added", pstCurr->name);
2013 bool __MmsGetRealFileName(MmsSmilMediaType mediaType, char *pszSrc, char *pszName, int msgID)
2019 MSG_DEBUG("__MmsUiGetRealFileName: mediaType[%d]", mediaType);
2020 MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
2023 MSG_DEBUG("__MmsUiGetRealFileName: pszName is null\n");
2027 if (mediaType == MMS_SMIL_MEDIA_TEXT || mediaType == MMS_SMIL_MEDIA_INVALID) {
2028 MSG_DEBUG("__MmsUiGetRealFileName: invalid mediaType(=%d)\n", mediaType);
2032 partCnt = MmsGetMediaPartCount(msgID);
2035 MSG_DEBUG("__MmsUiGetRealFileName: partCnt < 0, (=%d)\n", partCnt);
2039 for (i = 0; i < partCnt; i++) {
2040 MmsGetMediaPartHeader(i, &partHeader);
2042 if (mediaType == MMS_SMIL_MEDIA_AUDIO ||
2043 mediaType == MMS_SMIL_MEDIA_VIDEO ||
2044 mediaType == MMS_SMIL_MEDIA_IMG) {
2045 if (!strcmp(partHeader.param.szFileName , pszSrc)) {
2047 MSG_DEBUG("__MmsUiGetRealFileName: pszSrc[%s]\n", pszSrc);
2056 if (partHeader.param.szName[0] != '\0') {
2057 int nameLen = strlen(partHeader.param.szName);
2059 if (nameLen > MSG_FILENAME_LEN_MAX - 1) {
2062 strcpy(pszName, partHeader.param.szName);
2070 /** @fn static void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
2071 * @brief Sets Attribute. \n
2072 * @param[in] pNode specifies node. \n
2073 * @param[in] szField specifies attribute field. \n
2074 * @param[in] szValue specifies value of field \n
2076 void _MmsSmilSetAttribute(xmlNode *pNode, char *szField, char *szValue)
2080 if (pNode && szField && strlen(szField)) {
2081 if (szValue && strlen(szValue)) {
2082 xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)szValue);
2084 xmlSetProp(pNode, (const xmlChar *)szField, (const xmlChar *)"");
2091 /** @fn static char *__MmsSmilFindColorValue(int nValue)
2092 * @brief Converts color to RGB. \n
2093 * @param[in] nValue specifies color value. \n
2094 * @retval RGB value. \n
2096 char *__MmsSmilFindColorValue(int nValue)
2098 unsigned char red = (nValue & 0xFF0000) >> 16;
2099 unsigned char green = (nValue & 0x00FF00) >> 8;
2100 unsigned char blue = nValue & 0x0000FF;
2104 snprintf(gszColor,MMS_SMIL_COLOR_SIZE, "#%02x%02x%02x", red, green, blue);
2105 MSG_DEBUG("__MmsSmilFindColorValue: gszColor %s \n", gszColor);
2111 /** @fn static xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszValue)
2112 * @brief Get node based on pszValue. \n
2113 * @param[in] pNode specifies node. \n
2114 * @param[in] pszName specifies name field. \n
2115 * @retval RGB value. \n
2117 xmlNodePtr UtilxmlStringGetNodeList(xmlNodePtr pstNode, char *pszName)
2121 if ((NULL != pstNode) && (NULL != pszName)) {
2122 xmlNodePtr pstTempNode;
2123 xmlNodePtr pstReturnNode;
2125 pstTempNode = pstNode;
2127 for ( ; pstTempNode; pstTempNode = pstTempNode->next) {
2128 MSG_DEBUG("\n Node Name = %s[%p] children =%p \n", (char *)pstTempNode->name, pstTempNode, pstTempNode->children);
2129 MSG_DEBUG("\n Compare Parent Node = %s[%p] \n", (char *)pstTempNode->name, pstTempNode);
2130 if (0 == strcasecmp((char *)pstTempNode->name, pszName)) {
2134 if (pstTempNode->children) {
2135 MSG_DEBUG("\n Enter Inside\n");
2136 pstReturnNode = UtilxmlStringGetNodeList(pstTempNode->children, pszName);
2137 if (NULL != pstReturnNode) {
2138 return pstReturnNode;
2147 void MmsSmilGetElementOnlyLayout(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node)
2153 MMS_SMIL_ROOTLAYOUT rootlayout = {};
2154 static bool cmd[ELEMENT_MAX] = {false, };
2155 static MMS_SMIL_REGION *pRegion;
2156 static MMS_PAGE_S *pPage;
2157 static MMS_MEDIA_S *pMedia;
2158 static MMS_SMIL_TRANSITION *pTransition;
2159 static MMS_SMIL_META *pMeta;
2161 xmlNode *cur_node = NULL;
2163 for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
2164 MSG_DEBUG("******* node, name: %s ***\n", cur_node->name);
2166 if (cur_node->type == XML_ELEMENT_NODE) {
2167 // Get Smil Element =====================================================
2168 MSG_DEBUG("*** node type: Element, name: %s ***\n", cur_node->name);
2170 switch (elementType = MmsSmilGetElementID((char *)cur_node->name)) {
2171 case ELEMENT_ROOTLAYOUT:
2172 memset(cmd, 0, ELEMENT_MAX);
2173 cmd[ELEMENT_ROOTLAYOUT] = true;
2176 case ELEMENT_REGION:
2177 pRegion = (MMS_SMIL_REGION *)calloc(1, sizeof(MMS_SMIL_REGION));
2178 memset(cmd, 0, ELEMENT_MAX);
2179 cmd[ELEMENT_REGION] = true;
2182 case ELEMENT_TRANSITION:
2183 pTransition = (MMS_SMIL_TRANSITION *)calloc(1, sizeof(MMS_SMIL_TRANSITION));
2184 memset(cmd, 0, ELEMENT_MAX);
2185 cmd[ELEMENT_TRANSITION] = true;
2189 pMeta = (MMS_SMIL_META *)calloc(1, sizeof(MMS_SMIL_META));
2190 memset(cmd, 0, ELEMENT_MAX);
2191 cmd[ELEMENT_META] = true;
2195 pPage = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S));
2196 memset(cmd, 0, ELEMENT_MAX);
2197 cmd[ELEMENT_PAR] = true;
2200 case ELEMENT_PARAM: // Need to check the original element type
2204 pMedia = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S));
2205 pMedia->mediatype = MMS_SMIL_MEDIA_TEXT;
2206 memset(cmd, 0, ELEMENT_MAX);
2207 cmd[ELEMENT_TEXT] = true;
2211 pMedia = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S));
2212 pMedia->mediatype = MMS_SMIL_MEDIA_IMG;
2213 memset(cmd, 0, ELEMENT_MAX);
2214 cmd[ELEMENT_IMG] = true;
2218 pMedia = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S));
2219 pMedia->mediatype = MMS_SMIL_MEDIA_AUDIO;
2220 memset(cmd, 0, ELEMENT_MAX);
2221 cmd[ELEMENT_AUDIO] = true;
2225 pMedia = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S));
2226 pMedia->mediatype = MMS_SMIL_MEDIA_VIDEO;
2227 memset(cmd, 0, ELEMENT_MAX);
2228 cmd[ELEMENT_VIDEO] = true;
2232 pMedia = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S));
2233 pMedia->mediatype = MMS_SMIL_MEDIA_IMG_OR_VIDEO;
2234 memset(cmd, 0, ELEMENT_MAX);
2235 cmd[ELEMENT_REF] = true;
2238 case ELEMENT_ANIMATE:
2239 pMedia = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S));
2240 pMedia->mediatype = MMS_SMIL_MEDIA_ANIMATE;
2241 memset(cmd, 0, ELEMENT_MAX);
2242 cmd[ELEMENT_ANIMATE] = true;
2246 memset(cmd, 0, ELEMENT_MAX);
2250 //Get Smil Attribute =====================================================
2251 xmlAttr *pAttr = cur_node->properties;
2252 SMIL_ATTRIBUTE_T paramType = ATTRIBUTE_UNKNOWN;
2254 for ( ; pAttr; pAttr = pAttr->next) {
2255 MSG_DEBUG("AttributeType: (%s, %s) ", pAttr->name, pAttr->children->content);
2256 switch (attrType = MmsSmilGetAttrID((char *)pAttr->name)) {
2259 if (cmd[ELEMENT_REGION]) {
2260 strncpy(pRegion->szID, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
2261 } else if (cmd[ELEMENT_TRANSITION]) {
2262 strncpy(pTransition->szID, (char *)pAttr->children->content, MAX_SMIL_TRANSITION_ID - 1);
2263 } else if (cmd[ELEMENT_META]) {
2264 strncpy(pMeta->szID, (char *)pAttr->children->content, MAX_SMIL_META_ID - 1);
2274 if (strchr((char *)pAttr->children->content, '%'))
2275 bUnitPercent = true;
2277 bUnitPercent = false;
2279 value = atoi((char *)pAttr->children->content);
2281 if (cmd[ELEMENT_REGION]) {
2282 pRegion->nTop.bUnitPercent = bUnitPercent;
2283 pRegion->nTop.value = value;
2288 case ATTRIBUTE_LEFT:
2293 if (strchr((char *)pAttr->children->content, '%'))
2294 bUnitPercent = true;
2296 bUnitPercent = false;
2298 value = atoi((char *)pAttr->children->content);
2300 if (cmd[ELEMENT_REGION]) {
2301 pRegion->nLeft.bUnitPercent = bUnitPercent;
2302 pRegion->nLeft.value = value;
2308 case ATTRIBUTE_WIDTH:
2313 if (strchr((char *)pAttr->children->content, '%'))
2314 bUnitPercent = true;
2316 bUnitPercent = false;
2318 value = atoi((char *)pAttr->children->content);
2320 if (cmd[ELEMENT_ROOTLAYOUT]) {
2321 rootlayout.width.bUnitPercent = bUnitPercent;
2322 rootlayout.width.value = value;
2323 } else if (cmd[ELEMENT_REGION]) {
2324 pRegion->width.bUnitPercent = bUnitPercent;
2325 pRegion->width.value = value;
2330 case ATTRIBUTE_HEIGHT:
2335 if (strchr((char *)pAttr->children->content, '%'))
2336 bUnitPercent = true;
2338 bUnitPercent = false;
2340 value = atoi((char *)pAttr->children->content);
2342 if (cmd[ELEMENT_ROOTLAYOUT]) {
2343 rootlayout.height.bUnitPercent = bUnitPercent;
2344 rootlayout.height.value = value;
2345 } else if (cmd[ELEMENT_REGION]) {
2346 pRegion->height.bUnitPercent = bUnitPercent;
2347 pRegion->height.value = value;
2353 if (cmd[ELEMENT_REGION]) {
2354 if (!strcmp((char *)pAttr->children->content, "meet")) {
2355 pRegion->fit = MMSUI_IMAGE_REGION_FIT_MEET;
2357 pRegion->fit = MMSUI_IMAGE_REGION_FIT_HIDDEN;
2362 case ATTRIBUTE_BGCOLOR:
2363 if (cmd[ELEMENT_ROOTLAYOUT]) {
2364 rootlayout.bBgColor = true;
2365 rootlayout.bgColor = MmsSmilGetColorValue(pAttr->children->content);
2366 } else if (cmd[ELEMENT_REGION]) {
2367 pRegion->bBgColor = true;
2368 pRegion->bgColor = MmsSmilGetColorValue(pAttr->children->content);
2369 } else if (cmd[ELEMENT_TEXT])
2370 pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
2372 pMedia->sMedia.sAVI.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
2377 if (cmd[ELEMENT_PAR])
2378 pPage->nDur = MmsSmilGetTime((char *)pAttr->children->content);
2379 else if (cmd[ELEMENT_TRANSITION])
2380 pTransition->nDur = MmsSmilGetTime((char *)pAttr->children->content);
2381 else if (cmd[ELEMENT_TEXT])
2382 pMedia->sMedia.sText.nDurTime = MmsSmilGetTime((char *)pAttr->children->content);
2384 pMedia->sMedia.sAVI.nDurTime = MmsSmilGetTime((char *)pAttr->children->content);
2386 #ifdef MMS_SMIL_ANIMATE
2387 if (cmd[ELEMENT_ANIMATE])
2388 pMedia->sMedia.sAVI.nDur = MmsSmilGetTime((char *)pAttr->children->content);
2395 char szContentID[MSG_MSG_ID_LEN + 1] = {0,};
2398 szSrc = MsgChangeHexString((char *)pAttr->children->content);
2402 snprintf(szContentID, sizeof(szContentID), "%s", szSrc);
2405 cLen = strlen(szContentID);
2406 if (!strncasecmp(szContentID, "cid:", 4)) {
2407 strncpy(pMedia->szContentID, szContentID + 4, cLen - 4);
2408 pMedia->szContentID[cLen - 4] = '\0';
2410 strncpy(pMedia->szContentID, szContentID, cLen);
2411 pMedia->szContentID[cLen] = '\0';
2415 case ATTRIBUTE_COLOR:
2416 if (cmd[ELEMENT_TEXT])
2417 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
2420 case ATTRIBUTE_SIZE:
2421 if (cmd[ELEMENT_TEXT])
2422 pMedia->sMedia.sText.nSize = atoi((char *)pAttr->children->content);
2425 case ATTRIBUTE_BOLD:
2426 if (cmd[ELEMENT_TEXT]) {
2427 pMedia->sMedia.sText.bBold = MmsSmilGetFontAttrib((char *)pAttr->children->content);
2431 case ATTRIBUTE_UNDERLINE:
2432 if (cmd[ELEMENT_TEXT])
2433 pMedia->sMedia.sText.bUnderLine = MmsSmilGetFontAttrib((char *)pAttr->children->content);
2436 case ATTRIBUTE_ITALIC:
2437 if (cmd[ELEMENT_TEXT])
2438 pMedia->sMedia.sText.bItalic = MmsSmilGetFontAttrib((char *)pAttr->children->content);
2441 case ATTRIBUTE_REVERSE:
2442 if (cmd[ELEMENT_TEXT])
2443 pMedia->sMedia.sText.bReverse = MmsSmilGetFontAttrib((char *)pAttr->children->content);
2446 case ATTRIBUTE_DIRECTION:
2447 if (cmd[ELEMENT_TEXT])
2448 pMedia->sMedia.sText.nDirection = MmsSmilGetFontDirection((char *)pAttr->children->content);
2450 case ATTRIBUTE_REGION:
2451 strncpy(pMedia->regionId, (char *)pAttr->children->content, MAX_SMIL_REGION_ID - 1);
2454 case ATTRIBUTE_TRANSIN:
2455 if (cmd[ELEMENT_TEXT])
2456 strncpy(pMedia->sMedia.sText.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
2458 strncpy(pMedia->sMedia.sAVI.szTransInId, (char *)pAttr->children->content, MAX_SMIL_TRANSIN_ID - 1);
2461 case ATTRIBUTE_TRANSOUT:
2462 if (cmd[ELEMENT_TEXT])
2463 strncpy(pMedia->sMedia.sText.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
2465 strncpy(pMedia->sMedia.sAVI.szTransOutId, (char *)pAttr->children->content, MAX_SMIL_TRANSOUT_ID - 1);
2468 case ATTRIBUTE_BEGIN:
2469 if (cmd[ELEMENT_TEXT])
2470 pMedia->sMedia.sText.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
2472 pMedia->sMedia.sAVI.nBegin = MmsSmilGetTime((char *)pAttr->children->content);
2476 if (cmd[ELEMENT_TEXT])
2477 pMedia->sMedia.sText.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
2479 pMedia->sMedia.sAVI.nEnd = MmsSmilGetTime((char *)pAttr->children->content);
2482 case ATTRIBUTE_REPEAT_COUNT:
2483 if (cmd[ELEMENT_TEXT])
2484 pMedia->sMedia.sText.nRepeat = atoi((char *)pAttr->children->content);
2486 pMedia->sMedia.sAVI.nRepeat = atoi((char *)pAttr->children->content);
2489 case ATTRIBUTE_NAME:
2490 if (!strcmp((char *)pAttr->children->content, "foreground-color") || !strcmp((char *)pAttr->children->content, "foregroundcolor"))
2491 paramType = ATTRIBUTE_FGCOLOR;
2492 else if (!strcmp((char *)pAttr->children->content, "background-color") || !strcmp((char *)pAttr->children->content, "backgroundcolor"))
2493 paramType = ATTRIBUTE_BGCOLOR;
2494 else if (!strcmp((char *)pAttr->children->content, "textsize"))
2495 paramType = ATTRIBUTE_SIZE;
2496 else if (!strcmp((char *)pAttr->children->content, "textattribute"))
2497 paramType = ATTRIBUTE_TEXTFORMAT;
2499 if (cmd[ELEMENT_META])
2500 strncpy(pMeta->szName, (char *)pAttr->children->content, MAX_SMIL_META_NAME - 1);
2503 case ATTRIBUTE_VALUE:
2504 if (paramType == ATTRIBUTE_SIZE && cmd[ELEMENT_TEXT])
2505 pMedia->sMedia.sText.nSize = MmsSmilGetFontSizeValue((char *)pAttr->children->content);
2506 else if (paramType == ATTRIBUTE_FGCOLOR && cmd[ELEMENT_TEXT])
2507 pMedia->sMedia.sText.nColor = MmsSmilGetColorValue(pAttr->children->content);
2508 else if (paramType == ATTRIBUTE_BGCOLOR && cmd[ELEMENT_TEXT])
2509 pMedia->sMedia.sText.nBgColor = MmsSmilGetColorValue(pAttr->children->content);
2510 else if (paramType == ATTRIBUTE_TEXTFORMAT && cmd[ELEMENT_TEXT]) {
2511 MmsSmilFontType fontType;
2513 fontType = MmsSmilGetFontTypeValue((char *)pAttr->children->content);
2515 if (fontType == MMS_SMIL_FONT_TYPE_BOLD)
2516 pMedia->sMedia.sText.bBold = true;
2518 pMedia->sMedia.sText.bBold = false;
2520 if (fontType == MMS_SMIL_FONT_TYPE_ITALIC)
2521 pMedia->sMedia.sText.bItalic = true;
2523 pMedia->sMedia.sText.bItalic = false;
2525 if (fontType == MMS_SMIL_FONT_TYPE_UNDERLINE)
2526 pMedia->sMedia.sText.bUnderLine = true;
2528 pMedia->sMedia.sText.bUnderLine = false;
2533 strncpy(pMedia->szAlt, (char *)pAttr->children->content, MAX_SMIL_ALT_LEN - 1);
2536 case ATTRIBUTE_TYPE:
2537 pTransition->nType = (MmsSmilTransType)atoi((char *)pAttr->children->content);
2539 switch (pTransition->nType) {
2540 case MMS_SMIL_TRANS_SLIDEWIPE:
2541 pTransition->nSubType = MMS_SMIL_TRANS_SUB_FROM_LEFT;
2543 case MMS_SMIL_TRANS_BARWIPE:
2544 pTransition->nSubType = MMS_SMIL_TRANS_SUB_TOP_TO_BOTTOM;
2546 case MMS_SMIL_TRANS_BARNDOORWIPE:
2547 pTransition->nSubType = MMS_SMIL_TRANS_SUB_HORIZONTAL;
2550 pTransition->nSubType = MMS_SMIL_TRANS_SUB_NONE;
2556 case ATTRIBUTE_SUBTYPE:
2557 pTransition->nSubType = (MmsSmilTransSubType)atoi((char *)pAttr->children->content);
2560 case ATTRIBUTE_CONTENT:
2561 strncpy(pMeta->szContent, (char *)pAttr->children->content, MAX_SMIL_META_CONTENT - 1);
2563 #ifdef MMS_SMIL_ANIMATE
2564 case ATTRIBUTE_ATTRIBUTE_NAME:
2565 strcpy(pMedia->sMedia.sAVI.nAttributeName, (char *)pAttr->children->content);
2568 case ATTRIBUTE_ATTRIBUTE_TYPE:
2569 strcpy(pMedia->sMedia.sAVI.nAttributeType, (char *)pAttr->children->content);
2572 case ATTRIBUTE_TARGET_ELEMENT:
2573 strcpy(pMedia->sMedia.sAVI.nTargetElement, (char *)pAttr->children->content);
2576 case ATTRIBUTE_FROM:
2577 pMedia->sMedia.sAVI.nFrom = atoi((char *)pAttr->children->content);
2581 pMedia->sMedia.sAVI.nTo = atoi((char *)pAttr->children->content);
2585 pMedia->sMedia.sAVI.nBy = atoi((char *)pAttr->children->content);
2588 case ATTRIBUTE_VALUES:
2589 pMedia->sMedia.sAVI.nValues = atoi((char *)pAttr->children->content);
2592 case ATTRIBUTE_CALCMODE:
2593 strcpy(pMedia->sMedia.sAVI.nCalcMode, (char *)pAttr->children->content);
2597 MSG_DEBUG("Undefined Attribute was found!!!!!");
2601 if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_REGION]) {
2602 // Insert a region to region list
2603 _MsgMmsAddRegion(pMmsMsg, pRegion);
2604 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_PAR]) {
2605 //Insert a page to page list
2606 _MsgMmsAddPage(pMmsMsg, pPage);
2607 } else if (paramType == ATTRIBUTE_UNKNOWN && (cmd[ELEMENT_TEXT] ||cmd[ELEMENT_IMG] ||cmd[ELEMENT_AUDIO] ||cmd[ELEMENT_VIDEO] ||cmd[ELEMENT_ANIMATE] || cmd[ELEMENT_REF])) {
2608 //Insert a media to media list
2609 _MsgMmsAddMedia(pPage, pMedia);
2610 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_ROOTLAYOUT]) {
2611 _MsgMmsSetRootLayout(pMmsMsg, &rootlayout);
2612 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_TRANSITION]) {
2613 //Insert a transition to transition list
2614 _MsgMmsAddTransition(pMmsMsg, pTransition);
2615 } else if (paramType == ATTRIBUTE_UNKNOWN && cmd[ELEMENT_META]) {
2616 //Insert a meta to meta list
2617 _MsgMmsAddMeta(pMmsMsg, pMeta);
2620 paramType = ATTRIBUTE_UNKNOWN;
2623 MmsSmilGetElementOnlyLayout(pMmsMsg, cur_node->children);
2629 bool MmsSmilParseSmilDocOnlyLayout(MMS_MESSAGE_DATA_S *pMmsMsg, char *pSmilDoc)
2633 MSG_DEBUG("%s", pSmilDoc);
2634 doc = xmlParseMemory(pSmilDoc, strlen(pSmilDoc));
2637 MSG_DEBUG("Document not parsed successfully. \n");
2641 cur = xmlDocGetRootElement(doc);
2644 MSG_DEBUG("empty document\n");
2649 if (xmlStrcmp(cur->name, (const xmlChar *) "smil")) {
2650 MSG_DEBUG("document of the wrong type, root node != smil");
2655 MmsSmilGetElementOnlyLayout(pMmsMsg, cur);