[TSAM-8885] implmentation for reply on active notification
[platform/core/messaging/msg-service.git] / manager / src / msg-manager-notification.cpp
index ac4e516..26bff49 100644 (file)
@@ -64,6 +64,7 @@ int g_alarmId = 0;
 ==================================================================================================*/
 typedef struct _report_notification_s
 {
+       msg_mgr_notification_type_t             noti_type;
        int priv_id;
        char addressVal[MAX_ADDRESS_VAL_LEN+1];
 } report_notification_s;
@@ -85,6 +86,7 @@ typedef struct _msg_mgr_noti_info_s
        app_control_h           svc_h;
        app_control_h           active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
        msg_message_id_t                msg_id;
+       int                     conv_id;
        unsigned char           extra_data;
        int             sim_idx;
        int                     active_noti_button_num;
@@ -109,10 +111,12 @@ typedef struct _del_noti_info_s
 ===================================================================================================*/
 
 void MsgMgrInitReportNotiList();
+void MsgInitNotiCb(void *data);
 void MsgRefreshNotiCb(void *data);
 void MsgMgrDeleteNotiCb(void *data);
 
 void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simIndex);
+int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result);
 
 notification_h getHandle(int *noti_id);
 
@@ -139,8 +143,6 @@ void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
 
 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
 
-bool isExistAddressInReportTable(const char *addr);
-
 /* Wrapper */
 void createServiceHandle(app_control_h *svc_h);
 void setServiceAppId(app_control_h svc_h, const char* app_id);
@@ -180,55 +182,6 @@ bool _is_valid_email(char *pAddress)
 }
 
 
-bool isExistAddressInReportTable(const char *addr)
-{
-       char sqlQuery[MAX_QUERY_LEN+1];
-       int rowCnt = 0, colCnt = 0;
-       char **db_res = NULL;
-       int msg_err = 0;
-
-       char *normal_addr = msg_mgr_normalize_number((char *)addr);
-
-       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-       snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normal_addr);
-
-       msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
-               return false;
-       }
-
-       msg_err = msg_db_free(msg_handle, db_res);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
-               return false;
-       }
-
-       if (rowCnt > 0)
-               return true;
-
-       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-       snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normal_addr);
-
-       msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
-               return false;
-       }
-
-       msg_err = msg_db_free(msg_handle, db_res);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
-               return false;
-       }
-
-       if (rowCnt > 0)
-               return true;
-
-       return false;
-}
-
-
 void MsgMgrInitReportNotiList()
 {
        MSG_MGR_BEGIN();
@@ -256,6 +209,10 @@ void MsgMgrInitReportNotiList()
 
        while (noti_list != NULL) {
                noti = notification_list_get_data(noti_list);
+               if (noti == NULL) {
+                       MSG_MGR_DEBUG("notification_list_get_data() failed!!");
+                       break;
+               }
 
                char tempAddr[MAX_ADDRESS_VAL_LEN+1];
                memset(tempAddr, 0x00, sizeof(tempAddr));
@@ -266,25 +223,41 @@ void MsgMgrInitReportNotiList()
                        break;
                }
 
-               char *addr = NULL;
+               char *is_report_noti = NULL;
 
-               int ret = app_control_get_extra_data(app_control, "address", &addr);
-               if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
-                       if (isExistAddressInReportTable(addr)) {
+               int ret = app_control_get_extra_data(app_control, "is_report_noti", &is_report_noti);
+               if (ret == APP_CONTROL_ERROR_NONE && is_report_noti != NULL && g_strcmp0(is_report_noti, "true") == 0) {
+                       char *addr = NULL;
+
+                       ret = app_control_get_extra_data(app_control, "address", &addr);
+                       if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
                                report_notification_s *info = new report_notification_s;
                                memset(info, 0x00, sizeof(report_notification_s));
 
+                               char *noti_type = NULL;
+                               ret = app_control_get_extra_data(app_control, "noti_type", &noti_type);
+                               if (ret == APP_CONTROL_ERROR_NONE && noti_type != NULL) {
+                                       info->noti_type = (msg_mgr_notification_type_t)atoi(noti_type);
+                                       g_free(noti_type);
+                               }
+
                                notification_get_id(noti, NULL, &(info->priv_id));
                                snprintf(info->addressVal, sizeof(info->addressVal), "%s", addr);
 
                                msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
-                               MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
+                               MSG_MGR_SEC_DEBUG("appended list data = [noti_type = %d priv_id = %d address = %s]", info->noti_type, info->priv_id, info->addressVal);
+
+                               g_free(addr);
+                               addr = NULL;
                        }
+               }
 
-                       g_free(addr);
-                       addr = NULL;
+               if (is_report_noti) {
+                       g_free(is_report_noti);
+                       is_report_noti = NULL;
                }
 
+
                noti_list = notification_list_get_next(noti_list);
        }
 
