Skip to content

Commit

Permalink
add remote HTTPS support to Qt GUI
Browse files Browse the repository at this point in the history
This is a rather naive implementation that copies parts of the
SESSION_REMOTE_HOST settings and replaces HOST with HTTPS,
basically. We pull some ideas from the SESSION_REMOTE_AUTH parameter
as well (because it's a boolean) and we otherwise do not really know
what we are doing here.

In particular, we didn't add a new commandline flag for this, as I am
not sure what it would be called.

This explicitely does *not* add GUI elements as those were found to be
too confusing, as the backend does not support HTTPS. See #4593 for
the details of that discussion.

I actually would have much rather this be turned in a single URL
instead of having flags, UI elements and settings for what is
ultimately just a string, but that is yet another yak to shave...

Closes: #1294
  • Loading branch information
anarcat committed Jan 20, 2023
1 parent 8755207 commit 26afe4a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions libtransmission/quark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ auto constexpr MyStatic = std::array<std::string_view, 401>{ ""sv,
"recent-relocate-dir-4"sv,
"recheckProgress"sv,
"remote-session-enabled"sv,
"remote-session-https"sv,
"remote-session-host"sv,
"remote-session-password"sv,
"remote-session-port"sv,
Expand Down
1 change: 1 addition & 0 deletions libtransmission/quark.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ enum
TR_KEY_recent_relocate_dir_4,
TR_KEY_recheckProgress,
TR_KEY_remote_session_enabled,
TR_KEY_remote_session_https,
TR_KEY_remote_session_host,
TR_KEY_remote_session_password,
TR_KEY_remote_session_port,
Expand Down
2 changes: 2 additions & 0 deletions qt/Prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ std::array<Prefs::PrefItem, Prefs::PREFS_COUNT> const Prefs::Items{
{ FILTER_TRACKERS, TR_KEY_filter_trackers, QVariant::String },
{ FILTER_TEXT, TR_KEY_filter_text, QVariant::String },
{ SESSION_IS_REMOTE, TR_KEY_remote_session_enabled, QVariant::Bool },
{ SESSION_REMOTE_HTTPS, TR_KEY_remote_session_https, QVariant::Bool },
{ SESSION_REMOTE_HOST, TR_KEY_remote_session_host, QVariant::String },
{ SESSION_REMOTE_PORT, TR_KEY_remote_session_port, QVariant::Int },
{ SESSION_REMOTE_AUTH, TR_KEY_remote_session_requres_authentication, QVariant::Bool },
Expand Down Expand Up @@ -466,6 +467,7 @@ void Prefs::initDefaults(tr_variant* d) const
dictAdd(d, TR_KEY_filter_mode, FilterMode);
dictAdd(d, TR_KEY_main_window_layout_order, WindowLayout);
dictAdd(d, TR_KEY_open_dialog_dir, QDir::home().absolutePath());
dictAdd(d, TR_KEY_remote_session_https, false);
dictAdd(d, TR_KEY_remote_session_host, SessionHost);
dictAdd(d, TR_KEY_remote_session_password, SessionPassword);
dictAdd(d, TR_KEY_remote_session_username, SessionUsername);
Expand Down
1 change: 1 addition & 0 deletions qt/Prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Prefs : public QObject
COMPLETE_SOUND_ENABLED,
USER_HAS_GIVEN_INFORMED_CONSENT,
READ_CLIPBOARD,
SESSION_REMOTE_HTTPS,
/* core prefs */
FIRST_CORE_PREF,
ALT_SPEED_LIMIT_UP = FIRST_CORE_PREF,
Expand Down
9 changes: 8 additions & 1 deletion qt/Session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,14 @@ void Session::start()
if (prefs_.get<bool>(Prefs::SESSION_IS_REMOTE))
{
QUrl url;
url.setScheme(QStringLiteral("http"));
if (prefs_.get<bool>(Prefs::SESSION_REMOTE_HTTPS))
{
url.setScheme(QStringLiteral("https"));
}
else
{
url.setScheme(QStringLiteral("http"));
}
url.setHost(prefs_.get<QString>(Prefs::SESSION_REMOTE_HOST));
url.setPort(prefs_.get<int>(Prefs::SESSION_REMOTE_PORT));
url.setPath(QStringLiteral("/transmission/rpc"));
Expand Down

0 comments on commit 26afe4a

Please sign in to comment.