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@sonofthor.dk>
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 #include <kfoldertree.h>
00040 
00041 #include <qdict.h>
00042 #include <qguardedptr.h>
00043 #include <qmap.h>
00044 
00045 class KMFolder;
00046 class KMMessage;
00047 class KMFolderDir;
00048 class KMFolderTreeItem;
00049 
00050 namespace {
00051 
00052 // Local helper classes
00053 class ExtraFolder {
00054 public:
00055   ExtraFolder( KMFolder* f, KMail::FolderContentsType t ) : folder( f ), type( t ) {}
00056   KMFolder* folder;
00057   KMail::FolderContentsType type;
00058 };
00059 
00060 class Accumulator {
00061 public:
00062   Accumulator( const QString& t, const QString& f, int c )
00063   :type( t ), folder( f ), count( c ) {}
00064 
00065   void add( const QString& incidence ) {
00066     incidences << incidence;
00067     count--;
00068   }
00069   bool isFull() { return count == 0; }
00070 
00071   const QString type;
00072   const QString folder;
00073   QStringList incidences;
00074   int count;
00075 };
00076 
00077 }
00078 
00079 class KMailICalIfaceImpl : public QObject, virtual public KMailICalIface {
00080   Q_OBJECT
00081 public:
00082   KMailICalIfaceImpl();
00083 
00084   bool addIncidence( const QString& type, const QString& folder,
00085                      const QString& uid, const QString& ical );
00086   bool deleteIncidence( const QString& type, const QString& folder,
00087                         const QString& uid );
00088   QStringList incidences( const QString& type, const QString& folder );
00089 
00090   QStringList subresources( const QString& type );
00091 
00092   bool isWritableFolder( const QString& type, const QString& resource );
00093 
00094   // This saves the iCals/vCards in the entries in the folder.
00095   // The format in the string list is uid, entry, uid, entry...
00096   bool update( const QString& type, const QString& folder,
00097                const QStringList& entries );
00098 
00099   // Update a single entry in the storage layer
00100   bool update( const QString& type, const QString& folder,
00101                const QString& uid, const QString& entry );
00102 
00103   // tell KOrganizer about messages to be deleted
00104   void msgRemoved( KMFolder*, KMMessage* );
00105 
00107   void initFolders();
00108 
00110   void cleanup();
00111 
00116   bool isResourceImapFolder( KMFolder* folder ) const;
00117 
00122   bool hideResourceImapFolder( KMFolder* folder ) const;
00123 
00128   KFolderTreeItem::Type folderType( KMFolder* folder ) const;
00129 
00134   QString folderPixmap( KFolderTreeItem::Type type ) const;
00135 
00138   QString folderName( KFolderTreeItem::Type type, int language = -1 ) const;
00139 
00141   KMFolder* folderFromType( const QString& type, const QString& folder );
00142 
00144   QString icalFolderType( KMFolder* folder ) const;
00145 
00147   KMMessage* findMessageByUID( const QString& uid, KMFolder* folder );
00148 
00150   static void deleteMsg( KMMessage* msg );
00151 
00152   bool isEnabled() const { return mUseResourceIMAP; }
00153 
00155   void folderContentsTypeChanged( KMFolder*, KMail::FolderContentsType );
00156 
00157 public slots:
00158   /* (Re-)Read configuration file */
00159   void readConfig();
00160 
00161   void slotIncidenceAdded( KMFolder* folder, Q_UINT32 sernum );
00162   void slotIncidenceDeleted( KMFolder* folder, Q_UINT32 sernum );
00163   void slotRefresh( const QString& type);
00164 
00165 private slots:
00166   void slotRefreshFolder( KMFolder* folder );
00167   void slotCheckDone();
00168   void slotMessageRetrieved( KMMessage* );
00169 
00170 private:
00172   KMFolder* initFolder( KFolderTreeItem::Type itemType, const char* typeString );
00173 
00174   KMFolder* extraFolder( const QString& type, const QString& folder );
00175 
00176   void loadPixmaps() const;
00177 
00178   QGuardedPtr<KMFolder> mContacts;
00179   QGuardedPtr<KMFolder> mCalendar;
00180   QGuardedPtr<KMFolder> mNotes;
00181   QGuardedPtr<KMFolder> mTasks;
00182   QGuardedPtr<KMFolder> mJournals;
00183 
00184   // The extra IMAP resource folders
00185   QDict<ExtraFolder> mExtraFolders;
00186 
00187   // used for collecting incidences during async loading
00188   QDict<Accumulator> mAccumulators;
00189 
00190   unsigned int mFolderLanguage;
00191 
00192   KMFolderDir* mFolderParentDir;
00193   KMFolder*    mFolderParent;
00194   KMFolderType mFolderType;
00195 
00196   // groupware folder icons:
00197   static QPixmap *pixContacts, *pixCalendar, *pixNotes, *pixTasks, *pixJournals;
00198 
00199   bool mUseResourceIMAP;
00200   bool mHideFolders;
00201 
00202   /*
00203    * Bunch of maps to keep track of incidents currently in transfer, ones
00204    * which need to be ungotten, once we are done, once with updates pending.
00205    * Since these are transient attributes of only a small but changing number
00206    * of incidences they are not encapsulated in a struct or somesuch.
00207    */
00208   QMap<QString, Q_UINT32> mUIDToSerNum;
00209   QMap<Q_UINT32, bool> mTheUnGetMes;
00210   QMap<QString, QString> mPendingUpdates;
00211   QMap<QString, bool> mInTransit;
00212 
00213 };
00214 
00215 #endif // KMAILICALIFACEIMPL_H
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Apr 4 04:48:24 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003