summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-10 11:13:33 (UTC)
committer zecke <zecke>2004-09-10 11:13:33 (UTC)
commit046bff8abb6727f5522748a2dc8a259d27b5979b (patch) (unidiff)
tree9c5443ce219fe07fd24aca16ed8df7643c716c49
parent532d65f8a45850bfda3c3344a7b165af91e48440 (diff)
downloadopie-046bff8abb6727f5522748a2dc8a259d27b5979b.zip
opie-046bff8abb6727f5522748a2dc8a259d27b5979b.tar.gz
opie-046bff8abb6727f5522748a2dc8a259d27b5979b.tar.bz2
Fix unused global variables, unused code, unused parameters, sign != unsigned
tests...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/d3des.c7
-rw-r--r--noncore/comm/keypebble/krfbcanvas.cpp8
-rw-r--r--noncore/comm/keypebble/kvnc.cpp2
-rw-r--r--noncore/comm/keypebble/vncauth.c2
4 files changed, 7 insertions, 12 deletions
diff --git a/noncore/comm/keypebble/d3des.c b/noncore/comm/keypebble/d3des.c
index b0f065e..7f50da4 100644
--- a/noncore/comm/keypebble/d3des.c
+++ b/noncore/comm/keypebble/d3des.c
@@ -1,439 +1,432 @@
1/* 1/*
2 * This is D3DES (V5.09) by Richard Outerbridge with the double and 2 * This is D3DES (V5.09) by Richard Outerbridge with the double and
3 * triple-length support removed for use in VNC. Also the bytebit[] array 3 * triple-length support removed for use in VNC. Also the bytebit[] array
4 * has been reversed so that the most significant bit in each byte of the 4 * has been reversed so that the most significant bit in each byte of the
5 * key is ignored, not the least significant. 5 * key is ignored, not the least significant.
6 * 6 *
7 * These changes are Copyright (C) 1998 Olivetti & Oracle Research Laboratory 7 * These changes are Copyright (C) 1998 Olivetti & Oracle Research Laboratory
8 * 8 *
9 * This software is distributed in the hope that it will be useful, 9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 */ 12 */
13 13
14/* D3DES (V5.09) - 14/* D3DES (V5.09) -
15 * 15 *
16 * A portable, public domain, version of the Data Encryption Standard. 16 * A portable, public domain, version of the Data Encryption Standard.
17 * 17 *
18 * Written with Symantec's THINK (Lightspeed) C by Richard Outerbridge. 18 * Written with Symantec's THINK (Lightspeed) C by Richard Outerbridge.
19 * Thanks to: Dan Hoey for his excellent Initial and Inverse permutation 19 * Thanks to: Dan Hoey for his excellent Initial and Inverse permutation
20 * code; Jim Gillogly & Phil Karn for the DES key schedule code; Dennis 20 * code; Jim Gillogly & Phil Karn for the DES key schedule code; Dennis
21 * Ferguson, Eric Young and Dana How for comparing notes; and Ray Lau, 21 * Ferguson, Eric Young and Dana How for comparing notes; and Ray Lau,
22 * for humouring me on. 22 * for humouring me on.
23 * 23 *
24 * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge. 24 * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge.
25 * (GEnie : OUTER; CIS : [71755,204]) Graven Imagery, 1992. 25 * (GEnie : OUTER; CIS : [71755,204]) Graven Imagery, 1992.
26 */ 26 */
27 27
28#include "d3des.h" 28#include "d3des.h"
29 29
30static void scrunch(unsigned char *, unsigned long *); 30static void scrunch(unsigned char *, unsigned long *);
31static void unscrun(unsigned long *, unsigned char *); 31static void unscrun(unsigned long *, unsigned char *);
32static void desfunc(unsigned long *, unsigned long *); 32static void desfunc(unsigned long *, unsigned long *);
33static void cookey(unsigned long *); 33static void cookey(unsigned long *);
34 34
35static unsigned long KnL[32] = { 0L }; 35static unsigned long KnL[32] = { 0L };
36static unsigned long KnR[32] = { 0L };
37static unsigned long Kn3[32] = { 0L };
38static unsigned char Df_Key[24] = {
39 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
40 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
41 0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 };
42
43 static unsigned short bytebit[8]= { 36 static unsigned short bytebit[8]= {
44 01, 02, 04, 010, 020, 040, 0100, 0200 }; 37 01, 02, 04, 010, 020, 040, 0100, 0200 };
45 38
46static unsigned long bigbyte[24] = { 39static unsigned long bigbyte[24] = {
47 0x800000L, 0x400000L, 0x200000L,0x100000L, 40 0x800000L, 0x400000L, 0x200000L,0x100000L,
48 0x80000L, 0x40000L, 0x20000L,0x10000L, 41 0x80000L, 0x40000L, 0x20000L,0x10000L,
49 0x8000L, 0x4000L, 0x2000L,0x1000L, 42 0x8000L, 0x4000L, 0x2000L,0x1000L,
50 0x800L, 0x400L, 0x200L, 0x100L, 43 0x800L, 0x400L, 0x200L, 0x100L,
51 0x80L, 0x40L, 0x20L, 0x10L, 44 0x80L, 0x40L, 0x20L, 0x10L,
52 0x8L, 0x4L, 0x2L, 0x1L}; 45 0x8L, 0x4L, 0x2L, 0x1L};
53 46
54/* Use the key schedule specified in the Standard (ANSI X3.92-1981). */ 47/* Use the key schedule specified in the Standard (ANSI X3.92-1981). */
55 48
56static unsigned char pc1[56] = { 49static unsigned char pc1[56] = {
57 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17, 50 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17,
58 9, 1, 58, 50, 42, 34, 26,18, 10, 2, 59, 51, 43, 35, 51 9, 1, 58, 50, 42, 34, 26,18, 10, 2, 59, 51, 43, 35,
59 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 52 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21,
60 13, 5, 60, 52, 44, 36, 28,20, 12, 4, 27, 19, 11, 3 }; 53 13, 5, 60, 52, 44, 36, 28,20, 12, 4, 27, 19, 11, 3 };
61 54
62static unsigned char totrot[16] = { 55static unsigned char totrot[16] = {
63 1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 }; 56 1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 };
64 57
65static unsigned char pc2[48] = { 58static unsigned char pc2[48] = {
66 13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 59 13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9,
67 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 60 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1,
68 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 61 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
69 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 }; 62 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 };
70 63
71 void deskey(key, edf)/* Thanks to James Gillogly & Phil Karn! */ 64 void deskey(key, edf)/* Thanks to James Gillogly & Phil Karn! */
72unsigned char *key; 65unsigned char *key;
73short edf; 66short edf;
74{ 67{
75 register int i, j, l, m, n; 68 register int i, j, l, m, n;
76 unsigned char pc1m[56], pcr[56]; 69 unsigned char pc1m[56], pcr[56];
77 unsigned long kn[32]; 70 unsigned long kn[32];
78 71
79 for ( j = 0; j < 56; j++ ) { 72 for ( j = 0; j < 56; j++ ) {
80 l = pc1[j]; 73 l = pc1[j];
81 m = l & 07; 74 m = l & 07;
82 pc1m[j] = (key[l >> 3] & bytebit[m]) ? 1 : 0; 75 pc1m[j] = (key[l >> 3] & bytebit[m]) ? 1 : 0;
83 } 76 }
84 for( i = 0; i < 16; i++ ) { 77 for( i = 0; i < 16; i++ ) {
85 if( edf == DE1 ) m = (15 - i) << 1; 78 if( edf == DE1 ) m = (15 - i) << 1;
86 else m = i << 1; 79 else m = i << 1;
87 n = m + 1; 80 n = m + 1;
88 kn[m] = kn[n] = 0L; 81 kn[m] = kn[n] = 0L;
89 for( j = 0; j < 28; j++ ) { 82 for( j = 0; j < 28; j++ ) {
90 l = j + totrot[i]; 83 l = j + totrot[i];
91 if( l < 28 ) pcr[j] = pc1m[l]; 84 if( l < 28 ) pcr[j] = pc1m[l];
92 else pcr[j] = pc1m[l - 28]; 85 else pcr[j] = pc1m[l - 28];
93 } 86 }
94 for( j = 28; j < 56; j++ ) { 87 for( j = 28; j < 56; j++ ) {
95 l = j + totrot[i]; 88 l = j + totrot[i];
96 if( l < 56 ) pcr[j] = pc1m[l]; 89 if( l < 56 ) pcr[j] = pc1m[l];
97 else pcr[j] = pc1m[l - 28]; 90 else pcr[j] = pc1m[l - 28];
98 } 91 }
99 for( j = 0; j < 24; j++ ) { 92 for( j = 0; j < 24; j++ ) {
100 if( pcr[pc2[j]] ) kn[m] |= bigbyte[j]; 93 if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
101 if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j]; 94 if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
102 } 95 }
103 } 96 }
104 cookey(kn); 97 cookey(kn);
105 return; 98 return;
106 } 99 }
107 100
108static void cookey(raw1) 101static void cookey(raw1)
109register unsigned long *raw1; 102register unsigned long *raw1;
110{ 103{
111 register unsigned long *cook, *raw0; 104 register unsigned long *cook, *raw0;
112 unsigned long dough[32]; 105 unsigned long dough[32];
113 register int i; 106 register int i;
114 107
115 cook = dough; 108 cook = dough;
116 for( i = 0; i < 16; i++, raw1++ ) { 109 for( i = 0; i < 16; i++, raw1++ ) {
117 raw0 = raw1++; 110 raw0 = raw1++;
118 *cook = (*raw0 & 0x00fc0000L) << 6; 111 *cook = (*raw0 & 0x00fc0000L) << 6;
119 *cook|= (*raw0 & 0x00000fc0L) << 10; 112 *cook|= (*raw0 & 0x00000fc0L) << 10;
120 *cook|= (*raw1 & 0x00fc0000L) >> 10; 113 *cook|= (*raw1 & 0x00fc0000L) >> 10;
121 *cook++ |= (*raw1 & 0x00000fc0L) >> 6; 114 *cook++ |= (*raw1 & 0x00000fc0L) >> 6;
122 *cook = (*raw0 & 0x0003f000L) << 12; 115 *cook = (*raw0 & 0x0003f000L) << 12;
123 *cook|= (*raw0 & 0x0000003fL) << 16; 116 *cook|= (*raw0 & 0x0000003fL) << 16;
124 *cook|= (*raw1 & 0x0003f000L) >> 4; 117 *cook|= (*raw1 & 0x0003f000L) >> 4;
125 *cook++ |= (*raw1 & 0x0000003fL); 118 *cook++ |= (*raw1 & 0x0000003fL);
126 } 119 }
127 usekey(dough); 120 usekey(dough);
128 return; 121 return;
129 } 122 }
130 123
131void cpkey(into) 124void cpkey(into)
132register unsigned long *into; 125register unsigned long *into;
133{ 126{
134 register unsigned long *from, *endp; 127 register unsigned long *from, *endp;
135 128
136 from = KnL, endp = &KnL[32]; 129 from = KnL, endp = &KnL[32];
137 while( from < endp ) *into++ = *from++; 130 while( from < endp ) *into++ = *from++;
138 return; 131 return;
139 } 132 }
140 133
141void usekey(from) 134void usekey(from)
142register unsigned long *from; 135register unsigned long *from;
143{ 136{
144 register unsigned long *to, *endp; 137 register unsigned long *to, *endp;
145 138
146 to = KnL, endp = &KnL[32]; 139 to = KnL, endp = &KnL[32];
147 while( to < endp ) *to++ = *from++; 140 while( to < endp ) *to++ = *from++;
148 return; 141 return;
149 } 142 }
150 143
151void des(inblock, outblock) 144void des(inblock, outblock)
152unsigned char *inblock, *outblock; 145unsigned char *inblock, *outblock;
153{ 146{
154 unsigned long work[2]; 147 unsigned long work[2];
155 148
156 scrunch(inblock, work); 149 scrunch(inblock, work);
157 desfunc(work, KnL); 150 desfunc(work, KnL);
158 unscrun(work, outblock); 151 unscrun(work, outblock);
159 return; 152 return;
160 } 153 }
161 154
162static void scrunch(outof, into) 155static void scrunch(outof, into)
163register unsigned char *outof; 156register unsigned char *outof;
164register unsigned long *into; 157register unsigned long *into;
165{ 158{
166 *into = (*outof++ & 0xffL) << 24; 159 *into = (*outof++ & 0xffL) << 24;
167 *into|= (*outof++ & 0xffL) << 16; 160 *into|= (*outof++ & 0xffL) << 16;
168 *into|= (*outof++ & 0xffL) << 8; 161 *into|= (*outof++ & 0xffL) << 8;
169 *into++ |= (*outof++ & 0xffL); 162 *into++ |= (*outof++ & 0xffL);
170 *into = (*outof++ & 0xffL) << 24; 163 *into = (*outof++ & 0xffL) << 24;
171 *into|= (*outof++ & 0xffL) << 16; 164 *into|= (*outof++ & 0xffL) << 16;
172 *into|= (*outof++ & 0xffL) << 8; 165 *into|= (*outof++ & 0xffL) << 8;
173 *into|= (*outof & 0xffL); 166 *into|= (*outof & 0xffL);
174 return; 167 return;
175 } 168 }
176 169
177static void unscrun(outof, into) 170static void unscrun(outof, into)
178register unsigned long *outof; 171register unsigned long *outof;
179register unsigned char *into; 172register unsigned char *into;
180{ 173{
181 *into++ = (*outof >> 24) & 0xffL; 174 *into++ = (*outof >> 24) & 0xffL;
182 *into++ = (*outof >> 16) & 0xffL; 175 *into++ = (*outof >> 16) & 0xffL;
183 *into++ = (*outof >> 8) & 0xffL; 176 *into++ = (*outof >> 8) & 0xffL;
184 *into++ = *outof++ & 0xffL; 177 *into++ = *outof++ & 0xffL;
185 *into++ = (*outof >> 24) & 0xffL; 178 *into++ = (*outof >> 24) & 0xffL;
186 *into++ = (*outof >> 16) & 0xffL; 179 *into++ = (*outof >> 16) & 0xffL;
187 *into++ = (*outof >> 8) & 0xffL; 180 *into++ = (*outof >> 8) & 0xffL;
188 *into = *outof & 0xffL; 181 *into = *outof & 0xffL;
189 return; 182 return;
190 } 183 }
191 184
192static unsigned long SP1[64] = { 185static unsigned long SP1[64] = {
193 0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L, 186 0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
194 0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L, 187 0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
195 0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L, 188 0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
196 0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L, 189 0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L,
197 0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L, 190 0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L,
198 0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L, 191 0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L,
199 0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L, 192 0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L,
200 0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L, 193 0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L,
201 0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L, 194 0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L,
202 0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L, 195 0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L,
203 0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L, 196 0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L,
204 0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L, 197 0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L,
205 0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L, 198 0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
206 0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L, 199 0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
207 0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L, 200 0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
208 0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L }; 201 0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L };
209 202
210static unsigned long SP2[64] = { 203static unsigned long SP2[64] = {
211 0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L, 204 0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
212 0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L, 205 0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
213 0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L, 206 0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
214 0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L, 207 0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L,
215 0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L, 208 0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L,
216 0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L, 209 0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L,
217 0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L, 210 0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L,
218 0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L, 211 0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L,
219 0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L, 212 0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L,
220 0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L, 213 0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L,
221 0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L, 214 0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L,
222 0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L, 215 0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L,
223 0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L, 216 0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
224 0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L, 217 0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
225 0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L, 218 0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
226 0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L }; 219 0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L };
227 220
228static unsigned long SP3[64] = { 221static unsigned long SP3[64] = {
229 0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L, 222 0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
230 0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L, 223 0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
231 0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L, 224 0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
232 0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L, 225 0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L,
233 0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L, 226 0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L,
234 0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L, 227 0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L,
235 0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L, 228 0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L,
236 0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L, 229 0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L,
237 0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L, 230 0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L,
238 0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L, 231 0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L,
239 0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L, 232 0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L,
240 0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L, 233 0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L,
241 0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L, 234 0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
242 0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L, 235 0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
243 0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L, 236 0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
244 0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L }; 237 0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L };
245 238
246static unsigned long SP4[64] = { 239static unsigned long SP4[64] = {
247 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 240 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
248 0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L, 241 0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
249 0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L, 242 0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
250 0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L, 243 0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L,
251 0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L, 244 0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L,
252 0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L, 245 0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L,
253 0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L, 246 0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L,
254 0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L, 247 0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L,
255 0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L, 248 0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L,
256 0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L, 249 0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L,
257 0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L, 250 0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L,
258 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 251 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
259 0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L, 252 0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
260 0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L, 253 0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
261 0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L, 254 0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
262 0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L }; 255 0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L };
263 256
264static unsigned long SP5[64] = { 257static unsigned long SP5[64] = {
265 0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L, 258 0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
266 0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L, 259 0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
267 0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L, 260 0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
268 0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L, 261 0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L,
269 0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L, 262 0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L,
270 0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L, 263 0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L,
271 0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L, 264 0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L,
272 0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L, 265 0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L,
273 0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L, 266 0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L,
274 0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L, 267 0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L,
275 0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L, 268 0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L,
276 0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L, 269 0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L,
277 0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L, 270 0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
278 0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L, 271 0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
279 0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L, 272 0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
280 0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L }; 273 0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L };
281 274
282static unsigned long SP6[64] = { 275static unsigned long SP6[64] = {
283 0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L, 276 0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
284 0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L, 277 0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
285 0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L, 278 0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
286 0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L, 279 0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L,
287 0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L, 280 0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L,
288 0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L, 281 0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L,
289 0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L, 282 0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L,
290 0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L, 283 0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L,
291 0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L, 284 0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L,
292 0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L, 285 0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L,
293 0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L, 286 0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L,
294 0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L, 287 0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L,
295 0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L, 288 0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
296 0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L, 289 0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
297 0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L, 290 0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
298 0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L }; 291 0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L };
299 292
300static unsigned long SP7[64] = { 293static unsigned long SP7[64] = {
301 0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L, 294 0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
302 0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L, 295 0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
303 0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L, 296 0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
304 0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L, 297 0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L,
305 0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L, 298 0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L,
306 0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L, 299 0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L,
307 0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L, 300 0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L,
308 0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L, 301 0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L,
309 0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L, 302 0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L,
310 0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L, 303 0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L,
311 0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L, 304 0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L,
312 0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L, 305 0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L,
313 0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L, 306 0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
314 0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L, 307 0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
315 0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L, 308 0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
316 0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L }; 309 0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L };
317 310
318static unsigned long SP8[64] = { 311static unsigned long SP8[64] = {
319 0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L, 312 0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
320 0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L, 313 0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
321 0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L, 314 0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
322 0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L, 315 0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L,
323 0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L, 316 0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L,
324 0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L, 317 0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L,
325 0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L, 318 0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L,
326 0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L, 319 0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L,
327 0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L, 320 0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L,
328 0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L, 321 0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L,
329 0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L, 322 0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L,
330 0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L, 323 0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L,
331 0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L, 324 0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L,
332 0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L, 325 0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
333 0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L, 326 0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
334 0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L }; 327 0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L };
335 328
336static void desfunc(block, keys) 329static void desfunc(block, keys)
337register unsigned long *block, *keys; 330register unsigned long *block, *keys;
338{ 331{
339 register unsigned long fval, work, right, leftt; 332 register unsigned long fval, work, right, leftt;
340 register int round; 333 register int round;
341 334
342 leftt = block[0]; 335 leftt = block[0];
343 right = block[1]; 336 right = block[1];
344 work = ((leftt >> 4) ^ right) & 0x0f0f0f0fL; 337 work = ((leftt >> 4) ^ right) & 0x0f0f0f0fL;
345 right ^= work; 338 right ^= work;
346 leftt ^= (work << 4); 339 leftt ^= (work << 4);
347 work = ((leftt >> 16) ^ right) & 0x0000ffffL; 340 work = ((leftt >> 16) ^ right) & 0x0000ffffL;
348 right ^= work; 341 right ^= work;
349 leftt ^= (work << 16); 342 leftt ^= (work << 16);
350 work = ((right >> 2) ^ leftt) & 0x33333333L; 343 work = ((right >> 2) ^ leftt) & 0x33333333L;
351 leftt ^= work; 344 leftt ^= work;
352 right ^= (work << 2); 345 right ^= (work << 2);
353 work = ((right >> 8) ^ leftt) & 0x00ff00ffL; 346 work = ((right >> 8) ^ leftt) & 0x00ff00ffL;
354 leftt ^= work; 347 leftt ^= work;
355 right ^= (work << 8); 348 right ^= (work << 8);
356 right = ((right << 1) | ((right >> 31) & 1L)) & 0xffffffffL; 349 right = ((right << 1) | ((right >> 31) & 1L)) & 0xffffffffL;
357 work = (leftt ^ right) & 0xaaaaaaaaL; 350 work = (leftt ^ right) & 0xaaaaaaaaL;
358 leftt ^= work; 351 leftt ^= work;
359 right ^= work; 352 right ^= work;
360 leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL; 353 leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL;
361 354
362 for( round = 0; round < 8; round++ ) { 355 for( round = 0; round < 8; round++ ) {
363 work = (right << 28) | (right >> 4); 356 work = (right << 28) | (right >> 4);
364 work ^= *keys++; 357 work ^= *keys++;
365 fval = SP7[ work & 0x3fL]; 358 fval = SP7[ work & 0x3fL];
366 fval |= SP5[(work >> 8) & 0x3fL]; 359 fval |= SP5[(work >> 8) & 0x3fL];
367 fval |= SP3[(work >> 16) & 0x3fL]; 360 fval |= SP3[(work >> 16) & 0x3fL];
368 fval |= SP1[(work >> 24) & 0x3fL]; 361 fval |= SP1[(work >> 24) & 0x3fL];
369 work = right ^ *keys++; 362 work = right ^ *keys++;
370 fval |= SP8[ work & 0x3fL]; 363 fval |= SP8[ work & 0x3fL];
371 fval |= SP6[(work >> 8) & 0x3fL]; 364 fval |= SP6[(work >> 8) & 0x3fL];
372 fval |= SP4[(work >> 16) & 0x3fL]; 365 fval |= SP4[(work >> 16) & 0x3fL];
373 fval |= SP2[(work >> 24) & 0x3fL]; 366 fval |= SP2[(work >> 24) & 0x3fL];
374 leftt ^= fval; 367 leftt ^= fval;
375 work = (leftt << 28) | (leftt >> 4); 368 work = (leftt << 28) | (leftt >> 4);
376 work ^= *keys++; 369 work ^= *keys++;
377 fval = SP7[ work & 0x3fL]; 370 fval = SP7[ work & 0x3fL];
378 fval |= SP5[(work >> 8) & 0x3fL]; 371 fval |= SP5[(work >> 8) & 0x3fL];
379 fval |= SP3[(work >> 16) & 0x3fL]; 372 fval |= SP3[(work >> 16) & 0x3fL];
380 fval |= SP1[(work >> 24) & 0x3fL]; 373 fval |= SP1[(work >> 24) & 0x3fL];
381 work = leftt ^ *keys++; 374 work = leftt ^ *keys++;
382 fval |= SP8[ work & 0x3fL]; 375 fval |= SP8[ work & 0x3fL];
383 fval |= SP6[(work >> 8) & 0x3fL]; 376 fval |= SP6[(work >> 8) & 0x3fL];
384 fval |= SP4[(work >> 16) & 0x3fL]; 377 fval |= SP4[(work >> 16) & 0x3fL];
385 fval |= SP2[(work >> 24) & 0x3fL]; 378 fval |= SP2[(work >> 24) & 0x3fL];
386 right ^= fval; 379 right ^= fval;
387 } 380 }
388 381
389 right = (right << 31) | (right >> 1); 382 right = (right << 31) | (right >> 1);
390 work = (leftt ^ right) & 0xaaaaaaaaL; 383 work = (leftt ^ right) & 0xaaaaaaaaL;
391 leftt ^= work; 384 leftt ^= work;
392 right ^= work; 385 right ^= work;
393 leftt = (leftt << 31) | (leftt >> 1); 386 leftt = (leftt << 31) | (leftt >> 1);
394 work = ((leftt >> 8) ^ right) & 0x00ff00ffL; 387 work = ((leftt >> 8) ^ right) & 0x00ff00ffL;
395 right ^= work; 388 right ^= work;
396 leftt ^= (work << 8); 389 leftt ^= (work << 8);
397 work = ((leftt >> 2) ^ right) & 0x33333333L; 390 work = ((leftt >> 2) ^ right) & 0x33333333L;
398 right ^= work; 391 right ^= work;
399 leftt ^= (work << 2); 392 leftt ^= (work << 2);
400 work = ((right >> 16) ^ leftt) & 0x0000ffffL; 393 work = ((right >> 16) ^ leftt) & 0x0000ffffL;
401 leftt ^= work; 394 leftt ^= work;
402 right ^= (work << 16); 395 right ^= (work << 16);
403 work = ((right >> 4) ^ leftt) & 0x0f0f0f0fL; 396 work = ((right >> 4) ^ leftt) & 0x0f0f0f0fL;
404 leftt ^= work; 397 leftt ^= work;
405 right ^= (work << 4); 398 right ^= (work << 4);
406 *block++ = right; 399 *block++ = right;
407 *block = leftt; 400 *block = leftt;
408 return; 401 return;
409 } 402 }
410 403
411/* Validation sets: 404/* Validation sets:
412 * 405 *
413 * Single-length key, single-length plaintext - 406 * Single-length key, single-length plaintext -
414 * Key : 0123 4567 89ab cdef 407 * Key : 0123 4567 89ab cdef
415 * Plain : 0123 4567 89ab cde7 408 * Plain : 0123 4567 89ab cde7
416 * Cipher : c957 4425 6a5e d31d 409 * Cipher : c957 4425 6a5e d31d
417 * 410 *
418 * Double-length key, single-length plaintext - 411 * Double-length key, single-length plaintext -
419 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 412 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210
420 * Plain : 0123 4567 89ab cde7 413 * Plain : 0123 4567 89ab cde7
421 * Cipher : 7f1d 0a77 826b 8aff 414 * Cipher : 7f1d 0a77 826b 8aff
422 * 415 *
423 * Double-length key, double-length plaintext - 416 * Double-length key, double-length plaintext -
424 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 417 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210
425 * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff 418 * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff
426 * Cipher : 27a0 8440 406a df60 278f 47cf 42d6 15d7 419 * Cipher : 27a0 8440 406a df60 278f 47cf 42d6 15d7
427 * 420 *
428 * Triple-length key, single-length plaintext - 421 * Triple-length key, single-length plaintext -
429 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567 422 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567
430 * Plain : 0123 4567 89ab cde7 423 * Plain : 0123 4567 89ab cde7
431 * Cipher : de0b 7c06 ae5e 0ed5 424 * Cipher : de0b 7c06 ae5e 0ed5
432 * 425 *
433 * Triple-length key, double-length plaintext - 426 * Triple-length key, double-length plaintext -
434 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567 427 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567
435 * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff 428 * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff
436 * Cipher : ad0d 1b30 ac17 cf07 0ed1 1c63 81e4 4de5 429 * Cipher : ad0d 1b30 ac17 cf07 0ed1 1c63 81e4 4de5
437 * 430 *
438 * d3des V5.0a rwo 9208.07 18:44 Graven Imagery 431 * d3des V5.0a rwo 9208.07 18:44 Graven Imagery
439 **********************************************************************/ 432 **********************************************************************/
diff --git a/noncore/comm/keypebble/krfbcanvas.cpp b/noncore/comm/keypebble/krfbcanvas.cpp
index b3525df..d5b8ce7 100644
--- a/noncore/comm/keypebble/krfbcanvas.cpp
+++ b/noncore/comm/keypebble/krfbcanvas.cpp
@@ -1,204 +1,206 @@
1#include "krfbconnection.h" 1#include "krfbconnection.h"
2#include "krfbcanvas.h" 2#include "krfbcanvas.h"
3#include "krfbbuffer.h" 3#include "krfbbuffer.h"
4 4
5/* OPIE */ 5/* OPIE */
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
8using namespace Opie::Core; 8using namespace Opie::Core;
9 9
10/* QT */ 10/* QT */
11#include <qclipboard.h> 11#include <qclipboard.h>
12 12
13KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name ) 13KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name )
14 : QScrollView( parent, name ) 14 : QScrollView( parent, name )
15{ 15{
16 connection_ = new KRFBConnection(); 16 connection_ = new KRFBConnection();
17 connect( connection_, SIGNAL( loggedIn() ), 17 connect( connection_, SIGNAL( loggedIn() ),
18 this, SLOT( loggedIn() ) ); 18 this, SLOT( loggedIn() ) );
19 19
20 loggedIn_ = false; 20 loggedIn_ = false;
21 21
22 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold); 22 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold);
23 23
24 viewport()->setFocusPolicy( QWidget::StrongFocus ); 24 viewport()->setFocusPolicy( QWidget::StrongFocus );
25 viewport()->setFocus(); 25 viewport()->setFocus();
26 26
27 nextRightClick=0; 27 nextRightClick=0;
28 nextDoubleClick=0; 28 nextDoubleClick=0;
29} 29}
30 30
31KRFBCanvas::~KRFBCanvas() 31KRFBCanvas::~KRFBCanvas()
32{ 32{
33} 33}
34 34
35 35
36void KRFBCanvas::openConnection(KRFBServer server) 36void KRFBCanvas::openConnection(KRFBServer server)
37{ 37{
38 38
39 39
40 QCString host = server.hostname.latin1(); 40 QCString host = server.hostname.latin1();
41 password=server.password; 41 password=server.password;
42 connection_->connectTo( server); 42 connection_->connectTo( server);
43} 43}
44 44
45 45
46void KRFBCanvas::openURL( const QUrl &url ) 46void KRFBCanvas::openURL( const QUrl &url )
47{ 47{
48 if ( loggedIn_ ) { 48 if ( loggedIn_ ) {
49 owarn << "openURL invoked when logged in\n" << oendl; 49 owarn << "openURL invoked when logged in\n" << oendl;
50 return; 50 return;
51 } 51 }
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 Q_UNUSED( host )
56 Q_UNUSED( display )
55 57
56// connection_->connectTo( host, display ); 58// connection_->connectTo( host, display );
57} 59}
58 60
59void KRFBCanvas::closeConnection() 61void KRFBCanvas::closeConnection()
60{ 62{
61 loggedIn_ = false; 63 loggedIn_ = false;
62 connection_->disconnect(); 64 connection_->disconnect();
63 65
64 viewport()->setMouseTracking( false ); 66 viewport()->setMouseTracking( false );
65 viewport()->setBackgroundMode( PaletteDark ); 67 viewport()->setBackgroundMode( PaletteDark );
66 setBackgroundMode( PaletteDark ); 68 setBackgroundMode( PaletteDark );
67 update(); 69 update();
68} 70}
69 71
70 72
71void KRFBCanvas::bell() 73void KRFBCanvas::bell()
72{ 74{
73 if ( connection_->options()->deIconify ) { 75 if ( connection_->options()->deIconify ) {
74 topLevelWidget()->raise(); 76 topLevelWidget()->raise();
75 topLevelWidget()->show(); 77 topLevelWidget()->show();
76 } 78 }
77} 79}
78 80
79void KRFBCanvas::loggedIn() 81void KRFBCanvas::loggedIn()
80{ 82{
81 owarn << "Ok, we're logged in" << oendl; 83 owarn << "Ok, we're logged in" << oendl;
82 84
83 // 85 //
84 // Get ready for action 86 // Get ready for action
85 // 87 //
86 loggedIn_ = true; 88 loggedIn_ = true;
87 viewport()->setMouseTracking( true ); 89 viewport()->setMouseTracking( true );
88 viewport()->setBackgroundMode( NoBackground ); 90 viewport()->setBackgroundMode( NoBackground );
89 setBackgroundMode( NoBackground ); 91 setBackgroundMode( NoBackground );
90 92
91 // Start using the buffer 93 // Start using the buffer
92 connect( connection_->buffer(), SIGNAL( sizeChanged(int,int) ), 94 connect( connection_->buffer(), SIGNAL( sizeChanged(int,int) ),
93 this, SLOT( resizeContents(int,int) ) ); 95 this, SLOT( resizeContents(int,int) ) );
94 connect( connection_->buffer(), SIGNAL( updated(int,int,int,int) ), 96 connect( connection_->buffer(), SIGNAL( updated(int,int,int,int) ),
95 this, SLOT( viewportUpdate(int,int,int,int) ) ); 97 this, SLOT( viewportUpdate(int,int,int,int) ) );
96 connect( connection_->buffer(), SIGNAL( bell() ), 98 connect( connection_->buffer(), SIGNAL( bell() ),
97 this, SLOT( bell() ) ); 99 this, SLOT( bell() ) );
98 connect( qApp->clipboard(), SIGNAL( dataChanged() ), 100 connect( qApp->clipboard(), SIGNAL( dataChanged() ),
99 this, SLOT( clipboardChanged() ) ); 101 this, SLOT( clipboardChanged() ) );
100} 102}
101 103
102void KRFBCanvas::viewportPaintEvent( QPaintEvent *e ) 104void KRFBCanvas::viewportPaintEvent( QPaintEvent *e )
103{ 105{
104 QRect r = e->rect(); 106 QRect r = e->rect();
105 107
106 if ( loggedIn_ ) { 108 if ( loggedIn_ ) {
107 QPixmap p; 109 QPixmap p;
108 110
109 bitBlt( viewport(), r.x(), r.y(), 111 bitBlt( viewport(), r.x(), r.y(),
110 connection_->buffer()->pixmap(), 112 connection_->buffer()->pixmap(),
111 r.x() + contentsX(), r.y() + contentsY(), 113 r.x() + contentsX(), r.y() + contentsY(),
112 r.width(), r.height() ); 114 r.width(), r.height() );
113 } 115 }
114 else { 116 else {
115 QScrollView::viewportPaintEvent( e ); 117 QScrollView::viewportPaintEvent( e );
116 } 118 }
117} 119}
118 120
119void KRFBCanvas::viewportUpdate( int x, int y, int w, int h ) 121void KRFBCanvas::viewportUpdate( int x, int y, int w, int h )
120{ 122{
121 updateContents( x, y, w, h ); 123 updateContents( x, y, w, h );
122} 124}
123 125
124void KRFBCanvas::contentsMousePressEvent( QMouseEvent *e ) 126void KRFBCanvas::contentsMousePressEvent( QMouseEvent *e )
125{ 127{
126 128
127 if (nextDoubleClick) { 129 if (nextDoubleClick) {
128 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),LeftButton,LeftButton)); 130 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),LeftButton,LeftButton));
129 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0)); 131 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0));
130 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0)); 132 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0));
131 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton)); 133 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton));
132 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0)); 134 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0));
133 } if (nextRightClick) { 135 } if (nextRightClick) {
134 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),RightButton,RightButton)); 136 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),RightButton,RightButton));
135 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),RightButton,0)); 137 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),RightButton,0));
136 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton)); 138 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton));
137 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0)); 139 connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0));
138 } else if ( loggedIn_ ) 140 } else if ( loggedIn_ )
139 connection_->buffer()->mouseEvent( e ); 141 connection_->buffer()->mouseEvent( e );
140 142
141} 143}
142 144
143void KRFBCanvas::contentsMouseReleaseEvent( QMouseEvent *e ) 145void KRFBCanvas::contentsMouseReleaseEvent( QMouseEvent *e )
144{ 146{
145 if ( loggedIn_ && !nextRightClick && !nextDoubleClick) { 147 if ( loggedIn_ && !nextRightClick && !nextDoubleClick) {
146 connection_->buffer()->mouseEvent( e ); 148 connection_->buffer()->mouseEvent( e );
147 } 149 }
148 150
149 nextRightClick=0; 151 nextRightClick=0;
150 nextDoubleClick=0; 152 nextDoubleClick=0;
151} 153}
152 154
153void KRFBCanvas::contentsMouseMoveEvent( QMouseEvent *e ) 155void KRFBCanvas::contentsMouseMoveEvent( QMouseEvent *e )
154{ 156{
155 if ( loggedIn_ ) 157 if ( loggedIn_ )
156 connection_->buffer()->mouseEvent( e ); 158 connection_->buffer()->mouseEvent( e );
157} 159}
158 160
159void KRFBCanvas::keyPressEvent( QKeyEvent *e ) 161void KRFBCanvas::keyPressEvent( QKeyEvent *e )
160{ 162{
161 if ( loggedIn_ ) 163 if ( loggedIn_ )
162 connection_->buffer()->keyPressEvent( e ); 164 connection_->buffer()->keyPressEvent( e );
163} 165}
164 166
165void KRFBCanvas::keyReleaseEvent( QKeyEvent *e ) 167void KRFBCanvas::keyReleaseEvent( QKeyEvent *e )
166{ 168{
167 if ( loggedIn_ ) 169 if ( loggedIn_ )
168 connection_->buffer()->keyReleaseEvent( e ); 170 connection_->buffer()->keyReleaseEvent( e );
169} 171}
170 172
171void KRFBCanvas::refresh() 173void KRFBCanvas::refresh()
172{ 174{
173 if ( loggedIn_ ) 175 if ( loggedIn_ )
174 connection_->refresh(); 176 connection_->refresh();
175} 177}
176 178
177void KRFBCanvas::clipboardChanged() 179void KRFBCanvas::clipboardChanged()
178{ 180{
179 if ( loggedIn_ ) { 181 if ( loggedIn_ ) {
180 connection_->sendCutText( qApp->clipboard()->text() ); 182 connection_->sendCutText( qApp->clipboard()->text() );
181 } 183 }
182} 184}
183void KRFBCanvas::sendCtlAltDel( void) 185void KRFBCanvas::sendCtlAltDel( void)
184{ 186{
185 187
186 if ( loggedIn_ ) { 188 if ( loggedIn_ ) {
187 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Control, 0,0)); 189 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Control, 0,0));
188 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Alt, 0,0)); 190 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Alt, 0,0));
189 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Delete, 0,0)); 191 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Delete, 0,0));
190 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Control, 0,0)); 192 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Control, 0,0));
191 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Alt, 0,0)); 193 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Alt, 0,0));
192 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Delete, 0,0)); 194 connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Delete, 0,0));
193 } 195 }
194} 196}
195 197
196void KRFBCanvas::markDoubleClick( void) 198void KRFBCanvas::markDoubleClick( void)
197{ 199{
198 nextRightClick=1; 200 nextRightClick=1;
199} 201}
200 202
201void KRFBCanvas::markRightClick( void) 203void KRFBCanvas::markRightClick( void)
202{ 204{
203 nextRightClick=1; 205 nextRightClick=1;
204} 206}
diff --git a/noncore/comm/keypebble/kvnc.cpp b/noncore/comm/keypebble/kvnc.cpp
index 88cb50b..3a8e919 100644
--- a/noncore/comm/keypebble/kvnc.cpp
+++ b/noncore/comm/keypebble/kvnc.cpp
@@ -1,279 +1,279 @@
1#include <qaction.h> 1#include <qaction.h>
2#include <qpopupmenu.h> 2#include <qpopupmenu.h>
3#include <qpushbutton.h> 3#include <qpushbutton.h>
4#include <qmessagebox.h> 4#include <qmessagebox.h>
5#include <qlistbox.h> 5#include <qlistbox.h>
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8 8
9#include <assert.h> 9#include <assert.h>
10 10
11#include "kvnc.h" 11#include "kvnc.h"
12#include "krfbcanvas.h" 12#include "krfbcanvas.h"
13#include "krfbconnection.h" 13#include "krfbconnection.h"
14#include "kvncconndlg.h" 14#include "kvncconndlg.h"
15 15
16static int u_id = 1; 16static int u_id = 1;
17static int get_unique_id() 17static int get_unique_id()
18{ 18{
19 return u_id++; 19 return u_id++;
20} 20}
21 21
22 22
23/* XPM */ 23/* XPM */
24static char * menu_xpm[] = { 24static char * menu_xpm[] = {
25"12 12 5 1", 25"12 12 5 1",
26 " c None", 26 " c None",
27 ".c #000000", 27 ".c #000000",
28 "+c #FFFDAD", 28 "+c #FFFDAD",
29 "@c #FFFF00", 29 "@c #FFFF00",
30 "#c #E5E100", 30 "#c #E5E100",
31" ", 31" ",
32" ", 32" ",
33" ......... ", 33" ......... ",
34" .+++++++. ", 34" .+++++++. ",
35" .+@@@@#. ", 35" .+@@@@#. ",
36" .+@@@#. ", 36" .+@@@#. ",
37" .+@@#. ", 37" .+@@#. ",
38" .+@#. ", 38" .+@#. ",
39" .+#. ", 39" .+#. ",
40" .+. ", 40" .+. ",
41" .. ", 41" .. ",
42" "}; 42" "};
43 43
44const int StatusTextId = 0; 44const int StatusTextId = 0;
45 45
46KVNC::KVNC( QWidget *parent, const char *name, WFlags f) : QMainWindow( 0, name ,WStyle_ContextHelp) 46KVNC::KVNC( QWidget *parent, const char *name, WFlags ) : QMainWindow( parent, name ,WStyle_ContextHelp)
47{ 47{
48 setCaption( tr("VNC Viewer") ); 48 setCaption( tr("VNC Viewer") );
49 fullscreen = false; 49 fullscreen = false;
50 50
51 stack = new QWidgetStack( this ); 51 stack = new QWidgetStack( this );
52 setCentralWidget( stack ); 52 setCentralWidget( stack );
53 53
54 bookmarkSelector=new KVNCBookmarkDlg(); 54 bookmarkSelector=new KVNCBookmarkDlg();
55 stack->addWidget(bookmarkSelector,get_unique_id()); 55 stack->addWidget(bookmarkSelector,get_unique_id());
56 stack->raiseWidget( bookmarkSelector ); 56 stack->raiseWidget( bookmarkSelector );
57 57
58 canvas = new KRFBCanvas( stack, "canvas" ); 58 canvas = new KRFBCanvas( stack, "canvas" );
59 stack->addWidget(canvas,get_unique_id()); 59 stack->addWidget(canvas,get_unique_id());
60 setCentralWidget( stack ); 60 setCentralWidget( stack );
61 61
62 62
63 connect( bookmarkSelector->bookmarkList, SIGNAL(clicked(QListBoxItem*)), 63 connect( bookmarkSelector->bookmarkList, SIGNAL(clicked(QListBoxItem*)),
64 this, SLOT(openConnection(QListBoxItem*)) ); 64 this, SLOT(openConnection(QListBoxItem*)) );
65 connect( canvas->connection(), SIGNAL(statusChanged(const QString&)), 65 connect( canvas->connection(), SIGNAL(statusChanged(const QString&)),
66 this, SLOT(statusMessage(const QString&)) ); 66 this, SLOT(statusMessage(const QString&)) );
67 connect( canvas->connection(), SIGNAL(error(const QString&)), 67 connect( canvas->connection(), SIGNAL(error(const QString&)),
68 this, SLOT(error(const QString&)) ); 68 this, SLOT(error(const QString&)) );
69 connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) ); 69 connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) );
70 connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) ); 70 connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) );
71 connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) ); 71 connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) );
72 72
73 setupActions(); 73 setupActions();
74 74
75 cornerButton = new QPushButton( this ); 75 cornerButton = new QPushButton( this );
76 cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); 76 cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
77 connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) ); 77 connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) );
78 canvas->setCornerWidget( cornerButton ); 78 canvas->setCornerWidget( cornerButton );
79 79
80 stack->raiseWidget( bookmarkSelector ); 80 stack->raiseWidget( bookmarkSelector );
81 81
82 82
83 bar= new QToolBar( this ); 83 bar= new QToolBar( this );
84 setToolBarsMovable( false ); 84 setToolBarsMovable( false );
85 setRightJustification(false); 85 setRightJustification(false);
86 86
87 87
88 QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ), 88 QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ),
89 QString::null, 0, this, 0 ); 89 QString::null, 0, this, 0 );
90 connect( n, SIGNAL( activated() ), 90 connect( n, SIGNAL( activated() ),
91 this, SLOT( newConnection() ) ); 91 this, SLOT( newConnection() ) );
92 n->addTo( bar ); 92 n->addTo( bar );
93 93
94 QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "fileopen" ), 94 QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "fileopen" ),
95 QString::null, 0, this, 0 ); 95 QString::null, 0, this, 0 );
96 connect( o, SIGNAL( activated() ), 96 connect( o, SIGNAL( activated() ),
97 this, SLOT( openConnection() ) ); 97 this, SLOT( openConnection() ) );
98 o->addTo( bar ); 98 o->addTo( bar );
99 99
100 QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ), 100 QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ),
101 QString::null, 0, this, 0 ); 101 QString::null, 0, this, 0 );
102 connect( d, SIGNAL( activated() ), 102 connect( d, SIGNAL( activated() ),
103 this, SLOT( deleteBookmark() ) ); 103 this, SLOT( deleteBookmark() ) );
104 d->addTo( bar ); 104 d->addTo( bar );
105} 105}
106 106
107KVNC::~KVNC() 107KVNC::~KVNC()
108{ 108{
109 109
110} 110}
111 111
112void KVNC::newConnection() 112void KVNC::newConnection()
113{ 113{
114 curServer=new KRFBServer; 114 curServer=new KRFBServer;
115 115
116 KVNCConnDlg dlg( curServer,this); 116 KVNCConnDlg dlg( curServer,this);
117 if ( QPEApplication::execDialog( &dlg )) { 117 if ( QPEApplication::execDialog( &dlg )) {
118 if (!curServer->name.isEmpty()) 118 if (!curServer->name.isEmpty())
119 bookmarkSelector->addBookmark(curServer); 119 bookmarkSelector->addBookmark(curServer);
120 canvas->openConnection(*curServer); 120 canvas->openConnection(*curServer);
121 } else 121 } else
122 curServer=0; 122 curServer=0;
123} 123}
124 124
125void KVNC::openConnection( QString name) 125void KVNC::openConnection( QString name)
126{ 126{
127 curServer=bookmarkSelector->getServer(name); 127 curServer=bookmarkSelector->getServer(name);
128 128
129 if (curServer) { 129 if (curServer) {
130 KVNCConnDlg dlg( curServer,this); 130 KVNCConnDlg dlg( curServer,this);
131 if ( QPEApplication::execDialog( &dlg ) ) { 131 if ( QPEApplication::execDialog( &dlg ) ) {
132 canvas->openConnection(*curServer); 132 canvas->openConnection(*curServer);
133 bookmarkSelector->writeBookmarks(); 133 bookmarkSelector->writeBookmarks();
134 } else 134 } else
135 curServer=0; 135 curServer=0;
136 } 136 }
137} 137}
138 138
139void KVNC::openConnection( void ) 139void KVNC::openConnection( void )
140{ 140{
141 openConnection( bookmarkSelector->selectedBookmark()); 141 openConnection( bookmarkSelector->selectedBookmark());
142} 142}
143 143
144void KVNC::openConnection( QListBoxItem * item) 144void KVNC::openConnection( QListBoxItem * item)
145{ 145{
146 if (item) 146 if (item)
147 openConnection(item->text()); 147 openConnection(item->text());
148} 148}
149 149
150void KVNC::setupActions() 150void KVNC::setupActions()
151{ 151{
152 cornerMenu = new QPopupMenu( this ); 152 cornerMenu = new QPopupMenu( this );
153 153
154 fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 ); 154 fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 );
155 connect( fullScreenAction, SIGNAL(activated()), 155 connect( fullScreenAction, SIGNAL(activated()),
156 this, SLOT( toggleFullScreen() ) ); 156 this, SLOT( toggleFullScreen() ) );
157 fullScreenAction->addTo( cornerMenu ); 157 fullScreenAction->addTo( cornerMenu );
158 fullScreenAction->setEnabled( false ); 158 fullScreenAction->setEnabled( false );
159 159
160 ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 ); 160 ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 );
161 connect( ctlAltDelAction, SIGNAL(activated()), 161 connect( ctlAltDelAction, SIGNAL(activated()),
162 canvas, SLOT( sendCtlAltDel() ) ); 162 canvas, SLOT( sendCtlAltDel() ) );
163 ctlAltDelAction->addTo( cornerMenu ); 163 ctlAltDelAction->addTo( cornerMenu );
164 ctlAltDelAction->setEnabled( false ); 164 ctlAltDelAction->setEnabled( false );
165 165
166 disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 ); 166 disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 );
167 connect( disconnectAction, SIGNAL(activated()), 167 connect( disconnectAction, SIGNAL(activated()),
168 this, SLOT( closeConnection() ) ); 168 this, SLOT( closeConnection() ) );
169 disconnectAction->addTo( cornerMenu ); 169 disconnectAction->addTo( cornerMenu );
170 disconnectAction->setEnabled( false ); 170 disconnectAction->setEnabled( false );
171 171
172 doubleClickAction = new QAction( tr("Next Click is Double Click"), QString::null, 0, 0 ); 172 doubleClickAction = new QAction( tr("Next Click is Double Click"), QString::null, 0, 0 );
173 connect( doubleClickAction, SIGNAL(activated()), 173 connect( doubleClickAction, SIGNAL(activated()),
174 canvas, SLOT( markDoubleClick() ) ); 174 canvas, SLOT( markDoubleClick() ) );
175 doubleClickAction->addTo( cornerMenu ); 175 doubleClickAction->addTo( cornerMenu );
176 doubleClickAction->setEnabled( false ); 176 doubleClickAction->setEnabled( false );
177 177
178 rightClickAction = new QAction( tr("Next Click is Right Click"), QString::null, 0, 0 ); 178 rightClickAction = new QAction( tr("Next Click is Right Click"), QString::null, 0, 0 );
179 connect( rightClickAction, SIGNAL(activated()), 179 connect( rightClickAction, SIGNAL(activated()),
180 canvas, SLOT( markRightClick() ) ); 180 canvas, SLOT( markRightClick() ) );
181 rightClickAction->addTo( cornerMenu ); 181 rightClickAction->addTo( cornerMenu );
182 rightClickAction->setEnabled( false ); 182 rightClickAction->setEnabled( false );
183} 183}
184 184
185void KVNC::toggleFullScreen() 185void KVNC::toggleFullScreen()
186{ 186{
187 if ( fullscreen ) { 187 if ( fullscreen ) {
188 canvas->releaseKeyboard(); 188 canvas->releaseKeyboard();
189 canvas->reparent( stack, 0, QPoint(0,0), false ); 189 canvas->reparent( stack, 0, QPoint(0,0), false );
190 canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 190 canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken );
191 setCentralWidget( stack ); 191 setCentralWidget( stack );
192 stack->addWidget(canvas,get_unique_id()); 192 stack->addWidget(canvas,get_unique_id());
193 stack->raiseWidget(canvas); 193 stack->raiseWidget(canvas);
194 canvas->show(); 194 canvas->show();
195 stack->show(); 195 stack->show();
196 fullScreenAction->setText( tr("Full Screen") ); 196 fullScreenAction->setText( tr("Full Screen") );
197 } else { 197 } else {
198 canvas->setFrameStyle( QFrame::NoFrame ); 198 canvas->setFrameStyle( QFrame::NoFrame );
199 stack->removeWidget(canvas); 199 stack->removeWidget(canvas);
200 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, 200 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop,
201 QPoint(0,0),false); 201 QPoint(0,0),false);
202 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height()); 202 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height());
203 canvas->raise(); 203 canvas->raise();
204 canvas->setFocus(); 204 canvas->setFocus();
205 canvas->grabKeyboard(); 205 canvas->grabKeyboard();
206 canvas->show(); 206 canvas->show();
207 207
208 fullScreenAction->setText( tr("Stop Full Screen") ); 208 fullScreenAction->setText( tr("Stop Full Screen") );
209 } 209 }
210 210
211 211
212 fullscreen = !fullscreen; 212 fullscreen = !fullscreen;
213} 213}
214 214
215void KVNC::closeConnection() 215void KVNC::closeConnection()
216{ 216{
217 if ( fullscreen ) 217 if ( fullscreen )
218 toggleFullScreen(); 218 toggleFullScreen();
219 canvas->closeConnection(); 219 canvas->closeConnection();
220} 220}
221 221
222void KVNC::showMenu() 222void KVNC::showMenu()
223{ 223{
224 QPoint pt = mapToGlobal(cornerButton->pos()); 224 QPoint pt = mapToGlobal(cornerButton->pos());
225 QSize s = cornerMenu->sizeHint(); 225 QSize s = cornerMenu->sizeHint();
226 pt.ry() -= s.height(); 226 pt.ry() -= s.height();
227 pt.rx() -= s.width(); 227 pt.rx() -= s.width();
228 cornerMenu->popup( pt ); 228 cornerMenu->popup( pt );
229} 229}
230 230
231void KVNC::connected() 231void KVNC::connected()
232{ 232{
233 static QString msg = tr( "Connected to remote host" ); 233 static QString msg = tr( "Connected to remote host" );
234 statusMessage( msg ); 234 statusMessage( msg );
235 ctlAltDelAction->setEnabled(true); 235 ctlAltDelAction->setEnabled(true);
236 disconnectAction->setEnabled( true ); 236 disconnectAction->setEnabled( true );
237 fullScreenAction->setEnabled( true ); 237 fullScreenAction->setEnabled( true );
238 doubleClickAction->setEnabled( false ); 238 doubleClickAction->setEnabled( false );
239 rightClickAction->setEnabled( true ); 239 rightClickAction->setEnabled( true );
240 stack->raiseWidget(canvas); 240 stack->raiseWidget(canvas);
241 bar->hide(); 241 bar->hide();
242} 242}
243 243
244void KVNC::loggedIn() 244void KVNC::loggedIn()
245{ 245{
246 static QString msg = tr( "Logged in to remote host" ); 246 static QString msg = tr( "Logged in to remote host" );
247 statusMessage( msg ); 247 statusMessage( msg );
248} 248}
249 249
250void KVNC::disconnected() 250void KVNC::disconnected()
251{ 251{
252 252
253 if ( fullscreen ) 253 if ( fullscreen )
254 toggleFullScreen(); 254 toggleFullScreen();
255 static QString msg = tr( "Connection closed" ); 255 static QString msg = tr( "Connection closed" );
256 statusMessage( msg ); 256 statusMessage( msg );
257 ctlAltDelAction->setEnabled(false); 257 ctlAltDelAction->setEnabled(false);
258 disconnectAction->setEnabled( false ); 258 disconnectAction->setEnabled( false );
259 fullScreenAction->setEnabled( false ); 259 fullScreenAction->setEnabled( false );
260 doubleClickAction->setEnabled( false ); 260 doubleClickAction->setEnabled( false );
261 rightClickAction->setEnabled( false ); 261 rightClickAction->setEnabled( false );
262 stack->raiseWidget(bookmarkSelector); 262 stack->raiseWidget(bookmarkSelector);
263 bar->show(); 263 bar->show();
264} 264}
265 265
266void KVNC::statusMessage( const QString &m ) 266void KVNC::statusMessage( const QString &m )
267{ 267{
268 Global::statusMessage( m ); 268 Global::statusMessage( m );
269} 269}
270 270
271void KVNC::error( const QString &msg ) 271void KVNC::error( const QString &msg )
272{ 272{
273 statusMessage( msg ); 273 statusMessage( msg );
274 QMessageBox::warning( this, tr("VNC Viewer"), msg ); 274 QMessageBox::warning( this, tr("VNC Viewer"), msg );
275} 275}
276void KVNC::deleteBookmark(void) 276void KVNC::deleteBookmark(void)
277{ 277{
278 bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark()); 278 bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark());
279} 279}
diff --git a/noncore/comm/keypebble/vncauth.c b/noncore/comm/keypebble/vncauth.c
index dc276bf..277d145 100644
--- a/noncore/comm/keypebble/vncauth.c
+++ b/noncore/comm/keypebble/vncauth.c
@@ -1,160 +1,160 @@
1/* 1/*
2 * Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory 2 * Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
3 * 3 *
4 * This is free software; you can redistribute it and/or modify 4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or 6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. 7 * (at your option) any later version.
8 * 8 *
9 * This software is distributed in the hope that it will be useful, 9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA. 17 * USA.
18 */ 18 */
19 19
20/* 20/*
21 * vncauth.c - Functions for VNC password management and authentication. 21 * vncauth.c - Functions for VNC password management and authentication.
22 */ 22 */
23 23
24#include <stdio.h> 24#include <stdio.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include <string.h> 26#include <string.h>
27#include <sys/types.h> 27#include <sys/types.h>
28#include <sys/stat.h> 28#include <sys/stat.h>
29#include <time.h> 29#include <time.h>
30#include "vncauth.h" 30#include "vncauth.h"
31#include "d3des.h" 31#include "d3des.h"
32 32
33 33
34/* 34/*
35 * We use a fixed key to store passwords, since we assume that our local 35 * We use a fixed key to store passwords, since we assume that our local
36 * file system is secure but nonetheless don't want to store passwords 36 * file system is secure but nonetheless don't want to store passwords
37 * as plaintext. 37 * as plaintext.
38 */ 38 */
39 39
40unsigned char fixedkey[8] = {23,82,107,6,35,78,88,7}; 40unsigned char fixedkey[8] = {23,82,107,6,35,78,88,7};
41 41
42 42
43/* 43/*
44 * Encrypt a password and store it in a file. Returns 0 if successful, 44 * Encrypt a password and store it in a file. Returns 0 if successful,
45 * 1 if the file could not be written. 45 * 1 if the file could not be written.
46 */ 46 */
47 47
48int 48int
49vncEncryptAndStorePasswd(char *passwd, char *fname) 49vncEncryptAndStorePasswd(char *passwd, char *fname)
50{ 50{
51 FILE *fp; 51 FILE *fp;
52 int i; 52 uint i;
53 unsigned char encryptedPasswd[8]; 53 unsigned char encryptedPasswd[8];
54 54
55 if ((fp = fopen(fname,"w")) == NULL) return 1; 55 if ((fp = fopen(fname,"w")) == NULL) return 1;
56 56
57 chmod(fname, S_IRUSR|S_IWUSR); 57 chmod(fname, S_IRUSR|S_IWUSR);
58 58
59 /* pad password with nulls */ 59 /* pad password with nulls */
60 60
61 for (i = 0; i < 8; i++) { 61 for (i = 0; i < 8; i++) {
62 if (i < strlen(passwd)) { 62 if (i < strlen(passwd)) {
63 encryptedPasswd[i] = passwd[i]; 63 encryptedPasswd[i] = passwd[i];
64 } else { 64 } else {
65 encryptedPasswd[i] = 0; 65 encryptedPasswd[i] = 0;
66 } 66 }
67 } 67 }
68 68
69 /* Do encryption in-place - this way we overwrite our copy of the plaintext 69 /* Do encryption in-place - this way we overwrite our copy of the plaintext
70 password */ 70 password */
71 71
72 deskey(fixedkey, EN0); 72 deskey(fixedkey, EN0);
73 des(encryptedPasswd, encryptedPasswd); 73 des(encryptedPasswd, encryptedPasswd);
74 74
75 for (i = 0; i < 8; i++) { 75 for (i = 0; i < 8; i++) {
76 putc(encryptedPasswd[i], fp); 76 putc(encryptedPasswd[i], fp);
77 } 77 }
78 78
79 fclose(fp); 79 fclose(fp);
80 return 0; 80 return 0;
81} 81}
82 82
83 83
84/* 84/*
85 * Decrypt a password from a file. Returns a pointer to a newly allocated 85 * Decrypt a password from a file. Returns a pointer to a newly allocated
86 * string containing the password or a null pointer if the password could 86 * string containing the password or a null pointer if the password could
87 * not be retrieved for some reason. 87 * not be retrieved for some reason.
88 */ 88 */
89 89
90char * 90char *
91vncDecryptPasswdFromFile(char *fname) 91vncDecryptPasswdFromFile(char *fname)
92{ 92{
93 FILE *fp; 93 FILE *fp;
94 int i, ch; 94 int i, ch;
95 unsigned char *passwd = (unsigned char *)malloc(9); 95 unsigned char *passwd = (unsigned char *)malloc(9);
96 96
97 if ((fp = fopen(fname,"r")) == NULL) return NULL; 97 if ((fp = fopen(fname,"r")) == NULL) return NULL;
98 98
99 for (i = 0; i < 8; i++) { 99 for (i = 0; i < 8; i++) {
100 ch = getc(fp); 100 ch = getc(fp);
101 if (ch == EOF) { 101 if (ch == EOF) {
102 fclose(fp); 102 fclose(fp);
103 return NULL; 103 return NULL;
104 } 104 }
105 passwd[i] = ch; 105 passwd[i] = ch;
106 } 106 }
107 107
108 deskey(fixedkey, DE1); 108 deskey(fixedkey, DE1);
109 des(passwd, passwd); 109 des(passwd, passwd);
110 110
111 passwd[8] = 0; 111 passwd[8] = 0;
112 112
113 return (char *)passwd; 113 return (char *)passwd;
114} 114}
115 115
116 116
117/* 117/*
118 * Generate CHALLENGESIZE random bytes for use in challenge-response 118 * Generate CHALLENGESIZE random bytes for use in challenge-response
119 * authentication. 119 * authentication.
120 */ 120 */
121 121
122void 122void
123vncRandomBytes(unsigned char *bytes) 123vncRandomBytes(unsigned char *bytes)
124{ 124{
125 int i; 125 int i;
126 unsigned int seed = (unsigned int) time(0); 126 unsigned int seed = (unsigned int) time(0);
127 127
128 srandom(seed); 128 srandom(seed);
129 for (i = 0; i < CHALLENGESIZE; i++) { 129 for (i = 0; i < CHALLENGESIZE; i++) {
130 bytes[i] = (unsigned char)(random() & 255); 130 bytes[i] = (unsigned char)(random() & 255);
131 } 131 }
132} 132}
133 133
134 134
135/* 135/*
136 * Encrypt CHALLENGESIZE bytes in memory using a password. 136 * Encrypt CHALLENGESIZE bytes in memory using a password.
137 */ 137 */
138 138
139void 139void
140vncEncryptBytes(unsigned char *bytes, char *passwd) 140vncEncryptBytes(unsigned char *bytes, char *passwd)
141{ 141{
142 unsigned char key[8]; 142 unsigned char key[8];
143 int i; 143 int i;
144 144
145 /* key is simply password padded with nulls */ 145 /* key is simply password padded with nulls */
146 146
147 for (i = 0; i < 8; i++) { 147 for (i = 0; i < 8; i++) {
148 if (i < strlen(passwd)) { 148 if (i < strlen(passwd)) {
149 key[i] = passwd[i]; 149 key[i] = passwd[i];
150 } else { 150 } else {
151 key[i] = 0; 151 key[i] = 0;
152 } 152 }
153 } 153 }
154 154
155 deskey(key, EN0); 155 deskey(key, EN0);
156 156
157 for (i = 0; i < CHALLENGESIZE; i += 8) { 157 for (i = 0; i < CHALLENGESIZE; i += 8) {
158 des(bytes+i, bytes+i); 158 des(bytes+i, bytes+i);
159 } 159 }
160} 160}