1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
|
// vi: ts=8 sts=4 sw=4
/* This file is part of the KDE libraries
Copyright (C) 1998 Pietro Iglio <iglio@fub.it>
Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
Copyright (C) 2004,2005 Andrew Coles <andrew_coles@yahoo.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <unistd.h>
#include <tqwidget.h>
#include <tqlineedit.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqsize.h>
#include <tqevent.h>
#include <tqkeycode.h>
#include <tqcheckbox.h>
#include <tqregexp.h>
#include <tqhbox.h>
#include <tqwhatsthis.h>
#include <tqptrdict.h>
#include <kglobal.h>
#include <kdebug.h>
#include <kapplication.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kaboutdialog.h>
#include <kconfig.h>
#include <kstandarddirs.h>
#include <kprogress.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "kpassdlg.h"
#include "../kdesu/defaults.h"
/*
* Password line editor.
*/
// BCI: Add a real d-pointer and put the int into that
static TQPtrDict<int>* d_ptr = 0;
static void cleanup_d_ptr() {
delete d_ptr;
}
static int * ourMaxLength( const KPasswordEdit* const e ) {
if ( !d_ptr ) {
d_ptr = new TQPtrDict<int>;
d_ptr->setAutoDelete(true);
qAddPostRoutine( cleanup_d_ptr );
}
int* ret = d_ptr->find( (void*) e );
if ( ! ret ) {
ret = new int;
d_ptr->replace( (void*) e, ret );
}
return ret;
}
static void delete_d( const KPasswordEdit* const e ) {
if ( d_ptr )
d_ptr->remove( (void*) e );
}
const int KPasswordEdit::PassLen = 200;
class KPasswordDialog::KPasswordDialogPrivate
{
public:
KPasswordDialogPrivate()
: m_MatchLabel( 0 ), iconName( 0 ), allowEmptyPasswords( false ),
minimumPasswordLength(0), maximumPasswordLength(KPasswordEdit::PassLen - 1),
passwordStrengthWarningLevel(1), m_strengthBar(0),
reasonablePasswordLength(8)
{}
TQLabel *m_MatchLabel;
TQString iconName;
bool allowEmptyPasswords;
int minimumPasswordLength;
int maximumPasswordLength;
int passwordStrengthWarningLevel;
KProgress* m_strengthBar;
int reasonablePasswordLength;
};
KPasswordEdit::KPasswordEdit(TQWidget *parent, const char *name)
: TQLineEdit(parent, name)
{
init();
KConfig* const cfg = KGlobal::config();
KConfigGroupSaver saver(cfg, "Passwords");
const TQString val = cfg->readEntry("EchoMode", "OneStar");
if (val == "ThreeStars")
m_EchoMode = ThreeStars;
else if (val == "NoEcho")
m_EchoMode = NoEcho;
else
m_EchoMode = OneStar;
setInputMethodEnabled( true );
}
KPasswordEdit::KPasswordEdit(TQWidget *parent, const char *name, int echoMode)
: TQLineEdit(parent, name), m_EchoMode(echoMode)
{
init();
}
KPasswordEdit::KPasswordEdit(EchoModes echoMode, TQWidget *parent, const char *name)
: TQLineEdit(parent, name), m_EchoMode(echoMode)
{
init();
}
KPasswordEdit::KPasswordEdit(EchoMode echoMode, TQWidget *parent, const char *name)
: TQLineEdit(parent, name)
, m_EchoMode( echoMode == TQLineEdit::NoEcho ? NoEcho : OneStar )
{
init();
}
void KPasswordEdit::init()
{
setEchoMode(TQLineEdit::Password); // Just in case
setAcceptDrops(false);
int* t = ourMaxLength(this);
*t = (PassLen - 1); // the internal max length
m_Password = new char[PassLen];
m_Password[0] = '\000';
m_Length = 0;
}
KPasswordEdit::~KPasswordEdit()
{
memset(m_Password, 0, PassLen * sizeof(char));
delete[] m_Password;
delete_d(this);
}
void KPasswordEdit::insert(const TQString &txt)
{
const TQCString localTxt = txt.local8Bit();
const unsigned int lim = localTxt.length();
const int m_MaxLength = maxPasswordLength();
for(unsigned int i=0; i < lim; ++i)
{
const unsigned char ke = localTxt[i];
if (m_Length < m_MaxLength)
{
m_Password[m_Length] = ke;
m_Password[++m_Length] = '\000';
}
}
showPass();
}
void KPasswordEdit::erase()
{
m_Length = 0;
memset(m_Password, 0, PassLen * sizeof(char));
setText("");
}
void KPasswordEdit::focusInEvent(TQFocusEvent *e)
{
const TQString txt = text();
tqsetUpdatesEnabled(false);
TQLineEdit::focusInEvent(e);
tqsetUpdatesEnabled(true);
setText(txt);
}
void KPasswordEdit::keyPressEvent(TQKeyEvent *e)
{
switch (e->key()) {
case Key_Return:
case Key_Enter:
case Key_Escape:
e->ignore();
break;
case Key_Backspace:
case Key_Delete:
case 0x7f: // Delete
if (e->state() & (ControlButton | AltButton))
e->ignore();
else if (m_Length) {
m_Password[--m_Length] = '\000';
showPass();
}
break;
default:
const unsigned char ke = TQString(e->text()).local8Bit()[0];
if (ke >= 32) {
insert(e->text());
} else
e->ignore();
break;
}
}
bool KPasswordEdit::event(TQEvent *e) {
switch(e->type()) {
case TQEvent::MouseButtonPress:
case TQEvent::MouseButtonRelease:
case TQEvent::MouseButtonDblClick:
case TQEvent::MouseMove:
case TQEvent::IMStart:
case TQEvent::IMCompose:
return true; //Ignore
case TQEvent::IMEnd:
{
TQIMEvent* const ie = (TQIMEvent*) e;
if (!ie->text().isEmpty())
insert( ie->text() );
return true;
}
case TQEvent::AccelOverride:
{
TQKeyEvent* const k = (TQKeyEvent*) e;
switch (k->key()) {
case Key_U:
if (k->state() & ControlButton) {
m_Length = 0;
m_Password[m_Length] = '\000';
showPass();
}
}
return true; // stop bubbling
}
default:
// Do nothing
break;
}
return TQLineEdit::event(e);
}
void KPasswordEdit::showPass()
{
TQString tmp;
switch (m_EchoMode) {
case OneStar:
tmp.fill('*', m_Length);
setText(tmp);
break;
case ThreeStars:
tmp.fill('*', m_Length*3);
setText(tmp);
break;
case NoEcho: default:
emit textChanged(TQString::null); //To update the password comparison if need be.
break;
}
}
void KPasswordEdit::setMaxPasswordLength(int newLength)
{
if (newLength >= PassLen) newLength = PassLen - 1; // belt and braces
if (newLength < 0) newLength = 0;
int* t = ourMaxLength(this);
*t = newLength;
while (m_Length > newLength) {
m_Password[m_Length] = '\000';
--m_Length;
}
showPass();
}
int KPasswordEdit::maxPasswordLength() const
{
return *(ourMaxLength(this));
}
/*
* Password dialog.
*/
KPasswordDialog::KPasswordDialog(Types type, bool enableKeep, int extraBttn,
TQWidget *parent, const char *name)
: KDialogBase(parent, name, true, "", Ok|Cancel|extraBttn,
Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type), d(new KPasswordDialogPrivate)
{
d->iconName = "password";
init();
}
KPasswordDialog::KPasswordDialog(Types type, bool enableKeep, int extraBttn, const TQString& icon,
TQWidget *parent, const char *name )
: KDialogBase(parent, name, true, "", Ok|Cancel|extraBttn,
Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type), d(new KPasswordDialogPrivate)
{
if ( icon.stripWhiteSpace().isEmpty() )
d->iconName = "password";
else
d->iconName = icon;
init();
}
KPasswordDialog::KPasswordDialog(int type, TQString prompt, bool enableKeep,
int extraBttn)
: KDialogBase(0L, "Password Dialog", true, "", Ok|Cancel|extraBttn,
Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type), d(new KPasswordDialogPrivate)
{
d->iconName = "password";
init();
setPrompt(prompt);
}
void KPasswordDialog::init()
{
m_Row = 0;
KConfig* const cfg = KGlobal::config();
const KConfigGroupSaver saver(cfg, "Passwords");
bool def = ( qstrcmp( tqAppName(), "kdesu" ) == 0 ? defKeep : false );
if (m_Keep && cfg->readBoolEntry("Keep", def))
++m_Keep;
m_pMain = new TQWidget(this);
setMainWidget(m_pMain);
m_pGrid = new TQGridLayout(m_pMain, 10, 3, 0, 0);
m_pGrid->addColSpacing(1, 10);
// Row 1: pixmap + prompt
TQLabel *lbl;
const TQPixmap pix( KGlobal::iconLoader()->loadIcon( d->iconName, KIcon::NoGroup, KIcon::SizeHuge, 0, 0, true));
if (!pix.isNull()) {
lbl = new TQLabel(m_pMain);
lbl->setPixmap(pix);
lbl->tqsetAlignment(AlignHCenter|AlignVCenter);
lbl->setFixedSize(lbl->tqsizeHint());
m_pGrid->addWidget(lbl, 0, 0, (TQ_Alignment)AlignCenter);
}
m_pHelpLbl = new TQLabel(m_pMain);
m_pHelpLbl->tqsetAlignment(AlignLeft|AlignVCenter|WordBreak);
m_pGrid->addWidget(m_pHelpLbl, 0, 2, (TQ_Alignment)AlignLeft);
m_pGrid->addRowSpacing(1, 10);
m_pGrid->setRowStretch(1, 12);
// Row 2+: space for 4 extra info lines
m_pGrid->addRowSpacing(6, 5);
m_pGrid->setRowStretch(6, 12);
// Row 3: Password editor #1
lbl = new TQLabel(m_pMain);
lbl->tqsetAlignment(AlignLeft|AlignVCenter);
lbl->setText(i18n("&Password:"));
lbl->setFixedSize(lbl->tqsizeHint());
m_pGrid->addWidget(lbl, 7, 0, (TQ_Alignment)AlignLeft);
TQHBoxLayout *h_lay = new TQHBoxLayout();
m_pGrid->addLayout(h_lay, 7, 2);
m_pEdit = new KPasswordEdit(m_pMain);
m_pEdit2 = 0;
lbl->setBuddy(m_pEdit);
TQSize size = m_pEdit->tqsizeHint();
m_pEdit->setFixedHeight(size.height());
m_pEdit->setMinimumWidth(size.width());
h_lay->addWidget(m_pEdit);
// Row 4: Password editor #2 or keep password checkbox
if ((m_Type == Password) && m_Keep) {
m_pGrid->addRowSpacing(8, 10);
m_pGrid->setRowStretch(8, 12);
TQCheckBox* const cb = new TQCheckBox(i18n("&Keep password"), m_pMain);
cb->setFixedSize(cb->tqsizeHint());
if (m_Keep > 1)
cb->setChecked(true);
else
m_Keep = 0;
connect(cb, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotKeep(bool)));
m_pGrid->addWidget(cb, 9, 2, (TQ_Alignment)(AlignLeft|AlignVCenter));
} else if (m_Type == NewPassword) {
m_pGrid->addRowSpacing(8, 10);
lbl = new TQLabel(m_pMain);
lbl->tqsetAlignment(AlignLeft|AlignVCenter);
lbl->setText(i18n("&Verify:"));
lbl->setFixedSize(lbl->tqsizeHint());
m_pGrid->addWidget(lbl, 9, 0, (TQ_Alignment)AlignLeft);
h_lay = new TQHBoxLayout();
m_pGrid->addLayout(h_lay, 9, 2);
m_pEdit2 = new KPasswordEdit(m_pMain);
lbl->setBuddy(m_pEdit2);
size = m_pEdit2->tqsizeHint();
m_pEdit2->setFixedHeight(size.height());
m_pEdit2->setMinimumWidth(size.width());
h_lay->addWidget(m_pEdit2);
// Row 6: Password strength meter
m_pGrid->addRowSpacing(10, 10);
m_pGrid->setRowStretch(10, 12);
TQHBox* const strengthBox = new TQHBox(m_pMain);
strengthBox->setSpacing(10);
m_pGrid->addMultiCellWidget(strengthBox, 11, 11, 0, 2);
TQLabel* const passStrengthLabel = new TQLabel(strengthBox);
passStrengthLabel->tqsetAlignment(AlignLeft|AlignVCenter);
passStrengthLabel->setText(i18n("Password strength meter:"));
d->m_strengthBar = new KProgress(100, strengthBox, "PasswordStrengthMeter");
d->m_strengthBar->setPercentageVisible(false);
const TQString strengthBarWhatsThis(i18n("The password strength meter gives an indication of the security "
"of the password you have entered. To improve the strength of "
"the password, try:\n"
" - using a longer password;\n"
" - using a mixture of upper- and lower-case letters;\n"
" - using numbers or symbols, such as #, as well as letters."));
TQWhatsThis::add(passStrengthLabel, strengthBarWhatsThis);
TQWhatsThis::add(d->m_strengthBar, strengthBarWhatsThis);
// Row 6: Label saying whether the passwords match
m_pGrid->addRowSpacing(12, 10);
m_pGrid->setRowStretch(12, 12);
d->m_MatchLabel = new TQLabel(m_pMain);
d->m_MatchLabel->tqsetAlignment(AlignLeft|AlignVCenter|WordBreak);
m_pGrid->addMultiCellWidget(d->m_MatchLabel, 13, 13, 0, 2);
d->m_MatchLabel->setText(i18n("Passwords do not match"));
connect( m_pEdit, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(enableOkBtn()) );
connect( m_pEdit2, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(enableOkBtn()) );
enableOkBtn();
}
erase();
}
KPasswordDialog::~KPasswordDialog()
{
delete d;
}
void KPasswordDialog::clearPassword()
{
m_pEdit->erase();
}
/* KDE 4: Make it const TQString & */
void KPasswordDialog::setPrompt(TQString prompt)
{
m_pHelpLbl->setText(prompt);
m_pHelpLbl->setFixedSize(275, m_pHelpLbl->heightForWidth(275));
}
TQString KPasswordDialog::prompt() const
{
return m_pHelpLbl->text();
}
/* KDE 4: Make them const TQString & */
void KPasswordDialog::addLine(TQString key, TQString value)
{
if (m_Row > 3)
return;
TQLabel *lbl = new TQLabel(key, m_pMain);
lbl->tqsetAlignment(AlignLeft|AlignTop);
lbl->setFixedSize(lbl->tqsizeHint());
m_pGrid->addWidget(lbl, m_Row+2, 0, (TQ_Alignment)AlignLeft);
lbl = new TQLabel(value, m_pMain);
lbl->tqsetAlignment(AlignTop|WordBreak);
lbl->setFixedSize(275, lbl->heightForWidth(275));
m_pGrid->addWidget(lbl, m_Row+2, 2, (TQ_Alignment)AlignLeft);
++m_Row;
}
void KPasswordDialog::erase()
{
m_pEdit->erase();
m_pEdit->setFocus();
if (m_Type == NewPassword)
m_pEdit2->erase();
}
void KPasswordDialog::slotOk()
{
if (m_Type == NewPassword) {
if (strcmp(m_pEdit->password(), m_pEdit2->password())) {
KMessageBox::sorry(this, i18n("You entered two different "
"passwords. Please try again."));
erase();
return;
}
if (d->m_strengthBar && d->m_strengthBar->progress() < d->passwordStrengthWarningLevel) {
int retVal = KMessageBox::warningContinueCancel(this,
i18n( "The password you have entered has a low strength. "
"To improve the strength of "
"the password, try:\n"
" - using a longer password;\n"
" - using a mixture of upper- and lower-case letters;\n"
" - using numbers or symbols as well as letters.\n"
"\n"
"Would you like to use this password anyway?"),
i18n("Low Password Strength"));
if (retVal == KMessageBox::Cancel) return;
}
}
if (!checkPassword(m_pEdit->password())) {
erase();
return;
}
accept();
}
void KPasswordDialog::slotCancel()
{
reject();
}
void KPasswordDialog::slotKeep(bool keep)
{
m_Keep = keep;
}
// static . antlarr: KDE 4: Make it const TQString & prompt
int KPasswordDialog::getPassword(TQCString &password, TQString prompt,
int *keep)
{
const bool enableKeep = (keep && *keep);
KPasswordDialog* const dlg = new KPasswordDialog(int(Password), prompt, enableKeep);
const int ret = dlg->exec();
if (ret == Accepted) {
password = dlg->password();
if (enableKeep)
*keep = dlg->keep();
}
delete dlg;
return ret;
}
// static . antlarr: KDE 4: Make it const TQString & prompt
int KPasswordDialog::getNewPassword(TQCString &password, TQString prompt)
{
KPasswordDialog* const dlg = new KPasswordDialog(NewPassword, prompt);
const int ret = dlg->exec();
if (ret == Accepted)
password = dlg->password();
delete dlg;
return ret;
}
// static
void KPasswordDialog::disableCoreDumps()
{
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
}
void KPasswordDialog::virtual_hook( int id, void* data )
{ KDialogBase::virtual_hook( id, data ); }
void KPasswordDialog::enableOkBtn()
{
if (m_Type == NewPassword) {
const bool match = strcmp(m_pEdit->password(), m_pEdit2->password()) == 0
&& (d->allowEmptyPasswords || m_pEdit->password()[0]);
const TQString pass(m_pEdit->password());
const int minPasswordLength = minimumPasswordLength();
if ((int) pass.length() < minPasswordLength) {
enableButtonOK(false);
} else {
enableButtonOK( match );
}
if ( match && d->allowEmptyPasswords && m_pEdit->password()[0] == 0 ) {
d->m_MatchLabel->setText( i18n("Password is empty") );
} else {
if ((int) pass.length() < minPasswordLength) {
d->m_MatchLabel->setText(i18n("Password must be at least 1 character long", "Password must be at least %n characters long", minPasswordLength));
} else {
d->m_MatchLabel->setText( match? i18n("Passwords match")
:i18n("Passwords do not match") );
}
}
// Password strength calculator
// Based on code in the Master Password dialog in Firefox
// (pref-masterpass.js)
// Original code triple-licensed under the MPL, GPL, and LGPL
// so is license-compatible with this file
const double lengthFactor = d->reasonablePasswordLength / 8.0;
int pwlength = (int) (pass.length() / lengthFactor);
if (pwlength > 5) pwlength = 5;
const TQRegExp numRxp("[0-9]", true, false);
int numeric = (int) (pass.contains(numRxp) / lengthFactor);
if (numeric > 3) numeric = 3;
const TQRegExp symbRxp("\\W", false, false);
int numsymbols = (int) (pass.contains(symbRxp) / lengthFactor);
if (numsymbols > 3) numsymbols = 3;
const TQRegExp upperRxp("[A-Z]", true, false);
int upper = (int) (pass.contains(upperRxp) / lengthFactor);
if (upper > 3) upper = 3;
int pwstrength=((pwlength*10)-20) + (numeric*10) + (numsymbols*15) + (upper*10);
if ( pwstrength < 0 ) {
pwstrength = 0;
}
if ( pwstrength > 100 ) {
pwstrength = 100;
}
d->m_strengthBar->setProgress(pwstrength);
}
}
void KPasswordDialog::setAllowEmptyPasswords(bool allowed) {
d->allowEmptyPasswords = allowed;
enableOkBtn();
}
bool KPasswordDialog::allowEmptyPasswords() const {
return d->allowEmptyPasswords;
}
void KPasswordDialog::setMinimumPasswordLength(int minLength) {
d->minimumPasswordLength = minLength;
enableOkBtn();
}
int KPasswordDialog::minimumPasswordLength() const {
return d->minimumPasswordLength;
}
void KPasswordDialog::setMaximumPasswordLength(int maxLength) {
if (maxLength < 0) maxLength = 0;
if (maxLength >= KPasswordEdit::PassLen) maxLength = KPasswordEdit::PassLen - 1;
d->maximumPasswordLength = maxLength;
m_pEdit->setMaxPasswordLength(maxLength);
if (m_pEdit2) m_pEdit2->setMaxPasswordLength(maxLength);
}
int KPasswordDialog::maximumPasswordLength() const {
return d->maximumPasswordLength;
}
// reasonable password length code contributed by Steffen Mthing
void KPasswordDialog::setReasonablePasswordLength(int reasonableLength) {
if (reasonableLength < 1) reasonableLength = 1;
if (reasonableLength >= maximumPasswordLength()) reasonableLength = maximumPasswordLength();
d->reasonablePasswordLength = reasonableLength;
}
int KPasswordDialog::reasonablePasswordLength() const {
return d->reasonablePasswordLength;
}
void KPasswordDialog::setPasswordStrengthWarningLevel(int warningLevel) {
if (warningLevel < 0) warningLevel = 0;
if (warningLevel > 99) warningLevel = 99;
d->passwordStrengthWarningLevel = warningLevel;
}
int KPasswordDialog::passwordStrengthWarningLevel() const {
return d->passwordStrengthWarningLevel;
}
#include "kpassdlg.moc"
|