00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00038 #ifndef KMAILICALIFACEIMPL_H
00039 #define KMAILICALIFACEIMPL_H
00040
00041 #include "kmailicalIface.h"
00042 #include "kmfoldertype.h"
00043 #include <kfoldertree.h>
00044
00045 #include <qdict.h>
00046 #include <qguardedptr.h>
00047 #include <qmap.h>
00048
00049 class KMFolder;
00050 class KMMessage;
00051 class KMFolderDir;
00052 class KMFolderTreeItem;
00053
00054 namespace KMail {
00055
00056
00057 class ExtraFolder {
00058 public:
00059 ExtraFolder( KMFolder* f );
00060 ~ExtraFolder();
00061 QGuardedPtr<KMFolder> folder;
00062 };
00063
00064 class Accumulator {
00065 public:
00066 Accumulator( const QString& t, const QString& f, int c )
00067 :type( t ), folder( f ), count( c ) {}
00068
00069 void add( const QString& incidence ) {
00070 incidences << incidence;
00071 count--;
00072 }
00073 bool isFull() { return count == 0; }
00074
00075 const QString type;
00076 const QString folder;
00077 QStringList incidences;
00078 int count;
00079 };
00080
00081 }
00082
00084 class KMailICalIfaceImpl : public QObject, virtual public KMailICalIface {
00085 Q_OBJECT
00086 public:
00087 KMailICalIfaceImpl();
00088
00089 bool isWritableFolder( const QString& type, const QString& resource );
00090
00091 StorageFormat storageFormat( const QString &resource );
00092
00098 Q_UINT32 update( const QString& resource,
00099 Q_UINT32 sernum,
00100 const QString& subject,
00101 const QString& plainTextBody,
00102 const QMap<QCString, QString>& customHeaders,
00103 const QStringList& attachmentURLs,
00104 const QStringList& attachmentMimetypes,
00105 const QStringList& attachmentNames,
00106 const QStringList& deletedAttachments );
00107
00108 bool deleteIncidenceKolab( const QString& resource,
00109 Q_UINT32 sernum );
00110 int incidencesKolabCount( const QString& mimetype,
00111 const QString& resource );
00112 QMap<Q_UINT32, QString> incidencesKolab( const QString& mimetype,
00113 const QString& resource,
00114 int startIndex,
00115 int nbMessages );
00116 int dimapAccounts();
00117
00118 QValueList<SubResource> subresourcesKolab( const QString& contentsType );
00119
00120 bool triggerSync( const QString& contentsType );
00121
00122
00123
00124 KURL getAttachment( const QString& resource,
00125 Q_UINT32 sernum,
00126 const QString& filename );
00127
00128 QString attachmentMimetype( const QString &resource,
00129 Q_UINT32 sernum,
00130 const QString &filename );
00131
00132 QStringList listAttachments( const QString &resource, Q_UINT32 sernum );
00133
00134
00135 bool removeSubresource( const QString& );
00136
00137 bool addSubresource( const QString& resource,
00138 const QString& parent,
00139 const QString& contentsType );
00140
00141
00142 void msgRemoved( KMFolder*, KMMessage* );
00143
00145 void initFolders();
00146
00148 void cleanup();
00149
00154 bool isResourceFolder( KMFolder* folder ) const;
00155
00156
00157
00158 bool isStandardResourceFolder( KMFolder* folder ) const;
00159
00164 bool hideResourceFolder( KMFolder* folder ) const;
00165
00171 bool hideResourceAccountRoot( KMFolder* folder ) const;
00172
00177 KFolderTreeItem::Type folderType( KMFolder* folder ) const;
00178
00183 QString folderPixmap( KFolderTreeItem::Type type ) const;
00184
00187 QString folderName( KFolderTreeItem::Type type, int language = -1 ) const;
00188
00190 KMFolder* folderFromType( const QString& type, const QString& folder );
00191
00193 QString icalFolderType( KMFolder* folder ) const;
00194
00196 KMMessage* findMessageByUID( const QString& uid, KMFolder* folder );
00198 static KMMessage* findMessageBySerNum( Q_UINT32 serNum, KMFolder* folder );
00199
00201 void deleteMsg( KMMessage* msg );
00202
00203 bool isEnabled() const { return mUseResourceIMAP; }
00204
00206 void folderContentsTypeChanged( KMFolder*, KMail::FolderContentsType );
00207
00209 StorageFormat storageFormat( KMFolder* folder ) const;
00211 void setStorageFormat( KMFolder* folder, StorageFormat format );
00212
00213
00214 static const char* annotationForContentsType( KMail::FolderContentsType type );
00215
00216
00217 void folderSynced( KMFolder* folder, const KURL& folderURL );
00218
00219
00220 void folderDeletedOnServer( const KURL& folderURL );
00221 void addFolderChange( KMFolder* folder, FolderChanges changes );
00222
00223
00224 bool isResourceQuiet() const;
00225 void setResourceQuiet(bool q);
00226
00227 static QMap<QString, QString>* getResourceMap() { return mSubResourceUINamesMap; }
00228
00229 public slots:
00230
00231 void readConfig();
00232 void slotFolderRemoved( KMFolder* folder );
00233
00234 void slotIncidenceAdded( KMFolder* folder, Q_UINT32 sernum );
00235 void slotIncidenceDeleted( KMFolder* folder, Q_UINT32 sernum );
00236 void slotRefresh( const QString& type);
00237
00238
00239
00240 void slotFolderPropertiesChanged( KMFolder* folder );
00241 void changeResourceUIName( const QString &folderPath, const QString &newName );
00242
00243 private slots:
00244 void slotRefreshFolder( KMFolder* );
00245 void slotCheckDone();
00246 void slotFolderLocationChanged( const QString&, const QString& );
00247 void slotFolderRenamed();
00248 void slotMessageRetrieved( KMMessage* );
00249
00250 private:
00252 KMFolder* initFolder( KMail::FolderContentsType contentsType );
00253 KMFolder* initScalixFolder( KMail::FolderContentsType contentsType );
00254
00255 void connectFolder( KMFolder* folder );
00256
00257 KMFolder* extraFolder( const QString& type, const QString& folder );
00258
00259 void syncFolder( KMFolder* folder ) const;
00260
00261 struct StandardFolderSearchResult
00262 {
00263 enum FoundEnum { FoundAndStandard, NotFound, FoundByType, FoundByName };
00264 StandardFolderSearchResult() : folder( 0 ) {}
00265 StandardFolderSearchResult( KMFolder* f, FoundEnum e ) : folder( f ), found( e ) {}
00266 StandardFolderSearchResult( const QValueList<KMFolder*> &f, FoundEnum e ) :
00267 folder( f.first() ), folders( f ), found( e ) {}
00268 KMFolder* folder;
00269 QValueList<KMFolder*> folders;
00270 FoundEnum found;
00271 };
00272
00273 StandardFolderSearchResult findStandardResourceFolder( KMFolderDir* folderParentDir, KMail::FolderContentsType contentsType );
00274 KMFolder* findResourceFolder( const QString& resource );
00275
00276
00277 bool updateAttachment( KMMessage& msg,
00278 const QString& attachmentURL,
00279 const QString& attachmentName,
00280 const QString& attachmentMimetype,
00281 bool lookupByName );
00282 bool deleteAttachment( KMMessage& msg,
00283 const QString& attachmentURL );
00284 Q_UINT32 addIncidenceKolab( KMFolder& folder,
00285 const QString& subject,
00286 const QString& plainTextBody,
00287 const QMap<QCString, QString>& customHeaders,
00288 const QStringList& attachmentURLs,
00289 const QStringList& attachmentNames,
00290 const QStringList& attachmentMimetypes );
00291 static bool kolabXMLFoundAndDecoded( const KMMessage& msg, const QString& mimetype, QString& s );
00292
00293 void handleFolderSynced( KMFolder* folder,
00294 const KURL& folderURL,
00295 int _changes );
00296 void triggerKolabFreeBusy( const KURL& folderURL );
00297
00298 StorageFormat globalStorageFormat() const;
00299
00300 static bool folderIsAlarmRelevant( const KMFolder * );
00301
00302 private:
00303 QGuardedPtr<KMFolder> mContacts;
00304 QGuardedPtr<KMFolder> mCalendar;
00305 QGuardedPtr<KMFolder> mNotes;
00306 QGuardedPtr<KMFolder> mTasks;
00307 QGuardedPtr<KMFolder> mJournals;
00308
00309
00310
00311 QDict<KMail::ExtraFolder> mExtraFolders;
00312
00313 QDict<KMail::Accumulator> mAccumulators;
00314
00315
00316
00317 struct FolderInfo {
00318 FolderInfo() {}
00319 FolderInfo( StorageFormat f, FolderChanges c ) :
00320 mStorageFormat( f ), mChanges( c ) {}
00321 StorageFormat mStorageFormat;
00322 FolderChanges mChanges;
00323 };
00324
00325 typedef QMap<KMFolder*, FolderInfo> FolderInfoMap;
00326
00327 FolderInfo readFolderInfo( const KMFolder * const folder ) const;
00328
00329 FolderInfoMap mFolderInfoMap;
00330
00331 unsigned int mFolderLanguage;
00332
00333 KMFolderDir* mFolderParentDir;
00334 KMFolder* mFolderParent;
00335 KMFolderType mFolderType;
00336
00337 bool mUseResourceIMAP;
00338 bool mResourceQuiet;
00339 bool mHideFolders;
00340
00341
00342
00343
00344
00345
00346
00347 QMap<QString, Q_UINT32> mUIDToSerNum;
00348 QMap<Q_UINT32, bool> mTheUnGetMes;
00349 QMap<QString, QString> mPendingUpdates;
00350 QMap<QString, bool> mInTransit;
00351 static QMap<QString, QString> *mSubResourceUINamesMap;
00352
00353 };
00354
00355 #endif // KMAILICALIFACEIMPL_H