Beispiel #1
0
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);
}
static void device_disable_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 disabled: %s",
				path, error->message);
		goto out;
	}

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

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

		if (connman_network_get_device(pan->network) == device) {
			DBG("disable network %p", pan->network);
			connman_device_remove_network(device, pan->network);
		}
	}

out:
	g_free(path);
}
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);
}
Beispiel #4
0
static void remove_device_networks(struct connman_device *device)
{
	GHashTableIter iter;
	gpointer key, value;
	GSList *key_list = NULL;
	GSList *list;

	if (bluetooth_networks == NULL)
		return;

	g_hash_table_iter_init(&iter, bluetooth_networks);

	while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
		struct connman_network *network = value;

		if (connman_network_get_device(network) != device)
			continue;

		key_list = g_slist_prepend(key_list, key);
	}

	for (list = key_list; list != NULL; list = list->next) {
		const char *network_path = list->data;

		g_hash_table_remove(bluetooth_networks, network_path);
	}

	g_slist_free(key_list);
}
Beispiel #5
0
static gboolean device_removed(DBusConnection *conn,
				DBusMessage *message, void *user_data)
{
	const char *network_path;
	struct connman_network *network;
	struct connman_device *device;
	DBusMessageIter iter;

	DBG("");

	if (dbus_message_iter_init(message, &iter) == FALSE)
		return TRUE;

	dbus_message_iter_get_basic(&iter, &network_path);

	network = g_hash_table_lookup(bluetooth_networks, network_path);
	if (network == NULL)
		return TRUE;

	device = connman_network_get_device(network);
	if (device == NULL)
		return TRUE;

	g_hash_table_remove(bluetooth_networks, network_path);

	return TRUE;
}
Beispiel #6
0
static void remove_network(gpointer data)
{
	struct connman_network *network = data;
	struct connman_device *device;

	DBG("network %p", network);

	device = connman_network_get_device(network);
	if (device != NULL)
		connman_device_remove_network(device, network);

	connman_network_unref(network);
}
Beispiel #7
0
static int network_probe(struct connman_network *network)
{
	struct connman_device *device = connman_network_get_device(network);
	struct mbm_data *data;

	_DBG_MBM("network %p", network);

	data = connman_device_get_data(device);
	connman_network_set_data(network, data);

	g_at_chat_send(data->chat, "AT+CGDCONT=1,\"IP\",\"internet.com\"",
					NULL, generic_callback, NULL, NULL);

	g_at_chat_send(data->chat, "AT*ENAP?", NULL,
					generic_callback, NULL, NULL);

	return 0;
}
Beispiel #8
0
static void disable_device(struct connman_device *device, const char *path)
{
	GHashTableIter iter;
	gpointer key, value;

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

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

		if (pan->network && connman_network_get_device(pan->network)
				== device) {
			DBG("disable network %p", pan->network);
			connman_device_remove_network(device, pan->network);
		}
	}
}
Beispiel #9
0
static void pan_remove_nap(struct bluetooth_pan *pan)
{
	struct connman_device *device;
	struct connman_network *network = pan->network;

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

	if (!network)
		return;

	pan->network = NULL;
	connman_network_set_data(network, NULL);

	device = connman_network_get_device(network);
	if (device)
		connman_device_remove_network(device, network);

	connman_network_unref(network);
}