00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KSG_SENSORAGENT_H
00022 #define KSG_SENSORAGENT_H
00023
00024 #include <tqobject.h>
00025 #include <tqptrlist.h>
00026
00027 class KProcess;
00028 class KShellProcess;
00029
00030 class TQString;
00031
00032 namespace KSGRD {
00033
00034 class SensorClient;
00035 class SensorManager;
00036 class SensorRequest;
00037
00046 class KDE_EXPORT SensorAgent : public QObject
00047 {
00048 Q_OBJECT
00049
00050 public:
00051 SensorAgent( SensorManager *sm );
00052 virtual ~SensorAgent();
00053
00054 virtual bool start( const TQString &host, const TQString &shell,
00055 const TQString &command = "", int port = -1 ) = 0;
00056
00069 bool sendRequest( const TQString &req, SensorClient *client, int id = 0 );
00070
00071 virtual void hostInfo( TQString &sh, TQString &cmd, int &port ) const = 0;
00072
00073 void disconnectClient( SensorClient *client );
00074
00075 const TQString &hostName() const;
00076
00077 signals:
00078 void reconfigure( const SensorAgent* );
00079
00080 protected:
00081 void processAnswer( const TQString &buffer );
00082 void executeCommand();
00083
00084 SensorManager *sensorManager();
00085
00086 void setDaemonOnLine( bool value );
00087 bool daemonOnLine() const;
00088
00089 void setTransmitting( bool value );
00090 bool transmitting() const;
00091
00092 void setHostName( const TQString &hostName );
00093
00094 private:
00095 virtual bool writeMsg( const char *msg, int len ) = 0;
00096 virtual bool txReady() = 0;
00097
00098 int mState;
00099 TQPtrList<SensorRequest> mInputFIFO;
00100 TQPtrList<SensorRequest> mProcessingFIFO;
00101 TQString mAnswerBuffer;
00102 TQString mErrorBuffer;
00103
00104 SensorManager *mSensorManager;
00105
00106 bool mDaemonOnLine;
00107 bool mTransmitting;
00108 TQString mHostName;
00109 };
00110
00114 class SensorRequest
00115 {
00116 public:
00117 SensorRequest( const TQString &request, SensorClient *client, int id );
00118 ~SensorRequest();
00119
00120 void setRequest( const TQString& );
00121 TQString request() const;
00122
00123 void setClient( SensorClient* );
00124 SensorClient *client();
00125
00126 void setId( int );
00127 int id();
00128
00129 private:
00130 TQString mRequest;
00131 SensorClient *mClient;
00132 int mId;
00133 };
00134
00135 }
00136
00137 #endif