summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorHaejeong, Kim <backto.kim@samsung.com>2015-10-15 17:59:14 +0900
committerHaejeong, Kim <backto.kim@samsung.com>2015-10-16 09:22:54 +0900
commit43c07c05dd6821a249405477d8bd7912a11ff439 (patch)
tree808c73f787ba242e16017d4470640edc5fdc7290 /server
parenteb15572142170d12f0031380032e73b6e904b187 (diff)
downloadlibmedia-thumbnail-43c07c05dd6821a249405477d8bd7912a11ff439.tar.gz
libmedia-thumbnail-43c07c05dd6821a249405477d8bd7912a11ff439.tar.bz2
libmedia-thumbnail-43c07c05dd6821a249405477d8bd7912a11ff439.zip
Apply tizen coding rule
Change-Id: Id3e53ece459151791f678fbbd230bf7f824afa18
Diffstat (limited to 'server')
-rwxr-xr-xserver/thumb-server-dcm.c41
-rwxr-xr-xserver/thumb-server-internal.c65
-rwxr-xr-xserver/thumb-server.c10
3 files changed, 56 insertions, 60 deletions
diff --git a/server/thumb-server-dcm.c b/server/thumb-server-dcm.c
index 27b274d..8554ed4 100755
--- a/server/thumb-server-dcm.c
+++ b/server/thumb-server-dcm.c
@@ -40,14 +40,14 @@
#ifdef _SUPPORT_DCM
#define dcm_retvm_if(expr, val, fmt, arg...) do { \
- if(expr) { \
+ if (expr) { \
thumb_err(fmt, ##arg); \
thumb_err("(%s) -> %s() return", #expr, __FUNCTION__); \
return (val); \
} \
} while (0)
-#define DCM_CHECK_VAL(expr, val) dcm_retvm_if(!(expr), val, "Invalid parameter, return ERROR code!")
+#define DCM_CHECK_VAL(expr, val) dcm_retvm_if(!(expr), val, "Invalid parameter, return ERROR code!")
#define DCM_SVC_NAME "dcm-svc"
#define DCM_SVC_EXEC_NAME "/usr/bin/dcm-svc"
@@ -57,10 +57,10 @@ static bool b_dcm_svc_launched;
static int g_dcm_timer_id = 0;
static int g_dcm_server_pid = 0;
-static char DCM_IPC_PATH[3][100] =
- {"/var/run/media-server/media_ipc_thumbdcm_dcmrecv",
- "/var/run/media-server/media_ipc_thumbdcm_thumbrecv",
- "/var/run/media-server/dcm_ipc_thumbserver_comm_recv"};
+static char DCM_IPC_PATH[3][100] = {
+ "/var/run/media-server/media_ipc_thumbdcm_dcmrecv",
+ "/var/run/media-server/media_ipc_thumbdcm_thumbrecv",
+ "/var/run/media-server/dcm_ipc_thumbserver_comm_recv"};
static gboolean g_folk_dcm_server = FALSE;
static gboolean g_dcm_server_extracting = FALSE;
@@ -106,8 +106,8 @@ void __thumb_server_dcm_create_timer(int id)
g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), id));
GSource *timer_src = g_timeout_source_new_seconds(MS_TIMEOUT_SEC_20);
- g_source_set_callback (timer_src, __thumb_server_dcm_agent_timer, NULL, NULL);
- g_dcm_timer_id = g_source_attach (timer_src, g_main_context_get_thread_default());
+ g_source_set_callback(timer_src, __thumb_server_dcm_agent_timer, NULL, NULL);
+ g_dcm_timer_id = g_source_attach(timer_src, g_main_context_get_thread_default());
}
@@ -155,8 +155,7 @@ bool __thumb_server_dcm_check_process()
if (result == NULL)
break;
- if (pinfo.d_type != 4 || pinfo.d_name[0] == '.'
- || pinfo.d_name[0] > 57)
+ if (pinfo.d_type != 4 || pinfo.d_name[0] == '.' || pinfo.d_name[0] > 57)
continue;
FILE *fp;
@@ -210,7 +209,7 @@ bool __thumb_server_dcm_check_process()
if (!(recv_msg.msg_type >= 0 && recv_msg.msg_type < THUMB_SERVER_DCM_MSG_MAX)) {
thumb_err("IPC message is wrong!");
- return MEDIA_THUMB_ERROR_NETWORK;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
if (recv_msg.msg_type == THUMB_SERVER_DCM_MSG_SERVER_READY) {
@@ -267,7 +266,7 @@ static int __thumb_server_dcm_process_recv_msg(thumb_server_dcm_ipc_msg_s *recv_
}
if (g_folk_dcm_server == FALSE && g_dcm_server_extracting == FALSE) {
- if(__thumb_server_dcm_check_process() == FALSE) { // dcm-svc is running?
+ if (__thumb_server_dcm_check_process() == FALSE) { // dcm-svc is running?
thumb_warn("Dcm-svc server is not running.. so start it");
memcpy(&last_msg, recv_msg, sizeof(thumb_server_dcm_ipc_msg_s));
if (!__thumb_server_dcm_agent_execute_server()) {
@@ -340,7 +339,7 @@ static int __thumb_server_dcm_receive_tcp_msg(int client_sock, thumb_server_dcm_
if (!(recv_msg->msg_type >= 0 && recv_msg->msg_type < THUMB_SERVER_DCM_MSG_MAX)) {
thumb_err("IPC message is wrong!");
- return MS_MEDIA_ERR_SOCKET_RECEIVE;
+ return MS_MEDIA_ERR_SOCKET_RECEIVE;
}
return MS_MEDIA_ERR_NONE;
@@ -355,11 +354,11 @@ static int __thumb_server_dcm_accept_tcp_socket(int serv_sock, int* client_sock)
if ((sockfd = accept(serv_sock, (struct sockaddr*)&client_addr, &client_addr_len)) < 0) {
thumb_err("accept failed : %s", strerror(errno));
- *client_sock = -1;
+ *client_sock = -1;
return MS_MEDIA_ERR_SOCKET_ACCEPT;
}
- *client_sock = sockfd;
+ *client_sock = sockfd;
return MS_MEDIA_ERR_NONE;
}
@@ -429,12 +428,12 @@ static int __thumb_server_dcm_create_socket(int *socket_fd, thumb_server_dcm_por
strcpy(serv_addr.sun_path, DCM_IPC_PATH[port]);
/* Bind socket to local address */
- for (i = 0; i < 20; i ++) {
+ for (i = 0; i < 20; i++) {
if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == 0) {
bind_success = true;
break;
}
- thumb_dbg("#%d bind",i);
+ thumb_dbg("#%d bind", i);
usleep(250000);
}
@@ -472,7 +471,7 @@ gboolean _thumb_server_dcm_thread(void *data)
GMainContext *context = NULL;
int err = 0;
- thumb_err( "_thumb_server_dcm_thread!S");
+ thumb_err("_thumb_server_dcm_thread!S");
/* Create TCP Socket to receive message from thumb server main thread */
@@ -504,7 +503,7 @@ gboolean _thumb_server_dcm_thread(void *data)
b_dcm_svc_launched = false;
thumb_dbg("********************************************");
- thumb_dbg("*** Thumb Server DCM thread is running ***");
+ thumb_dbg("*** Thumb Server DCM thread is running ***");
thumb_dbg("********************************************");
/* Start to run main event loop for dcm thread */
@@ -513,7 +512,7 @@ gboolean _thumb_server_dcm_thread(void *data)
thumb_dbg("*** Thumb Server DCM thread will be closed ***");
/* Destroy IO channel */
- g_io_channel_shutdown(channel, FALSE, NULL);
+ g_io_channel_shutdown(channel, FALSE, NULL);
g_io_channel_unref(channel);
/* Close the TCP socket */
@@ -532,7 +531,7 @@ int _thumb_server_dcm_send_msg(thumb_server_dcm_ipc_msg_type_e msg_type, uid_t u
return MS_MEDIA_ERR_SOCKET_SEND;
}
- thumb_err( "_thumb_server_dcm_send_msg to %d ", port);
+ thumb_err("_thumb_server_dcm_send_msg to %d", port);
int socket_fd = -1;
struct sockaddr_un serv_addr;
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index 88b6190..eaf1745 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -247,7 +247,7 @@ static int __thumb_daemon_all_extract(uid_t uid)
return MS_MEDIA_ERR_INTERNAL;
}
- while(1) {
+ while (1) {
err = sqlite3_step(sqlite_stmt);
if (err != SQLITE_ROW) {
thumb_dbg("end of row [%s]", sqlite3_errmsg(sqlite_db_handle));
@@ -296,7 +296,7 @@ int _thumb_daemon_process_queue_jobs(gpointer data)
strncpy(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,uid );
+ err = _thumb_daemon_process_job(&recv_msg, &res_msg, uid);
if (err == MS_MEDIA_ERR_FILE_NOT_EXIST) {
thumb_err("Thumbnail processing is failed : %d", err);
} else {
@@ -370,7 +370,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
}
if (ms_cynara_receive_untrusted_message_thumb(client_sock, &recv_msg, &credentials) != MS_MEDIA_ERR_NONE) {
- thumb_err("ms_cynara_receive_untrusted_message_thumb failed");
+ thumb_err("ms_cynara_receive_untrusted_message_thumb failed");
close(client_sock);
return FALSE;
}
@@ -380,9 +380,9 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
_thumb_server_send_deny_message(client_sock);
close(client_sock);
return TRUE;
- }
+ }
- if(recv_msg.msg_type != THUMB_REQUEST_KILL_SERVER) {
+ if (recv_msg.msg_type != THUMB_REQUEST_KILL_SERVER) {
if (ms_cynara_check(&credentials, MEDIA_STORAGE_PRIVILEGE) != MS_MEDIA_ERR_NONE) {
thumb_err("Cynara denied access to process request");
_thumb_server_send_deny_message(client_sock);
@@ -400,17 +400,17 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
thumb_dbg("All thumbnails are being extracted now");
__thumb_daemon_all_extract(recv_msg.uid);
g_idle_add(_thumb_daemon_process_queue_jobs, NULL);
-
+
#ifdef _SUPPORT_DCM
/* Send msg to dcm thread to scan all images */
_thumb_server_dcm_send_msg(THUMB_SERVER_DCM_MSG_SCAN_ALL, recv_msg.uid, NULL, THUMB_SERVER_DCM_PORT_DCM_RECV);
#endif /* _SUPPORT_DCM */
- } else if(recv_msg.msg_type == THUMB_REQUEST_RAW_DATA) {
+ } else 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) {
+ } else if (recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
thumb_warn("received KILL msg from thumbnail agent.");
} else {
- _thumb_daemon_process_job(&recv_msg, &res_msg,recv_msg.uid);
+ _thumb_daemon_process_job(&recv_msg, &res_msg, recv_msg.uid);
#ifdef _SUPPORT_DCM
/* Send msg to dcm thread to scan a single image */
@@ -418,12 +418,12 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
#endif /* _SUPPORT_DCM */
}
- if(res_msg.msg_type == 0)
+ if (res_msg.msg_type == 0)
res_msg.msg_type = recv_msg.msg_type;
res_msg.request_id = recv_msg.request_id;
strncpy(res_msg.org_path, recv_msg.org_path, recv_msg.origin_path_size);
res_msg.origin_path_size = recv_msg.origin_path_size;
- if(res_msg.msg_type != THUMB_RESPONSE_RAW_DATA) {
+ if (res_msg.msg_type != THUMB_RESPONSE_RAW_DATA) {
res_msg.dest_path_size = strlen(res_msg.dst_path)+1;
res_msg.thumb_size = 0;
} else {
@@ -437,8 +437,8 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
unsigned char *buf = NULL;
_media_thumb_set_buffer(&res_msg, &buf, &buf_size);
- while(buf_size > 0) {
- if(buf_size < THUMB_BLOCK_SIZE) {
+ while (buf_size > 0) {
+ if (buf_size < THUMB_BLOCK_SIZE) {
block_size = buf_size;
}
if (send(client_sock, buf+sending_block, block_size, 0) != block_size) {
@@ -446,16 +446,16 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
}
sending_block += block_size;
buf_size -= block_size;
- if(block_size < THUMB_BLOCK_SIZE) {
+ if (block_size < THUMB_BLOCK_SIZE) {
block_size = THUMB_BLOCK_SIZE;
}
}
- if(buf_size == 0) {
+ if (buf_size == 0) {
thumb_dbg_slog("Sent data(%d) from %s", res_msg.thumb_size, res_msg.org_path);
}
SAFE_FREE(buf);
- if(recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
+ if (recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
thumb_warn("Shutting down...");
#ifdef _SUPPORT_DCM
/* Quit dcm thread main loop */
@@ -508,7 +508,7 @@ static gboolean __thumb_server_send_msg_to_agent(int msg_type)
ms_ipc_delete_client_socket(&sock_info);
- return TRUE;
+ return TRUE;
}
static gboolean _thumb_server_send_deny_message(int sockfd)
@@ -558,26 +558,23 @@ static char* _media_thumb_get_default_path(uid_t uid)
{
char *result_psswd = NULL;
struct group *grpinfo = NULL;
- if(uid == getuid())
- {
+ if (uid == getuid()) {
result_psswd = strdup(THUMB_DEFAULT_PATH);
grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
+ if (grpinfo == NULL) {
thumb_err("getgrnam(users) returns NULL !");
- if(result_psswd)
+ if (result_psswd)
free(result_psswd);
return NULL;
}
- }
- else
- {
+ } else {
struct passwd *userinfo = getpwuid(uid);
- if(userinfo == NULL) {
+ if (userinfo == NULL) {
thumb_err("getpwuid(%d) returns NULL !", uid);
return NULL;
}
grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
+ if (grpinfo == NULL) {
thumb_err("getgrnam(users) returns NULL !");
return NULL;
}
@@ -632,7 +629,7 @@ int _thumbnail_get_data(const char *origin_path,
file_type = _media_thumb_get_file_type(origin_path);
thumb_width = *width;
thumb_height = *height;
- if(thumb_width == 0) {
+ if (thumb_width == 0) {
thumb_width = THUMB_DEFAULT_WIDTH;
thumb_height = THUMB_DEFAULT_HEIGHT;
}
@@ -661,7 +658,7 @@ int _thumbnail_get_data(const char *origin_path,
if (origin_width) *origin_width = thumb_info.origin_width;
if (origin_height) *origin_height = thumb_info.origin_height;
if (alpha) *alpha = thumb_info.alpha;
- if (is_saved) *is_saved= thumb_info.is_saved;
+ if (is_saved) *is_saved = thumb_info.is_saved;
thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) 0x%x",
*size, *width, *height, *data);
@@ -782,10 +779,10 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
return MS_MEDIA_ERR_NONE;
} else {
if (strlen(thumb_path) == 0) {
- err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length,uid);
+ err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length, uid);
if (err != MS_MEDIA_ERR_NONE) {
char *default_path = _media_thumb_get_default_path(uid);
- if(default_path) {
+ if (default_path) {
thumb_err("_media_thumb_get_hash_name failed - %d", err);
strncpy(thumb_path, default_path, max_length);
free(default_path);
@@ -803,10 +800,10 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
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,uid);
+ err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length, uid);
if (err != MS_MEDIA_ERR_NONE) {
char *default_path = _media_thumb_get_default_path(uid);
- if(default_path) {
+ if (default_path) {
thumb_err("_media_thumb_get_hash_name failed - %d", err);
strncpy(thumb_path, default_path, max_length);
free(default_path);
@@ -832,7 +829,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
thumb_err("_thumbnail_get_data failed - %d", err);
SAFE_FREE(data);
- if(default_path) {
+ if (default_path) {
strncpy(thumb_path, default_path, max_length);
free(default_path);
default_path = NULL;
@@ -874,7 +871,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
SAFE_FREE(data);
if (msg_type == THUMB_REQUEST_DB_INSERT || msg_type == THUMB_REQUEST_ALL_MEDIA) {
- if(default_path) {
+ if (default_path) {
strncpy(thumb_path, default_path, max_length);
free(default_path);
default_path = NULL;
diff --git a/server/thumb-server.c b/server/thumb-server.c
index 44bd2eb..a927a7b 100755
--- a/server/thumb-server.c
+++ b/server/thumb-server.c
@@ -87,7 +87,7 @@ static void _thumb_server_add_signal_handler(void)
thumb_err("sigaction failed [%s]", strerror(errno));
}
- signal(SIGPIPE,SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
}
#endif
@@ -137,12 +137,12 @@ int main(void)
g_source_attach(source, context);
GSource *source_evas_init = NULL;
- source_evas_init = g_idle_source_new ();
- g_source_set_callback (source_evas_init, _thumb_daemon_start_jobs, NULL, NULL);
- g_source_attach (source_evas_init, context);
+ source_evas_init = g_idle_source_new();
+ g_source_set_callback(source_evas_init, _thumb_daemon_start_jobs, NULL, NULL);
+ g_source_attach(source_evas_init, context);
#ifdef _SUPPORT_DCM
- thumb_dbg( "[GD] _thumb_server_dcm_thread created");
+ thumb_dbg("[GD] _thumb_server_dcm_thread created");
/* Create dcm thread */
GThread *dcm_thread = NULL;
dcm_thread = g_thread_new("dcm_thread", (GThreadFunc)_thumb_server_dcm_thread, NULL);