2 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*==================================================================================================
19 ==================================================================================================*/
29 #include <app_control.h>
30 #include <badge_internal.h>
31 #include <notification_list.h>
32 #include <notification_text_domain.h>
33 #include <notification_internal.h>
34 #include <notification_status.h>
35 #include <notification_setting.h>
36 #include <notification_setting_internal.h>
37 #include <package_manager.h>
41 #include <msg_storage.h>
43 #include <msg-manager-util.h>
44 #include <msg-manager-contact.h>
45 #include <msg-manager-debug.h>
46 #include <msg-manager-notification.h>
47 #include <msg-manager-sound.h>
52 /*==================================================================================================
54 ==================================================================================================*/
56 static GList *msg_report_notification_list = NULL;
57 static bool is_init = false;
58 extern msg_handle_t msg_handle;
62 /*==================================================================================================
64 ==================================================================================================*/
65 typedef struct _report_notification_s
68 char addressVal[MAX_ADDRESS_VAL_LEN+1];
69 } report_notification_s;
72 typedef struct _msg_mgr_noti_info_s
74 msg_mgr_notification_type_t type;
80 char sender[MSG_NOTI_TEXT_LEN_S+1];
81 char text[MSG_NOTI_TEXT_LEN+1];
82 char number[MSG_NOTI_TEXT_LEN_S+1];
83 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
86 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
87 msg_message_id_t msg_id;
88 unsigned char extra_data;
90 int active_noti_button_num;
92 int active_media_size;
93 unsigned char active_subtype; /**< to distinguish cb, push message */
94 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
95 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
96 char active_text[MSG_NOTI_TEXT_LEN+1];
97 } MSG_MGR_NOTI_INFO_S;
100 typedef struct _del_noti_info_s
102 msg_mgr_notification_type_t type;
107 /*==================================================================================================
109 ===================================================================================================*/
111 void MsgMgrInitReportNotiList();
112 void MsgRefreshNotiCb(void *data);
113 void MsgMgrDeleteNotiCb(void *data);
115 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
116 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result);
118 notification_h getHandle(int *noti_id);
120 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
121 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
123 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
124 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
125 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
126 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
128 int getAppIcon(const char *app_id, char **icon_path);
129 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
131 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
132 void setTextDomain(notification_h noti_h);
133 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
134 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
135 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
136 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
137 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
138 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
139 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
141 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
144 void createServiceHandle(app_control_h *svc_h);
145 void setServiceAppId(app_control_h svc_h, const char* app_id);
146 void setServiceUri(app_control_h svc_h, const char* uri);
147 void setServiceOperation(app_control_h svc_h, const char* operation);
148 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
149 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
150 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
151 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
153 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
154 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
155 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
156 void setNotiTime(notification_h noti_h, time_t time);
157 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
158 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
159 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
160 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
163 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
164 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
165 void MsgMgrSoundSetRepeatAlarm();
167 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
169 /*==================================================================================================
170 FUNCTION IMPLEMENTATION
171 ==================================================================================================*/
172 bool _is_valid_email(char *pAddress)
174 if (!pAddress || pAddress[0] == 0)
176 if (!strchr (pAddress, EMAIL_AT))
182 void MsgMgrInitReportNotiList()
186 if (msg_report_notification_list) {
187 MSG_MGR_DEBUG("Report Noti List is already inited");
191 msg_report_notification_list = NULL;
193 notification_h noti = NULL;
194 notification_list_h noti_list = NULL;
195 notification_list_h head_noti_list = NULL;
196 int noti_err = NOTIFICATION_ERROR_NONE;
197 app_control_h app_control = NULL;
199 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
200 if (noti_err != NOTIFICATION_ERROR_NONE) {
201 MSG_MGR_DEBUG("notification_get_list() is failed!!");
205 head_noti_list = noti_list;
207 while (noti_list != NULL) {
208 noti = notification_list_get_data(noti_list);
210 MSG_MGR_DEBUG("notification_list_get_data() failed!!");
214 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
215 memset(tempAddr, 0x00, sizeof(tempAddr));
217 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
218 if (noti_err != NOTIFICATION_ERROR_NONE) {
219 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
223 char *is_report_noti = NULL;
225 int ret = app_control_get_extra_data(app_control, "is_report_noti", &is_report_noti);
226 if (ret == APP_CONTROL_ERROR_NONE && is_report_noti != NULL && g_strcmp0(is_report_noti, "true") == 0) {
229 ret = app_control_get_extra_data(app_control, "address", &addr);
230 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
231 report_notification_s *info = new report_notification_s;
232 memset(info, 0x00, sizeof(report_notification_s));
234 notification_get_id(noti, NULL, &(info->priv_id));
235 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
237 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
238 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
245 if (is_report_noti) {
246 g_free(is_report_noti);
247 is_report_noti = NULL;
251 noti_list = notification_list_get_next(noti_list);
255 notification_free_list(head_noti_list);
261 void MsgMgrInitNoti()
266 bool bNotiSvcReady = false;
268 bNotiSvcReady = notification_is_service_ready();
270 if (bNotiSvcReady == true) {
271 MSG_MGR_DEBUG("Notification server is available");
272 #ifndef MSG_NOTI_INTEGRATION
273 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
275 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
276 MsgMgrInitReportNotiList();
278 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
279 #ifndef MSG_NOTI_INTEGRATION
280 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
282 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
283 delNotiInfo->sim_idx = -1;
285 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
287 notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
294 void MsgRefreshNotiCb(void *data)
296 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
297 MsgMgrInitReportNotiList();
308 void MsgMgrDeleteNotiCb(void *data)
311 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)data;
313 MsgMgrDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx);
323 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
327 notification_h noti_h = NULL;
329 MSG_MGR_NOTI_INFO_S noti_info = {0, };
331 noti_info.type = noti_type;
332 noti_info.active_noti_button_num = 1;
334 createActiveInfoData(¬i_info, msg_info);
336 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
338 setActiveNotification(noti_h, ¬i_info);
340 clearInfoData(noti_h, ¬i_info);
347 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
350 notification_h noti_h = NULL;
351 int bNotification = 1;
352 /* bool bReplyPopup = false; */
354 MSG_MGR_NOTI_INFO_S noti_info = {0, };
355 noti_info.type = noti_type;
356 noti_info.id = getPrivId(noti_info.type, -1);
358 err = getLatestMsgInfo(¬i_info, false);
361 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
362 goto __END_OF_REFRESH_NOTI;
365 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
366 err = MsgMgrInsertInstantMessage(noti_type);
369 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
370 goto __END_OF_REFRESH_NOTI;
374 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
375 MSG_MGR_DEBUG("vconf_get_bool is failed.");
378 if (bNotification == 0) {
379 MSG_MGR_DEBUG("Msg Alert notification is off.");
380 goto __END_OF_REFRESH_NOTI;
383 createInfoData(¬i_info, active_type);
385 noti_h = getHandle(¬i_info.id);
387 if (noti_h == NULL) {
388 MSG_MGR_DEBUG("Notification handle is NULL");
389 err = MSG_ERR_NULL_POINTER;
390 goto __END_OF_REFRESH_NOTI;
393 setNotification(noti_h, ¬i_info, bFeedback);
395 __END_OF_REFRESH_NOTI :
396 clearInfoData(noti_h, ¬i_info);
402 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
406 notification_h noti_h = NULL;
408 report_notification_s *info = new report_notification_s;
409 memset(info, 0x00, sizeof(report_notification_s));
411 MSG_MGR_NOTI_INFO_S noti_info = {0, };
412 noti_info.type = noti_type;
414 createInfoData(¬i_info, msg_info);
416 noti_h = getHandle(¬i_info.id);
418 if (noti_h == NULL) {
419 MSG_MGR_DEBUG("Notification handle is NULL");
421 goto __END_OF_ADD_REPORT_NOTI;
424 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT || noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
425 noti_info.applist &= ~NOTIFICATION_DISPLAY_APP_TICKER;
427 ret = MsgMgrInsertDeliveryReportInstantNotification(noti_type, noti_info.extra_data);
430 MSG_MGR_ERR(" MsgInsertInstantDeliveryReportNotification() err = [%d]", ret);
431 goto __END_OF_ADD_REPORT_NOTI;
435 addServiceExtraData(noti_info.svc_h, "is_report_noti", "true");
436 setNotification(noti_h, ¬i_info, true);
438 info->priv_id = noti_info.id;
439 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
440 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
441 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
443 __END_OF_ADD_REPORT_NOTI :
444 clearInfoData(noti_h, ¬i_info);
450 int MsgMgrDeleteReportNotification(const char *addr)
454 notification_h noti_h = NULL;
455 int bNotification = 1;
457 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
458 MSG_MGR_DEBUG("vconf_get_bool is failed.");
461 if (bNotification == 0) {
462 MSG_MGR_DEBUG("Msg Alert notification is off.");
466 char* normalAddr = NULL;
467 unsigned int list_length = g_list_length(msg_report_notification_list);
468 bool isDelete = false;
470 MSG_MGR_DEBUG("list length [%d]", list_length);
472 if (list_length > 0) {
473 GList *iter = g_list_first(msg_report_notification_list);
475 while (iter != NULL) {
477 report_notification_s *info = (report_notification_s*)(iter->data);
479 MSG_MGR_DEBUG("info is NULL!");
483 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
485 noti_h = notification_load(NULL, info->priv_id);
486 if (noti_h == NULL) {
487 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
490 normalAddr = msg_mgr_normalize_number(info->addressVal);
493 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
495 if (g_str_has_suffix(addr, normalAddr)) {
496 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
497 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
500 MSG_MGR_DEBUG("delete notification failed");
505 notification_free(noti_h);
509 iter = g_list_next(iter);
512 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
526 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
530 notification_h noti_h = NULL;
532 MSG_MGR_NOTI_INFO_S noti_info = {0, };
534 noti_info.type = noti_type;
536 createInfoData(¬i_info, msg_info);
538 /* check mwi or voicemail count is 0 then skip add notification */
539 if (noti_info.count == 0) {
540 MSG_MGR_DEBUG("Notification count is 0");
542 goto __END_OF_ADD_NOTI;
545 noti_h = getHandle(¬i_info.id);
547 if (noti_h == NULL) {
548 MSG_MGR_DEBUG("Notification handle is NULL");
550 goto __END_OF_ADD_NOTI;
553 setNotification(noti_h, ¬i_info, true);
556 clearInfoData(noti_h, ¬i_info);
562 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex)
564 int noti_err = NOTIFICATION_ERROR_NONE;
566 if (noti_type == MSG_MGR_NOTI_TYPE_ALL) {
567 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
568 } 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) {
571 notiId = getPrivId(noti_type, simIndex);
572 MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
575 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, notiId);
578 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
581 if (noti_err != NOTIFICATION_ERROR_NONE) {
582 MSG_MGR_DEBUG("Fail to notification_delete_all noti_err [%d]", noti_err);
585 updatePrivId(noti_type, 0, simIndex);
589 int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
591 bool bNotiSvcReady = false;
593 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S));
596 delNotiInfo->type = noti_type;
597 delNotiInfo->sim_idx = simIndex;
600 bNotiSvcReady = notification_is_service_ready();
602 if (bNotiSvcReady == true) {
603 MSG_MGR_DEBUG("Notification server is available");
604 MsgMgrDeleteNotiCb((void *)delNotiInfo);
606 MSG_MGR_DEBUG("Notification server is not available. Delete is defered");
607 notification_add_deferred_task(MsgMgrDeleteNotiCb, (void *)delNotiInfo);
613 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
619 #ifndef MSG_NOTI_INTEGRATION
620 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
623 #ifdef MSG_NOTI_INTEGRATION
624 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
626 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
628 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
630 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
632 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
634 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
637 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
639 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
643 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
645 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
651 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
655 int noti_err = NOTIFICATION_ERROR_NONE;
658 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
659 if (noti_err != NOTIFICATION_ERROR_NONE) {
660 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
664 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
665 if (noti_err != NOTIFICATION_ERROR_NONE) {
666 MSG_MGR_DEBUG("Fail to notification_set_led.");
669 /* set execute option and property */
670 switch (noti_info->type) {
671 case MSG_MGR_NOTI_TYPE_NORMAL: {
672 if (noti_info->count > 1) {
673 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
675 if (noti_info->svc_h) { /* overwrite bundle key "type" */
676 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
677 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
679 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
682 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
685 case MSG_MGR_NOTI_TYPE_CB:
686 case MSG_MGR_NOTI_TYPE_SIM: {
687 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
688 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
691 case MSG_MGR_NOTI_TYPE_FAILED: {
692 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
693 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
696 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
697 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
700 case MSG_MGR_NOTI_TYPE_VOICE_1:
701 case MSG_MGR_NOTI_TYPE_VOICE_2:
702 case MSG_MGR_NOTI_TYPE_MWI:
703 case MSG_MGR_NOTI_TYPE_CLASS0:
704 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
705 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
706 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
707 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
711 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
716 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
717 if (noti_err != NOTIFICATION_ERROR_NONE) {
718 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
722 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
723 if (noti_err != NOTIFICATION_ERROR_NONE) {
724 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
731 void setTextDomain(notification_h noti_h)
735 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
740 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
744 char unreadMsgCntStr[10] = {0};
747 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
748 MSG_MGR_DEBUG("vconf_get_bool is failed.");
751 /* set title and content */
752 switch (noti_info->type) {
753 #ifdef MSG_NOTI_INTEGRATION
754 case MSG_MGR_NOTI_TYPE_NORMAL:
755 case MSG_MGR_NOTI_TYPE_CB:
756 case MSG_MGR_NOTI_TYPE_SIM: {
757 if (noti_info->count > 1) {
758 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
759 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
760 setNotiTime(noti_h, noti_info->time);
762 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
763 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
767 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
768 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
770 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
771 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
773 setNotiTime(noti_h, noti_info->time);
778 case MSG_MGR_NOTI_TYPE_NORMAL: {
779 if (noti_info->count > 1) {
780 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
781 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
782 setNotiTime(noti_h, noti_info->time);
784 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
785 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
788 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
789 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
791 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
792 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
794 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
795 setNotiTime(noti_h, noti_info->time);
799 case MSG_MGR_NOTI_TYPE_CB: {
800 if (noti_info->count > 1) {
801 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
802 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
803 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
804 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
805 setNotiTime(noti_h, noti_info->time);
808 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
809 setNotiTime(noti_h, noti_info->time);
812 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
813 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
815 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
816 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
821 case MSG_MGR_NOTI_TYPE_SIM: {
822 if (noti_info->count > 1) {
823 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
824 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
825 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
827 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
828 setNotiTime(noti_h, noti_info->time);
830 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
831 setNotiTime(noti_h, noti_info->time);
834 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
835 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
837 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
838 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
844 case MSG_MGR_NOTI_TYPE_FAILED: {
845 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
846 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
847 if (noti_info->count > 1) {
848 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
849 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
851 setNotiTime(noti_h, noti_info->time);
854 case MSG_MGR_NOTI_TYPE_VOICE_1:
855 case MSG_MGR_NOTI_TYPE_VOICE_2: {
856 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
857 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
858 setNotiTime(noti_h, noti_info->time);
860 if (noti_info->count == 1) {
861 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
862 } else if (noti_info->count > 1) {
863 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
864 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
866 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
870 case MSG_MGR_NOTI_TYPE_MWI: {
871 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
872 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
873 setNotiTime(noti_h, noti_info->time);
876 case MSG_MGR_NOTI_TYPE_CLASS0: {
877 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
878 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
879 setNotiTime(noti_h, noti_info->time);
882 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
883 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
884 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
886 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
887 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
888 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
889 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
891 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
894 setNotiTime(noti_h, noti_info->time);
897 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
898 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
899 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
901 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
902 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
903 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
905 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
906 /* notification free */
909 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
912 setNotiTime(noti_h, noti_info->time);
915 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
916 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
917 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
919 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) {
920 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
921 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) {
922 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", MESSAGE_REJECTED);
923 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) {
924 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
925 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED || noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE
926 || noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED || noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE
927 || noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) {
928 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Recipient not available", RECIPIENT_NOT_AVAILABLE);
930 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
933 setNotiTime(noti_h, noti_info->time);
936 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
937 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
938 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
942 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
949 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
953 switch (noti_info->type) {
954 #ifdef MSG_NOTI_INTEGRATION
955 case MSG_MGR_NOTI_TYPE_NORMAL:
956 case MSG_MGR_NOTI_TYPE_CB:
957 case MSG_MGR_NOTI_TYPE_SIM: {
958 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
959 if (noti_info->count > 1 && noti_info->senderCount > 1) {
960 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
961 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
962 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
964 if (noti_info->active_subtype == MSG_CB_SMS) {
965 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
966 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
967 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
968 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
969 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
970 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
971 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
973 if (noti_info->imagePath[0] != '\0') {
974 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
975 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
977 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
978 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
981 char *msg_icon_path = NULL;
982 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
983 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
984 g_free(msg_icon_path);
986 MSG_MGR_ERR("fail to get message-app icon");
993 case MSG_MGR_NOTI_TYPE_NORMAL: {
994 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
995 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
997 if (noti_info->count > 1) {
998 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1000 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
1004 case MSG_MGR_NOTI_TYPE_CB: {
1005 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1006 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1009 case MSG_MGR_NOTI_TYPE_SIM: {
1010 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1011 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1015 case MSG_MGR_NOTI_TYPE_FAILED: {
1016 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1017 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_FAILED_STATUS_ICON);
1020 case MSG_MGR_NOTI_TYPE_VOICE_1:
1021 case MSG_MGR_NOTI_TYPE_VOICE_2:
1022 case MSG_MGR_NOTI_TYPE_MWI: {
1023 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1024 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1027 case MSG_MGR_NOTI_TYPE_CLASS0:
1028 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1030 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1031 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1032 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1034 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1035 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1036 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1038 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1039 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1040 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1042 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1043 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1044 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1047 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1054 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1058 int noti_err = NOTIFICATION_ERROR_NONE;
1061 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1062 if (noti_err != NOTIFICATION_ERROR_NONE) {
1063 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1067 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1068 if (noti_err != NOTIFICATION_ERROR_NONE) {
1069 MSG_MGR_DEBUG("Fail to notification_set_led.");
1072 /* set execute option and property */
1073 switch (noti_info->type) {
1074 case MSG_MGR_NOTI_TYPE_NORMAL:
1075 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1076 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
1078 case MSG_MGR_NOTI_TYPE_CLASS0:
1079 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1082 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
1087 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1088 if (noti_err != NOTIFICATION_ERROR_NONE) {
1089 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1093 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
1094 if (noti_err != NOTIFICATION_ERROR_NONE) {
1095 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
1102 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1106 switch (noti_info->type) {
1107 case MSG_MGR_NOTI_TYPE_NORMAL:
1108 case MSG_MGR_NOTI_TYPE_SIM:
1109 case MSG_MGR_NOTI_TYPE_CB: {
1110 if (noti_info->active_subject[0] == '\0') {
1111 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1112 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1114 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1115 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1116 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1120 case MSG_MGR_NOTI_TYPE_CLASS0: {
1121 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1122 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1126 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1134 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1138 switch (noti_info->type) {
1139 case MSG_MGR_NOTI_TYPE_NORMAL:
1140 case MSG_MGR_NOTI_TYPE_SIM: {
1141 switch (noti_info->active_subtype) {
1143 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1145 case MSG_WAP_SI_SMS:
1146 case MSG_WAP_SL_SMS:
1147 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1150 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1153 if (noti_info->imagePath[0] != '\0')
1154 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1156 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1158 char *msg_icon_path = NULL;
1159 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1160 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1161 g_free(msg_icon_path);
1163 MSG_MGR_ERR("fail to get message-app icon");
1171 case MSG_MGR_NOTI_TYPE_CB: {
1172 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1175 case MSG_MGR_NOTI_TYPE_CLASS0:
1176 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1179 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1187 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result)
1191 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
1192 notification_set_pkgname(noti, MSG_DEFAULT_APP_ID);
1194 setTextDomain(noti);
1195 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
1196 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVER_REPORT_STATUS_ICON);
1198 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT) {
1199 if (result == MSG_NETWORK_DELIVER_SUCCESS) {
1200 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1201 } else if (result == MSG_NETWORK_DELIVER_EXPIRED) {
1202 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1203 } else if (result == MSG_NETWORK_DELIVER_PENDING) {
1204 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1206 MSG_MGR_ERR("unexpected result! [%d]", result);
1207 goto _END_OF_INSTANT_DELIVERY_REPORT_NOTI;
1209 } else if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
1210 if (result == MSG_DELIVERY_REPORT_EXPIRED)
1211 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1212 else if (result== MSG_DELIVERY_REPORT_REJECTED)
1213 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message rejected by recipient.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_REJECTED);
1214 else if (result == MSG_DELIVERY_REPORT_DEFERRED)
1215 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1216 else if (result == MSG_DELIVERY_REPORT_UNRECOGNISED || result == MSG_DELIVERY_REPORT_INDETERMINATE ||
1217 result == MSG_DELIVERY_REPORT_FORWARDED || result == MSG_DELIVERY_REPORT_UNREACHABLE ||
1218 result == MSG_DELIVERY_REPORT_ERROR)
1219 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Recipient not available.", UNABLE_TO_DELIVER_MESSAGE_RECIPIENT_NOT_AVAILABLE);
1221 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1224 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
1225 MSG_MGR_ERR("Fail to notification_set_display_applist");
1227 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
1228 MSG_MGR_ERR("Fail to notification_post");
1230 _END_OF_INSTANT_DELIVERY_REPORT_NOTI:
1232 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
1233 MSG_MGR_ERR("Fail to notification_delete");
1236 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
1237 MSG_MGR_ERR("Fail to notification_free");
1246 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1250 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1251 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1253 if (addressVal != NULL) {
1254 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1255 /* Get Contact Info */
1256 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1257 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1260 MSG_MGR_DEBUG("addressVal is NULL.");
1263 char *msg_tone_file_path = NULL;
1265 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1267 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1269 bool bPlaySound = false;
1270 bool bPlayVibration = false;
1271 bool bOnCall = false;
1273 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1276 if (msg_tone_file_path) {
1277 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1280 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1281 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1283 int ringtoneType = tmpVal;
1284 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1285 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1287 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1290 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1293 if (bPlayVibration) {
1294 if (contactInfo.vibrationPath[0] == '\0')
1295 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1297 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1299 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1302 if (msg_tone_file_path)
1303 delete [] msg_tone_file_path;
1309 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1313 int noti_err = NOTIFICATION_ERROR_NONE;
1315 if (noti_info->active_noti_button_num > 1) {
1316 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1317 if (noti_info->active_noti_svc_h[0]) {
1318 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1319 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1321 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1323 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1324 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1325 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1326 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1329 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1330 if (noti_info->active_noti_svc_h[1]) {
1331 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1333 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1334 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1335 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1337 char slot_id[5] = {0, };
1338 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1339 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1343 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1344 if (noti_info->active_noti_svc_h[2]) {
1345 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1347 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1348 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1349 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1350 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1352 char slot_id[5] = {0, };
1353 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1354 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1357 if (noti_info->active_noti_button_num > 1) {
1358 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1359 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1360 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1362 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1363 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1364 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1366 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1368 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1371 setActiveProperty(noti_h, noti_info);
1373 setTextDomain(noti_h);
1375 setActiveText(noti_h, noti_info);
1377 setActiveIcon(noti_h, noti_info);
1379 noti_err = notification_post(noti_h);
1380 if (noti_err != NOTIFICATION_ERROR_NONE) {
1381 MSG_MGR_DEBUG("Fail to notification_post");
1388 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1392 int noti_err = NOTIFICATION_ERROR_NONE;
1394 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1396 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1397 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1398 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1400 setActiveNotification(active_noti_h, noti_info);
1402 notification_free(active_noti_h);
1403 active_noti_h = NULL;
1406 setProperty(noti_h, noti_info);
1408 setTextDomain(noti_h);
1410 setText(noti_h, noti_info);
1412 setIcon(noti_h, noti_info);
1415 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1416 setSoundAndVibration(noti_h, noti_info->number, true);
1418 setSoundAndVibration(noti_h, noti_info->number, false);
1421 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1422 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1425 if (noti_info->id > 0) {
1426 MSG_MGR_DEBUG("Notification update");
1427 noti_err = notification_update(noti_h);
1428 if (noti_err != NOTIFICATION_ERROR_NONE) {
1429 MSG_MGR_DEBUG("Fail to notification_update");
1432 MSG_MGR_DEBUG("Notification insert");
1433 noti_err = notification_insert(noti_h, ¬i_info->id);
1434 if (noti_err != NOTIFICATION_ERROR_NONE) {
1435 MSG_MGR_DEBUG("Fail to notification_insert");
1438 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1445 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1450 MSG_MGR_DEBUG("msg_info is NULL");
1454 noti_info->msg_id = msg_info->msgId;
1455 noti_info->sim_idx = msg_info->sim_idx;
1457 switch (noti_info->type) {
1458 case MSG_MGR_NOTI_TYPE_NORMAL: {
1459 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1460 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1467 case MSG_MGR_NOTI_TYPE_CLASS0: {
1468 if (msg_info->displayName[0] == '\0')
1469 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1471 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1473 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1477 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1485 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1490 notification_free(noti_h);
1494 if (noti_info->svc_h) {
1495 app_control_destroy(noti_info->svc_h);
1496 noti_info->svc_h = NULL;
1499 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1500 if (noti_info->active_noti_svc_h[i]) {
1501 app_control_destroy(noti_info->active_noti_svc_h[i]);
1502 noti_info->active_noti_svc_h[i] = NULL;
1510 int getAppIcon(const char *app_id, char **icon_path)
1514 package_info_h pkg_info_h = NULL;
1515 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1518 if (app_id == NULL) {
1519 MSG_MGR_ERR("app id is NULL");
1521 goto END_OF_GET_APP_ICON;
1524 pkg_err = package_info_create(app_id, &pkg_info_h);
1525 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1526 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1528 goto END_OF_GET_APP_ICON;
1531 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1532 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1533 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1536 if (icon_path == NULL) {
1537 MSG_MGR_WARN("icon path is NULL");
1542 END_OF_GET_APP_ICON:
1544 pkg_err = package_info_destroy(pkg_info_h);
1545 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1546 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1558 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1563 msg_error_t msg_err = MSG_SUCCESS;
1564 char **db_res = NULL;
1565 int row_cnt = 0, col_cnt = 0;
1567 switch (noti_info->type) {
1568 case MSG_MGR_NOTI_TYPE_NORMAL:
1569 #ifdef MSG_NOTI_INTEGRATION
1570 case MSG_MGR_NOTI_TYPE_CB:
1571 case MSG_MGR_NOTI_TYPE_SIM:
1574 int smsUnreadCnt = 0;
1575 int mmsUnreadCnt = 0;
1577 char sqlQuery[MAX_QUERY_LEN +1];
1578 unsigned char mainType;
1579 unsigned char subType;
1582 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1583 #ifdef MSG_NOTI_INTEGRATION
1584 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1588 "WHERE A.CONV_ID=B.CONV_ID "
1589 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1590 "AND B.STORAGE_ID = %d "
1591 "GROUP BY A.ADDRESS_VAL "
1592 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1593 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1594 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1597 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1601 "WHERE A.CONV_ID=B.CONV_ID "
1602 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1603 "AND B.STORAGE_ID = %d "
1604 "GROUP BY A.ADDRESS_VAL "
1605 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1606 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1610 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1612 row_cnt = 0, col_cnt = 0;
1613 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1614 if (msg_err != MSG_SUCCESS) {
1615 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1619 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1620 int normalAddCnt = 0;
1621 int index = col_cnt;
1623 for (int i = 1; i <= row_cnt; i++) {
1624 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1626 char *address = db_res[index++];
1629 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1630 if (_is_valid_email(address)) {
1631 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1633 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1636 subType = atoi(db_res[index++]);
1638 MSG_MGR_CONTACT_INFO_S tmpContact;
1639 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1641 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1644 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1647 if (normalAddCnt > 1) {
1648 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1651 if (tmpContact.firstName[0] != '\0') {
1652 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1653 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1654 char *senderStr = NULL;
1655 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1656 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1663 noti_info->active_noti_button_num = 1;
1666 char *senderStr = NULL;
1667 if (subType == MSG_CB_SMS) {
1668 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1669 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1670 noti_info->active_noti_button_num = 1;
1671 } else if (subType == MSG_SYNCML_CP) {
1672 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1673 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1674 noti_info->active_noti_button_num = 1;
1675 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1676 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1677 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1678 noti_info->active_noti_button_num = 1;
1680 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1690 noti_info->active_subtype = subType;
1691 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1692 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1696 noti_info->senderCount = normalAddCnt;
1697 msg_db_free(msg_handle, db_res);
1699 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1701 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1703 #ifdef MSG_NOTI_INTEGRATION
1704 snprintf(sqlQuery, sizeof(sqlQuery),
1708 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
1709 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
1711 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1712 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1713 "(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) "
1715 "WHERE A.CONV_ID=B.CONV_ID "
1716 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1717 "AND B.STORAGE_ID = %d "
1718 "ORDER BY B.DISPLAY_TIME DESC;",
1721 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1722 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1723 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1726 snprintf(sqlQuery, sizeof(sqlQuery),
1733 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1734 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1736 "WHERE A.CONV_ID=B.CONV_ID "
1737 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1738 "AND B.STORAGE_ID = %d "
1739 "ORDER BY B.DISPLAY_TIME DESC;",
1742 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1746 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1748 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1749 if (msg_err != MSG_SUCCESS) {
1750 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1755 smsUnreadCnt = atoi(db_res[col_cnt+6]);
1756 mmsUnreadCnt = atoi(db_res[col_cnt+7]);
1757 msgSize = atoi(db_res[col_cnt+8]);
1759 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1761 if (noti_info->count > 0) {
1762 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1764 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1766 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1768 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1770 if (mainType == MSG_MMS_TYPE) {
1771 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1772 if (noti_info->text[0] == '\0') {
1773 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1774 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1778 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1779 if (prefix_subject) {
1780 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1781 g_free(prefix_subject);
1783 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1787 int kb_msg_size = msgSize / 1024;
1788 if (kb_msg_size == 0 && msgSize > 0)
1790 else if (msgSize % 1024 >= 512)
1793 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1794 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1796 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1798 g_free(msg_size_string);
1799 g_free(msg_size_unit_kb);
1803 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1806 if (noti_info->active_text[0] == '\0')
1807 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1809 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1811 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1812 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1813 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1815 if (!isForInstantMessage) {
1816 if (noti_info->id > 0 && noti_info->count == 1) {
1817 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1818 if (noti_err != NOTIFICATION_ERROR_NONE) {
1819 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1823 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1824 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1827 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1828 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1829 MsgMgrInsertBadge(noti_info->count);
1830 MsgMgrSoundSetRepeatAlarm();
1833 MSG_MGR_DEBUG("No unread message.");
1834 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1836 msg_db_free(msg_handle, db_res);
1838 if (!isForInstantMessage) {
1839 /* No unread message. */
1840 if (noti_info->id > 0) {
1841 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1842 if (noti_err != NOTIFICATION_ERROR_NONE) {
1843 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1849 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1850 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1852 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1853 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1854 MsgMgrInsertBadge(0);
1855 MsgMgrSoundSetRepeatAlarm();
1861 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1862 msg_db_free(msg_handle, db_res);
1866 msg_db_free(msg_handle, db_res);
1870 #ifndef MSG_NOTI_INTEGRATION
1871 case MSG_MGR_NOTI_TYPE_CB: {
1872 char sqlQuery[MAX_QUERY_LEN+1];
1873 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1875 snprintf(sqlQuery, sizeof(sqlQuery),
1881 "WHERE A.CONV_ID=B.CONV_ID "
1882 "AND B.READ_STATUS=0 "
1883 "AND B.FOLDER_ID=%d "
1884 "AND B.STORAGE_ID = %d "
1885 "ORDER BY B.DISPLAY_TIME DESC;",
1886 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1890 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1891 return MSG_ERR_DB_PREPARE;
1893 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1894 MSG_ADDRESS_INFO_S addrInfo;
1895 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1897 if (dbhandler->columnText(0) != NULL)
1898 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1900 MSG_CONTACT_INFO_S tmpContact;
1901 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1903 MsgGetContactInfo(&addrInfo, &tmpContact);
1905 if (tmpContact.firstName[0] != '\0') {
1906 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1907 } else if (addrInfo.addressVal[0] == '\0') {
1908 char *senderStr = NULL;
1909 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1910 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1916 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1919 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1921 noti_info->time = (time_t)dbhandler->columnInt(1);
1923 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1925 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1927 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1929 MSG_MGR_DEBUG("No unread CB message.");
1930 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1932 dbhandler->finalizeQuery();
1934 if (!isForInstantMessage) {
1935 /* No unread message. */
1936 if (noti_info->id > 0) {
1937 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1938 if (noti_err != NOTIFICATION_ERROR_NONE) {
1939 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1945 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1946 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1948 return MSG_ERR_DB_STEP;
1951 dbhandler->finalizeQuery();
1953 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
1954 MSG_MGR_DEBUG("getTable is failed");
1955 dbhandler->freeTable();
1956 return MSG_ERR_DB_GETTABLE;
1959 dbhandler->freeTable();
1960 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
1963 case MSG_MGR_NOTI_TYPE_SIM: {
1964 char sqlQuery[MAX_QUERY_LEN+1];
1965 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1967 snprintf(sqlQuery, sizeof(sqlQuery),
1972 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
1974 "WHERE A.CONV_ID=B.CONV_ID "
1975 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1976 "AND B.STORAGE_ID = %d "
1977 "ORDER BY B.DISPLAY_TIME DESC;",
1979 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1983 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1985 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1986 return MSG_ERR_DB_PREPARE;
1988 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1989 noti_info->count = dbhandler->columnInt(4);
1991 if (noti_info->count > 0) {
1992 MSG_ADDRESS_INFO_S addrInfo;
1993 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1995 if (dbhandler->columnText(0) != NULL)
1996 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1998 MSG_CONTACT_INFO_S tmpContact;
1999 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2001 MsgGetContactInfo(&addrInfo, &tmpContact);
2003 if (tmpContact.firstName[0] != '\0') {
2004 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2005 } else if (addrInfo.addressVal[0] == '\0') {
2006 char *senderStr = NULL;
2007 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2008 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2014 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2017 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2019 noti_info->time = (time_t)dbhandler->columnInt(1);
2021 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2023 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2025 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
2027 MSG_MGR_DEBUG("No unread SIM message.");
2028 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2030 dbhandler->finalizeQuery();
2032 if (!isForInstantMessage) {
2033 /* No unread message. */
2034 if (noti_info->id > 0) {
2035 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2036 if (noti_err != NOTIFICATION_ERROR_NONE) {
2037 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2043 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2044 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2047 return MSG_ERR_DB_STEP;
2050 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2051 dbhandler->finalizeQuery();
2052 return MSG_ERR_DB_STEP;
2055 dbhandler->finalizeQuery();
2059 case MSG_MGR_NOTI_TYPE_FAILED: {
2060 char sqlQuery[MAX_QUERY_LEN+1];
2061 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2063 snprintf(sqlQuery, sizeof(sqlQuery),
2070 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2072 "WHERE A.CONV_ID=B.CONV_ID "
2073 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2074 "AND B.STORAGE_ID = %d "
2075 "ORDER BY B.DISPLAY_TIME DESC;",
2076 MSG_NETWORK_SEND_FAIL,
2077 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2081 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2083 row_cnt = 0, col_cnt = 0;
2084 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2085 if (msg_err != MSG_SUCCESS) {
2086 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2091 noti_info->count = atoi(db_res[col_cnt+6]);
2093 if (noti_info->count > 0) {
2094 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2096 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2098 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2100 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2102 if (tmpContact.firstName[0] != '\0') {
2103 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2104 } else if (addrInfo.addressVal[0] == '\0') {
2105 char *senderStr = NULL;
2106 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2107 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2113 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2116 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2118 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2120 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2122 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2124 if (mainType == MSG_TYPE_MMS)
2125 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2127 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2129 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2131 if (!isForInstantMessage) {
2132 if (noti_info->id > 0 && noti_info->count == 1) {
2133 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2134 if (noti_err != NOTIFICATION_ERROR_NONE) {
2135 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2138 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2139 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2143 MSG_MGR_DEBUG("No sent failed message.");
2144 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2146 msg_db_free(msg_handle, db_res);
2148 if (!isForInstantMessage) {
2149 /* No unread message. */
2150 if (noti_info->id > 0) {
2151 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2152 if (noti_err != NOTIFICATION_ERROR_NONE) {
2153 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2159 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2160 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2166 msg_db_free(msg_handle, db_res);
2170 msg_db_free(msg_handle, db_res);
2173 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2176 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2186 notification_h getHandle(int *noti_id)
2188 notification_h noti_h = NULL;
2191 MSG_MGR_DEBUG("Notification load");
2192 noti_h = notification_load(NULL, *noti_id);
2194 MSG_MGR_DEBUG("notification_load is failed.");
2197 if (noti_h == NULL) {
2198 MSG_MGR_DEBUG("Notification create");
2199 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2200 if (noti_h == NULL) {
2201 MSG_MGR_DEBUG("notification_create is failed.");
2212 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2218 switch (noti_type) {
2219 #ifdef MSG_NOTI_INTEGRATION
2220 case MSG_MGR_NOTI_TYPE_NORMAL:
2221 case MSG_MGR_NOTI_TYPE_SIM:
2222 case MSG_MGR_NOTI_TYPE_CB:
2223 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2226 case MSG_MGR_NOTI_TYPE_NORMAL:
2227 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2229 case MSG_MGR_NOTI_TYPE_SIM:
2230 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2232 case MSG_MGR_NOTI_TYPE_CB:
2233 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2236 case MSG_MGR_NOTI_TYPE_FAILED:
2237 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2239 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2240 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2241 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2242 vconf_get_int(keyName, ¬i_id);
2245 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2246 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2247 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2248 vconf_get_int(keyName, ¬i_id);
2251 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2252 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2255 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2259 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2267 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2273 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2275 switch (noti_type) {
2276 #ifdef MSG_NOTI_INTEGRATION
2277 case MSG_MGR_NOTI_TYPE_NORMAL:
2278 case MSG_MGR_NOTI_TYPE_SIM:
2279 case MSG_MGR_NOTI_TYPE_CB:
2280 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2283 case MSG_MGR_NOTI_TYPE_NORMAL:
2284 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2286 case MSG_MGR_NOTI_TYPE_SIM:
2287 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2289 case MSG_MGR_NOTI_TYPE_CB:
2290 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2293 case MSG_MGR_NOTI_TYPE_FAILED:
2294 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2296 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2297 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2298 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2299 err = vconf_set_int(keyName, noti_id);
2302 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2303 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2304 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2305 err = vconf_set_int(keyName, noti_id);
2308 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2309 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2312 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2317 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2323 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2328 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2329 noti_info->msg_id = msg_info->msgId;
2331 MSG_MGR_DEBUG("msg_info is NULL");
2335 noti_info->sim_idx = msg_info->sim_idx;
2337 createServiceHandle(¬i_info->svc_h);
2338 char keyName[MAX_VCONFKEY_NAME_LEN];
2340 switch (noti_info->type) {
2341 case MSG_MGR_NOTI_TYPE_VOICE_1:
2342 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2343 memset(keyName, 0x00, sizeof(keyName));
2344 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2345 vconf_get_int(keyName, ¬i_info->count);
2346 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2347 noti_info->time = msg_info->displayTime;
2349 memset(keyName, 0x00, sizeof(keyName));
2350 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2351 char *voiceNumber = vconf_get_str(keyName);
2352 memset(keyName, 0x00, sizeof(keyName));
2353 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2354 char *voiceAlphaId = vconf_get_str(keyName);
2355 char *dialNumber = NULL;
2357 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2359 if (voiceNumber && strlen(voiceNumber))
2360 dialNumber = voiceNumber;
2362 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2363 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2364 } else if (dialNumber && strlen(dialNumber) > 0) {
2365 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2368 if (dialNumber && strlen(dialNumber) > 0)
2369 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2371 if (noti_info->svc_h) {
2372 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2373 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2375 char slot_id[5] = {0, };
2376 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2377 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2380 if (voiceNumber) g_free(voiceNumber);
2381 if (voiceAlphaId) g_free(voiceAlphaId);
2384 case MSG_MGR_NOTI_TYPE_MWI:
2385 case MSG_MGR_NOTI_TYPE_CLASS0: {
2386 noti_info->count = 1;
2387 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2388 noti_info->time = msg_info->displayTime;
2390 if (msg_info->displayName[0] == '\0')
2391 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2393 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2395 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2397 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2399 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2400 if (noti_info->svc_h) {
2401 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2402 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2404 char slot_id[5] = {0, };
2405 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2406 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2410 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2411 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2412 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2416 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2417 noti_info->count = 1;
2418 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2419 noti_info->time = msg_info->displayTime;
2420 noti_info->extra_data = msg_info->networkStatus;
2422 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2423 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2424 if (msg_info->addressVal[0] != '\0') {
2425 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2426 if (_is_valid_email(msg_info->addressVal)) {
2427 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2429 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2433 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2434 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2437 if (contactInfo.firstName[0] == '\0')
2438 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2440 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2442 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2444 if (noti_info->msg_id > 0) {
2445 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2446 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2447 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2448 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2452 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2453 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2454 noti_info->count = 1;
2455 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2456 noti_info->time = msg_info->displayTime;
2458 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2459 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2460 if (msg_info->addressVal[0] != '\0') {
2461 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2462 if (_is_valid_email(msg_info->addressVal)) {
2463 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2465 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2469 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2470 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2472 if (contactInfo.firstName[0] == '\0')
2473 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2475 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2477 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2479 char sqlQuery[MAX_QUERY_LEN+1];
2480 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2482 int report_status_type;
2483 int report_status_value;
2485 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2486 report_status_type = MSG_REPORT_TYPE_READ;
2488 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2491 snprintf(sqlQuery, sizeof(sqlQuery),
2494 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE \"%%%s\";",
2495 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2497 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2499 char **db_res = NULL;
2500 int row_cnt = 0, col_cnt = 0;
2502 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2503 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2504 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2508 report_status_value = atoi(db_res[col_cnt]);
2510 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2512 msg_err = msg_db_free(msg_handle, db_res);
2513 if (msg_err != MSG_SUCCESS) {
2514 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2518 if (noti_info->msg_id > 0) {
2519 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2520 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2521 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2522 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2525 noti_info->extra_data = (unsigned char)report_status_value;
2529 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2533 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2538 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2542 createServiceHandle(¬i_info->svc_h);
2544 switch (noti_info->type) {
2545 case MSG_MGR_NOTI_TYPE_NORMAL: {
2546 if (noti_info->count > 1) {
2547 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2549 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2552 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2553 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2554 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2555 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2557 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
2559 if (noti_info->active_noti_button_num == 0)
2560 noti_info->active_noti_button_num = 3;
2563 case MSG_MGR_NOTI_TYPE_CB: {
2564 if (noti_info->count > 1) {
2565 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2567 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2570 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2571 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2572 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2574 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2575 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2577 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2579 noti_info->active_noti_button_num = 1;
2582 case MSG_MGR_NOTI_TYPE_SIM: {
2583 if (noti_info->count > 1) {
2584 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2586 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2589 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2590 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2591 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2593 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2594 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2596 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2598 if (noti_info->active_noti_button_num == 0)
2599 noti_info->active_noti_button_num = 3;
2602 case MSG_MGR_NOTI_TYPE_FAILED: {
2603 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2605 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2606 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2607 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2609 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2612 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2613 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2615 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2616 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2618 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2625 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2626 noti_info->active_noti_button_num = 0;
2632 void createServiceHandle(app_control_h *svc_h)
2634 int svc_err = APP_CONTROL_ERROR_NONE;
2636 svc_err = app_control_create(svc_h);
2638 if (svc_err != APP_CONTROL_ERROR_NONE)
2639 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2643 void setServiceAppId(app_control_h svc_h, const char* app_id)
2645 int svc_err = APP_CONTROL_ERROR_NONE;
2647 svc_err = app_control_set_app_id(svc_h, app_id);
2649 if (svc_err != APP_CONTROL_ERROR_NONE)
2650 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2654 void setServiceUri(app_control_h svc_h, const char* uri)
2656 int svc_err = APP_CONTROL_ERROR_NONE;
2658 svc_err = app_control_set_uri(svc_h, uri);
2660 if (svc_err != APP_CONTROL_ERROR_NONE)
2661 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2665 void setServiceOperation(app_control_h svc_h, const char* operation)
2667 int svc_err = APP_CONTROL_ERROR_NONE;
2669 svc_err = app_control_set_operation(svc_h, operation);
2671 if (svc_err != APP_CONTROL_ERROR_NONE)
2672 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2676 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2678 int svc_err = APP_CONTROL_ERROR_NONE;
2680 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2682 if (svc_err != APP_CONTROL_ERROR_NONE)
2683 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2687 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2689 int svc_err = APP_CONTROL_ERROR_NONE;
2692 memset(&tempId, 0x00, sizeof(tempId));
2693 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2695 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2697 if (svc_err != APP_CONTROL_ERROR_NONE)
2698 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2702 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2704 int svc_err = APP_CONTROL_ERROR_NONE;
2706 svc_err = app_control_set_app_id(svc_h, pkg_name);
2708 if (svc_err != APP_CONTROL_ERROR_NONE)
2709 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2713 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2715 int svc_err = APP_CONTROL_ERROR_NONE;
2717 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2719 if (svc_err != APP_CONTROL_ERROR_NONE)
2720 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2724 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2726 int noti_err = NOTIFICATION_ERROR_NONE;
2728 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2729 if (noti_err != NOTIFICATION_ERROR_NONE)
2730 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2734 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2736 int noti_err = NOTIFICATION_ERROR_NONE;
2738 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2740 if (noti_err != NOTIFICATION_ERROR_NONE)
2741 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2745 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2747 int noti_err = NOTIFICATION_ERROR_NONE;
2749 noti_err = notification_set_time_to_text(noti_h, type, time);
2751 if (noti_err != NOTIFICATION_ERROR_NONE)
2752 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2756 void setNotiTime(notification_h noti_h, time_t time)
2758 int noti_err = NOTIFICATION_ERROR_NONE;
2760 noti_err = notification_set_time(noti_h, time);
2762 if (noti_err != NOTIFICATION_ERROR_NONE)
2763 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2768 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2770 int noti_err = NOTIFICATION_ERROR_NONE;
2772 noti_err = notification_set_image(noti_h, type, image_path);
2774 if (noti_err != NOTIFICATION_ERROR_NONE)
2775 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2779 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2781 int noti_err = NOTIFICATION_ERROR_NONE;
2783 noti_err = notification_set_sound(noti_h, type, path);
2785 if (noti_err != NOTIFICATION_ERROR_NONE)
2786 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2790 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2792 int noti_err = NOTIFICATION_ERROR_NONE;
2794 noti_err = notification_set_vibration(noti_h, type, path);
2796 if (noti_err != NOTIFICATION_ERROR_NONE)
2797 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2801 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2803 int noti_err = NOTIFICATION_ERROR_NONE;
2805 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2807 if (noti_err != NOTIFICATION_ERROR_NONE)
2808 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2812 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2816 char *notiMsg = NULL;
2818 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2820 switch (noti_type) {
2821 case MSG_MGR_NOTI_TYPE_NORMAL:
2822 case MSG_MGR_NOTI_TYPE_SIM:
2823 case MSG_MGR_NOTI_TYPE_CB: {
2824 MSG_MGR_NOTI_INFO_S noti_info;
2825 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2827 noti_info.type = noti_type;
2828 int err = getLatestMsgInfo(¬i_info, true);
2831 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2832 if (noti_info.count == 1) {
2833 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2834 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2835 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2836 } else if (noti_info.count > 1) {
2837 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2839 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
2840 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2841 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2842 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2847 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2851 case MSG_MGR_NOTI_TYPE_FAILED: {
2852 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2853 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2854 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2858 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2859 goto _END_OF_INSTANT_NOTI;
2863 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2864 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2866 if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
2867 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
2869 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2870 MSG_MGR_DEBUG("Fail to notification_post");
2872 _END_OF_INSTANT_NOTI:
2874 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2875 MSG_MGR_DEBUG("Fail to notification_delete");
2882 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2883 MSG_MGR_DEBUG("Fail to notification_free");
2892 bool MsgMgrCheckNotificationSettingEnable()
2894 bool msg_noti_enabled = false;
2895 notification_system_setting_h system_setting = NULL;
2896 notification_setting_h setting = NULL;
2898 int err = NOTIFICATION_ERROR_NONE;
2900 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
2902 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
2903 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2905 msg_noti_enabled = true;
2907 bool allow_to_notify = false;
2908 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
2910 if (err != NOTIFICATION_ERROR_NONE) {
2911 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2915 if (allow_to_notify) {
2916 MSG_MGR_DEBUG("message notification is allowed");
2918 /* check do not disturb mode */
2919 err = notification_system_setting_load_system_setting(&system_setting);
2921 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
2922 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
2926 bool do_not_disturb_mode = false;
2927 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
2929 if (err != NOTIFICATION_ERROR_NONE) {
2930 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2934 if (do_not_disturb_mode) {
2935 bool is_msg_excepted = false;
2936 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
2937 if (err != NOTIFICATION_ERROR_NONE) {
2938 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2939 msg_noti_enabled = false;
2941 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
2942 msg_noti_enabled = (is_msg_excepted) ? true : false;
2945 MSG_MGR_DEBUG("do not disturb mode is off");
2948 MSG_MGR_INFO("message notification is not allowed");
2949 msg_noti_enabled = false;
2955 notification_system_setting_free_system_setting(system_setting);
2958 notification_setting_free_notification(setting);
2960 return msg_noti_enabled;
2964 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
2966 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
2967 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
2969 MsgMgrChangePmState();
2971 char *notiMsg = NULL;
2972 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
2975 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
2976 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
2978 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
2979 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
2980 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
2981 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
2982 notification_status_message_post(pTickerMsg);
2984 notification_status_message_post(notiMsg);
2987 /* Show ticker popup for sending failed msg. */
2988 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
2996 if (bPlayFeedback) {
2998 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
2999 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
3001 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
3003 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
3004 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
3006 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
3009 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
3017 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
3019 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
3021 int err = BADGE_ERROR_NONE;
3024 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
3026 if (err != BADGE_ERROR_NONE) {
3027 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
3033 err = badge_add(MSG_DEFAULT_APP_ID);
3034 if (err != BADGE_ERROR_NONE) {
3035 MSG_MGR_ERR("Fail to badge_add : %d", err);
3040 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
3042 if (err != BADGE_ERROR_NONE) {
3043 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3051 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3055 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3057 #ifndef MSG_NOTI_INTEGRATION
3058 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3059 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3067 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3073 struct tm repeat_tm;
3077 tmp_time += (RepeatTime*60);
3079 localtime_r(&tmp_time, &repeat_tm);
3081 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3082 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3086 g_alarmId = tmpAlarmId;
3087 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3095 void MsgMgrSoundSetRepeatAlarm()
3097 int nRepeatValue = 0;
3098 long nRepeatTime = 0;
3100 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3101 MSG_MGR_INFO("vconf_get_int() is failed");
3104 switch (nRepeatValue) {
3105 case MSG_ALERT_TONE_ONCE:
3108 case MSG_ALERT_TONE_2MINS:
3111 case MSG_ALERT_TONE_5MINS:
3114 case MSG_ALERT_TONE_10MINS:
3118 MSG_MGR_DEBUG("Invalid Repetition time");
3122 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3124 if (nRepeatTime > 0) {
3125 if (g_alarmId > 0) {
3126 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3127 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3131 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3138 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3140 char *notiMsg = NULL;
3143 lang = vconf_get_str(VCONFKEY_LANGSET);
3145 setlocale(LC_MESSAGES, lang);
3147 bindtextdomain(pkg_name, locale_dir);
3149 notiMsg = dgettext(pkg_name, text);
3156 return g_strdup(notiMsg);