Add empty da_DK translation.
[dcpomatic.git] / src / wx / config_dialog.cc
index 036172bb7eaa45f381e4b91b7e4ed7f22d1e4696..da3d85bef15dbd459da8d5cbc10d3eef712b37c7 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/certificate_chain.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;
@@ -161,6 +162,8 @@ private:
                _language->Append (wxT ("Nederlands"));
                _language->Append (wxT ("Svenska"));
                _language->Append (wxT ("Русский"));
+               _language->Append (wxT ("Polski"));
+               _language->Append (wxT ("Danske"));
                table->Add (_language);
 
                wxStaticText* restart = add_label_to_sizer (table, _panel, _("(restart DCP-o-matic to see language changes)"), false);
@@ -199,19 +202,23 @@ private:
                checked_set (_set_language, config->language ());
 
                if (config->language().get_value_or ("") == "fr") {
-                       _language->SetSelection (3);
+                       checked_set (_language, 3);
                } else if (config->language().get_value_or ("") == "it") {
-                       _language->SetSelection (4);
+                       checked_set (_language, 4);
                } else if (config->language().get_value_or ("") == "es") {
-                       _language->SetSelection (2);
+                       checked_set (_language, 2);
                } else if (config->language().get_value_or ("") == "sv") {
-                       _language->SetSelection (6);
+                       checked_set (_language, 6);
                } else if (config->language().get_value_or ("") == "de") {
-                       _language->SetSelection (0);
+                       checked_set (_language, 0);
                } else if (config->language().get_value_or ("") == "nl") {
-                       _language->SetSelection (5);
+                       checked_set (_language, 5);
                } else if (config->language().get_value_or ("") == "ru") {
-                       _language->SetSelection (7);
+                       checked_set (_language, 7);
+               } else if (config->language().get_value_or ("") == "pl") {
+                       checked_set (_language, 8);
+               } else if (config->language().get_value_or ("") == "da") {
+                       checked_set (_language, 9);
                } else {
                        _language->SetSelection (1);
                }
@@ -265,6 +272,12 @@ private:
                case 7:
                        Config::instance()->set_language ("ru");
                        break;
+               case 8:
+                       Config::instance()->set_language ("pl");
+                       break;
+               case 9:
+                       Config::instance()->set_language ("da");
+                       break;
                }
        }
 
