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