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_internal.h>
30 #include <badge_internal.h>
32 #include <notification_list.h>
33 #include <notification_text_domain.h>
34 #include <notification_internal.h>
35 #include <notification_status.h>
36 #include <package_manager.h>
37 #include <phone_number.h>
41 #include <msg_storage.h>
43 #include <msg-manager-alarm.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 /*==================================================================================================
102 ===================================================================================================*/
104 void MsgMgrInitReportNotiList();
105 void MsgRefreshNotiCb(void *data);
107 notification_h getHandle(int *noti_id);
109 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
110 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
112 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
113 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
114 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
115 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
117 int getAppIcon(const char *app_id, char **icon_path);
118 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
120 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
121 void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type);
122 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
123 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
124 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
125 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
126 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
127 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
128 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
130 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
132 bool isExistAddressInReportTable(const char *addr);
135 void createServiceHandle(app_control_h *svc_h);
136 void setServiceAppId(app_control_h svc_h, const char* app_id);
137 void setServiceUri(app_control_h svc_h, const char* uri);
138 void setServiceOperation(app_control_h svc_h, const char* operation);
139 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
140 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
141 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
142 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
144 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
145 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
146 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
147 void setNotiTime(notification_h noti_h, time_t time);
148 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
149 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
150 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
151 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
154 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
155 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
156 void MsgMgrSoundSetRepeatAlarm();
158 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
160 /*==================================================================================================
161 FUNCTION IMPLEMENTATION
162 ==================================================================================================*/
163 bool _is_valid_email(char *pAddress)
165 if (!pAddress || pAddress[0] == 0)
167 if (!strchr (pAddress, EMAIL_AT))
173 bool isExistAddressInReportTable(const char *addr)
175 char sqlQuery[MAX_QUERY_LEN+1];
176 char *normal_addr = NULL;
177 int rowCnt = 0, colCnt = 0;
178 char **db_res = NULL;
181 int ret = phone_number_get_normalized_number(addr, &normal_addr);
182 if (ret != PHONE_NUMBER_ERROR_NONE) {
183 MSG_MGR_ERR("phone_number_get_normalized_number() failed [%d]", ret);
187 memset(sqlQuery, 0x00, sizeof(sqlQuery));
188 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normal_addr);
190 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
191 if (msg_err != MSG_SUCCESS) {
192 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
197 msg_err = msg_db_free(msg_handle, db_res);
198 if (msg_err != MSG_SUCCESS) {
199 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
209 memset(sqlQuery, 0x00, sizeof(sqlQuery));
210 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normal_addr);
214 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
215 if (msg_err != MSG_SUCCESS) {
216 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
220 msg_err = msg_db_free(msg_handle, db_res);
221 if (msg_err != MSG_SUCCESS) {
222 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
233 void MsgMgrInitReportNotiList()
237 if (msg_report_notification_list) {
238 MSG_MGR_DEBUG("Report Noti List is already inited");
242 msg_report_notification_list = NULL;
244 notification_h noti = NULL;
245 notification_list_h noti_list = NULL;
246 notification_list_h head_noti_list = NULL;
247 int noti_err = NOTIFICATION_ERROR_NONE;
250 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
251 if (noti_err != NOTIFICATION_ERROR_NONE) {
252 MSG_MGR_DEBUG("notification_get_list() is failed!!");
256 head_noti_list = noti_list;
258 while (noti_list != NULL) {
259 noti = notification_list_get_data(noti_list);
261 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
262 memset(tempAddr, 0x00, sizeof(tempAddr));
264 noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &b);
265 if (noti_err != NOTIFICATION_ERROR_NONE) {
266 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
270 char *bundle_addr = NULL;
272 int ret = bundle_get_str(b, "address", &bundle_addr);
273 if (ret == BUNDLE_ERROR_NONE && bundle_addr != NULL) {
274 if (isExistAddressInReportTable(bundle_addr)) {
275 report_notification_s *info = new report_notification_s;
276 memset(info, 0x00, sizeof(report_notification_s));
278 notification_get_id(noti, NULL, &(info->priv_id));
279 snprintf(info->addressVal, sizeof(info->addressVal), "%s", bundle_addr);
281 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
282 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
286 noti_list = notification_list_get_next(noti_list);
290 notification_free_list(head_noti_list);
296 void MsgMgrInitNoti()
301 bool bNotiSvcReady = false;
303 bNotiSvcReady = notification_is_service_ready();
305 if (bNotiSvcReady == true) {
306 MSG_MGR_DEBUG("Notification server is available");
307 #ifndef MSG_NOTI_INTEGRATION
308 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
310 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
311 MsgMgrInitReportNotiList();
313 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
314 #ifndef MSG_NOTI_INTEGRATION
315 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
317 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
318 delNotiInfo->sim_idx = -1;
320 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
322 notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
329 void MsgRefreshNotiCb(void *data)
331 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
332 MsgMgrInitReportNotiList();
343 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
347 notification_h noti_h = NULL;
349 MSG_MGR_NOTI_INFO_S noti_info = {0, };
351 noti_info.type = noti_type;
352 noti_info.active_noti_button_num = 1;
354 createActiveInfoData(¬i_info, msg_info);
356 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
358 setActiveNotification(noti_h, ¬i_info);
360 clearInfoData(noti_h, ¬i_info);
367 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
370 notification_h noti_h = NULL;
371 int bNotification = 1;
372 /* bool bReplyPopup = false; */
374 MSG_MGR_NOTI_INFO_S noti_info = {0,};
375 noti_info.type = noti_type;
376 noti_info.id = getPrivId(noti_info.type, -1);
378 err = getLatestMsgInfo(¬i_info, false);
381 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
382 goto __END_OF_REFRESH_NOTI;
385 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
386 err = MsgMgrInsertInstantMessage(noti_type);
389 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
390 goto __END_OF_REFRESH_NOTI;
394 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
395 MSG_MGR_DEBUG("vconf_get_bool is failed.");
398 if (bNotification == 0) {
399 MSG_MGR_DEBUG("Msg Alert notification is off.");
400 goto __END_OF_REFRESH_NOTI;
403 createInfoData(¬i_info, active_type);
405 noti_h = getHandle(¬i_info.id);
407 if (noti_h == NULL) {
408 MSG_MGR_DEBUG("Notification handle is NULL");
409 err = MSG_ERR_NULL_POINTER;
410 goto __END_OF_REFRESH_NOTI;
413 setNotification(noti_h, ¬i_info, bFeedback);
415 __END_OF_REFRESH_NOTI :
416 clearInfoData(noti_h, ¬i_info);
422 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
426 notification_h noti_h = NULL;
428 report_notification_s *info = new report_notification_s;
429 memset(info, 0x00, sizeof(report_notification_s));
431 MSG_MGR_NOTI_INFO_S noti_info = {0,};
432 noti_info.type = noti_type;
434 createInfoData(¬i_info, msg_info);
436 noti_h = getHandle(¬i_info.id);
438 if (noti_h == NULL) {
439 MSG_MGR_DEBUG("Notification handle is NULL");
441 goto __END_OF_ADD_REPORT_NOTI;
444 setNotification(noti_h, ¬i_info, true);
446 info->priv_id = noti_info.id;
447 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
448 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
449 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
451 __END_OF_ADD_REPORT_NOTI :
452 clearInfoData(noti_h, ¬i_info);
458 int MsgMgrDeleteReportNotification(const char *addr)
462 notification_h noti_h = NULL;
463 int bNotification = 1;
465 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
466 MSG_MGR_DEBUG("vconf_get_bool is failed.");
469 if (bNotification == 0) {
470 MSG_MGR_DEBUG("Msg Alert notification is off.");
474 char* normalAddr = NULL;
475 unsigned int list_length = g_list_length(msg_report_notification_list);
476 bool isDelete = false;
478 MSG_MGR_DEBUG("list length [%d]", list_length);
480 if (list_length > 0) {
481 GList *iter = g_list_first(msg_report_notification_list);
483 while (iter != NULL) {
485 report_notification_s *info = (report_notification_s*)(iter->data);
487 MSG_MGR_DEBUG("info is NULL!");
491 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
493 noti_h = notification_load(NULL, info->priv_id);
494 if (noti_h == NULL) {
495 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
498 phone_number_get_normalized_number(info->addressVal, &normalAddr);
501 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
503 if (g_str_has_suffix(addr, normalAddr)) {
504 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
505 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
508 MSG_MGR_DEBUG("delete notification failed");
516 notification_free(noti_h);
520 iter = g_list_next(iter);
523 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
537 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
541 notification_h noti_h = NULL;
543 MSG_MGR_NOTI_INFO_S noti_info = {0, };
545 noti_info.type = noti_type;
547 createInfoData(¬i_info, msg_info);
549 /* check mwi or voicemail count is 0 then skip add notification */
550 if (noti_info.count == 0) {
551 MSG_MGR_DEBUG("Notification count is 0");
553 goto __END_OF_ADD_NOTI;
556 noti_h = getHandle(¬i_info.id);
558 if (noti_h == NULL) {
559 MSG_MGR_DEBUG("Notification handle is NULL");
561 goto __END_OF_ADD_NOTI;
564 setNotification(noti_h, ¬i_info, true);
567 clearInfoData(noti_h, ¬i_info);
573 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
579 #ifndef MSG_NOTI_INTEGRATION
580 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
583 #ifdef MSG_NOTI_INTEGRATION
584 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
586 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
588 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
590 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
592 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
594 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
597 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
599 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
603 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
605 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
611 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
615 int noti_err = NOTIFICATION_ERROR_NONE;
618 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
619 if (noti_err != NOTIFICATION_ERROR_NONE) {
620 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
624 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
625 if (noti_err != NOTIFICATION_ERROR_NONE) {
626 MSG_MGR_DEBUG("Fail to notification_set_led.");
629 /* set execute option */
630 bundle *bundle_data = NULL;
631 bundle *reply_msg = NULL;
633 app_control_to_bundle(noti_info->svc_h, &bundle_data);
635 if (bundle_data == NULL) {
636 MSG_MGR_DEBUG("bundle is NULL");
639 /* set execute option and property */
640 switch (noti_info->type) {
641 case MSG_MGR_NOTI_TYPE_NORMAL: {
642 if (noti_info->count > 1) {
643 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data);
644 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, NULL);
646 if (noti_info->svc_h) { /* overwrite bundle key "type" */
647 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
648 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
650 app_control_to_bundle(noti_info->svc_h, &reply_msg);
652 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
653 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, reply_msg);
656 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
659 case MSG_MGR_NOTI_TYPE_CB:
660 case MSG_MGR_NOTI_TYPE_SIM: {
661 if (noti_info->count > 1) {
662 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data);
664 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
667 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
670 case MSG_MGR_NOTI_TYPE_FAILED: {
671 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
672 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
675 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
676 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
679 case MSG_MGR_NOTI_TYPE_VOICE_1:
680 case MSG_MGR_NOTI_TYPE_VOICE_2:
681 case MSG_MGR_NOTI_TYPE_MWI:
682 case MSG_MGR_NOTI_TYPE_CLASS0:
683 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
684 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
685 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
686 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
690 MSG_MGR_DEBUG("No matching type for notification_set_execute_option() [%d]", noti_info->type);
695 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
696 if (noti_err != NOTIFICATION_ERROR_NONE) {
697 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
705 void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type)
709 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
714 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
718 char unreadMsgCntStr[10] = {0};
721 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
722 MSG_MGR_DEBUG("vconf_get_bool is failed.");
725 /* set title and content */
726 switch (noti_info->type) {
727 #ifdef MSG_NOTI_INTEGRATION
728 case MSG_MGR_NOTI_TYPE_NORMAL:
729 case MSG_MGR_NOTI_TYPE_CB:
730 case MSG_MGR_NOTI_TYPE_SIM: {
731 if (noti_info->count > 1) {
732 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
733 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
734 setNotiTime(noti_h, noti_info->time);
736 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
737 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
741 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
742 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
744 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
745 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
747 setNotiTime(noti_h, noti_info->time);
752 case MSG_MGR_NOTI_TYPE_NORMAL: {
753 if (noti_info->count > 1) {
754 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
755 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
756 setNotiTime(noti_h, noti_info->time);
758 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
759 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
762 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
763 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
765 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
766 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
768 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
769 setNotiTime(noti_h, noti_info->time);
773 case MSG_MGR_NOTI_TYPE_CB: {
774 if (noti_info->count > 1) {
775 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
776 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
777 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
778 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
779 setNotiTime(noti_h, noti_info->time);
782 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
783 setNotiTime(noti_h, noti_info->time);
786 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
787 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
789 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
790 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
795 case MSG_MGR_NOTI_TYPE_SIM: {
796 if (noti_info->count > 1) {
797 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
798 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
799 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
801 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
802 setNotiTime(noti_h, noti_info->time);
804 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
805 setNotiTime(noti_h, noti_info->time);
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, "SIM card Message", SIM_CARD_MESSAGE);
812 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
818 case MSG_MGR_NOTI_TYPE_FAILED: {
819 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
820 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
821 if (noti_info->count > 1) {
822 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
823 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
825 setNotiTime(noti_h, noti_info->time);
828 case MSG_MGR_NOTI_TYPE_VOICE_1:
829 case MSG_MGR_NOTI_TYPE_VOICE_2: {
830 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
831 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
832 setNotiTime(noti_h, noti_info->time);
834 if (noti_info->count == 1) {
835 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
836 } else if (noti_info->count > 1) {
837 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
838 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
840 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
844 case MSG_MGR_NOTI_TYPE_MWI: {
845 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
846 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
847 setNotiTime(noti_h, noti_info->time);
850 case MSG_MGR_NOTI_TYPE_CLASS0: {
851 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
852 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
853 setNotiTime(noti_h, noti_info->time);
856 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
857 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
858 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
860 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
861 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
862 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
863 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
865 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
868 setNotiTime(noti_h, noti_info->time);
871 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
872 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
873 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
875 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
876 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
877 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
879 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
880 /* notification free */
883 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
886 setNotiTime(noti_h, noti_info->time);
889 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
890 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
891 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
893 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED)
894 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
895 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED)
896 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE);
897 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED)
898 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
899 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED)
900 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE);
901 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE)
902 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE);
903 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED)
904 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL);
905 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE)
906 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE);
907 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR)
908 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL);
909 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
911 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_NONE) {
912 /* notification free */
916 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
918 setNotiTime(noti_h, noti_info->time);
921 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
922 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
923 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
927 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
934 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
938 switch (noti_info->type) {
939 #ifdef MSG_NOTI_INTEGRATION
940 case MSG_MGR_NOTI_TYPE_NORMAL:
941 case MSG_MGR_NOTI_TYPE_CB:
942 case MSG_MGR_NOTI_TYPE_SIM: {
943 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
944 if (noti_info->count > 1 && noti_info->senderCount > 1) {
945 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
946 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
947 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
949 if (noti_info->active_subtype == MSG_CB_SMS) {
950 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
951 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
952 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
953 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
954 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
955 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
956 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
958 if (noti_info->imagePath[0] != '\0') {
959 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
960 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
962 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
963 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
966 char *msg_icon_path = NULL;
967 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
968 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
969 g_free(msg_icon_path);
971 MSG_MGR_ERR("fail to get message-app icon");
978 case MSG_MGR_NOTI_TYPE_NORMAL: {
979 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
980 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
982 if (noti_info->count > 1) {
983 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
985 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
989 case MSG_MGR_NOTI_TYPE_CB: {
990 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
991 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
994 case MSG_MGR_NOTI_TYPE_SIM: {
995 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
996 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
1000 case MSG_MGR_NOTI_TYPE_FAILED: {
1001 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
1002 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SMS_SENDING_FAILED_ICON_PATH);
1005 case MSG_MGR_NOTI_TYPE_VOICE_1:
1006 case MSG_MGR_NOTI_TYPE_VOICE_2:
1007 case MSG_MGR_NOTI_TYPE_MWI: {
1008 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
1009 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
1012 case MSG_MGR_NOTI_TYPE_CLASS0:
1013 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1015 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1016 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1017 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1019 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1020 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1021 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1023 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1024 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1025 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1027 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1028 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1029 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1032 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1039 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1043 int noti_err = NOTIFICATION_ERROR_NONE;
1046 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1047 if (noti_err != NOTIFICATION_ERROR_NONE) {
1048 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1052 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1053 if (noti_err != NOTIFICATION_ERROR_NONE) {
1054 MSG_MGR_DEBUG("Fail to notification_set_led.");
1058 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1059 if (noti_err != NOTIFICATION_ERROR_NONE) {
1060 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1067 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1071 switch (noti_info->type) {
1072 case MSG_MGR_NOTI_TYPE_NORMAL:
1073 case MSG_MGR_NOTI_TYPE_SIM:
1074 case MSG_MGR_NOTI_TYPE_CB: {
1075 if (noti_info->active_subject[0] == '\0') {
1076 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1077 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1079 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1080 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1081 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1085 case MSG_MGR_NOTI_TYPE_CLASS0: {
1086 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1087 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1091 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1099 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1103 switch (noti_info->type) {
1104 case MSG_MGR_NOTI_TYPE_NORMAL:
1105 case MSG_MGR_NOTI_TYPE_SIM: {
1106 switch (noti_info->active_subtype) {
1108 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1110 case MSG_WAP_SI_SMS:
1111 case MSG_WAP_SL_SMS:
1112 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1115 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1118 if (noti_info->imagePath[0] != '\0')
1119 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1121 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1123 char *msg_icon_path = NULL;
1124 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1125 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1126 g_free(msg_icon_path);
1128 MSG_MGR_ERR("fail to get message-app icon");
1136 case MSG_MGR_NOTI_TYPE_CB: {
1137 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1140 case MSG_MGR_NOTI_TYPE_CLASS0:
1141 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1144 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1152 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1156 MSG_MGR_ADDRESS_INFO_S addrInfo = {0,};
1157 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
1159 if (addressVal != NULL) {
1160 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1161 /* Get Contact Info */
1162 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1163 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1166 MSG_MGR_DEBUG("addressVal is NULL.");
1169 char *msg_tone_file_path = NULL;
1171 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1173 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1175 bool bPlaySound = false;
1176 bool bPlayVibration = false;
1177 bool bOnCall = false;
1179 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1182 if (msg_tone_file_path)
1183 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1186 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1187 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1189 int ringtoneType = tmpVal;
1190 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1191 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1193 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1196 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1199 if (bPlayVibration) {
1200 if (contactInfo.vibrationPath[0] == '\0')
1201 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1203 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1205 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1208 if (msg_tone_file_path)
1209 delete [] msg_tone_file_path;
1215 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1219 int noti_err = NOTIFICATION_ERROR_NONE;
1221 setActiveProperty(noti_h, noti_info);
1223 setTextDomain(noti_h, noti_info->type);
1225 setActiveText(noti_h, noti_info);
1227 setActiveIcon(noti_h, noti_info);
1229 if (noti_info->active_noti_button_num > 1) {
1230 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1231 if (noti_info->active_noti_svc_h[0]) {
1232 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1233 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1235 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1237 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1238 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1239 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1240 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1243 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1244 if (noti_info->active_noti_svc_h[1]) {
1245 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1247 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1248 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1249 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1251 char slot_id[5] = {0, };
1252 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1253 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1257 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1258 if (noti_info->active_noti_svc_h[2]) {
1259 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1261 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1262 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1263 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1264 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
1266 char slot_id[5] = {0, };
1267 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1268 addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
1271 if (noti_info->active_noti_button_num > 1) {
1272 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1273 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1274 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1276 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1277 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1278 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1280 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1282 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1285 noti_err = notification_post(noti_h);
1286 if (noti_err != NOTIFICATION_ERROR_NONE) {
1287 MSG_MGR_DEBUG("Fail to notification_post");
1294 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1298 int noti_err = NOTIFICATION_ERROR_NONE;
1300 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1302 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1303 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1304 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1306 setActiveNotification(active_noti_h, noti_info);
1308 notification_free(active_noti_h);
1309 active_noti_h = NULL;
1312 setProperty(noti_h, noti_info);
1314 setTextDomain(noti_h, noti_info->type);
1316 setText(noti_h, noti_info);
1318 setIcon(noti_h, noti_info);
1321 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1322 setSoundAndVibration(noti_h, noti_info->number, true);
1324 setSoundAndVibration(noti_h, noti_info->number, false);
1327 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1328 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1331 if (noti_info->id > 0) {
1332 MSG_MGR_DEBUG("Notification update");
1333 noti_err = notification_update(noti_h);
1334 if (noti_err != NOTIFICATION_ERROR_NONE) {
1335 MSG_MGR_DEBUG("Fail to notification_update");
1338 MSG_MGR_DEBUG("Notification insert");
1339 noti_err = notification_insert(noti_h, ¬i_info->id);
1340 if (noti_err != NOTIFICATION_ERROR_NONE) {
1341 MSG_MGR_DEBUG("Fail to notification_insert");
1344 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1351 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1356 MSG_MGR_DEBUG("msg_info is NULL");
1360 noti_info->msg_id = msg_info->msgId;
1361 noti_info->sim_idx = msg_info->sim_idx;
1363 switch (noti_info->type) {
1364 case MSG_MGR_NOTI_TYPE_NORMAL: {
1365 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1366 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1373 case MSG_MGR_NOTI_TYPE_CLASS0: {
1374 if (msg_info->displayName[0] == '\0')
1375 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1377 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1379 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1383 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1391 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1396 notification_free(noti_h);
1400 if (noti_info->svc_h) {
1401 app_control_destroy(noti_info->svc_h);
1402 noti_info->svc_h = NULL;
1405 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1406 if (noti_info->active_noti_svc_h[i]) {
1407 app_control_destroy(noti_info->active_noti_svc_h[i]);
1408 noti_info->active_noti_svc_h[i] = NULL;
1416 int getAppIcon(const char *app_id, char **icon_path)
1420 package_info_h pkg_info_h = NULL;
1421 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1424 if (app_id == NULL) {
1425 MSG_MGR_ERR("app id is NULL");
1427 goto END_OF_GET_APP_ICON;
1430 pkg_err = package_info_create(app_id, &pkg_info_h);
1431 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1432 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1434 goto END_OF_GET_APP_ICON;
1437 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1438 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1439 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1442 if (icon_path == NULL) {
1443 MSG_MGR_WARN("icon path is NULL");
1448 END_OF_GET_APP_ICON:
1450 pkg_err = package_info_destroy(pkg_info_h);
1451 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1452 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1464 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1469 msg_error_t msg_err = MSG_SUCCESS;
1470 char **db_res = NULL;
1471 int row_cnt = 0, col_cnt = 0;
1473 switch (noti_info->type) {
1474 case MSG_MGR_NOTI_TYPE_NORMAL:
1475 #ifdef MSG_NOTI_INTEGRATION
1476 case MSG_MGR_NOTI_TYPE_CB:
1477 case MSG_MGR_NOTI_TYPE_SIM:
1480 int smsUnreadCnt = 0;
1481 int mmsUnreadCnt = 0;
1483 char sqlQuery[MAX_QUERY_LEN +1];
1484 unsigned char mainType;
1485 unsigned char subType;
1488 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1489 #ifdef MSG_NOTI_INTEGRATION
1490 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1494 "WHERE A.CONV_ID=B.CONV_ID "
1495 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1496 "AND B.STORAGE_ID = %d "
1497 "GROUP BY A.ADDRESS_VAL "
1498 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1499 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1500 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1503 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1507 "WHERE A.CONV_ID=B.CONV_ID "
1508 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1509 "AND B.STORAGE_ID = %d "
1510 "GROUP BY A.ADDRESS_VAL "
1511 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1512 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1516 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1518 row_cnt = 0, col_cnt = 0;
1519 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1520 if (msg_err != MSG_SUCCESS) {
1521 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1525 /* contacts-service is not used for gear */
1526 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
1527 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1528 int normalAddCnt = 0;
1529 int index = col_cnt;
1531 for (int i = 1; i <= row_cnt; i++) {
1532 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1534 char *address = db_res[index++];
1537 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1538 if (_is_valid_email(address)) {
1539 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1541 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1544 subType = atoi(db_res[index++]);
1546 MSG_MGR_CONTACT_INFO_S tmpContact;
1547 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1549 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1552 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1555 if (normalAddCnt > 1) {
1556 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1559 if (tmpContact.firstName[0] != '\0') {
1560 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1561 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1562 char *senderStr = NULL;
1563 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1564 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1571 noti_info->active_noti_button_num = 1;
1574 char *senderStr = NULL;
1575 if (subType == MSG_CB_SMS) {
1576 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1577 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1578 noti_info->active_noti_button_num = 1;
1579 } else if (subType == MSG_SYNCML_CP) {
1580 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1581 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1582 noti_info->active_noti_button_num = 1;
1583 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1584 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1585 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1586 noti_info->active_noti_button_num = 1;
1588 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1598 noti_info->active_subtype = subType;
1599 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1600 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1604 noti_info->senderCount = normalAddCnt;
1605 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
1606 msg_db_free(msg_handle, db_res);
1608 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1610 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1612 #ifdef MSG_NOTI_INTEGRATION
1613 snprintf(sqlQuery, sizeof(sqlQuery),
1620 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1621 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1622 "(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) "
1624 "WHERE A.CONV_ID=B.CONV_ID "
1625 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1626 "AND B.STORAGE_ID = %d "
1627 "ORDER BY B.DISPLAY_TIME DESC;",
1630 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1631 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1632 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1635 snprintf(sqlQuery, sizeof(sqlQuery),
1642 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1643 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1645 "WHERE A.CONV_ID=B.CONV_ID "
1646 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1647 "AND B.STORAGE_ID = %d "
1648 "ORDER BY B.DISPLAY_TIME DESC;",
1651 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1655 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1657 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1658 if (msg_err != MSG_SUCCESS) {
1659 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1664 smsUnreadCnt = atoi(db_res[col_cnt+6]);
1665 mmsUnreadCnt = atoi(db_res[col_cnt+7]);
1666 msgSize = atoi(db_res[col_cnt+8]);
1668 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1670 if (noti_info->count > 0) {
1671 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1673 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1675 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1677 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1679 if (mainType == MSG_MMS_TYPE) {
1680 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1681 if (noti_info->text[0] == '\0') {
1682 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1683 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1687 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1688 if (prefix_subject) {
1689 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1690 g_free(prefix_subject);
1692 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1696 int kb_msg_size = msgSize / 1024;
1697 if (kb_msg_size == 0 && msgSize > 0)
1699 else if (msgSize % 1024 >= 512)
1702 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1703 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1705 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1707 g_free(msg_size_string);
1708 g_free(msg_size_unit_kb);
1712 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1715 if (noti_info->active_text[0] == '\0')
1716 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1718 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1720 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1721 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1722 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1724 if (!isForInstantMessage) {
1725 if (noti_info->id > 0 && noti_info->count == 1) {
1726 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1727 if (noti_err != NOTIFICATION_ERROR_NONE) {
1728 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1732 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1733 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1736 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1737 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1738 MsgMgrInsertBadge(noti_info->count);
1739 MsgMgrSoundSetRepeatAlarm();
1742 MSG_MGR_DEBUG("No unread message.");
1743 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1745 msg_db_free(msg_handle, db_res);
1747 if (!isForInstantMessage) {
1748 /* No unread message. */
1749 if (noti_info->id > 0) {
1750 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1751 if (noti_err != NOTIFICATION_ERROR_NONE) {
1752 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1758 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1759 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1761 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1762 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1763 MsgMgrInsertBadge(0);
1764 MsgMgrSoundSetRepeatAlarm();
1770 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1771 msg_db_free(msg_handle, db_res);
1775 msg_db_free(msg_handle, db_res);
1779 #ifndef MSG_NOTI_INTEGRATION
1780 case MSG_MGR_NOTI_TYPE_CB: {
1781 char sqlQuery[MAX_QUERY_LEN+1];
1782 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1784 snprintf(sqlQuery, sizeof(sqlQuery),
1790 "WHERE A.CONV_ID=B.CONV_ID "
1791 "AND B.READ_STATUS=0 "
1792 "AND B.FOLDER_ID=%d "
1793 "AND B.STORAGE_ID = %d "
1794 "ORDER BY B.DISPLAY_TIME DESC;",
1795 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1799 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1800 return MSG_ERR_DB_PREPARE;
1802 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1803 MSG_ADDRESS_INFO_S addrInfo;
1804 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1806 if (dbhandler->columnText(0) != NULL)
1807 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1809 MSG_CONTACT_INFO_S tmpContact;
1810 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1812 MsgGetContactInfo(&addrInfo, &tmpContact);
1814 if (tmpContact.firstName[0] != '\0') {
1815 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1816 } else if (addrInfo.addressVal[0] == '\0') {
1817 char *senderStr = NULL;
1818 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1819 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1825 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1828 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1830 noti_info->time = (time_t)dbhandler->columnInt(1);
1832 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1834 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1836 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1838 MSG_MGR_DEBUG("No unread CB message.");
1839 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1841 dbhandler->finalizeQuery();
1843 if (!isForInstantMessage) {
1844 /* No unread message. */
1845 if (noti_info->id > 0) {
1846 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1847 if (noti_err != NOTIFICATION_ERROR_NONE) {
1848 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1854 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1855 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1857 return MSG_ERR_DB_STEP;
1860 dbhandler->finalizeQuery();
1862 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
1863 MSG_MGR_DEBUG("getTable is failed");
1864 dbhandler->freeTable();
1865 return MSG_ERR_DB_GETTABLE;
1868 dbhandler->freeTable();
1869 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
1872 case MSG_MGR_NOTI_TYPE_SIM: {
1873 char sqlQuery[MAX_QUERY_LEN+1];
1874 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1876 snprintf(sqlQuery, sizeof(sqlQuery),
1881 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
1883 "WHERE A.CONV_ID=B.CONV_ID "
1884 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1885 "AND B.STORAGE_ID = %d "
1886 "ORDER BY B.DISPLAY_TIME DESC;",
1888 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1892 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1894 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1895 return MSG_ERR_DB_PREPARE;
1897 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1898 noti_info->count = dbhandler->columnInt(4);
1900 if (noti_info->count > 0) {
1901 MSG_ADDRESS_INFO_S addrInfo;
1902 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1904 if (dbhandler->columnText(0) != NULL)
1905 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1907 MSG_CONTACT_INFO_S tmpContact;
1908 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1910 MsgGetContactInfo(&addrInfo, &tmpContact);
1912 if (tmpContact.firstName[0] != '\0') {
1913 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1914 } else if (addrInfo.addressVal[0] == '\0') {
1915 char *senderStr = NULL;
1916 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1917 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1923 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1926 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1928 noti_info->time = (time_t)dbhandler->columnInt(1);
1930 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1932 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1934 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
1936 MSG_MGR_DEBUG("No unread SIM message.");
1937 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1939 dbhandler->finalizeQuery();
1941 if (!isForInstantMessage) {
1942 /* No unread message. */
1943 if (noti_info->id > 0) {
1944 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1945 if (noti_err != NOTIFICATION_ERROR_NONE) {
1946 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1952 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1953 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
1956 return MSG_ERR_DB_STEP;
1959 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1960 dbhandler->finalizeQuery();
1961 return MSG_ERR_DB_STEP;
1964 dbhandler->finalizeQuery();
1968 case MSG_MGR_NOTI_TYPE_FAILED: {
1969 char sqlQuery[MAX_QUERY_LEN+1];
1970 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1972 snprintf(sqlQuery, sizeof(sqlQuery),
1979 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
1981 "WHERE A.CONV_ID=B.CONV_ID "
1982 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1983 "AND B.STORAGE_ID = %d "
1984 "ORDER BY B.DISPLAY_TIME DESC;",
1985 MSG_NETWORK_SEND_FAIL,
1986 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1990 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1992 row_cnt = 0, col_cnt = 0;
1993 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1994 if (msg_err != MSG_SUCCESS) {
1995 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2000 noti_info->count = atoi(db_res[col_cnt+6]);
2002 if (noti_info->count > 0) {
2003 MSG_MGR_ADDRESS_INFO_S addrInfo = {0,};
2005 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
2007 MSG_MGR_CONTACT_INFO_S tmpContact = {0,};
2009 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
2011 if (tmpContact.firstName[0] != '\0') {
2012 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
2013 } else if (addrInfo.addressVal[0] == '\0') {
2014 char *senderStr = NULL;
2015 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2016 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2022 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2025 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2027 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2029 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2031 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2033 if (mainType == MSG_TYPE_MMS)
2034 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2036 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2038 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2040 if (!isForInstantMessage) {
2041 if (noti_info->id > 0 && noti_info->count == 1) {
2042 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
2043 if (noti_err != NOTIFICATION_ERROR_NONE) {
2044 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2047 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2048 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2052 MSG_MGR_DEBUG("No sent failed message.");
2053 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2055 msg_db_free(msg_handle, db_res);
2057 if (!isForInstantMessage) {
2058 /* No unread message. */
2059 if (noti_info->id > 0) {
2060 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
2061 if (noti_err != NOTIFICATION_ERROR_NONE) {
2062 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2068 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2069 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2075 msg_db_free(msg_handle, db_res);
2079 msg_db_free(msg_handle, db_res);
2082 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2085 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2095 notification_h getHandle(int *noti_id)
2097 notification_h noti_h = NULL;
2100 MSG_MGR_DEBUG("Notification load");
2101 noti_h = notification_load(NULL, *noti_id);
2103 MSG_MGR_DEBUG("notification_load is failed.");
2106 if (noti_h == NULL) {
2107 MSG_MGR_DEBUG("Notification create");
2108 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2109 if (noti_h == NULL) {
2110 MSG_MGR_DEBUG("notification_create is failed.");
2121 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2127 switch (noti_type) {
2128 #ifdef MSG_NOTI_INTEGRATION
2129 case MSG_MGR_NOTI_TYPE_NORMAL:
2130 case MSG_MGR_NOTI_TYPE_SIM:
2131 case MSG_MGR_NOTI_TYPE_CB:
2132 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2135 case MSG_MGR_NOTI_TYPE_NORMAL:
2136 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2138 case MSG_MGR_NOTI_TYPE_SIM:
2139 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2141 case MSG_MGR_NOTI_TYPE_CB:
2142 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2145 case MSG_MGR_NOTI_TYPE_FAILED:
2146 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2148 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2149 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2150 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2151 vconf_get_int(keyName, ¬i_id);
2154 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2155 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2156 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2157 vconf_get_int(keyName, ¬i_id);
2160 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2161 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2164 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2168 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2176 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2182 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2184 switch (noti_type) {
2185 #ifdef MSG_NOTI_INTEGRATION
2186 case MSG_MGR_NOTI_TYPE_NORMAL:
2187 case MSG_MGR_NOTI_TYPE_SIM:
2188 case MSG_MGR_NOTI_TYPE_CB:
2189 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2192 case MSG_MGR_NOTI_TYPE_NORMAL:
2193 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2195 case MSG_MGR_NOTI_TYPE_SIM:
2196 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2198 case MSG_MGR_NOTI_TYPE_CB:
2199 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2202 case MSG_MGR_NOTI_TYPE_FAILED:
2203 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2205 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2206 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2207 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2208 err = vconf_set_int(keyName, noti_id);
2211 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2212 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2213 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2214 err = vconf_set_int(keyName, noti_id);
2217 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2218 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2221 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2226 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2232 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2237 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2238 noti_info->msg_id = msg_info->msgId;
2240 MSG_MGR_DEBUG("msg_info is NULL");
2244 noti_info->sim_idx = msg_info->sim_idx;
2246 createServiceHandle(¬i_info->svc_h);
2247 char keyName[MAX_VCONFKEY_NAME_LEN];
2249 switch (noti_info->type) {
2250 case MSG_MGR_NOTI_TYPE_VOICE_1:
2251 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2252 memset(keyName, 0x00, sizeof(keyName));
2253 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2254 vconf_get_int(keyName, ¬i_info->count);
2255 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2256 noti_info->time = msg_info->displayTime;
2258 memset(keyName, 0x00, sizeof(keyName));
2259 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2260 char *voiceNumber = vconf_get_str(keyName);
2261 memset(keyName, 0x00, sizeof(keyName));
2262 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2263 char *voiceAlphaId = vconf_get_str(keyName);
2264 char *dialNumber = NULL;
2266 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2268 if (voiceNumber && strlen(voiceNumber))
2269 dialNumber = voiceNumber;
2271 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2272 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2273 } else if (dialNumber && strlen(dialNumber) > 0) {
2274 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2277 if (dialNumber && strlen(dialNumber) > 0)
2278 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2280 if (noti_info->svc_h) {
2281 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2282 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2284 char slot_id[5] = {0, };
2285 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2286 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2289 if (voiceNumber) g_free(voiceNumber);
2290 if (voiceAlphaId) g_free(voiceAlphaId);
2293 case MSG_MGR_NOTI_TYPE_MWI:
2294 case MSG_MGR_NOTI_TYPE_CLASS0: {
2295 noti_info->count = 1;
2296 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2297 noti_info->time = msg_info->displayTime;
2299 if (msg_info->displayName[0] == '\0')
2300 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2302 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2304 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2306 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2308 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2309 if (noti_info->svc_h) {
2310 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2311 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2313 char slot_id[5] = {0, };
2314 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2315 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2319 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2320 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2321 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2325 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2326 noti_info->count = 1;
2327 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2328 noti_info->time = msg_info->displayTime;
2329 noti_info->extra_data = msg_info->networkStatus;
2331 /* contacts-service is not used for gear */
2332 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
2333 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
2334 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,};
2335 if (msg_info->addressVal) {
2336 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2337 if (_is_valid_email(msg_info->addressVal)) {
2338 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2340 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2344 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2345 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2347 #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
2349 if (contactInfo.firstName[0] == '\0')
2350 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2352 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2354 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2356 if (noti_info->msg_id > 0) {
2357 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2358 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2359 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2360 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2364 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2365 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2366 noti_info->count = 1;
2367 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2368 noti_info->time = msg_info->displayTime;
2370 /* contacts-service is not used for gear */
2371 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
2372 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
2373 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,};
2374 if (msg_info->addressVal) {
2375 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2376 if (_is_valid_email(msg_info->addressVal)) {
2377 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2379 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2383 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2384 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2386 #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
2387 if (contactInfo.firstName[0] == '\0')
2388 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2390 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2392 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2394 char sqlQuery[MAX_QUERY_LEN+1];
2395 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2397 int report_status_type;
2398 int report_status_value;
2400 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2401 report_status_type = MSG_REPORT_TYPE_READ;
2403 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2406 char *normalNum = NULL;
2407 if (msg_info->addressVal[0] != '\0')
2408 phone_number_get_normalized_number(msg_info->addressVal, &normalNum);
2410 snprintf(sqlQuery, sizeof(sqlQuery),
2413 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';",
2414 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, normalNum);
2416 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2421 char **db_res = NULL;
2422 int row_cnt = 0, col_cnt = 0;
2424 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2425 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2426 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2430 report_status_value = atoi(db_res[col_cnt]);
2432 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2434 msg_err = msg_db_free(msg_handle, db_res);
2435 if (msg_err != MSG_SUCCESS) {
2436 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2440 if (noti_info->msg_id > 0) {
2441 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2442 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2443 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2444 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2447 noti_info->extra_data = (unsigned char)report_status_value;
2451 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2455 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2460 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2464 createServiceHandle(¬i_info->svc_h);
2466 switch (noti_info->type) {
2467 case MSG_MGR_NOTI_TYPE_NORMAL: {
2468 if (noti_info->count > 1) {
2469 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2471 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2474 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2475 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2476 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2477 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2479 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
2481 if (noti_info->active_noti_button_num == 0)
2482 noti_info->active_noti_button_num = 3;
2485 case MSG_MGR_NOTI_TYPE_CB: {
2486 if (noti_info->count > 1) {
2487 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2489 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2492 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2493 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2494 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2496 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2497 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2499 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2501 noti_info->active_noti_button_num = 1;
2504 case MSG_MGR_NOTI_TYPE_SIM: {
2505 if (noti_info->count > 1) {
2506 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2508 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2511 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2512 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2513 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2515 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2516 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2518 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2520 if (noti_info->active_noti_button_num == 0)
2521 noti_info->active_noti_button_num = 3;
2524 case MSG_MGR_NOTI_TYPE_FAILED: {
2525 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2527 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2528 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2529 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2531 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2534 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2535 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2537 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2538 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2540 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2547 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2548 noti_info->active_noti_button_num = 0;
2554 void createServiceHandle(app_control_h *svc_h)
2556 int svc_err = APP_CONTROL_ERROR_NONE;
2558 svc_err = app_control_create(svc_h);
2560 if (svc_err != APP_CONTROL_ERROR_NONE)
2561 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2565 void setServiceAppId(app_control_h svc_h, const char* app_id)
2567 int svc_err = APP_CONTROL_ERROR_NONE;
2569 svc_err = app_control_set_app_id(svc_h, app_id);
2571 if (svc_err != APP_CONTROL_ERROR_NONE)
2572 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2576 void setServiceUri(app_control_h svc_h, const char* uri)
2578 int svc_err = APP_CONTROL_ERROR_NONE;
2580 svc_err = app_control_set_uri(svc_h, uri);
2582 if (svc_err != APP_CONTROL_ERROR_NONE)
2583 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2587 void setServiceOperation(app_control_h svc_h, const char* operation)
2589 int svc_err = APP_CONTROL_ERROR_NONE;
2591 svc_err = app_control_set_operation(svc_h, operation);
2593 if (svc_err != APP_CONTROL_ERROR_NONE)
2594 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2598 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2600 int svc_err = APP_CONTROL_ERROR_NONE;
2602 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2604 if (svc_err != APP_CONTROL_ERROR_NONE)
2605 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2609 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2611 int svc_err = APP_CONTROL_ERROR_NONE;
2614 memset(&tempId, 0x00, sizeof(tempId));
2615 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2617 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2619 if (svc_err != APP_CONTROL_ERROR_NONE)
2620 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2624 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2626 int svc_err = APP_CONTROL_ERROR_NONE;
2628 svc_err = app_control_set_app_id(svc_h, pkg_name);
2630 if (svc_err != APP_CONTROL_ERROR_NONE)
2631 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2635 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2637 int svc_err = APP_CONTROL_ERROR_NONE;
2639 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2641 if (svc_err != APP_CONTROL_ERROR_NONE)
2642 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2646 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2648 int noti_err = NOTIFICATION_ERROR_NONE;
2650 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2651 if (noti_err != NOTIFICATION_ERROR_NONE)
2652 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2656 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2658 int noti_err = NOTIFICATION_ERROR_NONE;
2660 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2662 if (noti_err != NOTIFICATION_ERROR_NONE)
2663 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2667 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2669 int noti_err = NOTIFICATION_ERROR_NONE;
2671 noti_err = notification_set_time_to_text(noti_h, type, time);
2673 if (noti_err != NOTIFICATION_ERROR_NONE)
2674 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2678 void setNotiTime(notification_h noti_h, time_t time)
2680 int noti_err = NOTIFICATION_ERROR_NONE;
2682 noti_err = notification_set_time(noti_h, time);
2684 if (noti_err != NOTIFICATION_ERROR_NONE)
2685 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2690 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2692 int noti_err = NOTIFICATION_ERROR_NONE;
2694 noti_err = notification_set_image(noti_h, type, image_path);
2696 if (noti_err != NOTIFICATION_ERROR_NONE)
2697 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2701 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2703 int noti_err = NOTIFICATION_ERROR_NONE;
2705 noti_err = notification_set_sound(noti_h, type, path);
2707 if (noti_err != NOTIFICATION_ERROR_NONE)
2708 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2712 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2714 int noti_err = NOTIFICATION_ERROR_NONE;
2716 noti_err = notification_set_vibration(noti_h, type, path);
2718 if (noti_err != NOTIFICATION_ERROR_NONE)
2719 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2723 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2725 int noti_err = NOTIFICATION_ERROR_NONE;
2727 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2729 if (noti_err != NOTIFICATION_ERROR_NONE)
2730 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2734 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2738 char *notiMsg = NULL;
2740 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2742 switch (noti_type) {
2743 case MSG_MGR_NOTI_TYPE_NORMAL:
2744 case MSG_MGR_NOTI_TYPE_SIM:
2745 case MSG_MGR_NOTI_TYPE_CB: {
2746 MSG_MGR_NOTI_INFO_S noti_info;
2747 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2749 noti_info.type = noti_type;
2750 int err = getLatestMsgInfo(¬i_info, true);
2753 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2754 if (noti_info.count == 1) {
2755 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2756 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2757 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2758 } else if (noti_info.count > 1) {
2759 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2761 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGE);
2762 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2763 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2764 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2769 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2773 case MSG_MGR_NOTI_TYPE_FAILED: {
2774 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2775 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2776 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2780 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2781 goto _END_OF_INSTANT_NOTI;
2785 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2786 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2788 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2789 MSG_MGR_DEBUG("Fail to notification_post");
2791 _END_OF_INSTANT_NOTI:
2793 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2794 MSG_MGR_DEBUG("Fail to notification_delete");
2801 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2802 MSG_MGR_DEBUG("Fail to notification_free");
2811 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
2813 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
2815 int err = BADGE_ERROR_NONE;
2818 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
2820 if (err != BADGE_ERROR_NONE) {
2821 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
2827 err = badge_add(MSG_DEFAULT_APP_ID);
2828 if (err != BADGE_ERROR_NONE) {
2829 MSG_MGR_ERR("Fail to badge_add : %d", err);
2834 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
2836 if (err != BADGE_ERROR_NONE) {
2837 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
2845 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
2849 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2851 #ifndef MSG_NOTI_INTEGRATION
2852 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2853 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2861 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
2867 struct tm repeat_tm;
2871 tmp_time += (RepeatTime*60);
2873 localtime_r(&tmp_time, &repeat_tm);
2875 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
2876 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
2880 g_alarmId = tmpAlarmId;
2881 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
2889 void MsgMgrSoundSetRepeatAlarm()
2891 int nRepeatValue = 0;
2892 long nRepeatTime = 0;
2894 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
2895 MSG_MGR_INFO("vconf_get_int() is failed");
2898 switch (nRepeatValue) {
2899 case MSG_ALERT_TONE_ONCE:
2902 case MSG_ALERT_TONE_2MINS:
2905 case MSG_ALERT_TONE_5MINS:
2908 case MSG_ALERT_TONE_10MINS:
2912 MSG_MGR_DEBUG("Invalid Repetition time");
2916 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
2918 if (nRepeatTime > 0) {
2919 if (g_alarmId > 0) {
2920 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
2921 MSG_MGR_FATAL("MsgAlarmRemove fail.");
2925 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
2932 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
2934 char *notiMsg = NULL;
2937 lang = vconf_get_str(VCONFKEY_LANGSET);
2939 setlocale(LC_MESSAGES, lang);
2941 bindtextdomain(pkg_name, locale_dir);
2943 notiMsg = dgettext(pkg_name, text);
2950 return g_strdup(notiMsg);