1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 21:45:08 +00:00
serenity/Libraries/LibProtocol/Client.h
Andreas Kling 653e61d9cf LibProtocol: Add a Download object so users don't have to manage ID's
LibProtocol::Client::start_download() now gives you a Download object
with convenient hooks (on_finish & on_progress).

Also, the IPC handshake is snuck into the Client constructor, so you
don't need to perform it after instantiating a Client.

This makes using LibProtocol much more pleasant. :^)
2019-11-24 13:22:01 +01:00

31 lines
783 B
C++

#pragma once
#include <LibCore/CoreIPCClient.h>
#include <ProtocolServer/ProtocolClientEndpoint.h>
#include <ProtocolServer/ProtocolServerEndpoint.h>
namespace LibProtocol {
class Download;
class Client : public IPC::Client::ConnectionNG<ProtocolClientEndpoint, ProtocolServerEndpoint>
, public ProtocolClientEndpoint {
C_OBJECT(Client)
public:
Client();
virtual void handshake() override;
bool is_supported_protocol(const String&);
RefPtr<Download> start_download(const String& url);
bool stop_download(Badge<Download>, Download&);
private:
virtual void handle(const ProtocolClient::DownloadProgress&) override;
virtual void handle(const ProtocolClient::DownloadFinished&) override;
HashMap<i32, RefPtr<Download>> m_downloads;
};
}