Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Examples

LCDClient.h

00001 #ifndef _LCD_CLIENT_H_
00002 #define _LCD_CLIENT_H_
00003 
00004 #include "LCDConnection.h"
00005 #include "LCDElement.h"
00006 #include "../keys/LCDCallback.h"
00007 
00008 #include <pthread.h>
00009 #include <string>
00010 
00011 
00012 extern "C" void *mainRepliesLoop(void *);
00013 extern "C" void *handleKeyEvent(void *);
00014 
00015 struct KeyEventInfo
00016 {
00017   KeyEvent kev;
00018   LCDCallback *callback;
00019 };
00020 
00028 class LCDClient : public LCDElement
00029 {
00030  private:
00031   ::pthread_mutex_t _sendMutex;
00032   ::pthread_cond_t _gotAnswer;
00033   ::pthread_t _mainThread;
00034   LCDConnection _serverConnection;
00035   std::string _answer;
00036   std::string _currentScreen;
00037   std::string _connectionString;
00038   std::string _serverVersion;
00039   std::string _protocolVersion;
00040   int _width;
00041   int _height;
00042   int _charWidth;
00043   int _charHeight;
00044   CallbackMap _callbacks;
00045   void mainLoop();
00046 
00047  protected:
00048   void setClientOption(std::string optName, std::string value);
00049 
00050  public:
00051   friend void *mainRepliesLoop(void *param);
00059   LCDClient(const std::string &server, int port = 13666);
00060 
00065   ~LCDClient();
00066 
00074   void sendCommand(const std::string &cmd, const std::string &parameters = "");
00075 
00076   virtual void notifyCreated() {};
00077   virtual void notifyDestroyed() {};
00078 
00085   const std::string &getServerVersion() const {return _serverVersion;}
00086 
00093   const std::string &getProtocolVersion() const {return _protocolVersion;}
00094 
00101   int getWidth() const {return _width;}
00102 
00109   int getHeight() const {return _height;}
00110 
00117   int getCharWidth() const {return _charWidth;}
00118 
00125   int getCharHeight() const {return _charHeight;}
00126 
00133   void setName(std::string name);
00134 
00135   /*
00136    * \brief Enable or disable heart beat.
00137    *
00138    * Enable or disable the heart beat used by LCDproc to show data transmission.
00139    * This value will override the ones from screens.
00140    * @param heartbeat A string with the value to set. Constants \ref LCD_HEARTBEAT_ON, \ref LCD_HEARTBEAT_OFF and \ref LCD_HEARTBEAT_OPEN can be used.
00141    */
00142   // void setHeartBeat(std::string heartbeat);
00143 
00150   void setBackLight(std::string backlight);
00151 
00159   void assignKey(KeyEvent key, LCDCallback *callback);
00160 };
00161 
00162 #endif

Generated on Wed Aug 4 19:39:09 2004 for LCDApi by doxygen 1.3.6