File indexing completed on 2025-01-05 04:29:53

0001 /**
0002  * SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QNetworkRequest>
0010 #include <QObject>
0011 #include <QString>
0012 #include <QVector>
0013 
0014 #include "sync/sync.h"
0015 #include "sync/syncutils.h"
0016 
0017 class LoginRequest;
0018 class LogoutRequest;
0019 class DeviceRequest;
0020 class UpdateDeviceRequest;
0021 class SyncRequest;
0022 class UpdateSyncRequest;
0023 class SubscriptionRequest;
0024 class UploadSubscriptionRequest;
0025 class EpisodeActionRequest;
0026 class UploadEpisodeActionRequest;
0027 
0028 class GPodder : public QObject
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     GPodder(const QString &username, const QString &password, QObject *parent = nullptr);
0034     GPodder(const QString &username, const QString &password, const QString &hostname, const SyncUtils::Provider provider, QObject *parent = nullptr);
0035 
0036     LoginRequest *login();
0037     LogoutRequest *logout();
0038     DeviceRequest *getDevices();
0039     UpdateDeviceRequest *updateDevice(const QString &id, const QString &caption, const QString &type = QStringLiteral("other"));
0040     SyncRequest *getSyncStatus();
0041     UpdateSyncRequest *updateSyncStatus(const QVector<QStringList> &syncedDevices, const QStringList &unsyncedDevices);
0042     SubscriptionRequest *getSubscriptionChanges(const qulonglong &oldtimestamp, const QString &device);
0043     UploadSubscriptionRequest *uploadSubscriptionChanges(const QStringList &add, const QStringList &remove, const QString &device);
0044     EpisodeActionRequest *getEpisodeActions(const qulonglong &timestamp, bool aggregated = false);
0045     UploadEpisodeActionRequest *uploadEpisodeActions(const QVector<SyncUtils::EpisodeAction> &episodeActions);
0046 
0047 private:
0048     QString baseUrl();
0049     void addAuthentication(QNetworkRequest &request);
0050 
0051     QString m_username;
0052     QString m_password;
0053     QString m_hostname = QLatin1String("https://gpodder.net");
0054     SyncUtils::Provider m_provider = SyncUtils::Provider::GPodderNet;
0055 };