2 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*==================================================================================================
19 ==================================================================================================*/
29 #include <app_control.h>
30 #include <badge_internal.h>
31 #include <notification_list.h>
32 #include <notification_text_domain.h>
33 #include <notification_internal.h>
34 #include <notification_status.h>
35 #include <notification_setting.h>
36 #include <notification_setting_internal.h>
37 #include <package_manager.h>
41 #include <msg_storage.h>
43 #include <msg-manager-util.h>
44 #include <msg-manager-contact.h>
45 #include <msg-manager-debug.h>
46 #include <msg-manager-notification.h>
47 #include <msg-manager-sound.h>
52 /*==================================================================================================
54 ==================================================================================================*/
56 static GList *msg_report_notification_list = NULL;
57 static bool is_init = false;
58 extern msg_handle_t msg_handle;
62 /*==================================================================================================
64 ==================================================================================================*/
65 typedef struct _report_notification_s
68 char addressVal[MAX_ADDRESS_VAL_LEN+1];
69 } report_notification_s;
72 typedef struct _msg_mgr_noti_info_s
74 msg_mgr_notification_type_t type;
80 char sender[MSG_NOTI_TEXT_LEN_S+1];
81 char text[MSG_NOTI_TEXT_LEN+1];
82 char number[MSG_NOTI_TEXT_LEN_S+1];
83 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
86 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
87 msg_message_id_t msg_id;
88 unsigned char extra_data;
90 int active_noti_button_num;
92 int active_media_size;
93 unsigned char active_subtype; /**< to distinguish cb, push message */
94 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
95 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
96 char active_text[MSG_NOTI_TEXT_LEN+1];
97 } MSG_MGR_NOTI_INFO_S;
100 typedef struct _del_noti_info_s
102 msg_mgr_notification_type_t type;
107 /*==================================================================================================
109 ===================================================================================================*/
111 void MsgMgrInitReportNotiList();
112 void MsgRefreshNotiCb(void *data);
113 void MsgMgrDeleteNotiCb(void *data);
115 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
117 notification_h getHandle(int *noti_id);
119 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
120 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
122 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
123 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
124 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
125 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
127 int getAppIcon(const char *app_id, char **icon_path);
128 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
130 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
131 void setTextDomain(notification_h noti_h);
132 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
133 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
134 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
135 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
136 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
137 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
138 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
140 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
143 void createServiceHandle(app_control_h *svc_h);
144 void setServiceAppId(app_control_h svc_h, const char* app_id);
145 void setServiceUri(app_control_h svc_h, const char* uri);
146 void setServiceOperation(app_control_h svc_h, const char* operation);
147 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
148 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
149 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
150 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
152 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
153 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
154 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
155 void setNotiTime(notification_h noti_h, time_t time);
156 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
157 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
158 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
159 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
162 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
163 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
164 void MsgMgrSoundSetRepeatAlarm();
166 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
168 /*==================================================================================================
169 FUNCTION IMPLEMENTATION
170 ==================================================================================================*/
171 bool _is_valid_email(char *pAddress)
173 if (!pAddress || pAddress[0] == 0)
175 if (!strchr (pAddress, EMAIL_AT))
181 void MsgMgrInitReportNotiList()
185 if (msg_report_notification_list) {
186 MSG_MGR_DEBUG("Report Noti List is already inited");
190 msg_report_notification_list = NULL;
192 notification_h noti = NULL;
193 notification_list_h noti_list = NULL;
194 notification_list_h head_noti_list = NULL;
195 int noti_err = NOTIFICATION_ERROR_NONE;
196 app_control_h app_control = NULL;
198 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
199 if (noti_err != NOTIFICATION_ERROR_NONE) {
200 MSG_MGR_DEBUG("notification_get_list() is failed!!");
204 head_noti_list = noti_list;
206 while (noti_list != NULL) {
207 noti = notification_list_get_data(noti_list);
209 MSG_MGR_DEBUG("notification_list_get_data() failed!!");
213 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
214 memset(tempAddr, 0x00, sizeof(tempAddr));
216 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
217 if (noti_err != NOTIFICATION_ERROR_NONE) {
218 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
222 char *is_report_noti = NULL;
224 int ret = app_control_get_extra_data(app_control, "is_report_noti", &is_report_noti);
225 if (ret == APP_CONTROL_ERROR_NONE && is_report_noti != NULL && g_strcmp0(is_report_noti, "true") == 0) {
228 ret = app_control_get_extra_data(app_control, "address", &addr);
229 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
230 report_notification_s *info = new report_notification_s;
231 memset(info, 0x00, sizeof(report_notification_s));
233 notification_get_id(noti, NULL, &(info->priv_id));
234 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
236 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
237 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
244 if (is_report_noti) {
245 g_free(is_report_noti);
246 is_report_noti = NULL;
250 noti_list = notification_list_get_next(noti_list);
254 notification_free_list(head_noti_list);
260 void MsgMgrInitNoti()
265 bool bNotiSvcReady = false;
267 bNotiSvcReady = notification_is_service_ready();
269 if (bNotiSvcReady == true) {
270 MSG_MGR_DEBUG("Notification server is available");
271 #ifndef MSG_NOTI_INTEGRATION
272 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
274 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
275 MsgMgrInitReportNotiList();
277 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
278 #ifndef MSG_NOTI_INTEGRATION
279 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
281 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
282 delNotiInfo->sim_idx = -1;
284 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
286 notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
293 void MsgRefreshNotiCb(void *data)
295 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
296 MsgMgrInitReportNotiList();
307 void MsgMgrDeleteNotiCb(void *data)
310 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)data;
312 MsgMgrDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx);
322 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
326 notification_h noti_h = NULL;
328 MSG_MGR_NOTI_INFO_S noti_info = {0, };
330 noti_info.type = noti_type;
331 noti_info.active_noti_button_num = 1;
333 createActiveInfoData(¬i_info, msg_info);
335 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
337 setActiveNotification(noti_h, ¬i_info);
339 clearInfoData(noti_h, ¬i_info);
346 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
349 notification_h noti_h = NULL;
350 int bNotification = 1;
351 /* bool bReplyPopup = false; */
353 MSG_MGR_NOTI_INFO_S noti_info = {0, };
354 noti_info.type = noti_type;
355 noti_info.id = getPrivId(noti_info.type, -1);
357 err = getLatestMsgInfo(¬i_info, false);
360 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
361 goto __END_OF_REFRESH_NOTI;
364 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
365 err = MsgMgrInsertInstantMessage(noti_type);
368 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
369 goto __END_OF_REFRESH_NOTI;
373 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
374 MSG_MGR_DEBUG("vconf_get_bool is failed.");
377 if (bNotification == 0) {
378 MSG_MGR_DEBUG("Msg Alert notification is off.");
379 goto __END_OF_REFRESH_NOTI;
382 createInfoData(¬i_info, active_type);
384 noti_h = getHandle(¬i_info.id);
386 if (noti_h == NULL) {
387 MSG_MGR_DEBUG("Notification handle is NULL");
388 err = MSG_ERR_NULL_POINTER;
389 goto __END_OF_REFRESH_NOTI;
392 setNotification(noti_h, ¬i_info, bFeedback);
394 __END_OF_REFRESH_NOTI :
395 clearInfoData(noti_h, ¬i_info);
401 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
405 notification_h noti_h = NULL;
407 report_notification_s *info = new report_notification_s;
408 memset(info, 0x00, sizeof(report_notification_s));
410 MSG_MGR_NOTI_INFO_S noti_info = {0, };
411 noti_info.type = noti_type;
413 createInfoData(¬i_info, msg_info);
415 noti_h = getHandle(¬i_info.id);
417 if (noti_h == NULL) {
418 MSG_MGR_DEBUG("Notification handle is NULL");
420 goto __END_OF_ADD_REPORT_NOTI;
423 addServiceExtraData(noti_info.svc_h, "is_report_noti", "true");
424 setNotification(noti_h, ¬i_info, true);
426 info->priv_id = noti_info.id;
427 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
428 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
429 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
431 __END_OF_ADD_REPORT_NOTI :
432 clearInfoData(noti_h, ¬i_info);
438 int MsgMgrDeleteReportNotification(const char *addr)
442 notification_h noti_h = NULL;
443 int bNotification = 1;
445 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
446 MSG_MGR_DEBUG("vconf_get_bool is failed.");
449 if (bNotification == 0) {
450 MSG_MGR_DEBUG("Msg Alert notification is off.");
454 char* normalAddr = NULL;
455 unsigned int list_length = g_list_length(msg_report_notification_list);
456 bool isDelete = false;
458 MSG_MGR_DEBUG("list length [%d]", list_length);
460 if (list_length > 0) {
461 GList *iter = g_list_first(msg_report_notification_list);
463 while (iter != NULL) {
465 report_notification_s *info = (report_notification_s*)(iter->data);
467 MSG_MGR_DEBUG("info is NULL!");
471 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
473 noti_h = notification_load(NULL, info->priv_id);
474 if (noti_h == NULL) {
475 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
478 normalAddr = msg_mgr_normalize_number(info->addressVal);
481 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
483 if (g_str_has_suffix(addr, normalAddr)) {
484 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
485 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
488 MSG_MGR_DEBUG("delete notification failed");
493 notification_free(noti_h);
497 iter = g_list_next(iter);
500 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
514 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
518 notification_h noti_h = NULL;
520 MSG_MGR_NOTI_INFO_S noti_info = {0, };
522 noti_info.type = noti_type;
524 createInfoData(¬i_info, msg_info);
526 /* check mwi or voicemail count is 0 then skip add notification */
527 if (noti_info.count == 0) {
528 MSG_MGR_DEBUG("Notification count is 0");
530 goto __END_OF_ADD_NOTI;
533 noti_h = getHandle(¬i_info.id);
535 if (noti_h == NULL) {
536 MSG_MGR_DEBUG("Notification handle is NULL");
538 goto __END_OF_ADD_NOTI;
541 setNotification(noti_h, ¬i_info, true);
544 clearInfoData(noti_h, ¬i_info);
550 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex)
552 int noti_err = NOTIFICATION_ERROR_NONE;
554 if (noti_type == MSG_MGR_NOTI_TYPE_ALL) {
555 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
556 } 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) {
559 notiId = getPrivId(noti_type, simIndex);
560 MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
563 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, notiId);
566 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
569 if (noti_err != NOTIFICATION_ERROR_NONE) {
570 MSG_MGR_DEBUG("Fail to notification_delete_all noti_err [%d]", noti_err);
573 updatePrivId(noti_type, 0, simIndex);
577 int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
579 bool bNotiSvcReady = false;
581 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S));
584 delNotiInfo->type = noti_type;
585 delNotiInfo->sim_idx = simIndex;
588 bNotiSvcReady = notification_is_service_ready();
590 if (bNotiSvcReady == true) {
591 MSG_MGR_DEBUG("Notification server is available");
592 MsgMgrDeleteNotiCb((void *)delNotiInfo);
594 MSG_MGR_DEBUG("Notification server is not available. Delete is defered");
595 notification_add_deferred_task(MsgMgrDeleteNotiCb, (void *)delNotiInfo);
601 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
607 #ifndef MSG_NOTI_INTEGRATION
608 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
611 #ifdef MSG_NOTI_INTEGRATION
612 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
614 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
616 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
618 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
620 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
622 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
625 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
627 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
631 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
633 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
639 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
643 int noti_err = NOTIFICATION_ERROR_NONE;
646 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
647 if (noti_err != NOTIFICATION_ERROR_NONE) {
648 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
652 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
653 if (noti_err != NOTIFICATION_ERROR_NONE) {
654 MSG_MGR_DEBUG("Fail to notification_set_led.");
657 /* set execute option and property */
658 switch (noti_info->type) {
659 case MSG_MGR_NOTI_TYPE_NORMAL: {
660 if (noti_info->count > 1) {
661 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
663 if (noti_info->svc_h) { /* overwrite bundle key "type" */
664 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
665 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
667 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
670 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
673 case MSG_MGR_NOTI_TYPE_CB:
674 case MSG_MGR_NOTI_TYPE_SIM: {
675 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
676 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
679 case MSG_MGR_NOTI_TYPE_FAILED: {
680 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
681 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
684 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
685 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
688 case MSG_MGR_NOTI_TYPE_VOICE_1:
689 case MSG_MGR_NOTI_TYPE_VOICE_2:
690 case MSG_MGR_NOTI_TYPE_MWI:
691 case MSG_MGR_NOTI_TYPE_CLASS0:
692 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
693 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
694 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
695 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
699 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
704 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
705 if (noti_err != NOTIFICATION_ERROR_NONE) {
706 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
710 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
711 if (noti_err != NOTIFICATION_ERROR_NONE) {
712 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
719 void setTextDomain(notification_h noti_h)
723 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
728 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
732 char unreadMsgCntStr[10] = {0};
735 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
736 MSG_MGR_DEBUG("vconf_get_bool is failed.");
739 /* set title and content */
740 switch (noti_info->type) {
741 #ifdef MSG_NOTI_INTEGRATION
742 case MSG_MGR_NOTI_TYPE_NORMAL:
743 case MSG_MGR_NOTI_TYPE_CB:
744 case MSG_MGR_NOTI_TYPE_SIM: {
745 if (noti_info->count > 1) {
746 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
747 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
748 setNotiTime(noti_h, noti_info->time);
750 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
751 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
755 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
756 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
758 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
759 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
761 setNotiTime(noti_h, noti_info->time);
766 case MSG_MGR_NOTI_TYPE_NORMAL: {
767 if (noti_info->count > 1) {
768 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
769 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
770 setNotiTime(noti_h, noti_info->time);
772 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
773 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
776 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
777 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
779 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
780 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
782 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
783 setNotiTime(noti_h, noti_info->time);
787 case MSG_MGR_NOTI_TYPE_CB: {
788 if (noti_info->count > 1) {
789 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
790 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
791 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
792 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
793 setNotiTime(noti_h, noti_info->time);
796 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
797 setNotiTime(noti_h, noti_info->time);
800 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
801 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
803 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
804 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
809 case MSG_MGR_NOTI_TYPE_SIM: {
810 if (noti_info->count > 1) {
811 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
812 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
813 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
815 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
816 setNotiTime(noti_h, noti_info->time);
818 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
819 setNotiTime(noti_h, noti_info->time);
822 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
823 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
825 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
826 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
832 case MSG_MGR_NOTI_TYPE_FAILED: {
833 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
834 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
835 if (noti_info->count > 1) {
836 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
837 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
839 setNotiTime(noti_h, noti_info->time);
842 case MSG_MGR_NOTI_TYPE_VOICE_1:
843 case MSG_MGR_NOTI_TYPE_VOICE_2: {
844 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
845 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
846 setNotiTime(noti_h, noti_info->time);
848 if (noti_info->count == 1) {
849 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
850 } else if (noti_info->count > 1) {
851 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
852 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
854 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
858 case MSG_MGR_NOTI_TYPE_MWI: {
859 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
860 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
861 setNotiTime(noti_h, noti_info->time);
864 case MSG_MGR_NOTI_TYPE_CLASS0: {
865 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
866 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
867 setNotiTime(noti_h, noti_info->time);
870 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
871 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
872 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
874 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
875 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
876 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
877 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
879 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
882 setNotiTime(noti_h, noti_info->time);
885 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
886 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
887 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
889 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
890 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
891 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
893 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
894 /* notification free */
897 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
900 setNotiTime(noti_h, noti_info->time);
903 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
904 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
905 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
907 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED)
908 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
909 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED)
910 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE);
911 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED)
912 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
913 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED)
914 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE);
915 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE)
916 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE);
917 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED)
918 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL);
919 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE)
920 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE);
921 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR)
922 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL);
924 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
926 setNotiTime(noti_h, noti_info->time);
929 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
930 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
931 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
935 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
942 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
946 switch (noti_info->type) {
947 #ifdef MSG_NOTI_INTEGRATION
948 case MSG_MGR_NOTI_TYPE_NORMAL:
949 case MSG_MGR_NOTI_TYPE_CB:
950 case MSG_MGR_NOTI_TYPE_SIM: {
951 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
952 if (noti_info->count > 1 && noti_info->senderCount > 1) {
953 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
954 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
955 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
957 if (noti_info->active_subtype == MSG_CB_SMS) {
958 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
959 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
960 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
961 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
962 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
963 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
964 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
966 if (noti_info->imagePath[0] != '\0') {
967 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
968 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
970 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
971 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
974 char *msg_icon_path = NULL;
975 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
976 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
977 g_free(msg_icon_path);
979 MSG_MGR_ERR("fail to get message-app icon");
986 case MSG_MGR_NOTI_TYPE_NORMAL: {
987 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
988 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
990 if (noti_info->count > 1) {
991 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
993 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
997 case MSG_MGR_NOTI_TYPE_CB: {
998 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
999 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1002 case MSG_MGR_NOTI_TYPE_SIM: {
1003 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1004 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1008 case MSG_MGR_NOTI_TYPE_FAILED: {
1009 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1010 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_FAILED_STATUS_ICON);
1013 case MSG_MGR_NOTI_TYPE_VOICE_1:
1014 case MSG_MGR_NOTI_TYPE_VOICE_2:
1015 case MSG_MGR_NOTI_TYPE_MWI: {
1016 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1017 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1020 case MSG_MGR_NOTI_TYPE_CLASS0:
1021 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1023 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1024 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1025 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1027 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1028 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1029 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1031 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1032 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1033 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1035 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1036 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1037 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1040 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1047 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1051 int noti_err = NOTIFICATION_ERROR_NONE;
1054 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1055 if (noti_err != NOTIFICATION_ERROR_NONE) {
1056 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1060 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1061 if (noti_err != NOTIFICATION_ERROR_NONE) {
1062 MSG_MGR_DEBUG("Fail to notification_set_led.");
1065 /* set execute option and property */
1066 switch (noti_info->type) {
1067 case MSG_MGR_NOTI_TYPE_NORMAL:
1068 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1069 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
1071 case MSG_MGR_NOTI_TYPE_CLASS0:
1072 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1075 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
1080 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1081 if (noti_err != NOTIFICATION_ERROR_NONE) {
1082 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1086 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
1087 if (noti_err != NOTIFICATION_ERROR_NONE) {
1088 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
1095 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1099 switch (noti_info->type) {
1100 case MSG_MGR_NOTI_TYPE_NORMAL:
1101 case MSG_MGR_NOTI_TYPE_SIM:
1102 case MSG_MGR_NOTI_TYPE_CB: {
1103 if (noti_info->active_subject[0] == '\0') {
1104 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1105 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1107 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1108 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1109 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1113 case MSG_MGR_NOTI_TYPE_CLASS0: {
1114 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1115 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1119 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1127 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1131 switch (noti_info->type) {
1132 case MSG_MGR_NOTI_TYPE_NORMAL:
1133 case MSG_MGR_NOTI_TYPE_SIM: {
1134 switch (noti_info->active_subtype) {
1136 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1138 case MSG_WAP_SI_SMS:
1139 case MSG_WAP_SL_SMS:
1140 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1143 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1146 if (noti_info->imagePath[0] != '\0')
1147 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1149 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1151 char *msg_icon_path = NULL;
1152 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1153 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1154 g_free(msg_icon_path);
1156 MSG_MGR_ERR("fail to get message-app icon");
1164 case MSG_MGR_NOTI_TYPE_CB: {
1165 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1168 case MSG_MGR_NOTI_TYPE_CLASS0:
1169 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1172 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1180 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1184 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1185 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1187 if (addressVal != NULL) {
1188 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1189 /* Get Contact Info */
1190 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1191 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1194 MSG_MGR_DEBUG("addressVal is NULL.");
1197 char *msg_tone_file_path = NULL;
1199 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1201 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1203 bool bPlaySound = false;
1204 bool bPlayVibration = false;
1205 bool bOnCall = false;
1207 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1210 if (msg_tone_file_path) {
1211 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1214 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1215 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1217 int ringtoneType = tmpVal;
1218 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1219 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1221 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1224 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1227 if (bPlayVibration) {
1228 if (contactInfo.vibrationPath[0] == '\0')
1229 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1231 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1233 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1236 if (msg_tone_file_path)
1237 delete [] msg_tone_file_path;
1243 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1247 int noti_err = NOTIFICATION_ERROR_NONE;
1249 if (noti_info->active_noti_button_num > 1) {
1250 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1251 if (noti_info->active_noti_svc_h[0]) {
1252 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1253 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1255 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1257 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1258 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1259 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1260 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1263 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1264 if (noti_info->active_noti_svc_h[1]) {
1265 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1267 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1268 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1269 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1271 char slot_id[5] = {0, };
1272 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1273 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1277 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1278 if (noti_info->active_noti_svc_h[2]) {
1279 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1281 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1282 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1283 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1284 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1286 char slot_id[5] = {0, };
1287 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1288 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1291 if (noti_info->active_noti_button_num > 1) {
1292 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1293 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1294 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1296 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1297 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1298 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1300 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1302 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1305 setActiveProperty(noti_h, noti_info);
1307 setTextDomain(noti_h);
1309 setActiveText(noti_h, noti_info);
1311 setActiveIcon(noti_h, noti_info);
1313 noti_err = notification_post(noti_h);
1314 if (noti_err != NOTIFICATION_ERROR_NONE) {
1315 MSG_MGR_DEBUG("Fail to notification_post");
1322 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1326 int noti_err = NOTIFICATION_ERROR_NONE;
1328 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1330 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1331 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1332 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1334 setActiveNotification(active_noti_h, noti_info);
1336 notification_free(active_noti_h);
1337 active_noti_h = NULL;
1340 setProperty(noti_h, noti_info);
1342 setTextDomain(noti_h);
1344 setText(noti_h, noti_info);
1346 setIcon(noti_h, noti_info);
1349 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1350 setSoundAndVibration(noti_h, noti_info->number, true);
1352 setSoundAndVibration(noti_h, noti_info->number, false);
1355 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1356 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1359 if (noti_info->id > 0) {
1360 MSG_MGR_DEBUG("Notification update");
1361 noti_err = notification_update(noti_h);
1362 if (noti_err != NOTIFICATION_ERROR_NONE) {
1363 MSG_MGR_DEBUG("Fail to notification_update");
1366 MSG_MGR_DEBUG("Notification insert");
1367 noti_err = notification_insert(noti_h, ¬i_info->id);
1368 if (noti_err != NOTIFICATION_ERROR_NONE) {
1369 MSG_MGR_DEBUG("Fail to notification_insert");
1372 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1379 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1384 MSG_MGR_DEBUG("msg_info is NULL");
1388 noti_info->msg_id = msg_info->msgId;
1389 noti_info->sim_idx = msg_info->sim_idx;
1391 switch (noti_info->type) {
1392 case MSG_MGR_NOTI_TYPE_NORMAL: {
1393 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1394 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1401 case MSG_MGR_NOTI_TYPE_CLASS0: {
1402 if (msg_info->displayName[0] == '\0')
1403 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1405 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1407 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1411 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1419 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1424 notification_free(noti_h);
1428 if (noti_info->svc_h) {
1429 app_control_destroy(noti_info->svc_h);
1430 noti_info->svc_h = NULL;
1433 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1434 if (noti_info->active_noti_svc_h[i]) {
1435 app_control_destroy(noti_info->active_noti_svc_h[i]);
1436 noti_info->active_noti_svc_h[i] = NULL;
1444 int getAppIcon(const char *app_id, char **icon_path)
1448 package_info_h pkg_info_h = NULL;
1449 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1452 if (app_id == NULL) {
1453 MSG_MGR_ERR("app id is NULL");
1455 goto END_OF_GET_APP_ICON;
1458 pkg_err = package_info_create(app_id, &pkg_info_h);
1459 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1460 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1462 goto END_OF_GET_APP_ICON;
1465 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1466 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1467 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1470 if (icon_path == NULL) {
1471 MSG_MGR_WARN("icon path is NULL");
1476 END_OF_GET_APP_ICON:
1478 pkg_err = package_info_destroy(pkg_info_h);
1479 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1480 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1492 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1497 msg_error_t msg_err = MSG_SUCCESS;
1498 char **db_res = NULL;
1499 int row_cnt = 0, col_cnt = 0;
1501 switch (noti_info->type) {
1502 case MSG_MGR_NOTI_TYPE_NORMAL:
1503 #ifdef MSG_NOTI_INTEGRATION
1504 case MSG_MGR_NOTI_TYPE_CB:
1505 case MSG_MGR_NOTI_TYPE_SIM:
1508 int smsUnreadCnt = 0;
1509 int mmsUnreadCnt = 0;
1511 char sqlQuery[MAX_QUERY_LEN +1];
1512 unsigned char mainType;
1513 unsigned char subType;
1516 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1517 #ifdef MSG_NOTI_INTEGRATION
1518 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1522 "WHERE A.CONV_ID=B.CONV_ID "
1523 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1524 "AND B.STORAGE_ID = %d "
1525 "GROUP BY A.ADDRESS_VAL "
1526 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1527 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1528 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1531 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1535 "WHERE A.CONV_ID=B.CONV_ID "
1536 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1537 "AND B.STORAGE_ID = %d "
1538 "GROUP BY A.ADDRESS_VAL "
1539 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1540 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1544 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1546 row_cnt = 0, col_cnt = 0;
1547 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1548 if (msg_err != MSG_SUCCESS) {
1549 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1553 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1554 int normalAddCnt = 0;
1555 int index = col_cnt;
1557 for (int i = 1; i <= row_cnt; i++) {
1558 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1560 char *address = db_res[index++];
1563 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1564 if (_is_valid_email(address)) {
1565 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1567 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1570 subType = atoi(db_res[index++]);
1572 MSG_MGR_CONTACT_INFO_S tmpContact;
1573 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1575 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1578 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1581 if (normalAddCnt > 1) {
1582 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1585 if (tmpContact.firstName[0] != '\0') {
1586 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1587 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1588 char *senderStr = NULL;
1589 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1590 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1597 noti_info->active_noti_button_num = 1;
1600 char *senderStr = NULL;
1601 if (subType == MSG_CB_SMS) {
1602 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1603 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1604 noti_info->active_noti_button_num = 1;
1605 } else if (subType == MSG_SYNCML_CP) {
1606 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1607 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1608 noti_info->active_noti_button_num = 1;
1609 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1610 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1611 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1612 noti_info->active_noti_button_num = 1;
1614 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1624 noti_info->active_subtype = subType;
1625 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1626 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1630 noti_info->senderCount = normalAddCnt;
1631 msg_db_free(msg_handle, db_res);
1633 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1635 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1637 #ifdef MSG_NOTI_INTEGRATION
1638 snprintf(sqlQuery, sizeof(sqlQuery),
1642 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
1643 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
1645 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1646 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1647 "(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) "
1649 "WHERE A.CONV_ID=B.CONV_ID "
1650 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1651 "AND B.STORAGE_ID = %d "
1652 "ORDER BY B.DISPLAY_TIME DESC;",
1655 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1656 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1657 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1660 snprintf(sqlQuery, sizeof(sqlQuery),
1667 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1668 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1670 "WHERE A.CONV_ID=B.CONV_ID "
1671 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1672 "AND B.STORAGE_ID = %d "
1673 "ORDER BY B.DISPLAY_TIME DESC;",
1676 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1680 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1682 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1683 if (msg_err != MSG_SUCCESS) {
1684 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1689 smsUnreadCnt = atoi(db_res[col_cnt+6]);
1690 mmsUnreadCnt = atoi(db_res[col_cnt+7]);
1691 msgSize = atoi(db_res[col_cnt+8]);
1693 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1695 if (noti_info->count > 0) {
1696 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1698 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1700 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1702 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1704 if (mainType == MSG_MMS_TYPE) {
1705 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1706 if (noti_info->text[0] == '\0') {
1707 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1708 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1712 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1713 if (prefix_subject) {
1714 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1715 g_free(prefix_subject);
1717 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1721 int kb_msg_size = msgSize / 1024;
1722 if (kb_msg_size == 0 && msgSize > 0)
1724 else if (msgSize % 1024 >= 512)
1727 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1728 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1730 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1732 g_free(msg_size_string);
1733 g_free(msg_size_unit_kb);
1737 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1740 if (noti_info->active_text[0] == '\0')
1741 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1743 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1745 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1746 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1747 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1749 if (!isForInstantMessage) {
1750 if (noti_info->id > 0 && noti_info->count == 1) {
1751 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1752 if (noti_err != NOTIFICATION_ERROR_NONE) {
1753 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1757 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1758 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1761 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1762 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1763 MsgMgrInsertBadge(noti_info->count);
1764 MsgMgrSoundSetRepeatAlarm();
1767 MSG_MGR_DEBUG("No unread message.");
1768 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1770 msg_db_free(msg_handle, db_res);
1772 if (!isForInstantMessage) {
1773 /* No unread message. */
1774 if (noti_info->id > 0) {
1775 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1776 if (noti_err != NOTIFICATION_ERROR_NONE) {
1777 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1783 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1784 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1786 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1787 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1788 MsgMgrInsertBadge(0);
1789 MsgMgrSoundSetRepeatAlarm();
1795 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1796 msg_db_free(msg_handle, db_res);
1800 msg_db_free(msg_handle, db_res);
1804 #ifndef MSG_NOTI_INTEGRATION
1805 case MSG_MGR_NOTI_TYPE_CB: {
1806 char sqlQuery[MAX_QUERY_LEN+1];
1807 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1809 snprintf(sqlQuery, sizeof(sqlQuery),
1815 "WHERE A.CONV_ID=B.CONV_ID "
1816 "AND B.READ_STATUS=0 "
1817 "AND B.FOLDER_ID=%d "
1818 "AND B.STORAGE_ID = %d "
1819 "ORDER BY B.DISPLAY_TIME DESC;",
1820 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1824 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1825 return MSG_ERR_DB_PREPARE;
1827 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1828 MSG_ADDRESS_INFO_S addrInfo;
1829 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1831 if (dbhandler->columnText(0) != NULL)
1832 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1834 MSG_CONTACT_INFO_S tmpContact;
1835 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1837 MsgGetContactInfo(&addrInfo, &tmpContact);
1839 if (tmpContact.firstName[0] != '\0') {
1840 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1841 } else if (addrInfo.addressVal[0] == '\0') {
1842 char *senderStr = NULL;
1843 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1844 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1850 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1853 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1855 noti_info->time = (time_t)dbhandler->columnInt(1);
1857 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1859 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1861 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1863 MSG_MGR_DEBUG("No unread CB message.");
1864 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1866 dbhandler->finalizeQuery();
1868 if (!isForInstantMessage) {
1869 /* No unread message. */
1870 if (noti_info->id > 0) {
1871 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1872 if (noti_err != NOTIFICATION_ERROR_NONE) {
1873 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1879 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1880 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1882 return MSG_ERR_DB_STEP;
1885 dbhandler->finalizeQuery();
1887 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
1888 MSG_MGR_DEBUG("getTable is failed");
1889 dbhandler->freeTable();
1890 return MSG_ERR_DB_GETTABLE;
1893 dbhandler->freeTable();
1894 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
1897 case MSG_MGR_NOTI_TYPE_SIM: {
1898 char sqlQuery[MAX_QUERY_LEN+1];
1899 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1901 snprintf(sqlQuery, sizeof(sqlQuery),
1906 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
1908 "WHERE A.CONV_ID=B.CONV_ID "
1909 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1910 "AND B.STORAGE_ID = %d "
1911 "ORDER BY B.DISPLAY_TIME DESC;",
1913 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1917 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1919 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1920 return MSG_ERR_DB_PREPARE;
1922 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1923 noti_info->count = dbhandler->columnInt(4);
1925 if (noti_info->count > 0) {
1926 MSG_ADDRESS_INFO_S addrInfo;
1927 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1929 if (dbhandler->columnText(0) != NULL)
1930 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1932 MSG_CONTACT_INFO_S tmpContact;
1933 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1935 MsgGetContactInfo(&addrInfo, &tmpContact);
1937 if (tmpContact.firstName[0] != '\0') {
1938 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1939 } else if (addrInfo.addressVal[0] == '\0') {
1940 char *senderStr = NULL;
1941 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1942 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1948 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1951 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1953 noti_info->time = (time_t)dbhandler->columnInt(1);
1955 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1957 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1959 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
1961 MSG_MGR_DEBUG("No unread SIM message.");
1962 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1964 dbhandler->finalizeQuery();
1966 if (!isForInstantMessage) {
1967 /* No unread message. */
1968 if (noti_info->id > 0) {
1969 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1970 if (noti_err != NOTIFICATION_ERROR_NONE) {
1971 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1977 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1978 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
1981 return MSG_ERR_DB_STEP;
1984 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1985 dbhandler->finalizeQuery();
1986 return MSG_ERR_DB_STEP;
1989 dbhandler->finalizeQuery();
1993 case MSG_MGR_NOTI_TYPE_FAILED: {
1994 char sqlQuery[MAX_QUERY_LEN+1];
1995 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1997 snprintf(sqlQuery, sizeof(sqlQuery),
2004 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2006 "WHERE A.CONV_ID=B.CONV_ID "
2007 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2008 "AND B.STORAGE_ID = %d "
2009 "ORDER BY B.DISPLAY_TIME DESC;",
2010 MSG_NETWORK_SEND_FAIL,
2011 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2015 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2017 row_cnt = 0, col_cnt = 0;
2018 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2019 if (msg_err != MSG_SUCCESS) {
2020 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2025 noti_info->count = atoi(db_res[col_cnt+6]);
2027 if (noti_info->count > 0) {
2028 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2030 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2032 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2034 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2036 if (tmpContact.firstName[0] != '\0') {
2037 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2038 } else if (addrInfo.addressVal[0] == '\0') {
2039 char *senderStr = NULL;
2040 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2041 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2047 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2050 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2052 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2054 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2056 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2058 if (mainType == MSG_TYPE_MMS)
2059 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2061 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2063 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2065 if (!isForInstantMessage) {
2066 if (noti_info->id > 0 && noti_info->count == 1) {
2067 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2068 if (noti_err != NOTIFICATION_ERROR_NONE) {
2069 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2072 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2073 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2077 MSG_MGR_DEBUG("No sent failed message.");
2078 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2080 msg_db_free(msg_handle, db_res);
2082 if (!isForInstantMessage) {
2083 /* No unread message. */
2084 if (noti_info->id > 0) {
2085 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2086 if (noti_err != NOTIFICATION_ERROR_NONE) {
2087 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2093 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2094 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2100 msg_db_free(msg_handle, db_res);
2104 msg_db_free(msg_handle, db_res);
2107 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2110 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2120 notification_h getHandle(int *noti_id)
2122 notification_h noti_h = NULL;
2125 MSG_MGR_DEBUG("Notification load");
2126 noti_h = notification_load(NULL, *noti_id);
2128 MSG_MGR_DEBUG("notification_load is failed.");
2131 if (noti_h == NULL) {
2132 MSG_MGR_DEBUG("Notification create");
2133 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2134 if (noti_h == NULL) {
2135 MSG_MGR_DEBUG("notification_create is failed.");
2146 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2152 switch (noti_type) {
2153 #ifdef MSG_NOTI_INTEGRATION
2154 case MSG_MGR_NOTI_TYPE_NORMAL:
2155 case MSG_MGR_NOTI_TYPE_SIM:
2156 case MSG_MGR_NOTI_TYPE_CB:
2157 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2160 case MSG_MGR_NOTI_TYPE_NORMAL:
2161 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2163 case MSG_MGR_NOTI_TYPE_SIM:
2164 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2166 case MSG_MGR_NOTI_TYPE_CB:
2167 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2170 case MSG_MGR_NOTI_TYPE_FAILED:
2171 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2173 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2174 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2175 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2176 vconf_get_int(keyName, ¬i_id);
2179 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2180 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2181 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2182 vconf_get_int(keyName, ¬i_id);
2185 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2186 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2189 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2193 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2201 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2207 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2209 switch (noti_type) {
2210 #ifdef MSG_NOTI_INTEGRATION
2211 case MSG_MGR_NOTI_TYPE_NORMAL:
2212 case MSG_MGR_NOTI_TYPE_SIM:
2213 case MSG_MGR_NOTI_TYPE_CB:
2214 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2217 case MSG_MGR_NOTI_TYPE_NORMAL:
2218 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2220 case MSG_MGR_NOTI_TYPE_SIM:
2221 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2223 case MSG_MGR_NOTI_TYPE_CB:
2224 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2227 case MSG_MGR_NOTI_TYPE_FAILED:
2228 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2230 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2231 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2232 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2233 err = vconf_set_int(keyName, noti_id);
2236 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2237 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2238 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2239 err = vconf_set_int(keyName, noti_id);
2242 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2243 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2246 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2251 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2257 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2262 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2263 noti_info->msg_id = msg_info->msgId;
2265 MSG_MGR_DEBUG("msg_info is NULL");
2269 noti_info->sim_idx = msg_info->sim_idx;
2271 createServiceHandle(¬i_info->svc_h);
2272 char keyName[MAX_VCONFKEY_NAME_LEN];
2274 switch (noti_info->type) {
2275 case MSG_MGR_NOTI_TYPE_VOICE_1:
2276 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2277 memset(keyName, 0x00, sizeof(keyName));
2278 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2279 vconf_get_int(keyName, ¬i_info->count);
2280 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2281 noti_info->time = msg_info->displayTime;
2283 memset(keyName, 0x00, sizeof(keyName));
2284 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2285 char *voiceNumber = vconf_get_str(keyName);
2286 memset(keyName, 0x00, sizeof(keyName));
2287 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2288 char *voiceAlphaId = vconf_get_str(keyName);
2289 char *dialNumber = NULL;
2291 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2293 if (voiceNumber && strlen(voiceNumber))
2294 dialNumber = voiceNumber;
2296 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2297 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2298 } else if (dialNumber && strlen(dialNumber) > 0) {
2299 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2302 if (dialNumber && strlen(dialNumber) > 0)
2303 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2305 if (noti_info->svc_h) {
2306 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2307 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2309 char slot_id[5] = {0, };
2310 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2311 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2314 if (voiceNumber) g_free(voiceNumber);
2315 if (voiceAlphaId) g_free(voiceAlphaId);
2318 case MSG_MGR_NOTI_TYPE_MWI:
2319 case MSG_MGR_NOTI_TYPE_CLASS0: {
2320 noti_info->count = 1;
2321 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2322 noti_info->time = msg_info->displayTime;
2324 if (msg_info->displayName[0] == '\0')
2325 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2327 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2329 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2331 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2333 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2334 if (noti_info->svc_h) {
2335 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2336 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2338 char slot_id[5] = {0, };
2339 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2340 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2344 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2345 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2346 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2350 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2351 noti_info->count = 1;
2352 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2353 noti_info->time = msg_info->displayTime;
2354 noti_info->extra_data = msg_info->networkStatus;
2356 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2357 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2358 if (msg_info->addressVal[0] != '\0') {
2359 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2360 if (_is_valid_email(msg_info->addressVal)) {
2361 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2363 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2367 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2368 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2371 if (contactInfo.firstName[0] == '\0')
2372 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2374 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2376 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2378 if (noti_info->msg_id > 0) {
2379 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2380 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2381 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2382 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2386 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2387 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2388 noti_info->count = 1;
2389 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2390 noti_info->time = msg_info->displayTime;
2392 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2393 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2394 if (msg_info->addressVal[0] != '\0') {
2395 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2396 if (_is_valid_email(msg_info->addressVal)) {
2397 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2399 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2403 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2404 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2406 if (contactInfo.firstName[0] == '\0')
2407 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2409 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2411 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2413 char sqlQuery[MAX_QUERY_LEN+1];
2414 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2416 int report_status_type;
2417 int report_status_value;
2419 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2420 report_status_type = MSG_REPORT_TYPE_READ;
2422 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2425 snprintf(sqlQuery, sizeof(sqlQuery),
2428 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';",
2429 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2431 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2433 char **db_res = NULL;
2434 int row_cnt = 0, col_cnt = 0;
2436 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2437 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2438 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2442 report_status_value = atoi(db_res[col_cnt]);
2444 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2446 msg_err = msg_db_free(msg_handle, db_res);
2447 if (msg_err != MSG_SUCCESS) {
2448 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2452 if (noti_info->msg_id > 0) {
2453 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2454 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2455 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2456 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2459 noti_info->extra_data = (unsigned char)report_status_value;
2463 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2467 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2472 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2476 createServiceHandle(¬i_info->svc_h);
2478 switch (noti_info->type) {
2479 case MSG_MGR_NOTI_TYPE_NORMAL: {
2480 if (noti_info->count > 1) {
2481 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2483 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2486 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2487 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2488 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2489 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2491 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
2493 if (noti_info->active_noti_button_num == 0)
2494 noti_info->active_noti_button_num = 3;
2497 case MSG_MGR_NOTI_TYPE_CB: {
2498 if (noti_info->count > 1) {
2499 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2501 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2504 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2505 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2506 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2508 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2509 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2511 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2513 noti_info->active_noti_button_num = 1;
2516 case MSG_MGR_NOTI_TYPE_SIM: {
2517 if (noti_info->count > 1) {
2518 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2520 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2523 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2524 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2525 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2527 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2528 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2530 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2532 if (noti_info->active_noti_button_num == 0)
2533 noti_info->active_noti_button_num = 3;
2536 case MSG_MGR_NOTI_TYPE_FAILED: {
2537 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2539 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2540 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2541 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2543 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2546 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2547 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2549 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2550 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2552 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2559 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2560 noti_info->active_noti_button_num = 0;
2566 void createServiceHandle(app_control_h *svc_h)
2568 int svc_err = APP_CONTROL_ERROR_NONE;
2570 svc_err = app_control_create(svc_h);
2572 if (svc_err != APP_CONTROL_ERROR_NONE)
2573 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2577 void setServiceAppId(app_control_h svc_h, const char* app_id)
2579 int svc_err = APP_CONTROL_ERROR_NONE;
2581 svc_err = app_control_set_app_id(svc_h, app_id);
2583 if (svc_err != APP_CONTROL_ERROR_NONE)
2584 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2588 void setServiceUri(app_control_h svc_h, const char* uri)
2590 int svc_err = APP_CONTROL_ERROR_NONE;
2592 svc_err = app_control_set_uri(svc_h, uri);
2594 if (svc_err != APP_CONTROL_ERROR_NONE)
2595 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2599 void setServiceOperation(app_control_h svc_h, const char* operation)
2601 int svc_err = APP_CONTROL_ERROR_NONE;
2603 svc_err = app_control_set_operation(svc_h, operation);
2605 if (svc_err != APP_CONTROL_ERROR_NONE)
2606 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2610 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2612 int svc_err = APP_CONTROL_ERROR_NONE;
2614 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2616 if (svc_err != APP_CONTROL_ERROR_NONE)
2617 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2621 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2623 int svc_err = APP_CONTROL_ERROR_NONE;
2626 memset(&tempId, 0x00, sizeof(tempId));
2627 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2629 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2631 if (svc_err != APP_CONTROL_ERROR_NONE)
2632 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2636 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2638 int svc_err = APP_CONTROL_ERROR_NONE;
2640 svc_err = app_control_set_app_id(svc_h, pkg_name);
2642 if (svc_err != APP_CONTROL_ERROR_NONE)
2643 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2647 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2649 int svc_err = APP_CONTROL_ERROR_NONE;
2651 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2653 if (svc_err != APP_CONTROL_ERROR_NONE)
2654 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2658 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2660 int noti_err = NOTIFICATION_ERROR_NONE;
2662 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2663 if (noti_err != NOTIFICATION_ERROR_NONE)
2664 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2668 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2670 int noti_err = NOTIFICATION_ERROR_NONE;
2672 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2674 if (noti_err != NOTIFICATION_ERROR_NONE)
2675 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2679 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2681 int noti_err = NOTIFICATION_ERROR_NONE;
2683 noti_err = notification_set_time_to_text(noti_h, type, time);
2685 if (noti_err != NOTIFICATION_ERROR_NONE)
2686 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2690 void setNotiTime(notification_h noti_h, time_t time)
2692 int noti_err = NOTIFICATION_ERROR_NONE;
2694 noti_err = notification_set_time(noti_h, time);
2696 if (noti_err != NOTIFICATION_ERROR_NONE)
2697 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2702 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2704 int noti_err = NOTIFICATION_ERROR_NONE;
2706 noti_err = notification_set_image(noti_h, type, image_path);
2708 if (noti_err != NOTIFICATION_ERROR_NONE)
2709 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2713 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2715 int noti_err = NOTIFICATION_ERROR_NONE;
2717 noti_err = notification_set_sound(noti_h, type, path);
2719 if (noti_err != NOTIFICATION_ERROR_NONE)
2720 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2724 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2726 int noti_err = NOTIFICATION_ERROR_NONE;
2728 noti_err = notification_set_vibration(noti_h, type, path);
2730 if (noti_err != NOTIFICATION_ERROR_NONE)
2731 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2735 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2737 int noti_err = NOTIFICATION_ERROR_NONE;
2739 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2741 if (noti_err != NOTIFICATION_ERROR_NONE)
2742 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2746 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2750 char *notiMsg = NULL;
2752 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2754 switch (noti_type) {
2755 case MSG_MGR_NOTI_TYPE_NORMAL:
2756 case MSG_MGR_NOTI_TYPE_SIM:
2757 case MSG_MGR_NOTI_TYPE_CB: {
2758 MSG_MGR_NOTI_INFO_S noti_info;
2759 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2761 noti_info.type = noti_type;
2762 int err = getLatestMsgInfo(¬i_info, true);
2765 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2766 if (noti_info.count == 1) {
2767 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2768 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2769 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2770 } else if (noti_info.count > 1) {
2771 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2773 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
2774 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2775 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2776 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2781 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2785 case MSG_MGR_NOTI_TYPE_FAILED: {
2786 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2787 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2788 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2792 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2793 goto _END_OF_INSTANT_NOTI;
2797 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2798 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2800 if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
2801 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
2803 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2804 MSG_MGR_DEBUG("Fail to notification_post");
2806 _END_OF_INSTANT_NOTI:
2808 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2809 MSG_MGR_DEBUG("Fail to notification_delete");
2816 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2817 MSG_MGR_DEBUG("Fail to notification_free");
2826 bool MsgMgrCheckNotificationSettingEnable()
2828 bool msg_noti_enabled = false;
2829 notification_system_setting_h system_setting = NULL;
2830 notification_setting_h setting = NULL;
2832 int err = NOTIFICATION_ERROR_NONE;
2834 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
2836 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
2837 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2839 msg_noti_enabled = true;
2841 bool allow_to_notify = false;
2842 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
2844 if (err != NOTIFICATION_ERROR_NONE) {
2845 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2849 if (allow_to_notify) {
2850 MSG_MGR_DEBUG("message notification is allowed");
2852 /* check do not disturb mode */
2853 err = notification_system_setting_load_system_setting(&system_setting);
2855 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
2856 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
2860 bool do_not_disturb_mode = false;
2861 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
2863 if (err != NOTIFICATION_ERROR_NONE) {
2864 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2868 if (do_not_disturb_mode) {
2869 bool is_msg_excepted = false;
2870 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
2871 if (err != NOTIFICATION_ERROR_NONE) {
2872 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2873 msg_noti_enabled = false;
2875 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
2876 msg_noti_enabled = (is_msg_excepted) ? true : false;
2879 MSG_MGR_DEBUG("do not disturb mode is off");
2882 MSG_MGR_INFO("message notification is not allowed");
2883 msg_noti_enabled = false;
2889 notification_system_setting_free_system_setting(system_setting);
2892 notification_setting_free_notification(setting);
2894 return msg_noti_enabled;
2898 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
2900 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
2901 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
2903 MsgMgrChangePmState();
2905 char *notiMsg = NULL;
2906 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
2909 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
2910 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
2912 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
2913 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
2914 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
2915 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
2916 notification_status_message_post(pTickerMsg);
2918 notification_status_message_post(notiMsg);
2921 /* Show ticker popup for sending failed msg. */
2922 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
2930 if (bPlayFeedback) {
2932 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
2933 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
2935 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
2937 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
2938 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
2940 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
2943 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
2951 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
2953 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
2955 int err = BADGE_ERROR_NONE;
2958 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
2960 if (err != BADGE_ERROR_NONE) {
2961 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
2967 err = badge_add(MSG_DEFAULT_APP_ID);
2968 if (err != BADGE_ERROR_NONE) {
2969 MSG_MGR_ERR("Fail to badge_add : %d", err);
2974 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
2976 if (err != BADGE_ERROR_NONE) {
2977 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
2985 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
2989 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2991 #ifndef MSG_NOTI_INTEGRATION
2992 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2993 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3001 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3007 struct tm repeat_tm;
3011 tmp_time += (RepeatTime*60);
3013 localtime_r(&tmp_time, &repeat_tm);
3015 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3016 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3020 g_alarmId = tmpAlarmId;
3021 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3029 void MsgMgrSoundSetRepeatAlarm()
3031 int nRepeatValue = 0;
3032 long nRepeatTime = 0;
3034 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3035 MSG_MGR_INFO("vconf_get_int() is failed");
3038 switch (nRepeatValue) {
3039 case MSG_ALERT_TONE_ONCE:
3042 case MSG_ALERT_TONE_2MINS:
3045 case MSG_ALERT_TONE_5MINS:
3048 case MSG_ALERT_TONE_10MINS:
3052 MSG_MGR_DEBUG("Invalid Repetition time");
3056 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3058 if (nRepeatTime > 0) {
3059 if (g_alarmId > 0) {
3060 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3061 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3065 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3072 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3074 char *notiMsg = NULL;
3077 lang = vconf_get_str(VCONFKEY_LANGSET);
3079 setlocale(LC_MESSAGES, lang);
3081 bindtextdomain(pkg_name, locale_dir);
3083 notiMsg = dgettext(pkg_name, text);
3090 return g_strdup(notiMsg);