summaryrefslogtreecommitdiff
path: root/rest
diff options
context:
space:
mode:
authorRob Bradford <rob@o-hand.com>2008-09-03 14:24:54 +0100
committerRob Bradford <rob@linux.intel.com>2008-09-04 16:17:51 +0100
commitb0d8e6779895caba4d2913b942e86f4a444bc7d5 (patch)
treee2657c5f557ffe940f2594d369820a43306f0d77 /rest
parent5e16416f8ae2dd994f4bf3fb3432c6a3543d5c20 (diff)
downloadlibrest-b0d8e6779895caba4d2913b942e86f4a444bc7d5.tar.gz
Add first phase of cairoficiation of the API.
Diffstat (limited to 'rest')
-rw-r--r--rest/Makefile.am10
-rw-r--r--rest/rest-proxy-call.c70
-rw-r--r--rest/rest-proxy-call.h106
-rw-r--r--rest/rest-proxy.h6
4 files changed, 188 insertions, 4 deletions
diff --git a/rest/Makefile.am b/rest/Makefile.am
index 6cea68e..3fb3c6d 100644
--- a/rest/Makefile.am
+++ b/rest/Makefile.am
@@ -3,6 +3,12 @@ lib_LTLIBRARIES = librest.la
librest_la_CFLAGS = $(GLIB_CFLAGS) $(SOUP_CFLAGS) $(JSON_CFLAGS) $(XML_CFLAGS) \
-Wall -DG_LOG_DOMAIN=\"Rest\"
librest_la_LIBADD = $(GLIB_LIBS) $(SOUP_LIBS) $(JSON_CFLAGS) $(XML_LIBS)
-librest_la_SOURCES = rest-proxy.c rest-xml-parser.c rest-main.c rest-private.h
-librest_la_HEADERS = rest-proxy.h rest-xml-parser.h
+librest_la_SOURCES = rest-proxy.c \
+ rest-proxy-call.c \
+ rest-xml-parser.c \
+ rest-main.c \
+ rest-private.h
+librest_la_HEADERS = rest-proxy.h \
+ rest-proxy-call.h \
+ rest-xml-parser.h
librest_ladir = $(includedir)/rest/rest
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
new file mode 100644
index 0000000..ca5a24e
--- /dev/null
+++ b/rest/rest-proxy-call.c
@@ -0,0 +1,70 @@
+#include <rest/rest-proxy-call.h>
+
+G_DEFINE_TYPE (RestProxyCall, rest_proxy_call, G_TYPE_OBJECT)
+
+#define GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), REST_TYPE_PROXY_CALL, RestProxyCallPrivate))
+
+typedef struct _RestProxyCallPrivate RestProxyCallPrivate;
+
+struct _RestProxyCallPrivate {
+};
+
+static void
+rest_proxy_call_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec)
+{
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+rest_proxy_call_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+rest_proxy_call_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (rest_proxy_call_parent_class)->dispose)
+ G_OBJECT_CLASS (rest_proxy_call_parent_class)->dispose (object);
+}
+
+static void
+rest_proxy_call_finalize (GObject *object)
+{
+ if (G_OBJECT_CLASS (rest_proxy_call_parent_class)->finalize)
+ G_OBJECT_CLASS (rest_proxy_call_parent_class)->finalize (object);
+}
+
+static void
+rest_proxy_call_class_init (RestProxyCallClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (RestProxyCallPrivate));
+
+ object_class->get_property = rest_proxy_call_get_property;
+ object_class->set_property = rest_proxy_call_set_property;
+ object_class->dispose = rest_proxy_call_dispose;
+ object_class->finalize = rest_proxy_call_finalize;
+}
+
+static void
+rest_proxy_call_init (RestProxyCall *self)
+{
+}
+
+RestProxyCall*
+rest_proxy_call_new (void)
+{
+ return g_object_new (REST_TYPE_PROXY_CALL, NULL);
+}
+
diff --git a/rest/rest-proxy-call.h b/rest/rest-proxy-call.h
new file mode 100644
index 0000000..5bdbe4a
--- /dev/null
+++ b/rest/rest-proxy-call.h
@@ -0,0 +1,106 @@
+#ifndef _REST_PROXY_CALL
+#define _REST_PROXY_CALL
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define REST_TYPE_PROXY_CALL rest_proxy_call_get_type()
+
+#define REST_PROXY_CALL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), REST_TYPE_PROXY_CALL, RestProxyCall))
+
+#define REST_PROXY_CALL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), REST_TYPE_PROXY_CALL, RestProxyCallClass))
+
+#define REST_IS_PROXY_CALL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), REST_TYPE_PROXY_CALL))
+
+#define REST_IS_PROXY_CALL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), REST_TYPE_PROXY_CALL))
+
+#define REST_PROXY_CALL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), REST_TYPE_PROXY_CALL, RestProxyCallClass))
+
+typedef struct {
+ GObject parent;
+} RestProxyCall;
+
+typedef struct {
+ GObjectClass parent_class;
+} RestProxyCallClass;
+
+GType rest_proxy_call_get_type (void);
+
+/* Functions for dealing with request */
+void rest_proxy_call_set_method (RestProxyCall *call,
+ const gchar *method);
+
+void rest_proxy_call_add_header (RestProxyCall *call,
+ const gchar *header,
+ const gchar *value);
+
+void rest_proxy_call_add_headers (RestProxyCall *call,
+ const char *first_header_name,
+ ...);
+
+void rest_proxy_call_add_headers_from_valist (RestProxyCall *call,
+ va_list headers);
+
+void rest_proxy_call_add_headers_from_hash (RestProxyCall *call,
+ GHashTable *headers);
+
+const gchar *rest_proxy_call_lookup_header (RestProxyCall *call,
+ const gchar *header);
+
+void rest_proxy_call_remove_header (RestProxyCall *call,
+ const gchar *header);
+
+void rest_proxy_call_add_param (RestProxyCall *call,
+ const gchar *param,
+ const gchar *value);
+
+void rest_proxy_call_add_params (RestProxyCall *call,
+ const char *first_param_name,
+ ...);
+
+void rest_proxy_call_add_params_from_valist (RestProxyCall *call,
+ va_list params);
+
+void rest_proxy_call_add_params_from_hash (RestProxyCall *call,
+ GHashTable *params);
+
+const gchar *rest_proxy_call_lookup_param (RestProxyCall *call,
+ const gchar *param);
+
+void rest_proxy_call_remove_param (RestProxyCall *call,
+ const gchar *param);
+
+gboolean rest_proxy_call_run (RestProxyCall *call,
+ GMainLoop **loop,
+ GError **error);
+
+typedef void (*RestProxyCallRunAsyncCallback)(RestProxyCall *call,
+ gssize len,
+ GObject *weak_object,
+ gpointer userdata);
+
+void rest_proxy_call_run_async (RestProxyCall *call,
+ RestProxyCallRunAsyncCallback callback,
+ GObject *weak_object,
+ gpointer userdata,
+ GError **error);
+
+/* Functions for dealing with responses */
+
+const gchar *rest_proxy_call_lookup_response_header (RestProxyCall *call,
+ const gchar *header);
+
+gssize rest_proxy_call_get_payload_length (RestProxyCall *call);
+const gchar *rest_proxy_call_get_payload (RestProxyCall *call);
+guint rest_proxy_call_get_status_code (RestProxyCall *call);
+
+G_END_DECLS
+
+#endif /* _REST_PROXY_CALL */
+
diff --git a/rest/rest-proxy.h b/rest/rest-proxy.h
index feda9ba..52aed13 100644
--- a/rest/rest-proxy.h
+++ b/rest/rest-proxy.h
@@ -5,6 +5,7 @@
#include <json-glib/json-glib.h>
+#include <rest/rest-proxy-call.h>
G_BEGIN_DECLS
#define REST_TYPE_PROXY rest_proxy_get_type()
@@ -98,8 +99,7 @@ gboolean rest_proxy_call_json_async (RestProxy *proxy,
const gchar *first_field_name,
...);
-gboolean
-rest_proxy_call_json_async_valist (RestProxy *proxy,
+gboolean rest_proxy_call_json_async_valist (RestProxy *proxy,
const gchar *function,
const gchar *method,
RestProxyCallJsonCallback callback,
@@ -109,6 +109,8 @@ rest_proxy_call_json_async_valist (RestProxy *proxy,
const gchar *first_field_name,
va_list params);
+RestProxyCall *rest_proxy_new_call (RestProxy *proxy);
+
G_END_DECLS
#endif /* _REST_PROXY */