Remove unused code 68/138368/3
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 12 Jul 2017 02:56:56 +0000 (11:56 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Wed, 12 Jul 2017 06:02:55 +0000 (15:02 +0900)
Remove unused enums, values, APIs.

Change-Id: I9f9e66581dc1ef19ceb10f83abe7dcb88eb563e7
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-thumbnail.h
server/include/thumb-server-internal.h
server/thumb-server-internal.c
src/include/ipc/media-thumb-ipc.h
src/include/media-thumb-internal.h
src/include/util/media-thumb-util.h
src/ipc/media-thumb-ipc.c
src/util/media-thumb-util.c

index 1f8628f0150a8c60e80c9e3d14ce035ff639557c..3285b0a3045dac3b2c36a6d4053b7113cd7b027c 100755 (executable)
@@ -32,22 +32,16 @@ extern "C" {
 #endif
 
 
-
-
 typedef int (*ThumbFunc) (int error_code, char* path, void* data);
 
 typedef void (*ThumbRawFunc) (int error_code, int request_id, const char* org_path, int thumb_width, int thumb_height, unsigned char* thumb_data, int thumb_size, void* data);
 
 int thumbnail_request_from_db_async(unsigned int request_id, const char *origin_path, ThumbFunc func, void *user_data, uid_t uid);
-
 int thumbnail_request_extract_raw_data_async(int request_id, const char *origin_path, int width, int height, ThumbRawFunc func, void *user_data, uid_t uid);
-
 int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max_length, uid_t uid);
 
 int thumbnail_request_cancel_media(unsigned int request_id, const char *origin_path);
-
 int thumbnail_request_cancel_raw_data(int request_id);
-
 int thumbnail_request_cancel_all(bool is_raw_data);
 
 #ifdef __cplusplus
index 44b0d16577beedf0fe423a5c131cddd8564583b6..5e0c47f01d1f49d588eaa1a0135556a52e5f86c7 100755 (executable)
 #ifndef _THUMB_DAEMON_INTERNAL_H_
 #define _THUMB_DAEMON_INTERNAL_H_
 
-typedef enum {
-       MEDIA_SERVER_PID = 1,
-       OTHERS_PID = 0,
-       GETPID_FAIL = -1
-} _pid_e;
-
-typedef enum {
-       BLOCK_MODE = 0,
-       TIMEOUT_MODE = 1
-} _server_mode_e;
-
 gboolean _thumb_daemon_start_jobs(gpointer data);
 void _thumb_daemon_finish_jobs(void);
 gboolean _thumb_server_prepare_socket(int *sock_fd);
@@ -45,20 +34,14 @@ gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpoi
 int _thumbnail_get_data(const char *origin_path,
                                                char *thumb_path,
                                                unsigned char **data,
-                                               int *size,
                                                int *width,
                                                int *height,
                                                int *alpha,
                                                bool *is_saved);
 
-int _thumbnail_get_raw_data(const char *origin_path,
-                                               int *width,
-                                               int *height,
-                                               unsigned char **data,
-                                               int *size);
+int _thumbnail_get_raw_data(const char *origin_path, int *width, int *height, unsigned char **data, int *size);
 
 int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg);
-
 int _media_thumb_process_raw(thumbMsg *req_msg, thumbMsg *res_msg);
 
 #endif /*_THUMB_DAEMON_INTERNAL_H_*/
index ef2cb38e567b1aefcfba4d886da2bdaa51c76b1a..ff9e627deb42a4c89cbef947781b4aad82f0d855 100755 (executable)
@@ -84,9 +84,7 @@ int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg)
        return err;
 }
 
