コード例 #1
0
static void
mtn_connman_service_g_signal (GDBusProxy   *proxy,
                              const gchar  *sender_name,
                              const gchar  *signal_name,
                              GVariant     *parameters)
{
    MtnConnmanService *service = MTN_CONNMAN_SERVICE (proxy);

    if (!service->priv->properties)
        return;

    if (g_strcmp0 (signal_name, "PropertyChanged") == 0) {
        char *key;
        GVariant *value;

        g_variant_get (parameters, "(sv)", &key, &value);
        if (g_strcmp0 (key, "PassphraseRequested") == 0) {
            /* get the new Passphrase value before emitting signal
             * (because there is no signal for Passphrase) */
            g_dbus_proxy_call (proxy,
                               "GetProperties",
                               NULL,
                               G_DBUS_CALL_FLAGS_NONE,
                               -1,
                               NULL,
                               _get_properties_for_passphrase_cb,
                               NULL);
        } else {
           mtn_connman_service_handle_new_property (service, key, value);
        }
    }
}
コード例 #2
0
static void
_get_properties_for_passphrase_cb (GObject      *obj,
                                   GAsyncResult *res,
                                   gpointer      user_data)
{
    MtnConnmanService *service;
    GError *error;
    GVariant *var;

    service = MTN_CONNMAN_SERVICE (obj);

    error = NULL;
    var = g_dbus_proxy_call_finish (G_DBUS_PROXY (obj), res, &error);
    if (!var) {
        g_warning ("Connman Service.GetProperties failed: %s", 
                   error->message);
        g_error_free (error);
    } else {
        GVariant *value;
        char *key;
        GVariantIter *iter;
        
        g_variant_get (var, "(a{sv})", &iter);
        while (g_variant_iter_next (iter, "{sv}", &key, &value)) {
            if (g_strcmp0 (key, "Passphrase") == 0 ||
                g_strcmp0 (key, "PassphraseRequired") == 0) {
                mtn_connman_service_handle_new_property (service,
                                                         key, value);
            }
        }
        g_variant_iter_free (iter);
        g_variant_unref (var);
    }
}
コード例 #3
0
static void
mtn_connman_service_dispose (GObject *object)
{
    MtnConnmanService *service;

    service = MTN_CONNMAN_SERVICE (object);

    if (service->priv->properties) {
        g_hash_table_unref (service->priv->properties);
        service->priv->properties = NULL;
    }

    G_OBJECT_CLASS (mtn_connman_service_parent_class)->dispose (object);
}
コード例 #4
0
static gboolean
mtn_connman_service_initable_init_sync (GInitable     *initable,
                                        GCancellable  *cancellable,
                                        GError       **error)
{
    GInitableIface *iface_class, *parent_iface_class;
    GVariant *var, *value;
    GVariantIter *iter;
    char *key;
    MtnConnmanService *service;

    service = MTN_CONNMAN_SERVICE (initable);

    /* Chain up the old method */
    iface_class = G_INITABLE_GET_IFACE (initable);
    parent_iface_class = g_type_interface_peek_parent (iface_class);
    if (!parent_iface_class->init (initable, cancellable, error)) {
        return FALSE;
    }

    g_signal_connect (service, "notify::g-name-owner",
                      G_CALLBACK (_name_owner_notify_cb), NULL);

    var = g_dbus_proxy_call_sync (G_DBUS_PROXY (service),
                                  "GetProperties",
                                  NULL,
                                  G_DBUS_CALL_FLAGS_NONE,
                                  -1,
                                  NULL,
                                  error);
    if (!var) {
        g_debug ("Service has no properties?!");
        return FALSE;
    }

    g_variant_get (var, "(a{sv})", &iter);
    while (g_variant_iter_next (iter, "{sv}", &key, &value)) {
        g_debug ("Got Service property %s", key);
        g_hash_table_insert (service->priv->properties,
                             key, value);
    }
    g_variant_iter_free (iter);
    g_variant_unref (var);

    return TRUE;
}
コード例 #5
0
static void
_get_properties_cb (GObject      *obj,
                    GAsyncResult *res,
                    gpointer      user_data)
{
    MtnConnmanService *service;
    GError *error;
    GVariant *var;
    InitData *data;

    service = MTN_CONNMAN_SERVICE (obj);
    data = (InitData*)user_data;

    error = NULL;
    var = g_dbus_proxy_call_finish (G_DBUS_PROXY (obj), res, &error);
    if (!var) {
        g_warning ("Initial Service.GetProperties() failed: %s\n",
                   error->message);
        g_error_free (error);
    } else {
        GVariant *value;
        char *key;
        GVariantIter *iter;
        
        g_variant_get (var, "(a{sv})", &iter);
        while (g_variant_iter_next (iter, "{sv}", &key, &value)) {
            g_hash_table_insert (service->priv->properties,
                                 key, value);
        }
        g_variant_iter_free (iter);
        g_variant_unref (var);
    }

    g_simple_async_result_complete_in_idle (data->res);
    init_data_free (data);
}
コード例 #6
0
MtnConnmanService *
mtn_connman_service_new_finish (GAsyncResult  *res,
                                GError       **error)
{
    return MTN_CONNMAN_SERVICE (g_dbus_proxy_new_finish (res, error));
}