@@ -306,11 +279,41 @@ void MsgMgrInitNoti()
 
        if (bNotiSvcReady == true) {
                MSG_MGR_DEBUG("Notification server is available");
+               MsgMgrInitReportNotiList();
+       } else {
+               MSG_MGR_DEBUG("Notification server is not available. Init is defered");
+               notification_add_deferred_task(MsgInitNotiCb, NULL);
+       }
+
+       is_init = true;
+}
+
+
+void MsgInitNotiCb(void *data)
+{
+       MsgMgrInitReportNotiList();
+
+       if (data) {
+               free(data);
+               data = NULL;
+       }
+
+       return;
+}
+
+
+void MsgMgrOnBoot()
+{
+       bool bNotiSvcReady = false;
+
+       bNotiSvcReady = notification_is_service_ready();
+
+       if (bNotiSvcReady == true) {
+               MSG_MGR_DEBUG("Notification server is available");
 #ifndef MSG_NOTI_INTEGRATION
                MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1);
 #endif
                MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);            /* On Booting */
-               MsgMgrInitReportNotiList();
        } else {
                MSG_MGR_DEBUG("Notification server is not available. Init is defered");
 #ifndef MSG_NOTI_INTEGRATION
@@ -321,17 +324,14 @@ void MsgMgrInitNoti()
                }
                notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
 #endif
-               notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
+               notification_add_deferred_task(MsgRefreshNotiCb, NULL);
        }
-
-       is_init = true;
 }
 
 
 void MsgRefreshNotiCb(void *data)
 {
        MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT);
-       MsgMgrInitReportNotiList();
 
        if (data) {
                free(data);
@@ -366,7 +366,7 @@ int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MS
        MSG_MGR_NOTI_INFO_S noti_info = {0, };
 
        noti_info.type = noti_type;
-       noti_info.active_noti_button_num = 1;
+       noti_info.active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CLASS0_MESSAGE;
 
        createActiveInfoData(&noti_info, msg_info);
 
@@ -441,6 +441,7 @@ int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_M
        int ret = 0;
 
        notification_h noti_h = NULL;
+       bool isNewNoti = false;
 
        report_notification_s *info = new report_notification_s;
        memset(info, 0x00, sizeof(report_notification_s));
@@ -450,6 +451,9 @@ int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_M
 
        createInfoData(&noti_info, msg_info);
 
+       if (noti_info.id == 0)
+               isNewNoti = true;
+
        noti_h = getHandle(&noti_info.id);
 
        if (noti_h == NULL) {
@@ -458,8 +462,54 @@ int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_M
                goto __END_OF_ADD_REPORT_NOTI;
        }
 
+       if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT || noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
+               noti_info.applist &= ~NOTIFICATION_DISPLAY_APP_TICKER;
+
+               ret = MsgMgrInsertDeliveryReportInstantNotification(noti_type, noti_info.extra_data);
+
+               if (ret != 0) {
+                       MSG_MGR_ERR(" MsgInsertInstantDeliveryReportNotification() err = [%d]", ret);
+                       goto __END_OF_ADD_REPORT_NOTI;
+               }
+       }
+
+       addServiceExtraData(noti_info.svc_h, "is_report_noti", "true");
        setNotification(noti_h, &noti_info, true);
 
+       if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT)
+               noti_type = MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT;
+
+       if (isNewNoti) {
+               report_notification_s *info = new report_notification_s;
+               memset(info, 0x00, sizeof(report_notification_s));
+
+               info->noti_type = noti_type;
+               info->priv_id = noti_info.id;
+               snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
+               msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
+               MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
+       } else {
+               GList *iter = g_list_first(msg_report_notification_list);
+
+               while (iter != NULL) {
+                       report_notification_s *info = (report_notification_s*)(iter->data);
+                       if (info == NULL) {
+                               MSG_MGR_DEBUG("info is NULL!");
+                               continue;
+                       }
+
+                       // update new addressVal of noti_type
+                       if (info->priv_id == noti_info.id) {
+                               memset(info->addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+                               snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
+                               MSG_MGR_SEC_DEBUG("updated list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
+                               break;
+                       }
+
+                       iter = g_list_next(iter);
+               }
+       }
+
        info->priv_id = noti_info.id;
        snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal);
        msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
@@ -597,7 +647,7 @@ void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simInde
                MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type);
 
                if (notiId > 0)
