summaryrefslogtreecommitdiff
authortreke <treke>2002-09-04 17:53:12 (UTC)
committer treke <treke>2002-09-04 17:53:12 (UTC)
commit605d854057eb470a1d75210193b82eb0b1ad6b53 (patch) (unidiff)
treec411b661d5211fefbd83a7c8f63eef8c9cca72ee
parentc35a5eabd8f5ed18e4216f6c88ee6794bacfb491 (diff)
downloadopie-605d854057eb470a1d75210193b82eb0b1ad6b53.zip
opie-605d854057eb470a1d75210193b82eb0b1ad6b53.tar.gz
opie-605d854057eb470a1d75210193b82eb0b1ad6b53.tar.bz2
Major modifications to the User Interface
1) Bookmark support added, all options are stored on a per bookmark basis 2) 16 Bit color is now a supported bit depth for the server
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
@@ -9,7 +9,8 @@ HEADERS = d3des.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
@@ -22,8 +23,9 @@ SOURCES = d3des.c \
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
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
@@ -152,3 +152,34 @@ void KRFBBuffer::drawRawRectChunk( void *data,
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 {
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,5 +1,4 @@
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"
@@ -7,2 +6,3 @@
7#include <qpe/config.h> 6#include <qpe/config.h>
7#include <qpe/qpeapplication.h>
8 8
@@ -20,4 +20,2 @@ KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name )
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() ),
@@ -26,2 +24,3 @@ KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name )
26 loggedIn_ = false; 24 loggedIn_ = false;
25 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold);
27 26
@@ -35,12 +34,13 @@ KRFBCanvas::~KRFBCanvas()
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 )
@@ -54,6 +54,4 @@ void KRFBCanvas::openURL( const QUrl &url )
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}
@@ -71,6 +69,2 @@ void KRFBCanvas::closeConnection()
71 69
72void KRFBCanvas::passwordRequired( KRFBConnection *con )
73{
74 con->setPassword( password.latin1() );
75}
76 70
@@ -169 +163,10 @@ void KRFBCanvas::clipboardChanged()
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
@@ -9,2 +9,3 @@
9class KRFBConnection; 9class KRFBConnection;
10class KRFBServer;
10 11
@@ -25,6 +26,6 @@ public:
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
@@ -32,2 +33,3 @@ public slots:
32 void bell(); 33 void bell();
34 void sendCtlAltDel(void);
33 35
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
@@ -7,3 +7,3 @@
7#include "krfblogin.h" 7#include "krfblogin.h"
8#include "krfboptions.h" 8#include "krfbserver.h"
9#include "krfbdecoder.h" 9#include "krfbdecoder.h"
@@ -12,12 +12,12 @@
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}
@@ -26,27 +26,26 @@ KRFBConnection::~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}
@@ -55,15 +54,15 @@ void 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}
@@ -72,11 +71,10 @@ void 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}
@@ -85,11 +83,11 @@ void 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}
@@ -98,24 +96,24 @@ void 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}
@@ -124,35 +122,35 @@ void 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}
@@ -161,9 +159,9 @@ void 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}
@@ -172,16 +170,15 @@ void 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}
@@ -190,3 +187,3 @@ int KRFBConnection::read( void *buf, int sz )
190{ 187{
191 return sock->readBlock( (char *) buf, sz ); 188 return sock->readBlock( (char *) buf, sz );
192} 189}
@@ -195,3 +192,3 @@ int 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}
@@ -200,3 +197,3 @@ KRFBConnection::State KRFBConnection::state() const
200{ 197{
201 return currentState_; 198 return currentState_;
202} 199}
@@ -205,3 +202,3 @@ void KRFBConnection::setPortBase( int base )
205{ 202{
206 portBase_ = base; 203 portBase_ = base;
207} 204}
@@ -210,8 +207,3 @@ int 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}
@@ -220,3 +212,3 @@ void KRFBConnection::updateTimer()
220{ 212{
221 decoder_->sendUpdateRequest( true ); 213 decoder_->sendUpdateRequest( true );
222} 214}
@@ -225,3 +217,3 @@ void KRFBConnection::refresh()
225{ 217{
226 decoder_->sendUpdateRequest( false ); 218 decoder_->sendUpdateRequest( false );
227} 219}
@@ -230,3 +222,3 @@ void KRFBConnection::sendCutText( const QString &text )
230{ 222{
231 decoder_->sendCutEvent( text ); 223 decoder_->sendCutEvent( text );
232} 224}
@@ -235,8 +227,8 @@ const 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
@@ -8,2 +8,3 @@
8#include <qcstring.h> 8#include <qcstring.h>
9#include "krfbserver.h"
9#include <qurl.h> 10#include <qurl.h>
@@ -12,3 +13,3 @@ class KRFBLogin;
12class KRBUpdateHandler; 13class KRBUpdateHandler;
13class KRFBOptions; 14class KRFBServer;
14class QSocket; 15class QSocket;
@@ -47,3 +48,3 @@ public:
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
@@ -59,7 +60,4 @@ public:
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
@@ -69,6 +67,6 @@ public:
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
@@ -135,6 +133,3 @@ private:
135private: 133private:
136 QCString host_;
137 int portBase_; 134 int portBase_;
138 int display_;
139 QCString pass_;
140 QSocket *sock; 135 QSocket *sock;
@@ -145,3 +140,3 @@ private:
145 KRFBDecoder *decoder_; 140 KRFBDecoder *decoder_;
146 KRFBOptions *options_; 141 KRFBServer *options_;
147 KRFBBuffer *buffer_; 142 KRFBBuffer *buffer_;
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,3 +1,3 @@
1#include "krfbconnection.h" 1#include "krfbconnection.h"
2#include "krfboptions.h" 2#include "krfbserver.h"
3#include "krfbserverinfo.h" 3#include "krfbserverinfo.h"
@@ -798,2 +798,3 @@ void KRFBDecoder::sendKeyReleaseEvent( QKeyEvent *event )
798 798
799
799int KRFBDecoder::toKeySym( QKeyEvent *k ) 800int KRFBDecoder::toKeySym( QKeyEvent *k )
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
@@ -54,4 +54,2 @@ KRFBLogin::KRFBLogin( KRFBConnection *con )
54 54
55 connect( this, SIGNAL( passwordRequired( KRFBConnection * ) ),
56 con, SIGNAL( passwordRequired( KRFBConnection * ) ) );
57 55
@@ -185,3 +183,3 @@ void KRFBLogin::getPassword()
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" );
@@ -190,3 +188,3 @@ void KRFBLogin::getPassword()
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 "
@@ -198,3 +196,3 @@ void KRFBLogin::getPassword()
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 );
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
@@ -12,4 +12,10 @@
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>
@@ -18,4 +24,11 @@
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
@@ -50,5 +63,15 @@ KVNC::KVNC( const char *name ) : QMainWindow( 0, name )
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 &)),
@@ -68,3 +91,24 @@ KVNC::KVNC( const char *name ) : QMainWindow( 0, name )
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}
@@ -73,7 +117,43 @@ KVNC::~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}
@@ -90,10 +170,7 @@ void KVNC::setupActions()
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
@@ -108,22 +185,27 @@ void 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;
@@ -151,5 +233,6 @@ void KVNC::connected()
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}
@@ -164,7 +247,11 @@ void 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}
@@ -181,10 +268,5 @@ void KVNC::error( const QString &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
@@ -7,2 +7,4 @@
7#include <qurl.h> 7#include <qurl.h>
8#include <qwidgetstack.h>
9#include "kvncbookmarkdlg.h"
8 10
@@ -27,6 +29,9 @@ public:
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
@@ -52,3 +57,8 @@ private:
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};
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
@@ -12,6 +12,4 @@ int main( int argc, char **argv )
12 12
13 if ( argc > 1 )
14 view->openURL( QUrl(argv[1]) );
15
16 return app.exec(); 13 return app.exec();
17} 14}
15