summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rwxr-xr-xserver/include/thumb-server-internal.h9
-rwxr-xr-xserver/thumb-server-internal.c106
-rwxr-xr-xserver/thumb-server.c3
3 files changed, 14 insertions, 104 deletions
diff --git a/server/include/thumb-server-internal.h b/server/include/thumb-server-internal.h
index 5e0c47f..927f9e0 100755
--- a/server/include/thumb-server-internal.h
+++ b/server/include/thumb-server-internal.h
@@ -27,17 +27,10 @@
#define _THUMB_DAEMON_INTERNAL_H_
gboolean _thumb_daemon_start_jobs(gpointer data);
-void _thumb_daemon_finish_jobs(void);
gboolean _thumb_server_prepare_socket(int *sock_fd);
gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpointer data);
-int _thumbnail_get_data(const char *origin_path,
- char *thumb_path,
- unsigned char **data,
- int *width,
- int *height,
- int *alpha,
- bool *is_saved);
+int _thumbnail_get_data(const char *origin_path, char *thumb_path);
int _thumbnail_get_raw_data(const char *origin_path, int *width, int *height, unsigned char **data, int *size);
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index 2c84120..22a0ff8 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -28,7 +28,6 @@
#include <dirent.h>
#include <stdio.h>
#include <string.h>
-#include <Ecore_Evas.h>
#include <tzplatform_config.h>
#ifdef LOG_TAG
@@ -50,23 +49,11 @@ static gboolean _thumb_server_send_deny_message(int sockfd);
gboolean _thumb_daemon_start_jobs(gpointer data)
{
thumb_dbg("");
- /* Initialize ecore-evas to use evas library */
- ecore_evas_init();
-
__thumb_server_send_msg_to_agent(MS_MSG_THUMB_SERVER_READY);
return FALSE;
}
-void _thumb_daemon_finish_jobs(void)
-{
- /* Shutdown ecore-evas */
- ecore_evas_shutdown();
- g_main_loop_quit(g_thumb_server_mainloop);
-
- return;
-}
-
int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg)
{
int err = MS_MEDIA_ERR_NONE;
@@ -150,7 +137,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpoi
int buf_size = 0;
int sending_block = 0;
- int block_size = sizeof(res_msg) - MAX_FILEPATH_LEN*2 - sizeof(unsigned char *);
+ int block_size = sizeof(res_msg) - MAX_FILEPATH_LEN * 2 - sizeof(unsigned char *);
unsigned char *buf = NULL;
_media_thumb_set_buffer(&res_msg, &buf, &buf_size);
@@ -257,51 +244,36 @@ gboolean _thumb_server_prepare_socket(int *sock_fd)
return TRUE;
}
-int _thumbnail_get_data(const char *origin_path,
- char *thumb_path,
- unsigned char **data,
- int *width,
- int *height,
- int *alpha,
- bool *is_saved)
+int _thumbnail_get_data(const char *origin_path, char *thumb_path)
{
int err = MS_MEDIA_ERR_NONE;
+ int file_type = THUMB_NONE_TYPE;
- if (origin_path == NULL || width == NULL || height == NULL) {
- thumb_err("Invalid parameter");
+ if (origin_path == NULL) {
+ thumb_err("Original path is null");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+ if (!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR)) {
thumb_err("Original path (%s) does not exist", origin_path);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
thumb_dbg("Origin path : %s", origin_path);
-
- int file_type = THUMB_NONE_TYPE;
- media_thumb_info thumb_info = {0,};
file_type = _media_thumb_get_file_type(origin_path);
- thumb_info.is_raw = FALSE;
if (file_type == THUMB_IMAGE_TYPE) {
- err = _media_thumb_image(origin_path, thumb_path, THUMB_DEFAULT_WIDTH, THUMB_DEFAULT_HEIGHT, &thumb_info);
+ err = _media_thumb_image(origin_path, thumb_path, THUMB_DEFAULT_WIDTH, THUMB_DEFAULT_HEIGHT, NULL);
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_path, THUMB_DEFAULT_WIDTH, THUMB_DEFAULT_HEIGHT, &thumb_info);
+ err = _media_thumb_video(origin_path, thumb_path, THUMB_DEFAULT_WIDTH, THUMB_DEFAULT_HEIGHT, NULL);
thumb_retvm_if(err != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INTERNAL, "_media_thumb_video failed");
} else {
thumb_err("invalid file type");
return MS_MEDIA_ERR_THUMB_UNSUPPORTED;
}
- 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", thumb_info.size, *width, *height, *data);
+ thumb_dbg("Thumb data is generated successfully");
return MS_MEDIA_ERR_NONE;
}
@@ -311,7 +283,6 @@ int _thumbnail_get_raw_data(const char *origin_path, int *width, int *height, un
int err = MS_MEDIA_ERR_NONE;
int thumb_width = -1;
int thumb_height = -1;
- const char * thumb_path = NULL;
if (origin_path == NULL || *width <= 0 || *height <= 0) {
thumb_err("Invalid parameter");
@@ -328,10 +299,9 @@ int _thumbnail_get_raw_data(const char *origin_path, int *width, int *height, un
file_type = _media_thumb_get_file_type(origin_path);
thumb_width = *width;
thumb_height = *height;
- thumb_info.is_raw = TRUE;
if (file_type == THUMB_IMAGE_TYPE) {
- err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, &thumb_info);
+ err = _media_thumb_image(origin_path, NULL, thumb_width, thumb_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, NULL, thumb_width, thumb_height, &thumb_info);
@@ -352,12 +322,7 @@ int _thumbnail_get_raw_data(const char *origin_path, int *width, int *height, un
int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
{
int err = MS_MEDIA_ERR_NONE;
- unsigned char *data = NULL;
- int thumb_w = 0;
- int thumb_h = 0;
char *thumb_path = NULL;
- int alpha = 0;
- bool is_saved = FALSE;
thumb_retvm_if(req_msg == NULL || res_msg == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid msg");
@@ -390,15 +355,14 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
thumb_dbg_slog("Thumb path : %s", thumb_path);
- if (g_file_test(thumb_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+ if (g_file_test(thumb_path, G_FILE_TEST_IS_REGULAR)) {
thumb_warn("thumb path already exists in file system.. remove the existed file");
_media_thumb_remove_file(thumb_path);
}
- err = _thumbnail_get_data(origin_path, thumb_path, &data, &thumb_w, &thumb_h, &alpha, &is_saved);
+ err = _thumbnail_get_data(origin_path, thumb_path);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_thumbnail_get_data failed - %d", err);
- SAFE_FREE(data);
SAFE_STRLCPY(thumb_path, THUMB_EMPTY_STR, MAX_FILEPATH_LEN);
res_msg->status = err;
@@ -407,52 +371,6 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
res_msg->msg_type = THUMB_RESPONSE;
- /* If the image is transparent PNG format, make png file as thumbnail of this image */
- if (alpha) {
- char file_ext[10];
- err = _media_thumb_get_file_ext(origin_path, file_ext, sizeof(file_ext));
- if (strncasecmp(file_ext, "png", 3) == 0) {
- int len = strlen(thumb_path);
- thumb_path[len - 3] = 'p';
- thumb_path[len - 2] = 'n';
- thumb_path[len - 1] = 'g';
- }
- thumb_dbg_slog("Thumb path is changed : %s", thumb_path);
- }
-
- if (is_saved == FALSE && data != NULL) {
- err = _media_thumb_save_to_file_with_evas(data, thumb_w, thumb_h, alpha, thumb_path);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("save_to_file_with_evas failed - %d", err);
- SAFE_FREE(data);
-
- SAFE_STRLCPY(thumb_path, THUMB_EMPTY_STR, MAX_FILEPATH_LEN);
- res_msg->status = err;
- return err;
- } else {
- thumb_dbg("file save success");
- }
- } else {
- thumb_dbg("file is already saved");
- }
-
- /* fsync */
- int fd = 0;
- fd = open(thumb_path, O_WRONLY);
- if (fd < 0) {
- thumb_warn("open failed");
- } else {
- err = fsync(fd);
- if (err == -1) {
- thumb_warn("fsync failed");
- res_msg->status = MS_MEDIA_ERR_INTERNAL;
- }
-
- close(fd);
- }
- /* End of fsync */
-
- SAFE_FREE(data);
DB_UPDATE:
err = _media_thumb_update_db(origin_path, thumb_path, req_msg->uid);
if (err != MS_MEDIA_ERR_NONE) {
diff --git a/server/thumb-server.c b/server/thumb-server.c
index 7de7eda..4a24e0a 100755
--- a/server/thumb-server.c
+++ b/server/thumb-server.c
@@ -80,8 +80,7 @@ int main(void)
/*close socket*/
close(sockfd);
- _thumb_daemon_finish_jobs();
-
+ g_main_loop_quit(g_thumb_server_mainloop);
g_main_loop_unref(g_thumb_server_mainloop);
ms_cynara_finish();