#include "util.h"
#include "emailer.h"
#include "compose.hpp"
+#include "log.h"
#include <zip.h>
#include <boost/foreach.hpp>
using std::list;
using std::cout;
using std::string;
+using std::runtime_error;
using boost::shared_ptr;
void
struct zip_source* source = zip_source_buffer (zip, kdm->c_str(), kdm->length(), 0);
if (!source) {
- throw StringError ("could not create ZIP source");
+ throw runtime_error ("could not create ZIP source");
}
if (zip_add (zip, i.filename(film_name).c_str(), source) == -1) {
- throw StringError ("failed to add KDM to ZIP archive");
+ throw runtime_error ("failed to add KDM to ZIP archive");
}
}
if (zip_close (zip) == -1) {
- throw StringError ("failed to close ZIP archive");
+ throw runtime_error ("failed to close ZIP archive");
}
}
}
}
+/** @param log Log to write email session transcript to, or 0 */
/* XXX: should probably get from/to from the KDMs themselves */
void
-CinemaKDMs::email (string film_name, string cpl_name, list<CinemaKDMs> cinema_kdms, dcp::LocalTime from, dcp::LocalTime to, shared_ptr<Job> job)
+CinemaKDMs::email (
+ string film_name, string cpl_name, list<CinemaKDMs> cinema_kdms, dcp::LocalTime from, dcp::LocalTime to, shared_ptr<Job> job, shared_ptr<Log> log
+ )
{
Config* config = Config::instance ();
string const name = tidy_for_filename(i.cinema->name) + "_" + tidy_for_filename(film_name) + ".zip";
email.add_attachment (zip_file, name, "application/zip");
email.send (job);
+
+ if (log) {
+ log->log (email.notes(), LogEntry::TYPE_DEBUG_EMAIL);
+ }
}
}