Add debug option to log SMTP session transcripts.
[dcpomatic.git] / src / wx / config_dialog.cc
index adaee777b51634cdde165d66c664be7bd871abca..f35c9adc9fc8288eea5944176de7c9ef01dd5dfb 100644 (file)
@@ -183,6 +183,10 @@ private:
                table->Add (_num_local_encoding_threads, wxGBPosition (r, 1));
                ++r;
 
+               _automatic_audio_analysis = new wxCheckBox (_panel, wxID_ANY, _("Automatically analyse content audio"));
+               table->Add (_automatic_audio_analysis, wxGBPosition (r, 0), wxGBSpan (1, 2));
+               ++r;
+
                _check_for_updates = new wxCheckBox (_panel, wxID_ANY, _("Check for updates on startup"));
                table->Add (_check_for_updates, wxGBPosition (r, 0), wxGBSpan (1, 2));
                ++r;
@@ -211,6 +215,7 @@ private:
                _num_local_encoding_threads->SetRange (1, 128);
                _num_local_encoding_threads->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&GeneralPage::num_local_encoding_threads_changed, this));
 
+               _automatic_audio_analysis->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::automatic_audio_analysis_changed, this));
                _check_for_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_updates_changed, this));
                _check_for_test_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_test_updates_changed, this));
 
@@ -222,7 +227,7 @@ private:
        {
                Config* config = Config::instance ();
 
-               checked_set (_set_language, config->language ());
+               checked_set (_set_language, static_cast<bool>(config->language()));
 
                if (config->language().get_value_or ("") == "fr") {
                        checked_set (_language, 3);
@@ -249,6 +254,7 @@ private:
                setup_language_sensitivity ();
 
                checked_set (_num_local_encoding_threads, config->num_local_encoding_threads ());
+               checked_set (_automatic_audio_analysis, config->automatic_audio_analysis ());
                checked_set (_check_for_updates, config->check_for_updates ());
                checked_set (_check_for_test_updates, config->check_for_test_updates ());
                checked_set (_issuer, config->dcp_issuer ());
@@ -306,6 +312,11 @@ private:
                }
        }
 
+       void automatic_audio_analysis_changed ()
+       {
+               Config::instance()->set_automatic_audio_analysis (_automatic_audio_analysis->GetValue ());
+       }
+
        void check_for_updates_changed ()
        {
                Config::instance()->set_check_for_updates (_check_for_updates->GetValue ());
@@ -334,6 +345,7 @@ private:
        wxCheckBox* _set_language;
        wxChoice* _language;
        wxSpinCtrl* _num_local_encoding_threads;
+       wxCheckBox* _automatic_audio_analysis;
        wxCheckBox* _check_for_updates;
        wxCheckBox* _check_for_test_updates;
        wxTextCtrl* _issuer;
@@ -376,7 +388,7 @@ private:
                }
 
                add_label_to_sizer (table, _panel, _("Default directory for new films"), true);
-#ifdef DCPOMATIC_USE_OWN_DIR_PICKER
+#ifdef DCPOMATIC_USE_OWN_PICKER
                _directory = new DirPickerCtrl (_panel);
 #else
                _directory = new wxDirPickerCtrl (_panel, wxDD_DIR_MUST_EXIST);
@@ -413,6 +425,10 @@ private:
                        table->Add (s, 1);
                }
 
+               add_label_to_sizer (table, _panel, _("Default standard"), true);
+               _standard = new wxChoice (_panel, wxID_ANY);
+               table->Add (_standard);
+
                _still_length->SetRange (1, 3600);
                _still_length->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DefaultsPage::still_length_changed, this));
 
@@ -439,6 +455,10 @@ private:
 
                _audio_delay->SetRange (-1000, 1000);
                _audio_delay->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DefaultsPage::audio_delay_changed, this));
+
+               _standard->Append (_("SMPTE"));
+               _standard->Append (_("Interop"));
+               _standard->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DefaultsPage::standard_changed, this));
        }
 
        void config_changed ()
@@ -464,6 +484,7 @@ private:
                checked_set (_j2k_bandwidth, config->default_j2k_bandwidth() / 1000000);
                _j2k_bandwidth->SetRange (50, config->maximum_j2k_bandwidth() / 1000000);
                checked_set (_audio_delay, config->default_audio_delay ());
