author | wimpie <wimpie> | 2005-01-06 17:59:54 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-06 17:59:54 (UTC) |
commit | 006091cfc3bb54286fd4dd74773fe5c09048077b (patch) (unidiff) | |
tree | 23075790a300998a674dafe104fdc05bb6d19789 /noncore/settings/networksettings2/opietooth2/Opietooth.cpp | |
parent | fab28788f055b998803df9a6e8cfe2a4f9122351 (diff) | |
download | opie-006091cfc3bb54286fd4dd74773fe5c09048077b.zip opie-006091cfc3bb54286fd4dd74773fe5c09048077b.tar.gz opie-006091cfc3bb54286fd4dd74773fe5c09048077b.tar.bz2 |
Forgot networktemplate files
HCIdump seems to work -> bt sniffing is possible
Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/Opietooth.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/Opietooth.cpp | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index 5a890da..b14cc2f 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp | |||
@@ -12,25 +12,27 @@ using namespace Opie::Ui; | |||
12 | #include <qdialog.h> | 12 | #include <qdialog.h> |
13 | #include <qdir.h> | 13 | #include <qdir.h> |
14 | #include <qfile.h> | 14 | #include <qfile.h> |
15 | #include <qgroupbox.h> | 15 | #include <qgroupbox.h> |
16 | #include <qheader.h> | 16 | #include <qheader.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qlayout.h> | 18 | #include <qlayout.h> |
19 | #include <qlistbox.h> | 19 | #include <qlistbox.h> |
20 | #include <qlistview.h> | 20 | #include <qlistview.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qprogressbar.h> | 22 | #include <qprogressbar.h> |
23 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qscrollbar.h> | ||
24 | #include <qtextstream.h> | 25 | #include <qtextstream.h> |
26 | #include <qtextview.h> | ||
25 | 27 | ||
26 | #include <Opietooth.h> | 28 | #include <Opietooth.h> |
27 | #include <OTDriver.h> | 29 | #include <OTDriver.h> |
28 | #include <OTPeer.h> | 30 | #include <OTPeer.h> |
29 | #include <OTGateway.h> | 31 | #include <OTGateway.h> |
30 | #include <OTSDPAttribute.h> | 32 | #include <OTSDPAttribute.h> |
31 | #include <OTSDPService.h> | 33 | #include <OTSDPService.h> |
32 | #include <OTInquiry.h> | 34 | #include <OTInquiry.h> |
33 | 35 | ||
34 | #include <system.h> | 36 | #include <system.h> |
35 | 37 | ||
36 | using namespace Opietooth2; | 38 | using namespace Opietooth2; |
@@ -111,41 +113,45 @@ private : | |||
111 | }; | 113 | }; |
112 | 114 | ||
113 | // | 115 | // |
114 | // | 116 | // |
115 | // | 117 | // |
116 | // | 118 | // |
117 | // | 119 | // |
118 | 120 | ||
119 | OTSniffing::OTSniffing( QWidget * parent ) : OTSniffGUI( parent ) { | 121 | OTSniffing::OTSniffing( QWidget * parent ) : OTSniffGUI( parent ) { |
120 | 122 | ||
121 | OT = OTGateway::getOTGateway(); | 123 | OT = OTGateway::getOTGateway(); |
122 | HciDump = 0; | 124 | HciDump = 0; |
123 | Sys = new System(); | ||
124 | } | 125 | } |
125 | 126 | ||
126 | OTSniffing::~OTSniffing() { | 127 | OTSniffing::~OTSniffing() { |
127 | printf( "CLOSE \n" ); | 128 | SLOT_Trace( 0 ); |
128 | if ( HciDump ) { | ||
129 | HciDump->process().kill(); | ||
130 | delete HciDump; | ||
131 | } | ||
132 | delete Sys; | ||
133 | } | 129 | } |
134 | 130 | ||
135 | void OTSniffing::SLOT_Trace( bool ) { | 131 | void OTSniffing::SLOT_Trace( bool Run ) { |
132 | |||
133 | if( ! Run ) { | ||
134 | if ( HciDump ) { | ||
135 | HciDump->process().kill(); | ||
136 | delete HciDump; | ||
137 | } | ||
138 | HciDump = 0; | ||
139 | return; | ||
140 | } | ||
141 | |||
136 | HciDump = new MyProcess(); | 142 | HciDump = new MyProcess(); |
137 | QStringList SL; | 143 | QStringList SL; |
138 | 144 | ||
139 | SL << "hcidump"; | 145 | SL << "/usr/sbin/hcidump"; |
140 | switch( DataFormat_CB->currentItem() ) { | 146 | switch( DataFormat_CB->currentItem() ) { |
141 | case 0 : // Hex | 147 | case 0 : // Hex |
142 | SL << "-x"; | 148 | SL << "-x"; |
143 | break; | 149 | break; |
144 | case 1 : // Ascii | 150 | case 1 : // Ascii |
145 | SL << "-a"; | 151 | SL << "-a"; |
146 | break; | 152 | break; |
147 | case 2 : // both | 153 | case 2 : // both |
148 | SL << "-X"; | 154 | SL << "-X"; |
149 | break; | 155 | break; |
150 | } | 156 | } |
151 | 157 | ||
@@ -153,40 +159,48 @@ void OTSniffing::SLOT_Trace( bool ) { | |||
153 | SL << OT->scanWith()->devname(); | 159 | SL << OT->scanWith()->devname(); |
154 | 160 | ||
155 | connect( HciDump, | 161 | connect( HciDump, |
156 | SIGNAL( stdoutLine( const QString & ) ), | 162 | SIGNAL( stdoutLine( const QString & ) ), |
157 | this, | 163 | this, |
158 | SLOT( SLOT_Show( const QString & ) ) ); | 164 | SLOT( SLOT_Show( const QString & ) ) ); |
159 | 165 | ||
160 | connect( HciDump, | 166 | connect( HciDump, |
161 | SIGNAL(processExited(MyProcess*) ), | 167 | SIGNAL(processExited(MyProcess*) ), |
162 | this, | 168 | this, |
163 | SLOT( SLOT_ProcessExited(MyProcess*) ) ); | 169 | SLOT( SLOT_ProcessExited(MyProcess*) ) ); |
164 | 170 | ||
165 | if( ! Sys->runAsRoot( SL, HciDump ) ) { | 171 | HciDump->process() << SL; |
172 | |||
173 | if( ! HciDump->process().start( OProcess::DontCare, | ||
174 | OProcess::AllOutput ) | ||
175 | ) { | ||
166 | QMessageBox::warning(0, | 176 | QMessageBox::warning(0, |
167 | tr("Run hcidump"), | 177 | tr("Run hcidump"), |
168 | tr("Cannot start %1").arg(SL.join(" ")) | 178 | tr("Cannot start %1").arg(SL.join(" ")) |
169 | ); | 179 | ); |
170 | delete HciDump; | 180 | delete HciDump; |
171 | HciDump = 0; | 181 | HciDump = 0; |
172 | } | 182 | } |
173 | 183 | ||
174 | } | 184 | } |
175 | 185 | ||
176 | void OTSniffing::SLOT_Show( const QString & S ) { | 186 | void OTSniffing::SLOT_Show( const QString & S ) { |
177 | printf( "%s\n", S.latin1() ); | 187 | printf( "%s\n", S.latin1() ); |
178 | Output_LB->insertItem( S ); | 188 | Output_TV->setText( Output_TV->text() + S + "\n" ); |
179 | Output_LB->setCurrentItem( Output_LB->count()-1 ); | 189 | |
180 | Output_LB->ensureCurrentVisible(); | 190 | QScrollBar *scroll = Output_TV->verticalScrollBar(); |
191 | scroll->setValue(scroll->maxValue()); | ||
192 | //Output_LB->insertItem( S ); | ||
193 | //Output_LB->setCurrentItem( Output_LB->count()-1 ); | ||
194 | //Output_LB->ensureCurrentVisible(); | ||
181 | } | 195 | } |
182 | 196 | ||
183 | void OTSniffing::SLOT_ProcessExited( MyProcess * ) { | 197 | void OTSniffing::SLOT_ProcessExited( MyProcess * ) { |
184 | printf( "Exited\n" ); | 198 | printf( "Exited\n" ); |
185 | delete HciDump; | 199 | delete HciDump; |
186 | HciDump = 0; | 200 | HciDump = 0; |
187 | } | 201 | } |
188 | 202 | ||
189 | void OTSniffing::SLOT_Save( void ) { | 203 | void OTSniffing::SLOT_Save( void ) { |
190 | QString S = OFileDialog::getSaveFileName( | 204 | QString S = OFileDialog::getSaveFileName( |
191 | OFileSelector::Extended, | 205 | OFileSelector::Extended, |
192 | QDir::home().path(), | 206 | QDir::home().path(), |
@@ -219,30 +233,32 @@ void OTSniffing::SLOT_Load( void ) { | |||
219 | if( ! S.isEmpty() ) { | 233 | if( ! S.isEmpty() ) { |
220 | QFile F( S ); | 234 | QFile F( S ); |
221 | if( ! F.open( IO_ReadOnly ) ) { | 235 | if( ! F.open( IO_ReadOnly ) ) { |
222 | QMessageBox::warning(0, | 236 | QMessageBox::warning(0, |
223 | tr("Save log"), | 237 | tr("Save log"), |
224 | tr("Cannot open %1").arg(S) | 238 | tr("Cannot open %1").arg(S) |
225 | ); | 239 | ); |
226 | return; | 240 | return; |
227 | } | 241 | } |
228 | QTextStream TS ( &F ); | 242 | QTextStream TS ( &F ); |
229 | SLOT_ClearLog(); | 243 | SLOT_ClearLog(); |
230 | S = TS.read(); | 244 | S = TS.read(); |
231 | Output_LB->insertStringList( QStringList::split( "\n", S ) ); | 245 | // Output_LB->insertStringList( QStringList::split( "\n", S ) ); |
246 | Output_TV->setText( S ); | ||
232 | } | 247 | } |
233 | } | 248 | } |
234 | 249 | ||
235 | void OTSniffing::SLOT_ClearLog( void ) { | 250 | void OTSniffing::SLOT_ClearLog( void ) { |
236 | Output_LB->clear(); | 251 | // Output_LB->clear(); |
252 | Output_TV->setText( "" ); | ||
237 | } | 253 | } |
238 | 254 | ||
239 | // | 255 | // |
240 | // | 256 | // |
241 | // | 257 | // |
242 | // | 258 | // |
243 | // | 259 | // |
244 | 260 | ||
245 | OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : | 261 | OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : |
246 | OTPairingGUI( parent ) { | 262 | OTPairingGUI( parent ) { |
247 | 263 | ||
248 | OT = OTGateway::getOTGateway(); | 264 | OT = OTGateway::getOTGateway(); |