summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/securityplugins/blueping/bluepingConfigWidget.cpp74
-rw-r--r--noncore/securityplugins/blueping/bluepingConfigWidget.h59
-rw-r--r--noncore/securityplugins/blueping/bluepingplugin.cpp21
-rw-r--r--noncore/securityplugins/blueping/bluepingplugin.h4
-rw-r--r--noncore/securityplugins/blueping/bluepingplugin.pro4
5 files changed, 150 insertions, 12 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
10using Opie::Security::MultiauthConfigWidget;
11
12BluepingConfigWidget::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
49void 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
66BluepingConfigWidget::~BluepingConfigWidget()
67{
68 delete m_config;
69}
70
71// does nothing (there's a button to save the config)
72void 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
42class BluepingConfigWidget : public Opie::Security::MultiauthConfigWidget {
43
44 Q_OBJECT
45
46public:
47 BluepingConfigWidget(QWidget* parent, const char* name);
48 virtual ~BluepingConfigWidget();
49 virtual void writeConfig();
50private:
51 QLineEdit *editMAC;
52 QPushButton *setMAC;
53 Config *m_config;
54private 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
@@ -16,17 +16,16 @@ using Opie::Security::MultiauthPluginObject;
16using Opie::Security::MultiauthConfigWidget; 16using Opie::Security::MultiauthConfigWidget;
17 17
18 18
19/// creates and initializes the m_config Config object 19/// standard c'tor
20BluepingPlugin::BluepingPlugin() : MultiauthPluginObject(), m_ping(0) { 20BluepingPlugin::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
27BluepingPlugin::~BluepingPlugin() { 25BluepingPlugin::~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)
@@ -34,15 +33,17 @@ 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
38MultiauthConfigWidget * BluepingPlugin::configWidget(QWidget * parent) { 37MultiauthConfigWidget * 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}
41QString BluepingPlugin::pixmapNameWidget() const { 42QString BluepingPlugin::pixmapNameWidget() const {
42 return "security/bluepingplugin"; 43 return "security/bluepingplugin";
43} 44}
44QString BluepingPlugin::pixmapNameConfig() const { 45QString 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
@@ -135,6 +136,8 @@ int BluepingPlugin::authenticate() {
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
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
@@ -34,6 +34,8 @@
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>
@@ -72,7 +74,7 @@ class BluepingPlugin : public QObject, public Opie::Security::MultiauthPluginObj
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
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,9 +1,9 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on 2CONFIG += 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