-rw-r--r-- | libopie2/opiesecurity/config.in | 3 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthcommon.cpp | 179 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthcommon.h | 62 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthconfigwidget.h | 68 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthmainwindow.cpp | 129 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthmainwindow.h | 74 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthplugininterface.h | 109 | ||||
-rw-r--r-- | libopie2/opiesecurity/opiesecurity.pro | 15 |
8 files changed, 639 insertions, 0 deletions
diff --git a/libopie2/opiesecurity/config.in b/libopie2/opiesecurity/config.in new file mode 100644 index 0000000..bf33bd2 --- a/dev/null +++ b/libopie2/opiesecurity/config.in | |||
@@ -0,0 +1,3 @@ | |||
1 | config LIBOPIE2SECURITY | ||
2 | boolean "libopie2security (plugin-based authentication library for Opie)" | ||
3 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI | ||
diff --git a/libopie2/opiesecurity/multiauthcommon.cpp b/libopie2/opiesecurity/multiauthcommon.cpp new file mode 100644 index 0000000..b72b9b1 --- a/dev/null +++ b/libopie2/opiesecurity/multiauthcommon.cpp | |||
@@ -0,0 +1,179 @@ | |||
1 | #include "multiauthplugininterface.h" | ||
2 | #include "multiauthcommon.h" | ||
3 | |||
4 | /* Opie */ | ||
5 | #include <opie2/odebug.h> | ||
6 | #include <opie2/oapplication.h> | ||
7 | |||
8 | /* Qt */ | ||
9 | #include <qpe/qpeapplication.h> | ||
10 | #include <qpe/qlibrary.h> | ||
11 | #include <qpe/qcom.h> | ||
12 | #include <qtextview.h> | ||
13 | #include <qdir.h> | ||
14 | |||
15 | /* UNIX */ | ||
16 | #include <unistd.h> | ||
17 | #include <qpe/config.h> | ||
18 | |||
19 | |||
20 | SecOwnerDlg::SecOwnerDlg( QWidget *parent, const char * name, Contact c, | ||
21 | bool modal, bool fullscreen = FALSE ) | ||
22 | : QDialog( parent, name, modal, | ||
23 | fullscreen ? | ||
24 | WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop : 0 ) | ||
25 | { | ||
26 | if ( fullscreen ) { | ||
27 | QRect desk = qApp->desktop()->geometry(); | ||
28 | setGeometry( 0, 0, desk.width(), desk.height() ); | ||
29 | } | ||
30 | // set up contents. | ||
31 | QString text("<H3>" + tr("Please contact the owner (directions follow), or try again clicking of this screen (and waiting for the penalty time) if you are the legitimate owner") + "</H3>"); | ||
32 | text += c.toRichText(); | ||
33 | tv = new QTextView(this); | ||
34 | tv->setText(text); | ||
35 | |||
36 | tv->viewport()->installEventFilter(this); | ||
37 | } | ||
38 | |||
39 | void SecOwnerDlg::resizeEvent( QResizeEvent * ) | ||
40 | { | ||
41 | tv->resize( size() ); | ||
42 | } | ||
43 | |||
44 | bool SecOwnerDlg::eventFilter(QObject *o, QEvent *e) | ||
45 | { | ||
46 | if (e->type() == QEvent::KeyPress || e->type() == QEvent::MouseButtonPress ) { | ||
47 | accept(); | ||
48 | return TRUE; | ||
49 | } | ||
50 | return QWidget::eventFilter(o, e); | ||
51 | } | ||
52 | |||
53 | void SecOwnerDlg::mousePressEvent( QMouseEvent * ) { accept(); } | ||
54 | |||
55 | |||
56 | /// run plugins until we reach nbSuccessMin successes | ||
57 | int runPlugins() { | ||
58 | |||
59 | SecOwnerDlg *oi = 0; | ||
60 | // see if there is contact information. | ||
61 | QString vfilename = Global::applicationFileName("addressbook", | ||
62 | "businesscard.vcf"); | ||
63 | if (QFile::exists(vfilename)) { | ||
64 | Contact c; | ||
65 | c = Contact::readVCard( vfilename )[0]; | ||
66 | |||
67 | oi = new SecOwnerDlg(0, 0, c, TRUE, TRUE); | ||
68 | } | ||
69 | |||
70 | Config config("Security"); | ||
71 | config.setGroup("Plugins"); | ||
72 | QStringList plugins = config.readListEntry("IncludePlugins", ','); | ||
73 | config.setGroup("Misc"); | ||
74 | int nbSuccessMin = config.readNumEntry("nbSuccessMin", 1); | ||
75 | int nbSuccess = 0; | ||
76 | |||
77 | /* tries to launch successively each plugin in $OPIEDIR/plugins/security | ||
78 | * directory which file name is in Security.conf / [Misc] / IncludePlugins | ||
79 | */ | ||
80 | QString path = QPEApplication::qpeDir() + "/plugins/security"; | ||
81 | QStringList::Iterator libIt; | ||
82 | |||
83 | for ( libIt = plugins.begin(); libIt != plugins.end(); ++libIt ) { | ||
84 | QInterfacePtr<MultiauthPluginInterface> iface; | ||
85 | QLibrary *lib = new QLibrary( path + "/" + *libIt ); | ||
86 | |||
87 | if ( lib->queryInterface( | ||
88 | IID_MultiauthPluginInterface, | ||
89 | (QUnknownInterface**)&iface ) == QS_OK ) | ||
90 | { | ||
91 | // the plugin is a true Multiauth plugin | ||
92 | odebug << "Accepted plugin: " << QString( path + "/" + *libIt ) << oendl; | ||
93 | odebug << "Plugin name: " << iface->plugin()->pluginName() << oendl; | ||
94 | |||
95 | int resultCode; | ||
96 | int tries = 0; | ||
97 | |||
98 | // perform authentication | ||
99 | resultCode = iface->plugin()->authenticate(); | ||
100 | |||
101 | // display the result in command line | ||
102 | QString resultMessage; | ||
103 | switch (resultCode) | ||
104 | { | ||
105 | case MultiauthPluginObject::Success: | ||
106 | resultMessage = "Success!"; | ||
107 | nbSuccess++; | ||
108 | break; | ||
109 | case MultiauthPluginObject::Failure: | ||
110 | resultMessage = "Failure..."; | ||
111 | break; | ||
112 | case MultiauthPluginObject::Skip: | ||
113 | resultMessage = "Skip"; | ||
114 | break; | ||
115 | } | ||
116 | odebug << "Plugin result: " << resultMessage << oendl; | ||
117 | |||
118 | // if failure, wait, reperform, wait, reperform... until right | ||
119 | while (resultCode == MultiauthPluginObject::Failure) | ||
120 | { | ||
121 | tries++; | ||
122 | owarn << "This plugin has failed " << tries << " times already" << oendl; | ||
123 | |||
124 | // displays owner information, if any | ||
125 | if (oi) | ||
126 | { | ||
127 | oi->exec(); | ||
128 | odebug << "Contact information displayed" << oendl; | ||
129 | } | ||
130 | |||
131 | /// \todo parametrize the time penalty according to \em mode (exponential, | ||
132 | /// linear or fixed) and \em basetime (time penalty for the first failure) | ||
133 | sleep(2 * tries); | ||
134 | |||
135 | if (oi) | ||
136 | { | ||
137 | oi->hide(); | ||
138 | /** \todo fix the focus here: should go back to the current plugin widget | ||
139 | * but it doesn't, so we have to tap once on the widget before e.g. buttons | ||
140 | * are active again | ||
141 | */ | ||
142 | odebug << "Contact information hidden" << oendl; | ||
143 | } | ||
144 | |||
145 | // perform authentication | ||
146 | resultCode = iface->plugin()->authenticate(); | ||
147 | |||
148 | // display the result in command line | ||
149 | switch (resultCode) | ||
150 | { | ||
151 | case MultiauthPluginObject::Success: | ||
152 | resultMessage = "Success!"; | ||
153 | nbSuccess++; | ||
154 | break; | ||
155 | case MultiauthPluginObject::Failure: | ||
156 | resultMessage = "Failure..."; | ||
157 | break; | ||
158 | case MultiauthPluginObject::Skip: | ||
159 | resultMessage = "Skip"; | ||
160 | break; | ||
161 | } | ||
162 | odebug << "Plugin result: " << resultMessage << oendl; | ||
163 | } | ||
164 | delete lib; | ||
165 | |||
166 | if (resultCode == MultiauthPluginObject::Success && nbSuccess == nbSuccessMin) | ||
167 | { | ||
168 | if(oi) delete oi; | ||
169 | // we have reached the required number of successes, we can exit the plugin loop | ||
170 | return 0; | ||
171 | } | ||
172 | } else { | ||
173 | owarn << "Could not recognize plugin " << QString( path + "/" + *libIt ) << oendl; | ||
174 | delete lib; | ||
175 | } // end if plugin recognized | ||
176 | } //end for | ||
177 | if(oi) delete oi; | ||
178 | return 1; | ||
179 | } | ||
diff --git a/libopie2/opiesecurity/multiauthcommon.h b/libopie2/opiesecurity/multiauthcommon.h new file mode 100644 index 0000000..6d6d5d1 --- a/dev/null +++ b/libopie2/opiesecurity/multiauthcommon.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /** | ||
2 | * \file multiauthcommon.h | ||
3 | * \brief Objects and functions for Opie multiauth framework | ||
4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
5 | */ | ||
6 | /* | ||
7 | =. This file is part of the Opie Project | ||
8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This library is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This library is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #ifndef MULTIAUTHCOMMON_H | ||
35 | #define MULTIAUTHCOMMON_H | ||
36 | |||
37 | |||
38 | /* OwnerDialog stuff */ | ||
39 | #include <qpe/global.h> | ||
40 | #include <qpe/contact.h> | ||
41 | #include <qtextview.h> | ||
42 | #include <qdialog.h> | ||
43 | |||
44 | class SecOwnerDlg : public QDialog | ||
45 | { | ||
46 | Q_OBJECT | ||
47 | public: | ||
48 | |||
49 | SecOwnerDlg( QWidget *parent, const char * name, Contact c, | ||
50 | bool modal, bool fullscreen); | ||
51 | |||
52 | void resizeEvent( QResizeEvent * ); | ||
53 | bool eventFilter(QObject *o, QEvent *e); | ||
54 | void mousePressEvent( QMouseEvent * ); | ||
55 | |||
56 | private: | ||
57 | QTextView *tv; | ||
58 | }; | ||
59 | |||
60 | int runPlugins(); | ||
61 | |||
62 | #endif // MULTIAUTHCOMMON_H | ||
diff --git a/libopie2/opiesecurity/multiauthconfigwidget.h b/libopie2/opiesecurity/multiauthconfigwidget.h new file mode 100644 index 0000000..cd6f047 --- a/dev/null +++ b/libopie2/opiesecurity/multiauthconfigwidget.h | |||
@@ -0,0 +1,68 @@ | |||
1 | /** | ||
2 | * \file multiauthconfigwidget.h | ||
3 | * \brief Defines the Opie multiauth configuration widget interface. | ||
4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
5 | */ | ||
6 | /* | ||
7 | =. This file is part of the Opie Project | ||
8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This library is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This library is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #ifndef MULTIAUTHCONFIGWIDGET_H | ||
35 | #define MULTIAUTHCONFIGWIDGET_H | ||
36 | |||
37 | #include <qwidget.h> | ||
38 | #include <qobject.h> | ||
39 | |||
40 | /// Base class of all Opie multiauth config widgets | ||
41 | /** | ||
42 | * A base class for all Opie Multiauth Config Widgets. | ||
43 | * This will let a Opie multiauth plugin to add the possibility of configuration. | ||
44 | * Plugins need to inherit from this class and need to implement | ||
45 | * the pure virtual method to control configuration. | ||
46 | * The Plugin should read its configuration during creation of the Widget | ||
47 | * | ||
48 | * \author Clement Seveillac (helped by Maximilian Reiß's Today framework) | ||
49 | */ | ||
50 | class MultiauthConfigWidget : public QWidget { | ||
51 | |||
52 | Q_OBJECT | ||
53 | |||
54 | public: | ||
55 | |||
56 | /// standard widget constructor | ||
57 | MultiauthConfigWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) {} | ||
58 | virtual ~MultiauthConfigWidget() {} | ||
59 | |||
60 | /// Method to reimplement, supposed to save the plugin configuration | ||
61 | /** | ||
62 | * Plugins need to reimplement this in the config widget | ||
63 | * Used when the config dialog is closed to write config stuff | ||
64 | */ | ||
65 | virtual void writeConfig() = 0; | ||
66 | }; | ||
67 | |||
68 | #endif // MULTIAUTHCONFIGWIDGET_H | ||
diff --git a/libopie2/opiesecurity/multiauthmainwindow.cpp b/libopie2/opiesecurity/multiauthmainwindow.cpp new file mode 100644 index 0000000..2be3473 --- a/dev/null +++ b/libopie2/opiesecurity/multiauthmainwindow.cpp | |||
@@ -0,0 +1,129 @@ | |||
1 | #include "multiauthmainwindow.h" | ||
2 | |||
3 | #include "multiauthcommon.h" | ||
4 | #include <qpe/config.h> | ||
5 | |||
6 | /// Initializes widgets according to allowBypass and explanScreens config | ||
7 | MultiauthMainWindow::MultiauthMainWindow() | ||
8 | : QDialog(0, "main Opie multiauth modal dialog", TRUE, | ||
9 | Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop) | ||
10 | |||
11 | { | ||
12 | alreadyDone = false; | ||
13 | // initializes widget pointers which not always point to an object | ||
14 | quit = 0; | ||
15 | message2 = 0; | ||
16 | |||
17 | Config *pcfg = new Config("Security"); | ||
18 | pcfg->setGroup("Misc"); | ||
19 | explanScreens = pcfg->readBoolEntry("explanScreens", true); | ||
20 | allowBypass = pcfg->readBoolEntry("allowBypass", true); | ||
21 | delete pcfg; | ||
22 | |||
23 | layout = new QVBoxLayout(this); | ||
24 | layout->setSpacing(11); | ||
25 | layout->setMargin(11); | ||
26 | layout->setAlignment( Qt::AlignTop ); | ||
27 | |||
28 | // if explanScreens is false, we don't show any text in the QDialog, | ||
29 | // and we proceed directly | ||
30 | if ( explanScreens == true ) | ||
31 | { | ||
32 | title = new QLabel("<center><h1>" + tr("Welcome to Opie Multi-authentication Framework") + "</h1></center>", this); | ||
33 | message = new QLabel("<center><h3>" + tr("Launching authentication plugins...") + "</h3></center>", this); | ||
34 | } else { | ||
35 | title = new QLabel("", this); | ||
36 | message = new QLabel("", this); | ||
37 | } | ||
38 | |||
39 | layout->addWidget(title); | ||
40 | layout->addWidget(message); | ||
41 | proceedButton = new QPushButton(tr("Proceed..."), this); | ||
42 | layout->addWidget(proceedButton, 0, Qt::AlignHCenter); | ||
43 | |||
44 | QObject::connect(proceedButton, SIGNAL(clicked()), this, SLOT(proceed())); | ||
45 | |||
46 | if ( explanScreens == true ) | ||
47 | { | ||
48 | quit = new QPushButton("Exit", this); | ||
49 | layout->addWidget(quit, 0, Qt::AlignHCenter); | ||
50 | if ( allowBypass == true ) | ||
51 | { | ||
52 | // very important: we can close the widget through the quit button, and bypass authentication, only if allowBypass is set! | ||
53 | message2 = new QLabel("<center><i>" + tr("Note: the 'exit' button should be removed for real protection, through Security config dialog") + ".</i></center>", this); | ||
54 | layout->addWidget(message2); | ||
55 | QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close())); | ||
56 | } | ||
57 | else | ||
58 | { | ||
59 | quit->hide(); | ||
60 | } | ||
61 | |||
62 | } | ||
63 | else | ||
64 | { | ||
65 | // we will need this button only if runPlugins() fails in proceed() | ||
66 | proceedButton->hide(); | ||
67 | // let's proceed now | ||
68 | proceed(); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | /// nothing to do | ||
73 | MultiauthMainWindow::~MultiauthMainWindow() { | ||
74 | } | ||
75 | |||
76 | /// launch the authentication | ||
77 | void MultiauthMainWindow::proceed() { | ||
78 | int result = runPlugins(); | ||
79 | |||
80 | |||
81 | if ( (result == 0) && !explanScreens ) | ||
82 | { | ||
83 | // the authentication has succeeded, we can exit directly | ||
84 | // this will work if we haven't been called by the constructor of MultiauthMainWindow | ||
85 | close(); | ||
86 | // and if we've been called by this constructor, we use this variable to tell our | ||
87 | // caller we're already done | ||
88 | alreadyDone = true; | ||
89 | return; | ||
90 | } | ||
91 | else | ||
92 | { | ||
93 | |||
94 | proceedButton->setText("Another try?"); | ||
95 | QString resultMessage; | ||
96 | |||
97 | if (result == 0) | ||
98 | { | ||
99 | // authentication has succeeded, adapt interface then | ||
100 | message->setText( "<center><h3>" + tr("Congratulations! Your authentication has been successful.") + "</h3></center>" ); | ||
101 | quit->setText("Enter Opie"); | ||
102 | if ( quit->isHidden() ) | ||
103 | { | ||
104 | // that means we don't allow to bypass, but now we can show and connect this button | ||
105 | QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close())); | ||
106 | quit->show(); | ||
107 | } else { | ||
108 | if ( message2 != 0 ) message2->hide(); | ||
109 | } | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | // authentication has failed, explain that according to allowBypass | ||
114 | message->setText( "<center><h3>" + tr("You have not succeeded enough authentication steps!") + "</h3></center>" ); | ||
115 | proceedButton->show(); | ||
116 | if ( allowBypass == true ) | ||
117 | message2->setText( "<center><p>" + tr("Note: if 'allow to bypass' was uncheck in Security config, you would have to go back through all the steps now.") + "</p></center>" ); | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | |||
122 | /** When we don't show explanatory screens and we succeed authentication, | ||
123 | * as early as during the proceed() call of the constructor, the caller must know | ||
124 | * (through this function) authentication has already been succeeded.. | ||
125 | * \todo try to avoid this hack? | ||
126 | */ | ||
127 | bool MultiauthMainWindow::isAlreadyDone() { | ||
128 | return alreadyDone; | ||
129 | } | ||
diff --git a/libopie2/opiesecurity/multiauthmainwindow.h b/libopie2/opiesecurity/multiauthmainwindow.h new file mode 100644 index 0000000..d5f53c6 --- a/dev/null +++ b/libopie2/opiesecurity/multiauthmainwindow.h | |||
@@ -0,0 +1,74 @@ | |||
1 | /** | ||
2 | * \file multiauthmainwindow.h | ||
3 | * \brief Defines the Opie multiauth main window. | ||
4 | * | ||
5 | * This implementation was derived from the today plugins implementation. | ||
6 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
7 | */ | ||
8 | /* | ||
9 | =. This file is part of the Opie Project | ||
10 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
11 | .>+-= | ||
12 | _;:, .> :=|. This library is free software; you can | ||
13 | .> <`_, > . <= redistribute it and/or modify it under | ||
14 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
15 | .="- .-=="i, .._ License as published by the Free Software | ||
16 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
17 | ._= =} : or (at your option) any later version. | ||
18 | .%`+i> _;_. | ||
19 | .i_,=:_. -<s. This library is distributed in the hope that | ||
20 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
21 | : .. .:, . . . without even the implied warranty of | ||
22 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
23 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
24 | ..}^=.= = ; Library General Public License for more | ||
25 | ++= -. .` .: details. | ||
26 | : = ...= . :.=- | ||
27 | -. .:....=;==+<; You should have received a copy of the GNU | ||
28 | -_. . . )=. = Library General Public License along with | ||
29 | -- :-=` this library; see the file COPYING.LIB. | ||
30 | If not, write to the Free Software Foundation, | ||
31 | Inc., 59 Temple Place - Suite 330, | ||
32 | Boston, MA 02111-1307, USA. | ||
33 | |||
34 | */ | ||
35 | |||
36 | #ifndef MULTIAUTHMAINWINDOW_H | ||
37 | #define MULTIAUTHMAINWINDOW_H | ||
38 | |||
39 | #include <qdialog.h> | ||
40 | #include <qlayout.h> | ||
41 | #include <qpushbutton.h> | ||
42 | #include <qlabel.h> | ||
43 | |||
44 | /// Multiauth main window | ||
45 | /** | ||
46 | * This QDialog window displays some information and an exit button, | ||
47 | * and completely hides the desktop, preventing user interactions | ||
48 | * with it. | ||
49 | */ | ||
50 | class MultiauthMainWindow : public QDialog { | ||
51 | Q_OBJECT | ||
52 | |||
53 | public: | ||
54 | MultiauthMainWindow(); | ||
55 | ~MultiauthMainWindow(); | ||
56 | bool isAlreadyDone(); | ||
57 | |||
58 | private: | ||
59 | QVBoxLayout * layout; | ||
60 | QLabel * title, * message, * message2; | ||
61 | QPushButton * proceedButton, * quit; | ||
62 | /// whether to show explanatory screens before and after the authentication plugins | ||
63 | bool explanScreens; | ||
64 | /// allow to bypass authnentication via 'exit' buttons on both explan. screens | ||
65 | bool allowBypass; | ||
66 | /// true when the authentication has been done successfully | ||
67 | bool alreadyDone; | ||
68 | |||
69 | private slots: | ||
70 | void proceed(); | ||
71 | }; | ||
72 | |||
73 | #endif // MULTIAUTHMAINWINDOW_H | ||
74 | |||
diff --git a/libopie2/opiesecurity/multiauthplugininterface.h b/libopie2/opiesecurity/multiauthplugininterface.h new file mode 100644 index 0000000..0035107 --- a/dev/null +++ b/libopie2/opiesecurity/multiauthplugininterface.h | |||
@@ -0,0 +1,109 @@ | |||
1 | /** | ||
2 | * \file multiauthplugininterface.h | ||
3 | * \brief Main public interface to Opie multiauth authentication plugins. | ||
4 | * | ||
5 | * This implementation was derived from the todolist plugin implementation. | ||
6 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
7 | */ | ||
8 | /* | ||
9 | =. This file is part of the Opie Project | ||
10 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
11 | .>+-= | ||
12 | _;:, .> :=|. This library is free software; you can | ||
13 | .> <`_, > . <= redistribute it and/or modify it under | ||
14 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
15 | .="- .-=="i, .._ License as published by the Free Software | ||
16 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
17 | ._= =} : or (at your option) any later version. | ||
18 | .%`+i> _;_. | ||
19 | .i_,=:_. -<s. This library is distributed in the hope that | ||
20 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
21 | : .. .:, . . . without even the implied warranty of | ||
22 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
23 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
24 | ..}^=.= = ; Library General Public License for more | ||
25 | ++= -. .` .: details. | ||
26 | : = ...= . :.=- | ||
27 | -. .:....=;==+<; You should have received a copy of the GNU | ||
28 | -_. . . )=. = Library General Public License along with | ||
29 | -- :-=` this library; see the file COPYING.LIB. | ||
30 | If not, write to the Free Software Foundation, | ||
31 | Inc., 59 Temple Place - Suite 330, | ||
32 | Boston, MA 02111-1307, USA. | ||
33 | |||
34 | */ | ||
35 | |||
36 | #ifndef MULTIAUTH_PLUGIN_INTERFACE | ||
37 | #define MULTIAUTH_PLUGIN_INTERFACE | ||
38 | |||
39 | #include <qpe/qcom.h> | ||
40 | |||
41 | #include "multiauthconfigwidget.h" | ||
42 | |||
43 | class QString; | ||
44 | class QWidget; | ||
45 | |||
46 | #ifndef IID_MultiauthPluginInterface | ||
47 | /// Universally Unique Id of the interface (required by QCOM): | ||
48 | /// {AD5BE8B1-8421-447b-9AED-250BE1CDA49c} | ||
49 | #define IID_MultiauthPluginInterface QUuid(0xad5be8b1, 0x8421, 0x447b, 0x9a, 0xed, 0x25, 0x0b, 0xe1, 0xcd, 0xa4, 0x9c) | ||
50 | #endif | ||
51 | |||
52 | /// Base class for Opie multiauth plugins | ||
53 | /** | ||
54 | * A MultiauthPluginObject is the base for all Multiauth Plugins. | ||
55 | * A plugin author needs to inherit this class and implement | ||
56 | * the pure virtual methods. | ||
57 | * | ||
58 | * \author Clement Seveillac (helped by Maximilian Reiß's Today framework) | ||
59 | */ | ||
60 | class MultiauthPluginObject { | ||
61 | |||
62 | public: | ||
63 | |||
64 | virtual ~MultiauthPluginObject() {}; | ||
65 | |||
66 | /// The name of the plugin | ||
67 | /* | ||
68 | * \return The plugin should return its name here | ||
69 | */ | ||
70 | virtual QString pluginName() const = 0; | ||
71 | |||
72 | /// Ask the plugin to launch one authentication attempt | ||
73 | virtual int authenticate() = 0; | ||
74 | |||
75 | /// Possible return codes for authenticate() function | ||
76 | enum authResult { Success = 0, | ||
77 | Failure = 1, | ||
78 | Skip = 2 }; | ||
79 | |||
80 | /// Pointer to the (optional) plugin configuration widget | ||
81 | virtual MultiauthConfigWidget * configWidget(QWidget * parent) = 0; | ||
82 | |||
83 | /// (optional) plugin configuration tab icon | ||
84 | /** | ||
85 | * \return path to the image file (without the extension) | ||
86 | * from $OPIEDIR/pics | ||
87 | */ | ||
88 | virtual QString pixmapNameConfig() const = 0; | ||
89 | |||
90 | /// Plugin icon, to be displayed in the plugin list configuration widget | ||
91 | /** | ||
92 | * \return path to the image file (without the extension) | ||
93 | * from $OPIEDIR/pics | ||
94 | */ | ||
95 | virtual QString pixmapNameWidget() const = 0; | ||
96 | |||
97 | }; | ||
98 | |||
99 | /// Interface for multiauth plugin classes. | ||
100 | /* | ||
101 | * This is part of the QCOM works. See example plugins how to do it right. | ||
102 | * \see http://doc.trolltech.com/qtopia/html/pluginintro.html | ||
103 | */ | ||
104 | struct MultiauthPluginInterface : public QUnknownInterface { | ||
105 | /// return the MultiauthPluginObject implementation | ||
106 | virtual MultiauthPluginObject *plugin() = 0; | ||
107 | }; | ||
108 | |||
109 | #endif | ||
diff --git a/libopie2/opiesecurity/opiesecurity.pro b/libopie2/opiesecurity/opiesecurity.pro new file mode 100644 index 0000000..8cb4821 --- a/dev/null +++ b/libopie2/opiesecurity/opiesecurity.pro | |||
@@ -0,0 +1,15 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt warn_on | ||
3 | DESTDIR = $(OPIEDIR)/lib | ||
4 | HEADERS = multiauthcommon.h \ | ||
5 | multiauthmainwindow.h \ | ||
6 | multiauthconfigwidget.h \ | ||
7 | multiauthplugininterface.h | ||
8 | SOURCES = multiauthcommon.cpp \ | ||
9 | multiauthmainwindow.cpp | ||
10 | TARGET = opiesecurity2 | ||
11 | VERSION = 0.0.2 | ||
12 | INCLUDEPATH += $(OPIEDIR)/include | ||
13 | DEPENDPATH += $(OPIEDIR)/include | ||
14 | |||
15 | include ( $(OPIEDIR)/include.pro ) | ||