mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
Start working on a Downloader app and backing classes in LibGUI.
LibGUI is slowly becoming LibKitchensink but I'm okay with this for now.
This commit is contained in:
parent
c7365a00f8
commit
8f30657390
21 changed files with 375 additions and 1 deletions
36
LibGUI/GNetworkJob.h
Normal file
36
LibGUI/GNetworkJob.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGUI/GObject.h>
|
||||
#include <AK/Function.h>
|
||||
|
||||
class GNetworkResponse;
|
||||
|
||||
class GNetworkJob : public GObject {
|
||||
public:
|
||||
enum class Error {
|
||||
None,
|
||||
ConnectionFailed,
|
||||
TransmissionFailed,
|
||||
};
|
||||
virtual ~GNetworkJob() override;
|
||||
|
||||
Function<void(bool success)> on_finish;
|
||||
|
||||
bool has_error() const { return m_error != Error::None; }
|
||||
Error error() const { return m_error; }
|
||||
GNetworkResponse* response() { return m_response.ptr(); }
|
||||
const GNetworkResponse* response() const { return m_response.ptr(); }
|
||||
|
||||
virtual void start() = 0;
|
||||
|
||||
virtual const char* class_name() const override { return "GNetworkJob"; }
|
||||
|
||||
protected:
|
||||
GNetworkJob();
|
||||
void did_finish(Retained<GNetworkResponse>&&);
|
||||
void did_fail(Error);
|
||||
|
||||
private:
|
||||
RetainPtr<GNetworkResponse> m_response;
|
||||
Error m_error { Error::None };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue