mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Http_GetCurrent only returns request ID
This commit is contained in:
parent
ddf7b10d91
commit
49f7160974
13
src/Http.c
13
src/Http.c
@ -1054,24 +1054,19 @@ cc_bool Http_GetResult(int reqID, struct HttpRequest* item) {
|
||||
return i >= 0;
|
||||
}
|
||||
|
||||
cc_bool Http_GetCurrent(struct HttpRequest* request, int* progress) {
|
||||
cc_bool Http_GetCurrent(int* reqID, int* progress) {
|
||||
Mutex_Lock(curRequestMutex);
|
||||
{
|
||||
*request = http_curRequest;
|
||||
*reqID = http_curRequest.id;
|
||||
*progress = http_curProgress;
|
||||
}
|
||||
Mutex_Unlock(curRequestMutex);
|
||||
return request->id != 0;
|
||||
return *reqID != 0;
|
||||
}
|
||||
|
||||
int Http_CheckProgress(int reqID) {
|
||||
int curReqID, progress;
|
||||
Mutex_Lock(curRequestMutex);
|
||||
{
|
||||
curReqID = http_curRequest.id;
|
||||
progress = http_curProgress;
|
||||
}
|
||||
Mutex_Unlock(curRequestMutex);
|
||||
Http_GetCurrent(&curReqID, &progress);
|
||||
|
||||
if (reqID != curReqID) progress = HTTP_PROGRESS_NOT_WORKING_ON;
|
||||
return progress;
|
||||
|
@ -72,7 +72,7 @@ cc_bool Http_DescribeError(cc_result res, String* dst);
|
||||
/* (Data may still be non NULL even on error, e.g. on a http 404 error) */
|
||||
cc_bool Http_GetResult(int reqID, struct HttpRequest* item);
|
||||
/* Retrieves information about the request currently being processed. */
|
||||
cc_bool Http_GetCurrent(struct HttpRequest* request, int* progress);
|
||||
cc_bool Http_GetCurrent(int* reqID, int* progress);
|
||||
/* Retrieves information about the download progress of the given request. */
|
||||
/* NOTE: This may return HTTP_PROGRESS_NOT_WORKING_ON if download has finished. */
|
||||
/* As such, this method should always be paired with a call to Http_GetResult. */
|
||||
|
@ -1098,13 +1098,13 @@ static void ResourcesScreen_SetStatus(const String* str) {
|
||||
LWidget_Draw(w);
|
||||
}
|
||||
|
||||
static void ResourcesScreen_UpdateStatus(struct HttpRequest* req) {
|
||||
static void ResourcesScreen_UpdateStatus(int reqID) {
|
||||
String str; char strBuffer[STRING_SIZE];
|
||||
const char* name;
|
||||
struct LLabel* w = &ResourcesScreen_Instance.lblStatus;
|
||||
int count;
|
||||
|
||||
name = Fetcher_RequestName(req->id);
|
||||
name = Fetcher_RequestName(reqID);
|
||||
if (!name) return;
|
||||
|
||||
String_InitArray(str, strBuffer);
|
||||
@ -1116,11 +1116,10 @@ static void ResourcesScreen_UpdateStatus(struct HttpRequest* req) {
|
||||
}
|
||||
|
||||
static void ResourcesScreen_UpdateProgress(struct ResourcesScreen* s) {
|
||||
struct HttpRequest req;
|
||||
int progress;
|
||||
int reqID, progress;
|
||||
|
||||
if (!Http_GetCurrent(&req, &progress)) return;
|
||||
ResourcesScreen_UpdateStatus(&req);
|
||||
if (!Http_GetCurrent(&reqID, &progress)) return;
|
||||
ResourcesScreen_UpdateStatus(reqID);
|
||||
/* making request still, haven't started download yet */
|
||||
if (progress < 0 || progress > 100) return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user