summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-06 17:59:54 (UTC)
committer wimpie <wimpie>2005-01-06 17:59:54 (UTC)
commit006091cfc3bb54286fd4dd74773fe5c09048077b (patch) (unidiff)
tree23075790a300998a674dafe104fdc05bb6d19789
parentfab28788f055b998803df9a6e8cfe2a4f9122351 (diff)
downloadopie-006091cfc3bb54286fd4dd74773fe5c09048077b.zip
opie-006091cfc3bb54286fd4dd74773fe5c09048077b.tar.gz
opie-006091cfc3bb54286fd4dd74773fe5c09048077b.tar.bz2
Forgot networktemplate files
HCIdump seems to work -> bt sniffing is possible
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp7
-rw-r--r--noncore/settings/networksettings2/opie-networksettings2.control2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTSniffGUI.ui15
-rw-r--r--noncore/settings/networksettings2/opietooth2/Opietooth.cpp46
-rw-r--r--noncore/settings/networksettings2/opietooth2/Opietooth.h2
5 files changed, 43 insertions, 29 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index 9512579..e642c08 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -1,586 +1,587 @@
1#include <sys/types.h> 1#include <sys/types.h>
2#include <sys/wait.h> 2#include <sys/wait.h>
3 3
4#include <net/if.h> 4#include <net/if.h>
5#include <net/if_arp.h> 5#include <net/if_arp.h>
6#include <netinet/in.h> 6#include <netinet/in.h>
7#include <arpa/inet.h> 7#include <arpa/inet.h>
8#include <sys/ioctl.h> 8#include <sys/ioctl.h>
9#include <sys/socket.h> 9#include <sys/socket.h>
10#include <stdlib.h> 10#include <stdlib.h>
11#include <stdio.h> 11#include <stdio.h>
12#include <fcntl.h> 12#include <fcntl.h>
13#include <errno.h> 13#include <errno.h>
14#include <unistd.h> 14#include <unistd.h>
15 15
16#include <opie2/oprocess.h> 16#include <opie2/oprocess.h>
17 17
18#include <qdir.h> 18#include <qdir.h>
19#include <qregexp.h> 19#include <qregexp.h>
20#include <qstringlist.h> 20#include <qstringlist.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qtextstream.h> 22#include <qtextstream.h>
23#include <qapplication.h> 23#include <qapplication.h>
24 24
25#include "resources.h" 25#include "resources.h"
26#include "system.h" 26#include "system.h"
27 27
28#define PROCNETDEV "/proc/net/dev" 28#define PROCNETDEV "/proc/net/dev"
29 29
30#ifndef ARPHRD_IEEE80211 30#ifndef ARPHRD_IEEE80211
31#define ARPHRD_IEEE80211 801 31#define ARPHRD_IEEE80211 801
32#endif 32#endif
33 33
34static char Dig2Hex[] = { 34static char Dig2Hex[] = {
35 '0', '1', '2', '3', 35 '0', '1', '2', '3',
36 '4', '5', '6', '7', 36 '4', '5', '6', '7',
37 '8', '9', 'A', 'B', 37 '8', '9', 'A', 'B',
38 'C', 'D', 'E', 'F' 38 'C', 'D', 'E', 'F'
39}; 39};
40 40
41// get HIGH nibble of byte 41// get HIGH nibble of byte
42#define HN(x) Dig2Hex[(((x)&0xf0)>>4)] 42#define HN(x) Dig2Hex[(((x)&0xf0)>>4)]
43// get LOW nibble of byte 43// get LOW nibble of byte
44#define LN(x) Dig2Hex[((x)&0x0f)] 44#define LN(x) Dig2Hex[((x)&0x0f)]
45 45
46System::System( void ) : QObject(), ProbedInterfaces() { 46System::System( void ) : QObject(), ProbedInterfaces() {
47 ProcDevNet = 0;
47} 48}
48 49
49System::~System( void ) { 50System::~System( void ) {
50 if( ProcDevNet ) 51 if( ProcDevNet )
51 delete ProcDevNet; 52 delete ProcDevNet;
52} 53}
53 54
54QDict<InterfaceInfo> & System::interfaces( void ) { 55QDict<InterfaceInfo> & System::interfaces( void ) {
55 if( ProbedInterfaces.count() == 0 ) { 56 if( ProbedInterfaces.count() == 0 ) {
56 probeInterfaces(); 57 probeInterfaces();
57 } 58 }
58 return ProbedInterfaces; 59 return ProbedInterfaces;
59} 60}
60 61
61int System::runAsRoot( QStringList & S, MyProcess * Prc ) { 62int System::runAsRoot( QStringList & S, MyProcess * Prc ) {
62 char * usr = getenv("USER"); 63 char * usr = getenv("USER");
63 64
64 if( S.count() == 0 ) { 65 if( S.count() == 0 ) {
65 // loophole to start shell 66 // loophole to start shell
66 return 8888; 67 return 8888;
67 } 68 }
68 if( usr == 0 || strcmp( usr, "root" ) ) { 69 if( usr == 0 || strcmp( usr, "root" ) ) {
69 // unknown or non-root user -> use SUDO 70 // unknown or non-root user -> use SUDO
70 S.prepend( "sudo" ); 71 S.prepend( "sudo" );
71 } 72 }
72 73
73 if( getenv( "NS2TESTMODE" ) ) { 74 if( getenv( "NS2TESTMODE" ) ) {
74 owarn << "TESTMODE !!! execute " 75 owarn << "TESTMODE !!! execute "
75 << S.join( " ") 76 << S.join( " ")
76 << oendl; 77 << oendl;
77 } else { 78 } else {
78 MyProcess * P; 79 MyProcess * P;
79 80
80 if( Prc ) { 81 if( Prc ) {
81 P = Prc; 82 P = Prc;
82 } else { 83 } else {
83 P = new MyProcess(); 84 P = new MyProcess();
84 emit processEvent( tr("Command : ") + S.join( " " ) ); 85 emit processEvent( tr("Command : ") + S.join( " " ) );
85 86
86 connect( P, 87 connect( P,
87 SIGNAL( stdoutLine( const QString & ) ), 88 SIGNAL( stdoutLine( const QString & ) ),
88 this, 89 this,
89 SIGNAL( stdoutLine( const QString & ) ) ); 90 SIGNAL( stdoutLine( const QString & ) ) );
90 91
91 connect( P, 92 connect( P,
92 SIGNAL( stderrLine( const QString & ) ), 93 SIGNAL( stderrLine( const QString & ) ),
93 this, 94 this,
94 SIGNAL( stderrLine( const QString & ) ) ); 95 SIGNAL( stderrLine( const QString & ) ) );
95 96
96 connect( P, 97 connect( P,
97 SIGNAL(processExited(MyProcess*) ), 98 SIGNAL(processExited(MyProcess*) ),
98 this, SLOT 99 this, SLOT
99 (SLOT_ProcessExited(MyProcess*) ) ); 100 (SLOT_ProcessExited(MyProcess*) ) );
100 } 101 }
101 102
102 P->process() << S; 103 P->process() << S;
103 104
104 Log(("Executing %s\n", S.join( " " ).latin1() )); 105 Log(("Executing %s\n", S.join( " " ).latin1() ));
105 106
106 if( ! P->process().start( OProcess::DontCare, 107 if( ! P->process().start( OProcess::DontCare,
107 OProcess::AllOutput ) ) { 108 OProcess::AllOutput ) ) {
108 owarn << "Error starting " << S << oendl; 109 owarn << "Error starting " << S << oendl;
109 if( ! Prc ) 110 if( ! Prc )
110 delete P; 111 delete P;
111 // error starting app 112 // error starting app
112 return 1; 113 return 0;
113 } 114 }
114 owarn << "Started " << S << oendl; 115 owarn << "Started " << S << oendl;
115 } 116 }
116 117
117 // all is fine 118 // all is fine
118 return 0; 119 return 1;
119} 120}
120 121
121int System::execAsUser( QStringList & SL ) { 122int System::execAsUser( QStringList & SL ) {
122 MyProcess * P = new MyProcess(); 123 MyProcess * P = new MyProcess();
123 CurrentQPEUser CU = NSResources->currentUser(); 124 CurrentQPEUser CU = NSResources->currentUser();
124 char * usr = getenv("USER"); 125 char * usr = getenv("USER");
125 126
126 if( strcmp( usr, "root" ) == 0 ) { 127 if( strcmp( usr, "root" ) == 0 ) {
127 // find user running qpe 128 // find user running qpe
128 if( CU.UserName.isEmpty() ) { 129 if( CU.UserName.isEmpty() ) {
129 // if we come here, the exec was not successfull 130 // if we come here, the exec was not successfull
130 Log(("User not known \n" )); 131 Log(("User not known \n" ));
131 return 0; 132 return 0;
132 } 133 }
133 } 134 }
134 135
135 // now we are ready to exec the requested command 136 // now we are ready to exec the requested command
136 setuid( CU.Uid ); 137 setuid( CU.Uid );
137 setgid( CU.Gid ); 138 setgid( CU.Gid );
138 139
139 for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) { 140 for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) {
140 QString X; 141 QString X;
141 QStringList SL; 142 QStringList SL;
142 X = CU.EnvList[i]; 143 X = CU.EnvList[i];
143 SL = QStringList::split( "=", X ); 144 SL = QStringList::split( "=", X );
144 P->process().setEnvironment( SL[0], SL[1] ); 145 P->process().setEnvironment( SL[0], SL[1] );
145 } 146 }
146 147
147 P->process() << SL; 148 P->process() << SL;
148 149
149 emit processEvent( tr("Command : ") + SL.join( " " ) ); 150 emit processEvent( tr("Command : ") + SL.join( " " ) );
150 151
151 Log(("Executing as user %s : %s\n", 152 Log(("Executing as user %s : %s\n",
152 CU.UserName.latin1(), 153 CU.UserName.latin1(),
153 SL.join( " " ).latin1() )); 154 SL.join( " " ).latin1() ));
154 155
155 int rv = ( P->process().start( OProcess::DontCare, 156 int rv = ( P->process().start( OProcess::DontCare,
156 OProcess::NoCommunication ) ); 157 OProcess::NoCommunication ) );
157 delete P; 158 delete P;
158 159
159 if( rv ) { 160 if( rv ) {
160 // if we come here, the exec was not successfull 161 // if we come here, the exec was not successfull
161 Log(("Could not exec : %d\n", errno )); 162 Log(("Could not exec : %d\n", errno ));
162 } 163 }
163 164
164 return rv; 165 return ! rv;
165} 166}
166 167
167void System::SLOT_ProcessExited( MyProcess * P ) { 168void System::SLOT_ProcessExited( MyProcess * P ) {
168 QString R; 169 QString R;
169 170
170 for( QValueListConstIterator<QCString> it = P->process().args().begin(); 171 for( QValueListConstIterator<QCString> it = P->process().args().begin();
171 it != P->process().args().end(); 172 it != P->process().args().end();
172 ++it ) { 173 ++it ) {
173 R += (*it); 174 R += (*it);
174 R += " "; 175 R += " ";
175 } 176 }
176 177
177 R += "Returned with " + QString().setNum( P->process().exitStatus() ); 178 R += "Returned with " + QString().setNum( P->process().exitStatus() );
178 emit processEvent( R ); 179 emit processEvent( R );
179 delete P; 180 delete P;
180} 181}
181 182
182void System::refreshStatistics( InterfaceInfo & I ) { 183void System::refreshStatistics( InterfaceInfo & I ) {
183 if( ! ProcDevNet ) { 184 if( ! ProcDevNet ) {
184 return; 185 return;
185 } 186 }
186 // cannot seek on dev 187 // cannot seek on dev
187 ProcDevNet->close(); 188 ProcDevNet->close();
188 ProcDevNet->open( IO_ReadOnly ); 189 ProcDevNet->open( IO_ReadOnly );
189 190
190 QString line; 191 QString line;
191 QTextStream procTs(ProcDevNet); 192 QTextStream procTs(ProcDevNet);
192 QStringList SL; 193 QStringList SL;
193 int loc = -1; 194 int loc = -1;
194 int version; 195 int version;
195 196
196 procTs.readLine(); 197 procTs.readLine();
197 line = procTs.readLine(); 198 line = procTs.readLine();
198 // get version 199 // get version
199 if( line.find("compressed") ) 200 if( line.find("compressed") )
200 version = 3; 201 version = 3;
201 else if( line.find( "bytes" ) ) 202 else if( line.find( "bytes" ) )
202 version = 2; 203 version = 2;
203 else 204 else
204 version = 1; 205 version = 1;
205 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { 206 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
206 if( (loc = line.find(":") ) == -1) { 207 if( (loc = line.find(":") ) == -1) {
207 continue; 208 continue;
208 } 209 }
209 210
210 if( I.Name != line.left(loc) ) 211 if( I.Name != line.left(loc) )
211 continue; 212 continue;
212 213
213 // tokenize 214 // tokenize
214 SL = QStringList::split( ' ', line, FALSE ); 215 SL = QStringList::split( ' ', line, FALSE );
215 216
216 // update data 217 // update data
217 switch( version ) { 218 switch( version ) {
218 case 1 : 219 case 1 :
219 I.RcvBytes = SL[1]; 220 I.RcvBytes = SL[1];
220 I.RcvErrors = SL[3]; 221 I.RcvErrors = SL[3];
221 I.RcvDropped = SL[4]; 222 I.RcvDropped = SL[4];
222 I.SndBytes = SL[6]; 223 I.SndBytes = SL[6];
223 I.SndErrors = SL[8]; 224 I.SndErrors = SL[8];
224 I.SndDropped = SL[9]; 225 I.SndDropped = SL[9];
225 I.Collisions = SL[11]; 226 I.Collisions = SL[11];
226 break; 227 break;
227 case 2 : 228 case 2 :
228 I.RcvBytes = SL[1]; 229 I.RcvBytes = SL[1];
229 I.RcvErrors = SL[3]; 230 I.RcvErrors = SL[3];
230 I.RcvDropped = SL[4]; 231 I.RcvDropped = SL[4];
231 I.SndBytes = SL[7]; 232 I.SndBytes = SL[7];
232 I.SndErrors = SL[9]; 233 I.SndErrors = SL[9];
233 I.SndDropped = SL[10]; 234 I.SndDropped = SL[10];
234 I.Collisions = SL[12]; 235 I.Collisions = SL[12];
235 break; 236 break;
236 case 3 : 237 case 3 :
237 I.RcvBytes = SL[1]; 238 I.RcvBytes = SL[1];
238 I.RcvErrors = SL[3]; 239 I.RcvErrors = SL[3];
239 I.RcvDropped = SL[4]; 240 I.RcvDropped = SL[4];
240 I.SndBytes = SL[9]; 241 I.SndBytes = SL[9];
241 I.SndErrors = SL[11]; 242 I.SndErrors = SL[11];
242 I.SndDropped = SL[12]; 243 I.SndDropped = SL[12];
243 I.Collisions = SL[14]; 244 I.Collisions = SL[14];
244 break; 245 break;
245 } 246 }
246 break; 247 break;
247 } 248 }
248} 249}
249 250
250// 251//
251// THIS UPDATES THE LIST -> INTERFACES ARE NOT DELETED BUT 252// THIS UPDATES THE LIST -> INTERFACES ARE NOT DELETED BUT
252// FLAGGED AS ! 'IsUp' IF NO LONGER PRESENT 253// FLAGGED AS ! 'IsUp' IF NO LONGER PRESENT
253// 254//
254 255
255void System::probeInterfaces( void ) { 256void System::probeInterfaces( void ) {
256 257
257 // probe interfaces 258 // probe interfaces
258 int sockfd; 259 int sockfd;
259 // get list of all interfaces 260 // get list of all interfaces
260 struct ifreq ifrs; 261 struct ifreq ifrs;
261 InterfaceInfo * IFI; 262 InterfaceInfo * IFI;
262 263
263 // flag all as 'down' 264 // flag all as 'down'
264 for( QDictIterator<InterfaceInfo> it( ProbedInterfaces ); 265 for( QDictIterator<InterfaceInfo> it( ProbedInterfaces );
265 it.current(); 266 it.current();
266 ++it ) { 267 ++it ) {
267 it.current()->IsUp = 0; 268 it.current()->IsUp = 0;
268 } 269 }
269 270
270 sockfd = socket(PF_INET, SOCK_DGRAM, 0); 271 sockfd = socket(PF_INET, SOCK_DGRAM, 0);
271 if(sockfd == -1) { 272 if(sockfd == -1) {
272 owarn << "Cannot open INET socket " 273 owarn << "Cannot open INET socket "
273 << errno 274 << errno
274 << " " 275 << " "
275 << strerror( errno ) 276 << strerror( errno )
276 << oendl; 277 << oendl;
277 return; 278 return;
278 } 279 }
279 280
280 // read interfaces from /proc/dev/net 281 // read interfaces from /proc/dev/net
281 // SIOCGIFCONF does not return ALL interfaces ???!? 282 // SIOCGIFCONF does not return ALL interfaces ???!?
282 ProcDevNet = new QFile(PROCNETDEV); 283 ProcDevNet = new QFile(PROCNETDEV);
283 if( ! ProcDevNet->open(IO_ReadOnly) ) { 284 if( ! ProcDevNet->open(IO_ReadOnly) ) {
284 owarn << "Cannot open " 285 owarn << "Cannot open "
285 << PROCNETDEV 286 << PROCNETDEV
286 << " " 287 << " "
287 << errno 288 << errno
288 << " " 289 << " "
289 << strerror( errno ) 290 << strerror( errno )
290 << oendl; 291 << oendl;
291 delete ProcDevNet; 292 delete ProcDevNet;
292 ProcDevNet =0; 293 ProcDevNet =0;
293 ::close( sockfd ); 294 ::close( sockfd );
294 return; 295 return;
295 } 296 }
296 297
297 QString line; 298 QString line;
298 QString NicName; 299 QString NicName;
299 QTextStream procTs(ProcDevNet); 300 QTextStream procTs(ProcDevNet);
300 int loc = -1; 301 int loc = -1;
301 302
302 procTs.readLine(); // eat a line 303 procTs.readLine(); // eat a line
303 procTs.readLine(); // eat a line 304 procTs.readLine(); // eat a line
304 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { 305 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
305 if((loc = line.find(":")) == -1) { 306 if((loc = line.find(":")) == -1) {
306 continue; 307 continue;
307 } 308 }
308 309
309 NicName = line.left(loc); 310 NicName = line.left(loc);
310 311
311 // set name for ioctl 312 // set name for ioctl
312 strcpy( ifrs.ifr_name, NicName.latin1() ); 313 strcpy( ifrs.ifr_name, NicName.latin1() );
313 314
314 if ( ! ( IFI = ProbedInterfaces.find( NicName ) ) ) { 315 if ( ! ( IFI = ProbedInterfaces.find( NicName ) ) ) {
315 // new nic 316 // new nic
316 Log(("New NIC found : %s\n", NicName.latin1())); 317 Log(("New NIC found : %s\n", NicName.latin1()));
317 IFI = new InterfaceInfo; 318 IFI = new InterfaceInfo;
318 IFI->Name = line.left(loc); 319 IFI->Name = line.left(loc);
319 IFI->Collection = 0; 320 IFI->Collection = 0;
320 ProbedInterfaces.insert( IFI->Name, IFI ); 321 ProbedInterfaces.insert( IFI->Name, IFI );
321 322
322 // get dynamic info 323 // get dynamic info
323 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { 324 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) {
324 IFI->IsPointToPoint = ((ifrs.ifr_flags & IFF_POINTOPOINT) == IFF_POINTOPOINT); 325 IFI->IsPointToPoint = ((ifrs.ifr_flags & IFF_POINTOPOINT) == IFF_POINTOPOINT);
325 } else { 326 } else {
326 IFI->IsPointToPoint = 0; 327 IFI->IsPointToPoint = 0;
327 } 328 }
328 329
329 // settings that never change 330 // settings that never change
330 IFI->DstAddress = ""; 331 IFI->DstAddress = "";
331 332
332 if( IFI->IsPointToPoint ) { 333 if( IFI->IsPointToPoint ) {
333 if( ioctl(sockfd, SIOCGIFDSTADDR, &ifrs) >= 0 ) { 334 if( ioctl(sockfd, SIOCGIFDSTADDR, &ifrs) >= 0 ) {
334 IFI->DstAddress = 335 IFI->DstAddress =
335 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_dstaddr)->sin_addr); 336 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_dstaddr)->sin_addr);
336 } 337 }
337 } 338 }
338 339
339 IFI->CardType = 999999; 340 IFI->CardType = 999999;
340 IFI->MACAddress = ""; 341 IFI->MACAddress = "";
341 342
342 if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) { 343 if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) {
343 Log(("Family for NIC %s : %d\n", IFI->Name.latin1(), 344 Log(("Family for NIC %s : %d\n", IFI->Name.latin1(),
344 ifrs.ifr_hwaddr.sa_family )); 345 ifrs.ifr_hwaddr.sa_family ));
345 346
346 IFI->CardType = ifrs.ifr_hwaddr.sa_family; 347 IFI->CardType = ifrs.ifr_hwaddr.sa_family;
347 switch( ifrs.ifr_hwaddr.sa_family ) { 348 switch( ifrs.ifr_hwaddr.sa_family ) {
348 case ARPHRD_ETHER : // regular MAC address 349 case ARPHRD_ETHER : // regular MAC address
349 // valid address -> convert to regular ::: format 350 // valid address -> convert to regular ::: format
350 // length = 6 bytes = 12 DIGITS -> 6 : 351 // length = 6 bytes = 12 DIGITS -> 6 :
351 IFI->MACAddress.sprintf( 352 IFI->MACAddress.sprintf(
352 "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c", 353 "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
353 HN( ifrs.ifr_hwaddr.sa_data[0] ), 354 HN( ifrs.ifr_hwaddr.sa_data[0] ),
354 LN( ifrs.ifr_hwaddr.sa_data[0] ), 355 LN( ifrs.ifr_hwaddr.sa_data[0] ),
355 HN( ifrs.ifr_hwaddr.sa_data[1] ), 356 HN( ifrs.ifr_hwaddr.sa_data[1] ),
356 LN( ifrs.ifr_hwaddr.sa_data[1] ), 357 LN( ifrs.ifr_hwaddr.sa_data[1] ),
357 HN( ifrs.ifr_hwaddr.sa_data[2] ), 358 HN( ifrs.ifr_hwaddr.sa_data[2] ),
358 LN( ifrs.ifr_hwaddr.sa_data[2] ), 359 LN( ifrs.ifr_hwaddr.sa_data[2] ),
359 HN( ifrs.ifr_hwaddr.sa_data[3] ), 360 HN( ifrs.ifr_hwaddr.sa_data[3] ),
360 LN( ifrs.ifr_hwaddr.sa_data[3] ), 361 LN( ifrs.ifr_hwaddr.sa_data[3] ),
361 HN( ifrs.ifr_hwaddr.sa_data[4] ), 362 HN( ifrs.ifr_hwaddr.sa_data[4] ),
362 LN( ifrs.ifr_hwaddr.sa_data[4] ), 363 LN( ifrs.ifr_hwaddr.sa_data[4] ),
363 HN( ifrs.ifr_hwaddr.sa_data[5] ), 364 HN( ifrs.ifr_hwaddr.sa_data[5] ),
364 LN( ifrs.ifr_hwaddr.sa_data[5] ) 365 LN( ifrs.ifr_hwaddr.sa_data[5] )
365 ); 366 );
366 break; 367 break;
367#ifdef ARPHRD_IEEE1394 368#ifdef ARPHRD_IEEE1394
368 case ARPHRD_IEEE1394 : // Firewire Eth address 369 case ARPHRD_IEEE1394 : // Firewire Eth address
369 IFI->MACAddress.sprintf( 370 IFI->MACAddress.sprintf(
370 "%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-00-00", 371 "%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-00-00",
371 HN( ifrs.ifr_hwaddr.sa_data[0] ), 372 HN( ifrs.ifr_hwaddr.sa_data[0] ),
372 LN( ifrs.ifr_hwaddr.sa_data[0] ), 373 LN( ifrs.ifr_hwaddr.sa_data[0] ),
373 HN( ifrs.ifr_hwaddr.sa_data[1] ), 374 HN( ifrs.ifr_hwaddr.sa_data[1] ),
374 LN( ifrs.ifr_hwaddr.sa_data[1] ), 375 LN( ifrs.ifr_hwaddr.sa_data[1] ),
375 HN( ifrs.ifr_hwaddr.sa_data[2] ), 376 HN( ifrs.ifr_hwaddr.sa_data[2] ),
376 LN( ifrs.ifr_hwaddr.sa_data[2] ), 377 LN( ifrs.ifr_hwaddr.sa_data[2] ),
377 HN( ifrs.ifr_hwaddr.sa_data[3] ), 378 HN( ifrs.ifr_hwaddr.sa_data[3] ),
378 LN( ifrs.ifr_hwaddr.sa_data[3] ), 379 LN( ifrs.ifr_hwaddr.sa_data[3] ),
379 HN( ifrs.ifr_hwaddr.sa_data[4] ), 380 HN( ifrs.ifr_hwaddr.sa_data[4] ),
380 LN( ifrs.ifr_hwaddr.sa_data[4] ), 381 LN( ifrs.ifr_hwaddr.sa_data[4] ),
381 HN( ifrs.ifr_hwaddr.sa_data[5] ), 382 HN( ifrs.ifr_hwaddr.sa_data[5] ),
382 LN( ifrs.ifr_hwaddr.sa_data[5] ), 383 LN( ifrs.ifr_hwaddr.sa_data[5] ),
383 HN( ifrs.ifr_hwaddr.sa_data[6] ), 384 HN( ifrs.ifr_hwaddr.sa_data[6] ),
384 LN( ifrs.ifr_hwaddr.sa_data[6] ), 385 LN( ifrs.ifr_hwaddr.sa_data[6] ),
385 HN( ifrs.ifr_hwaddr.sa_data[7] ), 386 HN( ifrs.ifr_hwaddr.sa_data[7] ),
386 LN( ifrs.ifr_hwaddr.sa_data[7] ), 387 LN( ifrs.ifr_hwaddr.sa_data[7] ),
387 HN( ifrs.ifr_hwaddr.sa_data[8] ), 388 HN( ifrs.ifr_hwaddr.sa_data[8] ),
388 LN( ifrs.ifr_hwaddr.sa_data[8] ), 389 LN( ifrs.ifr_hwaddr.sa_data[8] ),
389 HN( ifrs.ifr_hwaddr.sa_data[9] ), 390 HN( ifrs.ifr_hwaddr.sa_data[9] ),
390 LN( ifrs.ifr_hwaddr.sa_data[9] ), 391 LN( ifrs.ifr_hwaddr.sa_data[9] ),
391 HN( ifrs.ifr_hwaddr.sa_data[10] ), 392 HN( ifrs.ifr_hwaddr.sa_data[10] ),
392 LN( ifrs.ifr_hwaddr.sa_data[10] ), 393 LN( ifrs.ifr_hwaddr.sa_data[10] ),
393 HN( ifrs.ifr_hwaddr.sa_data[11] ), 394 HN( ifrs.ifr_hwaddr.sa_data[11] ),
394 LN( ifrs.ifr_hwaddr.sa_data[11] ), 395 LN( ifrs.ifr_hwaddr.sa_data[11] ),
395 HN( ifrs.ifr_hwaddr.sa_data[12] ), 396 HN( ifrs.ifr_hwaddr.sa_data[12] ),
396 LN( ifrs.ifr_hwaddr.sa_data[12] ), 397 LN( ifrs.ifr_hwaddr.sa_data[12] ),
397 HN( ifrs.ifr_hwaddr.sa_data[13] ), 398 HN( ifrs.ifr_hwaddr.sa_data[13] ),
398 LN( ifrs.ifr_hwaddr.sa_data[13] ) 399 LN( ifrs.ifr_hwaddr.sa_data[13] )
399 ); 400 );
400 break; 401 break;
401#endif 402#endif
402 case ARPHRD_PPP : // PPP 403 case ARPHRD_PPP : // PPP
403 break; 404 break;
404 case ARPHRD_IEEE80211 : // WLAN 405 case ARPHRD_IEEE80211 : // WLAN
405 break; 406 break;
406 case ARPHRD_IRDA : // IRDA 407 case ARPHRD_IRDA : // IRDA
407 break; 408 break;
408 } 409 }
409 } 410 }
410 } else // else already probed before -> just update 411 } else // else already probed before -> just update
411 Log(("Redetected NIC %s\n", NicName.latin1())); 412 Log(("Redetected NIC %s\n", NicName.latin1()));
412 413
413 // get dynamic info 414 // get dynamic info
414 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { 415 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) {
415 IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP); 416 IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP);
416 IFI->HasMulticast = ((ifrs.ifr_flags & IFF_MULTICAST) == IFF_MULTICAST); 417 IFI->HasMulticast = ((ifrs.ifr_flags & IFF_MULTICAST) == IFF_MULTICAST);
417 } else { 418 } else {
418 IFI->IsUp = 0; 419 IFI->IsUp = 0;
419 IFI->HasMulticast = 0; 420 IFI->HasMulticast = 0;
420 } 421 }
421 422
422 if( ioctl(sockfd, SIOCGIFADDR, &ifrs) >= 0 ) { 423 if( ioctl(sockfd, SIOCGIFADDR, &ifrs) >= 0 ) {
423 IFI->Address = 424 IFI->Address =
424 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_addr)->sin_addr); 425 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_addr)->sin_addr);
425 } else { 426 } else {
426 IFI->Address = ""; 427 IFI->Address = "";
427 IFI->IsUp = 0; 428 IFI->IsUp = 0;
428 } 429 }
429 if( ioctl(sockfd, SIOCGIFBRDADDR, &ifrs) >= 0 ) { 430 if( ioctl(sockfd, SIOCGIFBRDADDR, &ifrs) >= 0 ) {
430 IFI->BCastAddress = 431 IFI->BCastAddress =
431 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_broadaddr)->sin_addr); 432 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_broadaddr)->sin_addr);
432 } else { 433 } else {
433 IFI->BCastAddress = ""; 434 IFI->BCastAddress = "";
434 } 435 }
435 if( ioctl(sockfd, SIOCGIFNETMASK, &ifrs) >= 0 ) { 436 if( ioctl(sockfd, SIOCGIFNETMASK, &ifrs) >= 0 ) {
436 IFI->Netmask = 437 IFI->Netmask =
437 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr); 438 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr);
438 } else { 439 } else {
439 IFI->Netmask = ""; 440 IFI->Netmask = "";
440 } 441 }
441 Log(("NIC %s UP ? %d\n", NicName.latin1(), IFI->IsUp )); 442 Log(("NIC %s UP ? %d\n", NicName.latin1(), IFI->IsUp ));
442 } 443 }
443 444
444 ::close( sockfd ); 445 ::close( sockfd );
445} 446}
446 447
447InterfaceInfo * System::findInterface( const QString & N ) { 448InterfaceInfo * System::findInterface( const QString & N ) {
448 InterfaceInfo * Run; 449 InterfaceInfo * Run;
449 // has PAN connection UP interface ? 450 // has PAN connection UP interface ?
450 for( QDictIterator<InterfaceInfo> It(ProbedInterfaces); 451 for( QDictIterator<InterfaceInfo> It(ProbedInterfaces);
451 It.current(); 452 It.current();
452 ++It ) { 453 ++It ) {
453 Run = It.current(); 454 Run = It.current();
454 if( N == Run->Name ) { 455 if( N == Run->Name ) {
455 // this PAN connection is up 456 // this PAN connection is up
456 return Run; 457 return Run;
457 } 458 }
458 } 459 }
459 return 0; 460 return 0;
460} 461}
461 462
462#include <stdarg.h> 463#include <stdarg.h>
463static FILE * logf = 0; 464static FILE * logf = 0;
464 465
465void VLog( char * Format, ... ) { 466void VLog( char * Format, ... ) {
466 va_list l; 467 va_list l;
467 468
468 va_start(l, Format ); 469 va_start(l, Format );
469 470
470 if( logf == (FILE *)0 ) { 471 if( logf == (FILE *)0 ) {
471 QString S = getenv("NS2LOG"); 472 QString S = getenv("NS2LOG");
472 if( S == "stderr" ) { 473 if( S == "stderr" ) {
473 logf = stderr; 474 logf = stderr;
474 } else if( S.isEmpty() ) { 475 } else if( S.isEmpty() ) {
475 logf = fopen( "/tmp/ns2log", "a" ); 476 logf = fopen( "/tmp/ns2log", "a" );
476 } else { 477 } else {
477 logf = fopen( S, "a" ); 478 logf = fopen( S, "a" );
478 } 479 }
479 480
480 if( ! logf ) { 481 if( ! logf ) {
481 fprintf( stderr, "Cannot open logfile %s : %d\n", 482 fprintf( stderr, "Cannot open logfile %s : %d\n",
482 S.latin1(), errno ); 483 S.latin1(), errno );
483 logf = (FILE *)1; 484 logf = (FILE *)1;
484 } else { 485 } else {
485 fprintf( logf, "____ OPEN LOGFILE ____\n"); 486 fprintf( logf, "____ OPEN LOGFILE ____\n");
486 } 487 }
487 } 488 }
488 489
489 if( (unsigned long)logf > 1 ) { 490 if( (unsigned long)logf > 1 ) {
490 vfprintf( logf, Format, l ); 491 vfprintf( logf, Format, l );
491 } 492 }
492 va_end( l ); 493 va_end( l );
493 fflush( logf ); 494 fflush( logf );
494 495
495} 496}
496 497
497void LogClose( void ) { 498void LogClose( void ) {
498 if( (long)logf > 1 ) { 499 if( (long)logf > 1 ) {
499 fprintf( logf, "____ CLOSE LOGFILE ____\n"); 500 fprintf( logf, "____ CLOSE LOGFILE ____\n");
500 if( logf != stderr ) { 501 if( logf != stderr ) {
501 fclose( logf ); 502 fclose( logf );
502 } 503 }
503 logf = 0; 504 logf = 0;
504 } 505 }
505} 506}
506 507
507QString removeSpaces( const QString & X ) { 508QString removeSpaces( const QString & X ) {
508 QString Y; 509 QString Y;
509 Y = X.simplifyWhiteSpace(); 510 Y = X.simplifyWhiteSpace();
510 Y.replace( QRegExp(" "), "_" ); 511 Y.replace( QRegExp(" "), "_" );
511 owarn << X << " **" << Y << "**" << oendl; 512 owarn << X << " **" << Y << "**" << oendl;
512 return Y; 513 return Y;
513} 514}
514 515
515// 516//
516// 517//
517// 518//
518// 519//
519// 520//
520 521
521MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() { 522MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() {
522 P = new OProcess(); 523 P = new OProcess();
523 connect( P, 524 connect( P,
524 SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int ) ), 525 SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int ) ),
525 this, 526 this,
526 SLOT( SLOT_Stdout(Opie::Core::OProcess*,char*,int) ) ); 527 SLOT( SLOT_Stdout(Opie::Core::OProcess*,char*,int) ) );
527 528
528 connect( P, 529 connect( P,
529 SIGNAL( receivedStderr(Opie::Core::OProcess*, char*, int ) ), 530 SIGNAL( receivedStderr(Opie::Core::OProcess*, char*, int ) ),
530 this, 531 this,
531 SLOT( SLOT_Stderr(Opie::Core::OProcess*,char*,int) ) ); 532 SLOT( SLOT_Stderr(Opie::Core::OProcess*,char*,int) ) );
532 connect( P, 533 connect( P,
533 SIGNAL( processExited(Opie::Core::OProcess*) ), 534 SIGNAL( processExited(Opie::Core::OProcess*) ),
534 this, 535 this,
535 SLOT( SLOT_ProcessExited(Opie::Core::OProcess*) ) ); 536 SLOT( SLOT_ProcessExited(Opie::Core::OProcess*) ) );
536} 537}
537 538
538MyProcess::~MyProcess() { 539MyProcess::~MyProcess() {
539 delete P; 540 delete P;
540} 541}
541 542
542void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { 543void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) {
543 char * LB = (char *)alloca( len + 1 ); 544 char * LB = (char *)alloca( len + 1 );
544 memcpy( LB, Buf, len ); 545 memcpy( LB, Buf, len );
545 LB[len] = '\0'; 546 LB[len] = '\0';
546 547
547 // now input is zero terminated 548 // now input is zero terminated
548 StdoutBuffer += LB; 549 StdoutBuffer += LB;
549 550
550 owarn << "Received " << len << " bytes on stdout" << oendl; 551 owarn << "Received " << len << " bytes on stdout" << oendl;
551 // see if we have some lines (allow empty lines) 552 // see if we have some lines (allow empty lines)
552 QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE ); 553 QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE );
553 554
554 for( unsigned int i = 0; i < SL.count()-1; i ++ ) { 555 for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
555 Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) ); 556 Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) );
556 emit stdoutLine( SL[i] ); 557 emit stdoutLine( SL[i] );
557 } 558 }
558 559
559 // last line is rest 560 // last line is rest
560 StdoutBuffer = SL[ SL.count()-1 ]; 561 StdoutBuffer = SL[ SL.count()-1 ];
561} 562}
562 563
563void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) { 564void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) {
564 char * LB = (char *)alloca( len + 1 ); 565 char * LB = (char *)alloca( len + 1 );
565 memcpy( LB, Buf, len ); 566 memcpy( LB, Buf, len );
566 LB[len] = '\0'; 567 LB[len] = '\0';
567 568
568 // now input is zero terminated 569 // now input is zero terminated
569 StderrBuffer += LB; 570 StderrBuffer += LB;
570 571
571 owarn << "Received " << len << " bytes on stderr" << oendl; 572 owarn << "Received " << len << " bytes on stderr" << oendl;
572 // see if we have some lines (allow empty lines) 573 // see if we have some lines (allow empty lines)
573 QStringList SL = QStringList::split( "\n", StderrBuffer, TRUE ); 574 QStringList SL = QStringList::split( "\n", StderrBuffer, TRUE );
574 575
575 for( unsigned int i = 0; i < SL.count()-1; i ++ ) { 576 for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
576 Log(( "Stderr : \"%s\"\n", SL[i].latin1() ) ); 577 Log(( "Stderr : \"%s\"\n", SL[i].latin1() ) );
577 emit stderrLine( SL[i] ); 578 emit stderrLine( SL[i] );
578 } 579 }
579 580
580 // last line is rest 581 // last line is rest
581 StderrBuffer = SL[ SL.count()-1 ]; 582 StderrBuffer = SL[ SL.count()-1 ];
582} 583}
583 584
584void MyProcess::SLOT_ProcessExited( Opie::Core::OProcess * ) { 585void MyProcess::SLOT_ProcessExited( Opie::Core::OProcess * ) {
585 emit processExited( this ); 586 emit processExited( this );
586} 587}
diff --git a/noncore/settings/networksettings2/opie-networksettings2.control b/noncore/settings/networksettings2/opie-networksettings2.control
index e4bd29c..874833c 100644
--- a/noncore/settings/networksettings2/opie-networksettings2.control
+++ b/noncore/settings/networksettings2/opie-networksettings2.control
@@ -1,10 +1,10 @@
1Package: opie-networksettings2 1Package: opie-networksettings2
2Files: bin/networksettings2 apps/Settings/networksettings2.desktop pics/networksettings2/*.png lib/libnetworksettings2.so* pics/networksettings2/Devices/*.png 2Files: bin/networksettings2 apps/Settings/networksettings2.desktop pics/networksettings2/*.png lib/libnetworksettings2.so* pics/networksettings2/Devices/*.png etc/NS2templates/* etc/NS2templates/*/*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: wim delvaux <wimpie@handhelds.org> 5Maintainer: wim delvaux <wimpie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, libopietooth2 7Depends: task-opie-minimal, libopietooth2
8Description: Network settings. 8Description: Network settings.
9Replaces: opie-networksetup 9Replaces: opie-networksetup
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings2/opietooth2/OTSniffGUI.ui b/noncore/settings/networksettings2/opietooth2/OTSniffGUI.ui
index 9ef540e..ec0b387 100644
--- a/noncore/settings/networksettings2/opietooth2/OTSniffGUI.ui
+++ b/noncore/settings/networksettings2/opietooth2/OTSniffGUI.ui
@@ -1,261 +1,260 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>OTSniffGUI</class> 2<class>OTSniffGUI</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>OTSniffGUI</cstring> 7 <cstring>OTSniffGUI</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>274</width> 14 <width>274</width>
15 <height>160</height> 15 <height>173</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Bluetooth Sniffing</string> 20 <string>Bluetooth Sniffing</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
25 <vbox> 28 <vbox>
26 <property stdset="1"> 29 <property stdset="1">
27 <name>margin</name> 30 <name>margin</name>
28 <number>3</number> 31 <number>3</number>
29 </property> 32 </property>
30 <property stdset="1"> 33 <property stdset="1">
31 <name>spacing</name> 34 <name>spacing</name>
32 <number>6</number> 35 <number>2</number>
33 </property> 36 </property>
34 <widget> 37 <widget>
35 <class>QLayoutWidget</class> 38 <class>QLayoutWidget</class>
36 <property stdset="1"> 39 <property stdset="1">
37 <name>name</name> 40 <name>name</name>
38 <cstring>Layout3</cstring> 41 <cstring>Layout3</cstring>
39 </property> 42 </property>
40 <hbox> 43 <hbox>
41 <property stdset="1"> 44 <property stdset="1">
42 <name>margin</name> 45 <name>margin</name>
43 <number>0</number> 46 <number>0</number>
44 </property> 47 </property>
45 <property stdset="1"> 48 <property stdset="1">
46 <name>spacing</name> 49 <name>spacing</name>
47 <number>6</number> 50 <number>6</number>
48 </property> 51 </property>
49 <widget> 52 <widget>
50 <class>QLabel</class> 53 <class>QLabel</class>
51 <property stdset="1"> 54 <property stdset="1">
52 <name>name</name> 55 <name>name</name>
53 <cstring>TextLabel1</cstring> 56 <cstring>TextLabel1</cstring>
54 </property> 57 </property>
55 <property stdset="1"> 58 <property stdset="1">
56 <name>sizePolicy</name> 59 <name>sizePolicy</name>
57 <sizepolicy> 60 <sizepolicy>
58 <hsizetype>0</hsizetype> 61 <hsizetype>0</hsizetype>
59 <vsizetype>1</vsizetype> 62 <vsizetype>1</vsizetype>
60 </sizepolicy> 63 </sizepolicy>
61 </property> 64 </property>
62 <property stdset="1"> 65 <property stdset="1">
63 <name>text</name> 66 <name>text</name>
64 <string>Display data</string> 67 <string>Display data</string>
65 </property> 68 </property>
66 </widget> 69 </widget>
67 <widget> 70 <widget>
68 <class>QComboBox</class> 71 <class>QComboBox</class>
69 <item> 72 <item>
70 <property> 73 <property>
71 <name>text</name> 74 <name>text</name>
72 <string>Hex</string> 75 <string>Hex</string>
73 </property> 76 </property>
74 </item> 77 </item>
75 <item> 78 <item>
76 <property> 79 <property>
77 <name>text</name> 80 <name>text</name>
78 <string>Ascii</string> 81 <string>Ascii</string>
79 </property> 82 </property>
80 </item> 83 </item>
81 <item> 84 <item>
82 <property> 85 <property>
83 <name>text</name> 86 <name>text</name>
84 <string>Both</string> 87 <string>Both</string>
85 </property> 88 </property>
86 </item> 89 </item>
87 <property stdset="1"> 90 <property stdset="1">
88 <name>name</name> 91 <name>name</name>
89 <cstring>DataFormat_CB</cstring> 92 <cstring>DataFormat_CB</cstring>
90 </property> 93 </property>
91 </widget> 94 </widget>
92 <spacer> 95 <spacer>
93 <property> 96 <property>
94 <name>name</name> 97 <name>name</name>
95 <cstring>Spacer1</cstring> 98 <cstring>Spacer1</cstring>
96 </property> 99 </property>
97 <property stdset="1"> 100 <property stdset="1">
98 <name>orientation</name> 101 <name>orientation</name>
99 <enum>Horizontal</enum> 102 <enum>Horizontal</enum>
100 </property> 103 </property>
101 <property stdset="1"> 104 <property stdset="1">
102 <name>sizeType</name> 105 <name>sizeType</name>
103 <enum>Expanding</enum> 106 <enum>Expanding</enum>
104 </property> 107 </property>
105 <property> 108 <property>
106 <name>sizeHint</name> 109 <name>sizeHint</name>
107 <size> 110 <size>
108 <width>20</width> 111 <width>20</width>
109 <height>20</height> 112 <height>20</height>
110 </size> 113 </size>
111 </property> 114 </property>
112 </spacer> 115 </spacer>
113 <widget> 116 <widget>
114 <class>QCheckBox</class> 117 <class>QCheckBox</class>
115 <property stdset="1"> 118 <property stdset="1">
116 <name>name</name> 119 <name>name</name>
117 <cstring>EnableTrace_CB</cstring> 120 <cstring>EnableTrace_CB</cstring>
118 </property> 121 </property>
119 <property stdset="1"> 122 <property stdset="1">
120 <name>text</name> 123 <name>text</name>
121 <string>Trace</string> 124 <string>Trace</string>
122 </property> 125 </property>
123 </widget> 126 </widget>
124 </hbox> 127 </hbox>
125 </widget> 128 </widget>
126 <widget> 129 <widget>
127 <class>QListBox</class> 130 <class>QTextView</class>
128 <property stdset="1"> 131 <property stdset="1">
129 <name>name</name> 132 <name>name</name>
130 <cstring>Output_LB</cstring> 133 <cstring>Output_TV</cstring>
131 </property>
132 <property stdset="1">
133 <name>selectionMode</name>
134 <enum>NoSelection</enum>
135 </property> 134 </property>
136 </widget> 135 </widget>
137 <widget> 136 <widget>
138 <class>QLayoutWidget</class> 137 <class>QLayoutWidget</class>
139 <property stdset="1"> 138 <property stdset="1">
140 <name>name</name> 139 <name>name</name>
141 <cstring>Layout3</cstring> 140 <cstring>Layout3</cstring>
142 </property> 141 </property>
143 <hbox> 142 <hbox>
144 <property stdset="1"> 143 <property stdset="1">
145 <name>margin</name> 144 <name>margin</name>
146 <number>0</number> 145 <number>0</number>
147 </property> 146 </property>
148 <property stdset="1"> 147 <property stdset="1">
149 <name>spacing</name> 148 <name>spacing</name>
150 <number>6</number> 149 <number>6</number>
151 </property> 150 </property>
152 <widget> 151 <widget>
153 <class>QPushButton</class> 152 <class>QPushButton</class>
154 <property stdset="1"> 153 <property stdset="1">
155 <name>name</name> 154 <name>name</name>
156 <cstring>Save_But</cstring> 155 <cstring>Save_But</cstring>
157 </property> 156 </property>
158 <property stdset="1"> 157 <property stdset="1">
159 <name>text</name> 158 <name>text</name>
160 <string>Save</string> 159 <string>Save</string>
161 </property> 160 </property>
162 </widget> 161 </widget>
163 <spacer> 162 <spacer>
164 <property> 163 <property>
165 <name>name</name> 164 <name>name</name>
166 <cstring>Spacer2_2</cstring> 165 <cstring>Spacer2_2</cstring>
167 </property> 166 </property>
168 <property stdset="1"> 167 <property stdset="1">
169 <name>orientation</name> 168 <name>orientation</name>
170 <enum>Horizontal</enum> 169 <enum>Horizontal</enum>
171 </property> 170 </property>
172 <property stdset="1"> 171 <property stdset="1">
173 <name>sizeType</name> 172 <name>sizeType</name>
174 <enum>Expanding</enum> 173 <enum>Expanding</enum>
175 </property> 174 </property>
176 <property> 175 <property>
177 <name>sizeHint</name> 176 <name>sizeHint</name>
178 <size> 177 <size>
179 <width>20</width> 178 <width>20</width>
180 <height>20</height> 179 <height>20</height>
181 </size> 180 </size>
182 </property> 181 </property>
183 </spacer> 182 </spacer>
184 <widget> 183 <widget>
185 <class>QPushButton</class> 184 <class>QPushButton</class>
186 <property stdset="1"> 185 <property stdset="1">
187 <name>name</name> 186 <name>name</name>
188 <cstring>Load_But</cstring> 187 <cstring>Load_But</cstring>
189 </property> 188 </property>
190 <property stdset="1"> 189 <property stdset="1">
191 <name>text</name> 190 <name>text</name>
192 <string>Load</string> 191 <string>Load</string>
193 </property> 192 </property>
194 </widget> 193 </widget>
195 <spacer> 194 <spacer>
196 <property> 195 <property>
197 <name>name</name> 196 <name>name</name>
198 <cstring>Spacer2</cstring> 197 <cstring>Spacer2</cstring>
199 </property> 198 </property>
200 <property stdset="1"> 199 <property stdset="1">
201 <name>orientation</name> 200 <name>orientation</name>
202 <enum>Horizontal</enum> 201 <enum>Horizontal</enum>
203 </property> 202 </property>
204 <property stdset="1"> 203 <property stdset="1">
205 <name>sizeType</name> 204 <name>sizeType</name>
206 <enum>Expanding</enum> 205 <enum>Expanding</enum>
207 </property> 206 </property>
208 <property> 207 <property>
209 <name>sizeHint</name> 208 <name>sizeHint</name>
210 <size> 209 <size>
211 <width>20</width> 210 <width>20</width>
212 <height>20</height> 211 <height>20</height>
213 </size> 212 </size>
214 </property> 213 </property>
215 </spacer> 214 </spacer>
216 <widget> 215 <widget>
217 <class>QPushButton</class> 216 <class>QPushButton</class>
218 <property stdset="1"> 217 <property stdset="1">
219 <name>name</name> 218 <name>name</name>
220 <cstring>ClearLog_But</cstring> 219 <cstring>ClearLog_But</cstring>
221 </property> 220 </property>
222 <property stdset="1"> 221 <property stdset="1">
223 <name>text</name> 222 <name>text</name>
224 <string>Clear log</string> 223 <string>Clear log</string>
225 </property> 224 </property>
226 </widget> 225 </widget>
227 </hbox> 226 </hbox>
228 </widget> 227 </widget>
229 </vbox> 228 </vbox>
230</widget> 229</widget>
231<connections> 230<connections>
232 <connection> 231 <connection>
233 <sender>EnableTrace_CB</sender> 232 <sender>EnableTrace_CB</sender>
234 <signal>toggled(bool)</signal> 233 <signal>toggled(bool)</signal>
235 <receiver>OTSniffGUI</receiver> 234 <receiver>OTSniffGUI</receiver>
236 <slot>SLOT_Trace( bool )</slot> 235 <slot>SLOT_Trace( bool )</slot>
237 </connection> 236 </connection>
238 <connection> 237 <connection>
239 <sender>ClearLog_But</sender> 238 <sender>ClearLog_But</sender>
240 <signal>clicked()</signal> 239 <signal>clicked()</signal>
241 <receiver>OTSniffGUI</receiver> 240 <receiver>OTSniffGUI</receiver>
242 <slot>SLOT_ClearLog()</slot> 241 <slot>SLOT_ClearLog()</slot>
243 </connection> 242 </connection>
244 <connection> 243 <connection>
245 <sender>Save_But</sender> 244 <sender>Save_But</sender>
246 <signal>clicked()</signal> 245 <signal>clicked()</signal>
247 <receiver>OTSniffGUI</receiver> 246 <receiver>OTSniffGUI</receiver>
248 <slot>SLOT_Save()</slot> 247 <slot>SLOT_Save()</slot>
249 </connection> 248 </connection>
250 <connection> 249 <connection>
251 <sender>Load_But</sender> 250 <sender>Load_But</sender>
252 <signal>clicked()</signal> 251 <signal>clicked()</signal>
253 <receiver>OTSniffGUI</receiver> 252 <receiver>OTSniffGUI</receiver>
254 <slot>SLOT_Load()</slot> 253 <slot>SLOT_Load()</slot>
255 </connection> 254 </connection>
256 <slot access="public">SLOT_ClearLog()</slot> 255 <slot access="public">SLOT_ClearLog()</slot>
257 <slot access="public">SLOT_Save()</slot> 256 <slot access="public">SLOT_Save()</slot>
258 <slot access="public">SLOT_Trace( bool )</slot> 257 <slot access="public">SLOT_Trace( bool )</slot>
259 <slot access="public">SLOT_Load()</slot> 258 <slot access="public">SLOT_Load()</slot>
260</connections> 259</connections>
261</UI> 260</UI>
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
@@ -1,1151 +1,1167 @@
1#include <opie2/odebug.h> 1#include <opie2/odebug.h>
2#include <opie2/oledbox.h> 2#include <opie2/oledbox.h>
3#include <opie2/ofiledialog.h> 3#include <opie2/ofiledialog.h>
4 4
5using namespace Opie::Core; 5using namespace Opie::Core;
6using namespace Opie::Ui; 6using namespace Opie::Ui;
7 7
8#include <qpe/resource.h> 8#include <qpe/resource.h>
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qcheckbox.h> 10#include <qcheckbox.h>
11#include <qcombobox.h> 11#include <qcombobox.h>
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
36using namespace Opietooth2; 38using namespace Opietooth2;
37 39
38namespace Opietooth2 { 40namespace Opietooth2 {
39 41
40class PeerLVI : public QListViewItem { 42class PeerLVI : public QListViewItem {
41 43
42public : 44public :
43 45
44 PeerLVI( OTPeer * P, QListView * it ) : QListViewItem (it) { 46 PeerLVI( OTPeer * P, QListView * it ) : QListViewItem (it) {
45 Peer = P; 47 Peer = P;
46 } 48 }
47 ~PeerLVI( void ) { 49 ~PeerLVI( void ) {
48 } 50 }
49 51
50 inline OTPeer * peer( void ) 52 inline OTPeer * peer( void )
51 { return Peer; } 53 { return Peer; }
52 54
53private : 55private :
54 56
55 OTPeer * Peer; 57 OTPeer * Peer;
56}; 58};
57 59
58class ChannelLVI : public QListViewItem { 60class ChannelLVI : public QListViewItem {
59 61
60public : 62public :
61 63
62 ChannelLVI( int Ch, QListViewItem * it ) : QListViewItem (it) { 64 ChannelLVI( int Ch, QListViewItem * it ) : QListViewItem (it) {
63 Channel = Ch; 65 Channel = Ch;
64 } 66 }
65 ~ChannelLVI( void ) { 67 ~ChannelLVI( void ) {
66 } 68 }
67 69
68 inline int channel( void ) 70 inline int channel( void )
69 { return Channel; } 71 { return Channel; }
70 72
71private : 73private :
72 74
73 int Channel; 75 int Channel;
74}; 76};
75 77
76class DriverLVI : public QListViewItem { 78class DriverLVI : public QListViewItem {
77 79
78public : 80public :
79 81
80 DriverLVI( OTDriver * P, QListView * it ) : QListViewItem (it) { 82 DriverLVI( OTDriver * P, QListView * it ) : QListViewItem (it) {
81 Driver = P; 83 Driver = P;
82 } 84 }
83 ~DriverLVI( void ) { 85 ~DriverLVI( void ) {
84 } 86 }
85 87
86 inline OTDriver * driver( void ) 88 inline OTDriver * driver( void )
87 { return Driver; } 89 { return Driver; }
88 90
89private : 91private :
90 92
91 OTDriver * Driver; 93 OTDriver * Driver;
92}; 94};
93 95
94class LinkKeyLVI : public QListViewItem { 96class LinkKeyLVI : public QListViewItem {
95 97
96public : 98public :
97 99
98 LinkKeyLVI( int Ch, QListView * it ) : QListViewItem (it) { 100 LinkKeyLVI( int Ch, QListView * it ) : QListViewItem (it) {
99 LinkKey = Ch; 101 LinkKey = Ch;
100 } 102 }
101 ~LinkKeyLVI( void ) { 103 ~LinkKeyLVI( void ) {
102 } 104 }
103 105
104 inline int index( void ) 106 inline int index( void )
105 { return LinkKey; } 107 { return LinkKey; }
106 108
107private : 109private :
108 110
109 int LinkKey; 111 int LinkKey;
110}; 112};
111}; 113};
112 114
113// 115//
114// 116//
115// 117//
116// 118//
117// 119//
118 120
119OTSniffing::OTSniffing( QWidget * parent ) : OTSniffGUI( parent ) { 121OTSniffing::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
126OTSniffing::~OTSniffing() { 127OTSniffing::~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
135void OTSniffing::SLOT_Trace( bool ) { 131void 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
152 SL << "-i"; 158 SL << "-i";
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
176void OTSniffing::SLOT_Show( const QString & S ) { 186void 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
183void OTSniffing::SLOT_ProcessExited( MyProcess * ) { 197void 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
189void OTSniffing::SLOT_Save( void ) { 203void 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(),
193 QString::null, 207 QString::null,
194 MimeTypes(), 208 MimeTypes(),
195 this ); 209 this );
196 210
197 if( ! S.isEmpty() ) { 211 if( ! S.isEmpty() ) {
198 QFile F( S ); 212 QFile F( S );
199 if( ! F.open( IO_WriteOnly ) ) { 213 if( ! F.open( IO_WriteOnly ) ) {
200 QMessageBox::warning(0, 214 QMessageBox::warning(0,
201 tr("Save log"), 215 tr("Save log"),
202 tr("Cannot open %1").arg(S) 216 tr("Cannot open %1").arg(S)
203 ); 217 );
204 return; 218 return;
205 } 219 }
206 QTextStream TS( &F ); 220 QTextStream TS( &F );
207 TS << S << endl; 221 TS << S << endl;
208 } 222 }
209} 223}
210 224
211void OTSniffing::SLOT_Load( void ) { 225void OTSniffing::SLOT_Load( void ) {
212 QString S = OFileDialog::getOpenFileName( 226 QString S = OFileDialog::getOpenFileName(
213 OFileSelector::Extended, 227 OFileSelector::Extended,
214 QDir::home().path(), 228 QDir::home().path(),
215 QString::null, 229 QString::null,
216 MimeTypes(), 230 MimeTypes(),
217 this ); 231 this );
218 232
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
235void OTSniffing::SLOT_ClearLog( void ) { 250void 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
245OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : 261OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) :
246 OTPairingGUI( parent ) { 262 OTPairingGUI( parent ) {
247 263
248 OT = OTGateway::getOTGateway(); 264 OT = OTGateway::getOTGateway();
249 Icons = (_IC ) ? _IC : new OTIcons(); 265 Icons = (_IC ) ? _IC : new OTIcons();
250 MyIcons = (_IC == 0 ); 266 MyIcons = (_IC == 0 );
251 267
252 // unpairing can only be done if bluetooth is disabled 268 // unpairing can only be done if bluetooth is disabled
253 Unpair_But->setEnabled( ! OT->isEnabled() ); 269 Unpair_But->setEnabled( ! OT->isEnabled() );
254 if( ! OT->isEnabled() ) { 270 if( ! OT->isEnabled() ) {
255 Unpair_LBL->hide(); 271 Unpair_LBL->hide();
256 } else { 272 } else {
257 Unpair_LBL->show(); 273 Unpair_LBL->show();
258 } 274 }
259 275
260 // open linkkey file and load pairs 276 // open linkkey file and load pairs
261 LinkKeyArray Keys = OT->getLinkKeys(); 277 LinkKeyArray Keys = OT->getLinkKeys();
262 LinkKeyLVI * it; 278 LinkKeyLVI * it;
263 OTPeer * P; 279 OTPeer * P;
264 OTDriver * D; 280 OTDriver * D;
265 281
266 for( unsigned int i = 0 ; 282 for( unsigned int i = 0 ;
267 i < Keys.count(); 283 i < Keys.count();
268 i ++ ) { 284 i ++ ) {
269 285
270 it = new LinkKeyLVI( i, Pairs_LV ); 286 it = new LinkKeyLVI( i, Pairs_LV );
271 287
272 P = 0; 288 P = 0;
273 D = OT->findDriver( Keys[i].from() ); 289 D = OT->findDriver( Keys[i].from() );
274 290
275 if( D ) { 291 if( D ) {
276 it->setText( 0, D->devname() ); 292 it->setText( 0, D->devname() );
277 293
278 // we are source 294 // we are source
279 P = OT->findPeer( Keys[i].to() ); 295 P = OT->findPeer( Keys[i].to() );
280 296
281 if( P ) { 297 if( P ) {
282 // put name 298 // put name
283 it->setText( 1, P->name() ); 299 it->setText( 1, P->name() );
284 } else { 300 } else {
285 // unknown 301 // unknown
286 it->setText( 1, Keys[i].to().toString() ); 302 it->setText( 1, Keys[i].to().toString() );
287 } 303 }
288 304
289 // and put address as sub 305 // and put address as sub
290 QListViewItem * Sub = new QListViewItem( it ); 306 QListViewItem * Sub = new QListViewItem( it );
291 Sub->setText( 0, D->address().toString() ); 307 Sub->setText( 0, D->address().toString() );
292 Sub->setText( 1, Keys[i].to().toString() ); 308 Sub->setText( 1, Keys[i].to().toString() );
293 } else { 309 } else {
294 // perhaps we are destination 310 // perhaps we are destination
295 D = OT->findDriver( Keys[i].to() ); 311 D = OT->findDriver( Keys[i].to() );
296 312
297 if( D ) { 313 if( D ) {
298 it->setText( 1, D->devname() ); 314 it->setText( 1, D->devname() );
299 315
300 // we are source 316 // we are source
301 P = OT->findPeer( Keys[i].from() ); 317 P = OT->findPeer( Keys[i].from() );
302 318
303 if( P ) { 319 if( P ) {
304 // put name 320 // put name
305 it->setText( 0, P->name() ); 321 it->setText( 0, P->name() );
306 } else { 322 } else {
307 // unknown 323 // unknown
308 it->setText( 0, Keys[i].from().toString() ); 324 it->setText( 0, Keys[i].from().toString() );
309 } 325 }
310 326
311 // and put address as sub 327 // and put address as sub
312 QListViewItem * Sub = new QListViewItem( it ); 328 QListViewItem * Sub = new QListViewItem( it );
313 Sub->setText( 0, Keys[i].from().toString() ); 329 Sub->setText( 0, Keys[i].from().toString() );
314 Sub->setText( 1, D->address().toString() ); 330 Sub->setText( 1, D->address().toString() );
315 } else { 331 } else {
316 // nor source nor destination -> unknown 332 // nor source nor destination -> unknown
317 it->setText( 0, Keys[i].from().toString() ); 333 it->setText( 0, Keys[i].from().toString() );
318 it->setText( 1, Keys[i].to().toString() ); 334 it->setText( 1, Keys[i].to().toString() );
319 } 335 }
320 } 336 }
321 } 337 }
322} 338}
323 339
324 340
325OTPairing::~OTPairing() { 341OTPairing::~OTPairing() {
326 if( MyIcons ) 342 if( MyIcons )
327 delete Icons; 343 delete Icons;
328 OTGateway::releaseOTGateway(); 344 OTGateway::releaseOTGateway();
329} 345}
330 346
331void OTPairing::SLOT_Unpair( ) { 347void OTPairing::SLOT_Unpair( ) {
332 // find selected pair 348 // find selected pair
333 349
334 QListViewItem * it = Pairs_LV->firstChild(); 350 QListViewItem * it = Pairs_LV->firstChild();
335 while( it ) { 351 while( it ) {
336 if( it->isSelected() ) { 352 if( it->isSelected() ) {
337 // confirm ? 353 // confirm ?
338 if( QMessageBox::warning(0, 354 if( QMessageBox::warning(0,
339 tr("Break pairing"), 355 tr("Break pairing"),
340 tr("Sure ?"), 356 tr("Sure ?"),
341 tr("Yes, break"), 357 tr("Yes, break"),
342 tr("No, don't break") ) == 0 ) { 358 tr("No, don't break") ) == 0 ) {
343 LinkKeyLVI * KPIt = (LinkKeyLVI *)it; 359 LinkKeyLVI * KPIt = (LinkKeyLVI *)it;
344 // break 360 // break
345 OT->removeLinkKey( KPIt->index() ); 361 OT->removeLinkKey( KPIt->index() );
346 delete KPIt; 362 delete KPIt;
347 } 363 }
348 return; 364 return;
349 } 365 }
350 it= it->nextSibling(); 366 it= it->nextSibling();
351 } 367 }
352} 368}
353 369
354// 370//
355// 371//
356// 372//
357// 373//
358// 374//
359 375
360OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : 376OTScan::OTScan( QWidget * parent, OTIcons * _IC ) :
361 OTScanGUI( parent ), Filter() { 377 OTScanGUI( parent ), Filter() {
362 378
363 OT = OTGateway::getOTGateway(); 379 OT = OTGateway::getOTGateway();
364 Icons = (_IC ) ? _IC : new OTIcons(); 380 Icons = (_IC ) ? _IC : new OTIcons();
365 MyIcons = (_IC == 0 ); 381 MyIcons = (_IC == 0 );
366 DetectedPeers_LV->header()->hide(); 382 DetectedPeers_LV->header()->hide();
367 Current = 0; 383 Current = 0;
368 SelectedPeer = 0; 384 SelectedPeer = 0;
369 SelectedChannel = 0; 385 SelectedChannel = 0;
370 386
371 StrengthTimer = new QTimer( this ); 387 StrengthTimer = new QTimer( this );
372 connect( StrengthTimer, 388 connect( StrengthTimer,
373 SIGNAL( timeout()), 389 SIGNAL( timeout()),
374 this, 390 this,
375 SLOT( SLOT_UpdateStrength()) 391 SLOT( SLOT_UpdateStrength())
376 ); 392 );
377 393
378 connect( OT, 394 connect( OT,
379 SIGNAL( detectedPeer( OTPeer *, bool )), 395 SIGNAL( detectedPeer( OTPeer *, bool )),
380 this, 396 this,
381 SLOT( SLOT_NewPeer( OTPeer *, bool )) 397 SLOT( SLOT_NewPeer( OTPeer *, bool ))
382 ); 398 );
383 connect( OT, 399 connect( OT,
384 SIGNAL( finishedDetecting()), 400 SIGNAL( finishedDetecting()),
385 this, 401 this,
386 SLOT( SLOT_FinishedDetecting()) 402 SLOT( SLOT_FinishedDetecting())
387 ); 403 );
388 404
389 // populate with peers we already know about 405 // populate with peers we already know about
390 const PeerVector & P = OT->peers(); 406 const PeerVector & P = OT->peers();
391 for( unsigned int i = 0; 407 for( unsigned int i = 0;
392 i < P.count(); 408 i < P.count();
393 i ++ ) { 409 i ++ ) {
394 SLOT_NewPeer( P[i], TRUE ); 410 SLOT_NewPeer( P[i], TRUE );
395 } 411 }
396 412
397 // populate State fram 413 // populate State fram
398 { QHBoxLayout * H =new QHBoxLayout( State_Frm ); 414 { QHBoxLayout * H =new QHBoxLayout( State_Frm );
399 415
400 Paired_Led = new OLedBox( green, State_Frm ); 416 Paired_Led = new OLedBox( green, State_Frm );
401 QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); 417 QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm );
402 418
403 H->addWidget( Paired_Led ); 419 H->addWidget( Paired_Led );
404 H->addWidget( L1 ); 420 H->addWidget( L1 );
405 H->addStretch( 1 ); 421 H->addStretch( 1 );
406 } 422 }
407} 423}
408 424
409OTScan::~OTScan() { 425OTScan::~OTScan() {
410 if( MyIcons ) 426 if( MyIcons )
411 delete Icons; 427 delete Icons;
412 OTGateway::releaseOTGateway(); 428 OTGateway::releaseOTGateway();
413 429
414 // send all peers that we do not care about states 430 // send all peers that we do not care about states
415 QListViewItem * Lit = DetectedPeers_LV->firstChild(); 431 QListViewItem * Lit = DetectedPeers_LV->firstChild();
416 while( Lit ) { 432 while( Lit ) {
417 ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); 433 ((PeerLVI *)Lit)->peer()->stopFindingOutState( );
418 Lit = Lit->nextSibling(); 434 Lit = Lit->nextSibling();
419 } 435 }
420} 436}
421 437
422// static scan dialog function 438// static scan dialog function
423int OTScan::getDevice( OTPeer *& Peer, 439int OTScan::getDevice( OTPeer *& Peer,
424 int & Channel, 440 int & Channel,
425 OTGateway * OT, 441 OTGateway * OT,
426 const UUIDVector & Filter, 442 const UUIDVector & Filter,
427 QWidget* Parent ) { 443 QWidget* Parent ) {
428 bool IsUp = 0; 444 bool IsUp = 0;
429 unsigned int i; 445 unsigned int i;
430 446
431 // check if bluetooth is up 447 // check if bluetooth is up
432 OTDriverList & DL = OT->getDriverList(); 448 OTDriverList & DL = OT->getDriverList();
433 for( i = 0; 449 for( i = 0;
434 i < DL.count(); 450 i < DL.count();
435 i ++ ) { 451 i ++ ) {
436 if( DL[i]->isUp() ) { 452 if( DL[i]->isUp() ) {
437 // one device that is up found 453 // one device that is up found
438 IsUp = 1; 454 IsUp = 1;
439 break; 455 break;
440 } 456 }
441 } 457 }
442 458
443 // use this driver 459 // use this driver
444 OT->setScanWith( OT->driver(i) ); 460 OT->setScanWith( OT->driver(i) );
445 461
446 // create dialog 462 // create dialog
447 QDialog * Dlg = new QDialog( Parent, 0, TRUE ); 463 QDialog * Dlg = new QDialog( Parent, 0, TRUE );
448 QVBoxLayout * V = new QVBoxLayout( Dlg ); 464 QVBoxLayout * V = new QVBoxLayout( Dlg );
449 OTScan * Scn = new OTScan( Dlg ); 465 OTScan * Scn = new OTScan( Dlg );
450 466
451 connect( Scn, 467 connect( Scn,
452 SIGNAL( selected() ), 468 SIGNAL( selected() ),
453 Dlg, 469 Dlg,
454 SLOT( accept() ) 470 SLOT( accept() )
455 ); 471 );
456 472
457 if( Filter ) { 473 if( Filter ) {
458 Scn->setScanFilter( Filter ); 474 Scn->setScanFilter( Filter );
459 } 475 }
460 476
461 V->addWidget( Scn ); 477 V->addWidget( Scn );
462 Dlg->setCaption( tr("Scan Neighbourhood" ) ); 478 Dlg->setCaption( tr("Scan Neighbourhood" ) );
463 Dlg->showMaximized(); 479 Dlg->showMaximized();
464 int rv = Dlg->exec(); 480 int rv = Dlg->exec();
465 481
466 if( rv == QDialog::Accepted ) { 482 if( rv == QDialog::Accepted ) {
467 // get peer 483 // get peer
468 Peer = Scn->selectedPeer(); 484 Peer = Scn->selectedPeer();
469 if( Peer == 0 ) { 485 if( Peer == 0 ) {
470 // no peer selected 486 // no peer selected
471 rv = QDialog::Rejected; 487 rv = QDialog::Rejected;
472 } else { 488 } else {
473 Channel = Scn->selectedChannel(); 489 Channel = Scn->selectedChannel();
474 } 490 }
475 } 491 }
476 492
477 delete Dlg; 493 delete Dlg;
478 494
479 return rv; 495 return rv;
480} 496}
481 497
482void OTScan::setScanFilter( const UUIDVector & V ) { 498void OTScan::setScanFilter( const UUIDVector & V ) {
483 Filter = V; 499 Filter = V;
484} 500}
485 501
486void OTScan::resetScanFilter( void ) { 502void OTScan::resetScanFilter( void ) {
487 Filter.truncate(0); 503 Filter.truncate(0);
488} 504}
489 505
490void OTScan::SLOT_DoScan( bool DoIt ) { 506void OTScan::SLOT_DoScan( bool DoIt ) {
491 if( DoIt ) { 507 if( DoIt ) {
492 OT->scanNeighbourhood(); 508 OT->scanNeighbourhood();
493 } else { 509 } else {
494 OT->stopScanOfNeighbourhood(); 510 OT->stopScanOfNeighbourhood();
495 } 511 }
496 512
497 scanMode( DoIt ); 513 scanMode( DoIt );
498} 514}
499 515
500// double clicked on a device 516// double clicked on a device
501void OTScan::SLOT_Selected( QListViewItem * it ) { 517void OTScan::SLOT_Selected( QListViewItem * it ) {
502 if( ! it ) 518 if( ! it )
503 return; 519 return;
504 520
505 if( Filter.count() > 0 ) { 521 if( Filter.count() > 0 ) {
506 // filter on service 522 // filter on service
507 if( it->depth() == 0 ) { 523 if( it->depth() == 0 ) {
508 // select a service and not a device 524 // select a service and not a device
509 return; 525 return;
510 } 526 }
511 527
512 // store result 528 // store result
513 SelectedPeer = ((PeerLVI *)it->parent())->peer(); 529 SelectedPeer = ((PeerLVI *)it->parent())->peer();
514 SelectedChannel = ((ChannelLVI *)it)->channel(); 530 SelectedChannel = ((ChannelLVI *)it)->channel();
515 } else { 531 } else {
516 // click on device 532 // click on device
517 if( it->depth() != 0 ) { 533 if( it->depth() != 0 ) {
518 return; 534 return;
519 } 535 }
520 536
521 SelectedPeer = ((PeerLVI *)it)->peer(); 537 SelectedPeer = ((PeerLVI *)it)->peer();
522 SelectedChannel = 0; 538 SelectedChannel = 0;
523 } 539 }
524 owarn << "Selected " << SelectedPeer->address().toString() << 540 owarn << "Selected " << SelectedPeer->address().toString() <<
525 " Channel " << SelectedChannel << oendl; 541 " Channel " << SelectedChannel << oendl;
526 emit selected(); 542 emit selected();
527} 543}
528 544
529void OTScan::SLOT_FinishedDetecting( ) { 545void OTScan::SLOT_FinishedDetecting( ) {
530 scanMode( false ); 546 scanMode( false );
531} 547}
532 548
533void OTScan::SLOT_CleanupOld( ) { 549void OTScan::SLOT_CleanupOld( ) {
534 550
535 // iterate over all peers and find those that 551 // iterate over all peers and find those that
536 // are down and have no pairing info 552 // are down and have no pairing info
537 OTPeer * TheP; 553 OTPeer * TheP;
538 const LinkKeyArray & Keys = OT->getLinkKeys(); 554 const LinkKeyArray & Keys = OT->getLinkKeys();
539 555
540 QListViewItem * Lit = DetectedPeers_LV->firstChild(); 556 QListViewItem * Lit = DetectedPeers_LV->firstChild();
541 while( Lit ) { 557 while( Lit ) {
542 TheP = ((PeerLVI *)Lit)->peer(); 558 TheP = ((PeerLVI *)Lit)->peer();
543 if( TheP->state() == OTPeer::Peer_Down ) { 559 if( TheP->state() == OTPeer::Peer_Down ) {
544 unsigned int k; 560 unsigned int k;
545 561
546 // what about linkkeys ? 562 // what about linkkeys ?
547 for( k = 0; k < Keys.count(); k ++ ) { 563 for( k = 0; k < Keys.count(); k ++ ) {
548 if( TheP->address() == Keys[k].to() || 564 if( TheP->address() == Keys[k].to() ||
549 TheP->address() == Keys[k].from() 565 TheP->address() == Keys[k].from()
550 ) { 566 ) {
551 // part of linkkey 567 // part of linkkey
552 owarn << "LINKKEY " << TheP->address().toString() << oendl; 568 owarn << "LINKKEY " << TheP->address().toString() << oendl;
553 break; 569 break;
554 } 570 }
555 } 571 }
556 572
557 if( k == Keys.count() ) { 573 if( k == Keys.count() ) {
558 owarn << "RM LINKKEY " << TheP->address().toString() << oendl; 574 owarn << "RM LINKKEY " << TheP->address().toString() << oendl;
559 // not found -> remember to remove this peer 575 // not found -> remember to remove this peer
560 QListViewItem * Nit; 576 QListViewItem * Nit;
561 OT->removePeer( TheP ); 577 OT->removePeer( TheP );
562 Nit = Lit->nextSibling(); 578 Nit = Lit->nextSibling();
563 delete Lit; 579 delete Lit;
564 Lit = Nit; 580 Lit = Nit;
565 continue; 581 continue;
566 } 582 }
567 } else { 583 } else {
568 owarn << "NODOWN " << TheP->address().toString() << oendl; 584 owarn << "NODOWN " << TheP->address().toString() << oendl;
569 } 585 }
570 586
571 Lit = Lit->nextSibling(); 587 Lit = Lit->nextSibling();
572 } 588 }
573} 589}
574 590
575void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ 591void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){
576 PeerLVI * it = 0; 592 PeerLVI * it = 0;
577 593
578 if( IsNew ) { 594 if( IsNew ) {
579 it = new PeerLVI( P, DetectedPeers_LV ); 595 it = new PeerLVI( P, DetectedPeers_LV );
580 } else { 596 } else {
581 // find peer in table 597 // find peer in table
582 QListViewItem * Lit = DetectedPeers_LV->firstChild(); 598 QListViewItem * Lit = DetectedPeers_LV->firstChild();
583 while( Lit ) { 599 while( Lit ) {
584 if( ((PeerLVI *)Lit)->peer() == P ) { 600 if( ((PeerLVI *)Lit)->peer() == P ) {
585 // this item 601 // this item
586 it = (PeerLVI *)Lit; 602 it = (PeerLVI *)Lit;
587 break; 603 break;
588 } 604 }
589 Lit = Lit->nextSibling(); 605 Lit = Lit->nextSibling();
590 } 606 }
591 607
592 if( ! it ) { 608 if( ! it ) {
593 owarn << "Should not occur" << oendl; 609 owarn << "Should not occur" << oendl;
594 return; 610 return;
595 } 611 }
596 } 612 }
597 613
598 // update/show info 614 // update/show info
599 it->setText( 0, P->name() ); 615 it->setText( 0, P->name() );
600 it->setPixmap(0, Icons->deviceIcon( 616 it->setPixmap(0, Icons->deviceIcon(
601 OT->deviceTypeToName( P->deviceClass() ) ) ); 617 OT->deviceTypeToName( P->deviceClass() ) ) );
602 618
603 // tell peer to report its state async 619 // tell peer to report its state async
604 connect( P, 620 connect( P,
605 SIGNAL( peerStateReport( OTPeer *)), 621 SIGNAL( peerStateReport( OTPeer *)),
606 this, 622 this,
607 SLOT( SLOT_PeerState( OTPeer *)) 623 SLOT( SLOT_PeerState( OTPeer *))
608 ); 624 );
609 625
610 if( IsNew ) { 626 if( IsNew ) {
611 // find state 627 // find state
612 refreshState( (PeerLVI *)it, 1 ); 628 refreshState( (PeerLVI *)it, 1 );
613 } else { 629 } else {
614 // update staet 630 // update staet
615 SLOT_PeerState( P ); 631 SLOT_PeerState( P );
616 } 632 }
617} 633}
618 634
619void OTScan::SLOT_PeerState( OTPeer * P ) { 635void OTScan::SLOT_PeerState( OTPeer * P ) {
620 PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); 636 PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild();
621 while( it ) { 637 while( it ) {
622 if( it->peer() == P ) { 638 if( it->peer() == P ) {
623 break; 639 break;
624 } 640 }
625 it = (PeerLVI * )it->nextSibling(); 641 it = (PeerLVI * )it->nextSibling();
626 } 642 }
627 643
628 if( ! it ) 644 if( ! it )
629 return; 645 return;
630 646
631 switch( P->state() ) { 647 switch( P->state() ) {
632 case OTPeer::Peer_Unknown : 648 case OTPeer::Peer_Unknown :
633 case OTPeer::Peer_Down : 649 case OTPeer::Peer_Down :
634 it->setPixmap( 1, 0 ); 650 it->setPixmap( 1, 0 );
635 break; 651 break;
636 case OTPeer::Peer_Up : 652 case OTPeer::Peer_Up :
637 it->setPixmap( 1, Icons->loadPixmap( 653 it->setPixmap( 1, Icons->loadPixmap(
638 ( P->connectedTo() ) ? "connected" : "notconnected" ) ); 654 ( P->connectedTo() ) ? "connected" : "notconnected" ) );
639 if( it == Current && ! StrengthTimer->isActive() ) { 655 if( it == Current && ! StrengthTimer->isActive() ) {
640 // start showing strength 656 // start showing strength
641 StrengthTimer->start( 1000, FALSE ); 657 StrengthTimer->start( 1000, FALSE );
642 SLOT_UpdateStrength(); 658 SLOT_UpdateStrength();
643 } 659 }
644 break; 660 break;
645 } 661 }
646} 662}
647 663
648void OTScan::SLOT_RefreshState( void ) { 664void OTScan::SLOT_RefreshState( void ) {
649 665
650 QListViewItem * it = DetectedPeers_LV->firstChild(); 666 QListViewItem * it = DetectedPeers_LV->firstChild();
651 while( it ) { 667 while( it ) {
652 if( it->isSelected() ) { 668 if( it->isSelected() ) {
653 break; 669 break;
654 } 670 }
655 it = it->nextSibling(); 671 it = it->nextSibling();
656 } 672 }
657 673
658 if( ! it ) 674 if( ! it )
659 return; 675 return;
660 676
661 refreshState( (PeerLVI *)it, 1 ); 677 refreshState( (PeerLVI *)it, 1 );
662} 678}
663 679
664void OTScan::refreshState( PeerLVI * it, bool Force ) { 680void OTScan::refreshState( PeerLVI * it, bool Force ) {
665 it->setPixmap( 1, Icons->loadPixmap( "find" ) ); 681 it->setPixmap( 1, Icons->loadPixmap( "find" ) );
666 it->peer()->findOutState( 30, Force ); 682 it->peer()->findOutState( 30, Force );
667} 683}
668 684
669void OTScan::SLOT_Show( QListViewItem * it ) { 685void OTScan::SLOT_Show( QListViewItem * it ) {
670 686
671 if( ! it || it->depth() > 0 ) 687 if( ! it || it->depth() > 0 )
672 return; 688 return;
673 689
674 QString S; 690 QString S;
675 691
676 Current = (PeerLVI *)it; 692 Current = (PeerLVI *)it;
677 693
678 Strength_PB->setProgress( 0 ); // reset 694 Strength_PB->setProgress( 0 ); // reset
679 Address_LBL->setText( Current->peer()->address().toString() ); 695 Address_LBL->setText( Current->peer()->address().toString() );
680 Peer_GB->setTitle( Current->peer()->name() ); 696 Peer_GB->setTitle( Current->peer()->name() );
681 697
682 const LinkKeyArray & Keys = OT->getLinkKeys(); 698 const LinkKeyArray & Keys = OT->getLinkKeys();
683 699
684 Paired_Led->setOn( FALSE ); 700 Paired_Led->setOn( FALSE );
685 for( unsigned int i = 0; 701 for( unsigned int i = 0;
686 i < Keys.count(); 702 i < Keys.count();
687 i ++ ) { 703 i ++ ) {
688 if( Current->peer()->address() == Keys[i].to() ) { 704 if( Current->peer()->address() == Keys[i].to() ) {
689 Paired_Led->setOn( TRUE ); 705 Paired_Led->setOn( TRUE );
690 break; 706 break;
691 } 707 }
692 } 708 }
693 709
694 if( Current->peer()->state() == OTPeer::Peer_Up ) { 710 if( Current->peer()->state() == OTPeer::Peer_Up ) {
695 RefreshServices_But->setEnabled( TRUE ); 711 RefreshServices_But->setEnabled( TRUE );
696 StrengthTimer->start( 1000, FALSE ); 712 StrengthTimer->start( 1000, FALSE );
697 SLOT_UpdateStrength(); 713 SLOT_UpdateStrength();
698 } else { 714 } else {
699 RefreshServices_But->setEnabled( FALSE ); 715 RefreshServices_But->setEnabled( FALSE );
700 } 716 }
701 717
702} 718}
703 719
704void OTScan::SLOT_UpdateStrength( void ) { 720void OTScan::SLOT_UpdateStrength( void ) {
705 OTDriver * D = Current->peer()->connectedTo(); 721 OTDriver * D = Current->peer()->connectedTo();
706 722
707 if( D ) { 723 if( D ) {
708 long Q = D->getLinkQuality( Current->peer()->address() ); 724 long Q = D->getLinkQuality( Current->peer()->address() );
709 Strength_PB->setProgress( Q ); 725 Strength_PB->setProgress( Q );
710 if( ! Q ) { 726 if( ! Q ) {
711 // no quality 727 // no quality
712 Strength_PB->setEnabled( TRUE ); 728 Strength_PB->setEnabled( TRUE );
713 StrengthTimer->stop(); 729 StrengthTimer->stop();
714 } 730 }
715 } else { 731 } else {
716 Strength_PB->setEnabled( FALSE ); 732 Strength_PB->setEnabled( FALSE );
717 Strength_PB->setProgress( 0 ); 733 Strength_PB->setProgress( 0 );
718 // no point in continuing 734 // no point in continuing
719 StrengthTimer->stop(); 735 StrengthTimer->stop();
720 } 736 }
721} 737}
722 738
723void OTScan::SLOT_RefreshServices( void ) { 739void OTScan::SLOT_RefreshServices( void ) {
724 740
725 QListViewItem * it = DetectedPeers_LV->firstChild(); 741 QListViewItem * it = DetectedPeers_LV->firstChild();
726 while( it ) { 742 while( it ) {
727 if( it->isSelected() ) { 743 if( it->isSelected() ) {
728 break; 744 break;
729 } 745 }
730 it = it->nextSibling(); 746 it = it->nextSibling();
731 } 747 }
732 748
733 if( ! it ) 749 if( ! it )
734 return; 750 return;
735 751
736 QString S; 752 QString S;
737 PeerLVI * PI = (PeerLVI *)it; 753 PeerLVI * PI = (PeerLVI *)it;
738 754
739 scanMode( true ); 755 scanMode( true );
740 qApp->processEvents(0); 756 qApp->processEvents(0);
741 757
742 ServiceVector & V = PI->peer()->services(); 758 ServiceVector & V = PI->peer()->services();
743 759
744 while( PI->firstChild() ) { 760 while( PI->firstChild() ) {
745 // remove children 761 // remove children
746 delete PI->firstChild(); 762 delete PI->firstChild();
747 } 763 }
748 764
749 for( unsigned int i = 0 ; 765 for( unsigned int i = 0 ;
750 i < V.count(); 766 i < V.count();
751 i ++ ) { 767 i ++ ) {
752 QString S; 768 QString S;
753 S = V[i]->name(); 769 S = V[i]->name();
754 770
755 if( S.isEmpty() ) { 771 if( S.isEmpty() ) {
756 continue; 772 continue;
757 } 773 }
758 774
759 { QListViewItem * SIt; 775 { QListViewItem * SIt;
760 UUIDVector UIDV; 776 UUIDVector UIDV;
761 QPixmap Pm; 777 QPixmap Pm;
762 bool Done = 0; 778 bool Done = 0;
763 bool R; 779 bool R;
764 short ID; 780 short ID;
765 781
766 SIt = 0; 782 SIt = 0;
767 783
768 UIDV = V[i]->classIDList(); 784 UIDV = V[i]->classIDList();
769 // first all UUID ! 1200 12ff (Genericprofiles) 785 // first all UUID ! 1200 12ff (Genericprofiles)
770 for( unsigned int j = 0; 786 for( unsigned int j = 0;
771 j < UIDV.count(); 787 j < UIDV.count();
772 j ++ ) { 788 j ++ ) {
773 789
774 if( Filter.count() ) { 790 if( Filter.count() ) {
775 bool FilterOut = 1; 791 bool FilterOut = 1;
776 // filter out if not in list 792 // filter out if not in list
777 for( unsigned int ff = 0; 793 for( unsigned int ff = 0;
778 ff < Filter.count(); 794 ff < Filter.count();
779 ff ++ ) { 795 ff ++ ) {
780 if( UIDV[j] == Filter[ff] ) { 796 if( UIDV[j] == Filter[ff] ) {
781 FilterOut = 0; 797 FilterOut = 0;
782 break; 798 break;
783 } 799 }
784 } 800 }
785 801
786 if( FilterOut ) { 802 if( FilterOut ) {
787 // not in filter list 803 // not in filter list
788 continue; 804 continue;
789 } 805 }
790 } // else show 806 } // else show
791 807
792 ID = UIDV[j].toShort(); 808 ID = UIDV[j].toShort();
793 if( ID < 0x1200 || ID > 0x12ff ) { 809 if( ID < 0x1200 || ID > 0x12ff ) {
794 // use this profile 810 // use this profile
795 if( R ) { 811 if( R ) {
796 unsigned int ch; 812 unsigned int ch;
797 bool has; 813 bool has;
798 has = V[i]->rfcommChannel( ch ); 814 has = V[i]->rfcommChannel( ch );
799 SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); 815 SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI );
800 SIt->setText(0, V[i]->name() ); 816 SIt->setText(0, V[i]->name() );
801 817
802 Pm = Icons->serviceIcon( ID, R ); 818 Pm = Icons->serviceIcon( ID, R );
803 SIt->setPixmap(0, Pm ); 819 SIt->setPixmap(0, Pm );
804 Done = 1; 820 Done = 1;
805 break; 821 break;
806 } 822 }
807 } 823 }
808 } 824 }
809 825
810 if( ! Done ) { 826 if( ! Done ) {
811 // check other range too 827 // check other range too
812 for( unsigned int j = 0; 828 for( unsigned int j = 0;
813 j < UIDV.count(); 829 j < UIDV.count();
814 j ++ ) { 830 j ++ ) {
815 831
816 if( Filter.count() ) { 832 if( Filter.count() ) {
817 bool FilterOut = 1; 833 bool FilterOut = 1;
818 // filter out if not in list 834 // filter out if not in list
819 for( unsigned int ff = 0; 835 for( unsigned int ff = 0;
820 ff < Filter.count(); 836 ff < Filter.count();
821 ff ++ ) { 837 ff ++ ) {
822 if( UIDV[j] == Filter[ff] ) { 838 if( UIDV[j] == Filter[ff] ) {
823 FilterOut = 0; 839 FilterOut = 0;
824 break; 840 break;
825 } 841 }
826 } 842 }
827 843
828 if( FilterOut ) { 844 if( FilterOut ) {
829 // not in filter list 845 // not in filter list
830 continue; 846 continue;
831 } 847 }
832 } // else show 848 } // else show
833 849
834 ID = UIDV[j].toShort(); 850 ID = UIDV[j].toShort();
835 if( ID >= 0x1200 && ID <= 0x12ff ) { 851 if( ID >= 0x1200 && ID <= 0x12ff ) {
836 // use this profile 852 // use this profile
837 unsigned int ch; 853 unsigned int ch;
838 bool has; 854 bool has;
839 has = V[i]->rfcommChannel( ch ); 855 has = V[i]->rfcommChannel( ch );
840 SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); 856 SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI );
841 SIt->setText(0, V[i]->name() ); 857 SIt->setText(0, V[i]->name() );
842 858
843 Pm = Icons->serviceIcon( ID, R ); 859 Pm = Icons->serviceIcon( ID, R );
844 SIt->setPixmap(0, Pm ); 860 SIt->setPixmap(0, Pm );
845 861
846 break; 862 break;
847 } 863 }
848 } 864 }
849 } 865 }
850 866
851 } 867 }
852 } 868 }
853 869
854 scanMode( false ); 870 scanMode( false );
855} 871}
856 872
857void OTScan::scanMode( bool M ) { 873void OTScan::scanMode( bool M ) {
858 // avoid infinite loop because it triggers DoScan 874 // avoid infinite loop because it triggers DoScan
859 Detect_But->blockSignals( TRUE ); 875 Detect_But->blockSignals( TRUE );
860 Detect_But->setOn( M ); 876 Detect_But->setOn( M );
861 Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") ); 877 Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") );
862 Detect_But->blockSignals( FALSE ); 878 Detect_But->blockSignals( FALSE );
863} 879}
864 880
865// 881//
866// 882//
867// 883//
868// 884//
869// 885//
870 886
871OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : 887OTManage::OTManage( QWidget * parent, OTIcons * _IC ) :
872 OTManageGUI( parent ) { 888 OTManageGUI( parent ) {
873 889
874 OT = OTGateway::getOTGateway(); 890 OT = OTGateway::getOTGateway();
875 891
876 Icons = (_IC ) ? _IC : new OTIcons(); 892 Icons = (_IC ) ? _IC : new OTIcons();
877 MyIcons = (_IC == 0 ); 893 MyIcons = (_IC == 0 );
878 AllDrivers_LV->setSorting(-1); 894 AllDrivers_LV->setSorting(-1);
879 895
880 connect( OT, 896 connect( OT,
881 SIGNAL( driverListChanged() ), 897 SIGNAL( driverListChanged() ),
882 this, 898 this,
883 SLOT( SLOT_DriverListChanged() ) 899 SLOT( SLOT_DriverListChanged() )
884 ); 900 );
885 connect( OT, 901 connect( OT,
886 SIGNAL( stateChange( OTDriver *, bool ) ), 902 SIGNAL( stateChange( OTDriver *, bool ) ),
887 this, 903 this,
888 SLOT( SLOT_StateChange( OTDriver *, bool ) ) 904 SLOT( SLOT_StateChange( OTDriver *, bool ) )
889 ); 905 );
890 906
891 SLOT_DriverListChanged(); 907 SLOT_DriverListChanged();
892 908
893 AllDrivers_LV->header()->hide(); 909 AllDrivers_LV->header()->hide();
894} 910}
895 911
896OTManage::~OTManage() { 912OTManage::~OTManage() {
897 if( MyIcons ) 913 if( MyIcons )
898 delete Icons; 914 delete Icons;
899 OTGateway::releaseOTGateway(); 915 OTGateway::releaseOTGateway();
900} 916}
901 917
902void OTManage::SLOT_ShowDriver( QListViewItem * It ) { 918void OTManage::SLOT_ShowDriver( QListViewItem * It ) {
903 if( It == 0 || It->depth() > 0 ) 919 if( It == 0 || It->depth() > 0 )
904 // not toplevel 920 // not toplevel
905 return; 921 return;
906 922
907 DriverLVI * it = (DriverLVI *) It; 923 DriverLVI * it = (DriverLVI *) It;
908 DriverIsUp_CB->setChecked( it->driver()->isUp() ); 924 DriverIsUp_CB->setChecked( it->driver()->isUp() );
909} 925}
910 926
911void OTManage::SLOT_UpDriver( bool Up ) { 927void OTManage::SLOT_UpDriver( bool Up ) {
912 QListViewItem * it = AllDrivers_LV->firstChild(); 928 QListViewItem * it = AllDrivers_LV->firstChild();
913 while( it ) { 929 while( it ) {
914 if( it->isSelected() ) { 930 if( it->isSelected() ) {
915 OTDriver * D = ((DriverLVI *)it)->driver(); 931 OTDriver * D = ((DriverLVI *)it)->driver();
916 owarn << "UP driver " << D->devname() << oendl; 932 owarn << "UP driver " << D->devname() << oendl;
917 // this 933 // this
918 D->setUp( Up ); 934 D->setUp( Up );
919 return; 935 return;
920 } 936 }
921 it = it->nextSibling(); 937 it = it->nextSibling();
922 } 938 }
923} 939}
924 940
925void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { 941void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) {
926 QListViewItem * it = AllDrivers_LV->firstChild(); 942 QListViewItem * it = AllDrivers_LV->firstChild();
927 while( it ) { 943 while( it ) {
928 if( ((DriverLVI *)it)->driver() == D ) { 944 if( ((DriverLVI *)it)->driver() == D ) {
929 it->setPixmap( 0, 945 it->setPixmap( 0,
930 Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); 946 Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) );
931 return; 947 return;
932 } 948 }
933 it = it->nextSibling(); 949 it = it->nextSibling();
934 } 950 }
935} 951}
936 952
937void OTManage::SLOT_DriverListChanged( ) { 953void OTManage::SLOT_DriverListChanged( ) {
938 DriverLVI * It; 954 DriverLVI * It;
939 QListViewItem * Sub; 955 QListViewItem * Sub;
940 QListViewItem * First = 0; 956 QListViewItem * First = 0;
941 OTDriver* D; 957 OTDriver* D;
942 OTDriverList & DL = OT->getDriverList(); 958 OTDriverList & DL = OT->getDriverList();
943 959
944 AllDrivers_LV->clear(); 960 AllDrivers_LV->clear();
945 for( unsigned int i = 0; 961 for( unsigned int i = 0;
946 i < DL.count(); 962 i < DL.count();
947 i ++ ) { 963 i ++ ) {
948 D = DL[i]; 964 D = DL[i];
949 It = new DriverLVI( D, AllDrivers_LV ); 965 It = new DriverLVI( D, AllDrivers_LV );
950 966
951 if( ! First ) 967 if( ! First )
952 First = It; 968 First = It;
953 969
954 It->setText( 0, D->devname() ); 970 It->setText( 0, D->devname() );
955 It->setPixmap( 0, 971 It->setPixmap( 0,
956 Icons->loadPixmap( (D->isUp()) ? 972 Icons->loadPixmap( (D->isUp()) ?
957 "bluezon" : "bluezoff" ) ); 973 "bluezon" : "bluezoff" ) );
958 974
959 Sub = new QListViewItem( It ); 975 Sub = new QListViewItem( It );
960 Sub->setText( 0, tr( "Name" ) ); 976 Sub->setText( 0, tr( "Name" ) );
961 Sub->setText( 1, D->name() ); 977 Sub->setText( 1, D->name() );
962 978
963 Sub = new QListViewItem( It ); 979 Sub = new QListViewItem( It );
964 Sub->setText( 0, tr( "Address" ) ); 980 Sub->setText( 0, tr( "Address" ) );
965 Sub->setText( 1, D->address().toString() ); 981 Sub->setText( 1, D->address().toString() );
966 982
967 Sub = new QListViewItem( It ); 983 Sub = new QListViewItem( It );
968 Sub->setText( 0, tr( "Revision" ) ); 984 Sub->setText( 0, tr( "Revision" ) );
969 Sub->setText( 1, D->revision() ); 985 Sub->setText( 1, D->revision() );
970 986
971 Sub = new QListViewItem( It ); 987 Sub = new QListViewItem( It );
972 Sub->setText( 0, tr( "Manufacturer" ) ); 988 Sub->setText( 0, tr( "Manufacturer" ) );
973 Sub->setText( 1, D->manufacturer() ); 989 Sub->setText( 1, D->manufacturer() );
974 990
975 QString Service, Device; 991 QString Service, Device;
976 D->getClass( Service, Device ); 992 D->getClass( Service, Device );
977 993
978 Sub = new QListViewItem( It ); 994 Sub = new QListViewItem( It );
979 Sub->setText( 0, tr( "Service classes" ) ); 995 Sub->setText( 0, tr( "Service classes" ) );
980 Sub->setText( 1, Service ); 996 Sub->setText( 1, Service );
981 Sub = new QListViewItem( It ); 997 Sub = new QListViewItem( It );
982 Sub->setText( 0, tr( "Device class" ) ); 998 Sub->setText( 0, tr( "Device class" ) );
983 Sub->setText( 1, Device ); 999 Sub->setText( 1, Device );
984 } 1000 }
985 1001
986 if( DL.count() ) { 1002 if( DL.count() ) {
987 AllDrivers_LV->setCurrentItem( First ); 1003 AllDrivers_LV->setCurrentItem( First );
988 DriverIsUp_CB->setEnabled( TRUE ); 1004 DriverIsUp_CB->setEnabled( TRUE );
989 } else { 1005 } else {
990 DriverIsUp_CB->setChecked( FALSE ); 1006 DriverIsUp_CB->setChecked( FALSE );
991 DriverIsUp_CB->setEnabled( FALSE ); 1007 DriverIsUp_CB->setEnabled( FALSE );
992 } 1008 }
993} 1009}
994 1010
995void OTManage::SLOT_SetRefreshTimer( int v ) { 1011void OTManage::SLOT_SetRefreshTimer( int v ) {
996 OT->setRefreshTimer( v * 1000 ); 1012 OT->setRefreshTimer( v * 1000 );
997} 1013}
998 1014
999// 1015//
1000// 1016//
1001// 1017//
1002// 1018//
1003// 1019//
1004 1020
1005OTMain::OTMain( QWidget * parent ) : OTMainGUI( parent ) { 1021OTMain::OTMain( QWidget * parent ) : OTMainGUI( parent ) {
1006 1022
1007 Icons = new OTIcons(); 1023 Icons = new OTIcons();
1008 SnifWindow = 0; 1024 SnifWindow = 0;
1009 OT = OTGateway::getOTGateway(); 1025 OT = OTGateway::getOTGateway();
1010 1026
1011 connect( OT, 1027 connect( OT,
1012 SIGNAL( deviceEnabled( bool ) ), 1028 SIGNAL( deviceEnabled( bool ) ),
1013 this, 1029 this,
1014 SLOT( SLOT_DeviceIsEnabled( bool ) ) 1030 SLOT( SLOT_DeviceIsEnabled( bool ) )
1015 ); 1031 );
1016 connect( OT, 1032 connect( OT,
1017 SIGNAL( driverListChanged() ), 1033 SIGNAL( driverListChanged() ),
1018 this, 1034 this,
1019 SLOT( SLOT_DriverListChanged() ) 1035 SLOT( SLOT_DriverListChanged() )
1020 ); 1036 );
1021 connect( OT, 1037 connect( OT,
1022 SIGNAL( stateChange( OTDriver *, bool ) ), 1038 SIGNAL( stateChange( OTDriver *, bool ) ),
1023 this, 1039 this,
1024 SLOT( SLOT_StateChange( OTDriver *, bool ) ) 1040 SLOT( SLOT_StateChange( OTDriver *, bool ) )
1025 ); 1041 );
1026 1042
1027 if( ! OT->needsEnabling() ) { 1043 if( ! OT->needsEnabling() ) {
1028 MustBeEnabled_CB->hide(); 1044 MustBeEnabled_CB->hide();
1029 } else { 1045 } else {
1030 // detect current state 1046 // detect current state
1031 MustBeEnabled_CB->setChecked( 1047 MustBeEnabled_CB->setChecked(
1032 OT->isEnabled() ); 1048 OT->isEnabled() );
1033 } 1049 }
1034 1050
1035 SLOT_DriverListChanged(); 1051 SLOT_DriverListChanged();
1036} 1052}
1037 1053
1038OTMain::~OTMain() { 1054OTMain::~OTMain() {
1039 OTGateway::releaseOTGateway(); 1055 OTGateway::releaseOTGateway();
1040 delete Icons; 1056 delete Icons;
1041} 1057}
1042 1058
1043void OTMain::SLOT_DriverListChanged() { 1059void OTMain::SLOT_DriverListChanged() {
1044 OTDriver * D; 1060 OTDriver * D;
1045 OTDriverList & DL = OT->getDriverList(); 1061 OTDriverList & DL = OT->getDriverList();
1046 1062
1047 DeviceList_CB->clear(); 1063 DeviceList_CB->clear();
1048 for( unsigned int i = 0; 1064 for( unsigned int i = 0;
1049 i < DL.count(); 1065 i < DL.count();
1050 i ++ ) { 1066 i ++ ) {
1051 D = DL[i]; 1067 D = DL[i];
1052 DeviceList_CB->insertItem( 1068 DeviceList_CB->insertItem(
1053 Icons->loadPixmap( (D->isUp()) ? 1069 Icons->loadPixmap( (D->isUp()) ?
1054 "bluezon" : "bluezoff" ), 1070 "bluezon" : "bluezoff" ),
1055 D->devname() ); 1071 D->devname() );
1056 if( D == OT->scanWith() ) { 1072 if( D == OT->scanWith() ) {
1057 DeviceList_CB->setCurrentItem( i ); 1073 DeviceList_CB->setCurrentItem( i );
1058 } 1074 }
1059 } 1075 }
1060 1076
1061 Scan_But->setEnabled( OT->getDriverList().count() > 0 ); 1077 Scan_But->setEnabled( OT->getDriverList().count() > 0 );
1062 DeviceList_CB->setEnabled( OT->getDriverList().count() > 0 ); 1078 DeviceList_CB->setEnabled( OT->getDriverList().count() > 0 );
1063} 1079}
1064 1080
1065void OTMain::SLOT_EnableBluetooth( bool Up ) { 1081void OTMain::SLOT_EnableBluetooth( bool Up ) {
1066 OT->SLOT_SetEnabled( Up ); 1082 OT->SLOT_SetEnabled( Up );
1067} 1083}
1068 1084
1069void OTMain::SLOT_DeviceIsEnabled( bool Up ) { 1085void OTMain::SLOT_DeviceIsEnabled( bool Up ) {
1070 MustBeEnabled_CB->blockSignals( TRUE ); 1086 MustBeEnabled_CB->blockSignals( TRUE );
1071 MustBeEnabled_CB->setChecked( Up ); 1087 MustBeEnabled_CB->setChecked( Up );
1072 MustBeEnabled_CB->blockSignals( FALSE ); 1088 MustBeEnabled_CB->blockSignals( FALSE );
1073} 1089}
1074 1090
1075void OTMain::SLOT_Manage( void ) { 1091void OTMain::SLOT_Manage( void ) {
1076 QDialog * Dlg = new QDialog( this, 0, TRUE ); 1092 QDialog * Dlg = new QDialog( this, 0, TRUE );
1077 QVBoxLayout * V = new QVBoxLayout( Dlg ); 1093 QVBoxLayout * V = new QVBoxLayout( Dlg );
1078 OTManage * Mng = new OTManage( Dlg, Icons ); 1094 OTManage * Mng = new OTManage( Dlg, Icons );
1079 1095
1080 V->addWidget( Mng ); 1096 V->addWidget( Mng );
1081 1097
1082 Dlg->setCaption( tr("Manage local devices" ) ); 1098 Dlg->setCaption( tr("Manage local devices" ) );
1083 Dlg->showMaximized(); 1099 Dlg->showMaximized();
1084 Dlg->exec(); 1100 Dlg->exec();
1085 delete Dlg; 1101 delete Dlg;
1086} 1102}
1087 1103
1088void OTMain::SLOT_Scan( void ) { 1104void OTMain::SLOT_Scan( void ) {
1089 OTDriverList & DL = OT->getDriverList(); 1105 OTDriverList & DL = OT->getDriverList();
1090 for( unsigned int i = 0; 1106 for( unsigned int i = 0;
1091 i < DL.count(); 1107 i < DL.count();
1092 i ++ ) { 1108 i ++ ) {
1093 if( DL[i]->isUp() && 1109 if( DL[i]->isUp() &&
1094 DL[i]->devname() == DeviceList_CB->currentText() 1110 DL[i]->devname() == DeviceList_CB->currentText()
1095 ) { 1111 ) {
1096 QDialog * Dlg = new QDialog( this, 0, TRUE ); 1112 QDialog * Dlg = new QDialog( this, 0, TRUE );
1097 QVBoxLayout * V = new QVBoxLayout( Dlg ); 1113 QVBoxLayout * V = new QVBoxLayout( Dlg );
1098 OTScan * Scn = new OTScan( Dlg, Icons ); 1114 OTScan * Scn = new OTScan( Dlg, Icons );
1099 1115
1100 OT->setScanWith( OT->driver(i) ); 1116 OT->setScanWith( OT->driver(i) );
1101 V->addWidget( Scn ); 1117 V->addWidget( Scn );
1102 Dlg->setCaption( tr("Scan Neighbourhood" ) ); 1118 Dlg->setCaption( tr("Scan Neighbourhood" ) );
1103 Dlg->showMaximized(); 1119 Dlg->showMaximized();
1104 Dlg->exec(); 1120 Dlg->exec();
1105 1121
1106 delete Dlg; 1122 delete Dlg;
1107 return; 1123 return;
1108 } 1124 }
1109 } 1125 }
1110 1126
1111} 1127}
1112 1128
1113void OTMain::SLOT_StateChange( OTDriver * D, bool Up ) { 1129void OTMain::SLOT_StateChange( OTDriver * D, bool Up ) {
1114 for( int i = 0; 1130 for( int i = 0;
1115 i < DeviceList_CB->count(); 1131 i < DeviceList_CB->count();
1116 i ++ ) { 1132 i ++ ) {
1117 if( DeviceList_CB->text(i) == D->devname() ) { 1133 if( DeviceList_CB->text(i) == D->devname() ) {
1118 DeviceList_CB->changeItem( 1134 DeviceList_CB->changeItem(
1119 Icons->loadPixmap( (Up) ? "bluezon" : "bluezoff" ), 1135 Icons->loadPixmap( (Up) ? "bluezon" : "bluezoff" ),
1120 D->devname(), 1136 D->devname(),
1121 i ); 1137 i );
1122 return; 1138 return;
1123 } 1139 }
1124 } 1140 }
1125} 1141}
1126 1142
1127void OTMain::SLOT_Pairing( void ) { 1143void OTMain::SLOT_Pairing( void ) {
1128 QDialog * Dlg = new QDialog( this, 0, TRUE ); 1144 QDialog * Dlg = new QDialog( this, 0, TRUE );
1129 QVBoxLayout * V = new QVBoxLayout( Dlg ); 1145 QVBoxLayout * V = new QVBoxLayout( Dlg );
1130 OTPairing * Pair = new OTPairing( Dlg, Icons ); 1146 OTPairing * Pair = new OTPairing( Dlg, Icons );
1131 1147
1132 V->addWidget( Pair ); 1148 V->addWidget( Pair );
1133 Dlg->showMaximized(); 1149 Dlg->showMaximized();
1134 Dlg->setCaption( tr("Manage pairing" ) ); 1150 Dlg->setCaption( tr("Manage pairing" ) );
1135 Dlg->exec(); 1151 Dlg->exec();
1136 1152
1137 delete Dlg; 1153 delete Dlg;
1138} 1154}
1139 1155
1140void OTMain::SLOT_Sniffing( void ) { 1156void OTMain::SLOT_Sniffing( void ) {
1141 1157
1142 if( SnifWindow == 0 ) { 1158 if( SnifWindow == 0 ) {
1143 SnifWindow = new QDialog( this, 0, FALSE ); 1159 SnifWindow = new QDialog( this, 0, FALSE );
1144 QVBoxLayout * V = new QVBoxLayout( SnifWindow ); 1160 QVBoxLayout * V = new QVBoxLayout( SnifWindow );
1145 OTSniffing * SN = new OTSniffing( SnifWindow ); 1161 OTSniffing * SN = new OTSniffing( SnifWindow );
1146 V->addWidget( SN ); 1162 V->addWidget( SN );
1147 } 1163 }
1148 1164
1149 SnifWindow->showMaximized(); 1165 SnifWindow->showMaximized();
1150 SnifWindow->show(); 1166 SnifWindow->show();
1151} 1167}
diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.h b/noncore/settings/networksettings2/opietooth2/Opietooth.h
index 2b20975..e66787f 100644
--- a/noncore/settings/networksettings2/opietooth2/Opietooth.h
+++ b/noncore/settings/networksettings2/opietooth2/Opietooth.h
@@ -1,240 +1,238 @@
1#ifndef OPIETOOTH_H 1#ifndef OPIETOOTH_H
2#define OPIETOOTH_H 2#define OPIETOOTH_H
3 3
4#include <OTIcons.h> 4#include <OTIcons.h>
5 5
6class MyProcess; 6class MyProcess;
7class System;
8 7
9namespace Opie { 8namespace Opie {
10 9
11 namespace Ui { 10 namespace Ui {
12 11
13 class OLedBox; 12 class OLedBox;
14 13
15 }; 14 };
16 15
17}; 16};
18 17
19#include <OTSniffGUI.h> 18#include <OTSniffGUI.h>
20namespace Opietooth2 { 19namespace Opietooth2 {
21 20
22class OTGateway; 21class OTGateway;
23class OTDriver; 22class OTDriver;
24class OTInquiry; 23class OTInquiry;
25class OTPeer; 24class OTPeer;
26class PeerLVI; 25class PeerLVI;
27 26
28class OTSniffing : public OTSniffGUI { 27class OTSniffing : public OTSniffGUI {
29 28
30 Q_OBJECT 29 Q_OBJECT
31 30
32public : 31public :
33 32
34 OTSniffing( QWidget * parent ); 33 OTSniffing( QWidget * parent );
35 ~OTSniffing(); 34 ~OTSniffing();
36 35
37private slots : 36private slots :
38 37
39 void SLOT_Trace( bool ); 38 void SLOT_Trace( bool );
40 void SLOT_ClearLog( void ); 39 void SLOT_ClearLog( void );
41 void SLOT_Load( void ); 40 void SLOT_Load( void );
42 void SLOT_Save( void ); 41 void SLOT_Save( void );
43 void SLOT_ProcessExited( MyProcess * ); 42 void SLOT_ProcessExited( MyProcess * );
44 void SLOT_Show( const QString & ); 43 void SLOT_Show( const QString & );
45 44
46signals : 45signals :
47 46
48protected : 47protected :
49 48
50private : 49private :
51 50
52 OTGateway * OT; 51 OTGateway * OT;
53 MyProcess * HciDump; 52 MyProcess * HciDump;
54 System * Sys;
55}; 53};
56}; 54};
57 55
58#include <OTPairingGUI.h> 56#include <OTPairingGUI.h>
59 57
60namespace Opietooth2 { 58namespace Opietooth2 {
61class OTPairing : public OTPairingGUI { 59class OTPairing : public OTPairingGUI {
62 60
63 Q_OBJECT 61 Q_OBJECT
64 62
65public : 63public :
66 64
67 OTPairing( QWidget * parent, 65 OTPairing( QWidget * parent,
68 OTIcons * _Ic = 0 ); 66 OTIcons * _Ic = 0 );
69 ~OTPairing(); 67 ~OTPairing();
70 68
71private slots : 69private slots :
72 70
73 void SLOT_Unpair( void ); 71 void SLOT_Unpair( void );
74 72
75signals : 73signals :
76 74
77protected : 75protected :
78 76
79private : 77private :
80 78
81 bool MyIcons; 79 bool MyIcons;
82 OTIcons * Icons; 80 OTIcons * Icons;
83 OTGateway * OT; 81 OTGateway * OT;
84}; 82};
85}; 83};
86 84
87#include <OTScanGUI.h> 85#include <OTScanGUI.h>
88 86
89namespace Opietooth2 { 87namespace Opietooth2 {
90 88
91class OTGateway; 89class OTGateway;
92class OTDriver; 90class OTDriver;
93class OTInquiry; 91class OTInquiry;
94class OTPeer; 92class OTPeer;
95 93
96class OTScan : public OTScanGUI { 94class OTScan : public OTScanGUI {
97 95
98 Q_OBJECT 96 Q_OBJECT
99 97
100public : 98public :
101 99
102 OTScan( QWidget * parent, 100 OTScan( QWidget * parent,
103 OTIcons * _Ic = 0 ); 101 OTIcons * _Ic = 0 );
104 ~OTScan(); 102 ~OTScan();
105 103
106 // static function to return a device and a channel 104 // static function to return a device and a channel
107 static int getDevice( OTPeer *& Peer, 105 static int getDevice( OTPeer *& Peer,
108 int & Channel, 106 int & Channel,
109 OTGateway * OT, 107 OTGateway * OT,
110 const UUIDVector & Filter = 0, 108 const UUIDVector & Filter = 0,
111 QWidget* Parent = 0); 109 QWidget* Parent = 0);
112 110
113 // show only services that match any of the filter 111 // show only services that match any of the filter
114 void setScanFilter( const UUIDVector & Filter ); 112 void setScanFilter( const UUIDVector & Filter );
115 void resetScanFilter( void ); 113 void resetScanFilter( void );
116 114
117 inline OTPeer * selectedPeer( void ) 115 inline OTPeer * selectedPeer( void )
118 { return SelectedPeer; } 116 { return SelectedPeer; }
119 inline int selectedChannel( void ) 117 inline int selectedChannel( void )
120 { return SelectedChannel; } 118 { return SelectedChannel; }
121 119
122public slots : 120public slots :
123 121
124private slots : 122private slots :
125 123
126 void SLOT_DoScan( bool ); 124 void SLOT_DoScan( bool );
127 void SLOT_NewPeer( OTPeer *, bool ); 125 void SLOT_NewPeer( OTPeer *, bool );
128 void SLOT_FinishedDetecting(); 126 void SLOT_FinishedDetecting();
129 void SLOT_Show( QListViewItem *); 127 void SLOT_Show( QListViewItem *);
130 void SLOT_RefreshServices( void ); 128 void SLOT_RefreshServices( void );
131 void SLOT_RefreshState( void ); 129 void SLOT_RefreshState( void );
132 void SLOT_CleanupOld( void ); 130 void SLOT_CleanupOld( void );
133 void SLOT_UpdateStrength( void ); 131 void SLOT_UpdateStrength( void );
134 void SLOT_PeerState( OTPeer * ); 132 void SLOT_PeerState( OTPeer * );
135 void SLOT_Selected( QListViewItem * ); 133 void SLOT_Selected( QListViewItem * );
136 134
137signals : 135signals :
138 136
139 void selected( void ); 137 void selected( void );
140 138
141protected : 139protected :
142 140
143private : 141private :
144 142
145 void refreshState( PeerLVI *, bool ); 143 void refreshState( PeerLVI *, bool );
146 void scanMode( bool ); 144 void scanMode( bool );
147 145
148 // load scanned devices 146 // load scanned devices
149 147
150 bool MyIcons; 148 bool MyIcons;
151 OTIcons * Icons; 149 OTIcons * Icons;
152 OTGateway * OT; 150 OTGateway * OT;
153 OTInquiry * Scanning; 151 OTInquiry * Scanning;
154 UUIDVector Filter; 152 UUIDVector Filter;
155 153
156 Opie::Ui::OLedBox * Paired_Led; 154 Opie::Ui::OLedBox * Paired_Led;
157 QTimer * StrengthTimer; 155 QTimer * StrengthTimer;
158 PeerLVI * Current; 156 PeerLVI * Current;
159 157
160 OTPeer * SelectedPeer; 158 OTPeer * SelectedPeer;
161 int SelectedChannel; 159 int SelectedChannel;
162}; 160};
163}; 161};
164 162
165#include <OTManageGUI.h> 163#include <OTManageGUI.h>
166namespace Opietooth2 { 164namespace Opietooth2 {
167 165
168class OTManage : public OTManageGUI { 166class OTManage : public OTManageGUI {
169 167
170 Q_OBJECT 168 Q_OBJECT
171 169
172public : 170public :
173 171
174 OTManage( QWidget * parent, 172 OTManage( QWidget * parent,
175 OTIcons * _IC = 0 ); 173 OTIcons * _IC = 0 );
176 ~OTManage(); 174 ~OTManage();
177 175
178public slots : 176public slots :
179 177
180private slots : 178private slots :
181 179
182 void SLOT_ShowDriver( QListViewItem * ); 180 void SLOT_ShowDriver( QListViewItem * );
183 void SLOT_UpDriver( bool ); 181 void SLOT_UpDriver( bool );
184 void SLOT_StateChange( OTDriver * , bool ); 182 void SLOT_StateChange( OTDriver * , bool );
185 void SLOT_DriverListChanged(); 183 void SLOT_DriverListChanged();
186 void SLOT_SetRefreshTimer( int ); 184 void SLOT_SetRefreshTimer( int );
187 185
188signals : 186signals :
189 187
190protected : 188protected :
191 189
192private : 190private :
193 191
194 // load scanned devices 192 // load scanned devices
195 193
196 bool MyIcons; 194 bool MyIcons;
197 OTIcons * Icons; 195 OTIcons * Icons;
198 OTGateway * OT; 196 OTGateway * OT;
199 OTInquiry * Scanning; 197 OTInquiry * Scanning;
200}; 198};
201}; 199};
202 200
203#include <OTMainGUI.h> 201#include <OTMainGUI.h>
204 202
205namespace Opietooth2 { 203namespace Opietooth2 {
206class OTMain : public OTMainGUI { 204class OTMain : public OTMainGUI {
207 205
208 Q_OBJECT 206 Q_OBJECT
209 207
210public : 208public :
211 209
212 OTMain( QWidget * parent ); 210 OTMain( QWidget * parent );
213 ~OTMain(); 211 ~OTMain();
214 212
215public slots : 213public slots :
216 214
217private slots : 215private slots :
218 216
219 void SLOT_Pairing( void ); 217 void SLOT_Pairing( void );
220 void SLOT_Manage( void ); 218 void SLOT_Manage( void );
221 void SLOT_Sniffing( void ); 219 void SLOT_Sniffing( void );
222 void SLOT_Scan( void ); 220 void SLOT_Scan( void );
223 void SLOT_EnableBluetooth( bool ); 221 void SLOT_EnableBluetooth( bool );
224 void SLOT_DriverListChanged(); 222 void SLOT_DriverListChanged();
225 void SLOT_DeviceIsEnabled( bool ); 223 void SLOT_DeviceIsEnabled( bool );
226 void SLOT_StateChange( OTDriver * , bool ); 224 void SLOT_StateChange( OTDriver * , bool );
227 225
228signals : 226signals :
229 227
230protected : 228protected :
231 229
232private : 230private :
233 231
234 // load scanned devices 232 // load scanned devices
235 OTIcons * Icons; 233 OTIcons * Icons;
236 OTGateway * OT; 234 OTGateway * OT;
237 QDialog * SnifWindow; 235 QDialog * SnifWindow;
238}; 236};
239}; 237};
240#endif 238#endif