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 /src/lib/upload_destination.cc | |
| parent | e67c0db714284d2eeba6be52ad075acaf002de08 (diff) | |
Generalise TMS upload to a single upload destination.
Diffstat (limited to 'src/lib/upload_destination.cc')
| -rw-r--r-- | src/lib/upload_destination.cc | 68 |
1 files changed, 68 insertions, 0 deletions
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; +} |