-gboolean _thumb_server_read_socket(GIOChannel *src,
-                                                                       GIOCondition condition,
-                                                                       gpointer data)
+gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpointer data)
 {
        struct sockaddr_un client_addr;
        unsigned int client_addr_len;
@@ -262,17 +260,14 @@ gboolean _thumb_server_prepare_socket(int *sock_fd)
 int _thumbnail_get_data(const char *origin_path,
                                                char *thumb_path,
                                                unsigned char **data,
-                                               int *size,
                                                int *width,
                                                int *height,
                                                int *alpha,
                                                bool *is_saved)
 {
        int err = MS_MEDIA_ERR_NONE;
-       int thumb_width = -1;
-       int thumb_height = -1;
 
-       if (origin_path == NULL || size == NULL || width == NULL || height == NULL) {
+       if (origin_path == NULL || width == NULL || height == NULL) {
                thumb_err("Invalid parameter");
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
@@ -287,49 +282,31 @@ int _thumbnail_get_data(const char *origin_path,
        int file_type = THUMB_NONE_TYPE;
        media_thumb_info thumb_info = {0,};
        file_type = _media_thumb_get_file_type(origin_path);
-       thumb_width = *width;
-       thumb_height = *height;
-       if (thumb_width == 0 || thumb_height == 0) {
-               thumb_width = THUMB_DEFAULT_WIDTH;
-               thumb_height = THUMB_DEFAULT_HEIGHT;
-       }
-
        thumb_info.is_raw = FALSE;
 
        if (file_type == THUMB_IMAGE_TYPE) {
-               err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, &thumb_info);
-               if (err != MS_MEDIA_ERR_NONE) {
-                       thumb_err("_media_thumb_image failed");
-                       return err;
-               }
+               err = _media_thumb_image(origin_path, thumb_path, THUMB_DEFAULT_WIDTH, THUMB_DEFAULT_HEIGHT, &thumb_info);
+               thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "_media_thumb_image failed");
        } else if (file_type == THUMB_VIDEO_TYPE) {
-               err = _media_thumb_video(origin_path, thumb_width, thumb_height, &thumb_info);
-               if (err != MS_MEDIA_ERR_NONE) {
-                       thumb_err("_media_thumb_image failed");
-                       return err;
-               }
+               err = _media_thumb_video(origin_path, THUMB_DEFAULT_WIDTH, THUMB_DEFAULT_HEIGHT, &thumb_info);
+               thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "_media_thumb_video failed");
        } else {
                thumb_err("invalid file type");
                return MS_MEDIA_ERR_THUMB_UNSUPPORTED;
        }
 
-       if (size) *size = thumb_info.size;
        if (width) *width = thumb_info.width;
        if (height) *height = thumb_info.height;
        *data = thumb_info.data;
        if (alpha) *alpha = thumb_info.alpha;
        if (is_saved) *is_saved = thumb_info.is_saved;
 
-       thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) %p", *size, *width, *height, *data);
+       thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) %p", thumb_info.size, *width, *height, *data);
 
        return MS_MEDIA_ERR_NONE;
 }
 