+               checked_set (_standard, config->default_interop() ? 1 : 0);
        }
 
        void j2k_bandwidth_changed ()
@@ -506,17 +527,23 @@ private:
                Config::instance()->set_default_dcp_content_type (ct[_dcp_content_type->GetSelection()]);
        }
 
+       void standard_changed ()
+       {
+               Config::instance()->set_default_interop (_standard->GetSelection() == 1);
+       }
+
        wxSpinCtrl* _j2k_bandwidth;
        wxSpinCtrl* _audio_delay;
        wxButton* _isdcf_metadata_button;
        wxSpinCtrl* _still_length;
-#ifdef DCPOMATIC_USE_OWN_DIR_PICKER
+#ifdef DCPOMATIC_USE_OWN_PICKER
        DirPickerCtrl* _directory;
 #else
        wxDirPickerCtrl* _directory;
 #endif
        wxChoice* _container;
        wxChoice* _dcp_content_type;
+       wxChoice* _standard;
 };
 
 class EncodingServersPage : public StandardPage
@@ -638,6 +665,8 @@ public:
                        s->Add (_add_certificate, 0, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
                        _remove_certificate = new wxButton (this, wxID_ANY, _("Remove"));
                        s->Add (_remove_certificate, 0, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
+                       _export_certificate = new wxButton (this, wxID_ANY, _("Export"));
+                       s->Add (_export_certificate, 0, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
                        certificates_sizer->Add (s, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP);
                }
 
@@ -663,6 +692,7 @@ public:
 
                _add_certificate->Bind     (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&CertificateChainEditor::add_certificate, this));
                _remove_certificate->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&CertificateChainEditor::remove_certificate, this));
+               _export_certificate->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&CertificateChainEditor::export_certificate, this));
                _certificates->Bind        (wxEVT_COMMAND_LIST_ITEM_SELECTED,   boost::bind (&CertificateChainEditor::update_sensitivity, this));
                _certificates->Bind        (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&CertificateChainEditor::update_sensitivity, this));
                _remake_certificates->Bind (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&CertificateChainEditor::remake_certificates, this));
@@ -721,6 +751,37 @@ private:
                update_sensitivity ();
        }
 
