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
67 msg_mgr_notification_type_t noti_type;
69 char addressVal[MAX_ADDRESS_VAL_LEN+1];
70 } report_notification_s;
73 typedef struct _msg_mgr_noti_info_s
75 msg_mgr_notification_type_t type;
81 char sender[MSG_NOTI_TEXT_LEN_S+1];
82 char text[MSG_NOTI_TEXT_LEN+1];
83 char number[MSG_NOTI_TEXT_LEN_S+1];
84 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
87 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
88 msg_message_id_t msg_id;
90 unsigned char extra_data;
92 int active_noti_button_num;
94 int active_media_size;
95 unsigned char active_subtype; /**< to distinguish cb, push message */
96 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
97 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
98 char active_text[MSG_NOTI_TEXT_LEN+1];
99 } MSG_MGR_NOTI_INFO_S;
102 typedef struct _del_noti_info_s
104 msg_mgr_notification_type_t type;
109 /*==================================================================================================
111 ===================================================================================================*/
113 void MsgMgrInitReportNotiList();
114 void MsgInitNotiCb(void *data);
115 void MsgRefreshNotiCb(void *data);
116 void MsgMgrDeleteNotiCb(void *data);
118 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
119 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result);
121 notification_h getHandle(int *noti_id);
123 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
124 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
126 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
127 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
128 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
129 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
131 int getAppIcon(const char *app_id, char **icon_path);
132 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
134 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
135 void setTextDomain(notification_h noti_h);
136 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
137 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
138 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
139 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
140 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
141 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
142 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
144 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
147 void createServiceHandle(app_control_h *svc_h);
148 void setServiceAppId(app_control_h svc_h, const char* app_id);
149 void setServiceUri(app_control_h svc_h, const char* uri);
150 void setServiceOperation(app_control_h svc_h, const char* operation);
151 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
152 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
153 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
154 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
156 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
157 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
158 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
159 void setNotiTime(notification_h noti_h, time_t time);
160 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
161 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
162 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
163 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
166 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
167 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
168 void MsgMgrSoundSetRepeatAlarm();
170 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
172 /*==================================================================================================
173 FUNCTION IMPLEMENTATION
174 ==================================================================================================*/
175 bool _is_valid_email(char *pAddress)
177 if (!pAddress || pAddress[0] == 0)
179 if (!strchr (pAddress, EMAIL_AT))
185 void MsgMgrInitReportNotiList()
189 if (msg_report_notification_list) {
190 MSG_MGR_DEBUG("Report Noti List is already inited");
194 msg_report_notification_list = NULL;
196 notification_h noti = NULL;
197 notification_list_h noti_list = NULL;
198 notification_list_h head_noti_list = NULL;
199 int noti_err = NOTIFICATION_ERROR_NONE;
200 app_control_h app_control = NULL;
202 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
203 if (noti_err != NOTIFICATION_ERROR_NONE) {
204 MSG_MGR_DEBUG("notification_get_list() is failed!!");
208 head_noti_list = noti_list;
210 while (noti_list != NULL) {
211 noti = notification_list_get_data(noti_list);
213 MSG_MGR_DEBUG("notification_list_get_data() failed!!");
217 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
218 memset(tempAddr, 0x00, sizeof(tempAddr));
220 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
221 if (noti_err != NOTIFICATION_ERROR_NONE) {
222 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
226 char *is_report_noti = NULL;
228 int ret = app_control_get_extra_data(app_control, "is_report_noti", &is_report_noti);
229 if (ret == APP_CONTROL_ERROR_NONE && is_report_noti != NULL && g_strcmp0(is_report_noti, "true") == 0) {
232 ret = app_control_get_extra_data(app_control, "address", &addr);
233 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
234 report_notification_s *info = new report_notification_s;
235 memset(info, 0x00, sizeof(report_notification_s));
237 char *noti_type = NULL;
238 ret = app_control_get_extra_data(app_control, "noti_type", ¬i_type);
239 if (ret == APP_CONTROL_ERROR_NONE && noti_type != NULL) {
240 info->noti_type = (msg_mgr_notification_type_t)atoi(noti_type);
244 notification_get_id(noti, NULL, &(info->priv_id));
245 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
247 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
248 MSG_MGR_SEC_DEBUG("appended list data = [noti_type = %d priv_id = %d address = %s]", info->noti_type, info->priv_id, info->addressVal);
255 if (is_report_noti) {
256 g_free(is_report_noti);
257 is_report_noti = NULL;
261 noti_list = notification_list_get_next(noti_list);
265 notification_free_list(head_noti_list);
271 void MsgMgrInitNoti()
276 bool bNotiSvcReady = false;
278 bNotiSvcReady = notification_is_service_ready();
280 if (bNotiSvcReady == true) {
281 MSG_MGR_DEBUG("Notification server is available");
282 MsgMgrInitReportNotiList();
284 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
285 notification_add_deferred_task(MsgInitNotiCb, NULL);
292 void MsgInitNotiCb(void *data)
294 MsgMgrInitReportNotiList();
307 bool bNotiSvcReady = false;
309 bNotiSvcReady = notification_is_service_ready();
311 if (bNotiSvcReady == true) {
312 MSG_MGR_DEBUG("Notification server is available");
313 #ifndef MSG_NOTI_INTEGRATION
314 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
316 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
318 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
319 #ifndef MSG_NOTI_INTEGRATION
320 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
322 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
323 delNotiInfo->sim_idx = -1;
325 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
327 notification_add_deferred_task(MsgRefreshNotiCb, NULL);
332 void MsgRefreshNotiCb(void *data)
334 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
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 = MSG_ACTIVE_NOTI_BUTTON_NUM_CLASS0_MESSAGE;
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;
444 bool isNewNoti = false;
446 report_notification_s *info = new report_notification_s;
447 memset(info, 0x00, sizeof(report_notification_s));
449 MSG_MGR_NOTI_INFO_S noti_info = {0, };
450 noti_info.type = noti_type;
452 createInfoData(¬i_info, msg_info);
454 if (noti_info.id == 0)
457 noti_h = getHandle(¬i_info.id);
459 if (noti_h == NULL) {
460 MSG_MGR_DEBUG("Notification handle is NULL");
462 goto __END_OF_ADD_REPORT_NOTI;
465 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT || noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
466 noti_info.applist &= ~NOTIFICATION_DISPLAY_APP_TICKER;
468 ret = MsgMgrInsertDeliveryReportInstantNotification(noti_type, noti_info.extra_data);
471 MSG_MGR_ERR(" MsgInsertInstantDeliveryReportNotification() err = [%d]", ret);
472 goto __END_OF_ADD_REPORT_NOTI;
476 addServiceExtraData(noti_info.svc_h, "is_report_noti", "true");
477 setNotification(noti_h, ¬i_info, true);
479 if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT)
480 noti_type = MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT;
483 report_notification_s *info = new report_notification_s;
484 memset(info, 0x00, sizeof(report_notification_s));
486 info->noti_type = noti_type;
487 info->priv_id = noti_info.id;
488 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
489 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
490 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
492 GList *iter = g_list_first(msg_report_notification_list);
494 while (iter != NULL) {
495 report_notification_s *info = (report_notification_s*)(iter->data);
497 MSG_MGR_DEBUG("info is NULL!");
501 // update new addressVal of noti_type
502 if (info->priv_id == noti_info.id) {
503 memset(info->addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
504 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
505 MSG_MGR_SEC_DEBUG("updated list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
509 iter = g_list_next(iter);
513 info->priv_id = noti_info.id;
514 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
515 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
516 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
518 __END_OF_ADD_REPORT_NOTI :
519 clearInfoData(noti_h, ¬i_info);
525 int MsgMgrDeleteReportNotification(const char *addr)
529 notification_h noti_h = NULL;
530 int bNotification = 1;
532 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
533 MSG_MGR_DEBUG("vconf_get_bool is failed.");
536 if (bNotification == 0) {
537 MSG_MGR_DEBUG("Msg Alert notification is off.");
541 char* normalAddr = NULL;
542 unsigned int list_length = g_list_length(msg_report_notification_list);
543 bool isDelete = false;
545 MSG_MGR_DEBUG("list length [%d]", list_length);
547 if (list_length > 0) {
548 GList *iter = g_list_first(msg_report_notification_list);
550 while (iter != NULL) {
552 report_notification_s *info = (report_notification_s*)(iter->data);
554 MSG_MGR_DEBUG("info is NULL!");
558 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
560 noti_h = notification_load(NULL, info->priv_id);
561 if (noti_h == NULL) {
562 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
565 normalAddr = msg_mgr_normalize_number(info->addressVal);
568 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
570 if (g_str_has_suffix(addr, normalAddr)) {
571 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
572 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
575 MSG_MGR_DEBUG("delete notification failed");
580 notification_free(noti_h);
584 iter = g_list_next(iter);
587 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
601 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
605 notification_h noti_h = NULL;
607 MSG_MGR_NOTI_INFO_S noti_info = {0, };
609 noti_info.type = noti_type;
611 createInfoData(¬i_info, msg_info);
613 /* check mwi or voicemail count is 0 then skip add notification */
614 if (noti_info.count == 0) {
615 MSG_MGR_DEBUG("Notification count is 0");
617 goto __END_OF_ADD_NOTI;
620 noti_h = getHandle(¬i_info.id);
622 if (noti_h == NULL) {
623 MSG_MGR_DEBUG("Notification handle is NULL");
625 goto __END_OF_ADD_NOTI;
628 setNotification(noti_h, ¬i_info, true);
631 clearInfoData(noti_h, ¬i_info);
637 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex)
639 int noti_err = NOTIFICATION_ERROR_NONE;
641 if (noti_type == MSG_MGR_NOTI_TYPE_ALL) {
642 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
643 } 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) {
646 notiId = getPrivId(noti_type, simIndex);
647 MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
650 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, notiId);
653 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
656 if (noti_err != NOTIFICATION_ERROR_NONE) {
657 MSG_MGR_DEBUG("Fail to notification_delete_all noti_err [%d]", noti_err);
660 updatePrivId(noti_type, 0, simIndex);
664 int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
666 bool bNotiSvcReady = false;
668 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S));
671 delNotiInfo->type = noti_type;
672 delNotiInfo->sim_idx = simIndex;
675 bNotiSvcReady = notification_is_service_ready();
677 if (bNotiSvcReady == true) {
678 MSG_MGR_DEBUG("Notification server is available");
679 MsgMgrDeleteNotiCb((void *)delNotiInfo);
681 MSG_MGR_DEBUG("Notification server is not available. Delete is defered");
682 notification_add_deferred_task(MsgMgrDeleteNotiCb, (void *)delNotiInfo);
688 int MsgMgrDeleteSentReadReportNotification()
690 int readReportSentNotiId = 0;
693 if (vconf_get_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, &readReportSentNotiId) != 0) {
694 MSG_MGR_INFO("vconf_get_int() is failed");
698 if (readReportSentNotiId > 0) {
699 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, readReportSentNotiId);
701 MSG_MGR_DEBUG("notification_delete_by_priv_id() fail [%d]", noti_err);
705 MSG_MGR_DEBUG("VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID is 0");
709 if (vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, 0) != 0) {
710 MSG_MGR_DEBUG("vconf_set_int fail : VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID");
714 if (vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID, 0) != 0) {
715 MSG_MGR_DEBUG("vconf_set_int fail : VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID");
723 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
729 #ifndef MSG_NOTI_INTEGRATION
730 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
733 #ifdef MSG_NOTI_INTEGRATION
734 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
736 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
738 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
740 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
742 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
744 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
747 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
749 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
753 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
755 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
761 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
765 int noti_err = NOTIFICATION_ERROR_NONE;
768 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
769 if (noti_err != NOTIFICATION_ERROR_NONE) {
770 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
774 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
775 if (noti_err != NOTIFICATION_ERROR_NONE) {
776 MSG_MGR_DEBUG("Fail to notification_set_led.");
779 /* set execute option and property */
780 switch (noti_info->type) {
781 case MSG_MGR_NOTI_TYPE_NORMAL: {
782 if (noti_info->count > 1) {
783 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
785 if (noti_info->svc_h) { /* overwrite bundle key "type" */
786 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
787 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
789 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
792 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
795 case MSG_MGR_NOTI_TYPE_CB:
796 case MSG_MGR_NOTI_TYPE_SIM: {
797 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
798 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
801 case MSG_MGR_NOTI_TYPE_FAILED: {
802 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
803 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
806 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
807 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
810 case MSG_MGR_NOTI_TYPE_VOICE_1:
811 case MSG_MGR_NOTI_TYPE_VOICE_2:
812 case MSG_MGR_NOTI_TYPE_MWI:
813 case MSG_MGR_NOTI_TYPE_CLASS0:
814 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
815 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
816 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
817 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
821 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
826 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
827 if (noti_err != NOTIFICATION_ERROR_NONE) {
828 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
832 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
833 if (noti_err != NOTIFICATION_ERROR_NONE) {
834 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
841 void setTextDomain(notification_h noti_h)
845 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
850 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
854 char unreadMsgCntStr[10] = {0};
857 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
858 MSG_MGR_DEBUG("vconf_get_bool is failed.");
861 /* set title and content */
862 switch (noti_info->type) {
863 #ifdef MSG_NOTI_INTEGRATION
864 case MSG_MGR_NOTI_TYPE_NORMAL:
865 case MSG_MGR_NOTI_TYPE_CB:
866 case MSG_MGR_NOTI_TYPE_SIM: {
867 if (noti_info->count > 1) {
868 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
869 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
870 setNotiTime(noti_h, noti_info->time);
872 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
873 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
877 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
878 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
880 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
881 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
883 setNotiTime(noti_h, noti_info->time);
888 case MSG_MGR_NOTI_TYPE_NORMAL: {
889 if (noti_info->count > 1) {
890 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
891 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
892 setNotiTime(noti_h, noti_info->time);
894 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
895 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
898 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
899 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
901 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
902 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
904 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
905 setNotiTime(noti_h, noti_info->time);
909 case MSG_MGR_NOTI_TYPE_CB: {
910 if (noti_info->count > 1) {
911 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
912 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
913 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
914 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
915 setNotiTime(noti_h, noti_info->time);
918 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
919 setNotiTime(noti_h, noti_info->time);
922 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
923 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
925 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
926 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
931 case MSG_MGR_NOTI_TYPE_SIM: {
932 if (noti_info->count > 1) {
933 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
934 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
935 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
937 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
938 setNotiTime(noti_h, noti_info->time);
940 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
941 setNotiTime(noti_h, noti_info->time);
944 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
945 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
947 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
948 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
954 case MSG_MGR_NOTI_TYPE_FAILED: {
955 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
956 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
957 if (noti_info->count > 1) {
958 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
959 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
961 setNotiTime(noti_h, noti_info->time);
964 case MSG_MGR_NOTI_TYPE_VOICE_1:
965 case MSG_MGR_NOTI_TYPE_VOICE_2: {
966 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
967 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
968 setNotiTime(noti_h, noti_info->time);
970 if (noti_info->count == 1) {
971 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
972 } else if (noti_info->count > 1) {
973 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
974 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
976 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
980 case MSG_MGR_NOTI_TYPE_MWI: {
981 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
982 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
983 setNotiTime(noti_h, noti_info->time);
986 case MSG_MGR_NOTI_TYPE_CLASS0: {
987 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
988 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
989 setNotiTime(noti_h, noti_info->time);
992 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
993 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
994 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
996 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
997 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
998 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
999 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
1001 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
1004 setNotiTime(noti_h, noti_info->time);
1007 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
1008 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
1010 char readStatusString[50] = {0,};
1011 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
1012 snprintf(readStatusString, sizeof(readStatusString), "Message deleted by %s", noti_info->sender);
1013 notification_set_text(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, readStatusString, MESSAGE_DELETED_BY_PS, NOTIFICATION_VARIABLE_TYPE_STRING, noti_info->sender, NOTIFICATION_VARIABLE_TYPE_NONE);
1015 char readStatusString[50] = {0,};
1016 snprintf(readStatusString, sizeof(readStatusString), "Message read by %s", noti_info->sender);
1017 notification_set_text(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, readStatusString, MESSAGE_READ_BY_PS, NOTIFICATION_VARIABLE_TYPE_STRING, noti_info->sender, NOTIFICATION_VARIABLE_TYPE_NONE);
1020 setNotiTime(noti_h, noti_info->time);
1023 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
1024 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
1025 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
1027 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) {
1028 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
1029 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) {
1030 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", MESSAGE_REJECTED);
1031 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) {
1032 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
1033 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED || noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE
1034 || noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED || noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE
1035 || noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) {
1036 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Recipient not available", RECIPIENT_NOT_AVAILABLE);
1038 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
1041 setNotiTime(noti_h, noti_info->time);
1044 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT: {
1045 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Messages", MSG_MESSAGE);
1047 if ((int)noti_info->extra_data == MSG_NETWORK_SEND_FAIL) {
1048 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send Read report", FAILED_TO_SEND_MMS_READ_REPORT);
1050 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Read report sent", MMS_READ_REPORT_SENT);
1053 setNotiTime(noti_h, noti_info->time);
1056 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
1057 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
1058 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
1062 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1069 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1073 switch (noti_info->type) {
1074 #ifdef MSG_NOTI_INTEGRATION
1075 case MSG_MGR_NOTI_TYPE_NORMAL:
1076 case MSG_MGR_NOTI_TYPE_CB:
1077 case MSG_MGR_NOTI_TYPE_SIM: {
1078 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1079 if (noti_info->count > 1 && noti_info->senderCount > 1) {
1080 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
1081 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1082 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
1084 if (noti_info->active_subtype == MSG_CB_SMS) {
1085 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
1086 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1087 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
1088 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
1089 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1090 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
1091 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1093 if (noti_info->imagePath[0] != '\0') {
1094 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
1095 /* for user profile image, use NOTIFICATION_IMAGE_TYPE_THUMBNAIL to show icon as circle */
1096 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, noti_info->imagePath);
1098 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1099 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1100 /* TSAM-9359 : priority of image selection on quickpanel, thumbnail is higher. So set NOTIFICATION_IMAGE_TYPE_THUMBNAIL with null */
1101 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, NULL);
1104 char *msg_icon_path = NULL;
1105 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1106 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1107 g_free(msg_icon_path);
1109 MSG_MGR_ERR("fail to get message-app icon");
1116 case MSG_MGR_NOTI_TYPE_NORMAL: {
1117 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1118 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
1120 if (noti_info->count > 1) {
1121 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1123 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
1127 case MSG_MGR_NOTI_TYPE_CB: {
1128 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1129 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1132 case MSG_MGR_NOTI_TYPE_SIM: {
1133 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1134 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1138 case MSG_MGR_NOTI_TYPE_FAILED: {
1139 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1140 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_FAILED_STATUS_ICON);
1143 case MSG_MGR_NOTI_TYPE_VOICE_1:
1144 case MSG_MGR_NOTI_TYPE_VOICE_2:
1145 case MSG_MGR_NOTI_TYPE_MWI: {
1146 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1147 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1150 case MSG_MGR_NOTI_TYPE_CLASS0:
1151 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1153 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1154 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_DELIVER_REPORT_STATUS_ICON);
1155 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVERY_ICON_PATH);
1157 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1158 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_READ_REPORT_STATUS_ICON);
1159 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_READ_ICON_PATH);
1161 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
1162 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_READ_REPORT_STATUS_ICON);
1163 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_READ_ICON_PATH);
1165 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1166 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_DELIVER_REPORT_STATUS_ICON);
1167 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVERY_ICON_PATH);
1169 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1170 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1171 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_FULL_STATUS_ICON);
1174 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1181 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1185 int noti_err = NOTIFICATION_ERROR_NONE;
1188 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1189 if (noti_err != NOTIFICATION_ERROR_NONE) {
1190 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1194 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1195 if (noti_err != NOTIFICATION_ERROR_NONE) {
1196 MSG_MGR_DEBUG("Fail to notification_set_led.");
1199 /* set execute option and property */
1200 switch (noti_info->type) {
1201 case MSG_MGR_NOTI_TYPE_NORMAL:
1202 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1203 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
1205 case MSG_MGR_NOTI_TYPE_CLASS0:
1206 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1209 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
1214 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1215 if (noti_err != NOTIFICATION_ERROR_NONE) {
1216 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1220 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
1221 if (noti_err != NOTIFICATION_ERROR_NONE) {
1222 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
1229 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1233 switch (noti_info->type) {
1234 case MSG_MGR_NOTI_TYPE_NORMAL:
1235 case MSG_MGR_NOTI_TYPE_SIM:
1236 case MSG_MGR_NOTI_TYPE_CB: {
1237 if (noti_info->active_subject[0] == '\0') {
1238 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1239 if (noti_info->active_text[0] != '\0') {
1240 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1242 if (noti_info->active_media_cnt > 1) {
1243 char attach_string[20] = {0,};
1244 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1245 notification_set_text(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, MSG_PD_ATTACHMENTS, NOTIFICATION_VARIABLE_TYPE_INT, noti_info->active_media_cnt, NOTIFICATION_VARIABLE_TYPE_NONE);
1246 } else if (noti_info->active_media_cnt == 1) {
1247 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", MSG_SINGLE_ATTACHMENT);
1251 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1252 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1253 if (noti_info->active_text[0] != '\0') {
1254 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1256 if (noti_info->active_media_cnt > 1) {
1257 char attach_string[20] = {0,};
1258 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1259 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
1260 } else if (noti_info->active_media_cnt == 1) {
1261 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
1267 case MSG_MGR_NOTI_TYPE_CLASS0: {
1268 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1269 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1273 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1281 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1285 switch (noti_info->type) {
1286 case MSG_MGR_NOTI_TYPE_NORMAL:
1287 case MSG_MGR_NOTI_TYPE_SIM: {
1288 switch (noti_info->active_subtype) {
1290 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1292 case MSG_WAP_SI_SMS:
1293 case MSG_WAP_SL_SMS:
1294 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1297 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1300 if (noti_info->imagePath[0] != '\0')
1301 /* for user profile image, use NOTIFICATION_IMAGE_TYPE_THUMBNAIL to show icon as circle */
1302 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, noti_info->imagePath);
1304 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1306 char *msg_icon_path = NULL;
1307 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1308 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1309 g_free(msg_icon_path);
1311 MSG_MGR_ERR("fail to get message-app icon");
1319 case MSG_MGR_NOTI_TYPE_CB: {
1320 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1323 case MSG_MGR_NOTI_TYPE_CLASS0:
1324 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1327 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1335 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result)
1339 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
1340 notification_set_pkgname(noti, MSG_DEFAULT_APP_ID);
1342 setTextDomain(noti);
1343 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
1344 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVER_REPORT_STATUS_ICON);
1346 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT) {
1347 if (result == MSG_NETWORK_DELIVER_SUCCESS) {
1348 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1349 } else if (result == MSG_NETWORK_DELIVER_EXPIRED) {
1350 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1351 } else if (result == MSG_NETWORK_DELIVER_PENDING) {
1352 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1354 MSG_MGR_ERR("unexpected result! [%d]", result);
1355 goto _END_OF_INSTANT_DELIVERY_REPORT_NOTI;
1357 } else if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
1358 if (result == MSG_DELIVERY_REPORT_EXPIRED)
1359 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1360 else if (result== MSG_DELIVERY_REPORT_REJECTED)
1361 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message rejected by recipient.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_REJECTED);
1362 else if (result == MSG_DELIVERY_REPORT_DEFERRED)
1363 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1364 else if (result == MSG_DELIVERY_REPORT_UNRECOGNISED || result == MSG_DELIVERY_REPORT_INDETERMINATE ||
1365 result == MSG_DELIVERY_REPORT_FORWARDED || result == MSG_DELIVERY_REPORT_UNREACHABLE ||
1366 result == MSG_DELIVERY_REPORT_ERROR)
1367 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Recipient not available.", UNABLE_TO_DELIVER_MESSAGE_RECIPIENT_NOT_AVAILABLE);
1369 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1372 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
1373 MSG_MGR_ERR("Fail to notification_set_display_applist");
1375 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
1376 MSG_MGR_ERR("Fail to notification_post");
1378 _END_OF_INSTANT_DELIVERY_REPORT_NOTI:
1380 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
1381 MSG_MGR_ERR("Fail to notification_delete");
1384 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
1385 MSG_MGR_ERR("Fail to notification_free");
1394 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1398 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1399 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1401 if (addressVal != NULL) {
1402 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1403 /* Get Contact Info */
1404 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1405 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1408 MSG_MGR_DEBUG("addressVal is NULL.");
1411 char *msg_tone_file_path = NULL;
1413 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1415 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1417 bool bPlaySound = false;
1418 bool bPlayVibration = false;
1419 bool bOnCall = false;
1421 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1424 if (msg_tone_file_path) {
1425 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1428 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1429 MSG_MGR_INFO("vconf_get_int() is failed");
1431 int ringtoneType = tmpVal;
1432 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1433 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1435 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1438 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1441 if (bPlayVibration) {
1442 if (contactInfo.vibrationPath[0] == '\0')
1443 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1445 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1447 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1450 if (msg_tone_file_path)
1451 delete [] msg_tone_file_path;
1457 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1461 int noti_err = NOTIFICATION_ERROR_NONE;
1463 if (noti_info->active_noti_button_num > 1) {
1464 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1465 if (noti_info->active_noti_svc_h[0]) {
1466 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1467 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1469 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1471 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1472 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1473 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1474 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1477 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1478 if (noti_info->active_noti_svc_h[1]) {
1479 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_MGR_APP_ID);
1481 MSG_MGR_DEBUG("Active Notification button 2 - number = [%s] slot_id = [%d]", noti_info->number, noti_info->sim_idx);
1482 addServiceExtraData(noti_info->active_noti_svc_h[1], "cmd", "reply_msg");
1483 addServiceExtraData(noti_info->active_noti_svc_h[1], "addr", noti_info->number);
1485 char slot_id[5] = {0, };
1486 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx);
1487 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1491 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1492 if (noti_info->active_noti_svc_h[2]) {
1493 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1495 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1496 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1497 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1498 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1500 char slot_id[5] = {0, };
1501 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1502 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1505 if (noti_info->active_noti_button_num > 1) {
1506 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1507 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1508 notification_set_text_input(noti_h, 100);
1509 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_TEXT_INPUT_BUTTON, noti_info->active_noti_svc_h[1]);
1510 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1512 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1513 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1514 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1516 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1518 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1521 setActiveProperty(noti_h, noti_info);
1523 setTextDomain(noti_h);
1525 setActiveText(noti_h, noti_info);
1527 setActiveIcon(noti_h, noti_info);
1529 noti_err = notification_post(noti_h);
1530 if (noti_err != NOTIFICATION_ERROR_NONE) {
1531 MSG_MGR_DEBUG("Fail to notification_post");
1538 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1542 int noti_err = NOTIFICATION_ERROR_NONE;
1544 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1546 if (bFeedback && noti_info->active_noti_button_num > MSG_ACTIVE_NOTI_BUTTON_NUM_NONE &&
1547 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1548 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1550 setActiveNotification(active_noti_h, noti_info);
1552 notification_free(active_noti_h);
1553 active_noti_h = NULL;
1556 setProperty(noti_h, noti_info);
1558 setTextDomain(noti_h);
1560 setText(noti_h, noti_info);
1562 setIcon(noti_h, noti_info);
1565 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1566 setSoundAndVibration(noti_h, noti_info->number, true);
1568 setSoundAndVibration(noti_h, noti_info->number, false);
1571 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1572 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1575 if (noti_info->id > 0) {
1576 MSG_MGR_DEBUG("Notification update");
1577 noti_err = notification_update(noti_h);
1578 if (noti_err != NOTIFICATION_ERROR_NONE) {
1579 MSG_MGR_DEBUG("Fail to notification_update");
1582 MSG_MGR_DEBUG("Notification insert");
1583 noti_err = notification_insert(noti_h, ¬i_info->id);
1584 if (noti_err != NOTIFICATION_ERROR_NONE) {
1585 MSG_MGR_DEBUG("Fail to notification_insert");
1588 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1591 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT && noti_info->msg_id > 0) {
1592 int err = vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID, noti_info->msg_id);
1594 MSG_MGR_ERR("vconf_set_int() failed [%d]", err);
1601 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1606 MSG_MGR_DEBUG("msg_info is NULL");
1610 noti_info->msg_id = msg_info->msgId;
1611 noti_info->sim_idx = msg_info->sim_idx;
1613 switch (noti_info->type) {
1614 case MSG_MGR_NOTI_TYPE_NORMAL: {
1615 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1616 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1623 case MSG_MGR_NOTI_TYPE_CLASS0: {
1624 if (msg_info->displayName[0] == '\0')
1625 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1627 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1629 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1633 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1641 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1646 notification_free(noti_h);
1650 if (noti_info->svc_h) {
1651 app_control_destroy(noti_info->svc_h);
1652 noti_info->svc_h = NULL;
1655 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1656 if (noti_info->active_noti_svc_h[i]) {
1657 app_control_destroy(noti_info->active_noti_svc_h[i]);
1658 noti_info->active_noti_svc_h[i] = NULL;
1666 int getAppIcon(const char *app_id, char **icon_path)
1670 package_info_h pkg_info_h = NULL;
1671 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1674 if (app_id == NULL) {
1675 MSG_MGR_ERR("app id is NULL");
1677 goto END_OF_GET_APP_ICON;
1680 pkg_err = package_info_create(app_id, &pkg_info_h);
1681 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1682 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1684 goto END_OF_GET_APP_ICON;
1687 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1688 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1689 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1692 if (icon_path == NULL) {
1693 MSG_MGR_WARN("icon path is NULL");
1698 END_OF_GET_APP_ICON:
1700 pkg_err = package_info_destroy(pkg_info_h);
1701 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1702 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1714 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1719 msg_error_t msg_err = MSG_SUCCESS;
1720 char **db_res = NULL;
1721 int row_cnt = 0, col_cnt = 0;
1723 switch (noti_info->type) {
1724 case MSG_MGR_NOTI_TYPE_NORMAL:
1725 #ifdef MSG_NOTI_INTEGRATION
1726 case MSG_MGR_NOTI_TYPE_CB:
1727 case MSG_MGR_NOTI_TYPE_SIM:
1730 int smsUnreadCnt = 0;
1731 int mmsUnreadCnt = 0;
1733 char sqlQuery[MAX_QUERY_LEN +1];
1734 unsigned char mainType;
1735 unsigned char subType;
1736 int msgSize, attachmentCnt;
1738 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1739 #ifdef MSG_NOTI_INTEGRATION
1740 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1744 "WHERE A.CONV_ID=B.CONV_ID "
1745 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1746 "AND B.STORAGE_ID = %d "
1747 "GROUP BY A.ADDRESS_VAL "
1748 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1749 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1750 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1753 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1757 "WHERE A.CONV_ID=B.CONV_ID "
1758 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1759 "AND B.STORAGE_ID = %d "
1760 "GROUP BY A.ADDRESS_VAL "
1761 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1762 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1766 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1768 row_cnt = 0, col_cnt = 0;
1769 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1770 if (msg_err != MSG_SUCCESS) {
1771 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1775 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1776 int normalAddCnt = 0;
1777 int index = col_cnt;
1779 for (int i = 1; i <= row_cnt; i++) {
1780 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1782 char *address = db_res[index++];
1785 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1786 if (_is_valid_email(address)) {
1787 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1789 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1792 subType = atoi(db_res[index++]);
1794 MSG_MGR_CONTACT_INFO_S tmpContact;
1795 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1797 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1800 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1803 if (normalAddCnt > 1) {
1804 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1807 if (tmpContact.firstName[0] != '\0') {
1808 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1809 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1810 char *senderStr = NULL;
1811 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1812 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1819 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_UNKNOWN_SENDER;
1822 char *senderStr = NULL;
1823 if (subType == MSG_CB_SMS) {
1824 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1825 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1826 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
1827 } else if (subType == MSG_SYNCML_CP) {
1828 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1829 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1830 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_PUSH_MESSAGE;
1831 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1832 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1833 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1834 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_PUSH_MESSAGE;
1836 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1837 if (subType == MSG_NOTIFICATIONIND_MMS)
1838 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_UNRETRIVED_MESSAGE;
1848 noti_info->active_subtype = subType;
1849 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1850 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1854 noti_info->senderCount = normalAddCnt;
1855 msg_db_free(msg_handle, db_res);
1857 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1859 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1860 snprintf(sqlQuery, MAX_QUERY_LEN,
1861 "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS SMS_UNREAD_CNT, "
1862 "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS MMS_UNREAD_CNT "
1863 "FROM %s WHERE READ_STATUS = 0 AND (FOLDER_ID=%d OR FOLDER_ID=%d) AND STORAGE_ID = %d;",
1866 MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE);
1868 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1870 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1871 if (msg_err != MSG_SUCCESS) {
1872 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1877 smsUnreadCnt = atoi(db_res[col_cnt]);
1878 mmsUnreadCnt = atoi(db_res[col_cnt+1]);
1881 msg_db_free(msg_handle, db_res);
1883 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1885 if (noti_info->count == 0) {
1886 MSG_MGR_DEBUG("No unread message.");
1887 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1889 if (!isForInstantMessage) {
1890 /* No unread message. */
1891 if (noti_info->id > 0) {
1892 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1893 if (noti_err != NOTIFICATION_ERROR_NONE) {
1894 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1900 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1901 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1903 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1904 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1905 MsgMgrInsertBadge(0);
1906 MsgMgrSoundSetRepeatAlarm();
1912 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1913 #ifdef MSG_NOTI_INTEGRATION
1914 snprintf(sqlQuery, sizeof(sqlQuery),
1918 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
1919 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
1922 "(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), "
1923 "B.ATTACHMENT_COUNT, "
1926 "LEFT JOIN %s A ON A.CONV_ID=B.CONV_ID "
1927 "WHERE B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1928 "AND B.STORAGE_ID = %d "
1929 "ORDER BY B.DISPLAY_TIME DESC;",
1930 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1931 MSGFW_MESSAGE_TABLE_NAME,
1932 MSGFW_ADDRESS_TABLE_NAME,
1933 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1936 snprintf(sqlQuery, sizeof(sqlQuery),
1943 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1944 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1946 "WHERE A.CONV_ID=B.CONV_ID "
1947 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1948 "AND B.STORAGE_ID = %d "
1949 "ORDER BY B.DISPLAY_TIME DESC;",
1952 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1956 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1958 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1959 if (msg_err != MSG_SUCCESS) {
1960 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1965 msgSize = atoi(db_res[col_cnt+7]);
1966 attachmentCnt = atoi(db_res[col_cnt+8]);
1967 noti_info->sim_idx = atoi(db_res[col_cnt+9]);
1969 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1971 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1973 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1975 noti_info->conv_id = atoi(db_res[col_cnt+6]);
1977 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1979 if (mainType == MSG_MMS_TYPE) {
1980 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1981 if (noti_info->text[0] == '\0') {
1982 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1983 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1987 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1988 if (prefix_subject) {
1989 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1990 g_free(prefix_subject);
1992 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1996 int kb_msg_size = msgSize / 1024;
1997 if (kb_msg_size == 0 && msgSize > 0)
1999 else if (msgSize % 1024 >= 512)
2002 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
2003 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
2005 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
2007 g_free(msg_size_string);
2008 g_free(msg_size_unit_kb);
2011 noti_info->active_media_cnt = attachmentCnt;
2014 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2017 if (noti_info->active_text[0] == '\0')
2018 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
2020 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
2022 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
2023 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
2024 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
2026 if (!isForInstantMessage) {
2027 if (noti_info->id > 0 && noti_info->count == 1) {
2028 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, 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);
2034 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
2035 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
2038 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
2039 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
2040 MsgMgrInsertBadge(noti_info->count);
2041 MsgMgrSoundSetRepeatAlarm();
2044 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2045 msg_db_free(msg_handle, db_res);
2049 msg_db_free(msg_handle, db_res);
2053 #ifndef MSG_NOTI_INTEGRATION
2054 case MSG_MGR_NOTI_TYPE_CB: {
2055 char sqlQuery[MAX_QUERY_LEN+1];
2056 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2058 snprintf(sqlQuery, sizeof(sqlQuery),
2064 "WHERE A.CONV_ID=B.CONV_ID "
2065 "AND B.READ_STATUS=0 "
2066 "AND B.FOLDER_ID=%d "
2067 "AND B.STORAGE_ID = %d "
2068 "ORDER BY B.DISPLAY_TIME DESC;",
2069 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2073 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
2074 return MSG_ERR_DB_PREPARE;
2076 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
2077 MSG_ADDRESS_INFO_S addrInfo;
2078 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
2080 if (dbhandler->columnText(0) != NULL)
2081 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2083 MSG_CONTACT_INFO_S tmpContact;
2084 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2086 MsgGetContactInfo(&addrInfo, &tmpContact);
2088 if (tmpContact.firstName[0] != '\0') {
2089 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2090 } else if (addrInfo.addressVal[0] == '\0') {
2091 char *senderStr = NULL;
2092 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2093 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2099 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2102 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2104 noti_info->time = (time_t)dbhandler->columnInt(1);
2106 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2108 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2110 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
2112 MSG_MGR_DEBUG("No unread CB message.");
2113 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
2115 dbhandler->finalizeQuery();
2117 if (!isForInstantMessage) {
2118 /* No unread message. */
2119 if (noti_info->id > 0) {
2120 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2121 if (noti_err != NOTIFICATION_ERROR_NONE) {
2122 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2128 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2129 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
2131 return MSG_ERR_DB_STEP;
2134 dbhandler->finalizeQuery();
2136 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
2137 MSG_MGR_DEBUG("getTable is failed");
2138 dbhandler->freeTable();
2139 return MSG_ERR_DB_GETTABLE;
2142 dbhandler->freeTable();
2143 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
2146 case MSG_MGR_NOTI_TYPE_SIM: {
2147 char sqlQuery[MAX_QUERY_LEN+1];
2148 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2150 snprintf(sqlQuery, sizeof(sqlQuery),
2155 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
2157 "WHERE A.CONV_ID=B.CONV_ID "
2158 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2159 "AND B.STORAGE_ID = %d "
2160 "ORDER BY B.DISPLAY_TIME DESC;",
2162 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2166 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2168 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
2169 return MSG_ERR_DB_PREPARE;
2171 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
2172 noti_info->count = dbhandler->columnInt(4);
2174 if (noti_info->count > 0) {
2175 MSG_ADDRESS_INFO_S addrInfo;
2176 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
2178 if (dbhandler->columnText(0) != NULL)
2179 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2181 MSG_CONTACT_INFO_S tmpContact;
2182 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2184 MsgGetContactInfo(&addrInfo, &tmpContact);
2186 if (tmpContact.firstName[0] != '\0') {
2187 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2188 } else if (addrInfo.addressVal[0] == '\0') {
2189 char *senderStr = NULL;
2190 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2191 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2197 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2200 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2202 noti_info->time = (time_t)dbhandler->columnInt(1);
2204 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2206 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2208 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
2210 MSG_MGR_DEBUG("No unread SIM message.");
2211 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2213 dbhandler->finalizeQuery();
2215 if (!isForInstantMessage) {
2216 /* No unread message. */
2217 if (noti_info->id > 0) {
2218 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2219 if (noti_err != NOTIFICATION_ERROR_NONE) {
2220 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2226 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2227 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2230 return MSG_ERR_DB_STEP;
2233 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2234 dbhandler->finalizeQuery();
2235 return MSG_ERR_DB_STEP;
2238 dbhandler->finalizeQuery();
2242 case MSG_MGR_NOTI_TYPE_FAILED: {
2243 char sqlQuery[MAX_QUERY_LEN+1];
2244 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2246 snprintf(sqlQuery, sizeof(sqlQuery),
2253 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2255 "WHERE A.CONV_ID=B.CONV_ID "
2256 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2257 "AND B.STORAGE_ID = %d "
2258 "ORDER BY B.DISPLAY_TIME DESC;",
2259 MSG_NETWORK_SEND_FAIL,
2260 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2264 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2266 row_cnt = 0, col_cnt = 0;
2267 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2268 if (msg_err != MSG_SUCCESS) {
2269 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2274 noti_info->count = atoi(db_res[col_cnt+6]);
2276 if (noti_info->count > 0) {
2277 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2279 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2281 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2283 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2285 if (tmpContact.firstName[0] != '\0') {
2286 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2287 } else if (addrInfo.addressVal[0] == '\0') {
2288 char *senderStr = NULL;
2289 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2290 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2296 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2299 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2301 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2303 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2305 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2307 if (mainType == MSG_TYPE_MMS)
2308 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2310 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2312 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2314 if (!isForInstantMessage) {
2315 if (noti_info->id > 0 && noti_info->count == 1) {
2316 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2317 if (noti_err != NOTIFICATION_ERROR_NONE) {
2318 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2321 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2322 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2326 MSG_MGR_DEBUG("No sent failed message.");
2327 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2329 msg_db_free(msg_handle, db_res);
2331 if (!isForInstantMessage) {
2332 /* No unread message. */
2333 if (noti_info->id > 0) {
2334 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2335 if (noti_err != NOTIFICATION_ERROR_NONE) {
2336 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2342 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2343 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2349 msg_db_free(msg_handle, db_res);
2353 msg_db_free(msg_handle, db_res);
2356 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2359 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2369 notification_h getHandle(int *noti_id)
2371 notification_h noti_h = NULL;
2374 MSG_MGR_DEBUG("Notification load");
2375 noti_h = notification_load(NULL, *noti_id);
2377 MSG_MGR_DEBUG("notification_load is failed.");
2380 if (noti_h == NULL) {
2381 MSG_MGR_DEBUG("Notification create");
2382 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2383 if (noti_h == NULL) {
2384 MSG_MGR_DEBUG("notification_create is failed.");
2395 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2401 switch (noti_type) {
2402 #ifdef MSG_NOTI_INTEGRATION
2403 case MSG_MGR_NOTI_TYPE_NORMAL:
2404 case MSG_MGR_NOTI_TYPE_SIM:
2405 case MSG_MGR_NOTI_TYPE_CB:
2406 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2409 case MSG_MGR_NOTI_TYPE_NORMAL:
2410 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2412 case MSG_MGR_NOTI_TYPE_SIM:
2413 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2415 case MSG_MGR_NOTI_TYPE_CB:
2416 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2419 case MSG_MGR_NOTI_TYPE_FAILED:
2420 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2422 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
2423 vconf_get_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, ¬i_id);
2425 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2426 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2427 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2428 vconf_get_int(keyName, ¬i_id);
2431 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2432 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2433 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2434 vconf_get_int(keyName, ¬i_id);
2437 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2438 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2441 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2445 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2453 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2459 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2461 switch (noti_type) {
2462 #ifdef MSG_NOTI_INTEGRATION
2463 case MSG_MGR_NOTI_TYPE_NORMAL:
2464 case MSG_MGR_NOTI_TYPE_SIM:
2465 case MSG_MGR_NOTI_TYPE_CB:
2466 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2469 case MSG_MGR_NOTI_TYPE_NORMAL:
2470 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2472 case MSG_MGR_NOTI_TYPE_SIM:
2473 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2475 case MSG_MGR_NOTI_TYPE_CB:
2476 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2479 case MSG_MGR_NOTI_TYPE_FAILED:
2480 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2482 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
2483 err = vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, noti_id);
2485 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2486 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2487 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2488 err = vconf_set_int(keyName, noti_id);
2491 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2492 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2493 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2494 err = vconf_set_int(keyName, noti_id);
2497 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2498 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2501 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2506 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2512 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2517 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2518 noti_info->msg_id = msg_info->msgId;
2520 MSG_MGR_DEBUG("msg_info is NULL");
2524 noti_info->sim_idx = msg_info->sim_idx;
2526 createServiceHandle(¬i_info->svc_h);
2527 char keyName[MAX_VCONFKEY_NAME_LEN];
2529 switch (noti_info->type) {
2530 case MSG_MGR_NOTI_TYPE_VOICE_1:
2531 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2532 memset(keyName, 0x00, sizeof(keyName));
2533 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2534 vconf_get_int(keyName, ¬i_info->count);
2535 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2536 noti_info->time = msg_info->displayTime;
2538 memset(keyName, 0x00, sizeof(keyName));
2539 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2540 char *voiceNumber = vconf_get_str(keyName);
2541 memset(keyName, 0x00, sizeof(keyName));
2542 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2543 char *voiceAlphaId = vconf_get_str(keyName);
2544 char *dialNumber = NULL;
2546 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2548 if (voiceNumber && strlen(voiceNumber))
2549 dialNumber = voiceNumber;
2551 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2552 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2553 } else if (dialNumber && strlen(dialNumber) > 0) {
2554 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2557 if (dialNumber && strlen(dialNumber) > 0)
2558 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2560 if (noti_info->svc_h) {
2561 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2562 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2564 char slot_id[5] = {0, };
2565 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2566 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2569 if (voiceNumber) g_free(voiceNumber);
2570 if (voiceAlphaId) g_free(voiceAlphaId);
2573 case MSG_MGR_NOTI_TYPE_MWI:
2574 case MSG_MGR_NOTI_TYPE_CLASS0: {
2575 noti_info->count = 1;
2576 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2577 noti_info->time = msg_info->displayTime;
2579 if (msg_info->displayName[0] == '\0')
2580 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2582 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2584 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2586 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2588 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2589 if (noti_info->svc_h) {
2590 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2591 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2593 char slot_id[5] = {0, };
2594 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2595 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2599 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2600 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2601 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2605 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2606 noti_info->count = 1;
2607 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2608 noti_info->time = msg_info->displayTime;
2609 noti_info->extra_data = msg_info->networkStatus;
2611 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2612 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2613 if (msg_info->addressVal[0] != '\0') {
2614 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2615 if (_is_valid_email(msg_info->addressVal)) {
2616 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2618 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2622 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2623 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2626 if (contactInfo.firstName[0] == '\0')
2627 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2629 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2631 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2633 if (noti_info->msg_id > 0) {
2634 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2635 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2636 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2637 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2641 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2642 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2643 noti_info->count = 1;
2644 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2645 noti_info->time = msg_info->displayTime;
2647 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2648 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2649 if (msg_info->addressVal[0] != '\0') {
2650 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2651 if (_is_valid_email(msg_info->addressVal)) {
2652 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2654 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2658 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2659 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2661 if (contactInfo.firstName[0] == '\0')
2662 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2664 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2666 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2668 char sqlQuery[MAX_QUERY_LEN+1];
2669 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2671 int report_status_type;
2672 int report_status_value;
2674 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2675 report_status_type = MSG_REPORT_TYPE_READ;
2677 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2680 snprintf(sqlQuery, sizeof(sqlQuery),
2683 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE \"%%%s\";",
2684 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2686 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2688 char **db_res = NULL;
2689 int row_cnt = 0, col_cnt = 0;
2691 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2692 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2693 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2697 report_status_value = atoi(db_res[col_cnt]);
2699 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2701 msg_err = msg_db_free(msg_handle, db_res);
2702 if (msg_err != MSG_SUCCESS) {
2703 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2707 if (noti_info->msg_id > 0) {
2708 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2709 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2710 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2711 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2714 noti_info->extra_data = (unsigned char)report_status_value;
2718 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2722 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2727 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2731 createServiceHandle(¬i_info->svc_h);
2733 switch (noti_info->type) {
2734 case MSG_MGR_NOTI_TYPE_NORMAL: {
2735 if (noti_info->count > 1) {
2736 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2738 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2741 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2742 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2743 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2744 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2746 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE) {
2747 if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
2748 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
2750 int activated_conv_id = -1;
2751 vconf_get_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, &activated_conv_id);
2753 if (activated_conv_id == -1) {
2754 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2755 } else if (activated_conv_id == 0) {
2756 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2757 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2758 } else if (activated_conv_id > 0){
2759 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2761 if (activated_conv_id != noti_info->conv_id)
2762 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2764 MSG_MGR_WARN("No adding Notification : activated conv id [%d] / notification conv id [%d]", activated_conv_id, noti_info->conv_id);
2767 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2772 case MSG_MGR_NOTI_TYPE_CB: {
2773 if (noti_info->count > 1) {
2774 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2776 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2779 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2780 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2781 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2783 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2784 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2786 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2788 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
2791 case MSG_MGR_NOTI_TYPE_SIM: {
2792 if (noti_info->count > 1) {
2793 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2795 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2798 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2799 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2800 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2802 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2803 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2805 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2807 if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
2808 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
2811 case MSG_MGR_NOTI_TYPE_FAILED: {
2812 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2814 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2815 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2816 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2818 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2821 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2822 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2824 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2825 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2827 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2834 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2835 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2841 void createServiceHandle(app_control_h *svc_h)
2843 int svc_err = APP_CONTROL_ERROR_NONE;
2845 svc_err = app_control_create(svc_h);
2847 if (svc_err != APP_CONTROL_ERROR_NONE)
2848 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2852 void setServiceAppId(app_control_h svc_h, const char* app_id)
2854 int svc_err = APP_CONTROL_ERROR_NONE;
2856 svc_err = app_control_set_app_id(svc_h, app_id);
2858 if (svc_err != APP_CONTROL_ERROR_NONE)
2859 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2863 void setServiceUri(app_control_h svc_h, const char* uri)
2865 int svc_err = APP_CONTROL_ERROR_NONE;
2867 svc_err = app_control_set_uri(svc_h, uri);
2869 if (svc_err != APP_CONTROL_ERROR_NONE)
2870 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2874 void setServiceOperation(app_control_h svc_h, const char* operation)
2876 int svc_err = APP_CONTROL_ERROR_NONE;
2878 svc_err = app_control_set_operation(svc_h, operation);
2880 if (svc_err != APP_CONTROL_ERROR_NONE)
2881 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2885 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2887 int svc_err = APP_CONTROL_ERROR_NONE;
2889 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2891 if (svc_err != APP_CONTROL_ERROR_NONE)
2892 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2896 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2898 int svc_err = APP_CONTROL_ERROR_NONE;
2901 memset(&tempId, 0x00, sizeof(tempId));
2902 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2904 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2906 if (svc_err != APP_CONTROL_ERROR_NONE)
2907 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2911 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2913 int svc_err = APP_CONTROL_ERROR_NONE;
2915 svc_err = app_control_set_app_id(svc_h, pkg_name);
2917 if (svc_err != APP_CONTROL_ERROR_NONE)
2918 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2922 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2924 int svc_err = APP_CONTROL_ERROR_NONE;
2926 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2928 if (svc_err != APP_CONTROL_ERROR_NONE)
2929 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2933 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2935 int noti_err = NOTIFICATION_ERROR_NONE;
2937 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2938 if (noti_err != NOTIFICATION_ERROR_NONE)
2939 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2943 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2945 int noti_err = NOTIFICATION_ERROR_NONE;
2947 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2949 if (noti_err != NOTIFICATION_ERROR_NONE)
2950 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2954 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2956 int noti_err = NOTIFICATION_ERROR_NONE;
2958 noti_err = notification_set_time_to_text(noti_h, type, time);
2960 if (noti_err != NOTIFICATION_ERROR_NONE)
2961 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2965 void setNotiTime(notification_h noti_h, time_t time)
2967 int noti_err = NOTIFICATION_ERROR_NONE;
2969 noti_err = notification_set_time(noti_h, time);
2971 if (noti_err != NOTIFICATION_ERROR_NONE)
2972 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2977 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2979 int noti_err = NOTIFICATION_ERROR_NONE;
2981 noti_err = notification_set_image(noti_h, type, image_path);
2983 if (noti_err != NOTIFICATION_ERROR_NONE)
2984 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2988 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2990 int noti_err = NOTIFICATION_ERROR_NONE;
2992 noti_err = notification_set_sound(noti_h, type, path);
2994 if (noti_err != NOTIFICATION_ERROR_NONE)
2995 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2999 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
3001 int noti_err = NOTIFICATION_ERROR_NONE;
3003 noti_err = notification_set_vibration(noti_h, type, path);
3005 if (noti_err != NOTIFICATION_ERROR_NONE)
3006 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
3010 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
3012 int noti_err = NOTIFICATION_ERROR_NONE;
3014 noti_err = notification_set_event_handler(noti_h, type, event_handler);
3016 if (noti_err != NOTIFICATION_ERROR_NONE)
3017 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
3021 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
3025 char *notiMsg = NULL;
3027 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
3029 switch (noti_type) {
3030 case MSG_MGR_NOTI_TYPE_NORMAL:
3031 case MSG_MGR_NOTI_TYPE_SIM:
3032 case MSG_MGR_NOTI_TYPE_CB: {
3033 MSG_MGR_NOTI_INFO_S noti_info;
3034 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
3036 noti_info.type = noti_type;
3037 int err = getLatestMsgInfo(¬i_info, true);
3040 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
3041 if (noti_info.count == 1) {
3042 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
3043 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
3044 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
3045 } else if (noti_info.count > 1) {
3046 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
3048 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
3049 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
3050 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
3051 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
3056 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
3060 case MSG_MGR_NOTI_TYPE_FAILED: {
3061 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
3062 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
3063 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
3067 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
3068 goto _END_OF_INSTANT_NOTI;
3072 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
3073 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
3075 if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
3076 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
3078 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
3079 MSG_MGR_DEBUG("Fail to notification_post");
3081 _END_OF_INSTANT_NOTI:
3083 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
3084 MSG_MGR_DEBUG("Fail to notification_delete");
3091 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
3092 MSG_MGR_DEBUG("Fail to notification_free");
3101 bool MsgMgrCheckNotificationSettingEnable()
3103 bool msg_noti_enabled = false;
3104 notification_system_setting_h system_setting = NULL;
3105 notification_setting_h setting = NULL;
3107 int err = NOTIFICATION_ERROR_NONE;
3109 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
3111 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
3112 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
3114 msg_noti_enabled = true;
3116 bool allow_to_notify = false;
3117 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
3119 if (err != NOTIFICATION_ERROR_NONE) {
3120 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
3124 if (allow_to_notify) {
3125 MSG_MGR_DEBUG("message notification is allowed");
3127 /* check do not disturb mode */
3128 err = notification_system_setting_load_system_setting(&system_setting);
3130 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
3131 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
3135 bool do_not_disturb_mode = false;
3136 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
3138 if (err != NOTIFICATION_ERROR_NONE) {
3139 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
3143 if (do_not_disturb_mode) {
3144 bool is_msg_excepted = false;
3145 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
3146 if (err != NOTIFICATION_ERROR_NONE) {
3147 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
3148 msg_noti_enabled = false;
3150 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
3151 msg_noti_enabled = (is_msg_excepted) ? true : false;
3154 MSG_MGR_DEBUG("do not disturb mode is off");
3157 MSG_MGR_INFO("message notification is not allowed");
3158 msg_noti_enabled = false;
3164 notification_system_setting_free_system_setting(system_setting);
3167 notification_setting_free_notification(setting);
3169 return msg_noti_enabled;
3173 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
3175 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
3176 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
3178 MsgMgrChangePmState();
3180 char *notiMsg = NULL;
3181 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
3184 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
3185 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
3187 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
3188 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
3189 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
3190 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
3191 notification_status_message_post(pTickerMsg);
3193 notification_status_message_post(notiMsg);
3196 /* Show ticker popup for sending failed msg. */
3197 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
3205 if (bPlayFeedback) {
3207 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
3208 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
3210 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
3212 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
3213 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
3215 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
3218 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
3226 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
3228 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
3230 int err = BADGE_ERROR_NONE;
3233 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
3235 if (err != BADGE_ERROR_NONE) {
3236 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
3242 err = badge_add(MSG_DEFAULT_APP_ID);
3243 if (err != BADGE_ERROR_NONE) {
3244 MSG_MGR_ERR("Fail to badge_add : %d", err);
3249 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
3251 if (err != BADGE_ERROR_NONE) {
3252 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3260 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3264 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3266 #ifndef MSG_NOTI_INTEGRATION
3267 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3268 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3276 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3282 struct tm repeat_tm;
3286 tmp_time += (RepeatTime*60);
3288 localtime_r(&tmp_time, &repeat_tm);
3290 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3291 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3295 g_alarmId = tmpAlarmId;
3296 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3304 void MsgMgrSoundSetRepeatAlarm()
3306 int nRepeatValue = 0;
3307 long nRepeatTime = 0;
3309 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3310 MSG_MGR_INFO("vconf_get_int() is failed");
3313 switch (nRepeatValue) {
3314 case MSG_ALERT_TONE_ONCE:
3317 case MSG_ALERT_TONE_2MINS:
3320 case MSG_ALERT_TONE_5MINS:
3323 case MSG_ALERT_TONE_10MINS:
3327 MSG_MGR_DEBUG("Invalid Repetition time");
3331 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3333 if (nRepeatTime > 0) {
3334 if (g_alarmId > 0) {
3335 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3336 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3340 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3347 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3349 char *notiMsg = NULL;
3352 lang = vconf_get_str(VCONFKEY_LANGSET);
3354 setlocale(LC_MESSAGES, lang);
3356 bindtextdomain(pkg_name, locale_dir);
3358 notiMsg = dgettext(pkg_name, text);
3365 return g_strdup(notiMsg);