summaryrefslogtreecommitdiff
path: root/noncore/comm/keypebble/kvncbookmarkdlg.cpp
Unidiff
Diffstat (limited to 'noncore/comm/keypebble/kvncbookmarkdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/kvncbookmarkdlg.cpp14
1 files changed, 0 insertions, 14 deletions
diff --git a/noncore/comm/keypebble/kvncbookmarkdlg.cpp b/noncore/comm/keypebble/kvncbookmarkdlg.cpp
index 8556d49..ef2fa12 100644
--- a/noncore/comm/keypebble/kvncbookmarkdlg.cpp
+++ b/noncore/comm/keypebble/kvncbookmarkdlg.cpp
@@ -1,114 +1,100 @@
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> 1#include <qdir.h>
10#include <qstring.h>
11#include <qapplication.h>
12#include <qlineedit.h>
13#include <qtextstream.h> 2#include <qtextstream.h>
14#include <qpushbutton.h>
15#include <qlistbox.h> 3#include <qlistbox.h>
16#include <qpe/config.h>
17#include <qpe/global.h> 4#include <qpe/global.h>
18#include "krfbserver.h"
19#include "kvncbookmarkdlg.h" 5#include "kvncbookmarkdlg.h"
20 6
21KVNCBookmarkDlg::KVNCBookmarkDlg( QWidget * parent, const char * name, WFlags f ) 7KVNCBookmarkDlg::KVNCBookmarkDlg( QWidget * parent, const char * name, WFlags f )
22 8
23: KVNCBookmarkDlgBase( parent, name,f) 9: KVNCBookmarkDlgBase( parent, name,f)
24{ 10{
25 readBookmarks(); 11 readBookmarks();
26 refresh(); 12 refresh();
27 13
28} 14}
29 15
30KVNCBookmarkDlg::~KVNCBookmarkDlg() 16KVNCBookmarkDlg::~KVNCBookmarkDlg()
31{ 17{
32} 18}
33 19
34void KVNCBookmarkDlg::addBookmark(KRFBServer * server) 20void KVNCBookmarkDlg::addBookmark(KRFBServer * server)
35{ 21{
36 if (server) { 22 if (server) {
37 servers.append(server); 23 servers.append(server);
38 bookmarkList->insertItem(server->name); 24 bookmarkList->insertItem(server->name);
39 writeBookmarks(); 25 writeBookmarks();
40 refresh(); 26 refresh();
41 } 27 }
42} 28}
43 29
44void KVNCBookmarkDlg::deleteBookmark(QString name) 30void KVNCBookmarkDlg::deleteBookmark(QString name)
45{ 31{
46 KRFBServer * server=0; 32 KRFBServer * server=0;
47 for ( server=servers.first(); server != 0; server=servers.next() ) { 33 for ( server=servers.first(); server != 0; server=servers.next() ) {
48 if (server->name==name) { 34 if (server->name==name) {
49 servers.remove(servers.at()); 35 servers.remove(servers.at());
50 writeBookmarks(); 36 writeBookmarks();
51 refresh(); 37 refresh();
52 return; 38 return;
53 } 39 }
54 } 40 }
55} 41}
56KRFBServer *KVNCBookmarkDlg::getServer(QString name) 42KRFBServer *KVNCBookmarkDlg::getServer(QString name)
57{ 43{
58 KRFBServer * server=0; 44 KRFBServer * server=0;
59 for ( server=servers.first(); server != 0; server=servers.next() ) { 45 for ( server=servers.first(); server != 0; server=servers.next() ) {
60 if (server->name==name) 46 if (server->name==name)
61 47
62 return server; 48 return server;
63 } 49 }
64 return 0; 50 return 0;
65} 51}
66 52
67 53
68/* 54/*
69 Note that the degree of protection offered by the encryption here is 55 Note that the degree of protection offered by the encryption here is
70 only sufficient to avoid the most casual observation of the configuration 56 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 57 files. People with access to the files can write down the contents and
72 decrypt it using this source code. 58 decrypt it using this source code.
73 59
74 Conceivably, and at some burden to the user, this encryption could 60 Conceivably, and at some burden to the user, this encryption could
75 be improved. 61 be improved.
76*/ 62*/
77QString KVNCBookmarkDlg::encipher(const QString& plain) 63QString KVNCBookmarkDlg::encipher(const QString& plain)
78{ 64{
79 // mainly, we make it long 65 // mainly, we make it long
80 QString cipher; 66 QString cipher;
81 int mix=28730492; 67 int mix=28730492;
82 for (int i=0; i<(int)plain.length(); i++) { 68 for (int i=0; i<(int)plain.length(); i++) {
83 int u = plain[i].unicode(); 69 int u = plain[i].unicode();
84 int c = u ^ mix; 70 int c = u ^ mix;
85 QString x = QString::number(c,36); 71 QString x = QString::number(c,36);
86 cipher.append(QChar('a'+x.length())); 72 cipher.append(QChar('a'+x.length()));
87 cipher.append(x); 73 cipher.append(x);
88 mix *= u; 74 mix *= u;
89 } 75 }
90 return cipher; 76 return cipher;
91} 77}
92 78
93QString KVNCBookmarkDlg::decipher(const QString& cipher) 79QString KVNCBookmarkDlg::decipher(const QString& cipher)
94{ 80{
95 QString plain; 81 QString plain;
96 int mix=28730492; 82 int mix=28730492;
97 for (int i=0; i<(int)cipher.length();) { 83 for (int i=0; i<(int)cipher.length();) {
98 int l = cipher[i].unicode()-'a'; 84 int l = cipher[i].unicode()-'a';
99 QString x = cipher.mid(i+1,l); i+=l+1; 85 QString x = cipher.mid(i+1,l); i+=l+1;
100 int u = x.toInt(0,36) ^ mix; 86 int u = x.toInt(0,36) ^ mix;
101 plain.append(QChar(u)); 87 plain.append(QChar(u));
102 mix *= u; 88 mix *= u;
103 } 89 }
104 return plain; 90 return plain;
105} 91}
106 92
107void KVNCBookmarkDlg::readBookmarks(void) 93void KVNCBookmarkDlg::readBookmarks(void)
108{ 94{
109 QFile f(QDir::homeDirPath() + QString("/Applications/keypebble/bookmarks")); 95 QFile f(QDir::homeDirPath() + QString("/Applications/keypebble/bookmarks"));
110 96
111 QStringList entry; 97 QStringList entry;
112 QString key, val; 98 QString key, val;
113 KRFBServer * server=0; 99 KRFBServer * server=0;
114 100