Diffstat (limited to 'noncore/net/wellenreiter/gui') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 88a474d..bb46dd7 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -22,16 +22,20 @@ | |||
22 | #include "scanlist.h" | 22 | #include "scanlist.h" |
23 | 23 | ||
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qdatastream.h> | 25 | #include <qdatastream.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qfileinfo.h> | 27 | #include <qfileinfo.h> |
28 | #include <qlabel.h> | ||
29 | #include <qlayout.h> | ||
30 | #include <qlineedit.h> | ||
28 | #include <qiconset.h> | 31 | #include <qiconset.h> |
29 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
30 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
31 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | ||
32 | #include <qstatusbar.h> | 36 | #include <qstatusbar.h> |
33 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
34 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
35 | 39 | ||
36 | #ifdef QWS | 40 | #ifdef QWS |
37 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
@@ -84,14 +88,14 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
84 | 88 | ||
85 | uploadButton = new QToolButton( 0 ); | 89 | uploadButton = new QToolButton( 0 ); |
86 | #ifdef QWS | 90 | #ifdef QWS |
87 | uploadButton->setAutoRaise( true ); | 91 | uploadButton->setAutoRaise( true ); |
88 | #endif | 92 | #endif |
89 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); | 93 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); |
90 | //uploadButton->setEnabled( false ); | 94 | uploadButton->setEnabled( false ); |
91 | uploadButton->setEnabled( true ); | 95 | //uploadButton->setEnabled( true ); // DEBUGGING |
92 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); | 96 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); |
93 | 97 | ||
94 | // setup menu bar | 98 | // setup menu bar |
95 | 99 | ||
96 | int id; | 100 | int id; |
97 | 101 | ||
@@ -373,32 +377,64 @@ static const char* CAP_hostname = "www.vanille.de"; | |||
373 | #include <unistd.h> | 377 | #include <unistd.h> |
374 | #include <sys/types.h> | 378 | #include <sys/types.h> |
375 | #include <sys/socket.h> | 379 | #include <sys/socket.h> |
376 | 380 | ||
377 | void WellenreiterMainWindow::uploadSession() | 381 | void WellenreiterMainWindow::uploadSession() |
378 | { | 382 | { |
383 | QLineEdit* from; | ||
384 | QLineEdit* location; | ||
385 | QLineEdit* comments; | ||
386 | QPushButton* accept; | ||
387 | QPushButton* reject; | ||
388 | |||
389 | QDialog* d = new QDialog( 0, "session upload", true ); | ||
390 | d->setCaption( tr( "Upload Session" ) ); | ||
391 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); | ||
392 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); | ||
393 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); | ||
394 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); | ||
395 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); | ||
396 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); | ||
397 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); | ||
398 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); | ||
399 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); | ||
400 | accept->setDefault( true ); | ||
401 | accept->setAutoDefault( true ); | ||
402 | from->setText( "WL II User" ); | ||
403 | location->setText( "WL II Location" ); | ||
404 | comments->setText( "No Comments." ); | ||
405 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); | ||
406 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); | ||
407 | int result = d->exec(); | ||
408 | |||
409 | if ( !result ) | ||
410 | { | ||
411 | qDebug( "Session upload cancelled :(" ); | ||
412 | return; | ||
413 | } | ||
414 | |||
379 | qDebug( "Starting upload..." ); | 415 | qDebug( "Starting upload..." ); |
380 | 416 | ||
381 | struct sockaddr_in raddr; | 417 | struct sockaddr_in raddr; |
382 | struct hostent *rhost_info; | 418 | struct hostent *rhost_info; |
383 | int sock = -1; | 419 | int sock = -1; |
384 | bool ok = false; | 420 | bool ok = false; |
385 | 421 | ||
386 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); | 422 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); |
387 | if ( rhost_info ) | 423 | if ( rhost_info ) |
388 | { | 424 | { |
389 | if ( !QFile::exists( "/var/log/dump.wellenreiter" ) ) | 425 | if ( !QFile::exists( "/var/log/dump.wellenreiter" ) ) |
390 | { | 426 | { |
391 | qDebug( "no file to upload!" ); | 427 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile doesn't exist</p>") ); |
392 | return; | 428 | return; |
393 | } | 429 | } |
394 | 430 | ||
395 | QFile f( "/var/log/dump.wellenreiter" ); | 431 | QFile f( "/var/log/dump.wellenreiter" ); |
396 | if ( !f.open( IO_ReadOnly ) ) | 432 | if ( !f.open( IO_ReadOnly ) ) |
397 | { | 433 | { |
398 | qDebug( "can't open file!" ); | 434 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile</p>") ); |
399 | return; | 435 | return; |
400 | } | 436 | } |
401 | 437 | ||
402 | int content_length = f.size(); | 438 | int content_length = f.size(); |
403 | 439 | ||
404 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); | 440 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); |
@@ -432,29 +468,33 @@ void WellenreiterMainWindow::uploadSession() | |||
432 | "\r\n"; | 468 | "\r\n"; |
433 | 469 | ||
434 | content = "" | 470 | content = "" |
435 | "-----------------------------97267758015830030481215568065\r\n" | 471 | "-----------------------------97267758015830030481215568065\r\n" |
436 | "Content-Disposition: form-data; name=\"Name\"\r\n" | 472 | "Content-Disposition: form-data; name=\"Name\"\r\n" |
437 | "\r\n" | 473 | "\r\n" |
438 | "Anonymous Wellenreiter II User\r\n" | 474 | "%1\r\n" |
439 | "-----------------------------97267758015830030481215568065\r\n" | 475 | "-----------------------------97267758015830030481215568065\r\n" |
440 | "Content-Disposition: form-data; name=\"Location\"\r\n" | 476 | "Content-Disposition: form-data; name=\"Location\"\r\n" |
441 | "\r\n" | 477 | "\r\n" |
442 | "Anonymous Wellenreiter II Location\r\n" | 478 | "%2\r\n" |
443 | "-----------------------------97267758015830030481215568065\r\n" | 479 | "-----------------------------97267758015830030481215568065\r\n" |
444 | "Content-Disposition: form-data; name=\"Comments\"\r\n" | 480 | "Content-Disposition: form-data; name=\"Comments\"\r\n" |
445 | "\r\n" | 481 | "\r\n" |
446 | "Anonymous Wellenreiter II Comments\r\n" | 482 | "%3\r\n" |
447 | "-----------------------------97267758015830030481215568065\r\n" | 483 | "-----------------------------97267758015830030481215568065\r\n" |
448 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"/var/log/dump.wellenreiter\"\r\n" | 484 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"/var/log/dump.wellenreiter\"\r\n" |
449 | "Content-Type: application/octet-stream\r\n" | 485 | "Content-Type: application/octet-stream\r\n" |
450 | "\r\n"; | 486 | "\r\n"; |
451 | 487 | ||
452 | preambel = "" | 488 | preambel = "" |
453 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; | 489 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; |
454 | 490 | ||
491 | content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); | ||
492 | content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); | ||
493 | content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); | ||
494 | |||
455 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); | 495 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); |
456 | 496 | ||
457 | // write header | 497 | // write header |
458 | 498 | ||
459 | const char* ascii = header.latin1(); | 499 | const char* ascii = header.latin1(); |
460 | uint ascii_len = ::strlen( ascii ); | 500 | uint ascii_len = ::strlen( ascii ); |
@@ -486,11 +526,13 @@ void WellenreiterMainWindow::uploadSession() | |||
486 | ok = true; | 526 | ok = true; |
487 | } | 527 | } |
488 | } | 528 | } |
489 | ::close ( sock ); | 529 | ::close ( sock ); |
490 | } | 530 | } |
491 | if ( ok ) | 531 | if ( ok ) |
492 | QMessageBox::information ( 0, tr( "Success" ), QString ( "<p>%1</p>" ). arg( tr( "Capture Dump was uploaded to %1" )).arg ( CAP_hostname )); | 532 | QMessageBox::information( 0, tr( "Success" ), |
533 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); | ||
493 | else | 534 | else |
494 | QMessageBox::warning ( 0, tr( "Error" ), QString ( "<p>%1</p>" ). arg ( tr( "Connection to %1 failed." )). arg ( CAP_hostname )); | 535 | QMessageBox::warning( 0, tr( "Error" ), |
536 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); | ||
495 | } | 537 | } |
496 | 538 | ||