kmail

kmtransport.h

Go to the documentation of this file.
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 QCheckBox;
00026 class QLabel;
00027 class QLineEdit;
00028 class QRadioButton;
00029 class KMServerTest;
00030 class QButtonGroup;
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 QString &name);
00040   static QStringList availableTransports();
00041   uint id() const { return mId; }
00042 
00044   QString passwd() const;
00045   void setPasswd( const QString& passwd );
00046 
00048   bool storePasswd() const { return mStorePasswd; }
00049   void setStorePasswd( bool store );
00050 
00052   void readPassword() const;
00053 
00054   QString type, name, host, port, user, precommand, encryption, authType;
00055   QString localHostname;
00056   bool auth, specifyHostname;
00057 
00058   private:
00059     mutable QString 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( QWidget *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 QString & caption, KMTransportInfo *transportInfo,
00085              QWidget *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 QStringList &, const QStringList &,
00095                              const QString &, const QString &,
00096                              const QString & );
00097   void slotSendmailEditPath(const QString &);
00098 private:
00099   struct SendmailWidgets
00100   {
00101     QLabel       *titleLabel;
00102     QLineEdit    *nameEdit;
00103     QLineEdit    *locationEdit;
00104     QPushButton  *chooseButton;
00105   };
00106   struct SmtpWidgets
00107   {
00108     QLabel       *titleLabel;
00109     QLineEdit    *nameEdit;
00110     QLineEdit    *hostEdit;
00111     QLineEdit    *portEdit;
00112     QCheckBox    *authCheck;
00113     QLabel       *loginLabel;
00114     QLineEdit    *loginEdit;
00115     QLabel       *passwordLabel;
00116     QLineEdit    *passwordEdit;
00117     QLineEdit    *precommand;
00118     QButtonGroup *encryptionGroup;
00119     QRadioButton *encryptionNone;
00120     QRadioButton *encryptionSSL;
00121     QRadioButton *encryptionTLS;
00122     QButtonGroup *authGroup;
00123     QRadioButton *authPlain;
00124     QRadioButton *authLogin;
00125     QRadioButton *authCramMd5;
00126     QRadioButton *authDigestMd5;
00127     QRadioButton *authNTLM;
00128     QRadioButton *authGSSAPI;
00129     QPushButton  *checkCapabilities;
00130     QCheckBox    *storePasswordCheck;
00131     QCheckBox    *specifyHostnameCheck;
00132     QLineEdit    *localHostnameEdit;
00133     QLabel       *localHostnameLabel;
00134   };
00135 
00136   void makeSendmailPage();
00137   void makeSmtpPage();
00138   void setupSettings();
00139   void saveSettings();
00140   void checkHighest( QButtonGroup * );
00141   void enableAuthMethods( unsigned int which );
00142   bool sanityCheckSmtpInput();
00143   static unsigned int authMethodsFromString( const QString & s );
00144   static unsigned int authMethodsFromStringList( const QStringList & 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