2 Copyright (C) 2014-2017 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "send_problem_report_job.h"
22 #include "compose.hpp"
29 #include "environment_info.h"
30 #include <libxml++/libxml++.h>
31 #include <boost/foreach.hpp>
37 using boost::shared_ptr;
39 /** @param film Film thta the problem is with, or 0 */
40 SendProblemReportJob::SendProblemReportJob (
41 shared_ptr<const Film> film,
53 SendProblemReportJob::name () const
56 return _("Email problem report");
59 return String::compose (_("Email problem report for %1"), _film->name());
63 SendProblemReportJob::json_name () const
65 return N_("send_problem_report");
69 SendProblemReportJob::run ()
71 sub (_("Sending email"));
72 set_progress_unknown ();
74 string body = _summary + "\n\n";
76 body += "Version: " + string (dcpomatic_version) + " " + string (dcpomatic_git_commit) + "\n\n";
78 BOOST_FOREACH (string i, environment_info ()) {
85 body += "log head and tail:\n";
86 body += "---<8----\n";
87 body += _film->log()->head_and_tail (4096);
88 body += "---<8----\n\n";
90 add_file (body, "ffprobe.log");
92 body += "---<8----\n";
93 body += _film->metadata()->write_to_string_formatted("UTF-8");
94 body += "---<8----\n";
98 to.push_back ("carl@dcpomatic.com");
100 Emailer emailer (_from, to, "DCP-o-matic problem report", body);
101 emailer.send ("main.carlh.net", 2525);
104 set_state (FINISHED_OK);
108 SendProblemReportJob::add_file (string& body, boost::filesystem::path file) const
110 FILE* f = fopen_boost (_film->file (file), "r");
115 body += file.string() + ":\n";
116 body += "---<8----\n";
117 uintmax_t const size = boost::filesystem::file_size (_film->file (file));
118 char* buffer = new char[size + 1];
119 int const N = fread (buffer, 1, size, f);
123 body += "---<8----\n\n";