mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-10 21:16:24 +02:00
Use the patched naett functions to implement progress updates
This commit is contained in:
1 parent
c17a559188
commit
9535b16740
8 files changed
+52
-39
No files matched your search
@@ -3,9 +3,34 @@
|
||||
#include "Common/Net/HTTPNaettRequest.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/System/OSD.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
Download::Download(RequestMethod method, const std::string &url, const std::string &name, bool *cancelled, ProgressBarMode mode) : method_(method), url_(url), name_(name), progress_(cancelled), progressBarMode_(mode) {
|
||||
progress_.callback = [=](int64_t bytes, int64_t contentLength, bool done) {
|
||||
std::string message;
|
||||
if (!name_.empty()) {
|
||||
message = name_;
|
||||
} else {
|
||||
std::size_t pos = url_.rfind('/');
|
||||
if (pos != std::string::npos) {
|
||||
message = url_.substr(pos + 1);
|
||||
} else {
|
||||
message = url_;
|
||||
}
|
||||
}
|
||||
if (progressBarMode_ != ProgressBarMode::NONE) {
|
||||
if (!done) {
|
||||
g_OSD.SetProgressBar(url_, std::move(message), 0.0f, (float)contentLength, (float)bytes, progressBarMode_ == ProgressBarMode::DELAYED ? 3.0f : 0.0f); // delay 3 seconds before showing.
|
||||
} else {
|
||||
g_OSD.RemoveProgressBar(url_, Failed() ? false : true, 0.5f);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool RequestManager::IsHttpsUrl(const std::string &url) {
|
||||
return startsWith(url, "https:");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user