diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-06-04 00:21:59 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-07-09 00:35:08 +0200 |
| commit | debd1b7233cf56f5d79e1de0c993996e5b549a6d (patch) | |
| tree | 77d7279f8951e7c365140ddbe61ea2c601dec882 | |
| parent | e67c0db714284d2eeba6be52ad075acaf002de08 (diff) | |
Generalise TMS upload to a single upload destination.
| -rw-r--r-- | src/lib/config.cc | 47 | ||||
| -rw-r--r-- | src/lib/config.h | 69 | ||||
| -rw-r--r-- | src/lib/curl_uploader.cc | 12 | ||||
| -rw-r--r-- | src/lib/curl_uploader.h | 3 | ||||
| -rw-r--r-- | src/lib/dcp_transcode_job.cc | 4 | ||||
| -rw-r--r-- | src/lib/film.cc | 4 | ||||
| -rw-r--r-- | src/lib/scp_uploader.cc | 14 | ||||
| -rw-r--r-- | src/lib/scp_uploader.h | 4 | ||||
| -rw-r--r-- | src/lib/upload_destination.cc | 68 | ||||
| -rw-r--r-- | src/lib/upload_destination.h | 72 | ||||
| -rw-r--r-- | src/lib/upload_job.cc | 15 | ||||
| -rw-r--r-- | src/lib/upload_job.h | 9 | ||||
| -rw-r--r-- | src/lib/uploader.cc | 7 | ||||
| -rw-r--r-- | src/lib/uploader.h | 4 | ||||
| -rw-r--r-- | src/lib/wscript | 1 | ||||
| -rw-r--r-- | src/wx/full_config_dialog.cc | 73 | ||||
| m--------- | test/data | 0 |
17 files changed, 246 insertions, 160 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index 5f3f2f6fe..233c7fed7 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -98,12 +98,7 @@ Config::set_defaults() _use_any_servers = true; _servers.clear(); _only_servers_encode = false; - _tms_protocol = FileTransferProtocol::SCP; - _tms_passive = true; - _tms_ip = ""; - _tms_path = "."; - _tms_user = ""; - _tms_password = ""; + _tms = boost::none; _allow_any_dcp_frame_rate = false; _allow_any_container = false; _allow_96khz_audio = false; @@ -349,12 +344,23 @@ try } _only_servers_encode = f.optional_bool_child("OnlyServersEncode").get_value_or(false); - _tms_protocol = static_cast<FileTransferProtocol>(f.optional_number_child<int>("TMSProtocol").get_value_or(static_cast<int>(FileTransferProtocol::SCP))); - _tms_passive = f.optional_bool_child("TMSPassive").get_value_or(true); - _tms_ip = f.string_child("TMSIP"); - _tms_path = f.string_child("TMSPath"); - _tms_user = f.string_child("TMSUser"); - _tms_password = f.string_child("TMSPassword"); + + if (f.optional_string_child("TMSIP")) { + _tms = UploadDestination( + _("TMS"), + static_cast<FileTransferProtocol>(f.optional_number_child<int>("TMSProtocol").get_value_or(static_cast<int>(FileTransferProtocol::SCP))), + f.optional_bool_child("TMSPassive").get_value_or(true), + boost::none, + f.string_child("TMSIP"), + f.string_child("TMSPath"), + f.string_child("TMSUser"), + f.string_child("TMSPassword") + ); + } + + if (auto node = f.optional_node_child("TMS")) { + _tms = UploadDestination(node); + } _language = f.optional_string_child("Language"); @@ -778,18 +784,11 @@ Config::write_config() const is done by the encoding servers. 0 to set the master to do some encoding as well as coordinating the job. */ cxml::add_text_child(root, "OnlyServersEncode", _only_servers_encode ? "1" : "0"); - /* [XML] TMSProtocol Protocol to use to copy files to a TMS; 0 to use SCP, 1 for FTP. */ - cxml::add_text_child(root, "TMSProtocol", fmt::to_string(static_cast<int>(_tms_protocol))); - /* [XML] TMSPassive True to use PASV mode with TMS FTP connections. */ - cxml::add_text_child(root, "TMSPassive", _tms_passive ? "1" : "0"); - /* [XML] TMSIP IP address of TMS. */ - cxml::add_text_child(root, "TMSIP", _tms_ip); - /* [XML] TMSPath Path on the TMS to copy files to. */ - cxml::add_text_child(root, "TMSPath", _tms_path); - /* [XML] TMSUser Username to log into the TMS with. */ - cxml::add_text_child(root, "TMSUser", _tms_user); - /* [XML] TMSPassword Password to log into the TMS with. */ - cxml::add_text_child(root, "TMSPassword", _tms_password); + + if (_tms) { + _tms->as_xml(cxml::add_child(root, "TMS")); + } + if (_language) { /* [XML:opt] Language Language to use in the GUI e.g. <code>fr_FR</code>. */ cxml::add_text_child(root, "Language", _language.get()); diff --git a/src/lib/config.h b/src/lib/config.h index 2bc700e86..f65edda20 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -32,6 +32,7 @@ #include "export_config.h" #include "rough_duration.h" #include "state.h" +#include "upload_destination.h" #include "video_encoding.h" #include <dcp/name_format.h> #include <dcp/certificate_chain.h> @@ -154,32 +155,8 @@ public: return _only_servers_encode; } - FileTransferProtocol tms_protocol() const { - return _tms_protocol; - } - - bool tms_passive() const { - return _tms_passive; - } - - /** @return The IP address of a TMS that we can copy DCPs to */ - std::string tms_ip() const { - return _tms_ip; - } - - /** @return The path on a TMS that we should changed DCPs to */ - std::string tms_path() const { - return _tms_path; - } - - /** @return User name to log into the TMS with */ - std::string tms_user() const { - return _tms_user; - } - - /** @return Password to log into the TMS with */ - std::string tms_password() const { - return _tms_password; + boost::optional<UploadDestination> tms() const { + return _tms; } std::list<int> allowed_dcp_frame_rates() const { @@ -720,32 +697,9 @@ public: maybe_set(_only_servers_encode, o); } - void set_tms_protocol(FileTransferProtocol p) { - maybe_set(_tms_protocol, p); - } - - void set_tms_passive(bool passive) { - maybe_set(_tms_passive, passive); - } - - /** @param i IP address of a TMS that we can copy DCPs to */ - void set_tms_ip(std::string i) { - maybe_set(_tms_ip, i); - } - - /** @param p Path on a TMS that we should changed DCPs to */ - void set_tms_path(std::string p) { - maybe_set(_tms_path, p); - } - - /** @param u User name to log into the TMS with */ - void set_tms_user(std::string u) { - maybe_set(_tms_user, u); - } - - /** @param p Password to log into the TMS with */ - void set_tms_password(std::string p) { - maybe_set(_tms_password, p); + void set_tms(UploadDestination tms) { + _tms = tms; + changed(); } void set_allowed_dcp_frame_rates(std::list<int> const & r) { @@ -1365,16 +1319,7 @@ private: /** J2K encoding servers that should definitely be used */ std::vector<std::string> _servers; bool _only_servers_encode; - FileTransferProtocol _tms_protocol; - bool _tms_passive; - /** The IP address of a TMS that we can copy DCPs to */ - std::string _tms_ip; - /** The path on a TMS that we should write DCPs to */ - std::string _tms_path; - /** User name to log into the TMS with */ - std::string _tms_user; - /** Password to log into the TMS with */ - std::string _tms_password; + boost::optional<UploadDestination> _tms; /** The list of possible DCP frame rates that DCP-o-matic will use */ std::list<int> _allowed_dcp_frame_rates; /** Allow any video frame rate for the DCP; if true, overrides _allowed_dcp_frame_rates */ diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc index 753c66496..7b8cf44c8 100644 --- a/src/lib/curl_uploader.cc +++ b/src/lib/curl_uploader.cc @@ -51,8 +51,8 @@ curl_debug_shim(CURL* curl, curl_infotype type, char* data, size_t size, void* u } -CurlUploader::CurlUploader(function<void (string)> set_status, function<void (float)> set_progress) - : Uploader(set_status, set_progress) +CurlUploader::CurlUploader(UploadDestination destination, function<void (string)> set_status, function<void (float)> set_progress) + : Uploader(destination, set_status, set_progress) { _curl = curl_easy_init(); if (!_curl) { @@ -64,9 +64,9 @@ CurlUploader::CurlUploader(function<void (string)> set_status, function<void (fl curl_easy_setopt(_curl, CURLOPT_UPLOAD, 1L); curl_easy_setopt(_curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L); curl_easy_setopt(_curl, CURLOPT_READDATA, this); - curl_easy_setopt(_curl, CURLOPT_USERNAME, Config::instance()->tms_user().c_str()); - curl_easy_setopt(_curl, CURLOPT_PASSWORD, Config::instance()->tms_password().c_str()); - if (!Config::instance()->tms_passive()) { + curl_easy_setopt(_curl, CURLOPT_USERNAME, _destination.user.c_str()); + curl_easy_setopt(_curl, CURLOPT_PASSWORD, _destination.password.c_str()); + if (!_destination.passive_ftp) { curl_easy_setopt(_curl, CURLOPT_FTPPORT, "-"); } curl_easy_setopt(_curl, CURLOPT_VERBOSE, 1L); @@ -94,7 +94,7 @@ CurlUploader::upload_file(boost::filesystem::path from, boost::filesystem::path curl_easy_setopt( _curl, CURLOPT_URL, /* Use generic_string so that we get forward-slashes in the path, even on Windows */ - String::compose("ftp://%1/%2/%3", Config::instance()->tms_ip(), Config::instance()->tms_path(), to.generic_string()).c_str() + String::compose("ftp://%1/%2/%3", _destination.host, _destination.path, to.generic_string()).c_str() ); dcp::File file(from, "rb"); diff --git a/src/lib/curl_uploader.h b/src/lib/curl_uploader.h index 0634d564f..afcdf8625 100644 --- a/src/lib/curl_uploader.h +++ b/src/lib/curl_uploader.h @@ -19,6 +19,7 @@ */ +#include "upload_destination.h" #include "uploader.h" #include <dcp/file.h> #include <curl/curl.h> @@ -27,7 +28,7 @@ class CurlUploader : public Uploader { public: - CurlUploader(std::function<void (std::string)> set_status, std::function<void (float)> set_progress); + CurlUploader(UploadDestination destination, std::function<void (std::string)> set_status, std::function<void (float)> set_progress); ~CurlUploader(); size_t read_callback(void* ptr, size_t size, size_t nmemb); diff --git a/src/lib/dcp_transcode_job.cc b/src/lib/dcp_transcode_job.cc index dd7b7d624..55e88e646 100644 --- a/src/lib/dcp_transcode_job.cc +++ b/src/lib/dcp_transcode_job.cc @@ -46,8 +46,8 @@ DCPTranscodeJob::DCPTranscodeJob (shared_ptr<const Film> film, ChangedBehaviour void DCPTranscodeJob::post_transcode () { - if (Config::instance()->upload_after_make_dcp()) { - JobManager::instance()->add(make_shared<UploadJob>(_film)); + if (Config::instance()->upload_after_make_dcp() && Config::instance()->tms()) { + JobManager::instance()->add(make_shared<UploadJob>(_film, *Config::instance()->tms())); } /* The first directory is the project's DCP, so the first CPL will also be from the project diff --git a/src/lib/film.cc b/src/lib/film.cc index cdf29766d..36af31bf1 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -380,7 +380,9 @@ Film::subtitle_analysis_path(shared_ptr<const Content> content) const void Film::send_dcp_to_tms() { - JobManager::instance()->add(make_shared<UploadJob>(shared_from_this())); + if (Config::instance()->tms()) { + JobManager::instance()->add(make_shared<UploadJob>(shared_from_this(), *Config::instance()->tms())); + } } shared_ptr<xmlpp::Document> diff --git a/src/lib/scp_uploader.cc b/src/lib/scp_uploader.cc index 193894293..1665c7a53 100644 --- a/src/lib/scp_uploader.cc +++ b/src/lib/scp_uploader.cc @@ -39,22 +39,22 @@ using std::shared_ptr; using std::string; -SCPUploader::SCPUploader(function<void (string)> set_status, function<void (float)> set_progress) - : Uploader(set_status, set_progress) +SCPUploader::SCPUploader(UploadDestination destination, function<void (string)> set_status, function<void (float)> set_progress) + : Uploader(destination, set_status, set_progress) { _session = ssh_new(); if (!_session) { throw NetworkError(String::compose(_("SSH error [%1]"), "ssh_new")); } - ssh_options_set(_session, SSH_OPTIONS_HOST, Config::instance()->tms_ip().c_str()); - ssh_options_set(_session, SSH_OPTIONS_USER, Config::instance()->tms_user().c_str()); + ssh_options_set(_session, SSH_OPTIONS_HOST, _destination.host.c_str()); + ssh_options_set(_session, SSH_OPTIONS_USER, _destination.user.c_str()); int const port = 22; ssh_options_set(_session, SSH_OPTIONS_PORT, &port); int r = ssh_connect(_session); if (r != SSH_OK) { - throw NetworkError(String::compose(_("Could not connect to server %1 (%2)"), Config::instance()->tms_ip(), ssh_get_error(_session))); + throw NetworkError(String::compose(_("Could not connect to server %1 (%2)"), _destination.host, ssh_get_error(_session))); } LIBDCP_DISABLE_WARNINGS @@ -64,13 +64,13 @@ LIBDCP_DISABLE_WARNINGS } LIBDCP_ENABLE_WARNINGS - r = ssh_userauth_password(_session, 0, Config::instance()->tms_password().c_str()); + r = ssh_userauth_password(_session, 0, _destination.password.c_str()); if (r != SSH_AUTH_SUCCESS) { throw NetworkError(String::compose(_("Failed to authenticate with server (%1)"), ssh_get_error(_session))); } LIBDCP_DISABLE_WARNINGS - _scp = ssh_scp_new(_session, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, Config::instance()->tms_path().c_str()); + _scp = ssh_scp_new(_session, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, _destination.path.c_str()); LIBDCP_ENABLE_WARNINGS if (!_scp) { throw NetworkError(String::compose(_("SSH error [%1] (%2)"), "ssh_scp_new", ssh_get_error(_session))); diff --git a/src/lib/scp_uploader.h b/src/lib/scp_uploader.h index bae175ea8..15de5bffe 100644 --- a/src/lib/scp_uploader.h +++ b/src/lib/scp_uploader.h @@ -19,8 +19,8 @@ */ -#include <dcp/warnings.h> #include "uploader.h" +#include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <libssh/libssh.h> LIBDCP_ENABLE_WARNINGS @@ -29,7 +29,7 @@ LIBDCP_ENABLE_WARNINGS class SCPUploader : public Uploader { public: - SCPUploader(std::function<void (std::string)> set_status, std::function<void (float)> set_progress); + SCPUploader(UploadDestination destination, std::function<void (std::string)> set_status, std::function<void (float)> set_progress); ~SCPUploader(); protected: diff --git a/src/lib/upload_destination.cc b/src/lib/upload_destination.cc new file mode 100644 index 000000000..c91ba6a6f --- /dev/null +++ b/src/lib/upload_destination.cc @@ -0,0 +1,68 @@ +/* + Copyright (C) 2025 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "upload_destination.h" +#include <libcxml/cxml.h> +#include <fmt/format.h> + + +UploadDestination::UploadDestination(cxml::ConstNodePtr node) + : name(node->string_child("Name")) + , protocol(file_transfer_protocol_from_string(node->string_child("Protocol"))) + , passive_ftp(node->bool_child("PassiveFTP")) + , maximum_connections(node->optional_number_child<int>("MaximumConnections")) + , host(node->string_child("Host")) + , path(node->string_child("Path")) + , user(node->string_child("User")) + , password(node->string_child("Password")) +{ + +} + + +void +UploadDestination::as_xml(xmlpp::Element* parent) const +{ + cxml::add_text_child(parent, "Name", name); + cxml::add_text_child(parent, "Protocol", file_transfer_protocol_to_string(protocol)); + cxml::add_text_child(parent, "PassiveFTP", passive_ftp ? "1" : "0"); + if (maximum_connections) { + cxml::add_text_child(parent, "MaximumConnections", fmt::to_string(*maximum_connections)); + } + cxml::add_text_child(parent, "Host", host); + cxml::add_text_child(parent, "Path", path); + cxml::add_text_child(parent, "User", user); + cxml::add_text_child(parent, "Password", password); +} + + +bool +operator==(UploadDestination const& a, UploadDestination const& b) +{ + return a.name == b.name + && a.protocol == b.protocol + && a.passive_ftp == b.passive_ftp + && a.maximum_connections == b.maximum_connections + && a.host == b.host + && a.path == b.path + && a.user == b.user + && a.password == b.password; +} diff --git a/src/lib/upload_destination.h b/src/lib/upload_destination.h new file mode 100644 index 000000000..6d062d172 --- /dev/null +++ b/src/lib/upload_destination.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2025 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#ifndef DCPOMATIC_UPLOAD_DESTINATION_H +#define DCPOMATIC_UPLOAD_DESTINATION_H + + +#include "types.h" +#include <libcxml/cxml.h> + + +class UploadDestination +{ +public: + UploadDestination( + std::string name_, + FileTransferProtocol protocol_, + bool passive_ftp_, + boost::optional<int> maximum_connections_, + std::string host_, + std::string path_, + std::string user_, + std::string password_ + ) + : name(name_) + , protocol(protocol_) + , passive_ftp(passive_ftp_) + , maximum_connections(maximum_connections_) + , host(host_) + , path(path_) + , user(user_) + , password(password_) + {} + + UploadDestination(cxml::ConstNodePtr node); + + void as_xml(xmlpp::Element* parent) const; + + std::string name; + FileTransferProtocol protocol; + bool passive_ftp = true; + boost::optional<int> maximum_connections; + std::string host; + std::string path; + std::string user; + std::string password; +}; + + +bool operator==(UploadDestination const& a, UploadDestination const& b); + + +#endif + diff --git a/src/lib/upload_job.cc b/src/lib/upload_job.cc index 3019b7662..2acc97320 100644 --- a/src/lib/upload_job.cc +++ b/src/lib/upload_job.cc @@ -32,22 +32,23 @@ #include "log.h" #include "scp_uploader.h" #include "upload_job.h" -#include <iostream> +#include <fmt/format.h> #include "i18n.h" -using std::string; using std::min; using std::shared_ptr; +using std::string; using boost::scoped_ptr; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif -UploadJob::UploadJob(shared_ptr<const Film> film) +UploadJob::UploadJob(shared_ptr<const Film> film, UploadDestination destination) : Job(film) + , _destination(destination) , _status(_("Waiting")) { @@ -63,7 +64,7 @@ UploadJob::~UploadJob() string UploadJob::name() const { - return _("Copy DCP to TMS"); + return fmt::format(_("Upload DCP to {}"), _destination.name); } @@ -80,12 +81,12 @@ UploadJob::run() LOG_GENERAL_NC(N_("Upload job starting")); scoped_ptr<Uploader> uploader; - switch (Config::instance()->tms_protocol()) { + switch (_destination.protocol) { case FileTransferProtocol::SCP: - uploader.reset(new SCPUploader(bind(&UploadJob::set_status, this, _1), bind(&UploadJob::set_progress, this, _1, false))); + uploader.reset(new SCPUploader(_destination, bind(&UploadJob::set_status, this, _1), bind(&UploadJob::set_progress, this, _1, false))); break; case FileTransferProtocol::FTP: - uploader.reset(new CurlUploader(bind(&UploadJob::set_status, this, _1), bind(&UploadJob::set_progress, this, _1, false))); + uploader.reset(new CurlUploader(_destination, bind(&UploadJob::set_status, this, _1), bind(&UploadJob::set_progress, this, _1, false))); break; } diff --git a/src/lib/upload_job.h b/src/lib/upload_job.h index 87beec1ad..4ccfef7ec 100644 --- a/src/lib/upload_job.h +++ b/src/lib/upload_job.h @@ -19,18 +19,19 @@ */ -/** @file src/upload_job.h - * @brief A job to copy DCPs to a server using libcurl. +/** @file src/upload_job.h + * @brief A job to copy DCPs to a server. */ #include "job.h" +#include "upload_destination.h" class UploadJob : public Job { public: - explicit UploadJob(std::shared_ptr<const Film>); + UploadJob(std::shared_ptr<const Film>, UploadDestination destination); ~UploadJob(); std::string name() const override; @@ -41,6 +42,8 @@ public: private: void set_status(std::string); + UploadDestination _destination; + mutable boost::mutex _status_mutex; std::string _status; }; diff --git a/src/lib/uploader.cc b/src/lib/uploader.cc index f2a47f50e..507100877 100644 --- a/src/lib/uploader.cc +++ b/src/lib/uploader.cc @@ -31,9 +31,10 @@ using std::shared_ptr; using std::function; -Uploader::Uploader (function<void (string)> set_status, function<void (float)> set_progress) - : _set_progress (set_progress) - , _set_status (set_status) +Uploader::Uploader(UploadDestination destination, function<void (string)> set_status, function<void (float)> set_progress) + : _set_progress(set_progress) + , _destination(std::move(destination)) + , _set_status(set_status) { _set_status (_("connecting")); } diff --git a/src/lib/uploader.h b/src/lib/uploader.h index 440746344..5fb1c129f 100644 --- a/src/lib/uploader.h +++ b/src/lib/uploader.h @@ -23,6 +23,7 @@ #define DCPOMATIC_UPLOADER_H +#include "upload_destination.h" #include <boost/filesystem.hpp> @@ -32,7 +33,7 @@ class Job; class Uploader { public: - Uploader(std::function<void (std::string)> set_status, std::function<void (float)> set_progress); + Uploader(UploadDestination destination, std::function<void (std::string)> set_status, std::function<void (float)> set_progress); virtual ~Uploader() {} void upload(boost::filesystem::path directory); @@ -43,6 +44,7 @@ protected: virtual void upload_file(boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size) = 0; std::function<void (float)> _set_progress; + UploadDestination _destination; private: void upload_directory (boost::filesystem::path base, boost::filesystem::path directory, boost::uintmax_t& transferred, boost::uintmax_t total_size); diff --git a/src/lib/wscript b/src/lib/wscript index ea6994eb1..adb05f356 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -216,6 +216,7 @@ sources = """ stdout_log.cc unzipper.cc update_checker.cc + upload_destination.cc upload_job.cc uploader.cc upmixer_a.cc diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 704bce621..162239e41 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -570,13 +570,13 @@ private: _tms_protocol->Append(_("FTP (for Dolby)")); _upload->bind(&TMSPage::upload_changed, this); - _tms_protocol->Bind(wxEVT_CHOICE, boost::bind(&TMSPage::tms_protocol_changed, this)); - _tms_passive->bind(&TMSPage::tms_passive_changed, this); + _tms_protocol->Bind(wxEVT_CHOICE, boost::bind(&TMSPage::tms_changed, this)); + _tms_passive->bind(&TMSPage::tms_changed, this); - _tms_ip->Bind(wxEVT_TEXT, boost::bind(&TMSPage::tms_ip_changed, this)); - _tms_path->Bind(wxEVT_TEXT, boost::bind(&TMSPage::tms_path_changed, this)); - _tms_user->Bind(wxEVT_TEXT, boost::bind(&TMSPage::tms_user_changed, this)); - _tms_password->Changed.connect(boost::bind(&TMSPage::tms_password_changed, this)); + _tms_ip->Bind(wxEVT_TEXT, boost::bind(&TMSPage::tms_changed, this)); + _tms_path->Bind(wxEVT_TEXT, boost::bind(&TMSPage::tms_changed, this)); + _tms_user->Bind(wxEVT_TEXT, boost::bind(&TMSPage::tms_changed, this)); + _tms_password->Changed.connect(boost::bind(&TMSPage::tms_changed, this)); } void config_changed() override @@ -584,14 +584,21 @@ private: auto config = Config::instance(); checked_set(_upload, config->upload_after_make_dcp()); - checked_set(_tms_protocol, static_cast<int>(config->tms_protocol())); - checked_set(_tms_passive, config->tms_protocol() == FileTransferProtocol::FTP && config->tms_passive()); - checked_set(_tms_ip, config->tms_ip()); - checked_set(_tms_path, config->tms_path()); - checked_set(_tms_user, config->tms_user()); - checked_set(_tms_password, config->tms_password()); - - _tms_passive->Enable(config->tms_protocol() == FileTransferProtocol::FTP); + if (auto tms = Config::instance()->tms()) { + checked_set(_tms_protocol, static_cast<int>(tms->protocol)); + checked_set(_tms_passive, tms->protocol == FileTransferProtocol::FTP && tms->passive_ftp); + checked_set(_tms_ip, tms->host); + checked_set(_tms_path, tms->path); + checked_set(_tms_user, tms->user); + checked_set(_tms_password, tms->password); + } else { + checked_set(_tms_protocol, static_cast<int>(FileTransferProtocol::FTP)); + checked_set(_tms_passive, false); + checked_set(_tms_ip, ""); + checked_set(_tms_path, ""); + checked_set(_tms_user, ""); + checked_set(_tms_password, ""); + } } void upload_changed() @@ -599,34 +606,18 @@ private: Config::instance()->set_upload_after_make_dcp(_upload->GetValue()); } - void tms_protocol_changed() - { - Config::instance()->set_tms_protocol(static_cast<FileTransferProtocol>(_tms_protocol->GetSelection())); - } - - void tms_passive_changed() - { - Config::instance()->set_tms_passive(_tms_passive->get()); - } - - void tms_ip_changed() - { - Config::instance()->set_tms_ip(wx_to_std(_tms_ip->GetValue())); - } - - void tms_path_changed() - { - Config::instance()->set_tms_path(wx_to_std(_tms_path->GetValue())); - } - - void tms_user_changed() - { - Config::instance()->set_tms_user(wx_to_std(_tms_user->GetValue())); - } - - void tms_password_changed() + void tms_changed() { - Config::instance()->set_tms_password(_tms_password->get()); + Config::instance()->set_tms({ + wx_to_std(_("TMS")), + static_cast<FileTransferProtocol>(_tms_protocol->GetSelection()), + _tms_passive->get(), + boost::none, + wx_to_std(_tms_ip->GetValue()), + wx_to_std(_tms_path->GetValue()), + wx_to_std(_tms_user->GetValue()), + _tms_password->get() + }); } CheckBox* _upload; diff --git a/test/data b/test/data -Subproject d1292b1ce9a2ee42320e7d3b94e94ea1e6101db +Subproject 91e99d70ac1dfbbff97348169c6f26e06b94288 |
