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>
48 #include <msg-manager-profile.h>
53 /*==================================================================================================
55 ==================================================================================================*/
57 static GList *msg_report_notification_list = NULL;
58 static bool is_init = false;
59 extern msg_handle_t msg_handle;
61 tizen_profile_t profile = _PROFILE_UNKNOWN;
62 char g_app_id[32] = {0};
65 /*==================================================================================================
67 ==================================================================================================*/
68 typedef struct _report_notification_s
70 msg_mgr_notification_type_t noti_type;
72 char addressVal[MAX_ADDRESS_VAL_LEN+1];
73 } report_notification_s;
76 typedef struct _msg_mgr_noti_info_s
78 msg_mgr_notification_type_t type;
84 char sender[MSG_NOTI_TEXT_LEN_S+1];
85 char text[MSG_NOTI_TEXT_LEN+1];
86 char number[MSG_NOTI_TEXT_LEN_S+1];
87 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
90 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
91 msg_message_id_t msg_id;
93 unsigned char extra_data;
95 int active_noti_button_num;
97 int active_media_size;
98 unsigned char active_subtype; /**< to distinguish cb, push message */
99 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
100 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
101 char active_text[MSG_NOTI_TEXT_LEN+1];
102 } MSG_MGR_NOTI_INFO_S;
105 typedef struct _del_noti_info_s
107 msg_mgr_notification_type_t type;
112 /*==================================================================================================
114 ===================================================================================================*/
116 void MsgMgrInitReportNotiList();
117 void MsgInitNotiCb(void *data);
118 void MsgRefreshNotiCb(void *data);
119 void MsgMgrDeleteNotiCb(void *data);
121 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
122 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result);
124 notification_h getHandle(int *noti_id);
126 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
127 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
129 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
130 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
131 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
132 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
134 int getAppIcon(const char *app_id, char **icon_path);
135 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
137 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
138 void setTextDomain(notification_h noti_h);
139 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
140 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
141 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
142 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
143 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
144 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
145 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
147 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
150 void createServiceHandle(app_control_h *svc_h);
151 void setServiceAppId(app_control_h svc_h, const char* app_id);
152 void setServiceUri(app_control_h svc_h, const char* uri);
153 void setServiceOperation(app_control_h svc_h, const char* operation);
154 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
155 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
156 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
157 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
159 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
160 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
161 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
162 void setNotiTime(notification_h noti_h, time_t time);
163 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
164 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
165 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
166 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
169 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
170 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
171 void MsgMgrSoundSetRepeatAlarm();
173 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
175 /*==================================================================================================
176 FUNCTION IMPLEMENTATION
177 ==================================================================================================*/
178 char *_get_app_id(void)
180 if ('\0' != *g_app_id)
183 const char *app_id = NULL;
184 switch (get_tizen_profile()) {
185 case _PROFILE_WEARABLE:
186 app_id = MSG_WEARABLE_APP_ID;
188 case _PROFILE_MOBILE:
190 app_id = MSG_DEFAULT_APP_ID;
193 snprintf(g_app_id, sizeof(g_app_id), "%s", app_id);
194 MSG_MGR_ERR("app id [%s]", g_app_id);
199 bool _is_valid_email(char *pAddress)
201 if (!pAddress || pAddress[0] == 0)
203 if (!strchr (pAddress, EMAIL_AT))
209 void MsgMgrInitReportNotiList()
213 if (msg_report_notification_list) {
214 MSG_MGR_DEBUG("Report Noti List is already inited");
218 msg_report_notification_list = NULL;
220 notification_h noti = NULL;
221 notification_list_h noti_list = NULL;
222 notification_list_h head_noti_list = NULL;
223 int noti_err = NOTIFICATION_ERROR_NONE;
224 app_control_h app_control = NULL;
226 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
227 if (noti_err != NOTIFICATION_ERROR_NONE) {
228 MSG_MGR_DEBUG("notification_get_list() is failed!!");
232 head_noti_list = noti_list;
234 while (noti_list != NULL) {
235 noti = notification_list_get_data(noti_list);
237 MSG_MGR_DEBUG("notification_list_get_data() failed!!");
241 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
242 memset(tempAddr, 0x00, sizeof(tempAddr));
244 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
245 if (noti_err != NOTIFICATION_ERROR_NONE) {
246 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
250 char *is_report_noti = NULL;
252 int ret = app_control_get_extra_data(app_control, "is_report_noti", &is_report_noti);
253 if (ret == APP_CONTROL_ERROR_NONE && is_report_noti != NULL && g_strcmp0(is_report_noti, "true") == 0) {
256 ret = app_control_get_extra_data(app_control, "address", &addr);
257 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
258 report_notification_s *info = new report_notification_s;
259 memset(info, 0x00, sizeof(report_notification_s));
261 char *noti_type = NULL;
262 ret = app_control_get_extra_data(app_control, "noti_type", ¬i_type);
263 if (ret == APP_CONTROL_ERROR_NONE && noti_type != NULL) {
264 info->noti_type = (msg_mgr_notification_type_t)atoi(noti_type);
268 notification_get_id(noti, NULL, &(info->priv_id));
269 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
271 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
272 MSG_MGR_SEC_DEBUG("appended list data = [noti_type = %d priv_id = %d address = %s]", info->noti_type, info->priv_id, info->addressVal);
279 if (is_report_noti) {
280 g_free(is_report_noti);
281 is_report_noti = NULL;
285 noti_list = notification_list_get_next(noti_list);
289 notification_free_list(head_noti_list);
295 void MsgMgrInitNoti()
300 bool bNotiSvcReady = false;
302 bNotiSvcReady = notification_is_service_ready();
304 if (bNotiSvcReady == true) {
305 MSG_MGR_DEBUG("Notification server is available");
306 MsgMgrInitReportNotiList();
308 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
309 notification_add_deferred_task(MsgInitNotiCb, NULL);
316 void MsgInitNotiCb(void *data)
318 MsgMgrInitReportNotiList();
331 bool bNotiSvcReady = false;
333 bNotiSvcReady = notification_is_service_ready();
335 if (bNotiSvcReady == true) {
336 MSG_MGR_DEBUG("Notification server is available");
337 #ifndef MSG_NOTI_INTEGRATION
338 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
340 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
342 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
343 #ifndef MSG_NOTI_INTEGRATION
344 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
346 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
347 delNotiInfo->sim_idx = -1;
349 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
351 notification_add_deferred_task(MsgRefreshNotiCb, NULL);
356 void MsgRefreshNotiCb(void *data)
358 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
369 void MsgMgrDeleteNotiCb(void *data)
372 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)data;
374 MsgMgrDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx);
384 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
388 notification_h noti_h = NULL;
390 MSG_MGR_NOTI_INFO_S noti_info = {0, };
392 noti_info.type = noti_type;
393 noti_info.active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CLASS0_MESSAGE;
395 createActiveInfoData(¬i_info, msg_info);
397 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
399 setActiveNotification(noti_h, ¬i_info);
401 clearInfoData(noti_h, ¬i_info);
408 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
411 notification_h noti_h = NULL;
412 int bNotification = 1;
413 /* bool bReplyPopup = false; */
415 MSG_MGR_NOTI_INFO_S noti_info = {0, };
416 noti_info.type = noti_type;
417 noti_info.id = getPrivId(noti_info.type, -1);
419 err = getLatestMsgInfo(¬i_info, false);
422 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
423 goto __END_OF_REFRESH_NOTI;
426 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
427 err = MsgMgrInsertInstantMessage(noti_type);
430 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
431 goto __END_OF_REFRESH_NOTI;
435 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
436 MSG_MGR_DEBUG("vconf_get_bool is failed.");
439 if (bNotification == 0) {
440 MSG_MGR_DEBUG("Msg Alert notification is off.");
441 goto __END_OF_REFRESH_NOTI;
444 createInfoData(¬i_info, active_type);
446 noti_h = getHandle(¬i_info.id);
448 if (noti_h == NULL) {
449 MSG_MGR_DEBUG("Notification handle is NULL");
450 err = MSG_ERR_NULL_POINTER;
451 goto __END_OF_REFRESH_NOTI;
454 setNotification(noti_h, ¬i_info, bFeedback);
456 __END_OF_REFRESH_NOTI :
457 clearInfoData(noti_h, ¬i_info);
463 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
467 notification_h noti_h = NULL;
468 bool isNewNoti = false;
470 MSG_MGR_NOTI_INFO_S noti_info = {0, };
471 noti_info.type = noti_type;
473 createInfoData(¬i_info, msg_info);
475 if (noti_info.id == 0)
478 noti_h = getHandle(¬i_info.id);
480 if (noti_h == NULL) {
481 MSG_MGR_DEBUG("Notification handle is NULL");
483 goto __END_OF_ADD_REPORT_NOTI;
486 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT || noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
487 noti_info.applist &= ~NOTIFICATION_DISPLAY_APP_TICKER;
489 ret = MsgMgrInsertDeliveryReportInstantNotification(noti_type, noti_info.extra_data);
492 MSG_MGR_ERR(" MsgInsertInstantDeliveryReportNotification() err = [%d]", ret);
493 goto __END_OF_ADD_REPORT_NOTI;
497 addServiceExtraData(noti_info.svc_h, "is_report_noti", "true");
498 setNotification(noti_h, ¬i_info, true);
500 if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT)
501 noti_type = MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT;
504 report_notification_s *info = new report_notification_s;
505 memset(info, 0x00, sizeof(report_notification_s));
507 info->noti_type = noti_type;
508 info->priv_id = noti_info.id;
509 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
510 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
511 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
513 GList *iter = g_list_first(msg_report_notification_list);
515 while (iter != NULL) {
516 report_notification_s *info = (report_notification_s*)(iter->data);
518 MSG_MGR_DEBUG("info is NULL!");
522 // update new addressVal of noti_type
523 if (info->priv_id == noti_info.id) {
524 memset(info->addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
525 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
526 MSG_MGR_SEC_DEBUG("updated list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
530 iter = g_list_next(iter);
534 __END_OF_ADD_REPORT_NOTI :
535 clearInfoData(noti_h, ¬i_info);
541 int MsgMgrDeleteReportNotification(const char *addr)
545 notification_h noti_h = NULL;
546 int bNotification = 1;
548 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
549 MSG_MGR_DEBUG("vconf_get_bool is failed.");
552 if (bNotification == 0) {
553 MSG_MGR_DEBUG("Msg Alert notification is off.");
557 char* normalAddr = NULL;
558 unsigned int list_length = g_list_length(msg_report_notification_list);
559 bool isDelete = false;
561 MSG_MGR_DEBUG("list length [%d]", list_length);
563 if (list_length > 0) {
564 GList *iter = g_list_first(msg_report_notification_list);
566 while (iter != NULL) {
568 report_notification_s *info = (report_notification_s*)(iter->data);
570 MSG_MGR_DEBUG("info is NULL!");
574 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
576 noti_h = notification_load(NULL, info->priv_id);
577 if (noti_h == NULL) {
578 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
581 normalAddr = msg_mgr_normalize_number(info->addressVal);
584 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
586 if (g_str_has_suffix(addr, normalAddr)) {
587 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
588 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
591 MSG_MGR_DEBUG("delete notification failed");
596 notification_free(noti_h);
600 iter = g_list_next(iter);
603 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
617 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
621 notification_h noti_h = NULL;
623 MSG_MGR_NOTI_INFO_S noti_info = {0, };
625 noti_info.type = noti_type;
627 createInfoData(¬i_info, msg_info);
629 /* check mwi or voicemail count is 0 then skip add notification */
630 if (noti_info.count == 0) {
631 MSG_MGR_DEBUG("Notification count is 0");
633 goto __END_OF_ADD_NOTI;
636 noti_h = getHandle(¬i_info.id);
638 if (noti_h == NULL) {
639 MSG_MGR_DEBUG("Notification handle is NULL");
641 goto __END_OF_ADD_NOTI;
644 setNotification(noti_h, ¬i_info, true);
647 clearInfoData(noti_h, ¬i_info);
653 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex)
655 int noti_err = NOTIFICATION_ERROR_NONE;
657 if (noti_type == MSG_MGR_NOTI_TYPE_ALL) {
658 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
659 } 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) {
662 notiId = getPrivId(noti_type, simIndex);
663 MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
666 noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, notiId);
669 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
672 if (noti_err != NOTIFICATION_ERROR_NONE) {
673 MSG_MGR_DEBUG("Fail to notification_delete_all noti_err [%d]", noti_err);
676 updatePrivId(noti_type, 0, simIndex);
680 int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
682 bool bNotiSvcReady = false;
684 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S));
687 delNotiInfo->type = noti_type;
688 delNotiInfo->sim_idx = simIndex;
691 bNotiSvcReady = notification_is_service_ready();
693 if (bNotiSvcReady == true) {
694 MSG_MGR_DEBUG("Notification server is available");
695 MsgMgrDeleteNotiCb((void *)delNotiInfo);
697 MSG_MGR_DEBUG("Notification server is not available. Delete is defered");
698 notification_add_deferred_task(MsgMgrDeleteNotiCb, (void *)delNotiInfo);
704 int MsgMgrDeleteSentReadReportNotification()
706 int readReportSentNotiId = 0;
709 if (vconf_get_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, &readReportSentNotiId) != 0) {
710 MSG_MGR_INFO("vconf_get_int() is failed");
714 if (readReportSentNotiId > 0) {
715 noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, readReportSentNotiId);
717 MSG_MGR_DEBUG("notification_delete_by_priv_id() fail [%d]", noti_err);
721 MSG_MGR_DEBUG("VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID is 0");
725 if (vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, 0) != 0) {
726 MSG_MGR_DEBUG("vconf_set_int fail : VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID");
730 if (vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID, 0) != 0) {
731 MSG_MGR_DEBUG("vconf_set_int fail : VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID");
739 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
745 #ifndef MSG_NOTI_INTEGRATION
746 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
749 #ifdef MSG_NOTI_INTEGRATION
750 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
752 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
754 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
756 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
758 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
760 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
763 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
765 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
769 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
771 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
777 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
781 int noti_err = NOTIFICATION_ERROR_NONE;
784 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
785 if (noti_err != NOTIFICATION_ERROR_NONE) {
786 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
790 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
791 if (noti_err != NOTIFICATION_ERROR_NONE) {
792 MSG_MGR_DEBUG("Fail to notification_set_led.");
795 /* set execute option and property */
796 switch (noti_info->type) {
797 case MSG_MGR_NOTI_TYPE_NORMAL: {
798 if (noti_info->count > 1) {
799 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
801 if (noti_info->svc_h) { /* overwrite bundle key "type" */
802 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
803 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
805 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
808 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
811 case MSG_MGR_NOTI_TYPE_CB:
812 case MSG_MGR_NOTI_TYPE_SIM: {
813 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
814 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
817 case MSG_MGR_NOTI_TYPE_FAILED: {
818 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
819 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
822 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
823 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
826 case MSG_MGR_NOTI_TYPE_STORAGE_FULL: {
827 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
830 case MSG_MGR_NOTI_TYPE_VOICE_1:
831 case MSG_MGR_NOTI_TYPE_VOICE_2:
832 case MSG_MGR_NOTI_TYPE_MWI:
833 case MSG_MGR_NOTI_TYPE_CLASS0:
834 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
835 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
836 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
837 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
841 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
846 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
847 if (noti_err != NOTIFICATION_ERROR_NONE) {
848 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
852 noti_err = notification_set_pkgname(noti_h, _get_app_id());
853 if (noti_err != NOTIFICATION_ERROR_NONE) {
854 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
861 void setTextDomain(notification_h noti_h)
865 setNotiTextDomain(noti_h, MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR);
870 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
875 char unreadMsgCntStr[10] = {0};
878 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
879 MSG_MGR_DEBUG("vconf_get_bool is failed.");
882 /* set title and content */
883 switch (noti_info->type) {
884 #ifdef MSG_NOTI_INTEGRATION
885 case MSG_MGR_NOTI_TYPE_NORMAL:
886 case MSG_MGR_NOTI_TYPE_CB:
887 case MSG_MGR_NOTI_TYPE_SIM: {
888 if (noti_info->count > 1) {
889 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
890 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
891 setNotiTime(noti_h, noti_info->time);
893 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
894 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
898 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
899 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
901 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
902 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
904 setNotiTime(noti_h, noti_info->time);
909 case MSG_MGR_NOTI_TYPE_NORMAL: {
910 if (noti_info->count > 1) {
911 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
912 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
913 setNotiTime(noti_h, noti_info->time);
915 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
916 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
919 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
920 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
922 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
923 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
925 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
926 setNotiTime(noti_h, noti_info->time);
930 case MSG_MGR_NOTI_TYPE_CB: {
931 if (noti_info->count > 1) {
932 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
933 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
934 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
935 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
936 setNotiTime(noti_h, noti_info->time);
939 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
940 setNotiTime(noti_h, noti_info->time);
943 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
944 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
946 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
947 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
952 case MSG_MGR_NOTI_TYPE_SIM: {
953 if (noti_info->count > 1) {
954 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
955 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
956 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
958 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
959 setNotiTime(noti_h, noti_info->time);
961 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
962 setNotiTime(noti_h, noti_info->time);
965 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
966 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
968 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
969 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
975 case MSG_MGR_NOTI_TYPE_FAILED: {
976 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
977 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
978 if (noti_info->count > 1) {
979 wrn = snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
981 MSG_MGR_INFO("snprintf was failed");
982 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
984 setNotiTime(noti_h, noti_info->time);
987 case MSG_MGR_NOTI_TYPE_VOICE_1:
988 case MSG_MGR_NOTI_TYPE_VOICE_2: {
989 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
990 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
991 setNotiTime(noti_h, noti_info->time);
993 if (noti_info->count == 1) {
994 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
995 } else if (noti_info->count > 1) {
996 wrn = snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
998 MSG_MGR_INFO("snprintf was failed");
999 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
1001 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
1005 case MSG_MGR_NOTI_TYPE_MWI: {
1006 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
1007 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
1008 setNotiTime(noti_h, noti_info->time);
1011 case MSG_MGR_NOTI_TYPE_CLASS0: {
1012 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1013 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
1014 setNotiTime(noti_h, noti_info->time);
1017 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
1018 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
1019 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
1021 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
1022 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
1023 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
1024 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
1026 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
1029 setNotiTime(noti_h, noti_info->time);
1032 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
1033 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
1035 char readStatusString[50] = {0, };
1036 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
1037 wrn = snprintf(readStatusString, sizeof(readStatusString), "Message deleted by %s", noti_info->sender);
1039 MSG_MGR_INFO("snprintf was failed");
1040 notification_set_text(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, readStatusString, MESSAGE_DELETED_BY_PS, NOTIFICATION_VARIABLE_TYPE_STRING, noti_info->sender, NOTIFICATION_VARIABLE_TYPE_NONE);
1042 char readStatusString[50] = {0, };
1043 wrn = snprintf(readStatusString, sizeof(readStatusString), "Message read by %s", noti_info->sender);
1045 MSG_MGR_INFO("snprintf was failed");
1046 notification_set_text(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, readStatusString, MESSAGE_READ_BY_PS, NOTIFICATION_VARIABLE_TYPE_STRING, noti_info->sender, NOTIFICATION_VARIABLE_TYPE_NONE);
1049 setNotiTime(noti_h, noti_info->time);
1052 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
1053 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
1054 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
1056 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) {
1057 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
1058 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) {
1059 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", MESSAGE_REJECTED);
1060 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) {
1061 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
1062 } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED || noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE
1063 || noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED || noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE
1064 || noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) {
1065 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Recipient not available", RECIPIENT_NOT_AVAILABLE);
1067 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
1070 setNotiTime(noti_h, noti_info->time);
1073 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT: {
1074 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Messages", MSG_MESSAGE);
1076 if ((int)noti_info->extra_data == MSG_NETWORK_SEND_FAIL) {
1077 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send Read report", FAILED_TO_SEND_MMS_READ_REPORT);
1079 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Read report sent", MMS_READ_REPORT_SENT);
1082 setNotiTime(noti_h, noti_info->time);
1085 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
1086 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
1087 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
1090 case MSG_MGR_NOTI_TYPE_STORAGE_FULL: {
1091 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Not enough space", NULL);
1092 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't receive new messages", NULL);
1093 setNotiTime(noti_h, time(NULL));
1097 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1104 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1108 switch (noti_info->type) {
1109 #ifdef MSG_NOTI_INTEGRATION
1110 case MSG_MGR_NOTI_TYPE_NORMAL:
1111 case MSG_MGR_NOTI_TYPE_CB:
1112 case MSG_MGR_NOTI_TYPE_SIM: {
1113 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1114 if (noti_info->count > 1 && noti_info->senderCount > 1) {
1115 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
1116 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1117 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
1119 if (noti_info->active_subtype == MSG_CB_SMS) {
1120 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
1121 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1122 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
1123 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
1124 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1125 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
1126 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1128 if (noti_info->imagePath[0] != '\0') {
1129 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
1130 /* for user profile image, use NOTIFICATION_IMAGE_TYPE_THUMBNAIL to show icon as circle */
1131 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, noti_info->imagePath);
1133 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1134 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1135 /* TSAM-9359 : priority of image selection on quickpanel, thumbnail is higher. So set NOTIFICATION_IMAGE_TYPE_THUMBNAIL with null */
1136 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, NULL);
1139 char *msg_icon_path = NULL;
1140 if (getAppIcon(_get_app_id(), &msg_icon_path) == 0) {
1141 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1142 g_free(msg_icon_path);
1144 MSG_MGR_ERR("fail to get message-app icon");
1151 case MSG_MGR_NOTI_TYPE_NORMAL: {
1152 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1153 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
1155 if (noti_info->count > 1) {
1156 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1158 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
1162 case MSG_MGR_NOTI_TYPE_CB: {
1163 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1164 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1167 case MSG_MGR_NOTI_TYPE_SIM: {
1168 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1169 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1173 case MSG_MGR_NOTI_TYPE_FAILED: {
1174 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1175 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_FAILED_STATUS_ICON);
1178 case MSG_MGR_NOTI_TYPE_VOICE_1:
1179 case MSG_MGR_NOTI_TYPE_VOICE_2:
1180 case MSG_MGR_NOTI_TYPE_MWI: {
1181 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1182 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1185 case MSG_MGR_NOTI_TYPE_CLASS0:
1186 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1188 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1189 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_DELIVER_REPORT_STATUS_ICON);
1190 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVERY_ICON_PATH);
1192 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1193 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_READ_REPORT_STATUS_ICON);
1194 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_READ_ICON_PATH);
1196 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
1197 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_READ_REPORT_STATUS_ICON);
1198 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_READ_ICON_PATH);
1200 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1201 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_DELIVER_REPORT_STATUS_ICON);
1202 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVERY_ICON_PATH);
1204 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1205 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1206 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_FULL_STATUS_ICON);
1208 case MSG_MGR_NOTI_TYPE_STORAGE_FULL: {
1209 char *msg_icon_path = NULL;
1210 if (getAppIcon(_get_app_id(), &msg_icon_path) == 0) {
1211 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, msg_icon_path);
1212 g_free(msg_icon_path);
1214 MSG_MGR_ERR("fail to get message-app icon");
1216 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_STORAGE_FULL_STATUS_ICON);
1220 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1227 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1231 int noti_err = NOTIFICATION_ERROR_NONE;
1234 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1235 if (noti_err != NOTIFICATION_ERROR_NONE) {
1236 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1240 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1241 if (noti_err != NOTIFICATION_ERROR_NONE) {
1242 MSG_MGR_DEBUG("Fail to notification_set_led.");
1245 /* set execute option and property */
1246 switch (noti_info->type) {
1247 case MSG_MGR_NOTI_TYPE_NORMAL:
1248 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1249 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
1251 case MSG_MGR_NOTI_TYPE_CLASS0:
1252 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->active_noti_svc_h[2]);
1255 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
1260 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1261 if (noti_err != NOTIFICATION_ERROR_NONE) {
1262 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1266 noti_err = notification_set_pkgname(noti_h, _get_app_id());
1267 if (noti_err != NOTIFICATION_ERROR_NONE) {
1268 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
1275 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1280 switch (noti_info->type) {
1281 case MSG_MGR_NOTI_TYPE_NORMAL:
1282 case MSG_MGR_NOTI_TYPE_SIM:
1283 case MSG_MGR_NOTI_TYPE_CB: {
1284 if (noti_info->active_subject[0] == '\0') {
1285 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1286 if (noti_info->active_text[0] != '\0') {
1287 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1289 if (noti_info->active_media_cnt > 1) {
1290 char attach_string[20] = {0, };
1291 wrn = snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1293 MSG_MGR_INFO("snprintf was failed");
1294 if (notification_set_text(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, MSG_PD_ATTACHMENTS, NOTIFICATION_VARIABLE_TYPE_INT, noti_info->active_media_cnt, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1295 MSG_MGR_DEBUG("notification_set_text() failed");
1296 } else if (noti_info->active_media_cnt == 1) {
1297 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", MSG_SINGLE_ATTACHMENT);
1301 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1302 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1303 if (noti_info->active_text[0] != '\0') {
1304 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1306 if (noti_info->active_media_cnt > 1) {
1307 char attach_string[20] = {0, };
1308 wrn = snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
1310 MSG_MGR_INFO("snprintf was failed");
1311 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
1312 } else if (noti_info->active_media_cnt == 1) {
1313 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
1319 case MSG_MGR_NOTI_TYPE_CLASS0: {
1320 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1321 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1325 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1333 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1337 switch (noti_info->type) {
1338 case MSG_MGR_NOTI_TYPE_NORMAL:
1339 case MSG_MGR_NOTI_TYPE_SIM: {
1340 switch (noti_info->active_subtype) {
1342 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1344 case MSG_WAP_SI_SMS:
1345 case MSG_WAP_SL_SMS:
1346 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1349 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1352 if (noti_info->imagePath[0] != '\0')
1353 /* for user profile image, use NOTIFICATION_IMAGE_TYPE_THUMBNAIL to show icon as circle */
1354 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, noti_info->imagePath);
1356 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1358 char *msg_icon_path = NULL;
1359 if (getAppIcon(_get_app_id(), &msg_icon_path) == 0) {
1360 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1361 g_free(msg_icon_path);
1363 MSG_MGR_ERR("fail to get message-app icon");
1371 case MSG_MGR_NOTI_TYPE_CB: {
1372 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1375 case MSG_MGR_NOTI_TYPE_CLASS0:
1376 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1379 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1387 int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result)
1391 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
1392 int noti_err = notification_set_pkgname(noti, _get_app_id());
1394 if(noti_err != NOTIFICATION_ERROR_NONE){
1395 MSG_MGR_ERR("Fail to notification_set_pkgname : %d", noti_err);
1398 setTextDomain(noti);
1399 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
1400 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVER_REPORT_STATUS_ICON);
1402 if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT) {
1403 if (result == MSG_NETWORK_DELIVER_SUCCESS) {
1404 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1405 } else if (result == MSG_NETWORK_DELIVER_EXPIRED) {
1406 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1407 } else if (result == MSG_NETWORK_DELIVER_PENDING) {
1408 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1410 MSG_MGR_ERR("unexpected result! [%d]", result);
1411 goto _END_OF_INSTANT_DELIVERY_REPORT_NOTI;
1413 } else if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
1414 if (result == MSG_DELIVERY_REPORT_EXPIRED)
1415 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
1416 else if (result== MSG_DELIVERY_REPORT_REJECTED)
1417 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message rejected by recipient.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_REJECTED);
1418 else if (result == MSG_DELIVERY_REPORT_DEFERRED)
1419 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
1420 else if (result == MSG_DELIVERY_REPORT_UNRECOGNISED || result == MSG_DELIVERY_REPORT_INDETERMINATE ||
1421 result == MSG_DELIVERY_REPORT_FORWARDED || result == MSG_DELIVERY_REPORT_UNREACHABLE ||
1422 result == MSG_DELIVERY_REPORT_ERROR)
1423 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Recipient not available.", UNABLE_TO_DELIVER_MESSAGE_RECIPIENT_NOT_AVAILABLE);
1425 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
1428 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
1429 MSG_MGR_ERR("Fail to notification_set_display_applist");
1431 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
1432 MSG_MGR_ERR("Fail to notification_post");
1434 _END_OF_INSTANT_DELIVERY_REPORT_NOTI:
1436 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
1437 MSG_MGR_ERR("Fail to notification_delete");
1440 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
1441 MSG_MGR_ERR("Fail to notification_free");
1450 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1454 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
1455 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
1457 if (addressVal != NULL) {
1458 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1459 /* Get Contact Info */
1460 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1461 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1464 MSG_MGR_DEBUG("addressVal is NULL.");
1467 char *msg_tone_file_path = NULL;
1469 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1471 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1473 bool bPlaySound = false;
1474 bool bPlayVibration = false;
1475 bool bOnCall = false;
1477 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1480 if (msg_tone_file_path) {
1481 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1484 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1485 MSG_MGR_INFO("vconf_get_int() is failed");
1487 int ringtoneType = tmpVal;
1488 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1489 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1491 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1494 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1497 if (bPlayVibration) {
1498 if (contactInfo.vibrationPath[0] == '\0')
1499 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1501 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1503 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1506 if (msg_tone_file_path)
1507 delete [] msg_tone_file_path;
1513 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1518 int noti_err = NOTIFICATION_ERROR_NONE;
1520 if (noti_info->active_noti_button_num > 1) {
1521 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1522 if (noti_info->active_noti_svc_h[0]) {
1523 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1524 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1526 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1528 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1529 wrn = snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1531 MSG_MGR_DEBUG("snprintf was failed");
1532 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1533 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1536 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1537 if (noti_info->active_noti_svc_h[1]) {
1538 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_MGR_APP_ID);
1540 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d] number = [%s] slot_id = [%d]", noti_info->msg_id, noti_info->number, noti_info->sim_idx);
1541 addServiceExtraData(noti_info->active_noti_svc_h[1], "cmd", "reply_msg");
1542 addServiceExtraData(noti_info->active_noti_svc_h[1], "msg_id", noti_info->msg_id);
1543 addServiceExtraData(noti_info->active_noti_svc_h[1], "addr", noti_info->number);
1545 char slot_id[5] = {0, };
1546 wrn = snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx);
1548 MSG_MGR_DEBUG("snprintf was failed");
1549 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1553 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1554 if (noti_info->active_noti_svc_h[2]) {
1555 setServicePackageName(noti_info->active_noti_svc_h[2], _get_app_id());
1557 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1558 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1559 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1560 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1562 char slot_id[5] = {0, };
1563 wrn = snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1565 MSG_MGR_DEBUG("snprintf was failed");
1566 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1569 if (noti_info->active_noti_button_num > 1) {
1570 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1571 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1572 notification_set_text_input(noti_h, 100);
1573 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_TEXT_INPUT_BUTTON, noti_info->active_noti_svc_h[1]);
1574 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1576 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", MSG_STRING_CALL);
1577 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", MSG_STRING_REPLY);
1578 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", MSG_STRING_VIEW);
1580 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1582 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", MSG_STRING_VIEW);
1585 setActiveProperty(noti_h, noti_info);
1587 setTextDomain(noti_h);
1589 setActiveText(noti_h, noti_info);
1591 setActiveIcon(noti_h, noti_info);
1593 noti_err = notification_post(noti_h);
1594 if (noti_err != NOTIFICATION_ERROR_NONE) {
1595 MSG_MGR_DEBUG("Fail to notification_post");
1602 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1606 int noti_err = NOTIFICATION_ERROR_NONE;
1608 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1610 if (bFeedback && noti_info->active_noti_button_num > MSG_ACTIVE_NOTI_BUTTON_NUM_NONE &&
1611 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1612 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1614 setActiveNotification(active_noti_h, noti_info);
1616 notification_free(active_noti_h);
1617 active_noti_h = NULL;
1620 setProperty(noti_h, noti_info);
1622 setTextDomain(noti_h);
1624 setText(noti_h, noti_info);
1626 setIcon(noti_h, noti_info);
1629 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1630 setSoundAndVibration(noti_h, noti_info->number, true);
1632 setSoundAndVibration(noti_h, noti_info->number, false);
1635 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1636 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1639 if (noti_info->id > 0) {
1640 MSG_MGR_DEBUG("Notification update");
1641 noti_err = notification_update(noti_h);
1642 if (noti_err != NOTIFICATION_ERROR_NONE) {
1643 MSG_MGR_DEBUG("Fail to notification_update");
1646 MSG_MGR_DEBUG("Notification insert");
1647 noti_err = notification_insert(noti_h, ¬i_info->id);
1648 if (noti_err != NOTIFICATION_ERROR_NONE) {
1649 MSG_MGR_DEBUG("Fail to notification_insert");
1652 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1655 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT && noti_info->msg_id > 0) {
1656 int err = vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID, noti_info->msg_id);
1658 MSG_MGR_ERR("vconf_set_int() failed [%d]", err);
1665 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1671 MSG_MGR_DEBUG("msg_info is NULL");
1675 noti_info->msg_id = msg_info->msgId;
1676 noti_info->sim_idx = msg_info->sim_idx;
1678 switch (noti_info->type) {
1679 case MSG_MGR_NOTI_TYPE_NORMAL: {
1680 char *senderStr = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, PUSH_MESSAGE);
1681 wrn = snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1683 MSG_MGR_DEBUG("snprintf was failed");
1690 case MSG_MGR_NOTI_TYPE_CLASS0: {
1691 if (msg_info->displayName[0] == '\0')
1693 wrn = snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1695 MSG_MGR_DEBUG("snprintf was failed");
1699 wrn = snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1701 MSG_MGR_DEBUG("snprintf was failed");
1704 wrn = snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1706 MSG_MGR_DEBUG("snprintf was failed");
1710 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1718 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1723 notification_free(noti_h);
1727 if (noti_info->svc_h) {
1728 app_control_destroy(noti_info->svc_h);
1729 noti_info->svc_h = NULL;
1732 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1733 if (noti_info->active_noti_svc_h[i]) {
1734 app_control_destroy(noti_info->active_noti_svc_h[i]);
1735 noti_info->active_noti_svc_h[i] = NULL;
1743 int getAppIcon(const char *app_id, char **icon_path)
1747 package_info_h pkg_info_h = NULL;
1748 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1751 if (app_id == NULL) {
1752 MSG_MGR_ERR("app id is NULL");
1754 goto END_OF_GET_APP_ICON;
1757 pkg_err = package_info_create(app_id, &pkg_info_h);
1758 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1759 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1761 goto END_OF_GET_APP_ICON;
1764 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1765 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1766 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1769 if (icon_path == NULL) {
1770 MSG_MGR_WARN("icon path is NULL");
1775 END_OF_GET_APP_ICON:
1777 pkg_err = package_info_destroy(pkg_info_h);
1778 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1779 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1791 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1797 msg_error_t msg_err = MSG_SUCCESS;
1798 char **db_res = NULL;
1799 int row_cnt = 0, col_cnt = 0;
1801 switch (noti_info->type) {
1802 case MSG_MGR_NOTI_TYPE_NORMAL:
1803 #ifdef MSG_NOTI_INTEGRATION
1804 case MSG_MGR_NOTI_TYPE_CB:
1805 case MSG_MGR_NOTI_TYPE_SIM:
1808 int smsUnreadCnt = 0;
1809 int mmsUnreadCnt = 0;
1811 char sqlQuery[MAX_QUERY_LEN +1];
1812 unsigned char mainType;
1813 unsigned char subType;
1814 int msgSize, attachmentCnt;
1816 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1817 #ifdef MSG_NOTI_INTEGRATION
1818 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1822 "WHERE A.CONV_ID=B.CONV_ID "
1823 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1824 "AND B.STORAGE_ID = %d "
1825 "GROUP BY A.ADDRESS_VAL "
1826 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1827 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1828 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1831 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1835 "WHERE A.CONV_ID=B.CONV_ID "
1836 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1837 "AND B.STORAGE_ID = %d "
1838 "GROUP BY A.ADDRESS_VAL "
1839 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1840 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1844 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1846 row_cnt = 0, col_cnt = 0;
1847 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1848 if (msg_err != MSG_SUCCESS) {
1849 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1853 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1854 int normalAddCnt = 0;
1855 int index = col_cnt;
1857 for (int i = 1; i <= row_cnt; i++) {
1858 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1860 char *address = db_res[index++];
1863 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1864 if (_is_valid_email(address)) {
1865 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1867 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1870 subType = atoi(db_res[index++]);
1872 MSG_MGR_CONTACT_INFO_S tmpContact;
1873 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1875 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1878 wrn = snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1880 MSG_MGR_DEBUG("snprintf was failed");
1883 if (normalAddCnt > 1) {
1884 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1887 if (tmpContact.firstName[0] != '\0') {
1888 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1889 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1890 char *senderStr = NULL;
1891 senderStr = get_translate_text("message", MSG_MGR_LOCALEDIR, MSG_UNKNOWN_SENDER);
1892 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1899 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_UNKNOWN_SENDER;
1902 char *senderStr = NULL;
1903 if (subType == MSG_CB_SMS) {
1904 senderStr = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, CB_MESSAGE);
1905 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1906 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
1907 } else if (subType == MSG_SYNCML_CP) {
1908 senderStr = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, CP_MESSAGE);
1909 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1910 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_PUSH_MESSAGE;
1911 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1912 senderStr = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, PUSH_MESSAGE);
1913 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1914 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_PUSH_MESSAGE;
1916 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1917 if (subType == MSG_NOTIFICATIONIND_MMS)
1918 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_UNRETRIVED_MESSAGE;
1928 noti_info->active_subtype = subType;
1929 wrn = snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1931 MSG_MGR_DEBUG("snprintf was failed");
1932 wrn = snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1934 MSG_MGR_DEBUG("snprintf was failed");
1938 noti_info->senderCount = normalAddCnt;
1939 msg_db_free(msg_handle, db_res);
1941 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1943 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1944 snprintf(sqlQuery, MAX_QUERY_LEN,
1945 "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS SMS_UNREAD_CNT, "
1946 "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS MMS_UNREAD_CNT "
1947 "FROM %s WHERE READ_STATUS = 0 AND (FOLDER_ID=%d OR FOLDER_ID=%d) AND STORAGE_ID = %d;",
1950 MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE);
1952 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1954 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1955 if (msg_err != MSG_SUCCESS) {
1956 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1961 smsUnreadCnt = atoi(db_res[col_cnt]);
1962 mmsUnreadCnt = atoi(db_res[col_cnt+1]);
1965 msg_db_free(msg_handle, db_res);
1967 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1969 if (noti_info->count == 0) {
1970 MSG_MGR_DEBUG("No unread message.");
1971 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1973 if (!isForInstantMessage) {
1974 /* No unread message. */
1975 if (noti_info->id > 0) {
1976 noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id);
1977 if (noti_err != NOTIFICATION_ERROR_NONE) {
1978 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1984 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1985 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1987 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1988 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1989 MsgMgrInsertBadge(0);
1990 MsgMgrSoundSetRepeatAlarm();
1996 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1997 #ifdef MSG_NOTI_INTEGRATION
1998 snprintf(sqlQuery, sizeof(sqlQuery),
2002 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
2003 "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
2006 "(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), "
2007 "B.ATTACHMENT_COUNT, "
2010 "LEFT JOIN %s A ON A.CONV_ID=B.CONV_ID "
2011 "WHERE B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
2012 "AND B.STORAGE_ID = %d "
2013 "ORDER BY B.DISPLAY_TIME DESC;",
2014 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
2015 MSGFW_MESSAGE_TABLE_NAME,
2016 MSGFW_ADDRESS_TABLE_NAME,
2017 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
2020 snprintf(sqlQuery, sizeof(sqlQuery),
2027 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
2028 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
2030 "WHERE A.CONV_ID=B.CONV_ID "
2031 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2032 "AND B.STORAGE_ID = %d "
2033 "ORDER BY B.DISPLAY_TIME DESC;",
2036 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2040 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2042 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2043 if (msg_err != MSG_SUCCESS) {
2044 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2049 msgSize = atoi(db_res[col_cnt+7]);
2050 attachmentCnt = atoi(db_res[col_cnt+8]);
2051 noti_info->sim_idx = atoi(db_res[col_cnt+9]);
2053 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
2055 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2057 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2059 noti_info->conv_id = atoi(db_res[col_cnt+6]);
2061 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2063 if (mainType == MSG_MMS_TYPE) {
2064 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2065 if (noti_info->text[0] == '\0') {
2066 char *noti_text = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, MSG_NO_SUBJECT);
2067 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
2071 char *prefix_subject = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, MSG_SUBJECT_COLON);
2072 if (prefix_subject) {
2073 wrn = snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
2075 MSG_MGR_DEBUG("snprintf was failed");
2076 g_free(prefix_subject);
2078 wrn = snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
2080 MSG_MGR_DEBUG("snprintf was failed");
2084 int kb_msg_size = msgSize / 1024;
2085 if (kb_msg_size == 0 && msgSize > 0)
2087 else if (msgSize % 1024 >= 512)
2090 char *msg_size_string = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, MESSAGE_SIZE_STRING);
2091 char *msg_size_unit_kb = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
2093 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
2095 g_free(msg_size_string);
2096 g_free(msg_size_unit_kb);
2099 noti_info->active_media_cnt = attachmentCnt;
2102 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2105 if (noti_info->active_text[0] == '\0')
2106 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
2108 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
2110 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
2111 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
2112 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
2114 if (!isForInstantMessage) {
2115 if (noti_info->id > 0 && noti_info->count == 1) {
2116 noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id);
2117 if (noti_err != NOTIFICATION_ERROR_NONE) {
2118 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2122 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
2123 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
2126 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
2127 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
2128 MsgMgrInsertBadge(noti_info->count);
2129 MsgMgrSoundSetRepeatAlarm();
2132 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2133 msg_db_free(msg_handle, db_res);
2137 msg_db_free(msg_handle, db_res);
2141 #ifndef MSG_NOTI_INTEGRATION
2142 case MSG_MGR_NOTI_TYPE_CB: {
2143 char sqlQuery[MAX_QUERY_LEN+1];
2144 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2146 snprintf(sqlQuery, sizeof(sqlQuery),
2152 "WHERE A.CONV_ID=B.CONV_ID "
2153 "AND B.READ_STATUS=0 "
2154 "AND B.FOLDER_ID=%d "
2155 "AND B.STORAGE_ID = %d "
2156 "ORDER BY B.DISPLAY_TIME DESC;",
2157 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2161 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
2162 return MSG_ERR_DB_PREPARE;
2164 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
2165 MSG_ADDRESS_INFO_S addrInfo;
2166 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
2168 if (dbhandler->columnText(0) != NULL)
2169 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2171 MSG_CONTACT_INFO_S tmpContact;
2172 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2174 MsgGetContactInfo(&addrInfo, &tmpContact);
2176 if (tmpContact.firstName[0] != '\0') {
2177 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2178 } else if (addrInfo.addressVal[0] == '\0') {
2179 char *senderStr = NULL;
2180 senderStr = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, MSG_UNKNOWN_SENDER);
2181 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2187 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2190 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2192 noti_info->time = (time_t)dbhandler->columnInt(1);
2194 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2196 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2198 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
2200 MSG_MGR_DEBUG("No unread CB message.");
2201 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
2203 dbhandler->finalizeQuery();
2205 if (!isForInstantMessage) {
2206 /* No unread message. */
2207 if (noti_info->id > 0) {
2208 noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id);
2209 if (noti_err != NOTIFICATION_ERROR_NONE) {
2210 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2216 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2217 MSG_MGR_DEBUG("MsgSettingSetInt Fail : CB_NOTI_PRIV_ID");
2219 return MSG_ERR_DB_STEP;
2222 dbhandler->finalizeQuery();
2224 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
2225 MSG_MGR_DEBUG("getTable is failed");
2226 dbhandler->freeTable();
2227 return MSG_ERR_DB_GETTABLE;
2230 dbhandler->freeTable();
2231 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
2234 case MSG_MGR_NOTI_TYPE_SIM: {
2235 char sqlQuery[MAX_QUERY_LEN+1];
2236 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2238 snprintf(sqlQuery, sizeof(sqlQuery),
2243 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
2245 "WHERE A.CONV_ID=B.CONV_ID "
2246 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2247 "AND B.STORAGE_ID = %d "
2248 "ORDER BY B.DISPLAY_TIME DESC;",
2250 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2254 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2256 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
2257 return MSG_ERR_DB_PREPARE;
2259 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
2260 noti_info->count = dbhandler->columnInt(4);
2262 if (noti_info->count > 0) {
2263 MSG_ADDRESS_INFO_S addrInfo;
2264 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
2266 if (dbhandler->columnText(0) != NULL)
2267 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
2269 MSG_CONTACT_INFO_S tmpContact;
2270 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
2272 MsgGetContactInfo(&addrInfo, &tmpContact);
2274 if (tmpContact.firstName[0] != '\0') {
2275 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2276 } else if (addrInfo.addressVal[0] == '\0') {
2277 char *senderStr = NULL;
2278 senderStr = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, MSG_UNKNOWN_SENDER);
2279 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2285 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2288 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2290 noti_info->time = (time_t)dbhandler->columnInt(1);
2292 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
2294 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
2296 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
2298 MSG_MGR_DEBUG("No unread SIM message.");
2299 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
2301 dbhandler->finalizeQuery();
2303 if (!isForInstantMessage) {
2304 /* No unread message. */
2305 if (noti_info->id > 0) {
2306 noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id);
2307 if (noti_err != NOTIFICATION_ERROR_NONE) {
2308 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2314 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
2315 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2318 return MSG_ERR_DB_STEP;
2321 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2322 dbhandler->finalizeQuery();
2323 return MSG_ERR_DB_STEP;
2326 dbhandler->finalizeQuery();
2330 case MSG_MGR_NOTI_TYPE_FAILED: {
2331 char sqlQuery[MAX_QUERY_LEN+1];
2332 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2334 snprintf(sqlQuery, sizeof(sqlQuery),
2341 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2343 "WHERE A.CONV_ID=B.CONV_ID "
2344 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2345 "AND B.STORAGE_ID = %d "
2346 "ORDER BY B.DISPLAY_TIME DESC;",
2347 MSG_NETWORK_SEND_FAIL,
2348 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2352 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2354 row_cnt = 0, col_cnt = 0;
2355 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2356 if (msg_err != MSG_SUCCESS) {
2357 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2362 noti_info->count = atoi(db_res[col_cnt+6]);
2364 if (noti_info->count > 0) {
2365 MSG_MGR_ADDRESS_INFO_S addrInfo = {0, };
2367 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2369 MSG_MGR_CONTACT_INFO_S tmpContact = {0, };
2371 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2373 if (tmpContact.firstName[0] != '\0') {
2374 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2375 } else if (addrInfo.addressVal[0] == '\0') {
2376 char *senderStr = NULL;
2377 senderStr = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, MSG_UNKNOWN_SENDER);
2378 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2384 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2387 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2389 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2391 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2393 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2395 if (mainType == MSG_TYPE_MMS)
2396 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2398 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2400 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2402 if (!isForInstantMessage) {
2403 if (noti_info->id > 0 && noti_info->count == 1) {
2404 noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id);
2405 if (noti_err != NOTIFICATION_ERROR_NONE) {
2406 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2409 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2410 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2414 MSG_MGR_DEBUG("No sent failed message.");
2415 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2417 msg_db_free(msg_handle, db_res);
2419 if (!isForInstantMessage) {
2420 /* No unread message. */
2421 if (noti_info->id > 0) {
2422 noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id);
2423 if (noti_err != NOTIFICATION_ERROR_NONE) {
2424 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2430 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2431 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2437 msg_db_free(msg_handle, db_res);
2441 msg_db_free(msg_handle, db_res);
2444 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2445 case MSG_MGR_NOTI_TYPE_STORAGE_FULL:
2448 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2458 notification_h getHandle(int *noti_id)
2460 notification_h noti_h = NULL;
2463 MSG_MGR_DEBUG("Notification load");
2464 noti_h = notification_load(NULL, *noti_id);
2466 MSG_MGR_DEBUG("notification_load is failed.");
2469 if (noti_h == NULL) {
2470 MSG_MGR_DEBUG("Notification create");
2471 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2472 if (noti_h == NULL) {
2473 MSG_MGR_DEBUG("notification_create is failed.");
2484 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2490 switch (noti_type) {
2491 #ifdef MSG_NOTI_INTEGRATION
2492 case MSG_MGR_NOTI_TYPE_NORMAL:
2493 case MSG_MGR_NOTI_TYPE_SIM:
2494 case MSG_MGR_NOTI_TYPE_CB:
2495 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2498 case MSG_MGR_NOTI_TYPE_NORMAL:
2499 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2501 case MSG_MGR_NOTI_TYPE_SIM:
2502 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2504 case MSG_MGR_NOTI_TYPE_CB:
2505 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2508 case MSG_MGR_NOTI_TYPE_FAILED:
2509 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2511 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
2512 vconf_get_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, ¬i_id);
2514 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2515 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2516 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2517 vconf_get_int(keyName, ¬i_id);
2520 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2521 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2522 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2523 vconf_get_int(keyName, ¬i_id);
2526 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2527 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2529 case MSG_MGR_NOTI_TYPE_STORAGE_FULL:
2530 vconf_get_int(STORAGE_FULL_NOTI_PRIV_ID, ¬i_id);
2533 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2537 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2545 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2551 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2553 switch (noti_type) {
2554 #ifdef MSG_NOTI_INTEGRATION
2555 case MSG_MGR_NOTI_TYPE_NORMAL:
2556 case MSG_MGR_NOTI_TYPE_SIM:
2557 case MSG_MGR_NOTI_TYPE_CB:
2558 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2561 case MSG_MGR_NOTI_TYPE_NORMAL:
2562 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2564 case MSG_MGR_NOTI_TYPE_SIM:
2565 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2567 case MSG_MGR_NOTI_TYPE_CB:
2568 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2571 case MSG_MGR_NOTI_TYPE_FAILED:
2572 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2574 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
2575 err = vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, noti_id);
2577 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2578 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2579 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2580 err = vconf_set_int(keyName, noti_id);
2583 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2584 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2585 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2586 err = vconf_set_int(keyName, noti_id);
2589 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2590 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2592 case MSG_MGR_NOTI_TYPE_STORAGE_FULL:
2593 err = vconf_set_int(STORAGE_FULL_NOTI_PRIV_ID, noti_id);
2596 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2601 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2607 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2612 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2613 noti_info->msg_id = msg_info->msgId;
2615 MSG_MGR_DEBUG("msg_info is NULL");
2620 noti_info->sim_idx = msg_info->sim_idx;
2622 createServiceHandle(¬i_info->svc_h);
2623 char keyName[MAX_VCONFKEY_NAME_LEN];
2625 switch (noti_info->type) {
2626 case MSG_MGR_NOTI_TYPE_VOICE_1:
2627 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2628 memset(keyName, 0x00, sizeof(keyName));
2629 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2630 vconf_get_int(keyName, ¬i_info->count);
2631 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2632 noti_info->time = msg_info->displayTime;
2634 memset(keyName, 0x00, sizeof(keyName));
2635 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2636 char *voiceNumber = vconf_get_str(keyName);
2637 memset(keyName, 0x00, sizeof(keyName));
2638 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2639 char *voiceAlphaId = vconf_get_str(keyName);
2640 char *dialNumber = NULL;
2642 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2644 if (voiceNumber && strlen(voiceNumber))
2645 dialNumber = voiceNumber;
2647 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2648 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2649 } else if (dialNumber && strlen(dialNumber) > 0) {
2650 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2653 if (dialNumber && strlen(dialNumber) > 0)
2654 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2656 if (noti_info->svc_h) {
2657 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2658 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2660 char slot_id[5] = {0, };
2661 wrn = snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2663 MSG_MGR_INFO("snprintf was failed");
2664 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2667 if (voiceNumber) g_free(voiceNumber);
2668 if (voiceAlphaId) g_free(voiceAlphaId);
2671 case MSG_MGR_NOTI_TYPE_MWI:
2672 case MSG_MGR_NOTI_TYPE_CLASS0: {
2673 noti_info->count = 1;
2674 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2675 noti_info->time = msg_info->displayTime;
2677 if (msg_info->displayName[0] == '\0')
2678 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2680 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2682 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2684 wrn = snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2686 MSG_MGR_INFO("snprintf was failed");
2688 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2689 if (noti_info->svc_h) {
2690 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2691 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2693 char slot_id[5] = {0, };
2694 wrn = snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2696 MSG_MGR_INFO("snprintf was failed");
2697 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2701 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2702 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2703 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2707 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2708 noti_info->count = 1;
2709 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2710 noti_info->time = msg_info->displayTime;
2711 noti_info->extra_data = msg_info->networkStatus;
2713 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2714 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2715 if (msg_info->addressVal[0] != '\0') {
2716 wrn = snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2718 MSG_MGR_INFO("snprintf was failed");
2719 if (_is_valid_email(msg_info->addressVal)) {
2720 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2722 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2726 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2727 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2730 if (contactInfo.firstName[0] == '\0')
2731 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2733 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2735 wrn = snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2737 MSG_MGR_INFO("snprintf was failed");
2739 if (noti_info->msg_id > 0) {
2740 setServiceAppId(noti_info->svc_h, _get_app_id());
2741 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2742 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2743 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2747 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2748 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2749 noti_info->count = 1;
2750 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2751 noti_info->time = msg_info->displayTime;
2753 MSG_MGR_CONTACT_INFO_S contactInfo = {0, };
2754 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0, };
2755 if (msg_info->addressVal[0] != '\0') {
2756 wrn = snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2758 MSG_MGR_INFO("snprintf was failed");
2759 if (_is_valid_email(msg_info->addressVal)) {
2760 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2762 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2766 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2767 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2769 if (contactInfo.firstName[0] == '\0')
2770 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2772 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2774 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2776 char sqlQuery[MAX_QUERY_LEN+1];
2777 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2779 int report_status_type;
2780 int report_status_value;
2782 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2783 report_status_type = MSG_REPORT_TYPE_READ;
2785 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2788 snprintf(sqlQuery, sizeof(sqlQuery),
2791 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE \"%%%s\";",
2792 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2794 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2796 char **db_res = NULL;
2797 int row_cnt = 0, col_cnt = 0;
2799 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2800 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2801 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2805 report_status_value = atoi(db_res[col_cnt]);
2807 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2809 msg_err = msg_db_free(msg_handle, db_res);
2810 if (msg_err != MSG_SUCCESS) {
2811 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2815 if (noti_info->msg_id > 0) {
2816 setServiceAppId(noti_info->svc_h, _get_app_id());
2817 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2818 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2819 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2822 noti_info->extra_data = (unsigned char)report_status_value;
2826 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2830 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2835 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2839 createServiceHandle(¬i_info->svc_h);
2841 switch (noti_info->type) {
2842 case MSG_MGR_NOTI_TYPE_NORMAL: {
2843 if (noti_info->count > 1) {
2844 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2846 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2849 setServiceAppId(noti_info->svc_h, _get_app_id());
2850 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2851 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2852 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2854 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE) {
2855 if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
2856 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
2858 int activated_conv_id = -1;
2859 vconf_get_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, &activated_conv_id);
2861 if (activated_conv_id == -1) {
2862 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2863 } else if (activated_conv_id == 0) {
2864 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2865 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2866 } else if (activated_conv_id > 0){
2867 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2869 if (activated_conv_id != noti_info->conv_id)
2870 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2872 MSG_MGR_WARN("No adding Notification : activated conv id [%d] / notification conv id [%d]", activated_conv_id, noti_info->conv_id);
2875 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
2880 case MSG_MGR_NOTI_TYPE_CB: {
2881 if (noti_info->count > 1) {
2882 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2884 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2887 setServiceAppId(noti_info->svc_h, _get_app_id());
2888 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2889 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2891 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2892 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2894 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2896 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
2899 case MSG_MGR_NOTI_TYPE_SIM: {
2900 if (noti_info->count > 1) {
2901 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2903 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2906 setServiceAppId(noti_info->svc_h, _get_app_id());
2907 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2908 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2910 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2911 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2913 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2915 if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
2916 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
2919 case MSG_MGR_NOTI_TYPE_FAILED: {
2920 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2922 setServiceAppId(noti_info->svc_h, _get_app_id());
2923 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2924 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2926 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2929 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2930 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2932 setServiceAppId(noti_info->svc_h, _get_app_id());
2933 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2935 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2938 case MSG_MGR_NOTI_TYPE_STORAGE_FULL: {
2939 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2940 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
2946 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2947 noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
2953 void createServiceHandle(app_control_h *svc_h)
2955 int svc_err = APP_CONTROL_ERROR_NONE;
2957 svc_err = app_control_create(svc_h);
2959 if (svc_err != APP_CONTROL_ERROR_NONE)
2960 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2964 void setServiceAppId(app_control_h svc_h, const char* app_id)
2966 int svc_err = APP_CONTROL_ERROR_NONE;
2968 svc_err = app_control_set_app_id(svc_h, app_id);
2970 if (svc_err != APP_CONTROL_ERROR_NONE)
2971 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2975 void setServiceUri(app_control_h svc_h, const char* uri)
2977 int svc_err = APP_CONTROL_ERROR_NONE;
2979 svc_err = app_control_set_uri(svc_h, uri);
2981 if (svc_err != APP_CONTROL_ERROR_NONE)
2982 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2986 void setServiceOperation(app_control_h svc_h, const char* operation)
2988 int svc_err = APP_CONTROL_ERROR_NONE;
2990 svc_err = app_control_set_operation(svc_h, operation);
2992 if (svc_err != APP_CONTROL_ERROR_NONE)
2993 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2997 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2999 int svc_err = APP_CONTROL_ERROR_NONE;
3001 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
3003 if (svc_err != APP_CONTROL_ERROR_NONE)
3004 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
3008 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
3010 int svc_err = APP_CONTROL_ERROR_NONE;
3013 memset(&tempId, 0x00, sizeof(tempId));
3014 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
3016 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
3018 if (svc_err != APP_CONTROL_ERROR_NONE)
3019 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
3023 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
3025 int svc_err = APP_CONTROL_ERROR_NONE;
3027 svc_err = app_control_set_app_id(svc_h, pkg_name);
3029 if (svc_err != APP_CONTROL_ERROR_NONE)
3030 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
3034 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
3036 int svc_err = APP_CONTROL_ERROR_NONE;
3038 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
3040 if (svc_err != APP_CONTROL_ERROR_NONE)
3041 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
3045 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
3047 int noti_err = NOTIFICATION_ERROR_NONE;
3049 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
3050 if (noti_err != NOTIFICATION_ERROR_NONE)
3051 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
3055 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
3057 int noti_err = NOTIFICATION_ERROR_NONE;
3059 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
3061 if (noti_err != NOTIFICATION_ERROR_NONE)
3062 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
3066 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
3068 int noti_err = NOTIFICATION_ERROR_NONE;
3070 noti_err = notification_set_time_to_text(noti_h, type, time);
3072 if (noti_err != NOTIFICATION_ERROR_NONE)
3073 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
3077 void setNotiTime(notification_h noti_h, time_t time)
3079 int noti_err = NOTIFICATION_ERROR_NONE;
3081 noti_err = notification_set_time(noti_h, time);
3083 if (noti_err != NOTIFICATION_ERROR_NONE)
3084 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
3089 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
3091 int noti_err = NOTIFICATION_ERROR_NONE;
3093 noti_err = notification_set_image(noti_h, type, image_path);
3095 if (noti_err != NOTIFICATION_ERROR_NONE)
3096 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
3100 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
3102 int noti_err = NOTIFICATION_ERROR_NONE;
3104 noti_err = notification_set_sound(noti_h, type, path);
3106 if (noti_err != NOTIFICATION_ERROR_NONE)
3107 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
3111 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
3113 int noti_err = NOTIFICATION_ERROR_NONE;
3115 noti_err = notification_set_vibration(noti_h, type, path);
3117 if (noti_err != NOTIFICATION_ERROR_NONE)
3118 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
3122 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
3124 int noti_err = NOTIFICATION_ERROR_NONE;
3126 noti_err = notification_set_event_handler(noti_h, type, event_handler);
3128 if (noti_err != NOTIFICATION_ERROR_NONE)
3129 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
3133 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
3137 char *notiMsg = NULL;
3139 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
3141 switch (noti_type) {
3142 case MSG_MGR_NOTI_TYPE_NORMAL:
3143 case MSG_MGR_NOTI_TYPE_SIM:
3144 case MSG_MGR_NOTI_TYPE_CB: {
3145 MSG_MGR_NOTI_INFO_S noti_info;
3146 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
3148 noti_info.type = noti_type;
3149 int err = getLatestMsgInfo(¬i_info, true);
3152 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
3153 if (noti_info.count == 1) {
3154 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
3155 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
3156 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
3157 } else if (noti_info.count > 1) {
3158 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
3160 notiMsg = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, NEW_MESSAGES);
3161 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
3162 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
3163 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
3168 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
3172 case MSG_MGR_NOTI_TYPE_FAILED: {
3173 notiMsg = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
3174 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
3175 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
3179 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
3180 goto _END_OF_INSTANT_NOTI;
3184 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
3185 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
3187 if (notification_set_pkgname(noti, _get_app_id()) != NOTIFICATION_ERROR_NONE)
3188 MSG_MGR_DEBUG("Fail to notification_set_pkgname");
3190 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
3191 MSG_MGR_DEBUG("Fail to notification_post");
3193 _END_OF_INSTANT_NOTI:
3195 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
3196 MSG_MGR_DEBUG("Fail to notification_delete");
3203 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
3204 MSG_MGR_DEBUG("Fail to notification_free");
3213 bool MsgMgrCheckNotificationSettingEnable()
3215 bool msg_noti_enabled = false;
3216 notification_system_setting_h system_setting = NULL;
3217 notification_setting_h setting = NULL;
3219 int err = NOTIFICATION_ERROR_NONE;
3221 err = notification_setting_get_setting_by_package_name(_get_app_id(), &setting);
3223 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
3224 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", _get_app_id(), err);
3226 msg_noti_enabled = true;
3228 bool allow_to_notify = false;
3229 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
3231 if (err != NOTIFICATION_ERROR_NONE) {
3232 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
3236 if (allow_to_notify) {
3237 MSG_MGR_DEBUG("message notification is allowed");
3239 /* check do not disturb mode */
3240 err = notification_system_setting_load_system_setting(&system_setting);
3242 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
3243 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
3247 bool do_not_disturb_mode = false;
3248 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
3250 if (err != NOTIFICATION_ERROR_NONE) {
3251 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
3255 if (do_not_disturb_mode) {
3256 bool is_msg_excepted = false;
3257 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
3258 if (err != NOTIFICATION_ERROR_NONE) {
3259 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", _get_app_id(), err);
3260 msg_noti_enabled = false;
3262 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", _get_app_id(), is_msg_excepted);
3263 msg_noti_enabled = (is_msg_excepted) ? true : false;
3266 MSG_MGR_DEBUG("do not disturb mode is off");
3269 MSG_MGR_INFO("message notification is not allowed");
3270 msg_noti_enabled = false;
3276 notification_system_setting_free_system_setting(system_setting);
3279 notification_setting_free_notification(setting);
3281 return msg_noti_enabled;
3285 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
3287 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
3288 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
3290 MsgMgrChangePmState();
3292 char *notiMsg = NULL;
3293 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
3296 notiMsg = get_translate_text(MSG_MGR_PACKAGE_NAME, MSG_MGR_LOCALEDIR, pLocaleTickerMsg);
3297 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
3299 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
3300 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
3301 g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_MEMORY_FULL) != 0 &&
3302 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
3303 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
3304 notification_status_message_post(pTickerMsg);
3306 notification_status_message_post(notiMsg);
3309 /* Show ticker popup for sending failed msg. */
3310 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
3318 if (bPlayFeedback) {
3320 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
3321 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
3323 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
3325 #if 0 /* Below codes are blocked because of change of UX guide. And it will be removed later. */
3326 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
3327 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
3329 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
3332 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_MEMORY_FULL) == 0) {
3333 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_STORAGE_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
3335 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
3338 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
3346 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
3348 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
3350 int err = BADGE_ERROR_NONE;
3353 err = badge_is_existing(_get_app_id(), &exist);
3355 if (err != BADGE_ERROR_NONE) {
3356 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
3362 err = badge_add(_get_app_id());
3363 if (err != BADGE_ERROR_NONE) {
3364 MSG_MGR_ERR("Fail to badge_add : %d", err);
3369 err = badge_set_count(_get_app_id(), unreadMsgCnt);
3371 if (err != BADGE_ERROR_NONE) {
3372 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3380 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3384 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3386 #ifndef MSG_NOTI_INTEGRATION
3387 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3388 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3396 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3402 struct tm repeat_tm;
3406 tmp_time += (RepeatTime*60);
3408 localtime_r(&tmp_time, &repeat_tm);
3410 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3411 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3415 g_alarmId = tmpAlarmId;
3416 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3424 void MsgMgrSoundSetRepeatAlarm()
3426 int nRepeatValue = 0;
3427 long nRepeatTime = 0;
3429 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3430 MSG_MGR_INFO("vconf_get_int() is failed");
3433 switch (nRepeatValue) {
3434 case MSG_ALERT_TONE_ONCE:
3437 case MSG_ALERT_TONE_2MINS:
3440 case MSG_ALERT_TONE_5MINS:
3443 case MSG_ALERT_TONE_10MINS:
3447 MSG_MGR_DEBUG("Invalid Repetition time");
3451 MSG_MGR_DEBUG("nRepeatTime = %ld", nRepeatTime);
3453 if (nRepeatTime > 0) {
3454 if (g_alarmId > 0) {
3455 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3456 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3460 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3467 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3469 char *notiMsg = NULL;
3472 lang = vconf_get_str(VCONFKEY_LANGSET);
3474 setlocale(LC_MESSAGES, lang);
3476 bindtextdomain(pkg_name, locale_dir);
3478 notiMsg = dgettext(pkg_name, text);
3485 return g_strdup(notiMsg);