Remove thumb_extract_all feature 04/130104/2
authorMinje Ahn <minje.ahn@samsung.com>
Fri, 19 May 2017 06:43:05 +0000 (15:43 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Fri, 19 May 2017 06:55:38 +0000 (06:55 +0000)
Change-Id: Iccd0bb0f918013bed22f0f27c968362fe54079d2
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-thumbnail.h
packaging/libmedia-thumbnail.spec
server/include/thumb-server-internal.h
server/thumb-server-internal.c
server/thumb-server.c
src/include/util/media-thumb-db.h
src/media-thumbnail.c
test/test-thumb.c

index 76e4ffa..334b8a3 100755 (executable)
@@ -42,8 +42,6 @@ int thumbnail_request_from_db_async(unsigned int request_id, const char *origin_
 
 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_extract_all_thumbs(uid_t uid);
-
 int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *origin_width, int *origin_height, uid_t uid);
 
 int thumbnail_request_cancel_media(unsigned int request_id, const char *origin_path);
index 24abd5d..5e1f983 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmedia-thumbnail
 Summary:    Media thumbnail service library for multimedia applications
-Version: 0.2.5
+Version: 0.2.6
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0 and PD
index c915c65..bce2e88 100755 (executable)
@@ -40,8 +40,6 @@ typedef enum {
 
 gboolean _thumb_daemon_start_jobs(gpointer data);
 void _thumb_daemon_finish_jobs(void);
-void _thumb_daemon_mmc_eject_vconf_cb(void *data);
-void _thumb_daemon_vconf_cb(void *data);
 gboolean _thumb_server_prepare_socket(int *sock_fd);
 gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpointer data);
 
index c0b69ea..b265b3c 100755 (executable)
 #define THUMB_COMM_SOCK_PATH tzplatform_mkpath(TZ_SYS_RUN, "media-server/media_ipc_thumbcomm.socket")
 #define THUMB_EMPTY_STR ""
 
-static __thread char **arr_path;
-static __thread uid_t *arr_uid;
-static __thread int g_idx = 0;
-static __thread int g_cur_idx = 0;
-
 GMainLoop *g_thumb_server_mainloop; // defined in thumb-server.c as extern
 
 static gboolean __thumb_server_send_msg_to_agent(int msg_type);
-static void __thumb_daemon_stop_job(void);
-static int __thumb_daemon_all_extract(uid_t uid);
-int _thumb_daemon_process_queue_jobs(gpointer data);
 static gboolean _thumb_server_send_deny_message(int sockfd);
 
 gboolean _thumb_daemon_start_jobs(gpointer data)
@@ -82,86 +74,6 @@ void _thumb_daemon_finish_jobs(void)
        return;
 }
 
-int _thumb_daemon_mmc_status(void)
-{
-       int err = -1;
-       int status = -1;
-
-       err = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status);
-       if (err == 0) {
-               return status;
-       } else if (err == -1) {
-               thumb_err("vconf_get_int failed : %d", err);
-       } else {
-               thumb_err("vconf_get_int Unexpected error code: %d", err);
-       }
-
-       return status;
-}
-
-void _thumb_daemon_mmc_eject_vconf_cb(void *data)
-{
-       int err = -1;
-       int status = 0;
-
-       thumb_warn("_thumb_daemon_vconf_cb called");
-
-       err = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status);
-       if (err == 0) {
-               if (status == VCONFKEY_SYSMAN_MMC_REMOVED || status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
-                       thumb_warn("SD card is ejected or not mounted. So media-thumbnail-server stops jobs to extract all thumbnails");
-
-                       __thumb_daemon_stop_job();
-               }
-       } else if (err == -1) {
-               thumb_err("vconf_get_int failed : %d", err);
-       } else {
-               thumb_err("vconf_get_int Unexpected error code: %d", err);
-       }
-
-       return;
-}
-
-void _thumb_daemon_vconf_cb(void *data)
-{
-       int err = -1;
-       int status = 0;
-
-       thumb_warn("_thumb_daemon_vconf_cb called");
-
-       err = vconf_get_int(VCONFKEY_SYSMAN_MMC_FORMAT, &status);
-       if (err == 0) {
-               if (status == VCONFKEY_SYSMAN_MMC_FORMAT_COMPLETED) {
-                       thumb_warn("SD card format is completed. So media-thumbnail-server stops jobs to extract all thumbnails");
-
-                       __thumb_daemon_stop_job();
-               } else {
-                       thumb_dbg("not completed");
-               }
-       } else if (err == -1) {
-               thumb_err("vconf_get_int failed : %d", err);
-       } else {
-               thumb_err("vconf_get_int Unexpected error code: %d", err);
-       }
-
-       return;
-}
-
-static void __thumb_daemon_stop_job()
-{
-       int i = 0;
-       char *path = NULL;
-
-       thumb_warn("There are %d jobs in the queue. But all jobs will be stopped", g_idx - g_cur_idx);
-
-       for (i = g_cur_idx; i < g_idx; i++) {
-               path = arr_path[g_cur_idx++];
-               SAFE_FREE(path);
-       }
-
-       return;
-}
-
 int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg)
 {
        int err = MS_MEDIA_ERR_NONE;
@@ -184,112 +96,6 @@ static int __thumb_daemon_process_job_raw(thumbMsg *req_msg, thumbMsg *res_msg)
        return err;
 }
 
