From 9df1e54cdf88b0a46a32d1248152907a67ca8a03 Mon Sep 17 00:00:00 2001 From: nekobit Date: Sun, 16 Oct 2022 05:30:53 +0000 Subject: [PATCH] Work FossilOrigin-Name: 4dad40a89c3a003bfda76a128f22df56bdab086313a822eee967add8d3a1820a --- include/mastodont_account.h | 12 ++++++++++++ include/mastodont_application.h | 4 ++++ include/mastodont_attachment.h | 2 ++ include/mastodont_chats.h | 6 ++++++ include/mastodont_list.h | 16 ++++++++++++++++ include/mastodont_notification.h | 8 ++++++++ include/mastodont_request.h | 2 ++ include/mastodont_scrobbles.h | 2 ++ include/mastodont_search.h | 2 ++ include/mastodont_status.h | 24 +++++++++++++++++++++++- include/mastodont_timeline.h | 10 ++++++++++ include/mastodont_types.h | 2 ++ src/account.c | 16 ++++++++++++++++ src/application.c | 4 ++++ src/attachment.c | 4 +++- src/chats.c | 14 ++++++++++---- src/fetch.c | 2 ++ src/list.c | 22 +++++++++++++++++++--- src/nodeinfo.c | 4 +++- src/notification.c | 8 ++++++++ src/relationship.c | 2 ++ src/request.c | 2 ++ src/scrobbles.c | 2 ++ src/search.c | 2 ++ src/static.c | 4 ++++ src/status.c | 26 +++++++++++++++++++++++++- src/timeline.c | 20 +++++++++++++++----- 27 files changed, 206 insertions(+), 16 deletions(-) diff --git a/include/mastodont_account.h b/include/mastodont_account.h index 1b10b0b..4a95699 100644 --- a/include/mastodont_account.h +++ b/include/mastodont_account.h @@ -103,11 +103,15 @@ MSTDNT_ACCOUNT_ACTION_DECL(unsubscribe); int mstdnt_verify_credentials(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_account* acct, struct mstdnt_storage* storage); int mstdnt_get_account(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, int lookup_type, char* id, struct mstdnt_account* acct, @@ -115,6 +119,8 @@ int mstdnt_get_account(mastodont_t* data, int mstdnt_get_blocks(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_account_args* args, struct mstdnt_storage* storage, struct mstdnt_account* accts[], @@ -122,6 +128,8 @@ int mstdnt_get_blocks(mastodont_t* data, int mstdnt_get_mutes(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_account_args* args, struct mstdnt_storage* storage, struct mstdnt_account* accts[], @@ -129,6 +137,8 @@ int mstdnt_get_mutes(mastodont_t* data, int mstdnt_get_followers(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_account_args* args, struct mstdnt_storage* storage, @@ -137,6 +147,8 @@ int mstdnt_get_followers(mastodont_t* data, int mstdnt_get_following(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_account_args* args, struct mstdnt_storage* storage, diff --git a/include/mastodont_application.h b/include/mastodont_application.h index 45e3265..250ae00 100644 --- a/include/mastodont_application.h +++ b/include/mastodont_application.h @@ -58,12 +58,16 @@ struct mstdnt_application_args int mstdnt_register_app(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_application_args* args, struct mstdnt_storage* storage, struct mstdnt_app* app); int mstdnt_obtain_oauth_token(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_application_args* args, struct mstdnt_storage* storage, struct mstdnt_oauth_token* app); diff --git a/include/mastodont_attachment.h b/include/mastodont_attachment.h index 1aaecac..322b4f4 100644 --- a/include/mastodont_attachment.h +++ b/include/mastodont_attachment.h @@ -53,6 +53,8 @@ void _mstdnt_val_attachments_call(cJSON* v, void* _type); int mstdnt_upload_media(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_upload_media_args* args, struct mstdnt_storage* storage, struct mstdnt_attachment* attachment); diff --git a/include/mastodont_chats.h b/include/mastodont_chats.h index 3e5508f..c2bbfc8 100644 --- a/include/mastodont_chats.h +++ b/include/mastodont_chats.h @@ -60,6 +60,8 @@ int mstdnt_messages_json(struct mstdnt_message* message[], size_t* size, cJSON* int mstdnt_get_chats_v2(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_chats_args* args, struct mstdnt_storage* storage, struct mstdnt_chat* chats[], @@ -67,6 +69,8 @@ int mstdnt_get_chats_v2(mastodont_t* data, int mstdnt_get_chat_messages(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* chat_id, struct mstdnt_chats_args* args, struct mstdnt_storage* storage, @@ -75,6 +79,8 @@ int mstdnt_get_chat_messages(mastodont_t* data, int mstdnt_get_chat(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* chat_id, struct mstdnt_storage* storage, struct mstdnt_chat* chat); diff --git a/include/mastodont_list.h b/include/mastodont_list.h index 4bacd16..593e471 100644 --- a/include/mastodont_list.h +++ b/include/mastodont_list.h @@ -51,24 +51,32 @@ int mstdnt_lists_json(struct mstdnt_list* lists[], int mstdnt_get_lists(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_storage* storage, struct mstdnt_list* lists[], size_t* size); int mstdnt_get_list(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_list* lists); int mstdnt_create_list(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_list_args* args, struct mstdnt_storage* storage, struct mstdnt_list* list); int mstdnt_update_list(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_list_args* args, struct mstdnt_storage* storage, @@ -76,11 +84,15 @@ int mstdnt_update_list(mastodont_t* api, int mstdnt_delete_list(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage); int mstdnt_list_get_accounts(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_account_args* args, struct mstdnt_storage* storage, @@ -89,6 +101,8 @@ int mstdnt_list_get_accounts(mastodont_t* data, int mstdnt_list_add_accounts(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, char** account_ids, size_t account_ids_len, @@ -96,6 +110,8 @@ int mstdnt_list_add_accounts(mastodont_t* api, int mstdnt_list_remove_accounts(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, char** account_ids, size_t account_ids_len, diff --git a/include/mastodont_notification.h b/include/mastodont_notification.h index 456661f..826588e 100644 --- a/include/mastodont_notification.h +++ b/include/mastodont_notification.h @@ -73,6 +73,8 @@ int mstdnt_notification_pleroma_json(struct mstdnt_notification_pleroma* notif, int mstdnt_get_notifications(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_notifications_args* args, struct mstdnt_storage* storage, struct mstdnt_notification** notifs, @@ -80,16 +82,22 @@ int mstdnt_get_notifications(mastodont_t* data, int mstdnt_notifications_clear(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_storage* storage); int mstdnt_notifications_read(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_notifications_args* args, struct mstdnt_storage* storage, struct mstdnt_notification* notification); int mstdnt_notification_dismiss(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_storage* storage, char* id); diff --git a/include/mastodont_request.h b/include/mastodont_request.h index 66d32c7..177df0d 100644 --- a/include/mastodont_request.h +++ b/include/mastodont_request.h @@ -36,6 +36,8 @@ struct mstdnt_request_args int mstdnt_request(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_request_args* args); #endif /* MASTODONT_REQUEST_H */ diff --git a/include/mastodont_scrobbles.h b/include/mastodont_scrobbles.h index 99d27d7..0ba2dda 100644 --- a/include/mastodont_scrobbles.h +++ b/include/mastodont_scrobbles.h @@ -48,6 +48,8 @@ struct _mstdnt_scrobbles_cb_args int mstdnt_get_scrobbles(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_get_scrobbles_args* args, struct mstdnt_storage* storage, diff --git a/include/mastodont_search.h b/include/mastodont_search.h index a29e003..ae1b9b9 100644 --- a/include/mastodont_search.h +++ b/include/mastodont_search.h @@ -56,6 +56,8 @@ int mstdnt_search_json(struct mstdnt_search_results* search_results, cJSON* json int mstdnt_search(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* query, struct mstdnt_storage* storage, struct mstdnt_search_args* args, diff --git a/include/mastodont_status.h b/include/mastodont_status.h index 1b0ec1e..7892e44 100644 --- a/include/mastodont_status.h +++ b/include/mastodont_status.h @@ -115,6 +115,8 @@ void mstdnt_cleanup_status(struct mstdnt_status* status); int mstdnt_status_json(struct mstdnt_status* status, cJSON* js); int mstdnt_status_emoji_react(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, char* emoji, struct mstdnt_storage* storage, @@ -136,6 +138,8 @@ int mstdnt_status_context_json(struct mstdnt_status* statuses_before[], int mstdnt_get_account_statuses(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_account_statuses_args* args, struct mstdnt_storage* storage, @@ -144,12 +148,16 @@ int mstdnt_get_account_statuses(mastodont_t* data, int mstdnt_get_status(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status); int mstdnt_get_status_context(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* statuses_before[], @@ -165,6 +173,8 @@ int mstdnt_status_favourited_by(mastodont_t* data, struct mstdnt_args* args, int mstdnt_status_reblogged_by(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_account* accounts[], @@ -172,11 +182,15 @@ int mstdnt_status_reblogged_by(mastodont_t* data, int mstdnt_create_status(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_status_args* args, struct mstdnt_storage* storage); /* Generates do and undo functions */ -#define MSTDNT_STATUS_ACTION_DECL(type) int mstdnt_##type##_status(mastodont_t* data, struct mstdnt_args* m_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status) +#define MSTDNT_STATUS_ACTION_DECL(type) int mstdnt_##type##_status(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status) #define MSTDNT_STATUS_ACTION_FUNC_URL(action) { \ return mstdnt_status_action(data, m_args, id, storage, status, "api/v1/statuses/%s/" action); \ } @@ -193,12 +207,16 @@ MSTDNT_STATUS_ACTION_DECL(delete); int mstdnt_mute_conversation(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status); int mstdnt_unmute_conversation(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status); @@ -235,6 +253,8 @@ struct mstdnt_favourites_args int mstdnt_get_bookmarks(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_bookmarks_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -242,6 +262,8 @@ int mstdnt_get_bookmarks(mastodont_t* data, int mstdnt_get_favourites(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_favourites_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], diff --git a/include/mastodont_timeline.h b/include/mastodont_timeline.h index 9165f2c..6cb59ce 100644 --- a/include/mastodont_timeline.h +++ b/include/mastodont_timeline.h @@ -42,6 +42,8 @@ struct mstdnt_timeline_args int mstdnt_timeline_home(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -49,6 +51,8 @@ int mstdnt_timeline_home(mastodont_t* data, int mstdnt_timeline_list(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* list_id, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, @@ -57,6 +61,8 @@ int mstdnt_timeline_list(mastodont_t* data, int mstdnt_timeline_public(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -64,6 +70,8 @@ int mstdnt_timeline_public(mastodont_t* data, int mstdnt_timeline_direct(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -71,6 +79,8 @@ int mstdnt_timeline_direct(mastodont_t* data, int mstdnt_timeline_tag(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* hashtag, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, diff --git a/include/mastodont_types.h b/include/mastodont_types.h index 64ee278..2b88169 100644 --- a/include/mastodont_types.h +++ b/include/mastodont_types.h @@ -27,6 +27,8 @@ typedef int8_t mstdnt_bool; #define MSTDNT_FALSE 1 #define MSTDNT_BOOL_UNSET 0 +typedef void (*mstdnt_request_cb_t)(void* data, void* args); + // It's more logical to not sanitize than to sanitize data #define MSTDNT_FLAG_NO_URI_SANITIZE (1<<0) #define MSTDNT_FLAG_SSL_UNVERIFIED (1<<1) diff --git a/src/account.c b/src/account.c index 963ba5b..6924a65 100644 --- a/src/account.c +++ b/src/account.c @@ -57,6 +57,8 @@ int mstdnt_accounts_json_callback(cJSON* json, void* _args) static int mstdnt_get_accounts_query(char* url, mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_account_args* args, struct mstdnt_storage* storage, struct mstdnt_account* accts[], @@ -92,6 +94,8 @@ static int mstdnt_get_accounts_query(char* url, int mstdnt_get_followers(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_account_args* args, struct mstdnt_storage* storage, @@ -105,6 +109,8 @@ int mstdnt_get_followers(mastodont_t* data, int mstdnt_get_following(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_account_args* args, struct mstdnt_storage* storage, @@ -117,6 +123,8 @@ int mstdnt_get_following(mastodont_t* data, } int mstdnt_get_blocks(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_account_args* args, struct mstdnt_storage* storage, struct mstdnt_account* accts[], @@ -126,6 +134,8 @@ int mstdnt_get_blocks(mastodont_t* data, struct mstdnt_args* m_args, } int mstdnt_get_mutes(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_account_args* args, struct mstdnt_storage* storage, struct mstdnt_account* accts[], @@ -136,6 +146,8 @@ int mstdnt_get_mutes(mastodont_t* data, struct mstdnt_args* m_args, int mstdnt_get_account(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, int lookup, /* TODO move into separate function for consistancy? */ char* id, struct mstdnt_account* acct, @@ -163,6 +175,8 @@ int mstdnt_get_account(mastodont_t* data, int mstdnt_verify_credentials(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_account* acct, struct mstdnt_storage* storage) { @@ -225,6 +239,8 @@ int mstdnt_account_json(struct mstdnt_account* acct, cJSON* js) int mstdnt_account_action(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_relationship* rel, diff --git a/src/application.c b/src/application.c index bb247eb..b323e2e 100644 --- a/src/application.c +++ b/src/application.c @@ -89,6 +89,8 @@ void _mstdnt_val_malloc_application_call(cJSON* v, void* _type) int mstdnt_register_app(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_application_args* args, struct mstdnt_storage* storage, struct mstdnt_app* app) @@ -116,6 +118,8 @@ int mstdnt_register_app(mastodont_t* data, int mstdnt_obtain_oauth_token(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_application_args* args, struct mstdnt_storage* storage, struct mstdnt_oauth_token* token) diff --git a/src/attachment.c b/src/attachment.c index 26f1a56..e676700 100644 --- a/src/attachment.c +++ b/src/attachment.c @@ -101,6 +101,8 @@ static int mstdnt_attachment_json_callback(cJSON* json, void* _args) int mstdnt_upload_media(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_upload_media_args* args, struct mstdnt_storage* storage, struct mstdnt_attachment* attachment) @@ -121,7 +123,7 @@ int mstdnt_upload_media(mastodont_t* api, mstdnt_attachment_json_callback, }; - return mstdnt_request(api, m_args, &req_args); + return mstdnt_request(api, m_args, &req_args, cb_request, cb_args); } void mstdnt_cleanup_attachments(struct mstdnt_attachment* attachment) diff --git a/src/chats.c b/src/chats.c index 150d747..62de44b 100644 --- a/src/chats.c +++ b/src/chats.c @@ -107,6 +107,8 @@ static int mstdnt_messages_json_callback(cJSON* json, void* _args) int mstdnt_get_chats_v2(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_chats_args* args, struct mstdnt_storage* storage, struct mstdnt_chat* chats[], @@ -140,6 +142,8 @@ int mstdnt_get_chats_v2(mastodont_t* data, int mstdnt_get_chat_messages(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* chat_id, struct mstdnt_chats_args* args, struct mstdnt_storage* storage, @@ -176,10 +180,12 @@ int mstdnt_get_chat_messages(mastodont_t* data, } int mstdnt_get_chat(mastodont_t* data, - struct mstdnt_args* m_args, - char* chat_id, - struct mstdnt_storage* storage, - struct mstdnt_chat* chat) + struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, + char* chat_id, + struct mstdnt_storage* storage, + struct mstdnt_chat* chat) { char url[MSTDNT_URLSIZE]; snprintf(url, MSTDNT_URLSIZE, "api/v1/pleroma/chats/%s", chat_id); diff --git a/src/fetch.c b/src/fetch.c index 7978707..da2fc10 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -49,6 +49,8 @@ void mstdnt_fetch_results_cleanup(struct mstdnt_fetch_results* res) int mstdnt_fetch_curl(mastodont_t* mstdnt, CURL* curl, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* _url, struct mstdnt_fetch_results* results, CURLoption request_t, diff --git a/src/list.c b/src/list.c index 1effeb9..f0cf305 100644 --- a/src/list.c +++ b/src/list.c @@ -75,6 +75,8 @@ static int mstdnt_lists_json_callback(cJSON* json, void* _args) int mstdnt_get_lists(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_storage* storage, struct mstdnt_list* lists[], size_t* size) @@ -100,6 +102,8 @@ int mstdnt_get_lists(mastodont_t* data, int mstdnt_get_list(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_list* list) @@ -136,6 +140,8 @@ static const char* replies_policy_str(enum mstdnt_list_replies_policy pol) } int mstdnt_create_list(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_list_args* args, struct mstdnt_storage* storage, struct mstdnt_list* list) @@ -161,6 +167,8 @@ int mstdnt_create_list(mastodont_t* data, struct mstdnt_args* m_args, int mstdnt_update_list(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_list_args* args, struct mstdnt_storage* storage, @@ -190,6 +198,8 @@ int mstdnt_update_list(mastodont_t* data, int mstdnt_delete_list(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage) { @@ -207,11 +217,13 @@ int mstdnt_delete_list(mastodont_t* api, NULL, }; - return mstdnt_request(api, m_args, &req_args); + return mstdnt_request(api, m_args, &req_args, cb_request, cb_args); } int mstdnt_list_add_accounts(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, char** account_ids, size_t account_ids_len, @@ -240,11 +252,13 @@ int mstdnt_list_add_accounts(mastodont_t* api, NULL, }; - return mstdnt_request(api, m_args, &req_args); + return mstdnt_request(api, m_args, &req_args, cb_request, cb_args); } int mstdnt_list_remove_accounts(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, char** account_ids, size_t account_ids_len, @@ -273,11 +287,13 @@ int mstdnt_list_remove_accounts(mastodont_t* api, NULL, }; - return mstdnt_request(api, m_args, &req_args); + return mstdnt_request(api, m_args, &req_args, cb_request, cb_args); } int mstdnt_list_get_accounts(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_account_args* args, struct mstdnt_storage* storage, diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 87f9bb1..237dc95 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -97,6 +97,8 @@ int mstdnt_nodeinfo_json_callback(cJSON* json, void* nodeinfo) int mstdnt_get_nodeinfo(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* version, struct mstdnt_storage* storage, struct mstdnt_nodeinfo* nodeinfo) @@ -115,7 +117,7 @@ int mstdnt_get_nodeinfo(mastodont_t* api, mstdnt_nodeinfo_json_callback }; - return mstdnt_request(api, m_args, &req_args); + return mstdnt_request(api, m_args, &req_args, cb_request, cb_args); } void mstdnt_cleanup_nodeinfo(struct mstdnt_nodeinfo* nodeinfo) diff --git a/src/notification.c b/src/notification.c index 086847c..b2e104a 100644 --- a/src/notification.c +++ b/src/notification.c @@ -116,6 +116,8 @@ int mstdnt_notifications_json_callback(cJSON* json, void* _args) int mstdnt_get_notifications(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_notifications_args* args, struct mstdnt_storage* storage, struct mstdnt_notification** notifs, @@ -161,6 +163,8 @@ int mstdnt_get_notifications(mastodont_t* data, int mstdnt_notification_dismiss(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_storage* storage, char* id) { @@ -183,6 +187,8 @@ int mstdnt_notification_dismiss(mastodont_t* data, int mstdnt_notifications_clear(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_storage* storage) { struct mstdnt_request_args req_args = { @@ -201,6 +207,8 @@ int mstdnt_notifications_clear(mastodont_t* data, int mstdnt_notifications_read(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_notifications_args* args, struct mstdnt_storage* storage, struct mstdnt_notification* notification) diff --git a/src/relationship.c b/src/relationship.c index 1c97b2c..3ac5de6 100644 --- a/src/relationship.c +++ b/src/relationship.c @@ -98,6 +98,8 @@ int mstdnt_relationships_json_callback(cJSON* json, void* _args) } int mstdnt_get_relationships(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char** ids, size_t ids_len, struct mstdnt_storage* storage, diff --git a/src/request.c b/src/request.c index 06c63c8..06553e9 100644 --- a/src/request.c +++ b/src/request.c @@ -73,6 +73,8 @@ static void mime_params_post(curl_mime* mime, int mstdnt_request(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_request_args* args) { int res = 0, curlerror = 0; diff --git a/src/scrobbles.c b/src/scrobbles.c index 5b50d30..253fd05 100644 --- a/src/scrobbles.c +++ b/src/scrobbles.c @@ -54,6 +54,8 @@ int mstdnt_scrobbles_json_callback(cJSON* json, void* _args) int mstdnt_get_scrobbles(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_get_scrobbles_args* args, struct mstdnt_storage* storage, diff --git a/src/search.c b/src/search.c index 1874c16..428c8b3 100644 --- a/src/search.c +++ b/src/search.c @@ -63,6 +63,8 @@ int mstdnt_search_json_callback(cJSON* json, void* _args) int mstdnt_search(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* query, struct mstdnt_storage* storage, struct mstdnt_search_args* args, diff --git a/src/static.c b/src/static.c index 8e6fb55..f2ba9fb 100644 --- a/src/static.c +++ b/src/static.c @@ -18,6 +18,8 @@ int mstdnt_instance_panel(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_fetch_results* html) { CURL* curl = curl_easy_init(); @@ -34,6 +36,8 @@ int mstdnt_instance_panel(mastodont_t* api, int mstdnt_terms_of_service(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_fetch_results* html) { CURL* curl = curl_easy_init(); diff --git a/src/status.c b/src/status.c index 6450565..8be406c 100644 --- a/src/status.c +++ b/src/status.c @@ -147,6 +147,8 @@ int mstdnt_statuses_json_callback(cJSON* json, void* _args) int mstdnt_get_account_statuses(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_account_statuses_args* args, struct mstdnt_storage* storage, @@ -188,6 +190,8 @@ int mstdnt_get_account_statuses(mastodont_t* data, /* TODO Populate the arguments! */ int mstdnt_create_status(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_status_args* args, struct mstdnt_storage* storage) { @@ -221,6 +225,8 @@ int mstdnt_create_status(mastodont_t* data, static int mstdnt_status_action(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status, @@ -291,6 +297,8 @@ MSTDNT_STATUS_ACTION_DECL(delete) /* TODO Mutes can be timed */ int mstdnt_mute_conversation(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status) @@ -300,6 +308,8 @@ int mstdnt_mute_conversation(mastodont_t* data, int mstdnt_unmute_conversation(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status) @@ -309,6 +319,8 @@ int mstdnt_unmute_conversation(mastodont_t* data, int mstdnt_get_status(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status) @@ -391,6 +403,8 @@ int mstdnt_status_context_json_callback(cJSON* json, void* _args) int mstdnt_get_status_context(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* statuses_before[], @@ -423,6 +437,8 @@ int mstdnt_get_status_context(mastodont_t* data, int mstdnt_status_favourited_by(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_account* accounts[], @@ -451,6 +467,8 @@ int mstdnt_status_favourited_by(mastodont_t* data, int mstdnt_status_reblogged_by(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_account* accounts[], @@ -480,6 +498,8 @@ int mstdnt_status_reblogged_by(mastodont_t* data, int mstdnt_get_bookmarks(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_bookmarks_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -510,6 +530,8 @@ int mstdnt_get_bookmarks(mastodont_t* data, int mstdnt_get_favourites(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_favourites_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -539,6 +561,8 @@ int mstdnt_get_favourites(mastodont_t* data, int mstdnt_status_emoji_react(mastodont_t* api, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* id, char* emoji, struct mstdnt_storage* storage, @@ -558,7 +582,7 @@ int mstdnt_status_emoji_react(mastodont_t* api, mstdnt_status_json_callback }; - return mstdnt_request(api, m_args, &req_args); + return mstdnt_request(api, m_args, &req_args, cb_request, cb_args); } void mstdnt_cleanup_status(struct mstdnt_status* status) diff --git a/src/timeline.c b/src/timeline.c index 34c1f44..db5f03a 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -22,6 +22,8 @@ int mstdnt_timeline_list(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* list_id, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, @@ -56,11 +58,13 @@ int mstdnt_timeline_list(mastodont_t* data, mstdnt_statuses_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, &req_args, cb_request, cb_args); } int mstdnt_timeline_tag(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, char* hashtag, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, @@ -98,7 +102,7 @@ int mstdnt_timeline_tag(mastodont_t* data, mstdnt_statuses_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, &req_args, cb_request, cb_args); } static const char* reply_visibility_str(enum mstdnt_reply_visibility vis) @@ -117,6 +121,8 @@ static const char* reply_visibility_str(enum mstdnt_reply_visibility vis) int mstdnt_timeline_public(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -148,12 +154,14 @@ int mstdnt_timeline_public(mastodont_t* data, mstdnt_statuses_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, &req_args, cb_request, cb_args); } int mstdnt_timeline_direct(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -181,12 +189,14 @@ int mstdnt_timeline_direct(mastodont_t* data, mstdnt_statuses_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, &req_args, cb_request, cb_args); } int mstdnt_timeline_home(mastodont_t* data, struct mstdnt_args* m_args, +mstdnt_request_cb_t cb_request, +void* cb_args, struct mstdnt_timeline_args* args, struct mstdnt_storage* storage, struct mstdnt_status* statuses[], @@ -219,6 +229,6 @@ int mstdnt_timeline_home(mastodont_t* data, mstdnt_statuses_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, &req_args, cb_request, cb_args); }