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
00117 QValueList<SubResource> subresourcesKolab( const QString& contentsType );
00118
00119 bool triggerSync( const QString& contentsType );
00120
00121
00122
00123 KURL getAttachment( const QString& resource,
00124 Q_UINT32 sernum,
00125 const QString& filename );
00126
00127 QStringList listAttachments( const QString &resource, Q_UINT32 sernum );
00128
00129
00130 bool removeSubresource( const QString& );
00131
00132 bool addSubresource( const QString& resource,
00133 const QString& parent,
00134 const QString& contentsType );
00135
00136
00137 void msgRemoved( KMFolder*, KMMessage* );
00138
00140 void initFolders();
00141
00143 void cleanup();
00144
00149 bool isResourceFolder( KMFolder* folder ) const;
00150
00151
00152
00153 bool isStandardResourceFolder( KMFolder* folder ) const;
00154
00159 bool hideResourceFolder( KMFolder* folder ) const;
00160
00166 bool hideResourceAccountRoot( KMFolder* folder ) const;
00167
00172 KFolderTreeItem::Type folderType( KMFolder* folder ) const;
00173
00178 QString folderPixmap( KFolderTreeItem::Type type ) const;
00179
00182 QString folderName( KFolderTreeItem::Type type, int language = -1 ) const;
00183
00185 KMFolder* folderFromType( const QString& type, const QString& folder );
00186
00188 QString icalFolderType( KMFolder* folder ) const;
00189
00191 KMMessage* findMessageByUID( const QString& uid, KMFolder* folder );
00193 static KMMessage* findMessageBySerNum( Q_UINT32 serNum, KMFolder* folder );
00194
00196 void deleteMsg( KMMessage* msg );
00197
00198 bool isEnabled() const { return mUseResourceIMAP; }
00199
00201 void folderContentsTypeChanged( KMFolder*, KMail::FolderContentsType );
00202
00204 StorageFormat storageFormat( KMFolder* folder ) const;
00206 void setStorageFormat( KMFolder* folder, StorageFormat format );
00207
00208
00209 static const char* annotationForContentsType( KMail::FolderContentsType type );
00210
00211
00212 void folderSynced( KMFolder* folder, const KURL& folderURL );
00213
00214
00215 void folderDeletedOnServer( const KURL& folderURL );
00216 void addFolderChange( KMFolder* folder, FolderChanges changes );
00217
00218
00219 bool isResourceQuiet() const;
00220 void setResourceQuiet(bool q);
00221
00222 public slots:
00223
00224 void readConfig();
00225 void slotFolderRemoved( KMFolder* folder );
00226
00227 void slotIncidenceAdded( KMFolder* folder, Q_UINT32 sernum );
00228 void slotIncidenceDeleted( KMFolder* folder, Q_UINT32 sernum );
00229 void slotRefresh( const QString& type);
00230
00231
00232
00233 void slotFolderPropertiesChanged( KMFolder* folder );
00234
00235 private slots:
00236 void slotRefreshFolder( KMFolder* );
00237 void slotCheckDone();
00238 void slotFolderLocationChanged( const QString&, const QString& );
00239 void slotFolderRenamed();
00240 void slotMessageRetrieved( KMMessage* );
00241
00242 private:
00244 KMFolder* initFolder( KMail::FolderContentsType contentsType );
00245 KMFolder* initScalixFolder( KMail::FolderContentsType contentsType );
00246
00247 void connectFolder( KMFolder* folder );
00248
00249 KMFolder* extraFolder( const QString& type, const QString& folder );
00250
00251 struct StandardFolderSearchResult
00252 {
00253 enum FoundEnum { FoundAndStandard, NotFound, FoundByType, FoundByName };
00254 StandardFolderSearchResult() : folder( 0 ) {}
00255 StandardFolderSearchResult( KMFolder* f, FoundEnum e ) : folder( f ), found( e ) {}
00256 KMFolder* folder;
00257 FoundEnum found;
00258 };
00259
00260 StandardFolderSearchResult findStandardResourceFolder( KMFolderDir* folderParentDir, KMail::FolderContentsType contentsType );
00261 KMFolder* findResourceFolder( const QString& resource );
00262
00263
00264 bool updateAttachment( KMMessage& msg,
00265 const QString& attachmentURL,
00266 const QString& attachmentName,
00267 const QString& attachmentMimetype,
00268 bool lookupByName );
00269 bool deleteAttachment( KMMessage& msg,
00270 const QString& attachmentURL );
00271 Q_UINT32 addIncidenceKolab( KMFolder& folder,
00272 const QString& subject,
00273 const QString& plainTextBody,
00274 const QMap<QCString, QString>& customHeaders,
00275 const QStringList& attachmentURLs,
00276 const QStringList& attachmentNames,
00277 const QStringList& attachmentMimetypes );
00278 static bool kolabXMLFoundAndDecoded( const KMMessage& msg, const QString& mimetype, QString& s );
00279
00280 void handleFolderSynced( KMFolder* folder,
00281 const KURL& folderURL,
00282 int _changes );
00283 void triggerKolabFreeBusy( const KURL& folderURL );
00284
00285 StorageFormat globalStorageFormat() const;
00286
00287 static bool folderIsAlarmRelevant( const KMFolder * );
00288
00289 private:
00290 QGuardedPtr<KMFolder> mContacts;
00291 QGuardedPtr<KMFolder> mCalendar;
00292 QGuardedPtr<KMFolder> mNotes;
00293 QGuardedPtr<KMFolder> mTasks;
00294 QGuardedPtr<KMFolder> mJournals;
00295
00296
00297
00298 QDict<KMail::ExtraFolder> mExtraFolders;
00299
00300 QDict<KMail::Accumulator> mAccumulators;
00301
00302
00303
00304 struct FolderInfo {
00305 FolderInfo() {}
00306 FolderInfo( StorageFormat f, FolderChanges c ) :
00307 mStorageFormat( f ), mChanges( c ) {}
00308 StorageFormat mStorageFormat;
00309 FolderChanges mChanges;
00310 };
00311
00312 typedef QMap<KMFolder*, FolderInfo> FolderInfoMap;
00313
00314 FolderInfo readFolderInfo( const KMFolder * const folder ) const;
00315
00316 FolderInfoMap mFolderInfoMap;
00317
00318 unsigned int mFolderLanguage;
00319
00320 KMFolderDir* mFolderParentDir;
00321 KMFolder* mFolderParent;
00322 KMFolderType mFolderType;
00323
00324 bool mUseResourceIMAP;
00325 bool mResourceQuiet;
00326 bool mHideFolders;
00327
00328
00329
00330
00331
00332
00333
00334 QMap<QString, Q_UINT32> mUIDToSerNum;
00335 QMap<Q_UINT32, bool> mTheUnGetMes;
00336 QMap<QString, QString> mPendingUpdates;
00337 QMap<QString, bool> mInTransit;
00338
00339 };
00340
00341 #endif // KMAILICALIFACEIMPL_H