コード例 #1
0
ファイル: manager.c プロジェクト: AazibSafi/pwn_plug_sources
static void manager_remove_adapter(struct btd_adapter *adapter)
{
	uint16_t dev_id = adapter_get_dev_id(adapter);
	const gchar *path = adapter_get_path(adapter);

	adapters = g_slist_remove(adapters, adapter);

	manager_update_adapters();

	if (default_adapter_id == dev_id || default_adapter_id < 0) {
		int new_default = hci_get_route(NULL);

		manager_set_default_adapter(new_default);
	}

	g_dbus_emit_signal(connection, "/",
			MANAGER_INTERFACE, "AdapterRemoved",
			DBUS_TYPE_OBJECT_PATH, &path,
			DBUS_TYPE_INVALID);

	adapter_remove(adapter);
	btd_adapter_unref(adapter);

	if (adapters == NULL)
		btd_start_exit_timer();
}
コード例 #2
0
ファイル: manager.c プロジェクト: AazibSafi/pwn_plug_sources
void manager_add_adapter(const char *path)
{
	g_dbus_emit_signal(connection, "/",
				MANAGER_INTERFACE, "AdapterAdded",
				DBUS_TYPE_OBJECT_PATH, &path,
				DBUS_TYPE_INVALID);

	manager_update_adapters();

	btd_stop_exit_timer();
}
コード例 #3
0
ファイル: manager.c プロジェクト: derekisbusy/AnyController
struct btd_adapter *btd_manager_register_adapter(int id, gboolean up)
{
	struct btd_adapter *adapter;
	const char *path;

	adapter = manager_find_adapter_by_id(id);
	if (adapter) {
		error("Unable to register adapter: hci%d already exist", id);
		return NULL;
	}

	adapter = adapter_create(connection, id);
	if (!adapter)
		return NULL;

	adapters = g_slist_append(adapters, adapter);

	if (!adapter_init(adapter, up)) {
		adapters = g_slist_remove(adapters, adapter);
		btd_adapter_unref(adapter);
		return NULL;
	}

	path = adapter_get_path(adapter);
	g_dbus_emit_signal(connection, "/",
				MANAGER_INTERFACE, "AdapterAdded",
				DBUS_TYPE_OBJECT_PATH, &path,
				DBUS_TYPE_INVALID);

	manager_update_adapters();

	btd_stop_exit_timer();

	if (default_adapter_id < 0)
		manager_set_default_adapter(id);

	if (main_opts.did_source)
		btd_adapter_set_did(adapter, main_opts.did_vendor,
						main_opts.did_product,
						main_opts.did_version,
						main_opts.did_source);

	DBG("Adapter %s registered", path);

	return btd_adapter_ref(adapter);
}