summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/keypebble.pro8
-rw-r--r--noncore/comm/keypebble/krfbdecoder.cpp7
-rw-r--r--noncore/comm/keypebble/kvnc.cpp18
-rw-r--r--noncore/comm/keypebble/kvnc.h7
-rw-r--r--noncore/comm/keypebble/main.cpp11
5 files changed, 25 insertions, 26 deletions
diff --git a/noncore/comm/keypebble/keypebble.pro b/noncore/comm/keypebble/keypebble.pro
index 7af60f9..b3cb172 100644
--- a/noncore/comm/keypebble/keypebble.pro
+++ b/noncore/comm/keypebble/keypebble.pro
@@ -1,55 +1,55 @@
1TEMPLATE = app 1CONFIG += qt warn_on release quick-app
2CONFIG += qt warn_on release
3DESTDIR = $(OPIEDIR)/bin
4 HEADERS = d3des.h \ 2 HEADERS = d3des.h \
5 krfbbuffer.h \ 3 krfbbuffer.h \
6 krfbcanvas.h \ 4 krfbcanvas.h \
7 krfbconnection.h \ 5 krfbconnection.h \
8 krfbdecoder.h \ 6 krfbdecoder.h \
9 krfblogin.h \ 7 krfblogin.h \
10 krfbserver.h \ 8 krfbserver.h \
11 krfbserverinfo.h \ 9 krfbserverinfo.h \
12 kvnc.h \ 10 kvnc.h \
13 kvncconndlg.h \ 11 kvncconndlg.h \
14 kvncbookmarkdlg.h \ 12 kvncbookmarkdlg.h \
15 vncauth.h 13 vncauth.h
16 SOURCES = d3des.c \ 14 SOURCES = d3des.c \
17 vncauth.c \ 15 vncauth.c \
18 krfbbuffer.cpp \ 16 krfbbuffer.cpp \
19 krfbcanvas.cpp \ 17 krfbcanvas.cpp \
20 krfbconnection.cpp \ 18 krfbconnection.cpp \
21 krfbdecoder.cpp \ 19 krfbdecoder.cpp \
22 krfblogin.cpp \ 20 krfblogin.cpp \
23 krfbserver.cpp \ 21 krfbserver.cpp \
24 kvnc.cpp \ 22 kvnc.cpp \
25 kvncconndlg.cpp \ 23 kvncconndlg.cpp \
26 kvncbookmarkdlg.cpp \ 24 kvncbookmarkdlg.cpp \
27 main.cpp 25 main.cpp
28 INTERFACES= kvncconndlgbase.ui \ 26 INTERFACES= kvncconndlgbase.ui \
29 kvncbookmarkdlgbase.ui 27 kvncbookmarkdlgbase.ui
30TARGET = keypebble 28
31INCLUDEPATH += $(OPIEDIR)/include 29INCLUDEPATH += $(OPIEDIR)/include
32DEPENDPATH += $(OPIEDIR)/include 30DEPENDPATH += $(OPIEDIR)/include
33LIBS += -lqpe 31LIBS += -lqpe
34 32
33 TARGET = keypebble
34
35TRANSLATIONS = ../../../i18n/de/keypebble.ts \ 35TRANSLATIONS = ../../../i18n/de/keypebble.ts \
36 ../../../i18n/nl/keypebble.ts \ 36 ../../../i18n/nl/keypebble.ts \
37 ../../../i18n/da/keypebble.ts \ 37 ../../../i18n/da/keypebble.ts \
38 ../../../i18n/xx/keypebble.ts \ 38 ../../../i18n/xx/keypebble.ts \
39 ../../../i18n/en/keypebble.ts \ 39 ../../../i18n/en/keypebble.ts \
40 ../../../i18n/es/keypebble.ts \ 40 ../../../i18n/es/keypebble.ts \
41 ../../../i18n/fr/keypebble.ts \ 41 ../../../i18n/fr/keypebble.ts \
42 ../../../i18n/hu/keypebble.ts \ 42 ../../../i18n/hu/keypebble.ts \
43 ../../../i18n/ja/keypebble.ts \ 43 ../../../i18n/ja/keypebble.ts \
44 ../../../i18n/ko/keypebble.ts \ 44 ../../../i18n/ko/keypebble.ts \
45 ../../../i18n/no/keypebble.ts \ 45 ../../../i18n/no/keypebble.ts \
46 ../../../i18n/pl/keypebble.ts \ 46 ../../../i18n/pl/keypebble.ts \
47 ../../../i18n/pt/keypebble.ts \ 47 ../../../i18n/pt/keypebble.ts \
48 ../../../i18n/pt_BR/keypebble.ts \ 48 ../../../i18n/pt_BR/keypebble.ts \
49 ../../../i18n/sl/keypebble.ts \ 49 ../../../i18n/sl/keypebble.ts \
50 ../../../i18n/zh_CN/keypebble.ts \ 50 ../../../i18n/zh_CN/keypebble.ts \
51 ../../../i18n/zh_TW/keypebble.ts 51 ../../../i18n/zh_TW/keypebble.ts
52 52
53 53
54 54
55include ( $(OPIEDIR)/include.pro ) 55include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp
index 33418ae..dc90d9c 100644
--- a/noncore/comm/keypebble/krfbdecoder.cpp
+++ b/noncore/comm/keypebble/krfbdecoder.cpp
@@ -209,483 +209,486 @@ void KRFBDecoder::gotServerInit()
209} 209}
210 210
211void KRFBDecoder::gotDesktopName() 211void KRFBDecoder::gotDesktopName()
212{ 212{
213 assert( info ); 213 assert( info );
214 assert( currentState == AwaitingDesktopName ); 214 assert( currentState == AwaitingDesktopName );
215 215
216 qWarning( "Got desktop name" ); 216 qWarning( "Got desktop name" );
217 217
218 disconnect( con, SIGNAL( gotEnoughData() ), 218 disconnect( con, SIGNAL( gotEnoughData() ),
219 this, SLOT( gotDesktopName() ) ); 219 this, SLOT( gotDesktopName() ) );
220 220
221 char *buf = new char[ info->nameLength + 1 ]; 221 char *buf = new char[ info->nameLength + 1 ];
222 CHECK_PTR( buf ); 222 CHECK_PTR( buf );
223 223
224 con->read( buf, info->nameLength ); 224 con->read( buf, info->nameLength );
225 buf[ info->nameLength ] = '\0'; 225 buf[ info->nameLength ] = '\0';
226 info->name = buf; 226 info->name = buf;
227 227
228 qWarning( "Desktop: %s", info->name.latin1() ); 228 qWarning( "Desktop: %s", info->name.latin1() );
229 229
230 delete buf; 230 delete buf;
231 231
232 // Get the format we'll really use and tell the server 232 // Get the format we'll really use and tell the server
233 decidePixelFormat(); 233 decidePixelFormat();
234 sendPixelFormat(); 234 sendPixelFormat();
235 sendAllowedEncodings(); 235 sendAllowedEncodings();
236 currentState = Idle; 236 currentState = Idle;
237 237
238 QString msg; 238 QString msg;
239 msg = tr( "Connected to %1" ); 239 msg = tr( "Connected to %1" );
240 msg = msg.arg( info->name ); 240 msg = msg.arg( info->name );
241 emit status( msg ); 241 emit status( msg );
242 242
243 sendUpdateRequest( false ); 243 sendUpdateRequest( false );
244} 244}
245 245
246void KRFBDecoder::decidePixelFormat() 246void KRFBDecoder::decidePixelFormat()
247{ 247{
248 assert( info ); 248 assert( info );
249 249
250 if ( format ) 250 if ( format )
251 delete format; 251 delete format;
252 format = new KRFBPixelFormat; 252 format = new KRFBPixelFormat;
253 CHECK_PTR( format ); 253 CHECK_PTR( format );
254 254
255 // What depth do we want? 255 // What depth do we want?
256 // 256 //
257 // We'll use the minimum of the remote and local depths, UNLESS an 257 // We'll use the minimum of the remote and local depths, UNLESS an
258 // eight bit session has been specifically requested by the user. 258 // eight bit session has been specifically requested by the user.
259 int screenDepth = QPixmap::defaultDepth(); 259 int screenDepth = QPixmap::defaultDepth();
260 int bestDepth = ( screenDepth > info->depth ) ? info->depth : screenDepth; 260 int bestDepth = ( screenDepth > info->depth ) ? info->depth : screenDepth;
261 int chosenDepth; 261 int chosenDepth;
262 262
263 if ( con->options()->colors256 ) 263 if ( con->options()->colors256 )
264 chosenDepth = 8; 264 chosenDepth = 8;
265 else 265 else
266 chosenDepth = bestDepth; 266 chosenDepth = bestDepth;
267 267
268 qWarning( "Screen depth=%d, server depth=%d, best depth=%d, " \ 268 qWarning( "Screen depth=%d, server depth=%d, best depth=%d, " \
269 "eight bit %d, chosenDepth=%d", 269 "eight bit %d, chosenDepth=%d",
270 screenDepth, 270 screenDepth,
271 info->depth, 271 info->depth,
272 bestDepth, 272 bestDepth,
273 con->options()->colors256, chosenDepth ); 273 con->options()->colors256, chosenDepth );
274 274
275 format->depth = chosenDepth; 275 format->depth = chosenDepth;
276 276
277 // If we're using the servers native depth 277 // If we're using the servers native depth
278 if ( chosenDepth == info->depth ) { 278 if ( chosenDepth == info->depth ) {
279 // Use the servers native format 279 // Use the servers native format
280 format->bpp = info->bpp; 280 format->bpp = info->bpp;
281 // format->bigEndian = info->bigEndian; 281 // format->bigEndian = info->bigEndian;
282 format->bigEndian = true; 282 format->bigEndian = true;
283 format->trueColor = info->trueColor; 283 format->trueColor = info->trueColor;
284 format->redMax = info->redMax; 284 format->redMax = info->redMax;
285 format->greenMax = info->greenMax; 285 format->greenMax = info->greenMax;
286 format->blueMax = info->blueMax; 286 format->blueMax = info->blueMax;
287 format->redShift = info->redShift; 287 format->redShift = info->redShift;
288 format->greenShift = info->greenShift; 288 format->greenShift = info->greenShift;
289 format->blueShift = info->blueShift; 289 format->blueShift = info->blueShift;
290 } 290 }
291 else { 291 else {
292 if ( chosenDepth == 8 ) { 292 if ( chosenDepth == 8 ) {
293 format->bpp = 8; 293 format->bpp = 8;
294 format->bigEndian = true; 294 format->bigEndian = true;
295 format->trueColor = true; 295 format->trueColor = true;
296 format->redMax = 7; 296 format->redMax = 7;
297 format->greenMax = 7; 297 format->greenMax = 7;
298 format->blueMax = 3; 298 format->blueMax = 3;
299 format->redShift = 0; 299 format->redShift = 0;
300 format->greenShift = 3; 300 format->greenShift = 3;
301 format->blueShift = 6; 301 format->blueShift = 6;
302 } 302 }
303 } 303 }
304 304
305 format->redMax = Swap16IfLE( format->redMax ); 305 format->redMax = Swap16IfLE( format->redMax );
306 format->greenMax = Swap16IfLE( format->greenMax ); 306 format->greenMax = Swap16IfLE( format->greenMax );
307 format->blueMax = Swap16IfLE( format->blueMax ); 307 format->blueMax = Swap16IfLE( format->blueMax );
308} 308}
309 309
310void KRFBDecoder::sendPixelFormat() 310void KRFBDecoder::sendPixelFormat()
311{ 311{
312 static char padding[3]; 312 static char padding[3];
313 con->write( &SetPixelFormatId, 1 ); 313 con->write( &SetPixelFormatId, 1 );
314 con->write( padding, 3 ); 314 con->write( padding, 3 );
315 315
316 con->write( &(format->bpp), 1 ); 316 con->write( &(format->bpp), 1 );
317 con->write( &(format->depth), 1 ); 317 con->write( &(format->depth), 1 );
318 con->write( &(format->bigEndian), 1 ); 318 con->write( &(format->bigEndian), 1 );
319 con->write( &(format->trueColor), 1 ); 319 con->write( &(format->trueColor), 1 );
320 320
321 con->write( &(format->redMax), 2 ); 321 con->write( &(format->redMax), 2 );
322 con->write( &(format->greenMax), 2 ); 322 con->write( &(format->greenMax), 2 );
323 con->write( &(format->blueMax), 2 ); 323 con->write( &(format->blueMax), 2 );
324 324
325 con->write( &(format->redShift), 1 ); 325 con->write( &(format->redShift), 1 );
326 con->write( &(format->greenShift), 1 ); 326 con->write( &(format->greenShift), 1 );
327 con->write( &(format->blueShift), 1 ); 327 con->write( &(format->blueShift), 1 );
328 con->write( format->padding, 3 ); // Padding 328 con->write( format->padding, 3 ); // Padding
329} 329}
330 330
331void KRFBDecoder::sendAllowedEncodings() 331void KRFBDecoder::sendAllowedEncodings()
332{ 332{
333 static CARD8 padding[1]; 333 static CARD8 padding[1];
334 con->write( &SetEncodingsId, 1 ); 334 con->write( &SetEncodingsId, 1 );
335 con->write( padding, 1 ); 335 con->write( padding, 1 );
336 336
337 static CARD16 noEncodings = con->options()->encodings(); 337 CARD16 noEncodings = con->options()->encodings();
338 noEncodings = Swap16IfLE( noEncodings ); 338 noEncodings = Swap16IfLE( noEncodings );
339 con->write( &noEncodings, 2 ); 339 con->write( &noEncodings, 2 );
340 340
341 if ( con->options()->corre ) 341 if ( con->options()->corre )
342 con->write( &CorreEncoding, 4 ); 342 con->write( &CorreEncoding, 4 );
343 if ( con->options()->hexTile ) 343 if ( con->options()->hexTile )
344 con->write( &HexTileEncoding, 4 ); 344 con->write( &HexTileEncoding, 4 );
345 if ( con->options()->rre ) 345 if ( con->options()->rre )
346 con->write( &RreEncoding, 4 ); 346 con->write( &RreEncoding, 4 );
347 if ( con->options()->copyrect ) 347 if ( con->options()->copyrect )
348 con->write( &CopyRectEncoding, 4 ); 348 con->write( &CopyRectEncoding, 4 );
349 // We always support this 349 // We always support this
350 con->write( &RawEncoding, 4 ); 350 con->write( &RawEncoding, 4 );
351} 351}
352 352
353void KRFBDecoder::sendUpdateRequest( bool incremental ) 353void KRFBDecoder::sendUpdateRequest( bool incremental )
354{ 354{
355 if ( currentState != Idle ) 355 if ( currentState != Idle )
356 return; 356 return;
357 357
358 con->write( &UpdateRequestId, 1 ); 358 con->write( &UpdateRequestId, 1 );
359 con->write( &incremental, 1 ); 359 con->write( &incremental, 1 );
360 360
361 static CARD16 x = 0, y = 0; 361 static CARD16 x = 0, y = 0;
362 static CARD16 w = Swap16IfLE( info->width ); 362 static CARD16 w = Swap16IfLE( info->width );
363 static CARD16 h = Swap16IfLE( info->height ); 363 static CARD16 h = Swap16IfLE( info->height );
364 364
365 con->write( &x, 2 ); 365 con->write( &x, 2 );
366 con->write( &y, 2 ); 366 con->write( &y, 2 );
367 con->write( &w, 2 ); 367 con->write( &w, 2 );
368 con->write( &h, 2 ); 368 con->write( &h, 2 );
369 369
370 // Now wait for the update 370 // Now wait for the update
371 currentState = AwaitingUpdate; 371 currentState = AwaitingUpdate;
372 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) ); 372 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
373 con->waitForData( UpdateHeaderLength ); 373 con->waitForData( UpdateHeaderLength );
374} 374}
375 375
376void KRFBDecoder::gotUpdateHeader() 376void KRFBDecoder::gotUpdateHeader()
377{ 377{
378 assert( currentState == AwaitingUpdate ); 378 assert( currentState == AwaitingUpdate );
379 379
380 // qWarning( "Got update header" ); 380 // qWarning( "Got update header" );
381 381
382 disconnect( con, SIGNAL( gotEnoughData() ), 382 disconnect( con, SIGNAL( gotEnoughData() ),
383 this, SLOT( gotUpdateHeader() ) ); 383 this, SLOT( gotUpdateHeader() ) );
384 384
385 CARD8 msgType; 385 CARD8 msgType;
386 con->read( &msgType, 1 ); 386 con->read( &msgType, 1 );
387 387
388 if ( msgType != UpdateId ) { 388 if ( msgType != UpdateId ) {
389 // We might have a bell or server cut 389 // We might have a bell or server cut
390 if ( msgType == ServerCutId ) { 390 if ( msgType == ServerCutId ) {
391 oldState = currentState; 391 oldState = currentState;
392 gotServerCut(); 392 gotServerCut();
393 } 393 }
394 else if ( msgType == BellId ) { 394 else if ( msgType == BellId ) {
395 oldState = currentState; 395 oldState = currentState;
396 gotBell(); 396 gotBell();
397 } 397 }
398 else { 398 else {
399 int msg = msgType; 399 int msg = msgType;
400 QString protocolError = tr( "Protocol Error: Message Id %1 was " 400 QString protocolError = tr( "Protocol Error: Message Id %1 was "
401 "found when expecting an update " 401 "found when expecting an update "
402 "message." ).arg( msg ); 402 "message." ).arg( msg );
403 currentState = Error; 403 currentState = Error;
404 emit error( protocolError ); 404 emit error( protocolError );
405 } 405 }
406 return; 406 return;
407 } 407 }
408 408
409 CARD8 padding; 409 CARD8 padding;
410 con->read( &padding, 1 ); 410 con->read( &padding, 1 );
411 411
412 con->read( &noRects, 2 ); 412 con->read( &noRects, 2 );
413 noRects = Swap16IfLE( noRects ); 413 noRects = Swap16IfLE( noRects );
414 414
415 // qWarning( "Expecting %d rects", noRects ); 415 // qWarning( "Expecting %d rects", noRects );
416 416
417 // Now wait for the data 417 // Now wait for the data
418 currentState = AwaitingRectHeader; 418 currentState = AwaitingRectHeader;
419 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); 419 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
420 con->waitForData( RectHeaderLength ); 420 con->waitForData( RectHeaderLength );
421} 421}
422 422
423void KRFBDecoder::gotRectHeader() 423void KRFBDecoder::gotRectHeader()
424{ 424{
425 assert( currentState == AwaitingRectHeader ); 425 assert( currentState == AwaitingRectHeader );
426 426
427 // qWarning( "Got rect header" ); 427 // qWarning( "Got rect header" );
428 428
429 disconnect( con, SIGNAL( gotEnoughData() ), 429 disconnect( con, SIGNAL( gotEnoughData() ),
430 this, SLOT( gotRectHeader() ) ); 430 this, SLOT( gotRectHeader() ) );
431 431
432 con->read( &x, 2 ); 432 con->read( &x, 2 );
433 x = Swap16IfLE( x ); 433 x = Swap16IfLE( x );
434 con->read( &y, 2 ); 434 con->read( &y, 2 );
435 y = Swap16IfLE( y ); 435 y = Swap16IfLE( y );
436 436
437 con->read( &w, 2 ); 437 con->read( &w, 2 );
438 w = Swap16IfLE( w ); 438 w = Swap16IfLE( w );
439 con->read( &h, 2 ); 439 con->read( &h, 2 );
440 h = Swap16IfLE( h ); 440 h = Swap16IfLE( h );
441 441
442 con->read( &encoding, 4 ); 442 con->read( &encoding, 4 );
443 443
444 // CARD32 encodingLocal = Swap32IfLE( encoding ); 444 // CARD32 encodingLocal = Swap32IfLE( encoding );
445 // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld", 445 // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld",
446 // x, y, w, h, encodingLocal ); 446 // x, y, w, h, encodingLocal );
447 447
448 // 448 //
449 // Each encoding needs to be handled differently. Some require 449 // Each encoding needs to be handled differently. Some require
450 // waiting for more data, but others like a copyrect do not. 450 // waiting for more data, but others like a copyrect do not.
451 // Our constants have already been byte swapped, so we use 451 // Our constants have already been byte swapped, so we use
452 // the remote value as is. 452 // the remote value as is.
453 // 453 //
454 if ( encoding == RawEncoding ) { 454 if ( encoding == RawEncoding ) {
455 // qWarning( "Raw encoding" ); 455 // qWarning( "Raw encoding" );
456 handleRawRect(); 456 handleRawRect();
457 } 457 }
458 else if ( encoding == CopyRectEncoding ) { 458 else if ( encoding == CopyRectEncoding ) {
459// qWarning( "CopyRect encoding" ); 459// qWarning( "CopyRect encoding" );
460 handleCopyRect(); 460 handleCopyRect();
461 } 461 }
462 else if ( encoding == RreEncoding ) { 462 else if ( encoding == RreEncoding ) {
463 qWarning( "RRE encoding" ); 463 qWarning( "RRE encoding" );
464 handleRRERect(); 464 handleRRERect();
465 } 465 }
466 else if ( encoding == CorreEncoding ) { 466 else if ( encoding == CorreEncoding ) {
467 qWarning( "CoRRE encoding" ); 467 qWarning( "CoRRE encoding" );
468 handleCoRRERect(); 468 handleCoRRERect();
469 } 469 }
470 else if ( encoding == HexTileEncoding ) { 470 else if ( encoding == HexTileEncoding ) {
471 qWarning( "HexTile encoding" ); 471 qWarning( "HexTile encoding" );
472 handleHexTileRect(); 472 handleHexTileRect();
473 } 473 }
474 else { 474 else {
475 int msg = Swap32IfLE( encoding ); 475 int msg = Swap32IfLE( encoding );
476 QString protocolError = tr( "Protocol Error: An unknown encoding was " 476 QString protocolError = tr( "Protocol Error: An unknown encoding was "
477 "used by the server %1" ).arg( msg ); 477 "used by the server %1" ).arg( msg );
478 currentState = Error; 478 currentState = Error;
479 qWarning( "Unknown encoding, %d", msg ); 479 qWarning( "Unknown encoding, %d", msg );
480 emit error( protocolError ); 480 emit error( protocolError );
481 return; 481 return;
482 } 482 }
483} 483}
484 484
485// 485//
486// Raw Encoding 486// Raw Encoding
487// 487//
488 488
489void KRFBDecoder::handleRawRect() 489void KRFBDecoder::handleRawRect()
490{ 490{
491 // We need something a bit cleverer here to handle large 491 // We need something a bit cleverer here to handle large
492 // rectanges nicely. The chunking should be based on the 492 // rectanges nicely. The chunking should be based on the
493 // overall size (but has to be in complete lines). 493 // overall size (but has to be in complete lines).
494 494
495 // qWarning( "Handling a raw rect chunk" ); 495 // qWarning( "Handling a raw rect chunk" );
496 496
497 // CARD32 lineCount = w * format->bpp / 8; 497 // CARD32 lineCount = w * format->bpp / 8;
498 498
499 if ( h > RectChunkSize ) { 499 if ( h > RectChunkSize ) {
500 // if ( con->sock->size() / lineCount ) { 500 // if ( con->sock->size() / lineCount ) {
501 // getRawRectChunk( con->sock->size() / lineCount ); 501 // getRawRectChunk( con->sock->size() / lineCount );
502 // } 502 // }
503 // else { 503 // else {
504 getRawRectChunk( RectChunkSize ); 504 getRawRectChunk( RectChunkSize );
505 // } 505 // }
506 } 506 }
507 else { 507 else {
508 getRawRectChunk( h ); 508 getRawRectChunk( h );
509 } 509 }
510} 510}
511 511
512void KRFBDecoder::getRawRectChunk( int lines ) 512void KRFBDecoder::getRawRectChunk( int lines )
513{ 513{
514 this->lines = lines; 514 this->lines = lines;
515 CARD32 count = lines * w * format->bpp / 8; 515 CARD32 count = lines * w * format->bpp / 8;
516 516
517 // Wait for server init 517 // Wait for server init
518 // qWarning( "Waiting for raw rect chunk, %ld", count ); 518 // qWarning( "Waiting for raw rect chunk, %ld", count );
519 519
520 currentState = AwaitingRawRectChunk; 520 currentState = AwaitingRawRectChunk;
521 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) ); 521 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) );
522 con->waitForData( count ); 522 con->waitForData( count );
523} 523}
524 524
525void KRFBDecoder::gotRawRectChunk() 525void KRFBDecoder::gotRawRectChunk()
526{ 526{
527 assert( currentState == AwaitingRawRectChunk ); 527 assert( currentState == AwaitingRawRectChunk );
528 528
529 disconnect( con, SIGNAL( gotEnoughData() ), 529 disconnect( con, SIGNAL( gotEnoughData() ),
530 this, SLOT( gotRawRectChunk() ) ); 530 this, SLOT( gotRawRectChunk() ) );
531 531
532 // qWarning( "Got raw rect chunk" ); 532 // qWarning( "Got raw rect chunk" );
533 533
534 // 534 //
535 // Read the rect data and copy it to the buffer. 535 // Read the rect data and copy it to the buffer.
536 // 536 //
537 537
538 // TODO: Replace this! 538 // TODO: Replace this!
539 int count = lines * w * format->bpp / 8; 539 int count = lines * w * format->bpp / 8;
540 char *hack = new char[ count ]; 540 char *hack = new char[ count ];
541 con->read( hack, count ); 541 con->read( hack, count );
542 buf->drawRawRectChunk( hack, x, y, w, lines ); 542 buf->drawRawRectChunk( hack, x, y, w, lines );
543 delete hack; 543 delete hack;
544 // /TODO: 544 // /TODO:
545 545
546 h = h - lines; 546 h = h - lines;
547 y = y + lines; 547 y = y + lines;
548 548
549 if ( h > 0 ) { 549 if ( h > 0 ) {
550 handleRawRect(); 550 handleRawRect();
551 } 551 }
552 else { 552 else {
553 noRects--; 553 noRects--;
554 554
555 // qWarning( "There are %d rects left", noRects ); 555 // qWarning( "There are %d rects left", noRects );
556 556
557 if ( noRects ) { 557 if ( noRects ) {
558 currentState = AwaitingRectHeader; 558 currentState = AwaitingRectHeader;
559 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); 559 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
560 con->waitForData( RectHeaderLength ); 560 con->waitForData( RectHeaderLength );
561 } 561 }
562 else 562 else {
563 // we are now ready for the next update - no need to wait for the timer
563 currentState = Idle; 564 currentState = Idle;
565 sendUpdateRequest (1);
566 }
564 } 567 }
565} 568}
566 569
567// 570//
568// Copy Rectangle Encoding 571// Copy Rectangle Encoding
569// 572//
570 573
571void KRFBDecoder::handleCopyRect() 574void KRFBDecoder::handleCopyRect()
572{ 575{
573 currentState = AwaitingCopyRectPos; 576 currentState = AwaitingCopyRectPos;
574 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotCopyRectPos() ) ); 577 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotCopyRectPos() ) );
575 con->waitForData( CopyRectPosLength ); 578 con->waitForData( CopyRectPosLength );
576} 579}
577 580
578void KRFBDecoder::gotCopyRectPos() 581void KRFBDecoder::gotCopyRectPos()
579{ 582{
580 disconnect( con, SIGNAL( gotEnoughData() ), 583 disconnect( con, SIGNAL( gotEnoughData() ),
581 this, SLOT( gotCopyRectPos() ) ); 584 this, SLOT( gotCopyRectPos() ) );
582 585
583 CARD16 srcX; 586 CARD16 srcX;
584 CARD16 srcY; 587 CARD16 srcY;
585 588
586 con->read( &srcX, 2 ); 589 con->read( &srcX, 2 );
587 con->read( &srcY, 2 ); 590 con->read( &srcY, 2 );
588 591
589 srcX = Swap16IfLE( srcX ); 592 srcX = Swap16IfLE( srcX );
590 srcY = Swap16IfLE( srcY ); 593 srcY = Swap16IfLE( srcY );
591 594
592 buf->copyRect( srcX, srcY, x, y, w, h ); 595 buf->copyRect( srcX, srcY, x, y, w, h );
593 596
594 noRects--; 597 noRects--;
595 598
596 // qWarning( "There are %d rects left", noRects ); 599 // qWarning( "There are %d rects left", noRects );
597 600
598 if ( noRects ) { 601 if ( noRects ) {
599 currentState = AwaitingRectHeader; 602 currentState = AwaitingRectHeader;
600 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) ); 603 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
601 con->waitForData( RectHeaderLength ); 604 con->waitForData( RectHeaderLength );
602 } 605 }
603 else 606 else
604 currentState = Idle; 607 currentState = Idle;
605} 608}
606 609
607void KRFBDecoder::handleRRERect() 610void KRFBDecoder::handleRRERect()
608{ 611{
609 qWarning( "RRE not implemented" ); 612 qWarning( "RRE not implemented" );
610} 613}
611 614
612void KRFBDecoder::handleCoRRERect() 615void KRFBDecoder::handleCoRRERect()
613{ 616{
614 qWarning( "CoRRE not implemented" ); 617 qWarning( "CoRRE not implemented" );
615} 618}
616 619
617void KRFBDecoder::handleHexTileRect() 620void KRFBDecoder::handleHexTileRect()
618{ 621{
619 qWarning( "HexTile not implemented" ); 622 qWarning( "HexTile not implemented" );
620} 623}
621 624
622void KRFBDecoder::sendMouseEvent( QMouseEvent *e ) 625void KRFBDecoder::sendMouseEvent( QMouseEvent *e )
623{ 626{
624 // Deal with the buttons 627 // Deal with the buttons
625 if ( e->type() != QEvent::MouseMove ) { 628 if ( e->type() != QEvent::MouseMove ) {
626 buttonMask = 0; 629 buttonMask = 0;
627 if ( e->type() == QEvent::MouseButtonPress ) { 630 if ( e->type() == QEvent::MouseButtonPress ) {
628 if ( e->button() & LeftButton ) 631 if ( e->button() & LeftButton )
629 buttonMask |= 0x01; 632 buttonMask |= 0x01;
630 if ( e->button() & MidButton ) 633 if ( e->button() & MidButton )
631 buttonMask |= 0x04; 634 buttonMask |= 0x04;
632 if ( e->button() & RightButton ) 635 if ( e->button() & RightButton )
633 buttonMask |= 0x02; 636 buttonMask |= 0x02;
634 } 637 }
635 else if ( e->type() == QEvent::MouseButtonRelease ) { 638 else if ( e->type() == QEvent::MouseButtonRelease ) {
636 if ( e->button() & LeftButton ) 639 if ( e->button() & LeftButton )
637 buttonMask &= 0x06; 640 buttonMask &= 0x06;
638 if ( e->button() & MidButton ) 641 if ( e->button() & MidButton )
639 buttonMask |= 0x03; 642 buttonMask |= 0x03;
640 if ( e->button() & RightButton ) 643 if ( e->button() & RightButton )
641 buttonMask |= 0x05; 644 buttonMask |= 0x05;
642 } 645 }
643 } 646 }
644 647
645 // HACK: Scaling 648 // HACK: Scaling
646 CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor ); 649 CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor );
647 CARD16 y = Swap16IfLE( e->y() *con->options()->scaleFactor ); 650 CARD16 y = Swap16IfLE( e->y() *con->options()->scaleFactor );
648 651
649 con->write( &PointerEventId, 1 ); 652 con->write( &PointerEventId, 1 );
650 con->write( &buttonMask, 1 ); 653 con->write( &buttonMask, 1 );
651 con->write( &x, 2 ); 654 con->write( &x, 2 );
652 con->write( &y, 2 ); 655 con->write( &y, 2 );
653} 656}
654 657
655 658
656void KRFBDecoder::sendCutEvent( const QString &unicode ) 659void KRFBDecoder::sendCutEvent( const QString &unicode )
657{ 660{
658 // 661 //
659 // Warning: There is a bug in the RFB protocol because there is no way to find 662 // Warning: There is a bug in the RFB protocol because there is no way to find
660 // out the codepage in use on the remote machine. This could be fixed by requiring 663 // out the codepage in use on the remote machine. This could be fixed by requiring
661 // the remote server to use utf8 etc. but for now we have to assume they're the 664 // the remote server to use utf8 etc. but for now we have to assume they're the
662 // same. I've reported this problem to the ORL guys, but they apparantly have no 665 // same. I've reported this problem to the ORL guys, but they apparantly have no
663 // immediate plans to fix the issue. :-( (rich) 666 // immediate plans to fix the issue. :-( (rich)
664 // 667 //
665 668
666 CARD8 padding[3]; 669 CARD8 padding[3];
667 QCString text = unicode.local8Bit(); 670 QCString text = unicode.local8Bit();
668 CARD32 length = text.length(); 671 CARD32 length = text.length();
669 length = Swap32IfLE( length ); 672 length = Swap32IfLE( length );
670 673
671 con->write( &ClientCutTextId, 1 ); 674 con->write( &ClientCutTextId, 1 );
672 con->write( &padding, 3 ); 675 con->write( &padding, 3 );
673 con->write( &length, 4 ); 676 con->write( &length, 4 );
674 con->write( text.data(), length ); 677 con->write( text.data(), length );
675} 678}
676 679
677void KRFBDecoder::gotServerCut() 680void KRFBDecoder::gotServerCut()
678{ 681{
679 qWarning( "Got server cut" ); 682 qWarning( "Got server cut" );
680 683
681 currentState = AwaitingServerCutLength; 684 currentState = AwaitingServerCutLength;
682 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) ); 685 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) );
683 con->waitForData( ServerCutLenLength ); 686 con->waitForData( ServerCutLenLength );
684} 687}
685 688
686void KRFBDecoder::gotServerCutLength() 689void KRFBDecoder::gotServerCutLength()
687{ 690{
688 assert( currentState = AwaitingServerCutLength ); 691 assert( currentState = AwaitingServerCutLength );
689 disconnect( con, SIGNAL( gotEnoughData() ), 692 disconnect( con, SIGNAL( gotEnoughData() ),
690 this, SLOT( gotServerCutLength() ) ); 693 this, SLOT( gotServerCutLength() ) );
691 694
diff --git a/noncore/comm/keypebble/kvnc.cpp b/noncore/comm/keypebble/kvnc.cpp
index 48a442c..c89dec5 100644
--- a/noncore/comm/keypebble/kvnc.cpp
+++ b/noncore/comm/keypebble/kvnc.cpp
@@ -1,295 +1,295 @@
1#include <qiconset.h> 1#include <qiconset.h>
2#include <qdialog.h> 2#include <qdialog.h>
3#include <qpixmap.h> 3#include <qpixmap.h>
4#include <qdom.h> 4#include <qdom.h>
5#include <qaction.h> 5#include <qaction.h>
6#include <qpe/qpemenubar.h> 6#include <qpe/qpemenubar.h>
7#include <qstatusbar.h> 7#include <qstatusbar.h>
8#include <qpopupmenu.h> 8#include <qpopupmenu.h>
9#include <qpushbutton.h> 9#include <qpushbutton.h>
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> 13#include <qspinbox.h>
14#include <qlistbox.h> 14#include <qlistbox.h>
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17#include <qpe/global.h> 17#include <qpe/global.h>
18#include <qpe/qpetoolbar.h> 18#include <qpe/qpetoolbar.h>
19#include <qpe/resource.h> 19#include <qpe/resource.h>
20 20
21#include <assert.h> 21#include <assert.h>
22 22
23#include "kvnc.h" 23#include "kvnc.h"
24#include "krfbcanvas.h" 24#include "krfbcanvas.h"
25#include "krfbconnection.h" 25#include "krfbconnection.h"
26#include "kvncconndlg.h" 26#include "kvncconndlg.h"
27#include "krfbserver.h" 27#include "krfbserver.h"
28 28
29static int u_id = 1; 29static int u_id = 1;
30static int get_unique_id() 30static int get_unique_id()
31{ 31{
32 return u_id++; 32 return u_id++;
33} 33}
34 34
35 35
36/* XPM */ 36/* XPM */
37static char * menu_xpm[] = { 37static char * menu_xpm[] = {
38"12 12 5 1", 38"12 12 5 1",
39 " c None", 39 " c None",
40 ".c #000000", 40 ".c #000000",
41 "+c #FFFDAD", 41 "+c #FFFDAD",
42 "@c #FFFF00", 42 "@c #FFFF00",
43 "#c #E5E100", 43 "#c #E5E100",
44" ", 44" ",
45" ", 45" ",
46" ......... ", 46" ......... ",
47" .+++++++. ", 47" .+++++++. ",
48" .+@@@@#. ", 48" .+@@@@#. ",
49" .+@@@#. ", 49" .+@@@#. ",
50" .+@@#. ", 50" .+@@#. ",
51" .+@#. ", 51" .+@#. ",
52" .+#. ", 52" .+#. ",
53" .+. ", 53" .+. ",
54" .. ", 54" .. ",
55" "}; 55" "};
56 56
57const int StatusTextId = 0; 57const int StatusTextId = 0;
58 58
59KVNC::KVNC( const char *name ) : QMainWindow( 0, name ,WStyle_ContextHelp) 59KVNC::KVNC( QWidget *parent, const char *name, WFlags f) : QMainWindow( 0, name ,WStyle_ContextHelp)
60{ 60{
61 setCaption( tr("VNC Viewer") ); 61 setCaption( tr("VNC Viewer") );
62 fullscreen = false; 62 fullscreen = false;
63 63
64 stack = new QWidgetStack( this ); 64 stack = new QWidgetStack( this );
65 setCentralWidget( stack ); 65 setCentralWidget( stack );
66 66
67 bookmarkSelector=new KVNCBookmarkDlg(); 67 bookmarkSelector=new KVNCBookmarkDlg();
68 stack->addWidget(bookmarkSelector,get_unique_id()); 68 stack->addWidget(bookmarkSelector,get_unique_id());
69 stack->raiseWidget( bookmarkSelector ); 69 stack->raiseWidget( bookmarkSelector );
70 70
71 canvas = new KRFBCanvas( stack, "canvas" ); 71 canvas = new KRFBCanvas( stack, "canvas" );
72 stack->addWidget(canvas,get_unique_id()); 72 stack->addWidget(canvas,get_unique_id());
73 setCentralWidget( stack ); 73 setCentralWidget( stack );
74 74
75 75
76 connect( bookmarkSelector->bookmarkList, SIGNAL(clicked(QListBoxItem *)), 76 connect( bookmarkSelector->bookmarkList, SIGNAL(clicked(QListBoxItem *)),
77 this, SLOT(openConnection(QListBoxItem *)) ); 77 this, SLOT(openConnection(QListBoxItem *)) );
78 connect( canvas->connection(), SIGNAL(statusChanged(const QString &)), 78 connect( canvas->connection(), SIGNAL(statusChanged(const QString &)),
79 this, SLOT(statusMessage(const QString &)) ); 79 this, SLOT(statusMessage(const QString &)) );
80 connect( canvas->connection(), SIGNAL(error(const QString &)), 80 connect( canvas->connection(), SIGNAL(error(const QString &)),
81 this, SLOT(error(const QString &)) ); 81 this, SLOT(error(const QString &)) );
82 connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) ); 82 connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) );
83 connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) ); 83 connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) );
84 connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) ); 84 connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) );
85 85
86 setupActions(); 86 setupActions();
87 87
88 cornerButton = new QPushButton( this ); 88 cornerButton = new QPushButton( this );
89 cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); 89 cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
90 connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) ); 90 connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) );
91 canvas->setCornerWidget( cornerButton ); 91 canvas->setCornerWidget( cornerButton );
92 92
93 stack->raiseWidget( bookmarkSelector ); 93 stack->raiseWidget( bookmarkSelector );
94 94
95 95
96 bar= new QToolBar( this ); 96 bar= new QToolBar( this );
97 setToolBarsMovable( false ); 97 setToolBarsMovable( false );
98 setRightJustification(false); 98 setRightJustification(false);
99 99
100 100
101 QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ), 101 QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ),
102 QString::null, 0, this, 0 ); 102 QString::null, 0, this, 0 );
103 connect( n, SIGNAL( activated() ), 103 connect( n, SIGNAL( activated() ),
104 this, SLOT( newConnection() ) ); 104 this, SLOT( newConnection() ) );
105 n->addTo( bar ); 105 n->addTo( bar );
106 106
107 QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "fileopen" ), 107 QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "fileopen" ),
108 QString::null, 0, this, 0 ); 108 QString::null, 0, this, 0 );
109 connect( o, SIGNAL( activated() ), 109 connect( o, SIGNAL( activated() ),
110 this, SLOT( openConnection() ) ); 110 this, SLOT( openConnection() ) );
111 o->addTo( bar ); 111 o->addTo( bar );
112 112
113 QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ), 113 QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ),
114 QString::null, 0, this, 0 ); 114 QString::null, 0, this, 0 );
115 connect( d, SIGNAL( activated() ), 115 connect( d, SIGNAL( activated() ),
116 this, SLOT( deleteBookmark() ) ); 116 this, SLOT( deleteBookmark() ) );
117 d->addTo( bar ); 117 d->addTo( bar );
118} 118}
119 119
120KVNC::~KVNC() 120KVNC::~KVNC()
121{ 121{
122 122
123} 123}
124 124
125void KVNC::newConnection() 125void KVNC::newConnection()
126{ 126{
127 curServer=new KRFBServer; 127 curServer=new KRFBServer;
128 128
129 KVNCConnDlg dlg( curServer,this); 129 KVNCConnDlg dlg( curServer,this);
130 dlg.showMaximized(); 130 dlg.showMaximized();
131 if (dlg.exec()) { 131 if (dlg.exec()) {
132 if (!curServer->name.isEmpty()) 132 if (!curServer->name.isEmpty())
133 bookmarkSelector->addBookmark(curServer); 133 bookmarkSelector->addBookmark(curServer);
134 canvas->openConnection(*curServer); 134 canvas->openConnection(*curServer);
135 } else 135 } else
136 curServer=0; 136 curServer=0;
137} 137}
138 138
139void KVNC::openConnection( QString name) 139void KVNC::openConnection( QString name)
140{ 140{
141 curServer=bookmarkSelector->getServer(name); 141 curServer=bookmarkSelector->getServer(name);
142 142
143 if (curServer) { 143 if (curServer) {
144 KVNCConnDlg dlg( curServer,this); 144 KVNCConnDlg dlg( curServer,this);
145 dlg.showMaximized(); 145 dlg.showMaximized();
146 146
147 if ( dlg.exec() ) { 147 if ( dlg.exec() ) {
148 canvas->openConnection(*curServer); 148 canvas->openConnection(*curServer);
149 bookmarkSelector->writeBookmarks(); 149 bookmarkSelector->writeBookmarks();
150 } else 150 } else
151 curServer=0; 151 curServer=0;
152 } 152 }
153} 153}
154 154
155void KVNC::openConnection( void ) 155void KVNC::openConnection( void )
156{ 156{
157 openConnection( bookmarkSelector->selectedBookmark()); 157 openConnection( bookmarkSelector->selectedBookmark());
158} 158}
159 159
160void KVNC::openConnection( QListBoxItem * item) 160void KVNC::openConnection( QListBoxItem * item)
161{ 161{
162 if (item) 162 if (item)
163 openConnection(item->text()); 163 openConnection(item->text());
164} 164}
165 165
166void KVNC::setupActions() 166void KVNC::setupActions()
167{ 167{
168 cornerMenu = new QPopupMenu( this ); 168 cornerMenu = new QPopupMenu( this );
169 169
170 fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 ); 170 fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 );
171 connect( fullScreenAction, SIGNAL(activated()), 171 connect( fullScreenAction, SIGNAL(activated()),
172 this, SLOT( toggleFullScreen() ) ); 172 this, SLOT( toggleFullScreen() ) );
173 fullScreenAction->addTo( cornerMenu ); 173 fullScreenAction->addTo( cornerMenu );
174 fullScreenAction->setEnabled( false ); 174 fullScreenAction->setEnabled( false );
175 175
176 ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 ); 176 ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 );
177 connect( ctlAltDelAction, SIGNAL(activated()), 177 connect( ctlAltDelAction, SIGNAL(activated()),
178 canvas, SLOT( sendCtlAltDel() ) ); 178 canvas, SLOT( sendCtlAltDel() ) );
179 ctlAltDelAction->addTo( cornerMenu ); 179 ctlAltDelAction->addTo( cornerMenu );
180 ctlAltDelAction->setEnabled( false ); 180 ctlAltDelAction->setEnabled( false );
181 181
182 disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 ); 182 disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 );
183 connect( disconnectAction, SIGNAL(activated()), 183 connect( disconnectAction, SIGNAL(activated()),
184 this, SLOT( closeConnection() ) ); 184 this, SLOT( closeConnection() ) );
185 disconnectAction->addTo( cornerMenu ); 185 disconnectAction->addTo( cornerMenu );
186 disconnectAction->setEnabled( false ); 186 disconnectAction->setEnabled( false );
187 187
188 doubleClickAction = new QAction( tr("Next Click is Double Click"), QString::null, 0, 0 ); 188 doubleClickAction = new QAction( tr("Next Click is Double Click"), QString::null, 0, 0 );
189 connect( doubleClickAction, SIGNAL(activated()), 189 connect( doubleClickAction, SIGNAL(activated()),
190 canvas, SLOT( markDoubleClick() ) ); 190 canvas, SLOT( markDoubleClick() ) );
191 doubleClickAction->addTo( cornerMenu ); 191 doubleClickAction->addTo( cornerMenu );
192 doubleClickAction->setEnabled( false ); 192 doubleClickAction->setEnabled( false );
193 193
194 rightClickAction = new QAction( tr("Next Click is Right Click"), QString::null, 0, 0 ); 194 rightClickAction = new QAction( tr("Next Click is Right Click"), QString::null, 0, 0 );
195 connect( rightClickAction, SIGNAL(activated()), 195 connect( rightClickAction, SIGNAL(activated()),
196 canvas, SLOT( markRightClick() ) ); 196 canvas, SLOT( markRightClick() ) );
197 rightClickAction->addTo( cornerMenu ); 197 rightClickAction->addTo( cornerMenu );
198 rightClickAction->setEnabled( false ); 198 rightClickAction->setEnabled( false );
199} 199}
200 200
201void KVNC::toggleFullScreen() 201void KVNC::toggleFullScreen()
202{ 202{
203 if ( fullscreen ) { 203 if ( fullscreen ) {
204 canvas->releaseKeyboard(); 204 canvas->releaseKeyboard();
205 canvas->reparent( stack, 0, QPoint(0,0), false ); 205 canvas->reparent( stack, 0, QPoint(0,0), false );
206 canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 206 canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken );
207 setCentralWidget( stack ); 207 setCentralWidget( stack );
208 stack->addWidget(canvas,get_unique_id()); 208 stack->addWidget(canvas,get_unique_id());
209 stack->raiseWidget(canvas); 209 stack->raiseWidget(canvas);
210 canvas->show(); 210 canvas->show();
211 stack->show(); 211 stack->show();
212 fullScreenAction->setText( tr("Full Screen") ); 212 fullScreenAction->setText( tr("Full Screen") );
213 } else { 213 } else {
214 canvas->setFrameStyle( QFrame::NoFrame ); 214 canvas->setFrameStyle( QFrame::NoFrame );
215 stack->removeWidget(canvas); 215 stack->removeWidget(canvas);
216 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, 216 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop,
217 QPoint(0,0),false); 217 QPoint(0,0),false);
218 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height()); 218 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height());
219 canvas->raise(); 219 canvas->raise();
220 canvas->setFocus(); 220 canvas->setFocus();
221 canvas->grabKeyboard(); 221 canvas->grabKeyboard();
222 canvas->show(); 222 canvas->show();
223 223
224 fullScreenAction->setText( tr("Stop Full Screen") ); 224 fullScreenAction->setText( tr("Stop Full Screen") );
225 } 225 }
226 226
227 227
228 fullscreen = !fullscreen; 228 fullscreen = !fullscreen;
229} 229}
230 230
231void KVNC::closeConnection() 231void KVNC::closeConnection()
232{ 232{
233 if ( fullscreen ) 233 if ( fullscreen )
234 toggleFullScreen(); 234 toggleFullScreen();
235 canvas->closeConnection(); 235 canvas->closeConnection();
236} 236}
237 237
238void KVNC::showMenu() 238void KVNC::showMenu()
239{ 239{
240 QPoint pt = mapToGlobal(cornerButton->pos()); 240 QPoint pt = mapToGlobal(cornerButton->pos());
241 QSize s = cornerMenu->sizeHint(); 241 QSize s = cornerMenu->sizeHint();
242 pt.ry() -= s.height(); 242 pt.ry() -= s.height();
243 pt.rx() -= s.width(); 243 pt.rx() -= s.width();
244 cornerMenu->popup( pt ); 244 cornerMenu->popup( pt );
245} 245}
246 246
247void KVNC::connected() 247void KVNC::connected()
248{ 248{
249 static QString msg = tr( "Connected to remote host" ); 249 static QString msg = tr( "Connected to remote host" );
250 statusMessage( msg ); 250 statusMessage( msg );
251 ctlAltDelAction->setEnabled(true); 251 ctlAltDelAction->setEnabled(true);
252 disconnectAction->setEnabled( true ); 252 disconnectAction->setEnabled( true );
253 fullScreenAction->setEnabled( true ); 253 fullScreenAction->setEnabled( true );
254 doubleClickAction->setEnabled( false ); 254 doubleClickAction->setEnabled( false );
255 rightClickAction->setEnabled( true ); 255 rightClickAction->setEnabled( true );
256 stack->raiseWidget(canvas); 256 stack->raiseWidget(canvas);
257 bar->hide(); 257 bar->hide();
258} 258}
259 259
260void KVNC::loggedIn() 260void KVNC::loggedIn()
261{ 261{
262 static QString msg = tr( "Logged in to remote host" ); 262 static QString msg = tr( "Logged in to remote host" );
263 statusMessage( msg ); 263 statusMessage( msg );
264} 264}
265 265
266void KVNC::disconnected() 266void KVNC::disconnected()
267{ 267{
268 268
269 if ( fullscreen ) 269 if ( fullscreen )
270 toggleFullScreen(); 270 toggleFullScreen();
271 static QString msg = tr( "Connection closed" ); 271 static QString msg = tr( "Connection closed" );
272 statusMessage( msg ); 272 statusMessage( msg );
273 ctlAltDelAction->setEnabled(false); 273 ctlAltDelAction->setEnabled(false);
274 disconnectAction->setEnabled( false ); 274 disconnectAction->setEnabled( false );
275 fullScreenAction->setEnabled( false ); 275 fullScreenAction->setEnabled( false );
276 doubleClickAction->setEnabled( false ); 276 doubleClickAction->setEnabled( false );
277 rightClickAction->setEnabled( false ); 277 rightClickAction->setEnabled( false );
278 stack->raiseWidget(bookmarkSelector); 278 stack->raiseWidget(bookmarkSelector);
279 bar->show(); 279 bar->show();
280} 280}
281 281
282void KVNC::statusMessage( const QString &m ) 282void KVNC::statusMessage( const QString &m )
283{ 283{
284 Global::statusMessage( m ); 284 Global::statusMessage( m );
285} 285}
286 286
287void KVNC::error( const QString &msg ) 287void KVNC::error( const QString &msg )
288{ 288{
289 statusMessage( msg ); 289 statusMessage( msg );
290 QMessageBox::warning( this, tr("VNC Viewer"), msg ); 290 QMessageBox::warning( this, tr("VNC Viewer"), msg );
291} 291}
292void KVNC::deleteBookmark(void) 292void KVNC::deleteBookmark(void)
293{ 293{
294 bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark()); 294 bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark());
295} 295}
diff --git a/noncore/comm/keypebble/kvnc.h b/noncore/comm/keypebble/kvnc.h
index 51c7151..7b7cc91 100644
--- a/noncore/comm/keypebble/kvnc.h
+++ b/noncore/comm/keypebble/kvnc.h
@@ -1,69 +1,70 @@
1// -*- c++ -*- 1// -*- c++ -*-
2 2
3#ifndef KVNC_H 3#ifndef KVNC_H
4#define KVNC_H 4#define KVNC_H
5 5
6#include <qmainwindow.h> 6#include <qmainwindow.h>
7#include <qtoolbar.h> 7#include <qtoolbar.h>
8#include <qwidgetstack.h> 8#include <qwidgetstack.h>
9#include "kvncbookmarkdlg.h" 9#include "kvncbookmarkdlg.h"
10 10
11class QAction; 11class QAction;
12class KRFBCanvas; 12class KRFBCanvas;
13class QPushButton; 13class QPushButton;
14class QToolBar; 14class QToolBar;
15 15
16/** 16/**
17 * Top level window for Keystone. 17 * Top level window for Keystone.
18 * 18 *
19 * @author Richard Moore, rich@kde.org 19 * @author Richard Moore, rich@kde.org
20 * @version $Id$ 20 * @version $Id$
21 */ 21 */
22class KVNC : public QMainWindow 22class KVNC : public QMainWindow
23{ 23{
24 Q_OBJECT 24 Q_OBJECT
25public: 25public:
26 KVNC( const char *name = 0 ); 26 KVNC( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
27 ~KVNC(); 27 ~KVNC();
28 28
29public slots: 29public slots:
30 void newConnection(); 30 void newConnection();
31 void deleteBookmark(); 31 void deleteBookmark();
32 void openConnection(QListBoxItem *); 32 void openConnection(QListBoxItem *);
33 void openConnection(QString); 33 void openConnection(QString);
34 void openConnection(void); 34 void openConnection(void);
35 void toggleFullScreen(); 35 void toggleFullScreen();
36 void closeConnection(); 36 void closeConnection();
37 static QString appName() { return QString::fromLatin1("keypebble"); }
37 38
38protected: 39protected:
39 void setupActions(); 40 void setupActions();
40 41
41protected slots: 42protected slots:
42 void showMenu(); 43 void showMenu();
43 44
44 void connected(); 45 void connected();
45 void loggedIn(); 46 void loggedIn();
46 void disconnected(); 47 void disconnected();
47 void statusMessage( const QString & ); 48 void statusMessage( const QString & );
48 void error( const QString & ); 49 void error( const QString & );
49 50
50private: 51private:
51 bool fullscreen; 52 bool fullscreen;
52 KRFBCanvas *canvas; 53 KRFBCanvas *canvas;
53 QPopupMenu *cornerMenu; 54 QPopupMenu *cornerMenu;
54 QPushButton *cornerButton; 55 QPushButton *cornerButton;
55 QAction *fullScreenAction; 56 QAction *fullScreenAction;
56 QAction *optionsAction; 57 QAction *optionsAction;
57 QAction *disconnectAction; 58 QAction *disconnectAction;
58 QAction *ctlAltDelAction;; 59 QAction *ctlAltDelAction;;
59 QAction *connectAction; 60 QAction *connectAction;
60 QAction *rightClickAction; 61 QAction *rightClickAction;
61 QAction *doubleClickAction; 62 QAction *doubleClickAction;
62 QToolBar * bar; 63 QToolBar * bar;
63 64
64 KVNCBookmarkDlg * bookmarkSelector; 65 KVNCBookmarkDlg * bookmarkSelector;
65 QWidgetStack * stack; 66 QWidgetStack * stack;
66 KRFBServer * curServer; 67 KRFBServer * curServer;
67}; 68};
68 69
69#endif // KVNC_H 70#endif // KVNC_H
diff --git a/noncore/comm/keypebble/main.cpp b/noncore/comm/keypebble/main.cpp
index bc7782c..11f67fc 100644
--- a/noncore/comm/keypebble/main.cpp
+++ b/noncore/comm/keypebble/main.cpp
@@ -1,15 +1,10 @@
1 1
2 2
3#include <qurl.h> 3
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include "kvnc.h" 5#include "kvnc.h"
6#include <opie/oapplicationfactory.h>
6 7
7int main( int argc, char **argv )
8{
9 QPEApplication app( argc, argv );
10 KVNC *view = new KVNC( "Keypebble" );
11 app.showMainWidget( view );
12 8
13 return app.exec();
14}
15 9
10OPIE_EXPORT_APP( OApplicationFactory<KVNC> )