-int _thumbnail_get_raw_data(const char *origin_path,
-                                               int *width,
-                                               int *height,
-                                               unsigned char **data,
-                                               int *size)
+int _thumbnail_get_raw_data(const char *origin_path, int *width, int *height, unsigned char **data, int *size)
 {
        int err = MS_MEDIA_ERR_NONE;
        int thumb_width = -1;
@@ -355,16 +332,10 @@ int _thumbnail_get_raw_data(const char *origin_path,
 
        if (file_type == THUMB_IMAGE_TYPE) {
                err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, &thumb_info);
-               if (err != MS_MEDIA_ERR_NONE) {
-                       thumb_err("_media_thumb_image failed");
-                       return err;
-               }
+               thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "_media_thumb_image failed");
        } else if (file_type == THUMB_VIDEO_TYPE) {
                err = _media_thumb_video(origin_path, thumb_width, thumb_height, &thumb_info);
-               if (err != MS_MEDIA_ERR_NONE) {
-                       thumb_err("_media_thumb_image failed");
-                       return err;
-               }
+               thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "_media_thumb_video failed");
        } else {
                thumb_err("invalid file type");
                return MS_MEDIA_ERR_THUMB_UNSUPPORTED;
@@ -382,7 +353,6 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
 {
        int err = MS_MEDIA_ERR_NONE;
        unsigned char *data = NULL;
-       int thumb_size = 0;
        int thumb_w = 0;
        int thumb_h = 0;
        int max_length = 0;
@@ -390,14 +360,9 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
        int alpha = 0;
        bool is_saved = FALSE;
 
-       if (req_msg == NULL || res_msg == NULL) {
-               thumb_err("Invalid msg!");
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
+       thumb_retvm_if(req_msg == NULL || res_msg == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid msg");
 
        const char *origin_path = req_msg->org_path;
-       thumb_w = req_msg->thumb_width;
-       thumb_h = req_msg->thumb_height;
        thumb_path = res_msg->dst_path;
        thumb_path[0] = '\0';
        max_length = sizeof(res_msg->dst_path) -1;
@@ -434,7 +399,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
                _media_thumb_remove_file(thumb_path);
        }
 
-       err = _thumbnail_get_data(origin_path, thumb_path, &data, &thumb_size, &thumb_w, &thumb_h, &alpha, &is_saved);
+       err = _thumbnail_get_data(origin_path, thumb_path, &data, &thumb_w, &thumb_h, &alpha, &is_saved);
        if (err != MS_MEDIA_ERR_NONE) {
                thumb_err("_thumbnail_get_data failed - %d", err);
                SAFE_FREE(data);
@@ -445,9 +410,6 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
        }
 
        res_msg->msg_type = THUMB_RESPONSE;
-       res_msg->thumb_size = thumb_size;
-       res_msg->thumb_width = thumb_w;
-       res_msg->thumb_height = thumb_h;
 
        /* If the image is transparent PNG format, make png file as thumbnail of this image */
        if (alpha) {
@@ -514,10 +476,7 @@ _media_thumb_process_raw(thumbMsg *req_msg, thumbMsg *res_msg)
        int thumb_w = 0;
        int thumb_h = 0;
 
-       if (req_msg == NULL || res_msg == NULL) {
-               thumb_err("Invalid msg!");
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
+       thumb_retvm_if(req_msg == NULL || res_msg == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid msg");
 
        const char *origin_path = req_msg->org_path;
        thumb_w = req_msg->thumb_width;
index cc021b657e79a93506f81f6c6ed6f3bbd9a66f52..651cd7cbb61b201e331824c3b807b1ce16412445 100755 (executable)
 #define _MEDIA_THUMB_IPC_H_
 
 #define MAX_PATH_SIZE 4096
-#define MAX_TRIES              3
 
 int _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg);
-
-int _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_un *from_addr, unsigned int *from_size);
-
 int _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size);
 
-int _media_thumb_request(int msg_type,
-                                       const char *origin_path,
-                                       char *thumb_path,
-                                       int max_length,
-                                       uid_t uid);
-
-int _media_thumb_request_async(int msg_type,
-                                       unsigned int request_id,
-                                       const char *origin_path,
-                                       thumbUserData *userData,
-                                       uid_t uid);
+int _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, int max_length, uid_t uid);
+int _media_thumb_request_async(int msg_type, unsigned int request_id, const char *origin_path, thumbUserData *userData, uid_t uid);
 
 int _media_thumb_request_raw_data_async(int msg_type,
                                        int request_id,
index 358fdc207ef70cc11a05e23c304c8ea7b8b7da45..43d9b41e5b9f2a72d40069a34d84827322cda379 100755 (executable)
 #ifndef _MEDIA_THUMB_INTERNAL_H_
 #define _MEDIA_THUMB_INTERNAL_H_
 
-#define THUMB_WIDTH_MAX
 /* The maximum of resolution to be able to get thumbnail is 3000 x 3000, except for only jpeg */
 #define THUMB_MAX_ALLOWED_MEM_FOR_THUMB 9000000
 
-#define THUMB_LARGE_WIDTH 320
-#define THUMB_LARGE_HEIGHT 240
-#define THUMB_SMALL_WIDTH 160
-#define THUMB_SMALL_HEIGHT 120
-
 typedef struct {
        int size;
        int width;
index 4b9c74be9b6f7b9d5d2d7524401b70bcab88e235..c71d6a3890770244a23e8748c04e151f27fd7121 100755 (executable)
 #define THUMB_VIDEO_TYPE   1   /* Video */
 
 int _media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len);
-
 int _media_thumb_get_file_type(const char *file_full_path);
 
 char* _media_thumb_generate_hash_name(const char *file);
-
 int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path, size_t max_thumb_path, uid_t uid);
 
 int _media_thumb_remove_file(const char *path);
index 9064a7b2bde8da3bc4b637b2a73b37c37a722c58..6b63959023dee03f21bef99225fbc883a5743bc8 100755 (executable)
@@ -117,7 +117,7 @@ void __media_thumb_shutdown_channel(bool only_shutdown)
        }
 }
 
