kdeui Library API Documentation

KPasswordDialog Class Reference

A password input dialog. More...

#include <kpassdlg.h>

Inheritance diagram for KPasswordDialog:

Inheritance graph
[legend]
Collaboration diagram for KPasswordDialog:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Types { Password, NewPassword }

Public Member Functions

 KPasswordDialog (Types type, bool enableKeep, int extraBttn, QWidget *parent=0, const char *name=0)
 KPasswordDialog (int type, QString prompt, bool enableKeep=false, int extraBttn=0) KDE_DEPRECATED
 KPasswordDialog (Types type, bool enableKeep, int extraBttn, const QString &iconName, QWidget *parent=0, const char *name=0)
virtual ~KPasswordDialog ()
void setPrompt (QString prompt)
QString prompt () const
void addLine (QString key, QString value)
void setAllowEmptyPasswords (bool allowed)
bool allowEmptyPasswords () const
void setMinimumPasswordLength (int minLength)
int minimumPasswordLength () const
void setMaximumPasswordLength (int maxLength)
int maximumPasswordLength () const
void setReasonablePasswordLength (int reasonableLength)
int reasonablePasswordLength () const
void setPasswordStrengthWarningLevel (int warningLevel)
int passwordStrengthWarningLevel () const
const char * password () const
void clearPassword ()
bool keep () const

Static Public Member Functions

int getPassword (QCString &password, QString prompt, int *keep=0L)
int getNewPassword (QCString &password, QString prompt)
void disableCoreDumps ()

Protected Slots

void slotOk ()
void slotCancel ()
void slotKeep (bool)

Protected Member Functions

virtual bool checkPassword (const char *)
virtual void virtual_hook (int id, void *data)

Detailed Description

A password input dialog.

This dialog asks the user to enter a password. The functions you're probably interested in are the static methods, getPassword() and getNewPassword().

Usage example

 QCString password;
 int result = KPasswordDialog::getPassword(password, i18n("Prompt message"));
 if (result == KPasswordDialog::Accepted)
     use(password);

kpassworddialog.png

KDE Password Dialog

Security notes:

Keeping passwords in memory can be a potential security hole. You should handle this situation with care.

Author:
Geert Jansen <jansen@kde.org>

Definition at line 166 of file kpassdlg.h.


Member Enumeration Documentation

enum KPasswordDialog::Types
 

This enum distinguishes the two operation modes of this dialog:.

Enumeration values:
Password  The user is asked to enter a password.
NewPassword  The user is asked to enter a password and to confirm it a second time.

This is usually used when the user changes his password.

Definition at line 175 of file kpassdlg.h.


Constructor & Destructor Documentation

KPasswordDialog::KPasswordDialog Types  type,
bool  enableKeep,
int  extraBttn,
QWidget parent = 0,
const char *  name = 0
 

Constructs a password dialog.

Parameters:
type: if NewPassword is given here, the dialog contains two input fields, so that the user must confirm his password and possible typos are detected immediately.
enableKeep: if true, a check box is shown in the dialog which allows the user to keep his password input for later.
extraBttn: allows to show additional buttons, KDialogBase.
parent Passed to lower level constructor.
name Passed to lower level constructor
Since:
3.0

Definition at line 300 of file kpassdlg.cpp.

Referenced by getNewPassword(), and getPassword().

KPasswordDialog::KPasswordDialog int  type,
QString  prompt,
bool  enableKeep = false,
int  extraBttn = 0
 

Deprecated:
Variant of the previous constructor without the possibility to specify a parent. Will be removed in KDE 4.0

Definition at line 321 of file kpassdlg.cpp.

References setPrompt().

KPasswordDialog::KPasswordDialog Types  type,
bool  enableKeep,
int  extraBttn,
const QString iconName,
QWidget parent = 0,
const char *  name = 0
 

Construct a password dialog.

Essentially the same as above but allows the icon in the password dialog to be set via iconName.

Parameters:
type if NewPassword is given here, the dialog contains two input fields, so that the user must confirm his password and possible typos are detected immediately
enableKeep: if true, a check box is shown in the dialog which allows the user to keep his password input for later.
extraBttn: allows to show additional buttons.
iconName the name of the icon to be shown in the dialog. If empty, a default icon is used
parent Passed to lower level constructor.
name Passed to lower level constructor
Since:
3.3

Definition at line 309 of file kpassdlg.cpp.

KPasswordDialog::~KPasswordDialog  )  [virtual]
 

Destructs the password dialog.

Definition at line 454 of file kpassdlg.cpp.


Member Function Documentation

void KPasswordDialog::setPrompt QString  prompt  ) 
 

Sets the password prompt.

Definition at line 466 of file kpassdlg.cpp.

Referenced by KPasswordDialog().

QString KPasswordDialog::prompt  )  const
 

Returns the password prompt.

Definition at line 473 of file kpassdlg.cpp.

void KPasswordDialog::addLine QString  key,
QString  value
 

Adds a line of information to the dialog.

Definition at line 481 of file kpassdlg.cpp.

void KPasswordDialog::setAllowEmptyPasswords bool  allowed  ) 
 

Allow empty passwords? - Default: false

Since:
3.4.

Definition at line 657 of file kpassdlg.cpp.

References allowEmptyPasswords().

bool KPasswordDialog::allowEmptyPasswords  )  const
 

Allow empty passwords?

Since:
3.4.

Definition at line 663 of file kpassdlg.cpp.

