-rw-r--r-- | noncore/securityplugins/blueping/bluepingplugin.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/securityplugins/blueping/bluepingplugin.cpp b/noncore/securityplugins/blueping/bluepingplugin.cpp index 1c514e5..05c26ba 100644 --- a/noncore/securityplugins/blueping/bluepingplugin.cpp +++ b/noncore/securityplugins/blueping/bluepingplugin.cpp | |||
@@ -134,92 +134,96 @@ int BluepingPlugin::authenticate() { | |||
134 | QRect desk = oApp->desktop()->geometry(); | 134 | QRect desk = oApp->desktop()->geometry(); |
135 | bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() ); | 135 | bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() ); |
136 | 136 | ||
137 | // Creation of the particular widgets of our Blueping user interface | 137 | // Creation of the particular widgets of our Blueping user interface |
138 | QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog); | 138 | QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog); |
139 | layout->setSpacing(11); | 139 | layout->setSpacing(11); |
140 | layout->setMargin(11); | 140 | layout->setMargin(11); |
141 | layout->setAlignment( Qt::AlignTop ); | 141 | layout->setAlignment( Qt::AlignTop ); |
142 | 142 | ||
143 | QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog); | 143 | QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog); |
144 | QLabel subTitle("<center><h2>Trying to reach your configured bluetooth device...</h2></center>", &bluepingDialog); | 144 | QLabel subTitle("<center><h2>Trying to reach your configured bluetooth device...</h2></center>", &bluepingDialog); |
145 | QLabel subTitle2("<center>You can skip this step and use another authentication way with the following button</center>", &bluepingDialog); | 145 | QLabel subTitle2("<center>You can skip this step and use another authentication way with the following button</center>", &bluepingDialog); |
146 | QPushButton pbSkip("Skip", &bluepingDialog); | 146 | QPushButton pbSkip("Skip", &bluepingDialog); |
147 | layout->addWidget(&title); | 147 | layout->addWidget(&title); |
148 | layout->addWidget(&subTitle); | 148 | layout->addWidget(&subTitle); |
149 | layout->addWidget(&subTitle2); | 149 | layout->addWidget(&subTitle2); |
150 | layout->addWidget(&pbSkip, 0, Qt::AlignHCenter); | 150 | layout->addWidget(&pbSkip, 0, Qt::AlignHCenter); |
151 | 151 | ||
152 | // connect the skip button to the skip signal emitting function | 152 | // connect the skip button to the skip signal emitting function |
153 | QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip())); | 153 | QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip())); |
154 | // connect the signal emitting functions to the bluepingDialog done(int) finishing function | 154 | // connect the signal emitting functions to the bluepingDialog done(int) finishing function |
155 | QObject::connect(this, SIGNAL(emitCode(int)), &bluepingDialog, SLOT(done(int))); | 155 | QObject::connect(this, SIGNAL(emitCode(int)), &bluepingDialog, SLOT(done(int))); |
156 | 156 | ||
157 | 157 | ||
158 | 158 | ||
159 | /* let's start Bluetooth if it's not running | 159 | /* let's start Bluetooth if it's not running |
160 | */ | 160 | */ |
161 | OProcess checkB; | 161 | OProcess checkB; |
162 | checkB << "pidof" << "hciattach"; | 162 | checkB << "pidof" << "hciattach"; |
163 | odebug << "checking if Bluetooth is running..." << oendl; | 163 | odebug << "checking if Bluetooth is running..." << oendl; |
164 | // now we start bluetooth *only* if the previous command works, exits normally, and | 164 | // now we start bluetooth *only* if the previous command works, exits normally, and |
165 | // it returns a non-null exit code (which means hciattach is not running) | 165 | // it returns a non-null exit code (which means hciattach is not running) |
166 | if ( checkB.start(OProcess::Block) && checkB.normalExit() && (checkB.exitStatus() != 0) ) | 166 | if ( checkB.start(OProcess::Block) && checkB.normalExit() && (checkB.exitStatus() != 0) ) |
167 | { | 167 | { |
168 | // remember to switch off Bluetooth once we're finished... | 168 | // remember to switch off Bluetooth once we're finished... |
169 | bluetoothWasOff = true; | 169 | bluetoothWasOff = true; |
170 | odebug << "Bluetooth is not running, we must start it now" << oendl; | 170 | odebug << "Bluetooth is not running, we must start it now" << oendl; |
171 | 171 | ||
172 | OProcess startB; | 172 | OProcess startB; |
173 | switch ( ODevice::inst()->model() ) { | 173 | switch ( ODevice::inst()->model() ) { |
174 | case Model_iPAQ_H39xx: | 174 | case Model_iPAQ_H39xx: |
175 | startB << "/sbin/hciattach" << "/dev/tts/1" << "bcsp" << "921600"; | 175 | startB << "/sbin/hciattach" << "/dev/tts/1" << "bcsp" << "921600"; |
176 | break; | 176 | break; |
177 | 177 | ||
178 | case Model_iPAQ_H5xxx: | 178 | case Model_iPAQ_H5xxx: |
179 | startB << "/sbin/hciattach" << "/dev/tts/1" << "any" << "921600"; | 179 | startB << "/sbin/hciattach" << "/dev/tts/1" << "any" << "921600"; |
180 | break; | 180 | break; |
181 | 181 | ||
182 | case Model_MyPal_716: | ||
183 | startB << "/sbin/hciattach" << "/dev/ttyS1" << "bcsp" << "921600"; | ||
184 | break; | ||
185 | |||
182 | default: | 186 | default: |
183 | startB << "/sbin/hciattach" << "/dev/ttySB0" << "bcsp" << "230400"; | 187 | startB << "/sbin/hciattach" << "/dev/ttySB0" << "bcsp" << "230400"; |
184 | break; | 188 | break; |
185 | } // end switch on device models | 189 | } // end switch on device models |
186 | 190 | ||
187 | if ( !startB.start(OProcess::Block) ) { | 191 | if ( !startB.start(OProcess::Block) ) { |
188 | oerr << "could not start Bluetooth" << oendl; | 192 | oerr << "could not start Bluetooth" << oendl; |
189 | return MultiauthPluginObject::Skip; | 193 | return MultiauthPluginObject::Skip; |
190 | } | 194 | } |
191 | else | 195 | else |
192 | { | 196 | { |
193 | if ( (startB.normalExit()) && (startB.exitStatus() == 0) ) | 197 | if ( (startB.normalExit()) && (startB.exitStatus() == 0) ) |
194 | { | 198 | { |
195 | odebug << "hciattach exited normally, Bluetooth is probably on now, let's wait 500 ms and ping" << oendl; | 199 | odebug << "hciattach exited normally, Bluetooth is probably on now, let's wait 500 ms and ping" << oendl; |
196 | // 500 ms timer, so l2ping won't try to find a route before bluetooth has \em really started | 200 | // 500 ms timer, so l2ping won't try to find a route before bluetooth has \em really started |
197 | QTimer::singleShot( 500, this, SLOT(ping()) ); | 201 | QTimer::singleShot( 500, this, SLOT(ping()) ); |
198 | } | 202 | } |
199 | else | 203 | else |
200 | { | 204 | { |
201 | owarn << "hciattach exited anormally (normalExit: " << startB.normalExit() << ", exit status: " << startB.exitStatus() << ")" << oendl; | 205 | owarn << "hciattach exited anormally (normalExit: " << startB.normalExit() << ", exit status: " << startB.exitStatus() << ")" << oendl; |
202 | return MultiauthPluginObject::Skip; | 206 | return MultiauthPluginObject::Skip; |
203 | } // end if startB exited normaly | 207 | } // end if startB exited normaly |
204 | } // end if startBluetooth started | 208 | } // end if startBluetooth started |
205 | } | 209 | } |
206 | else | 210 | else |
207 | { | 211 | { |
208 | // we don't need to wait, since bluetooth has been started long enough ago | 212 | // we don't need to wait, since bluetooth has been started long enough ago |
209 | odebug << "Bluetooth is already running, we can try to ping now" << oendl; | 213 | odebug << "Bluetooth is already running, we can try to ping now" << oendl; |
210 | ping(); | 214 | ping(); |
211 | } // end if Bluetooth was off | 215 | } // end if Bluetooth was off |
212 | 216 | ||
213 | 217 | ||
214 | // start the dialog event loop, while the ping is starting (or will start soon) in the background | 218 | // start the dialog event loop, while the ping is starting (or will start soon) in the background |
215 | return bluepingDialog.exec(); | 219 | return bluepingDialog.exec(); |
216 | 220 | ||
217 | 221 | ||
218 | } | 222 | } |
219 | else | 223 | else |
220 | { | 224 | { |
221 | owarn << "No Bluetooth device has been set!" << oendl; | 225 | owarn << "No Bluetooth device has been set!" << oendl; |
222 | owarn << "We will consider it as a successful authentication though." << oendl; | 226 | owarn << "We will consider it as a successful authentication though." << oendl; |
223 | return MultiauthPluginObject::Success; | 227 | return MultiauthPluginObject::Success; |
224 | } // end if mac defined | 228 | } // end if mac defined |
225 | } | 229 | } |