Diffstat (limited to 'noncore/net/wellenreiter/gui/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 7add6cd..a4b8839 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -1,82 +1,83 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Wellenreiter II. | 4 | ** This file is part of Wellenreiter II. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "configwindow.h" | 16 | #include "configwindow.h" |
17 | #include "gps.h" | 17 | #include "gps.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | #include "packetview.h" | 19 | #include "packetview.h" |
20 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
21 | #include "wellenreiter.h" | 21 | #include "wellenreiter.h" |
22 | #include "scanlist.h" | 22 | #include "scanlist.h" |
23 | 23 | ||
24 | /* OPIE */ | ||
25 | #ifdef QWS | ||
26 | #include <qpe/resource.h> | ||
27 | #include <opie2/odebug.h> | ||
28 | #include <opie2/ofiledialog.h> | ||
29 | #else | ||
30 | #include "resource.h" | ||
31 | #include <qapplication.h> | ||
32 | #include <qfiledialog.h> | ||
33 | #endif | ||
34 | using namespace Opie::Core; | ||
35 | using namespace Opie::Net; | ||
36 | using namespace Opie::Ui; | ||
37 | |||
38 | /* QT */ | ||
24 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
25 | #include <qdatastream.h> | 40 | #include <qdatastream.h> |
26 | #include <qfile.h> | 41 | #include <qfile.h> |
27 | #include <qfileinfo.h> | 42 | #include <qfileinfo.h> |
28 | #include <qlabel.h> | 43 | #include <qlabel.h> |
29 | #include <qlayout.h> | 44 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
31 | #include <qiconset.h> | 46 | #include <qiconset.h> |
32 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
33 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
34 | #include <qpopupmenu.h> | 49 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
36 | #include <qstatusbar.h> | 51 | #include <qstatusbar.h> |
37 | #include <qspinbox.h> | 52 | #include <qspinbox.h> |
38 | #include <qtextstream.h> | 53 | #include <qtextstream.h> |
39 | #include <qtoolbutton.h> | 54 | #include <qtoolbutton.h> |
40 | #include <qwhatsthis.h> | 55 | #include <qwhatsthis.h> |
41 | 56 | ||
42 | #ifdef QWS | 57 | /* STD */ |
43 | #include <qpe/resource.h> | ||
44 | #include <opie2/ofiledialog.h> | ||
45 | using namespace Opie; | ||
46 | #else | ||
47 | #include "resource.h" | ||
48 | #include <qapplication.h> | ||
49 | #include <qfiledialog.h> | ||
50 | #endif | ||
51 | |||
52 | #include <unistd.h> | 58 | #include <unistd.h> |
53 | 59 | ||
54 | using namespace Opie::Ui; | ||
55 | using namespace Opie::Net; | ||
56 | using namespace Opie::Ui; | ||
57 | using namespace Opie::Net; | ||
58 | using namespace Opie::Net; | ||
59 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 60 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
60 | :QMainWindow( parent, name, f ) | 61 | :QMainWindow( parent, name, f ) |
61 | { | 62 | { |
62 | cw = new WellenreiterConfigWindow( this ); | 63 | cw = new WellenreiterConfigWindow( this ); |
63 | mw = new Wellenreiter( this ); | 64 | mw = new Wellenreiter( this ); |
64 | mw->setConfigWindow( cw ); | 65 | mw->setConfigWindow( cw ); |
65 | setCentralWidget( mw ); | 66 | setCentralWidget( mw ); |
66 | 67 | ||
67 | // setup application icon | 68 | // setup application icon |
68 | 69 | ||
69 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | 70 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); |
70 | #ifndef QWS | 71 | #ifndef QWS |
71 | setIconText( "Wellenreiter/X11" ); | 72 | setIconText( "Wellenreiter/X11" ); |
72 | #endif | 73 | #endif |
73 | 74 | ||
74 | // setup tool buttons | 75 | // setup tool buttons |
75 | 76 | ||
76 | startButton = new QToolButton( 0 ); | 77 | startButton = new QToolButton( 0 ); |
77 | QWhatsThis::add( startButton, tr( "Click here to start scanning." ) ); | 78 | QWhatsThis::add( startButton, tr( "Click here to start scanning." ) ); |
78 | #ifdef QWS | 79 | #ifdef QWS |
79 | startButton->setAutoRaise( true ); | 80 | startButton->setAutoRaise( true ); |
80 | #endif | 81 | #endif |
81 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); | 82 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); |
82 | startButton->setEnabled( false ); | 83 | startButton->setEnabled( false ); |
@@ -167,112 +168,112 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
167 | mb->insertItem( d ); | 168 | mb->insertItem( d ); |
168 | #else // Qt3 changed the insertion order. It's now totally random :( | 169 | #else // Qt3 changed the insertion order. It's now totally random :( |
169 | mb->insertItem( d ); | 170 | mb->insertItem( d ); |
170 | mb->insertItem( uploadButton ); | 171 | mb->insertItem( uploadButton ); |
171 | mb->insertItem( stopButton ); | 172 | mb->insertItem( stopButton ); |
172 | mb->insertItem( startButton ); | 173 | mb->insertItem( startButton ); |
173 | #endif | 174 | #endif |
174 | 175 | ||
175 | updateToolButtonState(); | 176 | updateToolButtonState(); |
176 | 177 | ||
177 | // setup status bar (for now only on X11) | 178 | // setup status bar (for now only on X11) |
178 | 179 | ||
179 | #ifndef QWS | 180 | #ifndef QWS |
180 | statusBar()->message( tr( "Ready." ) ); | 181 | statusBar()->message( tr( "Ready." ) ); |
181 | #endif | 182 | #endif |
182 | 183 | ||
183 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); | 184 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); |
184 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); | 185 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); |
185 | }; | 186 | }; |
186 | 187 | ||
187 | 188 | ||
188 | 189 | ||
189 | void WellenreiterMainWindow::showConfigure() | 190 | void WellenreiterMainWindow::showConfigure() |
190 | { | 191 | { |
191 | qDebug( "show configure..." ); | 192 | odebug << "show configure..." << oendl; |
192 | cw->setCaption( tr( "Configure" ) ); | 193 | cw->setCaption( tr( "Configure" ) ); |
193 | int result = QPEApplication::execDialog( cw ); | 194 | int result = QPEApplication::execDialog( cw ); |
194 | 195 | ||
195 | if ( result ) updateToolButtonState(); | 196 | if ( result ) updateToolButtonState(); |
196 | } | 197 | } |
197 | 198 | ||
198 | 199 | ||
199 | void WellenreiterMainWindow::updateToolButtonState() | 200 | void WellenreiterMainWindow::updateToolButtonState() |
200 | { | 201 | { |
201 | const QString& interface = cw->interfaceName->currentText(); | 202 | const QString& interface = cw->interfaceName->currentText(); |
202 | const int cardtype = cw->driverType(); | 203 | const int cardtype = cw->driverType(); |
203 | 204 | ||
204 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 205 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) |
205 | { | 206 | { |
206 | startButton->setEnabled( true ); | 207 | startButton->setEnabled( true ); |
207 | menuBar()->setItemEnabled( startID, true ); | 208 | menuBar()->setItemEnabled( startID, true ); |
208 | } | 209 | } |
209 | else | 210 | else |
210 | { | 211 | { |
211 | startButton->setEnabled( false ); | 212 | startButton->setEnabled( false ); |
212 | menuBar()->setItemEnabled( startID, false ); | 213 | menuBar()->setItemEnabled( startID, false ); |
213 | } | 214 | } |
214 | } | 215 | } |
215 | 216 | ||
216 | 217 | ||
217 | void WellenreiterMainWindow::changedSniffingState() | 218 | void WellenreiterMainWindow::changedSniffingState() |
218 | { | 219 | { |
219 | startButton->setEnabled( !mw->sniffing ); | 220 | startButton->setEnabled( !mw->sniffing ); |
220 | menuBar()->setItemEnabled( startID, !mw->sniffing ); | 221 | menuBar()->setItemEnabled( startID, !mw->sniffing ); |
221 | stopButton->setEnabled( mw->sniffing ); | 222 | stopButton->setEnabled( mw->sniffing ); |
222 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | 223 | menuBar()->setItemEnabled( stopID, mw->sniffing ); |
223 | 224 | ||
224 | if ( !mw->sniffing ) | 225 | if ( !mw->sniffing ) |
225 | { | 226 | { |
226 | menuBar()->setItemEnabled( uploadID, true ); | 227 | menuBar()->setItemEnabled( uploadID, true ); |
227 | uploadButton->setEnabled( true ); | 228 | uploadButton->setEnabled( true ); |
228 | } | 229 | } |
229 | } | 230 | } |
230 | 231 | ||
231 | 232 | ||
232 | WellenreiterMainWindow::~WellenreiterMainWindow() | 233 | WellenreiterMainWindow::~WellenreiterMainWindow() |
233 | { | 234 | { |
234 | qDebug( "Wellenreiter: bye." ); | 235 | odebug << "Wellenreiter: bye." << oendl; |
235 | }; | 236 | }; |
236 | 237 | ||
237 | 238 | ||
238 | void WellenreiterMainWindow::demoAddStations() | 239 | void WellenreiterMainWindow::demoAddStations() |
239 | { | 240 | { |
240 | //mw = 0; // test SIGSEGV handling | 241 | //mw = 0; // test SIGSEGV handling |
241 | 242 | ||
242 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); | 243 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); |
243 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); | 244 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
244 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); | 245 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
245 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); | 246 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
246 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); | 247 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
247 | } | 248 | } |
248 | 249 | ||
249 | 250 | ||
250 | void WellenreiterMainWindow::demoReadFromGps() | 251 | void WellenreiterMainWindow::demoReadFromGps() |
251 | { | 252 | { |
252 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); | 253 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); |
253 | GPS* gps = new GPS( this ); | 254 | GPS* gps = new GPS( this ); |
254 | qDebug( "Wellenreiter::demoReadFromGps(): url=gps://%s:%d/", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 255 | odebug << "Wellenreiter::demoReadFromGps(): url=gps://" << (const char*) configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "/" << oendl; |
255 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 256 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
256 | GpsLocation loc = gps->position(); | 257 | GpsLocation loc = gps->position(); |
257 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); | 258 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); |
258 | delete gps; | 259 | delete gps; |
259 | } | 260 | } |
260 | 261 | ||
261 | 262 | ||
262 | QString WellenreiterMainWindow::getFileName( bool save ) | 263 | QString WellenreiterMainWindow::getFileName( bool save ) |
263 | { | 264 | { |
264 | QMap<QString, QStringList> map; | 265 | QMap<QString, QStringList> map; |
265 | map.insert( tr("All"), QStringList() ); | 266 | map.insert( tr("All"), QStringList() ); |
266 | QStringList text; | 267 | QStringList text; |
267 | text << "text/*"; | 268 | text << "text/*"; |
268 | map.insert( tr("Text"), text ); | 269 | map.insert( tr("Text"), text ); |
269 | text << "*"; | 270 | text << "*"; |
270 | map.insert( tr("All"), text ); | 271 | map.insert( tr("All"), text ); |
271 | 272 | ||
272 | QString str; | 273 | QString str; |
273 | if ( save ) | 274 | if ( save ) |
274 | { | 275 | { |
275 | #ifdef QWS | 276 | #ifdef QWS |
276 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 277 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
277 | #else | 278 | #else |
278 | str = QFileDialog::getSaveFileName(); | 279 | str = QFileDialog::getSaveFileName(); |
@@ -284,117 +285,117 @@ QString WellenreiterMainWindow::getFileName( bool save ) | |||
284 | { | 285 | { |
285 | #ifdef QWS | 286 | #ifdef QWS |
286 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); | 287 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); |
287 | #else | 288 | #else |
288 | str = QFileDialog::getOpenFileName(); | 289 | str = QFileDialog::getOpenFileName(); |
289 | #endif | 290 | #endif |
290 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) | 291 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) |
291 | return ""; | 292 | return ""; |
292 | } | 293 | } |
293 | return str; | 294 | return str; |
294 | } | 295 | } |
295 | 296 | ||
296 | 297 | ||
297 | void WellenreiterMainWindow::fileSaveLog() | 298 | void WellenreiterMainWindow::fileSaveLog() |
298 | { | 299 | { |
299 | QString fname = getFileName( true ); | 300 | QString fname = getFileName( true ); |
300 | if ( !fname.isEmpty() ) | 301 | if ( !fname.isEmpty() ) |
301 | { | 302 | { |
302 | QFile f( fname ); | 303 | QFile f( fname ); |
303 | if ( f.open(IO_WriteOnly) ) | 304 | if ( f.open(IO_WriteOnly) ) |
304 | { | 305 | { |
305 | QTextStream t( &f ); | 306 | QTextStream t( &f ); |
306 | t << mw->logWindow()->getLog(); | 307 | t << mw->logWindow()->getLog(); |
307 | f.close(); | 308 | f.close(); |
308 | qDebug( "Saved log to file '%s'", (const char*) fname ); | 309 | odebug << "Saved log to file '" << (const char*) fname << "'" << oendl; |
309 | } | 310 | } |
310 | else | 311 | else |
311 | { | 312 | { |
312 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); | 313 | odebug << "Problem saving log to file '" << (const char*) fname << "'" << oendl; |
313 | } | 314 | } |
314 | } | 315 | } |
315 | } | 316 | } |
316 | 317 | ||
317 | void WellenreiterMainWindow::fileSaveSession() | 318 | void WellenreiterMainWindow::fileSaveSession() |
318 | { | 319 | { |
319 | QString fname = getFileName( true ); | 320 | QString fname = getFileName( true ); |
320 | if ( !fname.isEmpty() ) | 321 | if ( !fname.isEmpty() ) |
321 | { | 322 | { |
322 | 323 | ||
323 | QFile f( fname ); | 324 | QFile f( fname ); |
324 | if ( f.open(IO_WriteOnly) ) | 325 | if ( f.open(IO_WriteOnly) ) |
325 | { | 326 | { |
326 | QDataStream t( &f ); | 327 | QDataStream t( &f ); |
327 | t << *mw->netView(); | 328 | t << *mw->netView(); |
328 | f.close(); | 329 | f.close(); |
329 | qDebug( "Saved session to file '%s'", (const char*) fname ); | 330 | odebug << "Saved session to file '" << (const char*) fname << "'" << oendl; |
330 | } | 331 | } |
331 | else | 332 | else |
332 | { | 333 | { |
333 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); | 334 | odebug << "Problem saving session to file '" << (const char*) fname << "'" << oendl; |
334 | } | 335 | } |
335 | } | 336 | } |
336 | } | 337 | } |
337 | 338 | ||
338 | void WellenreiterMainWindow::fileSaveHex() | 339 | void WellenreiterMainWindow::fileSaveHex() |
339 | { | 340 | { |
340 | #warning DOES NOT WORK AT THE MOMENT | 341 | #warning DOES NOT WORK AT THE MOMENT |
341 | /* | 342 | /* |
342 | QString fname = getFileName( true ); | 343 | QString fname = getFileName( true ); |
343 | if ( !fname.isEmpty() ) | 344 | if ( !fname.isEmpty() ) |
344 | { | 345 | { |
345 | QFile f( fname ); | 346 | QFile f( fname ); |
346 | if ( f.open(IO_WriteOnly) ) | 347 | if ( f.open(IO_WriteOnly) ) |
347 | { | 348 | { |
348 | QTextStream t( &f ); | 349 | QTextStream t( &f ); |
349 | t << mw->hexWindow()->getLog(); | 350 | t << mw->hexWindow()->getLog(); |
350 | f.close(); | 351 | f.close(); |
351 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); | 352 | odebug << "Saved hex log to file '" << (const char*) fname << "'" << oendl; |
352 | } | 353 | } |
353 | else | 354 | else |
354 | { | 355 | { |
355 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); | 356 | odebug << "Problem saving hex log to file '" << (const char*) fname << "'" << oendl; |
356 | } | 357 | } |
357 | } | 358 | } |
358 | */ | 359 | */ |
359 | } | 360 | } |
360 | 361 | ||
361 | void WellenreiterMainWindow::fileLoadSession() | 362 | void WellenreiterMainWindow::fileLoadSession() |
362 | { | 363 | { |
363 | QString fname = getFileName( false ); | 364 | QString fname = getFileName( false ); |
364 | if ( !fname.isEmpty() ) | 365 | if ( !fname.isEmpty() ) |
365 | { | 366 | { |
366 | QFile f( fname ); | 367 | QFile f( fname ); |
367 | if ( f.open(IO_ReadOnly) ) | 368 | if ( f.open(IO_ReadOnly) ) |
368 | { | 369 | { |
369 | QDataStream t( &f ); | 370 | QDataStream t( &f ); |
370 | t >> *mw->netView(); | 371 | t >> *mw->netView(); |
371 | f.close(); | 372 | f.close(); |
372 | qDebug( "Loaded session from file '%s'", (const char*) fname ); | 373 | odebug << "Loaded session from file '" << (const char*) fname << "'" << oendl; |
373 | } | 374 | } |
374 | else | 375 | else |
375 | { | 376 | { |
376 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); | 377 | odebug << "Problem loading session from file '" << (const char*) fname << "'" << oendl; |
377 | } | 378 | } |
378 | } | 379 | } |
379 | } | 380 | } |
380 | 381 | ||
381 | 382 | ||
382 | void WellenreiterMainWindow::fileNew() | 383 | void WellenreiterMainWindow::fileNew() |
383 | { | 384 | { |
384 | mw->netView()->clear(); | 385 | mw->netView()->clear(); |
385 | mw->logWindow()->clear(); | 386 | mw->logWindow()->clear(); |
386 | mw->hexWindow()->clear(); | 387 | mw->hexWindow()->clear(); |
387 | } | 388 | } |
388 | 389 | ||
389 | 390 | ||
390 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) | 391 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) |
391 | { | 392 | { |
392 | if ( mw->isDaemonRunning() ) | 393 | if ( mw->isDaemonRunning() ) |
393 | { | 394 | { |
394 | QMessageBox::warning( this, "Wellenreiter/Opie", | 395 | QMessageBox::warning( this, "Wellenreiter/Opie", |
395 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); | 396 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); |
396 | e->ignore(); | 397 | e->ignore(); |
397 | } | 398 | } |
398 | else | 399 | else |
399 | { | 400 | { |
400 | QMainWindow::closeEvent( e ); | 401 | QMainWindow::closeEvent( e ); |
@@ -417,53 +418,53 @@ void WellenreiterMainWindow::uploadSession() | |||
417 | QPushButton* reject; | 418 | QPushButton* reject; |
418 | 419 | ||
419 | QDialog* d = new QDialog( 0, "session upload", true ); | 420 | QDialog* d = new QDialog( 0, "session upload", true ); |
420 | d->setCaption( tr( "Upload Session" ) ); | 421 | d->setCaption( tr( "Upload Session" ) ); |
421 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); | 422 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); |
422 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); | 423 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); |
423 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); | 424 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); |
424 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); | 425 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); |
425 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); | 426 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); |
426 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); | 427 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); |
427 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); | 428 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); |
428 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); | 429 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); |
429 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); | 430 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); |
430 | accept->setDefault( true ); | 431 | accept->setDefault( true ); |
431 | accept->setAutoDefault( true ); | 432 | accept->setAutoDefault( true ); |
432 | from->setText( "WL II User" ); | 433 | from->setText( "WL II User" ); |
433 | location->setText( "WL II Location" ); | 434 | location->setText( "WL II Location" ); |
434 | comments->setText( "No Comments." ); | 435 | comments->setText( "No Comments." ); |
435 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); | 436 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); |
436 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); | 437 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); |
437 | int result = d->exec(); | 438 | int result = d->exec(); |
438 | 439 | ||
439 | if ( !result ) | 440 | if ( !result ) |
440 | { | 441 | { |
441 | qDebug( "Session upload cancelled :(" ); | 442 | odebug << "Session upload cancelled :(" << oendl; |
442 | return; | 443 | return; |
443 | } | 444 | } |
444 | 445 | ||
445 | qDebug( "Starting upload..." ); | 446 | odebug << "Starting upload..." << oendl; |
446 | 447 | ||
447 | struct sockaddr_in raddr; | 448 | struct sockaddr_in raddr; |
448 | struct hostent *rhost_info; | 449 | struct hostent *rhost_info; |
449 | int sock = -1; | 450 | int sock = -1; |
450 | bool ok = false; | 451 | bool ok = false; |
451 | 452 | ||
452 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); | 453 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); |
453 | if ( rhost_info ) | 454 | if ( rhost_info ) |
454 | { | 455 | { |
455 | 456 | ||
456 | 457 | ||
457 | if ( !QFile::exists( mw->captureFileName() ) ) | 458 | if ( !QFile::exists( mw->captureFileName() ) ) |
458 | { | 459 | { |
459 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); | 460 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); |
460 | return; | 461 | return; |
461 | } | 462 | } |
462 | 463 | ||
463 | QFile f( mw->captureFileName() ); | 464 | QFile f( mw->captureFileName() ); |
464 | if ( !f.open( IO_ReadOnly ) ) | 465 | if ( !f.open( IO_ReadOnly ) ) |
465 | { | 466 | { |
466 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); | 467 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); |
467 | return; | 468 | return; |
468 | } | 469 | } |
469 | 470 | ||