コード例 #1
0
static void
mm_simple_connect_properties_init (MMSimpleConnectProperties *self)
{
    self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
                                              MM_TYPE_SIMPLE_CONNECT_PROPERTIES,
                                              MMSimpleConnectPropertiesPrivate);

    /* Some defaults */
    self->priv->bearer_properties = mm_bearer_properties_new ();
    self->priv->allowed_modes = MM_MODEM_MODE_ANY;
    self->priv->preferred_mode = MM_MODEM_MODE_NONE;
    self->priv->bands = g_new (MMModemBand, 1);
    self->priv->bands[0] = MM_MODEM_BAND_ANY;
    self->priv->n_bands = 1;
}
コード例 #2
0
static MMBearerProperties *
expose_properties (MMBearer *self)
{
    MMBroadbandBearerHso *hso = MM_BROADBAND_BEARER_HSO (self);
    MMBearerProperties *properties;

    properties = mm_bearer_properties_new ();
    mm_bearer_properties_set_apn (properties,
                                  mm_broadband_bearer_get_3gpp_apn (MM_BROADBAND_BEARER (self)));
    mm_bearer_properties_set_ip_type (properties,
                                      mm_broadband_bearer_get_ip_type (MM_BROADBAND_BEARER (self)));
    mm_bearer_properties_set_allow_roaming (properties,
                                            mm_broadband_bearer_get_allow_roaming (MM_BROADBAND_BEARER (self)));
    mm_bearer_properties_set_user (properties, hso->priv->user);
    mm_bearer_properties_set_password (properties, hso->priv->user);
    return properties;
}
コード例 #3
0
MMBearerProperties *
mm_bearer_properties_new_from_dictionary (GVariant *dictionary,
                                          GError **error)
{
    GError *inner_error = NULL;
    GVariantIter iter;
    gchar *key;
    GVariant *value;
    MMBearerProperties *properties;

    properties = mm_bearer_properties_new ();
    if (!dictionary)
        return properties;

    if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) {
        g_set_error (error,
                     MM_CORE_ERROR,
                     MM_CORE_ERROR_INVALID_ARGS,
                     "Cannot create Bearer properties from dictionary: "
                     "invalid variant type received");
        g_object_unref (properties);
        return NULL;
    }

    g_variant_iter_init (&iter, dictionary);
    while (!inner_error &&
           g_variant_iter_next (&iter, "{sv}", &key, &value)) {
        mm_bearer_properties_consume_variant (properties,
                                                     key,
                                                     value,
                                                     &inner_error);
        g_free (key);
        g_variant_unref (value);
    }

    /* If error, destroy the object */
    if (inner_error) {
        g_propagate_error (error, inner_error);
        g_object_unref (properties);
        properties = NULL;
    }

    return properties;
}
コード例 #4
0
MMBearerProperties *
mm_bearer_properties_new_from_string (const gchar *str,
                                      GError **error)
{
    ParseKeyValueContext ctx;

    ctx.error = NULL;
    ctx.properties = mm_bearer_properties_new ();

    mm_common_parse_key_value_string (str,
                                      &ctx.error,
                                      (MMParseKeyValueForeachFn)key_value_foreach,
                                      &ctx);
    /* If error, destroy the object */
    if (ctx.error) {
        g_propagate_error (error, ctx.error);
        g_object_unref (ctx.properties);
        ctx.properties = NULL;
    }

    return ctx.properties;
}