2023-02-11 20:49:42 +00:00
|
|
|
// This file Copyright © 2022-2023 Mnemosyne LLC.
|
2022-08-25 03:18:58 +00:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
2022-01-20 18:27:56 +00:00
|
|
|
// License text can be found in the licenses/ folder.
|
2010-05-01 16:04:00 +00:00
|
|
|
|
2017-11-14 20:21:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
2010-09-23 13:29:41 +00:00
|
|
|
#ifndef __TRANSMISSION__
|
2017-04-19 12:04:45 +00:00
|
|
|
#error only libtransmission should #include this header.
|
2010-09-23 13:29:41 +00:00
|
|
|
#endif
|
|
|
|
|
2022-08-24 21:03:30 +00:00
|
|
|
#include <ctime>
|
|
|
|
#include <memory>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
2010-05-01 16:04:00 +00:00
|
|
|
|
2022-08-24 21:03:30 +00:00
|
|
|
#include "transmission.h"
|
|
|
|
|
|
|
|
#include "net.h" // for tr_address, tr_port
|
|
|
|
|
|
|
|
struct event_base;
|
|
|
|
|
2022-10-01 14:12:49 +00:00
|
|
|
namespace libtransmission
|
|
|
|
{
|
|
|
|
class TimerMaker;
|
|
|
|
}
|
|
|
|
|
2022-08-24 21:03:30 +00:00
|
|
|
class tr_lpd
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
class Mediator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct TorrentInfo
|
|
|
|
{
|
|
|
|
std::string_view info_hash_str;
|
|
|
|
tr_torrent_activity activity;
|
|
|
|
bool allows_lpd;
|
|
|
|
time_t announce_after;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual ~Mediator() = default;
|
|
|
|
|
|
|
|
[[nodiscard]] virtual tr_port port() const = 0;
|
|
|
|
|
|
|
|
[[nodiscard]] virtual bool allowsLPD() const = 0;
|
|
|
|
|
|
|
|
[[nodiscard]] virtual std::vector<TorrentInfo> torrents() const = 0;
|
|
|
|
|
2022-10-01 14:12:49 +00:00
|
|
|
[[nodiscard]] virtual libtransmission::TimerMaker& timerMaker() = 0;
|
|
|
|
|
2022-08-24 21:03:30 +00:00
|
|
|
virtual void setNextAnnounceTime(std::string_view info_hash_str, time_t announce_at) = 0;
|
|
|
|
|
|
|
|
// returns true if info was used
|
|
|
|
virtual bool onPeerFound(std::string_view info_hash_str, tr_address address, tr_port port) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual ~tr_lpd() = default;
|
2022-10-01 14:12:49 +00:00
|
|
|
static std::unique_ptr<tr_lpd> create(Mediator& mediator, event_base* event_base);
|
2022-08-24 21:03:30 +00:00
|
|
|
};
|