Diffstat (limited to 'noncore/securityplugins/blueping/bluepingplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/securityplugins/blueping/bluepingplugin.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/noncore/securityplugins/blueping/bluepingplugin.cpp b/noncore/securityplugins/blueping/bluepingplugin.cpp index f4c5e95..05fd3c2 100644 --- a/noncore/securityplugins/blueping/bluepingplugin.cpp +++ b/noncore/securityplugins/blueping/bluepingplugin.cpp @@ -1,126 +1,125 @@ #include "bluepingplugin.h" #include <opie2/oapplication.h> #include <opie2/odebug.h> #include <opie2/odevice.h> #include <qdialog.h> #include <qlayout.h> #include <qhbox.h> #include <qlabel.h> #include <qpushbutton.h> #include <qtimer.h> using namespace Opie::Core; using Opie::Security::MultiauthPluginObject; using Opie::Security::MultiauthConfigWidget; /// creates and initializes the m_config Config object BluepingPlugin::BluepingPlugin() : MultiauthPluginObject(), m_ping(0) { m_config = new Config("Security"); m_config->setGroup("BluepingPlugin"); bluetoothAlreadyRestarted = false; } /// deletes the m_config Config object and noticeW if necessary BluepingPlugin::~BluepingPlugin() { delete m_config; - if (m_ping != 0) - delete m_ping; + delete m_ping; } /// Simply return its name (Blueping plugin) QString BluepingPlugin::pluginName() const { return "Blueping plugin"; } /// no configuration widget for the moment MultiauthConfigWidget * BluepingPlugin::configWidget(QWidget * parent) { return 0l; } QString BluepingPlugin::pixmapNameWidget() const { return "security/bluepingplugin"; } QString BluepingPlugin::pixmapNameConfig() const { return 0l; } /// Emit the MultiauthPluginObject::Success emitCode void BluepingPlugin::success() { emit emitCode(MultiauthPluginObject::Success); } /// Emit the MultiauthPluginObject::Failure emitCode void BluepingPlugin::failure() { emit emitCode(MultiauthPluginObject::Failure); } /// Emit the MultiauthPluginObject::Skip emitCode void BluepingPlugin::skip() { emit emitCode(MultiauthPluginObject::Skip); } /// do the actual ping void BluepingPlugin::ping() { m_ping = new OProcess(); odebug << "pinging device: " << macToPing << oendl; *m_ping << "l2ping" << "-c 1" << macToPing; // starting to ping in the background /// \todo as soon as ping is launched, check RSSI (signal strength) and check /// it's high enough, meaning the device is close enough? /// \todo make it optionally pollable, so don't finish the ping and call /// Opie suspend if l2ping timeouts? if ( !m_ping->start() ) { oerr << "could not start l2ping" << oendl; this->skip(); } QObject::connect(m_ping, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT(pingFinished(Opie::Core::OProcess*)) ); } /// Deals with m_ping result void BluepingPlugin::pingFinished(OProcess * ping) { if ( ping->normalExit() && (ping->exitStatus() == 0) ) { odebug << "Successful Bluetooth ping!" << oendl; success(); } else { odebug << "Failed Bluetooth ping..." << oendl; failure(); } } /// Make one authentication attempt with this plugin /** * (very simple "success" / "failure" buttons in a dialog) * \return The outcome code of this authentication */ int BluepingPlugin::authenticate() { Config cfg("Security"); cfg.setGroup("BluepingPlugin"); macToPing = cfg.readEntry("mac"); if (!macToPing.isEmpty()) { /* Standard, inescapable authentication dialog */ QDialog bluepingDialog(0, "Blueping dialog", TRUE, Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); QRect desk = oApp->desktop()->geometry(); bluepingDialog.setGeometry( 0, 0, desk.width(), desk.height() ); // Creation of the particular widgets of our Blueping user interface QVBoxLayout *layout = new QVBoxLayout(&bluepingDialog); layout->setSpacing(11); layout->setMargin(11); layout->setAlignment( Qt::AlignTop ); QLabel title("<center><h1>\"Blueping\" <br />plugin</h1></center>", &bluepingDialog); QLabel subTitle("<center><h2>Trying to reach your configured bluetooth device...</h2></center>", &bluepingDialog); |