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);
1102 char *msg_icon_path = NULL;
1103 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1104 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1105 g_free(msg_icon_path);
1107 MSG_MGR_ERR("fail to get message-app icon");
1114 case MSG_MGR_NOTI_TYPE_NORMAL: {
1115 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1116 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
1118 if (noti_info->count > 1) {
1119 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1121 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
1125 case MSG_MGR_NOTI_TYPE_CB: {
1126 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1127 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1130 case MSG_MGR_NOTI_TYPE_SIM: {
1131 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1132 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1136 case MSG_MGR_NOTI_TYPE_FAILED: {
1137 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1138 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_FAILED_STATUS_ICON);
1141 case MSG_MGR_NOTI_TYPE_VOICE_1:
1142 case MSG_MGR_NOTI_TYPE_VOICE_2:
1143 case MSG_MGR_NOTI_TYPE_MWI: {
1144 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1145 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1148 case MSG_MGR_NOTI_TYPE_CLASS0:
1149 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1151 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1152 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1153 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1155 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1156 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1157 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1159 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
1160 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1161 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1163 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1164 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1165 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1167 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1168 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1169 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1172 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1179 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1183 int noti_err = NOTIFICATION_ERROR_NONE;
1186 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1187 if (noti_err != NOTIFICATION_ERROR_NONE) {
1188 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1192 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1193 if (noti_err != NOTIFICATION_ERROR_NONE) {
1194 MSG_MGR_DEBUG("Fail to notification_set_led.");
1197 /* set execute option and property */
1198 switch (noti_info->type) {
1199 case MSG_MGR_NOTI_TYPE_NORMAL:
1200 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1201 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
1203 case MSG_MGR_NOTI_TYPE_CLASS0:
1204 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1207 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
1212 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1213 if (noti_err != NOTIFICATION_ERROR_NONE) {
1214 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1218 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
1219 if (noti_err != NOTIFICATION_ERROR_NONE) {
1220 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
1227 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1231 switch (noti_info->type) {
1232 case MSG_MGR_NOTI_TYPE_NORMAL:
1233 case MSG_MGR_NOTI_TYPE_SIM:
1234 case MSG_MGR_NOTI_TYPE_CB: {
1235 if (noti_info->active_subject[0] == '\0') {
1236 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1237 if (noti_info->active_text[0] != '\0') {
1238 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1240 if (noti_info->active_media_cnt > 1) {
1241 char attach_string[20] = {0,};
1242 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1243 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);
1244 } else if (noti_info->active_media_cnt == 1) {
1245 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", MSG_SINGLE_ATTACHMENT);
1249 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1250 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1251 if (noti_info->active_text[0] != '\0') {
1252 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1254 if (noti_info->active_media_cnt > 1) {
1255 char attach_string[20] = {0,};
1256 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1257 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
1258 } else if (noti_info->active_media_cnt == 1) {
1259 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
1265 case MSG_MGR_NOTI_TYPE_CLASS0: {
1266 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1267 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1271 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1279 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1283 switch (noti_info->type) {
1284 case MSG_MGR_NOTI_TYPE_NORMAL:
1285 case MSG_MGR_NOTI_TYPE_SIM: {
1286 switch (noti_info->active_subtype) {
1288 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1290 case MSG_WAP_SI_SMS:
1291 case MSG_WAP_SL_SMS:
1292 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1295 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1298 if (noti_info->imagePath[0] != '\0')
1299 /* for user profile image, use NOTIFICATION_IMAGE_TYPE_THUMBNAIL to show icon as circle */
1300 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, noti_info->imagePath);
1302 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1304 char *msg_icon_path = NULL;
1305 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1306 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1307 g_free(msg_icon_path);
1309 MSG_MGR_ERR("fail to get message-app icon");
1317 case MSG_MGR_NOTI_TYPE_CB: {
1318 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1321 case MSG_MGR_NOTI_TYPE_CLASS0:
1322 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1325 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1333 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result)
1337 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
1338 notification_set_pkgname(noti, MSG_DEFAULT_APP_ID);
1340 setTextDomain(noti);
1341 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
1342 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVER_REPORT_STATUS_ICON);
1344 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT) {
1345 if (result == MSG_NETWORK_DELIVER_SUCCESS) {
1346 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1347 } else if (result == MSG_NETWORK_DELIVER_EXPIRED) {
1348 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1349 } else if (result == MSG_NETWORK_DELIVER_PENDING) {
1350 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1352 MSG_MGR_ERR("unexpected result! [%d]", result);
1353 goto _END_OF_INSTANT_DELIVERY_REPORT_NOTI;
1355 } else if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
1356 if (result == MSG_DELIVERY_REPORT_EXPIRED)
1357 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1358 else if (result== MSG_DELIVERY_REPORT_REJECTED)
1359 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message rejected by recipient.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_REJECTED);
1360 else if (result == MSG_DELIVERY_REPORT_DEFERRED)
1361 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1362 else if (result == MSG_DELIVERY_REPORT_UNRECOGNISED || result == MSG_DELIVERY_REPORT_INDETERMINATE ||
1363 result == MSG_DELIVERY_REPORT_FORWARDED || result == MSG_DELIVERY_REPORT_UNREACHABLE ||
1364 result == MSG_DELIVERY_REPORT_ERROR)
1365 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Recipient not available.", UNABLE_TO_DELIVER_MESSAGE_RECIPIENT_NOT_AVAILABLE);
1367 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1370 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
1371 MSG_MGR_ERR("Fail to notification_set_display_applist");
1373 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
1374 MSG_MGR_ERR("Fail to notification_post");
1376 _END_OF_INSTANT_DELIVERY_REPORT_NOTI:
1378 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
1379 MSG_MGR_ERR("Fail to notification_delete");
1382 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
1383 MSG_MGR_ERR("Fail to notification_free");
1392 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1396 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1397 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1399 if (addressVal != NULL) {
1400 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1401 /* Get Contact Info */
1402 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1403 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1406 MSG_MGR_DEBUG("addressVal is NULL.");
1409 char *msg_tone_file_path = NULL;
1411 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1413 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1415 bool bPlaySound = false;
1416 bool bPlayVibration = false;
1417 bool bOnCall = false;
1419 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1422 if (msg_tone_file_path) {
1423 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1426 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1427 MSG_MGR_INFO("vconf_get_int() is failed");
1429 int ringtoneType = tmpVal;
1430 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1431 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1433 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1436 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1439 if (bPlayVibration) {
1440 if (contactInfo.vibrationPath[0] == '\0')
1441 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1443 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1445 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1448 if (msg_tone_file_path)
1449 delete [] msg_tone_file_path;
1455 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1459 int noti_err = NOTIFICATION_ERROR_NONE;
1461 if (noti_info->active_noti_button_num > 1) {
1462 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1463 if (noti_info->active_noti_svc_h[0]) {
1464 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1465 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1467 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1469 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1470 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1471 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1472 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1475 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1476 if (noti_info->active_noti_svc_h[1]) {
1477 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1479 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1480 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1481 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1483 char slot_id[5] = {0, };
1484 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1485 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1489 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1490 if (noti_info->active_noti_svc_h[2]) {
1491 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1493 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1494 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1495 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1496 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1498 char slot_id[5] = {0, };
1499 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1500 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1503 if (noti_info->active_noti_button_num > 1) {
1504 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1505 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1506 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1508 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1509 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1510 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1512 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1514 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1517 setActiveProperty(noti_h, noti_info);
1519 setTextDomain(noti_h);
1521 setActiveText(noti_h, noti_info);
1523 setActiveIcon(noti_h, noti_info);
1525 noti_err = notification_post(noti_h);
1526 if (noti_err != NOTIFICATION_ERROR_NONE) {
1527 MSG_MGR_DEBUG("Fail to notification_post");
1534 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1538 int noti_err = NOTIFICATION_ERROR_NONE;
1540 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1542 if (bFeedback && noti_info->active_noti_button_num > MSG_ACTIVE_NOTI_BUTTON_NUM_NONE &&
1543 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1544 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1546 setActiveNotification(active_noti_h, noti_info);
1548 notification_free(active_noti_h);
1549 active_noti_h = NULL;
1552 setProperty(noti_h, noti_info);
1554 setTextDomain(noti_h);
1556 setText(noti_h, noti_info);
1558 setIcon(noti_h, noti_info);
1561 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1562 setSoundAndVibration(noti_h, noti_info->number, true);
1564 setSoundAndVibration(noti_h, noti_info->number, false);
1567 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1568 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1571 if (noti_info->id > 0) {
1572 MSG_MGR_DEBUG("Notification update");
1573 noti_err = notification_update(noti_h);
1574 if (noti_err != NOTIFICATION_ERROR_NONE) {
1575 MSG_MGR_DEBUG("Fail to notification_update");
1578 MSG_MGR_DEBUG("Notification insert");
1579 noti_err = notification_insert(noti_h, ¬i_info->id);
1580 if (noti_err != NOTIFICATION_ERROR_NONE) {
1581 MSG_MGR_DEBUG("Fail to notification_insert");
1584 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1587 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT && noti_info->msg_id > 0) {
1588 int err = vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID, noti_info->msg_id);
1590 MSG_MGR_ERR("vconf_set_int() failed [%d]", err);
1597 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1602 MSG_MGR_DEBUG("msg_info is NULL");
1606 noti_info->msg_id = msg_info->msgId;
1607 noti_info->sim_idx = msg_info->sim_idx;
1609 switch (noti_info->type) {
1610 case MSG_MGR_NOTI_TYPE_NORMAL: {
1611 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1612 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1619 case MSG_MGR_NOTI_TYPE_CLASS0: {
1620 if (msg_info->displayName[0] == '\0')
1621 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1623 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1625 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1629 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1637 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1642 notification_free(noti_h);
1646 if (noti_info->svc_h) {
1647 app_control_destroy(noti_info->svc_h);
1648 noti_info->svc_h = NULL;
1651 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1652 if (noti_info->active_noti_svc_h[i]) {
1653 app_control_destroy(noti_info->active_noti_svc_h[i]);
1654 noti_info->active_noti_svc_h[i] = NULL;
1662 int getAppIcon(const char *app_id, char **icon_path)
1666 package_info_h pkg_info_h = NULL;
1667 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1670 if (app_id == NULL) {
1671 MSG_MGR_ERR("app id is NULL");
1673 goto END_OF_GET_APP_ICON;
1676 pkg_err = package_info_create(app_id, &pkg_info_h);
1677 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1678 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1680 goto END_OF_GET_APP_ICON;
1683 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1684 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1685 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1688 if (icon_path == NULL) {
1689 MSG_MGR_WARN("icon path is NULL");
1694 END_OF_GET_APP_ICON:
1696 pkg_err = package_info_destroy(pkg_info_h);
1697 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1698 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1710 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1715 msg_error_t msg_err = MSG_SUCCESS;
1716 char **db_res = NULL;
1717 int row_cnt = 0, col_cnt = 0;
1719 switch (noti_info->type) {
1720 case MSG_MGR_NOTI_TYPE_NORMAL:
1721 #ifdef MSG_NOTI_INTEGRATION
1722 case MSG_MGR_NOTI_TYPE_CB:
1723 case MSG_MGR_NOTI_TYPE_SIM:
1726 int smsUnreadCnt = 0;
1727 int mmsUnreadCnt = 0;
1729 char sqlQuery[MAX_QUERY_LEN +1];
1730 unsigned char mainType;
1731 unsigned char subType;
1732 int msgSize, attachmentCnt;
1734 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1735 #ifdef MSG_NOTI_INTEGRATION
1736 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1740 "WHERE A.CONV_ID=B.CONV_ID "
1741 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1742 "AND B.STORAGE_ID = %d "
1743 "GROUP BY A.ADDRESS_VAL "
1744 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1745 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1746 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1749 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1753 "WHERE A.CONV_ID=B.CONV_ID "
1754 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1755 "AND B.STORAGE_ID = %d "
1756 "GROUP BY A.ADDRESS_VAL "
1757 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1758 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1762 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1764 row_cnt = 0, col_cnt = 0;
1765 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1766 if (msg_err != MSG_SUCCESS) {
1767 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1771 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1772 int normalAddCnt = 0;
1773 int index = col_cnt;
1775 for (int i = 1; i <= row_cnt; i++) {
1776 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1778 char *address = db_res[index++];
1781 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1782 if (_is_valid_email(address)) {
1783 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1785 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1788 subType = atoi(db_res[index++]);
1790 MSG_MGR_CONTACT_INFO_S tmpContact;
1791 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1793 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1796 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1799 if (normalAddCnt > 1) {
1800 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1803 if (tmpContact.firstName[0] != '\0') {
1804 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1805 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1806 char *senderStr = NULL;
1807 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1808 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1815 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_UNKNOWN_SENDER;
1818 char *senderStr = NULL;
1819 if (subType == MSG_CB_SMS) {
1820 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1821 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1822 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
1823 } else if (subType == MSG_SYNCML_CP) {
1824 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_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_PUSH_MESSAGE;
1827 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1828 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_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;
1832 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1833 if (subType == MSG_NOTIFICATIONIND_MMS)
1834 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_UNRETRIVED_MESSAGE;
1844 noti_info->active_subtype = subType;
1845 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1846 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1850 noti_info->senderCount = normalAddCnt;
1851 msg_db_free(msg_handle, db_res);
1853 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1855 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1856 snprintf(sqlQuery, MAX_QUERY_LEN,
1857 "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS SMS_UNREAD_CNT, "
1858 "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS MMS_UNREAD_CNT "
1859 "FROM %s WHERE READ_STATUS = 0 AND (FOLDER_ID=%d OR FOLDER_ID=%d) AND STORAGE_ID = %d;",
1862 MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE);
1864 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1866 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1867 if (msg_err != MSG_SUCCESS) {
1868 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1873 smsUnreadCnt = atoi(db_res[col_cnt]);
1874 mmsUnreadCnt = atoi(db_res[col_cnt+1]);
1877 msg_db_free(msg_handle, db_res);
1879 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1880 #ifdef MSG_NOTI_INTEGRATION
1881 snprintf(sqlQuery, sizeof(sqlQuery),
1885 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
1886 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
1889 "(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), "
1890 "B.ATTACHMENT_COUNT "
1892 "LEFT JOIN %s A ON A.CONV_ID=B.CONV_ID "
1893 "WHERE B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1894 "AND B.STORAGE_ID = %d "
1895 "ORDER BY B.DISPLAY_TIME DESC;",
1896 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1897 MSGFW_MESSAGE_TABLE_NAME,
1898 MSGFW_ADDRESS_TABLE_NAME,
1899 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1902 snprintf(sqlQuery, sizeof(sqlQuery),
1909 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1910 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1912 "WHERE A.CONV_ID=B.CONV_ID "
1913 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1914 "AND B.STORAGE_ID = %d "
1915 "ORDER BY B.DISPLAY_TIME DESC;",
1918 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1922 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1924 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1925 if (msg_err != MSG_SUCCESS) {
1926 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1931 msgSize = atoi(db_res[col_cnt+7]);
1932 attachmentCnt = atoi(db_res[col_cnt+8]);
1934 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1936 if (noti_info->count > 0) {
1937 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1939 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1941 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1943 noti_info->conv_id = atoi(db_res[col_cnt+6]);
1945 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1947 if (mainType == MSG_MMS_TYPE) {
1948 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1949 if (noti_info->text[0] == '\0') {
1950 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1951 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1955 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1956 if (prefix_subject) {
1957 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1958 g_free(prefix_subject);
1960 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1964 int kb_msg_size = msgSize / 1024;
1965 if (kb_msg_size == 0 && msgSize > 0)
1967 else if (msgSize % 1024 >= 512)
1970 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1971 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1973 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1975 g_free(msg_size_string);
1976 g_free(msg_size_unit_kb);
1979 noti_info->active_media_cnt = attachmentCnt;
1982 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1985 if (noti_info->active_text[0] == '\0')
1986 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1988 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1990 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1991 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1992 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1994 if (!isForInstantMessage) {
1995 if (noti_info->id > 0 && noti_info->count == 1) {
1996 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1997 if (noti_err != NOTIFICATION_ERROR_NONE) {
1998 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2002 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
2003 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
2006 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
2007 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
2008 MsgMgrInsertBadge(noti_info->count);
2009 MsgMgrSoundSetRepeatAlarm();
2012 MSG_MGR_DEBUG("No unread message.");
2013 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2015 msg_db_free(msg_handle, db_res);
2017 if (!isForInstantMessage) {
2018 /* No unread message. */
2019 if (noti_info->id > 0) {
2020 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2021 if (noti_err != NOTIFICATION_ERROR_NONE) {
2022 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2028 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
2029 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
2031 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
2032 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
2033 MsgMgrInsertBadge(0);
2034 MsgMgrSoundSetRepeatAlarm();
2040 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2041 msg_db_free(msg_handle, db_res);
2045 msg_db_free(msg_handle, db_res);
2049 #ifndef MSG_NOTI_INTEGRATION
2050 case MSG_MGR_NOTI_TYPE_CB: {
2051 char sqlQuery[MAX_QUERY_LEN+1];
2052 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2054 snprintf(sqlQuery, sizeof(sqlQuery),
2060 "WHERE A.CONV_ID=B.CONV_ID "
2061 "AND B.READ_STATUS=0 "
2062 "AND B.FOLDER_ID=%d "
2063 "AND B.STORAGE_ID = %d "
2064 "ORDER BY B.DISPLAY_TIME DESC;",
2065 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2069 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
2070 return MSG_ERR_DB_PREPARE;
2072 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
2073 MSG_ADDRESS_INFO_S addrInfo;
2074 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
2076 if (dbhandler->columnText(0) != NULL)
2077 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2079 MSG_CONTACT_INFO_S tmpContact;
2080 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2082 MsgGetContactInfo(&addrInfo, &tmpContact);
2084 if (tmpContact.firstName[0] != '\0') {
2085 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2086 } else if (addrInfo.addressVal[0] == '\0') {
2087 char *senderStr = NULL;
2088 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2089 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2095 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2098 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2100 noti_info->time = (time_t)dbhandler->columnInt(1);
2102 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2104 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2106 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
2108 MSG_MGR_DEBUG("No unread CB message.");
2109 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
2111 dbhandler->finalizeQuery();
2113 if (!isForInstantMessage) {
2114 /* No unread message. */
2115 if (noti_info->id > 0) {
2116 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2117 if (noti_err != NOTIFICATION_ERROR_NONE) {
2118 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2124 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2125 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
2127 return MSG_ERR_DB_STEP;
2130 dbhandler->finalizeQuery();
2132 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
2133 MSG_MGR_DEBUG("getTable is failed");
2134 dbhandler->freeTable();
2135 return MSG_ERR_DB_GETTABLE;
2138 dbhandler->freeTable();
2139 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
2142 case MSG_MGR_NOTI_TYPE_SIM: {
2143 char sqlQuery[MAX_QUERY_LEN+1];
2144 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2146 snprintf(sqlQuery, sizeof(sqlQuery),
2151 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
2153 "WHERE A.CONV_ID=B.CONV_ID "
2154 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2155 "AND B.STORAGE_ID = %d "
2156 "ORDER BY B.DISPLAY_TIME DESC;",
2158 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2162 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2164 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
2165 return MSG_ERR_DB_PREPARE;
2167 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
2168 noti_info->count = dbhandler->columnInt(4);
2170 if (noti_info->count > 0) {
2171 MSG_ADDRESS_INFO_S addrInfo;
2172 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
2174 if (dbhandler->columnText(0) != NULL)
2175 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2177 MSG_CONTACT_INFO_S tmpContact;
2178 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2180 MsgGetContactInfo(&addrInfo, &tmpContact);
2182 if (tmpContact.firstName[0] != '\0') {
2183 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2184 } else if (addrInfo.addressVal[0] == '\0') {
2185 char *senderStr = NULL;
2186 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2187 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2193 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2196 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2198 noti_info->time = (time_t)dbhandler->columnInt(1);
2200 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2202 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2204 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
2206 MSG_MGR_DEBUG("No unread SIM message.");
2207 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2209 dbhandler->finalizeQuery();
2211 if (!isForInstantMessage) {
2212 /* No unread message. */
2213 if (noti_info->id > 0) {
2214 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2215 if (noti_err != NOTIFICATION_ERROR_NONE) {
2216 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2222 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2223 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2226 return MSG_ERR_DB_STEP;
2229 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2230 dbhandler->finalizeQuery();
2231 return MSG_ERR_DB_STEP;
2234 dbhandler->finalizeQuery();
2238 case MSG_MGR_NOTI_TYPE_FAILED: {
2239 char sqlQuery[MAX_QUERY_LEN+1];
2240 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2242 snprintf(sqlQuery, sizeof(sqlQuery),
2249 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2251 "WHERE A.CONV_ID=B.CONV_ID "
2252 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2253 "AND B.STORAGE_ID = %d "
2254 "ORDER BY B.DISPLAY_TIME DESC;",
2255 MSG_NETWORK_SEND_FAIL,
2256 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2260 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2262 row_cnt = 0, col_cnt = 0;
2263 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2264 if (msg_err != MSG_SUCCESS) {
2265 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2270 noti_info->count = atoi(db_res[col_cnt+6]);
2272 if (noti_info->count > 0) {
2273 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2275 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2277 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2279 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2281 if (tmpContact.firstName[0] != '\0') {
2282 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2283 } else if (addrInfo.addressVal[0] == '\0') {
2284 char *senderStr = NULL;
2285 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2286 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2292 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2295 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2297 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2299 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2301 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2303 if (mainType == MSG_TYPE_MMS)
2304 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2306 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2308 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2310 if (!isForInstantMessage) {
2311 if (noti_info->id > 0 && noti_info->count == 1) {
2312 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2313 if (noti_err != NOTIFICATION_ERROR_NONE) {
2314 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2317 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2318 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2322 MSG_MGR_DEBUG("No sent failed message.");
2323 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2325 msg_db_free(msg_handle, db_res);
2327 if (!isForInstantMessage) {
2328 /* No unread message. */
2329 if (noti_info->id > 0) {
2330 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2331 if (noti_err != NOTIFICATION_ERROR_NONE) {
2332 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2338 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2339 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2345 msg_db_free(msg_handle, db_res);
2349 msg_db_free(msg_handle, db_res);
2352 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2355 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2365 notification_h getHandle(int *noti_id)
2367 notification_h noti_h = NULL;
2370 MSG_MGR_DEBUG("Notification load");
2371 noti_h = notification_load(NULL, *noti_id);
2373 MSG_MGR_DEBUG("notification_load is failed.");
2376 if (noti_h == NULL) {
2377 MSG_MGR_DEBUG("Notification create");
2378 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2379 if (noti_h == NULL) {
2380 MSG_MGR_DEBUG("notification_create is failed.");
2391 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2397 switch (noti_type) {
2398 #ifdef MSG_NOTI_INTEGRATION
2399 case MSG_MGR_NOTI_TYPE_NORMAL:
2400 case MSG_MGR_NOTI_TYPE_SIM:
2401 case MSG_MGR_NOTI_TYPE_CB:
2402 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2405 case MSG_MGR_NOTI_TYPE_NORMAL:
2406 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2408 case MSG_MGR_NOTI_TYPE_SIM:
2409 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2411 case MSG_MGR_NOTI_TYPE_CB:
2412 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2415 case MSG_MGR_NOTI_TYPE_FAILED:
2416 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2418 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
2419 vconf_get_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, ¬i_id);
2421 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2422 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2423 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2424 vconf_get_int(keyName, ¬i_id);
2427 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2428 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2429 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2430 vconf_get_int(keyName, ¬i_id);
2433 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2434 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2437 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2441 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2449 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2455 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2457 switch (noti_type) {
2458 #ifdef MSG_NOTI_INTEGRATION
2459 case MSG_MGR_NOTI_TYPE_NORMAL:
2460 case MSG_MGR_NOTI_TYPE_SIM:
2461 case MSG_MGR_NOTI_TYPE_CB:
2462 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2465 case MSG_MGR_NOTI_TYPE_NORMAL:
2466 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2468 case MSG_MGR_NOTI_TYPE_SIM:
2469 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2471 case MSG_MGR_NOTI_TYPE_CB:
2472 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2475 case MSG_MGR_NOTI_TYPE_FAILED:
2476 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2478 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
2479 err = vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, noti_id);
2481 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2482 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2483 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2484 err = vconf_set_int(keyName, noti_id);
2487 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2488 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2489 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2490 err = vconf_set_int(keyName, noti_id);
2493 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2494 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2497 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2502 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2508 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2513 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2514 noti_info->msg_id = msg_info->msgId;
2516 MSG_MGR_DEBUG("msg_info is NULL");
2520 noti_info->sim_idx = msg_info->sim_idx;
2522 createServiceHandle(¬i_info->svc_h);
2523 char keyName[MAX_VCONFKEY_NAME_LEN];
2525 switch (noti_info->type) {
2526 case MSG_MGR_NOTI_TYPE_VOICE_1:
2527 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2528 memset(keyName, 0x00, sizeof(keyName));
2529 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2530 vconf_get_int(keyName, ¬i_info->count);
2531 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2532 noti_info->time = msg_info->displayTime;
2534 memset(keyName, 0x00, sizeof(keyName));
2535 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2536 char *voiceNumber = vconf_get_str(keyName);
2537 memset(keyName, 0x00, sizeof(keyName));
2538 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2539 char *voiceAlphaId = vconf_get_str(keyName);
2540 char *dialNumber = NULL;
2542 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2544 if (voiceNumber && strlen(voiceNumber))
2545 dialNumber = voiceNumber;
2547 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2548 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2549 } else if (dialNumber && strlen(dialNumber) > 0) {
2550 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2553 if (dialNumber && strlen(dialNumber) > 0)
2554 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2556 if (noti_info->svc_h) {
2557 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2558 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2560 char slot_id[5] = {0, };
2561 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2562 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2565 if (voiceNumber) g_free(voiceNumber);
2566 if (voiceAlphaId) g_free(voiceAlphaId);
2569 case MSG_MGR_NOTI_TYPE_MWI:
2570 case MSG_MGR_NOTI_TYPE_CLASS0: {
2571 noti_info->count = 1;
2572 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2573 noti_info->time = msg_info->displayTime;
2575 if (msg_info->displayName[0] == '\0')
2576 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2578 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2580 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2582 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2584 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2585 if (noti_info->svc_h) {
2586 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2587 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2589 char slot_id[5] = {0, };
2590 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2591 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2595 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2596 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2597 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2601 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2602 noti_info->count = 1;
2603 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2604 noti_info->time = msg_info->displayTime;
2605 noti_info->extra_data = msg_info->networkStatus;
2607 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2608 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2609 if (msg_info->addressVal[0] != '\0') {
2610 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2611 if (_is_valid_email(msg_info->addressVal)) {
2612 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2614 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2618 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2619 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2622 if (contactInfo.firstName[0] == '\0')
2623 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2625 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2627 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2629 if (noti_info->msg_id > 0) {
2630 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2631 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2632 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2633 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2637 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2638 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2639 noti_info->count = 1;
2640 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2641 noti_info->time = msg_info->displayTime;
2643 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2644 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2645 if (msg_info->addressVal[0] != '\0') {
2646 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2647 if (_is_valid_email(msg_info->addressVal)) {
2648 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2650 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2654 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2655 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2657 if (contactInfo.firstName[0] == '\0')
2658 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2660 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2662 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2664 char sqlQuery[MAX_QUERY_LEN+1];
2665 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2667 int report_status_type;
2668 int report_status_value;
2670 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2671 report_status_type = MSG_REPORT_TYPE_READ;
2673 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2676 snprintf(sqlQuery, sizeof(sqlQuery),
2679 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE \"%%%s\";",
2680 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2682 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2684 char **db_res = NULL;
2685 int row_cnt = 0, col_cnt = 0;
2687 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2688 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2689 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2693 report_status_value = atoi(db_res[col_cnt]);
2695 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2697 msg_err = msg_db_free(msg_handle, db_res);
2698 if (msg_err != MSG_SUCCESS) {
2699 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2703 if (noti_info->msg_id > 0) {
2704 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2705 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2706 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2707 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2710 noti_info->extra_data = (unsigned char)report_status_value;
2714 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2718 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2723 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2727 createServiceHandle(¬i_info->svc_h);
2729 switch (noti_info->type) {
2730 case MSG_MGR_NOTI_TYPE_NORMAL: {
2731 if (noti_info->count > 1) {
2732 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2734 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2737 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2738 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2739 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2740 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2742 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE) {
2743 if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
2744 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
2746 int activated_conv_id = -1;
2747 vconf_get_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, &activated_conv_id);
2749 if (activated_conv_id == -1) {
2750 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2751 } else if (activated_conv_id == 0) {
2752 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2753 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2754 } else if (activated_conv_id > 0){
2755 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2757 if (activated_conv_id != noti_info->conv_id)
2758 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2760 MSG_MGR_WARN("No adding Notification : activated conv id [%d] / notification conv id [%d]", activated_conv_id, noti_info->conv_id);
2763 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2768 case MSG_MGR_NOTI_TYPE_CB: {
2769 if (noti_info->count > 1) {
2770 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2772 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2775 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2776 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2777 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2779 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2780 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2782 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2784 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
2787 case MSG_MGR_NOTI_TYPE_SIM: {
2788 if (noti_info->count > 1) {
2789 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2791 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2794 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2795 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2796 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2798 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2799 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2801 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2803 if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
2804 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
2807 case MSG_MGR_NOTI_TYPE_FAILED: {
2808 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2810 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2811 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2812 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2814 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2817 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2818 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2820 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2821 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2823 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2830 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2831 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2837 void createServiceHandle(app_control_h *svc_h)
2839 int svc_err = APP_CONTROL_ERROR_NONE;
2841 svc_err = app_control_create(svc_h);
2843 if (svc_err != APP_CONTROL_ERROR_NONE)
2844 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2848 void setServiceAppId(app_control_h svc_h, const char* app_id)
2850 int svc_err = APP_CONTROL_ERROR_NONE;
2852 svc_err = app_control_set_app_id(svc_h, app_id);
2854 if (svc_err != APP_CONTROL_ERROR_NONE)
2855 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2859 void setServiceUri(app_control_h svc_h, const char* uri)
2861 int svc_err = APP_CONTROL_ERROR_NONE;
2863 svc_err = app_control_set_uri(svc_h, uri);
2865 if (svc_err != APP_CONTROL_ERROR_NONE)
2866 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2870 void setServiceOperation(app_control_h svc_h, const char* operation)
2872 int svc_err = APP_CONTROL_ERROR_NONE;
2874 svc_err = app_control_set_operation(svc_h, operation);
2876 if (svc_err != APP_CONTROL_ERROR_NONE)
2877 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2881 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2883 int svc_err = APP_CONTROL_ERROR_NONE;
2885 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2887 if (svc_err != APP_CONTROL_ERROR_NONE)
2888 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2892 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2894 int svc_err = APP_CONTROL_ERROR_NONE;
2897 memset(&tempId, 0x00, sizeof(tempId));
2898 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2900 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2902 if (svc_err != APP_CONTROL_ERROR_NONE)
2903 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2907 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2909 int svc_err = APP_CONTROL_ERROR_NONE;
2911 svc_err = app_control_set_app_id(svc_h, pkg_name);
2913 if (svc_err != APP_CONTROL_ERROR_NONE)
2914 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2918 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2920 int svc_err = APP_CONTROL_ERROR_NONE;
2922 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2924 if (svc_err != APP_CONTROL_ERROR_NONE)
2925 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2929 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2931 int noti_err = NOTIFICATION_ERROR_NONE;
2933 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2934 if (noti_err != NOTIFICATION_ERROR_NONE)
2935 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2939 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2941 int noti_err = NOTIFICATION_ERROR_NONE;
2943 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2945 if (noti_err != NOTIFICATION_ERROR_NONE)
2946 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2950 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2952 int noti_err = NOTIFICATION_ERROR_NONE;
2954 noti_err = notification_set_time_to_text(noti_h, type, time);
2956 if (noti_err != NOTIFICATION_ERROR_NONE)
2957 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2961 void setNotiTime(notification_h noti_h, time_t time)
2963 int noti_err = NOTIFICATION_ERROR_NONE;
2965 noti_err = notification_set_time(noti_h, time);
2967 if (noti_err != NOTIFICATION_ERROR_NONE)
2968 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2973 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2975 int noti_err = NOTIFICATION_ERROR_NONE;
2977 noti_err = notification_set_image(noti_h, type, image_path);
2979 if (noti_err != NOTIFICATION_ERROR_NONE)
2980 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2984 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2986 int noti_err = NOTIFICATION_ERROR_NONE;
2988 noti_err = notification_set_sound(noti_h, type, path);
2990 if (noti_err != NOTIFICATION_ERROR_NONE)
2991 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2995 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2997 int noti_err = NOTIFICATION_ERROR_NONE;
2999 noti_err = notification_set_vibration(noti_h, type, path);
3001 if (noti_err != NOTIFICATION_ERROR_NONE)
3002 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
3006 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
3008 int noti_err = NOTIFICATION_ERROR_NONE;
3010 noti_err = notification_set_event_handler(noti_h, type, event_handler);
3012 if (noti_err != NOTIFICATION_ERROR_NONE)
3013 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
3017 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
3021 char *notiMsg = NULL;
3023 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
3025 switch (noti_type) {
3026 case MSG_MGR_NOTI_TYPE_NORMAL:
3027 case MSG_MGR_NOTI_TYPE_SIM:
3028 case MSG_MGR_NOTI_TYPE_CB: {
3029 MSG_MGR_NOTI_INFO_S noti_info;
3030 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
3032 noti_info.type = noti_type;
3033 int err = getLatestMsgInfo(¬i_info, true);
3036 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
3037 if (noti_info.count == 1) {
3038 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
3039 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
3040 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
3041 } else if (noti_info.count > 1) {
3042 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
3044 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
3045 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
3046 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
3047 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
3052 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
3056 case MSG_MGR_NOTI_TYPE_FAILED: {
3057 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
3058 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
3059 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
3063 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
3064 goto _END_OF_INSTANT_NOTI;
3068 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
3069 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
3071 if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
3072 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
3074 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
3075 MSG_MGR_DEBUG("Fail to notification_post");
3077 _END_OF_INSTANT_NOTI:
3079 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
3080 MSG_MGR_DEBUG("Fail to notification_delete");
3087 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
3088 MSG_MGR_DEBUG("Fail to notification_free");
3097 bool MsgMgrCheckNotificationSettingEnable()
3099 bool msg_noti_enabled = false;
3100 notification_system_setting_h system_setting = NULL;
3101 notification_setting_h setting = NULL;
3103 int err = NOTIFICATION_ERROR_NONE;
3105 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
3107 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
3108 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
3110 msg_noti_enabled = true;
3112 bool allow_to_notify = false;
3113 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
3115 if (err != NOTIFICATION_ERROR_NONE) {
3116 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
3120 if (allow_to_notify) {
3121 MSG_MGR_DEBUG("message notification is allowed");
3123 /* check do not disturb mode */
3124 err = notification_system_setting_load_system_setting(&system_setting);
3126 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
3127 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
3131 bool do_not_disturb_mode = false;
3132 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
3134 if (err != NOTIFICATION_ERROR_NONE) {
3135 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
3139 if (do_not_disturb_mode) {
3140 bool is_msg_excepted = false;
3141 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
3142 if (err != NOTIFICATION_ERROR_NONE) {
3143 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
3144 msg_noti_enabled = false;
3146 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
3147 msg_noti_enabled = (is_msg_excepted) ? true : false;
3150 MSG_MGR_DEBUG("do not disturb mode is off");
3153 MSG_MGR_INFO("message notification is not allowed");
3154 msg_noti_enabled = false;
3160 notification_system_setting_free_system_setting(system_setting);
3163 notification_setting_free_notification(setting);
3165 return msg_noti_enabled;
3169 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
3171 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
3172 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
3174 MsgMgrChangePmState();
3176 char *notiMsg = NULL;
3177 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
3180 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
3181 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
3183 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
3184 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
3185 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
3186 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
3187 notification_status_message_post(pTickerMsg);
3189 notification_status_message_post(notiMsg);
3192 /* Show ticker popup for sending failed msg. */
3193 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
3201 if (bPlayFeedback) {
3203 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
3204 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
3206 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
3208 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
3209 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
3211 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
3214 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
3222 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
3224 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
3226 int err = BADGE_ERROR_NONE;
3229 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
3231 if (err != BADGE_ERROR_NONE) {
3232 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
3238 err = badge_add(MSG_DEFAULT_APP_ID);
3239 if (err != BADGE_ERROR_NONE) {
3240 MSG_MGR_ERR("Fail to badge_add : %d", err);
3245 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
3247 if (err != BADGE_ERROR_NONE) {
3248 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3256 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3260 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3262 #ifndef MSG_NOTI_INTEGRATION
3263 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3264 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3272 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3278 struct tm repeat_tm;
3282 tmp_time += (RepeatTime*60);
3284 localtime_r(&tmp_time, &repeat_tm);
3286 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3287 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3291 g_alarmId = tmpAlarmId;
3292 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3300 void MsgMgrSoundSetRepeatAlarm()
3302 int nRepeatValue = 0;
3303 long nRepeatTime = 0;
3305 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3306 MSG_MGR_INFO("vconf_get_int() is failed");
3309 switch (nRepeatValue) {
3310 case MSG_ALERT_TONE_ONCE:
3313 case MSG_ALERT_TONE_2MINS:
3316 case MSG_ALERT_TONE_5MINS:
3319 case MSG_ALERT_TONE_10MINS:
3323 MSG_MGR_DEBUG("Invalid Repetition time");
3327 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3329 if (nRepeatTime > 0) {
3330 if (g_alarmId > 0) {
3331 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3332 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3336 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3343 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3345 char *notiMsg = NULL;
3348 lang = vconf_get_str(VCONFKEY_LANGSET);
3350 setlocale(LC_MESSAGES, lang);
3352 bindtextdomain(pkg_name, locale_dir);
3354 notiMsg = dgettext(pkg_name, text);
3361 return g_strdup(notiMsg);