Esempio n. 1
0
void dls_upnp_create_container(dls_upnp_t *upnp, dls_client_t *client,
			       dls_task_t *task,
			       dls_upnp_task_complete_t cb)
{
	dls_async_task_t *cb_data = (dls_async_task_t *)task;

	DLEYNA_LOG_DEBUG("Enter");

	cb_data->cb = cb;

	DLEYNA_LOG_DEBUG("Root Path %s Id %s", task->target.root_path,
			 task->target.id);

	dls_device_create_container(client, task, task->target.id);

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 2
0
static void prv_free_cb(gpointer data)
{
	dleyna_task_queue_t *task_queue = data;

	DLEYNA_LOG_DEBUG("Enter");

	g_ptr_array_foreach(task_queue->tasks, prv_task_free_cb, task_queue);
	g_ptr_array_unref(task_queue->tasks);

	if (task_queue->task_queue_finally_cb)
		task_queue->task_queue_finally_cb(task_queue->cancelled,
						  task_queue->user_data);

	g_free(task_queue);

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 3
0
void dld_upnp_get_prop(dld_upnp_t *upnp, dld_task_t *task,
		       dld_upnp_task_complete_t cb)
{
	dld_device_t *device;

	DLEYNA_LOG_DEBUG("Enter");

	DLEYNA_LOG_DEBUG("Path: %s", task->path);
	DLEYNA_LOG_DEBUG("Interface %s", task->ut.get_prop.interface_name);
	DLEYNA_LOG_DEBUG("Prop.%s", task->ut.get_prop.prop_name);

	device = prv_get_and_check_device(upnp, task, cb);
	if (device != NULL)
		dld_device_get_prop(device, task, cb);

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 4
0
static GUPnPServiceInfo *prv_remove_bm_service_sub_devices(
						GUPnPDeviceInfo *device_info,
						dld_upnp_t *upnp,
						const gchar *ip_address)
{
	GList *child_devices;
	GList *next;
	GUPnPDeviceInfo *child_info = NULL;
	GUPnPServiceInfo *service_info = NULL;

	DLEYNA_LOG_DEBUG("Enter");

	child_devices = gupnp_device_info_list_devices(device_info);

	next = child_devices;
	while (next != NULL) {
		child_info = (GUPnPDeviceInfo *)next->data;

		service_info = gupnp_device_info_get_service(child_info,
					  DLD_BASIC_MANAGEMENT_SERVICE_TYPE);

		if (service_info != NULL)
			prv_remove_sub_device(upnp,
					      (GUPnPDeviceProxy *)child_info,
					      (GUPnPServiceProxy *)service_info,
					      ip_address);

		service_info = prv_remove_bm_service_sub_devices(child_info,
								 upnp,
								 ip_address);

		if (service_info != NULL)
			prv_remove_sub_device(upnp,
					      (GUPnPDeviceProxy *)child_info,
					      (GUPnPServiceProxy *)service_info,
					      ip_address);

		next = g_list_next(next);
	}

	g_list_free_full(child_devices, g_object_unref);

	DLEYNA_LOG_DEBUG("Exit");

	return service_info;
}
static void prv_connector_connect(
			const gchar *server_name,
			dleyna_connector_connected_cb_t connected_cb,
			dleyna_connector_disconnected_cb_t disconnected_cb)
{
	DLEYNA_LOG_DEBUG("Enter");

	g_context.connected_cb = connected_cb;
	g_context.disconnected_cb = disconnected_cb;

	g_context.owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
					    server_name,
					    G_BUS_NAME_OWNER_FLAGS_NONE,
					    prv_bus_acquired, NULL,
					    prv_name_lost, NULL, NULL);

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 6
0
static void prv_cancel(const dleyna_task_queue_key_t *queue_id,
		       dleyna_task_queue_t *task_queue)
{
	if (prv_cancel_only(queue_id, task_queue)) {
		DLEYNA_LOG_DEBUG("Removing queue <%s,%s>",
				 queue_id->source, queue_id->sink);
		g_hash_table_remove(queue_id->processor->task_queues, queue_id);
	}
}
Esempio n. 7
0
void dleyna_white_list_enable(dleyna_white_list_t *wl,
			      gboolean enabled)
{
	if (wl->gupnp_wl != NULL) {
		gupnp_white_list_set_enabled(wl->gupnp_wl, enabled);

		DLEYNA_LOG_DEBUG("White List enabled: %d", enabled);
	}
}
Esempio n. 8
0
static void prv_white_list_init(void)
{
	gboolean enabled;
	GVariant *entries;
	dleyna_white_list_t *wl;

	DLEYNA_LOG_DEBUG("Enter");

	enabled = dleyna_settings_is_white_list_enabled(g_context.settings);
	entries = dleyna_settings_white_list_entries(g_context.settings);

	wl = dld_manager_get_white_list(g_context.manager);

	dleyna_white_list_enable(wl, enabled);
	dleyna_white_list_add_entries(wl, entries);

	DLEYNA_LOG_DEBUG("Exit");
}
static guint prv_connector_publish_subtree(
				dleyna_connector_id_t connection,
				const gchar *object_path,
				const dleyna_connector_dispatch_cb_t *cb_table,
				guint cb_table_size,
				dleyna_connector_interface_filter_cb_t cb)
{
	guint flags;
	guint object_id;
	dleyna_dbus_object_t *object;
	guint *object_key;

	DLEYNA_LOG_DEBUG("Enter, path = <%s>", object_path);

	object = g_new0(dleyna_dbus_object_t, 1);

	flags = G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES;
	object_id = g_dbus_connection_register_subtree(
						(GDBusConnection *)connection,
						object_path,
						&g_subtree_vtable,
						flags,
						object,
						NULL, NULL);

	if (object_id) {
		object->id = object_id;
		object->root_path = g_strdup(object_path);
		object->dispatch_table = cb_table;
		object->dispatch_table_size = cb_table_size;
		object->filter_cb = cb;

		object_key = g_new(guint, 1);
		*object_key = object_id;
		g_hash_table_insert(g_context.objects, object_key, object);
	} else {
		g_free(object);
	}

	DLEYNA_LOG_DEBUG("Exit, object_id = %u", object_id);

	return object_id;
}
Esempio n. 10
0
void dleyna_connector_mgr_release(const dleyna_connector_t *connector)
{
	GModule *module;

	DLEYNA_LOG_DEBUG("Enter");

	module = g_hash_table_lookup(g_connectors, connector);
	if (module) {
		g_module_close(module);

		g_hash_table_remove(g_connectors, connector);
		if (g_hash_table_size(g_connectors) == 0) {
			g_hash_table_unref(g_connectors);
			g_connectors = NULL;
		}
	}

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 11
0
void dls_upnp_create_reference(dls_upnp_t *upnp, dls_client_t *client,
			       dls_task_t *task,
			       dls_upnp_task_complete_t cb)
{
	dls_async_task_t *cb_data = (dls_async_task_t *)task;

	DLEYNA_LOG_DEBUG("Enter");

	cb_data->cb = cb;

	DLEYNA_LOG_DEBUG("Root Path: %s - Id: %s", task->target.root_path,
			 task->target.id);

	dls_device_create_reference(client, task);

	DLEYNA_LOG_DEBUG("Exit");

	return;
}
Esempio n. 12
0
dleyna_task_processor_t *dleyna_task_processor_new(GSourceFunc on_quit_cb)
{
	dleyna_task_processor_t *processor;

	DLEYNA_LOG_DEBUG("Enter");

	processor = g_malloc(sizeof(*processor));

	processor->task_queues = g_hash_table_new_full(prv_key_hash_cb,
						       prv_key_equal_cb,
						       prv_key_free_cb,
						       prv_free_cb);
	processor->running_tasks = 0;
	processor->quitting = FALSE;
	processor->on_quit_cb = on_quit_cb;

	DLEYNA_LOG_DEBUG("Exit");

	return processor;
}
Esempio n. 13
0
static void prv_dump_wl_entries(GUPnPWhiteList *wl)
{
	GList *l;

	l = gupnp_white_list_get_entries(wl);

	DLEYNA_LOG_DEBUG_NL();
	DLEYNA_LOG_DEBUG("White List entries:");

	if (l != NULL) {
		while (l != NULL) {
			DLEYNA_LOG_DEBUG("     Entry: [%s].", (char *)l->data);
			l = l->next;
		}
	} else {
		DLEYNA_LOG_DEBUG("     White List Empty.");
	}

	DLEYNA_LOG_DEBUG_NL();
}
Esempio n. 14
0
void dleyna_white_list_clear(dleyna_white_list_t *wl)
{
	if (wl->gupnp_wl != NULL) {
		DLEYNA_LOG_DEBUG("Clear white list");
		gupnp_white_list_clear(wl->gupnp_wl);

#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG
		prv_dump_wl_entries(wl->gupnp_wl);
#endif
	}
}
Esempio n. 15
0
const dleyna_connector_t *dleyna_connector_mgr_load(const gchar *name)
{
	GModule *module;
	const dleyna_connector_t *connector;
	dleyna_connector_get_interface_t get_interface;
	gchar *path;

	DLEYNA_LOG_DEBUG("Enter");

	path = g_strdup_printf("%s/%s%s.so", CONNECTOR_DIR,
			       DLEYNA_CONNECTOR_LIB_PATTERN, name);
	module = g_module_open(path, G_MODULE_BIND_LAZY);
	g_free(path);

	if (module) {
		if (!g_connectors)
			g_connectors = g_hash_table_new(g_direct_hash,
							g_direct_equal);

		if (g_module_symbol(module, "dleyna_connector_get_interface",
				    (gpointer *)&get_interface)) {
			connector = get_interface();
			g_hash_table_insert(g_connectors, (gpointer)connector,
					    module);
		} else {
			connector = NULL;
			g_module_close(module);
			DLEYNA_LOG_CRITICAL(
					"Connector '%s' entry point not found",
					name);
		}

	} else {
		connector = NULL;
		DLEYNA_LOG_CRITICAL("Connector '%s' not found", name);
	}

	DLEYNA_LOG_DEBUG("Exit");

	return connector;
}
Esempio n. 16
0
static void prv_device_available_cb(GUPnPControlPoint *cp,
				    GUPnPDeviceProxy *proxy,
				    gpointer user_data)
{
	dld_upnp_t *upnp = user_data;
	const char *udn;
	const gchar *ip_address;
	GUPnPServiceProxy *bms_proxy;

	DLEYNA_LOG_DEBUG("Enter");

	udn = gupnp_device_info_get_udn((GUPnPDeviceInfo *)proxy);

	ip_address = gupnp_context_get_host_ip(
					gupnp_control_point_get_context(cp));

	if (!udn || !ip_address)
		goto on_error;

	DLEYNA_LOG_DEBUG("UDN %s", udn);
	DLEYNA_LOG_DEBUG("IP Address %s", ip_address);

	bms_proxy = (GUPnPServiceProxy *)
			gupnp_device_info_get_service(
					(GUPnPDeviceInfo *)proxy,
					DLD_BASIC_MANAGEMENT_SERVICE_TYPE);

	if (bms_proxy != NULL)
		prv_add_device(upnp, proxy, bms_proxy, ip_address, udn);

	(void) prv_add_bm_service_sub_devices((GUPnPDeviceInfo *)proxy,
					      upnp,
					      ip_address);

on_error:

	DLEYNA_LOG_DEBUG("Exit");
	DLEYNA_LOG_DEBUG_NL();

	return;
}
Esempio n. 17
0
GVariant *dlr_upnp_get_server_ids(dlr_upnp_t *upnp)
{
	GVariantBuilder vb;
	GHashTableIter iter;
	gpointer value;
	dlr_device_t *device;

	DLEYNA_LOG_DEBUG("Enter");

	g_variant_builder_init(&vb, G_VARIANT_TYPE("as"));
	g_hash_table_iter_init(&iter, upnp->server_udn_map);

	while (g_hash_table_iter_next(&iter, NULL, &value)) {
		device = value;
		g_variant_builder_add(&vb, "s", device->path);
	}

	DLEYNA_LOG_DEBUG("Exit");

	return g_variant_ref_sink(g_variant_builder_end(&vb));
}
Esempio n. 18
0
void dleyna_white_list_add_entries(dleyna_white_list_t *wl,
				   GVariant *entries)
{
	GVariantIter viter;
	gchar *entry;

	DLEYNA_LOG_DEBUG("Enter");

	if ((entries != NULL) && (wl->gupnp_wl != NULL)) {
		(void) g_variant_iter_init(&viter, entries);

		while (g_variant_iter_next(&viter, "&s", &entry))
			(void) gupnp_white_list_add_entry(wl->gupnp_wl, entry);

#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG
		prv_dump_wl_entries(wl->gupnp_wl);
#endif
	}

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 19
0
static gboolean prv_process_task(gpointer user_data)
{
	dleyna_task_queue_key_t *queue_id = user_data;
	dleyna_task_queue_t *queue;

	DLEYNA_LOG_DEBUG("Enter - Start task processing for queue <%s,%s>",
			 queue_id->source, queue_id->sink);

	queue = g_hash_table_lookup(queue_id->processor->task_queues, queue_id);

	queue->cancelled = FALSE;
	queue->idle_id = 0;
	queue->current_task = g_ptr_array_index(queue->tasks, 0);
	g_ptr_array_remove_index(queue->tasks, 0);
	queue_id->processor->running_tasks++;
	queue->task_process_cb(queue->current_task, queue->user_data);

	DLEYNA_LOG_DEBUG("Exit");

	return FALSE;
}
Esempio n. 20
0
void dls_upnp_get_prop(dls_upnp_t *upnp, dls_client_t *client,
		       dls_task_t *task,
		       dls_upnp_task_complete_t cb)
{
	gboolean root_object;
	dls_async_task_t *cb_data = (dls_async_task_t *)task;
	dls_async_get_prop_t *cb_task_data;
	dls_prop_map_t *prop_map;
	dls_task_get_prop_t *task_data;

	DLEYNA_LOG_DEBUG("Enter");

	DLEYNA_LOG_DEBUG("Path: %s", task->target.path);
	DLEYNA_LOG_DEBUG("Interface %s", task->ut.get_prop.interface_name);
	DLEYNA_LOG_DEBUG("Prop.%s", task->ut.get_prop.prop_name);

	task_data = &task->ut.get_prop;
	cb_data->cb = cb;
	cb_task_data = &cb_data->ut.get_prop;

	root_object = task->target.id[0] == '0' && task->target.id[1] == 0;

	DLEYNA_LOG_DEBUG("Root Object = %d", root_object);

	cb_task_data->protocol_info = client->protocol_info;
	prop_map = g_hash_table_lookup(upnp->filter_map, task_data->prop_name);

	dls_device_get_prop(client, task, prop_map, root_object);

	DLEYNA_LOG_DEBUG("Exit with SUCCESS");
}
Esempio n. 21
0
void dls_upnp_upload_to_any(dls_upnp_t *upnp, dls_client_t *client,
			    dls_task_t *task,
			    dls_upnp_task_complete_t cb)
{
	dls_async_task_t *cb_data = (dls_async_task_t *)task;
	dls_async_upload_t *cb_task_data;

	DLEYNA_LOG_DEBUG("Enter");

	cb_data->cb = cb;
	cb_task_data = &cb_data->ut.upload;

	DLEYNA_LOG_DEBUG("Root Path %s Id %s", task->target.root_path,
			 task->target.id);

	if (strcmp(task->target.id, "0")) {
		DLEYNA_LOG_WARNING("Bad path %s", task->target.path);

		cb_data->error =
			g_error_new(DLEYNA_SERVER_ERROR, DLEYNA_ERROR_BAD_PATH,
				    "UploadToAnyContainer must be executed on a root path");
		goto on_error;
	}

	if (!prv_compute_mime_and_class(task, cb_task_data, &cb_data->error))
		goto on_error;

	DLEYNA_LOG_DEBUG("MIME Type %s", cb_task_data->mime_type);
	DLEYNA_LOG_DEBUG("Object class %s", cb_task_data->object_class);

	dls_device_upload(client, task, "DLNA.ORG_AnyContainer");

on_error:

	if (!cb_data->action)
		(void) g_idle_add(dls_async_task_complete, cb_data);

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 22
0
static guint prv_connector_publish_object(
			dleyna_connector_id_t connection,
			const gchar *object_path,
			gboolean root,
			const gchar* interface_name,
			const dleyna_connector_dispatch_cb_t *cb_table_1)
{
	guint object_id;
	GDBusInterfaceInfo *info;
	dleyna_dbus_object_t *object;
	guint *object_key;

	DLEYNA_LOG_DEBUG("Enter, path = <%s>", object_path);

	object = g_new0(dleyna_dbus_object_t, 1);

	info = prv_find_interface_info(root, interface_name);
	object_id = g_dbus_connection_register_object(
						(GDBusConnection *)connection,
						object_path,
						info,
						&g_object_vtable,
						object, NULL, NULL);
	if (object_id) {
		object->id = object_id;
		object->dispatch_table = cb_table_1;
		object->dispatch_table_size = 1;

		object_key = g_new(guint, 1);
		*object_key = object_id;
		g_hash_table_insert(g_context.objects, object_key, object);
	} else {
		g_free(object);
	}

	DLEYNA_LOG_DEBUG("Exit, object_id = %u", object_id);

	return object_id;
}
Esempio n. 23
0
void dls_upnp_get_children(dls_upnp_t *upnp, dls_client_t *client,
			   dls_task_t *task,
			   dls_upnp_task_complete_t cb)
{
	dls_async_task_t *cb_data = (dls_async_task_t *)task;
	dls_async_bas_t *cb_task_data;
	gchar *upnp_filter = NULL;
	gchar *sort_by = NULL;

	DLEYNA_LOG_DEBUG("Enter");

	DLEYNA_LOG_DEBUG("Path: %s", task->target.path);
	DLEYNA_LOG_DEBUG("Start: %u", task->ut.get_children.start);
	DLEYNA_LOG_DEBUG("Count: %u", task->ut.get_children.count);

	cb_data->cb = cb;
	cb_task_data = &cb_data->ut.bas;

	cb_task_data->filter_mask =
		dls_props_parse_filter(upnp->filter_map,
				       task->ut.get_children.filter,
				       &upnp_filter);

	DLEYNA_LOG_DEBUG("Filter Mask 0x%"G_GUINT64_FORMAT"x",
			 cb_task_data->filter_mask);

	sort_by = dls_sort_translate_sort_string(upnp->filter_map,
						 task->ut.get_children.sort_by);
	if (!sort_by) {
		DLEYNA_LOG_WARNING("Invalid Sort Criteria");

		cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
					     DLEYNA_ERROR_BAD_QUERY,
					     "Sort Criteria are not valid");
		goto on_error;
	}

	DLEYNA_LOG_DEBUG("Sort By %s", sort_by);

	cb_task_data->protocol_info = client->protocol_info;

	dls_device_get_children(client, task, upnp_filter, sort_by);

on_error:

	if (!cb_data->action)
		(void) g_idle_add(dls_async_task_complete, cb_data);

	g_free(sort_by);
	g_free(upnp_filter);

	DLEYNA_LOG_DEBUG("Exit with %s", !cb_data->action ? "FAIL" : "SUCCESS");
}
Esempio n. 24
0
void dlr_manager_get_prop(dlr_manager_t *manager,
			  dleyna_settings_t *settings,
			  dlr_task_t *task,
			  dlr_manager_task_complete_t cb)
{
	dlr_async_task_t *cb_data = (dlr_async_task_t *)task;
	dlr_task_get_prop_t *task_data = &task->ut.get_prop;
	gchar *i_name = task_data->interface_name;
	gchar *name = task_data->prop_name;

	DLEYNA_LOG_DEBUG("Enter");
	DLEYNA_LOG_DEBUG("Path: %s", task->path);
	DLEYNA_LOG_DEBUG("Interface %s", i_name);
	DLEYNA_LOG_DEBUG("Prop.%s", name);

	cb_data->cb = cb;

	if (!strcmp(i_name, DLEYNA_SERVER_INTERFACE_MANAGER) ||
	    !strcmp(i_name, "")) {
		cb_data->task.result = prv_get_prop(settings, name);

		if (!cb_data->task.result)
			cb_data->error = g_error_new(
						DLEYNA_SERVER_ERROR,
						DLEYNA_ERROR_UNKNOWN_PROPERTY,
						"Unknown property");
	} else {
		DLEYNA_LOG_WARNING("Interface is unknown.");

		cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
					     DLEYNA_ERROR_UNKNOWN_INTERFACE,
					     "Interface is unknown.");
	}

	(void) g_idle_add(dlr_async_task_complete, cb_data);

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 25
0
static gboolean prv_cancel_cb(gpointer key, gpointer value, gpointer user_data)
{
	dleyna_task_queue_key_t *queue_id = key;
	dleyna_task_queue_t *task_queue = value;
	gboolean retval = prv_cancel_only(queue_id, task_queue);

#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG
	if (retval)
		DLEYNA_LOG_DEBUG("Removing queue <%s,%s>", queue_id->source,
				 queue_id->sink);
#endif

	return retval;
}
Esempio n. 26
0
static void prv_connector_shutdown(void)
{
	DLEYNA_LOG_DEBUG("Enter");

	if (g_context.objects)
		g_hash_table_unref(g_context.objects);

	if (g_context.clients)
		g_hash_table_unref(g_context.clients);

	prv_connector_disconnect();

	if (g_context.connection)
		g_object_unref(g_context.connection);

	if (g_context.server_node_info)
		g_dbus_node_info_unref(g_context.server_node_info);

	if (g_context.root_node_info)
		g_dbus_node_info_unref(g_context.root_node_info);

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 27
0
void dlr_upnp_remove_uri(dlr_upnp_t *upnp, dlr_task_t *task,
			 dlr_upnp_task_complete_t cb)
{
	dlr_device_t *device;
	dlr_async_task_t *cb_data = (dlr_async_task_t *)task;

	DLEYNA_LOG_DEBUG("Enter");

	device = dlr_device_from_path(task->path, upnp->server_udn_map);

	if (!device) {
		cb_data->cb = cb;
		cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
					     DLEYNA_ERROR_OBJECT_NOT_FOUND,
					     "Cannot locate a device for the specified object");

		(void) g_idle_add(dlr_async_task_complete, cb_data);
	} else {
		dlr_device_remove_uri(device, task, upnp->host_service, cb);
	}

	DLEYNA_LOG_DEBUG("Exit");
}
Esempio n. 28
0
static gboolean prv_connector_initialize(const gchar *server_info,
					 const gchar *root_info,
					 GQuark error_quark,
					 gpointer user_data)
{
	gboolean success = TRUE;

	DLEYNA_LOG_DEBUG("Enter");

	memset(&g_context, 0, sizeof(g_context));

	g_context.objects = g_hash_table_new_full(g_direct_hash, g_direct_equal,
						  g_free, prv_free_dbus_object);
	g_context.clients = g_hash_table_new_full(g_str_hash, g_str_equal,
						  g_free, NULL);

	g_context.root_node_info = g_dbus_node_info_new_for_xml(root_info,
								NULL);
	if (!g_context.root_node_info) {
		success = FALSE;
		goto out;
	}

	g_context.server_node_info = g_dbus_node_info_new_for_xml(server_info,
								  NULL);
	if (!g_context.server_node_info) {
		success = FALSE;
		goto out;
	}

	prv_connector_init_error_domain(error_quark);

out:
	DLEYNA_LOG_DEBUG("Exit");

	return success;
}
Esempio n. 29
0
static gboolean prv_connector_watch_client(const gchar *client_name)
{
	guint watch_id;
	gboolean added = TRUE;

	DLEYNA_LOG_DEBUG("Enter");

	if (g_hash_table_lookup(g_context.clients, client_name)) {
		added = FALSE;
		goto out;
	}

	watch_id = g_bus_watch_name(G_BUS_TYPE_SESSION, client_name,
				      G_BUS_NAME_WATCHER_FLAGS_NONE,
				      NULL, prv_lost_client, NULL,
				      NULL);
	g_hash_table_insert(g_context.clients, g_strdup(client_name),
			    GUINT_TO_POINTER(watch_id));

out:
	DLEYNA_LOG_DEBUG("Exit");

	return added;
}
Esempio n. 30
0
void dlr_manager_get_all_props(dlr_manager_t *manager,
			       dleyna_settings_t *settings,
			       dlr_task_t *task,
			       dlr_manager_task_complete_t cb)
{
	dlr_async_task_t *cb_data = (dlr_async_task_t *)task;
	dlr_task_get_props_t *task_data = &task->ut.get_props;
	gchar *i_name = task_data->interface_name;
	GVariantBuilder vb;

	DLEYNA_LOG_DEBUG("Enter");
	DLEYNA_LOG_DEBUG("Path: %s", task->path);
	DLEYNA_LOG_DEBUG("Interface %s", i_name);

	cb_data->cb = cb;

	g_variant_builder_init(&vb, G_VARIANT_TYPE("a{sv}"));

	if (!strcmp(i_name, DLEYNA_SERVER_INTERFACE_MANAGER) ||
	    !strcmp(i_name, "")) {
		prv_add_all_props(settings, &vb);

		cb_data->task.result = g_variant_ref_sink(
						g_variant_builder_end(&vb));
	} else {
		DLEYNA_LOG_WARNING("Interface is unknown.");

		cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
					     DLEYNA_ERROR_UNKNOWN_INTERFACE,
					     "Interface is unknown.");
	}

	(void) g_idle_add(dlr_async_task_complete, cb_data);

	DLEYNA_LOG_DEBUG("Exit");
}