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 ==================================================================================================*/
29 #include <app_control.h>
30 #include <badge_internal.h>
31 #include <notification_list.h>
32 #include <notification_text_domain.h>
33 #include <notification_internal.h>
34 #include <notification_status.h>
35 #include <package_manager.h>
39 #include <msg_storage.h>
41 #include <msg-manager-alarm.h>
42 #include <msg-manager-contact.h>
43 #include <msg-manager-debug.h>
44 #include <msg-manager-notification.h>
45 #include <msg-manager-sound.h>
50 /*==================================================================================================
52 ==================================================================================================*/
54 static GList *msg_report_notification_list = NULL;
55 static bool is_init = false;
56 extern msg_handle_t msg_handle;
60 /*==================================================================================================
62 ==================================================================================================*/
63 typedef struct _report_notification_s
66 char addressVal[MAX_ADDRESS_VAL_LEN+1];
67 } report_notification_s;
70 typedef struct _msg_mgr_noti_info_s
72 msg_mgr_notification_type_t type;
78 char sender[MSG_NOTI_TEXT_LEN_S+1];
79 char text[MSG_NOTI_TEXT_LEN+1];
80 char number[MSG_NOTI_TEXT_LEN_S+1];
81 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
84 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
85 msg_message_id_t msg_id;
86 unsigned char extra_data;
88 int active_noti_button_num;
90 int active_media_size;
91 unsigned char active_subtype; /**< to distinguish cb, push message */
92 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
93 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
94 char active_text[MSG_NOTI_TEXT_LEN+1];
95 } MSG_MGR_NOTI_INFO_S;
98 /*==================================================================================================
100 ===================================================================================================*/
102 void MsgMgrInitReportNotiList();
103 void MsgRefreshNotiCb(void *data);
105 notification_h getHandle(int *noti_id);
107 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
108 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
110 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
111 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
112 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
113 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
115 int getAppIcon(const char *app_id, char **icon_path);
116 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
118 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
119 void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type);
120 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
121 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
122 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
123 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
124 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
125 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
126 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
128 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
130 bool isExistAddressInReportTable(const char *addr);
133 void createServiceHandle(app_control_h *svc_h);
134 void setServiceAppId(app_control_h svc_h, const char* app_id);
135 void setServiceUri(app_control_h svc_h, const char* uri);
136 void setServiceOperation(app_control_h svc_h, const char* operation);
137 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
138 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
139 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
140 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
142 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
143 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
144 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
145 void setNotiTime(notification_h noti_h, time_t time);
146 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
147 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
148 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
149 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
152 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
153 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
154 void MsgMgrSoundSetRepeatAlarm();
156 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
158 /*==================================================================================================
159 FUNCTION IMPLEMENTATION
160 ==================================================================================================*/
161 bool _is_valid_email(char *pAddress)
163 if (!pAddress || pAddress[0] == 0)
165 if (!strchr (pAddress, EMAIL_AT))
171 bool isExistAddressInReportTable(const char *addr)
173 char sqlQuery[MAX_QUERY_LEN+1];
174 int rowCnt = 0, colCnt = 0;
175 char **db_res = NULL;
178 char *normal_addr = msg_mgr_normalize_number((char *)addr);
180 memset(sqlQuery, 0x00, sizeof(sqlQuery));
181 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normal_addr);
183 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
184 if (msg_err != MSG_SUCCESS) {
185 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
189 msg_err = msg_db_free(msg_handle, db_res);
190 if (msg_err != MSG_SUCCESS) {
191 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
198 memset(sqlQuery, 0x00, sizeof(sqlQuery));
199 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normal_addr);
201 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
202 if (msg_err != MSG_SUCCESS) {
203 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
207 msg_err = msg_db_free(msg_handle, db_res);
208 if (msg_err != MSG_SUCCESS) {
209 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
220 void MsgMgrInitReportNotiList()
224 if (msg_report_notification_list) {
225 MSG_MGR_DEBUG("Report Noti List is already inited");
229 msg_report_notification_list = NULL;
231 notification_h noti = NULL;
232 notification_list_h noti_list = NULL;
233 notification_list_h head_noti_list = NULL;
234 int noti_err = NOTIFICATION_ERROR_NONE;
235 app_control_h app_control = NULL;
237 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
238 if (noti_err != NOTIFICATION_ERROR_NONE) {
239 MSG_MGR_DEBUG("notification_get_list() is failed!!");
243 head_noti_list = noti_list;
245 while (noti_list != NULL) {
246 noti = notification_list_get_data(noti_list);
248 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
249 memset(tempAddr, 0x00, sizeof(tempAddr));
251 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
252 if (noti_err != NOTIFICATION_ERROR_NONE) {
253 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
259 int ret = app_control_get_extra_data(app_control, "address", &addr);
260 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
261 if (isExistAddressInReportTable(addr)) {
262 report_notification_s *info = new report_notification_s;
263 memset(info, 0x00, sizeof(report_notification_s));
265 notification_get_id(noti, NULL, &(info->priv_id));
266 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
268 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
269 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
276 noti_list = notification_list_get_next(noti_list);
280 notification_free_list(head_noti_list);
286 void MsgMgrInitNoti()
291 bool bNotiSvcReady = false;
293 bNotiSvcReady = notification_is_service_ready();
295 if (bNotiSvcReady == true) {
296 MSG_MGR_DEBUG("Notification server is available");
297 #ifndef MSG_NOTI_INTEGRATION
298 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
300 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
301 MsgMgrInitReportNotiList();
303 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
304 #ifndef MSG_NOTI_INTEGRATION
305 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
307 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
308 delNotiInfo->sim_idx = -1;
310 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
312 notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
319 void MsgRefreshNotiCb(void *data)
321 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
322 MsgMgrInitReportNotiList();
333 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
337 notification_h noti_h = NULL;
339 MSG_MGR_NOTI_INFO_S noti_info = {0, };
341 noti_info.type = noti_type;
342 noti_info.active_noti_button_num = 1;
344 createActiveInfoData(¬i_info, msg_info);
346 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
348 setActiveNotification(noti_h, ¬i_info);
350 clearInfoData(noti_h, ¬i_info);
357 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
360 notification_h noti_h = NULL;
361 int bNotification = 1;
362 /* bool bReplyPopup = false; */
364 MSG_MGR_NOTI_INFO_S noti_info = {0,};
365 noti_info.type = noti_type;
366 noti_info.id = getPrivId(noti_info.type, -1);
368 err = getLatestMsgInfo(¬i_info, false);
371 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
372 goto __END_OF_REFRESH_NOTI;
375 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
376 err = MsgMgrInsertInstantMessage(noti_type);
379 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
380 goto __END_OF_REFRESH_NOTI;
384 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
385 MSG_MGR_DEBUG("vconf_get_bool is failed.");
388 if (bNotification == 0) {
389 MSG_MGR_DEBUG("Msg Alert notification is off.");
390 goto __END_OF_REFRESH_NOTI;
393 createInfoData(¬i_info, active_type);
395 noti_h = getHandle(¬i_info.id);
397 if (noti_h == NULL) {
398 MSG_MGR_DEBUG("Notification handle is NULL");
399 err = MSG_ERR_NULL_POINTER;
400 goto __END_OF_REFRESH_NOTI;
403 setNotification(noti_h, ¬i_info, bFeedback);
405 __END_OF_REFRESH_NOTI :
406 clearInfoData(noti_h, ¬i_info);
412 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
416 notification_h noti_h = NULL;
418 report_notification_s *info = new report_notification_s;
419 memset(info, 0x00, sizeof(report_notification_s));
421 MSG_MGR_NOTI_INFO_S noti_info = {0,};
422 noti_info.type = noti_type;
424 createInfoData(¬i_info, msg_info);
426 noti_h = getHandle(¬i_info.id);
428 if (noti_h == NULL) {
429 MSG_MGR_DEBUG("Notification handle is NULL");
431 goto __END_OF_ADD_REPORT_NOTI;
434 setNotification(noti_h, ¬i_info, true);
436 info->priv_id = noti_info.id;
437 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
438 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
439 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
441 __END_OF_ADD_REPORT_NOTI :
442 clearInfoData(noti_h, ¬i_info);
448 int MsgMgrDeleteReportNotification(const char *addr)
452 notification_h noti_h = NULL;
453 int bNotification = 1;
455 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
456 MSG_MGR_DEBUG("vconf_get_bool is failed.");
459 if (bNotification == 0) {
460 MSG_MGR_DEBUG("Msg Alert notification is off.");
464 char* normalAddr = NULL;
465 unsigned int list_length = g_list_length(msg_report_notification_list);
466 bool isDelete = false;
468 MSG_MGR_DEBUG("list length [%d]", list_length);
470 if (list_length > 0) {
471 GList *iter = g_list_first(msg_report_notification_list);
473 while (iter != NULL) {
475 report_notification_s *info = (report_notification_s*)(iter->data);
477 MSG_MGR_DEBUG("info is NULL!");
481 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
483 noti_h = notification_load(NULL, info->priv_id);
484 if (noti_h == NULL) {
485 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
488 normalAddr = msg_mgr_normalize_number(info->addressVal);
491 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
493 if (g_str_has_suffix(addr, normalAddr)) {
494 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
495 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
498 MSG_MGR_DEBUG("delete notification failed");
503 notification_free(noti_h);
507 iter = g_list_next(iter);
510 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
524 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
528 notification_h noti_h = NULL;
530 MSG_MGR_NOTI_INFO_S noti_info = {0, };
532 noti_info.type = noti_type;
534 createInfoData(¬i_info, msg_info);
536 /* check mwi or voicemail count is 0 then skip add notification */
537 if (noti_info.count == 0) {
538 MSG_MGR_DEBUG("Notification count is 0");
540 goto __END_OF_ADD_NOTI;
543 noti_h = getHandle(¬i_info.id);
545 if (noti_h == NULL) {
546 MSG_MGR_DEBUG("Notification handle is NULL");
548 goto __END_OF_ADD_NOTI;
551 setNotification(noti_h, ¬i_info, true);
554 clearInfoData(noti_h, ¬i_info);
560 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
566 #ifndef MSG_NOTI_INTEGRATION
567 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
570 #ifdef MSG_NOTI_INTEGRATION
571 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
573 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
575 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
577 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
579 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
581 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
584 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
586 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
590 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
592 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
598 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
602 int noti_err = NOTIFICATION_ERROR_NONE;
605 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
606 if (noti_err != NOTIFICATION_ERROR_NONE) {
607 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
611 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
612 if (noti_err != NOTIFICATION_ERROR_NONE) {
613 MSG_MGR_DEBUG("Fail to notification_set_led.");
616 /* set execute option and property */
617 switch (noti_info->type) {
618 case MSG_MGR_NOTI_TYPE_NORMAL: {
619 if (noti_info->count > 1) {
620 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
622 if (noti_info->svc_h) { /* overwrite bundle key "type" */
623 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
624 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
626 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
629 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
632 case MSG_MGR_NOTI_TYPE_CB:
633 case MSG_MGR_NOTI_TYPE_SIM: {
634 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
635 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
638 case MSG_MGR_NOTI_TYPE_FAILED: {
639 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
640 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
643 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
644 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
647 case MSG_MGR_NOTI_TYPE_VOICE_1:
648 case MSG_MGR_NOTI_TYPE_VOICE_2:
649 case MSG_MGR_NOTI_TYPE_MWI:
650 case MSG_MGR_NOTI_TYPE_CLASS0:
651 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
652 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
653 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
654 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
658 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
663 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
664 if (noti_err != NOTIFICATION_ERROR_NONE) {
665 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
673 void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type)
677 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
682 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
686 char unreadMsgCntStr[10] = {0};
689 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
690 MSG_MGR_DEBUG("vconf_get_bool is failed.");
693 /* set title and content */
694 switch (noti_info->type) {
695 #ifdef MSG_NOTI_INTEGRATION
696 case MSG_MGR_NOTI_TYPE_NORMAL:
697 case MSG_MGR_NOTI_TYPE_CB:
698 case MSG_MGR_NOTI_TYPE_SIM: {
699 if (noti_info->count > 1) {
700 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
701 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
702 setNotiTime(noti_h, noti_info->time);
704 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
705 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
709 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
710 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
712 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
713 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
715 setNotiTime(noti_h, noti_info->time);
720 case MSG_MGR_NOTI_TYPE_NORMAL: {
721 if (noti_info->count > 1) {
722 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
723 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
724 setNotiTime(noti_h, noti_info->time);
726 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
727 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
730 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
731 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
733 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
734 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
736 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
737 setNotiTime(noti_h, noti_info->time);
741 case MSG_MGR_NOTI_TYPE_CB: {
742 if (noti_info->count > 1) {
743 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
744 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
745 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
746 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
747 setNotiTime(noti_h, noti_info->time);
750 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
751 setNotiTime(noti_h, noti_info->time);
754 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
755 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
757 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
758 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
763 case MSG_MGR_NOTI_TYPE_SIM: {
764 if (noti_info->count > 1) {
765 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
766 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
767 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
769 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
770 setNotiTime(noti_h, noti_info->time);
772 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
773 setNotiTime(noti_h, noti_info->time);
776 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
777 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
779 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
780 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
786 case MSG_MGR_NOTI_TYPE_FAILED: {
787 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
788 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
789 if (noti_info->count > 1) {
790 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
791 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
793 setNotiTime(noti_h, noti_info->time);
796 case MSG_MGR_NOTI_TYPE_VOICE_1:
797 case MSG_MGR_NOTI_TYPE_VOICE_2: {
798 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
799 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
800 setNotiTime(noti_h, noti_info->time);
802 if (noti_info->count == 1) {
803 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
804 } else if (noti_info->count > 1) {
805 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
806 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
808 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
812 case MSG_MGR_NOTI_TYPE_MWI: {
813 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
814 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
815 setNotiTime(noti_h, noti_info->time);
818 case MSG_MGR_NOTI_TYPE_CLASS0: {
819 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
820 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
821 setNotiTime(noti_h, noti_info->time);
824 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
825 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
826 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
828 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
829 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
830 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
831 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
833 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
836 setNotiTime(noti_h, noti_info->time);
839 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
840 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
841 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
843 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
844 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
845 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
847 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
848 /* notification free */
851 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
854 setNotiTime(noti_h, noti_info->time);
857 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
858 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
859 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
861 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED)
862 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
863 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED)
864 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE);
865 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED)
866 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
867 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED)
868 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE);
869 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE)
870 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE);
871 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED)
872 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL);
873 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE)
874 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE);
875 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR)
876 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL);
877 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
879 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_NONE) {
880 /* notification free */
884 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
886 setNotiTime(noti_h, noti_info->time);
889 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
890 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
891 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
895 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
902 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
906 switch (noti_info->type) {
907 #ifdef MSG_NOTI_INTEGRATION
908 case MSG_MGR_NOTI_TYPE_NORMAL:
909 case MSG_MGR_NOTI_TYPE_CB:
910 case MSG_MGR_NOTI_TYPE_SIM: {
911 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
912 if (noti_info->count > 1 && noti_info->senderCount > 1) {
913 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
914 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
915 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
917 if (noti_info->active_subtype == MSG_CB_SMS) {
918 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
919 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
920 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
921 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
922 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
923 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
924 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
926 if (noti_info->imagePath[0] != '\0') {
927 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
928 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
930 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
931 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
934 char *msg_icon_path = NULL;
935 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
936 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
937 g_free(msg_icon_path);
939 MSG_MGR_ERR("fail to get message-app icon");
946 case MSG_MGR_NOTI_TYPE_NORMAL: {
947 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
948 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
950 if (noti_info->count > 1) {
951 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
953 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
957 case MSG_MGR_NOTI_TYPE_CB: {
958 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
959 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
962 case MSG_MGR_NOTI_TYPE_SIM: {
963 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
964 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
968 case MSG_MGR_NOTI_TYPE_FAILED: {
969 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
970 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SMS_SENDING_FAILED_ICON_PATH);
973 case MSG_MGR_NOTI_TYPE_VOICE_1:
974 case MSG_MGR_NOTI_TYPE_VOICE_2:
975 case MSG_MGR_NOTI_TYPE_MWI: {
976 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
977 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
980 case MSG_MGR_NOTI_TYPE_CLASS0:
981 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
983 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
984 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
985 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
987 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
988 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
989 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
991 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
992 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
993 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
995 case MSG_MGR_NOTI_TYPE_SIM_FULL:
996 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
997 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1000 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1007 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1011 int noti_err = NOTIFICATION_ERROR_NONE;
1014 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1015 if (noti_err != NOTIFICATION_ERROR_NONE) {
1016 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1020 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1021 if (noti_err != NOTIFICATION_ERROR_NONE) {
1022 MSG_MGR_DEBUG("Fail to notification_set_led.");
1026 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1027 if (noti_err != NOTIFICATION_ERROR_NONE) {
1028 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1035 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1039 switch (noti_info->type) {
1040 case MSG_MGR_NOTI_TYPE_NORMAL:
1041 case MSG_MGR_NOTI_TYPE_SIM:
1042 case MSG_MGR_NOTI_TYPE_CB: {
1043 if (noti_info->active_subject[0] == '\0') {
1044 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1045 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1047 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1048 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1049 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1053 case MSG_MGR_NOTI_TYPE_CLASS0: {
1054 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1055 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1059 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1067 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1071 switch (noti_info->type) {
1072 case MSG_MGR_NOTI_TYPE_NORMAL:
1073 case MSG_MGR_NOTI_TYPE_SIM: {
1074 switch (noti_info->active_subtype) {
1076 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1078 case MSG_WAP_SI_SMS:
1079 case MSG_WAP_SL_SMS:
1080 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1083 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1086 if (noti_info->imagePath[0] != '\0')
1087 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1089 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1091 char *msg_icon_path = NULL;
1092 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1093 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1094 g_free(msg_icon_path);
1096 MSG_MGR_ERR("fail to get message-app icon");
1104 case MSG_MGR_NOTI_TYPE_CB: {
1105 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1108 case MSG_MGR_NOTI_TYPE_CLASS0:
1109 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1112 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1120 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1124 MSG_MGR_ADDRESS_INFO_S addrInfo = {0,};
1125 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
1127 if (addressVal != NULL) {
1128 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1129 /* Get Contact Info */
1130 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1131 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1134 MSG_MGR_DEBUG("addressVal is NULL.");
1137 char *msg_tone_file_path = NULL;
1139 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1141 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1143 bool bPlaySound = false;
1144 bool bPlayVibration = false;
1145 bool bOnCall = false;
1147 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1150 if (msg_tone_file_path)
1151 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1154 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1155 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1157 int ringtoneType = tmpVal;
1158 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1159 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1161 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1164 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1167 if (bPlayVibration) {
1168 if (contactInfo.vibrationPath[0] == '\0')
1169 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1171 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1173 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1176 if (msg_tone_file_path)
1177 delete [] msg_tone_file_path;
1183 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1187 int noti_err = NOTIFICATION_ERROR_NONE;
1189 setActiveProperty(noti_h, noti_info);
1191 setTextDomain(noti_h, noti_info->type);
1193 setActiveText(noti_h, noti_info);
1195 setActiveIcon(noti_h, noti_info);
1197 if (noti_info->active_noti_button_num > 1) {
1198 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1199 if (noti_info->active_noti_svc_h[0]) {
1200 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1201 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1203 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1205 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1206 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1207 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1208 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1211 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1212 if (noti_info->active_noti_svc_h[1]) {
1213 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1215 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1216 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1217 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1219 char slot_id[5] = {0, };
1220 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1221 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1225 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1226 if (noti_info->active_noti_svc_h[2]) {
1227 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1229 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1230 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1231 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1232 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1234 char slot_id[5] = {0, };
1235 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1236 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1239 if (noti_info->active_noti_button_num > 1) {
1240 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1241 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1242 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1244 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1245 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1246 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1248 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1250 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1253 noti_err = notification_post(noti_h);
1254 if (noti_err != NOTIFICATION_ERROR_NONE) {
1255 MSG_MGR_DEBUG("Fail to notification_post");
1262 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1266 int noti_err = NOTIFICATION_ERROR_NONE;
1268 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1270 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1271 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1272 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1274 setActiveNotification(active_noti_h, noti_info);
1276 notification_free(active_noti_h);
1277 active_noti_h = NULL;
1280 setProperty(noti_h, noti_info);
1282 setTextDomain(noti_h, noti_info->type);
1284 setText(noti_h, noti_info);
1286 setIcon(noti_h, noti_info);
1289 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1290 setSoundAndVibration(noti_h, noti_info->number, true);
1292 setSoundAndVibration(noti_h, noti_info->number, false);
1295 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1296 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1299 if (noti_info->id > 0) {
1300 MSG_MGR_DEBUG("Notification update");
1301 noti_err = notification_update(noti_h);
1302 if (noti_err != NOTIFICATION_ERROR_NONE) {
1303 MSG_MGR_DEBUG("Fail to notification_update");
1306 MSG_MGR_DEBUG("Notification insert");
1307 noti_err = notification_insert(noti_h, ¬i_info->id);
1308 if (noti_err != NOTIFICATION_ERROR_NONE) {
1309 MSG_MGR_DEBUG("Fail to notification_insert");
1312 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1319 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1324 MSG_MGR_DEBUG("msg_info is NULL");
1328 noti_info->msg_id = msg_info->msgId;
1329 noti_info->sim_idx = msg_info->sim_idx;
1331 switch (noti_info->type) {
1332 case MSG_MGR_NOTI_TYPE_NORMAL: {
1333 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1334 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1341 case MSG_MGR_NOTI_TYPE_CLASS0: {
1342 if (msg_info->displayName[0] == '\0')
1343 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1345 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1347 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1351 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1359 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1364 notification_free(noti_h);
1368 if (noti_info->svc_h) {
1369 app_control_destroy(noti_info->svc_h);
1370 noti_info->svc_h = NULL;
1373 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1374 if (noti_info->active_noti_svc_h[i]) {
1375 app_control_destroy(noti_info->active_noti_svc_h[i]);
1376 noti_info->active_noti_svc_h[i] = NULL;
1384 int getAppIcon(const char *app_id, char **icon_path)
1388 package_info_h pkg_info_h = NULL;
1389 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1392 if (app_id == NULL) {
1393 MSG_MGR_ERR("app id is NULL");
1395 goto END_OF_GET_APP_ICON;
1398 pkg_err = package_info_create(app_id, &pkg_info_h);
1399 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1400 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1402 goto END_OF_GET_APP_ICON;
1405 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1406 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1407 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1410 if (icon_path == NULL) {
1411 MSG_MGR_WARN("icon path is NULL");
1416 END_OF_GET_APP_ICON:
1418 pkg_err = package_info_destroy(pkg_info_h);
1419 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1420 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1432 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1437 msg_error_t msg_err = MSG_SUCCESS;
1438 char **db_res = NULL;
1439 int row_cnt = 0, col_cnt = 0;
1441 switch (noti_info->type) {
1442 case MSG_MGR_NOTI_TYPE_NORMAL:
1443 #ifdef MSG_NOTI_INTEGRATION
1444 case MSG_MGR_NOTI_TYPE_CB:
1445 case MSG_MGR_NOTI_TYPE_SIM:
1448 int smsUnreadCnt = 0;
1449 int mmsUnreadCnt = 0;
1451 char sqlQuery[MAX_QUERY_LEN +1];
1452 unsigned char mainType;
1453 unsigned char subType;
1456 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1457 #ifdef MSG_NOTI_INTEGRATION
1458 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1462 "WHERE A.CONV_ID=B.CONV_ID "
1463 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1464 "AND B.STORAGE_ID = %d "
1465 "GROUP BY A.ADDRESS_VAL "
1466 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1467 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1468 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1471 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1475 "WHERE A.CONV_ID=B.CONV_ID "
1476 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1477 "AND B.STORAGE_ID = %d "
1478 "GROUP BY A.ADDRESS_VAL "
1479 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1480 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1484 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1486 row_cnt = 0, col_cnt = 0;
1487 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1488 if (msg_err != MSG_SUCCESS) {
1489 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1493 /* contacts-service is not used for gear */
1494 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
1495 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1496 int normalAddCnt = 0;
1497 int index = col_cnt;
1499 for (int i = 1; i <= row_cnt; i++) {
1500 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1502 char *address = db_res[index++];
1505 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1506 if (_is_valid_email(address)) {
1507 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1509 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1512 subType = atoi(db_res[index++]);
1514 MSG_MGR_CONTACT_INFO_S tmpContact;
1515 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1517 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1520 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1523 if (normalAddCnt > 1) {
1524 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1527 if (tmpContact.firstName[0] != '\0') {
1528 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1529 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1530 char *senderStr = NULL;
1531 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1532 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1539 noti_info->active_noti_button_num = 1;
1542 char *senderStr = NULL;
1543 if (subType == MSG_CB_SMS) {
1544 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1545 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1546 noti_info->active_noti_button_num = 1;
1547 } else if (subType == MSG_SYNCML_CP) {
1548 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1549 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1550 noti_info->active_noti_button_num = 1;
1551 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1552 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1553 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1554 noti_info->active_noti_button_num = 1;
1556 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1566 noti_info->active_subtype = subType;
1567 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1568 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1572 noti_info->senderCount = normalAddCnt;
1573 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
1574 msg_db_free(msg_handle, db_res);
1576 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1578 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1580 #ifdef MSG_NOTI_INTEGRATION
1581 snprintf(sqlQuery, sizeof(sqlQuery),
1588 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1589 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1590 "(CASE WHEN B.MAIN_TYPE = %d AND B.NETWORK_STATUS = %d THEN (SELECT C.MSG_SIZE FROM %s C WHERE B.MSG_ID = C.MSG_ID) ELSE -1 END) "
1592 "WHERE A.CONV_ID=B.CONV_ID "
1593 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1594 "AND B.STORAGE_ID = %d "
1595 "ORDER BY B.DISPLAY_TIME DESC;",
1598 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1599 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1600 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1603 snprintf(sqlQuery, sizeof(sqlQuery),
1610 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1611 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1613 "WHERE A.CONV_ID=B.CONV_ID "
1614 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1615 "AND B.STORAGE_ID = %d "
1616 "ORDER BY B.DISPLAY_TIME DESC;",
1619 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1623 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1625 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1626 if (msg_err != MSG_SUCCESS) {
1627 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1632 smsUnreadCnt = atoi(db_res[col_cnt+6]);
1633 mmsUnreadCnt = atoi(db_res[col_cnt+7]);
1634 msgSize = atoi(db_res[col_cnt+8]);
1636 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1638 if (noti_info->count > 0) {
1639 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1641 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1643 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1645 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1647 if (mainType == MSG_MMS_TYPE) {
1648 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1649 if (noti_info->text[0] == '\0') {
1650 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1651 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1655 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1656 if (prefix_subject) {
1657 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1658 g_free(prefix_subject);
1660 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1664 int kb_msg_size = msgSize / 1024;
1665 if (kb_msg_size == 0 && msgSize > 0)
1667 else if (msgSize % 1024 >= 512)
1670 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1671 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1673 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1675 g_free(msg_size_string);
1676 g_free(msg_size_unit_kb);
1680 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1683 if (noti_info->active_text[0] == '\0')
1684 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1686 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1688 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1689 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1690 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1692 if (!isForInstantMessage) {
1693 if (noti_info->id > 0 && noti_info->count == 1) {
1694 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1695 if (noti_err != NOTIFICATION_ERROR_NONE) {
1696 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1700 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1701 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1704 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1705 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1706 MsgMgrInsertBadge(noti_info->count);
1707 MsgMgrSoundSetRepeatAlarm();
1710 MSG_MGR_DEBUG("No unread message.");
1711 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1713 msg_db_free(msg_handle, db_res);
1715 if (!isForInstantMessage) {
1716 /* No unread message. */
1717 if (noti_info->id > 0) {
1718 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1719 if (noti_err != NOTIFICATION_ERROR_NONE) {
1720 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1726 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1727 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1729 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1730 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1731 MsgMgrInsertBadge(0);
1732 MsgMgrSoundSetRepeatAlarm();
1738 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1739 msg_db_free(msg_handle, db_res);
1743 msg_db_free(msg_handle, db_res);
1747 #ifndef MSG_NOTI_INTEGRATION
1748 case MSG_MGR_NOTI_TYPE_CB: {
1749 char sqlQuery[MAX_QUERY_LEN+1];
1750 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1752 snprintf(sqlQuery, sizeof(sqlQuery),
1758 "WHERE A.CONV_ID=B.CONV_ID "
1759 "AND B.READ_STATUS=0 "
1760 "AND B.FOLDER_ID=%d "
1761 "AND B.STORAGE_ID = %d "
1762 "ORDER BY B.DISPLAY_TIME DESC;",
1763 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1767 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1768 return MSG_ERR_DB_PREPARE;
1770 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1771 MSG_ADDRESS_INFO_S addrInfo;
1772 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1774 if (dbhandler->columnText(0) != NULL)
1775 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1777 MSG_CONTACT_INFO_S tmpContact;
1778 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1780 MsgGetContactInfo(&addrInfo, &tmpContact);
1782 if (tmpContact.firstName[0] != '\0') {
1783 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1784 } else if (addrInfo.addressVal[0] == '\0') {
1785 char *senderStr = NULL;
1786 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1787 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1793 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1796 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1798 noti_info->time = (time_t)dbhandler->columnInt(1);
1800 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1802 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1804 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1806 MSG_MGR_DEBUG("No unread CB message.");
1807 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1809 dbhandler->finalizeQuery();
1811 if (!isForInstantMessage) {
1812 /* No unread message. */
1813 if (noti_info->id > 0) {
1814 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1815 if (noti_err != NOTIFICATION_ERROR_NONE) {
1816 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1822 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1823 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1825 return MSG_ERR_DB_STEP;
1828 dbhandler->finalizeQuery();
1830 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
1831 MSG_MGR_DEBUG("getTable is failed");
1832 dbhandler->freeTable();
1833 return MSG_ERR_DB_GETTABLE;
1836 dbhandler->freeTable();
1837 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
1840 case MSG_MGR_NOTI_TYPE_SIM: {
1841 char sqlQuery[MAX_QUERY_LEN+1];
1842 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1844 snprintf(sqlQuery, sizeof(sqlQuery),
1849 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
1851 "WHERE A.CONV_ID=B.CONV_ID "
1852 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1853 "AND B.STORAGE_ID = %d "
1854 "ORDER BY B.DISPLAY_TIME DESC;",
1856 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1860 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1862 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1863 return MSG_ERR_DB_PREPARE;
1865 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1866 noti_info->count = dbhandler->columnInt(4);
1868 if (noti_info->count > 0) {
1869 MSG_ADDRESS_INFO_S addrInfo;
1870 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1872 if (dbhandler->columnText(0) != NULL)
1873 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1875 MSG_CONTACT_INFO_S tmpContact;
1876 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1878 MsgGetContactInfo(&addrInfo, &tmpContact);
1880 if (tmpContact.firstName[0] != '\0') {
1881 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1882 } else if (addrInfo.addressVal[0] == '\0') {
1883 char *senderStr = NULL;
1884 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1885 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1891 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1894 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1896 noti_info->time = (time_t)dbhandler->columnInt(1);
1898 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1900 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1902 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
1904 MSG_MGR_DEBUG("No unread SIM message.");
1905 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1907 dbhandler->finalizeQuery();
1909 if (!isForInstantMessage) {
1910 /* No unread message. */
1911 if (noti_info->id > 0) {
1912 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1913 if (noti_err != NOTIFICATION_ERROR_NONE) {
1914 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1920 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1921 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
1924 return MSG_ERR_DB_STEP;
1927 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1928 dbhandler->finalizeQuery();
1929 return MSG_ERR_DB_STEP;
1932 dbhandler->finalizeQuery();
1936 case MSG_MGR_NOTI_TYPE_FAILED: {
1937 char sqlQuery[MAX_QUERY_LEN+1];
1938 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1940 snprintf(sqlQuery, sizeof(sqlQuery),
1947 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
1949 "WHERE A.CONV_ID=B.CONV_ID "
1950 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1951 "AND B.STORAGE_ID = %d "
1952 "ORDER BY B.DISPLAY_TIME DESC;",
1953 MSG_NETWORK_SEND_FAIL,
1954 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1958 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1960 row_cnt = 0, col_cnt = 0;
1961 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1962 if (msg_err != MSG_SUCCESS) {
1963 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1968 noti_info->count = atoi(db_res[col_cnt+6]);
1970 if (noti_info->count > 0) {
1971 MSG_MGR_ADDRESS_INFO_S addrInfo = {0,};
1973 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
1975 MSG_MGR_CONTACT_INFO_S tmpContact = {0,};
1977 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
1979 if (tmpContact.firstName[0] != '\0') {
1980 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1981 } else if (addrInfo.addressVal[0] == '\0') {
1982 char *senderStr = NULL;
1983 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1984 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1990 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1993 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1995 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1997 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1999 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2001 if (mainType == MSG_TYPE_MMS)
2002 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2004 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2006 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2008 if (!isForInstantMessage) {
2009 if (noti_info->id > 0 && noti_info->count == 1) {
2010 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
2011 if (noti_err != NOTIFICATION_ERROR_NONE) {
2012 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2015 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2016 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2020 MSG_MGR_DEBUG("No sent failed message.");
2021 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2023 msg_db_free(msg_handle, db_res);
2025 if (!isForInstantMessage) {
2026 /* No unread message. */
2027 if (noti_info->id > 0) {
2028 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
2029 if (noti_err != NOTIFICATION_ERROR_NONE) {
2030 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2036 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2037 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2043 msg_db_free(msg_handle, db_res);
2047 msg_db_free(msg_handle, db_res);
2050 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2053 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2063 notification_h getHandle(int *noti_id)
2065 notification_h noti_h = NULL;
2068 MSG_MGR_DEBUG("Notification load");
2069 noti_h = notification_load(NULL, *noti_id);
2071 MSG_MGR_DEBUG("notification_load is failed.");
2074 if (noti_h == NULL) {
2075 MSG_MGR_DEBUG("Notification create");
2076 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2077 if (noti_h == NULL) {
2078 MSG_MGR_DEBUG("notification_create is failed.");
2089 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2095 switch (noti_type) {
2096 #ifdef MSG_NOTI_INTEGRATION
2097 case MSG_MGR_NOTI_TYPE_NORMAL:
2098 case MSG_MGR_NOTI_TYPE_SIM:
2099 case MSG_MGR_NOTI_TYPE_CB:
2100 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2103 case MSG_MGR_NOTI_TYPE_NORMAL:
2104 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2106 case MSG_MGR_NOTI_TYPE_SIM:
2107 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2109 case MSG_MGR_NOTI_TYPE_CB:
2110 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2113 case MSG_MGR_NOTI_TYPE_FAILED:
2114 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2116 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2117 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2118 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2119 vconf_get_int(keyName, ¬i_id);
2122 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2123 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2124 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2125 vconf_get_int(keyName, ¬i_id);
2128 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2129 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2132 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2136 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2144 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2150 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2152 switch (noti_type) {
2153 #ifdef MSG_NOTI_INTEGRATION
2154 case MSG_MGR_NOTI_TYPE_NORMAL:
2155 case MSG_MGR_NOTI_TYPE_SIM:
2156 case MSG_MGR_NOTI_TYPE_CB:
2157 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2160 case MSG_MGR_NOTI_TYPE_NORMAL:
2161 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2163 case MSG_MGR_NOTI_TYPE_SIM:
2164 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2166 case MSG_MGR_NOTI_TYPE_CB:
2167 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2170 case MSG_MGR_NOTI_TYPE_FAILED:
2171 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2173 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2174 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2175 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2176 err = vconf_set_int(keyName, noti_id);
2179 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2180 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2181 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2182 err = vconf_set_int(keyName, noti_id);
2185 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2186 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2189 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2194 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2200 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2205 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2206 noti_info->msg_id = msg_info->msgId;
2208 MSG_MGR_DEBUG("msg_info is NULL");
2212 noti_info->sim_idx = msg_info->sim_idx;
2214 createServiceHandle(¬i_info->svc_h);
2215 char keyName[MAX_VCONFKEY_NAME_LEN];
2217 switch (noti_info->type) {
2218 case MSG_MGR_NOTI_TYPE_VOICE_1:
2219 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2220 memset(keyName, 0x00, sizeof(keyName));
2221 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2222 vconf_get_int(keyName, ¬i_info->count);
2223 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2224 noti_info->time = msg_info->displayTime;
2226 memset(keyName, 0x00, sizeof(keyName));
2227 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2228 char *voiceNumber = vconf_get_str(keyName);
2229 memset(keyName, 0x00, sizeof(keyName));
2230 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2231 char *voiceAlphaId = vconf_get_str(keyName);
2232 char *dialNumber = NULL;
2234 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2236 if (voiceNumber && strlen(voiceNumber))
2237 dialNumber = voiceNumber;
2239 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2240 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2241 } else if (dialNumber && strlen(dialNumber) > 0) {
2242 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2245 if (dialNumber && strlen(dialNumber) > 0)
2246 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2248 if (noti_info->svc_h) {
2249 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2250 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2252 char slot_id[5] = {0, };
2253 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2254 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2257 if (voiceNumber) g_free(voiceNumber);
2258 if (voiceAlphaId) g_free(voiceAlphaId);
2261 case MSG_MGR_NOTI_TYPE_MWI:
2262 case MSG_MGR_NOTI_TYPE_CLASS0: {
2263 noti_info->count = 1;
2264 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2265 noti_info->time = msg_info->displayTime;
2267 if (msg_info->displayName[0] == '\0')
2268 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2270 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2272 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2274 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2276 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2277 if (noti_info->svc_h) {
2278 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2279 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2281 char slot_id[5] = {0, };
2282 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2283 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2287 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2288 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2289 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2293 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2294 noti_info->count = 1;
2295 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2296 noti_info->time = msg_info->displayTime;
2297 noti_info->extra_data = msg_info->networkStatus;
2299 /* contacts-service is not used for gear */
2300 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
2301 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
2302 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,};
2303 if (msg_info->addressVal) {
2304 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2305 if (_is_valid_email(msg_info->addressVal)) {
2306 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2308 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2312 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2313 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2315 #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
2317 if (contactInfo.firstName[0] == '\0')
2318 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2320 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2322 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2324 if (noti_info->msg_id > 0) {
2325 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2326 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2327 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2328 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2332 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2333 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2334 noti_info->count = 1;
2335 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2336 noti_info->time = msg_info->displayTime;
2338 /* contacts-service is not used for gear */
2339 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
2340 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
2341 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,};
2342 if (msg_info->addressVal) {
2343 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2344 if (_is_valid_email(msg_info->addressVal)) {
2345 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2347 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2351 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2352 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2354 #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
2355 if (contactInfo.firstName[0] == '\0')
2356 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2358 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2360 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2362 char sqlQuery[MAX_QUERY_LEN+1];
2363 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2365 int report_status_type;
2366 int report_status_value;
2368 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2369 report_status_type = MSG_REPORT_TYPE_READ;
2371 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2374 snprintf(sqlQuery, sizeof(sqlQuery),
2377 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';",
2378 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2380 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2382 char **db_res = NULL;
2383 int row_cnt = 0, col_cnt = 0;
2385 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2386 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2387 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2391 report_status_value = atoi(db_res[col_cnt]);
2393 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2395 msg_err = msg_db_free(msg_handle, db_res);
2396 if (msg_err != MSG_SUCCESS) {
2397 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2401 if (noti_info->msg_id > 0) {
2402 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2403 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2404 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2405 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2408 noti_info->extra_data = (unsigned char)report_status_value;
2412 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2416 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2421 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2425 createServiceHandle(¬i_info->svc_h);
2427 switch (noti_info->type) {
2428 case MSG_MGR_NOTI_TYPE_NORMAL: {
2429 if (noti_info->count > 1) {
2430 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2432 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2435 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2436 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2437 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2438 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2440 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
2442 if (noti_info->active_noti_button_num == 0)
2443 noti_info->active_noti_button_num = 3;
2446 case MSG_MGR_NOTI_TYPE_CB: {
2447 if (noti_info->count > 1) {
2448 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2450 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2453 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2454 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2455 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2457 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2458 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2460 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2462 noti_info->active_noti_button_num = 1;
2465 case MSG_MGR_NOTI_TYPE_SIM: {
2466 if (noti_info->count > 1) {
2467 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2469 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2472 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2473 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2474 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2476 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2477 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2479 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2481 if (noti_info->active_noti_button_num == 0)
2482 noti_info->active_noti_button_num = 3;
2485 case MSG_MGR_NOTI_TYPE_FAILED: {
2486 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2488 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2489 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2490 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2492 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2495 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2496 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2498 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2499 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2501 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2508 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2509 noti_info->active_noti_button_num = 0;
2515 void createServiceHandle(app_control_h *svc_h)
2517 int svc_err = APP_CONTROL_ERROR_NONE;
2519 svc_err = app_control_create(svc_h);
2521 if (svc_err != APP_CONTROL_ERROR_NONE)
2522 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2526 void setServiceAppId(app_control_h svc_h, const char* app_id)
2528 int svc_err = APP_CONTROL_ERROR_NONE;
2530 svc_err = app_control_set_app_id(svc_h, app_id);
2532 if (svc_err != APP_CONTROL_ERROR_NONE)
2533 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2537 void setServiceUri(app_control_h svc_h, const char* uri)
2539 int svc_err = APP_CONTROL_ERROR_NONE;
2541 svc_err = app_control_set_uri(svc_h, uri);
2543 if (svc_err != APP_CONTROL_ERROR_NONE)
2544 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2548 void setServiceOperation(app_control_h svc_h, const char* operation)
2550 int svc_err = APP_CONTROL_ERROR_NONE;
2552 svc_err = app_control_set_operation(svc_h, operation);
2554 if (svc_err != APP_CONTROL_ERROR_NONE)
2555 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2559 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2561 int svc_err = APP_CONTROL_ERROR_NONE;
2563 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2565 if (svc_err != APP_CONTROL_ERROR_NONE)
2566 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2570 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2572 int svc_err = APP_CONTROL_ERROR_NONE;
2575 memset(&tempId, 0x00, sizeof(tempId));
2576 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2578 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2580 if (svc_err != APP_CONTROL_ERROR_NONE)
2581 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2585 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2587 int svc_err = APP_CONTROL_ERROR_NONE;
2589 svc_err = app_control_set_app_id(svc_h, pkg_name);
2591 if (svc_err != APP_CONTROL_ERROR_NONE)
2592 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2596 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2598 int svc_err = APP_CONTROL_ERROR_NONE;
2600 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2602 if (svc_err != APP_CONTROL_ERROR_NONE)
2603 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2607 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2609 int noti_err = NOTIFICATION_ERROR_NONE;
2611 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2612 if (noti_err != NOTIFICATION_ERROR_NONE)
2613 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2617 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2619 int noti_err = NOTIFICATION_ERROR_NONE;
2621 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2623 if (noti_err != NOTIFICATION_ERROR_NONE)
2624 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2628 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2630 int noti_err = NOTIFICATION_ERROR_NONE;
2632 noti_err = notification_set_time_to_text(noti_h, type, time);
2634 if (noti_err != NOTIFICATION_ERROR_NONE)
2635 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2639 void setNotiTime(notification_h noti_h, time_t time)
2641 int noti_err = NOTIFICATION_ERROR_NONE;
2643 noti_err = notification_set_time(noti_h, time);
2645 if (noti_err != NOTIFICATION_ERROR_NONE)
2646 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2651 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2653 int noti_err = NOTIFICATION_ERROR_NONE;
2655 noti_err = notification_set_image(noti_h, type, image_path);
2657 if (noti_err != NOTIFICATION_ERROR_NONE)
2658 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2662 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2664 int noti_err = NOTIFICATION_ERROR_NONE;
2666 noti_err = notification_set_sound(noti_h, type, path);
2668 if (noti_err != NOTIFICATION_ERROR_NONE)
2669 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2673 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2675 int noti_err = NOTIFICATION_ERROR_NONE;
2677 noti_err = notification_set_vibration(noti_h, type, path);
2679 if (noti_err != NOTIFICATION_ERROR_NONE)
2680 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2684 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2686 int noti_err = NOTIFICATION_ERROR_NONE;
2688 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2690 if (noti_err != NOTIFICATION_ERROR_NONE)
2691 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2695 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2699 char *notiMsg = NULL;
2701 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2703 switch (noti_type) {
2704 case MSG_MGR_NOTI_TYPE_NORMAL:
2705 case MSG_MGR_NOTI_TYPE_SIM:
2706 case MSG_MGR_NOTI_TYPE_CB: {
2707 MSG_MGR_NOTI_INFO_S noti_info;
2708 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2710 noti_info.type = noti_type;
2711 int err = getLatestMsgInfo(¬i_info, true);
2714 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2715 if (noti_info.count == 1) {
2716 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2717 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2718 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2719 } else if (noti_info.count > 1) {
2720 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2722 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGE);
2723 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2724 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2725 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2730 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2734 case MSG_MGR_NOTI_TYPE_FAILED: {
2735 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2736 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2737 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2741 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2742 goto _END_OF_INSTANT_NOTI;
2746 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2747 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2749 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2750 MSG_MGR_DEBUG("Fail to notification_post");
2752 _END_OF_INSTANT_NOTI:
2754 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2755 MSG_MGR_DEBUG("Fail to notification_delete");
2762 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2763 MSG_MGR_DEBUG("Fail to notification_free");
2772 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
2774 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
2776 int err = BADGE_ERROR_NONE;
2779 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
2781 if (err != BADGE_ERROR_NONE) {
2782 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
2788 err = badge_add(MSG_DEFAULT_APP_ID);
2789 if (err != BADGE_ERROR_NONE) {
2790 MSG_MGR_ERR("Fail to badge_add : %d", err);
2795 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
2797 if (err != BADGE_ERROR_NONE) {
2798 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
2806 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
2810 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2812 #ifndef MSG_NOTI_INTEGRATION
2813 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2814 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2822 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
2828 struct tm repeat_tm;
2832 tmp_time += (RepeatTime*60);
2834 localtime_r(&tmp_time, &repeat_tm);
2836 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
2837 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
2841 g_alarmId = tmpAlarmId;
2842 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
2850 void MsgMgrSoundSetRepeatAlarm()
2852 int nRepeatValue = 0;
2853 long nRepeatTime = 0;
2855 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
2856 MSG_MGR_INFO("vconf_get_int() is failed");
2859 switch (nRepeatValue) {
2860 case MSG_ALERT_TONE_ONCE:
2863 case MSG_ALERT_TONE_2MINS:
2866 case MSG_ALERT_TONE_5MINS:
2869 case MSG_ALERT_TONE_10MINS:
2873 MSG_MGR_DEBUG("Invalid Repetition time");
2877 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
2879 if (nRepeatTime > 0) {
2880 if (g_alarmId > 0) {
2881 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
2882 MSG_MGR_FATAL("MsgAlarmRemove fail.");
2886 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
2893 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
2895 char *notiMsg = NULL;
2898 lang = vconf_get_str(VCONFKEY_LANGSET);
2900 setlocale(LC_MESSAGES, lang);
2902 bindtextdomain(pkg_name, locale_dir);
2904 notiMsg = dgettext(pkg_name, text);
2911 return g_strdup(notiMsg);