Ejemplo n.º 1
0
MMBearerProperties *
mm_bearer_properties_dup (MMBearerProperties *orig)
{
    GVariant *dict;
    MMBearerProperties *copy;
    GError *error = NULL;

    g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (orig), NULL);

    dict = mm_bearer_properties_get_dictionary (orig);
    copy = mm_bearer_properties_new_from_dictionary (dict, &error);
    g_assert_no_error (error);
    g_variant_unref (dict);

    return copy;
}
Ejemplo n.º 2
0
static void
ensure_internal_properties (MMBearer *self,
                            MMBearerProperties **dup)
{
    g_mutex_lock (&self->priv->properties_mutex);
    {
        /* If this is the first time ever asking for the object, setup the
         * update listener and the initial object, if any. */
        if (!self->priv->properties_id) {
            GVariant *dictionary;

            dictionary = mm_gdbus_bearer_dup_properties (MM_GDBUS_BEARER (self));
            if (dictionary) {
                GError *error = NULL;

                self->priv->properties = mm_bearer_properties_new_from_dictionary (dictionary, &error);
                if (error) {
                    g_warning ("Invalid initial bearer properties: %s", error->message);
                    g_error_free (error);
                }
                g_variant_unref (dictionary);
            }

            /* No need to clear this signal connection when freeing self */
            self->priv->properties_id =
                g_signal_connect (self,
                                  "notify::properties",
                                  G_CALLBACK (properties_updated),
                                  NULL);
        }

        if (dup && self->priv->properties)
            *dup = g_object_ref (self->priv->properties);
    }
    g_mutex_unlock (&self->priv->properties_mutex);
}
Ejemplo n.º 3
0
static void
properties_updated (MMBearer *self,
                    GParamSpec *pspec)
{
    g_mutex_lock (&self->priv->properties_mutex);
    {
        GVariant *dictionary;

        g_clear_object (&self->priv->properties);

        /* TODO: update existing object instead of re-creating? */
        dictionary = mm_gdbus_bearer_get_properties (MM_GDBUS_BEARER (self));
        if (dictionary) {
            GError *error = NULL;

            self->priv->properties = mm_bearer_properties_new_from_dictionary (dictionary, &error);
            if (error) {
                g_warning ("Invalid bearer properties received: %s", error->message);
                g_error_free (error);
            }
        }
    }
    g_mutex_unlock (&self->priv->properties_mutex);
}