5 files changed, 151 insertions, 13 deletions
diff --git a/noncore/securityplugins/blueping/bluepingConfigWidget.cpp b/noncore/securityplugins/blueping/bluepingConfigWidget.cpp new file mode 100644 index 0000000..876ccda --- a/dev/null +++ b/noncore/securityplugins/blueping/bluepingConfigWidget.cpp | |||
@@ -0,0 +1,74 @@ | |||
1 | #include "bluepingConfigWidget.h" | ||
2 | |||
3 | #include <qwidget.h> | ||
4 | #include <qlayout.h> | ||
5 | #include <qlabel.h> | ||
6 | #include <qgroupbox.h> | ||
7 | #include <qmessagebox.h> | ||
8 | #include <qregexp.h> | ||
9 | |||
10 | using Opie::Security::MultiauthConfigWidget; | ||
11 | |||
12 | BluepingConfigWidget::BluepingConfigWidget(QWidget* parent = 0, const char* name = "Blueping configuration widget") | ||
13 | : MultiauthConfigWidget(parent, name) | ||
14 | { | ||
15 | m_config = new Config("Security"); | ||
16 | m_config->setGroup("BluepingPlugin"); | ||
17 | QVBoxLayout * baseLayout = new QVBoxLayout( this); | ||
18 | baseLayout->setSpacing(11); | ||
19 | baseLayout->setMargin(11); | ||
20 | baseLayout->setAlignment( Qt::AlignTop ); | ||
21 | |||
22 | QGroupBox * configBox = new QGroupBox(0, Qt::Vertical, tr("Set the MAC address to ping here"), this); | ||
23 | baseLayout->addWidget(configBox); | ||
24 | QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() ); | ||
25 | |||
26 | QHBoxLayout * configLayout = new QHBoxLayout(); | ||
27 | configLayout->setSpacing(6); | ||
28 | boxLayout->addLayout(configLayout); | ||
29 | |||
30 | QString mac = m_config->readEntry("mac"); | ||
31 | if ( mac.isEmpty() ) | ||
32 | mac = "00:00:00:00:00:00"; | ||
33 | |||
34 | editMAC = new QLineEdit( mac, configBox, "editMAC" ); | ||
35 | setMAC = new QPushButton( tr("Set"), configBox, "setMAC" ); | ||
36 | configLayout->addWidget(editMAC); | ||
37 | configLayout->addWidget(setMAC); | ||
38 | |||
39 | QLabel * description = new QLabel( "<p>" + tr("Detecting another Bluetooth device by its MAC address provides a minimal and automatic level of protection.") + "</p><p><em>" | ||
40 | + tr("Note: if you don't put a valid MAC here but you activate the plugin, it will always succeed!") + "</em></p>", configBox ); | ||
41 | boxLayout->addWidget(description); | ||
42 | |||
43 | |||
44 | connect(setMAC, SIGNAL( clicked() ), this, SLOT( changeMAC() )); | ||
45 | |||
46 | } | ||
47 | |||
48 | /// checks and writes the MAC in the config file, if its format is OK | ||
49 | void BluepingConfigWidget::changeMAC() { | ||
50 | QString mac = editMAC->text(); | ||
51 | QRegExp macPattern("[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]"); | ||
52 | if ( (mac.length() == 17) && (macPattern.match(mac) == 0) ) | ||
53 | { | ||
54 | m_config->writeEntry("mac", mac); | ||
55 | QMessageBox success( tr("MAC address saved!"), "<p>" + tr("Make sure that Bluetooth is turned on on the corresponding device when the Blueping plugin needs it.") + "</p>", | ||
56 | QMessageBox::Information, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); | ||
57 | success.exec(); | ||
58 | } else { | ||
59 | QMessageBox failure( tr("Please enter a valid MAC"), "<p>" + tr("Please separate the six pairs of digits of your MAC like this: 01:02:03:04:05:06") + tr("</p>"), | ||
60 | QMessageBox::Warning, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton ); | ||
61 | failure.exec(); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | /// deletes the m_config pointer | ||
66 | BluepingConfigWidget::~BluepingConfigWidget() | ||
67 | { | ||
68 | delete m_config; | ||
69 | } | ||
70 | |||
71 | // does nothing (there's a button to save the config) | ||
72 | void BluepingConfigWidget::writeConfig() | ||
73 | { | ||
74 | } | ||
diff --git a/noncore/securityplugins/blueping/bluepingConfigWidget.h b/noncore/securityplugins/blueping/bluepingConfigWidget.h new file mode 100644 index 0000000..bd1bec9 --- a/dev/null +++ b/noncore/securityplugins/blueping/bluepingConfigWidget.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /** | ||
2 | * \file bluepingConfigWidget.h | ||
3 | * \brief "BluePing" plugin configuration widget | ||
4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
5 | */ | ||
6 | /* | ||
7 | =. This file is part of the Opie Project | ||
8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This library is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This library is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #ifndef BLUEPINGCONFIGWIDGET_H | ||
35 | #define BLUEPINGCONFIGWIDGET_H | ||
36 | #include <qlineedit.h> | ||
37 | #include <qpushbutton.h> | ||
38 | #include <qpe/config.h> | ||
39 | |||
40 | #include <opie2/multiauthconfigwidget.h> | ||
41 | |||
42 | class BluepingConfigWidget : public Opie::Security::MultiauthConfigWidget { | ||
43 | |||
44 | Q_OBJECT | ||
45 | |||
46 | public: | ||
47 | BluepingConfigWidget(QWidget* parent, const char* name); | ||
48 | virtual ~BluepingConfigWidget(); | ||
49 | virtual void writeConfig(); | ||
50 | private: | ||
51 | QLineEdit *editMAC; | ||
52 | QPushButton *setMAC; | ||
53 | Config *m_config; | ||
54 | private slots: | ||
55 | void changeMAC(); | ||
56 | |||
57 | }; | ||
58 | |||
59 | #endif // BLUEPINGCONFIGWIDGET_H | ||
diff --git a/noncore/securityplugins/blueping/bluepingplugin.cpp b/noncore/securityplugins/blueping/bluepingplugin.cpp index 05fd3c2..f5d9ad6 100644 --- a/noncore/securityplugins/blueping/bluepingplugin.cpp +++ b/noncore/securityplugins/blueping/bluepingplugin.cpp | |||
@@ -1,200 +1,203 @@ | |||
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 | /// creates and initializes the m_config Config object | 19 | /// standard c'tor |
20 | BluepingPlugin::BluepingPlugin() : MultiauthPluginObject(), m_ping(0) { | 20 | BluepingPlugin::BluepingPlugin() : MultiauthPluginObject(), m_ping(0), m_bluepingW(0) { |
21 | m_config = new Config("Security"); | ||
22 | m_config->setGroup("BluepingPlugin"); | ||
23 | bluetoothAlreadyRestarted = false; | 21 | bluetoothAlreadyRestarted = false; |
24 | } | 22 | } |
25 | 23 | ||
26 | /// deletes the m_config Config object and noticeW if necessary | 24 | /// cleans m_ping if we need to |
27 | BluepingPlugin::~BluepingPlugin() { | 25 | BluepingPlugin::~BluepingPlugin() { |
28 | delete m_config; | ||
29 | delete m_ping; | 26 | delete m_ping; |
27 | if (m_bluepingW != 0) | ||
28 | delete m_bluepingW; | ||
30 | } | 29 | } |
31 | 30 | ||
32 | /// Simply return its name (Blueping plugin) | 31 | /// Simply return its name (Blueping plugin) |
33 | QString BluepingPlugin::pluginName() const { | 32 | QString BluepingPlugin::pluginName() const { |
34 | return "Blueping plugin"; | 33 | return "Blueping plugin"; |
35 | } | 34 | } |
36 | 35 | ||
37 | /// no configuration widget for the moment | 36 | /// returns a BluepingConfigWidget |
38 | MultiauthConfigWidget * BluepingPlugin::configWidget(QWidget * parent) { | 37 | MultiauthConfigWidget * BluepingPlugin::configWidget(QWidget * parent) { |
39 | return 0l; | 38 | if (m_bluepingW == 0) |
39 | m_bluepingW = new BluepingConfigWidget(parent, "Blueping configuration widget"); | ||
40 | return m_bluepingW; | ||
40 | } | 41 | } |
41 | QString BluepingPlugin::pixmapNameWidget() const { | 42 | QString BluepingPlugin::pixmapNameWidget() const { |
42 | return "security/bluepingplugin"; | 43 | return "security/bluepingplugin"; |
43 | } | 44 | } |
44 | QString BluepingPlugin::pixmapNameConfig() const { | 45 | QString BluepingPlugin::pixmapNameConfig() const { |
45 | return 0l; | 46 | return "security/bluepingplugin"; |
46 | } | 47 | } |
47 | 48 | ||
48 | /// Emit the MultiauthPluginObject::Success emitCode | 49 | /// Emit the MultiauthPluginObject::Success emitCode |
49 | void BluepingPlugin::success() { | 50 | void BluepingPlugin::success() { |
50 | emit emitCode(MultiauthPluginObject::Success); | 51 | emit emitCode(MultiauthPluginObject::Success); |
51 | } | 52 | } |
52 | 53 | ||
53 | /// Emit the MultiauthPluginObject::Failure emitCode | 54 | /// Emit the MultiauthPluginObject::Failure emitCode |
54 | void BluepingPlugin::failure() { | 55 | void BluepingPlugin::failure() { |
55 | emit emitCode(MultiauthPluginObject::Failure); | 56 | emit emitCode(MultiauthPluginObject::Failure); |
56 | } | 57 | } |
57 | 58 | ||
58 | /// Emit the MultiauthPluginObject::Skip emitCode | 59 | /// Emit the MultiauthPluginObject::Skip emitCode |
59 | void BluepingPlugin::skip() { | 60 | void BluepingPlugin::skip() { |
60 | emit emitCode(MultiauthPluginObject::Skip); | 61 | emit emitCode(MultiauthPluginObject::Skip); |
61 | } | 62 | } |
62 | 63 | ||
63 | /// do the actual ping | 64 | /// do the actual ping |
64 | void BluepingPlugin::ping() { | 65 | void BluepingPlugin::ping() { |
65 | m_ping = new OProcess(); | 66 | m_ping = new OProcess(); |
66 | odebug << "pinging device: " << macToPing << oendl; | 67 | odebug << "pinging device: " << macToPing << oendl; |
67 | *m_ping << "l2ping" << "-c 1" << macToPing; | 68 | *m_ping << "l2ping" << "-c 1" << macToPing; |
68 | 69 | ||
69 | // starting to ping in the background | 70 | // starting to ping in the background |
70 | /// \todo as soon as ping is launched, check RSSI (signal strength) and check | 71 | /// \todo as soon as ping is launched, check RSSI (signal strength) and check |
71 | /// it's high enough, meaning the device is close enough? | 72 | /// it's high enough, meaning the device is close enough? |
72 | /// \todo make it optionally pollable, so don't finish the ping and call | 73 | /// \todo make it optionally pollable, so don't finish the ping and call |
73 | /// Opie suspend if l2ping timeouts? | 74 | /// Opie suspend if l2ping timeouts? |
74 | if ( !m_ping->start() ) { | 75 | if ( !m_ping->start() ) { |
75 | oerr << "could not start l2ping" << oendl; | 76 | oerr << "could not start l2ping" << oendl; |
76 | this->skip(); | 77 | this->skip(); |
77 | } | 78 | } |
78 | QObject::connect(m_ping, SIGNAL(processExited(Opie::Core::OProcess*)), | 79 | QObject::connect(m_ping, SIGNAL(processExited(Opie::Core::OProcess*)), |
79 | this, SLOT(pingFinished(Opie::Core::OProcess*)) ); | 80 | this, SLOT(pingFinished(Opie::Core::OProcess*)) ); |
80 | } | 81 | } |
81 | 82 | ||
82 | /// Deals with m_ping result | 83 | /// Deals with m_ping result |
83 | void BluepingPlugin::pingFinished(OProcess * ping) { | 84 | void BluepingPlugin::pingFinished(OProcess * ping) { |
84 | if ( ping->normalExit() && (ping->exitStatus() == 0) ) | 85 | if ( ping->normalExit() && (ping->exitStatus() == 0) ) |
85 | { | 86 | { |
86 | odebug << "Successful Bluetooth ping!" << oendl; | 87 | odebug << "Successful Bluetooth ping!" << oendl; |
87 | success(); | 88 | success(); |
88 | } | 89 | } |
89 | else | 90 | else |
90 | { | 91 | { |
91 | odebug << "Failed Bluetooth ping..." << oendl; | 92 | odebug << "Failed Bluetooth ping..." << oendl; |
92 | failure(); | 93 | failure(); |
93 | } | 94 | } |
94 | } | 95 | } |
95 | 96 | ||
96 | /// Make one authentication attempt with this plugin | 97 | /// Make one authentication attempt with this plugin |
97 | /** | 98 | /** |
98 | * (very simple "success" / "failure" buttons in a dialog) | 99 | * (very simple "success" / "failure" buttons in a dialog) |
99 | * \return The outcome code of this authentication | 100 | * \return The outcome code of this authentication |
100 | */ | 101 | */ |
101 | int BluepingPlugin::authenticate() { | 102 | int BluepingPlugin::authenticate() { |
102 | 103 | ||
103 | Config cfg("Security"); | 104 | Config cfg("Security"); |
104 | cfg.setGroup("BluepingPlugin"); | 105 | cfg.setGroup("BluepingPlugin"); |
105 | macToPing = cfg.readEntry("mac"); | 106 | macToPing = cfg.readEntry("mac"); |
106 | if (!macToPing.isEmpty()) | 107 | if (!macToPing.isEmpty()) |
107 | { | 108 | { |
108 | /* Standard, inescapable authentication dialog | 109 | /* Standard, inescapable authentication dialog |
109 | */ | 110 | */ |
110 | QDialog bluepingDialog(0, | 111 | QDialog bluepingDialog(0, |
111 | "Blueping dialog", | 112 | "Blueping dialog", |
112 | TRUE, | 113 | TRUE, |
113 | Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); | 114 | Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); |
114 | 115 | ||
115 | QRect desk = oApp->desktop()->geometry(); | 116 | QRect desk = oApp->desktop()->geometry(); |
116 | bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() ); | 117 | bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() ); |
117 | 118 | ||
118 | // Creation of the particular widgets of our Blueping user interface | 119 | // Creation of the particular widgets of our Blueping user interface |
119 | QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog); | 120 | QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog); |
120 | layout->setSpacing(11); | 121 | layout->setSpacing(11); |
121 | layout->setMargin(11); | 122 | layout->setMargin(11); |
122 | layout->setAlignment( Qt::AlignTop ); | 123 | layout->setAlignment( Qt::AlignTop ); |
123 | 124 | ||
124 | QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog); | 125 | QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog); |
125 | QLabel subTitle("<center><h2>Trying to reach your configured bluetooth device...</h2></center>", &bluepingDialog); | 126 | QLabel subTitle("<center><h2>Trying to reach your configured bluetooth device...</h2></center>", &bluepingDialog); |
126 | QLabel subTitle2("<center>You can skip this step and use another authentication way with the following button</center>", &bluepingDialog); | 127 | QLabel subTitle2("<center>You can skip this step and use another authentication way with the following button</center>", &bluepingDialog); |
127 | QPushButton pbSkip("Skip", &bluepingDialog); | 128 | QPushButton pbSkip("Skip", &bluepingDialog); |
128 | layout->addWidget(&title); | 129 | layout->addWidget(&title); |
129 | layout->addWidget(&subTitle); | 130 | layout->addWidget(&subTitle); |
130 | layout->addWidget(&subTitle2); | 131 | layout->addWidget(&subTitle2); |
131 | layout->addWidget(&pbSkip, 0, Qt::AlignHCenter); | 132 | layout->addWidget(&pbSkip, 0, Qt::AlignHCenter); |
132 | 133 | ||
133 | // connect the skip button to the skip signal emitting function | 134 | // connect the skip button to the skip signal emitting function |
134 | QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip())); | 135 | QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip())); |
135 | // connect the signal emitting functions to the bluepingDialog done(int) finishing function | 136 | // connect the signal emitting functions to the bluepingDialog done(int) finishing function |
136 | QObject::connect(this, SIGNAL(emitCode(int)), &bluepingDialog, SLOT(done(int))); | 137 | QObject::connect(this, SIGNAL(emitCode(int)), &bluepingDialog, SLOT(done(int))); |
137 | 138 | ||
139 | // we can uncomment the following when testing | ||
140 | //bluetoothAlreadyRestarted = true; | ||
138 | if (!bluetoothAlreadyRestarted) | 141 | if (!bluetoothAlreadyRestarted) |
139 | { | 142 | { |
140 | // we have just started or resumed the device, so Bluetooth has to be (re)started | 143 | // we have just started or resumed the device, so Bluetooth has to be (re)started |
141 | OProcess killB; | 144 | OProcess killB; |
142 | killB << "killall" << "hciattach"; | 145 | killB << "killall" << "hciattach"; |
143 | odebug << "killing Bluetooth..." << oendl; | 146 | odebug << "killing Bluetooth..." << oendl; |
144 | if ( !killB.start(OProcess::Block) ) { | 147 | if ( !killB.start(OProcess::Block) ) { |
145 | oerr << "could not kill bluetooth" << oendl; | 148 | oerr << "could not kill bluetooth" << oendl; |
146 | } | 149 | } |
147 | 150 | ||
148 | OProcess startB; | 151 | OProcess startB; |
149 | switch ( ODevice::inst()->model() ) { | 152 | switch ( ODevice::inst()->model() ) { |
150 | case Model_iPAQ_H39xx: | 153 | case Model_iPAQ_H39xx: |
151 | startB << "/sbin/hciattach" << "/dev/tts/1" << "bcsp" << "921600"; | 154 | startB << "/sbin/hciattach" << "/dev/tts/1" << "bcsp" << "921600"; |
152 | break; | 155 | break; |
153 | 156 | ||
154 | case Model_iPAQ_H5xxx: | 157 | case Model_iPAQ_H5xxx: |
155 | startB << "/sbin/hciattach" << "/dev/tts/1" << "any" << "921600"; | 158 | startB << "/sbin/hciattach" << "/dev/tts/1" << "any" << "921600"; |
156 | break; | 159 | break; |
157 | 160 | ||
158 | default: | 161 | default: |
159 | startB << "/sbin/hciattach" << "/dev/ttySB0" << "bcsp" << "230400"; | 162 | startB << "/sbin/hciattach" << "/dev/ttySB0" << "bcsp" << "230400"; |
160 | break; | 163 | break; |
161 | } // end switch on device models | 164 | } // end switch on device models |
162 | 165 | ||
163 | if ( !startB.start(OProcess::Block) ) { | 166 | if ( !startB.start(OProcess::Block) ) { |
164 | oerr << "could not (re)start bluetooth" << oendl; | 167 | oerr << "could not (re)start bluetooth" << oendl; |
165 | return MultiauthPluginObject::Skip; | 168 | return MultiauthPluginObject::Skip; |
166 | } | 169 | } |
167 | else | 170 | else |
168 | { | 171 | { |
169 | if ( startB.normalExit() && (startB.exitStatus() == 0) ) | 172 | if ( startB.normalExit() && (startB.exitStatus() == 0) ) |
170 | { | 173 | { |
171 | odebug << "hciattach exited normally."<< oendl; | 174 | odebug << "hciattach exited normally."<< oendl; |
172 | bluetoothAlreadyRestarted = true; | 175 | bluetoothAlreadyRestarted = true; |
173 | // 500 ms timer, so l2ping won't try to find a route before bluetooth has \em really started | 176 | // 500 ms timer, so l2ping won't try to find a route before bluetooth has \em really started |
174 | QTimer::singleShot( 500, this, SLOT(ping()) ); | 177 | QTimer::singleShot( 500, this, SLOT(ping()) ); |
175 | } | 178 | } |
176 | else | 179 | else |
177 | { | 180 | { |
178 | owarn << "hciattach exited anormally (error code: " << startB.exitStatus() << ")" << oendl; | 181 | owarn << "hciattach exited anormally (error code: " << startB.exitStatus() << ")" << oendl; |
179 | } // end if startBluetooth exit status == 0 | 182 | } // end if startBluetooth exit status == 0 |
180 | } // end if startBluetooth started | 183 | } // end if startBluetooth started |
181 | } | 184 | } |
182 | else | 185 | else |
183 | { | 186 | { |
184 | // we don't need to wait, since bluetooth has been started long enough ago | 187 | // we don't need to wait, since bluetooth has been started long enough ago |
185 | ping(); | 188 | ping(); |
186 | } // end if bluetooth not restarted | 189 | } // end if bluetooth not restarted |
187 | 190 | ||
188 | 191 | ||
189 | // start the dialog event loop, while the ping is starting (or will start soon) in the background | 192 | // start the dialog event loop, while the ping is starting (or will start soon) in the background |
190 | return bluepingDialog.exec(); | 193 | return bluepingDialog.exec(); |
191 | 194 | ||
192 | 195 | ||
193 | } | 196 | } |
194 | else | 197 | else |
195 | { | 198 | { |
196 | owarn << "No Bluetooth device has been set!" << oendl; | 199 | owarn << "No Bluetooth device has been set!" << oendl; |
197 | owarn << "We will consider it as a successful authentication though." << oendl; | 200 | owarn << "We will consider it as a successful authentication though." << oendl; |
198 | return MultiauthPluginObject::Success; | 201 | return MultiauthPluginObject::Success; |
199 | } // end if mac defined | 202 | } // end if mac defined |
200 | } | 203 | } |
diff --git a/noncore/securityplugins/blueping/bluepingplugin.h b/noncore/securityplugins/blueping/bluepingplugin.h index 0df3f78..b8d6734 100644 --- a/noncore/securityplugins/blueping/bluepingplugin.h +++ b/noncore/securityplugins/blueping/bluepingplugin.h | |||
@@ -1,81 +1,83 @@ | |||
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" | ||
38 | |||
37 | #include <opie2/multiauthplugininterface.h> | 39 | #include <opie2/multiauthplugininterface.h> |
38 | 40 | ||
39 | #include <opie2/oprocess.h> | 41 | #include <opie2/oprocess.h> |
40 | 42 | ||
41 | #include <qobject.h> | 43 | #include <qobject.h> |
42 | #include <qstring.h> | 44 | #include <qstring.h> |
43 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
44 | 46 | ||
45 | /// 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. |
46 | /** | 48 | /** |
47 | * The plugin itself, implementing the main authenticate() function. | 49 | * The plugin itself, implementing the main authenticate() function. |
48 | */ | 50 | */ |
49 | class BluepingPlugin : public QObject, public Opie::Security::MultiauthPluginObject { | 51 | class BluepingPlugin : public QObject, public Opie::Security::MultiauthPluginObject { |
50 | 52 | ||
51 | Q_OBJECT | 53 | Q_OBJECT |
52 | 54 | ||
53 | public: | 55 | public: |
54 | BluepingPlugin(); | 56 | BluepingPlugin(); |
55 | virtual ~BluepingPlugin(); | 57 | virtual ~BluepingPlugin(); |
56 | int authenticate(); | 58 | int authenticate(); |
57 | Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent); | 59 | Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent); |
58 | QString pixmapNameConfig() const; | 60 | QString pixmapNameConfig() const; |
59 | QString pixmapNameWidget() const; | 61 | QString pixmapNameWidget() const; |
60 | QString pluginName() const; | 62 | QString pluginName() const; |
61 | 63 | ||
62 | signals: | 64 | signals: |
63 | /// Signal carrying the result code of this plugin | 65 | /// Signal carrying the result code of this plugin |
64 | void emitCode(int resultCode); | 66 | void emitCode(int resultCode); |
65 | 67 | ||
66 | private slots: | 68 | private slots: |
67 | void success(); | 69 | void success(); |
68 | void failure(); | 70 | void failure(); |
69 | void skip(); | 71 | void skip(); |
70 | void ping(); | 72 | void ping(); |
71 | void pingFinished(Opie::Core::OProcess * ping); | 73 | void pingFinished(Opie::Core::OProcess * ping); |
72 | 74 | ||
73 | private: | 75 | private: |
74 | Opie::Core::OProcess *m_ping; | 76 | Opie::Core::OProcess *m_ping; |
75 | Config * m_config; | 77 | BluepingConfigWidget * m_bluepingW; |
76 | bool bluetoothAlreadyRestarted; | 78 | bool bluetoothAlreadyRestarted; |
77 | QString macToPing; | 79 | QString macToPing; |
78 | 80 | ||
79 | }; | 81 | }; |
80 | 82 | ||
81 | #endif | 83 | #endif |
diff --git a/noncore/securityplugins/blueping/bluepingplugin.pro b/noncore/securityplugins/blueping/bluepingplugin.pro index 2cc0cd3..0946749 100644 --- a/noncore/securityplugins/blueping/bluepingplugin.pro +++ b/noncore/securityplugins/blueping/bluepingplugin.pro | |||
@@ -1,18 +1,18 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | 3 | ||
4 | HEADERS = bluepingplugin.h bluepingpluginimpl.h | 4 | HEADERS = bluepingplugin.h bluepingpluginimpl.h bluepingConfigWidget.h |
5 | 5 | ||
6 | SOURCES = bluepingplugin.cpp bluepingpluginimpl.cpp | 6 | SOURCES = bluepingplugin.cpp bluepingpluginimpl.cpp bluepingConfigWidget.cpp |
7 | 7 | ||
8 | 8 | ||
9 | INCLUDEPATH+= $(OPIEDIR)/include | 9 | INCLUDEPATH+= $(OPIEDIR)/include |
10 | DEPENDPATH+= | 10 | DEPENDPATH+= |
11 | 11 | ||
12 | LIBS += -lqpe -lopieui2 -lopiecore2 -lopiesecurity2 | 12 | LIBS += -lqpe -lopieui2 -lopiecore2 -lopiesecurity2 |
13 | 13 | ||
14 | DESTDIR = $(OPIEDIR)/plugins/security | 14 | DESTDIR = $(OPIEDIR)/plugins/security |
15 | TARGET = multiauthbluepingplugin | 15 | TARGET = multiauthbluepingplugin |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
18 | 18 | ||