summaryrefslogtreecommitdiff
path: root/noncore/securityplugins
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 /noncore/securityplugins
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 (limited to 'noncore/securityplugins') (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
@@ -12,8 +12,8 @@ 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);
@@ -27,7 +27,7 @@ BluepingConfigWidget::BluepingConfigWidget(QWidget* parent = 0, const char* name
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";
@@ -51,7 +51,9 @@ void BluepingConfigWidget::changeMAC() {
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();
@@ -64,9 +66,7 @@ void BluepingConfigWidget::changeMAC() {
/// 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
@@ -50,7 +50,6 @@ public:
private:
QLineEdit *editMAC;
QPushButton *setMAC;
- Config *m_config;
private slots:
void changeMAC();
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
@@ -65,19 +65,17 @@ void NoticeConfigWidget::resetNotice()
* 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
@@ -10,15 +10,11 @@ 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)
@@ -81,6 +77,8 @@ int NoticePlugin::authenticate() {
*/
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
@@ -57,7 +57,6 @@ public:
QString pluginName() const;
private:
NoticeConfigWidget * m_noticeW;
- Config * m_config;
QString getNoticeText();
};