Fix assert when Mail-Followup-To contains two emails, as Ossi's Mutt does
[kdepim.git] / messagecore / messagehelpers.h
blob8691979fbbc7171b7f4d9336fc2eb7683e694b6a
1 /*
2 * This file is part of KDEPIM.
3 * Copyright (c) 2010 Till Adam <adam@kde.org>
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.
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.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef MESSAGECORE_MESSAGEHELPERS_H
21 #define MESSAGECORE_MESSAGEHELPERS_H
23 #include "messagecore_export.h"
25 #include <akonadi/item.h>
26 #include <akonadi/kmime/messagestatus.h>
27 #include <boost/shared_ptr.hpp>
28 #include <KMime/Message>
30 namespace MessageCore {
32 namespace Util {
33 /**
34 * Retrieve the KMime::Message from the item, if there is one.
35 * @returns A valid message pointer, or 0, is the item does not contain
36 * a valid message.
38 MESSAGECORE_EXPORT KMime::Message::Ptr message( const Akonadi::Item &item );
40 /**
41 * Returns whether the item represents a valid KMime::Message that is not
42 * in the Akonadi store (yet). This happens when operating on messages
43 * attached to other mails, for example. Such items are not "valid", in
44 * the akonadi sense, since jobs can not sensibly use them, but they do
45 * contain a valid message pointer.
47 MESSAGECORE_EXPORT bool isStandaloneMessage( const Akonadi::Item &item );
49 /**
50 * Get the message id as a string from the @p message.
52 MESSAGECORE_EXPORT QString messageId( const KMime::Message::Ptr &message );
54 /**
55 * Adds private headers to the given @p message that links it to the original message.
57 * @param message The message to add the link information to.
58 * @param id The item id of the original message.
59 * @param status The status (replied or forwarded) that links the message to the original message.
61 MESSAGECORE_EXPORT void addLinkInformation( const KMime::Message::Ptr &message, Akonadi::Item::Id item, const Akonadi::MessageStatus &status );
63 /**
64 * Reads the private headers of the given @p message to extract link information to its original message.
66 * @param message The message to read the link information from.
67 * @param id Will contain the item id of the original message.
68 * @param status Will contain the status (replied or forwarded) that linked the message to the original message.
69 * @returns Whether the mail contains valid link information or not.
71 MESSAGECORE_EXPORT bool getLinkInformation( const KMime::Message::Ptr &message, Akonadi::Item::Id &id, Akonadi::MessageStatus &status );
76 #endif