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 
00044 class QTextCodec;
00045 class KMFolder;
00046 class KMMessage;
00047 class KMFolderDir;
00048 class KMFolderTreeItem;
00049 
00050 namespace {
00051 
00052 // Local helper class
00053 class ExtraFolder {
00054 public:
00055   ExtraFolder( KMFolder* f ) : folder( f ) {}
00056   QGuardedPtr<KMFolder> folder;
00057 };
00058 
00059 } // anonymous namespace
00060 
00061 class KMailICalIfaceImpl : public QObject, virtual public KMailICalIface {
00062   Q_OBJECT
00063 public:
00064   KMailICalIfaceImpl();
00065 
00066   bool addIncidence( const QString& type, const QString& folder,
00067                      const QString& uid, const QString& ical );
00068   bool deleteIncidence( const QString& type, const QString& folder,
00069                         const QString& uid );
00070   QStringList incidences( const QString& type, const QString& folder );
00071 
00072   QStringList subresources( const QString& type );
00073 
00074   bool isWritableFolder( const QString& type, const QString& resource );
00075 
00076   // This saves the iCals/vCards in the entries in the folder.
00077   // The format in the string list is uid, entry, uid, entry...
00078   bool update( const QString& type, const QString& folder,
00079                const QStringList& entries );
00080 
00081   // Update a single entry in the storage layer
00082   bool update( const QString& type, const QString& folder,
00083                const QString& uid, const QString& entry );
00084 
00090   Q_UINT32 update( const QString& resource,
00091                    Q_UINT32 sernum,
00092                    const QString& subject,
00093                    const QString& plainTextBody,
00094                    const QMap<QCString, QString>& customHeaders,
00095                    const QStringList& attachmentURLs,
00096                    const QStringList& attachmentMimetypes,
00097                    const QStringList& attachmentNames,
00098                    const QStringList& deletedAttachments );
00099 
00100   bool deleteIncidenceKolab( const QString& resource,
00101                              Q_UINT32 sernum );
00102   int incidencesKolabCount( const QString& mimetype,
00103                             const QString& resource );
00104   QMap<Q_UINT32, QString> incidencesKolab( const QString& mimetype,
00105                                            const QString& resource,
00106                                            int startIndex,
00107                                            int nbMessages );
00108 
00109   QValueList<SubResource> subresourcesKolab( const QString& contentsType );
00110 
00111   // "Get" an attachment. This actually saves the attachment in a file
00112   // and returns a URL to it
00113   KURL getAttachment( const QString& resource,
00114                       Q_UINT32 sernum,
00115                       const QString& filename );
00116 
00117   bool removeSubresource( const QString& );
00118 
00119   bool addSubresource( const QString& resource,
00120                        const QString& parent,
00121                        const QString& contentsType );
00122 
00123   // tell KOrganizer about messages to be deleted
00124   void msgRemoved( KMFolder*, KMMessage* );
00125 
00127   void initFolders();
00128 
00130   void cleanup();
00131 
00136   bool isResourceFolder( KMFolder* folder ) const;
00137 
00142   bool isStandardResourceFolder( KMFolder* folder ) const;
00143 
00148   bool hideResourceImapFolder( KMFolder* folder ) const;
00149 
00155   bool hideResourceAccountRoot( KMFolder* folder ) const;
00156 
00161   KFolderTreeItem::Type folderType( KMFolder* folder ) const;
00162 
00167   QString folderPixmap( KFolderTreeItem::Type type ) const;
00168 
00171   QString folderName( KFolderTreeItem::Type type, int language = -1 ) const;
00172 
00174   KMFolder* folderFromType( const QString& type, const QString& folder );
00175 
00177   static KMMessage* findMessageByUID( const QString& uid, KMFolder* folder );
00178 
00180   static KMMessage* findMessageBySerNum( Q_UINT32 serNum, KMFolder* folder );
00181 
00183   void deleteMsg( KMMessage* msg );
00184 
00185   bool isEnabled() const { return mUseResourceIMAP; }
00186 
00188   void folderContentsTypeChanged( KMFolder*, KMail::FolderContentsType );
00189 
00191   StorageFormat storageFormat( KMFolder* folder ) const;
00193   void setStorageFormat( KMFolder* folder, StorageFormat format );
00194 
00195   static const char* annotationForContentsType( KMail::FolderContentsType type );
00196 
00197   // Called after a folder was synced with the server
00198   void folderSynced( KMFolder* folder, const KURL& folderURL );
00199   // Called when deletion of a folder from the server suceeded, 
00200   // triggers fb re-generation
00201   void folderDeletedOnServer( const KURL& folderURL );
00202   void addFolderChange( KMFolder* folder, FolderChanges changes );
00203 
00204   // See CachedImapJob::slotPutMessageResult
00205   bool isResourceQuiet() const;
00206   void setResourceQuiet(bool q);
00207 
00208 public slots:
00209   /* (Re-)Read configuration file */
00210   void readConfig();
00211   void slotFolderRemoved( KMFolder* folder );
00212 
00213   void slotIncidenceAdded( KMFolder* folder, Q_UINT32 sernum );
00214   void slotIncidenceDeleted( KMFolder* folder, Q_UINT32 sernum );
00215   void slotRefresh( const QString& type);
00216 
00217   // Called when a folder is made readonly or readwrite, or renamed,
00218   // or any other similar change that affects the resources
00219   void slotFolderPropertiesChanged( KMFolder* folder );
00220 
00221 private slots:
00222   void slotRefreshFolder( KMFolder* );
00223   void slotCheckDone();
00224   void slotFolderLocationChanged( const QString&, const QString& );
00225   void slotFolderRenamed();
00226 
00227 private:
00229   KMFolder* initFolder( const char* typeString, KMail::FolderContentsType contentsType );
00230 
00231   void connectFolder( KMFolder* folder );
00232 
00233   KMFolder* extraFolder( const QString& type, const QString& folder );
00234 
00235   struct StandardFolderSearchResult
00236   {
00237     enum FoundEnum { FoundAndStandard, NotFound, FoundByType, FoundByName };
00238     StandardFolderSearchResult() : folder( 0 ) {}
00239     StandardFolderSearchResult( KMFolder* f, FoundEnum e ) : folder( f ), found( e ) {}
00240     KMFolder* folder; // NotFound implies folder==0 of course.
00241     FoundEnum found;
00242   };
00243 
00244   StandardFolderSearchResult findStandardResourceFolder( KMFolderDir* folderParentDir, KMail::FolderContentsType contentsType );
00245   KMFolder* findResourceFolder( const QString& resource );
00246 
00247   bool updateAttachment( KMMessage& msg,
00248                          const QString& attachmentURL,
00249                          const QString& attachmentName,
00250                          const QString& attachmentMimetype,
00251                          bool lookupByName );
00252   bool deleteAttachment( KMMessage& msg,
00253                          const QString& attachmentURL );
00254   Q_UINT32 addIncidenceKolab( KMFolder& folder,
00255                               const QString& subject,
00256                               const QString& plainTextBody,
00257                               const QMap<QCString, QString>& customHeaders,
00258                               const QStringList& attachmentURLs,
00259                               const QStringList& attachmentNames,
00260                               const QStringList& attachmentMimetypes );
00261   static bool kolabXMLFoundAndDecoded( const KMMessage& msg, const QString& mimetype, QString& s );
00262 
00263   void handleFolderSynced( KMFolder* folder,
00264                            const KURL& folderURL,
00265                            int _changes );
00266   void triggerKolabFreeBusy( const KURL& folderURL );
00267 
00268   static bool folderIsAlarmRelevant( const KMFolder * );
00269 
00270 private:
00271   QGuardedPtr<KMFolder> mContacts;
00272   QGuardedPtr<KMFolder> mCalendar;
00273   QGuardedPtr<KMFolder> mNotes;
00274   QGuardedPtr<KMFolder> mTasks;
00275   QGuardedPtr<KMFolder> mJournals;
00276 
00277   // The extra IMAP resource folders
00278   // Key: folder location. Data: folder.
00279   QDict<ExtraFolder> mExtraFolders;
00280 
00281   // More info for each folder we care about (mContacts etc. as well as the extra folders)
00282   // The reason for storing it here is that it can be shared between
00283   // kmfoldercachedimap and kmfolderimap, and that it's groupware data anyway.
00284   struct FolderInfo {
00285     FolderInfo() {} // for QMap
00286     FolderInfo( StorageFormat f, FolderChanges c ) :
00287       mStorageFormat( f ), mChanges( c ) {}
00288     StorageFormat mStorageFormat;
00289     FolderChanges mChanges;
00290   };
00291   // The storage format used for each folder that we care about
00292   typedef QMap<KMFolder*, FolderInfo> FolderInfoMap;
00293   FolderInfoMap mFolderInfoMap;
00294 
00295   unsigned int mFolderLanguage;
00296 
00297   KMFolderDir* mFolderParentDir;
00298   KMFolderType mFolderType;
00299 
00300   bool mUseResourceIMAP;
00301   bool mResourceQuiet;
00302   bool mHideFolders;
00303   const QTextCodec* mUTF8Codec;
00304 };
00305 
00306 #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 Thu Oct 4 14:42:13 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003