Add debug option to log SMTP session transcripts.
authorCarl Hetherington <cth@carlh.net>
Sun, 11 Oct 2015 21:18:57 +0000 (22:18 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 11 Oct 2015 21:18:57 +0000 (22:18 +0100)
ChangeLog
src/lib/cinema_kdms.cc
src/lib/cinema_kdms.h
src/lib/log_entry.cc
src/lib/log_entry.h
src/lib/send_kdm_email_job.cc
src/lib/send_kdm_email_job.h
src/tools/dcpomatic.cc
src/tools/dcpomatic_kdm.cc
src/wx/config_dialog.cc

index 9d957bf..16eabd8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-10-11  Carl Hetherington  <cth@carlh.net>
 
+       * Add option to log SMTP session transcripts
+       for debugging failures to send email.
+
        * Provide progress indication when finding
        subtitles (#711).
 
index 9584a3f..37c9e1f 100644 (file)
@@ -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);
+               }
        }
 }
index 49f29cc..4458869 100644 (file)
@@ -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;
index 7c0f687..ea2d224 100644 (file)
@@ -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;
 
index 10a69c4..4eb9c7f 100644 (file)
@@ -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 () {}
index 0d77f08..7eff1b7 100644 (file)
@@ -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);
 }
index 13e2fb1..1bba69f 100644 (file)
@@ -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;
 };
index 9330b1b..47237ee 100644 (file)
@@ -460,7 +460,8 @@ private:
                                                                 _film->dcp_name(),
                                                                 d->from(),
                                                                 d->until(),
-                                                                CinemaKDMs::collect (screen_kdms)
+                                                                CinemaKDMs::collect (screen_kdms),
+                                                                _film->log()
                                                                 ))
                                        );
                        }
index df0df54..20ce9e4 100644 (file)
@@ -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<Log> ()
                                                             ));
 
                                JobManager::instance()->add (job);
index f3dbaf6..f35c9ad 100644 (file)
@@ -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