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