Exemplo n.º 1
0
static void
on_proxy_acquired (GObject *object, GAsyncResult *res, NMBluezDevice *self)
{
	NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
	GError *error = NULL;

	priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);

	if (!priv->proxy) {
		nm_log_warn (LOGD_BT, "bluez[%s] failed to acquire device proxy: %s.", priv->path, error->message);
		g_clear_error (&error);
		g_signal_emit (self, signals[INITIALIZED], 0, FALSE);
	} else {
		g_signal_connect (priv->proxy, "g-properties-changed",
		                  G_CALLBACK (properties_changed), self);
		if (priv->bluez_version == 4) {
			/* Watch for custom Bluez4 PropertyChanged signals */
			g_signal_connect (priv->proxy, "g-signal",
			                  G_CALLBACK (bluez4_property_changed), self);
		}

		query_properties (self);
	}
	g_object_unref (self);
}
Exemplo n.º 2
0
NMBluezAdapter *
nm_bluez_adapter_new (const char *path, NMConnectionProvider *provider)
{
	NMBluezAdapter *self;
	NMBluezAdapterPrivate *priv;
	DBusGConnection *connection;

	self = (NMBluezAdapter *) g_object_new (NM_TYPE_BLUEZ_ADAPTER,
	                                        NM_BLUEZ_ADAPTER_PATH, path,
	                                        NULL);
	if (!self)
		return NULL;

	priv = NM_BLUEZ_ADAPTER_GET_PRIVATE (self);

	priv->provider = provider;

	connection = nm_dbus_manager_get_connection (nm_dbus_manager_get ());

	priv->proxy = dbus_g_proxy_new_for_name (connection,
	                                         BLUEZ_SERVICE,
	                                         priv->path,
	                                         BLUEZ_ADAPTER_INTERFACE);

	dbus_g_proxy_add_signal (priv->proxy, "DeviceCreated",
	                         DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (priv->proxy, "DeviceCreated",
	                             G_CALLBACK (device_created), self, NULL);

	dbus_g_proxy_add_signal (priv->proxy, "DeviceRemoved",
	                         DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (priv->proxy, "DeviceRemoved",
	                             G_CALLBACK (device_removed), self, NULL);

	query_properties (self);
	return self;
}
Exemplo n.º 3
0
NMBluezDevice *
nm_bluez_device_new (const char *path)
{
	NMBluezDevice *self;
	NMBluezDevicePrivate *priv;
	NMDBusManager *dbus_mgr;
	DBusGConnection *connection;


	self = (NMBluezDevice *) g_object_new (NM_TYPE_BLUEZ_DEVICE,
	                                       NM_BLUEZ_DEVICE_PATH, path,
	                                       NULL);
	if (!self)
		return NULL;

	priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
	dbus_mgr = nm_dbus_manager_get ();
	connection = nm_dbus_manager_get_connection (dbus_mgr);

	priv->proxy = dbus_g_proxy_new_for_name (connection,
	                                         BLUEZ_SERVICE,
	                                         priv->path,
	                                         BLUEZ_DEVICE_INTERFACE);
	g_object_unref (dbus_mgr);

	dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_BOXED,
	                                   G_TYPE_NONE,
	                                   G_TYPE_STRING, G_TYPE_VALUE,
	                                   G_TYPE_INVALID);
	dbus_g_proxy_add_signal (priv->proxy, "PropertyChanged",
	                         G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
	dbus_g_proxy_connect_signal (priv->proxy, "PropertyChanged",
	                             G_CALLBACK (property_changed), self, NULL);

	query_properties (self);
	return self;
}