-                       noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, notiId);
+                       noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, notiId);
 
        } else {
                MSG_MGR_DEBUG("No matching type [%d]", noti_type);
@@ -635,6 +685,41 @@ int MsgMgrDeleteNoti(msg_mgr_notification_type_t noti_type, int simIndex)
 }
 
 
+int MsgMgrDeleteSentReadReportNotification()
+{
+       int readReportSentNotiId = 0;
+       int noti_err = 0;
+
+       if (vconf_get_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, &readReportSentNotiId) != 0) {
+               MSG_MGR_INFO("vconf_get_int() is failed");
+               return -1;
+       }
+
+       if (readReportSentNotiId > 0) {
+               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, readReportSentNotiId);
+               if (noti_err != 0) {
+                       MSG_MGR_DEBUG("notification_delete_by_priv_id() fail [%d]", noti_err);
+                       return -1;
+               }
+       } else {
+               MSG_MGR_DEBUG("VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID is 0");
+               return -1;
+       }
+
+       if (vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, 0) != 0) {
+               MSG_MGR_DEBUG("vconf_set_int fail : VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID");
+               return -1;
+       }
+
+       if (vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID, 0) != 0) {
+               MSG_MGR_DEBUG("vconf_set_int fail : VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID");
+               return -1;
+       }
+
+       return 0;
+}
+
+
 void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type)
 {
        MSG_MGR_BEGIN();
@@ -743,6 +828,11 @@ void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                MSG_MGR_DEBUG("Fail to notification_set_display_applist");
        }
 
+       /* set pkg name */
+       noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_MGR_DEBUG("Fail to notification_set_pkgname");
+       }
 
        MSG_MGR_END();
 }
@@ -904,11 +994,11 @@ void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
 
                if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
                } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
                } else {
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
                }
 
                setNotiTime(noti_h, noti_info->time);
@@ -916,17 +1006,15 @@ void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
        }
        case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: {
                setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
-               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
 
+               char readStatusString[50] = {0,};
                if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
-               /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
-#if 0
-               } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
-                       /* notification free */
-#endif
+                       snprintf(readStatusString, sizeof(readStatusString), "Message deleted by %s", noti_info->sender);
+                       notification_set_text(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, readStatusString, MESSAGE_DELETED_BY_PS, NOTIFICATION_VARIABLE_TYPE_STRING, noti_info->sender, NOTIFICATION_VARIABLE_TYPE_NONE);
                } else {
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
+                       char readStatusString[50] = {0,};
+                       snprintf(readStatusString, sizeof(readStatusString), "Message read by %s", noti_info->sender);
+                       notification_set_text(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, readStatusString, MESSAGE_READ_BY_PS, NOTIFICATION_VARIABLE_TYPE_STRING, noti_info->sender, NOTIFICATION_VARIABLE_TYPE_NONE);
                }
 
                setNotiTime(noti_h, noti_info->time);
@@ -936,24 +1024,31 @@ void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
                setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
 
-               if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED)
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
-               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED)
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE);
-               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED)
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
-               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED)
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE);
-               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE)
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE);
-               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED)
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL);
-               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE)
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE);
-               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR)
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL);
-               else
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
+               if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", MESSAGE_EXPIRED);
+               } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", MESSAGE_REJECTED);
+               } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delayed", MESSAGE_DELAYED);
+               } else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED || noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE
+                               || noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED || noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE
+                               || noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Recipient not available", RECIPIENT_NOT_AVAILABLE);
+               } else {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", MESSAGE_DELIVERED);
+               }
+
+               setNotiTime(noti_h, noti_info->time);
+               break;
+       }
+       case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Messages", MSG_MESSAGE);
+
+               if ((int)noti_info->extra_data == MSG_NETWORK_SEND_FAIL) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send Read report", FAILED_TO_SEND_MMS_READ_REPORT);
+               } else {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Read report sent", MMS_READ_REPORT_SENT);
+               }
 
                setNotiTime(noti_h, noti_info->time);
                break;
