#include "media-common-db-svc.h"
#include "media-common-system.h"
+#ifdef _USE_TVPD_MODE
+static int __ms_sys_subscribe_device_block_event(usb_connected_cb usr_callback, void *usr_data)
+{
+ MS_DBG_FENTER();
+
+ usb_device_init();
+ usb_set_connected_cb(usr_callback, usr_data);
+
+ MS_DBG_FLEAVE();
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int ms_sys_set_device_block_event_cb(usb_connected_cb usr_callback, void *usr_data)
+{
+ MS_DBG_FENTER();
+
+ return __ms_sys_subscribe_device_block_event(usr_callback, usr_data);
+}
+
+void ms_sys_unset_device_block_event_cb(void)
+{
+ usb_device_fini();
+}
+
+int ms_sys_get_device_list(GSList **dev_list)
+{
+ int i = 0;
+ int count = 0;
+ int err = 0;
+ usb_device_list_h list;
+ usb_device_h device;
+ char *mount_path = NULL;
-//////////////////////////////////////////////////////////////////////////////
-/// CHECK THE EXTERNAL STORATE STATE
-//////////////////////////////////////////////////////////////////////////////
-#ifdef _USE_DEVICED_DBUS
+ err = usb_device_get_device_list(USB_MASS_STORAGE, &list);
+ MS_DBG_RETVM_IF(err != 0, MS_MEDIA_ERR_INTERNAL, "usb_device_get_device_list failed [%d]", err);
+
+ count = usb_device_list_get_count(list);
+ if (count > 0) {
+ for (i = 0; i < count; i++) {
+ if (i == 0) {
+ 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)
+ MS_DBG_SWARN("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)
+ MS_DBG_SWARN("mount_path [%s]", mount_path);
+ }
+ }
+
+ char *storage_id = NULL;
+ ms_block_info_s *data = NULL;
+
+ err = ms_get_added_storage_path(mount_path, &storage_id);
+ if ((err == MS_MEDIA_ERR_NONE) && (storage_id != NULL)) {
+ data = g_new0(ms_block_info_s, 1);
+ data->mount_path = g_strdup(mount_path);
+ data->mount_uuid = storage_id;
+ *dev_list = g_slist_append(*dev_list, data);
+ } else {
+ MS_DBG_ERR("ms_get_added_stroage_path failed [%d]", err);
+ }
+ }
+ }
+
+ usb_device_free_device_list(list);
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+device_changed_cb g_user_callback;
+
+int ms_sys_set_poweroff_cb(device_changed_cb user_callback, void *user_data)
+{
+ MS_DBG_FENTER();
+ device_power_subscribe_standby(user_callback, user_data);
+ g_user_callback = user_callback;
+ MS_DBG_FLEAVE();
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+void ms_sys_unset_poweroff_cb(void)
+{
+ device_power_unsubscribe_standby(g_user_callback);
+ g_user_callback = NULL;
+}
+#else /*_USE_TVPD_MODE*/
#define DEVICED_BUS_NAME "org.tizen.system.storage"
#define DEVICED_PATH "/Org/Tizen/System/Storage/Block/Manager"
#define DEVICED_INTERFACE DEVICED_BUS_NAME".BlockManager"
(g_storage_cb_data.usr_cb)(&block_info, g_storage_cb_data.usr_data);
}
-#endif
-#ifdef _USE_DEVICED_DBUS
static int __ms_sys_subscribe_device_block_event(block_changed_cb usr_callback, void *usr_data)
{
GError *error = NULL;
return MS_MEDIA_ERR_NONE;
}
-#else
-static int __ms_sys_subscribe_device_block_event(usb_connected_cb usr_callback, void *usr_data)
-{
- MS_DBG_FENTER();
-
- usb_device_init();
- usb_set_connected_cb(usr_callback, usr_data);
- MS_DBG_FLEAVE();
-
- return MS_MEDIA_ERR_NONE;
-}
-#endif
-
-#ifdef _USE_DEVICED_DBUS
int ms_sys_set_device_block_event_cb(block_changed_cb usr_callback, void *usr_data)
{
MS_DBG_FENTER();
return __ms_sys_subscribe_device_block_event(usr_callback, usr_data);
}
-#else
-int ms_sys_set_device_block_event_cb(usb_connected_cb usr_callback, void *usr_data)
-{
- MS_DBG_FENTER();
-
- return __ms_sys_subscribe_device_block_event(usr_callback, usr_data);
-}
-#endif
-#ifdef _USE_DEVICED_DBUS
void ms_sys_unset_device_block_event_cb(void)
{
if (!g_storage_bus)
g_object_unref(g_storage_bus);
g_storage_bus = NULL;
}
-#else
-void ms_sys_unset_device_block_event_cb(void)
-{
- usb_device_fini();
-}
-#endif
-#ifdef _USE_DEVICED_DBUS
int ms_sys_get_device_list(GSList **dev_list)
{
GDBusConnection *g_bus = NULL;
return MS_MEDIA_ERR_NONE;
}
-#else
-int ms_sys_get_device_list(GSList **dev_list)
-{
- int i = 0;
- int count = 0;
- int err = 0;
- usb_device_list_h list;
- usb_device_h device;
- char *mount_path = NULL;
-
- err = usb_device_get_device_list(USB_MASS_STORAGE, &list);
- MS_DBG_RETVM_IF(err != 0, MS_MEDIA_ERR_INTERNAL, "usb_device_get_device_list failed [%d]", err);
-
- count = usb_device_list_get_count(list);
- if (count > 0) {
- for (i = 0; i < count; i++) {
- if (i == 0) {
- 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)
- MS_DBG_SWARN("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)
- MS_DBG_SWARN("mount_path [%s]", mount_path);
- }
- }
- char *storage_id = NULL;
- ms_block_info_s *data = NULL;
-
- err = ms_get_added_storage_path(mount_path, &storage_id);
- if ((err == MS_MEDIA_ERR_NONE) && (storage_id != NULL)) {
- data = g_new0(ms_block_info_s, 1);
- data->mount_path = g_strdup(mount_path);
- data->mount_uuid = storage_id;
- *dev_list = g_slist_append(*dev_list, data);
- } else {
- MS_DBG_ERR("ms_get_added_stroage_path failed [%d]", err);
- }
- }
- }
-
- usb_device_free_device_list(list);
-
- return MS_MEDIA_ERR_NONE;
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-/// GET ACTIVATE USER ID
-//////////////////////////////////////////////////////////////////////////////
-int ms_sys_get_uid(uid_t *uid)
-{
- uid_t *list = NULL;
- int users = -1;
- users = sd_get_uids(&list);
- if (users > 0) {
- *uid = list[0];
- MS_SAFE_FREE(list);
- } else {
- MS_DBG_ERR("No login user!.");
- MS_SAFE_FREE(list);
- return MS_MEDIA_ERR_INTERNAL;
- }
- return MS_MEDIA_ERR_NONE;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-/// CHECK THE POWER STATE
-//////////////////////////////////////////////////////////////////////////////
-#ifdef _USE_DEVICED_DBUS
#define POWER_DBUS_NAME "ChangeState"
#define POWER_DBUS_PATH "/Org/Tizen/System/DeviceD/PowerOff"
#define POWER_DBUS_INTERFACE "org.tizen.system.deviced.PowerOff"
return MS_MEDIA_ERR_NONE;
}
-#else
-device_changed_cb g_user_callback;
-
-int ms_sys_set_poweroff_cb(device_changed_cb user_callback, void *user_data)
-{
- MS_DBG_FENTER();
- device_power_subscribe_standby(user_callback, user_data);
- g_user_callback = user_callback;
- MS_DBG_FLEAVE();
-
- return MS_MEDIA_ERR_NONE;
-}
-#endif
void ms_sys_unset_poweroff_cb(void)
{
-#ifdef _USE_DEVICED_DBUS
if (!g_power_bus)
return;
g_power_bus = NULL;
g_free(g_power_cb_data);
-#else
- device_power_unsubscribe_standby(g_user_callback);
- g_user_callback = NULL;
-#endif
}
+#endif /*_USE_TVPD_MODE*/
+int ms_sys_get_uid(uid_t *uid)
+{
+ uid_t *list = NULL;
+ int users = -1;
+ users = sd_get_uids(&list);
+ if (users > 0) {
+ *uid = list[0];
+ MS_SAFE_FREE(list);
+ } else {
+ MS_DBG_ERR("No login user!.");
+ MS_SAFE_FREE(list);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ return MS_MEDIA_ERR_NONE;
+}
#include "media-server-scanner.h"
#include "media-server-db-manage.h"
#include "media-server-device-block.h"
+
#ifdef _USE_TVPD_MODE
#include <media-util-noti.h>
#define PROD_CUSTOM_MIME_ADDED "1"
ms_disconnect_db(handle);
}
-
}
-#ifdef _USE_DEVICED_DBUS
-void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
-{
- MS_DBG_WARN("GET EXTERNAL EVENT");
- if (block_info->mount_path != NULL && block_info->mount_uuid != NULL) {
- MS_DBG("uuid[%s] path[%s]", block_info->mount_uuid, block_info->mount_path);
-
- if (block_info->state == MS_STG_INSERTED)
- ms_storage_insert_handler(block_info->mount_path, block_info->mount_uuid);
- else if (block_info->state == MS_STG_REMOVED)
- ms_storage_remove_handler(block_info->mount_path, block_info->mount_uuid);
- } else {
- MS_DBG_ERR("mount_path or mount_uuid is NULL");
- }
-}
-#else
+#ifdef _USE_TVPD_MODE
static void __ms_usb_add_event(const char *mount_path)
{
int ret = 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");
-#ifdef _USE_TVPD_MODE
media_db_update_send(getpid(), MS_MEDIA_ITEM_STORAGE, MS_MEDIA_ITEM_UPDATE, mount_path, storage_id, MS_MEDIA_UNKNOWN, PROD_CUSTOM_MIME_ADDED);
-#endif
} else {
/* there is no information of this storage in Media DB */
ret = ms_insert_storage(handle, storage_id, mount_path, uid);
-#ifdef _USE_TVPD_MODE
+
media_db_update_send(getpid(), MS_MEDIA_ITEM_STORAGE, MS_MEDIA_ITEM_INSERT, mount_path, storage_id, MS_MEDIA_UNKNOWN, PROD_CUSTOM_MIME_ADDED);
-#endif
}
} else {
MS_DBG_ERR("STORAGE ID IS NUILL");
/*So try to remove it.*/
ms_send_storage_otg_scan_request(mount_path, device_id, MS_SCAN_INVALID, uid);
}
-#ifdef _USE_TVPD_MODE
+
media_db_update_send(getpid(), MS_MEDIA_ITEM_STORAGE, MS_MEDIA_ITEM_UPDATE, mount_path, device_id, MS_MEDIA_UNKNOWN, PROD_CUSTOM_MIME_REMOVED);
-#endif
}
ms_disconnect_db(handle);
return ret;
}
-#endif
+#else /*_USE_TVPD_MODE*/
+void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
+{
+ MS_DBG_WARN("GET EXTERNAL EVENT");
+ if (block_info->mount_path != NULL && block_info->mount_uuid != NULL) {
+ MS_DBG("uuid[%s] path[%s]", block_info->mount_uuid, block_info->mount_path);
+
+ if (block_info->state == MS_STG_INSERTED)
+ ms_storage_insert_handler(block_info->mount_path, block_info->mount_uuid);
+ else if (block_info->state == MS_STG_REMOVED)
+ ms_storage_remove_handler(block_info->mount_path, block_info->mount_uuid);
+ } else {
+ MS_DBG_ERR("mount_path or mount_uuid is NULL");
+ }
+}
+#endif /*_USE_TVPD_MODE*/