Remove ini parser 94/84294/2
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 18 Aug 2016 02:05:15 +0000 (11:05 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 18 Aug 2016 02:08:01 +0000 (11:08 +0900)
Change-Id: I233710cc8fe37051d132f803b2233f66b84448dc
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
CMakeLists.txt
packaging/libmedia-service.spec
src/common/media-svc-media.c
src/common/media-svc-util.c
src/common/media-svc.c
src/include/common/media-svc-util.h

index 01593c9c8e36c96b5ed0d8d682489abef29b72e7..d71de32a0e9e4fe3eddcfb053b53d68f8c803571 100755 (executable)
@@ -55,7 +55,7 @@ EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
 
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 dlog sqlite3 db-util libexif mm-fileinfo media-thumbnail libmedia-utils aul uuid vconf iniparser capi-media-image-util)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dlog sqlite3 db-util libexif mm-fileinfo media-thumbnail libmedia-utils aul uuid vconf capi-media-image-util)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index f8eb22958f29e4ef5c2ec16e540657722b3bd988..0628fdfdd1326720f7e181975fd163331a49d71f 100644 (file)
@@ -22,7 +22,6 @@ BuildRequires:  pkgconfig(media-thumbnail)
 BuildRequires:  pkgconfig(libmedia-utils)
 BuildRequires:  pkgconfig(uuid)
 BuildRequires:  pkgconfig(libtzplatform-config)
-BuildRequires:  pkgconfig(iniparser)
 BuildRequires:  pkgconfig(capi-media-image-util)
 
 %description
index 834beaaf7356372148ee9f778cbb255f0b82a217..f1a364768a65000ba9e50f7fc744522f794fbe98 100755 (executable)
@@ -219,7 +219,6 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
 {
        int ret = MS_MEDIA_ERR_NONE;
        char *burst_id = NULL;
-       int ini_val = _media_svc_get_ini_value();
 
        const char *db_fields = "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, folder_uuid, \
                                        thumbnail_path, title, album_id, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, description, \
@@ -245,24 +244,22 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                }
 
                /* Get thumbnail for burst shot */
-               if (ini_val == 1) {
-                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-                       int width = 0;
-                       int height = 0;
-
-                       ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid);
-                       if (ret == MS_MEDIA_ERR_NONE) {
-                               ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
-                               if (ret != MS_MEDIA_ERR_NONE)
-                                       content_info->thumbnail_path = NULL;
-                       }
-
-                       if (content_info->media_meta.width <= 0)
-                               content_info->media_meta.width = width;
+               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+               int width = 0;
+               int height = 0;
 
-                       if (content_info->media_meta.height <= 0)
-                               content_info->media_meta.height = height;
+               ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid);
+               if (ret == MS_MEDIA_ERR_NONE) {
+                       ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
+                       if (ret != MS_MEDIA_ERR_NONE)
+                               content_info->thumbnail_path = NULL;
                }
+
+               if (content_info->media_meta.width <= 0)
+                       content_info->media_meta.width = width;
+
+               if (content_info->media_meta.height <= 0)
+                       content_info->media_meta.height = height;
        }
 
        /*Update Pinyin If Support Pinyin*/
index a1da9fcfa8cdad9666d18f8c31e821e295d97f8b..70cb66ad5472258a564c036fa2eae9193f882f43 100755 (executable)
 #define _3GP_FILE ".3gp"
 #define _MP4_FILE ".mp4"
 #define _ASF_FILE ".asf"
-#define MEDIA_SVC_INI_GET_INT(dict, key, value, default) \
-       do { \
-               value = iniparser_getint(dict, key, default); \
-               media_svc_debug("get %s = %d", key, value); \
-       } while (0)
-#define MEDIA_SVC_INI_DEFAULT_PATH SYSCONFDIR"/multimedia/media_content_config.ini"
 #define MEDIA_SVC_ARTWORK_SIZE 2000
 
-static int g_ini_value = -1;
-
 typedef struct {
        char content_type[15];
        int category_by_mime;
@@ -2474,25 +2466,6 @@ bool _media_svc_check_pinyin_support(void)
        return TRUE;
 }
 
