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
|
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Messaging Framework.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef IMAPCLIENT_H
#define IMAPCLIENT_H
#include "imapprotocol.h"
#include "qtimer.h"
#include <qstring.h>
#include <qstringlist.h>
#include <qobject.h>
#include <qlist.h>
#include <qtimer.h>
#include <qmailaccountconfiguration.h>
#include <qmailfolder.h>
#include <qmailmessage.h>
#include <qmailmessageclassifier.h>
#include <qmailmessageserver.h>
class ImapStrategy;
class ImapStrategyContext;
class IdleProtocol;
class QMailMessageBufferFlushCallback;
class ImapClient : public QObject
{
Q_OBJECT
public:
ImapClient(QObject* parent);
~ImapClient();
void setAccount(const QMailAccountId& accountId);
QMailAccountId account() const;
void requestRapidClose() { _requestRapidClose = true; } // Close connection ASAP, unless interactive checking occurred recently
void newConnection();
void cancelTransfer(QMailServiceAction::Status::ErrorCode code, const QString &text);
void closeConnection();
ImapStrategyContext *strategyContext();
ImapStrategy *strategy() const;
void setStrategy(ImapStrategy *strategy);
QMailFolderId mailboxId(const QString &path) const;
QMailFolderIdList mailboxIds() const;
QStringList serverUids(const QMailFolderId &folderId) const;
QStringList serverUids(const QMailFolderId &folderId, quint64 messageStatusFilter, bool set = true) const;
QStringList serverUids(QMailMessageKey key) const;
QMailMessageKey messagesKey(const QMailFolderId &folderId) const;
QMailMessageKey trashKey(const QMailFolderId &folderId) const;
QStringList deletedMessages(const QMailFolderId &folderId) const;
bool idlesEstablished();
void idling(const QMailFolderId &id);
QMailFolderIdList configurationIdleFolderIds();
void monitor(const QMailFolderIdList &mailboxIds);
void removeAllFromBuffer(QMailMessage *message);
signals:
void errorOccurred(int, const QString &);
void errorOccurred(QMailServiceAction::Status::ErrorCode, const QString &);
void updateStatus(const QString &);
void restartPushEmail();
void progressChanged(uint, uint);
void retrievalCompleted();
void messageCopyCompleted(QMailMessage &message, const QMailMessage &original);
void messageActionCompleted(const QString &uid);
void matchingMessageIds(const QMailMessageIdList &messages);
void remainingMessagesCount(uint);
void messagesCount(uint);
void allMessagesReceived();
void idleNewMailNotification(QMailFolderId);
void idleFlagsChangedNotification(QMailFolderId);
public slots:
void transportError(int, const QString &msg);
void transportError(QMailServiceAction::Status::ErrorCode, const QString &msg);
void mailboxListed(const QString &, const QString &);
void messageFetched(QMailMessage& mail, const QString &detachedFilename, bool structureOnly);
void dataFetched(const QString &uid, const QString §ion, const QString &fileName, int size);
void nonexistentUid(const QString &uid);
void messageStored(const QString &);
void messageCopied(const QString &, const QString &);
void messageCreated(const QMailMessageId &, const QString &);
void downloadSize(const QString &uid, int);
void urlAuthorized(const QString &url);
void folderDeleted(const QMailFolder &folder);
void folderCreated(const QString &folder);
void folderRenamed(const QMailFolder &folder, const QString &newName);
protected slots:
void connectionInactive();
void commandCompleted(const ImapCommand, const OperationStatus);
void checkCommandResponse(const ImapCommand, const OperationStatus);
void commandTransition(const ImapCommand, const OperationStatus);
void transportStatus(const QString& status);
void idleOpenRequested(IdleProtocol*);
void messageBufferFlushed();
private:
friend class ImapStrategyContextBase;
void deactivateConnection();
void retrieveOperationCompleted();
void operationFailed(int code, const QString &text);
void operationFailed(QMailServiceAction::Status::ErrorCode code, const QString &text);
void updateFolderCountStatus(QMailFolder *folder);
static const int MaxTimeBeforeNoop = 60 * 1000; // 1 minute (this must be >= 1ms)
QMailAccountConfiguration _config;
ImapProtocol _protocol;
QTimer _inactiveTimer;
int _closeCount;
bool _waitingForIdle;
QMailFolderIdList _waitingForIdleFolderIds;
bool _idlesEstablished;
bool _qresyncEnabled;
bool _requestRapidClose;
bool _rapidClosing;
QMailMessageClassifier _classifier;
ImapStrategyContext *_strategyContext;
QMap<QMailFolderId, IdleProtocol*> _monitored;
QList<QMailMessageBufferFlushCallback*> callbacks;
QVector<QMailMessage*> _bufferedMessages;
};
#endif
|