コード例 #1
0
ファイル: bluetooth.c プロジェクト: igaw/connman
static void pan_create(GDBusProxy *network_proxy)
{
	const char *path = g_dbus_proxy_get_path(network_proxy);
	struct bluetooth_pan *pan;

	pan = g_try_new0(struct bluetooth_pan, 1);

	if (!pan) {
		connman_error("Out of memory creating PAN NAP");
		return;
	}

	g_hash_table_replace(networks, g_strdup(path), pan);

	pan->btnetwork_proxy = g_dbus_proxy_ref(network_proxy);
	pan->btdevice_proxy = g_dbus_proxy_new(client, path,
			"org.bluez.Device1");

	if (!pan->btdevice_proxy) {
		connman_error("Cannot create BT PAN watcher %s", path);
		g_hash_table_remove(networks, path);
		return;
	}

	g_dbus_proxy_set_property_watch(pan->btnetwork_proxy,
			btnetwork_property_change, NULL);

	g_dbus_proxy_set_property_watch(pan->btdevice_proxy,
			btdevice_property_change, NULL);

	DBG("pan %p %s role %s", pan, path, proxy_get_role(pan->btdevice_proxy));

	pan_create_nap(pan);
}
コード例 #2
0
ファイル: bluetooth.c プロジェクト: igaw/connman
static void btdevice_property_change(GDBusProxy *proxy, const char *name,
		DBusMessageIter *iter, void *user_data)
{
	struct bluetooth_pan *pan;
	const char *old_role = NULL;
	const char *new_role;

	if (strcmp(name, "UUIDs"))
		return;

	pan = g_hash_table_lookup(networks, g_dbus_proxy_get_path(proxy));
	if (!pan)
		return;

	if (pan->network &&
			connman_network_get_device(pan->network))
		old_role = pan->pan_role;
	new_role = proxy_get_role(pan->btdevice_proxy);

	DBG("network %p network role %s proxy role %s", pan->network, old_role,
			new_role);

	if (old_role && new_role && !strcmp(old_role, new_role))
		return;

	pan_create_nap(pan);
}
コード例 #3
0
static void btdevice_property_change(GDBusProxy *proxy, const char *name,
		DBusMessageIter *iter, void *user_data)
{
	struct bluetooth_pan *pan;
	connman_bool_t pan_nap = FALSE;

	if (strcmp(name, "UUIDs") != 0)
		return;

	pan = g_hash_table_lookup(networks, g_dbus_proxy_get_path(proxy));
	if (pan == NULL)
		return;

	if (pan->network != NULL &&
			connman_network_get_device(pan->network) != NULL)
		pan_nap = TRUE;

	DBG("network %p network nap %d proxy nap %d", pan->network, pan_nap,
			proxy_get_nap(pan->btdevice_proxy));

	if (proxy_get_nap(pan->btdevice_proxy) == pan_nap)
		return;

	pan_create_nap(pan);
}
コード例 #4
0
ファイル: bluetooth.c プロジェクト: igaw/connman
static void enable_device(struct connman_device *device, const char *path)
{
	GHashTableIter iter;
	gpointer key, value;

	DBG("device %p %s", device, path);
	connman_device_set_powered(device, true);

	g_hash_table_iter_init(&iter, networks);
	while (g_hash_table_iter_next(&iter, &key, &value)) {
		struct bluetooth_pan *pan = value;

		if (g_strcmp0(proxy_get_string(pan->btdevice_proxy, "Adapter"),
						path) == 0) {

			DBG("enable network %p", pan->network);
			pan_create_nap(pan);
		}
	}
}
コード例 #5
0
static void device_enable_cb(const DBusError *error, void *user_data)
{
	char *path = user_data;
	struct connman_device *device;
	GHashTableIter iter;
	gpointer key, value;

	device = g_hash_table_lookup(devices, path);
	if (device == NULL) {
		DBG("device already removed");
		goto out;
	}

	if (dbus_error_is_set(error) == TRUE) {
		connman_warn("Bluetooth device %s not enabled %s",
				path, error->message);
		goto out;
	}

	DBG("device %p %s", device, path);

	connman_device_set_powered(device, TRUE);

	g_hash_table_iter_init(&iter, networks);
	while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
		struct bluetooth_pan *pan = value;

		if (g_strcmp0(proxy_get_string(pan->btdevice_proxy, "Adapter"),
						path) == 0) {

			DBG("enable network %p", pan->network);
			pan_create_nap(pan);
		}
	}

out:
	g_free(path);
}