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 <notification_setting.h>
36 #include <notification_setting_internal.h>
37 #include <package_manager.h>
41 #include <msg_storage.h>
43 #include <msg-manager-util.h>
44 #include <msg-manager-contact.h>
45 #include <msg-manager-debug.h>
46 #include <msg-manager-notification.h>
47 #include <msg-manager-sound.h>
52 /*==================================================================================================
54 ==================================================================================================*/
56 static GList *msg_report_notification_list = NULL;
57 static bool is_init = false;
58 extern msg_handle_t msg_handle;
62 /*==================================================================================================
64 ==================================================================================================*/
65 typedef struct _report_notification_s
68 char addressVal[MAX_ADDRESS_VAL_LEN+1];
69 } report_notification_s;
72 typedef struct _msg_mgr_noti_info_s
74 msg_mgr_notification_type_t type;
80 char sender[MSG_NOTI_TEXT_LEN_S+1];
81 char text[MSG_NOTI_TEXT_LEN+1];
82 char number[MSG_NOTI_TEXT_LEN_S+1];
83 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
86 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
87 msg_message_id_t msg_id;
88 unsigned char extra_data;
90 int active_noti_button_num;
92 int active_media_size;
93 unsigned char active_subtype; /**< to distinguish cb, push message */
94 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
95 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
96 char active_text[MSG_NOTI_TEXT_LEN+1];
97 } MSG_MGR_NOTI_INFO_S;
100 typedef struct _del_noti_info_s
102 msg_mgr_notification_type_t type;
107 /*==================================================================================================
109 ===================================================================================================*/
111 void MsgMgrInitReportNotiList();
112 void MsgRefreshNotiCb(void *data);
113 void MsgMgrDeleteNotiCb(void *data);
115 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
117 notification_h getHandle(int *noti_id);
119 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
120 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
122 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
123 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
124 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
125 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
127 int getAppIcon(const char *app_id, char **icon_path);
128 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
130 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
131 void setTextDomain(notification_h noti_h);
132 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
133 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
134 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
135 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
136 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
137 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
138 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
140 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
142 bool isExistAddressInReportTable(const char *addr);
145 void createServiceHandle(app_control_h *svc_h);
146 void setServiceAppId(app_control_h svc_h, const char* app_id);
147 void setServiceUri(app_control_h svc_h, const char* uri);
148 void setServiceOperation(app_control_h svc_h, const char* operation);
149 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
150 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
151 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
152 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
154 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
155 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
156 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
157 void setNotiTime(notification_h noti_h, time_t time);
158 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
159 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
160 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
161 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
164 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
165 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
166 void MsgMgrSoundSetRepeatAlarm();
168 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
170 /*==================================================================================================
171 FUNCTION IMPLEMENTATION
172 ==================================================================================================*/
173 bool _is_valid_email(char *pAddress)
175 if (!pAddress || pAddress[0] == 0)
177 if (!strchr (pAddress, EMAIL_AT))
183 bool isExistAddressInReportTable(const char *addr)
185 char sqlQuery[MAX_QUERY_LEN+1];
186 int rowCnt = 0, colCnt = 0;
187 char **db_res = NULL;
190 char *normal_addr = msg_mgr_normalize_number((char *)addr);
192 memset(sqlQuery, 0x00, sizeof(sqlQuery));
193 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normal_addr);
195 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
196 if (msg_err != MSG_SUCCESS) {
197 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
201 msg_err = msg_db_free(msg_handle, db_res);
202 if (msg_err != MSG_SUCCESS) {
203 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
210 memset(sqlQuery, 0x00, sizeof(sqlQuery));
211 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normal_addr);
213 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
214 if (msg_err != MSG_SUCCESS) {
215 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
219 msg_err = msg_db_free(msg_handle, db_res);
220 if (msg_err != MSG_SUCCESS) {
221 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
232 void MsgMgrInitReportNotiList()
236 if (msg_report_notification_list) {
237 MSG_MGR_DEBUG("Report Noti List is already inited");
241 msg_report_notification_list = NULL;
243 notification_h noti = NULL;
244 notification_list_h noti_list = NULL;
245 notification_list_h head_noti_list = NULL;
246 int noti_err = NOTIFICATION_ERROR_NONE;
247 app_control_h app_control = NULL;
249 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
250 if (noti_err != NOTIFICATION_ERROR_NONE) {
251 MSG_MGR_DEBUG("notification_get_list() is failed!!");
255 head_noti_list = noti_list;
257 while (noti_list != NULL) {
258 noti = notification_list_get_data(noti_list);
260 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
261 memset(tempAddr, 0x00, sizeof(tempAddr));
263 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
264 if (noti_err != NOTIFICATION_ERROR_NONE) {
265 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
271 int ret = app_control_get_extra_data(app_control, "address", &addr);
272 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
273 if (isExistAddressInReportTable(addr)) {
274 report_notification_s *info = new report_notification_s;
275 memset(info, 0x00, sizeof(report_notification_s));
277 notification_get_id(noti, NULL, &(info->priv_id));
278 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
280 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
281 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
288 noti_list = notification_list_get_next(noti_list);
292 notification_free_list(head_noti_list);
298 void MsgMgrInitNoti()
303 bool bNotiSvcReady = false;
305 bNotiSvcReady = notification_is_service_ready();
307 if (bNotiSvcReady == true) {
308 MSG_MGR_DEBUG("Notification server is available");
309 #ifndef MSG_NOTI_INTEGRATION
310 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
312 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
313 MsgMgrInitReportNotiList();
315 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
316 #ifndef MSG_NOTI_INTEGRATION
317 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
319 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
320 delNotiInfo->sim_idx = -1;
322 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
324 notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
331 void MsgRefreshNotiCb(void *data)
333 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
334 MsgMgrInitReportNotiList();
345 void MsgMgrDeleteNotiCb(void *data)
348 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)data;
350 MsgMgrDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx);
360 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
364 notification_h noti_h = NULL;
366 MSG_MGR_NOTI_INFO_S noti_info = {0, };
368 noti_info.type = noti_type;
369 noti_info.active_noti_button_num = 1;
371 createActiveInfoData(¬i_info, msg_info);
373 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
375 setActiveNotification(noti_h, ¬i_info);
377 clearInfoData(noti_h, ¬i_info);
384 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
387 notification_h noti_h = NULL;
388 int bNotification = 1;
389 /* bool bReplyPopup = false; */
391 MSG_MGR_NOTI_INFO_S noti_info = {0, };
392 noti_info.type = noti_type;
393 noti_info.id = getPrivId(noti_info.type, -1);
395 err = getLatestMsgInfo(¬i_info, false);
398 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
399 goto __END_OF_REFRESH_NOTI;
402 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
403 err = MsgMgrInsertInstantMessage(noti_type);
406 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
407 goto __END_OF_REFRESH_NOTI;
411 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
412 MSG_MGR_DEBUG("vconf_get_bool is failed.");
415 if (bNotification == 0) {
416 MSG_MGR_DEBUG("Msg Alert notification is off.");
417 goto __END_OF_REFRESH_NOTI;
420 createInfoData(¬i_info, active_type);
422 noti_h = getHandle(¬i_info.id);
424 if (noti_h == NULL) {
425 MSG_MGR_DEBUG("Notification handle is NULL");
426 err = MSG_ERR_NULL_POINTER;
427 goto __END_OF_REFRESH_NOTI;
430 setNotification(noti_h, ¬i_info, bFeedback);
432 __END_OF_REFRESH_NOTI :
433 clearInfoData(noti_h, ¬i_info);
439 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
443 notification_h noti_h = NULL;
445 report_notification_s *info = new report_notification_s;
446 memset(info, 0x00, sizeof(report_notification_s));
448 MSG_MGR_NOTI_INFO_S noti_info = {0, };
449 noti_info.type = noti_type;
451 createInfoData(¬i_info, msg_info);
453 noti_h = getHandle(¬i_info.id);
455 if (noti_h == NULL) {
456 MSG_MGR_DEBUG("Notification handle is NULL");
458 goto __END_OF_ADD_REPORT_NOTI;
461 setNotification(noti_h, ¬i_info, true);
463 info->priv_id = noti_info.id;
464 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
465 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
466 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
468 __END_OF_ADD_REPORT_NOTI :
469 clearInfoData(noti_h, ¬i_info);
475 int MsgMgrDeleteReportNotification(const char *addr)
479 notification_h noti_h = NULL;
480 int bNotification = 1;
482 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
483 MSG_MGR_DEBUG("vconf_get_bool is failed.");
486 if (bNotification == 0) {
487 MSG_MGR_DEBUG("Msg Alert notification is off.");
491 char* normalAddr = NULL;
492 unsigned int list_length = g_list_length(msg_report_notification_list);
493 bool isDelete = false;
495 MSG_MGR_DEBUG("list length [%d]", list_length);
497 if (list_length > 0) {
498 GList *iter = g_list_first(msg_report_notification_list);
500 while (iter != NULL) {
502 report_notification_s *info = (report_notification_s*)(iter->data);
504 MSG_MGR_DEBUG("info is NULL!");
508 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
510 noti_h = notification_load(NULL, info->priv_id);
511 if (noti_h == NULL) {
512 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
515 normalAddr = msg_mgr_normalize_number(info->addressVal);
518 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
520 if (g_str_has_suffix(addr, normalAddr)) {
521 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
522 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
525 MSG_MGR_DEBUG("delete notification failed");
530 notification_free(noti_h);
534 iter = g_list_next(iter);
537 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
551 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
555 notification_h noti_h = NULL;
557 MSG_MGR_NOTI_INFO_S noti_info = {0, };
559 noti_info.type = noti_type;
561 createInfoData(¬i_info, msg_info);
563 /* check mwi or voicemail count is 0 then skip add notification */
564 if (noti_info.count == 0) {
565 MSG_MGR_DEBUG("Notification count is 0");
567 goto __END_OF_ADD_NOTI;
570 noti_h = getHandle(¬i_info.id);
572 if (noti_h == NULL) {
573 MSG_MGR_DEBUG("Notification handle is NULL");
575 goto __END_OF_ADD_NOTI;
578 setNotification(noti_h, ¬i_info, true);
581 clearInfoData(noti_h, ¬i_info);
587 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex)
589 int noti_err = NOTIFICATION_ERROR_NONE;
591 if (noti_type == MSG_MGR_NOTI_TYPE_ALL) {
592 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
593 } else if (noti_type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_type == MSG_MGR_NOTI_TYPE_VOICE_2 || noti_type == MSG_MGR_NOTI_TYPE_SIM) {
596 notiId = getPrivId(noti_type, simIndex);
597 MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
600 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, notiId);
603 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
606 if (noti_err != NOTIFICATION_ERROR_NONE) {
607 MSG_MGR_DEBUG("Fail to notification_delete_all noti_err [%d]", noti_err);
610 updatePrivId(noti_type, 0, simIndex);
614 int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
616 bool bNotiSvcReady = false;
618 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S));
621 delNotiInfo->type = noti_type;
622 delNotiInfo->sim_idx = simIndex;
625 bNotiSvcReady = notification_is_service_ready();
627 if (bNotiSvcReady == true) {
628 MSG_MGR_DEBUG("Notification server is available");
629 MsgMgrDeleteNotiCb((void *)delNotiInfo);
631 MSG_MGR_DEBUG("Notification server is not available. Delete is defered");
632 notification_add_deferred_task(MsgMgrDeleteNotiCb, (void *)delNotiInfo);
638 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
644 #ifndef MSG_NOTI_INTEGRATION
645 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
648 #ifdef MSG_NOTI_INTEGRATION
649 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
651 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
653 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
655 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
657 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
659 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
662 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
664 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
668 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
670 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
676 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
680 int noti_err = NOTIFICATION_ERROR_NONE;
683 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
684 if (noti_err != NOTIFICATION_ERROR_NONE) {
685 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
689 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
690 if (noti_err != NOTIFICATION_ERROR_NONE) {
691 MSG_MGR_DEBUG("Fail to notification_set_led.");
694 /* set execute option and property */
695 switch (noti_info->type) {
696 case MSG_MGR_NOTI_TYPE_NORMAL: {
697 if (noti_info->count > 1) {
698 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
700 if (noti_info->svc_h) { /* overwrite bundle key "type" */
701 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
702 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
704 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
707 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
710 case MSG_MGR_NOTI_TYPE_CB:
711 case MSG_MGR_NOTI_TYPE_SIM: {
712 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
713 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
716 case MSG_MGR_NOTI_TYPE_FAILED: {
717 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
718 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
721 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
722 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
725 case MSG_MGR_NOTI_TYPE_VOICE_1:
726 case MSG_MGR_NOTI_TYPE_VOICE_2:
727 case MSG_MGR_NOTI_TYPE_MWI:
728 case MSG_MGR_NOTI_TYPE_CLASS0:
729 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
730 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
731 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
732 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
736 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
741 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
742 if (noti_err != NOTIFICATION_ERROR_NONE) {
743 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
747 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
748 if (noti_err != NOTIFICATION_ERROR_NONE) {
749 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
756 void setTextDomain(notification_h noti_h)
760 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
765 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
769 char unreadMsgCntStr[10] = {0};
772 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
773 MSG_MGR_DEBUG("vconf_get_bool is failed.");
776 /* set title and content */
777 switch (noti_info->type) {
778 #ifdef MSG_NOTI_INTEGRATION
779 case MSG_MGR_NOTI_TYPE_NORMAL:
780 case MSG_MGR_NOTI_TYPE_CB:
781 case MSG_MGR_NOTI_TYPE_SIM: {
782 if (noti_info->count > 1) {
783 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
784 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
785 setNotiTime(noti_h, noti_info->time);
787 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
788 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
792 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
793 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
795 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
796 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
798 setNotiTime(noti_h, noti_info->time);
803 case MSG_MGR_NOTI_TYPE_NORMAL: {
804 if (noti_info->count > 1) {
805 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
806 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
807 setNotiTime(noti_h, noti_info->time);
809 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
810 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
813 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
814 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
816 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
817 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
819 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
820 setNotiTime(noti_h, noti_info->time);
824 case MSG_MGR_NOTI_TYPE_CB: {
825 if (noti_info->count > 1) {
826 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
827 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
828 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
829 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
830 setNotiTime(noti_h, noti_info->time);
833 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
834 setNotiTime(noti_h, noti_info->time);
837 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
838 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
840 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
841 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
846 case MSG_MGR_NOTI_TYPE_SIM: {
847 if (noti_info->count > 1) {
848 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
849 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
850 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
852 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
853 setNotiTime(noti_h, noti_info->time);
855 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
856 setNotiTime(noti_h, noti_info->time);
859 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
860 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
862 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
863 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
869 case MSG_MGR_NOTI_TYPE_FAILED: {
870 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
871 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
872 if (noti_info->count > 1) {
873 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
874 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
876 setNotiTime(noti_h, noti_info->time);
879 case MSG_MGR_NOTI_TYPE_VOICE_1:
880 case MSG_MGR_NOTI_TYPE_VOICE_2: {
881 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
882 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
883 setNotiTime(noti_h, noti_info->time);
885 if (noti_info->count == 1) {
886 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
887 } else if (noti_info->count > 1) {
888 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
889 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
891 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
895 case MSG_MGR_NOTI_TYPE_MWI: {
896 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
897 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
898 setNotiTime(noti_h, noti_info->time);
901 case MSG_MGR_NOTI_TYPE_CLASS0: {
902 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
903 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
904 setNotiTime(noti_h, noti_info->time);
907 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
908 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
909 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
911 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
912 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
913 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
914 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
916 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
919 setNotiTime(noti_h, noti_info->time);
922 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
923 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
924 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
926 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
927 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
928 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
930 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
931 /* notification free */
934 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
937 setNotiTime(noti_h, noti_info->time);
940 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
941 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
942 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
944 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED)
945 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
946 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED)
947 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE);
948 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED)
949 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
950 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED)
951 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE);
952 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE)
953 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE);
954 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED)
955 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL);
956 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE)
957 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE);
958 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR)
959 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL);
961 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
963 setNotiTime(noti_h, noti_info->time);
966 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
967 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
968 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
972 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
979 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
983 switch (noti_info->type) {
984 #ifdef MSG_NOTI_INTEGRATION
985 case MSG_MGR_NOTI_TYPE_NORMAL:
986 case MSG_MGR_NOTI_TYPE_CB:
987 case MSG_MGR_NOTI_TYPE_SIM: {
988 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
989 if (noti_info->count > 1 && noti_info->senderCount > 1) {
990 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
991 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
992 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
994 if (noti_info->active_subtype == MSG_CB_SMS) {
995 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
996 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
997 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
998 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
999 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1000 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
1001 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1003 if (noti_info->imagePath[0] != '\0') {
1004 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
1005 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1007 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1008 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1011 char *msg_icon_path = NULL;
1012 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1013 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1014 g_free(msg_icon_path);
1016 MSG_MGR_ERR("fail to get message-app icon");
1023 case MSG_MGR_NOTI_TYPE_NORMAL: {
1024 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1025 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
1027 if (noti_info->count > 1) {
1028 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1030 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
1034 case MSG_MGR_NOTI_TYPE_CB: {
1035 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1036 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1039 case MSG_MGR_NOTI_TYPE_SIM: {
1040 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1041 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1045 case MSG_MGR_NOTI_TYPE_FAILED: {
1046 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1047 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_FAILED_STATUS_ICON);
1050 case MSG_MGR_NOTI_TYPE_VOICE_1:
1051 case MSG_MGR_NOTI_TYPE_VOICE_2:
1052 case MSG_MGR_NOTI_TYPE_MWI: {
1053 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1054 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1057 case MSG_MGR_NOTI_TYPE_CLASS0:
1058 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1060 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1061 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1062 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1064 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1065 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1066 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1068 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1069 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1070 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1072 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1073 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1074 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1077 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1084 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1088 int noti_err = NOTIFICATION_ERROR_NONE;
1091 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1092 if (noti_err != NOTIFICATION_ERROR_NONE) {
1093 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1097 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1098 if (noti_err != NOTIFICATION_ERROR_NONE) {
1099 MSG_MGR_DEBUG("Fail to notification_set_led.");
1102 /* set execute option and property */
1103 switch (noti_info->type) {
1104 case MSG_MGR_NOTI_TYPE_NORMAL:
1105 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1106 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
1108 case MSG_MGR_NOTI_TYPE_CLASS0:
1109 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1112 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
1117 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1118 if (noti_err != NOTIFICATION_ERROR_NONE) {
1119 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1123 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
1124 if (noti_err != NOTIFICATION_ERROR_NONE) {
1125 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
1132 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1136 switch (noti_info->type) {
1137 case MSG_MGR_NOTI_TYPE_NORMAL:
1138 case MSG_MGR_NOTI_TYPE_SIM:
1139 case MSG_MGR_NOTI_TYPE_CB: {
1140 if (noti_info->active_subject[0] == '\0') {
1141 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1142 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1144 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1145 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1146 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1150 case MSG_MGR_NOTI_TYPE_CLASS0: {
1151 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1152 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1156 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1164 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1168 switch (noti_info->type) {
1169 case MSG_MGR_NOTI_TYPE_NORMAL:
1170 case MSG_MGR_NOTI_TYPE_SIM: {
1171 switch (noti_info->active_subtype) {
1173 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1175 case MSG_WAP_SI_SMS:
1176 case MSG_WAP_SL_SMS:
1177 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1180 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1183 if (noti_info->imagePath[0] != '\0')
1184 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1186 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1188 char *msg_icon_path = NULL;
1189 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1190 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1191 g_free(msg_icon_path);
1193 MSG_MGR_ERR("fail to get message-app icon");
1201 case MSG_MGR_NOTI_TYPE_CB: {
1202 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1205 case MSG_MGR_NOTI_TYPE_CLASS0:
1206 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1209 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1217 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1221 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1222 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1224 if (addressVal != NULL) {
1225 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1226 /* Get Contact Info */
1227 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1228 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1231 MSG_MGR_DEBUG("addressVal is NULL.");
1234 char *msg_tone_file_path = NULL;
1236 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1238 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1240 bool bPlaySound = false;
1241 bool bPlayVibration = false;
1242 bool bOnCall = false;
1244 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1247 if (msg_tone_file_path) {
1248 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1251 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1252 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1254 int ringtoneType = tmpVal;
1255 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1256 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1258 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1261 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1264 if (bPlayVibration) {
1265 if (contactInfo.vibrationPath[0] == '\0')
1266 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1268 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1270 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1273 if (msg_tone_file_path)
1274 delete [] msg_tone_file_path;
1280 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1284 int noti_err = NOTIFICATION_ERROR_NONE;
1286 if (noti_info->active_noti_button_num > 1) {
1287 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1288 if (noti_info->active_noti_svc_h[0]) {
1289 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1290 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1292 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1294 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1295 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1296 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1297 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1300 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1301 if (noti_info->active_noti_svc_h[1]) {
1302 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1304 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1305 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1306 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1308 char slot_id[5] = {0, };
1309 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1310 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1314 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1315 if (noti_info->active_noti_svc_h[2]) {
1316 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1318 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1319 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1320 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1321 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1323 char slot_id[5] = {0, };
1324 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1325 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1328 if (noti_info->active_noti_button_num > 1) {
1329 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1330 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1331 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1333 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1334 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1335 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1337 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1339 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1342 setActiveProperty(noti_h, noti_info);
1344 setTextDomain(noti_h);
1346 setActiveText(noti_h, noti_info);
1348 setActiveIcon(noti_h, noti_info);
1350 noti_err = notification_post(noti_h);
1351 if (noti_err != NOTIFICATION_ERROR_NONE) {
1352 MSG_MGR_DEBUG("Fail to notification_post");
1359 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1363 int noti_err = NOTIFICATION_ERROR_NONE;
1365 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1367 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1368 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1369 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1371 setActiveNotification(active_noti_h, noti_info);
1373 notification_free(active_noti_h);
1374 active_noti_h = NULL;
1377 setProperty(noti_h, noti_info);
1379 setTextDomain(noti_h);
1381 setText(noti_h, noti_info);
1383 setIcon(noti_h, noti_info);
1386 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1387 setSoundAndVibration(noti_h, noti_info->number, true);
1389 setSoundAndVibration(noti_h, noti_info->number, false);
1392 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1393 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1396 if (noti_info->id > 0) {
1397 MSG_MGR_DEBUG("Notification update");
1398 noti_err = notification_update(noti_h);
1399 if (noti_err != NOTIFICATION_ERROR_NONE) {
1400 MSG_MGR_DEBUG("Fail to notification_update");
1403 MSG_MGR_DEBUG("Notification insert");
1404 noti_err = notification_insert(noti_h, ¬i_info->id);
1405 if (noti_err != NOTIFICATION_ERROR_NONE) {
1406 MSG_MGR_DEBUG("Fail to notification_insert");
1409 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1416 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1421 MSG_MGR_DEBUG("msg_info is NULL");
1425 noti_info->msg_id = msg_info->msgId;
1426 noti_info->sim_idx = msg_info->sim_idx;
1428 switch (noti_info->type) {
1429 case MSG_MGR_NOTI_TYPE_NORMAL: {
1430 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1431 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1438 case MSG_MGR_NOTI_TYPE_CLASS0: {
1439 if (msg_info->displayName[0] == '\0')
1440 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1442 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1444 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1448 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1456 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1461 notification_free(noti_h);
1465 if (noti_info->svc_h) {
1466 app_control_destroy(noti_info->svc_h);
1467 noti_info->svc_h = NULL;
1470 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1471 if (noti_info->active_noti_svc_h[i]) {
1472 app_control_destroy(noti_info->active_noti_svc_h[i]);
1473 noti_info->active_noti_svc_h[i] = NULL;
1481 int getAppIcon(const char *app_id, char **icon_path)
1485 package_info_h pkg_info_h = NULL;
1486 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1489 if (app_id == NULL) {
1490 MSG_MGR_ERR("app id is NULL");
1492 goto END_OF_GET_APP_ICON;
1495 pkg_err = package_info_create(app_id, &pkg_info_h);
1496 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1497 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1499 goto END_OF_GET_APP_ICON;
1502 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1503 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1504 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1507 if (icon_path == NULL) {
1508 MSG_MGR_WARN("icon path is NULL");
1513 END_OF_GET_APP_ICON:
1515 pkg_err = package_info_destroy(pkg_info_h);
1516 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1517 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1529 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1534 msg_error_t msg_err = MSG_SUCCESS;
1535 char **db_res = NULL;
1536 int row_cnt = 0, col_cnt = 0;
1538 switch (noti_info->type) {
1539 case MSG_MGR_NOTI_TYPE_NORMAL:
1540 #ifdef MSG_NOTI_INTEGRATION
1541 case MSG_MGR_NOTI_TYPE_CB:
1542 case MSG_MGR_NOTI_TYPE_SIM:
1545 int smsUnreadCnt = 0;
1546 int mmsUnreadCnt = 0;
1548 char sqlQuery[MAX_QUERY_LEN +1];
1549 unsigned char mainType;
1550 unsigned char subType;
1553 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1554 #ifdef MSG_NOTI_INTEGRATION
1555 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1559 "WHERE A.CONV_ID=B.CONV_ID "
1560 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1561 "AND B.STORAGE_ID = %d "
1562 "GROUP BY A.ADDRESS_VAL "
1563 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1564 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1565 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1568 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1572 "WHERE A.CONV_ID=B.CONV_ID "
1573 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1574 "AND B.STORAGE_ID = %d "
1575 "GROUP BY A.ADDRESS_VAL "
1576 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1577 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1581 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1583 row_cnt = 0, col_cnt = 0;
1584 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1585 if (msg_err != MSG_SUCCESS) {
1586 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1590 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1591 int normalAddCnt = 0;
1592 int index = col_cnt;
1594 for (int i = 1; i <= row_cnt; i++) {
1595 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1597 char *address = db_res[index++];
1600 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1601 if (_is_valid_email(address)) {
1602 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1604 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1607 subType = atoi(db_res[index++]);
1609 MSG_MGR_CONTACT_INFO_S tmpContact;
1610 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1612 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1615 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1618 if (normalAddCnt > 1) {
1619 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1622 if (tmpContact.firstName[0] != '\0') {
1623 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1624 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1625 char *senderStr = NULL;
1626 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1627 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1634 noti_info->active_noti_button_num = 1;
1637 char *senderStr = NULL;
1638 if (subType == MSG_CB_SMS) {
1639 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1640 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1641 noti_info->active_noti_button_num = 1;
1642 } else if (subType == MSG_SYNCML_CP) {
1643 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1644 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1645 noti_info->active_noti_button_num = 1;
1646 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1647 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1648 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1649 noti_info->active_noti_button_num = 1;
1651 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1661 noti_info->active_subtype = subType;
1662 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1663 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1667 noti_info->senderCount = normalAddCnt;
1668 msg_db_free(msg_handle, db_res);
1670 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1672 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1674 #ifdef MSG_NOTI_INTEGRATION
1675 snprintf(sqlQuery, sizeof(sqlQuery),
1682 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1683 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1684 "(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) "
1686 "WHERE A.CONV_ID=B.CONV_ID "
1687 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1688 "AND B.STORAGE_ID = %d "
1689 "ORDER BY B.DISPLAY_TIME DESC;",
1692 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1693 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1694 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1697 snprintf(sqlQuery, sizeof(sqlQuery),
1704 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1705 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1707 "WHERE A.CONV_ID=B.CONV_ID "
1708 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1709 "AND B.STORAGE_ID = %d "
1710 "ORDER BY B.DISPLAY_TIME DESC;",
1713 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1717 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1719 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1720 if (msg_err != MSG_SUCCESS) {
1721 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1726 smsUnreadCnt = atoi(db_res[col_cnt+6]);
1727 mmsUnreadCnt = atoi(db_res[col_cnt+7]);
1728 msgSize = atoi(db_res[col_cnt+8]);
1730 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1732 if (noti_info->count > 0) {
1733 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1735 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1737 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1739 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1741 if (mainType == MSG_MMS_TYPE) {
1742 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1743 if (noti_info->text[0] == '\0') {
1744 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1745 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1749 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1750 if (prefix_subject) {
1751 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1752 g_free(prefix_subject);
1754 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1758 int kb_msg_size = msgSize / 1024;
1759 if (kb_msg_size == 0 && msgSize > 0)
1761 else if (msgSize % 1024 >= 512)
1764 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1765 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1767 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1769 g_free(msg_size_string);
1770 g_free(msg_size_unit_kb);
1774 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1777 if (noti_info->active_text[0] == '\0')
1778 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1780 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1782 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1783 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1784 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1786 if (!isForInstantMessage) {
1787 if (noti_info->id > 0 && noti_info->count == 1) {
1788 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1789 if (noti_err != NOTIFICATION_ERROR_NONE) {
1790 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1794 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1795 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1798 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1799 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1800 MsgMgrInsertBadge(noti_info->count);
1801 MsgMgrSoundSetRepeatAlarm();
1804 MSG_MGR_DEBUG("No unread message.");
1805 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1807 msg_db_free(msg_handle, db_res);
1809 if (!isForInstantMessage) {
1810 /* No unread message. */
1811 if (noti_info->id > 0) {
1812 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1813 if (noti_err != NOTIFICATION_ERROR_NONE) {
1814 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1820 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1821 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1823 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1824 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1825 MsgMgrInsertBadge(0);
1826 MsgMgrSoundSetRepeatAlarm();
1832 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1833 msg_db_free(msg_handle, db_res);
1837 msg_db_free(msg_handle, db_res);
1841 #ifndef MSG_NOTI_INTEGRATION
1842 case MSG_MGR_NOTI_TYPE_CB: {
1843 char sqlQuery[MAX_QUERY_LEN+1];
1844 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1846 snprintf(sqlQuery, sizeof(sqlQuery),
1852 "WHERE A.CONV_ID=B.CONV_ID "
1853 "AND B.READ_STATUS=0 "
1854 "AND B.FOLDER_ID=%d "
1855 "AND B.STORAGE_ID = %d "
1856 "ORDER BY B.DISPLAY_TIME DESC;",
1857 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1861 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1862 return MSG_ERR_DB_PREPARE;
1864 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1865 MSG_ADDRESS_INFO_S addrInfo;
1866 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1868 if (dbhandler->columnText(0) != NULL)
1869 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1871 MSG_CONTACT_INFO_S tmpContact;
1872 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1874 MsgGetContactInfo(&addrInfo, &tmpContact);
1876 if (tmpContact.firstName[0] != '\0') {
1877 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1878 } else if (addrInfo.addressVal[0] == '\0') {
1879 char *senderStr = NULL;
1880 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1881 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1887 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1890 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1892 noti_info->time = (time_t)dbhandler->columnInt(1);
1894 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1896 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1898 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1900 MSG_MGR_DEBUG("No unread CB message.");
1901 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1903 dbhandler->finalizeQuery();
1905 if (!isForInstantMessage) {
1906 /* No unread message. */
1907 if (noti_info->id > 0) {
1908 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1909 if (noti_err != NOTIFICATION_ERROR_NONE) {
1910 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1916 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1917 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1919 return MSG_ERR_DB_STEP;
1922 dbhandler->finalizeQuery();
1924 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
1925 MSG_MGR_DEBUG("getTable is failed");
1926 dbhandler->freeTable();
1927 return MSG_ERR_DB_GETTABLE;
1930 dbhandler->freeTable();
1931 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
1934 case MSG_MGR_NOTI_TYPE_SIM: {
1935 char sqlQuery[MAX_QUERY_LEN+1];
1936 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1938 snprintf(sqlQuery, sizeof(sqlQuery),
1943 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
1945 "WHERE A.CONV_ID=B.CONV_ID "
1946 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1947 "AND B.STORAGE_ID = %d "
1948 "ORDER BY B.DISPLAY_TIME DESC;",
1950 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1954 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1956 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1957 return MSG_ERR_DB_PREPARE;
1959 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1960 noti_info->count = dbhandler->columnInt(4);
1962 if (noti_info->count > 0) {
1963 MSG_ADDRESS_INFO_S addrInfo;
1964 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1966 if (dbhandler->columnText(0) != NULL)
1967 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1969 MSG_CONTACT_INFO_S tmpContact;
1970 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1972 MsgGetContactInfo(&addrInfo, &tmpContact);
1974 if (tmpContact.firstName[0] != '\0') {
1975 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1976 } else if (addrInfo.addressVal[0] == '\0') {
1977 char *senderStr = NULL;
1978 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1979 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1985 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1988 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1990 noti_info->time = (time_t)dbhandler->columnInt(1);
1992 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1994 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1996 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
1998 MSG_MGR_DEBUG("No unread SIM message.");
1999 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2001 dbhandler->finalizeQuery();
2003 if (!isForInstantMessage) {
2004 /* No unread message. */
2005 if (noti_info->id > 0) {
2006 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2007 if (noti_err != NOTIFICATION_ERROR_NONE) {
2008 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2014 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2015 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2018 return MSG_ERR_DB_STEP;
2021 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2022 dbhandler->finalizeQuery();
2023 return MSG_ERR_DB_STEP;
2026 dbhandler->finalizeQuery();
2030 case MSG_MGR_NOTI_TYPE_FAILED: {
2031 char sqlQuery[MAX_QUERY_LEN+1];
2032 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2034 snprintf(sqlQuery, sizeof(sqlQuery),
2041 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2043 "WHERE A.CONV_ID=B.CONV_ID "
2044 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2045 "AND B.STORAGE_ID = %d "
2046 "ORDER BY B.DISPLAY_TIME DESC;",
2047 MSG_NETWORK_SEND_FAIL,
2048 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2052 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2054 row_cnt = 0, col_cnt = 0;
2055 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2056 if (msg_err != MSG_SUCCESS) {
2057 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2062 noti_info->count = atoi(db_res[col_cnt+6]);
2064 if (noti_info->count > 0) {
2065 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2067 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2069 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2071 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2073 if (tmpContact.firstName[0] != '\0') {
2074 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2075 } else if (addrInfo.addressVal[0] == '\0') {
2076 char *senderStr = NULL;
2077 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2078 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2084 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2087 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2089 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2091 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2093 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2095 if (mainType == MSG_TYPE_MMS)
2096 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2098 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2100 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2102 if (!isForInstantMessage) {
2103 if (noti_info->id > 0 && noti_info->count == 1) {
2104 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2105 if (noti_err != NOTIFICATION_ERROR_NONE) {
2106 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2109 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2110 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2114 MSG_MGR_DEBUG("No sent failed message.");
2115 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2117 msg_db_free(msg_handle, db_res);
2119 if (!isForInstantMessage) {
2120 /* No unread message. */
2121 if (noti_info->id > 0) {
2122 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2123 if (noti_err != NOTIFICATION_ERROR_NONE) {
2124 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2130 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2131 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2137 msg_db_free(msg_handle, db_res);
2141 msg_db_free(msg_handle, db_res);
2144 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2147 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2157 notification_h getHandle(int *noti_id)
2159 notification_h noti_h = NULL;
2162 MSG_MGR_DEBUG("Notification load");
2163 noti_h = notification_load(NULL, *noti_id);
2165 MSG_MGR_DEBUG("notification_load is failed.");
2168 if (noti_h == NULL) {
2169 MSG_MGR_DEBUG("Notification create");
2170 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2171 if (noti_h == NULL) {
2172 MSG_MGR_DEBUG("notification_create is failed.");
2183 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2189 switch (noti_type) {
2190 #ifdef MSG_NOTI_INTEGRATION
2191 case MSG_MGR_NOTI_TYPE_NORMAL:
2192 case MSG_MGR_NOTI_TYPE_SIM:
2193 case MSG_MGR_NOTI_TYPE_CB:
2194 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2197 case MSG_MGR_NOTI_TYPE_NORMAL:
2198 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2200 case MSG_MGR_NOTI_TYPE_SIM:
2201 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2203 case MSG_MGR_NOTI_TYPE_CB:
2204 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2207 case MSG_MGR_NOTI_TYPE_FAILED:
2208 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2210 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2211 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2212 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2213 vconf_get_int(keyName, ¬i_id);
2216 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2217 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2218 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2219 vconf_get_int(keyName, ¬i_id);
2222 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2223 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2226 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2230 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2238 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2244 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2246 switch (noti_type) {
2247 #ifdef MSG_NOTI_INTEGRATION
2248 case MSG_MGR_NOTI_TYPE_NORMAL:
2249 case MSG_MGR_NOTI_TYPE_SIM:
2250 case MSG_MGR_NOTI_TYPE_CB:
2251 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2254 case MSG_MGR_NOTI_TYPE_NORMAL:
2255 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2257 case MSG_MGR_NOTI_TYPE_SIM:
2258 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2260 case MSG_MGR_NOTI_TYPE_CB:
2261 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2264 case MSG_MGR_NOTI_TYPE_FAILED:
2265 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2267 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2268 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2269 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2270 err = vconf_set_int(keyName, noti_id);
2273 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2274 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2275 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2276 err = vconf_set_int(keyName, noti_id);
2279 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2280 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2283 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2288 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2294 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2299 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2300 noti_info->msg_id = msg_info->msgId;
2302 MSG_MGR_DEBUG("msg_info is NULL");
2306 noti_info->sim_idx = msg_info->sim_idx;
2308 createServiceHandle(¬i_info->svc_h);
2309 char keyName[MAX_VCONFKEY_NAME_LEN];
2311 switch (noti_info->type) {
2312 case MSG_MGR_NOTI_TYPE_VOICE_1:
2313 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2314 memset(keyName, 0x00, sizeof(keyName));
2315 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2316 vconf_get_int(keyName, ¬i_info->count);
2317 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2318 noti_info->time = msg_info->displayTime;
2320 memset(keyName, 0x00, sizeof(keyName));
2321 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2322 char *voiceNumber = vconf_get_str(keyName);
2323 memset(keyName, 0x00, sizeof(keyName));
2324 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2325 char *voiceAlphaId = vconf_get_str(keyName);
2326 char *dialNumber = NULL;
2328 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2330 if (voiceNumber && strlen(voiceNumber))
2331 dialNumber = voiceNumber;
2333 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2334 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2335 } else if (dialNumber && strlen(dialNumber) > 0) {
2336 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2339 if (dialNumber && strlen(dialNumber) > 0)
2340 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2342 if (noti_info->svc_h) {
2343 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2344 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2346 char slot_id[5] = {0, };
2347 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2348 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2351 if (voiceNumber) g_free(voiceNumber);
2352 if (voiceAlphaId) g_free(voiceAlphaId);
2355 case MSG_MGR_NOTI_TYPE_MWI:
2356 case MSG_MGR_NOTI_TYPE_CLASS0: {
2357 noti_info->count = 1;
2358 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2359 noti_info->time = msg_info->displayTime;
2361 if (msg_info->displayName[0] == '\0')
2362 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2364 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2366 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2368 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2370 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2371 if (noti_info->svc_h) {
2372 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2373 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2375 char slot_id[5] = {0, };
2376 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2377 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2381 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2382 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2383 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2387 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2388 noti_info->count = 1;
2389 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2390 noti_info->time = msg_info->displayTime;
2391 noti_info->extra_data = msg_info->networkStatus;
2393 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2394 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2395 if (msg_info->addressVal[0] != '\0') {
2396 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2397 if (_is_valid_email(msg_info->addressVal)) {
2398 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2400 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2404 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2405 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2408 if (contactInfo.firstName[0] == '\0')
2409 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2411 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2413 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2415 if (noti_info->msg_id > 0) {
2416 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2417 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2418 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2419 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2423 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2424 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2425 noti_info->count = 1;
2426 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2427 noti_info->time = msg_info->displayTime;
2429 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2430 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2431 if (msg_info->addressVal[0] != '\0') {
2432 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2433 if (_is_valid_email(msg_info->addressVal)) {
2434 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2436 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2440 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2441 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2443 if (contactInfo.firstName[0] == '\0')
2444 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2446 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2448 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2450 char sqlQuery[MAX_QUERY_LEN+1];
2451 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2453 int report_status_type;
2454 int report_status_value;
2456 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2457 report_status_type = MSG_REPORT_TYPE_READ;
2459 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2462 snprintf(sqlQuery, sizeof(sqlQuery),
2465 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';",
2466 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2468 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2470 char **db_res = NULL;
2471 int row_cnt = 0, col_cnt = 0;
2473 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2474 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2475 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2479 report_status_value = atoi(db_res[col_cnt]);
2481 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2483 msg_err = msg_db_free(msg_handle, db_res);
2484 if (msg_err != MSG_SUCCESS) {
2485 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2489 if (noti_info->msg_id > 0) {
2490 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2491 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2492 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2493 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2496 noti_info->extra_data = (unsigned char)report_status_value;
2500 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2504 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2509 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2513 createServiceHandle(¬i_info->svc_h);
2515 switch (noti_info->type) {
2516 case MSG_MGR_NOTI_TYPE_NORMAL: {
2517 if (noti_info->count > 1) {
2518 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2520 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2523 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2524 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2525 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2526 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2528 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
2530 if (noti_info->active_noti_button_num == 0)
2531 noti_info->active_noti_button_num = 3;
2534 case MSG_MGR_NOTI_TYPE_CB: {
2535 if (noti_info->count > 1) {
2536 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2538 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2541 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2542 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2543 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2545 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2546 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2548 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2550 noti_info->active_noti_button_num = 1;
2553 case MSG_MGR_NOTI_TYPE_SIM: {
2554 if (noti_info->count > 1) {
2555 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2557 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2560 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2561 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2562 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2564 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2565 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2567 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2569 if (noti_info->active_noti_button_num == 0)
2570 noti_info->active_noti_button_num = 3;
2573 case MSG_MGR_NOTI_TYPE_FAILED: {
2574 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2576 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2577 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2578 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2580 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2583 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2584 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2586 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2587 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2589 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2596 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2597 noti_info->active_noti_button_num = 0;
2603 void createServiceHandle(app_control_h *svc_h)
2605 int svc_err = APP_CONTROL_ERROR_NONE;
2607 svc_err = app_control_create(svc_h);
2609 if (svc_err != APP_CONTROL_ERROR_NONE)
2610 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2614 void setServiceAppId(app_control_h svc_h, const char* app_id)
2616 int svc_err = APP_CONTROL_ERROR_NONE;
2618 svc_err = app_control_set_app_id(svc_h, app_id);
2620 if (svc_err != APP_CONTROL_ERROR_NONE)
2621 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2625 void setServiceUri(app_control_h svc_h, const char* uri)
2627 int svc_err = APP_CONTROL_ERROR_NONE;
2629 svc_err = app_control_set_uri(svc_h, uri);
2631 if (svc_err != APP_CONTROL_ERROR_NONE)
2632 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2636 void setServiceOperation(app_control_h svc_h, const char* operation)
2638 int svc_err = APP_CONTROL_ERROR_NONE;
2640 svc_err = app_control_set_operation(svc_h, operation);
2642 if (svc_err != APP_CONTROL_ERROR_NONE)
2643 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2647 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2649 int svc_err = APP_CONTROL_ERROR_NONE;
2651 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2653 if (svc_err != APP_CONTROL_ERROR_NONE)
2654 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2658 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2660 int svc_err = APP_CONTROL_ERROR_NONE;
2663 memset(&tempId, 0x00, sizeof(tempId));
2664 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2666 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2668 if (svc_err != APP_CONTROL_ERROR_NONE)
2669 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2673 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2675 int svc_err = APP_CONTROL_ERROR_NONE;
2677 svc_err = app_control_set_app_id(svc_h, pkg_name);
2679 if (svc_err != APP_CONTROL_ERROR_NONE)
2680 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2684 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2686 int svc_err = APP_CONTROL_ERROR_NONE;
2688 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2690 if (svc_err != APP_CONTROL_ERROR_NONE)
2691 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2695 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2697 int noti_err = NOTIFICATION_ERROR_NONE;
2699 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2700 if (noti_err != NOTIFICATION_ERROR_NONE)
2701 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2705 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2707 int noti_err = NOTIFICATION_ERROR_NONE;
2709 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2711 if (noti_err != NOTIFICATION_ERROR_NONE)
2712 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2716 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2718 int noti_err = NOTIFICATION_ERROR_NONE;
2720 noti_err = notification_set_time_to_text(noti_h, type, time);
2722 if (noti_err != NOTIFICATION_ERROR_NONE)
2723 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2727 void setNotiTime(notification_h noti_h, time_t time)
2729 int noti_err = NOTIFICATION_ERROR_NONE;
2731 noti_err = notification_set_time(noti_h, time);
2733 if (noti_err != NOTIFICATION_ERROR_NONE)
2734 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2739 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2741 int noti_err = NOTIFICATION_ERROR_NONE;
2743 noti_err = notification_set_image(noti_h, type, image_path);
2745 if (noti_err != NOTIFICATION_ERROR_NONE)
2746 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2750 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2752 int noti_err = NOTIFICATION_ERROR_NONE;
2754 noti_err = notification_set_sound(noti_h, type, path);
2756 if (noti_err != NOTIFICATION_ERROR_NONE)
2757 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2761 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2763 int noti_err = NOTIFICATION_ERROR_NONE;
2765 noti_err = notification_set_vibration(noti_h, type, path);
2767 if (noti_err != NOTIFICATION_ERROR_NONE)
2768 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2772 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2774 int noti_err = NOTIFICATION_ERROR_NONE;
2776 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2778 if (noti_err != NOTIFICATION_ERROR_NONE)
2779 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2783 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2787 char *notiMsg = NULL;
2789 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2791 switch (noti_type) {
2792 case MSG_MGR_NOTI_TYPE_NORMAL:
2793 case MSG_MGR_NOTI_TYPE_SIM:
2794 case MSG_MGR_NOTI_TYPE_CB: {
2795 MSG_MGR_NOTI_INFO_S noti_info;
2796 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2798 noti_info.type = noti_type;
2799 int err = getLatestMsgInfo(¬i_info, true);
2802 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2803 if (noti_info.count == 1) {
2804 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2805 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2806 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2807 } else if (noti_info.count > 1) {
2808 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2810 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
2811 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2812 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2813 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2818 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2822 case MSG_MGR_NOTI_TYPE_FAILED: {
2823 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2824 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2825 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2829 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2830 goto _END_OF_INSTANT_NOTI;
2834 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2835 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2837 if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
2838 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
2840 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2841 MSG_MGR_DEBUG("Fail to notification_post");
2843 _END_OF_INSTANT_NOTI:
2845 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2846 MSG_MGR_DEBUG("Fail to notification_delete");
2853 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2854 MSG_MGR_DEBUG("Fail to notification_free");
2863 bool MsgMgrCheckNotificationSettingEnable()
2865 bool msg_noti_enabled = false;
2866 notification_system_setting_h system_setting = NULL;
2867 notification_setting_h setting = NULL;
2869 int err = NOTIFICATION_ERROR_NONE;
2871 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
2873 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
2874 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2876 msg_noti_enabled = true;
2878 bool allow_to_notify = false;
2879 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
2881 if (err != NOTIFICATION_ERROR_NONE) {
2882 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2886 if (allow_to_notify) {
2887 MSG_MGR_DEBUG("message notification is allowed");
2889 /* check do not disturb mode */
2890 err = notification_system_setting_load_system_setting(&system_setting);
2892 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
2893 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
2897 bool do_not_disturb_mode = false;
2898 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
2900 if (err != NOTIFICATION_ERROR_NONE) {
2901 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2905 if (do_not_disturb_mode) {
2906 bool is_msg_excepted = false;
2907 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
2908 if (err != NOTIFICATION_ERROR_NONE) {
2909 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2910 msg_noti_enabled = false;
2912 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
2913 msg_noti_enabled = (is_msg_excepted) ? true : false;
2916 MSG_MGR_DEBUG("do not disturb mode is off");
2919 MSG_MGR_INFO("message notification is not allowed");
2920 msg_noti_enabled = false;
2926 notification_system_setting_free_system_setting(system_setting);
2929 notification_setting_free_notification(setting);
2931 return msg_noti_enabled;
2935 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
2937 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
2938 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
2940 MsgMgrChangePmState();
2942 char *notiMsg = NULL;
2943 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
2946 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
2947 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
2949 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
2950 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
2951 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
2952 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
2953 notification_status_message_post(pTickerMsg);
2955 notification_status_message_post(notiMsg);
2958 /* Show ticker popup for sending failed msg. */
2959 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
2967 if (bPlayFeedback) {
2969 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
2970 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
2972 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
2974 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
2975 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
2977 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
2980 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
2988 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
2990 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
2992 int err = BADGE_ERROR_NONE;
2995 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
2997 if (err != BADGE_ERROR_NONE) {
2998 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
3004 err = badge_add(MSG_DEFAULT_APP_ID);
3005 if (err != BADGE_ERROR_NONE) {
3006 MSG_MGR_ERR("Fail to badge_add : %d", err);
3011 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
3013 if (err != BADGE_ERROR_NONE) {
3014 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3022 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3026 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3028 #ifndef MSG_NOTI_INTEGRATION
3029 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3030 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3038 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3044 struct tm repeat_tm;
3048 tmp_time += (RepeatTime*60);
3050 localtime_r(&tmp_time, &repeat_tm);
3052 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3053 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3057 g_alarmId = tmpAlarmId;
3058 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3066 void MsgMgrSoundSetRepeatAlarm()
3068 int nRepeatValue = 0;
3069 long nRepeatTime = 0;
3071 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3072 MSG_MGR_INFO("vconf_get_int() is failed");
3075 switch (nRepeatValue) {
3076 case MSG_ALERT_TONE_ONCE:
3079 case MSG_ALERT_TONE_2MINS:
3082 case MSG_ALERT_TONE_5MINS:
3085 case MSG_ALERT_TONE_10MINS:
3089 MSG_MGR_DEBUG("Invalid Repetition time");
3093 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3095 if (nRepeatTime > 0) {
3096 if (g_alarmId > 0) {
3097 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3098 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3102 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3109 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3111 char *notiMsg = NULL;
3114 lang = vconf_get_str(VCONFKEY_LANGSET);
3116 setlocale(LC_MESSAGES, lang);
3118 bindtextdomain(pkg_name, locale_dir);
3120 notiMsg = dgettext(pkg_name, text);
3127 return g_strdup(notiMsg);