summaryrefslogtreecommitdiff
path: root/src/trg-client.h
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-09-18 16:21:04 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-09-18 16:21:04 +0000
commit79cd86dbfd5b2ea0963c84b48088ec189acfc795 (patch)
tree535769200823fdaa1fec9795fe986668cb33bdee /src/trg-client.h
parent63763bb00502e3c235e478ec50e097904c774696 (diff)
Big changeset, may break stuff. Unfortunately you can't magically jump into the UI thread using gdk_threads_enter/leave() on Windows, the only way is to schedule a callback using g_idle_add. This required a lot of reworking. Good news, Windows support actually works now \o/
Diffstat (limited to 'src/trg-client.h')
-rw-r--r--src/trg-client.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/trg-client.h b/src/trg-client.h
index a35b9cb..d6aa679 100644
--- a/src/trg-client.h
+++ b/src/trg-client.h
@@ -52,11 +52,25 @@
#define HTTP_OK 200
#define HTTP_CONFLICT 409
+#define FAIL_JSON_DECODE -2
+#define FAIL_RESPONSE_UNSUCCESSFUL -3
+#define DISPATCH_POOL_SIZE 3
+
+
typedef struct {
int status;
- char *data;
+ char *raw;
int size;
-} trg_http_response;
+ JsonObject *obj;
+ gpointer cb_data;
+} trg_response;
+
+typedef struct
+{
+ JsonNode *node;
+ GSourceFunc callback;
+ gpointer cb_data;
+} trg_request;
G_BEGIN_DECLS
@@ -98,14 +112,20 @@ typedef struct {
*/
int serial;
CURL *curl;
- trg_http_response *response;
} trg_tls;
/* stuff that used to be in http.h */
-void http_response_free(trg_http_response *response);
-trg_http_response *trg_http_perform(TrgClient * client, gchar * req);
+void trg_response_free(trg_response *response);
+int trg_http_perform(TrgClient * client, gchar * reqstr, trg_response *reqrsp);
/* end http.h*/
+/* stuff that used to be in dispatch.c */
+trg_response *dispatch(TrgClient * client, JsonNode * req);
+gboolean dispatch_async(TrgClient * client, JsonNode * req,
+ GSourceFunc callback,
+ gpointer data);
+/* end dispatch.c*/
+
GType trg_client_get_type (void);
TrgClient* trg_client_new (void);