summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-06 15:15:01 (UTC)
committer wimpie <wimpie>2005-01-06 15:15:01 (UTC)
commit0baf6b4c6862738d712f479cb7e99a5f2534d74d (patch) (unidiff)
treefb02c5279fb7e3949c08e51202ada1caf5e408fa
parentba9ce5a0fcd66031ade038f7e6a7ac26908225a5 (diff)
downloadopie-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)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/gprs/opie-networksettings2plugin-network.control2
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp53
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.h7
-rw-r--r--noncore/settings/networksettings2/opietooth2/Opietooth.cpp136
-rw-r--r--noncore/settings/networksettings2/opietooth2/Opietooth.h23
-rw-r--r--noncore/settings/networksettings2/opietooth2/libopietooth2.control2
-rw-r--r--noncore/settings/networksettings2/opietooth2/opietooth2.pro4
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 @@
1Package: opie-networksettings2plugin-GPRS 1Package: opie-networksettings2plugin-gprs
2Files: plugins/networksettings2/libGPRS.so* 2Files: plugins/networksettings2/libGPRS.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: opie-networksettings2, libopiecore2, libopienet2 7Depends: opie-networksettings2, libopiecore2, libopienet2
8Description: Setup GPRS network 8Description: Setup GPRS network
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $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,145 +1,158 @@
1#include <sys/types.h> 1#include <sys/types.h>
2#include <sys/wait.h> 2#include <sys/wait.h>
3 3
4#include <net/if.h> 4#include <net/if.h>
5#include <net/if_arp.h> 5#include <net/if_arp.h>
6#include <netinet/in.h> 6#include <netinet/in.h>
7#include <arpa/inet.h> 7#include <arpa/inet.h>
8#include <sys/ioctl.h> 8#include <sys/ioctl.h>
9#include <sys/socket.h> 9#include <sys/socket.h>
10#include <stdlib.h> 10#include <stdlib.h>
11#include <stdio.h> 11#include <stdio.h>
12#include <fcntl.h> 12#include <fcntl.h>
13#include <errno.h> 13#include <errno.h>
14#include <unistd.h> 14#include <unistd.h>
15 15
16#include <opie2/oprocess.h> 16#include <opie2/oprocess.h>
17 17
18#include <qdir.h> 18#include <qdir.h>
19#include <qregexp.h> 19#include <qregexp.h>
20#include <qstringlist.h> 20#include <qstringlist.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qtextstream.h> 22#include <qtextstream.h>
23#include <qapplication.h> 23#include <qapplication.h>
24 24
25#include "resources.h" 25#include "resources.h"
26#include "system.h" 26#include "system.h"
27 27
28#define PROCNETDEV "/proc/net/dev" 28#define PROCNETDEV "/proc/net/dev"
29 29
30#ifndef ARPHRD_IEEE80211 30#ifndef ARPHRD_IEEE80211
31#define ARPHRD_IEEE80211 801 31#define ARPHRD_IEEE80211 801
32#endif 32#endif
33 33
34static char Dig2Hex[] = { 34static char Dig2Hex[] = {
35 '0', '1', '2', '3', 35 '0', '1', '2', '3',
36 '4', '5', '6', '7', 36 '4', '5', '6', '7',
37 '8', '9', 'A', 'B', 37 '8', '9', 'A', 'B',
38 'C', 'D', 'E', 'F' 38 'C', 'D', 'E', 'F'
39}; 39};
40 40
41// get HIGH nibble of byte 41// get HIGH nibble of byte
42#define HN(x) Dig2Hex[(((x)&0xf0)>>4)] 42#define HN(x) Dig2Hex[(((x)&0xf0)>>4)]
43// get LOW nibble of byte 43// get LOW nibble of byte
44#define LN(x) Dig2Hex[((x)&0x0f)] 44#define LN(x) Dig2Hex[((x)&0x0f)]
45 45
46System::System( void ) : QObject(), ProbedInterfaces() { 46System::System( void ) : QObject(), ProbedInterfaces() {
47 probeInterfaces();
48} 47}
49 48
50System::~System( void ) { 49System::~System( void ) {
51 if( ProcDevNet ) 50 if( ProcDevNet )
52 delete ProcDevNet; 51 delete ProcDevNet;
53} 52}
54 53
55int System::runAsRoot( QStringList & S ) { 54QDict<InterfaceInfo> & System::interfaces( void ) {
55 if( ProbedInterfaces.count() == 0 ) {
56 probeInterfaces();
57 }
58 return ProbedInterfaces;
59}
60
61int 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
108int System::execAsUser( QStringList & SL ) { 121int 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
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
@@ -51,85 +51,84 @@ private :
51class InterfaceInfo { 51class InterfaceInfo {
52 52
53public : 53public :
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
90class System : public QObject { 90class System : public QObject {
91 91
92 Q_OBJECT 92 Q_OBJECT
93 93
94public : 94public :
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
118private slots : 117private slots :
119 118
120 void SLOT_ProcessExited( MyProcess * ); 119 void SLOT_ProcessExited( MyProcess * );
121 120
122signals : 121signals :
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
128private : 127private :
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,173 +1,284 @@
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
3using namespace Opie::Core; 5using namespace Opie::Core;
4using namespace Opie::Ui; 6using 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
30using namespace Opietooth2; 36using namespace Opietooth2;
31 37
32namespace Opietooth2 { 38namespace Opietooth2 {
33 39
34class PeerLVI : public QListViewItem { 40class PeerLVI : public QListViewItem {
35 41
36public : 42public :
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
47private : 53private :
48 54
49 OTPeer * Peer; 55 OTPeer * Peer;
50}; 56};
51 57
52class ChannelLVI : public QListViewItem { 58class ChannelLVI : public QListViewItem {
53 59
54public : 60public :
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
65private : 71private :
66 72
67 int Channel; 73 int Channel;
68}; 74};
69 75
70class DriverLVI : public QListViewItem { 76class DriverLVI : public QListViewItem {
71 77
72public : 78public :
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
83private : 89private :
84 90
85 OTDriver * Driver; 91 OTDriver * Driver;
86}; 92};
87 93
88class LinkKeyLVI : public QListViewItem { 94class LinkKeyLVI : public QListViewItem {
89 95
90public : 96public :
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
101private : 107private :
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
113OTSniffing::OTSniffing( QWidget * parent ) : OTSniffGUI( parent ) { 119OTSniffing::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
119OTSniffing::~OTSniffing() { 126OTSniffing::~OTSniffing() {
127 printf( "CLOSE \n" );
128 if ( HciDump ) {
129 HciDump->process().kill();
130 delete HciDump;
131 }
132 delete Sys;
120} 133}
121 134
122void OTSniffing::SLOT_Trace( void ) { 135void 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
176void 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
183void OTSniffing::SLOT_ProcessExited( MyProcess * ) {
184 printf( "Exited\n" );
185 delete HciDump;
186 HciDump = 0;
187}
188
189void 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
211void 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
125void OTSniffing::SLOT_ClearLog( void ) { 235void OTSniffing::SLOT_ClearLog( void ) {
236 Output_LB->clear();
126} 237}
127 238
128// 239//
129// 240//
130// 241//
131// 242//
132// 243//
133 244
134OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : 245OTPairing::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 {
@@ -984,54 +1095,57 @@ void OTMain::SLOT_Scan( void ) {
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
1002void OTMain::SLOT_StateChange( OTDriver * D, bool Up ) { 1113void 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
1016void OTMain::SLOT_Pairing( void ) { 1127void 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
1029void OTMain::SLOT_Sniffing( void ) { 1140void 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,85 +1,102 @@
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
6namespace Opie { namespace Ui { class OLedBox; }; }; 6class MyProcess;
7class System;
8
9namespace Opie {
10
11 namespace Ui {
12
13 class OLedBox;
14
15 };
16
17};
7 18
8#include <OTSniffGUI.h> 19#include <OTSniffGUI.h>
9namespace Opietooth2 { 20namespace Opietooth2 {
10 21
11class OTGateway; 22class OTGateway;
12class OTDriver; 23class OTDriver;
13class OTInquiry; 24class OTInquiry;
14class OTPeer; 25class OTPeer;
15class PeerLVI; 26class PeerLVI;
16 27
17class OTSniffing : public OTSniffGUI { 28class OTSniffing : public OTSniffGUI {
18 29
19 Q_OBJECT 30 Q_OBJECT
20 31
21public : 32public :
22 33
23 OTSniffing( QWidget * parent ); 34 OTSniffing( QWidget * parent );
24 ~OTSniffing(); 35 ~OTSniffing();
25 36
26private slots : 37private 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
31signals : 46signals :
32 47
33protected : 48protected :
34 49
35private : 50private :
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
43namespace Opietooth2 { 60namespace Opietooth2 {
44class OTPairing : public OTPairingGUI { 61class OTPairing : public OTPairingGUI {
45 62
46 Q_OBJECT 63 Q_OBJECT
47 64
48public : 65public :
49 66
50 OTPairing( QWidget * parent, 67 OTPairing( QWidget * parent,
51 OTIcons * _Ic = 0 ); 68 OTIcons * _Ic = 0 );
52 ~OTPairing(); 69 ~OTPairing();
53 70
54private slots : 71private slots :
55 72
56 void SLOT_Unpair( void ); 73 void SLOT_Unpair( void );
57 74
58signals : 75signals :
59 76
60protected : 77protected :
61 78
62private : 79private :
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
72namespace Opietooth2 { 89namespace Opietooth2 {
73 90
74class OTGateway; 91class OTGateway;
75class OTDriver; 92class OTDriver;
76class OTInquiry; 93class OTInquiry;
77class OTPeer; 94class OTPeer;
78 95
79class OTScan : public OTScanGUI { 96class OTScan : public OTScanGUI {
80 97
81 Q_OBJECT 98 Q_OBJECT
82 99
83public : 100public :
84 101
85 OTScan( QWidget * parent, 102 OTScan( QWidget * parent,
@@ -172,52 +189,52 @@ signals :
172 189
173protected : 190protected :
174 191
175private : 192private :
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
188namespace Opietooth2 { 205namespace Opietooth2 {
189class OTMain : public OTMainGUI { 206class OTMain : public OTMainGUI {
190 207
191 Q_OBJECT 208 Q_OBJECT
192 209
193public : 210public :
194 211
195 OTMain( QWidget * parent ); 212 OTMain( QWidget * parent );
196 ~OTMain(); 213 ~OTMain();
197 214
198public slots : 215public slots :
199 216
200private slots : 217private 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
211signals : 228signals :
212 229
213protected : 230protected :
214 231
215private : 232private :
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 @@
1Package: libopietooth2 1Package: libopietooth2
2Files: lib/libopietooth2.so.* apps/Settings/opietooth-manager.desktop pics/opietooth/*.png pics/opietooth/icons/*.png 2Files: lib/libopietooth2.so.* apps/Settings/opietooth-manager.desktop pics/opietooth/*.png pics/opietooth/icons/*.png
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: wim delvaux <wim.delvaux@handhelds.org> 5Maintainer: wim delvaux <wim.delvaux@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION$EXTRAVERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, libbluetooth1, opie-bluepin | opie-multiauth-bluepingplugin, bluez-utils-nodbus 8Depends: task-opie-minimal, opie-networksettings2, libbluetooth1, opie-bluepin | opie-multiauth-bluepingplugin, bluez-utils-nodbus
9Description: Opie bluetooth support library version 2 9Description: 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 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on release 2CONFIG += 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
32LIBS += -lqpe -lopiecore2 -lbluetooth 32LIBS += -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
37include ( $(OPIEDIR)/include.pro ) 37include ( $(OPIEDIR)/include.pro )