author | clem <clem> | 2004-08-05 22:55:35 (UTC) |
---|---|---|
committer | clem <clem> | 2004-08-05 22:55:35 (UTC) |
commit | 90ca457fbf420e31eed99c828a23e451bf8dc30c (patch) (unidiff) | |
tree | bb538c99c6157a3e431818594fea92584783fc90 | |
parent | 75286b93291026578a6352797c830787a9401055 (diff) | |
download | opie-90ca457fbf420e31eed99c828a23e451bf8dc30c.zip opie-90ca457fbf420e31eed99c828a23e451bf8dc30c.tar.gz opie-90ca457fbf420e31eed99c828a23e451bf8dc30c.tar.bz2 |
Don't bother with killing bluetooth anymore, since our
/etc/suspend-scripts/S50bluetooth new script does that just when
we need it. Also, don't forget to shut down Bluetooth when we
started it ourselves and when the authentication is finished (skipped or
successfull). Finally, there's more info in the debug output now.
-rw-r--r-- | noncore/securityplugins/blueping/bluepingplugin.cpp | 86 | ||||
-rw-r--r-- | noncore/securityplugins/blueping/bluepingplugin.h | 7 |
2 files changed, 58 insertions, 35 deletions
diff --git a/noncore/securityplugins/blueping/bluepingplugin.cpp b/noncore/securityplugins/blueping/bluepingplugin.cpp index f5d9ad6..1c514e5 100644 --- a/noncore/securityplugins/blueping/bluepingplugin.cpp +++ b/noncore/securityplugins/blueping/bluepingplugin.cpp | |||
@@ -1,203 +1,225 @@ | |||
1 | #include "bluepingplugin.h" | 1 | #include "bluepingplugin.h" |
2 | 2 | ||
3 | #include <opie2/oapplication.h> | 3 | #include <opie2/oapplication.h> |
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | #include <opie2/odevice.h> | 5 | #include <opie2/odevice.h> |
6 | 6 | ||
7 | #include <qdialog.h> | 7 | #include <qdialog.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qhbox.h> | 9 | #include <qhbox.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qtimer.h> | 12 | #include <qtimer.h> |
13 | 13 | ||
14 | using namespace Opie::Core; | 14 | using namespace Opie::Core; |
15 | using Opie::Security::MultiauthPluginObject; | 15 | using Opie::Security::MultiauthPluginObject; |
16 | using Opie::Security::MultiauthConfigWidget; | 16 | using Opie::Security::MultiauthConfigWidget; |
17 | 17 | ||
18 | 18 | ||
19 | /// standard c'tor | 19 | /// standard c'tor |
20 | BluepingPlugin::BluepingPlugin() : MultiauthPluginObject(), m_ping(0), m_bluepingW(0) { | 20 | BluepingPlugin::BluepingPlugin() : MultiauthPluginObject(), m_ping(0), m_bluepingW(0), bluetoothWasOff(false) { |
21 | bluetoothAlreadyRestarted = false; | ||
22 | } | 21 | } |
23 | 22 | ||
24 | /// cleans m_ping if we need to | 23 | /// cleans m_ping and m_bluepingW if we need to |
25 | BluepingPlugin::~BluepingPlugin() { | 24 | BluepingPlugin::~BluepingPlugin() { |
26 | delete m_ping; | 25 | odebug << "closing Blueping plugin..." << oendl; |
26 | if (m_ping != 0) | ||
27 | delete m_ping; | ||
27 | if (m_bluepingW != 0) | 28 | if (m_bluepingW != 0) |
28 | delete m_bluepingW; | 29 | delete m_bluepingW; |
30 | killBluetoothIfNecessary(); | ||
29 | } | 31 | } |
30 | 32 | ||
31 | /// Simply return its name (Blueping plugin) | 33 | /// Simply return its name (Blueping plugin) |
32 | QString BluepingPlugin::pluginName() const { | 34 | QString BluepingPlugin::pluginName() const { |
33 | return "Blueping plugin"; | 35 | return "Blueping plugin"; |
34 | } | 36 | } |
35 | 37 | ||
36 | /// returns a BluepingConfigWidget | 38 | /// returns a BluepingConfigWidget |
37 | MultiauthConfigWidget * BluepingPlugin::configWidget(QWidget * parent) { | 39 | MultiauthConfigWidget * BluepingPlugin::configWidget(QWidget * parent) { |
38 | if (m_bluepingW == 0) | 40 | if (m_bluepingW == 0) |
39 | m_bluepingW = new BluepingConfigWidget(parent, "Blueping configuration widget"); | 41 | m_bluepingW = new BluepingConfigWidget(parent, "Blueping configuration widget"); |
40 | return m_bluepingW; | 42 | return m_bluepingW; |
41 | } | 43 | } |
44 | |||
42 | QString BluepingPlugin::pixmapNameWidget() const { | 45 | QString BluepingPlugin::pixmapNameWidget() const { |
43 | return "security/bluepingplugin"; | 46 | return "security/bluepingplugin"; |
44 | } | 47 | } |
48 | |||
45 | QString BluepingPlugin::pixmapNameConfig() const { | 49 | QString BluepingPlugin::pixmapNameConfig() const { |
46 | return "security/bluepingplugin"; | 50 | return "security/bluepingplugin"; |
47 | } | 51 | } |
48 | 52 | ||
53 | /// If Bluetooth was off before the plugin ran, we switch it off again | ||
54 | void BluepingPlugin::killBluetoothIfNecessary() { | ||
55 | if (bluetoothWasOff) { | ||
56 | OProcess killB; | ||
57 | killB << "killall" << "hciattach"; | ||
58 | odebug << "killing Bluetooth... (since it was up only for Blueping)" << oendl; | ||
59 | if ( !killB.start(OProcess::Block) ) { | ||
60 | oerr << "could not kill bluetooth" << oendl; | ||
61 | } | ||
62 | } else { | ||
63 | odebug << "keeping Bluetooth on" << oendl; | ||
64 | } | ||
65 | } | ||
66 | |||
49 | /// Emit the MultiauthPluginObject::Success emitCode | 67 | /// Emit the MultiauthPluginObject::Success emitCode |
50 | void BluepingPlugin::success() { | 68 | void BluepingPlugin::success() { |
51 | emit emitCode(MultiauthPluginObject::Success); | 69 | emit emitCode(MultiauthPluginObject::Success); |
52 | } | 70 | } |
53 | 71 | ||
54 | /// Emit the MultiauthPluginObject::Failure emitCode | 72 | /// Emit the MultiauthPluginObject::Failure emitCode |
55 | void BluepingPlugin::failure() { | 73 | void BluepingPlugin::failure() { |
56 | emit emitCode(MultiauthPluginObject::Failure); | 74 | emit emitCode(MultiauthPluginObject::Failure); |
57 | } | 75 | } |
58 | 76 | ||
59 | /// Emit the MultiauthPluginObject::Skip emitCode | 77 | /// Emit the MultiauthPluginObject::Skip emitCode |
60 | void BluepingPlugin::skip() { | 78 | void BluepingPlugin::skip() { |
61 | emit emitCode(MultiauthPluginObject::Skip); | 79 | emit emitCode(MultiauthPluginObject::Skip); |
62 | } | 80 | } |
63 | 81 | ||
64 | /// do the actual ping | 82 | /// do the actual ping |
65 | void BluepingPlugin::ping() { | 83 | void BluepingPlugin::ping() { |
66 | m_ping = new OProcess(); | 84 | m_ping = new OProcess(); |
67 | odebug << "pinging device: " << macToPing << oendl; | 85 | odebug << "pinging device: " << macToPing << oendl; |
68 | *m_ping << "l2ping" << "-c 1" << macToPing; | 86 | *m_ping << "l2ping" << "-c 1" << macToPing; |
69 | 87 | ||
70 | // starting to ping in the background | 88 | // starting to ping in the background |
71 | /// \todo as soon as ping is launched, check RSSI (signal strength) and check | 89 | /// \todo as soon as ping is launched, check RSSI (signal strength) and check |
72 | /// it's high enough, meaning the device is close enough? | 90 | /// it's high enough, meaning the device is close enough? |
73 | /// \todo make it optionally pollable, so don't finish the ping and call | 91 | /// \todo make it optionally pollable, so don't finish the ping and call |
74 | /// Opie suspend if l2ping timeouts? | 92 | /// Opie suspend if l2ping timeouts? |
75 | if ( !m_ping->start() ) { | 93 | if ( !m_ping->start() ) { |
76 | oerr << "could not start l2ping" << oendl; | 94 | oerr << "could not start l2ping" << oendl; |
77 | this->skip(); | 95 | this->skip(); |
78 | } | 96 | } |
79 | QObject::connect(m_ping, SIGNAL(processExited(Opie::Core::OProcess*)), | 97 | QObject::connect(m_ping, SIGNAL(processExited(Opie::Core::OProcess*)), |
80 | this, SLOT(pingFinished(Opie::Core::OProcess*)) ); | 98 | this, SLOT(pingFinished(Opie::Core::OProcess*)) ); |
81 | } | 99 | } |
82 | 100 | ||
83 | /// Deals with m_ping result | 101 | /// Deals with m_ping result |
84 | void BluepingPlugin::pingFinished(OProcess * ping) { | 102 | void BluepingPlugin::pingFinished(OProcess * ping) { |
85 | if ( ping->normalExit() && (ping->exitStatus() == 0) ) | 103 | if ( ping->normalExit() && (ping->exitStatus() == 0) ) |
86 | { | 104 | { |
87 | odebug << "Successful Bluetooth ping!" << oendl; | 105 | odebug << "Successful Bluetooth ping!" << oendl; |
88 | success(); | 106 | success(); |
89 | } | ||
90 | else | ||
91 | { | ||
92 | odebug << "Failed Bluetooth ping..." << oendl; | ||
93 | failure(); | ||
94 | } | ||
95 | } | 107 | } |
108 | else | ||
109 | { | ||
110 | odebug << "Failed Bluetooth ping... (normalExit: " << ping->normalExit() << ", exitStatus: " << ping->exitStatus() << ")" << oendl; | ||
111 | failure(); | ||
112 | } | ||
113 | } | ||
96 | 114 | ||
97 | /// Make one authentication attempt with this plugin | 115 | /// Make one authentication attempt with this plugin |
98 | /** | 116 | /** |
99 | * (very simple "success" / "failure" buttons in a dialog) | 117 | * (very simple "success" / "failure" buttons in a dialog) |
100 | * \return The outcome code of this authentication | 118 | * \return The outcome code of this authentication |
101 | */ | 119 | */ |
102 | int BluepingPlugin::authenticate() { | 120 | int BluepingPlugin::authenticate() { |
103 | 121 | ||
104 | Config cfg("Security"); | 122 | Config cfg("Security"); |
105 | cfg.setGroup("BluepingPlugin"); | 123 | cfg.setGroup("BluepingPlugin"); |
106 | macToPing = cfg.readEntry("mac"); | 124 | macToPing = cfg.readEntry("mac"); |
107 | if (!macToPing.isEmpty()) | 125 | if (!macToPing.isEmpty()) |
108 | { | 126 | { |
109 | /* Standard, inescapable authentication dialog | 127 | /* Standard, inescapable authentication dialog |
110 | */ | 128 | */ |
111 | QDialog bluepingDialog(0, | 129 | QDialog bluepingDialog(0, |
112 | "Blueping dialog", | 130 | "Blueping dialog", |
113 | TRUE, | 131 | TRUE, |
114 | Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); | 132 | Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); |
115 | 133 | ||
116 | QRect desk = oApp->desktop()->geometry(); | 134 | QRect desk = oApp->desktop()->geometry(); |
117 | bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() ); | 135 | bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() ); |
118 | 136 | ||
119 | // Creation of the particular widgets of our Blueping user interface | 137 | // Creation of the particular widgets of our Blueping user interface |
120 | QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog); | 138 | QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog); |
121 | layout->setSpacing(11); | 139 | layout->setSpacing(11); |
122 | layout->setMargin(11); | 140 | layout->setMargin(11); |
123 | layout->setAlignment( Qt::AlignTop ); | 141 | layout->setAlignment( Qt::AlignTop ); |
124 | 142 | ||
125 | QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog); | 143 | QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog); |
126 | 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); |
127 | 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); |
128 | QPushButton pbSkip("Skip", &bluepingDialog); | 146 | QPushButton pbSkip("Skip", &bluepingDialog); |
129 | layout->addWidget(&title); | 147 | layout->addWidget(&title); |
130 | layout->addWidget(&subTitle); | 148 | layout->addWidget(&subTitle); |
131 | layout->addWidget(&subTitle2); | 149 | layout->addWidget(&subTitle2); |
132 | layout->addWidget(&pbSkip, 0, Qt::AlignHCenter); | 150 | layout->addWidget(&pbSkip, 0, Qt::AlignHCenter); |
133 | 151 | ||
134 | // connect the skip button to the skip signal emitting function | 152 | // connect the skip button to the skip signal emitting function |
135 | QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip())); | 153 | QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip())); |
136 | // 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 |
137 | QObject::connect(this, SIGNAL(emitCode(int)), &bluepingDialog, SLOT(done(int))); | 155 | QObject::connect(this, SIGNAL(emitCode(int)), &bluepingDialog, SLOT(done(int))); |
138 | 156 | ||
139 | // we can uncomment the following when testing | 157 | |
140 | //bluetoothAlreadyRestarted = true; | 158 | |
141 | if (!bluetoothAlreadyRestarted) | 159 | /* let's start Bluetooth if it's not running |
160 | */ | ||
161 | OProcess checkB; | ||
162 | checkB << "pidof" << "hciattach"; | ||
163 | odebug << "checking if Bluetooth is running..." << oendl; | ||
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) | ||
166 | if ( checkB.start(OProcess::Block) && checkB.normalExit() && (checkB.exitStatus() != 0) ) | ||
142 | { | 167 | { |
143 | // we have just started or resumed the device, so Bluetooth has to be (re)started | 168 | // remember to switch off Bluetooth once we're finished... |
144 | OProcess killB; | 169 | bluetoothWasOff = true; |
145 | killB << "killall" << "hciattach"; | 170 | odebug << "Bluetooth is not running, we must start it now" << oendl; |
146 | odebug << "killing Bluetooth..." << oendl; | ||
147 | if ( !killB.start(OProcess::Block) ) { | ||
148 | oerr << "could not kill bluetooth" << oendl; | ||
149 | } | ||
150 | 171 | ||
151 | OProcess startB; | 172 | OProcess startB; |
152 | switch ( ODevice::inst()->model() ) { | 173 | switch ( ODevice::inst()->model() ) { |
153 | case Model_iPAQ_H39xx: | 174 | case Model_iPAQ_H39xx: |
154 | startB << "/sbin/hciattach" << "/dev/tts/1" << "bcsp" << "921600"; | 175 | startB << "/sbin/hciattach" << "/dev/tts/1" << "bcsp" << "921600"; |
155 | break; | 176 | break; |
156 | 177 | ||
157 | case Model_iPAQ_H5xxx: | 178 | case Model_iPAQ_H5xxx: |
158 | startB << "/sbin/hciattach" << "/dev/tts/1" << "any" << "921600"; | 179 | startB << "/sbin/hciattach" << "/dev/tts/1" << "any" << "921600"; |
159 | break; | 180 | break; |
160 | 181 | ||
161 | default: | 182 | default: |
162 | startB << "/sbin/hciattach" << "/dev/ttySB0" << "bcsp" << "230400"; | 183 | startB << "/sbin/hciattach" << "/dev/ttySB0" << "bcsp" << "230400"; |
163 | break; | 184 | break; |
164 | } // end switch on device models | 185 | } // end switch on device models |
165 | 186 | ||
166 | if ( !startB.start(OProcess::Block) ) { | 187 | if ( !startB.start(OProcess::Block) ) { |
167 | oerr << "could not (re)start bluetooth" << oendl; | 188 | oerr << "could not start Bluetooth" << oendl; |
168 | return MultiauthPluginObject::Skip; | 189 | return MultiauthPluginObject::Skip; |
169 | } | 190 | } |
170 | else | 191 | else |
171 | { | 192 | { |
172 | if ( startB.normalExit() && (startB.exitStatus() == 0) ) | 193 | if ( (startB.normalExit()) && (startB.exitStatus() == 0) ) |
173 | { | 194 | { |
174 | odebug << "hciattach exited normally."<< oendl; | 195 | odebug << "hciattach exited normally, Bluetooth is probably on now, let's wait 500 ms and ping" << oendl; |
175 | bluetoothAlreadyRestarted = true; | ||
176 | // 500 ms timer, so l2ping won't try to find a route before bluetooth has \em really started | 196 | // 500 ms timer, so l2ping won't try to find a route before bluetooth has \em really started |
177 | QTimer::singleShot( 500, this, SLOT(ping()) ); | 197 | QTimer::singleShot( 500, this, SLOT(ping()) ); |
178 | } | 198 | } |
179 | else | 199 | else |
180 | { | 200 | { |
181 | owarn << "hciattach exited anormally (error code: " << startB.exitStatus() << ")" << oendl; | 201 | owarn << "hciattach exited anormally (normalExit: " << startB.normalExit() << ", exit status: " << startB.exitStatus() << ")" << oendl; |
182 | } // end if startBluetooth exit status == 0 | 202 | return MultiauthPluginObject::Skip; |
203 | } // end if startB exited normaly | ||
183 | } // end if startBluetooth started | 204 | } // end if startBluetooth started |
184 | } | 205 | } |
185 | else | 206 | else |
186 | { | 207 | { |
187 | // we don't need to wait, since bluetooth has been started long enough ago | 208 | // 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; | ||
188 | ping(); | 210 | ping(); |
189 | } // end if bluetooth not restarted | 211 | } // end if Bluetooth was off |
190 | 212 | ||
191 | 213 | ||
192 | // start the dialog event loop, while the ping is starting (or will start soon) in the background | 214 | // start the dialog event loop, while the ping is starting (or will start soon) in the background |
193 | return bluepingDialog.exec(); | 215 | return bluepingDialog.exec(); |
194 | 216 | ||
195 | 217 | ||
196 | } | 218 | } |
197 | else | 219 | else |
198 | { | 220 | { |
199 | owarn << "No Bluetooth device has been set!" << oendl; | 221 | owarn << "No Bluetooth device has been set!" << oendl; |
200 | owarn << "We will consider it as a successful authentication though." << oendl; | 222 | owarn << "We will consider it as a successful authentication though." << oendl; |
201 | return MultiauthPluginObject::Success; | 223 | return MultiauthPluginObject::Success; |
202 | } // end if mac defined | 224 | } // end if mac defined |
203 | } | 225 | } |
diff --git a/noncore/securityplugins/blueping/bluepingplugin.h b/noncore/securityplugins/blueping/bluepingplugin.h index b8d6734..56ff22d 100644 --- a/noncore/securityplugins/blueping/bluepingplugin.h +++ b/noncore/securityplugins/blueping/bluepingplugin.h | |||
@@ -1,83 +1,84 @@ | |||
1 | /** | 1 | /** |
2 | * \file bluepingplugin.h | 2 | * \file bluepingplugin.h |
3 | * \brief Standard Opie multiauth plugin definition | 3 | * \brief Standard Opie multiauth plugin definition |
4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | 4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) |
5 | */ | 5 | */ |
6 | /* | 6 | /* |
7 | =. This file is part of the Opie Project | 7 | =. This file is part of the Opie Project |
8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | 8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This library is free software; you can | 10 | _;:, .> :=|. This library is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This library is distributed in the hope that | 17 | .i_,=:_. -<s. This library is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef BLUEPING_PLUGIN_H | 34 | #ifndef BLUEPING_PLUGIN_H |
35 | #define BLUEPING_PLUGIN_H | 35 | #define BLUEPING_PLUGIN_H |
36 | 36 | ||
37 | #include "bluepingConfigWidget.h" | 37 | #include "bluepingConfigWidget.h" |
38 | 38 | ||
39 | #include <opie2/multiauthplugininterface.h> | 39 | #include <opie2/multiauthplugininterface.h> |
40 | 40 | ||
41 | #include <opie2/oprocess.h> | 41 | #include <opie2/oprocess.h> |
42 | 42 | ||
43 | #include <qobject.h> | 43 | #include <qobject.h> |
44 | #include <qstring.h> | 44 | #include <qstring.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | 46 | ||
47 | /// Multi-authentication bluetooth plugin, which tries to ping a specific MAC address. | 47 | /// Multi-authentication bluetooth plugin, which tries to ping a specific MAC address. |
48 | /** | 48 | /** |
49 | * The plugin itself, implementing the main authenticate() function. | 49 | * The plugin itself, implementing the main authenticate() function. |
50 | */ | 50 | */ |
51 | class BluepingPlugin : public QObject, public Opie::Security::MultiauthPluginObject { | 51 | class BluepingPlugin : public QObject, public Opie::Security::MultiauthPluginObject { |
52 | 52 | ||
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | 54 | ||
55 | public: | 55 | public: |
56 | BluepingPlugin(); | 56 | BluepingPlugin(); |
57 | virtual ~BluepingPlugin(); | 57 | virtual ~BluepingPlugin(); |
58 | int authenticate(); | 58 | int authenticate(); |
59 | Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent); | 59 | Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent); |
60 | QString pixmapNameConfig() const; | 60 | QString pixmapNameConfig() const; |
61 | QString pixmapNameWidget() const; | 61 | QString pixmapNameWidget() const; |
62 | QString pluginName() const; | 62 | QString pluginName() const; |
63 | 63 | ||
64 | signals: | 64 | signals: |
65 | /// Signal carrying the result code of this plugin | 65 | /// Signal carrying the result code of this plugin |
66 | void emitCode(int resultCode); | 66 | void emitCode(int resultCode); |
67 | 67 | ||
68 | private slots: | 68 | private slots: |
69 | void success(); | 69 | void success(); |
70 | void failure(); | 70 | void failure(); |
71 | void skip(); | 71 | void skip(); |
72 | void ping(); | 72 | void ping(); |
73 | void pingFinished(Opie::Core::OProcess * ping); | 73 | void pingFinished(Opie::Core::OProcess * ping); |
74 | 74 | ||
75 | private: | 75 | private: |
76 | Opie::Core::OProcess *m_ping; | 76 | void killBluetoothIfNecessary(); |
77 | Opie::Core::OProcess * m_ping; | ||
78 | Config * m_config; | ||
77 | BluepingConfigWidget * m_bluepingW; | 79 | BluepingConfigWidget * m_bluepingW; |
78 | bool bluetoothAlreadyRestarted; | 80 | bool bluetoothWasOff; |
79 | QString macToPing; | 81 | QString macToPing; |
80 | |||
81 | }; | 82 | }; |
82 | 83 | ||
83 | #endif | 84 | #endif |