MailTransport

resourcesendjob.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Constantin Berzan <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "../messagequeuejob.h"
8 #include "resourcesendjob_p.h"
9 #include "transport.h"
10 
11 #include <KMime/KMimeMessage>
12 
13 #include <Akonadi/AddressAttribute>
14 #include <Akonadi/Collection>
15 
16 using namespace Akonadi;
17 using namespace KMime;
18 using namespace MailTransport;
19 
20 ResourceSendJob::ResourceSendJob(Transport *transport, QObject *parent)
21  : TransportJob(transport, parent)
22 {
23 }
24 
25 ResourceSendJob::~ResourceSendJob() = default;
26 
27 void ResourceSendJob::doStart()
28 {
30  msg->setContent(data());
31  auto job = new MessageQueueJob;
32  job->setMessage(msg);
33  job->transportAttribute().setTransportId(transport()->id());
34  // Default dispatch mode (send now).
35  // Move to default sent-mail collection.
36  job->addressAttribute().setFrom(sender());
37  job->addressAttribute().setTo(to());
38  job->addressAttribute().setCc(cc());
39  job->addressAttribute().setBcc(bcc());
40  addSubjob(job);
41  // Once the item is in the outbox, there is nothing more we can do.
42  connect(job, &KJob::result, this, &ResourceSendJob::slotEmitResult);
43  job->start();
44 }
45 
46 void ResourceSendJob::slotEmitResult()
47 {
48  // KCompositeJob took care of the error.
49  emitResult();
50 }
51 
52 #include "moc_resourcesendjob_p.cpp"
Abstract base class for all mail transport jobs.
Definition: transportjob.h:30
Provides an interface for sending email.
void result(KJob *job)
Represents the settings of a specific mail transport.
Definition: transport.h:32
void setMessage(const KMime::Message::Ptr &message)
Sets the message to be sent.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 23 2023 04:19:12 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.