1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-30 10:52:00 +00:00

refactor: remove tr_parse_result enum (#6435)

This commit is contained in:
Charles Kerr 2023-12-24 18:05:18 -06:00 committed by GitHub
parent 0780104b8d
commit 501487b8cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 16 deletions

View file

@ -79,7 +79,7 @@ public:
void torrents_added(); void torrents_added();
void add_files(std::vector<Glib::RefPtr<Gio::File>> const& files, bool do_start, bool do_prompt, bool do_notify); void add_files(std::vector<Glib::RefPtr<Gio::File>> const& files, bool do_start, bool do_prompt, bool do_notify);
int add_ctor(tr_ctor* ctor, bool do_prompt, bool do_notify); void add_ctor(tr_ctor* ctor, bool do_prompt, bool do_notify);
void add_torrent(Glib::RefPtr<Torrent> const& torrent, bool do_notify); void add_torrent(Glib::RefPtr<Torrent> const& torrent, bool do_notify);
bool add_from_url(Glib::ustring const& url); bool add_from_url(Glib::ustring const& url);
@ -690,12 +690,12 @@ Glib::RefPtr<Torrent> Session::Impl::create_new_torrent(tr_ctor* ctor)
return Torrent::create(tor); return Torrent::create(tor);
} }
int Session::Impl::add_ctor(tr_ctor* ctor, bool do_prompt, bool do_notify) void Session::Impl::add_ctor(tr_ctor* ctor, bool do_prompt, bool do_notify)
{ {
auto const* metainfo = tr_ctorGetMetainfo(ctor); auto const* metainfo = tr_ctorGetMetainfo(ctor);
if (metainfo == nullptr) if (metainfo == nullptr)
{ {
return TR_PARSE_ERR; return;
} }
if (tr_torrentFindFromMetainfo(get_session(), metainfo) != nullptr) if (tr_torrentFindFromMetainfo(get_session(), metainfo) != nullptr)
@ -709,18 +709,17 @@ int Session::Impl::add_ctor(tr_ctor* ctor, bool do_prompt, bool do_notify)
} }
tr_ctorFree(ctor); tr_ctorFree(ctor);
return TR_PARSE_DUPLICATE; return;
} }
if (!do_prompt) if (!do_prompt)
{ {
add_torrent(create_new_torrent(ctor), do_notify); add_torrent(create_new_torrent(ctor), do_notify);
tr_ctorFree(ctor); tr_ctorFree(ctor);
return 0; return;
} }
signal_add_prompt_.emit(ctor); signal_add_prompt_.emit(ctor);
return 0;
} }
namespace namespace

View file

@ -31,8 +31,8 @@ class Session : public Glib::Object
public: public:
enum ErrorCode enum ErrorCode
{ {
ERR_ADD_TORRENT_ERR = TR_PARSE_ERR, ERR_ADD_TORRENT_ERR = 1,
ERR_ADD_TORRENT_DUP = TR_PARSE_DUPLICATE, ERR_ADD_TORRENT_DUP = 2,
ERR_NO_MORE_TORRENTS = 1000 /* finished adding a batch */ ERR_NO_MORE_TORRENTS = 1000 /* finished adding a batch */
}; };

View file

@ -808,14 +808,6 @@ void tr_ctorSetFilesWanted(tr_ctor* ctor, tr_file_index_t const* files, tr_file_
or nullptr if `tr_ctorSetMetainfoFromFile()` wasn't used */ or nullptr if `tr_ctorSetMetainfoFromFile()` wasn't used */
char const* tr_ctorGetSourceFile(tr_ctor const* ctor); char const* tr_ctorGetSourceFile(tr_ctor const* ctor);
// TODO(ckerr) remove
enum tr_parse_result
{
TR_PARSE_OK,
TR_PARSE_ERR,
TR_PARSE_DUPLICATE
};
/** /**
* Instantiate a single torrent. * Instantiate a single torrent.
* *