summaryrefslogtreecommitdiff
path: root/talk.h
blob: a07926c6d6314a39c1ad509ac44bcf868b4c7391 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//***************************************************************************
/*
 * fskcheck.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id: talk.h,v 1.1 2007/01/13 07:52:27 root Exp $
 */
//***************************************************************************

//***************************************************************************
// Includes
//***************************************************************************

#include "def.h"

//***************************************************************************
// Class Talk
//***************************************************************************

class Talk
{
   public:

      // declarations

      enum Error
      {
         errMessageServiceFirst = -1000,

         errMessageToBig,

         wrnSysInterrupt,
         wrnNoMessage
      };

      enum Size
      {
         sizeBuffer = 1000
      };

      enum Event
      {
         evtUnknown = na,

         evtCheck,         // = 0
         evtShow,          // = 1
         evtAsk,           // = 2
         evtConfirm,       // = 3
         evtAbort,         // = 4
         evtAnswer,        // = 5
         evtExit           // = 6
      };

      struct Header
      {
         long sender;
         long receiver;
         int event;
         int type;           // eMessageType
      };

      // object

      Talk();
      ~Talk();

      // functions

      int wait();
      int init();
      int send(long to, int event, const char* msg = 0);
      int open(long port);

      int isOpen()               { return opened; }
      long getTimeout()          { return timeout; }
      int getEvent()             { return event; }
      long getFrom()             { return from; }
      const char* getMessage()   { return message; }

      void setTimeout(long t)    { timeout = t; }

   protected:

      // data

      int receiverID;
      int msgID;
      char buffer[sizeBuffer];
      char* message;
      Header* header;
      long timeout;
      int opened;

      int event;
      long from;
};