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) (show whitespace changes)
-rw-r--r--noncore/comm/keypebble/keypebble.pro16
-rw-r--r--noncore/comm/keypebble/krfbbuffer.cpp31
-rw-r--r--noncore/comm/keypebble/krfbcanvas.cpp39
-rw-r--r--noncore/comm/keypebble/krfbcanvas.h6
-rw-r--r--noncore/comm/keypebble/krfbconnection.cpp20
-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.cpp132
-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, 537 insertions, 378 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,6 +150,37 @@ void KRFBBuffer::drawRawRectChunk( void *data,
150 *p = qRgb( r,g,b ); 150 *p = qRgb( r,g,b );
151 } 151 }
152 } 152 }
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 }
153 } 184 }
154 else { 185 else {
155 p.setBrush( QBrush( Qt::black ) ); 186 p.setBrush( QBrush( Qt::black ) );
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,7 +5,7 @@
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
@@ -16,7 +16,7 @@ KRFBConnection::KRFBConnection( QObject *parent )
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;
@@ -30,13 +30,12 @@ KRFBConnection::~KRFBConnection()
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 37
38 this->host_= host; 38 (*options_)=server;
39 this->display_ = display;
40 39
41 sock = new QSocket( this, "rfbSocket" ); 40 sock = new QSocket( this, "rfbSocket" );
42 CHECK_PTR( sock ); 41 CHECK_PTR( sock );
@@ -48,7 +47,7 @@ void KRFBConnection::connectTo( const QCString &host, int display )
48 qWarning( "Connecting..." ); 47 qWarning( "Connecting..." );
49 48
50 currentState_ = Connecting; 49 currentState_ = Connecting;
51 sock->connectToHost( host_, portBase_ + display_ ); 50 sock->connectToHost( options_->hostname.latin1(), portBase_ + options_->display );
52} 51}
53 52
54void KRFBConnection::disconnect() 53void KRFBConnection::disconnect()
@@ -70,7 +69,6 @@ void KRFBConnection::disconnect()
70 69
71void KRFBConnection::disconnectDone() 70void KRFBConnection::disconnectDone()
72{ 71{
73 qWarning( "KRFBConnection disconnected" );
74 currentState_ = Disconnected; 72 currentState_ = Disconnected;
75 delete sock; 73 delete sock;
76 sock = 0; 74 sock = 0;
@@ -180,7 +178,6 @@ void KRFBConnection::waitForData( unsigned int sz )
180 } 178 }
181 else { 179 else {
182 // qWarning( "Waiting for %u bytes", sz ); 180 // qWarning( "Waiting for %u bytes", sz );
183
184 minData_ = sz; 181 minData_ = sz;
185 connect( sock, SIGNAL( readyRead() ), SLOT( gotMoreData() ) ); 182 connect( sock, SIGNAL( readyRead() ), SLOT( gotMoreData() ) );
186 } 183 }
@@ -211,11 +208,6 @@ int KRFBConnection::portBase() const
211 return portBase_; 208 return portBase_;
212} 209}
213 210
214void KRFBConnection::setPassword( const QCString &pass )
215{
216 this->pass_ = pass;
217}
218
219void KRFBConnection::updateTimer() 211void KRFBConnection::updateTimer()
220{ 212{
221 decoder_->sendUpdateRequest( true ); 213 decoder_->sendUpdateRequest( true );
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
74} 119}
75 120
76void KVNC::openURL( const QUrl &url ) 121void KVNC::newConnection()
77{ 122{
78 canvas->openURL( url ); 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());
154}
155
156void KVNC::openConnection( QListBoxItem * item)
157{
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()),
@@ -108,13 +185,17 @@ 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 );
191 stack->addWidget(canvas,get_unique_id());
192 stack->raiseWidget(canvas);
114 canvas->show(); 193 canvas->show();
194 stack->show();
115 fullScreenAction->setText( tr("Full Screen") ); 195 fullScreenAction->setText( tr("Full Screen") );
116 } else { 196 } else {
117 canvas->setFrameStyle( QFrame::NoFrame ); 197 canvas->setFrameStyle( QFrame::NoFrame );
198 stack->removeWidget(canvas);
118 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, 199 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop,
119 QPoint(0,0),false); 200 QPoint(0,0),false);
120 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height()); 201 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height());
@@ -126,6 +207,7 @@ void KVNC::toggleFullScreen()
126 fullScreenAction->setText( tr("Stop Full Screen") ); 207 fullScreenAction->setText( tr("Stop Full Screen") );
127 } 208 }
128 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