-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 17 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 12 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 12 |
3 files changed, 23 insertions, 18 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 3e18531..ccb3ec0 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -1,583 +1,588 @@ | |||
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 */ | 24 | /* OPIE */ |
25 | #ifdef QWS | 25 | #ifdef QWS |
26 | #include <qpe/resource.h> | 26 | #include <opie2/oresource.h> |
27 | #include <opie2/odebug.h> | 27 | #include <opie2/odebug.h> |
28 | #include <opie2/ofiledialog.h> | 28 | #include <opie2/ofiledialog.h> |
29 | #else | 29 | #else |
30 | #include "resource.h" | 30 | #include "resource.h" |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #include <qfiledialog.h> | 32 | #include <qfiledialog.h> |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qdatastream.h> | 37 | #include <qdatastream.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qfileinfo.h> | 39 | #include <qfileinfo.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qlineedit.h> | 42 | #include <qlineedit.h> |
43 | #include <qiconset.h> | 43 | #include <qiconset.h> |
44 | #include <qmenubar.h> | 44 | #include <qmenubar.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qpopupmenu.h> | 46 | #include <qpopupmenu.h> |
47 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
48 | #include <qstatusbar.h> | 48 | #include <qstatusbar.h> |
49 | #include <qspinbox.h> | 49 | #include <qspinbox.h> |
50 | #include <qtextstream.h> | 50 | #include <qtextstream.h> |
51 | #include <qtoolbutton.h> | 51 | #include <qtoolbutton.h> |
52 | #include <qwhatsthis.h> | 52 | #include <qwhatsthis.h> |
53 | 53 | ||
54 | /* STD */ | 54 | /* STD */ |
55 | #include <unistd.h> | 55 | #include <unistd.h> |
56 | 56 | ||
57 | using namespace Opie::Core; | 57 | using namespace Opie::Core; |
58 | using namespace Opie::Net; | 58 | using namespace Opie::Net; |
59 | using namespace Opie::Ui; | 59 | using namespace Opie::Ui; |
60 | 60 | ||
61 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 61 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
62 | :QMainWindow( parent, name, f ) | 62 | :QMainWindow( parent, name, f ) |
63 | { | 63 | { |
64 | cw = new WellenreiterConfigWindow( this ); | 64 | cw = new WellenreiterConfigWindow( this ); |
65 | mw = new Wellenreiter( this ); | 65 | mw = new Wellenreiter( this ); |
66 | mw->setConfigWindow( cw ); | 66 | mw->setConfigWindow( cw ); |
67 | setCentralWidget( mw ); | 67 | setCentralWidget( mw ); |
68 | 68 | ||
69 | // setup application icon | 69 | // setup application icon |
70 | 70 | ||
71 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | 71 | setIcon( Opie::Core::OResource::loadPixmap( "wellenreiter/appicon-trans", Opie::Core::OResource::SmallIcon ) ); |
72 | #ifndef QWS | 72 | #ifndef QWS |
73 | setIconText( "Wellenreiter/X11" ); | 73 | setIconText( "Wellenreiter/X11" ); |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | // setup tool buttons | 76 | // setup tool buttons |
77 | bool useBigIcon = qApp->desktop()->size().width() > 330; | ||
77 | 78 | ||
78 | startButton = new QToolButton( 0 ); | 79 | startButton = new QToolButton( 0 ); |
80 | startButton->setUsesBigPixmap( useBigIcon ); | ||
79 | QWhatsThis::add( startButton, tr( "Click here to start scanning." ) ); | 81 | QWhatsThis::add( startButton, tr( "Click here to start scanning." ) ); |
80 | #ifdef QWS | 82 | #ifdef QWS |
81 | startButton->setAutoRaise( true ); | 83 | startButton->setAutoRaise( true ); |
82 | #endif | 84 | #endif |
83 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); | 85 | startButton->setIconSet( Opie::Core::OResource::loadPixmap( "wellenreiter/SearchIcon", Opie::Core::OResource::SmallIcon ) ); |
84 | startButton->setEnabled( false ); | 86 | startButton->setEnabled( false ); |
85 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); | 87 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); |
86 | 88 | ||
87 | stopButton = new QToolButton( 0 ); | 89 | stopButton = new QToolButton( 0 ); |
90 | stopButton->setUsesBigPixmap( useBigIcon ); | ||
88 | QWhatsThis::add( stopButton, tr( "Click here to stop scanning." ) ); | 91 | QWhatsThis::add( stopButton, tr( "Click here to stop scanning." ) ); |
89 | #ifdef QWS | 92 | #ifdef QWS |
90 | stopButton->setAutoRaise( true ); | 93 | stopButton->setAutoRaise( true ); |
91 | #endif | 94 | #endif |
92 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); | 95 | stopButton->setIconSet( Opie::Core::OResource::loadPixmap( "wellenreiter/CancelIcon", Opie::Core::OResource::SmallIcon ) ); |
93 | stopButton->setEnabled( false ); | 96 | stopButton->setEnabled( false ); |
94 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); | 97 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); |
95 | 98 | ||
96 | QToolButton* d = new QToolButton( 0 ); | 99 | QToolButton* d = new QToolButton( 0 ); |
100 | d->setUsesBigPixmap( useBigIcon ); | ||
97 | QWhatsThis::add( d, tr( "Click here to open the configure dialog." ) ), | 101 | QWhatsThis::add( d, tr( "Click here to open the configure dialog." ) ), |
98 | #ifdef QWS | 102 | #ifdef QWS |
99 | d->setAutoRaise( true ); | 103 | d->setAutoRaise( true ); |
100 | #endif | 104 | #endif |
101 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); | 105 | d->setIconSet( Opie::Core::OResource::loadPixmap( "wellenreiter/SettingsIcon", Opie::Core::OResource::SmallIcon ) ); |
102 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); | 106 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); |
103 | 107 | ||
104 | uploadButton = new QToolButton( 0 ); | 108 | uploadButton = new QToolButton( 0 ); |
109 | uploadButton->setUsesBigPixmap( useBigIcon ); | ||
105 | QWhatsThis::add( uploadButton, tr( "Click here to upload a capture session." ) ); | 110 | QWhatsThis::add( uploadButton, tr( "Click here to upload a capture session." ) ); |
106 | #ifdef QWS | 111 | #ifdef QWS |
107 | uploadButton->setAutoRaise( true ); | 112 | uploadButton->setAutoRaise( true ); |
108 | #endif | 113 | #endif |
109 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); | 114 | uploadButton->setIconSet( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); |
110 | uploadButton->setEnabled( false ); | 115 | uploadButton->setEnabled( false ); |
111 | //uploadButton->setEnabled( true ); // DEBUGGING | 116 | //uploadButton->setEnabled( true ); // DEBUGGING |
112 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); | 117 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); |
113 | 118 | ||
114 | // setup menu bar | 119 | // setup menu bar |
115 | 120 | ||
116 | int id; | 121 | int id; |
117 | 122 | ||
118 | QMenuBar* mb = menuBar(); | 123 | QMenuBar* mb = menuBar(); |
119 | 124 | ||
120 | QPopupMenu* fileSave = new QPopupMenu( mb ); | 125 | QPopupMenu* fileSave = new QPopupMenu( mb ); |
121 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); | 126 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); |
122 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); | 127 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); |
123 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); | 128 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); |
124 | 129 | ||
125 | QPopupMenu* fileLoad = new QPopupMenu( mb ); | 130 | QPopupMenu* fileLoad = new QPopupMenu( mb ); |
126 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); | 131 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); |
127 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); | 132 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); |
128 | 133 | ||
129 | QPopupMenu* file = new QPopupMenu( mb ); | 134 | QPopupMenu* file = new QPopupMenu( mb ); |
130 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); | 135 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); |
131 | id = file->insertItem( tr( "&Load" ), fileLoad ); | 136 | id = file->insertItem( tr( "&Load" ), fileLoad ); |
132 | file->insertItem( tr( "&Save" ), fileSave ); | 137 | file->insertItem( tr( "&Save" ), fileSave ); |
133 | file->insertSeparator(); | 138 | file->insertSeparator(); |
134 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); | 139 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); |
135 | file->insertSeparator(); | 140 | file->insertSeparator(); |
136 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); | 141 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); |
137 | 142 | ||
138 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 143 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
139 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); | 144 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); |
140 | sniffer->insertSeparator(); | 145 | sniffer->insertSeparator(); |
141 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); | 146 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); |
142 | sniffer->setItemEnabled( startID, false ); | 147 | sniffer->setItemEnabled( startID, false ); |
143 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); | 148 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); |
144 | sniffer->setItemEnabled( stopID, false ); | 149 | sniffer->setItemEnabled( stopID, false ); |
145 | 150 | ||
146 | QPopupMenu* view = new QPopupMenu( mb ); | 151 | QPopupMenu* view = new QPopupMenu( mb ); |
147 | view->insertItem( tr( "&Expand All" ), this, SLOT( viewExpandAll() ) ); | 152 | view->insertItem( tr( "&Expand All" ), this, SLOT( viewExpandAll() ) ); |
148 | view->insertItem( tr( "&Collapse All" ), this, SLOT( viewCollapseAll() ) ); | 153 | view->insertItem( tr( "&Collapse All" ), this, SLOT( viewCollapseAll() ) ); |
149 | 154 | ||
150 | QPopupMenu* demo = new QPopupMenu( mb ); | 155 | QPopupMenu* demo = new QPopupMenu( mb ); |
151 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); | 156 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); |
152 | //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); | 157 | //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); |
153 | 158 | ||
154 | id = mb->insertItem( tr( "&File" ), file ); | 159 | id = mb->insertItem( tr( "&File" ), file ); |
155 | 160 | ||
156 | id = mb->insertItem( tr( "&View" ), view ); | 161 | id = mb->insertItem( tr( "&View" ), view ); |
157 | //mb->setItemEnabled( id, false ); | 162 | //mb->setItemEnabled( id, false ); |
158 | 163 | ||
159 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); | 164 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); |
160 | 165 | ||
161 | id = mb->insertItem( tr( "&Demo" ), demo ); | 166 | id = mb->insertItem( tr( "&Demo" ), demo ); |
162 | mb->setItemEnabled( id, true ); | 167 | mb->setItemEnabled( id, true ); |
163 | mb->setItemEnabled( uploadID, false ); | 168 | mb->setItemEnabled( uploadID, false ); |
164 | 169 | ||
165 | #ifdef QWS | 170 | #ifdef QWS |
166 | mb->insertItem( startButton ); | 171 | mb->insertItem( startButton ); |
167 | mb->insertItem( stopButton ); | 172 | mb->insertItem( stopButton ); |
168 | mb->insertItem( uploadButton ); | 173 | mb->insertItem( uploadButton ); |
169 | mb->insertItem( d ); | 174 | mb->insertItem( d ); |
170 | #else // Qt3 changed the insertion order. It's now totally random :( | 175 | #else // Qt3 changed the insertion order. It's now totally random :( |
171 | mb->insertItem( d ); | 176 | mb->insertItem( d ); |
172 | mb->insertItem( uploadButton ); | 177 | mb->insertItem( uploadButton ); |
173 | mb->insertItem( stopButton ); | 178 | mb->insertItem( stopButton ); |
174 | mb->insertItem( startButton ); | 179 | mb->insertItem( startButton ); |
175 | #endif | 180 | #endif |
176 | 181 | ||
177 | updateToolButtonState(); | 182 | updateToolButtonState(); |
178 | 183 | ||
179 | // setup status bar (for now only on X11) | 184 | // setup status bar (for now only on X11) |
180 | 185 | ||
181 | #ifndef QWS | 186 | #ifndef QWS |
182 | statusBar()->message( tr( "Ready." ) ); | 187 | statusBar()->message( tr( "Ready." ) ); |
183 | #endif | 188 | #endif |
184 | 189 | ||
185 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); | 190 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); |
186 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); | 191 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); |
187 | }; | 192 | }; |
188 | 193 | ||
189 | 194 | ||
190 | 195 | ||
191 | void WellenreiterMainWindow::showConfigure() | 196 | void WellenreiterMainWindow::showConfigure() |
192 | { | 197 | { |
193 | odebug << "show configure..." << oendl; | 198 | odebug << "show configure..." << oendl; |
194 | cw->setCaption( tr( "Configure" ) ); | 199 | cw->setCaption( tr( "Configure" ) ); |
195 | int result = QPEApplication::execDialog( cw ); | 200 | int result = QPEApplication::execDialog( cw ); |
196 | 201 | ||
197 | if ( result ) updateToolButtonState(); | 202 | if ( result ) updateToolButtonState(); |
198 | } | 203 | } |
199 | 204 | ||
200 | 205 | ||
201 | void WellenreiterMainWindow::updateToolButtonState() | 206 | void WellenreiterMainWindow::updateToolButtonState() |
202 | { | 207 | { |
203 | const QString& interface = cw->interfaceName->currentText(); | 208 | const QString& interface = cw->interfaceName->currentText(); |
204 | const int cardtype = cw->driverType(); | 209 | const int cardtype = cw->driverType(); |
205 | 210 | ||
206 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 211 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) |
207 | { | 212 | { |
208 | startButton->setEnabled( true ); | 213 | startButton->setEnabled( true ); |
209 | menuBar()->setItemEnabled( startID, true ); | 214 | menuBar()->setItemEnabled( startID, true ); |
210 | } | 215 | } |
211 | else | 216 | else |
212 | { | 217 | { |
213 | startButton->setEnabled( false ); | 218 | startButton->setEnabled( false ); |
214 | menuBar()->setItemEnabled( startID, false ); | 219 | menuBar()->setItemEnabled( startID, false ); |
215 | } | 220 | } |
216 | } | 221 | } |
217 | 222 | ||
218 | 223 | ||
219 | void WellenreiterMainWindow::changedSniffingState() | 224 | void WellenreiterMainWindow::changedSniffingState() |
220 | { | 225 | { |
221 | startButton->setEnabled( !mw->sniffing ); | 226 | startButton->setEnabled( !mw->sniffing ); |
222 | menuBar()->setItemEnabled( startID, !mw->sniffing ); | 227 | menuBar()->setItemEnabled( startID, !mw->sniffing ); |
223 | stopButton->setEnabled( mw->sniffing ); | 228 | stopButton->setEnabled( mw->sniffing ); |
224 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | 229 | menuBar()->setItemEnabled( stopID, mw->sniffing ); |
225 | 230 | ||
226 | if ( !mw->sniffing && QFile::exists( mw->dumpname ) ) | 231 | if ( !mw->sniffing && QFile::exists( mw->dumpname ) ) |
227 | { | 232 | { |
228 | menuBar()->setItemEnabled( uploadID, true ); | 233 | menuBar()->setItemEnabled( uploadID, true ); |
229 | uploadButton->setEnabled( true ); | 234 | uploadButton->setEnabled( true ); |
230 | } | 235 | } |
231 | } | 236 | } |
232 | 237 | ||
233 | 238 | ||
234 | WellenreiterMainWindow::~WellenreiterMainWindow() | 239 | WellenreiterMainWindow::~WellenreiterMainWindow() |
235 | { | 240 | { |
236 | odebug << "Wellenreiter: bye." << oendl; | 241 | odebug << "Wellenreiter: bye." << oendl; |
237 | }; | 242 | }; |
238 | 243 | ||
239 | 244 | ||
240 | void WellenreiterMainWindow::demoAddStations() | 245 | void WellenreiterMainWindow::demoAddStations() |
241 | { | 246 | { |
242 | //mw = 0; // test SIGSEGV handling | 247 | //mw = 0; // test SIGSEGV handling |
243 | 248 | ||
244 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); | 249 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); |
245 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); | 250 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
246 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); | 251 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
247 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); | 252 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
248 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); | 253 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
249 | } | 254 | } |
250 | 255 | ||
251 | 256 | ||
252 | void WellenreiterMainWindow::demoReadFromGps() | 257 | void WellenreiterMainWindow::demoReadFromGps() |
253 | { | 258 | { |
254 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); | 259 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); |
255 | GPS* gps = new GPS( this ); | 260 | GPS* gps = new GPS( this ); |
256 | odebug << "Wellenreiter::demoReadFromGps(): url=gps://" << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "/" << oendl; | 261 | odebug << "Wellenreiter::demoReadFromGps(): url=gps://" << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "/" << oendl; |
257 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 262 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
258 | GpsLocation loc = gps->position(); | 263 | GpsLocation loc = gps->position(); |
259 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); | 264 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); |
260 | delete gps; | 265 | delete gps; |
261 | } | 266 | } |
262 | 267 | ||
263 | 268 | ||
264 | QString WellenreiterMainWindow::getFileName( bool save ) | 269 | QString WellenreiterMainWindow::getFileName( bool save ) |
265 | { | 270 | { |
266 | QMap<QString, QStringList> map; | 271 | QMap<QString, QStringList> map; |
267 | map.insert( tr("All"), QStringList() ); | 272 | map.insert( tr("All"), QStringList() ); |
268 | QStringList text; | 273 | QStringList text; |
269 | text << "text/*"; | 274 | text << "text/*"; |
270 | map.insert( tr("Text"), text ); | 275 | map.insert( tr("Text"), text ); |
271 | text << "*"; | 276 | text << "*"; |
272 | map.insert( tr("All"), text ); | 277 | map.insert( tr("All"), text ); |
273 | 278 | ||
274 | QString str; | 279 | QString str; |
275 | if ( save ) | 280 | if ( save ) |
276 | { | 281 | { |
277 | #ifdef QWS | 282 | #ifdef QWS |
278 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 283 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
279 | #else | 284 | #else |
280 | str = QFileDialog::getSaveFileName(); | 285 | str = QFileDialog::getSaveFileName(); |
281 | #endif | 286 | #endif |
282 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) | 287 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) |
283 | return ""; | 288 | return ""; |
284 | } | 289 | } |
285 | else | 290 | else |
286 | { | 291 | { |
287 | #ifdef QWS | 292 | #ifdef QWS |
288 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); | 293 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); |
289 | #else | 294 | #else |
290 | str = QFileDialog::getOpenFileName(); | 295 | str = QFileDialog::getOpenFileName(); |
291 | #endif | 296 | #endif |
292 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) | 297 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) |
293 | return ""; | 298 | return ""; |
294 | } | 299 | } |
295 | return str; | 300 | return str; |
296 | } | 301 | } |
297 | 302 | ||
298 | 303 | ||
299 | void WellenreiterMainWindow::fileSaveLog() | 304 | void WellenreiterMainWindow::fileSaveLog() |
300 | { | 305 | { |
301 | QString fname = getFileName( true ); | 306 | QString fname = getFileName( true ); |
302 | if ( !fname.isEmpty() ) | 307 | if ( !fname.isEmpty() ) |
303 | { | 308 | { |
304 | QFile f( fname ); | 309 | QFile f( fname ); |
305 | if ( f.open(IO_WriteOnly) ) | 310 | if ( f.open(IO_WriteOnly) ) |
306 | { | 311 | { |
307 | QTextStream t( &f ); | 312 | QTextStream t( &f ); |
308 | t << mw->logWindow()->getLog(); | 313 | t << mw->logWindow()->getLog(); |
309 | f.close(); | 314 | f.close(); |
310 | odebug << "Saved log to file '" << fname << "'" << oendl; | 315 | odebug << "Saved log to file '" << fname << "'" << oendl; |
311 | } | 316 | } |
312 | else | 317 | else |
313 | { | 318 | { |
314 | odebug << "Problem saving log to file '" << fname << "'" << oendl; | 319 | odebug << "Problem saving log to file '" << fname << "'" << oendl; |
315 | } | 320 | } |
316 | } | 321 | } |
317 | } | 322 | } |
318 | 323 | ||
319 | void WellenreiterMainWindow::fileSaveSession() | 324 | void WellenreiterMainWindow::fileSaveSession() |
320 | { | 325 | { |
321 | QString fname = getFileName( true ); | 326 | QString fname = getFileName( true ); |
322 | if ( !fname.isEmpty() ) | 327 | if ( !fname.isEmpty() ) |
323 | { | 328 | { |
324 | 329 | ||
325 | QFile f( fname ); | 330 | QFile f( fname ); |
326 | if ( f.open(IO_WriteOnly) ) | 331 | if ( f.open(IO_WriteOnly) ) |
327 | { | 332 | { |
328 | QDataStream t( &f ); | 333 | QDataStream t( &f ); |
329 | t << *mw->netView(); | 334 | t << *mw->netView(); |
330 | f.close(); | 335 | f.close(); |
331 | odebug << "Saved session to file '" << fname << "'" << oendl; | 336 | odebug << "Saved session to file '" << fname << "'" << oendl; |
332 | } | 337 | } |
333 | else | 338 | else |
334 | { | 339 | { |
335 | odebug << "Problem saving session to file '" << fname << "'" << oendl; | 340 | odebug << "Problem saving session to file '" << fname << "'" << oendl; |
336 | } | 341 | } |
337 | } | 342 | } |
338 | } | 343 | } |
339 | 344 | ||
340 | void WellenreiterMainWindow::fileSaveHex() | 345 | void WellenreiterMainWindow::fileSaveHex() |
341 | { | 346 | { |
342 | #warning DOES NOT WORK AT THE MOMENT | 347 | #warning DOES NOT WORK AT THE MOMENT |
343 | /* | 348 | /* |
344 | QString fname = getFileName( true ); | 349 | QString fname = getFileName( true ); |
345 | if ( !fname.isEmpty() ) | 350 | if ( !fname.isEmpty() ) |
346 | { | 351 | { |
347 | QFile f( fname ); | 352 | QFile f( fname ); |
348 | if ( f.open(IO_WriteOnly) ) | 353 | if ( f.open(IO_WriteOnly) ) |
349 | { | 354 | { |
350 | QTextStream t( &f ); | 355 | QTextStream t( &f ); |
351 | t << mw->hexWindow()->getLog(); | 356 | t << mw->hexWindow()->getLog(); |
352 | f.close(); | 357 | f.close(); |
353 | odebug << "Saved hex log to file '" << fname << "'" << oendl; | 358 | odebug << "Saved hex log to file '" << fname << "'" << oendl; |
354 | } | 359 | } |
355 | else | 360 | else |
356 | { | 361 | { |
357 | odebug << "Problem saving hex log to file '" << fname << "'" << oendl; | 362 | odebug << "Problem saving hex log to file '" << fname << "'" << oendl; |
358 | } | 363 | } |
359 | } | 364 | } |
360 | */ | 365 | */ |
361 | } | 366 | } |
362 | 367 | ||
363 | void WellenreiterMainWindow::fileLoadSession() | 368 | void WellenreiterMainWindow::fileLoadSession() |
364 | { | 369 | { |
365 | QString fname = getFileName( false ); | 370 | QString fname = getFileName( false ); |
366 | if ( !fname.isEmpty() ) | 371 | if ( !fname.isEmpty() ) |
367 | { | 372 | { |
368 | QFile f( fname ); | 373 | QFile f( fname ); |
369 | if ( f.open(IO_ReadOnly) ) | 374 | if ( f.open(IO_ReadOnly) ) |
370 | { | 375 | { |
371 | QDataStream t( &f ); | 376 | QDataStream t( &f ); |
372 | t >> *mw->netView(); | 377 | t >> *mw->netView(); |
373 | f.close(); | 378 | f.close(); |
374 | odebug << "Loaded session from file '" << fname << "'" << oendl; | 379 | odebug << "Loaded session from file '" << fname << "'" << oendl; |
375 | } | 380 | } |
376 | else | 381 | else |
377 | { | 382 | { |
378 | odebug << "Problem loading session from file '" << fname << "'" << oendl; | 383 | odebug << "Problem loading session from file '" << fname << "'" << oendl; |
379 | } | 384 | } |
380 | } | 385 | } |
381 | } | 386 | } |
382 | 387 | ||
383 | 388 | ||
384 | void WellenreiterMainWindow::fileNew() | 389 | void WellenreiterMainWindow::fileNew() |
385 | { | 390 | { |
386 | mw->netView()->clear(); | 391 | mw->netView()->clear(); |
387 | mw->logWindow()->clear(); | 392 | mw->logWindow()->clear(); |
388 | mw->hexWindow()->clear(); | 393 | mw->hexWindow()->clear(); |
389 | } | 394 | } |
390 | 395 | ||
391 | 396 | ||
392 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) | 397 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) |
393 | { | 398 | { |
394 | if ( mw->isDaemonRunning() ) | 399 | if ( mw->isDaemonRunning() ) |
395 | { | 400 | { |
396 | QMessageBox::warning( this, "Wellenreiter/Opie", | 401 | QMessageBox::warning( this, "Wellenreiter/Opie", |
397 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); | 402 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); |
398 | e->ignore(); | 403 | e->ignore(); |
399 | } | 404 | } |
400 | else | 405 | else |
401 | { | 406 | { |
402 | QMainWindow::closeEvent( e ); | 407 | QMainWindow::closeEvent( e ); |
403 | } | 408 | } |
404 | } | 409 | } |
405 | 410 | ||
406 | static const char* CAP_hostname = "www.vanille.de"; | 411 | static const char* CAP_hostname = "www.vanille.de"; |
407 | 412 | ||
408 | #include <netdb.h> | 413 | #include <netdb.h> |
409 | #include <unistd.h> | 414 | #include <unistd.h> |
410 | #include <sys/types.h> | 415 | #include <sys/types.h> |
411 | #include <sys/socket.h> | 416 | #include <sys/socket.h> |
412 | 417 | ||
413 | void WellenreiterMainWindow::uploadSession() | 418 | void WellenreiterMainWindow::uploadSession() |
414 | { | 419 | { |
415 | QLineEdit* from; | 420 | QLineEdit* from; |
416 | QLineEdit* location; | 421 | QLineEdit* location; |
417 | QLineEdit* comments; | 422 | QLineEdit* comments; |
418 | QPushButton* accept; | 423 | QPushButton* accept; |
419 | QPushButton* reject; | 424 | QPushButton* reject; |
420 | 425 | ||
421 | QDialog* d = new QDialog( 0, "session upload", true ); | 426 | QDialog* d = new QDialog( 0, "session upload", true ); |
422 | d->setCaption( tr( "Upload Session" ) ); | 427 | d->setCaption( tr( "Upload Session" ) ); |
423 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); | 428 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); |
424 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); | 429 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); |
425 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); | 430 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); |
426 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); | 431 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); |
427 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); | 432 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); |
428 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); | 433 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); |
429 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); | 434 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); |
430 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); | 435 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); |
431 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); | 436 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); |
432 | accept->setDefault( true ); | 437 | accept->setDefault( true ); |
433 | accept->setAutoDefault( true ); | 438 | accept->setAutoDefault( true ); |
434 | from->setText( "WL II User" ); | 439 | from->setText( "WL II User" ); |
435 | location->setText( "WL II Location" ); | 440 | location->setText( "WL II Location" ); |
436 | comments->setText( "No Comments." ); | 441 | comments->setText( "No Comments." ); |
437 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); | 442 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); |
438 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); | 443 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); |
439 | int result = d->exec(); | 444 | int result = d->exec(); |
440 | 445 | ||
441 | if ( !result ) | 446 | if ( !result ) |
442 | { | 447 | { |
443 | odebug << "Session upload cancelled :(" << oendl; | 448 | odebug << "Session upload cancelled :(" << oendl; |
444 | return; | 449 | return; |
445 | } | 450 | } |
446 | 451 | ||
447 | odebug << "Starting upload..." << oendl; | 452 | odebug << "Starting upload..." << oendl; |
448 | 453 | ||
449 | struct sockaddr_in raddr; | 454 | struct sockaddr_in raddr; |
450 | struct hostent *rhost_info; | 455 | struct hostent *rhost_info; |
451 | int sock = -1; | 456 | int sock = -1; |
452 | bool ok = false; | 457 | bool ok = false; |
453 | 458 | ||
454 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); | 459 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); |
455 | if ( rhost_info ) | 460 | if ( rhost_info ) |
456 | { | 461 | { |
457 | 462 | ||
458 | 463 | ||
459 | if ( !QFile::exists( mw->captureFileName() ) ) | 464 | if ( !QFile::exists( mw->captureFileName() ) ) |
460 | { | 465 | { |
461 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); | 466 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); |
462 | return; | 467 | return; |
463 | } | 468 | } |
464 | 469 | ||
465 | QFile f( mw->captureFileName() ); | 470 | QFile f( mw->captureFileName() ); |
466 | if ( !f.open( IO_ReadOnly ) ) | 471 | if ( !f.open( IO_ReadOnly ) ) |
467 | { | 472 | { |
468 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); | 473 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); |
469 | return; | 474 | return; |
470 | } | 475 | } |
471 | 476 | ||
472 | // int content_length = f.size(); | 477 | // int content_length = f.size(); |
473 | 478 | ||
474 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); | 479 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); |
475 | ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 480 | ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
476 | raddr.sin_family = rhost_info-> h_addrtype; | 481 | raddr.sin_family = rhost_info-> h_addrtype; |
477 | raddr.sin_port = htons ( 80 ); | 482 | raddr.sin_port = htons ( 80 ); |
478 | 483 | ||
479 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); | 484 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); |
480 | 485 | ||
481 | if ( sock >= 0 ) | 486 | if ( sock >= 0 ) |
482 | { | 487 | { |
483 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) | 488 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) |
484 | { | 489 | { |
485 | QString header; | 490 | QString header; |
486 | QString content; | 491 | QString content; |
487 | QString preambel; | 492 | QString preambel; |
488 | 493 | ||
489 | header = "" | 494 | header = "" |
490 | "POST /projects/capturedump.spy HTTP/1.1\r\n" | 495 | "POST /projects/capturedump.spy HTTP/1.1\r\n" |
491 | "Host: www.vanille.de\r\n" | 496 | "Host: www.vanille.de\r\n" |
492 | "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" | 497 | "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" |
493 | "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n" | 498 | "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n" |
494 | "Accept-Language: en\r\n" | 499 | "Accept-Language: en\r\n" |
495 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" | 500 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" |
496 | "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" | 501 | "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" |
497 | "Keep-Alive: 300\r\n" | 502 | "Keep-Alive: 300\r\n" |
498 | "Connection: keep-alive\r\n" | 503 | "Connection: keep-alive\r\n" |
499 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" | 504 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" |
500 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" | 505 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" |
501 | "Content-Length: %1\r\n" | 506 | "Content-Length: %1\r\n" |
502 | "\r\n"; | 507 | "\r\n"; |
503 | 508 | ||
504 | content = "" | 509 | content = "" |
505 | "-----------------------------97267758015830030481215568065\r\n" | 510 | "-----------------------------97267758015830030481215568065\r\n" |
506 | "Content-Disposition: form-data; name=\"Name\"\r\n" | 511 | "Content-Disposition: form-data; name=\"Name\"\r\n" |
507 | "\r\n" | 512 | "\r\n" |
508 | "%1\r\n" | 513 | "%1\r\n" |
509 | "-----------------------------97267758015830030481215568065\r\n" | 514 | "-----------------------------97267758015830030481215568065\r\n" |
510 | "Content-Disposition: form-data; name=\"Location\"\r\n" | 515 | "Content-Disposition: form-data; name=\"Location\"\r\n" |
511 | "\r\n" | 516 | "\r\n" |
512 | "%2\r\n" | 517 | "%2\r\n" |
513 | "-----------------------------97267758015830030481215568065\r\n" | 518 | "-----------------------------97267758015830030481215568065\r\n" |
514 | "Content-Disposition: form-data; name=\"Comments\"\r\n" | 519 | "Content-Disposition: form-data; name=\"Comments\"\r\n" |
515 | "\r\n" | 520 | "\r\n" |
516 | "%3\r\n" | 521 | "%3\r\n" |
517 | "-----------------------------97267758015830030481215568065\r\n" | 522 | "-----------------------------97267758015830030481215568065\r\n" |
518 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" | 523 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" |
519 | "Content-Type: application/octet-stream\r\n" | 524 | "Content-Type: application/octet-stream\r\n" |
520 | "\r\n"; | 525 | "\r\n"; |
521 | 526 | ||
522 | preambel = "" | 527 | preambel = "" |
523 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; | 528 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; |
524 | 529 | ||
525 | content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); | 530 | content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); |
526 | content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); | 531 | content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); |
527 | content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); | 532 | content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); |
528 | content = content.arg( mw->captureFileName() ); | 533 | content = content.arg( mw->captureFileName() ); |
529 | 534 | ||
530 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); | 535 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); |
531 | 536 | ||
532 | // write header | 537 | // write header |
533 | 538 | ||
534 | const char* ascii = header.latin1(); | 539 | const char* ascii = header.latin1(); |
535 | uint ascii_len = ::strlen( ascii ); | 540 | uint ascii_len = ::strlen( ascii ); |
536 | ::write ( sock, ascii, ascii_len ); | 541 | ::write ( sock, ascii, ascii_len ); |
537 | 542 | ||
538 | // write fixed content | 543 | // write fixed content |
539 | 544 | ||
540 | ascii = content.latin1(); | 545 | ascii = content.latin1(); |
541 | ascii_len = ::strlen( ascii ); | 546 | ascii_len = ::strlen( ascii ); |
542 | ::write ( sock, ascii, ascii_len ); | 547 | ::write ( sock, ascii, ascii_len ); |
543 | 548 | ||
544 | // write variable content | 549 | // write variable content |
545 | 550 | ||
546 | char ch; | 551 | char ch; |
547 | while ( !f.atEnd() ) | 552 | while ( !f.atEnd() ) |
548 | { | 553 | { |
549 | f.readBlock( &ch, 1 ); | 554 | f.readBlock( &ch, 1 ); |
550 | ::write ( sock, &ch, 1 ); | 555 | ::write ( sock, &ch, 1 ); |
551 | } | 556 | } |
552 | 557 | ||
553 | // write preambel | 558 | // write preambel |
554 | 559 | ||
555 | ascii = preambel.latin1(); | 560 | ascii = preambel.latin1(); |
556 | ascii_len = ::strlen( ascii ); | 561 | ascii_len = ::strlen( ascii ); |
557 | ::write ( sock, ascii, ascii_len ); | 562 | ::write ( sock, ascii, ascii_len ); |
558 | 563 | ||
559 | // done! | 564 | // done! |
560 | 565 | ||
561 | ok = true; | 566 | ok = true; |
562 | } | 567 | } |
563 | } | 568 | } |
564 | ::close ( sock ); | 569 | ::close ( sock ); |
565 | } | 570 | } |
566 | if ( ok ) | 571 | if ( ok ) |
567 | QMessageBox::information( 0, tr( "Success" ), | 572 | QMessageBox::information( 0, tr( "Success" ), |
568 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); | 573 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); |
569 | else | 574 | else |
570 | QMessageBox::warning( 0, tr( "Error" ), | 575 | QMessageBox::warning( 0, tr( "Error" ), |
571 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); | 576 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); |
572 | } | 577 | } |
573 | 578 | ||
574 | 579 | ||
575 | void WellenreiterMainWindow::viewExpandAll() | 580 | void WellenreiterMainWindow::viewExpandAll() |
576 | { | 581 | { |
577 | mw->netView()->expand(); | 582 | mw->netView()->expand(); |
578 | } | 583 | } |
579 | 584 | ||
580 | void WellenreiterMainWindow::viewCollapseAll() | 585 | void WellenreiterMainWindow::viewCollapseAll() |
581 | { | 586 | { |
582 | mw->netView()->collapse(); | 587 | mw->netView()->collapse(); |
583 | } | 588 | } |
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 587faad..a61e808 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,583 +1,583 @@ | |||
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 "scanlist.h" | 16 | #include "scanlist.h" |
17 | #include "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | 19 | ||
20 | /* OPIE */ | 20 | /* OPIE */ |
21 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <opie2/odebug.h> | 22 | #include <opie2/odebug.h> |
23 | #include <opie2/oresource.h> | ||
23 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | ||
25 | #else | 25 | #else |
26 | #include "resource.h" | 26 | #include "resource.h" |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | #include <qcursor.h> | 31 | #include <qcursor.h> |
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | 35 | ||
36 | /* STD */ | 36 | /* STD */ |
37 | #include <assert.h> | 37 | #include <assert.h> |
38 | 38 | ||
39 | using namespace Opie::Core; | 39 | using namespace Opie::Core; |
40 | using namespace Opie::Ui; | 40 | using namespace Opie::Ui; |
41 | using namespace Opie::Net; | 41 | using namespace Opie::Net; |
42 | 42 | ||
43 | const int col_type = 0; | 43 | const int col_type = 0; |
44 | const int col_essid = 0; | 44 | const int col_essid = 0; |
45 | const int col_sig = 1; | 45 | const int col_sig = 1; |
46 | const int col_ap = 2; | 46 | const int col_ap = 2; |
47 | const int col_channel = 3; | 47 | const int col_channel = 3; |
48 | const int col_wep = 4; | 48 | const int col_wep = 4; |
49 | const int col_traffic = 5; | 49 | const int col_traffic = 5; |
50 | const int col_ip = 6; | 50 | const int col_ip = 6; |
51 | const int col_manuf = 7; | 51 | const int col_manuf = 7; |
52 | const int col_firstseen = 8; | 52 | const int col_firstseen = 8; |
53 | const int col_lastseen = 9; | 53 | const int col_lastseen = 9; |
54 | const int col_location = 10; | 54 | const int col_location = 10; |
55 | 55 | ||
56 | #define DEBUG | 56 | #define DEBUG |
57 | 57 | ||
58 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 58 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
59 | :OListView( parent, name ) | 59 | :OListView( parent, name ) |
60 | { | 60 | { |
61 | setFrameShape( QListView::StyledPanel ); | 61 | setFrameShape( QListView::StyledPanel ); |
62 | setFrameShadow( QListView::Sunken ); | 62 | setFrameShadow( QListView::Sunken ); |
63 | 63 | ||
64 | addColumn( tr( "Net/Station" ) ); | 64 | addColumn( tr( "Net/Station" ) ); |
65 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 65 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
66 | addColumn( tr( "#" ) ); | 66 | addColumn( tr( "#" ) ); |
67 | setColumnAlignment( col_sig, AlignCenter ); | 67 | setColumnAlignment( col_sig, AlignCenter ); |
68 | addColumn( tr( "MAC" ) ); | 68 | addColumn( tr( "MAC" ) ); |
69 | setColumnAlignment( col_ap, AlignCenter ); | 69 | setColumnAlignment( col_ap, AlignCenter ); |
70 | addColumn( tr( "Chn" ) ); | 70 | addColumn( tr( "Chn" ) ); |
71 | setColumnAlignment( col_channel, AlignCenter ); | 71 | setColumnAlignment( col_channel, AlignCenter ); |
72 | addColumn( tr( "W" ) ); | 72 | addColumn( tr( "W" ) ); |
73 | setColumnAlignment( col_wep, AlignCenter ); | 73 | setColumnAlignment( col_wep, AlignCenter ); |
74 | addColumn( tr( "T" ) ); | 74 | addColumn( tr( "T" ) ); |
75 | setColumnAlignment( col_traffic, AlignCenter ); | 75 | setColumnAlignment( col_traffic, AlignCenter ); |
76 | addColumn( tr( "IP" ) ); | 76 | addColumn( tr( "IP" ) ); |
77 | setColumnAlignment( col_ip, AlignCenter ); | 77 | setColumnAlignment( col_ip, AlignCenter ); |
78 | addColumn( tr( "Manufacturer" ) ); | 78 | addColumn( tr( "Manufacturer" ) ); |
79 | setColumnAlignment( col_manuf, AlignCenter ); | 79 | setColumnAlignment( col_manuf, AlignCenter ); |
80 | addColumn( tr( "First Seen" ) ); | 80 | addColumn( tr( "First Seen" ) ); |
81 | setColumnAlignment( col_firstseen, AlignCenter ); | 81 | setColumnAlignment( col_firstseen, AlignCenter ); |
82 | addColumn( tr( "Last Seen" ) ); | 82 | addColumn( tr( "Last Seen" ) ); |
83 | setColumnAlignment( col_lastseen, AlignCenter ); | 83 | setColumnAlignment( col_lastseen, AlignCenter ); |
84 | addColumn( tr( "Location" ) ); | 84 | addColumn( tr( "Location" ) ); |
85 | setColumnAlignment( col_location, AlignCenter ); | 85 | setColumnAlignment( col_location, AlignCenter ); |
86 | setRootIsDecorated( true ); | 86 | setRootIsDecorated( true ); |
87 | setAllColumnsShowFocus( true ); | 87 | setAllColumnsShowFocus( true ); |
88 | 88 | ||
89 | connect( this, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), | 89 | connect( this, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
90 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | 90 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
91 | 91 | ||
92 | #ifdef QWS | 92 | #ifdef QWS |
93 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 93 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | }; | 96 | }; |
97 | 97 | ||
98 | 98 | ||
99 | MScanListView::~MScanListView() | 99 | MScanListView::~MScanListView() |
100 | { | 100 | { |
101 | }; | 101 | }; |
102 | 102 | ||
103 | 103 | ||
104 | OListViewItem* MScanListView::childFactory() | 104 | OListViewItem* MScanListView::childFactory() |
105 | { | 105 | { |
106 | return new MScanListItem( this ); | 106 | return new MScanListItem( this ); |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void MScanListView::serializeTo( QDataStream& s) const | 110 | void MScanListView::serializeTo( QDataStream& s) const |
111 | { | 111 | { |
112 | odebug << "serializing MScanListView" << oendl; | 112 | odebug << "serializing MScanListView" << oendl; |
113 | OListView::serializeTo( s ); | 113 | OListView::serializeTo( s ); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void MScanListView::serializeFrom( QDataStream& s) | 117 | void MScanListView::serializeFrom( QDataStream& s) |
118 | { | 118 | { |
119 | odebug << "serializing MScanListView" << oendl; | 119 | odebug << "serializing MScanListView" << oendl; |
120 | OListView::serializeFrom( s ); | 120 | OListView::serializeFrom( s ); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | void MScanListView::addNewItem( const QString& type, | 124 | void MScanListView::addNewItem( const QString& type, |
125 | const QString& essid, | 125 | const QString& essid, |
126 | const OMacAddress& mac, | 126 | const OMacAddress& mac, |
127 | bool wep, | 127 | bool wep, |
128 | int channel, | 128 | int channel, |
129 | int signal, | 129 | int signal, |
130 | const GpsLocation& loc, | 130 | const GpsLocation& loc, |
131 | bool probe ) | 131 | bool probe ) |
132 | { | 132 | { |
133 | QString macaddr = mac.toString(true); | 133 | QString macaddr = mac.toString(true); |
134 | 134 | ||
135 | #ifdef DEBUG | 135 | #ifdef DEBUG |
136 | odebug << "MScanList::addNewItem( " << type << " / " | 136 | odebug << "MScanList::addNewItem( " << type << " / " |
137 | << essid << " / " << macaddr | 137 | << essid << " / " << macaddr |
138 | << " [" << channel << "]" << oendl; | 138 | << " [" << channel << "]" << oendl; |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | // search, if we already have seen this net | 141 | // search, if we already have seen this net |
142 | 142 | ||
143 | QString s; | 143 | QString s; |
144 | MScanListItem* network; | 144 | MScanListItem* network; |
145 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 145 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
146 | 146 | ||
147 | while ( item && ( item->text( col_essid ) != essid ) ) | 147 | while ( item && ( item->text( col_essid ) != essid ) ) |
148 | { | 148 | { |
149 | #ifdef DEBUG | 149 | #ifdef DEBUG |
150 | odebug << "itemtext: " << item->text( col_essid ) << "" << oendl; | 150 | odebug << "itemtext: " << item->text( col_essid ) << "" << oendl; |
151 | #endif | 151 | #endif |
152 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 152 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
153 | } | 153 | } |
154 | if ( item ) | 154 | if ( item ) |
155 | { | 155 | { |
156 | // we have already seen this net, check all childs if MAC exists | 156 | // we have already seen this net, check all childs if MAC exists |
157 | 157 | ||
158 | network = item; | 158 | network = item; |
159 | 159 | ||
160 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 160 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
161 | assert( item ); // this shouldn't fail | 161 | assert( item ); // this shouldn't fail |
162 | 162 | ||
163 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 163 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
164 | { | 164 | { |
165 | #ifdef DEBUG | 165 | #ifdef DEBUG |
166 | odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl; | 166 | odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl; |
167 | #endif | 167 | #endif |
168 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 168 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
169 | } | 169 | } |
170 | 170 | ||
171 | if ( item ) | 171 | if ( item ) |
172 | { | 172 | { |
173 | // we have already seen this item, it's a dupe | 173 | // we have already seen this item, it's a dupe |
174 | #ifdef DEBUG | 174 | #ifdef DEBUG |
175 | odebug << "" << macaddr << " is a dupe - ignoring..." << oendl; | 175 | odebug << "" << macaddr << " is a dupe - ignoring..." << oendl; |
176 | #endif | 176 | #endif |
177 | item->receivedBeacon(); | 177 | item->receivedBeacon(); |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | else | 181 | else |
182 | { | 182 | { |
183 | s = QString( "(i) New network: ESSID '%1'" ).arg( essid ); | 183 | s = QString( "(i) New network: ESSID '%1'" ).arg( essid ); |
184 | MLogWindow::logwindow()->log( s ); | 184 | MLogWindow::logwindow()->log( s ); |
185 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); | 185 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | // insert new station as child from network | 189 | // insert new station as child from network |
190 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 190 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
191 | 191 | ||
192 | #ifdef DEBUG | 192 | #ifdef DEBUG |
193 | odebug << "inserting new station " << macaddr << "" << oendl; | 193 | odebug << "inserting new station " << macaddr << "" << oendl; |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 196 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
197 | station->setManufacturer( mac.manufacturer() ); | 197 | station->setManufacturer( mac.manufacturer() ); |
198 | station->setLocation( loc.dmsPosition() ); | 198 | station->setLocation( loc.dmsPosition() ); |
199 | 199 | ||
200 | if ( type == "managed" ) | 200 | if ( type == "managed" ) |
201 | { | 201 | { |
202 | s = QString( "(i) New Access Point in '%1' [%2]" ).arg( essid ).arg( channel ); | 202 | s = QString( "(i) New Access Point in '%1' [%2]" ).arg( essid ).arg( channel ); |
203 | } | 203 | } |
204 | else | 204 | else |
205 | { | 205 | { |
206 | s = QString( "(i) New AdHoc station in '%1' [%2]" ).arg( essid ).arg( channel ); | 206 | s = QString( "(i) New AdHoc station in '%1' [%2]" ).arg( essid ).arg( channel ); |
207 | } | 207 | } |
208 | MLogWindow::logwindow()->log( s ); | 208 | MLogWindow::logwindow()->log( s ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 212 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
213 | { | 213 | { |
214 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 214 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
215 | 215 | ||
216 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 216 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
217 | { | 217 | { |
218 | #ifdef DEBUG | 218 | #ifdef DEBUG |
219 | odebug << "subitemtext: " << subitem->text( col_ap ) << "" << oendl; | 219 | odebug << "subitemtext: " << subitem->text( col_ap ) << "" << oendl; |
220 | #endif | 220 | #endif |
221 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 221 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
222 | } | 222 | } |
223 | 223 | ||
224 | if ( subitem ) | 224 | if ( subitem ) |
225 | { | 225 | { |
226 | // we have already seen this item, it's a dupe | 226 | // we have already seen this item, it's a dupe |
227 | #ifdef DEBUG | 227 | #ifdef DEBUG |
228 | odebug << "" << addr.toString(true) << " is a dupe - ignoring..." << oendl; | 228 | odebug << "" << addr.toString(true) << " is a dupe - ignoring..." << oendl; |
229 | #endif | 229 | #endif |
230 | subitem->receivedBeacon(); //FIXME: sent data bit | 230 | subitem->receivedBeacon(); //FIXME: sent data bit |
231 | return; | 231 | return; |
232 | } | 232 | } |
233 | 233 | ||
234 | // Hey, it seems to be a new item :-D | 234 | // Hey, it seems to be a new item :-D |
235 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); | 235 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
236 | station->setManufacturer( addr.manufacturer() ); | 236 | station->setManufacturer( addr.manufacturer() ); |
237 | 237 | ||
238 | QString s; | 238 | QString s; |
239 | if ( type == "station" ) | 239 | if ( type == "station" ) |
240 | { | 240 | { |
241 | s = QString( "(i) New Station in '%1' [xx]" ).arg( network->text( col_essid ) ); | 241 | s = QString( "(i) New Station in '%1' [xx]" ).arg( network->text( col_essid ) ); |
242 | } | 242 | } |
243 | else | 243 | else |
244 | { | 244 | { |
245 | s = QString( "(i) New Wireless Station in '%1' [xx]" ).arg( network->text( col_essid ) ); | 245 | s = QString( "(i) New Wireless Station in '%1' [xx]" ).arg( network->text( col_essid ) ); |
246 | } | 246 | } |
247 | MLogWindow::logwindow()->log( s ); | 247 | MLogWindow::logwindow()->log( s ); |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 251 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
252 | { | 252 | { |
253 | odebug << "WDSTraffic: " << viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl; | 253 | odebug << "WDSTraffic: " << viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl; |
254 | QString s; | 254 | QString s; |
255 | // MScanListItem* network; | 255 | // MScanListItem* network; |
256 | 256 | ||
257 | QListViewItemIterator it( this ); | 257 | QListViewItemIterator it( this ); |
258 | while ( it.current() && | 258 | while ( it.current() && |
259 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 259 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
260 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 260 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
261 | 261 | ||
262 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 262 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
263 | 263 | ||
264 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 264 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
265 | { | 265 | { |
266 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 266 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
267 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 267 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
268 | } | 268 | } |
269 | else | 269 | else |
270 | { | 270 | { |
271 | odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl; | 271 | odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl; |
272 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 272 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | 276 | ||
277 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) | 277 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) |
278 | { | 278 | { |
279 | QString s; | 279 | QString s; |
280 | // MScanListItem* network; | 280 | // MScanListItem* network; |
281 | 281 | ||
282 | QListViewItemIterator it( this ); | 282 | QListViewItemIterator it( this ); |
283 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 283 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
284 | 284 | ||
285 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 285 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
286 | 286 | ||
287 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 287 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
288 | { | 288 | { |
289 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 289 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
290 | } | 290 | } |
291 | else | 291 | else |
292 | { | 292 | { |
293 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; | 293 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; |
294 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 294 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
295 | 295 | ||
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) | 300 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) |
301 | { | 301 | { |
302 | QString s; | 302 | QString s; |
303 | // MScanListItem* network; | 303 | // MScanListItem* network; |
304 | 304 | ||
305 | QListViewItemIterator it( this ); | 305 | QListViewItemIterator it( this ); |
306 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 306 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
307 | 307 | ||
308 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 308 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
309 | 309 | ||
310 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 310 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
311 | { | 311 | { |
312 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 312 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
313 | } | 313 | } |
314 | else | 314 | else |
315 | { | 315 | { |
316 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; | 316 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; |
317 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 317 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | void MScanListView::IBSStraffic( const OMacAddress& /*from*/, const OMacAddress& /*to*/, const OMacAddress& /*via*/ ) | 322 | void MScanListView::IBSStraffic( const OMacAddress& /*from*/, const OMacAddress& /*to*/, const OMacAddress& /*via*/ ) |
323 | { | 323 | { |
324 | owarn << "D'oh! Not yet implemented..." << oendl; | 324 | owarn << "D'oh! Not yet implemented..." << oendl; |
325 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 325 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 329 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
330 | { | 330 | { |
331 | odebug << "identify " << macaddr.toString() << " = " << ip << "" << oendl; | 331 | odebug << "identify " << macaddr.toString() << " = " << ip << "" << oendl; |
332 | 332 | ||
333 | QListViewItemIterator it( this ); | 333 | QListViewItemIterator it( this ); |
334 | for ( ; it.current(); ++it ) | 334 | for ( ; it.current(); ++it ) |
335 | { | 335 | { |
336 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 336 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
337 | { | 337 | { |
338 | it.current()->setText( col_ip, ip ); | 338 | it.current()->setText( col_ip, ip ); |
339 | return; | 339 | return; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; | 342 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; |
343 | MLogWindow::logwindow()->log( QString( "WARNING: Unhandled identification %1 = %2!" ) | 343 | MLogWindow::logwindow()->log( QString( "WARNING: Unhandled identification %1 = %2!" ) |
344 | .arg( macaddr.toString() ).arg( ip ) ); | 344 | .arg( macaddr.toString() ).arg( ip ) ); |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 348 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
349 | { | 349 | { |
350 | odebug << "addService '" << name << "', Server = " << macaddr.toString() << " = " << ip << "" << oendl; | 350 | odebug << "addService '" << name << "', Server = " << macaddr.toString() << " = " << ip << "" << oendl; |
351 | 351 | ||
352 | //TODO: Refactor that out, we need it all over the place. | 352 | //TODO: Refactor that out, we need it all over the place. |
353 | // Best to do it in a more comfortable abstraction in OListView | 353 | // Best to do it in a more comfortable abstraction in OListView |
354 | // (Hmm, didn't I already start something in this direction?) | 354 | // (Hmm, didn't I already start something in this direction?) |
355 | 355 | ||
356 | QListViewItemIterator it( this ); | 356 | QListViewItemIterator it( this ); |
357 | for ( ; it.current(); ++it ) | 357 | for ( ; it.current(); ++it ) |
358 | { | 358 | { |
359 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 359 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
360 | { | 360 | { |
361 | 361 | ||
362 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 362 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
363 | 363 | ||
364 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 364 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
365 | { | 365 | { |
366 | #ifdef DEBUG | 366 | #ifdef DEBUG |
367 | odebug << "subitemtext: " << subitem->text( col_essid ) << "" << oendl; | 367 | odebug << "subitemtext: " << subitem->text( col_essid ) << "" << oendl; |
368 | #endif | 368 | #endif |
369 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 369 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
370 | } | 370 | } |
371 | 371 | ||
372 | if ( subitem ) | 372 | if ( subitem ) |
373 | { | 373 | { |
374 | // we have already seen this item, it's a dupe | 374 | // we have already seen this item, it's a dupe |
375 | #ifdef DEBUG | 375 | #ifdef DEBUG |
376 | odebug << "" << name << " is a dupe - ignoring..." << oendl; | 376 | odebug << "" << name << " is a dupe - ignoring..." << oendl; |
377 | #endif | 377 | #endif |
378 | subitem->receivedBeacon(); //FIXME: sent data bit | 378 | subitem->receivedBeacon(); //FIXME: sent data bit |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | 381 | ||
382 | // never seen that - add new item | 382 | // never seen that - add new item |
383 | 383 | ||
384 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); | 384 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
385 | item->setText( col_essid, name ); | 385 | item->setText( col_essid, name ); |
386 | 386 | ||
387 | return; | 387 | return; |
388 | } | 388 | } |
389 | } | 389 | } |
390 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; | 390 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; |
391 | MLogWindow::logwindow()->log( QString("WARNING: Unhandled service addition %s = %s!") | 391 | MLogWindow::logwindow()->log( QString("WARNING: Unhandled service addition %s = %s!") |
392 | .arg( macaddr.toString() ).arg( ip ) ); | 392 | .arg( macaddr.toString() ).arg( ip ) ); |
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 396 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
397 | { | 397 | { |
398 | if ( !item ) return; | 398 | if ( !item ) return; |
399 | 399 | ||
400 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 400 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
401 | 401 | ||
402 | odebug << "contextMenuRequested on item '" << itm->text(0) << "' (" | 402 | odebug << "contextMenuRequested on item '" << itm->text(0) << "' (" |
403 | << itm->type << ") in column: '" << col << "'" << oendl; | 403 | << itm->type << ") in column: '" << col << "'" << oendl; |
404 | 404 | ||
405 | /* do something meaningful */ | 405 | /* do something meaningful */ |
406 | 406 | ||
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | 409 | ||
410 | //============================================================ | 410 | //============================================================ |
411 | // MScanListItem | 411 | // MScanListItem |
412 | //============================================================ | 412 | //============================================================ |
413 | 413 | ||
414 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, | 414 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
415 | bool wep, int channel, int signal, bool probed ) | 415 | bool wep, int channel, int signal, bool probed ) |
416 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 416 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
417 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 417 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
418 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 418 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
419 | { | 419 | { |
420 | #ifdef DEBUG | 420 | #ifdef DEBUG |
421 | odebug << "creating scanlist item" << oendl; | 421 | odebug << "creating scanlist item" << oendl; |
422 | #endif | 422 | #endif |
423 | 423 | ||
424 | if ( WellenreiterConfigWindow::instance() ) | 424 | if ( WellenreiterConfigWindow::instance() ) |
425 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 425 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
426 | 426 | ||
427 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); | 427 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
428 | } | 428 | } |
429 | 429 | ||
430 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 430 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
431 | bool wep, int channel, int signal ) | 431 | bool wep, int channel, int signal ) |
432 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 432 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
433 | { | 433 | { |
434 | #ifdef DEBUG | 434 | #ifdef DEBUG |
435 | odebug << "creating scanlist item" << oendl; | 435 | odebug << "creating scanlist item" << oendl; |
436 | #endif | 436 | #endif |
437 | if ( WellenreiterConfigWindow::instance() ) | 437 | if ( WellenreiterConfigWindow::instance() ) |
438 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 438 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
439 | 439 | ||
440 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); | 440 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
441 | } | 441 | } |
442 | 442 | ||
443 | const QString& MScanListItem::essid() const | 443 | const QString& MScanListItem::essid() const |
444 | { | 444 | { |
445 | if ( type == "network" ) | 445 | if ( type == "network" ) |
446 | return _essid; | 446 | return _essid; |
447 | else | 447 | else |
448 | return ( (MScanListItem*) parent() )->essid(); | 448 | return ( (MScanListItem*) parent() )->essid(); |
449 | } | 449 | } |
450 | 450 | ||
451 | OListViewItem* MScanListItem::childFactory() | 451 | OListViewItem* MScanListItem::childFactory() |
452 | { | 452 | { |
453 | return new MScanListItem( this ); | 453 | return new MScanListItem( this ); |
454 | } | 454 | } |
455 | 455 | ||
456 | void MScanListItem::serializeTo( QDataStream& s ) const | 456 | void MScanListItem::serializeTo( QDataStream& s ) const |
457 | { | 457 | { |
458 | #ifdef DEBUG | 458 | #ifdef DEBUG |
459 | odebug << "serializing MScanListItem" << oendl; | 459 | odebug << "serializing MScanListItem" << oendl; |
460 | #endif | 460 | #endif |
461 | OListViewItem::serializeTo( s ); | 461 | OListViewItem::serializeTo( s ); |
462 | 462 | ||
463 | s << _type; | 463 | s << _type; |
464 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 464 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
465 | } | 465 | } |
466 | 466 | ||
467 | void MScanListItem::serializeFrom( QDataStream& s ) | 467 | void MScanListItem::serializeFrom( QDataStream& s ) |
468 | { | 468 | { |
469 | #ifdef DEBUG | 469 | #ifdef DEBUG |
470 | odebug << "serializing MScanListItem" << oendl; | 470 | odebug << "serializing MScanListItem" << oendl; |
471 | #endif | 471 | #endif |
472 | OListViewItem::serializeFrom( s ); | 472 | OListViewItem::serializeFrom( s ); |
473 | 473 | ||
474 | Q_UINT8 wep; | 474 | Q_UINT8 wep; |
475 | s >> _type; | 475 | s >> _type; |
476 | s >> wep; | 476 | s >> wep; |
477 | _wep = (wep == 'y'); | 477 | _wep = (wep == 'y'); |
478 | 478 | ||
479 | QString name = QString( "wellenreiter/"+ _type ); | 479 | QString name = QString( "wellenreiter/"+ _type ); |
480 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 480 | setPixmap( col_type, Opie::Core::OResource::loadPixmap( name, Opie::Core::OResource::SmallIcon ) ); |
481 | if ( _wep ) | 481 | if ( _wep ) |
482 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 482 | setPixmap( col_wep, Opie::Core::OResource::loadPixmap( "wellenreiter/cracked", Opie::Core::OResource::SmallIcon ) ); //FIXME: rename the pixmap! |
483 | listView()->triggerUpdate(); | 483 | listView()->triggerUpdate(); |
484 | } | 484 | } |
485 | 485 | ||
486 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) | 486 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) |
487 | { | 487 | { |
488 | #ifdef DEBUG | 488 | #ifdef DEBUG |
489 | odebug << "decorating scanlist item " << type << " / " | 489 | odebug << "decorating scanlist item " << type << " / " |
490 | << essid << " / " << macaddr | 490 | << essid << " / " << macaddr |
491 | << "[" << channel << "]" << oendl; | 491 | << "[" << channel << "]" << oendl; |
492 | #endif | 492 | #endif |
493 | 493 | ||
494 | // set icon for managed or adhoc mode | 494 | // set icon for managed or adhoc mode |
495 | QString name; | 495 | QString name; |
496 | name.sprintf( "wellenreiter/"+ type ); | 496 | name.sprintf( "wellenreiter/"+ type ); |
497 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 497 | setPixmap( col_type, Opie::Core::OResource::loadPixmap( name, Opie::Core::OResource::SmallIcon ) ); |
498 | 498 | ||
499 | // special case for probed networks FIXME: This is ugly at present | 499 | // special case for probed networks FIXME: This is ugly at present |
500 | if ( type == "network" && probed ) | 500 | if ( type == "network" && probed ) |
501 | { | 501 | { |
502 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); | 502 | setPixmap( col_type, Opie::Core::OResource::loadPixmap( "wellenreiter/network-probed", Opie::Core::OResource::SmallIcon ) ); |
503 | } | 503 | } |
504 | 504 | ||
505 | // set icon for wep (wireless encryption protocol) | 505 | // set icon for wep (wireless encryption protocol) |
506 | if ( wep ) | 506 | if ( wep ) |
507 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 507 | setPixmap( col_wep, Opie::Core::OResource::loadPixmap( "wellenreiter/cracked", Opie::Core::OResource::SmallIcon ) ); //FIXME: rename the pixmap! |
508 | 508 | ||
509 | // set channel and signal text | 509 | // set channel and signal text |
510 | 510 | ||
511 | if ( signal != -1 ) | 511 | if ( signal != -1 ) |
512 | setText( col_sig, QString::number( signal ) ); | 512 | setText( col_sig, QString::number( signal ) ); |
513 | if ( channel != -1 ) | 513 | if ( channel != -1 ) |
514 | setText( col_channel, QString::number( channel ) ); | 514 | setText( col_channel, QString::number( channel ) ); |
515 | 515 | ||
516 | setText( col_firstseen, QTime::currentTime().toString() ); | 516 | setText( col_firstseen, QTime::currentTime().toString() ); |
517 | //setText( col_lastseen, QTime::currentTime().toString() ); | 517 | //setText( col_lastseen, QTime::currentTime().toString() ); |
518 | 518 | ||
519 | listView()->triggerUpdate(); | 519 | listView()->triggerUpdate(); |
520 | 520 | ||
521 | this->type = type; | 521 | this->type = type; |
522 | _type = type; | 522 | _type = type; |
523 | _essid = essid; | 523 | _essid = essid; |
524 | _macaddr = macaddr; | 524 | _macaddr = macaddr; |
525 | _channel = channel; | 525 | _channel = channel; |
526 | _beacons = 1; | 526 | _beacons = 1; |
527 | _signal = 0; | 527 | _signal = 0; |
528 | 528 | ||
529 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) | 529 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) |
530 | { | 530 | { |
531 | listView()->ensureItemVisible( this ); | 531 | listView()->ensureItemVisible( this ); |
532 | } | 532 | } |
533 | 533 | ||
534 | } | 534 | } |
535 | 535 | ||
536 | 536 | ||
537 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 537 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
538 | { | 538 | { |
539 | setText( col_manuf, manufacturer ); | 539 | setText( col_manuf, manufacturer ); |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | void MScanListItem::setLocation( const QString& location ) | 543 | void MScanListItem::setLocation( const QString& location ) |
544 | { | 544 | { |
545 | setText( col_location, location ); | 545 | setText( col_location, location ); |
546 | } | 546 | } |
547 | 547 | ||
548 | 548 | ||
549 | void MScanListItem::receivedBeacon() | 549 | void MScanListItem::receivedBeacon() |
550 | { | 550 | { |
551 | _beacons++; | 551 | _beacons++; |
552 | #ifdef DEBUG | 552 | #ifdef DEBUG |
553 | odebug << "MScanListItem " << _macaddr << ": received beacon #" << _beacons << "" << oendl; | 553 | odebug << "MScanListItem " << _macaddr << ": received beacon #" << _beacons << "" << oendl; |
554 | #endif | 554 | #endif |
555 | setText( col_sig, QString::number( _beacons ) ); | 555 | setText( col_sig, QString::number( _beacons ) ); |
556 | setText( col_lastseen, QTime::currentTime().toString() ); | 556 | setText( col_lastseen, QTime::currentTime().toString() ); |
557 | 557 | ||
558 | MScanListItem* p = (MScanListItem*) parent(); | 558 | MScanListItem* p = (MScanListItem*) parent(); |
559 | if ( p ) p->receivedBeacon(); | 559 | if ( p ) p->receivedBeacon(); |
560 | 560 | ||
561 | } | 561 | } |
562 | 562 | ||
563 | QString MScanListItem::key( int id, bool b )const { | 563 | QString MScanListItem::key( int id, bool b )const { |
564 | QString str; | 564 | QString str; |
565 | 565 | ||
566 | /* | 566 | /* |
567 | * Pad the amount of received packages, number | 567 | * Pad the amount of received packages, number |
568 | * of the channel. | 568 | * of the channel. |
569 | */ | 569 | */ |
570 | switch( id ) { | 570 | switch( id ) { |
571 | case col_sig: | 571 | case col_sig: |
572 | str = text(col_sig).rightJustify( 20, '0' ); | 572 | str = text(col_sig).rightJustify( 20, '0' ); |
573 | break; | 573 | break; |
574 | case col_channel: | 574 | case col_channel: |
575 | str = text(col_channel).rightJustify( 2, '0' ); | 575 | str = text(col_channel).rightJustify( 2, '0' ); |
576 | break; | 576 | break; |
577 | default: | 577 | default: |
578 | str = Opie::Ui::OListViewItem::key( id, b ); | 578 | str = Opie::Ui::OListViewItem::key( id, b ); |
579 | break; | 579 | break; |
580 | } | 580 | } |
581 | 581 | ||
582 | return str; | 582 | return str; |
583 | } | 583 | } |
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index 1d5bd1b..11eb145 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp | |||
@@ -1,190 +1,190 @@ | |||
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 "wellenreiterbase.h" | 16 | #include "wellenreiterbase.h" |
17 | 17 | ||
18 | #include <qlabel.h> | 18 | #include <qlabel.h> |
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | 20 | ||
21 | #include "logwindow.h" | 21 | #include "logwindow.h" |
22 | #include "packetview.h" | 22 | #include "packetview.h" |
23 | #include "scanlist.h" | 23 | #include "scanlist.h" |
24 | #include "statwindow.h" | 24 | #include "statwindow.h" |
25 | #include "graphwindow.h" | 25 | #include "graphwindow.h" |
26 | 26 | ||
27 | #ifdef QWS | 27 | #ifdef QWS |
28 | #include <qpe/resource.h> | 28 | #include <opie2/oresource.h> |
29 | #include <opie2/otabwidget.h> | 29 | #include <opie2/otabwidget.h> |
30 | using namespace Opie; | 30 | using namespace Opie; |
31 | #else | 31 | #else |
32 | #include "resource.h" | 32 | #include "resource.h" |
33 | #include <qtabwidget.h> | 33 | #include <qtabwidget.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | /* | 36 | /* |
37 | * Constructs a WellenreiterBase which is a child of 'parent', with the | 37 | * Constructs a WellenreiterBase which is a child of 'parent', with the |
38 | * name 'name' and widget flags set to 'f' | 38 | * name 'name' and widget flags set to 'f' |
39 | */ | 39 | */ |
40 | using namespace Opie::Ui; | 40 | using namespace Opie::Ui; |
41 | using namespace Opie::Ui; | 41 | using namespace Opie::Ui; |
42 | using namespace Opie::Ui; | 42 | using namespace Opie::Ui; |
43 | WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) | 43 | WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) |
44 | : QWidget( parent, name, fl ) | 44 | : QWidget( parent, name, fl ) |
45 | { | 45 | { |
46 | //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) ); | 46 | //ani1 = new QPixmap( Opie::Core::OResource::loadPixmap( "wellenreiter/networks_rot0", Opie::Core::OResource::SmallIcon ) ); |
47 | //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) ); | 47 | //ani2 = new QPixmap( Opie::Core::OResource::loadPixmap( "wellenreiter/networks_rot90", Opie::Core::OResource::SmallIcon ) ); |
48 | //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) ); | 48 | //ani3 = new QPixmap( Opie::Core::OResource::loadPixmap( "wellenreiter/networks_rot180", Opie::Core::OResource::SmallIcon ) ); |
49 | //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) ); | 49 | //ani4 = new QPixmap( Opie::Core::OResource::loadPixmap( "wellenreiter/networks_rot270", Opie::Core::OResource::SmallIcon ) ); |
50 | 50 | ||
51 | if ( !name ) | 51 | if ( !name ) |
52 | setName( "WellenreiterBase" ); | 52 | setName( "WellenreiterBase" ); |
53 | resize( 191, 294 ); | 53 | resize( 191, 294 ); |
54 | #ifdef QWS | 54 | #ifdef QWS |
55 | setCaption( tr( "Wellenreiter/Opie" ) ); | 55 | setCaption( tr( "Wellenreiter/Opie" ) ); |
56 | #else | 56 | #else |
57 | setCaption( tr( "Wellenreiter/X11" ) ); | 57 | setCaption( tr( "Wellenreiter/X11" ) ); |
58 | #endif | 58 | #endif |
59 | WellenreiterBaseLayout = new QVBoxLayout( this ); | 59 | WellenreiterBaseLayout = new QVBoxLayout( this ); |
60 | WellenreiterBaseLayout->setSpacing( 2 ); | 60 | WellenreiterBaseLayout->setSpacing( 2 ); |
61 | WellenreiterBaseLayout->setMargin( 0 ); | 61 | WellenreiterBaseLayout->setMargin( 0 ); |
62 | #ifdef QWS | 62 | #ifdef QWS |
63 | TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); | 63 | TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); |
64 | #else | 64 | #else |
65 | TabWidget = new QTabWidget( this, "TabWidget" ); | 65 | TabWidget = new QTabWidget( this, "TabWidget" ); |
66 | #endif | 66 | #endif |
67 | ap = new QWidget( TabWidget, "ap" ); | 67 | ap = new QWidget( TabWidget, "ap" ); |
68 | apLayout = new QVBoxLayout( ap ); | 68 | apLayout = new QVBoxLayout( ap ); |
69 | apLayout->setSpacing( 2 ); | 69 | apLayout->setSpacing( 2 ); |
70 | apLayout->setMargin( 2 ); | 70 | apLayout->setMargin( 2 ); |
71 | 71 | ||
72 | //--------- NETVIEW TAB -------------- | 72 | //--------- NETVIEW TAB -------------- |
73 | 73 | ||
74 | netview = new MScanListView( ap ); | 74 | netview = new MScanListView( ap ); |
75 | apLayout->addWidget( netview ); | 75 | apLayout->addWidget( netview ); |
76 | 76 | ||
77 | //--------- GRAPH TAB -------------- | 77 | //--------- GRAPH TAB -------------- |
78 | 78 | ||
79 | graphwindow = new MGraphWindow( TabWidget, "Graph" ); | 79 | graphwindow = new MGraphWindow( TabWidget, "Graph" ); |
80 | 80 | ||
81 | //--------- LOG TAB -------------- | 81 | //--------- LOG TAB -------------- |
82 | 82 | ||
83 | logwindow = new MLogWindow( TabWidget, "Log" ); | 83 | logwindow = new MLogWindow( TabWidget, "Log" ); |
84 | 84 | ||
85 | //--------- HEX TAB -------------- | 85 | //--------- HEX TAB -------------- |
86 | 86 | ||
87 | hexwindow = new PacketView( TabWidget, "Hex" ); | 87 | hexwindow = new PacketView( TabWidget, "Hex" ); |
88 | 88 | ||
89 | //--------- STAT TAB -------------- | 89 | //--------- STAT TAB -------------- |
90 | 90 | ||
91 | statwindow = new MStatWindow( TabWidget, "Stat" ); | 91 | statwindow = new MStatWindow( TabWidget, "Stat" ); |
92 | 92 | ||
93 | //--------- ABOUT TAB -------------- | 93 | //--------- ABOUT TAB -------------- |
94 | 94 | ||
95 | about = new QWidget( TabWidget, "about" ); | 95 | about = new QWidget( TabWidget, "about" ); |
96 | aboutLayout = new QGridLayout( about ); | 96 | aboutLayout = new QGridLayout( about ); |
97 | aboutLayout->setSpacing( 6 ); | 97 | aboutLayout->setSpacing( 6 ); |
98 | aboutLayout->setMargin( 11 ); | 98 | aboutLayout->setMargin( 11 ); |
99 | 99 | ||
100 | PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); | 100 | PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); |
101 | PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); | 101 | PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); |
102 | PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); | 102 | PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); |
103 | PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); | 103 | PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); |
104 | PixmapLabel1_3_2->setLineWidth( 2 ); | 104 | PixmapLabel1_3_2->setLineWidth( 2 ); |
105 | PixmapLabel1_3_2->setMargin( 0 ); | 105 | PixmapLabel1_3_2->setMargin( 0 ); |
106 | PixmapLabel1_3_2->setMidLineWidth( 0 ); | 106 | PixmapLabel1_3_2->setMidLineWidth( 0 ); |
107 | 107 | ||
108 | QPixmap logo = Resource::loadPixmap( "wellenreiter/logo" ); | 108 | QPixmap logo = Opie::Core::OResource::loadPixmap( "wellenreiter/logo" ); |
109 | QPainter draw( &logo ); | 109 | QPainter draw( &logo ); |
110 | draw.setPen( Qt::black ); | 110 | draw.setPen( Qt::black ); |
111 | draw.setFont( QFont( "Fixed", 8 ) ); | 111 | draw.setFont( QFont( "Fixed", 8 ) ); |
112 | draw.drawText( 5, 10, WELLENREITER_VERSION ); | 112 | draw.drawText( 5, 10, WELLENREITER_VERSION ); |
113 | 113 | ||
114 | PixmapLabel1_3_2->setPixmap( logo ); | 114 | PixmapLabel1_3_2->setPixmap( logo ); |
115 | PixmapLabel1_3_2->setScaledContents( TRUE ); | 115 | PixmapLabel1_3_2->setScaledContents( TRUE ); |
116 | PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); | 116 | PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); |
117 | 117 | ||
118 | aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); | 118 | aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); |
119 | 119 | ||
120 | TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); | 120 | TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); |
121 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); | 121 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); |
122 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); | 122 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); |
123 | TextLabel1_4_2_font.setPointSize( 10 ); | 123 | TextLabel1_4_2_font.setPointSize( 10 ); |
124 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); | 124 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); |
125 | TextLabel1_4_2->setText( | 125 | TextLabel1_4_2->setText( |
126 | "<p align=center>" | 126 | "<p align=center>" |
127 | "<hr>" | 127 | "<hr>" |
128 | "<b>(C) Michael 'Mickey' Lauer</b><br>" | 128 | "<b>(C) Michael 'Mickey' Lauer</b><br>" |
129 | "<hr>" | 129 | "<hr>" |
130 | "mickey@Vanille.de<br>" | 130 | "mickey@Vanille.de<br>" |
131 | "www.Vanille.de/projects/wellenreiter.html<br>" | 131 | "www.Vanille.de/projects/wellenreiter.html<br>" |
132 | "www.wellenreiter.net" | 132 | "www.wellenreiter.net" |
133 | "</p>" ); | 133 | "</p>" ); |
134 | TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); | 134 | TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); |
135 | 135 | ||
136 | aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); | 136 | aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); |
137 | 137 | ||
138 | #ifdef QWS | 138 | #ifdef QWS |
139 | TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); | 139 | TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); |
140 | TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); | 140 | TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); |
141 | TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); | 141 | TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); |
142 | TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); | 142 | TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); |
143 | TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); | 143 | TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); |
144 | TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); | 144 | TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); |
145 | #else | 145 | #else |
146 | TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); | 146 | TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); |
147 | TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); | 147 | TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); |
148 | TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); | 148 | TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); |
149 | TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); | 149 | TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); |
150 | TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); | 150 | TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); |
151 | TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); | 151 | TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); |
152 | #endif | 152 | #endif |
153 | WellenreiterBaseLayout->addWidget( TabWidget ); | 153 | WellenreiterBaseLayout->addWidget( TabWidget ); |
154 | 154 | ||
155 | #ifdef QWS | 155 | #ifdef QWS |
156 | TabWidget->setCurrentTab( tr( "Nets" ) ); | 156 | TabWidget->setCurrentTab( tr( "Nets" ) ); |
157 | #endif | 157 | #endif |
158 | 158 | ||
159 | connect(TabWidget, SIGNAL(currentChanged(QWidget*)), | 159 | connect(TabWidget, SIGNAL(currentChanged(QWidget*)), |
160 | this, SLOT(slotTabChanged(QWidget*))); | 160 | this, SLOT(slotTabChanged(QWidget*))); |
161 | } | 161 | } |
162 | 162 | ||
163 | /* | 163 | /* |
164 | * Destroys the object and frees any allocated resources | 164 | * Destroys the object and frees any allocated resources |
165 | */ | 165 | */ |
166 | WellenreiterBase::~WellenreiterBase() | 166 | WellenreiterBase::~WellenreiterBase() |
167 | { | 167 | { |
168 | // no need to delete child widgets, Qt does it all for us | 168 | // no need to delete child widgets, Qt does it all for us |
169 | } | 169 | } |
170 | 170 | ||
171 | /* | 171 | /* |
172 | * Main event handler. Reimplemented to handle application | 172 | * Main event handler. Reimplemented to handle application |
173 | * font changes | 173 | * font changes |
174 | */ | 174 | */ |
175 | bool WellenreiterBase::event( QEvent* ev ) | 175 | bool WellenreiterBase::event( QEvent* ev ) |
176 | { | 176 | { |
177 | bool ret = QWidget::event( ev ); | 177 | bool ret = QWidget::event( ev ); |
178 | if ( ev->type() == QEvent::ApplicationFontChange ) { | 178 | if ( ev->type() == QEvent::ApplicationFontChange ) { |
179 | //QFont Log_2_font( Log_2->font() ); | 179 | //QFont Log_2_font( Log_2->font() ); |
180 | //Log_2_font.setFamily( "adobe-courier" ); | 180 | //Log_2_font.setFamily( "adobe-courier" ); |
181 | //Log_2_font.setPointSize( 8 ); | 181 | //Log_2_font.setPointSize( 8 ); |
182 | //Log_2->setFont( Log_2_font ); | 182 | //Log_2->setFont( Log_2_font ); |
183 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); | 183 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); |
184 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); | 184 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); |
185 | TextLabel1_4_2_font.setPointSize( 10 ); | 185 | TextLabel1_4_2_font.setPointSize( 10 ); |
186 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); | 186 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); |
187 | } | 187 | } |
188 | return ret; | 188 | return ret; |
189 | } | 189 | } |
190 | 190 | ||