kmail

kmtransport.h

00001 /*
00002  * kmtransport.h
00003  *
00004  * Copyright (c) 2001-2002 Michael Haeckel <haeckel@kde.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License version 2
00008  *  as published by the Free Software Foundation
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef _KMTRANSPORT_H_
00021 #define _KMTRANSPORT_H_
00022 
00023 #include <kdialogbase.h>
00024 
00025 class TQCheckBox;
00026 class TQLabel;
00027 class TQLineEdit;
00028 class TQRadioButton;
00029 class KMServerTest;
00030 class TQButtonGroup;
00031 
00032 class KMTransportInfo : public QObject
00033 {
00034 public:
00035   KMTransportInfo();
00036   virtual ~KMTransportInfo();
00037   void readConfig(int id);
00038   void writeConfig(int id);
00039   static int findTransport(const TQString &name);
00040   static TQStringList availableTransports();
00041   uint id() const { return mId; }
00042 
00044   TQString passwd() const;
00045   void setPasswd( const TQString& passwd );
00046 
00048   bool storePasswd() const { return mStorePasswd; }
00049   void setStorePasswd( bool store );
00050 
00052   void readPassword() const;
00053 
00054   TQString type, name, host, port, user, precommand, encryption, authType;
00055   TQString localHostname;
00056   bool auth, specifyHostname;
00057 
00058   private:
00059     mutable TQString mPasswd;
00060     bool mPasswdDirty, mStorePasswd, mStorePasswdInConfig;
00061     uint mId;
00062 };
00063 
00064 class KMTransportSelDlg : public KDialogBase
00065 {
00066   Q_OBJECT
00067 
00068 public:
00069   KMTransportSelDlg( TQWidget *parent=0, const char *name=0, bool modal=TRUE );
00070   int selected() const;
00071 
00072 private slots:
00073   void buttonClicked( int id );
00074 
00075 private:
00076   int mSelectedButton;
00077 };
00078 
00079 class KMTransportDialog : public KDialogBase
00080 {
00081   Q_OBJECT
00082 
00083 public:
00084   KMTransportDialog( const TQString & caption, KMTransportInfo *transportInfo,
00085              TQWidget *parent=0, const char *name=0, bool modal=TRUE );
00086   virtual ~KMTransportDialog();
00087 
00088 private slots:
00089   virtual void slotOk();
00090   void slotSendmailChooser();
00091   void slotRequiresAuthClicked();
00092   void slotSmtpEncryptionChanged(int);
00093   void slotCheckSmtpCapabilities();
00094   void slotSmtpCapabilities( const TQStringList &, const TQStringList &,
00095                              const TQString &, const TQString &,
00096                              const TQString & );
00097   void slotSendmailEditPath(const TQString &);
00098 private:
00099   struct SendmailWidgets
00100   {
00101     TQLabel       *titleLabel;
00102     TQLineEdit    *nameEdit;
00103     TQLineEdit    *locationEdit;
00104     TQPushButton  *chooseButton;
00105   };
00106   struct SmtpWidgets
00107   {
00108     TQLabel       *titleLabel;
00109     TQLineEdit    *nameEdit;
00110     TQLineEdit    *hostEdit;
00111     TQLineEdit    *portEdit;
00112     TQCheckBox    *authCheck;
00113     TQLabel       *loginLabel;
00114     TQLineEdit    *loginEdit;
00115     TQLabel       *passwordLabel;
00116     TQLineEdit    *passwordEdit;
00117     TQLineEdit    *precommand;
00118     TQButtonGroup *encryptionGroup;
00119     TQRadioButton *encryptionNone;
00120     TQRadioButton *encryptionSSL;
00121     TQRadioButton *encryptionTLS;
00122     TQButtonGroup *authGroup;
00123     TQRadioButton *authPlain;
00124     TQRadioButton *authLogin;
00125     TQRadioButton *authCramMd5;
00126     TQRadioButton *authDigestMd5;
00127     TQRadioButton *authNTLM;
00128     TQRadioButton *authGSSAPI;
00129     TQPushButton  *checkCapabilities;
00130     TQCheckBox    *storePasswordCheck;
00131     TQCheckBox    *specifyHostnameCheck;
00132     TQLineEdit    *localHostnameEdit;
00133     TQLabel       *localHostnameLabel;
00134   };
00135 
00136   void makeSendmailPage();
00137   void makeSmtpPage();
00138   void setupSettings();
00139   void saveSettings();
00140   void checkHighest( TQButtonGroup * );
00141   void enableAuthMethods( unsigned int which );
00142   bool sanityCheckSmtpInput();
00143   static unsigned int authMethodsFromString( const TQString & s );
00144   static unsigned int authMethodsFromStringList( const TQStringList & sl );
00145 
00146   KMServerTest    *mServerTest;
00147   SmtpWidgets     mSmtp;
00148   SendmailWidgets mSendmail;
00149   KMTransportInfo *mTransportInfo;
00150   enum EncryptionMethods {
00151     NoEncryption = 0,
00152     SSL = 1,
00153     TLS = 2
00154   };
00155   enum AuthMethods {
00156     NoAuth = 0,
00157     LOGIN = 1,
00158     PLAIN = 2,
00159     CRAM_MD5 = 4,
00160     DIGEST_MD5 = 8,
00161     NTLM = 16,
00162     GSSAPI = 32,
00163     AllAuth = 0xffffffff
00164   };
00165   unsigned int mAuthNone, mAuthSSL, mAuthTLS;
00166 };
00167 
00168 
00169 #endif