#include "MmsPluginDebug.h"
#include "MmsPluginStorage.h"
#include "MmsPluginMessage.h"
-#include "MmsPluginMIME.h"
#include "MmsPluginAppBase.h"
#include "MmsPluginUtil.h"
-#include "MmsPluginTcs.h"
#include "MsgUtilFile.h"
+#include "MsgUtilMime.h"
msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allow_malware, const char *raw_filepath);
void MmsPluginAppBase::getFirstPageTextFilePath(char *textBuf, int textBufSize)
{
-
MMS_PAGE_S *pPage = NULL;
MMS_MEDIA_S *pMedia = NULL;
if (pMmsMsgData == NULL)
return;
- // Get the text data from the 1st slide.
+ /* Get the text data from the 1st slide. */
if (pMmsMsgData->pageCnt > 0) {
-
pPage = _MsgMmsGetPage(pMmsMsgData, 0);
if (pPage) {
-
for (int j = 0; j < pPage->mediaCnt; ++j) {
-
pMedia = _MsgMmsGetMedia(pPage, j);
if (pMedia && pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) {
-
MimeType mimeType = MIME_UNKNOWN;
- MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
+ MsgGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
if (mimeType == MIME_TEXT_X_VCALENDAR || mimeType == MIME_TEXT_X_VCARD || mimeType == MIME_TEXT_X_VTODO || mimeType == MIME_TEXT_X_VNOTE) {
- MSG_DEBUG("Media Type is Text, but Vobject file [%s]", pMedia->szFilePath);
+ MSG_SEC_DEBUG("Media Type is Text, but Vobject file [%s]", pMedia->szFilePath);
} else {
- MSG_DEBUG("Text path : [%s]", pMedia->szFilePath);
- snprintf(textBuf, textBufSize, "%s", pMedia->szFilePath);//Set Text Filepath of First Pages
+ MSG_SEC_DEBUG("Text path : [%s]", pMedia->szFilePath);
+ snprintf(textBuf, textBufSize, "%s", pMedia->szFilePath); /* Set Text Filepath of First Pages */
}
break;
}
}
}
+ } else {
+ /* Set filepath of the first text/plain attachment to display preview text on notification */
+ if (pMmsMsgData->attachlist) {
+ GList *l = pMmsMsgData->attachlist;
+ while (l) {
+ MMS_ATTACH_S *attach = (MMS_ATTACH_S *)l->data;
+ if (g_strcmp0(attach->szContentType, "text/plain") == 0) {
+ MSG_SEC_DEBUG("The first text filepath for multipart: (%s)", attach->szFilePath);
+ snprintf(textBuf, textBufSize, "%s", attach->szFilePath);
+ break;
+ }
+
+ l = g_list_next(l);
+ }
+ }
}
return;
}
-//FIXME::need to move AppBase
+/* FIXME::need to move AppBase */
msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allow_malware, const char *raw_filepath)
{
MMS_PAGE_S *pPage = NULL;
if (pMmsMsg == NULL)
return MSG_ERR_NULL_POINTER;
- MmsPluginStorage::instance()->removePreviewInfo(msgId); //remove exist previnfo
+ MmsPluginStorage::instance()->removePreviewInfo(msgId); /* remove exist previnfo */
- //scan malware in raw file
+ /* scan malware in raw file */
if (raw_filepath && strlen(raw_filepath) > 0 && MsgAccessFile(raw_filepath, F_OK) == true) {
- int tcs_ret = 0; // MmsPluginTcsScanFile(raw_filepath, &bc_level);
+ int tcs_ret = MsgTcsScanFile(raw_filepath, &bc_level);
if (tcs_ret == 0) {
if (bc_level > -1) {
MSG_DEBUG("malware exist, level = %d", bc_level);
}
}
- //check ref type and increase attach count
+ /* check ref type and increase attach count */
if (pMmsMsg->pageCnt > 0) {
for (int i = 0; i < pMmsMsg->pageCnt; i++) {
pPage = _MsgMmsGetPage(pMmsMsg, i);
if (pPage) {
for (int j = 0; j < pPage->mediaCnt; j++) {
pMedia = _MsgMmsGetMedia(pPage, j);
- if (pMedia) { //IF Vobject type add to Attach in Preview data
-
+ if (pMedia) { /* IF Vobject type add to Attach in Preview data */
MimeType mimeType = MIME_UNKNOWN;
- MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
+ MsgGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
if (mimeType == MIME_TEXT_X_VCALENDAR || mimeType == MIME_TEXT_X_VCARD) {
-
MSG_DEBUG("Unsupported File [%s] It will be add to attach list", pMedia->szFilePath);
ref_attach_count++;
attachment_name = pMedia->szFileName;
}
}
-
}
}
}
if (pMmsMsg->pageCnt > 0) {
-
MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_PAGE, (char *)"pagecount", pMmsMsg->pageCnt);
pPage = _MsgMmsGetPage(pMmsMsg, 0);
if (pPage) {
for (int j = 0; j < pPage->mediaCnt; j++) {
-
pMedia = _MsgMmsGetMedia(pPage, j);
if (pMedia == NULL) {
MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_AUDIO, pMedia->szFileName);
}
} else {
-
- if (j == 0) { //First Page, First Media
+ if (j == 0) { /* First Page, First Media */
MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_1ST_MEDIA, pMedia->szFilePath);
}
memset(szFileName, 0x00, MSG_FILENAME_LEN_MAX+1);
memset(thumbPath, 0x00, MSG_FILEPATH_LEN_MAX);
- MSG_DEBUG("drm type = %d, %s", pMedia->drmType, pMedia->szFilePath);
+ MSG_SEC_DEBUG("drm type = %d, %s", pMedia->drmType, pMedia->szFilePath);
if (pMedia->drmType == MSG_DRM_TYPE_NONE) {
-
- snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%d.mms",msgId);
+ snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%d.mms", msgId);
if ((pszExt = strrchr(pMedia->szFilePath, '.')) != NULL && !strcasecmp(pszExt, ".png")) {
snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, "%s%s.png", MSG_THUMBNAIL_PATH, szFileName);
snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, "%s%s.jpg", MSG_THUMBNAIL_PATH, szFileName);
}
- if (MmsMakeImageThumbnail(pMedia->szFilePath, thumbPath) == true) {
+ if (MakeThumbnail(pMedia->szFilePath, thumbPath) == true) {
if (pMedia->mediatype == MMS_SMIL_MEDIA_IMG) {
MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_IMG, thumbPath);
} else {
}
}
}
- } // end for
+ } /* end for */
} else {
MSG_DEBUG("There is no page");
}
int attachCnt = _MsgMmsGetAttachCount(pMmsMsg);
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, attachCnt); /* for Get Message */
if (attachment_name == NULL) {
attachment_name = pAttach->szFileName;
}
-
} else {
MSG_DEBUG("There is no attachment");
}
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);
}