Merge branch 'master' into tizen_2.0
[platform/core/messaging/msg-service.git] / mapi / msg_message.cpp
1 /*
2 * Copyright 2012-2013  Samsung Electronics Co., Ltd
3 *
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
7 *
8 *    http://floralicense.org
9 *
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.
15 */
16
17 #include <string.h>
18
19 #include "MsgTypes.h"
20 #include "MsgStorageTypes.h"
21 #include "MsgInternalTypes.h"
22 #include "MsgMmsMessage.h"
23
24 #include "msg.h"
25 #include "msg_private.h"
26
27 void msg_message_create_struct(msg_struct_s *msg_struct)
28 {
29         MSG_MESSAGE_HIDDEN_S *msg = (MSG_MESSAGE_HIDDEN_S *)new MSG_MESSAGE_HIDDEN_S;
30         memset(msg, 0x00, sizeof(MSG_MESSAGE_HIDDEN_S));
31
32         /* set default value to message*/
33         msg->msgId = 0;
34         msg->threadId = 0;
35         msg->folderId = MSG_DRAFT_ID;
36         msg->mainType= MSG_SMS_TYPE;
37         msg->subType = MSG_NORMAL_SMS;
38         msg->classType = MSG_CLASS_NONE;
39         msg->storageId = MSG_STORAGE_PHONE;
40         time_t curTime = time(NULL);
41         msg->displayTime = curTime;
42         msg->networkStatus = MSG_NETWORK_NOT_SEND;
43         msg->encodeType = MSG_ENCODE_AUTO;
44         msg->bRead = false;
45         msg->bProtected = false;
46         msg->bBackup = false;
47         msg->priority = MSG_MESSAGE_PRIORITY_NORMAL;
48         msg->direction = MSG_DIRECTION_TYPE_MO;
49         msg->bPortValid = false;
50         msg->dataSize = 0;
51         msg->pData = NULL;
52         msg->pMmsData = NULL;
53
54         /* Allocate memory for address list of message */
55         msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
56
57         addr_list->nCount = 0;
58         addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
59
60         msg_struct_s *pTmp = NULL;
61
62         for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
63                 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
64                 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
65                 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
66                 pTmp->data = new MSG_ADDRESS_INFO_S;
67                 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
68
69                 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
70         }
71
72         msg->addr_list = addr_list;
73
74         msg_struct->data = (int *)msg;
75 }
76
77 int msg_message_release(msg_struct_s **msg_struct)
78 {
79         MSG_MESSAGE_HIDDEN_S *msg = (MSG_MESSAGE_HIDDEN_S *)(*msg_struct)->data;
80
81         if (msg->pData) {
82                 delete [] static_cast<char*>(msg->pData);
83                 msg->pData = NULL;
84         }
85
86         if (msg->pMmsData) {
87                 delete [] static_cast<char*>(msg->pMmsData);
88                 msg->pMmsData = NULL;
89         }
90
91         // Memory Free
92         if (msg->addr_list!= NULL)
93         {
94                 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
95                         msg_struct_s * addrInfo = (msg_struct_s *)msg->addr_list->msg_struct_info[i];
96                         delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
97                         addrInfo->data = NULL;
98                         delete (msg_struct_s *)msg->addr_list->msg_struct_info[i];
99                         msg->addr_list->msg_struct_info[i] = NULL;
100                 }
101
102                 delete [] msg->addr_list->msg_struct_info;
103
104                 delete msg->addr_list;
105                 msg->addr_list = NULL;
106         }
107
108         delete msg;
109         (*msg_struct)->data = NULL;
110
111         delete (msg_struct_s *)*msg_struct;
112         *msg_struct = NULL;
113
114         return MSG_SUCCESS;
115 }
116
117 int msg_message_get_int_value(void *data, int field, int *value)
118 {
119         if (!data)
120                 return MSG_ERR_NULL_POINTER;
121
122         int ret = MSG_SUCCESS;
123
124         MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data;
125
126         switch (field)
127         {
128         case MSG_MESSAGE_ID_INT :
129                 *value = msg_data->msgId;
130                 break;
131         case MSG_MESSAGE_THREAD_ID_INT :
132                 *value = msg_data->threadId;
133                 break;
134         case MSG_MESSAGE_FOLDER_ID_INT :
135                 *value = msg_data->folderId;
136                 break;
137         case MSG_MESSAGE_TYPE_INT :
138         {
139         if (msg_data->mainType == MSG_SMS_TYPE)
140         {
141                         if (msg_data->subType == MSG_CB_SMS)
142                                 *value = MSG_TYPE_SMS_CB;
143                         else if (msg_data->subType == MSG_JAVACB_SMS)
144                                 *value = MSG_TYPE_SMS_JAVACB;
145                         else if (msg_data->subType == MSG_WAP_SI_SMS || msg_data->subType == MSG_WAP_SL_SMS)
146                                 *value = MSG_TYPE_SMS_WAPPUSH;
147                         else if (msg_data->subType == MSG_MWI_VOICE_SMS || msg_data->subType == MSG_MWI_FAX_SMS
148                                         || msg_data->subType == MSG_MWI_EMAIL_SMS || msg_data->subType == MSG_MWI_OTHER_SMS)
149                                 *value = MSG_TYPE_SMS_MWI;
150                         else if (msg_data->subType == MSG_SYNCML_CP)
151                                 *value = MSG_TYPE_SMS_SYNCML;
152                         else if (msg_data->subType == MSG_REJECT_SMS)
153                                 *value = MSG_TYPE_SMS_REJECT;
154                         else if (msg_data->subType == MSG_ETWS_SMS)
155                                 *value = MSG_TYPE_SMS_ETWS_PRIMARY;
156                         else
157                                 *value = MSG_TYPE_SMS;
158         }
159         else if (msg_data->mainType == MSG_MMS_TYPE)
160         {
161                         if (msg_data->subType == MSG_NOTIFICATIONIND_MMS)
162                                 *value = MSG_TYPE_MMS_NOTI;
163                         else if (msg_data->subType == MSG_SENDREQ_JAVA_MMS)
164                                 *value = MSG_TYPE_MMS_JAVA;
165                         else
166                                 *value = MSG_TYPE_MMS;
167         }
168         else
169                 *value = MSG_TYPE_INVALID;
170
171         break;
172         }
173         case MSG_MESSAGE_CLASS_TYPE_INT :
174                 *value = msg_data->classType;
175                 break;
176         case MSG_MESSAGE_STORAGE_ID_INT :
177                 *value = msg_data->storageId;
178                 break;
179         case MSG_MESSAGE_DISPLAY_TIME_INT :
180                 *value = msg_data->displayTime;
181                 break;
182         case MSG_MESSAGE_NETWORK_STATUS_INT :
183                 *value = msg_data->networkStatus;
184                 break;
185         case MSG_MESSAGE_ENCODE_TYPE_INT :
186                 *value = msg_data->encodeType;
187                 break;
188         case MSG_MESSAGE_PRIORITY_INT :
189                 *value = msg_data->priority;
190                 break;
191         case MSG_MESSAGE_DIRECTION_INT :
192                 *value = msg_data->direction;
193                 break;
194         case MSG_MESSAGE_DEST_PORT_INT :
195                 *value = msg_data->dstPort;
196                 break;
197         case MSG_MESSAGE_SRC_PORT_INT :
198                 *value = msg_data->srcPort;
199                 break;
200         case MSG_MESSAGE_ATTACH_COUNT_INT :
201                 *value = msg_data->attachCount;
202                 break;
203         case MSG_MESSAGE_DATA_SIZE_INT :
204                 *value = msg_data->dataSize;
205                 break;
206         default :
207                 ret = MSG_ERR_INVALID_PARAMETER;
208                 break;
209         }
210
211         return ret;
212 }
213
214 int msg_message_get_bool_value(void *data, int field, bool *value)
215 {
216         if (!data)
217                 return MSG_ERR_NULL_POINTER;
218
219         int ret = MSG_SUCCESS;
220
221         MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data;
222
223         switch (field) {
224         case MSG_MESSAGE_READ_BOOL :
225                 *value = msg_data->bRead;
226                 break;
227         case MSG_MESSAGE_PROTECTED_BOOL :
228                 *value = msg_data->bProtected;
229                 break;
230         case MSG_MESSAGE_BACKUP_BOOL :
231                 *value = msg_data->bBackup;
232                 break;
233         case MSG_MESSAGE_PORT_VALID_BOOL :
234                 *value = msg_data->bPortValid;
235                 break;
236         default :
237                 ret = MSG_ERR_INVALID_PARAMETER;
238                 break;
239         }
240
241         return ret;
242 }
243
244 int msg_message_get_str_value(void *data, int field, char *value, int size)
245 {
246         if (!data || !value)
247                 return MSG_ERR_NULL_POINTER;
248
249         int ret = MSG_SUCCESS;
250
251         MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data;
252
253         switch (field) {
254         case MSG_MESSAGE_REPLY_ADDR_STR :
255                 strncpy(value, msg_data->replyAddress, size);
256                 break;
257         case MSG_MESSAGE_SUBJECT_STR :
258                 strncpy(value, msg_data->subject, size);
259                 break;
260         case MSG_MESSAGE_THUMBNAIL_PATH_STR :
261                 strncpy(value, msg_data->thumbPath, size);
262                 break;
263         case MSG_MESSAGE_SMS_DATA_STR :
264         case MSG_MESSAGE_MMS_TEXT_STR :
265                 if (msg_data->pData)
266                 {
267                         if (msg_data->mainType == MSG_SMS_TYPE) {
268                                 int data_len = 0;
269                                 ((size_t)size >= msg_data->dataSize)? (data_len = msg_data->dataSize) : data_len = size;
270                                 memset(value, 0, size);
271                                 memcpy(value, msg_data->pData, data_len);
272                         } else if (msg_data->mainType == MSG_MMS_TYPE) {
273                                 memset(value, 0, size);
274                                 strncpy(value, (char *)msg_data->pData, size);
275                         }
276                 }
277                 break;
278
279         default :
280                 ret = MSG_ERR_INVALID_PARAMETER;
281                 break;
282         }
283
284         return ret;
285 }
286
287 int msg_message_get_struct_hnd(void *data, int field, void **value)
288 {
289         if (!data)
290                 return MSG_ERR_NULL_POINTER;
291
292         int ret = MSG_SUCCESS;
293
294         switch (field) {
295         default :
296                 ret = MSG_ERR_INVALID_PARAMETER;
297                 break;
298         }
299
300         return ret;
301 }
302
303 int msg_message_get_list_hnd(void *data, int field, void **value)
304 {
305         if (!data)
306                 return MSG_ERR_NULL_POINTER;
307
308         int ret = MSG_SUCCESS;
309
310         MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data;
311
312         switch (field) {
313         case MSG_MESSAGE_ADDR_LIST_STRUCT :
314                 *value = (void *)msg_data->addr_list;
315                 break;
316         default :
317                 ret = MSG_ERR_INVALID_PARAMETER;
318                 break;
319         }
320
321         return ret;
322 }
323
324 int msg_message_set_int_value(void *data, int field, int value)
325 {
326         if (!data)
327                 return MSG_ERR_NULL_POINTER;
328
329         int ret = MSG_SUCCESS;
330
331         MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data;
332
333         switch (field)
334         {
335         case MSG_MESSAGE_ID_INT :
336                 msg_data->msgId = value;
337                 break;
338         case MSG_MESSAGE_THREAD_ID_INT :
339                 msg_data->threadId = value;
340                 break;
341         case MSG_MESSAGE_FOLDER_ID_INT :
342                 msg_data->folderId = value;
343                 break;
344         case MSG_MESSAGE_TYPE_INT :
345         {
346                 if (value == MSG_TYPE_SMS) {
347                         msg_data->mainType = MSG_SMS_TYPE;
348                         msg_data->subType = MSG_NORMAL_SMS;
349                 }
350                 else if (value == MSG_TYPE_MMS) {
351                         msg_data->mainType = MSG_MMS_TYPE;
352                         msg_data->subType = MSG_SENDREQ_MMS;
353                 }
354                 else if (value == MSG_TYPE_MMS_JAVA) {
355                         msg_data->mainType = MSG_MMS_TYPE;
356                         msg_data->subType = MSG_SENDREQ_JAVA_MMS;
357                 }
358                 else if (value == MSG_TYPE_SMS_SYNCML) {
359                         msg_data->mainType = MSG_SMS_TYPE;
360                         msg_data->subType = MSG_SYNCML_CP;
361                 }
362                 else if (value == MSG_TYPE_SMS_REJECT) {
363                         msg_data->mainType = MSG_SMS_TYPE;
364                         msg_data->subType = MSG_REJECT_SMS;
365                 }
366                 else if (value == MSG_TYPE_SMS_ETWS_PRIMARY) {
367                         msg_data->mainType = MSG_SMS_TYPE;
368                         msg_data->subType = MSG_ETWS_SMS;
369                 }
370         break;
371         }
372         case MSG_MESSAGE_CLASS_TYPE_INT :
373                 msg_data->classType = value;
374                 break;
375         case MSG_MESSAGE_STORAGE_ID_INT :
376                 msg_data->storageId = value;
377                 break;
378         case MSG_MESSAGE_DISPLAY_TIME_INT :
379                 msg_data->displayTime = value;
380                 break;
381         case MSG_MESSAGE_NETWORK_STATUS_INT :
382                 msg_data->networkStatus = value;
383                 break;
384         case MSG_MESSAGE_ENCODE_TYPE_INT :
385                 msg_data->encodeType = value;
386                 break;
387         case MSG_MESSAGE_PRIORITY_INT :
388                 msg_data->priority = value;
389                 break;
390         case MSG_MESSAGE_DIRECTION_INT :
391                 msg_data->direction = value;
392                 break;
393         case MSG_MESSAGE_DEST_PORT_INT :
394                 msg_data->dstPort = value;
395                 break;
396         case MSG_MESSAGE_SRC_PORT_INT :
397                 msg_data->srcPort = value;
398                 break;
399         case MSG_MESSAGE_ATTACH_COUNT_INT :
400                  msg_data->attachCount = value;
401                 break;
402         case MSG_MESSAGE_DATA_SIZE_INT :
403                 msg_data->dataSize = value;
404                 break;
405         default :
406                 ret = MSG_ERR_INVALID_PARAMETER;
407                 break;
408         }
409
410         return ret;
411 }
412
413 int msg_message_set_bool_value(void *data, int field, bool value)
414 {
415         if (!data)
416                 return MSG_ERR_NULL_POINTER;
417
418         int ret = MSG_SUCCESS;
419
420         MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data;
421
422         switch (field) {
423         case MSG_MESSAGE_READ_BOOL :
424                 msg_data->bRead = value;
425                 break;
426         case MSG_MESSAGE_PROTECTED_BOOL :
427                 msg_data->bProtected = value;
428                 break;
429         case MSG_MESSAGE_BACKUP_BOOL :
430                 msg_data->bBackup = value;
431                 break;
432         case MSG_MESSAGE_PORT_VALID_BOOL :
433                 msg_data->bPortValid = value;
434                 break;
435         default :
436                 ret = MSG_ERR_INVALID_PARAMETER;
437                 break;
438         }
439
440         return ret;
441 }
442
443 int msg_message_set_str_value(void *data, int field, char *value, int size)
444 {
445         if (!data || !value)
446                 return MSG_ERR_NULL_POINTER;
447
448         int ret = MSG_SUCCESS;
449
450         MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data;
451
452         switch (field) {
453         case MSG_MESSAGE_REPLY_ADDR_STR :
454                 snprintf(msg_data->replyAddress, sizeof(msg_data->replyAddress), "%s", value);
455                 break;
456         case MSG_MESSAGE_SUBJECT_STR :
457                 snprintf(msg_data->subject, sizeof(msg_data->subject), "%s",value);
458                 break;
459         case MSG_MESSAGE_THUMBNAIL_PATH_STR :
460                 snprintf(msg_data->thumbPath, sizeof(msg_data->thumbPath), "%s",value);
461                 break;
462         case MSG_MESSAGE_SMS_DATA_STR :
463         {
464                 if (msg_data->pData)
465                         delete [] static_cast<char*>(msg_data->pData);
466
467                 msg_data->dataSize = size;
468                 msg_data->pData = (void*)new char[msg_data->dataSize+1];
469                 memcpy((char *)msg_data->pData, value, msg_data->dataSize);
470                 ((char*) msg_data->pData)[msg_data->dataSize] = '\0';
471         }
472                 break;
473         default :
474                 ret = MSG_ERR_INVALID_PARAMETER;
475                 break;
476         }
477
478         return ret;
479 }
480
481 int msg_message_set_struct_hnd(void *data, int field, void *value)
482 {
483         if (!data)
484                 return MSG_ERR_NULL_POINTER;
485
486         int ret = MSG_SUCCESS;
487
488         switch (field) {
489         default :
490                 ret = MSG_ERR_INVALID_PARAMETER;
491                 break;
492         }
493
494         return ret;
495 }
496
497 void msg_message_copy_message(MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_HIDDEN_S *pDst)
498 {
499
500         pDst->msgId = pSrc->msgId;
501         pDst->threadId = pSrc->msgId;
502         pDst->folderId = pSrc->folderId;
503         pDst->mainType = pSrc->mainType;
504         pDst->subType = pSrc->subType;
505         pDst->classType = pSrc->classType;
506         pDst->storageId = pSrc->storageId;
507         pDst->displayTime = pSrc->displayTime;
508         pDst->networkStatus = pSrc->networkStatus;
509         pDst->encodeType = pSrc->encodeType;
510         pDst->bRead = pSrc->bRead;
511         pDst->bProtected = pSrc->bProtected;
512         pDst->bBackup = pSrc->bBackup;
513         pDst->priority = pSrc->priority;
514         pDst->direction = pSrc->direction;
515         pDst->bPortValid = pSrc->bPortValid;
516         pDst->dataSize = pSrc->dataSize;
517         memcpy(pDst->subject, pSrc->subject, sizeof(pDst->subject));
518         if(pSrc->dataSize)
519         {
520                 if(pSrc->pMmsData)
521                 {
522                         pDst->pMmsData = new char[pSrc->dataSize + 1];
523                         memcpy(pDst->pMmsData, pSrc->pMmsData, pSrc->dataSize);
524                 }
525                 if(pSrc->pData)
526                 {
527                         int data_len = strlen((const char *)pSrc->pData);
528                         pDst->pData = new char[data_len + 1];
529                         memset(pDst->pData, 0x00, data_len + 1);
530                         strncpy((char *)pDst->pData, (const char *)pSrc->pData, data_len);
531                 }
532         }
533         msg_struct_list_s *src_addrlist = pSrc->addr_list;
534         msg_struct_list_s *dst_addrlist = pDst->addr_list;
535         dst_addrlist->nCount = src_addrlist->nCount;
536
537         for(int i=0; i < MAX_TO_ADDRESS_CNT; ++i)
538         {
539                 msg_struct_s *src_addr = (msg_struct_s *)src_addrlist->msg_struct_info[i];
540                 msg_struct_s *dst_addr = (msg_struct_s *)dst_addrlist->msg_struct_info[i];
541                 memcpy(dst_addr->data, src_addr->data, sizeof(MSG_ADDRESS_INFO_S));
542         }
543
544         if (strlen(pSrc->thumbPath) > 0) {
545                 memset(pDst->thumbPath, 0x00, sizeof(pDst->thumbPath));
546                 memcpy(pDst->thumbPath, pSrc->thumbPath, sizeof(pDst->thumbPath));
547         }
548
549 }
550
551 int msg_cb_message_get_int_value(void *data, int field, int *value)
552 {
553         if (!data)
554                 return MSG_ERR_NULL_POINTER;
555
556         int ret = MSG_SUCCESS;
557
558         MSG_CB_MSG_S *cb_msg = (MSG_CB_MSG_S *)data;
559
560         *value = 0;
561
562         switch (field)
563         {
564                 case MSG_CB_MSG_TYPE_INT :
565                         {
566                                 if ( cb_msg->type == MSG_ETWS_SMS )
567                                         *value = MSG_TYPE_SMS_ETWS_PRIMARY;
568                                 else if ( cb_msg->type == MSG_CB_SMS )
569                                         *value = ((cb_msg->messageId & 0xFFF8) == 0x1100 ) ? MSG_TYPE_SMS_ETWS_SECONDARY : MSG_TYPE_SMS_CB;
570                                 else
571                                         ret = MSG_ERR_UNKNOWN;
572                         }
573                         break;
574                 case MSG_CB_MSG_RECV_TIME_INT :
575                         *value = cb_msg->receivedTime;
576                         break;
577                 case MSG_CB_MSG_SERIAL_NUM_INT :
578                         *value = cb_msg->serialNum;
579                         break;
580                 case MSG_CB_MSG_MSG_ID_INT :
581                         *value = cb_msg->messageId;
582                         break;
583                 case MSG_CB_MSG_DCS_INT :
584                         *value = (int)cb_msg->dcs;
585                         break;
586                 case MSG_CB_MSG_CB_TEXT_LEN_INT :
587                         *value = cb_msg->cbTextLen;
588                         break;
589                 case MSG_CB_MSG_ETWS_WARNING_TYPE_INT :
590                         *value = cb_msg->etwsWarningType;
591                         break;
592                 default :
593                         ret = MSG_ERR_INVALID_PARAMETER;
594                         break;
595         }
596
597         return ret;
598 }
599
600 int msg_cb_message_get_str_value(void *data, int field, char *value, int size)
601 {
602         if (!data || !value)
603                 return MSG_ERR_NULL_POINTER;
604
605         int ret = MSG_SUCCESS;
606
607         MSG_CB_MSG_S *cb_msg = (MSG_CB_MSG_S *)data;
608
609         switch (field) {
610                 case MSG_CB_MSG_CB_TEXT_STR:
611                         {
612                                 int     copylen = 0;
613                                 copylen = (size > cb_msg->cbTextLen) ? cb_msg->cbTextLen : size - 1;
614                                 memcpy (value, cb_msg->cbText, copylen);
615                                 value[copylen] = '\0';
616                         }
617                         break;
618                 case MSG_CB_MSG_LANGUAGE_TYPE_STR:
619                         {
620                                 int     copylen = 0;
621                                 copylen = ((size_t)size > strlen((const char*)cb_msg->language_type)) ? strlen((const char*)cb_msg->language_type) : size - 1;
622                                 memcpy (value, cb_msg->language_type, copylen);
623                                 value[copylen] = '\0';
624                         }
625                         break;
626                 case MSG_CB_MSG_ETWS_WARNING_SECU_INFO_STR:
627                         {
628                                 if ((size_t)size < sizeof(cb_msg->etwsWarningSecurityInfo))
629                                         ret = MSG_ERR_INVALID_PARAMETER;
630                                 else
631                                         memcpy (value, cb_msg->etwsWarningSecurityInfo, sizeof(cb_msg->etwsWarningSecurityInfo));
632                         }
633                         break;
634
635                 default :
636                         ret = MSG_ERR_INVALID_PARAMETER;
637                         break;
638         }
639
640         return ret;
641 }
642
643
644
645 EXPORT_API int msg_get_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t mms_struct_handle)
646 {
647         //TODO :: check message type is MMS
648         int ret = MSG_SUCCESS;
649         msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
650         msg_struct_s *mms_struct = (msg_struct_s *)mms_struct_handle;
651
652         if (msg_struct == NULL || mms_struct == NULL) {
653                 return MSG_ERR_INVALID_PARAMETER;
654         }
655
656         if (msg_struct->data == NULL || mms_struct->data == NULL) {
657                 return MSG_ERR_INVALID_PARAMETER;
658         }
659
660         if (msg_struct->type != MSG_STRUCT_MESSAGE_INFO || mms_struct->type != MSG_STRUCT_MMS) {
661                 return MSG_ERR_INVALID_PARAMETER;
662         }
663
664         MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data;
665
666         MMS_MESSAGE_DATA_S *tmp_mms_data  = (MMS_MESSAGE_DATA_S *)calloc(1, sizeof(MMS_MESSAGE_DATA_S));
667
668         _MsgMmsDeserializeMessageData(tmp_mms_data, (char*)msg_data->pMmsData);
669
670         convert_from_mmsdata(tmp_mms_data, mms_struct);
671
672         _MsgMmsReleasePageList(tmp_mms_data);
673         _MsgMmsReleaseRegionList(tmp_mms_data);
674         _MsgMmsReleaseAttachList(tmp_mms_data);
675         _MsgMmsReleaseTransitionList(tmp_mms_data);
676         _MsgMmsReleaseMetaList(tmp_mms_data);
677         free(tmp_mms_data);
678
679         return ret;
680 }
681
682 EXPORT_API int msg_set_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t mms_struct_handle)
683 {
684         //TODO :: check message type is MMS
685         int ret = MSG_SUCCESS;
686         msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
687         msg_struct_s *mms_struct = (msg_struct_s *)mms_struct_handle;
688
689         if (msg_struct == NULL || mms_struct == NULL) {
690                 return MSG_ERR_INVALID_PARAMETER;
691         }
692
693         if (msg_struct->data == NULL || mms_struct->data == NULL) {
694                 return MSG_ERR_INVALID_PARAMETER;
695         }
696
697         if (msg_struct->type != MSG_STRUCT_MESSAGE_INFO || mms_struct->type != MSG_STRUCT_MMS) {
698                 return MSG_ERR_INVALID_PARAMETER;
699         }
700
701         MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data;
702
703         MMS_MESSAGE_DATA_S *tmp_mms_data = (MMS_MESSAGE_DATA_S *)calloc(1,sizeof(MMS_MESSAGE_DATA_S));
704
705         convert_to_mmsdata(mms_struct, tmp_mms_data);
706
707         msg_data->pMmsData = _MsgMmsSerializeMessageData(tmp_mms_data, &(msg_data->dataSize));
708
709         _MsgMmsReleasePageList(tmp_mms_data);
710         _MsgMmsReleaseRegionList(tmp_mms_data);
711         _MsgMmsReleaseAttachList(tmp_mms_data);
712         _MsgMmsReleaseTransitionList(tmp_mms_data);
713         _MsgMmsReleaseMetaList(tmp_mms_data);
714         free(tmp_mms_data);
715         return ret;
716 }
717