-static int __thumb_daemon_all_extract(uid_t uid)
-{
-       int err = MS_MEDIA_ERR_NONE;
-       char query_string[MAX_PATH_SIZE + 1] = { 0, };
-       char path[MAX_PATH_SIZE + 1] = { 0, };
-       sqlite3 *sqlite_db_handle = NULL;
-       sqlite3_stmt *sqlite_stmt = NULL;
-
-       err = _media_thumb_db_connect(uid);
-       if (err != MS_MEDIA_ERR_NONE) {
-               thumb_err("_media_thumb_db_connect failed: %d", err);
-               return err;
-       }
-
-       sqlite_db_handle = _media_thumb_db_get_handle();
-       if (sqlite_db_handle == NULL) {
-               thumb_err("sqlite handle is NULL");
-               return MS_MEDIA_ERR_INTERNAL;
-       }
-
-       if (_thumb_daemon_mmc_status() == VCONFKEY_SYSMAN_MMC_MOUNTED) {
-               snprintf(query_string, sizeof(query_string), SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA);
-       } else {
-               snprintf(query_string, sizeof(query_string), SELECT_PATH_FROM_UNEXTRACTED_THUMB_INTERNAL_MEDIA);
-       }
-
-       thumb_warn("Query: %s", query_string);
-
-       err = sqlite3_prepare_v2(sqlite_db_handle, query_string, strlen(query_string), &sqlite_stmt, NULL);
-       if (SQLITE_OK != err) {
-               thumb_err("prepare error [%s]", sqlite3_errmsg(sqlite_db_handle));
-               _media_thumb_db_disconnect();
-               return MS_MEDIA_ERR_INTERNAL;
-       }
-
-       while (1) {
-               err = sqlite3_step(sqlite_stmt);
-               if (err != SQLITE_ROW) {
-                       thumb_dbg("end of row [%s]", sqlite3_errmsg(sqlite_db_handle));
-                       break;
-               }
-
-               SAFE_STRLCPY(path, (const char *)sqlite3_column_text(sqlite_stmt, 0), sizeof(path));
-               path[sizeof(path) - 1] = '\0';
-
-               thumb_dbg_slog("Path : %s", path);
-
-               if (g_idx == 0) {
-                       arr_path = (char**)malloc(sizeof(char*));
-                       arr_uid = (uid_t*)malloc(sizeof(uid_t));
-               } else {
-                       arr_path = (char**)realloc(arr_path, (g_idx + 1) * sizeof(char*));
-                       arr_uid = (uid_t*)realloc(arr_uid, (g_idx + 1) * sizeof(uid_t));
-               }
-               arr_uid[g_idx] = uid;
-               arr_path[g_idx++] = strdup(path);
-       }
-
-       sqlite3_finalize(sqlite_stmt);
-       _media_thumb_db_disconnect();
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-int _thumb_daemon_process_queue_jobs(gpointer data)
-{
-       int err = MS_MEDIA_ERR_NONE;
-       char *path = NULL;
-       uid_t uid = 0;
-
-       if (g_cur_idx < g_idx) {
-               thumb_warn("There are %d jobs in the queue", g_idx - g_cur_idx);
-               thumb_dbg("Current idx : [%d]", g_cur_idx);
-               uid = arr_uid[g_cur_idx];
-               path = arr_path[g_cur_idx++];
-
-               thumbMsg recv_msg, res_msg;
-               memset(&recv_msg, 0x00, sizeof(thumbMsg));
-               memset(&res_msg, 0x00, sizeof(thumbMsg));
-
-               recv_msg.msg_type = THUMB_REQUEST_DB_INSERT;
-               recv_msg.uid = uid;
-               SAFE_STRLCPY(recv_msg.org_path, path, sizeof(recv_msg.org_path));
-               recv_msg.org_path[sizeof(recv_msg.org_path) - 1] = '\0';
-
-               err = _thumb_daemon_process_job(&recv_msg, &res_msg);
-               if (err != MS_MEDIA_ERR_NONE)
-                       thumb_err("Thumbnail processing is failed : %d", err);
-
-               SAFE_FREE(path);
-       } else {
-               g_cur_idx = 0;
-               g_idx = 0;
-               thumb_warn("Deleting array");
-               SAFE_FREE(arr_path);
-               SAFE_FREE(arr_uid);
-               //_media_thumb_db_disconnect();
-
-               __thumb_server_send_msg_to_agent(MS_MSG_THUMB_EXTRACT_ALL_DONE); // MS_MSG_THUMB_EXTRACT_ALL_DONE
-
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
 gboolean _thumb_server_read_socket(GIOChannel *src,
                                                                        GIOCondition condition,
                                                                        gpointer data)
@@ -340,11 +146,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
 
        thumb_warn_slog("Received [%d] %s(%d) from PID(%d)", recv_msg.msg_type, recv_msg.org_path, strlen(recv_msg.org_path), recv_msg.pid);
 
-       if (recv_msg.msg_type == THUMB_REQUEST_ALL_MEDIA) {
-               thumb_dbg("All thumbnails are being extracted now");
-               __thumb_daemon_all_extract(recv_msg.uid);
-               g_idle_add(_thumb_daemon_process_queue_jobs, NULL);
-       } else if (recv_msg.msg_type == THUMB_REQUEST_RAW_DATA) {
+       if (recv_msg.msg_type == THUMB_REQUEST_RAW_DATA) {
                __thumb_daemon_process_job_raw(&recv_msg, &res_msg);
        } else if (recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
                thumb_warn("received KILL msg from thumbnail agent.");
@@ -689,17 +491,6 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
                        }
                }
 
-       } else if (msg_type == THUMB_REQUEST_ALL_MEDIA) {
-               err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length, req_msg->uid);
-               if (err != MS_MEDIA_ERR_NONE) {
-                       thumb_err("_media_thumb_get_hash_name failed - %d", err);
-                       strncpy(thumb_path, THUMB_EMPTY_STR, max_length);
-                       _media_thumb_db_disconnect();
-                       res_msg->status = err;
-                       return err;
-               }
-
-               thumb_path[strlen(thumb_path)] = '\0';
        }
 
        thumb_dbg_slog("Thumb path : %s", thumb_path);
@@ -745,7 +536,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
                        thumb_err("save_to_file_with_evas failed - %d", err);
                        SAFE_FREE(data);
 
-                       if (msg_type == THUMB_REQUEST_DB_INSERT || msg_type == THUMB_REQUEST_ALL_MEDIA) {
+                       if (msg_type == THUMB_REQUEST_DB_INSERT) {
                                strncpy(thumb_path, THUMB_EMPTY_STR, max_length);
                        }
                        _media_thumb_db_disconnect();
index f7eeff0..3dded0b 100755 (executable)
@@ -52,8 +52,6 @@ static void _media_thumb_signal_handler(void *user_data)
 int main(void)
 {
        int sockfd = -1;
-       int err = 0;
-
        GSource *source = NULL;
        GIOChannel *channel = NULL;
        GMainContext *context = NULL;
@@ -63,17 +61,7 @@ int main(void)
                return -1;
        }
 
-       /* Set VCONFKEY_SYSMAN_MMC_FORMAT callback to get noti for SD card format */
-       err = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_FORMAT, (vconf_callback_fn) _thumb_daemon_vconf_cb, NULL);
-       if (err == -1)
-               thumb_err("vconf_notify_key_changed : %s fails", VCONFKEY_SYSMAN_MMC_FORMAT);
-
-       /* Set VCONFKEY_SYSMAN_MMC_STATUS callback to get noti when SD card is ejected */
-       err = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, (vconf_callback_fn) _thumb_daemon_mmc_eject_vconf_cb, NULL);
-       if (err == -1)
-               thumb_err("vconf_notify_key_changed : %s fails", VCONFKEY_SYSMAN_MMC_STATUS);
-
-       /* Create and bind new UDP socket */
+       /* Create and bind new tcp socket */
        if (!_thumb_server_prepare_socket(&sockfd)) {
                thumb_err("Failed to create socket");
                return -1;
@@ -82,7 +70,7 @@ int main(void)
        g_thumb_server_mainloop = g_main_loop_new(context, FALSE);
        context = g_main_loop_get_context(g_thumb_server_mainloop);
 
-       /* Create new channel to watch udp socket */
+       /* Create new channel to watch tcp socket */
        channel = g_io_channel_unix_new(sockfd);
        source = g_io_create_watch(channel, G_IO_IN);
 
@@ -95,12 +83,6 @@ int main(void)
        g_source_set_callback(source_evas_init, _thumb_daemon_start_jobs, NULL, NULL);
        g_source_attach(source_evas_init, context);
 
-/*     Would be used when glib 2.32 is installed
-       GSource *sig_handler_src = NULL;
-       sig_handler_src = g_unix_signal_source_new (SIGTERM);
-       g_source_set_callback(sig_handler_src, (GSourceFunc)_media_thumb_signal_handler, NULL, NULL);
-       g_source_attach(sig_handler_src, context);
-*/
        thumb_dbg("************************************");
        thumb_dbg("*** Thumbnail server is running ***");
        thumb_dbg("************************************");
index 9a374b4..03cca1f 100755 (executable)
@@ -28,8 +28,6 @@
 #define STRING_VALID(str)      \
        ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
 
-#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from media where thumbnail_path is null and validity=1 and (media_type=0 or media_type=1);"
-#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_INTERNAL_MEDIA "SELECT path from media where thumbnail_path is null and validity=1 and (media_type=0 or media_type=1) and storage_type=0;"
 #define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM media WHERE path='%q';"
 #define SELECT_TYPE_BY_PATH "SELECT media_type FROM media WHERE path='%q';"
 #define SELECT_WH_BY_PATH "SELECT width, height FROM media WHERE path='%q';"
index d18ee5d..f3ba2bc 100755 (executable)
@@ -75,24 +75,6 @@ int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_pat
        return MS_MEDIA_ERR_NONE;
 }
 
