summaryrefslogtreecommitdiffstats
path: root/kmail/accountdialog.h
blob: bf79f09680e3bc368d7864a03de0ecdbc3bc5203 (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
/*   -*- c++ -*-
 *   accountdialog.h
 *
 *   kmail: KDE mail client
 *   This file: Copyright (C) 2000 Espen Sand, espen@kde.org
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   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 _ACCOUNT_DIALOG_H_
#define _ACCOUNT_DIALOG_H_

#include <kdialogbase.h>
#include <tdelistview.h>
#include <klineedit.h>
#include <tqguardedptr.h>
#include "imapaccountbase.h"

class TQRegExpValidator;
class TQCheckBox;
class TQComboBox;
class TQPushButton;
class TQLabel;
class TQLineEdit;
class TQRadioButton;
class TQToolButton;
class KIntNumInput;
class KMAccount;
class KMFolder;
class KMServerTest;
class TQButtonGroup;

namespace KPIM {
class IdentityCombo;
}

namespace KMail {

class SieveConfigEditor;
class FolderRequester;

class AccountDialog : public KDialogBase
{
  Q_OBJECT
  

  public:
    AccountDialog( const TQString & caption, KMAccount *account,
		   TQWidget *parent=0, const char *name=0, bool modal=true );
    virtual ~AccountDialog();
  private:
    struct LocalWidgets
    {
      TQLabel       *titleLabel;
      TQLineEdit    *nameEdit;
      TQComboBox    *locationEdit;
      TQRadioButton *lockMutt;
      TQRadioButton *lockMuttPriv;
      TQRadioButton *lockProcmail;
      TQComboBox    *procmailLockFileName;
      TQRadioButton *lockFcntl;
      TQRadioButton *lockNone;
      TQLineEdit    *precommand;
#if 0
      TQCheckBox    *resourceCheck;
      TQPushButton  *resourceClearButton;
      TQPushButton  *resourceClearPastButton;
#endif
      TQCheckBox    *includeInCheck;
      TQCheckBox    *intervalCheck;
      TQLabel       *intervalLabel;
      KIntNumInput *intervalSpin;
      TQComboBox    *folderCombo;
      //TQComboBox    *identityCombo;
      KPIM::IdentityCombo    *identityCombo;
      TQLabel       *identityLabel;
    };

    struct MaildirWidgets
    {
      TQLabel       *titleLabel;
      TQLineEdit    *nameEdit;
      TQComboBox    *locationEdit;
      TQLineEdit    *precommand;
#if 0
      TQCheckBox    *resourceCheck;
      TQPushButton  *resourceClearButton;
      TQPushButton  *resourceClearPastButton;
#endif
      TQCheckBox    *includeInCheck;
      TQCheckBox    *intervalCheck;
      TQLabel       *intervalLabel;
      KIntNumInput *intervalSpin;
      TQComboBox    *folderCombo;
      //TQComboBox    *identityCombo;
      KPIM::IdentityCombo    *identityCombo;
      TQLabel       *identityLabel;
    };

    struct PopWidgets
    {
      TQLabel       *titleLabel;
      TQLineEdit    *nameEdit;
      TQLineEdit    *loginEdit;
      TQLineEdit    *passwordEdit;
      TQLineEdit    *hostEdit;
      TQLineEdit    *portEdit;
      TQLineEdit    *precommand;
      TQButtonGroup *encryptionGroup;
      TQRadioButton *encryptionNone;
      TQRadioButton *encryptionSSL;
      TQRadioButton *encryptionTLS;
      TQButtonGroup *authGroup;
      TQRadioButton *authUser;
      TQRadioButton *authPlain;
      TQRadioButton *authLogin;
      TQRadioButton *authCRAM_MD5;
      TQRadioButton *authDigestMd5;
      TQRadioButton *authNTLM;
      TQRadioButton *authGSSAPI;
      TQRadioButton *authAPOP;

      TQPushButton  *checkCapabilities;
      TQCheckBox    *usePipeliningCheck;
      TQCheckBox    *storePasswordCheck;
      TQCheckBox    *leaveOnServerCheck;
      TQCheckBox    *leaveOnServerDaysCheck;
      KIntNumInput *leaveOnServerDaysSpin;
      TQCheckBox    *leaveOnServerCountCheck;
      KIntNumInput *leaveOnServerCountSpin;
      TQCheckBox    *leaveOnServerSizeCheck;
      KIntNumInput *leaveOnServerSizeSpin;
#if 0
      TQCheckBox    *resourceCheck;
      TQPushButton  *resourceClearButton;
      TQPushButton  *resourceClearPastButton;
#endif
      TQCheckBox    *includeInCheck;
      TQCheckBox    *intervalCheck;
      TQCheckBox    *filterOnServerCheck;
      TQLabel       *intervalLabel;
      KIntNumInput *intervalSpin;
      KIntNumInput *filterOnServerSizeSpin;
      TQComboBox    *folderCombo;
      //TQComboBox    *identityCombo;
      KPIM::IdentityCombo    *identityCombo;
      TQLabel       *identityLabel;
    };

    struct ImapWidgets
    {
      TQLabel       *titleLabel;
      TQLineEdit    *nameEdit;
      TQLineEdit    *loginEdit;
      TQLineEdit    *passwordEdit;
      TQLineEdit    *hostEdit;
      TQLineEdit    *portEdit;
#if 0
      TQCheckBox    *resourceCheck;
      TQPushButton  *resourceClearButton;
      TQPushButton  *resourceClearPastButton;
#endif
      TQCheckBox    *autoExpungeCheck;     // only used by normal (online) IMAP
      TQCheckBox    *hiddenFoldersCheck;
      TQCheckBox    *subscribedFoldersCheck;
      TQCheckBox    *locallySubscribedFoldersCheck;
      TQCheckBox    *loadOnDemandCheck;
      TQCheckBox    *storePasswordCheck;
      TQCheckBox    *progressDialogCheck;  // only used by Disconnected IMAP
      TQCheckBox    *includeInCheck;
      TQCheckBox    *intervalCheck;
      TQCheckBox    *listOnlyOpenCheck;
      TQLabel       *intervalLabel;
      KIntNumInput *intervalSpin;
      TQButtonGroup *encryptionGroup;
      TQRadioButton *encryptionNone;
      TQRadioButton *encryptionSSL;
      TQRadioButton *encryptionTLS;
      TQButtonGroup *authGroup;
      TQRadioButton *authUser;
      TQRadioButton *authPlain;
      TQRadioButton *authLogin;
      TQRadioButton *authCramMd5;
      TQRadioButton *authDigestMd5;
      TQRadioButton *authGSSAPI;
      TQRadioButton *authNTLM;
      TQRadioButton *authAnonymous;
      TQPushButton  *checkCapabilities;
      FolderRequester *trashCombo;
      KLineEdit    *personalNS;
      KLineEdit    *otherUsersNS;
      KLineEdit    *sharedNS;
      TQToolButton  *editPNS;
      TQToolButton  *editONS;
      TQToolButton  *editSNS;
      ImapAccountBase::nsDelimMap nsMap;
      KPIM::IdentityCombo    *identityCombo;
      TQLabel       *identityLabel;
    };

  private slots:
    virtual void slotOk();
    void slotLocationChooser();
    void slotMaildirChooser();
    void slotEnablePopInterval( bool state );
    void slotEnableImapInterval( bool state );
    void slotEnableLocalInterval( bool state );
    void slotEnableMaildirInterval( bool state );
    void slotFontChanged();
    void slotLeaveOnServerClicked();
    void slotEnableLeaveOnServerDays( bool state );
    void slotEnableLeaveOnServerCount( bool state );
    void slotEnableLeaveOnServerSize( bool state );
    void slotFilterOnServerClicked();
    void slotPipeliningClicked();
    void slotPopEncryptionChanged(int);
    void slotImapEncryptionChanged(int);
    void slotCheckPopCapabilities();
    void slotCheckImapCapabilities();
    void slotPopCapabilities( const TQStringList &, const TQStringList & );
    void slotImapCapabilities( const TQStringList &, const TQStringList & );
    void slotReloadNamespaces();
    void slotSetupNamespaces( const ImapAccountBase::nsDelimMap& map );
    void slotEditPersonalNamespace();
    void slotEditOtherUsersNamespace();
    void slotEditSharedNamespace();
    void slotConnectionResult( int errorCode, const TQString& );
    void slotLeaveOnServerDaysChanged( int value );
    void slotLeaveOnServerCountChanged( int value );
    void slotFilterOnServerSizeChanged( int value );
#if 0
    // Moc doesn't understand #if 0, so they are also commented out
    // void slotClearResourceAllocations();
    // void slotClearPastResourceAllocations();
#endif

  private:
    void makeLocalAccountPage();
    void makeMaildirAccountPage();
    void makePopAccountPage();
    void makeImapAccountPage( bool disconnected = false );
    void setupSettings();
    void saveSettings();
    void checkHighest( TQButtonGroup * );
    static unsigned int popCapabilitiesFromStringList( const TQStringList & );
    static unsigned int imapCapabilitiesFromStringList( const TQStringList & );
    void enablePopFeatures( unsigned int );
    void enableImapAuthMethods( unsigned int );
    void initAccountForConnect();
    const TQString namespaceListToString( const TQStringList& list );

  private:
    LocalWidgets mLocal;
    MaildirWidgets mMaildir;
    PopWidgets   mPop;
    ImapWidgets  mImap;
    KMAccount    *mAccount;
    TQValueList<TQGuardedPtr<KMFolder> > mFolderList;
    TQStringList  mFolderNames;
    KMServerTest *mServerTest;
    enum EncryptionMethods {
      NoEncryption = 0,
      SSL = 1,
      TLS = 2
    };
    enum Capabilities {
      Plain      =   1,
      Login      =   2,
      CRAM_MD5   =   4,
      Digest_MD5 =   8,
      Anonymous  =  16,
      APOP       =  32,
      Pipelining =  64,
      TOP        = 128,
      UIDL       = 256,
      STLS       = 512, // TLS for POP
      STARTTLS   = 512, // TLS for IMAP
      GSSAPI     = 1024,
      NTLM       = 2048,
      AllCapa    = 0xffffffff
    };
    unsigned int mCurCapa;
    unsigned int mCapaNormal;
    unsigned int mCapaSSL;
    unsigned int mCapaTLS;
    KMail::SieveConfigEditor *mSieveConfigEditor;
    TQRegExpValidator *mValidator;
};

class NamespaceLineEdit: public KLineEdit
{
  Q_OBJECT
  

  public:
    NamespaceLineEdit( TQWidget* parent );

    const TQString& lastText() { return mLastText; }

  public slots:
    virtual void setText ( const TQString & );

  private:
    TQString mLastText;
};

class NamespaceEditDialog: public KDialogBase
{
  Q_OBJECT
  

  public:
    NamespaceEditDialog( TQWidget* parent, ImapAccountBase::imapNamespace type,
        ImapAccountBase::nsDelimMap* map );

  protected slots:
    void slotOk();
    void slotRemoveEntry( int );

  private:
    ImapAccountBase::imapNamespace mType;
    ImapAccountBase::nsDelimMap* mNamespaceMap;
    ImapAccountBase::namespaceDelim mDelimMap;
    TQMap<int, NamespaceLineEdit*> mLineEditMap;
    TQButtonGroup* mBg;
};

} // namespace KMail

#endif