Name: media-server
Summary: A server for media content management
-Version: 0.4.27
+Version: 0.4.28
Release: 0
Group: Multimedia/Service
License: Apache-2.0
#else
void ms_device_block_changed_cb(usb_device_h usb_device, char *action, void *user_data);
int ms_check_mounted_storage(uid_t uid);
+void ms_device_handle_usb_added(const char *mount_path);
+void ms_device_handle_usb_removed(const char *mount_path);
#endif
#endif
void ms_on_demand_insert_storage(gpointer data, gpointer user_data);
void ms_on_demand_remove_storage(gpointer data, gpointer user_data);
void ms_on_demand_update_storage_list(GSList *storage_list);
+#ifdef _USE_TVPD_MODE
+void ms_on_demand_reset_storage(void);
+#endif
#endif /* _MEDIA_SERVER_ON_DEMAND_H_ */
}
}
#else
-static void __ms_usb_add_event(const char *mount_path)
+void ms_device_handle_usb_added(const char *mount_path)
{
int ret = MS_MEDIA_ERR_NONE;
char *storage_id = NULL;
ms_disconnect_db(handle);
}
-static void __ms_usb_remove_event(const char *mount_path)
+void ms_device_handle_usb_removed(const char *mount_path)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *handle = NULL;
mount_path = usb_device_get_mountpath(usb_device);
ms_sys_get_uid(&uid);
+ ms_check_mediadb(uid, &is_reset);
+#ifdef _USE_ON_DEMAND
+ ms_block_info_s block_info = { mount_path, 0, 0, NULL };
+
+ if (!strcmp(action, "mounted")) {
+ MS_DBG_SWARN("USB MOUNTED, mountpath : %s", mount_path);
+ ms_on_demand_insert_storage((gpointer)&block_info, NULL);
+ } else if (!strcmp(action, "blocked")) { /*unmount->blocked stop accessing usb in time*/
+ MS_DBG_SWARN("USB blocked, mountpath : %s", mount_path);
+ if (!is_reset)
+ ms_on_demand_remove_storage((gpointer)&block_info, NULL);
+ }
+#else
if (!strcmp(action, "mounted")) {
MS_DBG_SWARN("USB MOUNTED, mountpath : %s", mount_path);
- ms_check_mediadb(uid, &is_reset);
- __ms_usb_add_event(mount_path);
+ ms_device_handle_usb_added(mount_path);
} else if (!strcmp(action, "blocked")) { /*unmount->blocked stop accessing usb in time*/
MS_DBG_SWARN("USB blocked, mountpath : %s", mount_path);
- ms_check_mediadb(uid, &is_reset);
if (!is_reset)
- __ms_usb_remove_event(mount_path);
+ ms_device_handle_usb_removed(mount_path);
}
+#endif
free_usb_device_h(usb_device);
bool smarthub_reset_start;
bool smarthub_reset;
-static void __ms_check_mediadb(void);
+static void __ms_update_mediadb(bool need_checkdb);
static void __ms_update_storage_status(void);
static void __ms_add_signal_handler(void);
static void __ms_add_event_receiver(void);
#endif
#ifdef _USE_TVPD_MODE
+static void __ms_check_mediadb(void);
+
static bool __ms_deal_reset_status(void)
{
int value = 0;
ms_config_set_int(MS_DB_RESET, 1);
ms_reset_ownerlist();
ms_reset_mediadb(uid);
- __ms_check_mediadb();
+ __ms_update_mediadb(true);
ms_config_set_int(MS_DB_RESET, 0);
MS_DBG_ERR("END SMART HUB RESET");
smarthub_reset = false;
int ret = 0;
#ifdef _USE_ON_DEMAND
ms_start_type_e start_type = ms_on_demand_get_start_type();
+#ifdef _USE_TVPD_MODE
+ bool need_checkdb = false;
+#endif
#endif
resource_pid_t stResource = {};
if (db_size > MEDIA_DB_SIZE_LIMIT_2) {
MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");
ms_reset_mediadb(uid);
+#ifdef _USE_ON_DEMAND
+ need_checkdb = true;
+ ms_on_demand_reset_storage();
+#endif
}
if (ms_check_corrupt_mediadb() != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("MEDIA DB IS CORRUPTED. RESET MEDIA DB.");
ms_reset_mediadb(uid);
+#ifdef _USE_ON_DEMAND
+ need_checkdb = true;
+ ms_on_demand_reset_storage();
+#endif
}
#endif
#ifdef _USE_ON_DEMAND
switch (start_type) {
case MS_START_TYPE_SOCKET:
- /* do nothing */
+#ifdef _USE_TVPD_MODE
+ if (need_checkdb)
+ __ms_update_mediadb(true);
+#endif
break;
case MS_START_TYPE_UDEV:
/* improve mount/unmount performance */
MS_DBG("ms_scanner_start [%s]", (ms_scanner_start() == MS_MEDIA_ERR_NONE) ? "success" : "fail");
- /* fall through */
+#ifdef _USE_TVPD_MODE
+ __ms_update_mediadb(need_checkdb);
+#else
+ __ms_update_mediadb(false);
+#endif
+ break;
case MS_START_TYPE_BOOT:
- __ms_check_mediadb();
+ __ms_update_mediadb(true);
break;
default:
MS_DBG_ERR("invalid start_type(%d)", start_type);
break;
}
#else
- __ms_check_mediadb();
+ __ms_update_mediadb(true);
#endif
/*Active flush */
g_slist_free_full(dev_list, __ms_dev_free);
}
+#ifdef _USE_TVPD_MODE
static void __ms_check_mediadb(void)
{
-#ifndef _USE_MULTI_USER
+ int ret = MS_MEDIA_ERR_NONE;
uid_t uid = MEDIA_DEFAULT_UID;
-
sqlite3 *db_handle = NULL;
- int ret = MS_MEDIA_ERR_NONE;
ms_sys_get_uid(&uid);
if (ms_set_all_storage_validity(db_handle, 0, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("ms_set_all_storage_validity fail");
-#ifdef _USE_TVPD_MODE
-/* auto scan tv interal storage */
+#ifdef _USE_ON_DEMAND
+ ms_on_demand_reset_storage();
+#endif
+
+ /* auto scan tv interal storage */
char *internal_path = NULL;
ms_sys_get_uid(&uid);
ms_user_get_internal_root_path(uid, &internal_path);
ms_send_storage_scan_request(internal_path, INTERNAL_STORAGE_ID, MS_SCAN_PART, uid);
g_free(internal_path);
-#endif
ms_disconnect_db(db_handle);
+}
+#endif
+
+static void __ms_update_mediadb(bool need_checkdb)
+{
+#ifdef _USE_TVPD_MODE
+ if (need_checkdb)
+ __ms_check_mediadb();
#endif
/* update external storage */
#include "media-server-scanner.h"
#include "media-server-device-block.h"
#include "media-server-on-demand.h"
+#ifndef _USE_DEVICED_DBUS
+#include "media-server-db-manage.h"
+#endif
#define MS_MAIN_TIMEOUT_SEC 300
#define BOOT_CHECK_FILE tzplatform_mkpath(TZ_SYS_TMP, "media_server_boot")
g_ms_on_demand_storage_list = g_slist_append(g_ms_on_demand_storage_list, new_storage);
/* request database insertion to scanner */
+#ifdef _USE_DEVICED_DBUS
ms_storage_insert_handler(block_info->mount_path, block_info->mount_uuid);
+#else
+ ms_device_handle_usb_added(block_info->mount_path);
+#endif
}
void ms_on_demand_remove_storage(gpointer data, gpointer user_data)
__ms_print_storage(block_info, "Remove");
/* request database removal to scanner */
+#ifdef _USE_DEVICED_DBUS
ms_storage_remove_handler(block_info->mount_path, block_info->mount_uuid);
+#else
+ ms_device_handle_usb_removed(block_info->mount_path);
+#endif
g_ms_on_demand_storage_list = g_slist_remove_link(g_ms_on_demand_storage_list, found);
g_slist_free_full(found, (GDestroyNotify)__ms_free_storage);
MS_DBG_FLEAVE();
}
+
+#ifdef _USE_TVPD_MODE
+void ms_on_demand_reset_storage(void)
+{
+ g_slist_free_full(g_ms_on_demand_storage_list, (GDestroyNotify)__ms_free_storage);
+ g_ms_on_demand_storage_list = NULL;
+}
+#endif