summaryrefslogtreecommitdiffstats
path: root/kmail/kmacctimap.h
blob: 6be22c010caf2cf779a4e4fb8285e6237fdc7590 (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
/*
 * kmacctimap.h
 *
 * Copyright (c) 2000-2002 Michael Haeckel <haeckel@kde.org>
 *
 * This file is based on popaccount.h by Don Sanders
 *
 *  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; version 2 of the License
 *
 *  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 KMAcctImap_h
#define KMAcctImap_h

#include "imapaccountbase.h"
#include <tqdict.h>

class KMFolderImap;
class KMFolderTreeItem;
namespace KMail {
  class ImapJob;
  class ActionScheduler;
}
namespace TDEIO {
  class Job;
}
class FolderStorage;

//-----------------------------------------------------------------------------
class KMAcctImap: public KMail::ImapAccountBase
{
  Q_OBJECT
  
  friend class KMail::ImapJob;

public:
  virtual ~KMAcctImap();

  /** A weak assignment operator */
  virtual void pseudoAssign( const KMAccount * a );

  /**
   * Inherited methods.
   */
  virtual TQString type(void) const;
  virtual void processNewMail(bool);
  ConnectionState makeConnection();

  /**
   * Kill all jobs related the the specified folder/msg
   */
  virtual void ignoreJobsForMessage( KMMessage * msg );
  virtual void ignoreJobsForFolder( KMFolder * folder );
  virtual void removeSlaveJobsForFolder( KMFolder * folder );

  /**
   * Kill the slave if any jobs are active
   */
  virtual void killAllJobs( bool disconnectSlave=false );

  /**
   * Set the top level pseudo folder
   */
  virtual void setImapFolder(KMFolderImap *);

  /**
   * Starts the folderlisting for the root folder
   */
  virtual void listDirectory();

  /**
   * Read config file entries. This method is called by the account
   * manager when a new account is created. The config group is
   * already properly set by the caller.
   */
  virtual void readConfig(TDEConfig& config);

  /**
   * Returns the root folder of this account
   */
  virtual FolderStorage* rootFolder() const;

  /**
   * Queues a message for automatic filtering
   */
  void execFilters(TQ_UINT32 serNum);
    
public slots:
  /**
   * updates the new-mail-check folderlist
   */
  void slotFiltered(TQ_UINT32 serNum);
  void slotUpdateFolderList();

protected:
  friend class ::AccountManager;
  KMAcctImap(AccountManager* owner, const TQString& accountName, uint id);
  /**
   * Handle an error coming from a TDEIO job
   * See ImapAccountBase::handleJobError for details.
   */
  virtual bool handleError( int error, const TQString &errorMsg, TDEIO::Job* job, const TQString& context, bool abortSync = false );
  virtual void cancelMailCheck();

  TQPtrList<KMail::ImapJob> mJobList;
  TQGuardedPtr<KMFolderImap> mFolder;

protected slots:
  /** new-mail-notification for the current folder (is called via folderComplete) */
  void postProcessNewMail(KMFolderImap*, bool);
  /**
   * new-mail-notification for not-selected folders (is called via
   * numUnreadMsgsChanged)
   */
  void postProcessNewMail( KMFolder * f );

  /**
   * hooked up to the progress item signaling cancellation.
   * Cleanup and reset state.
   */
  void slotMailCheckCanceled();

  /**
   * called to reset the connection error status
   */
  void slotResetConnectionError();
    
  /**
   * Slots for automatic filtering
   */
  void slotFolderSelected( KMFolderImap*, bool );
  int slotFilterMsg( KMMessage* );

private:
  int mCountRemainChecks;
  /** used to reset connection errors */
  TQTimer mErrorTimer;
  TQValueList<TQ_UINT32> mFilterSerNums;
  TQDict<int> mFilterSerNumsToSave;
  KMail::ActionScheduler *mScheduler;
};

#endif /*KMAcctImap_h*/