@@ -997,7 +1092,8 @@ void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                        } else {
                                if (noti_info->imagePath[0] != '\0') {
                                        setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
-                                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
+                                       /* for user profile image, use NOTIFICATION_IMAGE_TYPE_THUMBNAIL to show icon as circle */
+                                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, noti_info->imagePath);
                                } else {
                                        setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
                                        setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
@@ -1060,6 +1156,10 @@ void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
                break;
+       case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+               break;
        case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT:
                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
@@ -1114,6 +1214,12 @@ void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                MSG_MGR_DEBUG("Fail to notification_set_display_applist");
        }
 
+       /* set pkg name */
+       noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_MGR_DEBUG("Fail to notification_set_pkgname");
+       }
+
        MSG_MGR_END();
 }
 
@@ -1128,11 +1234,31 @@ void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
        case MSG_MGR_NOTI_TYPE_CB: {
                if (noti_info->active_subject[0] == '\0') {
                        setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
+                       if (noti_info->active_text[0] != '\0') {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
+                       } else {
+                               if (noti_info->active_media_cnt > 1) {
+                                       char attach_string[20] = {0,};
+                                       snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
+                                       notification_set_text(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, MSG_PD_ATTACHMENTS, NOTIFICATION_VARIABLE_TYPE_INT, noti_info->active_media_cnt, NOTIFICATION_VARIABLE_TYPE_NONE);
+                               } else if (noti_info->active_media_cnt == 1) {
+                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", MSG_SINGLE_ATTACHMENT);
+                               }
+                       }
                } else {
                        setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
                        setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
-                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
+                       if (noti_info->active_text[0] != '\0') {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
+                       } else {
+                               if (noti_info->active_media_cnt > 1) {
+                                       char attach_string[20] = {0,};
+                                       snprintf(attach_string, sizeof(attach_string), "%d attachments", noti_info->active_media_cnt);
+                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, attach_string, NULL);
+                               } else if (noti_info->active_media_cnt == 1) {
+                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "1 attachment", NULL);
+                               }
+                       }
                }
                break;
        }
@@ -1170,7 +1296,8 @@ void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                        break;
                default:
                        if (noti_info->imagePath[0] != '\0')
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
+                               /* for user profile image, use NOTIFICATION_IMAGE_TYPE_THUMBNAIL to show icon as circle */
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, noti_info->imagePath);
                        else
                                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
 
@@ -1203,6 +1330,65 @@ void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
 }
 
 
+int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t noti_type, int result)
+{
+       MSG_MGR_BEGIN();
+
+       notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
+       notification_set_pkgname(noti, MSG_DEFAULT_APP_ID);
+
+       setTextDomain(noti);
+       setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
+       setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_DELIVER_REPORT_STATUS_ICON);
+
+       if (noti_type == MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT) {
+               if (result == MSG_NETWORK_DELIVER_SUCCESS) {
+                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
+               } else if (result == MSG_NETWORK_DELIVER_EXPIRED) {
+                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
+               } else if (result == MSG_NETWORK_DELIVER_PENDING) {
+                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
+               } else {
+                       MSG_MGR_ERR("unexpected result! [%d]", result);
+                       goto _END_OF_INSTANT_DELIVERY_REPORT_NOTI;
+               }
+       } else if (noti_type == MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT) {
+               if (result == MSG_DELIVERY_REPORT_EXPIRED)
+                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message expired.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_EXPIRED);
+               else if (result== MSG_DELIVERY_REPORT_REJECTED)
+                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Message rejected by recipient.", UNABLE_TO_DELIVER_MESSAGE_MESSAGE_REJECTED);
+               else if (result == MSG_DELIVERY_REPORT_DEFERRED)
+                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delayed.", MESSAGE_DELAYED_POPUP);
+               else if (result == MSG_DELIVERY_REPORT_UNRECOGNISED || result == MSG_DELIVERY_REPORT_INDETERMINATE ||
+                               result == MSG_DELIVERY_REPORT_FORWARDED || result == MSG_DELIVERY_REPORT_UNREACHABLE ||
+                               result == MSG_DELIVERY_REPORT_ERROR)
+                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't deliver message. Recipient not available.", UNABLE_TO_DELIVER_MESSAGE_RECIPIENT_NOT_AVAILABLE);
+               else
+                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivered.", MESSAGE_DELIVERED_POPUP);
+       }
+
+       if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
+               MSG_MGR_ERR("Fail to notification_set_display_applist");
+
+       if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
+               MSG_MGR_ERR("Fail to notification_post");
+
+_END_OF_INSTANT_DELIVERY_REPORT_NOTI:
+
+       if (notification_delete(noti) != NOTIFICATION_ERROR_NONE)
+               MSG_MGR_ERR("Fail to notification_delete");
+
+       if (noti) {
+               if (notification_free(noti) != NOTIFICATION_ERROR_NONE)
+                       MSG_MGR_ERR("Fail to notification_free");
+               noti = NULL;
+       }
+
+       MSG_MGR_END();
+       return 0;
+}
+
+
 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail)
 {
        MSG_MGR_BEGIN();
@@ -1238,7 +1424,7 @@ void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMa
                } else {
                        int tmpVal = 0;
                        if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) {
-                               MSG_MGR_INFO("MsgSettingGetInt() is failed");
+                               MSG_MGR_INFO("vconf_get_int() is failed");
                        }
                        int ringtoneType = tmpVal;
                        if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
