Merge branch '2.0' of ssh://git.carlh.net/home/carl/git/dcpomatic2 into 2.0
authorCarl Hetherington <cth@carlh.net>
Mon, 6 Jul 2015 19:42:12 +0000 (20:42 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 6 Jul 2015 19:42:12 +0000 (20:42 +0100)
1  2 
src/lib/config.cc
src/lib/config.h
src/lib/kdm.cc
src/wx/config_dialog.cc

diff --combined src/lib/config.cc
index 657d79b7148a6d4c2333eaed127f8524c0f7679a,16a3849b51cc93da95af614b923d44bcfec5a8b7..b5e87267ad9ec6edca742b1c0c64dbaffa56869b
@@@ -75,7 -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;
@@@ -193,7 -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"));
@@@ -344,7 -342,6 +344,7 @@@ Config::write () cons
        }
  
        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);
@@@ -410,9 -407,9 +410,9 @@@ Config::drop (
  }
  
  void
- Config::changed ()
+ Config::changed (Property what)
  {
-       Changed ();
+       Changed (what);
  }
  
  void
diff --combined src/lib/config.h
index a5fdc17c0cff7293caaea2f17ce80d1a65010ff7,ad95bc3441fccc3344e82c4bb62c172589c1aae0..312118a55f9e24c7b4e93b140b70fae4fab8e96d
@@@ -1,5 -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
@@@ -59,6 -59,12 +59,12 @@@ public
  
        boost::filesystem::path default_directory_or (boost::filesystem::path a) const;
  
+       enum Property {
+               USE_ANY_SERVERS,
+               SERVERS,
+               OTHER
+       };
        /** @return base port number to use for J2K encoding servers */
        int server_port_base () const {
                return _server_port_base;
@@@ -66,7 -72,7 +72,7 @@@
  
        void set_use_any_servers (bool u) {
                _use_any_servers = u;
-               changed ();
+               changed (USE_ANY_SERVERS);
        }
  
        bool use_any_servers () const {
@@@ -76,7 -82,7 +82,7 @@@
        /** @param s New list of servers */
        void set_servers (std::vector<std::string> s) {
                _servers = s;
-               changed ();
+               changed (SERVERS);
        }
  
        /** @return Host names / IP addresses of J2K encoding servers that should definitely be used */
                return _mail_server;
        }
  
 +      int mail_port () const {
 +              return _mail_port;
 +      }
 +
        std::string mail_user () const {
                return _mail_user;
        }
                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);
        }
  
        void add_to_history (boost::filesystem::path p);
  
-       void changed ();
-       boost::signals2::signal<void ()> Changed;
+       void changed (Property p = OTHER);
+       boost::signals2::signal<void (Property)> Changed;
  
        void write () const;
  
@@@ -466,7 -464,6 +472,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;
diff --combined src/lib/kdm.cc
index f9b21c525a2bbc266dce7bbb3d391caa5c708c34,dd20311afefee83ab331fb9adf0c1b9f5eee11b4..0ded8f2c1589c3ffaa327520145919f9eb6e60ab
@@@ -254,8 -254,6 +254,6 @@@ email_kdms 
                        quickmail_add_bcc (mail, Config::instance()->kdm_bcc().c_str ());
                }
  
-               quickmail_add_header (mail, "Content-Type: text/plain; charset=UTF-8");
                string body = Config::instance()->kdm_email().c_str();
                boost::algorithm::replace_all (body, "$CPL_NAME", film->dcp_name ());
                boost::algorithm::replace_all (body, "$START_TIME", start.str ());
                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);
        }
diff --combined src/wx/config_dialog.cc
index 53ed7c44b738074146f557bc4e863f6a38dc37f4,96abe6d69a70ae1fbb993850a8b19b7554476189..f744ca83faa4a33b8ff682d9fc5d4bbf1ea2215f
   *  @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;
@@@ -162,6 -161,7 +162,7 @@@ private
                _language->Append (wxT ("Nederlands"));
                _language->Append (wxT ("Svenska"));
                _language->Append (wxT ("Русский"));
+               _language->Append (wxT ("Polski"));
                table->Add (_language);
  
                wxStaticText* restart = add_label_to_sizer (table, _panel, _("(restart DCP-o-matic to see language changes)"), false);
                        _language->SetSelection (5);
                } else if (config->language().get_value_or ("") == "ru") {
                        _language->SetSelection (7);
+               } else if (config->language().get_value_or ("") == "pl") {
+                       checked_set (_language, 8);
                } else {
                        _language->SetSelection (1);
                }
                case 7:
                        Config::instance()->set_language ("ru");
                        break;
+               case 8:
+                       Config::instance()->set_language ("pl");
+                       break;
                }
        }
  
@@@ -977,16 -982,8 +983,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);
                _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);
                _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));
                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 ());
                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 ()));
        }
  
        wxTextCtrl* _mail_server;
 +      wxSpinCtrl* _mail_port;
        wxTextCtrl* _mail_user;
        wxTextCtrl* _mail_password;
        wxTextCtrl* _kdm_subject;