summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-15 14:46:55 (UTC)
committer mickeyl <mickeyl>2003-12-15 14:46:55 (UTC)
commita92cea6bfe45dd7a2e55b22281919f5e588b4d15 (patch) (unidiff)
treee2c6458304d6a2ede4f4feb265a469d9a196bdeb
parentab8df0d8a80bc4ea50b72b39eedf896bb9337f69 (diff)
downloadopie-a92cea6bfe45dd7a2e55b22281919f5e588b4d15.zip
opie-a92cea6bfe45dd7a2e55b22281919f5e588b4d15.tar.gz
opie-a92cea6bfe45dd7a2e55b22281919f5e588b4d15.tar.bz2
*** empty log message ***
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp60
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
@@ -25,10 +25,14 @@
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>
@@ -87,8 +91,8 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
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
@@ -376,6 +380,38 @@ static const char* CAP_hostname = "www.vanille.de";
376 380
377void WellenreiterMainWindow::uploadSession() 381void 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;
@@ -388,14 +424,14 @@ void WellenreiterMainWindow::uploadSession()
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
@@ -435,15 +471,15 @@ void WellenreiterMainWindow::uploadSession()
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"
@@ -452,6 +488,10 @@ void WellenreiterMainWindow::uploadSession()
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
@@ -489,8 +529,10 @@ void WellenreiterMainWindow::uploadSession()
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