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);
goto ERROR;
}
- if (strcmp(mount_path, storage_path)) {
- /* update storage path */
+ /* update storage path */
+ if (strcmp(mount_path, storage_path))
ret = ms_update_storage(handle, mount_uuid, mount_path, uid);
- }
+
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) {
ms_disconnect_db(&handle);
ms_unload_functions();
- }
+ }
return ret;
}
MS_DBG("Current MMC info = [%s]", cid);
if (storage_name != NULL) {
- if (strcmp(storage_name, cid) == 0) {
+ if (strcmp(storage_name, cid) == 0)
scan_type = MS_SCAN_PART;
- }
}
if (scan_type == MS_SCAN_PART)
return MS_MEDIA_ERR_INTERNAL;
}
- if (mount_path == NULL) {
+ if (mount_path == NULL)
ret = ms_check_storage(handle, MMC_STORAGE_ID, NULL, &storage_path, &validity, uid);
- } else {
+ else
storage_path = strdup(mount_path);
- }
if (storage_path != NULL) {
MS_DBG_WARN("mmc_path[%s]", storage_path);
}
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 {
/* update storage_id table set validity=0 first */
ms_validaty_change_all_items(handle, storage_id, MS_STORAGE_EXTERNAL_USB, false, uid);
- //ms_set_folder_validity(handle, storage_id, mount_path, MS_INVALID, TRUE);
+ /*ms_set_folder_validity(handle, storage_id, mount_path, MS_INVALID, TRUE); */
/* update folder table set scan_status=0 first */
ms_set_folder_scan_status(handle, storage_id, NULL, MS_DIR_SCAN_NONE, uid);
ms_connect_db(&handle, uid);
- while(1) {
+ while (1) {
memset(device_id, 0x0, sizeof(device_id));
ret = ms_get_storage_id(handle, mount_path, device_id, 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");
}
void ms_device_block_changed_cb(usb_device_h usb_device, char *action, void *user_data)
{
- char *mount_path = NULL;
+ char *mount_path = NULL;
bool is_reset = FALSE;
uid_t uid = MEDIA_DEFAULT_UID;
count = usb_device_list_get_count(list);
if (count > 0) {
int i = 0;
- for(i = 0; i < count; i++) {
- if(i == 0) {
+ for (i = 0; i < count; i++) {
+ if (i == 0) {
if (0 == usb_device_list_get_first(list, &device) && device != NULL) {
mount_path = usb_device_get_mountpath(device);
if (mount_path != NULL) {
MS_DBG_WARN("mount_path [%s]", mount_path);
storage_path = strdup(mount_path);
- g_array_append_val (*added_list, storage_path);
+ g_array_append_val(*added_list, storage_path);
}
} else {
MS_DBG_ERR(" FAILED TO usb_device_list_get_first \n");
}
} else {
- if(0 == usb_device_list_get_next(list, &device) && device != NULL ) {
+ if (0 == usb_device_list_get_next(list, &device) && device != NULL) {
mount_path = usb_device_get_mountpath(device);
if (mount_path != NULL) {
MS_DBG_WARN("mount_path [%s]", mount_path);
storage_path = strdup(mount_path);
- g_array_append_val (*added_list, storage_path);
+ g_array_append_val(*added_list, storage_path);
}
} else {
MS_DBG_ERR(" FAILED TO usb_device_list_get_next \n");
int i = 0;
GArray *added_list = NULL;
char *mounted_path = NULL;
- //char *id = NULL;
char *storage_id = NULL;
ms_dir_scan_type_t scan_type = MS_SCAN_ALL;
void **handle = NULL;
if (added_list != NULL) {
count = added_list->len;
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i++) {
mounted_path = g_array_index(added_list, char *, i);
/* read deive information */
ret = ms_read_device_info(mounted_path, &storage_id);
if (ret == 0) {
if (validity == 1) {
MS_DBG_ERR("This storage is already updated.");
- MS_SAFE_FREE (db_storage_path);
+ MS_SAFE_FREE(db_storage_path);
continue;
}
MS_SAFE_FREE(storage_id);
}
- for (i = 0; i < count; i ++) {
+ for (i = 0; i < count; i++) {
mounted_path = g_array_index(added_list, char*, 0);
MS_SAFE_FREE(mounted_path);
g_array_remove_index(added_list, 0);
int value = 0;
uid_t uid = MEDIA_DEFAULT_UID;
- if(!ms_config_get_int(MS_VCONF_KEY_RESET_STATUS, &value))
- {
+ if (!ms_config_get_int(MS_VCONF_KEY_RESET_STATUS, &value)) {
MS_DBG_ERR("get db/media_server/reset_status failed\n");
return false;
}
MS_DBG_WARN("db/media_server/reset_status is [%d]\n", value);
- if(value == 1 || value == 2)
- {
+ if (value == 1 || value == 2) {
MS_DBG_WARN("POWER_OFF_REASON_FACTORY_RESET or SERVICE RESET");
ms_reset_mediadb(uid);
- if(!ms_config_set_int(MS_VCONF_KEY_RESET_STATUS, 0))
- {
+ if (!ms_config_set_int(MS_VCONF_KEY_RESET_STATUS, 0)) {
MS_DBG_ERR("set db/media_server/reset_status failed\n");
return false;
}
smarthub_reset = TRUE;
- if (status == 0 ) {
+ if (status == 0) {
scanner_pid = ms_get_scanner_pid();
thumb_pid = ms_thumb_get_server_pid();
/*Kill the running child process*/
- if (scanner_pid > 0 ) {
+ if (scanner_pid > 0) {
if (kill(scanner_pid, SIGKILL) < 0) {
MS_DBG_ERR("kill failed");
MS_DBG_STRERROR();
}
MS_DBG("KILL SCANNER");
- if (thumb_pid > 0 ) {
+ if (thumb_pid > 0) {
if (kill(thumb_pid, SIGKILL) < 0) {
MS_DBG_ERR("kill failed");
MS_DBG_STRERROR();
char *valid_type = "data";
ms_dir_scan_type_t scan_type = MS_SCAN_PART;
uid_t uid = MEDIA_DEFAULT_UID;
- char mnt_path[11] = {0,};
+ char mnt_path[11] = { 0, };
char *storage_path = NULL;
void **handle = NULL;
strncpy(mnt_path, disc_path, sizeof(mnt_path)-1);
if (disc_state == 1) {
- MS_DBG_WARN("[DISC INSERTED][%s]",disc_type);
-
+ MS_DBG_WARN("[DISC INSERTED][%s]", disc_type);
MS_DBG_WARN("MOUNT PATH [%s]", mnt_path);
/* update storage information into media DB */
}
if (strcmp(disc_type, valid_type) == 0) {
- MS_DBG_WARN("[DISC INSERTED][%s]",disc_type);
+ MS_DBG_WARN("[DISC INSERTED][%s]", disc_type);
MS_DBG_WARN("MOUNT PATH [%s]", mnt_path);
/* check mount path */
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
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));
scanner_cleaned = true;
if (path[len -1] == '/')
path[len -1] = '\0';
owner_data->req_path = strdup(path);
- // MS_DBG("the length of array : %d", owner_list->len);
- // MS_DBG("pid : %d", owner_data->pid);
- // MS_DBG("client_addr : %p", owner_data->client_addr);
-
owner_data->index = -1;
g_array_append_val(owner_list, owner_data);
}
ms_req_owner_data *data = NULL;
ms_comm_msg_s send_msg = {0,};
- if(owner_list != NULL) {
+ if (owner_list != NULL) {
len = owner_list->len;
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*, 0);
- g_array_remove_index (owner_list, 0);
+ g_array_remove_index(owner_list, 0);
MS_DBG("%d", data->pid);
MS_DBG("%s", data->req_path);
send_msg.pid = data->pid;
send_msg.msg_type = MS_MSG_MEDIA_DB_RESET;
send_msg.msg_size = strlen(data->req_path);
strncpy(send_msg.msg, data->req_path, send_msg.msg_size);
-
+
/* owner data exists */
/* send result to the owner of request */
ms_ipc_send_msg_to_client_tcp(data->client_sockfd, &send_msg, NULL);
close(data->client_sockfd);
- }
+ }
}
return MS_MEDIA_ERR_NONE;
void **handle = NULL;
/* stop the child process */
-
+
/*reset */
ms_config_set_int(MS_DB_RESET, 1);
ms_reset_ownerlist();
MS_DBG_ERR("function load failed [%d]", err);
return err;
}
-
+
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();
memset(&res_msg, 0x0, sizeof(ms_comm_msg_s));
switch (req_num) {
- case MS_MSG_DIRECTORY_SCANNING:
- case MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE:
- res_msg.msg_type = MS_MSG_SCANNER_RESULT;
- break;
- case MS_MSG_BULK_INSERT:
- case MS_MSG_BURSTSHOT_INSERT:
- res_msg.msg_type = MS_MSG_SCANNER_BULK_RESULT;
- break;
- case MS_MSG_RECEIVE_MSG_FAILED:
- res_msg.msg_type = MS_MSG_RECEIVE_MSG_FAILED;
- break;
- case MS_MSG_MEDIA_DB_MALFORMED:
- res_msg.msg_type = MS_MSG_MEDIA_DB_MALFORMED;
- break;
- default :
- break;
+ case MS_MSG_DIRECTORY_SCANNING:
+ case MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE:
+ res_msg.msg_type = MS_MSG_SCANNER_RESULT;
+ break;
+ case MS_MSG_BULK_INSERT:
+ case MS_MSG_BURSTSHOT_INSERT:
+ res_msg.msg_type = MS_MSG_SCANNER_BULK_RESULT;
+ break;
+ case MS_MSG_RECEIVE_MSG_FAILED:
+ res_msg.msg_type = MS_MSG_RECEIVE_MSG_FAILED;
+ break;
+ case MS_MSG_MEDIA_DB_MALFORMED:
+ res_msg.msg_type = MS_MSG_MEDIA_DB_MALFORMED;
+ break;
+ default:
+ break;
}
res_msg.result = res;
/* msg_type */
switch (scan_type) {
- case MS_SCAN_PART:
- scan_msg.msg_type = MS_MSG_STORAGE_PARTIAL;
- break;
- case MS_SCAN_ALL:
- scan_msg.msg_type = MS_MSG_STORAGE_ALL;
- break;
- case MS_SCAN_INVALID:
- scan_msg.msg_type = MS_MSG_STORAGE_INVALID;
- break;
- case MS_SCAN_META:
- scan_msg.msg_type = MS_MSG_STORAGE_META;
- break;
- default:
- ret = MS_MEDIA_ERR_INVALID_PARAMETER;
- MS_DBG_ERR("ms_send_storage_scan_request invalid parameter");
- goto ERROR;
- break;
+ case MS_SCAN_PART:
+ scan_msg.msg_type = MS_MSG_STORAGE_PARTIAL;
+ break;
+ case MS_SCAN_ALL:
+ scan_msg.msg_type = MS_MSG_STORAGE_ALL;
+ break;
+ case MS_SCAN_INVALID:
+ scan_msg.msg_type = MS_MSG_STORAGE_INVALID;
+ break;
+ case MS_SCAN_META:
+ scan_msg.msg_type = MS_MSG_STORAGE_META;
+ break;
+ default:
+ ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+ MS_DBG_ERR("ms_send_storage_scan_request invalid parameter");
+ goto ERROR;
+ break;
}
/* msg_size & msg */
ret = ms_update_storage(handle, storage_id, path, uid);
}
- if (validity== 0) {
+ if (validity == 0) {
ms_set_storage_validity(handle, storage_id, 1, uid);
/* update storage_id table set validity=0 first */
ms_validaty_change_all_items(handle, storage_id, MS_STORAGE_EXTERNAL, false, uid);
memset((void *)&recv_msg, 0, sizeof(ms_comm_msg_s));
-// MS_DBG_ERR("client sokcet : %d", client_sock);
-
while (1) {
if (power_off == TRUE) {
MS_DBG_WARN("in the power off sequence");
MS_DBG_STRERROR("send failed");
}
-// MS_DBG_ERR("client sokcet : %d", client_sock);
if (recv_msg.msg_type == MS_MSG_DB_UPDATE_BATCH_END) {
MS_DBG_WARN("Batch job is successfull!client sockfd [%d]", client_sock);
break;
(msg_type == MS_MSG_DIRECTORY_SCANNING_CANCEL)) {
MS_DBG_WARN("DB UPDATING IS DONE[%d]", msg_type);
- if((msg_type == MS_MSG_SCANNER_RESULT) ||
+ if ((msg_type == MS_MSG_SCANNER_RESULT) ||
(msg_type == MS_MSG_SCANNER_BULK_RESULT) ||
(msg_type == MS_MSG_EXTRACTOR_COMPLETE) ||
- (msg_type == MS_MSG_DIRECTORY_SCANNING_CANCEL))
- {
+ (msg_type == MS_MSG_DIRECTORY_SCANNING_CANCEL)) {
ms_req_num--;
MS_DBG_WARN("ms_req_num-- [%d]", ms_req_num);
}
/* msg_type */
switch (scan_type) {
- case MS_SCAN_PART:
- scan_msg.msg_type = MS_MSG_STORAGE_PARTIAL;
- break;
- case MS_SCAN_ALL:
- scan_msg.msg_type = MS_MSG_STORAGE_ALL;
- break;
- case MS_SCAN_INVALID:
- scan_msg.msg_type = MS_MSG_STORAGE_INVALID;
- break;
- default:
- ret = MS_MEDIA_ERR_INVALID_PARAMETER;
- MS_DBG_ERR("ms_send_storage_scan_request invalid parameter");
- goto ERROR;
- break;
+ case MS_SCAN_PART:
+ scan_msg.msg_type = MS_MSG_STORAGE_PARTIAL;
+ break;
+ case MS_SCAN_ALL:
+ scan_msg.msg_type = MS_MSG_STORAGE_ALL;
+ break;
+ case MS_SCAN_INVALID:
+ scan_msg.msg_type = MS_MSG_STORAGE_INVALID;
+ break;
+ default:
+ ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+ MS_DBG_ERR("ms_send_storage_scan_request invalid parameter");
+ goto ERROR;
+ break;
}
/* msg_size & msg */