diff options
Diffstat (limited to '')
-rw-r--r-- | src/h.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -19,7 +19,7 @@ enum dc_status { /* theese are flags and should be and-checked */ DC_UNSET = 0, /* default value when enum is calloced */ DC_INCOMPLETE = 1 << 0, /* struct SHALL NOT be used by the ui, it is yet to be filled by api */ DC_OK = 1 << 1, /* success status, api usually sets this after completion/filling of the strct */ - DC_BAD_LOGIN = 1 << 2, /* login failed */ + DC_BAD_LOGIN = 1 << 2, /* login failed because of wrong credentials */ DC_VERIFICATION_NEEDED = 1 << 3, /* login: check email, click link/reg: tough luck ur IP flagd */ DC_CAPTCHA_NEEDED = 1 << 4, /* must solve captcha, tough luck, not impl, use browser login */ DC_BAD_USERNAME = 1 << 5, /* provided username can't be registered */ @@ -28,7 +28,9 @@ enum dc_status { /* theese are flags and should be and-checked */ DC_CONTINUE = 1 << 8, /* attached handlers return this to continue processing this output, N/I */ DC_BREAK = 1 << 9, /* attached handlers return this to stop processing this output */ DC_FROM_LWS = 1 << 10, /* LWS cb is the caller, so do not attempt to do lws_service (loop) */ - DC_MUST_FREE = 1 << 11 /* cb pass: body must be freed when request is done with user_data */ + DC_MUST_FREE = 1 << 11, /* cb pass: body must be freed when request is done with user_data */ + DC_REQUEST_FAILED = 1 << 12, /* http request failed, reported to ui */ + DC_ERROR = 1 << 13 /* unknown error, non implemented non expected response */ }; enum dc_permissions { /* other permissions exist, but are not implemented/understood */ DC_ALL_PERMISSIONS = 1 << 3, /* this is incredibly retarded, why is this SEPARATE?!? - admins */ @@ -59,9 +61,9 @@ enum dc_api_io_type { DC_API_GUILD, /* i: TODO: create a guild-tr0 */ /* o: TODO: new guild created, GUI spawn it */ DC_API_LOGIN, /* i: pass a dc_client-tr1, to relogin FIX prev retd cl not create new */ - /* o: the previously passed dc_client with set status */ + /* o: the previously passed dc_client with set status, do not use yet! \/ */ DC_API_LOGIN_CB,/* i: used internally for passing response from http client to api, see source */ - /* o: n/a */ + /* o: to tell user that client is now fully filled and ready for use */ DC_API_REGISTER,/* i: pass a dc_client, to relogin FIX pr rt cl&cl->user not creat new */ /* o: the previously passed dc_client with set status */ DC_API_STATUS, /* i: N/A */ @@ -99,14 +101,16 @@ void dc_api_io_free (struct dc_api_io * s) { void dc_api_i (struct dc_api_io); enum dc_lws_headers { DC_LWS_AUTHORIZATION, + DC_LWS_CONTENT_TYPE, DC_LWS_HEADERS_LENGTH }; char * dc_lws_headers[] = { "Authorization:", + "Content-Type:" }; struct dc_lws_pass { /* struct that is allocated for in dc_lws_cb unique per connection in void * us */ char * body; /* this contains post body and when _CB is called, it contains response */ - size_t body_length; /* body is NULL terminated - note0 in src/api.c */ + size_t body_length; /* body is NULL terminated or NULL in case of failure */ char headers[DC_LWS_HEADERS_LENGTH][DC_LWS_MAX_HEADER_LENGTH]; /* nofree, a static 2d array */ int status; /* HTTP response code /\ headers contain request headers, then resp. */ struct dc_api_io api_io; /* so dc_api_io can decide what shall be passed into _CB */ |