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