Messagelib

messagesender.h
1/*
2 messagesender.h
3
4 This file is part of KMail, the KDE mail client
5 SPDX-FileCopyrightText: 2005 Klarälvdalens Datakonsult AB
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include <KMime/Message>
13namespace MessageComposer
14{
15class MessageSender
16{
17 Q_GADGET
18protected:
19 virtual ~MessageSender() = 0;
20
21public:
22 enum SendMethod {
23 SendDefault = -1,
24 SendImmediate = true,
25 SendLater = false,
26 };
27 Q_ENUM(SendMethod)
28
29 enum SaveIn : uint8_t {
30 SaveInNone,
31 SaveInDrafts,
32 SaveInTemplates,
33 SaveInOutbox,
34 };
35 Q_ENUM(SaveIn)
36
37 /**
38 Send given message.
39
40 The message is either queued (@p method == SendLater) or sent
41 immediately (@p method = SendImmediate). The default behaviour,
42 as selected with setSendImmediate(), can be overwritten with the
43 parameter @p method. The sender takes ownership of the given
44 message on success, so DO NOT DELETE OR MODIFY the message
45 further.
46
47 @return true on success.
48 */
49 [[nodiscard]] bool send(const KMime::Message::Ptr &msg, SendMethod method = SendDefault)
50 {
51 return doSend(msg, method);
52 }
53
54 /**
55 Start sending all queued messages.
56
57 FIXME: what does success mean here, if it's only _start_ sending?
58
59 Optionally a transport can be specified that will be used as the
60 default transport.
61
62 @return true on success.
63 */
64 [[nodiscard]] bool sendQueued(int transportId = -1)
65 {
66 return doSendQueued(transportId);
67 }
68
69protected:
70 [[nodiscard]] virtual bool doSend(const KMime::Message::Ptr &msg, short sendNow) = 0;
71 [[nodiscard]] virtual bool doSendQueued(int transportId) = 0;
72};
73
74inline MessageSender::~MessageSender() = default;
75}
QSharedPointer< Message > Ptr
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 12:05:41 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.