author | clem <clem> | 2004-06-15 13:49:36 (UTC) |
---|---|---|
committer | clem <clem> | 2004-06-15 13:49:36 (UTC) |
commit | 5431072f0ea1cbc8ca37914b6349e66079f1acff (patch) (unidiff) | |
tree | da335f89e506cde6ffe59a252b4ccab4e177809b /noncore/securityplugins/dummy/dummyplugin.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/dummy/dummyplugin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/securityplugins/dummy/dummyplugin.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/noncore/securityplugins/dummy/dummyplugin.cpp b/noncore/securityplugins/dummy/dummyplugin.cpp new file mode 100644 index 0000000..0d19e43 --- a/dev/null +++ b/noncore/securityplugins/dummy/dummyplugin.cpp | |||
@@ -0,0 +1,92 @@ | |||
1 | #include "dummyplugin.h" | ||
2 | |||
3 | #include <opie2/oapplication.h> | ||
4 | |||
5 | #include <qdialog.h> | ||
6 | #include <qlayout.h> | ||
7 | #include <qlabel.h> | ||
8 | #include <qpushbutton.h> | ||
9 | |||
10 | /// Simply return its name (Dummy plugin) | ||
11 | QString DummyPlugin::pluginName() const { | ||
12 | return "Dummy plugin"; | ||
13 | } | ||
14 | |||
15 | /// no configuration widget for the moment | ||
16 | MultiauthConfigWidget * DummyPlugin::configWidget(QWidget * parent) { | ||
17 | return 0l; | ||
18 | } | ||
19 | QString DummyPlugin::pixmapNameWidget() const { | ||
20 | return "security/dummyplugin"; | ||
21 | } | ||
22 | QString DummyPlugin::pixmapNameConfig() const { | ||
23 | return 0l; | ||
24 | } | ||
25 | |||
26 | /// Emit the MultiauthPluginObject::Success emitCode | ||
27 | void DummyPlugin::success() { | ||
28 | emit emitCode(MultiauthPluginObject::Success); | ||
29 | } | ||
30 | |||
31 | /// Emit the MultiauthPluginObject::Failure emitCode | ||
32 | void DummyPlugin::failure() { | ||
33 | emit emitCode(MultiauthPluginObject::Failure); | ||
34 | } | ||
35 | |||
36 | /// Emit the MultiauthPluginObject::Skip emitCode | ||
37 | void DummyPlugin::skip() { | ||
38 | emit emitCode(MultiauthPluginObject::Skip); | ||
39 | } | ||
40 | |||
41 | /// Make one authentication attempt with this plugin | ||
42 | /** | ||
43 | * (very simple "success" / "failure" buttons in a dialog) | ||
44 | * \return The outcome code of this authentication | ||
45 | */ | ||
46 | int DummyPlugin::authenticate() { | ||
47 | |||
48 | /* Standard, inescapable authentication dialog | ||
49 | */ | ||
50 | QDialog dummyDialog(0, | ||
51 | "Dummy dialog", | ||
52 | TRUE, | ||
53 | Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); | ||
54 | |||
55 | QRect desk = oApp->desktop()->geometry(); | ||
56 | dummyDialog.setGeometry( 0, 0, desk.width(), desk.height() ); | ||
57 | |||
58 | /* Creation of the particular widgets of our Dummy user interface | ||
59 | * Note: we have to resize the VBox to the QDialog size, since it's not | ||
60 | * done automatically. | ||
61 | */ | ||
62 | QVBoxLayout layout(&dummyDialog); | ||
63 | layout.setSpacing(11); | ||
64 | layout.setMargin(11); | ||
65 | layout.setAlignment( Qt::AlignTop ); | ||
66 | |||
67 | QLabel title("<center><h1>" + tr("\"Dummy\" <br />demonstration plugin") + "</h1></center>", &dummyDialog); | ||
68 | QLabel subTitle("<center><h2>" +tr("You can simulate the following outcomes:") + "</h2></center>", &dummyDialog); | ||
69 | layout.addWidget(&title); | ||
70 | layout.addWidget(&subTitle); | ||
71 | |||
72 | QHBoxLayout hl(&layout); | ||
73 | QPushButton pbSuccess("Success", &dummyDialog); | ||
74 | QPushButton pbSkip("Skip", &dummyDialog); | ||
75 | QPushButton pbFailure("Failure", &dummyDialog); | ||
76 | hl.addWidget(&pbSuccess, 0, Qt::AlignHCenter); | ||
77 | hl.addWidget(&pbSkip, 0, Qt::AlignHCenter); | ||
78 | hl.addWidget(&pbFailure, 0, Qt::AlignHCenter); | ||
79 | |||
80 | /* Linking our pushbuttons to exit functions | ||
81 | * (each result button here has a corresponding slot) | ||
82 | */ | ||
83 | QObject::connect(&pbSuccess, SIGNAL(clicked()), this, SLOT(success())); | ||
84 | QObject::connect(&pbFailure, SIGNAL(clicked()), this, SLOT(failure())); | ||
85 | QObject::connect(&pbSkip, SIGNAL(clicked()), this, SLOT(skip())); | ||
86 | |||
87 | /* The value of the signal these three slots will emit corresponds to | ||
88 | * the different values we want to return | ||
89 | */ | ||
90 | QObject::connect(this, SIGNAL(emitCode(int)), &dummyDialog, SLOT(done(int))); | ||
91 | return dummyDialog.exec(); | ||
92 | } | ||