summaryrefslogtreecommitdiff
path: root/Libraries/LibProtocol/Client.h
blob: fc90dc9320b4f18d64babfcee1a2a6a9c5cb2f26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include <LibIPC/IServerConnection.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;
};

}