summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-05-19 06:43:05 (GMT)
committerMinje ahn <minje.ahn@samsung.com>2017-05-19 06:55:38 (GMT)
commit84644e6c5ad0cc85ee7534bdc1ed6dde5990692b (patch)
tree33fa3b13cf671b581f82eb583902bfc14d358660 /server
parent73f45fa1ed096b33c0525d314f7167914b29ef03 (diff)
downloadlibmedia-thumbnail-84644e6c5ad0cc85ee7534bdc1ed6dde5990692b.zip
libmedia-thumbnail-84644e6c5ad0cc85ee7534bdc1ed6dde5990692b.tar.gz
libmedia-thumbnail-84644e6c5ad0cc85ee7534bdc1ed6dde5990692b.tar.bz2
Remove thumb_extract_all featurerefs/changes/04/130104/2
Change-Id: Iccd0bb0f918013bed22f0f27c968362fe54079d2 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'server')
-rwxr-xr-xserver/include/thumb-server-internal.h2
-rwxr-xr-xserver/thumb-server-internal.c213
-rwxr-xr-xserver/thumb-server.c22
3 files changed, 4 insertions, 233 deletions
diff --git a/server/include/thumb-server-internal.h b/server/include/thumb-server-internal.h
index c915c65..bce2e88 100755
--- a/server/include/thumb-server-internal.h
+++ b/server/include/thumb-server-internal.h
@@ -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);
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index c0b69ea..b265b3c 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -42,17 +42,9 @@
#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();
diff --git a/server/thumb-server.c b/server/thumb-server.c
index f7eeff0..3dded0b 100755
--- a/server/thumb-server.c
+++ b/server/thumb-server.c
@@ -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("************************************");