2 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*==================================================================================================
19 ==================================================================================================*/
29 #include <app_control.h>
30 #include <badge_internal.h>
31 #include <notification_list.h>
32 #include <notification_text_domain.h>
33 #include <notification_internal.h>
34 #include <notification_status.h>
35 #include <notification_setting.h>
36 #include <notification_setting_internal.h>
37 #include <package_manager.h>
41 #include <msg_storage.h>
43 #include <msg-manager-util.h>
44 #include <msg-manager-contact.h>
45 #include <msg-manager-debug.h>
46 #include <msg-manager-notification.h>
47 #include <msg-manager-sound.h>
52 /*==================================================================================================
54 ==================================================================================================*/
56 static GList *msg_report_notification_list = NULL;
57 static bool is_init = false;
58 extern msg_handle_t msg_handle;
62 /*==================================================================================================
64 ==================================================================================================*/
65 typedef struct _report_notification_s
68 char addressVal[MAX_ADDRESS_VAL_LEN+1];
69 } report_notification_s;
72 typedef struct _msg_mgr_noti_info_s
74 msg_mgr_notification_type_t type;
80 char sender[MSG_NOTI_TEXT_LEN_S+1];
81 char text[MSG_NOTI_TEXT_LEN+1];
82 char number[MSG_NOTI_TEXT_LEN_S+1];
83 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
86 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
87 msg_message_id_t msg_id;
89 unsigned char extra_data;
91 int active_noti_button_num;
93 int active_media_size;
94 unsigned char active_subtype; /**< to distinguish cb, push message */
95 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
96 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
97 char active_text[MSG_NOTI_TEXT_LEN+1];
98 } MSG_MGR_NOTI_INFO_S;
101 typedef struct _del_noti_info_s
103 msg_mgr_notification_type_t type;
108 /*==================================================================================================
110 ===================================================================================================*/
112 void MsgMgrInitReportNotiList();
113 void MsgInitNotiCb(void *data);
114 void MsgRefreshNotiCb(void *data);
115 void MsgMgrDeleteNotiCb(void *data);
117 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
118 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result);
120 notification_h getHandle(int *noti_id);
122 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
123 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
125 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
126 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
127 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
128 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
130 int getAppIcon(const char *app_id, char **icon_path);
131 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
133 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
134 void setTextDomain(notification_h noti_h);
135 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
136 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
137 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
138 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
139 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
140 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
141 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
143 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
146 void createServiceHandle(app_control_h *svc_h);
147 void setServiceAppId(app_control_h svc_h, const char* app_id);
148 void setServiceUri(app_control_h svc_h, const char* uri);
149 void setServiceOperation(app_control_h svc_h, const char* operation);
150 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
151 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
152 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
153 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
155 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
156 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
157 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
158 void setNotiTime(notification_h noti_h, time_t time);
159 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
160 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
161 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
162 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
165 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
166 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
167 void MsgMgrSoundSetRepeatAlarm();
169 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
171 /*==================================================================================================
172 FUNCTION IMPLEMENTATION
173 ==================================================================================================*/
174 bool _is_valid_email(char *pAddress)
176 if (!pAddress || pAddress[0] == 0)
178 if (!strchr (pAddress, EMAIL_AT))
184 void MsgMgrInitReportNotiList()
188 if (msg_report_notification_list) {
189 MSG_MGR_DEBUG("Report Noti List is already inited");
193 msg_report_notification_list = NULL;
195 notification_h noti = NULL;
196 notification_list_h noti_list = NULL;
197 notification_list_h head_noti_list = NULL;
198 int noti_err = NOTIFICATION_ERROR_NONE;
199 app_control_h app_control = NULL;
201 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
202 if (noti_err != NOTIFICATION_ERROR_NONE) {
203 MSG_MGR_DEBUG("notification_get_list() is failed!!");
207 head_noti_list = noti_list;
209 while (noti_list != NULL) {
210 noti = notification_list_get_data(noti_list);
212 MSG_MGR_DEBUG("notification_list_get_data() failed!!");
216 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
217 memset(tempAddr, 0x00, sizeof(tempAddr));
219 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
220 if (noti_err != NOTIFICATION_ERROR_NONE) {
221 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
225 char *is_report_noti = NULL;
227 int ret = app_control_get_extra_data(app_control, "is_report_noti", &is_report_noti);
228 if (ret == APP_CONTROL_ERROR_NONE && is_report_noti != NULL && g_strcmp0(is_report_noti, "true") == 0) {
231 ret = app_control_get_extra_data(app_control, "address", &addr);
232 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
233 report_notification_s *info = new report_notification_s;
234 memset(info, 0x00, sizeof(report_notification_s));
236 notification_get_id(noti, NULL, &(info->priv_id));
237 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
239 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
240 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
247 if (is_report_noti) {
248 g_free(is_report_noti);
249 is_report_noti = NULL;
253 noti_list = notification_list_get_next(noti_list);
257 notification_free_list(head_noti_list);
263 void MsgMgrInitNoti()
268 bool bNotiSvcReady = false;
270 bNotiSvcReady = notification_is_service_ready();
272 if (bNotiSvcReady == true) {
273 MSG_MGR_DEBUG("Notification server is available");
274 MsgMgrInitReportNotiList();
276 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
277 notification_add_deferred_task(MsgInitNotiCb, NULL);
284 void MsgInitNotiCb(void *data)
286 MsgMgrInitReportNotiList();
299 bool bNotiSvcReady = false;
301 bNotiSvcReady = notification_is_service_ready();
303 if (bNotiSvcReady == true) {
304 MSG_MGR_DEBUG("Notification server is available");
305 #ifndef MSG_NOTI_INTEGRATION
306 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
308 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
310 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
311 #ifndef MSG_NOTI_INTEGRATION
312 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
314 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
315 delNotiInfo->sim_idx = -1;
317 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
319 notification_add_deferred_task(MsgRefreshNotiCb, NULL);
324 void MsgRefreshNotiCb(void *data)
326 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
337 void MsgMgrDeleteNotiCb(void *data)
340 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)data;
342 MsgMgrDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx);
352 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
356 notification_h noti_h = NULL;
358 MSG_MGR_NOTI_INFO_S noti_info = {0, };
360 noti_info.type = noti_type;
361 noti_info.active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CLASS0_MESSAGE;
363 createActiveInfoData(¬i_info, msg_info);
365 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
367 setActiveNotification(noti_h, ¬i_info);
369 clearInfoData(noti_h, ¬i_info);
376 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
379 notification_h noti_h = NULL;
380 int bNotification = 1;
381 /* bool bReplyPopup = false; */
383 MSG_MGR_NOTI_INFO_S noti_info = {0, };
384 noti_info.type = noti_type;
385 noti_info.id = getPrivId(noti_info.type, -1);
387 err = getLatestMsgInfo(¬i_info, false);
390 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
391 goto __END_OF_REFRESH_NOTI;
394 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
395 err = MsgMgrInsertInstantMessage(noti_type);
398 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
399 goto __END_OF_REFRESH_NOTI;
403 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
404 MSG_MGR_DEBUG("vconf_get_bool is failed.");
407 if (bNotification == 0) {
408 MSG_MGR_DEBUG("Msg Alert notification is off.");
409 goto __END_OF_REFRESH_NOTI;
412 createInfoData(¬i_info, active_type);
414 noti_h = getHandle(¬i_info.id);
416 if (noti_h == NULL) {
417 MSG_MGR_DEBUG("Notification handle is NULL");
418 err = MSG_ERR_NULL_POINTER;
419 goto __END_OF_REFRESH_NOTI;
422 setNotification(noti_h, ¬i_info, bFeedback);
424 __END_OF_REFRESH_NOTI :
425 clearInfoData(noti_h, ¬i_info);
431 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
435 notification_h noti_h = NULL;
437 report_notification_s *info = new report_notification_s;
438 memset(info, 0x00, sizeof(report_notification_s));
440 MSG_MGR_NOTI_INFO_S noti_info = {0, };
441 noti_info.type = noti_type;
443 createInfoData(¬i_info, msg_info);
445 noti_h = getHandle(¬i_info.id);
447 if (noti_h == NULL) {
448 MSG_MGR_DEBUG("Notification handle is NULL");
450 goto __END_OF_ADD_REPORT_NOTI;
453 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT || noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
454 noti_info.applist &= ~NOTIFICATION_DISPLAY_APP_TICKER;
456 ret = MsgMgrInsertDeliveryReportInstantNotification(noti_type, noti_info.extra_data);
459 MSG_MGR_ERR(" MsgInsertInstantDeliveryReportNotification() err = [%d]", ret);
460 goto __END_OF_ADD_REPORT_NOTI;
464 addServiceExtraData(noti_info.svc_h, "is_report_noti", "true");
465 setNotification(noti_h, ¬i_info, true);
467 info->priv_id = noti_info.id;
468 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
469 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
470 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
472 __END_OF_ADD_REPORT_NOTI :
473 clearInfoData(noti_h, ¬i_info);
479 int MsgMgrDeleteReportNotification(const char *addr)
483 notification_h noti_h = NULL;
484 int bNotification = 1;
486 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
487 MSG_MGR_DEBUG("vconf_get_bool is failed.");
490 if (bNotification == 0) {
491 MSG_MGR_DEBUG("Msg Alert notification is off.");
495 char* normalAddr = NULL;
496 unsigned int list_length = g_list_length(msg_report_notification_list);
497 bool isDelete = false;
499 MSG_MGR_DEBUG("list length [%d]", list_length);
501 if (list_length > 0) {
502 GList *iter = g_list_first(msg_report_notification_list);
504 while (iter != NULL) {
506 report_notification_s *info = (report_notification_s*)(iter->data);
508 MSG_MGR_DEBUG("info is NULL!");
512 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
514 noti_h = notification_load(NULL, info->priv_id);
515 if (noti_h == NULL) {
516 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
519 normalAddr = msg_mgr_normalize_number(info->addressVal);
522 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
524 if (g_str_has_suffix(addr, normalAddr)) {
525 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
526 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
529 MSG_MGR_DEBUG("delete notification failed");
534 notification_free(noti_h);
538 iter = g_list_next(iter);
541 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
555 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
559 notification_h noti_h = NULL;
561 MSG_MGR_NOTI_INFO_S noti_info = {0, };
563 noti_info.type = noti_type;
565 createInfoData(¬i_info, msg_info);
567 /* check mwi or voicemail count is 0 then skip add notification */
568 if (noti_info.count == 0) {
569 MSG_MGR_DEBUG("Notification count is 0");
571 goto __END_OF_ADD_NOTI;
574 noti_h = getHandle(¬i_info.id);
576 if (noti_h == NULL) {
577 MSG_MGR_DEBUG("Notification handle is NULL");
579 goto __END_OF_ADD_NOTI;
582 setNotification(noti_h, ¬i_info, true);
585 clearInfoData(noti_h, ¬i_info);
591 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex)
593 int noti_err = NOTIFICATION_ERROR_NONE;
595 if (noti_type == MSG_MGR_NOTI_TYPE_ALL) {
596 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
597 } else if (noti_type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_type == MSG_MGR_NOTI_TYPE_VOICE_2 || noti_type == MSG_MGR_NOTI_TYPE_SIM) {
600 notiId = getPrivId(noti_type, simIndex);
601 MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
604 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, notiId);
607 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
610 if (noti_err != NOTIFICATION_ERROR_NONE) {
611 MSG_MGR_DEBUG("Fail to notification_delete_all noti_err [%d]", noti_err);
614 updatePrivId(noti_type, 0, simIndex);
618 int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
620 bool bNotiSvcReady = false;
622 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S));
625 delNotiInfo->type = noti_type;
626 delNotiInfo->sim_idx = simIndex;
629 bNotiSvcReady = notification_is_service_ready();
631 if (bNotiSvcReady == true) {
632 MSG_MGR_DEBUG("Notification server is available");
633 MsgMgrDeleteNotiCb((void *)delNotiInfo);
635 MSG_MGR_DEBUG("Notification server is not available. Delete is defered");
636 notification_add_deferred_task(MsgMgrDeleteNotiCb, (void *)delNotiInfo);
642 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
648 #ifndef MSG_NOTI_INTEGRATION
649 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
652 #ifdef MSG_NOTI_INTEGRATION
653 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
655 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
657 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
659 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
661 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
663 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
666 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
668 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
672 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
674 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
680 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
684 int noti_err = NOTIFICATION_ERROR_NONE;
687 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
688 if (noti_err != NOTIFICATION_ERROR_NONE) {
689 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
693 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
694 if (noti_err != NOTIFICATION_ERROR_NONE) {
695 MSG_MGR_DEBUG("Fail to notification_set_led.");
698 /* set execute option and property */
699 switch (noti_info->type) {
700 case MSG_MGR_NOTI_TYPE_NORMAL: {
701 if (noti_info->count > 1) {
702 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
704 if (noti_info->svc_h) { /* overwrite bundle key "type" */
705 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
706 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
708 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
711 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
714 case MSG_MGR_NOTI_TYPE_CB:
715 case MSG_MGR_NOTI_TYPE_SIM: {
716 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
717 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
720 case MSG_MGR_NOTI_TYPE_FAILED: {
721 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
722 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
725 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
726 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
729 case MSG_MGR_NOTI_TYPE_VOICE_1:
730 case MSG_MGR_NOTI_TYPE_VOICE_2:
731 case MSG_MGR_NOTI_TYPE_MWI:
732 case MSG_MGR_NOTI_TYPE_CLASS0:
733 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
734 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
735 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
736 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
740 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
745 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
746 if (noti_err != NOTIFICATION_ERROR_NONE) {
747 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
751 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
752 if (noti_err != NOTIFICATION_ERROR_NONE) {
753 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
760 void setTextDomain(notification_h noti_h)
764 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
769 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
773 char unreadMsgCntStr[10] = {0};
776 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
777 MSG_MGR_DEBUG("vconf_get_bool is failed.");
780 /* set title and content */
781 switch (noti_info->type) {
782 #ifdef MSG_NOTI_INTEGRATION
783 case MSG_MGR_NOTI_TYPE_NORMAL:
784 case MSG_MGR_NOTI_TYPE_CB:
785 case MSG_MGR_NOTI_TYPE_SIM: {
786 if (noti_info->count > 1) {
787 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
788 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
789 setNotiTime(noti_h, noti_info->time);
791 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
792 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
796 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
797 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
799 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
800 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
802 setNotiTime(noti_h, noti_info->time);
807 case MSG_MGR_NOTI_TYPE_NORMAL: {
808 if (noti_info->count > 1) {
809 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
810 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
811 setNotiTime(noti_h, noti_info->time);
813 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
814 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
817 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
818 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
820 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
821 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
823 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
824 setNotiTime(noti_h, noti_info->time);
828 case MSG_MGR_NOTI_TYPE_CB: {
829 if (noti_info->count > 1) {
830 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
831 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
832 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
833 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
834 setNotiTime(noti_h, noti_info->time);
837 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
838 setNotiTime(noti_h, noti_info->time);
841 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
842 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
844 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
845 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
850 case MSG_MGR_NOTI_TYPE_SIM: {
851 if (noti_info->count > 1) {
852 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
853 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
854 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
856 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
857 setNotiTime(noti_h, noti_info->time);
859 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
860 setNotiTime(noti_h, noti_info->time);
863 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
864 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
866 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
867 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
873 case MSG_MGR_NOTI_TYPE_FAILED: {
874 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
875 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
876 if (noti_info->count > 1) {
877 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
878 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
880 setNotiTime(noti_h, noti_info->time);
883 case MSG_MGR_NOTI_TYPE_VOICE_1:
884 case MSG_MGR_NOTI_TYPE_VOICE_2: {
885 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
886 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
887 setNotiTime(noti_h, noti_info->time);
889 if (noti_info->count == 1) {
890 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
891 } else if (noti_info->count > 1) {
892 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
893 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
895 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
899 case MSG_MGR_NOTI_TYPE_MWI: {
900 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
901 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
902 setNotiTime(noti_h, noti_info->time);
905 case MSG_MGR_NOTI_TYPE_CLASS0: {
906 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
907 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
908 setNotiTime(noti_h, noti_info->time);
911 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
912 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
913 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
915 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
916 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
917 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
918 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
920 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
923 setNotiTime(noti_h, noti_info->time);
926 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
927 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
928 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
930 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
931 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
932 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
934 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
935 /* notification free */
938 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
941 setNotiTime(noti_h, noti_info->time);
944 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
945 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
946 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
948 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) {
949 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
950 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) {
951 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", MESSAGE_REJECTED);
952 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) {
953 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
954 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED || noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE
955 || noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED || noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE
956 || noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) {
957 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Recipient not available", RECIPIENT_NOT_AVAILABLE);
959 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
962 setNotiTime(noti_h, noti_info->time);
965 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
966 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
967 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
971 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
978 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
982 switch (noti_info->type) {
983 #ifdef MSG_NOTI_INTEGRATION
984 case MSG_MGR_NOTI_TYPE_NORMAL:
985 case MSG_MGR_NOTI_TYPE_CB:
986 case MSG_MGR_NOTI_TYPE_SIM: {
987 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
988 if (noti_info->count > 1 && noti_info->senderCount > 1) {
989 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
990 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
991 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
993 if (noti_info->active_subtype == MSG_CB_SMS) {
994 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
995 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
996 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
997 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
998 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
999 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
1000 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1002 if (noti_info->imagePath[0] != '\0') {
1003 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
1004 /* for user profile image, use NOTIFICATION_IMAGE_TYPE_THUMBNAIL to show icon as circle */
1005 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, noti_info->imagePath);
1007 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1008 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1011 char *msg_icon_path = NULL;
1012 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1013 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1014 g_free(msg_icon_path);
1016 MSG_MGR_ERR("fail to get message-app icon");
1023 case MSG_MGR_NOTI_TYPE_NORMAL: {
1024 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1025 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
1027 if (noti_info->count > 1) {
1028 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1030 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
1034 case MSG_MGR_NOTI_TYPE_CB: {
1035 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1036 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1039 case MSG_MGR_NOTI_TYPE_SIM: {
1040 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1041 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1045 case MSG_MGR_NOTI_TYPE_FAILED: {
1046 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1047 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_FAILED_STATUS_ICON);
1050 case MSG_MGR_NOTI_TYPE_VOICE_1:
1051 case MSG_MGR_NOTI_TYPE_VOICE_2:
1052 case MSG_MGR_NOTI_TYPE_MWI: {
1053 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1054 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1057 case MSG_MGR_NOTI_TYPE_CLASS0:
1058 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1060 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1061 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1062 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1064 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1065 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1066 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1068 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1069 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1070 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1072 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1073 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1074 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1077 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1084 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1088 int noti_err = NOTIFICATION_ERROR_NONE;
1091 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1092 if (noti_err != NOTIFICATION_ERROR_NONE) {
1093 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1097 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1098 if (noti_err != NOTIFICATION_ERROR_NONE) {
1099 MSG_MGR_DEBUG("Fail to notification_set_led.");
1102 /* set execute option and property */
1103 switch (noti_info->type) {
1104 case MSG_MGR_NOTI_TYPE_NORMAL:
1105 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1106 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
1108 case MSG_MGR_NOTI_TYPE_CLASS0:
1109 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1112 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
1117 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1118 if (noti_err != NOTIFICATION_ERROR_NONE) {
1119 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1123 noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
1124 if (noti_err != NOTIFICATION_ERROR_NONE) {
1125 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
1132 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1136 switch (noti_info->type) {
1137 case MSG_MGR_NOTI_TYPE_NORMAL:
1138 case MSG_MGR_NOTI_TYPE_SIM:
1139 case MSG_MGR_NOTI_TYPE_CB: {
1140 if (noti_info->active_subject[0] == '\0') {
1141 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1142 if (noti_info->active_text[0] != '\0') {
1143 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1145 if (noti_info->active_media_cnt > 1) {
1146 char attach_string[20] = {0,};
1147 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1148 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
1149 } else if (noti_info->active_media_cnt == 1) {
1150 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
1154 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1155 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1156 if (noti_info->active_text[0] != '\0') {
1157 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1159 if (noti_info->active_media_cnt > 1) {
1160 char attach_string[20] = {0,};
1161 snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1162 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
1163 } else if (noti_info->active_media_cnt == 1) {
1164 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
1170 case MSG_MGR_NOTI_TYPE_CLASS0: {
1171 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1172 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1176 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1184 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1188 switch (noti_info->type) {
1189 case MSG_MGR_NOTI_TYPE_NORMAL:
1190 case MSG_MGR_NOTI_TYPE_SIM: {
1191 switch (noti_info->active_subtype) {
1193 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1195 case MSG_WAP_SI_SMS:
1196 case MSG_WAP_SL_SMS:
1197 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1200 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1203 if (noti_info->imagePath[0] != '\0')
1204 /* for user profile image, use NOTIFICATION_IMAGE_TYPE_THUMBNAIL to show icon as circle */
1205 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, noti_info->imagePath);
1207 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1209 char *msg_icon_path = NULL;
1210 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1211 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1212 g_free(msg_icon_path);
1214 MSG_MGR_ERR("fail to get message-app icon");
1222 case MSG_MGR_NOTI_TYPE_CB: {
1223 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1226 case MSG_MGR_NOTI_TYPE_CLASS0:
1227 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1230 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1238 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result)
1242 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
1243 notification_set_pkgname(noti, MSG_DEFAULT_APP_ID);
1245 setTextDomain(noti);
1246 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
1247 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVER_REPORT_STATUS_ICON);
1249 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT) {
1250 if (result == MSG_NETWORK_DELIVER_SUCCESS) {
1251 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1252 } else if (result == MSG_NETWORK_DELIVER_EXPIRED) {
1253 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1254 } else if (result == MSG_NETWORK_DELIVER_PENDING) {
1255 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1257 MSG_MGR_ERR("unexpected result! [%d]", result);
1258 goto _END_OF_INSTANT_DELIVERY_REPORT_NOTI;
1260 } else if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
1261 if (result == MSG_DELIVERY_REPORT_EXPIRED)
1262 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1263 else if (result== MSG_DELIVERY_REPORT_REJECTED)
1264 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message rejected by recipient.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_REJECTED);
1265 else if (result == MSG_DELIVERY_REPORT_DEFERRED)
1266 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1267 else if (result == MSG_DELIVERY_REPORT_UNRECOGNISED || result == MSG_DELIVERY_REPORT_INDETERMINATE ||
1268 result == MSG_DELIVERY_REPORT_FORWARDED || result == MSG_DELIVERY_REPORT_UNREACHABLE ||
1269 result == MSG_DELIVERY_REPORT_ERROR)
1270 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Recipient not available.", UNABLE_TO_DELIVER_MESSAGE_RECIPIENT_NOT_AVAILABLE);
1272 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1275 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
1276 MSG_MGR_ERR("Fail to notification_set_display_applist");
1278 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
1279 MSG_MGR_ERR("Fail to notification_post");
1281 _END_OF_INSTANT_DELIVERY_REPORT_NOTI:
1283 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
1284 MSG_MGR_ERR("Fail to notification_delete");
1287 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
1288 MSG_MGR_ERR("Fail to notification_free");
1297 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1301 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1302 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1304 if (addressVal != NULL) {
1305 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1306 /* Get Contact Info */
1307 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1308 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1311 MSG_MGR_DEBUG("addressVal is NULL.");
1314 char *msg_tone_file_path = NULL;
1316 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1318 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1320 bool bPlaySound = false;
1321 bool bPlayVibration = false;
1322 bool bOnCall = false;
1324 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1327 if (msg_tone_file_path) {
1328 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1331 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1332 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1334 int ringtoneType = tmpVal;
1335 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1336 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1338 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1341 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1344 if (bPlayVibration) {
1345 if (contactInfo.vibrationPath[0] == '\0')
1346 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1348 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1350 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1353 if (msg_tone_file_path)
1354 delete [] msg_tone_file_path;
1360 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1364 int noti_err = NOTIFICATION_ERROR_NONE;
1366 if (noti_info->active_noti_button_num > 1) {
1367 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1368 if (noti_info->active_noti_svc_h[0]) {
1369 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1370 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1372 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1374 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1375 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1376 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1377 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1380 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1381 if (noti_info->active_noti_svc_h[1]) {
1382 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1384 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1385 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1386 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1388 char slot_id[5] = {0, };
1389 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1390 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1394 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1395 if (noti_info->active_noti_svc_h[2]) {
1396 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1398 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1399 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1400 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1401 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1403 char slot_id[5] = {0, };
1404 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1405 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1408 if (noti_info->active_noti_button_num > 1) {
1409 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1410 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1411 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1413 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1414 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1415 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1417 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1419 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1422 setActiveProperty(noti_h, noti_info);
1424 setTextDomain(noti_h);
1426 setActiveText(noti_h, noti_info);
1428 setActiveIcon(noti_h, noti_info);
1430 noti_err = notification_post(noti_h);
1431 if (noti_err != NOTIFICATION_ERROR_NONE) {
1432 MSG_MGR_DEBUG("Fail to notification_post");
1439 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1443 int noti_err = NOTIFICATION_ERROR_NONE;
1445 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1447 if (bFeedback && noti_info->active_noti_button_num > MSG_ACTIVE_NOTI_BUTTON_NUM_NONE &&
1448 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1449 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1451 setActiveNotification(active_noti_h, noti_info);
1453 notification_free(active_noti_h);
1454 active_noti_h = NULL;
1457 setProperty(noti_h, noti_info);
1459 setTextDomain(noti_h);
1461 setText(noti_h, noti_info);
1463 setIcon(noti_h, noti_info);
1466 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1467 setSoundAndVibration(noti_h, noti_info->number, true);
1469 setSoundAndVibration(noti_h, noti_info->number, false);
1472 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1473 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1476 if (noti_info->id > 0) {
1477 MSG_MGR_DEBUG("Notification update");
1478 noti_err = notification_update(noti_h);
1479 if (noti_err != NOTIFICATION_ERROR_NONE) {
1480 MSG_MGR_DEBUG("Fail to notification_update");
1483 MSG_MGR_DEBUG("Notification insert");
1484 noti_err = notification_insert(noti_h, ¬i_info->id);
1485 if (noti_err != NOTIFICATION_ERROR_NONE) {
1486 MSG_MGR_DEBUG("Fail to notification_insert");
1489 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1496 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1501 MSG_MGR_DEBUG("msg_info is NULL");
1505 noti_info->msg_id = msg_info->msgId;
1506 noti_info->sim_idx = msg_info->sim_idx;
1508 switch (noti_info->type) {
1509 case MSG_MGR_NOTI_TYPE_NORMAL: {
1510 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1511 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1518 case MSG_MGR_NOTI_TYPE_CLASS0: {
1519 if (msg_info->displayName[0] == '\0')
1520 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1522 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1524 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1528 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1536 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1541 notification_free(noti_h);
1545 if (noti_info->svc_h) {
1546 app_control_destroy(noti_info->svc_h);
1547 noti_info->svc_h = NULL;
1550 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1551 if (noti_info->active_noti_svc_h[i]) {
1552 app_control_destroy(noti_info->active_noti_svc_h[i]);
1553 noti_info->active_noti_svc_h[i] = NULL;
1561 int getAppIcon(const char *app_id, char **icon_path)
1565 package_info_h pkg_info_h = NULL;
1566 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1569 if (app_id == NULL) {
1570 MSG_MGR_ERR("app id is NULL");
1572 goto END_OF_GET_APP_ICON;
1575 pkg_err = package_info_create(app_id, &pkg_info_h);
1576 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1577 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1579 goto END_OF_GET_APP_ICON;
1582 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1583 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1584 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1587 if (icon_path == NULL) {
1588 MSG_MGR_WARN("icon path is NULL");
1593 END_OF_GET_APP_ICON:
1595 pkg_err = package_info_destroy(pkg_info_h);
1596 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1597 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1609 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1614 msg_error_t msg_err = MSG_SUCCESS;
1615 char **db_res = NULL;
1616 int row_cnt = 0, col_cnt = 0;
1618 switch (noti_info->type) {
1619 case MSG_MGR_NOTI_TYPE_NORMAL:
1620 #ifdef MSG_NOTI_INTEGRATION
1621 case MSG_MGR_NOTI_TYPE_CB:
1622 case MSG_MGR_NOTI_TYPE_SIM:
1625 int smsUnreadCnt = 0;
1626 int mmsUnreadCnt = 0;
1628 char sqlQuery[MAX_QUERY_LEN +1];
1629 unsigned char mainType;
1630 unsigned char subType;
1631 int msgSize, attachmentCnt;
1633 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1634 #ifdef MSG_NOTI_INTEGRATION
1635 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1639 "WHERE A.CONV_ID=B.CONV_ID "
1640 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1641 "AND B.STORAGE_ID = %d "
1642 "GROUP BY A.ADDRESS_VAL "
1643 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1644 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1645 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1648 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1652 "WHERE A.CONV_ID=B.CONV_ID "
1653 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1654 "AND B.STORAGE_ID = %d "
1655 "GROUP BY A.ADDRESS_VAL "
1656 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1657 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1661 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1663 row_cnt = 0, col_cnt = 0;
1664 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1665 if (msg_err != MSG_SUCCESS) {
1666 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1670 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1671 int normalAddCnt = 0;
1672 int index = col_cnt;
1674 for (int i = 1; i <= row_cnt; i++) {
1675 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1677 char *address = db_res[index++];
1680 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1681 if (_is_valid_email(address)) {
1682 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1684 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1687 subType = atoi(db_res[index++]);
1689 MSG_MGR_CONTACT_INFO_S tmpContact;
1690 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1692 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1695 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1698 if (normalAddCnt > 1) {
1699 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1702 if (tmpContact.firstName[0] != '\0') {
1703 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1704 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1705 char *senderStr = NULL;
1706 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1707 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1714 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_UNKNOWN_SENDER;
1717 char *senderStr = NULL;
1718 if (subType == MSG_CB_SMS) {
1719 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1720 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1721 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
1722 } else if (subType == MSG_SYNCML_CP) {
1723 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1724 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1725 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_PUSH_MESSAGE;
1726 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1727 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1728 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1729 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_PUSH_MESSAGE;
1731 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1741 noti_info->active_subtype = subType;
1742 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1743 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1747 noti_info->senderCount = normalAddCnt;
1748 msg_db_free(msg_handle, db_res);
1750 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1752 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1753 snprintf(sqlQuery, MAX_QUERY_LEN,
1754 "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS SMS_UNREAD_CNT, "
1755 "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS MMS_UNREAD_CNT "
1756 "FROM %s WHERE READ_STATUS = 0 AND (FOLDER_ID=%d OR FOLDER_ID=%d) AND STORAGE_ID = %d;",
1759 MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE);
1761 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1763 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1764 if (msg_err != MSG_SUCCESS) {
1765 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1770 smsUnreadCnt = atoi(db_res[col_cnt]);
1771 mmsUnreadCnt = atoi(db_res[col_cnt+1]);
1774 msg_db_free(msg_handle, db_res);
1776 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1777 #ifdef MSG_NOTI_INTEGRATION
1778 snprintf(sqlQuery, sizeof(sqlQuery),
1782 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
1783 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
1786 "(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), "
1787 "B.ATTACHMENT_COUNT "
1789 "LEFT JOIN %s A ON A.CONV_ID=B.CONV_ID "
1790 "WHERE B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1791 "AND B.STORAGE_ID = %d "
1792 "ORDER BY B.DISPLAY_TIME DESC;",
1793 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1794 MSGFW_MESSAGE_TABLE_NAME,
1795 MSGFW_ADDRESS_TABLE_NAME,
1796 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1799 snprintf(sqlQuery, sizeof(sqlQuery),
1806 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1807 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1809 "WHERE A.CONV_ID=B.CONV_ID "
1810 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1811 "AND B.STORAGE_ID = %d "
1812 "ORDER BY B.DISPLAY_TIME DESC;",
1815 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1819 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1821 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1822 if (msg_err != MSG_SUCCESS) {
1823 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1828 msgSize = atoi(db_res[col_cnt+7]);
1829 attachmentCnt = atoi(db_res[col_cnt+8]);
1831 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1833 if (noti_info->count > 0) {
1834 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1836 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1838 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1840 noti_info->conv_id = atoi(db_res[col_cnt+6]);
1842 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1844 if (mainType == MSG_MMS_TYPE) {
1845 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1846 if (noti_info->text[0] == '\0') {
1847 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1848 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1852 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1853 if (prefix_subject) {
1854 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1855 g_free(prefix_subject);
1857 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1861 int kb_msg_size = msgSize / 1024;
1862 if (kb_msg_size == 0 && msgSize > 0)
1864 else if (msgSize % 1024 >= 512)
1867 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1868 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1870 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1872 g_free(msg_size_string);
1873 g_free(msg_size_unit_kb);
1876 noti_info->active_media_cnt = attachmentCnt;
1879 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1882 if (noti_info->active_text[0] == '\0')
1883 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1885 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1887 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1888 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1889 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1891 if (!isForInstantMessage) {
1892 if (noti_info->id > 0 && noti_info->count == 1) {
1893 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1894 if (noti_err != NOTIFICATION_ERROR_NONE) {
1895 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1899 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1900 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1903 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1904 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1905 MsgMgrInsertBadge(noti_info->count);
1906 MsgMgrSoundSetRepeatAlarm();
1909 MSG_MGR_DEBUG("No unread message.");
1910 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1912 msg_db_free(msg_handle, db_res);
1914 if (!isForInstantMessage) {
1915 /* No unread message. */
1916 if (noti_info->id > 0) {
1917 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
1918 if (noti_err != NOTIFICATION_ERROR_NONE) {
1919 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1925 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1926 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1928 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1929 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1930 MsgMgrInsertBadge(0);
1931 MsgMgrSoundSetRepeatAlarm();
1937 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1938 msg_db_free(msg_handle, db_res);
1942 msg_db_free(msg_handle, db_res);
1946 #ifndef MSG_NOTI_INTEGRATION
1947 case MSG_MGR_NOTI_TYPE_CB: {
1948 char sqlQuery[MAX_QUERY_LEN+1];
1949 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1951 snprintf(sqlQuery, sizeof(sqlQuery),
1957 "WHERE A.CONV_ID=B.CONV_ID "
1958 "AND B.READ_STATUS=0 "
1959 "AND B.FOLDER_ID=%d "
1960 "AND B.STORAGE_ID = %d "
1961 "ORDER BY B.DISPLAY_TIME DESC;",
1962 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1966 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1967 return MSG_ERR_DB_PREPARE;
1969 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1970 MSG_ADDRESS_INFO_S addrInfo;
1971 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1973 if (dbhandler->columnText(0) != NULL)
1974 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1976 MSG_CONTACT_INFO_S tmpContact;
1977 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1979 MsgGetContactInfo(&addrInfo, &tmpContact);
1981 if (tmpContact.firstName[0] != '\0') {
1982 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1983 } else if (addrInfo.addressVal[0] == '\0') {
1984 char *senderStr = NULL;
1985 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1986 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1992 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1995 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1997 noti_info->time = (time_t)dbhandler->columnInt(1);
1999 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2001 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2003 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
2005 MSG_MGR_DEBUG("No unread CB message.");
2006 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
2008 dbhandler->finalizeQuery();
2010 if (!isForInstantMessage) {
2011 /* No unread message. */
2012 if (noti_info->id > 0) {
2013 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2014 if (noti_err != NOTIFICATION_ERROR_NONE) {
2015 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2021 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2022 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
2024 return MSG_ERR_DB_STEP;
2027 dbhandler->finalizeQuery();
2029 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
2030 MSG_MGR_DEBUG("getTable is failed");
2031 dbhandler->freeTable();
2032 return MSG_ERR_DB_GETTABLE;
2035 dbhandler->freeTable();
2036 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
2039 case MSG_MGR_NOTI_TYPE_SIM: {
2040 char sqlQuery[MAX_QUERY_LEN+1];
2041 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2043 snprintf(sqlQuery, sizeof(sqlQuery),
2048 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
2050 "WHERE A.CONV_ID=B.CONV_ID "
2051 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2052 "AND B.STORAGE_ID = %d "
2053 "ORDER BY B.DISPLAY_TIME DESC;",
2055 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2059 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2061 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
2062 return MSG_ERR_DB_PREPARE;
2064 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
2065 noti_info->count = dbhandler->columnInt(4);
2067 if (noti_info->count > 0) {
2068 MSG_ADDRESS_INFO_S addrInfo;
2069 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
2071 if (dbhandler->columnText(0) != NULL)
2072 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2074 MSG_CONTACT_INFO_S tmpContact;
2075 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2077 MsgGetContactInfo(&addrInfo, &tmpContact);
2079 if (tmpContact.firstName[0] != '\0') {
2080 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2081 } else if (addrInfo.addressVal[0] == '\0') {
2082 char *senderStr = NULL;
2083 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2084 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2090 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2093 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2095 noti_info->time = (time_t)dbhandler->columnInt(1);
2097 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2099 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2101 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
2103 MSG_MGR_DEBUG("No unread SIM message.");
2104 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2106 dbhandler->finalizeQuery();
2108 if (!isForInstantMessage) {
2109 /* No unread message. */
2110 if (noti_info->id > 0) {
2111 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2112 if (noti_err != NOTIFICATION_ERROR_NONE) {
2113 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2119 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2120 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2123 return MSG_ERR_DB_STEP;
2126 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2127 dbhandler->finalizeQuery();
2128 return MSG_ERR_DB_STEP;
2131 dbhandler->finalizeQuery();
2135 case MSG_MGR_NOTI_TYPE_FAILED: {
2136 char sqlQuery[MAX_QUERY_LEN+1];
2137 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2139 snprintf(sqlQuery, sizeof(sqlQuery),
2146 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2148 "WHERE A.CONV_ID=B.CONV_ID "
2149 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2150 "AND B.STORAGE_ID = %d "
2151 "ORDER BY B.DISPLAY_TIME DESC;",
2152 MSG_NETWORK_SEND_FAIL,
2153 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2157 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2159 row_cnt = 0, col_cnt = 0;
2160 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2161 if (msg_err != MSG_SUCCESS) {
2162 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2167 noti_info->count = atoi(db_res[col_cnt+6]);
2169 if (noti_info->count > 0) {
2170 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2172 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2174 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2176 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2178 if (tmpContact.firstName[0] != '\0') {
2179 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2180 } else if (addrInfo.addressVal[0] == '\0') {
2181 char *senderStr = NULL;
2182 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2183 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2189 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2192 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2194 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2196 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2198 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2200 if (mainType == MSG_TYPE_MMS)
2201 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2203 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2205 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2207 if (!isForInstantMessage) {
2208 if (noti_info->id > 0 && noti_info->count == 1) {
2209 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2210 if (noti_err != NOTIFICATION_ERROR_NONE) {
2211 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2214 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2215 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2219 MSG_MGR_DEBUG("No sent failed message.");
2220 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2222 msg_db_free(msg_handle, db_res);
2224 if (!isForInstantMessage) {
2225 /* No unread message. */
2226 if (noti_info->id > 0) {
2227 noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
2228 if (noti_err != NOTIFICATION_ERROR_NONE) {
2229 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2235 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2236 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2242 msg_db_free(msg_handle, db_res);
2246 msg_db_free(msg_handle, db_res);
2249 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2252 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2262 notification_h getHandle(int *noti_id)
2264 notification_h noti_h = NULL;
2267 MSG_MGR_DEBUG("Notification load");
2268 noti_h = notification_load(NULL, *noti_id);
2270 MSG_MGR_DEBUG("notification_load is failed.");
2273 if (noti_h == NULL) {
2274 MSG_MGR_DEBUG("Notification create");
2275 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2276 if (noti_h == NULL) {
2277 MSG_MGR_DEBUG("notification_create is failed.");
2288 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2294 switch (noti_type) {
2295 #ifdef MSG_NOTI_INTEGRATION
2296 case MSG_MGR_NOTI_TYPE_NORMAL:
2297 case MSG_MGR_NOTI_TYPE_SIM:
2298 case MSG_MGR_NOTI_TYPE_CB:
2299 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2302 case MSG_MGR_NOTI_TYPE_NORMAL:
2303 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2305 case MSG_MGR_NOTI_TYPE_SIM:
2306 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2308 case MSG_MGR_NOTI_TYPE_CB:
2309 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2312 case MSG_MGR_NOTI_TYPE_FAILED:
2313 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2315 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2316 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2317 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2318 vconf_get_int(keyName, ¬i_id);
2321 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2322 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2323 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2324 vconf_get_int(keyName, ¬i_id);
2327 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2328 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2331 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2335 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2343 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2349 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2351 switch (noti_type) {
2352 #ifdef MSG_NOTI_INTEGRATION
2353 case MSG_MGR_NOTI_TYPE_NORMAL:
2354 case MSG_MGR_NOTI_TYPE_SIM:
2355 case MSG_MGR_NOTI_TYPE_CB:
2356 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2359 case MSG_MGR_NOTI_TYPE_NORMAL:
2360 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2362 case MSG_MGR_NOTI_TYPE_SIM:
2363 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2365 case MSG_MGR_NOTI_TYPE_CB:
2366 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2369 case MSG_MGR_NOTI_TYPE_FAILED:
2370 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2372 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2373 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2374 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2375 err = vconf_set_int(keyName, noti_id);
2378 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2379 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2380 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2381 err = vconf_set_int(keyName, noti_id);
2384 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2385 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2388 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2393 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2399 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2404 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2405 noti_info->msg_id = msg_info->msgId;
2407 MSG_MGR_DEBUG("msg_info is NULL");
2411 noti_info->sim_idx = msg_info->sim_idx;
2413 createServiceHandle(¬i_info->svc_h);
2414 char keyName[MAX_VCONFKEY_NAME_LEN];
2416 switch (noti_info->type) {
2417 case MSG_MGR_NOTI_TYPE_VOICE_1:
2418 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2419 memset(keyName, 0x00, sizeof(keyName));
2420 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2421 vconf_get_int(keyName, ¬i_info->count);
2422 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2423 noti_info->time = msg_info->displayTime;
2425 memset(keyName, 0x00, sizeof(keyName));
2426 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2427 char *voiceNumber = vconf_get_str(keyName);
2428 memset(keyName, 0x00, sizeof(keyName));
2429 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2430 char *voiceAlphaId = vconf_get_str(keyName);
2431 char *dialNumber = NULL;
2433 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2435 if (voiceNumber && strlen(voiceNumber))
2436 dialNumber = voiceNumber;
2438 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2439 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2440 } else if (dialNumber && strlen(dialNumber) > 0) {
2441 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2444 if (dialNumber && strlen(dialNumber) > 0)
2445 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2447 if (noti_info->svc_h) {
2448 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2449 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2451 char slot_id[5] = {0, };
2452 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2453 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2456 if (voiceNumber) g_free(voiceNumber);
2457 if (voiceAlphaId) g_free(voiceAlphaId);
2460 case MSG_MGR_NOTI_TYPE_MWI:
2461 case MSG_MGR_NOTI_TYPE_CLASS0: {
2462 noti_info->count = 1;
2463 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2464 noti_info->time = msg_info->displayTime;
2466 if (msg_info->displayName[0] == '\0')
2467 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2469 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2471 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2473 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2475 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2476 if (noti_info->svc_h) {
2477 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2478 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2480 char slot_id[5] = {0, };
2481 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2482 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2486 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2487 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2488 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2492 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2493 noti_info->count = 1;
2494 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2495 noti_info->time = msg_info->displayTime;
2496 noti_info->extra_data = msg_info->networkStatus;
2498 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2499 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2500 if (msg_info->addressVal[0] != '\0') {
2501 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2502 if (_is_valid_email(msg_info->addressVal)) {
2503 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2505 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2509 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2510 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2513 if (contactInfo.firstName[0] == '\0')
2514 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2516 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2518 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2520 if (noti_info->msg_id > 0) {
2521 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2522 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2523 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2524 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2528 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2529 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2530 noti_info->count = 1;
2531 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2532 noti_info->time = msg_info->displayTime;
2534 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2535 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2536 if (msg_info->addressVal[0] != '\0') {
2537 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2538 if (_is_valid_email(msg_info->addressVal)) {
2539 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2541 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2545 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2546 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2548 if (contactInfo.firstName[0] == '\0')
2549 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2551 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2553 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2555 char sqlQuery[MAX_QUERY_LEN+1];
2556 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2558 int report_status_type;
2559 int report_status_value;
2561 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2562 report_status_type = MSG_REPORT_TYPE_READ;
2564 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2567 snprintf(sqlQuery, sizeof(sqlQuery),
2570 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE \"%%%s\";",
2571 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2573 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2575 char **db_res = NULL;
2576 int row_cnt = 0, col_cnt = 0;
2578 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2579 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2580 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2584 report_status_value = atoi(db_res[col_cnt]);
2586 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2588 msg_err = msg_db_free(msg_handle, db_res);
2589 if (msg_err != MSG_SUCCESS) {
2590 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2594 if (noti_info->msg_id > 0) {
2595 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2596 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2597 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2598 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2601 noti_info->extra_data = (unsigned char)report_status_value;
2605 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2609 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2614 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2618 createServiceHandle(¬i_info->svc_h);
2620 switch (noti_info->type) {
2621 case MSG_MGR_NOTI_TYPE_NORMAL: {
2622 if (noti_info->count > 1) {
2623 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2625 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2628 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2629 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2630 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2631 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2633 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE) {
2634 if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
2635 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
2637 int activated_conv_id = -1;
2638 vconf_get_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, &activated_conv_id);
2640 if (activated_conv_id == -1) {
2641 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2642 } else if (activated_conv_id == 0) {
2643 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2644 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2645 } else if (activated_conv_id > 0){
2646 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2648 if (activated_conv_id != noti_info->conv_id)
2649 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2651 MSG_MGR_WARN("No adding Notification : activated conv id [%d] / notification conv id [%d]", activated_conv_id, noti_info->conv_id);
2654 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2659 case MSG_MGR_NOTI_TYPE_CB: {
2660 if (noti_info->count > 1) {
2661 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2663 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2666 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2667 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2668 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2670 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2671 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2673 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2675 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
2678 case MSG_MGR_NOTI_TYPE_SIM: {
2679 if (noti_info->count > 1) {
2680 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2682 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2685 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2686 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2687 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2689 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2690 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2692 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2694 if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
2695 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
2698 case MSG_MGR_NOTI_TYPE_FAILED: {
2699 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2701 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2702 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2703 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2705 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2708 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2709 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2711 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2712 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2714 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2721 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2722 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2728 void createServiceHandle(app_control_h *svc_h)
2730 int svc_err = APP_CONTROL_ERROR_NONE;
2732 svc_err = app_control_create(svc_h);
2734 if (svc_err != APP_CONTROL_ERROR_NONE)
2735 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2739 void setServiceAppId(app_control_h svc_h, const char* app_id)
2741 int svc_err = APP_CONTROL_ERROR_NONE;
2743 svc_err = app_control_set_app_id(svc_h, app_id);
2745 if (svc_err != APP_CONTROL_ERROR_NONE)
2746 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2750 void setServiceUri(app_control_h svc_h, const char* uri)
2752 int svc_err = APP_CONTROL_ERROR_NONE;
2754 svc_err = app_control_set_uri(svc_h, uri);
2756 if (svc_err != APP_CONTROL_ERROR_NONE)
2757 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2761 void setServiceOperation(app_control_h svc_h, const char* operation)
2763 int svc_err = APP_CONTROL_ERROR_NONE;
2765 svc_err = app_control_set_operation(svc_h, operation);
2767 if (svc_err != APP_CONTROL_ERROR_NONE)
2768 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2772 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2774 int svc_err = APP_CONTROL_ERROR_NONE;
2776 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2778 if (svc_err != APP_CONTROL_ERROR_NONE)
2779 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2783 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2785 int svc_err = APP_CONTROL_ERROR_NONE;
2788 memset(&tempId, 0x00, sizeof(tempId));
2789 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2791 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2793 if (svc_err != APP_CONTROL_ERROR_NONE)
2794 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2798 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2800 int svc_err = APP_CONTROL_ERROR_NONE;
2802 svc_err = app_control_set_app_id(svc_h, pkg_name);
2804 if (svc_err != APP_CONTROL_ERROR_NONE)
2805 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2809 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2811 int svc_err = APP_CONTROL_ERROR_NONE;
2813 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2815 if (svc_err != APP_CONTROL_ERROR_NONE)
2816 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2820 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2822 int noti_err = NOTIFICATION_ERROR_NONE;
2824 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2825 if (noti_err != NOTIFICATION_ERROR_NONE)
2826 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2830 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2832 int noti_err = NOTIFICATION_ERROR_NONE;
2834 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2836 if (noti_err != NOTIFICATION_ERROR_NONE)
2837 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2841 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2843 int noti_err = NOTIFICATION_ERROR_NONE;
2845 noti_err = notification_set_time_to_text(noti_h, type, time);
2847 if (noti_err != NOTIFICATION_ERROR_NONE)
2848 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2852 void setNotiTime(notification_h noti_h, time_t time)
2854 int noti_err = NOTIFICATION_ERROR_NONE;
2856 noti_err = notification_set_time(noti_h, time);
2858 if (noti_err != NOTIFICATION_ERROR_NONE)
2859 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2864 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2866 int noti_err = NOTIFICATION_ERROR_NONE;
2868 noti_err = notification_set_image(noti_h, type, image_path);
2870 if (noti_err != NOTIFICATION_ERROR_NONE)
2871 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2875 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2877 int noti_err = NOTIFICATION_ERROR_NONE;
2879 noti_err = notification_set_sound(noti_h, type, path);
2881 if (noti_err != NOTIFICATION_ERROR_NONE)
2882 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2886 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2888 int noti_err = NOTIFICATION_ERROR_NONE;
2890 noti_err = notification_set_vibration(noti_h, type, path);
2892 if (noti_err != NOTIFICATION_ERROR_NONE)
2893 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2897 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2899 int noti_err = NOTIFICATION_ERROR_NONE;
2901 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2903 if (noti_err != NOTIFICATION_ERROR_NONE)
2904 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2908 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2912 char *notiMsg = NULL;
2914 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2916 switch (noti_type) {
2917 case MSG_MGR_NOTI_TYPE_NORMAL:
2918 case MSG_MGR_NOTI_TYPE_SIM:
2919 case MSG_MGR_NOTI_TYPE_CB: {
2920 MSG_MGR_NOTI_INFO_S noti_info;
2921 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2923 noti_info.type = noti_type;
2924 int err = getLatestMsgInfo(¬i_info, true);
2927 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2928 if (noti_info.count == 1) {
2929 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2930 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2931 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2932 } else if (noti_info.count > 1) {
2933 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2935 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
2936 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2937 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2938 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2943 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2947 case MSG_MGR_NOTI_TYPE_FAILED: {
2948 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2949 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2950 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2954 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2955 goto _END_OF_INSTANT_NOTI;
2959 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2960 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2962 if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
2963 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
2965 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2966 MSG_MGR_DEBUG("Fail to notification_post");
2968 _END_OF_INSTANT_NOTI:
2970 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2971 MSG_MGR_DEBUG("Fail to notification_delete");
2978 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2979 MSG_MGR_DEBUG("Fail to notification_free");
2988 bool MsgMgrCheckNotificationSettingEnable()
2990 bool msg_noti_enabled = false;
2991 notification_system_setting_h system_setting = NULL;
2992 notification_setting_h setting = NULL;
2994 int err = NOTIFICATION_ERROR_NONE;
2996 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
2998 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
2999 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
3001 msg_noti_enabled = true;
3003 bool allow_to_notify = false;
3004 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
3006 if (err != NOTIFICATION_ERROR_NONE) {
3007 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
3011 if (allow_to_notify) {
3012 MSG_MGR_DEBUG("message notification is allowed");
3014 /* check do not disturb mode */
3015 err = notification_system_setting_load_system_setting(&system_setting);
3017 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
3018 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
3022 bool do_not_disturb_mode = false;
3023 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
3025 if (err != NOTIFICATION_ERROR_NONE) {
3026 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
3030 if (do_not_disturb_mode) {
3031 bool is_msg_excepted = false;
3032 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
3033 if (err != NOTIFICATION_ERROR_NONE) {
3034 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
3035 msg_noti_enabled = false;
3037 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
3038 msg_noti_enabled = (is_msg_excepted) ? true : false;
3041 MSG_MGR_DEBUG("do not disturb mode is off");
3044 MSG_MGR_INFO("message notification is not allowed");
3045 msg_noti_enabled = false;
3051 notification_system_setting_free_system_setting(system_setting);
3054 notification_setting_free_notification(setting);
3056 return msg_noti_enabled;
3060 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
3062 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
3063 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
3065 MsgMgrChangePmState();
3067 char *notiMsg = NULL;
3068 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
3071 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
3072 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
3074 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
3075 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
3076 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
3077 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
3078 notification_status_message_post(pTickerMsg);
3080 notification_status_message_post(notiMsg);
3083 /* Show ticker popup for sending failed msg. */
3084 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
3092 if (bPlayFeedback) {
3094 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
3095 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
3097 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
3099 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
3100 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
3102 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
3105 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
3113 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
3115 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
3117 int err = BADGE_ERROR_NONE;
3120 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
3122 if (err != BADGE_ERROR_NONE) {
3123 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
3129 err = badge_add(MSG_DEFAULT_APP_ID);
3130 if (err != BADGE_ERROR_NONE) {
3131 MSG_MGR_ERR("Fail to badge_add : %d", err);
3136 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
3138 if (err != BADGE_ERROR_NONE) {
3139 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3147 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3151 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3153 #ifndef MSG_NOTI_INTEGRATION
3154 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3155 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3163 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3169 struct tm repeat_tm;
3173 tmp_time += (RepeatTime*60);
3175 localtime_r(&tmp_time, &repeat_tm);
3177 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3178 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3182 g_alarmId = tmpAlarmId;
3183 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3191 void MsgMgrSoundSetRepeatAlarm()
3193 int nRepeatValue = 0;
3194 long nRepeatTime = 0;
3196 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3197 MSG_MGR_INFO("vconf_get_int() is failed");
3200 switch (nRepeatValue) {
3201 case MSG_ALERT_TONE_ONCE:
3204 case MSG_ALERT_TONE_2MINS:
3207 case MSG_ALERT_TONE_5MINS:
3210 case MSG_ALERT_TONE_10MINS:
3214 MSG_MGR_DEBUG("Invalid Repetition time");
3218 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3220 if (nRepeatTime > 0) {
3221 if (g_alarmId > 0) {
3222 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3223 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3227 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3234 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3236 char *notiMsg = NULL;
3239 lang = vconf_get_str(VCONFKEY_LANGSET);
3241 setlocale(LC_MESSAGES, lang);
3243 bindtextdomain(pkg_name, locale_dir);
3245 notiMsg = dgettext(pkg_name, text);
3252 return g_strdup(notiMsg);