update tizen source
[framework/messaging/msg-service.git] / utils / MsgMmsMessage.cpp
1 /*
2 *
3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
4 *
5 * This file is part of msg-service.
6 *
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 *          Sangkoo Kim <sangkoo.kim@samsung.com>
9 *          Seunghwan Lee <sh.cat.lee@samsung.com>
10 *          SoonMin Jung <sm0415.jung@samsung.com>
11 *          Jae-Young Lee <jy4710.lee@samsung.com>
12 *          KeeBum Kim <keebum.kim@samsung.com>
13 *
14 * PROPRIETARY/CONFIDENTIAL
15 *
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
21 *
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
28 *
29 */
30
31 #include <stdio.h>
32 #include <string.h>
33 #include <sys/stat.h>
34 #include <errno.h>
35 #include <time.h>
36 #include <stdlib.h>
37
38 #include "MsgTypes.h"
39 #include "MsgMmsTypes.h"
40 #include "MsgMmsMessage.h"
41 #include "MsgDebug.h"
42 #include "MsgUtilFile.h"
43 #include "MsgStorageTypes.h"
44 #include "MsgInternalTypes.h"
45
46
47 MMS_SMIL_ROOTLAYOUT     rootlayout;
48
49 static void __release_glist_element(gpointer data, gpointer user_data);
50 static void __release_page_element(gpointer data, gpointer user_data);
51
52 int msg_verify_number(const char *raw, char *trimmed)
53 {
54         if (!(raw && trimmed)) {
55                 MSG_DEBUG("Phone Number is NULL");
56                 return MSG_ERR_NULL_POINTER;
57         }
58
59         for (int i = 0, j = 0; raw[i]; i++) {
60                 if ((raw[i] >= '0' && raw[i] <= '9') || (raw[i] == ',') || raw[i] == ' ' || raw[i] == '+') {
61                         trimmed[j++] = raw[i];
62                 } else if (raw[i] == '-') {
63                         continue;
64                 } else {
65                         MSG_DEBUG("Unacceptable character in telephone number: [%c]", raw[i]);
66                         return MSG_ERR_INVALID_PARAMETER;
67                 }
68         }
69
70         MSG_DEBUG("Trimming [%s]->[%s]", raw, trimmed);
71         return MSG_SUCCESS;
72 }
73
74 int msg_verify_email(const char *raw)
75 {
76         bool onlyNum = true;
77         bool atExist = false;
78
79         if (!raw) {
80                 MSG_DEBUG("Email is NULL");
81                 return MSG_ERR_NULL_POINTER;
82         }
83
84         for (int i = 0; raw[i]; i++) {
85
86                 if (raw[i] == '@') {
87                         onlyNum = false;
88
89                         if (atExist == false) {
90                                 atExist = true;
91                                 continue;
92                         } else {
93                                 MSG_DEBUG("Character [@] is included more than twice in email address.");
94                                 return MSG_ERR_INVALID_PARAMETER;
95                         }
96                 }
97
98                 if ((raw[i] >= '0' && raw[i] <= '9') || raw[i] == ' ' || raw[i] == '+') {
99                         continue;
100                 } else if ((raw[i] >= 'a' && raw[i] <= 'z') ||(raw[i] >= 'A' && raw[i] <= 'Z') ||(raw[i] == '.') || raw[i] == '_' || raw[i] == '-') {
101                         onlyNum = false;
102                         continue;
103                 } else if (raw[i] == ',') {
104                         if (onlyNum == false && atExist == false) {
105                                 MSG_DEBUG("Unacceptable type in address.");
106                                 return MSG_ERR_INVALID_PARAMETER;
107                         }
108                         atExist = false;
109                         onlyNum = true;
110                         continue;
111                 } else {
112                         MSG_DEBUG("Unacceptable character in address : [%c]", raw[i]);
113                         return MSG_ERR_INVALID_PARAMETER;
114                 }
115         }
116
117         return MSG_SUCCESS;
118 }
119
120 static void __release_glist_element(gpointer data, gpointer user_data)
121 {
122         if(data != NULL) {
123                 free(data);
124         }
125 }
126
127 static void __release_page_element(gpointer data, gpointer user_data)
128 {
129         if(data != NULL) {
130                 MMS_PAGE_S *page = (MMS_PAGE_S *)data;
131
132                 if (page->medialist) {
133                         MMS_MEDIA_S *media = NULL;
134                         int mediaCnt = g_list_length(page->medialist);
135
136                         for (int i = 0; i < mediaCnt; i++) {
137                                 media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, i);
138                                 if (media)
139                                         free(media);
140                         }
141
142                         g_list_free(page->medialist);
143                         page->medialist = NULL;
144                         page->mediaCnt = 0;
145                 }
146
147                 free(page);
148         }
149 }
150
151 MSG_ERROR_T _MsgMmsReleasePageList(MMS_MESSAGE_DATA_S *pMsgData)
152 {
153         if (pMsgData == NULL) {
154                 MSG_DEBUG("pMsgData is NULL");
155                 return MSG_ERR_INVALID_PARAMETER;
156         }
157
158         if (pMsgData->pagelist) {
159                 g_list_foreach(pMsgData->pagelist, __release_page_element, NULL);
160                 g_list_free(pMsgData->pagelist);
161                 pMsgData->pagelist = NULL;
162         }
163
164         pMsgData->pageCnt = 0;
165
166         return MSG_SUCCESS;
167 }
168
169 MSG_ERROR_T _MsgMmsReleaseRegionList(MMS_MESSAGE_DATA_S *pMsgData)
170 {
171         if (pMsgData == NULL) {
172                 MSG_DEBUG("pMsgData is NULL");
173                 return MSG_ERR_INVALID_PARAMETER;
174         }
175
176         if (pMsgData->regionlist) {
177                 g_list_foreach(pMsgData->regionlist, __release_glist_element, NULL);
178                 g_list_free(pMsgData->regionlist);
179                 pMsgData->regionlist = NULL;
180         }
181
182         pMsgData->regionCnt = 0;
183
184         return MSG_SUCCESS;
185 }
186
187 MSG_ERROR_T _MsgMmsReleaseAttachList(MMS_MESSAGE_DATA_S *pMsgData)
188 {
189         if (pMsgData == NULL) {
190                 MSG_DEBUG("pMsgData is NULL");
191                 return MSG_ERR_INVALID_PARAMETER;
192         }
193
194         if (pMsgData->attachlist) {
195                 g_list_foreach(pMsgData->attachlist, __release_glist_element, NULL);
196                 g_list_free(pMsgData->attachlist);
197                 pMsgData->attachlist = NULL;
198         }
199
200         pMsgData->attachCnt = 0;
201
202         return MSG_SUCCESS;
203 }
204
205 MSG_ERROR_T _MsgMmsReleaseTransitionList(MMS_MESSAGE_DATA_S *pMsgData)
206 {
207         if (pMsgData == NULL) {
208                 MSG_DEBUG("pMsgData is NULL");
209                 return MSG_ERR_INVALID_PARAMETER;
210         }
211
212         if (pMsgData->transitionlist) {
213                 g_list_foreach(pMsgData->transitionlist, __release_glist_element, NULL);
214                 g_list_free(pMsgData->transitionlist);
215                 pMsgData->transitionlist = NULL;
216         }
217
218         pMsgData->transitionCnt = 0;
219
220         return MSG_SUCCESS;
221 }
222
223 MSG_ERROR_T _MsgMmsReleaseMetaList(MMS_MESSAGE_DATA_S *pMsgData)
224 {
225         if (pMsgData == NULL) {
226                 MSG_DEBUG("pMsgData is NULL");
227                 return MSG_ERR_INVALID_PARAMETER;
228         }
229
230         if (pMsgData->metalist) {
231                 g_list_foreach(pMsgData->metalist, __release_glist_element, NULL);
232                 g_list_free(pMsgData->metalist);
233                 pMsgData->metalist = NULL;
234         }
235
236         pMsgData->metaCnt = 0;
237
238         return MSG_SUCCESS;
239 }
240
241 MSG_ERROR_T _MsgMmsAddRegion(MMS_MESSAGE_DATA_S *pMsgData, MMS_SMIL_REGION* pRegion)
242 {
243         if(pMsgData == NULL || pRegion == NULL)
244                 return MSG_ERR_INVALID_PARAMETER;
245
246         pMsgData->regionlist = g_list_append(pMsgData->regionlist, pRegion);
247         pMsgData->regionCnt++;
248
249         return MSG_SUCCESS;
250 }
251
252 MSG_ERROR_T _MsgMmsAddPage(MMS_MESSAGE_DATA_S *pMsgData, MMS_PAGE_S *pPage)
253 {
254         if(pMsgData == NULL || pPage == NULL)
255                 return MSG_ERR_INVALID_PARAMETER;
256
257         pMsgData->pagelist = g_list_append(pMsgData->pagelist, pPage);
258         pMsgData->pageCnt++;
259
260         return MSG_SUCCESS;
261 }
262
263 MSG_ERROR_T _MsgMmsAddMedia(MMS_PAGE_S* pPage, MMS_MEDIA_S *pMedia)
264 {
265         if(pPage == NULL || pMedia == NULL)
266                 return MSG_ERR_INVALID_PARAMETER;
267
268         pPage->medialist = g_list_append(pPage->medialist, pMedia);
269         pPage->mediaCnt++;
270                 MSG_DEBUG("media's mediatype: %d", pMedia->mediatype);
271                 MSG_DEBUG("media's filename: %s", pMedia->szFileName);
272                 MSG_DEBUG("media's filepath: %s", pMedia->szFilePath);
273                 MSG_DEBUG("media's contentId: %s", pMedia->szContentID);
274         MSG_DEBUG("page's media count: %d", pPage->mediaCnt);
275
276         return MSG_SUCCESS;
277 }
278
279 MSG_ERROR_T _MsgMmsAddTransition(MMS_MESSAGE_DATA_S *pMsgData, MMS_SMIL_TRANSITION* pTransition)
280 {
281         if(pMsgData == NULL || pTransition == NULL)
282                 return MSG_ERR_INVALID_PARAMETER;
283
284         pMsgData->transitionlist = g_list_append(pMsgData->transitionlist, pTransition);
285         pMsgData->transitionCnt++;
286
287         return MSG_SUCCESS;
288 }
289
290 MSG_ERROR_T _MsgMmsAddMeta(MMS_MESSAGE_DATA_S *pMsgData, MMS_SMIL_META* pMeta)
291 {
292         if(pMsgData == NULL || pMeta == NULL)
293                 return MSG_ERR_INVALID_PARAMETER;
294
295         pMsgData->metalist = g_list_append(pMsgData->metalist, pMeta);
296         pMsgData->metaCnt++;
297
298         return MSG_SUCCESS;
299 }
300
301 MSG_ERROR_T _MsgMmsAddAttachment(MMS_MESSAGE_DATA_S *pMsgData, MMS_ATTACH_S *pAttach)
302 {
303         if(pMsgData == NULL || pAttach == NULL)
304                 return MSG_ERR_INVALID_PARAMETER;
305
306         pMsgData->attachlist = g_list_append(pMsgData->attachlist, pAttach);
307         pMsgData->attachCnt++;
308
309         return MSG_SUCCESS;
310 }
311
312 bool _MsgMmsFindMatchedMedia(MMS_MESSAGE_DATA_S *pMsgData, char *pszFilePath)
313 {
314         if (pMsgData == NULL || pszFilePath == NULL)
315                 return false;
316
317         if (pMsgData->pagelist) {
318                 for (int pageIdx = 0; pageIdx < pMsgData->pageCnt; pageIdx++) {
319                         MMS_PAGE_S *page = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, pageIdx);
320
321                         if (page && page->medialist) {
322                                 for (int mediaIdx = 0; mediaIdx < page->mediaCnt; mediaIdx++) {
323                                         MMS_MEDIA_S *media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, mediaIdx);
324                                         if (media) {
325                                                 if (strcmp(pszFilePath, media->szFilePath) == 0)
326                                                         return true;
327                                         }
328                                 }
329                         }
330                 }
331         }
332
333         return false;
334 }
335
336 MSG_ERROR_T _MsgMmsAddSmilDoc(char* pSmil, MMS_MESSAGE_DATA_S* pMsgData)
337 {
338         MSG_DEBUG("MsgMmsAddSmilDoc");
339
340         if(pSmil == NULL || pMsgData == NULL)
341                 return MSG_ERR_INVALID_PARAMETER;
342
343         char    fullpath[MSG_FILEPATH_LEN_MAX] = {0,};
344         char smilFileName[MSG_FILENAME_LEN_MAX+1] = {0,};
345         time_t  RawTime = 0;
346
347         //Create smilFileName
348         time(&RawTime);
349         snprintf(smilFileName, MSG_FILENAME_LEN_MAX+1, "%lu", RawTime);
350         snprintf(fullpath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_SMIL_FILE_PATH, smilFileName);
351
352         if (MsgWriteSmilFile(fullpath, pSmil, strlen(pSmil)) == false) {
353                 MSG_DEBUG("MsgWriteSmilFile error");
354                 return MSG_ERR_MMS_ERROR;
355         }
356         strncpy(pMsgData->szSmilFilePath, smilFileName, MSG_FILEPATH_LEN_MAX-1);
357
358         return MSG_SUCCESS;
359 }
360
361
362 char* _MsgMmsSerializeMessageData(const MMS_MESSAGE_DATA_S* pMsgData, unsigned int *pSize)
363 {
364         MSG_DEBUG("MsgMmsSerializeMessageData");
365
366         if (pMsgData == NULL)
367                 return NULL;
368
369         int bufsize = 0;
370         int offset = 0;
371         int pageCnt = 0;
372         char *buf = NULL;
373
374         pageCnt = pMsgData->pageCnt;
375
376         int mediaCnt = 0;
377
378         if (pMsgData->pagelist) {
379                 for (int pageIdx = 0; pageIdx < pageCnt; pageIdx++) {
380                         bufsize += sizeof(int); // Media cnt
381
382                         MMS_PAGE_S *page = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, pageIdx);
383                         mediaCnt = page->mediaCnt;
384
385                         if (page->medialist) {
386                                 for (int i = 0; i < mediaCnt; i++) {
387                                         MMS_MEDIA_S *media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, i);
388
389                                         if (media->mediatype == MMS_SMIL_MEDIA_TEXT) {
390                                                 bufsize += (sizeof(MmsSmilMediaType) + MSG_FILENAME_LEN_MAX + 2 * MSG_FILEPATH_LEN_MAX + MSG_MSG_ID_LEN + 1
391                                                         + MAX_SMIL_ALT_LEN + MAX_SMIL_REGION_ID
392 #ifdef __SUPPORT_DRM__
393                                                         + sizeof(MsgDrmType) + MSG_FILEPATH_LEN_MAX
394 #endif
395                                                         + MAX_SMIL_TRANSIN_ID + MAX_SMIL_TRANSOUT_ID +
396                                                         7 * sizeof(int) + 3* sizeof(bool) + sizeof(MmsTextDirection) + sizeof(MmsSmilFontType));
397                                         } else {
398                                                 bufsize += (sizeof(MmsSmilMediaType) + MSG_FILENAME_LEN_MAX + 2 * MSG_FILEPATH_LEN_MAX + MSG_MSG_ID_LEN + 1
399                                                         + MAX_SMIL_ALT_LEN + MAX_SMIL_REGION_ID
400 #ifdef __SUPPORT_DRM__
401                                                         + sizeof(MsgDrmType) + MSG_FILEPATH_LEN_MAX
402 #endif
403                                                         + MAX_SMIL_TRANSIN_ID + MAX_SMIL_TRANSOUT_ID + 5 * sizeof(int)
404                                                         );
405                                         }
406                                 }
407                         }
408
409                         bufsize += sizeof(int) * 6;
410                 }
411         }
412
413         bufsize += sizeof(int); // region count;
414         if (pMsgData->regionlist) {
415                 int elementSize = g_list_length(pMsgData->regionlist);
416                 bufsize += elementSize * (MAX_SMIL_REGION_ID + 4 * sizeof(MMS_LENGTH) + sizeof(int) + sizeof(REGION_FIT_TYPE_T));
417         }
418
419         bufsize += sizeof(int); // attachment count;
420         if (pMsgData->attachlist) {
421                 int elementSize = g_list_length(pMsgData->attachlist);
422                 bufsize += elementSize * (sizeof(MimeType) + MSG_FILENAME_LEN_MAX + MSG_FILEPATH_LEN_MAX + sizeof(int)
423 #ifdef __SUPPORT_DRM__
424                                 + sizeof(MsgDrmType) + MSG_FILEPATH_LEN_MAX
425 #endif
426                                 );
427         }
428
429         bufsize += sizeof(int); // transition count;
430         if (pMsgData->transitionlist) {
431                 int elementSize = g_list_length(pMsgData->transitionlist);
432                 bufsize += elementSize * (MAX_SMIL_TRANSITION_ID + sizeof(MmsSmilTransType) + sizeof(MmsSmilTransSubType) + sizeof(int));
433         }
434
435         bufsize += sizeof(int); // meta count;
436         if (pMsgData->metalist) {
437                 int elementSize = g_list_length(pMsgData->metalist);
438                 bufsize += elementSize * (MAX_SMIL_META_ID + MAX_SMIL_META_NAME + MAX_SMIL_META_CONTENT);
439         }
440
441         bufsize += sizeof(MMS_SMIL_ROOTLAYOUT);
442
443 #ifdef FEATURE_JAVA_MMS
444         bufsize += sizeof(MMS_APPID_INFO_S);
445 #endif
446
447         int filePathLen = strlen(pMsgData->szSmilFilePath);
448
449         bufsize += sizeof(int) + filePathLen + sizeof(int);
450
451         MSG_DEBUG("MsgMmsSerializeMessageData: bufsize = %d", bufsize);
452
453         buf = (char *)calloc(bufsize, 1);
454
455         // copy file path length
456         MSG_DEBUG("MsgMmsSerializeMessageData: smilFilePath Length = %d",  filePathLen);
457
458         memcpy(buf, &filePathLen, sizeof(int));
459
460         offset += sizeof(int);
461
462         // copy file path
463         MSG_DEBUG("MsgMmsSerializeMessageData: smilFilePath = %s",  pMsgData->szSmilFilePath);
464
465         if (filePathLen > 0) {
466                 memcpy(buf + offset, pMsgData->szSmilFilePath, filePathLen);
467
468                 offset += filePathLen;
469         }
470
471         // copy page count
472         MSG_DEBUG("MsgMmsSerializeMessageData: pageCnt = %d",  pMsgData->pageCnt);
473
474         memcpy(buf + offset, &(pMsgData->pageCnt), sizeof(int));
475
476         offset += sizeof(int);
477
478         if (pMsgData->pagelist) {
479                 for (int pageIdx = 0; pageIdx < pageCnt; pageIdx++)
480                 {
481                         MMS_PAGE_S *page = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, pageIdx);
482                         mediaCnt = page->mediaCnt;
483
484                         memcpy(buf + offset, &mediaCnt, sizeof(int));
485                         offset += sizeof(int);
486
487                         MSG_DEBUG("MsgMmsSerializeMessageData: mediaCnt = %d",  mediaCnt);
488                         if (page->medialist) {
489                                 for (int i = 0; i < mediaCnt; ++ i) {
490                                         MMS_MEDIA_S *media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, i);
491
492                                         memcpy(buf + offset, &(media->mediatype), sizeof(MmsSmilMediaType));
493                                         offset += sizeof(MmsSmilMediaType);
494                                         MSG_DEBUG("%d media's mediatype = %d", i, media->mediatype);
495
496                                         memcpy(buf + offset, media->szSrc, MSG_FILEPATH_LEN_MAX);
497                                         offset +=  MSG_FILEPATH_LEN_MAX;
498
499                                         memcpy(buf + offset, media->szFileName, MSG_FILENAME_LEN_MAX);
500                                         offset += MSG_FILENAME_LEN_MAX;
501                                         MSG_DEBUG("%d media's filename = %s", i, media->szFileName);
502
503                                         memcpy(buf + offset, media->szFilePath, MSG_FILEPATH_LEN_MAX);
504                                         offset += MSG_FILEPATH_LEN_MAX;
505                                         MSG_DEBUG("%d media's filepath = %s", i, media->szFilePath);
506
507                                         memcpy(buf + offset, media->szContentID, MSG_MSG_ID_LEN + 1);
508                                         offset +=  MSG_MSG_ID_LEN + 1;
509                                         MSG_DEBUG("%d media's contentID = %s", i, media->szContentID);
510
511                                         memcpy(buf + offset, media->regionId, MAX_SMIL_REGION_ID);
512                                         offset +=  MAX_SMIL_REGION_ID;
513                                         MSG_DEBUG("%d media's regionId = %s", i, media->regionId);
514
515                                         memcpy(buf + offset, media->szAlt, MAX_SMIL_ALT_LEN);
516                                         offset +=  MAX_SMIL_ALT_LEN;
517
518 #ifdef __SUPPORT_DRM__
519                                         memcpy(buf + offset, &(media->drmType), sizeof(MsgDrmType));
520                                         offset +=  sizeof(MsgDrmType);
521                                         memcpy(buf + offset, media->szDrm2FullPath, MSG_FILEPATH_LEN_MAX);
522                                         offset += MSG_FILEPATH_LEN_MAX;
523 #endif
524
525                                         if (media->mediatype == MMS_SMIL_MEDIA_TEXT) {
526                                                 MSG_DEBUG("##### Media = TEXT #####");
527                                                 memcpy(buf + offset, media->sMedia.sText.szTransInId, MAX_SMIL_TRANSIN_ID);
528                                                 offset +=  MAX_SMIL_TRANSIN_ID;
529
530                                                 memcpy(buf + offset, media->sMedia.sText.szTransOutId, MAX_SMIL_TRANSOUT_ID);
531                                                 offset +=  MAX_SMIL_TRANSOUT_ID;
532
533                                                 memcpy(buf + offset, &(media->sMedia.sText.nRepeat), sizeof(int));
534                                                 offset += sizeof(int);
535
536                                                 memcpy(buf + offset, &(media->sMedia.sText.nBegin), sizeof(int));
537                                                 offset += sizeof(int);
538
539                                                 memcpy(buf + offset, &(media->sMedia.sText.nEnd), sizeof(int));
540                                                 offset += sizeof(int);
541
542                                                 memcpy(buf + offset, &(media->sMedia.sText.nDurTime), sizeof(int));
543                                                 offset += sizeof(int);
544
545                                                 memcpy(buf + offset, &(media->sMedia.sText.nBgColor), sizeof(int));
546                                                 offset += sizeof(int);
547
548                                                 memcpy(buf + offset, &(media->sMedia.sText.bBold), sizeof(bool));
549                                                 offset += sizeof(bool);
550
551                                                 memcpy(buf + offset, &(media->sMedia.sText.bUnderLine), sizeof(bool));
552                                                 offset += sizeof(bool);
553
554                                                 memcpy(buf + offset, &(media->sMedia.sText.bItalic), sizeof(bool));
555                                                 offset += sizeof(bool);
556
557                                                 memcpy(buf + offset, &(media->sMedia.sText.bReverse), sizeof(bool));
558                                                 offset += sizeof(bool);
559
560                                                 memcpy(buf + offset, &(media->sMedia.sText.nDirection), sizeof(MmsTextDirection));
561                                                 offset += sizeof(MmsTextDirection);
562
563                                                 //memcpy(buf + offset, &(media->sMedia.sText.nFont), sizeof(MmsSmilFontType));
564                                                 //offset += sizeof(MmsSmilFontType);
565
566                                                 memcpy(buf + offset, &(media->sMedia.sText.nSize), sizeof(int));
567                                                 offset += sizeof(int);
568
569                                                 memcpy(buf + offset, &(media->sMedia.sText.nColor), sizeof(int));
570                                                 offset += sizeof(int);
571                                         } else {
572                                                 MSG_DEBUG("##### Media = IMAGE, AUDIO, VIDEO #####");
573                                                 memcpy(buf + offset, media->sMedia.sAVI.szTransInId, MAX_SMIL_TRANSIN_ID);
574                                                 offset +=  MAX_SMIL_TRANSIN_ID;
575
576                                                 memcpy(buf + offset, media->sMedia.sAVI.szTransOutId, MAX_SMIL_TRANSOUT_ID);
577                                                 offset +=  MAX_SMIL_TRANSOUT_ID;
578
579                                                 memcpy(buf + offset, &(media->sMedia.sAVI.nRepeat), sizeof(int));
580                                                 offset += sizeof(int);
581
582                                                 memcpy(buf + offset, &(media->sMedia.sAVI.nBegin), sizeof(int));
583                                                 offset += sizeof(int);
584
585                                                 memcpy(buf + offset, &(media->sMedia.sAVI.nEnd), sizeof(int));
586                                                 offset += sizeof(int);
587
588                                                 memcpy(buf + offset, &(media->sMedia.sAVI.nDurTime), sizeof(int));
589                                                 offset += sizeof(int);
590
591                                                 memcpy(buf + offset, &(media->sMedia.sAVI.nBgColor), sizeof(int));
592                                                 offset += sizeof(int);
593                                         }
594                                 }
595                         }
596
597                         memcpy(buf + offset, &page->nDur, sizeof(int));
598                         offset += sizeof(int);
599                         memcpy(buf + offset, &page->nBegin, sizeof(int));
600                         offset += sizeof(int);
601                         memcpy(buf + offset, &page->nEnd, sizeof(int));
602                         offset += sizeof(int);
603                         memcpy(buf + offset, &page->nMin, sizeof(int));
604                         offset += sizeof(int);
605                         memcpy(buf + offset, &page->nMax, sizeof(int));
606                         offset += sizeof(int);
607                         memcpy(buf + offset, &page->nRepeat, sizeof(int));
608                         offset += sizeof(int);
609                 }
610         }
611
612         memcpy(buf + offset, &pMsgData->regionCnt, sizeof(int));
613         offset += sizeof(int);
614         MSG_DEBUG("pMsgData->regionCnt: %d", pMsgData->regionCnt);
615
616         if (pMsgData->regionlist) {
617                 for (int i = 0; i < pMsgData->regionCnt; ++ i) {
618                         MMS_SMIL_REGION *region = (MMS_SMIL_REGION *)g_list_nth_data(pMsgData->regionlist, i);
619
620                         memcpy(buf + offset, region->szID, MAX_SMIL_REGION_ID);
621                         offset += MAX_SMIL_REGION_ID;
622                         MSG_DEBUG("%d region's ID = %s", i, region->szID);
623                         memcpy(buf + offset, &region->nLeft, sizeof(MMS_LENGTH));
624                         offset += sizeof(MMS_LENGTH);
625                         memcpy(buf + offset, &region->nTop, sizeof(MMS_LENGTH));
626                         offset += sizeof(MMS_LENGTH);
627                         memcpy(buf + offset, &region->width, sizeof(MMS_LENGTH));
628                         offset += sizeof(MMS_LENGTH);
629                         memcpy(buf + offset, &region->height, sizeof(MMS_LENGTH));
630                         offset += sizeof(MMS_LENGTH);
631                         memcpy(buf + offset, &region->bgColor, sizeof(int));
632                         offset += sizeof(int);
633                         memcpy(buf + offset, &region->fit, sizeof(REGION_FIT_TYPE_T));
634                         offset += sizeof(REGION_FIT_TYPE_T);
635                 }
636         }
637
638         memcpy(buf + offset, &pMsgData->attachCnt, sizeof(int));
639         offset += sizeof(int);
640         MSG_DEBUG("pMsgData->attachCnt: %d", pMsgData->attachCnt);
641
642         if (pMsgData->attachlist) {
643                 for (int i = 0; i < pMsgData->attachCnt; ++ i) {
644                         MMS_ATTACH_S *attach = (MMS_ATTACH_S *)g_list_nth_data(pMsgData->attachlist, i);
645
646                         memcpy(buf + offset, &(attach->mediatype), sizeof(MimeType));
647                         offset += sizeof(MimeType);
648                         MSG_DEBUG("%d attachment's mediatype = %d", i, attach->mediatype);
649
650                         memcpy(buf + offset, attach->szFileName, MSG_FILENAME_LEN_MAX);
651                         offset += MSG_FILENAME_LEN_MAX;
652                         MSG_DEBUG("%d attachment's filename = %s", i, attach->szFileName);
653
654                         memcpy(buf + offset, attach->szFilePath, MSG_FILEPATH_LEN_MAX);
655                         offset += MSG_FILEPATH_LEN_MAX;
656                         MSG_DEBUG("%d attachment's filepath = %s", i, attach->szFilePath);
657
658                         memcpy(buf + offset, &(attach->fileSize), sizeof(int));
659                         offset +=  sizeof(int);
660                         MSG_DEBUG("%d attachment's file size = %d", i, attach->fileSize);
661
662 #ifdef __SUPPORT_DRM__
663                         memcpy(buf + offset, &(attach->drmType), sizeof(MsgDrmType));
664                         offset +=  sizeof(MsgDrmType);
665                         memcpy(buf + offset, attach->szDrm2FullPath, MSG_FILEPATH_LEN_MAX);
666                         offset += MSG_FILEPATH_LEN_MAX;
667 #endif
668                 }
669         }
670
671         memcpy(buf + offset, &pMsgData->transitionCnt, sizeof(int));
672         offset += sizeof(int);
673         MSG_DEBUG("pMsgData->transitionCnt: %d", pMsgData->transitionCnt);
674
675         if (pMsgData->transitionlist) {
676                 for (int i = 0; i < pMsgData->transitionCnt; ++ i) {
677                         MMS_SMIL_TRANSITION *transition = (MMS_SMIL_TRANSITION *)g_list_nth_data(pMsgData->transitionlist, i);
678
679                         memcpy(buf + offset, transition->szID, MAX_SMIL_TRANSITION_ID);
680                         offset += MAX_SMIL_TRANSITION_ID;
681                         MSG_DEBUG("%d transition's ID = %s", i, transition->szID);
682
683                         memcpy(buf + offset, &transition->nType, sizeof(MmsSmilTransType));
684                         offset += sizeof(MmsSmilTransType);
685                         memcpy(buf + offset, &transition->nSubType, sizeof(MmsSmilTransSubType));
686                         offset += sizeof(MmsSmilTransSubType);
687                         memcpy(buf + offset, &transition->nDur, sizeof(int));
688                         offset += sizeof(int);
689                 }
690         }
691
692         memcpy(buf + offset, &pMsgData->metaCnt, sizeof(int));
693         offset += sizeof(int);
694         MSG_DEBUG("pMsgData->metaCnt: %d", pMsgData->metaCnt);
695
696         if (pMsgData->metalist) {
697                 for (int i = 0; i < pMsgData->metaCnt; ++ i) {
698                         MMS_SMIL_META *meta = (MMS_SMIL_META *)g_list_nth_data(pMsgData->metalist, i);
699
700                         memcpy(buf + offset, meta->szID, MAX_SMIL_META_ID);
701                         offset += MAX_SMIL_META_ID;
702                         MSG_DEBUG("%d meta's ID = %s", i, meta->szID);
703
704                         memcpy(buf + offset, meta->szName, MAX_SMIL_META_NAME);
705                         offset += MAX_SMIL_META_NAME;
706                         MSG_DEBUG("%d meta's ID = %s", i, meta->szID);
707
708                         memcpy(buf + offset, meta->szContent, MAX_SMIL_META_CONTENT);
709                         offset += MAX_SMIL_META_CONTENT;
710                         MSG_DEBUG("%d meta's ID = %s", i, meta->szID);
711                 }
712         }
713
714         memcpy(buf + offset, &pMsgData->rootlayout, sizeof(MMS_SMIL_ROOTLAYOUT));
715         offset += sizeof(MMS_SMIL_ROOTLAYOUT);
716
717 #ifdef FEATURE_JAVA_MMS
718         memcpy(buf + offset, &pMsgData->msgAppId, sizeof(MMS_APPID_INFO_S));
719         offset += sizeof(MMS_APPID_INFO_S);
720 #endif
721
722         *pSize = offset;
723
724         return buf;
725 }
726
727 int _MsgMmsGetPageCount(MMS_MESSAGE_DATA_S *pMsgData)
728 {
729         if (pMsgData == NULL) {
730                 MSG_DEBUG("pMsgData is NULL");
731                 return 0;
732         }
733
734         int count = 0;
735
736         if (pMsgData->pagelist)
737                 count = g_list_length(pMsgData->pagelist);
738
739         MSG_DEBUG("Page Count: %d", count);
740         return count;
741 }
742
743 MMS_PAGE_S *_MsgMmsGetPage(MMS_MESSAGE_DATA_S *pMsgData, int pageIdx)
744 {
745         if (pMsgData == NULL) {
746                 MSG_DEBUG("pMsgData is NULL");
747                 return NULL;
748         }
749
750         MMS_PAGE_S *page = NULL;
751
752         if (pMsgData->pagelist)
753                 page = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, pageIdx);
754
755         return page;
756 }
757
758 int _MsgMmsGetAttachCount(MMS_MESSAGE_DATA_S *pMsgData)
759 {
760         if (pMsgData == NULL) {
761                 MSG_DEBUG("pMsgData is NULL");
762                 return 0;
763         }
764
765         int count = 0;
766
767         if (pMsgData->attachlist)
768                 count = g_list_length(pMsgData->attachlist);
769
770         MSG_DEBUG("Attachment Count: %d", count);
771         return count;
772 }
773
774 MMS_ATTACH_S *_MsgMmsGetAttachment(MMS_MESSAGE_DATA_S *pMsgData, int attachIdx)
775 {
776         if (pMsgData == NULL) {
777                 MSG_DEBUG("pMsgData is NULL");
778                 return NULL;
779         }
780
781         MMS_ATTACH_S *attach = NULL;
782         if (pMsgData->attachlist)
783                 attach = (MMS_ATTACH_S *)g_list_nth_data(pMsgData->attachlist, attachIdx);
784
785         return attach;
786 }
787
788 MMS_SMIL_REGION *_MsgMmsGetSmilRegion(MMS_MESSAGE_DATA_S *pMsgData, int regionIdx)
789 {
790         if (pMsgData == NULL) {
791                 MSG_DEBUG("pMsgData is NULL");
792                 return NULL;
793         }
794
795         MMS_SMIL_REGION *region = NULL;
796
797         if (pMsgData->regionlist)
798                 region = (MMS_SMIL_REGION *)g_list_nth_data(pMsgData->regionlist, regionIdx);
799
800         return region;
801 }
802
803 MMS_MEDIA_S *_MsgMmsGetMedia(MMS_PAGE_S *pPage, int mediaIdx)
804 {
805         if (!pPage) {
806                 MSG_FATAL("pPage is NULL");
807                 return NULL;
808         }
809
810         if (mediaIdx > pPage->mediaCnt || mediaIdx < 0) {
811                 MSG_FATAL("Invalid media index = %d", mediaIdx);
812                 return NULL;
813         }
814
815         MMS_MEDIA_S *media = NULL;
816         if (pPage->medialist)
817                 media = (MMS_MEDIA_S *)g_list_nth_data(pPage->medialist, mediaIdx);
818
819         return media;
820
821 }
822
823 int _MsgMmsGetTransitionCount(MMS_MESSAGE_DATA_S *pMsgData)
824 {
825         if (pMsgData == NULL) {
826                 MSG_DEBUG("pMsgData is NULL");
827                 return 0;
828         }
829
830         int count = 0;
831
832         if (pMsgData->transitionlist)
833                 count = g_list_length(pMsgData->transitionlist);
834
835         MSG_DEBUG("Transition Count: %d", count);
836         return count;
837 }
838
839 MMS_SMIL_TRANSITION *_MsgMmsGetTransition(MMS_MESSAGE_DATA_S *pMsgData, int transitionIdx)
840 {
841         if (pMsgData == NULL) {
842                 MSG_DEBUG("pMsgData is NULL");
843                 return NULL;
844         }
845
846         MMS_SMIL_TRANSITION *transition = NULL;
847         if (pMsgData->transitionlist)
848                 transition = (MMS_SMIL_TRANSITION *)g_list_nth_data(pMsgData->transitionlist, transitionIdx);
849
850         return transition;
851 }
852
853 MMS_SMIL_META *_MsgMmsGetMeta(MMS_MESSAGE_DATA_S *pMsgData, int metaIdx)
854 {
855         if (pMsgData == NULL) {
856                 MSG_DEBUG("pMsgData is NULL");
857                 return NULL;
858         }
859
860         MMS_SMIL_META *meta = NULL;
861
862         if (pMsgData->metalist)
863                 meta = (MMS_SMIL_META *)g_list_nth_data(pMsgData->metalist, metaIdx);
864
865         return meta;
866 }
867
868 int     _MsgMmsGetMetaCount(MMS_MESSAGE_DATA_S *pMsgData)
869 {
870         if (pMsgData == NULL) {
871                 MSG_DEBUG("pMsgData is NULL");
872                 return 0;
873         }
874
875         int count = 0;
876
877         if (pMsgData->metalist)
878                 count = g_list_length(pMsgData->metalist);
879
880         MSG_DEBUG("Meta Count: %d", count);
881         return count;
882 }
883
884
885 bool            _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S* pBody, char* pData)
886 {
887         MSG_DEBUG("MmsGetMsgBodyfromFile");
888
889         if (pBody == NULL || pData == NULL) {
890                 MSG_DEBUG("param is NULL. pBody = %x, pData = %x", pBody, pData);
891                 return false;
892         }
893
894         int offset = 0;
895         int pageCnt = 0;
896         int filePathLen = 0;
897
898         MMS_PAGE_S *pPage = NULL;
899         MMS_MEDIA_S *pMedia = NULL;
900         MMS_SMIL_REGION *pRegion = NULL;
901         MMS_ATTACH_S *pAttach = NULL;
902         MMS_SMIL_TRANSITION *pTransition = NULL;
903         MMS_SMIL_META *pMeta = NULL;
904
905         memcpy(&filePathLen, pData, sizeof(int));
906
907         offset += sizeof(int);
908
909         MSG_DEBUG("Smil File Path Length : %d", filePathLen);
910
911         if (filePathLen > MSG_FILEPATH_LEN_MAX) {
912                 MSG_DEBUG("Smil File Path Length is abnormal.");
913                 return false;
914         }
915
916         memset(pBody->szSmilFilePath, 0x00, MSG_FILEPATH_LEN_MAX);
917
918         if (filePathLen > 0) {
919                 memcpy(pBody->szSmilFilePath, pData + offset, filePathLen);
920
921                 offset += filePathLen;
922         }
923
924         memcpy(&(pBody->pageCnt), pData + offset, sizeof(int));
925
926         offset += sizeof(int);
927
928         pageCnt = pBody->pageCnt;
929
930         MSG_DEBUG("MMS PAGE COUNT: %d", pageCnt);
931
932         for (int j = 0; j < pageCnt; ++j) {
933                 pPage = (MMS_PAGE_S *)calloc(sizeof(MMS_PAGE_S), 1);
934
935                 memcpy(&pPage->mediaCnt, pData + offset, sizeof(int));
936                 offset += sizeof(int);
937                 MSG_DEBUG("MMS MEDIA COUNT: %d", pPage->mediaCnt);
938
939                 for (int i = 0; i < pPage->mediaCnt; ++i) {
940                         pMedia = (MMS_MEDIA_S *)calloc(sizeof(MMS_MEDIA_S), 1);
941
942                         memcpy(&pMedia->mediatype, pData + offset, sizeof(int));
943                         offset += sizeof(int);
944
945                         memcpy(pMedia->szSrc, pData + offset, MSG_FILEPATH_LEN_MAX);
946                         offset += MSG_FILEPATH_LEN_MAX;
947
948                         memcpy(pMedia->szFileName, pData + offset, MSG_FILENAME_LEN_MAX);
949                         offset += MSG_FILENAME_LEN_MAX;
950
951                         memcpy(pMedia->szFilePath, pData + offset, MSG_FILEPATH_LEN_MAX);
952                         offset += MSG_FILEPATH_LEN_MAX;
953
954                         memcpy(pMedia->szContentID, pData + offset, MSG_MSG_ID_LEN+1);
955                         offset += MSG_MSG_ID_LEN + 1;
956
957                         memcpy(pMedia->regionId, pData + offset, MAX_SMIL_REGION_ID);
958                         offset += MAX_SMIL_REGION_ID;
959
960                         memcpy(pMedia->szAlt, pData + offset, MAX_SMIL_ALT_LEN);
961                         offset += MAX_SMIL_ALT_LEN;
962
963 #ifdef __SUPPORT_DRM__
964                         memcpy(&pMedia->drmType, pData + offset, sizeof(MsgDrmType));
965                         offset += sizeof(MsgDrmType);
966
967                         memcpy(pMedia->szDrm2FullPath, pData + offset, MSG_FILEPATH_LEN_MAX);
968                         offset += MSG_FILEPATH_LEN_MAX;
969 #endif
970
971                         if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) {
972                                 MSG_DEBUG("##### MEDIA TYPE = TEXT #####");
973                                 memcpy(pMedia->sMedia.sText.szTransInId, pData + offset, MAX_SMIL_TRANSIN_ID);
974                                 offset += MAX_SMIL_TRANSIN_ID;
975
976                                 memcpy(pMedia->sMedia.sText.szTransOutId, pData + offset, MAX_SMIL_TRANSOUT_ID);
977                                 offset += MAX_SMIL_TRANSOUT_ID;
978
979                                 memcpy(&pMedia->sMedia.sText.nRepeat, pData + offset, sizeof(int));
980                                 offset += sizeof(int);
981
982                                 memcpy(&pMedia->sMedia.sText.nBegin, pData + offset, sizeof(int));
983                                 offset += sizeof(int);
984
985                                 memcpy(&pMedia->sMedia.sText.nEnd, pData + offset, sizeof(int));
986                                 offset += sizeof(int);
987
988                                 memcpy(&pMedia->sMedia.sText.nDurTime, pData + offset, sizeof(int));
989                                 offset += sizeof(int);
990
991                                 memcpy(&pMedia->sMedia.sText.nBgColor, pData + offset, sizeof(int));
992                                 offset += sizeof(int);
993
994                                 memcpy(&pMedia->sMedia.sText.bBold, pData + offset, sizeof(bool));
995                                 offset += sizeof(bool);
996
997                                 memcpy(&pMedia->sMedia.sText.bUnderLine, pData + offset, sizeof(bool));
998                                 offset += sizeof(bool);
999
1000                                 memcpy(&pMedia->sMedia.sText.bItalic, pData + offset, sizeof(bool));
1001                                 offset += sizeof(bool);
1002
1003                                 memcpy(&pMedia->sMedia.sText.bReverse, pData + offset, sizeof(bool));
1004                                 offset += sizeof(bool);
1005
1006                                 memcpy(&pMedia->sMedia.sText.nDirection, pData + offset, sizeof(MmsTextDirection));
1007                                 offset += sizeof(MmsTextDirection);
1008
1009                                 //memcpy(&pMedia->sMedia.sText.nFont, pData + offset, sizeof(MmsSmilFontType));
1010                                 //offset += sizeof(MmsSmilFontType);
1011
1012                                 memcpy(&pMedia->sMedia.sText.nSize, pData + offset, sizeof(int));
1013                                 offset += sizeof(int);
1014
1015                                 memcpy(&pMedia->sMedia.sText.nColor, pData + offset, sizeof(int));
1016                                 offset += sizeof(int);
1017                         } else {
1018                                 MSG_DEBUG("##### MEDIA TYPE = IMAGE, AUDIO, VIDEO #####");
1019                                 memcpy(pMedia->sMedia.sAVI.szTransInId, pData + offset, MAX_SMIL_TRANSIN_ID);
1020                                 offset += MAX_SMIL_TRANSIN_ID;
1021
1022                                 memcpy(pMedia->sMedia.sAVI.szTransOutId, pData + offset, MAX_SMIL_TRANSOUT_ID);
1023                                 offset += MAX_SMIL_TRANSOUT_ID;
1024
1025                                 memcpy(&pMedia->sMedia.sAVI.nRepeat, pData + offset, sizeof(int));
1026                                 offset += sizeof(int);
1027
1028                                 memcpy(&pMedia->sMedia.sAVI.nBegin, pData + offset, sizeof(int));
1029                                 offset += sizeof(int);
1030
1031                                 memcpy(&pMedia->sMedia.sAVI.nEnd, pData + offset, sizeof(int));
1032                                 offset += sizeof(int);
1033
1034                                 memcpy(&pMedia->sMedia.sAVI.nDurTime, pData + offset, sizeof(int));
1035                                 offset += sizeof(int);
1036
1037                                 memcpy(&pMedia->sMedia.sAVI.nBgColor, pData + offset, sizeof(int));
1038                                 offset += sizeof(int);
1039                         }
1040                         pPage->medialist = g_list_append(pPage->medialist, pMedia);
1041                 }
1042
1043                 memcpy(&pPage->nDur , pData + offset, sizeof(int));
1044                 offset += sizeof(int);
1045                 memcpy(&pPage->nBegin , pData + offset, sizeof(int));
1046                 offset += sizeof(int);
1047                 memcpy(&pPage->nEnd , pData + offset, sizeof(int));
1048                 offset += sizeof(int);
1049                 memcpy(&pPage->nMin , pData + offset, sizeof(int));
1050                 offset += sizeof(int);
1051                 memcpy(&pPage->nMax , pData + offset, sizeof(int));
1052                 offset += sizeof(int);
1053                 memcpy(&pPage->nRepeat , pData + offset, sizeof(int));
1054                 offset += sizeof(int);
1055
1056                 pBody->pagelist = g_list_append(pBody->pagelist, pPage);
1057         }
1058
1059         //Processing Region List
1060         memcpy(&pBody->regionCnt, pData + offset, sizeof(int));
1061         offset += sizeof(int);
1062
1063         MSG_DEBUG(" pBody->regionCnt: %d", pBody->regionCnt);
1064
1065         for (int i = 0; i < pBody->regionCnt; ++i) {
1066                 pRegion = (MMS_SMIL_REGION *)calloc(sizeof(MMS_SMIL_REGION), 1);
1067
1068                 memcpy(pRegion->szID, pData + offset, MAX_SMIL_REGION_ID);
1069                 offset += MAX_SMIL_REGION_ID;
1070                 memcpy(&pRegion->nLeft, pData + offset, sizeof(MMS_LENGTH));
1071                 offset += sizeof(MMS_LENGTH);
1072                 memcpy(&pRegion->nTop, pData + offset, sizeof(MMS_LENGTH));
1073                 offset += sizeof(MMS_LENGTH);
1074                 memcpy(&pRegion->width, pData + offset, sizeof(MMS_LENGTH));
1075                 offset += sizeof(MMS_LENGTH);
1076                 memcpy(&pRegion->height, pData + offset, sizeof(MMS_LENGTH));
1077                 offset += sizeof(MMS_LENGTH);
1078                 memcpy(&pRegion->bgColor, pData + offset, sizeof(int));
1079                 offset += sizeof(int);
1080                 memcpy(&pRegion->fit, pData + offset, sizeof(REGION_FIT_TYPE_T));
1081                 offset += sizeof(REGION_FIT_TYPE_T);
1082
1083                 pBody->regionlist = g_list_append(pBody->regionlist, pRegion);
1084         }
1085
1086         //Processing Attachment List
1087         memcpy(&pBody->attachCnt, pData + offset, sizeof(int));
1088         offset += sizeof(int);
1089
1090         MSG_DEBUG(" pBody->attachCnt: %d", pBody->attachCnt);
1091
1092         for (int i = 0; i < pBody->attachCnt; ++i) {
1093                 pAttach = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1);
1094
1095                 memcpy(&pAttach->mediatype, pData + offset, sizeof(MimeType));
1096                 offset += sizeof(MimeType);
1097
1098                 memcpy(pAttach->szFileName, pData + offset, MSG_FILENAME_LEN_MAX);
1099                 offset += MSG_FILENAME_LEN_MAX;
1100
1101                 memcpy(pAttach->szFilePath, pData + offset, MSG_FILEPATH_LEN_MAX);
1102                 offset += MSG_FILEPATH_LEN_MAX;
1103
1104                 memcpy(&pAttach->fileSize, pData + offset, sizeof(int));
1105                 offset += sizeof(int);
1106
1107 #ifdef __SUPPORT_DRM__
1108                 memcpy(&pAttach->drmType, pData + offset, sizeof(MsgDrmType));
1109                 offset += sizeof(MsgDrmType);
1110
1111                 memcpy(pAttach->szDrm2FullPath, pData + offset, MSG_FILEPATH_LEN_MAX);
1112                 offset += MSG_FILEPATH_LEN_MAX;
1113 #endif
1114
1115                 pBody->attachlist = g_list_append(pBody->attachlist, pAttach);
1116         }
1117
1118         //Processing Transition List
1119         memcpy(&pBody->transitionCnt, pData + offset, sizeof(int));
1120         offset += sizeof(int);
1121
1122         MSG_DEBUG(" pBody->transitionCnt: %d", pBody->transitionCnt);
1123
1124         for (int i = 0; i < pBody->transitionCnt; ++i) {
1125                 pTransition = (MMS_SMIL_TRANSITION *)calloc(sizeof(MMS_SMIL_TRANSITION), 1);
1126
1127                 memcpy(pTransition->szID, pData + offset, MAX_SMIL_TRANSITION_ID);
1128                 offset += MAX_SMIL_TRANSITION_ID;
1129
1130                 memcpy(&pTransition->nType, pData + offset, sizeof(MmsSmilTransType));
1131                 offset += sizeof(MmsSmilTransType);
1132                 memcpy(&pTransition->nSubType, pData + offset, sizeof(MmsSmilTransSubType));
1133                 offset += sizeof(MmsSmilTransSubType);
1134                 memcpy(&pTransition->nDur, pData + offset, sizeof(int));
1135                 offset += sizeof(int);
1136
1137                 pBody->transitionlist = g_list_append(pBody->transitionlist, pTransition);
1138         }
1139
1140         //Processing Meta List
1141         memcpy(&pBody->metaCnt, pData + offset, sizeof(int));
1142         offset += sizeof(int);
1143
1144         MSG_DEBUG(" pBody->metaCnt: %d", pBody->metaCnt);
1145
1146         for (int i = 0; i < pBody->metaCnt; ++i) {
1147                 pMeta = (MMS_SMIL_META *)calloc(sizeof(MMS_SMIL_META), 1);
1148
1149                 memcpy(pMeta->szID, pData + offset, MAX_SMIL_META_ID);
1150                 offset += MAX_SMIL_META_ID;
1151
1152                 memcpy(pMeta->szName, pData + offset, MAX_SMIL_META_NAME);
1153                 offset += MAX_SMIL_META_NAME;
1154
1155                 memcpy(pMeta->szContent, pData + offset, MAX_SMIL_META_CONTENT);
1156                 offset += MAX_SMIL_META_CONTENT;
1157
1158                 pBody->metalist = g_list_append(pBody->metalist, pMeta);
1159         }
1160
1161         memcpy(&pBody->rootlayout, pData + offset, sizeof(MMS_SMIL_ROOTLAYOUT));
1162         offset += sizeof(MMS_SMIL_ROOTLAYOUT);
1163
1164 #ifdef FEATURE_JAVA_MMS
1165         memcpy(&pBody->msgAppId, pData + offset, sizeof(MMS_APPID_INFO_S));
1166         offset += sizeof(MMS_APPID_INFO_S);
1167         MSG_DEBUG("java_app_id valid:%d, appId:%s repleToAppId:%s", pBody->msgAppId.valid, pBody->msgAppId.appId, pBody->msgAppId.replyToAppId);
1168 #endif
1169         //free(pData);
1170
1171         return true;
1172 }
1173
1174 bool    _MsgMmsSetRootLayout(MMS_MESSAGE_DATA_S* pMmsMsg, MMS_SMIL_ROOTLAYOUT* pRootlayout)
1175 {
1176         memcpy(&pMmsMsg->rootlayout, pRootlayout, sizeof(MMS_SMIL_ROOTLAYOUT));
1177         return true;
1178 }
1179