static void device_proxy_new_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GUPnPNetworkManager *manager; GDBusProxy *device_proxy; NMDevice *nm_device = NULL; NMDeviceType type; GVariant *value; GError *error; error = NULL; device_proxy = g_dbus_proxy_new_for_bus_finish (res, &error); if (G_UNLIKELY (error != NULL)) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_message ("Failed to create D-Bus proxy: %s", error->message); g_error_free (error); goto done; } manager = GUPNP_NETWORK_MANAGER (user_data); value = g_dbus_proxy_get_cached_property (device_proxy, "DeviceType"); if (G_UNLIKELY (value == NULL)) { goto done; } if (G_UNLIKELY (!g_variant_is_of_type (value, G_VARIANT_TYPE_UINT32))) { g_variant_unref (value); goto done; } type = g_variant_get_uint32 (value); g_variant_unref (value); nm_device = nm_device_new (manager, device_proxy); if (type == NM_DEVICE_TYPE_WIFI) { const char *path; path = g_dbus_proxy_get_object_path (nm_device->proxy); g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, DBUS_SERVICE_NM, path, WIFI_INTERFACE, manager->priv->cancellable, wifi_proxy_new_cb, nm_device_ref (nm_device)); } else use_new_device (manager, nm_device); done: g_clear_pointer (&nm_device, (GDestroyNotify) nm_device_unref); g_clear_object (&device_proxy); }
static void wifi_proxy_new_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { NMDevice *nm_device; GError *error; nm_device = (NMDevice *) user_data; error = NULL; nm_device->wifi_proxy = g_dbus_proxy_new_for_bus_finish (res, &error); if (G_UNLIKELY (error != NULL)) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_message ("Failed to create D-Bus proxy: %s", error->message); else nm_device->manager = NULL; g_error_free (error); goto done; } use_new_device (nm_device->manager, nm_device); done: nm_device_unref (nm_device); }
static void wifi_proxy_new_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { NMDevice *nm_device; GError *error; nm_device = (NMDevice *) user_data; error = NULL; nm_device->wifi_proxy = g_dbus_proxy_new_for_bus_finish (res, &error); if (G_UNLIKELY (error != NULL)) { g_message ("Failed to create D-Bus proxy: %s", error->message); g_error_free (error); } use_new_device (nm_device->manager, nm_device); }