mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
fixup! fix: include daemon-specific options in app defaults (#6505)
* fixup! fix: include daemon-specific options in app defaults (#6499) * fix: windows build failure * Revert "fixup! fix: include daemon-specific options in app defaults (#6499)" This reverts commit 92c2106cc607df36aca4ba28e8c20bd96fa87688. * refactor: define daemon-specific quarks in libtransmission
This commit is contained in:
@@ -360,6 +360,16 @@ tr_rpc_callback_status on_rpc_callback(tr_session* /*session*/, tr_rpc_callback_
|
||||
return TR_RPC_OK;
|
||||
}
|
||||
|
||||
tr_variant load_settings(char const* config_dir)
|
||||
{
|
||||
auto app_defaults = tr_variant::make_map();
|
||||
tr_variantDictAddStr(&app_defaults, TR_KEY_watch_dir, ""sv);
|
||||
tr_variantDictAddBool(&app_defaults, TR_KEY_watch_dir_enabled, false);
|
||||
tr_variantDictAddBool(&app_defaults, TR_KEY_watch_dir_force_generic, false);
|
||||
tr_variantDictAddBool(&app_defaults, TR_KEY_rpc_enabled, true);
|
||||
return tr_sessionLoadSettings(&app_defaults, config_dir, MyName);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool tr_daemon::reopen_log_file(char const* filename)
|
||||
@@ -415,16 +425,6 @@ void tr_daemon::periodic_update()
|
||||
report_status();
|
||||
}
|
||||
|
||||
tr_variant tr_daemon::load_settings(char const* config_dir)
|
||||
{
|
||||
auto app_defaults = tr_variant::make_map();
|
||||
tr_variantDictAddStr(&app_defaults, TR_KEY_watch_dir, ""sv);
|
||||
tr_variantDictAddBool(&app_defaults, TR_KEY_watch_dir_enabled, false);
|
||||
tr_variantDictAddBool(&app_defaults, key_watch_dir_force_generic, false);
|
||||
tr_variantDictAddBool(&app_defaults, TR_KEY_rpc_enabled, true);
|
||||
return tr_sessionLoadSettings(&app_defaults, config_dir, MyName);
|
||||
}
|
||||
|
||||
bool tr_daemon::parse_args(int argc, char const* const* argv, bool* dump_settings, bool* foreground, int* exit_code)
|
||||
{
|
||||
int c;
|
||||
@@ -604,7 +604,7 @@ bool tr_daemon::parse_args(int argc, char const* const* argv, bool* dump_setting
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
tr_variantDictAddStr(&settings_, key_pidfile, optstr);
|
||||
tr_variantDictAddStr(&settings_, TR_KEY_pidfile, optstr);
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
@@ -723,7 +723,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground)
|
||||
tr_sessionSaveSettings(session, cdir, settings_);
|
||||
|
||||
auto sv = std::string_view{};
|
||||
(void)tr_variantDictFindStrView(&settings_, key_pidfile, &sv);
|
||||
(void)tr_variantDictFindStrView(&settings_, TR_KEY_pidfile, &sv);
|
||||
auto const sz_pid_filename = std::string{ sv };
|
||||
auto pidfile_created = false;
|
||||
if (!std::empty(sz_pid_filename))
|
||||
@@ -771,7 +771,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground)
|
||||
if (auto tmp_bool = false; tr_variantDictFindBool(&settings_, TR_KEY_watch_dir_enabled, &tmp_bool) && tmp_bool)
|
||||
{
|
||||
auto force_generic = bool{ false };
|
||||
(void)tr_variantDictFindBool(&settings_, key_watch_dir_force_generic, &force_generic);
|
||||
(void)tr_variantDictFindBool(&settings_, TR_KEY_watch_dir_force_generic, &force_generic);
|
||||
|
||||
auto dir = std::string_view{};
|
||||
(void)tr_variantDictFindStrView(&settings_, TR_KEY_watch_dir, &dir);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <libtransmission/quark.h>
|
||||
#include <libtransmission/file.h>
|
||||
|
||||
struct event_base;
|
||||
struct tr_error;
|
||||
struct tr_session;
|
||||
|
||||
@@ -55,14 +56,9 @@ private:
|
||||
struct event_base* ev_base_ = nullptr;
|
||||
tr_sys_file_t logfile_ = TR_BAD_SYS_FILE;
|
||||
|
||||
static inline const tr_quark key_pidfile = tr_quark_new("pidfile");
|
||||
static inline const tr_quark key_watch_dir_force_generic = tr_quark_new("watch-dir-force-generic");
|
||||
|
||||
bool parse_args(int argc, char const* const* argv, bool* dump_settings, bool* foreground, int* exit_code);
|
||||
bool reopen_log_file(char const* filename);
|
||||
bool setup_signals(struct event*& sig_ev);
|
||||
void cleanup_signals(struct event* sig_ev) const;
|
||||
void report_status();
|
||||
|
||||
static tr_variant load_settings(char const* config_dir);
|
||||
};
|
||||
|
||||
@@ -19,7 +19,8 @@ using namespace std::literals;
|
||||
namespace
|
||||
{
|
||||
|
||||
auto constexpr MyStatic = std::array<std::string_view, 405>{ ""sv,
|
||||
auto constexpr MyStatic = std::array<std::string_view, TR_N_KEYS>{
|
||||
""sv,
|
||||
"activeTorrentCount"sv,
|
||||
"activity-date"sv,
|
||||
"activityDate"sv,
|
||||
@@ -241,6 +242,7 @@ auto constexpr MyStatic = std::array<std::string_view, 405>{ ""sv,
|
||||
"percentComplete"sv,
|
||||
"percentDone"sv,
|
||||
"pex-enabled"sv,
|
||||
"pidfile"sv,
|
||||
"piece"sv,
|
||||
"piece length"sv,
|
||||
"pieceCount"sv,
|
||||
@@ -421,9 +423,11 @@ auto constexpr MyStatic = std::array<std::string_view, 405>{ ""sv,
|
||||
"wanted"sv,
|
||||
"watch-dir"sv,
|
||||
"watch-dir-enabled"sv,
|
||||
"watch-dir-force-generic"sv,
|
||||
"webseeds"sv,
|
||||
"webseedsSendingToUs"sv,
|
||||
"yourip"sv };
|
||||
"yourip"sv,
|
||||
};
|
||||
|
||||
bool constexpr quarks_are_sorted()
|
||||
{
|
||||
|
||||
@@ -243,6 +243,7 @@ enum
|
||||
TR_KEY_percentComplete,
|
||||
TR_KEY_percentDone,
|
||||
TR_KEY_pex_enabled,
|
||||
TR_KEY_pidfile,
|
||||
TR_KEY_piece,
|
||||
TR_KEY_piece_length,
|
||||
TR_KEY_pieceCount,
|
||||
@@ -423,6 +424,7 @@ enum
|
||||
TR_KEY_wanted,
|
||||
TR_KEY_watch_dir,
|
||||
TR_KEY_watch_dir_enabled,
|
||||
TR_KEY_watch_dir_force_generic,
|
||||
TR_KEY_webseeds,
|
||||
TR_KEY_webseedsSendingToUs,
|
||||
TR_KEY_yourip,
|
||||
|
||||
Reference in New Issue
Block a user