author | clem <clem> | 2004-06-15 13:49:36 (UTC) |
---|---|---|
committer | clem <clem> | 2004-06-15 13:49:36 (UTC) |
commit | 5431072f0ea1cbc8ca37914b6349e66079f1acff (patch) (side-by-side diff) | |
tree | da335f89e506cde6ffe59a252b4ccab4e177809b /noncore/securityplugins/notice/noticeplugin.cpp | |
parent | ba4722d0fed5527a5b799281caf6324f2e7ad5d8 (diff) | |
download | opie-5431072f0ea1cbc8ca37914b6349e66079f1acff.zip opie-5431072f0ea1cbc8ca37914b6349e66079f1acff.tar.gz opie-5431072f0ea1cbc8ca37914b6349e66079f1acff.tar.bz2 |
First revision of securityplugins, called by libopiesecurity2 authentication framework (see http://dudu.dyn.2-h.org/nist/OMAF.php).
Diffstat (limited to 'noncore/securityplugins/notice/noticeplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/securityplugins/notice/noticeplugin.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/noncore/securityplugins/notice/noticeplugin.cpp b/noncore/securityplugins/notice/noticeplugin.cpp new file mode 100644 index 0000000..f7d41ab --- a/dev/null +++ b/noncore/securityplugins/notice/noticeplugin.cpp @@ -0,0 +1,83 @@ +#include "noticeplugin.h" + +#include <opie2/oapplication.h> + +#include <qmessagebox.h> +#include <qregexp.h> + +/// creates and initializes the m_config Config object +NoticePlugin::NoticePlugin() : MultiauthPluginObject(), 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 (noticeW != 0) + delete 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 (noticeW == 0) + noticeW = new NoticeConfigWidget(parent, "Notice configuration widget"); + return 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, "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", defaultNoticeText).replace( QRegExp("\\\\n"), "\n" ); +} + |