Messagelib

dkimresultattribute.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "dkimresultattribute.h"
8#include <QDataStream>
9#include <QIODevice>
10
11using namespace MessageViewer;
12class MessageViewer::DKIMResultAttributePrivate
13{
14public:
15 DKIMResultAttributePrivate() = default;
16
17 int error = -1;
18 int warning = -1;
19 int status = -1;
20};
21
22DKIMResultAttribute::DKIMResultAttribute()
23 : d(new DKIMResultAttributePrivate)
24{
25}
26
27DKIMResultAttribute::~DKIMResultAttribute() = default;
28
29QByteArray DKIMResultAttribute::type() const
30{
31 static const QByteArray sType("DKIMResultAttribute");
32 return sType;
33}
34
35DKIMResultAttribute *DKIMResultAttribute::clone() const
36{
37 auto attr = new DKIMResultAttribute();
38 attr->setWarning(warning());
39 attr->setStatus(status());
40 attr->setError(error());
41 return attr;
42}
43
44QByteArray DKIMResultAttribute::serialized() const
45{
46 QByteArray result;
48 s.setVersion(QDataStream::Qt_5_15);
49 s << status();
50 s << warning();
51 s << error();
52 return result;
53}
54
55void DKIMResultAttribute::deserialize(const QByteArray &data)
56{
57 QDataStream s(data);
58 s.setVersion(QDataStream::Qt_5_15);
59 int stat = -1;
60 s >> stat;
61 d->status = stat;
62 int warn = -1;
63 s >> warn;
64 d->warning = warn;
65 int err = -1;
66 s >> err;
67 d->error = err;
68}
69
70bool DKIMResultAttribute::operator==(const DKIMResultAttribute &other) const
71{
72 return d->error == other.error() && d->warning == other.warning() && d->status == other.status();
73}
74
75void DKIMResultAttribute::setError(int err)
76{
77 d->error = err;
78}
79
80int DKIMResultAttribute::error() const
81{
82 return d->error;
83}
84
85void DKIMResultAttribute::setWarning(int err)
86{
87 d->warning = err;
88}
89
90int DKIMResultAttribute::warning() const
91{
92 return d->warning;
93}
94
95void DKIMResultAttribute::setStatus(int err)
96{
97 d->status = err;
98}
99
100int DKIMResultAttribute::status() const
101{
102 return d->status;
103}
KIOCORE_EXPORT StatJob * stat(const QUrl &url, JobFlags flags=DefaultFlags)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.