From: Dan Winship Date: Wed, 4 Jul 2012 17:12:38 +0000 (-0400) Subject: Reorganize files to need fewer forward declarations X-Git-Tag: LIBSOUP_2_39_4~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b916078d6e1f3bc54124a9433295a8c3d825c22;p=platform%2Fupstream%2Flibsoup.git Reorganize files to need fewer forward declarations Also, prefix virtual method implementation names with the class name, to be consistent with other code. --- diff --git a/libsoup/soup-address.c b/libsoup/soup-address.c index 25c1b25..38974c6 100644 --- a/libsoup/soup-address.c +++ b/libsoup/soup-address.c @@ -98,17 +98,7 @@ typedef struct { memcpy (SOUP_ADDRESS_GET_DATA (priv), data, length) -static GObject *constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_properties); -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static void soup_address_connectable_iface_init (GSocketConnectableIface *connectable_iface); -static GSocketAddressEnumerator *soup_address_connectable_enumerate (GSocketConnectable *connectable); -static GSocketAddressEnumerator *soup_address_connectable_proxy_enumerate (GSocketConnectable *connectable); G_DEFINE_TYPE_WITH_CODE (SoupAddress, soup_address, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (G_TYPE_SOCKET_CONNECTABLE, @@ -123,7 +113,7 @@ soup_address_init (SoupAddress *addr) } static void -finalize (GObject *object) +soup_address_finalize (GObject *object) { SoupAddress *addr = SOUP_ADDRESS (object); SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr); @@ -137,111 +127,10 @@ finalize (GObject *object) G_OBJECT_CLASS (soup_address_parent_class)->finalize (object); } -static void -soup_address_class_init (SoupAddressClass *address_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (address_class); - - g_type_class_add_private (address_class, sizeof (SoupAddressPrivate)); - - /* virtual method override */ - object_class->constructor = constructor; - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; - - /* properties */ - /** - * SOUP_ADDRESS_NAME: - * - * Alias for the #SoupAddress:name property. (The hostname for - * this address.) - **/ - g_object_class_install_property ( - object_class, PROP_NAME, - g_param_spec_string (SOUP_ADDRESS_NAME, - "Name", - "Hostname for this address", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - /** - * SOUP_ADDRESS_FAMILY: - * - * Alias for the #SoupAddress:family property. (The - * #SoupAddressFamily for this address.) - **/ - g_object_class_install_property ( - object_class, PROP_FAMILY, - g_param_spec_enum (SOUP_ADDRESS_FAMILY, - "Family", - "Address family for this address", - SOUP_TYPE_ADDRESS_FAMILY, - SOUP_ADDRESS_FAMILY_INVALID, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - /** - * SOUP_ADDRESS_PORT: - * - * An alias for the #SoupAddress:port property. (The port for - * this address.) - **/ - g_object_class_install_property ( - object_class, PROP_PORT, - g_param_spec_int (SOUP_ADDRESS_PORT, - "Port", - "Port for this address", - -1, 65535, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - /** - * SOUP_ADDRESS_PROTOCOL: - * - * Alias for the #SoupAddress:protocol property. (The URI scheme - * used with this address.) - **/ - g_object_class_install_property ( - object_class, PROP_PROTOCOL, - g_param_spec_string (SOUP_ADDRESS_PROTOCOL, - "Protocol", - "URI scheme for this address", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - /** - * SOUP_ADDRESS_PHYSICAL: - * - * An alias for the #SoupAddress:physical property. (The - * stringified IP address for this address.) - **/ - g_object_class_install_property ( - object_class, PROP_PHYSICAL, - g_param_spec_string (SOUP_ADDRESS_PHYSICAL, - "Physical address", - "IP address for this address", - NULL, - G_PARAM_READABLE)); - /** - * SOUP_ADDRESS_SOCKADDR: - * - * An alias for the #SoupAddress:sockaddr property. (A pointer - * to the struct sockaddr for this address.) - **/ - g_object_class_install_property ( - object_class, PROP_SOCKADDR, - g_param_spec_pointer (SOUP_ADDRESS_SOCKADDR, - "sockaddr", - "struct sockaddr for this address", - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); -} - -static void -soup_address_connectable_iface_init (GSocketConnectableIface *connectable_iface) -{ - connectable_iface->enumerate = soup_address_connectable_enumerate; - connectable_iface->proxy_enumerate = soup_address_connectable_proxy_enumerate; -} - static GObject * -constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_properties) +soup_address_constructor (GType type, + guint n_construct_properties, + GObjectConstructParam *construct_properties) { GObject *addr; SoupAddressPrivate *priv; @@ -261,8 +150,8 @@ constructor (GType type, } static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_address_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (object); SoupAddressFamily family; @@ -325,8 +214,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_address_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (object); @@ -358,6 +247,100 @@ get_property (GObject *object, guint prop_id, } } +static void +soup_address_class_init (SoupAddressClass *address_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (address_class); + + g_type_class_add_private (address_class, sizeof (SoupAddressPrivate)); + + /* virtual method override */ + object_class->constructor = soup_address_constructor; + object_class->finalize = soup_address_finalize; + object_class->set_property = soup_address_set_property; + object_class->get_property = soup_address_get_property; + + /* properties */ + /** + * SOUP_ADDRESS_NAME: + * + * Alias for the #SoupAddress:name property. (The hostname for + * this address.) + **/ + g_object_class_install_property ( + object_class, PROP_NAME, + g_param_spec_string (SOUP_ADDRESS_NAME, + "Name", + "Hostname for this address", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /** + * SOUP_ADDRESS_FAMILY: + * + * Alias for the #SoupAddress:family property. (The + * #SoupAddressFamily for this address.) + **/ + g_object_class_install_property ( + object_class, PROP_FAMILY, + g_param_spec_enum (SOUP_ADDRESS_FAMILY, + "Family", + "Address family for this address", + SOUP_TYPE_ADDRESS_FAMILY, + SOUP_ADDRESS_FAMILY_INVALID, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /** + * SOUP_ADDRESS_PORT: + * + * An alias for the #SoupAddress:port property. (The port for + * this address.) + **/ + g_object_class_install_property ( + object_class, PROP_PORT, + g_param_spec_int (SOUP_ADDRESS_PORT, + "Port", + "Port for this address", + -1, 65535, -1, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /** + * SOUP_ADDRESS_PROTOCOL: + * + * Alias for the #SoupAddress:protocol property. (The URI scheme + * used with this address.) + **/ + g_object_class_install_property ( + object_class, PROP_PROTOCOL, + g_param_spec_string (SOUP_ADDRESS_PROTOCOL, + "Protocol", + "URI scheme for this address", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /** + * SOUP_ADDRESS_PHYSICAL: + * + * An alias for the #SoupAddress:physical property. (The + * stringified IP address for this address.) + **/ + g_object_class_install_property ( + object_class, PROP_PHYSICAL, + g_param_spec_string (SOUP_ADDRESS_PHYSICAL, + "Physical address", + "IP address for this address", + NULL, + G_PARAM_READABLE)); + /** + * SOUP_ADDRESS_SOCKADDR: + * + * An alias for the #SoupAddress:sockaddr property. (A pointer + * to the struct sockaddr for this address.) + **/ + g_object_class_install_property ( + object_class, PROP_SOCKADDR, + g_param_spec_pointer (SOUP_ADDRESS_SOCKADDR, + "sockaddr", + "struct sockaddr for this address", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); +} + /** * soup_address_new: * @name: a hostname or physical address @@ -1242,3 +1225,10 @@ soup_address_connectable_proxy_enumerate (GSocketConnectable *connectable) return proxy_enum; } + +static void +soup_address_connectable_iface_init (GSocketConnectableIface *connectable_iface) +{ + connectable_iface->enumerate = soup_address_connectable_enumerate; + connectable_iface->proxy_enumerate = soup_address_connectable_proxy_enumerate; +} diff --git a/libsoup/soup-auth-basic.c b/libsoup/soup-auth-basic.c index 3705e6e..7df7e1e 100644 --- a/libsoup/soup-auth-basic.c +++ b/libsoup/soup-auth-basic.c @@ -17,12 +17,6 @@ #include "soup-misc.h" #include "soup-uri.h" -static gboolean update (SoupAuth *auth, SoupMessage *msg, GHashTable *auth_params); -static GSList *get_protection_space (SoupAuth *auth, SoupURI *source_uri); -static void authenticate (SoupAuth *auth, const char *username, const char *password); -static gboolean is_authenticated (SoupAuth *auth); -static char *get_authorization (SoupAuth *auth, SoupMessage *msg); - typedef struct { char *token; } SoupAuthBasicPrivate; @@ -36,7 +30,7 @@ soup_auth_basic_init (SoupAuthBasic *basic) } static void -finalize (GObject *object) +soup_auth_basic_finalize (GObject *object) { SoupAuthBasicPrivate *priv = SOUP_AUTH_BASIC_GET_PRIVATE (object); @@ -45,29 +39,9 @@ finalize (GObject *object) G_OBJECT_CLASS (soup_auth_basic_parent_class)->finalize (object); } -static void -soup_auth_basic_class_init (SoupAuthBasicClass *auth_basic_class) -{ - SoupAuthClass *auth_class = SOUP_AUTH_CLASS (auth_basic_class); - GObjectClass *object_class = G_OBJECT_CLASS (auth_basic_class); - - g_type_class_add_private (auth_basic_class, sizeof (SoupAuthBasicPrivate)); - - auth_class->scheme_name = "Basic"; - auth_class->strength = 1; - - auth_class->update = update; - auth_class->get_protection_space = get_protection_space; - auth_class->authenticate = authenticate; - auth_class->is_authenticated = is_authenticated; - auth_class->get_authorization = get_authorization; - - object_class->finalize = finalize; -} - - static gboolean -update (SoupAuth *auth, SoupMessage *msg, GHashTable *auth_params) +soup_auth_basic_update (SoupAuth *auth, SoupMessage *msg, + GHashTable *auth_params) { SoupAuthBasicPrivate *priv = SOUP_AUTH_BASIC_GET_PRIVATE (auth); @@ -85,7 +59,7 @@ update (SoupAuth *auth, SoupMessage *msg, GHashTable *auth_params) } static GSList * -get_protection_space (SoupAuth *auth, SoupURI *source_uri) +soup_auth_basic_get_protection_space (SoupAuth *auth, SoupURI *source_uri) { char *space, *p; @@ -100,7 +74,8 @@ get_protection_space (SoupAuth *auth, SoupURI *source_uri) } static void -authenticate (SoupAuth *auth, const char *username, const char *password) +soup_auth_basic_authenticate (SoupAuth *auth, const char *username, + const char *password) { SoupAuthBasicPrivate *priv = SOUP_AUTH_BASIC_GET_PRIVATE (auth); char *user_pass, *user_pass_latin1; @@ -127,15 +102,35 @@ authenticate (SoupAuth *auth, const char *username, const char *password) } static gboolean -is_authenticated (SoupAuth *auth) +soup_auth_basic_is_authenticated (SoupAuth *auth) { return SOUP_AUTH_BASIC_GET_PRIVATE (auth)->token != NULL; } static char * -get_authorization (SoupAuth *auth, SoupMessage *msg) +soup_auth_basic_get_authorization (SoupAuth *auth, SoupMessage *msg) { SoupAuthBasicPrivate *priv = SOUP_AUTH_BASIC_GET_PRIVATE (auth); return g_strdup_printf ("Basic %s", priv->token); } + +static void +soup_auth_basic_class_init (SoupAuthBasicClass *auth_basic_class) +{ + SoupAuthClass *auth_class = SOUP_AUTH_CLASS (auth_basic_class); + GObjectClass *object_class = G_OBJECT_CLASS (auth_basic_class); + + g_type_class_add_private (auth_basic_class, sizeof (SoupAuthBasicPrivate)); + + auth_class->scheme_name = "Basic"; + auth_class->strength = 1; + + auth_class->update = soup_auth_basic_update; + auth_class->get_protection_space = soup_auth_basic_get_protection_space; + auth_class->authenticate = soup_auth_basic_authenticate; + auth_class->is_authenticated = soup_auth_basic_is_authenticated; + auth_class->get_authorization = soup_auth_basic_get_authorization; + + object_class->finalize = soup_auth_basic_finalize; +} diff --git a/libsoup/soup-auth-digest.c b/libsoup/soup-auth-digest.c index 487e4b5..712967f 100644 --- a/libsoup/soup-auth-digest.c +++ b/libsoup/soup-auth-digest.c @@ -21,12 +21,6 @@ #include "soup-misc.h" #include "soup-uri.h" -static gboolean update (SoupAuth *auth, SoupMessage *msg, GHashTable *auth_params); -static GSList *get_protection_space (SoupAuth *auth, SoupURI *source_uri); -static void authenticate (SoupAuth *auth, const char *username, const char *password); -static gboolean is_authenticated (SoupAuth *auth); -static char *get_authorization (SoupAuth *auth, SoupMessage *msg); - typedef struct { char *user; char hex_urp[33]; @@ -56,7 +50,7 @@ soup_auth_digest_init (SoupAuthDigest *digest) } static void -finalize (GObject *object) +soup_auth_digest_finalize (GObject *object) { SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (object); @@ -71,26 +65,6 @@ finalize (GObject *object) G_OBJECT_CLASS (soup_auth_digest_parent_class)->finalize (object); } -static void -soup_auth_digest_class_init (SoupAuthDigestClass *auth_digest_class) -{ - SoupAuthClass *auth_class = SOUP_AUTH_CLASS (auth_digest_class); - GObjectClass *object_class = G_OBJECT_CLASS (auth_digest_class); - - g_type_class_add_private (auth_digest_class, sizeof (SoupAuthDigestPrivate)); - - auth_class->scheme_name = "Digest"; - auth_class->strength = 5; - - auth_class->get_protection_space = get_protection_space; - auth_class->update = update; - auth_class->authenticate = authenticate; - auth_class->is_authenticated = is_authenticated; - auth_class->get_authorization = get_authorization; - - object_class->finalize = finalize; -} - SoupAuthDigestAlgorithm soup_auth_digest_parse_algorithm (const char *algorithm) { @@ -151,7 +125,8 @@ soup_auth_digest_get_qop (SoupAuthDigestQop qop) } static gboolean -update (SoupAuth *auth, SoupMessage *msg, GHashTable *auth_params) +soup_auth_digest_update (SoupAuth *auth, SoupMessage *msg, + GHashTable *auth_params) { SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth); const char *stale, *qop; @@ -198,7 +173,7 @@ update (SoupAuth *auth, SoupMessage *msg, GHashTable *auth_params) } static GSList * -get_protection_space (SoupAuth *auth, SoupURI *source_uri) +soup_auth_digest_get_protection_space (SoupAuth *auth, SoupURI *source_uri) { SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth); GSList *space = NULL; @@ -303,7 +278,8 @@ recompute_hex_a1 (SoupAuthDigestPrivate *priv) } static void -authenticate (SoupAuth *auth, const char *username, const char *password) +soup_auth_digest_authenticate (SoupAuth *auth, const char *username, + const char *password) { SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth); char *bgen; @@ -328,7 +304,7 @@ authenticate (SoupAuth *auth, const char *username, const char *password) } static gboolean -is_authenticated (SoupAuth *auth) +soup_auth_digest_is_authenticated (SoupAuth *auth) { return SOUP_AUTH_DIGEST_GET_PRIVATE (auth)->cnonce != NULL; } @@ -413,7 +389,7 @@ authentication_info_cb (SoupMessage *msg, gpointer data) } static char * -get_authorization (SoupAuth *auth, SoupMessage *msg) +soup_auth_digest_get_authorization (SoupAuth *auth, SoupMessage *msg) { SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth); char response[33], *token; @@ -476,3 +452,23 @@ get_authorization (SoupAuth *auth, SoupMessage *msg) auth); return token; } + +static void +soup_auth_digest_class_init (SoupAuthDigestClass *auth_digest_class) +{ + SoupAuthClass *auth_class = SOUP_AUTH_CLASS (auth_digest_class); + GObjectClass *object_class = G_OBJECT_CLASS (auth_digest_class); + + g_type_class_add_private (auth_digest_class, sizeof (SoupAuthDigestPrivate)); + + auth_class->scheme_name = "Digest"; + auth_class->strength = 5; + + auth_class->get_protection_space = soup_auth_digest_get_protection_space; + auth_class->update = soup_auth_digest_update; + auth_class->authenticate = soup_auth_digest_authenticate; + auth_class->is_authenticated = soup_auth_digest_is_authenticated; + auth_class->get_authorization = soup_auth_digest_get_authorization; + + object_class->finalize = soup_auth_digest_finalize; +} diff --git a/libsoup/soup-auth-domain-basic.c b/libsoup/soup-auth-domain-basic.c index db3d6d5..0575caa 100644 --- a/libsoup/soup-auth-domain-basic.c +++ b/libsoup/soup-auth-domain-basic.c @@ -43,28 +43,13 @@ typedef struct { G_DEFINE_TYPE (SoupAuthDomainBasic, soup_auth_domain_basic, SOUP_TYPE_AUTH_DOMAIN) -static char *accepts (SoupAuthDomain *domain, - SoupMessage *msg, - const char *header); -static char *challenge (SoupAuthDomain *domain, - SoupMessage *msg); -static gboolean check_password (SoupAuthDomain *domain, - SoupMessage *msg, - const char *username, - const char *password); - -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static void soup_auth_domain_basic_init (SoupAuthDomainBasic *basic) { } static void -finalize (GObject *object) +soup_auth_domain_basic_finalize (GObject *object) { SoupAuthDomainBasicPrivate *priv = SOUP_AUTH_DOMAIN_BASIC_GET_PRIVATE (object); @@ -76,51 +61,8 @@ finalize (GObject *object) } static void -soup_auth_domain_basic_class_init (SoupAuthDomainBasicClass *basic_class) -{ - SoupAuthDomainClass *auth_domain_class = - SOUP_AUTH_DOMAIN_CLASS (basic_class); - GObjectClass *object_class = G_OBJECT_CLASS (basic_class); - - g_type_class_add_private (basic_class, sizeof (SoupAuthDomainBasicPrivate)); - - auth_domain_class->accepts = accepts; - auth_domain_class->challenge = challenge; - auth_domain_class->check_password = check_password; - - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; - - /** - * SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK: - * - * Alias for the #SoupAuthDomainBasic:auth-callback property. - * (The #SoupAuthDomainBasicAuthCallback.) - **/ - g_object_class_install_property ( - object_class, PROP_AUTH_CALLBACK, - g_param_spec_pointer (SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, - "Authentication callback", - "Password-checking callback", - G_PARAM_READWRITE)); - /** - * SOUP_AUTH_DOMAIN_BASIC_AUTH_DATA: - * - * Alias for the #SoupAuthDomainBasic:auth-data property. - * (The data to pass to the #SoupAuthDomainBasicAuthCallback.) - **/ - g_object_class_install_property ( - object_class, PROP_AUTH_DATA, - g_param_spec_pointer (SOUP_AUTH_DOMAIN_BASIC_AUTH_DATA, - "Authentication callback data", - "Data to pass to authentication callback", - G_PARAM_READWRITE)); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_auth_domain_basic_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupAuthDomainBasicPrivate *priv = SOUP_AUTH_DOMAIN_BASIC_GET_PRIVATE (object); @@ -143,8 +85,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_auth_domain_basic_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupAuthDomainBasicPrivate *priv = SOUP_AUTH_DOMAIN_BASIC_GET_PRIVATE (object); @@ -290,7 +232,8 @@ parse_basic (SoupMessage *msg, const char *header, } static char * -accepts (SoupAuthDomain *domain, SoupMessage *msg, const char *header) +soup_auth_domain_basic_accepts (SoupAuthDomain *domain, SoupMessage *msg, + const char *header) { SoupAuthDomainBasicPrivate *priv = SOUP_AUTH_DOMAIN_BASIC_GET_PRIVATE (domain); @@ -319,7 +262,7 @@ accepts (SoupAuthDomain *domain, SoupMessage *msg, const char *header) } static char * -challenge (SoupAuthDomain *domain, SoupMessage *msg) +soup_auth_domain_basic_challenge (SoupAuthDomain *domain, SoupMessage *msg) { GString *challenge; @@ -329,10 +272,10 @@ challenge (SoupAuthDomain *domain, SoupMessage *msg) } static gboolean -check_password (SoupAuthDomain *domain, - SoupMessage *msg, - const char *username, - const char *password) +soup_auth_domain_basic_check_password (SoupAuthDomain *domain, + SoupMessage *msg, + const char *username, + const char *password) { const char *header; char *msg_username, *msg_password; @@ -350,3 +293,46 @@ check_password (SoupAuthDomain *domain, return ok; } + +static void +soup_auth_domain_basic_class_init (SoupAuthDomainBasicClass *basic_class) +{ + SoupAuthDomainClass *auth_domain_class = + SOUP_AUTH_DOMAIN_CLASS (basic_class); + GObjectClass *object_class = G_OBJECT_CLASS (basic_class); + + g_type_class_add_private (basic_class, sizeof (SoupAuthDomainBasicPrivate)); + + auth_domain_class->accepts = soup_auth_domain_basic_accepts; + auth_domain_class->challenge = soup_auth_domain_basic_challenge; + auth_domain_class->check_password = soup_auth_domain_basic_check_password; + + object_class->finalize = soup_auth_domain_basic_finalize; + object_class->set_property = soup_auth_domain_basic_set_property; + object_class->get_property = soup_auth_domain_basic_get_property; + + /** + * SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK: + * + * Alias for the #SoupAuthDomainBasic:auth-callback property. + * (The #SoupAuthDomainBasicAuthCallback.) + **/ + g_object_class_install_property ( + object_class, PROP_AUTH_CALLBACK, + g_param_spec_pointer (SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, + "Authentication callback", + "Password-checking callback", + G_PARAM_READWRITE)); + /** + * SOUP_AUTH_DOMAIN_BASIC_AUTH_DATA: + * + * Alias for the #SoupAuthDomainBasic:auth-data property. + * (The data to pass to the #SoupAuthDomainBasicAuthCallback.) + **/ + g_object_class_install_property ( + object_class, PROP_AUTH_DATA, + g_param_spec_pointer (SOUP_AUTH_DOMAIN_BASIC_AUTH_DATA, + "Authentication callback data", + "Data to pass to authentication callback", + G_PARAM_READWRITE)); +} diff --git a/libsoup/soup-auth-domain-digest.c b/libsoup/soup-auth-domain-digest.c index 203b9f2..86e2285 100644 --- a/libsoup/soup-auth-domain-digest.c +++ b/libsoup/soup-auth-domain-digest.c @@ -47,28 +47,13 @@ typedef struct { G_DEFINE_TYPE (SoupAuthDomainDigest, soup_auth_domain_digest, SOUP_TYPE_AUTH_DOMAIN) -static char *accepts (SoupAuthDomain *domain, - SoupMessage *msg, - const char *header); -static char *challenge (SoupAuthDomain *domain, - SoupMessage *msg); -static gboolean check_password (SoupAuthDomain *domain, - SoupMessage *msg, - const char *username, - const char *password); - -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static void soup_auth_domain_digest_init (SoupAuthDomainDigest *digest) { } static void -finalize (GObject *object) +soup_auth_domain_digest_finalize (GObject *object) { SoupAuthDomainDigestPrivate *priv = SOUP_AUTH_DOMAIN_DIGEST_GET_PRIVATE (object); @@ -80,51 +65,8 @@ finalize (GObject *object) } static void -soup_auth_domain_digest_class_init (SoupAuthDomainDigestClass *digest_class) -{ - SoupAuthDomainClass *auth_domain_class = - SOUP_AUTH_DOMAIN_CLASS (digest_class); - GObjectClass *object_class = G_OBJECT_CLASS (digest_class); - - g_type_class_add_private (digest_class, sizeof (SoupAuthDomainDigestPrivate)); - - auth_domain_class->accepts = accepts; - auth_domain_class->challenge = challenge; - auth_domain_class->check_password = check_password; - - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; - - /** - * SOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK: - * - * Alias for the #SoupAuthDomainDigest:auth-callback property. - * (The #SoupAuthDomainDigestAuthCallback.) - **/ - g_object_class_install_property ( - object_class, PROP_AUTH_CALLBACK, - g_param_spec_pointer (SOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK, - "Authentication callback", - "Password-finding callback", - G_PARAM_READWRITE)); - /** - * SOUP_AUTH_DOMAIN_DIGEST_AUTH_DATA: - * - * Alias for the #SoupAuthDomainDigest:auth-callback property. - * (The #SoupAuthDomainDigestAuthCallback.) - **/ - g_object_class_install_property ( - object_class, PROP_AUTH_DATA, - g_param_spec_pointer (SOUP_AUTH_DOMAIN_DIGEST_AUTH_DATA, - "Authentication callback data", - "Data to pass to authentication callback", - G_PARAM_READWRITE)); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_auth_domain_digest_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupAuthDomainDigestPrivate *priv = SOUP_AUTH_DOMAIN_DIGEST_GET_PRIVATE (object); @@ -147,8 +89,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_auth_domain_digest_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupAuthDomainDigestPrivate *priv = SOUP_AUTH_DOMAIN_DIGEST_GET_PRIVATE (object); @@ -325,7 +267,8 @@ check_hex_urp (SoupAuthDomain *domain, SoupMessage *msg, } static char * -accepts (SoupAuthDomain *domain, SoupMessage *msg, const char *header) +soup_auth_domain_digest_accepts (SoupAuthDomain *domain, SoupMessage *msg, + const char *header) { SoupAuthDomainDigestPrivate *priv = SOUP_AUTH_DOMAIN_DIGEST_GET_PRIVATE (domain); @@ -369,7 +312,7 @@ accepts (SoupAuthDomain *domain, SoupMessage *msg, const char *header) } static char * -challenge (SoupAuthDomain *domain, SoupMessage *msg) +soup_auth_domain_digest_challenge (SoupAuthDomain *domain, SoupMessage *msg) { GString *str; @@ -418,10 +361,10 @@ soup_auth_domain_digest_encode_password (const char *username, } static gboolean -check_password (SoupAuthDomain *domain, - SoupMessage *msg, - const char *username, - const char *password) +soup_auth_domain_digest_check_password (SoupAuthDomain *domain, + SoupMessage *msg, + const char *username, + const char *password) { const char *header; GHashTable *params; @@ -451,3 +394,46 @@ check_password (SoupAuthDomain *domain, soup_header_free_param_list (params); return accept; } + +static void +soup_auth_domain_digest_class_init (SoupAuthDomainDigestClass *digest_class) +{ + SoupAuthDomainClass *auth_domain_class = + SOUP_AUTH_DOMAIN_CLASS (digest_class); + GObjectClass *object_class = G_OBJECT_CLASS (digest_class); + + g_type_class_add_private (digest_class, sizeof (SoupAuthDomainDigestPrivate)); + + auth_domain_class->accepts = soup_auth_domain_digest_accepts; + auth_domain_class->challenge = soup_auth_domain_digest_challenge; + auth_domain_class->check_password = soup_auth_domain_digest_check_password; + + object_class->finalize = soup_auth_domain_digest_finalize; + object_class->set_property = soup_auth_domain_digest_set_property; + object_class->get_property = soup_auth_domain_digest_get_property; + + /** + * SOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK: + * + * Alias for the #SoupAuthDomainDigest:auth-callback property. + * (The #SoupAuthDomainDigestAuthCallback.) + **/ + g_object_class_install_property ( + object_class, PROP_AUTH_CALLBACK, + g_param_spec_pointer (SOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK, + "Authentication callback", + "Password-finding callback", + G_PARAM_READWRITE)); + /** + * SOUP_AUTH_DOMAIN_DIGEST_AUTH_DATA: + * + * Alias for the #SoupAuthDomainDigest:auth-callback property. + * (The #SoupAuthDomainDigestAuthCallback.) + **/ + g_object_class_install_property ( + object_class, PROP_AUTH_DATA, + g_param_spec_pointer (SOUP_AUTH_DOMAIN_DIGEST_AUTH_DATA, + "Authentication callback data", + "Data to pass to authentication callback", + G_PARAM_READWRITE)); +} diff --git a/libsoup/soup-auth-domain.c b/libsoup/soup-auth-domain.c index dd47dff..6b7a629 100644 --- a/libsoup/soup-auth-domain.c +++ b/libsoup/soup-auth-domain.c @@ -74,11 +74,6 @@ typedef struct { G_DEFINE_ABSTRACT_TYPE (SoupAuthDomain, soup_auth_domain, G_TYPE_OBJECT) -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static void soup_auth_domain_init (SoupAuthDomain *domain) { @@ -88,7 +83,7 @@ soup_auth_domain_init (SoupAuthDomain *domain) } static void -finalize (GObject *object) +soup_auth_domain_finalize (GObject *object) { SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (object); @@ -104,15 +99,95 @@ finalize (GObject *object) } static void +soup_auth_domain_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + SoupAuthDomain *auth_domain = SOUP_AUTH_DOMAIN (object); + SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_REALM: + g_free (priv->realm); + priv->realm = g_value_dup_string (value); + break; + case PROP_PROXY: + priv->proxy = g_value_get_boolean (value); + break; + case PROP_ADD_PATH: + soup_auth_domain_add_path (auth_domain, + g_value_get_string (value)); + break; + case PROP_REMOVE_PATH: + soup_auth_domain_remove_path (auth_domain, + g_value_get_string (value)); + break; + case PROP_FILTER: + priv->filter = g_value_get_pointer (value); + break; + case PROP_FILTER_DATA: + if (priv->filter_dnotify) { + priv->filter_dnotify (priv->filter_data); + priv->filter_dnotify = NULL; + } + priv->filter_data = g_value_get_pointer (value); + break; + case PROP_GENERIC_AUTH_CALLBACK: + priv->auth_callback = g_value_get_pointer (value); + break; + case PROP_GENERIC_AUTH_DATA: + if (priv->auth_dnotify) { + priv->auth_dnotify (priv->auth_data); + priv->auth_dnotify = NULL; + } + priv->auth_data = g_value_get_pointer (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +soup_auth_domain_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_REALM: + g_value_set_string (value, priv->realm); + break; + case PROP_PROXY: + g_value_set_boolean (value, priv->proxy); + break; + case PROP_FILTER: + g_value_set_pointer (value, priv->filter); + break; + case PROP_FILTER_DATA: + g_value_set_pointer (value, priv->filter_data); + break; + case PROP_GENERIC_AUTH_CALLBACK: + g_value_set_pointer (value, priv->auth_callback); + break; + case PROP_GENERIC_AUTH_DATA: + g_value_set_pointer (value, priv->auth_data); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void soup_auth_domain_class_init (SoupAuthDomainClass *auth_domain_class) { GObjectClass *object_class = G_OBJECT_CLASS (auth_domain_class); g_type_class_add_private (auth_domain_class, sizeof (SoupAuthDomainPrivate)); - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->finalize = soup_auth_domain_finalize; + object_class->set_property = soup_auth_domain_set_property; + object_class->get_property = soup_auth_domain_get_property; /** * SOUP_AUTH_DOMAIN_REALM: @@ -216,86 +291,6 @@ soup_auth_domain_class_init (SoupAuthDomainClass *auth_domain_class) G_PARAM_READWRITE)); } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - SoupAuthDomain *auth_domain = SOUP_AUTH_DOMAIN (object); - SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_REALM: - g_free (priv->realm); - priv->realm = g_value_dup_string (value); - break; - case PROP_PROXY: - priv->proxy = g_value_get_boolean (value); - break; - case PROP_ADD_PATH: - soup_auth_domain_add_path (auth_domain, - g_value_get_string (value)); - break; - case PROP_REMOVE_PATH: - soup_auth_domain_remove_path (auth_domain, - g_value_get_string (value)); - break; - case PROP_FILTER: - priv->filter = g_value_get_pointer (value); - break; - case PROP_FILTER_DATA: - if (priv->filter_dnotify) { - priv->filter_dnotify (priv->filter_data); - priv->filter_dnotify = NULL; - } - priv->filter_data = g_value_get_pointer (value); - break; - case PROP_GENERIC_AUTH_CALLBACK: - priv->auth_callback = g_value_get_pointer (value); - break; - case PROP_GENERIC_AUTH_DATA: - if (priv->auth_dnotify) { - priv->auth_dnotify (priv->auth_data); - priv->auth_dnotify = NULL; - } - priv->auth_data = g_value_get_pointer (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_REALM: - g_value_set_string (value, priv->realm); - break; - case PROP_PROXY: - g_value_set_boolean (value, priv->proxy); - break; - case PROP_FILTER: - g_value_set_pointer (value, priv->filter); - break; - case PROP_FILTER_DATA: - g_value_set_pointer (value, priv->filter_data); - break; - case PROP_GENERIC_AUTH_CALLBACK: - g_value_set_pointer (value, priv->auth_callback); - break; - case PROP_GENERIC_AUTH_DATA: - g_value_set_pointer (value, priv->auth_data); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - /** * soup_auth_domain_add_path: * @domain: a #SoupAuthDomain diff --git a/libsoup/soup-auth-manager-ntlm.c b/libsoup/soup-auth-manager-ntlm.c index 04771b4..ae59504 100644 --- a/libsoup/soup-auth-manager-ntlm.c +++ b/libsoup/soup-auth-manager-ntlm.c @@ -30,17 +30,6 @@ static void soup_auth_manager_ntlm_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer interface_data); static SoupSessionFeatureInterface *soup_auth_manager_parent_feature_interface; -static void attach (SoupSessionFeature *feature, SoupSession *session); -static void request_queued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg); -static void request_started (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg, SoupSocket *socket); -static void request_unqueued (SoupSessionFeature *feature, - SoupSession *session, SoupMessage *msg); -static gboolean add_feature (SoupSessionFeature *feature, GType type); -static gboolean remove_feature (SoupSessionFeature *feature, GType type); -static gboolean has_feature (SoupSessionFeature *feature, GType type); - G_DEFINE_TYPE_WITH_CODE (SoupAuthManagerNTLM, soup_auth_manager_ntlm, SOUP_TYPE_AUTH_MANAGER, G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE, soup_auth_manager_ntlm_session_feature_init)) @@ -130,7 +119,7 @@ free_ntlm_connection (SoupNTLMConnection *conn) } static void -finalize (GObject *object) +soup_auth_manager_ntlm_finalize (GObject *object) { SoupAuthManagerNTLMPrivate *priv = SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (object); @@ -148,27 +137,11 @@ soup_auth_manager_ntlm_class_init (SoupAuthManagerNTLMClass *auth_manager_ntlm_c g_type_class_add_private (auth_manager_ntlm_class, sizeof (SoupAuthManagerNTLMPrivate)); - object_class->finalize = finalize; -} - -static void -soup_auth_manager_ntlm_session_feature_init (SoupSessionFeatureInterface *feature_interface, - gpointer interface_data) -{ - soup_auth_manager_parent_feature_interface = - g_type_interface_peek_parent (feature_interface); - - feature_interface->attach = attach; - feature_interface->request_queued = request_queued; - feature_interface->request_started = request_started; - feature_interface->request_unqueued = request_unqueued; - feature_interface->add_feature = add_feature; - feature_interface->remove_feature = remove_feature; - feature_interface->has_feature = has_feature; + object_class->finalize = soup_auth_manager_ntlm_finalize; } static void -attach (SoupSessionFeature *manager, SoupSession *session) +soup_auth_manager_ntlm_attach (SoupSessionFeature *manager, SoupSession *session) { SoupAuthManagerNTLMPrivate *priv = SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (manager); @@ -515,7 +488,9 @@ done: } static void -request_queued (SoupSessionFeature *ntlm, SoupSession *session, SoupMessage *msg) +soup_auth_manager_ntlm_request_queued (SoupSessionFeature *ntlm, + SoupSession *session, + SoupMessage *msg) { SoupAuthManagerNTLMPrivate *priv = SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (ntlm); @@ -533,8 +508,10 @@ request_queued (SoupSessionFeature *ntlm, SoupSession *session, SoupMessage *msg } static void -request_started (SoupSessionFeature *ntlm, SoupSession *session, - SoupMessage *msg, SoupSocket *socket) +soup_auth_manager_ntlm_request_started (SoupSessionFeature *ntlm, + SoupSession *session, + SoupMessage *msg, + SoupSocket *socket) { SoupAuthManagerNTLMPrivate *priv = SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (ntlm); @@ -616,8 +593,9 @@ super: } static void -request_unqueued (SoupSessionFeature *ntlm, SoupSession *session, - SoupMessage *msg) +soup_auth_manager_ntlm_request_unqueued (SoupSessionFeature *ntlm, + SoupSession *session, + SoupMessage *msg) { g_signal_handlers_disconnect_by_func (msg, ntlm_authorize_pre, ntlm); g_signal_handlers_disconnect_by_func (msg, ntlm_authorize_post, ntlm); @@ -626,7 +604,7 @@ request_unqueued (SoupSessionFeature *ntlm, SoupSession *session, } static gboolean -add_feature (SoupSessionFeature *feature, GType type) +soup_auth_manager_ntlm_add_feature (SoupSessionFeature *feature, GType type) { SoupAuthManagerNTLMPrivate *priv = SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (feature); @@ -640,7 +618,7 @@ add_feature (SoupSessionFeature *feature, GType type) } static gboolean -remove_feature (SoupSessionFeature *feature, GType type) +soup_auth_manager_ntlm_remove_feature (SoupSessionFeature *feature, GType type) { SoupAuthManagerNTLMPrivate *priv = SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (feature); @@ -654,7 +632,7 @@ remove_feature (SoupSessionFeature *feature, GType type) } static gboolean -has_feature (SoupSessionFeature *feature, GType type) +soup_auth_manager_ntlm_has_feature (SoupSessionFeature *feature, GType type) { SoupAuthManagerNTLMPrivate *priv = SOUP_AUTH_MANAGER_NTLM_GET_PRIVATE (feature); @@ -665,6 +643,22 @@ has_feature (SoupSessionFeature *feature, GType type) return soup_auth_manager_parent_feature_interface->has_feature (feature, type); } +static void +soup_auth_manager_ntlm_session_feature_init (SoupSessionFeatureInterface *feature_interface, + gpointer interface_data) +{ + soup_auth_manager_parent_feature_interface = + g_type_interface_peek_parent (feature_interface); + + feature_interface->attach = soup_auth_manager_ntlm_attach; + feature_interface->request_queued = soup_auth_manager_ntlm_request_queued; + feature_interface->request_started = soup_auth_manager_ntlm_request_started; + feature_interface->request_unqueued = soup_auth_manager_ntlm_request_unqueued; + feature_interface->add_feature = soup_auth_manager_ntlm_add_feature; + feature_interface->remove_feature = soup_auth_manager_ntlm_remove_feature; + feature_interface->has_feature = soup_auth_manager_ntlm_has_feature; +} + /* NTLM code */ static void md4sum (const unsigned char *in, diff --git a/libsoup/soup-auth-manager.c b/libsoup/soup-auth-manager.c index ba1d7c5..64637e9 100644 --- a/libsoup/soup-auth-manager.c +++ b/libsoup/soup-auth-manager.c @@ -26,17 +26,6 @@ static void soup_auth_manager_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer interface_data); static SoupSessionFeatureInterface *soup_session_feature_default_interface; -static void attach (SoupSessionFeature *feature, SoupSession *session); -static void request_queued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg); -static void request_started (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg, SoupSocket *socket); -static void request_unqueued (SoupSessionFeature *feature, - SoupSession *session, SoupMessage *msg); -static gboolean add_feature (SoupSessionFeature *feature, GType type); -static gboolean remove_feature (SoupSessionFeature *feature, GType type); -static gboolean has_feature (SoupSessionFeature *feature, GType type); - enum { AUTHENTICATE, LAST_SIGNAL @@ -78,7 +67,7 @@ soup_auth_manager_init (SoupAuthManager *manager) } static void -finalize (GObject *object) +soup_auth_manager_finalize (GObject *object) { SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (object); @@ -98,7 +87,7 @@ soup_auth_manager_class_init (SoupAuthManagerClass *auth_manager_class) g_type_class_add_private (auth_manager_class, sizeof (SoupAuthManagerPrivate)); - object_class->finalize = finalize; + object_class->finalize = soup_auth_manager_finalize; signals[AUTHENTICATE] = g_signal_new ("authenticate", @@ -114,22 +103,6 @@ soup_auth_manager_class_init (SoupAuthManagerClass *auth_manager_class) } -static void -soup_auth_manager_session_feature_init (SoupSessionFeatureInterface *feature_interface, - gpointer interface_data) -{ - soup_session_feature_default_interface = - g_type_default_interface_peek (SOUP_TYPE_SESSION_FEATURE); - - feature_interface->attach = attach; - feature_interface->request_queued = request_queued; - feature_interface->request_started = request_started; - feature_interface->request_unqueued = request_unqueued; - feature_interface->add_feature = add_feature; - feature_interface->remove_feature = remove_feature; - feature_interface->has_feature = has_feature; -} - static int auth_type_compare_func (gconstpointer a, gconstpointer b) { @@ -140,7 +113,7 @@ auth_type_compare_func (gconstpointer a, gconstpointer b) } static gboolean -add_feature (SoupSessionFeature *feature, GType type) +soup_auth_manager_add_feature (SoupSessionFeature *feature, GType type) { SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (feature); SoupAuthClass *auth_class; @@ -155,7 +128,7 @@ add_feature (SoupSessionFeature *feature, GType type) } static gboolean -remove_feature (SoupSessionFeature *feature, GType type) +soup_auth_manager_remove_feature (SoupSessionFeature *feature, GType type) { SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (feature); SoupAuthClass *auth_class; @@ -176,7 +149,7 @@ remove_feature (SoupSessionFeature *feature, GType type) } static gboolean -has_feature (SoupSessionFeature *feature, GType type) +soup_auth_manager_has_feature (SoupSessionFeature *feature, GType type) { SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (feature); SoupAuthClass *auth_class; @@ -201,7 +174,7 @@ soup_auth_manager_emit_authenticate (SoupAuthManager *manager, SoupMessage *msg, } static void -attach (SoupSessionFeature *manager, SoupSession *session) +soup_auth_manager_attach (SoupSessionFeature *manager, SoupSession *session) { SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager); @@ -567,8 +540,9 @@ requeue_if_proxy_authenticated (SoupMessage *msg, gpointer manager) } static void -request_queued (SoupSessionFeature *manager, SoupSession *session, - SoupMessage *msg) +soup_auth_manager_request_queued (SoupSessionFeature *manager, + SoupSession *session, + SoupMessage *msg) { soup_message_add_status_code_handler ( msg, "got_headers", SOUP_STATUS_UNAUTHORIZED, @@ -586,8 +560,10 @@ request_queued (SoupSessionFeature *manager, SoupSession *session, } static void -request_started (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg, SoupSocket *socket) +soup_auth_manager_request_started (SoupSessionFeature *feature, + SoupSession *session, + SoupMessage *msg, + SoupSocket *socket) { SoupAuthManager *manager = SOUP_AUTH_MANAGER (feature); SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager); @@ -605,9 +581,26 @@ request_started (SoupSessionFeature *feature, SoupSession *session, } static void -request_unqueued (SoupSessionFeature *manager, SoupSession *session, - SoupMessage *msg) +soup_auth_manager_request_unqueued (SoupSessionFeature *manager, + SoupSession *session, + SoupMessage *msg) { g_signal_handlers_disconnect_matched (msg, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, manager); } + +static void +soup_auth_manager_session_feature_init (SoupSessionFeatureInterface *feature_interface, + gpointer interface_data) +{ + soup_session_feature_default_interface = + g_type_default_interface_peek (SOUP_TYPE_SESSION_FEATURE); + + feature_interface->attach = soup_auth_manager_attach; + feature_interface->request_queued = soup_auth_manager_request_queued; + feature_interface->request_started = soup_auth_manager_request_started; + feature_interface->request_unqueued = soup_auth_manager_request_unqueued; + feature_interface->add_feature = soup_auth_manager_add_feature; + feature_interface->remove_feature = soup_auth_manager_remove_feature; + feature_interface->has_feature = soup_auth_manager_has_feature; +} diff --git a/libsoup/soup-auth-ntlm.c b/libsoup/soup-auth-ntlm.c index 6383311..7bba70f 100644 --- a/libsoup/soup-auth-ntlm.c +++ b/libsoup/soup-auth-ntlm.c @@ -17,12 +17,6 @@ #include "soup-misc.h" #include "soup-uri.h" -static gboolean update (SoupAuth *auth, SoupMessage *msg, GHashTable *auth_params); -static GSList *get_protection_space (SoupAuth *auth, SoupURI *source_uri); -static void authenticate (SoupAuth *auth, const char *username, const char *password); -static gboolean is_authenticated (SoupAuth *auth); -static char *get_authorization (SoupAuth *auth, SoupMessage *msg); - typedef struct { char *username, *password; } SoupAuthNTLMPrivate; @@ -36,7 +30,7 @@ soup_auth_ntlm_init (SoupAuthNTLM *ntlm) } static void -finalize (GObject *object) +soup_auth_ntlm_finalize (GObject *object) { SoupAuthNTLMPrivate *priv = SOUP_AUTH_NTLM_GET_PRIVATE (object); @@ -49,26 +43,6 @@ finalize (GObject *object) G_OBJECT_CLASS (soup_auth_ntlm_parent_class)->finalize (object); } -static void -soup_auth_ntlm_class_init (SoupAuthNTLMClass *auth_ntlm_class) -{ - SoupAuthClass *auth_class = SOUP_AUTH_CLASS (auth_ntlm_class); - GObjectClass *object_class = G_OBJECT_CLASS (auth_ntlm_class); - - g_type_class_add_private (auth_ntlm_class, sizeof (SoupAuthNTLMPrivate)); - - auth_class->scheme_name = "NTLM"; - auth_class->strength = 3; - - auth_class->update = update; - auth_class->get_protection_space = get_protection_space; - auth_class->authenticate = authenticate; - auth_class->is_authenticated = is_authenticated; - auth_class->get_authorization = get_authorization; - - object_class->finalize = finalize; -} - SoupAuth * soup_auth_ntlm_new (const char *realm, const char *host) { @@ -82,19 +56,21 @@ soup_auth_ntlm_new (const char *realm, const char *host) } static gboolean -update (SoupAuth *auth, SoupMessage *msg, GHashTable *auth_params) +soup_auth_ntlm_update (SoupAuth *auth, SoupMessage *msg, + GHashTable *auth_params) { g_return_val_if_reached (FALSE); } static GSList * -get_protection_space (SoupAuth *auth, SoupURI *source_uri) +soup_auth_ntlm_get_protection_space (SoupAuth *auth, SoupURI *source_uri) { g_return_val_if_reached (NULL); } static void -authenticate (SoupAuth *auth, const char *username, const char *password) +soup_auth_ntlm_authenticate (SoupAuth *auth, const char *username, + const char *password) { SoupAuthNTLMPrivate *priv = SOUP_AUTH_NTLM_GET_PRIVATE (auth); @@ -106,17 +82,37 @@ authenticate (SoupAuth *auth, const char *username, const char *password) } static gboolean -is_authenticated (SoupAuth *auth) +soup_auth_ntlm_is_authenticated (SoupAuth *auth) { return SOUP_AUTH_NTLM_GET_PRIVATE (auth)->password != NULL; } static char * -get_authorization (SoupAuth *auth, SoupMessage *msg) +soup_auth_ntlm_get_authorization (SoupAuth *auth, SoupMessage *msg) { g_return_val_if_reached (NULL); } +static void +soup_auth_ntlm_class_init (SoupAuthNTLMClass *auth_ntlm_class) +{ + SoupAuthClass *auth_class = SOUP_AUTH_CLASS (auth_ntlm_class); + GObjectClass *object_class = G_OBJECT_CLASS (auth_ntlm_class); + + g_type_class_add_private (auth_ntlm_class, sizeof (SoupAuthNTLMPrivate)); + + auth_class->scheme_name = "NTLM"; + auth_class->strength = 3; + + auth_class->update = soup_auth_ntlm_update; + auth_class->get_protection_space = soup_auth_ntlm_get_protection_space; + auth_class->authenticate = soup_auth_ntlm_authenticate; + auth_class->is_authenticated = soup_auth_ntlm_is_authenticated; + auth_class->get_authorization = soup_auth_ntlm_get_authorization; + + object_class->finalize = soup_auth_ntlm_finalize; +} + const char * soup_auth_ntlm_get_username (SoupAuth *auth) { diff --git a/libsoup/soup-auth.c b/libsoup/soup-auth.c index 5b77aa7..73f0c79 100644 --- a/libsoup/soup-auth.c +++ b/libsoup/soup-auth.c @@ -68,13 +68,13 @@ enum { LAST_PROP }; -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void +soup_auth_init (SoupAuth *auth) +{ +} static void -finalize (GObject *object) +soup_auth_finalize (GObject *object) { SoupAuth *auth = SOUP_AUTH (object); SoupAuthPrivate *priv = SOUP_AUTH_GET_PRIVATE (auth); @@ -88,15 +88,68 @@ finalize (GObject *object) } static void +soup_auth_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; + } +} + +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: + g_value_set_string (value, soup_auth_get_realm (auth)); + break; + case PROP_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; + } +} + + +static void soup_auth_class_init (SoupAuthClass *auth_class) { GObjectClass *object_class = G_OBJECT_CLASS (auth_class); g_type_class_add_private (auth_class, sizeof (SoupAuthPrivate)); - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->finalize = soup_auth_finalize; + object_class->set_property = soup_auth_set_property; + object_class->get_property = soup_auth_get_property; /** * SoupAuth::save-password: @@ -190,63 +243,6 @@ soup_auth_class_init (SoupAuthClass *auth_class) G_PARAM_READABLE)); } -static void -soup_auth_init (SoupAuth *auth) -{ -} - -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; - } -} - -static void -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: - g_value_set_string (value, soup_auth_get_realm (auth)); - break; - case PROP_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; - } -} - /** * soup_auth_new: * @type: the type of auth to create (a subtype of #SoupAuth) diff --git a/libsoup/soup-body-input-stream.c b/libsoup/soup-body-input-stream.c index a635bd5..e554f21 100644 --- a/libsoup/soup-body-input-stream.c +++ b/libsoup/soup-body-input-stream.c @@ -68,7 +68,7 @@ soup_body_input_stream_init (SoupBodyInputStream *bistream) } static void -constructed (GObject *object) +soup_body_input_stream_constructed (GObject *object) { SoupBodyInputStream *bistream = SOUP_BODY_INPUT_STREAM (object); @@ -81,8 +81,8 @@ constructed (GObject *object) } static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_body_input_stream_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupBodyInputStream *bistream = SOUP_BODY_INPUT_STREAM (object); @@ -102,8 +102,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_body_input_stream_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupBodyInputStream *bistream = SOUP_BODY_INPUT_STREAM (object); @@ -334,9 +334,9 @@ soup_body_input_stream_class_init (SoupBodyInputStreamClass *stream_class) g_type_class_add_private (stream_class, sizeof (SoupBodyInputStreamPrivate)); - object_class->constructed = constructed; - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->constructed = soup_body_input_stream_constructed; + object_class->set_property = soup_body_input_stream_set_property; + object_class->get_property = soup_body_input_stream_get_property; input_stream_class->read_fn = soup_body_input_stream_read_fn; input_stream_class->close_fn = soup_body_input_stream_close_fn; diff --git a/libsoup/soup-body-output-stream.c b/libsoup/soup-body-output-stream.c index 269ec71..5c93347 100644 --- a/libsoup/soup-body-output-stream.c +++ b/libsoup/soup-body-output-stream.c @@ -60,7 +60,7 @@ soup_body_output_stream_init (SoupBodyOutputStream *stream) } static void -constructed (GObject *object) +soup_body_output_stream_constructed (GObject *object) { SoupBodyOutputStream *bostream = SOUP_BODY_OUTPUT_STREAM (object); @@ -68,8 +68,8 @@ constructed (GObject *object) } static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_body_output_stream_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupBodyOutputStream *bostream = SOUP_BODY_OUTPUT_STREAM (object); @@ -89,8 +89,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_body_output_stream_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupBodyOutputStream *bostream = SOUP_BODY_OUTPUT_STREAM (object); @@ -276,9 +276,9 @@ soup_body_output_stream_class_init (SoupBodyOutputStreamClass *stream_class) g_type_class_add_private (stream_class, sizeof (SoupBodyOutputStreamPrivate)); - object_class->constructed = constructed; - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->constructed = soup_body_output_stream_constructed; + object_class->set_property = soup_body_output_stream_set_property; + object_class->get_property = soup_body_output_stream_get_property; output_stream_class->write_fn = soup_body_output_stream_write_fn; output_stream_class->close_fn = soup_body_output_stream_close_fn; diff --git a/libsoup/soup-client-input-stream.c b/libsoup/soup-client-input-stream.c index 155680f..29ac87e 100644 --- a/libsoup/soup-client-input-stream.c +++ b/libsoup/soup-client-input-stream.c @@ -49,8 +49,8 @@ soup_client_input_stream_init (SoupClientInputStream *stream) } static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_client_input_stream_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupClientInputStream *cistream = SOUP_CLIENT_INPUT_STREAM (object); @@ -65,8 +65,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_client_input_stream_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupClientInputStream *cistream = SOUP_CLIENT_INPUT_STREAM (object); @@ -255,8 +255,8 @@ soup_client_input_stream_class_init (SoupClientInputStreamClass *stream_class) g_type_class_add_private (stream_class, sizeof (SoupClientInputStreamPrivate)); - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->set_property = soup_client_input_stream_set_property; + object_class->get_property = soup_client_input_stream_get_property; input_stream_class->read_fn = soup_client_input_stream_read_fn; input_stream_class->close_fn = soup_client_input_stream_close_fn; diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c index 11d54ff..a70e764 100644 --- a/libsoup/soup-connection.c +++ b/libsoup/soup-connection.c @@ -80,11 +80,6 @@ enum { LAST_PROP }; -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static void stop_idle_timer (SoupConnectionPrivate *priv); static void clear_current_item (SoupConnection *conn); @@ -99,7 +94,7 @@ soup_connection_init (SoupConnection *conn) } static void -finalize (GObject *object) +soup_connection_finalize (GObject *object) { SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object); @@ -113,7 +108,7 @@ finalize (GObject *object) } static void -dispose (GObject *object) +soup_connection_dispose (GObject *object) { SoupConnection *conn = SOUP_CONNECTION (object); SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn); @@ -135,6 +130,110 @@ dispose (GObject *object) } static void +soup_connection_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object); + SoupProxyURIResolver *proxy_resolver; + + switch (prop_id) { + case PROP_REMOTE_URI: + priv->remote_uri = g_value_dup_boxed (value); + break; + case PROP_PROXY_RESOLVER: + proxy_resolver = g_value_get_object (value); + if (proxy_resolver && SOUP_IS_PROXY_RESOLVER_DEFAULT (proxy_resolver)) + priv->use_gproxyresolver = TRUE; + else if (proxy_resolver) + priv->proxy_resolver = g_object_ref (proxy_resolver); + break; + case PROP_SSL: + priv->ssl = g_value_get_boolean (value); + break; + case PROP_SSL_CREDS: + if (priv->tlsdb) + g_object_unref (priv->tlsdb); + priv->tlsdb = g_value_dup_object (value); + break; + case PROP_SSL_STRICT: + priv->ssl_strict = g_value_get_boolean (value); + break; + case PROP_SSL_FALLBACK: + priv->ssl_fallback = g_value_get_boolean (value); + break; + case PROP_ASYNC_CONTEXT: + priv->async_context = g_value_get_pointer (value); + if (priv->async_context) + g_main_context_ref (priv->async_context); + break; + case PROP_USE_THREAD_CONTEXT: + priv->use_thread_context = g_value_get_boolean (value); + break; + case PROP_TIMEOUT: + priv->io_timeout = g_value_get_uint (value); + break; + case PROP_IDLE_TIMEOUT: + priv->idle_timeout = g_value_get_uint (value); + break; + case PROP_STATE: + soup_connection_set_state (SOUP_CONNECTION (object), g_value_get_uint (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +soup_connection_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_REMOTE_URI: + g_value_set_boxed (value, priv->remote_uri); + break; + case PROP_SSL: + g_value_set_boolean (value, priv->ssl); + break; + case PROP_SSL_CREDS: + g_value_set_object (value, priv->tlsdb); + break; + case PROP_SSL_STRICT: + g_value_set_boolean (value, priv->ssl_strict); + break; + case PROP_SSL_FALLBACK: + g_value_set_boolean (value, priv->ssl_fallback); + break; + case PROP_ASYNC_CONTEXT: + g_value_set_pointer (value, priv->async_context ? g_main_context_ref (priv->async_context) : NULL); + break; + case PROP_USE_THREAD_CONTEXT: + g_value_set_boolean (value, priv->use_thread_context); + break; + case PROP_TIMEOUT: + g_value_set_uint (value, priv->io_timeout); + break; + case PROP_IDLE_TIMEOUT: + g_value_set_uint (value, priv->idle_timeout); + break; + case PROP_STATE: + g_value_set_enum (value, priv->state); + break; + case PROP_MESSAGE: + if (priv->cur_item) + g_value_set_object (value, priv->cur_item->msg); + else + g_value_set_object (value, NULL); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void soup_connection_class_init (SoupConnectionClass *connection_class) { GObjectClass *object_class = G_OBJECT_CLASS (connection_class); @@ -142,10 +241,10 @@ soup_connection_class_init (SoupConnectionClass *connection_class) g_type_class_add_private (connection_class, sizeof (SoupConnectionPrivate)); /* virtual method override */ - object_class->dispose = dispose; - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->dispose = soup_connection_dispose; + object_class->finalize = soup_connection_finalize; + object_class->set_property = soup_connection_set_property; + object_class->get_property = soup_connection_get_property; /* signals */ signals[EVENT] = @@ -253,110 +352,6 @@ soup_connection_class_init (SoupConnectionClass *connection_class) G_PARAM_READABLE)); } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object); - SoupProxyURIResolver *proxy_resolver; - - switch (prop_id) { - case PROP_REMOTE_URI: - priv->remote_uri = g_value_dup_boxed (value); - break; - case PROP_PROXY_RESOLVER: - proxy_resolver = g_value_get_object (value); - if (proxy_resolver && SOUP_IS_PROXY_RESOLVER_DEFAULT (proxy_resolver)) - priv->use_gproxyresolver = TRUE; - else if (proxy_resolver) - priv->proxy_resolver = g_object_ref (proxy_resolver); - break; - case PROP_SSL: - priv->ssl = g_value_get_boolean (value); - break; - case PROP_SSL_CREDS: - if (priv->tlsdb) - g_object_unref (priv->tlsdb); - priv->tlsdb = g_value_dup_object (value); - break; - case PROP_SSL_STRICT: - priv->ssl_strict = g_value_get_boolean (value); - break; - case PROP_SSL_FALLBACK: - priv->ssl_fallback = g_value_get_boolean (value); - break; - case PROP_ASYNC_CONTEXT: - priv->async_context = g_value_get_pointer (value); - if (priv->async_context) - g_main_context_ref (priv->async_context); - break; - case PROP_USE_THREAD_CONTEXT: - priv->use_thread_context = g_value_get_boolean (value); - break; - case PROP_TIMEOUT: - priv->io_timeout = g_value_get_uint (value); - break; - case PROP_IDLE_TIMEOUT: - priv->idle_timeout = g_value_get_uint (value); - break; - case PROP_STATE: - soup_connection_set_state (SOUP_CONNECTION (object), g_value_get_uint (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_REMOTE_URI: - g_value_set_boxed (value, priv->remote_uri); - break; - case PROP_SSL: - g_value_set_boolean (value, priv->ssl); - break; - case PROP_SSL_CREDS: - g_value_set_object (value, priv->tlsdb); - break; - case PROP_SSL_STRICT: - g_value_set_boolean (value, priv->ssl_strict); - break; - case PROP_SSL_FALLBACK: - g_value_set_boolean (value, priv->ssl_fallback); - break; - case PROP_ASYNC_CONTEXT: - g_value_set_pointer (value, priv->async_context ? g_main_context_ref (priv->async_context) : NULL); - break; - case PROP_USE_THREAD_CONTEXT: - g_value_set_boolean (value, priv->use_thread_context); - break; - case PROP_TIMEOUT: - g_value_set_uint (value, priv->io_timeout); - break; - case PROP_IDLE_TIMEOUT: - g_value_set_uint (value, priv->idle_timeout); - break; - case PROP_STATE: - g_value_set_enum (value, priv->state); - break; - case PROP_MESSAGE: - if (priv->cur_item) - g_value_set_object (value, priv->cur_item->msg); - else - g_value_set_object (value, NULL); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static gboolean idle_timeout (gpointer conn) { diff --git a/libsoup/soup-content-decoder.c b/libsoup/soup-content-decoder.c index e25caff..aeda5f0 100644 --- a/libsoup/soup-content-decoder.c +++ b/libsoup/soup-content-decoder.c @@ -56,11 +56,6 @@ typedef GConverter * (*SoupContentDecoderCreator) (void); static void soup_content_decoder_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer interface_data); -static void request_queued (SoupSessionFeature *feature, SoupSession *session, SoupMessage *msg); -static void request_unqueued (SoupSessionFeature *feature, SoupSession *session, SoupMessage *msg); - -static void finalize (GObject *object); - G_DEFINE_TYPE_WITH_CODE (SoupContentDecoder, soup_content_decoder, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE, soup_content_decoder_session_feature_init)) @@ -98,31 +93,23 @@ soup_content_decoder_init (SoupContentDecoder *decoder) } static void -soup_content_decoder_class_init (SoupContentDecoderClass *decoder_class) +soup_content_decoder_finalize (GObject *object) { - GObjectClass *object_class = G_OBJECT_CLASS (decoder_class); - - g_type_class_add_private (decoder_class, sizeof (SoupContentDecoderPrivate)); + SoupContentDecoder *decoder = SOUP_CONTENT_DECODER (object); - object_class->finalize = finalize; -} + g_hash_table_destroy (decoder->priv->decoders); -static void -soup_content_decoder_session_feature_init (SoupSessionFeatureInterface *feature_interface, - gpointer interface_data) -{ - feature_interface->request_queued = request_queued; - feature_interface->request_unqueued = request_unqueued; + G_OBJECT_CLASS (soup_content_decoder_parent_class)->finalize (object); } static void -finalize (GObject *object) +soup_content_decoder_class_init (SoupContentDecoderClass *decoder_class) { - SoupContentDecoder *decoder = SOUP_CONTENT_DECODER (object); + GObjectClass *object_class = G_OBJECT_CLASS (decoder_class); - g_hash_table_destroy (decoder->priv->decoders); + g_type_class_add_private (decoder_class, sizeof (SoupContentDecoderPrivate)); - G_OBJECT_CLASS (soup_content_decoder_parent_class)->finalize (object); + object_class->finalize = soup_content_decoder_finalize; } static void @@ -184,8 +171,9 @@ soup_content_decoder_got_headers_cb (SoupMessage *msg, SoupContentDecoder *decod } static void -request_queued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg) +soup_content_decoder_request_queued (SoupSessionFeature *feature, + SoupSession *session, + SoupMessage *msg) { SoupContentDecoder *decoder = SOUP_CONTENT_DECODER (feature); @@ -202,8 +190,17 @@ request_queued (SoupSessionFeature *feature, SoupSession *session, } static void -request_unqueued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg) +soup_content_decoder_request_unqueued (SoupSessionFeature *feature, + SoupSession *session, + SoupMessage *msg) { g_signal_handlers_disconnect_by_func (msg, soup_content_decoder_got_headers_cb, feature); } + +static void +soup_content_decoder_session_feature_init (SoupSessionFeatureInterface *feature_interface, + gpointer interface_data) +{ + feature_interface->request_queued = soup_content_decoder_request_queued; + feature_interface->request_unqueued = soup_content_decoder_request_unqueued; +} diff --git a/libsoup/soup-content-sniffer.c b/libsoup/soup-content-sniffer.c index 67ff352..4cf3864 100644 --- a/libsoup/soup-content-sniffer.c +++ b/libsoup/soup-content-sniffer.c @@ -32,14 +32,8 @@ * Since: 2.27.3 **/ -static char *sniff (SoupContentSniffer *sniffer, SoupMessage *msg, SoupBuffer *buffer, GHashTable **params); -static gsize get_buffer_size (SoupContentSniffer *sniffer); - static void soup_content_sniffer_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer interface_data); -static void request_queued (SoupSessionFeature *feature, SoupSession *session, SoupMessage *msg); -static void request_unqueued (SoupSessionFeature *feature, SoupSession *session, SoupMessage *msg); - G_DEFINE_TYPE_WITH_CODE (SoupContentSniffer, soup_content_sniffer, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE, soup_content_sniffer_session_feature_init)) @@ -49,71 +43,6 @@ soup_content_sniffer_init (SoupContentSniffer *content_sniffer) { } -static void -soup_content_sniffer_class_init (SoupContentSnifferClass *content_sniffer_class) -{ - content_sniffer_class->sniff = sniff; - content_sniffer_class->get_buffer_size = get_buffer_size; -} - -static void -soup_content_sniffer_session_feature_init (SoupSessionFeatureInterface *feature_interface, - gpointer interface_data) -{ - feature_interface->request_queued = request_queued; - feature_interface->request_unqueued = request_unqueued; -} - -/** - * soup_content_sniffer_new: - * - * Creates a new #SoupContentSniffer. - * - * Returns: a new #SoupContentSniffer - * - * Since: 2.27.3 - **/ -SoupContentSniffer * -soup_content_sniffer_new () -{ - return g_object_new (SOUP_TYPE_CONTENT_SNIFFER, NULL); -} - -/** - * soup_content_sniffer_sniff: - * @sniffer: a #SoupContentSniffer - * @msg: the message to sniff - * @buffer: a buffer containing the start of @msg's response body - * @params: (element-type utf8 utf8) (out) (transfer full) (allow-none): return - * location for Content-Type parameters (eg, "charset"), or %NULL - * - * Sniffs @buffer to determine its Content-Type. The result may also - * be influenced by the Content-Type declared in @msg's response - * headers. - * - * Return value: the sniffed Content-Type of @buffer; this will never be %NULL, - * but may be "application/octet-stream". - */ -char * -soup_content_sniffer_sniff (SoupContentSniffer *sniffer, - SoupMessage *msg, SoupBuffer *buffer, - GHashTable **params) -{ - g_return_val_if_fail (SOUP_IS_CONTENT_SNIFFER (sniffer), NULL); - g_return_val_if_fail (SOUP_IS_MESSAGE (msg), NULL); - g_return_val_if_fail (buffer != NULL, NULL); - - return SOUP_CONTENT_SNIFFER_GET_CLASS (sniffer)->sniff (sniffer, msg, buffer, params); -} - -gsize -soup_content_sniffer_get_buffer_size (SoupContentSniffer *sniffer) -{ - g_return_val_if_fail (SOUP_IS_CONTENT_SNIFFER (sniffer), 0); - - return SOUP_CONTENT_SNIFFER_GET_CLASS (sniffer)->get_buffer_size (sniffer); -} - /* This table is based on the HTML5 spec; * See 2.7.4 Content-Type sniffing: unknown type */ @@ -502,8 +431,9 @@ sniff_feed_or_html (SoupContentSniffer *sniffer, SoupMessage *msg, SoupBuffer *b return g_strdup ("text/html"); } -static char* -sniff (SoupContentSniffer *sniffer, SoupMessage *msg, SoupBuffer *buffer, GHashTable **params) +static char * +soup_content_sniffer_real_sniff (SoupContentSniffer *sniffer, SoupMessage *msg, + SoupBuffer *buffer, GHashTable **params) { const char *content_type; @@ -547,7 +477,7 @@ sniff (SoupContentSniffer *sniffer, SoupMessage *msg, SoupBuffer *buffer, GHashT } static gsize -get_buffer_size (SoupContentSniffer *sniffer) +soup_content_sniffer_real_get_buffer_size (SoupContentSniffer *sniffer) { return 512; } @@ -561,8 +491,9 @@ soup_content_sniffer_got_headers_cb (SoupMessage *msg, SoupContentSniffer *sniff } static void -request_queued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg) +soup_content_sniffer_request_queued (SoupSessionFeature *feature, + SoupSession *session, + SoupMessage *msg) { SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); @@ -573,8 +504,9 @@ request_queued (SoupSessionFeature *feature, SoupSession *session, } static void -request_unqueued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg) +soup_content_sniffer_request_unqueued (SoupSessionFeature *feature, + SoupSession *session, + SoupMessage *msg) { SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); @@ -583,3 +515,68 @@ request_unqueued (SoupSessionFeature *feature, SoupSession *session, g_signal_handlers_disconnect_by_func (msg, soup_content_sniffer_got_headers_cb, feature); } + +static void +soup_content_sniffer_class_init (SoupContentSnifferClass *content_sniffer_class) +{ + content_sniffer_class->sniff = soup_content_sniffer_real_sniff; + content_sniffer_class->get_buffer_size = soup_content_sniffer_real_get_buffer_size; +} + +static void +soup_content_sniffer_session_feature_init (SoupSessionFeatureInterface *feature_interface, + gpointer interface_data) +{ + feature_interface->request_queued = soup_content_sniffer_request_queued; + feature_interface->request_unqueued = soup_content_sniffer_request_unqueued; +} + +/** + * soup_content_sniffer_new: + * + * Creates a new #SoupContentSniffer. + * + * Returns: a new #SoupContentSniffer + * + * Since: 2.27.3 + **/ +SoupContentSniffer * +soup_content_sniffer_new () +{ + return g_object_new (SOUP_TYPE_CONTENT_SNIFFER, NULL); +} + +/** + * soup_content_sniffer_sniff: + * @sniffer: a #SoupContentSniffer + * @msg: the message to sniff + * @buffer: a buffer containing the start of @msg's response body + * @params: (element-type utf8 utf8) (out) (transfer full) (allow-none): return + * location for Content-Type parameters (eg, "charset"), or %NULL + * + * Sniffs @buffer to determine its Content-Type. The result may also + * be influenced by the Content-Type declared in @msg's response + * headers. + * + * Return value: the sniffed Content-Type of @buffer; this will never be %NULL, + * but may be "application/octet-stream". + */ +char * +soup_content_sniffer_sniff (SoupContentSniffer *sniffer, + SoupMessage *msg, SoupBuffer *buffer, + GHashTable **params) +{ + g_return_val_if_fail (SOUP_IS_CONTENT_SNIFFER (sniffer), NULL); + g_return_val_if_fail (SOUP_IS_MESSAGE (msg), NULL); + g_return_val_if_fail (buffer != NULL, NULL); + + return SOUP_CONTENT_SNIFFER_GET_CLASS (sniffer)->sniff (sniffer, msg, buffer, params); +} + +gsize +soup_content_sniffer_get_buffer_size (SoupContentSniffer *sniffer) +{ + g_return_val_if_fail (SOUP_IS_CONTENT_SNIFFER (sniffer), 0); + + return SOUP_CONTENT_SNIFFER_GET_CLASS (sniffer)->get_buffer_size (sniffer); +} diff --git a/libsoup/soup-cookie-jar-sqlite.c b/libsoup/soup-cookie-jar-sqlite.c index 413a565..a0b6b79 100644 --- a/libsoup/soup-cookie-jar-sqlite.c +++ b/libsoup/soup-cookie-jar-sqlite.c @@ -46,15 +46,6 @@ typedef struct { G_DEFINE_TYPE (SoupCookieJarSqlite, soup_cookie_jar_sqlite, SOUP_TYPE_COOKIE_JAR) static void load (SoupCookieJar *jar); -static void changed (SoupCookieJar *jar, - SoupCookie *old_cookie, - SoupCookie *new_cookie); -static gboolean is_persistent (SoupCookieJar *jar); - -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); static void soup_cookie_jar_sqlite_init (SoupCookieJarSqlite *sqlite) @@ -62,7 +53,7 @@ soup_cookie_jar_sqlite_init (SoupCookieJarSqlite *sqlite) } static void -finalize (GObject *object) +soup_cookie_jar_sqlite_finalize (GObject *object) { SoupCookieJarSqlitePrivate *priv = SOUP_COOKIE_JAR_SQLITE_GET_PRIVATE (object); @@ -76,39 +67,8 @@ finalize (GObject *object) } static void -soup_cookie_jar_sqlite_class_init (SoupCookieJarSqliteClass *sqlite_class) -{ - SoupCookieJarClass *cookie_jar_class = - SOUP_COOKIE_JAR_CLASS (sqlite_class); - GObjectClass *object_class = G_OBJECT_CLASS (sqlite_class); - - g_type_class_add_private (sqlite_class, sizeof (SoupCookieJarSqlitePrivate)); - - cookie_jar_class->is_persistent = is_persistent; - cookie_jar_class->changed = changed; - - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; - - /** - * SOUP_COOKIE_JAR_SQLITE_FILENAME: - * - * Alias for the #SoupCookieJarSqlite:filename property. (The - * cookie-storage filename.) - **/ - g_object_class_install_property ( - object_class, PROP_FILENAME, - g_param_spec_string (SOUP_COOKIE_JAR_SQLITE_FILENAME, - "Filename", - "Cookie-storage filename", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_cookie_jar_sqlite_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupCookieJarSqlitePrivate *priv = SOUP_COOKIE_JAR_SQLITE_GET_PRIVATE (object); @@ -125,8 +85,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_cookie_jar_sqlite_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupCookieJarSqlitePrivate *priv = SOUP_COOKIE_JAR_SQLITE_GET_PRIVATE (object); @@ -301,9 +261,9 @@ load (SoupCookieJar *jar) } static void -changed (SoupCookieJar *jar, - SoupCookie *old_cookie, - SoupCookie *new_cookie) +soup_cookie_jar_sqlite_changed (SoupCookieJar *jar, + SoupCookie *old_cookie, + SoupCookie *new_cookie) { SoupCookieJarSqlitePrivate *priv = SOUP_COOKIE_JAR_SQLITE_GET_PRIVATE (jar); @@ -340,7 +300,38 @@ changed (SoupCookieJar *jar, } static gboolean -is_persistent (SoupCookieJar *jar) +soup_cookie_jar_sqlite_is_persistent (SoupCookieJar *jar) { return TRUE; } + +static void +soup_cookie_jar_sqlite_class_init (SoupCookieJarSqliteClass *sqlite_class) +{ + SoupCookieJarClass *cookie_jar_class = + SOUP_COOKIE_JAR_CLASS (sqlite_class); + GObjectClass *object_class = G_OBJECT_CLASS (sqlite_class); + + g_type_class_add_private (sqlite_class, sizeof (SoupCookieJarSqlitePrivate)); + + cookie_jar_class->is_persistent = soup_cookie_jar_sqlite_is_persistent; + cookie_jar_class->changed = soup_cookie_jar_sqlite_changed; + + object_class->finalize = soup_cookie_jar_sqlite_finalize; + object_class->set_property = soup_cookie_jar_sqlite_set_property; + object_class->get_property = soup_cookie_jar_sqlite_get_property; + + /** + * SOUP_COOKIE_JAR_SQLITE_FILENAME: + * + * Alias for the #SoupCookieJarSqlite:filename property. (The + * cookie-storage filename.) + **/ + g_object_class_install_property ( + object_class, PROP_FILENAME, + g_param_spec_string (SOUP_COOKIE_JAR_SQLITE_FILENAME, + "Filename", + "Cookie-storage filename", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); +} diff --git a/libsoup/soup-cookie-jar-text.c b/libsoup/soup-cookie-jar-text.c index 259431f..64f03dc 100644 --- a/libsoup/soup-cookie-jar-text.c +++ b/libsoup/soup-cookie-jar-text.c @@ -41,16 +41,7 @@ typedef struct { G_DEFINE_TYPE (SoupCookieJarText, soup_cookie_jar_text, SOUP_TYPE_COOKIE_JAR) -static void load (SoupCookieJar *jar); -static void changed (SoupCookieJar *jar, - SoupCookie *old_cookie, - SoupCookie *new_cookie); -static gboolean is_persistent (SoupCookieJar *jar); - -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void load (SoupCookieJar *jar); static void soup_cookie_jar_text_init (SoupCookieJarText *text) @@ -58,7 +49,7 @@ soup_cookie_jar_text_init (SoupCookieJarText *text) } static void -finalize (GObject *object) +soup_cookie_jar_text_finalize (GObject *object) { SoupCookieJarTextPrivate *priv = SOUP_COOKIE_JAR_TEXT_GET_PRIVATE (object); @@ -69,39 +60,8 @@ finalize (GObject *object) } static void -soup_cookie_jar_text_class_init (SoupCookieJarTextClass *text_class) -{ - SoupCookieJarClass *cookie_jar_class = - SOUP_COOKIE_JAR_CLASS (text_class); - GObjectClass *object_class = G_OBJECT_CLASS (text_class); - - g_type_class_add_private (text_class, sizeof (SoupCookieJarTextPrivate)); - - cookie_jar_class->is_persistent = is_persistent; - cookie_jar_class->changed = changed; - - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; - - /** - * SOUP_COOKIE_JAR_TEXT_FILENAME: - * - * Alias for the #SoupCookieJarText:filename property. (The - * cookie-storage filename.) - **/ - g_object_class_install_property ( - object_class, PROP_FILENAME, - g_param_spec_string (SOUP_COOKIE_JAR_TEXT_FILENAME, - "Filename", - "Cookie-storage filename", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_cookie_jar_text_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupCookieJarTextPrivate *priv = SOUP_COOKIE_JAR_TEXT_GET_PRIVATE (object); @@ -118,8 +78,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_cookie_jar_text_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupCookieJarTextPrivate *priv = SOUP_COOKIE_JAR_TEXT_GET_PRIVATE (object); @@ -316,9 +276,9 @@ delete_cookie (const char *filename, SoupCookie *cookie) } static void -changed (SoupCookieJar *jar, - SoupCookie *old_cookie, - SoupCookie *new_cookie) +soup_cookie_jar_text_changed (SoupCookieJar *jar, + SoupCookie *old_cookie, + SoupCookie *new_cookie) { FILE *out; SoupCookieJarTextPrivate *priv = @@ -367,7 +327,38 @@ changed (SoupCookieJar *jar, } static gboolean -is_persistent (SoupCookieJar *jar) +soup_cookie_jar_text_is_persistent (SoupCookieJar *jar) { return TRUE; } + +static void +soup_cookie_jar_text_class_init (SoupCookieJarTextClass *text_class) +{ + SoupCookieJarClass *cookie_jar_class = + SOUP_COOKIE_JAR_CLASS (text_class); + GObjectClass *object_class = G_OBJECT_CLASS (text_class); + + g_type_class_add_private (text_class, sizeof (SoupCookieJarTextPrivate)); + + cookie_jar_class->is_persistent = soup_cookie_jar_text_is_persistent; + cookie_jar_class->changed = soup_cookie_jar_text_changed; + + object_class->finalize = soup_cookie_jar_text_finalize; + object_class->set_property = soup_cookie_jar_text_set_property; + object_class->get_property = soup_cookie_jar_text_get_property; + + /** + * SOUP_COOKIE_JAR_TEXT_FILENAME: + * + * Alias for the #SoupCookieJarText:filename property. (The + * cookie-storage filename.) + **/ + g_object_class_install_property ( + object_class, PROP_FILENAME, + g_param_spec_string (SOUP_COOKIE_JAR_TEXT_FILENAME, + "Filename", + "Cookie-storage filename", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); +} diff --git a/libsoup/soup-cookie-jar.c b/libsoup/soup-cookie-jar.c index ab5a803..2d47aab 100644 --- a/libsoup/soup-cookie-jar.c +++ b/libsoup/soup-cookie-jar.c @@ -37,13 +37,6 @@ **/ static void soup_cookie_jar_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer interface_data); -static void request_queued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg); -static void request_started (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg, SoupSocket *socket); -static void request_unqueued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg); -static gboolean is_persistent (SoupCookieJar *jar); G_DEFINE_TYPE_WITH_CODE (SoupCookieJar, soup_cookie_jar, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE, @@ -73,11 +66,6 @@ typedef struct { } SoupCookieJarPrivate; #define SOUP_COOKIE_JAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_COOKIE_JAR, SoupCookieJarPrivate)) -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static void soup_cookie_jar_init (SoupCookieJar *jar) { @@ -91,7 +79,7 @@ soup_cookie_jar_init (SoupCookieJar *jar) } static void -constructed (GObject *object) +soup_cookie_jar_constructed (GObject *object) { SoupCookieJarPrivate *priv = SOUP_COOKIE_JAR_GET_PRIVATE (object); @@ -99,7 +87,7 @@ constructed (GObject *object) } static void -finalize (GObject *object) +soup_cookie_jar_finalize (GObject *object) { SoupCookieJarPrivate *priv = SOUP_COOKIE_JAR_GET_PRIVATE (object); GHashTableIter iter; @@ -115,18 +103,64 @@ finalize (GObject *object) } static void +soup_cookie_jar_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + SoupCookieJarPrivate *priv = + SOUP_COOKIE_JAR_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_READ_ONLY: + priv->read_only = g_value_get_boolean (value); + break; + case PROP_ACCEPT_POLICY: + priv->accept_policy = g_value_get_enum (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +soup_cookie_jar_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + SoupCookieJarPrivate *priv = + SOUP_COOKIE_JAR_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_READ_ONLY: + g_value_set_boolean (value, priv->read_only); + break; + case PROP_ACCEPT_POLICY: + g_value_set_enum (value, priv->accept_policy); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static gboolean +soup_cookie_jar_real_is_persistent (SoupCookieJar *jar) +{ + return FALSE; +} + +static void soup_cookie_jar_class_init (SoupCookieJarClass *jar_class) { GObjectClass *object_class = G_OBJECT_CLASS (jar_class); g_type_class_add_private (jar_class, sizeof (SoupCookieJarPrivate)); - object_class->constructed = constructed; - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->constructed = soup_cookie_jar_constructed; + object_class->finalize = soup_cookie_jar_finalize; + object_class->set_property = soup_cookie_jar_set_property; + object_class->get_property = soup_cookie_jar_get_property; - jar_class->is_persistent = is_persistent; + jar_class->is_persistent = soup_cookie_jar_real_is_persistent; /** * SoupCookieJar::changed: @@ -191,55 +225,6 @@ soup_cookie_jar_class_init (SoupCookieJarClass *jar_class) G_PARAM_READWRITE)); } -static void -soup_cookie_jar_session_feature_init (SoupSessionFeatureInterface *feature_interface, - gpointer interface_data) -{ - feature_interface->request_queued = request_queued; - feature_interface->request_started = request_started; - feature_interface->request_unqueued = request_unqueued; -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - SoupCookieJarPrivate *priv = - SOUP_COOKIE_JAR_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_READ_ONLY: - priv->read_only = g_value_get_boolean (value); - break; - case PROP_ACCEPT_POLICY: - priv->accept_policy = g_value_get_enum (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - SoupCookieJarPrivate *priv = - SOUP_COOKIE_JAR_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_READ_ONLY: - g_value_set_boolean (value, priv->read_only); - break; - case PROP_ACCEPT_POLICY: - g_value_set_enum (value, priv->accept_policy); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - /** * soup_cookie_jar_new: * @@ -270,12 +255,6 @@ soup_cookie_jar_save (SoupCookieJar *jar) /* Does nothing, obsolete */ } -static gboolean -is_persistent (SoupCookieJar *jar) -{ - return FALSE; -} - static void soup_cookie_jar_changed (SoupCookieJar *jar, SoupCookie *old, SoupCookie *new) @@ -680,8 +659,9 @@ process_set_cookie_header (SoupMessage *msg, gpointer user_data) } static void -request_queued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg) +soup_cookie_jar_request_queued (SoupSessionFeature *feature, + SoupSession *session, + SoupMessage *msg) { soup_message_add_header_handler (msg, "got-headers", "Set-Cookie", @@ -690,8 +670,10 @@ request_queued (SoupSessionFeature *feature, SoupSession *session, } static void -request_started (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg, SoupSocket *socket) +soup_cookie_jar_request_started (SoupSessionFeature *feature, + SoupSession *session, + SoupMessage *msg, + SoupSocket *socket) { SoupCookieJar *jar = SOUP_COOKIE_JAR (feature); char *cookies; @@ -706,12 +688,22 @@ request_started (SoupSessionFeature *feature, SoupSession *session, } static void -request_unqueued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg) +soup_cookie_jar_request_unqueued (SoupSessionFeature *feature, + SoupSession *session, + SoupMessage *msg) { g_signal_handlers_disconnect_by_func (msg, process_set_cookie_header, feature); } +static void +soup_cookie_jar_session_feature_init (SoupSessionFeatureInterface *feature_interface, + gpointer interface_data) +{ + feature_interface->request_queued = soup_cookie_jar_request_queued; + feature_interface->request_started = soup_cookie_jar_request_started; + feature_interface->request_unqueued = soup_cookie_jar_request_unqueued; +} + /** * soup_cookie_jar_all_cookies: * @jar: a #SoupCookieJar diff --git a/libsoup/soup-filter-input-stream.c b/libsoup/soup-filter-input-stream.c index f8c1ab9..ba0137f 100644 --- a/libsoup/soup-filter-input-stream.c +++ b/libsoup/soup-filter-input-stream.c @@ -40,7 +40,7 @@ soup_filter_input_stream_init (SoupFilterInputStream *stream) } static void -finalize (GObject *object) +soup_filter_input_stream_finalize (GObject *object) { SoupFilterInputStream *fstream = SOUP_FILTER_INPUT_STREAM (object); @@ -144,7 +144,7 @@ soup_filter_input_stream_class_init (SoupFilterInputStreamClass *stream_class) g_type_class_add_private (stream_class, sizeof (SoupFilterInputStreamPrivate)); - object_class->finalize = finalize; + object_class->finalize = soup_filter_input_stream_finalize; input_stream_class->read_fn = soup_filter_input_stream_read_fn; } diff --git a/libsoup/soup-logger.c b/libsoup/soup-logger.c index 536f327..e68c4a8 100644 --- a/libsoup/soup-logger.c +++ b/libsoup/soup-logger.c @@ -83,13 +83,6 @@ static void soup_logger_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer interface_data); -static void request_queued (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg); -static void request_started (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg, SoupSocket *socket); -static void request_unqueued (SoupSessionFeature *feature, - SoupSession *session, SoupMessage *msg); - G_DEFINE_TYPE_WITH_CODE (SoupLogger, soup_logger, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE, soup_logger_session_feature_init)) @@ -131,7 +124,7 @@ soup_logger_init (SoupLogger *logger) } static void -finalize (GObject *object) +soup_logger_finalize (GObject *object) { SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (object); @@ -156,16 +149,7 @@ soup_logger_class_init (SoupLoggerClass *logger_class) g_type_class_add_private (logger_class, sizeof (SoupLoggerPrivate)); - object_class->finalize = finalize; -} - -static void -soup_logger_session_feature_init (SoupSessionFeatureInterface *feature_interface, - gpointer interface_data) -{ - feature_interface->request_queued = request_queued; - feature_interface->request_started = request_started; - feature_interface->request_unqueued = request_unqueued; + object_class->finalize = soup_logger_finalize; } /** @@ -630,8 +614,9 @@ got_body (SoupMessage *msg, gpointer user_data) } static void -request_queued (SoupSessionFeature *logger, SoupSession *session, - SoupMessage *msg) +soup_logger_request_queued (SoupSessionFeature *logger, + SoupSession *session, + SoupMessage *msg) { g_return_if_fail (SOUP_IS_MESSAGE (msg)); @@ -644,8 +629,10 @@ request_queued (SoupSessionFeature *logger, SoupSession *session, } static void -request_started (SoupSessionFeature *feature, SoupSession *session, - SoupMessage *msg, SoupSocket *socket) +soup_logger_request_started (SoupSessionFeature *feature, + SoupSession *session, + SoupMessage *msg, + SoupSocket *socket) { SoupLogger *logger = SOUP_LOGGER (feature); gboolean restarted; @@ -674,11 +661,21 @@ request_started (SoupSessionFeature *feature, SoupSession *session, } static void -request_unqueued (SoupSessionFeature *logger, SoupSession *session, - SoupMessage *msg) +soup_logger_request_unqueued (SoupSessionFeature *logger, + SoupSession *session, + SoupMessage *msg) { g_return_if_fail (SOUP_IS_MESSAGE (msg)); g_signal_handlers_disconnect_by_func (msg, got_informational, logger); g_signal_handlers_disconnect_by_func (msg, got_body, logger); } + +static void +soup_logger_session_feature_init (SoupSessionFeatureInterface *feature_interface, + gpointer interface_data) +{ + feature_interface->request_queued = soup_logger_request_queued; + feature_interface->request_started = soup_logger_request_started; + feature_interface->request_unqueued = soup_logger_request_unqueued; +} diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c index 0d025a1..eae697d 100644 --- a/libsoup/soup-message.c +++ b/libsoup/soup-message.c @@ -135,13 +135,6 @@ enum { LAST_PROP }; -static void got_body (SoupMessage *req); - -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static void soup_message_init (SoupMessage *msg) { @@ -156,7 +149,7 @@ soup_message_init (SoupMessage *msg) } static void -finalize (GObject *object) +soup_message_finalize (GObject *object) { SoupMessage *msg = SOUP_MESSAGE (object); SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); @@ -189,6 +182,136 @@ finalize (GObject *object) } static void +soup_message_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + SoupMessage *msg = SOUP_MESSAGE (object); + SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); + + switch (prop_id) { + case PROP_METHOD: + msg->method = g_intern_string (g_value_get_string (value)); + break; + case PROP_URI: + soup_message_set_uri (msg, g_value_get_boxed (value)); + break; + case PROP_HTTP_VERSION: + soup_message_set_http_version (msg, g_value_get_enum (value)); + break; + case PROP_FLAGS: + soup_message_set_flags (msg, g_value_get_flags (value)); + break; + case PROP_SERVER_SIDE: + priv->server_side = g_value_get_boolean (value); + if (priv->server_side) { + soup_message_headers_set_encoding (msg->response_headers, + SOUP_ENCODING_CONTENT_LENGTH); + } + break; + case PROP_STATUS_CODE: + soup_message_set_status (msg, g_value_get_uint (value)); + break; + case PROP_REASON_PHRASE: + soup_message_set_status_full (msg, msg->status_code, + g_value_get_string (value)); + break; + case PROP_FIRST_PARTY: + soup_message_set_first_party (msg, g_value_get_boxed (value)); + break; + case PROP_TLS_CERTIFICATE: + if (priv->tls_certificate) + g_object_unref (priv->tls_certificate); + priv->tls_certificate = g_value_dup_object (value); + if (priv->tls_errors) + priv->msg_flags &= ~SOUP_MESSAGE_CERTIFICATE_TRUSTED; + else if (priv->tls_certificate) + priv->msg_flags |= SOUP_MESSAGE_CERTIFICATE_TRUSTED; + break; + case PROP_TLS_ERRORS: + priv->tls_errors = g_value_get_flags (value); + if (priv->tls_errors) + priv->msg_flags &= ~SOUP_MESSAGE_CERTIFICATE_TRUSTED; + else if (priv->tls_certificate) + priv->msg_flags |= SOUP_MESSAGE_CERTIFICATE_TRUSTED; + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +soup_message_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + SoupMessage *msg = SOUP_MESSAGE (object); + SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); + + switch (prop_id) { + case PROP_METHOD: + g_value_set_string (value, msg->method); + break; + case PROP_URI: + g_value_set_boxed (value, priv->uri); + break; + case PROP_HTTP_VERSION: + g_value_set_enum (value, priv->http_version); + break; + case PROP_FLAGS: + g_value_set_flags (value, priv->msg_flags); + break; + case PROP_SERVER_SIDE: + g_value_set_boolean (value, priv->server_side); + break; + case PROP_STATUS_CODE: + g_value_set_uint (value, msg->status_code); + break; + case PROP_REASON_PHRASE: + g_value_set_string (value, msg->reason_phrase); + break; + case PROP_FIRST_PARTY: + g_value_set_boxed (value, priv->first_party); + break; + case PROP_REQUEST_BODY: + g_value_set_boxed (value, msg->request_body); + break; + case PROP_REQUEST_HEADERS: + g_value_set_boxed (value, msg->request_headers); + break; + case PROP_RESPONSE_BODY: + g_value_set_boxed (value, msg->response_body); + break; + case PROP_RESPONSE_HEADERS: + g_value_set_boxed (value, msg->response_headers); + break; + case PROP_TLS_CERTIFICATE: + g_value_set_object (value, priv->tls_certificate); + break; + case PROP_TLS_ERRORS: + g_value_set_flags (value, priv->tls_errors); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +soup_message_real_got_body (SoupMessage *req) +{ + SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (req); + SoupMessageBody *body; + + body = priv->server_side ? req->request_body : req->response_body; + if (soup_message_body_get_accumulate (body)) { + SoupBuffer *buffer; + + buffer = soup_message_body_flatten (body); + soup_buffer_free (buffer); + } +} + +static void soup_message_class_init (SoupMessageClass *message_class) { GObjectClass *object_class = G_OBJECT_CLASS (message_class); @@ -196,12 +319,12 @@ soup_message_class_init (SoupMessageClass *message_class) g_type_class_add_private (message_class, sizeof (SoupMessagePrivate)); /* virtual method definition */ - message_class->got_body = got_body; + message_class->got_body = soup_message_real_got_body; /* virtual method override */ - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->finalize = soup_message_finalize; + object_class->set_property = soup_message_set_property; + object_class->get_property = soup_message_get_property; /* signals */ @@ -734,121 +857,6 @@ soup_message_class_init (SoupMessageClass *message_class) G_PARAM_READWRITE)); } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - SoupMessage *msg = SOUP_MESSAGE (object); - SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); - - switch (prop_id) { - case PROP_METHOD: - msg->method = g_intern_string (g_value_get_string (value)); - break; - case PROP_URI: - soup_message_set_uri (msg, g_value_get_boxed (value)); - break; - case PROP_HTTP_VERSION: - soup_message_set_http_version (msg, g_value_get_enum (value)); - break; - case PROP_FLAGS: - soup_message_set_flags (msg, g_value_get_flags (value)); - break; - case PROP_SERVER_SIDE: - priv->server_side = g_value_get_boolean (value); - if (priv->server_side) { - soup_message_headers_set_encoding (msg->response_headers, - SOUP_ENCODING_CONTENT_LENGTH); - } - break; - case PROP_STATUS_CODE: - soup_message_set_status (msg, g_value_get_uint (value)); - break; - case PROP_REASON_PHRASE: - soup_message_set_status_full (msg, msg->status_code, - g_value_get_string (value)); - break; - case PROP_FIRST_PARTY: - soup_message_set_first_party (msg, g_value_get_boxed (value)); - break; - case PROP_TLS_CERTIFICATE: - if (priv->tls_certificate) - g_object_unref (priv->tls_certificate); - priv->tls_certificate = g_value_dup_object (value); - if (priv->tls_errors) - priv->msg_flags &= ~SOUP_MESSAGE_CERTIFICATE_TRUSTED; - else if (priv->tls_certificate) - priv->msg_flags |= SOUP_MESSAGE_CERTIFICATE_TRUSTED; - break; - case PROP_TLS_ERRORS: - priv->tls_errors = g_value_get_flags (value); - if (priv->tls_errors) - priv->msg_flags &= ~SOUP_MESSAGE_CERTIFICATE_TRUSTED; - else if (priv->tls_certificate) - priv->msg_flags |= SOUP_MESSAGE_CERTIFICATE_TRUSTED; - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - SoupMessage *msg = SOUP_MESSAGE (object); - SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); - - switch (prop_id) { - case PROP_METHOD: - g_value_set_string (value, msg->method); - break; - case PROP_URI: - g_value_set_boxed (value, priv->uri); - break; - case PROP_HTTP_VERSION: - g_value_set_enum (value, priv->http_version); - break; - case PROP_FLAGS: - g_value_set_flags (value, priv->msg_flags); - break; - case PROP_SERVER_SIDE: - g_value_set_boolean (value, priv->server_side); - break; - case PROP_STATUS_CODE: - g_value_set_uint (value, msg->status_code); - break; - case PROP_REASON_PHRASE: - g_value_set_string (value, msg->reason_phrase); - break; - case PROP_FIRST_PARTY: - g_value_set_boxed (value, priv->first_party); - break; - case PROP_REQUEST_BODY: - g_value_set_boxed (value, msg->request_body); - break; - case PROP_REQUEST_HEADERS: - g_value_set_boxed (value, msg->request_headers); - break; - case PROP_RESPONSE_BODY: - g_value_set_boxed (value, msg->response_body); - break; - case PROP_RESPONSE_HEADERS: - g_value_set_boxed (value, msg->response_headers); - break; - case PROP_TLS_CERTIFICATE: - g_value_set_object (value, priv->tls_certificate); - break; - case PROP_TLS_ERRORS: - g_value_set_flags (value, priv->tls_errors); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - /** * soup_message_new: @@ -1073,21 +1081,6 @@ soup_message_got_chunk (SoupMessage *msg, SoupBuffer *chunk) g_signal_emit (msg, signals[GOT_CHUNK], 0, chunk); } -static void -got_body (SoupMessage *req) -{ - SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (req); - SoupMessageBody *body; - - body = priv->server_side ? req->request_body : req->response_body; - if (soup_message_body_get_accumulate (body)) { - SoupBuffer *buffer; - - buffer = soup_message_body_flatten (body); - soup_buffer_free (buffer); - } -} - /** * soup_message_got_body: * @msg: a #SoupMessage diff --git a/libsoup/soup-password-manager-gnome.c b/libsoup/soup-password-manager-gnome.c index ae65564..bf36cb0 100644 --- a/libsoup/soup-password-manager-gnome.c +++ b/libsoup/soup-password-manager-gnome.c @@ -24,36 +24,11 @@ G_DEFINE_TYPE_EXTENDED (SoupPasswordManagerGNOME, soup_password_manager_gnome, G G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE, NULL) G_IMPLEMENT_INTERFACE (SOUP_TYPE_PASSWORD_MANAGER, soup_password_manager_gnome_interface_init)) -static void get_passwords_async (SoupPasswordManager *password_manager, - SoupMessage *msg, - SoupAuth *auth, - gboolean retrying, - GMainContext *async_context, - GCancellable *cancellable, - SoupPasswordManagerCallback callback, - gpointer user_data); -static void get_passwords_sync (SoupPasswordManager *password_manager, - SoupMessage *msg, - SoupAuth *auth, - GCancellable *cancellable); - static void soup_password_manager_gnome_init (SoupPasswordManagerGNOME *manager_gnome) { } -static void -soup_password_manager_gnome_class_init (SoupPasswordManagerGNOMEClass *gnome_class) -{ -} - -static void -soup_password_manager_gnome_interface_init (SoupPasswordManagerInterface *password_manager_interface) -{ - password_manager_interface->get_passwords_async = get_passwords_async; - password_manager_interface->get_passwords_sync = get_passwords_sync; -} - static void save_password_callback (GnomeKeyringResult result, guint32 val, gpointer data) @@ -168,14 +143,14 @@ free_auth_data (gpointer data) } static void -get_passwords_async (SoupPasswordManager *password_manager, - SoupMessage *msg, - SoupAuth *auth, - gboolean retrying, - GMainContext *async_context, - GCancellable *cancellable, - SoupPasswordManagerCallback callback, - gpointer user_data) +soup_password_manager_gnome_get_passwords_async (SoupPasswordManager *password_manager, + SoupMessage *msg, + SoupAuth *auth, + gboolean retrying, + GMainContext *async_context, + GCancellable *cancellable, + SoupPasswordManagerCallback callback, + gpointer user_data) { SoupPasswordManagerGNOMEAuthData *auth_data; SoupURI *uri = soup_message_get_uri (msg); @@ -209,10 +184,10 @@ get_passwords_async (SoupPasswordManager *password_manager, } static void -get_passwords_sync (SoupPasswordManager *password_manager, - SoupMessage *msg, - SoupAuth *auth, - GCancellable *cancellable) +soup_password_manager_gnome_get_passwords_sync (SoupPasswordManager *password_manager, + SoupMessage *msg, + SoupAuth *auth, + GCancellable *cancellable) { SoupURI *uri = soup_message_get_uri (msg); GList *results = NULL; @@ -231,3 +206,17 @@ get_passwords_sync (SoupPasswordManager *password_manager, update_auth_for_passwords (auth, msg, results, FALSE); } + +static void +soup_password_manager_gnome_class_init (SoupPasswordManagerGNOMEClass *gnome_class) +{ +} + +static void +soup_password_manager_gnome_interface_init (SoupPasswordManagerInterface *password_manager_interface) +{ + password_manager_interface->get_passwords_async = + soup_password_manager_gnome_get_passwords_async; + password_manager_interface->get_passwords_sync = + soup_password_manager_gnome_get_passwords_sync; +} diff --git a/libsoup/soup-proxy-resolver-static.c b/libsoup/soup-proxy-resolver-static.c index 9b702d4..93a833a 100644 --- a/libsoup/soup-proxy-resolver-static.c +++ b/libsoup/soup-proxy-resolver-static.c @@ -37,29 +37,13 @@ enum { LAST_PROP }; -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - -static void get_proxy_uri_async (SoupProxyURIResolver *proxy_resolver, - SoupURI *uri, - GMainContext *async_context, - GCancellable *cancellable, - SoupProxyURIResolverCallback callback, - gpointer user_data); -static guint get_proxy_uri_sync (SoupProxyURIResolver *proxy_resolver, - SoupURI *uri, - GCancellable *cancellable, - SoupURI **proxy_uri); - static void soup_proxy_resolver_static_init (SoupProxyResolverStatic *resolver_static) { } static void -finalize (GObject *object) +soup_proxy_resolver_static_finalize (GObject *object) { SoupProxyResolverStaticPrivate *priv = SOUP_PROXY_RESOLVER_STATIC_GET_PRIVATE (object); @@ -70,28 +54,8 @@ finalize (GObject *object) } static void -soup_proxy_resolver_static_class_init (SoupProxyResolverStaticClass *static_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (static_class); - - g_type_class_add_private (static_class, sizeof (SoupProxyResolverStaticPrivate)); - - object_class->set_property = set_property; - object_class->get_property = get_property; - object_class->finalize = finalize; - - g_object_class_install_property ( - object_class, PROP_PROXY_URI, - g_param_spec_boxed (SOUP_PROXY_RESOLVER_STATIC_PROXY_URI, - "Proxy URI", - "The HTTP Proxy to use", - SOUP_TYPE_URI, - G_PARAM_READWRITE)); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_proxy_resolver_static_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupProxyResolverStaticPrivate *priv = SOUP_PROXY_RESOLVER_STATIC_GET_PRIVATE (object); @@ -112,8 +76,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_proxy_resolver_static_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupProxyResolverStaticPrivate *priv = SOUP_PROXY_RESOLVER_STATIC_GET_PRIVATE (object); @@ -128,21 +92,6 @@ get_property (GObject *object, guint prop_id, } } -static void -soup_proxy_resolver_static_interface_init (SoupProxyURIResolverInterface *proxy_uri_resolver_interface) -{ - proxy_uri_resolver_interface->get_proxy_uri_async = get_proxy_uri_async; - proxy_uri_resolver_interface->get_proxy_uri_sync = get_proxy_uri_sync; -} - -SoupProxyURIResolver * -soup_proxy_resolver_static_new (SoupURI *proxy_uri) -{ - return g_object_new (SOUP_TYPE_PROXY_RESOLVER_STATIC, - SOUP_PROXY_RESOLVER_STATIC_PROXY_URI, proxy_uri, - NULL); -} - typedef struct { SoupProxyURIResolver *proxy_resolver; SoupProxyURIResolverCallback callback; @@ -166,12 +115,12 @@ idle_return_proxy_uri (gpointer data) } static void -get_proxy_uri_async (SoupProxyURIResolver *proxy_resolver, - SoupURI *uri, - GMainContext *async_context, - GCancellable *cancellable, - SoupProxyURIResolverCallback callback, - gpointer user_data) +soup_proxy_resolver_static_get_proxy_uri_async (SoupProxyURIResolver *proxy_resolver, + SoupURI *uri, + GMainContext *async_context, + GCancellable *cancellable, + SoupProxyURIResolverCallback callback, + gpointer user_data) { SoupStaticAsyncData *ssad; @@ -183,10 +132,10 @@ get_proxy_uri_async (SoupProxyURIResolver *proxy_resolver, } static guint -get_proxy_uri_sync (SoupProxyURIResolver *proxy_resolver, - SoupURI *uri, - GCancellable *cancellable, - SoupURI **proxy_uri) +soup_proxy_resolver_static_get_proxy_uri_sync (SoupProxyURIResolver *proxy_resolver, + SoupURI *uri, + GCancellable *cancellable, + SoupURI **proxy_uri) { SoupProxyResolverStaticPrivate *priv = SOUP_PROXY_RESOLVER_STATIC_GET_PRIVATE (proxy_resolver); @@ -194,3 +143,40 @@ get_proxy_uri_sync (SoupProxyURIResolver *proxy_resolver, *proxy_uri = soup_uri_copy (priv->proxy_uri); return SOUP_STATUS_OK; } + +static void +soup_proxy_resolver_static_class_init (SoupProxyResolverStaticClass *static_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (static_class); + + g_type_class_add_private (static_class, sizeof (SoupProxyResolverStaticPrivate)); + + object_class->set_property = soup_proxy_resolver_static_set_property; + object_class->get_property = soup_proxy_resolver_static_get_property; + object_class->finalize = soup_proxy_resolver_static_finalize; + + g_object_class_install_property ( + object_class, PROP_PROXY_URI, + g_param_spec_boxed (SOUP_PROXY_RESOLVER_STATIC_PROXY_URI, + "Proxy URI", + "The HTTP Proxy to use", + SOUP_TYPE_URI, + G_PARAM_READWRITE)); +} + +static void +soup_proxy_resolver_static_interface_init (SoupProxyURIResolverInterface *proxy_uri_resolver_interface) +{ + proxy_uri_resolver_interface->get_proxy_uri_async = + soup_proxy_resolver_static_get_proxy_uri_async; + proxy_uri_resolver_interface->get_proxy_uri_sync = + soup_proxy_resolver_static_get_proxy_uri_sync; +} + +SoupProxyURIResolver * +soup_proxy_resolver_static_new (SoupURI *proxy_uri) +{ + return g_object_new (SOUP_TYPE_PROXY_RESOLVER_STATIC, + SOUP_PROXY_RESOLVER_STATIC_PROXY_URI, proxy_uri, + NULL); +} diff --git a/libsoup/soup-requester.c b/libsoup/soup-requester.c index 5897ed2..c3d1f32 100644 --- a/libsoup/soup-requester.c +++ b/libsoup/soup-requester.c @@ -64,7 +64,7 @@ soup_requester_init (SoupRequester *requester) } static void -finalize (GObject *object) +soup_requester_finalize (GObject *object) { SoupRequester *requester = SOUP_REQUESTER (object); @@ -81,7 +81,7 @@ soup_requester_class_init (SoupRequesterClass *requester_class) g_type_class_add_private (requester_class, sizeof (SoupRequesterPrivate)); /* virtual method override */ - object_class->finalize = finalize; + object_class->finalize = soup_requester_finalize; } static void diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c index e6a7711..9ec1301 100644 --- a/libsoup/soup-server.c +++ b/libsoup/soup-server.c @@ -134,14 +134,6 @@ enum { LAST_PROP }; -static GObject *constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_properties); -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static SoupClientContext *soup_client_context_ref (SoupClientContext *client); static void soup_client_context_unref (SoupClientContext *client); @@ -161,7 +153,7 @@ soup_server_init (SoupServer *server) } static void -finalize (GObject *object) +soup_server_finalize (GObject *object) { SoupServer *server = SOUP_SERVER (object); SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (server); @@ -211,6 +203,159 @@ finalize (GObject *object) G_OBJECT_CLASS (soup_server_parent_class)->finalize (object); } +static GObject * +soup_server_constructor (GType type, + guint n_construct_properties, + GObjectConstructParam *construct_properties) +{ + GObject *server; + SoupServerPrivate *priv; + + server = G_OBJECT_CLASS (soup_server_parent_class)->constructor ( + type, n_construct_properties, construct_properties); + if (!server) + return NULL; + priv = SOUP_SERVER_GET_PRIVATE (server); + + if (!priv->iface) { + priv->iface = + soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV4, + priv->port); + } + + if (priv->ssl_cert_file && priv->ssl_key_file) { + GError *error = NULL; + + if (priv->ssl_cert) + g_object_unref (priv->ssl_cert); + priv->ssl_cert = g_tls_certificate_new_from_files (priv->ssl_cert_file, priv->ssl_key_file, &error); + if (!priv->ssl_cert) { + g_warning ("Could not read SSL certificate from '%s': %s", + priv->ssl_cert_file, error->message); + g_error_free (error); + g_object_unref (server); + return NULL; + } + } + + priv->listen_sock = + soup_socket_new (SOUP_SOCKET_LOCAL_ADDRESS, priv->iface, + SOUP_SOCKET_SSL_CREDENTIALS, priv->ssl_cert, + SOUP_SOCKET_ASYNC_CONTEXT, priv->async_context, + NULL); + if (!soup_socket_listen (priv->listen_sock)) { + g_object_unref (server); + return NULL; + } + + /* Re-resolve the interface address, in particular in case + * the passed-in address had SOUP_ADDRESS_ANY_PORT. + */ + g_object_unref (priv->iface); + priv->iface = soup_socket_get_local_address (priv->listen_sock); + g_object_ref (priv->iface); + priv->port = soup_address_get_port (priv->iface); + + return server; +} + +static void +soup_server_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (object); + const char *header; + + switch (prop_id) { + case PROP_PORT: + priv->port = g_value_get_uint (value); + break; + case PROP_INTERFACE: + if (priv->iface) + g_object_unref (priv->iface); + priv->iface = g_value_get_object (value); + if (priv->iface) + g_object_ref (priv->iface); + break; + case PROP_SSL_CERT_FILE: + priv->ssl_cert_file = + g_strdup (g_value_get_string (value)); + break; + case PROP_SSL_KEY_FILE: + priv->ssl_key_file = + g_strdup (g_value_get_string (value)); + break; + case PROP_TLS_CERTIFICATE: + if (priv->ssl_cert) + g_object_unref (priv->ssl_cert); + priv->ssl_cert = g_value_dup_object (value); + break; + case PROP_ASYNC_CONTEXT: + priv->async_context = g_value_get_pointer (value); + if (priv->async_context) + g_main_context_ref (priv->async_context); + break; + case PROP_RAW_PATHS: + priv->raw_paths = g_value_get_boolean (value); + break; + case PROP_SERVER_HEADER: + g_free (priv->server_header); + header = g_value_get_string (value); + if (!header) + priv->server_header = NULL; + else if (!*header) { + priv->server_header = + g_strdup (SOUP_SERVER_SERVER_HEADER_BASE); + } else if (g_str_has_suffix (header, " ")) { + priv->server_header = + g_strdup_printf ("%s%s", header, + SOUP_SERVER_SERVER_HEADER_BASE); + } else + priv->server_header = g_strdup (header); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +soup_server_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_PORT: + g_value_set_uint (value, priv->port); + break; + case PROP_INTERFACE: + g_value_set_object (value, priv->iface); + break; + case PROP_SSL_CERT_FILE: + g_value_set_string (value, priv->ssl_cert_file); + break; + case PROP_SSL_KEY_FILE: + g_value_set_string (value, priv->ssl_key_file); + break; + case PROP_TLS_CERTIFICATE: + g_value_set_object (value, priv->ssl_cert); + break; + case PROP_ASYNC_CONTEXT: + g_value_set_pointer (value, priv->async_context ? g_main_context_ref (priv->async_context) : NULL); + break; + case PROP_RAW_PATHS: + g_value_set_boolean (value, priv->raw_paths); + break; + case PROP_SERVER_HEADER: + g_value_set_string (value, priv->server_header); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + static void soup_server_class_init (SoupServerClass *server_class) { @@ -219,10 +364,10 @@ soup_server_class_init (SoupServerClass *server_class) g_type_class_add_private (server_class, sizeof (SoupServerPrivate)); /* virtual method override */ - object_class->constructor = constructor; - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->constructor = soup_server_constructor; + object_class->finalize = soup_server_finalize; + object_class->set_property = soup_server_set_property; + object_class->get_property = soup_server_get_property; /* signals */ @@ -494,159 +639,6 @@ soup_server_class_init (SoupServerClass *server_class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); } -static GObject * -constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_properties) -{ - GObject *server; - SoupServerPrivate *priv; - - server = G_OBJECT_CLASS (soup_server_parent_class)->constructor ( - type, n_construct_properties, construct_properties); - if (!server) - return NULL; - priv = SOUP_SERVER_GET_PRIVATE (server); - - if (!priv->iface) { - priv->iface = - soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV4, - priv->port); - } - - if (priv->ssl_cert_file && priv->ssl_key_file) { - GError *error = NULL; - - if (priv->ssl_cert) - g_object_unref (priv->ssl_cert); - priv->ssl_cert = g_tls_certificate_new_from_files (priv->ssl_cert_file, priv->ssl_key_file, &error); - if (!priv->ssl_cert) { - g_warning ("Could not read SSL certificate from '%s': %s", - priv->ssl_cert_file, error->message); - g_error_free (error); - g_object_unref (server); - return NULL; - } - } - - priv->listen_sock = - soup_socket_new (SOUP_SOCKET_LOCAL_ADDRESS, priv->iface, - SOUP_SOCKET_SSL_CREDENTIALS, priv->ssl_cert, - SOUP_SOCKET_ASYNC_CONTEXT, priv->async_context, - NULL); - if (!soup_socket_listen (priv->listen_sock)) { - g_object_unref (server); - return NULL; - } - - /* Re-resolve the interface address, in particular in case - * the passed-in address had SOUP_ADDRESS_ANY_PORT. - */ - g_object_unref (priv->iface); - priv->iface = soup_socket_get_local_address (priv->listen_sock); - g_object_ref (priv->iface); - priv->port = soup_address_get_port (priv->iface); - - return server; -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (object); - const char *header; - - switch (prop_id) { - case PROP_PORT: - priv->port = g_value_get_uint (value); - break; - case PROP_INTERFACE: - if (priv->iface) - g_object_unref (priv->iface); - priv->iface = g_value_get_object (value); - if (priv->iface) - g_object_ref (priv->iface); - break; - case PROP_SSL_CERT_FILE: - priv->ssl_cert_file = - g_strdup (g_value_get_string (value)); - break; - case PROP_SSL_KEY_FILE: - priv->ssl_key_file = - g_strdup (g_value_get_string (value)); - break; - case PROP_TLS_CERTIFICATE: - if (priv->ssl_cert) - g_object_unref (priv->ssl_cert); - priv->ssl_cert = g_value_dup_object (value); - break; - case PROP_ASYNC_CONTEXT: - priv->async_context = g_value_get_pointer (value); - if (priv->async_context) - g_main_context_ref (priv->async_context); - break; - case PROP_RAW_PATHS: - priv->raw_paths = g_value_get_boolean (value); - break; - case PROP_SERVER_HEADER: - g_free (priv->server_header); - header = g_value_get_string (value); - if (!header) - priv->server_header = NULL; - else if (!*header) { - priv->server_header = - g_strdup (SOUP_SERVER_SERVER_HEADER_BASE); - } else if (g_str_has_suffix (header, " ")) { - priv->server_header = - g_strdup_printf ("%s%s", header, - SOUP_SERVER_SERVER_HEADER_BASE); - } else - priv->server_header = g_strdup (header); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_PORT: - g_value_set_uint (value, priv->port); - break; - case PROP_INTERFACE: - g_value_set_object (value, priv->iface); - break; - case PROP_SSL_CERT_FILE: - g_value_set_string (value, priv->ssl_cert_file); - break; - case PROP_SSL_KEY_FILE: - g_value_set_string (value, priv->ssl_key_file); - break; - case PROP_TLS_CERTIFICATE: - g_value_set_object (value, priv->ssl_cert); - break; - case PROP_ASYNC_CONTEXT: - g_value_set_pointer (value, priv->async_context ? g_main_context_ref (priv->async_context) : NULL); - break; - case PROP_RAW_PATHS: - g_value_set_boolean (value, priv->raw_paths); - break; - case PROP_SERVER_HEADER: - g_value_set_string (value, priv->server_header); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - /** * soup_server_new: * @optname1: name of first property to set diff --git a/libsoup/soup-session-async.c b/libsoup/soup-session-async.c index 90c44e2..4073838 100644 --- a/libsoup/soup-session-async.c +++ b/libsoup/soup-session-async.c @@ -37,16 +37,6 @@ static void send_request_running (SoupSession *session, SoupMessageQueueItem * static void send_request_restarted (SoupSession *session, SoupMessageQueueItem *item); static void send_request_finished (SoupSession *session, SoupMessageQueueItem *item); -static void queue_message (SoupSession *session, SoupMessage *req, - SoupSessionCallback callback, gpointer user_data); -static guint send_message (SoupSession *session, SoupMessage *req); -static void cancel_message (SoupSession *session, SoupMessage *msg, - guint status_code); -static void kick (SoupSession *session); - -static void auth_required (SoupSession *session, SoupMessage *msg, - SoupAuth *auth, gboolean retrying); - G_DEFINE_TYPE (SoupSessionAsync, soup_session_async, SOUP_TYPE_SESSION) typedef struct { @@ -65,7 +55,7 @@ soup_session_async_init (SoupSessionAsync *sa) } static void -dispose (GObject *object) +soup_session_async_dispose (GObject *object) { SoupSessionAsyncPrivate *priv = SOUP_SESSION_ASYNC_GET_PRIVATE (object); @@ -74,25 +64,6 @@ dispose (GObject *object) G_OBJECT_CLASS (soup_session_async_parent_class)->dispose (object); } -static void -soup_session_async_class_init (SoupSessionAsyncClass *soup_session_async_class) -{ - SoupSessionClass *session_class = SOUP_SESSION_CLASS (soup_session_async_class); - GObjectClass *object_class = G_OBJECT_CLASS (session_class); - - g_type_class_add_private (soup_session_async_class, - sizeof (SoupSessionAsyncPrivate)); - - /* virtual method override */ - session_class->queue_message = queue_message; - session_class->send_message = send_message; - session_class->cancel_message = cancel_message; - session_class->auth_required = auth_required; - session_class->kick = kick; - - object_class->dispose = dispose; -} - /** * soup_session_async_new: @@ -427,8 +398,8 @@ do_idle_run_queue (SoupSession *session) } static void -queue_message (SoupSession *session, SoupMessage *req, - SoupSessionCallback callback, gpointer user_data) +soup_session_async_queue_message (SoupSession *session, SoupMessage *req, + SoupSessionCallback callback, gpointer user_data) { SOUP_SESSION_CLASS (soup_session_async_parent_class)->queue_message (session, req, callback, user_data); @@ -436,7 +407,7 @@ queue_message (SoupSession *session, SoupMessage *req, } static guint -send_message (SoupSession *session, SoupMessage *req) +soup_session_async_send_message (SoupSession *session, SoupMessage *req) { SoupMessageQueueItem *item; GMainContext *async_context = @@ -445,7 +416,7 @@ send_message (SoupSession *session, SoupMessage *req) /* Balance out the unref that queuing will eventually do */ g_object_ref (req); - queue_message (session, req, NULL, NULL); + soup_session_async_queue_message (session, req, NULL, NULL); item = soup_message_queue_lookup (soup_session_get_queue (session), req); g_return_val_if_fail (item != NULL, SOUP_STATUS_MALFORMED); @@ -459,8 +430,8 @@ send_message (SoupSession *session, SoupMessage *req) } static void -cancel_message (SoupSession *session, SoupMessage *msg, - guint status_code) +soup_session_async_cancel_message (SoupSession *session, SoupMessage *msg, + guint status_code) { SoupMessageQueue *queue; SoupMessageQueueItem *item; @@ -502,8 +473,8 @@ got_passwords (SoupPasswordManager *password_manager, SoupMessage *msg, } static void -auth_required (SoupSession *session, SoupMessage *msg, - SoupAuth *auth, gboolean retrying) +soup_session_async_auth_required (SoupSession *session, SoupMessage *msg, + SoupAuth *auth, gboolean retrying) { SoupSessionFeature *password_manager; @@ -525,7 +496,7 @@ auth_required (SoupSession *session, SoupMessage *msg, } static void -kick (SoupSession *session) +soup_session_async_kick (SoupSession *session) { do_idle_run_queue (session); } @@ -732,7 +703,7 @@ soup_session_send_request_async (SoupSession *session, /* Balance out the unref that queuing will eventually do */ g_object_ref (msg); - queue_message (session, msg, NULL, NULL); + soup_session_async_queue_message (session, msg, NULL, NULL); item = soup_message_queue_lookup (soup_session_get_queue (session), msg); g_return_if_fail (item != NULL); @@ -764,3 +735,22 @@ soup_session_send_request_finish (SoupSession *session, return NULL; return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple)); } + +static void +soup_session_async_class_init (SoupSessionAsyncClass *soup_session_async_class) +{ + SoupSessionClass *session_class = SOUP_SESSION_CLASS (soup_session_async_class); + GObjectClass *object_class = G_OBJECT_CLASS (session_class); + + g_type_class_add_private (soup_session_async_class, + sizeof (SoupSessionAsyncPrivate)); + + /* virtual method override */ + session_class->queue_message = soup_session_async_queue_message; + session_class->send_message = soup_session_async_send_message; + session_class->cancel_message = soup_session_async_cancel_message; + session_class->auth_required = soup_session_async_auth_required; + session_class->kick = soup_session_async_kick; + + object_class->dispose = soup_session_async_dispose; +} diff --git a/libsoup/soup-session-feature.c b/libsoup/soup-session-feature.c index e7fe453..3728149 100644 --- a/libsoup/soup-session-feature.c +++ b/libsoup/soup-session-feature.c @@ -53,19 +53,9 @@ static void soup_session_feature_default_init (SoupSessionFeatureInterface *interface); -static void attach (SoupSessionFeature *feature, SoupSession *session); -static void detach (SoupSessionFeature *feature, SoupSession *session); - G_DEFINE_INTERFACE (SoupSessionFeature, soup_session_feature, G_TYPE_OBJECT) static void -soup_session_feature_default_init (SoupSessionFeatureInterface *interface) -{ - interface->attach = attach; - interface->detach = detach; -} - -static void weak_notify_unref (gpointer feature, GObject *ex_object) { g_object_unref (feature); @@ -103,7 +93,7 @@ request_unqueued (SoupSession *session, SoupMessage *msg, gpointer feature) } static void -attach (SoupSessionFeature *feature, SoupSession *session) +soup_session_feature_real_attach (SoupSessionFeature *feature, SoupSession *session) { g_object_weak_ref (G_OBJECT (session), weak_notify_unref, g_object_ref (feature)); @@ -132,7 +122,7 @@ soup_session_feature_attach (SoupSessionFeature *feature, } static void -detach (SoupSessionFeature *feature, SoupSession *session) +soup_session_feature_real_detach (SoupSessionFeature *feature, SoupSession *session) { g_object_weak_unref (G_OBJECT (session), weak_notify_unref, feature); @@ -150,6 +140,13 @@ soup_session_feature_detach (SoupSessionFeature *feature, SOUP_SESSION_FEATURE_GET_CLASS (feature)->detach (feature, session); } +static void +soup_session_feature_default_init (SoupSessionFeatureInterface *interface) +{ + interface->attach = soup_session_feature_real_attach; + interface->detach = soup_session_feature_real_detach; +} + /** * soup_session_feature_add_feature: * @feature: the "base" feature diff --git a/libsoup/soup-session-sync.c b/libsoup/soup-session-sync.c index f4cfd6e..d8e2110 100644 --- a/libsoup/soup-session-sync.c +++ b/libsoup/soup-session-sync.c @@ -52,16 +52,6 @@ typedef struct { } SoupSessionSyncPrivate; #define SOUP_SESSION_SYNC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_SESSION_SYNC, SoupSessionSyncPrivate)) -static void queue_message (SoupSession *session, SoupMessage *msg, - SoupSessionCallback callback, gpointer user_data); -static guint send_message (SoupSession *session, SoupMessage *msg); -static void cancel_message (SoupSession *session, SoupMessage *msg, - guint status_code); -static void auth_required (SoupSession *session, SoupMessage *msg, - SoupAuth *auth, gboolean retrying); -static void flush_queue (SoupSession *session); -static void kick (SoupSession *session); - G_DEFINE_TYPE (SoupSessionSync, soup_session_sync, SOUP_TYPE_SESSION) static void @@ -74,7 +64,7 @@ soup_session_sync_init (SoupSessionSync *ss) } static void -finalize (GObject *object) +soup_session_sync_finalize (GObject *object) { SoupSessionSyncPrivate *priv = SOUP_SESSION_SYNC_GET_PRIVATE (object); @@ -84,25 +74,6 @@ finalize (GObject *object) G_OBJECT_CLASS (soup_session_sync_parent_class)->finalize (object); } -static void -soup_session_sync_class_init (SoupSessionSyncClass *session_sync_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (session_sync_class); - SoupSessionClass *session_class = SOUP_SESSION_CLASS (session_sync_class); - - g_type_class_add_private (session_sync_class, sizeof (SoupSessionSyncPrivate)); - - /* virtual method override */ - session_class->queue_message = queue_message; - session_class->send_message = send_message; - session_class->cancel_message = cancel_message; - session_class->auth_required = auth_required; - session_class->flush_queue = flush_queue; - session_class->kick = kick; - - object_class->finalize = finalize; -} - /** * soup_session_sync_new: @@ -355,8 +326,8 @@ queue_message_thread (gpointer data) } static void -queue_message (SoupSession *session, SoupMessage *msg, - SoupSessionCallback callback, gpointer user_data) +soup_session_sync_queue_message (SoupSession *session, SoupMessage *msg, + SoupSessionCallback callback, gpointer user_data) { SoupMessageQueueItem *item; GThread *thread; @@ -373,7 +344,7 @@ queue_message (SoupSession *session, SoupMessage *msg, } static guint -send_message (SoupSession *session, SoupMessage *msg) +soup_session_sync_send_message (SoupSession *session, SoupMessage *msg) { SoupMessageQueueItem *item; guint status; @@ -390,7 +361,7 @@ send_message (SoupSession *session, SoupMessage *msg) } static void -cancel_message (SoupSession *session, SoupMessage *msg, guint status_code) +soup_session_sync_cancel_message (SoupSession *session, SoupMessage *msg, guint status_code) { SoupSessionSyncPrivate *priv = SOUP_SESSION_SYNC_GET_PRIVATE (session); @@ -401,8 +372,8 @@ cancel_message (SoupSession *session, SoupMessage *msg, guint status_code) } static void -auth_required (SoupSession *session, SoupMessage *msg, - SoupAuth *auth, gboolean retrying) +soup_session_sync_auth_required (SoupSession *session, SoupMessage *msg, + SoupAuth *auth, gboolean retrying) { SoupSessionFeature *password_manager; @@ -419,7 +390,7 @@ auth_required (SoupSession *session, SoupMessage *msg, } static void -flush_queue (SoupSession *session) +soup_session_sync_flush_queue (SoupSession *session) { SoupSessionSyncPrivate *priv = SOUP_SESSION_SYNC_GET_PRIVATE (session); SoupMessageQueue *queue; @@ -464,7 +435,7 @@ flush_queue (SoupSession *session) } static void -kick (SoupSession *session) +soup_session_sync_kick (SoupSession *session) { SoupSessionSyncPrivate *priv = SOUP_SESSION_SYNC_GET_PRIVATE (session); @@ -473,6 +444,25 @@ kick (SoupSession *session) g_mutex_unlock (&priv->lock); } +static void +soup_session_sync_class_init (SoupSessionSyncClass *session_sync_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (session_sync_class); + SoupSessionClass *session_class = SOUP_SESSION_CLASS (session_sync_class); + + g_type_class_add_private (session_sync_class, sizeof (SoupSessionSyncPrivate)); + + /* virtual method override */ + session_class->queue_message = soup_session_sync_queue_message; + session_class->send_message = soup_session_sync_send_message; + session_class->cancel_message = soup_session_sync_cancel_message; + session_class->auth_required = soup_session_sync_auth_required; + session_class->flush_queue = soup_session_sync_flush_queue; + session_class->kick = soup_session_sync_kick; + + object_class->finalize = soup_session_sync_finalize; +} + GInputStream * soup_session_send_request (SoupSession *session, diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c index 3d22660..a674f29 100644 --- a/libsoup/soup-session.c +++ b/libsoup/soup-session.c @@ -121,21 +121,16 @@ typedef struct { } SoupSessionPrivate; #define SOUP_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_SESSION, SoupSessionPrivate)) -static void free_host (SoupSessionHost *host); - -static void queue_message (SoupSession *session, SoupMessage *msg, - SoupSessionCallback callback, gpointer user_data); -static void requeue_message (SoupSession *session, SoupMessage *msg); -static void cancel_message (SoupSession *session, SoupMessage *msg, - guint status_code); -static void auth_required (SoupSession *session, SoupMessage *msg, - SoupAuth *auth, gboolean retrying); -static void flush_queue (SoupSession *session); +static void free_host (SoupSessionHost *host); static void auth_manager_authenticate (SoupAuthManager *manager, SoupMessage *msg, SoupAuth *auth, gboolean retrying, gpointer user_data); +static void soup_session_real_queue_message (SoupSession *session, SoupMessage *msg, + SoupSessionCallback callback, + gpointer user_data); + #define SOUP_SESSION_MAX_CONNS_DEFAULT 10 #define SOUP_SESSION_MAX_CONNS_PER_HOST_DEFAULT 2 @@ -186,11 +181,6 @@ enum { LAST_PROP }; -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static void soup_session_init (SoupSession *session) { @@ -236,7 +226,7 @@ soup_session_init (SoupSession *session) } static void -dispose (GObject *object) +soup_session_dispose (GObject *object) { SoupSession *session = SOUP_SESSION (object); SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session); @@ -250,7 +240,7 @@ dispose (GObject *object) } static void -finalize (GObject *object) +soup_session_finalize (GObject *object) { SoupSession *session = SOUP_SESSION (object); SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session); @@ -280,777 +270,82 @@ finalize (GObject *object) G_OBJECT_CLASS (soup_session_parent_class)->finalize (object); } -static void -soup_session_class_init (SoupSessionClass *session_class) +/* Converts a language in POSIX format and to be RFC2616 compliant */ +/* Based on code from epiphany-webkit (ephy_langs_append_languages()) */ +static gchar * +posix_lang_to_rfc2616 (const gchar *language) { - GObjectClass *object_class = G_OBJECT_CLASS (session_class); + /* Don't include charset variants, etc */ + if (strchr (language, '.') || strchr (language, '@')) + return NULL; - g_type_class_add_private (session_class, sizeof (SoupSessionPrivate)); + /* Ignore "C" locale, which g_get_language_names() always + * includes as a fallback. + */ + if (!strcmp (language, "C")) + return NULL; - /* virtual method definition */ - session_class->queue_message = queue_message; - session_class->requeue_message = requeue_message; - session_class->cancel_message = cancel_message; - session_class->auth_required = auth_required; - session_class->flush_queue = flush_queue; + return g_strdelimit (g_ascii_strdown (language, -1), "_", '-'); +} - /* virtual method override */ - object_class->dispose = dispose; - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; +/* Converts @quality from 0-100 to 0.0-1.0 and appends to @str */ +static gchar * +add_quality_value (const gchar *str, int quality) +{ + g_return_val_if_fail (str != NULL, NULL); - /* signals */ + if (quality >= 0 && quality < 100) { + /* We don't use %.02g because of "." vs "," locale issues */ + if (quality % 10) + return g_strdup_printf ("%s;q=0.%02d", str, quality); + else + return g_strdup_printf ("%s;q=0.%d", str, quality / 10); + } else + return g_strdup (str); +} - /** - * SoupSession::request-queued: - * @session: the session - * @msg: the request that was queued - * - * Emitted when a request is queued on @session. (Note that - * "queued" doesn't just mean soup_session_queue_message(); - * soup_session_send_message() implicitly queues the message - * as well.) - * - * When sending a request, first #SoupSession::request_queued - * is emitted, indicating that the session has become aware of - * the request. - * - * Once a connection is available to send the request on, the - * session emits #SoupSession::request_started. Then, various - * #SoupMessage signals are emitted as the message is - * processed. If the message is requeued, it will emit - * #SoupMessage::restarted, which will then be followed by - * another #SoupSession::request_started and another set of - * #SoupMessage signals when the message is re-sent. - * - * Eventually, the message will emit #SoupMessage::finished. - * Normally, this signals the completion of message - * processing. However, it is possible that the application - * will requeue the message from the "finished" handler (or - * equivalently, from the soup_session_queue_message() - * callback). In that case, the process will loop back to - * #SoupSession::request_started. - * - * Eventually, a message will reach "finished" and not be - * requeued. At that point, the session will emit - * #SoupSession::request_unqueued to indicate that it is done - * with the message. - * - * To sum up: #SoupSession::request_queued and - * #SoupSession::request_unqueued are guaranteed to be emitted - * exactly once, but #SoupSession::request_started and - * #SoupMessage::finished (and all of the other #SoupMessage - * signals) may be invoked multiple times for a given message. - * - * Since: 2.4.1 - **/ - signals[REQUEST_QUEUED] = - g_signal_new ("request-queued", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, /* FIXME? */ - NULL, NULL, - _soup_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - SOUP_TYPE_MESSAGE); +/* Returns a RFC2616 compliant languages list from system locales */ +static gchar * +accept_languages_from_system (void) +{ + const char * const * lang_names; + GPtrArray *langs = NULL; + char *lang, *langs_str; + int delta; + int i; - /** - * SoupSession::request-started: - * @session: the session - * @msg: the request being sent - * @socket: the socket the request is being sent on - * - * Emitted just before a request is sent. See - * #SoupSession::request_queued for a detailed description of - * the message lifecycle within a session. - **/ - signals[REQUEST_STARTED] = - g_signal_new ("request-started", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (SoupSessionClass, request_started), - NULL, NULL, - _soup_marshal_NONE__OBJECT_OBJECT, - G_TYPE_NONE, 2, - SOUP_TYPE_MESSAGE, - SOUP_TYPE_SOCKET); + lang_names = g_get_language_names (); + g_return_val_if_fail (lang_names != NULL, NULL); - /** - * SoupSession::request-unqueued: - * @session: the session - * @msg: the request that was unqueued - * - * Emitted when a request is removed from @session's queue, - * indicating that @session is done with it. See - * #SoupSession::request_queued for a detailed description of the - * message lifecycle within a session. - * - * Since: 2.4.1 - **/ - signals[REQUEST_UNQUEUED] = - g_signal_new ("request-unqueued", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, /* FIXME? */ - NULL, NULL, - _soup_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - SOUP_TYPE_MESSAGE); + /* Build the array of languages */ + langs = g_ptr_array_new_with_free_func (g_free); + for (i = 0; lang_names[i] != NULL; i++) { + lang = posix_lang_to_rfc2616 (lang_names[i]); + if (lang) + g_ptr_array_add (langs, lang); + } - /** - * SoupSession::authenticate: - * @session: the session - * @msg: the #SoupMessage being sent - * @auth: the #SoupAuth to authenticate - * @retrying: %TRUE if this is the second (or later) attempt - * - * Emitted when the session requires authentication. If - * credentials are available call soup_auth_authenticate() on - * @auth. If these credentials fail, the signal will be - * emitted again, with @retrying set to %TRUE, which will - * continue until you return without calling - * soup_auth_authenticate() on @auth. - * - * Note that this may be emitted before @msg's body has been - * fully read. - * - * If you call soup_session_pause_message() on @msg before - * returning, then you can authenticate @auth asynchronously - * (as long as you g_object_ref() it to make sure it doesn't - * get destroyed), and then unpause @msg when you are ready - * for it to continue. - **/ - signals[AUTHENTICATE] = - g_signal_new ("authenticate", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (SoupSessionClass, authenticate), - NULL, NULL, - _soup_marshal_NONE__OBJECT_OBJECT_BOOLEAN, - G_TYPE_NONE, 3, - SOUP_TYPE_MESSAGE, - SOUP_TYPE_AUTH, - G_TYPE_BOOLEAN); + /* Add quality values */ + if (langs->len < 10) + delta = 10; + else if (langs->len < 20) + delta = 5; + else + delta = 1; - /** - * SoupSession::connection-created: - * @session: the #SoupSession - * @connection: the connection - * - * Emitted when a new connection is created. This is an - * internal signal intended only to be used for debugging - * purposes, and may go away in the future. - * - * Since: 2.30 - */ - signals[CONNECTION_CREATED] = - g_signal_new ("connection-created", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - _soup_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - /* SoupConnection is private, so we can't use - * SOUP_TYPE_CONNECTION here. - */ - G_TYPE_OBJECT); + for (i = 0; i < langs->len; i++) { + lang = langs->pdata[i]; + langs->pdata[i] = add_quality_value (lang, 100 - i * delta); + g_free (lang); + } - /** - * SoupSession::tunneling: - * @session: the #SoupSession - * @connection: the connection - * - * Emitted when an SSL tunnel is being created on a proxy - * connection. This is an internal signal intended only to be - * used for debugging purposes, and may go away in the future. - * - * Since: 2.30 - */ - signals[TUNNELING] = - g_signal_new ("tunneling", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - _soup_marshal_NONE__OBJECT, - G_TYPE_NONE, 1, - /* SoupConnection is private, so we can't use - * SOUP_TYPE_CONNECTION here. - */ - G_TYPE_OBJECT); + /* Fallback: add "en" if list is empty */ + if (langs->len == 0) + g_ptr_array_add (langs, g_strdup ("en")); - - /* properties */ - /** - * SOUP_SESSION_PROXY_URI: - * - * Alias for the #SoupSession:proxy-uri property. (The HTTP - * proxy to use for this session.) - **/ - g_object_class_install_property ( - object_class, PROP_PROXY_URI, - g_param_spec_boxed (SOUP_SESSION_PROXY_URI, - "Proxy URI", - "The HTTP Proxy to use for this session", - SOUP_TYPE_URI, - G_PARAM_READWRITE)); - /** - * SOUP_SESSION_MAX_CONNS: - * - * Alias for the #SoupSession:max-conns property. (The maximum - * number of connections that the session can open at once.) - **/ - g_object_class_install_property ( - object_class, PROP_MAX_CONNS, - g_param_spec_int (SOUP_SESSION_MAX_CONNS, - "Max Connection Count", - "The maximum number of connections that the session can open at once", - 1, - G_MAXINT, - SOUP_SESSION_MAX_CONNS_DEFAULT, - G_PARAM_READWRITE)); - /** - * SOUP_SESSION_MAX_CONNS_PER_HOST: - * - * Alias for the #SoupSession:max-conns-per-host property. - * (The maximum number of connections that the session can - * open at once to a given host.) - **/ - g_object_class_install_property ( - object_class, PROP_MAX_CONNS_PER_HOST, - g_param_spec_int (SOUP_SESSION_MAX_CONNS_PER_HOST, - "Max Per-Host Connection Count", - "The maximum number of connections that the session can open at once to a given host", - 1, - G_MAXINT, - SOUP_SESSION_MAX_CONNS_PER_HOST_DEFAULT, - G_PARAM_READWRITE)); - /** - * SoupSession:idle-timeout: - * - * Connection lifetime when idle - * - * Since: 2.4.1 - **/ - /** - * SOUP_SESSION_IDLE_TIMEOUT: - * - * Alias for the #SoupSession:idle-timeout property. (The idle - * connection lifetime.) - * - * Since: 2.4.1 - **/ - g_object_class_install_property ( - object_class, PROP_IDLE_TIMEOUT, - g_param_spec_uint (SOUP_SESSION_IDLE_TIMEOUT, - "Idle Timeout", - "Connection lifetime when idle", - 0, G_MAXUINT, 0, - G_PARAM_READWRITE)); - /** - * SoupSession:use-ntlm: - * - * Whether or not to use NTLM authentication. - * - * Deprecated: use soup_session_add_feature_by_type() with - * #SOUP_TYPE_AUTH_NTLM. - **/ - /** - * SOUP_SESSION_USE_NTLM: - * - * Alias for the #SoupSession:use-ntlm property. (Whether or - * not to use NTLM authentication.) - **/ - g_object_class_install_property ( - object_class, PROP_USE_NTLM, - g_param_spec_boolean (SOUP_SESSION_USE_NTLM, - "Use NTLM", - "Whether or not to use NTLM authentication", - FALSE, - G_PARAM_READWRITE)); - /** - * SoupSession:ssl-ca-file: - * - * File containing SSL CA certificates. - * - * Deprecated: use #SoupSession:ssl-use-system-ca-file or - * #SoupSession:tls-database instead - **/ - /** - * SOUP_SESSION_SSL_CA_FILE: - * - * Alias for the #SoupSession:ssl-ca-file property. (File - * containing SSL CA certificates.). - * - * Deprecated: use #SoupSession:ssl-use-system-ca-file or - * #SoupSession:tls-database instead - **/ - g_object_class_install_property ( - object_class, PROP_SSL_CA_FILE, - g_param_spec_string (SOUP_SESSION_SSL_CA_FILE, - "SSL CA file", - "File containing SSL CA certificates", - NULL, - G_PARAM_READWRITE)); - /** - * SOUP_SESSION_USE_SYSTEM_CA_FILE: - * - * Alias for the #SoupSession:ssl-use-system-ca-file property, - * qv. - * - * Since: 2.38 - **/ - /** - * SoupSession:ssl-use-system-ca-file: - * - * Setting this to %TRUE is equivalent to setting - * #SoupSession:tls-database to the default system CA database. - * (and likewise, setting #SoupSession:tls-database to the - * default database by hand will cause this property to - * become %TRUE). - * - * Setting this to %FALSE (when it was previously %TRUE) will - * clear the #SoupSession:tls-database field. - * - * See #SoupSession:ssl-strict for more information on how - * https certificate validation is handled. - * - * Since: 2.38 - **/ - g_object_class_install_property ( - object_class, PROP_SSL_USE_SYSTEM_CA_FILE, - g_param_spec_boolean (SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, - "Use system CA file", - "Use the system certificate database", - FALSE, - G_PARAM_READWRITE)); - /** - * SOUP_SESSION_TLS_DATABASE: - * - * Alias for the #SoupSession:tls-database property, qv. - * - * Since: 2.38 - **/ - /** - * SoupSession:tls-database: - * - * Sets the #GTlsDatabase to use for validating SSL/TLS - * certificates. - * - * Note that setting the #SoupSession:ssl-ca-file or - * #SoupSession:ssl-use-system-ca-file property will cause - * this property to be set to a #GTlsDatabase corresponding to - * the indicated file or system default. - * - * See #SoupSession:ssl-strict for more information on how - * https certificate validation is handled. - * - * Since: 2.38 - **/ - g_object_class_install_property ( - object_class, PROP_TLS_DATABASE, - g_param_spec_object (SOUP_SESSION_TLS_DATABASE, - "TLS Database", - "TLS database to use", - G_TYPE_TLS_DATABASE, - G_PARAM_READWRITE)); - /** - * SOUP_SESSION_SSL_STRICT: - * - * Alias for the #SoupSession:ssl-strict property, qv. - * - * Since: 2.30 - **/ - /** - * SoupSession:ssl-strict: - * - * Normally, if #SoupSession:tlsdb is set (including if it was - * set via #SoupSession:ssl-use-system-ca-file or - * #SoupSession:ssl-ca-file), then libsoup will reject any - * certificate that is invalid (ie, expired) or that is not - * signed by one of the given CA certificates, and the - * #SoupMessage will fail with the status - * %SOUP_STATUS_SSL_FAILED. - * - * If you set #SoupSession:ssl-strict to %FALSE, then all - * certificates will be accepted, and you will need to call - * soup_message_get_https_status() to distinguish valid from - * invalid certificates. (This can be used, eg, if you want to - * accept invalid certificates after giving some sort of - * warning.) - * - * If the session has no CA file or TLS database, then all - * certificates are always accepted, and this property has no - * effect. - * - * Since: 2.30 - */ - g_object_class_install_property ( - object_class, PROP_SSL_STRICT, - g_param_spec_boolean (SOUP_SESSION_SSL_STRICT, - "Strictly validate SSL certificates", - "Whether certificate errors should be considered a connection error", - TRUE, - G_PARAM_READWRITE)); - /** - * SOUP_SESSION_ASYNC_CONTEXT: - * - * Alias for the #SoupSession:async-context property. (The - * session's #GMainContext.) - */ - g_object_class_install_property ( - object_class, PROP_ASYNC_CONTEXT, - g_param_spec_pointer (SOUP_SESSION_ASYNC_CONTEXT, - "Async GMainContext", - "The GMainContext to dispatch async I/O in", - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - /** - * SOUP_SESSION_USE_THREAD_CONTEXT: - * - * Alias for the #SoupSession:use-thread-context property, qv. - * - * Since: 2.38 - */ - /** - * SoupSession:use-thread-context: - * - * If set, asynchronous operations in this session will run in - * whatever the thread-default #GMainContext is at the time - * they are started, rather than always occurring in a context - * fixed at the session's construction time. "Bookkeeping" - * tasks (like expiring idle connections) will happen in the - * context that was thread-default at the time the session was - * created. - * - * Since: 2.38 - */ - g_object_class_install_property ( - object_class, PROP_USE_THREAD_CONTEXT, - g_param_spec_boolean (SOUP_SESSION_USE_THREAD_CONTEXT, - "Use thread-default GMainContext", - "Whether to use thread-default main contexts", - FALSE, - G_PARAM_READWRITE)); - /** - * SOUP_SESSION_TIMEOUT: - * - * Alias for the #SoupSession:timeout property. (The timeout - * in seconds for blocking socket I/O operations.) - **/ - g_object_class_install_property ( - object_class, PROP_TIMEOUT, - g_param_spec_uint (SOUP_SESSION_TIMEOUT, - "Timeout value", - "Value in seconds to timeout a blocking I/O", - 0, G_MAXUINT, 0, - G_PARAM_READWRITE)); - - /** - * SoupSession:user-agent: - * - * If non-%NULL, the value to use for the "User-Agent" header - * on #SoupMessages sent from this session. - * - * RFC 2616 says: "The User-Agent request-header field - * contains information about the user agent originating the - * request. This is for statistical purposes, the tracing of - * protocol violations, and automated recognition of user - * agents for the sake of tailoring responses to avoid - * particular user agent limitations. User agents SHOULD - * include this field with requests." - * - * The User-Agent header contains a list of one or more - * product tokens, separated by whitespace, with the most - * significant product token coming first. The tokens must be - * brief, ASCII, and mostly alphanumeric (although "-", "_", - * and "." are also allowed), and may optionally include a "/" - * followed by a version string. You may also put comments, - * enclosed in parentheses, between or after the tokens. - * - * If you set a #SoupSession:user_agent property that has trailing - * whitespace, #SoupSession will append its own product token - * (eg, "libsoup/2.3.2") to the end of the - * header for you. - **/ - /** - * SOUP_SESSION_USER_AGENT: - * - * Alias for the #SoupSession:user-agent property, qv. - **/ - g_object_class_install_property ( - object_class, PROP_USER_AGENT, - g_param_spec_string (SOUP_SESSION_USER_AGENT, - "User-Agent string", - "User-Agent string", - NULL, - G_PARAM_READWRITE)); - - /** - * SoupSession:accept-language: - * - * If non-%NULL, the value to use for the "Accept-Language" header - * on #SoupMessages sent from this session. - * - * Setting this will disable - * #SoupSession:accept-language-auto. - * - * Since: 2.30 - **/ - /** - * SOUP_SESSION_ACCEPT_LANGUAGE: - * - * Alias for the #SoupSession:accept-language property, qv. - * - * Since: 2.30 - **/ - g_object_class_install_property ( - object_class, PROP_ACCEPT_LANGUAGE, - g_param_spec_string (SOUP_SESSION_ACCEPT_LANGUAGE, - "Accept-Language string", - "Accept-Language string", - NULL, - G_PARAM_READWRITE)); - - /** - * SoupSession:accept-language-auto: - * - * If %TRUE, #SoupSession will automatically set the string - * for the "Accept-Language" header on every #SoupMessage - * sent, based on the return value of g_get_language_names(). - * - * Setting this will override any previous value of - * #SoupSession:accept-language. - * - * Since: 2.30 - **/ - /** - * SOUP_SESSION_ACCEPT_LANGUAGE_AUTO: - * - * Alias for the #SoupSession:accept-language-auto property, qv. - * - * Since: 2.30 - **/ - g_object_class_install_property ( - object_class, PROP_ACCEPT_LANGUAGE_AUTO, - g_param_spec_boolean (SOUP_SESSION_ACCEPT_LANGUAGE_AUTO, - "Accept-Language automatic mode", - "Accept-Language automatic mode", - FALSE, - G_PARAM_READWRITE)); - - /** - * SoupSession:add-feature: (skip) - * - * Add a feature object to the session. (Shortcut for calling - * soup_session_add_feature().) - * - * Since: 2.24 - **/ - /** - * SOUP_SESSION_ADD_FEATURE: (skip) - * - * Alias for the #SoupSession:add-feature property. (Shortcut - * for calling soup_session_add_feature(). - * - * Since: 2.24 - **/ - g_object_class_install_property ( - object_class, PROP_ADD_FEATURE, - g_param_spec_object (SOUP_SESSION_ADD_FEATURE, - "Add Feature", - "Add a feature object to the session", - SOUP_TYPE_SESSION_FEATURE, - G_PARAM_READWRITE)); - /** - * SoupSession:add-feature-by-type: (skip) - * - * Add a feature object of the given type to the session. - * (Shortcut for calling soup_session_add_feature_by_type().) - * - * Since: 2.24 - **/ - /** - * SOUP_SESSION_ADD_FEATURE_BY_TYPE: (skip) - * - * Alias for the #SoupSession:add-feature-by-type property. - * (Shortcut for calling soup_session_add_feature_by_type(). - * - * Since: 2.24 - **/ - g_object_class_install_property ( - object_class, PROP_ADD_FEATURE_BY_TYPE, - g_param_spec_gtype (SOUP_SESSION_ADD_FEATURE_BY_TYPE, - "Add Feature By Type", - "Add a feature object of the given type to the session", - SOUP_TYPE_SESSION_FEATURE, - G_PARAM_READWRITE)); - /** - * SoupSession:remove-feature-by-type: (skip) - * - * Remove feature objects from the session. (Shortcut for - * calling soup_session_remove_feature_by_type().) - * - * Since: 2.24 - **/ - /** - * SOUP_SESSION_REMOVE_FEATURE_BY_TYPE: (skip) - * - * Alias for the #SoupSession:remove-feature-by-type - * property. (Shortcut for calling - * soup_session_remove_feature_by_type(). - * - * Since: 2.24 - **/ - g_object_class_install_property ( - object_class, PROP_REMOVE_FEATURE_BY_TYPE, - g_param_spec_gtype (SOUP_SESSION_REMOVE_FEATURE_BY_TYPE, - "Remove Feature By Type", - "Remove features of the given type from the session", - SOUP_TYPE_SESSION_FEATURE, - G_PARAM_READWRITE)); - /** - * SoupSession:http-aliases: - * - * A %NULL-terminated array of URI schemes that should be - * considered to be aliases for "http". Eg, if this included - * "dav", than a URI of - * dav://example.com/path would be treated - * identically to http://example.com/path. - * If the value is %NULL, then only "http" is recognized as - * meaning "http". - * - * For backward-compatibility reasons, the default value for - * this property is an array containing the single element - * "*", a special value which means that - * any scheme except "https" is considered to be an alias for - * "http". - * - * See also #SoupSession:https-aliases. - * - * Since: 2.38 - */ - /** - * SOUP_SESSION_HTTP_ALIASES: - * - * Alias for the #SoupSession:http-aliases property. (URI - * schemes that will be considered aliases for "http".) - * - * Since: 2.38 - */ - g_object_class_install_property ( - object_class, PROP_HTTP_ALIASES, - g_param_spec_boxed (SOUP_SESSION_HTTP_ALIASES, - "http aliases", - "URI schemes that are considered aliases for 'http'", - G_TYPE_STRV, - G_PARAM_READWRITE)); - /** - * SoupSession:https-aliases: - * - * A comma-delimited list of URI schemes that should be - * considered to be aliases for "https". See - * #SoupSession:http-aliases for more information. - * - * The default value is %NULL, meaning that no URI schemes - * are considered aliases for "https". - * - * Since: 2.38 - */ - /** - * SOUP_SESSION_HTTPS_ALIASES: - * - * Alias for the #SoupSession:https-aliases property. (URI - * schemes that will be considered aliases for "https".) - * - * Since: 2.38 - **/ - g_object_class_install_property ( - object_class, PROP_HTTPS_ALIASES, - g_param_spec_boxed (SOUP_SESSION_HTTPS_ALIASES, - "https aliases", - "URI schemes that are considered aliases for 'https'", - G_TYPE_STRV, - G_PARAM_READWRITE)); -} - -/* Converts a language in POSIX format and to be RFC2616 compliant */ -/* Based on code from epiphany-webkit (ephy_langs_append_languages()) */ -static gchar * -posix_lang_to_rfc2616 (const gchar *language) -{ - /* Don't include charset variants, etc */ - if (strchr (language, '.') || strchr (language, '@')) - return NULL; - - /* Ignore "C" locale, which g_get_language_names() always - * includes as a fallback. - */ - if (!strcmp (language, "C")) - return NULL; - - return g_strdelimit (g_ascii_strdown (language, -1), "_", '-'); -} - -/* Converts @quality from 0-100 to 0.0-1.0 and appends to @str */ -static gchar * -add_quality_value (const gchar *str, int quality) -{ - g_return_val_if_fail (str != NULL, NULL); - - if (quality >= 0 && quality < 100) { - /* We don't use %.02g because of "." vs "," locale issues */ - if (quality % 10) - return g_strdup_printf ("%s;q=0.%02d", str, quality); - else - return g_strdup_printf ("%s;q=0.%d", str, quality / 10); - } else - return g_strdup (str); -} - -/* Returns a RFC2616 compliant languages list from system locales */ -static gchar * -accept_languages_from_system (void) -{ - const char * const * lang_names; - GPtrArray *langs = NULL; - char *lang, *langs_str; - int delta; - int i; - - lang_names = g_get_language_names (); - g_return_val_if_fail (lang_names != NULL, NULL); - - /* Build the array of languages */ - langs = g_ptr_array_new_with_free_func (g_free); - for (i = 0; lang_names[i] != NULL; i++) { - lang = posix_lang_to_rfc2616 (lang_names[i]); - if (lang) - g_ptr_array_add (langs, lang); - } - - /* Add quality values */ - if (langs->len < 10) - delta = 10; - else if (langs->len < 20) - delta = 5; - else - delta = 1; - - for (i = 0; i < langs->len; i++) { - lang = langs->pdata[i]; - langs->pdata[i] = add_quality_value (lang, 100 - i * delta); - g_free (lang); - } - - /* Fallback: add "en" if list is empty */ - if (langs->len == 0) - g_ptr_array_add (langs, g_strdup ("en")); - - g_ptr_array_add (langs, NULL); - langs_str = g_strjoinv (", ", (char **)langs->pdata); - g_ptr_array_free (langs, TRUE); + g_ptr_array_add (langs, NULL); + langs_str = g_strjoinv (", ", (char **)langs->pdata); + g_ptr_array_free (langs, TRUE); return langs_str; } @@ -1170,8 +465,8 @@ set_aliases (char ***variable, char **value) } static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +soup_session_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { SoupSession *session = SOUP_SESSION (object); SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session); @@ -1295,8 +590,8 @@ set_property (GObject *object, guint prop_id, } static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +soup_session_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { SoupSession *session = SOUP_SESSION (object); SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session); @@ -1551,7 +846,7 @@ free_host (SoupSessionHost *host) } static void -auth_required (SoupSession *session, SoupMessage *msg, +soup_session_real_auth_required (SoupSession *session, SoupMessage *msg, SoupAuth *auth, gboolean retrying) { g_signal_emit (session, signals[AUTHENTICATE], 0, msg, auth, retrying); @@ -1892,7 +1187,7 @@ soup_session_make_connect_message (SoupSession *session, * directly, to add msg to the SoupMessageQueue and cause all * the right signals to be emitted. */ - queue_message (session, msg, NULL, NULL); + soup_session_real_queue_message (session, msg, NULL, NULL); item = soup_message_queue_lookup (priv->queue, msg); soup_message_queue_item_set_connection (item, conn); g_object_unref (msg); @@ -2084,8 +1379,8 @@ soup_session_set_item_status (SoupSession *session, } static void -queue_message (SoupSession *session, SoupMessage *msg, - SoupSessionCallback callback, gpointer user_data) +soup_session_real_queue_message (SoupSession *session, SoupMessage *msg, + SoupSessionCallback callback, gpointer user_data) { SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session); SoupMessageQueueItem *item; @@ -2146,7 +1441,7 @@ soup_session_queue_message (SoupSession *session, SoupMessage *msg, } static void -requeue_message (SoupSession *session, SoupMessage *msg) +soup_session_real_requeue_message (SoupSession *session, SoupMessage *msg) { SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session); SoupMessageQueueItem *item; @@ -2262,7 +1557,7 @@ soup_session_unpause_message (SoupSession *session, static void -cancel_message (SoupSession *session, SoupMessage *msg, guint status_code) +soup_session_real_cancel_message (SoupSession *session, SoupMessage *msg, guint status_code) { SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session); SoupMessageQueueItem *item; @@ -2329,7 +1624,7 @@ soup_session_cancel_message (SoupSession *session, SoupMessage *msg, } static void -flush_queue (SoupSession *session) +soup_session_real_flush_queue (SoupSession *session) { SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session); SoupMessageQueueItem *item; @@ -2627,83 +1922,778 @@ soup_session_get_features (SoupSession *session, GType feature_type) g_return_val_if_fail (SOUP_IS_SESSION (session), NULL); - priv = SOUP_SESSION_GET_PRIVATE (session); - for (f = priv->features, ret = NULL; f; f = f->next) { - if (G_TYPE_CHECK_INSTANCE_TYPE (f->data, feature_type)) - ret = g_slist_prepend (ret, f->data); + priv = SOUP_SESSION_GET_PRIVATE (session); + for (f = priv->features, ret = NULL; f; f = f->next) { + if (G_TYPE_CHECK_INSTANCE_TYPE (f->data, feature_type)) + ret = g_slist_prepend (ret, f->data); + } + return g_slist_reverse (ret); +} + +/** + * soup_session_get_feature: + * @session: a #SoupSession + * @feature_type: the #GType of the feature to get + * + * Gets the first feature in @session of type @feature_type. For + * features where there may be more than one feature of a given type, + * use soup_session_get_features(). + * + * Return value: (transfer none): a #SoupSessionFeature, or %NULL. The + * feature is owned by @session. + * + * Since: 2.26 + **/ +SoupSessionFeature * +soup_session_get_feature (SoupSession *session, GType feature_type) +{ + SoupSessionPrivate *priv; + SoupSessionFeature *feature; + GSList *f; + + g_return_val_if_fail (SOUP_IS_SESSION (session), NULL); + + priv = SOUP_SESSION_GET_PRIVATE (session); + + feature = g_hash_table_lookup (priv->features_cache, + GSIZE_TO_POINTER (feature_type)); + if (feature) + return feature; + + for (f = priv->features; f; f = f->next) { + feature = f->data; + if (G_TYPE_CHECK_INSTANCE_TYPE (feature, feature_type)) { + g_hash_table_insert (priv->features_cache, + GSIZE_TO_POINTER (feature_type), + feature); + return feature; + } } - return g_slist_reverse (ret); + return NULL; } /** - * soup_session_get_feature: + * soup_session_get_feature_for_message: * @session: a #SoupSession * @feature_type: the #GType of the feature to get + * @msg: a #SoupMessage * - * Gets the first feature in @session of type @feature_type. For - * features where there may be more than one feature of a given type, - * use soup_session_get_features(). + * Gets the first feature in @session of type @feature_type, provided + * that it is not disabled for @msg. As with + * soup_session_get_feature(), this should only be used for features + * where @feature_type is only expected to match a single feature. In + * particular, if there are two matching features, and the first is + * disabled on @msg, and the second is not, then this will return + * %NULL, not the second feature. * * Return value: (transfer none): a #SoupSessionFeature, or %NULL. The * feature is owned by @session. * - * Since: 2.26 + * Since: 2.28 **/ SoupSessionFeature * -soup_session_get_feature (SoupSession *session, GType feature_type) +soup_session_get_feature_for_message (SoupSession *session, GType feature_type, + SoupMessage *msg) { - SoupSessionPrivate *priv; SoupSessionFeature *feature; - GSList *f; - g_return_val_if_fail (SOUP_IS_SESSION (session), NULL); + feature = soup_session_get_feature (session, feature_type); + if (feature && soup_message_disables_feature (msg, feature)) + return NULL; + return feature; +} - priv = SOUP_SESSION_GET_PRIVATE (session); +static void +soup_session_class_init (SoupSessionClass *session_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (session_class); + + g_type_class_add_private (session_class, sizeof (SoupSessionPrivate)); + + /* virtual method definition */ + session_class->queue_message = soup_session_real_queue_message; + session_class->requeue_message = soup_session_real_requeue_message; + session_class->cancel_message = soup_session_real_cancel_message; + session_class->auth_required = soup_session_real_auth_required; + session_class->flush_queue = soup_session_real_flush_queue; + + /* virtual method override */ + object_class->dispose = soup_session_dispose; + object_class->finalize = soup_session_finalize; + object_class->set_property = soup_session_set_property; + object_class->get_property = soup_session_get_property; + + /* signals */ + + /** + * SoupSession::request-queued: + * @session: the session + * @msg: the request that was queued + * + * Emitted when a request is queued on @session. (Note that + * "queued" doesn't just mean soup_session_queue_message(); + * soup_session_send_message() implicitly queues the message + * as well.) + * + * When sending a request, first #SoupSession::request_queued + * is emitted, indicating that the session has become aware of + * the request. + * + * Once a connection is available to send the request on, the + * session emits #SoupSession::request_started. Then, various + * #SoupMessage signals are emitted as the message is + * processed. If the message is requeued, it will emit + * #SoupMessage::restarted, which will then be followed by + * another #SoupSession::request_started and another set of + * #SoupMessage signals when the message is re-sent. + * + * Eventually, the message will emit #SoupMessage::finished. + * Normally, this signals the completion of message + * processing. However, it is possible that the application + * will requeue the message from the "finished" handler (or + * equivalently, from the soup_session_queue_message() + * callback). In that case, the process will loop back to + * #SoupSession::request_started. + * + * Eventually, a message will reach "finished" and not be + * requeued. At that point, the session will emit + * #SoupSession::request_unqueued to indicate that it is done + * with the message. + * + * To sum up: #SoupSession::request_queued and + * #SoupSession::request_unqueued are guaranteed to be emitted + * exactly once, but #SoupSession::request_started and + * #SoupMessage::finished (and all of the other #SoupMessage + * signals) may be invoked multiple times for a given message. + * + * Since: 2.4.1 + **/ + signals[REQUEST_QUEUED] = + g_signal_new ("request-queued", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, /* FIXME? */ + NULL, NULL, + _soup_marshal_NONE__OBJECT, + G_TYPE_NONE, 1, + SOUP_TYPE_MESSAGE); + + /** + * SoupSession::request-started: + * @session: the session + * @msg: the request being sent + * @socket: the socket the request is being sent on + * + * Emitted just before a request is sent. See + * #SoupSession::request_queued for a detailed description of + * the message lifecycle within a session. + **/ + signals[REQUEST_STARTED] = + g_signal_new ("request-started", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (SoupSessionClass, request_started), + NULL, NULL, + _soup_marshal_NONE__OBJECT_OBJECT, + G_TYPE_NONE, 2, + SOUP_TYPE_MESSAGE, + SOUP_TYPE_SOCKET); + + /** + * SoupSession::request-unqueued: + * @session: the session + * @msg: the request that was unqueued + * + * Emitted when a request is removed from @session's queue, + * indicating that @session is done with it. See + * #SoupSession::request_queued for a detailed description of the + * message lifecycle within a session. + * + * Since: 2.4.1 + **/ + signals[REQUEST_UNQUEUED] = + g_signal_new ("request-unqueued", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, /* FIXME? */ + NULL, NULL, + _soup_marshal_NONE__OBJECT, + G_TYPE_NONE, 1, + SOUP_TYPE_MESSAGE); + + /** + * SoupSession::authenticate: + * @session: the session + * @msg: the #SoupMessage being sent + * @auth: the #SoupAuth to authenticate + * @retrying: %TRUE if this is the second (or later) attempt + * + * Emitted when the session requires authentication. If + * credentials are available call soup_auth_authenticate() on + * @auth. If these credentials fail, the signal will be + * emitted again, with @retrying set to %TRUE, which will + * continue until you return without calling + * soup_auth_authenticate() on @auth. + * + * Note that this may be emitted before @msg's body has been + * fully read. + * + * If you call soup_session_pause_message() on @msg before + * returning, then you can authenticate @auth asynchronously + * (as long as you g_object_ref() it to make sure it doesn't + * get destroyed), and then unpause @msg when you are ready + * for it to continue. + **/ + signals[AUTHENTICATE] = + g_signal_new ("authenticate", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (SoupSessionClass, authenticate), + NULL, NULL, + _soup_marshal_NONE__OBJECT_OBJECT_BOOLEAN, + G_TYPE_NONE, 3, + SOUP_TYPE_MESSAGE, + SOUP_TYPE_AUTH, + G_TYPE_BOOLEAN); + + /** + * SoupSession::connection-created: + * @session: the #SoupSession + * @connection: the connection + * + * Emitted when a new connection is created. This is an + * internal signal intended only to be used for debugging + * purposes, and may go away in the future. + * + * Since: 2.30 + */ + signals[CONNECTION_CREATED] = + g_signal_new ("connection-created", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + _soup_marshal_NONE__OBJECT, + G_TYPE_NONE, 1, + /* SoupConnection is private, so we can't use + * SOUP_TYPE_CONNECTION here. + */ + G_TYPE_OBJECT); + + /** + * SoupSession::tunneling: + * @session: the #SoupSession + * @connection: the connection + * + * Emitted when an SSL tunnel is being created on a proxy + * connection. This is an internal signal intended only to be + * used for debugging purposes, and may go away in the future. + * + * Since: 2.30 + */ + signals[TUNNELING] = + g_signal_new ("tunneling", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + _soup_marshal_NONE__OBJECT, + G_TYPE_NONE, 1, + /* SoupConnection is private, so we can't use + * SOUP_TYPE_CONNECTION here. + */ + G_TYPE_OBJECT); + + + /* properties */ + /** + * SOUP_SESSION_PROXY_URI: + * + * Alias for the #SoupSession:proxy-uri property. (The HTTP + * proxy to use for this session.) + **/ + g_object_class_install_property ( + object_class, PROP_PROXY_URI, + g_param_spec_boxed (SOUP_SESSION_PROXY_URI, + "Proxy URI", + "The HTTP Proxy to use for this session", + SOUP_TYPE_URI, + G_PARAM_READWRITE)); + /** + * SOUP_SESSION_MAX_CONNS: + * + * Alias for the #SoupSession:max-conns property. (The maximum + * number of connections that the session can open at once.) + **/ + g_object_class_install_property ( + object_class, PROP_MAX_CONNS, + g_param_spec_int (SOUP_SESSION_MAX_CONNS, + "Max Connection Count", + "The maximum number of connections that the session can open at once", + 1, + G_MAXINT, + SOUP_SESSION_MAX_CONNS_DEFAULT, + G_PARAM_READWRITE)); + /** + * SOUP_SESSION_MAX_CONNS_PER_HOST: + * + * Alias for the #SoupSession:max-conns-per-host property. + * (The maximum number of connections that the session can + * open at once to a given host.) + **/ + g_object_class_install_property ( + object_class, PROP_MAX_CONNS_PER_HOST, + g_param_spec_int (SOUP_SESSION_MAX_CONNS_PER_HOST, + "Max Per-Host Connection Count", + "The maximum number of connections that the session can open at once to a given host", + 1, + G_MAXINT, + SOUP_SESSION_MAX_CONNS_PER_HOST_DEFAULT, + G_PARAM_READWRITE)); + /** + * SoupSession:idle-timeout: + * + * Connection lifetime when idle + * + * Since: 2.4.1 + **/ + /** + * SOUP_SESSION_IDLE_TIMEOUT: + * + * Alias for the #SoupSession:idle-timeout property. (The idle + * connection lifetime.) + * + * Since: 2.4.1 + **/ + g_object_class_install_property ( + object_class, PROP_IDLE_TIMEOUT, + g_param_spec_uint (SOUP_SESSION_IDLE_TIMEOUT, + "Idle Timeout", + "Connection lifetime when idle", + 0, G_MAXUINT, 0, + G_PARAM_READWRITE)); + /** + * SoupSession:use-ntlm: + * + * Whether or not to use NTLM authentication. + * + * Deprecated: use soup_session_add_feature_by_type() with + * #SOUP_TYPE_AUTH_NTLM. + **/ + /** + * SOUP_SESSION_USE_NTLM: + * + * Alias for the #SoupSession:use-ntlm property. (Whether or + * not to use NTLM authentication.) + **/ + g_object_class_install_property ( + object_class, PROP_USE_NTLM, + g_param_spec_boolean (SOUP_SESSION_USE_NTLM, + "Use NTLM", + "Whether or not to use NTLM authentication", + FALSE, + G_PARAM_READWRITE)); + /** + * SoupSession:ssl-ca-file: + * + * File containing SSL CA certificates. + * + * Deprecated: use #SoupSession:ssl-use-system-ca-file or + * #SoupSession:tls-database instead + **/ + /** + * SOUP_SESSION_SSL_CA_FILE: + * + * Alias for the #SoupSession:ssl-ca-file property. (File + * containing SSL CA certificates.). + * + * Deprecated: use #SoupSession:ssl-use-system-ca-file or + * #SoupSession:tls-database instead + **/ + g_object_class_install_property ( + object_class, PROP_SSL_CA_FILE, + g_param_spec_string (SOUP_SESSION_SSL_CA_FILE, + "SSL CA file", + "File containing SSL CA certificates", + NULL, + G_PARAM_READWRITE)); + /** + * SOUP_SESSION_USE_SYSTEM_CA_FILE: + * + * Alias for the #SoupSession:ssl-use-system-ca-file property, + * qv. + * + * Since: 2.38 + **/ + /** + * SoupSession:ssl-use-system-ca-file: + * + * Setting this to %TRUE is equivalent to setting + * #SoupSession:tls-database to the default system CA database. + * (and likewise, setting #SoupSession:tls-database to the + * default database by hand will cause this property to + * become %TRUE). + * + * Setting this to %FALSE (when it was previously %TRUE) will + * clear the #SoupSession:tls-database field. + * + * See #SoupSession:ssl-strict for more information on how + * https certificate validation is handled. + * + * Since: 2.38 + **/ + g_object_class_install_property ( + object_class, PROP_SSL_USE_SYSTEM_CA_FILE, + g_param_spec_boolean (SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, + "Use system CA file", + "Use the system certificate database", + FALSE, + G_PARAM_READWRITE)); + /** + * SOUP_SESSION_TLS_DATABASE: + * + * Alias for the #SoupSession:tls-database property, qv. + * + * Since: 2.38 + **/ + /** + * SoupSession:tls-database: + * + * Sets the #GTlsDatabase to use for validating SSL/TLS + * certificates. + * + * Note that setting the #SoupSession:ssl-ca-file or + * #SoupSession:ssl-use-system-ca-file property will cause + * this property to be set to a #GTlsDatabase corresponding to + * the indicated file or system default. + * + * See #SoupSession:ssl-strict for more information on how + * https certificate validation is handled. + * + * Since: 2.38 + **/ + g_object_class_install_property ( + object_class, PROP_TLS_DATABASE, + g_param_spec_object (SOUP_SESSION_TLS_DATABASE, + "TLS Database", + "TLS database to use", + G_TYPE_TLS_DATABASE, + G_PARAM_READWRITE)); + /** + * SOUP_SESSION_SSL_STRICT: + * + * Alias for the #SoupSession:ssl-strict property, qv. + * + * Since: 2.30 + **/ + /** + * SoupSession:ssl-strict: + * + * Normally, if #SoupSession:tlsdb is set (including if it was + * set via #SoupSession:ssl-use-system-ca-file or + * #SoupSession:ssl-ca-file), then libsoup will reject any + * certificate that is invalid (ie, expired) or that is not + * signed by one of the given CA certificates, and the + * #SoupMessage will fail with the status + * %SOUP_STATUS_SSL_FAILED. + * + * If you set #SoupSession:ssl-strict to %FALSE, then all + * certificates will be accepted, and you will need to call + * soup_message_get_https_status() to distinguish valid from + * invalid certificates. (This can be used, eg, if you want to + * accept invalid certificates after giving some sort of + * warning.) + * + * If the session has no CA file or TLS database, then all + * certificates are always accepted, and this property has no + * effect. + * + * Since: 2.30 + */ + g_object_class_install_property ( + object_class, PROP_SSL_STRICT, + g_param_spec_boolean (SOUP_SESSION_SSL_STRICT, + "Strictly validate SSL certificates", + "Whether certificate errors should be considered a connection error", + TRUE, + G_PARAM_READWRITE)); + /** + * SOUP_SESSION_ASYNC_CONTEXT: + * + * Alias for the #SoupSession:async-context property. (The + * session's #GMainContext.) + */ + g_object_class_install_property ( + object_class, PROP_ASYNC_CONTEXT, + g_param_spec_pointer (SOUP_SESSION_ASYNC_CONTEXT, + "Async GMainContext", + "The GMainContext to dispatch async I/O in", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /** + * SOUP_SESSION_USE_THREAD_CONTEXT: + * + * Alias for the #SoupSession:use-thread-context property, qv. + * + * Since: 2.38 + */ + /** + * SoupSession:use-thread-context: + * + * If set, asynchronous operations in this session will run in + * whatever the thread-default #GMainContext is at the time + * they are started, rather than always occurring in a context + * fixed at the session's construction time. "Bookkeeping" + * tasks (like expiring idle connections) will happen in the + * context that was thread-default at the time the session was + * created. + * + * Since: 2.38 + */ + g_object_class_install_property ( + object_class, PROP_USE_THREAD_CONTEXT, + g_param_spec_boolean (SOUP_SESSION_USE_THREAD_CONTEXT, + "Use thread-default GMainContext", + "Whether to use thread-default main contexts", + FALSE, + G_PARAM_READWRITE)); + /** + * SOUP_SESSION_TIMEOUT: + * + * Alias for the #SoupSession:timeout property. (The timeout + * in seconds for blocking socket I/O operations.) + **/ + g_object_class_install_property ( + object_class, PROP_TIMEOUT, + g_param_spec_uint (SOUP_SESSION_TIMEOUT, + "Timeout value", + "Value in seconds to timeout a blocking I/O", + 0, G_MAXUINT, 0, + G_PARAM_READWRITE)); - feature = g_hash_table_lookup (priv->features_cache, - GSIZE_TO_POINTER (feature_type)); - if (feature) - return feature; + /** + * SoupSession:user-agent: + * + * If non-%NULL, the value to use for the "User-Agent" header + * on #SoupMessages sent from this session. + * + * RFC 2616 says: "The User-Agent request-header field + * contains information about the user agent originating the + * request. This is for statistical purposes, the tracing of + * protocol violations, and automated recognition of user + * agents for the sake of tailoring responses to avoid + * particular user agent limitations. User agents SHOULD + * include this field with requests." + * + * The User-Agent header contains a list of one or more + * product tokens, separated by whitespace, with the most + * significant product token coming first. The tokens must be + * brief, ASCII, and mostly alphanumeric (although "-", "_", + * and "." are also allowed), and may optionally include a "/" + * followed by a version string. You may also put comments, + * enclosed in parentheses, between or after the tokens. + * + * If you set a #SoupSession:user_agent property that has trailing + * whitespace, #SoupSession will append its own product token + * (eg, "libsoup/2.3.2") to the end of the + * header for you. + **/ + /** + * SOUP_SESSION_USER_AGENT: + * + * Alias for the #SoupSession:user-agent property, qv. + **/ + g_object_class_install_property ( + object_class, PROP_USER_AGENT, + g_param_spec_string (SOUP_SESSION_USER_AGENT, + "User-Agent string", + "User-Agent string", + NULL, + G_PARAM_READWRITE)); - for (f = priv->features; f; f = f->next) { - feature = f->data; - if (G_TYPE_CHECK_INSTANCE_TYPE (feature, feature_type)) { - g_hash_table_insert (priv->features_cache, - GSIZE_TO_POINTER (feature_type), - feature); - return feature; - } - } - return NULL; -} + /** + * SoupSession:accept-language: + * + * If non-%NULL, the value to use for the "Accept-Language" header + * on #SoupMessages sent from this session. + * + * Setting this will disable + * #SoupSession:accept-language-auto. + * + * Since: 2.30 + **/ + /** + * SOUP_SESSION_ACCEPT_LANGUAGE: + * + * Alias for the #SoupSession:accept-language property, qv. + * + * Since: 2.30 + **/ + g_object_class_install_property ( + object_class, PROP_ACCEPT_LANGUAGE, + g_param_spec_string (SOUP_SESSION_ACCEPT_LANGUAGE, + "Accept-Language string", + "Accept-Language string", + NULL, + G_PARAM_READWRITE)); -/** - * soup_session_get_feature_for_message: - * @session: a #SoupSession - * @feature_type: the #GType of the feature to get - * @msg: a #SoupMessage - * - * Gets the first feature in @session of type @feature_type, provided - * that it is not disabled for @msg. As with - * soup_session_get_feature(), this should only be used for features - * where @feature_type is only expected to match a single feature. In - * particular, if there are two matching features, and the first is - * disabled on @msg, and the second is not, then this will return - * %NULL, not the second feature. - * - * Return value: (transfer none): a #SoupSessionFeature, or %NULL. The - * feature is owned by @session. - * - * Since: 2.28 - **/ -SoupSessionFeature * -soup_session_get_feature_for_message (SoupSession *session, GType feature_type, - SoupMessage *msg) -{ - SoupSessionFeature *feature; + /** + * SoupSession:accept-language-auto: + * + * If %TRUE, #SoupSession will automatically set the string + * for the "Accept-Language" header on every #SoupMessage + * sent, based on the return value of g_get_language_names(). + * + * Setting this will override any previous value of + * #SoupSession:accept-language. + * + * Since: 2.30 + **/ + /** + * SOUP_SESSION_ACCEPT_LANGUAGE_AUTO: + * + * Alias for the #SoupSession:accept-language-auto property, qv. + * + * Since: 2.30 + **/ + g_object_class_install_property ( + object_class, PROP_ACCEPT_LANGUAGE_AUTO, + g_param_spec_boolean (SOUP_SESSION_ACCEPT_LANGUAGE_AUTO, + "Accept-Language automatic mode", + "Accept-Language automatic mode", + FALSE, + G_PARAM_READWRITE)); - feature = soup_session_get_feature (session, feature_type); - if (feature && soup_message_disables_feature (msg, feature)) - return NULL; - return feature; + /** + * SoupSession:add-feature: (skip) + * + * Add a feature object to the session. (Shortcut for calling + * soup_session_add_feature().) + * + * Since: 2.24 + **/ + /** + * SOUP_SESSION_ADD_FEATURE: (skip) + * + * Alias for the #SoupSession:add-feature property. (Shortcut + * for calling soup_session_add_feature(). + * + * Since: 2.24 + **/ + g_object_class_install_property ( + object_class, PROP_ADD_FEATURE, + g_param_spec_object (SOUP_SESSION_ADD_FEATURE, + "Add Feature", + "Add a feature object to the session", + SOUP_TYPE_SESSION_FEATURE, + G_PARAM_READWRITE)); + /** + * SoupSession:add-feature-by-type: (skip) + * + * Add a feature object of the given type to the session. + * (Shortcut for calling soup_session_add_feature_by_type().) + * + * Since: 2.24 + **/ + /** + * SOUP_SESSION_ADD_FEATURE_BY_TYPE: (skip) + * + * Alias for the #SoupSession:add-feature-by-type property. + * (Shortcut for calling soup_session_add_feature_by_type(). + * + * Since: 2.24 + **/ + g_object_class_install_property ( + object_class, PROP_ADD_FEATURE_BY_TYPE, + g_param_spec_gtype (SOUP_SESSION_ADD_FEATURE_BY_TYPE, + "Add Feature By Type", + "Add a feature object of the given type to the session", + SOUP_TYPE_SESSION_FEATURE, + G_PARAM_READWRITE)); + /** + * SoupSession:remove-feature-by-type: (skip) + * + * Remove feature objects from the session. (Shortcut for + * calling soup_session_remove_feature_by_type().) + * + * Since: 2.24 + **/ + /** + * SOUP_SESSION_REMOVE_FEATURE_BY_TYPE: (skip) + * + * Alias for the #SoupSession:remove-feature-by-type + * property. (Shortcut for calling + * soup_session_remove_feature_by_type(). + * + * Since: 2.24 + **/ + g_object_class_install_property ( + object_class, PROP_REMOVE_FEATURE_BY_TYPE, + g_param_spec_gtype (SOUP_SESSION_REMOVE_FEATURE_BY_TYPE, + "Remove Feature By Type", + "Remove features of the given type from the session", + SOUP_TYPE_SESSION_FEATURE, + G_PARAM_READWRITE)); + /** + * SoupSession:http-aliases: + * + * A %NULL-terminated array of URI schemes that should be + * considered to be aliases for "http". Eg, if this included + * "dav", than a URI of + * dav://example.com/path would be treated + * identically to http://example.com/path. + * If the value is %NULL, then only "http" is recognized as + * meaning "http". + * + * For backward-compatibility reasons, the default value for + * this property is an array containing the single element + * "*", a special value which means that + * any scheme except "https" is considered to be an alias for + * "http". + * + * See also #SoupSession:https-aliases. + * + * Since: 2.38 + */ + /** + * SOUP_SESSION_HTTP_ALIASES: + * + * Alias for the #SoupSession:http-aliases property. (URI + * schemes that will be considered aliases for "http".) + * + * Since: 2.38 + */ + g_object_class_install_property ( + object_class, PROP_HTTP_ALIASES, + g_param_spec_boxed (SOUP_SESSION_HTTP_ALIASES, + "http aliases", + "URI schemes that are considered aliases for 'http'", + G_TYPE_STRV, + G_PARAM_READWRITE)); + /** + * SoupSession:https-aliases: + * + * A comma-delimited list of URI schemes that should be + * considered to be aliases for "https". See + * #SoupSession:http-aliases for more information. + * + * The default value is %NULL, meaning that no URI schemes + * are considered aliases for "https". + * + * Since: 2.38 + */ + /** + * SOUP_SESSION_HTTPS_ALIASES: + * + * Alias for the #SoupSession:https-aliases property. (URI + * schemes that will be considered aliases for "https".) + * + * Since: 2.38 + **/ + g_object_class_install_property ( + object_class, PROP_HTTPS_ALIASES, + g_param_spec_boxed (SOUP_SESSION_HTTPS_ALIASES, + "https aliases", + "URI schemes that are considered aliases for 'https'", + G_TYPE_STRV, + G_PARAM_READWRITE)); } diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c index ca66dac..8899b48 100644 --- a/libsoup/soup-socket.c +++ b/libsoup/soup-socket.c @@ -99,11 +99,6 @@ typedef struct { } SoupSocketPrivate; #define SOUP_SOCKET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_SOCKET, SoupSocketPrivate)) -static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - static void soup_socket_peer_certificate_changed (GObject *conn, GParamSpec *pspec, gpointer user_data); @@ -138,7 +133,7 @@ disconnect_internal (SoupSocket *sock, gboolean close) } static void -finalize (GObject *object) +soup_socket_finalize (GObject *object) { SoupSocketPrivate *priv = SOUP_SOCKET_GET_PRIVATE (object); @@ -174,6 +169,133 @@ finalize (GObject *object) G_OBJECT_CLASS (soup_socket_parent_class)->finalize (object); } + +static void +finish_socket_setup (SoupSocketPrivate *priv) +{ + if (!priv->gsock) + return; + + if (!priv->conn) + priv->conn = (GIOStream *)g_socket_connection_factory_create_connection (priv->gsock); + if (!priv->iostream) + priv->iostream = soup_io_stream_new (priv->conn, FALSE); + if (!priv->istream) + priv->istream = g_object_ref (g_io_stream_get_input_stream (priv->iostream)); + if (!priv->ostream) + priv->ostream = g_object_ref (g_io_stream_get_output_stream (priv->iostream)); + + g_socket_set_timeout (priv->gsock, priv->timeout); +} + +static void +soup_socket_set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + SoupSocketPrivate *priv = SOUP_SOCKET_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_LOCAL_ADDRESS: + priv->local_addr = (SoupAddress *)g_value_dup_object (value); + break; + case PROP_REMOTE_ADDRESS: + priv->remote_addr = (SoupAddress *)g_value_dup_object (value); + break; + case PROP_NON_BLOCKING: + priv->non_blocking = g_value_get_boolean (value); + break; + case PROP_SSL_CREDENTIALS: + priv->ssl_creds = g_value_get_pointer (value); + break; + case PROP_SSL_STRICT: + priv->ssl_strict = g_value_get_boolean (value); + break; + case PROP_SSL_FALLBACK: + priv->ssl_fallback = g_value_get_boolean (value); + break; + case PROP_ASYNC_CONTEXT: + priv->async_context = g_value_get_pointer (value); + if (priv->async_context) + g_main_context_ref (priv->async_context); + break; + case PROP_USE_THREAD_CONTEXT: + priv->use_thread_context = g_value_get_boolean (value); + break; + case PROP_TIMEOUT: + priv->timeout = g_value_get_uint (value); + if (priv->conn) + g_socket_set_timeout (priv->gsock, priv->timeout); + break; + case PROP_USE_PROXY: + priv->use_proxy = g_value_get_boolean (value); + break; + case PROP_CLEAN_DISPOSE: + priv->clean_dispose = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +soup_socket_get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + SoupSocketPrivate *priv = SOUP_SOCKET_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_LOCAL_ADDRESS: + g_value_set_object (value, soup_socket_get_local_address (SOUP_SOCKET (object))); + break; + case PROP_REMOTE_ADDRESS: + g_value_set_object (value, soup_socket_get_remote_address (SOUP_SOCKET (object))); + break; + case PROP_NON_BLOCKING: + g_value_set_boolean (value, priv->non_blocking); + break; + case PROP_IS_SERVER: + g_value_set_boolean (value, priv->is_server); + break; + case PROP_SSL_CREDENTIALS: + g_value_set_pointer (value, priv->ssl_creds); + break; + case PROP_SSL_STRICT: + g_value_set_boolean (value, priv->ssl_strict); + break; + case PROP_SSL_FALLBACK: + g_value_set_boolean (value, priv->ssl_fallback); + break; + case PROP_TRUSTED_CERTIFICATE: + g_value_set_boolean (value, priv->tls_errors == 0); + break; + case PROP_ASYNC_CONTEXT: + g_value_set_pointer (value, priv->async_context ? g_main_context_ref (priv->async_context) : NULL); + break; + case PROP_USE_THREAD_CONTEXT: + g_value_set_boolean (value, priv->use_thread_context); + break; + case PROP_TIMEOUT: + g_value_set_uint (value, priv->timeout); + break; + case PROP_TLS_CERTIFICATE: + if (G_IS_TLS_CONNECTION (priv->conn)) + g_value_set_object (value, g_tls_connection_get_peer_certificate (G_TLS_CONNECTION (priv->conn))); + else + g_value_set_object (value, NULL); + break; + case PROP_TLS_ERRORS: + g_value_set_flags (value, priv->tls_errors); + break; + case PROP_USE_PROXY: + g_value_set_boolean (value, priv->use_proxy); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + static void soup_socket_class_init (SoupSocketClass *socket_class) { @@ -182,9 +304,9 @@ soup_socket_class_init (SoupSocketClass *socket_class) g_type_class_add_private (socket_class, sizeof (SoupSocketPrivate)); /* virtual method override */ - object_class->finalize = finalize; - object_class->set_property = set_property; - object_class->get_property = get_property; + object_class->finalize = soup_socket_finalize; + object_class->set_property = soup_socket_set_property; + object_class->get_property = soup_socket_get_property; /* signals */ @@ -512,133 +634,6 @@ soup_socket_class_init (SoupSocketClass *socket_class) } -static void -finish_socket_setup (SoupSocketPrivate *priv) -{ - if (!priv->gsock) - return; - - if (!priv->conn) - priv->conn = (GIOStream *)g_socket_connection_factory_create_connection (priv->gsock); - if (!priv->iostream) - priv->iostream = soup_io_stream_new (priv->conn, FALSE); - if (!priv->istream) - priv->istream = g_object_ref (g_io_stream_get_input_stream (priv->iostream)); - if (!priv->ostream) - priv->ostream = g_object_ref (g_io_stream_get_output_stream (priv->iostream)); - - g_socket_set_timeout (priv->gsock, priv->timeout); -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - SoupSocketPrivate *priv = SOUP_SOCKET_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_LOCAL_ADDRESS: - priv->local_addr = (SoupAddress *)g_value_dup_object (value); - break; - case PROP_REMOTE_ADDRESS: - priv->remote_addr = (SoupAddress *)g_value_dup_object (value); - break; - case PROP_NON_BLOCKING: - priv->non_blocking = g_value_get_boolean (value); - break; - case PROP_SSL_CREDENTIALS: - priv->ssl_creds = g_value_get_pointer (value); - break; - case PROP_SSL_STRICT: - priv->ssl_strict = g_value_get_boolean (value); - break; - case PROP_SSL_FALLBACK: - priv->ssl_fallback = g_value_get_boolean (value); - break; - case PROP_ASYNC_CONTEXT: - priv->async_context = g_value_get_pointer (value); - if (priv->async_context) - g_main_context_ref (priv->async_context); - break; - case PROP_USE_THREAD_CONTEXT: - priv->use_thread_context = g_value_get_boolean (value); - break; - case PROP_TIMEOUT: - priv->timeout = g_value_get_uint (value); - if (priv->conn) - g_socket_set_timeout (priv->gsock, priv->timeout); - break; - case PROP_USE_PROXY: - priv->use_proxy = g_value_get_boolean (value); - break; - case PROP_CLEAN_DISPOSE: - priv->clean_dispose = g_value_get_boolean (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - SoupSocketPrivate *priv = SOUP_SOCKET_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_LOCAL_ADDRESS: - g_value_set_object (value, soup_socket_get_local_address (SOUP_SOCKET (object))); - break; - case PROP_REMOTE_ADDRESS: - g_value_set_object (value, soup_socket_get_remote_address (SOUP_SOCKET (object))); - break; - case PROP_NON_BLOCKING: - g_value_set_boolean (value, priv->non_blocking); - break; - case PROP_IS_SERVER: - g_value_set_boolean (value, priv->is_server); - break; - case PROP_SSL_CREDENTIALS: - g_value_set_pointer (value, priv->ssl_creds); - break; - case PROP_SSL_STRICT: - g_value_set_boolean (value, priv->ssl_strict); - break; - case PROP_SSL_FALLBACK: - g_value_set_boolean (value, priv->ssl_fallback); - break; - case PROP_TRUSTED_CERTIFICATE: - g_value_set_boolean (value, priv->tls_errors == 0); - break; - case PROP_ASYNC_CONTEXT: - g_value_set_pointer (value, priv->async_context ? g_main_context_ref (priv->async_context) : NULL); - break; - case PROP_USE_THREAD_CONTEXT: - g_value_set_boolean (value, priv->use_thread_context); - break; - case PROP_TIMEOUT: - g_value_set_uint (value, priv->timeout); - break; - case PROP_TLS_CERTIFICATE: - if (G_IS_TLS_CONNECTION (priv->conn)) - g_value_set_object (value, g_tls_connection_get_peer_certificate (G_TLS_CONNECTION (priv->conn))); - else - g_value_set_object (value, NULL); - break; - case PROP_TLS_ERRORS: - g_value_set_flags (value, priv->tls_errors); - break; - case PROP_USE_PROXY: - g_value_set_boolean (value, priv->use_proxy); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - /** * soup_socket_new: * @optname1: name of first property to set (or %NULL)