-int thumbnail_request_extract_all_thumbs(uid_t uid)
-{
-       int err = MS_MEDIA_ERR_NONE;
-
-       media_thumb_info thumb_info;
-       char tmp_origin_path[MAX_PATH_SIZE] = {0,};
-       char tmp_thumb_path[MAX_PATH_SIZE] = {0,};
-
-       /* Request for thumb file to the daemon "Thumbnail generator" */
-       err = _media_thumb_request(THUMB_REQUEST_ALL_MEDIA, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid);
-       if (err != MS_MEDIA_ERR_NONE) {
-               thumb_err("_media_thumb_request failed : %d", err);
-               return err;
-       }
-
-       return MS_MEDIA_ERR_NONE;
-}
-
 int thumbnail_request_from_db_async(unsigned int request_id, const char *origin_path, ThumbFunc func, void *user_data, uid_t uid)
 {
        int err = MS_MEDIA_ERR_NONE;
index 1bf115f..d07ac7e 100755 (executable)
@@ -167,16 +167,6 @@ int main(int argc, char *argv[])
 #endif
        } else if (origin_path && mode == 4) {
                printf("Success!!\n");
-       } else if (mode == 5) {
-               printf("Test thumbnail_request_extract_all_thumbs\n");
-
-               err = thumbnail_request_extract_all_thumbs(tzplatform_getuid(TZ_USER_NAME));
-               if (err < 0) {
-                       printf("thumbnail_request_extract_all_thumbs failed : %d\n", err);
-                       return -1;
-               } else {
-                       printf("thumbnail_request_extract_all_thumbs success!\n");
-               }
        } else if (mode == 6) {
                printf("Test thumbnail_request_cancel_media\n");