-int _media_svc_get_ini_value()
-{
-       if (g_ini_value == -1) {
-               dictionary *dict = NULL;
-
-               dict = iniparser_load(MEDIA_SVC_INI_DEFAULT_PATH);
-               if (!dict) {
-                       media_svc_error("%s load failed", MEDIA_SVC_INI_DEFAULT_PATH);
-                       return -1;
-               }
-
-               MEDIA_SVC_INI_GET_INT(dict, "media-content-config:thumbnail_activation", g_ini_value, 0);
-               iniparser_freedict(dict);
-       }
-       media_svc_debug("Thumb-server activation level = %d", g_ini_value);
-
-       return g_ini_value;
-}
-
 char* _media_svc_get_title_from_path(const char *path)
 {
        char *filename = NULL;
index d59ed5132f5e235ed6cdab7a7e7c9da205979707..14863dc00d204a4f23b884797880116ec04b4a20 100755 (executable)
@@ -439,7 +439,6 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
        sqlite3 *db_handle = (sqlite3 *)handle;
        char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
        media_svc_media_type_e media_type;
-       int ini_val = _media_svc_get_ini_value();
 
        media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
@@ -473,28 +472,25 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
 
        ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
        media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-#if 1
+
        /* Extracting thumbnail */
-       if (ini_val == 1) {
-               if (content_info.thumbnail_path == NULL) {
-                       if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-                               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-                               int width = 0;
-                               int height = 0;
+       if (content_info.thumbnail_path == NULL) {
+               if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+                       int width = 0;
+                       int height = 0;
 
-                               ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
-                               if (ret == MS_MEDIA_ERR_NONE)
-                                       ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
+                       ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
+                       if (ret == MS_MEDIA_ERR_NONE)
+                               ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
 
-                               if (content_info.media_meta.width <= 0)
-                                       content_info.media_meta.width = width;
+                       if (content_info.media_meta.width <= 0)
+                               content_info.media_meta.width = width;
 
-                               if (content_info.media_meta.height <= 0)
-                                       content_info.media_meta.height = height;
-                       }
+                       if (content_info.media_meta.height <= 0)
+                               content_info.media_meta.height = height;
                }
        }
-#endif
 
        ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, FALSE, FALSE, uid);
 
@@ -897,7 +893,6 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *db_handle = (sqlite3 *)handle;
        media_svc_media_type_e media_type;
-       int ini_val = _media_svc_get_ini_value();
 
        media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
@@ -913,25 +908,23 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
                return ret;
 
        /* Initialize thumbnail information to remake thumbnail. */
-       if (ini_val == 1) {
-               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1];
-               ret = _media_svc_get_thumbnail_path_by_path(db_handle, storage_id, path, thumb_path);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       _media_svc_destroy_content_info(&content_info);
-                       return ret;
-               }
+       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1];
+       ret = _media_svc_get_thumbnail_path_by_path(db_handle, storage_id, path, thumb_path);
+       if (ret != MS_MEDIA_ERR_NONE) {
+               _media_svc_destroy_content_info(&content_info);
+               return ret;
+       }
 
-               if (g_file_test(thumb_path, G_FILE_TEST_EXISTS) && (STRING_VALID(MEDIA_SVC_THUMB_DEFAULT_PATH)) && (strncmp(thumb_path, MEDIA_SVC_THUMB_DEFAULT_PATH, strlen(MEDIA_SVC_THUMB_DEFAULT_PATH)) != 0)) {
-                       ret = _media_svc_remove_file(thumb_path);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               media_svc_error("_media_svc_remove_file failed : %s", thumb_path);
-               }
+       if (g_file_test(thumb_path, G_FILE_TEST_EXISTS) && (STRING_VALID(MEDIA_SVC_THUMB_DEFAULT_PATH)) && (strncmp(thumb_path, MEDIA_SVC_THUMB_DEFAULT_PATH, strlen(MEDIA_SVC_THUMB_DEFAULT_PATH)) != 0)) {
+               ret = _media_svc_remove_file(thumb_path);
+               if (ret != MS_MEDIA_ERR_NONE)
+                       media_svc_error("_media_svc_remove_file failed : %s", thumb_path);
+       }
 
