24 #ifndef __KMAIL_IMAPACCOUNTBASE_H__
25 #define __KMAIL_IMAPACCOUNTBASE_H__
29 #include "networkaccount.h"
32 #include <tqguardedptr.h>
33 #include <tdeio/global.h>
44 template <
typename T>
class TQValueVector;
57 typedef TQValueVector<KMail::ACLListEntry> ACLList;
59 class AttachmentStrategy;
61 class ImapAccountBase :
public KMail::NetworkAccount {
65 ImapAccountBase(
AccountManager * parent,
const TQString & name, uint
id );
67 virtual ~ImapAccountBase();
73 virtual void pseudoAssign(
const KMAccount * a );
77 bool autoExpunge()
const {
return mAutoExpunge; }
78 virtual void setAutoExpunge(
bool expunge );
81 bool hiddenFolders()
const {
return mHiddenFolders; }
82 virtual void setHiddenFolders(
bool show );
85 bool onlySubscribedFolders()
const {
return mOnlySubscribedFolders; }
86 virtual void setOnlySubscribedFolders(
bool show );
89 bool onlyLocallySubscribedFolders()
const {
return mOnlyLocallySubscribedFolders; }
90 virtual void setOnlyLocallySubscribedFolders(
bool show );
94 bool loadOnDemand()
const {
return mLoadOnDemand; }
95 virtual void setLoadOnDemand(
bool load );
98 bool listOnlyOpenFolders()
const {
return mListOnlyOpenFolders; }
99 virtual void setListOnlyOpenFolders(
bool only );
102 virtual TDEIO::MetaData slaveConfig()
const;
104 virtual void readConfig( TDEConfig& config );
105 virtual void writeConfig( TDEConfig& config );
110 enum ConnectionState { Error = 0, Connected, Connecting };
116 ListSubscribedNoCheck,
118 ListFolderOnlySubscribed
127 ConnectionState makeConnection();
130 enum imapNamespace { PersonalNS=0, OtherUsersNS=1, SharedNS=2 };
133 typedef TQMap<imapNamespace, TQStringList> nsMap;
136 typedef TQMap<TQString, TQString> namespaceDelim;
139 typedef TQMap<imapNamespace, namespaceDelim> nsDelimMap;
147 jobData() : url(TQString()), parent(0), current(0), total(1), done(0), offset(0), progressItem(0),
148 onlySubscribed(
false), quiet(
false), cancellable(
false) {}
151 int _total = 1,
int _done = 0,
bool _quiet =
false,
152 bool _cancelable =
false )
153 : url(_url), parent(_parent), current(0), total(_total), done(_done), offset(0),
154 progressItem(0), quiet(_quiet), cancellable(_cancelable) {}
158 TQString curNamespace;
163 TQPtrList<KMMessage> msgList;
164 int total, done, offset;
165 KPIM::ProgressItem *progressItem;
166 bool onlySubscribed, quiet, cancellable;
169 typedef TQMap<TDEIO::Job *, jobData>::Iterator JobIterator;
173 void insertJob( TDEIO::Job* job,
const jobData& data ) {
174 mapJobData.insert( job, data );
179 JobIterator findJob( TDEIO::Job* job ) {
return mapJobData.
find( job ); }
180 JobIterator jobsEnd() {
return mapJobData.end(); }
185 void removeJob( JobIterator& it );
187 void removeJob( TDEIO::Job* job );
196 void changeSubscription(
bool subscribe,
const TQString& imapPath,
bool quiet =
false );
202 bool locallySubscribedTo(
const TQString& imapPath );
208 void changeLocalSubscription(
const TQString& imapPath,
bool subscribe );
230 void getStorageQuotaInfo(
KMFolder* folder,
const TQString& imapPath );
236 void setImapStatus(
KMFolder* folder,
const TQString& path,
const TQCString& flags );
242 void setImapSeenStatus(
KMFolder* folder,
const TQString& path,
bool seen );
247 void slaveDied() { mSlave = 0; killAllJobs(); }
252 void killAllJobs(
bool disconnectSlave=
false ) = 0;
257 virtual void cancelMailCheck();
262 enum FolderListType { Single, Recursive };
263 void processNewMailInFolder(
KMFolder* folder, FolderListType type = Single );
268 bool checkingSingleFolder() {
return mCheckingSingleFolder; }
274 void postProcessNewMail(
bool setStatusMsg =
true );
280 bool checkingMail(
KMFolder *folder );
282 bool checkingMail() {
return NetworkAccount::checkingMail(); }
287 void handleBodyStructure( TQDataStream & stream,
KMMessage * msg,
288 const AttachmentStrategy *as );
293 virtual void setFolder(
KMFolder*,
bool addAccount =
false);
299 bool hasACLSupport()
const {
return mACLSupport; }
305 bool hasAnnotationSupport()
const {
return mAnnotationSupport; }
310 void setHasNoAnnotationSupport() { mAnnotationSupport =
false; }
316 bool hasQuotaSupport()
const {
return mQuotaSupport; }
321 void setHasNoQuotaSupport() { mQuotaSupport =
false; }
327 bool handleJobError( TDEIO::Job* job,
const TQString& context,
bool abortSync =
false );
337 KPIM::ProgressItem* listDirProgressItem();
343 virtual unsigned int folderCount()
const;
348 nsMap namespaces()
const {
return mNamespaces; }
353 virtual void setNamespaces( nsMap map )
354 { mNamespaces = map; }
360 nsDelimMap namespacesWithDelimiter();
370 TQString addPathToNamespace(
const TQString& ns );
375 TQString delimiterForNamespace(
const TQString& prefix );
385 namespaceDelim namespaceToDelimiter()
const
386 {
return mNamespaceToDelimiter; }
391 void setNamespaceToDelimiter( namespaceDelim map )
392 { mNamespaceToDelimiter = map; }
397 bool isNamespaceFolder( TQString& name );
402 bool hasCapability(
const TQString& capa ) {
403 return mCapabilities.contains( capa ); }
410 TQString createImapPath(
FolderStorage* parent,
const TQString& folderName );
415 TQString createImapPath(
const TQString& parent,
const TQString& folderName );
423 void getNamespaces();
430 void slotSubscriptionResult(TDEIO::Job * job);
433 virtual void slotCheckQueuedFolders();
436 void slotSchedulerSlaveConnected(TDEIO::Slave *aSlave);
438 void slotSchedulerSlaveError(TDEIO::Slave *aSlave,
int,
const TQString &errorMsg);
443 void slotSetStatusResult(TDEIO::Job * job);
446 void slotGetUserRightsResult( TDEIO::Job* _job );
449 void slotGetACLResult( TDEIO::Job* _job );
452 void slotGetStorageQuotaInfoResult( TDEIO::Job* _job );
457 void slotNoopTimeout();
461 void slotIdleTimeout();
466 void slotAbortRequested( KPIM::ProgressItem* );
471 void slotSimpleResult(TDEIO::Job * job);
474 void slotNamespaceResult( TDEIO::Job*,
const TQString& str );
479 void slotSaveNamespaces(
const ImapAccountBase::nsDelimMap& map );
484 void slotCapabilitiesResult( TDEIO::Job*,
const TQString& result );
504 virtual bool handleError(
int error,
const TQString &errorMsg, TDEIO::Job* job,
const TQString& context,
bool abortSync =
false );
507 bool handlePutError( TDEIO::Job* job, jobData& jd,
KMFolder* folder );
509 virtual TQString protocol()
const;
510 virtual unsigned short int defaultPort()
const;
515 void constructParts( TQDataStream & stream,
int count, KMMessagePart* parentKMPart,
516 DwBodyPart * parent,
const DwMessage * dwmsg );
519 void migratePrefix();
522 TQStringList locallyBlacklistedFolders()
const;
523 void localBlacklistFromStringList(
const TQStringList & );
524 TQString prettifyQuotaError(
const TQString& _error, TDEIO::Job * job );
527 TQPtrList<TQGuardedPtr<KMFolder> > mOpenFolders;
528 TQStringList mSubfolderNames, mSubfolderPaths,
529 mSubfolderMimeTypes, mSubfolderAttributes;
530 TQMap<TDEIO::Job *, jobData> mapJobData;
535 int mTotal, mCountUnread, mCountLastUnread;
536 TQMap<TQString, int> mUnreadBeforeCheck;
537 bool mAutoExpunge : 1;
538 bool mHiddenFolders : 1;
539 bool mOnlySubscribedFolders : 1;
540 bool mOnlyLocallySubscribedFolders : 1;
541 bool mLoadOnDemand : 1;
542 bool mListOnlyOpenFolders : 1;
543 bool mProgressEnabled : 1;
545 bool mErrorDialogIsActive : 1;
546 bool mPasswordDialogIsActive : 1;
547 bool mACLSupport : 1;
548 bool mAnnotationSupport : 1;
549 bool mQuotaSupport : 1;
550 bool mSlaveConnected : 1;
551 bool mSlaveConnectionError : 1;
552 bool mCheckingSingleFolder : 1;
555 TQValueList<TQGuardedPtr<KMFolder> > mMailCheckFolders;
557 TQValueList<TQGuardedPtr<KMFolder> > mFoldersQueuedForChecking;
559 TQPtrList<KMMessagePart> mBodyPartList;
563 TQGuardedPtr<KPIM::ProgressItem> mListDirProgressItem;
569 namespaceDelim mNamespaceToDelimiter;
575 TQStringList mCapabilities;
577 std::set<TQString> mLocalSubscriptionBlackList;
586 void connectionResult(
int errorCode,
const TQString& errorMsg );
592 void subscriptionChanged(
const TQString& imapPath,
bool subscribed);
598 void subscriptionChangeFailed(
const TQString &errorMessage );
605 void imapStatusChanged(
KMFolder*,
const TQString& imapPath,
bool cont );
613 void receivedUserRights(
KMFolder* folder );
622 void receivedACL(
KMFolder* folder, TDEIO::Job* job,
const KMail::ACLList& entries );
632 void receivedStorageQuotaInfo(
KMFolder* folder, TDEIO::Job* job,
const KMail::QuotaInfo& entries );
637 void namespacesFetched(
const ImapAccountBase::nsDelimMap& );
642 void namespacesFetched();
The FolderStorage class is the bass class for the storage related aspects of a collection of mail (a ...
int find(const KMMsgBase *msg) const
Returns the index of the given message or -1 if not found.
The account manager is responsible for creating accounts of various types via the factory method crea...
GetUserRightsJob * getUserRights(TDEIO::Slave *slave, const KURL &url)
Get the users' rights for a given url.
GetACLJob * getACL(TDEIO::Slave *slave, const KURL &url)
List all ACLs for a given url.