summaryrefslogtreecommitdiffstats
path: root/kmail/kmtransport.h
blob: a71541fe146e96a470cf72b9d046295439ef7a70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
 * kmtransport.h
 *
 * Copyright (c) 2001-2002 Michael Haeckel <haeckel@kde.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2
 *  as published by the Free Software Foundation
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef _KMTRANSPORT_H_
#define _KMTRANSPORT_H_

#include <kdialogbase.h>

class QCheckBox;
class QLabel;
class QLineEdit;
class QRadioButton;
class KMServerTest;
class QButtonGroup;

class KMTransportInfo : public QObject
{
public:
  KMTransportInfo();
  virtual ~KMTransportInfo();
  void readConfig(int id);
  void writeConfig(int id);
  static int findTransport(const TQString &name);
  static TQStringList availableTransports();
  uint id() const { return mId; }

  /** Get/set password for this account */
  TQString passwd() const;
  void setPasswd( const TQString& passwd );

  /** Get/set password storage flag */
  bool storePasswd() const { return mStorePasswd; }
  void setStorePasswd( bool store );

  /** Read password from wallet */
  void readPassword() const;

  TQString type, name, host, port, user, precommand, encryption, authType;
  TQString localHostname;
  bool auth, specifyHostname;

  private:
    mutable TQString mPasswd;
    bool mPasswdDirty, mStorePasswd, mStorePasswdInConfig;
    uint mId;
};

class KMTransportSelDlg : public KDialogBase
{
  Q_OBJECT

public:
  KMTransportSelDlg( TQWidget *parent=0, const char *name=0, bool modal=TRUE );
  int selected() const;

private slots:
  void buttonClicked( int id );

private:
  int mSelectedButton;
};

class KMTransportDialog : public KDialogBase
{
  Q_OBJECT

public:
  KMTransportDialog( const TQString & caption, KMTransportInfo *transportInfo,
		     TQWidget *parent=0, const char *name=0, bool modal=TRUE );
  virtual ~KMTransportDialog();

private slots:
  virtual void slotOk();
  void slotSendmailChooser();
  void slotRequiresAuthClicked();
  void slotSmtpEncryptionChanged(int);
  void slotCheckSmtpCapabilities();
  void slotSmtpCapabilities( const TQStringList &, const TQStringList &,
                             const TQString &, const TQString &,
                             const TQString & );
  void slotSendmailEditPath(const TQString &);
private:
  struct SendmailWidgets
  {
    TQLabel       *titleLabel;
    TQLineEdit    *nameEdit;
    TQLineEdit    *locationEdit;
    TQPushButton  *chooseButton;
  };
  struct SmtpWidgets
  {
    TQLabel       *titleLabel;
    TQLineEdit    *nameEdit;
    TQLineEdit    *hostEdit;
    TQLineEdit    *portEdit;
    TQCheckBox    *authCheck;
    TQLabel       *loginLabel;
    TQLineEdit    *loginEdit;
    TQLabel       *passwordLabel;
    TQLineEdit    *passwordEdit;
    TQLineEdit    *precommand;
    TQButtonGroup *encryptionGroup;
    TQRadioButton *encryptionNone;
    TQRadioButton *encryptionSSL;
    TQRadioButton *encryptionTLS;
    TQButtonGroup *authGroup;
    TQRadioButton *authPlain;
    TQRadioButton *authLogin;
    TQRadioButton *authCramMd5;
    TQRadioButton *authDigestMd5;
    TQRadioButton *authNTLM;
    TQRadioButton *authGSSAPI;
    TQPushButton  *checkCapabilities;
    TQCheckBox    *storePasswordCheck;
    TQCheckBox    *specifyHostnameCheck;
    TQLineEdit    *localHostnameEdit;
    TQLabel       *localHostnameLabel;
  };

  void makeSendmailPage();
  void makeSmtpPage();
  void setupSettings();
  void saveSettings();
  void checkHighest( TQButtonGroup * );
  void enableAuthMethods( unsigned int which );
  bool sanityCheckSmtpInput();
  static unsigned int authMethodsFromString( const TQString & s );
  static unsigned int authMethodsFromStringList( const TQStringList & sl );

  KMServerTest    *mServerTest;
  SmtpWidgets     mSmtp;
  SendmailWidgets mSendmail;
  KMTransportInfo *mTransportInfo;
  enum EncryptionMethods {
    NoEncryption = 0,
    SSL = 1,
    TLS = 2
  };
  enum AuthMethods {
    NoAuth = 0,
    LOGIN = 1,
    PLAIN = 2,
    CRAM_MD5 = 4,
    DIGEST_MD5 = 8,
    NTLM = 16,
    GSSAPI = 32,
    AllAuth = 0xffffffff
  };
  unsigned int mAuthNone, mAuthSSL, mAuthTLS;
};


#endif