-rw-r--r-- | noncore/comm/keypebble/config.in | 2 | ||||
-rw-r--r-- | noncore/comm/keypebble/keypebble.pro | 9 | ||||
-rw-r--r-- | noncore/comm/keypebble/krfbbuffer.cpp | 24 | ||||
-rw-r--r-- | noncore/comm/keypebble/krfbcanvas.cpp | 8 | ||||
-rw-r--r-- | noncore/comm/keypebble/krfbconnection.cpp | 31 | ||||
-rw-r--r-- | noncore/comm/keypebble/krfbdecoder.cpp | 63 | ||||
-rw-r--r-- | noncore/comm/keypebble/krfblogin.cpp | 41 | ||||
-rw-r--r-- | noncore/comm/keypebble/kvncbookmarkdlg.cpp | 12 |
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 @@ | |||
1 | CONFIG += qt warn_on quick-app | 1 | CONFIG += 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 | ||
29 | INCLUDEPATH += $(OPIEDIR)/include | 28 | INCLUDEPATH += $(OPIEDIR)/include |
30 | DEPENDPATH += $(OPIEDIR)/include | 29 | DEPENDPATH += $(OPIEDIR)/include |
31 | LIBS += -lqpe | 30 | LIBS += -lqpe -lopiecore2 |
32 | 31 | ||
33 | TARGET = keypebble | 32 | TARGET = keypebble |
34 | 33 | ||
35 | include ( $(OPIEDIR)/include.pro ) | 34 | include ( $(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,173 +1,181 @@ | |||
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> | ||
8 | using 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 |
14 | const int endianTest = 1; | 22 | const 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 | ||
26 | KRFBBuffer::KRFBBuffer( KRFBDecoder *decoder, | 34 | KRFBBuffer::KRFBBuffer( KRFBDecoder *decoder, |
27 | QObject *parent, const char *name ) | 35 | QObject *parent, const char *name ) |
28 | : QObject( parent, name ) | 36 | : QObject( parent, name ) |
29 | { | 37 | { |
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 | ||
35 | KRFBBuffer::~KRFBBuffer() | 43 | KRFBBuffer::~KRFBBuffer() |
36 | { | 44 | { |
37 | delete pix; | 45 | delete pix; |
38 | } | 46 | } |
39 | 47 | ||
40 | void KRFBBuffer::resize( int w, int h ) | 48 | void 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 | ||
52 | void KRFBBuffer::soundBell() | 60 | void KRFBBuffer::soundBell() |
53 | { | 61 | { |
54 | emit bell(); | 62 | emit bell(); |
55 | } | 63 | } |
56 | 64 | ||
57 | void KRFBBuffer::mouseEvent( QMouseEvent *e ) | 65 | void KRFBBuffer::mouseEvent( QMouseEvent *e ) |
58 | { | 66 | { |
59 | decoder->sendMouseEvent( e ); | 67 | decoder->sendMouseEvent( e ); |
60 | } | 68 | } |
61 | 69 | ||
62 | void KRFBBuffer::keyPressEvent( QKeyEvent *e ) | 70 | void 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 | ||
69 | void KRFBBuffer::keyReleaseEvent( QKeyEvent *e ) | 77 | void KRFBBuffer::keyReleaseEvent( QKeyEvent *e ) |
70 | { | 78 | { |
71 | decoder->sendKeyReleaseEvent( e ); | 79 | decoder->sendKeyReleaseEvent( e ); |
72 | } | 80 | } |
73 | 81 | ||
74 | void KRFBBuffer::copyRect( int srcX, int srcY, | 82 | void 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 | ||
83 | void KRFBBuffer::drawRawRectChunk( void *data, | 91 | void 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 ); |
90 | int greenMax = Swap16IfLE( decoder->format->greenMax ); | 98 | int greenMax = Swap16IfLE( decoder->format->greenMax ); |
91 | int blueMax = Swap16IfLE( decoder->format->blueMax ); | 99 | int blueMax = Swap16IfLE( decoder->format->blueMax ); |
92 | 100 | ||
93 | QPainter p( pix ); | 101 | QPainter p( pix ); |
94 | 102 | ||
95 | if ( decoder->format->bpp == 8 ) { | 103 | if ( decoder->format->bpp == 8 ) { |
96 | uchar *d = (unsigned char *) data; | 104 | uchar *d = (unsigned char *) data; |
97 | 105 | ||
98 | uint r,g,b; | 106 | uint r,g,b; |
99 | 107 | ||
100 | 108 | ||
101 | for ( int j = 0; j < h; j++) { | 109 | for ( int j = 0; j < h; j++) { |
102 | for ( int i = 0; i < w ; i++ ) { | 110 | for ( int i = 0; i < w ; i++ ) { |
103 | r = d[ j * w + i ]; | 111 | r = d[ j * w + i ]; |
104 | r = r >> decoder->format->redShift; | 112 | r = r >> decoder->format->redShift; |
105 | r = r & redMax; | 113 | r = r & redMax; |
106 | 114 | ||
107 | g = d[ j * w + i ]; | 115 | g = d[ j * w + i ]; |
108 | g = g >> decoder->format->greenShift; | 116 | g = g >> decoder->format->greenShift; |
109 | g = g & greenMax; | 117 | g = g & greenMax; |
110 | 118 | ||
111 | b = d[ j * w + i ]; | 119 | b = d[ j * w + i ]; |
112 | b = b >> decoder->format->blueShift; | 120 | b = b >> decoder->format->blueShift; |
113 | b = b & blueMax; | 121 | b = b & blueMax; |
114 | 122 | ||
115 | r = ( r * 255 ) / redMax; | 123 | r = ( r * 255 ) / redMax; |
116 | g = ( g * 255 ) / greenMax; | 124 | g = ( g * 255 ) / greenMax; |
117 | b = ( b * 255 ) / blueMax; | 125 | b = ( b * 255 ) / blueMax; |
118 | 126 | ||
119 | uint *p = ( uint * ) img.scanLine( j ) + i; | 127 | uint *p = ( uint * ) img.scanLine( j ) + i; |
120 | *p = qRgb( r,g,b ); | 128 | *p = qRgb( r,g,b ); |
121 | } | 129 | } |
122 | } | 130 | } |
123 | } | 131 | } |
124 | else if ( decoder->format->bpp == 32 ) { | 132 | else if ( decoder->format->bpp == 32 ) { |
125 | ulong *d = (ulong *) data; | 133 | ulong *d = (ulong *) data; |
126 | 134 | ||
127 | ulong r,g,b; | 135 | ulong r,g,b; |
128 | 136 | ||
129 | for ( int j = 0; j < h; j++ ) { | 137 | for ( int j = 0; j < h; j++ ) { |
130 | for ( int i = 0; i < w ; i++ ) { | 138 | for ( int i = 0; i < w ; i++ ) { |
131 | ulong pixel = d[ j * w + i ]; | 139 | ulong pixel = d[ j * w + i ]; |
132 | pixel = Swap32IfLE( pixel ); | 140 | pixel = Swap32IfLE( pixel ); |
133 | 141 | ||
134 | r = pixel; | 142 | r = pixel; |
135 | r = r >> decoder->format->redShift; | 143 | r = r >> decoder->format->redShift; |
136 | r = r & redMax; | 144 | r = r & redMax; |
137 | 145 | ||
138 | g = pixel; | 146 | g = pixel; |
139 | g = g >> decoder->format->greenShift; | 147 | g = g >> decoder->format->greenShift; |
140 | g = g & greenMax; | 148 | g = g & greenMax; |
141 | 149 | ||
142 | b = pixel; | 150 | b = pixel; |
143 | b = b >> decoder->format->blueShift; | 151 | b = b >> decoder->format->blueShift; |
144 | b = b & blueMax; | 152 | b = b & blueMax; |
145 | 153 | ||
146 | r = ( r * 255 ) / redMax; | 154 | r = ( r * 255 ) / redMax; |
147 | g = ( g * 255 ) / greenMax; | 155 | g = ( g * 255 ) / greenMax; |
148 | b = ( b * 255 ) / blueMax; | 156 | b = ( b * 255 ) / blueMax; |
149 | 157 | ||
150 | uint *p = ( uint * ) img.scanLine( j ) + i; | 158 | uint *p = ( uint * ) img.scanLine( j ) + i; |
151 | *p = qRgb( r,g,b ); | 159 | *p = qRgb( r,g,b ); |
152 | } | 160 | } |
153 | } | 161 | } |
154 | } else if (decoder->format->bpp == 16 ) { | 162 | } else if (decoder->format->bpp == 16 ) { |
155 | 163 | ||
156 | CARD16 *d = (CARD16 *) data; | 164 | CARD16 *d = (CARD16 *) data; |
157 | 165 | ||
158 | uint r,g,b; | 166 | uint r,g,b; |
159 | 167 | ||
160 | for ( int j = 0; j < h; j++ ) { | 168 | for ( int j = 0; j < h; j++ ) { |
161 | for ( int i = 0; i < w ; i++ ) { | 169 | for ( int i = 0; i < w ; i++ ) { |
162 | CARD16 pixel = d[ j * w + i ]; | 170 | CARD16 pixel = d[ j * w + i ]; |
163 | pixel = Swap16IfLE( pixel ); | 171 | pixel = Swap16IfLE( pixel ); |
164 | 172 | ||
165 | r = pixel; | 173 | r = pixel; |
166 | r = r >> decoder->format->redShift; | 174 | r = r >> decoder->format->redShift; |
167 | r = r & redMax; | 175 | r = r & redMax; |
168 | 176 | ||
169 | g = pixel; | 177 | g = pixel; |
170 | g = g >> decoder->format->greenShift; | 178 | g = g >> decoder->format->greenShift; |
171 | g = g & greenMax; | 179 | g = g & greenMax; |
172 | 180 | ||
173 | b = pixel; | 181 | b = pixel; |
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,173 +1,177 @@ | |||
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> |
8 | using namespace Opie::Core; | ||
6 | 9 | ||
10 | /* QT */ | ||
7 | #include <qclipboard.h> | 11 | #include <qclipboard.h> |
8 | 12 | ||
9 | KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name ) | 13 | KRFBCanvas::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); |
19 | 23 | ||
20 | viewport()->setFocusPolicy( QWidget::StrongFocus ); | 24 | viewport()->setFocusPolicy( QWidget::StrongFocus ); |
21 | viewport()->setFocus(); | 25 | viewport()->setFocus(); |
22 | 26 | ||
23 | nextRightClick=0; | 27 | nextRightClick=0; |
24 | nextDoubleClick=0; | 28 | nextDoubleClick=0; |
25 | } | 29 | } |
26 | 30 | ||
27 | KRFBCanvas::~KRFBCanvas() | 31 | KRFBCanvas::~KRFBCanvas() |
28 | { | 32 | { |
29 | } | 33 | } |
30 | 34 | ||
31 | 35 | ||
32 | void KRFBCanvas::openConnection(KRFBServer server) | 36 | 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 | ||
42 | void KRFBCanvas::openURL( const QUrl &url ) | 46 | void 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 | ||
55 | void KRFBCanvas::closeConnection() | 59 | void KRFBCanvas::closeConnection() |
56 | { | 60 | { |
57 | loggedIn_ = false; | 61 | loggedIn_ = false; |
58 | connection_->disconnect(); | 62 | connection_->disconnect(); |
59 | 63 | ||
60 | viewport()->setMouseTracking( false ); | 64 | viewport()->setMouseTracking( false ); |
61 | viewport()->setBackgroundMode( PaletteDark ); | 65 | viewport()->setBackgroundMode( PaletteDark ); |
62 | setBackgroundMode( PaletteDark ); | 66 | setBackgroundMode( PaletteDark ); |
63 | update(); | 67 | update(); |
64 | } | 68 | } |
65 | 69 | ||
66 | 70 | ||
67 | void KRFBCanvas::bell() | 71 | void 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 | ||
75 | void KRFBCanvas::loggedIn() | 79 | void 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) ) ); |
90 | connect( connection_->buffer(), SIGNAL( updated(int,int,int,int) ), | 94 | connect( connection_->buffer(), SIGNAL( updated(int,int,int,int) ), |
91 | this, SLOT( viewportUpdate(int,int,int,int) ) ); | 95 | this, SLOT( viewportUpdate(int,int,int,int) ) ); |
92 | connect( connection_->buffer(), SIGNAL( bell() ), | 96 | connect( connection_->buffer(), SIGNAL( bell() ), |
93 | this, SLOT( bell() ) ); | 97 | this, SLOT( bell() ) ); |
94 | connect( qApp->clipboard(), SIGNAL( dataChanged() ), | 98 | connect( qApp->clipboard(), SIGNAL( dataChanged() ), |
95 | this, SLOT( clipboardChanged() ) ); | 99 | this, SLOT( clipboardChanged() ) ); |
96 | } | 100 | } |
97 | 101 | ||
98 | void KRFBCanvas::viewportPaintEvent( QPaintEvent *e ) | 102 | void KRFBCanvas::viewportPaintEvent( QPaintEvent *e ) |
99 | { | 103 | { |
100 | QRect r = e->rect(); | 104 | QRect r = e->rect(); |
101 | 105 | ||
102 | if ( loggedIn_ ) { | 106 | if ( loggedIn_ ) { |
103 | QPixmap p; | 107 | QPixmap p; |
104 | 108 | ||
105 | bitBlt( viewport(), r.x(), r.y(), | 109 | bitBlt( viewport(), r.x(), r.y(), |
106 | connection_->buffer()->pixmap(), | 110 | connection_->buffer()->pixmap(), |
107 | r.x() + contentsX(), r.y() + contentsY(), | 111 | r.x() + contentsX(), r.y() + contentsY(), |
108 | r.width(), r.height() ); | 112 | r.width(), r.height() ); |
109 | } | 113 | } |
110 | else { | 114 | else { |
111 | QScrollView::viewportPaintEvent( e ); | 115 | QScrollView::viewportPaintEvent( e ); |
112 | } | 116 | } |
113 | } | 117 | } |
114 | 118 | ||
115 | void KRFBCanvas::viewportUpdate( int x, int y, int w, int h ) | 119 | void KRFBCanvas::viewportUpdate( int x, int y, int w, int h ) |
116 | { | 120 | { |
117 | updateContents( x, y, w, h ); | 121 | updateContents( x, y, w, h ); |
118 | } | 122 | } |
119 | 123 | ||
120 | void KRFBCanvas::contentsMousePressEvent( QMouseEvent *e ) | 124 | void KRFBCanvas::contentsMousePressEvent( QMouseEvent *e ) |
121 | { | 125 | { |
122 | 126 | ||
123 | if (nextDoubleClick) { | 127 | if (nextDoubleClick) { |
124 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),LeftButton,LeftButton)); | 128 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),LeftButton,LeftButton)); |
125 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0)); | 129 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0)); |
126 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0)); | 130 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0)); |
127 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton)); | 131 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton)); |
128 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0)); | 132 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0)); |
129 | } if (nextRightClick) { | 133 | } if (nextRightClick) { |
130 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),RightButton,RightButton)); | 134 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),RightButton,RightButton)); |
131 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),RightButton,0)); | 135 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),RightButton,0)); |
132 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton)); | 136 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton)); |
133 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0)); | 137 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0)); |
134 | } else if ( loggedIn_ ) | 138 | } else if ( loggedIn_ ) |
135 | connection_->buffer()->mouseEvent( e ); | 139 | connection_->buffer()->mouseEvent( e ); |
136 | 140 | ||
137 | } | 141 | } |
138 | 142 | ||
139 | void KRFBCanvas::contentsMouseReleaseEvent( QMouseEvent *e ) | 143 | void KRFBCanvas::contentsMouseReleaseEvent( QMouseEvent *e ) |
140 | { | 144 | { |
141 | if ( loggedIn_ && !nextRightClick && !nextDoubleClick) { | 145 | if ( loggedIn_ && !nextRightClick && !nextDoubleClick) { |
142 | connection_->buffer()->mouseEvent( e ); | 146 | connection_->buffer()->mouseEvent( e ); |
143 | } | 147 | } |
144 | 148 | ||
145 | nextRightClick=0; | 149 | nextRightClick=0; |
146 | nextDoubleClick=0; | 150 | nextDoubleClick=0; |
147 | } | 151 | } |
148 | 152 | ||
149 | void KRFBCanvas::contentsMouseMoveEvent( QMouseEvent *e ) | 153 | void KRFBCanvas::contentsMouseMoveEvent( QMouseEvent *e ) |
150 | { | 154 | { |
151 | if ( loggedIn_ ) | 155 | if ( loggedIn_ ) |
152 | connection_->buffer()->mouseEvent( e ); | 156 | connection_->buffer()->mouseEvent( e ); |
153 | } | 157 | } |
154 | 158 | ||
155 | void KRFBCanvas::keyPressEvent( QKeyEvent *e ) | 159 | void KRFBCanvas::keyPressEvent( QKeyEvent *e ) |
156 | { | 160 | { |
157 | if ( loggedIn_ ) | 161 | if ( loggedIn_ ) |
158 | connection_->buffer()->keyPressEvent( e ); | 162 | connection_->buffer()->keyPressEvent( e ); |
159 | } | 163 | } |
160 | 164 | ||
161 | void KRFBCanvas::keyReleaseEvent( QKeyEvent *e ) | 165 | void KRFBCanvas::keyReleaseEvent( QKeyEvent *e ) |
162 | { | 166 | { |
163 | if ( loggedIn_ ) | 167 | if ( loggedIn_ ) |
164 | connection_->buffer()->keyReleaseEvent( e ); | 168 | connection_->buffer()->keyReleaseEvent( e ); |
165 | } | 169 | } |
166 | 170 | ||
167 | void KRFBCanvas::refresh() | 171 | void KRFBCanvas::refresh() |
168 | { | 172 | { |
169 | if ( loggedIn_ ) | 173 | if ( loggedIn_ ) |
170 | connection_->refresh(); | 174 | connection_->refresh(); |
171 | } | 175 | } |
172 | 176 | ||
173 | void KRFBCanvas::clipboardChanged() | 177 | void KRFBCanvas::clipboardChanged() |
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,233 +1,240 @@ | |||
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> | ||
8 | using 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 | |||
11 | KRFBConnection::KRFBConnection( QObject *parent ) | 18 | KRFBConnection::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 | } |
23 | 30 | ||
24 | KRFBConnection::~KRFBConnection() | 31 | KRFBConnection::~KRFBConnection() |
25 | { | 32 | { |
26 | if ( ( currentState_ != Disconnected ) && ( currentState_ != Disconnecting ) && sock ) { | 33 | if ( ( currentState_ != Disconnected ) && ( currentState_ != Disconnecting ) && sock ) { |
27 | disconnectDone(); | 34 | disconnectDone(); |
28 | } | 35 | } |
29 | delete options_; | 36 | delete options_; |
30 | } | 37 | } |
31 | 38 | ||
32 | void KRFBConnection::connectTo( KRFBServer server) | 39 | void KRFBConnection::connectTo( KRFBServer server) |
33 | { | 40 | { |
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 | ||
52 | void KRFBConnection::disconnect() | 59 | void 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 | } |
67 | } | 74 | } |
68 | 75 | ||
69 | void KRFBConnection::disconnectDone() | 76 | void KRFBConnection::disconnectDone() |
70 | { | 77 | { |
71 | currentState_ = Disconnected; | 78 | currentState_ = Disconnected; |
72 | delete sock; | 79 | delete sock; |
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 | ||
81 | void KRFBConnection::gotSocketConnection() | 88 | void 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 | ||
94 | void KRFBConnection::gotRFBConnection() | 101 | void 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 | ||
109 | connect( decoder_, SIGNAL( status(const QString&) ), | 116 | connect( decoder_, SIGNAL( status(const QString&) ), |
110 | this, SIGNAL( statusChanged(const QString&) ) ); | 117 | this, SIGNAL( statusChanged(const QString&) ) ); |
111 | emit loggedIn(); | 118 | emit loggedIn(); |
112 | 119 | ||
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 | ||
120 | void KRFBConnection::gotSocketError( int err ) | 127 | void 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; |
138 | break; | 145 | break; |
139 | case QSocket::ErrHostNotFound: | 146 | case QSocket::ErrHostNotFound: |
140 | msg = host; | 147 | msg = host; |
141 | break; | 148 | break; |
142 | case QSocket::ErrSocketRead: | 149 | case QSocket::ErrSocketRead: |
143 | msg = read; | 150 | msg = read; |
144 | break; | 151 | break; |
145 | default: | 152 | default: |
146 | msg = confused; | 153 | msg = confused; |
147 | }; | 154 | }; |
148 | 155 | ||
149 | QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) ); | 156 | QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) ); |
150 | delete sock; | 157 | delete sock; |
151 | sock = 0; | 158 | sock = 0; |
152 | currentState_ = Disconnected; | 159 | currentState_ = Disconnected; |
153 | 160 | ||
154 | emit error( msg ); | 161 | emit error( msg ); |
155 | } | 162 | } |
156 | 163 | ||
157 | void KRFBConnection::gotMoreData() | 164 | void KRFBConnection::gotMoreData() |
158 | { | 165 | { |
159 | assert( minData_ > 0 ); | 166 | assert( minData_ > 0 ); |
160 | 167 | ||
161 | if ( sock->size() >= minData_ ) { | 168 | if ( sock->size() >= minData_ ) { |
162 | minData_ = 0; | 169 | minData_ = 0; |
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 | ||
168 | void KRFBConnection::waitForData( unsigned int sz ) | 175 | 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 | ||
185 | int KRFBConnection::read( void *buf, int sz ) | 192 | int 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 | ||
190 | int KRFBConnection::write( void *buf, int sz ) | 197 | int KRFBConnection::write( void *buf, int sz ) |
191 | { | 198 | { |
192 | return sock->writeBlock( (const char *) buf, sz ); | 199 | return sock->writeBlock( (const char *) buf, sz ); |
193 | } | 200 | } |
194 | 201 | ||
195 | KRFBConnection::State KRFBConnection::state() const | 202 | KRFBConnection::State KRFBConnection::state() const |
196 | { | 203 | { |
197 | return currentState_; | 204 | return currentState_; |
198 | } | 205 | } |
199 | 206 | ||
200 | void KRFBConnection::setPortBase( int base ) | 207 | void KRFBConnection::setPortBase( int base ) |
201 | { | 208 | { |
202 | portBase_ = base; | 209 | portBase_ = base; |
203 | } | 210 | } |
204 | 211 | ||
205 | int KRFBConnection::portBase() const | 212 | int KRFBConnection::portBase() const |
206 | { | 213 | { |
207 | return portBase_; | 214 | return portBase_; |
208 | } | 215 | } |
209 | 216 | ||
210 | void KRFBConnection::updateTimer() | 217 | void KRFBConnection::updateTimer() |
211 | { | 218 | { |
212 | decoder_->sendUpdateRequest( true ); | 219 | decoder_->sendUpdateRequest( true ); |
213 | } | 220 | } |
214 | 221 | ||
215 | void KRFBConnection::refresh() | 222 | void KRFBConnection::refresh() |
216 | { | 223 | { |
217 | decoder_->sendUpdateRequest( false ); | 224 | decoder_->sendUpdateRequest( false ); |
218 | } | 225 | } |
219 | 226 | ||
220 | void KRFBConnection::sendCutText( const QString &text ) | 227 | void KRFBConnection::sendCutText( const QString &text ) |
221 | { | 228 | { |
222 | decoder_->sendCutEvent( text ); | 229 | decoder_->sendCutEvent( text ); |
223 | } | 230 | } |
224 | 231 | ||
225 | const QUrl &KRFBConnection::url() | 232 | const QUrl &KRFBConnection::url() |
226 | { | 233 | { |
227 | url_.setProtocol( "vnc" ); | 234 | url_.setProtocol( "vnc" ); |
228 | url_.setPort( display() ); | 235 | url_.setPort( display() ); |
229 | url_.setHost( host() ); | 236 | url_.setHost( host() ); |
230 | url_.setPath( "/" ); | 237 | url_.setPath( "/" ); |
231 | 238 | ||
232 | return url_; | 239 | return url_; |
233 | } | 240 | } |
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,830 +1,835 @@ | |||
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> | ||
8 | using 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 |
15 | const int endianTest = 1; | 20 | const 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 | ||
27 | // | 32 | // |
28 | // The lengths of the messages we need to wait for | 33 | // The lengths of the messages we need to wait for |
29 | // | 34 | // |
30 | const int ServerInitLength = 24; | 35 | const int ServerInitLength = 24; |
31 | const int UpdateHeaderLength = 4; | 36 | const int UpdateHeaderLength = 4; |
32 | const int RectHeaderLength = 12; | 37 | const int RectHeaderLength = 12; |
33 | const int RectChunkSize = 4; | 38 | const int RectChunkSize = 4; |
34 | const int CopyRectPosLength = 4; | 39 | const int CopyRectPosLength = 4; |
35 | const int ServerCutLenLength = 7; | 40 | const int ServerCutLenLength = 7; |
36 | 41 | ||
37 | // | 42 | // |
38 | // Client -> Server Message Identifiers | 43 | // Client -> Server Message Identifiers |
39 | // | 44 | // |
40 | static CARD8 SetPixelFormatId = 0; | 45 | static CARD8 SetPixelFormatId = 0; |
41 | //static CARD8 FixColourMapEntriesId = 1; // Not used | 46 | //static CARD8 FixColourMapEntriesId = 1; // Not used |
42 | static CARD8 SetEncodingsId = 2; | 47 | static CARD8 SetEncodingsId = 2; |
43 | static CARD8 UpdateRequestId = 3; | 48 | static CARD8 UpdateRequestId = 3; |
44 | static CARD8 KeyEventId = 4; | 49 | static CARD8 KeyEventId = 4; |
45 | static CARD8 PointerEventId = 5; | 50 | static CARD8 PointerEventId = 5; |
46 | static CARD8 ClientCutTextId = 6; | 51 | static CARD8 ClientCutTextId = 6; |
47 | 52 | ||
48 | // | 53 | // |
49 | // Server -> Client Message Identifiers | 54 | // Server -> Client Message Identifiers |
50 | // | 55 | // |
51 | static CARD8 UpdateId = 0; | 56 | static CARD8 UpdateId = 0; |
52 | static CARD8 BellId = 2; | 57 | static CARD8 BellId = 2; |
53 | static CARD8 ServerCutId = 3; | 58 | static CARD8 ServerCutId = 3; |
54 | 59 | ||
55 | // | 60 | // |
56 | // Encoding identifiers | 61 | // Encoding identifiers |
57 | // | 62 | // |
58 | static CARD32 RawEncoding = Swap32IfLE( 0 ); | 63 | static CARD32 RawEncoding = Swap32IfLE( 0 ); |
59 | static CARD32 CopyRectEncoding = Swap32IfLE(1 ); | 64 | static CARD32 CopyRectEncoding = Swap32IfLE(1 ); |
60 | static CARD32 RreEncoding = Swap32IfLE( 2 ); | 65 | static CARD32 RreEncoding = Swap32IfLE( 2 ); |
61 | static CARD32 CorreEncoding = Swap32IfLE( 4 ); | 66 | static CARD32 CorreEncoding = Swap32IfLE( 4 ); |
62 | static CARD32 HexTileEncoding = Swap32IfLE( 5 ); | 67 | static CARD32 HexTileEncoding = Swap32IfLE( 5 ); |
63 | 68 | ||
64 | static struct { | 69 | static struct { |
65 | int keysym; | 70 | int keysym; |
66 | int keycode; | 71 | int keycode; |
67 | } keyMap[] = { | 72 | } keyMap[] = { |
68 | { 0xff08, Qt::Key_Backspace }, | 73 | { 0xff08, Qt::Key_Backspace }, |
69 | { 0xff09, Qt::Key_Tab }, | 74 | { 0xff09, Qt::Key_Tab }, |
70 | { 0xff0d, Qt::Key_Return }, | 75 | { 0xff0d, Qt::Key_Return }, |
71 | { 0xff1b, Qt::Key_Escape }, | 76 | { 0xff1b, Qt::Key_Escape }, |
72 | { 0xff63, Qt::Key_Insert }, | 77 | { 0xff63, Qt::Key_Insert }, |
73 | { 0xffff, Qt::Key_Delete }, | 78 | { 0xffff, Qt::Key_Delete }, |
74 | { 0xff50, Qt::Key_Home }, | 79 | { 0xff50, Qt::Key_Home }, |
75 | { 0xff57, Qt::Key_End }, | 80 | { 0xff57, Qt::Key_End }, |
76 | { 0xff55, Qt::Key_Prior }, | 81 | { 0xff55, Qt::Key_Prior }, |
77 | { 0xff56, Qt::Key_Next }, | 82 | { 0xff56, Qt::Key_Next }, |
78 | { 0xff51, Qt::Key_Left }, | 83 | { 0xff51, Qt::Key_Left }, |
79 | { 0xff52, Qt::Key_Up }, | 84 | { 0xff52, Qt::Key_Up }, |
80 | { 0xff53, Qt::Key_Right }, | 85 | { 0xff53, Qt::Key_Right }, |
81 | { 0xff54, Qt::Key_Down }, | 86 | { 0xff54, Qt::Key_Down }, |
82 | { 0xffbe, Qt::Key_F1 }, | 87 | { 0xffbe, Qt::Key_F1 }, |
83 | { 0xffbf, Qt::Key_F2 }, | 88 | { 0xffbf, Qt::Key_F2 }, |
84 | { 0xffc0, Qt::Key_F3 }, | 89 | { 0xffc0, Qt::Key_F3 }, |
85 | { 0xffc1, Qt::Key_F4 }, | 90 | { 0xffc1, Qt::Key_F4 }, |
86 | { 0xffc2, Qt::Key_F5 }, | 91 | { 0xffc2, Qt::Key_F5 }, |
87 | { 0xffc3, Qt::Key_F6 }, | 92 | { 0xffc3, Qt::Key_F6 }, |
88 | { 0xffc4, Qt::Key_F7 }, | 93 | { 0xffc4, Qt::Key_F7 }, |
89 | { 0xffc5, Qt::Key_F8 }, | 94 | { 0xffc5, Qt::Key_F8 }, |
90 | { 0xffc6, Qt::Key_F9 }, | 95 | { 0xffc6, Qt::Key_F9 }, |
91 | { 0xffc7, Qt::Key_F10 }, | 96 | { 0xffc7, Qt::Key_F10 }, |
92 | { 0xffc8, Qt::Key_F11 }, | 97 | { 0xffc8, Qt::Key_F11 }, |
93 | { 0xffc9, Qt::Key_F12 }, | 98 | { 0xffc9, Qt::Key_F12 }, |
94 | { 0xffe1, Qt::Key_Shift }, | 99 | { 0xffe1, Qt::Key_Shift }, |
95 | { 0xffe2, Qt::Key_Shift }, | 100 | { 0xffe2, Qt::Key_Shift }, |
96 | { 0xffe3, Qt::Key_Control }, | 101 | { 0xffe3, Qt::Key_Control }, |
97 | { 0xffe4, Qt::Key_Control }, | 102 | { 0xffe4, Qt::Key_Control }, |
98 | { 0xffe7, Qt::Key_Meta }, | 103 | { 0xffe7, Qt::Key_Meta }, |
99 | { 0xffe8, Qt::Key_Meta }, | 104 | { 0xffe8, Qt::Key_Meta }, |
100 | { 0xffe9, Qt::Key_Alt }, | 105 | { 0xffe9, Qt::Key_Alt }, |
101 | { 0xffea, Qt::Key_Alt }, | 106 | { 0xffea, Qt::Key_Alt }, |
102 | { 0, 0 } | 107 | { 0, 0 } |
103 | }; | 108 | }; |
104 | 109 | ||
105 | 110 | ||
106 | KRFBDecoder::KRFBDecoder( KRFBConnection *con ) | 111 | KRFBDecoder::KRFBDecoder( KRFBConnection *con ) |
107 | : QObject( con, "RFB Decoder" ) | 112 | : QObject( con, "RFB Decoder" ) |
108 | { | 113 | { |
109 | assert( con ); | 114 | assert( con ); |
110 | assert( con->state() == KRFBConnection::Connected ); | 115 | assert( con->state() == KRFBConnection::Connected ); |
111 | 116 | ||
112 | this->con = con; | 117 | this->con = con; |
113 | this->buf = 0; | 118 | this->buf = 0; |
114 | this->info = 0; | 119 | this->info = 0; |
115 | this->format = 0; | 120 | this->format = 0; |
116 | this->buttonMask = 0; | 121 | this->buttonMask = 0; |
117 | currentState = Idle; | 122 | currentState = Idle; |
118 | } | 123 | } |
119 | 124 | ||
120 | KRFBDecoder::~KRFBDecoder() | 125 | KRFBDecoder::~KRFBDecoder() |
121 | { | 126 | { |
122 | if ( info ) | 127 | if ( info ) |
123 | delete info; | 128 | delete info; |
124 | if ( format ) | 129 | if ( format ) |
125 | delete format; | 130 | delete format; |
126 | } | 131 | } |
127 | 132 | ||
128 | void KRFBDecoder::start() | 133 | void KRFBDecoder::start() |
129 | { | 134 | { |
130 | sendClientInit(); | 135 | sendClientInit(); |
131 | } | 136 | } |
132 | 137 | ||
133 | void KRFBDecoder::sendClientInit() | 138 | void 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 | ||
148 | void KRFBDecoder::gotServerInit() | 153 | void 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 | ||
163 | con->read( &(info->bpp), 1 ); | 168 | con->read( &(info->bpp), 1 ); |
164 | con->read( &(info->depth), 1 ); | 169 | con->read( &(info->depth), 1 ); |
165 | con->read( &(info->bigEndian), 1 ); | 170 | con->read( &(info->bigEndian), 1 ); |
166 | con->read( &(info->trueColor), 1 ); | 171 | con->read( &(info->trueColor), 1 ); |
167 | 172 | ||
168 | con->read( &(info->redMax), 2 ); | 173 | con->read( &(info->redMax), 2 ); |
169 | info->redMax = Swap16IfLE( info->redMax ); | 174 | info->redMax = Swap16IfLE( info->redMax ); |
170 | con->read( &(info->greenMax), 2 ); | 175 | con->read( &(info->greenMax), 2 ); |
171 | info->greenMax = Swap16IfLE( info->greenMax ); | 176 | info->greenMax = Swap16IfLE( info->greenMax ); |
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 | ||
205 | void KRFBDecoder::gotDesktopName() | 210 | void 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 ); |
235 | emit status( msg ); | 240 | emit status( msg ); |
236 | 241 | ||
237 | sendUpdateRequest( false ); | 242 | sendUpdateRequest( false ); |
238 | } | 243 | } |
239 | 244 | ||
240 | void KRFBDecoder::decidePixelFormat() | 245 | void KRFBDecoder::decidePixelFormat() |
241 | { | 246 | { |
242 | assert( info ); | 247 | assert( info ); |
243 | 248 | ||
244 | if ( format ) | 249 | if ( format ) |
245 | delete format; | 250 | delete format; |
246 | format = new KRFBPixelFormat; | 251 | format = new KRFBPixelFormat; |
247 | CHECK_PTR( format ); | 252 | CHECK_PTR( format ); |
248 | 253 | ||
249 | // What depth do we want? | 254 | // What depth do we want? |
250 | // | 255 | // |
251 | // We'll use the minimum of the remote and local depths, UNLESS an | 256 | // We'll use the minimum of the remote and local depths, UNLESS an |
252 | // eight bit session has been specifically requested by the user. | 257 | // eight bit session has been specifically requested by the user. |
253 | int screenDepth = QPixmap::defaultDepth(); | 258 | int screenDepth = QPixmap::defaultDepth(); |
254 | int bestDepth = ( screenDepth > info->depth ) ? info->depth : screenDepth; | 259 | int bestDepth = ( screenDepth > info->depth ) ? info->depth : screenDepth; |
255 | int chosenDepth; | 260 | int chosenDepth; |
256 | 261 | ||
257 | if ( con->options()->colors256 ) | 262 | if ( con->options()->colors256 ) |
258 | chosenDepth = 8; | 263 | chosenDepth = 8; |
259 | else | 264 | else |
260 | chosenDepth = bestDepth; | 265 | chosenDepth = bestDepth; |
261 | 266 | ||
262 | qWarning( "Screen depth=%d, server depth=%d, best depth=%d, " \ | 267 | qWarning( "Screen depth=%d, server depth=%d, best depth=%d, " \ |
263 | "eight bit %d, chosenDepth=%d", | 268 | "eight bit %d, chosenDepth=%d", |
264 | screenDepth, | 269 | screenDepth, |
265 | info->depth, | 270 | info->depth, |
266 | bestDepth, | 271 | bestDepth, |
267 | con->options()->colors256, chosenDepth ); | 272 | con->options()->colors256, chosenDepth ); |
268 | 273 | ||
269 | format->depth = chosenDepth; | 274 | format->depth = chosenDepth; |
270 | 275 | ||
271 | // If we're using the servers native depth | 276 | // If we're using the servers native depth |
272 | if ( chosenDepth == info->depth ) { | 277 | if ( chosenDepth == info->depth ) { |
273 | // Use the servers native format | 278 | // Use the servers native format |
274 | format->bpp = info->bpp; | 279 | format->bpp = info->bpp; |
275 | // format->bigEndian = info->bigEndian; | 280 | // format->bigEndian = info->bigEndian; |
276 | format->bigEndian = true; | 281 | format->bigEndian = true; |
277 | format->trueColor = info->trueColor; | 282 | format->trueColor = info->trueColor; |
278 | format->redMax = info->redMax; | 283 | format->redMax = info->redMax; |
279 | format->greenMax = info->greenMax; | 284 | format->greenMax = info->greenMax; |
280 | format->blueMax = info->blueMax; | 285 | format->blueMax = info->blueMax; |
281 | format->redShift = info->redShift; | 286 | format->redShift = info->redShift; |
282 | format->greenShift = info->greenShift; | 287 | format->greenShift = info->greenShift; |
283 | format->blueShift = info->blueShift; | 288 | format->blueShift = info->blueShift; |
284 | } | 289 | } |
285 | else { | 290 | else { |
286 | if ( chosenDepth == 8 ) { | 291 | if ( chosenDepth == 8 ) { |
287 | format->bpp = 8; | 292 | format->bpp = 8; |
288 | format->bigEndian = true; | 293 | format->bigEndian = true; |
289 | format->trueColor = true; | 294 | format->trueColor = true; |
290 | format->redMax = 7; | 295 | format->redMax = 7; |
291 | format->greenMax = 7; | 296 | format->greenMax = 7; |
292 | format->blueMax = 3; | 297 | format->blueMax = 3; |
293 | format->redShift = 0; | 298 | format->redShift = 0; |
294 | format->greenShift = 3; | 299 | format->greenShift = 3; |
295 | format->blueShift = 6; | 300 | format->blueShift = 6; |
296 | } | 301 | } |
297 | } | 302 | } |
298 | 303 | ||
299 | format->redMax = Swap16IfLE( format->redMax ); | 304 | format->redMax = Swap16IfLE( format->redMax ); |
300 | format->greenMax = Swap16IfLE( format->greenMax ); | 305 | format->greenMax = Swap16IfLE( format->greenMax ); |
301 | format->blueMax = Swap16IfLE( format->blueMax ); | 306 | format->blueMax = Swap16IfLE( format->blueMax ); |
302 | } | 307 | } |
303 | 308 | ||
304 | void KRFBDecoder::sendPixelFormat() | 309 | void KRFBDecoder::sendPixelFormat() |
305 | { | 310 | { |
306 | static char padding[3]; | 311 | static char padding[3]; |
307 | con->write( &SetPixelFormatId, 1 ); | 312 | con->write( &SetPixelFormatId, 1 ); |
308 | con->write( padding, 3 ); | 313 | con->write( padding, 3 ); |
309 | 314 | ||
310 | con->write( &(format->bpp), 1 ); | 315 | con->write( &(format->bpp), 1 ); |
311 | con->write( &(format->depth), 1 ); | 316 | con->write( &(format->depth), 1 ); |
312 | con->write( &(format->bigEndian), 1 ); | 317 | con->write( &(format->bigEndian), 1 ); |
313 | con->write( &(format->trueColor), 1 ); | 318 | con->write( &(format->trueColor), 1 ); |
314 | 319 | ||
315 | con->write( &(format->redMax), 2 ); | 320 | con->write( &(format->redMax), 2 ); |
316 | con->write( &(format->greenMax), 2 ); | 321 | con->write( &(format->greenMax), 2 ); |
317 | con->write( &(format->blueMax), 2 ); | 322 | con->write( &(format->blueMax), 2 ); |
318 | 323 | ||
319 | con->write( &(format->redShift), 1 ); | 324 | con->write( &(format->redShift), 1 ); |
320 | con->write( &(format->greenShift), 1 ); | 325 | con->write( &(format->greenShift), 1 ); |
321 | con->write( &(format->blueShift), 1 ); | 326 | con->write( &(format->blueShift), 1 ); |
322 | con->write( format->padding, 3 ); // Padding | 327 | con->write( format->padding, 3 ); // Padding |
323 | } | 328 | } |
324 | 329 | ||
325 | void KRFBDecoder::sendAllowedEncodings() | 330 | void KRFBDecoder::sendAllowedEncodings() |
326 | { | 331 | { |
327 | static CARD8 padding[1]; | 332 | static CARD8 padding[1]; |
328 | con->write( &SetEncodingsId, 1 ); | 333 | con->write( &SetEncodingsId, 1 ); |
329 | con->write( padding, 1 ); | 334 | con->write( padding, 1 ); |
330 | 335 | ||
331 | CARD16 noEncodings = con->options()->encodings(); | 336 | CARD16 noEncodings = con->options()->encodings(); |
332 | noEncodings = Swap16IfLE( noEncodings ); | 337 | noEncodings = Swap16IfLE( noEncodings ); |
333 | con->write( &noEncodings, 2 ); | 338 | con->write( &noEncodings, 2 ); |
334 | 339 | ||
335 | if ( con->options()->corre ) | 340 | if ( con->options()->corre ) |
336 | con->write( &CorreEncoding, 4 ); | 341 | con->write( &CorreEncoding, 4 ); |
337 | if ( con->options()->hexTile ) | 342 | if ( con->options()->hexTile ) |
338 | con->write( &HexTileEncoding, 4 ); | 343 | con->write( &HexTileEncoding, 4 ); |
339 | if ( con->options()->rre ) | 344 | if ( con->options()->rre ) |
340 | con->write( &RreEncoding, 4 ); | 345 | con->write( &RreEncoding, 4 ); |
341 | if ( con->options()->copyrect ) | 346 | if ( con->options()->copyrect ) |
342 | con->write( &CopyRectEncoding, 4 ); | 347 | con->write( &CopyRectEncoding, 4 ); |
343 | // We always support this | 348 | // We always support this |
344 | con->write( &RawEncoding, 4 ); | 349 | con->write( &RawEncoding, 4 ); |
345 | } | 350 | } |
346 | 351 | ||
347 | void KRFBDecoder::sendUpdateRequest( bool incremental ) | 352 | void KRFBDecoder::sendUpdateRequest( bool incremental ) |
348 | { | 353 | { |
349 | if ( currentState != Idle ) | 354 | if ( currentState != Idle ) |
350 | return; | 355 | return; |
351 | 356 | ||
352 | con->write( &UpdateRequestId, 1 ); | 357 | con->write( &UpdateRequestId, 1 ); |
353 | con->write( &incremental, 1 ); | 358 | con->write( &incremental, 1 ); |
354 | 359 | ||
355 | static CARD16 x = 0, y = 0; | 360 | static CARD16 x = 0, y = 0; |
356 | static CARD16 w = Swap16IfLE( info->width ); | 361 | static CARD16 w = Swap16IfLE( info->width ); |
357 | static CARD16 h = Swap16IfLE( info->height ); | 362 | static CARD16 h = Swap16IfLE( info->height ); |
358 | 363 | ||
359 | con->write( &x, 2 ); | 364 | con->write( &x, 2 ); |
360 | con->write( &y, 2 ); | 365 | con->write( &y, 2 ); |
361 | con->write( &w, 2 ); | 366 | con->write( &w, 2 ); |
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 | ||
370 | void KRFBDecoder::gotUpdateHeader() | 375 | void 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(); |
387 | } | 392 | } |
388 | else if ( msgType == BellId ) { | 393 | else if ( msgType == BellId ) { |
389 | oldState = currentState; | 394 | oldState = currentState; |
390 | gotBell(); | 395 | gotBell(); |
391 | } | 396 | } |
392 | else { | 397 | else { |
393 | int msg = msgType; | 398 | int msg = msgType; |
394 | QString protocolError = tr( "Protocol Error: Message Id %1 was " | 399 | QString protocolError = tr( "Protocol Error: Message Id %1 was " |
395 | "found when expecting an update " | 400 | "found when expecting an update " |
396 | "message." ).arg( msg ); | 401 | "message." ).arg( msg ); |
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 | ||
417 | void KRFBDecoder::gotRectHeader() | 422 | void 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 ); |
434 | h = Swap16IfLE( h ); | 439 | h = Swap16IfLE( h ); |
435 | 440 | ||
436 | con->read( &encoding, 4 ); | 441 | con->read( &encoding, 4 ); |
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 | ||
483 | void KRFBDecoder::handleRawRect() | 488 | void 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 | ||
506 | void KRFBDecoder::getRawRectChunk( int lines ) | 511 | void 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 | ||
519 | void KRFBDecoder::gotRawRectChunk() | 524 | void 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 | } |
562 | } | 567 | } |
563 | 568 | ||
564 | // | 569 | // |
565 | // Copy Rectangle Encoding | 570 | // Copy Rectangle Encoding |
566 | // | 571 | // |
567 | 572 | ||
568 | void KRFBDecoder::handleCopyRect() | 573 | void KRFBDecoder::handleCopyRect() |
569 | { | 574 | { |
570 | currentState = AwaitingCopyRectPos; | 575 | currentState = AwaitingCopyRectPos; |
571 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotCopyRectPos() ) ); | 576 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotCopyRectPos() ) ); |
572 | con->waitForData( CopyRectPosLength ); | 577 | con->waitForData( CopyRectPosLength ); |
573 | } | 578 | } |
574 | 579 | ||
575 | void KRFBDecoder::gotCopyRectPos() | 580 | void KRFBDecoder::gotCopyRectPos() |
576 | { | 581 | { |
577 | disconnect( con, SIGNAL( gotEnoughData() ), | 582 | disconnect( con, SIGNAL( gotEnoughData() ), |
578 | this, SLOT( gotCopyRectPos() ) ); | 583 | this, SLOT( gotCopyRectPos() ) ); |
579 | 584 | ||
580 | CARD16 srcX; | 585 | CARD16 srcX; |
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 | ||
604 | void KRFBDecoder::handleRRERect() | 609 | void KRFBDecoder::handleRRERect() |
605 | { | 610 | { |
606 | qWarning( "RRE not implemented" ); | 611 | owarn << "RRE not implemented" << oendl; |
607 | } | 612 | } |
608 | 613 | ||
609 | void KRFBDecoder::handleCoRRERect() | 614 | void KRFBDecoder::handleCoRRERect() |
610 | { | 615 | { |
611 | qWarning( "CoRRE not implemented" ); | 616 | owarn << "CoRRE not implemented" << oendl; |
612 | } | 617 | } |
613 | 618 | ||
614 | void KRFBDecoder::handleHexTileRect() | 619 | void KRFBDecoder::handleHexTileRect() |
615 | { | 620 | { |
616 | qWarning( "HexTile not implemented" ); | 621 | owarn << "HexTile not implemented" << oendl; |
617 | } | 622 | } |
618 | 623 | ||
619 | void KRFBDecoder::sendMouseEvent( QMouseEvent *e ) | 624 | void 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; |
629 | if ( e->button() & RightButton ) | 634 | if ( e->button() & RightButton ) |
630 | buttonMask |= 0x02; | 635 | buttonMask |= 0x02; |
631 | } | 636 | } |
632 | else if ( e->type() == QEvent::MouseButtonRelease ) { | 637 | else if ( e->type() == QEvent::MouseButtonRelease ) { |
633 | if ( e->button() & LeftButton ) | 638 | if ( e->button() & LeftButton ) |
634 | buttonMask &= 0x06; | 639 | buttonMask &= 0x06; |
635 | if ( e->button() & MidButton ) | 640 | if ( e->button() & MidButton ) |
636 | buttonMask |= 0x03; | 641 | buttonMask |= 0x03; |
637 | if ( e->button() & RightButton ) | 642 | if ( e->button() & RightButton ) |
638 | buttonMask |= 0x05; | 643 | buttonMask |= 0x05; |
639 | } | 644 | } |
640 | } | 645 | } |
641 | 646 | ||
642 | // HACK: Scaling | 647 | // HACK: Scaling |
643 | CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor ); | 648 | CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor ); |
644 | CARD16 y = Swap16IfLE( e->y() *con->options()->scaleFactor ); | 649 | CARD16 y = Swap16IfLE( e->y() *con->options()->scaleFactor ); |
645 | 650 | ||
646 | con->write( &PointerEventId, 1 ); | 651 | con->write( &PointerEventId, 1 ); |
647 | con->write( &buttonMask, 1 ); | 652 | con->write( &buttonMask, 1 ); |
648 | con->write( &x, 2 ); | 653 | con->write( &x, 2 ); |
649 | con->write( &y, 2 ); | 654 | con->write( &y, 2 ); |
650 | } | 655 | } |
651 | 656 | ||
652 | 657 | ||
653 | void KRFBDecoder::sendCutEvent( const QString &unicode ) | 658 | void KRFBDecoder::sendCutEvent( const QString &unicode ) |
654 | { | 659 | { |
655 | // | 660 | // |
656 | // Warning: There is a bug in the RFB protocol because there is no way to find | 661 | // Warning: There is a bug in the RFB protocol because there is no way to find |
657 | // out the codepage in use on the remote machine. This could be fixed by requiring | 662 | // out the codepage in use on the remote machine. This could be fixed by requiring |
658 | // the remote server to use utf8 etc. but for now we have to assume they're the | 663 | // the remote server to use utf8 etc. but for now we have to assume they're the |
659 | // same. I've reported this problem to the ORL guys, but they apparantly have no | 664 | // same. I've reported this problem to the ORL guys, but they apparantly have no |
660 | // immediate plans to fix the issue. :-( (rich) | 665 | // immediate plans to fix the issue. :-( (rich) |
661 | // | 666 | // |
662 | 667 | ||
663 | CARD8 padding[3]; | 668 | CARD8 padding[3]; |
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 | ||
674 | void KRFBDecoder::gotServerCut() | 679 | void 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 | ||
683 | void KRFBDecoder::gotServerCutLength() | 688 | void 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 | ||
689 | CARD8 padding[3]; | 694 | CARD8 padding[3]; |
690 | con->read( padding, 3 ); | 695 | con->read( padding, 3 ); |
691 | 696 | ||
692 | con->read( &serverCutTextLen, 4 ); | 697 | con->read( &serverCutTextLen, 4 ); |
693 | serverCutTextLen = Swap32IfLE( serverCutTextLen ); | 698 | serverCutTextLen = Swap32IfLE( serverCutTextLen ); |
694 | 699 | ||
695 | currentState = AwaitingServerCutText; | 700 | currentState = AwaitingServerCutText; |
696 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutText() ) ); | 701 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutText() ) ); |
697 | con->waitForData( serverCutTextLen ); | 702 | con->waitForData( serverCutTextLen ); |
698 | } | 703 | } |
699 | 704 | ||
700 | void KRFBDecoder::gotServerCutText() | 705 | void KRFBDecoder::gotServerCutText() |
701 | { | 706 | { |
702 | assert( currentState = AwaitingServerCutText ); | 707 | assert( currentState = AwaitingServerCutText ); |
703 | 708 | ||
704 | disconnect( con, SIGNAL( gotEnoughData() ), | 709 | disconnect( con, SIGNAL( gotEnoughData() ), |
705 | this, SLOT( gotServerCutText() ) ); | 710 | this, SLOT( gotServerCutText() ) ); |
706 | 711 | ||
707 | 712 | ||
708 | // | 713 | // |
709 | // Warning: There is a bug in the RFB protocol because there is no way to find | 714 | // Warning: There is a bug in the RFB protocol because there is no way to find |
710 | // out the codepage in use on the remote machine. This could be fixed by requiring | 715 | // out the codepage in use on the remote machine. This could be fixed by requiring |
711 | // the remote server to use utf8 etc. but for now we have to assume they're the | 716 | // the remote server to use utf8 etc. but for now we have to assume they're the |
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 | ||
746 | void KRFBDecoder::gotBell() | 751 | void 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 | ||
766 | void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event ) | 771 | void 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; |
774 | 779 | ||
775 | CARD16 padding = 0; | 780 | CARD16 padding = 0; |
776 | con->write( &KeyEventId, 1 ); | 781 | con->write( &KeyEventId, 1 ); |
777 | con->write( &mask, 1 ); | 782 | con->write( &mask, 1 ); |
778 | con->write( &padding, 2 ); | 783 | con->write( &padding, 2 ); |
779 | con->write( &key, 4 ); | 784 | con->write( &key, 4 ); |
780 | } | 785 | } |
781 | } | 786 | } |
782 | 787 | ||
783 | void KRFBDecoder::sendKeyReleaseEvent( QKeyEvent *event ) | 788 | void KRFBDecoder::sendKeyReleaseEvent( QKeyEvent *event ) |
784 | { | 789 | { |
785 | int key; | 790 | int key; |
786 | key = toKeySym( event ); | 791 | key = toKeySym( event ); |
787 | if ( key ) { | 792 | if ( key ) { |
788 | key = Swap32IfLE( key ); | 793 | key = Swap32IfLE( key ); |
789 | 794 | ||
790 | CARD8 mask = false; | 795 | CARD8 mask = false; |
791 | 796 | ||
792 | CARD16 padding = 0; | 797 | CARD16 padding = 0; |
793 | con->write( &KeyEventId, 1 ); | 798 | con->write( &KeyEventId, 1 ); |
794 | con->write( &mask, 1 ); | 799 | con->write( &mask, 1 ); |
795 | con->write( &padding, 2 ); | 800 | con->write( &padding, 2 ); |
796 | con->write( &key, 4 ); | 801 | con->write( &key, 4 ); |
797 | } | 802 | } |
798 | } | 803 | } |
799 | 804 | ||
800 | 805 | ||
801 | 806 | ||
802 | 807 | ||
803 | // | 808 | // |
804 | // The RFB protocol spec says 'For most ordinary keys, the 'keysym' | 809 | // The RFB protocol spec says 'For most ordinary keys, the 'keysym' |
805 | // is the same as the corresponding ASCII value.', but doesn't | 810 | // is the same as the corresponding ASCII value.', but doesn't |
806 | // elaborate what the most ordinary keys are. The spec also lists | 811 | // elaborate what the most ordinary keys are. The spec also lists |
807 | // a set (possibly subset, it's unspecified) of mappings for | 812 | // a set (possibly subset, it's unspecified) of mappings for |
808 | // "other common keys" (backspace, tab, return, escape, etc). | 813 | // "other common keys" (backspace, tab, return, escape, etc). |
809 | // | 814 | // |
810 | int KRFBDecoder::toKeySym( QKeyEvent *k ) | 815 | int KRFBDecoder::toKeySym( QKeyEvent *k ) |
811 | { | 816 | { |
812 | 817 | ||
813 | // | 818 | // |
814 | // Try and map these "other common keys" first. | 819 | // Try and map these "other common keys" first. |
815 | // | 820 | // |
816 | if ((k->key() >= Qt::Key_Escape) && (k->key() <= Qt::Key_F12)) { | 821 | if ((k->key() >= Qt::Key_Escape) && (k->key() <= Qt::Key_F12)) { |
817 | for(int i = 0; keyMap[i].keycode != 0; i++) { | 822 | for(int i = 0; keyMap[i].keycode != 0; i++) { |
818 | if (k->key() == keyMap[i].keycode) { | 823 | if (k->key() == keyMap[i].keycode) { |
819 | return keyMap[i].keysym; | 824 | return keyMap[i].keysym; |
820 | } | 825 | } |
821 | } | 826 | } |
822 | } | 827 | } |
823 | 828 | ||
824 | // | 829 | // |
825 | // If these keys aren't matched, return the ascii code and let the | 830 | // If these keys aren't matched, return the ascii code and let the |
826 | // server figure it out. We don't return k->key(), as the data in | 831 | // server figure it out. We don't return k->key(), as the data in |
827 | // key differs between input methods, and we don't want special cases. | 832 | // key differs between input methods, and we don't want special cases. |
828 | // | 833 | // |
829 | return k->ascii(); | 834 | return k->ascii(); |
830 | } | 835 | } |
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,253 +1,258 @@ | |||
1 | #include <assert.h> | 1 | #include "krfblogin.h" |
2 | #include "krfbconnection.h" | ||
2 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | using namespace Opie::Core; | ||
7 | |||
8 | /* QT */ | ||
9 | #include <qtimer.h> | ||
3 | 10 | ||
11 | /* STD */ | ||
12 | #include <assert.h> | ||
4 | extern "C" { | 13 | extern "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). |
14 | const int ServerVersionLength = 12; | 19 | const int ServerVersionLength = 12; |
15 | const int ClientVersionLength = 12; | 20 | const int ClientVersionLength = 12; |
16 | const int AuthSchemeLength = 4; | 21 | const int AuthSchemeLength = 4; |
17 | const int FailureReasonSizeLength = 4; | 22 | const int FailureReasonSizeLength = 4; |
18 | const int ChallengeLength = 16; | 23 | const int ChallengeLength = 16; |
19 | const int AuthResultLength = 4; | 24 | const int AuthResultLength = 4; |
20 | 25 | ||
21 | // Authentication results | 26 | // Authentication results |
22 | enum AuthResult { | 27 | enum AuthResult { |
23 | AuthOk, | 28 | AuthOk, |
24 | AuthFailed, | 29 | AuthFailed, |
25 | AuthTooMany | 30 | AuthTooMany |
26 | }; | 31 | }; |
27 | 32 | ||
28 | typedef unsigned char CARD8; | 33 | typedef unsigned char CARD8; |
29 | typedef unsigned short CARD16; | 34 | typedef unsigned short CARD16; |
30 | typedef unsigned long CARD32; | 35 | typedef unsigned long CARD32; |
31 | 36 | ||
32 | const int endianTest = 1; | 37 | const int endianTest = 1; |
33 | 38 | ||
34 | // Endian stuff | 39 | // Endian stuff |
35 | #define Swap16IfLE(s) \ | 40 | #define Swap16IfLE(s) \ |
36 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) | 41 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) |
37 | 42 | ||
38 | #define Swap32IfLE(l) \ | 43 | #define Swap32IfLE(l) \ |
39 | (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ | 44 | (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ |
40 | (((l) & 0x00ff0000) >> 8) | \ | 45 | (((l) & 0x00ff0000) >> 8) | \ |
41 | (((l) & 0x0000ff00) << 8) | \ | 46 | (((l) & 0x0000ff00) << 8) | \ |
42 | (((l) & 0x000000ff) << 24)) : (l)) | 47 | (((l) & 0x000000ff) << 24)) : (l)) |
43 | 48 | ||
44 | KRFBLogin::KRFBLogin( KRFBConnection *con ) | 49 | KRFBLogin::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 | ||
65 | KRFBLogin::~KRFBLogin() | 70 | KRFBLogin::~KRFBLogin() |
66 | { | 71 | { |
67 | 72 | ||
68 | } | 73 | } |
69 | 74 | ||
70 | KRFBLogin::State KRFBLogin::state() const | 75 | KRFBLogin::State KRFBLogin::state() const |
71 | { | 76 | { |
72 | return currentState; | 77 | return currentState; |
73 | } | 78 | } |
74 | 79 | ||
75 | void KRFBLogin::gotServerVersion() | 80 | void 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 | ||
132 | void KRFBLogin::gotAuthScheme() | 137 | void 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 | ||
168 | void KRFBLogin::gotChallenge() | 173 | void 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 | ||
176 | void KRFBLogin::getPassword() | 181 | void 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() ); |
197 | con->write( challenge, ChallengeLength ); | 202 | con->write( challenge, ChallengeLength ); |
198 | 203 | ||
199 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotAuthResult() ) ); | 204 | connect( con, SIGNAL( gotEnoughData() ), SLOT( gotAuthResult() ) ); |
200 | con->waitForData( AuthResultLength ); | 205 | con->waitForData( AuthResultLength ); |
201 | } | 206 | } |
202 | 207 | ||
203 | void KRFBLogin::gotFailureReasonSize() | 208 | void KRFBLogin::gotFailureReasonSize() |
204 | { | 209 | { |
205 | disconnect( con, SIGNAL( gotEnoughData() ), this, | 210 | disconnect( con, SIGNAL( gotEnoughData() ), this, |
206 | SLOT( gotFailureReasonSize() ) ); | 211 | SLOT( gotFailureReasonSize() ) ); |
207 | } | 212 | } |
208 | 213 | ||
209 | void KRFBLogin::gotAuthResult() | 214 | void 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 | ||
249 | void KRFBLogin::sendClientVersion() | 254 | void 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,209 +1,215 @@ | |||
1 | #include "kvncbookmarkdlg.h" | ||
2 | |||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | #include <qpe/global.h> | ||
6 | using 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 | ||
7 | KVNCBookmarkDlg::KVNCBookmarkDlg( QWidget * parent, const char * name, WFlags f ) | 13 | KVNCBookmarkDlg::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 | ||
16 | KVNCBookmarkDlg::~KVNCBookmarkDlg() | 22 | KVNCBookmarkDlg::~KVNCBookmarkDlg() |
17 | { | 23 | { |
18 | } | 24 | } |
19 | 25 | ||
20 | void KVNCBookmarkDlg::addBookmark(KRFBServer * server) | 26 | void KVNCBookmarkDlg::addBookmark(KRFBServer * server) |
21 | { | 27 | { |
22 | if (server) { | 28 | if (server) { |
23 | servers.append(server); | 29 | servers.append(server); |
24 | bookmarkList->insertItem(server->name); | 30 | bookmarkList->insertItem(server->name); |
25 | writeBookmarks(); | 31 | writeBookmarks(); |
26 | refresh(); | 32 | refresh(); |
27 | } | 33 | } |
28 | } | 34 | } |
29 | 35 | ||
30 | void KVNCBookmarkDlg::deleteBookmark(QString name) | 36 | void KVNCBookmarkDlg::deleteBookmark(QString name) |
31 | { | 37 | { |
32 | KRFBServer * server=0; | 38 | KRFBServer * server=0; |
33 | for ( server=servers.first(); server != 0; server=servers.next() ) { | 39 | for ( server=servers.first(); server != 0; server=servers.next() ) { |
34 | if (server->name==name) { | 40 | if (server->name==name) { |
35 | servers.remove(servers.at()); | 41 | servers.remove(servers.at()); |
36 | writeBookmarks(); | 42 | writeBookmarks(); |
37 | refresh(); | 43 | refresh(); |
38 | return; | 44 | return; |
39 | } | 45 | } |
40 | } | 46 | } |
41 | } | 47 | } |
42 | KRFBServer *KVNCBookmarkDlg::getServer(QString name) | 48 | KRFBServer *KVNCBookmarkDlg::getServer(QString name) |
43 | { | 49 | { |
44 | KRFBServer * server=0; | 50 | KRFBServer * server=0; |
45 | for ( server=servers.first(); server != 0; server=servers.next() ) { | 51 | for ( server=servers.first(); server != 0; server=servers.next() ) { |
46 | if (server->name==name) | 52 | if (server->name==name) |
47 | 53 | ||
48 | return server; | 54 | return server; |
49 | } | 55 | } |
50 | return 0; | 56 | return 0; |
51 | } | 57 | } |
52 | 58 | ||
53 | 59 | ||
54 | /* | 60 | /* |
55 | Note that the degree of protection offered by the encryption here is | 61 | Note that the degree of protection offered by the encryption here is |
56 | only sufficient to avoid the most casual observation of the configuration | 62 | only sufficient to avoid the most casual observation of the configuration |
57 | files. People with access to the files can write down the contents and | 63 | files. People with access to the files can write down the contents and |
58 | decrypt it using this source code. | 64 | decrypt it using this source code. |
59 | 65 | ||
60 | Conceivably, and at some burden to the user, this encryption could | 66 | Conceivably, and at some burden to the user, this encryption could |
61 | be improved. | 67 | be improved. |
62 | */ | 68 | */ |
63 | QString KVNCBookmarkDlg::encipher(const QString& plain) | 69 | QString KVNCBookmarkDlg::encipher(const QString& plain) |
64 | { | 70 | { |
65 | // mainly, we make it long | 71 | // mainly, we make it long |
66 | QString cipher; | 72 | QString cipher; |
67 | int mix=28730492; | 73 | int mix=28730492; |
68 | for (int i=0; i<(int)plain.length(); i++) { | 74 | for (int i=0; i<(int)plain.length(); i++) { |
69 | int u = plain[i].unicode(); | 75 | int u = plain[i].unicode(); |
70 | int c = u ^ mix; | 76 | int c = u ^ mix; |
71 | QString x = QString::number(c,36); | 77 | QString x = QString::number(c,36); |
72 | cipher.append(QChar('a'+x.length())); | 78 | cipher.append(QChar('a'+x.length())); |
73 | cipher.append(x); | 79 | cipher.append(x); |
74 | mix *= u; | 80 | mix *= u; |
75 | } | 81 | } |
76 | return cipher; | 82 | return cipher; |
77 | } | 83 | } |
78 | 84 | ||
79 | QString KVNCBookmarkDlg::decipher(const QString& cipher) | 85 | QString KVNCBookmarkDlg::decipher(const QString& cipher) |
80 | { | 86 | { |
81 | QString plain; | 87 | QString plain; |
82 | int mix=28730492; | 88 | int mix=28730492; |
83 | for (int i=0; i<(int)cipher.length();) { | 89 | for (int i=0; i<(int)cipher.length();) { |
84 | int l = cipher[i].unicode()-'a'; | 90 | int l = cipher[i].unicode()-'a'; |
85 | QString x = cipher.mid(i+1,l); i+=l+1; | 91 | QString x = cipher.mid(i+1,l); i+=l+1; |
86 | int u = x.toInt(0,36) ^ mix; | 92 | int u = x.toInt(0,36) ^ mix; |
87 | plain.append(QChar(u)); | 93 | plain.append(QChar(u)); |
88 | mix *= u; | 94 | mix *= u; |
89 | } | 95 | } |
90 | return plain; | 96 | return plain; |
91 | } | 97 | } |
92 | 98 | ||
93 | void KVNCBookmarkDlg::readBookmarks(void) | 99 | void KVNCBookmarkDlg::readBookmarks(void) |
94 | { | 100 | { |
95 | QFile f(QDir::homeDirPath() + QString("/Applications/keypebble/bookmarks")); | 101 | QFile f(QDir::homeDirPath() + QString("/Applications/keypebble/bookmarks")); |
96 | 102 | ||
97 | QStringList entry; | 103 | QStringList entry; |
98 | QString key, val; | 104 | QString key, val; |
99 | KRFBServer * server=0; | 105 | KRFBServer * server=0; |
100 | 106 | ||
101 | if ( f.open(IO_ReadOnly) ) { | 107 | if ( f.open(IO_ReadOnly) ) { |
102 | QTextStream t( &f ); | 108 | QTextStream t( &f ); |
103 | QString s; | 109 | QString s; |
104 | int n = 1; | 110 | int n = 1; |
105 | while ( !t.eof() ) { | 111 | while ( !t.eof() ) { |
106 | s = t.readLine(); | 112 | s = t.readLine(); |
107 | 113 | ||
108 | 114 | ||
109 | entry=QStringList::split('=',s); | 115 | entry=QStringList::split('=',s); |
110 | key=entry[0].stripWhiteSpace().lower(); | 116 | key=entry[0].stripWhiteSpace().lower(); |
111 | val=entry[1].stripWhiteSpace(); | 117 | val=entry[1].stripWhiteSpace(); |
112 | 118 | ||
113 | if (key=="server") { | 119 | if (key=="server") { |
114 | 120 | ||
115 | if (server){ | 121 | if (server){ |
116 | servers.append(server); | 122 | servers.append(server); |
117 | server=0; | 123 | server=0; |
118 | } | 124 | } |
119 | server = new KRFBServer(); | 125 | server = new KRFBServer(); |
120 | 126 | ||
121 | if (!server) | 127 | if (!server) |
122 | return; | 128 | return; |
123 | server->name=val; | 129 | server->name=val; |
124 | 130 | ||
125 | } | 131 | } |
126 | else if (key=="hostname") | 132 | else if (key=="hostname") |
127 | server->hostname=val; | 133 | server->hostname=val; |
128 | else if (key=="password") | 134 | else if (key=="password") |
129 | server->password=decipher(val); | 135 | server->password=decipher(val); |
130 | else if (key=="display") | 136 | else if (key=="display") |
131 | server->display=val.toInt(); | 137 | server->display=val.toInt(); |
132 | else if (key=="hextile") | 138 | else if (key=="hextile") |
133 | server->hexTile=val.toInt(); | 139 | server->hexTile=val.toInt(); |
134 | else if (key=="corre") | 140 | else if (key=="corre") |
135 | server->corre=val.toInt(); | 141 | server->corre=val.toInt(); |
136 | else if (key=="rre") | 142 | else if (key=="rre") |
137 | server->rre=val.toInt(); | 143 | server->rre=val.toInt(); |
138 | else if (key=="copyrect") | 144 | else if (key=="copyrect") |
139 | server->copyrect=val.toInt(); | 145 | server->copyrect=val.toInt(); |
140 | else if (key=="colors256") | 146 | else if (key=="colors256") |
141 | server->colors256=val.toInt(); | 147 | server->colors256=val.toInt(); |
142 | else if (key=="shared") | 148 | else if (key=="shared") |
143 | server->shared=val.toInt(); | 149 | server->shared=val.toInt(); |
144 | else if (key=="readonly") | 150 | else if (key=="readonly") |
145 | server->readOnly=val.toInt(); | 151 | server->readOnly=val.toInt(); |
146 | else if (key=="deiconify") | 152 | else if (key=="deiconify") |
147 | server->deIconify=val.toInt(); | 153 | server->deIconify=val.toInt(); |
148 | else if (key=="updaterate") | 154 | else if (key=="updaterate") |
149 | server->updateRate=val.toInt(); | 155 | server->updateRate=val.toInt(); |
150 | else if (key=="scalefactor") | 156 | else if (key=="scalefactor") |
151 | server->scaleFactor=val.toInt(); | 157 | server->scaleFactor=val.toInt(); |
152 | 158 | ||
153 | } | 159 | } |
154 | if (server){ | 160 | if (server){ |
155 | servers.append(server); | 161 | servers.append(server); |
156 | server=0; | 162 | server=0; |
157 | } | 163 | } |
158 | f.close(); | 164 | f.close(); |
159 | } | 165 | } |
160 | } | 166 | } |
161 | 167 | ||
162 | void KVNCBookmarkDlg::writeBookmarks(void) | 168 | void KVNCBookmarkDlg::writeBookmarks(void) |
163 | { | 169 | { |
164 | QString filename=Global::applicationFileName("keypebble","bookmarks"); | 170 | QString filename=Global::applicationFileName("keypebble","bookmarks"); |
165 | 171 | ||
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'; |
191 | t << "\tscalefactor=" << server->scaleFactor << '\n'; | 197 | t << "\tscalefactor=" << server->scaleFactor << '\n'; |
192 | 198 | ||
193 | } | 199 | } |
194 | f.close(); | 200 | f.close(); |
195 | } | 201 | } |
196 | } | 202 | } |
197 | void KVNCBookmarkDlg::refresh(void) | 203 | void KVNCBookmarkDlg::refresh(void) |
198 | { | 204 | { |
199 | bookmarkList->clear(); | 205 | bookmarkList->clear(); |
200 | KRFBServer * server=0; | 206 | KRFBServer * server=0; |
201 | for ( server=servers.first(); server != 0; server=servers.next() ) { | 207 | for ( server=servers.first(); server != 0; server=servers.next() ) { |
202 | bookmarkList->insertItem(server->name); | 208 | bookmarkList->insertItem(server->name); |
203 | } | 209 | } |
204 | } | 210 | } |
205 | 211 | ||
206 | QString KVNCBookmarkDlg::selectedBookmark() | 212 | QString KVNCBookmarkDlg::selectedBookmark() |
207 | { | 213 | { |
208 | return bookmarkList->currentText(); | 214 | return bookmarkList->currentText(); |
209 | } | 215 | } |