From c658aec3ffd5009cbe7fa2540da5a0579e2f2e8c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 11 Oct 2015 22:18:57 +0100 Subject: [PATCH] Add debug option to log SMTP session transcripts. --- ChangeLog | 3 +++ src/lib/cinema_kdms.cc | 10 +++++++++- src/lib/cinema_kdms.h | 4 +++- src/lib/log_entry.cc | 1 + src/lib/log_entry.h | 1 + src/lib/send_kdm_email_job.cc | 7 +++++-- src/lib/send_kdm_email_job.h | 5 ++++- src/tools/dcpomatic.cc | 3 ++- src/tools/dcpomatic_kdm.cc | 3 ++- src/wx/config_dialog.cc | 9 +++++++++ 10 files changed, 39 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d957bf15..16eabd8d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2015-10-11 Carl Hetherington + * Add option to log SMTP session transcripts + for debugging failures to send email. + * Provide progress indication when finding subtitles (#711). 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 #include @@ -113,9 +114,12 @@ CinemaKDMs::write_zip_files (string film_name, list 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 cinema_kdms, dcp::LocalTime from, dcp::LocalTime to, shared_ptr job) +CinemaKDMs::email ( + string film_name, string cpl_name, list cinema_kdms, dcp::LocalTime from, dcp::LocalTime to, shared_ptr job, shared_ptr log + ) { Config* config = Config::instance (); @@ -159,5 +163,9 @@ CinemaKDMs::email (string film_name, string cpl_name, list 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 cinema_kdms, dcp::LocalTime from, dcp::LocalTime to, - boost::shared_ptr job + boost::shared_ptr job, + boost::shared_ptr log ); boost::shared_ptr 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 cinema_kdms + list cinema_kdms, + shared_ptr log ) : Job (shared_ptr()) , _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 cinema_kdms + std::list cinema_kdms, + boost::shared_ptr log ); std::string name () const; @@ -45,4 +47,5 @@ private: boost::posix_time::ptime _from; boost::posix_time::ptime _to; std::list _cinema_kdms; + boost::shared_ptr _log; }; diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 9330b1b60..47237eee6 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -460,7 +460,8 @@ private: _film->dcp_name(), d->from(), d->until(), - CinemaKDMs::collect (screen_kdms) + CinemaKDMs::collect (screen_kdms), + _film->log() )) ); } diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index df0df5489..20ce9e475 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -285,7 +285,8 @@ private: film_name, decrypted.content_title_text(), _timing->from(), _timing->until(), - CinemaKDMs::collect (screen_kdms) + CinemaKDMs::collect (screen_kdms), + shared_ptr () )); JobManager::instance()->add (job); diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index f3dbaf6d9..f35c9adc9 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -1278,6 +1278,7 @@ public: , _log_timing (0) , _log_debug_decode (0) , _log_debug_encode (0) + , _log_debug_email (0) {} private: @@ -1326,6 +1327,8 @@ private: t->Add (_log_debug_decode, 1, wxEXPAND | wxALL); _log_debug_encode = new wxCheckBox (_panel, wxID_ANY, _("Debug: encode")); t->Add (_log_debug_encode, 1, wxEXPAND | wxALL); + _log_debug_email = new wxCheckBox (_panel, wxID_ANY, _("Debug: email sending")); + t->Add (_log_debug_email, 1, wxEXPAND | wxALL); table->Add (t, 0, wxALL, 6); } @@ -1345,6 +1348,7 @@ private: _log_timing->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AdvancedPage::log_changed, this)); _log_debug_decode->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AdvancedPage::log_changed, this)); _log_debug_encode->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AdvancedPage::log_changed, this)); + _log_debug_email->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AdvancedPage::log_changed, this)); #ifdef DCPOMATIC_WINDOWS _win32_console->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AdvancedPage::win32_console_changed, this)); #endif @@ -1363,6 +1367,7 @@ private: checked_set (_log_timing, config->log_types() & LogEntry::TYPE_TIMING); checked_set (_log_debug_decode, config->log_types() & LogEntry::TYPE_DEBUG_DECODE); checked_set (_log_debug_encode, config->log_types() & LogEntry::TYPE_DEBUG_ENCODE); + checked_set (_log_debug_email, config->log_types() & LogEntry::TYPE_DEBUG_EMAIL); #ifdef DCPOMATIC_WINDOWS checked_set (_win32_console, config->win32_console()); #endif @@ -1404,6 +1409,9 @@ private: if (_log_debug_encode->GetValue ()) { types |= LogEntry::TYPE_DEBUG_ENCODE; } + if (_log_debug_email->GetValue ()) { + types |= LogEntry::TYPE_DEBUG_EMAIL; + } Config::instance()->set_log_types (types); } @@ -1423,6 +1431,7 @@ private: wxCheckBox* _log_timing; wxCheckBox* _log_debug_decode; wxCheckBox* _log_debug_encode; + wxCheckBox* _log_debug_email; #ifdef DCPOMATIC_WINDOWS wxCheckBox* _win32_console; #endif -- 2.30.2