2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright 2021-2022 Mnemosyne LLC.
|
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0), GPLv3 (SPDX: GPL-3.0),
|
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2021-11-10 02:42:18 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "transmission.h"
|
|
|
|
|
2021-12-14 20:59:40 +00:00
|
|
|
#include "announce-list.h"
|
2021-11-10 02:42:18 +00:00
|
|
|
|
2021-12-15 21:25:42 +00:00
|
|
|
struct tr_error;
|
2021-11-18 00:17:09 +00:00
|
|
|
struct tr_variant;
|
|
|
|
|
2021-12-25 21:21:13 +00:00
|
|
|
class tr_magnet_metainfo
|
2021-11-10 02:42:18 +00:00
|
|
|
{
|
2021-12-25 21:21:13 +00:00
|
|
|
public:
|
2021-11-10 02:42:18 +00:00
|
|
|
bool parseMagnet(std::string_view magnet_link, tr_error** error = nullptr);
|
2022-02-13 04:16:55 +00:00
|
|
|
|
2021-11-10 02:42:18 +00:00
|
|
|
std::string magnet() const;
|
2021-12-25 21:21:13 +00:00
|
|
|
|
|
|
|
auto const& infoHash() const
|
|
|
|
{
|
|
|
|
return info_hash_;
|
|
|
|
}
|
2022-02-24 21:52:29 +00:00
|
|
|
|
2021-12-25 21:21:13 +00:00
|
|
|
auto const& name() const
|
|
|
|
{
|
|
|
|
return name_;
|
|
|
|
}
|
2022-01-09 16:55:09 +00:00
|
|
|
|
|
|
|
auto webseedCount() const
|
|
|
|
{
|
|
|
|
return std::size(webseed_urls_);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto const& webseed(size_t i) const
|
2021-12-25 21:21:13 +00:00
|
|
|
{
|
2022-01-09 16:55:09 +00:00
|
|
|
return webseed_urls_[i];
|
2021-12-25 21:21:13 +00:00
|
|
|
}
|
2021-11-10 02:42:18 +00:00
|
|
|
|
2021-12-25 21:21:13 +00:00
|
|
|
auto& announceList()
|
|
|
|
{
|
|
|
|
return announce_list_;
|
|
|
|
}
|
2021-11-10 02:42:18 +00:00
|
|
|
|
2021-12-25 21:21:13 +00:00
|
|
|
auto const& announceList() const
|
2021-11-10 02:42:18 +00:00
|
|
|
{
|
2021-12-25 21:21:13 +00:00
|
|
|
return announce_list_;
|
2021-11-10 02:42:18 +00:00
|
|
|
}
|
|
|
|
|
2021-12-25 21:21:13 +00:00
|
|
|
std::string const& infoHashString() const
|
|
|
|
{
|
|
|
|
return info_hash_str_;
|
|
|
|
}
|
2021-11-10 02:42:18 +00:00
|
|
|
|
2021-12-25 21:21:13 +00:00
|
|
|
void setName(std::string_view name)
|
|
|
|
{
|
|
|
|
name_ = name;
|
|
|
|
}
|
2021-11-10 02:42:18 +00:00
|
|
|
|
2021-12-25 21:21:13 +00:00
|
|
|
protected:
|
|
|
|
tr_announce_list announce_list_;
|
|
|
|
std::vector<std::string> webseed_urls_;
|
|
|
|
tr_sha1_digest_t info_hash_;
|
|
|
|
std::string info_hash_str_;
|
|
|
|
std::string name_;
|
2021-11-10 02:42:18 +00:00
|
|
|
};
|