kpassdlg.h
00001 // vi: ts=8 sts=4 sw=4 00002 /* This file is part of the KDE libraries 00003 Copyright (C) 1998 Pietro Iglio <iglio@fub.it> 00004 Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> 00005 Copyright (C) 2004,2005 Andrew Coles <andrew_coles@yahoo.co.uk> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License version 2 as published by the Free Software Foundation. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 #ifndef __KPassDlg_h_included__ 00022 #define __KPassDlg_h_included__ 00023 00024 #include <tqstring.h> 00025 #include <tqlineedit.h> 00026 #include <kdialogbase.h> 00027 00028 class TQLabel; 00029 class TQGridLayout; 00030 class TQWidget; 00031 00039 class TDEUI_EXPORT KPasswordEdit 00040 : public TQLineEdit 00041 { 00042 Q_OBJECT 00043 00044 public: 00045 enum EchoModes { OneStar, ThreeStars, NoEcho }; 00046 00050 KPasswordEdit(TQWidget *parent=0, const char *name=0); 00051 // KDE4: either of the two must go! add default values for parameters 00052 00058 KPasswordEdit(EchoMode echoMode, TQWidget *parent, const char *name); 00059 00065 KPasswordEdit(EchoModes echoMode, TQWidget *parent, const char *name); 00066 00071 KPasswordEdit(TQWidget *parent, const char *name, int echoMode) KDE_DEPRECATED; 00072 00076 ~KPasswordEdit(); 00077 00082 const char *password() const; 00083 00087 void erase(); 00088 00089 static const int PassLen; 00090 00098 void setMaxPasswordLength(int newLength); 00099 00104 int maxPasswordLength() const; 00105 00106 public slots: 00110 virtual void insert( const TQString &); 00111 00112 protected: 00113 virtual void keyPressEvent(TQKeyEvent *); 00114 virtual void focusInEvent(TQFocusEvent *e); 00115 virtual bool event(TQEvent *e); 00116 00117 private: 00118 void init(); 00119 }; 00120 00121 00160 class TDEUI_EXPORT KPasswordDialog 00161 : public KDialogBase 00162 { 00163 Q_OBJECT 00164 00165 public: 00169 enum Types { 00173 Password, 00174 00180 NewPassword 00181 }; 00182 00197 KPasswordDialog(Types type, bool enableKeep, int extraBttn, 00198 TQWidget *parent=0, const char *name=0); 00199 00204 KPasswordDialog(int type, TQString prompt, bool enableKeep=false, 00205 int extraBttn=0) KDE_DEPRECATED; 00206 // note that this implicitly deprecates the 'prompt' variants of 00207 // getPassword() below. i guess the above constructor needs to be extended. 00208 00224 KPasswordDialog(Types type, bool enableKeep, int extraBttn, const TQString& iconName, 00225 TQWidget *parent = 0, const char *name = 0); 00226 00230 virtual ~KPasswordDialog(); 00231 00235 void setPrompt(TQString prompt); 00236 00240 TQString prompt() const; 00241 00245 void setKeepWarning(TQString warn); 00246 00250 void addLine(TQString key, TQString value); 00251 00256 void setAllowEmptyPasswords(bool allowed); 00257 00262 bool allowEmptyPasswords() const; 00263 00272 void setMinimumPasswordLength(int minLength); 00273 00278 int minimumPasswordLength() const; 00279 00287 void setMaximumPasswordLength(int maxLength); 00288 00293 int maximumPasswordLength() const; 00294 00303 void setReasonablePasswordLength(int reasonableLength); 00304 00309 int reasonablePasswordLength() const; 00310 00321 void setPasswordStrengthWarningLevel(int warningLevel); 00322 00327 int passwordStrengthWarningLevel() const; 00328 00333 const char *password() const { return m_pEdit->password(); } 00334 00340 void clearPassword(); 00341 00345 bool keep() const { return m_Keep; } 00346 00359 static int getPassword(TQCString &password, TQString prompt, int *keep=0L); 00360 00371 static int getNewPassword(TQCString &password, TQString prompt); 00372 00376 static void disableCoreDumps(); 00377 00378 protected slots: 00379 void slotOk(); 00380 void slotCancel(); 00381 void slotKeep(bool); 00382 void slotLayout(); 00383 00384 protected: 00385 00391 virtual bool checkPassword(const char *) { return true; } 00392 00393 private slots: 00394 void enableOkBtn(); 00395 00396 private: 00397 void init(); 00398 void erase(); 00399 00400 int m_Keep; 00401 int m_Type; 00402 int m_Row; 00403 TQLabel *m_pHelpLbl; 00404 TQLabel *m_keepWarnLbl; 00405 TQGridLayout *m_pGrid; 00406 TQWidget *m_pMain; 00407 KPasswordEdit *m_pEdit; 00408 KPasswordEdit *m_pEdit2; 00409 00410 protected: 00411 virtual void virtual_hook( int id, void* data ); 00412 private: 00413 class KPasswordDialogPrivate; 00414 KPasswordDialogPrivate* const d; 00415 }; 00416 00417 00418 #endif // __KPassDlg_h_included__