digiKam
vkontakte_photopostjob.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 : 2011-02-19
7  * Description : a tool to export images to VKontakte web service
8  *
9  * Copyright (C) 2011-2015 by Alexander Potashev <aspotashev at gmail dot com>
10  * Copyright (C) 2011-2022 by Gilles Caulier <caulier dot gilles 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_VKONTAKTE_PHOTOPOSTJOB_H
25 #define DIGIKAM_VKONTAKTE_PHOTOPOSTJOB_H
26 
27 // Qt includes
28 
29 #include <QStringList>
30 #include <QVariantMap>
31 
32 // Local includes
33 
34 #include "vkontakte_jobs.h"
36 
37 class QHttpMultiPart;
38 class QNetworkReply;
39 
40 namespace Vkontakte
41 {
42 
43 // This class is not exported, so:
44 // - we don't care about ABI of this class (not using Pimpl)
45 // - library's users should use class UploadPhotosJob
46 class PhotoPostJob : public KJob
47 {
48  Q_OBJECT
49 
50 public:
51 
52  // files.size <= 5
53  explicit PhotoPostJob(Vkontakte::UploadPhotosJob::Dest dest,
54  const QUrl& url,
55  const QStringList& files);
56 
57  void start() override;
58  QVariantMap response() const;
59 
60 protected:
61 
65  void handleError(const QJsonValue& data);
66 
67 private Q_SLOTS:
68 
69  void parseNetworkResponse(QNetworkReply* reply);
70 
71 private:
72 
73  bool appendFile(QHttpMultiPart* multiPart, const QString& header, const QString& path);
74 
75 private:
76 
77  UploadPhotosJob::Dest m_dest;
78  QUrl m_url;
79  QStringList m_files;
80  bool m_ok;
81  QVariantMap m_response;
82 
83 private:
84 
85  // Disable
86  explicit PhotoPostJob(QObject*) = delete;
87 };
88 
89 } // namespace Vkontakte
90 
91 #endif // DIGIKAM_VKONTAKTE_PHOTOPOSTJOB_H