Octoprint (#804)

* Octoprint progress dialog

* Fix curl version on Windows
This commit is contained in:
Vojtech Kral 2018-04-04 11:18:22 +02:00 committed by bubnikv
parent 00324a14b8
commit b0840065ed
8 changed files with 136 additions and 41 deletions

View file

@ -14,9 +14,22 @@ class Http : public std::enable_shared_from_this<Http> {
private:
struct priv;
public:
struct Progress
{
size_t dltotal;
size_t dlnow;
size_t ultotal;
size_t ulnow;
Progress(size_t dltotal, size_t dlnow, size_t ultotal, size_t ulnow) :
dltotal(dltotal), dlnow(dlnow), ultotal(ultotal), ulnow(ulnow)
{}
};
typedef std::shared_ptr<Http> Ptr;
typedef std::function<void(std::string /* body */, unsigned /* http_status */)> CompleteFn;
typedef std::function<void(std::string /* body */, std::string /* error */, unsigned /* http_status */)> ErrorFn;
typedef std::function<void(Progress, bool& /* cancel */)> ProgressFn;
Http(Http &&other);
@ -37,9 +50,11 @@ public:
Http& on_complete(CompleteFn fn);
Http& on_error(ErrorFn fn);
Http& on_progress(ProgressFn fn);
Ptr perform();
void perform_sync();
void cancel();
static bool ca_file_supported();
private:
@ -48,6 +63,8 @@ private:
std::unique_ptr<priv> p;
};
std::ostream& operator<<(std::ostream &, const Http::Progress &);
}