Add configuration of KDM SMTP port; remove slight warning about plaintext passwords.
authorCarl Hetherington <cth@carlh.net>
Mon, 6 Jul 2015 00:45:02 +0000 (01:45 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 6 Jul 2015 00:45:02 +0000 (01:45 +0100)
src/lib/config.cc
src/lib/config.h
src/lib/kdm.cc
src/wx/config_dialog.cc

index ee38e98665994ce4c87380e400032b4dd35adf45..657d79b7148a6d4c2333eaed127f8524c0f7679a 100644 (file)
@@ -75,6 +75,7 @@ Config::set_defaults ()
        _default_dcp_content_type = DCPContentType::from_isdcf_name ("FTR");
        _default_j2k_bandwidth = 100000000;
        _default_audio_delay = 0;
+       _mail_port = 25;
        _check_for_updates = false;
        _check_for_test_updates = false;
        _maximum_j2k_bandwidth = 250000000;
@@ -192,6 +193,7 @@ Config::read ()
        }
 
        _mail_server = f.string_child ("MailServer");
+       _mail_port = f.optional_number_child<int> ("MailPort").get_value_or (25);
        _mail_user = f.optional_string_child("MailUser").get_value_or ("");
        _mail_password = f.optional_string_child("MailPassword").get_value_or ("");
        _kdm_subject = f.optional_string_child ("KDMSubject").get_value_or (_("KDM delivery: $CPL_NAME"));
@@ -342,6 +344,7 @@ Config::write () const
        }
 
        root->add_child("MailServer")->add_child_text (_mail_server);
+       root->add_child("MailPort")->add_child_text (raw_convert<string> (_mail_port));
        root->add_child("MailUser")->add_child_text (_mail_user);
        root->add_child("MailPassword")->add_child_text (_mail_password);
        root->add_child("KDMSubject")->add_child_text (_kdm_subject);
index 0040591f165543c4b895c9171397aa91b7e95eaa..a5fdc17c0cff7293caaea2f17ce80d1a65010ff7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -157,6 +157,10 @@ public:
                return _mail_server;
        }
 
+       int mail_port () const {
+               return _mail_port;
+       }
+
        std::string mail_user () const {
                return _mail_user;
        }
@@ -324,6 +328,10 @@ public:
                maybe_set (_mail_server, s);
        }
 
+       void set_mail_port (int p) {
+               maybe_set (_mail_port, p);
+       }
+
        void set_mail_user (std::string u) {
                maybe_set (_mail_user, u);
        }
@@ -458,6 +466,7 @@ private:
        int _default_audio_delay;
        std::list<boost::shared_ptr<Cinema> > _cinemas;
        std::string _mail_server;
+       int _mail_port;
        std::string _mail_user;
        std::string _mail_password;
        std::string _kdm_subject;
index 8489eed3352d34cb45e1bfa83bf6126d0d2b591a..f9b21c525a2bbc266dce7bbb3d391caa5c708c34 100644 (file)
@@ -271,19 +271,23 @@ email_kdms (
                quickmail_set_body (mail, body.c_str());
                quickmail_add_attachment_file (mail, zip_file.string().c_str(), "application/zip");
 
-               int const port = Config::instance()->mail_user().empty() ? 25 : 587;
-
                char const* error = quickmail_send (
                        mail,
                        Config::instance()->mail_server().c_str(),
-                       port,
+                       Config::instance()->mail_port(),
                        Config::instance()->mail_user().c_str(),
                        Config::instance()->mail_password().c_str()
                        );
 
                if (error) {
                        quickmail_destroy (mail);
-                       throw KDMError (String::compose ("Failed to send KDM email (%1)", error));
+                       throw KDMError (
+                               String::compose (
+                                       "Failed to send KDM email to %1 (%2)",
+                                       Config::instance()->mail_server(),
+                                       error
+                                       )
+                               );
                }
                quickmail_destroy (mail);
        }
index 34aaa779542a5b577e186b8ea655e19ebd77217d..53ed7c44b738074146f557bc4e863f6a38dc37f4 100644 (file)
  *  @brief A dialogue to edit DCP-o-matic configuration.
  */
 
-#include <iostream>
-#include <boost/lexical_cast.hpp>
-#include <boost/filesystem.hpp>
-#include <wx/stdpaths.h>
-#include <wx/preferences.h>
-#include <wx/filepicker.h>
-#include <wx/spinctrl.h>
-#include <dcp/exceptions.h>
-#include <dcp/signer.h>
-#include "lib/config.h"
-#include "lib/ratio.h"
-#include "lib/filter.h"
-#include "lib/dcp_content_type.h"
-#include "lib/log.h"
-#include "lib/util.h"
-#include "lib/cross.h"
-#include "lib/exceptions.h"
 #include "config_dialog.h"
 #include "wx_util.h"
 #include "editable_list.h"
 #include "isdcf_metadata_dialog.h"
 #include "server_dialog.h"
 #include "make_signer_chain_dialog.h"
