kmail

accountdialog.h

00001 /*   -*- c++ -*-
00002  *   accountdialog.h
00003  *
00004  *   kmail: KDE mail client
00005  *   This file: Copyright (C) 2000 Espen Sand, espen@kde.org
00006  *
00007  *   This program is free software; you can redistribute it and/or modify
00008  *   it under the terms of the GNU General Public License as published by
00009  *   the Free Software Foundation; either version 2 of the License, or
00010  *   (at your option) any later version.
00011  *
00012  *   This program is distributed in the hope that it will be useful,
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *   GNU General Public License for more details.
00016  *
00017  *   You should have received a copy of the GNU General Public License
00018  *   along with this program; if not, write to the Free Software
00019  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef _ACCOUNT_DIALOG_H_
00024 #define _ACCOUNT_DIALOG_H_
00025 
00026 #include <kdialogbase.h>
00027 #include <klistview.h>
00028 #include <klineedit.h>
00029 #include <qguardedptr.h>
00030 #include "imapaccountbase.h"
00031 
00032 class QRegExpValidator;
00033 class QCheckBox;
00034 class QComboBox;
00035 class QPushButton;
00036 class QLabel;
00037 class QLineEdit;
00038 class QRadioButton;
00039 class QToolButton;
00040 class KIntNumInput;
00041 class KMAccount;
00042 class KMFolder;
00043 class KMServerTest;
00044 class QButtonGroup;
00045 
00046 namespace KMail {
00047 
00048 class SieveConfigEditor;
00049 class FolderRequester;
00050 
00051 class AccountDialog : public KDialogBase
00052 {
00053   Q_OBJECT
00054 
00055   public:
00056     AccountDialog( const QString & caption, KMAccount *account,
00057            QWidget *parent=0, const char *name=0, bool modal=true );
00058     virtual ~AccountDialog();
00059   private:
00060     struct LocalWidgets
00061     {
00062       QLabel       *titleLabel;
00063       QLineEdit    *nameEdit;
00064       QComboBox    *locationEdit;
00065       QRadioButton *lockMutt;
00066       QRadioButton *lockMuttPriv;
00067       QRadioButton *lockProcmail;
00068       QComboBox    *procmailLockFileName;
00069       QRadioButton *lockFcntl;
00070       QRadioButton *lockNone;
00071       QLineEdit    *precommand;
00072 #if 0
00073       QCheckBox    *resourceCheck;
00074       QPushButton  *resourceClearButton;
00075       QPushButton  *resourceClearPastButton;
00076 #endif
00077       QCheckBox    *includeInCheck;
00078       QCheckBox    *intervalCheck;
00079       QLabel       *intervalLabel;
00080       KIntNumInput *intervalSpin;
00081       QComboBox    *folderCombo;
00082       QComboBox    *identityCombo;
00083     };
00084 
00085     struct MaildirWidgets
00086     {
00087       QLabel       *titleLabel;
00088       QLineEdit    *nameEdit;
00089       QComboBox    *locationEdit;
00090       QLineEdit    *precommand;
00091 #if 0
00092       QCheckBox    *resourceCheck;
00093       QPushButton  *resourceClearButton;
00094       QPushButton  *resourceClearPastButton;
00095 #endif
00096       QCheckBox    *includeInCheck;
00097       QCheckBox    *intervalCheck;
00098       QLabel       *intervalLabel;
00099       KIntNumInput *intervalSpin;
00100       QComboBox    *folderCombo;
00101       QComboBox    *identityCombo;
00102     };
00103 
00104     struct PopWidgets
00105     {
00106       QLabel       *titleLabel;
00107       QLineEdit    *nameEdit;
00108       QLineEdit    *loginEdit;
00109       QLineEdit    *passwordEdit;
00110       QLineEdit    *hostEdit;
00111       QLineEdit    *portEdit;
00112       QLineEdit    *precommand;
00113       QButtonGroup *encryptionGroup;
00114       QRadioButton *encryptionNone;
00115       QRadioButton *encryptionSSL;
00116       QRadioButton *encryptionTLS;
00117       QButtonGroup *authGroup;
00118       QRadioButton *authUser;
00119       QRadioButton *authPlain;
00120       QRadioButton *authLogin;
00121       QRadioButton *authCRAM_MD5;
00122       QRadioButton *authDigestMd5;
00123       QRadioButton *authNTLM;
00124       QRadioButton *authGSSAPI;
00125       QRadioButton *authAPOP;
00126 
00127       QPushButton  *checkCapabilities;
00128       QCheckBox    *usePipeliningCheck;
00129       QCheckBox    *storePasswordCheck;
00130       QCheckBox    *leaveOnServerCheck;
00131       QCheckBox    *leaveOnServerDaysCheck;
00132       KIntNumInput *leaveOnServerDaysSpin;
00133       QCheckBox    *leaveOnServerCountCheck;
00134       KIntNumInput *leaveOnServerCountSpin;
00135       QCheckBox    *leaveOnServerSizeCheck;
00136       KIntNumInput *leaveOnServerSizeSpin;
00137 #if 0
00138       QCheckBox    *resourceCheck;
00139       QPushButton  *resourceClearButton;
00140       QPushButton  *resourceClearPastButton;
00141 #endif
00142       QCheckBox    *includeInCheck;
00143       QCheckBox    *intervalCheck;
00144       QCheckBox    *filterOnServerCheck;
00145       QLabel       *intervalLabel;
00146       KIntNumInput *intervalSpin;
00147       KIntNumInput *filterOnServerSizeSpin;
00148       QComboBox    *folderCombo;
00149       QComboBox    *identityCombo;
00150     };
00151 
00152     struct ImapWidgets
00153     {
00154       QLabel       *titleLabel;
00155       QLineEdit    *nameEdit;
00156       QLineEdit    *loginEdit;
00157       QLineEdit    *passwordEdit;
00158       QLineEdit    *hostEdit;
00159       QLineEdit    *portEdit;
00160 #if 0
00161       QCheckBox    *resourceCheck;
00162       QPushButton  *resourceClearButton;
00163       QPushButton  *resourceClearPastButton;
00164 #endif
00165       QCheckBox    *autoExpungeCheck;     // only used by normal (online) IMAP
00166       QCheckBox    *hiddenFoldersCheck;
00167       QCheckBox    *subscribedFoldersCheck;
00168       QCheckBox    *loadOnDemandCheck;
00169       QCheckBox    *storePasswordCheck;
00170       QCheckBox    *progressDialogCheck;  // only used by Disconnected IMAP
00171       QCheckBox    *includeInCheck;
00172       QCheckBox    *intervalCheck;
00173       QCheckBox    *listOnlyOpenCheck;
00174       QLabel       *intervalLabel;
00175       KIntNumInput *intervalSpin;
00176       QButtonGroup *encryptionGroup;
00177       QRadioButton *encryptionNone;
00178       QRadioButton *encryptionSSL;
00179       QRadioButton *encryptionTLS;
00180       QButtonGroup *authGroup;
00181       QRadioButton *authUser;
00182       QRadioButton *authPlain;
00183       QRadioButton *authLogin;
00184       QRadioButton *authCramMd5;
00185       QRadioButton *authDigestMd5;
00186       QRadioButton *authGSSAPI;
00187       QRadioButton *authNTLM;
00188       QRadioButton *authAnonymous;
00189       QPushButton  *checkCapabilities;
00190       FolderRequester *trashCombo;
00191       KLineEdit    *personalNS;
00192       KLineEdit    *otherUsersNS;
00193       KLineEdit    *sharedNS;
00194       QToolButton  *editPNS;
00195       QToolButton  *editONS;
00196       QToolButton  *editSNS;
00197       ImapAccountBase::nsDelimMap nsMap;
00198     };
00199 
00200   private slots:
00201     virtual void slotOk();
00202     void slotLocationChooser();
00203     void slotMaildirChooser();
00204     void slotEnablePopInterval( bool state );
00205     void slotEnableImapInterval( bool state );
00206     void slotEnableLocalInterval( bool state );
00207     void slotEnableMaildirInterval( bool state );
00208     void slotFontChanged();
00209     void slotLeaveOnServerClicked();
00210     void slotEnableLeaveOnServerDays( bool state );
00211     void slotEnableLeaveOnServerCount( bool state );
00212     void slotEnableLeaveOnServerSize( bool state );
00213     void slotFilterOnServerClicked();
00214     void slotPipeliningClicked();
00215     void slotPopEncryptionChanged(int);
00216     void slotImapEncryptionChanged(int);
00217     void slotCheckPopCapabilities();
00218     void slotCheckImapCapabilities();
00219     void slotPopCapabilities( const QStringList &, const QStringList & );
00220     void slotImapCapabilities( const QStringList &, const QStringList & );
00221     void slotReloadNamespaces();
00222     void slotSetupNamespaces( const ImapAccountBase::nsDelimMap& map );
00223     void slotEditPersonalNamespace();
00224     void slotEditOtherUsersNamespace();
00225     void slotEditSharedNamespace();
00226     void slotConnectionResult( int errorCode, const QString& );
00227     void slotLeaveOnServerDaysChanged( int value );
00228     void slotLeaveOnServerCountChanged( int value );
00229     void slotFilterOnServerSizeChanged( int value );
00230 #if 0
00231     // Moc doesn't understand #if 0, so they are also commented out
00232     // void slotClearResourceAllocations();
00233     // void slotClearPastResourceAllocations();
00234 #endif
00235 
00236   private:
00237     void makeLocalAccountPage();
00238     void makeMaildirAccountPage();
00239     void makePopAccountPage();
00240     void makeImapAccountPage( bool disconnected = false );
00241     void setupSettings();
00242     void saveSettings();
00243     void checkHighest( QButtonGroup * );
00244     static unsigned int popCapabilitiesFromStringList( const QStringList & );
00245     static unsigned int imapCapabilitiesFromStringList( const QStringList & );
00246     void enablePopFeatures( unsigned int );
00247     void enableImapAuthMethods( unsigned int );
00248     void initAccountForConnect();
00249     const QString namespaceListToString( const QStringList& list );
00250 
00251   private:
00252     LocalWidgets mLocal;
00253     MaildirWidgets mMaildir;
00254     PopWidgets   mPop;
00255     ImapWidgets  mImap;
00256     KMAccount    *mAccount;
00257     QValueList<QGuardedPtr<KMFolder> > mFolderList;
00258     QStringList  mFolderNames;
00259     KMServerTest *mServerTest;
00260     enum EncryptionMethods {
00261       NoEncryption = 0,
00262       SSL = 1,
00263       TLS = 2
00264     };
00265     enum Capabilities {
00266       Plain      =   1,
00267       Login      =   2,
00268       CRAM_MD5   =   4,
00269       Digest_MD5 =   8,
00270       Anonymous  =  16,
00271       APOP       =  32,
00272       Pipelining =  64,
00273       TOP        = 128,
00274       UIDL       = 256,
00275       STLS       = 512, // TLS for POP
00276       STARTTLS   = 512, // TLS for IMAP
00277       GSSAPI     = 1024,
00278       NTLM       = 2048,
00279       AllCapa    = 0xffffffff
00280     };
00281     unsigned int mCurCapa;
00282     unsigned int mCapaNormal;
00283     unsigned int mCapaSSL;
00284     unsigned int mCapaTLS;
00285     KMail::SieveConfigEditor *mSieveConfigEditor;
00286     QRegExpValidator *mValidator;
00287 };
00288 
00289 class NamespaceLineEdit: public KLineEdit
00290 {
00291   Q_OBJECT
00292 
00293   public:
00294     NamespaceLineEdit( QWidget* parent );
00295 
00296     const QString& lastText() { return mLastText; }
00297 
00298   public slots:
00299     virtual void setText ( const QString & );
00300 
00301   private:
00302     QString mLastText;
00303 };
00304 
00305 class NamespaceEditDialog: public KDialogBase
00306 {
00307   Q_OBJECT
00308 
00309   public:
00310     NamespaceEditDialog( QWidget* parent, ImapAccountBase::imapNamespace type,
00311         ImapAccountBase::nsDelimMap* map );
00312 
00313   protected slots:
00314     void slotOk();
00315     void slotRemoveEntry( int );
00316 
00317   private:
00318     ImapAccountBase::imapNamespace mType;
00319     ImapAccountBase::nsDelimMap* mNamespaceMap;
00320     ImapAccountBase::namespaceDelim mDelimMap;
00321     QMap<int, NamespaceLineEdit*> mLineEditMap;
00322     QButtonGroup* mBg;
00323 };
00324 
00325 } // namespace KMail
00326 
00327 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys