7 files changed, 170 insertions, 27 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,5 +1,5 @@ | |||
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> |
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 | |||
@@ -43,17 +43,23 @@ static char Dig2Hex[] = { | |||
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 |
@@ -68,12 +74,15 @@ int System::runAsRoot( QStringList & S ) { | |||
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 ) { |
81 | P = Prc; | ||
82 | } else { | ||
83 | P = new MyProcess(); | ||
84 | emit processEvent( tr("Command : ") + S.join( " " ) ); | ||
76 | 85 | ||
77 | connect( P, | 86 | connect( P, |
78 | SIGNAL( stdoutLine( const QString & ) ), | 87 | SIGNAL( stdoutLine( const QString & ) ), |
79 | this, | 88 | this, |
@@ -87,14 +96,18 @@ int System::runAsRoot( QStringList & S ) { | |||
87 | connect( P, | 96 | connect( P, |
88 | SIGNAL(processExited(MyProcess*) ), | 97 | SIGNAL(processExited(MyProcess*) ), |
89 | this, SLOT | 98 | this, SLOT |
90 | (SLOT_ProcessExited(MyProcess*) ) ); | 99 | (SLOT_ProcessExited(MyProcess*) ) ); |
100 | } | ||
101 | |||
102 | P->process() << S; | ||
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; |
109 | if( ! Prc ) | ||
97 | delete P; | 110 | delete P; |
98 | // error starting app | 111 | // error starting app |
99 | return 1; | 112 | return 1; |
100 | } | 113 | } |
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 | |||
@@ -95,15 +95,14 @@ 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 | ||
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,24 +1,28 @@ | |||
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> |
@@ -26,8 +30,10 @@ using namespace Opie::Ui; | |||
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 | ||
@@ -112,18 +118,123 @@ private : | |||
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 | // |
@@ -1028,9 +1139,12 @@ void OTMain::SLOT_Pairing( void ) { | |||
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(); |
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 | |||
@@ -2,9 +2,20 @@ | |||
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 | ||
@@ -24,18 +35,24 @@ public : | |||
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> |
@@ -216,8 +233,8 @@ 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 | |||
@@ -4,6 +4,6 @@ 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 | |||
@@ -26,11 +26,11 @@ SOURCES = OTDevice.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 | ||