digiKam
twittermpform.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2018-06-29
7  * Description : a tool to export images to Twitter social network
8  *
9  * Copyright (C) 2018 by Tarek Talaat <tarektalaat93 at gmail dot com>
10  * Copyright (C) 2019 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_TWITTER_MPFORM_H
25 #define DIGIKAM_TWITTER_MPFORM_H
26 
27 // Qt includes
28 
29 #include <QByteArray>
30 #include <QString>
31 #include <QList>
32 
33 #define MAX_MEDIA_SIZE 1048576
34 
36 {
37 
38 class TwMPForm
39 {
40 
41 public:
42 
43  explicit TwMPForm();
44  ~TwMPForm();
45 
46  void reset();
47  QByteArray fileHeader(const QString& imgPath);
48  bool addFile(const QString& imgPath, bool fragmented = false);
49  QByteArray createPair(const QByteArray& name, const QByteArray& value);
50  bool addPair(const QByteArray& pair);
51  void finish();
52  QByteArray border();
53 
54  int numberOfChunks() const;
55  QString contentType() const;
56  QByteArray formData() const;
57  QByteArray getChunk(int index) const;
58 
59 private:
60 
61  void formChunks(const QByteArray& data);
62 
63 private:
64 
65  QByteArray m_buffer;
66  QByteArray m_boundary;
67  QList<QByteArray> m_chunks;
68 };
69 
70 } // namespace DigikamGenericTwitterPlugin
71 
72 #endif // DIGIKAM_TWITTER_MPFORM_H
Definition: twittermpform.h:39
QByteArray fileHeader(const QString &imgPath)
Definition: twittermpform.cpp:79
~TwMPForm()
Definition: twittermpform.cpp:47
QByteArray getChunk(int index) const
Definition: twittermpform.cpp:117
bool addFile(const QString &imgPath, bool fragmented=false)
Definition: twittermpform.cpp:92
QByteArray formData() const
Definition: twittermpform.cpp:145
int numberOfChunks() const
Definition: twittermpform.cpp:171
bool addPair(const QByteArray &pair)
Definition: twittermpform.cpp:72
QByteArray createPair(const QByteArray &name, const QByteArray &value)
Definition: twittermpform.cpp:57
TwMPForm()
Definition: twittermpform.cpp:41
QByteArray border()
Definition: twittermpform.cpp:130
void reset()
Definition: twittermpform.cpp:51
void finish()
Definition: twittermpform.cpp:140
QString contentType() const
Definition: twittermpform.cpp:122
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: twitteritem.h:31