[libsoup/wip/new-master: 9/22] Modernize GObject declarations
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/new-master: 9/22] Modernize GObject declarations
- Date: Sat, 19 Sep 2020 21:02:03 +0000 (UTC)
commit ded031298c43ddc36e3f8eacb2578517fe05c01b
Author: Patrick Griffis <pgriffis igalia com>
Date: Wed Mar 25 03:59:41 2020 -0700
Modernize GObject declarations
docs/reference/meson.build | 1 -
libsoup/auth/soup-auth-basic.c | 4 +
libsoup/auth/soup-auth-basic.h | 23 +-
libsoup/auth/soup-auth-digest-private.h | 41 ++
libsoup/auth/soup-auth-digest.c | 10 +-
libsoup/auth/soup-auth-digest.h | 60 +--
libsoup/auth/soup-auth-domain-basic.c | 4 +
libsoup/auth/soup-auth-domain-basic.h | 32 +-
libsoup/auth/soup-auth-domain-digest.c | 6 +-
libsoup/auth/soup-auth-domain-digest.h | 32 +-
libsoup/auth/soup-auth-domain.h | 32 +-
libsoup/auth/soup-auth-manager.c | 35 +-
libsoup/auth/soup-auth-manager.h | 30 +-
libsoup/auth/soup-auth-negotiate.c | 5 +
libsoup/auth/soup-auth-negotiate.h | 23 +-
libsoup/auth/soup-auth-ntlm.c | 4 +
libsoup/auth/soup-auth-ntlm.h | 25 +-
libsoup/auth/soup-auth.c | 28 +-
libsoup/auth/soup-auth.h | 46 +--
libsoup/auth/soup-connection-auth.c | 23 +-
libsoup/auth/soup-connection-auth.h | 28 +-
libsoup/cache/soup-cache-private.h | 5 +-
libsoup/cache/soup-cache.c | 120 +++---
libsoup/cache/soup-cache.h | 36 +-
libsoup/content-sniffer/soup-content-decoder.c | 28 +-
libsoup/content-sniffer/soup-content-decoder.h | 32 +-
libsoup/content-sniffer/soup-content-processor.c | 4 +-
libsoup/content-sniffer/soup-content-processor.h | 17 +-
.../content-sniffer/soup-content-sniffer-stream.c | 112 ++---
.../content-sniffer/soup-content-sniffer-stream.h | 31 +-
libsoup/content-sniffer/soup-content-sniffer.h | 35 +-
libsoup/content-sniffer/soup-converter-wrapper.c | 28 +-
libsoup/content-sniffer/soup-converter-wrapper.h | 33 +-
libsoup/cookies/soup-cookie-jar-db.c | 5 +
libsoup/cookies/soup-cookie-jar-db.h | 32 +-
libsoup/cookies/soup-cookie-jar-text.c | 6 +
libsoup/cookies/soup-cookie-jar-text.h | 31 +-
libsoup/cookies/soup-cookie-jar.h | 26 +-
libsoup/cookies/soup-cookie.h | 7 +-
libsoup/hsts/soup-hsts-enforcer-db.c | 21 +-
libsoup/hsts/soup-hsts-enforcer-db.h | 36 +-
libsoup/hsts/soup-hsts-enforcer.c | 59 +--
libsoup/hsts/soup-hsts-enforcer.h | 34 +-
libsoup/hsts/soup-hsts-policy.h | 7 +-
libsoup/include/soup-installed.h | 6 +-
libsoup/meson.build | 4 +-
libsoup/soup-autocleanups.h | 65 ---
libsoup/soup-date.h | 7 +-
libsoup/soup-logger.c | 6 +
libsoup/soup-logger.h | 31 +-
libsoup/soup-message-body.h | 8 +-
libsoup/soup-message-headers.h | 7 +-
libsoup/soup-message-io.c | 6 +-
libsoup/soup-method.h | 5 +-
libsoup/soup-multipart-input-stream.c | 53 +--
libsoup/soup-multipart-input-stream.h | 30 +-
libsoup/soup-multipart.h | 7 +-
libsoup/soup-request-data.c | 28 +-
libsoup/soup-request-data.h | 27 +-
libsoup/soup-request-file.c | 65 +--
libsoup/soup-request-file.h | 27 +-
libsoup/soup-request-http.c | 45 ++-
libsoup/soup-request-http.h | 27 +-
libsoup/soup-request.c | 43 +-
libsoup/soup-request.h | 26 +-
libsoup/soup-server.h | 32 +-
libsoup/soup-session-feature.c | 22 +-
libsoup/soup-session-feature.h | 21 +-
libsoup/soup-session.c | 9 +-
libsoup/soup-session.h | 39 +-
libsoup/soup-status.h | 5 +-
libsoup/soup-tld.h | 5 +-
libsoup/soup-uri.h | 7 +-
libsoup/soup-version.h.in | 5 +-
libsoup/soup.h | 6 +-
libsoup/websocket/soup-websocket-connection.c | 450 +++++++++++----------
libsoup/websocket/soup-websocket-connection.h | 30 +-
.../websocket/soup-websocket-extension-deflate.c | 4 +
.../websocket/soup-websocket-extension-deflate.h | 26 +-
.../websocket/soup-websocket-extension-manager.c | 4 +
.../websocket/soup-websocket-extension-manager.h | 23 +-
libsoup/websocket/soup-websocket-extension.h | 31 +-
libsoup/websocket/soup-websocket.h | 5 +-
libsoup/xmlrpc/soup-xmlrpc.h | 7 +-
84 files changed, 955 insertions(+), 1536 deletions(-)
---
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index 89413822..724a8d92 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -1,6 +1,5 @@
ignore_headers = [
'soup.h',
- 'soup-autocleanups.h',
'soup-enum-types.h',
'soup-message-private.h',
'soup-session-private.h',
diff --git a/libsoup/auth/soup-auth-basic.c b/libsoup/auth/soup-auth-basic.c
index 5f1e7186..db13124c 100644
--- a/libsoup/auth/soup-auth-basic.c
+++ b/libsoup/auth/soup-auth-basic.c
@@ -14,6 +14,10 @@
#include "soup-auth-basic.h"
#include "soup.h"
+struct _SoupAuthBasic {
+ SoupAuth parent;
+};
+
typedef struct {
char *token;
} SoupAuthBasicPrivate;
diff --git a/libsoup/auth/soup-auth-basic.h b/libsoup/auth/soup-auth-basic.h
index b7936871..947c4b92 100644
--- a/libsoup/auth/soup-auth-basic.h
+++ b/libsoup/auth/soup-auth-basic.h
@@ -3,25 +3,14 @@
* Copyright (C) 2000-2003, Ximian, Inc.
*/
-#ifndef __SOUP_AUTH_BASIC_H__
-#define __SOUP_AUTH_BASIC_H__ 1
+#pragma once
#include "soup-auth.h"
-#define SOUP_AUTH_BASIC(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SOUP_TYPE_AUTH_BASIC,
SoupAuthBasic))
-#define SOUP_AUTH_BASIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_AUTH_BASIC,
SoupAuthBasicClass))
-#define SOUP_IS_AUTH_BASIC(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SOUP_TYPE_AUTH_BASIC))
-#define SOUP_IS_AUTH_BASIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_AUTH_BASIC))
-#define SOUP_AUTH_BASIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH_BASIC,
SoupAuthBasicClass))
+G_BEGIN_DECLS
-typedef struct {
- SoupAuth parent;
+#define SOUP_TYPE_AUTH_BASIC (soup_auth_basic_get_type ())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_FINAL_TYPE (SoupAuthBasic, soup_auth_basic, SOUP, AUTH_BASIC, SoupAuth)
-} SoupAuthBasic;
-
-typedef struct {
- SoupAuthClass parent_class;
-
-} SoupAuthBasicClass;
-
-#endif /* __SOUP_AUTH_BASIC_H__ */
+G_END_DECLS
diff --git a/libsoup/auth/soup-auth-digest-private.h b/libsoup/auth/soup-auth-digest-private.h
new file mode 100644
index 00000000..bb251ad0
--- /dev/null
+++ b/libsoup/auth/soup-auth-digest-private.h
@@ -0,0 +1,41 @@
+
+#pragma once
+
+#include "auth/soup-auth-digest.h"
+
+/* Utility routines (also used by SoupAuthDomainDigest) */
+
+typedef enum {
+ SOUP_AUTH_DIGEST_ALGORITHM_NONE,
+ SOUP_AUTH_DIGEST_ALGORITHM_MD5,
+ SOUP_AUTH_DIGEST_ALGORITHM_MD5_SESS
+} SoupAuthDigestAlgorithm;
+
+typedef enum {
+ SOUP_AUTH_DIGEST_QOP_AUTH = 1 << 0,
+ SOUP_AUTH_DIGEST_QOP_AUTH_INT = 1 << 1
+} SoupAuthDigestQop;
+
+SoupAuthDigestAlgorithm soup_auth_digest_parse_algorithm (const char *algorithm);
+char *soup_auth_digest_get_algorithm (SoupAuthDigestAlgorithm algorithm);
+
+SoupAuthDigestQop soup_auth_digest_parse_qop (const char *qop);
+char *soup_auth_digest_get_qop (SoupAuthDigestQop qop);
+
+void soup_auth_digest_compute_hex_urp (const char *username,
+ const char *realm,
+ const char *password,
+ char hex_urp[33]);
+void soup_auth_digest_compute_hex_a1 (const char *hex_urp,
+ SoupAuthDigestAlgorithm algorithm,
+ const char *nonce,
+ const char *cnonce,
+ char hex_a1[33]);
+void soup_auth_digest_compute_response (const char *method,
+ const char *uri,
+ const char *hex_a1,
+ SoupAuthDigestQop qop,
+ const char *nonce,
+ const char *cnonce,
+ int nc,
+ char response[33]);
diff --git a/libsoup/auth/soup-auth-digest.c b/libsoup/auth/soup-auth-digest.c
index e8ba9903..06439ea3 100644
--- a/libsoup/auth/soup-auth-digest.c
+++ b/libsoup/auth/soup-auth-digest.c
@@ -11,7 +11,7 @@
#include <string.h>
-#include "soup-auth-digest.h"
+#include "auth/soup-auth-digest-private.h"
#include "soup.h"
#include "soup-message-private.h"
@@ -19,6 +19,10 @@
#include <process.h>
#endif
+struct _SoupAuthDigest {
+ SoupAuth parent;
+};
+
typedef struct {
char *user;
char hex_urp[33];
@@ -309,7 +313,7 @@ soup_auth_digest_authenticate (SoupAuth *auth, const char *username,
priv->user = g_strdup (username);
/* compute "URP" (user:realm:password) */
- soup_auth_digest_compute_hex_urp (username, auth->realm,
+ soup_auth_digest_compute_hex_urp (username, soup_auth_get_realm (auth),
password ? password : "",
priv->hex_urp);
@@ -428,7 +432,7 @@ soup_auth_digest_get_authorization (SoupAuth *auth, SoupMessage *msg)
soup_header_g_string_append_param_quoted (out, "username", priv->user);
g_string_append (out, ", ");
- soup_header_g_string_append_param_quoted (out, "realm", auth->realm);
+ soup_header_g_string_append_param_quoted (out, "realm", soup_auth_get_realm (auth));
g_string_append (out, ", ");
soup_header_g_string_append_param_quoted (out, "nonce", priv->nonce);
g_string_append (out, ", ");
diff --git a/libsoup/auth/soup-auth-digest.h b/libsoup/auth/soup-auth-digest.h
index 59fd748e..d6673de0 100644
--- a/libsoup/auth/soup-auth-digest.h
+++ b/libsoup/auth/soup-auth-digest.h
@@ -3,62 +3,10 @@
* Copyright (C) 2000-2003, Ximian, Inc.
*/
-#ifndef __SOUP_AUTH_DIGEST_H__
-#define __SOUP_AUTH_DIGEST_H__ 1
+#pragma once
#include "soup-auth.h"
-#define SOUP_AUTH_DIGEST(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SOUP_TYPE_AUTH_DIGEST,
SoupAuthDigest))
-#define SOUP_AUTH_DIGEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_AUTH_DIGEST,
SoupAuthDigestClass))
-#define SOUP_IS_AUTH_DIGEST(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SOUP_TYPE_AUTH_DIGEST))
-#define SOUP_IS_AUTH_DIGEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_AUTH_DIGEST))
-#define SOUP_AUTH_DIGEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH_DIGEST,
SoupAuthDigestClass))
-
-typedef struct {
- SoupAuth parent;
-
-} SoupAuthDigest;
-
-typedef struct {
- SoupAuthClass parent_class;
-
-} SoupAuthDigestClass;
-
-/* Utility routines (also used by SoupAuthDomainDigest) */
-
-typedef enum {
- SOUP_AUTH_DIGEST_ALGORITHM_NONE,
- SOUP_AUTH_DIGEST_ALGORITHM_MD5,
- SOUP_AUTH_DIGEST_ALGORITHM_MD5_SESS
-} SoupAuthDigestAlgorithm;
-
-typedef enum {
- SOUP_AUTH_DIGEST_QOP_AUTH = 1 << 0,
- SOUP_AUTH_DIGEST_QOP_AUTH_INT = 1 << 1
-} SoupAuthDigestQop;
-
-SoupAuthDigestAlgorithm soup_auth_digest_parse_algorithm (const char *algorithm);
-char *soup_auth_digest_get_algorithm (SoupAuthDigestAlgorithm algorithm);
-
-SoupAuthDigestQop soup_auth_digest_parse_qop (const char *qop);
-char *soup_auth_digest_get_qop (SoupAuthDigestQop qop);
-
-void soup_auth_digest_compute_hex_urp (const char *username,
- const char *realm,
- const char *password,
- char hex_urp[33]);
-void soup_auth_digest_compute_hex_a1 (const char *hex_urp,
- SoupAuthDigestAlgorithm algorithm,
- const char *nonce,
- const char *cnonce,
- char hex_a1[33]);
-void soup_auth_digest_compute_response (const char *method,
- const char *uri,
- const char *hex_a1,
- SoupAuthDigestQop qop,
- const char *nonce,
- const char *cnonce,
- int nc,
- char response[33]);
-
-#endif /* __SOUP_AUTH_DIGEST_H__ */
+#define SOUP_TYPE_AUTH_DIGEST (soup_auth_digest_get_type ())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_FINAL_TYPE (SoupAuthDigest, soup_auth_digest, SOUP, AUTH_DIGEST, SoupAuth)
diff --git a/libsoup/auth/soup-auth-domain-basic.c b/libsoup/auth/soup-auth-domain-basic.c
index e15f37f3..9a850050 100644
--- a/libsoup/auth/soup-auth-domain-basic.c
+++ b/libsoup/auth/soup-auth-domain-basic.c
@@ -31,6 +31,10 @@ enum {
LAST_PROP
};
+struct _SoupAuthDomainBasic {
+ SoupAuthDomain parent;
+};
+
typedef struct {
SoupAuthDomainBasicAuthCallback auth_callback;
gpointer auth_data;
diff --git a/libsoup/auth/soup-auth-domain-basic.h b/libsoup/auth/soup-auth-domain-basic.h
index 79ee6163..a260e891 100644
--- a/libsoup/auth/soup-auth-domain-basic.h
+++ b/libsoup/auth/soup-auth-domain-basic.h
@@ -3,41 +3,19 @@
* Copyright (C) 2007 Novell, Inc.
*/
-#ifndef __SOUP_AUTH_DOMAIN_BASIC_H__
-#define __SOUP_AUTH_DOMAIN_BASIC_H__ 1
+#pragma once
#include "soup-auth-domain.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_AUTH_DOMAIN_BASIC (soup_auth_domain_basic_get_type ())
-#define SOUP_AUTH_DOMAIN_BASIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SOUP_TYPE_AUTH_DOMAIN_BASIC, SoupAuthDomainBasic))
-#define SOUP_AUTH_DOMAIN_BASIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
SOUP_TYPE_AUTH_DOMAIN_BASIC, SoupAuthDomainBasicClass))
-#define SOUP_IS_AUTH_DOMAIN_BASIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
SOUP_TYPE_AUTH_DOMAIN_BASIC))
-#define SOUP_IS_AUTH_DOMAIN_BASIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_AUTH_DOMAIN_BASIC))
-#define SOUP_AUTH_DOMAIN_BASIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
SOUP_TYPE_AUTH_DOMAIN_BASIC, SoupAuthDomainBasicClass))
-
-typedef struct {
- SoupAuthDomain parent;
-
-} SoupAuthDomainBasic;
-
-typedef struct {
- SoupAuthDomainClass parent_class;
-
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupAuthDomainBasicClass;
+#define SOUP_TYPE_AUTH_DOMAIN_BASIC (soup_auth_domain_basic_get_type ())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_FINAL_TYPE (SoupAuthDomainBasic, soup_auth_domain_basic, SOUP, AUTH_DOMAIN_BASIC, SoupAuthDomain)
#define SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK "auth-callback"
#define SOUP_AUTH_DOMAIN_BASIC_AUTH_DATA "auth-data"
-SOUP_AVAILABLE_IN_2_4
-GType soup_auth_domain_basic_get_type (void);
-
SOUP_AVAILABLE_IN_2_4
SoupAuthDomain *soup_auth_domain_basic_new (const char *optname1,
...) G_GNUC_NULL_TERMINATED;
@@ -55,5 +33,3 @@ void soup_auth_domain_basic_set_auth_callback (SoupAuthDomain *domain,
GDestroyNotify dnotify);
G_END_DECLS
-
-#endif /* __SOUP_AUTH_DOMAIN_BASIC_H__ */
diff --git a/libsoup/auth/soup-auth-domain-digest.c b/libsoup/auth/soup-auth-domain-digest.c
index b69b5829..ae9fa266 100644
--- a/libsoup/auth/soup-auth-domain-digest.c
+++ b/libsoup/auth/soup-auth-domain-digest.c
@@ -14,7 +14,7 @@
#include "soup-auth-domain-digest.h"
#include "soup.h"
-#include "soup-auth-digest.h"
+#include "auth/soup-auth-digest-private.h"
/**
* SECTION:soup-auth-domain-digest
@@ -33,6 +33,10 @@ enum {
LAST_PROP
};
+struct _SoupAuthDomainDigest {
+ SoupAuthDomain parent;
+};
+
typedef struct {
SoupAuthDomainDigestAuthCallback auth_callback;
gpointer auth_data;
diff --git a/libsoup/auth/soup-auth-domain-digest.h b/libsoup/auth/soup-auth-domain-digest.h
index 5fbe6c94..523497ce 100644
--- a/libsoup/auth/soup-auth-domain-digest.h
+++ b/libsoup/auth/soup-auth-domain-digest.h
@@ -3,41 +3,19 @@
* Copyright (C) 2007 Novell, Inc.
*/
-#ifndef __SOUP_AUTH_DOMAIN_DIGEST_H__
-#define __SOUP_AUTH_DOMAIN_DIGEST_H__ 1
+#pragma once
#include "soup-auth-domain.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_AUTH_DOMAIN_DIGEST (soup_auth_domain_digest_get_type ())
-#define SOUP_AUTH_DOMAIN_DIGEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SOUP_TYPE_AUTH_DOMAIN_DIGEST, SoupAuthDomainDigest))
-#define SOUP_AUTH_DOMAIN_DIGEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
SOUP_TYPE_AUTH_DOMAIN_DIGEST, SoupAuthDomainDigestClass))
-#define SOUP_IS_AUTH_DOMAIN_DIGEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
SOUP_TYPE_AUTH_DOMAIN_DIGEST))
-#define SOUP_IS_AUTH_DOMAIN_DIGEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj),
SOUP_TYPE_AUTH_DOMAIN_DIGEST))
-#define SOUP_AUTH_DOMAIN_DIGEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
SOUP_TYPE_AUTH_DOMAIN_DIGEST, SoupAuthDomainDigestClass))
-
-typedef struct {
- SoupAuthDomain parent;
-
-} SoupAuthDomainDigest;
-
-typedef struct {
- SoupAuthDomainClass parent_class;
-
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupAuthDomainDigestClass;
+#define SOUP_TYPE_AUTH_DOMAIN_DIGEST (soup_auth_domain_digest_get_type ())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_FINAL_TYPE (SoupAuthDomainDigest, soup_auth_domain_digest, SOUP, AUTH_DOMAIN_DIGEST,
SoupAuthDomain)
#define SOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK "auth-callback"
#define SOUP_AUTH_DOMAIN_DIGEST_AUTH_DATA "auth-data"
-SOUP_AVAILABLE_IN_2_4
-GType soup_auth_domain_digest_get_type (void);
-
SOUP_AVAILABLE_IN_2_4
SoupAuthDomain *soup_auth_domain_digest_new (const char *optname1,
...) G_GNUC_NULL_TERMINATED;
@@ -59,5 +37,3 @@ char *soup_auth_domain_digest_encode_password (const char *username,
const char *password);
G_END_DECLS
-
-#endif /* __SOUP_AUTH_DOMAIN_DIGEST_H__ */
diff --git a/libsoup/auth/soup-auth-domain.h b/libsoup/auth/soup-auth-domain.h
index 0fdbbb29..397dc53b 100644
--- a/libsoup/auth/soup-auth-domain.h
+++ b/libsoup/auth/soup-auth-domain.h
@@ -3,26 +3,17 @@
* Copyright (C) 2007 Novell, Inc.
*/
-#ifndef __SOUP_AUTH_DOMAIN_H__
-#define __SOUP_AUTH_DOMAIN_H__ 1
+#pragma once
#include "soup-types.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_AUTH_DOMAIN (soup_auth_domain_get_type ())
-#define SOUP_AUTH_DOMAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_AUTH_DOMAIN,
SoupAuthDomain))
-#define SOUP_AUTH_DOMAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_AUTH_DOMAIN,
SoupAuthDomainClass))
-#define SOUP_IS_AUTH_DOMAIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_AUTH_DOMAIN))
-#define SOUP_IS_AUTH_DOMAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_AUTH_DOMAIN))
-#define SOUP_AUTH_DOMAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH_DOMAIN,
SoupAuthDomainClass))
-
-struct _SoupAuthDomain {
- GObject parent;
-
-};
+#define SOUP_TYPE_AUTH_DOMAIN (soup_auth_domain_get_type ())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_DERIVABLE_TYPE (SoupAuthDomain, soup_auth_domain, SOUP, AUTH_DOMAIN, GObject)
-typedef struct {
+struct _SoupAuthDomainClass {
GObjectClass parent_class;
char * (*accepts) (SoupAuthDomain *domain,
@@ -34,12 +25,8 @@ typedef struct {
SoupMessage *msg,
const char *username,
const char *password);
-
- /* Padding for future expansion */
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupAuthDomainClass;
+ gpointer padding[6];
+};
#define SOUP_AUTH_DOMAIN_REALM "realm"
#define SOUP_AUTH_DOMAIN_PROXY "proxy"
@@ -59,9 +46,6 @@ typedef gboolean (*SoupAuthDomainGenericAuthCallback) (SoupAuthDomain *domain,
const char *username,
gpointer user_data);
-SOUP_AVAILABLE_IN_2_4
-GType soup_auth_domain_get_type (void);
-
SOUP_AVAILABLE_IN_2_4
void soup_auth_domain_add_path (SoupAuthDomain *domain,
const char *path);
@@ -106,5 +90,3 @@ gboolean soup_auth_domain_try_generic_auth_callback (SoupAuthDomain *domain,
const char *username);
G_END_DECLS
-
-#endif /* __SOUP_AUTH_DOMAIN_H__ */
diff --git a/libsoup/auth/soup-auth-manager.c b/libsoup/auth/soup-auth-manager.c
index 3b9e2b6b..225b85d9 100644
--- a/libsoup/auth/soup-auth-manager.c
+++ b/libsoup/auth/soup-auth-manager.c
@@ -61,7 +61,7 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-struct SoupAuthManagerPrivate {
+typedef struct {
SoupSession *session;
GPtrArray *auth_types;
gboolean auto_ntlm;
@@ -69,7 +69,7 @@ struct SoupAuthManagerPrivate {
GMutex lock;
SoupAuth *proxy_auth;
GHashTable *auth_hosts;
-};
+} SoupAuthManagerPrivate;
typedef struct {
SoupURI *uri;
@@ -90,9 +90,7 @@ static SoupAuth *record_auth_for_uri (SoupAuthManagerPrivate *priv,
static void
soup_auth_manager_init (SoupAuthManager *manager)
{
- SoupAuthManagerPrivate *priv;
-
- priv = manager->priv = soup_auth_manager_get_instance_private (manager);
+ SoupAuthManagerPrivate *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,
@@ -105,7 +103,7 @@ soup_auth_manager_init (SoupAuthManager *manager)
static void
soup_auth_manager_finalize (GObject *object)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (object)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private ((SoupAuthManager*)object);
g_ptr_array_free (priv->auth_types, TRUE);
@@ -165,7 +163,7 @@ auth_type_compare_func (gconstpointer a, gconstpointer b)
static gboolean
soup_auth_manager_add_feature (SoupSessionFeature *feature, GType type)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (feature)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private ((SoupAuthManager*)feature);
SoupAuthClass *auth_class;
if (!g_type_is_a (type, SOUP_TYPE_AUTH))
@@ -188,7 +186,7 @@ soup_auth_manager_add_feature (SoupSessionFeature *feature, GType type)
static gboolean
soup_auth_manager_remove_feature (SoupSessionFeature *feature, GType type)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (feature)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private ((SoupAuthManager*)feature);
SoupAuthClass *auth_class;
guint i;
@@ -213,7 +211,7 @@ soup_auth_manager_remove_feature (SoupSessionFeature *feature, GType type)
static gboolean
soup_auth_manager_has_feature (SoupSessionFeature *feature, GType type)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (feature)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private ((SoupAuthManager*)feature);
SoupAuthClass *auth_class;
guint i;
@@ -231,7 +229,7 @@ soup_auth_manager_has_feature (SoupSessionFeature *feature, GType type)
static void
soup_auth_manager_attach (SoupSessionFeature *feature, SoupSession *session)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (feature)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private ((SoupAuthManager*)feature);
/* FIXME: should support multiple sessions */
priv->session = session;
@@ -518,7 +516,7 @@ authenticate_auth (SoupAuthManager *manager, SoupAuth *auth,
SoupMessage *msg, gboolean prior_auth_failed,
gboolean proxy, gboolean can_interact)
{
- SoupAuthManagerPrivate *priv = manager->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private (manager);
SoupURI *uri;
if (!soup_auth_can_authenticate (auth))
@@ -607,7 +605,7 @@ record_auth_for_uri (SoupAuthManagerPrivate *priv, SoupURI *uri,
static void
auth_got_headers (SoupMessage *msg, gpointer manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (manager)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private (manager);
SoupAuth *auth, *prior_auth;
gboolean prior_auth_failed = FALSE;
@@ -647,7 +645,7 @@ auth_got_headers (SoupMessage *msg, gpointer manager)
static void
auth_got_body (SoupMessage *msg, gpointer manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (manager)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private (manager);
SoupAuth *auth;
g_mutex_lock (&priv->lock);
@@ -674,7 +672,7 @@ auth_got_body (SoupMessage *msg, gpointer manager)
static void
proxy_auth_got_headers (SoupMessage *msg, gpointer manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (manager)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private (manager);
SoupAuth *auth = NULL, *prior_auth;
gboolean prior_auth_failed = FALSE;
@@ -711,7 +709,7 @@ proxy_auth_got_headers (SoupMessage *msg, gpointer manager)
static void
proxy_auth_got_body (SoupMessage *msg, gpointer manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (manager)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private (manager);
SoupAuth *auth;
g_mutex_lock (&priv->lock);
@@ -732,7 +730,7 @@ proxy_auth_got_body (SoupMessage *msg, gpointer manager)
static void
auth_msg_starting (SoupMessage *msg, gpointer manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (manager)->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private (manager);
SoupAuth *auth;
if (soup_message_get_flags (msg) & SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE)
@@ -818,7 +816,7 @@ soup_auth_manager_use_auth (SoupAuthManager *manager,
SoupURI *uri,
SoupAuth *auth)
{
- SoupAuthManagerPrivate *priv = manager->priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private (manager);
g_mutex_lock (&priv->lock);
record_auth_for_uri (priv, uri, auth, FALSE);
@@ -836,11 +834,10 @@ soup_auth_manager_use_auth (SoupAuthManager *manager,
void
soup_auth_manager_clear_cached_credentials (SoupAuthManager *manager)
{
- SoupAuthManagerPrivate *priv;
+ SoupAuthManagerPrivate *priv = soup_auth_manager_get_instance_private (manager);
g_return_if_fail (SOUP_IS_AUTH_MANAGER (manager));
- priv = manager->priv;
g_mutex_lock (&priv->lock);
g_hash_table_remove_all (priv->auth_hosts);
g_mutex_unlock (&priv->lock);
diff --git a/libsoup/auth/soup-auth-manager.h b/libsoup/auth/soup-auth-manager.h
index cf38936a..c17c921c 100644
--- a/libsoup/auth/soup-auth-manager.h
+++ b/libsoup/auth/soup-auth-manager.h
@@ -3,38 +3,24 @@
* Copyright (C) 2007 Red Hat, Inc.
*/
-#ifndef __SOUP_AUTH_MANAGER_H__
-#define __SOUP_AUTH_MANAGER_H__ 1
+#pragma once
#include "soup-types.h"
#include "soup-auth.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_AUTH_MANAGER (soup_auth_manager_get_type ())
-#define SOUP_AUTH_MANAGER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SOUP_TYPE_AUTH_MANAGER,
SoupAuthManager))
-#define SOUP_AUTH_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_AUTH_MANAGER,
SoupAuthManagerClass))
-#define SOUP_IS_AUTH_MANAGER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SOUP_TYPE_AUTH_MANAGER))
-#define SOUP_IS_AUTH_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_AUTH_MANAGER))
-#define SOUP_AUTH_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH_MANAGER,
SoupAuthManagerClass))
-
-typedef struct SoupAuthManagerPrivate SoupAuthManagerPrivate;
-
-typedef struct {
- GObject parent;
-
- SoupAuthManagerPrivate *priv;
-} SoupAuthManager;
+#define SOUP_TYPE_AUTH_MANAGER (soup_auth_manager_get_type ())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_DERIVABLE_TYPE (SoupAuthManager, soup_auth_manager, SOUP, AUTH_MANAGER, GObject)
-typedef struct {
+struct _SoupAuthManagerClass {
GObjectClass parent_class;
void (*authenticate) (SoupAuthManager *manager, SoupMessage *msg,
SoupAuth *auth, gboolean retrying);
-} SoupAuthManagerClass;
-
-SOUP_AVAILABLE_IN_2_4
-GType soup_auth_manager_get_type (void);
+ gpointer padding[4];
+};
SOUP_AVAILABLE_IN_2_4
void soup_auth_manager_use_auth (SoupAuthManager *manager,
@@ -45,5 +31,3 @@ SOUP_AVAILABLE_IN_2_58
void soup_auth_manager_clear_cached_credentials (SoupAuthManager *manager);
G_END_DECLS
-
-#endif /* __SOUP_AUTH_MANAGER_H__ */
diff --git a/libsoup/auth/soup-auth-negotiate.c b/libsoup/auth/soup-auth-negotiate.c
index 1ceac3b0..de4a778d 100644
--- a/libsoup/auth/soup-auth-negotiate.c
+++ b/libsoup/auth/soup-auth-negotiate.c
@@ -66,6 +66,11 @@ typedef struct {
SoupNegotiateState state;
} SoupNegotiateConnectionState;
+
+struct _SoupAuthNegotiate {
+ SoupConnectionAuth parent;
+};
+
typedef struct {
gboolean is_authenticated;
} SoupAuthNegotiatePrivate;
diff --git a/libsoup/auth/soup-auth-negotiate.h b/libsoup/auth/soup-auth-negotiate.h
index 5c3916bf..ffcda002 100644
--- a/libsoup/auth/soup-auth-negotiate.h
+++ b/libsoup/auth/soup-auth-negotiate.h
@@ -4,25 +4,14 @@
* Copyright (C) 2016 Red Hat, Inc.
*/
-#ifndef __SOUP_AUTH_NEGOTIATE_H__
-#define __SOUP_AUTH_NEGOTIATE_H__ 1
+#pragma once
#include "soup-connection-auth.h"
-#define SOUP_AUTH_NEGOTIATE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SOUP_TYPE_AUTH_NEGOTIATE,
SoupAuthNegotiate))
-#define SOUP_AUTH_NEGOTIATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_AUTH_NEGOTIATE,
SoupAuthNegotiateClass))
-#define SOUP_IS_AUTH_NEGOTIATE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SOUP_TYPE_AUTH_NEGOTIATE))
-#define SOUP_IS_AUTH_NEGOTIATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_AUTH_NEGOTIATE))
-#define SOUP_AUTH_NEGOTIATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH_NEGOTIATE,
SoupAuthNegotiateClass))
+G_BEGIN_DECLS
-typedef struct {
- SoupConnectionAuth parent;
+#define SOUP_TYPE_AUTH_NEGOTIATE (soup_auth_negotiate_get_type())
+SOUP_AVAILABLE_IN_2_54
+G_DECLARE_FINAL_TYPE (SoupAuthNegotiate, soup_auth_negotiate, SOUP, AUTH_NEGOTIATE, SoupConnectionAuth)
-} SoupAuthNegotiate;
-
-typedef struct {
- SoupConnectionAuthClass parent_class;
-
-} SoupAuthNegotiateClass;
-
-#endif /* __SOUP_AUTH_NEGOTIATE_H__ */
+G_END_DECLS
diff --git a/libsoup/auth/soup-auth-ntlm.c b/libsoup/auth/soup-auth-ntlm.c
index 2d078461..7a9b7ac3 100644
--- a/libsoup/auth/soup-auth-ntlm.c
+++ b/libsoup/auth/soup-auth-ntlm.c
@@ -69,6 +69,10 @@ typedef enum {
SOUP_NTLM_PASSWORD_REJECTED
} SoupNTLMPasswordState;
+struct _SoupAuthNTLM {
+ SoupConnectionAuth parent;
+};
+
typedef struct {
char *username, *domain;
guchar nt_hash[21], lm_hash[21];
diff --git a/libsoup/auth/soup-auth-ntlm.h b/libsoup/auth/soup-auth-ntlm.h
index ef07353b..1c022686 100644
--- a/libsoup/auth/soup-auth-ntlm.h
+++ b/libsoup/auth/soup-auth-ntlm.h
@@ -1,27 +1,16 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-ntlm-offset: 8 -*- */
/*
* Copyright (C) 2007 Red Hat, Inc.
*/
-#ifndef __SOUP_AUTH_NTLM_H__
-#define __SOUP_AUTH_NTLM_H__ 1
+#pragma once
#include "soup-connection-auth.h"
-#define SOUP_AUTH_NTLM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SOUP_TYPE_AUTH_NTLM,
SoupAuthNTLM))
-#define SOUP_AUTH_NTLM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_AUTH_NTLM,
SoupAuthNTLMClass))
-#define SOUP_IS_AUTH_NTLM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SOUP_TYPE_AUTH_NTLM))
-#define SOUP_IS_AUTH_NTLM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_AUTH_NTLM))
-#define SOUP_AUTH_NTLM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH_NTLM,
SoupAuthNTLMClass))
+G_BEGIN_DECLS
-typedef struct {
- SoupConnectionAuth parent;
+#define SOUP_TYPE_AUTH_NTLM (soup_auth_ntlm_get_type ())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_FINAL_TYPE (SoupAuthNTLM, soup_auth_ntlm, SOUP, AUTH_NTLM, SoupConnectionAuth)
-} SoupAuthNTLM;
-
-typedef struct {
- SoupConnectionAuthClass parent_class;
-
-} SoupAuthNTLMClass;
-
-#endif /* __SOUP_AUTH_NTLM_H__ */
+G_END_DECLS
diff --git a/libsoup/auth/soup-auth.c b/libsoup/auth/soup-auth.c
index 2ba75e23..7e5a5f70 100644
--- a/libsoup/auth/soup-auth.c
+++ b/libsoup/auth/soup-auth.c
@@ -35,8 +35,9 @@
**/
typedef struct {
- gboolean proxy;
+ char *realm;
char *host;
+ gboolean proxy;
} SoupAuthPrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SoupAuth, soup_auth, G_TYPE_OBJECT)
@@ -64,7 +65,7 @@ soup_auth_finalize (GObject *object)
SoupAuth *auth = SOUP_AUTH (object);
SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
- g_free (auth->realm);
+ g_free (priv->realm);
g_free (priv->host);
G_OBJECT_CLASS (soup_auth_parent_class)->finalize (object);
@@ -79,8 +80,8 @@ soup_auth_set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_REALM:
- g_free (auth->realm);
- auth->realm = g_value_dup_string (value);
+ g_free (priv->realm);
+ priv->realm = g_value_dup_string (value);
break;
case PROP_HOST:
g_free (priv->host);
@@ -234,7 +235,7 @@ soup_auth_new (GType type, SoupMessage *msg, const char *auth_header)
{
SoupAuth *auth;
GHashTable *params;
- const char *scheme, *realm;
+ const char *scheme;
g_return_val_if_fail (g_type_is_a (type, SOUP_TYPE_AUTH), NULL);
g_return_val_if_fail (SOUP_IS_MESSAGE (msg), NULL);
@@ -245,6 +246,8 @@ soup_auth_new (GType type, SoupMessage *msg, const char *auth_header)
SOUP_AUTH_HOST, soup_message_get_uri (msg)->host,
NULL);
+ SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
+
scheme = soup_auth_get_scheme_name (auth);
if (g_ascii_strncasecmp (auth_header, scheme, strlen (scheme)) != 0) {
g_object_unref (auth);
@@ -255,9 +258,7 @@ soup_auth_new (GType type, SoupMessage *msg, const char *auth_header)
if (!params)
params = g_hash_table_new (NULL, NULL);
- realm = g_hash_table_lookup (params, "realm");
- if (realm)
- auth->realm = g_strdup (realm);
+ priv->realm = g_strdup (g_hash_table_lookup (params, "realm"));
if (!SOUP_AUTH_GET_CLASS (auth)->update (auth, msg, params)) {
g_object_unref (auth);
@@ -287,6 +288,7 @@ soup_auth_update (SoupAuth *auth, SoupMessage *msg, const char *auth_header)
GHashTable *params;
const char *scheme, *realm;
gboolean was_authenticated, success;
+ SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
g_return_val_if_fail (SOUP_IS_AUTH (auth), FALSE);
g_return_val_if_fail (SOUP_IS_MESSAGE (msg), FALSE);
@@ -301,7 +303,7 @@ soup_auth_update (SoupAuth *auth, SoupMessage *msg, const char *auth_header)
params = g_hash_table_new (NULL, NULL);
realm = g_hash_table_lookup (params, "realm");
- if (realm && auth->realm && strcmp (realm, auth->realm) != 0) {
+ if (realm && priv->realm && strcmp (realm, priv->realm) != 0) {
soup_header_free_param_list (params);
return FALSE;
}
@@ -405,9 +407,11 @@ soup_auth_get_host (SoupAuth *auth)
const char *
soup_auth_get_realm (SoupAuth *auth)
{
+ SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
+
g_return_val_if_fail (SOUP_IS_AUTH (auth), NULL);
- return auth->realm;
+ return priv->realm;
}
/**
@@ -424,6 +428,8 @@ soup_auth_get_realm (SoupAuth *auth)
char *
soup_auth_get_info (SoupAuth *auth)
{
+ SoupAuthPrivate *priv = soup_auth_get_instance_private (auth);
+
g_return_val_if_fail (SOUP_IS_AUTH (auth), NULL);
if (SOUP_IS_CONNECTION_AUTH (auth))
@@ -431,7 +437,7 @@ soup_auth_get_info (SoupAuth *auth)
else {
return g_strdup_printf ("%s:%s",
SOUP_AUTH_GET_CLASS (auth)->scheme_name,
- auth->realm);
+ priv->realm);
}
}
diff --git a/libsoup/auth/soup-auth.h b/libsoup/auth/soup-auth.h
index 987946f9..c9b78933 100644
--- a/libsoup/auth/soup-auth.h
+++ b/libsoup/auth/soup-auth.h
@@ -3,28 +3,18 @@
* Copyright (C) 2001-2003, Ximian, Inc.
*/
-#ifndef __SOUP_AUTH_H__
-#define __SOUP_AUTH_H__ 1
+#pragma once
#include "soup-types.h"
#include "soup-headers.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_AUTH (soup_auth_get_type ())
-#define SOUP_AUTH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_AUTH, SoupAuth))
-#define SOUP_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_AUTH, SoupAuthClass))
-#define SOUP_IS_AUTH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_AUTH))
-#define SOUP_IS_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_AUTH))
-#define SOUP_AUTH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH, SoupAuthClass))
-
-struct _SoupAuth {
- GObject parent;
-
- char *realm;
-};
+#define SOUP_TYPE_AUTH (soup_auth_get_type())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_DERIVABLE_TYPE (SoupAuth, soup_auth, SOUP, AUTH, GObject)
-typedef struct {
+struct _SoupAuthClass {
GObjectClass parent_class;
const char *scheme_name;
@@ -50,10 +40,8 @@ typedef struct {
gboolean (*can_authenticate) (SoupAuth *auth);
- /* Padding for future expansion */
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupAuthClass;
+ gpointer padding[6];
+};
#define SOUP_AUTH_SCHEME_NAME "scheme-name"
#define SOUP_AUTH_REALM "realm"
@@ -61,9 +49,6 @@ typedef struct {
#define SOUP_AUTH_IS_FOR_PROXY "is-for-proxy"
#define SOUP_AUTH_IS_AUTHENTICATED "is-authenticated"
-SOUP_AVAILABLE_IN_2_4
-GType soup_auth_get_type (void);
-
SOUP_AVAILABLE_IN_2_4
SoupAuth *soup_auth_new (GType type,
SoupMessage *msg,
@@ -107,24 +92,7 @@ SOUP_AVAILABLE_IN_2_4
void soup_auth_free_protection_space (SoupAuth *auth,
GSList *space);
-/* The actual auth types, which can be added/removed as features */
-
-#define SOUP_TYPE_AUTH_BASIC (soup_auth_basic_get_type ())
-SOUP_AVAILABLE_IN_2_4
-GType soup_auth_basic_get_type (void);
-#define SOUP_TYPE_AUTH_DIGEST (soup_auth_digest_get_type ())
-SOUP_AVAILABLE_IN_2_4
-GType soup_auth_digest_get_type (void);
-#define SOUP_TYPE_AUTH_NTLM (soup_auth_ntlm_get_type ())
-SOUP_AVAILABLE_IN_2_4
-GType soup_auth_ntlm_get_type (void);
-#define SOUP_TYPE_AUTH_NEGOTIATE (soup_auth_negotiate_get_type ())
-SOUP_AVAILABLE_IN_2_54
-GType soup_auth_negotiate_get_type (void);
-
SOUP_AVAILABLE_IN_2_54
gboolean soup_auth_negotiate_supported (void);
G_END_DECLS
-
-#endif /* __SOUP_AUTH_H__ */
diff --git a/libsoup/auth/soup-connection-auth.c b/libsoup/auth/soup-connection-auth.c
index f55cfe6b..7689b109 100644
--- a/libsoup/auth/soup-connection-auth.c
+++ b/libsoup/auth/soup-connection-auth.c
@@ -18,18 +18,18 @@
#include "soup-connection.h"
#include "soup-message-private.h"
-struct SoupConnectionAuthPrivate {
+typedef struct {
GHashTable *conns;
-};
+} SoupConnectionAuthPrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SoupConnectionAuth, soup_connection_auth, SOUP_TYPE_AUTH)
static void
soup_connection_auth_init (SoupConnectionAuth *auth)
{
- auth->priv = soup_connection_auth_get_instance_private (auth);
+ SoupConnectionAuthPrivate *priv = soup_connection_auth_get_instance_private (auth);
- auth->priv->conns = g_hash_table_new (NULL, NULL);
+ priv->conns = g_hash_table_new (NULL, NULL);
}
static void connection_disconnected (SoupConnection *conn, gpointer user_data);
@@ -47,10 +47,11 @@ static void
connection_disconnected (SoupConnection *conn, gpointer user_data)
{
SoupConnectionAuth *auth = user_data;
+ SoupConnectionAuthPrivate *priv = soup_connection_auth_get_instance_private (auth);
gpointer state;
- state = g_hash_table_lookup (auth->priv->conns, conn);
- g_hash_table_remove (auth->priv->conns, conn);
+ state = g_hash_table_lookup (priv->conns, conn);
+ g_hash_table_remove (priv->conns, conn);
soup_connection_auth_free_connection_state (auth, conn, state);
}
@@ -58,15 +59,16 @@ static void
soup_connection_auth_finalize (GObject *object)
{
SoupConnectionAuth *auth = SOUP_CONNECTION_AUTH (object);
+ SoupConnectionAuthPrivate *priv = soup_connection_auth_get_instance_private (auth);
GHashTableIter iter;
gpointer conn, state;
- g_hash_table_iter_init (&iter, auth->priv->conns);
+ g_hash_table_iter_init (&iter, priv->conns);
while (g_hash_table_iter_next (&iter, &conn, &state)) {
soup_connection_auth_free_connection_state (auth, conn, state);
g_hash_table_iter_remove (&iter);
}
- g_hash_table_destroy (auth->priv->conns);
+ g_hash_table_destroy (priv->conns);
G_OBJECT_CLASS (soup_connection_auth_parent_class)->finalize (object);
}
@@ -90,6 +92,7 @@ gpointer
soup_connection_auth_get_connection_state_for_message (SoupConnectionAuth *auth,
SoupMessage *msg)
{
+ SoupConnectionAuthPrivate *priv = soup_connection_auth_get_instance_private (auth);
SoupConnection *conn;
gpointer state;
@@ -97,7 +100,7 @@ soup_connection_auth_get_connection_state_for_message (SoupConnectionAuth *auth,
g_return_val_if_fail (SOUP_IS_MESSAGE (msg), NULL);
conn = soup_message_get_connection (msg);
- state = g_hash_table_lookup (auth->priv->conns, conn);
+ state = g_hash_table_lookup (priv->conns, conn);
if (state)
return state;
@@ -107,7 +110,7 @@ soup_connection_auth_get_connection_state_for_message (SoupConnectionAuth *auth,
G_CALLBACK (connection_disconnected), auth);
}
- g_hash_table_insert (auth->priv->conns, conn, state);
+ g_hash_table_insert (priv->conns, conn, state);
return state;
}
diff --git a/libsoup/auth/soup-connection-auth.h b/libsoup/auth/soup-connection-auth.h
index b7ef16fe..c1c922c4 100644
--- a/libsoup/auth/soup-connection-auth.h
+++ b/libsoup/auth/soup-connection-auth.h
@@ -3,29 +3,17 @@
* Copyright (C) 2010 Red Hat, Inc.
*/
-#ifndef __SOUP_CONNECTION_AUTH_H__
-#define __SOUP_CONNECTION_AUTH_H__ 1
+#pragma once
#include "soup-auth.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_CONNECTION_AUTH (soup_connection_auth_get_type ())
-#define SOUP_CONNECTION_AUTH(object) (G_TYPE_CHECK_INSTANCE_CAST ((object),
SOUP_TYPE_CONNECTION_AUTH, SoupConnectionAuth))
-#define SOUP_CONNECTION_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_CONNECTION_AUTH,
SoupConnectionAuthClass))
-#define SOUP_IS_CONNECTION_AUTH(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object),
SOUP_TYPE_CONNECTION_AUTH))
-#define SOUP_IS_CONNECTION_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_CONNECTION_AUTH))
-#define SOUP_CONNECTION_AUTH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_CONNECTION_AUTH,
SoupConnectionAuthClass))
+#define SOUP_TYPE_CONNECTION_AUTH (soup_connection_auth_get_type ())
+_SOUP_EXTERN
+G_DECLARE_DERIVABLE_TYPE (SoupConnectionAuth, soup_connection_auth, SOUP, CONNECTION_AUTH, SoupAuth)
-typedef struct SoupConnectionAuthPrivate SoupConnectionAuthPrivate;
-
-typedef struct {
- SoupAuth parent;
-
- SoupConnectionAuthPrivate *priv;
-} SoupConnectionAuth;
-
-typedef struct {
+struct _SoupConnectionAuthClass {
SoupAuthClass parent_class;
gpointer (*create_connection_state) (SoupConnectionAuth *auth);
@@ -42,14 +30,10 @@ typedef struct {
gboolean (*is_connection_ready) (SoupConnectionAuth *auth,
SoupMessage *msg,
gpointer conn);
-} SoupConnectionAuthClass;
+};
-GType soup_connection_auth_get_type (void);
-SOUP_AVAILABLE_IN_2_58
gpointer soup_connection_auth_get_connection_state_for_message
(SoupConnectionAuth *auth,
SoupMessage *message);
G_END_DECLS
-
-#endif /* __SOUP_CONNECTION_AUTH_H__ */
diff --git a/libsoup/cache/soup-cache-private.h b/libsoup/cache/soup-cache-private.h
index 9760def9..40a83055 100644
--- a/libsoup/cache/soup-cache-private.h
+++ b/libsoup/cache/soup-cache-private.h
@@ -20,8 +20,7 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __SOUP_CACHE_PRIVATE_H__
-#define __SOUP_CACHE_PRIVATE_H__ 1
+#pragma once
#include "cache/soup-cache.h"
#include "soup-message.h"
@@ -42,5 +41,3 @@ void soup_cache_update_from_conditional_request (SoupCache *cach
SoupMessage *msg);
G_END_DECLS
-
-#endif /* __SOUP_CACHE_PRIVATE_H__ */
diff --git a/libsoup/cache/soup-cache.c b/libsoup/cache/soup-cache.c
index bbdb4b4c..09c71a44 100644
--- a/libsoup/cache/soup-cache.c
+++ b/libsoup/cache/soup-cache.c
@@ -110,7 +110,7 @@ typedef struct _SoupCacheEntry {
guint16 status_code;
} SoupCacheEntry;
-struct _SoupCachePrivate {
+typedef struct {
char *cache_dir;
GHashTable *cache;
guint n_pending;
@@ -120,7 +120,7 @@ struct _SoupCachePrivate {
guint max_size;
guint max_entry_data_size; /* Computed value. Here for performance reasons */
GList *lru_start;
-};
+} SoupCachePrivate;
enum {
PROP_0,
@@ -142,7 +142,8 @@ static gboolean cache_accepts_entries_of_size (SoupCache *cache, guint length_to
static GFile *
get_file_from_entry (SoupCache *cache, SoupCacheEntry *entry)
{
- char *filename = g_strdup_printf ("%s%s%u", cache->priv->cache_dir,
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
+ char *filename = g_strdup_printf ("%s%s%u", priv->cache_dir,
G_DIR_SEPARATOR_S, (guint) entry->key);
GFile *file = g_file_new_for_path (filename);
g_free (filename);
@@ -153,6 +154,7 @@ get_file_from_entry (SoupCache *cache, SoupCacheEntry *entry)
static SoupCacheability
get_cacheability (SoupCache *cache, SoupMessage *msg)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
SoupCacheability cacheability;
const char *cache_control, *content_type;
gboolean has_max_age = FALSE;
@@ -174,7 +176,6 @@ 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_instance_private (cache);
hash = soup_header_parse_param_list (cache_control);
@@ -507,6 +508,7 @@ soup_cache_entry_new (SoupCache *cache, SoupMessage *msg, time_t request_time, t
static gboolean
soup_cache_entry_remove (SoupCache *cache, SoupCacheEntry *entry, gboolean purge)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
GList *lru_item;
if (entry->dirty) {
@@ -515,19 +517,19 @@ soup_cache_entry_remove (SoupCache *cache, SoupCacheEntry *entry, gboolean purge
}
g_assert (!entry->dirty);
- g_assert (g_list_length (cache->priv->lru_start) == g_hash_table_size (cache->priv->cache));
+ g_assert (g_list_length (priv->lru_start) == g_hash_table_size (priv->cache));
- if (!g_hash_table_remove (cache->priv->cache, GUINT_TO_POINTER (entry->key)))
+ if (!g_hash_table_remove (priv->cache, GUINT_TO_POINTER (entry->key)))
return FALSE;
/* Remove from LRU */
- lru_item = g_list_find (cache->priv->lru_start, entry);
- cache->priv->lru_start = g_list_delete_link (cache->priv->lru_start, lru_item);
+ lru_item = g_list_find (priv->lru_start, entry);
+ priv->lru_start = g_list_delete_link (priv->lru_start, lru_item);
/* Adjust cache size */
- cache->priv->size -= entry->length;
+ priv->size -= entry->length;
- g_assert (g_list_length (cache->priv->lru_start) == g_hash_table_size (cache->priv->cache));
+ g_assert (g_list_length (priv->lru_start) == g_hash_table_size (priv->cache));
/* Free resources */
if (purge) {
@@ -572,16 +574,18 @@ lru_compare_func (gconstpointer a, gconstpointer b)
static gboolean
cache_accepts_entries_of_size (SoupCache *cache, guint length_to_add)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
/* We could add here some more heuristics. TODO: review how
this is done by other HTTP caches */
- return length_to_add <= cache->priv->max_entry_data_size;
+ return length_to_add <= priv->max_entry_data_size;
}
static void
make_room_for_new_entry (SoupCache *cache, guint length_to_add)
{
- GList *lru_entry = cache->priv->lru_start;
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
+ GList *lru_entry = priv->lru_start;
/* Check that there is enough room for the new entry. This is
an approximation as we're not working out the size of the
@@ -589,14 +593,14 @@ make_room_for_new_entry (SoupCache *cache, guint length_to_add)
reasons. TODO: check if that would be really that expensive */
while (lru_entry &&
- (length_to_add + cache->priv->size > cache->priv->max_size)) {
+ (length_to_add + priv->size > priv->max_size)) {
SoupCacheEntry *old_entry = (SoupCacheEntry *)lru_entry->data;
/* Discard entries. Once cancelled resources will be
* freed in close_ready_cb
*/
if (soup_cache_entry_remove (cache, old_entry, TRUE))
- lru_entry = cache->priv->lru_start;
+ lru_entry = priv->lru_start;
else
lru_entry = g_list_next (lru_entry);
}
@@ -607,6 +611,7 @@ soup_cache_entry_insert (SoupCache *cache,
SoupCacheEntry *entry,
gboolean sort)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
guint length_to_add = 0;
SoupCacheEntry *old_entry;
@@ -626,24 +631,24 @@ soup_cache_entry_insert (SoupCache *cache,
}
/* Remove any previous entry */
- if ((old_entry = g_hash_table_lookup (cache->priv->cache, GUINT_TO_POINTER (entry->key))) != NULL) {
+ if ((old_entry = g_hash_table_lookup (priv->cache, GUINT_TO_POINTER (entry->key))) != NULL) {
if (!soup_cache_entry_remove (cache, old_entry, TRUE))
return FALSE;
}
/* Add to hash table */
- g_hash_table_insert (cache->priv->cache, GUINT_TO_POINTER (entry->key), entry);
+ g_hash_table_insert (priv->cache, GUINT_TO_POINTER (entry->key), entry);
/* Compute new cache size */
- cache->priv->size += length_to_add;
+ priv->size += length_to_add;
/* Update LRU */
if (sort)
- cache->priv->lru_start = g_list_insert_sorted (cache->priv->lru_start, entry,
lru_compare_func);
+ priv->lru_start = g_list_insert_sorted (priv->lru_start, entry, lru_compare_func);
else
- cache->priv->lru_start = g_list_prepend (cache->priv->lru_start, entry);
+ priv->lru_start = g_list_prepend (priv->lru_start, entry);
- g_assert (g_list_length (cache->priv->lru_start) == g_hash_table_size (cache->priv->cache));
+ g_assert (g_list_length (priv->lru_start) == g_hash_table_size (priv->cache));
return TRUE;
}
@@ -652,6 +657,7 @@ static SoupCacheEntry*
soup_cache_entry_lookup (SoupCache *cache,
SoupMessage *msg)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
SoupCacheEntry *entry;
guint32 key;
char *uri = NULL;
@@ -659,7 +665,7 @@ soup_cache_entry_lookup (SoupCache *cache,
uri = soup_uri_to_string (soup_message_get_uri (msg), FALSE);
key = get_cache_key_from_uri ((const char *) uri);
- entry = g_hash_table_lookup (cache->priv->cache, GUINT_TO_POINTER (key));
+ entry = g_hash_table_lookup (priv->cache, GUINT_TO_POINTER (key));
if (entry != NULL && (strcmp (entry->uri, uri) != 0))
entry = NULL;
@@ -671,6 +677,7 @@ soup_cache_entry_lookup (SoupCache *cache,
GInputStream *
soup_cache_send_response (SoupCache *cache, SoupMessage *msg)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
SoupCacheEntry *entry;
GInputStream *file_stream, *body_stream, *cache_stream, *client_stream;
GFile *file;
@@ -711,7 +718,7 @@ soup_cache_send_response (SoupCache *cache, SoupMessage *msg)
/* Create the cache stream. */
soup_message_disable_feature (msg, SOUP_TYPE_CACHE);
cache_stream = soup_message_setup_body_istream (body_stream, msg,
- cache->priv->session,
+ priv->session,
SOUP_STAGE_ENTITY_BODY);
g_object_unref (body_stream);
@@ -746,7 +753,8 @@ static void
attach (SoupSessionFeature *feature, SoupSession *session)
{
SoupCache *cache = SOUP_CACHE (feature);
- cache->priv->session = session;
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
+ priv->session = session;
soup_cache_default_feature_interface->attach (feature, session);
}
@@ -775,9 +783,10 @@ istream_caching_finished (SoupCacheInputStream *istream,
{
StreamHelper *helper = (StreamHelper *) user_data;
SoupCache *cache = helper->cache;
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
SoupCacheEntry *entry = helper->entry;
- --cache->priv->n_pending;
+ --priv->n_pending;
entry->dirty = FALSE;
entry->length = bytes_written;
@@ -786,7 +795,7 @@ istream_caching_finished (SoupCacheInputStream *istream,
if (error) {
/* Update cache size */
if (soup_message_headers_get_encoding (entry->headers) == SOUP_ENCODING_CONTENT_LENGTH)
- cache->priv->size -= soup_message_headers_get_content_length (entry->headers);
+ priv->size -= soup_message_headers_get_content_length (entry->headers);
soup_cache_entry_remove (cache, entry, TRUE);
helper->entry = entry = NULL;
@@ -797,7 +806,7 @@ istream_caching_finished (SoupCacheInputStream *istream,
if (cache_accepts_entries_of_size (cache, entry->length)) {
make_room_for_new_entry (cache, entry->length);
- cache->priv->size += entry->length;
+ priv->size += entry->length;
} else {
soup_cache_entry_remove (cache, entry, TRUE);
helper->entry = entry = NULL;
@@ -816,6 +825,7 @@ soup_cache_content_processor_wrap_input (SoupContentProcessor *processor,
GError **error)
{
SoupCache *cache = (SoupCache*) processor;
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
SoupCacheEntry *entry;
SoupCacheability cacheability;
GInputStream *istream;
@@ -868,7 +878,7 @@ soup_cache_content_processor_wrap_input (SoupContentProcessor *processor,
}
entry->cancellable = g_cancellable_new ();
- ++cache->priv->n_pending;
+ ++priv->n_pending;
helper = g_slice_new (StreamHelper);
helper->cache = g_object_ref (cache);
@@ -897,9 +907,7 @@ soup_cache_content_processor_init (SoupContentProcessorInterface *processor_inte
static void
soup_cache_init (SoupCache *cache)
{
- SoupCachePrivate *priv;
-
- priv = cache->priv = soup_cache_get_instance_private (cache);
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
priv->cache = g_hash_table_new (g_direct_hash, g_direct_equal);
/* LRU */
@@ -924,11 +932,9 @@ remove_cache_item (gpointer data,
static void
soup_cache_finalize (GObject *object)
{
- SoupCachePrivate *priv;
+ SoupCachePrivate *priv = soup_cache_get_instance_private ((SoupCache*)object);
GList *entries;
- priv = SOUP_CACHE (object)->priv;
-
/* Cannot use g_hash_table_foreach as callbacks must not modify the hash table */
entries = g_hash_table_get_values (priv->cache);
g_list_foreach (entries, remove_cache_item, object);
@@ -946,7 +952,7 @@ static void
soup_cache_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- SoupCachePrivate *priv = SOUP_CACHE (object)->priv;
+ SoupCachePrivate *priv = soup_cache_get_instance_private ((SoupCache*)object);
switch (prop_id) {
case PROP_CACHE_DIR:
@@ -978,7 +984,7 @@ static void
soup_cache_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
- SoupCachePrivate *priv = SOUP_CACHE (object)->priv;
+ SoupCachePrivate *priv = soup_cache_get_instance_private ((SoupCache*)object);
switch (prop_id) {
case PROP_CACHE_DIR:
@@ -1072,6 +1078,7 @@ soup_cache_new (const char *cache_dir, SoupCacheType cache_type)
SoupCacheResponse
soup_cache_has_response (SoupCache *cache, SoupMessage *msg)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
SoupCacheEntry *entry;
const char *cache_control;
gpointer value;
@@ -1088,13 +1095,13 @@ soup_cache_has_response (SoupCache *cache, SoupMessage *msg)
/* Increase hit count. Take sorting into account */
entry->hits++;
- lru_item = g_list_find (cache->priv->lru_start, entry);
+ lru_item = g_list_find (priv->lru_start, entry);
item = lru_item;
while (item->next && lru_compare_func (item->data, item->next->data) > 0)
item = g_list_next (item);
if (item != lru_item) {
- cache->priv->lru_start = g_list_remove_link (cache->priv->lru_start, lru_item);
+ priv->lru_start = g_list_remove_link (priv->lru_start, lru_item);
item = g_list_insert_sorted (item, lru_item->data, lru_compare_func);
g_list_free (lru_item);
}
@@ -1260,6 +1267,7 @@ force_flush_timeout (gpointer data)
void
soup_cache_flush (SoupCache *cache)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
GMainContext *async_context;
SoupSession *session;
GSource *timeout;
@@ -1267,20 +1275,20 @@ soup_cache_flush (SoupCache *cache)
g_return_if_fail (SOUP_IS_CACHE (cache));
- session = cache->priv->session;
+ session = priv->session;
g_return_if_fail (SOUP_IS_SESSION (session));
async_context = g_main_context_get_thread_default ();
/* We give cache 10 secs to finish */
timeout = soup_add_timeout (async_context, 10000, force_flush_timeout, &forced);
- while (!forced && cache->priv->n_pending > 0)
+ while (!forced && priv->n_pending > 0)
g_main_context_iteration (async_context, FALSE);
if (!forced)
g_source_destroy (timeout);
else
- g_warning ("Cache flush finished despite %d pending requests", cache->priv->n_pending);
+ g_warning ("Cache flush finished despite %d pending requests", priv->n_pending);
}
typedef void (* SoupCacheForeachFileFunc) (SoupCache *cache, const char *name, gpointer user_data);
@@ -1288,9 +1296,9 @@ typedef void (* SoupCacheForeachFileFunc) (SoupCache *cache, const char *name, g
static void
soup_cache_foreach_file (SoupCache *cache, SoupCacheForeachFileFunc func, gpointer user_data)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
GDir *dir;
const char *name;
- SoupCachePrivate *priv = cache->priv;
dir = g_dir_open (priv->cache_dir, 0, NULL);
while ((name = g_dir_read_name (dir))) {
@@ -1312,9 +1320,10 @@ clear_cache_item (gpointer data,
static void
delete_cache_file (SoupCache *cache, const char *name, gpointer user_data)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
gchar *path;
- path = g_build_filename (cache->priv->cache_dir, name, NULL);
+ path = g_build_filename (priv->cache_dir, name, NULL);
g_unlink (path);
g_free (path);
}
@@ -1336,13 +1345,14 @@ clear_cache_files (SoupCache *cache)
void
soup_cache_clear (SoupCache *cache)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
GList *entries;
g_return_if_fail (SOUP_IS_CACHE (cache));
- g_return_if_fail (cache->priv->cache);
+ g_return_if_fail (priv->cache);
/* Cannot use g_hash_table_foreach as callbacks must not modify the hash table */
- entries = g_hash_table_get_values (cache->priv->cache);
+ entries = g_hash_table_get_values (priv->cache);
g_list_foreach (entries, clear_cache_item, cache);
g_list_free (entries);
@@ -1405,13 +1415,14 @@ void
soup_cache_cancel_conditional_request (SoupCache *cache,
SoupMessage *msg)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
SoupCacheEntry *entry;
entry = soup_cache_entry_lookup (cache, msg);
if (entry)
entry->being_validated = FALSE;
- soup_session_cancel_message (cache->priv->session, msg, SOUP_STATUS_CANCELLED);
+ soup_session_cancel_message (priv->session, msg, SOUP_STATUS_CANCELLED);
}
void
@@ -1490,14 +1501,14 @@ soup_cache_dump (SoupCache *cache)
GVariantBuilder entries_builder;
GVariant *cache_variant;
- if (!g_list_length (cache->priv->lru_start))
+ if (!g_list_length (priv->lru_start))
return;
/* Create the builder and iterate over all entries */
g_variant_builder_init (&entries_builder, G_VARIANT_TYPE (SOUP_CACHE_ENTRIES_FORMAT));
g_variant_builder_add (&entries_builder, "q", SOUP_CACHE_CURRENT_VERSION);
g_variant_builder_open (&entries_builder, G_VARIANT_TYPE ("a" SOUP_CACHE_PHEADERS_FORMAT));
- g_list_foreach (cache->priv->lru_start, pack_entry, &entries_builder);
+ g_list_foreach (priv->lru_start, pack_entry, &entries_builder);
g_variant_builder_close (&entries_builder);
/* Serialize and dump */
@@ -1522,9 +1533,10 @@ get_key_from_cache_filename (const char *name)
static void
insert_cache_file (SoupCache *cache, const char *name, GHashTable *leaked_entries)
{
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
gchar *path;
- path = g_build_filename (cache->priv->cache_dir, name, NULL);
+ path = g_build_filename (priv->cache_dir, name, NULL);
if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
guint32 key = get_key_from_cache_filename (name);
@@ -1555,7 +1567,7 @@ soup_cache_load (SoupCache *cache)
GVariantIter *entries_iter = NULL, *headers_iter = NULL;
gsize length;
SoupCacheEntry *entry;
- SoupCachePrivate *priv = cache->priv;
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
guint16 version, status_code;
GHashTable *leaked_entries = NULL;
GHashTableIter iter;
@@ -1628,7 +1640,7 @@ soup_cache_load (SoupCache *cache)
g_unlink ((char *)value);
g_hash_table_destroy (leaked_entries);
- cache->priv->lru_start = g_list_reverse (cache->priv->lru_start);
+ priv->lru_start = g_list_reverse (priv->lru_start);
/* frees */
g_variant_iter_free (entries_iter);
@@ -1648,8 +1660,9 @@ void
soup_cache_set_max_size (SoupCache *cache,
guint max_size)
{
- cache->priv->max_size = max_size;
- cache->priv->max_entry_data_size = cache->priv->max_size / MAX_ENTRY_DATA_PERCENTAGE;
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
+ priv->max_size = max_size;
+ priv->max_entry_data_size = priv->max_size / MAX_ENTRY_DATA_PERCENTAGE;
}
/**
@@ -1665,5 +1678,6 @@ soup_cache_set_max_size (SoupCache *cache,
guint
soup_cache_get_max_size (SoupCache *cache)
{
- return cache->priv->max_size;
+ SoupCachePrivate *priv = soup_cache_get_instance_private (cache);
+ return priv->max_size;
}
diff --git a/libsoup/cache/soup-cache.h b/libsoup/cache/soup-cache.h
index 9386f283..6905634e 100644
--- a/libsoup/cache/soup-cache.h
+++ b/libsoup/cache/soup-cache.h
@@ -20,22 +20,15 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __SOUP_CACHE_H__
-#define __SOUP_CACHE_H__ 1
+#pragma once
#include "soup-types.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_CACHE (soup_cache_get_type ())
-#define SOUP_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_CACHE, SoupCache))
-#define SOUP_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_CACHE, SoupCacheClass))
-#define SOUP_IS_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_CACHE))
-#define SOUP_IS_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_CACHE))
-#define SOUP_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_CACHE, SoupCacheClass))
-
-typedef struct _SoupCache SoupCache;
-typedef struct _SoupCachePrivate SoupCachePrivate;
+#define SOUP_TYPE_CACHE (soup_cache_get_type ())
+SOUP_AVAILABLE_IN_2_34
+G_DECLARE_DERIVABLE_TYPE (SoupCache, soup_cache, SOUP, CACHE, GObject)
typedef enum {
SOUP_CACHE_CACHEABLE = (1 << 0),
@@ -55,27 +48,15 @@ typedef enum {
SOUP_CACHE_SHARED
} SoupCacheType;
-struct _SoupCache {
- GObject parent_instance;
-
- SoupCachePrivate *priv;
-};
-
-typedef struct {
+struct _SoupCacheClass {
GObjectClass parent_class;
/* methods */
SoupCacheability (*get_cacheability) (SoupCache *cache,
SoupMessage *msg);
+ gpointer padding[4];
+};
- /* Padding for future expansion */
- void (*_libsoup_reserved1)(void);
- void (*_libsoup_reserved2)(void);
- void (*_libsoup_reserved3)(void);
-} SoupCacheClass;
-
-SOUP_AVAILABLE_IN_2_34
-GType soup_cache_get_type (void);
SOUP_AVAILABLE_IN_2_34
SoupCache *soup_cache_new (const char *cache_dir,
SoupCacheType cache_type);
@@ -96,6 +77,3 @@ SOUP_AVAILABLE_IN_2_34
guint soup_cache_get_max_size (SoupCache *cache);
G_END_DECLS
-
-#endif /* __SOUP_CACHE_H__ */
-
diff --git a/libsoup/content-sniffer/soup-content-decoder.c b/libsoup/content-sniffer/soup-content-decoder.c
index c0155786..eeb880ff 100644
--- a/libsoup/content-sniffer/soup-content-decoder.c
+++ b/libsoup/content-sniffer/soup-content-decoder.c
@@ -53,10 +53,14 @@
* Since: 2.30
**/
-struct _SoupContentDecoderPrivate {
- GHashTable *decoders;
+struct _SoupContentDecoder {
+ GObject parent;
};
+typedef struct {
+ GHashTable *decoders;
+} SoupContentDecoderPrivate;
+
typedef GConverter * (*SoupContentDecoderCreator) (void);
static void soup_content_decoder_session_feature_init (SoupSessionFeatureInterface *feature_interface,
gpointer interface_data);
@@ -75,6 +79,7 @@ G_DEFINE_TYPE_WITH_CODE (SoupContentDecoder, soup_content_decoder, G_TYPE_OBJECT
static GSList *
soup_content_decoder_get_decoders_for_msg (SoupContentDecoder *decoder, SoupMessage *msg)
{
+ SoupContentDecoderPrivate *priv = soup_content_decoder_get_instance_private (decoder);
const char *header;
GSList *encodings, *e, *decoders = NULL;
SoupContentDecoderCreator converter_creator;
@@ -104,14 +109,14 @@ soup_content_decoder_get_decoders_for_msg (SoupContentDecoder *decoder, SoupMess
return NULL;
for (e = encodings; e; e = e->next) {
- if (!g_hash_table_lookup (decoder->priv->decoders, e->data)) {
+ if (!g_hash_table_lookup (priv->decoders, e->data)) {
soup_header_free_list (encodings);
return NULL;
}
}
for (e = encodings; e; e = e->next) {
- converter_creator = g_hash_table_lookup (decoder->priv->decoders, e->data);
+ converter_creator = g_hash_table_lookup (priv->decoders, e->data);
converter = converter_creator ();
/* Content-Encoding lists the codings in the order
@@ -204,18 +209,18 @@ brotli_decoder_creator (void)
static void
soup_content_decoder_init (SoupContentDecoder *decoder)
{
- decoder->priv = soup_content_decoder_get_instance_private (decoder);
+ SoupContentDecoderPrivate *priv = soup_content_decoder_get_instance_private (decoder);
- decoder->priv->decoders = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->decoders = g_hash_table_new (g_str_hash, g_str_equal);
/* Hardcoded for now */
- g_hash_table_insert (decoder->priv->decoders, "gzip",
+ g_hash_table_insert (priv->decoders, "gzip",
gzip_decoder_creator);
- g_hash_table_insert (decoder->priv->decoders, "x-gzip",
+ g_hash_table_insert (priv->decoders, "x-gzip",
gzip_decoder_creator);
- g_hash_table_insert (decoder->priv->decoders, "deflate",
+ g_hash_table_insert (priv->decoders, "deflate",
zlib_decoder_creator);
#ifdef WITH_BROTLI
- g_hash_table_insert (decoder->priv->decoders, "br",
+ g_hash_table_insert (priv->decoders, "br",
brotli_decoder_creator);
#endif
}
@@ -224,8 +229,9 @@ static void
soup_content_decoder_finalize (GObject *object)
{
SoupContentDecoder *decoder = SOUP_CONTENT_DECODER (object);
+ SoupContentDecoderPrivate *priv = soup_content_decoder_get_instance_private (decoder);
- g_hash_table_destroy (decoder->priv->decoders);
+ g_hash_table_destroy (priv->decoders);
G_OBJECT_CLASS (soup_content_decoder_parent_class)->finalize (object);
}
diff --git a/libsoup/content-sniffer/soup-content-decoder.h b/libsoup/content-sniffer/soup-content-decoder.h
index c27042ee..f31c4055 100644
--- a/libsoup/content-sniffer/soup-content-decoder.h
+++ b/libsoup/content-sniffer/soup-content-decoder.h
@@ -3,8 +3,7 @@
* Copyright (C) 2009 Red Hat, Inc.
*/
-#ifndef __SOUP_CONTENT_DECODER_H__
-#define __SOUP_CONTENT_DECODER_H__ 1
+#pragma once
#include "soup-types.h"
#include "soup-message-body.h"
@@ -12,34 +11,7 @@
G_BEGIN_DECLS
#define SOUP_TYPE_CONTENT_DECODER (soup_content_decoder_get_type ())
-#define SOUP_CONTENT_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_CONTENT_DECODER,
SoupContentDecoder))
-#define SOUP_CONTENT_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_CONTENT_DECODER,
SoupContentDecoderClass))
-#define SOUP_IS_CONTENT_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_CONTENT_DECODER))
-#define SOUP_IS_CONTENT_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_CONTENT_DECODER))
-#define SOUP_CONTENT_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_CONTENT_DECODER,
SoupContentDecoderClass))
-
-typedef struct _SoupContentDecoderPrivate SoupContentDecoderPrivate;
-
-typedef struct {
- GObject parent;
-
- SoupContentDecoderPrivate *priv;
-} SoupContentDecoder;
-
-typedef struct {
- GObjectClass parent_class;
-
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
- void (*_libsoup_reserved5) (void);
-} SoupContentDecoderClass;
-
SOUP_AVAILABLE_IN_2_30
-GType soup_content_decoder_get_type (void);
+G_DECLARE_FINAL_TYPE (SoupContentDecoder, soup_content_decoder, SOUP, CONTENT_DECODER, GObject)
G_END_DECLS
-
-#endif /* __SOUP_CONTENT_DECODER_H__ */
diff --git a/libsoup/content-sniffer/soup-content-processor.c
b/libsoup/content-sniffer/soup-content-processor.c
index ca1bd169..da9ad89e 100644
--- a/libsoup/content-sniffer/soup-content-processor.c
+++ b/libsoup/content-sniffer/soup-content-processor.c
@@ -37,7 +37,7 @@ soup_content_processor_wrap_input (SoupContentProcessor *processor,
{
g_return_val_if_fail (SOUP_IS_CONTENT_PROCESSOR (processor), NULL);
- return SOUP_CONTENT_PROCESSOR_GET_INTERFACE (processor)->wrap_input (processor, base_stream, msg,
error);
+ return SOUP_CONTENT_PROCESSOR_GET_IFACE (processor)->wrap_input (processor, base_stream, msg, error);
}
SoupProcessingStage
@@ -45,5 +45,5 @@ soup_content_processor_get_processing_stage (SoupContentProcessor *processor)
{
g_return_val_if_fail (SOUP_IS_CONTENT_PROCESSOR (processor), SOUP_STAGE_INVALID);
- return SOUP_CONTENT_PROCESSOR_GET_INTERFACE (processor)->processing_stage;
+ return SOUP_CONTENT_PROCESSOR_GET_IFACE (processor)->processing_stage;
}
diff --git a/libsoup/content-sniffer/soup-content-processor.h
b/libsoup/content-sniffer/soup-content-processor.h
index ab92788e..39075412 100644
--- a/libsoup/content-sniffer/soup-content-processor.h
+++ b/libsoup/content-sniffer/soup-content-processor.h
@@ -3,18 +3,14 @@
* Copyright (C) 2012 Igalia, S.L.
*/
-
-#ifndef __SOUP_CONTENT_PROCESSOR_H__
-#define __SOUP_CONTENT_PROCESSOR_H__ 1
+#pragma once
#include "soup-types.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_CONTENT_PROCESSOR (soup_content_processor_get_type ())
-#define SOUP_CONTENT_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SOUP_TYPE_CONTENT_PROCESSOR, SoupContentProcessor))
-#define SOUP_IS_CONTENT_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
SOUP_TYPE_CONTENT_PROCESSOR))
-#define SOUP_CONTENT_PROCESSOR_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst),
SOUP_TYPE_CONTENT_PROCESSOR, SoupContentProcessorInterface))
+#define SOUP_TYPE_CONTENT_PROCESSOR (soup_content_processor_get_type ())
+G_DECLARE_INTERFACE (SoupContentProcessor, soup_content_processor, SOUP, CONTENT_PROCESSOR, GObject)
typedef enum {
SOUP_STAGE_INVALID,
@@ -26,9 +22,6 @@ typedef enum {
SOUP_STAGE_BODY_DATA /* Actual body data */
} SoupProcessingStage;
-typedef struct _SoupContentProcessor SoupContentProcessor;
-typedef struct _SoupContentProcessorInterface SoupContentProcessorInterface;
-
struct _SoupContentProcessorInterface {
GTypeInterface parent;
@@ -41,8 +34,6 @@ struct _SoupContentProcessorInterface {
GError **error);
};
-GType soup_content_processor_get_type (void);
-
GInputStream *soup_content_processor_wrap_input (SoupContentProcessor *processor,
GInputStream *base_stream,
SoupMessage *msg,
@@ -51,5 +42,3 @@ GInputStream *soup_content_processor_wrap_input (SoupContentProc
SoupProcessingStage soup_content_processor_get_processing_stage (SoupContentProcessor *processor);
G_END_DECLS
-
-#endif /* __SOUP_CONTENT_PROCESSOR_H__ */
diff --git a/libsoup/content-sniffer/soup-content-sniffer-stream.c
b/libsoup/content-sniffer/soup-content-sniffer-stream.c
index f1ed6a1d..4b026e01 100644
--- a/libsoup/content-sniffer/soup-content-sniffer-stream.c
+++ b/libsoup/content-sniffer/soup-content-sniffer-stream.c
@@ -21,7 +21,11 @@ enum {
PROP_MESSAGE,
};
-struct _SoupContentSnifferStreamPrivate {
+struct _SoupContentSnifferStream {
+ GFilterInputStream parent_instance;
+};
+
+typedef struct {
SoupContentSniffer *sniffer;
SoupMessage *msg;
@@ -32,7 +36,7 @@ struct _SoupContentSnifferStreamPrivate {
char *sniffed_type;
GHashTable *sniffed_params;
-};
+} SoupContentSnifferStreamPrivate;
static void soup_content_sniffer_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
gpointer interface_data);
@@ -45,13 +49,14 @@ static void
soup_content_sniffer_stream_finalize (GObject *object)
{
SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (object);
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
- g_clear_object (&sniffer->priv->sniffer);
- g_clear_object (&sniffer->priv->msg);
- g_free (sniffer->priv->buffer);
- g_clear_error (&sniffer->priv->error);
- g_free (sniffer->priv->sniffed_type);
- g_clear_pointer (&sniffer->priv->sniffed_params, g_hash_table_unref);
+ g_clear_object (&priv->sniffer);
+ g_clear_object (&priv->msg);
+ g_free (priv->buffer);
+ g_clear_error (&priv->error);
+ g_free (priv->sniffed_type);
+ g_clear_pointer (&priv->sniffed_params, g_hash_table_unref);
G_OBJECT_CLASS (soup_content_sniffer_stream_parent_class)->finalize (object);
}
@@ -61,16 +66,17 @@ soup_content_sniffer_stream_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (object);
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
switch (prop_id) {
case PROP_SNIFFER:
- sniffer->priv->sniffer = g_value_dup_object (value);
+ priv->sniffer = g_value_dup_object (value);
/* FIXME: supposed to wait until after got-headers for this */
- sniffer->priv->buffer_size = soup_content_sniffer_get_buffer_size (sniffer->priv->sniffer);
- sniffer->priv->buffer = g_malloc (sniffer->priv->buffer_size);
+ priv->buffer_size = soup_content_sniffer_get_buffer_size (priv->sniffer);
+ priv->buffer = g_malloc (priv->buffer_size);
break;
case PROP_MESSAGE:
- sniffer->priv->msg = g_value_dup_object (value);
+ priv->msg = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -83,13 +89,14 @@ soup_content_sniffer_stream_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (object);
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
switch (prop_id) {
case PROP_SNIFFER:
- g_value_set_object (value, sniffer->priv->sniffer);
+ g_value_set_object (value, priv->sniffer);
break;
case PROP_MESSAGE:
- g_value_set_object (value, sniffer->priv->msg);
+ g_value_set_object (value, priv->msg);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -101,7 +108,8 @@ static gssize
read_and_sniff (GInputStream *stream, gboolean blocking,
GCancellable *cancellable, GError **error)
{
- SoupContentSnifferStreamPrivate *priv = SOUP_CONTENT_SNIFFER_STREAM (stream)->priv;
+ SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (stream);
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
gssize nread;
GError *my_error = NULL;
SoupBuffer *buf;
@@ -151,33 +159,34 @@ read_internal (GInputStream *stream,
GError **error)
{
SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (stream);
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
gssize nread;
- if (sniffer->priv->error) {
- g_propagate_error (error, sniffer->priv->error);
- sniffer->priv->error = NULL;
+ if (priv->error) {
+ g_propagate_error (error, priv->error);
+ priv->error = NULL;
return -1;
}
- if (sniffer->priv->sniffing) {
+ if (priv->sniffing) {
nread = read_and_sniff (stream, blocking, cancellable, error);
if (nread <= 0)
return nread;
}
- if (sniffer->priv->buffer) {
- nread = MIN (count, sniffer->priv->buffer_nread);
+ if (priv->buffer) {
+ nread = MIN (count, priv->buffer_nread);
if (buffer)
- memcpy (buffer, sniffer->priv->buffer, nread);
- if (nread == sniffer->priv->buffer_nread) {
- g_free (sniffer->priv->buffer);
- sniffer->priv->buffer = NULL;
+ memcpy (buffer, priv->buffer, nread);
+ if (nread == priv->buffer_nread) {
+ g_free (priv->buffer);
+ priv->buffer = NULL;
} else {
/* FIXME, inefficient */
- memmove (sniffer->priv->buffer,
- sniffer->priv->buffer + nread,
- sniffer->priv->buffer_nread - nread);
- sniffer->priv->buffer_nread -= nread;
+ memmove (priv->buffer,
+ priv->buffer + nread,
+ priv->buffer_nread - nread);
+ priv->buffer_nread -= nread;
}
} else {
nread = g_pollable_stream_read (G_FILTER_INPUT_STREAM (stream)->base_stream,
@@ -205,9 +214,10 @@ soup_content_sniffer_stream_skip (GInputStream *stream,
GError **error)
{
SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (stream);
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
gssize nskipped;
- if (sniffer->priv->sniffing) {
+ if (priv->sniffing) {
/* Read into the internal buffer... */
nskipped = soup_content_sniffer_stream_read (stream, NULL, 0, cancellable, error);
if (nskipped == -1)
@@ -215,17 +225,17 @@ soup_content_sniffer_stream_skip (GInputStream *stream,
/* Now fall through */
}
- if (sniffer->priv->buffer) {
- nskipped = MIN (count, sniffer->priv->buffer_nread);
- if (nskipped == sniffer->priv->buffer_nread) {
- g_free (sniffer->priv->buffer);
- sniffer->priv->buffer = NULL;
+ if (priv->buffer) {
+ nskipped = MIN (count, priv->buffer_nread);
+ if (nskipped == priv->buffer_nread) {
+ g_free (priv->buffer);
+ priv->buffer = NULL;
} else {
/* FIXME */
- memmove (sniffer->priv->buffer,
- sniffer->priv->buffer + nskipped,
- sniffer->priv->buffer_nread - nskipped);
- sniffer->priv->buffer_nread -= nskipped;
+ memmove (priv->buffer,
+ priv->buffer + nskipped,
+ priv->buffer_nread - nskipped);
+ priv->buffer_nread -= nskipped;
}
} else {
nskipped = G_INPUT_STREAM_CLASS (soup_content_sniffer_stream_parent_class)->
@@ -248,9 +258,10 @@ static gboolean
soup_content_sniffer_stream_is_readable (GPollableInputStream *stream)
{
SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (stream);
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
- if (sniffer->priv->error ||
- (!sniffer->priv->sniffing && sniffer->priv->buffer))
+ if (priv->error ||
+ (!priv->sniffing && priv->buffer))
return TRUE;
return g_pollable_input_stream_is_readable (G_POLLABLE_INPUT_STREAM (G_FILTER_INPUT_STREAM
(stream)->base_stream));
@@ -271,10 +282,11 @@ soup_content_sniffer_stream_create_source (GPollableInputStream *stream,
GCancellable *cancellable)
{
SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (stream);
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
GSource *base_source, *pollable_source;
- if (sniffer->priv->error ||
- (!sniffer->priv->sniffing && sniffer->priv->buffer))
+ if (priv->error ||
+ (!priv->sniffing && priv->buffer))
base_source = g_timeout_source_new (0);
else
base_source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM
(G_FILTER_INPUT_STREAM (stream)->base_stream), cancellable);
@@ -290,8 +302,8 @@ soup_content_sniffer_stream_create_source (GPollableInputStream *stream,
static void
soup_content_sniffer_stream_init (SoupContentSnifferStream *sniffer)
{
- sniffer->priv = soup_content_sniffer_stream_get_instance_private (sniffer);
- sniffer->priv->sniffing = TRUE;
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
+ priv->sniffing = TRUE;
}
static void
@@ -340,7 +352,9 @@ soup_content_sniffer_stream_is_ready (SoupContentSnifferStream *sniffer,
GCancellable *cancellable,
GError **error)
{
- if (!sniffer->priv->sniffing)
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
+
+ if (!priv->sniffing)
return TRUE;
return read_and_sniff (G_INPUT_STREAM (sniffer), blocking,
@@ -351,7 +365,9 @@ const char *
soup_content_sniffer_stream_sniff (SoupContentSnifferStream *sniffer,
GHashTable **params)
{
+ SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
+
if (params)
- *params = sniffer->priv->sniffed_params;
- return sniffer->priv->sniffed_type;
+ *params = priv->sniffed_params;
+ return priv->sniffed_type;
}
diff --git a/libsoup/content-sniffer/soup-content-sniffer-stream.h
b/libsoup/content-sniffer/soup-content-sniffer-stream.h
index de3e9c96..1db3002e 100644
--- a/libsoup/content-sniffer/soup-content-sniffer-stream.h
+++ b/libsoup/content-sniffer/soup-content-sniffer-stream.h
@@ -3,38 +3,15 @@
* Copyright (C) 2010 Red Hat, Inc.
*/
-#ifndef __SOUP_CONTENT_SNIFFER_STREAM_H__
-#define __SOUP_CONTENT_SNIFFER_STREAM_H__ 1
+#pragma once
#include "soup-types.h"
#include "content-sniffer/soup-content-sniffer.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_CONTENT_SNIFFER_STREAM (soup_content_sniffer_stream_get_type ())
-#define SOUP_CONTENT_SNIFFER_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
SOUP_TYPE_CONTENT_SNIFFER_STREAM, SoupContentSnifferStream))
-#define SOUP_CONTENT_SNIFFER_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
SOUP_TYPE_CONTENT_SNIFFER_STREAM, SoupContentSnifferStreamClass))
-#define SOUP_IS_CONTENT_SNIFFER_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
SOUP_TYPE_CONTENT_SNIFFER_STREAM))
-#define SOUP_IS_CONTENT_SNIFFER_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
SOUP_TYPE_CONTENT_SNIFFER_STREAM))
-#define SOUP_CONTENT_SNIFFER_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
SOUP_TYPE_CONTENT_SNIFFER_STREAM, SoupContentSnifferStreamClass))
-
-typedef struct _SoupContentSnifferStream SoupContentSnifferStream;
-typedef struct _SoupContentSnifferStreamPrivate SoupContentSnifferStreamPrivate;
-typedef struct _SoupContentSnifferStreamClass SoupContentSnifferStreamClass;
-
-struct _SoupContentSnifferStream {
- GFilterInputStream parent_instance;
-
- /*< private >*/
- SoupContentSnifferStreamPrivate *priv;
-};
-
-struct _SoupContentSnifferStreamClass {
- GFilterInputStreamClass parent_class;
-
-};
-
-GType soup_content_sniffer_stream_get_type (void) G_GNUC_CONST;
+#define SOUP_TYPE_CONTENT_SNIFFER_STREAM (soup_content_sniffer_stream_get_type ())
+G_DECLARE_FINAL_TYPE (SoupContentSnifferStream, soup_content_sniffer_stream, SOUP, CONTENT_SNIFFER_STREAM,
GFilterInputStream)
gboolean soup_content_sniffer_stream_is_ready (SoupContentSnifferStream *sniffer,
gboolean blocking,
@@ -45,5 +22,3 @@ const char *soup_content_sniffer_stream_sniff (SoupContentSnifferStream *s
G_END_DECLS
-
-#endif /* __SOUP_CONTENT_SNIFFER_STREAM_H__ */
diff --git a/libsoup/content-sniffer/soup-content-sniffer.h b/libsoup/content-sniffer/soup-content-sniffer.h
index 7c86f668..cc9aa2b9 100644
--- a/libsoup/content-sniffer/soup-content-sniffer.h
+++ b/libsoup/content-sniffer/soup-content-sniffer.h
@@ -3,30 +3,18 @@
* Copyright (C) 2009 Gustavo Noronha Silva.
*/
-#ifndef __SOUP_CONTENT_SNIFFER_H__
-#define __SOUP_CONTENT_SNIFFER_H__ 1
+#pragma once
#include "soup-types.h"
#include "soup-message-body.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_CONTENT_SNIFFER (soup_content_sniffer_get_type ())
-#define SOUP_CONTENT_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_CONTENT_SNIFFER,
SoupContentSniffer))
-#define SOUP_CONTENT_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_CONTENT_SNIFFER,
SoupContentSnifferClass))
-#define SOUP_IS_CONTENT_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_CONTENT_SNIFFER))
-#define SOUP_IS_CONTENT_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_CONTENT_SNIFFER))
-#define SOUP_CONTENT_SNIFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_CONTENT_SNIFFER,
SoupContentSnifferClass))
-
-typedef struct _SoupContentSnifferPrivate SoupContentSnifferPrivate;
-
-typedef struct {
- GObject parent;
-
- SoupContentSnifferPrivate *priv;
-} SoupContentSniffer;
+#define SOUP_TYPE_CONTENT_SNIFFER (soup_content_sniffer_get_type ())
+SOUP_AVAILABLE_IN_2_28
+G_DECLARE_DERIVABLE_TYPE (SoupContentSniffer, soup_content_sniffer, SOUP, CONTENT_SNIFFER, GObject)
-typedef struct {
+struct _SoupContentSnifferClass {
GObjectClass parent_class;
char* (*sniff) (SoupContentSniffer *sniffer,
@@ -35,16 +23,8 @@ typedef struct {
GHashTable **params);
gsize (*get_buffer_size) (SoupContentSniffer *sniffer);
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
- void (*_libsoup_reserved5) (void);
-} SoupContentSnifferClass;
-
-SOUP_AVAILABLE_IN_2_28
-GType soup_content_sniffer_get_type (void);
+ gpointer padding[6];
+};
SOUP_AVAILABLE_IN_2_28
SoupContentSniffer *soup_content_sniffer_new (void);
@@ -59,4 +39,3 @@ gsize soup_content_sniffer_get_buffer_size (SoupContentSniffer *s
G_END_DECLS
-#endif /* __SOUP_CONTENT_SNIFFER_H__ */
diff --git a/libsoup/content-sniffer/soup-converter-wrapper.c
b/libsoup/content-sniffer/soup-converter-wrapper.c
index 133a3ebe..72e459cc 100644
--- a/libsoup/content-sniffer/soup-converter-wrapper.c
+++ b/libsoup/content-sniffer/soup-converter-wrapper.c
@@ -34,14 +34,18 @@ enum {
PROP_MESSAGE
};
-struct _SoupConverterWrapperPrivate
-{
+struct _SoupConverterWrapper {
+ GObject parent;
+};
+
+
+typedef struct {
GConverter *base_converter;
SoupMessage *msg;
gboolean try_deflate_fallback;
gboolean started;
gboolean discarding;
-};
+} SoupConverterWrapperPrivate;
static void soup_converter_wrapper_iface_init (GConverterIface *iface);
@@ -53,13 +57,13 @@ G_DEFINE_TYPE_WITH_CODE (SoupConverterWrapper, soup_converter_wrapper, G_TYPE_OB
static void
soup_converter_wrapper_init (SoupConverterWrapper *converter)
{
- converter->priv = soup_converter_wrapper_get_instance_private (converter);
}
static void
soup_converter_wrapper_finalize (GObject *object)
{
- SoupConverterWrapperPrivate *priv = SOUP_CONVERTER_WRAPPER (object)->priv;
+ SoupConverterWrapper *converter = (SoupConverterWrapper*)object;
+ SoupConverterWrapperPrivate *priv = soup_converter_wrapper_get_instance_private (converter);
g_clear_object (&priv->base_converter);
g_clear_object (&priv->msg);
@@ -74,7 +78,8 @@ soup_converter_wrapper_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- SoupConverterWrapperPrivate *priv = SOUP_CONVERTER_WRAPPER (object)->priv;
+ SoupConverterWrapper *converter = (SoupConverterWrapper*)object;
+ SoupConverterWrapperPrivate *priv = soup_converter_wrapper_get_instance_private (converter);
switch (prop_id) {
case PROP_BASE_CONVERTER:
@@ -106,7 +111,8 @@ soup_converter_wrapper_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- SoupConverterWrapperPrivate *priv = SOUP_CONVERTER_WRAPPER (object)->priv;
+ SoupConverterWrapper *converter = (SoupConverterWrapper*)object;
+ SoupConverterWrapperPrivate *priv = soup_converter_wrapper_get_instance_private (converter);
switch (prop_id) {
case PROP_BASE_CONVERTER:
@@ -165,7 +171,7 @@ soup_converter_wrapper_new (GConverter *base_converter,
static void
soup_converter_wrapper_reset (GConverter *converter)
{
- SoupConverterWrapperPrivate *priv = SOUP_CONVERTER_WRAPPER (converter)->priv;
+ SoupConverterWrapperPrivate *priv = soup_converter_wrapper_get_instance_private
(SOUP_CONVERTER_WRAPPER (converter));
if (priv->base_converter)
g_converter_reset (priv->base_converter);
@@ -182,7 +188,7 @@ soup_converter_wrapper_fallback_convert (GConverter *converter,
gsize *bytes_written,
GError **error)
{
- SoupConverterWrapperPrivate *priv = SOUP_CONVERTER_WRAPPER (converter)->priv;
+ SoupConverterWrapperPrivate *priv = soup_converter_wrapper_get_instance_private
(SOUP_CONVERTER_WRAPPER (converter));
if (outbuf_size == 0) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NO_SPACE,
@@ -232,7 +238,7 @@ soup_converter_wrapper_real_convert (GConverter *converter,
gsize *bytes_written,
GError **error)
{
- SoupConverterWrapperPrivate *priv = SOUP_CONVERTER_WRAPPER (converter)->priv;
+ SoupConverterWrapperPrivate *priv = soup_converter_wrapper_get_instance_private
(SOUP_CONVERTER_WRAPPER (converter));
GConverterResult result;
GError *my_error = NULL;
@@ -320,7 +326,7 @@ soup_converter_wrapper_convert (GConverter *converter,
gsize *bytes_written,
GError **error)
{
- SoupConverterWrapperPrivate *priv = SOUP_CONVERTER_WRAPPER (converter)->priv;
+ SoupConverterWrapperPrivate *priv = soup_converter_wrapper_get_instance_private
(SOUP_CONVERTER_WRAPPER (converter));
if (priv->base_converter) {
return soup_converter_wrapper_real_convert (converter,
diff --git a/libsoup/content-sniffer/soup-converter-wrapper.h
b/libsoup/content-sniffer/soup-converter-wrapper.h
index 9104c5ef..c1b6f627 100644
--- a/libsoup/content-sniffer/soup-converter-wrapper.h
+++ b/libsoup/content-sniffer/soup-converter-wrapper.h
@@ -3,43 +3,16 @@
* Copyright 2011 Red Hat, Inc.
*/
-#ifndef __SOUP_CONVERTER_WRAPPER_H__
-#define __SOUP_CONVERTER_WRAPPER_H__ 1
+#pragma once
#include "soup-types.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_CONVERTER_WRAPPER (soup_converter_wrapper_get_type ())
-#define SOUP_CONVERTER_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SOUP_TYPE_CONVERTER_WRAPPER, SoupConverterWrapper))
-#define SOUP_CONVERTER_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
SOUP_TYPE_CONVERTER_WRAPPER, SoupConverterWrapperClass))
-#define SOUP_IS_CONVERTER_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
SOUP_TYPE_CONVERTER_WRAPPER))
-#define SOUP_IS_CONVERTER_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_CONVERTER_WRAPPER))
-#define SOUP_CONVERTER_WRAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
SOUP_TYPE_CONVERTER_WRAPPER, SoupConverterWrapperClass))
-
-typedef struct _SoupConverterWrapperPrivate SoupConverterWrapperPrivate;
-
-typedef struct {
- GObject parent;
-
- SoupConverterWrapperPrivate *priv;
-} SoupConverterWrapper;
-
-typedef struct {
- GObjectClass parent_class;
-
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupConverterWrapperClass;
-
-GType soup_converter_wrapper_get_type (void);
+#define SOUP_TYPE_CONVERTER_WRAPPER (soup_converter_wrapper_get_type ())
+G_DECLARE_FINAL_TYPE (SoupConverterWrapper, soup_converter_wrapper, SOUP, CONVERTER_WRAPPER, GObject)
GConverter *soup_converter_wrapper_new (GConverter *base_converter,
SoupMessage *msg);
G_END_DECLS
-
-#endif /* __SOUP_CONVERTER_WRAPPER_H__ */
diff --git a/libsoup/cookies/soup-cookie-jar-db.c b/libsoup/cookies/soup-cookie-jar-db.c
index 3e7a7072..c6f698d4 100644
--- a/libsoup/cookies/soup-cookie-jar-db.c
+++ b/libsoup/cookies/soup-cookie-jar-db.c
@@ -38,6 +38,11 @@ enum {
LAST_PROP
};
+struct _SoupCookieJarDB {
+ SoupCookieJar parent;
+};
+
+
typedef struct {
char *filename;
sqlite3 *db;
diff --git a/libsoup/cookies/soup-cookie-jar-db.h b/libsoup/cookies/soup-cookie-jar-db.h
index 90a6048d..084599f9 100644
--- a/libsoup/cookies/soup-cookie-jar-db.h
+++ b/libsoup/cookies/soup-cookie-jar-db.h
@@ -3,44 +3,20 @@
* Copyright (C) 2008 Diego Escalante Urrelo
*/
-#ifndef __SOUP_COOKIE_JAR_DB_H__
-#define __SOUP_COOKIE_JAR_DB_H__ 1
+#pragma once
#include "soup-cookie-jar.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_COOKIE_JAR_DB (soup_cookie_jar_db_get_type ())
-#define SOUP_COOKIE_JAR_DB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_COOKIE_JAR_DB,
SoupCookieJarDB))
-#define SOUP_COOKIE_JAR_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_COOKIE_JAR_DB,
SoupCookieJarDBClass))
-#define SOUP_IS_COOKIE_JAR_DB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_COOKIE_JAR_DB))
-#define SOUP_IS_COOKIE_JAR_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_COOKIE_JAR_DB))
-#define SOUP_COOKIE_JAR_DB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_COOKIE_JAR_DB,
SoupCookieJarDBClass))
-
-typedef struct {
- SoupCookieJar parent;
-
-} SoupCookieJarDB;
-
-typedef struct {
- SoupCookieJarClass parent_class;
-
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupCookieJarDBClass;
+#define SOUP_TYPE_COOKIE_JAR_DB (soup_cookie_jar_db_get_type ())
+SOUP_AVAILABLE_IN_2_42
+G_DECLARE_FINAL_TYPE (SoupCookieJarDB, soup_cookie_jar_db, SOUP, COOKIE_JAR_DB, SoupCookieJar)
#define SOUP_COOKIE_JAR_DB_FILENAME "filename"
-SOUP_AVAILABLE_IN_2_42
-GType soup_cookie_jar_db_get_type (void);
-
SOUP_AVAILABLE_IN_2_42
SoupCookieJar *soup_cookie_jar_db_new (const char *filename,
gboolean read_only);
G_END_DECLS
-
-#endif /* __SOUP_COOKIE_JAR_DB_H__ */
diff --git a/libsoup/cookies/soup-cookie-jar-text.c b/libsoup/cookies/soup-cookie-jar-text.c
index a187ced9..31c0d891 100644
--- a/libsoup/cookies/soup-cookie-jar-text.c
+++ b/libsoup/cookies/soup-cookie-jar-text.c
@@ -32,6 +32,12 @@ enum {
LAST_PROP
};
+struct _SoupCookieJarText {
+ SoupCookieJar parent;
+
+};
+
+
typedef struct {
char *filename;
diff --git a/libsoup/cookies/soup-cookie-jar-text.h b/libsoup/cookies/soup-cookie-jar-text.h
index 1566596a..80135484 100644
--- a/libsoup/cookies/soup-cookie-jar-text.h
+++ b/libsoup/cookies/soup-cookie-jar-text.h
@@ -3,44 +3,21 @@
* Copyright (C) 2008 Red Hat, Inc.
*/
-#ifndef __SOUP_COOKIE_JAR_TEXT_H__
-#define __SOUP_COOKIE_JAR_TEXT_H__ 1
+#pragma once
#include "soup-cookie-jar.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_COOKIE_JAR_TEXT (soup_cookie_jar_text_get_type ())
-#define SOUP_COOKIE_JAR_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_COOKIE_JAR_TEXT,
SoupCookieJarText))
-#define SOUP_COOKIE_JAR_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_COOKIE_JAR_TEXT,
SoupCookieJarTextClass))
-#define SOUP_IS_COOKIE_JAR_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_COOKIE_JAR_TEXT))
-#define SOUP_IS_COOKIE_JAR_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_COOKIE_JAR_TEXT))
-#define SOUP_COOKIE_JAR_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_COOKIE_JAR_TEXT,
SoupCookieJarTextClass))
-
-typedef struct {
- SoupCookieJar parent;
-
-} SoupCookieJarText;
-
-typedef struct {
- SoupCookieJarClass parent_class;
-
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupCookieJarTextClass;
+#define SOUP_TYPE_COOKIE_JAR_TEXT (soup_cookie_jar_text_get_type ())
+SOUP_AVAILABLE_IN_2_26
+G_DECLARE_FINAL_TYPE (SoupCookieJarText, soup_cookie_jar_text, SOUP, COOKIE_JAR_TEXT, SoupCookieJar)
#define SOUP_COOKIE_JAR_TEXT_FILENAME "filename"
-SOUP_AVAILABLE_IN_2_26
-GType soup_cookie_jar_text_get_type (void);
-
SOUP_AVAILABLE_IN_2_26
SoupCookieJar *soup_cookie_jar_text_new (const char *filename,
gboolean read_only);
G_END_DECLS
-#endif /* __SOUP_COOKIE_JAR_TEXT_H__ */
diff --git a/libsoup/cookies/soup-cookie-jar.h b/libsoup/cookies/soup-cookie-jar.h
index 793e503c..32c0a15e 100644
--- a/libsoup/cookies/soup-cookie-jar.h
+++ b/libsoup/cookies/soup-cookie-jar.h
@@ -3,26 +3,17 @@
* Copyright (C) 2008 Red Hat, Inc.
*/
-#ifndef __SOUP_COOKIE_JAR_H__
-#define __SOUP_COOKIE_JAR_H__ 1
+#pragma once
#include "soup-types.h"
G_BEGIN_DECLS
#define SOUP_TYPE_COOKIE_JAR (soup_cookie_jar_get_type ())
-#define SOUP_COOKIE_JAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_COOKIE_JAR,
SoupCookieJar))
-#define SOUP_COOKIE_JAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_COOKIE_JAR,
SoupCookieJarClass))
-#define SOUP_IS_COOKIE_JAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_COOKIE_JAR))
-#define SOUP_IS_COOKIE_JAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_COOKIE_JAR))
-#define SOUP_COOKIE_JAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_COOKIE_JAR,
SoupCookieJarClass))
-
-struct _SoupCookieJar {
- GObject parent;
-
-};
+SOUP_AVAILABLE_IN_2_24
+G_DECLARE_DERIVABLE_TYPE (SoupCookieJar, soup_cookie_jar, SOUP, COOKIE_JAR, GObject)
-typedef struct {
+struct _SoupCookieJarClass {
GObjectClass parent_class;
void (*save) (SoupCookieJar *jar);
@@ -34,9 +25,8 @@ typedef struct {
SoupCookie *new_cookie);
/* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
-} SoupCookieJarClass;
+ gpointer padding[6];
+};
#define SOUP_COOKIE_JAR_READ_ONLY "read-only"
#define SOUP_COOKIE_JAR_ACCEPT_POLICY "accept-policy"
@@ -48,8 +38,6 @@ typedef enum {
SOUP_COOKIE_JAR_ACCEPT_GRANDFATHERED_THIRD_PARTY
} SoupCookieJarAcceptPolicy;
-SOUP_AVAILABLE_IN_2_24
-GType soup_cookie_jar_get_type (void);
SOUP_AVAILABLE_IN_2_24
SoupCookieJar * soup_cookie_jar_new (void);
SOUP_AVAILABLE_IN_2_24
@@ -104,5 +92,3 @@ SOUP_AVAILABLE_IN_2_40
gboolean soup_cookie_jar_is_persistent (SoupCookieJar *jar);
G_END_DECLS
-
-#endif /* __SOUP_COOKIE_JAR_H__ */
diff --git a/libsoup/cookies/soup-cookie.h b/libsoup/cookies/soup-cookie.h
index 275960cc..eb533a55 100644
--- a/libsoup/cookies/soup-cookie.h
+++ b/libsoup/cookies/soup-cookie.h
@@ -3,8 +3,7 @@
* Copyright 2007, 2008 Red Hat, Inc.
*/
-#ifndef __SOUP_COOKIE_H__
-#define __SOUP_COOKIE_H__ 1
+#pragma once
#include "soup-types.h"
@@ -137,6 +136,6 @@ SOUP_AVAILABLE_IN_2_30
gboolean soup_cookie_domain_matches (SoupCookie *cookie,
const char *host);
-G_END_DECLS
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupCookie, soup_cookie_free)
-#endif /* __SOUP_COOKIE_H__ */
+G_END_DECLS
diff --git a/libsoup/hsts/soup-hsts-enforcer-db.c b/libsoup/hsts/soup-hsts-enforcer-db.c
index bad688a0..1caa46bf 100644
--- a/libsoup/hsts/soup-hsts-enforcer-db.c
+++ b/libsoup/hsts/soup-hsts-enforcer-db.c
@@ -34,10 +34,14 @@ enum {
LAST_PROP
};
-struct _SoupHSTSEnforcerDBPrivate {
+struct _SoupHSTSEnforcerDB {
+ SoupHSTSEnforcer parent;
+};
+
+typedef struct {
char *filename;
sqlite3 *db;
-};
+} SoupHSTSEnforcerDBPrivate;
G_DEFINE_TYPE_WITH_CODE (SoupHSTSEnforcerDB, soup_hsts_enforcer_db, SOUP_TYPE_HSTS_ENFORCER,
G_ADD_PRIVATE(SoupHSTSEnforcerDB))
@@ -47,13 +51,12 @@ static void load (SoupHSTSEnforcer *hsts_enforcer);
static void
soup_hsts_enforcer_db_init (SoupHSTSEnforcerDB *db)
{
- db->priv = soup_hsts_enforcer_db_get_instance_private (db);
}
static void
soup_hsts_enforcer_db_finalize (GObject *object)
{
- SoupHSTSEnforcerDBPrivate *priv = SOUP_HSTS_ENFORCER_DB (object)->priv;
+ SoupHSTSEnforcerDBPrivate *priv = soup_hsts_enforcer_db_get_instance_private
((SoupHSTSEnforcerDB*)object);
g_free (priv->filename);
sqlite3_close (priv->db);
@@ -65,7 +68,7 @@ static void
soup_hsts_enforcer_db_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- SoupHSTSEnforcerDBPrivate *priv = SOUP_HSTS_ENFORCER_DB (object)->priv;
+ SoupHSTSEnforcerDBPrivate *priv = soup_hsts_enforcer_db_get_instance_private
((SoupHSTSEnforcerDB*)object);
switch (prop_id) {
case PROP_FILENAME:
@@ -82,7 +85,7 @@ static void
soup_hsts_enforcer_db_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
- SoupHSTSEnforcerDBPrivate *priv = SOUP_HSTS_ENFORCER_DB (object)->priv;
+ SoupHSTSEnforcerDBPrivate *priv = soup_hsts_enforcer_db_get_instance_private
((SoupHSTSEnforcerDB*)object);
switch (prop_id) {
case PROP_FILENAME:
@@ -212,7 +215,7 @@ try_exec:
static gboolean
open_db (SoupHSTSEnforcer *hsts_enforcer)
{
- SoupHSTSEnforcerDBPrivate *priv = SOUP_HSTS_ENFORCER_DB (hsts_enforcer)->priv;
+ SoupHSTSEnforcerDBPrivate *priv = soup_hsts_enforcer_db_get_instance_private
((SoupHSTSEnforcerDB*)hsts_enforcer);
char *error = NULL;
@@ -234,7 +237,7 @@ open_db (SoupHSTSEnforcer *hsts_enforcer)
static void
load (SoupHSTSEnforcer *hsts_enforcer)
{
- SoupHSTSEnforcerDBPrivate *priv = SOUP_HSTS_ENFORCER_DB (hsts_enforcer)->priv;
+ SoupHSTSEnforcerDBPrivate *priv = soup_hsts_enforcer_db_get_instance_private
((SoupHSTSEnforcerDB*)hsts_enforcer);
if (priv->db == NULL) {
if (open_db (hsts_enforcer))
@@ -249,7 +252,7 @@ soup_hsts_enforcer_db_changed (SoupHSTSEnforcer *hsts_enforcer,
SoupHSTSPolicy *old_policy,
SoupHSTSPolicy *new_policy)
{
- SoupHSTSEnforcerDBPrivate *priv = SOUP_HSTS_ENFORCER_DB (hsts_enforcer)->priv;
+ SoupHSTSEnforcerDBPrivate *priv = soup_hsts_enforcer_db_get_instance_private
((SoupHSTSEnforcerDB*)hsts_enforcer);
char *query;
/* Session policies do not need to be stored in the database. */
diff --git a/libsoup/hsts/soup-hsts-enforcer-db.h b/libsoup/hsts/soup-hsts-enforcer-db.h
index ae93d71f..2ff3ba1f 100644
--- a/libsoup/hsts/soup-hsts-enforcer-db.h
+++ b/libsoup/hsts/soup-hsts-enforcer-db.h
@@ -4,47 +4,19 @@
* Copyright (C) 2017, 2018 Metrological Group B.V.
*/
-#ifndef __SOUP_HSTS_ENFORCER_DB_H__
-#define __SOUP_HSTS_ENFORCER_DB_H__ 1
+#pragma once
#include "soup-hsts-enforcer.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_HSTS_ENFORCER_DB (soup_hsts_enforcer_db_get_type ())
-#define SOUP_HSTS_ENFORCER_DB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SOUP_TYPE_HSTS_ENFORCER_DB, SoupHSTSEnforcerDB))
-#define SOUP_HSTS_ENFORCER_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_HSTS_ENFORCER_DB,
SoupHSTSEnforcerDBClass))
-#define SOUP_IS_HSTS_ENFORCER_DB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
SOUP_TYPE_HSTS_ENFORCER_DB))
-#define SOUP_IS_HSTS_ENFORCER_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_HSTS_ENFORCER_DB))
-#define SOUP_HSTS_ENFORCER_DB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_HSTS_ENFORCER_DB,
SoupHSTSEnforcerDBClass))
-
-typedef struct _SoupHSTSEnforcerDBPrivate SoupHSTSEnforcerDBPrivate;
-
-typedef struct {
- SoupHSTSEnforcer parent;
-
- SoupHSTSEnforcerDBPrivate *priv;
-
-} SoupHSTSEnforcerDB;
-
-typedef struct {
- SoupHSTSEnforcerClass parent_class;
-
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupHSTSEnforcerDBClass;
+#define SOUP_TYPE_HSTS_ENFORCER_DB (soup_hsts_enforcer_db_get_type ())
+SOUP_AVAILABLE_IN_2_68
+G_DECLARE_FINAL_TYPE (SoupHSTSEnforcerDB, soup_hsts_enforcer_db, SOUP, HSTS_ENFORCER_DB, SoupHSTSEnforcer)
#define SOUP_HSTS_ENFORCER_DB_FILENAME "filename"
-SOUP_AVAILABLE_IN_2_68
-GType soup_hsts_enforcer_db_get_type (void);
-
SOUP_AVAILABLE_IN_2_68
SoupHSTSEnforcer *soup_hsts_enforcer_db_new (const char *filename);
G_END_DECLS
-
-#endif /* __SOUP_HSTS_ENFORCER_DB_H__ */
diff --git a/libsoup/hsts/soup-hsts-enforcer.c b/libsoup/hsts/soup-hsts-enforcer.c
index 3d30054e..e3fc2e58 100644
--- a/libsoup/hsts/soup-hsts-enforcer.c
+++ b/libsoup/hsts/soup-hsts-enforcer.c
@@ -53,11 +53,11 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-struct _SoupHSTSEnforcerPrivate {
+typedef struct {
SoupSession *session;
GHashTable *host_policies;
GHashTable *session_policies;
-};
+} SoupHSTSEnforcerPrivate;
G_DEFINE_TYPE_WITH_CODE (SoupHSTSEnforcer, soup_hsts_enforcer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
@@ -67,13 +67,13 @@ G_DEFINE_TYPE_WITH_CODE (SoupHSTSEnforcer, soup_hsts_enforcer, G_TYPE_OBJECT,
static void
soup_hsts_enforcer_init (SoupHSTSEnforcer *hsts_enforcer)
{
- hsts_enforcer->priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
- hsts_enforcer->priv->host_policies = g_hash_table_new_full (soup_str_case_hash,
+ priv->host_policies = g_hash_table_new_full (soup_str_case_hash,
soup_str_case_equal,
g_free, NULL);
- hsts_enforcer->priv->session_policies = g_hash_table_new_full (soup_str_case_hash,
+ priv->session_policies = g_hash_table_new_full (soup_str_case_hash,
soup_str_case_equal,
g_free, NULL);
}
@@ -81,7 +81,7 @@ soup_hsts_enforcer_init (SoupHSTSEnforcer *hsts_enforcer)
static void
soup_hsts_enforcer_finalize (GObject *object)
{
- SoupHSTSEnforcerPrivate *priv = SOUP_HSTS_ENFORCER (object)->priv;
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private ((SoupHSTSEnforcer*)object);
GHashTableIter iter;
gpointer key, value;
@@ -108,14 +108,16 @@ static SoupHSTSPolicy *
soup_hsts_enforcer_get_host_policy (SoupHSTSEnforcer *hsts_enforcer,
const char *domain)
{
- return g_hash_table_lookup (hsts_enforcer->priv->host_policies, domain);
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
+ return g_hash_table_lookup (priv->host_policies, domain);
}
static SoupHSTSPolicy *
soup_hsts_enforcer_get_session_policy (SoupHSTSEnforcer *hsts_enforcer,
const char *domain)
{
- return g_hash_table_lookup (hsts_enforcer->priv->session_policies, domain);
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
+ return g_hash_table_lookup (priv->session_policies, domain);
}
static gboolean
@@ -240,7 +242,8 @@ should_remove_expired_host_policy (G_GNUC_UNUSED gpointer key,
static void
remove_expired_host_policies (SoupHSTSEnforcer *hsts_enforcer)
{
- g_hash_table_foreach_remove (hsts_enforcer->priv->host_policies,
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
+ g_hash_table_foreach_remove (priv->host_policies,
(GHRFunc)should_remove_expired_host_policy,
hsts_enforcer);
}
@@ -249,14 +252,15 @@ static void
soup_hsts_enforcer_remove_host_policy (SoupHSTSEnforcer *hsts_enforcer,
const char *domain)
{
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
SoupHSTSPolicy *policy;
- policy = g_hash_table_lookup (hsts_enforcer->priv->host_policies, domain);
+ policy = g_hash_table_lookup (priv->host_policies, domain);
if (!policy)
return;
- g_hash_table_remove (hsts_enforcer->priv->host_policies, domain);
+ g_hash_table_remove (priv->host_policies, domain);
soup_hsts_enforcer_changed (hsts_enforcer, policy, NULL);
soup_hsts_policy_free (policy);
@@ -267,6 +271,7 @@ static void
soup_hsts_enforcer_replace_policy (SoupHSTSEnforcer *hsts_enforcer,
SoupHSTSPolicy *new_policy)
{
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
GHashTable *policies;
SoupHSTSPolicy *old_policy;
const char *domain;
@@ -277,8 +282,8 @@ soup_hsts_enforcer_replace_policy (SoupHSTSEnforcer *hsts_enforcer,
domain = soup_hsts_policy_get_domain (new_policy);
is_session_policy = soup_hsts_policy_is_session_policy (new_policy);
- policies = is_session_policy ? hsts_enforcer->priv->session_policies :
- hsts_enforcer->priv->host_policies;
+ policies = is_session_policy ? priv->session_policies :
+ priv->host_policies;
old_policy = g_hash_table_lookup (policies, domain);
g_assert (old_policy);
@@ -295,6 +300,7 @@ static void
soup_hsts_enforcer_insert_policy (SoupHSTSEnforcer *hsts_enforcer,
SoupHSTSPolicy *policy)
{
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
GHashTable *policies;
const char *domain;
gboolean is_session_policy;
@@ -309,8 +315,8 @@ soup_hsts_enforcer_insert_policy (SoupHSTSEnforcer *hsts_enforcer,
g_return_if_fail (domain != NULL);
- policies = is_session_policy ? hsts_enforcer->priv->session_policies :
- hsts_enforcer->priv->host_policies;
+ policies = is_session_policy ? priv->session_policies :
+ priv->host_policies;
g_assert (!g_hash_table_contains (policies, domain));
@@ -337,6 +343,7 @@ void
soup_hsts_enforcer_set_policy (SoupHSTSEnforcer *hsts_enforcer,
SoupHSTSPolicy *policy)
{
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
GHashTable *policies;
const char *domain;
gboolean is_session_policy;
@@ -349,8 +356,8 @@ soup_hsts_enforcer_set_policy (SoupHSTSEnforcer *hsts_enforcer,
g_return_if_fail (domain != NULL);
is_session_policy = soup_hsts_policy_is_session_policy (policy);
- policies = is_session_policy ? hsts_enforcer->priv->session_policies :
- hsts_enforcer->priv->host_policies;
+ policies = is_session_policy ? priv->session_policies :
+ priv->host_policies;
if (!is_session_policy && soup_hsts_policy_is_expired (policy)) {
soup_hsts_enforcer_remove_host_policy (hsts_enforcer, domain);
@@ -496,8 +503,9 @@ rewrite_message_uri_to_https (SoupMessage *msg)
}
static void
-on_sts_known_host_message_starting (SoupMessage *msg, SoupHSTSEnforcer *enforcer)
+on_sts_known_host_message_starting (SoupMessage *msg, SoupHSTSEnforcer *hsts_enforcer)
{
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
GTlsCertificateFlags errors;
/* THE UA MUST terminate the connection if there are
@@ -506,7 +514,7 @@ on_sts_known_host_message_starting (SoupMessage *msg, SoupHSTSEnforcer *enforcer
soup_message_get_https_status (msg, NULL, &errors);
if (errors)
- soup_session_cancel_message (enforcer->priv->session, msg, SOUP_STATUS_CANCELLED);
+ soup_session_cancel_message (priv->session, msg, SOUP_STATUS_CANCELLED);
}
static void
@@ -556,7 +564,8 @@ message_restarted_cb (SoupMessage *msg, gpointer user_data)
static void
soup_hsts_enforcer_attach (SoupSessionFeature *feature, SoupSession *session)
{
- SOUP_HSTS_ENFORCER (feature)->priv->session = session;
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (SOUP_HSTS_ENFORCER
(feature));
+ priv->session = session;
if (soup_hsts_enforcer_default_feature_interface->attach)
soup_hsts_enforcer_default_feature_interface->attach (feature, session);
@@ -677,13 +686,14 @@ GList*
soup_hsts_enforcer_get_domains (SoupHSTSEnforcer *hsts_enforcer,
gboolean session_policies)
{
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
GList *domains = NULL;
g_return_val_if_fail (SOUP_IS_HSTS_ENFORCER (hsts_enforcer), NULL);
- g_hash_table_foreach (hsts_enforcer->priv->host_policies, add_domain_to_list, &domains);
+ g_hash_table_foreach (priv->host_policies, add_domain_to_list, &domains);
if (session_policies)
- g_hash_table_foreach (hsts_enforcer->priv->session_policies, add_domain_to_list, &domains);
+ g_hash_table_foreach (priv->session_policies, add_domain_to_list, &domains);
return domains;
}
@@ -715,13 +725,14 @@ GList*
soup_hsts_enforcer_get_policies (SoupHSTSEnforcer *hsts_enforcer,
gboolean session_policies)
{
+ SoupHSTSEnforcerPrivate *priv = soup_hsts_enforcer_get_instance_private (hsts_enforcer);
GList *policies = NULL;
g_return_val_if_fail (SOUP_IS_HSTS_ENFORCER (hsts_enforcer), NULL);
- g_hash_table_foreach (hsts_enforcer->priv->host_policies, add_policy_to_list, &policies);
+ g_hash_table_foreach (priv->host_policies, add_policy_to_list, &policies);
if (session_policies)
- g_hash_table_foreach (hsts_enforcer->priv->session_policies, add_policy_to_list, &policies);
+ g_hash_table_foreach (priv->session_policies, add_policy_to_list, &policies);
return policies;
}
diff --git a/libsoup/hsts/soup-hsts-enforcer.h b/libsoup/hsts/soup-hsts-enforcer.h
index bb80825a..ba7d43f5 100644
--- a/libsoup/hsts/soup-hsts-enforcer.h
+++ b/libsoup/hsts/soup-hsts-enforcer.h
@@ -4,27 +4,15 @@
* Copyright (C) 2017, 2018 Metrological Group B.V.
*/
-#ifndef __SOUP_HSTS_ENFORCER_H__
-#define __SOUP_HSTS_ENFORCER_H__ 1
+#pragma once
#include "soup-types.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_HSTS_ENFORCER (soup_hsts_enforcer_get_type ())
-#define SOUP_HSTS_ENFORCER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SOUP_TYPE_HSTS_ENFORCER, SoupHSTSEnforcer))
-#define SOUP_HSTS_ENFORCER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
SOUP_TYPE_HSTS_ENFORCER, SoupHSTSEnforcerClass))
-#define SOUP_IS_HSTS_ENFORCER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_HSTS_ENFORCER))
-#define SOUP_IS_HSTS_ENFORCER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_HSTS_ENFORCER))
-#define SOUP_HSTS_ENFORCER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_HSTS_ENFORCER,
SoupHSTSEnforcerClass))
-
-typedef struct _SoupHSTSEnforcerPrivate SoupHSTSEnforcerPrivate;
-
-struct _SoupHSTSEnforcer {
- GObject parent;
-
- SoupHSTSEnforcerPrivate *priv;
-};
+#define SOUP_TYPE_HSTS_ENFORCER (soup_hsts_enforcer_get_type ())
+SOUP_AVAILABLE_IN_2_68
+G_DECLARE_DERIVABLE_TYPE (SoupHSTSEnforcer, soup_hsts_enforcer, SOUP, HSTS_ENFORCER, GObject)
/**
* SoupHSTSEnforcerClass:
@@ -38,7 +26,7 @@ struct _SoupHSTSEnforcer {
* policies.
* @changed: the class closure for the #SoupHSTSEnforcer::changed signal.
**/
-typedef struct {
+struct _SoupHSTSEnforcerClass {
GObjectClass parent_class;
gboolean (*is_persistent) (SoupHSTSEnforcer *hsts_enforcer);
@@ -52,15 +40,9 @@ typedef struct {
void (*hsts_enforced) (SoupHSTSEnforcer *enforcer,
SoupMessage *message);
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupHSTSEnforcerClass;
+ gpointer padding[4];
+};
-SOUP_AVAILABLE_IN_2_68
-GType soup_hsts_enforcer_get_type (void);
SOUP_AVAILABLE_IN_2_68
SoupHSTSEnforcer *soup_hsts_enforcer_new (void);
SOUP_AVAILABLE_IN_2_68
@@ -85,5 +67,3 @@ GList *soup_hsts_enforcer_get_policies (SoupHSTSEnfo
gboolean session_policies);
G_END_DECLS
-
-#endif /* __SOUP_HSTS_ENFORCER_H__ */
diff --git a/libsoup/hsts/soup-hsts-policy.h b/libsoup/hsts/soup-hsts-policy.h
index b86aca02..b55f496b 100644
--- a/libsoup/hsts/soup-hsts-policy.h
+++ b/libsoup/hsts/soup-hsts-policy.h
@@ -4,8 +4,7 @@
* Copyright (C) 2017, 2018 Metrological Group B.V.
*/
-#ifndef __SOUP_HSTS_POLICY_H__
-#define __SOUP_HSTS_POLICY_H__ 1
+#pragma once
#include "soup-types.h"
@@ -56,6 +55,6 @@ gboolean soup_hsts_policy_is_session_policy (SoupHSTSPolicy *policy);
SOUP_AVAILABLE_IN_2_68
void soup_hsts_policy_free (SoupHSTSPolicy *policy);
-G_END_DECLS
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SoupHSTSPolicy, soup_hsts_policy_free)
-#endif /* __SOUP_HSTS_POLICY_H__ */
+G_END_DECLS
diff --git a/libsoup/include/soup-installed.h b/libsoup/include/soup-installed.h
index 1e1a0ebd..cf08bbd2 100644
--- a/libsoup/include/soup-installed.h
+++ b/libsoup/include/soup-installed.h
@@ -13,10 +13,14 @@ extern "C" {
#define __SOUP_H_INSIDE__
#include <libsoup/soup-auth.h>
+#include <libsoup/soup-auth-basic.h>
+#include <libsoup/soup-auth-digest.h>
#include <libsoup/soup-auth-domain.h>
#include <libsoup/soup-auth-domain-basic.h>
#include <libsoup/soup-auth-domain-digest.h>
#include <libsoup/soup-auth-manager.h>
+#include <libsoup/soup-auth-negotiate.h>
+#include <libsoup/soup-auth-ntlm.h>
#include <libsoup/soup-cache.h>
#include <libsoup/soup-content-decoder.h>
#include <libsoup/soup-content-sniffer.h>
@@ -53,8 +57,6 @@ extern "C" {
#include <libsoup/soup-websocket-extension-manager.h>
#include <libsoup/soup-xmlrpc.h>
-#include <libsoup/soup-autocleanups.h>
-
#undef __SOUP_H_INSIDE__
#ifdef __cplusplus
diff --git a/libsoup/meson.build b/libsoup/meson.build
index 8ad52c92..2515ba35 100644
--- a/libsoup/meson.build
+++ b/libsoup/meson.build
@@ -93,6 +93,8 @@ soup_private_enum_headers = [
soup_introspection_headers = [
'auth/soup-auth.h',
+ 'auth/soup-auth-basic.h',
+ 'auth/soup-auth-digest.h',
'auth/soup-auth-domain.h',
'auth/soup-auth-domain-basic.h',
'auth/soup-auth-domain-digest.h',
@@ -123,8 +125,6 @@ soup_introspection_headers = [
'xmlrpc/soup-xmlrpc.h',
- 'soup-autocleanups.h',
-
'soup-date.h',
'soup-form.h',
'soup-headers.h',
diff --git a/libsoup/soup-date.h b/libsoup/soup-date.h
index b0b5b395..cbb0798f 100644
--- a/libsoup/soup-date.h
+++ b/libsoup/soup-date.h
@@ -4,8 +4,7 @@
* Copyright (C) 2007 Red Hat, Inc.
*/
-#ifndef __SOUP_DATE_H__
-#define __SOUP_DATE_H__ 1
+#pragma once
#include <time.h>
#include "soup-types.h"
@@ -84,6 +83,6 @@ SoupDate *soup_date_copy (SoupDate *date);
SOUP_AVAILABLE_IN_2_24
void soup_date_free (SoupDate *date);
-G_END_DECLS
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SoupDate, soup_date_free)
-#endif /* __SOUP_DATE_H__ */
+G_END_DECLS
diff --git a/libsoup/soup-logger.c b/libsoup/soup-logger.c
index 2ba6ce52..50297dc8 100644
--- a/libsoup/soup-logger.c
+++ b/libsoup/soup-logger.c
@@ -89,6 +89,12 @@
* event of the #SoupMessage::finished signal.
**/
+struct _SoupLogger {
+ GObject parent;
+
+};
+
+
typedef struct {
/* We use a mutex so that if requests are being run in
* multiple threads, we don't mix up the output.
diff --git a/libsoup/soup-logger.h b/libsoup/soup-logger.h
index 06c9cef4..e6c6b409 100644
--- a/libsoup/soup-logger.h
+++ b/libsoup/soup-logger.h
@@ -3,19 +3,15 @@
* Copyright (C) 2008 Red Hat, Inc.
*/
-#ifndef __SOUP_LOGGER_H__
-#define __SOUP_LOGGER_H__ 1
+#pragma once
#include "soup-types.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_LOGGER (soup_logger_get_type ())
-#define SOUP_LOGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_LOGGER, SoupLogger))
-#define SOUP_LOGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_LOGGER, SoupLoggerClass))
-#define SOUP_IS_LOGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_LOGGER))
-#define SOUP_IS_LOGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_LOGGER))
-#define SOUP_LOGGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_LOGGER, SoupLoggerClass))
+#define SOUP_TYPE_LOGGER (soup_logger_get_type ())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_FINAL_TYPE (SoupLogger, soup_logger, SOUP, LOGGER, GObject)
typedef enum {
SOUP_LOGGER_LOG_NONE,
@@ -24,21 +20,6 @@ typedef enum {
SOUP_LOGGER_LOG_BODY
} SoupLoggerLogLevel;
-typedef struct {
- GObject parent;
-
-} SoupLogger;
-
-typedef struct {
- GObjectClass parent_class;
-
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupLoggerClass;
-
typedef SoupLoggerLogLevel (*SoupLoggerFilter) (SoupLogger *logger,
SoupMessage *msg,
gpointer user_data);
@@ -49,8 +30,6 @@ typedef void (*SoupLoggerPrinter) (SoupLogger *logger,
const char *data,
gpointer user_data);
-SOUP_AVAILABLE_IN_2_4
-GType soup_logger_get_type (void);
#define SOUP_LOGGER_LEVEL "level"
#define SOUP_LOGGER_MAX_BODY_SIZE "max-body-size"
@@ -77,5 +56,3 @@ void soup_logger_set_printer (SoupLogger *logger,
GDestroyNotify destroy);
G_END_DECLS
-
-#endif /* __SOUP_LOGGER_H__ */
diff --git a/libsoup/soup-message-body.h b/libsoup/soup-message-body.h
index 60c29333..c08e26ae 100644
--- a/libsoup/soup-message-body.h
+++ b/libsoup/soup-message-body.h
@@ -3,8 +3,7 @@
* Copyright (C) 2000-2003, Ximian, Inc.
*/
-#ifndef __SOUP_MESSAGE_BODY_H__
-#define __SOUP_MESSAGE_BODY_H__ 1
+#pragma once
#include "soup-types.h"
@@ -109,6 +108,7 @@ void soup_message_body_wrote_chunk (SoupMessageBody *body,
SOUP_AVAILABLE_IN_2_4
void soup_message_body_free (SoupMessageBody *body);
-G_END_DECLS
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SoupBuffer, soup_buffer_free)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SoupMessageBody, soup_message_body_free)
-#endif /* __SOUP_MESSAGE_BODY_H__ */
+G_END_DECLS
diff --git a/libsoup/soup-message-headers.h b/libsoup/soup-message-headers.h
index a55158fb..f69e093a 100644
--- a/libsoup/soup-message-headers.h
+++ b/libsoup/soup-message-headers.h
@@ -3,8 +3,7 @@
* Copyright (C) 2005 Novell, Inc.
*/
-#ifndef __SOUP_MESSAGE_HEADERS_H__
-#define __SOUP_MESSAGE_HEADERS_H__ 1
+#pragma once
#include "soup-types.h"
@@ -170,6 +169,6 @@ void soup_message_headers_set_content_disposition (SoupMessageHeaders *hdrs
const char *disposition,
GHashTable *params);
-G_END_DECLS
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SoupMessageHeaders, soup_message_headers_free)
-#endif /* __SOUP_MESSAGE_HEADERS_H__ */
+G_END_DECLS
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index 6a104e1c..302630ba 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -277,10 +277,10 @@ read_headers (SoupMessage *msg, gboolean blocking,
static gint
processing_stage_cmp (gconstpointer a,
- gconstpointer b)
+ gconstpointer b)
{
- SoupProcessingStage stage_a = soup_content_processor_get_processing_stage (SOUP_CONTENT_PROCESSOR
(a));
- SoupProcessingStage stage_b = soup_content_processor_get_processing_stage (SOUP_CONTENT_PROCESSOR
(b));
+ SoupProcessingStage stage_a = soup_content_processor_get_processing_stage (SOUP_CONTENT_PROCESSOR
((gpointer)a));
+ SoupProcessingStage stage_b = soup_content_processor_get_processing_stage (SOUP_CONTENT_PROCESSOR
((gpointer)b));
if (stage_a > stage_b)
return 1;
diff --git a/libsoup/soup-method.h b/libsoup/soup-method.h
index 1a6a38c1..b5a002d8 100644
--- a/libsoup/soup-method.h
+++ b/libsoup/soup-method.h
@@ -3,8 +3,7 @@
* Copyright (C) 2008 Red Hat, Inc.
*/
-#ifndef __SOUP_METHOD_H__
-#define __SOUP_METHOD_H__ 1
+#pragma once
#include "soup-types.h"
@@ -75,5 +74,3 @@ SOUP_VAR gpointer _SOUP_METHOD_LOCK;
SOUP_VAR gpointer _SOUP_METHOD_UNLOCK;
G_END_DECLS
-
-#endif /* __SOUP_METHOD_H__ */
diff --git a/libsoup/soup-multipart-input-stream.c b/libsoup/soup-multipart-input-stream.c
index 535dd6ec..f17d0c3a 100644
--- a/libsoup/soup-multipart-input-stream.c
+++ b/libsoup/soup-multipart-input-stream.c
@@ -43,7 +43,11 @@ enum {
PROP_MESSAGE,
};
-struct _SoupMultipartInputStreamPrivate {
+struct _SoupMultipartInputStream {
+ GFilterInputStream parent_instance;
+};
+
+typedef struct {
SoupMessage *msg;
gboolean done_with_part;
@@ -57,7 +61,7 @@ struct _SoupMultipartInputStreamPrivate {
gsize boundary_size;
goffset remaining_bytes;
-};
+} SoupMultipartInputStreamPrivate;
static void soup_multipart_input_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
gpointer interface_data);
@@ -70,9 +74,10 @@ static void
soup_multipart_input_stream_dispose (GObject *object)
{
SoupMultipartInputStream *multipart = SOUP_MULTIPART_INPUT_STREAM (object);
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
- g_clear_object (&multipart->priv->msg);
- g_clear_object (&multipart->priv->base_stream);
+ g_clear_object (&priv->msg);
+ g_clear_object (&priv->base_stream);
G_OBJECT_CLASS (soup_multipart_input_stream_parent_class)->dispose (object);
}
@@ -81,11 +86,12 @@ static void
soup_multipart_input_stream_finalize (GObject *object)
{
SoupMultipartInputStream *multipart = SOUP_MULTIPART_INPUT_STREAM (object);
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
- g_free (multipart->priv->boundary);
+ g_free (priv->boundary);
- if (multipart->priv->meta_buf)
- g_clear_pointer (&multipart->priv->meta_buf, g_byte_array_unref);
+ if (priv->meta_buf)
+ g_clear_pointer (&priv->meta_buf, g_byte_array_unref);
G_OBJECT_CLASS (soup_multipart_input_stream_parent_class)->finalize (object);
}
@@ -95,10 +101,11 @@ soup_multipart_input_stream_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
SoupMultipartInputStream *multipart = SOUP_MULTIPART_INPUT_STREAM (object);
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
switch (prop_id) {
case PROP_MESSAGE:
- multipart->priv->msg = g_value_dup_object (value);
+ priv->msg = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -111,10 +118,11 @@ soup_multipart_input_stream_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SoupMultipartInputStream *multipart = SOUP_MULTIPART_INPUT_STREAM (object);
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
switch (prop_id) {
case PROP_MESSAGE:
- g_value_set_object (value, multipart->priv->msg);
+ g_value_set_object (value, priv->msg);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -131,7 +139,7 @@ soup_multipart_input_stream_read_real (GInputStream *stream,
GError **error)
{
SoupMultipartInputStream *multipart = SOUP_MULTIPART_INPUT_STREAM (stream);
- SoupMultipartInputStreamPrivate *priv = multipart->priv;
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
gboolean got_boundary = FALSE;
gssize nread = 0;
guint8 *buf;
@@ -201,8 +209,7 @@ soup_multipart_input_stream_read (GInputStream *stream,
static void
soup_multipart_input_stream_init (SoupMultipartInputStream *multipart)
{
- SoupMultipartInputStreamPrivate *priv;
- priv = multipart->priv = soup_multipart_input_stream_get_instance_private (multipart);
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
priv->meta_buf = g_byte_array_sized_new (RESPONSE_BLOCK_SIZE);
priv->done_with_part = FALSE;
@@ -211,15 +218,12 @@ soup_multipart_input_stream_init (SoupMultipartInputStream *multipart)
static void
soup_multipart_input_stream_constructed (GObject *object)
{
- SoupMultipartInputStream *multipart;
- SoupMultipartInputStreamPrivate *priv;
+ SoupMultipartInputStream *multipart = (SoupMultipartInputStream*)object;
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
GInputStream *base_stream;
const char* boundary;
GHashTable *params = NULL;
- multipart = SOUP_MULTIPART_INPUT_STREAM (object);
- priv = multipart->priv;
-
base_stream = G_FILTER_INPUT_STREAM (multipart)->base_stream;
priv->base_stream = SOUP_FILTER_INPUT_STREAM (soup_filter_input_stream_new (base_stream));
@@ -248,7 +252,7 @@ static gboolean
soup_multipart_input_stream_is_readable (GPollableInputStream *stream)
{
SoupMultipartInputStream *multipart = SOUP_MULTIPART_INPUT_STREAM (stream);
- SoupMultipartInputStreamPrivate *priv = multipart->priv;
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
return g_pollable_input_stream_is_readable (G_POLLABLE_INPUT_STREAM (priv->base_stream));
}
@@ -271,7 +275,7 @@ soup_multipart_input_stream_create_source (GPollableInputStream *stream,
GCancellable *cancellable)
{
SoupMultipartInputStream *multipart = SOUP_MULTIPART_INPUT_STREAM (stream);
- SoupMultipartInputStreamPrivate *priv = multipart->priv;
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
GSource *base_source, *pollable_source;
base_source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (priv->base_stream),
cancellable);
@@ -320,7 +324,7 @@ soup_multipart_input_stream_pollable_init (GPollableInputStreamInterface *pollab
static void
soup_multipart_input_stream_parse_headers (SoupMultipartInputStream *multipart)
{
- SoupMultipartInputStreamPrivate *priv = multipart->priv;
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
gboolean success;
priv->current_headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
@@ -346,7 +350,7 @@ soup_multipart_input_stream_read_headers (SoupMultipartInputStream *multipart,
GCancellable *cancellable,
GError **error)
{
- SoupMultipartInputStreamPrivate *priv = multipart->priv;
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
guchar read_buf[RESPONSE_BLOCK_SIZE];
guchar *buf;
gboolean got_boundary = FALSE;
@@ -465,12 +469,14 @@ soup_multipart_input_stream_next_part (SoupMultipartInputStream *multipart,
GCancellable *cancellable,
GError **error)
{
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
+
if (!soup_multipart_input_stream_read_headers (multipart, cancellable, error))
return NULL;
soup_multipart_input_stream_parse_headers (multipart);
- multipart->priv->done_with_part = FALSE;
+ priv->done_with_part = FALSE;
return G_INPUT_STREAM (g_object_new (SOUP_TYPE_BODY_INPUT_STREAM,
"base-stream", G_INPUT_STREAM (multipart),
@@ -587,5 +593,6 @@ soup_multipart_input_stream_next_part_finish (SoupMultipartInputStream *multipar
SoupMessageHeaders *
soup_multipart_input_stream_get_headers (SoupMultipartInputStream *multipart)
{
- return multipart->priv->current_headers;
+ SoupMultipartInputStreamPrivate *priv = soup_multipart_input_stream_get_instance_private (multipart);
+ return priv->current_headers;
}
diff --git a/libsoup/soup-multipart-input-stream.h b/libsoup/soup-multipart-input-stream.h
index e35dfdc3..4e7e3d02 100644
--- a/libsoup/soup-multipart-input-stream.h
+++ b/libsoup/soup-multipart-input-stream.h
@@ -3,38 +3,16 @@
* Copyright (C) 2012 Collabora Ltd.
*/
-#ifndef __SOUP_MULTIPART_INPUT_STREAM_H__
-#define __SOUP_MULTIPART_INPUT_STREAM_H__ 1
+#pragma once
#include "soup-types.h"
#include "soup-message-headers.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_MULTIPART_INPUT_STREAM (soup_multipart_input_stream_get_type ())
-#define SOUP_MULTIPART_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
SOUP_TYPE_MULTIPART_INPUT_STREAM, SoupMultipartInputStream))
-#define SOUP_MULTIPART_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
SOUP_TYPE_MULTIPART_INPUT_STREAM, SoupMultipartInputStreamClass))
-#define SOUP_IS_MULTIPART_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
SOUP_TYPE_MULTIPART_INPUT_STREAM))
-#define SOUP_IS_MULTIPART_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
SOUP_TYPE_MULTIPART_INPUT_STREAM))
-#define SOUP_MULTIPART_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
SOUP_TYPE_MULTIPART_INPUT_STREAM, SoupMultipartInputStreamClass))
-
-typedef struct _SoupMultipartInputStream SoupMultipartInputStream;
-typedef struct _SoupMultipartInputStreamPrivate SoupMultipartInputStreamPrivate;
-typedef struct _SoupMultipartInputStreamClass SoupMultipartInputStreamClass;
-
-struct _SoupMultipartInputStream {
- GFilterInputStream parent_instance;
-
- /*< private >*/
- SoupMultipartInputStreamPrivate *priv;
-};
-
-struct _SoupMultipartInputStreamClass {
- GFilterInputStreamClass parent_class;
-};
-
+#define SOUP_TYPE_MULTIPART_INPUT_STREAM (soup_multipart_input_stream_get_type ())
SOUP_AVAILABLE_IN_2_40
-GType soup_multipart_input_stream_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (SoupMultipartInputStream, soup_multipart_input_stream, SOUP, MULTIPART_INPUT_STREAM,
GFilterInputStream)
SOUP_AVAILABLE_IN_2_40
SoupMultipartInputStream *soup_multipart_input_stream_new (SoupMessage *msg,
@@ -62,5 +40,3 @@ SoupMessageHeaders *soup_multipart_input_stream_get_headers (SoupMult
G_END_DECLS
-
-#endif /* __SOUP_MULTIPART_INPUT_STREAM_H__ */
diff --git a/libsoup/soup-multipart.h b/libsoup/soup-multipart.h
index e37aae44..22675c39 100644
--- a/libsoup/soup-multipart.h
+++ b/libsoup/soup-multipart.h
@@ -3,8 +3,7 @@
* Copyright (C) 2008 Red Hat, Inc.
*/
-#ifndef __SOUP_MULTIPART_H__
-#define __SOUP_MULTIPART_H__ 1
+#pragma once
#include "soup-types.h"
#include "soup-message-body.h"
@@ -56,6 +55,6 @@ void soup_multipart_to_message (SoupMultipart *multipart,
SOUP_AVAILABLE_IN_2_26
void soup_multipart_free (SoupMultipart *multipart);
-G_END_DECLS
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SoupMultipart, soup_multipart_free)
-#endif /* __SOUP_MULTIPART_H__ */
+G_END_DECLS
diff --git a/libsoup/soup-request-data.c b/libsoup/soup-request-data.c
index 7bdffd89..897ad2a6 100644
--- a/libsoup/soup-request-data.c
+++ b/libsoup/soup-request-data.c
@@ -38,26 +38,29 @@
* #SoupRequestData implements #SoupRequest for "data" URIs.
*/
+struct _SoupRequestData {
+ SoupRequest parent;
+};
-struct _SoupRequestDataPrivate {
+typedef struct {
gsize content_length;
char *content_type;
-};
+} SoupRequestDataPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (SoupRequestData, soup_request_data, SOUP_TYPE_REQUEST)
static void
soup_request_data_init (SoupRequestData *data)
{
- data->priv = soup_request_data_get_instance_private (data);
}
static void
soup_request_data_finalize (GObject *object)
{
SoupRequestData *data = SOUP_REQUEST_DATA (object);
+ SoupRequestDataPrivate *priv = soup_request_data_get_instance_private (data);
- g_free (data->priv->content_type);
+ g_free (priv->content_type);
G_OBJECT_CLASS (soup_request_data_parent_class)->finalize (object);
}
@@ -79,6 +82,7 @@ soup_request_data_send (SoupRequest *request,
GError **error)
{
SoupRequestData *data = SOUP_REQUEST_DATA (request);
+ SoupRequestDataPrivate *priv = soup_request_data_get_instance_private (data);
SoupURI *uri = soup_request_get_uri (request);
GInputStream *memstream;
const char *comma, *start, *end;
@@ -97,7 +101,7 @@ soup_request_data_send (SoupRequest *request,
end = comma;
if (end != start)
- data->priv->content_type = soup_uri_decoded_copy (start, end - start, NULL);
+ priv->content_type = soup_uri_decoded_copy (start, end - start, NULL);
}
memstream = g_memory_input_stream_new ();
@@ -111,12 +115,12 @@ soup_request_data_send (SoupRequest *request,
&decoded_length);
if (base64)
- buf = g_base64_decode_inplace ((gchar*) buf, &data->priv->content_length);
+ buf = g_base64_decode_inplace ((gchar*) buf, &priv->content_length);
else
- data->priv->content_length = decoded_length;
+ priv->content_length = decoded_length;
g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (memstream),
- buf, data->priv->content_length,
+ buf, priv->content_length,
g_free);
}
g_free (uristr);
@@ -128,17 +132,19 @@ static goffset
soup_request_data_get_content_length (SoupRequest *request)
{
SoupRequestData *data = SOUP_REQUEST_DATA (request);
+ SoupRequestDataPrivate *priv = soup_request_data_get_instance_private (data);
- return data->priv->content_length;
+ return priv->content_length;
}
static const char *
soup_request_data_get_content_type (SoupRequest *request)
{
SoupRequestData *data = SOUP_REQUEST_DATA (request);
+ SoupRequestDataPrivate *priv = soup_request_data_get_instance_private (data);
- if (data->priv->content_type)
- return data->priv->content_type;
+ if (priv->content_type)
+ return priv->content_type;
else
return "text/plain;charset=US-ASCII";
}
diff --git a/libsoup/soup-request-data.h b/libsoup/soup-request-data.h
index 154a904a..27dc1fe5 100644
--- a/libsoup/soup-request-data.h
+++ b/libsoup/soup-request-data.h
@@ -19,35 +19,14 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __SOUP_REQUEST_DATA_H__
-#define __SOUP_REQUEST_DATA_H__ 1
+#pragma once
#include "soup-request.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_REQUEST_DATA (soup_request_data_get_type ())
-#define SOUP_REQUEST_DATA(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SOUP_TYPE_REQUEST_DATA,
SoupRequestData))
-#define SOUP_REQUEST_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_REQUEST_DATA,
SoupRequestDataClass))
-#define SOUP_IS_REQUEST_DATA(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SOUP_TYPE_REQUEST_DATA))
-#define SOUP_IS_REQUEST_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_REQUEST_DATA))
-#define SOUP_REQUEST_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_REQUEST_DATA,
SoupRequestDataClass))
-
-typedef struct _SoupRequestDataPrivate SoupRequestDataPrivate;
-
-typedef struct {
- SoupRequest parent;
-
- SoupRequestDataPrivate *priv;
-} SoupRequestData;
-
-typedef struct {
- SoupRequestClass parent;
-} SoupRequestDataClass;
-
+#define SOUP_TYPE_REQUEST_DATA (soup_request_data_get_type ())
SOUP_AVAILABLE_IN_2_34
-GType soup_request_data_get_type (void);
+G_DECLARE_FINAL_TYPE (SoupRequestData, soup_request_data, SOUP, REQUEST_DATA, SoupRequest)
G_END_DECLS
-
-#endif /* __SOUP_REQUEST_DATA_H__ */
diff --git a/libsoup/soup-request-file.c b/libsoup/soup-request-file.c
index cdd5d673..740b52a9 100644
--- a/libsoup/soup-request-file.c
+++ b/libsoup/soup-request-file.c
@@ -39,30 +39,35 @@
* URIs.
*/
-struct _SoupRequestFilePrivate {
+struct _SoupRequestFile {
+ SoupRequest parent;
+};
+
+typedef struct {
GFile *gfile;
char *mime_type;
goffset size;
-};
+} SoupRequestFilePrivate;
G_DEFINE_TYPE_WITH_PRIVATE (SoupRequestFile, soup_request_file, SOUP_TYPE_REQUEST)
static void
soup_request_file_init (SoupRequestFile *file)
{
- file->priv = soup_request_file_get_instance_private (file);
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
- file->priv->size = -1;
+ priv->size = -1;
}
static void
soup_request_file_finalize (GObject *object)
{
SoupRequestFile *file = SOUP_REQUEST_FILE (object);
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
- g_clear_object (&file->priv->gfile);
- g_free (file->priv->mime_type);
+ g_clear_object (&priv->gfile);
+ g_free (priv->mime_type);
G_OBJECT_CLASS (soup_request_file_parent_class)->finalize (object);
}
@@ -121,10 +126,11 @@ soup_request_file_ensure_file (SoupRequestFile *file,
GCancellable *cancellable,
GError **error)
{
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
SoupURI *uri;
char *decoded_path;
- if (file->priv->gfile)
+ if (priv->gfile)
return TRUE;
uri = soup_request_get_uri (SOUP_REQUEST (file));
@@ -138,10 +144,10 @@ soup_request_file_ensure_file (SoupRequestFile *file,
char *uri_str;
uri_str = g_strdup_printf ("resource://%s", decoded_path);
- file->priv->gfile = g_file_new_for_uri (uri_str);
+ priv->gfile = g_file_new_for_uri (uri_str);
g_free (uri_str);
} else
- file->priv->gfile = g_file_new_for_path (decoded_path);
+ priv->gfile = g_file_new_for_path (decoded_path);
g_free (decoded_path);
return TRUE;
@@ -153,19 +159,20 @@ soup_request_file_send (SoupRequest *request,
GError **error)
{
SoupRequestFile *file = SOUP_REQUEST_FILE (request);
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
GInputStream *stream;
GError *my_error = NULL;
if (!soup_request_file_ensure_file (file, cancellable, error))
return NULL;
- stream = G_INPUT_STREAM (g_file_read (file->priv->gfile,
+ stream = G_INPUT_STREAM (g_file_read (priv->gfile,
cancellable, &my_error));
if (stream == NULL) {
if (g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY)) {
GFileEnumerator *enumerator;
g_clear_error (&my_error);
- enumerator = g_file_enumerate_children (file->priv->gfile,
+ enumerator = g_file_enumerate_children (priv->gfile,
"*",
G_FILE_QUERY_INFO_NONE,
cancellable,
@@ -174,22 +181,22 @@ soup_request_file_send (SoupRequest *request,
stream = soup_directory_input_stream_new (enumerator,
soup_request_get_uri (request));
g_object_unref (enumerator);
- file->priv->mime_type = g_strdup ("text/html");
+ priv->mime_type = g_strdup ("text/html");
}
} else
g_propagate_error (error, my_error);
} else {
- GFileInfo *info = g_file_query_info (file->priv->gfile,
+ GFileInfo *info = g_file_query_info (priv->gfile,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
G_FILE_ATTRIBUTE_STANDARD_SIZE,
0, cancellable, NULL);
if (info) {
const char *content_type;
- file->priv->size = g_file_info_get_size (info);
+ priv->size = g_file_info_get_size (info);
content_type = g_file_info_get_content_type (info);
if (content_type)
- file->priv->mime_type = g_content_type_get_mime_type (content_type);
+ priv->mime_type = g_content_type_get_mime_type (content_type);
g_object_unref (info);
}
}
@@ -204,6 +211,7 @@ on_enumerate_children_ready (GObject *source,
{
GTask *task = G_TASK (user_data);
SoupRequestFile *file = SOUP_REQUEST_FILE (g_task_get_source_object (task));
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
GFileEnumerator *enumerator;
GError *error = NULL;
@@ -216,7 +224,7 @@ on_enumerate_children_ready (GObject *source,
stream = soup_directory_input_stream_new (enumerator,
soup_request_get_uri (SOUP_REQUEST (file)));
g_object_unref (enumerator);
- file->priv->mime_type = g_strdup ("text/html");
+ priv->mime_type = g_strdup ("text/html");
g_task_return_pointer (task, stream, g_object_unref);
}
@@ -231,6 +239,7 @@ on_query_info_ready (GObject *source,
{
GTask *task = G_TASK (user_data);
SoupRequestFile *file = SOUP_REQUEST_FILE (g_task_get_source_object (task));
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
GInputStream *stream = G_INPUT_STREAM (g_task_get_task_data (task));
GFileInfo *info;
GError *error = NULL;
@@ -239,11 +248,11 @@ on_query_info_ready (GObject *source,
if (info) {
const char *content_type;
- file->priv->size = g_file_info_get_size (info);
+ priv->size = g_file_info_get_size (info);
content_type = g_file_info_get_content_type (info);
if (content_type)
- file->priv->mime_type = g_content_type_get_mime_type (content_type);
+ priv->mime_type = g_content_type_get_mime_type (content_type);
g_object_unref (info);
}
@@ -258,13 +267,14 @@ on_read_file_ready (GObject *source,
{
GTask *task = G_TASK (user_data);
SoupRequestFile *file = SOUP_REQUEST_FILE (g_task_get_source_object (task));
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
GInputStream *stream;
GError *error = NULL;
stream = G_INPUT_STREAM (g_file_read_finish (G_FILE (source), result, &error));
if (stream == NULL) {
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY)) {
- g_file_enumerate_children_async (file->priv->gfile,
+ g_file_enumerate_children_async (priv->gfile,
"*",
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
@@ -278,7 +288,7 @@ on_read_file_ready (GObject *source,
}
} else {
g_task_set_task_data (task, stream, g_object_unref);
- g_file_query_info_async (file->priv->gfile,
+ g_file_query_info_async (priv->gfile,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
G_FILE_ATTRIBUTE_STANDARD_SIZE,
0,
@@ -296,6 +306,7 @@ soup_request_file_send_async (SoupRequest *request,
gpointer user_data)
{
SoupRequestFile *file = SOUP_REQUEST_FILE (request);
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
GTask *task;
GError *error = NULL;
@@ -307,7 +318,7 @@ soup_request_file_send_async (SoupRequest *request,
return;
}
- g_file_read_async (file->priv->gfile,
+ g_file_read_async (priv->gfile,
G_PRIORITY_DEFAULT,
cancellable,
on_read_file_ready,
@@ -328,19 +339,20 @@ static goffset
soup_request_file_get_content_length (SoupRequest *request)
{
SoupRequestFile *file = SOUP_REQUEST_FILE (request);
-
- return file->priv->size;
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
+ return priv->size;
}
static const char *
soup_request_file_get_content_type (SoupRequest *request)
{
SoupRequestFile *file = SOUP_REQUEST_FILE (request);
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
- if (!file->priv->mime_type)
+ if (!priv->mime_type)
return "application/octet-stream";
- return file->priv->mime_type;
+ return priv->mime_type;
}
static const char *file_schemes[] = { "file", "resource", NULL };
@@ -377,5 +389,6 @@ soup_request_file_class_init (SoupRequestFileClass *request_file_class)
GFile *
soup_request_file_get_file (SoupRequestFile *file)
{
- return g_object_ref (file->priv->gfile);
+ SoupRequestFilePrivate *priv = soup_request_file_get_instance_private (file);
+ return g_object_ref (priv->gfile);
}
diff --git a/libsoup/soup-request-file.h b/libsoup/soup-request-file.h
index cc70c9f4..02688224 100644
--- a/libsoup/soup-request-file.h
+++ b/libsoup/soup-request-file.h
@@ -19,38 +19,17 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __SOUP_REQUEST_FILE_H__
-#define __SOUP_REQUEST_FILE_H__ 1
+#pragma once
#include "soup-request.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_REQUEST_FILE (soup_request_file_get_type ())
-#define SOUP_REQUEST_FILE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SOUP_TYPE_REQUEST_FILE,
SoupRequestFile))
-#define SOUP_REQUEST_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_REQUEST_FILE,
SoupRequestFileClass))
-#define SOUP_IS_REQUEST_FILE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SOUP_TYPE_REQUEST_FILE))
-#define SOUP_IS_REQUEST_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_REQUEST_FILE))
-#define SOUP_REQUEST_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_REQUEST_FILE,
SoupRequestFileClass))
-
-typedef struct _SoupRequestFilePrivate SoupRequestFilePrivate;
-
-typedef struct {
- SoupRequest parent;
-
- SoupRequestFilePrivate *priv;
-} SoupRequestFile;
-
-typedef struct {
- SoupRequestClass parent;
-} SoupRequestFileClass;
-
+#define SOUP_TYPE_REQUEST_FILE (soup_request_file_get_type ())
SOUP_AVAILABLE_IN_2_34
-GType soup_request_file_get_type (void);
+G_DECLARE_FINAL_TYPE (SoupRequestFile, soup_request_file, SOUP, REQUEST_FILE, SoupRequest)
SOUP_AVAILABLE_IN_2_34
GFile *soup_request_file_get_file (SoupRequestFile *file);
G_END_DECLS
-
-#endif /* __SOUP_REQUEST_FILE_H__ */
diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c
index efdea6fe..d4a4cd87 100644
--- a/libsoup/soup-request-http.c
+++ b/libsoup/soup-request-http.c
@@ -44,10 +44,14 @@
* #SoupMessage.
*/
-struct _SoupRequestHTTPPrivate {
+struct _SoupRequestHTTP {
+ SoupRequest parent;
+};
+
+typedef struct {
SoupMessage *msg;
char *content_type;
-};
+} SoupRequestHTTPPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (SoupRequestHTTP, soup_request_http, SOUP_TYPE_REQUEST)
@@ -59,7 +63,6 @@ static void content_sniffed (SoupMessage *msg,
static void
soup_request_http_init (SoupRequestHTTP *http)
{
- http->priv = soup_request_http_get_instance_private (http);
}
static gboolean
@@ -68,14 +71,15 @@ soup_request_http_check_uri (SoupRequest *request,
GError **error)
{
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (request);
+ SoupRequestHTTPPrivate *priv = soup_request_http_get_instance_private (http);
if (!SOUP_URI_VALID_FOR_HTTP (uri))
return FALSE;
- http->priv->msg = soup_message_new_from_uri (SOUP_METHOD_GET, uri);
- soup_message_set_soup_request (http->priv->msg, request);
+ priv->msg = soup_message_new_from_uri (SOUP_METHOD_GET, uri);
+ soup_message_set_soup_request (priv->msg, request);
- g_signal_connect (http->priv->msg, "content-sniffed",
+ g_signal_connect (priv->msg, "content-sniffed",
G_CALLBACK (content_sniffed), http);
return TRUE;
}
@@ -84,15 +88,16 @@ static void
soup_request_http_finalize (GObject *object)
{
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (object);
+ SoupRequestHTTPPrivate *priv = soup_request_http_get_instance_private (http);
- if (http->priv->msg) {
- g_signal_handlers_disconnect_by_func (http->priv->msg,
+ if (priv->msg) {
+ g_signal_handlers_disconnect_by_func (priv->msg,
G_CALLBACK (content_sniffed),
http);
- g_object_unref (http->priv->msg);
+ g_object_unref (priv->msg);
}
- g_free (http->priv->content_type);
+ g_free (priv->content_type);
G_OBJECT_CLASS (soup_request_http_parent_class)->finalize (object);
}
@@ -103,9 +108,10 @@ soup_request_http_send (SoupRequest *request,
GError **error)
{
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (request);
+ SoupRequestHTTPPrivate *priv = soup_request_http_get_instance_private (http);
SoupSession *session = soup_request_get_session (request);
- return soup_session_send (session, http->priv->msg,
+ return soup_session_send (session, priv->msg,
cancellable, error);
}
@@ -132,11 +138,12 @@ soup_request_http_send_async (SoupRequest *request,
gpointer user_data)
{
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (request);
+ SoupRequestHTTPPrivate *priv = soup_request_http_get_instance_private (http);
SoupSession *session = soup_request_get_session (request);
GTask *task;
task = g_task_new (request, cancellable, callback, user_data);
- soup_session_send_async (session, http->priv->msg, cancellable,
+ soup_session_send_async (session, priv->msg, cancellable,
http_input_stream_ready_cb, task);
}
@@ -154,8 +161,9 @@ static goffset
soup_request_http_get_content_length (SoupRequest *request)
{
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (request);
+ SoupRequestHTTPPrivate *priv = soup_request_http_get_instance_private (http);
- return soup_message_headers_get_content_length (http->priv->msg->response_headers);
+ return soup_message_headers_get_content_length (priv->msg->response_headers);
}
static void
@@ -165,6 +173,7 @@ content_sniffed (SoupMessage *msg,
gpointer user_data)
{
SoupRequestHTTP *http = user_data;
+ SoupRequestHTTPPrivate *priv = soup_request_http_get_instance_private (http);
GString *sniffed_type;
sniffed_type = g_string_new (content_type);
@@ -178,16 +187,17 @@ content_sniffed (SoupMessage *msg,
soup_header_g_string_append_param (sniffed_type, key, value);
}
}
- g_free (http->priv->content_type);
- http->priv->content_type = g_string_free (sniffed_type, FALSE);
+ g_free (priv->content_type);
+ priv->content_type = g_string_free (sniffed_type, FALSE);
}
static const char *
soup_request_http_get_content_type (SoupRequest *request)
{
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (request);
+ SoupRequestHTTPPrivate *priv = soup_request_http_get_instance_private (http);
- return http->priv->content_type;
+ return priv->content_type;
}
static const char *http_schemes[] = { "http", "https", NULL };
@@ -225,6 +235,7 @@ SoupMessage *
soup_request_http_get_message (SoupRequestHTTP *http)
{
g_return_val_if_fail (SOUP_IS_REQUEST_HTTP (http), NULL);
+ SoupRequestHTTPPrivate *priv = soup_request_http_get_instance_private (http);
- return g_object_ref (http->priv->msg);
+ return g_object_ref (priv->msg);
}
diff --git a/libsoup/soup-request-http.h b/libsoup/soup-request-http.h
index 3a32febd..c61c496e 100644
--- a/libsoup/soup-request-http.h
+++ b/libsoup/soup-request-http.h
@@ -19,38 +19,17 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __SOUP_REQUEST_HTTP_H__
-#define __SOUP_REQUEST_HTTP_H__ 1
+#pragma once
#include "soup-request.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_REQUEST_HTTP (soup_request_http_get_type ())
-#define SOUP_REQUEST_HTTP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SOUP_TYPE_REQUEST_HTTP,
SoupRequestHTTP))
-#define SOUP_REQUEST_HTTP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_REQUEST_HTTP,
SoupRequestHTTPClass))
-#define SOUP_IS_REQUEST_HTTP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SOUP_TYPE_REQUEST_HTTP))
-#define SOUP_IS_REQUEST_HTTP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_REQUEST_HTTP))
-#define SOUP_REQUEST_HTTP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_REQUEST_HTTP,
SoupRequestHTTPClass))
-
-typedef struct _SoupRequestHTTPPrivate SoupRequestHTTPPrivate;
-
-struct _SoupRequestHTTP {
- SoupRequest parent;
-
- SoupRequestHTTPPrivate *priv;
-};
-
-typedef struct {
- SoupRequestClass parent;
-} SoupRequestHTTPClass;
-
+#define SOUP_TYPE_REQUEST_HTTP (soup_request_http_get_type ())
SOUP_AVAILABLE_IN_2_34
-GType soup_request_http_get_type (void);
+G_DECLARE_FINAL_TYPE (SoupRequestHTTP, soup_request_http, SOUP, REQUEST_HTTP, SoupRequest)
SOUP_AVAILABLE_IN_2_34
SoupMessage *soup_request_http_get_message (SoupRequestHTTP *http);
G_END_DECLS
-
-#endif /* __SOUP_REQUEST_HTTP_H__ */
diff --git a/libsoup/soup-request.c b/libsoup/soup-request.c
index b06d4aea..8b04ae5c 100644
--- a/libsoup/soup-request.c
+++ b/libsoup/soup-request.c
@@ -52,10 +52,10 @@ enum {
PROP_SESSION
};
-struct _SoupRequestPrivate {
+typedef struct {
SoupURI *uri;
SoupSession *session;
-};
+} SoupRequestPrivate;
static void soup_request_initable_interface_init (GInitableIface *initable_interface);
@@ -67,16 +67,16 @@ G_DEFINE_TYPE_WITH_CODE (SoupRequest, soup_request, G_TYPE_OBJECT,
static void
soup_request_init (SoupRequest *request)
{
- request->priv = soup_request_get_instance_private (request);
}
static void
soup_request_finalize (GObject *object)
{
SoupRequest *request = SOUP_REQUEST (object);
+ SoupRequestPrivate *priv = soup_request_get_instance_private (request);
- g_clear_pointer (&request->priv->uri, soup_uri_free);
- g_clear_object (&request->priv->session);
+ g_clear_pointer (&priv->uri, soup_uri_free);
+ g_clear_object (&priv->session);
G_OBJECT_CLASS (soup_request_parent_class)->finalize (object);
}
@@ -88,17 +88,18 @@ soup_request_set_property (GObject *object,
GParamSpec *pspec)
{
SoupRequest *request = SOUP_REQUEST (object);
+ SoupRequestPrivate *priv = soup_request_get_instance_private (request);
switch (prop_id) {
case PROP_URI:
- if (request->priv->uri)
- soup_uri_free (request->priv->uri);
- request->priv->uri = g_value_dup_boxed (value);
+ if (priv->uri)
+ soup_uri_free (priv->uri);
+ priv->uri = g_value_dup_boxed (value);
break;
case PROP_SESSION:
- if (request->priv->session)
- g_object_unref (request->priv->session);
- request->priv->session = g_value_dup_object (value);
+ if (priv->session)
+ g_object_unref (priv->session);
+ priv->session = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -113,13 +114,14 @@ soup_request_get_property (GObject *object,
GParamSpec *pspec)
{
SoupRequest *request = SOUP_REQUEST (object);
+ SoupRequestPrivate *priv = soup_request_get_instance_private (request);
switch (prop_id) {
case PROP_URI:
- g_value_set_boxed (value, request->priv->uri);
+ g_value_set_boxed (value, priv->uri);
break;
case PROP_SESSION:
- g_value_set_object (value, request->priv->session);
+ g_value_set_object (value, priv->session);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -133,22 +135,23 @@ soup_request_initable_init (GInitable *initable,
GError **error)
{
SoupRequest *request = SOUP_REQUEST (initable);
+ SoupRequestPrivate *priv = soup_request_get_instance_private (request);
gboolean ok;
- if (!request->priv->uri) {
+ if (!priv->uri) {
g_set_error (error, SOUP_REQUEST_ERROR, SOUP_REQUEST_ERROR_BAD_URI,
_("No URI provided"));
return FALSE;
}
ok = SOUP_REQUEST_GET_CLASS (initable)->
- check_uri (request, request->priv->uri, error);
+ check_uri (request, priv->uri, error);
if (!ok && error && !*error) {
- char *uri_string = soup_uri_to_string (request->priv->uri, FALSE);
+ char *uri_string = soup_uri_to_string (priv->uri, FALSE);
g_set_error (error, SOUP_REQUEST_ERROR, SOUP_REQUEST_ERROR_BAD_URI,
_("Invalid “%s” URI: %s"),
- request->priv->uri->scheme,
+ priv->uri->scheme,
uri_string);
g_free (uri_string);
}
@@ -341,7 +344,8 @@ soup_request_initable_interface_init (GInitableIface *initable_interface)
SoupURI *
soup_request_get_uri (SoupRequest *request)
{
- return request->priv->uri;
+ SoupRequestPrivate *priv = soup_request_get_instance_private (request);
+ return priv->uri;
}
/**
@@ -357,7 +361,8 @@ soup_request_get_uri (SoupRequest *request)
SoupSession *
soup_request_get_session (SoupRequest *request)
{
- return request->priv->session;
+ SoupRequestPrivate *priv = soup_request_get_instance_private (request);
+ return priv->session;
}
/**
diff --git a/libsoup/soup-request.h b/libsoup/soup-request.h
index 6a6e94fa..fbb6b22a 100644
--- a/libsoup/soup-request.h
+++ b/libsoup/soup-request.h
@@ -19,8 +19,7 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __SOUP_REQUEST_H__
-#define __SOUP_REQUEST_H__ 1
+#pragma once
#include <gio/gio.h>
@@ -28,21 +27,9 @@
G_BEGIN_DECLS
-#define SOUP_TYPE_REQUEST (soup_request_get_type ())
-#define SOUP_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_REQUEST, SoupRequest))
-#define SOUP_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_REQUEST, SoupRequestClass))
-#define SOUP_IS_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_REQUEST))
-#define SOUP_IS_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_REQUEST))
-#define SOUP_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_REQUEST, SoupRequestClass))
-
-typedef struct _SoupRequestPrivate SoupRequestPrivate;
-typedef struct _SoupRequestClass SoupRequestClass;
-
-struct _SoupRequest {
- GObject parent;
-
- SoupRequestPrivate *priv;
-};
+#define SOUP_TYPE_REQUEST (soup_request_get_type ())
+SOUP_AVAILABLE_IN_2_34
+G_DECLARE_DERIVABLE_TYPE (SoupRequest, soup_request, SOUP, REQUEST, GObject)
struct _SoupRequestClass {
GObjectClass parent;
@@ -68,9 +55,6 @@ struct _SoupRequestClass {
const char * (*get_content_type) (SoupRequest *request);
};
-SOUP_AVAILABLE_IN_2_34
-GType soup_request_get_type (void);
-
#define SOUP_REQUEST_URI "uri"
#define SOUP_REQUEST_SESSION "session"
@@ -99,5 +83,3 @@ SOUP_AVAILABLE_IN_2_34
const char *soup_request_get_content_type (SoupRequest *request);
G_END_DECLS
-
-#endif /* __SOUP_REQUEST_H__ */
diff --git a/libsoup/soup-server.h b/libsoup/soup-server.h
index 9caea25d..4ede834d 100644
--- a/libsoup/soup-server.h
+++ b/libsoup/soup-server.h
@@ -3,8 +3,7 @@
* Copyright (C) 2000-2003, Ximian, Inc.
*/
-#ifndef __SOUP_SERVER_H__
-#define __SOUP_SERVER_H__ 1
+#pragma once
#include "soup-types.h"
#include "soup-uri.h"
@@ -12,12 +11,9 @@
G_BEGIN_DECLS
-#define SOUP_TYPE_SERVER (soup_server_get_type ())
-#define SOUP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SERVER, SoupServer))
-#define SOUP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SERVER, SoupServerClass))
-#define SOUP_IS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SERVER))
-#define SOUP_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SERVER))
-#define SOUP_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SERVER, SoupServerClass))
+#define SOUP_TYPE_SERVER (soup_server_get_type ())
+SOUP_AVAILABLE_IN_2_4
+G_DECLARE_DERIVABLE_TYPE (SoupServer, soup_server, SOUP, SERVER, GObject)
typedef struct SoupClientContext SoupClientContext;
SOUP_AVAILABLE_IN_2_4
@@ -30,12 +26,7 @@ typedef enum {
SOUP_SERVER_LISTEN_IPV6_ONLY = (1 << 2)
} SoupServerListenOptions;
-struct _SoupServer {
- GObject parent;
-
-};
-
-typedef struct {
+struct _SoupServerClass {
GObjectClass parent_class;
/* signals */
@@ -48,15 +39,8 @@ typedef struct {
void (*request_aborted) (SoupServer *server, SoupMessage *msg,
SoupClientContext *client);
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupServerClass;
-
-SOUP_AVAILABLE_IN_2_4
-GType soup_server_get_type (void);
+ gpointer padding[6];
+};
#define SOUP_SERVER_TLS_CERTIFICATE "tls-certificate"
#define SOUP_SERVER_RAW_PATHS "raw-paths"
@@ -194,5 +178,3 @@ SOUP_AVAILABLE_IN_2_50
GIOStream *soup_client_context_steal_connection (SoupClientContext *client);
G_END_DECLS
-
-#endif /* __SOUP_SERVER_H__ */
diff --git a/libsoup/soup-session-feature.c b/libsoup/soup-session-feature.c
index 7b9a3a83..a25313b7 100644
--- a/libsoup/soup-session-feature.c
+++ b/libsoup/soup-session-feature.c
@@ -67,8 +67,8 @@ request_queued (SoupSession *session, SoupMessage *msg, gpointer feature)
return;
g_object_ref (feature);
- if (SOUP_SESSION_FEATURE_GET_CLASS (feature)->request_queued) {
- SOUP_SESSION_FEATURE_GET_CLASS (feature)->
+ if (SOUP_SESSION_FEATURE_GET_IFACE (feature)->request_queued) {
+ SOUP_SESSION_FEATURE_GET_IFACE (feature)->
request_queued (feature, session, msg);
}
}
@@ -79,7 +79,7 @@ request_started (SoupSession *session, SoupMessage *msg, gpointer feature)
if (soup_message_disables_feature (msg, feature))
return;
- SOUP_SESSION_FEATURE_GET_CLASS (feature)->
+ SOUP_SESSION_FEATURE_GET_IFACE (feature)->
request_started (feature, session, msg);
}
@@ -89,8 +89,8 @@ request_unqueued (SoupSession *session, SoupMessage *msg, gpointer feature)
if (soup_message_disables_feature (msg, feature))
return;
- if (SOUP_SESSION_FEATURE_GET_CLASS (feature)->request_unqueued) {
- SOUP_SESSION_FEATURE_GET_CLASS (feature)->
+ if (SOUP_SESSION_FEATURE_GET_IFACE (feature)->request_unqueued) {
+ SOUP_SESSION_FEATURE_GET_IFACE (feature)->
request_unqueued (feature, session, msg);
}
g_object_unref (feature);
@@ -105,7 +105,7 @@ soup_session_feature_real_attach (SoupSessionFeature *feature, SoupSession *sess
g_signal_connect (session, "request_queued",
G_CALLBACK (request_queued), feature);
- if (SOUP_SESSION_FEATURE_GET_CLASS (feature)->request_started) {
+ if (SOUP_SESSION_FEATURE_GET_IFACE (feature)->request_started) {
g_signal_connect (session, "request_started",
G_CALLBACK (request_started), feature);
}
@@ -121,7 +121,7 @@ soup_session_feature_attach (SoupSessionFeature *feature,
g_return_if_fail (SOUP_IS_SESSION_FEATURE (feature));
g_return_if_fail (SOUP_IS_SESSION (session));
- SOUP_SESSION_FEATURE_GET_CLASS (feature)->attach (feature, session);
+ SOUP_SESSION_FEATURE_GET_IFACE (feature)->attach (feature, session);
}
static void
@@ -143,7 +143,7 @@ soup_session_feature_detach (SoupSessionFeature *feature,
g_return_if_fail (SOUP_IS_SESSION_FEATURE (feature));
g_return_if_fail (SOUP_IS_SESSION (session));
- SOUP_SESSION_FEATURE_GET_CLASS (feature)->detach (feature, session);
+ SOUP_SESSION_FEATURE_GET_IFACE (feature)->detach (feature, session);
}
static void
@@ -172,7 +172,7 @@ soup_session_feature_add_feature (SoupSessionFeature *feature,
GType type)
{
SoupSessionFeatureInterface *feature_iface =
- SOUP_SESSION_FEATURE_GET_CLASS (feature);
+ SOUP_SESSION_FEATURE_GET_IFACE (feature);
if (feature_iface->add_feature)
return feature_iface->add_feature (feature, type);
@@ -197,7 +197,7 @@ soup_session_feature_remove_feature (SoupSessionFeature *feature,
GType type)
{
SoupSessionFeatureInterface *feature_iface =
- SOUP_SESSION_FEATURE_GET_CLASS (feature);
+ SOUP_SESSION_FEATURE_GET_IFACE (feature);
if (feature_iface->remove_feature)
return feature_iface->remove_feature (feature, type);
@@ -222,7 +222,7 @@ soup_session_feature_has_feature (SoupSessionFeature *feature,
GType type)
{
SoupSessionFeatureInterface *feature_iface =
- SOUP_SESSION_FEATURE_GET_CLASS (feature);
+ SOUP_SESSION_FEATURE_GET_IFACE (feature);
if (feature_iface->has_feature)
return feature_iface->has_feature (feature, type);
diff --git a/libsoup/soup-session-feature.h b/libsoup/soup-session-feature.h
index 4ce7825f..929f93a1 100644
--- a/libsoup/soup-session-feature.h
+++ b/libsoup/soup-session-feature.h
@@ -3,21 +3,17 @@
* Copyright (C) 2008 Red Hat, Inc.
*/
-#ifndef __SOUP_SESSION_FEATURE_H__
-#define __SOUP_SESSION_FEATURE_H__ 1
+#pragma once
#include "soup-types.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_SESSION_FEATURE (soup_session_feature_get_type ())
-#define SOUP_SESSION_FEATURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SESSION_FEATURE,
SoupSessionFeature))
-#define SOUP_SESSION_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SESSION_FEATURE,
SoupSessionFeatureInterface))
-#define SOUP_IS_SESSION_FEATURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SESSION_FEATURE))
-#define SOUP_IS_SESSION_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_SESSION_FEATURE))
-#define SOUP_SESSION_FEATURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj),
SOUP_TYPE_SESSION_FEATURE, SoupSessionFeatureInterface))
+#define SOUP_TYPE_SESSION_FEATURE (soup_session_feature_get_type ())
+SOUP_AVAILABLE_IN_2_24
+G_DECLARE_INTERFACE (SoupSessionFeature, soup_session_feature, SOUP, SESSION_FEATURE, GObject)
-typedef struct {
+struct _SoupSessionFeatureInterface {
GTypeInterface parent;
/* methods */
@@ -43,10 +39,7 @@ typedef struct {
gboolean (*has_feature) (SoupSessionFeature *feature,
GType type);
-} SoupSessionFeatureInterface;
-
-SOUP_AVAILABLE_IN_2_24
-GType soup_session_feature_get_type (void);
+};
SOUP_AVAILABLE_IN_2_24
void soup_session_feature_attach (SoupSessionFeature *feature,
@@ -66,5 +59,3 @@ gboolean soup_session_feature_has_feature (SoupSessionFeature *feature,
GType type);
G_END_DECLS
-
-#endif /* __SOUP_SESSION_FEATURE_H__ */
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index e358df31..d4c75d85 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -14,6 +14,7 @@
#include "soup-session.h"
#include "soup.h"
#include "auth/soup-auth-manager.h"
+#include "auth/soup-auth-ntlm.h"
#include "cache/soup-cache-private.h"
#include "soup-connection.h"
#include "soup-message-private.h"
@@ -81,6 +82,10 @@ typedef struct {
static guint soup_host_uri_hash (gconstpointer key);
static gboolean soup_host_uri_equal (gconstpointer v1, gconstpointer v2);
+struct _SoupSession {
+ GObject parent;
+};
+
typedef struct {
gboolean disposed;
@@ -2626,7 +2631,7 @@ soup_session_class_init (SoupSessionClass *session_class)
g_signal_new ("request-started",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (SoupSessionClass, request_started),
+ 0,
NULL, NULL,
NULL,
G_TYPE_NONE, 1,
@@ -2681,7 +2686,7 @@ soup_session_class_init (SoupSessionClass *session_class)
g_signal_new ("authenticate",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (SoupSessionClass, authenticate),
+ 0,
NULL, NULL,
NULL,
G_TYPE_NONE, 3,
diff --git a/libsoup/soup-session.h b/libsoup/soup-session.h
index af2d42ca..1879b36d 100644
--- a/libsoup/soup-session.h
+++ b/libsoup/soup-session.h
@@ -3,8 +3,7 @@
* Copyright (C) 2000-2003, Ximian, Inc.
*/
-#ifndef __SOUP_SESSION_H__
-#define __SOUP_SESSION_H__ 1
+#pragma once
#include "soup-types.h"
#include "soup-message.h"
@@ -12,42 +11,14 @@
G_BEGIN_DECLS
-#define SOUP_TYPE_SESSION (soup_session_get_type ())
-#define SOUP_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SESSION, SoupSession))
-#define SOUP_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SESSION, SoupSessionClass))
-#define SOUP_IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SESSION))
-#define SOUP_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SESSION))
-#define SOUP_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SESSION, SoupSessionClass))
+#define SOUP_TYPE_SESSION soup_session_get_type ()
+SOUP_AVAILABLE_IN_2_42
+G_DECLARE_FINAL_TYPE (SoupSession, soup_session, SOUP, SESSION, GObject)
typedef void (*SoupSessionCallback) (SoupSession *session,
SoupMessage *msg,
gpointer user_data);
-struct _SoupSession {
- GObject parent;
-
-};
-
-typedef struct {
- GObjectClass parent_class;
-
- /* signals */
- void (*request_started) (SoupSession *session, SoupMessage *msg,
- SoupSocket *socket);
- void (*authenticate) (SoupSession *session, SoupMessage *msg,
- SoupAuth *auth, gboolean retrying);
-
- /* methods */
- void (*auth_required) (SoupSession *session, SoupMessage *msg,
- SoupAuth *auth, gboolean retrying);
-
- /* Padding for future expansion */
- void (*_libsoup_reserved4) (void);
-} SoupSessionClass;
-
-SOUP_AVAILABLE_IN_2_42
-GType soup_session_get_type (void);
-
#define SOUP_SESSION_LOCAL_ADDRESS "local-address"
#define SOUP_SESSION_PROXY_RESOLVER "proxy-resolver"
#define SOUP_SESSION_MAX_CONNS "max-conns"
@@ -200,5 +171,3 @@ SoupWebsocketConnection *soup_session_websocket_connect_finish (SoupSession
GError **error);
G_END_DECLS
-
-#endif /* __SOUP_SESSION_H__ */
diff --git a/libsoup/soup-status.h b/libsoup/soup-status.h
index 625fe669..040a858c 100644
--- a/libsoup/soup-status.h
+++ b/libsoup/soup-status.h
@@ -5,8 +5,7 @@
* Copyright (C) 2001-2003, Ximian, Inc.
*/
-#ifndef __SOUP_STATUS_H__
-#define __SOUP_STATUS_H__ 1
+#pragma once
#include "soup-version.h"
@@ -110,5 +109,3 @@ SOUP_AVAILABLE_IN_2_4
GQuark soup_http_error_quark (void);
G_END_DECLS
-
-#endif /* __SOUP_STATUS_H__ */
diff --git a/libsoup/soup-tld.h b/libsoup/soup-tld.h
index cc71933c..f563fac7 100644
--- a/libsoup/soup-tld.h
+++ b/libsoup/soup-tld.h
@@ -3,8 +3,7 @@
* Copyright (C) 2012 Igalia S.L.
*/
-#ifndef __SOUP_TLD_H__
-#define __SOUP_TLD_H__
+#pragma once
#include "soup-types.h"
@@ -31,5 +30,3 @@ typedef enum {
} SoupTLDError;
G_END_DECLS
-
-#endif /* __SOUP_TLD_H__ */
diff --git a/libsoup/soup-uri.h b/libsoup/soup-uri.h
index f60f7560..6e949ea1 100644
--- a/libsoup/soup-uri.h
+++ b/libsoup/soup-uri.h
@@ -5,8 +5,7 @@
*/
-#ifndef __SOUP_URI_H__
-#define __SOUP_URI_H__ 1
+#pragma once
#include "soup-types.h"
@@ -136,6 +135,6 @@ gboolean soup_uri_host_equal (gconstpointer v1,
#define SOUP_URI_IS_VALID(uri) ((uri) && (uri)->scheme && (uri)->path)
#define SOUP_URI_VALID_FOR_HTTP(uri) ((uri) && ((uri)->scheme == SOUP_URI_SCHEME_HTTP || (uri)->scheme ==
SOUP_URI_SCHEME_HTTPS) && (uri)->host && (uri)->path)
-G_END_DECLS
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupURI, soup_uri_free)
-#endif /* __SOUP_URI_H__ */
+G_END_DECLS
diff --git a/libsoup/soup-version.h.in b/libsoup/soup-version.h.in
index 07bed7fd..53605dfa 100644
--- a/libsoup/soup-version.h.in
+++ b/libsoup/soup-version.h.in
@@ -5,8 +5,7 @@
* Copyright (C) 2012 Igalia S.L.
*/
-#ifndef __SOUP_VERSION_H__
-#define __SOUP_VERSION_H__
+#pragma once
#include <glib.h>
@@ -433,5 +432,3 @@ gboolean soup_check_version (guint major,
guint micro);
G_END_DECLS
-
-#endif /* __SOUP_VERSION_H__ */
diff --git a/libsoup/soup.h b/libsoup/soup.h
index f023565c..254ce582 100644
--- a/libsoup/soup.h
+++ b/libsoup/soup.h
@@ -13,10 +13,14 @@ extern "C" {
#define __SOUP_H_INSIDE__
#include "auth/soup-auth.h"
+#include "auth/soup-auth-basic.h"
+#include "auth/soup-auth-digest.h"
#include "auth/soup-auth-domain.h"
#include "auth/soup-auth-domain-basic.h"
#include "auth/soup-auth-domain-digest.h"
#include "auth/soup-auth-manager.h"
+#include "auth/soup-auth-negotiate.h"
+#include "auth/soup-auth-ntlm.h"
#include "cache/soup-cache.h"
#include "content-sniffer/soup-content-decoder.h"
#include "content-sniffer/soup-content-sniffer.h"
@@ -55,8 +59,6 @@ extern "C" {
#include "websocket/soup-websocket-extension-manager.h"
#include "xmlrpc/soup-xmlrpc.h"
-#include "soup-autocleanups.h"
-
#undef __SOUP_H_INSIDE__
#ifdef __cplusplus
diff --git a/libsoup/websocket/soup-websocket-connection.c b/libsoup/websocket/soup-websocket-connection.c
index a4095e1c..a6c34f40 100644
--- a/libsoup/websocket/soup-websocket-connection.c
+++ b/libsoup/websocket/soup-websocket-connection.c
@@ -113,7 +113,7 @@ typedef struct {
gboolean pending;
} Frame;
-struct _SoupWebsocketConnectionPrivate {
+typedef struct {
GIOStream *io_stream;
SoupWebsocketConnectionType connection_type;
SoupURI *uri;
@@ -149,7 +149,7 @@ struct _SoupWebsocketConnectionPrivate {
GSource *keepalive_timeout;
GList *extensions;
-};
+} SoupWebsocketConnectionPrivate;
#define MAX_INCOMING_PAYLOAD_SIZE_DEFAULT 128 * 1024
#define READ_BUFFER_SIZE 1024
@@ -260,13 +260,11 @@ frame_free (gpointer data)
static void
soup_websocket_connection_init (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- pv = self->pv = soup_websocket_connection_get_instance_private (self);
-
- pv->incoming = g_byte_array_sized_new (1024);
- g_queue_init (&pv->outgoing);
- pv->main_context = g_main_context_ref_thread_default ();
+ priv->incoming = g_byte_array_sized_new (1024);
+ g_queue_init (&priv->outgoing);
+ priv->main_context = g_main_context_ref_thread_default ();
}
static void
@@ -275,18 +273,18 @@ on_iostream_closed (GObject *source,
gpointer user_data)
{
SoupWebsocketConnection *self = user_data;
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
GError *error = NULL;
/* We treat connection as closed even if close fails */
- pv->io_closed = TRUE;
- g_io_stream_close_finish (pv->io_stream, result, &error);
+ priv->io_closed = TRUE;
+ g_io_stream_close_finish (priv->io_stream, result, &error);
if (error) {
g_debug ("error closing web socket stream: %s", error->message);
- if (!pv->dirty_close)
+ if (!priv->dirty_close)
g_signal_emit (self, signals[ERROR], 0, error);
- pv->dirty_close = TRUE;
+ priv->dirty_close = TRUE;
g_error_free (error);
}
@@ -300,93 +298,93 @@ on_iostream_closed (GObject *source,
static void
soup_websocket_connection_start_input_source (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- if (pv->input_source)
+ if (priv->input_source)
return;
- pv->input_source = g_pollable_input_stream_create_source (pv->input, NULL);
- g_source_set_callback (pv->input_source, (GSourceFunc)on_web_socket_input, self, NULL);
- g_source_attach (pv->input_source, pv->main_context);
+ priv->input_source = g_pollable_input_stream_create_source (priv->input, NULL);
+ g_source_set_callback (priv->input_source, (GSourceFunc)on_web_socket_input, self, NULL);
+ g_source_attach (priv->input_source, priv->main_context);
}
static void
soup_websocket_connection_stop_input_source (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- if (pv->input_source) {
+ if (priv->input_source) {
g_debug ("stopping input source");
- g_source_destroy (pv->input_source);
- g_source_unref (pv->input_source);
- pv->input_source = NULL;
+ g_source_destroy (priv->input_source);
+ g_source_unref (priv->input_source);
+ priv->input_source = NULL;
}
}
static void
soup_websocket_connection_start_output_source (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- if (pv->output_source)
+ if (priv->output_source)
return;
- pv->output_source = g_pollable_output_stream_create_source (pv->output, NULL);
- g_source_set_callback (pv->output_source, (GSourceFunc)on_web_socket_output, self, NULL);
- g_source_attach (pv->output_source, pv->main_context);
+ priv->output_source = g_pollable_output_stream_create_source (priv->output, NULL);
+ g_source_set_callback (priv->output_source, (GSourceFunc)on_web_socket_output, self, NULL);
+ g_source_attach (priv->output_source, priv->main_context);
}
static void
soup_websocket_connection_stop_output_source (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- if (pv->output_source) {
+ if (priv->output_source) {
g_debug ("stopping output source");
- g_source_destroy (pv->output_source);
- g_source_unref (pv->output_source);
- pv->output_source = NULL;
+ g_source_destroy (priv->output_source);
+ g_source_unref (priv->output_source);
+ priv->output_source = NULL;
}
}
static void
keepalive_stop_timeout (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- if (pv->keepalive_timeout) {
- g_source_destroy (pv->keepalive_timeout);
- g_source_unref (pv->keepalive_timeout);
- pv->keepalive_timeout = NULL;
+ if (priv->keepalive_timeout) {
+ g_source_destroy (priv->keepalive_timeout);
+ g_source_unref (priv->keepalive_timeout);
+ priv->keepalive_timeout = NULL;
}
}
static void
close_io_stop_timeout (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- if (pv->close_timeout) {
- g_source_destroy (pv->close_timeout);
- g_source_unref (pv->close_timeout);
- pv->close_timeout = NULL;
+ if (priv->close_timeout) {
+ g_source_destroy (priv->close_timeout);
+ g_source_unref (priv->close_timeout);
+ priv->close_timeout = NULL;
}
}
static void
close_io_stream (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
keepalive_stop_timeout (self);
close_io_stop_timeout (self);
- if (!pv->io_closing) {
+ if (!priv->io_closing) {
soup_websocket_connection_stop_input_source (self);
soup_websocket_connection_stop_output_source (self);
- pv->io_closing = TRUE;
+ priv->io_closing = TRUE;
g_debug ("closing io stream");
- g_io_stream_close_async (pv->io_stream, G_PRIORITY_DEFAULT,
+ g_io_stream_close_async (priv->io_stream, G_PRIORITY_DEFAULT,
NULL, on_iostream_closed, g_object_ref (self));
}
@@ -396,16 +394,16 @@ close_io_stream (SoupWebsocketConnection *self)
static void
shutdown_wr_io_stream (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
GSocket *socket;
GIOStream *base_iostream;
GError *error = NULL;
soup_websocket_connection_stop_output_source (self);
- base_iostream = SOUP_IS_IO_STREAM (pv->io_stream) ?
- soup_io_stream_get_base_iostream (SOUP_IO_STREAM (pv->io_stream)) :
- pv->io_stream;
+ base_iostream = SOUP_IS_IO_STREAM (priv->io_stream) ?
+ soup_io_stream_get_base_iostream (SOUP_IO_STREAM (priv->io_stream)) :
+ priv->io_stream;
if (G_IS_SOCKET_CONNECTION (base_iostream)) {
socket = g_socket_connection_get_socket (G_SOCKET_CONNECTION (base_iostream));
@@ -423,9 +421,9 @@ static gboolean
on_timeout_close_io (gpointer user_data)
{
SoupWebsocketConnection *self = SOUP_WEBSOCKET_CONNECTION (user_data);
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- pv->close_timeout = 0;
+ priv->close_timeout = 0;
g_debug ("peer did not close io when expected");
close_io_stream (self);
@@ -436,16 +434,16 @@ on_timeout_close_io (gpointer user_data)
static void
close_io_after_timeout (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
const int timeout = 5;
- if (pv->close_timeout)
+ if (priv->close_timeout)
return;
g_debug ("waiting %d seconds for peer to close io", timeout);
- pv->close_timeout = g_timeout_source_new_seconds (timeout);
- g_source_set_callback (pv->close_timeout, on_timeout_close_io, self, NULL);
- g_source_attach (pv->close_timeout, pv->main_context);
+ priv->close_timeout = g_timeout_source_new_seconds (timeout);
+ g_source_set_callback (priv->close_timeout, on_timeout_close_io, self, NULL);
+ g_source_attach (priv->close_timeout, priv->main_context);
}
static void
@@ -467,6 +465,7 @@ send_message (SoupWebsocketConnection *self,
const guint8 *data,
gsize length)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
gsize buffered_amount;
GByteArray *bytes;
gsize frame_len;
@@ -486,7 +485,7 @@ send_message (SoupWebsocketConnection *self,
outer[0] = 0x80 | opcode;
filtered_bytes = g_bytes_new_static (data, length);
- for (l = self->pv->extensions; l != NULL; l = g_list_next (l)) {
+ for (l = priv->extensions; l != NULL; l = g_list_next (l)) {
SoupWebsocketExtension *extension;
extension = (SoupWebsocketExtension *)l->data;
@@ -542,7 +541,7 @@ send_message (SoupWebsocketConnection *self,
/* The server side doesn't need to mask, so we don't. There's
* probably a client somewhere that's not expecting it.
*/
- if (self->pv->connection_type == SOUP_WEBSOCKET_CONNECTION_CLIENT) {
+ if (priv->connection_type == SOUP_WEBSOCKET_CONNECTION_CLIENT) {
guint32 rnd = g_random_int ();
outer[1] |= 0x80;
mask_offset = bytes->len;
@@ -552,7 +551,7 @@ send_message (SoupWebsocketConnection *self,
g_byte_array_append (bytes, data, length);
- if (self->pv->connection_type == SOUP_WEBSOCKET_CONNECTION_CLIENT)
+ if (priv->connection_type == SOUP_WEBSOCKET_CONNECTION_CLIENT)
xor_with_mask (bytes->data + mask_offset, bytes->data + mask_offset + MASK_LENGTH, length);
frame_len = bytes->len;
@@ -568,6 +567,7 @@ send_close (SoupWebsocketConnection *self,
gushort code,
const char *reason)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
/* Note that send_message truncates as expected */
char buffer[128];
gsize len = 0;
@@ -580,7 +580,7 @@ send_close (SoupWebsocketConnection *self,
}
send_message (self, flags, 0x08, (guint8 *)buffer, len);
- self->pv->close_sent = TRUE;
+ priv->close_sent = TRUE;
keepalive_stop_timeout (self);
}
@@ -590,6 +590,7 @@ emit_error_and_close (SoupWebsocketConnection *self,
GError *error,
gboolean prejudice)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
gboolean ignore = FALSE;
gushort code;
@@ -603,7 +604,7 @@ emit_error_and_close (SoupWebsocketConnection *self,
else
code = SOUP_WEBSOCKET_CLOSE_GOING_AWAY;
- self->pv->dirty_close = TRUE;
+ priv->dirty_close = TRUE;
g_signal_emit (self, signals[ERROR], 0, error);
g_error_free (error);
@@ -634,11 +635,12 @@ static void
protocol_error_and_close_full (SoupWebsocketConnection *self,
gboolean prejudice)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
GError *error;
error = g_error_new_literal (SOUP_WEBSOCKET_ERROR,
SOUP_WEBSOCKET_CLOSE_PROTOCOL_ERROR,
- self->pv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER ?
+ priv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER ?
"Received invalid WebSocket response from the client" :
"Received invalid WebSocket response from the server");
emit_error_and_close (self, error, prejudice);
@@ -653,11 +655,12 @@ protocol_error_and_close (SoupWebsocketConnection *self)
static void
bad_data_error_and_close (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
GError *error;
error = g_error_new_literal (SOUP_WEBSOCKET_ERROR,
SOUP_WEBSOCKET_CLOSE_BAD_DATA,
- self->pv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER ?
+ priv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER ?
"Received invalid WebSocket data from the client" :
"Received invalid WebSocket data from the server");
emit_error_and_close (self, error, FALSE);
@@ -667,16 +670,17 @@ static void
too_big_error_and_close (SoupWebsocketConnection *self,
guint64 payload_len)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
GError *error;
error = g_error_new_literal (SOUP_WEBSOCKET_ERROR,
SOUP_WEBSOCKET_CLOSE_TOO_BIG,
- self->pv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER ?
+ priv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER ?
"Received extremely large WebSocket data from the client" :
"Received extremely large WebSocket data from the server");
g_debug ("%s is trying to frame of size %" G_GUINT64_FORMAT " or greater, but max supported size is
%" G_GUINT64_FORMAT,
- self->pv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER ? "server" : "client",
- payload_len, self->pv->max_incoming_payload_size);
+ priv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER ? "server" : "client",
+ payload_len, priv->max_incoming_payload_size);
emit_error_and_close (self, error, TRUE);
}
@@ -686,11 +690,9 @@ close_connection (SoupWebsocketConnection *self,
const char *data)
{
SoupWebsocketQueueFlags flags;
- SoupWebsocketConnectionPrivate *pv;
-
- pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- if (pv->close_sent) {
+ if (priv->close_sent) {
g_debug ("close code already sent");
return;
}
@@ -706,13 +708,13 @@ close_connection (SoupWebsocketConnection *self,
case SOUP_WEBSOCKET_CLOSE_TOO_BIG:
break;
case SOUP_WEBSOCKET_CLOSE_NO_EXTENSION:
- if (pv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER) {
+ if (priv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER) {
g_debug ("Wrong closing code %d received for a server connection",
code);
}
break;
case SOUP_WEBSOCKET_CLOSE_SERVER_ERROR:
- if (pv->connection_type != SOUP_WEBSOCKET_CONNECTION_SERVER) {
+ if (priv->connection_type != SOUP_WEBSOCKET_CONNECTION_SERVER) {
g_debug ("Wrong closing code %d received for a non server connection",
code);
}
@@ -731,11 +733,11 @@ close_connection (SoupWebsocketConnection *self,
g_signal_emit (self, signals[CLOSING], 0);
- if (pv->close_received)
+ if (priv->close_received)
g_debug ("responding to close request");
flags = 0;
- if (pv->close_received)
+ if (priv->close_received)
flags |= SOUP_WEBSOCKET_QUEUE_LAST;
send_close (self, flags, code, data);
close_io_after_timeout (self);
@@ -746,17 +748,17 @@ receive_close (SoupWebsocketConnection *self,
const guint8 *data,
gsize len)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- pv->peer_close_code = 0;
- g_free (pv->peer_close_data);
- pv->peer_close_data = NULL;
- pv->close_received = TRUE;
+ priv->peer_close_code = 0;
+ g_free (priv->peer_close_data);
+ priv->peer_close_data = NULL;
+ priv->close_received = TRUE;
switch (len) {
case 0:
/* Send a clean close when having an empty payload */
- pv->peer_close_code = SOUP_WEBSOCKET_CLOSE_NO_STATUS;
+ priv->peer_close_code = SOUP_WEBSOCKET_CLOSE_NO_STATUS;
close_connection (self, 1000, NULL);
return;
case 1:
@@ -765,7 +767,7 @@ receive_close (SoupWebsocketConnection *self,
return;
default:
/* Store the code/data payload */
- pv->peer_close_code = (guint16)data[0] << 8 | data[1];
+ priv->peer_close_code = (guint16)data[0] << 8 | data[1];
break;
}
@@ -779,16 +781,16 @@ receive_close (SoupWebsocketConnection *self,
return;
}
- pv->peer_close_data = g_strndup ((char *)data, len);
+ priv->peer_close_data = g_strndup ((char *)data, len);
}
/* Once we receive close response on server, close immediately */
- if (pv->close_sent) {
+ if (priv->close_sent) {
shutdown_wr_io_stream (self);
- if (pv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER)
+ if (priv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER)
close_io_stream (self);
} else {
- close_connection (self, pv->peer_close_code, pv->peer_close_data);
+ close_connection (self, priv->peer_close_code, priv->peer_close_data);
}
}
@@ -830,14 +832,14 @@ process_contents (SoupWebsocketConnection *self,
guint8 opcode,
GBytes *payload_data)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
GBytes *message;
gconstpointer payload;
gsize payload_len;
payload = g_bytes_get_data (payload_data, &payload_len);
- if (pv->close_sent && pv->close_received)
+ if (priv->close_sent && priv->close_received)
return;
if (control) {
@@ -865,14 +867,14 @@ process_contents (SoupWebsocketConnection *self,
protocol_error_and_close (self);
return;
}
- } else if (pv->close_received) {
+ } else if (priv->close_received) {
g_debug ("received message after close was received");
} else {
/* A message frame */
if (!fin && opcode) {
/* Initial fragment of a message */
- if (pv->message_data) {
+ if (priv->message_data) {
g_debug ("received out of order initial message fragment");
protocol_error_and_close (self);
return;
@@ -880,7 +882,7 @@ process_contents (SoupWebsocketConnection *self,
g_debug ("received initial fragment frame %d with %d payload", (int)opcode,
(int)payload_len);
} else if (!fin && !opcode) {
/* Middle fragment of a message */
- if (!pv->message_data) {
+ if (!priv->message_data) {
g_debug ("received out of order middle message fragment");
protocol_error_and_close (self);
return;
@@ -888,7 +890,7 @@ process_contents (SoupWebsocketConnection *self,
g_debug ("received middle fragment frame with %d payload", (int)payload_len);
} else if (fin && !opcode) {
/* Last fragment of a message */
- if (!pv->message_data) {
+ if (!priv->message_data) {
g_debug ("received out of order ending message fragment");
protocol_error_and_close (self);
return;
@@ -897,7 +899,7 @@ process_contents (SoupWebsocketConnection *self,
} else {
/* An unfragmented message */
g_assert (opcode != 0);
- if (pv->message_data) {
+ if (priv->message_data) {
g_debug ("received unfragmented message when fragment was expected");
protocol_error_and_close (self);
return;
@@ -906,14 +908,14 @@ process_contents (SoupWebsocketConnection *self,
}
if (opcode) {
- pv->message_opcode = opcode;
- pv->message_data = g_byte_array_sized_new (payload_len + 1);
+ priv->message_opcode = opcode;
+ priv->message_data = g_byte_array_sized_new (payload_len + 1);
}
- switch (pv->message_opcode) {
+ switch (priv->message_opcode) {
case 0x01:
case 0x02:
- g_byte_array_append (pv->message_data, payload, payload_len);
+ g_byte_array_append (priv->message_data, payload, payload_len);
break;
default:
g_debug ("received unknown data frame: %d", (int)opcode);
@@ -923,31 +925,31 @@ process_contents (SoupWebsocketConnection *self,
/* Actually deliver the message? */
if (fin) {
- if (pv->message_opcode == 0x01 &&
- !utf8_validate((const char *)pv->message_data->data,
- pv->message_data->len)) {
+ if (priv->message_opcode == 0x01 &&
+ !utf8_validate((const char *)priv->message_data->data,
+ priv->message_data->len)) {
g_debug ("received invalid non-UTF8 text data");
/* Discard the entire message */
- g_byte_array_unref (pv->message_data);
- pv->message_data = NULL;
- pv->message_opcode = 0;
+ g_byte_array_unref (priv->message_data);
+ priv->message_data = NULL;
+ priv->message_opcode = 0;
bad_data_error_and_close (self);
return;
}
/* Always null terminate, as a convenience */
- g_byte_array_append (pv->message_data, (guchar *)"\0", 1);
+ g_byte_array_append (priv->message_data, (guchar *)"\0", 1);
/* But don't include the null terminator in the byte count */
- pv->message_data->len--;
+ priv->message_data->len--;
- opcode = pv->message_opcode;
- message = g_byte_array_free_to_bytes (pv->message_data);
- pv->message_data = NULL;
- pv->message_opcode = 0;
+ opcode = priv->message_opcode;
+ message = g_byte_array_free_to_bytes (priv->message_data);
+ priv->message_data = NULL;
+ priv->message_opcode = 0;
g_debug ("message: delivering %d with %d length",
(int)opcode, (int)g_bytes_get_size (message));
g_signal_emit (self, signals[MESSAGE], 0, (int)opcode, message);
@@ -959,6 +961,7 @@ process_contents (SoupWebsocketConnection *self,
static gboolean
process_frame (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
guint8 *header;
guint8 *payload;
guint64 payload_len;
@@ -973,17 +976,17 @@ process_frame (SoupWebsocketConnection *self)
GList *l;
GError *error = NULL;
- len = self->pv->incoming->len;
+ len = priv->incoming->len;
if (len < 2)
return FALSE; /* need more data */
- header = self->pv->incoming->data;
+ header = priv->incoming->data;
fin = ((header[0] & 0x80) != 0);
control = header[0] & 0x08;
opcode = header[0] & 0x0f;
masked = ((header[1] & 0x80) != 0);
- if (self->pv->connection_type == SOUP_WEBSOCKET_CONNECTION_CLIENT && masked) {
+ if (priv->connection_type == SOUP_WEBSOCKET_CONNECTION_CLIENT && masked) {
/* A server MUST NOT mask any frames that it sends to the client.
* A client MUST close a connection if it detects a masked frame.
*/
@@ -992,7 +995,7 @@ process_frame (SoupWebsocketConnection *self)
return FALSE;
}
- if (self->pv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER && !masked) {
+ if (priv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER && !masked) {
/* The server MUST close the connection upon receiving a frame
* that is not masked.
*/
@@ -1048,8 +1051,8 @@ process_frame (SoupWebsocketConnection *self)
}
/* Safety valve */
- if (self->pv->max_incoming_payload_size > 0 &&
- payload_len >= self->pv->max_incoming_payload_size) {
+ if (priv->max_incoming_payload_size > 0 &&
+ payload_len >= priv->max_incoming_payload_size) {
too_big_error_and_close (self, payload_len);
return FALSE;
}
@@ -1071,11 +1074,11 @@ process_frame (SoupWebsocketConnection *self)
}
filtered_bytes = g_bytes_new_static (payload, payload_len);
- for (l = self->pv->extensions; l != NULL; l = g_list_next (l)) {
+ for (l = priv->extensions; l != NULL; l = g_list_next (l)) {
SoupWebsocketExtension *extension;
extension = (SoupWebsocketExtension *)l->data;
- filtered_bytes = soup_websocket_extension_process_incoming_message (extension,
self->pv->incoming->data, filtered_bytes, &error);
+ filtered_bytes = soup_websocket_extension_process_incoming_message (extension,
priv->incoming->data, filtered_bytes, &error);
if (error) {
emit_error_and_close (self, error, FALSE);
return FALSE;
@@ -1097,7 +1100,7 @@ process_frame (SoupWebsocketConnection *self)
g_bytes_unref (filtered_bytes);
/* Move past the parsed frame */
- g_byte_array_remove_range (self->pv->incoming, 0, at + payload_len);
+ g_byte_array_remove_range (priv->incoming, 0, at + payload_len);
return TRUE;
}
@@ -1112,7 +1115,7 @@ process_incoming (SoupWebsocketConnection *self)
static void
soup_websocket_connection_read (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
GError *error = NULL;
gboolean end = FALSE;
gssize count;
@@ -1121,11 +1124,11 @@ soup_websocket_connection_read (SoupWebsocketConnection *self)
soup_websocket_connection_stop_input_source (self);
do {
- len = pv->incoming->len;
- g_byte_array_set_size (pv->incoming, len + READ_BUFFER_SIZE);
+ len = priv->incoming->len;
+ g_byte_array_set_size (priv->incoming, len + READ_BUFFER_SIZE);
- count = g_pollable_input_stream_read_nonblocking (pv->input,
- pv->incoming->data + len,
+ count = g_pollable_input_stream_read_nonblocking (priv->input,
+ priv->incoming->data + len,
READ_BUFFER_SIZE, NULL, &error);
if (count < 0) {
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
@@ -1139,14 +1142,14 @@ soup_websocket_connection_read (SoupWebsocketConnection *self)
end = TRUE;
}
- pv->incoming->len = len + count;
+ priv->incoming->len = len + count;
} while (count > 0);
process_incoming (self);
if (end) {
- if (!pv->close_sent || !pv->close_received) {
- pv->dirty_close = TRUE;
+ if (!priv->close_sent || !priv->close_received) {
+ priv->dirty_close = TRUE;
g_debug ("connection unexpectedly closed by peer");
} else {
g_debug ("peer has closed socket");
@@ -1156,7 +1159,7 @@ soup_websocket_connection_read (SoupWebsocketConnection *self)
return;
}
- if (!pv->io_closing)
+ if (!priv->io_closing)
soup_websocket_connection_start_input_source (self);
}
@@ -1172,7 +1175,7 @@ on_web_socket_input (GObject *pollable_stream,
static void
soup_websocket_connection_write (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
const guint8 *data;
GError *error = NULL;
Frame *frame;
@@ -1186,7 +1189,7 @@ soup_websocket_connection_write (SoupWebsocketConnection *self)
return;
}
- frame = g_queue_peek_head (&pv->outgoing);
+ frame = g_queue_peek_head (&priv->outgoing);
/* No more frames to send */
if (frame == NULL)
@@ -1196,7 +1199,7 @@ soup_websocket_connection_write (SoupWebsocketConnection *self)
g_assert (len > 0);
g_assert (len > frame->sent);
- count = g_pollable_output_stream_write_nonblocking (pv->output,
+ count = g_pollable_output_stream_write_nonblocking (priv->output,
data + frame->sent,
len - frame->sent,
NULL, &error);
@@ -1217,10 +1220,10 @@ soup_websocket_connection_write (SoupWebsocketConnection *self)
frame->sent += count;
if (frame->sent >= len) {
g_debug ("sent frame");
- g_queue_pop_head (&pv->outgoing);
+ g_queue_pop_head (&priv->outgoing);
if (frame->flags & SOUP_WEBSOCKET_QUEUE_LAST) {
- if (pv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER) {
+ if (priv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER) {
close_io_stream (self);
} else {
shutdown_wr_io_stream (self);
@@ -1229,7 +1232,7 @@ soup_websocket_connection_write (SoupWebsocketConnection *self)
}
frame_free (frame);
- if (g_queue_is_empty (&pv->outgoing))
+ if (g_queue_is_empty (&priv->outgoing))
return;
}
@@ -1252,11 +1255,11 @@ queue_frame (SoupWebsocketConnection *self,
gsize len,
gsize amount)
{
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
Frame *frame;
g_return_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self));
- g_return_if_fail (pv->close_sent == FALSE);
+ g_return_if_fail (priv->close_sent == FALSE);
g_return_if_fail (data != NULL);
g_return_if_fail (len > 0);
@@ -1270,7 +1273,7 @@ queue_frame (SoupWebsocketConnection *self,
GList *l;
/* Find out the first frame that is not urgent or partially sent or pending */
- for (l = g_queue_peek_head_link (&pv->outgoing); l != NULL; l = l->next) {
+ for (l = g_queue_peek_head_link (&priv->outgoing); l != NULL; l = l->next) {
Frame *prev = l->data;
if (!(prev->flags & SOUP_WEBSOCKET_QUEUE_URGENT) &&
@@ -1278,9 +1281,9 @@ queue_frame (SoupWebsocketConnection *self,
break;
}
- g_queue_insert_before (&pv->outgoing, l, frame);
+ g_queue_insert_before (&priv->outgoing, l, frame);
} else {
- g_queue_push_tail (&pv->outgoing, frame);
+ g_queue_push_tail (&priv->outgoing, frame);
}
soup_websocket_connection_write (self);
@@ -1290,23 +1293,23 @@ static void
soup_websocket_connection_constructed (GObject *object)
{
SoupWebsocketConnection *self = SOUP_WEBSOCKET_CONNECTION (object);
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
GInputStream *is;
GOutputStream *os;
G_OBJECT_CLASS (soup_websocket_connection_parent_class)->constructed (object);
- g_return_if_fail (pv->io_stream != NULL);
+ g_return_if_fail (priv->io_stream != NULL);
- is = g_io_stream_get_input_stream (pv->io_stream);
+ is = g_io_stream_get_input_stream (priv->io_stream);
g_return_if_fail (G_IS_POLLABLE_INPUT_STREAM (is));
- pv->input = G_POLLABLE_INPUT_STREAM (is);
- g_return_if_fail (g_pollable_input_stream_can_poll (pv->input));
+ priv->input = G_POLLABLE_INPUT_STREAM (is);
+ g_return_if_fail (g_pollable_input_stream_can_poll (priv->input));
- os = g_io_stream_get_output_stream (pv->io_stream);
+ os = g_io_stream_get_output_stream (priv->io_stream);
g_return_if_fail (G_IS_POLLABLE_OUTPUT_STREAM (os));
- pv->output = G_POLLABLE_OUTPUT_STREAM (os);
- g_return_if_fail (g_pollable_output_stream_can_poll (pv->output));
+ priv->output = G_POLLABLE_OUTPUT_STREAM (os);
+ g_return_if_fail (g_pollable_output_stream_can_poll (priv->output));
soup_websocket_connection_start_input_source (self);
}
@@ -1318,7 +1321,7 @@ soup_websocket_connection_get_property (GObject *object,
GParamSpec *pspec)
{
SoupWebsocketConnection *self = SOUP_WEBSOCKET_CONNECTION (object);
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
switch (prop_id) {
case PROP_IO_STREAM:
@@ -1346,15 +1349,15 @@ soup_websocket_connection_get_property (GObject *object,
break;
case PROP_MAX_INCOMING_PAYLOAD_SIZE:
- g_value_set_uint64 (value, pv->max_incoming_payload_size);
+ g_value_set_uint64 (value, priv->max_incoming_payload_size);
break;
case PROP_KEEPALIVE_INTERVAL:
- g_value_set_uint (value, pv->keepalive_interval);
+ g_value_set_uint (value, priv->keepalive_interval);
break;
case PROP_EXTENSIONS:
- g_value_set_pointer (value, pv->extensions);
+ g_value_set_pointer (value, priv->extensions);
break;
default:
@@ -1370,35 +1373,35 @@ soup_websocket_connection_set_property (GObject *object,
GParamSpec *pspec)
{
SoupWebsocketConnection *self = SOUP_WEBSOCKET_CONNECTION (object);
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
switch (prop_id) {
case PROP_IO_STREAM:
- g_return_if_fail (pv->io_stream == NULL);
- pv->io_stream = g_value_dup_object (value);
+ g_return_if_fail (priv->io_stream == NULL);
+ priv->io_stream = g_value_dup_object (value);
break;
case PROP_CONNECTION_TYPE:
- pv->connection_type = g_value_get_enum (value);
+ priv->connection_type = g_value_get_enum (value);
break;
case PROP_URI:
- g_return_if_fail (pv->uri == NULL);
- pv->uri = g_value_dup_boxed (value);
+ g_return_if_fail (priv->uri == NULL);
+ priv->uri = g_value_dup_boxed (value);
break;
case PROP_ORIGIN:
- g_return_if_fail (pv->origin == NULL);
- pv->origin = g_value_dup_string (value);
+ g_return_if_fail (priv->origin == NULL);
+ priv->origin = g_value_dup_string (value);
break;
case PROP_PROTOCOL:
- g_return_if_fail (pv->protocol == NULL);
- pv->protocol = g_value_dup_string (value);
+ g_return_if_fail (priv->protocol == NULL);
+ priv->protocol = g_value_dup_string (value);
break;
case PROP_MAX_INCOMING_PAYLOAD_SIZE:
- pv->max_incoming_payload_size = g_value_get_uint64 (value);
+ priv->max_incoming_payload_size = g_value_get_uint64 (value);
break;
case PROP_KEEPALIVE_INTERVAL:
@@ -1407,7 +1410,7 @@ soup_websocket_connection_set_property (GObject *object,
break;
case PROP_EXTENSIONS:
- pv->extensions = g_value_get_pointer (value);
+ priv->extensions = g_value_get_pointer (value);
break;
default:
@@ -1420,8 +1423,9 @@ static void
soup_websocket_connection_dispose (GObject *object)
{
SoupWebsocketConnection *self = SOUP_WEBSOCKET_CONNECTION (object);
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- self->pv->dirty_close = TRUE;
+ priv->dirty_close = TRUE;
close_io_stream (self);
G_OBJECT_CLASS (soup_websocket_connection_parent_class)->dispose (object);
@@ -1431,34 +1435,34 @@ static void
soup_websocket_connection_finalize (GObject *object)
{
SoupWebsocketConnection *self = SOUP_WEBSOCKET_CONNECTION (object);
- SoupWebsocketConnectionPrivate *pv = self->pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
- g_free (pv->peer_close_data);
+ g_free (priv->peer_close_data);
- g_main_context_unref (pv->main_context);
+ g_main_context_unref (priv->main_context);
- if (pv->incoming)
- g_byte_array_free (pv->incoming, TRUE);
- while (!g_queue_is_empty (&pv->outgoing))
- frame_free (g_queue_pop_head (&pv->outgoing));
+ if (priv->incoming)
+ g_byte_array_free (priv->incoming, TRUE);
+ while (!g_queue_is_empty (&priv->outgoing))
+ frame_free (g_queue_pop_head (&priv->outgoing));
- g_clear_object (&pv->io_stream);
- g_assert (!pv->input_source);
- g_assert (!pv->output_source);
- g_assert (pv->io_closing);
- g_assert (pv->io_closed);
- g_assert (!pv->close_timeout);
- g_assert (!pv->keepalive_timeout);
+ g_clear_object (&priv->io_stream);
+ g_assert (!priv->input_source);
+ g_assert (!priv->output_source);
+ g_assert (priv->io_closing);
+ g_assert (priv->io_closed);
+ g_assert (!priv->close_timeout);
+ g_assert (!priv->keepalive_timeout);
- if (pv->message_data)
- g_byte_array_free (pv->message_data, TRUE);
+ if (priv->message_data)
+ g_byte_array_free (priv->message_data, TRUE);
- if (pv->uri)
- soup_uri_free (pv->uri);
- g_free (pv->origin);
- g_free (pv->protocol);
+ if (priv->uri)
+ soup_uri_free (priv->uri);
+ g_free (priv->origin);
+ g_free (priv->protocol);
- g_list_free_full (pv->extensions, g_object_unref);
+ g_list_free_full (priv->extensions, g_object_unref);
G_OBJECT_CLASS (soup_websocket_connection_parent_class)->finalize (object);
}
@@ -1806,9 +1810,11 @@ soup_websocket_connection_new_with_extensions (GIOStream *str
GIOStream *
soup_websocket_connection_get_io_stream (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
+
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), NULL);
- return self->pv->io_stream;
+ return priv->io_stream;
}
/**
@@ -1824,9 +1830,11 @@ soup_websocket_connection_get_io_stream (SoupWebsocketConnection *self)
SoupWebsocketConnectionType
soup_websocket_connection_get_connection_type (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
+
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), SOUP_WEBSOCKET_CONNECTION_UNKNOWN);
- return self->pv->connection_type;
+ return priv->connection_type;
}
/**
@@ -1845,9 +1853,11 @@ soup_websocket_connection_get_connection_type (SoupWebsocketConnection *self)
SoupURI *
soup_websocket_connection_get_uri (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
+
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), NULL);
- return self->pv->uri;
+ return priv->uri;
}
/**
@@ -1863,9 +1873,11 @@ soup_websocket_connection_get_uri (SoupWebsocketConnection *self)
const char *
soup_websocket_connection_get_origin (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
+
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), NULL);
- return self->pv->origin;
+ return priv->origin;
}
/**
@@ -1881,9 +1893,11 @@ soup_websocket_connection_get_origin (SoupWebsocketConnection *self)
const char *
soup_websocket_connection_get_protocol (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
+
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), NULL);
- return self->pv->protocol;
+ return priv->protocol;
}
/**
@@ -1899,9 +1913,11 @@ soup_websocket_connection_get_protocol (SoupWebsocketConnection *self)
GList *
soup_websocket_connection_get_extensions (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
+
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), NULL);
- return self->pv->extensions;
+ return priv->extensions;
}
/**
@@ -1917,11 +1933,13 @@ soup_websocket_connection_get_extensions (SoupWebsocketConnection *self)
SoupWebsocketState
soup_websocket_connection_get_state (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
+
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), 0);
- if (self->pv->io_closed)
+ if (priv->io_closed)
return SOUP_WEBSOCKET_STATE_CLOSED;
- else if (self->pv->io_closing || self->pv->close_sent)
+ else if (priv->io_closing || priv->close_sent)
return SOUP_WEBSOCKET_STATE_CLOSING;
else
return SOUP_WEBSOCKET_STATE_OPEN;
@@ -1945,9 +1963,11 @@ soup_websocket_connection_get_state (SoupWebsocketConnection *self)
gushort
soup_websocket_connection_get_close_code (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
+
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), 0);
- return self->pv->peer_close_code;
+ return priv->peer_close_code;
}
/**
@@ -1967,9 +1987,11 @@ soup_websocket_connection_get_close_code (SoupWebsocketConnection *self)
const char *
soup_websocket_connection_get_close_data (SoupWebsocketConnection *self)
{
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
+
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), NULL);
- return self->pv->peer_close_data;
+ return priv->peer_close_data;
}
/**
@@ -2083,15 +2105,15 @@ soup_websocket_connection_close (SoupWebsocketConnection *self,
gushort code,
const char *data)
{
- SoupWebsocketConnectionPrivate *pv;
+
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
g_return_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self));
- pv = self->pv;
- g_return_if_fail (!pv->close_sent);
+ g_return_if_fail (!priv->close_sent);
g_return_if_fail (code != SOUP_WEBSOCKET_CLOSE_ABNORMAL &&
code != SOUP_WEBSOCKET_CLOSE_TLS_HANDSHAKE);
- if (pv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER)
+ if (priv->connection_type == SOUP_WEBSOCKET_CONNECTION_SERVER)
g_return_if_fail (code != SOUP_WEBSOCKET_CLOSE_NO_EXTENSION);
else
g_return_if_fail (code != SOUP_WEBSOCKET_CLOSE_SERVER_ERROR);
@@ -2112,12 +2134,11 @@ soup_websocket_connection_close (SoupWebsocketConnection *self,
guint64
soup_websocket_connection_get_max_incoming_payload_size (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), MAX_INCOMING_PAYLOAD_SIZE_DEFAULT);
- pv = self->pv;
- return pv->max_incoming_payload_size;
+ return priv->max_incoming_payload_size;
}
/**
@@ -2134,13 +2155,12 @@ void
soup_websocket_connection_set_max_incoming_payload_size (SoupWebsocketConnection *self,
guint64 max_incoming_payload_size)
{
- SoupWebsocketConnectionPrivate *pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
g_return_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self));
- pv = self->pv;
- if (pv->max_incoming_payload_size != max_incoming_payload_size) {
- pv->max_incoming_payload_size = max_incoming_payload_size;
+ if (priv->max_incoming_payload_size != max_incoming_payload_size) {
+ priv->max_incoming_payload_size = max_incoming_payload_size;
g_object_notify (G_OBJECT (self), "max-incoming-payload-size");
}
}
@@ -2158,12 +2178,11 @@ soup_websocket_connection_set_max_incoming_payload_size (SoupWebsocketConnection
guint
soup_websocket_connection_get_keepalive_interval (SoupWebsocketConnection *self)
{
- SoupWebsocketConnectionPrivate *pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
g_return_val_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self), 0);
- pv = self->pv;
- return pv->keepalive_interval;
+ return priv->keepalive_interval;
}
static gboolean
@@ -2194,21 +2213,20 @@ void
soup_websocket_connection_set_keepalive_interval (SoupWebsocketConnection *self,
guint interval)
{
- SoupWebsocketConnectionPrivate *pv;
+ SoupWebsocketConnectionPrivate *priv = soup_websocket_connection_get_instance_private (self);
g_return_if_fail (SOUP_IS_WEBSOCKET_CONNECTION (self));
- pv = self->pv;
- if (pv->keepalive_interval != interval) {
- pv->keepalive_interval = interval;
+ if (priv->keepalive_interval != interval) {
+ priv->keepalive_interval = interval;
g_object_notify (G_OBJECT (self), "keepalive-interval");
keepalive_stop_timeout (self);
if (interval > 0) {
- pv->keepalive_timeout = g_timeout_source_new_seconds (interval);
- g_source_set_callback (pv->keepalive_timeout, on_queue_ping, self, NULL);
- g_source_attach (pv->keepalive_timeout, pv->main_context);
+ priv->keepalive_timeout = g_timeout_source_new_seconds (interval);
+ g_source_set_callback (priv->keepalive_timeout, on_queue_ping, self, NULL);
+ g_source_attach (priv->keepalive_timeout, priv->main_context);
}
}
}
diff --git a/libsoup/websocket/soup-websocket-connection.h b/libsoup/websocket/soup-websocket-connection.h
index b5e90fb8..503ba19c 100644
--- a/libsoup/websocket/soup-websocket-connection.h
+++ b/libsoup/websocket/soup-websocket-connection.h
@@ -18,31 +18,18 @@
* along with this library; If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __SOUP_WEBSOCKET_CONNECTION_H__
-#define __SOUP_WEBSOCKET_CONNECTION_H__
+#pragma once
#include "soup-types.h"
#include "soup-websocket.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_WEBSOCKET_CONNECTION (soup_websocket_connection_get_type ())
-#define SOUP_WEBSOCKET_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
SOUP_TYPE_WEBSOCKET_CONNECTION, SoupWebsocketConnection))
-#define SOUP_IS_WEBSOCKET_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
SOUP_TYPE_WEBSOCKET_CONNECTION))
-#define SOUP_WEBSOCKET_CONNECTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),
SOUP_TYPE_WEBSOCKET_CONNECTION, SoupWebsocketConnectionClass))
-#define SOUP_WEBSOCKET_CONNECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
SOUP_TYPE_WEBSOCKET_CONNECTION, SoupWebsocketConnectionClass))
-#define SOUP_IS_WEBSOCKET_CONNECTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
SOUP_TYPE_WEBSOCKET_CONNECTION))
-
-typedef struct _SoupWebsocketConnectionPrivate SoupWebsocketConnectionPrivate;
-
-struct _SoupWebsocketConnection {
- GObject parent;
-
- /*< private >*/
- SoupWebsocketConnectionPrivate *pv;
-};
+#define SOUP_TYPE_WEBSOCKET_CONNECTION (soup_websocket_connection_get_type ())
+SOUP_AVAILABLE_IN_2_50
+G_DECLARE_DERIVABLE_TYPE (SoupWebsocketConnection, soup_websocket_connection, SOUP, WEBSOCKET_CONNECTION,
GObject)
-typedef struct {
+struct _SoupWebsocketConnectionClass {
GObjectClass parent;
/* signals */
@@ -59,10 +46,7 @@ typedef struct {
void (* pong) (SoupWebsocketConnection *self,
GBytes *message);
-} SoupWebsocketConnectionClass;
-
-SOUP_AVAILABLE_IN_2_50
-GType soup_websocket_connection_get_type (void) G_GNUC_CONST;
+};
SOUP_AVAILABLE_IN_2_50
SoupWebsocketConnection *soup_websocket_connection_new (GIOStream *stream,
@@ -137,5 +121,3 @@ void soup_websocket_connection_set_keepalive_interval (SoupWebsoc
guint interval);
G_END_DECLS
-
-#endif /* __SOUP_WEBSOCKET_CONNECTION_H__ */
diff --git a/libsoup/websocket/soup-websocket-extension-deflate.c
b/libsoup/websocket/soup-websocket-extension-deflate.c
index c7864426..c343f1d0 100644
--- a/libsoup/websocket/soup-websocket-extension-deflate.c
+++ b/libsoup/websocket/soup-websocket-extension-deflate.c
@@ -53,6 +53,10 @@ typedef struct {
gushort client_max_window_bits;
} Params;
+struct _SoupWebsocketExtensionDeflate {
+ SoupWebsocketExtension parent;
+};
+
typedef struct {
Params params;
diff --git a/libsoup/websocket/soup-websocket-extension-deflate.h
b/libsoup/websocket/soup-websocket-extension-deflate.h
index e353965d..b5b4accf 100644
--- a/libsoup/websocket/soup-websocket-extension-deflate.h
+++ b/libsoup/websocket/soup-websocket-extension-deflate.h
@@ -20,30 +20,14 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __SOUP_WEBSOCKET_EXTENSION_DEFLATE_H__
-#define __SOUP_WEBSOCKET_EXTENSION_DEFLATE_H__ 1
+#pragma once
#include "soup-websocket-extension.h"
-#define SOUP_TYPE_WEBSOCKET_EXTENSION_DEFLATE (soup_websocket_extension_deflate_get_type ())
-#define SOUP_WEBSOCKET_EXTENSION_DEFLATE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object),
SOUP_TYPE_WEBSOCKET_EXTENSION_DEFLATE, SoupWebsocketExtensionDeflate))
-#define SOUP_IS_WEBSOCKET_EXTENSION_DEFLATE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object),
SOUP_TYPE_WEBSOCKET_EXTENSION_DEFLATE))
-#define SOUP_WEBSOCKET_EXTENSION_DEFLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
SOUP_TYPE_WEBSOCKET_EXTENSION_DEFLATE, SoupWebsocketExtensionDeflateClass))
-#define SOUP_IS_WEBSOCKET_EXTENSION_DEFLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
SOUP_TYPE_WEBSOCKET_EXTENSION_DEFLATE))
-#define SOUP_WEBSOCKET_EXTENSION_DEFLATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
SOUP_TYPE_WEBSOCKET_EXTENSION_DEFLATE, SoupWebsocketExtensionDeflateClass))
-
-typedef struct _SoupWebsocketExtensionDeflate SoupWebsocketExtensionDeflate;
-typedef struct _SoupWebsocketExtensionDeflateClass SoupWebsocketExtensionDeflateClass;
-
-struct _SoupWebsocketExtensionDeflate {
- SoupWebsocketExtension parent;
-};
-
-struct _SoupWebsocketExtensionDeflateClass {
- SoupWebsocketExtensionClass parent_class;
-};
+G_BEGIN_DECLS
+#define SOUP_TYPE_WEBSOCKET_EXTENSION_DEFLATE (soup_websocket_extension_deflate_get_type ())
SOUP_AVAILABLE_IN_2_68
-GType soup_websocket_extension_deflate_get_type (void);
+G_DECLARE_FINAL_TYPE (SoupWebsocketExtensionDeflate, soup_websocket_extension_deflate, SOUP,
WEBSOCKET_EXTENSION_DEFLATE, SoupWebsocketExtension)
-#endif /* __SOUP_WEBSOCKET_EXTENSION_DEFLATE_H__ */
+G_END_DECLS
diff --git a/libsoup/websocket/soup-websocket-extension-manager.c
b/libsoup/websocket/soup-websocket-extension-manager.c
index 69c4fd4a..90ca105d 100644
--- a/libsoup/websocket/soup-websocket-extension-manager.c
+++ b/libsoup/websocket/soup-websocket-extension-manager.c
@@ -62,6 +62,10 @@
static void soup_websocket_extension_manager_session_feature_init (SoupSessionFeatureInterface
*feature_interface, gpointer interface_data);
+struct _SoupWebsocketExtensionManager {
+ GObject parent;
+};
+
typedef struct {
GPtrArray *extension_types;
} SoupWebsocketExtensionManagerPrivate;
diff --git a/libsoup/websocket/soup-websocket-extension-manager.h
b/libsoup/websocket/soup-websocket-extension-manager.h
index 0940a53e..8c0a5f9d 100644
--- a/libsoup/websocket/soup-websocket-extension-manager.h
+++ b/libsoup/websocket/soup-websocket-extension-manager.h
@@ -20,31 +20,14 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __SOUP_WEBSOCKET_EXTENSION_MANAGER_H__
-#define __SOUP_WEBSOCKET_EXTENSION_MANAGER_H__ 1
+#pragma once
#include "soup-types.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_WEBSOCKET_EXTENSION_MANAGER (soup_websocket_extension_manager_get_type ())
-#define SOUP_WEBSOCKET_EXTENSION_MANAGER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object),
SOUP_TYPE_WEBSOCKET_EXTENSION_MANAGER, SoupWebsocketExtensionManager))
-#define SOUP_IS_WEBSOCKET_EXTENSION_MANAGER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object),
SOUP_TYPE_WEBSOCKET_EXTENSION_MANAGER))
-#define SOUP_WEBSOCKET_EXTENSION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
SOUP_TYPE_WEBSOCKET_EXTENSION_MANAGER, SoupWebsocketExtensionManagerClass))
-#define SOUP_IS_WEBSOCKET_EXTENSION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
SOUP_TYPE_WEBSOCKET_EXTENSION_MANAGER))
-#define SOUP_WEBSOCKET_EXTENSION_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
SOUP_TYPE_WEBSOCKET_EXTENSION_MANAGER, SoupWebsocketExtensionManagerClass))
-
-typedef struct {
- GObject parent;
-} SoupWebsocketExtensionManager;
-
-typedef struct {
- GObjectClass parent_class;
-} SoupWebsocketExtensionManagerClass;
-
+#define SOUP_TYPE_WEBSOCKET_EXTENSION_MANAGER (soup_websocket_extension_manager_get_type ())
SOUP_AVAILABLE_IN_2_68
-GType soup_websocket_extension_manager_get_type (void);
+G_DECLARE_FINAL_TYPE (SoupWebsocketExtensionManager, soup_websocket_extension_manager, SOUP,
WEBSOCKET_EXTENSION_MANAGER, GObject)
G_END_DECLS
-
-#endif /* __SOUP_WEBSOCKET_EXTENSION_MANAGER_H__ */
diff --git a/libsoup/websocket/soup-websocket-extension.h b/libsoup/websocket/soup-websocket-extension.h
index e8f345a0..7d2d3686 100644
--- a/libsoup/websocket/soup-websocket-extension.h
+++ b/libsoup/websocket/soup-websocket-extension.h
@@ -20,26 +20,18 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __SOUP_WEBSOCKET_EXTENSION_H__
-#define __SOUP_WEBSOCKET_EXTENSION_H__ 1
+#pragma once
#include "soup-types.h"
#include "soup-websocket.h"
G_BEGIN_DECLS
-#define SOUP_TYPE_WEBSOCKET_EXTENSION (soup_websocket_extension_get_type ())
-#define SOUP_WEBSOCKET_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SOUP_TYPE_WEBSOCKET_EXTENSION, SoupWebsocketExtension))
-#define SOUP_IS_WEBSOCKET_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
SOUP_TYPE_WEBSOCKET_EXTENSION))
-#define SOUP_WEBSOCKET_EXTENSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
SOUP_TYPE_WEBSOCKET_EXTENSION, SoupWebsocketExtensionClass))
-#define SOUP_IS_WEBSOCKET_EXTENSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj),
SOUP_TYPE_WEBSOCKET_EXTENSION))
-#define SOUP_WEBSOCKET_EXTENSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
SOUP_TYPE_WEBSOCKET_EXTENSION, SoupWebsocketExtensionClass))
-
-struct _SoupWebsocketExtension {
- GObject parent;
-};
+#define SOUP_TYPE_WEBSOCKET_EXTENSION (soup_websocket_extension_get_type ())
+SOUP_AVAILABLE_IN_2_68
+G_DECLARE_DERIVABLE_TYPE (SoupWebsocketExtension, soup_websocket_extension, SOUP, WEBSOCKET_EXTENSION,
GObject)
-typedef struct {
+struct _SoupWebsocketExtensionClass {
GObjectClass parent_class;
const char *name;
@@ -63,15 +55,8 @@ typedef struct {
GBytes *payload,
GError **error);
- /* Padding for future expansion */
- void (*_libsoup_reserved1) (void);
- void (*_libsoup_reserved2) (void);
- void (*_libsoup_reserved3) (void);
- void (*_libsoup_reserved4) (void);
-} SoupWebsocketExtensionClass;
-
-SOUP_AVAILABLE_IN_2_68
-GType soup_websocket_extension_get_type (void);
+ gpointer padding[6];
+};
SOUP_AVAILABLE_IN_2_68
gboolean soup_websocket_extension_configure (SoupWebsocketExtension
*extension,
@@ -96,5 +81,3 @@ GBytes *soup_websocket_extension_process_incoming_message (Soup
GError
**error);
G_END_DECLS
-
-#endif /* __SOUP_WEBSOCKET_EXTENSION_H__ */
diff --git a/libsoup/websocket/soup-websocket.h b/libsoup/websocket/soup-websocket.h
index b96dec2b..9f265e0a 100644
--- a/libsoup/websocket/soup-websocket.h
+++ b/libsoup/websocket/soup-websocket.h
@@ -18,8 +18,7 @@
* along with this library; If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __SOUP_WEBSOCKET_H__
-#define __SOUP_WEBSOCKET_H__
+#pragma once
#include "soup-types.h"
@@ -113,5 +112,3 @@ soup_websocket_server_process_handshake_with_extensions (SoupMessage *msg,
GList **accepted_extensions);
G_END_DECLS
-
-#endif /* __SOUP_WEBSOCKET_H__ */
diff --git a/libsoup/xmlrpc/soup-xmlrpc.h b/libsoup/xmlrpc/soup-xmlrpc.h
index 2c76d440..2a32e466 100644
--- a/libsoup/xmlrpc/soup-xmlrpc.h
+++ b/libsoup/xmlrpc/soup-xmlrpc.h
@@ -3,8 +3,7 @@
* Copyright 2015 - Collabora Ltd.
*/
-#ifndef __SOUP_XMLRPC_H__
-#define __SOUP_XMLRPC_H__ 1
+#pragma once
#include "soup-types.h"
@@ -91,6 +90,6 @@ typedef enum {
SOUP_XMLRPC_FAULT_TRANSPORT_ERROR = -32300
} SoupXMLRPCFault;
-G_END_DECLS
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SoupXMLRPCParams, soup_xmlrpc_params_free)
-#endif /* __SOUP_XMLRPC_H__ */
+G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]