autocryptrecipient.h 1.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
   SPDX-FileCopyrightText: 2020 Sandro Knauß <knauss@kde.org>

   SPDX-License-Identifier: LGPL-2.0-or-later
*/

#ifndef AUTOCRYPTRECIPIENT_H
#define AUTOCRYPTRECIPIENT_H

#include <KMime/Headers>
#include <MimeTreeParser/NodeHelper>

#include <gpgme++/data.h>

#include <QJsonDocument>

class AutocryptRecipientPrivate;
class AutocryptRecipientTest;

namespace MessageCore {

class HeaderMixupNodeHelper
{
public:
    HeaderMixupNodeHelper(MimeTreeParser::NodeHelper *n, KMime::Content *m);

    Q_REQUIRED_RESULT bool hasMailHeader(const char *header) const;
    KMime::Headers::Base const *mailHeaderAsBase(const char *header) const;
    QSharedPointer<KMime::Headers::Generics::AddressList> mailHeaderAsAddressList(const char *header) const;
    Q_REQUIRED_RESULT QDateTime dateHeader() const;

public:
    KMime::Content *message;
private:
    MimeTreeParser::NodeHelper *nodeHelper;
};

class AutocryptRecipient
{
public:
    AutocryptRecipient();
42
    ~AutocryptRecipient();
43
    void updateFromMessage(const HeaderMixupNodeHelper &mixup);
44
    void updateFromGossip(const HeaderMixupNodeHelper& mixup, const KMime::Headers::Base* header);
Sandro Knauß's avatar
Sandro Knauß committed
45

46
    QByteArray toJson(QJsonDocument::JsonFormat format) const;
47
    void fromJson(const QByteArray &json);
48

49
50
51
    bool hasChanged() const;
    void setChangedFlag(bool changed);

52
53
    GpgME::Key gpgKey() const;
    GpgME::Key gossipKey() const;
54
55
56
57
58
59
60
61
62

private:
    AutocryptRecipientPrivate *d_ptr;
    Q_DECLARE_PRIVATE(AutocryptRecipient)

    friend class AutocryptRecipientTest;
};
}
#endif