apply Tizen 3.0 Message UX Guide
[platform/core/messaging/msg-service.git] / externals / MsgNotificationWrapper.cpp
index bfeb8f0..40b7409 100755 (executable)
@@ -20,6 +20,7 @@
 #include "MsgGconfWrapper.h"
 #include "MsgNotificationWrapper.h"
 #include "MsgDevicedWrapper.h"
+#include "MsgSqliteWrapper.h"
 
 extern "C"
 {
@@ -89,6 +90,10 @@ msg_error_t MsgInsertNotification(MSG_MESSAGE_INFO_S *msg_info)
        case MSG_READORGIND_MMS:
                noti_type = MSG_NOTI_TYPE_MMS_READ_REPORT;
                break;
+       case MSG_READRECIND_MMS:
+       case MSG_READREPLY_MMS:
+               noti_type = MSG_NOTI_TYPE_MMS_READ_REPORT_SENT;
+               break;
        default:
 #ifdef MSG_NOTI_INTEGRATION
                noti_type = MSG_NOTI_TYPE_NORMAL;
@@ -119,6 +124,7 @@ msg_error_t MsgInsertNotification(MSG_MESSAGE_INFO_S *msg_info)
        case MSG_NOTI_TYPE_VOICE_2:
        case MSG_NOTI_TYPE_MWI:
        case MSG_NOTI_TYPE_CLASS0:
+       case MSG_NOTI_TYPE_MMS_READ_REPORT_SENT:
                err = MsgAddNotification(noti_type, msg_info);
                break;
        default:
@@ -178,6 +184,74 @@ msg_error_t MsgDeleteReportNotification(const char *addr)
        return err;
 }
 
+msg_error_t MsgIsSentReadReportNotificationExist(int threadId, int *msgId)
+{
+       MSG_BEGIN();
+
+       msg_error_t err = MSG_SUCCESS;
+
+#ifndef MSG_WEARABLE_PROFILE
+       char sqlQuery[MAX_QUERY_LEN+1];
+       int readReportSentMsgId = 0;
+
+       if (MsgSettingGetInt(VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID, &readReportSentMsgId) != MSG_SUCCESS)
+               MSG_INFO("MsgSettingGetInt() is failed");
+
+       MsgDbHandler *dbHandle = getDbHandle();
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE CONV_ID = %d AND MSG_ID = %d;",
+                       MSGFW_MESSAGE_TABLE_NAME,  threadId, readReportSentMsgId);
+
+       if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+               dbHandle->finalizeQuery();
+               MSG_DEBUG("MsgId[%d] is in ThreadId[%d]", readReportSentMsgId, threadId);
+               *msgId = readReportSentMsgId;
+               return err;
+       }
+
+       dbHandle->finalizeQuery();
+
+       MSG_DEBUG("MsgId[%d] is not in ThreadId[%d]", readReportSentMsgId, threadId);
+
+       err = MSG_ERR_UNKNOWN;
+#endif /* MSG_WEARABLE_PROFILE */
+       MSG_END();
+       return err;
+}
+
+msg_error_t MsgDeleteSentReadReportNotification(int msgId)
+{
+       MSG_BEGIN();
+
+       msg_error_t err = MSG_SUCCESS;
+
+#ifndef MSG_WEARABLE_PROFILE
+       int readReportSentMsgId = 0;
+
+       if (MsgSettingGetInt(VCONFKEY_MESSAGE_READ_REPORT_SENT_MSG_ID, &readReportSentMsgId) != MSG_SUCCESS)
+               MSG_INFO("MsgSettingGetInt() is failed");
+
+       if (readReportSentMsgId != msgId) {
+               MSG_ERR("Invalid read report sent notification msgId, noti msgId[%d], requested msgId[%d]", readReportSentMsgId, msgId);
+               return MSG_ERR_UNKNOWN;
+       }
+
+       bundle *bundle_data = bundle_create();
+
+       bundle_add_str(bundle_data, "cmd", "del_sent_read_report_noti");
+
+       err = msg_launch_app(MSG_MGR_APP_ID, bundle_data);
+
+       bundle_free(bundle_data);
+
+#endif /* MSG_WEARABLE_PROFILE */
+       MSG_END();
+       return err;
+}
+
 msg_error_t MsgAddReportNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info)
 {
        msg_error_t err = MSG_SUCCESS;
@@ -287,6 +361,9 @@ msg_error_t MsgAddNotification(msg_notification_type_t noti_type, MSG_MESSAGE_IN
        case MSG_NOTI_TYPE_CLASS0:
                bundle_add_str(bundle_data, "type", "class0");
                break;
+       case MSG_NOTI_TYPE_MMS_READ_REPORT_SENT:
+               bundle_add_str(bundle_data, "type", "read_report_sent");
+               break;
        default:
                break;
        }