File indexing completed on 2024-05-19 05:17:41
0001 /* 0002 Copyright (c) 2009 Kevin Ottens <ervin@kde.org> 0003 0004 This library is free software; you can redistribute it and/or modify it 0005 under the terms of the GNU Library General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or (at your 0007 option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, but WITHOUT 0010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0012 License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to the 0016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0017 02110-1301, USA. 0018 */ 0019 0020 #ifndef KIMAP2_IDLEJOB_H 0021 #define KIMAP2_IDLEJOB_H 0022 0023 #include "kimap2_export.h" 0024 0025 #include "imapset.h" 0026 #include "job.h" 0027 0028 #include <kmime/kmime_content.h> 0029 #include <kmime/kmime_message.h> 0030 0031 namespace KIMAP2 0032 { 0033 0034 class Session; 0035 struct Message; 0036 class IdleJobPrivate; 0037 0038 /** 0039 * Idles the connection to the IMAP server. 0040 * 0041 * This job can be run while the client has no other use 0042 * for the connection, and the server will send updates 0043 * about the selected mailbox. 0044 * 0045 * Note that although the server may send a variety of 0046 * responses while the job is running (including EXPUNGE, 0047 * for example), only RECENT and EXISTS responses are 0048 * actually reported by this job. 0049 * 0050 * The job also processes updates in pairs - if the server 0051 * sends an EXISTS update but not a RECENT one (because 0052 * another client is changing the mailbox contents), this 0053 * job will not report the update. 0054 * 0055 * It only makes sense to run this job when the session is 0056 * in the selected state. 0057 * 0058 * This job requires that the server supports the IDLE 0059 * capability, defined in 0060 * <a href="http://www.apps.ietf.org/rfc/rfc2177.html">RFC 2177</a>. 0061 */ 0062 class KIMAP2_EXPORT IdleJob : public Job 0063 { 0064 Q_OBJECT 0065 Q_DECLARE_PRIVATE(IdleJob) 0066 0067 public: 0068 explicit IdleJob(Session *session); 0069 virtual ~IdleJob(); 0070 0071 /** 0072 * The last mailbox status that was reported. 0073 * 0074 * This is just the session's selected mailbox. 0075 */ 0076 QString lastMailBox() const; 0077 /** 0078 * The last message count that was reported. 0079 * 0080 * The server will send updates about the number of 0081 * messages in the mailbox when that number changes. 0082 * This is the last number it reported. 0083 * 0084 * @return the last message count the server reported, 0085 * or -1 if it has not reported a message count 0086 * since the job started. 0087 */ 0088 int lastMessageCount() const; 0089 /** 0090 * The last recent message count that was reported. 0091 * 0092 * The server will send updates about the number of 0093 * messages in the mailbox that are tagged with \Recent 0094 * when that number changes. This is the last number it 0095 * reported. 0096 * 0097 * @return the last recent message count the server reported, 0098 * or -1 if it has not reported a recent message count 0099 * since the job started. 0100 */ 0101 int lastRecentCount() const; 0102 0103 public Q_SLOTS: 0104 /** 0105 * Stops the idle job. 0106 */ 0107 void stop(); 0108 0109 Q_SIGNALS: 0110 /** 0111 * Signals that the server has notified that the total and 0112 * recent message counts have changed. 0113 * 0114 * @param job this object 0115 * @param mailBox the selected mailbox 0116 * @param messageCount the new total message count reported by the server 0117 * @param recentCount the new "recent message" count reported by the server 0118 */ 0119 void mailBoxStats(KIMAP2::IdleJob *job, const QString &mailBox, int messageCount, int recentCount); 0120 0121 /** 0122 * Signals that the server has notified that the some messages flags 0123 * have changed 0124 * 0125 * @param job this object 0126 * @param uid UID of message that has changed 0127 * @since 4.12 0128 */ 0129 void mailBoxMessageFlagsChanged(KIMAP2::IdleJob *job, qint64 uid); 0130 0131 protected: 0132 void doStart() Q_DECL_OVERRIDE; 0133 void handleResponse(const Message &response) Q_DECL_OVERRIDE; 0134 0135 private: 0136 Q_PRIVATE_SLOT(d_func(), void emitStats()) 0137 Q_PRIVATE_SLOT(d_func(), void resetTimeout()) 0138 }; 0139 0140 } 0141 0142 #endif