summaryrefslogtreecommitdiff
path: root/rtclient
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-02-02 09:29:10 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-02-02 09:29:10 +0800
commit12cde42c929b63a1ef1b2ad7f3482336419980b2 (patch)
tree3c7e7185909432068985da6bb739bf34d67fcd58 /rtclient
parentebfa1718a36a8a0f3cf4571bc48b1990129af703 (diff)
Asynchronous connection
Important updates: 1. Emscripten port. 2. HTTP request code copied from libicclient & slightly fixed. 3. Cookies, for maintaining authorisation between different async handles.
Diffstat (limited to 'rtclient')
-rw-r--r--rtclient/search.h12
-rw-r--r--rtclient/ticket.h14
-rw-r--r--rtclient/typedefs.h18
-rw-r--r--rtclient/user.h8
4 files changed, 29 insertions, 23 deletions
diff --git a/rtclient/search.h b/rtclient/search.h
index e0e386a..25b7258 100644
--- a/rtclient/search.h
+++ b/rtclient/search.h
@@ -1,21 +1,15 @@
#ifndef RTCLIENT_SEARCH_H
#define RTCLIENT_SEARCH_H
-struct rtclient_search_ticket_list {
- size_t length;
- struct rtclient_ticket *tickets[];
-};
-
#ifdef __cplusplus
extern "C" {
#endif
- void rtclient_search_ticket(struct rtclient_search_ticket_list **listptr
- , const char *query);
- void rtclient_search_ticket_free(struct rtclient_search_ticket_list *list);
+void rtclient_search_ticket(const char *query,
+ void (*callback)(struct rtclient_ticket **));
#ifdef __cplusplus
}
#endif
-#endif // RTCLIENT_SEARCH_H
+#endif
diff --git a/rtclient/ticket.h b/rtclient/ticket.h
index 9fdd9a0..0600c34 100644
--- a/rtclient/ticket.h
+++ b/rtclient/ticket.h
@@ -56,11 +56,6 @@ struct rtclient_ticket_history {
struct rtclient_ticket_history_attachment_list *attachments;
};
-struct rtclient_ticket_history_list {
- size_t length;
- struct rtclient_ticket_history *histories[];
-};
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -79,12 +74,9 @@ void rtclient_ticket_new(const char *queue,
const char *starts,
const char *due,
const char *text);
- void rtclient_ticket_history(struct rtclient_ticket_history_list **listptr
- , unsigned int id, bool long_format);
- void rtclient_ticket_history_free
- (struct rtclient_ticket_history *history);
- void rtclient_ticket_history_list_free
- (struct rtclient_ticket_history_list *list);
+void rtclient_ticket_history_list(unsigned int id, bool long_format,
+ void (*callback)(struct rtclient_ticket_history **));
+void rtclient_ticket_history_free(struct rtclient_ticket_history *history);
#ifdef __cplusplus
}
diff --git a/rtclient/typedefs.h b/rtclient/typedefs.h
new file mode 100644
index 0000000..e15b1df
--- /dev/null
+++ b/rtclient/typedefs.h
@@ -0,0 +1,18 @@
+#ifndef RTCLIENT_TYPEDEFS_H
+#define RTCLIENT_TYPEDEFS_H
+
+#include <stddef.h>
+#ifdef __EMSCRIPTEN__
+#include <emscripten/fetch.h>
+typedef emscripten_fetch_t rtclient_response;
+#else
+#include <curl/curl.h>
+typedef struct {
+ void *userData;
+ char *data;
+ size_t numBytes;
+ CURL *curl;
+} rtclient_response;
+#endif
+
+#endif
diff --git a/rtclient/user.h b/rtclient/user.h
index 5f62d17..02b2daa 100644
--- a/rtclient/user.h
+++ b/rtclient/user.h
@@ -1,6 +1,8 @@
#ifndef RTCLIENT_USER_H
#define RTCLIENT_USER_H
+#include "typedefs.h"
+
enum rtclient_user_lang {
RTCLIENT_USER_LANG_NONE = 0,
RTCLIENT_USER_LANG_AR,
@@ -464,9 +466,9 @@ void rtclient_user_new(const char *name,
enum rtclient_user_timezone timezone,
bool disabled,
bool privileged);
- void rtclient_user_showid(struct rtclient_user **userptr, unsigned int id);
- void rtclient_user_showname(struct rtclient_user **userptr, const char *name);
- void rtclient_user_free(struct rtclient_user *user);
+void rtclient_user_showid(unsigned int id, void (*)(struct rtclient_user *));
+void rtclient_user_showname(const char *name, void (*)(struct rtclient_user *));
+void rtclient_user_free(struct rtclient_user *user);
#ifdef __cplusplus
}