2 * Copyright (c) 2016 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.
17 /*==================================================================================================
19 ==================================================================================================*/
28 #include <service_app.h>
29 #include <app_event.h>
30 #include <notification_list.h>
31 #include <notification_text_domain.h>
32 #include <notification_internal.h>
34 #include <call-manager.h>
38 #include "msg_storage.h"
39 #include "msg_transport.h"
41 #include "msg-manager-contact.h"
42 #include "msg-manager-debug.h"
43 #include "msg-manager-notification.h"
44 #include "msg-manager-sound.h"
45 #include "msg-manager-util.h"
47 /*==================================================================================================
49 ==================================================================================================*/
50 msg_handle_t msg_handle = NULL;
51 cm_client_h cm_handle = NULL;
53 pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER;
54 static int job_cnt = 0;
55 static bool terminated = false;
57 /*==================================================================================================
58 FUNCTION IMPLEMENTATION
59 ==================================================================================================*/
60 static int _service_app_exit(void *data)
62 MSG_MGR_INFO("kill msg-manager");
68 static int _check_app_terminate(void *data)
70 pthread_mutex_lock(&mx);
73 MSG_MGR_DEBUG("job_cnt [%d]", job_cnt);
76 g_idle_add(_service_app_exit, NULL);
79 pthread_mutex_unlock(&mx);
84 bool service_app_create(void *data)
86 MSG_MGR_INFO("app_create");
88 int msg_server_ready = 0;
89 for (int i = 0; i < 100; i++) {
90 vconf_get_bool(VCONFKEY_MSG_SERVER_READY, &msg_server_ready);
91 if (msg_server_ready == 1) {
92 int msg_err = msg_open_msg_handle(&msg_handle);
93 if (msg_err != MSG_SUCCESS)
94 MSG_MGR_ERR("msg_open_msg_handle() failed [%d]", msg_err);
96 MSG_MGR_INFO("msg_open_msg_handle() success");
100 MSG_MGR_INFO("msg-server is not ready.");
105 if (msg_handle == NULL)
109 initMsgMgrSoundPlayer();
115 void service_app_terminate(void *data)
117 MSG_MGR_INFO("app_terminate");
119 cm_deinit(cm_handle);
120 MsgMgrCloseContactSvc();
121 msg_close_msg_handle(&msg_handle);
126 void _incoming_msg_func(app_control_h app_control)
131 char *rcv_msg_type = NULL;
132 char *rcv_msg_id = NULL;
134 ret = app_control_get_extra_data(app_control, EVENT_KEY_MSG_ID, &rcv_msg_id);
135 if (ret != APP_CONTROL_ERROR_NONE || rcv_msg_id == NULL) {
136 MSG_MGR_ERR("app_control_get_extra_data failed");
140 ret = app_control_get_extra_data(app_control, EVENT_KEY_MSG_TYPE, &rcv_msg_type);
141 if (ret != APP_CONTROL_ERROR_NONE || rcv_msg_type == NULL) {
142 MSG_MGR_ERR("app_control_get_extra_data failed");
147 MSG_MGR_INFO("rcv_msg_type(%s), rcv_msg_id(%s)", rcv_msg_type, rcv_msg_id);
149 int msg_err = MSG_SUCCESS;
150 msg_message_id_t msg_id = atoi(rcv_msg_id);
151 msg_struct_t msg = NULL;
152 msg_struct_t opt = NULL;
153 contactInfo contact_info = {0, };
154 contact_info.msgId = msg_id;
156 msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
157 opt = msg_create_struct(MSG_STRUCT_SENDOPT);
158 msg_err = msg_get_message(msg_handle, msg_id, msg, opt);
159 if (msg_err != MSG_SUCCESS) {
160 MSG_MGR_ERR("msg_get_message() failed [%d]", msg_err);
161 msg_release_struct(&msg);
162 msg_release_struct(&opt);
166 msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &contact_info.msgType);
167 msg_get_int_value(msg, MSG_MESSAGE_FOLDER_ID_INT, &contact_info.folderId);
168 msg_get_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, &contact_info.simIndex);
169 msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **)&contact_info.addrList);
170 msg_get_str_value(msg, MSG_MESSAGE_SUBJECT_STR, contact_info.subject, MAX_CONTACT_TEXT_LEN);
172 msg_get_int_value(msg, MSG_MESSAGE_DATA_SIZE_INT, &msgSize);
174 msg_get_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, contact_info.msgText, MAX_CONTACT_TEXT_LEN);
176 if ((contact_info.folderId == MSG_INBOX_ID || contact_info.folderId == MSG_SPAMBOX_ID)) {
177 MsgMgrAddPhoneLog(&contact_info);
180 msg_release_struct(&msg);
181 msg_release_struct(&opt);
184 g_free(rcv_msg_type);
189 void _outgoing_msg_func(app_control_h app_control)
194 char *sent_msg_type = NULL;
195 char *sent_msg_id = NULL;
197 ret = app_control_get_extra_data(app_control, EVENT_KEY_OUT_MSG_ID, &sent_msg_id);
198 if (ret != APP_CONTROL_ERROR_NONE || sent_msg_id == NULL) {
199 MSG_MGR_ERR("app_control_get_extra_data failed");
203 ret = app_control_get_extra_data(app_control, EVENT_KEY_OUT_MSG_TYPE, &sent_msg_type);
204 if (ret != APP_CONTROL_ERROR_NONE || sent_msg_type == NULL) {
205 MSG_MGR_ERR("app_control_get_extra_data failed");
210 MSG_MGR_INFO("sent_msg_type(%s) sent_msg_id(%s)", sent_msg_type, sent_msg_id);
212 int msg_err = MSG_SUCCESS;
213 msg_message_id_t msg_id = atoi(sent_msg_id);
214 msg_struct_t msg = NULL;
215 msg_struct_t opt = NULL;
216 contactInfo contact_info = {0, };
217 contact_info.msgId = msg_id;
219 msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
220 opt = msg_create_struct(MSG_STRUCT_SENDOPT);
221 msg_err = msg_get_message(msg_handle, msg_id, msg, opt);
222 if (msg_err != MSG_SUCCESS) {
223 MSG_MGR_ERR("msg_get_message() failed [%d]", msg_err);
224 msg_release_struct(&msg);
225 msg_release_struct(&opt);
229 msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &contact_info.msgType);
230 msg_get_int_value(msg, MSG_MESSAGE_FOLDER_ID_INT, &contact_info.folderId);
231 msg_get_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, &contact_info.simIndex);
232 msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **)&contact_info.addrList);
233 msg_get_str_value(msg, MSG_MESSAGE_SUBJECT_STR, contact_info.subject, 100);
235 msg_get_int_value(msg, MSG_MESSAGE_DATA_SIZE_INT, &msgSize);
237 msg_get_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, contact_info.msgText, 100);
239 MsgMgrAddPhoneLog(&contact_info);
241 msg_release_struct(&msg);
242 msg_release_struct(&opt);
245 g_free(sent_msg_type);
250 void _refresh_noti_func(app_control_h app_control)
253 char *feedback = NULL;
254 char *active_type = NULL;
255 msg_mgr_notification_type_t noti_type = MSG_MGR_NOTI_TYPE_NORMAL;
256 bool bFeedback = true;
257 msg_mgr_active_notification_type_t active_noti_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
259 int ret = app_control_get_extra_data(app_control, "type", &type);
260 if (ret == APP_CONTROL_ERROR_NONE && type) {
261 MSG_MGR_DEBUG("type [%s]", type);
262 if (g_strcmp0(type, "normal") == 0)
263 noti_type = MSG_MGR_NOTI_TYPE_NORMAL;
264 else if (g_strcmp0(type, "failed") == 0)
265 noti_type = MSG_MGR_NOTI_TYPE_FAILED;
269 MSG_MGR_ERR("app_control_get_extra_data failed");
273 ret = app_control_get_extra_data(app_control, "feedback", &feedback);
274 if (ret == APP_CONTROL_ERROR_NONE && feedback) {
275 MSG_MGR_DEBUG("feedback [%s]", feedback);
276 if (g_strcmp0(feedback, "false") == 0)
278 else if (g_strcmp0(feedback, "true") == 0)
284 ret = app_control_get_extra_data(app_control, "active_type", &active_type);
285 if (ret == APP_CONTROL_ERROR_NONE && active_type) {
286 MSG_MGR_DEBUG("active_type [%s]", active_type);
287 if (g_strcmp0(active_type, "none") == 0)
288 active_noti_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
289 else if (g_strcmp0(active_type, "active") == 0)
290 active_noti_type = MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE;
291 else if (g_strcmp0(active_type, "instant") == 0)
292 active_noti_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
297 MsgMgrRefreshNotification(noti_type, bFeedback, active_noti_type);
300 void _add_noti_func(app_control_h app_control)
303 msg_mgr_notification_type_t noti_type = MSG_MGR_NOTI_TYPE_ALL;
305 int ret = app_control_get_extra_data(app_control, "type", &type);
306 if (ret == APP_CONTROL_ERROR_NONE && type) {
307 if (g_strcmp0(type, "voice1") == 0) {
308 noti_type = MSG_MGR_NOTI_TYPE_VOICE_1;
309 } else if (g_strcmp0(type, "voice2") == 0) {
310 noti_type = MSG_MGR_NOTI_TYPE_VOICE_2;
311 } else if (g_strcmp0(type, "mwi") == 0) {
312 noti_type = MSG_MGR_NOTI_TYPE_MWI;
313 } else if (g_strcmp0(type, "class0") == 0) {
314 noti_type = MSG_MGR_NOTI_TYPE_CLASS0;
315 } else if (g_strcmp0(type, "read_report_sent") == 0) {
316 noti_type = MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT;
321 MSG_MGR_ERR("app_control_get_extra_data failed");
326 ret = app_control_get_extra_data(app_control, "msg_id", &msgId);
327 if (ret != APP_CONTROL_ERROR_NONE || msgId == NULL) {
328 MSG_MGR_ERR("app_control_get_extra_data failed");
332 int msg_err = MSG_SUCCESS;
333 msg_message_id_t msg_id = atoi(msgId);
334 msg_struct_t msg = NULL;
335 msg_struct_t opt = NULL;
336 msg_list_handle_t addr_list = NULL;
337 MSG_MGR_MESSAGE_INFO_S msg_info = {0, };
338 msg_info.msgId = msg_id;
340 msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
341 opt = msg_create_struct(MSG_STRUCT_SENDOPT);
342 msg_err = msg_get_message(msg_handle, msg_id, msg, opt);
343 if (msg_err != MSG_SUCCESS) {
344 MSG_MGR_ERR("msg_get_message() failed [%d]", msg_err);
345 msg_release_struct(&msg);
346 msg_release_struct(&opt);
350 msg_get_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, &msg_info.sim_idx);
351 msg_get_int_value(msg, MSG_MESSAGE_DISPLAY_TIME_INT, (int *)&msg_info.displayTime);
352 msg_get_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, (int *)&msg_info.networkStatus);
353 msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addr_list);
355 msg_struct_t addr_data = msg_list_nth_data(addr_list, 0);
356 msg_get_str_value(addr_data, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, msg_info.addressVal, MAX_ADDRESS_VAL_LEN);
357 msg_get_str_value(addr_data, MSG_ADDRESS_INFO_DISPLAYNAME_STR, msg_info.displayName, MAX_DISPLAY_NAME_LEN);
359 if (noti_type == MSG_MGR_NOTI_TYPE_MWI || noti_type == MSG_MGR_NOTI_TYPE_CLASS0) {
361 msg_get_int_value(msg, MSG_MESSAGE_DATA_SIZE_INT, &msg_size);
363 msg_get_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, msg_info.msgText, MAX_MSG_TEXT_LEN);
366 msg_release_struct(&msg);
367 msg_release_struct(&opt);
371 MsgMgrAddNotification(noti_type, &msg_info);
374 void _del_noti_func(app_control_h app_control)
377 msg_mgr_notification_type_t noti_type = MSG_MGR_NOTI_TYPE_ALL;
379 int ret = app_control_get_extra_data(app_control, "type", &type);
380 if (ret == APP_CONTROL_ERROR_NONE && type) {
381 if (g_strcmp0(type, "all") == 0) {
382 noti_type = MSG_MGR_NOTI_TYPE_ALL;
383 } else if (g_strcmp0(type, "normal") == 0) {
384 noti_type = MSG_MGR_NOTI_TYPE_NORMAL;
385 } else if (g_strcmp0(type, "sim") == 0) {
386 noti_type = MSG_MGR_NOTI_TYPE_SIM;
387 } else if (g_strcmp0(type, "voice1") == 0) {
388 noti_type = MSG_MGR_NOTI_TYPE_VOICE_1;
389 } else if (g_strcmp0(type, "voice2") == 0) {
390 noti_type = MSG_MGR_NOTI_TYPE_VOICE_2;
395 MSG_MGR_ERR("app_control_get_extra_data failed");
399 char *simIndex = NULL;
400 ret = app_control_get_extra_data(app_control, "sim_index", &simIndex);
401 if (ret != APP_CONTROL_ERROR_NONE || simIndex == NULL) {
402 MSG_MGR_ERR("app_control_get_extra_data failed");
406 int sim_index = atoi(simIndex);
408 MsgMgrDeleteNoti(noti_type, sim_index);
413 void _add_report_noti_func(app_control_h app_control)
416 msg_mgr_notification_type_t noti_type = MSG_MGR_NOTI_TYPE_ALL;
418 int ret = app_control_get_extra_data(app_control, "type", &type);
419 if (ret == APP_CONTROL_ERROR_NONE && type) {
420 if (g_strcmp0(type, "sms_delivery") == 0) {
421 noti_type = MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT;
422 } else if (g_strcmp0(type, "mms_delivery") == 0) {
423 noti_type = MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT;
424 } else if (g_strcmp0(type, "mms_read") == 0) {
425 noti_type = MSG_MGR_NOTI_TYPE_MMS_READ_REPORT;
430 MSG_MGR_ERR("app_control_get_extra_data failed");
435 ret = app_control_get_extra_data(app_control, "msg_id", &msgId);
436 if (ret != APP_CONTROL_ERROR_NONE || msgId == NULL) {
437 MSG_MGR_ERR("app_control_get_extra_data failed");
441 int msg_err = MSG_SUCCESS;
442 msg_message_id_t msg_id = atoi(msgId);
443 msg_struct_t msg = NULL;
444 msg_struct_t opt = NULL;
445 msg_list_handle_t addr_list = NULL;
446 MSG_MGR_MESSAGE_INFO_S msg_info = {0, };
447 msg_info.msgId = msg_id;
449 msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
450 opt = msg_create_struct(MSG_STRUCT_SENDOPT);
451 msg_err = msg_get_message(msg_handle, msg_id, msg, opt);
452 if (msg_err != MSG_SUCCESS) {
453 MSG_MGR_ERR("msg_get_message() failed [%d]", msg_err);
454 msg_release_struct(&msg);
455 msg_release_struct(&opt);
459 msg_get_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, &msg_info.sim_idx);
460 msg_get_int_value(msg, MSG_MESSAGE_DISPLAY_TIME_INT, (int *)&msg_info.displayTime);
461 msg_get_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, (int *)&msg_info.networkStatus);
462 msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addr_list);
464 msg_struct_t addr_data = msg_list_nth_data(addr_list, 0);
465 msg_get_str_value(addr_data, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, msg_info.addressVal, MAX_ADDRESS_VAL_LEN);
466 msg_get_str_value(addr_data, MSG_ADDRESS_INFO_DISPLAYNAME_STR, msg_info.displayName, MAX_DISPLAY_NAME_LEN);
468 msg_release_struct(&msg);
469 msg_release_struct(&opt);
473 MsgMgrAddReportNotification(noti_type, &msg_info);
476 void _del_report_noti_func(app_control_h app_control)
479 int ret = app_control_get_extra_data(app_control, "address", &addr);
480 if (ret != APP_CONTROL_ERROR_NONE || addr == NULL) {
481 MSG_MGR_ERR("app_control_get_extra_data failed");
485 MsgMgrDeleteReportNotification(addr);
490 void _del_sent_read_report_noti_func(app_control_h app_control)
492 MsgMgrDeleteSentReadReportNotification();
495 void _insert_only_active_noti_func(app_control_h app_control)
498 msg_mgr_notification_type_t noti_type = MSG_MGR_NOTI_TYPE_ALL;
500 int ret = app_control_get_extra_data(app_control, "type", &type);
501 if (ret == APP_CONTROL_ERROR_NONE && type) {
502 if (g_strcmp0(type, "normal") == 0) {
503 noti_type = MSG_MGR_NOTI_TYPE_NORMAL;
504 } else if (g_strcmp0(type, "class0") == 0) {
505 noti_type = MSG_MGR_NOTI_TYPE_CLASS0;
510 MSG_MGR_ERR("app_control_get_extra_data failed");
515 ret = app_control_get_extra_data(app_control, "msg_id", &msgId);
516 if (ret != APP_CONTROL_ERROR_NONE || msgId == NULL) {
517 MSG_MGR_ERR("app_control_get_extra_data failed");
521 int msg_err = MSG_SUCCESS;
522 msg_message_id_t msg_id = atoi(msgId);
523 msg_struct_t msg = NULL;
524 msg_struct_t opt = NULL;
525 msg_list_handle_t addr_list = NULL;
526 MSG_MGR_MESSAGE_INFO_S msg_info = {0, };
527 msg_info.msgId = msg_id;
529 msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
530 opt = msg_create_struct(MSG_STRUCT_SENDOPT);
531 msg_err = msg_get_message(msg_handle, msg_id, msg, opt);
532 if (msg_err != MSG_SUCCESS) {
533 MSG_MGR_ERR("msg_get_message() failed [%d]", msg_err);
534 msg_release_struct(&msg);
535 msg_release_struct(&opt);
539 msg_get_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, &msg_info.sim_idx);
541 if (noti_type == MSG_MGR_NOTI_TYPE_CLASS0) {
542 msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addr_list);
544 msg_struct_t addr_data = msg_list_nth_data(addr_list, 0);
545 msg_get_str_value(addr_data, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, msg_info.addressVal, MAX_ADDRESS_VAL_LEN);
546 msg_get_str_value(addr_data, MSG_ADDRESS_INFO_DISPLAYNAME_STR, msg_info.displayName, MAX_DISPLAY_NAME_LEN);
549 msg_get_int_value(msg, MSG_MESSAGE_DATA_SIZE_INT, &msg_size);
551 msg_get_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, msg_info.msgText, MAX_MSG_TEXT_LEN);
554 msg_release_struct(&msg);
555 msg_release_struct(&opt);
559 MsgMgrInsertOnlyActiveNotification(noti_type, &msg_info);
562 void _insert_ticker_func(app_control_h app_control)
564 char *ticker_msg = NULL;
565 char *locale_ticker_msg = NULL;
566 char *feedback_str = NULL;
567 bool feedback = false;
568 char *msg_id_str = NULL;
571 int ret = app_control_get_extra_data(app_control, "ticker_msg", &ticker_msg);
572 if (ret != APP_CONTROL_ERROR_NONE || ticker_msg == NULL) {
573 MSG_MGR_ERR("app_control_get_extra_data failed [%d]", ret);
574 goto _END_OF_INSERT_TICKER;
577 ret = app_control_get_extra_data(app_control, "locale_ticker_msg", &locale_ticker_msg);
578 if (ret != APP_CONTROL_ERROR_NONE || locale_ticker_msg == NULL) {
579 MSG_MGR_ERR("app_control_get_extra_data failed [%d]", ret);
580 goto _END_OF_INSERT_TICKER;
583 ret = app_control_get_extra_data(app_control, "feedback", &feedback_str);
584 if (ret != APP_CONTROL_ERROR_NONE || feedback_str == NULL) {
585 MSG_MGR_ERR("app_control_get_extra_data failed [%d]", ret);
586 goto _END_OF_INSERT_TICKER;
588 if (g_strcmp0(feedback_str, "true") == 0)
594 ret = app_control_get_extra_data(app_control, "msg_id", &msg_id_str);
595 if (ret != APP_CONTROL_ERROR_NONE || msg_id_str == NULL) {
596 MSG_MGR_ERR("app_control_get_extra_data failed [%d]", ret);
597 goto _END_OF_INSERT_TICKER;
599 msg_id = atoi(msg_id_str);
602 ret = MsgMgrInsertTicker(ticker_msg, locale_ticker_msg, feedback, msg_id);
604 MSG_MGR_ERR("MsgMgrInsertTicker failed [%d]", ret);
606 _END_OF_INSERT_TICKER:
610 if (locale_ticker_msg)
611 g_free(locale_ticker_msg);
614 g_free(feedback_str);
620 void _sound_play_start_func(app_control_h app_control)
623 MSG_MGR_SOUND_TYPE_T sound_type = MSG_MGR_SOUND_PLAY_DEFAULT;
625 int ret = app_control_get_extra_data(app_control, "type", &type);
626 if (ret == APP_CONTROL_ERROR_NONE && type) {
627 if (g_strcmp0(type, "default") == 0) {
628 sound_type = MSG_MGR_SOUND_PLAY_DEFAULT;
629 } else if (g_strcmp0(type, "user") == 0) {
630 sound_type = MSG_MGR_SOUND_PLAY_USER;
631 } else if (g_strcmp0(type, "emergency") == 0) {
632 sound_type = MSG_MGR_SOUND_PLAY_EMERGENCY;
633 } else if (g_strcmp0(type, "voicemail") == 0) {
634 sound_type = MSG_MGR_SOUND_PLAY_VOICEMAIL;
639 MSG_MGR_ERR("app_control_get_extra_data failed");
644 ret = app_control_get_extra_data(app_control, "address", &addr);
647 MSG_MGR_ADDRESS_INFO_S addr_info = {0, };
648 snprintf(addr_info.addressVal, MAX_ADDRESS_VAL_LEN, "%s", addr);
650 MsgMgrSoundPlayStart(&addr_info, sound_type);
654 MsgMgrSoundPlayStart(NULL, sound_type);
658 void _change_pm_state_func(app_control_h app_control)
660 MsgMgrChangePmState();
668 void _reply_msg_func(app_control_h app_control)
672 char *slot_id = NULL;
674 int ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_TEXT, &text);
675 if (ret != APP_CONTROL_ERROR_NONE || text == NULL) {
676 MSG_MGR_ERR("app_control_get_extra_data failed");
680 ret = app_control_get_extra_data(app_control, "addr", &addr);
681 if (ret != APP_CONTROL_ERROR_NONE || addr == NULL) {
682 MSG_MGR_ERR("app_control_get_extra_data failed");
687 ret = app_control_get_extra_data(app_control, "slot_id", &slot_id);
688 if (ret != APP_CONTROL_ERROR_NONE || slot_id == NULL) {
689 MSG_MGR_ERR("app_control_get_extra_data failed");
695 MSG_MGR_DEBUG("text [%s]", text);
696 MSG_MGR_DEBUG("addr [%s]", addr);
697 MSG_MGR_DEBUG("slot_id [%s]", slot_id);
699 msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
700 msg_struct_t opt = msg_create_struct(MSG_STRUCT_SENDOPT);
702 msg_struct_t addr_item = NULL;
703 msg_list_add_item(msg, MSG_MESSAGE_ADDR_LIST_HND, &addr_item);
704 msg_set_int_value(addr_item, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MSG_ADDRESS_TYPE_PLMN);
705 msg_set_int_value(addr_item, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO);
706 msg_set_str_value(addr_item, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, addr, strlen(addr));
708 msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS);
709 msg_set_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, atoi(slot_id));
710 msg_set_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, text, strlen(text));
712 msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO);
713 msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, msg);
714 msg_set_struct_handle(req, MSG_REQUEST_SENDOPT_HND, opt);
716 int msg_err = msg_sms_send_message(msg_handle, req);
717 if (msg_err != MSG_SUCCESS)
718 MSG_MGR_ERR("msg_sms_send_message() failed [%d]", msg_err);
721 ret = app_control_get_extra_data(app_control, "msg_id", &msg_id);
722 if (ret != APP_CONTROL_ERROR_NONE || msg_id == NULL) {
723 MSG_MGR_ERR("app_control_get_extra_data failed");
725 msg_err = msg_update_read_status(msg_handle, atoi(msg_id), true);
726 if (msg_err != MSG_SUCCESS)
727 MSG_MGR_ERR("msg_update_read_status() failed [%d]", msg_err);
732 msg_release_struct(&msg);
733 msg_release_struct(&opt);
734 msg_release_struct(&req);
741 void service_app_control(app_control_h app_control, void *data)
743 MSG_MGR_INFO("service_app_control called");
745 pthread_mutex_lock(&mx);
747 pthread_mutex_unlock(&mx);
750 char *operation = NULL;
753 ret = app_control_get_operation(app_control, &operation);
754 if (ret == APP_CONTROL_ERROR_NONE && operation) {
755 if (g_strcmp0(operation, APP_CONTROL_OPERATION_DEFAULT) == 0) {
756 ret = app_control_get_extra_data(app_control, "cmd", &cmd);
757 if (ret == APP_CONTROL_ERROR_NONE && cmd) {
758 MSG_MGR_INFO("cmd [%s]", cmd);
760 if (g_strcmp0(cmd, "incoming_msg") == 0) {
761 _incoming_msg_func(app_control);
762 } else if (g_strcmp0(cmd, "outgoing_msg") == 0) {
763 _outgoing_msg_func(app_control);
764 } else if (g_strcmp0(cmd, "refresh_noti") == 0) {
765 _refresh_noti_func(app_control);
766 } else if (g_strcmp0(cmd, "add_noti") == 0) {
767 _add_noti_func(app_control);
768 } else if (g_strcmp0(cmd, "del_noti") == 0) {
769 _del_noti_func(app_control);
770 } else if (g_strcmp0(cmd, "add_report_noti") == 0) {
771 _add_report_noti_func(app_control);
772 } else if (g_strcmp0(cmd, "del_report_noti") == 0) {
773 _del_report_noti_func(app_control);
774 } else if (g_strcmp0(cmd, "del_sent_read_report_noti") == 0) {
775 _del_sent_read_report_noti_func(app_control);
776 } else if (g_strcmp0(cmd, "insert_only_active_noti") == 0) {
777 _insert_only_active_noti_func(app_control);
778 } else if (g_strcmp0(cmd, "insert_ticker") == 0) {
779 _insert_ticker_func(app_control);
780 } else if (g_strcmp0(cmd, "sound_play_start") == 0) {
781 _sound_play_start_func(app_control);
782 } else if (g_strcmp0(cmd, "change_pm_state") == 0) {
783 _change_pm_state_func(app_control);
784 } else if (g_strcmp0(cmd, "reply_msg") == 0) {
785 _reply_msg_func(app_control);
789 } else if (ret == APP_CONTROL_ERROR_KEY_NOT_FOUND) {
790 MSG_MGR_INFO("on boot");
797 pthread_mutex_lock(&mx);
799 g_timeout_add_seconds(60, _check_app_terminate, NULL);
800 pthread_mutex_unlock(&mx);
805 int main(int argc, char* argv[])
807 service_app_lifecycle_callback_s event_callback = {0, };
809 event_callback.create = service_app_create;
810 event_callback.terminate = service_app_terminate;
811 event_callback.app_control = service_app_control;
813 return service_app_main(argc, argv, &event_callback, NULL);