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 
00059   public:
00060     AccountDialog( const TQString & caption, KMAccount *account,
00061            TQWidget *parent=0, const char *name=0, bool modal=true );
00062     virtual ~AccountDialog();
00063   private:
00064     struct LocalWidgets
00065     {
00066       TQLabel       *titleLabel;
00067       TQLineEdit    *nameEdit;
00068       TQComboBox    *locationEdit;
00069       TQRadioButton *lockMutt;
00070       TQRadioButton *lockMuttPriv;
00071       TQRadioButton *lockProcmail;
00072       TQComboBox    *procmailLockFileName;
00073       TQRadioButton *lockFcntl;
00074       TQRadioButton *lockNone;
00075       TQLineEdit    *precommand;
00076 #if 0
00077       TQCheckBox    *resourceCheck;
00078       TQPushButton  *resourceClearButton;
00079       TQPushButton  *resourceClearPastButton;
00080 #endif
00081       TQCheckBox    *includeInCheck;
00082       TQCheckBox    *intervalCheck;
00083       TQLabel       *intervalLabel;
00084       KIntNumInput *intervalSpin;
00085       TQComboBox    *folderCombo;
00086       //TQComboBox    *identityCombo;
00087       KPIM::IdentityCombo    *identityCombo;
00088       TQLabel       *identityLabel;
00089     };
00090 
00091     struct MaildirWidgets
00092     {
00093       TQLabel       *titleLabel;
00094       TQLineEdit    *nameEdit;
00095       TQComboBox    *locationEdit;
00096       TQLineEdit    *precommand;
00097 #if 0
00098       TQCheckBox    *resourceCheck;
00099       TQPushButton  *resourceClearButton;
00100       TQPushButton  *resourceClearPastButton;
00101 #endif
00102       TQCheckBox    *includeInCheck;
00103       TQCheckBox    *intervalCheck;
00104       TQLabel       *intervalLabel;
00105       KIntNumInput *intervalSpin;
00106       TQComboBox    *folderCombo;
00107       //TQComboBox    *identityCombo;
00108       KPIM::IdentityCombo    *identityCombo;
00109       TQLabel       *identityLabel;
00110     };
00111 
00112     struct PopWidgets
00113     {
00114       TQLabel       *titleLabel;
00115       TQLineEdit    *nameEdit;
00116       TQLineEdit    *loginEdit;
00117       TQLineEdit    *passwordEdit;
00118       TQLineEdit    *hostEdit;
00119       TQLineEdit    *portEdit;
00120       TQLineEdit    *precommand;
00121       TQButtonGroup *encryptionGroup;
00122       TQRadioButton *encryptionNone;
00123       TQRadioButton *encryptionSSL;
00124       TQRadioButton *encryptionTLS;
00125       TQButtonGroup *authGroup;
00126       TQRadioButton *authUser;
00127       TQRadioButton *authPlain;
00128       TQRadioButton *authLogin;
00129       TQRadioButton *authCRAM_MD5;
00130       TQRadioButton *authDigestMd5;
00131       TQRadioButton *authNTLM;
00132       TQRadioButton *authGSSAPI;
00133       TQRadioButton *authAPOP;
00134 
00135       TQPushButton  *checkCapabilities;
00136       TQCheckBox    *usePipeliningCheck;
00137       TQCheckBox    *storePasswordCheck;
00138       TQCheckBox    *leaveOnServerCheck;
00139       TQCheckBox    *leaveOnServerDaysCheck;
00140       KIntNumInput *leaveOnServerDaysSpin;
00141       TQCheckBox    *leaveOnServerCountCheck;
00142       KIntNumInput *leaveOnServerCountSpin;
00143       TQCheckBox    *leaveOnServerSizeCheck;
00144       KIntNumInput *leaveOnServerSizeSpin;
00145 #if 0
00146       TQCheckBox    *resourceCheck;
00147       TQPushButton  *resourceClearButton;
00148       TQPushButton  *resourceClearPastButton;
00149 #endif
00150       TQCheckBox    *includeInCheck;
00151       TQCheckBox    *intervalCheck;
00152       TQCheckBox    *filterOnServerCheck;
00153       TQLabel       *intervalLabel;
00154       KIntNumInput *intervalSpin;
00155       KIntNumInput *filterOnServerSizeSpin;
00156       TQComboBox    *folderCombo;
00157       //TQComboBox    *identityCombo;
00158       KPIM::IdentityCombo    *identityCombo;
00159       TQLabel       *identityLabel;
00160     };
00161 
00162     struct ImapWidgets
00163     {
00164       TQLabel       *titleLabel;
00165       TQLineEdit    *nameEdit;
00166       TQLineEdit    *loginEdit;
00167       TQLineEdit    *passwordEdit;
00168       TQLineEdit    *hostEdit;
00169       TQLineEdit    *portEdit;
00170 #if 0
00171       TQCheckBox    *resourceCheck;
00172       TQPushButton  *resourceClearButton;
00173       TQPushButton  *resourceClearPastButton;
00174 #endif
00175       TQCheckBox    *autoExpungeCheck;     // only used by normal (online) IMAP
00176       TQCheckBox    *hiddenFoldersCheck;
00177       TQCheckBox    *subscribedFoldersCheck;
00178       TQCheckBox    *locallySubscribedFoldersCheck;
00179       TQCheckBox    *loadOnDemandCheck;
00180       TQCheckBox    *storePasswordCheck;
00181       TQCheckBox    *progressDialogCheck;  // only used by Disconnected IMAP
00182       TQCheckBox    *includeInCheck;
00183       TQCheckBox    *intervalCheck;
00184       TQCheckBox    *listOnlyOpenCheck;
00185       TQLabel       *intervalLabel;
00186       KIntNumInput *intervalSpin;
00187       TQButtonGroup *encryptionGroup;
00188       TQRadioButton *encryptionNone;
00189       TQRadioButton *encryptionSSL;
00190       TQRadioButton *encryptionTLS;
00191       TQButtonGroup *authGroup;
00192       TQRadioButton *authUser;
00193       TQRadioButton *authPlain;
00194       TQRadioButton *authLogin;
00195       TQRadioButton *authCramMd5;
00196       TQRadioButton *authDigestMd5;
00197       TQRadioButton *authGSSAPI;
00198       TQRadioButton *authNTLM;
00199       TQRadioButton *authAnonymous;
00200       TQPushButton  *checkCapabilities;
00201       FolderRequester *trashCombo;
00202       KLineEdit    *personalNS;
00203       KLineEdit    *otherUsersNS;
00204       KLineEdit    *sharedNS;
00205       TQToolButton  *editPNS;
00206       TQToolButton  *editONS;
00207       TQToolButton  *editSNS;
00208       ImapAccountBase::nsDelimMap nsMap;
00209       KPIM::IdentityCombo    *identityCombo;
00210       TQLabel       *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 TQStringList &, const TQStringList & );
00233     void slotImapCapabilities( const TQStringList &, const TQStringList & );
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 TQString& );
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( TQButtonGroup * );
00257     static unsigned int popCapabilitiesFromStringList( const TQStringList & );
00258     static unsigned int imapCapabilitiesFromStringList( const TQStringList & );
00259     void enablePopFeatures( unsigned int );
00260     void enableImapAuthMethods( unsigned int );
00261     void initAccountForConnect();
00262     const TQString namespaceListToString( const TQStringList& list );
00263 
00264   private:
00265     LocalWidgets mLocal;
00266     MaildirWidgets mMaildir;
00267     PopWidgets   mPop;
00268     ImapWidgets  mImap;
00269     KMAccount    *mAccount;
00270     TQValueList<TQGuardedPtr<KMFolder> > mFolderList;
00271     TQStringList  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     TQRegExpValidator *mValidator;
00300 };
00301 
00302 class NamespaceLineEdit: public KLineEdit
00303 {
00304   Q_OBJECT
00305 
00306   public:
00307     NamespaceLineEdit( TQWidget* parent );
00308 
00309     const TQString& lastText() { return mLastText; }
00310 
00311   public slots:
00312     virtual void setText ( const TQString & );
00313 
00314   private:
00315     TQString mLastText;
00316 };
00317 
00318 class NamespaceEditDialog: public KDialogBase
00319 {
00320   Q_OBJECT
00321 
00322   public:
00323     NamespaceEditDialog( TQWidget* 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     TQMap<int, NamespaceLineEdit*> mLineEditMap;
00335     TQButtonGroup* mBg;
00336 };
00337 
00338 } // namespace KMail
00339 
00340 #endif