@@ -1288,14 +1474,14 @@ void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info
 
                createServiceHandle(&noti_info->active_noti_svc_h[1]);
                if (noti_info->active_noti_svc_h[1]) {
-                       setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
+                       setServicePackageName(noti_info->active_noti_svc_h[1], MSG_MGR_APP_ID);
 
-                       MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
-                       addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
-                       addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
+                       MSG_MGR_DEBUG("Active Notification button 2 - number = [%s] slot_id = [%d]", noti_info->number, noti_info->sim_idx);
+                       addServiceExtraData(noti_info->active_noti_svc_h[1], "cmd", "reply_msg");
+                       addServiceExtraData(noti_info->active_noti_svc_h[1], "addr", noti_info->number);
 
                        char slot_id[5] = {0, };
-                       snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
+                       snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx);
                        addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
                }
        }
@@ -1317,6 +1503,8 @@ void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info
        if (noti_info->active_noti_button_num > 1) {
                setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
                setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
+               notification_set_text_input(noti_h, 100);
+               setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_TEXT_INPUT_BUTTON, noti_info->active_noti_svc_h[1]);
                setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
 
                setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
@@ -1353,7 +1541,7 @@ void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool
 
        MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num);
 
-       if (bFeedback && noti_info->active_noti_button_num > 0 &&
+       if (bFeedback && noti_info->active_noti_button_num > MSG_ACTIVE_NOTI_BUTTON_NUM_NONE &&
                ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) {
                notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
 
@@ -1398,6 +1586,12 @@ void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool
                updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx);
        }
 
+       if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT && noti_info->msg_id > 0) {
+               int err = vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID, noti_info->msg_id);
+               if (err != 0)
+                       MSG_MGR_ERR("vconf_set_int() failed [%d]", err);
+       }
+
        MSG_MGR_END();
 }
 
@@ -1537,7 +1731,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                char sqlQuery[MAX_QUERY_LEN     +1];
                unsigned char mainType;
                unsigned char subType;
-               int msgSize;
+               int msgSize, attachmentCnt;
 
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
 #ifdef MSG_NOTI_INTEGRATION
