Path: blob/master/dep/rcheevos/include/rc_api_user.h
4246 views
#ifndef RC_API_USER_H1#define RC_API_USER_H23#include "rc_api_request.h"45#include <stdint.h>6#include <time.h>78RC_BEGIN_C_DECLS910/* --- Login --- */1112/**13* API parameters for a login request.14* If both password and api_token are provided, api_token will be ignored.15*/16typedef struct rc_api_login_request_t {17/* The username of the player being logged in */18const char* username;19/* The API token from a previous login */20const char* api_token;21/* The player's password */22const char* password;23}24rc_api_login_request_t;2526/**27* Response data for a login request.28*/29typedef struct rc_api_login_response_t {30/* The case-corrected username of the player */31const char* username;32/* The API token to use for all future requests */33const char* api_token;34/* The current score of the player */35uint32_t score;36/* The current softcore score of the player */37uint32_t score_softcore;38/* The number of unread messages waiting for the player on the web site */39uint32_t num_unread_messages;40/* The preferred name to display for the player */41const char* display_name;42/* A URL to the user's avatar image */43const char* avatar_url;4445/* Common server-provided response information */46rc_api_response_t response;47}48rc_api_login_response_t;4950RC_EXPORT int RC_CCONV rc_api_init_login_request(rc_api_request_t* request, const rc_api_login_request_t* api_params);51RC_EXPORT int RC_CCONV rc_api_init_login_request_hosted(rc_api_request_t* request, const rc_api_login_request_t* api_params, const rc_api_host_t* host);52/* [deprecated] use rc_api_process_login_server_response instead */53RC_EXPORT int RC_CCONV rc_api_process_login_response(rc_api_login_response_t* response, const char* server_response);54RC_EXPORT int RC_CCONV rc_api_process_login_server_response(rc_api_login_response_t* response, const rc_api_server_response_t* server_response);55RC_EXPORT void RC_CCONV rc_api_destroy_login_response(rc_api_login_response_t* response);5657/* --- Start Session --- */5859/**60* API parameters for a start session request.61*/62typedef struct rc_api_start_session_request_t {63/* The username of the player */64const char* username;65/* The API token from the login request */66const char* api_token;67/* The unique identifier of the game */68uint32_t game_id;69/* (recommended) The hash associated to the game being played */70const char* game_hash;71/* Non-zero if hardcore is currently enabled (ignored if game_hash is null) */72uint32_t hardcore;73}74rc_api_start_session_request_t;7576/**77* Response data for an achievement unlock.78*/79typedef struct rc_api_unlock_entry_t {80/* The unique identifier of the unlocked achievement */81uint32_t achievement_id;82/* When the achievement was unlocked */83time_t when;84}85rc_api_unlock_entry_t;8687/**88* Response data for a start session request.89*/90typedef struct rc_api_start_session_response_t {91/* An array of hardcore user unlocks */92rc_api_unlock_entry_t* hardcore_unlocks;93/* An array of user unlocks */94rc_api_unlock_entry_t* unlocks;9596/* The number of items in the hardcore_unlocks array */97uint32_t num_hardcore_unlocks;98/* The number of items in the unlocks array */99uint32_t num_unlocks;100101/* The server timestamp when the response was generated */102time_t server_now;103104/* Common server-provided response information */105rc_api_response_t response;106}107rc_api_start_session_response_t;108109RC_EXPORT int RC_CCONV rc_api_init_start_session_request(rc_api_request_t* request, const rc_api_start_session_request_t* api_params);110RC_EXPORT int RC_CCONV rc_api_init_start_session_request_hosted(rc_api_request_t* request, const rc_api_start_session_request_t* api_params, const rc_api_host_t* host);111/* [deprecated] use rc_api_process_start_session_server_response instead */112RC_EXPORT int RC_CCONV rc_api_process_start_session_response(rc_api_start_session_response_t* response, const char* server_response);113RC_EXPORT int RC_CCONV rc_api_process_start_session_server_response(rc_api_start_session_response_t* response, const rc_api_server_response_t* server_response);114RC_EXPORT void RC_CCONV rc_api_destroy_start_session_response(rc_api_start_session_response_t* response);115116/* --- Fetch User Unlocks --- */117118/**119* API parameters for a fetch user unlocks request.120*/121typedef struct rc_api_fetch_user_unlocks_request_t {122/* The username of the player */123const char* username;124/* The API token from the login request */125const char* api_token;126/* The unique identifier of the game */127uint32_t game_id;128/* Non-zero to fetch hardcore unlocks, 0 to fetch non-hardcore unlocks */129uint32_t hardcore;130}131rc_api_fetch_user_unlocks_request_t;132133/**134* Response data for a fetch user unlocks request.135*/136typedef struct rc_api_fetch_user_unlocks_response_t {137/* An array of achievement IDs previously unlocked by the user */138uint32_t* achievement_ids;139/* The number of items in the achievement_ids array */140uint32_t num_achievement_ids;141142/* Common server-provided response information */143rc_api_response_t response;144}145rc_api_fetch_user_unlocks_response_t;146147RC_EXPORT int RC_CCONV rc_api_init_fetch_user_unlocks_request(rc_api_request_t* request, const rc_api_fetch_user_unlocks_request_t* api_params);148RC_EXPORT int RC_CCONV rc_api_init_fetch_user_unlocks_request_hosted(rc_api_request_t* request, const rc_api_fetch_user_unlocks_request_t* api_params, const rc_api_host_t* host);149/* [deprecated] use rc_api_process_fetch_user_unlocks_server_response instead */150RC_EXPORT int RC_CCONV rc_api_process_fetch_user_unlocks_response(rc_api_fetch_user_unlocks_response_t* response, const char* server_response);151RC_EXPORT int RC_CCONV rc_api_process_fetch_user_unlocks_server_response(rc_api_fetch_user_unlocks_response_t* response, const rc_api_server_response_t* server_response);152RC_EXPORT void RC_CCONV rc_api_destroy_fetch_user_unlocks_response(rc_api_fetch_user_unlocks_response_t* response);153154/* --- Fetch Followed Users --- */155156/**157* API parameters for a fetch followed users request.158*/159typedef struct rc_api_fetch_followed_users_request_t {160/* The username of the player */161const char* username;162/* The API token from the login request */163const char* api_token;164}165rc_api_fetch_followed_users_request_t;166167typedef struct rc_api_followed_user_activity_t {168/* The record associated to the activity */169const char* context;170/* The image of the record associated to the activity */171const char* context_image_url;172/* The description of the activity */173const char* description;174/* The time of the activity */175time_t when;176/* The unique identifier of the record associated to the activity */177uint32_t context_id;178}179rc_api_followed_user_activity_t;180181/**182* Response data for a followed user.183*/184typedef struct rc_api_followed_user_t {185/* The preferred name to display for the player */186const char* display_name;187/* A URL to the user's avatar image */188const char* avatar_url;189/* The player's last registered activity */190rc_api_followed_user_activity_t recent_activity;191/* The current score of the player */192uint32_t score;193}194rc_api_followed_user_t;195196/**197* Response data for a fetch followed users request.198*/199typedef struct rc_api_fetch_followed_users_response_t {200/* An array of followed user information */201rc_api_followed_user_t* users;202/* The number of items in the users array */203uint32_t num_users;204205/* Common server-provided response information */206rc_api_response_t response;207}208rc_api_fetch_followed_users_response_t;209210RC_EXPORT int RC_CCONV rc_api_init_fetch_followed_users_request(rc_api_request_t* request, const rc_api_fetch_followed_users_request_t* api_params);211RC_EXPORT int RC_CCONV rc_api_init_fetch_followed_users_request_hosted(rc_api_request_t* request, const rc_api_fetch_followed_users_request_t* api_params, const rc_api_host_t* host);212RC_EXPORT int RC_CCONV rc_api_process_fetch_followed_users_server_response(rc_api_fetch_followed_users_response_t* response, const rc_api_server_response_t* server_response);213RC_EXPORT void RC_CCONV rc_api_destroy_fetch_followed_users_response(rc_api_fetch_followed_users_response_t* response);214215/* --- Fetch All Progress --- */216217/**218* API parameters for a fetch all user progress request.219*/220typedef struct rc_api_fetch_all_user_progress_request_t {221/* The username of the player */222const char* username;223/* The API token from the login request */224const char* api_token;225/* The unique identifier of the console to query */226uint32_t console_id;227} rc_api_fetch_all_user_progress_request_t;228229/* An all-user-progress entry */230typedef struct rc_api_all_user_progress_entry_t {231/* The unique identifier of the game */232uint32_t game_id;233/* The total number of achievements for this game */234uint32_t num_achievements;235/* The total number of unlocked achievements for this game in softcore mode */236uint32_t num_unlocked_achievements;237/* The total number of unlocked achievements for this game in hardcore mode */238uint32_t num_unlocked_achievements_hardcore;239} rc_api_all_user_progress_entry_t;240241/**242* Response data for a fetch all user progress request.243*/244typedef struct rc_api_fetch_all_user_progress_response_t {245/* An array of entries, one per game */246rc_api_all_user_progress_entry_t* entries;247/* The number of items in the entries array */248uint32_t num_entries;249250/* Common server-provided response information */251rc_api_response_t response;252} rc_api_fetch_all_user_progress_response_t;253254RC_EXPORT int RC_CCONV rc_api_init_fetch_all_user_progress_request(rc_api_request_t* request, const rc_api_fetch_all_user_progress_request_t* api_params);255RC_EXPORT int RC_CCONV rc_api_init_fetch_all_user_progress_request_hosted(rc_api_request_t* request, const rc_api_fetch_all_user_progress_request_t* api_params, const rc_api_host_t* host);256RC_EXPORT int RC_CCONV rc_api_process_fetch_all_user_progress_server_response(rc_api_fetch_all_user_progress_response_t* response, const rc_api_server_response_t* server_response);257RC_EXPORT void RC_CCONV rc_api_destroy_fetch_all_user_progress_response(rc_api_fetch_all_user_progress_response_t* response);258259RC_END_C_DECLS260261#endif /* RC_API_H */262263264