[gnome-online-accounts] Add GoaRestProxy



commit 7d9e1ab69cf59ba7b9ff15673697581ff708810d
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Aug 3 18:36:37 2017 +0200

    Add GoaRestProxy
    
    This uses g_log_default_handler, via GoaSoupLogger, instead of raw
    printf to log the RestProxy's HTTP traffic.

 src/goabackend/Makefile.am    |    1 +
 src/goabackend/goarestproxy.c |   70 +++++++++++++++++++++++++++++++++++++++++
 src/goabackend/goarestproxy.h |   50 +++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+), 0 deletions(-)
---
diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am
index d54eb37..7d6340a 100644
--- a/src/goabackend/Makefile.am
+++ b/src/goabackend/Makefile.am
@@ -76,6 +76,7 @@ libgoa_backend_1_0_la_SOURCES =                                               \
        goaproviderfactory.h            goaproviderfactory.c            \
        goamailauth.h                   goamailauth.c                   \
        goaimapauthlogin.h              goaimapauthlogin.c              \
+       goarestproxy.h                  goarestproxy.c                  \
        goasmtpauth.h                   goasmtpauth.c                   \
        goasouplogger.h                 goasouplogger.c                 \
        goamailclient.h                 goamailclient.c                 \
diff --git a/src/goabackend/goarestproxy.c b/src/goabackend/goarestproxy.c
new file mode 100644
index 0000000..e5d4bb5
--- /dev/null
+++ b/src/goabackend/goarestproxy.c
@@ -0,0 +1,70 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright © 2017 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "goarestproxy.h"
+#include "goasouplogger.h"
+
+struct _GoaRestProxy
+{
+  RestProxy parent_instance;
+};
+
+struct _GoaRestProxyClass
+{
+  RestProxyClass parent_class;
+};
+
+G_DEFINE_TYPE (GoaRestProxy, goa_rest_proxy, REST_TYPE_PROXY);
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+goa_rest_proxy_constructed (GObject *object)
+{
+  GoaRestProxy *self = GOA_REST_PROXY (object);
+  SoupLogger *logger = NULL;
+
+  G_OBJECT_CLASS (goa_rest_proxy_parent_class)->constructed (object);
+
+  logger = goa_soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
+  rest_proxy_add_soup_feature (REST_PROXY (self), SOUP_SESSION_FEATURE (logger));
+  g_object_unref (logger);
+}
+
+static void
+goa_rest_proxy_init (GoaRestProxy *self)
+{
+}
+
+static void
+goa_rest_proxy_class_init (GoaRestProxyClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->constructed = goa_rest_proxy_constructed;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+RestProxy *
+goa_rest_proxy_new (const gchar  *url_format,
+                    gboolean      binding_required)
+{
+  return g_object_new (GOA_TYPE_REST_PROXY, "url-format", url_format, "binding-required", binding_required, 
NULL);
+}
diff --git a/src/goabackend/goarestproxy.h b/src/goabackend/goarestproxy.h
new file mode 100644
index 0000000..04af426
--- /dev/null
+++ b/src/goabackend/goarestproxy.h
@@ -0,0 +1,50 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright © 2017 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined (__GOA_BACKEND_INSIDE_GOA_BACKEND_H__) && !defined (GOA_BACKEND_COMPILATION)
+#error "Only <goabackend/goabackend.h> can be included directly."
+#endif
+
+#ifndef __GOA_REST_PROXY_H__
+#define __GOA_REST_PROXY_H__
+
+#include <rest/rest-proxy.h>
+
+G_BEGIN_DECLS
+
+#define GOA_TYPE_REST_PROXY (goa_rest_proxy_get_type ())
+
+#define GOA_REST_PROXY(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   GOA_TYPE_REST_PROXY, GoaRestProxy))
+
+#define GOA_IS_REST_PROXY(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   GOA_TYPE_REST_PROXY))
+
+typedef struct _GoaRestProxy      GoaRestProxy;
+typedef struct _GoaRestProxyClass GoaRestProxyClass;
+
+GType          goa_rest_proxy_get_type           (void) G_GNUC_CONST;
+
+RestProxy     *goa_rest_proxy_new                (const gchar  *url_format,
+                                                  gboolean      binding_required);
+
+G_END_DECLS
+
+#endif /* __GOA_REST_PROXY_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]