Diffstat (limited to 'noncore/securityplugins/notice') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/securityplugins/notice/noticeConfigWidget.cpp | 14 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticeplugin.cpp | 10 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticeplugin.h | 1 |
3 files changed, 10 insertions, 15 deletions
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 | |||
@@ -56,28 +56,26 @@ void NoticeConfigWidget::writeConfig() | |||
56 | 56 | ||
57 | /// reset the notice text to the hard-coded example defaultNoticeText | 57 | /// reset the notice text to the hard-coded example defaultNoticeText |
58 | void NoticeConfigWidget::resetNotice() | 58 | void 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 | */ |
67 | QString NoticeConfigWidget::getNoticeText() { | 67 | QString 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) |
77 | void NoticeConfigWidget::setNoticeText(QString noticeText) { | 76 | void 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,33 +1,29 @@ | |||
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 | ||
8 | using Opie::Security::MultiauthPluginObject; | 8 | using Opie::Security::MultiauthPluginObject; |
9 | using Opie::Security::MultiauthConfigWidget; | 9 | using Opie::Security::MultiauthConfigWidget; |
10 | 10 | ||
11 | /// creates and initializes the m_config Config object | 11 | /// creates and initializes the m_config Config object |
12 | NoticePlugin::NoticePlugin() : MultiauthPluginObject(), m_noticeW(0) { | 12 | NoticePlugin::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 |
18 | NoticePlugin::~NoticePlugin() { | 16 | NoticePlugin::~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) |
25 | QString NoticePlugin::pluginName() const { | 21 | QString 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 | */ |
33 | MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) { | 29 | MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) { |
@@ -72,15 +68,17 @@ int NoticePlugin::authenticate() { | |||
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 | */ |
82 | QString NoticePlugin::getNoticeText() { | 78 | QString 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 | |||
@@ -48,17 +48,16 @@ class NoticePlugin : public QObject, public Opie::Security::MultiauthPluginObjec | |||
48 | Q_OBJECT; | 48 | Q_OBJECT; |
49 | 49 | ||
50 | public: | 50 | public: |
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; |
58 | private: | 58 | private: |
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 |