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 ) : folder( f ) {}
00060 QGuardedPtr<KMFolder> folder;
00061 };
00062
00063 class Accumulator {
00064 public:
00065 Accumulator( const QString& t, const QString& f, int c )
00066 :type( t ), folder( f ), count( c ) {}
00067
00068 void add( const QString& incidence ) {
00069 incidences << incidence;
00070 count--;
00071 }
00072 bool isFull() { return count == 0; }
00073
00074 const QString type;
00075 const QString folder;
00076 QStringList incidences;
00077 int count;
00078 };
00079
00080 }
00081
00083 class KMailICalIfaceImpl : public QObject, virtual public KMailICalIface {
00084 Q_OBJECT
00085 public:
00086 KMailICalIfaceImpl();
00087
00088 bool isWritableFolder( const QString& type, const QString& resource );
00089
00090 StorageFormat storageFormat( const QString &resource );
00091
00097 Q_UINT32 update( const QString& resource,
00098 Q_UINT32 sernum,
00099 const QString& subject,
00100 const QString& plainTextBody,
00101 const QMap<QCString, QString>& customHeaders,
00102 const QStringList& attachmentURLs,
00103 const QStringList& attachmentMimetypes,
00104 const QStringList& attachmentNames,
00105 const QStringList& deletedAttachments );
00106
00107 bool deleteIncidenceKolab( const QString& resource,
00108 Q_UINT32 sernum );
00109 int incidencesKolabCount( const QString& mimetype,
00110 const QString& resource );
00111 QMap<Q_UINT32, QString> incidencesKolab( const QString& mimetype,
00112 const QString& resource,
00113 int startIndex,
00114 int nbMessages );
00115
00116 QValueList<SubResource> subresourcesKolab( const QString& contentsType );
00117
00118 bool triggerSync( const QString& contentsType );
00119
00120
00121
00122 KURL getAttachment( const QString& resource,
00123 Q_UINT32 sernum,
00124 const QString& filename );
00125
00126
00127
00128 void msgRemoved( KMFolder*, KMMessage* );
00129
00131 void initFolders();
00132
00134 void cleanup();
00135
00140 bool isResourceFolder( KMFolder* folder ) const;
00141
00142
00143
00144 bool isStandardResourceFolder( KMFolder* folder ) const;
00145
00150 bool hideResourceFolder( KMFolder* folder ) const;
00151
00157 bool hideResourceAccountRoot( KMFolder* folder ) const;
00158
00163 KFolderTreeItem::Type folderType( KMFolder* folder ) const;
00164
00169 QString folderPixmap( KFolderTreeItem::Type type ) const;
00170
00173 QString folderName( KFolderTreeItem::Type type, int language = -1 ) const;
00174
00176 KMFolder* folderFromType( const QString& type, const QString& folder );
00177
00179 QString icalFolderType( KMFolder* folder ) const;
00180
00182 KMMessage* findMessageByUID( const QString& uid, KMFolder* folder );
00184 static KMMessage* findMessageBySerNum( Q_UINT32 serNum, KMFolder* folder );
00185
00187 void deleteMsg( KMMessage* msg );
00188
00189 bool isEnabled() const { return mUseResourceIMAP; }
00190
00192 void folderContentsTypeChanged( KMFolder*, KMail::FolderContentsType );
00193
00195 StorageFormat storageFormat( KMFolder* folder ) const;
00197 void setStorageFormat( KMFolder* folder, StorageFormat format );
00198
00199
00200 static const char* annotationForContentsType( KMail::FolderContentsType type );
00201
00202
00203 void folderSynced( KMFolder* folder, const KURL& folderURL );
00204
00205
00206 void folderDeletedOnServer( const KURL& folderURL );
00207 void addFolderChange( KMFolder* folder, FolderChanges changes );
00208
00209
00210 bool isResourceQuiet() const;
00211 void setResourceQuiet(bool q);
00212
00213 public slots:
00214
00215 void readConfig();
00216 void slotFolderRemoved( KMFolder* folder );
00217
00218 void slotIncidenceAdded( KMFolder* folder, Q_UINT32 sernum );
00219 void slotIncidenceDeleted( KMFolder* folder, Q_UINT32 sernum );
00220 void slotRefresh( const QString& type);
00221
00222
00223
00224 void slotFolderPropertiesChanged( KMFolder* folder );
00225
00226 private slots:
00227 void slotRefreshFolder( KMFolder* );
00228 void slotCheckDone();
00229 void slotFolderLocationChanged( const QString&, const QString& );
00230 void slotFolderRenamed();
00231 void slotMessageRetrieved( KMMessage* );
00232
00233 private:
00235 KMFolder* initFolder( KMail::FolderContentsType contentsType );
00236
00237 void connectFolder( KMFolder* folder );
00238
00239 KMFolder* extraFolder( const QString& type, const QString& folder );
00240
00241 struct StandardFolderSearchResult
00242 {
00243 enum FoundEnum { FoundAndStandard, NotFound, FoundByType, FoundByName };
00244 StandardFolderSearchResult() : folder( 0 ) {}
00245 StandardFolderSearchResult( KMFolder* f, FoundEnum e ) : folder( f ), found( e ) {}
00246 KMFolder* folder;
00247 FoundEnum found;
00248 };
00249
00250 StandardFolderSearchResult findStandardResourceFolder( KMFolderDir* folderParentDir, KMail::FolderContentsType contentsType );
00251 KMFolder* findResourceFolder( const QString& resource );
00252
00253
00254 bool updateAttachment( KMMessage& msg,
00255 const QString& attachmentURL,
00256 const QString& attachmentName,
00257 const QString& attachmentMimetype,
00258 bool lookupByName );
00259 bool deleteAttachment( KMMessage& msg,
00260 const QString& attachmentURL );
00261 Q_UINT32 addIncidenceKolab( KMFolder& folder,
00262 const QString& subject,
00263 const QString& plainTextBody,
00264 const QMap<QCString, QString>& customHeaders,
00265 const QStringList& attachmentURLs,
00266 const QStringList& attachmentNames,
00267 const QStringList& attachmentMimetypes );
00268 static bool kolabXMLFoundAndDecoded( const KMMessage& msg, const QString& mimetype, QString& s );
00269
00270 void handleFolderSynced( KMFolder* folder,
00271 const KURL& folderURL,
00272 int _changes );
00273 void triggerKolabFreeBusy( const KURL& folderURL );
00274
00275 StorageFormat globalStorageFormat() const;
00276
00277 static bool folderIsAlarmRelevant( const KMFolder * );
00278
00279 private:
00280 QGuardedPtr<KMFolder> mContacts;
00281 QGuardedPtr<KMFolder> mCalendar;
00282 QGuardedPtr<KMFolder> mNotes;
00283 QGuardedPtr<KMFolder> mTasks;
00284 QGuardedPtr<KMFolder> mJournals;
00285
00286
00287
00288 QDict<KMail::ExtraFolder> mExtraFolders;
00289
00290 QDict<KMail::Accumulator> mAccumulators;
00291
00292
00293
00294 struct FolderInfo {
00295 FolderInfo() {}
00296 FolderInfo( StorageFormat f, FolderChanges c ) :
00297 mStorageFormat( f ), mChanges( c ) {}
00298 StorageFormat mStorageFormat;
00299 FolderChanges mChanges;
00300 };
00301
00302 typedef QMap<KMFolder*, FolderInfo> FolderInfoMap;
00303
00304 FolderInfo readFolderInfo( const KMFolder * const folder ) const;
00305
00306 FolderInfoMap mFolderInfoMap;
00307
00308 unsigned int mFolderLanguage;
00309
00310 KMFolderDir* mFolderParentDir;
00311 KMFolder* mFolderParent;
00312 KMFolderType mFolderType;
00313
00314 bool mUseResourceIMAP;
00315 bool mResourceQuiet;
00316 bool mHideFolders;
00317
00318
00319
00320
00321
00322
00323
00324 QMap<QString, Q_UINT32> mUIDToSerNum;
00325 QMap<Q_UINT32, bool> mTheUnGetMes;
00326 QMap<QString, QString> mPendingUpdates;
00327 QMap<QString, bool> mInTransit;
00328
00329 };
00330
00331 #endif // KMAILICALIFACEIMPL_H