Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

krfbconnection.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 
00003 #ifndef KRFBCONNECTION_H
00004 #define KRFBCONNECTION_H
00005 
00006 #include <qobject.h>
00007 #include <qstring.h>
00008 #include <qcstring.h>
00009 #include "krfbserver.h"
00010 #include <qurl.h>
00011 
00012 class KRFBLogin;
00013 class KRBUpdateHandler;
00014 class KRFBServer;
00015 class QSocket;
00016 class KRFBDecoder;
00017 class KRFBBuffer;
00018 class QTimer;
00019 
00024 class KRFBConnection : public QObject
00025 {
00026   Q_OBJECT
00027 
00028 public:
00029   friend class KRFBLogin;
00030   friend class KRFBDecoder;
00031 
00032   //* The state of the connection.
00033   enum State {
00034     Connecting,
00035     LoggingIn,
00036     Connected,
00037     Disconnecting,
00038     Disconnected,
00039     Error
00040   };
00041 
00042   KRFBConnection( QObject *parent = 0 );
00043   ~KRFBConnection();
00044 
00045   //* Get the state of a connection.
00046   State state() const;
00047 
00048   //* Get the options for this connection
00049   KRFBServer *options() const { return options_; };
00050 
00051   KRFBBuffer *buffer() const { return buffer_; };
00052 
00053   KRFBDecoder *decoder() const { return decoder_; };
00054 
00055   //* Set the base from which the port for a given display will be calculated.
00056   void setPortBase( int base );
00057 
00058   //* Get the base from which the port for a given display is calculated.
00059   int portBase() const;
00060 
00061   //* Open a connection
00062   void connectTo( KRFBServer);
00063 
00064   //* Close the connection
00065   void disconnect();
00066 
00067   //* Get the host
00068   const QCString host() const { return options_->hostname.latin1(); };
00069 
00070   //* Get the display
00071   int display() const { return options_->display; };
00072 
00073   //* Get the current host/display as a URL
00074   const QUrl &url();
00075 
00076   //* Reload the display
00077   void refresh();
00078 
00079   //* Send text to the remote clipboard
00080   void sendCutText( const QString & );
00081 
00082 protected slots:
00083   //* When the shit hits the fan
00084   void gotSocketError( int );
00085 
00086   //* When we have an open socket
00087   void gotSocketConnection();
00088 
00089   //* When we have logged in
00090   void gotRFBConnection();
00091 
00092   //* When some more data arrived
00093   void gotMoreData();
00094 
00095   void updateTimer();
00096 
00097   void disconnectDone();
00098 
00099 signals:
00100   //* Emitted when the status of the connection changes.
00101   void statusChanged( const QString & );
00102 
00108   void passwordRequired( KRFBConnection * );
00109 
00110   //* When we have a working RFB connection
00111   void connected();
00112 
00113   void loggedIn();
00114 
00115   void disconnected();
00116 
00117   //* What happened?
00118   void error( const QString &msg );
00119 
00120   //* Emitted in response to a waitForData() call.
00121   void gotEnoughData();
00122 
00123 private:
00124   //
00125   // The following are called by our friends.
00126   //
00127 
00128   void waitForData( unsigned int );
00129 
00130   int read( void *buf, int sz );
00131   int write( void *buf, int sz );
00132 
00133 private:
00134   int portBase_;
00135   QSocket *sock;
00136   State currentState_;
00137   unsigned int minData_;
00138   QTimer *updater;
00139   KRFBLogin *login;
00140   KRFBDecoder *decoder_;
00141   KRFBServer *options_;
00142   KRFBBuffer *buffer_;
00143   QUrl url_;
00144 };
00145 
00146 #endif // KRFBCONNECTION_H
00147 

Generated on Sat Nov 5 16:17:16 2005 for OPIE by  doxygen 1.4.2