2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/upload_job.cc
21 * @brief A job to copy DCPs to a server using libcurl.
24 #include "compose.hpp"
25 #include "upload_job.h"
29 #include "scp_uploader.h"
30 #include "curl_uploader.h"
35 #define LOG_GENERAL_NC(...) _film->log()->log (__VA_ARGS__, LogEntry::TYPE_GENERAL);
39 using boost::shared_ptr;
40 using boost::scoped_ptr;
42 UploadJob::UploadJob (shared_ptr<const Film> film)
44 , _status (_("Waiting"))
50 UploadJob::name () const
52 return _("Copy DCP to TMS");
56 UploadJob::json_name () const
64 LOG_GENERAL_NC (N_("Upload job starting"));
66 scoped_ptr<Uploader> uploader;
67 switch (Config::instance()->tms_protocol ()) {
69 uploader.reset (new SCPUploader (bind (&UploadJob::set_status, this, _1), bind (&UploadJob::set_progress, this, _1, false)));
72 uploader.reset (new CurlUploader (bind (&UploadJob::set_status, this, _1), bind (&UploadJob::set_progress, this, _1, false)));
76 uploader->upload (_film->dir (_film->dcp_name ()));
80 set_state (FINISHED_OK);
84 UploadJob::status () const
86 boost::mutex::scoped_lock lm (_status_mutex);
87 string s = Job::status ();
88 if (!_status.empty () && !finished_in_error ()) {
89 s += N_("; ") + _status;
95 UploadJob::set_status (string s)
97 boost::mutex::scoped_lock lm (_status_mutex);