Messagelib

contentjobbase.h
1/*
2 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
3
4 Based on ideas by Stephen Kelly.
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#pragma once
10
11#include "jobbase.h"
12#include "messagecomposer_export.h"
13
14namespace KMime
15{
16class Content;
17}
18
19namespace MessageComposer
20{
21class ContentJobBasePrivate;
22/**
23 * @brief The ContentJobBase class
24 */
25class MESSAGECOMPOSER_EXPORT ContentJobBase : public JobBase
26{
27 Q_OBJECT
28
29public:
30 explicit ContentJobBase(QObject *parent = nullptr);
31 ~ContentJobBase() override;
32
33 /**
34 Starts processing this ContentJobBase asynchronously.
35 This processes all children in order first, then calls process().
36 Emits finished() after all processing is done, and the
37 content is reachable through content().
38 */
39 void start() override;
40
41 /**
42 Get the resulting KMime::Content that the ContentJobBase has generated.
43 Jobs never delete their content.
44 */
45 [[nodiscard]] KMime::Content *content() const;
46
47 /**
48 This is meant to be used instead of KCompositeJob::addSubjob(), making
49 it possible to add subjobs from the outside.
50 Transfers ownership of the @p job to this object.
51 */
52 bool appendSubjob(ContentJobBase *job);
53
54 /**
55 Set some extra content to be saved with the job, and available
56 later, for example, in slot handling result of job.
57 Job does not take care of deleting extra content.
58 */
59 void setExtraContent(KMime::Content *extra);
60
61 /**
62 Get extra content that was previously added.
63 */
64 [[nodiscard]] KMime::Content *extraContent() const;
65
66protected:
67 ContentJobBase(ContentJobBasePrivate &dd, QObject *parent);
68
69 /** Use appendSubjob() instead. */
70 bool addSubjob(KJob *job) override;
71
72protected Q_SLOTS:
73 /**
74 Reimplement to do additional stuff before processing children, such as
75 adding more subjobs. Remember to call the base implementation.
76 */
77 virtual void doStart();
78
79 /**
80 This is called after all the children have been processed.
81 (You must use their resulting contents, or delete them.)
82 Reimplement in subclasses to process concrete content. Call
83 emitResult() when finished.
84 */
85 virtual void process() = 0;
86
87 void slotResult(KJob *job) override;
88
89private:
90 Q_DECLARE_PRIVATE(ContentJobBase)
91};
92} // namespace MessageComposer
The ContentJobBase class.
virtual void process()=0
This is called after all the children have been processed.
A dummy abstract class defining some errors pertaining to the Composer.
Definition jobbase.h:25
Q_SCRIPTABLE Q_NOREPLY void start()
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-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.