} while (0)
#define MSAPI_RETV_IF(expr, val) do { \
- if(expr) { \
+ if (expr) { \
LOGE(FONT_COLOR_RED); \
return (val); \
} \
} while (0)
#define MSAPI_RETVM_IF(expr, val, fmt, arg...) do { \
- if(expr) { \
+ if (expr) { \
LOGE(FONT_COLOR_RED fmt, ##arg); \
return (val); \
} \
#define TRUE 1
#endif
-#define MS_SAFE_FREE(src) { if(src) {free(src); src = NULL;} }
+#define MS_SAFE_FREE(src) { if (src) {free(src); src = NULL;} }
#define MS_MALLOC(src, size) { if (size > SIZE_MAX || size <= 0) {src = NULL;} \
- else { src = malloc(size); if(src) memset(src, 0x0, size);} }
+ else { src = malloc(size); if (src) memset(src, 0x0, size);} }
#define MS_STRING_VALID(str) \
((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
int ret = 0;
int recv_msg_size = 0;
- if (!recv_msg ||!credentials)
+ if (!recv_msg || !credentials)
return MS_MEDIA_ERR_INVALID_PARAMETER;
if ((recv_msg_size = read(sockfd, recv_msg, sizeof(ms_comm_msg_s))) < 0) {
}
ret = cynara_creds_socket_get_pid(sockfd, &(credentials->pid));
- if(ret < 0) {
+ if (ret < 0) {
MSAPI_DBG_ERR("cynara_creds_socket_get_pid failed");
return MS_MEDIA_ERR_INTERNAL;
}
ret = cynara_creds_socket_get_user(sockfd, USER_METHOD_UID, &(credentials->uid));
- if(ret < 0) {
+ if (ret < 0) {
MSAPI_DBG_ERR("cynara_creds_socket_get_user failed");
return MS_MEDIA_ERR_INTERNAL;
}
ret = cynara_creds_socket_get_client(sockfd, CLIENT_METHOD_SMACK, &(credentials->smack));
- if(ret < 0) {
+ if (ret < 0) {
MSAPI_DBG_ERR("cynara_creds_socket_get_client failed");
return MS_MEDIA_ERR_INTERNAL;
}
int recv_msg_size = 0;
unsigned char *buf = NULL;
- if (!recv_msg ||!credentials)
+ if (!recv_msg || !credentials)
return MS_MEDIA_ERR_INVALID_PARAMETER;
header_size = sizeof(thumbMsg) -(MAX_FILEPATH_LEN * 2) - sizeof(unsigned char *);
- MS_MALLOC(buf,header_size);
+ MS_MALLOC(buf, header_size);
if ((recv_msg_size = recv(sockfd, buf, header_size, 0)) < 0) {
if (errno == EWOULDBLOCK) {
if (recv_msg->origin_path_size <= 0) {
MS_SAFE_FREE(buf);
- MSAPI_DBG_ERR("msg->origin_path_size is invalid %d", recv_msg->origin_path_size );
+ MSAPI_DBG_ERR("msg->origin_path_size is invalid %d", recv_msg->origin_path_size);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
MS_MALLOC(buf, (unsigned int)(recv_msg->origin_path_size));
- if(buf == NULL) {
+ if (buf == NULL) {
MSAPI_DBG_STRERROR("malloc failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
if (recv_msg->dest_path_size <= 0) {
MS_SAFE_FREE(buf);
- MSAPI_DBG_ERR("msg->origin_path_size is invalid %d", recv_msg->dest_path_size );
+ MSAPI_DBG_ERR("msg->origin_path_size is invalid %d", recv_msg->dest_path_size);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
MS_MALLOC(buf, (unsigned int)(recv_msg->dest_path_size));
- if(buf == NULL) {
+ if (buf == NULL) {
MSAPI_DBG_STRERROR("malloc failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
ret = cynara_creds_socket_get_pid(sockfd, &(credentials->pid));
- if(ret < 0) {
+ if (ret < 0) {
MSAPI_DBG_ERR("cynara_creds_socket_get_pid failed");
return MS_MEDIA_ERR_INTERNAL;
}
ret = cynara_creds_socket_get_user(sockfd, USER_METHOD_UID, &(credentials->uid));
- if(ret < 0) {
+ if (ret < 0) {
MSAPI_DBG_ERR("cynara_creds_socket_get_user failed");
return MS_MEDIA_ERR_INTERNAL;
}
ret = cynara_creds_socket_get_client(sockfd, CLIENT_METHOD_SMACK, &(credentials->smack));
- if(ret < 0) {
+ if (ret < 0) {
MSAPI_DBG_ERR("cynara_creds_socket_get_client failed");
return MS_MEDIA_ERR_INTERNAL;
}
{
char *result_psswd = NULL;
struct group *grpinfo = NULL;
- if(uid == getuid())
- {
+ if (uid == getuid()) {
result_psswd = strdup(MEDIA_DB_NAME);
grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
+ if (grpinfo == NULL) {
MSAPI_DBG_ERR("getgrnam(users) returns NULL !");
return NULL;
}
- }
- else
- {
+ } else {
struct passwd *userinfo = getpwuid(uid);
- if(userinfo == NULL) {
+ if (userinfo == NULL) {
MSAPI_DBG_ERR("getpwuid(%d) returns NULL !", uid);
return NULL;
}
grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
+ if (grpinfo == NULL) {
MSAPI_DBG_ERR("getgrnam(users) returns NULL !");
return NULL;
}
return result_psswd;
}
-static int __media_db_connect_db_with_handle(sqlite3 **db_handle,uid_t uid, bool need_write)
+static int __media_db_connect_db_with_handle(sqlite3 **db_handle, uid_t uid, bool need_write)
{
int ret = SQLITE_OK;
int retry_count = 0;
sock_info.port = MS_DB_UPDATE_PORT;
- if(!MS_STRING_VALID(request_msg))
- {
+ if (!MS_STRING_VALID(request_msg)) {
MSAPI_DBG_ERR("invalid query");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
request_msg_size = strlen(request_msg);
- if(request_msg_size >= MAX_MSG_SIZE)
- {
+ if (request_msg_size >= MAX_MSG_SIZE) {
MSAPI_DBG_ERR("Query is Too long. [%d] query size limit is [%d]", request_msg_size, MAX_MSG_SIZE);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if ((recv_msg_size = recv(sockfd, &recv_msg, sizeof(recv_msg), 0)) < 0) {
MSAPI_DBG_ERR("recv failed : [%d]", sockfd);
- if (errno == EINTR) {
+ if (errno == EINTR) {
MSAPI_DBG_STRERROR("catch interrupt");
goto RETRY;
- }
+ }
if (errno == EWOULDBLOCK) {
- if(retry_count < MAX_RETRY_COUNT) {
+ if (retry_count < MAX_RETRY_COUNT) {
MSAPI_DBG_ERR("TIME OUT[%d]", retry_count);
- retry_count ++;
+ retry_count++;
goto RETRY;
- }
+ }
close(sockfd);
MSAPI_DBG_ERR("Timeout. Can't try any more");
int ret = MS_MEDIA_ERR_NONE;
if (g_tcp_client_sock != -1) {
- if (close(g_tcp_client_sock)<0) {
+ if (close(g_tcp_client_sock) < 0) {
MSAPI_DBG_ERR("sock(%d) close failed", g_tcp_client_sock);
MSAPI_DBG_STRERROR("socket close failed");
ret = MS_MEDIA_ERR_SOCKET_INTERNAL;
int request_msg_size = 0;
int sockfd = -1;
- if(!MS_STRING_VALID(request_msg))
- {
+ if (!MS_STRING_VALID(request_msg)) {
MSAPI_DBG_ERR("invalid query");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
request_msg_size = strlen(request_msg);
- if(request_msg_size >= MAX_MSG_SIZE)
- {
+ if (request_msg_size >= MAX_MSG_SIZE) {
MSAPI_DBG_ERR("Query is Too long. [%d] query size limit is [%d]", request_msg_size, MAX_MSG_SIZE);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
// MSAPI_DBG_SLOG("SQL = [%s]", sql_str);
-EXEC_RETRY:
+EXEC_RETRY :
ret = sqlite3_exec(db_handle, sql_str, NULL, NULL, &zErrMsg);
if (SQLITE_OK != ret) {
- MSAPI_DBG_ERR("DB Update Fail SQL:%s", sql_str);
+ MSAPI_DBG_ERR("DB Update Fail SQL : %s", sql_str);
MSAPI_DBG_ERR("ERROR [%s]", zErrMsg);
if (ret == SQLITE_BUSY) {
ret = MS_MEDIA_ERR_DB_BUSY_FAIL;
}
if (zErrMsg)
- sqlite3_free (zErrMsg);
+ sqlite3_free(zErrMsg);
return ret;
}
MSAPI_DBG_FUNC();
- ret = __media_db_connect_db_with_handle(&db_handle,uid, need_write);
+ ret = __media_db_connect_db_with_handle(&db_handle, uid, need_write);
MSAPI_RETV_IF(ret != MS_MEDIA_ERR_NONE, ret);
*handle = db_handle;
MSAPI_RETVM_IF(!MS_STRING_VALID(query_str), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid Query");
- ret = __media_db_request_update_tcp(MS_MSG_DB_UPDATE, query_str ,uid);
+ ret = __media_db_request_update_tcp(MS_MSG_DB_UPDATE, query_str, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MSAPI_DBG_ERR("__media_db_request_update_tcp failed : %d", ret);
}
#define MS_SOCK_UDP_BLOCK_SIZE 512
-char MEDIA_IPC_PATH[][70] ={
+char MEDIA_IPC_PATH[][70] = {
{"/var/run/media-server/media_ipc_dbbatchupdate.socket"},
{"/var/run/media-server/media_ipc_scandaemon.socket"},
{"/var/run/media-server/media_ipc_scanner.socket"},
{"/var/run/media-server/media_ipc_thumbdaemon.socket"},
};
-char MEDIA_IPC_PATH_CLIENT[][80] ={
+char MEDIA_IPC_PATH_CLIENT[][80] = {
{"/var/run/user/%i/media-server/media_ipc_dbbatchupdate_client%i.socket"},
{"/var/run/user/%i/media-server/media_ipc_scandaemon_client%i.socket"},
{"/var/run/user/%i/media-server/media_ipc_scanner_client%i.socket"},
{"/var/run/user/%i/media-server/media_ipc_thumbdaemon_client%i.socket"},
};
-char MEDIA_IPC_PATH_CLIENT_ROOT[][80] ={
+char MEDIA_IPC_PATH_CLIENT_ROOT[][80] = {
{"/var/run/media-server/media_ipc_dbbatchupdate_client%i.socket"},
{"/var/run/media-server/media_ipc_scandaemon_client%i.socket"},
{"/var/run/media-server/media_ipc_scanner_client%i.socket"},
{"/var/run/media-server/media_ipc_thumbdaemon_client%i.socket"},
};
-static int _mkdir(const char *dir, mode_t mode) {
- char tmp[256];
- char *p = NULL;
- size_t len;
-
- snprintf(tmp, sizeof(tmp),"%s",dir);
- len = strlen(tmp);
- if(tmp[len - 1] == '/')
- tmp[len - 1] = 0;
- for(p = tmp + 1; *p; p++)
- if(*p == '/') {
- *p = 0;
- mkdir(tmp, mode);
- *p = '/';
- }
- return mkdir(tmp, mode);
+static int _mkdir(const char *dir, mode_t mode)
+{
+ char tmp[256];
+ char *p = NULL;
+ size_t len;
+
+ snprintf(tmp, sizeof(tmp), "%s", dir);
+ len = strlen(tmp);
+ if (tmp[len - 1] == '/')
+ tmp[len - 1] = 0;
+ for (p = tmp + 1; *p; p++)
+ if (*p == '/') {
+ *p = 0;
+ mkdir(tmp, mode);
+ *p = '/';
+ }
+
+ return mkdir(tmp, mode);
}
int ms_ipc_create_client_socket(ms_protocol_e protocol, int timeout_sec, ms_sock_info_s* sock_info)
struct timeval tv_timeout = { timeout_sec, 0 };
- if(protocol == MS_PROTOCOL_UDP)
- {
- char *path;
- int cx,len;
+ if (protocol == MS_PROTOCOL_UDP) {
+ char *path = NULL;
+ int cx = 0, len = 0;
- if (tzplatform_getuid(TZ_USER_NAME) == 0 ){
- cx = snprintf ( NULL, 0, MEDIA_IPC_PATH_CLIENT_ROOT[sock_info->port],getpid());
- sock_info->sock_path = (char*)malloc((cx + 1 )*sizeof(char));
- snprintf ( sock_info->sock_path, cx + 1, MEDIA_IPC_PATH_CLIENT_ROOT[sock_info->port],getpid());
+ if (tzplatform_getuid(TZ_USER_NAME) == 0) {
+ cx = snprintf(NULL, 0, MEDIA_IPC_PATH_CLIENT_ROOT[sock_info->port], getpid());
+ sock_info->sock_path = (char*)malloc((cx + 1)*sizeof(char));
+ snprintf(sock_info->sock_path, cx + 1, MEDIA_IPC_PATH_CLIENT_ROOT[sock_info->port], getpid());
} else {
- len = snprintf ( NULL, 0, "/var/run/user/%i/media-server", tzplatform_getuid(TZ_USER_NAME));
- path = (char*)malloc((len + 1 )*sizeof(char));
- snprintf ( path, len + 1, "/var/run/user/%i/media-server", tzplatform_getuid(TZ_USER_NAME));
+ len = snprintf(NULL, 0, "/var/run/user/%i/media-server", tzplatform_getuid(TZ_USER_NAME));
+ path = (char*)malloc((len + 1)*sizeof(char));
+ snprintf(path, len + 1, "/var/run/user/%i/media-server", tzplatform_getuid(TZ_USER_NAME));
_mkdir(path, 0777);
free(path);
- cx = snprintf ( NULL, 0, MEDIA_IPC_PATH_CLIENT[sock_info->port], tzplatform_getuid(TZ_USER_NAME),getpid());
- sock_info->sock_path = (char*)malloc((cx + 1 )*sizeof(char));
- snprintf ( sock_info->sock_path, cx + 1, MEDIA_IPC_PATH_CLIENT[sock_info->port],tzplatform_getuid(TZ_USER_NAME),getpid());
+ cx = snprintf(NULL, 0, MEDIA_IPC_PATH_CLIENT[sock_info->port], tzplatform_getuid(TZ_USER_NAME), getpid());
+ sock_info->sock_path = (char*)malloc((cx + 1)*sizeof(char));
+ snprintf(sock_info->sock_path, cx + 1, MEDIA_IPC_PATH_CLIENT[sock_info->port], tzplatform_getuid(TZ_USER_NAME), getpid());
}
/* Create a datagram/UDP socket */
free(sock_info->sock_path);
return MS_MEDIA_ERR_SOCKET_CONN;
}
- }
- else
- {
+ } else {
/*Create TCP Socket*/
if ((sock = socket(PF_FILE, SOCK_STREAM, 0)) < 0) {
MSAPI_DBG_STRERROR("socket failed");
MSAPI_DBG("sockfd %d close", sock_info->sock_fd);
if (sock_info->sock_path != NULL) {
err = unlink(sock_info->sock_path);
- if (err< 0) {
+ if (err < 0) {
MSAPI_DBG_STRERROR("unlink failed");
}
free(sock_info->sock_path);
serv_port = port;
- if(protocol == MS_PROTOCOL_UDP)
- {
+ if (protocol == MS_PROTOCOL_UDP) {
/* Create a datagram/UDP socket */
if ((sock = socket(PF_FILE, SOCK_DGRAM, 0)) < 0) {
MSAPI_DBG_STRERROR("socket failed");
return MS_MEDIA_ERR_SOCKET_CONN;
}
- }
- else
- {
+ } else {
/* Create a TCP socket */
if ((sock = socket(PF_FILE, SOCK_STREAM, 0)) < 0) {
MSAPI_DBG_STRERROR("socket failed");
strncpy(serv_addr.sun_path, MEDIA_IPC_PATH[serv_port], strlen(MEDIA_IPC_PATH[serv_port]));
/* Bind to the local address */
- for (i = 0; i < 100; i ++) {
+ for (i = 0; i < 100; i++) {
if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == 0) {
bind_success = true;
break;
}
- MSAPI_DBG("%d",i);
+ MSAPI_DBG("%d", i);
usleep(250000);
}
int recv_msg_size;
socklen_t addr_len;
- if (!recv_msg ||!recv_addr)
+ if (!recv_msg || !recv_addr)
return MS_MEDIA_ERR_INVALID_PARAMETER;
addr_len = sizeof(struct sockaddr_un);
int recv_size = 0;
unsigned int remain_size = msg_size;
- if (!recv_msg ||!recv_addr)
+ if (!recv_msg || !recv_addr)
return MS_MEDIA_ERR_INVALID_PARAMETER;
addr_len = sizeof(struct sockaddr_un);
block_size = MS_SOCK_UDP_BLOCK_SIZE;
block_buf = malloc(block_size * sizeof(unsigned char));
- if(block_buf == NULL) {
+ if (block_buf == NULL) {
MSAPI_DBG_ERR("malloc failed.");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
memset(block_buf, 0, block_size * sizeof(unsigned char));
- while(remain_size > 0) {
- if(remain_size < MS_SOCK_UDP_BLOCK_SIZE) {
+ while (remain_size > 0) {
+ if (remain_size < MS_SOCK_UDP_BLOCK_SIZE) {
block_size = remain_size;
}
if ((recv_msg_size = recvfrom(sockfd, block_buf, block_size, 0, (struct sockaddr *)recv_addr, &addr_len)) < 0) {
#define MS_MEDIA_DBUS_NAME_INTERNAL "ms_db_updated_internal"
-typedef struct internal_noti_cb_data{
+typedef struct internal_noti_cb_data {
DBusConnection *dbus;
db_update_cb user_callback;
void *user_data;
int path_length = strlen(path) + 1;
/* Get a connection to the session bus */
- dbus_error_init (&error);
- bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+ dbus_error_init(&error);
+ bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
if (!bus) {
- MSAPI_DBG ("Failed to connect to the D-BUS daemon: %s", error.message);
- dbus_error_free (&error);
+ MSAPI_DBG("Failed to connect to the D-BUS daemon: %s", error.message);
+ dbus_error_free(&error);
return MS_MEDIA_ERR_INTERNAL;
}
- message = dbus_message_new_signal (MS_MEDIA_DBUS_PATH, MS_MEDIA_DBUS_INTERFACE, MS_MEDIA_DBUS_NAME_INTERNAL);
+ message = dbus_message_new_signal(MS_MEDIA_DBUS_PATH, MS_MEDIA_DBUS_INTERFACE, MS_MEDIA_DBUS_NAME_INTERNAL);
if (message != NULL) {
path_array = malloc(sizeof(unsigned char) * path_length);
memcpy(path_array, path, path_length);
MSAPI_DBG("FILE CHANGED");
if (uuid != NULL && mime_type != NULL) {
/* fill all datas */
- dbus_message_append_args (message,
+ dbus_message_append_args(message,
DBUS_TYPE_INT32, &item,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &update_type,
} else {
MSAPI_DBG_ERR("uuid or mime_type is NULL");
MS_SAFE_FREE(path_array);
- dbus_message_unref (message);
+ dbus_message_unref(message);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
} else if (item == MS_MEDIA_ITEM_DIRECTORY) {
MSAPI_DBG("DIRECTORY CHANGED");
/* fill all datas */
- if(uuid != NULL) {
- dbus_message_append_args (message,
+ if (uuid != NULL) {
+ dbus_message_append_args(message,
DBUS_TYPE_INT32, &item,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &update_type,
DBUS_TYPE_STRING, &uuid,
DBUS_TYPE_INVALID);
} else {
- dbus_message_append_args (message,
+ dbus_message_append_args(message,
DBUS_TYPE_INT32, &item,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &update_type,
MS_SAFE_FREE(path_array);
/* Send the signal */
- dbus_connection_send (bus, message, NULL);
+ dbus_connection_send(bus, message, NULL);
/* Free the signal now we have finished with it */
- dbus_message_unref (message);
+ dbus_message_unref(message);
MSAPI_DBG_ERR("success send notification");
} else {
__get_message_internal(DBusMessage *message, db_update_cb user_cb, void *userdata)
{
/* A Ping signal on the com.burtonini.dbus.Signal interface */
- if (dbus_message_is_signal (message, MS_MEDIA_DBUS_INTERFACE, MS_MEDIA_DBUS_NAME_INTERNAL)) {
+ if (dbus_message_is_signal(message, MS_MEDIA_DBUS_INTERFACE, MS_MEDIA_DBUS_NAME_INTERNAL)) {
int i = 0;
int current_type = DBUS_TYPE_INVALID;
DBusError error;
void *recevie_path = NULL;
int path_len = 0;
- dbus_error_init (&error);
+ dbus_error_init(&error);
MSAPI_DBG("size [%d]", sizeof(value));
memset(value, 0x0, sizeof(value));
/* get data from dbus message */
- dbus_message_iter_init (message, &read_iter);
- while ((current_type = dbus_message_iter_get_arg_type (&read_iter)) != DBUS_TYPE_INVALID){
+ dbus_message_iter_init(message, &read_iter);
+ while ((current_type = dbus_message_iter_get_arg_type(&read_iter)) != DBUS_TYPE_INVALID) {
if (current_type == DBUS_TYPE_ARRAY) {
DBusMessageIter sub;
dbus_message_iter_recurse(&read_iter, &sub);
dbus_message_iter_get_fixed_array(&sub, &recevie_path, &path_len);
} else {
- dbus_message_iter_get_basic (&read_iter, &value[i]);
- i ++;
+ dbus_message_iter_get_basic(&read_iter, &value[i]);
+ i++;
}
- dbus_message_iter_next (&read_iter);
+ dbus_message_iter_next(&read_iter);
}
item = value[0].i32;
dbus_g_thread_init();
- dbus_error_init (&error);
+ dbus_error_init(&error);
- dbus = dbus_bus_get_private (DBUS_BUS_SYSTEM, &error);
+ dbus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
if (!dbus) {
- MSAPI_DBG ("Failed to connect to the D-BUS daemon: %s", error.message);
- dbus_error_free (&error);
+ MSAPI_DBG("Failed to connect to the D-BUS daemon: %s", error.message);
+ dbus_error_free(&error);
ret = MS_MEDIA_ERR_INTERNAL;
goto ERROR;
}
- dbus_connection_setup_with_g_main (dbus, NULL);
+ dbus_connection_setup_with_g_main(dbus, NULL);
MS_MALLOC(noti_data, sizeof(internal_noti_cb_data));
if (noti_data == NULL) {
noti_data->user_data = user_data;
/* listening to messages from all objects as no path is specified */
- dbus_bus_add_match (dbus, MS_MEDIA_DBUS_MATCH_RULE, &error);
- if( !dbus_connection_add_filter (dbus, __message_filter_internal, noti_data, NULL)) {
- dbus_bus_remove_match (dbus, MS_MEDIA_DBUS_MATCH_RULE, NULL);
+ dbus_bus_add_match(dbus, MS_MEDIA_DBUS_MATCH_RULE, &error);
+ if (!dbus_connection_add_filter(dbus, __message_filter_internal, noti_data, NULL)) {
+ dbus_bus_remove_match(dbus, MS_MEDIA_DBUS_MATCH_RULE, NULL);
ret = MS_MEDIA_ERR_INTERNAL;
goto ERROR;
}
MediaNotiHandle data;
/*delete all node*/
- if(handle_list_internal != NULL) {
- for (i =0; i < handle_list_internal->len; i++) {
+ if (handle_list_internal != NULL) {
+ for (i = 0; i < handle_list_internal->len; i++) {
data = g_array_index(handle_list_internal , MediaNotiHandle, i);
MSAPI_DBG_ERR("%x %x", handle, data);
if (data == handle) {
g_mutex_lock(&mutex_internal);
err = _find_handle(handle, &idx);
- if(err == MS_MEDIA_ERR_NONE) {
+ if (err == MS_MEDIA_ERR_NONE) {
DBusConnection *dbus = ((internal_noti_cb_data*)handle)->dbus;
dbus_connection_remove_filter(dbus, __message_filter_internal, (internal_noti_cb_data*)handle);
- dbus_bus_remove_match (dbus, MS_MEDIA_DBUS_MATCH_RULE, NULL);
+ dbus_bus_remove_match(dbus, MS_MEDIA_DBUS_MATCH_RULE, NULL);
dbus_connection_close(dbus);
dbus_connection_unref(dbus);
g_array_remove_index(handle_list_internal, idx);
#define MS_MEDIA_DBUS_NAME "ms_db_updated"
-typedef struct noti_callback_data{
+typedef struct noti_callback_data {
db_update_cb user_callback;
void *user_data;
} noti_callback_data;
if (g_bus == NULL) {
g_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (!g_bus) {
- MSAPI_DBG ("Failed to connect to the g D-BUS daemon: %s", error->message);
- g_error_free (error);
+ MSAPI_DBG("Failed to connect to the g D-BUS daemon: %s", error->message);
+ g_error_free(error);
ret = MS_MEDIA_ERR_INTERNAL;
goto ERROR;
}
g_data_store = (void *)callback_data;
}
- ref_count ++;
+ ref_count++;
g_mutex_unlock(¬i_mutex);
g_data_store = NULL;
}
- ref_count --;
+ ref_count--;
g_mutex_unlock(¬i_mutex);
bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (!bus) {
- MSAPI_DBG ("Failed to get gdbus connection: %s", error->message);
- g_error_free (error);
+ MSAPI_DBG("Failed to get gdbus connection: %s", error->message);
+ g_error_free(error);
return MS_MEDIA_ERR_INTERNAL;
}
} else if (item == MS_MEDIA_ITEM_DIRECTORY) {
MSAPI_DBG("DIRECTORY CHANGED");
/* fill all datas */
- if(uuid != NULL) {
+ if (uuid != NULL) {
message = g_variant_new("(iiiss)", item, pid, update_type, path, uuid);
} else {
message = g_variant_new("(iiis)", item, pid, update_type, path);
MS_MEDIA_DBUS_NAME,
message,
&error);
- if (!emmiting)
- {
- MSAPI_DBG_ERR("g_dbus_connection_emit_signal failed : %s", error?error->message:"none");
- if (error)
- {
+ if (!emmiting) {
+ MSAPI_DBG_ERR("g_dbus_connection_emit_signal failed : %s", error ? error->message : "none");
+ if (error) {
MSAPI_DBG_ERR("Error in g_dbus_connection_emit_signal");
g_object_unref(bus);
g_error_free(error);
gboolean flush = FALSE;
flush = g_dbus_connection_flush_sync(bus, NULL, &error);
- if (!flush)
- {
+ if (!flush) {
MSAPI_DBG_ERR("g_dbus_connection_flush_sync failed");
- if (error)
- {
+ if (error) {
MSAPI_DBG_ERR("error : [%s]", error->message);
g_object_unref(bus);
g_error_free(error);
bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (!bus) {
- MSAPI_DBG ("Failed to get gdbus connection: %s", error->message);
- g_error_free (error);
+ MSAPI_DBG("Failed to get gdbus connection: %s", error->message);
+ g_error_free(error);
return MS_MEDIA_ERR_INTERNAL;
}
} else if (item == MS_MEDIA_ITEM_DIRECTORY) {
MSAPI_DBG("DIRECTORY CHANGED");
/* fill all datas */
- if(uuid != NULL) {
+ if (uuid != NULL) {
message = g_variant_new("(iiiss)", item, pid, update_type, path, uuid);
} else {
message = g_variant_new("(iiis)", item, pid, update_type, path);
MS_MEDIA_DBUS_NAME,
message,
&error);
- if (!emmiting)
- {
- MSAPI_DBG_ERR("g_dbus_connection_emit_signal failed : %s", error?error->message:"none");
- if (error)
- {
+ if (!emmiting) {
+ MSAPI_DBG_ERR("g_dbus_connection_emit_signal failed : %s", error ? error->message : "none");
+ if (error) {
MSAPI_DBG_ERR("Error in g_dbus_connection_emit_signal");
g_object_unref(bus);
g_error_free(error);
gboolean flush = FALSE;
flush = g_dbus_connection_flush_sync(bus, NULL, &error);
- if (!flush)
- {
+ if (!flush) {
MSAPI_DBG_ERR("g_dbus_connection_flush_sync failed");
- if (error)
- {
+ if (error) {
MSAPI_DBG_ERR("error : [%s]", error->message);
g_object_unref(bus);
g_error_free(error);
#include "media-util-dbg.h"
#include "media-util.h"
-typedef struct media_callback_data{
+typedef struct media_callback_data {
GSource *source;
scan_complete_cb user_callback;
void *user_data;
char *sock_path;
} media_callback_data;
-typedef struct media_scan_data{
+typedef struct media_scan_data {
GIOChannel *src;
media_callback_data *cb_data;
int pid;
struct stat sb;
DIR *dp = NULL;
- if (!_is_valid_path(dir_path,uid)) {
+ if (!_is_valid_path(dir_path, uid)) {
MSAPI_DBG("Invalid path : %s", dir_path);
return MS_MEDIA_ERR_INVALID_PATH;
}
}
return MS_MEDIA_ERR_INTERNAL;
} else {
- if((sb.st_mode & S_IFMT) != S_IFDIR) {
+ if ((sb.st_mode & S_IFMT) != S_IFDIR) {
MSAPI_DBG("Invalid path : %s is not directory", dir_path);
return MS_MEDIA_ERR_INVALID_PATH;
}
req_result.pid = recv_msg.pid;
req_result.result = recv_msg.result;
- if (recv_msg.msg_type ==MS_MSG_SCANNER_RESULT) {
+ if (recv_msg.msg_type == MS_MSG_SCANNER_RESULT) {
req_result.complete_path = strndup(recv_msg.msg, recv_msg.msg_size);
req_result.request_type = MEDIA_DIRECTORY_SCAN;
MSAPI_DBG("complete_path :%d", req_result.complete_path);
req_data = g_array_index(req_list, media_scan_data*, i);
if (strcmp(req_data->req_path, req_path) == 0) {
flag = true;
- g_array_remove_index (req_list, i);
+ g_array_remove_index(req_list, i);
}
}
char *sock_path = NULL;
ms_sock_info_s sock_info;
- if(!MS_STRING_VALID(request_msg))
- {
+ if (!MS_STRING_VALID(request_msg)) {
MSAPI_DBG_ERR("invalid query");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
MSAPI_DBG("REQUEST DIRECTORY SCANNING[%s]", request_msg);
request_msg_size = strlen(request_msg);
- if(request_msg_size >= MAX_MSG_SIZE)
- {
+ if (request_msg_size >= MAX_MSG_SIZE) {
MSAPI_DBG_ERR("Query is Too long. [%d] query size limit is [%d]", request_msg_size, MAX_MSG_SIZE);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
return ret;
}
- ret = _attach_callback(request_msg, &sockfd, sock_path, user_callback ,user_data);
- if(ret != MS_MEDIA_ERR_NONE)
+ ret = _attach_callback(request_msg, &sockfd, sock_path, user_callback, user_data);
+ if (ret != MS_MEDIA_ERR_NONE)
return ret;
return ret;
ms_sock_info_s sock_info;
sock_info.port = MS_SCANNER_PORT;
- if(!MS_STRING_VALID(request_msg))
- {
+ if (!MS_STRING_VALID(request_msg)) {
MSAPI_DBG_ERR("invalid query");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
MSAPI_DBG("REQUEST CANCEL DIRECTORY SCANNING[%s]", request_msg);
request_msg_size = strlen(request_msg);
- if(request_msg_size >= MAX_MSG_SIZE)
- {
+ if (request_msg_size >= MAX_MSG_SIZE) {
MSAPI_DBG_ERR("Query is Too long. [%d] query size limit is [%d]", request_msg_size, MAX_MSG_SIZE);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
}
ret = _remove_request(request_msg);
- if(ret != MS_MEDIA_ERR_NONE)
+ if (ret != MS_MEDIA_ERR_NONE)
return ret;
return ret;
{
int ret = MS_MEDIA_ERR_NONE;
- ret = _check_dir_path(directory_path,uid);
- if(ret != MS_MEDIA_ERR_NONE)
+ ret = _check_dir_path(directory_path, uid);
+ if (ret != MS_MEDIA_ERR_NONE)
return ret;
if (recursive_on == TRUE)
int ret = MS_MEDIA_ERR_NONE;
ret = _check_dir_path(directory_path, uid);
- if(ret != MS_MEDIA_ERR_NONE)
+ if (ret != MS_MEDIA_ERR_NONE)
return ret;
ret = __media_db_request_update_cancel(MS_MSG_DIRECTORY_SCANNING_CANCEL, directory_path);
Name: media-server
Summary: File manager service server.
-Version: 0.2.59
+Version: 0.2.60
Release: 0
Group: Multimedia/Service
License: Apache-2.0
#define MS_DBG_SLOG(fmt, args...) do{ if (true) { \
SECURE_LOGD(fmt "\n" , ##args); \
- }} while(false)
+ }} while (false)
#define MS_DBG(fmt, args...) do{ if (true) { \
LOGD(fmt "\n" , ##args); \
- }} while(false)
+ }} while (false)
#define MS_DBG_INFO(fmt, args...) do{ if (true) { \
LOGI(fmt "\n" , ##args); \
- }} while(false)
+ }} while (false)
#define MS_DBG_WARN(fmt, args...) do{ if (true) { \
LOGW(fmt "\n", ##args); \
- }} while(false)
+ }} while (false)
#define MS_DBG_ERR(fmt, args...) do{ if (true) { \
LOGE(fmt "\n", ##args); \
- }} while(false)
+ }} while (false)
#define MS_DBG_FENTER() do{ if (true) { \
LOGD("<ENTER> \n"); \
- }} while(false)
+ }} while (false)
#define MS_DBG_FLEAVE() do{ if (true) { \
LOGD("<LEAVE> \n"); \
- }} while(false)
+ }} while (false)
#endif /*_MEDIA_COMMON_DBG_H_*/
/*Use for Poweroff sequence*/
#define POWEROFF -1 /*This number uses for stopping Scannig thread*/
-#define MS_SAFE_FREE(src) { if(src) {free(src); src = NULL;} }
+#define MS_SAFE_FREE(src) { if (src) {free(src); src = NULL;} }
#define MS_MALLOC(src, size) { if (size > SIZE_MAX || size <= 0) {src = NULL;} \
- else { src = malloc(size); if(src) memset(src, 0x0, size);} }
+ else { src = malloc(size); if (src) memset(src, 0x0, size);} }
#define MS_STRING_VALID(str) \
((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
#include "media-common-dbg.h"
#include <tzplatform_config.h>
-#define CONFIG_PATH tzplatform_mkpath(TZ_SYS_DATA,"file-manager-service/plugin-config")
+#define CONFIG_PATH tzplatform_mkpath(TZ_SYS_DATA, "file-manager-service/plugin-config")
#define EXT ".so"
#define EXT_LEN 3
#define MSC_REGISTER_COUNT 300 /*For bundle commit*/
MS_DBG_ERR("fp is NULL");
return MS_MEDIA_ERR_FILE_OPEN_FAIL;
}
- while(1) {
+ while (1) {
if (fgets(buf, 256, fp) == NULL)
break;
/*load information of so*/
_ms_load_config();
- if(so_array->len == 0) {
+ if (so_array->len == 0) {
MS_DBG_ERR("There is no information for functions");
return MS_MEDIA_ERR_DYNAMIC_LINK;
}
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- while(lib_index < lib_num) {
+ while (lib_index < lib_num) {
/*get handle*/
MS_DBG_SLOG("[name of so : %s]", g_array_index(so_array, char*, lib_index));
func_handle[lib_index] = dlopen(g_array_index(so_array, char*, lib_index), RTLD_LAZY);
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- for(lib_index = 0 ; lib_index < lib_num; lib_index ++) {
+ for (lib_index = 0 ; lib_index < lib_num; lib_index++) {
MS_MALLOC(func_array[lib_index], sizeof(void*) * eFUNC_MAX);
if (func_array[lib_index] == NULL) {
int index;
- for (index = 0; index < lib_index; index ++) {
+ for (index = 0; index < lib_index; index++) {
MS_SAFE_FREE(func_array[index]);
}
MS_SAFE_FREE(func_array);
if (func_array[lib_index][func_index] == NULL) {
int index;
- for (index = 0; index < lib_index; index ++) {
+ for (index = 0; index < lib_index; index++) {
MS_SAFE_FREE(func_array[index]);
}
MS_SAFE_FREE(func_array);
{
int lib_index;
- for (lib_index = 0; lib_index < lib_num; lib_index ++)
+ for (lib_index = 0; lib_index < lib_num; lib_index++)
dlclose(func_handle[lib_index]);
for (lib_index = 0; lib_index < lib_num; lib_index++) {
}
}
- MS_SAFE_FREE (func_array);
- MS_SAFE_FREE (func_handle);
+ MS_SAFE_FREE(func_array);
+ MS_SAFE_FREE(func_handle);
if (so_array) {
/*delete all node*/
- while(so_array->len != 0) {
+ while (so_array->len != 0) {
char *so_name = NULL;
so_name = g_array_index(so_array , char*, 0);
- g_array_remove_index (so_array, 0);
+ g_array_remove_index(so_array, 0);
MS_SAFE_FREE(so_name);
}
g_array_free(so_array, FALSE);
/*Lock mutex for openning db*/
g_mutex_lock(&db_mutex);
- MS_MALLOC(*handle, sizeof (void*) * lib_num);
+ MS_MALLOC(*handle, sizeof(void*) * lib_num);
if (*handle == NULL) {
MS_DBG_ERR("malloc failed");
g_mutex_unlock(&db_mutex);
*dir_array = g_array_new(FALSE, FALSE, sizeof(ms_dir_info_s*));
if (count != 0) {
- for(i = 0; i < count; i ++) {
+ for (i = 0; i < count; i++) {
dir_info = malloc(sizeof(ms_dir_info_s));
if (dir_info != NULL) {
dir_info->dir_path = strdup(folder_list[i]);
dir_info->modified_time = modified_time_list[i];
- dir_info->item_num= item_num_list[i];
+ dir_info->item_num = item_num_list[i];
g_array_append_val(*dir_array, dir_info);
} else {
MS_DBG_ERR("malloc failed");
ERROR:
if (*dir_array) {
- while((*dir_array)->len != 0) {
+ while ((*dir_array)->len != 0) {
ms_dir_info_s *data = NULL;
data = g_array_index(*dir_array , ms_dir_info_s*, 0);
- g_array_remove_index (*dir_array, 0);
+ g_array_remove_index(*dir_array, 0);
MS_SAFE_FREE(data->dir_path);
}
g_array_free(*dir_array, FALSE);
return res;
}
- int ms_genarate_uuid(void **handle, char **uuid)
+int ms_genarate_uuid(void **handle, char **uuid)
{
int lib_index = 0;
int ret;
else if (status == MS_SDCARD_REMOVED)
ret = notification_status_message_post(_GETSYSTEMSTR("IDS_COM_BODY_SD_CARD_UNEXPECTEDLY_REMOVED"));
- if(ret != NOTIFICATION_ERROR_NONE)
+ if (ret != NOTIFICATION_ERROR_NONE)
return MS_MEDIA_ERR_INTERNAL;
return MS_MEDIA_ERR_NONE;
}
#define DEVICE_INFO_FILE ".device_info_"
struct linux_dirent {
- ino64_t d_ino; /* 64-bit inode number */
- off64_t d_off; /* 64-bit offset to next structure */
- unsigned short d_reclen; /* Size of this dirent */
- unsigned char d_type; /* File type */
- char d_name[]; /* Filename (null-terminated) */
+ ino64_t d_ino; /* 64-bit inode number */
+ off64_t d_off; /* 64-bit offset to next structure */
+ unsigned short d_reclen; /* Size of this dirent */
+ unsigned char d_type; /* File type */
+ char d_name[]; /* Filename (null-terminated) */
};
#define BUF_SIZE 1024
int len = 0;
char path[MS_FILE_PATH_LEN_MAX] = {0,};
- len = snprintf(path, MS_FILE_PATH_LEN_MAX -1 , "%s/%s%s", root_path, DEVICE_INFO_FILE,device_uuid);
+ len = snprintf(path, MS_FILE_PATH_LEN_MAX -1, "%s/%s%s", root_path, DEVICE_INFO_FILE, device_uuid);
if (len < 0) {
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
static int g_usb_handler;
-typedef struct block_cb_data{
+typedef struct block_cb_data {
block_changed_cb usr_cb;
void *usr_data;
} block_cb_data;
MS_DBG_ERR("block_type : %d", block_info->block_type);
tmp = g_variant_get_child_value(parameters, 1);
- devnode = g_variant_get_string (tmp, &size);
+ devnode = g_variant_get_string(tmp, &size);
MS_DBG_ERR("devnode : %s", devnode);
tmp = g_variant_get_child_value(parameters, 8);
- mount_path = g_variant_get_string (tmp, &size);
+ mount_path = g_variant_get_string(tmp, &size);
if (mount_path != NULL) {
block_info->mount_path = strdup(mount_path);
MS_DBG_ERR("mount_point : %s", block_info->mount_path);
}
tmp = g_variant_get_child_value(parameters, 9);
- block_info->state = g_variant_get_int32 (tmp);
+ block_info->state = g_variant_get_int32(tmp);
MS_DBG_ERR("state : %d", block_info->state);
((block_changed_cb)usr_cb)(block_info, usr_data);
if (g_usb_bus == NULL) {
g_usb_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (!g_usb_bus) {
- MS_DBG_ERR ("Failed to connect to the g D-BUS daemon: %s", error->message);
- g_error_free (error);
+ MS_DBG_ERR("Failed to connect to the g D-BUS daemon: %s", error->message);
+ g_error_free(error);
ret = MS_MEDIA_ERR_INTERNAL;
goto ERROR;
}
return MS_MEDIA_ERR_NONE;
}
-#define DBUS_REPLY_TIMEOUT (-1)
-static int __ms_dbus_method_sync(const char *dest, const char *path,
- const char *interface, const char *method, const char *param, GArray **dev_list)
+#define DBUS_REPLY_TIMEOUT (-1)
+static int __ms_dbus_method_sync(const char *dest, const char *path, const char *interface, const char *method, const char *param, GArray **dev_list)
{
DBusConnection *conn;
DBusMessage *msg;
dbus_message_iter_next(&piter);
dbus_message_iter_get_basic(&piter, &val_int);
- MS_DBG("\treadonly(%d)", val_int);
+ MS_DBG("\treadonly(%d)", val_int);
dbus_message_iter_next(&piter);
dbus_message_iter_get_basic(&piter, &val_str);
int ms_sys_release_device_list(GArray **dev_list)
{
if (*dev_list) {
- while((*dev_list)->len != 0) {
+ while ((*dev_list)->len != 0) {
ms_block_info_s *data = NULL;
data = g_array_index(*dev_list , ms_block_info_s*, 0);
- g_array_remove_index (*dev_list, 0);
- MS_DBG("MOUNT PATH [%s] RELEASED",data->mount_path);
+ g_array_remove_index(*dev_list, 0);
+ MS_DBG("MOUNT PATH [%s] RELEASED", data->mount_path);
MS_SAFE_FREE(data->mount_path);
MS_SAFE_FREE(data);
}
- g_array_free (*dev_list, FALSE);
+ g_array_free(*dev_list, FALSE);
*dev_list = NULL;
}
{
int ret;
- ret = __ms_dbus_get_uid(UID_DBUS_NAME,UID_DBUS_PATH, UID_DBUS_INTERFACE, UID_DBUS_METHOD, uid);
+ ret = __ms_dbus_get_uid(UID_DBUS_NAME, UID_DBUS_PATH, UID_DBUS_INTERFACE, UID_DBUS_METHOD, uid);
if (ret < 0) {
MS_DBG("Failed to send dbus (%d)", ret);
} else {
#define POWER_DBUS_INTERFACE "org.tizen.system.deviced.PowerOff"
#define POWER_DBUS_MATCH_RULE "type='signal',interface='org.tizen.system.deviced.PowerOff'"
-typedef struct pwoff_cb_data{
+typedef struct pwoff_cb_data {
power_off_cb usr_cb;
void *usr_data;
} pwoff_cb_data;
pwoff_cb_data *g_pwr_cb_data = NULL;
-static DBusHandlerResult __poweroff_msg_filter (DBusConnection *connection, DBusMessage *message, void *user_data)
+static DBusHandlerResult __poweroff_msg_filter(DBusConnection *connection, DBusMessage *message, void *user_data)
{
pwoff_cb_data *cb_data = (pwoff_cb_data *)user_data;
void *usr_cb = cb_data->usr_cb;
MS_DBG_FENTER();
/* A Ping signal on the com.burtonini.dbus.Signal interface */
- if (dbus_message_is_signal (message, POWER_DBUS_INTERFACE, POWER_DBUS_NAME)) {
+ if (dbus_message_is_signal(message, POWER_DBUS_INTERFACE, POWER_DBUS_NAME)) {
int current_type = DBUS_TYPE_INVALID;
DBusError error;
DBusMessageIter read_iter;
power_off_cb cb_func = (power_off_cb)usr_cb;
ms_power_info_s *power_info = NULL;
- dbus_error_init (&error);
+ dbus_error_init(&error);
/* get data from dbus message */
- dbus_message_iter_init (message, &read_iter);
- while ((current_type = dbus_message_iter_get_arg_type (&read_iter)) != DBUS_TYPE_INVALID){
- dbus_message_iter_get_basic (&read_iter, &value);
- switch(current_type) {
+ dbus_message_iter_init(message, &read_iter);
+ while ((current_type = dbus_message_iter_get_arg_type(&read_iter)) != DBUS_TYPE_INVALID) {
+ dbus_message_iter_get_basic(&read_iter, &value);
+ switch (current_type) {
case DBUS_TYPE_INT32:
MS_DBG_WARN("value[%d]", value.i32);
break;
break;
}
- dbus_message_iter_next (&read_iter);
+ dbus_message_iter_next(&read_iter);
}
if (value.i32 == 2 || value.i32 == 3)
DBusError error;
/*add noti receiver for power off*/
- dbus_error_init (&error);
+ dbus_error_init(&error);
- g_pwr_dbus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+ g_pwr_dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
if (!g_pwr_dbus) {
- MS_DBG_ERR ("Failed to connect to the D-BUS daemon: %s", error.message);
+ MS_DBG_ERR("Failed to connect to the D-BUS daemon: %s", error.message);
return MS_MEDIA_ERR_INTERNAL;
}
- dbus_connection_setup_with_g_main (g_pwr_dbus, NULL);
+ dbus_connection_setup_with_g_main(g_pwr_dbus, NULL);
g_pwr_cb_data = malloc(sizeof(pwoff_cb_data));
if (g_pwr_cb_data == NULL) {
- MS_DBG_ERR ("malloc failed");
+ MS_DBG_ERR("malloc failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
g_pwr_cb_data->usr_data = user_data;
/* listening to messages from all objects as no path is specified */
- dbus_bus_add_match (g_pwr_dbus, POWER_DBUS_MATCH_RULE, &error);
- if( !dbus_connection_add_filter (g_pwr_dbus, __poweroff_msg_filter, g_pwr_cb_data, NULL)) {
- dbus_bus_remove_match (g_pwr_dbus, POWER_DBUS_MATCH_RULE, NULL);
+ dbus_bus_add_match(g_pwr_dbus, POWER_DBUS_MATCH_RULE, &error);
+ if (!dbus_connection_add_filter(g_pwr_dbus, __poweroff_msg_filter, g_pwr_cb_data, NULL)) {
+ dbus_bus_remove_match(g_pwr_dbus, POWER_DBUS_MATCH_RULE, NULL);
MS_DBG_ERR("dbus_connection_add_filter failed");
return MS_MEDIA_ERR_INTERNAL;
}
}
dbus_connection_remove_filter(g_pwr_dbus, __poweroff_msg_filter, g_pwr_cb_data);
- dbus_bus_remove_match (g_pwr_dbus, MS_MEDIA_DBUS_MATCH_RULE, NULL);
+ dbus_bus_remove_match(g_pwr_dbus, MS_MEDIA_DBUS_MATCH_RULE, NULL);
dbus_connection_unref(g_pwr_dbus);
g_pwr_dbus = NULL;
MS_SAFE_FREE(g_pwr_cb_data);
- return MS_MEDIA_ERR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int len = 0;
int real_size = size - 1;
- if (!res ||!pattern || !str1 ||!str2 )
+ if (!res || !pattern || !str1 || !str2)
return MS_MEDIA_ERR_INVALID_PARAMETER;
if (real_size < (int)(strlen(str1) + strlen(str2)))
printf("\n");
printf("db-update --help for check this messages.\n");
printf("\n");
- printf("A file or directory must exists under %s or %s.\n",tzplatform_getenv(TZ_USER_HOME),tzplatform_mkpath(TZ_SYS_STORAGE,"sdcard"));
- printf("Using %s is allowed SD card is mounted.\n",tzplatform_mkpath(TZ_SYS_STORAGE,"sdcard"));
+ printf("A file or directory must exists under %s or %s.\n", tzplatform_getenv(TZ_USER_HOME), tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard"));
+ printf("Using %s is allowed SD card is mounted.\n", tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard"));
printf("\n");
printf("=======================================================================================\n");
}
void *db_handle = NULL;
char *err_msg = NULL;
int ret = 0;
- bool fscan= false;
+ bool fscan = false;
- funcHandle = dlopen ("/usr/lib/libmedia-content-plugin.so", RTLD_LAZY);
- if(funcHandle == NULL)
- {
+ funcHandle = dlopen("/usr/lib/libmedia-content-plugin.so", RTLD_LAZY);
+ if (funcHandle == NULL) {
printf("Error when open plug-in\n");
return;
}
- svc_connect = dlsym (funcHandle, "connect_db");
- svc_disconnect = dlsym (funcHandle, "disconnect_db");
- svc_check_db = dlsym (funcHandle, "check_db");
+ svc_connect = dlsym(funcHandle, "connect_db");
+ svc_disconnect = dlsym(funcHandle, "disconnect_db");
+ svc_check_db = dlsym(funcHandle, "check_db");
- ret = svc_connect(&db_handle,tzplatform_getuid(TZ_USER_NAME), &err_msg);
- if(ret < 0)
+ ret = svc_connect(&db_handle, tzplatform_getuid(TZ_USER_NAME), &err_msg);
+ if (ret < 0)
printf("Error svc_connect\n");
ret = svc_check_db(db_handle, &fscan, tzplatform_getuid(TZ_USER_NAME), &err_msg);
- if(ret < 0)
+ if (ret < 0)
printf("Error svc_check_db\n");
ret = svc_disconnect(db_handle, &err_msg);
- if(ret < 0)
+ if (ret < 0)
printf("Error svc_disconnect\n");
printf("Check media db done\n");
- dlclose (funcHandle);
+ dlclose(funcHandle);
}
static void __get_storage_id(const char *path, char *storage_id, uid_t uid)
char *err_msg = NULL;
int ret = 0;
- funcHandle = dlopen ("/usr/lib/libmedia-content-plugin.so", RTLD_LAZY);
- if(funcHandle == NULL)
- {
+ funcHandle = dlopen("/usr/lib/libmedia-content-plugin.so", RTLD_LAZY);
+ if (funcHandle == NULL) {
printf("Error when open plug-in\n");
return;
}
- svc_connect = dlsym (funcHandle, "connect_db");
- svc_disconnect = dlsym (funcHandle, "disconnect_db");
- svc_get_storage_id = dlsym (funcHandle, "get_storage_id");
+ svc_connect = dlsym(funcHandle, "connect_db");
+ svc_disconnect = dlsym(funcHandle, "disconnect_db");
+ svc_get_storage_id = dlsym(funcHandle, "get_storage_id");
ret = svc_connect(&db_handle, uid, &err_msg);
- if(ret < 0)
+ if (ret < 0)
printf("Error svc_connect\n");
ret = svc_get_storage_id(db_handle, path, storage_id, uid, &err_msg);
- if(ret < 0)
+ if (ret < 0)
printf("Error svc_get_storage_id\n");
ret = svc_disconnect(db_handle, &err_msg);
- if(ret < 0)
+ if (ret < 0)
printf("Error svc_disconnect\n");
printf("Start Scanning for [%s][%s]\n", path, storage_id);
- dlclose (funcHandle);
+ dlclose(funcHandle);
}
int dir_scan_non_recursive(const char *path)
DIRECTORY_OK,
FILE_OK,
NOT_OK,
-}check_result;
+} check_result;
check_result check_path(char *path)
{
char *argv1 = NULL;
char *argv2 = NULL;
- if (argc > 3 ||argc < 2) {
+ if (argc > 3 || argc < 2) {
print_help();
exit(1);
}
int remain_request = 0;
bool status = FALSE;
- if(!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &update_status)) {
+ if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &update_status)) {
MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
}
/*call for bundle commit*/
//__msc_bacth_commit_disable(handle, TRUE, TRUE, extract_data->storage_id, ret);
-NEXT:
+NEXT :
msc_get_power_status(&power_off_status);
if (power_off_status) {
MS_DBG_ERR("power off");
/*Active flush */
malloc_trim(0);
- if(extract_data->result)
- {
+ if (extract_data->result) {
msc_send_result(ret, extract_data);
}
extract_data->uid = uid;
extract_data->result = ins_status;
extract_data->msg_size = strlen(path);
- strncpy(extract_data->msg, path, extract_data->msg_size );
+ strncpy(extract_data->msg, path, extract_data->msg_size);
strncpy(extract_data->storage_id, storage_id, MS_UUID_SIZE-1);
if (message_type == MS_MSG_STORAGE_ALL || message_type == MS_MSG_STORAGE_PARTIAL || message_type == MS_MSG_STORAGE_INVALID) {
g_async_queue_push(storage_extract_queue, GINT_TO_POINTER(extract_data));
MS_DBG("insert to storage exactor queue. msg_type [%d]", ins_status);
- } else if(message_type == MS_MSG_DIRECTORY_SCANNING || message_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
+ } else if (message_type == MS_MSG_DIRECTORY_SCANNING || message_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
g_async_queue_push(folder_extract_queue, GINT_TO_POINTER(extract_data));
MS_DBG("insert to dir exactor queue. msg_type [%d]", ins_status);
} else {
int msc_remove_extract_request(const ms_comm_msg_s *recv_msg)
{
- if(recv_msg == NULL) {
+ if (recv_msg == NULL) {
MS_DBG_ERR("recv_msg is null");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
temp_queue = g_async_queue_new();
int i = 0;
- for (; i <len; i++) {
+ for (; i < len; i++) {
/*create new queue to compare request*/
msg = g_async_queue_pop(storage_extract_queue);
if ((strcmp(msg->storage_id, storageid) == 0)) {
g_async_queue_push(temp_queue, GINT_TO_POINTER(msg));
}
}
- g_async_queue_unref (storage_extract_queue);
+ g_async_queue_unref(storage_extract_queue);
storage_extract_queue = temp_queue;
END_REMOVE_REQUEST:
static int __msc_resume_extract()
{
- g_mutex_lock (&extract_data_mutex);
+ g_mutex_lock(&extract_data_mutex);
- g_cond_signal (&extract_data_cond);
+ g_cond_signal(&extract_data_cond);
- g_mutex_unlock (&extract_data_mutex);
+ g_mutex_unlock(&extract_data_mutex);
return MS_MEDIA_ERR_NONE;
}
static int __msc_pause_extract()
{
- g_mutex_lock (&extract_data_mutex);
+ g_mutex_lock(&extract_data_mutex);
while (g_directory_extract_processing)
- g_cond_wait (&extract_data_cond, &extract_data_mutex);
+ g_cond_wait(&extract_data_cond, &extract_data_mutex);
- g_mutex_unlock (&extract_data_mutex);
+ g_mutex_unlock(&extract_data_mutex);
return MS_MEDIA_ERR_NONE;
}
}
}
} else if (status == MS_DB_UPDATED) {
- if(!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
res = MS_MEDIA_ERR_VCONF_SET_FAIL;
MS_DBG_ERR("ms_config_set_int failed");
}
}
}
} else {
- if(!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
res = MS_MEDIA_ERR_VCONF_SET_FAIL;
MS_DBG_ERR("ms_config_set_int failed");
}
{
int ret = MS_MEDIA_ERR_NONE;
- switch(scan_type) {
+ switch (scan_type) {
case MS_EXTRACT_STORAGE:
g_async_queue_push(storage_extract_queue, GINT_TO_POINTER(recv_msg));
break;
{
int ret = MS_MEDIA_ERR_NONE;
- switch(scan_type) {
+ switch (scan_type) {
case MS_EXTRACT_STORAGE:
*remain_request = g_async_queue_length(storage_extract_queue);
break;
if (uid == getuid()) {
result_psswd = strndup(MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL));
grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
+ if (grpinfo == NULL) {
MS_DBG_ERR("getgrnam(users) returns NULL !");
return NULL;
}
}
}
} else if (status == MS_DB_UPDATED) {
- if(!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
res = MS_MEDIA_ERR_VCONF_SET_FAIL;
MS_DBG_ERR("ms_config_set_int failed");
}
}
}
} else {
- if(!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
res = MS_MEDIA_ERR_VCONF_SET_FAIL;
MS_DBG_ERR("ms_config_set_int failed");
}
char *check_ignore_file = NULL;
int ret = MS_MEDIA_ERR_NONE;
- if(strstr(path, "/."))
- {
+ if (strstr(path, "/.")) {
MS_DBG_ERR("hidden path");
ret = MS_MEDIA_ERR_INVALID_PATH;
goto ERROR;
if (strstr(path, MEDIA_ROOT_PATH_USB) != NULL) {
if (errno == ENOENT) {
/*if the directory does not exist, check the device is unmounted*/
- if(!__msc_storage_mount_status(path)) {
+ if (!__msc_storage_mount_status(path)) {
MS_DBG_ERR("Device is unmounted[%s]", path);
ret = MS_MEDIA_ERR_USB_UNMOUNTED;
goto ERROR;
}
struct stat folder_st;
- if(stat(path, &folder_st) == 0) {
+ if (stat(path, &folder_st) == 0) {
MS_DBG_ERR("DEV[%ld] INODE[%lld] UID[%ld] GID[%ld] MODE[%lo] PATH[%s]", (long)folder_st.st_dev, (long long)folder_st.st_ino,
(long)folder_st.st_uid, (long)folder_st.st_gid, (unsigned long) folder_st.st_mode, path);
} else {
path_len = strlen(path) + strlen(ignore_path) + 1;
check_ignore_file = malloc(path_len);
- if(check_ignore_file != NULL) {
+ if (check_ignore_file != NULL) {
memset(check_ignore_file, 0x0, path_len);
snprintf(check_ignore_file, path_len, "%s%s", path, ignore_path);
exist = open(check_ignore_file, O_RDONLY);
- if(exist >= 0) {
+ if (exist >= 0) {
MS_DBG_ERR("scan_ignore exists [%s]", check_ignore_file);
ret = MS_MEDIA_ERR_INVALID_PATH;
}
ERROR:
- if(fd != -1) {
+ if (fd != -1) {
close(fd);
fd = -1;
}
static int __msc_resume_scan()
{
- g_mutex_lock (&data_mutex2);
+ g_mutex_lock(&data_mutex2);
- g_cond_signal (&data_cond2);
+ g_cond_signal(&data_cond2);
- g_mutex_unlock (&data_mutex2);
+ g_mutex_unlock(&data_mutex2);
return MS_MEDIA_ERR_NONE;
}
static int __msc_pause_scan()
{
- g_mutex_lock (&data_mutex2);
+ g_mutex_lock(&data_mutex2);
while (g_directory_scan_processing2)
- g_cond_wait (&data_cond2, &data_mutex2);
+ g_cond_wait(&data_cond2, &data_mutex2);
- g_mutex_unlock (&data_mutex2);
+ g_mutex_unlock(&data_mutex2);
return MS_MEDIA_ERR_NONE;
}
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
}
- if (scan_type == MS_MSG_DIRECTORY_SCANNING ||scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
+ if (scan_type == MS_MSG_DIRECTORY_SCANNING || scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
g_mutex_lock(&scan_req_mutex2);
/* check cancel path */
if (g_cancel_path2 != NULL) {
g_mutex_lock(&blocked_mutex2);
/* check cancel path */
- if (g_blocked_path2!= NULL) {
+ if (g_blocked_path2 != NULL) {
MS_DBG_ERR("check blocked storage [%s][%s]", g_blocked_path2, start_path);
if (strncmp(start_path, g_blocked_path2, strlen(start_path)) == 0) {
MS_DBG_ERR("Receive blocked message[%s][%s]. STOP scan!!",
}
struct linux_dirent {
- ino64_t d_ino; /* 64-bit inode number */
- off64_t d_off; /* 64-bit offset to next structure */
- unsigned short d_reclen; /* Size of this dirent */
- unsigned char d_type; /* File type */
- char d_name[]; /* Filename (null-terminated) */
+ ino64_t d_ino; /* 64-bit inode number */
+ off64_t d_off; /* 64-bit offset to next structure */
+ unsigned short d_reclen; /* Size of this dirent */
+ unsigned char d_type; /* File type */
+ char d_name[]; /* Filename (null-terminated) */
};
#define BUF_SIZE 1024
MS_DBG_ERR("storage id [%s] start path [%s]", storage_id, start_path);
/* make new array for storing directory */
- dir_array = g_array_new (FALSE, FALSE, sizeof (char*));
+ dir_array = g_array_new(FALSE, FALSE, sizeof(char*));
if (dir_array == NULL) {
MS_DBG_ERR("g_array_new failed");
}
/* add first direcotiry to directory array */
new_start_path = strdup(start_path);
- if (new_start_path == NULL){
+ if (new_start_path == NULL) {
MS_DBG_ERR("strdup failed");
g_array_free(dir_array, FALSE);
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
MS_DBG_ERR("new start path [%s]", new_start_path);
- g_array_append_val (dir_array, start_path);
- if(ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE) {
+ g_array_append_val(dir_array, start_path);
+ if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("insert folder failed");
}
/* folder validity set 0 under the start_path in folder table*/
if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE || scan_type == MS_MSG_DIRECTORY_SCANNING) {
- if(ms_set_folder_validity(handle, storage_id, new_start_path, MS_INVALID, is_recursive, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_set_folder_validity(handle, storage_id, new_start_path, MS_INVALID, is_recursive, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("set_folder_validity failed [%d] ", scan_type);
}
}
}
/* get the current path from directory array */
current_path = g_array_index(dir_array , char*, 0);
- g_array_remove_index (dir_array, 0);
+ g_array_remove_index(dir_array, 0);
ret = __msc_check_scan_ignore(current_path);
if (ret != MS_MEDIA_ERR_NONE) {
}
if (ms_strappend(path, sizeof(path), "%s/%s", current_path, d->d_name) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_strappend failed");
+ MS_DBG_ERR("ms_strappend failed");
bpos += d->d_reclen;
continue;
}
if (d->d_type == DT_REG) {
MS_DBG_ERR("INSERT DT_REG");
/* insert into media DB */
- if (scan_function(handle,storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
+ if (scan_function(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("failed to update db : %d\n", scan_type);
bpos += d->d_reclen;
continue;
- }
- else {
+ } else {
++scan_count;
//MSC_DBG_ERR("insert count %d", nScanCount);
- if(scan_count/MAX_SCAN_COUNT>0) {
+ if (scan_count/MAX_SCAN_COUNT > 0) {
scan_count = 0;
MS_DBG_ERR("storage_id = [%s]", storage_id);
msc_insert_exactor_request(scan_type, FALSE, storage_id, current_path, 0, uid);
/* this request is recursive scanning */
/* add new directory to dir_array */
new_path = strdup(path);
- g_array_append_val (dir_array, new_path);
+ g_array_append_val(dir_array, new_path);
- if(ms_insert_folder(handle, storage_id, new_path, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_insert_folder(handle, storage_id, new_path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("insert folder failed");
}
} else {
/* this request is non-recursive scanning */
/* don't add new directory to dir_array */
- if(ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("insert folder failed");
bpos += d->d_reclen;
continue;
// msc_insert_exactor_request(scan_type, FALSE, storage_id, current_path, 0);
// scan_count = 0;
- if(fd != -1) {
+ if (fd != -1) {
close(fd);
fd = -1;
}
/*remove invalid folder in folder table.*/
if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL) {
if (__msc_storage_mount_status(new_start_path)) {
- if(ms_delete_invalid_folder(handle, storage_id, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_delete_invalid_folder(handle, storage_id, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("delete invalid folder failed");
ret = MS_MEDIA_ERR_DB_DELETE_FAIL;
}
}
}
STOP_SCAN:
- if(fd != -1) {
+ if (fd != -1) {
close(fd);
fd = -1;
}
if (err != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("error : %d", err);
}
- } else if ( scan_type == MS_MSG_STORAGE_INVALID) {
+ } else if (scan_type == MS_MSG_STORAGE_INVALID) {
MS_DBG_ERR("INVALID");
/*In this case, update just validation record*/
/*update just valid type*/
}
/* folder validity set 0 under the start_path in folder table*/
- if(ms_set_folder_validity(handle, storage_id, scan_data->msg, MS_INVALID, TRUE, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_set_folder_validity(handle, storage_id, scan_data->msg, MS_INVALID, TRUE, scan_data->uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("set_folder_validity failed");
}
msc_remove_extract_request(scan_data);
ms_delete_invalid_items_in_folder(handle, storage_id, scan_data->msg, is_recursive, scan_data->uid);
- if ( !(count == 0 && insert_count == 0)) {
+ if (!(count == 0 && insert_count == 0)) {
ms_send_dir_update_noti(handle, storage_id, noti_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
}
MS_SAFE_FREE(noti_path);
time_t mtime;
bool find_flag = false;
- if(stat(folder_path, &buf) == 0) {
+ if (stat(folder_path, &buf) == 0) {
mtime = buf.st_mtime;
} else {
return MS_MEDIA_ERR_INTERNAL;
}
for (i = 0; i < array_len; i++) {
- dir_info = g_array_index (dir_array, ms_dir_info_s*, i);
+ dir_info = g_array_index(dir_array, ms_dir_info_s*, i);
if (strcmp(folder_path, dir_info->dir_path) == 0) {
/* if modified time is same, the folder does not need updating */
if (mtime == dir_info->modified_time) {
- g_array_remove_index (dir_array, i);
+ g_array_remove_index(dir_array, i);
MS_SAFE_FREE(dir_info->dir_path);
MS_SAFE_FREE(dir_info);
}
}
/* make new array for storing directory */
- read_dir_array = g_array_new (FALSE, FALSE, sizeof (char*));
- if (read_dir_array == NULL){
+ read_dir_array = g_array_new(FALSE, FALSE, sizeof(char*));
+ if (read_dir_array == NULL) {
MS_DBG_ERR("g_array_new failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
/* add first direcotiry to directory array */
- g_array_append_val (read_dir_array, start_path);
+ g_array_append_val(read_dir_array, start_path);
/*start db update. the number of element in the array , db update is complete.*/
while (read_dir_array->len != 0) {
/* get the current path from directory array */
current_path = g_array_index(read_dir_array , char*, 0);
- g_array_remove_index (read_dir_array, 0);
+ g_array_remove_index(read_dir_array, 0);
// MSC_DBG_ERR("%s", current_path);
if (__msc_check_scan_ignore(current_path) != MS_MEDIA_ERR_NONE) {
if (entry.d_type & DT_DIR) {
if (ms_strappend(path, sizeof(path), "%s/%s", current_path, entry.d_name) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_strappend failed");
+ MS_DBG_ERR("ms_strappend failed");
continue;
}
/* add new directory to dir_array */
new_path = strdup(path);
- g_array_append_val (read_dir_array, new_path);
+ g_array_append_val(read_dir_array, new_path);
}
}
} else {
ms_dir_info_s* dir_info = NULL;
char *update_path = NULL;
- for (i = 0; i < dir_array->len; i ++) {
- dir_info = g_array_index (dir_array, ms_dir_info_s*, i);
+ for (i = 0; i < dir_array->len; i++) {
+ dir_info = g_array_index(dir_array, ms_dir_info_s*, i);
update_path = strdup(dir_info->dir_path);
if (update_path == NULL) {
MS_DBG_ERR("malloc failed");
}
/*delete all node*/
- while(dir_array->len != 0) {
+ while (dir_array->len != 0) {
ms_dir_info_s *data = NULL;
data = g_array_index(dir_array , ms_dir_info_s*, 0);
- g_array_remove_index (dir_array, 0);
+ g_array_remove_index(dir_array, 0);
MS_SAFE_FREE(data->dir_path);
MS_SAFE_FREE(data);
}
return false;
usr_path = __msc_get_path(uid);
- if(usr_path == NULL)
+ if (usr_path == NULL)
return false;
if (strncmp(path, usr_path, strlen(usr_path)) == 0) {
/* check location of file */
/* file must exists under "/opt/usr/media" or "/opt/storage/sdcard" */
- if(!__msc_is_valid_path(file_path, uid)) {
+ if (!__msc_is_valid_path(file_path, uid)) {
MS_DBG_ERR("Invalid path : %s", file_path);
return MS_MEDIA_ERR_INVALID_PATH;
}
/* check the file exits actually */
exist = open(file_path, O_RDONLY);
- if(exist < 0) {
+ if (exist < 0) {
MS_DBG_ERR("[%s]open files");
return MS_MEDIA_ERR_INVALID_PATH;
}
/* check type of the path */
/* It must be a regular file */
memset(&file_st, 0, sizeof(struct stat));
- if(stat(file_path, &file_st) == 0) {
- if(!S_ISREG(file_st.st_mode)) {
+ if (stat(file_path, &file_st) == 0) {
+ if (!S_ISREG(file_st.st_mode)) {
/* In this case, it is not a regula file */
MS_DBG_ERR("this path is not a file");
return MS_MEDIA_ERR_INVALID_PATH;
static int __msc_clear_file_list(GArray *path_array)
{
if (path_array) {
- while(path_array->len != 0) {
+ while (path_array->len != 0) {
char *data = NULL;
data = g_array_index(path_array , char*, 0);
- g_array_remove_index (path_array, 0);
+ g_array_remove_index(path_array, 0);
MS_SAFE_FREE(data);
}
g_array_free(path_array, FALSE);
return MS_MEDIA_ERR_INVALID_PATH;
}
- while(1) {
- if(__msc_check_scan_ignore(dir_path) != MS_MEDIA_ERR_NONE) {
+ while (1) {
+ if (__msc_check_scan_ignore(dir_path) != MS_MEDIA_ERR_NONE) {
ret = MS_MEDIA_ERR_INVALID_PATH;
break;
}
/*If root path, Stop Scanning*/
- if(strcmp(dir_path, __msc_get_path(uid)) == 0)
+ if (strcmp(dir_path, __msc_get_path(uid)) == 0)
break;
- else if(strcmp(dir_path, MEDIA_ROOT_PATH_SDCARD) == 0)
+ else if (strcmp(dir_path, MEDIA_ROOT_PATH_SDCARD) == 0)
break;
- else if(strcmp(dir_path, MEDIA_ROOT_PATH_USB) == 0)
+ else if (strcmp(dir_path, MEDIA_ROOT_PATH_USB) == 0)
break;
leaf_path = strrchr(dir_path, '/');
- if(leaf_path != NULL) {
+ if (leaf_path != NULL) {
int seek_len = leaf_path -dir_path;
dir_path[seek_len] = '\0';
} else {
memset(buf, 0x0, MS_FILE_PATH_LEN_MAX);
/* This is an array for storing the path of insert datas*/
- *path_array = g_array_new (FALSE, FALSE, sizeof (char *));
+ *path_array = g_array_new(FALSE, FALSE, sizeof(char *));
if (*path_array == NULL) {
MS_DBG_ERR("g_array_new failed");
res = MS_MEDIA_ERR_OUT_OF_MEMORY;
}
/* read registering file path from stored file */
- while(fgets(buf, MS_FILE_PATH_LEN_MAX, fp) != NULL) {
+ while (fgets(buf, MS_FILE_PATH_LEN_MAX, fp) != NULL) {
length = strlen(buf); /*the return value of function, strlen(), includes "\n" */
path = strndup(buf, length - 1); /*copying except "\n" and strndup fuction adds "\0" at the end of the copying string */
}
}
- if(fp) fclose(fp);
+ if (fp) fclose(fp);
fp = NULL;
return MS_MEDIA_ERR_NONE;
__msc_clear_file_list(*path_array);
- if(fp) fclose(fp);
+ if (fp) fclose(fp);
fp = NULL;
return res;
/*updating requests remain*/
if (register_array->len != 0 && remain_request == 0) {
*register_data = g_array_index(register_array, ms_comm_msg_s*, 0);
- g_array_remove_index (register_array, 0);
+ g_array_remove_index(register_array, 0);
break;
} else if (remain_request != 0) {
insert_data = g_async_queue_pop(reg_queue2);
}
}
- if(((*register_data)->msg_size <= 0) ||((*register_data)->msg_size > MS_FILE_PATH_LEN_MAX)) {
+ if (((*register_data)->msg_size <= 0) || ((*register_data)->msg_size > MS_FILE_PATH_LEN_MAX)) {
MS_DBG_ERR("message size[%d] is wrong", (*register_data)->msg_size);
return MS_MEDIA_ERR_INVALID_IPC_MESSAGE;
}
ms_msg_type_e current_msg = MS_MSG_MAX;
/*create array for processing overlay data*/
- register_array = g_array_new (FALSE, FALSE, sizeof (ms_comm_msg_s *));
+ register_array = g_array_new(FALSE, FALSE, sizeof(ms_comm_msg_s *));
if (register_array == NULL) {
MS_DBG_ERR("g_array_new error");
return false;
MS_SAFE_FREE(file_path);
MS_SAFE_FREE(register_data);
if (register_array) {
- while(register_array->len != 0) {
+ while (register_array->len != 0) {
ms_comm_msg_s *data = NULL;
data = g_array_index(register_array , ms_comm_msg_s*, 0);
- g_array_remove_index (register_array, 0);
+ g_array_remove_index(register_array, 0);
MS_SAFE_FREE(data);
}
- g_array_free (register_array, FALSE);
+ g_array_free(register_array, FALSE);
register_array = NULL;
}
int dev_num = dev_list->len;
ms_block_info_s *block_info = NULL;
- for (i = 0; i < dev_num; i ++) {
+ for (i = 0; i < dev_num; i++) {
block_info = (ms_block_info_s *)g_array_index(dev_list , ms_stg_type_e*, i);
if (strcmp(block_info->mount_path, storage_path) == 0) {
ret = TRUE;
{
int ret = MS_MEDIA_ERR_NONE;
- switch(scan_type) {
+ switch (scan_type) {
case MS_SCAN_STORAGE:
g_async_queue_push(storage_queue2, GINT_TO_POINTER(recv_msg));
break;
{
int ret = MS_MEDIA_ERR_NONE;
- switch(scan_type) {
+ switch (scan_type) {
case MS_SCAN_STORAGE:
*remain_request = g_async_queue_length(storage_queue2);
break;
temp_scan_queue = g_async_queue_new();
- for (i = 0; i <len; i++) {
+ for (i = 0; i < len; i++) {
/*create new queue to compare request*/
msg = g_async_queue_pop(scan_queue2);
if ((strcmp(msg->msg, cancel_path) == 0) && (pid == msg->pid)) {
g_async_queue_push(temp_scan_queue, GINT_TO_POINTER(msg));
}
}
- g_async_queue_unref (scan_queue2);
+ g_async_queue_unref(scan_queue2);
scan_queue2 = temp_scan_queue;
END_REMOVE_REQUEST:
GAsyncQueue *temp_extract_queue = NULL;
int len_extract = g_async_queue_length(folder_extract_queue);
- if(len_extract != 0)
- {
+ if (len_extract != 0) {
temp_extract_queue = g_async_queue_new();
- for (i = 0; i <len_extract; i++) {
+ for (i = 0; i < len_extract; i++) {
/*create new queue to compare request*/
msg = g_async_queue_pop(folder_extract_queue);
if ((strcmp(msg->msg, cancel_path) == 0) && (pid == msg->pid)) {
g_async_queue_push(temp_extract_queue, GINT_TO_POINTER(msg));
}
}
- g_async_queue_unref (folder_extract_queue);
+ g_async_queue_unref(folder_extract_queue);
folder_extract_queue = temp_extract_queue;
}
/* copy from recived data */
req_num = recv_msg->msg_type;
- switch(req_num){
+ switch (req_num) {
case MS_MSG_BULK_INSERT:
case MS_MSG_BURSTSHOT_INSERT:
{
/* Create pipe */
err = unlink(MS_SCANNER_FIFO_PATH_REQ);
- if (err !=0) {
+ if (err != 0) {
MS_DBG_STRERROR("[No-Error] unlink failed");
}
err = mkfifo(MS_SCANNER_FIFO_PATH_REQ, MS_SCANNER_FIFO_MODE);
- if (err !=0) {
+ if (err != 0) {
MS_DBG_STRERROR("mkfifo failed");
return MS_MEDIA_ERR_INTERNAL;
}
g_main_loop_run(scanner_mainloop2);
- g_thread_join (scan_thread);
- g_thread_join (register_thread);
- g_thread_join (storage_scan_thread);
- g_thread_join (storage_extract_thread);
- g_thread_join (folder_extract_thread);
+ g_thread_join(scan_thread);
+ g_thread_join(register_thread);
+ g_thread_join(storage_scan_thread);
+ g_thread_join(storage_extract_thread);
+ g_thread_join(folder_extract_thread);
g_io_channel_shutdown(channel, FALSE, NULL);
g_io_channel_unref(channel);
if (uid == getuid()) {
result_psswd = strndup(MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL));
grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
+ if (grpinfo == NULL) {
MS_DBG_ERR("getgrnam(users) returns NULL !");
return NULL;
}
}
}
} else if (status == MS_DB_UPDATED) {
- if(!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED)) {
res = MS_MEDIA_ERR_VCONF_SET_FAIL;
MS_DBG_ERR("ms_config_set_int failed");
}
struct dirent *result;
const char *ignore_path = ".scan_ignore";
- if(strstr(path, "/."))
- {
+ if (strstr(path, "/.")) {
MS_DBG_ERR("hidden path");
return true;
}
static int __msc_resume_scan()
{
- g_mutex_lock (&data_mutex);
+ g_mutex_lock(&data_mutex);
// current_data = GINT_TO_POINTER(g_directory_scan_processing);
- g_cond_signal (&data_cond);
+ g_cond_signal(&data_cond);
- g_mutex_unlock (&data_mutex);
+ g_mutex_unlock(&data_mutex);
return MS_MEDIA_ERR_NONE;
}
static int __msc_pause_scan()
{
- g_mutex_lock (&data_mutex);
+ g_mutex_lock(&data_mutex);
// while (current_data)
while (g_directory_scan_processing)
- g_cond_wait (&data_cond, &data_mutex);
+ g_cond_wait(&data_cond, &data_mutex);
// current_data = GPOINTER_TO_INT(g_directory_scan_processing);
- g_mutex_unlock (&data_mutex);
+ g_mutex_unlock(&data_mutex);
return MS_MEDIA_ERR_NONE;
}
/*check SD card in out */
#if 0
if ((mmc_state != MS_STG_INSERTED) && (storage_type == MS_STORAGE_EXTERNAL)) {
- MS_DBG_ERR("Directory scanning is stopped");
+ MS_DBG_ERR(fmt,args...)("Directory scanning is stopped");
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
}
#endif
}
/* make new array for storing directory */
- dir_array = g_array_new (FALSE, FALSE, sizeof (char*));
- if (dir_array == NULL){
+ dir_array = g_array_new(FALSE, FALSE, sizeof(char*));
+ if (dir_array == NULL) {
MS_DBG_ERR("g_array_new failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- g_array_append_val (dir_array, start_path);
+ g_array_append_val(dir_array, start_path);
scan_function = (scan_type == MS_MSG_STORAGE_ALL) ? ms_insert_item_batch : ms_validate_item;
}
/* get the current path from directory array */
current_path = g_array_index(dir_array , char*, 0);
- g_array_remove_index (dir_array, 0);
+ g_array_remove_index(dir_array, 0);
MS_DBG_SLOG("%d", dir_array->len);
if (__msc_check_scan_ignore(current_path)) {
dp = opendir(current_path);
if (dp != NULL) {
/*insert current directory*/
- if(ms_insert_folder(handle, storage_id, current_path, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_insert_folder(handle, storage_id, current_path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("insert folder failed");
}
if (entry.d_type & DT_REG) {
/* insert into media DB */
- if (scan_function(handle,storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
+ if (scan_function(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("failed to update db : %d", scan_type);
continue;
}
/* add new directory to dir_array */
new_path = strdup(path);
if (new_path != NULL) {
- g_array_append_val (dir_array, new_path);
+ g_array_append_val(dir_array, new_path);
} else {
MS_DBG_ERR("strdup failed");
continue;
} else {
/* this request is recursive scanning */
/* don't add new directory to dir_array */
- if(ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("insert folder failed");
}
}
int (*scan_function)(void **, const char*, const char*, uid_t) = NULL;
/* make new array for storing directory */
- dir_array = g_array_new (FALSE, FALSE, sizeof (char*));
- if (dir_array == NULL){
+ dir_array = g_array_new(FALSE, FALSE, sizeof(char*));
+ if (dir_array == NULL) {
MS_DBG_ERR("g_array_new failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- g_array_append_val (dir_array, start_path);
+ g_array_append_val(dir_array, start_path);
MS_DBG_ERR("[No-Error] start path [%s]", new_start_path);
/* folder validity set 0 under the start_path in folder table*/
if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE || scan_type == MS_MSG_DIRECTORY_SCANNING) {
- if(ms_set_folder_validity(handle, storage_id, new_start_path, MS_INVALID, is_recursive, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_set_folder_validity(handle, storage_id, new_start_path, MS_INVALID, is_recursive, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("set_folder_validity failed [%d] ", scan_type);
}
}
- if(__msc_check_folder_path(new_start_path)) {
+ if (__msc_check_folder_path(new_start_path)) {
ms_insert_folder(handle, storage_id, new_start_path, uid);
}
}
/* get the current path from directory array */
current_path = g_array_index(dir_array , char*, 0);
- g_array_remove_index (dir_array, 0);
+ g_array_remove_index(dir_array, 0);
// MS_DBG_SLOG("%d", dir_array->len);
if (__msc_check_scan_ignore(current_path)) {
continue;
if (ms_strappend(path, sizeof(path), "%s/%s", current_path, entry.d_name) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_strappend failed");
+ MS_DBG_ERR("ms_strappend failed");
continue;
}
if (entry.d_type & DT_REG) {
/* insert into media DB */
- if (scan_function(handle,storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
+ if (scan_function(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("failed to update db : %d", scan_type);
continue;
}
/* add new directory to dir_array */
new_path = strdup(path);
if (new_path != NULL) {
- g_array_append_val (dir_array, new_path);
+ g_array_append_val(dir_array, new_path);
- if(ms_insert_folder(handle, storage_id, new_path, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_insert_folder(handle, storage_id, new_path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("insert folder failed");
}
} else {
} else {
/* this request is recursive scanning */
/* don't add new directory to dir_array */
- if(ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("insert folder failed");
continue;
}
/*remove invalid folder in folder table.*/
if (__msc_check_mount_storage(new_start_path)) {
- if(ms_delete_invalid_folder(handle, storage_id, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_delete_invalid_folder(handle, storage_id, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("delete invalid folder failed");
ret = MS_MEDIA_ERR_DB_DELETE_FAIL;
}
MS_DBG_ERR("BEFORE COUNT[%d]", before_count);
/* folder validity set 0 under the start_path in folder table*/
- if(ms_set_folder_validity(handle, storage_id, scan_data->msg, MS_INVALID, is_recursive, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_set_folder_validity(handle, storage_id, scan_data->msg, MS_INVALID, is_recursive, scan_data->uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("set_folder_validity failed [%d] ", scan_type);
}
}
/*remove invalid folder in folder table.*/
- if(ms_delete_invalid_folder_by_path(handle, storage_id, scan_data->msg, scan_data->uid, &delete_folder_count) != MS_MEDIA_ERR_NONE) {
+ if (ms_delete_invalid_folder_by_path(handle, storage_id, scan_data->msg, scan_data->uid, &delete_folder_count) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("deleting invalid folder failed");
}
time_t mtime;
bool find_flag = false;
- if(stat(folder_path, &buf) == 0) {
+ if (stat(folder_path, &buf) == 0) {
mtime = buf.st_mtime;
} else {
return MS_MEDIA_ERR_INTERNAL;
}
for (i = 0; i < array_len; i++) {
- dir_info = g_array_index (dir_array, ms_dir_info_s*, i);
+ dir_info = g_array_index(dir_array, ms_dir_info_s*, i);
if (strcmp(folder_path, dir_info->dir_path) == 0) {
/* if modified time is same, the folder does not need updating */
if ((mtime == dir_info->modified_time) && (item_num == dir_info->item_num)) {
if (mtime == 0)
continue;
- g_array_remove_index (dir_array, i);
+ g_array_remove_index(dir_array, i);
MS_SAFE_FREE(dir_info->dir_path);
MS_SAFE_FREE(dir_info);
}
}
/* make new array for storing directory */
- read_dir_array = g_array_new (FALSE, FALSE, sizeof (char*));
- if (read_dir_array == NULL){
+ read_dir_array = g_array_new(FALSE, FALSE, sizeof(char*));
+ if (read_dir_array == NULL) {
MS_DBG_ERR("g_array_new failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
/* add first direcotiry to directory array */
- g_array_append_val (read_dir_array, start_path);
+ g_array_append_val(read_dir_array, start_path);
/*start db update. the number of element in the array , db update is complete.*/
while (read_dir_array->len != 0) {
/* get the current path from directory array */
current_path = g_array_index(read_dir_array , char*, 0);
- g_array_remove_index (read_dir_array, 0);
+ g_array_remove_index(read_dir_array, 0);
// MS_DBG_ERR("%s", current_path);
if (__msc_check_scan_ignore(current_path)) {
if (entry.d_type & DT_DIR) {
if (ms_strappend(path, sizeof(path), "%s/%s", current_path, entry.d_name) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_strappend failed");
+ MS_DBG_ERR("ms_strappend failed");
continue;
}
/* add new directory to dir_array */
new_path = strdup(path);
- g_array_append_val (read_dir_array, new_path);
+ g_array_append_val(read_dir_array, new_path);
} else if (entry.d_type & DT_REG) {
item_num++;
}
ms_dir_info_s* dir_info = NULL;
char *update_path = NULL;
- for (i = 0; i < dir_array->len; i ++) {
- dir_info = g_array_index (dir_array, ms_dir_info_s*, i);
+ for (i = 0; i < dir_array->len; i++) {
+ dir_info = g_array_index(dir_array, ms_dir_info_s*, i);
update_path = strdup(dir_info->dir_path);
// MS_DBG_SLOG("update_path : %s, %d", update_path, dir_info->modified_time);
}
/*delete all node*/
- while(dir_array->len != 0) {
+ while (dir_array->len != 0) {
ms_dir_info_s *data = NULL;
data = g_array_index(dir_array , ms_dir_info_s*, 0);
- g_array_remove_index (dir_array, 0);
+ g_array_remove_index(dir_array, 0);
MS_SAFE_FREE(data->dir_path);
MS_SAFE_FREE(data);
}
return false;
usr_path = __msc_get_path(uid);
- if(usr_path == NULL)
+ if (usr_path == NULL)
return false;
if (strncmp(path, usr_path, strlen(usr_path)) == 0) {
/* check location of file */
/* file must exists under "/opt/usr/media" or "/opt/storage/sdcard" */
- if(!__msc_is_valid_path(file_path, uid)) {
+ if (!__msc_is_valid_path(file_path, uid)) {
MS_DBG_ERR("Invalid path : %s", file_path);
return MS_MEDIA_ERR_INVALID_PATH;
}
/* check the file exits actually */
exist = open(file_path, O_RDONLY);
- if(exist < 0) {
+ if (exist < 0) {
MS_DBG_STRERROR("Open failed");
MS_DBG_ERR("error path [%s]", file_path);
return MS_MEDIA_ERR_INVALID_PATH;
/* check type of the path */
/* It must be a regular file */
memset(&file_st, 0, sizeof(struct stat));
- if(stat(file_path, &file_st) == 0) {
- if(!S_ISREG(file_st.st_mode)) {
+ if (stat(file_path, &file_st) == 0) {
+ if (!S_ISREG(file_st.st_mode)) {
/* In this case, it is not a regula file */
MS_DBG_ERR("this path is not a file");
return MS_MEDIA_ERR_INVALID_PATH;
static int __msc_clear_file_list(GArray *path_array)
{
if (path_array) {
- while(path_array->len != 0) {
+ while (path_array->len != 0) {
char *data = NULL;
data = g_array_index(path_array , char*, 0);
- g_array_remove_index (path_array, 0);
+ g_array_remove_index(path_array, 0);
MS_SAFE_FREE(data);
}
g_array_free(path_array, FALSE);
return MS_MEDIA_ERR_INVALID_PATH;
}
- while(1) {
- if(__msc_check_scan_ignore(dir_path)) {
+ while (1) {
+ if (__msc_check_scan_ignore(dir_path)) {
ret = MS_MEDIA_ERR_INVALID_PATH;
break;
}
/*If root path, Stop Scanning*/
- if(strcmp(dir_path, __msc_get_path(uid)) == 0)
+ if (strcmp(dir_path, __msc_get_path(uid)) == 0)
break;
- else if(strcmp(dir_path, MEDIA_ROOT_PATH_SDCARD) == 0)
+ else if (strcmp(dir_path, MEDIA_ROOT_PATH_SDCARD) == 0)
break;
- else if(strcmp(dir_path, MEDIA_ROOT_PATH_USB) == 0)
+ else if (strcmp(dir_path, MEDIA_ROOT_PATH_USB) == 0)
break;
leaf_path = strrchr(dir_path, '/');
- if(leaf_path != NULL) {
+ if (leaf_path != NULL) {
int seek_len = leaf_path -dir_path;
dir_path[seek_len] = '\0';
} else {
memset(buf, 0x0, MS_FILE_PATH_LEN_MAX);
/* This is an array for storing the path of insert datas*/
- *path_array = g_array_new (FALSE, FALSE, sizeof (char *));
+ *path_array = g_array_new(FALSE, FALSE, sizeof(char *));
if (*path_array == NULL) {
MS_DBG_ERR("g_array_new failed");
res = MS_MEDIA_ERR_OUT_OF_MEMORY;
}
/* read registering file path from stored file */
- while(fgets(buf, MS_FILE_PATH_LEN_MAX, fp) != NULL) {
+ while (fgets(buf, MS_FILE_PATH_LEN_MAX, fp) != NULL) {
length = strlen(buf); /*the return value of function, strlen(), includes "\n" */
path = strndup(buf, length - 1); /*copying except "\n" and strndup fuction adds "\0" at the end of the copying string */
}
}
- if(fp) fclose(fp);
+ if (fp) fclose(fp);
fp = NULL;
return MS_MEDIA_ERR_NONE;
__msc_clear_file_list(*path_array);
- if(fp) fclose(fp);
+ if (fp) fclose(fp);
fp = NULL;
return res;
/*updating requests remain*/
if (register_array->len != 0 && remain_request == 0) {
*register_data = g_array_index(register_array, ms_comm_msg_s*, 0);
- g_array_remove_index (register_array, 0);
+ g_array_remove_index(register_array, 0);
break;
} else if (remain_request != 0) {
insert_data = g_async_queue_pop(reg_queue);
}
}
- if(((*register_data)->msg_size <= 0) ||((*register_data)->msg_size > MS_FILE_PATH_LEN_MAX)) {
+ if (((*register_data)->msg_size <= 0) || ((*register_data)->msg_size > MS_FILE_PATH_LEN_MAX)) {
MS_DBG_ERR("message size[%d] is wrong", (*register_data)->msg_size);
return MS_MEDIA_ERR_INVALID_IPC_MESSAGE;
}
ms_msg_type_e current_msg = MS_MSG_MAX;
/*create array for processing overlay data*/
- register_array = g_array_new (FALSE, FALSE, sizeof (ms_comm_msg_s *));
+ register_array = g_array_new(FALSE, FALSE, sizeof(ms_comm_msg_s *));
if (register_array == NULL) {
MS_DBG_ERR("g_array_new error");
return false;
MS_SAFE_FREE(file_path);
MS_SAFE_FREE(register_data);
if (register_array) {
- while(register_array->len != 0) {
+ while (register_array->len != 0) {
ms_comm_msg_s *data = NULL;
data = g_array_index(register_array , ms_comm_msg_s*, 0);
- g_array_remove_index (register_array, 0);
+ g_array_remove_index(register_array, 0);
MS_SAFE_FREE(data);
}
- g_array_free (register_array, FALSE);
+ g_array_free(register_array, FALSE);
register_array = NULL;
}
int (*scan_function)(void **, const char*, uid_t) = ms_update_meta_batch;
/* make new array for storing directory */
- dir_array = g_array_new (FALSE, FALSE, sizeof (char*));
- if (dir_array == NULL){
+ dir_array = g_array_new(FALSE, FALSE, sizeof(char*));
+ if (dir_array == NULL) {
MS_DBG_ERR("g_array_new failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
/* add first direcotiry to directory array */
- g_array_append_val (dir_array, start_path);
+ g_array_append_val(dir_array, start_path);
/*start db update. the number of element in the array , db update is complete.*/
while (dir_array->len != 0) {
/* get the current path from directory array */
current_path = g_array_index(dir_array , char*, 0);
- g_array_remove_index (dir_array, 0);
+ g_array_remove_index(dir_array, 0);
// MS_DBG_SLOG("%d", dir_array->len);
if (__msc_check_scan_ignore(current_path)) {
if (entry.d_type & DT_REG) {
if (ms_strappend(path, sizeof(path), "%s/%s", current_path, entry.d_name) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_strappend failed");
+ MS_DBG_ERR("ms_strappend failed");
continue;
}
/* insert into media DB */
MS_DBG_ERR("%s", path);
- if (scan_function(handle,path, uid) != MS_MEDIA_ERR_NONE) {
+ if (scan_function(handle, path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("failed to update db");
continue;
}
} else if (entry.d_type & DT_DIR) {
/* this request is recursive scanning */
if (ms_strappend(path, sizeof(path), "%s/%s", current_path, entry.d_name) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_strappend failed");
+ MS_DBG_ERR("ms_strappend failed");
continue;
}
/* add new directory to dir_array */
new_path = strdup(path);
- g_array_append_val (dir_array, new_path);
+ g_array_append_val(dir_array, new_path);
}
}
} else {
{
int ret = MS_MEDIA_ERR_NONE;
- switch(scan_type) {
+ switch (scan_type) {
case MS_SCAN_STORAGE:
g_async_queue_push(storage_queue, GINT_TO_POINTER(recv_msg));
break;
temp_scan_queue = g_async_queue_new();
- for (i = 0; i <len; i++) {
+ for (i = 0; i < len; i++) {
/*create new queue to compare request*/
msg = g_async_queue_pop(scan_queue);
if ((strcmp(msg->msg, cancel_path) == 0) && (pid == msg->pid)) {
g_async_queue_push(temp_scan_queue, GINT_TO_POINTER(msg));
}
}
- g_async_queue_unref (scan_queue);
+ g_async_queue_unref(scan_queue);
scan_queue = temp_scan_queue;
END_REMOVE_REQUEST:
/* copy from recived data */
req_num = recv_msg->msg_type;
- switch(req_num){
+ switch (req_num) {
case MS_MSG_BULK_INSERT:
case MS_MSG_BURSTSHOT_INSERT:
{
/* Create pipe */
err = unlink(MS_SCANNER_FIFO_PATH_REQ);
- if (err !=0) {
+ if (err != 0) {
MS_DBG_STRERROR("unlink failed");
}
err = mkfifo(MS_SCANNER_FIFO_PATH_REQ, MS_SCANNER_FIFO_MODE);
- if (err !=0) {
+ if (err != 0) {
MS_DBG_STRERROR("mkfifo failed");
return MS_MEDIA_ERR_INTERNAL;
}
g_main_loop_run(scanner_mainloop);
- g_thread_join (scan_thread);
- g_thread_join (register_thread);
- g_thread_join (storage_scan_thread);
+ g_thread_join(scan_thread);
+ g_thread_join(register_thread);
+ g_thread_join(storage_scan_thread);
g_io_channel_shutdown(channel, FALSE, NULL);
g_io_channel_unref(channel);
/* Create TCP Socket*/
ret = ms_ipc_create_server_socket(MS_PROTOCOL_TCP, MS_DB_UPDATE_PORT, &sockfd);
- if(ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("Failed to create socket");
return FALSE;
}
/* Create TCP Socket for batch query*/
ret = ms_ipc_create_server_socket(MS_PROTOCOL_TCP, MS_DB_BATCH_UPDATE_PORT, &tcp_sockfd);
- if(ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
close(sockfd);
MS_DBG_ERR("Failed to create socket");
return FALSE;
}
scan_type = MS_SCAN_PART;
ms_set_storage_validity(handle, storage_id, 1, uid);
- if (ms_set_storage_scan_status(handle, storage_id, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE){
+ if (ms_set_storage_scan_status(handle, storage_id, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_set_storage_scan_status failed");
}
} else {
ms_connect_db(&handle, uid);
- while(1) {
+ while (1) {
memset(device_id, 0x0, sizeof(device_id));
ms_get_storage_id(handle, mount_path, device_id);
MS_DBG("Last MMC id = [%s] MMC path = [%s]", storage_name, storage_path);
MS_DBG("Current MMC info = [%s]", cid);
- if(storage_name != NULL) {
+ if (storage_name != NULL) {
if (strcmp(storage_name, cid) == 0) {
scan_type = MS_SCAN_PART;
}
}
- if(scan_type == MS_SCAN_PART)
+ if (scan_type == MS_SCAN_PART)
MS_DBG("MMC Scan type [MS_SCAN_PART]");
else
MS_DBG("MMC Scan type [MS_SCAN_ALL]");
if (info_exist == TRUE) {
scan_type = __ms_get_mmc_scan_type(cid, storage_name, storage_path);
- if(scan_type == MS_SCAN_ALL) /*FIX ME. path should be compared*/
+ if (scan_type == MS_SCAN_ALL) /*FIX ME. path should be compared*/
__ms_update_mmc_info(db_handle, storage_name, cid, mount_path);
} else {
__ms_insert_mmc_info(db_handle, cid, mount_path);
/*Quit DB Thread*/
GMainLoop *db_mainloop = ms_db_get_mainloop();
- if(db_mainloop && g_main_loop_is_running(db_mainloop)) {
+ if (db_mainloop && g_main_loop_is_running(db_mainloop)) {
g_main_loop_quit(db_mainloop);
}
return;
}
-static int _mkdir(const char *dir, mode_t mode) {
- char tmp[256];
- char *p = NULL;
- size_t len;
-
- snprintf(tmp, sizeof(tmp),"%s",dir);
- len = strlen(tmp);
- if(tmp[len - 1] == '/')
- tmp[len - 1] = 0;
- for(p = tmp + 1; *p; p++)
- if(*p == '/') {
- *p = 0;
- mkdir(tmp, mode);
- *p = '/';
- }
- return mkdir(tmp, mode);
+static int _mkdir(const char *dir, mode_t mode)
+{
+ char tmp[256];
+ char *p = NULL;
+ size_t len;
+
+ snprintf(tmp, sizeof(tmp), "%s", dir);
+ len = strlen(tmp);
+ if (tmp[len - 1] == '/')
+ tmp[len - 1] = 0;
+ for (p = tmp + 1; *p; p++)
+ if (*p == '/') {
+ *p = 0;
+ mkdir(tmp, mode);
+ *p = '/';
+ }
+
+ return mkdir(tmp, mode);
}
int main(int argc, char **argv)
thumb_thread = g_thread_new("thumb_agent_thread", (GThreadFunc)ms_thumb_agent_start_thread, NULL);
/*clear previous data of sdcard on media database and check db status for updating*/
- while(!ms_db_get_thread_status()) {
+ while (!ms_db_get_thread_status()) {
MS_DBG_ERR("wait db thread");
sleep(1);
}
/*prepare socket*/
/* create dir socket */
- _mkdir("/var/run/media-server",S_IRWXU | S_IRWXG | S_IRWXO);
+ _mkdir("/var/run/media-server", S_IRWXU | S_IRWXG | S_IRWXO);
/* Create and bind new UDP socket */
if (ms_ipc_create_server_socket(MS_PROTOCOL_TCP, MS_SCANNER_PORT, &sockfd)
char *lang = NULL;
/*set power off callback function*/
- ms_sys_set_poweroff_cb(_power_off_cb,channel);
+ ms_sys_set_poweroff_cb(_power_off_cb, channel);
ms_sys_set_device_block_event_cb(ms_device_block_changed_cb, NULL);
if (!ms_config_get_str(VCONFKEY_LANGSET, &lang)) {
MS_DBG_STRERROR("sigaction failed");
}
- signal(SIGPIPE,SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
}
static void __ms_check_mediadb(void)
int dev_num = dev_list->len;
ms_block_info_s *block_info = NULL;
- for (i = 0; i < dev_num; i ++) {
+ for (i = 0; i < dev_num; i++) {
block_info = (ms_block_info_s *)g_array_index(dev_list , ms_stg_type_e*, i);
ms_mmc_insert_handler(block_info->mount_path);
}
int dev_num = dev_list->len;
ms_block_info_s *block_info = NULL;
- for (i = 0; i < dev_num; i ++) {
+ for (i = 0; i < dev_num; i++) {
block_info = (ms_block_info_s *)g_array_index(dev_list , ms_stg_type_e*, i);
ms_usb_insert_handler(block_info->mount_path);
}
#define MS_NO_REMAIN_TASK 0
-#define MEDIA_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN,"media-scanner")
-#define MEDIA_SERVER_PATH_V2 tzplatform_mkpath(TZ_SYS_BIN,"media-scanner-v2")
+#define MEDIA_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN, "media-scanner")
+#define MEDIA_SERVER_PATH_V2 tzplatform_mkpath(TZ_SYS_BIN, "media-scanner-v2")
extern GMainLoop *mainloop;
extern GArray *owner_list;
{
int status;
- if(ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status)) {
+ if (ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status)) {
if (status == VCONFKEY_FILEMANAGER_DB_UPDATING) {
return MS_DB_UPDATING;
}
return MS_DB_UPDATED;
}
-static gboolean _ms_stop_scanner (gpointer user_data)
+static gboolean _ms_stop_scanner(gpointer user_data)
{
int task_num = MS_NO_REMAIN_TASK;
}
/* stop media scanner */
- if (child_pid >0 ) {
+ if (child_pid > 0) {
if (kill(child_pid, SIGKILL) < 0) {
MS_DBG_STRERROR("kill failed");
g_mutex_unlock(&scanner_mutex);
// ms_reset_scanner_status();
- g_source_destroy(g_main_context_find_source_by_id(g_main_loop_get_context (mainloop), alarm_id));
- g_source_destroy(g_main_context_find_source_by_id(g_main_loop_get_context (mainloop), receive_id));
+ g_source_destroy(g_main_context_find_source_by_id(g_main_loop_get_context(mainloop), alarm_id));
+ g_source_destroy(g_main_context_find_source_by_id(g_main_loop_get_context(mainloop), receive_id));
return FALSE;
}
int value = 0;
dict = iniparser_load(MS_INI_DEFAULT_PATH);
- if(!dict) {
+ if (!dict) {
MS_DBG_ERR("%s load failed", MS_INI_DEFAULT_PATH);
return 0;
}
unlink(MS_SCANNER_FIFO_PATH_RES);
unlink(MS_SCANNER_FIFO_PATH_REQ);
- g_source_destroy(g_main_context_find_source_by_id(g_main_loop_get_context (mainloop), alarm_id));
- g_source_destroy(g_main_context_find_source_by_id(g_main_loop_get_context (mainloop), receive_id));
+ g_source_destroy(g_main_context_find_source_by_id(g_main_loop_get_context(mainloop), alarm_id));
+ g_source_destroy(g_main_context_find_source_by_id(g_main_loop_get_context(mainloop), receive_id));
g_mutex_unlock(&scanner_mutex);
src = g_timeout_source_new_seconds(interval);
g_source_set_callback(src, func, data, NULL);
- alarm_id = g_source_attach(src, g_main_loop_get_context (mainloop));
+ alarm_id = g_source_attach(src, g_main_loop_get_context(mainloop));
g_source_unref(src);
}
return MS_MEDIA_ERR_NONE;
}
- if((pid = fork()) < 0) {
+ if ((pid = fork()) < 0) {
MS_DBG_ERR("Fork error\n");
g_mutex_unlock(&scanner_mutex);
} else if (pid > 0) {
int scanner_status = -1;
err = unlink(MS_SCANNER_FIFO_PATH_RES);
- if (err !=0) {
+ if (err != 0) {
MS_DBG_STRERROR("[No-Error] unlink failed");
}
err = mkfifo(MS_SCANNER_FIFO_PATH_RES, MS_SCANNER_FIFO_MODE);
- if (err !=0) {
+ if (err != 0) {
MS_DBG_STRERROR("mkfifo failed");
return MS_MEDIA_ERR_INTERNAL;
}
return ret;
/* attach socket receive message callback */
- } else if(pid == 0) {
+ } else if (pid == 0) {
/* child process */
MS_DBG_ERR("[No-Error] CHILD PROCESS");
MS_DBG("[No-Error] EXECUTE MEDIA SCANNER");
- if(_ms_get_ini_config("media-content-config:scanner_type") == 1)
+ if (_ms_get_ini_config("media-content-config:scanner_type") == 1)
execl(MEDIA_SERVER_PATH_V2, "media-scanner-v2", NULL);
else
execl(MEDIA_SERVER_PATH, "media-scanner", NULL);
extern bool power_off;
-typedef struct ms_req_owner_data
-{
+typedef struct ms_req_owner_data {
int pid;
int index;
int client_sockfd;
char *req_path;
-}ms_req_owner_data;
+} ms_req_owner_data;
static int __ms_add_owner(int pid, int client_sock, char *path)
{
/* These are used for sending result of scanning */
if (owner_list == NULL) {
/*create array for processing overlay data*/
- owner_list = g_array_new (FALSE, FALSE, sizeof (ms_req_owner_data *));
+ owner_list = g_array_new(FALSE, FALSE, sizeof(ms_req_owner_data *));
if (owner_list == NULL) {
MS_DBG_ERR("g_array_new error");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
if (owner_data == NULL) {
MS_DBG_ERR("MS_MALLOC failed");
- g_array_free (owner_list, FALSE);
+ g_array_free(owner_list, FALSE);
owner_list = NULL;
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
MS_DBG("length list : %d", len);
- for (i=0; i < len; i++) {
+ for (i = 0; i < len; i++) {
data = g_array_index(owner_list, ms_req_owner_data*, i);
MS_DBG("%d %d", data->pid, pid);
MS_DBG("%s %s", data->req_path, req_path);
static int __ms_send_result_to_client(int pid, ms_comm_msg_s *recv_msg)
{
- if(strlen(recv_msg->msg) == 0) {
+ if (strlen(recv_msg->msg) == 0) {
MS_DBG_ERR("msg is NULL");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
/* find owner data */
ms_req_owner_data *owner_data = NULL;
char *res_path = strdup(recv_msg->msg);
- if(res_path == NULL) {
+ if (res_path == NULL) {
MS_DBG_ERR("res_path is NULL");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
goto ERROR;
}
- if(strncmp(recv_msg.msg, MEDIA_ROOT_PATH_EXTERNAL, strlen(MEDIA_ROOT_PATH_EXTERNAL)) == 0) {
+ if (strncmp(recv_msg.msg, MEDIA_ROOT_PATH_EXTERNAL, strlen(MEDIA_ROOT_PATH_EXTERNAL)) == 0) {
if (ms_cynara_check(&creds, EXTERNAL_STORAGE_PRIVILEGE) != MS_MEDIA_ERR_NONE) {
res = ret;
goto ERROR;
req_num = recv_msg.msg_type;
pid = recv_msg.pid;
- /* register file request
- * media server inserts the meta data of one file into media db */
+ /* register file request media server inserts the meta data of one file into media db */
if (req_num == MS_MSG_DIRECTORY_SCANNING
- ||req_num == MS_MSG_BULK_INSERT
- ||req_num == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE
+ || req_num == MS_MSG_BULK_INSERT
+ || req_num == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE
|| req_num == MS_MSG_BURSTSHOT_INSERT
|| req_num == MS_MSG_DIRECTORY_SCANNING_CANCEL) {
if ((ret = ms_send_scan_request(&recv_msg, client_sock)) != MS_MEDIA_ERR_NONE) {
memset(&res_msg, 0x0, sizeof(ms_comm_msg_s));
- switch(req_num) {
+ switch (req_num) {
case MS_MSG_DIRECTORY_SCANNING:
case MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE:
res_msg.msg_type = MS_MSG_SCANNER_RESULT;
case MS_MSG_BURSTSHOT_INSERT:
res_msg.msg_type = MS_MSG_SCANNER_BULK_RESULT;
break;
- default :
+ default:
break;
}
g_mutex_unlock(&scanner_mutex);
err = ms_scanner_start();
- if(err == MS_MEDIA_ERR_NONE) {
+ if (err == MS_MEDIA_ERR_NONE) {
err = __ms_send_request(send_msg);
- if(err != MS_MEDIA_ERR_NONE) {
+ if (err != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("__ms_send_request failed", err);
}
} else {
case MS_SCAN_META:
scan_msg.msg_type = MS_MSG_STORAGE_META;
break;
- default :
+ default:
ret = MS_MEDIA_ERR_INVALID_PARAMETER;
MS_DBG_ERR("ms_send_storage_scan_request invalid parameter");
goto ERROR;
/* msg_size & msg */
if (root_path != NULL) {
scan_msg.msg_size = strlen(root_path);
- strncpy(scan_msg.msg, root_path, scan_msg.msg_size );
+ strncpy(scan_msg.msg, root_path, scan_msg.msg_size);
}
if (storage_id != NULL) {
strncpy(scan_msg.storage_id, storage_id, MS_UUID_SIZE-1);
}
- if(uid == 0) {
+ if (uid == 0) {
ms_sys_get_uid(&uid);
}
MS_SAFE_FREE(creds.smack);
MS_SAFE_FREE(creds.uid);
- if(media_db_connect(&db_handle, recv_msg.uid, TRUE) != MS_MEDIA_ERR_NONE) {
+ if (media_db_connect(&db_handle, recv_msg.uid, TRUE) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("Failed to connect DB");
goto ERROR;
}
MS_DBG("Sent successfully");
}
- if (close(client_sock) <0) {
+ if (close(client_sock) < 0) {
MS_DBG_STRERROR("close failed");
}
int ret = MS_MEDIA_ERR_NONE;
char * sql_query = NULL;
ms_comm_msg_s recv_msg;
- int client_sock = GPOINTER_TO_INT (data);
+ int client_sock = GPOINTER_TO_INT(data);
int send_msg = MS_MEDIA_ERR_NONE;
MediaDBHandle *db_handle = NULL;
// MS_DBG_ERR("client sokcet : %d", client_sock);
- while(1) {
+ while (1) {
if (power_off == TRUE) {
MS_DBG_WARN("in the power off sequence");
break;
}
/* Connect Media DB*/
- if(db_handle == NULL) {
- if(media_db_connect(&db_handle, recv_msg.uid, TRUE) != MS_MEDIA_ERR_NONE) {
+ if (db_handle == NULL) {
+ if (media_db_connect(&db_handle, recv_msg.uid, TRUE) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("Failed to connect DB");
send_msg = MS_MEDIA_ERR_DB_CONNECT_FAIL;
goto ERROR;
if (sql_query != NULL) {
if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_START) {
ret = media_db_update_db_batch_start(sql_query);
- } else if(recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_END) {
+ } else if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_END) {
ret = media_db_update_db_batch_end(db_handle, sql_query);
- } else if(recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH) {
+ } else if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH) {
ret = media_db_update_db_batch(sql_query);
} else {
}
}
- if (close(client_sock) <0) {
+ if (close(client_sock) < 0) {
MS_DBG_STRERROR("close failed");
}
MS_DBG("Sent successfully");
}
- if (close(client_sock) <0) {
+ if (close(client_sock) < 0) {
MS_DBG_STRERROR("close failed");
}
MS_DBG("Sent successfully");
}
- if (close(client_sock) <0) {
+ if (close(client_sock) < 0) {
MS_DBG_STRERROR("close failed");
}
}
MS_DBG_SLOG("This request is from media-server");
}
} else {
- MS_DBG_ERR("This result message is wrong : %d", recv_msg.msg_type );
+ MS_DBG_ERR("This result message is wrong : %d", recv_msg.msg_type);
}
return TRUE;
case MS_SCAN_INVALID:
scan_msg.msg_type = MS_MSG_STORAGE_INVALID;
break;
- default :
+ default:
ret = MS_MEDIA_ERR_INVALID_PARAMETER;
MS_DBG_ERR("ms_send_storage_scan_request invalid parameter");
goto ERROR;
/* msg_size & msg */
scan_msg.msg_size = strlen(path);
- strncpy(scan_msg.msg, path, scan_msg.msg_size );
+ strncpy(scan_msg.msg, path, scan_msg.msg_size);
strncpy(scan_msg.storage_id, device_uuid, MS_UUID_SIZE-1);
ret = ms_send_scan_request(&scan_msg, -1);
do { \
value = iniparser_getint(dict, key, default); \
MS_DBG("get %s = %d", key, value); \
- } while(0)
-#define THUMB_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN,"media-thumbnail-server")
+ } while (0)
+#define THUMB_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN, "media-thumbnail-server")
gboolean _ms_thumb_agent_timer();
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, _ms_thumb_agent_timer, NULL, NULL);
- g_timer_id = g_source_attach (timer_src, g_main_context_get_thread_default());
+ g_source_set_callback(timer_src, _ms_thumb_agent_timer, NULL, NULL);
+ g_timer_id = g_source_attach(timer_src, g_main_context_get_thread_default());
}
header_size = sizeof(thumbMsg) -(MAX_FILEPATH_LEN * 2) - sizeof(unsigned char *);
MS_MALLOC(buf, header_size);
- if(buf == NULL) {
+ if (buf == NULL) {
MS_DBG_STRERROR("malloc failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
MS_SAFE_FREE(buf);
- if(msg->msg_type == MS_MSG_THUMB_EXTRACT_ALL_DONE || msg->msg_type == 5) {
+ if (msg->msg_type == MS_MSG_THUMB_EXTRACT_ALL_DONE || msg->msg_type == 5) {
MS_DBG("msg_type only cases [%d]", msg->msg_type);
return MS_MEDIA_ERR_NONE;
}
if (msg->origin_path_size <= 0 || msg->origin_path_size > MS_FILE_PATH_LEN_MAX) {
MS_SAFE_FREE(buf);
- MS_DBG_ERR("msg->origin_path_size is invalid %d", msg->origin_path_size );
+ MS_DBG_ERR("msg->origin_path_size is invalid %d", msg->origin_path_size);
return MS_MEDIA_ERR_DATA_TAINTED;
}
MS_MALLOC(buf, (unsigned int)(msg->origin_path_size));
- if(buf == NULL) {
+ if (buf == NULL) {
MS_DBG_STRERROR("malloc failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
if (msg->dest_path_size <= 0 || msg->dest_path_size > MS_FILE_PATH_LEN_MAX) {
MS_SAFE_FREE(buf);
- MS_DBG_ERR("msg->dest_path_size is invalid %d", msg->dest_path_size );
+ MS_DBG_ERR("msg->dest_path_size is invalid %d", msg->dest_path_size);
return MS_MEDIA_ERR_DATA_TAINTED;
}
MS_MALLOC(buf, (unsigned int)(msg->dest_path_size));
- if(buf == NULL) {
+ if (buf == NULL) {
MS_DBG_ERR("malloc failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
if (msg->thumb_size < 0) {
MS_SAFE_FREE(buf);
- MS_DBG_ERR("msg->thumb_size is invalid %d", msg->thumb_size );
+ MS_DBG_ERR("msg->thumb_size is invalid %d", msg->thumb_size);
return MS_MEDIA_ERR_DATA_TAINTED;
}
- if(msg->thumb_size > 0) {
+ if (msg->thumb_size > 0) {
MS_MALLOC(buf, (unsigned int)(msg->thumb_size));
- if(buf == NULL) {
+ if (buf == NULL) {
MS_DBG_ERR("malloc failed");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
MS_SAFE_FREE(msg->thumb_data);
MS_MALLOC(msg->thumb_data, (unsigned int)(msg->thumb_size));
- if(msg->thumb_data == NULL) {
+ if (msg->thumb_data == NULL) {
MS_DBG_ERR("malloc failed");
MS_SAFE_FREE(buf);
return MS_MEDIA_ERR_OUT_OF_MEMORY;
size = header_size + org_path_len + dst_path_len + data_len;
MS_MALLOC(*buf, size);
- if(*buf == NULL) {
+ if (*buf == NULL) {
MS_DBG_STRERROR("MALLOC failed");
return -1;
}
memcpy(*buf, req_msg, header_size);
memcpy((*buf)+header_size, req_msg->org_path, org_path_len);
memcpy((*buf)+header_size + org_path_len, req_msg->dst_path, dst_path_len);
- if(data_len > 0)
+ if (data_len > 0)
memcpy((*buf)+header_size + org_path_len + dst_path_len, req_msg->thumb_data, data_len);
*buf_size = size;
/* Once all-thumb extraction is done, check if there is queued all-thumb request */
GSource *check_queued_all_thumb_request = NULL;
- check_queued_all_thumb_request = g_idle_source_new ();
- g_source_set_callback (check_queued_all_thumb_request, _ms_thumb_check_queued_request, NULL, NULL);
- g_source_attach (check_queued_all_thumb_request, g_main_context_get_thread_default());
+ check_queued_all_thumb_request = g_idle_source_new();
+ g_source_set_callback(check_queued_all_thumb_request, _ms_thumb_check_queued_request, NULL, NULL);
+ g_source_attach(check_queued_all_thumb_request, g_main_context_get_thread_default());
if (g_thumb_server_extracting == FALSE) {
MS_DBG_WARN("Recv thumb server extracting done already");
}
if (g_folk_thumb_server == FALSE && g_thumb_server_extracting == FALSE) {
-// if(_ms_thumb_check_process() == FALSE) { // This logic is temporary
+// if (_ms_thumb_check_process() == FALSE) { // This logic is temporary
MS_DBG_WARN("Thumb server is not running.. so start it");
if (!_ms_thumb_agent_execute_server()) {
MS_DBG_ERR("_ms_thumb_agent_execute_server is failed");
client_sock = req->client_sock;
recv_msg = req->recv_msg;
- if (req->client_sock <=0 || req->recv_msg == NULL) {
+ if (req->client_sock <= 0 || req->recv_msg == NULL) {
MS_DBG_ERR("client sock is below 0 or recv msg is NULL");
MS_SAFE_FREE(req->recv_msg);
MS_SAFE_FREE(req);
unsigned char *buf = NULL;
_ms_thumb_set_buffer(&res_msg, &buf, &buf_size);
- while(buf_size > 0) {
- if(buf_size < MS_SOCK_BLOCK_SIZE) {
+ while (buf_size > 0) {
+ if (buf_size < MS_SOCK_BLOCK_SIZE) {
block_size = buf_size;
}
if (send(client_sock, buf+sending_block, block_size, 0) != block_size) {
}
sending_block += block_size;
buf_size -= block_size;
- if(block_size < MS_SOCK_BLOCK_SIZE) {
+ if (block_size < MS_SOCK_BLOCK_SIZE) {
block_size = MS_SOCK_BLOCK_SIZE;
}
}
- if(buf_size == 0) {
+ if (buf_size == 0) {
MS_DBG_SLOG("Sent data(%d) from %s", res_msg.thumb_size, res_msg.org_path);
}
MS_DBG_ERR("credential information error");
}
- if ( getuid() != cr.uid ){
+ if (getuid() != cr.uid) {
recv_msg->uid = cr.uid;
}
if (!g_queue_work) {
GSource *src_request = NULL;
- src_request = g_idle_source_new ();
- g_source_set_callback (src_request, _ms_thumb_request_to_server, NULL, NULL);
+ src_request = g_idle_source_new();
+ g_source_set_callback(src_request, _ms_thumb_request_to_server, NULL, NULL);
//g_source_set_priority(src_request, G_PRIORITY_LOW);
- g_source_attach (src_request, g_main_context_get_thread_default());
+ g_source_attach(src_request, g_main_context_get_thread_default());
g_queue_work = 1;
}
dictionary *dict = NULL;
dict = iniparser_load(MS_INI_DEFAULT_PATH);
- if(!dict) {
+ if (!dict) {
MS_DBG_ERR("%s load failed", MS_INI_DEFAULT_PATH);
return -1;
}
- MS_INI_GET_INT(dict, "media-content-config:thumbnail_activation",g_thumb_server_active, 0);
+ MS_INI_GET_INT(dict, "media-content-config:thumbnail_activation", g_thumb_server_active, 0);
MS_DBG("Thumb-server activation level = %d", g_thumb_server_active);
iniparser_freedict(dict);