X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fupload_job.cc;h=113e3a7e88bd8740456b6e8a30b7ace771f38621;hb=9b9202c7f9fc26fcef0984189aaed366b7c6d726;hp=cbcb8dfc622ce3261175fafec32df5311116ae5e;hpb=ad1ef39eda58b3a919ea3b7084401a0439409ec6;p=dcpomatic.git diff --git a/src/lib/upload_job.cc b/src/lib/upload_job.cc index cbcb8dfc6..113e3a7e8 100644 --- a/src/lib/upload_job.cc +++ b/src/lib/upload_job.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 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,51 +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 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 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) {