kmail

kmmsgdict.h
1/*
2 * This file is part of KMail, the KDE mail client
3 * Copyright (c) Ronen Tzur <rtzur@shani.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef __KMMSGDICT
21#define __KMMSGDICT
22
23#include <tqvaluelist.h>
24#include <tqptrlist.h>
25
26class KMFolder;
27class KMMsgBase;
28class KMMessage;
29class KMMsgDictEntry;
30class KMMsgDictREntry;
31class KMDict;
32class TQString;
33class FolderStorage;
34
53{
54 template<class> friend class KStaticDeleter;
55 public:
57 static const KMMsgDict* instance();
58
61 void getLocation( unsigned long key, KMFolder **retFolder, int *retIndex ) const;
64 void getLocation( const KMMsgBase *msg, KMFolder **retFolder, int *retIndex ) const;
67 void getLocation( const KMMessage *msg, KMFolder **retFolder, int *retIndex ) const;
68
72 unsigned long getMsgSerNum( KMFolder *folder, int index ) const;
73
75 static TQValueList<unsigned long> serNumList(TQPtrList<KMMsgBase> msgList);
76
77private:
78 /* FIXME It would be better to do without these, they are the classes
79 * involved in filling and maintaining the dict. The MsgList needs access
80 * because of things it does that should be in FolderIndex, probably, which
81 * the message list is an implementation detail of. */
82 friend class FolderStorage;
83 friend class KMMsgList;
84 friend class KMFolderIndex;
85
86 // Access for those altering the dict, our friend classes
87 static KMMsgDict* mutableInstance();
88
92 unsigned long insert(unsigned long msgSerNum, const KMMsgBase *msg, int index = -1);
93
97 unsigned long insert(const KMMsgBase *msg, int index = -1);
98
100 void replace(unsigned long msgSerNum,
101 const KMMsgBase *msg, int index = -1);
102
104 void remove(unsigned long msgSerNum);
105
107 unsigned long remove(const KMMsgBase *msg);
108
110 void update(const KMMsgBase *msg, int index, int newIndex);
111
112
113 // ----- per folder serial number on-disk structure handling ("ids files")
114
116 static TQString getFolderIdsLocation( const FolderStorage &folder );
117
119 bool isFolderIdsOutdated( const FolderStorage &folder );
120
122 int readFolderIds( FolderStorage & );
123
125 int writeFolderIds( const FolderStorage & );
126
128 int touchFolderIds( const FolderStorage & );
129
132 int appendToFolderIds( FolderStorage&, int index );
133
135 bool hasFolderIds( const FolderStorage & );
136
138 bool removeFolderIds( FolderStorage & );
139
142 KMMsgDictREntry *openFolderIds( const FolderStorage &, bool truncate);
143
144
145 // --------- helpers ------------
146
149 static void deleteRentry(KMMsgDictREntry *entry);
150
152 unsigned long getNextMsgSerNum();
153
154 // prevent creation and deletion, we are a singleton
155 KMMsgDict();
156 ~KMMsgDict();
157
159 unsigned long nextMsgSerNum;
160
162 KMDict *dict;
163
165 static KMMsgDict *m_self;
166};
167
168#endif /* __KMMSGDICT */
The FolderStorage class is the bass class for the storage related aspects of a collection of mail (a ...
Definition: folderstorage.h:80
virtual void remove()
Removes the folder physically from disk and empties the contents of the folder in memory.
KMDict implements a lightweight dictionary with serial numbers as keys.
Definition: kmdict.h:27
A FolderStorage with an index for faster access to often used message properties.
Definition: kmfolderindex.h:38
Mail folder.
Definition: kmfolder.h:69
This is a Mime Message.
Definition: kmmessage.h:68
KMail message dictionary.
Definition: kmmsgdict.h:53
unsigned long getMsgSerNum(KMFolder *folder, int index) const
Find the message serial number for the message located at index index in folder folder.
Definition: kmmsgdict.cpp:345
static TQValueList< unsigned long > serNumList(TQPtrList< KMMsgBase > msgList)
Convert a list of KMMsgBase pointers to a list of serial numbers.
Definition: kmmsgdict.cpp:359
void getLocation(unsigned long key, KMFolder **retFolder, int *retIndex) const
Returns the folder the message represented by the serial number key is in and the index in that folde...
Definition: kmmsgdict.cpp:319
static const KMMsgDict * instance()
Access the globally unique MessageDict.
Definition: kmmsgdict.cpp:167
An abstraction of an array of pointers to messages.
Definition: kmmsglist.h:38