+       void export_certificate ()
+       {
+               int i = _certificates->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+               if (i == -1) {
+                       return;
+               }
+
+               wxFileDialog* d = new wxFileDialog (
+                       this, _("Select Certificate File"), wxEmptyString, wxEmptyString, wxT ("PEM files (*.pem)|*.pem"),
+                       wxFD_SAVE | wxFD_OVERWRITE_PROMPT
+                       );
+
+               dcp::CertificateChain::List all = _chain->root_to_leaf ();
+               dcp::CertificateChain::List::iterator j = all.begin ();
+               for (int k = 0; k < i; ++k) {
+                       ++j;
+               }
+
+               if (d->ShowModal () == wxID_OK) {
+                       FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
+                       if (!f) {
+                               throw OpenFileError (wx_to_std (d->GetPath ()));
+                       }
+
+                       string const s = j->certificate (true);
+                       fwrite (s.c_str(), 1, s.length(), f);
+                       fclose (f);
+               }
+               d->Destroy ();
+       }
+
        void update_certificate_list ()
        {
                _certificates->DeleteAllItems ();
@@ -748,9 +809,28 @@ private:
        {
                shared_ptr<const dcp::CertificateChain> chain = _get ();
 
+               string subject_organization_name;
+               string subject_organizational_unit_name;
+               string root_common_name;
                string intermediate_common_name;
-               if (chain->root_to_leaf().size() >= 3) {
-                       dcp::CertificateChain::List all = chain->root_to_leaf ();
+               string leaf_common_name;
+
+               dcp::CertificateChain::List all = chain->root_to_leaf ();
+
+               if (all.size() >= 1) {
+                       /* Have a root */
+                       subject_organization_name = chain->root().subject_organization_name ();
+                       subject_organizational_unit_name = chain->root().subject_organizational_unit_name ();
+                       root_common_name = chain->root().subject_common_name ();
+               }
+
+               if (all.size() >= 2) {
+                       /* Have a leaf */
+                       leaf_common_name = chain->leaf().subject_common_name ();
+               }
+
+               if (all.size() >= 3) {
+                       /* Have an intermediate */
                        dcp::CertificateChain::List::iterator i = all.begin ();
                        ++i;
                        intermediate_common_name = i->subject_common_name ();
@@ -758,11 +838,11 @@ private:
 
                MakeChainDialog* d = new MakeChainDialog (
                        this,
-                       chain->root().subject_organization_name (),
-                       chain->root().subject_organizational_unit_name (),
-                       chain->root().subject_common_name (),
+                       subject_organization_name,
+                       subject_organizational_unit_name,
+                       root_common_name,
                        intermediate_common_name,
-                       chain->leaf().subject_common_name ()
+                       leaf_common_name
                        );
 
                if (d->ShowModal () == wxID_OK) {
@@ -788,6 +868,7 @@ private:
        void update_sensitivity ()
        {
                _remove_certificate->Enable (_certificates->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1);
+               _export_certificate->Enable (_certificates->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1);
        }
 
        void update_private_key ()
@@ -823,6 +904,7 @@ private:
 
        wxListCtrl* _certificates;
        wxButton* _add_certificate;
+       wxButton* _export_certificate;
        wxButton* _remove_certificate;
        wxButton* _remake_certificates;
        wxStaticText* _private_key;
@@ -956,7 +1038,7 @@ private:
                _tms_password = new wxTextCtrl (_panel, wxID_ANY);
                table->Add (_tms_password, 1, wxEXPAND);
 
-               _tms_protocol->Append (_("SCP (for AAM)"));
+               _tms_protocol->Append (_("SCP (for AAM and Doremi)"));
                _tms_protocol->Append (_("FTP (for Dolby)"));
 
                _tms_protocol->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&TMSPage::tms_protocol_changed, this));
@@ -1196,6 +1278,7 @@ public:
                , _log_timing (0)
                , _log_debug_decode (0)
                , _log_debug_encode (0)
+               , _log_debug_email (0)
        {}
 
 private:
@@ -1244,6 +1327,8 @@ 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);
                }
 
@@ -1263,6 +1348,7 @@ private:
                _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
@@ -1275,12 +1361,13 @@ private:
                checked_set (_maximum_j2k_bandwidth, config->maximum_j2k_bandwidth() / 1000000);
                checked_set (_allow_any_dcp_frame_rate, config->allow_any_dcp_frame_rate ());
                checked_set (_only_servers_encode, config->only_servers_encode ());
-               checked_set (_log_general, config->log_types() & Log::TYPE_GENERAL);
-               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);
+               checked_set (_log_general, config->log_types() & LogEntry::TYPE_GENERAL);
+               checked_set (_log_warning, config->log_types() & LogEntry::TYPE_WARNING);
+               checked_set (_log_error, config->log_types() & LogEntry::TYPE_ERROR);
+               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
@@ -1305,22 +1392,25 @@ private:
        {
                int types = 0;
                if (_log_general->GetValue ()) {
-                       types |= Log::TYPE_GENERAL;
+                       types |= LogEntry::TYPE_GENERAL;
                }
                if (_log_warning->GetValue ()) {
-                       types |= Log::TYPE_WARNING;
+                       types |= LogEntry::TYPE_WARNING;
                }
                if (_log_error->GetValue ())  {
-                       types |= Log::TYPE_ERROR;
+                       types |= LogEntry::TYPE_ERROR;
                }
                if (_log_timing->GetValue ()) {
-                       types |= Log::TYPE_TIMING;
+                       types |= LogEntry::TYPE_TIMING;
                }
                if (_log_debug_decode->GetValue ()) {
-                       types |= Log::TYPE_DEBUG_DECODE;
+                       types |= LogEntry::TYPE_DEBUG_DECODE;
                }
                if (_log_debug_encode->GetValue ()) {
-                       types |= Log::TYPE_DEBUG_ENCODE;
+                       types |= LogEntry::TYPE_DEBUG_ENCODE;
+               }
+               if (_log_debug_email->GetValue ()) {
+                       types |= LogEntry::TYPE_DEBUG_EMAIL;
                }
                Config::instance()->set_log_types (types);
        }
@@ -1341,6 +1431,7 @@ private:
        wxCheckBox* _log_timing;
        wxCheckBox* _log_debug_decode;
        wxCheckBox* _log_debug_encode;
+       wxCheckBox* _log_debug_email;
 #ifdef DCPOMATIC_WINDOWS
        wxCheckBox* _win32_console;
 #endif