author | zecke <zecke> | 2002-11-03 11:11:28 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-03 11:11:28 (UTC) |
commit | e84a1bc31c336df5aea13ac23a47bc15b6ca2e8d (patch) (unidiff) | |
tree | 65c0a66d7fce49f012549fcfb97724c074a38511 | |
parent | d26f82ea57c70fd0e77eb192f7e133c5f76c2f0f (diff) | |
download | opie-e84a1bc31c336df5aea13ac23a47bc15b6ca2e8d.zip opie-e84a1bc31c336df5aea13ac23a47bc15b6ca2e8d.tar.gz opie-e84a1bc31c336df5aea13ac23a47bc15b6ca2e8d.tar.bz2 |
patch by jowenn no default arguments....
-rw-r--r-- | noncore/comm/keypebble/kvncbookmarkdlg.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/comm/keypebble/kvncbookmarkdlg.cpp b/noncore/comm/keypebble/kvncbookmarkdlg.cpp index 1e2f3c3..8556d49 100644 --- a/noncore/comm/keypebble/kvncbookmarkdlg.cpp +++ b/noncore/comm/keypebble/kvncbookmarkdlg.cpp | |||
@@ -1,149 +1,149 @@ | |||
1 | #include <qframe.h> | 1 | #include <qframe.h> |
2 | #include <qvbox.h> | 2 | #include <qvbox.h> |
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qspinbox.h> | 4 | #include <qspinbox.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | #include <qwhatsthis.h> | 7 | #include <qwhatsthis.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qapplication.h> | 11 | #include <qapplication.h> |
12 | #include <qlineedit.h> | 12 | #include <qlineedit.h> |
13 | #include <qtextstream.h> | 13 | #include <qtextstream.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qlistbox.h> | 15 | #include <qlistbox.h> |
16 | #include <qpe/config.h> | 16 | #include <qpe/config.h> |
17 | #include <qpe/global.h> | 17 | #include <qpe/global.h> |
18 | #include "krfbserver.h" | 18 | #include "krfbserver.h" |
19 | #include "kvncbookmarkdlg.h" | 19 | #include "kvncbookmarkdlg.h" |
20 | 20 | ||
21 | KVNCBookmarkDlg::KVNCBookmarkDlg( QWidget * parent=0, const char * name=0, WFlags f=0 ) | 21 | KVNCBookmarkDlg::KVNCBookmarkDlg( QWidget * parent, const char * name, WFlags f ) |
22 | 22 | ||
23 | : KVNCBookmarkDlgBase( parent, name,f) | 23 | : KVNCBookmarkDlgBase( parent, name,f) |
24 | { | 24 | { |
25 | readBookmarks(); | 25 | readBookmarks(); |
26 | refresh(); | 26 | refresh(); |
27 | 27 | ||
28 | } | 28 | } |
29 | 29 | ||
30 | KVNCBookmarkDlg::~KVNCBookmarkDlg() | 30 | KVNCBookmarkDlg::~KVNCBookmarkDlg() |
31 | { | 31 | { |
32 | } | 32 | } |
33 | 33 | ||
34 | void KVNCBookmarkDlg::addBookmark(KRFBServer * server) | 34 | void KVNCBookmarkDlg::addBookmark(KRFBServer * server) |
35 | { | 35 | { |
36 | if (server) { | 36 | if (server) { |
37 | servers.append(server); | 37 | servers.append(server); |
38 | bookmarkList->insertItem(server->name); | 38 | bookmarkList->insertItem(server->name); |
39 | writeBookmarks(); | 39 | writeBookmarks(); |
40 | refresh(); | 40 | refresh(); |
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | void KVNCBookmarkDlg::deleteBookmark(QString name) | 44 | void KVNCBookmarkDlg::deleteBookmark(QString name) |
45 | { | 45 | { |
46 | KRFBServer * server=0; | 46 | KRFBServer * server=0; |
47 | for ( server=servers.first(); server != 0; server=servers.next() ) { | 47 | for ( server=servers.first(); server != 0; server=servers.next() ) { |
48 | if (server->name==name) { | 48 | if (server->name==name) { |
49 | servers.remove(servers.at()); | 49 | servers.remove(servers.at()); |
50 | writeBookmarks(); | 50 | writeBookmarks(); |
51 | refresh(); | 51 | refresh(); |
52 | return; | 52 | return; |
53 | } | 53 | } |
54 | } | 54 | } |
55 | } | 55 | } |
56 | KRFBServer *KVNCBookmarkDlg::getServer(QString name) | 56 | KRFBServer *KVNCBookmarkDlg::getServer(QString name) |
57 | { | 57 | { |
58 | KRFBServer * server=0; | 58 | KRFBServer * server=0; |
59 | for ( server=servers.first(); server != 0; server=servers.next() ) { | 59 | for ( server=servers.first(); server != 0; server=servers.next() ) { |
60 | if (server->name==name) | 60 | if (server->name==name) |
61 | 61 | ||
62 | return server; | 62 | return server; |
63 | } | 63 | } |
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | /* | 68 | /* |
69 | Note that the degree of protection offered by the encryption here is | 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 | 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 | 71 | files. People with access to the files can write down the contents and |
72 | decrypt it using this source code. | 72 | decrypt it using this source code. |
73 | 73 | ||
74 | Conceivably, and at some burden to the user, this encryption could | 74 | Conceivably, and at some burden to the user, this encryption could |
75 | be improved. | 75 | be improved. |
76 | */ | 76 | */ |
77 | QString KVNCBookmarkDlg::encipher(const QString& plain) | 77 | QString KVNCBookmarkDlg::encipher(const QString& plain) |
78 | { | 78 | { |
79 | // mainly, we make it long | 79 | // mainly, we make it long |
80 | QString cipher; | 80 | QString cipher; |
81 | int mix=28730492; | 81 | int mix=28730492; |
82 | for (int i=0; i<(int)plain.length(); i++) { | 82 | for (int i=0; i<(int)plain.length(); i++) { |
83 | int u = plain[i].unicode(); | 83 | int u = plain[i].unicode(); |
84 | int c = u ^ mix; | 84 | int c = u ^ mix; |
85 | QString x = QString::number(c,36); | 85 | QString x = QString::number(c,36); |
86 | cipher.append(QChar('a'+x.length())); | 86 | cipher.append(QChar('a'+x.length())); |
87 | cipher.append(x); | 87 | cipher.append(x); |
88 | mix *= u; | 88 | mix *= u; |
89 | } | 89 | } |
90 | return cipher; | 90 | return cipher; |
91 | } | 91 | } |
92 | 92 | ||
93 | QString KVNCBookmarkDlg::decipher(const QString& cipher) | 93 | QString KVNCBookmarkDlg::decipher(const QString& cipher) |
94 | { | 94 | { |
95 | QString plain; | 95 | QString plain; |
96 | int mix=28730492; | 96 | int mix=28730492; |
97 | for (int i=0; i<(int)cipher.length();) { | 97 | for (int i=0; i<(int)cipher.length();) { |
98 | int l = cipher[i].unicode()-'a'; | 98 | int l = cipher[i].unicode()-'a'; |
99 | QString x = cipher.mid(i+1,l); i+=l+1; | 99 | QString x = cipher.mid(i+1,l); i+=l+1; |
100 | int u = x.toInt(0,36) ^ mix; | 100 | int u = x.toInt(0,36) ^ mix; |
101 | plain.append(QChar(u)); | 101 | plain.append(QChar(u)); |
102 | mix *= u; | 102 | mix *= u; |
103 | } | 103 | } |
104 | return plain; | 104 | return plain; |
105 | } | 105 | } |
106 | 106 | ||
107 | void KVNCBookmarkDlg::readBookmarks(void) | 107 | void KVNCBookmarkDlg::readBookmarks(void) |
108 | { | 108 | { |
109 | QFile f(QDir::homeDirPath() + QString("/Applications/keypebble/bookmarks")); | 109 | QFile f(QDir::homeDirPath() + QString("/Applications/keypebble/bookmarks")); |
110 | 110 | ||
111 | QStringList entry; | 111 | QStringList entry; |
112 | QString key, val; | 112 | QString key, val; |
113 | KRFBServer * server=0; | 113 | KRFBServer * server=0; |
114 | 114 | ||
115 | if ( f.open(IO_ReadOnly) ) { | 115 | if ( f.open(IO_ReadOnly) ) { |
116 | QTextStream t( &f ); | 116 | QTextStream t( &f ); |
117 | QString s; | 117 | QString s; |
118 | int n = 1; | 118 | int n = 1; |
119 | while ( !t.eof() ) { | 119 | while ( !t.eof() ) { |
120 | s = t.readLine(); | 120 | s = t.readLine(); |
121 | 121 | ||
122 | 122 | ||
123 | entry=QStringList::split('=',s); | 123 | entry=QStringList::split('=',s); |
124 | key=entry[0].stripWhiteSpace().lower(); | 124 | key=entry[0].stripWhiteSpace().lower(); |
125 | val=entry[1].stripWhiteSpace(); | 125 | val=entry[1].stripWhiteSpace(); |
126 | 126 | ||
127 | if (key=="server") { | 127 | if (key=="server") { |
128 | 128 | ||
129 | if (server){ | 129 | if (server){ |
130 | servers.append(server); | 130 | servers.append(server); |
131 | server=0; | 131 | server=0; |
132 | } | 132 | } |
133 | server = new KRFBServer(); | 133 | server = new KRFBServer(); |
134 | 134 | ||
135 | if (!server) | 135 | if (!server) |
136 | return; | 136 | return; |
137 | server->name=val; | 137 | server->name=val; |
138 | 138 | ||
139 | } | 139 | } |
140 | else if (key=="hostname") | 140 | else if (key=="hostname") |
141 | server->hostname=val; | 141 | server->hostname=val; |
142 | else if (key=="password") | 142 | else if (key=="password") |
143 | server->password=decipher(val); | 143 | server->password=decipher(val); |
144 | else if (key=="display") | 144 | else if (key=="display") |
145 | server->display=val.toInt(); | 145 | server->display=val.toInt(); |
146 | else if (key=="hextile") | 146 | else if (key=="hextile") |
147 | server->hexTile=val.toInt(); | 147 | server->hexTile=val.toInt(); |
148 | else if (key=="corre") | 148 | else if (key=="corre") |
149 | server->corre=val.toInt(); | 149 | server->corre=val.toInt(); |