summaryrefslogtreecommitdiff
path: root/noncore/comm
Unidiff
Diffstat (limited to 'noncore/comm') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/config.in2
-rw-r--r--noncore/comm/keypebble/keypebble.pro9
-rw-r--r--noncore/comm/keypebble/krfbbuffer.cpp24
-rw-r--r--noncore/comm/keypebble/krfbcanvas.cpp8
-rw-r--r--noncore/comm/keypebble/krfbconnection.cpp31
-rw-r--r--noncore/comm/keypebble/krfbdecoder.cpp63
-rw-r--r--noncore/comm/keypebble/krfblogin.cpp41
-rw-r--r--noncore/comm/keypebble/kvncbookmarkdlg.cpp12
8 files changed, 112 insertions, 78 deletions
diff --git a/noncore/comm/keypebble/config.in b/noncore/comm/keypebble/config.in
index 20384aa..8a800b9 100644
--- a/noncore/comm/keypebble/config.in
+++ b/noncore/comm/keypebble/config.in
@@ -1,4 +1,4 @@
1 config KEYPEBBLE 1 config KEYPEBBLE
2 boolean "opie-keypebble (Virtual Network Computing VNC viewer)" 2 boolean "opie-keypebble (Virtual Network Computing VNC viewer)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
diff --git a/noncore/comm/keypebble/keypebble.pro b/noncore/comm/keypebble/keypebble.pro
index 3515016..7631e4e 100644
--- a/noncore/comm/keypebble/keypebble.pro
+++ b/noncore/comm/keypebble/keypebble.pro
@@ -1,35 +1,34 @@
1CONFIG += qt warn_on quick-app 1CONFIG += qt warn_on quick-app
2 HEADERS = d3des.h \ 2 HEADERS = d3des.h \
3 krfbbuffer.h \ 3 krfbbuffer.h \
4 krfbcanvas.h \ 4 krfbcanvas.h \
5 krfbconnection.h \ 5 krfbconnection.h \
6 krfbdecoder.h \ 6 krfbdecoder.h \
7 krfblogin.h \ 7 krfblogin.h \
8 krfbserver.h \ 8 krfbserver.h \
9 krfbserverinfo.h \ 9 krfbserverinfo.h \
10 kvnc.h \ 10 kvnc.h \
11 kvncconndlg.h \ 11 kvncconndlg.h \
12 kvncbookmarkdlg.h \ 12 kvncbookmarkdlg.h \
13 vncauth.h 13 vncauth.h
14 SOURCES = d3des.c \ 14 SOURCES = d3des.c \
15 vncauth.c \ 15 vncauth.c \
16 krfbbuffer.cpp \ 16 krfbbuffer.cpp \
17 krfbcanvas.cpp \ 17 krfbcanvas.cpp \
18 krfbconnection.cpp \ 18 krfbconnection.cpp \
19 krfbdecoder.cpp \ 19 krfbdecoder.cpp \
20 krfblogin.cpp \ 20 krfblogin.cpp \
21 krfbserver.cpp \ 21 krfbserver.cpp \
22 kvnc.cpp \ 22 kvnc.cpp \
23 kvncconndlg.cpp \ 23 kvncconndlg.cpp \
24 kvncbookmarkdlg.cpp \ 24 kvncbookmarkdlg.cpp \
25 main.cpp 25 main.cpp
26 INTERFACES= kvncconndlgbase.ui \ 26 INTERFACES= kvncconndlgbase.ui kvncbookmarkdlgbase.ui
27 kvncbookmarkdlgbase.ui
28 27
29INCLUDEPATH += $(OPIEDIR)/include 28INCLUDEPATH += $(OPIEDIR)/include
30DEPENDPATH += $(OPIEDIR)/include 29DEPENDPATH += $(OPIEDIR)/include
31LIBS += -lqpe 30LIBS += -lqpe -lopiecore2
32 31
33 TARGET = keypebble 32 TARGET = keypebble
34 33
35include ( $(OPIEDIR)/include.pro ) 34include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/comm/keypebble/krfbbuffer.cpp b/noncore/comm/keypebble/krfbbuffer.cpp
index 4cec0c2..4b29612 100644
--- a/noncore/comm/keypebble/krfbbuffer.cpp
+++ b/noncore/comm/keypebble/krfbbuffer.cpp
@@ -1,25 +1,33 @@
1#include <assert.h>
2#include <qimage.h>
3#include <qpainter.h>
4#include <qapplication.h>
5#include "krfbdecoder.h" 1#include "krfbdecoder.h"
6#include "krfbbuffer.h" 2#include "krfbbuffer.h"
7#include "krfbconnection.h" 3#include "krfbconnection.h"
8#include "krfbserverinfo.h" 4#include "krfbserverinfo.h"
9 5
6/* OPIE */
7#include <opie2/odebug.h>
8using namespace Opie::Core;
9
10/* QT */
11#include <qimage.h>
12#include <qpainter.h>
13#include <qapplication.h>
14
15/* STD */
16#include <assert.h>
17
10// 18//
11// Endian stuff 19// Endian stuff
12// 20//
13#ifndef KDE_USE_FINAL 21#ifndef OPIE_NO_DEBUG
14const int endianTest = 1; 22const int endianTest = 1;
15#endif 23#endif
16 24
17#define Swap16IfLE(s) \ 25#define Swap16IfLE(s) \
18 (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) 26 (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
19 27
20#define Swap32IfLE(l) \ 28#define Swap32IfLE(l) \
21 (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ 29 (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \
22 (((l) & 0x00ff0000) >> 8) | \ 30 (((l) & 0x00ff0000) >> 8) | \
23 (((l) & 0x0000ff00) << 8) | \ 31 (((l) & 0x0000ff00) << 8) | \
24 (((l) & 0x000000ff) << 24)) : (l)) 32 (((l) & 0x000000ff) << 24)) : (l))
25 33
@@ -30,60 +38,60 @@ KRFBBuffer::KRFBBuffer( KRFBDecoder *decoder,
30 assert( decoder ); 38 assert( decoder );
31 this->decoder = decoder; 39 this->decoder = decoder;
32 pix = new QPixmap(); 40 pix = new QPixmap();
33} 41}
34 42
35KRFBBuffer::~KRFBBuffer() 43KRFBBuffer::~KRFBBuffer()
36{ 44{
37 delete pix; 45 delete pix;
38} 46}
39 47
40void KRFBBuffer::resize( int w, int h ) 48void KRFBBuffer::resize( int w, int h )
41{ 49{
42 qWarning( "Resizing buffer" ); 50 owarn << "Resizing buffer" << oendl;
43 51
44 pix->resize( w, h ); 52 pix->resize( w, h );
45 53
46 QPalette pal = qApp->palette(); 54 QPalette pal = qApp->palette();
47 pix->fill( pal.active().base() ); 55 pix->fill( pal.active().base() );
48 56
49 emit sizeChanged( w, h ); 57 emit sizeChanged( w, h );
50} 58}
51 59
52void KRFBBuffer::soundBell() 60void KRFBBuffer::soundBell()
53{ 61{
54 emit bell(); 62 emit bell();
55} 63}
56 64
57void KRFBBuffer::mouseEvent( QMouseEvent *e ) 65void KRFBBuffer::mouseEvent( QMouseEvent *e )
58{ 66{
59 decoder->sendMouseEvent( e ); 67 decoder->sendMouseEvent( e );
60} 68}
61 69
62void KRFBBuffer::keyPressEvent( QKeyEvent *e ) 70void KRFBBuffer::keyPressEvent( QKeyEvent *e )
63{ 71{
64 qWarning( "Buffer got a key" ); 72 owarn << "Buffer got a key" << oendl;
65 73
66 decoder->sendKeyPressEvent( e ); 74 decoder->sendKeyPressEvent( e );
67} 75}
68 76
69void KRFBBuffer::keyReleaseEvent( QKeyEvent *e ) 77void KRFBBuffer::keyReleaseEvent( QKeyEvent *e )
70{ 78{
71 decoder->sendKeyReleaseEvent( e ); 79 decoder->sendKeyReleaseEvent( e );
72} 80}
73 81
74void KRFBBuffer::copyRect( int srcX, int srcY, 82void KRFBBuffer::copyRect( int srcX, int srcY,
75 int destX, int destY, int w, int h ) 83 int destX, int destY, int w, int h )
76{ 84{
77// qWarning( "Got copy rect" ); 85// owarn << "Got copy rect" << oendl;
78 bitBlt( pix, destX, destY, pix, srcX, srcY, w, h, CopyROP ); 86 bitBlt( pix, destX, destY, pix, srcX, srcY, w, h, CopyROP );
79 87
80 emit updated( destX, destY, w, h ); 88 emit updated( destX, destY, w, h );
81} 89}
82 90
83void KRFBBuffer::drawRawRectChunk( void *data, 91void KRFBBuffer::drawRawRectChunk( void *data,
84 int x, int y, int w, int h ) 92 int x, int y, int w, int h )
85{ 93{
86 QImage img( w, h, 32 ); 94 QImage img( w, h, 32 );
87 95
88 int scaleFactor=decoder->con->options()->scaleFactor; 96 int scaleFactor=decoder->con->options()->scaleFactor;
89 int redMax = Swap16IfLE( decoder->format->redMax ); 97 int redMax = Swap16IfLE( decoder->format->redMax );
diff --git a/noncore/comm/keypebble/krfbcanvas.cpp b/noncore/comm/keypebble/krfbcanvas.cpp
index cd1fda0..b3525df 100644
--- a/noncore/comm/keypebble/krfbcanvas.cpp
+++ b/noncore/comm/keypebble/krfbcanvas.cpp
@@ -1,18 +1,22 @@
1#include "krfbconnection.h" 1#include "krfbconnection.h"
2#include "krfbcanvas.h" 2#include "krfbcanvas.h"
3#include "krfbbuffer.h" 3#include "krfbbuffer.h"
4 4
5/* OPIE */
6#include <opie2/odebug.h>
5#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
8using namespace Opie::Core;
6 9
10/* QT */
7#include <qclipboard.h> 11#include <qclipboard.h>
8 12
9KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name ) 13KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name )
10 : QScrollView( parent, name ) 14 : QScrollView( parent, name )
11{ 15{
12 connection_ = new KRFBConnection(); 16 connection_ = new KRFBConnection();
13 connect( connection_, SIGNAL( loggedIn() ), 17 connect( connection_, SIGNAL( loggedIn() ),
14 this, SLOT( loggedIn() ) ); 18 this, SLOT( loggedIn() ) );
15 19
16 loggedIn_ = false; 20 loggedIn_ = false;
17 21
18 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold); 22 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold);
@@ -33,25 +37,25 @@ void KRFBCanvas::openConnection(KRFBServer server)
33{ 37{
34 38
35 39
36 QCString host = server.hostname.latin1(); 40 QCString host = server.hostname.latin1();
37 password=server.password; 41 password=server.password;
38 connection_->connectTo( server); 42 connection_->connectTo( server);
39} 43}
40 44
41 45
42void KRFBCanvas::openURL( const QUrl &url ) 46void KRFBCanvas::openURL( const QUrl &url )
43{ 47{
44 if ( loggedIn_ ) { 48 if ( loggedIn_ ) {
45 qWarning( "openURL invoked when logged in\n" ); 49 owarn << "openURL invoked when logged in\n" << oendl;
46 return; 50 return;
47 } 51 }
48 52
49 QCString host = url.host().latin1(); 53 QCString host = url.host().latin1();
50 int display = url.port(); 54 int display = url.port();
51 55
52// connection_->connectTo( host, display ); 56// connection_->connectTo( host, display );
53} 57}
54 58
55void KRFBCanvas::closeConnection() 59void KRFBCanvas::closeConnection()
56{ 60{
57 loggedIn_ = false; 61 loggedIn_ = false;
@@ -65,25 +69,25 @@ void KRFBCanvas::closeConnection()
65 69
66 70
67void KRFBCanvas::bell() 71void KRFBCanvas::bell()
68{ 72{
69 if ( connection_->options()->deIconify ) { 73 if ( connection_->options()->deIconify ) {
70 topLevelWidget()->raise(); 74 topLevelWidget()->raise();
71 topLevelWidget()->show(); 75 topLevelWidget()->show();
72 } 76 }
73} 77}
74 78
75void KRFBCanvas::loggedIn() 79void KRFBCanvas::loggedIn()
76{ 80{
77 qWarning( "Ok, we're logged in" ); 81 owarn << "Ok, we're logged in" << oendl;
78 82
79 // 83 //
80 // Get ready for action 84 // Get ready for action
81 // 85 //
82 loggedIn_ = true; 86 loggedIn_ = true;
83 viewport()->setMouseTracking( true ); 87 viewport()->setMouseTracking( true );
84 viewport()->setBackgroundMode( NoBackground ); 88 viewport()->setBackgroundMode( NoBackground );
85 setBackgroundMode( NoBackground ); 89 setBackgroundMode( NoBackground );
86 90
87 // Start using the buffer 91 // Start using the buffer
88 connect( connection_->buffer(), SIGNAL( sizeChanged(int,int) ), 92 connect( connection_->buffer(), SIGNAL( sizeChanged(int,int) ),
89 this, SLOT( resizeContents(int,int) ) ); 93 this, SLOT( resizeContents(int,int) ) );
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,22 +1,29 @@
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;
17 minData_ = 0; 24 minData_ = 0;
18 options_ = new KRFBServer(); 25 options_ = new KRFBServer();
19 updater = 0; 26 updater = 0;
20 decoder_ = 0; 27 decoder_ = 0;
21 buffer_ = 0; 28 buffer_ = 0;
22} 29}
@@ -34,33 +41,33 @@ void KRFBConnection::connectTo( KRFBServer server)
34 if ( currentState_ != Disconnected ) 41 if ( currentState_ != Disconnected )
35 disconnect(); 42 disconnect();
36 43
37 (*options_)=server; 44 (*options_)=server;
38 45
39 sock = new QSocket( this, "rfbSocket" ); 46 sock = new QSocket( this, "rfbSocket" );
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
61 connect( sock, SIGNAL( delayedCloseFinished() ), SLOT( disconnectDone() ) ); 68 connect( sock, SIGNAL( delayedCloseFinished() ), SLOT( disconnectDone() ) );
62 sock->close(); 69 sock->close();
63 70
64 if ( sock->state() != QSocket::Closing ) 71 if ( sock->state() != QSocket::Closing )
65 disconnectDone(); 72 disconnectDone();
66 } 73 }
@@ -73,36 +80,36 @@ void KRFBConnection::disconnectDone()
73 sock = 0; 80 sock = 0;
74 minData_ = 0; 81 minData_ = 0;
75 delete updater; 82 delete updater;
76 delete decoder_; 83 delete decoder_;
77 delete buffer_; 84 delete buffer_;
78 emit disconnected(); 85 emit disconnected();
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 );
103 CHECK_PTR( decoder_ ); 110 CHECK_PTR( decoder_ );
104 111
105 buffer_ = new KRFBBuffer( decoder_, this, "RFB Buffer" ); 112 buffer_ = new KRFBBuffer( decoder_, this, "RFB Buffer" );
106 CHECK_PTR( buffer_ ); 113 CHECK_PTR( buffer_ );
107 decoder_->setBuffer( buffer_ ); 114 decoder_->setBuffer( buffer_ );
108 115
@@ -113,25 +120,25 @@ void KRFBConnection::gotRFBConnection()
113 decoder_->start(); 120 decoder_->start();
114 121
115 updater = new QTimer; 122 updater = new QTimer;
116 connect( updater, SIGNAL( timeout() ), SLOT( updateTimer() ) ); 123 connect( updater, SIGNAL( timeout() ), SLOT( updateTimer() ) );
117 updater->start( options_->updateRate ); 124 updater->start( options_->updateRate );
118} 125}
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." );
132 static QString confused = tr( "QSocket reported an invalid error code" ); 139 static QString confused = tr( "QSocket reported an invalid error code" );
133 140
134 QString msg; 141 QString msg;
135 switch ( err ) { 142 switch ( err ) {
136 case QSocket::ErrConnectionRefused: 143 case QSocket::ErrConnectionRefused:
137 msg = refused; 144 msg = refused;
@@ -163,29 +170,29 @@ void KRFBConnection::gotMoreData()
163 QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) ); 170 QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) );
164 emit gotEnoughData(); 171 emit gotEnoughData();
165 } 172 }
166} 173}
167 174
168void KRFBConnection::waitForData( unsigned int sz ) 175void 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 )
186{ 193{
187 return sock->readBlock( (char *) buf, sz ); 194 return sock->readBlock( (char *) buf, sz );
188} 195}
189 196
190int KRFBConnection::write( void *buf, int sz ) 197int KRFBConnection::write( void *buf, int sz )
191{ 198{
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp
index db95154..69457e2 100644
--- a/noncore/comm/keypebble/krfbdecoder.cpp
+++ b/noncore/comm/keypebble/krfbdecoder.cpp
@@ -1,26 +1,31 @@
1#include "krfbconnection.h" 1#include "krfbconnection.h"
2#include "krfbserverinfo.h" 2#include "krfbserverinfo.h"
3#include "krfbdecoder.h" 3#include "krfbdecoder.h"
4#include "krfbbuffer.h" 4#include "krfbbuffer.h"
5 5
6/* OPIE */
7#include <opie2/odebug.h>
8using namespace Opie::Core;
6 9
10/* QT */
7#include <qpixmap.h> 11#include <qpixmap.h>
8 12
13/* STD */
9#include <assert.h> 14#include <assert.h>
10 15
11// 16//
12// Endian stuff 17// Endian stuff
13// 18//
14#ifndef KDE_USE_FINAL 19#ifndef OPIE_NO_DEBUG
15const int endianTest = 1; 20const int endianTest = 1;
16#endif 21#endif
17 22
18#define Swap16IfLE(s) \ 23#define Swap16IfLE(s) \
19 (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) 24 (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
20 25
21#define Swap32IfLE(l) \ 26#define Swap32IfLE(l) \
22 (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ 27 (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \
23 (((l) & 0x00ff0000) >> 8) | \ 28 (((l) & 0x00ff0000) >> 8) | \
24 (((l) & 0x0000ff00) << 8) | \ 29 (((l) & 0x0000ff00) << 8) | \
25 (((l) & 0x000000ff) << 24)) : (l)) 30 (((l) & 0x000000ff) << 24)) : (l))
26 31
@@ -126,37 +131,37 @@ KRFBDecoder::~KRFBDecoder()
126} 131}
127 132
128void KRFBDecoder::start() 133void KRFBDecoder::start()
129{ 134{
130 sendClientInit(); 135 sendClientInit();
131} 136}
132 137
133void KRFBDecoder::sendClientInit() 138void KRFBDecoder::sendClientInit()
134{ 139{
135 con->write( &( con->options()->shared ), 1 ); 140 con->write( &( con->options()->shared ), 1 );
136 141
137 // Wait for server init 142 // Wait for server init
138 qWarning( "Waiting for server init" ); 143 owarn << "Waiting for server init" << oendl;
139 144
140 static QString statusMsg = tr( "Waiting for server initialization..." ); 145 static QString statusMsg = tr( "Waiting for server initialization..." );
141 emit status( statusMsg ); 146 emit status( statusMsg );
142 147
143 currentState = AwaitingServerInit; 148 currentState = AwaitingServerInit;
144 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerInit() ) ); 149 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerInit() ) );
145 con->waitForData( ServerInitLength ); 150 con->waitForData( ServerInitLength );
146} 151}
147 152
148void KRFBDecoder::gotServerInit() 153void KRFBDecoder::gotServerInit()
149{ 154{
150 qWarning( "Got server init" ); 155 owarn << "Got server init" << oendl;
151 disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) ); 156 disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) );
152 157
153 if ( info ) 158 if ( info )
154 delete info; 159 delete info;
155 info = new KRFBServerInfo; 160 info = new KRFBServerInfo;
156 CHECK_PTR( info ); 161 CHECK_PTR( info );
157 162
158 con->read( &(info->width), 2 ); 163 con->read( &(info->width), 2 );
159 info->width = Swap16IfLE( info->width ); 164 info->width = Swap16IfLE( info->width );
160 con->read( &info->height, 2 ); 165 con->read( &info->height, 2 );
161 info->height = Swap16IfLE( info->height ); 166 info->height = Swap16IfLE( info->height );
162 167
@@ -172,63 +177,63 @@ void KRFBDecoder::gotServerInit()
172 con->read( &(info->blueMax), 2 ); 177 con->read( &(info->blueMax), 2 );
173 info->blueMax = Swap16IfLE( info->blueMax ); 178 info->blueMax = Swap16IfLE( info->blueMax );
174 179
175 con->read( &(info->redShift), 1 ); 180 con->read( &(info->redShift), 1 );
176 con->read( &(info->greenShift), 1 ); 181 con->read( &(info->greenShift), 1 );
177 con->read( &(info->blueShift), 1 ); 182 con->read( &(info->blueShift), 1 );
178 183
179 con->read( info->padding, 3 ); 184 con->read( info->padding, 3 );
180 185
181 con->read( &(info->nameLength), 4 ); 186 con->read( &(info->nameLength), 4 );
182 info->nameLength = Swap32IfLE( info->nameLength ); 187 info->nameLength = Swap32IfLE( info->nameLength );
183 188
184 qWarning( "Width = %d, Height = %d", info->width, info->height ); 189 owarn << "Width = " << info->width << ", Height = " << info->height << "" << oendl;
185 qWarning( "Bpp = %d, Depth = %d, Big = %d, True = %d", 190 qWarning( "Bpp = %d, Depth = %d, Big = %d, True = %d",
186 info->bpp, info->depth, info->bigEndian, info->trueColor ); 191 info->bpp, info->depth, info->bigEndian, info->trueColor );
187 qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d", 192 qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d",
188 info->redMax, info->greenMax, info->blueMax ); 193 info->redMax, info->greenMax, info->blueMax );
189 qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d", 194 qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d",
190 info->redShift, info->greenShift,info-> blueShift ); 195 info->redShift, info->greenShift,info-> blueShift );
191 196
192 buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor); 197 buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor);
193 198
194 // Wait for desktop name 199 // Wait for desktop name
195 qWarning( "Waiting for desktop name" ); 200 owarn << "Waiting for desktop name" << oendl;
196 201
197 static QString statusMsg = tr( "Waiting for desktop name..." ); 202 static QString statusMsg = tr( "Waiting for desktop name..." );
198 emit status( statusMsg ); 203 emit status( statusMsg );
199 204
200 currentState = AwaitingDesktopName; 205 currentState = AwaitingDesktopName;
201 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) ); 206 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) );
202 con->waitForData( info->nameLength ); 207 con->waitForData( info->nameLength );
203} 208}
204 209
205void KRFBDecoder::gotDesktopName() 210void KRFBDecoder::gotDesktopName()
206{ 211{
207 assert( info ); 212 assert( info );
208 assert( currentState == AwaitingDesktopName ); 213 assert( currentState == AwaitingDesktopName );
209 214
210 qWarning( "Got desktop name" ); 215 owarn << "Got desktop name" << oendl;
211 216
212 disconnect( con, SIGNAL( gotEnoughData() ), 217 disconnect( con, SIGNAL( gotEnoughData() ),
213 this, SLOT( gotDesktopName() ) ); 218 this, SLOT( gotDesktopName() ) );
214 219
215 char *buf = new char[ info->nameLength + 1 ]; 220 char *buf = new char[ info->nameLength + 1 ];
216 CHECK_PTR( buf ); 221 CHECK_PTR( buf );
217 222
218 con->read( buf, info->nameLength ); 223 con->read( buf, info->nameLength );
219 buf[ info->nameLength ] = '\0'; 224 buf[ info->nameLength ] = '\0';
220 info->name = buf; 225 info->name = buf;
221 226
222 qWarning( "Desktop: %s", info->name.latin1() ); 227 owarn << "Desktop: " << info->name.latin1() << "" << oendl;
223 228
224 delete buf; 229 delete buf;
225 230
226 // Get the format we'll really use and tell the server 231 // Get the format we'll really use and tell the server
227 decidePixelFormat(); 232 decidePixelFormat();
228 sendPixelFormat(); 233 sendPixelFormat();
229 sendAllowedEncodings(); 234 sendAllowedEncodings();
230 currentState = Idle; 235 currentState = Idle;
231 236
232 QString msg; 237 QString msg;
233 msg = tr( "Connected to %1" ); 238 msg = tr( "Connected to %1" );
234 msg = msg.arg( info->name ); 239 msg = msg.arg( info->name );
@@ -362,25 +367,25 @@ void KRFBDecoder::sendUpdateRequest( bool incremental )
362 con->write( &h, 2 ); 367 con->write( &h, 2 );
363 368
364 // Now wait for the update 369 // Now wait for the update
365 currentState = AwaitingUpdate; 370 currentState = AwaitingUpdate;
366 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); 371 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
367 con->waitForData( UpdateHeaderLength ); 372 con->waitForData( UpdateHeaderLength );
368} 373}
369 374
370void KRFBDecoder::gotUpdateHeader() 375void KRFBDecoder::gotUpdateHeader()
371{ 376{
372 assert( currentState == AwaitingUpdate ); 377 assert( currentState == AwaitingUpdate );
373 378
374 // qWarning( "Got update header" ); 379 // owarn << "Got update header" << oendl;
375 380
376 disconnect( con, SIGNAL( gotEnoughData() ), 381 disconnect( con, SIGNAL( gotEnoughData() ),
377 this, SLOT( gotUpdateHeader() ) ); 382 this, SLOT( gotUpdateHeader() ) );
378 383
379 CARD8 msgType; 384 CARD8 msgType;
380 con->read( &msgType, 1 ); 385 con->read( &msgType, 1 );
381 386
382 if ( msgType != UpdateId ) { 387 if ( msgType != UpdateId ) {
383 // We might have a bell or server cut 388 // We might have a bell or server cut
384 if ( msgType == ServerCutId ) { 389 if ( msgType == ServerCutId ) {
385 oldState = currentState; 390 oldState = currentState;
386 gotServerCut(); 391 gotServerCut();
@@ -397,37 +402,37 @@ void KRFBDecoder::gotUpdateHeader()
397 currentState = Error; 402 currentState = Error;
398 emit error( protocolError ); 403 emit error( protocolError );
399 } 404 }
400 return; 405 return;
401 } 406 }
402 407
403 CARD8 padding; 408 CARD8 padding;
404 con->read( &padding, 1 ); 409 con->read( &padding, 1 );
405 410
406 con->read( &noRects, 2 ); 411 con->read( &noRects, 2 );
407 noRects = Swap16IfLE( noRects ); 412 noRects = Swap16IfLE( noRects );
408 413
409 // qWarning( "Expecting %d rects", noRects ); 414 // owarn << "Expecting " << noRects << " rects" << oendl;
410 415
411 // Now wait for the data 416 // Now wait for the data
412 currentState = AwaitingRectHeader; 417 currentState = AwaitingRectHeader;
413 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); 418 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
414 con->waitForData( RectHeaderLength ); 419 con->waitForData( RectHeaderLength );
415} 420}
416 421
417void KRFBDecoder::gotRectHeader() 422void KRFBDecoder::gotRectHeader()
418{ 423{
419 assert( currentState == AwaitingRectHeader ); 424 assert( currentState == AwaitingRectHeader );
420 425
421 // qWarning( "Got rect header" ); 426 // owarn << "Got rect header" << oendl;
422 427
423 disconnect( con, SIGNAL( gotEnoughData() ), 428 disconnect( con, SIGNAL( gotEnoughData() ),
424 this, SLOT( gotRectHeader() ) ); 429 this, SLOT( gotRectHeader() ) );
425 430
426 con->read( &x, 2 ); 431 con->read( &x, 2 );
427 x = Swap16IfLE( x ); 432 x = Swap16IfLE( x );
428 con->read( &y, 2 ); 433 con->read( &y, 2 );
429 y = Swap16IfLE( y ); 434 y = Swap16IfLE( y );
430 435
431 con->read( &w, 2 ); 436 con->read( &w, 2 );
432 w = Swap16IfLE( w ); 437 w = Swap16IfLE( w );
433 con->read( &h, 2 ); 438 con->read( &h, 2 );
@@ -437,125 +442,125 @@ void KRFBDecoder::gotRectHeader()
437 442
438 // CARD32 encodingLocal = Swap32IfLE( encoding ); 443 // CARD32 encodingLocal = Swap32IfLE( encoding );
439 // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld", 444 // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld",
440 // x, y, w, h, encodingLocal ); 445 // x, y, w, h, encodingLocal );
441 446
442 // 447 //
443 // Each encoding needs to be handled differently. Some require 448 // Each encoding needs to be handled differently. Some require
444 // waiting for more data, but others like a copyrect do not. 449 // waiting for more data, but others like a copyrect do not.
445 // Our constants have already been byte swapped, so we use 450 // Our constants have already been byte swapped, so we use
446 // the remote value as is. 451 // the remote value as is.
447 // 452 //
448 if ( encoding == RawEncoding ) { 453 if ( encoding == RawEncoding ) {
449 // qWarning( "Raw encoding" ); 454 // owarn << "Raw encoding" << oendl;
450 handleRawRect(); 455 handleRawRect();
451 } 456 }
452 else if ( encoding == CopyRectEncoding ) { 457 else if ( encoding == CopyRectEncoding ) {
453// qWarning( "CopyRect encoding" ); 458// owarn << "CopyRect encoding" << oendl;
454 handleCopyRect(); 459 handleCopyRect();
455 } 460 }
456 else if ( encoding == RreEncoding ) { 461 else if ( encoding == RreEncoding ) {
457 qWarning( "RRE encoding" ); 462 owarn << "RRE encoding" << oendl;
458 handleRRERect(); 463 handleRRERect();
459 } 464 }
460 else if ( encoding == CorreEncoding ) { 465 else if ( encoding == CorreEncoding ) {
461 qWarning( "CoRRE encoding" ); 466 owarn << "CoRRE encoding" << oendl;
462 handleCoRRERect(); 467 handleCoRRERect();
463 } 468 }
464 else if ( encoding == HexTileEncoding ) { 469 else if ( encoding == HexTileEncoding ) {
465 qWarning( "HexTile encoding" ); 470 owarn << "HexTile encoding" << oendl;
466 handleHexTileRect(); 471 handleHexTileRect();
467 } 472 }
468 else { 473 else {
469 int msg = Swap32IfLE( encoding ); 474 int msg = Swap32IfLE( encoding );
470 QString protocolError = tr( "Protocol Error: An unknown encoding was " 475 QString protocolError = tr( "Protocol Error: An unknown encoding was "
471 "used by the server %1" ).arg( msg ); 476 "used by the server %1" ).arg( msg );
472 currentState = Error; 477 currentState = Error;
473 qWarning( "Unknown encoding, %d", msg ); 478 owarn << "Unknown encoding, " << msg << "" << oendl;
474 emit error( protocolError ); 479 emit error( protocolError );
475 return; 480 return;
476 } 481 }
477} 482}
478 483
479// 484//
480// Raw Encoding 485// Raw Encoding
481// 486//
482 487
483void KRFBDecoder::handleRawRect() 488void KRFBDecoder::handleRawRect()
484{ 489{
485 // We need something a bit cleverer here to handle large 490 // We need something a bit cleverer here to handle large
486 // rectanges nicely. The chunking should be based on the 491 // rectanges nicely. The chunking should be based on the
487 // overall size (but has to be in complete lines). 492 // overall size (but has to be in complete lines).
488 493
489 // qWarning( "Handling a raw rect chunk" ); 494 // owarn << "Handling a raw rect chunk" << oendl;
490 495
491 // CARD32 lineCount = w * format->bpp / 8; 496 // CARD32 lineCount = w * format->bpp / 8;
492 497
493 if ( h > RectChunkSize ) { 498 if ( h > RectChunkSize ) {
494 // if ( con->sock->size() / lineCount ) { 499 // if ( con->sock->size() / lineCount ) {
495 // getRawRectChunk( con->sock->size() / lineCount ); 500 // getRawRectChunk( con->sock->size() / lineCount );
496 // } 501 // }
497 // else { 502 // else {
498 getRawRectChunk( RectChunkSize ); 503 getRawRectChunk( RectChunkSize );
499 // } 504 // }
500 } 505 }
501 else { 506 else {
502 getRawRectChunk( h ); 507 getRawRectChunk( h );
503 } 508 }
504} 509}
505 510
506void KRFBDecoder::getRawRectChunk( int lines ) 511void KRFBDecoder::getRawRectChunk( int lines )
507{ 512{
508 this->lines = lines; 513 this->lines = lines;
509 CARD32 count = lines * w * format->bpp / 8; 514 CARD32 count = lines * w * format->bpp / 8;
510 515
511 // Wait for server init 516 // Wait for server init
512 // qWarning( "Waiting for raw rect chunk, %ld", count ); 517 // owarn << "Waiting for raw rect chunk, " << count << "" << oendl;
513 518
514 currentState = AwaitingRawRectChunk; 519 currentState = AwaitingRawRectChunk;
515 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) ); 520 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) );
516 con->waitForData( count ); 521 con->waitForData( count );
517} 522}
518 523
519void KRFBDecoder::gotRawRectChunk() 524void KRFBDecoder::gotRawRectChunk()
520{ 525{
521 assert( currentState == AwaitingRawRectChunk ); 526 assert( currentState == AwaitingRawRectChunk );
522 527
523 disconnect( con, SIGNAL( gotEnoughData() ), 528 disconnect( con, SIGNAL( gotEnoughData() ),
524 this, SLOT( gotRawRectChunk() ) ); 529 this, SLOT( gotRawRectChunk() ) );
525 530
526 // qWarning( "Got raw rect chunk" ); 531 // owarn << "Got raw rect chunk" << oendl;
527 532
528 // 533 //
529 // Read the rect data and copy it to the buffer. 534 // Read the rect data and copy it to the buffer.
530 // 535 //
531 536
532 // TODO: Replace this! 537 // TODO: Replace this!
533 int count = lines * w * format->bpp / 8; 538 int count = lines * w * format->bpp / 8;
534 char *hack = new char[ count ]; 539 char *hack = new char[ count ];
535 con->read( hack, count ); 540 con->read( hack, count );
536 buf->drawRawRectChunk( hack, x, y, w, lines ); 541 buf->drawRawRectChunk( hack, x, y, w, lines );
537 delete hack; 542 delete hack;
538 // /TODO: 543 // /TODO:
539 544
540 h = h - lines; 545 h = h - lines;
541 y = y + lines; 546 y = y + lines;
542 547
543 if ( h > 0 ) { 548 if ( h > 0 ) {
544 handleRawRect(); 549 handleRawRect();
545 } 550 }
546 else { 551 else {
547 noRects--; 552 noRects--;
548 553
549 // qWarning( "There are %d rects left", noRects ); 554 // owarn << "There are " << noRects << " rects left" << oendl;
550 555
551 if ( noRects ) { 556 if ( noRects ) {
552 currentState = AwaitingRectHeader; 557 currentState = AwaitingRectHeader;
553 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); 558 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
554 con->waitForData( RectHeaderLength ); 559 con->waitForData( RectHeaderLength );
555 } 560 }
556 else { 561 else {
557 // we are now ready for the next update - no need to wait for the timer 562 // we are now ready for the next update - no need to wait for the timer
558 currentState = Idle; 563 currentState = Idle;
559 sendUpdateRequest (1); 564 sendUpdateRequest (1);
560 } 565 }
561 } 566 }
@@ -581,48 +586,48 @@ void KRFBDecoder::gotCopyRectPos()
581 CARD16 srcY; 586 CARD16 srcY;
582 587
583 con->read( &srcX, 2 ); 588 con->read( &srcX, 2 );
584 con->read( &srcY, 2 ); 589 con->read( &srcY, 2 );
585 590
586 srcX = Swap16IfLE( srcX ); 591 srcX = Swap16IfLE( srcX );
587 srcY = Swap16IfLE( srcY ); 592 srcY = Swap16IfLE( srcY );
588 593
589 buf->copyRect( srcX, srcY, x, y, w, h ); 594 buf->copyRect( srcX, srcY, x, y, w, h );
590 595
591 noRects--; 596 noRects--;
592 597
593 // qWarning( "There are %d rects left", noRects ); 598 // owarn << "There are " << noRects << " rects left" << oendl;
594 599
595 if ( noRects ) { 600 if ( noRects ) {
596 currentState = AwaitingRectHeader; 601 currentState = AwaitingRectHeader;
597 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); 602 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
598 con->waitForData( RectHeaderLength ); 603 con->waitForData( RectHeaderLength );
599 } 604 }
600 else 605 else
601 currentState = Idle; 606 currentState = Idle;
602} 607}
603 608
604void KRFBDecoder::handleRRERect() 609void KRFBDecoder::handleRRERect()
605{ 610{
606 qWarning( "RRE not implemented" ); 611 owarn << "RRE not implemented" << oendl;
607} 612}
608 613
609void KRFBDecoder::handleCoRRERect() 614void KRFBDecoder::handleCoRRERect()
610{ 615{
611 qWarning( "CoRRE not implemented" ); 616 owarn << "CoRRE not implemented" << oendl;
612} 617}
613 618
614void KRFBDecoder::handleHexTileRect() 619void KRFBDecoder::handleHexTileRect()
615{ 620{
616 qWarning( "HexTile not implemented" ); 621 owarn << "HexTile not implemented" << oendl;
617} 622}
618 623
619void KRFBDecoder::sendMouseEvent( QMouseEvent *e ) 624void KRFBDecoder::sendMouseEvent( QMouseEvent *e )
620{ 625{
621 // Deal with the buttons 626 // Deal with the buttons
622 if ( e->type() != QEvent::MouseMove ) { 627 if ( e->type() != QEvent::MouseMove ) {
623 buttonMask = 0; 628 buttonMask = 0;
624 if ( e->type() == QEvent::MouseButtonPress ) { 629 if ( e->type() == QEvent::MouseButtonPress ) {
625 if ( e->button() & LeftButton ) 630 if ( e->button() & LeftButton )
626 buttonMask |= 0x01; 631 buttonMask |= 0x01;
627 if ( e->button() & MidButton ) 632 if ( e->button() & MidButton )
628 buttonMask |= 0x04; 633 buttonMask |= 0x04;
@@ -664,25 +669,25 @@ void KRFBDecoder::sendCutEvent( const QString &unicode )
664 QCString text = unicode.local8Bit(); 669 QCString text = unicode.local8Bit();
665 CARD32 length = text.length(); 670 CARD32 length = text.length();
666 length = Swap32IfLE( length ); 671 length = Swap32IfLE( length );
667 672
668 con->write( &ClientCutTextId, 1 ); 673 con->write( &ClientCutTextId, 1 );
669 con->write( &padding, 3 ); 674 con->write( &padding, 3 );
670 con->write( &length, 4 ); 675 con->write( &length, 4 );
671 con->write( text.data(), length ); 676 con->write( text.data(), length );
672} 677}
673 678
674void KRFBDecoder::gotServerCut() 679void KRFBDecoder::gotServerCut()
675{ 680{
676 qWarning( "Got server cut" ); 681 owarn << "Got server cut" << oendl;
677 682
678 currentState = AwaitingServerCutLength; 683 currentState = AwaitingServerCutLength;
679 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) ); 684 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) );
680 con->waitForData( ServerCutLenLength ); 685 con->waitForData( ServerCutLenLength );
681} 686}
682 687
683void KRFBDecoder::gotServerCutLength() 688void KRFBDecoder::gotServerCutLength()
684{ 689{
685 assert( currentState = AwaitingServerCutLength ); 690 assert( currentState = AwaitingServerCutLength );
686 disconnect( con, SIGNAL( gotEnoughData() ), 691 disconnect( con, SIGNAL( gotEnoughData() ),
687 this, SLOT( gotServerCutLength() ) ); 692 this, SLOT( gotServerCutLength() ) );
688 693
@@ -712,62 +717,62 @@ void KRFBDecoder::gotServerCutText()
712 // same. I've reported this problem to the ORL guys, but they apparantly have no 717 // same. I've reported this problem to the ORL guys, but they apparantly have no
713 // immediate plans to fix the issue. :-( (rich) 718 // immediate plans to fix the issue. :-( (rich)
714 // 719 //
715 720
716 char *cutbuf = new char[ serverCutTextLen + 1 ]; 721 char *cutbuf = new char[ serverCutTextLen + 1 ];
717 CHECK_PTR( cutbuf ); 722 CHECK_PTR( cutbuf );
718 723
719 con->read( cutbuf, serverCutTextLen ); 724 con->read( cutbuf, serverCutTextLen );
720 cutbuf[ serverCutTextLen ] = '\0'; 725 cutbuf[ serverCutTextLen ] = '\0';
721 726
722 /* For some reason QApplication::clipboard()->setText() segfaults when called 727 /* For some reason QApplication::clipboard()->setText() segfaults when called
723 * from within keypebble's mass of signals and slots 728 * from within keypebble's mass of signals and slots
724 qWarning( "Server cut: %s", cutbuf ); 729 owarn << "Server cut: " << cutbuf << "" << oendl;
725 730
726 QString cutText( cutbuf ); // DANGER!! 731 QString cutText( cutbuf ); // DANGER!!
727 qApp->clipboard()->setText( cutText ); 732 qApp->clipboard()->setText( cutText );
728 */ 733 */
729 734
730 delete cutbuf; 735 delete cutbuf;
731 // Now wait for the update (again) 736 // Now wait for the update (again)
732 if ( oldState == AwaitingUpdate ) { 737 if ( oldState == AwaitingUpdate ) {
733 currentState = AwaitingUpdate; 738 currentState = AwaitingUpdate;
734 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); 739 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
735 con->waitForData( UpdateHeaderLength ); 740 con->waitForData( UpdateHeaderLength );
736 } 741 }
737 else if ( oldState == Idle ) { 742 else if ( oldState == Idle ) {
738 currentState = Idle; 743 currentState = Idle;
739 } 744 }
740 else { 745 else {
741 qWarning( "Async handled in weird state" ); 746 owarn << "Async handled in weird state" << oendl;
742 currentState = oldState; 747 currentState = oldState;
743 }; 748 };
744} 749}
745 750
746void KRFBDecoder::gotBell() 751void KRFBDecoder::gotBell()
747{ 752{
748 qWarning( "Got server bell" ); 753 owarn << "Got server bell" << oendl;
749 buf->soundBell(); 754 buf->soundBell();
750 755
751 // Now wait for the update (again) 756 // Now wait for the update (again)
752 if ( oldState == AwaitingUpdate ) { 757 if ( oldState == AwaitingUpdate ) {
753 currentState = AwaitingUpdate; 758 currentState = AwaitingUpdate;
754 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); 759 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
755 con->waitForData( UpdateHeaderLength ); 760 con->waitForData( UpdateHeaderLength );
756 } 761 }
757 else if ( oldState == Idle ) { 762 else if ( oldState == Idle ) {
758 currentState = Idle; 763 currentState = Idle;
759 } 764 }
760 else { 765 else {
761 qWarning( "Async handled in weird state" ); 766 owarn << "Async handled in weird state" << oendl;
762 currentState = oldState; 767 currentState = oldState;
763 }; 768 };
764} 769}
765 770
766void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event ) 771void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event )
767{ 772{
768 int key; 773 int key;
769 key = toKeySym( event ); 774 key = toKeySym( event );
770 if ( key ) { 775 if ( key ) {
771 key = Swap32IfLE( key ); 776 key = Swap32IfLE( key );
772 777
773 CARD8 mask = true; 778 CARD8 mask = true;
diff --git a/noncore/comm/keypebble/krfblogin.cpp b/noncore/comm/keypebble/krfblogin.cpp
index 2bbd110..92005d2 100644
--- a/noncore/comm/keypebble/krfblogin.cpp
+++ b/noncore/comm/keypebble/krfblogin.cpp
@@ -1,23 +1,28 @@
1#include <assert.h> 1#include "krfblogin.h"
2#include "krfbconnection.h"
2 3
4/* OPIE */
5#include <opie2/odebug.h>
6using namespace Opie::Core;
7
8/* QT */
9#include <qtimer.h>
3 10
11/* STD */
12#include <assert.h>
4extern "C" { 13extern "C" {
5#include "vncauth.h" 14#include "vncauth.h"
6} 15}
7 16
8#include "krfblogin.h"
9#include "krfbconnection.h"
10#include <qtimer.h>
11
12// The length of the various messages (used to decide how many bytes to 17// The length of the various messages (used to decide how many bytes to
13// wait for). 18// wait for).
14const int ServerVersionLength = 12; 19const int ServerVersionLength = 12;
15const int ClientVersionLength = 12; 20const int ClientVersionLength = 12;
16const int AuthSchemeLength = 4; 21const int AuthSchemeLength = 4;
17const int FailureReasonSizeLength = 4; 22const int FailureReasonSizeLength = 4;
18const int ChallengeLength = 16; 23const int ChallengeLength = 16;
19const int AuthResultLength = 4; 24const int AuthResultLength = 4;
20 25
21// Authentication results 26// Authentication results
22enum AuthResult { 27enum AuthResult {
23 AuthOk, 28 AuthOk,
@@ -43,154 +48,154 @@ const int endianTest = 1;
43 48
44KRFBLogin::KRFBLogin( KRFBConnection *con ) 49KRFBLogin::KRFBLogin( KRFBConnection *con )
45 : QObject( con, "RFB login manager" ) 50 : QObject( con, "RFB login manager" )
46{ 51{
47 assert( con ); 52 assert( con );
48 this->con = con; 53 this->con = con;
49 currentState = AwaitingServerVersion; 54 currentState = AwaitingServerVersion;
50 55
51 connect( this, SIGNAL( error(const QString&) ), 56 connect( this, SIGNAL( error(const QString&) ),
52 con, SIGNAL( error(const QString&) ) ); 57 con, SIGNAL( error(const QString&) ) );
53 58
54 59
55 qWarning( "Waiting for server version..." ); 60 owarn << "Waiting for server version..." << oendl;
56 61
57 static QString statusMsg = tr( "Waiting for server version..." ); 62 static QString statusMsg = tr( "Waiting for server version..." );
58 emit status( statusMsg ); 63 emit status( statusMsg );
59 64
60 // Kick off the state machine 65 // Kick off the state machine
61 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerVersion() ) ); 66 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerVersion() ) );
62 con->waitForData( ServerVersionLength ); 67 con->waitForData( ServerVersionLength );
63} 68}
64 69
65KRFBLogin::~KRFBLogin() 70KRFBLogin::~KRFBLogin()
66{ 71{
67 72
68} 73}
69 74
70KRFBLogin::State KRFBLogin::state() const 75KRFBLogin::State KRFBLogin::state() const
71{ 76{
72 return currentState; 77 return currentState;
73} 78}
74 79
75void KRFBLogin::gotServerVersion() 80void KRFBLogin::gotServerVersion()
76{ 81{
77 qWarning( "Got server version" ); 82 owarn << "Got server version" << oendl;
78 83
79 disconnect( con, SIGNAL( gotEnoughData() ), 84 disconnect( con, SIGNAL( gotEnoughData() ),
80 this, SLOT( gotServerVersion() ) ); 85 this, SLOT( gotServerVersion() ) );
81 86
82 // Read the server's version message 87 // Read the server's version message
83 char serverVersion[ ServerVersionLength + 1 ]; 88 char serverVersion[ ServerVersionLength + 1 ];
84 con->read( serverVersion, ServerVersionLength ); 89 con->read( serverVersion, ServerVersionLength );
85 serverVersion[ ServerVersionLength ] = '\0'; 90 serverVersion[ ServerVersionLength ] = '\0';
86 91
87 QCString rfbString( serverVersion, ServerVersionLength + 1 ); 92 QCString rfbString( serverVersion, ServerVersionLength + 1 );
88 versionString = rfbString; 93 versionString = rfbString;
89 94
90 QRegExp regexp( "RFB [0-9][0-9][0-9]\\.[0-9][0-9][0-9]\n" ); 95 QRegExp regexp( "RFB [0-9][0-9][0-9]\\.[0-9][0-9][0-9]\n" );
91 96
92 if ( rfbString.find( regexp ) == -1 ) { 97 if ( rfbString.find( regexp ) == -1 ) {
93 static QString msg = tr( "Error: Invalid server version, %1" ).arg( rfbString ); 98 static QString msg = tr( "Error: Invalid server version, %1" ).arg( rfbString );
94 99
95 qWarning( msg ); 100 owarn << msg << oendl;
96 emit error( msg ); 101 emit error( msg );
97 currentState = Error; 102 currentState = Error;
98 return; 103 return;
99 } 104 }
100 105
101 // Calculate the actual version number 106 // Calculate the actual version number
102 serverMajor = (serverVersion[4] - '0') * 100 107 serverMajor = (serverVersion[4] - '0') * 100
103 + (serverVersion[5] - '0') * 10 108 + (serverVersion[5] - '0') * 10
104 + (serverVersion[6] - '0'); 109 + (serverVersion[6] - '0');
105 serverMinor = (serverVersion[8] - '0') * 100 110 serverMinor = (serverVersion[8] - '0') * 100
106 + (serverVersion[9] - '0') * 10 111 + (serverVersion[9] - '0') * 10
107 + (serverVersion[10] - '0'); 112 + (serverVersion[10] - '0');
108 113
109 qWarning("Server Version: %03d.%03d", serverMajor, serverMinor ); 114 owarn << "Server Version: " << serverMajor << "." << serverMinor << "" << oendl;
110 115
111 if ( serverMajor != 3 ) { 116 if ( serverMajor != 3 ) {
112 QString msg = tr( "Error: Unsupported server version, %1" ) 117 QString msg = tr( "Error: Unsupported server version, %1" )
113 .arg( rfbString ); 118 .arg( rfbString );
114 119
115 qWarning( msg ); 120 owarn << msg << oendl;
116 emit error( msg ); 121 emit error( msg );
117 currentState = Error; 122 currentState = Error;
118 return; 123 return;
119 } 124 }
120 125
121 if ( serverMinor != 3 ) { 126 if ( serverMinor != 3 ) {
122 qWarning( "Minor version mismatch: %d", serverMinor ); 127 owarn << "Minor version mismatch: " << serverMinor << "" << oendl;
123 } 128 }
124 129
125 // Setup for the next state 130 // Setup for the next state
126 sendClientVersion(); 131 sendClientVersion();
127 132
128 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotAuthScheme() ) ); 133 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotAuthScheme() ) );
129 con->waitForData( AuthSchemeLength ); 134 con->waitForData( AuthSchemeLength );
130} 135}
131 136
132void KRFBLogin::gotAuthScheme() 137void KRFBLogin::gotAuthScheme()
133{ 138{
134 disconnect( con, SIGNAL( gotEnoughData() ), 139 disconnect( con, SIGNAL( gotEnoughData() ),
135 this, SLOT( gotAuthScheme() ) ); 140 this, SLOT( gotAuthScheme() ) );
136 141
137 // Got data 142 // Got data
138 CARD32 scheme; 143 CARD32 scheme;
139 con->read( &scheme, AuthSchemeLength ); 144 con->read( &scheme, AuthSchemeLength );
140 scheme = Swap32IfLE( scheme ); 145 scheme = Swap32IfLE( scheme );
141 146
142 static QString statusMsgOk = tr( "Logged in" ); 147 static QString statusMsgOk = tr( "Logged in" );
143 148
144 switch ( scheme ) { 149 switch ( scheme ) {
145 case 0: 150 case 0:
146 qWarning( "Failed" ); 151 owarn << "Failed" << oendl;
147 // Handle failure 152 // Handle failure
148 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotFailureReasonSize() ) ); 153 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotFailureReasonSize() ) );
149 con->waitForData( FailureReasonSizeLength ); 154 con->waitForData( FailureReasonSizeLength );
150 break; 155 break;
151 case 1: 156 case 1:
152 // Handle no auth 157 // Handle no auth
153 emit status( statusMsgOk ); 158 emit status( statusMsgOk );
154 con->gotRFBConnection(); 159 con->gotRFBConnection();
155 break; 160 break;
156 case 2: 161 case 2:
157 // Handle VNC auth 162 // Handle VNC auth
158 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotChallenge() ) ); 163 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotChallenge() ) );
159 con->waitForData( ChallengeLength ); 164 con->waitForData( ChallengeLength );
160 break; 165 break;
161 default: 166 default:
162 qWarning( "Unknown authentication scheme, 0x%08lx", scheme ); 167 owarn << "Unknown authentication scheme, 0x" << scheme << "" << oendl;
163 currentState = Error; 168 currentState = Error;
164 break; 169 break;
165 }; 170 };
166} 171}
167 172
168void KRFBLogin::gotChallenge() 173void KRFBLogin::gotChallenge()
169{ 174{
170 disconnect( con, SIGNAL( gotEnoughData() ), 175 disconnect( con, SIGNAL( gotEnoughData() ),
171 this, SLOT( gotChallenge() ) ); 176 this, SLOT( gotChallenge() ) );
172 177
173 QTimer::singleShot( 0, this, SLOT(getPassword()) ); 178 QTimer::singleShot( 0, this, SLOT(getPassword()) );
174} 179}
175 180
176void KRFBLogin::getPassword() 181void KRFBLogin::getPassword()
177{ 182{
178 // Got data 183 // Got data
179 CARD8 challenge[ ChallengeLength ]; 184 CARD8 challenge[ ChallengeLength ];
180 con->read( challenge, ChallengeLength ); 185 con->read( challenge, ChallengeLength );
181 186
182 // Last chance to enter a password 187 // Last chance to enter a password
183 if ( con->options_->password.isNull() ) { 188 if ( con->options_->password.isNull() ) {
184 qWarning( "krfblogin needs a password" ); 189 owarn << "krfblogin needs a password" << oendl;
185 emit passwordRequired( con ); 190 emit passwordRequired( con );
186 } 191 }
187 192
188 if ( con->options_->password.isNull() ) { 193 if ( con->options_->password.isNull() ) {
189 QString msg = tr( "Error: This server requires a password, but none " 194 QString msg = tr( "Error: This server requires a password, but none "
190 "has been specified.\n" ); 195 "has been specified.\n" );
191 196
192 emit error( msg ); 197 emit error( msg );
193 return; 198 return;
194 } 199 }
195 200
196 vncEncryptBytes( (unsigned char *) challenge, QCString(con->options_->password.latin1()).data() ); 201 vncEncryptBytes( (unsigned char *) challenge, QCString(con->options_->password.latin1()).data() );
@@ -207,47 +212,47 @@ void KRFBLogin::gotFailureReasonSize()
207} 212}
208 213
209void KRFBLogin::gotAuthResult() 214void KRFBLogin::gotAuthResult()
210{ 215{
211 // Got data 216 // Got data
212 disconnect( con, SIGNAL( gotEnoughData() ), this, 217 disconnect( con, SIGNAL( gotEnoughData() ), this,
213 SLOT( gotAuthResult() ) ); 218 SLOT( gotAuthResult() ) );
214 219
215 long result; 220 long result;
216 con->read( &result, AuthResultLength ); 221 con->read( &result, AuthResultLength );
217 result = Swap32IfLE( result ); 222 result = Swap32IfLE( result );
218 223
219 qWarning( "Authentication Result is 0x%08lx", result ); 224 owarn << "Authentication Result is 0x" << result << "" << oendl;
220 225
221 static QString failed = tr( "Error: The password you specified was incorrect." ); 226 static QString failed = tr( "Error: The password you specified was incorrect." );
222 static QString tooMany = tr( "Error: Too many invalid login attempts have been made\n" 227 static QString tooMany = tr( "Error: Too many invalid login attempts have been made\n"
223 "to this account, please try later." ); 228 "to this account, please try later." );
224 229
225 static QString statusMsgOk = tr( "Logged in" ); 230 static QString statusMsgOk = tr( "Logged in" );
226 static QString statusMsgFailed = tr( "Login Failed" ); 231 static QString statusMsgFailed = tr( "Login Failed" );
227 static QString statusMsgTooMany = tr( "Too many failures" ); 232 static QString statusMsgTooMany = tr( "Too many failures" );
228 233
229 switch( result ) { 234 switch( result ) {
230 case AuthOk: 235 case AuthOk:
231 emit status( statusMsgOk ); 236 emit status( statusMsgOk );
232 con->gotRFBConnection(); 237 con->gotRFBConnection();
233 break; 238 break;
234 case AuthFailed: 239 case AuthFailed:
235 qWarning( "Dammit" ); 240 owarn << "Dammit" << oendl;
236 emit status( statusMsgFailed ); 241 emit status( statusMsgFailed );
237 emit error( failed ); 242 emit error( failed );
238 break; 243 break;
239 case AuthTooMany: 244 case AuthTooMany:
240 emit status( statusMsgTooMany ); 245 emit status( statusMsgTooMany );
241 emit error( tooMany ); 246 emit error( tooMany );
242 break; 247 break;
243 default: 248 default:
244 qWarning( "Invalid authentication result, %lx", result ); 249 owarn << "Invalid authentication result, " << result << "" << oendl;
245 break; 250 break;
246 } 251 }
247} 252}
248 253
249void KRFBLogin::sendClientVersion() 254void KRFBLogin::sendClientVersion()
250{ 255{
251 qWarning( "Sending client version" ); 256 owarn << "Sending client version" << oendl;
252 con->write( (void*)"RFB 003.003\n", ClientVersionLength ); 257 con->write( (void*)"RFB 003.003\n", ClientVersionLength );
253} 258}
diff --git a/noncore/comm/keypebble/kvncbookmarkdlg.cpp b/noncore/comm/keypebble/kvncbookmarkdlg.cpp
index ef2fa12..149c398 100644
--- a/noncore/comm/keypebble/kvncbookmarkdlg.cpp
+++ b/noncore/comm/keypebble/kvncbookmarkdlg.cpp
@@ -1,17 +1,23 @@
1#include "kvncbookmarkdlg.h"
2
3/* OPIE */
4#include <opie2/odebug.h>
5#include <qpe/global.h>
6using namespace Opie::Core;
7
8/* QT */
1#include <qdir.h> 9#include <qdir.h>
2#include <qtextstream.h> 10#include <qtextstream.h>
3#include <qlistbox.h> 11#include <qlistbox.h>
4#include <qpe/global.h>
5#include "kvncbookmarkdlg.h"
6 12
7KVNCBookmarkDlg::KVNCBookmarkDlg( QWidget * parent, const char * name, WFlags f ) 13KVNCBookmarkDlg::KVNCBookmarkDlg( QWidget * parent, const char * name, WFlags f )
8 14
9: KVNCBookmarkDlgBase( parent, name,f) 15: KVNCBookmarkDlgBase( parent, name,f)
10{ 16{
11 readBookmarks(); 17 readBookmarks();
12 refresh(); 18 refresh();
13 19
14} 20}
15 21
16KVNCBookmarkDlg::~KVNCBookmarkDlg() 22KVNCBookmarkDlg::~KVNCBookmarkDlg()
17{ 23{
@@ -166,25 +172,25 @@ void KVNCBookmarkDlg::writeBookmarks(void)
166 QFile f(filename); 172 QFile f(filename);
167 173
168 QString key, val; 174 QString key, val;
169 KRFBServer * server=0; 175 KRFBServer * server=0;
170 176
171 if ( f.open(IO_ReadWrite) ) { 177 if ( f.open(IO_ReadWrite) ) {
172 QTextStream t( &f ); 178 QTextStream t( &f );
173 QString s; 179 QString s;
174 int n = 1; 180 int n = 1;
175 KRFBServer *server; 181 KRFBServer *server;
176 182
177 for ( server=servers.first(); server != 0; server=servers.next() ) { 183 for ( server=servers.first(); server != 0; server=servers.next() ) {
178 qDebug(server->name); 184 odebug << server->name << oendl;
179 t << "server=" << server->name << '\n'; 185 t << "server=" << server->name << '\n';
180 t << "\thostname=" << server->hostname << '\n'; 186 t << "\thostname=" << server->hostname << '\n';
181 t << "\tpassword=" << encipher(server->password )<< '\n'; 187 t << "\tpassword=" << encipher(server->password )<< '\n';
182 t << "\tdisplay=" << server->display << '\n'; 188 t << "\tdisplay=" << server->display << '\n';
183 t << "\thextile=" << server->hexTile << '\n'; 189 t << "\thextile=" << server->hexTile << '\n';
184 t << "\tcorre=" << server->corre << '\n'; 190 t << "\tcorre=" << server->corre << '\n';
185 t << "\trre=" << server->rre << '\n'; 191 t << "\trre=" << server->rre << '\n';
186 t << "\tcopyrect=" << server->copyrect << '\n'; 192 t << "\tcopyrect=" << server->copyrect << '\n';
187 t << "\tshared=" << server->shared << '\n'; 193 t << "\tshared=" << server->shared << '\n';
188 t << "\treadonly=" << server->readOnly << '\n'; 194 t << "\treadonly=" << server->readOnly << '\n';
189 t << "\tdeiconify=" << server->deIconify << '\n'; 195 t << "\tdeiconify=" << server->deIconify << '\n';
190 t << "\tupdaterate=" << server->updateRate << '\n'; 196 t << "\tupdaterate=" << server->updateRate << '\n';