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 <QPointer>
00042 #include <QMap>
00043 #include <QList>
00044 #include <QHash>
00045
00046 #include <kurl.h>
00047
00048 #include <kfoldertree.h>
00049 using KPIM::KFolderTreeItem;
00050 #include "kmfoldertype.h"
00051 #include "groupware_types.h"
00052
00053 class KMFolder;
00054 class KMMessage;
00055 class KMFolderDir;
00056
00057 namespace KMail {
00058
00059
00060 class ExtraFolder {
00061 public:
00062 ExtraFolder( KMFolder* f );
00063 ~ExtraFolder();
00064 QPointer<KMFolder> folder;
00065 };
00066
00067 class Accumulator {
00068 public:
00069 Accumulator( const QString& t, const QString& f, int c )
00070 :type( t ), folder( f ), count( c ) {}
00071
00072 void add( const QString& incidence ) {
00073 incidences << incidence;
00074 count--;
00075 }
00076 bool isFull() { return count == 0; }
00077
00078 const QString type;
00079 const QString folder;
00080 QStringList incidences;
00081 int count;
00082 };
00083
00084 }
00085
00087 class KMailICalIfaceImpl :public QObject {
00088 Q_OBJECT
00089 public:
00090 KMailICalIfaceImpl();
00091 ~KMailICalIfaceImpl();
00092
00101 void registerWithDBus();
00102
00103 bool isWritableFolder( const QString& type, const QString& resource );
00104
00105 KMail::StorageFormat storageFormat( const QString &resource );
00106
00112 quint32 update( const QString& resource,
00113 quint32 sernum,
00114 const QString& subject,
00115 const QString& plainTextBody,
00116 const KMail::CustomHeader::List& customHeaders,
00117 const QStringList& attachmentURLs,
00118 const QStringList& attachmentMimetypes,
00119 const QStringList& attachmentNames,
00120 const QStringList& deletedAttachments );
00121
00122 bool deleteIncidenceKolab( const QString& resource,
00123 quint32 sernum );
00124 int incidencesKolabCount( const QString& mimetype,
00125 const QString& resource );
00126 KMail::SernumDataPair::List incidencesKolab( const QString& mimetype,
00127 const QString& resource,
00128 int startIndex,
00129 int nbMessages );
00130
00131 QList<KMail::SubResource> subresourcesKolab( const QString& contentsType );
00132
00133 bool triggerSync( const QString& contentsType );
00134
00135
00136
00137 QString getAttachment( const QString& resource,
00138 quint32 sernum,
00139 const QString& filename );
00140
00141 QString attachmentMimetype( const QString &resource,
00142 quint32 sernum,
00143 const QString &filename );
00144
00145 QStringList listAttachments( const QString &resource, quint32 sernum );
00146
00147
00148 bool removeSubresource( const QString& );
00149
00150 bool addSubresource( const QString& resource,
00151 const QString& parent,
00152 const QString& contentsType );
00153
00154
00155 void msgRemoved( KMFolder*, KMMessage* );
00156
00158 void initFolders();
00159
00161 void cleanup();
00162
00167 bool isResourceFolder( KMFolder* folder ) const;
00168
00169
00170
00171 bool isStandardResourceFolder( KMFolder* folder ) const;
00172
00177 bool hideResourceFolder( KMFolder* folder ) const;
00178
00184 bool hideResourceAccountRoot( KMFolder* folder ) const;
00185
00190 KFolderTreeItem::Type folderType( KMFolder* folder ) const;
00191
00196 QString folderPixmap( KFolderTreeItem::Type type ) const;
00197
00200 QString folderName( KFolderTreeItem::Type type, int language = -1 ) const;
00201
00203 KMFolder* folderFromType( const QString& type, const QString& folder );
00204
00206 QString icalFolderType( KMFolder* folder ) const;
00207
00209 KMMessage* findMessageByUID( const QString& uid, KMFolder* folder );
00211 static KMMessage* findMessageBySerNum( quint32 serNum, KMFolder* folder );
00212
00214 void deleteMsg( KMMessage* msg );
00215
00216 bool isEnabled() const { return mUseResourceIMAP; }
00217
00219 void folderContentsTypeChanged( KMFolder*, KMail::FolderContentsType );
00220
00222 KMail::StorageFormat storageFormat( KMFolder* folder ) const;
00224 void setStorageFormat( KMFolder* folder, KMail::StorageFormat format );
00225
00226
00227 static const char* annotationForContentsType( KMail::FolderContentsType type );
00228
00229
00230 void folderSynced( KMFolder* folder, const KUrl& folderURL );
00231
00232
00233 void folderDeletedOnServer( const KUrl& folderURL );
00234 void addFolderChange( KMFolder* folder, KMail::FolderChanges changes );
00235
00236
00237 bool isResourceQuiet() const;
00238 void setResourceQuiet(bool q);
00239
00240 public slots:
00241
00242 void readConfig();
00243 void slotFolderRemoved( KMFolder* folder );
00244
00245 void slotIncidenceAdded( KMFolder* folder, quint32 sernum );
00246 void slotIncidenceDeleted( KMFolder* folder, quint32 sernum );
00247 void slotRefresh( const QString& type);
00248
00249
00250
00251 void slotFolderPropertiesChanged( KMFolder* folder );
00252
00253 private slots:
00254 void slotRefreshFolder( KMFolder* );
00255 void slotCheckDone();
00256 void slotFolderLocationChanged( const QString&, const QString& );
00257 void slotFolderRenamed();
00258 void slotMessageRetrieved( KMMessage* );
00259
00260 signals:
00261 void incidenceAdded( const QString& type, const QString& folder,
00262 uint sernum, int format, const QString& entry );
00263 void asyncLoadResult( const QMap<quint32, QString>, const QString& type,
00264 const QString& folder );
00265 void incidenceDeleted( const QString& type, const QString& folder,
00266 const QString& uid );
00267 void signalRefresh( const QString& type, const QString& folder );
00268 void subresourceAdded( const QString& type, const QString& resource,
00269 const QString& label, bool writable, bool alarmRelevant );
00270 void subresourceDeleted( const QString& type, const QString& resource );
00271
00272 private:
00274 KMFolder* initFolder( KMail::FolderContentsType contentsType );
00275 KMFolder* initScalixFolder( KMail::FolderContentsType contentsType );
00276
00277 void connectFolder( KMFolder* folder );
00278
00279 KMFolder* extraFolder( const QString& type, const QString& folder );
00280
00281 void syncFolder( KMFolder* folder ) const;
00282
00283 struct StandardFolderSearchResult
00284 {
00285 enum FoundEnum { FoundAndStandard, NotFound, FoundByType, FoundByName };
00286 StandardFolderSearchResult() : folder( 0 ) {}
00287 StandardFolderSearchResult( KMFolder* f, FoundEnum e ) : folder( f ), found( e ) {}
00288 StandardFolderSearchResult( const QList<KMFolder*> &f, FoundEnum e ) :
00289 folder( f.first() ), folders( f ), found( e ) {}
00290 KMFolder* folder;
00291 QList<KMFolder*> folders;
00292 FoundEnum found;
00293 };
00294
00295 StandardFolderSearchResult findStandardResourceFolder( KMFolderDir* folderParentDir, KMail::FolderContentsType contentsType );
00296 KMFolder* findResourceFolder( const QString& resource );
00297
00298
00299 bool updateAttachment( KMMessage& msg,
00300 const QString& attachmentURL,
00301 const QString& attachmentName,
00302 const QString& attachmentMimetype,
00303 bool lookupByName );
00304 bool deleteAttachment( KMMessage& msg,
00305 const QString& attachmentURL );
00306 quint32 addIncidenceKolab( KMFolder& folder,
00307 const QString& subject,
00308 const QString& plainTextBody,
00309 const KMail::CustomHeader::List& customHeaders,
00310 const QStringList& attachmentURLs,
00311 const QStringList& attachmentNames,
00312 const QStringList& attachmentMimetypes );
00313 static bool kolabXMLFoundAndDecoded( const KMMessage& msg, const QString& mimetype, QString& s );
00314
00315 void handleFolderSynced( KMFolder* folder,
00316 const KUrl& folderURL,
00317 int _changes );
00318 void triggerKolabFreeBusy( const KUrl& folderURL );
00319
00320 KMail::StorageFormat globalStorageFormat() const;
00321
00322 static bool folderIsAlarmRelevant( const KMFolder * );
00323
00324 private:
00325 QPointer<KMFolder> mContacts;
00326 QPointer<KMFolder> mCalendar;
00327 QPointer<KMFolder> mNotes;
00328 QPointer<KMFolder> mTasks;
00329 QPointer<KMFolder> mJournals;
00330
00331
00332
00333 QHash<QString, KMail::ExtraFolder*> mExtraFolders;
00334
00335 QHash<QString, KMail::Accumulator*> mAccumulators;
00336
00337
00338
00339 struct FolderInfo {
00340 FolderInfo() {}
00341 FolderInfo(KMail::StorageFormat f, KMail::FolderChanges c ) :
00342 mStorageFormat( f ), mChanges( c ) {}
00343 KMail::StorageFormat mStorageFormat;
00344 KMail::FolderChanges mChanges;
00345 };
00346
00347 typedef QMap<KMFolder*, FolderInfo> FolderInfoMap;
00348
00349 FolderInfo readFolderInfo( const KMFolder * const folder ) const;
00350
00351 FolderInfoMap mFolderInfoMap;
00352
00353 unsigned int mFolderLanguage;
00354
00355 KMFolderDir* mFolderParentDir;
00356 KMFolder* mFolderParent;
00357 KMFolderType mFolderType;
00358
00359 bool mUseResourceIMAP;
00360 bool mResourceQuiet;
00361 bool mHideFolders;
00362
00363
00364
00365
00366
00367
00368
00369 QMap<QString, quint32> mUIDToSerNum;
00370 QMap<quint32, bool> mTheUnGetMes;
00371 QMap<QString, QString> mPendingUpdates;
00372 QMap<QString, bool> mInTransit;
00373
00374 };
00375
00376 #endif // KMAILICALIFACEIMPL_H