summaryrefslogtreecommitdiff
path: root/rest/rest-proxy.c
diff options
context:
space:
mode:
authorRob Bradford <rob@linux.intel.com>2008-11-20 12:11:28 +0000
committerRob Bradford <rob@linux.intel.com>2008-11-20 14:11:01 +0000
commit95bf9dcb7565fba8eb89430f90f7391bf181c417 (patch)
treea456360d19862c89a266d81df75163570a76ab3d /rest/rest-proxy.c
parenta33e86af319e0e533dcf21822d2ade1064b5636a (diff)
downloadlibrest-95bf9dcb7565fba8eb89430f90f7391bf181c417.tar.gz
Remove deprecated functions
The functionality that these functions provided can be achieved using RestProxyCall and rest_proxy_simple_run.
Diffstat (limited to 'rest/rest-proxy.c')
-rw-r--r--rest/rest-proxy.c323
1 files changed, 0 insertions, 323 deletions
diff --git a/rest/rest-proxy.c b/rest/rest-proxy.c
index 9c3667d..361d325 100644
--- a/rest/rest-proxy.c
+++ b/rest/rest-proxy.c
@@ -227,329 +227,6 @@ rest_proxy_bind (RestProxy *proxy, ...)
return res;
}
-typedef struct {
- RestProxy *proxy;
- RestProxyCallRawCallback callback;
- GObject *weak_object;
- gpointer userdata;
- SoupMessage *message;
-} RestProxyCallRawAsyncClosure;
-
-static void _call_raw_async_weak_notify_cb (gpointer *data,
- GObject *dead_object);
-static void _call_raw_async_finished_cb (SoupMessage *message,
- gpointer userdata);
-
-static void
-_populate_headers_hash_table (const gchar *name,
- const gchar *value,
- gpointer userdata)
-{
- GHashTable *headers = (GHashTable *)userdata;
-
- g_hash_table_insert (headers, g_strdup (name), g_strdup (value));
-}
-
-static void
-_call_raw_async_finished_cb (SoupMessage *message,
- gpointer userdata)
-{
- RestProxyCallRawAsyncClosure *closure;
- GHashTable *headers;
-
- closure = (RestProxyCallRawAsyncClosure *)userdata;
-
- headers = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- g_free);
-
- /* Convert the soup headers in to hash */
- /* FIXME: Eeek..are you allowed duplicate headers? ... */
- soup_message_headers_foreach (
- message->response_headers,
- (SoupMessageHeadersForeachFunc)_populate_headers_hash_table,
- headers);
-
- closure->callback (closure->proxy, /* proxy */
- message->status_code, /* status code */
- message->reason_phrase, /* status message */
- headers, /* hash of headers */
- message->response_body->data, /* payload */
- message->response_body->length, /* payload length */
- closure->weak_object,
- closure->userdata);
-
- /* Finished with the headers. */
- g_hash_table_unref (headers);
-
- /* Success. We don't need the weak reference any more */
- if (closure->weak_object)
- {
- g_object_weak_unref (closure->weak_object,
- (GWeakNotify)_call_raw_async_weak_notify_cb,
- closure);
- }
-
- g_object_unref (closure->proxy);
- g_free (closure);
-}
-
-static void
-_call_raw_async_weak_notify_cb (gpointer *data,
- GObject *dead_object)
-{
- RestProxyCallRawAsyncClosure *closure;
-
- closure = (RestProxyCallRawAsyncClosure *)data;
-
- /* Remove the "finished" signal handler on the message */
- g_signal_handlers_disconnect_by_func (closure->message,
- _call_raw_async_finished_cb,
- closure);
-
- g_object_unref (closure->proxy);
- g_free (closure);
-}
-
-gboolean
-rest_proxy_call_raw_async_valist (RestProxy *proxy,
- const gchar *function,
- const gchar *method,
- RestProxyCallRawCallback callback,
- GObject *weak_object,
- gpointer userdata,
- GError **error,
- const gchar *first_field_name,
- va_list params)
-{
- RestProxyPrivate *priv = GET_PRIVATE (proxy);
- SoupMessage *message = NULL;
- gchar *url = NULL;
- RestProxyCallRawAsyncClosure *closure;
- SoupURI *uri;
- gchar *formdata;
-
- if (priv->binding_required && !priv->url)
- {
- g_critical (G_STRLOC ": URL requires binding and is unbound");
- /* FIXME: Return a GError */
- return FALSE;
- }
-
- if (!priv->binding_required)
- {
- priv->url = g_strdup (priv->url_format);
- }
-
- /* FIXME: Perhaps excessive memory duplication */
- if (function)
- {
- if (g_str_has_suffix (priv->url, "/"))
- {
- url = g_strdup_printf ("%s%s", priv->url, function);
- } else {
- url = g_strdup_printf ("%s/%s", priv->url, function);
- }
- } else {
- url = g_strdup (priv->url);
- }
-
- if (first_field_name)
- {
- uri = soup_uri_new (url);
-
- if (!uri)
- {
- g_warning (G_STRLOC ": Unable to parse URI: %s", url);
- return FALSE;
- }
-
- formdata = soup_form_encode_valist (first_field_name, params);
-
- /* In the GET case we must encode into the URI */
- if (g_str_equal (method, "GET"))
- {
- soup_uri_set_query (uri, formdata);
- g_free (formdata);
- formdata = NULL;
- }
-
- message = soup_message_new_from_uri (method, uri);
- soup_uri_free (uri);
-
- /* In the POST case we must encode into the request */
- if (g_str_equal (method, "POST"))
- {
- /* This function takes over the memory so no need to free */
- soup_message_set_request (message,
- "application/x-www-form-urlencoded",
- SOUP_MEMORY_TAKE,
- formdata,
- strlen (formdata));
- formdata = NULL;
- }
-
- if (formdata)
- {
- g_warning (G_STRLOC ": Unexpected method: %s", method);
- g_free (formdata);
- return FALSE;
- }
- } else {
- message = soup_message_new (method, url);
- }
-
- /* Set up the closure. */
- /* FIXME: For cancellation perhaps we should return an opaque like dbus */
- closure = g_new0 (RestProxyCallRawAsyncClosure, 1);
- closure->proxy = g_object_ref (proxy);
- closure->callback = callback;
- closure->weak_object = weak_object;
- closure->message = message;
- closure->userdata = userdata;
-
- /* Weakly reference this object. We remove our callback if it goes away. */
- if (closure->weak_object)
- {
- g_object_weak_ref (closure->weak_object,
- (GWeakNotify)_call_raw_async_weak_notify_cb,
- closure);
- }
-
- g_signal_connect (message,
- "finished",
- (GCallback)_call_raw_async_finished_cb,
- closure);
-
- /* TODO: Should we do something in this callback ? */
- soup_session_queue_message (priv->session,
- message,
- NULL,
- NULL);
-
- g_free (url);
- return TRUE;
-}
-
-gboolean
-rest_proxy_call_raw_async (RestProxy *proxy,
- const gchar *function,
- const gchar *method,
- RestProxyCallRawCallback callback,
- GObject *weak_object,
- gpointer userdata,
- GError **error,
- const gchar *first_field_name,
- ...)
-
-{
- gboolean res;
- va_list params;
-
- va_start (params, first_field_name);
- res = rest_proxy_call_raw_async_valist (proxy,
- function,
- method,
- callback,
- weak_object,
- userdata,
- error,
- first_field_name,
- params);
- va_end (params);
-
- return res;
-}
-
-typedef struct
-{
- GMainLoop *loop;
- guint *status_code;
- gchar **response_message;
- GHashTable **headers;
- gchar **payload;
- goffset *len;
-} RestProxyRunRawClosure;
-
-static void
-_call_raw_async_for_run_raw_cb (RestProxy *proxy,
- guint status_code,
- const gchar *response_message,
- GHashTable *headers,
- const gchar *payload,
- goffset len,
- GObject *weak_object,
- gpointer userdata)
-{
- RestProxyRunRawClosure *closure;
-
- closure = (RestProxyRunRawClosure *)userdata;
-
- if (closure->status_code)
- *(closure->status_code) = status_code;
-
- if (closure->response_message)
- *(closure->response_message) = g_strdup (response_message);
-
- if (closure->headers)
- *(closure->headers) = g_hash_table_ref (headers);
-
- if (closure->payload)
- *(closure->payload) = g_memdup (payload, len);
-
- if (closure->len)
- *(closure->len) = len;
-
- g_main_loop_quit (closure->loop);
-}
-
-gboolean
-rest_proxy_run_raw (RestProxy *proxy,
- const gchar *function,
- const gchar *method,
- guint *status_code,
- gchar **response_message,
- GHashTable **headers,
- gchar **payload,
- goffset *len,
- GError **error,
- const gchar *first_field_name,
- ...)
-{
- RestProxyRunRawClosure *closure;
- va_list params;
-
- gboolean res = TRUE;
-
- closure = g_new0 (RestProxyRunRawClosure, 1);
- closure->loop = g_main_loop_new (NULL, FALSE);
- closure->payload = payload;
- closure->len = len;
-
- va_start (params, first_field_name);
- res = rest_proxy_call_raw_async_valist (proxy,
- function,
- method,
- _call_raw_async_for_run_raw_cb,
- NULL,
- closure,
- error,
- first_field_name,
- params);
- va_end (params);
-
- if (!res)
- goto error;
-
- g_main_loop_run (closure->loop);
-
-error:
- g_main_loop_unref (closure->loop);
- g_free (closure);
- return res;
-}
-
static RestProxyCall *
_rest_proxy_new_call (RestProxy *proxy)
{