summaryrefslogtreecommitdiff
path: root/noncore/comm/keypebble/krfbconnection.cpp
Unidiff
Diffstat (limited to 'noncore/comm/keypebble/krfbconnection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/krfbconnection.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/noncore/comm/keypebble/krfbconnection.cpp b/noncore/comm/keypebble/krfbconnection.cpp
index b447046..33e0563 100644
--- a/noncore/comm/keypebble/krfbconnection.cpp
+++ b/noncore/comm/keypebble/krfbconnection.cpp
@@ -1,16 +1,23 @@
1#include <assert.h>
2#include <qsocket.h>
3#include <qtimer.h>
4#include <string.h>
5
6#include "krfbconnection.h" 1#include "krfbconnection.h"
7#include "krfblogin.h" 2#include "krfblogin.h"
8#include "krfbdecoder.h" 3#include "krfbdecoder.h"
9#include "krfbbuffer.h" 4#include "krfbbuffer.h"
10 5
6/* OPIE */
7#include <opie2/odebug.h>
8using namespace Opie::Core;
9
10/* QT */
11#include <qsocket.h>
12#include <qtimer.h>
13
14/* STD */
15#include <assert.h>
16#include <string.h>
17
11KRFBConnection::KRFBConnection( QObject *parent ) 18KRFBConnection::KRFBConnection( QObject *parent )
12 : QObject( parent, "KRFBConnection" ) 19 : QObject( parent, "KRFBConnection" )
13{ 20{
14 portBase_ = 5900; 21 portBase_ = 5900;
15 currentState_ = Disconnected; 22 currentState_ = Disconnected;
16 sock = 0; 23 sock = 0;
@@ -40,21 +47,21 @@ void KRFBConnection::connectTo( KRFBServer server)
40 CHECK_PTR( sock ); 47 CHECK_PTR( sock );
41 48
42 // Connect to something to notice connection or error 49 // Connect to something to notice connection or error
43 connect( sock, SIGNAL( error(int) ), SLOT( gotSocketError(int) ) ); 50 connect( sock, SIGNAL( error(int) ), SLOT( gotSocketError(int) ) );
44 connect( sock, SIGNAL( connected() ), SLOT( gotSocketConnection() ) ); 51 connect( sock, SIGNAL( connected() ), SLOT( gotSocketConnection() ) );
45 52
46 qWarning( "Connecting..." ); 53 owarn << "Connecting..." << oendl;
47 54
48 currentState_ = Connecting; 55 currentState_ = Connecting;
49 sock->connectToHost( options_->hostname.latin1(), portBase_ + options_->display ); 56 sock->connectToHost( options_->hostname.latin1(), portBase_ + options_->display );
50} 57}
51 58
52void KRFBConnection::disconnect() 59void KRFBConnection::disconnect()
53{ 60{
54 qWarning( "Disconnecting from server" ); 61 owarn << "Disconnecting from server" << oendl;
55 62
56 if ( ( currentState_ != Disconnected ) 63 if ( ( currentState_ != Disconnected )
57 && ( currentState_ != Disconnecting ) 64 && ( currentState_ != Disconnecting )
58 && sock ) { 65 && sock ) {
59 currentState_ = Disconnecting; 66 currentState_ = Disconnecting;
60 67
@@ -79,24 +86,24 @@ void KRFBConnection::disconnectDone()
79} 86}
80 87
81void KRFBConnection::gotSocketConnection() 88void KRFBConnection::gotSocketConnection()
82{ 89{
83 currentState_ = LoggingIn; 90 currentState_ = LoggingIn;
84 91
85 qWarning( "Connected, logging in..." ); 92 owarn << "Connected, logging in..." << oendl;
86 93
87 static QString statusMsg = tr( "Connected" ); 94 static QString statusMsg = tr( "Connected" );
88 emit statusChanged( statusMsg ); 95 emit statusChanged( statusMsg );
89 96
90 // Do some login stuff 97 // Do some login stuff
91 login = new KRFBLogin( this ); 98 login = new KRFBLogin( this );
92} 99}
93 100
94void KRFBConnection::gotRFBConnection() 101void KRFBConnection::gotRFBConnection()
95{ 102{
96 qWarning( "Logged into server" ); 103 owarn << "Logged into server" << oendl;
97 104
98 currentState_ = Connected; 105 currentState_ = Connected;
99 emit connected(); 106 emit connected();
100 107
101 // Create the decoder and start doing stuff 108 // Create the decoder and start doing stuff
102 decoder_ = new KRFBDecoder( this ); 109 decoder_ = new KRFBDecoder( this );
@@ -119,13 +126,13 @@ void KRFBConnection::gotRFBConnection()
119 126
120void KRFBConnection::gotSocketError( int err ) 127void KRFBConnection::gotSocketError( int err )
121{ 128{
122 currentState_ = Error; 129 currentState_ = Error;
123 130
124 // Do some error handling stuff 131 // Do some error handling stuff
125 qWarning( "KRFBConnection: Socket error %d", err ); 132 owarn << "KRFBConnection: Socket error " << err << "" << oendl;
126 133
127 static QString refused = tr( "Connection Refused" ); 134 static QString refused = tr( "Connection Refused" );
128 static QString host = tr( "Host not found" ); 135 static QString host = tr( "Host not found" );
129 static QString read = tr( "Read Error: QSocket reported an error reading\n" 136 static QString read = tr( "Read Error: QSocket reported an error reading\n"
130 "data, the remote host has probably dropped the\n" 137 "data, the remote host has probably dropped the\n"
131 "connection." ); 138 "connection." );
@@ -169,17 +176,17 @@ void KRFBConnection::waitForData( unsigned int sz )
169{ 176{
170 assert( minData_ == 0 ); 177 assert( minData_ == 0 );
171 assert( sz > 0 ); 178 assert( sz > 0 );
172 assert( currentState_ != Error ); 179 assert( currentState_ != Error );
173 180
174 if ( sock->size() >= sz ) { 181 if ( sock->size() >= sz ) {
175 // qWarning( "No need to wait for data" ); 182 // owarn << "No need to wait for data" << oendl;
176 emit gotEnoughData(); 183 emit gotEnoughData();
177 } 184 }
178 else { 185 else {
179 // qWarning( "Waiting for %u bytes", sz ); 186 // owarn << "Waiting for " << sz << " bytes" << oendl;
180 minData_ = sz; 187 minData_ = sz;
181 connect( sock, SIGNAL( readyRead() ), SLOT( gotMoreData() ) ); 188 connect( sock, SIGNAL( readyRead() ), SLOT( gotMoreData() ) );
182 } 189 }
183} 190}
184 191
185int KRFBConnection::read( void *buf, int sz ) 192int KRFBConnection::read( void *buf, int sz )