File indexing completed on 2025-01-19 03:53:14

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2018-06-29
0007  * Description : a tool to export images to Twitter social network
0008  *
0009  * SPDX-FileCopyrightText: 2018 by Tarek Talaat <tarektalaat93 at gmail dot com>
0010  * SPDX-FileCopyrightText: 2019 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_TWITTER_MPFORM_H
0017 #define DIGIKAM_TWITTER_MPFORM_H
0018 
0019 // Qt includes
0020 
0021 #include <QByteArray>
0022 #include <QString>
0023 #include <QList>
0024 
0025 #define MAX_MEDIA_SIZE 1048576
0026 
0027 namespace DigikamGenericTwitterPlugin
0028 {
0029 
0030 class TwMPForm
0031 {
0032 
0033 public:
0034 
0035     explicit TwMPForm();
0036     ~TwMPForm();
0037 
0038     void reset();
0039     QByteArray fileHeader(const QString& imgPath);
0040     bool addFile(const QString& imgPath, bool fragmented = false);
0041     QByteArray createPair(const QByteArray& name, const QByteArray& value);
0042     bool addPair(const QByteArray& pair);
0043     void finish();
0044     QByteArray border();
0045 
0046     int numberOfChunks()           const;
0047     QString contentType()          const;
0048     QByteArray formData()          const;
0049     QByteArray getChunk(int index) const;
0050 
0051 private:
0052 
0053     void formChunks(const QByteArray& data);
0054 
0055 private:
0056 
0057     QByteArray        m_buffer;
0058     QByteArray        m_boundary;
0059     QList<QByteArray> m_chunks;
0060 };
0061 
0062 } // namespace DigikamGenericTwitterPlugin
0063 
0064 #endif // DIGIKAM_TWITTER_MPFORM_H