kmail

accountdialog.h

Go to the documentation of this file.
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 KPIM {
00047 class IdentityCombo;
00048 }
00049 
00050 namespace KMail {
00051 
00052 class SieveConfigEditor;
00053 class FolderRequester;
00054 
00055 class AccountDialog : public KDialogBase
00056 {
00057   Q_OBJECT
00058 
00059   public:
00060     AccountDialog( const QString & caption, KMAccount *account,
00061            QWidget *parent=0, const char *name=0, bool modal=true );
00062     virtual ~AccountDialog();
00063   private:
00064     struct LocalWidgets
00065     {
00066       QLabel       *titleLabel;
00067       QLineEdit    *nameEdit;
00068       QComboBox    *locationEdit;
00069       QRadioButton *lockMutt;
00070       QRadioButton *lockMuttPriv;
00071       QRadioButton *lockProcmail;
00072       QComboBox    *procmailLockFileName;
00073       QRadioButton *lockFcntl;
00074       QRadioButton *lockNone;
00075       QLineEdit    *precommand;
00076 #if 0
00077       QCheckBox    *resourceCheck;
00078       QPushButton  *resourceClearButton;
00079       QPushButton  *resourceClearPastButton;
00080 #endif
00081       QCheckBox    *includeInCheck;
00082       QCheckBox    *intervalCheck;
00083       QLabel       *intervalLabel;
00084       KIntNumInput *intervalSpin;
00085       QComboBox    *folderCombo;
00086       //QComboBox    *identityCombo;
00087       KPIM::IdentityCombo    *identityCombo;
00088       QLabel       *identityLabel;
00089     };
00090 
00091     struct MaildirWidgets
00092     {
00093       QLabel       *titleLabel;
00094       QLineEdit    *nameEdit;
00095       QComboBox    *locationEdit;
00096       QLineEdit    *precommand;
00097 #if 0
00098       QCheckBox    *resourceCheck;
00099       QPushButton  *resourceClearButton;
00100       QPushButton  *resourceClearPastButton;
00101 #endif
00102       QCheckBox    *includeInCheck;
00103       QCheckBox    *intervalCheck;
00104       QLabel       *intervalLabel;
00105       KIntNumInput *intervalSpin;
00106       QComboBox    *folderCombo;
00107       //QComboBox    *identityCombo;
00108       KPIM::IdentityCombo    *identityCombo;
00109       QLabel       *identityLabel;
00110     };
00111 
00112     struct PopWidgets
00113     {
00114       QLabel       *titleLabel;
00115       QLineEdit    *nameEdit;
00116       QLineEdit    *loginEdit;
00117       QLineEdit    *passwordEdit;
00118       QLineEdit    *hostEdit;
00119       QLineEdit    *portEdit;
00120       QLineEdit    *precommand;
00121       QButtonGroup *encryptionGroup;
00122       QRadioButton *encryptionNone;
00123       QRadioButton *encryptionSSL;
00124       QRadioButton *encryptionTLS;
00125       QButtonGroup *authGroup;
00126       QRadioButton *authUser;
00127       QRadioButton *authPlain;
00128       QRadioButton *authLogin;
00129       QRadioButton *authCRAM_MD5;
00130       QRadioButton *authDigestMd5;
00131       QRadioButton *authNTLM;
00132       QRadioButton *authGSSAPI;
00133       QRadioButton *authAPOP;
00134 
00135       QPushButton  *checkCapabilities;
00136       QCheckBox    *usePipeliningCheck;
00137       QCheckBox    *storePasswordCheck;
00138       QCheckBox    *leaveOnServerCheck;
00139       QCheckBox    *leaveOnServerDaysCheck;
00140       KIntNumInput *leaveOnServerDaysSpin;
00141       QCheckBox    *leaveOnServerCountCheck;
00142       KIntNumInput *leaveOnServerCountSpin;
00143       QCheckBox    *leaveOnServerSizeCheck;
00144       KIntNumInput *leaveOnServerSizeSpin;
00145 #if 0
00146       QCheckBox    *resourceCheck;
00147       QPushButton  *resourceClearButton;
00148       QPushButton  *resourceClearPastButton;
00149 #endif
00150       QCheckBox    *includeInCheck;
00151       QCheckBox    *intervalCheck;
00152       QCheckBox    *filterOnServerCheck;
00153       QLabel       *intervalLabel;
00154       KIntNumInput *intervalSpin;
00155       KIntNumInput *filterOnServerSizeSpin;
00156       QComboBox    *folderCombo;
00157       //QComboBox    *identityCombo;
00158       KPIM::IdentityCombo    *identityCombo;
00159       QLabel       *identityLabel;
00160     };
00161 
00162     struct ImapWidgets
00163     {
00164       QLabel       *titleLabel;
00165       QLineEdit    *nameEdit;
00166       QLineEdit    *loginEdit;
00167       QLineEdit    *passwordEdit;
00168       QLineEdit    *hostEdit;
00169       QLineEdit    *portEdit;
00170 #if 0
00171       QCheckBox    *resourceCheck;
00172       QPushButton  *resourceClearButton;
00173       QPushButton  *resourceClearPastButton;
00174 #endif
00175       QCheckBox    *autoExpungeCheck;     // only used by normal (online) IMAP
00176       QCheckBox    *hiddenFoldersCheck;
00177       QCheckBox    *subscribedFoldersCheck;
00178       QCheckBox    *locallySubscribedFoldersCheck;
00179       QCheckBox    *loadOnDemandCheck;
00180       QCheckBox    *storePasswordCheck;
00181       QCheckBox    *progressDialogCheck;  // only used by Disconnected IMAP
00182       QCheckBox    *includeInCheck;
00183       QCheckBox    *intervalCheck;
00184       QCheckBox    *listOnlyOpenCheck;
00185       QLabel       *intervalLabel;
00186       KIntNumInput *intervalSpin;
00187       QButtonGroup *encryptionGroup;
00188       QRadioButton *encryptionNone;
00189       QRadioButton *encryptionSSL;
00190       QRadioButton *encryptionTLS;
00191       QButtonGroup *authGroup;
00192       QRadioButton *authUser;
00193       QRadioButton *authPlain;
00194       QRadioButton *authLogin;
00195       QRadioButton *authCramMd5;
00196       QRadioButton *authDigestMd5;
00197       QRadioButton *authGSSAPI;
00198       QRadioButton *authNTLM;
00199       QRadioButton *authAnonymous;
00200       QPushButton  *checkCapabilities;
00201       FolderRequester *trashCombo;
00202       KLineEdit    *personalNS;
00203       KLineEdit    *otherUsersNS;
00204       KLineEdit    *sharedNS;
00205       QToolButton  *editPNS;
00206       QToolButton  *editONS;
00207       QToolButton  *editSNS;
00208       ImapAccountBase::nsDelimMap nsMap;
00209       KPIM::IdentityCombo    *identityCombo;
00210       QLabel       *identityLabel;
00211     };
00212 
00213   private slots:
00214     virtual void slotOk();
00215     void slotLocationChooser();
00216     void slotMaildirChooser();
00217     void slotEnablePopInterval( bool state );
00218     void slotEnableImapInterval( bool state );
00219     void slotEnableLocalInterval( bool state );
00220     void slotEnableMaildirInterval( bool state );
00221     void slotFontChanged();
00222     void slotLeaveOnServerClicked();
00223     void slotEnableLeaveOnServerDays( bool state );
00224     void slotEnableLeaveOnServerCount( bool state );
00225     void slotEnableLeaveOnServerSize( bool state );
00226     void slotFilterOnServerClicked();
00227     void slotPipeliningClicked();
00228     void slotPopEncryptionChanged(int);
00229     void slotImapEncryptionChanged(int);
00230     void slotCheckPopCapabilities();
00231     void slotCheckImapCapabilities();
00232     void slotPopCapabilities( const QStringList &, const QStringList & );
00233     void slotImapCapabilities( const QStringList &, const QStringList & );
00234     void slotReloadNamespaces();
00235     void slotSetupNamespaces( const ImapAccountBase::nsDelimMap& map );
00236     void slotEditPersonalNamespace();
00237     void slotEditOtherUsersNamespace();
00238     void slotEditSharedNamespace();
00239     void slotConnectionResult( int errorCode, const QString& );
00240     void slotLeaveOnServerDaysChanged( int value );
00241     void slotLeaveOnServerCountChanged( int value );
00242     void slotFilterOnServerSizeChanged( int value );
00243 #if 0
00244     // Moc doesn't understand #if 0, so they are also commented out
00245     // void slotClearResourceAllocations();
00246     // void slotClearPastResourceAllocations();
00247 #endif
00248 
00249   private:
00250     void makeLocalAccountPage();
00251     void makeMaildirAccountPage();
00252     void makePopAccountPage();
00253     void makeImapAccountPage( bool disconnected = false );
00254     void setupSettings();
00255     void saveSettings();
00256     void checkHighest( QButtonGroup * );
00257     static unsigned int popCapabilitiesFromStringList( const QStringList & );
00258     static unsigned int imapCapabilitiesFromStringList( const QStringList & );
00259     void enablePopFeatures( unsigned int );
00260     void enableImapAuthMethods( unsigned int );
00261     void initAccountForConnect();
00262     const QString namespaceListToString( const QStringList& list );
00263 
00264   private:
00265     LocalWidgets mLocal;
00266     MaildirWidgets mMaildir;
00267     PopWidgets   mPop;
00268     ImapWidgets  mImap;
00269     KMAccount    *mAccount;
00270     QValueList<QGuardedPtr<KMFolder> > mFolderList;
00271     QStringList  mFolderNames;
00272     KMServerTest *mServerTest;
00273     enum EncryptionMethods {
00274       NoEncryption = 0,
00275       SSL = 1,
00276       TLS = 2
00277     };
00278     enum Capabilities {
00279       Plain      =   1,
00280       Login      =   2,
00281       CRAM_MD5   =   4,
00282       Digest_MD5 =   8,
00283       Anonymous  =  16,
00284       APOP       =  32,
00285       Pipelining =  64,
00286       TOP        = 128,
00287       UIDL       = 256,
00288       STLS       = 512, // TLS for POP
00289       STARTTLS   = 512, // TLS for IMAP
00290       GSSAPI     = 1024,
00291       NTLM       = 2048,
00292       AllCapa    = 0xffffffff
00293     };
00294     unsigned int mCurCapa;
00295     unsigned int mCapaNormal;
00296     unsigned int mCapaSSL;
00297     unsigned int mCapaTLS;
00298     KMail::SieveConfigEditor *mSieveConfigEditor;
00299     QRegExpValidator *mValidator;
00300 };
00301 
00302 class NamespaceLineEdit: public KLineEdit
00303 {
00304   Q_OBJECT
00305 
00306   public:
00307     NamespaceLineEdit( QWidget* parent );
00308 
00309     const QString& lastText() { return mLastText; }
00310 
00311   public slots:
00312     virtual void setText ( const QString & );
00313 
00314   private:
00315     QString mLastText;
00316 };
00317 
00318 class NamespaceEditDialog: public KDialogBase
00319 {
00320   Q_OBJECT
00321 
00322   public:
00323     NamespaceEditDialog( QWidget* parent, ImapAccountBase::imapNamespace type,
00324         ImapAccountBase::nsDelimMap* map );
00325 
00326   protected slots:
00327     void slotOk();
00328     void slotRemoveEntry( int );
00329 
00330   private:
00331     ImapAccountBase::imapNamespace mType;
00332     ImapAccountBase::nsDelimMap* mNamespaceMap;
00333     ImapAccountBase::namespaceDelim mDelimMap;
00334     QMap<int, NamespaceLineEdit*> mLineEditMap;
00335     QButtonGroup* mBg;
00336 };
00337 
00338 } // namespace KMail
00339 
00340 #endif