Config* c = Config::instance ();
try {
- email.send (c->mail_server(), c->mail_port(), c->mail_user(), c->mail_password());
+ email.send (c->mail_server(), c->mail_port(), c->mail_protocol(), c->mail_user(), c->mail_password());
} catch (...) {
boost::filesystem::remove (zip_file);
dcpomatic_log->log ("Email content follows", LogEntry::TYPE_DEBUG_EMAIL);
_use_any_servers = true;
_servers.clear ();
_only_servers_encode = false;
- _tms_protocol = PROTOCOL_SCP;
+ _tms_protocol = FILE_TRANSFER_PROTOCOL_SCP;
_tms_ip = "";
_tms_path = ".";
_tms_user = "";
_default_upload_after_make_dcp = false;
_mail_server = "";
_mail_port = 25;
+ _mail_protocol = EMAIL_PROTOCOL_AUTO;
_mail_user = "";
_mail_password = "";
_kdm_from = "";
}
_only_servers_encode = f.optional_bool_child ("OnlyServersEncode").get_value_or (false);
- _tms_protocol = static_cast<Protocol> (f.optional_number_child<int> ("TMSProtocol").get_value_or (static_cast<int> (PROTOCOL_SCP)));
+ _tms_protocol = static_cast<FileTransferProtocol>(f.optional_number_child<int>("TMSProtocol").get_value_or(static_cast<int>(FILE_TRANSFER_PROTOCOL_SCP)));
_tms_ip = f.string_child ("TMSIP");
_tms_path = f.string_child ("TMSPath");
_tms_user = f.string_child ("TMSUser");
_mail_server = f.string_child ("MailServer");
_mail_port = f.optional_number_child<int> ("MailPort").get_value_or (25);
+
+ {
+ /* Make sure this matches the code in write_config */
+ string const protocol = f.optional_string_child("MailProtocol").get_value_or("Auto");
+ if (protocol == "Auto") {
+ _mail_protocol = EMAIL_PROTOCOL_AUTO;
+ } else if (protocol == "Plain") {
+ _mail_protocol = EMAIL_PROTOCOL_PLAIN;
+ } else if (protocol == "STARTTLS") {
+ _mail_protocol = EMAIL_PROTOCOL_STARTTLS;
+ } else if (protocol == "SSL") {
+ _mail_protocol = EMAIL_PROTOCOL_SSL;
+ }
+ }
+
_mail_user = f.optional_string_child("MailUser").get_value_or ("");
_mail_password = f.optional_string_child("MailPassword").get_value_or ("");
root->add_child("MailServer")->add_child_text (_mail_server);
/* [XML] MailPort Port number to use on SMTP server. */
root->add_child("MailPort")->add_child_text (raw_convert<string> (_mail_port));
+ /* [XML] MailProtocol Protocol to use on SMTP server (Auto, Plain, STARTTLS or SSL) */
+ switch (_mail_protocol) {
+ case EMAIL_PROTOCOL_AUTO:
+ root->add_child("MailProtocol")->add_child_text("Auto");
+ break;
+ case EMAIL_PROTOCOL_PLAIN:
+ root->add_child("MailProtocol")->add_child_text("Plain");
+ break;
+ case EMAIL_PROTOCOL_STARTTLS:
+ root->add_child("MailProtocol")->add_child_text("STARTTLS");
+ break;
+ case EMAIL_PROTOCOL_SSL:
+ root->add_child("MailProtocol")->add_child_text("SSL");
+ break;
+ }
/* [XML] MailUser Username to use on SMTP server. */
root->add_child("MailUser")->add_child_text (_mail_user);
/* [XML] MailPassword Password to use on SMTP server. */
return _only_servers_encode;
}
- Protocol tms_protocol () const {
+ FileTransferProtocol tms_protocol () const {
return _tms_protocol;
}
return _mail_port;
}
+ EmailProtocol mail_protocol () const {
+ return _mail_protocol;
+ }
+
std::string mail_user () const {
return _mail_user;
}
maybe_set (_only_servers_encode, o);
}
- void set_tms_protocol (Protocol p) {
+ void set_tms_protocol (FileTransferProtocol p) {
maybe_set (_tms_protocol, p);
}
maybe_set (_mail_port, p);
}
+ void set_mail_protocol (EmailProtocol p) {
+ maybe_set (_mail_protocol, p);
+ }
+
void set_mail_user (std::string u) {
maybe_set (_mail_user, u);
}
/** J2K encoding servers that should definitely be used */
std::vector<std::string> _servers;
bool _only_servers_encode;
- Protocol _tms_protocol;
+ FileTransferProtocol _tms_protocol;
/** The IP address of a TMS that we can copy DCPs to */
std::string _tms_ip;
/** The path on a TMS that we should write DCPs to */
std::list<boost::shared_ptr<Cinema> > _cinemas;
std::string _mail_server;
int _mail_port;
+ EmailProtocol _mail_protocol;
std::string _mail_user;
std::string _mail_password;
std::string _kdm_subject;
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
}
void
-Emailer::send (string server, int port, string user, string password)
+Emailer::send (string server, int port, EmailProtocol protocol, string user, string password)
{
char date_buffer[128];
time_t now = time (0);
throw NetworkError ("Could not initialise libcurl");
}
- if (port == 465) {
- /* "Implicit TLS"; I think curl wants us to use smtps here */
- curl_easy_setopt (curl, CURLOPT_URL, String::compose ("smtps://%1:465", server).c_str());
+ if ((protocol == EMAIL_PROTOCOL_AUTO && port == 465) || protocol == EMAIL_PROTOCOL_SSL) {
+ /* "SSL" or "Implicit TLS"; I think curl wants us to use smtps here */
+ curl_easy_setopt (curl, CURLOPT_URL, String::compose("smtps://%1:%2", server, port).c_str());
} else {
- curl_easy_setopt (curl, CURLOPT_URL, String::compose ("smtp://%1:%2", server, port).c_str());
+ curl_easy_setopt (curl, CURLOPT_URL, String::compose("smtp://%1:%2", server, port).c_str());
}
if (!user.empty ()) {
curl_easy_setopt (curl, CURLOPT_READDATA, this);
curl_easy_setopt (curl, CURLOPT_UPLOAD, 1L);
- curl_easy_setopt (curl, CURLOPT_USE_SSL, (long) CURLUSESSL_TRY);
+ if (protocol == EMAIL_PROTOCOL_AUTO || protocol == EMAIL_PROTOCOL_STARTTLS) {
+ curl_easy_setopt (curl, CURLOPT_USE_SSL, (long) CURLUSESSL_TRY);
+ }
curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt (curl, CURLOPT_VERBOSE, 1L);
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
void add_bcc (std::string bcc);
void add_attachment (boost::filesystem::path file, std::string name, std::string mime_type);
- void send (std::string server, int port, std::string user = "", std::string password = "");
+ void send (std::string server, int port, EmailProtocol protocol, std::string user = "", std::string password = "");
std::string notes () const {
return _notes;
#include "dcpomatic_time.h"
#include "rgba.h"
#include "ffmpeg_stream.h"
+#include <boost/thread/mutex.hpp>
#include <map>
class FFmpegSubtitleStream : public FFmpegStream
}
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
+#include <boost/thread/mutex.hpp>
class Image;
class ImageProxy;
email.add_bcc (config->notification_bcc ());
}
- email.send (config->mail_server(), config->mail_port(), config->mail_user(), config->mail_password());
+ email.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password());
set_progress (1);
set_state (FINISHED_OK);
to.push_back ("carl@dcpomatic.com");
Emailer emailer (_from, to, "DCP-o-matic problem report", body);
- emailer.send ("main.carlh.net", 2525);
+ emailer.send ("main.carlh.net", 2525, EMAIL_PROTOCOL_STARTTLS);
set_progress (1);
set_state (FINISHED_OK);
std::string resolution_to_string (Resolution);
Resolution string_to_resolution (std::string);
-enum Protocol {
- PROTOCOL_SCP,
- PROTOCOL_FTP
+enum FileTransferProtocol {
+ FILE_TRANSFER_PROTOCOL_SCP,
+ FILE_TRANSFER_PROTOCOL_FTP
+};
+
+enum EmailProtocol {
+ EMAIL_PROTOCOL_AUTO,
+ EMAIL_PROTOCOL_PLAIN,
+ EMAIL_PROTOCOL_STARTTLS,
+ EMAIL_PROTOCOL_SSL
};
#endif
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
scoped_ptr<Uploader> uploader;
switch (Config::instance()->tms_protocol ()) {
- case PROTOCOL_SCP:
+ case FILE_TRANSFER_PROTOCOL_SCP:
uploader.reset (new SCPUploader (bind (&UploadJob::set_status, this, _1), bind (&UploadJob::set_progress, this, _1, false)));
break;
- case PROTOCOL_FTP:
+ case FILE_TRANSFER_PROTOCOL_FTP:
uploader.reset (new CurlUploader (bind (&UploadJob::set_status, this, _1), bind (&UploadJob::set_progress, this, _1, false)));
break;
}
list<string> to;
to.push_back ("carl@dcpomatic.com");
Emailer emailer (d->email(), to, "DCP-o-matic translations", body);
- emailer.send ("main.carlh.net", 2525);
+ emailer.send ("main.carlh.net", 2525, EMAIL_PROTOCOL_STARTTLS);
}
d->Destroy ();
void tms_protocol_changed ()
{
- Config::instance()->set_tms_protocol (static_cast<Protocol> (_tms_protocol->GetSelection ()));
+ Config::instance()->set_tms_protocol(static_cast<FileTransferProtocol>(_tms_protocol->GetSelection()));
}
void tms_ip_changed ()
_port = new wxSpinCtrl (_panel, wxID_ANY);
_port->SetRange (0, 65535);
s->Add (_port);
+ add_label_to_sizer (s, _panel, _("protocol"), false);
+ _protocol = new wxChoice (_panel, wxID_ANY);
+ /* Make sure this matches the switches in config_changed and port_changed below */
+ _protocol->Append (_("Auto"));
+ _protocol->Append (_("Plain"));
+ _protocol->Append (_("STARTTLS"));
+ _protocol->Append (_("SSL"));
+ s->Add (_protocol);
table->Add (s, 1, wxEXPAND | wxALL);
}
_server->Bind (wxEVT_TEXT, boost::bind (&EmailPage::server_changed, this));
_port->Bind (wxEVT_SPINCTRL, boost::bind (&EmailPage::port_changed, this));
+ _protocol->Bind (wxEVT_CHOICE, boost::bind (&EmailPage::protocol_changed, this));
_user->Bind (wxEVT_TEXT, boost::bind (&EmailPage::user_changed, this));
_password->Bind (wxEVT_TEXT, boost::bind (&EmailPage::password_changed, this));
}
checked_set (_server, config->mail_server ());
checked_set (_port, config->mail_port ());
+ switch (config->mail_protocol()) {
+ case EMAIL_PROTOCOL_AUTO:
+ checked_set (_protocol, 0);
+ break;
+ case EMAIL_PROTOCOL_PLAIN:
+ checked_set (_protocol, 1);
+ break;
+ case EMAIL_PROTOCOL_STARTTLS:
+ checked_set (_protocol, 2);
+ break;
+ case EMAIL_PROTOCOL_SSL:
+ checked_set (_protocol, 3);
+ break;
+ }
checked_set (_user, config->mail_user ());
checked_set (_password, config->mail_password ());
}
Config::instance()->set_mail_port (_port->GetValue ());
}
+ void protocol_changed ()
+ {
+ switch (_protocol->GetSelection()) {
+ case 0:
+ Config::instance()->set_mail_protocol(EMAIL_PROTOCOL_AUTO);
+ break;
+ case 1:
+ Config::instance()->set_mail_protocol(EMAIL_PROTOCOL_PLAIN);
+ break;
+ case 2:
+ Config::instance()->set_mail_protocol(EMAIL_PROTOCOL_STARTTLS);
+ break;
+ case 3:
+ Config::instance()->set_mail_protocol(EMAIL_PROTOCOL_SSL);
+ break;
+ }
+ }
+
void user_changed ()
{
Config::instance()->set_mail_user (wx_to_std (_user->GetValue ()));
wxTextCtrl* _server;
wxSpinCtrl* _port;
+ wxChoice* _protocol;
wxTextCtrl* _user;
wxTextCtrl* _password;
};