• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmail

kmailicalifaceimpl.h

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, 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 
00038 #ifndef KMAILICALIFACEIMPL_H
00039 #define KMAILICALIFACEIMPL_H
00040 
00041 #include <QPointer>
00042 #include <QMap>
00043 #include <QList>
00044 #include <QHash>
00045 
00046 #include <kurl.h>
00047 
00048 #include <kfoldertree.h>
00049 using KPIM::KFolderTreeItem;
00050 #include "kmfoldertype.h"
00051 #include "groupware_types.h"
00052 
00053 class KMFolder;
00054 class KMMessage;
00055 class KMFolderDir;
00056 
00057 namespace KMail {
00058 
00059   // Local helper class
00060 class ExtraFolder {
00061 public:
00062   ExtraFolder( KMFolder* f );
00063   ~ExtraFolder();
00064   QPointer<KMFolder> folder;
00065 };
00066 
00067 class Accumulator {
00068 public:
00069   Accumulator( const QString& t, const QString& f, int c )
00070   :type( t ), folder( f ), count( c ) {}
00071 
00072   void add( const QString& incidence ) {
00073     incidences << incidence;
00074     count--;
00075   }
00076   bool isFull() { return count == 0; }
00077 
00078   const QString type;
00079   const QString folder;
00080   QStringList incidences;
00081   int count;
00082 };
00083 
00084 }
00085 
00087 class KMailICalIfaceImpl :public QObject {
00088   Q_OBJECT
00089 public:
00090   KMailICalIfaceImpl();
00091   ~KMailICalIfaceImpl();
00092 
00101   void registerWithDBus();
00102 
00103   bool isWritableFolder( const QString& type, const QString& resource );
00104 
00105   KMail::StorageFormat storageFormat( const QString &resource );
00106 
00112   quint32 update( const QString& resource,
00113                    quint32 sernum,
00114                    const QString& subject,
00115                    const QString& plainTextBody,
00116                    const KMail::CustomHeader::List& customHeaders,
00117                    const QStringList& attachmentURLs,
00118                    const QStringList& attachmentMimetypes,
00119                    const QStringList& attachmentNames,
00120                    const QStringList& deletedAttachments );
00121 
00122   bool deleteIncidenceKolab( const QString& resource,
00123                              quint32 sernum );
00124   int incidencesKolabCount( const QString& mimetype,
00125                             const QString& resource );
00126   KMail::SernumDataPair::List incidencesKolab( const QString& mimetype,
00127                                            const QString& resource,
00128                                            int startIndex,
00129                                            int nbMessages );
00130 
00131   QList<KMail::SubResource> subresourcesKolab( const QString& contentsType );
00132 
00133   bool triggerSync( const QString& contentsType );
00134 
00135   // "Get" an attachment. This actually saves the attachment in a file
00136   // and returns a URL to it
00137   QString getAttachment( const QString& resource,
00138                       quint32 sernum,
00139                       const QString& filename );
00140 
00141   QString attachmentMimetype( const QString &resource,
00142                               quint32 sernum,
00143                               const QString &filename );
00144 
00145   QStringList listAttachments( const QString &resource, quint32 sernum );
00146 
00147 
00148   bool removeSubresource( const QString& );
00149 
00150   bool addSubresource( const QString& resource,
00151                        const QString& parent,
00152                        const QString& contentsType );
00153 
00154   // tell KOrganizer about messages to be deleted
00155   void msgRemoved( KMFolder*, KMMessage* );
00156 
00158   void initFolders();
00159 
00161   void cleanup();
00162 
00167   bool isResourceFolder( KMFolder* folder ) const;
00168 
00169   /* Returns true if the folder is one of the standard resource folders, as
00170    * opposed to an extra folder. */
00171   bool isStandardResourceFolder( KMFolder* folder ) const;
00172 
00177   bool hideResourceFolder( KMFolder* folder ) const;
00178 
00184   bool hideResourceAccountRoot( KMFolder* folder ) const;
00185 
00190   KFolderTreeItem::Type folderType( KMFolder* folder ) const;
00191 
00196   QString folderPixmap( KFolderTreeItem::Type type ) const;
00197 
00200   QString folderName( KFolderTreeItem::Type type, int language = -1 ) const;
00201 
00203   KMFolder* folderFromType( const QString& type, const QString& folder );
00204 
00206   QString icalFolderType( KMFolder* folder ) const;
00207 
00209   KMMessage* findMessageByUID( const QString& uid, KMFolder* folder );
00211   static KMMessage* findMessageBySerNum( quint32 serNum, KMFolder* folder );
00212 
00214   void deleteMsg( KMMessage* msg );
00215 
00216   bool isEnabled() const { return mUseResourceIMAP; }
00217 
00219   void folderContentsTypeChanged( KMFolder*, KMail::FolderContentsType );
00220 
00222     KMail::StorageFormat storageFormat( KMFolder* folder ) const;
00224   void setStorageFormat( KMFolder* folder, KMail::StorageFormat format );
00225 
00226 
00227   static const char* annotationForContentsType( KMail::FolderContentsType type );
00228 
00229   // Called after a folder was synced with the server
00230   void folderSynced( KMFolder* folder, const KUrl& folderURL );
00231   // Called when deletion of a folder from the server suceeded,
00232   // triggers fb re-generation
00233   void folderDeletedOnServer( const KUrl& folderURL );
00234   void addFolderChange( KMFolder* folder, KMail::FolderChanges changes );
00235 
00236   // See CachedImapJob::slotPutMessageResult
00237   bool isResourceQuiet() const;
00238   void setResourceQuiet(bool q);
00239 
00240 public slots:
00241   /* (Re-)Read configuration file */
00242   void readConfig();
00243   void slotFolderRemoved( KMFolder* folder );
00244 
00245   void slotIncidenceAdded( KMFolder* folder, quint32 sernum );
00246   void slotIncidenceDeleted( KMFolder* folder, quint32 sernum );
00247   void slotRefresh( const QString& type);
00248 
00249   // Called when a folder is made readonly or readwrite, or renamed,
00250   // or any other similar change that affects the resources
00251   void slotFolderPropertiesChanged( KMFolder* folder );
00252 
00253 private slots:
00254   void slotRefreshFolder( KMFolder* );
00255   void slotCheckDone();
00256   void slotFolderLocationChanged( const QString&, const QString& );
00257   void slotFolderRenamed();
00258   void slotMessageRetrieved( KMMessage* );
00259 
00260 signals:
00261   void incidenceAdded( const QString& type, const QString& folder,
00262                        uint sernum, int format, const QString& entry );
00263   void asyncLoadResult( const QMap<quint32, QString>, const QString& type,
00264                         const QString& folder );
00265   void incidenceDeleted( const QString& type, const QString& folder,
00266                          const QString& uid );
00267   void signalRefresh( const QString& type, const QString& folder );
00268   void subresourceAdded( const QString& type, const QString& resource,
00269                          const QString& label, bool writable, bool alarmRelevant );
00270   void subresourceDeleted( const QString& type, const QString& resource );
00271 
00272 private:
00274   KMFolder* initFolder( KMail::FolderContentsType contentsType );
00275   KMFolder* initScalixFolder( KMail::FolderContentsType contentsType );
00276 
00277   void connectFolder( KMFolder* folder );
00278 
00279   KMFolder* extraFolder( const QString& type, const QString& folder );
00280 
00281   void syncFolder( KMFolder* folder ) const;
00282 
00283   struct StandardFolderSearchResult
00284   {
00285     enum FoundEnum { FoundAndStandard, NotFound, FoundByType, FoundByName };
00286     StandardFolderSearchResult() : folder( 0 ) {}
00287     StandardFolderSearchResult( KMFolder* f, FoundEnum e ) : folder( f ), found( e ) {}
00288     StandardFolderSearchResult( const QList<KMFolder*> &f, FoundEnum e ) :
00289         folder( f.first() ), folders( f ), found( e ) {}
00290     KMFolder* folder; // NotFound implies folder==0 of course.
00291     QList<KMFolder*> folders; // in case we found multiple default folders (which should not happen)
00292     FoundEnum found;
00293   };
00294 
00295   StandardFolderSearchResult findStandardResourceFolder( KMFolderDir* folderParentDir, KMail::FolderContentsType contentsType );
00296   KMFolder* findResourceFolder( const QString& resource );
00297 
00298 
00299   bool updateAttachment( KMMessage& msg,
00300                          const QString& attachmentURL,
00301                          const QString& attachmentName,
00302                          const QString& attachmentMimetype,
00303                          bool lookupByName );
00304   bool deleteAttachment( KMMessage& msg,
00305                          const QString& attachmentURL );
00306   quint32 addIncidenceKolab( KMFolder& folder,
00307                               const QString& subject,
00308                               const QString& plainTextBody,
00309                               const KMail::CustomHeader::List& customHeaders,
00310                               const QStringList& attachmentURLs,
00311                               const QStringList& attachmentNames,
00312                               const QStringList& attachmentMimetypes );
00313   static bool kolabXMLFoundAndDecoded( const KMMessage& msg, const QString& mimetype, QString& s );
00314 
00315   void handleFolderSynced( KMFolder* folder,
00316                            const KUrl& folderURL,
00317                            int _changes );
00318   void triggerKolabFreeBusy( const KUrl& folderURL );
00319 
00320   KMail::StorageFormat globalStorageFormat() const;
00321 
00322   static bool folderIsAlarmRelevant( const KMFolder * );
00323 
00324 private:
00325   QPointer<KMFolder> mContacts;
00326   QPointer<KMFolder> mCalendar;
00327   QPointer<KMFolder> mNotes;
00328   QPointer<KMFolder> mTasks;
00329   QPointer<KMFolder> mJournals;
00330 
00331   // The extra IMAP resource folders
00332   // Key: folder location. Data: folder.
00333   QHash<QString, KMail::ExtraFolder*> mExtraFolders;
00334   // used for collecting incidences during async loading
00335   QHash<QString, KMail::Accumulator*> mAccumulators;
00336   // More info for each folder we care about (mContacts etc. as well as the extra folders)
00337   // The reason for storing it here is that it can be shared between
00338   // kmfoldercachedimap and kmfolderimap, and that it's groupware data anyway.
00339   struct FolderInfo {
00340     FolderInfo() {} // for QMap
00341     FolderInfo(KMail::StorageFormat f, KMail::FolderChanges c ) :
00342       mStorageFormat( f ), mChanges( c ) {}
00343     KMail::StorageFormat mStorageFormat;
00344     KMail::FolderChanges mChanges;
00345   };
00346   // The storage format used for each folder that we care about
00347   typedef QMap<KMFolder*, FolderInfo> FolderInfoMap;
00348   // helper for reading the FolderInfo from the config file
00349   FolderInfo readFolderInfo( const KMFolder * const folder ) const;
00350 
00351   FolderInfoMap mFolderInfoMap;
00352 
00353   unsigned int mFolderLanguage;
00354 
00355   KMFolderDir* mFolderParentDir;
00356   KMFolder*    mFolderParent;
00357   KMFolderType mFolderType;
00358 
00359   bool mUseResourceIMAP;
00360   bool mResourceQuiet;
00361   bool mHideFolders;
00362 
00363   /*
00364    * Bunch of maps to keep track of incidents currently in transfer, ones
00365    * which need to be ungotten, once we are done, once with updates pending.
00366    * Since these are transient attributes of only a small but changing number
00367    * of incidences they are not encapsulated in a struct or somesuch.
00368    */
00369   QMap<QString, quint32> mUIDToSerNum;
00370   QMap<quint32, bool> mTheUnGetMes;
00371   QMap<QString, QString> mPendingUpdates;
00372   QMap<QString, bool> mInTransit;
00373 
00374 };
00375 
00376 #endif // KMAILICALIFACEIMPL_H

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal