summaryrefslogtreecommitdiff
authorzecke <zecke>2004-12-20 22:21:55 (UTC)
committer zecke <zecke>2004-12-20 22:21:55 (UTC)
commit2be4d5bf420dc4aff71cf78601c095a96ed88c47 (patch) (unidiff)
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 @@
1#include "bluepingConfigWidget.h" 1#include "bluepingConfigWidget.h"
2 2
3#include <qwidget.h> 3#include <qwidget.h>
4#include <qlayout.h> 4#include <qlayout.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qgroupbox.h> 6#include <qgroupbox.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qregexp.h> 8#include <qregexp.h>
9 9
10using Opie::Security::MultiauthConfigWidget; 10using Opie::Security::MultiauthConfigWidget;
11 11
12BluepingConfigWidget::BluepingConfigWidget(QWidget* parent = 0, const char* name = "Blueping configuration widget") 12BluepingConfigWidget::BluepingConfigWidget(QWidget* parent = 0, const char* name = "Blueping configuration widget")
13: MultiauthConfigWidget(parent, name) 13: MultiauthConfigWidget(parent, name)
14{ 14{
15 m_config = new Config("Security"); 15 Config config("Security");
16 m_config->setGroup("BluepingPlugin"); 16 config.setGroup("BluepingPlugin");
17 QVBoxLayout * baseLayout = new QVBoxLayout( this); 17 QVBoxLayout * baseLayout = new QVBoxLayout( this);
18 baseLayout->setSpacing(11); 18 baseLayout->setSpacing(11);
19 baseLayout->setMargin(11); 19 baseLayout->setMargin(11);
20 baseLayout->setAlignment( Qt::AlignTop ); 20 baseLayout->setAlignment( Qt::AlignTop );
21 21
22 QGroupBox * configBox = new QGroupBox(0, Qt::Vertical, tr("Set the MAC address to ping here"), this); 22 QGroupBox * configBox = new QGroupBox(0, Qt::Vertical, tr("Set the MAC address to ping here"), this);
23 baseLayout->addWidget(configBox); 23 baseLayout->addWidget(configBox);
24 QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() ); 24 QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() );
25 25
26 QHBoxLayout * configLayout = new QHBoxLayout(); 26 QHBoxLayout * configLayout = new QHBoxLayout();
27 configLayout->setSpacing(6); 27 configLayout->setSpacing(6);
28 boxLayout->addLayout(configLayout); 28 boxLayout->addLayout(configLayout);
29 29
30 QString mac = m_config->readEntry("mac"); 30 QString mac = config.readEntry("mac");
31 if ( mac.isEmpty() ) 31 if ( mac.isEmpty() )
32 mac = "00:00:00:00:00:00"; 32 mac = "00:00:00:00:00:00";
33 33
34 editMAC = new QLineEdit( mac, configBox, "editMAC" ); 34 editMAC = new QLineEdit( mac, configBox, "editMAC" );
35 setMAC = new QPushButton( tr("Set"), configBox, "setMAC" ); 35 setMAC = new QPushButton( tr("Set"), configBox, "setMAC" );
36 configLayout->addWidget(editMAC); 36 configLayout->addWidget(editMAC);
37 configLayout->addWidget(setMAC); 37 configLayout->addWidget(setMAC);
38 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>" 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 ); 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); 41 boxLayout->addWidget(description);
42 42
43 43
44 connect(setMAC, SIGNAL( clicked() ), this, SLOT( changeMAC() )); 44 connect(setMAC, SIGNAL( clicked() ), this, SLOT( changeMAC() ));
45 45
46} 46}
47 47
48/// checks and writes the MAC in the config file, if its format is OK 48/// checks and writes the MAC in the config file, if its format is OK
49void BluepingConfigWidget::changeMAC() { 49void BluepingConfigWidget::changeMAC() {
50 QString mac = editMAC->text(); 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]"); 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) ) 52 if ( (mac.length() == 17) && (macPattern.match(mac) == 0) )
53 { 53 {
54 m_config->writeEntry("mac", mac); 54 Config config("Security");
55 config.setGroup("BluepingPlugin");
56 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>", 57 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 ); 58 QMessageBox::Information, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton );
57 success.exec(); 59 success.exec();
58 } else { 60 } 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>"), 61 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 ); 62 QMessageBox::Warning, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton );
61 failure.exec(); 63 failure.exec();
62 } 64 }
63} 65}
64 66
65/// deletes the m_config pointer 67/// deletes the m_config pointer
66BluepingConfigWidget::~BluepingConfigWidget() 68BluepingConfigWidget::~BluepingConfigWidget()
67{ 69{}
68 delete m_config;
69}
70 70
71// does nothing (there's a button to save the config) 71// does nothing (there's a button to save the config)
72void BluepingConfigWidget::writeConfig() 72void BluepingConfigWidget::writeConfig()
73{ 73{
74} 74}
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
@@ -1,59 +1,58 @@
1/** 1/**
2 * \file bluepingConfigWidget.h 2 * \file bluepingConfigWidget.h
3 * \brief "BluePing" plugin configuration widget 3 * \brief "BluePing" plugin configuration widget
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 BLUEPINGCONFIGWIDGET_H 34#ifndef BLUEPINGCONFIGWIDGET_H
35#define BLUEPINGCONFIGWIDGET_H 35#define BLUEPINGCONFIGWIDGET_H
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39 39
40#include <opie2/multiauthconfigwidget.h> 40#include <opie2/multiauthconfigwidget.h>
41 41
42class BluepingConfigWidget : public Opie::Security::MultiauthConfigWidget { 42class BluepingConfigWidget : public Opie::Security::MultiauthConfigWidget {
43 43
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 BluepingConfigWidget(QWidget* parent, const char* name); 47 BluepingConfigWidget(QWidget* parent, const char* name);
48 virtual ~BluepingConfigWidget(); 48 virtual ~BluepingConfigWidget();
49 virtual void writeConfig(); 49 virtual void writeConfig();
50private: 50private:
51 QLineEdit *editMAC; 51 QLineEdit *editMAC;
52 QPushButton *setMAC; 52 QPushButton *setMAC;
53 Config *m_config;
54private slots: 53private slots:
55 void changeMAC(); 54 void changeMAC();
56 55
57}; 56};
58 57
59#endif // BLUEPINGCONFIGWIDGET_H 58#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
@@ -1,83 +1,81 @@
1#include "noticeConfigWidget.h" 1#include "noticeConfigWidget.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4 4
5#include <qwidget.h> 5#include <qwidget.h>
6#include <qlayout.h> 6#include <qlayout.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qregexp.h> 8#include <qregexp.h>
9#include <qgroupbox.h> 9#include <qgroupbox.h>
10 10
11using Opie::Security::MultiauthConfigWidget; 11using Opie::Security::MultiauthConfigWidget;
12 12
13/// constructs the widget, filling the noticeMLE QMultiLineEdit with the "noticeText" entry 13/// constructs the widget, filling the noticeMLE QMultiLineEdit with the "noticeText" entry
14NoticeConfigWidget::NoticeConfigWidget(QWidget* parent = 0, const char* name = "Notice configuration widget") : MultiauthConfigWidget(parent, name) 14NoticeConfigWidget::NoticeConfigWidget(QWidget* parent = 0, const char* name = "Notice configuration widget") : MultiauthConfigWidget(parent, name)
15{ 15{
16 QVBoxLayout *baseLayout = new QVBoxLayout( this); 16 QVBoxLayout *baseLayout = new QVBoxLayout( this);
17 baseLayout->setSpacing(11); 17 baseLayout->setSpacing(11);
18 baseLayout->setMargin(6); 18 baseLayout->setMargin(6);
19 baseLayout->setAlignment( Qt::AlignTop ); 19 baseLayout->setAlignment( Qt::AlignTop );
20 20
21 QGroupBox *configBox = new QGroupBox(0, Qt::Vertical, tr("Set the message the user must accept"), this); 21 QGroupBox *configBox = new QGroupBox(0, Qt::Vertical, tr("Set the message the user must accept"), this);
22 baseLayout->addWidget(configBox); 22 baseLayout->addWidget(configBox);
23 QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() ); 23 QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() );
24 24
25 QLabel * comment1 = new QLabel("<p><em>" + tr("You may want to consult your legal department for proper wording here.") + "</em></p>", configBox); 25 QLabel * comment1 = new QLabel("<p><em>" + tr("You may want to consult your legal department for proper wording here.") + "</em></p>", configBox);
26 boxLayout->addWidget(comment1); 26 boxLayout->addWidget(comment1);
27 27
28 // Set the multilineedit box text to getNoticeText() 28 // Set the multilineedit box text to getNoticeText()
29 noticeMLE = new QMultiLineEdit(configBox, "notice text"); 29 noticeMLE = new QMultiLineEdit(configBox, "notice text");
30 noticeMLE->setWordWrap(QMultiLineEdit::WidgetWidth); 30 noticeMLE->setWordWrap(QMultiLineEdit::WidgetWidth);
31 noticeMLE->setFocus(); 31 noticeMLE->setFocus();
32 noticeMLE->setText(getNoticeText()); 32 noticeMLE->setText(getNoticeText());
33 boxLayout->addWidget(noticeMLE); 33 boxLayout->addWidget(noticeMLE);
34 34
35 resetNoticeButton = new QPushButton( tr("Reset notice to default"), configBox, "reset Notice Button" ); 35 resetNoticeButton = new QPushButton( tr("Reset notice to default"), configBox, "reset Notice Button" );
36 connect(resetNoticeButton, SIGNAL( clicked() ), this, SLOT( resetNotice() )); 36 connect(resetNoticeButton, SIGNAL( clicked() ), this, SLOT( resetNotice() ));
37 boxLayout->addWidget(resetNoticeButton, 0, Qt::AlignHCenter); 37 boxLayout->addWidget(resetNoticeButton, 0, Qt::AlignHCenter);
38 38
39 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); 39 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);
40 boxLayout->addWidget(comment2); 40 boxLayout->addWidget(comment2);
41 41
42} 42}
43 43
44/// nothing to do 44/// nothing to do
45NoticeConfigWidget::~NoticeConfigWidget() 45NoticeConfigWidget::~NoticeConfigWidget()
46{} 46{}
47 47
48/// write the notice text in the multiauth.conf Config file 48/// write the notice text in the multiauth.conf Config file
49void NoticeConfigWidget::writeConfig() 49void NoticeConfigWidget::writeConfig()
50{ 50{
51 if ( noticeMLE->edited() ) { 51 if ( noticeMLE->edited() ) {
52 odebug << "writing new notice text in Security.conf" << oendl; 52 odebug << "writing new notice text in Security.conf" << oendl;
53 setNoticeText(noticeMLE->text()); 53 setNoticeText(noticeMLE->text());
54 } 54 }
55} 55}
56 56
57/// reset the notice text to the hard-coded example defaultNoticeText 57/// reset the notice text to the hard-coded example defaultNoticeText
58void NoticeConfigWidget::resetNotice() 58void NoticeConfigWidget::resetNotice()
59{ 59{
60 noticeMLE->setText(QObject::tr(defaultNoticeText)); 60 noticeMLE->setText(QObject::tr(defaultNoticeText));
61} 61}
62 62
63/// get the notice text from the config file (with true new lines) 63/// get the notice text from the config file (with true new lines)
64/** 64/**
65 * if no text has been defined yet returns defaultNoticeText 65 * if no text has been defined yet returns defaultNoticeText
66 */ 66 */
67QString NoticeConfigWidget::getNoticeText() { 67QString NoticeConfigWidget::getNoticeText() {
68 m_config = new Config("Security"); 68 Config config("Security");
69 m_config->setGroup("NoticePlugin"); 69 config.setGroup("NoticePlugin");
70 // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp 70 // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
71 QString noticeText = m_config->readEntry("noticeText", QObject::tr(defaultNoticeText) ).replace( QRegExp("\\\\n"), "\n" ); 71 QString noticeText = config.readEntry("noticeText", QObject::tr(defaultNoticeText) ).replace( QRegExp("\\\\n"), "\n" );
72 delete m_config;
73 return noticeText; 72 return noticeText;
74} 73}
75 74
76/// set the notice text in our m_config config file (escaping new lines) 75/// set the notice text in our m_config config file (escaping new lines)
77void NoticeConfigWidget::setNoticeText(QString noticeText) { 76void NoticeConfigWidget::setNoticeText(QString noticeText) {
78 m_config = new Config("Security"); 77 Config config("Security");
79 m_config->setGroup("NoticePlugin"); 78 config.setGroup("NoticePlugin");
80 // since Config files do not allow true newlines, we replace them with litteral "\n" 79 // since Config files do not allow true newlines, we replace them with litteral "\n"
81 m_config->writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" )); 80 config.writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" ));
82 delete m_config;
83} 81}
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 @@
1#include "noticeplugin.h" 1#include "noticeplugin.h"
2 2
3#include <opie2/oapplication.h> 3#include <opie2/oapplication.h>
4 4
5#include <qmessagebox.h> 5#include <qmessagebox.h>
6#include <qregexp.h> 6#include <qregexp.h>
7 7
8using Opie::Security::MultiauthPluginObject; 8using Opie::Security::MultiauthPluginObject;
9using Opie::Security::MultiauthConfigWidget; 9using Opie::Security::MultiauthConfigWidget;
10 10
11/// creates and initializes the m_config Config object 11/// creates and initializes the m_config Config object
12NoticePlugin::NoticePlugin() : MultiauthPluginObject(), m_noticeW(0) { 12NoticePlugin::NoticePlugin() : MultiauthPluginObject(), m_noticeW(0) {
13 m_config = new Config("Security");
14 m_config->setGroup("NoticePlugin");
15} 13}
16 14
17/// deletes the m_config Config object and noticeW if necessary 15/// deletes the m_config Config object and noticeW if necessary
18NoticePlugin::~NoticePlugin() { 16NoticePlugin::~NoticePlugin() {
19 delete m_config; 17 delete m_noticeW;
20 if (m_noticeW != 0)
21 delete m_noticeW;
22} 18}
23 19
24/// Simply return its name (Notice plugin) 20/// Simply return its name (Notice plugin)
25QString NoticePlugin::pluginName() const { 21QString NoticePlugin::pluginName() const {
26 return "Notice plugin"; 22 return "Notice plugin";
27} 23}
28 24
29/// return the Notice widget configuration widget 25/// return the Notice widget configuration widget
30/** 26/**
31 * \return noticeW, the NoticeConfigWidget 27 * \return noticeW, the NoticeConfigWidget
32 */ 28 */
33MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) { 29MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) {
34 if (m_noticeW == 0) 30 if (m_noticeW == 0)
35 m_noticeW = new NoticeConfigWidget(parent, "Notice configuration widget"); 31 m_noticeW = new NoticeConfigWidget(parent, "Notice configuration widget");
36 return m_noticeW; 32 return m_noticeW;
37} 33}
38 34
39/// return the path of the small tab icon 35/// return the path of the small tab icon
40QString NoticePlugin::pixmapNameConfig() const { 36QString NoticePlugin::pixmapNameConfig() const {
41 return "security/noticeplugin_small"; 37 return "security/noticeplugin_small";
42} 38}
43 39
44/// return the path of the big icon for the active/order checklist 40/// return the path of the big icon for the active/order checklist
45QString NoticePlugin::pixmapNameWidget() const { 41QString NoticePlugin::pixmapNameWidget() const {
46 return "security/noticeplugin"; 42 return "security/noticeplugin";
47} 43}
48 44
49/// Displays the configured message and an 'Accept' button 45/// Displays the configured message and an 'Accept' button
50/** 46/**
51 * \return the outcome code of this authentication (can be only success) 47 * \return the outcome code of this authentication (can be only success)
52 */ 48 */
53int NoticePlugin::authenticate() { 49int NoticePlugin::authenticate() {
54 QMessageBox noticeDialog("Notice plugin", 50 QMessageBox noticeDialog("Notice plugin",
55 getNoticeText(), 51 getNoticeText(),
56 QMessageBox::Warning, 52 QMessageBox::Warning,
57 QMessageBox::Yes, 53 QMessageBox::Yes,
58 0, 54 0,
59 0, 55 0,
60 0, 56 0,
61 "notice plugin dialog", 57 "notice plugin dialog",
62 true, 58 true,
63 Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); 59 Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop);
64 60
65 noticeDialog.setButtonText(QMessageBox::Yes, tr("I accept")); 61 noticeDialog.setButtonText(QMessageBox::Yes, tr("I accept"));
66 62
67 QRect desk = oApp->desktop()->geometry(); 63 QRect desk = oApp->desktop()->geometry();
68 noticeDialog.setGeometry( 0, 0, desk.width(), desk.height() ); 64 noticeDialog.setGeometry( 0, 0, desk.width(), desk.height() );
69 65
70 switch (noticeDialog.exec()) 66 switch (noticeDialog.exec())
71 { 67 {
72 case QMessageBox::Yes: 68 case QMessageBox::Yes:
73 return MultiauthPluginObject::Success; 69 return MultiauthPluginObject::Success;
74 } 70 }
75 return 255; //should not be returned anyway 71 return 255; //should not be returned anyway
76} 72}
77 73
78/// get the notice text from our m_config config file (with true new lines) 74/// get the notice text from our m_config config file (with true new lines)
79/** 75/**
80 * if no text has been defined yet returns defaultNoticeText 76 * if no text has been defined yet returns defaultNoticeText
81 */ 77 */
82QString NoticePlugin::getNoticeText() { 78QString NoticePlugin::getNoticeText() {
83 // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp 79 // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
84 return m_config->readEntry("noticeText", QObject::tr(defaultNoticeText)).replace( QRegExp("\\\\n"), "\n" ); 80 Config config("Security");
81 config.setGroup("NoticePlugin");
82 return config.readEntry("noticeText", QObject::tr(defaultNoticeText)).replace( QRegExp("\\\\n"), "\n" );
85} 83}
86 84
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
@@ -1,64 +1,63 @@
1/** 1/**
2 * \file noticeplugin.h 2 * \file noticeplugin.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 NOTICE_PLUGIN_H 34#ifndef NOTICE_PLUGIN_H
35#define NOTICE_PLUGIN_H 35#define NOTICE_PLUGIN_H
36 36
37#include <qstring.h> 37#include <qstring.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39#include <opie2/multiauthplugininterface.h> 39#include <opie2/multiauthplugininterface.h>
40#include "noticeConfigWidget.h" 40#include "noticeConfigWidget.h"
41 41
42/// Multi-authentication plugin, having the user accept a (legal, etc.) notice text. 42/// Multi-authentication plugin, having the user accept a (legal, etc.) notice text.
43/** 43/**
44 * The plugin itself, implementing the main authenticate() function. 44 * The plugin itself, implementing the main authenticate() function.
45 */ 45 */
46class NoticePlugin : public QObject, public Opie::Security::MultiauthPluginObject { 46class NoticePlugin : public QObject, public Opie::Security::MultiauthPluginObject {
47 47
48 Q_OBJECT; 48 Q_OBJECT;
49 49
50public: 50public:
51 NoticePlugin(); 51 NoticePlugin();
52 virtual ~NoticePlugin(); 52 virtual ~NoticePlugin();
53 int authenticate(); 53 int authenticate();
54 Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent); 54 Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent);
55 QString pixmapNameConfig() const; 55 QString pixmapNameConfig() const;
56 QString pixmapNameWidget() const; 56 QString pixmapNameWidget() const;
57 QString pluginName() const; 57 QString pluginName() const;
58private: 58private:
59 NoticeConfigWidget * m_noticeW; 59 NoticeConfigWidget * m_noticeW;
60 Config * m_config;
61 QString getNoticeText(); 60 QString getNoticeText();
62}; 61};
63 62
64#endif 63#endif