File indexing completed on 2025-01-05 03:53:41

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2011-04-12
0007  * Description : A tool to export items to Rajce web service
0008  *
0009  * SPDX-FileCopyrightText: 2011      by Lukas Krejci <krejci.l at centrum dot cz>
0010  * SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_RAJCE_TALKER_H
0017 #define DIGIKAM_RAJCE_TALKER_H
0018 
0019 // Qt includes
0020 
0021 #include <QObject>
0022 #include <QString>
0023 #include <QSharedPointer>
0024 
0025 // Local includes
0026 
0027 #include "rajcesession.h"
0028 
0029 class QWidget;
0030 class QNetworkReply;
0031 
0032 namespace DigikamGenericRajcePlugin
0033 {
0034 
0035 class RajceCommand;
0036 
0037 class RajceTalker : public QObject
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042 
0043     explicit RajceTalker(QWidget* const parent);
0044     ~RajceTalker() override;
0045 
0046 public:
0047 
0048     void  init(const RajceSession& initialState);
0049     const RajceSession& session() const;
0050     void  login(const QString& username, const QString& password);
0051     void  logout();
0052 
0053     void  loadAlbums();
0054     void  createAlbum(const QString& name, const QString& description, bool visible);
0055     void  openAlbum(const RajceAlbum& album);
0056     void  closeAlbum();
0057 
0058     void  uploadPhoto(const QString& path, unsigned dimension, int jpgQuality);
0059 
0060     void  clearLastError();
0061     void  cancelCurrentCommand();
0062 
0063 Q_SIGNALS:
0064 
0065     void signalBusyStarted(unsigned);
0066     void signalBusyFinished(unsigned);
0067     void signalBusyProgress(unsigned, unsigned percent);
0068 
0069 private Q_SLOTS:
0070 
0071     void slotFinished(QNetworkReply* reply);
0072     void slotUploadProgress(qint64 bytesSent, qint64 bytesTotal);
0073 
0074 private:
0075 
0076     void startCommand(const QSharedPointer<RajceCommand>&);
0077     void enqueueCommand(const QSharedPointer<RajceCommand>&);
0078 
0079 private:
0080 
0081     class Private;
0082     Private* const d;
0083 };
0084 
0085 } // namespace DigikamGenericRajcePlugin
0086 
0087 #endif // DIGIKAM_RAJCE_TALKER_H