aboutsummaryrefslogtreecommitdiffstats
path: root/messagesocket.h
blob: 5a4c67d22190d81849c2b3f86781be560bebf145 (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
32
33
34
35
36
37
38
39
40
#ifndef MESSAGESOCKET_H
#define MESSAGESOCKET_H

class MessageSocket
{
private:
    // Unimplemented
    MessageSocket(const MessageSocket&);
    MessageSocket& operator=(const MessageSocket&);

public:
    MessageSocket() : _sock(-1) {}
    ~MessageSocket() { Close(); }
    int fd() const { return _sock; }

    bool ServerInit();
    MessageSocket* Accept();
    ssize_t Read(void* buf, size_t len);

    bool ClientInit();
    bool Show(const char* message);
    bool Dismiss();

    void Close();

private:
    explicit MessageSocket(int fd) : _sock(fd) {}

    bool send_command(const char* command);

    int _sock;
};

extern int dialog_server_init();
extern int dialog_client_init();
extern int dialog_accept(int fd);
extern int dialog_show(int fd);
extern int dialog_dismiss(int fd);

#endif