author | llornkcor <llornkcor> | 2004-01-18 05:12:31 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-01-18 05:12:31 (UTC) |
commit | a5a10ccc4b39e9ec21b1774713745b31f47a5133 (patch) (unidiff) | |
tree | 49701a63648b8ea69a1c47accb700ee5085a7509 | |
parent | f5d28a9b86f5fdf8b4512d34c34e77284756f95c (diff) | |
download | opie-a5a10ccc4b39e9ec21b1774713745b31f47a5133.zip opie-a5a10ccc4b39e9ec21b1774713745b31f47a5133.tar.gz opie-a5a10ccc4b39e9ec21b1774713745b31f47a5133.tar.bz2 |
anti anti debug
-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 99effa5..5f83539 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -366,166 +366,166 @@ void ScreenshotControl::savePixmap() | |||
366 | 366 | ||
367 | if (!lnk.writeLink()) | 367 | if (!lnk.writeLink()) |
368 | qDebug("Writing doclink did not work"); | 368 | qDebug("Writing doclink did not work"); |
369 | } | 369 | } |
370 | else { | 370 | else { |
371 | 371 | ||
372 | fileName = "sc_" + QDateTime::currentDateTime().toString(); | 372 | fileName = "sc_" + QDateTime::currentDateTime().toString(); |
373 | fileName.replace(QRegExp("'"), ""); | 373 | fileName.replace(QRegExp("'"), ""); |
374 | fileName.replace(QRegExp(" "), "_"); | 374 | fileName.replace(QRegExp(" "), "_"); |
375 | fileName.replace(QRegExp(":"), "."); | 375 | fileName.replace(QRegExp(":"), "."); |
376 | fileName.replace(QRegExp(","), ""); | 376 | fileName.replace(QRegExp(","), ""); |
377 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; | 377 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; |
378 | 378 | ||
379 | if ( !QDir( dirName).exists() ) { | 379 | if ( !QDir( dirName).exists() ) { |
380 | qDebug("making dir " + dirName); | 380 | qDebug("making dir " + dirName); |
381 | QString msg = "mkdir -p " + dirName; | 381 | QString msg = "mkdir -p " + dirName; |
382 | system(msg.latin1()); | 382 | system(msg.latin1()); |
383 | } | 383 | } |
384 | fileName = dirName + fileName; | 384 | fileName = dirName + fileName; |
385 | if (fileName.right(3) != "png") | 385 | if (fileName.right(3) != "png") |
386 | fileName = fileName + ".png"; | 386 | fileName = fileName + ".png"; |
387 | lnk.setFile(fileName); //sets File property | 387 | lnk.setFile(fileName); //sets File property |
388 | qDebug("saving file " + fileName); | 388 | qDebug("saving file " + fileName); |
389 | snapshot.save( fileName, "PNG"); | 389 | snapshot.save( fileName, "PNG"); |
390 | QFileInfo fi( fileName); | 390 | QFileInfo fi( fileName); |
391 | lnk.setName( fi.fileName()); //sets file name | 391 | lnk.setName( fi.fileName()); //sets file name |
392 | 392 | ||
393 | if (!lnk.writeLink()) | 393 | if (!lnk.writeLink()) |
394 | qDebug("Writing doclink did not work"); | 394 | qDebug("Writing doclink did not work"); |
395 | 395 | ||
396 | } | 396 | } |
397 | 397 | ||
398 | QPEApplication::beep(); | 398 | QPEApplication::beep(); |
399 | } | 399 | } |
400 | 400 | ||
401 | void ScreenshotControl::performGrab() | 401 | void ScreenshotControl::performGrab() |
402 | { | 402 | { |
403 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); | 403 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); |
404 | 404 | ||
405 | if (buttonPushed == 1) { | 405 | if (buttonPushed == 1) { |
406 | qDebug("grabbing screen"); | 406 | qDebug("grabbing screen"); |
407 | grabTimer->stop(); | 407 | grabTimer->stop(); |
408 | show(); | 408 | show(); |
409 | qApp->processEvents(); | 409 | qApp->processEvents(); |
410 | savePixmap(); | 410 | savePixmap(); |
411 | } else { | 411 | } else { |
412 | grabTimer->stop(); | 412 | grabTimer->stop(); |
413 | 413 | ||
414 | struct sockaddr_in raddr; | 414 | struct sockaddr_in raddr; |
415 | struct hostent *rhost_info; | 415 | struct hostent *rhost_info; |
416 | int sock = -1; | 416 | int sock = -1; |
417 | bool ok = false; | 417 | bool ok = false; |
418 | 418 | ||
419 | QString displayEnv = getenv("QWS_DISPLAY"); | 419 | QString displayEnv = getenv("QWS_DISPLAY"); |
420 | qDebug(displayEnv); | 420 | qDebug(displayEnv); |
421 | 421 | ||
422 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { | 422 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { |
423 | 423 | ||
424 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { | 424 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { |
425 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); | 425 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); |
426 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 426 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
427 | raddr. sin_family = rhost_info-> h_addrtype; | 427 | raddr. sin_family = rhost_info-> h_addrtype; |
428 | raddr. sin_port = htons ( SCAP_port ); | 428 | raddr. sin_port = htons ( SCAP_port ); |
429 | 429 | ||
430 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { | 430 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { |
431 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { | 431 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { |
432 | 432 | ||
433 | QString header; | 433 | QString header; |
434 | 434 | ||
435 | QPixmap pix; | 435 | QPixmap pix; |
436 | 436 | ||
437 | QString SCAP_model=""; | 437 | QString SCAP_model=""; |
438 | #warning FIXME: model string should be filled with actual device model | 438 | #warning FIXME: model string should be filled with actual device model |
439 | if( snapshot.width() > 320) | 439 | if( snapshot.width() > 320) |
440 | SCAP_model ="Corgi"; | 440 | SCAP_model ="Corgi"; |
441 | 441 | ||
442 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! | 442 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! |
443 | pix = snapshot.xForm(QWMatrix().rotate(90)); | 443 | pix = snapshot.xForm(QWMatrix().rotate(90)); |
444 | } else | 444 | } else |
445 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); | 445 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); |
446 | 446 | ||
447 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it | 447 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it |
448 | 448 | ||
449 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user | 449 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user |
450 | "Content-length: %3\n" // 3: content length | 450 | "Content-length: %3\n" // 3: content length |
451 | "Content-Type: image/png\n" | 451 | "Content-Type: image/png\n" |
452 | "Host: %4\n" // 4: scap host | 452 | "Host: %4\n" // 4: scap host |
453 | "\n"; | 453 | "\n"; |
454 | 454 | ||
455 | 455 | ||
456 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); | 456 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); |
457 | qDebug(header); | 457 | qDebug(header); |
458 | 458 | ||
459 | if ( !pix.isNull() ) { | 459 | if ( !pix.isNull() ) { |
460 | const char *ascii = header.latin1( ); | 460 | const char *ascii = header.latin1( ); |
461 | uint ascii_len = ::strlen( ascii ); | 461 | uint ascii_len = ::strlen( ascii ); |
462 | // ::write ( sock, ascii, ascii_len ); | 462 | ::write ( sock, ascii, ascii_len ); |
463 | // ::write ( sock, img.bits(), img.numBytes() ); | 463 | ::write ( sock, img.bits(), img.numBytes() ); |
464 | 464 | ||
465 | ok = true; | 465 | ok = true; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | ::close ( sock ); | 468 | ::close ( sock ); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | if ( ok ) { | 471 | if ( ok ) { |
472 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); | 472 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); |
473 | } else { | 473 | } else { |
474 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); | 474 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); |
475 | } | 475 | } |
476 | } else { | 476 | } else { |
477 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); | 477 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | } | 481 | } |
482 | 482 | ||
483 | 483 | ||
484 | 484 | ||
485 | //=========================================================================== | 485 | //=========================================================================== |
486 | 486 | ||
487 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 487 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
488 | : QWidget( parent, name ) | 488 | : QWidget( parent, name ) |
489 | { | 489 | { |
490 | setFixedWidth( AppLnk::smallIconSize()); | 490 | setFixedWidth( AppLnk::smallIconSize()); |
491 | 491 | ||
492 | QImage img = (const char **)snapshot_xpm; | 492 | QImage img = (const char **)snapshot_xpm; |
493 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 493 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
494 | m_icon.convertFromImage(img); | 494 | m_icon.convertFromImage(img); |
495 | } | 495 | } |
496 | 496 | ||
497 | ScreenshotApplet::~ScreenshotApplet() | 497 | ScreenshotApplet::~ScreenshotApplet() |
498 | { | 498 | { |
499 | } | 499 | } |
500 | 500 | ||
501 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) | 501 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) |
502 | { | 502 | { |
503 | ScreenshotControl *sc = new ScreenshotControl ( ); | 503 | ScreenshotControl *sc = new ScreenshotControl ( ); |
504 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); | 504 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); |
505 | 505 | ||
506 | // windowPosX is the windows position centered above the applets icon. | 506 | // windowPosX is the windows position centered above the applets icon. |
507 | // If the icon is near the edge of the screen, the window would leave the visible area | 507 | // If the icon is near the edge of the screen, the window would leave the visible area |
508 | // so we check the position against the screen width and correct the difference if needed | 508 | // so we check the position against the screen width and correct the difference if needed |
509 | 509 | ||
510 | int screenWidth = qApp->desktop()->width(); | 510 | int screenWidth = qApp->desktop()->width(); |
511 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; | 511 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; |
512 | int ZwindowPosX, XwindowPosX; | 512 | int ZwindowPosX, XwindowPosX; |
513 | 513 | ||
514 | // the window would be placed beyond the screen wich doesn't look tooo good | 514 | // the window would be placed beyond the screen wich doesn't look tooo good |
515 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { | 515 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { |
516 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; | 516 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; |
517 | ZwindowPosX = windowPosX - XwindowPosX - 1; | 517 | ZwindowPosX = windowPosX - XwindowPosX - 1; |
518 | } else { | 518 | } else { |
519 | ZwindowPosX = windowPosX; | 519 | ZwindowPosX = windowPosX; |
520 | } | 520 | } |
521 | 521 | ||
522 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); | 522 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); |
523 | sc-> show ( ); | 523 | sc-> show ( ); |
524 | } | 524 | } |
525 | 525 | ||
526 | void ScreenshotApplet::paintEvent( QPaintEvent* ) | 526 | void ScreenshotApplet::paintEvent( QPaintEvent* ) |
527 | { | 527 | { |
528 | QPainter p ( this ); | 528 | QPainter p ( this ); |
529 | p.drawPixmap( 0,0, m_icon ); | 529 | p.drawPixmap( 0,0, m_icon ); |
530 | } | 530 | } |
531 | 531 | ||