@ -8,6 +8,7 @@
# ifndef __PINDIALOG_HXX__
# ifndef __PINDIALOG_HXX__
# define __PINDIALOG_HXX__
# define __PINDIALOG_HXX__
# include <cryptoki.hxx>
# include <qbrowserlib/log.hxx>
# include <qbrowserlib/log.hxx>
# include <ui_pinentry.h>
# include <ui_pinentry.h>
# include <QtGui/QDialog>
# include <QtGui/QDialog>
@ -19,7 +20,9 @@
class PinEntry : public QDialog , public Ui : : PinEntry {
class PinEntry : public QDialog , public Ui : : PinEntry {
Q_OBJECT ;
Q_OBJECT ;
public :
public :
PinEntry ( const QSslCertificate & cert , QWidget * parent = 0 ) : QDialog ( parent ) {
PinEntry ( const QSslCertificate & cert , QWidget * parent = 0 ) :
QDialog ( parent ) ,
_maxPinLen ( - 1 ) , _minPinLen ( 0 ) {
setModal ( true ) ;
setModal ( true ) ;
setupUi ( this ) ;
setupUi ( this ) ;
_cert - > certificate ( cert ) ;
_cert - > certificate ( cert ) ;
@ -37,6 +40,12 @@ class PinEntry: public QDialog, public Ui::PinEntry {
_certSerial - > setText ( cert . serialNumber ( ) ) ;
_certSerial - > setText ( cert . serialNumber ( ) ) ;
}
}
}
}
PinEntry & tokeninfo ( const cryptoki : : TokenInfo & ti ) {
_maxPinLen = ti . maxPinLen ;
_minPinLen = ti . minPinLen ;
on__pin_textChanged ( _pin - > text ( ) ) ;
return * this ;
}
PinEntry & retries ( int num ) {
PinEntry & retries ( int num ) {
_pinstatus - > setCurrentIndex ( num = = - 1 ? 1 : ( num = = - 2 ? 2 : 0 ) ) ;
_pinstatus - > setCurrentIndex ( num = = - 1 ? 1 : ( num = = - 2 ? 2 : 0 ) ) ;
_retries - > setText ( tr ( " there are %1 PIN attempts left " ) . arg ( num ) ) ;
_retries - > setText ( tr ( " there are %1 PIN attempts left " ) . arg ( num ) ) ;
@ -76,6 +85,11 @@ class PinEntry: public QDialog, public Ui::PinEntry {
_cert - > setVisible ( s ) ;
_cert - > setVisible ( s ) ;
adjustSize ( ) ;
adjustSize ( ) ;
}
}
void on__pin_textChanged ( const QString & text ) {
_buttonBox - > button ( QDialogButtonBox : : Ok )
- > setEnabled ( ( unsigned long ) text . size ( ) > = _minPinLen & &
( unsigned long ) text . size ( ) < = _maxPinLen ) ;
}
protected :
protected :
QString utfConv ( const QString & txt ) {
QString utfConv ( const QString & txt ) {
QByteArray value ( txt . toAscii ( ) ) ;
QByteArray value ( txt . toAscii ( ) ) ;
@ -85,6 +99,8 @@ class PinEntry: public QDialog, public Ui::PinEntry {
}
}
private :
private :
QEventLoop _run ;
QEventLoop _run ;
unsigned long _maxPinLen ;
unsigned long _minPinLen ;
} ;
} ;
# endif
# endif