kmail Library API Documentation

kmailicalifaceimpl.h

00001 /* 00002 This file is part of KMail. 00003 00004 Copyright (c) 2003 Steffen Hansen <steffen@klaralvdalens-datakonsult.se> 00005 Copyright (c) 2003 - 2004 Bo Thorsen <bo@klaralvdalens-datakonsult.se> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00020 Boston, MA 02111-1307, USA. 00021 00022 In addition, as a special exception, the copyright holders give 00023 permission to link the code of this program with any edition of 00024 the Qt library by Trolltech AS, Norway (or with modified versions 00025 of Qt that use the same license as Qt), and distribute linked 00026 combinations including the two. You must obey the GNU General 00027 Public License in all respects for all of the code used other than 00028 Qt. If you modify this file, you may extend this exception to 00029 your version of the file, but you are not obligated to do so. If 00030 you do not wish to do so, delete this exception statement from 00031 your version. 00032 */ 00033 00034 #ifndef KMAILICALIFACEIMPL_H 00035 #define KMAILICALIFACEIMPL_H 00036 00037 #include "kmailicalIface.h" 00038 #include "kmfoldertype.h" 00039 00040 #include <kfoldertree.h> 00041 00042 #include <qdict.h> 00043 #include <qguardedptr.h> 00044 #include <qmap.h> 00045 00046 class KMFolder; 00047 class KMMessage; 00048 class KMFolderDir; 00049 class KMFolderTreeItem; 00050 00051 namespace { 00052 00053 // Local helper classes 00054 class ExtraFolder { 00055 public: 00056 ExtraFolder( KMFolder* f, KMail::FolderContentsType t ) : folder( f ), type( t ) {} 00057 KMFolder* folder; 00058 KMail::FolderContentsType type; 00059 }; 00060 00061 class Accumulator { 00062 public: 00063 Accumulator( const QString& t, const QString& f, int c ) 00064 :type( t ), folder( f ), count( c ) {} 00065 00066 void add( const QString& incidence ) { 00067 incidences << incidence; 00068 count--; 00069 } 00070 bool isFull() { return count == 0; } 00071 00072 const QString type; 00073 const QString folder; 00074 QStringList incidences; 00075 int count; 00076 }; 00077 00078 } 00079 00080 class KMailICalIfaceImpl : public QObject, virtual public KMailICalIface { 00081 Q_OBJECT 00082 public: 00083 KMailICalIfaceImpl(); 00084 00085 bool addIncidence( const QString& type, const QString& folder, 00086 const QString& uid, const QString& ical ); 00087 bool deleteIncidence( const QString& type, const QString& folder, 00088 const QString& uid ); 00089 QStringList incidences( const QString& type, const QString& folder ); 00090 00091 QStringList subresources( const QString& type ); 00092 00093 bool isWritableFolder( const QString& type, const QString& resource ); 00094 00095 // This saves the iCals/vCards in the entries in the folder. 00096 // The format in the string list is uid, entry, uid, entry... 00097 bool update( const QString& type, const QString& folder, 00098 const QStringList& entries ); 00099 00100 // Update a single entry in the storage layer 00101 bool update( const QString& type, const QString& folder, 00102 const QString& uid, const QString& entry ); 00103 00104 // tell KOrganizer about messages to be deleted 00105 void msgRemoved( KMFolder*, KMMessage* ); 00106 00108 void initFolders(); 00109 00111 void cleanup(); 00112 00117 bool isResourceImapFolder( KMFolder* folder ) const; 00118 00123 bool hideResourceImapFolder( KMFolder* folder ) const; 00124 00129 KFolderTreeItem::Type folderType( KMFolder* folder ) const; 00130 00135 QString folderPixmap( KFolderTreeItem::Type type ) const; 00136 00139 QString folderName( KFolderTreeItem::Type type, int language = -1 ) const; 00140 00142 KMFolder* folderFromType( const QString& type, const QString& folder ); 00143 00145 QString icalFolderType( KMFolder* folder ) const; 00146 00148 KMMessage* findMessageByUID( const QString& uid, KMFolder* folder ); 00149 00151 static void deleteMsg( KMMessage* msg ); 00152 00153 bool isEnabled() const { return mUseResourceIMAP; } 00154 00156 void folderContentsTypeChanged( KMFolder*, KMail::FolderContentsType ); 00157 00158 public slots: 00159 /* (Re-)Read configuration file */ 00160 void readConfig(); 00161 00162 void slotIncidenceAdded( KMFolder* folder, Q_UINT32 sernum ); 00163 void slotIncidenceDeleted( KMFolder* folder, Q_UINT32 sernum ); 00164 void slotRefresh( const QString& type); 00165 00166 private slots: 00167 void slotRefreshCalendar(); 00168 void slotRefreshTasks(); 00169 void slotRefreshJournals(); 00170 void slotRefreshContacts(); 00171 void slotRefreshNotes(); 00172 00173 void slotCheckDone(); 00174 void slotMessageRetrieved( KMMessage* ); 00175 00176 private: 00178 KMFolder* initFolder( KFolderTreeItem::Type itemType, const char* typeString ); 00179 00180 KMFolder* extraFolder( const QString& type, const QString& folder ); 00181 00182 void loadPixmaps() const; 00183 00184 QGuardedPtr<KMFolder> mContacts; 00185 QGuardedPtr<KMFolder> mCalendar; 00186 QGuardedPtr<KMFolder> mNotes; 00187 QGuardedPtr<KMFolder> mTasks; 00188 QGuardedPtr<KMFolder> mJournals; 00189 00190 // The extra IMAP resource folders 00191 QDict<ExtraFolder> mExtraFolders; 00192 00193 // used for collecting incidences during async loading 00194 QDict<Accumulator> mAccumulators; 00195 00196 unsigned int mFolderLanguage; 00197 00198 KMFolderDir* mFolderParentDir; 00199 KMFolder* mFolderParent; 00200 KMFolderType mFolderType; 00201 00202 // groupware folder icons: 00203 static QPixmap *pixContacts, *pixCalendar, *pixNotes, *pixTasks, *pixJournals; 00204 00205 bool mUseResourceIMAP; 00206 bool mHideFolders; 00207 00208 /* 00209 * Bunch of maps to keep track of incidents currently in transfer, ones 00210 * which need to be ungotten, once we are done, once with updates pending. 00211 * Since these are transient attributes of only a small but changing number 00212 * of incidences they are not encapsulated in a struct or somesuch. 00213 */ 00214 QMap<QString, Q_UINT32> mUIDToSerNum; 00215 QMap<Q_UINT32, bool> mTheUnGetMes; 00216 QMap<QString, QString> mPendingUpdates; 00217 QMap<QString, bool> mInTransit; 00218 00219 }; 00220 00221 #endif // KMAILICALIFACEIMPL_H
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:46 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003