00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include <unistd.h>
00022
00023
#include <qwidget.h>
00024
#include <qlineedit.h>
00025
#include <qlabel.h>
00026
#include <qlayout.h>
00027
#include <qsize.h>
00028
#include <qevent.h>
00029
#include <qkeycode.h>
00030
#include <qcheckbox.h>
00031
#include <qregexp.h>
00032
#include <qhbox.h>
00033
#include <qwhatsthis.h>
00034
#include <qptrdict.h>
00035
00036
#include <kglobal.h>
00037
#include <kdebug.h>
00038
#include <kapplication.h>
00039
#include <klocale.h>
00040
#include <kiconloader.h>
00041
#include <kmessagebox.h>
00042
#include <kaboutdialog.h>
00043
#include <kconfig.h>
00044
#include <kstandarddirs.h>
00045
#include <kprogress.h>
00046
00047
#include <sys/time.h>
00048
#include <sys/resource.h>
00049
00050
#include "kpassdlg.h"
00051
00052
00053
00054
00055
00056
00057
00058
static QPtrDict<int>* d_ptr = 0;
00059
00060
static void cleanup_d_ptr() {
00061
delete d_ptr;
00062 }
00063
00064
static int * ourMaxLength(
const KPasswordEdit*
const e ) {
00065
if ( !d_ptr ) {
00066 d_ptr =
new QPtrDict<int>;
00067 qAddPostRoutine( cleanup_d_ptr );
00068 }
00069
int* ret = d_ptr->find( (
void*) e );
00070
if ( ! ret ) {
00071 ret =
new int;
00072 d_ptr->replace( (
void*) e, ret );
00073 }
00074
return ret;
00075 }
00076
00077
static void delete_d(
const KPasswordEdit*
const e ) {
00078
if ( d_ptr )
00079 d_ptr->remove( (
void*) e );
00080 }
00081
00082
const int KPasswordEdit::PassLen = 200;
00083
00084
class KPasswordDialog::KPasswordDialogPrivate
00085 {
00086
public:
00087 KPasswordDialogPrivate()
00088 : m_MatchLabel( 0 ), iconName( 0 ), allowEmptyPasswords( false ),
00089 minimumPasswordLength(0), maximumPasswordLength(
KPasswordEdit::PassLen - 1),
00090 passwordStrengthWarningLevel(1), m_strengthBar(0),
00091 reasonablePasswordLength(8)
00092 {}
00093
QLabel *m_MatchLabel;
00094
QString iconName;
00095
bool allowEmptyPasswords;
00096
int minimumPasswordLength;
00097
int maximumPasswordLength;
00098
int passwordStrengthWarningLevel;
00099
KProgress* m_strengthBar;
00100
int reasonablePasswordLength;
00101 };
00102
00103
00104 KPasswordEdit::KPasswordEdit(
QWidget *parent,
const char *name)
00105 :
QLineEdit(parent, name)
00106 {
00107 init();
00108
00109
KConfig*
const cfg =
KGlobal::config();
00110
KConfigGroupSaver saver(cfg,
"Passwords");
00111
00112
const QString val = cfg->
readEntry(
"EchoMode",
"OneStar");
00113
if (val ==
"ThreeStars")
00114 m_EchoMode = ThreeStars;
00115
else if (val ==
"NoEcho")
00116 m_EchoMode = NoEcho;
00117
else
00118 m_EchoMode = OneStar;
00119
00120 }
00121
00122 KPasswordEdit::KPasswordEdit(
QWidget *parent,
const char *name,
int echoMode)
00123 :
QLineEdit(parent, name), m_EchoMode(echoMode)
00124 {
00125 init();
00126 }
00127
00128 KPasswordEdit::KPasswordEdit(EchoModes echoMode,
QWidget *parent,
const char *name)
00129 :
QLineEdit(parent, name), m_EchoMode(echoMode)
00130 {
00131 init();
00132 }
00133
00134 KPasswordEdit::KPasswordEdit(EchoMode echoMode,
QWidget *parent,
const char *name)
00135 :
QLineEdit(parent, name)
00136 , m_EchoMode( echoMode ==
QLineEdit::NoEcho ? NoEcho : OneStar )
00137 {
00138 init();
00139 }
00140
00141
void KPasswordEdit::init()
00142 {
00143 setEchoMode(QLineEdit::Password);
00144 setAcceptDrops(
false);
00145
int* t = ourMaxLength(
this);
00146 *t = (PassLen - 1);
00147 m_Password =
new char[PassLen];
00148 m_Password[0] =
'\000';
00149 m_Length = 0;
00150 }
00151
00152 KPasswordEdit::~KPasswordEdit()
00153 {
00154 memset(m_Password, 0, PassLen *
sizeof(
char));
00155
delete[] m_Password;
00156 delete_d(
this);
00157 }
00158
00159 void KPasswordEdit::insert(
const QString &txt)
00160 {
00161
const QCString localTxt = txt.
local8Bit();
00162
const unsigned int lim = localTxt.
length();
00163
const int m_MaxLength =
maxPasswordLength();
00164
for(
unsigned int i=0; i < lim; ++i)
00165 {
00166
const unsigned char ke = localTxt[i];
00167
if (m_Length < m_MaxLength)
00168 {
00169 m_Password[m_Length] = ke;
00170 m_Password[++m_Length] =
'\000';
00171 }
00172 }
00173 showPass();
00174 }
00175
00176 void KPasswordEdit::erase()
00177 {
00178 m_Length = 0;
00179 memset(m_Password, 0, PassLen *
sizeof(
char));
00180 setText(
"");
00181 }
00182
00183
void KPasswordEdit::focusInEvent(
QFocusEvent *e)
00184 {
00185
const QString txt =
text();
00186 setUpdatesEnabled(
false);
00187 QLineEdit::focusInEvent(e);
00188 setUpdatesEnabled(
true);
00189 setText(txt);
00190 }
00191
00192
00193
void KPasswordEdit::keyPressEvent(
QKeyEvent *e)
00194 {
00195
switch (e->
key()) {
00196
case Key_Return:
00197
case Key_Enter:
00198
case Key_Escape:
00199 e->
ignore();
00200
break;
00201
case Key_Backspace:
00202
case Key_Delete:
00203
case 0x7f:
00204
if (e->
state() & (ControlButton | AltButton))
00205 e->
ignore();
00206
else if (m_Length) {
00207 m_Password[--m_Length] =
'\000';
00208 showPass();
00209 }
00210
break;
00211
default:
00212
const unsigned char ke = e->
text().local8Bit()[0];
00213
if (ke >= 32) {
00214
insert(e->
text());
00215 }
else
00216 e->
ignore();
00217
break;
00218 }
00219 }
00220
00221
bool KPasswordEdit::event(
QEvent *e) {
00222
switch(e->
type()) {
00223
00224
case QEvent::MouseButtonPress:
00225
case QEvent::MouseButtonRelease:
00226
case QEvent::MouseButtonDblClick:
00227
case QEvent::MouseMove:
00228
case QEvent::IMStart:
00229
case QEvent::IMCompose:
00230
return true;
00231
00232
case QEvent::IMEnd:
00233 {
00234
QIMEvent*
const ie = (
QIMEvent*) e;
00235
insert( ie->
text() );
00236
return true;
00237 }
00238
00239
case QEvent::AccelOverride:
00240 {
00241
QKeyEvent*
const k = (
QKeyEvent*) e;
00242
switch (k->
key()) {
00243
case Key_U:
00244
if (k->
state() & ControlButton) {
00245 m_Length = 0;
00246 m_Password[m_Length] =
'\000';
00247 showPass();
00248 }
00249 }
00250
return true;
00251 }
00252
00253
default:
00254
00255
break;
00256 }
00257
return QLineEdit::event(e);
00258 }
00259
00260
void KPasswordEdit::showPass()
00261 {
00262
QString tmp;
00263
00264
switch (m_EchoMode) {
00265
case OneStar:
00266 tmp.
fill(
'*', m_Length);
00267
setText(tmp);
00268
break;
00269
case ThreeStars:
00270 tmp.
fill(
'*', m_Length*3);
00271
setText(tmp);
00272
break;
00273
case NoEcho:
default:
00274 emit
textChanged(QString::null);
00275
break;
00276 }
00277 }
00278
00279 void KPasswordEdit::setMaxPasswordLength(
int newLength)
00280 {
00281
if (newLength >= PassLen) newLength = PassLen - 1;
00282
if (newLength < 0) newLength = 0;
00283
int* t = ourMaxLength(
this);
00284 *t = newLength;
00285
while (m_Length > newLength) {
00286 m_Password[m_Length] =
'\000';
00287 --m_Length;
00288 }
00289 showPass();
00290 }
00291
00292 int KPasswordEdit::maxPasswordLength()
const
00293
{
00294
return *(ourMaxLength(
this));
00295 }
00296
00297
00298
00299
00300 KPasswordDialog::KPasswordDialog(Types type,
bool enableKeep,
int extraBttn,
00301
QWidget *parent,
const char *name)
00302 :
KDialogBase(parent, name, true, "", Ok|Cancel|extraBttn,
00303 Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type), d(new KPasswordDialogPrivate)
00304 {
00305 d->iconName =
"password";
00306 init();
00307 }
00308
00309 KPasswordDialog::KPasswordDialog(Types type,
bool enableKeep,
int extraBttn,
const QString& icon,
00310
QWidget *parent,
const char *name )
00311 :
KDialogBase(parent, name, true, "", Ok|Cancel|extraBttn,
00312 Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type), d(new KPasswordDialogPrivate)
00313 {
00314
if ( icon.
stripWhiteSpace().isEmpty() )
00315 d->iconName =
"password";
00316
else
00317 d->iconName = icon;
00318 init();
00319 }
00320
00321 KPasswordDialog::KPasswordDialog(
int type,
QString prompt,
bool enableKeep,
00322
int extraBttn)
00323 :
KDialogBase(0L, "Password Dialog", true, "", Ok|Cancel|extraBttn,
00324 Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type), d(new KPasswordDialogPrivate)
00325 {
00326 d->iconName =
"password";
00327 init();
00328
setPrompt(prompt);
00329 }
00330
00331
void KPasswordDialog::init()
00332 {
00333 m_Row = 0;
00334
00335
KConfig*
const cfg =
KGlobal::config();
00336
const KConfigGroupSaver saver(cfg,
"Passwords");
00337
if (m_Keep && cfg->
readBoolEntry(
"Keep",
false))
00338 ++m_Keep;
00339
00340 m_pMain =
new QWidget(
this);
00341 setMainWidget(m_pMain);
00342 m_pGrid =
new QGridLayout(m_pMain, 10, 3, 0, 0);
00343 m_pGrid->addColSpacing(1, 10);
00344
00345
00346
QLabel *lbl;
00347
const QPixmap pix( KGlobal::iconLoader()->loadIcon( d->iconName, KIcon::NoGroup, KIcon::SizeHuge, 0, 0,
true));
00348
if (!pix.
isNull()) {
00349 lbl =
new QLabel(m_pMain);
00350 lbl->
setPixmap(pix);
00351 lbl->
setAlignment(AlignHCenter|AlignVCenter);
00352 lbl->setFixedSize(lbl->sizeHint());
00353 m_pGrid->
addWidget(lbl, 0, 0, AlignCenter);
00354 }
00355
00356 m_pHelpLbl =
new QLabel(m_pMain);
00357 m_pHelpLbl->
setAlignment(AlignLeft|AlignVCenter|WordBreak);
00358 m_pGrid->
addWidget(m_pHelpLbl, 0, 2, AlignLeft);
00359 m_pGrid->addRowSpacing(1, 10);
00360 m_pGrid->
setRowStretch(1, 12);
00361
00362
00363 m_pGrid->addRowSpacing(6, 5);
00364 m_pGrid->
setRowStretch(6, 12);
00365
00366
00367 lbl =
new QLabel(m_pMain);
00368 lbl->
setAlignment(AlignLeft|AlignVCenter);
00369 lbl->
setText(i18n(
"&Password:"));
00370 lbl->setFixedSize(lbl->sizeHint());
00371 m_pGrid->
addWidget(lbl, 7, 0, AlignLeft);
00372
00373
QHBoxLayout *h_lay =
new QHBoxLayout();
00374 m_pGrid->
addLayout(h_lay, 7, 2);
00375 m_pEdit =
new KPasswordEdit(m_pMain);
00376 m_pEdit2 = 0;
00377 lbl->
setBuddy(m_pEdit);
00378
QSize size = m_pEdit->
sizeHint();
00379 m_pEdit->setFixedHeight(size.
height());
00380 m_pEdit->setMinimumWidth(size.
width());
00381 h_lay->addWidget(m_pEdit);
00382
00383
00384
00385
if ((m_Type ==
Password) && m_Keep) {
00386 m_pGrid->addRowSpacing(8, 10);
00387 m_pGrid->
setRowStretch(8, 12);
00388
QCheckBox*
const cb =
new QCheckBox(i18n(
"&Keep password"), m_pMain);
00389 cb->setFixedSize(cb->sizeHint());
00390
if (m_Keep > 1)
00391 cb->
setChecked(
true);
00392
else
00393 m_Keep = 0;
00394 connect(cb, SIGNAL(toggled(
bool)), SLOT(slotKeep(
bool)));
00395 m_pGrid->
addWidget(cb, 9, 2, AlignLeft|AlignVCenter);
00396 }
else if (m_Type ==
NewPassword) {
00397 m_pGrid->addRowSpacing(8, 10);
00398 lbl =
new QLabel(m_pMain);
00399 lbl->
setAlignment(AlignLeft|AlignVCenter);
00400 lbl->
setText(i18n(
"&Verify:"));
00401 lbl->setFixedSize(lbl->sizeHint());
00402 m_pGrid->
addWidget(lbl, 9, 0, AlignLeft);
00403
00404 h_lay =
new QHBoxLayout();
00405 m_pGrid->
addLayout(h_lay, 9, 2);
00406 m_pEdit2 =
new KPasswordEdit(m_pMain);
00407 lbl->
setBuddy(m_pEdit2);
00408 size = m_pEdit2->
sizeHint();
00409 m_pEdit2->setFixedHeight(size.
height());
00410 m_pEdit2->setMinimumWidth(size.
width());
00411 h_lay->addWidget(m_pEdit2);
00412
00413
00414 m_pGrid->addRowSpacing(10, 10);
00415 m_pGrid->
setRowStretch(10, 12);
00416
00417
QHBox*
const strengthBox =
new QHBox(m_pMain);
00418 strengthBox->
setSpacing(10);
00419 m_pGrid->
addMultiCellWidget(strengthBox, 11, 11, 0, 2);
00420 QLabel*
const passStrengthLabel =
new QLabel(strengthBox);
00421 passStrengthLabel->
setAlignment(AlignLeft|AlignVCenter);
00422 passStrengthLabel->
setText(i18n(
"Password strength meter:"));
00423 d->m_strengthBar =
new KProgress(100, strengthBox,
"PasswordStrengthMeter");
00424 d->m_strengthBar->setPercentageVisible(
false);
00425
00426
const QString strengthBarWhatsThis(i18n(
"The password strength meter gives an indication of the security "
00427
"of the password you have entered. To improve the strength of "
00428
"the password, try:\n"
00429
" - using a longer password;\n"
00430
" - using a mixture of upper- and lower-case letters;\n"
00431
" - using numbers or symbols, such as #, as well as letters."));
00432
QWhatsThis::add(passStrengthLabel, strengthBarWhatsThis);
00433
QWhatsThis::add(d->m_strengthBar, strengthBarWhatsThis);
00434
00435
00436 m_pGrid->addRowSpacing(12, 10);
00437 m_pGrid->
setRowStretch(12, 12);
00438
00439 d->m_MatchLabel =
new QLabel(m_pMain);
00440 d->m_MatchLabel->setAlignment(AlignLeft|AlignVCenter|WordBreak);
00441 m_pGrid->
addMultiCellWidget(d->m_MatchLabel, 13, 13, 0, 2);
00442 d->m_MatchLabel->setText(i18n(
"Passwords do not match"));
00443
00444
00445 connect( m_pEdit, SIGNAL(textChanged(
const QString&)), SLOT(enableOkBtn()) );
00446 connect( m_pEdit2, SIGNAL(textChanged(
const QString&)), SLOT(enableOkBtn()) );
00447 enableOkBtn();
00448 }
00449
00450 erase();
00451 }
00452
00453
00454 KPasswordDialog::~KPasswordDialog()
00455 {
00456
delete d;
00457 }
00458
00459
00460 void KPasswordDialog::clearPassword()
00461 {
00462 m_pEdit->
erase();
00463 }
00464
00465
00466 void KPasswordDialog::setPrompt(
QString prompt)
00467 {
00468 m_pHelpLbl->
setText(prompt);
00469 m_pHelpLbl->setFixedSize(275, m_pHelpLbl->heightForWidth(275));
00470 }
00471
00472
00473 QString KPasswordDialog::prompt()
const
00474
00475
{
00476
return m_pHelpLbl->
text();
00477 }
00478
00479
00480
00481 void KPasswordDialog::addLine(
QString key,
QString value)
00482 {
00483
if (m_Row > 3)
00484
return;
00485
00486 QLabel *lbl =
new QLabel(key, m_pMain);
00487 lbl->
setAlignment(AlignLeft|AlignTop);
00488 lbl->setFixedSize(lbl->sizeHint());
00489 m_pGrid->
addWidget(lbl, m_Row+2, 0, AlignLeft);
00490
00491 lbl =
new QLabel(value, m_pMain);
00492 lbl->
setAlignment(AlignTop|WordBreak);
00493 lbl->setFixedSize(275, lbl->heightForWidth(275));
00494 m_pGrid->
addWidget(lbl, m_Row+2, 2, AlignLeft);
00495 ++m_Row;
00496 }
00497
00498
00499
void KPasswordDialog::erase()
00500 {
00501 m_pEdit->
erase();
00502 m_pEdit->setFocus();
00503
if (m_Type == NewPassword)
00504 m_pEdit2->
erase();
00505 }
00506
00507
00508 void KPasswordDialog::slotOk()
00509 {
00510
if (m_Type ==
NewPassword) {
00511
if (strcmp(m_pEdit->
password(), m_pEdit2->
password())) {
00512 KMessageBox::sorry(
this, i18n(
"You entered two different "
00513
"passwords. Please try again."));
00514 erase();
00515
return;
00516 }
00517
if (d->m_strengthBar && d->m_strengthBar->progress() < d->passwordStrengthWarningLevel) {
00518
int retVal = KMessageBox::warningYesNo(
this,
00519 i18n(
"The password you have entered has a low strength. "
00520
"To improve the strength of "
00521
"the password, try:\n"
00522
" - using a longer password;\n"
00523
" - using a mixture of upper- and lower-case letters;\n"
00524
" - using numbers or symbols as well as letters.\n"
00525
"\n"
00526
"Would you like to use this password anyway?"),
00527 i18n(
"Low Password Strength"));
00528
if (retVal == KMessageBox::No)
return;
00529 }
00530 }
00531
if (!
checkPassword(m_pEdit->
password())) {
00532 erase();
00533
return;
00534 }
00535
accept();
00536 }
00537
00538
00539 void KPasswordDialog::slotCancel()
00540 {
00541
reject();
00542 }
00543
00544
00545
void KPasswordDialog::slotKeep(
bool keep)
00546 {
00547 m_Keep = keep;
00548 }
00549
00550
00551
00552 int KPasswordDialog::getPassword(
QCString &password,
QString prompt,
00553
int *keep)
00554 {
00555
const bool enableKeep = (keep && *keep);
00556
KPasswordDialog*
const dlg =
new KPasswordDialog(
int(
Password), prompt, enableKeep);
00557
const int ret = dlg->
exec();
00558
if (ret == Accepted) {
00559 password = dlg->
password();
00560
if (enableKeep)
00561 *keep = dlg->
keep();
00562 }
00563
delete dlg;
00564
return ret;
00565 }
00566
00567
00568
00569 int KPasswordDialog::getNewPassword(
QCString &password,
QString prompt)
00570 {
00571
KPasswordDialog*
const dlg =
new KPasswordDialog(
NewPassword, prompt);
00572
const int ret = dlg->
exec();
00573
if (ret == Accepted)
00574 password = dlg->
password();
00575
delete dlg;
00576
return ret;
00577 }
00578
00579
00580
00581 void KPasswordDialog::disableCoreDumps()
00582 {
00583
struct rlimit rlim;
00584 rlim.rlim_cur = rlim.rlim_max = 0;
00585 setrlimit(RLIMIT_CORE, &rlim);
00586 }
00587
00588
void KPasswordDialog::virtual_hook(
int id,
void* data )
00589 { KDialogBase::virtual_hook(
id, data ); }
00590
00591
void KPasswordDialog::enableOkBtn()
00592 {
00593
if (m_Type ==
NewPassword) {
00594
const bool match = strcmp(m_pEdit->
password(), m_pEdit2->
password()) == 0
00595 && (d->allowEmptyPasswords || m_pEdit->
password()[0]);
00596
00597
const QString pass(m_pEdit->
password());
00598
00599
const int minPasswordLength =
minimumPasswordLength();
00600
00601
if ((
int) pass.
length() < minPasswordLength) {
00602
enableButtonOK(
false);
00603 }
else {
00604
enableButtonOK( match );
00605 }
00606
00607
if ( match && d->allowEmptyPasswords && m_pEdit->
password()[0] == 0 ) {
00608 d->m_MatchLabel->setText( i18n(
"Password is empty") );
00609 }
else {
00610
if ((
int) pass.
length() < minPasswordLength) {
00611 d->m_MatchLabel->setText(i18n(
"Password must be at least 1 character long",
"Password must be at least %n characters long", minPasswordLength));
00612 }
else {
00613 d->m_MatchLabel->setText( match? i18n(
"Passwords match")
00614 :i18n(
"Passwords do not match") );
00615 }
00616 }
00617
00618
00619
00620
00621
00622
00623
00624
const double lengthFactor = d->reasonablePasswordLength / 8.0;
00625
00626
00627
int pwlength = (
int) (pass.
length() / lengthFactor);
00628
if (pwlength > 5) pwlength = 5;
00629
00630
const QRegExp numRxp(
"[0-9]",
true,
false);
00631
int numeric = (
int) (pass.
contains(numRxp) / lengthFactor);
00632
if (numeric > 3) numeric = 3;
00633
00634
const QRegExp symbRxp(
"\\W",
false,
false);
00635
int numsymbols = (
int) (pass.
contains(symbRxp) / lengthFactor);
00636
if (numsymbols > 3) numsymbols = 3;
00637
00638
const QRegExp upperRxp(
"[A-Z]",
true,
false);
00639
int upper = (
int) (pass.
contains(upperRxp) / lengthFactor);
00640
if (upper > 3) upper = 3;
00641
00642
int pwstrength=((pwlength*10)-20) + (numeric*10) + (numsymbols*15) + (upper*10);
00643
00644
if ( pwstrength < 0 ) {
00645 pwstrength = 0;
00646 }
00647
00648
if ( pwstrength > 100 ) {
00649 pwstrength = 100;
00650 }
00651 d->m_strengthBar->setProgress(pwstrength);
00652
00653 }
00654 }
00655
00656
00657 void KPasswordDialog::setAllowEmptyPasswords(
bool allowed) {
00658 d->allowEmptyPasswords = allowed;
00659 enableOkBtn();
00660 }
00661
00662
00663 bool KPasswordDialog::allowEmptyPasswords()
const {
00664
return d->allowEmptyPasswords;
00665 }
00666
00667 void KPasswordDialog::setMinimumPasswordLength(
int minLength) {
00668 d->minimumPasswordLength = minLength;
00669 enableOkBtn();
00670 }
00671
00672 int KPasswordDialog::minimumPasswordLength()
const {
00673
return d->minimumPasswordLength;
00674 }
00675
00676 void KPasswordDialog::setMaximumPasswordLength(
int maxLength) {
00677
00678
if (maxLength < 0) maxLength = 0;
00679
if (maxLength >= KPasswordEdit::PassLen) maxLength = KPasswordEdit::PassLen - 1;
00680
00681 d->maximumPasswordLength = maxLength;
00682
00683 m_pEdit->
setMaxPasswordLength(maxLength);
00684
if (m_pEdit2) m_pEdit2->
setMaxPasswordLength(maxLength);
00685
00686 }
00687
00688 int KPasswordDialog::maximumPasswordLength()
const {
00689
return d->maximumPasswordLength;
00690 }
00691
00692
00693
00694 void KPasswordDialog::setReasonablePasswordLength(
int reasonableLength) {
00695
00696
if (reasonableLength < 1) reasonableLength = 1;
00697
if (reasonableLength >=
maximumPasswordLength()) reasonableLength =
maximumPasswordLength();
00698
00699 d->reasonablePasswordLength = reasonableLength;
00700
00701 }
00702
00703 int KPasswordDialog::reasonablePasswordLength()
const {
00704
return d->reasonablePasswordLength;
00705 }
00706
00707
00708 void KPasswordDialog::setPasswordStrengthWarningLevel(
int warningLevel) {
00709
if (warningLevel < 0) warningLevel = 0;
00710
if (warningLevel > 99) warningLevel = 99;
00711 d->passwordStrengthWarningLevel = warningLevel;
00712 }
00713
00714 int KPasswordDialog::passwordStrengthWarningLevel()
const {
00715
return d->passwordStrengthWarningLevel;
00716 }
00717
00718
#include "kpassdlg.moc"