2015-10-11 Carl Hetherington <cth@carlh.net>
+ * Add option to log SMTP session transcripts
+ for debugging failures to send email.
+
* Version 2.4.9 released.
2015-10-11 Carl Hetherington <cth@carlh.net>
#include "util.h"
#include "emailer.h"
#include "compose.hpp"
+#include "log.h"
#include <zip.h>
#include <boost/foreach.hpp>
}
}
+/** @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);
+ }
}
}
class Cinema;
class Job;
+class Log;
class CinemaKDMs
{
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;
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;
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 () {}
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)
, _from (from)
, _to (to)
, _cinema_kdms (cinema_kdms)
+ , _log (log)
{
}
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);
}
class Screen;
class CinemaKDMs;
+class Log;
class SendKDMEmailJob : public Job
{
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;
boost::posix_time::ptime _from;
boost::posix_time::ptime _to;
std::list<CinemaKDMs> _cinema_kdms;
+ boost::shared_ptr<Log> _log;
};
_film->dcp_name(),
d->from(),
d->until(),
- CinemaKDMs::collect (screen_kdms)
+ CinemaKDMs::collect (screen_kdms),
+ _film->log()
))
);
}
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);
, _log_timing (0)
, _log_debug_decode (0)
, _log_debug_encode (0)
+ , _log_debug_email (0)
{}
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);
}
_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
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
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);
}
wxCheckBox* _log_timing;
wxCheckBox* _log_debug_decode;
wxCheckBox* _log_debug_encode;
+ wxCheckBox* _log_debug_email;
#ifdef DCPOMATIC_WINDOWS
wxCheckBox* _win32_console;
#endif