362c1f4c3b5ce9e3fce11167a51fbe4cdb2174de
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h   1) /* Blinker
Stefan Schuermans update copyright header

Stefan Schuermans authored 5 years ago

src/common/Phone.h   2)    Copyright 2011-2019 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h   3)    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
src/noarch/Phone.h   4)    a blinkenarea.org project */
src/noarch/Phone.h   5) 
src/noarch/Phone.h   6) #ifndef BLINKER_PHONE_H
src/noarch/Phone.h   7) #define BLINKER_PHONE_H
src/noarch/Phone.h   8) 
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h   9) #include <map>
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  10) #include <string>
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  11) #include <vector>
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  12) 
src/noarch/Phone.h  13) #include "Directory.h"
src/noarch/Phone.h  14) #include "File.h"
src/noarch/Phone.h  15) #include "IoCallee.h"
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  16) #include "ListTracker.h"
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  17) #include "Mgrs.h"
src/noarch/Phone.h  18) #include "Module.h"
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  19) #include "OpConn.h"
src/noarch/Phone.h  20) #include "OpConnIf.h"
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  21) #include "SettingFile.h"
src/noarch/Phone.h  22) #include "Time.h"
src/noarch/Phone.h  23) #include "TimeCallee.h"
src/noarch/Phone.h  24) 
src/noarch/Phone.h  25) namespace Blinker {
src/noarch/Phone.h  26) 
src/noarch/Phone.h  27) /// phone connector (using EBIP)
src/noarch/Phone.h  28) template<typename ADDR, typename SOCK>
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  29) class Phone: public IoCallee, public Module, public OpConnIf, public TimeCallee
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  30) {
src/noarch/Phone.h  31) protected:
src/noarch/Phone.h  32)   /// type for address setting file
src/noarch/Phone.h  33)   typedef SettingFile<ADDR> AddrFile;
src/noarch/Phone.h  34) 
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  35)   /// extension to be called
src/noarch/Phone.h  36)   class Extension;
src/noarch/Phone.h  37) 
src/noarch/Phone.h  38)   /// extension list tracker
src/noarch/Phone.h  39)   typedef ListTracker<Phone, Extension, Directory> ExtListTracker;
src/noarch/Phone.h  40) 
Stefan Schuermans whitespace fix

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  41)   /// map of extensions to call (extension name -> module name)
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  42)   typedef std::map<std::string, std::string> ExtMap;
src/noarch/Phone.h  43) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  44)   /// map from line number to connection
src/noarch/Phone.h  45)   typedef std::map<unsigned int, OpConn *> LineConnMap;
src/noarch/Phone.h  46) 
src/noarch/Phone.h  47)   /// map from connection to line number
src/noarch/Phone.h  48)   typedef std::map<OpConn *, unsigned int> ConnLineMap;
src/noarch/Phone.h  49) 
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  50)   /// type for command buffer (command sent before line connected)
src/noarch/Phone.h  51)   typedef std::vector<std::string> CmdBuf;
src/noarch/Phone.h  52) 
src/noarch/Phone.h  53)   /// type for command buffer map (line to command buffer)
src/noarch/Phone.h  54)   typedef std::map<unsigned int, CmdBuf> CmdBufMap;
src/noarch/Phone.h  55) 
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  56) public:
src/noarch/Phone.h  57)   /**
src/noarch/Phone.h  58)    * @brief constructor
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  59)    * @param[in] name module name
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  60)    * @param[in] mgrs managers
src/noarch/Phone.h  61)    * @param[in] dirBase base directory
src/noarch/Phone.h  62)    */
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  63)   Phone(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  64) 
src/noarch/Phone.h  65)   /// virtual destructor
src/noarch/Phone.h  66)   virtual ~Phone();
src/noarch/Phone.h  67) 
src/noarch/Phone.h  68) private:
src/noarch/Phone.h  69)   /// copy constructor disabled
src/noarch/Phone.h  70)   Phone(const Phone &that);
src/noarch/Phone.h  71) 
src/noarch/Phone.h  72)   /// assignment operator disabled
src/noarch/Phone.h  73)   const Phone & operator=(const Phone &that);
src/noarch/Phone.h  74) 
src/noarch/Phone.h  75) public:
src/noarch/Phone.h  76)   /// check for update of configuration
src/noarch/Phone.h  77)   virtual void updateConfig();
src/noarch/Phone.h  78) 
src/noarch/Phone.h  79)   /// callback when requested time reached
src/noarch/Phone.h  80)   virtual void timeCall();
src/noarch/Phone.h  81) 
src/noarch/Phone.h  82)   /**
src/noarch/Phone.h  83)    * @brief callback when I/O object is readable
src/noarch/Phone.h  84)    * @param[in] io I/O object that is readable
src/noarch/Phone.h  85)    */
src/noarch/Phone.h  86)   virtual void ioReadCall(Io *io);
src/noarch/Phone.h  87) 
src/noarch/Phone.h  88)   /**
src/noarch/Phone.h  89)    * @brief callback when I/O object is writable
src/noarch/Phone.h  90)    * @param[in] io I/O object that is writable
src/noarch/Phone.h  91)    */
src/noarch/Phone.h  92)   virtual void ioWriteCall(Io *io);
src/noarch/Phone.h  93) 
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h  94)   /**
src/noarch/Phone.h  95)    * @brief key command received on operator connection
src/noarch/Phone.h  96)    * @param[in] pConn operator connection object
src/noarch/Phone.h  97)    * @param[in] key key that was pressed
src/noarch/Phone.h  98)    */
src/noarch/Phone.h  99)   virtual void opConnRecvKey(OpConn *pConn, char key);
src/noarch/Phone.h 100) 
src/noarch/Phone.h 101)   /**
src/noarch/Phone.h 102)    * @brief play command received on operator connection
src/noarch/Phone.h 103)    * @param[in] pConn operator connection object
src/noarch/Phone.h 104)    * @param[in] sound name of sound to play
src/noarch/Phone.h 105)    */
src/noarch/Phone.h 106)   virtual void opConnRecvPlay(OpConn *pConn, const std::string &sound);
src/noarch/Phone.h 107) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 108)   /**
src/noarch/Phone.h 109)    * @brief operator connection is closed
src/noarch/Phone.h 110)    * @param[in] pConn operator connection object
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 111)    *
src/noarch/Phone.h 112)    * The connection may not be used for sending any more in this callback.
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 113)    */
src/noarch/Phone.h 114)   virtual void opConnClose(OpConn *pConn);
src/noarch/Phone.h 115) 
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 116) protected:
src/noarch/Phone.h 117)   /// (re-)read server address
src/noarch/Phone.h 118)   void readServer();
src/noarch/Phone.h 119) 
src/noarch/Phone.h 120)   /// create socket and bind it
src/noarch/Phone.h 121)   void createSock();
src/noarch/Phone.h 122) 
src/noarch/Phone.h 123)   /// destroy socket
src/noarch/Phone.h 124)   void destroySock();
src/noarch/Phone.h 125) 
src/noarch/Phone.h 126)   /// register with server
src/noarch/Phone.h 127)   void sendRegister();
src/noarch/Phone.h 128) 
src/noarch/Phone.h 129)   /// send heartbeat to server
src/noarch/Phone.h 130)   void sendHeartbeat();
src/noarch/Phone.h 131) 
Stefan Schuermans accepting EBIP calls works now

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 132)   /**
src/noarch/Phone.h 133)    * @brief send accept message
src/noarch/Phone.h 134)    * @param[in] line number of line accept on
src/noarch/Phone.h 135)    */
src/noarch/Phone.h 136)   void sendAccept(unsigned int line);
src/noarch/Phone.h 137) 
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 138)   /**
src/noarch/Phone.h 139)    * @brief send play message
src/noarch/Phone.h 140)    * @param[in] line number of line to request play on
src/noarch/Phone.h 141)    * @param[in] sound name of sound to request
src/noarch/Phone.h 142)    */
src/noarch/Phone.h 143)   void sendPlay(unsigned int line, const std::string &sound);
src/noarch/Phone.h 144) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 145)   /**
src/noarch/Phone.h 146)    * @brief send hangup message
src/noarch/Phone.h 147)    * @param[in] line number of line to hangup
src/noarch/Phone.h 148)    */
src/noarch/Phone.h 149)   void sendHangup(unsigned int line);
src/noarch/Phone.h 150) 
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 151)   /**
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 152)    * @brief send message buffered to server
src/noarch/Phone.h 153)    * @param[in] line number of line to hangup
src/noarch/Phone.h 154)    * @param[in] msg message to send
src/noarch/Phone.h 155)    */
src/noarch/Phone.h 156)   void sendBuf(unsigned int line, const std::string &msg);
src/noarch/Phone.h 157) 
src/noarch/Phone.h 158)   /**
src/noarch/Phone.h 159)    * @brief send message to server now
src/noarch/Phone.h 160)    * @param[in] line number of line to hangup
src/noarch/Phone.h 161)    * @param[in] msg message to send
src/noarch/Phone.h 162)    */
src/noarch/Phone.h 163)   void sendNow(unsigned int line, const std::string &msg);
src/noarch/Phone.h 164) 
src/noarch/Phone.h 165)   /**
src/noarch/Phone.h 166)    * @brief send message to socket
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 167)    * @param[in] msg message to send
src/noarch/Phone.h 168)    */
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 169)   void sendSock(const std::string &msg);
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 170) 
src/noarch/Phone.h 171)   /// receive data from socket
src/noarch/Phone.h 172)   void receiveFromSock();
src/noarch/Phone.h 173) 
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 174)   /**
src/noarch/Phone.h 175)    * @brief process message from server
src/noarch/Phone.h 176)    * @param[in] msg message from server
src/noarch/Phone.h 177)    */
src/noarch/Phone.h 178)   void serverMsg(const std::string &msg);
src/noarch/Phone.h 179) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 180)   /**
src/noarch/Phone.h 181)    * @brief process incoming call
src/noarch/Phone.h 182)    * @param[in] line number of phone line
src/noarch/Phone.h 183)    * @param[in] extension extenstion called (i.e. phone number)
src/noarch/Phone.h 184)    */
src/noarch/Phone.h 185)   void incomingCall(unsigned int line, const std::string &extension);
src/noarch/Phone.h 186) 
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 187)   /**
src/noarch/Phone.h 188)    * @brief phone line connected
src/noarch/Phone.h 189)    * @param[in] line number of phone line
src/noarch/Phone.h 190)    */
src/noarch/Phone.h 191)   void connected(unsigned int line);
src/noarch/Phone.h 192) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 193)   /**
src/noarch/Phone.h 194)    * @brief hangup on phone line
src/noarch/Phone.h 195)    * @param[in] line number of phone line
src/noarch/Phone.h 196)    */
src/noarch/Phone.h 197)   void hangup(unsigned int line);
src/noarch/Phone.h 198) 
src/noarch/Phone.h 199)   /**
src/noarch/Phone.h 200)    * @brief key pressed on phone line
src/noarch/Phone.h 201)    * @param[in] line number of phone line
src/noarch/Phone.h 202)    * @param[in] key key that has been pressed
src/noarch/Phone.h 203)    */
src/noarch/Phone.h 204)   void keyPressed(unsigned int line, char key);
src/noarch/Phone.h 205) 
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 206)   /**
src/noarch/Phone.h 207)    * @brief get phone line number from operator connection
src/noarch/Phone.h 208)    * @param[in] pConn operator connection object
src/noarch/Phone.h 209)    * @param[out] line phone line number
src/noarch/Phone.h 210)    * @return if phone line was found
src/noarch/Phone.h 211)    */
src/noarch/Phone.h 212)   bool conn2line(OpConn *pConn, unsigned int &line) const;
src/noarch/Phone.h 213) 
src/noarch/Phone.h 214)   /**
src/noarch/Phone.h 215)    * @brief get operator connection from phone line number
src/noarch/Phone.h 216)    * @param[in] line phone line number
src/noarch/Phone.h 217)    * @param[out] pConn operator connection object
src/noarch/Phone.h 218)    * @return if phone line was found
src/noarch/Phone.h 219)    */
src/noarch/Phone.h 220)   bool line2conn(unsigned int line, OpConn *&pConn) const;
src/noarch/Phone.h 221) 
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 222)   /// update time callback
src/noarch/Phone.h 223)   void updateTimeCallback();
src/noarch/Phone.h 224) 
src/noarch/Phone.h 225) protected:
src/noarch/Phone.h 226)   static const Time m_serverTimeout;
src/noarch/Phone.h 227)   static const Time m_heartbeatInterval;
src/noarch/Phone.h 228) 
src/noarch/Phone.h 229) protected:
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 230)   AddrFile       m_fileBind;       ///< bind address file
src/noarch/Phone.h 231)   AddrFile       m_fileServer;     ///< server address file
src/noarch/Phone.h 232)   ExtListTracker m_extListTracker; ///< extension tracker
src/noarch/Phone.h 233)   SOCK           *m_pSock;         ///< socket to use for sending messages
src/noarch/Phone.h 234)   Time           m_timeRegister;   ///< time to re-register
src/noarch/Phone.h 235)   Time           m_timeHeartbeat;  ///< time to send next heartbeat
src/noarch/Phone.h 236)   ExtMap         m_extMap;         ///< map of extensions to call
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 237)   LineConnMap    m_lineConnMap;    ///< map from line number to connection
src/noarch/Phone.h 238)   ConnLineMap    m_connLineMap;    ///< map from connection to line number
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone.h 239)   CmdBufMap      m_cmdBufMap;      ///< commands to send after line connected