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 MsgRefreshNotiCb(void *data);
114 void MsgMgrDeleteNotiCb(void *data);
116 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
117 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result);
119 notification_h getHandle(int *noti_id);
121 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
122 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
124 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
125 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
126 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
127 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
129 int getAppIcon(const char *app_id, char **icon_path);
130 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
132 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
133 void setTextDomain(notification_h noti_h);
134 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
135 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
136 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
137 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
138 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
139 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
140 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
142 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
145 void createServiceHandle(app_control_h *svc_h);
146 void setServiceAppId(app_control_h svc_h, const char* app_id);
147 void setServiceUri(app_control_h svc_h, const char* uri);
148 void setServiceOperation(app_control_h svc_h, const char* operation);
149 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
150 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
151 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
152 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
154 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
155 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
156 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
157 void setNotiTime(notification_h noti_h, time_t time);
158 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
159 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
160 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
161 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
164 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
165 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
166 void MsgMgrSoundSetRepeatAlarm();
168 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
170 /*==================================================================================================
171 FUNCTION IMPLEMENTATION
172 ==================================================================================================*/
173 bool _is_valid_email(char *pAddress)
175 if (!pAddress || pAddress[0] == 0)
177 if (!strchr (pAddress, EMAIL_AT))
183 void MsgMgrInitReportNotiList()
187 if (msg_report_notification_list) {
188 MSG_MGR_DEBUG("Report Noti List is already inited");
192 msg_report_notification_list = NULL;
194 notification_h noti = NULL;
195 notification_list_h noti_list = NULL;
196 notification_list_h head_noti_list = NULL;
197 int noti_err = NOTIFICATION_ERROR_NONE;
198 app_control_h app_control = NULL;
200 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
201 if (noti_err != NOTIFICATION_ERROR_NONE) {
202 MSG_MGR_DEBUG("notification_get_list() is failed!!");
206 head_noti_list = noti_list;
208 while (noti_list != NULL) {
209 noti = notification_list_get_data(noti_list);
211 MSG_MGR_DEBUG("notification_list_get_data() failed!!");
215 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
216 memset(tempAddr, 0x00, sizeof(tempAddr));
218 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
219 if (noti_err != NOTIFICATION_ERROR_NONE) {
220 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
224 char *is_report_noti = NULL;
226 int ret = app_control_get_extra_data(app_control, "is_report_noti", &is_report_noti);
227 if (ret == APP_CONTROL_ERROR_NONE && is_report_noti != NULL && g_strcmp0(is_report_noti, "true") == 0) {
230 ret = app_control_get_extra_data(app_control, "address", &addr);
231 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
232 report_notification_s *info = new report_notification_s;
233 memset(info, 0x00, sizeof(report_notification_s));
235 notification_get_id(noti, NULL, &(info->priv_id));
236 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
238 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
239 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
246 if (is_report_noti) {
247 g_free(is_report_noti);
248 is_report_noti = NULL;
252 noti_list = notification_list_get_next(noti_list);
256 notification_free_list(head_noti_list);
262 void MsgMgrInitNoti()
267 bool bNotiSvcReady = false;
269 bNotiSvcReady = notification_is_service_ready();
271 if (bNotiSvcReady == true) {
272 MSG_MGR_DEBUG("Notification server is available");
273 #ifndef MSG_NOTI_INTEGRATION
274 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
276 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
277 MsgMgrInitReportNotiList();
279 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
280 #ifndef MSG_NOTI_INTEGRATION
281 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
283 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
284 delNotiInfo->sim_idx = -1;
286 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
288 notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
295 void MsgRefreshNotiCb(void *data)
297 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
298 MsgMgrInitReportNotiList();
309 void MsgMgrDeleteNotiCb(void *data)
312 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)data;
314 MsgMgrDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx);
324 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
328 notification_h noti_h = NULL;
330 MSG_MGR_NOTI_INFO_S noti_info = {0, };
332 noti_info.type = noti_type;
333 noti_info.active_noti_button_num = 1;
335 createActiveInfoData(¬i_info, msg_info);
337 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
339 setActiveNotification(noti_h, ¬i_info);
341 clearInfoData(noti_h, ¬i_info);
348 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
351 notification_h noti_h = NULL;
352 int bNotification = 1;
353 /* bool bReplyPopup = false; */
355 MSG_MGR_NOTI_INFO_S noti_info = {0, };
356 noti_info.type = noti_type;
357 noti_info.id = getPrivId(noti_info.type, -1);
359 err = getLatestMsgInfo(¬i_info, false);
362 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
363 goto __END_OF_REFRESH_NOTI;
366 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
367 err = MsgMgrInsertInstantMessage(noti_type);
370 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
371 goto __END_OF_REFRESH_NOTI;
375 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
376 MSG_MGR_DEBUG("vconf_get_bool is failed.");
379 if (bNotification == 0) {
380 MSG_MGR_DEBUG("Msg Alert notification is off.");
381 goto __END_OF_REFRESH_NOTI;
384 createInfoData(¬i_info, active_type);
386 noti_h = getHandle(¬i_info.id);
388 if (noti_h == NULL) {
389 MSG_MGR_DEBUG("Notification handle is NULL");
390 err = MSG_ERR_NULL_POINTER;
391 goto __END_OF_REFRESH_NOTI;
394 setNotification(noti_h, ¬i_info, bFeedback);
396 __END_OF_REFRESH_NOTI :
397 clearInfoData(noti_h, ¬i_info);
403 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
407 notification_h noti_h = NULL;
409 report_notification_s *info = new report_notification_s;
410 memset(info, 0x00, sizeof(report_notification_s));
412 MSG_MGR_NOTI_INFO_S noti_info = {0, };
413 noti_info.type = noti_type;
415 createInfoData(¬i_info, msg_info);
417 noti_h = getHandle(¬i_info.id);
419 if (noti_h == NULL) {
420 MSG_MGR_DEBUG("Notification handle is NULL");
422 goto __END_OF_ADD_REPORT_NOTI;
425 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT || noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
426 noti_info.applist &= ~NOTIFICATION_DISPLAY_APP_TICKER;
428 ret = MsgMgrInsertDeliveryReportInstantNotification(noti_type, noti_info.extra_data);
431 MSG_MGR_ERR(" MsgInsertInstantDeliveryReportNotification() err = [%d]", ret);
432 goto __END_OF_ADD_REPORT_NOTI;
436 addServiceExtraData(noti_info.svc_h, "is_report_noti", "true");
437 setNotification(noti_h, ¬i_info, true);
439 info->priv_id = noti_info.id;
440 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
441 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
442 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
444 __END_OF_ADD_REPORT_NOTI :
445 clearInfoData(noti_h, ¬i_info);
451 int MsgMgrDeleteReportNotification(const char *addr)
455 notification_h noti_h = NULL;
456 int bNotification = 1;
458 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
459 MSG_MGR_DEBUG("vconf_get_bool is failed.");
462 if (bNotification == 0) {
463 MSG_MGR_DEBUG("Msg Alert notification is off.");
467 char* normalAddr = NULL;
468 unsigned int list_length = g_list_length(msg_report_notification_list);
469 bool isDelete = false;
471 MSG_MGR_DEBUG("list length [%d]", list_length);
473 if (list_length > 0) {
474 GList *iter = g_list_first(msg_report_notification_list);
476 while (iter != NULL) {
478 report_notification_s *info = (report_notification_s*)(iter->data);
480 MSG_MGR_DEBUG("info is NULL!");
484 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
486 noti_h = notification_load(NULL, info->priv_id);
487 if (noti_h == NULL) {
488 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
491 normalAddr = msg_mgr_normalize_number(info->addressVal);
494 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
496 if (g_str_has_suffix(addr, normalAddr)) {
497 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
498 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
501 MSG_MGR_DEBUG("delete notification failed");
506 notification_free(noti_h);
510 iter = g_list_next(iter);
513 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
527 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
531 notification_h noti_h = NULL;
533 MSG_MGR_NOTI_INFO_S noti_info = {0, };
535 noti_info.type = noti_type;
537 createInfoData(¬i_info, msg_info);
539 /* check mwi or voicemail count is 0 then skip add notification */
540 if (noti_info.count == 0) {
541 MSG_MGR_DEBUG("Notification count is 0");
543 goto __END_OF_ADD_NOTI;
546 noti_h = getHandle(¬i_info.id);
548 if (noti_h == NULL) {
549 MSG_MGR_DEBUG("Notification handle is NULL");
551 goto __END_OF_ADD_NOTI;
554 setNotification(noti_h, ¬i_info, true);
557 clearInfoData(noti_h, ¬i_info);
563 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex)
565 int noti_err = NOTIFICATION_ERROR_NONE;
567 if (noti_type == MSG_MGR_NOTI_TYPE_ALL) {
568 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
569 } 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) {
572 notiId = getPrivId(noti_type, simIndex);
573 MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
576 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, notiId);
579 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
582 if (noti_err != NOTIFICATION_ERROR_NONE) {
583 MSG_MGR_DEBUG("Fail to notification_delete_all noti_err [%d]", noti_err);
586 updatePrivId(noti_type, 0, simIndex);
590 int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
592 bool bNotiSvcReady = false;
594 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S));
597 delNotiInfo->type = noti_type;
598 delNotiInfo->sim_idx = simIndex;
601 bNotiSvcReady = notification_is_service_ready();
603 if (bNotiSvcReady == true) {
604 MSG_MGR_DEBUG("Notification server is available");
605 MsgMgrDeleteNotiCb((void *)delNotiInfo);
607 MSG_MGR_DEBUG("Notification server is not available. Delete is defered");
608 notification_add_deferred_task(MsgMgrDeleteNotiCb, (void *)delNotiInfo);
614 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
620 #ifndef MSG_NOTI_INTEGRATION
621 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
624 #ifdef MSG_NOTI_INTEGRATION
625 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
627 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
629 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
631 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
633 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
635 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
638 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
640 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
644 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
646 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
652 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
656 int noti_err = NOTIFICATION_ERROR_NONE;
659 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
660 if (noti_err != NOTIFICATION_ERROR_NONE) {
661 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
665 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
666 if (noti_err != NOTIFICATION_ERROR_NONE) {
667 MSG_MGR_DEBUG("Fail to notification_set_led.");
670 /* set execute option and property */
671 switch (noti_info->type) {
672 case MSG_MGR_NOTI_TYPE_NORMAL: {
673 if (noti_info->count > 1) {
674 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
676 if (noti_info->svc_h) { /* overwrite bundle key "type" */
677 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
678 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
680 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
683 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
686 case MSG_MGR_NOTI_TYPE_CB:
687 case MSG_MGR_NOTI_TYPE_SIM: {
688 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
689 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
692 case MSG_MGR_NOTI_TYPE_FAILED: {
693 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
694 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
697 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
698 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
701 case MSG_MGR_NOTI_TYPE_VOICE_1:
702 case MSG_MGR_NOTI_TYPE_VOICE_2:
703 case MSG_MGR_NOTI_TYPE_MWI:
704 case MSG_MGR_NOTI_TYPE_CLASS0:
705 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
706 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
707 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
708 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
712 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
717 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
718 if (noti_err != NOTIFICATION_ERROR_NONE) {
719 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
723 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
724 if (noti_err != NOTIFICATION_ERROR_NONE) {
725 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
732 void setTextDomain(notification_h noti_h)
736 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
741 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
745 char unreadMsgCntStr[10] = {0};
748 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
749 MSG_MGR_DEBUG("vconf_get_bool is failed.");
752 /* set title and content */
753 switch (noti_info->type) {
754 #ifdef MSG_NOTI_INTEGRATION
755 case MSG_MGR_NOTI_TYPE_NORMAL:
756 case MSG_MGR_NOTI_TYPE_CB:
757 case MSG_MGR_NOTI_TYPE_SIM: {
758 if (noti_info->count > 1) {
759 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
760 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
761 setNotiTime(noti_h, noti_info->time);
763 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
764 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
768 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
769 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
771 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
772 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
774 setNotiTime(noti_h, noti_info->time);
779 case MSG_MGR_NOTI_TYPE_NORMAL: {
780 if (noti_info->count > 1) {
781 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
782 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
783 setNotiTime(noti_h, noti_info->time);
785 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
786 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
789 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
790 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
792 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
793 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
795 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
796 setNotiTime(noti_h, noti_info->time);
800 case MSG_MGR_NOTI_TYPE_CB: {
801 if (noti_info->count > 1) {
802 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
803 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
804 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
805 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
806 setNotiTime(noti_h, noti_info->time);
809 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
810 setNotiTime(noti_h, noti_info->time);
813 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
814 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
816 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
817 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
822 case MSG_MGR_NOTI_TYPE_SIM: {
823 if (noti_info->count > 1) {
824 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
825 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
826 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
828 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
829 setNotiTime(noti_h, noti_info->time);
831 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
832 setNotiTime(noti_h, noti_info->time);
835 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
836 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
838 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
839 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
845 case MSG_MGR_NOTI_TYPE_FAILED: {
846 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
847 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
848 if (noti_info->count > 1) {
849 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
850 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
852 setNotiTime(noti_h, noti_info->time);
855 case MSG_MGR_NOTI_TYPE_VOICE_1:
856 case MSG_MGR_NOTI_TYPE_VOICE_2: {
857 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
858 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
859 setNotiTime(noti_h, noti_info->time);
861 if (noti_info->count == 1) {
862 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
863 } else if (noti_info->count > 1) {
864 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
865 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
867 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
871 case MSG_MGR_NOTI_TYPE_MWI: {
872 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
873 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
874 setNotiTime(noti_h, noti_info->time);
877 case MSG_MGR_NOTI_TYPE_CLASS0: {
878 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
879 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
880 setNotiTime(noti_h, noti_info->time);
883 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
884 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
885 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
887 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
888 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
889 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
890 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
892 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
895 setNotiTime(noti_h, noti_info->time);
898 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
899 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
900 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
902 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
903 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
904 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
906 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
907 /* notification free */
910 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
913 setNotiTime(noti_h, noti_info->time);
916 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
917 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
918 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
920 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) {
921 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
922 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) {
923 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", MESSAGE_REJECTED);
924 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) {
925 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
926 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED || noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE
927 || noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED || noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE
928 || noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) {
929 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Recipient not available", RECIPIENT_NOT_AVAILABLE);
931 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
934 setNotiTime(noti_h, noti_info->time);
937 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
938 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
939 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
943 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
950 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
954 switch (noti_info->type) {
955 #ifdef MSG_NOTI_INTEGRATION
956 case MSG_MGR_NOTI_TYPE_NORMAL:
957 case MSG_MGR_NOTI_TYPE_CB:
958 case MSG_MGR_NOTI_TYPE_SIM: {
959 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
960 if (noti_info->count > 1 && noti_info->senderCount > 1) {
961 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
962 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
963 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
965 if (noti_info->active_subtype == MSG_CB_SMS) {
966 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
967 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
968 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
969 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
970 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
971 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
972 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
974 if (noti_info->imagePath[0] != '\0') {
975 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
976 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
978 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
979 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
982 char *msg_icon_path = NULL;
983 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
984 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
985 g_free(msg_icon_path);
987 MSG_MGR_ERR("fail to get message-app icon");
994 case MSG_MGR_NOTI_TYPE_NORMAL: {
995 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
996 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
998 if (noti_info->count > 1) {
999 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1001 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
1005 case MSG_MGR_NOTI_TYPE_CB: {
1006 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1007 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1010 case MSG_MGR_NOTI_TYPE_SIM: {
1011 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1012 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1016 case MSG_MGR_NOTI_TYPE_FAILED: {
1017 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1018 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_FAILED_STATUS_ICON);
1021 case MSG_MGR_NOTI_TYPE_VOICE_1:
1022 case MSG_MGR_NOTI_TYPE_VOICE_2:
1023 case MSG_MGR_NOTI_TYPE_MWI: {
1024 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1025 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1028 case MSG_MGR_NOTI_TYPE_CLASS0:
1029 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1031 case MSG_MGR_NOTI_TYPE_SMS_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_MMS_READ_REPORT:
1036 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1037 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1039 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1040 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1041 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1043 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1044 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1045 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1048 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1055 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1059 int noti_err = NOTIFICATION_ERROR_NONE;
1062 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1063 if (noti_err != NOTIFICATION_ERROR_NONE) {
1064 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1068 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1069 if (noti_err != NOTIFICATION_ERROR_NONE) {
1070 MSG_MGR_DEBUG("Fail to notification_set_led.");
1073 /* set execute option and property */
1074 switch (noti_info->type) {
1075 case MSG_MGR_NOTI_TYPE_NORMAL:
1076 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1077 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
1079 case MSG_MGR_NOTI_TYPE_CLASS0:
1080 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1083 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
1088 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1089 if (noti_err != NOTIFICATION_ERROR_NONE) {
1090 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1094 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
1095 if (noti_err != NOTIFICATION_ERROR_NONE) {
1096 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
1103 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1107 switch (noti_info->type) {
1108 case MSG_MGR_NOTI_TYPE_NORMAL:
1109 case MSG_MGR_NOTI_TYPE_SIM:
1110 case MSG_MGR_NOTI_TYPE_CB: {
1111 if (noti_info->active_subject[0] == '\0') {
1112 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1113 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1115 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1116 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1117 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1121 case MSG_MGR_NOTI_TYPE_CLASS0: {
1122 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1123 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1127 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1135 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1139 switch (noti_info->type) {
1140 case MSG_MGR_NOTI_TYPE_NORMAL:
1141 case MSG_MGR_NOTI_TYPE_SIM: {
1142 switch (noti_info->active_subtype) {
1144 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1146 case MSG_WAP_SI_SMS:
1147 case MSG_WAP_SL_SMS:
1148 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1151 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1154 if (noti_info->imagePath[0] != '\0')
1155 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1157 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1159 char *msg_icon_path = NULL;
1160 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1161 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1162 g_free(msg_icon_path);
1164 MSG_MGR_ERR("fail to get message-app icon");
1172 case MSG_MGR_NOTI_TYPE_CB: {
1173 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1176 case MSG_MGR_NOTI_TYPE_CLASS0:
1177 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1180 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1188 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result)
1192 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
1193 notification_set_pkgname(noti, MSG_DEFAULT_APP_ID);
1195 setTextDomain(noti);
1196 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
1197 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVER_REPORT_STATUS_ICON);
1199 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT) {
1200 if (result == MSG_NETWORK_DELIVER_SUCCESS) {
1201 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1202 } else if (result == MSG_NETWORK_DELIVER_EXPIRED) {
1203 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1204 } else if (result == MSG_NETWORK_DELIVER_PENDING) {
1205 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1207 MSG_MGR_ERR("unexpected result! [%d]", result);
1208 goto _END_OF_INSTANT_DELIVERY_REPORT_NOTI;
1210 } else if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
1211 if (result == MSG_DELIVERY_REPORT_EXPIRED)
1212 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1213 else if (result== MSG_DELIVERY_REPORT_REJECTED)
1214 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message rejected by recipient.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_REJECTED);
1215 else if (result == MSG_DELIVERY_REPORT_DEFERRED)
1216 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1217 else if (result == MSG_DELIVERY_REPORT_UNRECOGNISED || result == MSG_DELIVERY_REPORT_INDETERMINATE ||
1218 result == MSG_DELIVERY_REPORT_FORWARDED || result == MSG_DELIVERY_REPORT_UNREACHABLE ||
1219 result == MSG_DELIVERY_REPORT_ERROR)
1220 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Recipient not available.", UNABLE_TO_DELIVER_MESSAGE_RECIPIENT_NOT_AVAILABLE);
1222 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1225 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
1226 MSG_MGR_ERR("Fail to notification_set_display_applist");
1228 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
1229 MSG_MGR_ERR("Fail to notification_post");
1231 _END_OF_INSTANT_DELIVERY_REPORT_NOTI:
1233 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
1234 MSG_MGR_ERR("Fail to notification_delete");
1237 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
1238 MSG_MGR_ERR("Fail to notification_free");
1247 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1251 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1252 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1254 if (addressVal != NULL) {
1255 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1256 /* Get Contact Info */
1257 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1258 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1261 MSG_MGR_DEBUG("addressVal is NULL.");
1264 char *msg_tone_file_path = NULL;
1266 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1268 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1270 bool bPlaySound = false;
1271 bool bPlayVibration = false;
1272 bool bOnCall = false;
1274 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1277 if (msg_tone_file_path) {
1278 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1281 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1282 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1284 int ringtoneType = tmpVal;
1285 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1286 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1288 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1291 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1294 if (bPlayVibration) {
1295 if (contactInfo.vibrationPath[0] == '\0')
1296 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1298 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1300 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1303 if (msg_tone_file_path)
1304 delete [] msg_tone_file_path;
1310 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1314 int noti_err = NOTIFICATION_ERROR_NONE;
1316 if (noti_info->active_noti_button_num > 1) {
1317 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1318 if (noti_info->active_noti_svc_h[0]) {
1319 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1320 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1322 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1324 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1325 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1326 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1327 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1330 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1331 if (noti_info->active_noti_svc_h[1]) {
1332 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1334 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1335 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1336 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1338 char slot_id[5] = {0, };
1339 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1340 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1344 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1345 if (noti_info->active_noti_svc_h[2]) {
1346 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1348 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1349 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1350 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1351 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1353 char slot_id[5] = {0, };
1354 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1355 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1358 if (noti_info->active_noti_button_num > 1) {
1359 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1360 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1361 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1363 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1364 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1365 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1367 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1369 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1372 setActiveProperty(noti_h, noti_info);
1374 setTextDomain(noti_h);
1376 setActiveText(noti_h, noti_info);
1378 setActiveIcon(noti_h, noti_info);
1380 noti_err = notification_post(noti_h);
1381 if (noti_err != NOTIFICATION_ERROR_NONE) {
1382 MSG_MGR_DEBUG("Fail to notification_post");
1389 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1393 int noti_err = NOTIFICATION_ERROR_NONE;
1395 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1397 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1398 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1399 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1401 setActiveNotification(active_noti_h, noti_info);
1403 notification_free(active_noti_h);
1404 active_noti_h = NULL;
1407 setProperty(noti_h, noti_info);
1409 setTextDomain(noti_h);
1411 setText(noti_h, noti_info);
1413 setIcon(noti_h, noti_info);
1416 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1417 setSoundAndVibration(noti_h, noti_info->number, true);
1419 setSoundAndVibration(noti_h, noti_info->number, false);
1422 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1423 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1426 if (noti_info->id > 0) {
1427 MSG_MGR_DEBUG("Notification update");
1428 noti_err = notification_update(noti_h);
1429 if (noti_err != NOTIFICATION_ERROR_NONE) {
1430 MSG_MGR_DEBUG("Fail to notification_update");
1433 MSG_MGR_DEBUG("Notification insert");
1434 noti_err = notification_insert(noti_h, ¬i_info->id);
1435 if (noti_err != NOTIFICATION_ERROR_NONE) {
1436 MSG_MGR_DEBUG("Fail to notification_insert");
1439 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1446 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1451 MSG_MGR_DEBUG("msg_info is NULL");
1455 noti_info->msg_id = msg_info->msgId;
1456 noti_info->sim_idx = msg_info->sim_idx;
1458 switch (noti_info->type) {
1459 case MSG_MGR_NOTI_TYPE_NORMAL: {
1460 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1461 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1468 case MSG_MGR_NOTI_TYPE_CLASS0: {
1469 if (msg_info->displayName[0] == '\0')
1470 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1472 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1474 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1478 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1486 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1491 notification_free(noti_h);
1495 if (noti_info->svc_h) {
1496 app_control_destroy(noti_info->svc_h);
1497 noti_info->svc_h = NULL;
1500 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1501 if (noti_info->active_noti_svc_h[i]) {
1502 app_control_destroy(noti_info->active_noti_svc_h[i]);
1503 noti_info->active_noti_svc_h[i] = NULL;
1511 int getAppIcon(const char *app_id, char **icon_path)
1515 package_info_h pkg_info_h = NULL;
1516 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1519 if (app_id == NULL) {
1520 MSG_MGR_ERR("app id is NULL");
1522 goto END_OF_GET_APP_ICON;
1525 pkg_err = package_info_create(app_id, &pkg_info_h);
1526 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1527 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1529 goto END_OF_GET_APP_ICON;
1532 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1533 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1534 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1537 if (icon_path == NULL) {
1538 MSG_MGR_WARN("icon path is NULL");
1543 END_OF_GET_APP_ICON:
1545 pkg_err = package_info_destroy(pkg_info_h);
1546 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1547 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1559 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1564 msg_error_t msg_err = MSG_SUCCESS;
1565 char **db_res = NULL;
1566 int row_cnt = 0, col_cnt = 0;
1568 switch (noti_info->type) {
1569 case MSG_MGR_NOTI_TYPE_NORMAL:
1570 #ifdef MSG_NOTI_INTEGRATION
1571 case MSG_MGR_NOTI_TYPE_CB:
1572 case MSG_MGR_NOTI_TYPE_SIM:
1575 int smsUnreadCnt = 0;
1576 int mmsUnreadCnt = 0;
1578 char sqlQuery[MAX_QUERY_LEN +1];
1579 unsigned char mainType;
1580 unsigned char subType;
1583 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1584 #ifdef MSG_NOTI_INTEGRATION
1585 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1589 "WHERE A.CONV_ID=B.CONV_ID "
1590 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1591 "AND B.STORAGE_ID = %d "
1592 "GROUP BY A.ADDRESS_VAL "
1593 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1594 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1595 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1598 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1602 "WHERE A.CONV_ID=B.CONV_ID "
1603 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1604 "AND B.STORAGE_ID = %d "
1605 "GROUP BY A.ADDRESS_VAL "
1606 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1607 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1611 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1613 row_cnt = 0, col_cnt = 0;
1614 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1615 if (msg_err != MSG_SUCCESS) {
1616 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1620 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1621 int normalAddCnt = 0;
1622 int index = col_cnt;
1624 for (int i = 1; i <= row_cnt; i++) {
1625 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1627 char *address = db_res[index++];
1630 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1631 if (_is_valid_email(address)) {
1632 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1634 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1637 subType = atoi(db_res[index++]);
1639 MSG_MGR_CONTACT_INFO_S tmpContact;
1640 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1642 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1645 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1648 if (normalAddCnt > 1) {
1649 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1652 if (tmpContact.firstName[0] != '\0') {
1653 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1654 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1655 char *senderStr = NULL;
1656 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1657 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1664 noti_info->active_noti_button_num = 1;
1667 char *senderStr = NULL;
1668 if (subType == MSG_CB_SMS) {
1669 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1670 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1671 noti_info->active_noti_button_num = 1;
1672 } else if (subType == MSG_SYNCML_CP) {
1673 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1674 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1675 noti_info->active_noti_button_num = 1;
1676 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1677 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1678 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1679 noti_info->active_noti_button_num = 1;
1681 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1691 noti_info->active_subtype = subType;
1692 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1693 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1697 noti_info->senderCount = normalAddCnt;
1698 msg_db_free(msg_handle, db_res);
1700 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1702 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1704 #ifdef MSG_NOTI_INTEGRATION
1705 snprintf(sqlQuery, sizeof(sqlQuery),
1709 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
1710 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
1713 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1714 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1715 "(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) "
1717 "WHERE A.CONV_ID=B.CONV_ID "
1718 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1719 "AND B.STORAGE_ID = %d "
1720 "ORDER BY B.DISPLAY_TIME DESC;",
1723 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1724 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1725 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1728 snprintf(sqlQuery, sizeof(sqlQuery),
1735 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1736 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1738 "WHERE A.CONV_ID=B.CONV_ID "
1739 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1740 "AND B.STORAGE_ID = %d "
1741 "ORDER BY B.DISPLAY_TIME DESC;",
1744 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1748 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1750 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1751 if (msg_err != MSG_SUCCESS) {
1752 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1757 smsUnreadCnt = atoi(db_res[col_cnt+7]);
1758 mmsUnreadCnt = atoi(db_res[col_cnt+8]);
1759 msgSize = atoi(db_res[col_cnt+9]);
1761 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1763 if (noti_info->count > 0) {
1764 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1766 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1768 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1770 noti_info->conv_id = atoi(db_res[col_cnt+6]);
1772 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1774 if (mainType == MSG_MMS_TYPE) {
1775 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1776 if (noti_info->text[0] == '\0') {
1777 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1778 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1782 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1783 if (prefix_subject) {
1784 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1785 g_free(prefix_subject);
1787 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1791 int kb_msg_size = msgSize / 1024;
1792 if (kb_msg_size == 0 && msgSize > 0)
1794 else if (msgSize % 1024 >= 512)
1797 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1798 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1800 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1802 g_free(msg_size_string);
1803 g_free(msg_size_unit_kb);
1807 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1810 if (noti_info->active_text[0] == '\0')
1811 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1813 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1815 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1816 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1817 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1819 if (!isForInstantMessage) {
1820 if (noti_info->id > 0 && noti_info->count == 1) {
1821 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1822 if (noti_err != NOTIFICATION_ERROR_NONE) {
1823 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1827 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1828 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1831 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1832 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1833 MsgMgrInsertBadge(noti_info->count);
1834 MsgMgrSoundSetRepeatAlarm();
1837 MSG_MGR_DEBUG("No unread message.");
1838 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1840 msg_db_free(msg_handle, db_res);
1842 if (!isForInstantMessage) {
1843 /* No unread message. */
1844 if (noti_info->id > 0) {
1845 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1846 if (noti_err != NOTIFICATION_ERROR_NONE) {
1847 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1853 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1854 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1856 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1857 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1858 MsgMgrInsertBadge(0);
1859 MsgMgrSoundSetRepeatAlarm();
1865 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1866 msg_db_free(msg_handle, db_res);
1870 msg_db_free(msg_handle, db_res);
1874 #ifndef MSG_NOTI_INTEGRATION
1875 case MSG_MGR_NOTI_TYPE_CB: {
1876 char sqlQuery[MAX_QUERY_LEN+1];
1877 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1879 snprintf(sqlQuery, sizeof(sqlQuery),
1885 "WHERE A.CONV_ID=B.CONV_ID "
1886 "AND B.READ_STATUS=0 "
1887 "AND B.FOLDER_ID=%d "
1888 "AND B.STORAGE_ID = %d "
1889 "ORDER BY B.DISPLAY_TIME DESC;",
1890 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1894 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1895 return MSG_ERR_DB_PREPARE;
1897 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1898 MSG_ADDRESS_INFO_S addrInfo;
1899 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1901 if (dbhandler->columnText(0) != NULL)
1902 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1904 MSG_CONTACT_INFO_S tmpContact;
1905 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1907 MsgGetContactInfo(&addrInfo, &tmpContact);
1909 if (tmpContact.firstName[0] != '\0') {
1910 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1911 } else if (addrInfo.addressVal[0] == '\0') {
1912 char *senderStr = NULL;
1913 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1914 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1920 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1923 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1925 noti_info->time = (time_t)dbhandler->columnInt(1);
1927 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1929 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1931 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1933 MSG_MGR_DEBUG("No unread CB message.");
1934 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1936 dbhandler->finalizeQuery();
1938 if (!isForInstantMessage) {
1939 /* No unread message. */
1940 if (noti_info->id > 0) {
1941 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1942 if (noti_err != NOTIFICATION_ERROR_NONE) {
1943 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1949 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1950 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1952 return MSG_ERR_DB_STEP;
1955 dbhandler->finalizeQuery();
1957 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
1958 MSG_MGR_DEBUG("getTable is failed");
1959 dbhandler->freeTable();
1960 return MSG_ERR_DB_GETTABLE;
1963 dbhandler->freeTable();
1964 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
1967 case MSG_MGR_NOTI_TYPE_SIM: {
1968 char sqlQuery[MAX_QUERY_LEN+1];
1969 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1971 snprintf(sqlQuery, sizeof(sqlQuery),
1976 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
1978 "WHERE A.CONV_ID=B.CONV_ID "
1979 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1980 "AND B.STORAGE_ID = %d "
1981 "ORDER BY B.DISPLAY_TIME DESC;",
1983 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1987 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1989 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1990 return MSG_ERR_DB_PREPARE;
1992 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1993 noti_info->count = dbhandler->columnInt(4);
1995 if (noti_info->count > 0) {
1996 MSG_ADDRESS_INFO_S addrInfo;
1997 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1999 if (dbhandler->columnText(0) != NULL)
2000 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2002 MSG_CONTACT_INFO_S tmpContact;
2003 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2005 MsgGetContactInfo(&addrInfo, &tmpContact);
2007 if (tmpContact.firstName[0] != '\0') {
2008 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2009 } else if (addrInfo.addressVal[0] == '\0') {
2010 char *senderStr = NULL;
2011 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2012 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2018 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2021 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2023 noti_info->time = (time_t)dbhandler->columnInt(1);
2025 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2027 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2029 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
2031 MSG_MGR_DEBUG("No unread SIM message.");
2032 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2034 dbhandler->finalizeQuery();
2036 if (!isForInstantMessage) {
2037 /* No unread message. */
2038 if (noti_info->id > 0) {
2039 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2040 if (noti_err != NOTIFICATION_ERROR_NONE) {
2041 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2047 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2048 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2051 return MSG_ERR_DB_STEP;
2054 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2055 dbhandler->finalizeQuery();
2056 return MSG_ERR_DB_STEP;
2059 dbhandler->finalizeQuery();
2063 case MSG_MGR_NOTI_TYPE_FAILED: {
2064 char sqlQuery[MAX_QUERY_LEN+1];
2065 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2067 snprintf(sqlQuery, sizeof(sqlQuery),
2074 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2076 "WHERE A.CONV_ID=B.CONV_ID "
2077 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2078 "AND B.STORAGE_ID = %d "
2079 "ORDER BY B.DISPLAY_TIME DESC;",
2080 MSG_NETWORK_SEND_FAIL,
2081 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2085 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2087 row_cnt = 0, col_cnt = 0;
2088 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2089 if (msg_err != MSG_SUCCESS) {
2090 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2095 noti_info->count = atoi(db_res[col_cnt+6]);
2097 if (noti_info->count > 0) {
2098 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2100 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2102 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2104 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2106 if (tmpContact.firstName[0] != '\0') {
2107 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2108 } else if (addrInfo.addressVal[0] == '\0') {
2109 char *senderStr = NULL;
2110 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2111 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2117 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2120 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2122 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2124 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2126 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2128 if (mainType == MSG_TYPE_MMS)
2129 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2131 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2133 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2135 if (!isForInstantMessage) {
2136 if (noti_info->id > 0 && noti_info->count == 1) {
2137 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2138 if (noti_err != NOTIFICATION_ERROR_NONE) {
2139 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2142 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2143 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2147 MSG_MGR_DEBUG("No sent failed message.");
2148 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2150 msg_db_free(msg_handle, db_res);
2152 if (!isForInstantMessage) {
2153 /* No unread message. */
2154 if (noti_info->id > 0) {
2155 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2156 if (noti_err != NOTIFICATION_ERROR_NONE) {
2157 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2163 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2164 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2170 msg_db_free(msg_handle, db_res);
2174 msg_db_free(msg_handle, db_res);
2177 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2180 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2190 notification_h getHandle(int *noti_id)
2192 notification_h noti_h = NULL;
2195 MSG_MGR_DEBUG("Notification load");
2196 noti_h = notification_load(NULL, *noti_id);
2198 MSG_MGR_DEBUG("notification_load is failed.");
2201 if (noti_h == NULL) {
2202 MSG_MGR_DEBUG("Notification create");
2203 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2204 if (noti_h == NULL) {
2205 MSG_MGR_DEBUG("notification_create is failed.");
2216 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2222 switch (noti_type) {
2223 #ifdef MSG_NOTI_INTEGRATION
2224 case MSG_MGR_NOTI_TYPE_NORMAL:
2225 case MSG_MGR_NOTI_TYPE_SIM:
2226 case MSG_MGR_NOTI_TYPE_CB:
2227 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2230 case MSG_MGR_NOTI_TYPE_NORMAL:
2231 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2233 case MSG_MGR_NOTI_TYPE_SIM:
2234 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2236 case MSG_MGR_NOTI_TYPE_CB:
2237 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2240 case MSG_MGR_NOTI_TYPE_FAILED:
2241 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2243 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2244 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2245 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2246 vconf_get_int(keyName, ¬i_id);
2249 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2250 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2251 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2252 vconf_get_int(keyName, ¬i_id);
2255 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2256 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2259 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2263 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2271 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2277 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2279 switch (noti_type) {
2280 #ifdef MSG_NOTI_INTEGRATION
2281 case MSG_MGR_NOTI_TYPE_NORMAL:
2282 case MSG_MGR_NOTI_TYPE_SIM:
2283 case MSG_MGR_NOTI_TYPE_CB:
2284 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2287 case MSG_MGR_NOTI_TYPE_NORMAL:
2288 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2290 case MSG_MGR_NOTI_TYPE_SIM:
2291 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2293 case MSG_MGR_NOTI_TYPE_CB:
2294 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2297 case MSG_MGR_NOTI_TYPE_FAILED:
2298 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2300 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2301 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2302 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2303 err = vconf_set_int(keyName, noti_id);
2306 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2307 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2308 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2309 err = vconf_set_int(keyName, noti_id);
2312 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2313 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2316 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2321 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2327 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2332 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2333 noti_info->msg_id = msg_info->msgId;
2335 MSG_MGR_DEBUG("msg_info is NULL");
2339 noti_info->sim_idx = msg_info->sim_idx;
2341 createServiceHandle(¬i_info->svc_h);
2342 char keyName[MAX_VCONFKEY_NAME_LEN];
2344 switch (noti_info->type) {
2345 case MSG_MGR_NOTI_TYPE_VOICE_1:
2346 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2347 memset(keyName, 0x00, sizeof(keyName));
2348 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2349 vconf_get_int(keyName, ¬i_info->count);
2350 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2351 noti_info->time = msg_info->displayTime;
2353 memset(keyName, 0x00, sizeof(keyName));
2354 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2355 char *voiceNumber = vconf_get_str(keyName);
2356 memset(keyName, 0x00, sizeof(keyName));
2357 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2358 char *voiceAlphaId = vconf_get_str(keyName);
2359 char *dialNumber = NULL;
2361 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2363 if (voiceNumber && strlen(voiceNumber))
2364 dialNumber = voiceNumber;
2366 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2367 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2368 } else if (dialNumber && strlen(dialNumber) > 0) {
2369 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2372 if (dialNumber && strlen(dialNumber) > 0)
2373 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2375 if (noti_info->svc_h) {
2376 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2377 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2379 char slot_id[5] = {0, };
2380 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2381 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2384 if (voiceNumber) g_free(voiceNumber);
2385 if (voiceAlphaId) g_free(voiceAlphaId);
2388 case MSG_MGR_NOTI_TYPE_MWI:
2389 case MSG_MGR_NOTI_TYPE_CLASS0: {
2390 noti_info->count = 1;
2391 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2392 noti_info->time = msg_info->displayTime;
2394 if (msg_info->displayName[0] == '\0')
2395 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2397 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2399 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2401 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2403 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2404 if (noti_info->svc_h) {
2405 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2406 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2408 char slot_id[5] = {0, };
2409 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2410 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2414 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2415 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2416 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2420 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2421 noti_info->count = 1;
2422 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2423 noti_info->time = msg_info->displayTime;
2424 noti_info->extra_data = msg_info->networkStatus;
2426 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2427 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2428 if (msg_info->addressVal[0] != '\0') {
2429 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2430 if (_is_valid_email(msg_info->addressVal)) {
2431 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2433 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2437 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2438 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2441 if (contactInfo.firstName[0] == '\0')
2442 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2444 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2446 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2448 if (noti_info->msg_id > 0) {
2449 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2450 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2451 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2452 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2456 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2457 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2458 noti_info->count = 1;
2459 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2460 noti_info->time = msg_info->displayTime;
2462 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2463 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2464 if (msg_info->addressVal[0] != '\0') {
2465 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2466 if (_is_valid_email(msg_info->addressVal)) {
2467 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2469 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2473 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2474 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2476 if (contactInfo.firstName[0] == '\0')
2477 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2479 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2481 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2483 char sqlQuery[MAX_QUERY_LEN+1];
2484 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2486 int report_status_type;
2487 int report_status_value;
2489 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2490 report_status_type = MSG_REPORT_TYPE_READ;
2492 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2495 snprintf(sqlQuery, sizeof(sqlQuery),
2498 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE \"%%%s\";",
2499 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2501 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2503 char **db_res = NULL;
2504 int row_cnt = 0, col_cnt = 0;
2506 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2507 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2508 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2512 report_status_value = atoi(db_res[col_cnt]);
2514 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2516 msg_err = msg_db_free(msg_handle, db_res);
2517 if (msg_err != MSG_SUCCESS) {
2518 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2522 if (noti_info->msg_id > 0) {
2523 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2524 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2525 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2526 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2529 noti_info->extra_data = (unsigned char)report_status_value;
2533 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2537 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2542 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2546 createServiceHandle(¬i_info->svc_h);
2548 switch (noti_info->type) {
2549 case MSG_MGR_NOTI_TYPE_NORMAL: {
2550 if (noti_info->count > 1) {
2551 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2553 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2556 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2557 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2558 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2559 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2561 if (noti_info->active_noti_button_num == 0)
2562 noti_info->active_noti_button_num = 3;
2564 int activated_conv_id = -1;
2565 vconf_get_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, &activated_conv_id);
2567 if (activated_conv_id == -1) {
2568 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2569 } else if (activated_conv_id == 0) {
2570 noti_info->active_noti_button_num = 0;
2571 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2572 } else if (activated_conv_id > 0){
2573 noti_info->active_noti_button_num = 0;
2575 if (activated_conv_id != noti_info->conv_id)
2576 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2578 MSG_MGR_WARN("No adding Notification : activated conv id [%d] / notification conv id [%d]", activated_conv_id, noti_info->conv_id);
2583 case MSG_MGR_NOTI_TYPE_CB: {
2584 if (noti_info->count > 1) {
2585 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2587 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2590 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2591 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2592 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2594 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2595 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2597 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2599 noti_info->active_noti_button_num = 1;
2602 case MSG_MGR_NOTI_TYPE_SIM: {
2603 if (noti_info->count > 1) {
2604 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2606 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2609 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2610 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2611 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2613 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2614 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2616 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2618 if (noti_info->active_noti_button_num == 0)
2619 noti_info->active_noti_button_num = 3;
2622 case MSG_MGR_NOTI_TYPE_FAILED: {
2623 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2625 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2626 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2627 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2629 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2632 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2633 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2635 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2636 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2638 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2645 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2646 noti_info->active_noti_button_num = 0;
2652 void createServiceHandle(app_control_h *svc_h)
2654 int svc_err = APP_CONTROL_ERROR_NONE;
2656 svc_err = app_control_create(svc_h);
2658 if (svc_err != APP_CONTROL_ERROR_NONE)
2659 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2663 void setServiceAppId(app_control_h svc_h, const char* app_id)
2665 int svc_err = APP_CONTROL_ERROR_NONE;
2667 svc_err = app_control_set_app_id(svc_h, app_id);
2669 if (svc_err != APP_CONTROL_ERROR_NONE)
2670 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2674 void setServiceUri(app_control_h svc_h, const char* uri)
2676 int svc_err = APP_CONTROL_ERROR_NONE;
2678 svc_err = app_control_set_uri(svc_h, uri);
2680 if (svc_err != APP_CONTROL_ERROR_NONE)
2681 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2685 void setServiceOperation(app_control_h svc_h, const char* operation)
2687 int svc_err = APP_CONTROL_ERROR_NONE;
2689 svc_err = app_control_set_operation(svc_h, operation);
2691 if (svc_err != APP_CONTROL_ERROR_NONE)
2692 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2696 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2698 int svc_err = APP_CONTROL_ERROR_NONE;
2700 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2702 if (svc_err != APP_CONTROL_ERROR_NONE)
2703 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2707 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2709 int svc_err = APP_CONTROL_ERROR_NONE;
2712 memset(&tempId, 0x00, sizeof(tempId));
2713 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2715 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2717 if (svc_err != APP_CONTROL_ERROR_NONE)
2718 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2722 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2724 int svc_err = APP_CONTROL_ERROR_NONE;
2726 svc_err = app_control_set_app_id(svc_h, pkg_name);
2728 if (svc_err != APP_CONTROL_ERROR_NONE)
2729 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2733 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2735 int svc_err = APP_CONTROL_ERROR_NONE;
2737 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2739 if (svc_err != APP_CONTROL_ERROR_NONE)
2740 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2744 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2746 int noti_err = NOTIFICATION_ERROR_NONE;
2748 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2749 if (noti_err != NOTIFICATION_ERROR_NONE)
2750 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2754 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2756 int noti_err = NOTIFICATION_ERROR_NONE;
2758 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2760 if (noti_err != NOTIFICATION_ERROR_NONE)
2761 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2765 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2767 int noti_err = NOTIFICATION_ERROR_NONE;
2769 noti_err = notification_set_time_to_text(noti_h, type, time);
2771 if (noti_err != NOTIFICATION_ERROR_NONE)
2772 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2776 void setNotiTime(notification_h noti_h, time_t time)
2778 int noti_err = NOTIFICATION_ERROR_NONE;
2780 noti_err = notification_set_time(noti_h, time);
2782 if (noti_err != NOTIFICATION_ERROR_NONE)
2783 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2788 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2790 int noti_err = NOTIFICATION_ERROR_NONE;
2792 noti_err = notification_set_image(noti_h, type, image_path);
2794 if (noti_err != NOTIFICATION_ERROR_NONE)
2795 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2799 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2801 int noti_err = NOTIFICATION_ERROR_NONE;
2803 noti_err = notification_set_sound(noti_h, type, path);
2805 if (noti_err != NOTIFICATION_ERROR_NONE)
2806 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2810 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2812 int noti_err = NOTIFICATION_ERROR_NONE;
2814 noti_err = notification_set_vibration(noti_h, type, path);
2816 if (noti_err != NOTIFICATION_ERROR_NONE)
2817 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2821 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2823 int noti_err = NOTIFICATION_ERROR_NONE;
2825 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2827 if (noti_err != NOTIFICATION_ERROR_NONE)
2828 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2832 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2836 char *notiMsg = NULL;
2838 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2840 switch (noti_type) {
2841 case MSG_MGR_NOTI_TYPE_NORMAL:
2842 case MSG_MGR_NOTI_TYPE_SIM:
2843 case MSG_MGR_NOTI_TYPE_CB: {
2844 MSG_MGR_NOTI_INFO_S noti_info;
2845 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2847 noti_info.type = noti_type;
2848 int err = getLatestMsgInfo(¬i_info, true);
2851 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2852 if (noti_info.count == 1) {
2853 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2854 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2855 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2856 } else if (noti_info.count > 1) {
2857 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2859 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
2860 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2861 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2862 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2867 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2871 case MSG_MGR_NOTI_TYPE_FAILED: {
2872 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2873 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2874 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2878 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2879 goto _END_OF_INSTANT_NOTI;
2883 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2884 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2886 if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
2887 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
2889 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2890 MSG_MGR_DEBUG("Fail to notification_post");
2892 _END_OF_INSTANT_NOTI:
2894 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2895 MSG_MGR_DEBUG("Fail to notification_delete");
2902 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2903 MSG_MGR_DEBUG("Fail to notification_free");
2912 bool MsgMgrCheckNotificationSettingEnable()
2914 bool msg_noti_enabled = false;
2915 notification_system_setting_h system_setting = NULL;
2916 notification_setting_h setting = NULL;
2918 int err = NOTIFICATION_ERROR_NONE;
2920 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
2922 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
2923 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2925 msg_noti_enabled = true;
2927 bool allow_to_notify = false;
2928 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
2930 if (err != NOTIFICATION_ERROR_NONE) {
2931 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2935 if (allow_to_notify) {
2936 MSG_MGR_DEBUG("message notification is allowed");
2938 /* check do not disturb mode */
2939 err = notification_system_setting_load_system_setting(&system_setting);
2941 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
2942 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
2946 bool do_not_disturb_mode = false;
2947 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
2949 if (err != NOTIFICATION_ERROR_NONE) {
2950 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2954 if (do_not_disturb_mode) {
2955 bool is_msg_excepted = false;
2956 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
2957 if (err != NOTIFICATION_ERROR_NONE) {
2958 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2959 msg_noti_enabled = false;
2961 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
2962 msg_noti_enabled = (is_msg_excepted) ? true : false;
2965 MSG_MGR_DEBUG("do not disturb mode is off");
2968 MSG_MGR_INFO("message notification is not allowed");
2969 msg_noti_enabled = false;
2975 notification_system_setting_free_system_setting(system_setting);
2978 notification_setting_free_notification(setting);
2980 return msg_noti_enabled;
2984 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
2986 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
2987 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
2989 MsgMgrChangePmState();
2991 char *notiMsg = NULL;
2992 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
2995 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
2996 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
2998 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
2999 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
3000 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
3001 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
3002 notification_status_message_post(pTickerMsg);
3004 notification_status_message_post(notiMsg);
3007 /* Show ticker popup for sending failed msg. */
3008 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
3016 if (bPlayFeedback) {
3018 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
3019 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
3021 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
3023 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
3024 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
3026 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
3029 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
3037 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
3039 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
3041 int err = BADGE_ERROR_NONE;
3044 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
3046 if (err != BADGE_ERROR_NONE) {
3047 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
3053 err = badge_add(MSG_DEFAULT_APP_ID);
3054 if (err != BADGE_ERROR_NONE) {
3055 MSG_MGR_ERR("Fail to badge_add : %d", err);
3060 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
3062 if (err != BADGE_ERROR_NONE) {
3063 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3071 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3075 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3077 #ifndef MSG_NOTI_INTEGRATION
3078 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3079 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3087 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3093 struct tm repeat_tm;
3097 tmp_time += (RepeatTime*60);
3099 localtime_r(&tmp_time, &repeat_tm);
3101 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3102 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3106 g_alarmId = tmpAlarmId;
3107 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3115 void MsgMgrSoundSetRepeatAlarm()
3117 int nRepeatValue = 0;
3118 long nRepeatTime = 0;
3120 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3121 MSG_MGR_INFO("vconf_get_int() is failed");
3124 switch (nRepeatValue) {
3125 case MSG_ALERT_TONE_ONCE:
3128 case MSG_ALERT_TONE_2MINS:
3131 case MSG_ALERT_TONE_5MINS:
3134 case MSG_ALERT_TONE_10MINS:
3138 MSG_MGR_DEBUG("Invalid Repetition time");
3142 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3144 if (nRepeatTime > 0) {
3145 if (g_alarmId > 0) {
3146 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3147 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3151 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3158 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3160 char *notiMsg = NULL;
3163 lang = vconf_get_str(VCONFKEY_LANGSET);
3165 setlocale(LC_MESSAGES, lang);
3167 bindtextdomain(pkg_name, locale_dir);
3169 notiMsg = dgettext(pkg_name, text);
3176 return g_strdup(notiMsg);