summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/keypebble.pro16
-rw-r--r--noncore/comm/keypebble/krfbbuffer.cpp33
-rw-r--r--noncore/comm/keypebble/krfbcanvas.cpp39
-rw-r--r--noncore/comm/keypebble/krfbcanvas.h6
-rw-r--r--noncore/comm/keypebble/krfbconnection.cpp272
-rw-r--r--noncore/comm/keypebble/krfbconnection.h19
-rw-r--r--noncore/comm/keypebble/krfbdecoder.cpp3
-rw-r--r--noncore/comm/keypebble/krfblogin.cpp8
-rw-r--r--noncore/comm/keypebble/krfboptions.cpp56
-rw-r--r--noncore/comm/keypebble/krfboptions.h31
-rw-r--r--noncore/comm/keypebble/krfbserver.cpp39
-rw-r--r--noncore/comm/keypebble/kvnc.cpp168
-rw-r--r--noncore/comm/keypebble/kvnc.h14
-rw-r--r--noncore/comm/keypebble/kvncbookmarkdlg.cpp220
-rw-r--r--noncore/comm/keypebble/kvncconndlg.cpp75
-rw-r--r--noncore/comm/keypebble/kvncconnectdlg.cpp79
-rw-r--r--noncore/comm/keypebble/kvncconnectdlg.h39
-rw-r--r--noncore/comm/keypebble/kvncoptionsdlg.cpp54
-rw-r--r--noncore/comm/keypebble/kvncoptionsdlg.h30
-rw-r--r--noncore/comm/keypebble/main.cpp4
20 files changed, 682 insertions, 523 deletions
diff --git a/noncore/comm/keypebble/keypebble.pro b/noncore/comm/keypebble/keypebble.pro
index a102381..1017133 100644
--- a/noncore/comm/keypebble/keypebble.pro
+++ b/noncore/comm/keypebble/keypebble.pro
@@ -7,11 +7,12 @@ HEADERS = d3des.h \
7 krfbconnection.h \ 7 krfbconnection.h \
8 krfbdecoder.h \ 8 krfbdecoder.h \
9 krfblogin.h \ 9 krfblogin.h \
10 krfboptions.h \ 10 krfbserver.h \
11 krfbserverinfo.h \ 11 krfbserverinfo.h \
12 kvnc.h \ 12 kvnc.h \
13 kvncconnectdlg.h \ 13 kvncconndlg.h \
14 kvncoptionsdlg.h \ 14 kvncbookmarkdlg.h \
15 version.h \
15 vncauth.h 16 vncauth.h
16 SOURCES = d3des.c \ 17 SOURCES = d3des.c \
17 vncauth.c \ 18 vncauth.c \
@@ -20,12 +21,13 @@ SOURCES = d3des.c \
20 krfbconnection.cpp \ 21 krfbconnection.cpp \
21 krfbdecoder.cpp \ 22 krfbdecoder.cpp \
22 krfblogin.cpp \ 23 krfblogin.cpp \
23 krfboptions.cpp \ 24 krfbserver.cpp \
24 kvnc.cpp \ 25 kvnc.cpp \
25 kvncconnectdlg.cpp \ 26 kvncconndlg.cpp \
26 kvncoptionsdlg.cpp \ 27 kvncbookmarkdlg.cpp \
27 main.cpp 28 main.cpp
28 INTERFACES= vncoptionsbase.ui 29 INTERFACES= kvncconndlgbase.ui \
30 kvncbookmarkdlgbase.ui
29TARGET = keypebble 31TARGET = keypebble
30INCLUDEPATH += $(OPIEDIR)/include 32INCLUDEPATH += $(OPIEDIR)/include
31DEPENDPATH += $(OPIEDIR)/include 33DEPENDPATH += $(OPIEDIR)/include
diff --git a/noncore/comm/keypebble/krfbbuffer.cpp b/noncore/comm/keypebble/krfbbuffer.cpp
index 4885261..5a52f31 100644
--- a/noncore/comm/keypebble/krfbbuffer.cpp
+++ b/noncore/comm/keypebble/krfbbuffer.cpp
@@ -150,7 +150,38 @@ void KRFBBuffer::drawRawRectChunk( void *data,
150 *p = qRgb( r,g,b ); 150 *p = qRgb( r,g,b );
151 } 151 }
152 } 152 }
153 } 153 } else if (decoder->format->bpp == 16 ) {
154
155 CARD16 *d = (CARD16 *) data;
156
157 uint r,g,b;
158
159 for ( int j = 0; j < h; j++ ) {
160 for ( int i = 0; i < w ; i++ ) {
161 CARD16 pixel = d[ j * w + i ];
162 pixel = Swap16IfLE( pixel );
163
164 r = pixel;
165 r = r >> decoder->format->redShift;
166 r = r & redMax;
167
168 g = pixel;
169 g = g >> decoder->format->greenShift;
170 g = g & greenMax;
171
172 b = pixel;
173 b = b >> decoder->format->blueShift;
174 b = b & blueMax;
175
176 r = ( r * 255 ) / redMax;
177 g = ( g * 255 ) / greenMax;
178 b = ( b * 255 ) / blueMax;
179
180 ulong *p = ( ulong * ) img.scanLine( j ) + i;
181 *p = qRgb( r,g,b );
182 }
183 }
184 }
154 else { 185 else {
155 p.setBrush( QBrush( Qt::black ) ); 186 p.setBrush( QBrush( Qt::black ) );
156 p.drawRect( x, y, w, h ); 187 p.drawRect( x, y, w, h );
diff --git a/noncore/comm/keypebble/krfbcanvas.cpp b/noncore/comm/keypebble/krfbcanvas.cpp
index f74ab7b..8b56795 100644
--- a/noncore/comm/keypebble/krfbcanvas.cpp
+++ b/noncore/comm/keypebble/krfbcanvas.cpp
@@ -1,10 +1,10 @@
1#include "kvncconnectdlg.h"
2#include "krfbconnection.h" 1#include "krfbconnection.h"
3#include "krfbcanvas.h" 2#include "krfbcanvas.h"
4#include "krfboptions.h" 3#include "krfbserver.h"
5#include "krfbbuffer.h" 4#include "krfbbuffer.h"
6 5
7#include <qpe/config.h> 6#include <qpe/config.h>
7#include <qpe/qpeapplication.h>
8 8
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qclipboard.h> 10#include <qclipboard.h>
@@ -18,12 +18,11 @@ KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name )
18 : QScrollView( parent, name ) 18 : QScrollView( parent, name )
19{ 19{
20 connection_ = new KRFBConnection(); 20 connection_ = new KRFBConnection();
21 connect( connection_, SIGNAL( passwordRequired( KRFBConnection * ) ),
22 this, SLOT( passwordRequired( KRFBConnection * ) ) );
23 connect( connection_, SIGNAL( loggedIn() ), 21 connect( connection_, SIGNAL( loggedIn() ),
24 this, SLOT( loggedIn() ) ); 22 this, SLOT( loggedIn() ) );
25 23
26 loggedIn_ = false; 24 loggedIn_ = false;
25 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold);
27 26
28 viewport()->setFocusPolicy( QWidget::StrongFocus ); 27 viewport()->setFocusPolicy( QWidget::StrongFocus );
29 viewport()->setFocus(); 28 viewport()->setFocus();
@@ -33,16 +32,17 @@ KRFBCanvas::~KRFBCanvas()
33{ 32{
34} 33}
35 34
36void KRFBCanvas::openConnection() 35
36void KRFBCanvas::openConnection(KRFBServer server)
37{ 37{
38 KVNCConnectDlg dlg( connection_, this, "connect dialog" ); 38
39 if ( dlg.exec() ) { 39
40 QCString host = dlg.hostname().latin1(); 40 QCString host = server.hostname.latin1();
41 password = dlg.password(); 41 password=server.password;
42 connection_->connectTo( host, dlg.display() ); 42 connection_->connectTo( server);
43 }
44} 43}
45 44
45
46void KRFBCanvas::openURL( const QUrl &url ) 46void KRFBCanvas::openURL( const QUrl &url )
47{ 47{
48 if ( loggedIn_ ) { 48 if ( loggedIn_ ) {
@@ -52,10 +52,8 @@ void KRFBCanvas::openURL( const QUrl &url )
52 52
53 QCString host = url.host().latin1(); 53 QCString host = url.host().latin1();
54 int display = url.port(); 54 int display = url.port();
55 if ( url.hasPassword() )
56 connection_->setPassword( url.password().latin1() );
57 55
58 connection_->connectTo( host, display ); 56// connection_->connectTo( host, display );
59} 57}
60 58
61void KRFBCanvas::closeConnection() 59void KRFBCanvas::closeConnection()
@@ -69,10 +67,6 @@ void KRFBCanvas::closeConnection()
69 update(); 67 update();
70} 68}
71 69
72void KRFBCanvas::passwordRequired( KRFBConnection *con )
73{
74 con->setPassword( password.latin1() );
75}
76 70
77void KRFBCanvas::bell() 71void KRFBCanvas::bell()
78{ 72{
@@ -167,3 +161,12 @@ void KRFBCanvas::clipboardChanged()
167 connection_->sendCutText( qApp->clipboard()->text() ); 161 connection_->sendCutText( qApp->clipboard()->text() );
168 } 162 }
169} 163}
164void KRFBCanvas::sendCtlAltDel( void)
165{
166
167 qDebug("Here");
168 if ( loggedIn_ ) {
169 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Delete, 0x7f,ControlButton|AltButton));
170 // connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Delete, 0x7f,ControlButton|AltButton));
171 }
172}
diff --git a/noncore/comm/keypebble/krfbcanvas.h b/noncore/comm/keypebble/krfbcanvas.h
index 7864f1c..cd3047c 100644
--- a/noncore/comm/keypebble/krfbcanvas.h
+++ b/noncore/comm/keypebble/krfbcanvas.h
@@ -7,6 +7,7 @@
7#include <qurl.h> 7#include <qurl.h>
8 8
9class KRFBConnection; 9class KRFBConnection;
10class KRFBServer;
10 11
11/** 12/**
12 * Displays data from an KRFBDecoder, and sends events to the 13 * Displays data from an KRFBDecoder, and sends events to the
@@ -23,13 +24,14 @@ public:
23 KRFBConnection *connection() { return connection_; }; 24 KRFBConnection *connection() { return connection_; };
24 25
25public slots: 26public slots:
26 void openConnection(); 27
28 void openConnection (KRFBServer);
27 void openURL( const QUrl & ); 29 void openURL( const QUrl & );
28 void closeConnection(); 30 void closeConnection();
29 void passwordRequired( KRFBConnection * );
30 31
31 void refresh(); 32 void refresh();
32 void bell(); 33 void bell();
34 void sendCtlAltDel(void);
33 35
34protected: 36protected:
35 virtual void keyPressEvent( QKeyEvent * ); 37 virtual void keyPressEvent( QKeyEvent * );
diff --git a/noncore/comm/keypebble/krfbconnection.cpp b/noncore/comm/keypebble/krfbconnection.cpp
index c51f18a..389c836 100644
--- a/noncore/comm/keypebble/krfbconnection.cpp
+++ b/noncore/comm/keypebble/krfbconnection.cpp
@@ -5,238 +5,230 @@
5 5
6#include "krfbconnection.h" 6#include "krfbconnection.h"
7#include "krfblogin.h" 7#include "krfblogin.h"
8#include "krfboptions.h" 8#include "krfbserver.h"
9#include "krfbdecoder.h" 9#include "krfbdecoder.h"
10#include "krfbbuffer.h" 10#include "krfbbuffer.h"
11 11
12KRFBConnection::KRFBConnection( QObject *parent ) 12KRFBConnection::KRFBConnection( QObject *parent )
13 : QObject( parent, "KRFBConnection" ) 13 : QObject( parent, "KRFBConnection" )
14{ 14{
15 portBase_ = 5900; 15 portBase_ = 5900;
16 currentState_ = Disconnected; 16 currentState_ = Disconnected;
17 sock = 0; 17 sock = 0;
18 minData_ = 0; 18 minData_ = 0;
19 options_ = new KRFBOptions(); 19 options_ = new KRFBServer();
20 updater = 0; 20 updater = 0;
21 decoder_ = 0; 21 decoder_ = 0;
22 buffer_ = 0; 22 buffer_ = 0;
23} 23}
24 24
25KRFBConnection::~KRFBConnection() 25KRFBConnection::~KRFBConnection()
26{ 26{
27 if ( ( currentState_ != Disconnected ) && ( currentState_ != Disconnecting ) && sock ) { 27 if ( ( currentState_ != Disconnected ) && ( currentState_ != Disconnecting ) && sock ) {
28 disconnectDone(); 28 disconnectDone();
29 } 29 }
30 delete options_; 30 delete options_;
31} 31}
32 32
33void KRFBConnection::connectTo( const QCString &host, int display ) 33void KRFBConnection::connectTo( KRFBServer server)
34{ 34{
35 if ( currentState_ != Disconnected ); 35 if ( currentState_ != Disconnected )
36 disconnect(); 36 disconnect();
37
38 (*options_)=server;
37 39
38 this->host_= host; 40 sock = new QSocket( this, "rfbSocket" );
39 this->display_ = display; 41 CHECK_PTR( sock );
40 42
41 sock = new QSocket( this, "rfbSocket" ); 43 // Connect to something to notice connection or error
42 CHECK_PTR( sock ); 44 connect( sock, SIGNAL( error( int ) ), SLOT( gotSocketError( int ) ) );
45 connect( sock, SIGNAL( connected() ), SLOT( gotSocketConnection() ) );
43 46
44 // Connect to something to notice connection or error 47 qWarning( "Connecting..." );
45 connect( sock, SIGNAL( error( int ) ), SLOT( gotSocketError( int ) ) );
46 connect( sock, SIGNAL( connected() ), SLOT( gotSocketConnection() ) );
47 48
48 qWarning( "Connecting..." ); 49 currentState_ = Connecting;
49 50 sock->connectToHost( options_->hostname.latin1(), portBase_ + options_->display );
50 currentState_ = Connecting;
51 sock->connectToHost( host_, portBase_ + display_ );
52} 51}
53 52
54void KRFBConnection::disconnect() 53void KRFBConnection::disconnect()
55{ 54{
56 qWarning( "Disconnecting from server" ); 55 qWarning( "Disconnecting from server" );
57 56
58 if ( ( currentState_ != Disconnected ) 57 if ( ( currentState_ != Disconnected )
59 && ( currentState_ != Disconnecting ) 58 && ( currentState_ != Disconnecting )
60 && sock ) { 59 && sock ) {
61 currentState_ = Disconnecting; 60 currentState_ = Disconnecting;
62 61
63 connect( sock, SIGNAL( delayedCloseFinished() ), SLOT( disconnectDone() ) ); 62 connect( sock, SIGNAL( delayedCloseFinished() ), SLOT( disconnectDone() ) );
64 sock->close(); 63 sock->close();
65 64
66 if ( sock->state() != QSocket::Closing ) 65 if ( sock->state() != QSocket::Closing )
67 disconnectDone(); 66 disconnectDone();
68 } 67 }
69} 68}
70 69
71void KRFBConnection::disconnectDone() 70void KRFBConnection::disconnectDone()
72{ 71{
73 qWarning( "KRFBConnection disconnected" ); 72 currentState_ = Disconnected;
74 currentState_ = Disconnected; 73 delete sock;
75 delete sock; 74 sock = 0;
76 sock = 0; 75 minData_ = 0;
77 minData_ = 0; 76 delete updater;
78 delete updater; 77 delete decoder_;
79 delete decoder_; 78 delete buffer_;
80 delete buffer_; 79 emit disconnected();
81 emit disconnected();
82} 80}
83 81
84void KRFBConnection::gotSocketConnection() 82void KRFBConnection::gotSocketConnection()
85{ 83{
86 currentState_ = LoggingIn; 84 currentState_ = LoggingIn;
87 85
88 qWarning( "Connected, logging in..." ); 86 qWarning( "Connected, logging in..." );
89 87
90 static QString statusMsg = tr( "Connected" ); 88 static QString statusMsg = tr( "Connected" );
91 emit statusChanged( statusMsg ); 89 emit statusChanged( statusMsg );
92 90
93 // Do some login stuff 91 // Do some login stuff
94 login = new KRFBLogin( this ); 92 login = new KRFBLogin( this );
95} 93}
96 94
97void KRFBConnection::gotRFBConnection() 95void KRFBConnection::gotRFBConnection()
98{ 96{
99 qWarning( "Logged into server" ); 97 qWarning( "Logged into server" );
100 98
101 currentState_ = Connected; 99 currentState_ = Connected;
102 emit connected(); 100 emit connected();
103 101
104 // Create the decoder and start doing stuff 102 // Create the decoder and start doing stuff
105 decoder_ = new KRFBDecoder( this ); 103 decoder_ = new KRFBDecoder( this );
106 CHECK_PTR( decoder_ ); 104 CHECK_PTR( decoder_ );
107 105
108 buffer_ = new KRFBBuffer( decoder_, this, "RFB Buffer" ); 106 buffer_ = new KRFBBuffer( decoder_, this, "RFB Buffer" );
109 CHECK_PTR( buffer_ ); 107 CHECK_PTR( buffer_ );
110 decoder_->setBuffer( buffer_ ); 108 decoder_->setBuffer( buffer_ );
111 109
112 connect( decoder_, SIGNAL( status( const QString & ) ), 110 connect( decoder_, SIGNAL( status( const QString & ) ),
113 this, SIGNAL( statusChanged( const QString & ) ) ); 111 this, SIGNAL( statusChanged( const QString & ) ) );
114 emit loggedIn(); 112 emit loggedIn();
115 113
116 decoder_->start(); 114 decoder_->start();
117 115
118 updater = new QTimer; 116 updater = new QTimer;
119 connect( updater, SIGNAL( timeout() ), SLOT( updateTimer() ) ); 117 connect( updater, SIGNAL( timeout() ), SLOT( updateTimer() ) );
120 updater->start( options_->updateRate ); 118 updater->start( options_->updateRate );
121} 119}
122 120
123void KRFBConnection::gotSocketError( int err ) 121void KRFBConnection::gotSocketError( int err )
124{ 122{
125 currentState_ = Error; 123 currentState_ = Error;
126 124
127 // Do some error handling stuff 125 // Do some error handling stuff
128 qWarning( "KRFBConnection: Socket error %d", err ); 126 qWarning( "KRFBConnection: Socket error %d", err );
129 127
130 static QString refused = tr( "Connection Refused" ); 128 static QString refused = tr( "Connection Refused" );
131 static QString host = tr( "Host not found" ); 129 static QString host = tr( "Host not found" );
132 static QString read = tr( "Read Error: QSocket reported an error reading\n" 130 static QString read = tr( "Read Error: QSocket reported an error reading\n"
133 "data, the remote host has probably dropped the\n" 131 "data, the remote host has probably dropped the\n"
134 "connection." ); 132 "connection." );
135 static QString confused = tr( "QSocket reported an invalid error code" ); 133 static QString confused = tr( "QSocket reported an invalid error code" );
136 134
137 QString msg; 135 QString msg;
138 switch ( err ) { 136 switch ( err ) {
139 case QSocket::ErrConnectionRefused: 137 case QSocket::ErrConnectionRefused:
140 msg = refused; 138 msg = refused;
141 break; 139 break;
142 case QSocket::ErrHostNotFound: 140 case QSocket::ErrHostNotFound:
143 msg = host; 141 msg = host;
144 break; 142 break;
145 case QSocket::ErrSocketRead: 143 case QSocket::ErrSocketRead:
146 msg = read; 144 msg = read;
147 break; 145 break;
148 default: 146 default:
149 msg = confused; 147 msg = confused;
150 }; 148 };
151 149
152 QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) ); 150 QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) );
153 delete sock; 151 delete sock;
154 sock = 0; 152 sock = 0;
155 currentState_ = Disconnected; 153 currentState_ = Disconnected;
156 154
157 emit error( msg ); 155 emit error( msg );
158} 156}
159 157
160void KRFBConnection::gotMoreData() 158void KRFBConnection::gotMoreData()
161{ 159{
162 assert( minData_ > 0 ); 160 assert( minData_ > 0 );
163 161
164 if ( sock->size() >= minData_ ) { 162 if ( sock->size() >= minData_ ) {
165 minData_ = 0; 163 minData_ = 0;
166 QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) ); 164 QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) );
167 emit gotEnoughData(); 165 emit gotEnoughData();
168 } 166 }
169} 167}
170 168
171void KRFBConnection::waitForData( unsigned int sz ) 169void KRFBConnection::waitForData( unsigned int sz )
172{ 170{
173 assert( minData_ == 0 ); 171 assert( minData_ == 0 );
174 assert( sz > 0 ); 172 assert( sz > 0 );
175 assert( currentState_ != Error ); 173 assert( currentState_ != Error );
176 174
177 if ( sock->size() >= sz ) { 175 if ( sock->size() >= sz ) {
178 // qWarning( "No need to wait for data" ); 176 // qWarning( "No need to wait for data" );
179 emit gotEnoughData(); 177 emit gotEnoughData();
180 } 178 }
181 else { 179 else {
182 // qWarning( "Waiting for %u bytes", sz ); 180 // qWarning( "Waiting for %u bytes", sz );
183 181 minData_ = sz;
184 minData_ = sz; 182 connect( sock, SIGNAL( readyRead() ), SLOT( gotMoreData() ) );
185 connect( sock, SIGNAL( readyRead() ), SLOT( gotMoreData() ) ); 183 }
186 }
187} 184}
188 185
189int KRFBConnection::read( void *buf, int sz ) 186int KRFBConnection::read( void *buf, int sz )
190{ 187{
191 return sock->readBlock( (char *) buf, sz ); 188 return sock->readBlock( (char *) buf, sz );
192} 189}
193 190
194int KRFBConnection::write( void *buf, int sz ) 191int KRFBConnection::write( void *buf, int sz )
195{ 192{
196 return sock->writeBlock( (const char *) buf, sz ); 193 return sock->writeBlock( (const char *) buf, sz );
197} 194}
198 195
199KRFBConnection::State KRFBConnection::state() const 196KRFBConnection::State KRFBConnection::state() const
200{ 197{
201 return currentState_; 198 return currentState_;
202} 199}
203 200
204void KRFBConnection::setPortBase( int base ) 201void KRFBConnection::setPortBase( int base )
205{ 202{
206 portBase_ = base; 203 portBase_ = base;
207} 204}
208 205
209int KRFBConnection::portBase() const 206int KRFBConnection::portBase() const
210{ 207{
211 return portBase_; 208 return portBase_;
212}
213
214void KRFBConnection::setPassword( const QCString &pass )
215{
216 this->pass_ = pass;
217} 209}
218 210
219void KRFBConnection::updateTimer() 211void KRFBConnection::updateTimer()
220{ 212{
221 decoder_->sendUpdateRequest( true ); 213 decoder_->sendUpdateRequest( true );
222} 214}
223 215
224void KRFBConnection::refresh() 216void KRFBConnection::refresh()
225{ 217{
226 decoder_->sendUpdateRequest( false ); 218 decoder_->sendUpdateRequest( false );
227} 219}
228 220
229void KRFBConnection::sendCutText( const QString &text ) 221void KRFBConnection::sendCutText( const QString &text )
230{ 222{
231 decoder_->sendCutEvent( text ); 223 decoder_->sendCutEvent( text );
232} 224}
233 225
234const QUrl &KRFBConnection::url() 226const QUrl &KRFBConnection::url()
235{ 227{
236 url_.setProtocol( "vnc" ); 228 url_.setProtocol( "vnc" );
237 url_.setPort( display() ); 229 url_.setPort( display() );
238 url_.setHost( host() ); 230 url_.setHost( host() );
239 url_.setPath( "/" ); 231 url_.setPath( "/" );
240 232
241 return url_; 233 return url_;
242} 234}
diff --git a/noncore/comm/keypebble/krfbconnection.h b/noncore/comm/keypebble/krfbconnection.h
index fe477c1..a8d3457 100644
--- a/noncore/comm/keypebble/krfbconnection.h
+++ b/noncore/comm/keypebble/krfbconnection.h
@@ -6,11 +6,12 @@
6#include <qobject.h> 6#include <qobject.h>
7#include <qstring.h> 7#include <qstring.h>
8#include <qcstring.h> 8#include <qcstring.h>
9#include "krfbserver.h"
9#include <qurl.h> 10#include <qurl.h>
10 11
11class KRFBLogin; 12class KRFBLogin;
12class KRBUpdateHandler; 13class KRBUpdateHandler;
13class KRFBOptions; 14class KRFBServer;
14class QSocket; 15class QSocket;
15class KRFBDecoder; 16class KRFBDecoder;
16class KRFBBuffer; 17class KRFBBuffer;
@@ -45,7 +46,7 @@ public:
45 State state() const; 46 State state() const;
46 47
47 //* Get the options for this connection 48 //* Get the options for this connection
48 KRFBOptions *options() const { return options_; }; 49 KRFBServer *options() const { return options_; };
49 50
50 KRFBBuffer *buffer() const { return buffer_; }; 51 KRFBBuffer *buffer() const { return buffer_; };
51 52
@@ -57,20 +58,17 @@ public:
57 //* Get the base from which the port for a given display is calculated. 58 //* Get the base from which the port for a given display is calculated.
58 int portBase() const; 59 int portBase() const;
59 60
60 //* Set the password which will be used to login
61 void setPassword( const QCString &pass );
62
63 //* Open a connection 61 //* Open a connection
64 void connectTo( const QCString &host, int display ); 62 void connectTo( KRFBServer);
65 63
66 //* Close the connection 64 //* Close the connection
67 void disconnect(); 65 void disconnect();
68 66
69 //* Get the host 67 //* Get the host
70 const QCString host() const { return host_; }; 68 const QCString host() const { return options_->hostname.latin1(); };
71 69
72 //* Get the display 70 //* Get the display
73 int display() const { return display_; }; 71 int display() const { return options_->display; };
74 72
75 //* Get the current host/display as a URL 73 //* Get the current host/display as a URL
76 const QUrl &url(); 74 const QUrl &url();
@@ -133,17 +131,14 @@ private:
133 int write( void *buf, int sz ); 131 int write( void *buf, int sz );
134 132
135private: 133private:
136 QCString host_;
137 int portBase_; 134 int portBase_;
138 int display_;
139 QCString pass_;
140 QSocket *sock; 135 QSocket *sock;
141 State currentState_; 136 State currentState_;
142 unsigned int minData_; 137 unsigned int minData_;
143 QTimer *updater; 138 QTimer *updater;
144 KRFBLogin *login; 139 KRFBLogin *login;
145 KRFBDecoder *decoder_; 140 KRFBDecoder *decoder_;
146 KRFBOptions *options_; 141 KRFBServer *options_;
147 KRFBBuffer *buffer_; 142 KRFBBuffer *buffer_;
148 QUrl url_; 143 QUrl url_;
149}; 144};
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp
index 174dd7b..a964c09 100644
--- a/noncore/comm/keypebble/krfbdecoder.cpp
+++ b/noncore/comm/keypebble/krfbdecoder.cpp
@@ -1,5 +1,5 @@
1#include "krfbconnection.h" 1#include "krfbconnection.h"
2#include "krfboptions.h" 2#include "krfbserver.h"
3#include "krfbserverinfo.h" 3#include "krfbserverinfo.h"
4#include "krfbdecoder.h" 4#include "krfbdecoder.h"
5#include "krfbbuffer.h" 5#include "krfbbuffer.h"
@@ -796,6 +796,7 @@ void KRFBDecoder::sendKeyReleaseEvent( QKeyEvent *event )
796 } 796 }
797} 797}
798 798
799
799int KRFBDecoder::toKeySym( QKeyEvent *k ) 800int KRFBDecoder::toKeySym( QKeyEvent *k )
800{ 801{
801 int ke = 0; 802 int ke = 0;
diff --git a/noncore/comm/keypebble/krfblogin.cpp b/noncore/comm/keypebble/krfblogin.cpp
index cc3a8fa..0d2a205 100644
--- a/noncore/comm/keypebble/krfblogin.cpp
+++ b/noncore/comm/keypebble/krfblogin.cpp
@@ -52,8 +52,6 @@ KRFBLogin::KRFBLogin( KRFBConnection *con )
52 connect( this, SIGNAL( error( const QString & ) ), 52 connect( this, SIGNAL( error( const QString & ) ),
53 con, SIGNAL( error( const QString & ) ) ); 53 con, SIGNAL( error( const QString & ) ) );
54 54
55 connect( this, SIGNAL( passwordRequired( KRFBConnection * ) ),
56 con, SIGNAL( passwordRequired( KRFBConnection * ) ) );
57 55
58 qWarning( "Waiting for server version..." ); 56 qWarning( "Waiting for server version..." );
59 57
@@ -183,12 +181,12 @@ void KRFBLogin::getPassword()
183 con->read( challenge, ChallengeLength ); 181 con->read( challenge, ChallengeLength );
184 182
185 // Last chance to enter a password 183 // Last chance to enter a password
186 if ( con->pass_.isNull() ) { 184 if ( con->options_->password.isNull() ) {
187 qWarning( "krfblogin needs a password" ); 185 qWarning( "krfblogin needs a password" );
188 emit passwordRequired( con ); 186 emit passwordRequired( con );
189 } 187 }
190 188
191 if ( con->pass_.isNull() ) { 189 if ( con->options_->password.isNull() ) {
192 QString msg = tr( "Error: This server requires a password, but none " 190 QString msg = tr( "Error: This server requires a password, but none "
193 "has been specified.\n" ); 191 "has been specified.\n" );
194 192
@@ -196,7 +194,7 @@ void KRFBLogin::getPassword()
196 return; 194 return;
197 } 195 }
198 196
199 vncEncryptBytes( (unsigned char *) challenge, con->pass_.data() ); 197 vncEncryptBytes( (unsigned char *) challenge, QCString(con->options_->password.latin1()).data() );
200 con->write( challenge, ChallengeLength ); 198 con->write( challenge, ChallengeLength );
201 199
202 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotAuthResult() ) ); 200 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotAuthResult() ) );
diff --git a/noncore/comm/keypebble/krfboptions.cpp b/noncore/comm/keypebble/krfboptions.cpp
deleted file mode 100644
index 8c4320b..0000000
--- a/noncore/comm/keypebble/krfboptions.cpp
+++ b/dev/null
@@ -1,56 +0,0 @@
1#include <qpe/config.h>
2#include <qpe/qpeapplication.h>
3#include "krfboptions.h"
4
5KRFBOptions::KRFBOptions()
6{
7 readSettings();
8}
9
10KRFBOptions::~KRFBOptions()
11{
12 writeSettings();
13}
14
15void KRFBOptions::readSettings()
16{
17 Config config( "keypebble" );
18 config.setGroup("Settings");
19 hexTile = config.readBoolEntry( "HexTile", 0 );
20 corre = config.readBoolEntry( "CORRE", 0 );
21 rre = config.readBoolEntry( "RRE", 0 );
22 copyrect = config.readBoolEntry( "CopyRect", 1 );
23 colors256 = config.readBoolEntry( "Colors256", 0 );
24 shared = config.readBoolEntry( "Shared", 0 );
25 readOnly = config.readBoolEntry( "ReadOnly", 0 );
26 updateRate = config.readNumEntry( "UpdateRate", 50 );
27 deIconify = config.readBoolEntry( "DeIconify", 0 );
28}
29
30void KRFBOptions::writeSettings()
31{
32 Config config( "keypebble" );
33 config.setGroup("Settings");
34 config.writeEntry( "HexTile", hexTile );
35 config.writeEntry( "CORRE", corre );
36 config.writeEntry( "RRE", rre );
37 config.writeEntry( "CopyRect", copyrect );
38 config.writeEntry( "Colors256", colors256 );
39 config.writeEntry( "Shared", shared );
40 config.writeEntry( "ReadOnly", readOnly );
41 config.writeEntry( "UpdateRate", updateRate );
42 config.writeEntry( "DeIconify", deIconify );
43}
44
45int KRFBOptions::encodings()
46{
47 // Initially one because we always support raw encoding
48 int count = 1;
49
50 count += hexTile ? 1 : 0;
51 count += corre ? 1 : 0;
52 count += rre ? 1 : 0;
53 count += copyrect ? 1 : 0;
54
55 return count;
56}
diff --git a/noncore/comm/keypebble/krfboptions.h b/noncore/comm/keypebble/krfboptions.h
deleted file mode 100644
index fd2b65c..0000000
--- a/noncore/comm/keypebble/krfboptions.h
+++ b/dev/null
@@ -1,31 +0,0 @@
1// -*- c++ -*-
2
3#ifndef KRFBOPTIONS_H
4#define KRFBOPTIONS_H
5
6class Config;
7
8class KRFBOptions
9{
10public:
11 KRFBOptions();
12 ~KRFBOptions();
13
14 int encodings();
15 void readSettings();
16 void writeSettings();
17
18 bool hexTile;
19 bool corre;
20 bool rre;
21 bool copyrect;
22
23 bool colors256;
24 bool shared;
25 bool readOnly;
26 bool deIconify;
27
28 int updateRate;
29};
30
31#endif // KRFBOPTIONS_H
diff --git a/noncore/comm/keypebble/krfbserver.cpp b/noncore/comm/keypebble/krfbserver.cpp
new file mode 100644
index 0000000..5775f09
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbserver.cpp
@@ -0,0 +1,39 @@
1#include <qpe/config.h>
2#include <qpe/qpeapplication.h>
3#include "krfbserver.h"
4
5KRFBServer::KRFBServer()
6{
7 QString name;
8 QString hostname;
9 QString password;
10 display=0;
11
12 hexTile=0;
13 corre=0;
14 rre=0;
15 copyrect=1;
16
17 colors256=1;
18 shared=0;
19 readOnly=0;
20 deIconify=0;
21
22 updateRate=0;
23}
24KRFBServer::~KRFBServer()
25{
26}
27
28int KRFBServer::encodings()
29{
30 // Initially one because we always support raw encoding
31 int count = 1;
32
33 count += hexTile ? 1 : 0;
34 count += corre ? 1 : 0;
35 count += rre ? 1 : 0;
36 count += copyrect ? 1 : 0;
37
38 return count;
39}
diff --git a/noncore/comm/keypebble/kvnc.cpp b/noncore/comm/keypebble/kvnc.cpp
index 43cffc5..aa46e2f 100644
--- a/noncore/comm/keypebble/kvnc.cpp
+++ b/noncore/comm/keypebble/kvnc.cpp
@@ -10,14 +10,27 @@
10#include <qpe/qpetoolbar.h> 10#include <qpe/qpetoolbar.h>
11#include <qtimer.h> 11#include <qtimer.h>
12#include <qmessagebox.h> 12#include <qmessagebox.h>
13#include <qspinbox.h>
14#include <qlistbox.h>
15#include <qlineedit.h>
13#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
14#include <qpe/global.h> 17#include <qpe/global.h>
18#include <qpe/qpetoolbar.h>
19#include <qpe/resource.h>
20
15#include <assert.h> 21#include <assert.h>
16 22
17#include "kvnc.h" 23#include "kvnc.h"
18#include "krfbcanvas.h" 24#include "krfbcanvas.h"
19#include "kvncoptionsdlg.h"
20#include "krfbconnection.h" 25#include "krfbconnection.h"
26#include "kvncconndlg.h"
27#include "krfbserver.h"
28
29static int u_id = 1;
30static int get_unique_id()
31{
32 return u_id++;
33}
21 34
22 35
23/* XPM */ 36/* XPM */
@@ -48,9 +61,19 @@ KVNC::KVNC( const char *name ) : QMainWindow( 0, name )
48 setCaption( tr("VNC Viewer") ); 61 setCaption( tr("VNC Viewer") );
49 fullscreen = false; 62 fullscreen = false;
50 63
51 canvas = new KRFBCanvas( this, "canvas" ); 64 stack = new QWidgetStack( this );
52 setCentralWidget( canvas ); 65 setCentralWidget( stack );
53 66
67 bookmarkSelector=new KVNCBookmarkDlg();
68 stack->addWidget(bookmarkSelector,get_unique_id());
69 stack->raiseWidget( bookmarkSelector );
70
71 canvas = new KRFBCanvas( stack, "canvas" );
72 stack->addWidget(canvas,get_unique_id());
73 setCentralWidget( stack );
74
75 connect( bookmarkSelector->bookmarkList, SIGNAL(doubleClicked(QListBoxItem *)),
76 this, SLOT(openConnection(QListBoxItem *)) );
54 connect( canvas->connection(), SIGNAL(statusChanged(const QString &)), 77 connect( canvas->connection(), SIGNAL(statusChanged(const QString &)),
55 this, SLOT(statusMessage(const QString &)) ); 78 this, SLOT(statusMessage(const QString &)) );
56 connect( canvas->connection(), SIGNAL(error(const QString &)), 79 connect( canvas->connection(), SIGNAL(error(const QString &)),
@@ -66,16 +89,73 @@ KVNC::KVNC( const char *name ) : QMainWindow( 0, name )
66 connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) ); 89 connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) );
67 canvas->setCornerWidget( cornerButton ); 90 canvas->setCornerWidget( cornerButton );
68 91
69 QTimer::singleShot( 0, canvas, SLOT(openConnection()) ); 92 stack->raiseWidget( bookmarkSelector );
93
94
95 QPEToolBar *bar = new QPEToolBar( this );
96
97 QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ),
98 QString::null, 0, this, 0 );
99 connect( n, SIGNAL( activated() ),
100 this, SLOT( newConnection() ) );
101 n->addTo( bar );
102
103 QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "edit" ),
104 QString::null, 0, this, 0 );
105 connect( o, SIGNAL( activated() ),
106 this, SLOT( openConnection() ) );
107 o->addTo( bar );
108
109 QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ),
110 QString::null, 0, this, 0 );
111 connect( d, SIGNAL( activated() ),
112 this, SLOT( deleteBookmark() ) );
113 d->addTo( bar );
70} 114}
71 115
72KVNC::~KVNC() 116KVNC::~KVNC()
73{ 117{
118
119}
120
121void KVNC::newConnection()
122{
123 curServer=new KRFBServer;
124
125 KVNCConnDlg dlg( curServer,this);
126 dlg.showMaximized();
127 if (dlg.exec()) {
128 if (!curServer->name.isEmpty())
129 bookmarkSelector->addBookmark(curServer);
130 canvas->openConnection(*curServer);
131 } else
132 curServer=0;
133}
134
135void KVNC::openConnection( QString name)
136{
137 curServer=bookmarkSelector->getServer(name);
138
139 if (curServer) {
140 KVNCConnDlg dlg( curServer,this);
141 dlg.showMaximized();
142
143 if ( dlg.exec() ) {
144 canvas->openConnection(*curServer);
145 bookmarkSelector->writeBookmarks();
146 } else
147 curServer=0;
148 }
149}
150
151void KVNC::openConnection( void )
152{
153 openConnection( bookmarkSelector->selectedBookmark());
74} 154}
75 155
76void KVNC::openURL( const QUrl &url ) 156void KVNC::openConnection( QListBoxItem * item)
77{ 157{
78 canvas->openURL( url ); 158 openConnection(item->text());
79} 159}
80 160
81void KVNC::setupActions() 161void KVNC::setupActions()
@@ -88,14 +168,11 @@ void KVNC::setupActions()
88 fullScreenAction->addTo( cornerMenu ); 168 fullScreenAction->addTo( cornerMenu );
89 fullScreenAction->setEnabled( false ); 169 fullScreenAction->setEnabled( false );
90 170
91 optionsAction = new QAction( tr("Settings"), QString::null, 0, 0 ); 171 ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 );
92 connect( optionsAction, SIGNAL(activated()), this, SLOT( showOptions() ) ); 172 connect( ctlAltDelAction, SIGNAL(activated()),
93 optionsAction->addTo( cornerMenu ); 173 canvas, SLOT( sendCtlAltDel() ) );
94 174 ctlAltDelAction->addTo( cornerMenu );
95 connectAction = new QAction( tr("Connect..."), QString::null, 0, 0 ); 175 ctlAltDelAction->setEnabled( false );
96 connect( connectAction, SIGNAL(activated()),
97 canvas, SLOT( openConnection() ) );
98 connectAction->addTo( cornerMenu );
99 176
100 disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 ); 177 disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 );
101 connect( disconnectAction, SIGNAL(activated()), 178 connect( disconnectAction, SIGNAL(activated()),
@@ -106,26 +183,31 @@ void KVNC::setupActions()
106 183
107void KVNC::toggleFullScreen() 184void KVNC::toggleFullScreen()
108{ 185{
109 if ( fullscreen ) { 186 if ( fullscreen ) {
110 canvas->releaseKeyboard(); 187 canvas->releaseKeyboard();
111 canvas->reparent( this, 0, QPoint(0,0), false ); 188 canvas->reparent( stack, 0, QPoint(0,0), false );
112 canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 189 canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken );
113 setCentralWidget( canvas ); 190 setCentralWidget( stack );
114 canvas->show(); 191 stack->addWidget(canvas,get_unique_id());
115 fullScreenAction->setText( tr("Full Screen") ); 192 stack->raiseWidget(canvas);
116 } else { 193 canvas->show();
117 canvas->setFrameStyle( QFrame::NoFrame ); 194 stack->show();
118 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, 195 fullScreenAction->setText( tr("Full Screen") );
119 QPoint(0,0),false); 196 } else {
120 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height()); 197 canvas->setFrameStyle( QFrame::NoFrame );
121 canvas->raise(); 198 stack->removeWidget(canvas);
122 canvas->setFocus(); 199 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop,
123 canvas->grabKeyboard(); 200 QPoint(0,0),false);
124 canvas->show(); 201 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height());
125 202 canvas->raise();
126 fullScreenAction->setText( tr("Stop Full Screen") ); 203 canvas->setFocus();
127 } 204 canvas->grabKeyboard();
128 205 canvas->show();
206
207 fullScreenAction->setText( tr("Stop Full Screen") );
208 }
209
210
129 fullscreen = !fullscreen; 211 fullscreen = !fullscreen;
130} 212}
131 213
@@ -149,9 +231,10 @@ void KVNC::connected()
149{ 231{
150 static QString msg = tr( "Connected to remote host" ); 232 static QString msg = tr( "Connected to remote host" );
151 statusMessage( msg ); 233 statusMessage( msg );
152 connectAction->setEnabled( false ); 234 ctlAltDelAction->setEnabled(true);
153 disconnectAction->setEnabled( true ); 235 disconnectAction->setEnabled( true );
154 fullScreenAction->setEnabled( true ); 236 fullScreenAction->setEnabled( true );
237 stack->raiseWidget(canvas);
155} 238}
156 239
157void KVNC::loggedIn() 240void KVNC::loggedIn()
@@ -162,11 +245,15 @@ void KVNC::loggedIn()
162 245
163void KVNC::disconnected() 246void KVNC::disconnected()
164{ 247{
248
249 if ( fullscreen )
250 toggleFullScreen();
165 static QString msg = tr( "Connection closed" ); 251 static QString msg = tr( "Connection closed" );
166 statusMessage( msg ); 252 statusMessage( msg );
167 connectAction->setEnabled( true ); 253 ctlAltDelAction->setEnabled(false);
168 disconnectAction->setEnabled( false ); 254 disconnectAction->setEnabled( false );
169 fullScreenAction->setEnabled( false ); 255 fullScreenAction->setEnabled( false );
256 stack->raiseWidget(bookmarkSelector);
170} 257}
171 258
172void KVNC::statusMessage( const QString &m ) 259void KVNC::statusMessage( const QString &m )
@@ -179,12 +266,7 @@ void KVNC::error( const QString &msg )
179 statusMessage( msg ); 266 statusMessage( msg );
180 QMessageBox::warning( this, tr("VNC Viewer"), msg ); 267 QMessageBox::warning( this, tr("VNC Viewer"), msg );
181} 268}
182 269void KVNC::deleteBookmark(void)
183void KVNC::showOptions()
184{ 270{
185 KVNCOptionsDlg *wdg = new KVNCOptionsDlg( canvas->connection()->options(), this ); 271 bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark());
186 wdg->showMaximized();
187 wdg->exec();
188 delete wdg;
189} 272}
190
diff --git a/noncore/comm/keypebble/kvnc.h b/noncore/comm/keypebble/kvnc.h
index 92666c5..6e0a385 100644
--- a/noncore/comm/keypebble/kvnc.h
+++ b/noncore/comm/keypebble/kvnc.h
@@ -5,6 +5,8 @@
5 5
6#include <qmainwindow.h> 6#include <qmainwindow.h>
7#include <qurl.h> 7#include <qurl.h>
8#include <qwidgetstack.h>
9#include "kvncbookmarkdlg.h"
8 10
9class QAction; 11class QAction;
10class KRFBCanvas; 12class KRFBCanvas;
@@ -25,10 +27,13 @@ public:
25 ~KVNC(); 27 ~KVNC();
26 28
27public slots: 29public slots:
30 void newConnection();
31 void deleteBookmark();
32 void openConnection(QListBoxItem *);
33 void openConnection(QString);
34 void openConnection(void);
28 void toggleFullScreen(); 35 void toggleFullScreen();
29 void openURL( const QUrl & );
30 void closeConnection(); 36 void closeConnection();
31 void showOptions();
32 37
33protected: 38protected:
34 void setupActions(); 39 void setupActions();
@@ -50,7 +55,12 @@ private:
50 QAction *fullScreenAction; 55 QAction *fullScreenAction;
51 QAction *optionsAction; 56 QAction *optionsAction;
52 QAction *disconnectAction; 57 QAction *disconnectAction;
58 QAction *ctlAltDelAction;;
53 QAction *connectAction; 59 QAction *connectAction;
60
61 KVNCBookmarkDlg * bookmarkSelector;
62 QWidgetStack * stack;
63 KRFBServer * curServer;
54}; 64};
55 65
56#endif // KVNC_H 66#endif // KVNC_H
diff --git a/noncore/comm/keypebble/kvncbookmarkdlg.cpp b/noncore/comm/keypebble/kvncbookmarkdlg.cpp
new file mode 100644
index 0000000..1f97d13
--- a/dev/null
+++ b/noncore/comm/keypebble/kvncbookmarkdlg.cpp
@@ -0,0 +1,220 @@
1#include <qframe.h>
2#include <qvbox.h>
3#include <qcheckbox.h>
4#include <qspinbox.h>
5#include <qlabel.h>
6#include <qlayout.h>
7#include <qwhatsthis.h>
8#include <qfile.h>
9#include <qdir.h>
10#include <qstring.h>
11#include <qapplication.h>
12#include <qlineedit.h>
13#include <qtextstream.h>
14#include <qpushbutton.h>
15#include <qlistbox.h>
16#include <qpe/config.h>
17#include <qpe/global.h>
18#include "krfbserver.h"
19#include "kvncbookmarkdlg.h"
20
21KVNCBookmarkDlg::KVNCBookmarkDlg( QWidget * parent=0, const char * name=0, WFlags f=0 )
22
23: KVNCBookmarkDlgBase( parent, name,f)
24{
25 readBookmarks();
26 refresh();
27
28}
29
30KVNCBookmarkDlg::~KVNCBookmarkDlg()
31{
32}
33
34void KVNCBookmarkDlg::addBookmark(KRFBServer * server)
35{
36 if (server) {
37 servers.append(server);
38 bookmarkList->insertItem(server->name);
39 writeBookmarks();
40 refresh();
41 }
42}
43
44void KVNCBookmarkDlg::deleteBookmark(QString name)
45{
46 KRFBServer * server=0;
47 for ( server=servers.first(); server != 0; server=servers.next() ) {
48 if (server->name==name) {
49 servers.remove(servers.at());
50 writeBookmarks();
51 refresh();
52 return;
53 }
54 }
55}
56KRFBServer *KVNCBookmarkDlg::getServer(QString name)
57{
58 KRFBServer * server=0;
59 for ( server=servers.first(); server != 0; server=servers.next() ) {
60 if (server->name==name)
61
62 return server;
63 }
64 return 0;
65}
66
67
68/*
69 Note that the degree of protection offered by the encryption here is
70 only sufficient to avoid the most casual observation of the configuration
71 files. People with access to the files can write down the contents and
72 decrypt it using this source code.
73
74 Conceivably, and at some burden to the user, this encryption could
75 be improved.
76*/
77QString KVNCBookmarkDlg::encipher(const QString& plain)
78{
79 // mainly, we make it long
80 QString cipher;
81 int mix=28730492;
82 for (int i=0; i<(int)plain.length(); i++) {
83 int u = plain[i].unicode();
84 int c = u ^ mix;
85 QString x = QString::number(c,36);
86 cipher.append(QChar('a'+x.length()));
87 cipher.append(x);
88 mix *= u;
89 }
90 return cipher;
91}
92
93QString KVNCBookmarkDlg::decipher(const QString& cipher)
94{
95 QString plain;
96 int mix=28730492;
97 for (int i=0; i<(int)cipher.length();) {
98 int l = cipher[i].unicode()-'a';
99 QString x = cipher.mid(i+1,l); i+=l+1;
100 int u = x.toInt(0,36) ^ mix;
101 plain.append(QChar(u));
102 mix *= u;
103 }
104 return plain;
105}
106
107void KVNCBookmarkDlg::readBookmarks(void)
108{
109 QFile f(QDir::homeDirPath() + QString("/Applications/keypebble/bookmarks"));
110
111 QStringList entry;
112 QString key, val;
113 KRFBServer * server=0;
114
115 if ( f.open(IO_ReadOnly) ) {
116 QTextStream t( &f );
117 QString s;
118 int n = 1;
119 while ( !t.eof() ) {
120 s = t.readLine();
121
122
123 entry=QStringList::split('=',s);
124 key=entry[0].stripWhiteSpace().lower();
125 val=entry[1].stripWhiteSpace();
126
127 if (key=="server") {
128
129 if (server){
130 servers.append(server);
131 server=0;
132 }
133 server = new KRFBServer();
134
135 if (!server)
136 return;
137 server->name=val;
138
139 }
140 else if (key=="hostname")
141 server->hostname=val;
142 else if (key=="password")
143 server->password=decipher(val);
144 else if (key=="display")
145 server->display=val.toInt();
146 else if (key=="hextile")
147 server->hexTile=val.toInt();
148 else if (key=="corre")
149 server->corre=val.toInt();
150 else if (key=="rre")
151 server->rre=val.toInt();
152 else if (key=="copyrect")
153 server->copyrect=val.toInt();
154 else if (key=="colors256")
155 server->colors256=val.toInt();
156 else if (key=="shared")
157 server->shared=val.toInt();
158 else if (key=="readonly")
159 server->readOnly=val.toInt();
160 else if (key=="deiconify")
161 server->deIconify=val.toInt();
162 else if (key=="updaterate")
163 server->updateRate=val.toInt();
164
165 }
166 if (server){
167 servers.append(server);
168 server=0;
169 }
170 f.close();
171 }
172}
173
174void KVNCBookmarkDlg::writeBookmarks(void)
175{
176 QString filename=Global::applicationFileName("keypebble","bookmarks");
177
178 QFile f(filename);
179
180 QString key, val;
181 KRFBServer * server=0;
182
183 if ( f.open(IO_ReadWrite) ) {
184 QTextStream t( &f );
185 QString s;
186 int n = 1;
187 KRFBServer *server;
188
189 for ( server=servers.first(); server != 0; server=servers.next() ) {
190 qDebug(server->name);
191 t << "server=" << server->name << '\n';
192 t << "\thostname=" << server->hostname << '\n';
193 t << "\tpassword=" << encipher(server->password )<< '\n';
194 t << "\tdisplay=" << server->display << '\n';
195 t << "\thextile=" << server->hexTile << '\n';
196 t << "\tcorre=" << server->corre << '\n';
197 t << "\trre=" << server->rre << '\n';
198 t << "\tcopyrect=" << server->copyrect << '\n';
199 t << "\tshared=" << server->shared << '\n';
200 t << "\treadonly=" << server->readOnly << '\n';
201 t << "\tdeiconify=" << server->deIconify << '\n';
202 t << "\tupdaterate=" << server->updateRate << '\n';
203
204 }
205 f.close();
206 }
207}
208void KVNCBookmarkDlg::refresh(void)
209{
210 bookmarkList->clear();
211 KRFBServer * server=0;
212 for ( server=servers.first(); server != 0; server=servers.next() ) {
213 bookmarkList->insertItem(server->name);
214 }
215}
216
217QString KVNCBookmarkDlg::selectedBookmark()
218{
219 return bookmarkList->currentText();
220}
diff --git a/noncore/comm/keypebble/kvncconndlg.cpp b/noncore/comm/keypebble/kvncconndlg.cpp
new file mode 100644
index 0000000..6873feb
--- a/dev/null
+++ b/noncore/comm/keypebble/kvncconndlg.cpp
@@ -0,0 +1,75 @@
1#include <qframe.h>
2#include <qvbox.h>
3#include <qcheckbox.h>
4#include <qspinbox.h>
5#include <qlabel.h>
6#include <qlayout.h>
7#include <qwhatsthis.h>
8#include <qapplication.h>
9#include <qlineedit.h>
10#include <qpushbutton.h>
11#include "krfbserver.h"
12
13#include "kvncconndlg.h"
14
15KVNCConnDlg::KVNCConnDlg( KRFBServer *options,
16 QWidget *parent, char *name, bool modal )
17: KVNCConnDlgBase( parent, name, modal )
18{
19 this->options=options;
20 tmpOptions=*options;
21
22 serverHostname->setText(options->hostname);
23 serverDisplay->setValue(options->display);
24 serverPassword->setText(options->password);
25 serverBookmark->setText(options->name);
26
27 hex->setChecked( options->hexTile );
28 corre->setChecked( options->corre );
29 rre->setChecked( options->rre );
30 copyRect->setChecked( options->copyrect );
31
32 // TODO
33 hex->setEnabled( false );
34 corre->setEnabled( false );
35 rre->setEnabled( false );
36 // /TODO
37
38 deIconify->setChecked( options->deIconify );
39 bit->setChecked( options->colors256 );
40 shared->setChecked( options->shared );
41 timeBox->setValue( options->updateRate );
42
43
44}
45
46KVNCConnDlg::~KVNCConnDlg()
47{
48}
49
50void KVNCConnDlg::accept()
51{
52 save();
53 QDialog::accept();
54}
55
56void KVNCConnDlg::save()
57{
58 tmpOptions.hexTile = hex->isChecked();
59 tmpOptions.corre = corre->isChecked();
60 tmpOptions.rre = rre->isChecked();
61 tmpOptions.copyrect = copyRect->isChecked();
62 tmpOptions.deIconify = deIconify->isChecked();
63 tmpOptions.colors256 = bit->isChecked();
64 tmpOptions.shared = shared->isChecked();
65 tmpOptions.hostname = serverHostname->text();
66 tmpOptions.password = serverPassword->text();
67 tmpOptions.display = serverDisplay->value();
68 tmpOptions.name = serverBookmark->text();
69
70 if (!serverBookmark->text().isEmpty()) {
71 if ( options) {
72 *options=tmpOptions;
73 }
74 }
75}
diff --git a/noncore/comm/keypebble/kvncconnectdlg.cpp b/noncore/comm/keypebble/kvncconnectdlg.cpp
deleted file mode 100644
index 467cebf..0000000
--- a/noncore/comm/keypebble/kvncconnectdlg.cpp
+++ b/dev/null
@@ -1,79 +0,0 @@
1#include <qstring.h>
2#include <qlayout.h>
3#include <qframe.h>
4#include <qspinbox.h>
5#include <qcombobox.h>
6#include <qlabel.h>
7#include <qfont.h>
8
9#include <assert.h>
10
11#include "krfbconnection.h"
12#include "kvncoptionsdlg.h"
13#include "kvncconnectdlg.h"
14
15
16KVNCConnectDlg::KVNCConnectDlg( KRFBConnection *con,
17 QWidget *parent, const char *name )
18 : QDialog( parent, name, true )
19{
20 setCaption( tr("Connect to VNC server") );
21 assert( con );
22 this->con = con;
23
24 QGridLayout *inner = new QGridLayout( this, 3, 2, 6 );
25
26 QLabel *label = new QLabel( tr("Host Name:"),
27 this , "hostLabel");
28 hostNameCombo = new QComboBox( true, this );
29 hostNameCombo->setInsertionPolicy( QComboBox::AtTop );
30 hostNameCombo->setMaxCount( 10 );
31 hostNameCombo->insertItem( "localhost" );
32 hostNameCombo->setFocus();
33
34 inner->addWidget( label, 0, 0 );
35 inner->addWidget( hostNameCombo, 0, 1 );
36
37 label = new QLabel( tr("Display Number:"), this, "displayNumber" );
38 displayNumberEdit = new QSpinBox( this );
39
40 inner->addWidget( label, 1, 0 );
41 inner->addWidget( displayNumberEdit, 1, 1 );
42
43 // if ( viewer->display() != -1 ) {
44 // displayNumberEdit->setValue( viewer->display() );
45 displayNumberEdit->setValue( 1 );
46 // }
47
48 label = new QLabel( tr("Password:"), this );
49 inner->addWidget( label, 2, 0 );
50
51 passwordEdit = new QLineEdit( this );
52 passwordEdit->setEchoMode( QLineEdit::Password );
53 inner->addWidget( passwordEdit, 2, 1 );
54
55 inner->setColStretch( 0, 0 );
56 inner->setColStretch( 1, 15 );
57}
58
59
60void KVNCConnectDlg::accept()
61{
62 int dis;
63 // viewer->setHost(hostNameCombo->currentText());
64 QString temp = displayNumberEdit->text();
65 if(temp.isEmpty())
66 dis = -1;
67 else
68 dis = temp.toUInt();
69 // viewer->setDisplay(dis);
70 QDialog::accept();
71}
72
73void KVNCConnectDlg::options()
74{
75 KVNCOptionsDlg *wdg = new KVNCOptionsDlg( con->options(), this );
76 wdg->exec();
77 delete wdg;
78}
79
diff --git a/noncore/comm/keypebble/kvncconnectdlg.h b/noncore/comm/keypebble/kvncconnectdlg.h
deleted file mode 100644
index cf34aab..0000000
--- a/noncore/comm/keypebble/kvncconnectdlg.h
+++ b/dev/null
@@ -1,39 +0,0 @@
1// -*- c++ -*-
2
3#ifndef KVNCCONNECTDLG_H
4#define KVNCCONNECTDLG_H
5
6#include <qdialog.h>
7#include <qspinbox.h>
8#include <qcombobox.h>
9#include <qlineedit.h>
10#include <qurl.h>
11
12class KRFBConnection;
13
14class KVNCConnectDlg : public QDialog
15{
16 Q_OBJECT
17
18public:
19 KVNCConnectDlg( KRFBConnection *con,
20 QWidget *parent = 0, const char *name = 0 );
21
22 QString hostname() { return hostNameCombo->currentText(); };
23 int display() { return displayNumberEdit->value(); };
24 QString password() const { return passwordEdit->text(); }
25
26protected:
27 void accept();
28
29protected slots:
30 void options();
31
32private:
33 QComboBox *hostNameCombo;
34 QSpinBox *displayNumberEdit;
35 QLineEdit *passwordEdit;
36 KRFBConnection *con;
37};
38
39#endif // KVNCCONNECTDLG_H
diff --git a/noncore/comm/keypebble/kvncoptionsdlg.cpp b/noncore/comm/keypebble/kvncoptionsdlg.cpp
deleted file mode 100644
index 9d61c7b..0000000
--- a/noncore/comm/keypebble/kvncoptionsdlg.cpp
+++ b/dev/null
@@ -1,54 +0,0 @@
1#include <qframe.h>
2#include <qvbox.h>
3#include <qcheckbox.h>
4#include <qspinbox.h>
5#include <qlabel.h>
6#include <qlayout.h>
7#include <qwhatsthis.h>
8#include <qapplication.h>
9#include "krfboptions.h"
10
11#include "kvncoptionsdlg.h"
12
13KVNCOptionsDlg::KVNCOptionsDlg( KRFBOptions *options,
14 QWidget *parent, char *name, bool modal )
15 : VncOptionsBase( parent, name, modal )
16{
17 this->options = options;
18
19 hex->setChecked( options->hexTile );
20 corre->setChecked( options->corre );
21 rre->setChecked( options->rre );
22 copyRect->setChecked( options->copyrect );
23
24 // TODO
25 hex->setEnabled( false );
26 corre->setEnabled( false );
27 rre->setEnabled( false );
28 // /TODO
29
30 deIconify->setChecked( options->deIconify );
31 bit->setChecked( options->colors256 );
32 shared->setChecked( options->shared );
33 timeBox->setValue( options->updateRate );
34}
35
36KVNCOptionsDlg::~KVNCOptionsDlg()
37{
38}
39
40void KVNCOptionsDlg::accept()
41{
42 options->hexTile = hex->isChecked();
43 options->corre = corre->isChecked();
44 options->rre = rre->isChecked();
45 options->copyrect = copyRect->isChecked();
46 options->deIconify = deIconify->isChecked();
47 options->colors256 = bit->isChecked();
48 options->shared = shared->isChecked();
49 options->updateRate = timeBox->value();
50 options->writeSettings();
51
52 QDialog::accept();
53}
54
diff --git a/noncore/comm/keypebble/kvncoptionsdlg.h b/noncore/comm/keypebble/kvncoptionsdlg.h
deleted file mode 100644
index a166490..0000000
--- a/noncore/comm/keypebble/kvncoptionsdlg.h
+++ b/dev/null
@@ -1,30 +0,0 @@
1// -*- c++ -*-
2
3#ifndef KVNCOPTIONSDIALOG_H
4#define KVNCOPTIONSDIALOG_H
5
6#include "vncoptionsbase.h"
7
8class KRFBOptions;
9
10class KVNCOptionsDlg : public VncOptionsBase
11{
12Q_OBJECT
13
14public:
15 KVNCOptionsDlg( KRFBOptions *options,
16 QWidget *parent = 0, char *name = 0, bool modal = true );
17 ~KVNCOptionsDlg();
18
19protected:
20 void accept();
21
22private:
23 KRFBOptions *options;
24};
25
26#endif // KVNCOPTIONSDIALOG_H
27
28
29
30
diff --git a/noncore/comm/keypebble/main.cpp b/noncore/comm/keypebble/main.cpp
index ee3cd79..bc7782c 100644
--- a/noncore/comm/keypebble/main.cpp
+++ b/noncore/comm/keypebble/main.cpp
@@ -10,8 +10,6 @@ int main( int argc, char **argv )
10 KVNC *view = new KVNC( "Keypebble" ); 10 KVNC *view = new KVNC( "Keypebble" );
11 app.showMainWidget( view ); 11 app.showMainWidget( view );
12 12
13 if ( argc > 1 )
14 view->openURL( QUrl(argv[1]) );
15
16 return app.exec(); 13 return app.exec();
17} 14}
15