summaryrefslogtreecommitdiff
authorclem <clem>2004-08-03 22:59:45 (UTC)
committer clem <clem>2004-08-03 22:59:45 (UTC)
commit72d6b839da4aecba0ad6479c3e1d68192bbe6a51 (patch) (unidiff)
tree1a60581005dfab811debe87e2eae6be905743dc2
parent02434fe2d87d1c69c60693d9537b419d9dfd44e7 (diff)
downloadopie-72d6b839da4aecba0ad6479c3e1d68192bbe6a51.zip
opie-72d6b839da4aecba0ad6479c3e1d68192bbe6a51.tar.gz
opie-72d6b839da4aecba0ad6479c3e1d68192bbe6a51.tar.bz2
manage better the MultiauthConfigWidget PinConfigWidget object, with a pointer managed by PinPlugin c'tor and d'tor (like in NoticePlugin)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/securityplugins/pin/pin.cpp22
-rw-r--r--noncore/securityplugins/pin/pin.h3
2 files changed, 19 insertions, 6 deletions
diff --git a/noncore/securityplugins/pin/pin.cpp b/noncore/securityplugins/pin/pin.cpp
index c21ffcd..2accb9c 100644
--- a/noncore/securityplugins/pin/pin.cpp
+++ b/noncore/securityplugins/pin/pin.cpp
@@ -2,49 +2,48 @@
2 * \note Taken from opie-security and libqpe password.cpp, and modified for Opie multiauth by Clement Seveillac 2 * \note Taken from opie-security and libqpe password.cpp, and modified for Opie multiauth by Clement Seveillac
3 */ 3 */
4/********************************************************************** 4/**********************************************************************
5 ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 5 ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
6 ** 6 **
7 ** This file is part of the Qtopia Environment. 7 ** This file is part of the Qtopia Environment.
8 ** 8 **
9 ** This file may be distributed and/or modified under the terms of the 9 ** This file may be distributed and/or modified under the terms of the
10 ** GNU General Public License version 2 as published by the Free Software 10 ** GNU General Public License version 2 as published by the Free Software
11 ** Foundation and appearing in the file LICENSE.GPL included in the 11 ** Foundation and appearing in the file LICENSE.GPL included in the
12 ** packaging of this file. 12 ** packaging of this file.
13 ** 13 **
14 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 14 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
15 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 15 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 ** 16 **
17 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 17 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
18 ** 18 **
19 ** Contact info@trolltech.com if any conditions of this licensing are 19 ** Contact info@trolltech.com if any conditions of this licensing are
20 ** not clear to you. 20 ** not clear to you.
21 ** 21 **
22 **********************************************************************/ 22 **********************************************************************/
23 23
24#include "pin.h" 24#include "pin.h"
25#include "pinDialogBase.h" 25#include "pinDialogBase.h"
26#include "pinConfigWidget.h"
27/* OPIE */ 26/* OPIE */
28#include <opie2/odebug.h> 27#include <opie2/odebug.h>
29#include <opie2/oapplication.h> 28#include <opie2/oapplication.h>
30/* QT */ 29/* QT */
31#include <qpe/config.h> 30#include <qpe/config.h>
32#include <qlabel.h> 31#include <qlabel.h>
33#include <qlineedit.h> 32#include <qlineedit.h>
34#include <qtextview.h> 33#include <qtextview.h>
35#include <qstring.h> 34#include <qstring.h>
36#include <qdialog.h> 35#include <qdialog.h>
37/* UNIX */ 36/* UNIX */
38#include <unistd.h> 37#include <unistd.h>
39#include <stdlib.h> 38#include <stdlib.h>
40#include <time.h> 39#include <time.h>
41 40
42extern "C" char *crypt(const char *key, const char *salt); 41extern "C" char *crypt(const char *key, const char *salt);
43 42
44using Opie::Security::MultiauthConfigWidget; 43using Opie::Security::MultiauthConfigWidget;
45using Opie::Security::MultiauthPluginObject; 44using Opie::Security::MultiauthPluginObject;
46 45
47/// set to TRUE when we press the 'Skip' button 46/// set to TRUE when we press the 'Skip' button
48static bool isSkip = FALSE; 47static bool isSkip = FALSE;
49 48
50/// PIN input graphical widget. 49/// PIN input graphical widget.
@@ -297,49 +296,60 @@ int PinPlugin::authenticate()
297 isSkip = FALSE; 296 isSkip = FALSE;
298 // fetch value in config 297 // fetch value in config
299 Config cfg("Security"); 298 Config cfg("Security");
300 cfg.setGroup("PinPlugin"); 299 cfg.setGroup("PinPlugin");
301 QString hashedPin = cfg.readEntry("hashedPIN"); 300 QString hashedPin = cfg.readEntry("hashedPIN");
302 if (!hashedPin.isEmpty()) 301 if (!hashedPin.isEmpty())
303 { 302 {
304 // prompt for the PIN in a fullscreen modal dialog 303 // prompt for the PIN in a fullscreen modal dialog
305 PinDlg pd(0,0,TRUE,TRUE); 304 PinDlg pd(0,0,TRUE,TRUE);
306 pd.reset(); 305 pd.reset();
307 pd.exec(); 306 pd.exec();
308 307
309 // analyse the result 308 // analyse the result
310 if (isSkip == TRUE) 309 if (isSkip == TRUE)
311 return MultiauthPluginObject::Skip; 310 return MultiauthPluginObject::Skip;
312 else if (verify(pd.pinD->text, hashedPin)) 311 else if (verify(pd.pinD->text, hashedPin))
313 return MultiauthPluginObject::Success; 312 return MultiauthPluginObject::Success;
314 else 313 else
315 return MultiauthPluginObject::Failure; 314 return MultiauthPluginObject::Failure;
316 } 315 }
317 owarn << "No PIN has been defined! We consider it as a successful authentication though." << oendl; 316 owarn << "No PIN has been defined! We consider it as a successful authentication though." << oendl;
318 return MultiauthPluginObject::Success; 317 return MultiauthPluginObject::Success;
319} 318}
320 319
320/// Standard c'tor
321PinPlugin::PinPlugin() : MultiauthPluginObject(), m_pinW(0) {
322}
323
324/// deletes m_pinW if we need to
325PinPlugin::~PinPlugin() {
326 if (m_pinW != 0)
327 delete m_pinW;
328}
329
321/// Simply returns the plugin name (PIN plugin) 330/// Simply returns the plugin name (PIN plugin)
322QString PinPlugin::pluginName() const { 331QString PinPlugin::pluginName() const {
323 return "PIN Plugin"; 332 return "PIN Plugin";
324} 333}
325 334
326QString PinPlugin::pixmapNameWidget() const { 335QString PinPlugin::pixmapNameWidget() const {
327 return "security/pinplugin"; 336 return "security/pinplugin";
328} 337}
329 338
330QString PinPlugin::pixmapNameConfig() const { 339QString PinPlugin::pixmapNameConfig() const {
331 return "security/pinplugin"; 340 return "security/pinplugin";
332} 341}
333 342
334/// returns a PinConfigWidget 343/// returns a PinConfigWidget
335MultiauthConfigWidget * PinPlugin::configWidget(QWidget * parent) { 344MultiauthConfigWidget * PinPlugin::configWidget(QWidget * parent) {
336 PinConfigWidget * pinw = new PinConfigWidget(parent, "PIN configuration widget"); 345 if (m_pinW == 0) {
337 346 m_pinW = new PinConfigWidget(parent, "PIN configuration widget");
338 connect(pinw->changePIN, SIGNAL( clicked() ), this, SLOT( changePIN() ));
339 connect(pinw->clearPIN, SIGNAL( clicked() ), this, SLOT( clearPIN() ));
340 347
341 return pinw; 348 connect(m_pinW->changePIN, SIGNAL( clicked() ), this, SLOT( changePIN() ));
349 connect(m_pinW->clearPIN, SIGNAL( clicked() ), this, SLOT( clearPIN() ));
350 }
351 return m_pinW;
342} 352}
343 353
344#include "pin.moc" 354#include "pin.moc"
345 355
diff --git a/noncore/securityplugins/pin/pin.h b/noncore/securityplugins/pin/pin.h
index 1832210..b5ae10a 100644
--- a/noncore/securityplugins/pin/pin.h
+++ b/noncore/securityplugins/pin/pin.h
@@ -27,42 +27,45 @@
27 -- :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PIN_H 34#ifndef PIN_H
35#define PIN_H 35#define PIN_H
36 36
37#include <qobject.h> 37#include <qobject.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <opie2/multiauthplugininterface.h> 39#include <opie2/multiauthplugininterface.h>
40#include "pinConfigWidget.h" 40#include "pinConfigWidget.h"
41 41
42/// Multi-authentication plugin, implementing a PIN verification. 42/// Multi-authentication plugin, implementing a PIN verification.
43/** 43/**
44 * The plugin itself, implementing the main authenticate() function. 44 * The plugin itself, implementing the main authenticate() function.
45 */ 45 */
46class PinPlugin : public QObject, public Opie::Security::MultiauthPluginObject { 46class PinPlugin : public QObject, public Opie::Security::MultiauthPluginObject {
47 47
48 Q_OBJECT 48 Q_OBJECT
49 49
50public: 50public:
51 PinPlugin();
52 virtual ~PinPlugin();
51 int authenticate(); 53 int authenticate();
52 Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent); 54 Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent);
53 QString pixmapNameConfig() const; 55 QString pixmapNameConfig() const;
54 QString pixmapNameWidget() const; 56 QString pixmapNameWidget() const;
55 QString pluginName() const; 57 QString pluginName() const;
56 58
57private slots: 59private slots:
58 QString getPIN( const QString& prompt ); 60 QString getPIN( const QString& prompt );
59 QString getCryptedPIN( const QString& prompt ); 61 QString getCryptedPIN( const QString& prompt );
60 void changePIN(); 62 void changePIN();
61 void clearPIN(); 63 void clearPIN();
62 64
63private: 65private:
66 PinConfigWidget * m_pinW;
64 QString encrypt(const QString& pin); 67 QString encrypt(const QString& pin);
65 bool verify(const QString& pin, const QString& hash); 68 bool verify(const QString& pin, const QString& hash);
66}; 69};
67 70
68#endif // PIN_H 71#endif // PIN_H