MailTransport

resourcesendjob.cpp
1 /*
2  Copyright (c) 2009 Constantin Berzan <[email protected]>
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 "resourcesendjob_p.h"
21 #include "../messagequeuejob.h"
22 #include "transport.h"
23 
24 #include <kmime/kmime_message.h>
25 
26 #include <AkonadiCore/Collection>
27 #include <Akonadi/KMime/AddressAttribute>
28 
29 using namespace Akonadi;
30 using namespace KMime;
31 using namespace MailTransport;
32 
33 ResourceSendJob::ResourceSendJob(Transport *transport, QObject *parent)
34  : TransportJob(transport, parent)
35 {
36 }
37 
38 ResourceSendJob::~ResourceSendJob()
39 {
40 }
41 
42 void ResourceSendJob::doStart()
43 {
45  msg->setContent(data());
47  job->setMessage(msg);
48  job->transportAttribute().setTransportId(transport()->id());
49  // Default dispatch mode (send now).
50  // Move to default sent-mail collection.
52  job->addressAttribute().setTo(to());
53  job->addressAttribute().setCc(cc());
54  job->addressAttribute().setBcc(bcc());
55  addSubjob(job);
56  // Once the item is in the outbox, there is nothing more we can do.
57  connect(job, &KJob::result, this, &ResourceSendJob::slotEmitResult);
58  job->start();
59 }
60 
61 void ResourceSendJob::slotEmitResult()
62 {
63  // KCompositeJob took care of the error.
64  emitResult();
65 }
66 
67 #include "moc_resourcesendjob_p.cpp"
void setTo(const QStringList &to)
void setMessage(const KMime::Message::Ptr &message)
Sets the message to be sent.
void emitResult()
void setFrom(const QString &from)
QObject * sender() const const
Provides an interface for sending email.
void setBcc(const QStringList &bcc)
void setTransportId(int id)
Sets the transport id to use for sending this message.
TransportAttribute & transportAttribute()
Returns a reference to the transport attribute for this message.
QString to() const
void start() override
Creates the item and places it in the outbox.
Abstract base class for all mail transport jobs.
Definition: transportjob.h:40
Akonadi::AddressAttribute & addressAttribute()
Returns a reference to the address attribute for this message.
void setCc(const QStringList &cc)
void result(KJob *job)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents the settings of a specific mail transport.
Definition: transport.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 1 2020 23:10:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.