1 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
2 
3    This file is part of the Trojita Qt IMAP e-mail client,
4    http://trojita.flaska.net/
5 
6    This program is free software; you can redistribute it and/or
7    modify it under the terms of the GNU General Public License as
8    published by the Free Software Foundation; either version 2 of
9    the License or (at your option) version 3 or any later version
10    accepted by the membership of KDE e.V. (or its successor approved
11    by the membership of KDE e.V.), which shall act as a proxy
12    defined in Section 14 of version 3 of the license.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #ifndef IMAP_PARSER_THREADINGNODE
24 #define IMAP_PARSER_THREADINGNODE
25 
26 #include <QDataStream>
27 #include <QMetaType>
28 #include <QVector>
29 
30 namespace Imap
31 {
32 namespace Responses
33 {
34 
35 /** @short Structure for keeping track of the message hierarchy, or threading */
36 struct ThreadingNode {
37     /** @short Message sequence number or UID number
38 
39     Which of the two allowed numbering schemes would be used depends on
40     the command which triggered this reply, if it was plain THREAD, it
41     will use message sequence numbers, if it was an UID THREAD command,
42     it uses UIDs.
43 
44     Special value 0 means "parent is present and its existence can be
45     proved, but it doesn't match the search criteria or it isn't in the
46     mailbox.
47     */
48     uint num;
49     /** @short Recursive data structure storing numbers of all messages which are children of the current one */
50     QVector<ThreadingNode> children;
51     ThreadingNode(const uint num=0, const QVector<ThreadingNode> &children=QVector<ThreadingNode>()):
numThreadingNode52         num(num), children(children)
53     {
54     }
55 };
56 
57 bool operator==(const ThreadingNode &n1, const ThreadingNode &n2);
58 bool operator!=(const ThreadingNode &n1, const ThreadingNode &n2);
59 
60 QDataStream &operator>>(QDataStream &s, ThreadingNode &n);
61 QDataStream &operator<<(QDataStream &s, const ThreadingNode &n);
62 
63 }
64 }
65 
66 Q_DECLARE_METATYPE(Imap::Responses::ThreadingNode);
67 
68 
69 #endif // IMAP_PARSER_THREADINGNODE
70