summaryrefslogtreecommitdiff
path: root/noncore/securityplugins/notice
Side-by-side diff
Diffstat (limited to 'noncore/securityplugins/notice') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/securityplugins/notice/noticeConfigWidget.cpp4
-rw-r--r--noncore/securityplugins/notice/noticeConfigWidget.h15
-rw-r--r--noncore/securityplugins/notice/noticeplugin.cpp6
-rw-r--r--noncore/securityplugins/notice/noticeplugin.h4
-rw-r--r--noncore/securityplugins/notice/noticepluginimpl.cpp3
-rw-r--r--noncore/securityplugins/notice/noticepluginimpl.h5
6 files changed, 22 insertions, 15 deletions
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.cpp b/noncore/securityplugins/notice/noticeConfigWidget.cpp
index e2c2d83..e532232 100644
--- a/noncore/securityplugins/notice/noticeConfigWidget.cpp
+++ b/noncore/securityplugins/notice/noticeConfigWidget.cpp
@@ -1,81 +1,83 @@
#include "noticeConfigWidget.h"
#include <opie2/odebug.h>
#include <qwidget.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qregexp.h>
#include <qgroupbox.h>
+using Opie::Security::MultiauthConfigWidget;
+
/// constructs the widget, filling the noticeMLE QMultiLineEdit with the "noticeText" entry
NoticeConfigWidget::NoticeConfigWidget(QWidget* parent = 0, const char* name = "Notice configuration widget") : MultiauthConfigWidget(parent, name)
{
QVBoxLayout *baseLayout = new QVBoxLayout( this);
baseLayout->setSpacing(11);
baseLayout->setMargin(6);
baseLayout->setAlignment( Qt::AlignTop );
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() ) {
+ 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(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");
// Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
QString noticeText = m_config->readEntry("noticeText", defaultNoticeText).replace( QRegExp("\\\\n"), "\n" );
delete m_config;
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");
// 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;
}
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.h b/noncore/securityplugins/notice/noticeConfigWidget.h
index 69f15bf..c90484c 100644
--- a/noncore/securityplugins/notice/noticeConfigWidget.h
+++ b/noncore/securityplugins/notice/noticeConfigWidget.h
@@ -1,71 +1,72 @@
/**
* \file noticeConfigWidget.h
* \brief Notice plugin configuration widget
* \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
*/
/*
=. 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
+ _;:, .> :=|. 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
+ .%`+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.
+ -- :-=` 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 NOTICECONFIGWIDGET_H
#define NOTICECONFIGWIDGET_H
#include <qpushbutton.h>
#include <qmultilineedit.h>
#include <qpe/config.h>
#include <opie2/multiauthconfigwidget.h>
static char defaultNoticeText [] = "<h2>NOTICE TO USERS</h2>\n"
"<p>This is a private computer system and is the property of "
"the company XXX / Mr or Ms X. It is for authorized "
"use only. Users have no expectation of privacy.</p>\n"
"<p><strong>Unauthorized or improper use of this system may result in "
"disciplinary action and civil and criminal penalties. <em>By continuing to use "
"this system you indicate your awareness of and consent to these "
"terms. LOG OFF IMMEDIATELY if you do not agree to them.</em></strong></p>";
-
-class NoticeConfigWidget : public MultiauthConfigWidget {
+
+class NoticeConfigWidget : public Opie::Security::MultiauthConfigWidget {
Q_OBJECT
public:
NoticeConfigWidget(QWidget* parent, const char* name);
virtual ~NoticeConfigWidget();
virtual void writeConfig();
private:
QMultiLineEdit * noticeMLE;
QPushButton * resetNoticeButton;
private slots:
void resetNotice();
private:
Config * m_config;
QString getNoticeText();
void setNoticeText(QString noticeText);
};
#endif // NOTICECONFIGWIDGET_H
+
diff --git a/noncore/securityplugins/notice/noticeplugin.cpp b/noncore/securityplugins/notice/noticeplugin.cpp
index bacc439..25a452a 100644
--- a/noncore/securityplugins/notice/noticeplugin.cpp
+++ b/noncore/securityplugins/notice/noticeplugin.cpp
@@ -1,84 +1,86 @@
#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(), 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, 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", defaultNoticeText).replace( QRegExp("\\\\n"), "\n" );
}
diff --git a/noncore/securityplugins/notice/noticeplugin.h b/noncore/securityplugins/notice/noticeplugin.h
index 842d47b..4aa6f02 100644
--- a/noncore/securityplugins/notice/noticeplugin.h
+++ b/noncore/securityplugins/notice/noticeplugin.h
@@ -1,64 +1,64 @@
/**
* \file noticeplugin.h
* \brief Standard Opie multiauth plugin definition
* \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
*/
/*
=. 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 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 MultiauthPluginObject {
+class NoticePlugin : public QObject, public Opie::Security::MultiauthPluginObject {
Q_OBJECT;
public:
NoticePlugin();
virtual ~NoticePlugin();
int authenticate();
- MultiauthConfigWidget * configWidget(QWidget * parent);
+ Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent);
QString pixmapNameConfig() const;
QString pixmapNameWidget() const;
QString pluginName() const;
private:
NoticeConfigWidget * noticeW;
Config * m_config;
QString getNoticeText();
};
#endif
diff --git a/noncore/securityplugins/notice/noticepluginimpl.cpp b/noncore/securityplugins/notice/noticepluginimpl.cpp
index 34e3cfc..7524512 100644
--- a/noncore/securityplugins/notice/noticepluginimpl.cpp
+++ b/noncore/securityplugins/notice/noticepluginimpl.cpp
@@ -1,28 +1,31 @@
#include "noticepluginimpl.h"
+using Opie::Security::MultiauthPluginObject;
+using Opie::Security::MultiauthPluginInterface;
+
NoticePluginImpl::NoticePluginImpl() {
noticePlugin = new NoticePlugin();
}
NoticePluginImpl::~NoticePluginImpl() {
delete noticePlugin;
}
MultiauthPluginObject* NoticePluginImpl::plugin() {
return noticePlugin;
}
Q_EXPORT_INTERFACE() {
Q_CREATE_INSTANCE( NoticePluginImpl )
}
QRESULT NoticePluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) {
*iface = 0;
if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MultiauthPluginInterface ) ) {
*iface = this, (*iface)->addRef();
} else {
return QE_NOINTERFACE;
}
return QS_OK;
}
diff --git a/noncore/securityplugins/notice/noticepluginimpl.h b/noncore/securityplugins/notice/noticepluginimpl.h
index b2a1140..1b1e22f 100644
--- a/noncore/securityplugins/notice/noticepluginimpl.h
+++ b/noncore/securityplugins/notice/noticepluginimpl.h
@@ -1,61 +1,60 @@
/**
* \file noticepluginimpl.h
* \brief Standard Opie multiauth plugin definition
* \author Clément Séveillac (clement . seveillac (at) via . ecp . fr)
*/
/*
=. 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 NOTICE_PLUGIN_IMPL
#define NOTICE_PLUGIN_IMPL
#include "noticeplugin.h"
/**
* \brief Standard multiauth plugin class
*/
-class NoticePluginImpl : public MultiauthPluginInterface{
+class NoticePluginImpl : public Opie::Security::MultiauthPluginInterface{
public:
NoticePluginImpl();
virtual ~NoticePluginImpl();
QRESULT queryInterface( const QUuid &, QUnknownInterface** );
/// defines standard addRef() and release() functions
Q_REFCOUNT;
- virtual MultiauthPluginObject *plugin();
+ virtual Opie::Security::MultiauthPluginObject *plugin();
private:
/// the plugin itself
NoticePlugin *noticePlugin;
- ulong ref;
};
#endif