@@ -564,8 +577,14 @@ public:
 private:
        void setup ()
        {
-               wxStaticText* m = new wxStaticText (_panel, wxID_ANY, _("Certificate chain for signing DCPs and KDMs:"));
-               _panel->GetSizer()->Add (m, 0, wxALL, _border);
+               wxFont subheading_font (*wxNORMAL_FONT);
+               subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
+
+               {
+                       wxStaticText* m = new wxStaticText (_panel, wxID_ANY, _("Signing DCPs and KDMs"));
+                       m->SetFont (subheading_font);
+                       _panel->GetSizer()->Add (m, 0, wxALL, _border);
+               }
 
                wxBoxSizer* certificates_sizer = new wxBoxSizer (wxHORIZONTAL);
                _panel->GetSizer()->Add (certificates_sizer, 0, wxLEFT | wxRIGHT, _border);
@@ -609,11 +628,7 @@ private:
 
                int r = 0;
 
-               _remake_certificates = new wxButton (_panel, wxID_ANY, _("Re-make certificates..."));
-               table->Add (_remake_certificates, wxGBPosition (r, 0), wxGBSpan (1, 3));
-               ++r;
-
-               add_label_to_grid_bag_sizer (table, _panel, _("Private key for leaf certificate"), true, wxGBPosition (r, 0));
+               add_label_to_grid_bag_sizer (table, _panel, _("Leaf private key"), true, wxGBPosition (r, 0));
                _signer_private_key = new wxStaticText (_panel, wxID_ANY, wxT (""));
                wxFont font = _signer_private_key->GetFont ();
                font.SetFamily (wxFONTFAMILY_TELETYPE);
@@ -623,7 +638,18 @@ private:
                table->Add (_load_signer_private_key, wxGBPosition (r, 2));
                ++r;
 
-               add_label_to_grid_bag_sizer (table, _panel, _("Certificate for decrypting DCPs"), true, wxGBPosition (r, 0));
+               _remake_certificates = new wxButton (_panel, wxID_ANY, _("Re-make certificates and key..."));
+               table->Add (_remake_certificates, wxGBPosition (r, 0), wxGBSpan (1, 3));
+               ++r;
+
+               {
+                       wxStaticText* m = new wxStaticText (_panel, wxID_ANY, _("Decrypting DCPs"));
+                       m->SetFont (subheading_font);
+                       table->Add (m, wxGBPosition (r, 0), wxGBSpan (1, 3), wxTOP, _border * 1.5);
+                       ++r;
+               }
+
+               add_label_to_grid_bag_sizer (table, _panel, _("Certificate"), true, wxGBPosition (r, 0));
                _decryption_certificate = new wxStaticText (_panel, wxID_ANY, wxT (""));
                _decryption_certificate->SetFont (font);
                table->Add (_decryption_certificate, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
@@ -631,7 +657,7 @@ private:
                table->Add (_load_decryption_certificate, wxGBPosition (r, 2));
                ++r;
 
-               add_label_to_grid_bag_sizer (table, _panel, _("Private key for decrypting DCPs"), true, wxGBPosition (r, 0));
+               add_label_to_grid_bag_sizer (table, _panel, _("Private key"), true, wxGBPosition (r, 0));
                _decryption_private_key = new wxStaticText (_panel, wxID_ANY, wxT (""));
                _decryption_private_key->SetFont (font);
                table->Add (_decryption_private_key, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
@@ -656,7 +682,7 @@ private:
 
        void config_changed ()
        {
-               _signer.reset (new dcp::Signer (*Config::instance()->signer().get ()));
+               _signer.reset (new dcp::CertificateChain (*Config::instance()->signer().get ()));
 
                update_certificate_list ();
                update_signer_private_key ();
@@ -672,7 +698,7 @@ private:
                if (d->ShowModal() == wxID_OK) {
                        try {
                                dcp::Certificate c (dcp::file_to_string (wx_to_std (d->GetPath ())));
-                               _signer->certificates().add (c);
+                               _signer->add (c);
                                Config::instance()->set_signer (_signer);
                                update_certificate_list ();
                        } catch (dcp::MiscError& e) {
@@ -693,7 +719,7 @@ private:
                }
 
                _certificates->DeleteItem (i);
-               _signer->certificates().remove (i);
+               _signer->remove (i);
                Config::instance()->set_signer (_signer);
 
                update_sensitivity ();
@@ -702,7 +728,7 @@ private:
        void update_certificate_list ()
        {
                _certificates->DeleteAllItems ();
-               dcp::CertificateChain::List certs = _signer->certificates().root_to_leaf ();
+               dcp::CertificateChain::List certs = _signer->root_to_leaf ();
                size_t n = 0;
                for (dcp::CertificateChain::List::const_iterator i = certs.begin(); i != certs.end(); ++i) {
                        wxListItem item;
@@ -724,10 +750,28 @@ private:
 
        void remake_certificates ()
        {
-               MakeSignerChainDialog* d = new MakeSignerChainDialog (_panel);
+               shared_ptr<const dcp::CertificateChain> chain = Config::instance()->signer();
+
+               string intermediate_common_name;
+               if (chain->root_to_leaf().size() >= 3) {
+                       dcp::CertificateChain::List all = chain->root_to_leaf ();
+                       dcp::CertificateChain::List::iterator i = all.begin ();
+                       ++i;
+                       intermediate_common_name = i->subject_common_name ();
+               }
+
+               MakeSignerChainDialog* d = new MakeSignerChainDialog (
+                       _panel,
+                       chain->root().subject_organization_name (),
+                       chain->root().subject_organizational_unit_name (),
+                       chain->root().subject_common_name (),
+                       intermediate_common_name,
+                       chain->leaf().subject_common_name ()
+                       );
+
                if (d->ShowModal () == wxID_OK) {
                        _signer.reset (
-                               new dcp::Signer (
+                               new dcp::CertificateChain (
                                        openssl_path (),
                                        d->organisation (),
                                        d->organisational_unit (),
@@ -752,7 +796,7 @@ private:
 
        void update_signer_private_key ()
        {
-               checked_set (_signer_private_key, dcp::private_key_fingerprint (_signer->key ()));
+               checked_set (_signer_private_key, dcp::private_key_fingerprint (_signer->key().get ()));
        }
 
        void load_signer_private_key ()
@@ -856,7 +900,7 @@ private:
        wxStaticText* _decryption_private_key;
        wxButton* _load_decryption_private_key;
        wxButton* _export_decryption_certificate;
-       shared_ptr<dcp::Signer> _signer;
+       shared_ptr<dcp::CertificateChain> _signer;
 };
 
 class TMSPage : public StandardPage
@@ -885,6 +929,10 @@ private:
                table->AddGrowableCol (1, 1);
                _panel->GetSizer()->Add (table, 1, wxALL | wxEXPAND, _border);
 
+               add_label_to_sizer (table, _panel, _("Protocol"), true);
+               _tms_protocol = new wxChoice (_panel, wxID_ANY);
+               table->Add (_tms_protocol, 1, wxEXPAND);
+
                add_label_to_sizer (table, _panel, _("IP address"), true);
                _tms_ip = new wxTextCtrl (_panel, wxID_ANY);
                table->Add (_tms_ip, 1, wxEXPAND);
@@ -901,6 +949,10 @@ private:
                _tms_password = new wxTextCtrl (_panel, wxID_ANY);
                table->Add (_tms_password, 1, wxEXPAND);
 
+               _tms_protocol->Append (_("SCP (for AAM)"));
+               _tms_protocol->Append (_("FTP (for Dolby)"));
+
+               _tms_protocol->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&TMSPage::tms_protocol_changed, this));
                _tms_ip->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TMSPage::tms_ip_changed, this));
                _tms_path->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TMSPage::tms_path_changed, this));
                _tms_user->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TMSPage::tms_user_changed, this));
@@ -911,12 +963,18 @@ private:
        {
                Config* config = Config::instance ();
 
+               checked_set (_tms_protocol, config->tms_protocol ());
                checked_set (_tms_ip, config->tms_ip ());
                checked_set (_tms_path, config->tms_path ());
                checked_set (_tms_user, config->tms_user ());
                checked_set (_tms_password, config->tms_password ());
        }
 
+       void tms_protocol_changed ()
+       {
+               Config::instance()->set_tms_protocol (static_cast<Protocol> (_tms_protocol->GetSelection ()));
+       }
+
        void tms_ip_changed ()
        {
                Config::instance()->set_tms_ip (wx_to_std (_tms_ip->GetValue ()));
@@ -937,6 +995,7 @@ private:
                Config::instance()->set_tms_password (wx_to_std (_tms_password->GetValue ()));
        }
 
+       wxChoice* _tms_protocol;
        wxTextCtrl* _tms_ip;
        wxTextCtrl* _tms_path;
        wxTextCtrl* _tms_user;
@@ -976,8 +1035,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 +1054,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 +1077,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 +1093,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 +1108,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 +1161,7 @@ private:
        }
 
        wxTextCtrl* _mail_server;
+       wxSpinCtrl* _mail_port;
        wxTextCtrl* _mail_user;
        wxTextCtrl* _mail_password;
        wxTextCtrl* _kdm_subject;
@@ -1118,6 +1186,8 @@ public:
                , _log_warning (0)
                , _log_error (0)
                , _log_timing (0)
+               , _log_debug_decode (0)
+               , _log_debug_encode (0)
        {}
 
 private:
@@ -1158,6 +1228,10 @@ private:
                        t->Add (_log_error, 1, wxEXPAND | wxALL);
                        _log_timing = new wxCheckBox (_panel, wxID_ANY, S_("Config|Timing"));
                        t->Add (_log_timing, 1, wxEXPAND | wxALL);
+                       _log_debug_decode = new wxCheckBox (_panel, wxID_ANY, _("Debug: decode"));
+                       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);
                        table->Add (t, 0, wxALL, 6);
                }
 
