[librest/gwagner/deprecated: 4/14] rest-proxy: modernized and aligned
- From: Günther Wagner <gwagner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librest/gwagner/deprecated: 4/14] rest-proxy: modernized and aligned
- Date: Wed, 12 Jan 2022 19:05:06 +0000 (UTC)
commit df87882f59645fa8d52f0848d522270411e2d562
Author: Günther Wagner <info gunibert de>
Date: Wed Dec 22 17:59:49 2021 +0100
rest-proxy: modernized and aligned
rest/rest-proxy.c | 69 +++++++++++++++++++++++++++++--------------------------
rest/rest-proxy.h | 61 +++++++++++++++++++++---------------------------
2 files changed, 63 insertions(+), 67 deletions(-)
---
diff --git a/rest/rest-proxy.c b/rest/rest-proxy.c
index 8231b6f..d8dbfc6 100644
--- a/rest/rest-proxy.c
+++ b/rest/rest-proxy.c
@@ -31,8 +31,6 @@
#include "rest-private.h"
-#define GET_PRIVATE(o) rest_proxy_get_instance_private(REST_PROXY(o))
-
typedef struct _RestProxyPrivate RestProxyPrivate;
struct _RestProxyPrivate {
@@ -74,16 +72,14 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-static gboolean _rest_proxy_simple_run_valist (RestProxy *proxy,
- char **payload,
- goffset *len,
- GError **error,
- va_list params);
-
-static RestProxyCall *_rest_proxy_new_call (RestProxy *proxy);
-
-static gboolean _rest_proxy_bind_valist (RestProxy *proxy,
- va_list params);
+static gboolean _rest_proxy_simple_run_valist (RestProxy *proxy,
+ char **payload,
+ goffset *len,
+ GError **error,
+ va_list params);
+static RestProxyCall *_rest_proxy_new_call (RestProxy *proxy);
+static gboolean _rest_proxy_bind_valist (RestProxy *proxy,
+ va_list params);
GQuark
rest_proxy_error_quark (void)
@@ -97,7 +93,8 @@ rest_proxy_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- RestProxyPrivate *priv = GET_PRIVATE (object);
+ RestProxy *self = REST_PROXY (object);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (self);
switch (property_id) {
case PROP_URL_FORMAT:
@@ -145,7 +142,8 @@ rest_proxy_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- RestProxyPrivate *priv = GET_PRIVATE (object);
+ RestProxy *self = REST_PROXY (object);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (self);
switch (property_id) {
case PROP_URL_FORMAT:
@@ -199,7 +197,8 @@ rest_proxy_set_property (GObject *object,
static void
rest_proxy_dispose (GObject *object)
{
- RestProxyPrivate *priv = GET_PRIVATE (object);
+ RestProxy *self = REST_PROXY (object);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (self);
g_clear_object (&priv->session);
@@ -226,7 +225,7 @@ authenticate (RestProxy *self,
gboolean retrying,
SoupSession *session)
{
- RestProxyPrivate *priv = GET_PRIVATE (self);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (self);
RestProxyAuth *rest_auth;
gboolean try_auth;
@@ -241,7 +240,8 @@ authenticate (RestProxy *self,
static void
rest_proxy_constructed (GObject *object)
{
- RestProxyPrivate *priv = GET_PRIVATE (object);
+ RestProxy *self = REST_PROXY (object);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (self);
if (!priv->disable_cookies) {
SoupSessionFeature *cookie_jar =
@@ -270,7 +270,8 @@ rest_proxy_constructed (GObject *object)
static void
rest_proxy_finalize (GObject *object)
{
- RestProxyPrivate *priv = GET_PRIVATE (object);
+ RestProxy *self = REST_PROXY (object);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (self);
g_free (priv->url);
g_free (priv->url_format);
@@ -440,14 +441,17 @@ transform_tls_database_to_ssl_ca_file (GBinding *binding,
static void
rest_proxy_init (RestProxy *self)
{
- RestProxyPrivate *priv = GET_PRIVATE (self);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (self);
+#ifdef REST_SYSTEM_CA_FILE
GTlsDatabase *tls_database;
+#endif
#ifndef WITH_SOUP_2
priv->ssl_strict = TRUE;
#endif
priv->session = soup_session_new ();
+ soup_session_remove_feature_by_type (priv->session, SOUP_TYPE_AUTH_MANAGER);
#ifdef REST_SYSTEM_CA_FILE
/* with ssl-strict (defaults TRUE) setting ssl-ca-file forces all
@@ -532,7 +536,7 @@ static gboolean
_rest_proxy_bind_valist (RestProxy *proxy,
va_list params)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (proxy);
g_return_val_if_fail (proxy != NULL, FALSE);
g_return_val_if_fail (priv->url_format != NULL, FALSE);
@@ -583,7 +587,7 @@ rest_proxy_set_user_agent (RestProxy *proxy,
const gchar *
rest_proxy_get_user_agent (RestProxy *proxy)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (proxy);
g_return_val_if_fail (REST_IS_PROXY (proxy), NULL);
@@ -613,9 +617,10 @@ rest_proxy_get_user_agent (RestProxy *proxy)
* Since: 0.7.92
*/
void
-rest_proxy_add_soup_feature (RestProxy *proxy, SoupSessionFeature *feature)
+rest_proxy_add_soup_feature (RestProxy *proxy,
+ SoupSessionFeature *feature)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (proxy);
g_return_if_fail (REST_IS_PROXY(proxy));
g_return_if_fail (feature != NULL);
@@ -659,7 +664,7 @@ rest_proxy_new_call (RestProxy *proxy)
gboolean
_rest_proxy_get_binding_required (RestProxy *proxy)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (proxy);
g_return_val_if_fail (REST_IS_PROXY (proxy), FALSE);
@@ -669,14 +674,14 @@ _rest_proxy_get_binding_required (RestProxy *proxy)
const gchar *
_rest_proxy_get_bound_url (RestProxy *proxy)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (proxy);
g_return_val_if_fail (REST_IS_PROXY (proxy), NULL);
if (!priv->url && !priv->binding_required)
- {
- priv->url = g_strdup (priv->url_format);
- }
+ {
+ priv->url = g_strdup (priv->url_format);
+ }
return priv->url;
}
@@ -791,7 +796,7 @@ _rest_proxy_queue_message (RestProxy *proxy,
RestMessageFinishedCallback callback,
gpointer user_data)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (proxy);
RestMessageQueueData *data;
g_return_if_fail (REST_IS_PROXY (proxy));
@@ -841,7 +846,7 @@ _rest_proxy_send_message_async (RestProxy *proxy,
GAsyncReadyCallback callback,
gpointer user_data)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (proxy);
GTask *task;
task = g_task_new (proxy, cancellable, callback, user_data);
@@ -868,7 +873,7 @@ _rest_proxy_cancel_message (RestProxy *proxy,
SoupMessage *message)
{
#ifdef WITH_SOUP_2
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (proxy);
g_return_if_fail (REST_IS_PROXY (proxy));
g_return_if_fail (SOUP_IS_MESSAGE (message));
@@ -885,7 +890,7 @@ _rest_proxy_send_message (RestProxy *proxy,
GCancellable *cancellable,
GError **error)
{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
+ RestProxyPrivate *priv = rest_proxy_get_instance_private (proxy);
GBytes *body;
g_return_val_if_fail (REST_IS_PROXY (proxy), NULL);
diff --git a/rest/rest-proxy.h b/rest/rest-proxy.h
index bb6d7b0..4b2a813 100644
--- a/rest/rest-proxy.h
+++ b/rest/rest-proxy.h
@@ -160,41 +160,32 @@ typedef enum {
GQuark rest_proxy_error_quark (void);
-RestProxy *rest_proxy_new (const gchar *url_format,
- gboolean binding_required);
-
-RestProxy *
-rest_proxy_new_with_authentication (const gchar *url_format,
- gboolean binding_required,
- const gchar *username,
- const gchar *password);
-
-gboolean rest_proxy_bind (RestProxy *proxy,
- ...);
-
-gboolean rest_proxy_bind_valist (RestProxy *proxy,
- va_list params);
-
-void rest_proxy_set_user_agent (RestProxy *proxy, const char *user_agent);
-
-const gchar *rest_proxy_get_user_agent (RestProxy *proxy);
-
-void rest_proxy_add_soup_feature (RestProxy *proxy,
- SoupSessionFeature *feature);
-
-RestProxyCall *rest_proxy_new_call (RestProxy *proxy);
-
-G_GNUC_NULL_TERMINATED
-gboolean rest_proxy_simple_run (RestProxy *proxy,
- gchar **payload,
- goffset *len,
- GError **error,
- ...);
-gboolean rest_proxy_simple_run_valist (RestProxy *proxy,
- gchar **payload,
- goffset *len,
- GError **error,
- va_list params);
+RestProxy *rest_proxy_new (const gchar *url_format,
+ gboolean binding_required);
+RestProxy *rest_proxy_new_with_authentication (const gchar *url_format,
+ gboolean binding_required,
+ const gchar *username,
+ const gchar *password);
+gboolean rest_proxy_bind (RestProxy *proxy,
+ ...);
+gboolean rest_proxy_bind_valist (RestProxy *proxy,
+ va_list params);
+void rest_proxy_set_user_agent (RestProxy *proxy,
+ const char *user_agent);
+const gchar *rest_proxy_get_user_agent (RestProxy *proxy);
+void rest_proxy_add_soup_feature (RestProxy *proxy,
+ SoupSessionFeature *feature);
+RestProxyCall *rest_proxy_new_call (RestProxy *proxy);
+gboolean rest_proxy_simple_run (RestProxy *proxy,
+ gchar **payload,
+ goffset *len,
+ GError **error,
+ ...) G_GNUC_NULL_TERMINATED;
+gboolean rest_proxy_simple_run_valist (RestProxy *proxy,
+ gchar **payload,
+ goffset *len,
+ GError **error,
+ va_list params);
G_END_DECLS
#endif /* _REST_PROXY */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]