-rw-r--r-- | noncore/securityplugins/pin/pin.cpp | 22 | ||||
-rw-r--r-- | noncore/securityplugins/pin/pin.h | 3 |
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 | |||
@@ -14,25 +14,24 @@ | |||
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> |
@@ -309,37 +308,48 @@ int PinPlugin::authenticate() | |||
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 | ||
321 | PinPlugin::PinPlugin() : MultiauthPluginObject(), m_pinW(0) { | ||
322 | } | ||
323 | |||
324 | /// deletes m_pinW if we need to | ||
325 | PinPlugin::~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) |
322 | QString PinPlugin::pluginName() const { | 331 | QString PinPlugin::pluginName() const { |
323 | return "PIN Plugin"; | 332 | return "PIN Plugin"; |
324 | } | 333 | } |
325 | 334 | ||
326 | QString PinPlugin::pixmapNameWidget() const { | 335 | QString PinPlugin::pixmapNameWidget() const { |
327 | return "security/pinplugin"; | 336 | return "security/pinplugin"; |
328 | } | 337 | } |
329 | 338 | ||
330 | QString PinPlugin::pixmapNameConfig() const { | 339 | QString PinPlugin::pixmapNameConfig() const { |
331 | return "security/pinplugin"; | 340 | return "security/pinplugin"; |
332 | } | 341 | } |
333 | 342 | ||
334 | /// returns a PinConfigWidget | 343 | /// returns a PinConfigWidget |
335 | MultiauthConfigWidget * PinPlugin::configWidget(QWidget * parent) { | 344 | MultiauthConfigWidget * 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 | |||
@@ -39,30 +39,33 @@ | |||
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 | */ |
46 | class PinPlugin : public QObject, public Opie::Security::MultiauthPluginObject { | 46 | class PinPlugin : public QObject, public Opie::Security::MultiauthPluginObject { |
47 | 47 | ||
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | 49 | ||
50 | public: | 50 | public: |
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 | ||
57 | private slots: | 59 | private 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 | ||
63 | private: | 65 | private: |
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 |