summaryrefslogtreecommitdiff
authorzecke <zecke>2004-12-20 22:21:55 (UTC)
committer zecke <zecke>2004-12-20 22:21:55 (UTC)
commit2be4d5bf420dc4aff71cf78601c095a96ed88c47 (patch) (side-by-side diff)
treef8d053d475501c2230a2c65acc1bed091d39faf9
parentb15930cd03acafd9770bca26f3388817f1a4dcbf (diff)
downloadopie-2be4d5bf420dc4aff71cf78601c095a96ed88c47.zip
opie-2be4d5bf420dc4aff71cf78601c095a96ed88c47.tar.gz
opie-2be4d5bf420dc4aff71cf78601c095a96ed88c47.tar.bz2
Create the 'Config' instance on the Stack to avoid
that we revert changes done in between of our creation and deletion
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/securityplugins/blueping/bluepingConfigWidget.cpp14
-rw-r--r--noncore/securityplugins/blueping/bluepingConfigWidget.h1
-rw-r--r--noncore/securityplugins/notice/noticeConfigWidget.cpp14
-rw-r--r--noncore/securityplugins/notice/noticeplugin.cpp10
-rw-r--r--noncore/securityplugins/notice/noticeplugin.h1
5 files changed, 17 insertions, 23 deletions
diff --git a/noncore/securityplugins/blueping/bluepingConfigWidget.cpp b/noncore/securityplugins/blueping/bluepingConfigWidget.cpp
index 876ccda..17168f9 100644
--- a/noncore/securityplugins/blueping/bluepingConfigWidget.cpp
+++ b/noncore/securityplugins/blueping/bluepingConfigWidget.cpp
@@ -1,74 +1,74 @@
#include "bluepingConfigWidget.h"
#include <qwidget.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qgroupbox.h>
#include <qmessagebox.h>
#include <qregexp.h>
using Opie::Security::MultiauthConfigWidget;
BluepingConfigWidget::BluepingConfigWidget(QWidget* parent = 0, const char* name = "Blueping configuration widget")
: MultiauthConfigWidget(parent, name)
{
- m_config = new Config("Security");
- m_config->setGroup("BluepingPlugin");
+ Config config("Security");
+ config.setGroup("BluepingPlugin");
QVBoxLayout * baseLayout = new QVBoxLayout( this);
baseLayout->setSpacing(11);
baseLayout->setMargin(11);
baseLayout->setAlignment( Qt::AlignTop );
QGroupBox * configBox = new QGroupBox(0, Qt::Vertical, tr("Set the MAC address to ping here"), this);
baseLayout->addWidget(configBox);
QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() );
QHBoxLayout * configLayout = new QHBoxLayout();
configLayout->setSpacing(6);
boxLayout->addLayout(configLayout);
- QString mac = m_config->readEntry("mac");
+ QString mac = config.readEntry("mac");
if ( mac.isEmpty() )
mac = "00:00:00:00:00:00";
editMAC = new QLineEdit( mac, configBox, "editMAC" );
setMAC = new QPushButton( tr("Set"), configBox, "setMAC" );
configLayout->addWidget(editMAC);
configLayout->addWidget(setMAC);
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>"
+ tr("Note: if you don't put a valid MAC here but you activate the plugin, it will always succeed!") + "</em></p>", configBox );
boxLayout->addWidget(description);
connect(setMAC, SIGNAL( clicked() ), this, SLOT( changeMAC() ));
}
/// checks and writes the MAC in the config file, if its format is OK
void BluepingConfigWidget::changeMAC() {
QString mac = editMAC->text();
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]");
if ( (mac.length() == 17) && (macPattern.match(mac) == 0) )
{
- m_config->writeEntry("mac", mac);
+ Config config("Security");
+ config.setGroup("BluepingPlugin");
+ config.writeEntry("mac", mac);
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>",
QMessageBox::Information, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton );
success.exec();
} else {
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>"),
QMessageBox::Warning, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton );
failure.exec();
}
}
/// deletes the m_config pointer
BluepingConfigWidget::~BluepingConfigWidget()
-{
- delete m_config;
-}
+{}
// does nothing (there's a button to save the config)
void BluepingConfigWidget::writeConfig()
{
}
diff --git a/noncore/securityplugins/blueping/bluepingConfigWidget.h b/noncore/securityplugins/blueping/bluepingConfigWidget.h
index bd1bec9..643c97f 100644
--- a/noncore/securityplugins/blueping/bluepingConfigWidget.h
+++ b/noncore/securityplugins/blueping/bluepingConfigWidget.h
@@ -5,55 +5,54 @@
*/
/*
=. This file is part of the Opie Project
.=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
.>+-=
_;:, .> :=|. This library is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This library is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef BLUEPINGCONFIGWIDGET_H
#define BLUEPINGCONFIGWIDGET_H
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qpe/config.h>
#include <opie2/multiauthconfigwidget.h>
class BluepingConfigWidget : public Opie::Security::MultiauthConfigWidget {
Q_OBJECT
public:
BluepingConfigWidget(QWidget* parent, const char* name);
virtual ~BluepingConfigWidget();
virtual void writeConfig();
private:
QLineEdit *editMAC;
QPushButton *setMAC;
- Config *m_config;
private slots:
void changeMAC();
};
#endif // BLUEPINGCONFIGWIDGET_H
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.cpp b/noncore/securityplugins/notice/noticeConfigWidget.cpp
index e0468a7..02084f8 100644
--- a/noncore/securityplugins/notice/noticeConfigWidget.cpp
+++ b/noncore/securityplugins/notice/noticeConfigWidget.cpp
@@ -20,64 +20,62 @@ NoticeConfigWidget::NoticeConfigWidget(QWidget* parent = 0, const char* name = "
QGroupBox *configBox = new QGroupBox(0, Qt::Vertical, tr("Set the message the user must accept"), this);
baseLayout->addWidget(configBox);
QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() );
QLabel * comment1 = new QLabel("<p><em>" + tr("You may want to consult your legal department for proper wording here.") + "</em></p>", configBox);
boxLayout->addWidget(comment1);
// Set the multilineedit box text to getNoticeText()
noticeMLE = new QMultiLineEdit(configBox, "notice text");
noticeMLE->setWordWrap(QMultiLineEdit::WidgetWidth);
noticeMLE->setFocus();
noticeMLE->setText(getNoticeText());
boxLayout->addWidget(noticeMLE);
resetNoticeButton = new QPushButton( tr("Reset notice to default"), configBox, "reset Notice Button" );
connect(resetNoticeButton, SIGNAL( clicked() ), this, SLOT( resetNotice() ));
boxLayout->addWidget(resetNoticeButton, 0, Qt::AlignHCenter);
QLabel * comment2 = new QLabel("<p>" + tr("Note: you can use HTML tags to improve its layout (example: text between &lt;em&gt; and &lt;/em&gt; will be <em>emphasized</em>)") + "</p>", configBox);
boxLayout->addWidget(comment2);
}
/// nothing to do
NoticeConfigWidget::~NoticeConfigWidget()
{}
/// write the notice text in the multiauth.conf Config file
void NoticeConfigWidget::writeConfig()
{
if ( noticeMLE->edited() ) {
odebug << "writing new notice text in Security.conf" << oendl;
setNoticeText(noticeMLE->text());
}
}
/// reset the notice text to the hard-coded example defaultNoticeText
void NoticeConfigWidget::resetNotice()
{
noticeMLE->setText(QObject::tr(defaultNoticeText));
}
/// get the notice text from the config file (with true new lines)
/**
* if no text has been defined yet returns defaultNoticeText
*/
QString NoticeConfigWidget::getNoticeText() {
- m_config = new Config("Security");
- m_config->setGroup("NoticePlugin");
+ Config config("Security");
+ config.setGroup("NoticePlugin");
// Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
- QString noticeText = m_config->readEntry("noticeText", QObject::tr(defaultNoticeText) ).replace( QRegExp("\\\\n"), "\n" );
- delete m_config;
+ QString noticeText = config.readEntry("noticeText", QObject::tr(defaultNoticeText) ).replace( QRegExp("\\\\n"), "\n" );
return noticeText;
}
/// set the notice text in our m_config config file (escaping new lines)
void NoticeConfigWidget::setNoticeText(QString noticeText) {
- m_config = new Config("Security");
- m_config->setGroup("NoticePlugin");
+ Config config("Security");
+ config.setGroup("NoticePlugin");
// since Config files do not allow true newlines, we replace them with litteral "\n"
- m_config->writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" ));
- delete m_config;
+ config.writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" ));
}
diff --git a/noncore/securityplugins/notice/noticeplugin.cpp b/noncore/securityplugins/notice/noticeplugin.cpp
index 5617855..d3dc7a4 100644
--- a/noncore/securityplugins/notice/noticeplugin.cpp
+++ b/noncore/securityplugins/notice/noticeplugin.cpp
@@ -1,86 +1,84 @@
#include "noticeplugin.h"
#include <opie2/oapplication.h>
#include <qmessagebox.h>
#include <qregexp.h>
using Opie::Security::MultiauthPluginObject;
using Opie::Security::MultiauthConfigWidget;
/// creates and initializes the m_config Config object
NoticePlugin::NoticePlugin() : MultiauthPluginObject(), m_noticeW(0) {
- m_config = new Config("Security");
- m_config->setGroup("NoticePlugin");
}
/// deletes the m_config Config object and noticeW if necessary
NoticePlugin::~NoticePlugin() {
- delete m_config;
- if (m_noticeW != 0)
- delete m_noticeW;
+ delete m_noticeW;
}
/// Simply return its name (Notice plugin)
QString NoticePlugin::pluginName() const {
return "Notice plugin";
}
/// return the Notice widget configuration widget
/**
* \return noticeW, the NoticeConfigWidget
*/
MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) {
if (m_noticeW == 0)
m_noticeW = new NoticeConfigWidget(parent, "Notice configuration widget");
return m_noticeW;
}
/// return the path of the small tab icon
QString NoticePlugin::pixmapNameConfig() const {
return "security/noticeplugin_small";
}
/// return the path of the big icon for the active/order checklist
QString NoticePlugin::pixmapNameWidget() const {
return "security/noticeplugin";
}
/// Displays the configured message and an 'Accept' button
/**
* \return the outcome code of this authentication (can be only success)
*/
int NoticePlugin::authenticate() {
QMessageBox noticeDialog("Notice plugin",
getNoticeText(),
QMessageBox::Warning,
QMessageBox::Yes,
0,
0,
0,
"notice plugin dialog",
true,
Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop);
noticeDialog.setButtonText(QMessageBox::Yes, tr("I accept"));
QRect desk = oApp->desktop()->geometry();
noticeDialog.setGeometry( 0, 0, desk.width(), desk.height() );
switch (noticeDialog.exec())
{
case QMessageBox::Yes:
return MultiauthPluginObject::Success;
}
return 255; //should not be returned anyway
}
/// get the notice text from our m_config config file (with true new lines)
/**
* if no text has been defined yet returns defaultNoticeText
*/
QString NoticePlugin::getNoticeText() {
// Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
- return m_config->readEntry("noticeText", QObject::tr(defaultNoticeText)).replace( QRegExp("\\\\n"), "\n" );
+ Config config("Security");
+ config.setGroup("NoticePlugin");
+ return config.readEntry("noticeText", QObject::tr(defaultNoticeText)).replace( QRegExp("\\\\n"), "\n" );
}
diff --git a/noncore/securityplugins/notice/noticeplugin.h b/noncore/securityplugins/notice/noticeplugin.h
index 2828f58..22b2322 100644
--- a/noncore/securityplugins/notice/noticeplugin.h
+++ b/noncore/securityplugins/notice/noticeplugin.h
@@ -12,53 +12,52 @@
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This library is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef NOTICE_PLUGIN_H
#define NOTICE_PLUGIN_H
#include <qstring.h>
#include <qpe/config.h>
#include <opie2/multiauthplugininterface.h>
#include "noticeConfigWidget.h"
/// Multi-authentication plugin, having the user accept a (legal, etc.) notice text.
/**
* The plugin itself, implementing the main authenticate() function.
*/
class NoticePlugin : public QObject, public Opie::Security::MultiauthPluginObject {
Q_OBJECT;
public:
NoticePlugin();
virtual ~NoticePlugin();
int authenticate();
Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent);
QString pixmapNameConfig() const;
QString pixmapNameWidget() const;
QString pluginName() const;
private:
NoticeConfigWidget * m_noticeW;
- Config * m_config;
QString getNoticeText();
};
#endif