2 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /*==================================================================================================
19 ==================================================================================================*/
29 #include <app_control.h>
30 #include <badge_internal.h>
31 #include <notification_list.h>
32 #include <notification_text_domain.h>
33 #include <notification_internal.h>
34 #include <notification_status.h>
35 #include <notification_setting.h>
36 #include <notification_setting_internal.h>
37 #include <package_manager.h>
41 #include <msg_storage.h>
43 #include <msg-manager-util.h>
44 #include <msg-manager-contact.h>
45 #include <msg-manager-debug.h>
46 #include <msg-manager-notification.h>
47 #include <msg-manager-sound.h>
52 /*==================================================================================================
54 ==================================================================================================*/
56 static GList *msg_report_notification_list = NULL;
57 static bool is_init = false;
58 extern msg_handle_t msg_handle;
62 /*==================================================================================================
64 ==================================================================================================*/
65 typedef struct _report_notification_s
68 char addressVal[MAX_ADDRESS_VAL_LEN+1];
69 } report_notification_s;
72 typedef struct _msg_mgr_noti_info_s
74 msg_mgr_notification_type_t type;
80 char sender[MSG_NOTI_TEXT_LEN_S+1];
81 char text[MSG_NOTI_TEXT_LEN+1];
82 char number[MSG_NOTI_TEXT_LEN_S+1];
83 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
86 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
87 msg_message_id_t msg_id;
88 unsigned char extra_data;
90 int active_noti_button_num;
92 int active_media_size;
93 unsigned char active_subtype; /**< to distinguish cb, push message */
94 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
95 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
96 char active_text[MSG_NOTI_TEXT_LEN+1];
97 } MSG_MGR_NOTI_INFO_S;
100 typedef struct _del_noti_info_s
102 msg_mgr_notification_type_t type;
107 /*==================================================================================================
109 ===================================================================================================*/
111 void MsgMgrInitReportNotiList();
112 void MsgRefreshNotiCb(void *data);
113 void MsgMgrDeleteNotiCb(void *data);
115 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
117 notification_h getHandle(int *noti_id);
119 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
120 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
122 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
123 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
124 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
125 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
127 int getAppIcon(const char *app_id, char **icon_path);
128 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
130 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
131 void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type);
132 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
133 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
134 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
135 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
136 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
137 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
138 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
140 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
142 bool isExistAddressInReportTable(const char *addr);
145 void createServiceHandle(app_control_h *svc_h);
146 void setServiceAppId(app_control_h svc_h, const char* app_id);
147 void setServiceUri(app_control_h svc_h, const char* uri);
148 void setServiceOperation(app_control_h svc_h, const char* operation);
149 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
150 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
151 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
152 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
154 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
155 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
156 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
157 void setNotiTime(notification_h noti_h, time_t time);
158 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
159 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
160 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
161 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
164 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
165 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
166 void MsgMgrSoundSetRepeatAlarm();
168 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
170 /*==================================================================================================
171 FUNCTION IMPLEMENTATION
172 ==================================================================================================*/
173 bool _is_valid_email(char *pAddress)
175 if (!pAddress || pAddress[0] == 0)
177 if (!strchr (pAddress, EMAIL_AT))
183 bool isExistAddressInReportTable(const char *addr)
185 char sqlQuery[MAX_QUERY_LEN+1];
186 int rowCnt = 0, colCnt = 0;
187 char **db_res = NULL;
190 char *normal_addr = msg_mgr_normalize_number((char *)addr);
192 memset(sqlQuery, 0x00, sizeof(sqlQuery));
193 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normal_addr);
195 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
196 if (msg_err != MSG_SUCCESS) {
197 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
201 msg_err = msg_db_free(msg_handle, db_res);
202 if (msg_err != MSG_SUCCESS) {
203 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
210 memset(sqlQuery, 0x00, sizeof(sqlQuery));
211 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normal_addr);
213 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
214 if (msg_err != MSG_SUCCESS) {
215 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
219 msg_err = msg_db_free(msg_handle, db_res);
220 if (msg_err != MSG_SUCCESS) {
221 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
232 void MsgMgrInitReportNotiList()
236 if (msg_report_notification_list) {
237 MSG_MGR_DEBUG("Report Noti List is already inited");
241 msg_report_notification_list = NULL;
243 notification_h noti = NULL;
244 notification_list_h noti_list = NULL;
245 notification_list_h head_noti_list = NULL;
246 int noti_err = NOTIFICATION_ERROR_NONE;
247 app_control_h app_control = NULL;
249 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
250 if (noti_err != NOTIFICATION_ERROR_NONE) {
251 MSG_MGR_DEBUG("notification_get_list() is failed!!");
255 head_noti_list = noti_list;
257 while (noti_list != NULL) {
258 noti = notification_list_get_data(noti_list);
260 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
261 memset(tempAddr, 0x00, sizeof(tempAddr));
263 noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, &app_control);
264 if (noti_err != NOTIFICATION_ERROR_NONE) {
265 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
271 int ret = app_control_get_extra_data(app_control, "address", &addr);
272 if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
273 if (isExistAddressInReportTable(addr)) {
274 report_notification_s *info = new report_notification_s;
275 memset(info, 0x00, sizeof(report_notification_s));
277 notification_get_id(noti, NULL, &(info->priv_id));
278 snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
280 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
281 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
288 noti_list = notification_list_get_next(noti_list);
292 notification_free_list(head_noti_list);
298 void MsgMgrInitNoti()
303 bool bNotiSvcReady = false;
305 bNotiSvcReady = notification_is_service_ready();
307 if (bNotiSvcReady == true) {
308 MSG_MGR_DEBUG("Notification server is available");
309 #ifndef MSG_NOTI_INTEGRATION
310 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
312 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
313 MsgMgrInitReportNotiList();
315 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
316 #ifndef MSG_NOTI_INTEGRATION
317 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
319 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
320 delNotiInfo->sim_idx = -1;
322 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
324 notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
331 void MsgRefreshNotiCb(void *data)
333 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
334 MsgMgrInitReportNotiList();
345 void MsgMgrDeleteNotiCb(void *data)
348 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)data;
350 MsgMgrDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx);
360 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
364 notification_h noti_h = NULL;
366 MSG_MGR_NOTI_INFO_S noti_info = {0, };
368 noti_info.type = noti_type;
369 noti_info.active_noti_button_num = 1;
371 createActiveInfoData(¬i_info, msg_info);
373 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
375 setActiveNotification(noti_h, ¬i_info);
377 clearInfoData(noti_h, ¬i_info);
384 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
387 notification_h noti_h = NULL;
388 int bNotification = 1;
389 /* bool bReplyPopup = false; */
391 MSG_MGR_NOTI_INFO_S noti_info = {0,};
392 noti_info.type = noti_type;
393 noti_info.id = getPrivId(noti_info.type, -1);
395 err = getLatestMsgInfo(¬i_info, false);
398 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
399 goto __END_OF_REFRESH_NOTI;
402 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
403 err = MsgMgrInsertInstantMessage(noti_type);
406 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
407 goto __END_OF_REFRESH_NOTI;
411 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
412 MSG_MGR_DEBUG("vconf_get_bool is failed.");
415 if (bNotification == 0) {
416 MSG_MGR_DEBUG("Msg Alert notification is off.");
417 goto __END_OF_REFRESH_NOTI;
420 createInfoData(¬i_info, active_type);
422 noti_h = getHandle(¬i_info.id);
424 if (noti_h == NULL) {
425 MSG_MGR_DEBUG("Notification handle is NULL");
426 err = MSG_ERR_NULL_POINTER;
427 goto __END_OF_REFRESH_NOTI;
430 setNotification(noti_h, ¬i_info, bFeedback);
432 __END_OF_REFRESH_NOTI :
433 clearInfoData(noti_h, ¬i_info);
439 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
443 notification_h noti_h = NULL;
445 report_notification_s *info = new report_notification_s;
446 memset(info, 0x00, sizeof(report_notification_s));
448 MSG_MGR_NOTI_INFO_S noti_info = {0,};
449 noti_info.type = noti_type;
451 createInfoData(¬i_info, msg_info);
453 noti_h = getHandle(¬i_info.id);
455 if (noti_h == NULL) {
456 MSG_MGR_DEBUG("Notification handle is NULL");
458 goto __END_OF_ADD_REPORT_NOTI;
461 setNotification(noti_h, ¬i_info, true);
463 info->priv_id = noti_info.id;
464 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
465 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
466 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
468 __END_OF_ADD_REPORT_NOTI :
469 clearInfoData(noti_h, ¬i_info);
475 int MsgMgrDeleteReportNotification(const char *addr)
479 notification_h noti_h = NULL;
480 int bNotification = 1;
482 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
483 MSG_MGR_DEBUG("vconf_get_bool is failed.");
486 if (bNotification == 0) {
487 MSG_MGR_DEBUG("Msg Alert notification is off.");
491 char* normalAddr = NULL;
492 unsigned int list_length = g_list_length(msg_report_notification_list);
493 bool isDelete = false;
495 MSG_MGR_DEBUG("list length [%d]", list_length);
497 if (list_length > 0) {
498 GList *iter = g_list_first(msg_report_notification_list);
500 while (iter != NULL) {
502 report_notification_s *info = (report_notification_s*)(iter->data);
504 MSG_MGR_DEBUG("info is NULL!");
508 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
510 noti_h = notification_load(NULL, info->priv_id);
511 if (noti_h == NULL) {
512 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
515 normalAddr = msg_mgr_normalize_number(info->addressVal);
518 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
520 if (g_str_has_suffix(addr, normalAddr)) {
521 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
522 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
525 MSG_MGR_DEBUG("delete notification failed");
530 notification_free(noti_h);
534 iter = g_list_next(iter);
537 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
551 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
555 notification_h noti_h = NULL;
557 MSG_MGR_NOTI_INFO_S noti_info = {0, };
559 noti_info.type = noti_type;
561 createInfoData(¬i_info, msg_info);
563 /* check mwi or voicemail count is 0 then skip add notification */
564 if (noti_info.count == 0) {
565 MSG_MGR_DEBUG("Notification count is 0");
567 goto __END_OF_ADD_NOTI;
570 noti_h = getHandle(¬i_info.id);
572 if (noti_h == NULL) {
573 MSG_MGR_DEBUG("Notification handle is NULL");
575 goto __END_OF_ADD_NOTI;
578 setNotification(noti_h, ¬i_info, true);
581 clearInfoData(noti_h, ¬i_info);
587 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex)
589 int noti_err = NOTIFICATION_ERROR_NONE;
591 if (noti_type == MSG_MGR_NOTI_TYPE_ALL) {
592 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
593 } 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) {
596 notiId = getPrivId(noti_type, simIndex);
597 MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
600 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, notiId);
603 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
606 if (noti_err != NOTIFICATION_ERROR_NONE) {
607 MSG_MGR_DEBUG("Fail to notification_delete_all noti_err [%d]", noti_err);
610 updatePrivId(noti_type, 0, simIndex);
614 int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
616 bool bNotiSvcReady = false;
618 DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S));
621 delNotiInfo->type = noti_type;
622 delNotiInfo->sim_idx = simIndex;
625 bNotiSvcReady = notification_is_service_ready();
627 if (bNotiSvcReady == true) {
628 MSG_MGR_DEBUG("Notification server is available");
629 MsgMgrDeleteNotiCb((void *)delNotiInfo);
631 MSG_MGR_DEBUG("Notification server is not available. Delete is defered");
632 notification_add_deferred_task(MsgMgrDeleteNotiCb, (void *)delNotiInfo);
638 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
644 #ifndef MSG_NOTI_INTEGRATION
645 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
648 #ifdef MSG_NOTI_INTEGRATION
649 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
651 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
653 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
655 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
657 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
659 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
662 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
664 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
668 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
670 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
676 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
680 int noti_err = NOTIFICATION_ERROR_NONE;
683 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
684 if (noti_err != NOTIFICATION_ERROR_NONE) {
685 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
689 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
690 if (noti_err != NOTIFICATION_ERROR_NONE) {
691 MSG_MGR_DEBUG("Fail to notification_set_led.");
694 /* set execute option and property */
695 switch (noti_info->type) {
696 case MSG_MGR_NOTI_TYPE_NORMAL: {
697 if (noti_info->count > 1) {
698 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
700 if (noti_info->svc_h) { /* overwrite bundle key "type" */
701 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
702 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
704 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
707 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
710 case MSG_MGR_NOTI_TYPE_CB:
711 case MSG_MGR_NOTI_TYPE_SIM: {
712 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
713 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
716 case MSG_MGR_NOTI_TYPE_FAILED: {
717 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
718 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
721 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
722 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
725 case MSG_MGR_NOTI_TYPE_VOICE_1:
726 case MSG_MGR_NOTI_TYPE_VOICE_2:
727 case MSG_MGR_NOTI_TYPE_MWI:
728 case MSG_MGR_NOTI_TYPE_CLASS0:
729 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
730 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
731 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
732 notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
736 MSG_MGR_DEBUG("No matching type for notification_set_launch_option() [%d]", noti_info->type);
741 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
742 if (noti_err != NOTIFICATION_ERROR_NONE) {
743 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
751 void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type)
755 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
760 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
764 char unreadMsgCntStr[10] = {0};
767 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
768 MSG_MGR_DEBUG("vconf_get_bool is failed.");
771 /* set title and content */
772 switch (noti_info->type) {
773 #ifdef MSG_NOTI_INTEGRATION
774 case MSG_MGR_NOTI_TYPE_NORMAL:
775 case MSG_MGR_NOTI_TYPE_CB:
776 case MSG_MGR_NOTI_TYPE_SIM: {
777 if (noti_info->count > 1) {
778 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
779 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
780 setNotiTime(noti_h, noti_info->time);
782 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
783 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
787 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
788 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
790 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
791 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
793 setNotiTime(noti_h, noti_info->time);
798 case MSG_MGR_NOTI_TYPE_NORMAL: {
799 if (noti_info->count > 1) {
800 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
801 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
802 setNotiTime(noti_h, noti_info->time);
804 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
805 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
808 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
809 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
811 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
812 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
814 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
815 setNotiTime(noti_h, noti_info->time);
819 case MSG_MGR_NOTI_TYPE_CB: {
820 if (noti_info->count > 1) {
821 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
822 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
823 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
824 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
825 setNotiTime(noti_h, noti_info->time);
828 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
829 setNotiTime(noti_h, noti_info->time);
832 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
833 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
835 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
836 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
841 case MSG_MGR_NOTI_TYPE_SIM: {
842 if (noti_info->count > 1) {
843 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
844 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
845 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
847 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
848 setNotiTime(noti_h, noti_info->time);
850 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
851 setNotiTime(noti_h, noti_info->time);
854 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
855 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
857 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
858 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
864 case MSG_MGR_NOTI_TYPE_FAILED: {
865 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
866 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
867 if (noti_info->count > 1) {
868 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
869 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
871 setNotiTime(noti_h, noti_info->time);
874 case MSG_MGR_NOTI_TYPE_VOICE_1:
875 case MSG_MGR_NOTI_TYPE_VOICE_2: {
876 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
877 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
878 setNotiTime(noti_h, noti_info->time);
880 if (noti_info->count == 1) {
881 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
882 } else if (noti_info->count > 1) {
883 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
884 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
886 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
890 case MSG_MGR_NOTI_TYPE_MWI: {
891 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
892 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
893 setNotiTime(noti_h, noti_info->time);
896 case MSG_MGR_NOTI_TYPE_CLASS0: {
897 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
898 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
899 setNotiTime(noti_h, noti_info->time);
902 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
903 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
904 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
906 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
907 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
908 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
909 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
911 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
914 setNotiTime(noti_h, noti_info->time);
917 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
918 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
919 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
921 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
922 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
923 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
925 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
926 /* notification free */
929 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
932 setNotiTime(noti_h, noti_info->time);
935 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
936 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
937 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
939 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED)
940 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
941 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED)
942 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE);
943 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED)
944 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
945 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED)
946 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE);
947 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE)
948 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE);
949 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED)
950 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL);
951 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE)
952 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE);
953 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR)
954 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL);
955 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
957 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_NONE) {
958 /* notification free */
962 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
964 setNotiTime(noti_h, noti_info->time);
967 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
968 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
969 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
973 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
980 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
984 switch (noti_info->type) {
985 #ifdef MSG_NOTI_INTEGRATION
986 case MSG_MGR_NOTI_TYPE_NORMAL:
987 case MSG_MGR_NOTI_TYPE_CB:
988 case MSG_MGR_NOTI_TYPE_SIM: {
989 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
990 if (noti_info->count > 1 && noti_info->senderCount > 1) {
991 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
992 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
993 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
995 if (noti_info->active_subtype == MSG_CB_SMS) {
996 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
997 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
998 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
999 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
1000 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1001 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
1002 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1004 if (noti_info->imagePath[0] != '\0') {
1005 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
1006 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1008 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1009 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1012 char *msg_icon_path = NULL;
1013 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1014 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1015 g_free(msg_icon_path);
1017 MSG_MGR_ERR("fail to get message-app icon");
1024 case MSG_MGR_NOTI_TYPE_NORMAL: {
1025 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1026 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
1028 if (noti_info->count > 1) {
1029 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1031 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
1035 case MSG_MGR_NOTI_TYPE_CB: {
1036 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1037 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
1040 case MSG_MGR_NOTI_TYPE_SIM: {
1041 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
1042 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1046 case MSG_MGR_NOTI_TYPE_FAILED: {
1047 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1048 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SMS_SENDING_FAILED_ICON_PATH);
1051 case MSG_MGR_NOTI_TYPE_VOICE_1:
1052 case MSG_MGR_NOTI_TYPE_VOICE_2:
1053 case MSG_MGR_NOTI_TYPE_MWI: {
1054 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1055 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1058 case MSG_MGR_NOTI_TYPE_CLASS0:
1059 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1061 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1062 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1063 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1065 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1066 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1067 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1069 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1070 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1071 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1073 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1074 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1075 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1078 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1085 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1089 int noti_err = NOTIFICATION_ERROR_NONE;
1092 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1093 if (noti_err != NOTIFICATION_ERROR_NONE) {
1094 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1098 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1099 if (noti_err != NOTIFICATION_ERROR_NONE) {
1100 MSG_MGR_DEBUG("Fail to notification_set_led.");
1104 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1105 if (noti_err != NOTIFICATION_ERROR_NONE) {
1106 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1113 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1117 switch (noti_info->type) {
1118 case MSG_MGR_NOTI_TYPE_NORMAL:
1119 case MSG_MGR_NOTI_TYPE_SIM:
1120 case MSG_MGR_NOTI_TYPE_CB: {
1121 if (noti_info->active_subject[0] == '\0') {
1122 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1123 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1125 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1126 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1127 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1131 case MSG_MGR_NOTI_TYPE_CLASS0: {
1132 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1133 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1137 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1145 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1149 switch (noti_info->type) {
1150 case MSG_MGR_NOTI_TYPE_NORMAL:
1151 case MSG_MGR_NOTI_TYPE_SIM: {
1152 switch (noti_info->active_subtype) {
1154 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1156 case MSG_WAP_SI_SMS:
1157 case MSG_WAP_SL_SMS:
1158 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1161 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1164 if (noti_info->imagePath[0] != '\0')
1165 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1167 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1169 char *msg_icon_path = NULL;
1170 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1171 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1172 g_free(msg_icon_path);
1174 MSG_MGR_ERR("fail to get message-app icon");
1182 case MSG_MGR_NOTI_TYPE_CB: {
1183 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1186 case MSG_MGR_NOTI_TYPE_CLASS0:
1187 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1190 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1198 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1202 MSG_MGR_ADDRESS_INFO_S addrInfo = {0,};
1203 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
1205 if (addressVal != NULL) {
1206 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1207 /* Get Contact Info */
1208 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1209 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1212 MSG_MGR_DEBUG("addressVal is NULL.");
1215 char *msg_tone_file_path = NULL;
1217 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1219 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1221 bool bPlaySound = false;
1222 bool bPlayVibration = false;
1223 bool bOnCall = false;
1225 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1228 if (msg_tone_file_path)
1229 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1232 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1233 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1235 int ringtoneType = tmpVal;
1236 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1237 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1239 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1242 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1245 if (bPlayVibration) {
1246 if (contactInfo.vibrationPath[0] == '\0')
1247 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1249 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1251 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1254 if (msg_tone_file_path)
1255 delete [] msg_tone_file_path;
1261 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1265 int noti_err = NOTIFICATION_ERROR_NONE;
1267 setActiveProperty(noti_h, noti_info);
1269 setTextDomain(noti_h, noti_info->type);
1271 setActiveText(noti_h, noti_info);
1273 setActiveIcon(noti_h, noti_info);
1275 if (noti_info->active_noti_button_num > 1) {
1276 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1277 if (noti_info->active_noti_svc_h[0]) {
1278 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1279 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1281 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1283 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1284 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1285 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1286 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1289 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1290 if (noti_info->active_noti_svc_h[1]) {
1291 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1293 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1294 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1295 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1297 char slot_id[5] = {0, };
1298 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1299 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1303 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1304 if (noti_info->active_noti_svc_h[2]) {
1305 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1307 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1308 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1309 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1310 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1312 char slot_id[5] = {0, };
1313 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1314 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1317 if (noti_info->active_noti_button_num > 1) {
1318 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1319 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1320 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1322 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1323 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1324 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1326 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1328 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1331 noti_err = notification_post(noti_h);
1332 if (noti_err != NOTIFICATION_ERROR_NONE) {
1333 MSG_MGR_DEBUG("Fail to notification_post");
1340 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1344 int noti_err = NOTIFICATION_ERROR_NONE;
1346 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1348 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1349 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1350 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1352 setActiveNotification(active_noti_h, noti_info);
1354 notification_free(active_noti_h);
1355 active_noti_h = NULL;
1358 setProperty(noti_h, noti_info);
1360 setTextDomain(noti_h, noti_info->type);
1362 setText(noti_h, noti_info);
1364 setIcon(noti_h, noti_info);
1367 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1368 setSoundAndVibration(noti_h, noti_info->number, true);
1370 setSoundAndVibration(noti_h, noti_info->number, false);
1373 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1374 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1377 if (noti_info->id > 0) {
1378 MSG_MGR_DEBUG("Notification update");
1379 noti_err = notification_update(noti_h);
1380 if (noti_err != NOTIFICATION_ERROR_NONE) {
1381 MSG_MGR_DEBUG("Fail to notification_update");
1384 MSG_MGR_DEBUG("Notification insert");
1385 noti_err = notification_insert(noti_h, ¬i_info->id);
1386 if (noti_err != NOTIFICATION_ERROR_NONE) {
1387 MSG_MGR_DEBUG("Fail to notification_insert");
1390 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1397 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1402 MSG_MGR_DEBUG("msg_info is NULL");
1406 noti_info->msg_id = msg_info->msgId;
1407 noti_info->sim_idx = msg_info->sim_idx;
1409 switch (noti_info->type) {
1410 case MSG_MGR_NOTI_TYPE_NORMAL: {
1411 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1412 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1419 case MSG_MGR_NOTI_TYPE_CLASS0: {
1420 if (msg_info->displayName[0] == '\0')
1421 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1423 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1425 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1429 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1437 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1442 notification_free(noti_h);
1446 if (noti_info->svc_h) {
1447 app_control_destroy(noti_info->svc_h);
1448 noti_info->svc_h = NULL;
1451 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1452 if (noti_info->active_noti_svc_h[i]) {
1453 app_control_destroy(noti_info->active_noti_svc_h[i]);
1454 noti_info->active_noti_svc_h[i] = NULL;
1462 int getAppIcon(const char *app_id, char **icon_path)
1466 package_info_h pkg_info_h = NULL;
1467 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1470 if (app_id == NULL) {
1471 MSG_MGR_ERR("app id is NULL");
1473 goto END_OF_GET_APP_ICON;
1476 pkg_err = package_info_create(app_id, &pkg_info_h);
1477 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1478 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1480 goto END_OF_GET_APP_ICON;
1483 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1484 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1485 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1488 if (icon_path == NULL) {
1489 MSG_MGR_WARN("icon path is NULL");
1494 END_OF_GET_APP_ICON:
1496 pkg_err = package_info_destroy(pkg_info_h);
1497 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1498 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1510 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1515 msg_error_t msg_err = MSG_SUCCESS;
1516 char **db_res = NULL;
1517 int row_cnt = 0, col_cnt = 0;
1519 switch (noti_info->type) {
1520 case MSG_MGR_NOTI_TYPE_NORMAL:
1521 #ifdef MSG_NOTI_INTEGRATION
1522 case MSG_MGR_NOTI_TYPE_CB:
1523 case MSG_MGR_NOTI_TYPE_SIM:
1526 int smsUnreadCnt = 0;
1527 int mmsUnreadCnt = 0;
1529 char sqlQuery[MAX_QUERY_LEN +1];
1530 unsigned char mainType;
1531 unsigned char subType;
1534 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1535 #ifdef MSG_NOTI_INTEGRATION
1536 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1540 "WHERE A.CONV_ID=B.CONV_ID "
1541 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1542 "AND B.STORAGE_ID = %d "
1543 "GROUP BY A.ADDRESS_VAL "
1544 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1545 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1546 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1549 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1553 "WHERE A.CONV_ID=B.CONV_ID "
1554 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1555 "AND B.STORAGE_ID = %d "
1556 "GROUP BY A.ADDRESS_VAL "
1557 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1558 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1562 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1564 row_cnt = 0, col_cnt = 0;
1565 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1566 if (msg_err != MSG_SUCCESS) {
1567 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1571 /* contacts-service is not used for gear */
1572 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
1573 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1574 int normalAddCnt = 0;
1575 int index = col_cnt;
1577 for (int i = 1; i <= row_cnt; i++) {
1578 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1580 char *address = db_res[index++];
1583 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1584 if (_is_valid_email(address)) {
1585 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1587 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1590 subType = atoi(db_res[index++]);
1592 MSG_MGR_CONTACT_INFO_S tmpContact;
1593 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1595 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1598 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1601 if (normalAddCnt > 1) {
1602 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1605 if (tmpContact.firstName[0] != '\0') {
1606 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1607 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1608 char *senderStr = NULL;
1609 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1610 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1617 noti_info->active_noti_button_num = 1;
1620 char *senderStr = NULL;
1621 if (subType == MSG_CB_SMS) {
1622 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1623 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1624 noti_info->active_noti_button_num = 1;
1625 } else if (subType == MSG_SYNCML_CP) {
1626 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1627 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1628 noti_info->active_noti_button_num = 1;
1629 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1630 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1631 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1632 noti_info->active_noti_button_num = 1;
1634 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1644 noti_info->active_subtype = subType;
1645 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1646 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1650 noti_info->senderCount = normalAddCnt;
1651 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
1652 msg_db_free(msg_handle, db_res);
1654 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1656 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1658 #ifdef MSG_NOTI_INTEGRATION
1659 snprintf(sqlQuery, sizeof(sqlQuery),
1666 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1667 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1668 "(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) "
1670 "WHERE A.CONV_ID=B.CONV_ID "
1671 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1672 "AND B.STORAGE_ID = %d "
1673 "ORDER BY B.DISPLAY_TIME DESC;",
1676 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1677 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1678 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1681 snprintf(sqlQuery, sizeof(sqlQuery),
1688 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1689 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1691 "WHERE A.CONV_ID=B.CONV_ID "
1692 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1693 "AND B.STORAGE_ID = %d "
1694 "ORDER BY B.DISPLAY_TIME DESC;",
1697 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1701 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1703 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1704 if (msg_err != MSG_SUCCESS) {
1705 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1710 smsUnreadCnt = atoi(db_res[col_cnt+6]);
1711 mmsUnreadCnt = atoi(db_res[col_cnt+7]);
1712 msgSize = atoi(db_res[col_cnt+8]);
1714 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1716 if (noti_info->count > 0) {
1717 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1719 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1721 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1723 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1725 if (mainType == MSG_MMS_TYPE) {
1726 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1727 if (noti_info->text[0] == '\0') {
1728 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1729 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1733 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1734 if (prefix_subject) {
1735 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1736 g_free(prefix_subject);
1738 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1742 int kb_msg_size = msgSize / 1024;
1743 if (kb_msg_size == 0 && msgSize > 0)
1745 else if (msgSize % 1024 >= 512)
1748 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1749 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1751 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1753 g_free(msg_size_string);
1754 g_free(msg_size_unit_kb);
1758 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1761 if (noti_info->active_text[0] == '\0')
1762 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1764 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1766 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1767 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1768 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1770 if (!isForInstantMessage) {
1771 if (noti_info->id > 0 && noti_info->count == 1) {
1772 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1773 if (noti_err != NOTIFICATION_ERROR_NONE) {
1774 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1778 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1779 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1782 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1783 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1784 MsgMgrInsertBadge(noti_info->count);
1785 MsgMgrSoundSetRepeatAlarm();
1788 MSG_MGR_DEBUG("No unread message.");
1789 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1791 msg_db_free(msg_handle, db_res);
1793 if (!isForInstantMessage) {
1794 /* No unread message. */
1795 if (noti_info->id > 0) {
1796 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1797 if (noti_err != NOTIFICATION_ERROR_NONE) {
1798 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1804 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1805 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1807 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1808 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1809 MsgMgrInsertBadge(0);
1810 MsgMgrSoundSetRepeatAlarm();
1816 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1817 msg_db_free(msg_handle, db_res);
1821 msg_db_free(msg_handle, db_res);
1825 #ifndef MSG_NOTI_INTEGRATION
1826 case MSG_MGR_NOTI_TYPE_CB: {
1827 char sqlQuery[MAX_QUERY_LEN+1];
1828 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1830 snprintf(sqlQuery, sizeof(sqlQuery),
1836 "WHERE A.CONV_ID=B.CONV_ID "
1837 "AND B.READ_STATUS=0 "
1838 "AND B.FOLDER_ID=%d "
1839 "AND B.STORAGE_ID = %d "
1840 "ORDER BY B.DISPLAY_TIME DESC;",
1841 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1845 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1846 return MSG_ERR_DB_PREPARE;
1848 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1849 MSG_ADDRESS_INFO_S addrInfo;
1850 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1852 if (dbhandler->columnText(0) != NULL)
1853 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1855 MSG_CONTACT_INFO_S tmpContact;
1856 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1858 MsgGetContactInfo(&addrInfo, &tmpContact);
1860 if (tmpContact.firstName[0] != '\0') {
1861 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1862 } else if (addrInfo.addressVal[0] == '\0') {
1863 char *senderStr = NULL;
1864 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1865 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1871 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1874 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1876 noti_info->time = (time_t)dbhandler->columnInt(1);
1878 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1880 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1882 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1884 MSG_MGR_DEBUG("No unread CB message.");
1885 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1887 dbhandler->finalizeQuery();
1889 if (!isForInstantMessage) {
1890 /* No unread message. */
1891 if (noti_info->id > 0) {
1892 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1893 if (noti_err != NOTIFICATION_ERROR_NONE) {
1894 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1900 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1901 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1903 return MSG_ERR_DB_STEP;
1906 dbhandler->finalizeQuery();
1908 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
1909 MSG_MGR_DEBUG("getTable is failed");
1910 dbhandler->freeTable();
1911 return MSG_ERR_DB_GETTABLE;
1914 dbhandler->freeTable();
1915 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
1918 case MSG_MGR_NOTI_TYPE_SIM: {
1919 char sqlQuery[MAX_QUERY_LEN+1];
1920 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1922 snprintf(sqlQuery, sizeof(sqlQuery),
1927 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
1929 "WHERE A.CONV_ID=B.CONV_ID "
1930 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1931 "AND B.STORAGE_ID = %d "
1932 "ORDER BY B.DISPLAY_TIME DESC;",
1934 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1938 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1940 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1941 return MSG_ERR_DB_PREPARE;
1943 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1944 noti_info->count = dbhandler->columnInt(4);
1946 if (noti_info->count > 0) {
1947 MSG_ADDRESS_INFO_S addrInfo;
1948 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1950 if (dbhandler->columnText(0) != NULL)
1951 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1953 MSG_CONTACT_INFO_S tmpContact;
1954 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1956 MsgGetContactInfo(&addrInfo, &tmpContact);
1958 if (tmpContact.firstName[0] != '\0') {
1959 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1960 } else if (addrInfo.addressVal[0] == '\0') {
1961 char *senderStr = NULL;
1962 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1963 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1969 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1972 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1974 noti_info->time = (time_t)dbhandler->columnInt(1);
1976 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1978 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1980 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
1982 MSG_MGR_DEBUG("No unread SIM message.");
1983 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1985 dbhandler->finalizeQuery();
1987 if (!isForInstantMessage) {
1988 /* No unread message. */
1989 if (noti_info->id > 0) {
1990 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1991 if (noti_err != NOTIFICATION_ERROR_NONE) {
1992 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1998 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1999 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
2002 return MSG_ERR_DB_STEP;
2005 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2006 dbhandler->finalizeQuery();
2007 return MSG_ERR_DB_STEP;
2010 dbhandler->finalizeQuery();
2014 case MSG_MGR_NOTI_TYPE_FAILED: {
2015 char sqlQuery[MAX_QUERY_LEN+1];
2016 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2018 snprintf(sqlQuery, sizeof(sqlQuery),
2025 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
2027 "WHERE A.CONV_ID=B.CONV_ID "
2028 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
2029 "AND B.STORAGE_ID = %d "
2030 "ORDER BY B.DISPLAY_TIME DESC;",
2031 MSG_NETWORK_SEND_FAIL,
2032 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
2036 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
2038 row_cnt = 0, col_cnt = 0;
2039 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2040 if (msg_err != MSG_SUCCESS) {
2041 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2046 noti_info->count = atoi(db_res[col_cnt+6]);
2048 if (noti_info->count > 0) {
2049 MSG_MGR_ADDRESS_INFO_S addrInfo = {0,};
2051 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2053 MSG_MGR_CONTACT_INFO_S tmpContact = {0,};
2055 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2057 if (tmpContact.firstName[0] != '\0') {
2058 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2059 } else if (addrInfo.addressVal[0] == '\0') {
2060 char *senderStr = NULL;
2061 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2062 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2068 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2071 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2073 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2075 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2077 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2079 if (mainType == MSG_TYPE_MMS)
2080 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2082 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2084 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2086 if (!isForInstantMessage) {
2087 if (noti_info->id > 0 && noti_info->count == 1) {
2088 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
2089 if (noti_err != NOTIFICATION_ERROR_NONE) {
2090 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2093 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2094 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2098 MSG_MGR_DEBUG("No sent failed message.");
2099 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2101 msg_db_free(msg_handle, db_res);
2103 if (!isForInstantMessage) {
2104 /* No unread message. */
2105 if (noti_info->id > 0) {
2106 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
2107 if (noti_err != NOTIFICATION_ERROR_NONE) {
2108 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2114 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2115 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2121 msg_db_free(msg_handle, db_res);
2125 msg_db_free(msg_handle, db_res);
2128 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2131 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2141 notification_h getHandle(int *noti_id)
2143 notification_h noti_h = NULL;
2146 MSG_MGR_DEBUG("Notification load");
2147 noti_h = notification_load(NULL, *noti_id);
2149 MSG_MGR_DEBUG("notification_load is failed.");
2152 if (noti_h == NULL) {
2153 MSG_MGR_DEBUG("Notification create");
2154 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2155 if (noti_h == NULL) {
2156 MSG_MGR_DEBUG("notification_create is failed.");
2167 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2173 switch (noti_type) {
2174 #ifdef MSG_NOTI_INTEGRATION
2175 case MSG_MGR_NOTI_TYPE_NORMAL:
2176 case MSG_MGR_NOTI_TYPE_SIM:
2177 case MSG_MGR_NOTI_TYPE_CB:
2178 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2181 case MSG_MGR_NOTI_TYPE_NORMAL:
2182 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2184 case MSG_MGR_NOTI_TYPE_SIM:
2185 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2187 case MSG_MGR_NOTI_TYPE_CB:
2188 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2191 case MSG_MGR_NOTI_TYPE_FAILED:
2192 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2194 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2195 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2196 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2197 vconf_get_int(keyName, ¬i_id);
2200 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2201 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2202 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2203 vconf_get_int(keyName, ¬i_id);
2206 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2207 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2210 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2214 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2222 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2228 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2230 switch (noti_type) {
2231 #ifdef MSG_NOTI_INTEGRATION
2232 case MSG_MGR_NOTI_TYPE_NORMAL:
2233 case MSG_MGR_NOTI_TYPE_SIM:
2234 case MSG_MGR_NOTI_TYPE_CB:
2235 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2238 case MSG_MGR_NOTI_TYPE_NORMAL:
2239 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2241 case MSG_MGR_NOTI_TYPE_SIM:
2242 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2244 case MSG_MGR_NOTI_TYPE_CB:
2245 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2248 case MSG_MGR_NOTI_TYPE_FAILED:
2249 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2251 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2252 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2253 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2254 err = vconf_set_int(keyName, noti_id);
2257 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2258 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2259 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2260 err = vconf_set_int(keyName, noti_id);
2263 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2264 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2267 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2272 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2278 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2283 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2284 noti_info->msg_id = msg_info->msgId;
2286 MSG_MGR_DEBUG("msg_info is NULL");
2290 noti_info->sim_idx = msg_info->sim_idx;
2292 createServiceHandle(¬i_info->svc_h);
2293 char keyName[MAX_VCONFKEY_NAME_LEN];
2295 switch (noti_info->type) {
2296 case MSG_MGR_NOTI_TYPE_VOICE_1:
2297 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2298 memset(keyName, 0x00, sizeof(keyName));
2299 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2300 vconf_get_int(keyName, ¬i_info->count);
2301 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2302 noti_info->time = msg_info->displayTime;
2304 memset(keyName, 0x00, sizeof(keyName));
2305 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2306 char *voiceNumber = vconf_get_str(keyName);
2307 memset(keyName, 0x00, sizeof(keyName));
2308 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2309 char *voiceAlphaId = vconf_get_str(keyName);
2310 char *dialNumber = NULL;
2312 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2314 if (voiceNumber && strlen(voiceNumber))
2315 dialNumber = voiceNumber;
2317 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2318 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2319 } else if (dialNumber && strlen(dialNumber) > 0) {
2320 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2323 if (dialNumber && strlen(dialNumber) > 0)
2324 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2326 if (noti_info->svc_h) {
2327 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2328 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2330 char slot_id[5] = {0, };
2331 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2332 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2335 if (voiceNumber) g_free(voiceNumber);
2336 if (voiceAlphaId) g_free(voiceAlphaId);
2339 case MSG_MGR_NOTI_TYPE_MWI:
2340 case MSG_MGR_NOTI_TYPE_CLASS0: {
2341 noti_info->count = 1;
2342 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2343 noti_info->time = msg_info->displayTime;
2345 if (msg_info->displayName[0] == '\0')
2346 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2348 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2350 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2352 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2354 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2355 if (noti_info->svc_h) {
2356 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2357 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2359 char slot_id[5] = {0, };
2360 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2361 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2365 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2366 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2367 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2371 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2372 noti_info->count = 1;
2373 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2374 noti_info->time = msg_info->displayTime;
2375 noti_info->extra_data = msg_info->networkStatus;
2377 /* contacts-service is not used for gear */
2378 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
2379 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
2380 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,};
2381 if (msg_info->addressVal) {
2382 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2383 if (_is_valid_email(msg_info->addressVal)) {
2384 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2386 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2390 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2391 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2393 #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
2395 if (contactInfo.firstName[0] == '\0')
2396 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2398 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2400 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2402 if (noti_info->msg_id > 0) {
2403 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2404 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2405 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2406 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2410 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2411 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2412 noti_info->count = 1;
2413 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2414 noti_info->time = msg_info->displayTime;
2416 /* contacts-service is not used for gear */
2417 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
2418 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
2419 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,};
2420 if (msg_info->addressVal) {
2421 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2422 if (_is_valid_email(msg_info->addressVal)) {
2423 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2425 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2429 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2430 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2432 #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
2433 if (contactInfo.firstName[0] == '\0')
2434 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2436 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2438 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2440 char sqlQuery[MAX_QUERY_LEN+1];
2441 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2443 int report_status_type;
2444 int report_status_value;
2446 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2447 report_status_type = MSG_REPORT_TYPE_READ;
2449 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2452 snprintf(sqlQuery, sizeof(sqlQuery),
2455 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';",
2456 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2458 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2460 char **db_res = NULL;
2461 int row_cnt = 0, col_cnt = 0;
2463 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2464 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2465 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2469 report_status_value = atoi(db_res[col_cnt]);
2471 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2473 msg_err = msg_db_free(msg_handle, db_res);
2474 if (msg_err != MSG_SUCCESS) {
2475 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2479 if (noti_info->msg_id > 0) {
2480 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2481 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2482 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2483 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2486 noti_info->extra_data = (unsigned char)report_status_value;
2490 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2494 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2499 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2503 createServiceHandle(¬i_info->svc_h);
2505 switch (noti_info->type) {
2506 case MSG_MGR_NOTI_TYPE_NORMAL: {
2507 if (noti_info->count > 1) {
2508 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2510 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2513 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2514 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2515 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2516 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2518 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
2520 if (noti_info->active_noti_button_num == 0)
2521 noti_info->active_noti_button_num = 3;
2524 case MSG_MGR_NOTI_TYPE_CB: {
2525 if (noti_info->count > 1) {
2526 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2528 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2531 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2532 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2533 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2535 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2536 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2538 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2540 noti_info->active_noti_button_num = 1;
2543 case MSG_MGR_NOTI_TYPE_SIM: {
2544 if (noti_info->count > 1) {
2545 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2547 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2550 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2551 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2552 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2554 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2555 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2557 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2559 if (noti_info->active_noti_button_num == 0)
2560 noti_info->active_noti_button_num = 3;
2563 case MSG_MGR_NOTI_TYPE_FAILED: {
2564 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2566 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2567 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2568 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2570 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2573 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2574 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2576 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2577 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2579 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2586 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2587 noti_info->active_noti_button_num = 0;
2593 void createServiceHandle(app_control_h *svc_h)
2595 int svc_err = APP_CONTROL_ERROR_NONE;
2597 svc_err = app_control_create(svc_h);
2599 if (svc_err != APP_CONTROL_ERROR_NONE)
2600 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2604 void setServiceAppId(app_control_h svc_h, const char* app_id)
2606 int svc_err = APP_CONTROL_ERROR_NONE;
2608 svc_err = app_control_set_app_id(svc_h, app_id);
2610 if (svc_err != APP_CONTROL_ERROR_NONE)
2611 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2615 void setServiceUri(app_control_h svc_h, const char* uri)
2617 int svc_err = APP_CONTROL_ERROR_NONE;
2619 svc_err = app_control_set_uri(svc_h, uri);
2621 if (svc_err != APP_CONTROL_ERROR_NONE)
2622 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2626 void setServiceOperation(app_control_h svc_h, const char* operation)
2628 int svc_err = APP_CONTROL_ERROR_NONE;
2630 svc_err = app_control_set_operation(svc_h, operation);
2632 if (svc_err != APP_CONTROL_ERROR_NONE)
2633 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2637 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2639 int svc_err = APP_CONTROL_ERROR_NONE;
2641 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2643 if (svc_err != APP_CONTROL_ERROR_NONE)
2644 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2648 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2650 int svc_err = APP_CONTROL_ERROR_NONE;
2653 memset(&tempId, 0x00, sizeof(tempId));
2654 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2656 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2658 if (svc_err != APP_CONTROL_ERROR_NONE)
2659 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2663 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2665 int svc_err = APP_CONTROL_ERROR_NONE;
2667 svc_err = app_control_set_app_id(svc_h, pkg_name);
2669 if (svc_err != APP_CONTROL_ERROR_NONE)
2670 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2674 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2676 int svc_err = APP_CONTROL_ERROR_NONE;
2678 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2680 if (svc_err != APP_CONTROL_ERROR_NONE)
2681 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2685 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2687 int noti_err = NOTIFICATION_ERROR_NONE;
2689 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2690 if (noti_err != NOTIFICATION_ERROR_NONE)
2691 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2695 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2697 int noti_err = NOTIFICATION_ERROR_NONE;
2699 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2701 if (noti_err != NOTIFICATION_ERROR_NONE)
2702 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2706 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2708 int noti_err = NOTIFICATION_ERROR_NONE;
2710 noti_err = notification_set_time_to_text(noti_h, type, time);
2712 if (noti_err != NOTIFICATION_ERROR_NONE)
2713 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2717 void setNotiTime(notification_h noti_h, time_t time)
2719 int noti_err = NOTIFICATION_ERROR_NONE;
2721 noti_err = notification_set_time(noti_h, time);
2723 if (noti_err != NOTIFICATION_ERROR_NONE)
2724 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2729 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2731 int noti_err = NOTIFICATION_ERROR_NONE;
2733 noti_err = notification_set_image(noti_h, type, image_path);
2735 if (noti_err != NOTIFICATION_ERROR_NONE)
2736 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2740 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2742 int noti_err = NOTIFICATION_ERROR_NONE;
2744 noti_err = notification_set_sound(noti_h, type, path);
2746 if (noti_err != NOTIFICATION_ERROR_NONE)
2747 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2751 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2753 int noti_err = NOTIFICATION_ERROR_NONE;
2755 noti_err = notification_set_vibration(noti_h, type, path);
2757 if (noti_err != NOTIFICATION_ERROR_NONE)
2758 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2762 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2764 int noti_err = NOTIFICATION_ERROR_NONE;
2766 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2768 if (noti_err != NOTIFICATION_ERROR_NONE)
2769 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2773 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2777 char *notiMsg = NULL;
2779 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2781 switch (noti_type) {
2782 case MSG_MGR_NOTI_TYPE_NORMAL:
2783 case MSG_MGR_NOTI_TYPE_SIM:
2784 case MSG_MGR_NOTI_TYPE_CB: {
2785 MSG_MGR_NOTI_INFO_S noti_info;
2786 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2788 noti_info.type = noti_type;
2789 int err = getLatestMsgInfo(¬i_info, true);
2792 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2793 if (noti_info.count == 1) {
2794 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2795 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2796 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2797 } else if (noti_info.count > 1) {
2798 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2800 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGE);
2801 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2802 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2803 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2808 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2812 case MSG_MGR_NOTI_TYPE_FAILED: {
2813 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2814 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2815 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2819 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2820 goto _END_OF_INSTANT_NOTI;
2824 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2825 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2827 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2828 MSG_MGR_DEBUG("Fail to notification_post");
2830 _END_OF_INSTANT_NOTI:
2832 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2833 MSG_MGR_DEBUG("Fail to notification_delete");
2840 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2841 MSG_MGR_DEBUG("Fail to notification_free");
2850 bool MsgMgrCheckNotificationSettingEnable()
2852 bool msg_noti_enabled = false;
2853 notification_system_setting_h system_setting = NULL;
2854 notification_setting_h setting = NULL;
2856 int err = NOTIFICATION_ERROR_NONE;
2858 err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
2860 if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
2861 MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2863 msg_noti_enabled = true;
2865 bool allow_to_notify = false;
2866 err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
2868 if (err != NOTIFICATION_ERROR_NONE) {
2869 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2873 if (allow_to_notify) {
2874 MSG_MGR_DEBUG("message notification is allowed");
2876 /* check do not disturb mode */
2877 err = notification_system_setting_load_system_setting(&system_setting);
2879 if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
2880 MSG_MGR_ERR("getting system setting is failed. err = %d", err);
2884 bool do_not_disturb_mode = false;
2885 err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
2887 if (err != NOTIFICATION_ERROR_NONE) {
2888 MSG_MGR_ERR("getting do not disturb setting is failed. err = %d", err);
2892 if (do_not_disturb_mode) {
2893 bool is_msg_excepted = false;
2894 err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
2895 if (err != NOTIFICATION_ERROR_NONE) {
2896 MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
2897 msg_noti_enabled = false;
2899 MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
2900 msg_noti_enabled = (is_msg_excepted) ? true : false;
2903 MSG_MGR_DEBUG("do not disturb mode is off");
2906 MSG_MGR_INFO("message notification is not allowed");
2907 msg_noti_enabled = false;
2913 notification_system_setting_free_system_setting(system_setting);
2916 notification_setting_free_notification(setting);
2918 return msg_noti_enabled;
2922 int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId)
2924 MSG_MGR_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
2925 MSG_MGR_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
2927 MsgMgrChangePmState();
2929 char *notiMsg = NULL;
2930 msg_mgr_active_notification_type_t active_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE;
2933 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
2934 MSG_MGR_DEBUG("notiMsg %s", notiMsg);
2936 if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
2937 g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
2938 g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
2939 if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
2940 notification_status_message_post(pTickerMsg);
2942 notification_status_message_post(notiMsg);
2945 /* Show ticker popup for sending failed msg. */
2946 active_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT;
2954 if (bPlayFeedback) {
2956 (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
2957 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, true, active_type);
2959 MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
2961 } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
2962 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
2964 MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
2967 MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
2975 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
2977 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
2979 int err = BADGE_ERROR_NONE;
2982 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
2984 if (err != BADGE_ERROR_NONE) {
2985 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
2991 err = badge_add(MSG_DEFAULT_APP_ID);
2992 if (err != BADGE_ERROR_NONE) {
2993 MSG_MGR_ERR("Fail to badge_add : %d", err);
2998 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
3000 if (err != BADGE_ERROR_NONE) {
3001 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
3009 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
3013 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3015 #ifndef MSG_NOTI_INTEGRATION
3016 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3017 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
3025 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
3031 struct tm repeat_tm;
3035 tmp_time += (RepeatTime*60);
3037 localtime_r(&tmp_time, &repeat_tm);
3039 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
3040 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
3044 g_alarmId = tmpAlarmId;
3045 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
3053 void MsgMgrSoundSetRepeatAlarm()
3055 int nRepeatValue = 0;
3056 long nRepeatTime = 0;
3058 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
3059 MSG_MGR_INFO("vconf_get_int() is failed");
3062 switch (nRepeatValue) {
3063 case MSG_ALERT_TONE_ONCE:
3066 case MSG_ALERT_TONE_2MINS:
3069 case MSG_ALERT_TONE_5MINS:
3072 case MSG_ALERT_TONE_10MINS:
3076 MSG_MGR_DEBUG("Invalid Repetition time");
3080 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
3082 if (nRepeatTime > 0) {
3083 if (g_alarmId > 0) {
3084 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
3085 MSG_MGR_FATAL("MsgAlarmRemove fail.");
3089 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
3096 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
3098 char *notiMsg = NULL;
3101 lang = vconf_get_str(VCONFKEY_LANGSET);
3103 setlocale(LC_MESSAGES, lang);
3105 bindtextdomain(pkg_name, locale_dir);
3107 notiMsg = dgettext(pkg_name, text);
3114 return g_strdup(notiMsg);