mailtransport
sentbehaviourattribute.cpp
00001 /* 00002 Copyright 2009 Constantin Berzan <exit3219@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #include "sentbehaviourattribute.h" 00021 00022 #include <QDataStream> 00023 00024 #include <KDebug> 00025 00026 using namespace Akonadi; 00027 using namespace MailTransport; 00028 00029 class SentBehaviourAttribute::Private 00030 { 00031 public: 00032 SentBehaviour mBehaviour; 00033 Akonadi::Collection mMoveToCollection; 00034 }; 00035 00036 SentBehaviourAttribute::SentBehaviourAttribute( SentBehaviour beh, Collection moveToCollection ) 00037 : d( new Private ) 00038 { 00039 d->mBehaviour = beh; 00040 d->mMoveToCollection = moveToCollection; 00041 } 00042 00043 SentBehaviourAttribute::~SentBehaviourAttribute() 00044 { 00045 delete d; 00046 } 00047 00048 SentBehaviourAttribute *SentBehaviourAttribute::clone() const 00049 { 00050 return new SentBehaviourAttribute( d->mBehaviour, d->mMoveToCollection ); 00051 } 00052 00053 QByteArray SentBehaviourAttribute::type() const 00054 { 00055 static const QByteArray sType( "SentBehaviourAttribute" ); 00056 return sType; 00057 } 00058 00059 QByteArray SentBehaviourAttribute::serialized() const 00060 { 00061 switch( d->mBehaviour ) { 00062 case Delete: return "delete"; 00063 case MoveToCollection: return "moveTo" + QByteArray::number( d->mMoveToCollection.id() ); 00064 case MoveToDefaultSentCollection: return "moveToDefault"; 00065 } 00066 00067 Q_ASSERT( false ); 00068 return QByteArray(); 00069 } 00070 00071 void SentBehaviourAttribute::deserialize( const QByteArray &data ) 00072 { 00073 d->mMoveToCollection = Akonadi::Collection( -1 ); 00074 if ( data == "delete" ) { 00075 d->mBehaviour = Delete; 00076 } else if ( data == "moveToDefault" ) { 00077 d->mBehaviour = MoveToDefaultSentCollection; 00078 } else if ( data.startsWith( QByteArray( "moveTo" ) ) ) { 00079 d->mBehaviour = MoveToCollection; 00080 d->mMoveToCollection = Akonadi::Collection( data.mid( 6 ).toLongLong() ); 00081 // NOTE: 6 is the strlen of "moveTo". 00082 } else { 00083 Q_ASSERT( false ); 00084 } 00085 } 00086 00087 SentBehaviourAttribute::SentBehaviour SentBehaviourAttribute::sentBehaviour() const 00088 { 00089 return d->mBehaviour; 00090 } 00091 00092 void SentBehaviourAttribute::setSentBehaviour( SentBehaviour beh ) 00093 { 00094 d->mBehaviour = beh; 00095 } 00096 00097 Collection SentBehaviourAttribute::moveToCollection() const 00098 { 00099 return d->mMoveToCollection; 00100 } 00101 00102 void SentBehaviourAttribute::setMoveToCollection( Collection moveToCollection ) 00103 { 00104 d->mMoveToCollection = moveToCollection; 00105 } 00106
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:02 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:02 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.