00001
00032
#ifndef kmfoldercachedimap_h
00033
#define kmfoldercachedimap_h
00034
00035
#include <kdialogbase.h>
00036
#include <kstandarddirs.h>
00037
#include <qvaluelist.h>
00038
#include <qvaluevector.h>
00039
#include <qptrlist.h>
00040
#include <qdialog.h>
00041
00042
#include "kmfoldermaildir.h"
00043
#include "kmfolderimap.h"
00044
#include "kmacctimap.h"
00045
#include "kmfoldertype.h"
00046
#include "folderjob.h"
00047
#include "cachedimapjob.h"
00048
00049
using KMail::FolderJob;
00050
class KMAcctCachedImap;
00051
00052
namespace KMail {
00053
class AttachmentStrategy;
00054
struct ACLListEntry;
00055 }
00056
using KMail::AttachmentStrategy;
00057
00058
class DImapTroubleShootDialog :
public KDialogBase
00059 {
00060 Q_OBJECT
00061
public:
00062 DImapTroubleShootDialog(
QWidget* parent=0,
const char* name=0 );
00063
00064
static int run();
00065
00066
private slots:
00067
void slotRebuildIndex();
00068
void slotRebuildCache();
00069
00070
private:
00071
int rc;
00072 };
00073
00074
class KMFolderCachedImap :
public KMFolderMaildir
00075 {
00076 Q_OBJECT
00077
00078
public:
00079
static QString cacheLocation() {
00080
return locateLocal(
"data",
"kmail/dimap" );
00081 }
00082
00086 KMFolderCachedImap(
KMFolder* folder,
const char* name=0);
00087
virtual ~KMFolderCachedImap();
00088
00090
void initializeFrom( KMFolderCachedImap* parent );
00091
00092
virtual void readConfig();
00093
00095
virtual KMFolderType folderType()
const {
return KMFolderTypeCachedImap; }
00096
00098
virtual void remove();
00099
00101
virtual void serverSync(
bool recurse );
00102
00104
void resetSyncState();
00105
00106
void checkUidValidity();
00107
00108
enum imapState { imapNoInformation=0, imapInProgress=1, imapFinished=2 };
00109
00110
virtual imapState getContentState() {
return mContentState; }
00111
virtual void setContentState(imapState state) { mContentState = state; }
00112
00113
virtual imapState getSubfolderState() {
return mSubfolderState; }
00114
virtual void setSubfolderState(imapState state);
00115
00117
void setImapPath(
const QString &path);
00118
QString imapPath()
const {
return mImapPath; }
00119
00121
void setLastUid( ulong uid );
00122 ulong lastUid();
00123
00125 KMMsgBase* findByUID( ulong uid );
00126
00128
void setUidValidity(
const QString &validity) { mUidValidity = validity; }
00129
QString uidValidity()
const {
return mUidValidity; }
00130
00133
void clearUidMap() { uidMap.clear(); }
00134
00136
void setAccount(KMAcctCachedImap *acct);
00137 KMAcctCachedImap* account() const;
00138
00140
QString uidCacheLocation() const;
00141
00143
int readUidCache();
00144
00146
int writeUidCache();
00147
00149
int progress()
const {
return mProgress; }
00150
00151
00152
virtual int rename(
const QString& aName,
KMFolderDir *aParent=0);
00153
00154
00155
virtual KMMessage* take(
int idx);
00156
00157
virtual int addMsg(KMMessage* msg,
int* index_return = 0);
00158
00159
virtual int addMsgInternal(KMMessage* msg,
bool,
int* index_return = 0);
00160
virtual int addMsgKeepUID(KMMessage* msg,
int* index_return = 0) {
00161
return addMsgInternal(msg,
false, index_return);
00162 }
00163
00164
00165
virtual void removeMsg(
int i,
bool imapQuiet = FALSE);
00166
virtual void removeMsg(
QPtrList<KMMessage> msgList,
bool imapQuiet = FALSE)
00167 {
FolderStorage::removeMsg(msgList, imapQuiet); }
00168
00170
bool isReadOnly()
const {
return KMFolderMaildir::isReadOnly() || mReadOnly; }
00171
00175
void sendFolderComplete(
bool success)
00176 { emit folderComplete(
this, success); }
00177
00181
void setSilentUpload(
bool silent ) { mSilentUpload = silent; }
00182
bool silentUpload() {
return mSilentUpload; }
00183
00184
virtual int createIndexFromContents()
00185 {
return KMFolderMaildir::createIndexFromContents(); }
00186
00187
00188
00194
virtual bool listDirectory(
bool secondStep =
false);
00195
00197
KMFolder* trashFolder() const;
00198
00203
int userRights()
const {
return mUserRights; }
00204
00206
void setUserRights(
unsigned int userRights );
00207
00209
typedef QValueVector<KMail::ACLListEntry> ACLList;
00210
const ACLList& aclList()
const {
return mACLList; }
00211
00213
void setACLList(
const ACLList& arr );
00214
00216
void setContentsType( KMail::FolderContentsType type );
00217
00218
00219
virtual void setStatus(
QValueList<int>& ids, KMMsgStatus status,
bool toggle);
00220
00221
protected slots:
00226
void slotListResult(
const QStringList&,
const QStringList&,
00227
const QStringList&,
const QStringList&,
const ImapAccountBase::jobData& );
00228
00229
void slotGetMessagesData(KIO::Job * job,
const QByteArray & data);
00230
void getMessagesResult(KMail::FolderJob *,
bool lastSet);
00231
void slotGetLastMessagesResult(KMail::FolderJob *);
00232
void slotProgress(
unsigned long done,
unsigned long total);
00233
void slotPutProgress(
unsigned long,
unsigned long );
00234
00235
00236
void slotSubFolderComplete(KMFolderCachedImap*,
bool);
00237
00238
00239
void slotConnectionResult(
int errorCode,
const QString& errorMsg );
00240
00241
void slotCheckUidValidityResult( KMail::FolderJob* job );
00242
00243
void slotReceivedUserRights(
KMFolder* );
00244
void slotReceivedACL(
KMFolder*, KIO::Job*,
const KMail::ACLList& );
00245
00246
void slotMultiSetACLResult(KIO::Job *);
00247
void slotACLChanged(
const QString&,
int );
00248
void slotDeleteMessagesResult(KMail::FolderJob *);
00249
void slotImapStatusChanged(
KMFolder* folder,
const QString&,
bool);
00250
00251
protected:
00252
00253
00254
bool deleteMessages();
00255
void listMessages();
00256
void uploadNewMessages();
00257
void uploadFlags();
00258
void createNewFolders();
00259
00260
void listDirectory2();
00261
00262
00265
virtual QValueList<unsigned long> findNewMessages();
00268
virtual QValueList<KMFolderCachedImap*> findNewFolders();
00269
00271
virtual bool canRemoveFolder() const;
00272
00274 virtual FolderJob* doCreateJob( KMMessage *msg, FolderJob::JobType jt,
KMFolder *folder,
00275
QString partSpecifier, const AttachmentStrategy *as ) const;
00276 virtual FolderJob* doCreateJob(
QPtrList<KMMessage>& msgList, const
QString& sets,
00277 FolderJob::JobType jt,
KMFolder *folder ) const;
00278
00279 virtual
void timerEvent(
QTimerEvent* );
00280
00281
00282
void newState(
int progress, const
QString& syncStatus );
00283
00284 public slots:
00288
void slotSimpleData(KIO::Job * job, const
QByteArray & data);
00289
00293
void slotTroubleshoot();
00294
00295 private slots:
00296
void serverSyncInternal();
00297
void slotIncreaseProgress();
00298
void slotUpdateLastUid();
00299
00300 signals:
00301
void folderComplete(KMFolderCachedImap *folder,
bool success);
00302
void listComplete( KMFolderCachedImap* );
00303
00307
void syncState(
int state,
int number );
00308
00309 private:
00310
QString state2String(
int state ) const;
00311
00313 enum {
00314 SYNC_STATE_INITIAL,
00315 SYNC_STATE_PUT_MESSAGES,
00316 SYNC_STATE_UPLOAD_FLAGS,
00317 SYNC_STATE_CREATE_SUBFOLDERS,
00318 SYNC_STATE_LIST_SUBFOLDERS,
00319 SYNC_STATE_LIST_SUBFOLDERS2,
00320 SYNC_STATE_DELETE_SUBFOLDERS,
00321 SYNC_STATE_LIST_MESSAGES,
00322 SYNC_STATE_DELETE_MESSAGES,
00323 SYNC_STATE_EXPUNGE_MESSAGES,
00324 SYNC_STATE_GET_MESSAGES,
00325 SYNC_STATE_HANDLE_INBOX,
00326 SYNC_STATE_GET_USERRIGHTS,
00327 SYNC_STATE_GET_ACLS,
00328 SYNC_STATE_SET_ACLS,
00329 SYNC_STATE_FIND_SUBFOLDERS,
00330 SYNC_STATE_SYNC_SUBFOLDERS,
00331 SYNC_STATE_CHECK_UIDVALIDITY,
00332 SYNC_STATE_RENAME_FOLDER
00333 } mSyncState;
00334
00335
int mProgress;
00336
int mStatusFlagsJobs;
00337
00338
QString mUidValidity;
00339
QString mImapPath;
00340 imapState mContentState, mSubfolderState;
00341
QStringList mSubfolderNames, mSubfolderPaths,
00342 mSubfolderMimeTypes, mSubfolderAttributes;
00343
00344
bool mHasInbox;
00345
bool mIsSelected;
00346
bool mCheckFlags;
00347
bool mReadOnly;
00348
mutable QGuardedPtr<KMAcctCachedImap> mAccount;
00349
00350
QIntDict<int> uidsOnServer;
00351
QValueList<ulong> uidsForDeletionOnServer;
00352
QValueList<KMail::CachedImapJob::MsgForDownload> mMsgsForDownload;
00353
QValueList<ulong> mUidsForDownload;
00354
QStringList foldersForDeletionOnServer;
00355
00356
QValueList<KMFolderCachedImap*> mSubfoldersForSync;
00357 KMFolderCachedImap* mCurrentSubfolder;
00358
00362
QMap<ulong,int> uidMap;
00363
bool uidMapDirty;
00364
void reloadUidMap();
00365
int uidWriteTimer;
00366
00376 ulong mLastUid;
00381 ulong mTentativeHighestUid;
00382
00383
int mUserRights;
00384
ACLList mACLList;
00385
00386
bool mSilentUpload;
00387
bool mFolderRemoved;
00388
00389
bool mRecurse;
00390
bool mCreateInbox;
00391
bool mContentsTypeChanged;
00396
bool mStatusChangedLocally;
00397 };
00398
00399
#endif