Provide torrent creation feature via WebAPI

PR #20366.
Closes #5614.

Co-authored-by: Radu Carpa <radu.carpa@cern.ch>
This commit is contained in:
Vladimir Golovnev
2024-02-27 15:57:16 +03:00
committed by GitHub
parent 15697f904d
commit 0114610a40
17 changed files with 887 additions and 83 deletions

View File

@@ -1,6 +1,7 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014, 2017, 2022-2023 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2014-2024 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2024 Radu Carpa <radu.carpa@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -62,6 +63,11 @@ class AuthController;
class FreeDiskSpaceChecker;
class WebApplication;
namespace BitTorrent
{
class TorrentCreationManager;
}
class WebSession final : public ApplicationComponent<QObject>, public ISession
{
public:
@@ -72,15 +78,7 @@ public:
bool hasExpired(qint64 seconds) const;
void updateTimestamp();
template <typename T>
T *registerAPIController(const QString &scope)
{
static_assert(std::is_base_of_v<APIController, T>, "Class should be derived from APIController.");
auto *controller = new T(app(), this);
m_apiControllers[scope] = controller;
return controller;
}
void registerAPIController(const QString &scope, APIController *controller);
APIController *getAPIController(const QString &scope) const;
private:
@@ -172,6 +170,8 @@ private:
{{u"search"_s, u"stop"_s}, Http::METHOD_POST},
{{u"search"_s, u"uninstallPlugin"_s}, Http::METHOD_POST},
{{u"search"_s, u"updatePlugins"_s}, Http::METHOD_POST},
{{u"torrentcreator"_s, u"addTask"_s}, Http::METHOD_POST},
{{u"torrentcreator"_s, u"deleteTask"_s}, Http::METHOD_POST},
{{u"torrents"_s, u"add"_s}, Http::METHOD_POST},
{{u"torrents"_s, u"addPeers"_s}, Http::METHOD_POST},
{{u"torrents"_s, u"addTags"_s}, Http::METHOD_POST},
@@ -254,4 +254,5 @@ private:
Utils::Thread::UniquePtr m_workerThread;
FreeDiskSpaceChecker *m_freeDiskSpaceChecker = nullptr;
QTimer *m_freeDiskSpaceCheckingTimer = nullptr;
BitTorrent::TorrentCreationManager *m_torrentCreationManager = nullptr;
};