#define MEDIA_SHARE_PATH tzplatform_getenv(TZ_SYS_MEDIASHARED)
#endif
-#ifdef _USE_SENIOR_MODE
-#define MEDIA_ROOT_PATH_SENIOR_MODE "/opt/familytv"
-#define SENIOR_MODE_ID "familytv"
-#endif
-
-#define MEDIA_ROOT_PATH_DISC "/mnt/cdrom"
-
#define MEDIA_DB_SIZE_LIMIT_2 20000000.0
#define MEDIA_DB_SIZE_LIMIT_1 10000000.0
#define MEDIA_DB_SPACE_LIMIT 20971520.0
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef _USE_SENIOR_MODE
-#include <system_info.h>
-#endif
-
static GMutex tzplatform_mutex;
typedef enum {
MEDIA_SHARED
} ms_user_path_type_e;
-#ifdef _USE_SENIOR_MODE
-static bool __ms_is_support_senior_mode(void)
-{
- bool bSupportSeniorMode = false;
-
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_GET_SENIOR_MODE_SUPPORTED, &bSupportSeniorMode) != SYSTEM_INFO_ERROR_NONE) {
- MSAPI_DBG("Get familytv Support failed");
- return false;
- }
-
- MSAPI_DBG("FamilyTv Support : [%d]", bSupportSeniorMode);
-
- return bSupportSeniorMode;
-}
-#endif
-
static int __ms_user_get_path(ms_user_path_type_e type, uid_t uid, char **path)
{
int ret = MS_MEDIA_ERR_NONE;
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
-#ifdef _USE_SENIOR_MODE
- if (__ms_is_support_senior_mode()) {
- if (strncmp(path, MEDIA_ROOT_PATH_SENIOR_MODE, strlen(MEDIA_ROOT_PATH_SENIOR_MODE)) == 0) {
- *storage_type = MS_USER_STORAGE_EXTERNAL;
- return MS_MEDIA_ERR_NONE;
- }
- }
-#endif
-
ret = ms_user_get_internal_root_path(uid, &internal_path);
MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail get internal root path");
*storage_type = MS_USER_STORAGE_EXTERNAL;
} else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0)) {
*storage_type = MS_USER_STORAGE_EXTERNAL_USB;
- } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0)) {
- *storage_type = MS_USER_STORAGE_EXTERNAL_USB;
} else {
MSAPI_DBG_ERR("[%s][%s][%s]", MEDIA_ROOT_PATH_SDCARD, MEDIA_ROOT_PATH_USB, path);
ret = MS_MEDIA_ERR_INVALID_PARAMETER;
Name: media-server
Summary: A server for media content management
-Version: 0.4.7
+Version: 0.4.8
Release: 0
Group: Multimedia/Service
License: Apache-2.0
%restore_fcommon
%endif
%if 0%{?product_tv}
-export CFLAGS="$CFLAGS -D_USE_SENIOR_MODE -D_USE_RECORDED_CONTENT -D_USE_SUSPEND_MODE -D_SET_VIP_PROCESS -D_USE_TVPD_MODE"
+export CFLAGS="$CFLAGS -D_USE_RECORDED_CONTENT -D_USE_SUSPEND_MODE -D_SET_VIP_PROCESS -D_USE_TVPD_MODE"
%else
export CFLAGS="$CFLAGS -D_USE_MULTI_USER -D_USE_META_UPDATE -D_USE_DEVICED_DBUS"
%endif
#define MS_DB_LIMIT "file/private/mediaserver/db_limit"
#define MS_DB_RESET "file/private/mediaserver/db_reset"
#endif
-#define MS_DISC_STATE "db/disc/mount/state"
-#define MS_DISC_PATH "memory/disc/info/mount_path"
-#define MS_DISC_TYPE "memory/disc/info/logical_type"
-#define MS_DISC_ACCESS_STATE "memory/disc/info/datadisc/access_state/mmfw"
-
-typedef enum {
- MS_DISC_ACCESS = 1, /**< The device's external storage */
- MS_DISC_NOT_ACCESS = 2, /**< The external USB storage (Since 2.4) */
-} ms_disc_access_state_e;
/*Use for Poweroff sequence*/
#define POWEROFF -1 /*This number uses for stopping Scannig thread*/
bool ms_is_support_pvr(void);
#endif
-#ifdef _USE_SENIOR_MODE
-bool ms_is_support_senior_mode(void);
-#endif
-
int ms_check_file_path(const char *file_path, uid_t uid);
int ms_check_ignore_dir(const char *full_path, uid_t uid);
int ms_check_scan_ignore(char * path, uid_t uid);
if (users > 0) {
*uid = list[0];
MS_SAFE_FREE(list);
-#ifdef _USE_SENIOR_MODE
- /*in tv side, sometimes the uid is not valid.
- so for debbuging add below code temporary */
- if (*uid != MEDIA_DEFAULT_UID) {
- MS_DBG_ERR("NOT VALID UID[%d]", *uid);
- return MS_MEDIA_ERR_INTERNAL;
- }
-#endif
} else {
MS_DBG_ERR("No login user!.");
MS_SAFE_FREE(list);
}
#endif
-#ifdef _USE_SENIOR_MODE
-bool ms_is_support_senior_mode(void)
-{
- bool bSupportSeniorMode = false;
-
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_GET_SENIOR_MODE_SUPPORTED, &bSupportSeniorMode) != SYSTEM_INFO_ERROR_NONE) {
- MS_DBG_ERR("Get senior mode support failed");
- return false;
- }
-
- MS_DBG("Senior mode support : [%d]", bSupportSeniorMode);
-
- return bSupportSeniorMode;
-}
-#endif
-
int ms_check_file_path(const char *file_path, uid_t uid)
{
ms_user_storage_type_e storage_type = -1;
break;
}
-#ifdef _USE_SENIOR_MODE
- if (ms_is_support_senior_mode()) {
- if (strcmp(dir_path, MEDIA_ROOT_PATH_SENIOR_MODE) == 0)
- break;
- }
-#endif
if (strcmp(dir_path, usr_path) == 0)
break;
else if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && (strncmp(dir_path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0))
break;
else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(dir_path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0))
break;
- else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(dir_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0))
- break;
leaf_path = strrchr(dir_path, '/');
if (leaf_path != NULL) {
void msc_set_power_status(bool status);
void msc_get_power_status(bool *status);
-void msc_set_disc_stg_scan_status(bool status);
-bool msc_get_disc_stg_scan_status(void);
-void msc_set_disc_dir_scan_status(bool status);
-bool msc_get_disc_dir_scan_status(void);
#endif /*_MEDIA_SCANNER_COMMON_V2_H_*/
#include "media-scanner-common-v2.h"
bool power_off2;
-static bool disc_stg_scan_status;
-static bool disc_dir_scan_status;
void msc_set_power_status(bool status)
{
{
*status = power_off2;
}
-
-void msc_set_disc_stg_scan_status(bool status)
-{
- disc_stg_scan_status = status;
-}
-
-bool msc_get_disc_stg_scan_status(void)
-{
- return disc_stg_scan_status;
-}
-
-void msc_set_disc_dir_scan_status(bool status)
-{
- disc_dir_scan_status = status;
-}
-
-bool msc_get_disc_dir_scan_status(void)
-{
- return disc_dir_scan_status;
-}
-
-
char *update_path = NULL;
unsigned int io_err_count = 0;
uid_t uid = MEDIA_DEFAULT_UID;
- int disc_state = 0;
int end_flag = NORMAL_EVENT;
ms_noti_type_e noti_type = MS_ITEM_INSERT;
__msc_del_cur_extract_item();
__msc_del_cancel_extract_item();
- if (msc_get_disc_dir_scan_status()) {
- MS_DBG("[DISC ACCESS END]");
- msc_set_disc_dir_scan_status(false);
-
- ms_config_get_int(MS_DISC_ACCESS_STATE, &disc_state);
- if (disc_state == MS_DISC_ACCESS) {
- MS_DBG_WARN("[CHANGE DISC STATE]");
- ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_NOT_ACCESS);
- }
- }
MS_DBG_WARN("DIRECTORY EXTRACT END [%d]", ret);
char *update_path = NULL;
unsigned int io_err_count = 0;
uid_t uid = MEDIA_DEFAULT_UID;
- int disc_state = 0;
int end_flag = NORMAL_EVENT;
int tem_ret = MS_MEDIA_ERR_NONE;
MS_DBG_ERR("%s is unmounted", update_path);
ret = MS_MEDIA_ERR_USB_UNMOUNTED;
msc_remove_extract_request(extract_data);
- goto STOP_DISC;
+ goto NEXT;
}
}
ms_set_storage_scan_status(handle, extract_data->storage_id, MEDIA_EXTRACT_PROCESSING, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("NOT ENOUGH MEMORY");
__msc_extract_set_db_status(MS_DB_STOPPED);
- goto STOP_DISC;
+ goto NEXT;
}
/*extract meta*/
__msc_extract_set_db_status(MS_DB_STOPPED);
msc_remove_extract_request(extract_data);
- goto STOP_DISC;
+ goto NEXT;
}
+
if (extract_data->result) {
MS_DBG_WARN("extract_data->result is true, MS_STORAGE_SCAN_COMPLETE");
__msc_del_extract_blocked_path(update_path);
ms_send_dir_update_noti(update_path, NULL, MS_ITEM_UPDATE, extract_data->pid);
/* set vconf key db extract status */
__msc_extract_set_db_status(MS_DB_UPDATED);
- goto STOP_DISC;
- }
-
- goto NEXT;
-
-STOP_DISC:
- if (strncmp(update_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0) {
- if (msc_get_disc_stg_scan_status()) {
- MS_DBG("[DISC ACCESS STOP]");
- msc_set_disc_stg_scan_status(false);
-
- ms_config_get_int(MS_DISC_ACCESS_STATE, &disc_state);
- if (disc_state == MS_DISC_ACCESS) {
- MS_DBG_WARN("[CHANGE DISC STATE]");
- ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_NOT_ACCESS);
- }
-
- }
}
NEXT:
g_free(update_path);
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
goto END;
}
- if (strncmp(start_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0) {
- int disc_state = 0;
- ms_config_get_int(MS_DISC_STATE, &disc_state);
- if (disc_state == 0) {
- MS_DBG_ERR("[DISC IS NOT INSERTED]");
- ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
- goto END;
- }
- }
if (scan_type == MS_MSG_DIRECTORY_SCANNING || scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
g_mutex_lock(&extract_req_mutex);
goto END;
}
- if (strncmp(start_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0) {
- int disc_state = 0;
- ms_config_get_int(MS_DISC_STATE, &disc_state);
- if (disc_state == 0) {
- MS_DBG_ERR("[DISC IS NOT INSERTED]");
- ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
- goto END;
- }
- }
if (scan_type == MS_MSG_DIRECTORY_SCANNING || scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
g_mutex_lock(&scan_req_mutex2);
/* check cancel path */
__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, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_SERR("%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, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_SERR("%s is ignore", current_path);
+ MS_SAFE_FREE(current_path);
+ if (ret == MS_MEDIA_ERR_USB_UNMOUNTED)
+ goto STOP_SCAN;
- continue;
- }
- } else {
- MS_DBG_ERR("[DATA DISC] PASS IGNORE");
+ ret = MS_MEDIA_ERR_NONE;
+ continue;
}
ret = msc_check_db_size(uid, scan_type);
}
for ( ; ; ) {
- if (strncmp(current_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0) {
- int disc_state = 0;
- ms_config_get_int(MS_DISC_STATE, &disc_state);
- if (disc_state == 0) {
- MS_DBG_ERR("[DISC IS NOT INSERTED]");
- ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
- break;
- }
- }
nread = syscall(SYS_getdents64, fd, buf, BUF_SIZE);
if (nread == -1) {
MS_DBG_STRERROR("getdents");
/*call for bundle commit*/
ms_batch_commit_enable(true, true, false, 0);
- if (strcmp(scan_data->msg, MEDIA_ROOT_PATH_DISC) == 0) {
- MS_DBG("[DATA DISC]");
- msc_set_disc_dir_scan_status(true);
- }
-
/*insert data into media db */
ret = __msc_db_update(handle, storage_id, scan_data);
/*start db updating */
ms_set_db_status(MS_DB_UPDATING, storage_type);
- if (strcmp(update_path, MEDIA_ROOT_PATH_DISC) == 0) {
- MS_DBG("[DATA DISC]");
- msc_set_disc_stg_scan_status(true);
- }
-
valid_status = (scan_type == MS_MSG_STORAGE_PARTIAL || MS_MSG_STORAGE_ALL == scan_type) ? true : false;
if (scan_type != MS_MSG_STORAGE_INVALID)
MS_DBG_ERR("POWER OFF END");
}
-#ifdef _USE_SENIOR_MODE
-extern GAsyncQueue *storage_queue2;
-extern GAsyncQueue *storage_extract_queue;
-extern int g_directory_scan_processing2;
-extern bool g_directory_extract_processing;
-
-static void __msc_datadisc_vconf_cb(void *data)
-{
- int disc_state = 0;
- char *disc_type = NULL;
- char *disc_path = NULL;
- char *valid_type = "data";
- char storage_path[11] = {0,};
-
- /*check disc type */
- if (!ms_config_get_str(MS_DISC_TYPE, &disc_type)) {
- MS_DBG_ERR("Get MS_DISC_TYPE failed.");
- goto END;
- }
-
- MS_DBG("[disc type] %s", disc_type);
-
- if (strcmp(disc_type, valid_type) == 0) {
- ms_config_get_int(MS_DISC_STATE, &disc_state);
-
- if (disc_state == 1) {
- MS_DBG_WARN("[DISC INSERTED]");
- } else {
- MS_DBG_WARN("[DISC REMOVED]");
- int status = -1;
-
- /* check mount path */
- if (!ms_config_get_str(MS_DISC_PATH, &disc_path)) {
- MS_DBG_ERR("Get MS_DISC_PATH failed.");
- goto END;
- }
-
- MS_DBG_SLOG("[disc path] %s", disc_path);
- memset(storage_path, 0x0, sizeof(storage_path));
- SAFE_STRLCPY(storage_path, disc_path, sizeof(storage_path));
-
- if (msc_get_disc_dir_scan_status() ||
- msc_get_disc_stg_scan_status()) {
- MS_DBG("[DATA DISC IS READING]");
- ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_ACCESS);
- }
-
- 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))
- 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))
- msc_set_extract_blocked_path(storage_path);
-
- if (g_directory_extract_processing == true) {
- MS_DBG_WARN("Doing directory extracting. Set cancel path");
- msc_set_cancel_extract_item(storage_path, -1);
- }
- }
- }
-
-END:
- g_free(disc_type);
-}
-#endif
-
int main(int argc, char **argv)
{
GThread *storage_scan_thread = NULL;
/*set power off callback function*/
ms_sys_set_poweroff_cb(__msc_power_off_cb, NULL);
ms_sys_set_device_block_event_cb(msc_device_block_changed_cb, NULL);
-
-#ifdef _USE_SENIOR_MODE
- if (vconf_notify_key_changed(MS_DISC_STATE, (vconf_callback_fn) __msc_datadisc_vconf_cb, NULL) == -1)
- MS_DBG_ERR("add call back function for event %s fails", MS_DISC_STATE);
-#endif
}
static void __msc_remove_event_receiver(void)
void ms_remove_request_owner(int pid, const char *req_path);
int ms_send_storage_otg_scan_request(const char *path, const char *device_uuid, ms_dir_scan_type_t scan_type, uid_t uid);
void ms_reset_ownerlist(void);
-#ifdef _USE_SENIOR_MODE
-int ms_send_storage_scan_request_senior_mode(sqlite3 *handle);
-#endif
#endif /*_MEDIA_SERVER_SOCKET_H_*/
return true;
}
-#endif
-#ifdef _USE_SENIOR_MODE
static void __ms_smarthub_vconf_cb(void *data)
{
int status = 0;
}
}
}
-
-static void __ms_datadisc_vconf_cb(void *data)
-{
- int ret = MS_MEDIA_ERR_NONE;
- int disc_state = 0;
- int validity = 0;
- char *disc_type = NULL;
- char *disc_path = NULL;
- 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 *storage_path = NULL;
- sqlite3 *handle = NULL;
-
- /*check disc type */
- if (!ms_config_get_str(MS_DISC_TYPE, &disc_type)) {
- MS_DBG_ERR("Get MS_DISC_TYPE failed.");
- goto END;
- }
-
- MS_DBG("[disc type] %s", disc_type);
-
- if (strcmp(disc_type, valid_type) == 0) {
- ms_config_get_int(MS_DISC_STATE, &disc_state);
-
- /* request scanning */
- ms_sys_get_uid(&uid);
-
- ms_connect_db(&handle, uid);
-
- /* check mount path */
- if (!ms_config_get_str(MS_DISC_PATH, &disc_path)) {
- MS_DBG_ERR("Get MS_DISC_PATH failed.");
- goto END;
- }
-
- MS_DBG_SLOG("[disc path] %s", disc_path);
- memset(mnt_path, 0x0, sizeof(mnt_path));
- SAFE_STRLCPY(mnt_path, disc_path, sizeof(mnt_path));
-
- if (disc_state == 1) {
- MS_DBG_WARN("[DISC INSERTED][%s]", disc_type);
- MS_DBG_SWARN("MOUNT PATH [%s]", mnt_path);
-
- /* update storage information into media DB */
- ret = ms_check_storage(handle, DATADISC_STORAGE_ID, &storage_path, &validity, uid);
- if (ret == 0) {
- ms_set_storage_validity(handle, DATADISC_STORAGE_ID, 1, uid);
- if (ms_set_storage_scan_status(handle, DATADISC_STORAGE_ID, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_set_storage_scan_status failed");
- goto END;
- }
-
- MS_DBG_WARN("init storage data in DB");
- /* update storage_id table set validity=0 first */
- ms_validity_change_all_items(handle, DATADISC_STORAGE_ID, false, uid);
- /*update folder table set validity = 0*/
- ms_set_folder_validity(handle, DATADISC_STORAGE_ID, mnt_path, MS_INVALID, true, uid);
- /* update folder table set scan_status=0 first */
- ms_set_folder_scan_status(handle, DATADISC_STORAGE_ID, NULL, MS_DIR_SCAN_NONE, uid);
- MS_DBG_WARN("init storage data in DB end");
-
- } else {
- ret = ms_insert_storage(handle, DATADISC_STORAGE_ID, mnt_path, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_insert_storage failed");
- goto END;
- }
- }
-
- ms_send_storage_scan_request(mnt_path, DATADISC_STORAGE_ID, scan_type, uid);
- } else {
- MS_DBG_WARN("[DISC REMOVED]");
- ms_set_storage_validity(handle, DATADISC_STORAGE_ID, 0, uid);
- /*set media validaty to 0 first, then set folder validaty to 0*/
- ms_validity_change_all_items(handle, DATADISC_STORAGE_ID, false, uid);
- ms_set_folder_validity(handle, DATADISC_STORAGE_ID, mnt_path, false, true, uid);
- }
-
- ms_disconnect_db(handle);
- }
-
-END:
- g_free(disc_type);
- g_free(disc_path);
- g_free(storage_path);
-}
#endif
+
int ms_write_media_server_status(void)
{
FILE * fp = NULL;
g_free(lang);
#endif
-#ifdef _USE_SENIOR_MODE
+#ifdef _USE_TVPD_MODE
/*add noti receiver for smart hub reset */
err = vconf_notify_key_changed(SMARTHUB_RESET_VCONF, (vconf_callback_fn) __ms_smarthub_vconf_cb, NULL);
if (err == -1)
MS_DBG_ERR("add call back function for event %s fails", SMARTHUB_RESET_VCONF);
-
- err = vconf_notify_key_changed(MS_DISC_STATE, (vconf_callback_fn) __ms_datadisc_vconf_cb, NULL);
- if (err == -1)
- MS_DBG_ERR("add call back function for event %s fails", MS_DISC_STATE);
#endif
/*set power off callback function*/
#ifdef _USE_DEVICED_DBUS
g_slist_free_full(dev_list, __ms_dev_free);
}
-#ifdef _USE_SENIOR_MODE
-static int __ms_check_disc_status(void)
-{
- int ret = MS_MEDIA_ERR_NONE;
- int disc_state = 0;
- int validity = 0;
- char *disc_type = NULL;
- char *disc_path = NULL;
- 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 *storage_path = NULL;
- sqlite3 *handle = NULL;
-
- ms_config_get_int(MS_DISC_STATE, &disc_state);
- if (disc_state == 1) {
- /*check disc type */
- if (!ms_config_get_str(MS_DISC_TYPE, &disc_type)) {
- MS_DBG_ERR("Get MS_DISC_TYPE failed.");
- goto END;
- }
-
- if (strcmp(disc_type, valid_type) == 0) {
- MS_DBG_WARN("[DISC INSERTED][%s]", disc_type);
- MS_DBG_SWARN("MOUNT PATH [%s]", mnt_path);
-
- /* check mount path */
- if (!ms_config_get_str(MS_DISC_PATH, &disc_path)) {
- MS_DBG_ERR("Get MS_DISC_PATH failed.");
- goto END;
- }
-
- MS_DBG_SLOG("[disc path] %s", disc_path);
- memset(mnt_path, 0x0, sizeof(mnt_path));
- SAFE_STRLCPY(mnt_path, disc_path, sizeof(mnt_path));
-
- /* request scanning */
- ms_sys_get_uid(&uid);
-
- ms_connect_db(&handle, uid);
-
- /* update storage information into media DB */
- ret = ms_check_storage(handle, DATADISC_STORAGE_ID, &storage_path, &validity, uid);
- if (ret == 0) {
- ms_set_storage_validity(handle, DATADISC_STORAGE_ID, 1, uid);
- if (ms_set_storage_scan_status(handle, DATADISC_STORAGE_ID, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_set_storage_scan_status failed");
- goto END;
- }
-
- MS_DBG_WARN("init storage data in DB");
- /* update storage_id table set validity=0 first */
- ms_validity_change_all_items(handle, DATADISC_STORAGE_ID, false, uid);
- /*update folder table set validity = 0*/
- ms_set_folder_validity(handle, DATADISC_STORAGE_ID, mnt_path, MS_INVALID, true, uid);
- /* update folder table set scan_status=0 first */
- ms_set_folder_scan_status(handle, DATADISC_STORAGE_ID, NULL, MS_DIR_SCAN_NONE, uid);
- MS_DBG_WARN("init storage data in DB end");
-
- } else {
- ret = ms_insert_storage(handle, DATADISC_STORAGE_ID, mnt_path, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_insert_storage failed");
- goto END;
- }
- }
-
- ms_send_storage_scan_request(mnt_path, DATADISC_STORAGE_ID, scan_type, uid);
-
- ms_disconnect_db(handle);
- }
- }
-
-END:
- g_free(disc_type);
- g_free(disc_path);
- g_free(storage_path);
-
- return MS_MEDIA_ERR_NONE;
-}
-#endif
-
static void __ms_check_mediadb(void)
{
#ifndef _USE_MULTI_USER
g_free(internal_path);
#endif
-#ifdef _USE_SENIOR_MODE
- if (ms_is_support_senior_mode())
- ms_send_storage_scan_request_senior_mode(db_handle);
-#endif
-
ms_disconnect_db(db_handle);
#endif
/* update external storage */
if (__ms_is_external_supported())
__ms_update_storage_status();
-
-#ifdef _USE_SENIOR_MODE
- __ms_check_disc_status();
-#endif
-
}
static bool __ms_is_dcm_supported(void)
return ms_send_scan_request(&scan_msg, -1);
}
-#ifdef _USE_SENIOR_MODE
-int ms_send_storage_scan_request_senior_mode(sqlite3 *handle)
-{
- int ret = MS_MEDIA_ERR_NONE;
- uid_t uid = MEDIA_DEFAULT_UID;
- /* update storage information into media DB */
- int validity = 0;
- ms_dir_scan_type_t scan_type = MS_SCAN_ALL;
- char *storage_path = NULL;
-
- ms_sys_get_uid(&uid);
-
- ret = ms_check_storage(handle, SENIOR_MODE_ID, &storage_path, &validity, uid);
- if (ret == 0) {
- if (storage_path != NULL) {
- MS_DBG_SWARN("##[senior mode]####[path [%s], %s]###", MEDIA_ROOT_PATH_SENIOR_MODE, storage_path);
- if (strcmp(MEDIA_ROOT_PATH_SENIOR_MODE, storage_path)) {
- /* update storage path */
- MS_DBG_SWARN("##[senior mode]update storage from %s to %s", storage_path, MEDIA_ROOT_PATH_SENIOR_MODE);
- ret = ms_update_storage(handle, SENIOR_MODE_ID, MEDIA_ROOT_PATH_SENIOR_MODE, uid);
- }
-
- if (validity == 0) {
- ms_set_storage_validity(handle, SENIOR_MODE_ID, 1, uid);
- /* update storage_id table set validity=0 first */
- ms_validity_change_all_items(handle, SENIOR_MODE_ID, false, uid);
- ms_set_folder_validity(handle, SENIOR_MODE_ID, storage_path, MS_INVALID, true, uid);
- /* update folder table set scan_status=0 first */
- ms_set_folder_scan_status(handle, SENIOR_MODE_ID, NULL, MS_DIR_SCAN_NONE, uid);
- }
-
- scan_type = MS_SCAN_PART;
- g_free(storage_path);
- } else {
- /* there is no information of this storage in Media DB */
- MS_DBG_SWARN("##[senior mode]insert storage %s", MEDIA_ROOT_PATH_SENIOR_MODE);
- ret = ms_insert_storage(handle, SENIOR_MODE_ID, MEDIA_ROOT_PATH_SENIOR_MODE, uid);
- MS_DBG_WARN("##[senior mode]");
- scan_type = MS_SCAN_ALL;
- }
- } else {
- /* there is no information of this storage in Media DB */
- MS_DBG_SWARN("##[senior mode]insert storage %s", MEDIA_ROOT_PATH_SENIOR_MODE);
- ret = ms_insert_storage(handle, SENIOR_MODE_ID, MEDIA_ROOT_PATH_SENIOR_MODE, uid);
- MS_DBG_WARN("##[senior mode]");
- scan_type = MS_SCAN_ALL;
- }
-
- /* request to update media db */
- ret = ms_insert_folder(handle, SENIOR_MODE_ID, MEDIA_ROOT_PATH_SENIOR_MODE, uid);
- if (ret != MS_MEDIA_ERR_NONE)
- MS_DBG_ERR("##[senior mode]error : ms_insert_folder failed");
-
- ms_send_storage_otg_scan_request(MEDIA_ROOT_PATH_SENIOR_MODE, SENIOR_MODE_ID, scan_type, uid);
-
- return ret;
-}
-#endif
-
gboolean ms_read_db_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer data)
{
int sock = -1;