summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-10-11 22:18:57 +0100
committerCarl Hetherington <cth@carlh.net>2015-10-11 22:18:57 +0100
commitc658aec3ffd5009cbe7fa2540da5a0579e2f2e8c (patch)
treeb460bea7792310d4c89a15601fea04d9db83b52c /src/lib
parent27bd2c44278ccf181b11ba961649a3e9b3ae03af (diff)
Add debug option to log SMTP session transcripts.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cinema_kdms.cc10
-rw-r--r--src/lib/cinema_kdms.h4
-rw-r--r--src/lib/log_entry.cc1
-rw-r--r--src/lib/log_entry.h1
-rw-r--r--src/lib/send_kdm_email_job.cc7
-rw-r--r--src/lib/send_kdm_email_job.h5
6 files changed, 23 insertions, 5 deletions
diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc
index 9584a3f23..37c9e1fb5 100644
--- a/src/lib/cinema_kdms.cc
+++ b/src/lib/cinema_kdms.cc
@@ -25,6 +25,7 @@
#include "util.h"
#include "emailer.h"
#include "compose.hpp"
+#include "log.h"
#include <zip.h>
#include <boost/foreach.hpp>
@@ -113,9 +114,12 @@ CinemaKDMs::write_zip_files (string film_name, list<CinemaKDMs> cinema_kdms, boo
}
}
+/** @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 ();
@@ -159,5 +163,9 @@ CinemaKDMs::email (string film_name, string cpl_name, list<CinemaKDMs> cinema_kd
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);
+ }
}
}
diff --git a/src/lib/cinema_kdms.h b/src/lib/cinema_kdms.h
index 49f29cc42..4458869db 100644
--- a/src/lib/cinema_kdms.h
+++ b/src/lib/cinema_kdms.h
@@ -21,6 +21,7 @@
class Cinema;
class Job;
+class Log;
class CinemaKDMs
{
@@ -35,7 +36,8 @@ public:
std::list<CinemaKDMs> cinema_kdms,
dcp::LocalTime from,
dcp::LocalTime to,
- boost::shared_ptr<Job> job
+ boost::shared_ptr<Job> job,
+ boost::shared_ptr<Log> log
);
boost::shared_ptr<Cinema> cinema;
diff --git a/src/lib/log_entry.cc b/src/lib/log_entry.cc
index 7c0f68787..ea2d22462 100644
--- a/src/lib/log_entry.cc
+++ b/src/lib/log_entry.cc
@@ -28,6 +28,7 @@ int const LogEntry::TYPE_ERROR = 0x4;
int const LogEntry::TYPE_DEBUG_DECODE = 0x8;
int const LogEntry::TYPE_DEBUG_ENCODE = 0x10;
int const LogEntry::TYPE_TIMING = 0x20;
+int const LogEntry::TYPE_DEBUG_EMAIL = 0x40;
using std::string;
diff --git a/src/lib/log_entry.h b/src/lib/log_entry.h
index 10a69c416..4eb9c7f33 100644
--- a/src/lib/log_entry.h
+++ b/src/lib/log_entry.h
@@ -33,6 +33,7 @@ public:
static const int TYPE_DEBUG_DECODE;
static const int TYPE_DEBUG_ENCODE;
static const int TYPE_TIMING;
+ static const int TYPE_DEBUG_EMAIL;
LogEntry (int type);
virtual ~LogEntry () {}
diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc
index 0d77f0862..7eff1b719 100644
--- a/src/lib/send_kdm_email_job.cc
+++ b/src/lib/send_kdm_email_job.cc
@@ -29,12 +29,14 @@ using std::string;
using std::list;
using boost::shared_ptr;
+/** @param log Log to write to, or 0 */
SendKDMEmailJob::SendKDMEmailJob (
string film_name,
string cpl_name,
boost::posix_time::ptime from,
boost::posix_time::ptime to,
- list<CinemaKDMs> cinema_kdms
+ list<CinemaKDMs> cinema_kdms,
+ shared_ptr<Log> log
)
: Job (shared_ptr<Film>())
, _film_name (film_name)
@@ -42,6 +44,7 @@ SendKDMEmailJob::SendKDMEmailJob (
, _from (from)
, _to (to)
, _cinema_kdms (cinema_kdms)
+ , _log (log)
{
}
@@ -66,7 +69,7 @@ void
SendKDMEmailJob::run ()
{
set_progress_unknown ();
- CinemaKDMs::email (_film_name, _cpl_name, _cinema_kdms, _from, _to, shared_from_this ());
+ CinemaKDMs::email (_film_name, _cpl_name, _cinema_kdms, _from, _to, shared_from_this(), _log);
set_progress (1);
set_state (FINISHED_OK);
}
diff --git a/src/lib/send_kdm_email_job.h b/src/lib/send_kdm_email_job.h
index 13e2fb11d..1bba69f9b 100644
--- a/src/lib/send_kdm_email_job.h
+++ b/src/lib/send_kdm_email_job.h
@@ -23,6 +23,7 @@
class Screen;
class CinemaKDMs;
+class Log;
class SendKDMEmailJob : public Job
{
@@ -32,7 +33,8 @@ public:
std::string cpl_name,
boost::posix_time::ptime from,
boost::posix_time::ptime to,
- std::list<CinemaKDMs> cinema_kdms
+ std::list<CinemaKDMs> cinema_kdms,
+ boost::shared_ptr<Log> log
);
std::string name () const;
@@ -45,4 +47,5 @@ private:
boost::posix_time::ptime _from;
boost::posix_time::ptime _to;
std::list<CinemaKDMs> _cinema_kdms;
+ boost::shared_ptr<Log> _log;
};