• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

mailtransport

  • mailtransport
sentactionattribute.cpp
1/*
2 Copyright (C) 2010 Klarälvdalens Datakonsult AB,
3 a KDAB Group company, info@kdab.net,
4 author Tobias Koenig <tokoe@kdab.com>
5
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Library General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
10
11 This library is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301, USA.
20*/
21
22#include "sentactionattribute.h"
23
24#include <QtCore/QDataStream>
25#include <QtCore/QSharedData>
26
27using namespace Akonadi;
28using namespace MailTransport;
29
30class SentActionAttribute::Action::Private : public QSharedData
31{
32 public:
33 Private()
34 : mType( Invalid )
35 {
36 }
37
38 Private( const Private &other )
39 : QSharedData( other )
40 {
41 mType = other.mType;
42 mValue = other.mValue;
43 }
44
45 Type mType;
46 QVariant mValue;
47};
48
49SentActionAttribute::Action::Action()
50 : d( new Private )
51{
52}
53
54SentActionAttribute::Action::Action( Type type, const QVariant &value )
55 : d( new Private )
56{
57 d->mType = type;
58 d->mValue = value;
59}
60
61SentActionAttribute::Action::Action( const Action &other )
62 : d( other.d )
63{
64}
65
66SentActionAttribute::Action::~Action()
67{
68}
69
70SentActionAttribute::Action::Type SentActionAttribute::Action::type() const
71{
72 return d->mType;
73}
74
75QVariant SentActionAttribute::Action::value() const
76{
77 return d->mValue;
78}
79
80SentActionAttribute::Action &SentActionAttribute::Action::operator=( const Action &other )
81{
82 if ( this != &other ) {
83 d = other.d;
84 }
85
86 return *this;
87}
88
89bool SentActionAttribute::Action::operator==( const Action &other ) const
90{
91 return ( ( d->mType == other.d->mType ) && ( d->mValue == other.d->mValue ) );
92}
93
94class SentActionAttribute::Private
95{
96 public:
97 Action::List mActions;
98};
99
100SentActionAttribute::SentActionAttribute()
101 : d( new Private )
102{
103}
104
105SentActionAttribute::~SentActionAttribute()
106{
107 delete d;
108}
109
110void SentActionAttribute::addAction( Action::Type type, const QVariant &value )
111{
112 d->mActions.append( Action( type, value ) );
113}
114
115SentActionAttribute::Action::List SentActionAttribute::actions() const
116{
117 return d->mActions;
118}
119
120SentActionAttribute *SentActionAttribute::clone() const
121{
122 SentActionAttribute *attribute = new SentActionAttribute;
123 attribute->d->mActions = d->mActions;
124
125 return attribute;
126}
127
128QByteArray SentActionAttribute::type() const
129{
130 static const QByteArray sType( "SentActionAttribute" );
131 return sType;
132}
133
134QByteArray SentActionAttribute::serialized() const
135{
136 QVariantList list;
137 foreach ( const Action &action, d->mActions ) {
138 QVariantMap map;
139 map.insert( QString::number( action.type() ), action.value() );
140
141 list << QVariant( map );
142 }
143
144 QByteArray data;
145 QDataStream stream( &data, QIODevice::WriteOnly );
146 stream.setVersion( QDataStream::Qt_4_6 );
147 stream << list;
148
149 return data;
150}
151
152void SentActionAttribute::deserialize( const QByteArray &data )
153{
154 d->mActions.clear();
155
156 QDataStream stream( data );
157 stream.setVersion( QDataStream::Qt_4_6 );
158
159 QVariantList list;
160 stream >> list;
161
162 foreach ( const QVariant &variant, list ) {
163 const QVariantMap map = variant.toMap();
164 QMapIterator<QString, QVariant> it( map );
165 while ( it.hasNext() ) {
166 it.next();
167 d->mActions << Action( static_cast<Action::Type>( it.key().toInt() ), it.value() );
168 }
169 }
170}
MailTransport::SentActionAttribute::Action
A sent action.
Definition: sentactionattribute.h:50
MailTransport::SentActionAttribute::Action::List
QList< Action > List
Describes a list of sent actions.
Definition: sentactionattribute.h:64
MailTransport::SentActionAttribute::Action::Type
Type
Describes the action type.
Definition: sentactionattribute.h:55
MailTransport::SentActionAttribute::Action::Invalid
@ Invalid
An invalid action.
Definition: sentactionattribute.h:56
MailTransport::SentActionAttribute::Action::operator=
Action & operator=(const Action &other)
Definition: sentactionattribute.cpp:80
MailTransport::SentActionAttribute::Action::Action
Action()
Creates a new invalid action.
Definition: sentactionattribute.cpp:49
MailTransport::SentActionAttribute::Action::operator==
bool operator==(const Action &other) const
Definition: sentactionattribute.cpp:89
MailTransport::SentActionAttribute::Action::value
QVariant value() const
Returns the argument value of the action.
Definition: sentactionattribute.cpp:75
MailTransport::SentActionAttribute::Action::type
Type type() const
Returns the type of the action.
Definition: sentactionattribute.cpp:70
MailTransport::SentActionAttribute::Action::~Action
~Action()
Destroys the action.
Definition: sentactionattribute.cpp:66
MailTransport::SentActionAttribute
An Attribute that stores the action to execute after sending.
Definition: sentactionattribute.h:44
MailTransport::SentActionAttribute::actions
Action::List actions() const
Returns the list of actions.
Definition: sentactionattribute.cpp:115
MailTransport::SentActionAttribute::SentActionAttribute
SentActionAttribute()
Creates a new sent action attribute.
Definition: sentactionattribute.cpp:100
MailTransport::SentActionAttribute::~SentActionAttribute
virtual ~SentActionAttribute()
Destroys the sent action attribute.
Definition: sentactionattribute.cpp:105
MailTransport::SentActionAttribute::addAction
void addAction(Action::Type type, const QVariant &value)
Adds a new action to the attribute.
Definition: sentactionattribute.cpp:110
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailtransport

Skip menu "mailtransport"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal