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>
40 #include <msg_storage.h>
42 #include <msg-manager-alarm.h>
43 #include <msg-manager-contact.h>
44 #include <msg-manager-debug.h>
45 #include <msg-manager-notification.h>
46 #include <msg-manager-sound.h>
51 /*==================================================================================================
53 ==================================================================================================*/
55 static GList *msg_report_notification_list = NULL;
56 static bool is_init = false;
57 extern msg_handle_t msg_handle;
61 /*==================================================================================================
63 ==================================================================================================*/
64 typedef struct _report_notification_s
67 char addressVal[MAX_ADDRESS_VAL_LEN+1];
68 } report_notification_s;
71 typedef struct _msg_mgr_noti_info_s
73 msg_mgr_notification_type_t type;
79 char sender[MSG_NOTI_TEXT_LEN_S+1];
80 char text[MSG_NOTI_TEXT_LEN+1];
81 char number[MSG_NOTI_TEXT_LEN_S+1];
82 char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
85 app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
86 msg_message_id_t msg_id;
87 unsigned char extra_data;
89 int active_noti_button_num;
91 int active_media_size;
92 unsigned char active_subtype; /**< to distinguish cb, push message */
93 char active_sender[MSG_NOTI_TEXT_LEN_S+1];
94 char active_subject[MSG_NOTI_TEXT_LEN_S+1];
95 char active_text[MSG_NOTI_TEXT_LEN+1];
96 } MSG_MGR_NOTI_INFO_S;
99 /*==================================================================================================
101 ===================================================================================================*/
103 void MsgMgrInitReportNotiList();
104 void MsgRefreshNotiCb(void *data);
106 notification_h getHandle(int *noti_id);
108 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx);
109 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx);
111 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */
112 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti);
113 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info);
114 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
116 int getAppIcon(const char *app_id, char **icon_path);
117 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
119 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
120 void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type);
121 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
122 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
123 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
124 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
125 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
126 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
127 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
129 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
131 bool isExistAddressInReportTable(const char *addr);
134 void createServiceHandle(app_control_h *svc_h);
135 void setServiceAppId(app_control_h svc_h, const char* app_id);
136 void setServiceUri(app_control_h svc_h, const char* uri);
137 void setServiceOperation(app_control_h svc_h, const char* operation);
138 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
139 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
140 void setServicePackageName(app_control_h svc_h, const char* pkg_name);
141 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data);
143 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir);
144 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key);
145 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time);
146 void setNotiTime(notification_h noti_h, time_t time);
147 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
148 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
149 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
150 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
153 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId);
154 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime);
155 void MsgMgrSoundSetRepeatAlarm();
157 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text);
159 /*==================================================================================================
160 FUNCTION IMPLEMENTATION
161 ==================================================================================================*/
162 bool _is_valid_email(char *pAddress)
164 if (!pAddress || pAddress[0] == 0)
166 if (!strchr (pAddress, EMAIL_AT))
172 bool isExistAddressInReportTable(const char *addr)
174 char sqlQuery[MAX_QUERY_LEN+1];
175 int rowCnt = 0, colCnt = 0;
176 char **db_res = NULL;
179 char *normal_addr = msg_mgr_normalize_number((char *)addr);
181 memset(sqlQuery, 0x00, sizeof(sqlQuery));
182 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normal_addr);
184 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
185 if (msg_err != MSG_SUCCESS) {
186 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
190 msg_err = msg_db_free(msg_handle, db_res);
191 if (msg_err != MSG_SUCCESS) {
192 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
199 memset(sqlQuery, 0x00, sizeof(sqlQuery));
200 snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normal_addr);
202 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
203 if (msg_err != MSG_SUCCESS) {
204 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
208 msg_err = msg_db_free(msg_handle, db_res);
209 if (msg_err != MSG_SUCCESS) {
210 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
221 void MsgMgrInitReportNotiList()
225 if (msg_report_notification_list) {
226 MSG_MGR_DEBUG("Report Noti List is already inited");
230 msg_report_notification_list = NULL;
232 notification_h noti = NULL;
233 notification_list_h noti_list = NULL;
234 notification_list_h head_noti_list = NULL;
235 int noti_err = NOTIFICATION_ERROR_NONE;
238 noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
239 if (noti_err != NOTIFICATION_ERROR_NONE) {
240 MSG_MGR_DEBUG("notification_get_list() is failed!!");
244 head_noti_list = noti_list;
246 while (noti_list != NULL) {
247 noti = notification_list_get_data(noti_list);
249 char tempAddr[MAX_ADDRESS_VAL_LEN+1];
250 memset(tempAddr, 0x00, sizeof(tempAddr));
252 noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &b);
253 if (noti_err != NOTIFICATION_ERROR_NONE) {
254 MSG_MGR_DEBUG("notification_get_excute_option() failed!!");
258 char *bundle_addr = NULL;
260 int ret = bundle_get_str(b, "address", &bundle_addr);
261 if (ret == BUNDLE_ERROR_NONE && bundle_addr != NULL) {
262 if (isExistAddressInReportTable(bundle_addr)) {
263 report_notification_s *info = new report_notification_s;
264 memset(info, 0x00, sizeof(report_notification_s));
266 notification_get_id(noti, NULL, &(info->priv_id));
267 snprintf(info->addressVal, sizeof(info->addressVal), "%s", bundle_addr);
269 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
270 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
274 noti_list = notification_list_get_next(noti_list);
278 notification_free_list(head_noti_list);
284 void MsgMgrInitNoti()
289 bool bNotiSvcReady = false;
291 bNotiSvcReady = notification_is_service_ready();
293 if (bNotiSvcReady == true) {
294 MSG_MGR_DEBUG("Notification server is available");
295 #ifndef MSG_NOTI_INTEGRATION
296 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
298 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */
299 MsgMgrInitReportNotiList();
301 MSG_MGR_DEBUG("Notification server is not available. Init is defered");
302 #ifndef MSG_NOTI_INTEGRATION
303 MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S));
305 delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM;
306 delNotiInfo->sim_idx = -1;
308 notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
310 notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
317 void MsgRefreshNotiCb(void *data)
319 MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
320 MsgMgrInitReportNotiList();
331 int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
335 notification_h noti_h = NULL;
337 MSG_MGR_NOTI_INFO_S noti_info = {0, };
339 noti_info.type = noti_type;
340 noti_info.active_noti_button_num = 1;
342 createActiveInfoData(¬i_info, msg_info);
344 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
346 setActiveNotification(noti_h, ¬i_info);
348 clearInfoData(noti_h, ¬i_info);
355 int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type)
358 notification_h noti_h = NULL;
359 int bNotification = 1;
360 /* bool bReplyPopup = false; */
362 MSG_MGR_NOTI_INFO_S noti_info = {0,};
363 noti_info.type = noti_type;
364 noti_info.id = getPrivId(noti_info.type, -1);
366 err = getLatestMsgInfo(¬i_info, false);
369 MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err);
370 goto __END_OF_REFRESH_NOTI;
373 if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) {
374 err = MsgMgrInsertInstantMessage(noti_type);
377 MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err);
378 goto __END_OF_REFRESH_NOTI;
382 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
383 MSG_MGR_DEBUG("vconf_get_bool is failed.");
386 if (bNotification == 0) {
387 MSG_MGR_DEBUG("Msg Alert notification is off.");
388 goto __END_OF_REFRESH_NOTI;
391 createInfoData(¬i_info, active_type);
393 noti_h = getHandle(¬i_info.id);
395 if (noti_h == NULL) {
396 MSG_MGR_DEBUG("Notification handle is NULL");
397 err = MSG_ERR_NULL_POINTER;
398 goto __END_OF_REFRESH_NOTI;
401 setNotification(noti_h, ¬i_info, bFeedback);
403 __END_OF_REFRESH_NOTI :
404 clearInfoData(noti_h, ¬i_info);
410 int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
414 notification_h noti_h = NULL;
416 report_notification_s *info = new report_notification_s;
417 memset(info, 0x00, sizeof(report_notification_s));
419 MSG_MGR_NOTI_INFO_S noti_info = {0,};
420 noti_info.type = noti_type;
422 createInfoData(¬i_info, msg_info);
424 noti_h = getHandle(¬i_info.id);
426 if (noti_h == NULL) {
427 MSG_MGR_DEBUG("Notification handle is NULL");
429 goto __END_OF_ADD_REPORT_NOTI;
432 setNotification(noti_h, ¬i_info, true);
434 info->priv_id = noti_info.id;
435 snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
436 msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
437 MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
439 __END_OF_ADD_REPORT_NOTI :
440 clearInfoData(noti_h, ¬i_info);
446 int MsgMgrDeleteReportNotification(const char *addr)
450 notification_h noti_h = NULL;
451 int bNotification = 1;
453 if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) {
454 MSG_MGR_DEBUG("vconf_get_bool is failed.");
457 if (bNotification == 0) {
458 MSG_MGR_DEBUG("Msg Alert notification is off.");
462 char* normalAddr = NULL;
463 unsigned int list_length = g_list_length(msg_report_notification_list);
464 bool isDelete = false;
466 MSG_MGR_DEBUG("list length [%d]", list_length);
468 if (list_length > 0) {
469 GList *iter = g_list_first(msg_report_notification_list);
471 while (iter != NULL) {
473 report_notification_s *info = (report_notification_s*)(iter->data);
475 MSG_MGR_DEBUG("info is NULL!");
479 MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
481 noti_h = notification_load(NULL, info->priv_id);
482 if (noti_h == NULL) {
483 MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
486 normalAddr = msg_mgr_normalize_number(info->addressVal);
489 MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr);
491 if (g_str_has_suffix(addr, normalAddr)) {
492 if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
493 MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
496 MSG_MGR_DEBUG("delete notification failed");
501 notification_free(noti_h);
505 iter = g_list_next(iter);
508 msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
522 int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info)
526 notification_h noti_h = NULL;
528 MSG_MGR_NOTI_INFO_S noti_info = {0, };
530 noti_info.type = noti_type;
532 createInfoData(¬i_info, msg_info);
534 /* check mwi or voicemail count is 0 then skip add notification */
535 if (noti_info.count == 0) {
536 MSG_MGR_DEBUG("Notification count is 0");
538 goto __END_OF_ADD_NOTI;
541 noti_h = getHandle(¬i_info.id);
543 if (noti_h == NULL) {
544 MSG_MGR_DEBUG("Notification handle is NULL");
546 goto __END_OF_ADD_NOTI;
549 setNotification(noti_h, ¬i_info, true);
552 clearInfoData(noti_h, ¬i_info);
558 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
564 #ifndef MSG_NOTI_INTEGRATION
565 MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM);
568 #ifdef MSG_NOTI_INTEGRATION
569 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
571 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
573 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type);
575 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err);
577 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type);
579 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err);
582 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type);
584 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err);
588 err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type);
590 MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err);
596 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
600 int noti_err = NOTIFICATION_ERROR_NONE;
603 noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
604 if (noti_err != NOTIFICATION_ERROR_NONE) {
605 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
609 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
610 if (noti_err != NOTIFICATION_ERROR_NONE) {
611 MSG_MGR_DEBUG("Fail to notification_set_led.");
614 /* set execute option */
615 bundle *bundle_data = NULL;
616 bundle *reply_msg = NULL;
618 app_control_to_bundle(noti_info->svc_h, &bundle_data);
620 if (bundle_data == NULL) {
621 MSG_MGR_DEBUG("bundle is NULL");
624 /* set execute option and property */
625 switch (noti_info->type) {
626 case MSG_MGR_NOTI_TYPE_NORMAL: {
627 if (noti_info->count > 1) {
628 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data);
629 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, NULL);
631 if (noti_info->svc_h) { /* overwrite bundle key "type" */
632 /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
633 addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
635 app_control_to_bundle(noti_info->svc_h, &reply_msg);
637 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
638 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, reply_msg);
641 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
644 case MSG_MGR_NOTI_TYPE_CB:
645 case MSG_MGR_NOTI_TYPE_SIM: {
646 if (noti_info->count > 1) {
647 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data);
649 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
652 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
655 case MSG_MGR_NOTI_TYPE_FAILED: {
656 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
657 notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
660 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
661 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
664 case MSG_MGR_NOTI_TYPE_VOICE_1:
665 case MSG_MGR_NOTI_TYPE_VOICE_2:
666 case MSG_MGR_NOTI_TYPE_MWI:
667 case MSG_MGR_NOTI_TYPE_CLASS0:
668 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
669 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
670 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
671 notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
675 MSG_MGR_DEBUG("No matching type for notification_set_execute_option() [%d]", noti_info->type);
680 noti_err = notification_set_display_applist(noti_h, noti_info->applist);
681 if (noti_err != NOTIFICATION_ERROR_NONE) {
682 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
690 void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type)
694 setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
699 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
703 char unreadMsgCntStr[10] = {0};
706 if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) {
707 MSG_MGR_DEBUG("vconf_get_bool is failed.");
710 /* set title and content */
711 switch (noti_info->type) {
712 #ifdef MSG_NOTI_INTEGRATION
713 case MSG_MGR_NOTI_TYPE_NORMAL:
714 case MSG_MGR_NOTI_TYPE_CB:
715 case MSG_MGR_NOTI_TYPE_SIM: {
716 if (noti_info->count > 1) {
717 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
718 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
719 setNotiTime(noti_h, noti_info->time);
721 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
722 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
726 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
727 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
729 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
730 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
732 setNotiTime(noti_h, noti_info->time);
737 case MSG_MGR_NOTI_TYPE_NORMAL: {
738 if (noti_info->count > 1) {
739 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
740 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
741 setNotiTime(noti_h, noti_info->time);
743 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
744 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
747 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
748 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
750 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
751 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
753 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
754 setNotiTime(noti_h, noti_info->time);
758 case MSG_MGR_NOTI_TYPE_CB: {
759 if (noti_info->count > 1) {
760 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
761 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
762 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
763 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
764 setNotiTime(noti_h, noti_info->time);
767 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
768 setNotiTime(noti_h, noti_info->time);
771 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
772 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
774 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
775 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
780 case MSG_MGR_NOTI_TYPE_SIM: {
781 if (noti_info->count > 1) {
782 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
783 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
784 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
786 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
787 setNotiTime(noti_h, noti_info->time);
789 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
790 setNotiTime(noti_h, noti_info->time);
793 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
794 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
796 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
797 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
803 case MSG_MGR_NOTI_TYPE_FAILED: {
804 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
805 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
806 if (noti_info->count > 1) {
807 snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
808 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
810 setNotiTime(noti_h, noti_info->time);
813 case MSG_MGR_NOTI_TYPE_VOICE_1:
814 case MSG_MGR_NOTI_TYPE_VOICE_2: {
815 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
816 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
817 setNotiTime(noti_h, noti_info->time);
819 if (noti_info->count == 1) {
820 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
821 } else 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 MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
829 case MSG_MGR_NOTI_TYPE_MWI: {
830 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
831 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
832 setNotiTime(noti_h, noti_info->time);
835 case MSG_MGR_NOTI_TYPE_CLASS0: {
836 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
837 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
838 setNotiTime(noti_h, noti_info->time);
841 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
842 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
843 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
845 if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
846 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
847 } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
848 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
850 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
853 setNotiTime(noti_h, noti_info->time);
856 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
857 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
858 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
860 if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
861 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
862 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
864 } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
865 /* notification free */
868 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
871 setNotiTime(noti_h, noti_info->time);
874 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
875 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
876 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
878 if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED)
879 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
880 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED)
881 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE);
882 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED)
883 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
884 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED)
885 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE);
886 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE)
887 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE);
888 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED)
889 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL);
890 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE)
891 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE);
892 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR)
893 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL);
894 /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
896 else if (noti_info->extra_data == MSG_DELIVERY_REPORT_NONE) {
897 /* notification free */
901 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
903 setNotiTime(noti_h, noti_info->time);
906 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
907 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
908 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
912 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
919 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
923 switch (noti_info->type) {
924 #ifdef MSG_NOTI_INTEGRATION
925 case MSG_MGR_NOTI_TYPE_NORMAL:
926 case MSG_MGR_NOTI_TYPE_CB:
927 case MSG_MGR_NOTI_TYPE_SIM: {
928 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
929 if (noti_info->count > 1 && noti_info->senderCount > 1) {
930 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
931 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
932 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
934 if (noti_info->active_subtype == MSG_CB_SMS) {
935 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
936 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
937 } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
938 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
939 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
940 } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
941 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
943 if (noti_info->imagePath[0] != '\0') {
944 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
945 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
947 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
948 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
951 char *msg_icon_path = NULL;
952 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
953 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
954 g_free(msg_icon_path);
956 MSG_MGR_ERR("fail to get message-app icon");
963 case MSG_MGR_NOTI_TYPE_NORMAL: {
964 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
965 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
967 if (noti_info->count > 1) {
968 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
970 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
974 case MSG_MGR_NOTI_TYPE_CB: {
975 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
976 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
979 case MSG_MGR_NOTI_TYPE_SIM: {
980 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
981 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
985 case MSG_MGR_NOTI_TYPE_FAILED: {
986 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
987 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SMS_SENDING_FAILED_ICON_PATH);
990 case MSG_MGR_NOTI_TYPE_VOICE_1:
991 case MSG_MGR_NOTI_TYPE_VOICE_2:
992 case MSG_MGR_NOTI_TYPE_MWI: {
993 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
994 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
997 case MSG_MGR_NOTI_TYPE_CLASS0:
998 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1000 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT:
1001 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1002 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1004 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
1005 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1006 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1008 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
1009 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1010 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1012 case MSG_MGR_NOTI_TYPE_SIM_FULL:
1013 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1014 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
1017 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1024 void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1028 int noti_err = NOTIFICATION_ERROR_NONE;
1031 noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1032 if (noti_err != NOTIFICATION_ERROR_NONE) {
1033 MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err);
1037 noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
1038 if (noti_err != NOTIFICATION_ERROR_NONE) {
1039 MSG_MGR_DEBUG("Fail to notification_set_led.");
1043 noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
1044 if (noti_err != NOTIFICATION_ERROR_NONE) {
1045 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
1052 void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1056 switch (noti_info->type) {
1057 case MSG_MGR_NOTI_TYPE_NORMAL:
1058 case MSG_MGR_NOTI_TYPE_SIM:
1059 case MSG_MGR_NOTI_TYPE_CB: {
1060 if (noti_info->active_subject[0] == '\0') {
1061 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1062 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1064 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
1065 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
1066 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
1070 case MSG_MGR_NOTI_TYPE_CLASS0: {
1071 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
1072 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
1076 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1084 void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1088 switch (noti_info->type) {
1089 case MSG_MGR_NOTI_TYPE_NORMAL:
1090 case MSG_MGR_NOTI_TYPE_SIM: {
1091 switch (noti_info->active_subtype) {
1093 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1095 case MSG_WAP_SI_SMS:
1096 case MSG_WAP_SL_SMS:
1097 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
1100 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
1103 if (noti_info->imagePath[0] != '\0')
1104 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
1106 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
1108 char *msg_icon_path = NULL;
1109 if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
1110 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
1111 g_free(msg_icon_path);
1113 MSG_MGR_ERR("fail to get message-app icon");
1121 case MSG_MGR_NOTI_TYPE_CB: {
1122 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
1125 case MSG_MGR_NOTI_TYPE_CLASS0:
1126 setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
1129 MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
1137 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
1141 MSG_MGR_ADDRESS_INFO_S addrInfo = {0,};
1142 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
1144 if (addressVal != NULL) {
1145 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
1146 /* Get Contact Info */
1147 if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) {
1148 MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail.");
1151 MSG_MGR_DEBUG("addressVal is NULL.");
1154 char *msg_tone_file_path = NULL;
1156 MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
1158 MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
1160 bool bPlaySound = false;
1161 bool bPlayVibration = false;
1162 bool bOnCall = false;
1164 MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
1167 if (msg_tone_file_path)
1168 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
1171 if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
1172 MSG_MGR_INFO("MsgSettingGetInt() is failed");
1174 int ringtoneType = tmpVal;
1175 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
1176 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1178 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
1181 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1184 if (bPlayVibration) {
1185 if (contactInfo.vibrationPath[0] == '\0')
1186 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
1188 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
1190 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1193 if (msg_tone_file_path)
1194 delete [] msg_tone_file_path;
1200 void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1204 int noti_err = NOTIFICATION_ERROR_NONE;
1206 setActiveProperty(noti_h, noti_info);
1208 setTextDomain(noti_h, noti_info->type);
1210 setActiveText(noti_h, noti_info);
1212 setActiveIcon(noti_h, noti_info);
1214 if (noti_info->active_noti_button_num > 1) {
1215 createServiceHandle(¬i_info->active_noti_svc_h[0]);
1216 if (noti_info->active_noti_svc_h[0]) {
1217 setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
1218 setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
1220 MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
1222 char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, };
1223 snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
1224 MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number);
1225 setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
1228 createServiceHandle(¬i_info->active_noti_svc_h[1]);
1229 if (noti_info->active_noti_svc_h[1]) {
1230 setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
1232 MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
1233 addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
1234 addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
1236 char slot_id[5] = {0, };
1237 snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
1238 addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
1242 createServiceHandle(¬i_info->active_noti_svc_h[2]);
1243 if (noti_info->active_noti_svc_h[2]) {
1244 setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
1246 MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
1247 addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
1248 addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
1249 addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
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[2], "slot_id", slot_id);
1256 if (noti_info->active_noti_button_num > 1) {
1257 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
1258 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
1259 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
1261 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
1262 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
1263 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
1265 setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
1267 setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
1270 noti_err = notification_post(noti_h);
1271 if (noti_err != NOTIFICATION_ERROR_NONE) {
1272 MSG_MGR_DEBUG("Fail to notification_post");
1279 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback)
1283 int noti_err = NOTIFICATION_ERROR_NONE;
1285 MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
1287 if (bFeedback && noti_info->active_noti_button_num > 0 &&
1288 ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
1289 notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
1291 setActiveNotification(active_noti_h, noti_info);
1293 notification_free(active_noti_h);
1294 active_noti_h = NULL;
1297 setProperty(noti_h, noti_info);
1299 setTextDomain(noti_h, noti_info->type);
1301 setText(noti_h, noti_info);
1303 setIcon(noti_h, noti_info);
1306 if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2)
1307 setSoundAndVibration(noti_h, noti_info->number, true);
1309 setSoundAndVibration(noti_h, noti_info->number, false);
1312 setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
1313 setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
1316 if (noti_info->id > 0) {
1317 MSG_MGR_DEBUG("Notification update");
1318 noti_err = notification_update(noti_h);
1319 if (noti_err != NOTIFICATION_ERROR_NONE) {
1320 MSG_MGR_DEBUG("Fail to notification_update");
1323 MSG_MGR_DEBUG("Notification insert");
1324 noti_err = notification_insert(noti_h, ¬i_info->id);
1325 if (noti_err != NOTIFICATION_ERROR_NONE) {
1326 MSG_MGR_DEBUG("Fail to notification_insert");
1329 updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
1336 void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
1341 MSG_MGR_DEBUG("msg_info is NULL");
1345 noti_info->msg_id = msg_info->msgId;
1346 noti_info->sim_idx = msg_info->sim_idx;
1348 switch (noti_info->type) {
1349 case MSG_MGR_NOTI_TYPE_NORMAL: {
1350 char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1351 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
1358 case MSG_MGR_NOTI_TYPE_CLASS0: {
1359 if (msg_info->displayName[0] == '\0')
1360 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal);
1362 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName);
1364 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
1368 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
1376 void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
1381 notification_free(noti_h);
1385 if (noti_info->svc_h) {
1386 app_control_destroy(noti_info->svc_h);
1387 noti_info->svc_h = NULL;
1390 for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
1391 if (noti_info->active_noti_svc_h[i]) {
1392 app_control_destroy(noti_info->active_noti_svc_h[i]);
1393 noti_info->active_noti_svc_h[i] = NULL;
1401 int getAppIcon(const char *app_id, char **icon_path)
1405 package_info_h pkg_info_h = NULL;
1406 int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
1409 if (app_id == NULL) {
1410 MSG_MGR_ERR("app id is NULL");
1412 goto END_OF_GET_APP_ICON;
1415 pkg_err = package_info_create(app_id, &pkg_info_h);
1416 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1417 MSG_MGR_ERR("package_info_create failed (%d)", pkg_err);
1419 goto END_OF_GET_APP_ICON;
1422 pkg_err = package_info_get_icon(pkg_info_h, icon_path);
1423 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1424 MSG_MGR_ERR("package_info_get_icon failed (%d)", pkg_err);
1427 if (icon_path == NULL) {
1428 MSG_MGR_WARN("icon path is NULL");
1433 END_OF_GET_APP_ICON:
1435 pkg_err = package_info_destroy(pkg_info_h);
1436 if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
1437 MSG_MGR_ERR("package_info_destroy failed (%d)", pkg_err);
1449 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
1454 msg_error_t msg_err = MSG_SUCCESS;
1455 char **db_res = NULL;
1456 int row_cnt = 0, col_cnt = 0;
1458 switch (noti_info->type) {
1459 case MSG_MGR_NOTI_TYPE_NORMAL:
1460 #ifdef MSG_NOTI_INTEGRATION
1461 case MSG_MGR_NOTI_TYPE_CB:
1462 case MSG_MGR_NOTI_TYPE_SIM:
1465 int smsUnreadCnt = 0;
1466 int mmsUnreadCnt = 0;
1468 char sqlQuery[MAX_QUERY_LEN +1];
1469 unsigned char mainType;
1470 unsigned char subType;
1473 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1474 #ifdef MSG_NOTI_INTEGRATION
1475 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1479 "WHERE A.CONV_ID=B.CONV_ID "
1480 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1481 "AND B.STORAGE_ID = %d "
1482 "GROUP BY A.ADDRESS_VAL "
1483 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1484 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1485 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1488 snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT "
1492 "WHERE A.CONV_ID=B.CONV_ID "
1493 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1494 "AND B.STORAGE_ID = %d "
1495 "GROUP BY A.ADDRESS_VAL "
1496 "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
1497 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1501 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1503 row_cnt = 0, col_cnt = 0;
1504 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1505 if (msg_err != MSG_SUCCESS) {
1506 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1510 /* contacts-service is not used for gear */
1511 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
1512 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo;
1513 int normalAddCnt = 0;
1514 int index = col_cnt;
1516 for (int i = 1; i <= row_cnt; i++) {
1517 memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S));
1519 char *address = db_res[index++];
1522 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
1523 if (_is_valid_email(address)) {
1524 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
1526 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
1529 subType = atoi(db_res[index++]);
1531 MSG_MGR_CONTACT_INFO_S tmpContact;
1532 memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S));
1534 MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact);
1537 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1540 if (normalAddCnt > 1) {
1541 g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
1544 if (tmpContact.firstName[0] != '\0') {
1545 g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
1546 } else if (tmpAddressInfo.addressVal[0] == '\0') {
1547 char *senderStr = NULL;
1548 senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1549 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1556 noti_info->active_noti_button_num = 1;
1559 char *senderStr = NULL;
1560 if (subType == MSG_CB_SMS) {
1561 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
1562 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1563 noti_info->active_noti_button_num = 1;
1564 } else if (subType == MSG_SYNCML_CP) {
1565 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
1566 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1567 noti_info->active_noti_button_num = 1;
1568 } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
1569 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
1570 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1571 noti_info->active_noti_button_num = 1;
1573 g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
1583 noti_info->active_subtype = subType;
1584 snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
1585 snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
1589 noti_info->senderCount = normalAddCnt;
1590 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
1591 msg_db_free(msg_handle, db_res);
1593 MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
1595 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1597 #ifdef MSG_NOTI_INTEGRATION
1598 snprintf(sqlQuery, sizeof(sqlQuery),
1605 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
1606 "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
1607 "(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) "
1609 "WHERE A.CONV_ID=B.CONV_ID "
1610 "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
1611 "AND B.STORAGE_ID = %d "
1612 "ORDER BY B.DISPLAY_TIME DESC;",
1615 MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
1616 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1617 MSG_INBOX_ID, MSG_CBMSGBOX_ID,
1620 snprintf(sqlQuery, sizeof(sqlQuery),
1627 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
1628 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
1630 "WHERE A.CONV_ID=B.CONV_ID "
1631 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1632 "AND B.STORAGE_ID = %d "
1633 "ORDER BY B.DISPLAY_TIME DESC;",
1636 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1640 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1642 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1643 if (msg_err != MSG_SUCCESS) {
1644 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1649 smsUnreadCnt = atoi(db_res[col_cnt+6]);
1650 mmsUnreadCnt = atoi(db_res[col_cnt+7]);
1651 msgSize = atoi(db_res[col_cnt+8]);
1653 noti_info->count = smsUnreadCnt + mmsUnreadCnt;
1655 if (noti_info->count > 0) {
1656 snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]);
1658 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
1660 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
1662 mainType = (unsigned char)atoi(db_res[col_cnt+5]);
1664 if (mainType == MSG_MMS_TYPE) {
1665 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
1666 if (noti_info->text[0] == '\0') {
1667 char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
1668 snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
1672 char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
1673 if (prefix_subject) {
1674 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
1675 g_free(prefix_subject);
1677 snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
1681 int kb_msg_size = msgSize / 1024;
1682 if (kb_msg_size == 0 && msgSize > 0)
1684 else if (msgSize % 1024 >= 512)
1687 char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
1688 char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
1690 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
1692 g_free(msg_size_string);
1693 g_free(msg_size_unit_kb);
1697 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
1700 if (noti_info->active_text[0] == '\0')
1701 snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]);
1703 MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id);
1705 MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender);
1706 MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject);
1707 MSG_MGR_DEBUG("active text [%s]", noti_info->active_text);
1709 if (!isForInstantMessage) {
1710 if (noti_info->id > 0 && noti_info->count == 1) {
1711 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1712 if (noti_err != NOTIFICATION_ERROR_NONE) {
1713 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1717 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1718 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1721 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt);
1722 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt);
1723 MsgMgrInsertBadge(noti_info->count);
1724 MsgMgrSoundSetRepeatAlarm();
1727 MSG_MGR_DEBUG("No unread message.");
1728 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1730 msg_db_free(msg_handle, db_res);
1732 if (!isForInstantMessage) {
1733 /* No unread message. */
1734 if (noti_info->id > 0) {
1735 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1736 if (noti_err != NOTIFICATION_ERROR_NONE) {
1737 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1743 if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0)
1744 MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID");
1746 vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0);
1747 vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0);
1748 MsgMgrInsertBadge(0);
1749 MsgMgrSoundSetRepeatAlarm();
1755 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1756 msg_db_free(msg_handle, db_res);
1760 msg_db_free(msg_handle, db_res);
1764 #ifndef MSG_NOTI_INTEGRATION
1765 case MSG_MGR_NOTI_TYPE_CB: {
1766 char sqlQuery[MAX_QUERY_LEN+1];
1767 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1769 snprintf(sqlQuery, sizeof(sqlQuery),
1775 "WHERE A.CONV_ID=B.CONV_ID "
1776 "AND B.READ_STATUS=0 "
1777 "AND B.FOLDER_ID=%d "
1778 "AND B.STORAGE_ID = %d "
1779 "ORDER BY B.DISPLAY_TIME DESC;",
1780 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1784 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1785 return MSG_ERR_DB_PREPARE;
1787 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1788 MSG_ADDRESS_INFO_S addrInfo;
1789 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1791 if (dbhandler->columnText(0) != NULL)
1792 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1794 MSG_CONTACT_INFO_S tmpContact;
1795 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1797 MsgGetContactInfo(&addrInfo, &tmpContact);
1799 if (tmpContact.firstName[0] != '\0') {
1800 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1801 } else if (addrInfo.addressVal[0] == '\0') {
1802 char *senderStr = NULL;
1803 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1804 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1810 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1813 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1815 noti_info->time = (time_t)dbhandler->columnInt(1);
1817 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1819 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1821 MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id);
1823 MSG_MGR_DEBUG("No unread CB message.");
1824 MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id);
1826 dbhandler->finalizeQuery();
1828 if (!isForInstantMessage) {
1829 /* No unread message. */
1830 if (noti_info->id > 0) {
1831 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1832 if (noti_err != NOTIFICATION_ERROR_NONE) {
1833 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1839 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1840 MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1842 return MSG_ERR_DB_STEP;
1845 dbhandler->finalizeQuery();
1847 if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) {
1848 MSG_MGR_DEBUG("getTable is failed");
1849 dbhandler->freeTable();
1850 return MSG_ERR_DB_GETTABLE;
1853 dbhandler->freeTable();
1854 MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
1857 case MSG_MGR_NOTI_TYPE_SIM: {
1858 char sqlQuery[MAX_QUERY_LEN+1];
1859 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1861 snprintf(sqlQuery, sizeof(sqlQuery),
1866 "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
1868 "WHERE A.CONV_ID=B.CONV_ID "
1869 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1870 "AND B.STORAGE_ID = %d "
1871 "ORDER BY B.DISPLAY_TIME DESC;",
1873 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1877 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1879 if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
1880 return MSG_ERR_DB_PREPARE;
1882 if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
1883 noti_info->count = dbhandler->columnInt(4);
1885 if (noti_info->count > 0) {
1886 MSG_ADDRESS_INFO_S addrInfo;
1887 memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1889 if (dbhandler->columnText(0) != NULL)
1890 snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
1892 MSG_CONTACT_INFO_S tmpContact;
1893 memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
1895 MsgGetContactInfo(&addrInfo, &tmpContact);
1897 if (tmpContact.firstName[0] != '\0') {
1898 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1899 } else if (addrInfo.addressVal[0] == '\0') {
1900 char *senderStr = NULL;
1901 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
1902 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
1908 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
1911 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
1913 noti_info->time = (time_t)dbhandler->columnInt(1);
1915 noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
1917 snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
1919 MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id);
1921 MSG_MGR_DEBUG("No unread SIM message.");
1922 MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id);
1924 dbhandler->finalizeQuery();
1926 if (!isForInstantMessage) {
1927 /* No unread message. */
1928 if (noti_info->id > 0) {
1929 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
1930 if (noti_err != NOTIFICATION_ERROR_NONE) {
1931 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1937 if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
1938 MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
1941 return MSG_ERR_DB_STEP;
1944 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1945 dbhandler->finalizeQuery();
1946 return MSG_ERR_DB_STEP;
1949 dbhandler->finalizeQuery();
1953 case MSG_MGR_NOTI_TYPE_FAILED: {
1954 char sqlQuery[MAX_QUERY_LEN+1];
1955 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1957 snprintf(sqlQuery, sizeof(sqlQuery),
1964 "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
1966 "WHERE A.CONV_ID=B.CONV_ID "
1967 "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
1968 "AND B.STORAGE_ID = %d "
1969 "ORDER BY B.DISPLAY_TIME DESC;",
1970 MSG_NETWORK_SEND_FAIL,
1971 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
1975 MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
1977 row_cnt = 0, col_cnt = 0;
1978 msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
1979 if (msg_err != MSG_SUCCESS) {
1980 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
1985 noti_info->count = atoi(db_res[col_cnt+6]);
1987 if (noti_info->count > 0) {
1988 MSG_MGR_ADDRESS_INFO_S addrInfo = {0,};
1990 snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]);
1992 MSG_MGR_CONTACT_INFO_S tmpContact = {0,};
1994 MsgMgrGetContactInfo(&addrInfo, &tmpContact);
1996 if (tmpContact.firstName[0] != '\0') {
1997 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
1998 } else if (addrInfo.addressVal[0] == '\0') {
1999 char *senderStr = NULL;
2000 senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
2001 g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
2007 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
2010 snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
2012 noti_info->time = (time_t)atoi(db_res[col_cnt+1]);
2014 noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
2016 unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]);
2018 if (mainType == MSG_TYPE_MMS)
2019 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
2021 snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]);
2023 MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
2025 if (!isForInstantMessage) {
2026 if (noti_info->id > 0 && noti_info->count == 1) {
2027 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
2028 if (noti_err != NOTIFICATION_ERROR_NONE) {
2029 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2032 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2033 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2037 MSG_MGR_DEBUG("No sent failed message.");
2038 MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id);
2040 msg_db_free(msg_handle, db_res);
2042 if (!isForInstantMessage) {
2043 /* No unread message. */
2044 if (noti_info->id > 0) {
2045 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
2046 if (noti_err != NOTIFICATION_ERROR_NONE) {
2047 MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
2053 if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0)
2054 MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID");
2060 msg_db_free(msg_handle, db_res);
2064 msg_db_free(msg_handle, db_res);
2067 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2070 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2080 notification_h getHandle(int *noti_id)
2082 notification_h noti_h = NULL;
2085 MSG_MGR_DEBUG("Notification load");
2086 noti_h = notification_load(NULL, *noti_id);
2088 MSG_MGR_DEBUG("notification_load is failed.");
2091 if (noti_h == NULL) {
2092 MSG_MGR_DEBUG("Notification create");
2093 noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
2094 if (noti_h == NULL) {
2095 MSG_MGR_DEBUG("notification_create is failed.");
2106 int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
2112 switch (noti_type) {
2113 #ifdef MSG_NOTI_INTEGRATION
2114 case MSG_MGR_NOTI_TYPE_NORMAL:
2115 case MSG_MGR_NOTI_TYPE_SIM:
2116 case MSG_MGR_NOTI_TYPE_CB:
2117 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2120 case MSG_MGR_NOTI_TYPE_NORMAL:
2121 vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id);
2123 case MSG_MGR_NOTI_TYPE_SIM:
2124 vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id);
2126 case MSG_MGR_NOTI_TYPE_CB:
2127 vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id);
2130 case MSG_MGR_NOTI_TYPE_FAILED:
2131 vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id);
2133 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2134 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2135 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2136 vconf_get_int(keyName, ¬i_id);
2139 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2140 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2141 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2142 vconf_get_int(keyName, ¬i_id);
2145 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2146 vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id);
2149 MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
2153 MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
2161 void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx)
2167 MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2169 switch (noti_type) {
2170 #ifdef MSG_NOTI_INTEGRATION
2171 case MSG_MGR_NOTI_TYPE_NORMAL:
2172 case MSG_MGR_NOTI_TYPE_SIM:
2173 case MSG_MGR_NOTI_TYPE_CB:
2174 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2177 case MSG_MGR_NOTI_TYPE_NORMAL:
2178 err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id);
2180 case MSG_MGR_NOTI_TYPE_SIM:
2181 err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id);
2183 case MSG_MGR_NOTI_TYPE_CB:
2184 err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id);
2187 case MSG_MGR_NOTI_TYPE_FAILED:
2188 err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
2190 case MSG_MGR_NOTI_TYPE_VOICE_1: {
2191 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2192 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
2193 err = vconf_set_int(keyName, noti_id);
2196 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2197 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
2198 snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
2199 err = vconf_set_int(keyName, noti_id);
2202 case MSG_MGR_NOTI_TYPE_SIM_FULL:
2203 err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
2206 MSG_MGR_DEBUG("No matching type [%d]", noti_type);
2211 MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
2217 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info)
2222 noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx);
2223 noti_info->msg_id = msg_info->msgId;
2225 MSG_MGR_DEBUG("msg_info is NULL");
2229 noti_info->sim_idx = msg_info->sim_idx;
2231 createServiceHandle(¬i_info->svc_h);
2232 char keyName[MAX_VCONFKEY_NAME_LEN];
2234 switch (noti_info->type) {
2235 case MSG_MGR_NOTI_TYPE_VOICE_1:
2236 case MSG_MGR_NOTI_TYPE_VOICE_2: {
2237 memset(keyName, 0x00, sizeof(keyName));
2238 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
2239 vconf_get_int(keyName, ¬i_info->count);
2240 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2241 noti_info->time = msg_info->displayTime;
2243 memset(keyName, 0x00, sizeof(keyName));
2244 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
2245 char *voiceNumber = vconf_get_str(keyName);
2246 memset(keyName, 0x00, sizeof(keyName));
2247 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
2248 char *voiceAlphaId = vconf_get_str(keyName);
2249 char *dialNumber = NULL;
2251 MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
2253 if (voiceNumber && strlen(voiceNumber))
2254 dialNumber = voiceNumber;
2256 if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
2257 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
2258 } else if (dialNumber && strlen(dialNumber) > 0) {
2259 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
2262 if (dialNumber && strlen(dialNumber) > 0)
2263 snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
2265 if (noti_info->svc_h) {
2266 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2267 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2269 char slot_id[5] = {0, };
2270 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2271 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2274 if (voiceNumber) g_free(voiceNumber);
2275 if (voiceAlphaId) g_free(voiceAlphaId);
2278 case MSG_MGR_NOTI_TYPE_MWI:
2279 case MSG_MGR_NOTI_TYPE_CLASS0: {
2280 noti_info->count = 1;
2281 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2282 noti_info->time = msg_info->displayTime;
2284 if (msg_info->displayName[0] == '\0')
2285 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2287 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName);
2289 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2291 snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
2293 if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) {
2294 if (noti_info->svc_h) {
2295 setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
2296 setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
2298 char slot_id[5] = {0, };
2299 snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
2300 addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
2304 setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
2305 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2306 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2310 case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: {
2311 noti_info->count = 1;
2312 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2313 noti_info->time = msg_info->displayTime;
2314 noti_info->extra_data = msg_info->networkStatus;
2316 /* contacts-service is not used for gear */
2317 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
2318 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
2319 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,};
2320 if (msg_info->addressVal) {
2321 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2322 if (_is_valid_email(msg_info->addressVal)) {
2323 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2325 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2329 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2330 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2332 #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
2334 if (contactInfo.firstName[0] == '\0')
2335 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2337 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2339 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2341 if (noti_info->msg_id > 0) {
2342 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2343 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2344 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2345 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2349 case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT:
2350 case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: {
2351 noti_info->count = 1;
2352 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2353 noti_info->time = msg_info->displayTime;
2355 /* contacts-service is not used for gear */
2356 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
2357 MSG_MGR_CONTACT_INFO_S contactInfo = {0,};
2358 MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,};
2359 if (msg_info->addressVal) {
2360 snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal);
2361 if (_is_valid_email(msg_info->addressVal)) {
2362 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
2364 tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
2368 if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) {
2369 MSG_MGR_WARN("MsgMgrGetContactInfo() fail.");
2371 #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
2372 if (contactInfo.firstName[0] == '\0')
2373 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal);
2375 snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName);
2377 snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal);
2379 char sqlQuery[MAX_QUERY_LEN+1];
2380 memset(sqlQuery, 0x00, sizeof(sqlQuery));
2382 int report_status_type;
2383 int report_status_value;
2385 if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) {
2386 report_status_type = MSG_REPORT_TYPE_READ;
2388 report_status_type = MSG_REPORT_TYPE_DELIVERY;
2391 snprintf(sqlQuery, sizeof(sqlQuery),
2394 "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';",
2395 MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
2397 MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
2399 char **db_res = NULL;
2400 int row_cnt = 0, col_cnt = 0;
2402 int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
2403 if (msg_err != MSG_SUCCESS || row_cnt <= 0) {
2404 MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
2408 report_status_value = atoi(db_res[col_cnt]);
2410 MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
2412 msg_err = msg_db_free(msg_handle, db_res);
2413 if (msg_err != MSG_SUCCESS) {
2414 MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
2418 if (noti_info->msg_id > 0) {
2419 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2420 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2421 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2422 addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal);
2425 noti_info->extra_data = (unsigned char)report_status_value;
2429 MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
2433 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2438 void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti)
2442 createServiceHandle(¬i_info->svc_h);
2444 switch (noti_info->type) {
2445 case MSG_MGR_NOTI_TYPE_NORMAL: {
2446 if (noti_info->count > 1) {
2447 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2449 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2452 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2453 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2454 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2455 addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
2457 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
2459 if (noti_info->active_noti_button_num == 0)
2460 noti_info->active_noti_button_num = 3;
2463 case MSG_MGR_NOTI_TYPE_CB: {
2464 if (noti_info->count > 1) {
2465 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2467 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2470 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2471 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2472 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2474 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2475 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2477 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2479 noti_info->active_noti_button_num = 1;
2482 case MSG_MGR_NOTI_TYPE_SIM: {
2483 if (noti_info->count > 1) {
2484 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
2486 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2489 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2490 addServiceExtraData(noti_info->svc_h, "type", "new_msg");
2491 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2493 if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT)
2494 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
2496 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2498 if (noti_info->active_noti_button_num == 0)
2499 noti_info->active_noti_button_num = 3;
2502 case MSG_MGR_NOTI_TYPE_FAILED: {
2503 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2505 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2506 addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
2507 addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
2509 noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
2512 case MSG_MGR_NOTI_TYPE_SIM_FULL: {
2513 noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2515 setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
2516 addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
2518 noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
2525 if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
2526 noti_info->active_noti_button_num = 0;
2532 void createServiceHandle(app_control_h *svc_h)
2534 int svc_err = APP_CONTROL_ERROR_NONE;
2536 svc_err = app_control_create(svc_h);
2538 if (svc_err != APP_CONTROL_ERROR_NONE)
2539 MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err);
2543 void setServiceAppId(app_control_h svc_h, const char* app_id)
2545 int svc_err = APP_CONTROL_ERROR_NONE;
2547 svc_err = app_control_set_app_id(svc_h, app_id);
2549 if (svc_err != APP_CONTROL_ERROR_NONE)
2550 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2554 void setServiceUri(app_control_h svc_h, const char* uri)
2556 int svc_err = APP_CONTROL_ERROR_NONE;
2558 svc_err = app_control_set_uri(svc_h, uri);
2560 if (svc_err != APP_CONTROL_ERROR_NONE)
2561 MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
2565 void setServiceOperation(app_control_h svc_h, const char* operation)
2567 int svc_err = APP_CONTROL_ERROR_NONE;
2569 svc_err = app_control_set_operation(svc_h, operation);
2571 if (svc_err != APP_CONTROL_ERROR_NONE)
2572 MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err);
2576 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val)
2578 int svc_err = APP_CONTROL_ERROR_NONE;
2580 svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val);
2582 if (svc_err != APP_CONTROL_ERROR_NONE)
2583 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2587 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val)
2589 int svc_err = APP_CONTROL_ERROR_NONE;
2592 memset(&tempId, 0x00, sizeof(tempId));
2593 snprintf(tempId, sizeof(tempId), "%d", bundle_val);
2595 svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId);
2597 if (svc_err != APP_CONTROL_ERROR_NONE)
2598 MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err);
2602 void setServicePackageName(app_control_h svc_h, const char* pkg_name)
2604 int svc_err = APP_CONTROL_ERROR_NONE;
2606 svc_err = app_control_set_app_id(svc_h, pkg_name);
2608 if (svc_err != APP_CONTROL_ERROR_NONE)
2609 MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err);
2613 void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data)
2615 int svc_err = APP_CONTROL_ERROR_NONE;
2617 svc_err = app_control_send_launch_request(svc_h, callback, user_data);
2619 if (svc_err != APP_CONTROL_ERROR_NONE)
2620 MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err);
2624 void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir)
2626 int noti_err = NOTIFICATION_ERROR_NONE;
2628 noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir);
2629 if (noti_err != NOTIFICATION_ERROR_NONE)
2630 MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err);
2634 void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key)
2636 int noti_err = NOTIFICATION_ERROR_NONE;
2638 noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE);
2640 if (noti_err != NOTIFICATION_ERROR_NONE)
2641 MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err);
2645 void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time)
2647 int noti_err = NOTIFICATION_ERROR_NONE;
2649 noti_err = notification_set_time_to_text(noti_h, type, time);
2651 if (noti_err != NOTIFICATION_ERROR_NONE)
2652 MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err);
2656 void setNotiTime(notification_h noti_h, time_t time)
2658 int noti_err = NOTIFICATION_ERROR_NONE;
2660 noti_err = notification_set_time(noti_h, time);
2662 if (noti_err != NOTIFICATION_ERROR_NONE)
2663 MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err);
2668 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path)
2670 int noti_err = NOTIFICATION_ERROR_NONE;
2672 noti_err = notification_set_image(noti_h, type, image_path);
2674 if (noti_err != NOTIFICATION_ERROR_NONE)
2675 MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err);
2679 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path)
2681 int noti_err = NOTIFICATION_ERROR_NONE;
2683 noti_err = notification_set_sound(noti_h, type, path);
2685 if (noti_err != NOTIFICATION_ERROR_NONE)
2686 MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err);
2690 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path)
2692 int noti_err = NOTIFICATION_ERROR_NONE;
2694 noti_err = notification_set_vibration(noti_h, type, path);
2696 if (noti_err != NOTIFICATION_ERROR_NONE)
2697 MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err);
2701 void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
2703 int noti_err = NOTIFICATION_ERROR_NONE;
2705 noti_err = notification_set_event_handler(noti_h, type, event_handler);
2707 if (noti_err != NOTIFICATION_ERROR_NONE)
2708 MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
2712 int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
2716 char *notiMsg = NULL;
2718 notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
2720 switch (noti_type) {
2721 case MSG_MGR_NOTI_TYPE_NORMAL:
2722 case MSG_MGR_NOTI_TYPE_SIM:
2723 case MSG_MGR_NOTI_TYPE_CB: {
2724 MSG_MGR_NOTI_INFO_S noti_info;
2725 memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S));
2727 noti_info.type = noti_type;
2728 int err = getLatestMsgInfo(¬i_info, true);
2731 MSG_MGR_DEBUG("Unread count [%d]", noti_info.count);
2732 if (noti_info.count == 1) {
2733 MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender);
2734 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
2735 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
2736 } else if (noti_info.count > 1) {
2737 gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
2739 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGE);
2740 gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
2741 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
2742 setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
2747 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
2751 case MSG_MGR_NOTI_TYPE_FAILED: {
2752 notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
2753 setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
2754 setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
2758 MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type);
2759 goto _END_OF_INSTANT_NOTI;
2763 if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
2764 MSG_MGR_DEBUG("Fail to notification_set_display_applist");
2766 if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
2767 MSG_MGR_DEBUG("Fail to notification_post");
2769 _END_OF_INSTANT_NOTI:
2771 if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
2772 MSG_MGR_DEBUG("Fail to notification_delete");
2779 if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
2780 MSG_MGR_DEBUG("Fail to notification_free");
2789 int MsgMgrInsertBadge(unsigned int unreadMsgCnt)
2791 MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt);
2793 int err = BADGE_ERROR_NONE;
2796 err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
2798 if (err != BADGE_ERROR_NONE) {
2799 MSG_MGR_ERR("Fail to badge_is_existing : %d", err);
2805 err = badge_add(MSG_DEFAULT_APP_ID);
2806 if (err != BADGE_ERROR_NONE) {
2807 MSG_MGR_ERR("Fail to badge_add : %d", err);
2812 err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
2814 if (err != BADGE_ERROR_NONE) {
2815 MSG_MGR_ERR("Fail to badge_set_count : %d", err);
2823 void MsgMgrNotiSoundRepeatAlarmCB(int alarmId)
2827 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2829 #ifndef MSG_NOTI_INTEGRATION
2830 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2831 MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE);
2839 void MsgMgrSoundCreateRepeatAlarm(int RepeatTime)
2845 struct tm repeat_tm;
2849 tmp_time += (RepeatTime*60);
2851 localtime_r(&tmp_time, &repeat_tm);
2853 if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) {
2854 MSG_MGR_DEBUG("MsgAlarmRegistration fail.");
2858 g_alarmId = tmpAlarmId;
2859 MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId);
2867 void MsgMgrSoundSetRepeatAlarm()
2869 int nRepeatValue = 0;
2870 long nRepeatTime = 0;
2872 if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) {
2873 MSG_MGR_INFO("vconf_get_int() is failed");
2876 switch (nRepeatValue) {
2877 case MSG_ALERT_TONE_ONCE:
2880 case MSG_ALERT_TONE_2MINS:
2883 case MSG_ALERT_TONE_5MINS:
2886 case MSG_ALERT_TONE_10MINS:
2890 MSG_MGR_DEBUG("Invalid Repetition time");
2894 MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime);
2896 if (nRepeatTime > 0) {
2897 if (g_alarmId > 0) {
2898 if (MsgMgrAlarmRemove(g_alarmId) != 0) {
2899 MSG_MGR_FATAL("MsgAlarmRemove fail.");
2903 MsgMgrSoundCreateRepeatAlarm(nRepeatTime);
2910 char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text)
2912 char *notiMsg = NULL;
2915 lang = vconf_get_str(VCONFKEY_LANGSET);
2917 setlocale(LC_MESSAGES, lang);
2919 bindtextdomain(pkg_name, locale_dir);
2921 notiMsg = dgettext(pkg_name, text);
2928 return g_strdup(notiMsg);