@@ -1620,24 +1814,26 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                                }
 
                                if (i == 1) {
-                                       noti_info->active_noti_button_num = 1;
+                                       noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_UNKNOWN_SENDER;
                                }
                        } else {
                                char *senderStr = NULL;
                                if (subType == MSG_CB_SMS) {
                                        senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
                                        g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                       noti_info->active_noti_button_num = 1;
+                                       noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
                                } else if (subType == MSG_SYNCML_CP) {
                                        senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
                                        g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                       noti_info->active_noti_button_num = 1;
+                                       noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_PUSH_MESSAGE;
                                } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
                                        senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
                                        g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                       noti_info->active_noti_button_num = 1;
+                                       noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_PUSH_MESSAGE;
                                } else {
                                        g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                                       if (subType == MSG_NOTIFICATIONIND_MMS)
+                                               noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_UNRETRIVED_MESSAGE;
                                }
 
                                if (senderStr) {
@@ -1659,27 +1855,50 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender);
 
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, MAX_QUERY_LEN,
+                               "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS SMS_UNREAD_CNT, "
+                               "(COUNT(DISTINCT(CASE WHEN MAIN_TYPE = %d THEN MSG_ID END))) AS MMS_UNREAD_CNT "
+                               "FROM %s WHERE READ_STATUS = 0 AND (FOLDER_ID=%d OR FOLDER_ID=%d) AND STORAGE_ID = %d;",
+                               MSG_SMS_TYPE,
+                               MSG_MMS_TYPE,
+                               MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE);
+
+               MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery);
+
+               msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt);
+               if (msg_err != MSG_SUCCESS) {
+                       MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
+                       return -1;
+               }
+
+               if (row_cnt > 0) {
+                       smsUnreadCnt = atoi(db_res[col_cnt]);
+                       mmsUnreadCnt = atoi(db_res[col_cnt+1]);
+               }
+
+               msg_db_free(msg_handle, db_res);
 
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
 #ifdef MSG_NOTI_INTEGRATION
                snprintf(sqlQuery, sizeof(sqlQuery),
                                "A.ADDRESS_VAL, "
                                "B.DISPLAY_TIME, "
                                "B.MSG_ID, "
-                               "B.SUBJECT, "
-                               "B.MSG_TEXT, "
+                               "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.SUBJECT ELSE \"restricted message\" END), "
+                               "(CASE WHEN B.DPM_RESTRICTED = 0 THEN B.MSG_TEXT ELSE \"restricted message\" END), "
                                "B.MAIN_TYPE, "
-                               "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, "
-                               "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, "
-                               "(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) "
-                               "FROM %s A, %s B "
-                               "WHERE A.CONV_ID=B.CONV_ID "
-                               "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
+                               "B.CONV_ID, "
+                               "(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), "
+                               "B.ATTACHMENT_COUNT, "
+                               "B.SIM_INDEX "
+                               "FROM %s B "
+                               "LEFT JOIN %s A ON A.CONV_ID=B.CONV_ID "
+                               "WHERE B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
                                "AND B.STORAGE_ID = %d "
                                "ORDER BY B.DISPLAY_TIME DESC;",
-                               MSG_SMS_TYPE,
-                               MSG_MMS_TYPE,
                                MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
-                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                               MSGFW_MESSAGE_TABLE_NAME,
+                               MSGFW_ADDRESS_TABLE_NAME,
                                MSG_INBOX_ID, MSG_CBMSGBOX_ID,
                                MSG_STORAGE_PHONE);
 #else
@@ -1712,9 +1931,9 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                }
 
                if (row_cnt > 0) {
-                       smsUnreadCnt = atoi(db_res[col_cnt+6]);
-                       mmsUnreadCnt = atoi(db_res[col_cnt+7]);
-                       msgSize = atoi(db_res[col_cnt+8]);
+                       msgSize = atoi(db_res[col_cnt+7]);
+                       attachmentCnt = atoi(db_res[col_cnt+8]);
+                       noti_info->sim_idx = atoi(db_res[col_cnt+9]);
 
                        noti_info->count = smsUnreadCnt + mmsUnreadCnt;
 
@@ -1725,6 +1944,8 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
 
                                noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]);
 
+                               noti_info->conv_id = atoi(db_res[col_cnt+6]);
+
                                mainType = (unsigned char)atoi(db_res[col_cnt+5]);
 
                                if (mainType == MSG_MMS_TYPE) {
@@ -1759,6 +1980,8 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                                                g_free(msg_size_unit_kb);
                                        }
 
+                                       noti_info->active_media_cnt = attachmentCnt;
+
                                } else {
                                        snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]);
                                }
