2 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "MsgHandle.h"
22 #include "MsgTextConvert.h"
23 #include "MsgException.h"
24 #include "MsgMemory.h"
26 #include "msg_private.h"
29 void __msg_release_list_item(gpointer data)
34 msg_release_struct((msg_struct_t*)(&data));
38 EXPORT_API msg_struct_t msg_create_struct(int field)
40 CHECK_MSG_SUPPORTED_RETURN_NULL(MSG_TELEPHONY_SMS_FEATURE);
41 msg_struct_s *msg_struct = new msg_struct_s;
42 memset(msg_struct, 0x00, sizeof(msg_struct_s));
44 msg_struct->type = field;
45 msg_struct->data = NULL;
48 case MSG_STRUCT_MESSAGE_INFO:
49 msg_message_create_struct(msg_struct);
51 case MSG_STRUCT_CONV_INFO: {
52 msg_struct->data = (void *)new MSG_CONVERSATION_VIEW_S;
53 memset(msg_struct->data, 0x00, sizeof(MSG_CONVERSATION_VIEW_S));
56 case MSG_STRUCT_FILTER: {
57 msg_struct->data = (void *)new MSG_FILTER_S;
58 memset(msg_struct->data, 0x00, sizeof(MSG_FILTER_S));
61 case MSG_STRUCT_THREAD_INFO: {
62 msg_struct->data = (void *)new MSG_THREAD_VIEW_S;
63 memset(msg_struct->data, 0x00, sizeof(MSG_THREAD_VIEW_S));
66 case MSG_STRUCT_SENDOPT: {
67 MSG_SENDINGOPT_S *pOpt = (MSG_SENDINGOPT_S *)new MSG_SENDINGOPT_S;
68 memset(pOpt, 0x00, sizeof(MSG_SENDINGOPT_S));
69 msg_struct->data = pOpt;
71 msg_struct_s *pSms = new msg_struct_s;
72 msg_struct_s *pMms = new msg_struct_s;
74 pOpt->mmsSendOpt = (msg_struct_t)pMms;
75 pOpt->smsSendOpt = (msg_struct_t)pSms;
77 pMms->type = MSG_STRUCT_MMS_SENDOPT;
78 pMms->data = new MMS_SENDINGOPT_S;
79 memset(pMms->data, 0x00, sizeof(MMS_SENDINGOPT_S));
81 pSms->type = MSG_STRUCT_SMS_SENDOPT;
82 pSms->data = new SMS_SENDINGOPT_S;
83 memset(pSms->data, 0x00, sizeof(SMS_SENDINGOPT_S));
86 case MSG_STRUCT_SYNCML_INFO: {
87 MSG_SYNCML_MESSAGE_S *pSyncML = (MSG_SYNCML_MESSAGE_S *)new MSG_SYNCML_MESSAGE_S;
88 memset(pSyncML, 0x00, sizeof(MSG_SYNCML_MESSAGE_S));
89 msg_struct->data = pSyncML;
91 msg_struct_s *pStruct = new msg_struct_s;
92 pSyncML->msg = (msg_struct_t)pStruct;
93 pStruct->type = MSG_STRUCT_MESSAGE_INFO;
94 msg_message_create_struct(pStruct);
98 case MSG_STRUCT_COUNT_INFO: {
99 msg_struct->data = new MSG_COUNT_INFO_S;
100 memset(msg_struct->data, 0x00, sizeof(MSG_COUNT_INFO_S));
103 case MSG_STRUCT_THREAD_COUNT_INFO: {
104 msg_struct->data = new MSG_THREAD_COUNT_INFO_S;
105 memset(msg_struct->data, 0x00, sizeof(MSG_THREAD_COUNT_INFO_S));
108 case MSG_STRUCT_THREAD_LIST_INDEX: {
109 MSG_THREAD_LIST_INDEX_INFO_S * pThread = (MSG_THREAD_LIST_INDEX_INFO_S *)new MSG_THREAD_LIST_INDEX_INFO_S;
110 memset(pThread, 0x00, sizeof(MSG_THREAD_LIST_INDEX_INFO_S));
112 msg_struct->data = (void *)pThread;
114 msg_struct_s *pStruct = new msg_struct_s;
115 pThread->msgAddrInfo = (msg_struct_t)pStruct;
117 pStruct->type = MSG_STRUCT_ADDRESS_INFO;
118 pStruct->data = new MSG_ADDRESS_INFO_S;
119 memset(pStruct->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
123 case MSG_STRUCT_SORT_RULE: {
124 msg_struct->data = new MSG_SORT_RULE_S;
125 memset(msg_struct->data, 0x00, sizeof(MSG_SORT_RULE_S));
128 case MSG_STRUCT_FOLDER_INFO: {
129 msg_struct->data = new MSG_FOLDER_INFO_S;
130 memset(msg_struct->data, 0x00, sizeof(MSG_FOLDER_INFO_S));
133 case MSG_STRUCT_MSG_LIST_CONDITION: {
134 msg_struct->data = new MSG_LIST_CONDITION_S;
135 memset(msg_struct->data, 0x00, sizeof(MSG_LIST_CONDITION_S));
137 msg_struct_s *pStruct = new msg_struct_s;
138 ((MSG_LIST_CONDITION_S *)msg_struct->data)->sortRule = (msg_struct_t)pStruct;
140 pStruct->type = MSG_STRUCT_SORT_RULE;
141 pStruct->data = new MSG_SORT_RULE_S;
142 memset(pStruct->data, 0x00, sizeof(MSG_SORT_RULE_S));
146 case MSG_STRUCT_REPORT_STATUS_INFO: {
147 msg_struct->data = new MSG_REPORT_STATUS_INFO_S;
148 memset(msg_struct->data, 0x00, sizeof(MSG_REPORT_STATUS_INFO_S));
151 case MSG_STRUCT_SETTING_SMSC_OPT: {
152 msg_struct->data = new MSG_SMSC_LIST_HIDDEN_S;
153 memset(msg_struct->data, 0x00, sizeof(MSG_SMSC_LIST_HIDDEN_S));
155 MSG_SMSC_LIST_HIDDEN_S *pTmp = (MSG_SMSC_LIST_HIDDEN_S *)msg_struct->data;
156 pTmp->simIndex = MSG_SIM_SLOT_ID_1; /* default sim index */
158 msg_struct_list_s *smsc_list = (msg_struct_list_s *)new msg_struct_list_s;
159 memset(smsc_list, 0x00, sizeof(msg_struct_list_s));
161 pTmp->smsc_list = smsc_list;
163 smsc_list->msg_struct_info = (msg_struct_t *)calloc(SMSC_LIST_MAX, sizeof(msg_struct_t));
165 if (smsc_list->msg_struct_info != NULL) {
166 msg_struct_s *pStructTmp = NULL;
168 for (int i = 0; i < SMSC_LIST_MAX; i++) {
169 pStructTmp = (msg_struct_s *)new msg_struct_s;
170 pStructTmp->type = MSG_STRUCT_SETTING_SMSC_INFO;
171 pStructTmp->data = new MSG_SMSC_DATA_S;
172 memset(pStructTmp->data, 0x00, sizeof(MSG_SMSC_DATA_S));
173 smsc_list->msg_struct_info[i] = (msg_struct_t)pStructTmp;
178 case MSG_STRUCT_SETTING_SMSC_INFO: {
179 msg_struct->data = new MSG_SMSC_DATA_S;
180 memset(msg_struct->data, 0x00, sizeof(MSG_SMSC_DATA_S));
183 case MSG_STRUCT_SETTING_CB_OPT: {
184 msg_struct->data = new MSG_CBMSG_OPT_HIDDEN_S;
185 memset(msg_struct->data, 0x00, sizeof(MSG_CBMSG_OPT_HIDDEN_S));
187 MSG_CBMSG_OPT_HIDDEN_S *pTmp = (MSG_CBMSG_OPT_HIDDEN_S *)msg_struct->data;
188 pTmp->simIndex = MSG_SIM_SLOT_ID_1; /* default sim index */
190 pTmp->channelData = (msg_struct_list_s *)new msg_struct_list_s;
191 memset(pTmp->channelData, 0x00, sizeof(msg_struct_list_s));
193 pTmp->channelData->msg_struct_info = (msg_struct_t *)calloc(CB_CHANNEL_MAX, sizeof(msg_struct_t));
195 if (pTmp->channelData->msg_struct_info != NULL) {
196 msg_struct_s *pStructTmp = NULL;
198 for (int i = 0; i < CB_CHANNEL_MAX; i++) {
199 pStructTmp = (msg_struct_s *)new msg_struct_s;
200 pStructTmp->type = MSG_STRUCT_SETTING_CB_CHANNEL_INFO;
201 pStructTmp->data = new MSG_CB_CHANNEL_INFO_S;
203 memset(pStructTmp->data, 0x00, sizeof(MSG_CB_CHANNEL_INFO_S));
204 pTmp->channelData->msg_struct_info[i] = (msg_struct_t)pStructTmp;
209 case MSG_STRUCT_SETTING_CB_CHANNEL_INFO: {
210 msg_struct->data = new MSG_CB_CHANNEL_INFO_S;
211 memset(msg_struct->data, 0x00, sizeof(MSG_CB_CHANNEL_INFO_S));
214 case MSG_STRUCT_SETTING_SMS_SEND_OPT: {
215 msg_struct->data = new MSG_SMS_SENDOPT_S;
216 memset(msg_struct->data, 0x00, sizeof(MSG_SMS_SENDOPT_S));
219 case MSG_STRUCT_SETTING_MMS_SEND_OPT: {
220 msg_struct->data = new MSG_MMS_SENDOPT_S;
221 memset(msg_struct->data, 0x00, sizeof(MSG_MMS_SENDOPT_S));
224 case MSG_STRUCT_SETTING_MMS_RECV_OPT: {
225 msg_struct->data = new MSG_MMS_RECVOPT_S;
226 memset(msg_struct->data, 0x00, sizeof(MSG_MMS_RECVOPT_S));
229 case MSG_STRUCT_SETTING_PUSH_MSG_OPT: {
230 msg_struct->data = new MSG_PUSHMSG_OPT_S;
231 memset(msg_struct->data, 0x00, sizeof(MSG_PUSHMSG_OPT_S));
234 case MSG_STRUCT_SETTING_VOICE_MSG_OPT: {
235 msg_struct->data = new MSG_VOICEMAIL_OPT_S;
236 memset(msg_struct->data, 0x00, sizeof(MSG_VOICEMAIL_OPT_S));
237 MSG_VOICEMAIL_OPT_S *pTmp = (MSG_VOICEMAIL_OPT_S *)msg_struct->data;
238 pTmp->simIndex = MSG_SIM_SLOT_ID_1; /* default sim index */
241 case MSG_STRUCT_SETTING_GENERAL_OPT: {
242 msg_struct->data = new MSG_GENERAL_OPT_S;
243 memset(msg_struct->data, 0x00, sizeof(MSG_GENERAL_OPT_S));
246 case MSG_STRUCT_SETTING_MSGSIZE_OPT: {
247 msg_struct->data = new MSG_MSGSIZE_OPT_S;
248 memset(msg_struct->data, 0x00, sizeof(MSG_MSGSIZE_OPT_S));
251 case MSG_STRUCT_SMS_SENDOPT: {
252 msg_struct->data = new SMS_SENDINGOPT_S;
253 memset(msg_struct->data, 0x00, sizeof(SMS_SENDINGOPT_S));
256 case MSG_STRUCT_MMS_SENDOPT: {
257 msg_struct->data = new MMS_SENDINGOPT_S;
258 memset(msg_struct->data, 0x00, sizeof(MMS_SENDINGOPT_S));
261 case MSG_STRUCT_REQUEST_INFO: {
262 MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)new MSG_REQUEST_S;
263 memset(pRequest, 0x00, sizeof(MSG_REQUEST_S));
264 msg_struct->data = pRequest;
266 msg_struct_s *pMsg = (msg_struct_s *)new msg_struct_s;
267 msg_struct_s *pOpt = (msg_struct_s *)new msg_struct_s;
269 pRequest->msg = (msg_struct_t)pMsg;
270 pRequest->sendOpt = (msg_struct_t)pOpt;
272 pMsg->type = MSG_STRUCT_MESSAGE_INFO;
273 msg_message_create_struct(pMsg);
275 pOpt->type = MSG_STRUCT_SENDOPT;
276 pOpt->data = new MSG_SENDINGOPT_S;
277 memset(pOpt->data, 0x00, sizeof(MSG_SENDINGOPT_S));
278 msg_struct_s *pSms = new msg_struct_s;
279 msg_struct_s *pMms = new msg_struct_s;
281 MSG_SENDINGOPT_S *sendOpt = (MSG_SENDINGOPT_S *)pOpt->data;
283 sendOpt->mmsSendOpt = (msg_struct_t)pMms;
284 sendOpt->smsSendOpt = (msg_struct_t)pSms;
286 pMms->type = MSG_STRUCT_MMS_SENDOPT;
287 pMms->data = new MMS_SENDINGOPT_S;
288 memset(pMms->data, 0x00, sizeof(MMS_SENDINGOPT_S));
290 pSms->type = MSG_STRUCT_SMS_SENDOPT;
291 pSms->data = new SMS_SENDINGOPT_S;
292 memset(pSms->data, 0x00, sizeof(SMS_SENDINGOPT_S));
296 case MSG_STRUCT_MMS_PAGE:
297 case MSG_STRUCT_MMS_MEDIA:
298 case MSG_STRUCT_MMS_ATTACH:
299 case MSG_STRUCT_MMS_REGION:
300 case MSG_STRUCT_MMS_TRANSITION:
301 case MSG_STRUCT_MMS_META:
302 case MSG_STRUCT_MMS_SMIL_TEXT:
303 case MSG_STRUCT_MMS_SMIL_AVI:
304 case MSG_STRUCT_MULTIPART_INFO:
305 msg_struct->data = msg_mms_create_struct_data(field);
307 case MSG_STRUCT_PUSH_CONFIG_INFO:
308 msg_struct->data = new MSG_PUSH_EVENT_INFO_S;
309 memset(msg_struct->data, 0x00, sizeof(MSG_PUSH_EVENT_INFO_S));
317 return (msg_struct_t) msg_struct;
321 static int _release_msg_struct(msg_struct_t *msg_struct_handle)
323 msg_error_t err = MSG_SUCCESS;
325 if (msg_struct_handle == NULL || *msg_struct_handle == NULL)
326 return MSG_ERR_NULL_POINTER;
328 msg_struct_s *msg_struct = (msg_struct_s *)*msg_struct_handle;
330 switch (msg_struct->type) {
331 case MSG_STRUCT_MESSAGE_INFO: {
332 msg_message_release(&msg_struct);
334 *msg_struct_handle = NULL;
337 case MSG_STRUCT_FILTER: {
338 delete (MSG_FILTER_S*)(msg_struct->data);
339 msg_struct->data = NULL;
342 *msg_struct_handle = NULL;
345 case MSG_STRUCT_CONV_INFO: {
346 MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S*)(msg_struct->data);
348 if (pConv->multipart_list) {
349 g_list_free_full((GList *)pConv->multipart_list, __msg_release_list_item);
350 pConv->multipart_list = NULL;
354 delete [] pConv->pText;
359 msg_struct->data = NULL;
362 *msg_struct_handle = NULL;
365 case MSG_STRUCT_THREAD_INFO: {
366 delete (MSG_THREAD_VIEW_S*)(msg_struct->data);
367 msg_struct->data = NULL;
370 *msg_struct_handle = NULL;
373 case MSG_STRUCT_SENDOPT: {
374 MSG_SENDINGOPT_S *pOpt = (MSG_SENDINGOPT_S*)(msg_struct->data);
375 delete (MMS_SENDINGOPT_S *)(((msg_struct_s *)pOpt->mmsSendOpt)->data);
376 ((msg_struct_s *)pOpt->mmsSendOpt)->data = NULL;
377 delete (msg_struct_s *)pOpt->mmsSendOpt;
378 pOpt->mmsSendOpt = NULL;
380 delete (SMS_SENDINGOPT_S *)(((msg_struct_s *)pOpt->smsSendOpt)->data);
381 ((msg_struct_s *)pOpt->smsSendOpt)->data = NULL;
382 delete (msg_struct_s *)pOpt->smsSendOpt;
383 pOpt->smsSendOpt = NULL;
386 msg_struct->data = NULL;
389 *msg_struct_handle = NULL;
393 case MSG_STRUCT_SYNCML_INFO: {
394 MSG_SYNCML_MESSAGE_S *pSyncML = (MSG_SYNCML_MESSAGE_S*)(msg_struct->data);
395 msg_struct_s *msg = (msg_struct_s *)pSyncML->msg;
396 msg_message_release(&msg);
399 msg_struct->data = NULL;
402 *msg_struct_handle = NULL;
405 case MSG_STRUCT_COUNT_INFO: {
406 delete (MSG_COUNT_INFO_S*)(msg_struct->data);
407 msg_struct->data = NULL;
410 *msg_struct_handle = NULL;
413 case MSG_STRUCT_THREAD_COUNT_INFO: {
414 delete (MSG_THREAD_COUNT_INFO_S*)(msg_struct->data);
415 msg_struct->data = NULL;
418 *msg_struct_handle = NULL;
422 case MSG_STRUCT_THREAD_LIST_INDEX: {
423 MSG_THREAD_LIST_INDEX_INFO_S *pThread = (MSG_THREAD_LIST_INDEX_INFO_S*)(msg_struct->data);
424 delete (MSG_ADDRESS_INFO_S *)(((msg_struct_s *)pThread->msgAddrInfo)->data);
425 ((msg_struct_s *)pThread->msgAddrInfo)->data = NULL;
426 delete (msg_struct_s *)pThread->msgAddrInfo;
427 pThread->msgAddrInfo = NULL;
429 msg_struct->data = NULL;
432 *msg_struct_handle = NULL;
436 case MSG_STRUCT_SORT_RULE: {
437 delete (MSG_SORT_RULE_S*)(msg_struct->data);
438 msg_struct->data = NULL;
441 *msg_struct_handle = NULL;
445 case MSG_STRUCT_FOLDER_INFO: {
446 delete (MSG_FOLDER_INFO_S*)(msg_struct->data);
447 msg_struct->data = NULL;
450 *msg_struct_handle = NULL;
454 case MSG_STRUCT_MSG_LIST_CONDITION: {
455 MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S*)(msg_struct->data);
456 MSG_SORT_RULE_S *pSortRule = (MSG_SORT_RULE_S *)(((msg_struct_s *)pCond->sortRule)->data);
458 delete (MSG_SORT_RULE_S *)pSortRule;
459 ((msg_struct_s *)pCond->sortRule)->data = NULL;
460 delete (msg_struct_s *)pCond->sortRule;
461 pCond->sortRule = NULL;
463 if (pCond->pAddressVal) {
464 delete [] pCond->pAddressVal;
465 pCond->pAddressVal = NULL;
468 if (pCond->pTextVal) {
469 delete [] pCond->pTextVal;
470 pCond->pTextVal = NULL;
473 delete (MSG_LIST_CONDITION_S*)(msg_struct->data);
474 msg_struct->data = NULL;
477 *msg_struct_handle = NULL;
481 case MSG_STRUCT_REPORT_STATUS_INFO: {
482 delete (MSG_REPORT_STATUS_INFO_S*)(msg_struct->data);
483 msg_struct->data = NULL;
486 *msg_struct_handle = NULL;
490 case MSG_STRUCT_SMS_SENDOPT: {
491 delete (SMS_SENDINGOPT_S*)(msg_struct->data);
492 msg_struct->data = NULL;
495 *msg_struct_handle = NULL;
499 case MSG_STRUCT_MMS_SENDOPT: {
500 delete (MMS_SENDINGOPT_S*)(msg_struct->data);
501 msg_struct->data = NULL;
504 *msg_struct_handle = NULL;
508 case MSG_STRUCT_REQUEST_INFO: {
509 MSG_REQUEST_S *pRequest = (MSG_REQUEST_S*)(msg_struct->data);
511 MSG_SENDINGOPT_S *pSendingOpt = (MSG_SENDINGOPT_S *)(((msg_struct_s *)pRequest->sendOpt)->data);
513 msg_struct_s *pMmsOpt = (msg_struct_s *)pSendingOpt->mmsSendOpt;
514 msg_struct_s *pSmsOpt = (msg_struct_s *)pSendingOpt->smsSendOpt;
516 delete (MMS_SENDINGOPT_S *)(pMmsOpt->data);
517 pMmsOpt->data = NULL;
518 delete (msg_struct_s *)pSendingOpt->mmsSendOpt;
519 pSendingOpt->mmsSendOpt = NULL;
520 delete (MMS_SENDINGOPT_S *)(pSmsOpt->data);
521 pSmsOpt->data = NULL;
522 delete (msg_struct_s *)pSendingOpt->smsSendOpt;
523 pSendingOpt->smsSendOpt = NULL;
525 delete (MSG_SENDINGOPT_S *)pSendingOpt;
526 ((msg_struct_s *)pRequest->sendOpt)->data = NULL;
527 delete (msg_struct_s *)pRequest->sendOpt;
528 pRequest->sendOpt = NULL;
530 msg_struct_s *msg = (msg_struct_s *)pRequest->msg;
531 msg_message_release(&msg);
534 msg_struct->data = NULL;
537 *msg_struct_handle = NULL;
541 case MSG_STRUCT_MMS_PAGE:
542 case MSG_STRUCT_MMS_MEDIA:
543 case MSG_STRUCT_MMS_ATTACH:
544 case MSG_STRUCT_MMS_REGION:
545 case MSG_STRUCT_MMS_TRANSITION:
546 case MSG_STRUCT_MMS_META:
547 case MSG_STRUCT_MMS_SMIL_TEXT:
548 case MSG_STRUCT_MMS_SMIL_AVI:
549 case MSG_STRUCT_MULTIPART_INFO: {
550 msg_mms_release_struct(&msg_struct);
551 *msg_struct_handle = NULL;
554 case MSG_STRUCT_SETTING_SMSC_OPT: {
555 msg_struct_list_s *smsc_list = NULL;
556 msg_struct_s *smsc_info = NULL;
557 MSG_SMSC_LIST_HIDDEN_S *pTmp = NULL;
559 pTmp = (MSG_SMSC_LIST_HIDDEN_S *)msg_struct->data;
560 smsc_list = (msg_struct_list_s *)pTmp->smsc_list;
562 for (int i = 0; i < SMSC_LIST_MAX; i++) {
563 smsc_info = (msg_struct_s *)smsc_list->msg_struct_info[i];
564 delete (MSG_SMSC_DATA_S*)(smsc_info->data);
568 g_free(smsc_list->msg_struct_info);
573 msg_struct->data = NULL;
576 *msg_struct_handle = NULL;
579 case MSG_STRUCT_SETTING_CB_CHANNEL_INFO: {
580 delete (MSG_CB_CHANNEL_INFO_S*)(msg_struct->data);
581 msg_struct->data = NULL;
584 *msg_struct_handle = NULL;
587 case MSG_STRUCT_SETTING_CB_OPT: {
588 msg_struct_list_s *cb_list = NULL;
589 msg_struct_s *cb_info = NULL;
590 MSG_CBMSG_OPT_HIDDEN_S *pTmp = NULL;
592 pTmp = (MSG_CBMSG_OPT_HIDDEN_S *)msg_struct->data;
593 cb_list = (msg_struct_list_s *)pTmp->channelData;
595 for (int i = 0; i < CB_CHANNEL_MAX; i++) {
596 cb_info = (msg_struct_s *)cb_list->msg_struct_info[i];
597 delete (MSG_CB_CHANNEL_INFO_S*)(cb_info->data);
601 g_free(cb_list->msg_struct_info);
606 msg_struct->data = NULL;
609 *msg_struct_handle = NULL;
612 case MSG_STRUCT_SETTING_SMS_SEND_OPT: {
613 delete (MSG_SMS_SENDOPT_S*)(msg_struct->data);
614 msg_struct->data = NULL;
617 *msg_struct_handle = NULL;
620 case MSG_STRUCT_SETTING_MMS_SEND_OPT: {
621 delete (MSG_MMS_SENDOPT_S*)(msg_struct->data);
622 msg_struct->data = NULL;
625 *msg_struct_handle = NULL;
628 case MSG_STRUCT_SETTING_MMS_RECV_OPT: {
629 delete (MSG_MMS_RECVOPT_S*)(msg_struct->data);
630 msg_struct->data = NULL;
633 *msg_struct_handle = NULL;
636 case MSG_STRUCT_SETTING_PUSH_MSG_OPT: {
637 delete (MSG_PUSHMSG_OPT_S*)(msg_struct->data);
638 msg_struct->data = NULL;
641 *msg_struct_handle = NULL;
644 case MSG_STRUCT_SETTING_VOICE_MSG_OPT: {
645 delete (MSG_VOICEMAIL_OPT_S*)(msg_struct->data);
646 msg_struct->data = NULL;
649 *msg_struct_handle = NULL;
652 case MSG_STRUCT_SETTING_GENERAL_OPT: {
653 delete (MSG_GENERAL_OPT_S*)(msg_struct->data);
654 msg_struct->data = NULL;
657 *msg_struct_handle = NULL;
660 case MSG_STRUCT_SETTING_MSGSIZE_OPT: {
661 delete (MSG_MSGSIZE_OPT_S*)(msg_struct->data);
662 msg_struct->data = NULL;
665 *msg_struct_handle = NULL;
668 case MSG_STRUCT_ADDRESS_INFO: {
669 delete (MSG_ADDRESS_INFO_S*)(msg_struct->data);
670 msg_struct->data = NULL;
673 *msg_struct_handle = NULL;
676 case MSG_STRUCT_PUSH_CONFIG_INFO: {
677 delete (MSG_PUSH_EVENT_INFO_S*)(msg_struct->data);
678 msg_struct->data = NULL;
681 *msg_struct_handle = NULL;
684 case MSG_STRUCT_MEDIA_INFO: {
685 delete (MSG_MEDIA_INFO_S*)(msg_struct->data);
686 msg_struct->data = NULL;
689 *msg_struct_handle = NULL;
693 err = MSG_ERR_INVALID_PARAMETER;
700 EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle)
702 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
704 int ret = _release_msg_struct(msg_struct_handle);
709 EXPORT_API int msg_release_list_struct(msg_struct_list_s *msg_struct_list)
711 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
712 msg_error_t err = MSG_SUCCESS;
714 if (msg_struct_list == NULL)
715 return MSG_ERR_NULL_POINTER;
717 if (msg_struct_list->msg_struct_info == NULL) {
718 if (msg_struct_list->nCount > 0)
719 msg_struct_list->nCount = 0;
720 return MSG_ERR_NULL_POINTER;
723 if (msg_struct_list->nCount > 0) {
724 int listCnt = msg_struct_list->nCount;
726 for (int i = 0; i < listCnt; i++) {
727 _release_msg_struct(&(msg_struct_list->msg_struct_info[i]));
731 /* free peer info list */
732 g_free(msg_struct_list->msg_struct_info);
733 msg_struct_list->msg_struct_info = NULL;
735 msg_struct_list->nCount = 0;
740 EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int *value)
742 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
743 msg_error_t err = MSG_SUCCESS;
745 if (msg_struct_handle == NULL || value == NULL)
746 return MSG_ERR_NULL_POINTER;
748 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
749 MSG_TYPE_CHECK(msg_struct->type, field);
751 if (msg_struct->data == NULL)
752 return MSG_ERR_NULL_POINTER;
754 switch (msg_struct->type) {
755 case MSG_STRUCT_MESSAGE_INFO:
756 err = msg_message_get_int_value(msg_struct->data, field, value);
758 case MSG_STRUCT_FILTER:
759 err = msg_get_filter_info_int(msg_struct->data, field, value);
761 case MSG_STRUCT_SYNCML_INFO:
762 err = msg_syncml_info_get_int(msg_struct->data, field, value);
764 case MSG_STRUCT_COUNT_INFO:
765 err = msg_count_info_get_int(msg_struct->data, field, value);
767 case MSG_STRUCT_THREAD_COUNT_INFO:
768 err = msg_thread_count_get_int(msg_struct->data, field, value);
770 case MSG_STRUCT_THREAD_LIST_INDEX:
771 err = msg_thread_index_get_int(msg_struct->data, field, value);
773 case MSG_STRUCT_SORT_RULE:
774 err = msg_sortrule_get_int(msg_struct->data, field, value);
776 case MSG_STRUCT_FOLDER_INFO:
777 err = msg_folder_info_get_int(msg_struct->data, field, value);
779 case MSG_STRUCT_THREAD_INFO:
780 err = msg_thread_info_get_int(msg_struct->data, field, value);
782 case MSG_STRUCT_CONV_INFO:
783 err = msg_conv_info_get_int(msg_struct->data, field, value);
785 case MSG_STRUCT_MSG_LIST_CONDITION:
786 err = msg_list_condition_get_int(msg_struct->data, field, value);
788 case MSG_STRUCT_REPORT_STATUS_INFO:
789 err = msg_report_status_get_int(msg_struct->data, field, value);
791 case MSG_STRUCT_ADDRESS_INFO:
792 err = msg_address_info_get_int(msg_struct->data, field, value);
794 case MSG_STRUCT_MMS_SENDOPT:
795 err = msg_mms_sendopt_get_int(msg_struct->data, field, value);
797 case MSG_STRUCT_REJECT_MSG_INFO:
798 err = msg_reject_message_get_int(msg_struct->data, field, value);
800 case MSG_STRUCT_REQUEST_INFO:
801 err = msg_request_get_int(msg_struct->data, field, value);
803 case MSG_STRUCT_SENT_STATUS_INFO:
804 err = msg_sent_status_get_int((MSG_SENT_STATUS_S *)msg_struct->data, field, value);
806 case MSG_STRUCT_CB_MSG:
807 err = msg_cb_message_get_int_value(msg_struct->data, field, value);
810 case MSG_STRUCT_MMS_PAGE:
811 case MSG_STRUCT_MMS_MEDIA:
812 case MSG_STRUCT_MMS_ATTACH:
813 case MSG_STRUCT_MMS_REGION:
814 case MSG_STRUCT_MMS_TRANSITION:
815 case MSG_STRUCT_MMS_META:
816 case MSG_STRUCT_MMS_SMIL_TEXT:
817 case MSG_STRUCT_MMS_SMIL_AVI:
818 case MSG_STRUCT_MULTIPART_INFO:
819 err = msg_mms_get_int_value(msg_struct, field, value);
821 case MSG_STRUCT_SETTING_SMSC_OPT:
822 case MSG_STRUCT_SETTING_SMSC_INFO:
823 case MSG_STRUCT_SETTING_CB_OPT:
824 case MSG_STRUCT_SETTING_CB_CHANNEL_INFO:
825 case MSG_STRUCT_SETTING_SMS_SEND_OPT:
826 case MSG_STRUCT_SETTING_MMS_SEND_OPT:
827 case MSG_STRUCT_SETTING_MMS_RECV_OPT:
828 case MSG_STRUCT_SETTING_PUSH_MSG_OPT:
829 case MSG_STRUCT_SETTING_GENERAL_OPT:
830 case MSG_STRUCT_SETTING_MSGSIZE_OPT:
831 case MSG_STRUCT_SETTING_VOICE_MSG_OPT:
832 err = msg_setting_get_int_value(msg_struct, field, value);
834 case MSG_STRUCT_MEDIA_INFO:
835 err = msg_media_item_get_int(msg_struct->data, field, value);
838 err = MSG_ERR_INVALID_PARAMETER;
845 EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char *value, int size)
847 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
848 msg_error_t err = MSG_SUCCESS;
850 if (msg_struct_handle == NULL || value == NULL)
851 return MSG_ERR_NULL_POINTER;
854 return MSG_ERR_INVALID_PARAMETER;
856 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
858 if (msg_struct->data == NULL)
859 return MSG_ERR_NULL_POINTER;
861 switch (msg_struct->type) {
862 case MSG_STRUCT_MESSAGE_INFO:
863 err = msg_message_get_str_value(msg_struct->data, field, value, size);
865 case MSG_STRUCT_FILTER:
866 err = msg_get_filter_info_str(msg_struct->data, field, value, size);
868 case MSG_STRUCT_FOLDER_INFO:
869 err = msg_folder_info_get_str(msg_struct->data, field, value, size);
871 case MSG_STRUCT_THREAD_INFO:
872 err = msg_thread_info_get_str(msg_struct->data, field, value, size);
874 case MSG_STRUCT_CONV_INFO:
875 err = msg_conv_info_get_str(msg_struct->data, field, value, size);
877 case MSG_STRUCT_MSG_LIST_CONDITION:
878 err = msg_list_condition_get_str(msg_struct->data, field, value, size);
881 case MSG_STRUCT_ADDRESS_INFO:
882 err = msg_address_info_get_str(msg_struct->data, field, value, size);
885 case MSG_STRUCT_REJECT_MSG_INFO:
886 err = msg_reject_message_get_str(msg_struct->data, field, value, size);
888 case MSG_STRUCT_MEDIA_INFO:
889 err = msg_media_item_get_str(msg_struct->data, field, value, size);
892 case MSG_STRUCT_MMS_PAGE:
893 case MSG_STRUCT_MMS_MEDIA:
894 case MSG_STRUCT_MMS_ATTACH:
895 case MSG_STRUCT_MMS_REGION:
896 case MSG_STRUCT_MMS_TRANSITION:
897 case MSG_STRUCT_MMS_META:
898 case MSG_STRUCT_MMS_SMIL_TEXT:
899 case MSG_STRUCT_MMS_SMIL_AVI:
900 case MSG_STRUCT_MULTIPART_INFO:
901 err = msg_mms_get_str_value(msg_struct, field, value, size);
903 case MSG_STRUCT_SETTING_GENERAL_OPT:
904 case MSG_STRUCT_SETTING_SMSC_INFO:
905 case MSG_STRUCT_SETTING_CB_CHANNEL_INFO:
906 case MSG_STRUCT_SETTING_VOICE_MSG_OPT:
907 err = msg_setting_get_str_value(msg_struct, field, value, size);
909 case MSG_STRUCT_PUSH_CONFIG_INFO:
910 err = msg_push_config_get_str(msg_struct->data, field, value, size);
912 case MSG_STRUCT_REPORT_STATUS_INFO:
913 err = msg_report_status_get_str(msg_struct->data, field, value, size);
915 case MSG_STRUCT_CB_MSG:
916 err = msg_cb_message_get_str_value(msg_struct->data, field, value, size);
919 err = MSG_ERR_INVALID_PARAMETER;
926 EXPORT_API int msg_get_bool_value(msg_struct_t msg_struct_handle, int field, bool *value)
928 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
929 msg_error_t err = MSG_SUCCESS;
931 if (msg_struct_handle == NULL || value == NULL)
932 return MSG_ERR_NULL_POINTER;
934 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
936 if (msg_struct->data == NULL)
937 return MSG_ERR_NULL_POINTER;
939 switch (msg_struct->type) {
940 case MSG_STRUCT_FILTER:
941 err = msg_get_filter_info_bool(msg_struct->data, field, value);
943 case MSG_STRUCT_MESSAGE_INFO:
944 err = msg_message_get_bool_value(msg_struct->data, field, value);
946 case MSG_STRUCT_THREAD_INFO:
947 err = msg_thread_info_get_bool(msg_struct->data, field, value);
949 case MSG_STRUCT_CONV_INFO:
950 err = msg_conv_get_bool(msg_struct->data, field, value);
952 case MSG_STRUCT_SENDOPT:
953 err = msg_sendopt_get_bool(msg_struct->data, field, value);
955 case MSG_STRUCT_SORT_RULE:
956 err = msg_sortrule_get_bool(msg_struct->data, field, value);
958 case MSG_STRUCT_MSG_LIST_CONDITION:
959 err = msg_list_condition_get_bool(msg_struct->data, field, value);
961 case MSG_STRUCT_MMS_SENDOPT:
962 err = msg_mms_sendopt_get_bool(msg_struct->data, field, value);
964 case MSG_STRUCT_SMS_SENDOPT:
965 err = msg_sms_sendopt_get_bool(msg_struct->data, field, value);
968 case MSG_STRUCT_MMS_PAGE:
969 case MSG_STRUCT_MMS_MEDIA:
970 case MSG_STRUCT_MMS_ATTACH:
971 case MSG_STRUCT_MMS_REGION:
972 case MSG_STRUCT_MMS_TRANSITION:
973 case MSG_STRUCT_MMS_META:
974 case MSG_STRUCT_MMS_SMIL_TEXT:
975 case MSG_STRUCT_MMS_SMIL_AVI:
976 err = msg_mms_get_bool_value(msg_struct, field, value);
978 case MSG_STRUCT_SETTING_CB_OPT:
979 case MSG_STRUCT_SETTING_CB_CHANNEL_INFO:
980 case MSG_STRUCT_SETTING_SMS_SEND_OPT:
981 case MSG_STRUCT_SETTING_MMS_SEND_OPT:
982 case MSG_STRUCT_SETTING_MMS_RECV_OPT:
983 case MSG_STRUCT_SETTING_PUSH_MSG_OPT:
984 case MSG_STRUCT_SETTING_GENERAL_OPT:
985 err = msg_setting_get_bool_value(msg_struct, field, value);
987 case MSG_STRUCT_PUSH_CONFIG_INFO:
988 err = msg_push_config_get_bool(msg_struct->data, field, value);
991 err = MSG_ERR_INVALID_PARAMETER;
998 EXPORT_API int msg_get_struct_handle(msg_struct_t msg_struct_handle, int field, msg_struct_t *value)
1000 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1001 msg_error_t err = MSG_SUCCESS;
1003 if (msg_struct_handle == NULL || value == NULL)
1004 return MSG_ERR_NULL_POINTER;
1006 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
1008 if (msg_struct->data == NULL)
1009 return MSG_ERR_NULL_POINTER;
1011 switch (msg_struct->type) {
1012 case MSG_STRUCT_MESSAGE_INFO:
1013 err = msg_message_get_struct_hnd(msg_struct->data, field, (void **)value);
1015 case MSG_STRUCT_SENDOPT:
1016 err = msg_sendopt_get_struct_handle(msg_struct, field, (void **)value);
1018 case MSG_STRUCT_SYNCML_INFO:
1019 err = msg_syncml_get_struct_handle(msg_struct, field, (void **)value);
1021 case MSG_STRUCT_THREAD_LIST_INDEX:
1022 err = msg_thread_index_get_struct_handle(msg_struct, field, (void **)value);
1024 case MSG_STRUCT_MSG_LIST_CONDITION:
1025 err = msg_list_condition_get_struct_handle(msg_struct, field, (void **)value);
1027 case MSG_STRUCT_MMS_MEDIA:
1028 err = msg_mms_get_struct_handle(msg_struct, field, (msg_struct_s**)value);
1030 case MSG_STRUCT_REQUEST_INFO:
1031 err = msg_request_get_struct_handle(msg_struct, field, (void **)value);
1034 err = MSG_ERR_INVALID_PARAMETER;
1041 EXPORT_API int msg_get_list_handle(msg_struct_t msg_struct_handle, int field, void **value)
1043 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1044 msg_error_t err = MSG_SUCCESS;
1046 if (msg_struct_handle == NULL || value == NULL)
1047 return MSG_ERR_NULL_POINTER;
1049 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
1051 if (msg_struct->data == NULL)
1052 return MSG_ERR_NULL_POINTER;
1054 switch (msg_struct->type) {
1055 case MSG_STRUCT_MESSAGE_INFO:
1056 err = msg_message_get_list_hnd(msg_struct->data, field, value);
1058 case MSG_STRUCT_CONV_INFO:
1059 err = msg_conversation_get_list_hnd(msg_struct->data, field, value);
1061 case MSG_STRUCT_MMS:
1062 case MSG_STRUCT_MMS_PAGE:
1063 err = msg_mms_get_list_handle(msg_struct, field, (msg_list_handle_t *)value);
1065 case MSG_STRUCT_SETTING_CB_OPT:
1066 case MSG_STRUCT_SETTING_SMSC_OPT:
1067 err = msg_setting_get_list_handle(msg_struct, field, value);
1070 err = MSG_ERR_INVALID_PARAMETER;
1077 EXPORT_API int msg_set_int_value(msg_struct_t msg_struct_handle, int field, int value)
1079 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1080 msg_error_t err = MSG_SUCCESS;
1082 if (msg_struct_handle == NULL)
1083 return MSG_ERR_NULL_POINTER;
1085 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
1087 if (msg_struct->data == NULL)
1088 return MSG_ERR_NULL_POINTER;
1090 switch (msg_struct->type) {
1091 case MSG_STRUCT_MESSAGE_INFO:
1092 err = msg_message_set_int_value(msg_struct->data, field, value);
1094 case MSG_STRUCT_FILTER:
1095 err = msg_set_filter_info_int(msg_struct->data, field, value);
1097 case MSG_STRUCT_SYNCML_INFO:
1098 err = msg_syncml_info_set_int(msg_struct->data, field, value);
1100 case MSG_STRUCT_COUNT_INFO:
1101 err = msg_count_info_set_int(msg_struct->data, field, value);
1103 case MSG_STRUCT_THREAD_COUNT_INFO:
1104 err = msg_thread_count_set_int(msg_struct->data, field, value);
1106 case MSG_STRUCT_THREAD_LIST_INDEX:
1107 err = msg_thread_index_set_int(msg_struct->data, field, value);
1109 case MSG_STRUCT_SORT_RULE:
1110 err = msg_sortrule_set_int(msg_struct->data, field, value);
1112 case MSG_STRUCT_FOLDER_INFO:
1113 err = msg_folder_info_set_int(msg_struct->data, field, value);
1115 case MSG_STRUCT_MSG_LIST_CONDITION:
1116 err = msg_list_condition_set_int(msg_struct->data, field, value);
1118 case MSG_STRUCT_REPORT_STATUS_INFO:
1119 err = msg_report_status_set_int(msg_struct->data, field, value);
1121 case MSG_STRUCT_ADDRESS_INFO:
1122 err = msg_address_info_set_int(msg_struct->data, field, value);
1124 case MSG_STRUCT_MMS_SENDOPT:
1125 err = msg_mms_sendopt_set_int(msg_struct->data, field, value);
1127 case MSG_STRUCT_REJECT_MSG_INFO:
1128 err = msg_reject_message_set_int(msg_struct->data, field, value);
1130 case MSG_STRUCT_REQUEST_INFO:
1131 err = msg_request_set_int(msg_struct->data, field, value);
1133 case MSG_STRUCT_MMS:
1134 case MSG_STRUCT_MMS_PAGE:
1135 case MSG_STRUCT_MMS_MEDIA:
1136 case MSG_STRUCT_MMS_ATTACH:
1137 case MSG_STRUCT_MMS_REGION:
1138 case MSG_STRUCT_MMS_TRANSITION:
1139 case MSG_STRUCT_MMS_META:
1140 case MSG_STRUCT_MMS_SMIL_TEXT:
1141 case MSG_STRUCT_MMS_SMIL_AVI:
1142 err = msg_mms_set_int_value(msg_struct, field, value);
1144 case MSG_STRUCT_SETTING_SMSC_OPT:
1145 case MSG_STRUCT_SETTING_SMSC_INFO:
1146 case MSG_STRUCT_SETTING_CB_OPT:
1147 case MSG_STRUCT_SETTING_CB_CHANNEL_INFO:
1148 case MSG_STRUCT_SETTING_SMS_SEND_OPT:
1149 case MSG_STRUCT_SETTING_MMS_SEND_OPT:
1150 case MSG_STRUCT_SETTING_MMS_RECV_OPT:
1151 case MSG_STRUCT_SETTING_PUSH_MSG_OPT:
1152 case MSG_STRUCT_SETTING_GENERAL_OPT:
1153 case MSG_STRUCT_SETTING_MSGSIZE_OPT:
1154 case MSG_STRUCT_SETTING_VOICE_MSG_OPT:
1155 err = msg_setting_set_int_value(msg_struct, field, value);
1158 err = MSG_ERR_INVALID_PARAMETER;
1165 EXPORT_API int msg_set_str_value(msg_struct_t msg_struct_handle, int field, const char *value, int size)
1167 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1168 msg_error_t err = MSG_SUCCESS;
1170 if (msg_struct_handle == NULL || value == NULL)
1171 return MSG_ERR_NULL_POINTER;
1174 return MSG_ERR_INVALID_PARAMETER;
1176 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
1178 if (msg_struct->data == NULL)
1179 return MSG_ERR_NULL_POINTER;
1181 switch (msg_struct->type) {
1182 case MSG_STRUCT_MESSAGE_INFO:
1183 err = msg_message_set_str_value(msg_struct->data, field, value, size);
1185 case MSG_STRUCT_FILTER:
1186 err = msg_set_filter_info_str(msg_struct->data, field, value, size);
1188 case MSG_STRUCT_FOLDER_INFO:
1189 err = msg_folder_info_set_str(msg_struct->data, field, value, size);
1191 case MSG_STRUCT_MSG_LIST_CONDITION:
1192 err = msg_list_condition_set_str(msg_struct->data, field, value, size);
1194 case MSG_STRUCT_ADDRESS_INFO:
1195 err = msg_address_info_set_str(msg_struct->data, field, value, size);
1197 case MSG_STRUCT_REJECT_MSG_INFO:
1198 err = msg_reject_message_set_str(msg_struct->data, field, value, size);
1200 case MSG_STRUCT_MMS:
1201 case MSG_STRUCT_MMS_PAGE:
1202 case MSG_STRUCT_MMS_MEDIA:
1203 case MSG_STRUCT_MMS_ATTACH:
1204 case MSG_STRUCT_MMS_REGION:
1205 case MSG_STRUCT_MMS_TRANSITION:
1206 case MSG_STRUCT_MMS_META:
1207 case MSG_STRUCT_MMS_SMIL_TEXT:
1208 case MSG_STRUCT_MMS_SMIL_AVI:
1209 case MSG_STRUCT_MULTIPART_INFO:
1210 err = msg_mms_set_str_value(msg_struct, field, value, size);
1212 case MSG_STRUCT_SETTING_GENERAL_OPT:
1213 case MSG_STRUCT_SETTING_SMSC_INFO:
1214 case MSG_STRUCT_SETTING_CB_CHANNEL_INFO:
1215 case MSG_STRUCT_SETTING_VOICE_MSG_OPT:
1216 err = msg_setting_set_str_value(msg_struct, field, value, size);
1218 case MSG_STRUCT_PUSH_CONFIG_INFO:
1219 err = msg_push_config_set_str(msg_struct->data, field, value, size);
1221 case MSG_STRUCT_MEDIA_INFO:
1222 err = msg_media_info_set_str(msg_struct->data, field, value, size);
1225 err = MSG_ERR_INVALID_PARAMETER;
1232 EXPORT_API int msg_set_bool_value(msg_struct_t msg_struct_handle, int field, bool value)
1234 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1235 msg_error_t err = MSG_SUCCESS;
1237 if (msg_struct_handle == NULL)
1238 return MSG_ERR_NULL_POINTER;
1240 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
1242 if (msg_struct->data == NULL)
1243 return MSG_ERR_NULL_POINTER;
1245 switch (msg_struct->type) {
1246 case MSG_STRUCT_FILTER:
1247 err = msg_set_filter_info_bool(msg_struct->data, field, value);
1249 case MSG_STRUCT_MESSAGE_INFO:
1250 err = msg_message_set_bool_value(msg_struct->data, field, value);
1252 case MSG_STRUCT_SENDOPT:
1253 err = msg_sendopt_set_bool(msg_struct->data, field, value);
1255 case MSG_STRUCT_SORT_RULE:
1256 err = msg_sortrule_set_bool(msg_struct->data, field, value);
1258 case MSG_STRUCT_MSG_LIST_CONDITION:
1259 err = msg_list_condition_set_bool(msg_struct->data, field, value);
1261 case MSG_STRUCT_MMS_SENDOPT:
1262 err = msg_mms_sendopt_set_bool(msg_struct->data, field, value);
1264 case MSG_STRUCT_SMS_SENDOPT:
1265 err = msg_sms_sendopt_set_bool(msg_struct->data, field, value);
1267 case MSG_STRUCT_MMS:
1268 case MSG_STRUCT_MMS_PAGE:
1269 case MSG_STRUCT_MMS_MEDIA:
1270 case MSG_STRUCT_MMS_ATTACH:
1271 case MSG_STRUCT_MMS_REGION:
1272 case MSG_STRUCT_MMS_TRANSITION:
1273 case MSG_STRUCT_MMS_META:
1274 case MSG_STRUCT_MMS_SMIL_TEXT:
1275 case MSG_STRUCT_MMS_SMIL_AVI:
1276 err = msg_mms_set_bool_value(msg_struct, field, value);
1278 case MSG_STRUCT_SETTING_CB_OPT:
1279 case MSG_STRUCT_SETTING_CB_CHANNEL_INFO:
1280 case MSG_STRUCT_SETTING_SMS_SEND_OPT:
1281 case MSG_STRUCT_SETTING_MMS_SEND_OPT:
1282 case MSG_STRUCT_SETTING_MMS_RECV_OPT:
1283 case MSG_STRUCT_SETTING_PUSH_MSG_OPT:
1284 case MSG_STRUCT_SETTING_GENERAL_OPT:
1285 err = msg_setting_set_bool_value(msg_struct, field, value);
1287 case MSG_STRUCT_PUSH_CONFIG_INFO:
1288 err = msg_push_config_set_bool(msg_struct->data, field, value);
1291 err = MSG_ERR_INVALID_PARAMETER;
1298 EXPORT_API int msg_set_struct_handle(msg_struct_t msg_struct_handle, int field, msg_struct_t value)
1300 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1301 msg_error_t err = MSG_SUCCESS;
1303 if (msg_struct_handle == NULL || value == NULL)
1304 return MSG_ERR_NULL_POINTER;
1306 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
1308 if (msg_struct->data == NULL)
1309 return MSG_ERR_NULL_POINTER;
1311 switch (msg_struct->type) {
1312 case MSG_STRUCT_MESSAGE_INFO:
1313 err = msg_message_set_struct_hnd(msg_struct->data, field, (void *)value);
1315 case MSG_STRUCT_SENDOPT:
1316 err = msg_sendopt_set_struct_handle(msg_struct, field, (msg_struct_s *)value);
1318 case MSG_STRUCT_SYNCML_INFO:
1319 err = msg_syncml_set_struct_handle(msg_struct, field, (msg_struct_s *)value);
1321 case MSG_STRUCT_THREAD_LIST_INDEX:
1322 err = msg_thread_index_set_struct_handle(msg_struct, field, (msg_struct_s *)value);
1324 case MSG_STRUCT_MSG_LIST_CONDITION:
1325 err = msg_list_condition_set_struct_handle(msg_struct, field, (msg_struct_s *)value);
1327 case MSG_STRUCT_MMS_MEDIA:
1328 err = msg_mms_set_struct_handle(msg_struct, field, (msg_struct_s *)value);
1330 case MSG_STRUCT_REQUEST_INFO:
1331 err = msg_request_set_struct_handle(msg_struct, field, (msg_struct_s *)value);
1334 err = MSG_ERR_INVALID_PARAMETER;
1341 EXPORT_API int msg_set_list_handle(msg_struct_t msg_struct_handle, int field, void *value)
1343 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1344 msg_error_t err = MSG_SUCCESS;
1346 if (msg_struct_handle == NULL || value == NULL)
1347 return MSG_ERR_NULL_POINTER;
1349 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
1351 if (msg_struct->data == NULL)
1352 return MSG_ERR_NULL_POINTER;
1354 #if 0 /* No operations */
1355 switch (msg_struct->type) {
1357 err = MSG_ERR_INVALID_PARAMETER;
1365 EXPORT_API int msg_list_add_item(msg_struct_t msg_struct_handle, int field, msg_struct_t *item)
1367 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1368 if (msg_struct_handle == NULL || item == NULL)
1369 return MSG_ERR_NULL_POINTER;
1371 msg_error_t err = MSG_SUCCESS;
1372 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
1374 switch (msg_struct->type) {
1375 case MSG_STRUCT_MESSAGE_INFO: {
1376 err = msg_message_list_append(msg_struct_handle, field, item);
1379 case MSG_STRUCT_MMS:
1380 case MSG_STRUCT_MMS_PAGE: {
1381 err = msg_mms_list_append(msg_struct_handle, field, item);
1385 err = MSG_ERR_INVALID_PARAMETER;
1392 EXPORT_API msg_struct_t msg_list_nth_data(msg_list_handle_t list_handle, int index)
1394 CHECK_MSG_SUPPORTED_RETURN_NULL(MSG_TELEPHONY_SMS_FEATURE);
1395 if (list_handle == NULL)
1398 return (msg_struct_t)g_list_nth_data((GList *)list_handle, (guint)index);
1401 EXPORT_API int msg_list_length(msg_list_handle_t list_handle)
1403 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1404 if (list_handle == NULL) {
1408 return (int)g_list_length((GList *)list_handle);
1411 EXPORT_API int msg_list_clear(msg_struct_t msg_struct_handle, int field)
1413 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1414 if (msg_struct_handle == NULL)
1415 return MSG_ERR_NULL_POINTER;
1417 msg_error_t err = MSG_SUCCESS;
1418 msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
1420 switch (msg_struct->type) {
1421 case MSG_STRUCT_MESSAGE_INFO: {
1422 err = msg_message_list_clear(msg_struct_handle, field);
1426 err = MSG_ERR_INVALID_PARAMETER;
1433 EXPORT_API int msg_list_free(msg_list_handle_t list_handle)
1435 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1436 if (list_handle == NULL)
1437 return MSG_ERR_NULL_POINTER;
1439 g_list_free_full((GList *)list_handle, __msg_release_list_item);
1446 EXPORT_API int msg_util_calculate_text_length(const char* msg_text, msg_encode_type_t msg_encode_type_to, unsigned int *text_size, unsigned int *segment_size, msg_encode_type_t *msg_encode_type_in)
1448 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
1449 msg_error_t err = MSG_SUCCESS;
1451 if (msg_text == NULL || text_size == NULL || segment_size == NULL || msg_encode_type_in == NULL)
1452 return MSG_ERR_INVALID_PARAMETER;
1454 if (msg_encode_type_to > MSG_ENCODE_ASCII7BIT) {
1455 MSG_FATAL("unsupported msg_encode_type [%d]", msg_encode_type_to);
1456 return MSG_ERR_INVALID_PARAMETER;
1459 msg_encode_type_t encodeType = MSG_ENCODE_AUTO;
1460 MSG_LANGUAGE_ID_T langId = MSG_LANG_ID_RESERVED;
1466 bool bAbnormal = false;
1468 textSize = strlen(msg_text);
1470 bufSize = textSize * 4;
1472 unsigned char decodeData[bufSize+1];
1473 memset(decodeData, 0x00, sizeof(decodeData));
1475 MsgTextConvert *textCvt = MsgTextConvert::instance();
1480 switch (msg_encode_type_to) {
1481 case MSG_ENCODE_GSM7BIT:
1482 decodeLen = textCvt->convertUTF8ToGSM7bit(decodeData, bufSize, (const unsigned char*)msg_text, textSize, &langId, &bAbnormal);
1484 case MSG_ENCODE_UCS2:
1485 decodeLen = textCvt->convertUTF8ToUCS2(decodeData, bufSize, (const unsigned char*)msg_text, textSize);
1487 case MSG_ENCODE_AUTO: {
1488 msg_encode_type_t defaultEncodingType = MSG_ENCODE_GSM7BIT;
1489 bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
1490 if (CDMASupported) {
1491 defaultEncodingType = MSG_ENCODE_ASCII7BIT;
1493 decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (const unsigned char*)msg_text, textSize, defaultEncodingType, &encodeType);
1497 return MSG_ERR_INVALID_PARAMETER;
1500 /* calculate segment size. */
1508 if (langId != MSG_LANG_ID_RESERVED) {
1509 MSG_DEBUG("National Language Exists");
1514 if (msg_encode_type_to == MSG_ENCODE_GSM7BIT || encodeType == MSG_ENCODE_GSM7BIT) {
1515 MSG_DEBUG("MSG_ENCODE_GSM7BIT");
1517 if ((decodeLen + headerSize) > 160) {
1519 segSize = ((140 - (headerLen + concat + headerSize)) * 8)/7;
1521 segSize = ((140 - headerLen - headerSize) * 8) / 7;
1525 *msg_encode_type_in = MSG_ENCODE_GSM7BIT_ABNORMAL;
1527 *msg_encode_type_in = MSG_ENCODE_GSM7BIT;
1529 } else if (msg_encode_type_to == MSG_ENCODE_UCS2 || encodeType == MSG_ENCODE_UCS2) {
1530 MSG_DEBUG("MSG_ENCODE_UCS2");
1532 if (decodeLen > 140) {
1534 segSize = 140 - (headerLen + concat);
1539 *msg_encode_type_in = MSG_ENCODE_UCS2;
1540 } else if (encodeType == MSG_ENCODE_ASCII7BIT) {
1541 MSG_DEBUG("MSG_ENCODE_ASCII7BIT");
1544 segSize = ((140*8) - ((headerLen + concat)*8)) / 7;
1548 *msg_encode_type_in = MSG_ENCODE_GSM7BIT;
1550 MSG_DEBUG("Unsupported encode type.");
1551 err = MSG_ERR_INVALID_PARAMETER;
1555 MSG_DEBUG("decodeLen [%d] segSize [%d]", decodeLen, segSize);
1557 *text_size = decodeLen;
1558 *segment_size = segSize;