Remove the unneeded manage memory option in request
This commit is contained in:
parent
89d35f09fa
commit
4cb3383c4a
@ -370,7 +370,7 @@ void AchievementsStatus::sync(const std::vector<uint32_t> & achieved_ids)
|
|||||||
ids = ids.substr(0, ids.size() - 1); // delete the last "," in the string
|
ids = ids.substr(0, ids.size() - 1); // delete the last "," in the string
|
||||||
Log::info("Achievements", "Synching achievement %s to server.",
|
Log::info("Achievements", "Synching achievement %s to server.",
|
||||||
ids.c_str());
|
ids.c_str());
|
||||||
auto request = std::make_shared<Online::HTTPRequest>(true, 2);
|
auto request = std::make_shared<Online::HTTPRequest>(/*priority*/2);
|
||||||
PlayerManager::setUserDetails(request, "achieving");
|
PlayerManager::setUserDetails(request, "achieving");
|
||||||
request->addParameter("achievementid", ids);
|
request->addParameter("achievementid", ids);
|
||||||
request->queue();
|
request->queue();
|
||||||
|
@ -396,7 +396,7 @@ void AddonsManager::downloadIcons()
|
|||||||
public:
|
public:
|
||||||
IconRequest(const std::string &filename,
|
IconRequest(const std::string &filename,
|
||||||
const std::string &url,
|
const std::string &url,
|
||||||
Addon *addon ) : HTTPRequest(filename, true, 1)
|
Addon *addon ) : HTTPRequest(filename,/*priority*/1)
|
||||||
{
|
{
|
||||||
m_addon = addon; setURL(url);
|
m_addon = addon; setURL(url);
|
||||||
} // IconRequest
|
} // IconRequest
|
||||||
|
@ -370,7 +370,7 @@ void reportHardwareStats()
|
|||||||
/** Version number of the hw report. */
|
/** Version number of the hw report. */
|
||||||
int m_version;
|
int m_version;
|
||||||
public:
|
public:
|
||||||
HWReportRequest(int version) : Online::HTTPRequest(/*manage memory*/true, 1)
|
HWReportRequest(int version) : Online::HTTPRequest(/*priority*/1)
|
||||||
, m_version(version)
|
, m_version(version)
|
||||||
{}
|
{}
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
@ -2461,7 +2461,7 @@ void ServerLobby::checkIncomingConnectionRequests()
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
PollServerRequest(std::shared_ptr<ServerLobby> sl)
|
PollServerRequest(std::shared_ptr<ServerLobby> sl)
|
||||||
: XMLRequest(true), m_server_lobby(sl)
|
: XMLRequest(), m_server_lobby(sl)
|
||||||
{
|
{
|
||||||
m_disable_sending_log = true;
|
m_disable_sending_log = true;
|
||||||
}
|
}
|
||||||
|
@ -85,8 +85,7 @@ std::shared_ptr<Online::XMLRequest> ServersManager::getWANRefreshRequest() const
|
|||||||
class WANRefreshRequest : public Online::XMLRequest
|
class WANRefreshRequest : public Online::XMLRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WANRefreshRequest() : Online::XMLRequest(/*manage_memory*/true,
|
WANRefreshRequest() : Online::XMLRequest(/*priority*/100) {}
|
||||||
/*priority*/100) {}
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
virtual void afterOperation() OVERRIDE
|
virtual void afterOperation() OVERRIDE
|
||||||
{
|
{
|
||||||
@ -120,7 +119,7 @@ std::shared_ptr<Online::XMLRequest> ServersManager::getLANRefreshRequest() const
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/** High priority for this request. */
|
/** High priority for this request. */
|
||||||
LANRefreshRequest() : XMLRequest(true, 100) {m_success = false;}
|
LANRefreshRequest() : XMLRequest(/*priority*/100) {m_success = false;}
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
virtual ~LANRefreshRequest() {}
|
virtual ~LANRefreshRequest() {}
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
@ -38,13 +38,11 @@ namespace Online
|
|||||||
|
|
||||||
/** Creates a HTTP(S) request that will have a raw string as result. (Can
|
/** Creates a HTTP(S) request that will have a raw string as result. (Can
|
||||||
* of course be used if the result doesn't matter.)
|
* of course be used if the result doesn't matter.)
|
||||||
* \param manage_memory whether or not the RequestManager should take care of
|
|
||||||
* deleting the object after all callbacks have been done.
|
|
||||||
* \param priority by what priority should the RequestManager take care of
|
* \param priority by what priority should the RequestManager take care of
|
||||||
* this request.
|
* this request.
|
||||||
*/
|
*/
|
||||||
HTTPRequest::HTTPRequest(bool manage_memory, int priority)
|
HTTPRequest::HTTPRequest(int priority)
|
||||||
: Request(manage_memory, priority, 0)
|
: Request(priority, 0)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
} // HTTPRequest
|
} // HTTPRequest
|
||||||
@ -52,14 +50,11 @@ namespace Online
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** This constructor configures this request to save the data in a flie.
|
/** This constructor configures this request to save the data in a flie.
|
||||||
* \param filename Name of the file to save the data to.
|
* \param filename Name of the file to save the data to.
|
||||||
* \param manage_memory whether or not the RequestManager should take care of
|
|
||||||
* deleting the object after all callbacks have been done.
|
|
||||||
* \param priority by what priority should the RequestManager take care of
|
* \param priority by what priority should the RequestManager take care of
|
||||||
* this request.
|
* this request.
|
||||||
*/
|
*/
|
||||||
HTTPRequest::HTTPRequest(const std::string &filename, bool manage_memory,
|
HTTPRequest::HTTPRequest(const std::string &filename, int priority)
|
||||||
int priority)
|
: Request(priority, 0)
|
||||||
: Request(manage_memory, priority, 0)
|
|
||||||
{
|
{
|
||||||
// A http request should not even be created when internet is disabled
|
// A http request should not even be created when internet is disabled
|
||||||
assert(UserConfigParams::m_internet_status ==
|
assert(UserConfigParams::m_internet_status ==
|
||||||
@ -74,9 +69,8 @@ namespace Online
|
|||||||
/** Char * needs a separate constructor, otherwise it will be considered
|
/** Char * needs a separate constructor, otherwise it will be considered
|
||||||
* to be the no-filename constructor (char* -> bool).
|
* to be the no-filename constructor (char* -> bool).
|
||||||
*/
|
*/
|
||||||
HTTPRequest::HTTPRequest(const char* const filename, bool manage_memory,
|
HTTPRequest::HTTPRequest(const char* const filename, int priority)
|
||||||
int priority)
|
: Request(priority, 0)
|
||||||
: Request(manage_memory, priority, 0)
|
|
||||||
{
|
{
|
||||||
// A http request should not even be created when internet is disabled
|
// A http request should not even be created when internet is disabled
|
||||||
assert(UserConfigParams::m_internet_status ==
|
assert(UserConfigParams::m_internet_status ==
|
||||||
|
@ -91,11 +91,9 @@ namespace Online
|
|||||||
void init();
|
void init();
|
||||||
|
|
||||||
public :
|
public :
|
||||||
HTTPRequest(bool manage_memory = false, int priority = 1);
|
HTTPRequest(int priority = 1);
|
||||||
HTTPRequest(const std::string &filename, bool manage_memory = false,
|
HTTPRequest(const std::string &filename, int priority = 1);
|
||||||
int priority = 1);
|
HTTPRequest(const char * const filename, int priority = 1);
|
||||||
HTTPRequest(const char * const filename, bool manage_memory = false,
|
|
||||||
int priority = 1);
|
|
||||||
virtual ~HTTPRequest()
|
virtual ~HTTPRequest()
|
||||||
{
|
{
|
||||||
if (m_http_header)
|
if (m_http_header)
|
||||||
|
@ -54,7 +54,7 @@ namespace Online
|
|||||||
virtual void callback();
|
virtual void callback();
|
||||||
public:
|
public:
|
||||||
SignInRequest()
|
SignInRequest()
|
||||||
: XMLRequest(true/*manage_memory*/, /*priority*/10) {}
|
: XMLRequest(/*priority*/10) {}
|
||||||
}; // SignInRequest
|
}; // SignInRequest
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
@ -298,7 +298,7 @@ namespace Online
|
|||||||
* happens before a following logout.
|
* happens before a following logout.
|
||||||
*/
|
*/
|
||||||
SignOutRequest(PlayerProfile *player)
|
SignOutRequest(PlayerProfile *player)
|
||||||
: XMLRequest(true,/*priority*/RequestManager::HTTP_MAX_PRIORITY)
|
: XMLRequest(/*priority*/RequestManager::HTTP_MAX_PRIORITY)
|
||||||
{
|
{
|
||||||
m_player = player;
|
m_player = player;
|
||||||
setAbortable(false);
|
setAbortable(false);
|
||||||
@ -366,7 +366,7 @@ namespace Online
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
PrivateRequest::PollRequest::PollRequest()
|
PrivateRequest::PollRequest::PollRequest()
|
||||||
: XMLRequest(true)
|
: XMLRequest()
|
||||||
{
|
{
|
||||||
} // PollRequest
|
} // PollRequest
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ void OnlineProfile::fetchAchievements()
|
|||||||
class AchievementsRequest : public XMLRequest
|
class AchievementsRequest : public XMLRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AchievementsRequest() : XMLRequest(true, true) {}
|
AchievementsRequest() : XMLRequest() {}
|
||||||
virtual void callback()
|
virtual void callback()
|
||||||
{
|
{
|
||||||
uint32_t user_id = 0;
|
uint32_t user_id = 0;
|
||||||
@ -195,7 +195,7 @@ void OnlineProfile::fetchFriends()
|
|||||||
class FriendsListRequest : public XMLRequest
|
class FriendsListRequest : public XMLRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FriendsListRequest() : XMLRequest(true, true) {}
|
FriendsListRequest() : XMLRequest() {}
|
||||||
virtual void callback()
|
virtual void callback()
|
||||||
{
|
{
|
||||||
uint32_t user_id = 0;
|
uint32_t user_id = 0;
|
||||||
|
@ -30,15 +30,13 @@ namespace Online
|
|||||||
// ========================================================================
|
// ========================================================================
|
||||||
/**
|
/**
|
||||||
* Creates a request that can be handled by the RequestManager
|
* Creates a request that can be handled by the RequestManager
|
||||||
* \param manage_memory whether or not the RequestManager should take care of
|
|
||||||
* deleting the object after all callbacks have been done
|
|
||||||
* \param priority by what priority should the RequestManager take care of
|
* \param priority by what priority should the RequestManager take care of
|
||||||
* this request
|
* this request
|
||||||
* \param type indicates whether the request has a special task for the
|
* \param type indicates whether the request has a special task for the
|
||||||
* RequestManager
|
* RequestManager
|
||||||
*/
|
*/
|
||||||
Request::Request(bool manage_memory, int priority, int type)
|
Request::Request(int priority, int type)
|
||||||
: m_type(type), m_manage_memory(manage_memory), m_priority(priority)
|
: m_type(type), m_priority(priority)
|
||||||
{
|
{
|
||||||
m_cancel.setAtomic(false);
|
m_cancel.setAtomic(false);
|
||||||
m_state.setAtomic(S_PREPARING);
|
m_state.setAtomic(S_PREPARING);
|
||||||
|
@ -64,12 +64,6 @@ namespace Online
|
|||||||
/** Type of the request. Has 0 as default value. */
|
/** Type of the request. Has 0 as default value. */
|
||||||
const int m_type;
|
const int m_type;
|
||||||
|
|
||||||
/** True if the memory for this Request should be managed by
|
|
||||||
* http connector (i.e. this object is freed once the request
|
|
||||||
* is handled). Otherwise the memory is not freed, so it must
|
|
||||||
* be freed by the calling function. */
|
|
||||||
bool m_manage_memory;
|
|
||||||
|
|
||||||
/** The priority of this request. The higher the value the more
|
/** The priority of this request. The higher the value the more
|
||||||
important this request is. */
|
important this request is. */
|
||||||
const int m_priority;
|
const int m_priority;
|
||||||
@ -130,7 +124,7 @@ namespace Online
|
|||||||
RT_QUIT = 1
|
RT_QUIT = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
Request(bool manage_memory, int priority, int type);
|
Request(int priority, int type);
|
||||||
virtual ~Request() {}
|
virtual ~Request() {}
|
||||||
void execute();
|
void execute();
|
||||||
void executeNow();
|
void executeNow();
|
||||||
@ -144,17 +138,6 @@ namespace Online
|
|||||||
/** Returns the type of the request. */
|
/** Returns the type of the request. */
|
||||||
int getType() const { return m_type; }
|
int getType() const { return m_type; }
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
/** Returns if the memory for this object should be managed by
|
|
||||||
* by network_http (i.e. freed once the request is handled). */
|
|
||||||
bool manageMemory() const { return m_manage_memory; }
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
/** Sets the memory management flag of this request. This function
|
|
||||||
* must only be called by the main thread, since it is only tested by
|
|
||||||
* the main thread. */
|
|
||||||
void setManageMemory(bool m) { m_manage_memory = m; }
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
/** Returns the priority of this request. */
|
/** Returns the priority of this request. */
|
||||||
int getPriority() const { return m_priority; }
|
int getPriority() const { return m_priority; }
|
||||||
|
@ -145,8 +145,7 @@ namespace Online
|
|||||||
// quit request).
|
// quit request).
|
||||||
// Required for std::make_shared as it takes reference
|
// Required for std::make_shared as it takes reference
|
||||||
int priority = HTTP_MAX_PRIORITY;
|
int priority = HTTP_MAX_PRIORITY;
|
||||||
auto quit = std::make_shared<Request>(true, priority,
|
auto quit = std::make_shared<Request>(priority, Request::RT_QUIT);
|
||||||
Request::RT_QUIT);
|
|
||||||
quit->setAbortable(false);
|
quit->setAbortable(false);
|
||||||
addRequest(quit);
|
addRequest(quit);
|
||||||
|
|
||||||
|
@ -34,13 +34,11 @@ namespace Online
|
|||||||
{
|
{
|
||||||
/** Creates a HTTP(S) request that will automatically parse the answer into
|
/** Creates a HTTP(S) request that will automatically parse the answer into
|
||||||
* a XML structure.
|
* a XML structure.
|
||||||
* \param manage_memory whether or not the RequestManager should take care of
|
|
||||||
* deleting the object after all callbacks have been done.
|
|
||||||
* \param priority by what priority should the RequestManager take care of
|
* \param priority by what priority should the RequestManager take care of
|
||||||
* this request.
|
* this request.
|
||||||
*/
|
*/
|
||||||
XMLRequest::XMLRequest(bool manage_memory, int priority)
|
XMLRequest::XMLRequest(int priority)
|
||||||
: HTTPRequest(manage_memory, priority)
|
: HTTPRequest(priority)
|
||||||
{
|
{
|
||||||
m_info = "";
|
m_info = "";
|
||||||
m_success = false;
|
m_success = false;
|
||||||
|
@ -54,7 +54,7 @@ namespace Online
|
|||||||
virtual void afterOperation() OVERRIDE;
|
virtual void afterOperation() OVERRIDE;
|
||||||
|
|
||||||
public :
|
public :
|
||||||
XMLRequest(bool manage_memory = false, int priority = 1);
|
XMLRequest(int priority = 1);
|
||||||
virtual ~XMLRequest();
|
virtual ~XMLRequest();
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@ -345,7 +345,7 @@ void AddonsLoading::startDownload()
|
|||||||
std::string save = "tmp/"
|
std::string save = "tmp/"
|
||||||
+ StringUtils::getBasename(m_addon.getZipFileName());
|
+ StringUtils::getBasename(m_addon.getZipFileName());
|
||||||
m_download_request = std::make_shared<Online::HTTPRequest>(
|
m_download_request = std::make_shared<Online::HTTPRequest>(
|
||||||
save, /*manage mem*/false, /*priority*/5);
|
save, /*priority*/5);
|
||||||
m_download_request->setURL(m_addon.getZipFileName());
|
m_download_request->setURL(m_addon.getZipFileName());
|
||||||
m_download_request->queue();
|
m_download_request->queue();
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,8 +62,7 @@ private:
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
AddonsPackRequest(const std::string& url)
|
AddonsPackRequest(const std::string& url)
|
||||||
: HTTPRequest(StringUtils::getBasename(url), /*manage mem*/false,
|
: HTTPRequest(StringUtils::getBasename(url), /*priority*/5)
|
||||||
/*priority*/5)
|
|
||||||
{
|
{
|
||||||
m_extraction_error = true;
|
m_extraction_error = true;
|
||||||
if (url.find("https://") != std::string::npos ||
|
if (url.find("https://") != std::string::npos ||
|
||||||
@ -166,7 +165,6 @@ void AddonsPack::onUpdate(float delta)
|
|||||||
{
|
{
|
||||||
// Avoid displaying '-100%' in case of an error.
|
// Avoid displaying '-100%' in case of an error.
|
||||||
m_progress->setVisible(false);
|
m_progress->setVisible(false);
|
||||||
m_download_request->setManageMemory(true);
|
|
||||||
dismiss();
|
dismiss();
|
||||||
new MessageDialog(_("Sorry, downloading the add-on failed"));
|
new MessageDialog(_("Sorry, downloading the add-on failed"));
|
||||||
return;
|
return;
|
||||||
|
@ -49,7 +49,7 @@ private:
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
DownloadAssetsRequest()
|
DownloadAssetsRequest()
|
||||||
: HTTPRequest("stk-assets.zip", /*manage mem*/false, /*priority*/5)
|
: HTTPRequest("stk-assets.zip", /*priority*/5)
|
||||||
{
|
{
|
||||||
m_extraction_error = true;
|
m_extraction_error = true;
|
||||||
std::string download_url = stk_config->m_assets_download_url;
|
std::string download_url = stk_config->m_assets_download_url;
|
||||||
|
@ -81,7 +81,7 @@ protected:
|
|||||||
uint32_t online_id,
|
uint32_t online_id,
|
||||||
GUIEngine::LabelWidget* info,
|
GUIEngine::LabelWidget* info,
|
||||||
std::shared_ptr<bool> done)
|
std::shared_ptr<bool> done)
|
||||||
: XMLRequest(true)
|
: XMLRequest()
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
m_info = info;
|
m_info = info;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user