@@ -1174,6 +1248,8 @@ private:
                _log_warning->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AdvancedPage::log_changed, this));
                _log_error->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AdvancedPage::log_changed, this));
                _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));
 #ifdef DCPOMATIC_WINDOWS
                _win32_console->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AdvancedPage::win32_console_changed, this));
 #endif
@@ -1189,6 +1265,8 @@ private:
                checked_set (_log_warning, config->log_types() & Log::TYPE_WARNING);
                checked_set (_log_error, config->log_types() & Log::TYPE_ERROR);
                checked_set (_log_timing, config->log_types() & Log::TYPE_TIMING);
+               checked_set (_log_debug_decode, config->log_types() & Log::TYPE_DEBUG_DECODE);
+               checked_set (_log_debug_encode, config->log_types() & Log::TYPE_DEBUG_ENCODE);
 #ifdef DCPOMATIC_WINDOWS
                checked_set (_win32_console, config->win32_console());
 #endif
@@ -1219,6 +1297,12 @@ private:
                if (_log_timing->GetValue ()) {
                        types |= Log::TYPE_TIMING;
                }
+               if (_log_debug_decode->GetValue ()) {
+                       types |= Log::TYPE_DEBUG_DECODE;
+               }
+               if (_log_debug_encode->GetValue ()) {
+                       types |= Log::TYPE_DEBUG_ENCODE;
+               }
                Config::instance()->set_log_types (types);
        }
 
@@ -1235,6 +1319,8 @@ private:
        wxCheckBox* _log_warning;
        wxCheckBox* _log_error;
        wxCheckBox* _log_timing;
+       wxCheckBox* _log_debug_decode;
+       wxCheckBox* _log_debug_encode;
 #ifdef DCPOMATIC_WINDOWS
        wxCheckBox* _win32_console;
 #endif