Akonadi Mime

addressattribute.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "addressattribute.h"
8
9#include <QDataStream>
10#include <QIODevice>
11
12#include <Akonadi/AttributeFactory>
13
14using namespace Akonadi;
15
16/**
17 @internal
18*/
19class Akonadi::AddressAttributePrivate
20{
21public:
22 bool mDSN = false;
23 QString mFrom;
24 QStringList mTo;
25 QStringList mCc;
26 QStringList mBcc;
27};
28
29AddressAttribute::AddressAttribute(const QString &from, const QStringList &to, const QStringList &cc, const QStringList &bcc, bool dsn)
30 : d(new AddressAttributePrivate)
31{
32 d->mFrom = from;
33 d->mTo = to;
34 d->mCc = cc;
35 d->mBcc = bcc;
36 d->mDSN = dsn;
37}
38
40
41AddressAttribute *AddressAttribute::clone() const
42{
43 return new AddressAttribute(d->mFrom, d->mTo, d->mCc, d->mBcc, d->mDSN);
44}
45
46QByteArray AddressAttribute::type() const
47{
48 static const QByteArray sType("AddressAttribute");
49 return sType;
50}
51
52QByteArray AddressAttribute::serialized() const
53{
54 QByteArray serializedData;
55 QDataStream serializer(&serializedData, QIODevice::WriteOnly);
56 serializer.setVersion(QDataStream::Qt_4_5);
57 serializer << d->mFrom;
58 serializer << d->mTo;
59 serializer << d->mCc;
60 serializer << d->mBcc;
61 serializer << d->mDSN;
62 return serializedData;
63}
64
65void AddressAttribute::deserialize(const QByteArray &data)
66{
67 QDataStream deserializer(data);
68 deserializer.setVersion(QDataStream::Qt_4_5);
69 deserializer >> d->mFrom;
70 deserializer >> d->mTo;
71 deserializer >> d->mCc;
72 deserializer >> d->mBcc;
73 if (!deserializer.atEnd()) {
74 deserializer >> d->mDSN;
75 }
76}
77
79{
80 return d->mFrom;
81}
82
84{
85 d->mFrom = from;
86}
87
89{
90 return d->mTo;
91}
92
94{
95 d->mTo = to;
96}
97
99{
100 return d->mCc;
101}
102
104{
105 d->mCc = cc;
106}
107
109{
110 return d->mBcc;
111}
112
114{
115 d->mBcc = bcc;
116}
117
118bool AddressAttribute::deliveryStatusNotification() const
119{
120 return d->mDSN;
121}
122
123bool AddressAttribute::operator==(const AddressAttribute &other) const
124{
125 return d->mDSN == other.deliveryStatusNotification() && d->mBcc == other.bcc() && d->mTo == other.to() && d->mCc == other.cc() && d->mFrom == other.from();
126}
127
128void AddressAttribute::setDeliveryStatusNotification(bool b)
129{
130 d->mDSN = b;
131}
132
133// Register the attribute when the library is loaded.
134namespace
135{
136bool address_dummy()
137{
138 using namespace Akonadi;
140 return true;
141}
142
143const bool address_registered = address_dummy();
144}
Attribute storing the From, To, Cc, Bcc addresses of a message.
QStringList to() const
Returns the addresses of the "To:" receivers.
void setCc(const QStringList &cc)
Sets the addresses of the "Cc:" receivers.
AddressAttribute(const QString &from=QString(), const QStringList &to=QStringList(), const QStringList &cc=QStringList(), const QStringList &bcc=QStringList(), bool dsn=false)
Creates a new AddressAttribute.
void setBcc(const QStringList &bcc)
Sets the addresses of the "Bcc:" receivers.
void setFrom(const QString &from)
Sets the address of the sender.
void setTo(const QStringList &to)
Sets the addresses of the "To: "receivers.
QStringList cc() const
Returns the addresses of the "Cc:" receivers.
QStringList bcc() const
Returns the addresses of the "Bcc:" receivers.
QString from() const
Returns the address of the sender.
~AddressAttribute() override
Destroys the AddressAttribute.
static void registerAttribute()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:04:17 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.