summaryrefslogtreecommitdiff
path: root/vdr-androvdr/sock.h
blob: 260efedf165f7a9a312c7174337b05712fa48649 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * extendes sockets
 */

#ifndef _VDRMON_SOCK
#define _VDRMON_SOCK

#include <sys/types.h>
#include <sys/socket.h>
#include <string>

using namespace std;

class cVdrmanagerSocket
{
protected:
  int sock;
  const char * password;
protected:
  cVdrmanagerSocket();
public:
  virtual ~cVdrmanagerSocket();
  void Close();
  int GetSocket();
  bool MakeDontBlock();
  const char * GetPassword();
};

class cVdrmanagerClientSocket : public cVdrmanagerSocket
{
private:
  string readbuf;
  string writebuf;
  bool disconnected;
  int client;
  bool login;
public:
  cVdrmanagerClientSocket(const char * password);
  virtual ~cVdrmanagerClientSocket();
  bool Attach(int fd);
  bool IsLineComplete();
  bool GetLine(string& line);
  bool PutLine(string line);
  bool Read();
  bool Disconnected();
  void Disconnect();
  bool Flush();
  int GetClientId();
  bool WritePending();
  bool IsLoggedIn();
  void SetLoggedIn();
};

class cVdrmanagerServerSocket : public cVdrmanagerSocket
{
public:
  cVdrmanagerServerSocket();
  virtual ~cVdrmanagerServerSocket();
  bool Create(int port, const char * password);
  cVdrmanagerClientSocket * Accept();
};

#endif