summaryrefslogtreecommitdiff
path: root/core/applets/screenshotapplet
authorllornkcor <llornkcor>2004-01-10 21:57:56 (UTC)
committer llornkcor <llornkcor>2004-01-10 21:57:56 (UTC)
commit478b311227f9af1d114c9005f6c40030f587599c (patch) (unidiff)
tree8779b1bff9a7df01146ed2722f55a2fcb9f02615 /core/applets/screenshotapplet
parentd13059a60121951311b491cef32e3d26e9e950c7 (diff)
downloadopie-478b311227f9af1d114c9005f6c40030f587599c.zip
opie-478b311227f9af1d114c9005f6c40030f587599c.tar.gz
opie-478b311227f9af1d114c9005f6c40030f587599c.tar.bz2
fix for qvfb
Diffstat (limited to 'core/applets/screenshotapplet') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp127
1 files changed, 70 insertions, 57 deletions
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp
index 7e2fdf0..f024f47 100644
--- a/core/applets/screenshotapplet/screenshot.cpp
+++ b/core/applets/screenshotapplet/screenshot.cpp
@@ -400,63 +400,76 @@ void ScreenshotControl::savePixmap()
400 400
401void ScreenshotControl::performGrab() 401void 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 } 411 } else {
412 else { 412 grabTimer->stop();
413 grabTimer->stop(); 413
414 414 struct sockaddr_in raddr;
415 struct sockaddr_in raddr; 415 struct hostent *rhost_info;
416 struct hostent *rhost_info; 416 int sock = -1;
417 int sock = -1; 417 bool ok = false;
418 bool ok = false; 418
419 419 if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) {
420 if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { 420 ::memset ( &raddr, 0, sizeof (struct sockaddr_in));
421 ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); 421 ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length );
422 ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); 422 raddr. sin_family = rhost_info-> h_addrtype;
423 raddr. sin_family = rhost_info-> h_addrtype; 423 raddr. sin_port = htons ( SCAP_port );
424 raddr. sin_port = htons ( SCAP_port ); 424
425 425 if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) {
426 if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) 426 if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) {
427 { 427
428 if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { 428 QString header;
429 QString header; 429
430 430 QPixmap pix;
431 QPixmap pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); 431 QString displayEnv = getenv("QWS_DISPLAY");
432 QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it 432 qDebug(displayEnv);
433 433
434 header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user 434 QString SCAP_model="";
435 "Content-length: %3\n" // 3: content length 435#warning FIXME: model string should be filled with actual device model
436 "Content-Type: image/gif\n" 436 if( snapshot.width() > 320)
437 "Host: %4\n" // 4: scap host 437 SCAP_model ="Corgi";
438 "\n"; 438
439 439 if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!!
440 header = header.arg( "" ).arg( ::getenv ( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); 440 pix = snapshot.xForm(QWMatrix().rotate(90));
441 441 } else
442 if ( !pix.isNull() ) 442 pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) );
443 { 443
444 const char *ascii = header.latin1( ); 444 QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it
445 uint ascii_len = ::strlen( ascii ); 445
446 ::write ( sock, ascii, ascii_len ); 446 header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user
447 ::write ( sock, img.bits(), img.numBytes() ); 447 "Content-length: %3\n" // 3: content length
448 448 "Content-Type: image/png\n"
449 ok = true; 449 "Host: %4\n" // 4: scap host
450 } 450 "\n";
451 } 451
452 ::close ( sock ); 452
453 } 453 header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname );
454 } 454 qDebug(header);
455 if ( ok ) 455
456 QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); 456 if ( !pix.isNull() ) {
457 else 457 const char *ascii = header.latin1( );
458 QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); 458 uint ascii_len = ::strlen( ascii );
459 } 459 ::write ( sock, ascii, ascii_len );
460 ::write ( sock, img.bits(), img.numBytes() );
461
462 ok = true;
463 }
464 }
465 ::close ( sock );
466 }
467 }
468 if ( ok )
469 QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname ));
470 else
471 QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname ));
472 }
460 473
461} 474}
462 475