summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2015-06-08 12:43:27 +0900
committerMinje Ahn <minje.ahn@samsung.com>2015-06-08 15:22:41 +0900
commit9c534f334a71a5250c9411cc53c83cd72e3b7e74 (patch)
treecca701a14ae87449dab7de9e8ccbec23c6312554
parentbe3906afcd5d61009fa339b320305b04b5e89c64 (diff)
downloadlibmedia-thumbnail-9c534f334a71a5250c9411cc53c83cd72e3b7e74.tar.gz
libmedia-thumbnail-9c534f334a71a5250c9411cc53c83cd72e3b7e74.tar.bz2
libmedia-thumbnail-9c534f334a71a5250c9411cc53c83cd72e3b7e74.zip
Remove unused code.
Change-Id: I9c8d472cff513d88c90b9558201d20f2fbad05c2 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rw-r--r--CMakeLists.txt2
-rw-r--r--md5/media-thumb-hash.c23
-rwxr-xr-xserver/include/thumb-server-internal.h5
-rwxr-xr-xserver/thumb-server-internal.c102
-rwxr-xr-xserver/thumb-server.c11
-rw-r--r--src/codec/img-codec-osal.c1
-rwxr-xr-xsrc/include/ipc/media-thumb-ipc.h90
-rwxr-xr-xsrc/include/util/media-thumb-db.h15
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c120
-rwxr-xr-xsrc/media-thumb-internal.c7
-rwxr-xr-xsrc/util/media-thumb-db.c133
-rwxr-xr-xsrc/util/media-thumb-debug.c1
-rwxr-xr-xsrc/util/media-thumb-util.c12
-rwxr-xr-xtest/test-thumb.c10
14 files changed, 48 insertions, 484 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75edff3..883af10 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,8 +68,6 @@ ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
#ADD_DEFINITIONS("-D_PERFORMANCE_CHECK_")
ADD_DEFINITIONS("-D_USE_NEW_MEDIA_DB_")
-ADD_DEFINITIONS("-D_USE_MEDIA_UTIL_")
-ADD_DEFINITIONS("-D_USE_UDS_SOCKET_")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both")
CONFIGURE_FILE(media-thumbnail.pc.in media-thumbnail.pc @ONLY)
diff --git a/md5/media-thumb-hash.c b/md5/media-thumb-hash.c
index 6081681..6e8b74e 100644
--- a/md5/media-thumb-hash.c
+++ b/md5/media-thumb-hash.c
@@ -109,25 +109,4 @@ char *_media_thumb_generate_hash_name(const char *file)
md5out[2 * n] = '\0';
return md5out;
-}
-
-int thumbnail_generate_hash_code(const char *origin_path, char *hash_code, int max_length)
-{
- char *hash = NULL;
-
- if (max_length < ((2 * MD5_HASHBYTES) + 1)) {
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- hash = _media_thumb_generate_hash_name(origin_path);
-
- if (hash == NULL) {
- return MS_MEDIA_ERR_INTERNAL;
- }
-
- strncpy(hash_code, hash, max_length);
- hash_code[strlen(hash_code)] ='\0';
-
- return MS_MEDIA_ERR_NONE;
-}
-
+} \ No newline at end of file
diff --git a/server/include/thumb-server-internal.h b/server/include/thumb-server-internal.h
index 13e06fe..818a02c 100755
--- a/server/include/thumb-server-internal.h
+++ b/server/include/thumb-server-internal.h
@@ -39,11 +39,6 @@ typedef enum {
TIMEOUT_MODE = 1
} _server_mode_e;
-#if 0
-int _thumb_daemon_get_sockfd();
-gboolean _thumb_daemon_udp_thread(void *data);
-#endif
-
gboolean _thumb_daemon_start_jobs(gpointer data);
void _thumb_daemon_finish_jobs();
void _thumb_daemon_mmc_eject_vconf_cb(void *data);
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index bd08d61..3bd4139 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -40,22 +40,19 @@ static __thread int g_cur_idx = 0;
GMainLoop *g_thumb_server_mainloop; // defined in thumb-server.c as extern
-#ifdef _USE_MEDIA_UTIL_
gboolean _thumb_server_send_msg_to_agent(int msg_type);
-#endif
void _thumb_daemon_stop_job();
gboolean _thumb_daemon_start_jobs(gpointer data)
{
thumb_dbg("");
-#ifdef _USE_MEDIA_UTIL_
_thumb_server_send_msg_to_agent(MS_MSG_THUMB_SERVER_READY);
-#endif
+
return FALSE;
}
-void _thumb_daemon_finish_jobs()
+void _thumb_daemon_finish_jobs(void)
{
sqlite3 *sqlite_db_handle = _media_thumb_db_get_handle();
@@ -69,7 +66,7 @@ void _thumb_daemon_finish_jobs()
return;
}
-int _thumb_daemon_mmc_status()
+int _thumb_daemon_mmc_status(void)
{
int err = -1;
int status = -1;
@@ -300,16 +297,9 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
GIOCondition condition,
gpointer data)
{
-#ifdef _USE_UDS_SOCKET_
struct sockaddr_un client_addr;
-#else
- struct sockaddr_in client_addr;
-#endif
unsigned int client_addr_len;
-#ifndef _USE_MEDIA_UTIL_
int client_sock;
-#endif
-
thumbMsg recv_msg;
thumbMsg res_msg;
@@ -327,27 +317,10 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2;
-#ifndef _USE_MEDIA_UTIL_
- if ((client_sock = accept(sock, (struct sockaddr*)&client_addr, &client_addr_len)) < 0) {
- thumb_err("accept failed : %s", strerror(errno));
- return TRUE;
- }
-
- thumb_dbg("Client[%d] is accepted", client_sock);
-
-
- if (_media_thumb_recv_msg(client_sock, header_size, &recv_msg) < 0) {
- thumb_err("_media_thumb_recv_msg failed ");
- close(client_sock);
- return TRUE;
- }
-#else
-
if (_media_thumb_recv_udp_msg(sock, header_size, &recv_msg, &client_addr, &client_addr_len) < 0) {
thumb_err("_media_thumb_recv_udp_msg failed");
return FALSE;
}
-#endif
thumb_warn("Received [%d] %s(%d) from PID(%d) \n", recv_msg.msg_type, recv_msg.org_path, strlen(recv_msg.org_path), recv_msg.pid);
@@ -375,26 +348,11 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
unsigned char *buf = NULL;
_media_thumb_set_buffer(&res_msg, &buf, &buf_size);
- //thumb_dbg("buffer size : %d", buf_size);
-
-#ifndef _USE_MEDIA_UTIL_
- if (send(client_sock, buf, buf_size, 0) != buf_size) {
- thumb_err("sendto failed : %s", strerror(errno));
- } else {
- thumb_dbg("Sent %s(%d) \n", res_msg.dst_path, strlen(res_msg.dst_path));
- }
-
- close(client_sock);
-#else
-#ifdef _USE_UDS_SOCKET_
- thumb_dbg("+++++++++++++++++++++%s", client_addr.sun_path);
-#endif
if (sendto(sock, buf, buf_size, 0, (struct sockaddr *)&client_addr, sizeof(client_addr)) != buf_size) {
thumb_err("sendto failed: %s\n", strerror(errno));
SAFE_FREE(buf);
return FALSE;
}
-#endif
thumb_warn("Sent %s(%d)", res_msg.dst_path, strlen(res_msg.dst_path));
@@ -408,36 +366,22 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
return TRUE;
}
-#ifdef _USE_MEDIA_UTIL_
gboolean _thumb_server_send_msg_to_agent(int msg_type)
{
int sock;
const char *serv_ip = "127.0.0.1";
-#ifdef _USE_UDS_SOCKET_
struct sockaddr_un serv_addr;
-#else
- struct sockaddr_in serv_addr;
-#endif
ms_thumb_server_msg send_msg;
-#ifdef _USE_UDS_SOCKET_
if (ms_ipc_create_client_socket(MS_PROTOCOL_UDP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_COMM_PORT) < 0) {
-#else
- if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock) < 0) {
-#endif
thumb_err("ms_ipc_create_server_socket failed");
return FALSE;
}
memset(&serv_addr, 0, sizeof(serv_addr));
-#ifdef _USE_UDS_SOCKET_
+
serv_addr.sun_family = AF_UNIX;
strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcomm.socket");
-#else
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_addr.s_addr = inet_addr(serv_ip);
- serv_addr.sin_port = htons(MS_THUMB_COMM_PORT);
-#endif
send_msg.msg_type = msg_type;
@@ -459,7 +403,6 @@ gboolean _thumb_server_send_msg_to_agent(int msg_type)
close(sock);
return TRUE;
}
-#endif
gboolean _thumb_server_prepare_socket(int *sock_fd)
{
@@ -471,49 +414,12 @@ gboolean _thumb_server_prepare_socket(int *sock_fd)
memset((void *)&recv_msg, 0, sizeof(recv_msg));
memset((void *)&res_msg, 0, sizeof(res_msg));
-#ifdef _USE_MEDIA_UTIL_
serv_port = MS_THUMB_DAEMON_PORT;
if (ms_ipc_create_server_socket(MS_PROTOCOL_UDP, serv_port, &sock) < 0) {
thumb_err("ms_ipc_create_server_socket failed");
return FALSE;
}
-#else
- char thumb_path[MAX_PATH_SIZE + 1];
-#ifdef _USE_UDS_SOCKET_
- struct sockaddr_un serv_addr;
-#else
- struct sockaddr_in serv_addr;
-#endif
- serv_port = THUMB_DAEMON_PORT;
-
- /* Creaete a TCP socket */
- if (_media_thumb_create_socket(SERVER_SOCKET, &sock) < 0) {
- thumb_err("_media_thumb_create_socket failed");
- return FALSE;
- }
-
- memset(thumb_path, 0, sizeof(thumb_path));
- memset(&serv_addr, 0, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- serv_addr.sin_port = htons(serv_port);
-
- /* Bind to the local address */
- if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
- thumb_err("bind failed : %s", strerror(errno));
- return FALSE;
- }
-
- thumb_dbg("bind success");
-
- /* Listening */
- if (listen(sock, SOMAXCONN) < 0) {
- thumb_err("listen failed : %s", strerror(errno));
- }
-
- thumb_dbg("Listening...");
-#endif
*sock_fd = sock;
diff --git a/server/thumb-server.c b/server/thumb-server.c
index 4248f24..b64a3d6 100755
--- a/server/thumb-server.c
+++ b/server/thumb-server.c
@@ -27,9 +27,6 @@
#include <pthread.h>
#include <heynoti.h>
#include <vconf.h>
-//#include <signal.h>
-//#include <glib-unix.h>
-
#ifdef LOG_TAG
#undef LOG_TAG
@@ -38,7 +35,6 @@
#define LOG_TAG "MEDIA_THUMBNAIL_SERVER"
#define POWEROFF_NOTI_NAME "power_off_start" /*poeroff noti from system-server*/
-
extern GMainLoop *g_thumb_server_mainloop;
static void _media_thumb_signal_handler(void *user_data)
@@ -53,14 +49,13 @@ static void _media_thumb_signal_handler(void *user_data)
return;
}
-int main()
+int main(void)
{
-
int sockfd = -1;
- GSource *source = NULL;
+ GSource *source = NULL;
GIOChannel *channel = NULL;
- GMainContext *context = NULL;
+ GMainContext *context = NULL;
/*heynoti for power off*/
int err = 0;
diff --git a/src/codec/img-codec-osal.c b/src/codec/img-codec-osal.c
index 47062bc..ecce649 100644
--- a/src/codec/img-codec-osal.c
+++ b/src/codec/img-codec-osal.c
@@ -25,7 +25,6 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-//#include <drm-service.h>
#include <drm_client.h>
void *IfegMemAlloc(unsigned int size)
diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h
index b4ad38e..cc3cabf 100755
--- a/src/include/ipc/media-thumb-ipc.h
+++ b/src/include/ipc/media-thumb-ipc.h
@@ -20,21 +20,7 @@
*/
-#include "media-thumb-debug.h"
-#include "media-thumb-types.h"
-#include "media-thumb-internal.h"
-
-#ifdef _USE_MEDIA_UTIL_
-#include "media-util-ipc.h"
-#include "media-server-ipc.h"
-#endif
-
-#ifdef _USE_UDS_SOCKET_
#include <sys/un.h>
-#else
-#include <sys/socket.h>
-#endif
-
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
@@ -43,18 +29,16 @@
#include <signal.h>
#include <sys/types.h>
+#include "media-thumb-debug.h"
+#include "media-thumb-types.h"
+#include "media-thumb-internal.h"
+#include "media-util-ipc.h"
+#include "media-server-ipc.h"
+
#ifndef _MEDIA_THUMB_IPC_H_
#define _MEDIA_THUMB_IPC_H_
-#ifndef _USE_MEDIA_UTIL_
-#define THUMB_DAEMON_PORT 10000
-#endif
#define MAX_PATH_SIZE 4096
-
-#ifndef _USE_MEDIA_UTIL_
-#define TIMEOUT_SEC 10
-#endif
-
#define MAX_TRIES 3
enum {
@@ -72,52 +56,18 @@ enum {
THUMB_FAIL
};
-#ifndef _USE_MEDIA_UTIL_
-enum {
- CLIENT_SOCKET,
- SERVER_SOCKET
-};
-typedef struct _thumbMsg{
- int msg_type;
- media_thumb_type thumb_type;
- int status;
- int pid;
- uid_t uid;
- int thumb_size;
- int thumb_width;
- int thumb_height;
- int origin_width;
- int origin_height;
- int origin_path_size;
- int dest_path_size;
- char org_path[MAX_PATH_SIZE];
- char dst_path[MAX_PATH_SIZE];
-} thumbMsg;
-#endif
-
-int
-_media_thumb_create_socket(int sock_type, int *sock);
-
-int
-_media_thumb_create_udp_socket(int *sock);
-
-int
-_media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg);
-
-#ifdef _USE_UDS_SOCKET_
-int
-_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_un *from_addr, unsigned int *from_size);
-#else
-int
-_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_in *from_addr, unsigned int *from_size);
-#endif
-
-int
-_media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size);
-
-int
-_media_thumb_request(int msg_type,
+int _media_thumb_create_socket(int sock_type, int *sock);
+
+int _media_thumb_create_udp_socket(int *sock);
+
+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,
media_thumb_type thumb_type,
const char *origin_path,
char *thumb_path,
@@ -125,14 +75,12 @@ _media_thumb_request(int msg_type,
media_thumb_info *thumb_info,
uid_t uid);
-int
-_media_thumb_request_async(int msg_type,
+int _media_thumb_request_async(int msg_type,
media_thumb_type thumb_type,
const char *origin_path,
thumbUserData *userData,
uid_t uid);
-int
-_media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid);
+int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid);
#endif /*_MEDIA_THUMB_IPC_H_*/
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
index 3dc5495..5302fa6 100755
--- a/src/include/util/media-thumb-db.h
+++ b/src/include/util/media-thumb-db.h
@@ -49,28 +49,23 @@
sqlite3 *_media_thumb_db_get_handle();
-int
-_media_thumb_db_connect(uid_t uid);
+int _media_thumb_db_connect(uid_t uid);
-int
-_media_thumb_db_disconnect();
+int _media_thumb_db_disconnect();
-int
-_media_thumb_get_thumb_from_db(const char *origin_path,
+int _media_thumb_get_thumb_from_db(const char *origin_path,
char *thumb_path,
int max_length,
int *need_update_db);
-int
-_media_thumb_get_thumb_from_db_with_size(const char *origin_path,
+int _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
char *thumb_path,
int max_length,
int *need_update_db,
int *width,
int *height);
-int
-_media_thumb_update_db(const char *origin_path,
+int _media_thumb_update_db(const char *origin_path,
char *thumb_path,
int width,
int height,
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 2f56457..9284c64 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -40,8 +40,7 @@ typedef struct {
int source_id;
} thumbReq;
-int
-_media_thumb_create_socket(int sock_type, int *sock)
+int _media_thumb_create_socket(int sock_type, int *sock)
{
int sock_fd = 0;
@@ -51,12 +50,7 @@ _media_thumb_create_socket(int sock_type, int *sock)
}
if (sock_type == CLIENT_SOCKET) {
-
-#ifdef _USE_MEDIA_UTIL_
struct timeval tv_timeout = { MS_TIMEOUT_SEC_10, 0 };
-#else
- struct timeval tv_timeout = { TIMEOUT_SEC, 0 };
-#endif
if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) {
thumb_err("setsockopt failed: %s", strerror(errno));
@@ -80,8 +74,7 @@ _media_thumb_create_socket(int sock_type, int *sock)
}
-int
-_media_thumb_create_udp_socket(int *sock)
+int _media_thumb_create_udp_socket(int *sock)
{
int sock_fd = 0;
@@ -90,11 +83,7 @@ _media_thumb_create_udp_socket(int *sock)
return MS_MEDIA_ERR_SOCKET_CONN;
}
-#ifdef _USE_MEDIA_UTIL_
struct timeval tv_timeout = { MS_TIMEOUT_SEC_10, 0 };
-#else
- struct timeval tv_timeout = { TIMEOUT_SEC, 0 };
-#endif
if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) {
thumb_err("setsockopt failed: %s", strerror(errno));
@@ -122,12 +111,9 @@ int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
{
int req_len = 0, i;
- if (g_request_queue == NULL) return -1;
+ if (g_request_queue == NULL) return MS_MEDIA_ERR_INVALID_PARAMETER;
req_len = g_queue_get_length(g_request_queue);
-// thumb_dbg("Queue length : %d", req_len);
-// thumb_dbg("Queue path : %s", path);
-
if (req_len <= 0) {
// thumb_dbg("There is no request in the queue");
} else {
@@ -138,7 +124,6 @@ int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
if (req == NULL) continue;
if (strncmp(path, req->path, strlen(path)) == 0) {
- //thumb_dbg("Popped %s", path);
if (shutdown_channel) {
g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id));
@@ -238,20 +223,11 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
return MS_MEDIA_ERR_NONE;
}
-#ifdef _USE_UDS_SOCKET_
int
_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_un *from_addr, unsigned int *from_size)
-#else
-int
-_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_in *from_addr, unsigned int *from_size)
-#endif
{
int recv_msg_len = 0;
-#ifdef _USE_UDS_SOCKET_
unsigned int from_addr_size = sizeof(struct sockaddr_un);
-#else
- unsigned int from_addr_size = sizeof(struct sockaddr_in);
-#endif
unsigned char *buf = NULL;
buf = (unsigned char*)malloc(sizeof(thumbMsg));
@@ -321,61 +297,19 @@ int
_media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *origin_path, char *thumb_path, int max_length, media_thumb_info *thumb_info, uid_t uid)
{
int sock;
-#ifdef _USE_UDS_SOCKET_
struct sockaddr_un serv_addr;
-#elif defined(_USE_UDS_SOCKET_TCP_)
- struct sockaddr_un serv_addr;
-#else
- const char *serv_ip = "127.0.0.1";
- struct sockaddr_in serv_addr;
-#endif
-
int recv_str_len = 0;
int err = MS_MEDIA_ERR_NONE;
int pid;
-
-#ifdef _USE_MEDIA_UTIL_
-#ifdef _USE_UDS_SOCKET_
if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
-#elif defined(_USE_UDS_SOCKET_TCP_)
- if (ms_ipc_create_client_tcp_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_TCP_PORT) < 0) {
-#else
- if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock) < 0) {
-#endif
thumb_err("ms_ipc_create_client_socket failed");
return MS_MEDIA_ERR_SOCKET_CONN;
}
-#else
- /* Creaete a TCP socket */
- if (_media_thumb_create_socket(CLIENT_SOCKET, &sock) < 0) {
- thumb_err("_media_thumb_create_socket failed");
- return MS_MEDIA_ERR_SOCKET_CONN;
- }
-#endif
memset(&serv_addr, 0, sizeof(serv_addr));
-#ifdef _USE_UDS_SOCKET_
serv_addr.sun_family = AF_UNIX;
-#elif defined(_USE_UDS_SOCKET_TCP_)
- serv_addr.sun_family = AF_UNIX;
-#else
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_addr.s_addr = inet_addr(serv_ip);
-#endif
-
-#ifdef _USE_MEDIA_UTIL_
-#ifdef _USE_UDS_SOCKET_
- strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
-#elif defined(_USE_UDS_SOCKET_TCP_)
- thumb_dbg("");
strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
-#else
- serv_addr.sin_port = htons(MS_THUMB_CREATOR_PORT);
-#endif
-#else
- serv_addr.sin_port = htons(THUMB_DAEMON_PORT);
-#endif
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
@@ -520,8 +454,7 @@ static char* _media_thumb_get_default_path(uid_t uid)
return result_psswd;
}
-int
-_media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
+int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
{
int err = -1;
GdkPixbuf *gdkdata = NULL;
@@ -660,7 +593,6 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
if (err == -1) {
thumb_warn("fsync failed");
}
-
close(fd);
}
/* End of fsync */
@@ -731,66 +663,26 @@ int
_media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char *origin_path, thumbUserData *userData, uid_t uid)
{
int sock;
-#ifdef _USE_UDS_SOCKET_
- struct sockaddr_un serv_addr;
-#elif defined(_USE_UDS_SOCKET_TCP_)
struct sockaddr_un serv_addr;
-#else
- const char *serv_ip = "127.0.0.1";
- struct sockaddr_in serv_addr;
-#endif
-
int pid;
if ((msg_type == THUMB_REQUEST_DB_INSERT) && (__media_thumb_check_req_queue(origin_path) < 0)) {
return MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST;
}
-#ifdef _USE_MEDIA_UTIL_
-#ifdef _USE_UDS_SOCKET_
if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
-#elif defined(_USE_UDS_SOCKET_TCP_)
- if (ms_ipc_create_client_tcp_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_TCP_PORT) < 0) {
-#else
- if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock) < 0) {
-#endif
thumb_err("ms_ipc_create_client_socket failed");
return MS_MEDIA_ERR_SOCKET_CONN;
}
-#else
- /* Creaete a TCP socket */
- if (_media_thumb_create_socket(CLIENT_SOCKET, &sock) < 0) {
- thumb_err("_media_thumb_create_socket failed");
- return MS_MEDIA_ERR_SOCKET_CONN;
- }
-#endif
-
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(sock);
int source_id = -1;
memset(&serv_addr, 0, sizeof(serv_addr));
-#ifdef _USE_UDS_SOCKET_
- serv_addr.sun_family = AF_UNIX;
-#elif defined(_USE_UDS_SOCKET_TCP_)
serv_addr.sun_family = AF_UNIX;
-#else
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_addr.s_addr = inet_addr(serv_ip);
-#endif
-#ifdef _USE_MEDIA_UTIL_
-#ifdef _USE_UDS_SOCKET_
strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
-#elif defined(_USE_UDS_SOCKET_TCP_)
- strcpy(serv_addr.sun_path, "/tmp/media_ipc_thumbcreator.dat");
-#else
- serv_addr.sin_port = htons(MS_THUMB_CREATOR_PORT);
-#endif
-#else
- serv_addr.sin_port = htons(THUMB_DAEMON_PORT);
-#endif
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
@@ -819,7 +711,7 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
req_msg.msg_type = msg_type;
req_msg.thumb_type = thumb_type;
req_msg.uid = uid;
-
+
strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
req_msg.org_path[strlen(req_msg.org_path)] = '\0';
@@ -836,8 +728,6 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
int buf_size = 0;
_media_thumb_set_buffer(&req_msg, &buf, &buf_size);
- //thumb_dbg("buffer size : %d", buf_size);
-
if (send(sock, buf, buf_size, 0) != buf_size) {
thumb_err("sendto failed: %d\n", errno);
SAFE_FREE(buf);
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index b8890f7..2ca640d 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -36,7 +36,6 @@
#include <fcntl.h>
#include <unistd.h>
-//#include <drm-service.h>
#include <drm_client.h>
#include <mm_file.h>
#include <mm_error.h>
@@ -153,8 +152,7 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
buf[strlen(buf)] = '\0';
if (*buf) {
- thumb_dbg("%s: %s\n",
- exif_tag_get_name_in_ifd(tag, ifd), buf);
+ thumb_dbg("%s: %s\n", exif_tag_get_name_in_ifd(tag, ifd), buf);
}
}
}
@@ -913,8 +911,7 @@ int _media_thumb_jpeg(const char *origin_path,
return err;
}
-int
-_media_thumb_image(const char *origin_path,
+int _media_thumb_image(const char *origin_path,
int thumb_width,
int thumb_height,
media_thumb_format format,
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
index 664cc47..275a98e 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -28,12 +28,7 @@
#include <unistd.h>
#include <util-func.h>
-
-#ifdef _USE_MEDIA_UTIL_
static __thread MediaDBHandle *db_handle;
-#else
-static __thread sqlite3 *db_handle;
-#endif
static int _media_thumb_busy_handler(void *pData, int count)
{
@@ -48,8 +43,7 @@ sqlite3 *_media_thumb_db_get_handle()
return db_handle;
}
-int
-_media_thumb_sqlite_connect(sqlite3 **handle)
+int _media_thumb_sqlite_connect(sqlite3 **handle)
{
int err = MS_MEDIA_ERR_NONE;
@@ -81,8 +75,7 @@ _media_thumb_sqlite_connect(sqlite3 **handle)
return MS_MEDIA_ERR_NONE;
}
-int
-_media_thumb_sqlite_disconnect(sqlite3 *handle)
+int _media_thumb_sqlite_disconnect(sqlite3 *handle)
{
int err = MS_MEDIA_ERR_NONE;
if (handle != NULL) {
@@ -258,42 +251,17 @@ int _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
thumbpath_string = sqlite3_mprintf("%s", thumb_path);
query_string = sqlite3_mprintf(UPDATE_THUMB_BY_PATH, thumbpath_string, path_string);
-#ifndef _USE_MEDIA_UTIL_
- char *err_msg = NULL;
- err = sqlite3_exec(handle, query_string, NULL, NULL, &err_msg);
-
- thumb_dbg("Query : %s", query_string);
-
- sqlite3_free(query_string);
- sqlite3_free(thumbpath_string);
- sqlite3_free(path_string);
-
- if (SQLITE_OK != err) {
- if (err_msg) {
- thumb_err("Failed to query[ %s ]", err_msg);
- sqlite3_free(err_msg);
- err_msg = NULL;
- }
-
- return MS_MEDIA_ERR_DB_UPDATE_FAIL;
- }
-
- if (err_msg)
- sqlite3_free(err_msg);
-#else
err = media_db_request_update_db(query_string, uid);
if (err < 0) {
thumb_err("media_db_request_update_db failed : %d", err);
return err;
}
-#endif
thumb_dbg("Query success");
return MS_MEDIA_ERR_NONE;
}
-int
-_media_thumb_update_wh_to_db(sqlite3 *handle,
+int _media_thumb_update_wh_to_db(sqlite3 *handle,
const char *origin_path,
int width,
int height,
@@ -311,34 +279,11 @@ _media_thumb_update_wh_to_db(sqlite3 *handle,
path_string = sqlite3_mprintf("%s", origin_path);
query_string = sqlite3_mprintf(UPDATE_WH_BY_PATH, width, height, path_string);
-#ifndef _USE_MEDIA_UTIL_
- char *err_msg = NULL;
- err = sqlite3_exec(handle, query_string, NULL, NULL, &err_msg);
-
- thumb_dbg("Query : %s", query_string);
-
- sqlite3_free(query_string);
- sqlite3_free(path_string);
-
- if (SQLITE_OK != err) {
- if (err_msg) {
- thumb_err("Failed to query[ %s ]", err_msg);
- sqlite3_free(err_msg);
- err_msg = NULL;
- }
-
- return MS_MEDIA_ERR_DB_UPDATE_FAIL;
- }
-
- if (err_msg)
- sqlite3_free(err_msg);
-#else
err = media_db_request_update_db(query_string, uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_request_update_db failed : %d", err);
return err;
}
-#endif
thumb_dbg("Query success");
return err;
@@ -377,61 +322,27 @@ int _media_thumb_update_thumb_path_wh_to_db(sqlite3 *handle,
int _media_thumb_db_connect(uid_t uid)
{
int err = MS_MEDIA_ERR_NONE;
-/*
- err = media_svc_connect(&mb_svc_handle);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("media_svc_connect failed: %d", err);
- mb_svc_handle = NULL;
- return err;
- }
-*/
-#ifndef _USE_MEDIA_UTIL_
- err = _media_thumb_sqlite_connect(&db_handle);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_sqlite_connect failed: %d", err);
- db_handle = NULL;
- return err;
- }
-#else
+
err = media_db_connect(&db_handle,uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_connect failed: %d", err);
db_handle = NULL;
return MS_MEDIA_ERR_DB_CONNECT_FAIL;
}
-#endif
return MS_MEDIA_ERR_NONE;
}
-int
-_media_thumb_db_disconnect()
+int _media_thumb_db_disconnect()
{
int err = MS_MEDIA_ERR_NONE;
-/*
- err = media_svc_disconnect(mb_svc_handle);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("media_svc_disconnect failed: %d", err);
- }
-
- mb_svc_handle = NULL;
-*/
-#ifndef _USE_MEDIA_UTIL_
- err = _media_thumb_sqlite_disconnect(db_handle);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_sqlite_disconnect failed: %d", err);
- db_handle = NULL;
- return err;
- }
-#else
err = media_db_disconnect(db_handle);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_disconnect failed: %d", err);
db_handle = NULL;
return MS_MEDIA_ERR_DB_CONNECT_FAIL;
}
-#endif
db_handle = NULL;
return err;
@@ -525,40 +436,8 @@ int _media_thumb_update_db(const char *origin_path,
uid_t uid)
{
int err = MS_MEDIA_ERR_NONE;
-
-#if 0
- Mitem *item = NULL;
-
- err = minfo_get_item(mb_svc_handle, origin_path, &item);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("minfo_get_item (%s) failed: %d", origin_path, err);
- return err;
- }
-
- err = minfo_update_media_thumb(mb_svc_handle, item->uuid, thumb_path);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("minfo_update_media_thumb (ID:%s, %s) failed: %d",
- item->uuid, thumb_path, err);
- minfo_destroy_mtype_item(item);
- return err;
- }
-
- if (item->type == MINFO_ITEM_IMAGE) {
- err = minfo_update_image_meta_info_int(mb_svc_handle, item->uuid,
- MINFO_IMAGE_META_WIDTH, width,
- MINFO_IMAGE_META_HEIGHT, height, -1);
-
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("minfo_update_image_meta_info_int failed: %d", err);
- minfo_destroy_mtype_item(item);
- return err;
- }
- }
-
- err = minfo_destroy_mtype_item(item);
-#endif
-
int media_type = THUMB_NONE_TYPE;
+
err = _media_thumb_get_type_from_db(db_handle, origin_path, &media_type);
if (err < 0) {
thumb_err("_media_thumb_get_type_from_db (%s) failed: %d", origin_path, err);
diff --git a/src/util/media-thumb-debug.c b/src/util/media-thumb-debug.c
index b684aa4..ab75286 100755
--- a/src/util/media-thumb-debug.c
+++ b/src/util/media-thumb-debug.c
@@ -109,4 +109,3 @@ thumb_print_debug_time_ex(long start, long end, const char *func_name,
totaltime);
#endif
}
-
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
index 2f0fef0..ed9c0c7 100755
--- a/src/util/media-thumb-util.c
+++ b/src/util/media-thumb-util.c
@@ -169,14 +169,9 @@ _media_thumb_get_file_type(const char *file_full_path)
int _media_thumb_get_store_type_by_path(const char *full_path)
{
if (full_path != NULL) {
- if (strncmp
- (full_path, THUMB_PATH_PHONE,
- strlen(THUMB_PATH_PHONE)) == 0) {
+ if (strncmp(full_path, THUMB_PATH_PHONE, strlen(THUMB_PATH_PHONE)) == 0) {
return THUMB_PHONE;
- } else
- if (strncmp
- (full_path, THUMB_PATH_MMC,
- strlen(THUMB_PATH_MMC)) == 0) {
+ } else if (strncmp(full_path, THUMB_PATH_MMC, strlen(THUMB_PATH_MMC)) == 0) {
return THUMB_MMC;
}
}
@@ -292,8 +287,7 @@ static char* _media_thumb_phone_get_path(uid_t uid)
return result_psswd;
}
-int
-_media_thumb_get_hash_name(const char *file_full_path,
+int _media_thumb_get_hash_name(const char *file_full_path,
char *thumb_hash_path, size_t max_thumb_path, uid_t uid)
{
char *hash_name;
diff --git a/test/test-thumb.c b/test/test-thumb.c
index 5e37255..e408090 100755
--- a/test/test-thumb.c
+++ b/test/test-thumb.c
@@ -135,16 +135,6 @@ int main(int argc, char *argv[])
printf("Success!!\n");
} else if (origin_path && mode == 4) {
printf("Test thumbnail_generate_hash_code\n");
- char hash[255] = {0,};
-
- err = thumbnail_generate_hash_code(origin_path, hash, sizeof(hash));
- if (err < 0) {
- printf("thumbnail_generate_hash_code failed : %d\n", err);
- return -1;
- } else {
- printf("Hash : %s\n", hash);
- }
-
printf("Success!!\n");
} else if (mode == 5) {
printf("Test thumbnail_request_extract_all_thumbs\n");