File indexing completed on 2025-01-19 03:52:45

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2004-02-25
0007  * Description : a tool to e-mailing images
0008  *
0009  * SPDX-FileCopyrightText: 2004-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_MAIL_PROCESS_H
0016 #define DIGIKAM_MAIL_PROCESS_H
0017 
0018 // Qt includes
0019 
0020 #include <QObject>
0021 
0022 // Local includes
0023 
0024 #include "mailsettings.h"
0025 #include "dinfointerface.h"
0026 
0027 using namespace Digikam;
0028 
0029 namespace DigikamGenericSendByMailPlugin
0030 {
0031 
0032 class MailProcess : public QObject
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037 
0038     explicit MailProcess(MailSettings* const settings,
0039                          DInfoInterface* const iface,
0040                          QObject* const parent);
0041     ~MailProcess() override;
0042 
0043     void firstStage();
0044 
0045 Q_SIGNALS:
0046 
0047     void signalProgress(int);
0048     void signalMessage(QString, bool);
0049     void signalDone(bool);
0050 
0051 public Q_SLOTS:
0052 
0053     void slotCancel();
0054 
0055 private Q_SLOTS:
0056 
0057     void slotStartingResize(const QUrl&);
0058     void slotFinishedResize(const QUrl&, const QUrl&, int);
0059     void slotFailedResize(const QUrl&, const QString&, int);
0060     void slotCompleteResize();
0061     void slotCleanUp();
0062 
0063 private:
0064 
0065     void secondStage();
0066     void invokeMailAgentError(const QString& prog, const QStringList& args);
0067     void invokeMailAgentDone(const QString& prog, const QStringList& args);
0068 
0069     /**
0070      * Creates a text file with all images Comments, Tags, and Rating.
0071      */
0072     void buildPropertiesFile();
0073 
0074     /**
0075      * Invokes mail agent. Depending on which mail agent to be used, we have different
0076      * proceedings. Easy for every agent except of mozilla derivates
0077      */
0078     bool invokeMailAgent();
0079 
0080     /**
0081      * Shows up an error dialog about the problematic resized images.
0082      */
0083     bool showFailedResizedImages() const;
0084 
0085     /**
0086      * Returns a list of image urls, whose sum file-size is smaller than the quota set in dialog.
0087      * The returned list are images than we can send immediately, and are removed from
0088      * d->attachementFiles list.
0089      * Files which still in d->attachementFiles need to be send by another pass.
0090      */
0091     QList<QUrl> divideEmails();
0092 
0093 private:
0094 
0095     class Private;
0096     Private* const d;
0097 };
0098 
0099 } // namespace DigikamGenericSendByMailPlugin
0100 
0101 #endif // DIGIKAM_MAIL_PROCESS_H