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

mailtransport

  • mailtransport
dispatchmodeattribute.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 "dispatchmodeattribute.h"
21
22#include <KDebug>
23
24#include "akonadi/attributefactory.h"
25
26using namespace Akonadi;
27using namespace MailTransport;
28
29class DispatchModeAttribute::Private
30{
31 public:
32 DispatchMode mMode;
33 QDateTime mDueDate;
34};
35
36DispatchModeAttribute::DispatchModeAttribute( DispatchMode mode )
37 : d( new Private )
38{
39 d->mMode = mode;
40}
41
42DispatchModeAttribute::~DispatchModeAttribute()
43{
44 delete d;
45}
46
47DispatchModeAttribute *DispatchModeAttribute::clone() const
48{
49 DispatchModeAttribute * const cloned = new DispatchModeAttribute( d->mMode );
50 cloned->setSendAfter( d->mDueDate );
51 return cloned;
52}
53
54QByteArray DispatchModeAttribute::type() const
55{
56 static const QByteArray sType( "DispatchModeAttribute" );
57 return sType;
58}
59
60QByteArray DispatchModeAttribute::serialized() const
61{
62 switch ( d->mMode ) {
63 case Automatic:
64 {
65 if ( !d->mDueDate.isValid() ) {
66 return "immediately";
67 } else {
68 return "after" + d->mDueDate.toString( Qt::ISODate ).toLatin1();
69 }
70 }
71 case Manual: return "never";
72 }
73
74 Q_ASSERT( false );
75 return QByteArray(); // suppress control-reaches-end-of-non-void-function warning
76}
77
78void DispatchModeAttribute::deserialize( const QByteArray &data )
79{
80 d->mDueDate = QDateTime();
81 if ( data == "immediately" ) {
82 d->mMode = Automatic;
83 } else if ( data == "never" ) {
84 d->mMode = Manual;
85 } else if ( data.startsWith( QByteArray( "after" ) ) ) {
86 d->mMode = Automatic;
87 d->mDueDate = QDateTime::fromString( QString::fromLatin1( data.mid( 5 ) ), Qt::ISODate );
88 // NOTE: 5 is the strlen of "after".
89 } else {
90 kWarning() << "Failed to deserialize data [" << data << "]";
91 }
92}
93
94DispatchModeAttribute::DispatchMode DispatchModeAttribute::dispatchMode() const
95{
96 return d->mMode;
97}
98
99void DispatchModeAttribute::setDispatchMode( DispatchMode mode )
100{
101 d->mMode = mode;
102}
103
104QDateTime DispatchModeAttribute::sendAfter() const
105{
106 return d->mDueDate;
107}
108
109void DispatchModeAttribute::setSendAfter( const QDateTime &date )
110{
111 d->mDueDate = date;
112}
113
MailTransport::DispatchModeAttribute
Attribute determining how and when a message from the outbox should be dispatched.
Definition dispatchmodeattribute.h:40
MailTransport::DispatchModeAttribute::sendAfter
QDateTime sendAfter() const
Returns the date and time when the message should be sent.
Definition dispatchmodeattribute.cpp:104
MailTransport::DispatchModeAttribute::dispatchMode
DispatchMode dispatchMode() const
Returns the dispatch mode for the message.
Definition dispatchmodeattribute.cpp:94
MailTransport::DispatchModeAttribute::DispatchMode
DispatchMode
Determines how the message is sent.
Definition dispatchmodeattribute.h:45
MailTransport::DispatchModeAttribute::Automatic
@ Automatic
Send message as soon as possible, but no earlier than specified by setSendAfter()
Definition dispatchmodeattribute.h:46
MailTransport::DispatchModeAttribute::Manual
@ Manual
Send message only when the user requests so.
Definition dispatchmodeattribute.h:48
MailTransport::DispatchModeAttribute::setDispatchMode
void setDispatchMode(DispatchMode mode)
Sets the dispatch mode for the message.
Definition dispatchmodeattribute.cpp:99
MailTransport::DispatchModeAttribute::setSendAfter
void setSendAfter(const QDateTime &date)
Sets the date and time when the message should be sent.
Definition dispatchmodeattribute.cpp:109
MailTransport::DispatchModeAttribute::~DispatchModeAttribute
virtual ~DispatchModeAttribute()
Destroys the DispatchModeAttribute.
Definition dispatchmodeattribute.cpp:42
MailTransport::DispatchModeAttribute::DispatchModeAttribute
DispatchModeAttribute(DispatchMode mode=Automatic)
Creates a new DispatchModeAttribute.
Definition dispatchmodeattribute.cpp:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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