2 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*==================================================================================================
19 ==================================================================================================*/
29 #include <app_control.h>
30 #include <badge_internal.h>
31 #include <notification_list.h>
32 #include <notification_text_domain.h>
33 #include <notification_internal.h>
34 #include <notification_status.h>
35 #include <notification_setting.h>
36 #include <notification_setting_internal.h>
37 #include <package_manager.h>
41 #include <msg_storage.h>
43 #include <msg-manager-util.h>
44 #include <msg-manager-contact.h>
45 #include <msg-manager-debug.h>
46 #include <msg-manager-notification.h>
47 #include <msg-manager-sound.h>
52 /*==================================================================================================
54 ==================================================================================================*/
56 static GList *msg_report_notification_list = NULL;
57 static bool is_init = false;
58 extern msg_handle_t msg_handle;
62 /*==================================================================================================
64 ==================================================================================================*/
65 typedef struct _report_notification_s
68 char addressVal[MAX_ADDRESS_VAL_LEN+1];
69 } report_notification_s;
72 typedef struct _msg_mgr_noti_info_s
74 msg_mgr_notification_type_t type;
80 char sender[MSG_NOTI_TEXT_LEN_S+1];
81 char text[MSG_NOTI_TEXT_LEN+1];
82 char number[MSG_NOTI_TEXT_LEN_S+1];
83 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
86 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
87 msg_message_id_t msg_id;
89 unsigned char extra_data;
91 int active_noti_button_num;
93 int active_media_size;
94 unsigned char active_subtype; /**< to distinguish cb, push message */
95 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
96 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
97 char active_text[MSG_NOTI_TEXT_LEN+1];
98 } MSG_MGR_NOTI_INFO_S;
101 typedef struct _del_noti_info_s
103 msg_mgr_notification_type_t type;
108 /*==================================================================================================
110 ===================================================================================================*/
112 void MsgMgrInitReportNotiList();
113 void MsgInitNotiCb(void *data);
114 void MsgRefreshNotiCb(void *data);
115 void MsgMgrDeleteNotiCb(void *data);
117 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
118 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result);
120 notification_h getHandle(int *noti_id);
122 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
123 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
125 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
126 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
127 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
128 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
130 int getAppIcon(const char *app_id, char **icon_path);
131 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
133 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
134 void setTextDomain(notification_h noti_h);
135 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
136 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
137 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
138 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
139 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
140 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
141 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
143 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
146 void createServiceHandle(app_control_h *svc_h);
147 void setServiceAppId(app_control_h svc_h, const char* app_id);
148 void setServiceUri(app_control_h svc_h, const char* uri);
149 void setServiceOperation(app_control_h svc_h, const char* operation);
150 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
151 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
152 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
153 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
155 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
156 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
157 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
158 void setNotiTime(notification_h noti_h, time_t time);
159 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
160 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
161 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
162 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
165 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
166 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
167 void MsgMgrSoundSetRepeatAlarm();
169 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
171 /*==================================================================================================
172 FUNCTION IMPLEMENTATION
173 ==================================================================================================*/
174 bool _is_valid_email(char *pAddress)
176 if (!pAddress || pAddress[0] == 0)
178 if (!strchr (pAddress, EMAIL_AT))
184 void MsgMgrInitReportNotiList()
188 if (msg_report_notification_list) {
189 MSG_MGR_DEBUG("Report Noti List is already inited");
193 msg_report_notification_list = NULL;
195 notification_h noti = NULL;
196 notification_list_h noti_list = NULL;
197 notification_list_h head_noti_list = NULL;
198 int noti_err = NOTIFICATION_ERROR_NONE;
199 app_control_h app_control = NULL;
201 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
202 if (noti_err != NOTIFICATION_ERROR_NONE) {
203 MSG_MGR_DEBUG("notification_get_list() is failed!!");
207 head_noti_list = noti_list;
209 while (noti_list != NULL) {
210 noti = notification_list_get_data(noti_list);
212 MSG_MGR_DEBUG("notification_list_get_data() failed!!");
216 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
217 memset(tempAddr, 0x00, sizeof(tempAddr));
219 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
220 if (noti_err != NOTIFICATION_ERROR_NONE) {
221 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
225 char *is_report_noti = NULL;
227 int ret = app_control_get_extra_data(app_control, "is_report_noti", &is_report_noti);
228 if (ret == APP_CONTROL_ERROR_NONE && is_report_noti != NULL && g_strcmp0(is_report_noti, "true") == 0) {
231 ret = app_control_get_extra_data(app_control, "address", &addr);
232 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
233 report_notification_s *info = new report_notification_s;
234 memset(info, 0x00, sizeof(report_notification_s));
236 notification_get_id(noti, NULL, &(info->priv_id));
237 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
239 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
240 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
247 if (is_report_noti) {
248 g_free(is_report_noti);
249 is_report_noti = NULL;
253 noti_list = notification_list_get_next(noti_list);
257 notification_free_list(head_noti_list);
263 void MsgMgrInitNoti()
268 bool bNotiSvcReady = false;
270 bNotiSvcReady = notification_is_service_ready();
272 if (bNotiSvcReady == true) {
273 MSG_MGR_DEBUG("Notification server is available");
274 MsgMgrInitReportNotiList();
276 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
277 notification_add_deferred_task(MsgInitNotiCb, NULL);
284 void MsgInitNotiCb(void *data)
286 MsgMgrInitReportNotiList();
299 bool bNotiSvcReady = false;
301 bNotiSvcReady = notification_is_service_ready();
303 if (bNotiSvcReady == true) {
304 MSG_MGR_DEBUG("Notification server is available");
305 #ifndef MSG_NOTI_INTEGRATION
306 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
308 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
310 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
311 #ifndef MSG_NOTI_INTEGRATION
312 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
314 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
315 delNotiInfo->sim_idx = -1;
317 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
319 notification_add_deferred_task(MsgRefreshNotiCb, NULL);
324 void MsgRefreshNotiCb(void *data)
326 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
337 void MsgMgrDeleteNotiCb(void *data)
340 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)data;
342 MsgMgrDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx);
352 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
356 notification_h noti_h = NULL;
358 MSG_MGR_NOTI_INFO_S noti_info = {0, };
360 noti_info.type = noti_type;
361 noti_info.active_noti_button_num = 1;
363 createActiveInfoData(¬i_info, msg_info);
365 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
367 setActiveNotification(noti_h, ¬i_info);
369 clearInfoData(noti_h, ¬i_info);
376 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
379 notification_h noti_h = NULL;
380 int bNotification = 1;
381 /* bool bReplyPopup = false; */
383 MSG_MGR_NOTI_INFO_S noti_info = {0, };
384 noti_info.type = noti_type;
385 noti_info.id = getPrivId(noti_info.type, -1);
387 err = getLatestMsgInfo(¬i_info, false);
390 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
391 goto __END_OF_REFRESH_NOTI;
394 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
395 err = MsgMgrInsertInstantMessage(noti_type);
398 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
399 goto __END_OF_REFRESH_NOTI;
403 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
404 MSG_MGR_DEBUG("vconf_get_bool is failed.");
407 if (bNotification == 0) {
408 MSG_MGR_DEBUG("Msg Alert notification is off.");
409 goto __END_OF_REFRESH_NOTI;
412 createInfoData(¬i_info, active_type);
414 noti_h = getHandle(¬i_info.id);
416 if (noti_h == NULL) {
417 MSG_MGR_DEBUG("Notification handle is NULL");
418 err = MSG_ERR_NULL_POINTER;
419 goto __END_OF_REFRESH_NOTI;
422 setNotification(noti_h, ¬i_info, bFeedback);
424 __END_OF_REFRESH_NOTI :
425 clearInfoData(noti_h, ¬i_info);
431 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
435 notification_h noti_h = NULL;
437 report_notification_s *info = new report_notification_s;
438 memset(info, 0x00, sizeof(report_notification_s));
440 MSG_MGR_NOTI_INFO_S noti_info = {0, };
441 noti_info.type = noti_type;
443 createInfoData(¬i_info, msg_info);
445 noti_h = getHandle(¬i_info.id);
447 if (noti_h == NULL) {
448 MSG_MGR_DEBUG("Notification handle is NULL");
450 goto __END_OF_ADD_REPORT_NOTI;
453 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT || noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
454 noti_info.applist &= ~NOTIFICATION_DISPLAY_APP_TICKER;
456 ret = MsgMgrInsertDeliveryReportInstantNotification(noti_type, noti_info.extra_data);
459 MSG_MGR_ERR(" MsgInsertInstantDeliveryReportNotification() err = [%d]", ret);
460 goto __END_OF_ADD_REPORT_NOTI;
464 addServiceExtraData(noti_info.svc_h, "is_report_noti", "true");
465 setNotification(noti_h, ¬i_info, true);
467 info->priv_id = noti_info.id;
468 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
469 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
470 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
472 __END_OF_ADD_REPORT_NOTI :
473 clearInfoData(noti_h, ¬i_info);
479 int MsgMgrDeleteReportNotification(const char *addr)
483 notification_h noti_h = NULL;
484 int bNotification = 1;
486 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
487 MSG_MGR_DEBUG("vconf_get_bool is failed.");
490 if (bNotification == 0) {
491 MSG_MGR_DEBUG("Msg Alert notification is off.");
495 char* normalAddr = NULL;
496 unsigned int list_length = g_list_length(msg_report_notification_list);
497 bool isDelete = false;
499 MSG_MGR_DEBUG("list length [%d]", list_length);
501 if (list_length > 0) {
502 GList *iter = g_list_first(msg_report_notification_list);
504 while (iter != NULL) {
506 report_notification_s *info = (report_notification_s*)(iter->data);
508 MSG_MGR_DEBUG("info is NULL!");
512 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
514 noti_h = notification_load(NULL, info->priv_id);
515 if (noti_h == NULL) {
516 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
519 normalAddr = msg_mgr_normalize_number(info->addressVal);
522 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
524 if (g_str_has_suffix(addr, normalAddr)) {
525 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
526 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
529 MSG_MGR_DEBUG("delete notification failed");
534 notification_free(noti_h);
538 iter = g_list_next(iter);
541 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
555 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
559 notification_h noti_h = NULL;
561 MSG_MGR_NOTI_INFO_S noti_info = {0, };
563 noti_info.type = noti_type;
565 createInfoData(¬i_info, msg_info);
567 /* check mwi or voicemail count is 0 then skip add notification */
568 if (noti_info.count == 0) {
569 MSG_MGR_DEBUG("Notification count is 0");
571 goto __END_OF_ADD_NOTI;
574 noti_h = getHandle(¬i_info.id);
576 if (noti_h == NULL) {
577 MSG_MGR_DEBUG("Notification handle is NULL");
579 goto __END_OF_ADD_NOTI;
582 setNotification(noti_h, ¬i_info, true);
585 clearInfoData(noti_h, ¬i_info);
591 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex)
593 int noti_err = NOTIFICATION_ERROR_NONE;
595 if (noti_type == MSG_MGR_NOTI_TYPE_ALL) {
596 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
597 } 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) {
600 notiId = getPrivId(noti_type, simIndex);
601 MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
604 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, notiId);
607 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
610 if (noti_err != NOTIFICATION_ERROR_NONE) {
611 MSG_MGR_DEBUG("Fail to notification_delete_all noti_err [%d]", noti_err);
614 updatePrivId(noti_type, 0, simIndex);
618 int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
620 bool bNotiSvcReady = false;
622 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S));
625 delNotiInfo->type = noti_type;
626 delNotiInfo->sim_idx = simIndex;
629 bNotiSvcReady = notification_is_service_ready();
631 if (bNotiSvcReady == true) {
632 MSG_MGR_DEBUG("Notification server is available");
633 MsgMgrDeleteNotiCb((void *)delNotiInfo);
635 MSG_MGR_DEBUG("Notification server is not available. Delete is defered");
636 notification_add_deferred_task(MsgMgrDeleteNotiCb, (void *)delNotiInfo);
642 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
648 #ifndef MSG_NOTI_INTEGRATION
649 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
652 #ifdef MSG_NOTI_INTEGRATION
653 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
655 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
657 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
659 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
661 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
663 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
666 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
668 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
672 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
674 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
680 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
684 int noti_err = NOTIFICATION_ERROR_NONE;
687 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
688 if (noti_err != NOTIFICATION_ERROR_NONE) {
689 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
693 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
694 if (noti_err != NOTIFICATION_ERROR_NONE) {
695 MSG_MGR_DEBUG("Fail to notification_set_led.");
698 /* set execute option and property */
699 switch (noti_info->type) {
700 case MSG_MGR_NOTI_TYPE_NORMAL: {
701 if (noti_info->count > 1) {
702 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
704 if (noti_info->svc_h) { /* overwrite bundle key "type" */
705 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
706 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
708 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
711 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
714 case MSG_MGR_NOTI_TYPE_CB:
715 case MSG_MGR_NOTI_TYPE_SIM: {
716 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
717 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
720 case MSG_MGR_NOTI_TYPE_FAILED: {
721 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
722 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
725 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
726 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
729 case MSG_MGR_NOTI_TYPE_VOICE_1:
730 case MSG_MGR_NOTI_TYPE_VOICE_2:
731 case MSG_MGR_NOTI_TYPE_MWI:
732 case MSG_MGR_NOTI_TYPE_CLASS0:
733 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
734 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
735 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
736 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
740 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
745 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
746 if (noti_err != NOTIFICATION_ERROR_NONE) {
747 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
751 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
752 if (noti_err != NOTIFICATION_ERROR_NONE) {
753 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
760 void setTextDomain(notification_h noti_h)
764 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
769 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
773 char unreadMsgCntStr[10] = {0};
776 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
777 MSG_MGR_DEBUG("vconf_get_bool is failed.");
780 /* set title and content */
781 switch (noti_info->type) {
782 #ifdef MSG_NOTI_INTEGRATION
783 case MSG_MGR_NOTI_TYPE_NORMAL:
784 case MSG_MGR_NOTI_TYPE_CB:
785 case MSG_MGR_NOTI_TYPE_SIM: {
786 if (noti_info->count > 1) {
787 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
788 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
789 setNotiTime(noti_h, noti_info->time);
791 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
792 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
796 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
797 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
799 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
800 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
802 setNotiTime(noti_h, noti_info->time);
807 case MSG_MGR_NOTI_TYPE_NORMAL: {
808 if (noti_info->count > 1) {
809 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
810 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
811 setNotiTime(noti_h, noti_info->time);
813 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
814 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
817 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
818 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
820 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
821 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
823 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
824 setNotiTime(noti_h, noti_info->time);
828 case MSG_MGR_NOTI_TYPE_CB: {
829 if (noti_info->count > 1) {
830 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
831 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
832 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
833 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
834 setNotiTime(noti_h, noti_info->time);
837 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
838 setNotiTime(noti_h, noti_info->time);
841 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
842 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
844 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
845 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
850 case MSG_MGR_NOTI_TYPE_SIM: {
851 if (noti_info->count > 1) {
852 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
853 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
854 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
856 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
857 setNotiTime(noti_h, noti_info->time);
859 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
860 setNotiTime(noti_h, noti_info->time);
863 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
864 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
866 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
867 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
873 case MSG_MGR_NOTI_TYPE_FAILED: {
874 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
875 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
876 if (noti_info->count > 1) {
877 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
878 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
880 setNotiTime(noti_h, noti_info->time);
883 case MSG_MGR_NOTI_TYPE_VOICE_1:
884 case MSG_MGR_NOTI_TYPE_VOICE_2: {
885 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
886 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
887 setNotiTime(noti_h, noti_info->time);
889 if (noti_info->count == 1) {
890 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
891 } else if (noti_info->count > 1) {
892 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
893 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
895 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
899 case MSG_MGR_NOTI_TYPE_MWI: {
900 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
901 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
902 setNotiTime(noti_h, noti_info->time);
905 case MSG_MGR_NOTI_TYPE_CLASS0: {
906 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
907 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
908 setNotiTime(noti_h, noti_info->time);
911 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
912 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
913 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
915 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
916 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
917 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
918 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
920 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
923 setNotiTime(noti_h, noti_info->time);
926 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
927 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
928 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
930 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
931 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
932 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
934 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
935 /* notification free */
938 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
941 setNotiTime(noti_h, noti_info->time);
944 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
945 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
946 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
948 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) {
949 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
950 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) {
951 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", MESSAGE_REJECTED);
952 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) {
953 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
954 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED || noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE
955 || noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED || noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE
956 || noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) {
957 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Recipient not available", RECIPIENT_NOT_AVAILABLE);
959 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
962 setNotiTime(noti_h, noti_info->time);
965 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
966 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
967 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
971 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
978 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
982 switch (noti_info->type) {
983 #ifdef MSG_NOTI_INTEGRATION
984 case MSG_MGR_NOTI_TYPE_NORMAL:
985 case MSG_MGR_NOTI_TYPE_CB:
986 case MSG_MGR_NOTI_TYPE_SIM: {
987 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
988 if (noti_info->count > 1 && noti_info->senderCount > 1) {
989 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
990 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
991 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
993 if (noti_info->active_subtype == MSG_CB_SMS) {
994 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
995 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
996 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
997 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
998 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
999 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
1000 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1002 if (noti_info->imagePath[0] != '\0') {
1003 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
1004 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1006 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1007 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1010 char *msg_icon_path = NULL;
1011 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1012 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1013 g_free(msg_icon_path);
1015 MSG_MGR_ERR("fail to get message-app icon");
1022 case MSG_MGR_NOTI_TYPE_NORMAL: {
1023 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1024 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
1026 if (noti_info->count > 1) {
1027 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1029 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
1033 case MSG_MGR_NOTI_TYPE_CB: {
1034 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1035 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1038 case MSG_MGR_NOTI_TYPE_SIM: {
1039 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1040 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1044 case MSG_MGR_NOTI_TYPE_FAILED: {
1045 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1046 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_FAILED_STATUS_ICON);
1049 case MSG_MGR_NOTI_TYPE_VOICE_1:
1050 case MSG_MGR_NOTI_TYPE_VOICE_2:
1051 case MSG_MGR_NOTI_TYPE_MWI: {
1052 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1053 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1056 case MSG_MGR_NOTI_TYPE_CLASS0:
1057 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1059 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1060 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1061 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1063 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1064 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1065 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1067 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1068 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1069 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1071 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1072 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1073 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1076 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1083 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1087 int noti_err = NOTIFICATION_ERROR_NONE;
1090 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1091 if (noti_err != NOTIFICATION_ERROR_NONE) {
1092 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1096 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1097 if (noti_err != NOTIFICATION_ERROR_NONE) {
1098 MSG_MGR_DEBUG("Fail to notification_set_led.");
1101 /* set execute option and property */
1102 switch (noti_info->type) {
1103 case MSG_MGR_NOTI_TYPE_NORMAL:
1104 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1105 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
1107 case MSG_MGR_NOTI_TYPE_CLASS0:
1108 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1111 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
1116 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1117 if (noti_err != NOTIFICATION_ERROR_NONE) {
1118 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1122 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
1123 if (noti_err != NOTIFICATION_ERROR_NONE) {
1124 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
1131 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1135 switch (noti_info->type) {
1136 case MSG_MGR_NOTI_TYPE_NORMAL:
1137 case MSG_MGR_NOTI_TYPE_SIM:
1138 case MSG_MGR_NOTI_TYPE_CB: {
1139 if (noti_info->active_subject[0] == '\0') {
1140 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1141 if (noti_info->active_text[0] != '\0') {
1142 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1144 if (noti_info->active_media_cnt > 1) {
1145 char attach_string[20] = {0,};
1146 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1147 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
1148 } else if (noti_info->active_media_cnt == 1) {
1149 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
1153 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1154 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1155 if (noti_info->active_text[0] != '\0') {
1156 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1158 if (noti_info->active_media_cnt > 1) {
1159 char attach_string[20] = {0,};
1160 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1161 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
1162 } else if (noti_info->active_media_cnt == 1) {
1163 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
1169 case MSG_MGR_NOTI_TYPE_CLASS0: {
1170 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1171 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1175 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1183 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1187 switch (noti_info->type) {
1188 case MSG_MGR_NOTI_TYPE_NORMAL:
1189 case MSG_MGR_NOTI_TYPE_SIM: {
1190 switch (noti_info->active_subtype) {
1192 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1194 case MSG_WAP_SI_SMS:
1195 case MSG_WAP_SL_SMS:
1196 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1199 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1202 if (noti_info->imagePath[0] != '\0')
1203 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1205 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1207 char *msg_icon_path = NULL;
1208 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1209 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1210 g_free(msg_icon_path);
1212 MSG_MGR_ERR("fail to get message-app icon");
1220 case MSG_MGR_NOTI_TYPE_CB: {
1221 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1224 case MSG_MGR_NOTI_TYPE_CLASS0:
1225 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1228 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1236 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result)
1240 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
1241 notification_set_pkgname(noti, MSG_DEFAULT_APP_ID);
1243 setTextDomain(noti);
1244 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
1245 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVER_REPORT_STATUS_ICON);
1247 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT) {
1248 if (result == MSG_NETWORK_DELIVER_SUCCESS) {
1249 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1250 } else if (result == MSG_NETWORK_DELIVER_EXPIRED) {
1251 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1252 } else if (result == MSG_NETWORK_DELIVER_PENDING) {
1253 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1255 MSG_MGR_ERR("unexpected result! [%d]", result);
1256 goto _END_OF_INSTANT_DELIVERY_REPORT_NOTI;
1258 } else if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
1259 if (result == MSG_DELIVERY_REPORT_EXPIRED)
1260 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1261 else if (result== MSG_DELIVERY_REPORT_REJECTED)
1262 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message rejected by recipient.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_REJECTED);
1263 else if (result == MSG_DELIVERY_REPORT_DEFERRED)
1264 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1265 else if (result == MSG_DELIVERY_REPORT_UNRECOGNISED || result == MSG_DELIVERY_REPORT_INDETERMINATE ||
1266 result == MSG_DELIVERY_REPORT_FORWARDED || result == MSG_DELIVERY_REPORT_UNREACHABLE ||
1267 result == MSG_DELIVERY_REPORT_ERROR)
1268 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Recipient not available.", UNABLE_TO_DELIVER_MESSAGE_RECIPIENT_NOT_AVAILABLE);
1270 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1273 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
1274 MSG_MGR_ERR("Fail to notification_set_display_applist");
1276 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
1277 MSG_MGR_ERR("Fail to notification_post");
1279 _END_OF_INSTANT_DELIVERY_REPORT_NOTI:
1281 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
1282 MSG_MGR_ERR("Fail to notification_delete");
1285 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
1286 MSG_MGR_ERR("Fail to notification_free");
1295 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1299 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1300 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1302 if (addressVal != NULL) {
1303 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1304 /* Get Contact Info */
1305 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1306 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1309 MSG_MGR_DEBUG("addressVal is NULL.");
1312 char *msg_tone_file_path = NULL;
1314 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1316 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1318 bool bPlaySound = false;
1319 bool bPlayVibration = false;
1320 bool bOnCall = false;
1322 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1325 if (msg_tone_file_path) {
1326 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1329 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1330 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1332 int ringtoneType = tmpVal;
1333 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1334 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1336 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1339 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1342 if (bPlayVibration) {
1343 if (contactInfo.vibrationPath[0] == '\0')
1344 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1346 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1348 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1351 if (msg_tone_file_path)
1352 delete [] msg_tone_file_path;
1358 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1362 int noti_err = NOTIFICATION_ERROR_NONE;
1364 if (noti_info->active_noti_button_num > 1) {
1365 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1366 if (noti_info->active_noti_svc_h[0]) {
1367 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1368 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1370 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1372 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1373 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1374 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1375 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1378 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1379 if (noti_info->active_noti_svc_h[1]) {
1380 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1382 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1383 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1384 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1386 char slot_id[5] = {0, };
1387 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1388 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1392 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1393 if (noti_info->active_noti_svc_h[2]) {
1394 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1396 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1397 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1398 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1399 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1401 char slot_id[5] = {0, };
1402 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1403 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1406 if (noti_info->active_noti_button_num > 1) {
1407 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1408 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1409 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1411 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1412 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1413 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1415 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1417 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1420 setActiveProperty(noti_h, noti_info);
1422 setTextDomain(noti_h);
1424 setActiveText(noti_h, noti_info);
1426 setActiveIcon(noti_h, noti_info);
1428 noti_err = notification_post(noti_h);
1429 if (noti_err != NOTIFICATION_ERROR_NONE) {
1430 MSG_MGR_DEBUG("Fail to notification_post");
1437 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1441 int noti_err = NOTIFICATION_ERROR_NONE;
1443 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1445 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1446 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1447 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1449 setActiveNotification(active_noti_h, noti_info);
1451 notification_free(active_noti_h);
1452 active_noti_h = NULL;
1455 setProperty(noti_h, noti_info);
1457 setTextDomain(noti_h);
1459 setText(noti_h, noti_info);
1461 setIcon(noti_h, noti_info);
1464 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1465 setSoundAndVibration(noti_h, noti_info->number, true);
1467 setSoundAndVibration(noti_h, noti_info->number, false);
1470 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1471 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1474 if (noti_info->id > 0) {
1475 MSG_MGR_DEBUG("Notification update");
1476 noti_err = notification_update(noti_h);
1477 if (noti_err != NOTIFICATION_ERROR_NONE) {
1478 MSG_MGR_DEBUG("Fail to notification_update");
1481 MSG_MGR_DEBUG("Notification insert");
1482 noti_err = notification_insert(noti_h, ¬i_info->id);
1483 if (noti_err != NOTIFICATION_ERROR_NONE) {
1484 MSG_MGR_DEBUG("Fail to notification_insert");
1487 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1494 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1499 MSG_MGR_DEBUG("msg_info is NULL");
1503 noti_info->msg_id = msg_info->msgId;
1504 noti_info->sim_idx = msg_info->sim_idx;
1506 switch (noti_info->type) {
1507 case MSG_MGR_NOTI_TYPE_NORMAL: {
1508 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1509 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1516 case MSG_MGR_NOTI_TYPE_CLASS0: {
1517 if (msg_info->displayName[0] == '\0')
1518 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1520 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1522 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1526 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1534 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1539 notification_free(noti_h);
1543 if (noti_info->svc_h) {
1544 app_control_destroy(noti_info->svc_h);
1545 noti_info->svc_h = NULL;
1548 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1549 if (noti_info->active_noti_svc_h[i]) {
1550 app_control_destroy(noti_info->active_noti_svc_h[i]);
1551 noti_info->active_noti_svc_h[i] = NULL;
1559 int getAppIcon(const char *app_id, char **icon_path)
1563 package_info_h pkg_info_h = NULL;
1564 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1567 if (app_id == NULL) {
1568 MSG_MGR_ERR("app id is NULL");
1570 goto END_OF_GET_APP_ICON;
1573 pkg_err = package_info_create(app_id, &pkg_info_h);
1574 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1575 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1577 goto END_OF_GET_APP_ICON;
1580 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1581 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1582 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1585 if (icon_path == NULL) {
1586 MSG_MGR_WARN("icon path is NULL");
1591 END_OF_GET_APP_ICON:
1593 pkg_err = package_info_destroy(pkg_info_h);
1594 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1595 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1607 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1612 msg_error_t msg_err = MSG_SUCCESS;
1613 char **db_res = NULL;
1614 int row_cnt = 0, col_cnt = 0;
1616 switch (noti_info->type) {
1617 case MSG_MGR_NOTI_TYPE_NORMAL:
1618 #ifdef MSG_NOTI_INTEGRATION
1619 case MSG_MGR_NOTI_TYPE_CB:
1620 case MSG_MGR_NOTI_TYPE_SIM:
1623 int smsUnreadCnt = 0;
1624 int mmsUnreadCnt = 0;
1626 char sqlQuery[MAX_QUERY_LEN +1];
1627 unsigned char mainType;
1628 unsigned char subType;
1629 int msgSize, attachmentCnt;
1631 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1632 #ifdef MSG_NOTI_INTEGRATION
1633 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1637 "WHERE A.CONV_ID=B.CONV_ID "
1638 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1639 "AND B.STORAGE_ID = %d "
1640 "GROUP BY A.ADDRESS_VAL "
1641 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1642 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1643 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1646 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1650 "WHERE A.CONV_ID=B.CONV_ID "
1651 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1652 "AND B.STORAGE_ID = %d "
1653 "GROUP BY A.ADDRESS_VAL "
1654 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1655 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1659 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1661 row_cnt = 0, col_cnt = 0;
1662 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1663 if (msg_err != MSG_SUCCESS) {
1664 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1668 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1669 int normalAddCnt = 0;
1670 int index = col_cnt;
1672 for (int i = 1; i <= row_cnt; i++) {
1673 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1675 char *address = db_res[index++];
1678 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1679 if (_is_valid_email(address)) {
1680 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1682 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1685 subType = atoi(db_res[index++]);
1687 MSG_MGR_CONTACT_INFO_S tmpContact;
1688 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1690 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1693 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1696 if (normalAddCnt > 1) {
1697 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1700 if (tmpContact.firstName[0] != '\0') {
1701 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1702 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1703 char *senderStr = NULL;
1704 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1705 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1712 noti_info->active_noti_button_num = 1;
1715 char *senderStr = NULL;
1716 if (subType == MSG_CB_SMS) {
1717 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1718 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1719 noti_info->active_noti_button_num = 1;
1720 } else if (subType == MSG_SYNCML_CP) {
1721 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1722 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1723 noti_info->active_noti_button_num = 1;
1724 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1725 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1726 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1727 noti_info->active_noti_button_num = 1;
1729 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1739 noti_info->active_subtype = subType;
1740 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1741 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1745 noti_info->senderCount = normalAddCnt;
1746 msg_db_free(msg_handle, db_res);
1748 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1750 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1752 #ifdef MSG_NOTI_INTEGRATION
1753 snprintf(sqlQuery, sizeof(sqlQuery),
1757 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
1758 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
1761 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1762 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1763 "(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), "
1764 "B.ATTACHMENT_COUNT "
1766 "WHERE A.CONV_ID=B.CONV_ID "
1767 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1768 "AND B.STORAGE_ID = %d "
1769 "ORDER BY B.DISPLAY_TIME DESC;",
1772 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1773 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1774 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1777 snprintf(sqlQuery, sizeof(sqlQuery),
1784 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1785 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1787 "WHERE A.CONV_ID=B.CONV_ID "
1788 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1789 "AND B.STORAGE_ID = %d "
1790 "ORDER BY B.DISPLAY_TIME DESC;",
1793 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1797 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1799 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1800 if (msg_err != MSG_SUCCESS) {
1801 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1806 smsUnreadCnt = atoi(db_res[col_cnt+7]);
1807 mmsUnreadCnt = atoi(db_res[col_cnt+8]);
1808 msgSize = atoi(db_res[col_cnt+9]);
1809 attachmentCnt = atoi(db_res[col_cnt+10]);
1811 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1813 if (noti_info->count > 0) {
1814 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1816 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1818 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1820 noti_info->conv_id = atoi(db_res[col_cnt+6]);
1822 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1824 if (mainType == MSG_MMS_TYPE) {
1825 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1826 if (noti_info->text[0] == '\0') {
1827 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1828 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1832 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1833 if (prefix_subject) {
1834 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1835 g_free(prefix_subject);
1837 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1841 int kb_msg_size = msgSize / 1024;
1842 if (kb_msg_size == 0 && msgSize > 0)
1844 else if (msgSize % 1024 >= 512)
1847 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1848 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1850 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1852 g_free(msg_size_string);
1853 g_free(msg_size_unit_kb);
1856 noti_info->active_media_cnt = attachmentCnt;
1859 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1862 if (noti_info->active_text[0] == '\0')
1863 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1865 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1867 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1868 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1869 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1871 if (!isForInstantMessage) {
1872 if (noti_info->id > 0 && noti_info->count == 1) {
1873 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1874 if (noti_err != NOTIFICATION_ERROR_NONE) {
1875 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1879 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1880 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1883 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1884 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1885 MsgMgrInsertBadge(noti_info->count);
1886 MsgMgrSoundSetRepeatAlarm();
1889 MSG_MGR_DEBUG("No unread message.");
1890 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1892 msg_db_free(msg_handle, db_res);
1894 if (!isForInstantMessage) {
1895 /* No unread message. */
1896 if (noti_info->id > 0) {
1897 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1898 if (noti_err != NOTIFICATION_ERROR_NONE) {
1899 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1905 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1906 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1908 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1909 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1910 MsgMgrInsertBadge(0);
1911 MsgMgrSoundSetRepeatAlarm();
1917 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1918 msg_db_free(msg_handle, db_res);
1922 msg_db_free(msg_handle, db_res);
1926 #ifndef MSG_NOTI_INTEGRATION
1927 case MSG_MGR_NOTI_TYPE_CB: {
1928 char sqlQuery[MAX_QUERY_LEN+1];
1929 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1931 snprintf(sqlQuery, sizeof(sqlQuery),
1937 "WHERE A.CONV_ID=B.CONV_ID "
1938 "AND B.READ_STATUS=0 "
1939 "AND B.FOLDER_ID=%d "
1940 "AND B.STORAGE_ID = %d "
1941 "ORDER BY B.DISPLAY_TIME DESC;",
1942 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1946 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1947 return MSG_ERR_DB_PREPARE;
1949 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1950 MSG_ADDRESS_INFO_S addrInfo;
1951 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1953 if (dbhandler->columnText(0) != NULL)
1954 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1956 MSG_CONTACT_INFO_S tmpContact;
1957 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1959 MsgGetContactInfo(&addrInfo, &tmpContact);
1961 if (tmpContact.firstName[0] != '\0') {
1962 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1963 } else if (addrInfo.addressVal[0] == '\0') {
1964 char *senderStr = NULL;
1965 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1966 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1972 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1975 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1977 noti_info->time = (time_t)dbhandler->columnInt(1);
1979 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1981 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1983 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1985 MSG_MGR_DEBUG("No unread CB message.");
1986 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1988 dbhandler->finalizeQuery();
1990 if (!isForInstantMessage) {
1991 /* No unread message. */
1992 if (noti_info->id > 0) {
1993 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1994 if (noti_err != NOTIFICATION_ERROR_NONE) {
1995 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2001 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2002 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
2004 return MSG_ERR_DB_STEP;
2007 dbhandler->finalizeQuery();
2009 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
2010 MSG_MGR_DEBUG("getTable is failed");
2011 dbhandler->freeTable();
2012 return MSG_ERR_DB_GETTABLE;
2015 dbhandler->freeTable();
2016 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
2019 case MSG_MGR_NOTI_TYPE_SIM: {
2020 char sqlQuery[MAX_QUERY_LEN+1];
2021 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2023 snprintf(sqlQuery, sizeof(sqlQuery),
2028 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
2030 "WHERE A.CONV_ID=B.CONV_ID "
2031 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2032 "AND B.STORAGE_ID = %d "
2033 "ORDER BY B.DISPLAY_TIME DESC;",
2035 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2039 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2041 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
2042 return MSG_ERR_DB_PREPARE;
2044 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
2045 noti_info->count = dbhandler->columnInt(4);
2047 if (noti_info->count > 0) {
2048 MSG_ADDRESS_INFO_S addrInfo;
2049 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
2051 if (dbhandler->columnText(0) != NULL)
2052 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2054 MSG_CONTACT_INFO_S tmpContact;
2055 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2057 MsgGetContactInfo(&addrInfo, &tmpContact);
2059 if (tmpContact.firstName[0] != '\0') {
2060 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2061 } else if (addrInfo.addressVal[0] == '\0') {
2062 char *senderStr = NULL;
2063 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2064 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2070 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2073 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2075 noti_info->time = (time_t)dbhandler->columnInt(1);
2077 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2079 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2081 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
2083 MSG_MGR_DEBUG("No unread SIM message.");
2084 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2086 dbhandler->finalizeQuery();
2088 if (!isForInstantMessage) {
2089 /* No unread message. */
2090 if (noti_info->id > 0) {
2091 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2092 if (noti_err != NOTIFICATION_ERROR_NONE) {
2093 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2099 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2100 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2103 return MSG_ERR_DB_STEP;
2106 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2107 dbhandler->finalizeQuery();
2108 return MSG_ERR_DB_STEP;
2111 dbhandler->finalizeQuery();
2115 case MSG_MGR_NOTI_TYPE_FAILED: {
2116 char sqlQuery[MAX_QUERY_LEN+1];
2117 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2119 snprintf(sqlQuery, sizeof(sqlQuery),
2126 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2128 "WHERE A.CONV_ID=B.CONV_ID "
2129 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2130 "AND B.STORAGE_ID = %d "
2131 "ORDER BY B.DISPLAY_TIME DESC;",
2132 MSG_NETWORK_SEND_FAIL,
2133 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2137 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2139 row_cnt = 0, col_cnt = 0;
2140 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2141 if (msg_err != MSG_SUCCESS) {
2142 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2147 noti_info->count = atoi(db_res[col_cnt+6]);
2149 if (noti_info->count > 0) {
2150 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2152 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2154 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2156 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2158 if (tmpContact.firstName[0] != '\0') {
2159 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2160 } else if (addrInfo.addressVal[0] == '\0') {
2161 char *senderStr = NULL;
2162 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2163 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2169 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2172 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2174 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2176 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2178 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2180 if (mainType == MSG_TYPE_MMS)
2181 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2183 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2185 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2187 if (!isForInstantMessage) {
2188 if (noti_info->id > 0 && noti_info->count == 1) {
2189 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2190 if (noti_err != NOTIFICATION_ERROR_NONE) {
2191 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2194 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2195 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2199 MSG_MGR_DEBUG("No sent failed message.");
2200 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2202 msg_db_free(msg_handle, db_res);
2204 if (!isForInstantMessage) {
2205 /* No unread message. */
2206 if (noti_info->id > 0) {
2207 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2208 if (noti_err != NOTIFICATION_ERROR_NONE) {
2209 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2215 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2216 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2222 msg_db_free(msg_handle, db_res);
2226 msg_db_free(msg_handle, db_res);
2229 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2232 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2242 notification_h getHandle(int *noti_id)
2244 notification_h noti_h = NULL;
2247 MSG_MGR_DEBUG("Notification load");
2248 noti_h = notification_load(NULL, *noti_id);
2250 MSG_MGR_DEBUG("notification_load is failed.");
2253 if (noti_h == NULL) {
2254 MSG_MGR_DEBUG("Notification create");
2255 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2256 if (noti_h == NULL) {
2257 MSG_MGR_DEBUG("notification_create is failed.");
2268 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2274 switch (noti_type) {
2275 #ifdef MSG_NOTI_INTEGRATION
2276 case MSG_MGR_NOTI_TYPE_NORMAL:
2277 case MSG_MGR_NOTI_TYPE_SIM:
2278 case MSG_MGR_NOTI_TYPE_CB:
2279 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2282 case MSG_MGR_NOTI_TYPE_NORMAL:
2283 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2285 case MSG_MGR_NOTI_TYPE_SIM:
2286 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2288 case MSG_MGR_NOTI_TYPE_CB:
2289 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2292 case MSG_MGR_NOTI_TYPE_FAILED:
2293 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2295 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2296 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2297 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2298 vconf_get_int(keyName, ¬i_id);
2301 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2302 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2303 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2304 vconf_get_int(keyName, ¬i_id);
2307 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2308 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2311 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2315 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2323 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2329 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2331 switch (noti_type) {
2332 #ifdef MSG_NOTI_INTEGRATION
2333 case MSG_MGR_NOTI_TYPE_NORMAL:
2334 case MSG_MGR_NOTI_TYPE_SIM:
2335 case MSG_MGR_NOTI_TYPE_CB:
2336 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2339 case MSG_MGR_NOTI_TYPE_NORMAL:
2340 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2342 case MSG_MGR_NOTI_TYPE_SIM:
2343 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2345 case MSG_MGR_NOTI_TYPE_CB:
2346 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2349 case MSG_MGR_NOTI_TYPE_FAILED:
2350 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2352 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2353 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2354 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2355 err = vconf_set_int(keyName, noti_id);
2358 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2359 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2360 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2361 err = vconf_set_int(keyName, noti_id);
2364 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2365 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2368 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2373 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2379 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2384 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2385 noti_info->msg_id = msg_info->msgId;
2387 MSG_MGR_DEBUG("msg_info is NULL");
2391 noti_info->sim_idx = msg_info->sim_idx;
2393 createServiceHandle(¬i_info->svc_h);
2394 char keyName[MAX_VCONFKEY_NAME_LEN];
2396 switch (noti_info->type) {
2397 case MSG_MGR_NOTI_TYPE_VOICE_1:
2398 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2399 memset(keyName, 0x00, sizeof(keyName));
2400 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2401 vconf_get_int(keyName, ¬i_info->count);
2402 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2403 noti_info->time = msg_info->displayTime;
2405 memset(keyName, 0x00, sizeof(keyName));
2406 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2407 char *voiceNumber = vconf_get_str(keyName);
2408 memset(keyName, 0x00, sizeof(keyName));
2409 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2410 char *voiceAlphaId = vconf_get_str(keyName);
2411 char *dialNumber = NULL;
2413 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2415 if (voiceNumber && strlen(voiceNumber))
2416 dialNumber = voiceNumber;
2418 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2419 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2420 } else if (dialNumber && strlen(dialNumber) > 0) {
2421 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2424 if (dialNumber && strlen(dialNumber) > 0)
2425 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2427 if (noti_info->svc_h) {
2428 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2429 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2431 char slot_id[5] = {0, };
2432 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2433 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2436 if (voiceNumber) g_free(voiceNumber);
2437 if (voiceAlphaId) g_free(voiceAlphaId);
2440 case MSG_MGR_NOTI_TYPE_MWI:
2441 case MSG_MGR_NOTI_TYPE_CLASS0: {
2442 noti_info->count = 1;
2443 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2444 noti_info->time = msg_info->displayTime;
2446 if (msg_info->displayName[0] == '\0')
2447 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2449 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2451 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2453 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2455 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2456 if (noti_info->svc_h) {
2457 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2458 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2460 char slot_id[5] = {0, };
2461 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2462 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2466 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2467 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2468 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2472 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2473 noti_info->count = 1;
2474 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2475 noti_info->time = msg_info->displayTime;
2476 noti_info->extra_data = msg_info->networkStatus;
2478 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2479 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2480 if (msg_info->addressVal[0] != '\0') {
2481 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2482 if (_is_valid_email(msg_info->addressVal)) {
2483 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2485 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2489 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2490 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2493 if (contactInfo.firstName[0] == '\0')
2494 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2496 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2498 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2500 if (noti_info->msg_id > 0) {
2501 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2502 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2503 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2504 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2508 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2509 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2510 noti_info->count = 1;
2511 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2512 noti_info->time = msg_info->displayTime;
2514 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2515 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2516 if (msg_info->addressVal[0] != '\0') {
2517 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2518 if (_is_valid_email(msg_info->addressVal)) {
2519 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2521 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2525 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2526 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2528 if (contactInfo.firstName[0] == '\0')
2529 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2531 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2533 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2535 char sqlQuery[MAX_QUERY_LEN+1];
2536 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2538 int report_status_type;
2539 int report_status_value;
2541 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2542 report_status_type = MSG_REPORT_TYPE_READ;
2544 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2547 snprintf(sqlQuery, sizeof(sqlQuery),
2550 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE \"%%%s\";",
2551 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2553 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2555 char **db_res = NULL;
2556 int row_cnt = 0, col_cnt = 0;
2558 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2559 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2560 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2564 report_status_value = atoi(db_res[col_cnt]);
2566 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2568 msg_err = msg_db_free(msg_handle, db_res);
2569 if (msg_err != MSG_SUCCESS) {
2570 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2574 if (noti_info->msg_id > 0) {
2575 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2576 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2577 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2578 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2581 noti_info->extra_data = (unsigned char)report_status_value;
2585 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2589 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2594 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2598 createServiceHandle(¬i_info->svc_h);
2600 switch (noti_info->type) {
2601 case MSG_MGR_NOTI_TYPE_NORMAL: {
2602 if (noti_info->count > 1) {
2603 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2605 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2608 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2609 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2610 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2611 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2613 if (noti_info->active_noti_button_num == 0)
2614 noti_info->active_noti_button_num = 3;
2616 int activated_conv_id = -1;
2617 vconf_get_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, &activated_conv_id);
2619 if (activated_conv_id == -1) {
2620 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2621 } else if (activated_conv_id == 0) {
2622 noti_info->active_noti_button_num = 0;
2623 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2624 } else if (activated_conv_id > 0){
2625 noti_info->active_noti_button_num = 0;
2627 if (activated_conv_id != noti_info->conv_id)
2628 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2630 MSG_MGR_WARN("No adding Notification : activated conv id [%d] / notification conv id [%d]", activated_conv_id, noti_info->conv_id);
2635 case MSG_MGR_NOTI_TYPE_CB: {
2636 if (noti_info->count > 1) {
2637 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2639 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2642 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2643 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2644 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2646 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2647 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2649 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2651 noti_info->active_noti_button_num = 1;
2654 case MSG_MGR_NOTI_TYPE_SIM: {
2655 if (noti_info->count > 1) {
2656 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2658 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2661 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2662 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2663 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2665 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2666 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2668 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2670 if (noti_info->active_noti_button_num == 0)
2671 noti_info->active_noti_button_num = 3;
2674 case MSG_MGR_NOTI_TYPE_FAILED: {
2675 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2677 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2678 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2679 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2681 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2684 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2685 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2687 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2688 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2690 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2697 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2698 noti_info->active_noti_button_num = 0;
2704 void createServiceHandle(app_control_h *svc_h)
2706 int svc_err = APP_CONTROL_ERROR_NONE;
2708 svc_err = app_control_create(svc_h);
2710 if (svc_err != APP_CONTROL_ERROR_NONE)
2711 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2715 void setServiceAppId(app_control_h svc_h, const char* app_id)
2717 int svc_err = APP_CONTROL_ERROR_NONE;
2719 svc_err = app_control_set_app_id(svc_h, app_id);
2721 if (svc_err != APP_CONTROL_ERROR_NONE)
2722 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2726 void setServiceUri(app_control_h svc_h, const char* uri)
2728 int svc_err = APP_CONTROL_ERROR_NONE;
2730 svc_err = app_control_set_uri(svc_h, uri);
2732 if (svc_err != APP_CONTROL_ERROR_NONE)
2733 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2737 void setServiceOperation(app_control_h svc_h, const char* operation)
2739 int svc_err = APP_CONTROL_ERROR_NONE;
2741 svc_err = app_control_set_operation(svc_h, operation);
2743 if (svc_err != APP_CONTROL_ERROR_NONE)
2744 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2748 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2750 int svc_err = APP_CONTROL_ERROR_NONE;
2752 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2754 if (svc_err != APP_CONTROL_ERROR_NONE)
2755 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2759 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2761 int svc_err = APP_CONTROL_ERROR_NONE;
2764 memset(&tempId, 0x00, sizeof(tempId));
2765 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2767 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2769 if (svc_err != APP_CONTROL_ERROR_NONE)
2770 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2774 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2776 int svc_err = APP_CONTROL_ERROR_NONE;
2778 svc_err = app_control_set_app_id(svc_h, pkg_name);
2780 if (svc_err != APP_CONTROL_ERROR_NONE)
2781 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2785 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2787 int svc_err = APP_CONTROL_ERROR_NONE;
2789 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2791 if (svc_err != APP_CONTROL_ERROR_NONE)
2792 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2796 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2798 int noti_err = NOTIFICATION_ERROR_NONE;
2800 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2801 if (noti_err != NOTIFICATION_ERROR_NONE)
2802 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2806 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2808 int noti_err = NOTIFICATION_ERROR_NONE;
2810 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2812 if (noti_err != NOTIFICATION_ERROR_NONE)
2813 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2817 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2819 int noti_err = NOTIFICATION_ERROR_NONE;
2821 noti_err = notification_set_time_to_text(noti_h, type, time);
2823 if (noti_err != NOTIFICATION_ERROR_NONE)
2824 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2828 void setNotiTime(notification_h noti_h, time_t time)
2830 int noti_err = NOTIFICATION_ERROR_NONE;
2832 noti_err = notification_set_time(noti_h, time);
2834 if (noti_err != NOTIFICATION_ERROR_NONE)
2835 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2840 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2842 int noti_err = NOTIFICATION_ERROR_NONE;
2844 noti_err = notification_set_image(noti_h, type, image_path);
2846 if (noti_err != NOTIFICATION_ERROR_NONE)
2847 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2851 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2853 int noti_err = NOTIFICATION_ERROR_NONE;
2855 noti_err = notification_set_sound(noti_h, type, path);
2857 if (noti_err != NOTIFICATION_ERROR_NONE)
2858 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2862 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2864 int noti_err = NOTIFICATION_ERROR_NONE;
2866 noti_err = notification_set_vibration(noti_h, type, path);
2868 if (noti_err != NOTIFICATION_ERROR_NONE)
2869 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2873 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2875 int noti_err = NOTIFICATION_ERROR_NONE;
2877 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2879 if (noti_err != NOTIFICATION_ERROR_NONE)
2880 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2884 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2888 char *notiMsg = NULL;
2890 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2892 switch (noti_type) {
2893 case MSG_MGR_NOTI_TYPE_NORMAL:
2894 case MSG_MGR_NOTI_TYPE_SIM:
2895 case MSG_MGR_NOTI_TYPE_CB: {
2896 MSG_MGR_NOTI_INFO_S noti_info;
2897 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2899 noti_info.type = noti_type;
2900 int err = getLatestMsgInfo(¬i_info, true);
2903 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2904 if (noti_info.count == 1) {
2905 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2906 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2907 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2908 } else if (noti_info.count > 1) {
2909 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2911 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
2912 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2913 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2914 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2919 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2923 case MSG_MGR_NOTI_TYPE_FAILED: {
2924 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2925 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2926 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2930 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2931 goto _END_OF_INSTANT_NOTI;
2935 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2936 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2938 if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
2939 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
2941 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2942 MSG_MGR_DEBUG("Fail to notification_post");
2944 _END_OF_INSTANT_NOTI:
2946 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2947 MSG_MGR_DEBUG("Fail to notification_delete");
2954 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2955 MSG_MGR_DEBUG("Fail to notification_free");
2964 bool MsgMgrCheckNotificationSettingEnable()
2966 bool msg_noti_enabled = false;
2967 notification_system_setting_h system_setting = NULL;
2968 notification_setting_h setting = NULL;
2970 int err = NOTIFICATION_ERROR_NONE;
2972 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
2974 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
2975 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2977 msg_noti_enabled = true;
2979 bool allow_to_notify = false;
2980 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
2982 if (err != NOTIFICATION_ERROR_NONE) {
2983 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2987 if (allow_to_notify) {
2988 MSG_MGR_DEBUG("message notification is allowed");
2990 /* check do not disturb mode */
2991 err = notification_system_setting_load_system_setting(&system_setting);
2993 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
2994 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
2998 bool do_not_disturb_mode = false;
2999 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
3001 if (err != NOTIFICATION_ERROR_NONE) {
3002 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
3006 if (do_not_disturb_mode) {
3007 bool is_msg_excepted = false;
3008 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
3009 if (err != NOTIFICATION_ERROR_NONE) {
3010 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
3011 msg_noti_enabled = false;
3013 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
3014 msg_noti_enabled = (is_msg_excepted) ? true : false;
3017 MSG_MGR_DEBUG("do not disturb mode is off");
3020 MSG_MGR_INFO("message notification is not allowed");
3021 msg_noti_enabled = false;
3027 notification_system_setting_free_system_setting(system_setting);
3030 notification_setting_free_notification(setting);
3032 return msg_noti_enabled;
3036 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
3038 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
3039 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
3041 MsgMgrChangePmState();
3043 char *notiMsg = NULL;
3044 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
3047 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
3048 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
3050 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
3051 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
3052 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
3053 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
3054 notification_status_message_post(pTickerMsg);
3056 notification_status_message_post(notiMsg);
3059 /* Show ticker popup for sending failed msg. */
3060 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
3068 if (bPlayFeedback) {
3070 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
3071 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
3073 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
3075 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
3076 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
3078 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
3081 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
3089 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
3091 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
3093 int err = BADGE_ERROR_NONE;
3096 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
3098 if (err != BADGE_ERROR_NONE) {
3099 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
3105 err = badge_add(MSG_DEFAULT_APP_ID);
3106 if (err != BADGE_ERROR_NONE) {
3107 MSG_MGR_ERR("Fail to badge_add : %d", err);
3112 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
3114 if (err != BADGE_ERROR_NONE) {
3115 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3123 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3127 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3129 #ifndef MSG_NOTI_INTEGRATION
3130 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3131 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3139 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3145 struct tm repeat_tm;
3149 tmp_time += (RepeatTime*60);
3151 localtime_r(&tmp_time, &repeat_tm);
3153 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3154 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3158 g_alarmId = tmpAlarmId;
3159 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3167 void MsgMgrSoundSetRepeatAlarm()
3169 int nRepeatValue = 0;
3170 long nRepeatTime = 0;
3172 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3173 MSG_MGR_INFO("vconf_get_int() is failed");
3176 switch (nRepeatValue) {
3177 case MSG_ALERT_TONE_ONCE:
3180 case MSG_ALERT_TONE_2MINS:
3183 case MSG_ALERT_TONE_5MINS:
3186 case MSG_ALERT_TONE_10MINS:
3190 MSG_MGR_DEBUG("Invalid Repetition time");
3194 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3196 if (nRepeatTime > 0) {
3197 if (g_alarmId > 0) {
3198 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3199 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3203 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3210 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3212 char *notiMsg = NULL;
3215 lang = vconf_get_str(VCONFKEY_LANGSET);
3217 setlocale(LC_MESSAGES, lang);
3219 bindtextdomain(pkg_name, locale_dir);
3221 notiMsg = dgettext(pkg_name, text);
3228 return g_strdup(notiMsg);