#endif
#define MS_SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
-#define MS_MALLOC(src, size) { if (size > SIZE_MAX || size <= 0) {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); } }
#define MS_STRING_VALID(str) \
((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
error_buffer[0] = '\0';
err = cynara_strerror(error_code, error_buffer, sizeof(error_buffer));
- if (err == CYNARA_API_SUCCESS) {
+ if (err == CYNARA_API_SUCCESS)
MSAPI_DBG_ERR("%s: %s", prefix, error_buffer);
- } else {
+ else
MSAPI_DBG_ERR("%s: error code %i", prefix, error_code);
- }
}
int ms_cynara_initialize(void)
MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_DB_CONNECT_FAIL, "ms_user_get_media_db_path failed");
/*Connect DB*/
- if (need_write) {
+ if (need_write)
ret = db_util_open_with_options(db_path, db_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
- } else {
+ else
ret = db_util_open_with_options(db_path, db_handle, SQLITE_OPEN_READONLY, NULL);
- }
MS_SAFE_FREE(db_path);
if (SQLITE_OK != ret) {
- if (*db_handle) {
+ if (*db_handle)
MSAPI_DBG_ERR("[error when register busy handler] %s", sqlite3_errmsg(*db_handle));
- }
db_util_close(*db_handle);
*db_handle = NULL;
sqlite3_free(sql);
if (SQLITE_OK != ret) {
- if (*db_handle) {
+ if (*db_handle)
MSAPI_DBG_ERR("[error when change the journal mode] %s", sqlite3_errmsg(*db_handle));
- }
db_util_close(*db_handle);
*db_handle = NULL;
MSAPI_DBG("RECEIVE OK [%d]", recv_msg);
ret = recv_msg;
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
MSAPI_DBG_ERR("batch updated[%d] failed, error [%d]", msg_type, ret);
- }
return ret;
}
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);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
MSAPI_DBG_ERR("__media_db_request_update_tcp failed : %d", ret);
- }
return ret;
}
}
ret = __media_db_request_batch_update(MS_MSG_DB_UPDATE_BATCH_START, query_str, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
__media_db_close_tcp_client_socket();
- }
return ret;
}
MSAPI_RETVM_IF(!MS_STRING_VALID(query_str), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid Query");
ret = __media_db_request_batch_update(MS_MSG_DB_UPDATE_BATCH, query_str, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
__media_db_close_tcp_client_socket();
- }
return ret;
}
if ((err = recv(sock, &recv_msg, sizeof(dcmMsg), 0)) < 0) {
MSAPI_DBG_STRERROR("recv failed ");
- if (recv_msg.msg_size > 0) {
+ if (recv_msg.msg_size > 0)
__media_dcm_pop_data();
- } else {
+ else
MSAPI_DBG_ERR("origin path size is wrong.");
- }
return FALSE;
}
MSAPI_DBG_ERR("__media_dcm_check_cancel is true");
if (data) {
faceUserData* cb = (faceUserData*)data;
- if (cb->func != NULL) {
+ if (cb->func != NULL)
cb->func(recv_msg.msg_type, (int)(recv_msg.result), cb->user_data);
- }
}
}
} 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, repl_path, uuid);
- } else {
+ else
message = g_variant_new("(iiis)", item, pid, update_type, repl_path);
- }
} else {
MSAPI_DBG("this request is wrong");
}
int media_db_update_unsubscribe(void)
{
- if (g_bus == NULL) {
+ if (g_bus == NULL)
return MS_MEDIA_ERR_NONE;
- }
g_mutex_lock(¬i_mutex);
} 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, repl_path, uuid);
- } else {
+ else
message = g_variant_new("(iiis)", item, pid, update_type, repl_path);
- }
} else {
MSAPI_DBG("this request is wrong");
}
#define POWEROFF -1 /*This number uses for stopping Scannig thread*/
#define MS_SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
-#define MS_MALLOC(src, size) { if (size > SIZE_MAX || size <= 0) {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); } }
#define MS_STRING_VALID(str) \
((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
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);
MS_SAFE_FREE(func_handle);
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);
MS_SAFE_FREE(func_handle);
dlclose(func_handle[lib_index]);
for (lib_index = 0; lib_index < lib_num; lib_index++) {
- if (func_array[lib_index]) {
+ if (func_array[lib_index])
MS_SAFE_FREE(func_array[lib_index]);
- }
}
MS_SAFE_FREE(func_array);
if (ret != 0) {
MS_SAFE_FREE(err_msg);
ret = ms_insert_item_batch(handle, storage_id, path, uid);
- if (ret != 0) {
+ if (ret != 0)
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
- }
} else {
if (modified == FALSE) {
/*if meta data of file exist, change valid field to "1" */
res = MS_MEDIA_ERR_DB_DELETE_FAIL;
} else {
ret = ms_insert_item_batch(handle, storage_id, path, uid);
- if (ret != 0) {
+ if (ret != 0)
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
- }
}
}
}
if (ret != 0) {
MS_SAFE_FREE(err_msg);
ret = ms_scan_item_batch(handle, storage_id, path, uid);
- if (ret != 0) {
+ if (ret != 0)
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
- } else {
+ else
insert_count_for_partial++;
- }
} else {
if (modified == FALSE) {
/*if meta data of file exist, change valid field to "1" */
res = MS_MEDIA_ERR_DB_DELETE_FAIL;
} else {
ret = ms_scan_item_batch(handle, storage_id, path, uid);
- if (ret != 0) {
+ if (ret != 0)
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
- } else {
+ else
insert_count_for_partial++;
- }
}
}
}
if (ret != 0) {
MS_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
MS_SAFE_FREE(err_msg);
- if (ret == -2) {
+ if (ret == -2)
res = MS_MEDIA_ERR_FILE_IO;
- } else {
+ else
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
- }
}
}
}
}
- if (strlen(folder_uuid) == (MS_UUID_SIZE-1)) {
+ if (strlen(folder_uuid) == (MS_UUID_SIZE-1))
*folder_id = strdup(folder_uuid);
- } else {
+ else
*folder_id = NULL;
- }
MS_DBG("folder_id [%s]", *folder_id);
if (!g_file_test(mmc_path, G_FILE_TEST_IS_DIR)) {
MS_DBG("%s path did not exist", mmc_path);
ret = mkdir(mmc_path, 0770);
- if (ret < 0) {
+ if (ret < 0)
MS_DBG_ERR("mkdir failed");
- }
+
/*this fuction for emulator*/
/*at the first time, the directroies are made permission 755*/
ret = chmod(mmc_path, 0770);
- if (ret != 0) {
+ if (ret != 0)
MS_DBG_STRERROR("chmod failed");
- }
}
}
}
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);
- if (len < 0) {
+ if (len < 0)
return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
path[len] = '\0';
if (ret == MS_MEDIA_ERR_FILE_NOT_EXIST) {
ret = ms_genarate_uuid(handle, &id);
ret = ms_write_device_info(add_path , id);
- if (ret == MS_MEDIA_ERR_NONE) {
+ if (ret == MS_MEDIA_ERR_NONE)
*device_id = strdup(id);
- }
}
} else {
*device_id = strdup(id);
#ifdef _USE_DEVICED_DBUS
int ms_sys_unset_device_block_event_cb(void)
{
- if (g_usb_bus == NULL) {
+ if (g_usb_bus == NULL)
return MS_MEDIA_ERR_NONE;
- }
g_dbus_connection_signal_unsubscribe(g_usb_bus, g_usb_handler);
g_object_unref(g_usb_bus);
MS_DBG("\tstorage_id(%d)", val_int[4]);
}
- for (i = 0; i < 7; i++) {
+ for (i = 0; i < 7; i++)
MS_SAFE_FREE(val_str[i]);
- }
}
g_variant_iter_free(iter);
DEVICED_INTERFACE_BLOCK_MANAGER,
BLOCK_DEVICE_METHOD,
dev_params[stg_type], dev_list);
- if (ret < 0) {
+
+ if (ret < 0)
MS_DBG("Failed to send dbus (%d)", ret);
- } else {
+ else
MS_DBG("%d block devices are founded", ret);
- }
return MS_MEDIA_ERR_NONE;
}
err = usb_device_list_get_first(list, &device);
if (err != USB_ERROR_LIST_FAILED_TO_GET && device != NULL) {
mount_path = usb_device_get_mountpath(device);
- if (mount_path != NULL) {
+ if (mount_path != NULL)
MS_DBG_WARN("mount_path [%s]", mount_path);
- }
}
} else {
usb_device_list_get_next(list, &device);
if (device != NULL) {
mount_path = usb_device_get_mountpath(device);
- if (mount_path != NULL) {
+ if (mount_path != NULL)
MS_DBG_WARN("mount_path [%s]", mount_path);
- }
}
}
MS_DBG_ERR("current type : %s", type_str);
}
- if (val_int == 2 || val_int == 3) {
+ if (val_int == 2 || val_int == 3)
MS_DBG_WARN("PREPARE POWER OFF");
- }
if (val_int == 2 || val_int == 3)
cb_func(power_info, usr_data);
#ifdef _USE_DEVICED_DBUS
int ms_sys_unset_poweroff_cb(void)
{
- if (g_pwr_bus == NULL) {
+ if (g_pwr_bus == NULL)
return MS_MEDIA_ERR_NONE;
- }
g_dbus_connection_signal_unsubscribe(g_pwr_bus, g_pwr_handler);
g_object_unref(g_pwr_bus);
return MS_MEDIA_ERR_INVALID_PARAMETER;
len = snprintf(res, real_size, pattern, str1, str2);
- if (len < 0) {
+ if (len < 0)
return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
res[len] = '\0';
data->mount_uuid = strdup(val_str[5]);
data->flags = val_int[3];
- if (*dev_list == NULL) {
+ if (*dev_list == NULL)
*dev_list = g_array_new(FALSE, FALSE, sizeof(block_info_s*));
- }
g_array_append_val(*dev_list, data);
}
}
- for (i = 0; i < 7; i++) {
+ for (i = 0; i < 7; i++)
MU_SAFE_FREE(val_str[i]);
- }
}
g_variant_iter_free(iter);
-/*\r
- * Media Server\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#ifndef _MEDIA_SCANNER_DB_MANAGER_V2_H_\r
-#define _MEDIA_SCANNER_DB_MANAGER_V2_H_\r
-\r
-#include "media-common-types.h"\r
-\r
-int msc_check_db_size(uid_t uid, int scan_type);\r
-int msc_cleanup_invalid_values(uid_t uid);\r
-\r
-#endif\r
-\r
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _MEDIA_SCANNER_DB_MANAGER_V2_H_
+#define _MEDIA_SCANNER_DB_MANAGER_V2_H_
+
+#include "media-common-types.h"
+
+int msc_check_db_size(uid_t uid, int scan_type);
+int msc_cleanup_invalid_values(uid_t uid);
+
+#endif
+
void msc_device_block_changed_cb(usb_device_h usb_device, char *action, void *user_data);
#endif
-#endif
\ No newline at end of file
+#endif
int msc_get_dir_scan_status(bool *scan_status);
int msc_set_cancel_path(const char *cancel_path);
-#endif /*_MEDIA_SCANNER_SCAN_V2_H_*/
\ No newline at end of file
+#endif /*_MEDIA_SCANNER_SCAN_V2_H_*/
-/*\r
- * Media Server\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <errno.h>\r
-#include <sys/stat.h>\r
-#include <sqlite3.h>\r
-\r
-#include "media-util.h"\r
-#include "media-common-utils.h"\r
-#include "media-common-system.h"\r
-#include "media-common-db-svc.h"\r
-#include "media-scanner-dbg-v2.h"\r
-#include "media-scanner-db-manage-v2.h"\r
-\r
-int msc_check_db_size(uid_t uid, int scan_type)\r
-{\r
- double db_size = 0.0;\r
- double free_space = 0.0;\r
- int err = MS_MEDIA_ERR_NONE;\r
-\r
- ms_check_size_mediadb(uid, &db_size);\r
-\r
- if (scan_type == MS_MSG_STORAGE_ALL\r
- || scan_type == MS_MSG_STORAGE_PARTIAL) {\r
- if (db_size >= MEDIA_DB_SIZE_LIMIT_1) {\r
- MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_1[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_1);\r
- return MS_MEDIA_ERR_DB_LIMIT_1;\r
- }\r
- } else if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE\r
- || scan_type == MS_MSG_DIRECTORY_SCANNING) {\r
- if (db_size >= MEDIA_DB_SIZE_LIMIT_2) {\r
- MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_2[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_2);\r
-\r
- MS_DBG_WARN("START REMOVE INVALID DATA");\r
- msc_cleanup_invalid_values(uid);\r
- MS_DBG_WARN("END REMOVE INVALID DATA");\r
-\r
- ms_check_size_mediadb(uid, &db_size);\r
- if (db_size >= MEDIA_DB_SIZE_LIMIT_2) {\r
-#ifdef _USE_TVPD_MODE\r
- ms_config_set_int(MS_DB_LIMIT, 0);\r
-#endif\r
- MS_DBG_ERR("DB IS FULL. CANNOT UPDATE");\r
- return MS_MEDIA_ERR_DB_FULL_FAIL;\r
- }\r
- }\r
- }\r
-\r
- /*check remain space*/\r
- err = ms_get_remain_space(&free_space);\r
- if (err != MS_MEDIA_ERR_NONE) {\r
- MS_DBG_ERR("ms_get_remain_space failed");\r
- } else {\r
- if (free_space < MEDIA_DB_SPACE_LIMIT) {\r
- MS_DBG_ERR("FREE SPACE [%lf] DB SIZE [%lf]", free_space, db_size);\r
- return MS_MEDIA_ERR_NOT_ENOUGH_SPACE;\r
- }\r
- }\r
-\r
- return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
-int msc_cleanup_invalid_values(uid_t uid)\r
-{\r
- int ret = MS_MEDIA_ERR_NONE;\r
- void **handle = NULL;\r
-\r
- MS_DBG_ERR("START CLEANUP MEDIA DB");\r
-\r
- ms_connect_db(&handle, uid);\r
- ret = ms_cleanup_db(handle, uid);\r
- if (ret != MS_MEDIA_ERR_NONE) {\r
- MS_DBG_ERR("'Cleanup failed [%d]", ret);\r
- return ret;\r
- }\r
-\r
- if (handle)\r
- ms_disconnect_db(&handle);\r
-\r
- MS_DBG_ERR("END CLEANUP MEDIA DB");\r
-\r
- return ret;\r
-}\r
-\r
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <sqlite3.h>
+
+#include "media-util.h"
+#include "media-common-utils.h"
+#include "media-common-system.h"
+#include "media-common-db-svc.h"
+#include "media-scanner-dbg-v2.h"
+#include "media-scanner-db-manage-v2.h"
+
+int msc_check_db_size(uid_t uid, int scan_type)
+{
+ double db_size = 0.0;
+ double free_space = 0.0;
+ int err = MS_MEDIA_ERR_NONE;
+
+ ms_check_size_mediadb(uid, &db_size);
+
+ if (scan_type == MS_MSG_STORAGE_ALL
+ || scan_type == MS_MSG_STORAGE_PARTIAL) {
+ if (db_size >= MEDIA_DB_SIZE_LIMIT_1) {
+ MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_1[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_1);
+ return MS_MEDIA_ERR_DB_LIMIT_1;
+ }
+ } else if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE
+ || scan_type == MS_MSG_DIRECTORY_SCANNING) {
+ if (db_size >= MEDIA_DB_SIZE_LIMIT_2) {
+ MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_2[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_2);
+
+ MS_DBG_WARN("START REMOVE INVALID DATA");
+ msc_cleanup_invalid_values(uid);
+ MS_DBG_WARN("END REMOVE INVALID DATA");
+
+ ms_check_size_mediadb(uid, &db_size);
+ if (db_size >= MEDIA_DB_SIZE_LIMIT_2) {
+#ifdef _USE_TVPD_MODE
+ ms_config_set_int(MS_DB_LIMIT, 0);
+#endif
+ MS_DBG_ERR("DB IS FULL. CANNOT UPDATE");
+ return MS_MEDIA_ERR_DB_FULL_FAIL;
+ }
+ }
+ }
+
+ /*check remain space*/
+ err = ms_get_remain_space(&free_space);
+ if (err != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("ms_get_remain_space failed");
+ } else {
+ if (free_space < MEDIA_DB_SPACE_LIMIT) {
+ MS_DBG_ERR("FREE SPACE [%lf] DB SIZE [%lf]", free_space, db_size);
+ return MS_MEDIA_ERR_NOT_ENOUGH_SPACE;
+ }
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int msc_cleanup_invalid_values(uid_t uid)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+ void **handle = NULL;
+
+ MS_DBG_ERR("START CLEANUP MEDIA DB");
+
+ ms_connect_db(&handle, uid);
+ ret = ms_cleanup_db(handle, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("'Cleanup failed [%d]", ret);
+ return ret;
+ }
+
+ if (handle)
+ ms_disconnect_db(&handle);
+
+ MS_DBG_ERR("END CLEANUP MEDIA DB");
+
+ return ret;
+}
+
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]");
- }
if (msc_get_remain_scan_request(MS_SCAN_STORAGE, &remain_request) == MS_MEDIA_ERR_NONE) {
- if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED))
msc_set_blocked_path(mount_path);
- }
+
remain_request = 0;
}
}
if (msc_get_remain_extract_request(MS_EXTRACT_STORAGE, &remain_request) == MS_MEDIA_ERR_NONE) {
- if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!(remain_request == 0 && update_status == VCONFKEY_FILEMANAGER_DB_UPDATED))
msc_set_extract_blocked_path(mount_path);
- }
+
remain_request = 0;
}
/* If scanner is not working, media server executes media scanner and sends request. */
/* If scanner is working, it detects changing status of SD card. */
if (mount_status == MS_STG_INSERTED) {
+ MS_DBG_WARN("GET THE MMC INSERT EVENT");
/*DO NOT THING*/
} else if (mount_status == MS_STG_REMOVED) {
+ MS_DBG_WARN("GET THE MMC REMOVE EVENT");
msc_mmc_remove_handler(mount_path);
}
void msc_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
{
if (block_info->block_type == 0) {
- MS_DBG_WARN("GET THE USB EVENT");
if (block_info->state == MS_STG_INSERTED) {
- /*DO NOT THING*/
+ MS_DBG_WARN("GET THE USB INSERT EVENT");
} else {
+ MS_DBG_WARN("GET THE USB REMOVE EVENT");
__msc_usb_remove_event(block_info->mount_path);
}
} else {
MS_DBG_ERR("USB BLOCKED, mountpath : %s", mount_path);
int status = -1;
- if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status)) {
+ if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status))
MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
- }
- if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED))
msc_set_blocked_path(mount_path);
- }
if (g_directory_scan_processing2 != 0) {
MS_DBG_WARN("Doing directory scanning. Set cancel path");
msc_set_cancel_scan_item(mount_path, -1);
}
- if (!ms_config_get_int(VCONFKEY_PRIVATE_EXTRACTSTATUS, &status)) {
+ if (!ms_config_get_int(VCONFKEY_PRIVATE_EXTRACTSTATUS, &status))
MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
- }
- if (!(g_async_queue_length(storage_extract_queue) == 0 && status == MS_DB_UPDATED)) {
+
+ if (!(g_async_queue_length(storage_extract_queue) == 0 && status == MS_DB_UPDATED))
msc_set_extract_blocked_path(mount_path);
- }
if (g_directory_extract_processing == true) {
MS_DBG_WARN("Doing directory extracting. Set cancel path");
g_array_remove_index(data_array, 0);
tmp_ret = ms_update_one_extract_item(handle, storage_id, storage_type, db_data, burst);
- if (tmp_ret == MS_MEDIA_ERR_NONE) {
+ if (tmp_ret == MS_MEDIA_ERR_NONE)
extract_count++;
- } else if (tmp_ret == MS_MEDIA_ERR_FILE_IO) {
+ else if (tmp_ret == MS_MEDIA_ERR_FILE_IO)
(*io_err_count)++;
- }
if (db_data) {
MS_SAFE_FREE(db_data->path);
}
}
- if (extract_count > 0) {
+ if (extract_count > 0)
ret = ms_query_do_update_list(handle);
- }
while (data_array->len != 0) {
db_data = NULL;
ret = msc_check_db_size(uid, extract_data->msg_type);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("NOT ENOUGH MEMORY");
- if (ret == MS_MEDIA_ERR_DB_FULL_FAIL) {
+ if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
ret = MS_MEDIA_ERR_NONE;
- }
+
goto NEXT;
}
int j = 0;
for (; j < len; j++) {
msg = g_async_queue_pop(temp_queue);
- if (msg) {
+ if (msg)
g_async_queue_push(storage_extract_queue, GINT_TO_POINTER(msg));
- }
}
g_async_queue_unref(temp_queue);
}
if (cur_extract_item && cur_extract_item->path) {
- if ((strcmp(cur_extract_item->path, cancel_path) == 0) && (pid == cur_extract_item->pid)) {
+ if ((strcmp(cur_extract_item->path, cancel_path) == 0) && (pid == cur_extract_item->pid))
ret = _msc_set_extract_item(&cancel_extract_item, cancel_path, pid);
- } else if ((pid == -1) && (strncmp(cur_extract_item->path, cancel_path, strlen(cancel_path)) == 0)) {
+ else if ((pid == -1) && (strncmp(cur_extract_item->path, cancel_path, strlen(cancel_path)) == 0))
ret = _msc_set_extract_item(&cancel_extract_item, cancel_path, pid);
- }
}
g_mutex_unlock(&extract_item_mutex);
is_recursive = (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) ? false : true;
/* folder validity set 0 under the start_path in folder table*/
- 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 (g_file_test(new_start_path, G_FILE_TEST_IS_DIR)) {
- if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("insert folder failed");
- }
MS_DBG_WARN("ms_insert_folder insert path11112222[%s]", new_start_path);
}
/*check poweroff status*/
ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
if (ret != MS_MEDIA_ERR_NONE) {
- if (is_recursive == true) {
+ if (is_recursive == true)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
- }
+
goto STOP_SCAN;
}
__msc_set_dir_scan_cur_path(current_path);
if (strncmp(current_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) != 0) {
- ret = ms_check_scan_ignore(current_path);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("%s is ignore", current_path);
- MS_SAFE_FREE(current_path);
- if (ret == MS_MEDIA_ERR_USB_UNMOUNTED) {
- goto STOP_SCAN;
- } else {
- ret = MS_MEDIA_ERR_NONE;
- }
+ ret = ms_check_scan_ignore(current_path);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("%s is ignore", current_path);
+ MS_SAFE_FREE(current_path);
+ if (ret == MS_MEDIA_ERR_USB_UNMOUNTED)
+ goto STOP_SCAN;
+ else
+ ret = MS_MEDIA_ERR_NONE;
- continue;
+ continue;
}
} else {
MS_DBG_ERR("[DATA DISC] PASS IGNORE");
ret = msc_check_db_size(uid, scan_type);
if (ret != MS_MEDIA_ERR_NONE) {
- if (ret == MS_MEDIA_ERR_DB_FULL_FAIL) {
+ if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
ret = MS_MEDIA_ERR_NONE;
- }
- if (is_recursive == true) {
+ if (is_recursive == true)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
- }
+
goto STOP_SCAN;
}
/*check poweroff status*/
ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
if (ret != MS_MEDIA_ERR_NONE) {
- if (is_recursive == true) {
+ if (is_recursive == true)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
- }
+
goto STOP_SCAN;
}
ret = msc_check_db_size(uid, scan_type);
if (ret != MS_MEDIA_ERR_NONE) {
//ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, ui);
- if (ret == MS_MEDIA_ERR_DB_FULL_FAIL) {
+ if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
ret = MS_MEDIA_ERR_NONE;
- }
+
goto STOP_SCAN;
}
#if 0
if (io_err_folder == MS_MAX_IO_ERR_COUNT) {
MS_DBG_ERR("REACH I/O MAX COUNT[%d]", io_err_folder);
- if (is_recursive == true) {
+ if (is_recursive == true)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
- }
+
goto STOP_SCAN;
}
#endif
/*check poweroff status*/
ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
if (ret != MS_MEDIA_ERR_NONE) {
- if (is_recursive == true) {
+ if (is_recursive == true)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
- }
+
goto STOP_SCAN;
}
ret = msc_check_db_size(uid, scan_type);
if (ret != MS_MEDIA_ERR_NONE) {
- if (ret == MS_MEDIA_ERR_DB_FULL_FAIL) {
+ if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
ret = MS_MEDIA_ERR_NONE;
- }
- if (is_recursive == true) {
+ if (is_recursive == true)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
- }
+
//ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, uid);
goto STOP_SCAN;
}
#if 0
if (io_err_folder == MS_MAX_IO_ERR_COUNT) {
MS_DBG_ERR("REACH I/O MAX COUNT[%d]", io_err_folder);
- if (is_recursive == true) {
+ if (is_recursive == true)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
- }
+
goto STOP_SCAN;
}
#endif
if (d->d_type == DT_UNKNOWN) {
struct stat st;
if (stat(path, &st) == 0) {
- if (S_ISREG(st.st_mode)) {
+ if (S_ISREG(st.st_mode))
d->d_type = DT_REG;
- } else if (S_ISDIR(st.st_mode)) {
+ else if (S_ISDIR(st.st_mode))
d->d_type = DT_DIR;
- }
}
}
ret = ms_scan_validate_item(handle, storage_id, path, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("failed to update db : %d", scan_type);
- if (ret == MS_MEDIA_ERR_FILE_IO) {
+ if (ret == MS_MEDIA_ERR_FILE_IO)
MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_folder++);
- }
+
bpos += d->d_reclen;
continue;
} else {
}
if (insert_count_for_partial >= MAX_SCAN_COUNT) {
- if (pid != 0) {
+ if (pid != 0)
msc_send_result_partial(ret, MS_MSG_SCANNER_PARTIAL, pid, (char*)start_path);
- }
+
insert_count_for_partial = 0;
}
if (set_count_for_partial >= MAX_SCAN_COUNT) {
- if (pid != 0) {
+ if (pid != 0)
msc_send_result_partial(ret, MS_MSG_SCANNER_PARTIAL, pid, (char*)start_path);
- }
+
set_count_for_partial = 0;
}
}
new_path = strdup(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 */
g_array_append_val(dir_array, start_path);
ms_insert_folder_end(handle, uid);
- if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("insert folder failed");
- }
scan_function = (scan_type == MS_MSG_STORAGE_ALL) ? ms_scan_item_batch : ms_scan_validate_item;
while (dir_array->len != 0) {
/*check poweroff status*/
ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
- }
ms_bacth_commit_disable(handle, TRUE, TRUE, uid);
ms_bacth_commit_enable(handle, TRUE, TRUE, MS_NOTI_SWITCH_OFF, pid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("%s is ignore", current_path);
MS_SAFE_FREE(current_path);
- if (ret == MS_MEDIA_ERR_USB_UNMOUNTED) {
+ if (ret == MS_MEDIA_ERR_USB_UNMOUNTED)
goto STOP_SCAN;
- } else {
+ else
ret = MS_MEDIA_ERR_NONE;
- }
continue;
}
ret = msc_check_db_size(uid, scan_type);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
- }
ms_get_folder_scan_status(handle, storage_id, current_path, (int *)&scan_status);
/*check poweroff status*/
ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
- }
ret = msc_check_db_size(uid, scan_type);
if (ret != MS_MEDIA_ERR_NONE) {
for (bpos = 0; bpos < nread;) {
/*check poweroff status*/
ret = __msc_check_stop_status(scan_type, storage_type, new_start_path, pid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
- }
ret = msc_check_db_size(uid, scan_type);
if (ret != MS_MEDIA_ERR_NONE) {
if (d->d_type == DT_UNKNOWN) {
struct stat st;
if (stat(path, &st) == 0) {
- if (S_ISREG(st.st_mode)) {
+ if (S_ISREG(st.st_mode))
d->d_type = DT_REG;
- } else if (S_ISDIR(st.st_mode)) {
+ else if (S_ISDIR(st.st_mode))
d->d_type = DT_DIR;
- }
}
}
ret = scan_function(handle, storage_id, path, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("failed to update db : %d", scan_type);
- if (ret == MS_MEDIA_ERR_FILE_IO) {
+ if (ret == MS_MEDIA_ERR_FILE_IO)
MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_storage++);
- }
+
bpos += d->d_reclen;
continue;
} else {
new_path = strdup(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");
- }
}
bpos += d->d_reclen;
MS_DBG_WARN("no wait folder scan callback");
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
break;
- }
} else {
__msc_set_dir_scan_cb(__msc_dir_scan_cb);
ret = __msc_get_null_scan_folder_list(handle, storage_id, NULL, dir_array);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
break;
- }
}
}
}
storage_len = strlen(storage_path);
folder_len = strlen(g_dir_scan_path);
- if (folder_len < storage_len) {
+ if (folder_len < storage_len)
ret = -1;
- } else {
+ else
ret = strncmp(storage_path, g_dir_scan_path, storage_len);
- }
MS_SAFE_FREE(storage_path);
g_mutex_unlock(&dir_scan_mutex2);
if (scan_type != MS_MSG_STORAGE_INVALID) {
MS_DBG_WARN("INSERT");
start_path = strndup(scan_data->msg, scan_data->msg_size);
- 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)
err = __msc_dir_scan_for_folder(handle, storage_id, start_path, storage_type, scan_type, scan_data->pid, scan_data->uid);
- } else if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL) {
+ else if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL)
err = __msc_dir_scan_for_storage(handle, storage_id, start_path, storage_type, scan_type, scan_data->pid, scan_data->uid);
- }
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("error : %d", err);
- }
+
} else if (scan_type == MS_MSG_STORAGE_INVALID) {
MS_DBG_WARN("INVALID");
msc_remove_extract_request(scan_data);
sleep(1);
ret = __msc_check_stop_status(scan_type, storage_type, scan_data->msg, scan_data->pid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
goto NEXT;
- }
- if ((++index) % 3 == 0) {
+ if ((++index) % 3 == 0)
msc_send_result_partial(ret, MS_MSG_SCANNER_PARTIAL, scan_data->pid, scan_data->msg);
- }
err = __msc_check_scan_same_path(scan_data->msg);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err != MS_MEDIA_ERR_NONE)
break;
- }
}
index = 0;
} else {
ms_get_folder_scan_status(handle, storage_id, scan_data->msg, (int*)&scan_status);
- if (scan_status == MS_DIR_SCAN_DONE) {
+ if (scan_status == MS_DIR_SCAN_DONE)
ms_set_folder_item_validity(handle, storage_id, scan_data->msg, MS_VALIND_V2, MS_RECURSIVE, uid);
- } else {
+ else
ms_set_folder_item_validity(handle, storage_id, scan_data->msg, MS_INVALID, MS_RECURSIVE, uid);
- }
}
} else {
MS_DBG_WARN("start non recursive dir scan!!");
sleep(1);
ret = __msc_check_stop_status(scan_type, storage_type, scan_data->msg, scan_data->pid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
goto NEXT;
- }
- if ((++index) % 3 == 0) {
+ if ((++index) % 3 == 0)
msc_send_result_partial(ret, MS_MSG_SCANNER_PARTIAL, scan_data->pid, scan_data->msg);
- }
ms_get_folder_scan_status(handle, storage_id, scan_data->msg, (int*)&scan_status);
if ((scan_status == MS_DIR_SCAN_DONE) || (scan_status == MS_DIR_SCAN_STOP)) {
MS_DBG_WARN("folder scan done, sent cb event path = [%s]", scan_data->msg);
__msc_call_dir_scan_cb();
- if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid)) {
+ if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid))
MS_DBG_ERR("deleting invalid items in storage failed");
- }
- if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("deleting invalid folders in storage failed");
- }
if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
MS_DBG_INFO("working normally");
if (scan_type == MS_MSG_STORAGE_ALL) {
/* Delete all data before full scanning */
- if (!ms_delete_invalid_items(handle, scan_data->storage_id, storage_type, uid)) {
+ if (!ms_delete_invalid_items(handle, scan_data->storage_id, storage_type, uid))
MS_DBG_ERR("ms_delete_invalid_items fails");
- }
}
ret = __msc_db_update(handle, scan_data->storage_id, scan_data);
/*call for bundle commit*/
- if (scan_type != MS_MSG_STORAGE_INVALID) {
+ if (scan_type != MS_MSG_STORAGE_INVALID)
ms_bacth_commit_disable(handle, TRUE, valid_status, uid);
- }
- if (scan_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE) {
+ if (scan_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE)
ms_delete_invalid_items(handle, scan_data->storage_id, storage_type, uid);
- }
/* send notification */
ms_send_dir_update_noti(handle, scan_data->storage_id, update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
{
MS_DBG_SLOG("path : %s", insert_data->msg);
- if (insert_data->pid == POWEROFF) {
+ if (insert_data->pid == POWEROFF)
g_array_prepend_val(register_array, insert_data);
- } else if (insert_data->msg_type == MS_MSG_BURSTSHOT_INSERT) {
+ else if (insert_data->msg_type == MS_MSG_BURSTSHOT_INSERT)
g_array_prepend_val(register_array, insert_data);
- } else {
+ else
g_array_append_val(register_array, insert_data);
- }
+
}
static int __msc_clear_file_list(GArray *path_array)
if (cur_scan_item != NULL && cur_scan_item->path != NULL) {
MS_DBG_WARN("cur_scan_item->path[%s], cur_scan_item->pid[%d]", cur_scan_item->path, cur_scan_item->pid);
MS_DBG_WARN("cancel_path[%s], pid[%d]", cancel_path, pid);
- if ((strcmp(cur_scan_item->path, cancel_path) == 0) && (pid == cur_scan_item->pid)) {
+ if ((strcmp(cur_scan_item->path, cancel_path) == 0) && (pid == cur_scan_item->pid))
ret = _msc_set_scan_item(&cancel_scan_item, cancel_path, pid);
- }
+
} else {
MS_DBG_ERR("cur_scan_item == NULL || cur_scan_item->path == NULL");
}
int j = 0;
for (; j < len; j++) {
msg = g_async_queue_pop(temp_scan_queue);
- if (msg) {
+ if (msg)
g_async_queue_push(scan_queue2, GINT_TO_POINTER(msg));
- }
}
g_async_queue_unref(temp_scan_queue);
MS_DBG_WARN("end update scan_queue2");
int j = 0;
for (; j < len; j++) {
msg = g_async_queue_pop(temp_extract_queue);
- if (msg) {
+ if (msg)
g_async_queue_push(folder_extract_queue, GINT_TO_POINTER(msg));
- }
}
g_async_queue_unref(temp_extract_queue);
MS_DBG_WARN("end update folder_extract_queue");
if (g_main_loop_is_running(scanner_mainloop2)) g_main_loop_quit(scanner_mainloop2);
- if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 1)) {
+ if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 1))
MS_DBG_ERR("set power off status to 1 failed");
- }
MS_DBG_ERR("POWER OFF END");
}
ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_ACCESS);
}
- if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status)) {
+ if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status))
MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
- }
- if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED))
msc_set_blocked_path(storage_path);
- }
if (g_directory_scan_processing2 != 0) {
MS_DBG_WARN("Doing directory scanning. Set cancel path");
msc_set_cancel_scan_item(storage_path, -1);
}
- if (!(g_async_queue_length(storage_extract_queue) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+ if (!(g_async_queue_length(storage_extract_queue) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED))
msc_set_extract_blocked_path(storage_path);
- }
if (g_directory_extract_processing == true) {
MS_DBG_WARN("Doing directory extracting. Set cancel path");
/* 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) {
return MS_MEDIA_ERR_FILE_OPEN_FAIL;
}
- if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 0)) {
+ if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 0))
MS_DBG_ERR("set power off status to 0 failed");
- }
context = g_main_loop_get_context(scanner_mainloop2);
ms_unload_functions();
EXIT:
- if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 0)) {
+ if (!ms_config_set_int(MSC_VCONF_KEY_SCANNER_POWEROFF_STATUS, 0))
MS_DBG_ERR("set power off status to 0 failed");
- }
MS_DBG_INFO("Scanner-V2 is shutting down");
return 0;
int msc_send_power_off_request(void);
int msc_remove_dir_scan_request(ms_comm_msg_s *recv_msg);
-#endif /*_MEDIA_SCANNER_SCAN_H_*/
\ No newline at end of file
+#endif /*_MEDIA_SCANNER_SCAN_H_*/
while (dir_array->len != 0) {
ret = __msc_check_stop_status(storage_type);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
- }
current_path = g_array_index(dir_array , char*, 0);
g_array_remove_index(dir_array, 0);
dir = g_dir_open(current_path, 0, &error);
if (error == NULL && dir != NULL) {
- 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");
- }
+
while ((name = g_dir_read_name(dir))) {
ret = __msc_check_stop_status(storage_type);
if (ret != MS_MEDIA_ERR_NONE) {
continue;
}
} else {
- 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");
- }
}
}
}
else
err = __msc_dir_scan(handle, storage_id, start_path, storage_type, true, true, scan_data->uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("error : %d", err);
- }
+
} else {
MS_DBG_INFO("INVALID");
err = ms_validaty_change_all_items(handle, storage_id, storage_type, false, scan_data->uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("error : %d", err);
- }
ms_set_folder_validity(handle, storage_id, start_path, 0, TRUE, scan_data->uid);
ms_bacth_commit_disable(handle, TRUE, TRUE, scan_data->uid);
- if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid)) {
+ if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid))
MS_DBG_ERR("deleting invalid items in storage failed");
- }
- if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("deleting invalid folders in storage failed");
- }
if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
MS_DBG_INFO("working normally");
if (scan_type == MS_MSG_STORAGE_ALL) {
/* Delete all data before full scanning */
- if (!ms_delete_all_items(handle, storage_id, storage_type, scan_data->uid)) {
+ if (!ms_delete_all_items(handle, storage_id, storage_type, scan_data->uid))
MS_DBG_ERR("msc_delete_all_record fails");
- }
+
} else if (scan_type == MS_MSG_STORAGE_PARTIAL) {
ms_validaty_change_all_items(handle, storage_id, storage_type, false, scan_data->uid);
}
ms_bacth_commit_disable(handle, TRUE, valid_status, scan_data->uid);
if (scan_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE) {
- if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid)) {
+ if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid))
MS_DBG_ERR("deleting invalid items in storage failed");
- }
- if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("deleting invalid folders in storage failed");
- }
}
/* send notification */
ms_send_dir_update_noti(handle, storage_id, update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
- if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
+ if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP)
ms_set_db_status(MS_DB_STOPPED, storage_type);
- } else {
+ else
ms_set_db_status(MS_DB_UPDATED, storage_type);
- }
NEXT:
MS_SAFE_FREE(update_path);
{
MS_DBG_SLOG("path : %s", insert_data->msg);
- if (insert_data->pid == POWEROFF) {
+ if (insert_data->pid == POWEROFF)
g_array_prepend_val(register_array, insert_data);
- } else if (insert_data->msg_type == MS_MSG_BURSTSHOT_INSERT) {
+ else if (insert_data->msg_type == MS_MSG_BURSTSHOT_INSERT)
g_array_prepend_val(register_array, insert_data);
- } else {
+ else
g_array_append_val(register_array, insert_data);
- }
}
static int __msc_clear_file_list(GArray *path_array)
while (dir_array->len != 0) {
ret = __msc_check_stop_status(storage_type);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
- }
current_path = g_array_index(dir_array , char*, 0);
g_array_remove_index(dir_array, 0);
if (error == NULL && dir != NULL) {
while ((name = g_dir_read_name(dir))) {
ret = __msc_check_stop_status(storage_type);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
- }
if (name[0] == '.')
continue;
/*create new queue to compare request*/
msg = g_async_queue_pop(scan_queue);
if ((strcmp(msg->msg, cancel_path) == 0) && (pid == msg->pid)) {
+ MS_DBG("Find request. Remove it");
MS_SAFE_FREE(msg);
} else {
g_async_queue_push(temp_scan_queue, GINT_TO_POINTER(msg));
/* Create pipe */
if (g_file_test(MS_SCANNER_FIFO_PATH_REQ, G_FILE_TEST_EXISTS)) {
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);
-/*\r
- * Media Server\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#ifndef _MEDIA_SERVER_DB_MANAGER_H__\r
-#define _MEDIA_SERVER_DB_MANAGER_H__\r
-\r
-#include "media-common-types.h"\r
-\r
-int ms_reset_mediadb(uid_t uid);\r
-int ms_check_mediadb(uid_t uid, bool *is_reset);\r
-int ms_check_corrupt_mediadb(void);\r
-\r
-#endif\r
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _MEDIA_SERVER_DB_MANAGER_H__
+#define _MEDIA_SERVER_DB_MANAGER_H__
+
+#include "media-common-types.h"
+
+int ms_reset_mediadb(uid_t uid);
+int ms_check_mediadb(uid_t uid, bool *is_reset);
+int ms_check_corrupt_mediadb(void);
+
+#endif
#endif
int ms_check_mounted_storage(uid_t uid);
-#endif
\ No newline at end of file
+#endif
int ms_get_scanner_pid(void);
void ms_cleanup_scanner(void);
-#endif /*_MEDIA_SERVER_SCANNER_H*/
\ No newline at end of file
+#endif /*_MEDIA_SERVER_SCANNER_H*/
-/*\r
- * Media Server\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#include <errno.h>\r
-#include <sys/stat.h>\r
-#include <sqlite3.h>\r
-\r
-#include "media-util.h"\r
-#include "media-common-db-svc.h"\r
-#include "media-common-system.h"\r
-#include "media-common-utils.h"\r
-#include "media-server-ipc.h"\r
-#include "media-server-dbg.h"\r
-#include "media-server-scanner.h"\r
-#include "media-server-thumb.h"\r
-#include "media-server-db-manage.h"\r
-\r
-int ms_reset_mediadb(uid_t uid)\r
-{\r
- MS_DBG_ERR("[MEDIA DB RESET START]");\r
- int ret = MS_MEDIA_ERR_NONE;\r
- char *command = "/bin/cp";\r
- char *dummy_path = MS_DUMMY_MEDIA_DB_PATH;\r
- char *db_path = NULL;\r
-\r
- ret = ms_user_get_media_db_path(uid, &db_path);\r
- if ((ret == MS_MEDIA_ERR_NONE) && (db_path != NULL)) {\r
- char command_line[MS_FILE_PATH_LEN_MAX] = {0,};\r
- snprintf(command_line, sizeof(command_line), "%s %s %s", command, dummy_path, db_path);\r
-\r
- MS_DBG_ERR("[RESET COMMAND %s]", command_line);\r
- WEXITSTATUS(system(command_line));\r
- }\r
-\r
- MS_SAFE_FREE(db_path);\r
-\r
- MS_DBG_ERR("[MEDIA DB RESET END]");\r
-\r
- return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
-static int __ms_remake_mediadb(uid_t uid)\r
-{\r
- int err = MS_MEDIA_ERR_NONE;\r
- void **handle = NULL;\r
-\r
- MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");\r
-\r
- /*write read schema*/\r
- /*load functions from plusin(s)*/\r
- err = ms_load_functions();\r
- if (err != MS_MEDIA_ERR_NONE) {\r
- MS_DBG_ERR("function load failed [%d]", err);\r
- return err;\r
- }\r
-#ifdef _USE_TVPD_MODE\r
- ms_config_set_int(MS_DB_RESET, 1);\r
-#endif\r
- ms_reset_mediadb(uid);\r
-\r
- ms_connect_db(&handle, uid);\r
-\r
- MS_DBG_WARN("START WRITE SCHEMA");\r
- if (ms_check_db_upgrade(handle, uid) != MS_MEDIA_ERR_NONE) {\r
- MS_DBG_ERR("ms_check_db_upgrade fail");\r
- }\r
- MS_DBG_WARN("END WRITE SCHEMA");\r
-\r
- /*disconnect form media db*/\r
- if (handle) ms_disconnect_db(&handle);\r
-\r
- /*unload functions*/\r
- ms_unload_functions();\r
-\r
-#ifdef _USE_TVPD_MODE\r
- ms_config_set_int(MS_DB_RESET, 0);\r
-#endif\r
- return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
-int ms_check_mediadb(uid_t uid, bool *is_reset)\r
-{\r
- double db_size = 0.0;\r
-\r
- ms_check_size_mediadb(uid, &db_size);\r
-\r
- MS_DBG_WARN("[DB SIZE : %lf] [LIMIT1 : %lf] [LIMIT2 : %lf]", db_size, MEDIA_DB_SIZE_LIMIT_1, MEDIA_DB_SIZE_LIMIT_2);\r
- if (db_size > MEDIA_DB_SIZE_LIMIT_2) {\r
- MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");\r
- MS_DBG_ERR("[DB SIZE : %lf] [LIMIT1 : %lf] [LIMIT2 : %lf]", db_size, MEDIA_DB_SIZE_LIMIT_1, MEDIA_DB_SIZE_LIMIT_2);\r
- __ms_remake_mediadb(uid);\r
- *is_reset = TRUE;\r
- }\r
-\r
- return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
-int ms_check_corrupt_mediadb(void)\r
-{\r
- MediaDBHandle *db_handle = NULL;\r
- uid_t uid = MEDIA_DEFAULT_UID;\r
-\r
- ms_sys_get_uid(&uid);\r
-\r
- if (media_db_connect(&db_handle, uid, TRUE) != MS_MEDIA_ERR_NONE) {\r
- MS_DBG_ERR("Failed to connect DB");\r
- return MS_MEDIA_ERR_DB_CONNECT_FAIL;\r
- }\r
-\r
- /* Disconnect DB*/\r
- media_db_disconnect(db_handle);\r
-\r
- return MS_MEDIA_ERR_NONE;\r
-}\r
-\r
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <sqlite3.h>
+
+#include "media-util.h"
+#include "media-common-db-svc.h"
+#include "media-common-system.h"
+#include "media-common-utils.h"
+#include "media-server-ipc.h"
+#include "media-server-dbg.h"
+#include "media-server-scanner.h"
+#include "media-server-thumb.h"
+#include "media-server-db-manage.h"
+
+int ms_reset_mediadb(uid_t uid)
+{
+ MS_DBG_ERR("[MEDIA DB RESET START]");
+ int ret = MS_MEDIA_ERR_NONE;
+ char *command = "/bin/cp";
+ char *dummy_path = MS_DUMMY_MEDIA_DB_PATH;
+ char *db_path = NULL;
+
+ ret = ms_user_get_media_db_path(uid, &db_path);
+ if ((ret == MS_MEDIA_ERR_NONE) && (db_path != NULL)) {
+ char command_line[MS_FILE_PATH_LEN_MAX] = {0,};
+ snprintf(command_line, sizeof(command_line), "%s %s %s", command, dummy_path, db_path);
+
+ MS_DBG_ERR("[RESET COMMAND %s]", command_line);
+ WEXITSTATUS(system(command_line));
+ }
+
+ MS_SAFE_FREE(db_path);
+
+ MS_DBG_ERR("[MEDIA DB RESET END]");
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+static int __ms_remake_mediadb(uid_t uid)
+{
+ int err = MS_MEDIA_ERR_NONE;
+ void **handle = NULL;
+
+ MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");
+
+ /*write read schema*/
+ /*load functions from plusin(s)*/
+ err = ms_load_functions();
+ if (err != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("function load failed [%d]", err);
+ return err;
+ }
+#ifdef _USE_TVPD_MODE
+ ms_config_set_int(MS_DB_RESET, 1);
+#endif
+ ms_reset_mediadb(uid);
+
+ ms_connect_db(&handle, uid);
+
+ MS_DBG_WARN("START WRITE SCHEMA");
+ if (ms_check_db_upgrade(handle, uid) != MS_MEDIA_ERR_NONE)
+ MS_DBG_ERR("ms_check_db_upgrade fail");
+
+ MS_DBG_WARN("END WRITE SCHEMA");
+
+ /*disconnect form media db*/
+ if (handle) ms_disconnect_db(&handle);
+
+ /*unload functions*/
+ ms_unload_functions();
+
+#ifdef _USE_TVPD_MODE
+ ms_config_set_int(MS_DB_RESET, 0);
+#endif
+ return MS_MEDIA_ERR_NONE;
+}
+
+int ms_check_mediadb(uid_t uid, bool *is_reset)
+{
+ double db_size = 0.0;
+
+ ms_check_size_mediadb(uid, &db_size);
+
+ MS_DBG_WARN("[DB SIZE : %lf] [LIMIT1 : %lf] [LIMIT2 : %lf]", db_size, MEDIA_DB_SIZE_LIMIT_1, MEDIA_DB_SIZE_LIMIT_2);
+ if (db_size > MEDIA_DB_SIZE_LIMIT_2) {
+ MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");
+ MS_DBG_ERR("[DB SIZE : %lf] [LIMIT1 : %lf] [LIMIT2 : %lf]", db_size, MEDIA_DB_SIZE_LIMIT_1, MEDIA_DB_SIZE_LIMIT_2);
+ __ms_remake_mediadb(uid);
+ *is_reset = TRUE;
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int ms_check_corrupt_mediadb(void)
+{
+ MediaDBHandle *db_handle = NULL;
+ uid_t uid = MEDIA_DEFAULT_UID;
+
+ ms_sys_get_uid(&uid);
+
+ if (media_db_connect(&db_handle, uid, TRUE) != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("Failed to connect DB");
+ return MS_MEDIA_ERR_DB_CONNECT_FAIL;
+ }
+
+ /* Disconnect DB*/
+ media_db_disconnect(db_handle);
+
+ return MS_MEDIA_ERR_NONE;
+}
+
scan_type = MS_SCAN_PART;
ms_set_storage_validity(handle, mount_uuid, 1, uid);
- if (ms_set_storage_scan_status(handle, uuid, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_set_storage_scan_status(handle, uuid, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("ms_set_storage_scan_status failed");
- }
MS_DBG_WARN("init storage data in DB");
/* update storage_id table set validity=0 first */
int ret = MS_MEDIA_ERR_NONE;
ret = ms_get_mmc_info(handle, storage_name, storage_path, validity, info_exist);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("[No-Error] ms_get_mmc_info failed. Maybe storage info not in media db [%d]", ret);
- }
return ret;
}
ms_sys_get_uid(&uid);
ret = ms_delete_storage(handle, MMC_STORAGE_ID, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("ms_delete_storage failed [%d]", ret);
- }
ret = ms_insert_storage(handle, MMC_STORAGE_ID, new_storage_name, new_storage_path, uid);
if (ret != MS_MEDIA_ERR_NONE) {
}
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 {
/* there is no information of this storage in Media DB */
ret = ms_insert_storage(handle, storage_id, NULL, mount_path, uid);
ms_set_storage_validity(handle, device_id, 0, uid);
/* folder validity set 0 under the start_path in folder table*/
- if (ms_set_folder_validity(handle, device_id, mount_path, MS_INVALID, TRUE, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_set_folder_validity(handle, device_id, mount_path, MS_INVALID, TRUE, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("set_folder_validity failed");
- }
if (ms_get_scanner_status()) {
/*If the media scanner is running, the removed USB can be queueing in the job list.*/
} else if (!strcmp(action, "blocked")) { /*unmount->blocked stop accessing usb in time*/
MS_DBG_WARN("USB blocked, mountpath : %s", mount_path);
ms_check_mediadb(uid, &is_reset);
- if (!is_reset) {
+ if (!is_reset)
__ms_usb_remove_event(mount_path);
- }
}
free_usb_device_h(usb_device);
- if (is_reset) {
+ if (is_reset)
ms_check_mounted_storage(uid);
- }
+
MS_DBG_WARN("usb_event_callback END[%s]", action);
}
err = usb_device_get_device_list(USB_MASS_STORAGE, &list);
if (err == 0) {
- if (*added_list == NULL) {
+ if (*added_list == NULL)
*added_list = g_array_new(FALSE, FALSE, sizeof(char*));
- }
count = usb_device_list_get_count(list);
if (count > 0) {
#else
ret = __ms_check_mounted_storage_list(&added_list);
#endif
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("__ms_check_mounted_storage_list failed");
- }
if (added_list != NULL) {
count = added_list->len;
/* request to update media db */
ret = ms_insert_folder(handle, storage_id, mounted_path, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("error : ms_insert_folder failed");
- }
ms_send_storage_otg_scan_request(mounted_path, storage_id, scan_type, uid);
MS_SAFE_FREE(storage_id);
uid_t uid = MEDIA_DEFAULT_UID;
if (power_off == FALSE) {
- if (!ms_config_get_int(SMARTHUB_RESET_VCONF, &status)) {
+ if (!ms_config_get_int(SMARTHUB_RESET_VCONF, &status))
MS_DBG_ERR("Get VCONFKEY_SYSMAN_MMC_STATUS failed.");
- }
MS_DBG_ERR("CURRENT STATUS OF SMARTHUB_RESET_VCONF[%d]", status);
/*Quit Thumbnail Thread*/
GMainLoop *thumb_mainloop = ms_get_thumb_thread_mainloop();
- if (thumb_mainloop && g_main_is_running(thumb_mainloop)) {
+ if (thumb_mainloop && g_main_is_running(thumb_mainloop))
g_main_loop_quit(thumb_mainloop);
- }
/*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);
- }
__ms_remove_request_receiver(channel);
g_io_channel_unref(channel);
if (fd > 0) {
- if (close(fd) < 0) {
+ if (close(fd) < 0)
MS_DBG_STRERROR("CLOSE ERROR");
- }
}
}
#endif
sigset.sa_flags = SA_RESTART |SA_NODEFER;
sigset.sa_handler = _ms_signal_handler;
- if (sigaction(SIGCHLD, &sigset, NULL) < 0) {
+ if (sigaction(SIGCHLD, &sigset, NULL) < 0)
MS_DBG_STRERROR("sigaction failed");
- }
signal(SIGPIPE, SIG_IGN);
}
MS_DBG_ERR("ms_set_all_storage_validity fail");
#ifdef _USE_SENIOR_MODE
- if (ms_is_support_senior_mode()) {
+ if (ms_is_support_senior_mode())
ms_send_storage_scan_request_senior_mode(db_handle);
- }
#endif
ms_disconnect_db(&db_handle);
int status;
if (ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status)) {
- if (status == VCONFKEY_FILEMANAGER_DB_UPDATING) {
+ if (status == VCONFKEY_FILEMANAGER_DB_UPDATING)
return MS_DB_UPDATING;
- }
}
#ifdef _USE_TVPD_MODE
if (ms_config_get_int(VCONFKEY_PRIVATE_EXTRACTSTATUS, &status)) {
MS_DBG("extract status %d", status);
- if (status == MS_DB_UPDATING) {
+ if (status == MS_DB_UPDATING)
return MS_DB_UPDATING;
- }
}
#endif
return MS_DB_UPDATED;
/* stop media scanner */
if (child_pid > 0) {
- if (kill(child_pid, SIGKILL) < 0) {
+ if (kill(child_pid, SIGKILL) < 0)
MS_DBG_ERR("kill failed[%d]", child_pid);
- }
+
MS_DBG_INFO("KILL SCANNER");
} else {
MS_DBG_ERR("SCANNER IS ALREADY DEAD");
if (g_file_test(MS_SCANNER_FIFO_PATH_RES, G_FILE_TEST_EXISTS)) {
err = unlink(MS_SCANNER_FIFO_PATH_RES);
- if (err != 0) {
+ if (err != 0)
MS_DBG_STRERROR("unlink failed");
- }
}
err = mkfifo(MS_SCANNER_FIFO_PATH_RES, MS_SCANNER_FIFO_MODE);
ms_connect_db(&handle, uid);
MS_DBG_WARN("START WRITE SCHEMA");
- if (ms_check_db_upgrade(handle, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_check_db_upgrade(handle, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("ms_check_db_upgrade fail");
- }
+
MS_DBG_WARN("END WRITE SCHEMA");
/*disconnect form media db*/
/* get client socket fd */
ret = ms_ipc_accept_client_tcp(sockfd, &client_sock);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
return TRUE;
- }
memset(&creds, 0, sizeof(creds));
err = ms_scanner_start();
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 [%d]", err);
- }
} else {
MS_DBG_ERR("Scanner starting failed [%d]", err);
res = err;
SAFE_STRLCPY(scan_msg.msg, root_path, sizeof(scan_msg.msg));
}
- if (storage_id != NULL) {
+ if (storage_id != NULL)
SAFE_STRLCPY(scan_msg.storage_id, storage_id, sizeof(scan_msg.storage_id));
- }
scan_msg.uid = uid;
/* request to update media db */
ret = ms_insert_folder(handle, storage_id, path, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("##[senior mode]error : ms_insert_folder failed");
- }
ms_send_storage_otg_scan_request(path, storage_id, scan_type, uid);
MS_SAFE_FREE(storage_id);
/* get client socket fd */
ret = ms_ipc_accept_client_tcp(sock, &client_sock);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE)
return TRUE;
- }
memset(&creds, 0, sizeof(creds));
media_db_disconnect(db_handle);
ERROR:
- if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg)) {
+ if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg))
MS_DBG_STRERROR("send failed");
- } else {
+ else
MS_DBG("Sent successfully");
- }
- if (close(client_sock) < 0) {
+ if (close(client_sock) < 0)
MS_DBG_STRERROR("close failed");
- }
return TRUE;
}
sql_query = strndup(recv_msg.msg, recv_msg.msg_size);
if (sql_query != NULL) {
- if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_START) {
+ 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 {
-
- }
MS_SAFE_FREE(sql_query);
send_msg = ret;
- if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg)) {
+ if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg))
MS_DBG_STRERROR("send failed");
- }
if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_END) {
MS_DBG_WARN("Batch job is successfull!client sockfd [%d]", client_sock);
}
}
- if (close(client_sock) < 0) {
+ if (close(client_sock) < 0)
MS_DBG_STRERROR("close failed");
- }
/* Disconnect DB*/
media_db_disconnect(db_handle);
ERROR:
/* send error to client */
- if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg)) {
+ if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg))
MS_DBG_STRERROR("send failed");
- } else {
+ else
MS_DBG("Sent successfully");
- }
- if (close(client_sock) < 0) {
+ if (close(client_sock) < 0)
MS_DBG_STRERROR("close failed");
- }
/* Disconnect DB*/
media_db_disconnect(db_handle);
/* send error to clinet*/
send_msg = res;
- if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg)) {
+ if (write(client_sock, &send_msg, sizeof(send_msg)) != sizeof(send_msg))
MS_DBG_STRERROR("send failed");
- } else {
+ else
MS_DBG("Sent successfully");
- }
- if (close(client_sock) < 0) {
+ if (close(client_sock) < 0)
MS_DBG_STRERROR("close failed");
- }
}
return TRUE;
MS_DBG_WARN("ms_req_num-- [%d]", ms_req_num);
}
- if (pid != 0) {
+ if (pid != 0)
__ms_send_result_to_client(pid, &recv_msg);
- } else {
+ else
MS_DBG_SLOG("This request is from media-server");
- }
} else {
MS_DBG_ERR("This result message is wrong : %d", recv_msg.msg_type);
}
}
while (remain_size > 0) {
- if (remain_size < MS_SOCK_BLOCK_SIZE) {
+ if (remain_size < MS_SOCK_BLOCK_SIZE)
block_size = remain_size;
- }
+
if ((recv_msg_len = recv(sock, block_buf, block_size, 0)) < 0) {
MS_DBG_STRERROR("recv failed");
MS_SAFE_FREE(buf);
}
//MS_DBG("Receive : %d(%d)", recv_msg.msg_type, recv_msg_size);
- if (recv_msg.msg_type == MS_MSG_THUMB_SERVER_READY) {
+ if (recv_msg.msg_type == MS_MSG_THUMB_SERVER_READY)
MS_DBG("Thumbnail server is ready");
- }
close(sockfd);
return TRUE;
unsigned char *buf = NULL;
_ms_thumb_set_buffer(&res_msg, &buf, &buf_size);
- if (send(client_sock, buf, buf_size, 0) != buf_size) {
+ if (send(client_sock, buf, buf_size, 0) != buf_size)
MS_DBG_STRERROR("sendto failed");
- } else {
+ else
MS_DBG("Sent Refuse msg from %s", recv_msg->org_path);
- }
close(client_sock);
_ms_thumb_set_buffer(&res_msg, &buf, &buf_size);
while (buf_size > 0) {
- if (buf_size < MS_SOCK_BLOCK_SIZE) {
+ if (buf_size < MS_SOCK_BLOCK_SIZE)
block_size = buf_size;
- }
- if (send(client_sock, buf+sending_block, block_size, 0) != block_size) {
+
+ if (send(client_sock, buf+sending_block, block_size, 0) != block_size)
MS_DBG_STRERROR("sendto failed");
- }
+
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);
- }
close(client_sock);
MS_SAFE_FREE(buf);
int buf_size = 0;
_ms_thumb_set_buffer(&res_msg, &buf, &buf_size);
- if (send(client_sock, buf, buf_size, 0) != buf_size) {
+ if (send(client_sock, buf, buf_size, 0) != buf_size)
MS_DBG_STRERROR("sendto failed");
- } else {
+ else
MS_DBG("Sent Refuse msg from %s", recv_msg->org_path);
- }
close(client_sock);
MS_SAFE_FREE(buf);
context = g_main_context_new();
- if (context == NULL) {
+ if (context == NULL)
MS_DBG_ERR("g_main_context_new failed");
- } else {
+ else
MS_DBG("g_main_context_new success");
- }
g_thumb_agent_loop = g_main_loop_new(context, FALSE);
g_main_context_push_thread_default(context);