digiKam
vkontakte_uploadphotosjob.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_UPLOADPHOTOSJOB_H
25 #define DIGIKAM_VKONTAKTE_UPLOADPHOTOSJOB_H
26 
27 // Qt includes
28 
29 #include <QVariantMap>
30 
31 // Local includes
32 
33 #include "vkontakte_jobs.h"
34 #include "vkontakte_photoinfo.h"
35 
36 namespace Vkontakte
37 {
38 
39 class UploadPhotosJob : public KJobWithSubjobs
40 {
41  Q_OBJECT
42 
43 public:
44 
45  enum Dest
46  {
47  DEST_ALBUM = 1,
48  DEST_PROFILE,
49  DEST_WALL
50  };
51 
52  explicit UploadPhotosJob(const QString& accessToken,
53  const QStringList& files, bool saveBig, int aid, int gid = -1);
54  ~UploadPhotosJob() override;
55 
56  void start() override;
57 
58  QList<PhotoInfo> list() const;
59 
60 protected:
61 
62  static const int MAX_POST_JOBS;
63  static const int REQUEST_FILES_COUNT;
64 
65 protected:
66 
67  int getMaxRequestFilesCount() const;
68 
69  bool mayStartPostJob();
70 
71  void startPostJob(int offset, int count);
72  void startSaveJob(const QVariantMap& photoIdData);
73 
74 Q_SIGNALS:
75 
76  void progress(int);
77 
78 private Q_SLOTS:
79 
80  void serverJobFinished(KJob*);
81  void postJobFinished(KJob*);
82  void saveJobFinished(KJob*);
83 
84 private:
85 
86  // Disable
87  UploadPhotosJob(QObject*) = delete;
88 
89 private:
90 
91  class Private;
92  Private* const d;
93 };
94 
95 } // namespace Vkontakte
96 
97 #endif // DIGIKAM_VKONTAKTE_UPLOADPHOTOSJOB_H
Definition: piwigotalker.h:48