From: Kyeonghun Lee Date: Thu, 18 Feb 2016 02:35:25 +0000 (+0900) Subject: fix JIRA issue: TNEF-6774 X-Git-Tag: accepted/tizen/common/20160222.162154^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b691c0506262c9f86fe2ccf2f4836994d771efd2;p=platform%2Fcore%2Fapi%2Fmessages.git fix JIRA issue: TNEF-6774 Change-Id: I0300e2bde35a904eee58773c6ed17929bc06b7dc Signed-off-by: Kyeonghun Lee --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bb1380f..4f6d955 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(dependents "dlog glib-2.0 msg-service capi-base-common capi-appfw-application capi-system-info privacy-manager-client") +SET(dependents "dlog glib-2.0 msg-service capi-base-common capi-appfw-application capi-content-mime-type capi-system-info privacy-manager-client") INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) diff --git a/packaging/capi-messaging-messages.spec b/packaging/capi-messaging-messages.spec index edc1417..a43b58f 100644 --- a/packaging/capi-messaging-messages.spec +++ b/packaging/capi-messaging-messages.spec @@ -15,6 +15,7 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(msg-service) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-content-mime-type) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(privacy-manager-client) Requires(post): /sbin/ldconfig diff --git a/src/messages.c b/src/messages.c index 5d2b841..36aa9fb 100644 --- a/src/messages.c +++ b/src/messages.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -1677,6 +1678,7 @@ int _messages_get_media_type_from_filepath(const char *filepath) int len; int ret; char *file_ext; + char *mime_type = NULL; if (NULL == filepath) return MESSAGES_MEDIA_UNKNOWN; @@ -1687,17 +1689,27 @@ int _messages_get_media_type_from_filepath(const char *filepath) return MESSAGES_MEDIA_UNKNOWN; /* check extension of file */ - file_ext = (char *)&filepath[len - 4]; + file_ext = strrchr(filepath, '.'); + if (file_ext == NULL) + return MESSAGES_MEDIA_UNKNOWN; + + file_ext++; - if (strncmp(file_ext, ".jpg", 4) != 0 && strncmp(file_ext, ".gif", 4) != 0 && strncmp(file_ext, ".bmp", 4) != 0 && strncmp(file_ext, ".png", 4) != 0) + mime_type_get_mime_type(file_ext, &mime_type); + if (mime_type == NULL) + return MESSAGES_MEDIA_UNKNOWN; + + if (g_str_has_prefix(mime_type, "image")) ret = MESSAGES_MEDIA_IMAGE; - else if (strncmp(file_ext, ".mp4", 4) != 0 && strncmp(file_ext, ".3gp", 4) != 0) + else if (g_str_has_prefix(mime_type, "video")) ret = MESSAGES_MEDIA_VIDEO; - else if (strncmp(file_ext, ".mid", 4) != 0 && strncmp(file_ext, ".aac", 4) != 0 && strncmp(file_ext, ".amr", 4) != 0) + else if (g_str_has_prefix(mime_type, "audio")) ret = MESSAGES_MEDIA_AUDIO; else ret = MESSAGES_MEDIA_UNKNOWN; + g_free(mime_type); + return ret; }