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

mailtransport

  • mailtransport
sentbehaviourattribute.cpp
1 /*
2  Copyright 2009 Constantin Berzan <exit3219@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "sentbehaviourattribute.h"
21 
22 #include <QDataStream>
23 
24 #include <KDebug>
25 
26 using namespace Akonadi;
27 using namespace MailTransport;
28 
29 class SentBehaviourAttribute::Private
30 {
31  public:
32  SentBehaviour mBehaviour;
33  Akonadi::Collection mMoveToCollection;
34 };
35 
36 SentBehaviourAttribute::SentBehaviourAttribute( SentBehaviour beh, Collection moveToCollection )
37  : d( new Private )
38 {
39  d->mBehaviour = beh;
40  d->mMoveToCollection = moveToCollection;
41 }
42 
43 SentBehaviourAttribute::~SentBehaviourAttribute()
44 {
45  delete d;
46 }
47 
48 SentBehaviourAttribute *SentBehaviourAttribute::clone() const
49 {
50  return new SentBehaviourAttribute( d->mBehaviour, d->mMoveToCollection );
51 }
52 
53 QByteArray SentBehaviourAttribute::type() const
54 {
55  static const QByteArray sType( "SentBehaviourAttribute" );
56  return sType;
57 }
58 
59 QByteArray SentBehaviourAttribute::serialized() const
60 {
61  switch ( d->mBehaviour ) {
62  case Delete: return "delete";
63  case MoveToCollection: return "moveTo" + QByteArray::number( d->mMoveToCollection.id() );
64  case MoveToDefaultSentCollection: return "moveToDefault";
65  }
66 
67  Q_ASSERT( false );
68  return QByteArray();
69 }
70 
71 void SentBehaviourAttribute::deserialize( const QByteArray &data )
72 {
73  d->mMoveToCollection = Akonadi::Collection( -1 );
74  if ( data == "delete" ) {
75  d->mBehaviour = Delete;
76  } else if ( data == "moveToDefault" ) {
77  d->mBehaviour = MoveToDefaultSentCollection;
78  } else if ( data.startsWith( QByteArray( "moveTo" ) ) ) {
79  d->mBehaviour = MoveToCollection;
80  d->mMoveToCollection = Akonadi::Collection( data.mid( 6 ).toLongLong() );
81  // NOTE: 6 is the strlen of "moveTo".
82  } else {
83  Q_ASSERT( false );
84  }
85 }
86 
87 SentBehaviourAttribute::SentBehaviour SentBehaviourAttribute::sentBehaviour() const
88 {
89  return d->mBehaviour;
90 }
91 
92 void SentBehaviourAttribute::setSentBehaviour( SentBehaviour beh )
93 {
94  d->mBehaviour = beh;
95 }
96 
97 Collection SentBehaviourAttribute::moveToCollection() const
98 {
99  return d->mMoveToCollection;
100 }
101 
102 void SentBehaviourAttribute::setMoveToCollection( Collection moveToCollection )
103 {
104  d->mMoveToCollection = moveToCollection;
105 }
106 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:26:52 by doxygen 1.8.3.1 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.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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