Eneboo - Documentación para desarrolladores
src/flmail/mailfolder.h
Ir a la documentación de este archivo.
00001 /*
00002     Copyright (C) 2001-2002 by theKompany.com <www.thekompany.com>
00003     This program is free software; you can redistribute it and/or modify
00004     it under the terms of the GNU General Public License as published by
00005     the Free Software Foundation; either version 2 of the License, or
00006     (at your option) any later version.
00007 
00008     This program is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011     GNU General Public License for more details.
00012 
00013     You should have received a copy of the GNU General Public License
00014     along with this program; if not, write to the Free Software
00015     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 
00017     By PLUGINS we mean the commercial plug-ins developed by theKompany.com
00018     for Aethera.
00019 
00020     In addition, as a special exception, theKompany.com gives permission
00021     to link the code of this program with PLUGINS (or with
00022     modified versions of PLUGINS that use the same license as PLUGINS),
00023     and distribute linked combinations including the two.  You must obey
00024     the GNU General Public License in all respects for all of the code used
00025     other than PLUGINS.  If you modify this file, you may extend this
00026     exception to your version of the file, but you are not obligated to do so.
00027     If you do not wish to do so, delete this exception statement from your
00028     version.
00029 
00030     This license grants you the ability to use PLUGINS with Aethera only
00031     and may not be used outside of Aethera.
00032     See also http://www.thekompany.com/products/license.txt for details.
00033 */
00034 /***************************************************************************
00035                           mailfolder.h  -  the mail folder interface
00036                              -------------------
00037     begin                : Mon Mar  5 16:16:00 EET 2001
00038     copyright            : (C) 2001 by theKompany (www.thekompany.com>
00039     author               : Eugen Constantinescu
00040     email                : eug@thekompany.com
00041  ***************************************************************************/
00042 
00043 #ifndef MAILFOLDER_H
00044 #define MAILFOLDER_H
00045 
00046 #include <qstring.h>
00047 #include <qcstring.h>
00048 #include <qdir.h>
00049 #include <messageclass.h>
00050 #include <qstringlist.h>
00051 #include <qdict.h>
00052 #include <qptrlist.h>
00053 #include <qmap.h>
00054 #include <qdatetime.h>
00055 
00056 class MessageDevice;
00057 class IndexClass;
00058 
00059 class MailFolder
00060 {
00062     friend class IndexClass;
00063 public:
00065     enum MESSAGES_PLACE {LOCAL=0, REMOTE};
00067     enum PROTOCOL {MBOX=0, POP3, IMAP4};
00069     enum TYPES {Normal=100, Deleted, Drafts, Inbox, Outbox, Sent, Templates};
00071     enum ACCESS_RIGHTS {DENIED=0, WRITE_ONLY=1, READ_ONLY=2, ALL=4};
00072 
00074     enum IMAP4_FLAGS {NO_FLAGS=0, Seen=1, Answered=2, Flagged=4, Draft=8, Recent=16, Delete=32, Other=64};
00075 
00076     MailFolder(const QString &_storageDevice);
00077     virtual ~MailFolder();
00078 
00079     // Index management
00081     void saveIndex(IndexClass *);
00083     void saveIndex();
00085     QDict<IndexClass>& indexIDict();
00087     static QString nextIndexID();
00089     unsigned long getLastIndexID() const;
00090 
00091     // Attribute public methods
00093     QString getStorageDevice() const;
00095     QString name() const;
00097     virtual QString getMessagesFileName() const=0;
00099     QString getIndexFileName() const;
00101     QString getDescriptorFileName() const;
00103     int getFolderType() const;
00105     int getFolderProtocol() const;
00107     int getMessagesPlace() const;
00109     int getAccessRights() const;
00111     void setAccessRights(int access);
00113     static void setAutoExpunge(bool expunge=true);
00115     bool getAutoExpunge() const;
00116 
00118     int getMessageCount() const;
00120     int getUnread() const;
00122     unsigned int getPruneIndexCount() const;
00123 
00124     // Add and delete messages from the folder.
00126     virtual QString createMessage(const QCString &text, const QCString &uid,
00127                                   const QDateTime &rcvtime, const QString &account,
00128                                   const MessageClass *parsedMessage = 0, // parsed message, added to avoid parsing second time
00129                                   bool bSync=false, const unsigned flags=0)=0;
00130 
00132     virtual QString createMessage();
00133 
00135     virtual bool deleteMessage(IndexClass *idx)=0;
00137     virtual QString copyMessage(IndexClass *idx)=0;
00139     virtual QString moveMessage(IndexClass *idx)=0;
00140 
00142     virtual bool expunge(bool force)=0;
00143 
00144     virtual bool moveMessage(const QStringList & urls)=0;
00145     virtual bool copyMessage(const QStringList & urls)=0;
00146     virtual bool deleteMessage(const QStringList & urls)=0;
00147 
00149     virtual bool compact(unsigned level=0);
00150 
00152     QMap<QString, QByteArray> entryCacheBlock();
00153 
00155     void incrementUnread();
00157     void decrementUnread();
00159     void setUnread(int _unread=0);
00161     QStringList getEntryList(const QString url=QString::null) const;
00165     virtual void sync()=0;
00166 
00167 protected:
00168     // Internal protected methods
00170     void setupFiles();
00172     virtual bool shouldExpunge()=0;
00173 
00174     // Index methods
00176     virtual void loadIndex()=0;
00178     void crossReferenceIndex(IndexClass *);
00180     void crossReferenceIndexSet(IndexClass *);
00182     void reparentIndex(IndexClass *);
00184     bool reparentByRelated(IndexClass *);
00186     bool reparentBySubject(IndexClass *);
00188     static IndexClass *findIndex(const QString &);
00190     void setPruneIndexCount(unsigned int _pruneIndexCount=0);
00192     void incrementPruneIndexCount();
00194     void setLastIndexID(long unsigned _lastIndexId);
00196     void syncIndexID(IndexClass *);
00197 
00199     bool subjectThreadMatch(QString parentSubject, QString sonSubject);
00201     static QString translateGlobalMessageID(QString);
00203     QString translateLocalMessageID(QString);
00204 
00205     // Protected attributes
00207     QDict<IndexClass> indexCollection;
00209     unsigned int pruneIndexCount;
00211     QPtrList<MessageDevice> syncMessages;
00212 
00213 private:
00214     // ---------- Private Attributes -------------
00215     // global data
00217     static QPtrList<MailFolder> folderList;
00219     static bool autoExpunge;
00221     static long unsigned lastIndexID;
00222 
00223     // files attributes
00225     QString storageDevice;
00227     QString indexFileName;
00229     QString descriptorFileName;
00231     int folderType;
00233     int folderProtocol;
00235     int messagesPlace;
00237     int accessRights;
00238 
00240     unsigned int unread;
00241 };
00242 
00243 #endif
00244 
00245 
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'