예제 #1
0
static void
on_wifi_device_activated (NMDevice *nm_device)
{
        GVariant *value;
        const char *ap_path;

        value = g_dbus_proxy_get_cached_property (nm_device->wifi_proxy,
                                                  "ActiveAccessPoint");
        if (G_UNLIKELY (value == NULL))
                return;

        if (G_UNLIKELY (!g_variant_is_of_type (value,
                                               G_VARIANT_TYPE_OBJECT_PATH))) {
                g_variant_unref (value);

                return;
        }

        ap_path = g_variant_get_string (value, NULL);
        if (G_UNLIKELY (ap_path == NULL))
                create_context_for_device (nm_device);
        else {
                g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
                                          G_DBUS_PROXY_FLAGS_NONE,
                                          NULL,
                                          DBUS_SERVICE_NM,
                                          ap_path,
                                          AP_INTERFACE,
                                          nm_device->manager->priv->cancellable,
                                          ap_proxy_new_cb,
                                          nm_device);
	}

        g_variant_unref (value);
}
static void
ap_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->ap_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;
        }

        create_context_for_device (nm_device);

done:
        nm_device_unref (nm_device);
}
예제 #3
0
static void
on_device_activated (NMDevice *nm_device)
{
        if (nm_device->wifi_proxy != NULL)
                on_wifi_device_activated (nm_device);
        else
                create_context_for_device (nm_device);
}
예제 #4
0
static void
ap_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->ap_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);
        }

        create_context_for_device (nm_device);
}
예제 #5
0
static void
get_device_interface_cb (DBusGProxy     *proxy,
                         DBusGProxyCall *call,
                         void           *user_data)
{
        GValue value = {0,};
        GError *error = NULL;
        NMDevice *nm_device = (NMDevice *) user_data;

        if (!dbus_g_proxy_end_call (nm_device->prop_proxy,
                                    call,
                                    &error,
                                    G_TYPE_VALUE, &value,
                                    G_TYPE_INVALID)) {
                g_warning ("Error reading property from object: %s\n",
                           error->message);

                g_error_free (error);
                return;
        }

        create_context_for_device (nm_device, g_value_get_string (&value));
        g_value_unset (&value);
}