FossilOrigin-Name: 149127123e9ac46c8ea98c76335f9c288f339a69769317c4dee3ea560f7bbca6
This commit is contained in:
nekobit 2022-06-23 21:45:33 +00:00
parent a37f407ab0
commit fc1292ea4b
24 changed files with 255 additions and 139 deletions

View File

@ -32,8 +32,7 @@
void mastodont_global_curl_init();
void mastodont_global_curl_cleanup();
int mastodont_init(mastodont_t* data, uint16_t flags);
int mastodont_set_token(mastodont_t* data, char* token);
int mastodont_init(mastodont_t* data);
void mastodont_cleanup(mastodont_t* data);
void mastodont_free(void*);

View File

@ -76,7 +76,8 @@ struct mstdnt_account_args
int with_relationships; // mastodont_get_mutes
};
int mstdnt_account_action(mastodont_t* data, struct mstdnt_args* args,
int mstdnt_account_action(mastodont_t* data,
struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_relationship* rel,
@ -88,7 +89,7 @@ int mstdnt_accounts_json(struct mstdnt_account* accounts[],
#define MSTDNT_ACCOUNT_ACTION_DECL(type) int mastodont_##type##_account(mastodont_t* data, struct mstdnt_args* args, char* id, struct mstdnt_storage* storage, struct mstdnt_relationship* relationship)
#define MSTDNT_ACCOUNT_ACTION_FUNC_URL(action) { \
return mstdnt_account_action(data, id, storage, relationship, "api/v1/accounts/%s/" action); \
return mstdnt_account_action(data, args, id, storage, relationship, "api/v1/accounts/%s/" action); \
}
MSTDNT_ACCOUNT_ACTION_DECL(follow);
@ -100,35 +101,42 @@ MSTDNT_ACCOUNT_ACTION_DECL(unblock);
MSTDNT_ACCOUNT_ACTION_DECL(subscribe);
MSTDNT_ACCOUNT_ACTION_DECL(unsubscribe);
int mastodont_verify_credentials(mastodont_t* data, struct mstdnt_args* args,
int mastodont_verify_credentials(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_account* acct,
struct mstdnt_storage* storage);
int mastodont_get_account(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_account(mastodont_t* data,
struct mstdnt_args* m_args,
int lookup_type,
char* id,
struct mstdnt_account* acct,
struct mstdnt_storage* storage);
int mastodont_get_blocks(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_blocks(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
size_t* accts_len);
int mastodont_get_mutes(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_mutes(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
size_t* accts_len);
int mastodont_get_followers(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_followers(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
size_t* accts_len);
int mastodont_get_following(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_following(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,

View File

@ -16,7 +16,6 @@
#ifndef MASTODONT_APPLICATION
#define MASTODONT_APPLICATION
#include "mastodont_types.h"
#include "mastodont_args.h"
#include "mastodont_fetch.h"
#include <cjson/cJSON.h>
@ -48,13 +47,31 @@ struct mstdnt_oauth_token
time_t time;
};
int mastodont_register_app(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_args* args,
struct mstdnt_application_args
{
char* grant_type;
char* client_id;
char* client_secret;
char* redirect_uri;
char* scope;
char* code;
char* username;
char* password;
char* client_name;
char* redirect_uris;
char* scopes;
char* website;
};
int mastodont_register_app(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_application_args* args,
struct mstdnt_storage* storage,
struct mstdnt_app* app);
int mastodont_obtain_oauth_token(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_args* args,
int mastodont_obtain_oauth_token(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_application_args* args,
struct mstdnt_storage* storage,
struct mstdnt_oauth_token* app);

View File

@ -51,7 +51,8 @@ int mstdnt_attachment_json(cJSON* att_json, struct mstdnt_attachment* att);
void _mstdnt_val_attachments_call(cJSON* v, void* _type);
int mastodont_upload_media(mastodont_t* api, struct mstdnt_args* args,
int mastodont_upload_media(mastodont_t* api,
struct mstdnt_args* m_args,
struct mstdnt_upload_media_args* args,
struct mstdnt_storage* storage,
struct mstdnt_attachment* attachment);

View File

@ -49,45 +49,53 @@ int mstdnt_lists_json(struct mstdnt_list* lists[],
size_t* size,
cJSON* json);
int mastodont_get_lists(mastodont_t* api, struct mstdnt_args* args,
int mastodont_get_lists(mastodont_t* api,
struct mstdnt_args* m_args,
struct mstdnt_storage* storage,
struct mstdnt_list* lists[],
size_t* size);
int mastodont_get_list(mastodont_t* api, struct mstdnt_args* args,
int mastodont_get_list(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_list* lists);
int mastodont_create_list(mastodont_t* api, struct mstdnt_args* args,
int mastodont_create_list(mastodont_t* api,
struct mstdnt_args* m_args,
struct mstdnt_list_args* args,
struct mstdnt_storage* storage,
struct mstdnt_list* list);
int mastodont_update_list(mastodont_t* api, struct mstdnt_args* args,
int mastodont_update_list(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_list_args* args,
struct mstdnt_storage* storage,
struct mstdnt_list* list);
int mastodont_delete_list(mastodont_t* api, struct mstdnt_args* args,
int mastodont_delete_list(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage);
int mastodont_list_get_accounts(mastodont_t* data, struct mstdnt_args* args,
int mastodont_list_get_accounts(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
size_t* accts_len);
int mastodont_list_add_accounts(mastodont_t* api, struct mstdnt_args* args,
int mastodont_list_add_accounts(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
char** account_ids,
size_t account_ids_len,
struct mstdnt_storage* storage);
int mastodont_list_remove_accounts(mastodont_t* api, struct mstdnt_args* args,
int mastodont_list_remove_accounts(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
char** account_ids,
size_t account_ids_len,

View File

@ -18,7 +18,6 @@
#include "mastodont_types.h"
#include "mastodont_account.h"
#include "mastodont_status.h"
#include "mastodont_args.h"
#include "mastodont_notif_types.h"
#include "mastodont_visibility_types.h"
#include <cjson/cJSON.h>
@ -57,7 +56,8 @@ struct _mstdnt_notifications_result_cb_args
int mstdnt_notifications_json_callback(cJSON* json, void* _args);
int mastodont_get_notifications(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_notifications(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_get_notifications_args* args,
struct mstdnt_storage* storage,
struct mstdnt_notification** notifs,

View File

@ -46,7 +46,8 @@ struct _mstdnt_scrobbles_cb_args
size_t* size;
};
int mastodont_get_scrobbles(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_scrobbles(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_get_scrobbles_args* args,
struct mstdnt_storage* storage,

View File

@ -54,7 +54,8 @@ int mstdnt_search_json_callback(cJSON* json, void* _args);
int mstdnt_search_json(struct mstdnt_search_results* search_results, cJSON* json);
int mastodont_search(mastodont_t* data, struct mstdnt_args* args,
int mastodont_search(mastodont_t* data,
struct mstdnt_args* m_args,
char* query,
struct mstdnt_storage* storage,
struct mstdnt_search_args* args,

View File

@ -18,10 +18,12 @@
#include "mastodont_types.h"
#include "mastodont_fetch.h"
int mastodont_instance_panel(mastodont_t* api, struct mstdnt_args* args,
int mastodont_instance_panel(mastodont_t* api,
struct mstdnt_args* args,
struct mstdnt_fetch_results* html);
int mastodont_terms_of_service(mastodont_t* api, struct mstdnt_args* args,
int mastodont_terms_of_service(mastodont_t* api,
struct mstdnt_args* args,
struct mstdnt_fetch_results* html);
#endif /* MSTDNT_STATIC_H */

View File

@ -19,7 +19,6 @@
#include <cjson/cJSON.h>
#include "mastodont_pleroma.h"
#include "mastodont_types.h"
#include "mastodont_args.h"
#include "mastodont_fetch.h"
#include "mastodont_attachment.h"
#include "mastodont_application.h"
@ -91,13 +90,27 @@ struct mstdnt_account_statuses_args
int limit;
};
struct mstdnt_status_args
{
char* in_reply_to_id;
char* content_type;
char* status;
char* visibility;
char** media_ids;
int media_ids_len;
};
// Cleanup
void mstdnt_cleanup_statuses(struct mstdnt_status* statuses, size_t s);
void mstdnt_cleanup_status(struct mstdnt_status* status);
int mstdnt_status_json(struct mstdnt_status* status, cJSON* js);
int mastodont_status_emoji_react(mastodont_t* api, struct mstdnt_args* args, char* id, char* emoji,
struct mstdnt_storage* storage, struct mstdnt_status* status);
int mastodont_status_emoji_react(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
char* emoji,
struct mstdnt_storage* storage,
struct mstdnt_status* status);
// Generated function
int mstdnt_statuses_json(struct mstdnt_status* statuses[],
@ -113,19 +126,22 @@ int mstdnt_status_context_json(struct mstdnt_status* statuses_before[],
size_t* size_after,
cJSON* js);
int mastodont_get_account_statuses(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_account_statuses(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_statuses_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);
int mastodont_get_status(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_status(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status);
int mastodont_get_status_context(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_status_context(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses_before[],
@ -139,20 +155,22 @@ int mastodont_status_favourited_by(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_account* accounts[],
size_t* accts);
int mastodont_status_reblogged_by(mastodont_t* data, struct mstdnt_args* args,
int mastodont_status_reblogged_by(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
size_t* accts);
int mastodont_create_status(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_args* args,
int mastodont_create_status(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_status_args* args,
struct mstdnt_storage* storage);
/* Generates do and undo functions */
#define MSTDNT_STATUS_ACTION_DECL(type) int mastodont_##type##_status(mastodont_t* data, struct mstdnt_args* args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status)
#define MSTDNT_STATUS_ACTION_DECL(type) int mastodont_##type##_status(mastodont_t* data, struct mstdnt_args* m_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status)
#define MSTDNT_STATUS_ACTION_FUNC_URL(action) { \
return mstdnt_status_action(data, id, storage, status, "api/v1/statuses/%s/" action); \
return mstdnt_status_action(data, m_args, id, storage, status, "api/v1/statuses/%s/" action); \
}
MSTDNT_STATUS_ACTION_DECL(favourite);
@ -165,12 +183,14 @@ MSTDNT_STATUS_ACTION_DECL(bookmark);
MSTDNT_STATUS_ACTION_DECL(unbookmark);
MSTDNT_STATUS_ACTION_DECL(delete);
int mastodont_mute_conversation(mastodont_t* data, struct mstdnt_args* args,
int mastodont_mute_conversation(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status);
int mastodont_unmute_conversation(mastodont_t* data, struct mstdnt_args* args,
int mastodont_unmute_conversation(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status);
@ -205,13 +225,15 @@ struct mstdnt_favourites_args
int limit;
};
int mastodont_get_bookmarks(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_bookmarks(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_bookmarks_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);
int mastodont_get_favourites(mastodont_t* data, struct mstdnt_args* args,
int mastodont_get_favourites(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_favourites_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],

View File

@ -40,32 +40,37 @@ struct mstdnt_timeline_args
int with_muted;
};
int mastodont_timeline_home(mastodont_t* data, struct mstdnt_args* args,
int mastodont_timeline_home(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);
int mastodont_timeline_list(mastodont_t* data, struct mstdnt_args* args,
int mastodont_timeline_list(mastodont_t* data,
struct mstdnt_args* m_args,
char* list_id,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);
int mastodont_timeline_public(mastodont_t* data, struct mstdnt_args* args,
int mastodont_timeline_public(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* statuses_size);
int mastodont_timeline_direct(mastodont_t* data, struct mstdnt_args* args,
int mastodont_timeline_direct(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* statuses_size);
int mastodont_timeline_tag(mastodont_t* data, struct mstdnt_args* args,
int mastodont_timeline_tag(mastodont_t* data,
struct mstdnt_args* m_args,
char* hashtag,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,

View File

@ -54,7 +54,8 @@ int mstdnt_accounts_json_callback(cJSON* json, void* _args)
}
static int mastodont_get_accounts_query(char* url,
mastodont_t* data, struct mstdnt_args* args,
mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
@ -85,10 +86,11 @@ static int mastodont_get_accounts_query(char* url,
mstdnt_accounts_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_get_followers(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_followers(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
@ -97,10 +99,11 @@ int mastodont_get_followers(mastodont_t* data, struct mstdnt_args* m_args,
{
char url[MSTDNT_URLSIZE];
snprintf(url, MSTDNT_URLSIZE, "api/v1/accounts/%s/followers", id);
return mastodont_get_accounts_query(url, data, args, storage, accts, accts_len);
return mastodont_get_accounts_query(url, data, m_args, args, storage, accts, accts_len);
}
int mastodont_get_following(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_following(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
@ -109,7 +112,7 @@ int mastodont_get_following(mastodont_t* data, struct mstdnt_args* m_args,
{
char url[MSTDNT_URLSIZE];
snprintf(url, MSTDNT_URLSIZE, "api/v1/accounts/%s/following", id);
return mastodont_get_accounts_query(url, data, args, storage, accts, accts_len);
return mastodont_get_accounts_query(url, data, m_args, args, storage, accts, accts_len);
}
int mastodont_get_blocks(mastodont_t* data, struct mstdnt_args* m_args,
@ -118,7 +121,7 @@ int mastodont_get_blocks(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_account* accts[],
size_t* accts_len)
{
return mastodont_get_accounts_query("api/v1/blocks", data, args, storage, accts, accts_len);
return mastodont_get_accounts_query("api/v1/blocks", data, m_args, args, storage, accts, accts_len);
}
int mastodont_get_mutes(mastodont_t* data, struct mstdnt_args* m_args,
@ -127,11 +130,12 @@ int mastodont_get_mutes(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_account* accts[],
size_t* accts_len)
{
return mastodont_get_accounts_query("api/v1/mutes", data, args, storage, accts, accts_len);
return mastodont_get_accounts_query("api/v1/mutes", data, m_args, args, storage, accts, accts_len);
}
int mastodont_get_account(mastodont_t* data, struct mstdnt_args* m_args,
int lookup, /* TODO move into separate function for consistancy */
int mastodont_get_account(mastodont_t* data,
struct mstdnt_args* m_args,
int lookup, /* TODO move into separate function for consistancy? */
char* id,
struct mstdnt_account* acct,
struct mstdnt_storage* storage)
@ -153,10 +157,11 @@ int mastodont_get_account(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_account_json_callback, /* callback */
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_verify_credentials(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_verify_credentials(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_account* acct,
struct mstdnt_storage* storage)
{
@ -171,7 +176,7 @@ int mastodont_verify_credentials(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_account_json_callback, /* callback */
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mstdnt_account_json(struct mstdnt_account* acct, cJSON* js)
@ -217,7 +222,8 @@ int mstdnt_account_json(struct mstdnt_account* acct, cJSON* js)
}
int mstdnt_account_action(mastodont_t* data, struct mstdnt_args* m_args,
int mstdnt_account_action(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_relationship* rel,
@ -237,7 +243,7 @@ int mstdnt_account_action(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_relationship_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
/* These are all the same */

View File

@ -69,8 +69,9 @@ static int mstdnt_token_json_callback(cJSON* json, void* args)
return mstdnt_token_json(json, args);
}
int mastodont_register_app(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_args* args,
int mastodont_register_app(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_application_args* args,
struct mstdnt_storage* storage,
struct mstdnt_app* app)
{
@ -92,12 +93,13 @@ int mastodont_register_app(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_app_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_obtain_oauth_token(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_args* args,
int mastodont_obtain_oauth_token(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_application_args* args,
struct mstdnt_storage* storage,
struct mstdnt_oauth_token* token)
{
@ -125,6 +127,6 @@ int mastodont_obtain_oauth_token(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_token_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}

View File

@ -98,7 +98,8 @@ static int mstdnt_attachment_json_callback(cJSON* json, void* _args)
return mstdnt_attachment_json(json, _args);
}
int mastodont_upload_media(mastodont_t* api, struct mstdnt_args* args,
int mastodont_upload_media(mastodont_t* api,
struct mstdnt_args* m_args,
struct mstdnt_upload_media_args* args,
struct mstdnt_storage* storage,
struct mstdnt_attachment* attachment)
@ -119,7 +120,7 @@ int mastodont_upload_media(mastodont_t* api, struct mstdnt_args* args,
mstdnt_attachment_json_callback,
};
return mastodont_request(api, &req_args);
return mastodont_request(api, m_args, &req_args);
}
void mstdnt_cleanup_attachments(struct mstdnt_attachment* attachment)

View File

@ -72,7 +72,8 @@ static int mstdnt_lists_json_callback(cJSON* json, void* _args)
return mstdnt_lists_json(args->lists, args->size, json);
}
int mastodont_get_lists(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_lists(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_storage* storage,
struct mstdnt_list* lists[],
size_t* size)
@ -93,10 +94,11 @@ int mastodont_get_lists(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_lists_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_get_list(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_list(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_list* list)
@ -115,7 +117,7 @@ int mastodont_get_list(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_list_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
static const char* replies_policy_str(enum mstdnt_list_replies_policy pol)
@ -156,7 +158,8 @@ int mastodont_create_list(mastodont_t* data, struct mstdnt_args* m_args,
return mastodont_request(data, m_args,&req_args);
}
int mastodont_update_list(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_update_list(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_list_args* args,
struct mstdnt_storage* storage,
@ -181,10 +184,11 @@ int mastodont_update_list(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_list_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_delete_list(mastodont_t* api, struct mstdnt_args* args,
int mastodont_delete_list(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage)
{
@ -202,10 +206,11 @@ int mastodont_delete_list(mastodont_t* api, struct mstdnt_args* args,
NULL,
};
return mastodont_request(api, &req_args);
return mastodont_request(api, m_args, &req_args);
}
int mastodont_list_add_accounts(mastodont_t* api, struct mstdnt_args* args,
int mastodont_list_add_accounts(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
char** account_ids,
size_t account_ids_len,
@ -234,10 +239,11 @@ int mastodont_list_add_accounts(mastodont_t* api, struct mstdnt_args* args,
NULL,
};
return mastodont_request(api, &req_args);
return mastodont_request(api, m_args, &req_args);
}
int mastodont_list_remove_accounts(mastodont_t* api, struct mstdnt_args* args,
int mastodont_list_remove_accounts(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
char** account_ids,
size_t account_ids_len,
@ -266,10 +272,11 @@ int mastodont_list_remove_accounts(mastodont_t* api, struct mstdnt_args* args,
NULL,
};
return mastodont_request(api, &req_args);
return mastodont_request(api, m_args, &req_args);
}
int mastodont_list_get_accounts(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_list_get_accounts(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
@ -303,7 +310,7 @@ int mastodont_list_get_accounts(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_accounts_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
void mstdnt_cleanup_lists(struct mstdnt_list* lists)

View File

@ -13,7 +13,7 @@ void mastodont_global_curl_cleanup()
curl_global_cleanup();
}
int mastodont_init(mastodont_t* data, struct mstdnt_args* m_args, uint16_t flags)
int mastodont_init(mastodont_t* data)
{
data->curl = curl_easy_init();
return data->curl == NULL;

View File

@ -94,7 +94,8 @@ int mstdnt_nodeinfo_json_callback(cJSON* json, void* nodeinfo)
return mstdnt_nodeinfo_json(nodeinfo, json);
}
int mastodont_get_nodeinfo(mastodont_t* api, struct mstdnt_args* args,
int mastodont_get_nodeinfo(mastodont_t* api,
struct mstdnt_args* m_args,
char* version,
struct mstdnt_storage* storage,
struct mstdnt_nodeinfo* nodeinfo)
@ -113,7 +114,7 @@ int mastodont_get_nodeinfo(mastodont_t* api, struct mstdnt_args* args,
mstdnt_nodeinfo_json_callback
};
return mastodont_request(api, &req_args);
return mastodont_request(api, m_args, &req_args);
}
void mstdnt_cleanup_nodeinfo(struct mstdnt_nodeinfo* nodeinfo)

View File

@ -75,7 +75,8 @@ int mstdnt_notifications_json_callback(cJSON* json, void* _args)
return mstdnt_notifications_json(args->notif, args->size, json);
}
int mastodont_get_notifications(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_notifications(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_get_notifications_args* args,
struct mstdnt_storage* storage,
struct mstdnt_notification** notifs,
@ -116,7 +117,7 @@ int mastodont_get_notifications(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_notifications_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
void mstdnt_cleanup_notifications(struct mstdnt_notification* notifs, size_t notifs_len)

View File

@ -82,7 +82,7 @@ int mastodont_request(mastodont_t* data,
char* post;
// TODO debug me
char* url_query = args->params_query ?
_mstdnt_query_string(data, args->url, args->params_query, args->params_query_len) :
_mstdnt_query_string(data, m_args, args->url, args->params_query, args->params_query_len) :
args->url;
/* Zero out */
@ -93,7 +93,7 @@ int mastodont_request(mastodont_t* data,
(args->request_type == CURLOPT_POST ||
args->request_type == CURLOPT_CUSTOMREQUEST))
{
post = _mstdnt_query_string(data, NULL, args->params_post, args->params_post_len);
post = _mstdnt_query_string(data, m_args, NULL, args->params_post, args->params_post_len);
curl_easy_setopt(data->curl, CURLOPT_POSTFIELDS, post);
}
else if (args->params_post && args->request_type == CURLOPT_MIMEPOST)

View File

@ -52,7 +52,8 @@ int mstdnt_scrobbles_json_callback(cJSON* json, void* _args)
return mstdnt_scrobbles_json(args->scrobbles, args->size, json);
}
int mastodont_get_scrobbles(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_scrobbles(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_get_scrobbles_args* args,
struct mstdnt_storage* storage,
@ -82,6 +83,6 @@ int mastodont_get_scrobbles(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_scrobbles_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}

View File

@ -61,7 +61,8 @@ int mstdnt_search_json_callback(cJSON* json, void* _args)
return mstdnt_search_json(_args, json);
}
int mastodont_search(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_search(mastodont_t* data,
struct mstdnt_args* m_args,
char* query,
struct mstdnt_storage* storage,
struct mstdnt_search_args* args,
@ -92,7 +93,7 @@ int mastodont_search(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_search_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
void mstdnt_cleanup_search_results(struct mstdnt_search_results* res)

View File

@ -16,14 +16,26 @@
#include <mastodont_static.h>
#include <mastodont_fetch.h>
int mastodont_instance_panel(mastodont_t* api, struct mstdnt_args* args,
int mastodont_instance_panel(mastodont_t* api,
struct mstdnt_args* m_args,
struct mstdnt_fetch_results* html)
{
return mastodont_fetch_curl(api, "instance/panel.html", html, CURLOPT_HTTPGET, NULL);
return mastodont_fetch_curl(api,
m_args,
"instance/panel.html",
html,
CURLOPT_HTTPGET,
NULL);
}
int mastodont_terms_of_service(mastodont_t* api, struct mstdnt_args* args,
int mastodont_terms_of_service(mastodont_t* api,
struct mstdnt_args* m_args,
struct mstdnt_fetch_results* html)
{
return mastodont_fetch_curl(api, "static/terms-of-service.html", html, CURLOPT_HTTPGET, NULL);
return mastodont_fetch_curl(api,
m_args,
"static/terms-of-service.html",
html,
CURLOPT_HTTPGET,
NULL);
}

View File

@ -143,7 +143,8 @@ int mstdnt_statuses_json_callback(cJSON* json, void* _args)
return mstdnt_statuses_json(args->statuses, args->size, json);
}
int mastodont_get_account_statuses(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_account_statuses(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_statuses_args* args,
struct mstdnt_storage* storage,
@ -179,12 +180,13 @@ int mastodont_get_account_statuses(mastodont_t* data, struct mstdnt_args* m_args
mstdnt_statuses_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
/* TODO Populate the arguments! */
int mastodont_create_status(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_args* args,
int mastodont_create_status(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_status_args* args,
struct mstdnt_storage* storage)
{
struct _mstdnt_query_param params[] = {
@ -212,10 +214,11 @@ int mastodont_create_status(mastodont_t* data, struct mstdnt_args* m_args,
* (not sure if the api returns it or not) */
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
static int mstdnt_status_action(mastodont_t* data, struct mstdnt_args* m_args,
static int mstdnt_status_action(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status,
@ -235,7 +238,7 @@ static int mstdnt_status_action(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_status_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
/* These are all the same */
@ -280,27 +283,30 @@ MSTDNT_STATUS_ACTION_DECL(delete)
mstdnt_status_json_callback
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
/* TODO Mutes can be timed */
int mastodont_mute_conversation(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_mute_conversation(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
{
return mstdnt_status_action(data, id, storage, status, "api/v1/statuses/%s/mute");
return mstdnt_status_action(data, m_args, id, storage, status, "api/v1/statuses/%s/mute");
}
int mastodont_unmute_conversation(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_unmute_conversation(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
{
return mstdnt_status_action(data, id, storage, status, "api/v1/statuses/%s/unmute");
return mstdnt_status_action(data, m_args, id, storage, status, "api/v1/statuses/%s/unmute");
}
int mastodont_get_status(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_status(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
@ -319,7 +325,7 @@ int mastodont_get_status(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_status_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mstdnt_status_context_json(struct mstdnt_status* statuses_before[],
@ -381,7 +387,8 @@ int mstdnt_status_context_json_callback(cJSON* json, void* _args)
json);
}
int mastodont_get_status_context(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_status_context(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses_before[],
@ -409,10 +416,11 @@ int mastodont_get_status_context(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_status_context_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_status_favourited_by(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_status_favourited_by(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
@ -436,10 +444,11 @@ int mastodont_status_favourited_by(mastodont_t* data, struct mstdnt_args* m_args
mstdnt_accounts_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_status_reblogged_by(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_status_reblogged_by(mastodont_t* data,
struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
@ -463,11 +472,12 @@ int mastodont_status_reblogged_by(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_accounts_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_get_bookmarks(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_bookmarks(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_bookmarks_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -493,10 +503,11 @@ int mastodont_get_bookmarks(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_get_favourites(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_get_favourites(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_favourites_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -521,11 +532,15 @@ int mastodont_get_favourites(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_status_emoji_react(mastodont_t* api, struct mstdnt_args* args, char* id, char* emoji,
struct mstdnt_storage* storage, struct mstdnt_status* status)
int mastodont_status_emoji_react(mastodont_t* api,
struct mstdnt_args* m_args,
char* id,
char* emoji,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
{
char url[MSTDNT_URLSIZE];
snprintf(url, MSTDNT_URLSIZE, "api/v1/pleroma/statuses/%s/reactions/%s", id, emoji);
@ -541,7 +556,7 @@ int mastodont_status_emoji_react(mastodont_t* api, struct mstdnt_args* args, cha
mstdnt_status_json_callback
};
return mastodont_request(api, &req_args);
return mastodont_request(api, m_args, &req_args);
}
void mstdnt_cleanup_status(struct mstdnt_status* status)

View File

@ -20,7 +20,8 @@
#include <mastodont_query.h>
#include <mastodont_request.h>
int mastodont_timeline_list(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_timeline_list(mastodont_t* data,
struct mstdnt_args* m_args,
char* list_id,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
@ -55,10 +56,11 @@ int mastodont_timeline_list(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_timeline_tag(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_timeline_tag(mastodont_t* data,
struct mstdnt_args* m_args,
char* hashtag,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
@ -96,7 +98,7 @@ int mastodont_timeline_tag(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
static const char* reply_visibility_str(enum mstdnt_reply_visibility vis)
@ -113,7 +115,8 @@ static const char* reply_visibility_str(enum mstdnt_reply_visibility vis)
}
}
int mastodont_timeline_public(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_timeline_public(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -145,11 +148,12 @@ int mastodont_timeline_public(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_timeline_direct(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_timeline_direct(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -177,11 +181,12 @@ int mastodont_timeline_direct(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}
int mastodont_timeline_home(mastodont_t* data, struct mstdnt_args* m_args,
int mastodont_timeline_home(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -214,6 +219,6 @@ int mastodont_timeline_home(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, m_args,&req_args);
return mastodont_request(data, m_args, &req_args);
}