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