20 #include "selectjob.h"
22 #include <KDE/KLocalizedString>
26 #include "message_p.h"
27 #include "session_p.h"
32 class SelectJobPrivate :
public JobPrivate
35 SelectJobPrivate( Session *session,
const QString& name )
36 : JobPrivate( session, name ), readOnly( false ), messageCount( -1 ), recentCount( -1 ),
37 firstUnseenIndex( -1 ), uidValidity( -1 ), nextUid( -1 ), highestmodseq( 0 ),
38 condstoreEnabled( false ) { }
39 ~SelectJobPrivate() { }
51 quint64 highestmodseq;
52 bool condstoreEnabled;
56 using namespace KIMAP;
58 SelectJob::SelectJob( Session *session )
59 : Job( *new SelectJobPrivate( session, i18nc(
"name of the select job",
"Select" ) ) )
63 SelectJob::~SelectJob()
67 void SelectJob::setMailBox(
const QString &mailBox )
73 QString SelectJob::mailBox()
const
75 Q_D(
const SelectJob );
79 void SelectJob::setOpenReadOnly(
bool readOnly )
82 d->readOnly = readOnly;
85 bool SelectJob::isOpenReadOnly()
const
87 Q_D(
const SelectJob );
93 Q_D(
const SelectJob );
99 Q_D(
const SelectJob );
100 return d->permanentFlags;
103 int SelectJob::messageCount()
const
105 Q_D(
const SelectJob );
106 return d->messageCount;
109 int SelectJob::recentCount()
const
111 Q_D(
const SelectJob );
112 return d->recentCount;
115 int SelectJob::firstUnseenIndex()
const
117 Q_D(
const SelectJob );
118 return d->firstUnseenIndex;
121 qint64 SelectJob::uidValidity()
const
123 Q_D(
const SelectJob );
124 return d->uidValidity;
127 qint64 SelectJob::nextUid()
const
129 Q_D(
const SelectJob );
133 quint64 SelectJob::highestModSequence()
const
135 Q_D(
const SelectJob );
136 return d->highestmodseq;
139 void SelectJob::setCondstoreEnabled(
bool enable )
142 d->condstoreEnabled = enable;
145 bool SelectJob::condstoreEnabled()
const
147 Q_D(
const SelectJob );
148 return d->condstoreEnabled;
152 void SelectJob::doStart()
161 QByteArray params =
'\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+
'\"';
163 if ( d->condstoreEnabled ) {
164 params +=
" (CONDSTORE)";
167 d->tags << d->sessionInternal()->sendCommand( command, params );
170 void SelectJob::handleResponse(
const Message &response )
174 if ( handleErrorReplies( response ) == NotHandled ) {
175 if ( response.content.size() >= 2 ) {
176 QByteArray code = response.content[1].toString();
178 if ( code ==
"OK" ) {
179 if ( response.responseCode.size() < 2 ) {
183 code = response.responseCode[0].toString();
185 if ( code ==
"PERMANENTFLAGS" ) {
186 d->permanentFlags = response.responseCode[1].toList();
187 }
else if ( code ==
"HIGHESTMODSEQ" ) {
189 quint64 value = response.responseCode[1].toString().
toULongLong( &isInt );
193 d->highestmodseq = value;
196 qint64 value = response.responseCode[1].toString().toLongLong( &isInt );
200 if ( code ==
"UIDVALIDITY" ) {
201 d->uidValidity = value;
202 }
else if ( code ==
"UNSEEN" ) {
203 d->firstUnseenIndex = value;
204 }
else if ( code ==
"UIDNEXT" ) {
208 }
else if ( code ==
"FLAGS" ) {
209 d->flags = response.content[2].toList();
212 int value = response.content[1].toString().toInt( &isInt );
213 if ( !isInt || response.content.size() < 3 ) {
217 code = response.content[2].toString();
218 if ( code ==
"EXISTS" ) {
219 d->messageCount = value;
220 }
else if ( code ==
"RECENT" ) {
221 d->recentCount = value;
225 kDebug() << response.toString();
228 Q_ASSERT( error() || d->m_session->selectedMailBox() == d->mailBox );
This file is part of the IMAP support library and defines the RfcCodecs class.
qulonglong toULongLong(bool *ok, int base) const