X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fupload_job.cc;h=113e3a7e88bd8740456b6e8a30b7ace771f38621;hb=ff639b3cf30afcc097bfd21d39c8d15f466cadd6;hp=fbfbb92d83459bc1c89189cf3016a5880ad1c273;hpb=caf67bef2611a911307267b20dbf3be89ffff71f;p=dcpomatic.git diff --git a/src/lib/upload_job.cc b/src/lib/upload_job.cc index fbfbb92d8..113e3a7e8 100644 --- a/src/lib/upload_job.cc +++ b/src/lib/upload_job.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2019 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,26 +18,33 @@ */ + /** @file src/upload_job.cc * @brief A job to copy DCPs to a server using libcurl. */ + #include "compose.hpp" -#include "upload_job.h" #include "config.h" -#include "log.h" +#include "curl_uploader.h" #include "dcpomatic_log.h" #include "film.h" +#include "log.h" #include "scp_uploader.h" -#include "curl_uploader.h" +#include "upload_job.h" #include #include "i18n.h" + using std::string; using std::min; -using boost::shared_ptr; +using std::shared_ptr; using boost::scoped_ptr; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif + UploadJob::UploadJob (shared_ptr film) : Job (film) @@ -46,56 +53,62 @@ UploadJob::UploadJob (shared_ptr film) } + UploadJob::~UploadJob () { stop_thread (); } + string UploadJob::name () const { return _("Copy DCP to TMS"); } + string UploadJob::json_name () const { return N_("upload"); } + void UploadJob::run () { LOG_GENERAL_NC (N_("Upload job starting")); scoped_ptr uploader; - switch (Config::instance()->tms_protocol ()) { - case FILE_TRANSFER_PROTOCOL_SCP: - uploader.reset (new SCPUploader (bind (&UploadJob::set_status, this, _1), bind (&UploadJob::set_progress, this, _1, false))); + switch (Config::instance()->tms_protocol()) { + case FileTransferProtocol::SCP: + uploader.reset (new SCPUploader(bind (&UploadJob::set_status, this, _1), bind(&UploadJob::set_progress, this, _1, false))); break; - case FILE_TRANSFER_PROTOCOL_FTP: - uploader.reset (new CurlUploader (bind (&UploadJob::set_status, this, _1), bind (&UploadJob::set_progress, this, _1, false))); + case FileTransferProtocol::FTP: + uploader.reset (new CurlUploader(bind (&UploadJob::set_status, this, _1), bind(&UploadJob::set_progress, this, _1, false))); break; } - uploader->upload (_film->dir (_film->dcp_name ())); + uploader->upload (_film->dir(_film->dcp_name())); set_progress (1); set_status (N_("")); set_state (FINISHED_OK); } + string UploadJob::status () const { boost::mutex::scoped_lock lm (_status_mutex); - string s = Job::status (); - if (!_status.empty () && !finished_in_error ()) { + auto s = Job::status (); + if (!_status.empty() && !finished_in_error()) { s += N_("; ") + _status; } return s; } + void UploadJob::set_status (string s) {