Messagelib

messagehelper.h
1 /*
2  SPDX-FileCopyrightText: 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected]
3  SPDX-FileCopyrightText: 2009 Andras Mantia <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #pragma once
9 
10 #include "messagecomposer_export.h"
11 
12 #include <Akonadi/Item>
13 #include <KMime/Headers>
14 #include <KMime/KMimeMessage>
15 
16 namespace KIdentityManagement
17 {
18 class IdentityManager;
19 }
20 
21 namespace KMime
22 {
23 class Message;
24 }
25 
26 /**
27  * Contains random helper methods when dealing with messages.
28  * TODO: cleanup and organize, along with similar methods in messageviewer.
29  */
30 namespace MessageHelper
31 {
32 /** Initialize header fields. Should be called on new messages
33  if they are not set manually. E.g. before composing. Calling
34  of setAutomaticFields(), see below, is still required. */
35 void MESSAGECOMPOSER_EXPORT initHeader(const KMime::Message::Ptr &message, const KIdentityManagement::IdentityManager *identMan, uint id = 0);
36 
37 /** Set the from, to, cc, bcc, encryption etc headers as specified in the
38  * given identity. */
39 void applyIdentity(const KMime::Message::Ptr &message, const KIdentityManagement::IdentityManager *identMan, uint id);
40 
41 /** Initialize headers fields according to the identity and the transport
42  header of the given original message */
43 void initFromMessage(const KMime::Message::Ptr &msg,
44  const KMime::Message::Ptr &orgiMsg,
46  uint id,
47  bool idHeaders = true);
48 
49 MESSAGECOMPOSER_EXPORT KMime::Types::AddrSpecList extractAddrSpecs(const KMime::Message::Ptr &msg, const QByteArray &header);
50 
51 /** Set fields that are either automatically set (Message-id)
52  or that do not change from one message to another (MIME-Version).
53  Call this method before sending *after* all changes to the message
54  are done because this method does things different if there are
55  attachments / multiple body parts. */
56 void setAutomaticFields(const KMime::Message::Ptr &msg, bool isMultipart = false);
57 }
58 
Contains random helper methods when dealing with messages.
void initHeader(const KMime::Message::Ptr &message, const KIdentityManagement::IdentityManager *identMan, uint id)
Initialize header fields.
void setAutomaticFields(const KMime::Message::Ptr &msg, bool aIsMulti)
Set fields that are either automatically set (Message-id) or that do not change from one message to a...
void applyIdentity(const KMime::Message::Ptr &message, const KIdentityManagement::IdentityManager *identMan, uint id)
Set the from, to, cc, bcc, encryption etc headers as specified in the given identity.
void initFromMessage(const KMime::Message::Ptr &msg, const KMime::Message::Ptr &origMsg, KIdentityManagement::IdentityManager *identMan, uint id, bool idHeaders)
Initialize headers fields according to the identity and the transport header of the given original me...
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 23:04:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.