-               ret = _media_svc_update_thumbnail_path(storage_id, path, NULL, uid);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       _media_svc_destroy_content_info(&content_info);
-                       return ret;
-               }
+       ret = _media_svc_update_thumbnail_path(storage_id, path, NULL, uid);
+       if (ret != MS_MEDIA_ERR_NONE) {
+               _media_svc_destroy_content_info(&content_info);
+               return ret;
        }
 
        /* Get notification info */
@@ -960,30 +953,26 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
                _media_svc_destroy_content_info(&content_info);
                return ret;
        }
-#if 1
+
        /* Extracting thumbnail */
-       if (ini_val == 1) {
-               if (content_info.thumbnail_path == NULL) {
-                       if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-                               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-                               int width = 0;
-                               int height = 0;
+       if (content_info.thumbnail_path == NULL) {
+               if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+                       int width = 0;
+                       int height = 0;
 
-                               ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
-                               if (ret == MS_MEDIA_ERR_NONE)
-                                       ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
+                       ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
+                       if (ret == MS_MEDIA_ERR_NONE)
+                               ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
 
-                               if (content_info.media_meta.width <= 0)
-                                       content_info.media_meta.width = width;
+                       if (content_info.media_meta.width <= 0)
+                               content_info.media_meta.width = width;
 
-                               if (content_info.media_meta.height <= 0)
-                                       content_info.media_meta.height = height;
-                       }
+                       if (content_info.media_meta.height <= 0)
+                               content_info.media_meta.height = height;
                }
        }
 
-#endif
-
        ret = _media_svc_update_item_with_data(storage_id, &content_info, uid);
 
        if (ret == MS_MEDIA_ERR_NONE) {
@@ -1711,24 +1700,21 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv
                media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
 
                /* Extracting thumbnail */
-               int ini_val = _media_svc_get_ini_value();
-               if (ini_val == 1) {
-                       if (_new_content_info.thumbnail_path == NULL) {
-                               if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-                                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
-                                       int width = 0;
-                                       int height = 0;
-
-                                       ret = _media_svc_request_thumbnail_with_origin_size(_new_content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
-                                       if (ret == MS_MEDIA_ERR_NONE)
-                                               ret = __media_svc_malloc_and_strncpy(&(_new_content_info.thumbnail_path), thumb_path);
-
-                                       if (_new_content_info.media_meta.width <= 0)
-                                               _new_content_info.media_meta.width = width;
-
-                                       if (_new_content_info.media_meta.height <= 0)
-                                               _new_content_info.media_meta.height = height;
-                               }
+               if (_new_content_info.thumbnail_path == NULL) {
+                       if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+                               char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+                               int width = 0;
+                               int height = 0;
+
+                               ret = _media_svc_request_thumbnail_with_origin_size(_new_content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid);
+                               if (ret == MS_MEDIA_ERR_NONE)
+                                       ret = __media_svc_malloc_and_strncpy(&(_new_content_info.thumbnail_path), thumb_path);
+
+                               if (_new_content_info.media_meta.width <= 0)
+                                       _new_content_info.media_meta.width = width;
+
+                               if (_new_content_info.media_meta.height <= 0)
+                                       _new_content_info.media_meta.height = height;
                        }
                }
        }
index 37b28bb9a1c2786ad42dde6bc6038f17c10dc740..1d37260a9c8d8a749dfa3e56b4286f5384c90b96 100755 (executable)
@@ -27,7 +27,6 @@
 #include <string.h>
 #include <stdbool.h>
 #include <sqlite3.h>
-#include <iniparser.h>
 #include "media-svc-types.h"
 #include "media-svc-env.h"
 
@@ -71,7 +70,6 @@ int _media_svc_request_thumbnail_with_origin_size(const char *path, char *thumb_
 int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str);
 bool _media_svc_check_pinyin_support(void);
 int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type);
-int _media_svc_get_ini_value();
 char *_media_svc_get_title_from_path(const char *path);
 void _media_svc_print_stderror(void);