Rename Download* to Request* and move HTTP stuff inside src/client/http
This commit is contained in:
parent
1864a8649d
commit
30c7f6ded7
@ -51,8 +51,6 @@
|
|||||||
#include "gui/interface/Keys.h"
|
#include "gui/interface/Keys.h"
|
||||||
#include "gui/Style.h"
|
#include "gui/Style.h"
|
||||||
|
|
||||||
#include "client/HTTP.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define INCLUDE_SYSWM
|
#define INCLUDE_SYSWM
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
#include "client/UserInfo.h"
|
#include "client/UserInfo.h"
|
||||||
#include "gui/preview/Comment.h"
|
#include "gui/preview/Comment.h"
|
||||||
#include "ClientListener.h"
|
#include "ClientListener.h"
|
||||||
#include "client/Download.h"
|
#include "client/http/Request.h"
|
||||||
#include "client/DownloadManager.h"
|
#include "client/http/RequestManager.h"
|
||||||
|
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ void Client::Initialise(ByteString proxyString)
|
|||||||
update_finish();
|
update_finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
http::DownloadManager::Ref().Initialise(proxyString);
|
http::RequestManager::Ref().Initialise(proxyString);
|
||||||
|
|
||||||
//Read stamps library
|
//Read stamps library
|
||||||
std::ifstream stampsLib;
|
std::ifstream stampsLib;
|
||||||
@ -128,7 +128,7 @@ void Client::Initialise(ByteString proxyString)
|
|||||||
stampsLib.close();
|
stampsLib.close();
|
||||||
|
|
||||||
//Begin version check
|
//Begin version check
|
||||||
versionCheckRequest = new http::Download("http://" SERVER "/Startup.json");
|
versionCheckRequest = new http::Request("http://" SERVER "/Startup.json");
|
||||||
|
|
||||||
if (authUser.UserID)
|
if (authUser.UserID)
|
||||||
{
|
{
|
||||||
@ -138,7 +138,7 @@ void Client::Initialise(ByteString proxyString)
|
|||||||
|
|
||||||
#ifdef UPDATESERVER
|
#ifdef UPDATESERVER
|
||||||
// use an alternate update server
|
// use an alternate update server
|
||||||
alternateVersionCheckRequest = new http::Download("http://" UPDATESERVER "/Startup.json");
|
alternateVersionCheckRequest = new http::Request("http://" UPDATESERVER "/Startup.json");
|
||||||
usingAltUpdateServer = true;
|
usingAltUpdateServer = true;
|
||||||
if (authUser.UserID)
|
if (authUser.UserID)
|
||||||
{
|
{
|
||||||
@ -718,7 +718,7 @@ void Client::Tick()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::CheckUpdate(http::Download *updateRequest, bool checkSession)
|
bool Client::CheckUpdate(http::Request *updateRequest, bool checkSession)
|
||||||
{
|
{
|
||||||
//Check status on version check request
|
//Check status on version check request
|
||||||
if (updateRequest->CheckDone())
|
if (updateRequest->CheckDone())
|
||||||
@ -913,7 +913,7 @@ void Client::WritePrefs()
|
|||||||
|
|
||||||
void Client::Shutdown()
|
void Client::Shutdown()
|
||||||
{
|
{
|
||||||
http::DownloadManager::Ref().Shutdown();
|
http::RequestManager::Ref().Shutdown();
|
||||||
|
|
||||||
//Save config
|
//Save config
|
||||||
WritePrefs();
|
WritePrefs();
|
||||||
@ -976,7 +976,7 @@ RequestStatus Client::UploadSave(SaveInfo & save)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data = http::Download::SimpleAuth("http://" SERVER "/Save.api", &dataStatus, userID, authUser.SessionID, {
|
data = http::Request::SimpleAuth("http://" SERVER "/Save.api", &dataStatus, userID, authUser.SessionID, {
|
||||||
{ "Name", save.GetName().ToUtf8() },
|
{ "Name", save.GetName().ToUtf8() },
|
||||||
{ "Description", save.GetDescription().ToUtf8() },
|
{ "Description", save.GetDescription().ToUtf8() },
|
||||||
{ "Data:save.bin", ByteString(gameData, gameData + gameDataLength) },
|
{ "Data:save.bin", ByteString(gameData, gameData + gameDataLength) },
|
||||||
@ -1172,7 +1172,7 @@ RequestStatus Client::ExecVote(int saveID, int direction)
|
|||||||
{
|
{
|
||||||
ByteString saveIDText = ByteString::Build(saveID);
|
ByteString saveIDText = ByteString::Build(saveID);
|
||||||
ByteString userIDText = ByteString::Build(authUser.UserID);
|
ByteString userIDText = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth("http://" SERVER "/Vote.api", &dataStatus, userIDText, authUser.SessionID, {
|
data = http::Request::SimpleAuth("http://" SERVER "/Vote.api", &dataStatus, userIDText, authUser.SessionID, {
|
||||||
{ "ID", saveIDText },
|
{ "ID", saveIDText },
|
||||||
{ "Action", direction == 1 ? "Up" : "Down" },
|
{ "Action", direction == 1 ? "Up" : "Down" },
|
||||||
});
|
});
|
||||||
@ -1198,7 +1198,7 @@ unsigned char * Client::GetSaveData(int saveID, int saveDate, int & dataLength)
|
|||||||
else
|
else
|
||||||
urlStr = ByteString::Build("http://", STATICSERVER, "/", saveID, ".cps");
|
urlStr = ByteString::Build("http://", STATICSERVER, "/", saveID, ".cps");
|
||||||
|
|
||||||
data = http::Download::Simple(urlStr, &dataStatus);
|
data = http::Request::Simple(urlStr, &dataStatus);
|
||||||
|
|
||||||
// will always return failure
|
// will always return failure
|
||||||
ParseServerReturn(data, dataStatus, false);
|
ParseServerReturn(data, dataStatus, false);
|
||||||
@ -1244,7 +1244,7 @@ LoginStatus Client::Login(ByteString username, ByteString password, User & user)
|
|||||||
|
|
||||||
ByteString data;
|
ByteString data;
|
||||||
int dataStatus;
|
int dataStatus;
|
||||||
data = http::Download::Simple("http://" SERVER "/Login.json", &dataStatus, {
|
data = http::Request::Simple("http://" SERVER "/Login.json", &dataStatus, {
|
||||||
{ "Username", username },
|
{ "Username", username },
|
||||||
{ "Hash", totalHash },
|
{ "Hash", totalHash },
|
||||||
});
|
});
|
||||||
@ -1304,7 +1304,7 @@ RequestStatus Client::DeleteSave(int saveID)
|
|||||||
if(authUser.UserID)
|
if(authUser.UserID)
|
||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
|
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1324,7 +1324,7 @@ RequestStatus Client::AddComment(int saveID, String comment)
|
|||||||
if(authUser.UserID)
|
if(authUser.UserID)
|
||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
|
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
|
||||||
{ "Comment", comment.ToUtf8() },
|
{ "Comment", comment.ToUtf8() },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1349,7 +1349,7 @@ RequestStatus Client::FavouriteSave(int saveID, bool favourite)
|
|||||||
if(authUser.UserID)
|
if(authUser.UserID)
|
||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
|
data = http::Request::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1369,7 +1369,7 @@ RequestStatus Client::ReportSave(int saveID, String message)
|
|||||||
if(authUser.UserID)
|
if(authUser.UserID)
|
||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
|
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
|
||||||
{ "Reason", message.ToUtf8() },
|
{ "Reason", message.ToUtf8() },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1391,7 +1391,7 @@ RequestStatus Client::UnpublishSave(int saveID)
|
|||||||
if(authUser.UserID)
|
if(authUser.UserID)
|
||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
|
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1411,7 +1411,7 @@ RequestStatus Client::PublishSave(int saveID)
|
|||||||
if (authUser.UserID)
|
if (authUser.UserID)
|
||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
|
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID, {
|
||||||
{ "ActionPublish", "bagels" },
|
{ "ActionPublish", "bagels" },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1439,11 +1439,11 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
|
|||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
|
|
||||||
data = http::Download::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
|
data = http::Request::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = http::Download::Simple(urlStream.Build(), &dataStatus);
|
data = http::Request::Simple(urlStream.Build(), &dataStatus);
|
||||||
}
|
}
|
||||||
if(dataStatus == 200 && data.size())
|
if(dataStatus == 200 && data.size())
|
||||||
{
|
{
|
||||||
@ -1511,7 +1511,7 @@ std::vector<std::pair<ByteString, int> > * Client::GetTags(int start, int count,
|
|||||||
urlStream << format::URLEncode(query.ToUtf8());
|
urlStream << format::URLEncode(query.ToUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
data = http::Download::Simple(urlStream.Build(), &dataStatus);
|
data = http::Request::Simple(urlStream.Build(), &dataStatus);
|
||||||
if(dataStatus == 200 && data.size())
|
if(dataStatus == 200 && data.size())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1569,11 +1569,11 @@ std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, String query,
|
|||||||
if(authUser.UserID)
|
if(authUser.UserID)
|
||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
|
data = http::Request::SimpleAuth(urlStream.Build(), &dataStatus, userID, authUser.SessionID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = http::Download::Simple(urlStream.Build(), &dataStatus);
|
data = http::Request::Simple(urlStream.Build(), &dataStatus);
|
||||||
}
|
}
|
||||||
ParseServerReturn(data, dataStatus, true);
|
ParseServerReturn(data, dataStatus, true);
|
||||||
if (dataStatus == 200 && data.size())
|
if (dataStatus == 200 && data.size())
|
||||||
@ -1621,7 +1621,7 @@ std::list<ByteString> * Client::RemoveTag(int saveID, ByteString tag)
|
|||||||
if(authUser.UserID)
|
if(authUser.UserID)
|
||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
|
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1660,7 +1660,7 @@ std::list<ByteString> * Client::AddTag(int saveID, ByteString tag)
|
|||||||
if(authUser.UserID)
|
if(authUser.UserID)
|
||||||
{
|
{
|
||||||
ByteString userID = ByteString::Build(authUser.UserID);
|
ByteString userID = ByteString::Build(authUser.UserID);
|
||||||
data = http::Download::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
|
data = http::Request::SimpleAuth(url, &dataStatus, userID, authUser.SessionID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -48,15 +48,15 @@ class RequestListener;
|
|||||||
class ClientListener;
|
class ClientListener;
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
class Download;
|
class Request;
|
||||||
}
|
}
|
||||||
class Client: public Singleton<Client> {
|
class Client: public Singleton<Client> {
|
||||||
private:
|
private:
|
||||||
String messageOfTheDay;
|
String messageOfTheDay;
|
||||||
std::vector<std::pair<String, ByteString> > serverNotifications;
|
std::vector<std::pair<String, ByteString> > serverNotifications;
|
||||||
|
|
||||||
http::Download *versionCheckRequest;
|
http::Request *versionCheckRequest;
|
||||||
http::Download *alternateVersionCheckRequest;
|
http::Request *alternateVersionCheckRequest;
|
||||||
bool usingAltUpdateServer;
|
bool usingAltUpdateServer;
|
||||||
bool updateAvailable;
|
bool updateAvailable;
|
||||||
UpdateInfo updateInfo;
|
UpdateInfo updateInfo;
|
||||||
@ -167,7 +167,7 @@ public:
|
|||||||
}
|
}
|
||||||
RequestStatus ParseServerReturn(ByteString &result, int status, bool json);
|
RequestStatus ParseServerReturn(ByteString &result, int status, bool json);
|
||||||
void Tick();
|
void Tick();
|
||||||
bool CheckUpdate(http::Download *updateRequest, bool checkSession);
|
bool CheckUpdate(http::Request *updateRequest, bool checkSession);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
// preferences functions
|
// preferences functions
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
APIRequest::APIRequest(ByteString url) : Download(url)
|
APIRequest::APIRequest(ByteString url) : Request(url)
|
||||||
{
|
{
|
||||||
User user = Client::Ref().GetAuthUser();
|
User user = Client::Ref().GetAuthUser();
|
||||||
AuthHeaders(ByteString::Build(user.UserID), user.SessionID);
|
AuthHeaders(ByteString::Build(user.UserID), user.SessionID);
|
||||||
@ -19,7 +19,7 @@ namespace http
|
|||||||
Result result;
|
Result result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ByteString data = Download::Finish(&result.status);
|
ByteString data = Request::Finish(&result.status);
|
||||||
Client::Ref().ParseServerReturn(data, result.status, true);
|
Client::Ref().ParseServerReturn(data, result.status, true);
|
||||||
if (result.status == 200 && data.size())
|
if (result.status == 200 && data.size())
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef APIREQUEST2_H
|
#ifndef APIREQUEST2_H
|
||||||
#define APIREQUEST2_H
|
#define APIREQUEST2_H
|
||||||
|
|
||||||
#include "Download.h"
|
#include "Request.h"
|
||||||
#include "common/String.h"
|
#include "common/String.h"
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
|
|
||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
class APIRequest : public Download
|
class APIRequest : public Request
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct Result
|
struct Result
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef GETUSERINFOREQUEST2_H
|
#ifndef GETUSERINFOREQUEST2_H
|
||||||
#define GETUSERINFOREQUEST2_H
|
#define GETUSERINFOREQUEST2_H
|
||||||
|
|
||||||
#include "Download.h"
|
#include "Request.h"
|
||||||
#include "common/String.h"
|
#include "common/String.h"
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "client/APIRequest.h"
|
#include "APIRequest.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
@ -51,7 +51,7 @@
|
|||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Misc.h"
|
#include "Misc.h"
|
||||||
#include "HTTP.h"
|
#include "HTTP.h"
|
||||||
#include "MD5.h"
|
#include "../MD5.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
#ifdef WIN
|
#ifdef WIN
|
||||||
@ -979,7 +979,7 @@ ByteString FindBoundary(std::map<ByteString, ByteString> parts, ByteString bound
|
|||||||
|
|
||||||
// Generates a MIME multipart message to be used in POST requests
|
// Generates a MIME multipart message to be used in POST requests
|
||||||
// see https://en.wikipedia.org/wiki/MIME#Multipart_messages
|
// see https://en.wikipedia.org/wiki/MIME#Multipart_messages
|
||||||
// this function used in Download class, and eventually all http requests
|
// this function used in Request class, and eventually all http requests
|
||||||
ByteString GetMultipartMessage(std::map<ByteString, ByteString> parts, ByteString boundary)
|
ByteString GetMultipartMessage(std::map<ByteString, ByteString> parts, ByteString boundary)
|
||||||
{
|
{
|
||||||
ByteStringBuilder data;
|
ByteStringBuilder data;
|
@ -7,7 +7,7 @@
|
|||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
ImageRequest::ImageRequest(ByteString url, int width, int height) :
|
ImageRequest::ImageRequest(ByteString url, int width, int height) :
|
||||||
Download(url),
|
Request(url),
|
||||||
Width(width),
|
Width(width),
|
||||||
Height(height)
|
Height(height)
|
||||||
{
|
{
|
||||||
@ -19,7 +19,7 @@ namespace http
|
|||||||
|
|
||||||
std::unique_ptr<VideoBuffer> ImageRequest::Finish()
|
std::unique_ptr<VideoBuffer> ImageRequest::Finish()
|
||||||
{
|
{
|
||||||
ByteString data = Download::Finish(nullptr);
|
ByteString data = Request::Finish(nullptr);
|
||||||
std::unique_ptr<VideoBuffer> vb;
|
std::unique_ptr<VideoBuffer> vb;
|
||||||
if (data.size())
|
if (data.size())
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef IMAGEREQUEST2_H
|
#ifndef IMAGEREQUEST2_H
|
||||||
#define IMAGEREQUEST2_H
|
#define IMAGEREQUEST2_H
|
||||||
|
|
||||||
#include "Download.h"
|
#include "Request.h"
|
||||||
#include "common/String.h"
|
#include "common/String.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -9,7 +9,7 @@
|
|||||||
class VideoBuffer;
|
class VideoBuffer;
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
class ImageRequest : public Download
|
class ImageRequest : public Request
|
||||||
{
|
{
|
||||||
int Width, Height;
|
int Width, Height;
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include "Download.h"
|
#include "Request.h"
|
||||||
#include "DownloadManager.h"
|
#include "RequestManager.h"
|
||||||
#include "HTTP.h"
|
#include "HTTP.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
Download::Download(ByteString uri_, bool keepAlive):
|
Request::Request(ByteString uri_, bool keepAlive):
|
||||||
http(NULL),
|
http(NULL),
|
||||||
keepAlive(keepAlive),
|
keepAlive(keepAlive),
|
||||||
downloadData(NULL),
|
downloadData(NULL),
|
||||||
@ -21,11 +21,11 @@ Download::Download(ByteString uri_, bool keepAlive):
|
|||||||
downloadStarted(false)
|
downloadStarted(false)
|
||||||
{
|
{
|
||||||
uri = ByteString(uri_);
|
uri = ByteString(uri_);
|
||||||
DownloadManager::Ref().AddDownload(this);
|
RequestManager::Ref().AddDownload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// called by download thread itself if download was canceled
|
// called by download thread itself if download was canceled
|
||||||
Download::~Download()
|
Request::~Request()
|
||||||
{
|
{
|
||||||
if (http && (keepAlive || downloadCanceled))
|
if (http && (keepAlive || downloadCanceled))
|
||||||
http_async_req_close(http);
|
http_async_req_close(http);
|
||||||
@ -34,12 +34,12 @@ Download::~Download()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add post data to a request
|
// add post data to a request
|
||||||
void Download::AddPostData(std::map<ByteString, ByteString> data)
|
void Request::AddPostData(std::map<ByteString, ByteString> data)
|
||||||
{
|
{
|
||||||
postDataBoundary = FindBoundary(data, "");
|
postDataBoundary = FindBoundary(data, "");
|
||||||
postData = GetMultipartMessage(data, postDataBoundary);
|
postData = GetMultipartMessage(data, postDataBoundary);
|
||||||
}
|
}
|
||||||
void Download::AddPostData(std::pair<ByteString, ByteString> data)
|
void Request::AddPostData(std::pair<ByteString, ByteString> data)
|
||||||
{
|
{
|
||||||
std::map<ByteString, ByteString> postData;
|
std::map<ByteString, ByteString> postData;
|
||||||
postData.insert(data);
|
postData.insert(data);
|
||||||
@ -47,7 +47,7 @@ void Download::AddPostData(std::pair<ByteString, ByteString> data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add userID and sessionID headers to the download. Must be done after download starts for some reason
|
// add userID and sessionID headers to the download. Must be done after download starts for some reason
|
||||||
void Download::AuthHeaders(ByteString ID, ByteString session)
|
void Request::AuthHeaders(ByteString ID, ByteString session)
|
||||||
{
|
{
|
||||||
if (ID != "0")
|
if (ID != "0")
|
||||||
userID = ID;
|
userID = ID;
|
||||||
@ -55,7 +55,7 @@ void Download::AuthHeaders(ByteString ID, ByteString session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start the download thread
|
// start the download thread
|
||||||
void Download::Start()
|
void Request::Start()
|
||||||
{
|
{
|
||||||
if (CheckStarted() || CheckDone())
|
if (CheckStarted() || CheckDone())
|
||||||
return;
|
return;
|
||||||
@ -65,19 +65,19 @@ void Download::Start()
|
|||||||
http_auth_headers(http, userID.c_str(), NULL, userSession.c_str());
|
http_auth_headers(http, userID.c_str(), NULL, userSession.c_str());
|
||||||
if (postDataBoundary.length())
|
if (postDataBoundary.length())
|
||||||
http_add_multipart_header(http, postDataBoundary);
|
http_add_multipart_header(http, postDataBoundary);
|
||||||
DownloadManager::Ref().Lock();
|
RequestManager::Ref().Lock();
|
||||||
downloadStarted = true;
|
downloadStarted = true;
|
||||||
DownloadManager::Ref().Unlock();
|
RequestManager::Ref().Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// finish the download (if called before the download is done, this will block)
|
// finish the download (if called before the download is done, this will block)
|
||||||
ByteString Download::Finish(int *status)
|
ByteString Request::Finish(int *status)
|
||||||
{
|
{
|
||||||
if (CheckCanceled())
|
if (CheckCanceled())
|
||||||
return ""; // shouldn't happen but just in case
|
return ""; // shouldn't happen but just in case
|
||||||
while (!CheckDone()); // block
|
while (!CheckDone()); // block
|
||||||
DownloadManager::Ref().Lock();
|
RequestManager::Ref().Lock();
|
||||||
downloadStarted = false;
|
downloadStarted = false;
|
||||||
if (status)
|
if (status)
|
||||||
*status = downloadStatus;
|
*status = downloadStatus;
|
||||||
@ -90,60 +90,60 @@ ByteString Download::Finish(int *status)
|
|||||||
downloadData = NULL;
|
downloadData = NULL;
|
||||||
if (!keepAlive)
|
if (!keepAlive)
|
||||||
downloadCanceled = true;
|
downloadCanceled = true;
|
||||||
DownloadManager::Ref().Unlock();
|
RequestManager::Ref().Unlock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the download size and progress (if the download has the correct length headers)
|
// returns the download size and progress (if the download has the correct length headers)
|
||||||
void Download::CheckProgress(int *total, int *done)
|
void Request::CheckProgress(int *total, int *done)
|
||||||
{
|
{
|
||||||
DownloadManager::Ref().Lock();
|
RequestManager::Ref().Lock();
|
||||||
if (!downloadFinished && http)
|
if (!downloadFinished && http)
|
||||||
http_async_get_length(http, total, done);
|
http_async_get_length(http, total, done);
|
||||||
else
|
else
|
||||||
*total = *done = 0;
|
*total = *done = 0;
|
||||||
DownloadManager::Ref().Unlock();
|
RequestManager::Ref().Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if the download has finished
|
// returns true if the download has finished
|
||||||
bool Download::CheckDone()
|
bool Request::CheckDone()
|
||||||
{
|
{
|
||||||
DownloadManager::Ref().Lock();
|
RequestManager::Ref().Lock();
|
||||||
bool ret = downloadFinished;
|
bool ret = downloadFinished;
|
||||||
DownloadManager::Ref().Unlock();
|
RequestManager::Ref().Unlock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if the download was canceled
|
// returns true if the download was canceled
|
||||||
bool Download::CheckCanceled()
|
bool Request::CheckCanceled()
|
||||||
{
|
{
|
||||||
DownloadManager::Ref().Lock();
|
RequestManager::Ref().Lock();
|
||||||
bool ret = downloadCanceled;
|
bool ret = downloadCanceled;
|
||||||
DownloadManager::Ref().Unlock();
|
RequestManager::Ref().Unlock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if the download is running
|
// returns true if the download is running
|
||||||
bool Download::CheckStarted()
|
bool Request::CheckStarted()
|
||||||
{
|
{
|
||||||
DownloadManager::Ref().Lock();
|
RequestManager::Ref().Lock();
|
||||||
bool ret = downloadStarted;
|
bool ret = downloadStarted;
|
||||||
DownloadManager::Ref().Unlock();
|
RequestManager::Ref().Unlock();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cancels the download, the download thread will delete the Download* when it finishes (do not use Download in any way after canceling)
|
// cancels the download, the download thread will delete the Request* when it finishes (do not use Request in any way after canceling)
|
||||||
void Download::Cancel()
|
void Request::Cancel()
|
||||||
{
|
{
|
||||||
DownloadManager::Ref().Lock();
|
RequestManager::Ref().Lock();
|
||||||
downloadCanceled = true;
|
downloadCanceled = true;
|
||||||
DownloadManager::Ref().Unlock();
|
RequestManager::Ref().Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteString Download::Simple(ByteString uri, int *status, std::map<ByteString, ByteString> post_data)
|
ByteString Request::Simple(ByteString uri, int *status, std::map<ByteString, ByteString> post_data)
|
||||||
{
|
{
|
||||||
Download *request = new Download(uri);
|
Request *request = new Request(uri);
|
||||||
request->AddPostData(post_data);
|
request->AddPostData(post_data);
|
||||||
request->Start();
|
request->Start();
|
||||||
while(!request->CheckDone())
|
while(!request->CheckDone())
|
||||||
@ -153,9 +153,9 @@ ByteString Download::Simple(ByteString uri, int *status, std::map<ByteString, By
|
|||||||
return request->Finish(status);
|
return request->Finish(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteString Download::SimpleAuth(ByteString uri, int *status, ByteString ID, ByteString session, std::map<ByteString, ByteString> post_data)
|
ByteString Request::SimpleAuth(ByteString uri, int *status, ByteString ID, ByteString session, std::map<ByteString, ByteString> post_data)
|
||||||
{
|
{
|
||||||
Download *request = new Download(uri);
|
Request *request = new Request(uri);
|
||||||
request->AddPostData(post_data);
|
request->AddPostData(post_data);
|
||||||
request->AuthHeaders(ID, session);
|
request->AuthHeaders(ID, session);
|
||||||
request->Start();
|
request->Start();
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
class DownloadManager;
|
class RequestManager;
|
||||||
class Download
|
class Request
|
||||||
{
|
{
|
||||||
ByteString uri;
|
ByteString uri;
|
||||||
void *http;
|
void *http;
|
||||||
@ -27,8 +27,8 @@ class Download
|
|||||||
volatile bool downloadStarted;
|
volatile bool downloadStarted;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Download(ByteString uri, bool keepAlive = false);
|
Request(ByteString uri, bool keepAlive = false);
|
||||||
virtual ~Download();
|
virtual ~Request();
|
||||||
|
|
||||||
void AddPostData(std::map<ByteString, ByteString> data);
|
void AddPostData(std::map<ByteString, ByteString> data);
|
||||||
void AddPostData(std::pair<ByteString, ByteString> data);
|
void AddPostData(std::pair<ByteString, ByteString> data);
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
bool CheckCanceled();
|
bool CheckCanceled();
|
||||||
bool CheckStarted();
|
bool CheckStarted();
|
||||||
|
|
||||||
friend class DownloadManager;
|
friend class RequestManager;
|
||||||
|
|
||||||
static ByteString Simple(ByteString uri, int *status, std::map<ByteString, ByteString> post_data = {});
|
static ByteString Simple(ByteString uri, int *status, std::map<ByteString, ByteString> post_data = {});
|
||||||
static ByteString SimpleAuth(ByteString uri, int *status, ByteString ID, ByteString session, std::map<ByteString, ByteString> post_data = {});
|
static ByteString SimpleAuth(ByteString uri, int *status, ByteString ID, ByteString session, std::map<ByteString, ByteString> post_data = {});
|
@ -1,35 +1,35 @@
|
|||||||
#include "DownloadManager.h"
|
#include "RequestManager.h"
|
||||||
#include "Download.h"
|
#include "Request.h"
|
||||||
#include "HTTP.h"
|
#include "HTTP.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
DownloadManager::DownloadManager():
|
RequestManager::RequestManager():
|
||||||
threadStarted(false),
|
threadStarted(false),
|
||||||
lastUsed(time(NULL)),
|
lastUsed(time(NULL)),
|
||||||
managerRunning(false),
|
managerRunning(false),
|
||||||
managerShutdown(false),
|
managerShutdown(false),
|
||||||
downloads(std::vector<Download*>()),
|
downloads(std::vector<Request*>()),
|
||||||
downloadsAddQueue(std::vector<Download*>())
|
downloadsAddQueue(std::vector<Request*>())
|
||||||
{
|
{
|
||||||
pthread_mutex_init(&downloadLock, NULL);
|
pthread_mutex_init(&downloadLock, NULL);
|
||||||
pthread_mutex_init(&downloadAddLock, NULL);
|
pthread_mutex_init(&downloadAddLock, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadManager::~DownloadManager()
|
RequestManager::~RequestManager()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::Shutdown()
|
void RequestManager::Shutdown()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&downloadLock);
|
pthread_mutex_lock(&downloadLock);
|
||||||
pthread_mutex_lock(&downloadAddLock);
|
pthread_mutex_lock(&downloadAddLock);
|
||||||
for (std::vector<Download*>::iterator iter = downloads.begin(); iter != downloads.end(); ++iter)
|
for (std::vector<Request*>::iterator iter = downloads.begin(); iter != downloads.end(); ++iter)
|
||||||
{
|
{
|
||||||
Download *download = (*iter);
|
Request *download = (*iter);
|
||||||
if (download->http)
|
if (download->http)
|
||||||
http_force_close(download->http);
|
http_force_close(download->http);
|
||||||
download->downloadCanceled = true;
|
download->downloadCanceled = true;
|
||||||
@ -47,14 +47,14 @@ void DownloadManager::Shutdown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//helper function for download
|
//helper function for download
|
||||||
TH_ENTRY_POINT void* DownloadManagerHelper(void* obj)
|
TH_ENTRY_POINT void* RequestManagerHelper(void* obj)
|
||||||
{
|
{
|
||||||
DownloadManager *temp = (DownloadManager*)obj;
|
RequestManager *temp = (RequestManager*)obj;
|
||||||
temp->Update();
|
temp->Update();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::Initialise(ByteString Proxy)
|
void RequestManager::Initialise(ByteString Proxy)
|
||||||
{
|
{
|
||||||
proxy = Proxy;
|
proxy = Proxy;
|
||||||
if (proxy.length())
|
if (proxy.length())
|
||||||
@ -67,14 +67,14 @@ void DownloadManager::Initialise(ByteString Proxy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::Start()
|
void RequestManager::Start()
|
||||||
{
|
{
|
||||||
managerRunning = true;
|
managerRunning = true;
|
||||||
lastUsed = time(NULL);
|
lastUsed = time(NULL);
|
||||||
pthread_create(&downloadThread, NULL, &DownloadManagerHelper, this);
|
pthread_create(&downloadThread, NULL, &RequestManagerHelper, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::Update()
|
void RequestManager::Update()
|
||||||
{
|
{
|
||||||
unsigned int numActiveDownloads = 0;
|
unsigned int numActiveDownloads = 0;
|
||||||
while (!managerShutdown)
|
while (!managerShutdown)
|
||||||
@ -95,7 +95,7 @@ void DownloadManager::Update()
|
|||||||
pthread_mutex_lock(&downloadLock);
|
pthread_mutex_lock(&downloadLock);
|
||||||
for (size_t i = 0; i < downloads.size(); i++)
|
for (size_t i = 0; i < downloads.size(); i++)
|
||||||
{
|
{
|
||||||
Download *download = downloads[i];
|
Request *download = downloads[i];
|
||||||
if (download->downloadCanceled)
|
if (download->downloadCanceled)
|
||||||
{
|
{
|
||||||
if (download->http && download->downloadStarted)
|
if (download->http && download->downloadStarted)
|
||||||
@ -130,7 +130,7 @@ void DownloadManager::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::EnsureRunning()
|
void RequestManager::EnsureRunning()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&downloadLock);
|
pthread_mutex_lock(&downloadLock);
|
||||||
if (!managerRunning)
|
if (!managerRunning)
|
||||||
@ -144,7 +144,7 @@ void DownloadManager::EnsureRunning()
|
|||||||
pthread_mutex_unlock(&downloadLock);
|
pthread_mutex_unlock(&downloadLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::AddDownload(Download *download)
|
void RequestManager::AddDownload(Request *download)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&downloadAddLock);
|
pthread_mutex_lock(&downloadAddLock);
|
||||||
downloadsAddQueue.push_back(download);
|
downloadsAddQueue.push_back(download);
|
||||||
@ -152,12 +152,12 @@ void DownloadManager::AddDownload(Download *download)
|
|||||||
EnsureRunning();
|
EnsureRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::Lock()
|
void RequestManager::Lock()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&downloadAddLock);
|
pthread_mutex_lock(&downloadAddLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::Unlock()
|
void RequestManager::Unlock()
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&downloadAddLock);
|
pthread_mutex_unlock(&downloadAddLock);
|
||||||
}
|
}
|
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
class Download;
|
class Request;
|
||||||
class DownloadManager : public Singleton<DownloadManager>
|
class RequestManager : public Singleton<RequestManager>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
pthread_t downloadThread;
|
pthread_t downloadThread;
|
||||||
@ -21,13 +21,13 @@ private:
|
|||||||
int lastUsed;
|
int lastUsed;
|
||||||
volatile bool managerRunning;
|
volatile bool managerRunning;
|
||||||
volatile bool managerShutdown;
|
volatile bool managerShutdown;
|
||||||
std::vector<Download*> downloads;
|
std::vector<Request*> downloads;
|
||||||
std::vector<Download*> downloadsAddQueue;
|
std::vector<Request*> downloadsAddQueue;
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
public:
|
public:
|
||||||
DownloadManager();
|
RequestManager();
|
||||||
~DownloadManager();
|
~RequestManager();
|
||||||
|
|
||||||
void Initialise(ByteString proxy);
|
void Initialise(ByteString proxy);
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public:
|
|||||||
void Update();
|
void Update();
|
||||||
void EnsureRunning();
|
void EnsureRunning();
|
||||||
|
|
||||||
void AddDownload(Download *download);
|
void AddDownload(Request *download);
|
||||||
void RemoveDownload(int id);
|
void RemoveDownload(int id);
|
||||||
|
|
||||||
void Lock();
|
void Lock();
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef SAVEUSERINFOREQUEST2_H
|
#ifndef SAVEUSERINFOREQUEST2_H
|
||||||
#define SAVEUSERINFOREQUEST2_H
|
#define SAVEUSERINFOREQUEST2_H
|
||||||
|
|
||||||
#include "Download.h"
|
#include "Request.h"
|
||||||
#include "common/String.h"
|
#include "common/String.h"
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "client/APIRequest.h"
|
#include "APIRequest.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
@ -6,8 +6,8 @@
|
|||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
#include "gui/interface/Colour.h"
|
#include "gui/interface/Colour.h"
|
||||||
#include "client/AvatarRequest.h"
|
#include "client/http/AvatarRequest.h"
|
||||||
#include "client/RequestMonitor.h"
|
#include "client/http/RequestMonitor.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
#include "client/SaveInfo.h"
|
#include "client/SaveInfo.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
#include "gui/interface/Colour.h"
|
#include "gui/interface/Colour.h"
|
||||||
#include "client/ThumbnailRequest.h"
|
#include "client/http/ThumbnailRequest.h"
|
||||||
#include "client/RequestMonitor.h"
|
#include "client/http/RequestMonitor.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -75,13 +75,13 @@ void PreviewModel::UpdateSave(int saveID, int saveDate)
|
|||||||
url = ByteString::Build("http://", STATICSERVER, "/", saveID, "_", saveDate, ".cps");
|
url = ByteString::Build("http://", STATICSERVER, "/", saveID, "_", saveDate, ".cps");
|
||||||
else
|
else
|
||||||
url = ByteString::Build("http://", STATICSERVER, "/", saveID, ".cps");
|
url = ByteString::Build("http://", STATICSERVER, "/", saveID, ".cps");
|
||||||
saveDataDownload = new http::Download(url);
|
saveDataDownload = new http::Request(url);
|
||||||
saveDataDownload->Start();
|
saveDataDownload->Start();
|
||||||
|
|
||||||
url = ByteString::Build("http://", SERVER , "/Browse/View.json?ID=", saveID);
|
url = ByteString::Build("http://", SERVER , "/Browse/View.json?ID=", saveID);
|
||||||
if (saveDate)
|
if (saveDate)
|
||||||
url += ByteString::Build("&Date=", saveDate);
|
url += ByteString::Build("&Date=", saveDate);
|
||||||
saveInfoDownload = new http::Download(url);
|
saveInfoDownload = new http::Request(url);
|
||||||
saveInfoDownload->AuthHeaders(ByteString::Build(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
|
saveInfoDownload->AuthHeaders(ByteString::Build(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
|
||||||
saveInfoDownload->Start();
|
saveInfoDownload->Start();
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ void PreviewModel::UpdateSave(int saveID, int saveDate)
|
|||||||
commentsLoaded = false;
|
commentsLoaded = false;
|
||||||
|
|
||||||
url = ByteString::Build("http://", SERVER, "/Browse/Comments.json?ID=", saveID, "&Start=", (commentsPageNumber-1)*20, "&Count=20");
|
url = ByteString::Build("http://", SERVER, "/Browse/Comments.json?ID=", saveID, "&Start=", (commentsPageNumber-1)*20, "&Count=20");
|
||||||
commentsDownload = new http::Download(url);
|
commentsDownload = new http::Request(url);
|
||||||
commentsDownload->AuthHeaders(ByteString::Build(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
|
commentsDownload->AuthHeaders(ByteString::Build(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
|
||||||
commentsDownload->Start();
|
commentsDownload->Start();
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ void PreviewModel::UpdateComments(int pageNumber)
|
|||||||
if (!GetDoOpen())
|
if (!GetDoOpen())
|
||||||
{
|
{
|
||||||
ByteString url = ByteString::Build("http://", SERVER, "/Browse/Comments.json?ID=", saveID, "&Start=", (commentsPageNumber-1)*20, "&Count=20");
|
ByteString url = ByteString::Build("http://", SERVER, "/Browse/Comments.json?ID=", saveID, "&Start=", (commentsPageNumber-1)*20, "&Count=20");
|
||||||
commentsDownload = new http::Download(url);
|
commentsDownload = new http::Request(url);
|
||||||
commentsDownload->AuthHeaders(ByteString::Build(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
|
commentsDownload->AuthHeaders(ByteString::Build(Client::Ref().GetAuthUser().UserID), Client::Ref().GetAuthUser().SessionID);
|
||||||
commentsDownload->Start();
|
commentsDownload->Start();
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ bool PreviewModel::ParseSaveInfo(ByteString &saveInfoResponse)
|
|||||||
saveDataDownload->Cancel();
|
saveDataDownload->Cancel();
|
||||||
delete saveData;
|
delete saveData;
|
||||||
saveData = NULL;
|
saveData = NULL;
|
||||||
saveDataDownload = new http::Download(ByteString::Build("http://", STATICSERVER, "/2157797.cps"));
|
saveDataDownload = new http::Request(ByteString::Build("http://", STATICSERVER, "/2157797.cps"));
|
||||||
saveDataDownload->Start();
|
saveDataDownload->Start();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "PreviewView.h"
|
#include "PreviewView.h"
|
||||||
#include "client/SaveInfo.h"
|
#include "client/SaveInfo.h"
|
||||||
#include "gui/preview/Comment.h"
|
#include "gui/preview/Comment.h"
|
||||||
#include "client/Download.h"
|
#include "client/http/Request.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -23,9 +23,9 @@ class PreviewModel {
|
|||||||
void notifyCommentsPageChanged();
|
void notifyCommentsPageChanged();
|
||||||
void notifyCommentBoxEnabledChanged();
|
void notifyCommentBoxEnabledChanged();
|
||||||
|
|
||||||
http::Download * saveDataDownload;
|
http::Request * saveDataDownload;
|
||||||
http::Download * saveInfoDownload;
|
http::Request * saveInfoDownload;
|
||||||
http::Download * commentsDownload;
|
http::Request * commentsDownload;
|
||||||
int saveID;
|
int saveID;
|
||||||
int saveDate;
|
int saveDate;
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
#include "Activity.h"
|
#include "Activity.h"
|
||||||
#include "client/UserInfo.h"
|
#include "client/UserInfo.h"
|
||||||
#include "gui/interface/Window.h"
|
#include "gui/interface/Window.h"
|
||||||
#include "client/SaveUserInfoRequest.h"
|
#include "client/http/SaveUserInfoRequest.h"
|
||||||
#include "client/GetUserInfoRequest.h"
|
#include "client/http/GetUserInfoRequest.h"
|
||||||
#include "client/RequestMonitor.h"
|
#include "client/http/RequestMonitor.h"
|
||||||
|
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "Update.h"
|
#include "Update.h"
|
||||||
#include "client/Download.h"
|
#include "client/http/Request.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ private:
|
|||||||
virtual bool doWork()
|
virtual bool doWork()
|
||||||
{
|
{
|
||||||
String error;
|
String error;
|
||||||
http::Download *request = new http::Download(updateName);
|
http::Request *request = new http::Request(updateName);
|
||||||
request->Start();
|
request->Start();
|
||||||
notifyStatus("Downloading update");
|
notifyStatus("Downloading update");
|
||||||
notifyProgress(-1);
|
notifyProgress(-1);
|
||||||
@ -149,7 +149,7 @@ void UpdateActivity::NotifyError(Task * sender)
|
|||||||
if (result == ConfirmPrompt::ResultOkay)
|
if (result == ConfirmPrompt::ResultOkay)
|
||||||
{
|
{
|
||||||
#ifndef UPDATESERVER
|
#ifndef UPDATESERVER
|
||||||
Platform::OpenURI("http://powdertoy.co.uk/Download.html");
|
Platform::OpenURI("http://powdertoy.co.uk/http/Request.html");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
a->Exit();
|
a->Exit();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
|
||||||
#include "client/Download.h"
|
#include "client/http/Request.h"
|
||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
#include "LuaScriptInterface.h"
|
#include "LuaScriptInterface.h"
|
||||||
#include "LuaScriptHelper.h"
|
#include "LuaScriptHelper.h"
|
||||||
@ -1355,7 +1355,7 @@ int luatpt_getscript(lua_State* l)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
ByteString scriptData = http::Download::Simple(url, &ret);
|
ByteString scriptData = http::Request::Simple(url, &ret);
|
||||||
if (!scriptData.size() || !filename)
|
if (!scriptData.size() || !filename)
|
||||||
{
|
{
|
||||||
return luaL_error(l, "Server did not return data");
|
return luaL_error(l, "Server did not return data");
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "gui/game/GameModel.h"
|
#include "gui/game/GameModel.h"
|
||||||
#include "gui/game/Tool.h"
|
#include "gui/game/Tool.h"
|
||||||
#include "LuaScriptHelper.h"
|
#include "LuaScriptHelper.h"
|
||||||
#include "client/HTTP.h"
|
|
||||||
#include "client/GameSave.h"
|
#include "client/GameSave.h"
|
||||||
#include "client/SaveFile.h"
|
#include "client/SaveFile.h"
|
||||||
#include "Misc.h"
|
#include "Misc.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user