Referenced by setAllowEmptyPasswords().

void KPasswordDialog::setMinimumPasswordLength int  minLength  ) 
 

Minimum acceptable password length.

Default: If empty passwords are forbidden, 1; Otherwise, 0.

Parameters:
minLength: The new minimum password length
Since:
3.4

Definition at line 667 of file kpassdlg.cpp.

References minimumPasswordLength().

int KPasswordDialog::minimumPasswordLength  )  const
 

Minimum acceptable password length.

Since:
3.4

Definition at line 672 of file kpassdlg.cpp.

Referenced by setMinimumPasswordLength().

void KPasswordDialog::setMaximumPasswordLength int  maxLength  ) 
 

Maximum acceptable password length.

Limited to 199. Default: No limit, i.e. -1

Parameters:
maxLength: The new maximum password length.
Since:
3.4

Definition at line 676 of file kpassdlg.cpp.

References maximumPasswordLength(), and KPasswordEdit::setMaxPasswordLength().

int KPasswordDialog::maximumPasswordLength  )  const
 

Maximum acceptable password length.

Since:
3.4

Definition at line 688 of file kpassdlg.cpp.

Referenced by setMaximumPasswordLength(), and setReasonablePasswordLength().

void KPasswordDialog::setReasonablePasswordLength int  reasonableLength  ) 
 

Password length that is expected to be reasonably safe.

Default: 8 - the standard UNIX password length

Parameters:
reasonableLength: The new reasonable password length.
Since:
3.4

Definition at line 694 of file kpassdlg.cpp.

References maximumPasswordLength().

int KPasswordDialog::reasonablePasswordLength  )  const
 

Password length that is expected to be reasonably safe.

Since:
3.4

Definition at line 703 of file kpassdlg.cpp.

void KPasswordDialog::setPasswordStrengthWarningLevel int  warningLevel  ) 
 

Set the password strength level below which a warning is given Value is in the range 0 to 99.

Empty passwords score 0; non-empty passwords score up to 100, depending on their length and whether they contain numbers, mixed case letters and punctuation.

Default: 1 - warn if the password has no discernable strength whatsoever

Parameters:
warningLevel: The level below which a warning should be given.
Since:
3.4

Definition at line 708 of file kpassdlg.cpp.

int KPasswordDialog::passwordStrengthWarningLevel  )  const
 

Password strength level below which a warning is given

Since:
3.4.

Definition at line 714 of file kpassdlg.cpp.

const char* KPasswordDialog::password  )  const [inline]
 

Returns the password entered.

The memory is freed in the destructor, so you should make a copy.

Definition at line 334 of file kpassdlg.h.

Referenced by getNewPassword(), and getPassword().

void KPasswordDialog::clearPassword  ) 
 

Clears the password input field.

You might want to use this after the user failed to enter the correct password.

Since:
3.3

Definition at line 460 of file kpassdlg.cpp.

References KPasswordEdit::erase().

bool KPasswordDialog::keep  )  const [inline]
 

Returns true if the user wants to keep the password.

Definition at line 346 of file kpassdlg.h.

Referenced by getPassword().

int KPasswordDialog::getPassword QCString password,
QString  prompt,
int *  keep = 0L
[static]
 

Pops up the dialog, asks the user for a password, and returns it.

Parameters:
password The password is returned in this reference parameter.
prompt A prompt for the password. This can be a few lines of information. The text is word broken to fit nicely in the dialog.
keep Enable/disable a checkbox controlling password keeping. If you pass a null pointer, or a pointer to the value 0, the checkbox is not shown. If you pass a pointer to a nonzero value, the checkbox is shown and the result is stored in *keep.
Returns:
Result code: Accepted or Rejected.

Definition at line 552 of file kpassdlg.cpp.

References keep(), KPasswordDialog(), password(), and Password.

int KPasswordDialog::getNewPassword QCString password,
QString  prompt
[static]
 

Pops up the dialog, asks the user for a password and returns it.

The user has to enter the password twice to make sure it was entered correctly.

Parameters:
password The password is returned in this reference parameter.
prompt A prompt for the password. This can be a few lines of information. The text is word broken to fit nicely in the dialog.
Returns:
Result code: Accepted or Rejected.

Definition at line 569 of file kpassdlg.cpp.

References KPasswordDialog(), NewPassword, and password().

void KPasswordDialog::disableCoreDumps  )  [static]
 

Static helper function that disables core dumps.

Definition at line 581 of file kpassdlg.cpp.

void KPasswordDialog::slotOk  )  [protected, virtual, slot]
 

Activated when the Ok button has been clicked.

The QDialog::accept() is activated.

Reimplemented from KDialogBase.

Definition at line 508 of file kpassdlg.cpp.

References checkPassword(), KPasswordEdit::password(), KMessageBox::sorry(), and KMessageBox::warningYesNo().

void KPasswordDialog::slotCancel  )  [protected, virtual, slot]
 

Activated when the Cancel button has been clicked.

The QDialog::reject() is activated in regular mode and QDialog::done( Cancel ) when in message box mode.

Reimplemented from KDialogBase.

Definition at line 539 of file kpassdlg.cpp.

virtual bool KPasswordDialog::checkPassword const char *   )  [inline, protected, virtual]
 

Virtual function that can be overridden to provide password checking in derived classes.

It should return true if the password is valid, false otherwise.

Definition at line 391 of file kpassdlg.h.

Referenced by slotOk().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdeui Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 7 22:06:49 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003