[libsoup] Port some of the classes to the new glib private api
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] Port some of the classes to the new glib private api
- Date: Mon, 14 Nov 2016 16:27:43 +0000 (UTC)
commit bd93c273ea787df4f3fe03c9cf6c8e53d8fc5fc9
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Nov 7 10:13:44 2016 +0100
Port some of the classes to the new glib private api
We are already depending on the a newly enough glib so
we are now allowed to clean up a bit and use the new private
api.
https://bugzilla.gnome.org/show_bug.cgi?id=774189
libsoup/soup-address.c | 70 +++++++++++++++++---------------
libsoup/soup-auth-basic.c | 17 ++++----
libsoup/soup-auth-digest.c | 26 +++++++-----
libsoup/soup-auth-domain-basic.c | 16 +++-----
libsoup/soup-auth-domain-digest.c | 16 +++-----
libsoup/soup-auth-domain.c | 32 +++++++--------
libsoup/soup-auth-manager.c | 12 +++---
libsoup/soup-auth-negotiate.c | 48 ++++++++++------------
libsoup/soup-auth-ntlm.c | 27 +++++++------
libsoup/soup-auth.c | 20 +++++-----
libsoup/soup-body-input-stream.c | 7 +--
libsoup/soup-body-output-stream.c | 7 +--
libsoup/soup-cache-input-stream.c | 20 ++++-----
libsoup/soup-cache.c | 13 ++----
libsoup/soup-client-input-stream.c | 7 +--
libsoup/soup-connection-auth.c | 8 +--
libsoup/soup-connection.c | 67 +++++++++++++++++--------------
libsoup/soup-content-decoder.c | 7 +--
libsoup/soup-content-sniffer-stream.c | 19 ++++-----
libsoup/soup-converter-wrapper.c | 19 ++++-----
libsoup/soup-cookie-jar-db.c | 18 +++-----
libsoup/soup-cookie-jar-text.c | 15 +++----
libsoup/soup-cookie-jar.c | 50 ++++++++++++------------
libsoup/soup-filter-input-stream.c | 7 +--
libsoup/soup-io-stream.c | 8 +---
libsoup/soup-logger.c | 55 +++++++++++++-------------
26 files changed, 287 insertions(+), 324 deletions(-)
---
diff --git a/libsoup/soup-address.c b/libsoup/soup-address.c
index 6daf668..650cf81 100644
--- a/libsoup/soup-address.c
+++ b/libsoup/soup-address.c
@@ -53,7 +53,6 @@ typedef struct {
GMutex lock;
} SoupAddressPrivate;
-#define SOUP_ADDRESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_ADDRESS,
SoupAddressPrivate))
/* sockaddr generic macros */
#define SOUP_SIN(priv) ((struct sockaddr_in *)priv->sockaddr)
@@ -98,13 +97,14 @@ typedef struct {
static void soup_address_connectable_iface_init (GSocketConnectableIface *connectable_iface);
G_DEFINE_TYPE_WITH_CODE (SoupAddress, soup_address, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (SoupAddress)
G_IMPLEMENT_INTERFACE (G_TYPE_SOCKET_CONNECTABLE,
soup_address_connectable_iface_init))
static void
soup_address_init (SoupAddress *addr)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
g_mutex_init (&priv->lock);
}
@@ -113,7 +113,7 @@ static void
soup_address_finalize (GObject *object)
{
SoupAddress *addr = SOUP_ADDRESS (object);
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
g_free (priv->sockaddr);
g_free (priv->name);
@@ -136,7 +136,7 @@ soup_address_constructor (GType type,
type, n_construct_properties, construct_properties);
if (!addr)
return NULL;
- priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ priv = soup_address_get_instance_private (SOUP_ADDRESS (addr));
if (!priv->name && !priv->sockaddr) {
g_object_unref (addr);
@@ -150,7 +150,7 @@ static void
soup_address_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (object);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (SOUP_ADDRESS (object));
SoupAddressFamily family;
struct sockaddr *sa;
int len, port;
@@ -214,7 +214,7 @@ static void
soup_address_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (object);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (SOUP_ADDRESS (object));
switch (prop_id) {
case PROP_NAME:
@@ -249,8 +249,6 @@ 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;
@@ -450,9 +448,12 @@ soup_address_new_any (SoupAddressFamily family, guint port)
const char *
soup_address_get_name (SoupAddress *addr)
{
+ SoupAddressPrivate *priv;
+
g_return_val_if_fail (SOUP_IS_ADDRESS (addr), NULL);
+ priv = soup_address_get_instance_private (addr);
- return SOUP_ADDRESS_GET_PRIVATE (addr)->name;
+ return priv->name;
}
/**
@@ -476,7 +477,7 @@ soup_address_get_sockaddr (SoupAddress *addr, int *len)
SoupAddressPrivate *priv;
g_return_val_if_fail (SOUP_IS_ADDRESS (addr), NULL);
- priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ priv = soup_address_get_instance_private (addr);
if (priv->sockaddr && len)
*len = SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE (SOUP_ADDRESS_GET_FAMILY (priv));
@@ -497,7 +498,7 @@ soup_address_get_sockaddr (SoupAddress *addr, int *len)
GSocketAddress *
soup_address_get_gsockaddr (SoupAddress *addr)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
return g_socket_address_new_from_native (priv->sockaddr,
SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE (SOUP_ADDRESS_GET_FAMILY
(priv)));
@@ -506,7 +507,7 @@ soup_address_get_gsockaddr (SoupAddress *addr)
static GInetAddress *
soup_address_make_inet_address (SoupAddress *addr)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
GSocketAddress *gsa;
GInetAddress *gia;
@@ -538,7 +539,7 @@ soup_address_get_physical (SoupAddress *addr)
SoupAddressPrivate *priv;
g_return_val_if_fail (SOUP_IS_ADDRESS (addr), NULL);
- priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ priv = soup_address_get_instance_private (addr);
if (!priv->sockaddr)
return NULL;
@@ -565,9 +566,12 @@ soup_address_get_physical (SoupAddress *addr)
guint
soup_address_get_port (SoupAddress *addr)
{
+ SoupAddressPrivate *priv;
+
g_return_val_if_fail (SOUP_IS_ADDRESS (addr), 0);
+ priv = soup_address_get_instance_private (addr);
- return SOUP_ADDRESS_GET_PRIVATE (addr)->port;
+ return priv->port;
}
@@ -577,7 +581,7 @@ soup_address_get_port (SoupAddress *addr)
static void
maybe_resolve_ip (SoupAddress *addr)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
const char *pct, *ip;
char *tmp = NULL;
GSocketConnectable *gaddr;
@@ -627,7 +631,7 @@ maybe_resolve_ip (SoupAddress *addr)
static guint
update_addrs (SoupAddress *addr, GList *addrs, GError *error)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
GInetAddress *gia;
GSocketAddress *gsa;
int i;
@@ -666,7 +670,7 @@ update_addrs (SoupAddress *addr, GList *addrs, GError *error)
static guint
update_name (SoupAddress *addr, const char *name, GError *error)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
if (error) {
if (error->domain == G_IO_ERROR &&
@@ -725,7 +729,7 @@ lookup_resolved (GObject *source, GAsyncResult *result, gpointer user_data)
GResolver *resolver = G_RESOLVER (source);
SoupAddressResolveAsyncData *res_data = user_data;
SoupAddress *addr = res_data->addr;
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
GError *error = NULL;
guint status;
@@ -809,7 +813,7 @@ soup_address_resolve_async (SoupAddress *addr, GMainContext *async_context,
GResolver *resolver;
g_return_if_fail (SOUP_IS_ADDRESS (addr));
- priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ priv = soup_address_get_instance_private (addr);
g_return_if_fail (priv->name || priv->sockaddr);
/* We don't need to do locking here because the async case is
@@ -858,7 +862,7 @@ soup_address_resolve_async (SoupAddress *addr, GMainContext *async_context,
static guint
resolve_sync_internal (SoupAddress *addr, GCancellable *cancellable, GError **error)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
GResolver *resolver;
guint status;
GError *my_err = NULL;
@@ -937,7 +941,7 @@ soup_address_resolve_sync (SoupAddress *addr, GCancellable *cancellable)
SoupAddressPrivate *priv;
g_return_val_if_fail (SOUP_IS_ADDRESS (addr), SOUP_STATUS_MALFORMED);
- priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ priv = soup_address_get_instance_private (addr);
g_return_val_if_fail (priv->name || priv->sockaddr, SOUP_STATUS_MALFORMED);
return resolve_sync_internal (addr, cancellable, NULL);
@@ -960,7 +964,7 @@ soup_address_is_resolved (SoupAddress *addr)
gboolean resolved;
g_return_val_if_fail (SOUP_IS_ADDRESS (addr), FALSE);
- priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ priv = soup_address_get_instance_private (addr);
g_mutex_lock (&priv->lock);
resolved = priv->sockaddr && priv->name;
@@ -983,7 +987,7 @@ soup_address_is_resolved (SoupAddress *addr)
guint
soup_address_hash_by_name (gconstpointer addr)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (SOUP_ADDRESS (addr));
g_return_val_if_fail (priv->name != NULL, 0);
return g_str_hash (priv->name);
@@ -1024,8 +1028,8 @@ soup_address_hash_by_name (gconstpointer addr)
gboolean
soup_address_equal_by_name (gconstpointer addr1, gconstpointer addr2)
{
- SoupAddressPrivate *priv1 = SOUP_ADDRESS_GET_PRIVATE (addr1);
- SoupAddressPrivate *priv2 = SOUP_ADDRESS_GET_PRIVATE (addr2);
+ SoupAddressPrivate *priv1 = soup_address_get_instance_private (SOUP_ADDRESS (addr1));
+ SoupAddressPrivate *priv2 = soup_address_get_instance_private (SOUP_ADDRESS (addr2));
g_return_val_if_fail (priv1->name != NULL, FALSE);
g_return_val_if_fail (priv2->name != NULL, FALSE);
@@ -1046,7 +1050,7 @@ soup_address_equal_by_name (gconstpointer addr1, gconstpointer addr2)
guint
soup_address_hash_by_ip (gconstpointer addr)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (SOUP_ADDRESS (addr));
guint hash;
g_return_val_if_fail (priv->sockaddr != NULL, 0);
@@ -1084,8 +1088,8 @@ soup_address_hash_by_ip (gconstpointer addr)
gboolean
soup_address_equal_by_ip (gconstpointer addr1, gconstpointer addr2)
{
- SoupAddressPrivate *priv1 = SOUP_ADDRESS_GET_PRIVATE (addr1);
- SoupAddressPrivate *priv2 = SOUP_ADDRESS_GET_PRIVATE (addr2);
+ SoupAddressPrivate *priv1 = soup_address_get_instance_private (SOUP_ADDRESS (addr1));
+ SoupAddressPrivate *priv2 = soup_address_get_instance_private (SOUP_ADDRESS (addr2));
int size;
g_return_val_if_fail (priv1->sockaddr != NULL, FALSE);
@@ -1131,7 +1135,7 @@ soup_address_address_enumerator_finalize (GObject *object)
static GSocketAddress *
next_address (SoupAddressAddressEnumerator *addr_enum)
{
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr_enum->addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr_enum->addr);
struct sockaddr_storage *ss;
int next_addr;
@@ -1159,7 +1163,7 @@ soup_address_address_enumerator_next (GSocketAddressEnumerator *enumerator,
{
SoupAddressAddressEnumerator *addr_enum =
SOUP_ADDRESS_ADDRESS_ENUMERATOR (enumerator);
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr_enum->addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr_enum->addr);
if (!priv->sockaddr) {
if (resolve_sync_internal (addr_enum->addr, cancellable, error) != SOUP_STATUS_OK)
@@ -1195,7 +1199,7 @@ soup_address_address_enumerator_next_async (GSocketAddressEnumerator *enumerato
{
SoupAddressAddressEnumerator *addr_enum =
SOUP_ADDRESS_ADDRESS_ENUMERATOR (enumerator);
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr_enum->addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr_enum->addr);
GTask *task;
task = g_task_new (enumerator, cancellable, callback, user_data);
@@ -1244,7 +1248,7 @@ soup_address_connectable_enumerate (GSocketConnectable *connectable)
addr_enum = g_object_new (SOUP_TYPE_ADDRESS_ADDRESS_ENUMERATOR, NULL);
addr_enum->addr = g_object_ref (connectable);
- priv = SOUP_ADDRESS_GET_PRIVATE (addr_enum->addr);
+ priv = soup_address_get_instance_private (addr_enum->addr);
addr_enum->orig_offset = priv->offset;
return (GSocketAddressEnumerator *)addr_enum;
@@ -1254,7 +1258,7 @@ static GSocketAddressEnumerator *
soup_address_connectable_proxy_enumerate (GSocketConnectable *connectable)
{
SoupAddress *addr = SOUP_ADDRESS (connectable);
- SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
+ SoupAddressPrivate *priv = soup_address_get_instance_private (addr);
GSocketAddressEnumerator *proxy_enum;
SoupURI *uri;
char *uri_string;
diff --git a/libsoup/soup-auth-basic.c b/libsoup/soup-auth-basic.c
index f4b3717..5f1e718 100644
--- a/libsoup/soup-auth-basic.c
+++ b/libsoup/soup-auth-basic.c
@@ -17,7 +17,6 @@
typedef struct {
char *token;
} SoupAuthBasicPrivate;
-#define SOUP_AUTH_BASIC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_AUTH_BASIC,
SoupAuthBasicPrivate))
/**
* SOUP_TYPE_AUTH_BASIC:
@@ -30,7 +29,7 @@ typedef struct {
* Since: 2.34
*/
-G_DEFINE_TYPE (SoupAuthBasic, soup_auth_basic, SOUP_TYPE_AUTH)
+G_DEFINE_TYPE_WITH_PRIVATE (SoupAuthBasic, soup_auth_basic, SOUP_TYPE_AUTH)
static void
soup_auth_basic_init (SoupAuthBasic *basic)
@@ -40,7 +39,7 @@ soup_auth_basic_init (SoupAuthBasic *basic)
static void
soup_auth_basic_finalize (GObject *object)
{
- SoupAuthBasicPrivate *priv = SOUP_AUTH_BASIC_GET_PRIVATE (object);
+ SoupAuthBasicPrivate *priv = soup_auth_basic_get_instance_private (SOUP_AUTH_BASIC (object));
g_free (priv->token);
@@ -51,7 +50,7 @@ static gboolean
soup_auth_basic_update (SoupAuth *auth, SoupMessage *msg,
GHashTable *auth_params)
{
- SoupAuthBasicPrivate *priv = SOUP_AUTH_BASIC_GET_PRIVATE (auth);
+ SoupAuthBasicPrivate *priv = soup_auth_basic_get_instance_private (SOUP_AUTH_BASIC (auth));
/* If we're updating a pre-existing auth, the
* username/password must be bad now, so forget it.
@@ -87,7 +86,7 @@ static void
soup_auth_basic_authenticate (SoupAuth *auth, const char *username,
const char *password)
{
- SoupAuthBasicPrivate *priv = SOUP_AUTH_BASIC_GET_PRIVATE (auth);
+ SoupAuthBasicPrivate *priv = soup_auth_basic_get_instance_private (SOUP_AUTH_BASIC (auth));
char *user_pass, *user_pass_latin1;
int len;
@@ -114,13 +113,15 @@ soup_auth_basic_authenticate (SoupAuth *auth, const char *username,
static gboolean
soup_auth_basic_is_authenticated (SoupAuth *auth)
{
- return SOUP_AUTH_BASIC_GET_PRIVATE (auth)->token != NULL;
+ SoupAuthBasicPrivate *priv = soup_auth_basic_get_instance_private (SOUP_AUTH_BASIC (auth));
+
+ return priv->token != NULL;
}
static char *
soup_auth_basic_get_authorization (SoupAuth *auth, SoupMessage *msg)
{
- SoupAuthBasicPrivate *priv = SOUP_AUTH_BASIC_GET_PRIVATE (auth);
+ SoupAuthBasicPrivate *priv = soup_auth_basic_get_instance_private (SOUP_AUTH_BASIC (auth));
return g_strdup_printf ("Basic %s", priv->token);
}
@@ -131,8 +132,6 @@ 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;
diff --git a/libsoup/soup-auth-digest.c b/libsoup/soup-auth-digest.c
index 1fbb639..eda2a93 100644
--- a/libsoup/soup-auth-digest.c
+++ b/libsoup/soup-auth-digest.c
@@ -36,7 +36,6 @@ typedef struct {
int nc;
SoupAuthDigestQop qop;
} SoupAuthDigestPrivate;
-#define SOUP_AUTH_DIGEST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_AUTH_DIGEST,
SoupAuthDigestPrivate))
static void recompute_hex_a1 (SoupAuthDigestPrivate *priv);
@@ -51,7 +50,7 @@ static void recompute_hex_a1 (SoupAuthDigestPrivate *priv);
* Since: 2.34
*/
-G_DEFINE_TYPE (SoupAuthDigest, soup_auth_digest, SOUP_TYPE_AUTH)
+G_DEFINE_TYPE_WITH_PRIVATE (SoupAuthDigest, soup_auth_digest, SOUP_TYPE_AUTH)
static void
soup_auth_digest_init (SoupAuthDigest *digest)
@@ -61,7 +60,7 @@ soup_auth_digest_init (SoupAuthDigest *digest)
static void
soup_auth_digest_finalize (GObject *object)
{
- SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (object);
+ SoupAuthDigestPrivate *priv = soup_auth_digest_get_instance_private (SOUP_AUTH_DIGEST (object));
g_free (priv->user);
g_free (priv->nonce);
@@ -137,7 +136,8 @@ static gboolean
soup_auth_digest_update (SoupAuth *auth, SoupMessage *msg,
GHashTable *auth_params)
{
- SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth);
+ SoupAuthDigest *auth_digest = SOUP_AUTH_DIGEST (auth);
+ SoupAuthDigestPrivate *priv = soup_auth_digest_get_instance_private (auth_digest);
const char *stale, *qop;
guint qop_options;
gboolean ok = TRUE;
@@ -184,7 +184,8 @@ soup_auth_digest_update (SoupAuth *auth, SoupMessage *msg,
static GSList *
soup_auth_digest_get_protection_space (SoupAuth *auth, SoupURI *source_uri)
{
- SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth);
+ SoupAuthDigest *auth_digest = SOUP_AUTH_DIGEST (auth);
+ SoupAuthDigestPrivate *priv = soup_auth_digest_get_instance_private (auth_digest);
GSList *space = NULL;
SoupURI *uri;
char **dvec, *d, *dir, *slash;
@@ -290,7 +291,8 @@ static void
soup_auth_digest_authenticate (SoupAuth *auth, const char *username,
const char *password)
{
- SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth);
+ SoupAuthDigest *auth_digest = SOUP_AUTH_DIGEST (auth);
+ SoupAuthDigestPrivate *priv = soup_auth_digest_get_instance_private (auth_digest);
char *bgen;
g_clear_pointer (&priv->cnonce, g_free);
@@ -318,7 +320,9 @@ soup_auth_digest_authenticate (SoupAuth *auth, const char *username,
static gboolean
soup_auth_digest_is_authenticated (SoupAuth *auth)
{
- return SOUP_AUTH_DIGEST_GET_PRIVATE (auth)->cnonce != NULL;
+ SoupAuthDigestPrivate *priv = soup_auth_digest_get_instance_private (SOUP_AUTH_DIGEST (auth));
+
+ return priv->cnonce != NULL;
}
void
@@ -373,7 +377,8 @@ static void
authentication_info_cb (SoupMessage *msg, gpointer data)
{
SoupAuth *auth = data;
- SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth);
+ SoupAuthDigest *auth_digest = SOUP_AUTH_DIGEST (auth);
+ SoupAuthDigestPrivate *priv = soup_auth_digest_get_instance_private (auth_digest);
const char *header;
GHashTable *auth_params;
char *nextnonce;
@@ -403,7 +408,8 @@ authentication_info_cb (SoupMessage *msg, gpointer data)
static char *
soup_auth_digest_get_authorization (SoupAuth *auth, SoupMessage *msg)
{
- SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth);
+ SoupAuthDigest *auth_digest = SOUP_AUTH_DIGEST (auth);
+ SoupAuthDigestPrivate *priv = soup_auth_digest_get_instance_private (auth_digest);
char response[33], *token;
char *url, *algorithm;
GString *out;
@@ -471,8 +477,6 @@ 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;
diff --git a/libsoup/soup-auth-domain-basic.c b/libsoup/soup-auth-domain-basic.c
index b843ad7..aef2f68 100644
--- a/libsoup/soup-auth-domain-basic.c
+++ b/libsoup/soup-auth-domain-basic.c
@@ -37,9 +37,7 @@ typedef struct {
GDestroyNotify auth_dnotify;
} SoupAuthDomainBasicPrivate;
-#define SOUP_AUTH_DOMAIN_BASIC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),
SOUP_TYPE_AUTH_DOMAIN_BASIC, SoupAuthDomainBasicPrivate))
-
-G_DEFINE_TYPE (SoupAuthDomainBasic, soup_auth_domain_basic, SOUP_TYPE_AUTH_DOMAIN)
+G_DEFINE_TYPE_WITH_PRIVATE (SoupAuthDomainBasic, soup_auth_domain_basic, SOUP_TYPE_AUTH_DOMAIN)
static void
soup_auth_domain_basic_init (SoupAuthDomainBasic *basic)
@@ -50,7 +48,7 @@ static void
soup_auth_domain_basic_finalize (GObject *object)
{
SoupAuthDomainBasicPrivate *priv =
- SOUP_AUTH_DOMAIN_BASIC_GET_PRIVATE (object);
+ soup_auth_domain_basic_get_instance_private (SOUP_AUTH_DOMAIN_BASIC (object));
if (priv->auth_dnotify)
priv->auth_dnotify (priv->auth_data);
@@ -63,7 +61,7 @@ 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);
+ soup_auth_domain_basic_get_instance_private (SOUP_AUTH_DOMAIN_BASIC (object));
switch (prop_id) {
case PROP_AUTH_CALLBACK:
@@ -87,7 +85,7 @@ soup_auth_domain_basic_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SoupAuthDomainBasicPrivate *priv =
- SOUP_AUTH_DOMAIN_BASIC_GET_PRIVATE (object);
+ soup_auth_domain_basic_get_instance_private (SOUP_AUTH_DOMAIN_BASIC (object));
switch (prop_id) {
case PROP_AUTH_CALLBACK:
@@ -181,7 +179,7 @@ soup_auth_domain_basic_set_auth_callback (SoupAuthDomain *domain,
GDestroyNotify dnotify)
{
SoupAuthDomainBasicPrivate *priv =
- SOUP_AUTH_DOMAIN_BASIC_GET_PRIVATE (domain);
+ soup_auth_domain_basic_get_instance_private (SOUP_AUTH_DOMAIN_BASIC (domain));
if (priv->auth_dnotify)
priv->auth_dnotify (priv->auth_data);
@@ -234,7 +232,7 @@ soup_auth_domain_basic_accepts (SoupAuthDomain *domain, SoupMessage *msg,
const char *header)
{
SoupAuthDomainBasicPrivate *priv =
- SOUP_AUTH_DOMAIN_BASIC_GET_PRIVATE (domain);
+ soup_auth_domain_basic_get_instance_private (SOUP_AUTH_DOMAIN_BASIC (domain));
char *username, *password;
gboolean ok = FALSE;
@@ -299,8 +297,6 @@ soup_auth_domain_basic_class_init (SoupAuthDomainBasicClass *basic_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;
diff --git a/libsoup/soup-auth-domain-digest.c b/libsoup/soup-auth-domain-digest.c
index bd7b951..5cb4315 100644
--- a/libsoup/soup-auth-domain-digest.c
+++ b/libsoup/soup-auth-domain-digest.c
@@ -40,9 +40,7 @@ typedef struct {
} SoupAuthDomainDigestPrivate;
-#define SOUP_AUTH_DOMAIN_DIGEST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),
SOUP_TYPE_AUTH_DOMAIN_DIGEST, SoupAuthDomainDigestPrivate))
-
-G_DEFINE_TYPE (SoupAuthDomainDigest, soup_auth_domain_digest, SOUP_TYPE_AUTH_DOMAIN)
+G_DEFINE_TYPE_WITH_PRIVATE (SoupAuthDomainDigest, soup_auth_domain_digest, SOUP_TYPE_AUTH_DOMAIN)
static void
soup_auth_domain_digest_init (SoupAuthDomainDigest *digest)
@@ -53,7 +51,7 @@ static void
soup_auth_domain_digest_finalize (GObject *object)
{
SoupAuthDomainDigestPrivate *priv =
- SOUP_AUTH_DOMAIN_DIGEST_GET_PRIVATE (object);
+ soup_auth_domain_digest_get_instance_private (SOUP_AUTH_DOMAIN_DIGEST (object));
if (priv->auth_dnotify)
priv->auth_dnotify (priv->auth_data);
@@ -66,7 +64,7 @@ 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);
+ soup_auth_domain_digest_get_instance_private (SOUP_AUTH_DOMAIN_DIGEST (object));
switch (prop_id) {
case PROP_AUTH_CALLBACK:
@@ -90,7 +88,7 @@ soup_auth_domain_digest_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SoupAuthDomainDigestPrivate *priv =
- SOUP_AUTH_DOMAIN_DIGEST_GET_PRIVATE (object);
+ soup_auth_domain_digest_get_instance_private (SOUP_AUTH_DOMAIN_DIGEST (object));
switch (prop_id) {
case PROP_AUTH_CALLBACK:
@@ -175,7 +173,7 @@ soup_auth_domain_digest_set_auth_callback (SoupAuthDomain *domain,
GDestroyNotify dnotify)
{
SoupAuthDomainDigestPrivate *priv =
- SOUP_AUTH_DOMAIN_DIGEST_GET_PRIVATE (domain);
+ soup_auth_domain_digest_get_instance_private (SOUP_AUTH_DOMAIN_DIGEST (domain));
if (priv->auth_dnotify)
priv->auth_dnotify (priv->auth_data);
@@ -269,7 +267,7 @@ soup_auth_domain_digest_accepts (SoupAuthDomain *domain, SoupMessage *msg,
const char *header)
{
SoupAuthDomainDigestPrivate *priv =
- SOUP_AUTH_DOMAIN_DIGEST_GET_PRIVATE (domain);
+ soup_auth_domain_digest_get_instance_private (SOUP_AUTH_DOMAIN_DIGEST (domain));
GHashTable *params;
const char *username;
gboolean accept = FALSE;
@@ -400,8 +398,6 @@ soup_auth_domain_digest_class_init (SoupAuthDomainDigestClass *digest_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;
diff --git a/libsoup/soup-auth-domain.c b/libsoup/soup-auth-domain.c
index 3b2c035..06c9e64 100644
--- a/libsoup/soup-auth-domain.c
+++ b/libsoup/soup-auth-domain.c
@@ -69,14 +69,12 @@ typedef struct {
} SoupAuthDomainPrivate;
-#define SOUP_AUTH_DOMAIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_AUTH_DOMAIN,
SoupAuthDomainPrivate))
-
-G_DEFINE_ABSTRACT_TYPE (SoupAuthDomain, soup_auth_domain, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SoupAuthDomain, soup_auth_domain, G_TYPE_OBJECT)
static void
soup_auth_domain_init (SoupAuthDomain *domain)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
priv->paths = soup_path_map_new (NULL);
}
@@ -84,7 +82,7 @@ soup_auth_domain_init (SoupAuthDomain *domain)
static void
soup_auth_domain_finalize (GObject *object)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (object);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (SOUP_AUTH_DOMAIN (object));
g_free (priv->realm);
soup_path_map_free (priv->paths);
@@ -102,7 +100,7 @@ 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);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (auth_domain);
switch (prop_id) {
case PROP_REALM:
@@ -150,7 +148,7 @@ static void
soup_auth_domain_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (object);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (SOUP_AUTH_DOMAIN (object));
switch (prop_id) {
case PROP_REALM:
@@ -182,8 +180,6 @@ 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 = soup_auth_domain_finalize;
object_class->set_property = soup_auth_domain_set_property;
object_class->get_property = soup_auth_domain_get_property;
@@ -306,7 +302,7 @@ soup_auth_domain_class_init (SoupAuthDomainClass *auth_domain_class)
void
soup_auth_domain_add_path (SoupAuthDomain *domain, const char *path)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
/* "" should not match "*" */
if (!*path)
@@ -338,7 +334,7 @@ soup_auth_domain_add_path (SoupAuthDomain *domain, const char *path)
void
soup_auth_domain_remove_path (SoupAuthDomain *domain, const char *path)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
/* "" should not match "*" */
if (!*path)
@@ -398,7 +394,7 @@ soup_auth_domain_set_filter (SoupAuthDomain *domain,
gpointer filter_data,
GDestroyNotify dnotify)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
if (priv->filter_dnotify)
priv->filter_dnotify (priv->filter_data);
@@ -422,7 +418,7 @@ soup_auth_domain_set_filter (SoupAuthDomain *domain,
const char *
soup_auth_domain_get_realm (SoupAuthDomain *domain)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
return priv->realm;
}
@@ -476,7 +472,7 @@ soup_auth_domain_set_generic_auth_callback (SoupAuthDomain *domain,
gpointer auth_data,
GDestroyNotify dnotify)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
if (priv->auth_dnotify)
priv->auth_dnotify (priv->auth_data);
@@ -494,7 +490,7 @@ soup_auth_domain_try_generic_auth_callback (SoupAuthDomain *domain,
SoupMessage *msg,
const char *username)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
if (priv->auth_callback)
return priv->auth_callback (domain, msg, username, priv->auth_data);
@@ -544,7 +540,7 @@ soup_auth_domain_check_password (SoupAuthDomain *domain,
gboolean
soup_auth_domain_covers (SoupAuthDomain *domain, SoupMessage *msg)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
const char *path;
if (!priv->proxy) {
@@ -578,7 +574,7 @@ soup_auth_domain_covers (SoupAuthDomain *domain, SoupMessage *msg)
char *
soup_auth_domain_accepts (SoupAuthDomain *domain, SoupMessage *msg)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
const char *header;
header = soup_message_headers_get_one (msg->request_headers,
@@ -605,7 +601,7 @@ soup_auth_domain_accepts (SoupAuthDomain *domain, SoupMessage *msg)
void
soup_auth_domain_challenge (SoupAuthDomain *domain, SoupMessage *msg)
{
- SoupAuthDomainPrivate *priv = SOUP_AUTH_DOMAIN_GET_PRIVATE (domain);
+ SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
char *challenge;
challenge = SOUP_AUTH_DOMAIN_GET_CLASS (domain)->challenge (domain, msg);
diff --git a/libsoup/soup-auth-manager.c b/libsoup/soup-auth-manager.c
index 9455265..703d188 100644
--- a/libsoup/soup-auth-manager.c
+++ b/libsoup/soup-auth-manager.c
@@ -60,9 +60,6 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE_WITH_CODE (SoupAuthManager, soup_auth_manager, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
- soup_auth_manager_session_feature_init))
struct SoupAuthManagerPrivate {
SoupSession *session;
@@ -80,6 +77,11 @@ typedef struct {
GHashTable *auths; /* scheme:realm -> SoupAuth */
} SoupAuthHost;
+G_DEFINE_TYPE_WITH_CODE (SoupAuthManager, soup_auth_manager, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (SoupAuthManager)
+ G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
+ soup_auth_manager_session_feature_init))
+
static void soup_auth_host_free (SoupAuthHost *host);
static SoupAuth *record_auth_for_uri (SoupAuthManagerPrivate *priv,
SoupURI *uri, SoupAuth *auth,
@@ -90,7 +92,7 @@ soup_auth_manager_init (SoupAuthManager *manager)
{
SoupAuthManagerPrivate *priv;
- priv = manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, SOUP_TYPE_AUTH_MANAGER,
SoupAuthManagerPrivate);
+ priv = manager->priv = soup_auth_manager_get_instance_private (manager);
priv->auth_types = g_ptr_array_new_with_free_func ((GDestroyNotify)g_type_class_unref);
priv->auth_hosts = g_hash_table_new_full (soup_uri_host_hash,
@@ -121,8 +123,6 @@ soup_auth_manager_class_init (SoupAuthManagerClass *auth_manager_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (auth_manager_class);
- g_type_class_add_private (auth_manager_class, sizeof (SoupAuthManagerPrivate));
-
object_class->finalize = soup_auth_manager_finalize;
/**
diff --git a/libsoup/soup-auth-negotiate.c b/libsoup/soup-auth-negotiate.c
index aa5d1cd..fc040f0 100644
--- a/libsoup/soup-auth-negotiate.c
+++ b/libsoup/soup-auth-negotiate.c
@@ -24,22 +24,6 @@
#include "soup-uri.h"
/**
- * SOUP_TYPE_AUTH_NEGOTIATE:
- *
- * A #GType corresponding to HTTP-based GSS-Negotiate authentication.
- * #SoupSessions do not support this type by default; if you want to
- * enable support for it, call soup_session_add_feature_by_type(),
- * passing %SOUP_TYPE_AUTH_NEGOTIATE.
- *
- * This auth type will only work if libsoup was compiled with GSSAPI
- * support; you can check soup_auth_negotiate_supported() to see if it
- * was.
- *
- * Since: 2.54
- */
-G_DEFINE_TYPE (SoupAuthNegotiate, soup_auth_negotiate, SOUP_TYPE_CONNECTION_AUTH)
-
-/**
* soup_auth_negotiate_supported:
*
* Indicates whether libsoup was built with GSSAPI support. If this is
@@ -90,7 +74,21 @@ typedef struct {
SoupNegotiateConnectionState *conn_state;
} SoupAuthNegotiatePrivate;
-#define SOUP_AUTH_NEGOTIATE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_AUTH_NEGOTIATE,
SoupAuthNegotiatePrivate))
+/**
+ * SOUP_TYPE_AUTH_NEGOTIATE:
+ *
+ * A #GType corresponding to HTTP-based GSS-Negotiate authentication.
+ * #SoupSessions do not support this type by default; if you want to
+ * enable support for it, call soup_session_add_feature_by_type(),
+ * passing %SOUP_TYPE_AUTH_NEGOTIATE.
+ *
+ * This auth type will only work if libsoup was compiled with GSSAPI
+ * support; you can check soup_auth_negotiate_supported() to see if it
+ * was.
+ *
+ * Since: 2.54
+ */
+G_DEFINE_TYPE_WITH_PRIVATE (SoupAuthNegotiate, soup_auth_negotiate, SOUP_TYPE_CONNECTION_AUTH)
static gboolean check_auth_trusted_uri (SoupConnectionAuth *auth,
SoupMessage *msg);
@@ -116,7 +114,7 @@ static const gss_OID_desc gss_mech_spnego = { sizeof (spnego_OID) - 1, (void *)
static gpointer
soup_auth_negotiate_create_connection_state (SoupConnectionAuth *auth)
{
- SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (auth);
+ SoupAuthNegotiatePrivate *priv = soup_auth_negotiate_get_instance_private (SOUP_AUTH_NEGOTIATE
(auth));
SoupNegotiateConnectionState *conn;
conn = g_slice_new0 (SoupNegotiateConnectionState);
@@ -138,7 +136,7 @@ soup_auth_negotiate_free_connection_state (SoupConnectionAuth *auth,
gpointer state)
{
SoupAuthNegotiate *negotiate = SOUP_AUTH_NEGOTIATE (auth);
- SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (negotiate);
+ SoupAuthNegotiatePrivate *priv = soup_auth_negotiate_get_instance_private (negotiate);
SoupNegotiateConnectionState *conn = state;
free_connection_state_data (conn);
@@ -169,7 +167,7 @@ soup_auth_negotiate_authenticate (SoupAuth *auth, const char *username,
const char *password)
{
SoupAuthNegotiate *negotiate = SOUP_AUTH_NEGOTIATE (auth);
- SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (negotiate);
+ SoupAuthNegotiatePrivate *priv = soup_auth_negotiate_get_instance_private (negotiate);
/* It is not possible to authenticate with username and password. */
priv->is_authenticated = FALSE;
@@ -179,7 +177,7 @@ static gboolean
soup_auth_negotiate_is_authenticated (SoupAuth *auth)
{
SoupAuthNegotiate *negotiate = SOUP_AUTH_NEGOTIATE (auth);
- SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (negotiate);
+ SoupAuthNegotiatePrivate *priv = soup_auth_negotiate_get_instance_private (negotiate);
/* We are authenticated just in case we received the GSS_S_COMPLETE. */
return priv->is_authenticated;
@@ -226,7 +224,7 @@ soup_auth_negotiate_update_connection (SoupConnectionAuth *auth, SoupMessage *ms
#ifdef LIBSOUP_HAVE_GSSAPI
gboolean success = TRUE;
SoupNegotiateConnectionState *conn = state;
- SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (auth);
+ SoupAuthNegotiatePrivate *priv = soup_auth_negotiate_get_instance_private (SOUP_AUTH_NEGOTIATE
(auth));
GError *err = NULL;
if (!check_auth_trusted_uri (auth, msg)) {
@@ -317,8 +315,6 @@ soup_auth_negotiate_class_init (SoupAuthNegotiateClass *auth_negotiate_class)
auth_class->is_authenticated = soup_auth_negotiate_is_authenticated;
auth_class->can_authenticate = soup_auth_negotiate_can_authenticate;
- g_type_class_add_private (auth_negotiate_class, sizeof (SoupAuthNegotiatePrivate));
-
parse_uris_from_env_variable ("SOUP_GSSAPI_TRUSTED_URIS", &trusted_uris);
parse_uris_from_env_variable ("SOUP_GSSAPI_BLACKLISTED_URIS", &blacklisted_uris);
#endif /* LIBSOUP_HAVE_GSSAPI */
@@ -332,7 +328,7 @@ check_server_response (SoupMessage *msg, gpointer auth)
const char *auth_headers;
GError *err = NULL;
SoupAuthNegotiate *negotiate = auth;
- SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (negotiate);
+ SoupAuthNegotiatePrivate *priv = soup_auth_negotiate_get_instance_private (negotiate);
SoupNegotiateConnectionState *conn = priv->conn_state;
if (auth != soup_message_get_auth (msg))
@@ -369,7 +365,7 @@ static void
remove_server_response_handler (SoupMessage *msg, gpointer auth)
{
SoupAuthNegotiate *negotiate = auth;
- SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (negotiate);
+ SoupAuthNegotiatePrivate *priv = soup_auth_negotiate_get_instance_private (negotiate);
g_signal_handler_disconnect (msg, priv->message_got_headers_signal_id);
priv->message_got_headers_signal_id = 0;
diff --git a/libsoup/soup-auth-ntlm.c b/libsoup/soup-auth-ntlm.c
index 68029ae..723c8ca 100644
--- a/libsoup/soup-auth-ntlm.c
+++ b/libsoup/soup-auth-ntlm.c
@@ -76,7 +76,6 @@ typedef struct {
int fd_out;
#endif
} SoupAuthNTLMPrivate;
-#define SOUP_AUTH_NTLM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_AUTH_NTLM,
SoupAuthNTLMPrivate))
#ifdef USE_NTLM_AUTH
static gboolean ntlm_auth_available, ntlm_auth_debug;
@@ -94,13 +93,13 @@ static void sso_ntlm_close (SoupAuthNTLMPrivate *priv);
* Since: 2.34
*/
-G_DEFINE_TYPE (SoupAuthNTLM, soup_auth_ntlm, SOUP_TYPE_CONNECTION_AUTH)
+G_DEFINE_TYPE_WITH_PRIVATE (SoupAuthNTLM, soup_auth_ntlm, SOUP_TYPE_CONNECTION_AUTH)
static void
soup_auth_ntlm_init (SoupAuthNTLM *ntlm)
{
#ifdef USE_NTLM_AUTH
- SoupAuthNTLMPrivate *priv = SOUP_AUTH_NTLM_GET_PRIVATE (ntlm);
+ SoupAuthNTLMPrivate *priv = soup_auth_ntlm_get_instance_private (ntlm);
const char *username = NULL, *slash;
priv->sso_available = TRUE;
@@ -125,7 +124,7 @@ soup_auth_ntlm_init (SoupAuthNTLM *ntlm)
static void
soup_auth_ntlm_finalize (GObject *object)
{
- SoupAuthNTLMPrivate *priv = SOUP_AUTH_NTLM_GET_PRIVATE (object);
+ SoupAuthNTLMPrivate *priv = soup_auth_ntlm_get_instance_private (SOUP_AUTH_NTLM (object));
g_free (priv->username);
g_free (priv->domain);
@@ -288,7 +287,8 @@ static gboolean
soup_auth_ntlm_update_connection (SoupConnectionAuth *auth, SoupMessage *msg,
const char *auth_header, gpointer state)
{
- SoupAuthNTLMPrivate *priv = SOUP_AUTH_NTLM_GET_PRIVATE (auth);
+ SoupAuthNTLM *auth_ntlm = SOUP_AUTH_NTLM (auth);
+ SoupAuthNTLMPrivate *priv = soup_auth_ntlm_get_instance_private (auth_ntlm);
SoupNTLMConnectionState *conn = state;
gboolean success = TRUE;
@@ -400,7 +400,8 @@ static void
soup_auth_ntlm_authenticate (SoupAuth *auth, const char *username,
const char *password)
{
- SoupAuthNTLMPrivate *priv = SOUP_AUTH_NTLM_GET_PRIVATE (auth);
+ SoupAuthNTLM *auth_ntlm = SOUP_AUTH_NTLM (auth);
+ SoupAuthNTLMPrivate *priv = soup_auth_ntlm_get_instance_private (auth_ntlm);
const char *slash;
g_return_if_fail (username != NULL);
@@ -429,7 +430,8 @@ soup_auth_ntlm_authenticate (SoupAuth *auth, const char *username,
static gboolean
soup_auth_ntlm_is_authenticated (SoupAuth *auth)
{
- SoupAuthNTLMPrivate *priv = SOUP_AUTH_NTLM_GET_PRIVATE (auth);
+ SoupAuthNTLM *auth_ntlm = SOUP_AUTH_NTLM (auth);
+ SoupAuthNTLMPrivate *priv = soup_auth_ntlm_get_instance_private (auth_ntlm);
return (priv->password_state != SOUP_NTLM_PASSWORD_NONE &&
priv->password_state != SOUP_NTLM_PASSWORD_REJECTED);
@@ -440,7 +442,8 @@ soup_auth_ntlm_is_connection_ready (SoupConnectionAuth *auth,
SoupMessage *msg,
gpointer state)
{
- SoupAuthNTLMPrivate *priv = SOUP_AUTH_NTLM_GET_PRIVATE (auth);
+ SoupAuthNTLM *auth_ntlm = SOUP_AUTH_NTLM (auth);
+ SoupAuthNTLMPrivate *priv = soup_auth_ntlm_get_instance_private (auth_ntlm);
SoupNTLMConnectionState *conn = state;
if (priv->password_state == SOUP_NTLM_PASSWORD_REJECTED)
@@ -456,6 +459,7 @@ static void
got_final_auth_result (SoupMessage *msg, gpointer data)
{
SoupAuth *auth = data;
+ SoupAuthNTLMPrivate *priv = soup_auth_ntlm_get_instance_private (SOUP_AUTH_NTLM (auth));
g_signal_handlers_disconnect_by_func (msg, G_CALLBACK (got_final_auth_result), auth);
@@ -463,7 +467,7 @@ got_final_auth_result (SoupMessage *msg, gpointer data)
return;
if (msg->status_code != SOUP_STATUS_UNAUTHORIZED)
- SOUP_AUTH_NTLM_GET_PRIVATE (auth)->password_state = SOUP_NTLM_PASSWORD_ACCEPTED;
+ priv->password_state = SOUP_NTLM_PASSWORD_ACCEPTED;
}
static char *
@@ -471,7 +475,8 @@ soup_auth_ntlm_get_connection_authorization (SoupConnectionAuth *auth,
SoupMessage *msg,
gpointer state)
{
- SoupAuthNTLMPrivate *priv = SOUP_AUTH_NTLM_GET_PRIVATE (auth);
+ SoupAuthNTLM *auth_ntlm = SOUP_AUTH_NTLM (auth);
+ SoupAuthNTLMPrivate *priv = soup_auth_ntlm_get_instance_private (auth_ntlm);
SoupNTLMConnectionState *conn = state;
char *header = NULL;
@@ -546,8 +551,6 @@ soup_auth_ntlm_class_init (SoupAuthNTLMClass *auth_ntlm_class)
SoupConnectionAuthClass *connauth_class = SOUP_CONNECTION_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;
diff --git a/libsoup/soup-auth.c b/libsoup/soup-auth.c
index 79aa7c3..00aa405 100644
--- a/libsoup/soup-auth.c
+++ b/libsoup/soup-auth.c
@@ -38,9 +38,8 @@ typedef struct {
gboolean proxy;
char *host;
} SoupAuthPrivate;
-#define SOUP_AUTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_AUTH, SoupAuthPrivate))
-G_DEFINE_ABSTRACT_TYPE (SoupAuth, soup_auth, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SoupAuth, soup_auth, G_TYPE_OBJECT)
enum {
PROP_0,
@@ -63,7 +62,7 @@ static void
soup_auth_finalize (GObject *object)
{
SoupAuth *auth = SOUP_AUTH (object);
- SoupAuthPrivate *priv = SOUP_AUTH_GET_PRIVATE (auth);
+ SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
g_free (auth->realm);
g_free (priv->host);
@@ -76,7 +75,7 @@ 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);
+ SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
switch (prop_id) {
case PROP_REALM:
@@ -101,7 +100,7 @@ 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);
+ SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
switch (prop_id) {
case PROP_SCHEME_NAME:
@@ -140,8 +139,6 @@ soup_auth_class_init (SoupAuthClass *auth_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (auth_class);
- g_type_class_add_private (auth_class, sizeof (SoupAuthPrivate));
-
auth_class->can_authenticate = auth_can_authenticate;
object_class->finalize = soup_auth_finalize;
@@ -352,9 +349,11 @@ soup_auth_authenticate (SoupAuth *auth, const char *username, const char *passwo
gboolean
soup_auth_is_for_proxy (SoupAuth *auth)
{
+ SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
+
g_return_val_if_fail (SOUP_IS_AUTH (auth), FALSE);
- return SOUP_AUTH_GET_PRIVATE (auth)->proxy;
+ return priv->proxy;
}
/**
@@ -384,12 +383,13 @@ soup_auth_get_scheme_name (SoupAuth *auth)
const char *
soup_auth_get_host (SoupAuth *auth)
{
+ SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
+
g_return_val_if_fail (SOUP_IS_AUTH (auth), NULL);
- return SOUP_AUTH_GET_PRIVATE (auth)->host;
+ return priv->host;
}
-
/**
* soup_auth_get_realm:
* @auth: a #SoupAuth
diff --git a/libsoup/soup-body-input-stream.c b/libsoup/soup-body-input-stream.c
index 6274744..32ad074 100644
--- a/libsoup/soup-body-input-stream.c
+++ b/libsoup/soup-body-input-stream.c
@@ -54,6 +54,7 @@ static void soup_body_input_stream_pollable_init (GPollableInputStreamInterface
static void soup_body_input_stream_seekable_init (GSeekableIface *seekable_interface);
G_DEFINE_TYPE_WITH_CODE (SoupBodyInputStream, soup_body_input_stream, G_TYPE_FILTER_INPUT_STREAM,
+ G_ADD_PRIVATE (SoupBodyInputStream)
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
soup_body_input_stream_pollable_init)
G_IMPLEMENT_INTERFACE (G_TYPE_SEEKABLE,
@@ -62,9 +63,7 @@ G_DEFINE_TYPE_WITH_CODE (SoupBodyInputStream, soup_body_input_stream, G_TYPE_FIL
static void
soup_body_input_stream_init (SoupBodyInputStream *bistream)
{
- bistream->priv = G_TYPE_INSTANCE_GET_PRIVATE (bistream,
- SOUP_TYPE_BODY_INPUT_STREAM,
- SoupBodyInputStreamPrivate);
+ bistream->priv = soup_body_input_stream_get_instance_private (bistream);
bistream->priv->encoding = SOUP_ENCODING_NONE;
}
@@ -368,8 +367,6 @@ soup_body_input_stream_class_init (SoupBodyInputStreamClass *stream_class)
GObjectClass *object_class = G_OBJECT_CLASS (stream_class);
GInputStreamClass *input_stream_class = G_INPUT_STREAM_CLASS (stream_class);
- g_type_class_add_private (stream_class, sizeof (SoupBodyInputStreamPrivate));
-
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;
diff --git a/libsoup/soup-body-output-stream.c b/libsoup/soup-body-output-stream.c
index 03353ef..314d7ee 100644
--- a/libsoup/soup-body-output-stream.c
+++ b/libsoup/soup-body-output-stream.c
@@ -43,6 +43,7 @@ enum {
static void soup_body_output_stream_pollable_init (GPollableOutputStreamInterface *pollable_interface,
gpointer interface_data);
G_DEFINE_TYPE_WITH_CODE (SoupBodyOutputStream, soup_body_output_stream, G_TYPE_FILTER_OUTPUT_STREAM,
+ G_ADD_PRIVATE (SoupBodyOutputStream)
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_OUTPUT_STREAM,
soup_body_output_stream_pollable_init))
@@ -50,9 +51,7 @@ G_DEFINE_TYPE_WITH_CODE (SoupBodyOutputStream, soup_body_output_stream, G_TYPE_F
static void
soup_body_output_stream_init (SoupBodyOutputStream *stream)
{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- SOUP_TYPE_BODY_OUTPUT_STREAM,
- SoupBodyOutputStreamPrivate);
+ stream->priv = soup_body_output_stream_get_instance_private (stream);
}
static void
@@ -297,8 +296,6 @@ soup_body_output_stream_class_init (SoupBodyOutputStreamClass *stream_class)
GObjectClass *object_class = G_OBJECT_CLASS (stream_class);
GOutputStreamClass *output_stream_class = G_OUTPUT_STREAM_CLASS (stream_class);
- g_type_class_add_private (stream_class, sizeof (SoupBodyOutputStreamPrivate));
-
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;
diff --git a/libsoup/soup-cache-input-stream.c b/libsoup/soup-cache-input-stream.c
index 137e0cf..e93b43f 100644
--- a/libsoup/soup-cache-input-stream.c
+++ b/libsoup/soup-cache-input-stream.c
@@ -11,12 +11,6 @@
#include "soup-cache-input-stream.h"
#include "soup-message-body.h"
-static void soup_cache_input_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
gpointer interface_data);
-
-G_DEFINE_TYPE_WITH_CODE (SoupCacheInputStream, soup_cache_input_stream, SOUP_TYPE_FILTER_INPUT_STREAM,
- G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
- soup_cache_input_stream_pollable_init))
-
/* properties */
enum {
PROP_0,
@@ -45,6 +39,14 @@ struct _SoupCacheInputStreamPrivate
GQueue *buffer_queue;
};
+static void soup_cache_input_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
gpointer interface_data);
+
+G_DEFINE_TYPE_WITH_CODE (SoupCacheInputStream, soup_cache_input_stream, SOUP_TYPE_FILTER_INPUT_STREAM,
+ G_ADD_PRIVATE (SoupCacheInputStream)
+ G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
+ soup_cache_input_stream_pollable_init))
+
+
static void soup_cache_input_stream_write_next_buffer (SoupCacheInputStream *istream);
static inline void
@@ -98,9 +100,7 @@ file_replaced_cb (GObject *source,
static void
soup_cache_input_stream_init (SoupCacheInputStream *self)
{
- SoupCacheInputStreamPrivate *priv =
- G_TYPE_INSTANCE_GET_PRIVATE (self, SOUP_TYPE_CACHE_INPUT_STREAM,
- SoupCacheInputStreamPrivate);
+ SoupCacheInputStreamPrivate *priv = soup_cache_input_stream_get_instance_private (self);
priv->buffer_queue = g_queue_new ();
self->priv = priv;
@@ -305,8 +305,6 @@ soup_cache_input_stream_class_init (SoupCacheInputStreamClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GInputStreamClass *istream_class = G_INPUT_STREAM_CLASS (klass);
- g_type_class_add_private (klass, sizeof (SoupCacheInputStreamPrivate));
-
gobject_class->get_property = soup_cache_input_stream_get_property;
gobject_class->set_property = soup_cache_input_stream_set_property;
gobject_class->finalize = soup_cache_input_stream_finalize;
diff --git a/libsoup/soup-cache.c b/libsoup/soup-cache.c
index d5f5586..0963864 100644
--- a/libsoup/soup-cache.c
+++ b/libsoup/soup-cache.c
@@ -127,9 +127,8 @@ enum {
PROP_CACHE_TYPE
};
-#define SOUP_CACHE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_CACHE, SoupCachePrivate))
-
G_DEFINE_TYPE_WITH_CODE (SoupCache, soup_cache, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (SoupCache)
G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
soup_cache_session_feature_init)
G_IMPLEMENT_INTERFACE (SOUP_TYPE_CONTENT_PROCESSOR,
@@ -174,7 +173,7 @@ get_cacheability (SoupCache *cache, SoupMessage *msg)
cache_control = soup_message_headers_get_list (msg->response_headers, "Cache-Control");
if (cache_control && *cache_control) {
GHashTable *hash;
- SoupCachePrivate *priv = SOUP_CACHE_GET_PRIVATE (cache);
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
hash = soup_header_parse_param_list (cache_control);
@@ -348,7 +347,7 @@ soup_cache_entry_set_freshness (SoupCacheEntry *entry, SoupMessage *msg, SoupCac
const char *max_age, *s_maxage;
gint64 freshness_lifetime = 0;
GHashTable *hash;
- SoupCachePrivate *priv = SOUP_CACHE_GET_PRIVATE (cache);
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
hash = soup_header_parse_param_list (cache_control);
@@ -899,7 +898,7 @@ soup_cache_init (SoupCache *cache)
{
SoupCachePrivate *priv;
- priv = cache->priv = SOUP_CACHE_GET_PRIVATE (cache);
+ priv = cache->priv = soup_cache_get_instance_private (cache);
priv->cache = g_hash_table_new (g_direct_hash, g_direct_equal);
/* LRU */
@@ -1030,8 +1029,6 @@ soup_cache_class_init (SoupCacheClass *cache_class)
SOUP_TYPE_CACHE_TYPE,
SOUP_CACHE_SINGLE_USER,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_type_class_add_private (cache_class, sizeof (SoupCachePrivate));
}
/**
@@ -1494,7 +1491,7 @@ pack_entry (gpointer data,
void
soup_cache_dump (SoupCache *cache)
{
- SoupCachePrivate *priv = SOUP_CACHE_GET_PRIVATE (cache);
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
char *filename;
GVariantBuilder entries_builder;
GVariant *cache_variant;
diff --git a/libsoup/soup-client-input-stream.c b/libsoup/soup-client-input-stream.c
index 1798306..c305dd8 100644
--- a/libsoup/soup-client-input-stream.c
+++ b/libsoup/soup-client-input-stream.c
@@ -34,15 +34,14 @@ static GPollableInputStreamInterface *soup_client_input_stream_parent_pollable_i
static void soup_client_input_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
gpointer interface_data);
G_DEFINE_TYPE_WITH_CODE (SoupClientInputStream, soup_client_input_stream, SOUP_TYPE_FILTER_INPUT_STREAM,
+ G_ADD_PRIVATE (SoupClientInputStream)
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
soup_client_input_stream_pollable_init))
static void
soup_client_input_stream_init (SoupClientInputStream *stream)
{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- SOUP_TYPE_CLIENT_INPUT_STREAM,
- SoupClientInputStreamPrivate);
+ stream->priv = soup_client_input_stream_get_instance_private (stream);
}
static void
@@ -215,8 +214,6 @@ soup_client_input_stream_class_init (SoupClientInputStreamClass *stream_class)
GObjectClass *object_class = G_OBJECT_CLASS (stream_class);
GInputStreamClass *input_stream_class = G_INPUT_STREAM_CLASS (stream_class);
- g_type_class_add_private (stream_class, sizeof (SoupClientInputStreamPrivate));
-
object_class->finalize = soup_client_input_stream_finalize;
object_class->set_property = soup_client_input_stream_set_property;
object_class->get_property = soup_client_input_stream_get_property;
diff --git a/libsoup/soup-connection-auth.c b/libsoup/soup-connection-auth.c
index fc32733..8362095 100644
--- a/libsoup/soup-connection-auth.c
+++ b/libsoup/soup-connection-auth.c
@@ -18,16 +18,16 @@
#include "soup-connection.h"
#include "soup-message-private.h"
-G_DEFINE_ABSTRACT_TYPE (SoupConnectionAuth, soup_connection_auth, SOUP_TYPE_AUTH)
-
struct SoupConnectionAuthPrivate {
GHashTable *conns;
};
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SoupConnectionAuth, soup_connection_auth, SOUP_TYPE_AUTH)
+
static void
soup_connection_auth_init (SoupConnectionAuth *auth)
{
- auth->priv = G_TYPE_INSTANCE_GET_PRIVATE (auth, SOUP_TYPE_CONNECTION_AUTH, SoupConnectionAuthPrivate);
+ auth->priv = soup_connection_auth_get_instance_private (auth);
auth->priv->conns = g_hash_table_new (NULL, NULL);
}
@@ -163,8 +163,6 @@ soup_connection_auth_class_init (SoupConnectionAuthClass *connauth_class)
SoupAuthClass *auth_class = SOUP_AUTH_CLASS (connauth_class);
GObjectClass *object_class = G_OBJECT_CLASS (connauth_class);
- g_type_class_add_private (connauth_class, sizeof (SoupConnectionAuthPrivate));
-
auth_class->update = soup_connection_auth_update;
auth_class->get_authorization = soup_connection_auth_get_authorization;
auth_class->is_ready = soup_connection_auth_is_ready;
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index 00fd4c3..5403704 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -27,9 +27,8 @@ typedef struct {
GSource *idle_timeout_src;
gboolean reusable;
} SoupConnectionPrivate;
-#define SOUP_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_CONNECTION,
SoupConnectionPrivate))
-G_DEFINE_TYPE (SoupConnection, soup_connection, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (SoupConnection, soup_connection, G_TYPE_OBJECT)
enum {
EVENT,
@@ -64,7 +63,7 @@ soup_connection_init (SoupConnection *conn)
static void
soup_connection_finalize (GObject *object)
{
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (SOUP_CONNECTION (object));
g_clear_pointer (&priv->remote_uri, soup_uri_free);
g_clear_pointer (&priv->proxy_uri, soup_uri_free);
@@ -83,7 +82,7 @@ static void
soup_connection_dispose (GObject *object)
{
SoupConnection *conn = SOUP_CONNECTION (object);
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
stop_idle_timer (priv);
@@ -94,7 +93,7 @@ static void
soup_connection_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (SOUP_CONNECTION (object));
switch (prop_id) {
case PROP_REMOTE_URI:
@@ -120,7 +119,7 @@ static void
soup_connection_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (SOUP_CONNECTION (object));
switch (prop_id) {
case PROP_REMOTE_URI:
@@ -143,8 +142,6 @@ soup_connection_class_init (SoupConnectionClass *connection_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (connection_class);
- g_type_class_add_private (connection_class, sizeof (SoupConnectionPrivate));
-
/* virtual method override */
object_class->dispose = soup_connection_dispose;
object_class->finalize = soup_connection_finalize;
@@ -200,7 +197,7 @@ soup_connection_event (SoupConnection *conn,
GSocketClientEvent event,
GIOStream *connection)
{
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
if (!connection && priv->socket)
connection = soup_socket_get_connection (priv->socket);
@@ -219,7 +216,7 @@ idle_timeout (gpointer conn)
static void
start_idle_timer (SoupConnection *conn)
{
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
if (priv->socket_props->idle_timeout > 0 && !priv->idle_timeout_src) {
priv->idle_timeout_src =
@@ -242,7 +239,7 @@ static void
current_msg_got_body (SoupMessage *msg, gpointer user_data)
{
SoupConnection *conn = user_data;
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
priv->unused_timeout = 0;
@@ -261,7 +258,7 @@ current_msg_got_body (SoupMessage *msg, gpointer user_data)
static void
clear_current_msg (SoupConnection *conn)
{
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
SoupMessage *msg;
msg = priv->current_msg;
@@ -274,7 +271,7 @@ clear_current_msg (SoupConnection *conn)
static void
set_current_msg (SoupConnection *conn, SoupMessage *msg)
{
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
g_return_if_fail (priv->state == SOUP_CONNECTION_IN_USE);
@@ -316,7 +313,7 @@ static void
socket_connect_finished (GTask *task, SoupSocket *sock, GError *error)
{
SoupConnection *conn = g_task_get_source_object (task);
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
if (!error) {
if (!priv->ssl || !priv->proxy_uri) {
@@ -352,7 +349,7 @@ socket_connect_complete (GObject *object, GAsyncResult *result, gpointer user_da
SoupSocket *sock = SOUP_SOCKET (object);
GTask *task = user_data;
SoupConnection *conn = g_task_get_source_object (task);
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
GError *error = NULL;
if (!soup_socket_connect_finish_internal (sock, result, &error)) {
@@ -383,7 +380,7 @@ soup_connection_connect_async (SoupConnection *conn,
GTask *task;
g_return_if_fail (SOUP_IS_CONNECTION (conn));
- priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ priv = soup_connection_get_instance_private (conn);
g_return_if_fail (priv->socket == NULL);
soup_connection_set_state (conn, SOUP_CONNECTION_CONNECTING);
@@ -430,7 +427,7 @@ soup_connection_connect_sync (SoupConnection *conn,
SoupAddress *remote_addr;
g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
- priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ priv = soup_connection_get_instance_private (conn);
g_return_val_if_fail (priv->socket == NULL, FALSE);
soup_connection_set_state (conn, SOUP_CONNECTION_CONNECTING);
@@ -482,7 +479,7 @@ soup_connection_is_tunnelled (SoupConnection *conn)
SoupConnectionPrivate *priv;
g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
- priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ priv = soup_connection_get_instance_private (conn);
return priv->ssl && priv->proxy_uri != NULL;
}
@@ -495,7 +492,7 @@ soup_connection_start_ssl_sync (SoupConnection *conn,
SoupConnectionPrivate *priv;
g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
- priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ priv = soup_connection_get_instance_private (conn);
if (soup_socket_handshake_sync (priv->socket, priv->remote_uri->host,
cancellable, error)) {
@@ -510,7 +507,7 @@ start_ssl_completed (GObject *object, GAsyncResult *result, gpointer user_data)
{
GTask *task = user_data;
SoupConnection *conn = g_task_get_source_object (task);
- SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
GError *error = NULL;
if (soup_socket_handshake_finish (priv->socket, result, &error)) {
@@ -531,7 +528,7 @@ soup_connection_start_ssl_async (SoupConnection *conn,
GTask *task;
g_return_if_fail (SOUP_IS_CONNECTION (conn));
- priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ priv = soup_connection_get_instance_private (conn);
soup_socket_properties_push_async_context (priv->socket_props);
task = g_task_new (conn, cancellable, callback, user_data);
@@ -564,7 +561,7 @@ soup_connection_disconnect (SoupConnection *conn)
SoupConnectionState old_state;
g_return_if_fail (SOUP_IS_CONNECTION (conn));
- priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ priv = soup_connection_get_instance_private (conn);
old_state = priv->state;
if (old_state != SOUP_CONNECTION_DISCONNECTED)
@@ -587,33 +584,41 @@ soup_connection_disconnect (SoupConnection *conn)
SoupSocket *
soup_connection_get_socket (SoupConnection *conn)
{
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
+
g_return_val_if_fail (SOUP_IS_CONNECTION (conn), NULL);
- return SOUP_CONNECTION_GET_PRIVATE (conn)->socket;
+ return priv->socket;
}
SoupURI *
soup_connection_get_remote_uri (SoupConnection *conn)
{
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
+
g_return_val_if_fail (SOUP_IS_CONNECTION (conn), NULL);
- return SOUP_CONNECTION_GET_PRIVATE (conn)->remote_uri;
+ return priv->remote_uri;
}
SoupURI *
soup_connection_get_proxy_uri (SoupConnection *conn)
{
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
+
g_return_val_if_fail (SOUP_IS_CONNECTION (conn), NULL);
- return SOUP_CONNECTION_GET_PRIVATE (conn)->proxy_uri;
+ return priv->proxy_uri;
}
gboolean
soup_connection_is_via_proxy (SoupConnection *conn)
{
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
+
g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
- return SOUP_CONNECTION_GET_PRIVATE (conn)->proxy_uri != NULL;
+ return priv->proxy_uri != NULL;
}
SoupConnectionState
@@ -623,7 +628,7 @@ soup_connection_get_state (SoupConnection *conn)
g_return_val_if_fail (SOUP_IS_CONNECTION (conn),
SOUP_CONNECTION_DISCONNECTED);
- priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ priv = soup_connection_get_instance_private (conn);
if (priv->state == SOUP_CONNECTION_IDLE &&
(!soup_socket_is_connected (priv->socket) ||
@@ -648,7 +653,7 @@ soup_connection_set_state (SoupConnection *conn, SoupConnectionState state)
g_object_freeze_notify (G_OBJECT (conn));
- priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ priv = soup_connection_get_instance_private (conn);
if (priv->current_msg) {
g_warn_if_fail (state == SOUP_CONNECTION_IDLE ||
@@ -674,9 +679,11 @@ soup_connection_set_state (SoupConnection *conn, SoupConnectionState state)
gboolean
soup_connection_get_ever_used (SoupConnection *conn)
{
+ SoupConnectionPrivate *priv = soup_connection_get_instance_private (conn);
+
g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
- return SOUP_CONNECTION_GET_PRIVATE (conn)->unused_timeout == 0;
+ return priv->unused_timeout == 0;
}
void
@@ -689,7 +696,7 @@ soup_connection_send_request (SoupConnection *conn,
g_return_if_fail (SOUP_IS_CONNECTION (conn));
g_return_if_fail (item != NULL);
- priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+ priv = soup_connection_get_instance_private (conn);
g_return_if_fail (priv->state != SOUP_CONNECTION_NEW &&
priv->state != SOUP_CONNECTION_DISCONNECTED);
diff --git a/libsoup/soup-content-decoder.c b/libsoup/soup-content-decoder.c
index bce78c0..080904a 100644
--- a/libsoup/soup-content-decoder.c
+++ b/libsoup/soup-content-decoder.c
@@ -63,6 +63,7 @@ static void soup_content_decoder_content_processor_init (SoupContentProcessorInt
G_DEFINE_TYPE_WITH_CODE (SoupContentDecoder, soup_content_decoder, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (SoupContentDecoder)
G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
soup_content_decoder_session_feature_init)
G_IMPLEMENT_INTERFACE (SOUP_TYPE_CONTENT_PROCESSOR,
@@ -185,9 +186,7 @@ zlib_decoder_creator (void)
static void
soup_content_decoder_init (SoupContentDecoder *decoder)
{
- decoder->priv = G_TYPE_INSTANCE_GET_PRIVATE (decoder,
- SOUP_TYPE_CONTENT_DECODER,
- SoupContentDecoderPrivate);
+ decoder->priv = soup_content_decoder_get_instance_private (decoder);
decoder->priv->decoders = g_hash_table_new (g_str_hash, g_str_equal);
/* Hardcoded for now */
@@ -214,8 +213,6 @@ soup_content_decoder_class_init (SoupContentDecoderClass *decoder_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (decoder_class);
- g_type_class_add_private (decoder_class, sizeof (SoupContentDecoderPrivate));
-
object_class->finalize = soup_content_decoder_finalize;
}
diff --git a/libsoup/soup-content-sniffer-stream.c b/libsoup/soup-content-sniffer-stream.c
index d358a19..b8a8c97 100644
--- a/libsoup/soup-content-sniffer-stream.c
+++ b/libsoup/soup-content-sniffer-stream.c
@@ -14,12 +14,6 @@
#include "soup-content-sniffer-stream.h"
#include "soup.h"
-static void soup_content_sniffer_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
gpointer interface_data);
-
-G_DEFINE_TYPE_WITH_CODE (SoupContentSnifferStream, soup_content_sniffer_stream, G_TYPE_FILTER_INPUT_STREAM,
- G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
- soup_content_sniffer_stream_pollable_init))
-
enum {
PROP_0,
@@ -40,6 +34,13 @@ struct _SoupContentSnifferStreamPrivate {
GHashTable *sniffed_params;
};
+static void soup_content_sniffer_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
gpointer interface_data);
+
+G_DEFINE_TYPE_WITH_CODE (SoupContentSnifferStream, soup_content_sniffer_stream, G_TYPE_FILTER_INPUT_STREAM,
+ G_ADD_PRIVATE (SoupContentSnifferStream)
+ G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
+ soup_content_sniffer_stream_pollable_init))
+
static void
soup_content_sniffer_stream_finalize (GObject *object)
{
@@ -288,9 +289,7 @@ soup_content_sniffer_stream_create_source (GPollableInputStream *stream,
static void
soup_content_sniffer_stream_init (SoupContentSnifferStream *sniffer)
{
- sniffer->priv = G_TYPE_INSTANCE_GET_PRIVATE (sniffer,
- SOUP_TYPE_CONTENT_SNIFFER_STREAM,
- SoupContentSnifferStreamPrivate);
+ sniffer->priv = soup_content_sniffer_stream_get_instance_private (sniffer);
sniffer->priv->sniffing = TRUE;
}
@@ -301,8 +300,6 @@ soup_content_sniffer_stream_class_init (SoupContentSnifferStreamClass *sniffer_c
GInputStreamClass *input_stream_class =
G_INPUT_STREAM_CLASS (sniffer_class);
- g_type_class_add_private (sniffer_class, sizeof (SoupContentSnifferStreamPrivate));
-
object_class->finalize = soup_content_sniffer_stream_finalize;
object_class->set_property = soup_content_sniffer_stream_set_property;
object_class->get_property = soup_content_sniffer_stream_get_property;
diff --git a/libsoup/soup-converter-wrapper.c b/libsoup/soup-converter-wrapper.c
index d1837e6..133a3eb 100644
--- a/libsoup/soup-converter-wrapper.c
+++ b/libsoup/soup-converter-wrapper.c
@@ -34,12 +34,6 @@ enum {
PROP_MESSAGE
};
-static void soup_converter_wrapper_iface_init (GConverterIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (SoupConverterWrapper, soup_converter_wrapper, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_CONVERTER,
- soup_converter_wrapper_iface_init))
-
struct _SoupConverterWrapperPrivate
{
GConverter *base_converter;
@@ -49,12 +43,17 @@ struct _SoupConverterWrapperPrivate
gboolean discarding;
};
+static void soup_converter_wrapper_iface_init (GConverterIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (SoupConverterWrapper, soup_converter_wrapper, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (SoupConverterWrapper)
+ G_IMPLEMENT_INTERFACE (G_TYPE_CONVERTER,
+ soup_converter_wrapper_iface_init))
+
static void
soup_converter_wrapper_init (SoupConverterWrapper *converter)
{
- converter->priv = G_TYPE_INSTANCE_GET_PRIVATE (converter,
- SOUP_TYPE_CONVERTER_WRAPPER,
- SoupConverterWrapperPrivate);
+ converter->priv = soup_converter_wrapper_get_instance_private (converter);
}
static void
@@ -129,8 +128,6 @@ soup_converter_wrapper_class_init (SoupConverterWrapperClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (SoupConverterWrapperPrivate));
-
gobject_class->finalize = soup_converter_wrapper_finalize;
gobject_class->get_property = soup_converter_wrapper_get_property;
gobject_class->set_property = soup_converter_wrapper_set_property;
diff --git a/libsoup/soup-cookie-jar-db.c b/libsoup/soup-cookie-jar-db.c
index 8f21baa..0274038 100644
--- a/libsoup/soup-cookie-jar-db.c
+++ b/libsoup/soup-cookie-jar-db.c
@@ -43,9 +43,7 @@ typedef struct {
sqlite3 *db;
} SoupCookieJarDBPrivate;
-#define SOUP_COOKIE_JAR_DB_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_COOKIE_JAR_DB,
SoupCookieJarDBPrivate))
-
-G_DEFINE_TYPE (SoupCookieJarDB, soup_cookie_jar_db, SOUP_TYPE_COOKIE_JAR)
+G_DEFINE_TYPE_WITH_PRIVATE (SoupCookieJarDB, soup_cookie_jar_db, SOUP_TYPE_COOKIE_JAR)
static void load (SoupCookieJar *jar);
@@ -58,7 +56,7 @@ static void
soup_cookie_jar_db_finalize (GObject *object)
{
SoupCookieJarDBPrivate *priv =
- SOUP_COOKIE_JAR_DB_GET_PRIVATE (object);
+ soup_cookie_jar_db_get_instance_private (SOUP_COOKIE_JAR_DB (object));
g_free (priv->filename);
g_clear_pointer (&priv->db, sqlite3_close);
@@ -71,7 +69,7 @@ soup_cookie_jar_db_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
SoupCookieJarDBPrivate *priv =
- SOUP_COOKIE_JAR_DB_GET_PRIVATE (object);
+ soup_cookie_jar_db_get_instance_private (SOUP_COOKIE_JAR_DB (object));
switch (prop_id) {
case PROP_FILENAME:
@@ -89,7 +87,7 @@ soup_cookie_jar_db_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SoupCookieJarDBPrivate *priv =
- SOUP_COOKIE_JAR_DB_GET_PRIVATE (object);
+ soup_cookie_jar_db_get_instance_private (SOUP_COOKIE_JAR_DB (object));
switch (prop_id) {
case PROP_FILENAME:
@@ -227,7 +225,7 @@ static gboolean
open_db (SoupCookieJar *jar)
{
SoupCookieJarDBPrivate *priv =
- SOUP_COOKIE_JAR_DB_GET_PRIVATE (jar);
+ soup_cookie_jar_db_get_instance_private (SOUP_COOKIE_JAR_DB (jar));
char *error = NULL;
@@ -250,7 +248,7 @@ static void
load (SoupCookieJar *jar)
{
SoupCookieJarDBPrivate *priv =
- SOUP_COOKIE_JAR_DB_GET_PRIVATE (jar);
+ soup_cookie_jar_db_get_instance_private (SOUP_COOKIE_JAR_DB (jar));
if (priv->db == NULL) {
if (open_db (jar))
@@ -266,7 +264,7 @@ soup_cookie_jar_db_changed (SoupCookieJar *jar,
SoupCookie *new_cookie)
{
SoupCookieJarDBPrivate *priv =
- SOUP_COOKIE_JAR_DB_GET_PRIVATE (jar);
+ soup_cookie_jar_db_get_instance_private (SOUP_COOKIE_JAR_DB (jar));
char *query;
if (priv->db == NULL) {
@@ -312,8 +310,6 @@ soup_cookie_jar_db_class_init (SoupCookieJarDBClass *db_class)
SOUP_COOKIE_JAR_CLASS (db_class);
GObjectClass *object_class = G_OBJECT_CLASS (db_class);
- g_type_class_add_private (db_class, sizeof (SoupCookieJarDBPrivate));
-
cookie_jar_class->is_persistent = soup_cookie_jar_db_is_persistent;
cookie_jar_class->changed = soup_cookie_jar_db_changed;
diff --git a/libsoup/soup-cookie-jar-text.c b/libsoup/soup-cookie-jar-text.c
index 433c571..46e12e5 100644
--- a/libsoup/soup-cookie-jar-text.c
+++ b/libsoup/soup-cookie-jar-text.c
@@ -36,9 +36,8 @@ typedef struct {
char *filename;
} SoupCookieJarTextPrivate;
-#define SOUP_COOKIE_JAR_TEXT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_COOKIE_JAR_TEXT,
SoupCookieJarTextPrivate))
-G_DEFINE_TYPE (SoupCookieJarText, soup_cookie_jar_text, SOUP_TYPE_COOKIE_JAR)
+G_DEFINE_TYPE_WITH_PRIVATE (SoupCookieJarText, soup_cookie_jar_text, SOUP_TYPE_COOKIE_JAR)
static void load (SoupCookieJar *jar);
@@ -51,7 +50,7 @@ static void
soup_cookie_jar_text_finalize (GObject *object)
{
SoupCookieJarTextPrivate *priv =
- SOUP_COOKIE_JAR_TEXT_GET_PRIVATE (object);
+ soup_cookie_jar_text_get_instance_private (SOUP_COOKIE_JAR_TEXT (object));
g_free (priv->filename);
@@ -63,7 +62,7 @@ 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);
+ soup_cookie_jar_text_get_instance_private (SOUP_COOKIE_JAR_TEXT (object));
switch (prop_id) {
case PROP_FILENAME:
@@ -81,7 +80,7 @@ soup_cookie_jar_text_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SoupCookieJarTextPrivate *priv =
- SOUP_COOKIE_JAR_TEXT_GET_PRIVATE (object);
+ soup_cookie_jar_text_get_instance_private (SOUP_COOKIE_JAR_TEXT (object));
switch (prop_id) {
case PROP_FILENAME:
@@ -192,7 +191,7 @@ static void
load (SoupCookieJar *jar)
{
SoupCookieJarTextPrivate *priv =
- SOUP_COOKIE_JAR_TEXT_GET_PRIVATE (jar);
+ soup_cookie_jar_text_get_instance_private (SOUP_COOKIE_JAR_TEXT (jar));
char *contents = NULL, *line, *p;
gsize length = 0;
time_t now = time (NULL);
@@ -281,7 +280,7 @@ soup_cookie_jar_text_changed (SoupCookieJar *jar,
{
FILE *out;
SoupCookieJarTextPrivate *priv =
- SOUP_COOKIE_JAR_TEXT_GET_PRIVATE (jar);
+ soup_cookie_jar_text_get_instance_private (SOUP_COOKIE_JAR_TEXT (jar));
/* We can sort of ignore the semantics of the 'changed'
* signal here and simply delete the old cookie if present
@@ -338,8 +337,6 @@ soup_cookie_jar_text_class_init (SoupCookieJarTextClass *text_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;
diff --git a/libsoup/soup-cookie-jar.c b/libsoup/soup-cookie-jar.c
index d12bc85..41b614a 100644
--- a/libsoup/soup-cookie-jar.c
+++ b/libsoup/soup-cookie-jar.c
@@ -28,12 +28,6 @@
* of long-term cookie persistence.
**/
-static void soup_cookie_jar_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer
interface_data);
-
-G_DEFINE_TYPE_WITH_CODE (SoupCookieJar, soup_cookie_jar, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
- soup_cookie_jar_session_feature_init))
-
enum {
CHANGED,
LAST_SIGNAL
@@ -56,12 +50,18 @@ typedef struct {
guint serial;
SoupCookieJarAcceptPolicy accept_policy;
} SoupCookieJarPrivate;
-#define SOUP_COOKIE_JAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_COOKIE_JAR,
SoupCookieJarPrivate))
+
+static void soup_cookie_jar_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer
interface_data);
+
+G_DEFINE_TYPE_WITH_CODE (SoupCookieJar, soup_cookie_jar, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (SoupCookieJar)
+ G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
+ soup_cookie_jar_session_feature_init))
static void
soup_cookie_jar_init (SoupCookieJar *jar)
{
- SoupCookieJarPrivate *priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ SoupCookieJarPrivate *priv = soup_cookie_jar_get_instance_private (jar);
priv->domains = g_hash_table_new_full (soup_str_case_hash,
soup_str_case_equal,
@@ -73,7 +73,8 @@ soup_cookie_jar_init (SoupCookieJar *jar)
static void
soup_cookie_jar_constructed (GObject *object)
{
- SoupCookieJarPrivate *priv = SOUP_COOKIE_JAR_GET_PRIVATE (object);
+ SoupCookieJarPrivate *priv =
+ soup_cookie_jar_get_instance_private (SOUP_COOKIE_JAR (object));
priv->constructed = TRUE;
}
@@ -81,7 +82,8 @@ soup_cookie_jar_constructed (GObject *object)
static void
soup_cookie_jar_finalize (GObject *object)
{
- SoupCookieJarPrivate *priv = SOUP_COOKIE_JAR_GET_PRIVATE (object);
+ SoupCookieJarPrivate *priv =
+ soup_cookie_jar_get_instance_private (SOUP_COOKIE_JAR (object));
GHashTableIter iter;
gpointer key, value;
@@ -99,7 +101,7 @@ soup_cookie_jar_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
SoupCookieJarPrivate *priv =
- SOUP_COOKIE_JAR_GET_PRIVATE (object);
+ soup_cookie_jar_get_instance_private (SOUP_COOKIE_JAR (object));
switch (prop_id) {
case PROP_READ_ONLY:
@@ -119,7 +121,7 @@ soup_cookie_jar_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SoupCookieJarPrivate *priv =
- SOUP_COOKIE_JAR_GET_PRIVATE (object);
+ soup_cookie_jar_get_instance_private (SOUP_COOKIE_JAR (object));
switch (prop_id) {
case PROP_READ_ONLY:
@@ -145,8 +147,6 @@ 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 = soup_cookie_jar_constructed;
object_class->finalize = soup_cookie_jar_finalize;
object_class->set_property = soup_cookie_jar_set_property;
@@ -255,7 +255,7 @@ static void
soup_cookie_jar_changed (SoupCookieJar *jar,
SoupCookie *old, SoupCookie *new)
{
- SoupCookieJarPrivate *priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ SoupCookieJarPrivate *priv = soup_cookie_jar_get_instance_private (jar);
if (old && old != new)
g_hash_table_remove (priv->serials, old);
@@ -275,7 +275,7 @@ compare_cookies (gconstpointer a, gconstpointer b, gpointer jar)
{
SoupCookie *ca = (SoupCookie *)a;
SoupCookie *cb = (SoupCookie *)b;
- SoupCookieJarPrivate *priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ SoupCookieJarPrivate *priv = soup_cookie_jar_get_instance_private (jar);
int alen, blen;
guint aserial, bserial;
@@ -304,7 +304,7 @@ get_cookies (SoupCookieJar *jar, SoupURI *uri, gboolean for_http, gboolean copy_
char *domain, *cur, *next_domain;
GSList *new_head, *cookies_to_remove = NULL, *p;
- priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ priv = soup_cookie_jar_get_instance_private (jar);
if (!uri->host)
return NULL;
@@ -462,7 +462,7 @@ soup_cookie_jar_add_cookie (SoupCookieJar *jar, SoupCookie *cookie)
return;
}
- priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ priv = soup_cookie_jar_get_instance_private (jar);
old_cookies = g_hash_table_lookup (priv->domains, cookie->domain);
for (oc = old_cookies; oc; oc = oc->next) {
old_cookie = oc->data;
@@ -535,7 +535,7 @@ soup_cookie_jar_add_cookie_with_first_party (SoupCookieJar *jar, SoupURI *first_
g_return_if_fail (first_party != NULL);
g_return_if_fail (cookie != NULL);
- priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ priv = soup_cookie_jar_get_instance_private (jar);
if (priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NEVER) {
soup_cookie_free (cookie);
return;
@@ -581,7 +581,7 @@ soup_cookie_jar_set_cookie (SoupCookieJar *jar, SoupURI *uri,
if (!uri->host)
return;
- priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ priv = soup_cookie_jar_get_instance_private (jar);
if (priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NEVER)
return;
@@ -633,7 +633,7 @@ static void
process_set_cookie_header (SoupMessage *msg, gpointer user_data)
{
SoupCookieJar *jar = user_data;
- SoupCookieJarPrivate *priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ SoupCookieJarPrivate *priv = soup_cookie_jar_get_instance_private (jar);
GSList *new_cookies, *nc;
if (priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NEVER)
@@ -723,7 +723,7 @@ soup_cookie_jar_all_cookies (SoupCookieJar *jar)
g_return_val_if_fail (SOUP_IS_COOKIE_JAR (jar), NULL);
- priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ priv = soup_cookie_jar_get_instance_private (jar);
g_hash_table_iter_init (&iter, priv->domains);
@@ -755,7 +755,7 @@ soup_cookie_jar_delete_cookie (SoupCookieJar *jar,
g_return_if_fail (SOUP_IS_COOKIE_JAR (jar));
g_return_if_fail (cookie != NULL);
- priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ priv = soup_cookie_jar_get_instance_private (jar);
cookies = g_hash_table_lookup (priv->domains, cookie->domain);
if (cookies == NULL)
@@ -814,7 +814,7 @@ soup_cookie_jar_get_accept_policy (SoupCookieJar *jar)
g_return_val_if_fail (SOUP_IS_COOKIE_JAR (jar), SOUP_COOKIE_JAR_ACCEPT_ALWAYS);
- priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ priv = soup_cookie_jar_get_instance_private (jar);
return priv->accept_policy;
}
@@ -835,7 +835,7 @@ soup_cookie_jar_set_accept_policy (SoupCookieJar *jar,
g_return_if_fail (SOUP_IS_COOKIE_JAR (jar));
- priv = SOUP_COOKIE_JAR_GET_PRIVATE (jar);
+ priv = soup_cookie_jar_get_instance_private (jar);
if (priv->accept_policy != policy) {
priv->accept_policy = policy;
diff --git a/libsoup/soup-filter-input-stream.c b/libsoup/soup-filter-input-stream.c
index 8067b88..cde4d12 100644
--- a/libsoup/soup-filter-input-stream.c
+++ b/libsoup/soup-filter-input-stream.c
@@ -29,15 +29,14 @@ struct _SoupFilterInputStreamPrivate {
static void soup_filter_input_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
gpointer interface_data);
G_DEFINE_TYPE_WITH_CODE (SoupFilterInputStream, soup_filter_input_stream, G_TYPE_FILTER_INPUT_STREAM,
+ G_ADD_PRIVATE (SoupFilterInputStream)
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
soup_filter_input_stream_pollable_init))
static void
soup_filter_input_stream_init (SoupFilterInputStream *stream)
{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- SOUP_TYPE_FILTER_INPUT_STREAM,
- SoupFilterInputStreamPrivate);
+ stream->priv = soup_filter_input_stream_get_instance_private (stream);
}
static void
@@ -149,8 +148,6 @@ soup_filter_input_stream_class_init (SoupFilterInputStreamClass *stream_class)
GObjectClass *object_class = G_OBJECT_CLASS (stream_class);
GInputStreamClass *input_stream_class = G_INPUT_STREAM_CLASS (stream_class);
- g_type_class_add_private (stream_class, sizeof (SoupFilterInputStreamPrivate));
-
object_class->finalize = soup_filter_input_stream_finalize;
input_stream_class->read_fn = soup_filter_input_stream_read_fn;
diff --git a/libsoup/soup-io-stream.c b/libsoup/soup-io-stream.c
index 62daaa0..9c77b26 100644
--- a/libsoup/soup-io-stream.c
+++ b/libsoup/soup-io-stream.c
@@ -29,14 +29,12 @@ enum {
PROP_CLOSE_ON_DISPOSE
};
-G_DEFINE_TYPE (SoupIOStream, soup_io_stream, G_TYPE_IO_STREAM)
+G_DEFINE_TYPE_WITH_PRIVATE (SoupIOStream, soup_io_stream, G_TYPE_IO_STREAM)
static void
soup_io_stream_init (SoupIOStream *stream)
{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- SOUP_TYPE_IO_STREAM,
- SoupIOStreamPrivate);
+ stream->priv = soup_io_stream_get_instance_private (stream);
}
static void
@@ -181,8 +179,6 @@ soup_io_stream_class_init (SoupIOStreamClass *stream_class)
GObjectClass *object_class = G_OBJECT_CLASS (stream_class);
GIOStreamClass *io_stream_class = G_IO_STREAM_CLASS (stream_class);
- g_type_class_add_private (stream_class, sizeof (SoupIOStreamPrivate));
-
object_class->set_property = soup_io_stream_set_property;
object_class->get_property = soup_io_stream_get_property;
object_class->dispose = soup_io_stream_dispose;
diff --git a/libsoup/soup-logger.c b/libsoup/soup-logger.c
index b7ce19e..0b3b145 100644
--- a/libsoup/soup-logger.c
+++ b/libsoup/soup-logger.c
@@ -88,13 +88,6 @@
* event of the #SoupMessage::finished signal.
**/
-static SoupSessionFeatureInterface *soup_logger_default_feature_interface;
-static void soup_logger_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer
interface_data);
-
-G_DEFINE_TYPE_WITH_CODE (SoupLogger, soup_logger, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
- soup_logger_session_feature_init))
-
typedef struct {
/* We use a mutex so that if requests are being run in
* multiple threads, we don't mix up the output.
@@ -120,7 +113,6 @@ typedef struct {
gpointer printer_data;
GDestroyNotify printer_dnotify;
} SoupLoggerPrivate;
-#define SOUP_LOGGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_LOGGER, SoupLoggerPrivate))
enum {
PROP_0,
@@ -131,10 +123,18 @@ enum {
LAST_PROP
};
+static SoupSessionFeatureInterface *soup_logger_default_feature_interface;
+static void soup_logger_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer
interface_data);
+
+G_DEFINE_TYPE_WITH_CODE (SoupLogger, soup_logger, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (SoupLogger)
+ G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
+ soup_logger_session_feature_init))
+
static void
soup_logger_init (SoupLogger *logger)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
g_mutex_init (&priv->lock);
priv->tag = g_quark_from_static_string (g_strdup_printf ("SoupLogger-%p", logger));
@@ -144,7 +144,8 @@ soup_logger_init (SoupLogger *logger)
static void
soup_logger_finalize (GObject *object)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (object);
+ SoupLogger *logger = SOUP_LOGGER (object);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
g_hash_table_destroy (priv->ids);
@@ -165,7 +166,7 @@ soup_logger_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
SoupLogger *logger = SOUP_LOGGER (object);
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
switch (prop_id) {
case PROP_LEVEL:
@@ -185,7 +186,7 @@ soup_logger_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SoupLogger *logger = SOUP_LOGGER (object);
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
switch (prop_id) {
case PROP_LEVEL:
@@ -205,8 +206,6 @@ soup_logger_class_init (SoupLoggerClass *logger_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (logger_class);
- g_type_class_add_private (logger_class, sizeof (SoupLoggerPrivate));
-
object_class->finalize = soup_logger_finalize;
object_class->set_property = soup_logger_set_property;
object_class->get_property = soup_logger_get_property;
@@ -334,7 +333,7 @@ soup_logger_set_request_filter (SoupLogger *logger,
gpointer filter_data,
GDestroyNotify destroy)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
priv->request_filter = request_filter;
priv->request_filter_data = filter_data;
@@ -360,7 +359,7 @@ soup_logger_set_response_filter (SoupLogger *logger,
gpointer filter_data,
GDestroyNotify destroy)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
priv->response_filter = response_filter;
priv->response_filter_data = filter_data;
@@ -406,7 +405,7 @@ soup_logger_set_printer (SoupLogger *logger,
gpointer printer_data,
GDestroyNotify destroy)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
priv->printer = printer;
priv->printer_data = printer_data;
@@ -416,7 +415,7 @@ soup_logger_set_printer (SoupLogger *logger,
static guint
soup_logger_get_id (SoupLogger *logger, gpointer object)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
return GPOINTER_TO_UINT (g_object_get_qdata (object, priv->tag));
}
@@ -424,7 +423,7 @@ soup_logger_get_id (SoupLogger *logger, gpointer object)
static guint
soup_logger_set_id (SoupLogger *logger, gpointer object)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
gpointer klass = G_OBJECT_GET_CLASS (object);
gpointer id;
@@ -480,7 +479,7 @@ static void
soup_logger_print (SoupLogger *logger, SoupLoggerLogLevel level,
char direction, const char *format, ...)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
va_list args;
char *data, *line, *end;
@@ -544,7 +543,7 @@ static void
print_request (SoupLogger *logger, SoupMessage *msg,
SoupSocket *socket, gboolean restarted)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
SoupLoggerLogLevel log_level;
SoupMessageHeadersIter iter;
const char *name, *value;
@@ -647,7 +646,7 @@ print_request (SoupLogger *logger, SoupMessage *msg,
static void
print_response (SoupLogger *logger, SoupMessage *msg)
{
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
SoupLoggerLogLevel log_level;
SoupMessageHeadersIter iter;
const char *name, *value;
@@ -695,7 +694,7 @@ static void
finished (SoupMessage *msg, gpointer user_data)
{
SoupLogger *logger = user_data;
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
g_mutex_lock (&priv->lock);
@@ -709,7 +708,7 @@ static void
got_informational (SoupMessage *msg, gpointer user_data)
{
SoupLogger *logger = user_data;
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
g_mutex_lock (&priv->lock);
@@ -744,7 +743,7 @@ static void
got_body (SoupMessage *msg, gpointer user_data)
{
SoupLogger *logger = user_data;
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
g_mutex_lock (&priv->lock);
@@ -759,7 +758,7 @@ static void
starting (SoupMessage *msg, gpointer user_data)
{
SoupLogger *logger = SOUP_LOGGER (user_data);
- SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (logger);
gboolean restarted;
guint msg_id;
SoupConnection *conn;
@@ -823,7 +822,9 @@ static void
soup_logger_feature_attach (SoupSessionFeature *feature,
SoupSession *session)
{
- SOUP_LOGGER_GET_PRIVATE (feature)->session = session;
+ SoupLoggerPrivate *priv = soup_logger_get_instance_private (SOUP_LOGGER (feature));
+
+ priv->session = session;
soup_logger_default_feature_interface->attach (feature, session);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]