/usr/include/k3passworddialog.h is in kdelibs5-dev 4:4.8.4-4+deb7u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | // 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.
*/
#ifndef K3PASSWORDDIALOG_H
#define K3PASSWORDDIALOG_H
#include <kde3support_export.h>
#include <kdialog.h>
#include <QtGui/QLineEdit>
class QLabel;
class QGridLayout;
class QWidget;
/**
* @short A safe password input widget.
* @author Geert Jansen <geertj@kde.org>
*
* The widget uses the user's global "echo mode" setting.
* @deprecated use KLineEdit with KLineEdit::setPasswordMode(true)
*/
class KDE3SUPPORT_EXPORT K3PasswordEdit
: public QLineEdit
{
Q_OBJECT
public:
enum EchoModes { OneStar, ThreeStars, NoEcho };
/**
* Constructs a password input widget using the user's global "echo mode" setting.
*/
explicit K3PasswordEdit(QWidget *parent=0);
// KDE4: either of the two must go! add default values for parameters
/**
* Constructs a password input widget using echoMode as "echo mode".
* Note that echoMode is a QLineEdit::EchoMode.
*/
explicit K3PasswordEdit(EchoMode echoMode, QWidget *parent = 0);
/**
* Constructs a password input widget using echoMode as "echo mode".
* Note that echoMode is a K3PasswordEdit::EchoModes.
*/
explicit K3PasswordEdit(EchoModes echoMode, QWidget *parent = 0);
/**
* Destructs the widget.
*/
~K3PasswordEdit();
/**
* Returns the password. The memory is freed in the destructor
* so you should make a copy.
*/
const char *password() const;
/**
* Erases the current password.
*/
void erase();
static const int PassLen;
/**
* Set the current maximum password length. If a password longer than the limit
* specified is currently entered, it is truncated accordingly.
*
* The length is capped to lie between 0 and 199 inclusive.
*
* @param newLength: The new maximum password length
*/
void setMaxPasswordLength(int newLength);
/**
* Returns the current maximum password length.
*/
int maxPasswordLength() const;
public Q_SLOTS:
/**
* Reimplementation
*/
virtual void insert( const QString &);
protected:
virtual void keyPressEvent(QKeyEvent *);
virtual void focusInEvent(QFocusEvent *e);
virtual bool event(QEvent *e);
private:
void init();
void showPass();
char *m_Password;
int m_EchoMode, m_Length;
};
/**
* @short 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().
*
* <b>Usage example</b>\n
*
* \code
* QCString password;
* int result = K3PasswordDialog::getPassword(parent, password, i18n("Prompt message"));
* if (result == K3PasswordDialog::Accepted)
* use(password);
* \endcode
*
* \image html k3passworddialog.png "KDE Password Dialog"
*
* <b>Security notes:</b>\n
*
* Keeping passwords in memory can be a potential security hole. You should
* handle this situation with care.
*
* @li You may want to use disableCoreDump() to disable core dumps.
* Core dumps are dangerous because they are an image of the process memory,
* and thus include any passwords that were in memory.
*
* @li You should delete passwords as soon as they are not needed anymore.
* The functions getPassword() and getNewPassword() return the
* password as a QCString. I believe this is safer than a QString. A QString
* stores its characters internally as 16-bit wide values, so conversions are
* needed, both for creating the QString and by using it. The temporary
* memory used for these conversion is probably not erased. This could lead
* to stray passwords in memory, even if you think you erased all of them.
*
* @author Geert Jansen <jansen@kde.org>
* @deprecated use KPasswordDialog or KNewPasswordDialog
*/
class KDE3SUPPORT_EXPORT K3PasswordDialog
: public KDialog
{
Q_OBJECT
public:
/**
* This enum distinguishes the two operation modes of this dialog:
*/
enum Types {
/**
* The user is asked to enter a password.
*/
Password,
/**
* 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.
*/
NewPassword
};
/**
* Constructs a password dialog.
*
* @param 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.
* @param enableKeep: if true, a check box is shown in the dialog
* which allows the user to keep his password input for later.
* @param extraBttn: allows to show additional buttons, KDialog.
* @param parent Passed to lower level constructor.
*/
K3PasswordDialog(Types type, bool enableKeep, ButtonCodes extraBttn, QWidget *parent=0);
/**
* Construct a password dialog. Essentially the same as above but allows the
* icon in the password dialog to be set via @p iconName.
* @param 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
* @param enableKeep: if true, a check box is shown in the dialog
* which allows the user to keep his password input for later.
* @param extraBttn: allows to show additional buttons.
* @param iconName the name of the icon to be shown in the dialog. If empty,
* a default icon is used
* @param parent Passed to lower level constructor.
*/
K3PasswordDialog(Types type, bool enableKeep, ButtonCodes extraBttn, const QString& iconName,
QWidget *parent = 0);
/**
* Destructs the password dialog.
*/
virtual ~K3PasswordDialog();
/**
* Sets the password prompt.
*/
void setPrompt(const QString &prompt);
/**
* Returns the password prompt.
*/
QString prompt() const;
/**
* Adds a line of information to the dialog.
*/
void addLine(const QString &key, const QString &value);
/**
* Allow empty passwords? - Default: false
*/
void setAllowEmptyPasswords(bool allowed);
/**
* Allow empty passwords?
*/
bool allowEmptyPasswords() const;
/**
* Minimum acceptable password length.
* Default: If empty passwords are forbidden, 1;
* Otherwise, 0.
*
* @param minLength: The new minimum password length
*/
void setMinimumPasswordLength(int minLength);
/**
* Minimum acceptable password length.
*/
int minimumPasswordLength() const;
/**
* Maximum acceptable password length. Limited to 199.
* Default: No limit, i.e. -1
*
* @param maxLength: The new maximum password length.
*/
void setMaximumPasswordLength(int maxLength);
/**
* Maximum acceptable password length.
*/
int maximumPasswordLength() const;
/**
* Password length that is expected to be reasonably safe.
*
* Default: 8 - the standard UNIX password length
*
* @param reasonableLength: The new reasonable password length.
*/
void setReasonablePasswordLength(int reasonableLength);
/**
* Password length that is expected to be reasonably safe.
*/
int reasonablePasswordLength() const;
/**
* 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
* @param warningLevel: The level below which a warning should be given.
*/
void setPasswordStrengthWarningLevel(int warningLevel);
/**
* Password strength level below which a warning is given
*/
int passwordStrengthWarningLevel() const;
/**
* Returns the password entered. The memory is freed in the destructor,
* so you should make a copy.
*/
const char *password() const;
/**
* Clears the password input field. You might want to use this after the
* user failed to enter the correct password.
*/
void clearPassword();
/**
* Returns true if the user wants to keep the password.
*/
bool keep() const;
/**
* Pops up the dialog, asks the user for a password, and returns it.
*
* @param parent The widget the dialog belongs too
* @param password The password is returned in this reference parameter.
* @param caption A caption for the dialog.
* @param 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.
* @param keep Enable/disable a checkbox controlling password keeping.
* If you pass a null pointer, or a pointer to the value false, the checkbox
* is not shown. If you pass a pointer to a true value, the checkbox
* is shown and the result is stored in *keep.
* @return Result code: Accepted or Rejected.
*/
static int getPassword(QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt, bool *keep = 0L);
/**
* @overload
*
* @deprecated Use the new version with the caption argument
*/
static KDE_DEPRECATED int getPassword(QWidget *parent, QByteArray &password, const QString &prompt, int *keep = 0L);
/**
* 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.
*
* @param parent The widget the dialog belongs too
* @param password The password is returned in this reference parameter.
* @param caption A caption for the dialog.
* @param 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.
* @return Result code: Accepted or Rejected.
*/
static int getNewPassword(QWidget *parent, QByteArray &password, const QString &caption, const QString &prompt);
/**
* @overload
*
* @deprecated Use the new version with the caption argument
*/
static KDE_DEPRECATED int getNewPassword(QWidget *parent, QByteArray &password, const QString &prompt);
/**
* Static helper function that disables core dumps.
*/
static void disableCoreDumps();
virtual void accept();
protected Q_SLOTS:
void slotKeep(bool);
protected:
/**
* Virtual function that can be overridden to provide password
* checking in derived classes. It should return @p true if the
* password is valid, @p false otherwise.
*/
virtual bool checkPassword(const char *password);
private Q_SLOTS:
void enableOkBtn();
private:
void init();
void erase();
int m_Keep, m_Type, m_Row;
QLabel *m_pHelpLbl;
QGridLayout *m_pGrid;
QWidget *m_pMain;
K3PasswordEdit *m_pEdit, *m_pEdit2;
private:
class K3PasswordDialogPrivate;
K3PasswordDialogPrivate* const d;
};
#endif // K3PasswordDialog_H
|