summaryrefslogtreecommitdiff
path: root/noncore/comm/keypebble/krfbconnection.h
Unidiff
Diffstat (limited to 'noncore/comm/keypebble/krfbconnection.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/krfbconnection.h152
1 files changed, 152 insertions, 0 deletions
diff --git a/noncore/comm/keypebble/krfbconnection.h b/noncore/comm/keypebble/krfbconnection.h
new file mode 100644
index 0000000..fe477c1
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbconnection.h
@@ -0,0 +1,152 @@
1// -*- c++ -*-
2
3#ifndef KRFBCONNECTION_H
4#define KRFBCONNECTION_H
5
6#include <qobject.h>
7#include <qstring.h>
8#include <qcstring.h>
9#include <qurl.h>
10
11class KRFBLogin;
12class KRBUpdateHandler;
13class KRFBOptions;
14class QSocket;
15class KRFBDecoder;
16class KRFBBuffer;
17class QTimer;
18
19/**
20 * Encapsulates the RFB socket.
21 *
22 */
23class KRFBConnection : public QObject
24{
25 Q_OBJECT
26
27public:
28 friend class KRFBLogin;
29 friend class KRFBDecoder;
30
31 //* The state of the connection.
32 enum State {
33 Connecting,
34 LoggingIn,
35 Connected,
36 Disconnecting,
37 Disconnected,
38 Error
39 };
40
41 KRFBConnection( QObject *parent = 0 );
42 ~KRFBConnection();
43
44 //* Get the state of a connection.
45 State state() const;
46
47 //* Get the options for this connection
48 KRFBOptions *options() const { return options_; };
49
50 KRFBBuffer *buffer() const { return buffer_; };
51
52 KRFBDecoder *decoder() const { return decoder_; };
53
54 //* Set the base from which the port for a given display will be calculated.
55 void setPortBase( int base );
56
57 //* Get the base from which the port for a given display is calculated.
58 int portBase() const;
59
60 //* Set the password which will be used to login
61 void setPassword( const QCString &pass );
62
63 //* Open a connection
64 void connectTo( const QCString &host, int display );
65
66 //* Close the connection
67 void disconnect();
68
69 //* Get the host
70 const QCString host() const { return host_; };
71
72 //* Get the display
73 int display() const { return display_; };
74
75 //* Get the current host/display as a URL
76 const QUrl &url();
77
78 //* Reload the display
79 void refresh();
80
81 //* Send text to the remote clipboard
82 void sendCutText( const QString & );
83
84protected slots:
85 //* When the shit hits the fan
86 void gotSocketError( int );
87
88 //* When we have an open socket
89 void gotSocketConnection();
90
91 //* When we have logged in
92 void gotRFBConnection();
93
94 //* When some more data arrived
95 void gotMoreData();
96
97 void updateTimer();
98
99 void disconnectDone();
100
101signals:
102 //* Emitted when the status of the connection changes.
103 void statusChanged( const QString & );
104
105 /**
106 * Emitted when we *really* need a password. If the password
107 * was specified before you tried to connect then you won't
108 * see this.
109 */
110 void passwordRequired( KRFBConnection * );
111
112 //* When we have a working RFB connection
113 void connected();
114
115 void loggedIn();
116
117 void disconnected();
118
119 //* What happened?
120 void error( const QString &msg );
121
122 //* Emitted in response to a waitForData() call.
123 void gotEnoughData();
124
125private:
126 //
127 // The following are called by our friends.
128 //
129
130 void waitForData( unsigned int );
131
132 int read( void *buf, int sz );
133 int write( void *buf, int sz );
134
135private:
136 QCString host_;
137 int portBase_;
138 int display_;
139 QCString pass_;
140 QSocket *sock;
141 State currentState_;
142 unsigned int minData_;
143 QTimer *updater;
144 KRFBLogin *login;
145 KRFBDecoder *decoder_;
146 KRFBOptions *options_;
147 KRFBBuffer *buffer_;
148 QUrl url_;
149};
150
151#endif // KRFBCONNECTION_H
152