@@ -1774,7 +1997,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
 
                                if (!isForInstantMessage) {
                                        if (noti_info->id > 0 && noti_info->count == 1) {
-                                               noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
                                                if (noti_err != NOTIFICATION_ERROR_NONE) {
                                                        MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                                }
@@ -1798,7 +2021,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                                if (!isForInstantMessage) {
                                        /* No unread message. */
                                        if (noti_info->id > 0) {
-                                               noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
                                                if (noti_err != NOTIFICATION_ERROR_NONE) {
                                                        MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                                }
@@ -1894,7 +2117,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                        if (!isForInstantMessage) {
                                /* No unread message. */
                                if (noti_info->id > 0) {
-                                       noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                       noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
                                        if (noti_err != NOTIFICATION_ERROR_NONE) {
                                                MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                        }
@@ -1992,7 +2215,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                                if (!isForInstantMessage) {
                                        /* No unread message. */
                                        if (noti_info->id > 0) {
-                                               noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
                                                if (noti_err != NOTIFICATION_ERROR_NONE) {
                                                        MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                                }
@@ -2090,7 +2313,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
 
                                if (!isForInstantMessage) {
                                        if (noti_info->id > 0 && noti_info->count == 1) {
-                                               noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
                                                if (noti_err != NOTIFICATION_ERROR_NONE) {
                                                        MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                                }
@@ -2108,7 +2331,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                                if (!isForInstantMessage) {
                                        /* No unread message. */
                                        if (noti_info->id > 0) {
-                                               noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
                                                if (noti_err != NOTIFICATION_ERROR_NONE) {
                                                        MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                                }
@@ -2196,6 +2419,9 @@ int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
        case MSG_MGR_NOTI_TYPE_FAILED:
                vconf_get_int(MSG_SENTFAIL_NOTI_ID, &noti_id);
                break;
+       case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
+               vconf_get_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, &noti_id);
+               break;
        case MSG_MGR_NOTI_TYPE_VOICE_1: {
                char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
                snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
@@ -2253,6 +2479,9 @@ void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_id
        case MSG_MGR_NOTI_TYPE_FAILED:
                err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id);
                break;
+       case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT:
+               err = vconf_set_int(VCONFKEY_MESSAGE_READ_REPORT_SENT_NOTI_ID, noti_id);
+               break;
        case MSG_MGR_NOTI_TYPE_VOICE_1: {
                char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
                snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
@@ -2451,7 +2680,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_
                snprintf(sqlQuery, sizeof(sqlQuery),
                                "STATUS "
                                "FROM %s "
-                               "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';",
+                               "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE \"%%%s\";",
                                MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, msg_mgr_normalize_number(msg_info->addressVal));
 
                MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery);
@@ -2514,10 +2743,30 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_
                addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
                addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
 
-               noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
+               if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE) {
+                       if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
+                               noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
+
+                       int activated_conv_id = -1;
+                       vconf_get_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, &activated_conv_id);
+
+                       if (activated_conv_id == -1) {
+                               noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
+                       } else if (activated_conv_id == 0) {
+                               noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
+                               noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
+                       } else if (activated_conv_id > 0){
+                               noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
+
+                               if (activated_conv_id != noti_info->conv_id)
+                                       noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
+                               else
+                                       MSG_MGR_WARN("No adding Notification : activated conv id [%d] / notification conv id [%d]", activated_conv_id, noti_info->conv_id);
+                       }
+               } else {
+                       noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_LOCK|NOTIFICATION_DISPLAY_APP_INDICATOR;
+               }
 
-               if (noti_info->active_noti_button_num == 0)
-                       noti_info->active_noti_button_num = 3;
                break;
        }
        case MSG_MGR_NOTI_TYPE_CB: {
@@ -2536,7 +2785,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_
                else
                        noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
 
-               noti_info->active_noti_button_num = 1;
+               noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_CB_MESSAGE;
                break;
        }
        case MSG_MGR_NOTI_TYPE_SIM: {
@@ -2555,8 +2804,8 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_
                else
                        noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
 
-               if (noti_info->active_noti_button_num == 0)
-                       noti_info->active_noti_button_num = 3;
+               if (noti_info->active_noti_button_num == MSG_ACTIVE_NOTI_BUTTON_NUM_NONE)
+                       noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NORMAL_MESSAGE;
                break;
        }
        case MSG_MGR_NOTI_TYPE_FAILED: {
@@ -2583,7 +2832,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_
        }
 
        if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE)
-               noti_info->active_noti_button_num = 0;
+               noti_info->active_noti_button_num = MSG_ACTIVE_NOTI_BUTTON_NUM_NONE;
 
        MSG_MGR_END();
 }
@@ -2823,6 +3072,9 @@ int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
        if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
                MSG_MGR_DEBUG("Fail to notification_set_display_applist");
 
+       if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE)
+               MSG_MGR_DEBUG("Fail to notification_set_pkgname");
+
        if (notification_post(noti) != NOTIFICATION_ERROR_NONE)
                MSG_MGR_DEBUG("Fail to notification_post");