resolve TSAM-8516: set number of attachments for active notification 78/90778/2
authorKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 4 Oct 2016 08:05:38 +0000 (17:05 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 4 Oct 2016 08:07:32 +0000 (17:07 +0900)
Change-Id: Id8d0b80e850b58ff4c36ef7982e952b7f804f4a8

manager/src/msg-manager-notification.cpp
plugin/mms_plugin/MmsPluginAppBase.cpp

index ea6512483d22efdd3cc9df198fa27543346a691e..081d32740d63234560923e3da7b9cda8e7a97fde 100644 (file)
@@ -1110,11 +1110,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);
+                                       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);
+                               }
+                       }
                } 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;
        }
@@ -1578,7 +1598,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
@@ -1712,7 +1732,8 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                                "B.CONV_ID, "
                                "(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) "
+                               "(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 "
                                "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) "
@@ -1757,6 +1778,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                        smsUnreadCnt = atoi(db_res[col_cnt+7]);
                        mmsUnreadCnt = atoi(db_res[col_cnt+8]);
                        msgSize = atoi(db_res[col_cnt+9]);
+                       attachmentCnt = atoi(db_res[col_cnt+10]);
 
                        noti_info->count = smsUnreadCnt + mmsUnreadCnt;
 
@@ -1803,6 +1825,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]);
                                }
index 2677ed9860f37a1fe82fc7f88fd491453e747215..ba1b6c37acbe40679083ae9e04cc1d7a6afecdf0 100755 (executable)
@@ -231,11 +231,21 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allo
        }
 
        int attachCnt = _MsgMmsGetAttachCount(pMmsMsg);
+
+       MMS_ATTACH_S *attach = NULL;
+       int attachCntExceptText = attachCnt;
+       for (int i = 0; i < attachCnt; i++) {
+               attach = (MMS_ATTACH_S *)g_list_nth_data(pMmsMsg->attachlist, i);
+               if (g_strcmp0(attach->szContentType, "text/plain") == 0)
+                       attachCntExceptText--;
+       }
+
+
        if (attachCnt > 0) {
                MMS_ATTACH_S *pAttach = _MsgMmsGetAttachment(pMmsMsg, 0);
 
                MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_ATTACH, pAttach->szFileName, attachCnt);
-               MmsPluginStorage::instance()->updateMmsAttachCount(msgId, attachCnt); /* for Get Message */
+               MmsPluginStorage::instance()->updateMmsAttachCount(msgId, attachCntExceptText); /* for Get Message */
 
                if (attachment_name == NULL) {
                        attachment_name = pAttach->szFileName;
@@ -246,7 +256,7 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allo
 
        if (attachCnt + ref_attach_count > 0 && attachment_name) {
                MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_ATTACH, attachment_name, attachCnt + ref_attach_count);
-               MmsPluginStorage::instance()->updateMmsAttachCount(msgId, attachCnt + ref_attach_count);
+               MmsPluginStorage::instance()->updateMmsAttachCount(msgId, attachCntExceptText + ref_attach_count);
        }
 
        return MSG_SUCCESS;