[gnome-maps/wip/osm-edit: 7/11] osmEdit: Add specialized OAuthProxyCall subclass
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/osm-edit: 7/11] osmEdit: Add specialized OAuthProxyCall subclass
- Date: Sat, 5 Dec 2015 21:10:49 +0000 (UTC)
commit 6ed29f8fa7fb5d302a4dcd1b83e078b85303eb0b
Author: Marcus Lundblad <ml update uu se>
Date: Mon Nov 30 22:50:27 2015 +0100
osmEdit: Add specialized OAuthProxyCall subclass
Add OAuthProxyCall class supporting setting the request content.
configure.ac | 1 +
lib/Makefile.am | 9 ++-
lib/maps-osm-oauth-proxy-call.c | 100 +++++++++++++++++++++++++++++++++++++++
lib/maps-osm-oauth-proxy-call.h | 59 +++++++++++++++++++++++
4 files changed, 166 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5af1165..cd73850 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,7 @@ PKG_CHECK_MODULES(GNOME_MAPS_LIB, [
geocode-glib-1.0 >= $GEOCODE_MIN_VERSION
champlain-0.12 >= $CHAMPLAIN_MIN_VERSION
libxml-2.0
+ rest-0.7
])
AC_SUBST(GNOME_MAPS_LIB_CFLAGS)
AC_SUBST(GNOME_MAPS_LIB_LIBS)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 74818e2..6d4629b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -15,7 +15,8 @@ libgnome_maps_headers_private = \
maps-osm-node.h \
maps-osm-object.h \
maps-osm-relation.h \
- maps-osm-way.h
+ maps-osm-way.h \
+ maps-osm-oauth-proxy-call.h
libgnome_maps_sources = \
maps-contact-store.c \
@@ -26,7 +27,8 @@ libgnome_maps_sources = \
maps-osm-node.c \
maps-osm-object.c \
maps-osm-way.c \
- maps-osm-relation.c
+ maps-osm-relation.c \
+ maps-osm-oauth-proxy-call.c
libgnome_maps_la_SOURCES = \
$(libgnome_maps_sources) \
@@ -58,7 +60,8 @@ GnomeMaps_1_0_gir_INCLUDES = \
GLib-2.0 \
GObject-2.0 \
GeocodeGlib-1.0 \
- Champlain-0.12
+ Champlain-0.12 \
+ Rest-0.7
GnomeMaps_1_0_gir_PACKAGES = gobject-2.0 geocode-glib-1.0
GnomeMaps_1_0_gir_FILES = $(libgnome_maps_la_SOURCES)
GnomeMaps_1_0_gir_CFLAGS = $(MAPS_CFLAGS) -I$(top_srcdir) -I$(top_builddir) -I$(srcdir)
diff --git a/lib/maps-osm-oauth-proxy-call.c b/lib/maps-osm-oauth-proxy-call.c
new file mode 100644
index 0000000..5f6babd
--- /dev/null
+++ b/lib/maps-osm-oauth-proxy-call.c
@@ -0,0 +1,100 @@
+/* maps-osm-oauth-proxy-call.c
+ *
+ * Copyright (C) 2015 Marcus Lundblad <ml update uu se>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "maps-osm-oauth-proxy-call.h"
+
+#include <glib.h>
+#include <rest/rest-proxy-call.h>
+#include <string.h>
+
+#define MAPS_OSM_OAUTH_PROXY_CALL_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), MAPS_TYPE_OSM_OAUTH_PROXY_CALL,\
+ MapsOSMOAuthProxyCallPrivate))
+
+struct _MapsOSMOAuthProxyCallPrivate
+{
+ char *payload;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(MapsOSMOAuthProxyCall, maps_osm_oauth_proxy_call,
+ OAUTH_TYPE_PROXY_CALL);
+
+static gboolean
+maps_osm_oauth_proxy_call_serialize_params (RestProxyCall *call,
+ gchar **content_type,
+ gchar **content,
+ gsize *content_len,
+ GError **error)
+{
+ g_return_val_if_fail(MAPS_IS_OSM_OAUTH_PROXY_CALL (call), FALSE);
+ g_return_val_if_fail(content_type != NULL, FALSE);
+ g_return_val_if_fail(content != NULL, FALSE);
+ g_return_val_if_fail(content_len != NULL, FALSE);
+
+ gchar *payload = (MAPS_OSM_OAUTH_PROXY_CALL (call))->priv->payload;
+
+ *content_type = g_strdup ("text/xml");
+ *content = g_strdup (payload);
+ *content_len = strlen (payload);
+
+ return TRUE;
+}
+
+static void
+maps_osm_oauth_proxy_call_dispose (GObject *object)
+{
+ MapsOSMOAuthProxyCall *call = MAPS_OSM_OAUTH_PROXY_CALL (object);
+
+ g_free (call->priv->payload);
+ call->priv->payload = NULL;
+
+ G_OBJECT_CLASS (maps_osm_oauth_proxy_call_parent_class)->dispose (object);
+}
+
+static void
+maps_osm_oauth_proxy_call_class_init (MapsOSMOAuthProxyCallClass *klass)
+{
+ RestProxyCallClass *proxy_call_class = REST_PROXY_CALL_CLASS (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ proxy_call_class->serialize_params =
+ maps_osm_oauth_proxy_call_serialize_params;
+ gobject_class->dispose = maps_osm_oauth_proxy_call_dispose;
+}
+
+static void
+maps_osm_oauth_proxy_call_init (MapsOSMOAuthProxyCall *call)
+{
+ call->priv = MAPS_OSM_OAUTH_PROXY_CALL_GET_PRIVATE (call);
+}
+
+MapsOSMOAuthProxyCall *
+maps_osm_oauth_proxy_call_new (OAuthProxy *proxy, const char *payload)
+{
+ g_return_val_if_fail (OAUTH_IS_PROXY (proxy), NULL);
+ g_return_val_if_fail (payload != NULL, NULL);
+
+ MapsOSMOAuthProxyCall *call =
+ g_object_new (MAPS_TYPE_OSM_OAUTH_PROXY_CALL, "proxy", proxy, NULL);
+
+ call->priv->payload = g_strdup (payload);
+
+ return call;
+}
+
+
diff --git a/lib/maps-osm-oauth-proxy-call.h b/lib/maps-osm-oauth-proxy-call.h
new file mode 100644
index 0000000..bdd9ef5
--- /dev/null
+++ b/lib/maps-osm-oauth-proxy-call.h
@@ -0,0 +1,59 @@
+/* maps-osm-oauth-proxy-call.h
+ *
+ * Copyright (C) 2015 Marcus Lundblad <ml update uu se>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+#ifndef MAPS_OSM_OAUTH_PROXY_CALL_H
+#define MAPS_OSM_OAUTH_PROXY_CALL_H
+
+#include <glib-object.h>
+
+#include <rest/oauth-proxy-call.h>
+#include <rest/oauth-proxy.h>
+
+G_BEGIN_DECLS
+
+#define MAPS_TYPE_OSM_OAUTH_PROXY_CALL (maps_osm_oauth_proxy_call_get_type ())
+#define MAPS_OSM_OAUTH_PROXY_CALL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
MAPS_TYPE_OSM_OAUTH_PROXY_CALL, MapsOSMOAuthProxyCall))
+#define MAPS_OSM_OAUTH_PROXY_CALL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
MAPS_TYPE_OSM_OAUTH_PROXY_CALL, MapsOSMOAuthProxyCallClass))
+#define MAPS_IS_OSM_OAUTH_PROXY_CALL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
MAPS_TYPE_OSM_OAUTH_PROXY_CALL))
+#define MAPS_IS_OSM_OAUTH_PROXY_CALL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
MAPS_TYPE_OSM_OAUTH_PROXY_CALL))
+#define MAPS_OSM_OAUTH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
MAPS_TYPE_OSM_OAUTH_PROXY_CALL, MapsOSMOAuthProxyCallClass))
+
+typedef struct _MapsOSMOAuthProxyCall MapsOSMOAuthProxyCall;
+typedef struct _MapsOSMOAuthProxyCallPrivate MapsOSMOAuthProxyCallPrivate;
+typedef struct _MapsOSMOAuthProxyCallClass MapsOSMOAuthProxyCallClass;
+
+struct _MapsOSMOAuthProxyCall
+{
+ OAuthProxyCall parent;
+ MapsOSMOAuthProxyCallPrivate *priv;
+};
+
+struct _MapsOSMOAuthProxyCallClass
+{
+ OAuthProxyCallClass parent_class;
+};
+
+GType maps_osm_oauth_proxy_call_get_type(void);
+MapsOSMOAuthProxyCall *maps_osm_oauth_proxy_call_new (OAuthProxy *proxy,
+ const char *content);
+
+G_END_DECLS
+
+#endif /* MAPS_OSM_OAUTH_PROXY_CALL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]