summaryrefslogtreecommitdiff
path: root/server/thumb-server-internal.c
diff options
context:
space:
mode:
authorJiyong Min <jiyong.min@samsung.com>2017-04-06 10:45:54 (GMT)
committerJiyong Min <jiyong.min@samsung.com>2017-04-07 10:45:37 (GMT)
commite10f2207aeea99bcde0258359d4d336d4ae9d253 (patch)
treef6c8682ab5615500ad79896a7ade961ccf5df34d /server/thumb-server-internal.c
parentaee150adb2f1ea46f8ab3e1ee32896338bc811eb (diff)
downloadlibmedia-thumbnail-e10f2207aeea99bcde0258359d4d336d4ae9d253.zip
libmedia-thumbnail-e10f2207aeea99bcde0258359d4d336d4ae9d253.tar.gz
libmedia-thumbnail-e10f2207aeea99bcde0258359d4d336d4ae9d253.tar.bz2
Check Error type and remove Unused coderefs/changes/71/123671/8
1. Check Proper Error Type when create thumbnail and return it to App. 2. Remove unused THUMB_REQUEST_SAVE_FILE related code Change-Id: Idf40c8f3a515319bcccce81dcd49d7cda8d56165 Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
Diffstat (limited to 'server/thumb-server-internal.c')
-rwxr-xr-xserver/thumb-server-internal.c72
1 files changed, 20 insertions, 52 deletions
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index 2e6bc8c..8e0cff7 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -167,22 +167,8 @@ int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg)
int err = MS_MEDIA_ERR_NONE;
err = _media_thumb_process(req_msg, res_msg);
- if (err != MS_MEDIA_ERR_NONE) {
- if (req_msg->msg_type == THUMB_REQUEST_SAVE_FILE) {
- thumb_err("_media_thumb_process is failed: %d", err);
- res_msg->status = THUMB_FAIL;
- } else {
- if (err != MS_MEDIA_ERR_FILE_NOT_EXIST) {
- thumb_warn("_media_thumb_process is failed: %d, So use default thumb", err);
- res_msg->status = THUMB_SUCCESS;
- } else {
- thumb_warn("_media_thumb_process is failed: %d, (file not exist) ", err);
- res_msg->status = THUMB_FAIL;
- }
- }
- } else {
- res_msg->status = THUMB_SUCCESS;
- }
+ if (err != MS_MEDIA_ERR_NONE)
+ thumb_warn("_media_thumb_process is failed: %d", err);
return err;
}
@@ -192,12 +178,8 @@ static int __thumb_daemon_process_job_raw(thumbMsg *req_msg, thumbMsg *res_msg)
int err = MS_MEDIA_ERR_NONE;
err = _media_thumb_process_raw(req_msg, res_msg);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_warn("_media_thumb_process is failed: %d", err);
- res_msg->status = THUMB_FAIL;
- } else {
- res_msg->status = THUMB_SUCCESS;
- }
+ if (err != MS_MEDIA_ERR_NONE)
+ thumb_warn("_media_thumb_process_raw is failed: %d", err);
return err;
}
@@ -288,30 +270,8 @@ int _thumb_daemon_process_queue_jobs(gpointer data)
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_FILE_NOT_EXIST) {
+ if (err != MS_MEDIA_ERR_NONE)
thumb_err("Thumbnail processing is failed : %d", err);
- } else {
- if (res_msg.status == THUMB_SUCCESS) {
-
- err = _media_thumb_db_connect(uid);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
- return TRUE;
- }
-
- /* Need to update DB once generating thumb is done */
- err = _media_thumb_update_db(recv_msg.org_path,
- res_msg.dst_path,
- res_msg.origin_width,
- res_msg.origin_height,
- uid);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_update_db failed : %d", err);
- }
-
- _media_thumb_db_disconnect();
- }
- }
SAFE_FREE(path);
} else {
@@ -488,7 +448,7 @@ static gboolean _thumb_server_send_deny_message(int sockfd)
int bytes_to_send = sizeof(msg) - sizeof(msg.org_path) - sizeof(msg.dst_path);
msg.msg_type = THUMB_RESPONSE;
- msg.status = THUMB_FAIL;
+ msg.status = MS_MEDIA_ERR_PERMISSION_DENIED;
if (send(sockfd, &msg, bytes_to_send, 0) != bytes_to_send) {
thumb_stderror("send failed");
@@ -587,7 +547,7 @@ int _thumbnail_get_data(const char *origin_path,
}
} else {
thumb_err("invalid file type");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_THUMB_UNSUPPORTED;
}
if (size) *size = thumb_info.size;
@@ -692,15 +652,18 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
thumb_path = res_msg->dst_path;
thumb_path[0] = '\0';
max_length = sizeof(res_msg->dst_path) -1;
+ res_msg->status = MS_MEDIA_ERR_NONE;
if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
thumb_err("origin_path does not exist in file system.");
+ res_msg->status = MS_MEDIA_ERR_FILE_NOT_EXIST;
return MS_MEDIA_ERR_FILE_NOT_EXIST;
}
err = _media_thumb_db_connect(req_msg->uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
+ res_msg->status = MS_MEDIA_ERR_DB_CONNECT_FAIL;
return err;
}
@@ -718,6 +681,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
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;
}
@@ -725,15 +689,13 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
}
}
- } else if (msg_type == THUMB_REQUEST_SAVE_FILE) {
- strncpy(thumb_path, req_msg->dst_path, max_length);
-
} 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;
}
@@ -752,6 +714,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
thumb_err("_thumbnail_get_data failed - %d", err);
SAFE_FREE(data);
strncpy(thumb_path, THUMB_EMPTY_STR, max_length);
+ res_msg->status = err;
goto DB_UPDATE;
}
@@ -786,6 +749,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
strncpy(thumb_path, THUMB_EMPTY_STR, max_length);
}
_media_thumb_db_disconnect();
+ res_msg->status = err;
return err;
} else {
thumb_dbg("file save success");
@@ -803,6 +767,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
err = fsync(fd);
if (err == -1) {
thumb_warn("fsync failed");
+ res_msg->status = MS_MEDIA_ERR_INTERNAL;
}
close(fd);
@@ -816,12 +781,13 @@ DB_UPDATE:
err = _media_thumb_update_db(origin_path, thumb_path, res_msg->origin_width, res_msg->origin_height, req_msg->uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_update_db failed : %d", err);
+ res_msg->status = err;
}
}
_media_thumb_db_disconnect();
- return MS_MEDIA_ERR_NONE;
+ return err;
}
int
@@ -843,11 +809,13 @@ _media_thumb_process_raw(thumbMsg *req_msg, thumbMsg *res_msg)
media_thumb_format thumb_format = MEDIA_THUMB_BGRA;
thumb_w = req_msg->thumb_width;
thumb_h = req_msg->thumb_height;
+ res_msg->status = MS_MEDIA_ERR_NONE;
err = _thumbnail_get_raw_data(origin_path, thumb_format, &thumb_w, &thumb_h, &data, &thumb_size);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_thumbnail_get_data failed - %d", err);
+ res_msg->status = err;
SAFE_FREE(data);
}
@@ -860,5 +828,5 @@ _media_thumb_process_raw(thumbMsg *req_msg, thumbMsg *res_msg)
SAFE_FREE(data);
- return MS_MEDIA_ERR_NONE;
+ return err;
}