File indexing completed on 2025-03-09 04:54:12
0001 /* 0002 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "messagecore_export.h" 0010 0011 #include "attachmentpart.h" 0012 0013 #include <KJob> 0014 #include <memory> 0015 0016 namespace MessageCore 0017 { 0018 /** 0019 * @short A job to compress the attachment of an email. 0020 * 0021 * @author Constantin Berzan <exit3219@gmail.com> 0022 */ 0023 class MESSAGECORE_EXPORT AttachmentCompressJob : public KJob 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 /** 0029 * Creates a new attachment compress job. 0030 * 0031 * @param part The part of the attachment to compress. 0032 * @param parent The parent object. 0033 */ 0034 explicit AttachmentCompressJob(const AttachmentPart::Ptr &part, QObject *parent = nullptr); 0035 0036 /** 0037 * Destroys the attachment compress job. 0038 */ 0039 ~AttachmentCompressJob() override; 0040 0041 /** 0042 * Starts the attachment compress job. 0043 */ 0044 void start() override; 0045 0046 /** 0047 * Sets the original @p part of the compressed attachment. 0048 */ 0049 void setOriginalPart(const AttachmentPart::Ptr &part); 0050 0051 /** 0052 * Returns the original part of the compressed attachment. 0053 */ 0054 [[nodiscard]] const AttachmentPart::Ptr originalPart() const; 0055 0056 /** 0057 * Returns the compressed part of the attachment. 0058 * 0059 * @note does not delete it unless it failed... 0060 */ 0061 [[nodiscard]] AttachmentPart::Ptr compressedPart() const; 0062 0063 /** 0064 * Returns whether the compressed part is larger than the original part. 0065 */ 0066 [[nodiscard]] bool isCompressedPartLarger() const; 0067 0068 private: 0069 //@cond PRIVATE 0070 class AttachmentCompressJobPrivate; 0071 std::unique_ptr<AttachmentCompressJobPrivate> const d; 0072 //@endcond 0073 }; 0074 }