Exemplo n.º 1
0
/**
 * soup_auth_is_for_proxy:
 * @auth: a #SoupAuth
 *
 * Tests whether or not @auth is associated with a proxy server rather
 * than an "origin" server.
 *
 * Return value: %TRUE or %FALSE
 **/
gboolean
soup_auth_is_for_proxy (SoupAuth *auth)
{
	g_return_val_if_fail (SOUP_IS_AUTH (auth), FALSE);

	return SOUP_AUTH_GET_PRIVATE (auth)->proxy;
}
Exemplo n.º 2
0
static void
soup_auth_get_property (GObject *object, guint prop_id,
			GValue *value, GParamSpec *pspec)
{
	SoupAuth *auth = SOUP_AUTH (object);
	SoupAuthPrivate *priv = SOUP_AUTH_GET_PRIVATE (object);

	switch (prop_id) {
	case PROP_SCHEME_NAME:
		g_value_set_string (value, soup_auth_get_scheme_name (auth));
		break;
	case PROP_REALM:
		if (auth->realm)
			g_free (auth->realm);
		g_value_set_string (value, soup_auth_get_realm (auth));
		break;
	case PROP_HOST:
		if (priv->host)
			g_free (priv->host);
		g_value_set_string (value, soup_auth_get_host (auth));
		break;
	case PROP_IS_FOR_PROXY:
		g_value_set_boolean (value, priv->proxy);
		break;
	case PROP_IS_AUTHENTICATED:
		g_value_set_boolean (value, soup_auth_is_authenticated (auth));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
Exemplo n.º 3
0
/**
 * soup_auth_get_host:
 * @auth: a #SoupAuth
 *
 * Returns the host that @auth is associated with.
 *
 * Return value: the hostname
 **/
const char *
soup_auth_get_host (SoupAuth *auth)
{
	g_return_val_if_fail (SOUP_IS_AUTH (auth), NULL);

	return SOUP_AUTH_GET_PRIVATE (auth)->host;
}
Exemplo n.º 4
0
static void
soup_auth_finalize (GObject *object)
{
	SoupAuth *auth = SOUP_AUTH (object);
	SoupAuthPrivate *priv = SOUP_AUTH_GET_PRIVATE (auth);

	g_free (auth->realm);
	g_free (priv->host);

	G_OBJECT_CLASS (soup_auth_parent_class)->finalize (object);
}
Exemplo n.º 5
0
static void
finalize (GObject *object)
{
    SoupAuth *auth = SOUP_AUTH (object);
    SoupAuthPrivate *priv = SOUP_AUTH_GET_PRIVATE (auth);

    g_free (auth->realm);
    g_free (priv->host);
    if (priv->saved_passwords)
        g_hash_table_destroy (priv->saved_passwords);

    G_OBJECT_CLASS (soup_auth_parent_class)->finalize (object);
}
Exemplo n.º 6
0
/**
 * soup_auth_get_saved_password:
 * @auth: a #SoupAuth
 * @user: a username from the list returned from
 * soup_auth_get_saved_users().
 *
 * Given a username for which @auth has a saved password, this returns
 * that password. If @auth doesn't have a passwords saved for @user, it
 * returns %NULL.
 *
 * Return value: the saved password, or %NULL.
 *
 * Since: 2.28
 **/
const char *
soup_auth_get_saved_password (SoupAuth *auth, const char *user)
{
    SoupAuthPrivate *priv;

    g_return_val_if_fail (SOUP_IS_AUTH (auth), NULL);
    g_return_val_if_fail (user != NULL, NULL);

    priv = SOUP_AUTH_GET_PRIVATE (auth);
    if (!priv->saved_passwords)
        return NULL;
    return g_hash_table_lookup (priv->saved_passwords, user);
}
Exemplo n.º 7
0
/**
 * soup_auth_has_saved_password:
 * @auth: a #SoupAuth
 * @username: a username
 * @password: a password
 *
 * Updates @auth to be aware of an already-saved username/password
 * combination. This method <emphasis>does not</emphasis> cause the
 * given @username and @password to be saved; use
 * soup_auth_save_password() for that. (soup_auth_has_saved_password()
 * is an internal method, which is used by the code that actually
 * saves and restores the passwords.)
 *
 * Since: 2.28
 **/
void
soup_auth_has_saved_password (SoupAuth *auth, const char *username,
                              const char *password)
{
    SoupAuthPrivate *priv;

    g_return_if_fail (SOUP_IS_AUTH (auth));
    g_return_if_fail (username != NULL);
    g_return_if_fail (password != NULL);

    priv = SOUP_AUTH_GET_PRIVATE (auth);

    if (!priv->saved_passwords)
        init_saved_passwords (priv);
    g_hash_table_insert (priv->saved_passwords,
                         g_strdup (username), g_strdup (password));
}
Exemplo n.º 8
0
/**
 * soup_auth_get_saved_users:
 * @auth: a #SoupAuth
 *
 * Gets a list of usernames for which a saved password is available.
 * (If the session is not configured to save passwords, this will
 * always be %NULL.)
 *
 * Return value: (transfer container): the list of usernames. You must
 * free the list with g_slist_free(), but do not free or modify the
 * contents.
 *
 * Since: 2.28
 **/
GSList *
soup_auth_get_saved_users (SoupAuth *auth)
{
    SoupAuthPrivate *priv;
    GSList *users;

    g_return_val_if_fail (SOUP_IS_AUTH (auth), NULL);

    priv = SOUP_AUTH_GET_PRIVATE (auth);
    users = NULL;

    if (priv->saved_passwords) {
        GHashTableIter iter;
        gpointer key, value;

        g_hash_table_iter_init (&iter, priv->saved_passwords);
        while (g_hash_table_iter_next (&iter, &key, &value))
            users = g_slist_prepend (users, key);
    }
    return users;
}
Exemplo n.º 9
0
static void
set_property (GObject *object, guint prop_id,
              const GValue *value, GParamSpec *pspec)
{
    SoupAuth *auth = SOUP_AUTH (object);
    SoupAuthPrivate *priv = SOUP_AUTH_GET_PRIVATE (object);

    switch (prop_id) {
    case PROP_REALM:
        auth->realm = g_value_dup_string (value);
        break;
    case PROP_HOST:
        priv->host = g_value_dup_string (value);
        break;
    case PROP_IS_FOR_PROXY:
        priv->proxy = g_value_get_boolean (value);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}