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.
18 #include <privacy_checker_client.h>
20 #include "MsgHandle.h"
22 #include "MsgException.h"
23 #include "MsgUtilFunction.h"
26 #include "msg_private.h"
27 #include "msg_transport.h"
30 /*==================================================================================================
31 FUNCTION IMPLEMENTATION
32 ==================================================================================================*/
33 EXPORT_API int msg_submit_req(msg_handle_t handle, msg_struct_t req)
35 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
36 msg_error_t err = MSG_SUCCESS;
39 int ret = PRIV_MGR_ERROR_SUCCESS;
40 ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
41 if(ret != PRIV_MGR_ERROR_SUCCESS)
43 return MSG_ERR_PERMISSION_DENIED;
46 if (handle == NULL ||req == NULL)
48 return MSG_ERR_INVALID_PARAMETER;
51 MsgHandle* pHandle = (MsgHandle*)handle;
53 msg_struct_s *pStruct = (msg_struct_s *)req;
57 err = pHandle->submitReq((MSG_REQUEST_S *)pStruct->data);
59 catch (MsgException& e)
61 MSG_FATAL("%s", e.what());
62 return MSG_ERR_TRANSPORT_ERROR;
69 EXPORT_API int msg_reg_sent_status_callback(msg_handle_t handle, msg_sent_status_cb cb, void *user_param)
71 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
72 msg_error_t err = MSG_SUCCESS;
75 int ret = PRIV_MGR_ERROR_SUCCESS;
76 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
77 if(ret != PRIV_MGR_ERROR_SUCCESS)
79 return MSG_ERR_PERMISSION_DENIED;
82 if (handle == NULL || cb == NULL)
84 return MSG_ERR_INVALID_PARAMETER;
87 MsgHandle* pHandle = (MsgHandle*)handle;
91 err = pHandle->regSentStatusCallback(cb, user_param);
93 catch (MsgException& e)
95 MSG_FATAL("%s", e.what());
96 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
97 return MSG_ERR_PERMISSION_DENIED;
99 return MSG_ERR_CALLBACK_ERROR;
106 EXPORT_API int msg_reg_sms_message_callback(msg_handle_t handle, msg_sms_incoming_cb cb, unsigned short port, void *user_param)
108 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
109 msg_error_t err = MSG_SUCCESS;
112 int ret = PRIV_MGR_ERROR_SUCCESS;
113 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
114 if(ret != PRIV_MGR_ERROR_SUCCESS)
116 return MSG_ERR_PERMISSION_DENIED;
119 if (handle == NULL || cb == NULL)
121 return MSG_ERR_INVALID_PARAMETER;
124 MsgHandle* pHandle = (MsgHandle*)handle;
128 err = pHandle->regSmsMessageCallback(cb, port, user_param);
130 catch (MsgException& e)
132 MSG_FATAL("%s", e.what());
133 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
134 return MSG_ERR_PERMISSION_DENIED;
136 return MSG_ERR_CALLBACK_ERROR;
143 EXPORT_API int msg_reg_mms_conf_message_callback(msg_handle_t handle, msg_mms_conf_msg_incoming_cb cb, const char *app_id, void *user_param)
145 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
146 msg_error_t err = MSG_SUCCESS;
149 int ret = PRIV_MGR_ERROR_SUCCESS;
150 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
151 if(ret != PRIV_MGR_ERROR_SUCCESS)
153 return MSG_ERR_PERMISSION_DENIED;
156 if (handle == NULL || cb == NULL)
158 return MSG_ERR_INVALID_PARAMETER;
161 if (app_id && strlen(app_id) > MAX_MMS_JAVA_APPID_LEN)
163 return MSG_ERR_INVALID_PARAMETER;
166 MsgHandle* pHandle = (MsgHandle*)handle;
170 err = pHandle->regMmsConfMessageCallback(cb, app_id, user_param);
172 catch (MsgException& e)
174 MSG_FATAL("%s", e.what());
175 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
176 return MSG_ERR_PERMISSION_DENIED;
178 return MSG_ERR_CALLBACK_ERROR;
185 EXPORT_API int msg_reg_syncml_message_callback(msg_handle_t handle, msg_syncml_msg_incoming_cb cb, void *user_param)
187 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
188 msg_error_t err = MSG_SUCCESS;
191 int ret = PRIV_MGR_ERROR_SUCCESS;
192 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
193 if(ret != PRIV_MGR_ERROR_SUCCESS)
195 return MSG_ERR_PERMISSION_DENIED;
198 if (handle == NULL || cb == NULL)
200 return MSG_ERR_INVALID_PARAMETER;
203 MsgHandle* pHandle = (MsgHandle*)handle;
207 err = pHandle->regSyncMLMessageCallback(cb, user_param);
209 catch (MsgException& e)
211 MSG_FATAL("%s", e.what());
212 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
213 return MSG_ERR_PERMISSION_DENIED;
215 return MSG_ERR_CALLBACK_ERROR;
222 EXPORT_API int msg_reg_lbs_message_callback(msg_handle_t handle, msg_lbs_msg_incoming_cb cb, void *user_param)
224 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
225 msg_error_t err = MSG_SUCCESS;
228 int ret = PRIV_MGR_ERROR_SUCCESS;
229 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
230 if(ret != PRIV_MGR_ERROR_SUCCESS)
232 return MSG_ERR_PERMISSION_DENIED;
235 if (handle == NULL || cb == NULL)
237 return MSG_ERR_INVALID_PARAMETER;
240 MsgHandle* pHandle = (MsgHandle*)handle;
244 err = pHandle->regLBSMessageCallback(cb, user_param);
246 catch (MsgException& e)
248 MSG_FATAL("%s", e.what());
249 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
250 return MSG_ERR_PERMISSION_DENIED;
252 return MSG_ERR_CALLBACK_ERROR;
259 EXPORT_API int msg_reg_syncml_message_operation_callback(msg_handle_t handle, msg_syncml_msg_operation_cb cb, void *user_param)
261 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
262 msg_error_t err = MSG_SUCCESS;
265 int ret = PRIV_MGR_ERROR_SUCCESS;
266 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
267 if(ret != PRIV_MGR_ERROR_SUCCESS)
269 return MSG_ERR_PERMISSION_DENIED;
272 if (handle == NULL || cb == NULL)
274 return MSG_ERR_INVALID_PARAMETER;
277 MsgHandle* pHandle = (MsgHandle*)handle;
281 err = pHandle->regSyncMLMessageOperationCallback(cb, user_param);
283 catch (MsgException& e)
285 MSG_FATAL("%s", e.what());
286 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
287 return MSG_ERR_PERMISSION_DENIED;
289 return MSG_ERR_CALLBACK_ERROR;
296 EXPORT_API int msg_reg_push_message_callback(msg_handle_t handle, msg_push_msg_incoming_cb cb, const char *app_id, void *user_param)
298 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
299 msg_error_t err = MSG_SUCCESS;
302 int ret = PRIV_MGR_ERROR_SUCCESS;
303 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
304 if(ret != PRIV_MGR_ERROR_SUCCESS)
306 return MSG_ERR_PERMISSION_DENIED;
309 if (handle == NULL || cb == NULL)
311 return MSG_ERR_INVALID_PARAMETER;
314 if (app_id && strlen(app_id) > MAX_WAPPUSH_ID_LEN)
316 return MSG_ERR_INVALID_PARAMETER;
319 MsgHandle* pHandle = (MsgHandle*)handle;
323 err = pHandle->regPushMessageCallback(cb, app_id, user_param);
325 catch (MsgException& e)
327 MSG_FATAL("%s", e.what());
328 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
329 return MSG_ERR_PERMISSION_DENIED;
331 return MSG_ERR_CALLBACK_ERROR;
337 EXPORT_API int msg_reg_cb_message_callback(msg_handle_t handle, msg_cb_incoming_cb cb, bool bsave, void *user_param)
339 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
340 msg_error_t err = MSG_SUCCESS;
343 int ret = PRIV_MGR_ERROR_SUCCESS;
344 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
345 if(ret != PRIV_MGR_ERROR_SUCCESS)
347 return MSG_ERR_PERMISSION_DENIED;
350 if (handle == NULL || cb == NULL)
352 return MSG_ERR_INVALID_PARAMETER;
355 MsgHandle* pHandle = (MsgHandle*)handle;
359 err = pHandle->regCBMessageCallback(cb, bsave, user_param);
361 catch (MsgException& e)
363 MSG_FATAL("%s", e.what());
364 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
365 return MSG_ERR_PERMISSION_DENIED;
367 return MSG_ERR_CALLBACK_ERROR;
374 EXPORT_API int msg_reg_report_message_callback(msg_handle_t handle, msg_report_msg_incoming_cb cb, void *user_param)
376 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
377 msg_error_t err = MSG_SUCCESS;
380 int ret = PRIV_MGR_ERROR_SUCCESS;
381 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
382 if(ret != PRIV_MGR_ERROR_SUCCESS)
384 return MSG_ERR_PERMISSION_DENIED;
387 if (handle == NULL || cb == NULL)
389 return MSG_ERR_INVALID_PARAMETER;
392 MsgHandle* pHandle = (MsgHandle*)handle;
396 err = pHandle->regReportMessageCallback(cb, user_param);
398 catch (MsgException& e)
400 MSG_FATAL("%s", e.what());
401 if (e.errorCode() == MsgException::SERVER_READY_ERROR)
402 return MSG_ERR_PERMISSION_DENIED;
404 return MSG_ERR_CALLBACK_ERROR;
411 EXPORT_API int msg_syncml_message_operation(msg_handle_t handle, msg_message_id_t msgId)
413 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
414 msg_error_t err = MSG_SUCCESS;
417 int ret = PRIV_MGR_ERROR_SUCCESS;
418 ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
419 if(ret != PRIV_MGR_ERROR_SUCCESS)
421 return MSG_ERR_PERMISSION_DENIED;
424 if (handle == NULL || msgId < 1)
426 return MSG_ERR_INVALID_PARAMETER;
429 MsgHandle* pHandle = (MsgHandle*)handle;
433 err = pHandle->operateSyncMLMessage(msgId);
435 catch (MsgException& e)
437 MSG_FATAL("%s", e.what());
438 return MSG_ERR_TRANSPORT_ERROR;
445 static msg_handle_t msgHandle = NULL;
446 static msg_simple_sent_status_cb sentStatusCallback = NULL;
448 static void sent_status_cb_func(msg_handle_t handle, msg_struct_t sent_status, void *user_param)
450 // MSG_DEBUG("Sent Status [%d]", sent_status->status);
452 msg_simple_sent_status_cb pfunc = sentStatusCallback;
454 pfunc((msg_struct_t)sent_status, user_param);
456 MSG_DEBUG("After entering callback function.");
458 // Close control handle instance
459 // msg_close_msg_handle(&msgHandle);
461 // MSG_DEBUG("After msg_close_msg_handle.");
466 static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param)
468 if (phone_num == NULL || sms_text == NULL || cb == NULL)
470 MSG_SEC_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num, sms_text, cb);
471 return MSG_ERR_INVALID_PARAMETER;
474 if (strlen(phone_num) > MAX_PHONE_NUMBER_LEN)
476 MSG_SEC_DEBUG("Phone Number is too long [%s]", phone_num);
477 return MSG_ERR_INVALID_PARAMETER;
480 msg_struct_s req = {0,};
481 MSG_REQUEST_S msgReq = {0};
483 req.type = MSG_STRUCT_REQUEST_INFO;
484 req.data = (void *)&msgReq;
486 msg_error_t retVal = MSG_SUCCESS;
488 // Open control handle instance
489 if ((retVal = msg_open_msg_handle(&msgHandle)) != MSG_SUCCESS)
491 MSG_DEBUG("MsgOpenMsgHandle is failed. Error Code = %d", retVal);
495 //msgReq.msg = msg_new_message();
496 MSG_MESSAGE_HIDDEN_S msg_info = {0,};
497 msg_struct_s msg = {0,};
499 msg.type = MSG_STRUCT_MESSAGE_INFO;
500 msg.data = &msg_info;
502 /* when sending SMS */
503 msg_info.mainType = MSG_SMS_TYPE;
504 msg_info.subType = MSG_NORMAL_SMS;
506 msg_info.folderId = MSG_OUTBOX_ID;
507 msg_info.simIndex = MSG_SIM_SLOT_ID_1;
509 /* fill the destination number in msgReq */
510 MSG_ADDRESS_INFO_S address = {0,};
511 memset(&address, 0x00, sizeof(MSG_ADDRESS_INFO_S));
513 address.addressType = MSG_ADDRESS_TYPE_PLMN;
514 address.recipientType = MSG_RECIPIENTS_TYPE_TO;
515 snprintf(address.addressVal, MAX_ADDRESS_VAL_LEN, "%s", phone_num);
517 msg_struct_list_s addr_list = {0,};
519 addr_list.nCount = 1;
520 addr_list.msg_struct_info = (msg_struct_t *)calloc(1, sizeof(msg_struct_t));
521 addr_list.msg_struct_info[0] = (msg_struct_t)new msg_struct_s;
524 pTmp = (msg_struct_s *)addr_list.msg_struct_info[0];
525 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
526 pTmp->data = &address;
528 msg_info.addr_list = (msg_struct_list_s *)&addr_list;
530 msg_info.bPortValid = false;
532 /* fill the msg text in msgReq */
533 msg_info.dataSize = strlen(sms_text);
534 msg_info.pData = (void*)sms_text;
537 msg_struct_s sendOpt = {0,};
538 MSG_SENDINGOPT_S send_info;
539 memset(&send_info, 0x00, sizeof(MSG_SENDINGOPT_S));
541 sendOpt.type = MSG_STRUCT_SENDOPT;
542 sendOpt.data = (void *)&send_info;
544 msg_struct_s smsSendOpt = {0,};
545 SMS_SENDINGOPT_INFO_S sms_send_opt = {0,};
546 memset(&sms_send_opt, 0x00, sizeof(SMS_SENDINGOPT_INFO_S));
548 smsSendOpt.type = MSG_STRUCT_SMS_SENDOPT;
549 smsSendOpt.data = (void *)&sms_send_opt;
551 send_info.smsSendOpt = (msg_struct_t)&smsSendOpt;
553 sentStatusCallback = cb;
555 // register sent status callback
556 retVal = msg_reg_sent_status_callback(msgHandle, sent_status_cb_func, user_param);
558 if (retVal != MSG_SUCCESS)
560 MSG_DEBUG("msg_reg_sent_status_callback() is failed. Error Code = %d", retVal);
561 msg_close_msg_handle(&msgHandle);
565 // sending message request
566 msgReq.msg = (msg_struct_t)&msg;
567 msgReq.sendOpt = (msg_struct_t)&sendOpt;
569 retVal = msg_submit_req(msgHandle, (msg_struct_t)&req);
571 if (addr_list.msg_struct_info) {
572 g_free(addr_list.msg_struct_info);
573 addr_list.msg_struct_info = NULL;
576 if (retVal != MSG_SUCCESS)
578 MSG_DEBUG("msg_submit_req() is failed. Error Code = %d", retVal);
579 msg_close_msg_handle(&msgHandle);
586 EXPORT_API int msg_sms_send(const char *phone_num_list, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param)
588 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
590 int ret = PRIV_MGR_ERROR_SUCCESS;
591 ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
592 if(ret != PRIV_MGR_ERROR_SUCCESS)
594 return MSG_ERR_PERMISSION_DENIED;
597 if (phone_num_list == NULL || sms_text == NULL || cb == NULL)
599 MSG_SEC_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num_list, sms_text, cb);
600 return MSG_ERR_INVALID_PARAMETER;
603 char trimmed_num[strlen(phone_num_list)+1];
604 bzero(trimmed_num, strlen(phone_num_list)+1);
606 msg_error_t retVal = msg_verify_number(phone_num_list, trimmed_num);
608 if ( retVal != MSG_SUCCESS )
611 for( char* cur_num = strtok(trimmed_num,", "); cur_num ; cur_num = strtok(NULL,", "))
613 if (strlen(cur_num) > MAX_PHONE_NUMBER_LEN)
615 MSG_SEC_DEBUG("Phone number is too long [%s], and sending is skipped", cur_num);
619 MSG_SEC_DEBUG("phone number: [%s]", cur_num);
620 MSG_SEC_DEBUG("text: [%s]", sms_text);
621 retVal = msg_send_single_sms(cur_num, sms_text, cb, user_param);
623 if (retVal != MSG_SUCCESS)
631 EXPORT_API int msg_sms_send_message(msg_handle_t handle, msg_struct_t req)
633 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_FEATURE);
634 msg_error_t err = MSG_SUCCESS;
637 int ret = PRIV_MGR_ERROR_SUCCESS;
638 ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
639 if(ret != PRIV_MGR_ERROR_SUCCESS)
641 return MSG_ERR_PERMISSION_DENIED;
644 if (handle == NULL || !req) {
645 MSG_FATAL("handle or req is NULL");
646 return MSG_ERR_NULL_POINTER;
649 msg_struct_s *req_s = (msg_struct_s *)req;
650 MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data;
654 msg_struct_s *msg_s = (msg_struct_s *)pReq->msg;
656 MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data;
658 if (reqmsg->dataSize <= 0) {
659 MSG_FATAL("msg size is invalid : [%d]", reqmsg->dataSize);
660 return MSG_ERR_INVALID_PARAMETER;
663 if (reqmsg->mainType != MSG_SMS_TYPE) {
664 MSG_DEBUG("mainType is not SMS [%d]", reqmsg->mainType);
665 reqmsg->mainType = MSG_SMS_TYPE;
668 if (reqmsg->subType > MSG_CONCAT_SIM_SMS) {
669 MSG_DEBUG("subType is not SMS [%d]", reqmsg->subType);
670 reqmsg->subType = MSG_NORMAL_SMS;
673 reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
674 reqmsg->networkStatus = MSG_NETWORK_SENDING;
676 MSG_DEBUG("Coding Scheme From App. = [%d]", reqmsg->encodeType);
678 err = msg_submit_req(handle, req);
680 if (err == MSG_SUCCESS)
681 MSG_DEBUG("Sending Message is OK!");
683 MSG_DEBUG("Sending Message is failed! [%d]", err);
689 EXPORT_API int msg_mms_send_message(msg_handle_t handle, msg_struct_t req)
691 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
692 msg_error_t err = MSG_SUCCESS;
695 int ret = PRIV_MGR_ERROR_SUCCESS;
696 ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
697 if(ret != PRIV_MGR_ERROR_SUCCESS)
699 return MSG_ERR_PERMISSION_DENIED;
702 if (handle == NULL || !req)
704 MSG_FATAL("handle or req is NULL");
705 return MSG_ERR_INVALID_PARAMETER;
708 msg_struct_s *req_s = (msg_struct_s *)req;
709 MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data;
713 msg_struct_s *msg_s = (msg_struct_s *)pReq->msg;
715 MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data;
717 if (reqmsg->mmsDataSize <= 0)
719 MSG_FATAL("MMS data size is invalid");
720 return MSG_ERR_INVALID_PARAMETER;
723 reqmsg->mainType = MSG_MMS_TYPE;
724 reqmsg->subType = MSG_SENDREQ_MMS;
725 reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
726 reqmsg->networkStatus = MSG_NETWORK_SENDING;
728 err = msg_submit_req(handle, req);
730 if (err == MSG_SUCCESS)
731 MSG_DEBUG("Sending Message is OK!");
733 MSG_DEBUG("Sending Message is failed! [%d]", err);
739 EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t msgId, msg_read_report_status_t mms_read_status)
741 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
742 msg_error_t err = MSG_SUCCESS;
745 int ret = PRIV_MGR_ERROR_SUCCESS;
746 ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
747 if(ret != PRIV_MGR_ERROR_SUCCESS)
749 return MSG_ERR_PERMISSION_DENIED;
754 return MSG_ERR_INVALID_PARAMETER;
757 msg_struct_t req_t = msg_create_struct(MSG_STRUCT_REQUEST_INFO);
759 msg_struct_s *req_s = (msg_struct_s *)req_t;
760 MSG_REQUEST_S *req = (MSG_REQUEST_S *)req_s->data;
761 msg_struct_s *msg_s = (msg_struct_s *)req->msg;
762 MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S *)msg_s->data;
763 void *read_report_data = NULL;
764 size_t read_report_datasize;
766 read_report_datasize = sizeof(msg_read_report_status_t);
767 read_report_data = (void *)calloc(read_report_datasize, 1);
768 if(read_report_data == NULL) {
769 msg_release_struct(&req_t);
770 return MSG_ERR_MEMORY_ERROR;
773 MSG_DEBUG("mms_read_status [%d]", mms_read_status);
774 memcpy(read_report_data, &mms_read_status, read_report_datasize);
778 reqmsg->bPortValid = false;
779 reqmsg->msgId = msgId;
780 reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
781 reqmsg->mainType = MSG_MMS_TYPE;
782 reqmsg->subType = MSG_READREPLY_MMS;
784 reqmsg->mmsDataSize = read_report_datasize;
785 reqmsg->pMmsData = read_report_data;
787 err = msg_submit_req(handle, req_t);
788 if (err == MSG_SUCCESS)
789 MSG_DEBUG("Sending Message is OK!");
791 MSG_DEBUG("Sending Message is failed!");
793 free(read_report_data);
794 read_report_data = NULL;
795 reqmsg->pMmsData = NULL;
797 msg_release_struct(&req_t);
803 EXPORT_API int msg_mms_forward_message(msg_handle_t handle, msg_struct_t req)
805 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
806 msg_error_t err = MSG_SUCCESS;
809 int ret = PRIV_MGR_ERROR_SUCCESS;
810 ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
811 if(ret != PRIV_MGR_ERROR_SUCCESS)
813 return MSG_ERR_PERMISSION_DENIED;
816 if (handle == NULL || !req )
818 MSG_FATAL("handle or req is NULL");
819 return MSG_ERR_INVALID_PARAMETER;
822 msg_struct_s *req_s = (msg_struct_s *)req;
823 MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data;
827 msg_struct_s *msg_s = (msg_struct_s *)pReq->msg;
829 MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data;
831 reqmsg->mainType = MSG_MMS_TYPE;
832 reqmsg->subType = MSG_FORWARD_MMS;
833 reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
834 reqmsg->networkStatus = MSG_NETWORK_SENDING;
836 err = msg_submit_req(handle, req);
838 if (err == MSG_SUCCESS)
839 MSG_DEBUG("Sending Message is OK!");
841 MSG_DEBUG("Sending Message is failed!");
847 EXPORT_API int msg_mms_retrieve_message(msg_handle_t handle, msg_struct_t req)
849 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
850 msg_error_t err = MSG_SUCCESS;
853 int ret = PRIV_MGR_ERROR_SUCCESS;
854 ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
855 if(ret != PRIV_MGR_ERROR_SUCCESS)
857 return MSG_ERR_PERMISSION_DENIED;
860 if ( handle == NULL|| !req)
862 MSG_FATAL("handle or req is NULL");
863 return MSG_ERR_INVALID_PARAMETER;
866 msg_struct_s *req_s = (msg_struct_s *)req;
867 MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data;
869 msg_struct_s *msg_s = (msg_struct_s *)pReq->msg;
870 MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data;
872 reqmsg->mainType = MSG_MMS_TYPE;
873 reqmsg->subType = MSG_RETRIEVE_MMS;
874 reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
875 reqmsg->networkStatus = MSG_NETWORK_RETRIEVING;
877 err = msg_submit_req(handle, req);
879 if (err == MSG_SUCCESS)
880 MSG_DEBUG("Sending Message is OK!");
882 MSG_DEBUG("Sending Message is failed!");
888 /* reject_msg_support */
889 EXPORT_API int msg_mms_reject_message(msg_handle_t handle, msg_struct_t req)
891 CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
892 msg_error_t err = MSG_SUCCESS;
895 int ret = PRIV_MGR_ERROR_SUCCESS;
896 ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
897 if(ret != PRIV_MGR_ERROR_SUCCESS)
899 return MSG_ERR_PERMISSION_DENIED;
902 if (handle == NULL || !req )
904 MSG_FATAL("handle or req is NULL");
905 return MSG_ERR_INVALID_PARAMETER;
908 msg_struct_s *req_s = (msg_struct_s *)req;
909 MSG_REQUEST_S *pReq = (MSG_REQUEST_S *)req_s->data;
911 msg_struct_s *msg_s = (msg_struct_s *)pReq->msg;
912 MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data;
914 reqmsg->mainType = MSG_MMS_TYPE;
915 reqmsg->subType = MSG_NOTIFYRESPIND_MMS;
916 reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
917 reqmsg->networkStatus = MSG_NETWORK_SENDING;
919 err = msg_submit_req(handle, req);
921 if (err == MSG_SUCCESS)
922 MSG_DEBUG("Sending Message is OK!");
924 MSG_DEBUG("Sending Message is failed!");
928 /* reject_msg_support */
931 int msg_request_get_int(void *request_info, int field)
934 MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)request_info;
937 case MSG_REQUEST_REQUESTID_INT:
938 result = pRequest->reqId;
948 int msg_request_get_struct_handle(msg_struct_s *msg_struct, int field, void **value)
950 msg_error_t err = MSG_SUCCESS;
952 if(!msg_struct || !value)
953 return MSG_ERR_NULL_POINTER;
955 MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)msg_struct->data;
958 case MSG_REQUEST_MESSAGE_HND:
959 *value = (void *)pRequest->msg;
961 case MSG_REQUEST_SENDOPT_HND:
962 *value = (void *)pRequest->sendOpt;
965 err = MSG_ERR_UNKNOWN;
972 int msg_request_set_int(void *request_info, int field, int value)
974 msg_error_t err = MSG_SUCCESS;
976 return MSG_ERR_NULL_POINTER;
978 MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)request_info;
981 case MSG_REQUEST_REQUESTID_INT:
982 pRequest->reqId = value;
985 err = MSG_ERR_UNKNOWN;
992 int msg_request_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value)
994 msg_error_t err = MSG_SUCCESS;
995 if(!msg_struct || !value)
996 return MSG_ERR_NULL_POINTER;
998 MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)msg_struct->data;
999 msg_struct_s *pTmp = NULL;
1004 case MSG_REQUEST_MESSAGE_HND:
1006 pTmp = (msg_struct_s *)pRequest->msg;
1007 MSG_MESSAGE_HIDDEN_S *pSrc = (MSG_MESSAGE_HIDDEN_S *)value->data;
1008 MSG_MESSAGE_HIDDEN_S *pDst = (MSG_MESSAGE_HIDDEN_S *)pTmp->data;
1009 msg_message_copy_message(pSrc, pDst);
1012 case MSG_REQUEST_SENDOPT_HND:
1014 pTmp = (msg_struct_s *)pRequest->sendOpt;
1015 MSG_SENDINGOPT_S *pSrc = (MSG_SENDINGOPT_S *)value->data;
1016 MSG_SENDINGOPT_S *pDst = (MSG_SENDINGOPT_S *)pTmp->data;
1017 pDst->bDeliverReq = pSrc->bDeliverReq;
1018 pDst->bKeepCopy = pSrc->bKeepCopy;
1019 pDst->bSetting = pSrc->bSetting;
1021 msg_struct_s *tmpDstMmsSendOpt = (msg_struct_s *)pDst->mmsSendOpt;
1022 msg_struct_s *tmpDstSmsSendOpt = (msg_struct_s *)pDst->smsSendOpt;
1024 msg_struct_s *tmpSrcMmsSendOpt = (msg_struct_s *)pDst->mmsSendOpt;
1025 msg_struct_s *tmpSrcSmsSendOpt = (msg_struct_s *)pDst->smsSendOpt;
1027 tmpDstMmsSendOpt->type = tmpSrcMmsSendOpt->type;
1028 memcpy(tmpDstMmsSendOpt->data, tmpSrcMmsSendOpt->data, sizeof(MMS_SENDINGOPT_S));
1030 tmpDstSmsSendOpt->type = tmpSrcSmsSendOpt->type;
1031 memcpy(tmpDstSmsSendOpt->data, tmpSrcSmsSendOpt->data, sizeof(SMS_SENDINGOPT_S));
1036 err = MSG_ERR_UNKNOWN;
1043 int msg_sent_status_get_int(MSG_SENT_STATUS_S *sent_status_info, int field)
1049 case MSG_SENT_STATUS_REQUESTID_INT:
1050 result = sent_status_info->reqId;
1052 case MSG_SENT_STATUS_NETWORK_STATUS_INT:
1053 result = sent_status_info->status;