-int __media_thumb_pop_req_queue(const char *path)
+int __media_thumb_pop_req_queue()
 {
        int req_len = 0;
 
@@ -380,8 +380,7 @@ bool __media_thumb_check_cancel_for_raw(void)
        }
 }
 
-int
-_media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
+int _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
 {
        int recv_msg_len = 0;
        int remain_size = 0;
@@ -460,51 +459,7 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
        return MS_MEDIA_ERR_NONE;
 }
 
-int
-_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_un *from_addr, unsigned int *from_size)
-{
-       int recv_msg_len = 0;
-       unsigned int from_addr_size = sizeof(struct sockaddr_un);
-       unsigned char *buf = NULL;
-
-       THUMB_MALLOC(buf, sizeof(thumbMsg));
-       if (buf == NULL) {
-               thumb_err("memory allocation failed");
-               return MS_MEDIA_ERR_OUT_OF_MEMORY;
-       }
-
-       if ((recv_msg_len = recvfrom(sock, buf, sizeof(thumbMsg), 0, (struct sockaddr *)from_addr, &from_addr_size)) < 0) {
-               thumb_stderror("recvform failed");
-               SAFE_FREE(buf);
-               return _media_thumb_get_error();
-       }
-
-       memcpy(msg, buf, header_size);
-
-       if (msg->origin_path_size <= 0 || msg->origin_path_size > MAX_PATH_SIZE) {
-               SAFE_FREE(buf);
-               thumb_err("msg->origin_path_size is invalid %d", msg->origin_path_size);
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
-       SAFE_STRLCPY(msg->org_path, (char*)buf + header_size, sizeof(msg->org_path));
-
-       if (msg->dest_path_size <= 0 || msg->dest_path_size > MAX_PATH_SIZE) {
-               SAFE_FREE(buf);
-               thumb_err("msg->origin_path_size is invalid %d", msg->dest_path_size);
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
-       SAFE_STRLCPY(msg->dst_path, (char*)buf + header_size + msg->origin_path_size, sizeof(msg->dst_path));
-
-       SAFE_FREE(buf);
-       *from_size = from_addr_size;
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-int
-_media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
+int _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
 {
        if (req_msg == NULL || buf == NULL) {
                return MS_MEDIA_ERR_INVALID_PARAMETER;
@@ -540,8 +495,7 @@ _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
        return MS_MEDIA_ERR_NONE;
 }
 
-int
-_media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, int max_length, uid_t uid)
+int _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, int max_length, uid_t uid)
 {
        int sock = -1;
        struct sockaddr_un serv_addr;
@@ -653,11 +607,7 @@ gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpoi
 
        if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
                thumb_err("_media_thumb_recv_msg failed ");
-               if (recv_msg.origin_path_size > 0) {
-                       __media_thumb_pop_req_queue(recv_msg.org_path);
-               } else {
-                       thumb_err("origin path size is wrong.");
-               }
+               __media_thumb_pop_req_queue();
 
                return FALSE;
        }
@@ -675,7 +625,7 @@ gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpoi
                }
        }
 
-       __media_thumb_pop_req_queue(recv_msg.org_path);
+       __media_thumb_pop_req_queue();
 
        thumb_dbg("Done");
 
index 5c4afb755b5ca20250d3972dc21ea0db25b15132..b9140cbf97217585fa0d48a31cb11d580a5e3d4f 100755 (executable)
@@ -27,8 +27,7 @@
 #include <aul.h>
 #include <string.h>
 
-int
-_media_thumb_get_file_type(const char *file_full_path)
+int _media_thumb_get_file_type(const char *file_full_path)
 {
        int ret = 0;
        char mimetype[255] = {0,};