Commit 25a0ebcf authored by Paweł Wegner's avatar Paweł Wegner

Progress: accept uint64_t instead of uint32_t.

parent 91a24160
......@@ -53,7 +53,7 @@ void DownloadFileCallback::done(EitherError<void> e) {
emit window_->downloadProgressChanged(0, 0);
}
void DownloadFileCallback::progress(uint32_t total, uint32_t now) {
void DownloadFileCallback::progress(uint64_t total, uint64_t now) {
emit window_->downloadProgressChanged(total, now);
}
......@@ -87,7 +87,7 @@ void UploadFileCallback::done(EitherError<IItem> e) {
emit window_->uploadProgressChanged(0, 0);
}
void UploadFileCallback::progress(uint32_t total, uint32_t now) {
void UploadFileCallback::progress(uint64_t total, uint64_t now) {
emit window_->uploadProgressChanged(total, now);
}
......@@ -153,4 +153,4 @@ void DownloadThumbnailCallback::done(EitherError<void> e) {
emit item_->receivedImage();
}
void DownloadThumbnailCallback::progress(uint32_t, uint32_t) {}
void DownloadThumbnailCallback::progress(uint64_t, uint64_t) {}
......@@ -58,7 +58,7 @@ class DownloadThumbnailCallback : public IDownloadFileCallback {
void done(EitherError<void>) override;
void progress(uint32_t, uint32_t) override;
void progress(uint64_t, uint64_t) override;
private:
ItemModel* item_;
......@@ -71,7 +71,7 @@ class DownloadFileCallback : public IDownloadFileCallback {
void receivedData(const char* data, uint32_t length) override;
void done(EitherError<void>) override;
void progress(uint32_t total, uint32_t now) override;
void progress(uint64_t total, uint64_t now) override;
private:
Window* window_;
......@@ -87,7 +87,7 @@ class UploadFileCallback : public IUploadFileCallback {
uint32_t putData(char* data, uint32_t maxlength) override;
uint64_t size() override;
void done(EitherError<IItem>) override;
void progress(uint32_t total, uint32_t now) override;
void progress(uint64_t total, uint64_t now) override;
private:
Window* window_;
......
......@@ -94,7 +94,7 @@ class DownloadFileCallback : public cloudstorage::IDownloadFileCallback {
callback_(e);
}
void progress(uint32_t, uint32_t) override {}
void progress(uint64_t, uint64_t) override {}
private:
std::fstream file_;
......@@ -128,7 +128,7 @@ class UploadFileCallback : public cloudstorage::IUploadFileCallback {
callback_(e);
}
void progress(uint32_t, uint32_t) override {}
void progress(uint64_t, uint64_t) override {}
private:
std::fstream file_;
......
......@@ -272,7 +272,7 @@ class HttpDataCallback : public IDownloadFileCallback {
buffer_->resume();
}
void progress(uint32_t, uint32_t) override {}
void progress(uint64_t, uint64_t) override {}
Buffer::Pointer buffer_;
};
......
......@@ -78,7 +78,7 @@ class IHttpRequest {
* @param total count of bytes to download
* @param now count of bytes downloaded
*/
virtual void progressDownload(uint32_t total, uint32_t now) = 0;
virtual void progressDownload(uint64_t total, uint64_t now) = 0;
/**
* Called when upload progress changed.
......@@ -86,7 +86,7 @@ class IHttpRequest {
* @param total count of bytes to upload
* @param now count of bytes uploaded
*/
virtual void progressUpload(uint32_t total, uint32_t now) = 0;
virtual void progressUpload(uint64_t total, uint64_t now) = 0;
};
/**
......
......@@ -144,7 +144,7 @@ class IDownloadFileCallback {
* @param total count of bytes to download
* @param now count of bytes downloaded
*/
virtual void progress(uint32_t total, uint32_t now) = 0;
virtual void progress(uint64_t total, uint64_t now) = 0;
};
class IUploadFileCallback {
......@@ -184,7 +184,7 @@ class IUploadFileCallback {
* @param total count of bytes to upload
* @param now count of bytes already uploaded
*/
virtual void progress(uint32_t total, uint32_t now) = 0;
virtual void progress(uint64_t total, uint64_t now) = 0;
};
struct Error {
......
......@@ -28,8 +28,7 @@ namespace cloudstorage {
HttpCallback::HttpCallback(
std::function<bool()> is_cancelled,
std::function<bool(int, const IHttpRequest::HeaderParameters&)> is_success,
std::function<void(uint32_t, uint32_t)> progress_download,
std::function<void(uint32_t, uint32_t)> progress_upload)
ProgressFunction progress_download, ProgressFunction progress_upload)
: is_cancelled_(is_cancelled),
is_success_(is_success),
progress_download_(progress_download),
......@@ -42,11 +41,11 @@ bool HttpCallback::isSuccess(int code,
bool HttpCallback::abort() { return is_cancelled_(); }
void HttpCallback::progressDownload(uint32_t total, uint32_t now) {
void HttpCallback::progressDownload(uint64_t total, uint64_t now) {
if (progress_download_) progress_download_(total, now);
}
void HttpCallback::progressUpload(uint32_t total, uint32_t now) {
void HttpCallback::progressUpload(uint64_t total, uint64_t now) {
if (progress_upload_) progress_upload_(total, now);
}
......
......@@ -32,25 +32,27 @@
namespace cloudstorage {
class HttpCallback : public IHttpRequest::ICallback {
public:
using ProgressFunction = std::function<void(uint64_t, uint64_t)>;
HttpCallback(std::function<bool()> is_cancelled,
std::function<bool(int, const IHttpRequest::HeaderParameters&)>
is_success,
std::function<void(uint32_t, uint32_t)> progress_download,
std::function<void(uint32_t, uint32_t)> progress_upload);
ProgressFunction progress_download,
ProgressFunction progress_upload);
bool isSuccess(int, const IHttpRequest::HeaderParameters&) const override;
bool abort() override;
void progressDownload(uint32_t total, uint32_t now) override;
void progressDownload(uint64_t total, uint64_t now) override;
void progressUpload(uint32_t, uint32_t) override;
void progressUpload(uint64_t, uint64_t) override;
private:
std::function<bool()> is_cancelled_;
std::function<bool(int, const IHttpRequest::HeaderParameters&)> is_success_;
std::function<void(uint32_t, uint32_t)> progress_download_;
std::function<void(uint32_t, uint32_t)> progress_upload_;
ProgressFunction progress_download_;
ProgressFunction progress_upload_;
};
} // namespace cloudstorage
......
......@@ -80,11 +80,11 @@ int progress_callback(void* clientp, curl_off_t dltotal, curl_off_t dlnow,
static_cast<CurlHttpRequest::ICallback*>(clientp);
if (callback) {
if (ultotal != 0)
callback->progressUpload(static_cast<uint32_t>(ultotal),
static_cast<uint32_t>(ulnow));
callback->progressUpload(static_cast<uint64_t>(ultotal),
static_cast<uint64_t>(ulnow));
if (dltotal != 0)
callback->progressDownload(static_cast<uint32_t>(dltotal),
static_cast<uint32_t>(dlnow));
callback->progressDownload(static_cast<uint64_t>(dltotal),
static_cast<uint64_t>(dlnow));
if (callback->abort()) return 1;
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment