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 if (noti_info->active_text[0] != '\0') {
1114 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1116 if (noti_info->active_media_cnt > 1) {
1117 char attach_string[20] = {0,};
1118 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1119 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
1120 } else if (noti_info->active_media_cnt == 1) {
1121 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
1125 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1126 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1127 if (noti_info->active_text[0] != '\0') {
1128 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1130 if (noti_info->active_media_cnt > 1) {
1131 char attach_string[20] = {0,};
1132 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1133 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
1134 } else if (noti_info->active_media_cnt == 1) {
1135 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
1141 case MSG_MGR_NOTI_TYPE_CLASS0: {
1142 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1143 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1147 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1155 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1159 switch (noti_info->type) {
1160 case MSG_MGR_NOTI_TYPE_NORMAL:
1161 case MSG_MGR_NOTI_TYPE_SIM: {
1162 switch (noti_info->active_subtype) {
1164 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1166 case MSG_WAP_SI_SMS:
1167 case MSG_WAP_SL_SMS:
1168 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1171 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1174 if (noti_info->imagePath[0] != '\0')
1175 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1177 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1179 char *msg_icon_path = NULL;
1180 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1181 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1182 g_free(msg_icon_path);
1184 MSG_MGR_ERR("fail to get message-app icon");
1192 case MSG_MGR_NOTI_TYPE_CB: {
1193 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1196 case MSG_MGR_NOTI_TYPE_CLASS0:
1197 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1200 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1208 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result)
1212 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
1213 notification_set_pkgname(noti, MSG_DEFAULT_APP_ID);
1215 setTextDomain(noti);
1216 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
1217 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVER_REPORT_STATUS_ICON);
1219 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT) {
1220 if (result == MSG_NETWORK_DELIVER_SUCCESS) {
1221 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1222 } else if (result == MSG_NETWORK_DELIVER_EXPIRED) {
1223 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1224 } else if (result == MSG_NETWORK_DELIVER_PENDING) {
1225 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1227 MSG_MGR_ERR("unexpected result! [%d]", result);
1228 goto _END_OF_INSTANT_DELIVERY_REPORT_NOTI;
1230 } else if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
1231 if (result == MSG_DELIVERY_REPORT_EXPIRED)
1232 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1233 else if (result== MSG_DELIVERY_REPORT_REJECTED)
1234 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message rejected by recipient.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_REJECTED);
1235 else if (result == MSG_DELIVERY_REPORT_DEFERRED)
1236 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1237 else if (result == MSG_DELIVERY_REPORT_UNRECOGNISED || result == MSG_DELIVERY_REPORT_INDETERMINATE ||
1238 result == MSG_DELIVERY_REPORT_FORWARDED || result == MSG_DELIVERY_REPORT_UNREACHABLE ||
1239 result == MSG_DELIVERY_REPORT_ERROR)
1240 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Recipient not available.", UNABLE_TO_DELIVER_MESSAGE_RECIPIENT_NOT_AVAILABLE);
1242 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1245 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
1246 MSG_MGR_ERR("Fail to notification_set_display_applist");
1248 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
1249 MSG_MGR_ERR("Fail to notification_post");
1251 _END_OF_INSTANT_DELIVERY_REPORT_NOTI:
1253 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
1254 MSG_MGR_ERR("Fail to notification_delete");
1257 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
1258 MSG_MGR_ERR("Fail to notification_free");
1267 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1271 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1272 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1274 if (addressVal != NULL) {
1275 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1276 /* Get Contact Info */
1277 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1278 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1281 MSG_MGR_DEBUG("addressVal is NULL.");
1284 char *msg_tone_file_path = NULL;
1286 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1288 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1290 bool bPlaySound = false;
1291 bool bPlayVibration = false;
1292 bool bOnCall = false;
1294 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1297 if (msg_tone_file_path) {
1298 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1301 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1302 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1304 int ringtoneType = tmpVal;
1305 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1306 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1308 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1311 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1314 if (bPlayVibration) {
1315 if (contactInfo.vibrationPath[0] == '\0')
1316 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1318 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1320 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1323 if (msg_tone_file_path)
1324 delete [] msg_tone_file_path;
1330 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1334 int noti_err = NOTIFICATION_ERROR_NONE;
1336 if (noti_info->active_noti_button_num > 1) {
1337 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1338 if (noti_info->active_noti_svc_h[0]) {
1339 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1340 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1342 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1344 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1345 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1346 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1347 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1350 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1351 if (noti_info->active_noti_svc_h[1]) {
1352 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1354 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1355 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1356 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1358 char slot_id[5] = {0, };
1359 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1360 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1364 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1365 if (noti_info->active_noti_svc_h[2]) {
1366 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1368 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1369 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1370 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1371 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1373 char slot_id[5] = {0, };
1374 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1375 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1378 if (noti_info->active_noti_button_num > 1) {
1379 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1380 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1381 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1383 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1384 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1385 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1387 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1389 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1392 setActiveProperty(noti_h, noti_info);
1394 setTextDomain(noti_h);
1396 setActiveText(noti_h, noti_info);
1398 setActiveIcon(noti_h, noti_info);
1400 noti_err = notification_post(noti_h);
1401 if (noti_err != NOTIFICATION_ERROR_NONE) {
1402 MSG_MGR_DEBUG("Fail to notification_post");
1409 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1413 int noti_err = NOTIFICATION_ERROR_NONE;
1415 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1417 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1418 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1419 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1421 setActiveNotification(active_noti_h, noti_info);
1423 notification_free(active_noti_h);
1424 active_noti_h = NULL;
1427 setProperty(noti_h, noti_info);
1429 setTextDomain(noti_h);
1431 setText(noti_h, noti_info);
1433 setIcon(noti_h, noti_info);
1436 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1437 setSoundAndVibration(noti_h, noti_info->number, true);
1439 setSoundAndVibration(noti_h, noti_info->number, false);
1442 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1443 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1446 if (noti_info->id > 0) {
1447 MSG_MGR_DEBUG("Notification update");
1448 noti_err = notification_update(noti_h);
1449 if (noti_err != NOTIFICATION_ERROR_NONE) {
1450 MSG_MGR_DEBUG("Fail to notification_update");
1453 MSG_MGR_DEBUG("Notification insert");
1454 noti_err = notification_insert(noti_h, ¬i_info->id);
1455 if (noti_err != NOTIFICATION_ERROR_NONE) {
1456 MSG_MGR_DEBUG("Fail to notification_insert");
1459 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1466 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1471 MSG_MGR_DEBUG("msg_info is NULL");
1475 noti_info->msg_id = msg_info->msgId;
1476 noti_info->sim_idx = msg_info->sim_idx;
1478 switch (noti_info->type) {
1479 case MSG_MGR_NOTI_TYPE_NORMAL: {
1480 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1481 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1488 case MSG_MGR_NOTI_TYPE_CLASS0: {
1489 if (msg_info->displayName[0] == '\0')
1490 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1492 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1494 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1498 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1506 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1511 notification_free(noti_h);
1515 if (noti_info->svc_h) {
1516 app_control_destroy(noti_info->svc_h);
1517 noti_info->svc_h = NULL;
1520 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1521 if (noti_info->active_noti_svc_h[i]) {
1522 app_control_destroy(noti_info->active_noti_svc_h[i]);
1523 noti_info->active_noti_svc_h[i] = NULL;
1531 int getAppIcon(const char *app_id, char **icon_path)
1535 package_info_h pkg_info_h = NULL;
1536 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1539 if (app_id == NULL) {
1540 MSG_MGR_ERR("app id is NULL");
1542 goto END_OF_GET_APP_ICON;
1545 pkg_err = package_info_create(app_id, &pkg_info_h);
1546 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1547 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1549 goto END_OF_GET_APP_ICON;
1552 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1553 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1554 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1557 if (icon_path == NULL) {
1558 MSG_MGR_WARN("icon path is NULL");
1563 END_OF_GET_APP_ICON:
1565 pkg_err = package_info_destroy(pkg_info_h);
1566 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1567 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1579 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1584 msg_error_t msg_err = MSG_SUCCESS;
1585 char **db_res = NULL;
1586 int row_cnt = 0, col_cnt = 0;
1588 switch (noti_info->type) {
1589 case MSG_MGR_NOTI_TYPE_NORMAL:
1590 #ifdef MSG_NOTI_INTEGRATION
1591 case MSG_MGR_NOTI_TYPE_CB:
1592 case MSG_MGR_NOTI_TYPE_SIM:
1595 int smsUnreadCnt = 0;
1596 int mmsUnreadCnt = 0;
1598 char sqlQuery[MAX_QUERY_LEN +1];
1599 unsigned char mainType;
1600 unsigned char subType;
1601 int msgSize, attachmentCnt;
1603 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1604 #ifdef MSG_NOTI_INTEGRATION
1605 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1609 "WHERE A.CONV_ID=B.CONV_ID "
1610 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1611 "AND B.STORAGE_ID = %d "
1612 "GROUP BY A.ADDRESS_VAL "
1613 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1614 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1615 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1618 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1622 "WHERE A.CONV_ID=B.CONV_ID "
1623 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1624 "AND B.STORAGE_ID = %d "
1625 "GROUP BY A.ADDRESS_VAL "
1626 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1627 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1631 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1633 row_cnt = 0, col_cnt = 0;
1634 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1635 if (msg_err != MSG_SUCCESS) {
1636 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1640 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1641 int normalAddCnt = 0;
1642 int index = col_cnt;
1644 for (int i = 1; i <= row_cnt; i++) {
1645 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1647 char *address = db_res[index++];
1650 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1651 if (_is_valid_email(address)) {
1652 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1654 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1657 subType = atoi(db_res[index++]);
1659 MSG_MGR_CONTACT_INFO_S tmpContact;
1660 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1662 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1665 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1668 if (normalAddCnt > 1) {
1669 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1672 if (tmpContact.firstName[0] != '\0') {
1673 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1674 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1675 char *senderStr = NULL;
1676 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1677 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1684 noti_info->active_noti_button_num = 1;
1687 char *senderStr = NULL;
1688 if (subType == MSG_CB_SMS) {
1689 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1690 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1691 noti_info->active_noti_button_num = 1;
1692 } else if (subType == MSG_SYNCML_CP) {
1693 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1694 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1695 noti_info->active_noti_button_num = 1;
1696 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1697 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1698 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1699 noti_info->active_noti_button_num = 1;
1701 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1711 noti_info->active_subtype = subType;
1712 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1713 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1717 noti_info->senderCount = normalAddCnt;
1718 msg_db_free(msg_handle, db_res);
1720 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1722 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1724 #ifdef MSG_NOTI_INTEGRATION
1725 snprintf(sqlQuery, sizeof(sqlQuery),
1729 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
1730 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
1733 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1734 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1735 "(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), "
1736 "B.ATTACHMENT_COUNT "
1738 "WHERE A.CONV_ID=B.CONV_ID "
1739 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1740 "AND B.STORAGE_ID = %d "
1741 "ORDER BY B.DISPLAY_TIME DESC;",
1744 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1745 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1746 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1749 snprintf(sqlQuery, sizeof(sqlQuery),
1756 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1757 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1759 "WHERE A.CONV_ID=B.CONV_ID "
1760 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1761 "AND B.STORAGE_ID = %d "
1762 "ORDER BY B.DISPLAY_TIME DESC;",
1765 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1769 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1771 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1772 if (msg_err != MSG_SUCCESS) {
1773 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1778 smsUnreadCnt = atoi(db_res[col_cnt+7]);
1779 mmsUnreadCnt = atoi(db_res[col_cnt+8]);
1780 msgSize = atoi(db_res[col_cnt+9]);
1781 attachmentCnt = atoi(db_res[col_cnt+10]);
1783 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1785 if (noti_info->count > 0) {
1786 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1788 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1790 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1792 noti_info->conv_id = atoi(db_res[col_cnt+6]);
1794 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1796 if (mainType == MSG_MMS_TYPE) {
1797 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1798 if (noti_info->text[0] == '\0') {
1799 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1800 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1804 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1805 if (prefix_subject) {
1806 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1807 g_free(prefix_subject);
1809 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1813 int kb_msg_size = msgSize / 1024;
1814 if (kb_msg_size == 0 && msgSize > 0)
1816 else if (msgSize % 1024 >= 512)
1819 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1820 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1822 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1824 g_free(msg_size_string);
1825 g_free(msg_size_unit_kb);
1828 noti_info->active_media_cnt = attachmentCnt;
1831 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1834 if (noti_info->active_text[0] == '\0')
1835 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1837 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1839 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1840 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1841 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1843 if (!isForInstantMessage) {
1844 if (noti_info->id > 0 && noti_info->count == 1) {
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);
1851 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1852 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1855 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1856 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1857 MsgMgrInsertBadge(noti_info->count);
1858 MsgMgrSoundSetRepeatAlarm();
1861 MSG_MGR_DEBUG("No unread message.");
1862 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1864 msg_db_free(msg_handle, db_res);
1866 if (!isForInstantMessage) {
1867 /* No unread message. */
1868 if (noti_info->id > 0) {
1869 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1870 if (noti_err != NOTIFICATION_ERROR_NONE) {
1871 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1877 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1878 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1880 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1881 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1882 MsgMgrInsertBadge(0);
1883 MsgMgrSoundSetRepeatAlarm();
1889 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1890 msg_db_free(msg_handle, db_res);
1894 msg_db_free(msg_handle, db_res);
1898 #ifndef MSG_NOTI_INTEGRATION
1899 case MSG_MGR_NOTI_TYPE_CB: {
1900 char sqlQuery[MAX_QUERY_LEN+1];
1901 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1903 snprintf(sqlQuery, sizeof(sqlQuery),
1909 "WHERE A.CONV_ID=B.CONV_ID "
1910 "AND B.READ_STATUS=0 "
1911 "AND B.FOLDER_ID=%d "
1912 "AND B.STORAGE_ID = %d "
1913 "ORDER BY B.DISPLAY_TIME DESC;",
1914 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1918 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1919 return MSG_ERR_DB_PREPARE;
1921 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1922 MSG_ADDRESS_INFO_S addrInfo;
1923 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1925 if (dbhandler->columnText(0) != NULL)
1926 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1928 MSG_CONTACT_INFO_S tmpContact;
1929 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1931 MsgGetContactInfo(&addrInfo, &tmpContact);
1933 if (tmpContact.firstName[0] != '\0') {
1934 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1935 } else if (addrInfo.addressVal[0] == '\0') {
1936 char *senderStr = NULL;
1937 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1938 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1944 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1947 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1949 noti_info->time = (time_t)dbhandler->columnInt(1);
1951 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1953 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1955 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1957 MSG_MGR_DEBUG("No unread CB message.");
1958 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1960 dbhandler->finalizeQuery();
1962 if (!isForInstantMessage) {
1963 /* No unread message. */
1964 if (noti_info->id > 0) {
1965 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1966 if (noti_err != NOTIFICATION_ERROR_NONE) {
1967 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1973 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1974 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1976 return MSG_ERR_DB_STEP;
1979 dbhandler->finalizeQuery();
1981 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
1982 MSG_MGR_DEBUG("getTable is failed");
1983 dbhandler->freeTable();
1984 return MSG_ERR_DB_GETTABLE;
1987 dbhandler->freeTable();
1988 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
1991 case MSG_MGR_NOTI_TYPE_SIM: {
1992 char sqlQuery[MAX_QUERY_LEN+1];
1993 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1995 snprintf(sqlQuery, sizeof(sqlQuery),
2000 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
2002 "WHERE A.CONV_ID=B.CONV_ID "
2003 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2004 "AND B.STORAGE_ID = %d "
2005 "ORDER BY B.DISPLAY_TIME DESC;",
2007 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2011 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2013 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
2014 return MSG_ERR_DB_PREPARE;
2016 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
2017 noti_info->count = dbhandler->columnInt(4);
2019 if (noti_info->count > 0) {
2020 MSG_ADDRESS_INFO_S addrInfo;
2021 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
2023 if (dbhandler->columnText(0) != NULL)
2024 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2026 MSG_CONTACT_INFO_S tmpContact;
2027 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2029 MsgGetContactInfo(&addrInfo, &tmpContact);
2031 if (tmpContact.firstName[0] != '\0') {
2032 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2033 } else if (addrInfo.addressVal[0] == '\0') {
2034 char *senderStr = NULL;
2035 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2036 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2042 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2045 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2047 noti_info->time = (time_t)dbhandler->columnInt(1);
2049 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2051 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2053 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
2055 MSG_MGR_DEBUG("No unread SIM message.");
2056 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2058 dbhandler->finalizeQuery();
2060 if (!isForInstantMessage) {
2061 /* No unread message. */
2062 if (noti_info->id > 0) {
2063 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2064 if (noti_err != NOTIFICATION_ERROR_NONE) {
2065 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2071 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2072 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2075 return MSG_ERR_DB_STEP;
2078 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2079 dbhandler->finalizeQuery();
2080 return MSG_ERR_DB_STEP;
2083 dbhandler->finalizeQuery();
2087 case MSG_MGR_NOTI_TYPE_FAILED: {
2088 char sqlQuery[MAX_QUERY_LEN+1];
2089 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2091 snprintf(sqlQuery, sizeof(sqlQuery),
2098 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2100 "WHERE A.CONV_ID=B.CONV_ID "
2101 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2102 "AND B.STORAGE_ID = %d "
2103 "ORDER BY B.DISPLAY_TIME DESC;",
2104 MSG_NETWORK_SEND_FAIL,
2105 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2109 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2111 row_cnt = 0, col_cnt = 0;
2112 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2113 if (msg_err != MSG_SUCCESS) {
2114 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2119 noti_info->count = atoi(db_res[col_cnt+6]);
2121 if (noti_info->count > 0) {
2122 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2124 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2126 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2128 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2130 if (tmpContact.firstName[0] != '\0') {
2131 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2132 } else if (addrInfo.addressVal[0] == '\0') {
2133 char *senderStr = NULL;
2134 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2135 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2141 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2144 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2146 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2148 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2150 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2152 if (mainType == MSG_TYPE_MMS)
2153 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2155 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2157 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2159 if (!isForInstantMessage) {
2160 if (noti_info->id > 0 && noti_info->count == 1) {
2161 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2162 if (noti_err != NOTIFICATION_ERROR_NONE) {
2163 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2166 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2167 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2171 MSG_MGR_DEBUG("No sent failed message.");
2172 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2174 msg_db_free(msg_handle, db_res);
2176 if (!isForInstantMessage) {
2177 /* No unread message. */
2178 if (noti_info->id > 0) {
2179 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2180 if (noti_err != NOTIFICATION_ERROR_NONE) {
2181 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2187 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2188 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2194 msg_db_free(msg_handle, db_res);
2198 msg_db_free(msg_handle, db_res);
2201 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2204 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2214 notification_h getHandle(int *noti_id)
2216 notification_h noti_h = NULL;
2219 MSG_MGR_DEBUG("Notification load");
2220 noti_h = notification_load(NULL, *noti_id);
2222 MSG_MGR_DEBUG("notification_load is failed.");
2225 if (noti_h == NULL) {
2226 MSG_MGR_DEBUG("Notification create");
2227 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2228 if (noti_h == NULL) {
2229 MSG_MGR_DEBUG("notification_create is failed.");
2240 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2246 switch (noti_type) {
2247 #ifdef MSG_NOTI_INTEGRATION
2248 case MSG_MGR_NOTI_TYPE_NORMAL:
2249 case MSG_MGR_NOTI_TYPE_SIM:
2250 case MSG_MGR_NOTI_TYPE_CB:
2251 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2254 case MSG_MGR_NOTI_TYPE_NORMAL:
2255 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2257 case MSG_MGR_NOTI_TYPE_SIM:
2258 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2260 case MSG_MGR_NOTI_TYPE_CB:
2261 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2264 case MSG_MGR_NOTI_TYPE_FAILED:
2265 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2267 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2268 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2269 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2270 vconf_get_int(keyName, ¬i_id);
2273 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2274 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2275 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2276 vconf_get_int(keyName, ¬i_id);
2279 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2280 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2283 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2287 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2295 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2301 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2303 switch (noti_type) {
2304 #ifdef MSG_NOTI_INTEGRATION
2305 case MSG_MGR_NOTI_TYPE_NORMAL:
2306 case MSG_MGR_NOTI_TYPE_SIM:
2307 case MSG_MGR_NOTI_TYPE_CB:
2308 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2311 case MSG_MGR_NOTI_TYPE_NORMAL:
2312 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2314 case MSG_MGR_NOTI_TYPE_SIM:
2315 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2317 case MSG_MGR_NOTI_TYPE_CB:
2318 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2321 case MSG_MGR_NOTI_TYPE_FAILED:
2322 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2324 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2325 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2326 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2327 err = vconf_set_int(keyName, noti_id);
2330 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2331 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2332 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2333 err = vconf_set_int(keyName, noti_id);
2336 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2337 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2340 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2345 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2351 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2356 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2357 noti_info->msg_id = msg_info->msgId;
2359 MSG_MGR_DEBUG("msg_info is NULL");
2363 noti_info->sim_idx = msg_info->sim_idx;
2365 createServiceHandle(¬i_info->svc_h);
2366 char keyName[MAX_VCONFKEY_NAME_LEN];
2368 switch (noti_info->type) {
2369 case MSG_MGR_NOTI_TYPE_VOICE_1:
2370 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2371 memset(keyName, 0x00, sizeof(keyName));
2372 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2373 vconf_get_int(keyName, ¬i_info->count);
2374 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2375 noti_info->time = msg_info->displayTime;
2377 memset(keyName, 0x00, sizeof(keyName));
2378 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2379 char *voiceNumber = vconf_get_str(keyName);
2380 memset(keyName, 0x00, sizeof(keyName));
2381 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2382 char *voiceAlphaId = vconf_get_str(keyName);
2383 char *dialNumber = NULL;
2385 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2387 if (voiceNumber && strlen(voiceNumber))
2388 dialNumber = voiceNumber;
2390 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2391 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2392 } else if (dialNumber && strlen(dialNumber) > 0) {
2393 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2396 if (dialNumber && strlen(dialNumber) > 0)
2397 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2399 if (noti_info->svc_h) {
2400 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2401 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2403 char slot_id[5] = {0, };
2404 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2405 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2408 if (voiceNumber) g_free(voiceNumber);
2409 if (voiceAlphaId) g_free(voiceAlphaId);
2412 case MSG_MGR_NOTI_TYPE_MWI:
2413 case MSG_MGR_NOTI_TYPE_CLASS0: {
2414 noti_info->count = 1;
2415 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2416 noti_info->time = msg_info->displayTime;
2418 if (msg_info->displayName[0] == '\0')
2419 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2421 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2423 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2425 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2427 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2428 if (noti_info->svc_h) {
2429 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2430 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2432 char slot_id[5] = {0, };
2433 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2434 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2438 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2439 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2440 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2444 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2445 noti_info->count = 1;
2446 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2447 noti_info->time = msg_info->displayTime;
2448 noti_info->extra_data = msg_info->networkStatus;
2450 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2451 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2452 if (msg_info->addressVal[0] != '\0') {
2453 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2454 if (_is_valid_email(msg_info->addressVal)) {
2455 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2457 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2461 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2462 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2465 if (contactInfo.firstName[0] == '\0')
2466 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2468 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2470 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2472 if (noti_info->msg_id > 0) {
2473 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2474 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2475 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2476 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2480 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2481 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2482 noti_info->count = 1;
2483 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2484 noti_info->time = msg_info->displayTime;
2486 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2487 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2488 if (msg_info->addressVal[0] != '\0') {
2489 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2490 if (_is_valid_email(msg_info->addressVal)) {
2491 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2493 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2497 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2498 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2500 if (contactInfo.firstName[0] == '\0')
2501 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2503 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2505 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2507 char sqlQuery[MAX_QUERY_LEN+1];
2508 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2510 int report_status_type;
2511 int report_status_value;
2513 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2514 report_status_type = MSG_REPORT_TYPE_READ;
2516 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2519 snprintf(sqlQuery, sizeof(sqlQuery),
2522 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE \"%%%s\";",
2523 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2525 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2527 char **db_res = NULL;
2528 int row_cnt = 0, col_cnt = 0;
2530 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2531 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2532 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2536 report_status_value = atoi(db_res[col_cnt]);
2538 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2540 msg_err = msg_db_free(msg_handle, db_res);
2541 if (msg_err != MSG_SUCCESS) {
2542 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2546 if (noti_info->msg_id > 0) {
2547 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2548 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2549 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2550 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2553 noti_info->extra_data = (unsigned char)report_status_value;
2557 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2561 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2566 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2570 createServiceHandle(¬i_info->svc_h);
2572 switch (noti_info->type) {
2573 case MSG_MGR_NOTI_TYPE_NORMAL: {
2574 if (noti_info->count > 1) {
2575 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2577 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2580 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2581 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2582 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2583 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2585 if (noti_info->active_noti_button_num == 0)
2586 noti_info->active_noti_button_num = 3;
2588 int activated_conv_id = -1;
2589 vconf_get_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, &activated_conv_id);
2591 if (activated_conv_id == -1) {
2592 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2593 } else if (activated_conv_id == 0) {
2594 noti_info->active_noti_button_num = 0;
2595 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2596 } else if (activated_conv_id > 0){
2597 noti_info->active_noti_button_num = 0;
2599 if (activated_conv_id != noti_info->conv_id)
2600 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2602 MSG_MGR_WARN("No adding Notification : activated conv id [%d] / notification conv id [%d]", activated_conv_id, noti_info->conv_id);
2607 case MSG_MGR_NOTI_TYPE_CB: {
2608 if (noti_info->count > 1) {
2609 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2611 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2614 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2615 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2616 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2618 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2619 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2621 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2623 noti_info->active_noti_button_num = 1;
2626 case MSG_MGR_NOTI_TYPE_SIM: {
2627 if (noti_info->count > 1) {
2628 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2630 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2633 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2634 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2635 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2637 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2638 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2640 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2642 if (noti_info->active_noti_button_num == 0)
2643 noti_info->active_noti_button_num = 3;
2646 case MSG_MGR_NOTI_TYPE_FAILED: {
2647 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2649 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2650 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2651 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2653 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2656 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2657 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2659 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2660 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2662 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2669 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2670 noti_info->active_noti_button_num = 0;
2676 void createServiceHandle(app_control_h *svc_h)
2678 int svc_err = APP_CONTROL_ERROR_NONE;
2680 svc_err = app_control_create(svc_h);
2682 if (svc_err != APP_CONTROL_ERROR_NONE)
2683 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2687 void setServiceAppId(app_control_h svc_h, const char* app_id)
2689 int svc_err = APP_CONTROL_ERROR_NONE;
2691 svc_err = app_control_set_app_id(svc_h, app_id);
2693 if (svc_err != APP_CONTROL_ERROR_NONE)
2694 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2698 void setServiceUri(app_control_h svc_h, const char* uri)
2700 int svc_err = APP_CONTROL_ERROR_NONE;
2702 svc_err = app_control_set_uri(svc_h, uri);
2704 if (svc_err != APP_CONTROL_ERROR_NONE)
2705 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2709 void setServiceOperation(app_control_h svc_h, const char* operation)
2711 int svc_err = APP_CONTROL_ERROR_NONE;
2713 svc_err = app_control_set_operation(svc_h, operation);
2715 if (svc_err != APP_CONTROL_ERROR_NONE)
2716 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2720 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2722 int svc_err = APP_CONTROL_ERROR_NONE;
2724 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2726 if (svc_err != APP_CONTROL_ERROR_NONE)
2727 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2731 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2733 int svc_err = APP_CONTROL_ERROR_NONE;
2736 memset(&tempId, 0x00, sizeof(tempId));
2737 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2739 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2741 if (svc_err != APP_CONTROL_ERROR_NONE)
2742 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2746 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2748 int svc_err = APP_CONTROL_ERROR_NONE;
2750 svc_err = app_control_set_app_id(svc_h, pkg_name);
2752 if (svc_err != APP_CONTROL_ERROR_NONE)
2753 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2757 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2759 int svc_err = APP_CONTROL_ERROR_NONE;
2761 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2763 if (svc_err != APP_CONTROL_ERROR_NONE)
2764 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2768 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2770 int noti_err = NOTIFICATION_ERROR_NONE;
2772 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2773 if (noti_err != NOTIFICATION_ERROR_NONE)
2774 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2778 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2780 int noti_err = NOTIFICATION_ERROR_NONE;
2782 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2784 if (noti_err != NOTIFICATION_ERROR_NONE)
2785 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2789 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2791 int noti_err = NOTIFICATION_ERROR_NONE;
2793 noti_err = notification_set_time_to_text(noti_h, type, time);
2795 if (noti_err != NOTIFICATION_ERROR_NONE)
2796 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2800 void setNotiTime(notification_h noti_h, time_t time)
2802 int noti_err = NOTIFICATION_ERROR_NONE;
2804 noti_err = notification_set_time(noti_h, time);
2806 if (noti_err != NOTIFICATION_ERROR_NONE)
2807 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2812 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2814 int noti_err = NOTIFICATION_ERROR_NONE;
2816 noti_err = notification_set_image(noti_h, type, image_path);
2818 if (noti_err != NOTIFICATION_ERROR_NONE)
2819 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2823 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2825 int noti_err = NOTIFICATION_ERROR_NONE;
2827 noti_err = notification_set_sound(noti_h, type, path);
2829 if (noti_err != NOTIFICATION_ERROR_NONE)
2830 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2834 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2836 int noti_err = NOTIFICATION_ERROR_NONE;
2838 noti_err = notification_set_vibration(noti_h, type, path);
2840 if (noti_err != NOTIFICATION_ERROR_NONE)
2841 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2845 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2847 int noti_err = NOTIFICATION_ERROR_NONE;
2849 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2851 if (noti_err != NOTIFICATION_ERROR_NONE)
2852 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2856 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2860 char *notiMsg = NULL;
2862 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2864 switch (noti_type) {
2865 case MSG_MGR_NOTI_TYPE_NORMAL:
2866 case MSG_MGR_NOTI_TYPE_SIM:
2867 case MSG_MGR_NOTI_TYPE_CB: {
2868 MSG_MGR_NOTI_INFO_S noti_info;
2869 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2871 noti_info.type = noti_type;
2872 int err = getLatestMsgInfo(¬i_info, true);
2875 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2876 if (noti_info.count == 1) {
2877 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2878 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2879 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2880 } else if (noti_info.count > 1) {
2881 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2883 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
2884 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2885 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2886 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2891 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2895 case MSG_MGR_NOTI_TYPE_FAILED: {
2896 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2897 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2898 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2902 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2903 goto _END_OF_INSTANT_NOTI;
2907 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2908 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2910 if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
2911 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
2913 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2914 MSG_MGR_DEBUG("Fail to notification_post");
2916 _END_OF_INSTANT_NOTI:
2918 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2919 MSG_MGR_DEBUG("Fail to notification_delete");
2926 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2927 MSG_MGR_DEBUG("Fail to notification_free");
2936 bool MsgMgrCheckNotificationSettingEnable()
2938 bool msg_noti_enabled = false;
2939 notification_system_setting_h system_setting = NULL;
2940 notification_setting_h setting = NULL;
2942 int err = NOTIFICATION_ERROR_NONE;
2944 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
2946 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
2947 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2949 msg_noti_enabled = true;
2951 bool allow_to_notify = false;
2952 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
2954 if (err != NOTIFICATION_ERROR_NONE) {
2955 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2959 if (allow_to_notify) {
2960 MSG_MGR_DEBUG("message notification is allowed");
2962 /* check do not disturb mode */
2963 err = notification_system_setting_load_system_setting(&system_setting);
2965 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
2966 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
2970 bool do_not_disturb_mode = false;
2971 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
2973 if (err != NOTIFICATION_ERROR_NONE) {
2974 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2978 if (do_not_disturb_mode) {
2979 bool is_msg_excepted = false;
2980 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
2981 if (err != NOTIFICATION_ERROR_NONE) {
2982 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2983 msg_noti_enabled = false;
2985 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
2986 msg_noti_enabled = (is_msg_excepted) ? true : false;
2989 MSG_MGR_DEBUG("do not disturb mode is off");
2992 MSG_MGR_INFO("message notification is not allowed");
2993 msg_noti_enabled = false;
2999 notification_system_setting_free_system_setting(system_setting);
3002 notification_setting_free_notification(setting);
3004 return msg_noti_enabled;
3008 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
3010 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
3011 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
3013 MsgMgrChangePmState();
3015 char *notiMsg = NULL;
3016 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
3019 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
3020 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
3022 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
3023 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
3024 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
3025 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
3026 notification_status_message_post(pTickerMsg);
3028 notification_status_message_post(notiMsg);
3031 /* Show ticker popup for sending failed msg. */
3032 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
3040 if (bPlayFeedback) {
3042 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
3043 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
3045 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
3047 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
3048 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
3050 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
3053 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
3061 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
3063 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
3065 int err = BADGE_ERROR_NONE;
3068 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
3070 if (err != BADGE_ERROR_NONE) {
3071 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
3077 err = badge_add(MSG_DEFAULT_APP_ID);
3078 if (err != BADGE_ERROR_NONE) {
3079 MSG_MGR_ERR("Fail to badge_add : %d", err);
3084 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
3086 if (err != BADGE_ERROR_NONE) {
3087 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3095 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3099 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3101 #ifndef MSG_NOTI_INTEGRATION
3102 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3103 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3111 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3117 struct tm repeat_tm;
3121 tmp_time += (RepeatTime*60);
3123 localtime_r(&tmp_time, &repeat_tm);
3125 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3126 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3130 g_alarmId = tmpAlarmId;
3131 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3139 void MsgMgrSoundSetRepeatAlarm()
3141 int nRepeatValue = 0;
3142 long nRepeatTime = 0;
3144 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3145 MSG_MGR_INFO("vconf_get_int() is failed");
3148 switch (nRepeatValue) {
3149 case MSG_ALERT_TONE_ONCE:
3152 case MSG_ALERT_TONE_2MINS:
3155 case MSG_ALERT_TONE_5MINS:
3158 case MSG_ALERT_TONE_10MINS:
3162 MSG_MGR_DEBUG("Invalid Repetition time");
3166 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3168 if (nRepeatTime > 0) {
3169 if (g_alarmId > 0) {
3170 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3171 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3175 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3182 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3184 char *notiMsg = NULL;
3187 lang = vconf_get_str(VCONFKEY_LANGSET);
3189 setlocale(LC_MESSAGES, lang);
3191 bindtextdomain(pkg_name, locale_dir);
3193 notiMsg = dgettext(pkg_name, text);
3200 return g_strdup(notiMsg);