+#include "lib/config.h"
+#include "lib/ratio.h"
+#include "lib/filter.h"
+#include "lib/dcp_content_type.h"
+#include "lib/log.h"
+#include "lib/util.h"
+#include "lib/raw_convert.h"
+#include "lib/cross.h"
+#include "lib/exceptions.h"
+#include <dcp/exceptions.h>
+#include <dcp/signer.h>
+#include <wx/stdpaths.h>
+#include <wx/preferences.h>
+#include <wx/filepicker.h>
+#include <wx/spinctrl.h>
+#include <boost/lexical_cast.hpp>
+#include <boost/filesystem.hpp>
+#include <iostream>
 
 using std::vector;
 using std::string;
@@ -976,8 +977,16 @@ private:
                _panel->GetSizer()->Add (table, 1, wxEXPAND | wxALL, _border);
 
                add_label_to_sizer (table, _panel, _("Outgoing mail server"), true);
-               _mail_server = new wxTextCtrl (_panel, wxID_ANY);
-               table->Add (_mail_server, 1, wxEXPAND | wxALL);
+               {
+                       wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+                       _mail_server = new wxTextCtrl (_panel, wxID_ANY);
+                       s->Add (_mail_server, 1, wxEXPAND | wxALL);
+                       add_label_to_sizer (s, _panel, _("port"), false);
+                       _mail_port = new wxSpinCtrl (_panel, wxID_ANY);
+                       _mail_port->SetRange (0, 65535);
+                       s->Add (_mail_port);
+                       table->Add (s, 1, wxEXPAND | wxALL);
+               }
 
                add_label_to_sizer (table, _panel, _("Mail user name"), true);
                _mail_user = new wxTextCtrl (_panel, wxID_ANY);
@@ -987,13 +996,6 @@ private:
                _mail_password = new wxTextCtrl (_panel, wxID_ANY);
                table->Add (_mail_password, 1, wxEXPAND | wxALL);
 
-               wxStaticText* plain = add_label_to_sizer (table, _panel, _("(password will be stored on disk in plaintext)"), false);
-               wxFont font = plain->GetFont();
-               font.SetStyle (wxFONTSTYLE_ITALIC);
-               font.SetPointSize (font.GetPointSize() - 1);
-               plain->SetFont (font);
-               table->AddSpacer (0);
-
                add_label_to_sizer (table, _panel, _("Subject"), true);
                _kdm_subject = new wxTextCtrl (_panel, wxID_ANY);
                table->Add (_kdm_subject, 1, wxEXPAND | wxALL);
@@ -1017,6 +1019,7 @@ private:
                _panel->GetSizer()->Add (_reset_kdm_email, 0, wxEXPAND | wxALL, _border);
 
                _mail_server->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KDMEmailPage::mail_server_changed, this));
+               _mail_port->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&KDMEmailPage::mail_port_changed, this));
                _mail_user->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KDMEmailPage::mail_user_changed, this));
                _mail_password->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KDMEmailPage::mail_password_changed, this));
                _kdm_subject->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KDMEmailPage::kdm_subject_changed, this));
@@ -1032,6 +1035,7 @@ private:
                Config* config = Config::instance ();
 
                checked_set (_mail_server, config->mail_server ());
+               checked_set (_mail_port, config->mail_port ());
                checked_set (_mail_user, config->mail_user ());
                checked_set (_mail_password, config->mail_password ());
                checked_set (_kdm_subject, config->kdm_subject ());
@@ -1046,6 +1050,11 @@ private:
                Config::instance()->set_mail_server (wx_to_std (_mail_server->GetValue ()));
        }
 
+       void mail_port_changed ()
+       {
+               Config::instance()->set_mail_port (_mail_port->GetValue ());
+       }
+
        void mail_user_changed ()
        {
                Config::instance()->set_mail_user (wx_to_std (_mail_user->GetValue ()));
@@ -1094,6 +1103,7 @@ private:
        }
 
        wxTextCtrl* _mail_server;
+       wxSpinCtrl* _mail_port;
        wxTextCtrl* _mail_user;
        wxTextCtrl* _mail_password;
        wxTextCtrl* _kdm_subject;