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 9d957bf154d90c63c5301da592cc9a3aec3a52ad..16eabd8d4a7da72471cde41fb2af72262c26427d 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 9584a3f236200a22bbabd576221de1784d9bdcce..37c9e1fb55cb5684aaba45612b8bdcc6c5ba2ba2 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 49f29cc42b05562927d001461b303b2899d37eac..4458869db8cd56bac83e2c97daeee01914ed8d09 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 7c0f68787c2d39366452b0ef41963b98a66e0c7d..ea2d22462932fb5d6d1edf89ecd084d0391883c1 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 10a69c41644517483c0a8cee5575d5b025417449..4eb9c7f333bab943a4ddefc80a08cf77195c3096 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 0d77f0862b3f0876951e03314396cf6f73ef555b..7eff1b719bf5eadc74c7967aa86ffd561b239f36 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 13e2fb11d354588284984416fcb72388a02c674e..1bba69f9b42d549f68bcd25d33060b9efb3f8076 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 9330b1b60b7e579fe67bce611c5d422dd1352580..47237eee6de872fe607d98b653893f6cffc986fa 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 df0df54896a87e3cfc6c92b674fe3a496217dc04..20ce9e475b3a9737cb3bf3017182ac1026c214f1 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 f3dbaf6d9a959fbf4e7c83c475ba8af32331771c..f35c9adc9fc8288eea5944176de7c9ef01dd5dfb 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