Improve wording of use-any-servers checkbox.
[dcpomatic.git] / src / wx / config_dialog.cc
index 5b02d71e358a4f0e016ce6be3ef8efec222381ea..ff0120ea83d5853a2e38d5590b6e85bbee3b24c6 100644 (file)
@@ -57,6 +57,7 @@ using boost::bind;
 using boost::shared_ptr;
 using boost::lexical_cast;
 using boost::function;
+using boost::optional;
 
 class Page
 {
@@ -165,7 +166,8 @@ private:
                _language->Append (wxT ("Svenska"));
                _language->Append (wxT ("Русский"));
                _language->Append (wxT ("Polski"));
-               _language->Append (wxT ("Danske"));
+               _language->Append (wxT ("Dansk"));
+               _language->Append (wxT ("Português europeu"));
                table->Add (_language, wxGBPosition (r, 1));
                ++r;
 
@@ -227,7 +229,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);
@@ -247,6 +249,8 @@ private:
                        checked_set (_language, 8);
                } else if (config->language().get_value_or ("") == "da") {
                        checked_set (_language, 9);
+               } else if (config->language().get_value_or ("") == "pt") {
+                       checked_set (_language, 10);
                } else {
                        _language->SetSelection (1);
                }
@@ -309,6 +313,9 @@ private:
                case 9:
                        Config::instance()->set_language ("da");
                        break;
+               case 10:
+                       Config::instance()->set_language ("pt");
+                       break;
                }
        }
 
@@ -388,7 +395,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);
@@ -536,7 +543,7 @@ private:
        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;
@@ -568,7 +575,7 @@ public:
 private:
        void setup ()
        {
-               _use_any_servers = new wxCheckBox (_panel, wxID_ANY, _("Use all servers"));
+               _use_any_servers = new wxCheckBox (_panel, wxID_ANY, _("Search network for servers"));
                _panel->GetSizer()->Add (_use_any_servers, 0, wxALL, _border);
 
                vector<string> columns;
@@ -634,7 +641,7 @@ public:
                wxBoxSizer* certificates_sizer = new wxBoxSizer (wxHORIZONTAL);
                _sizer->Add (certificates_sizer, 0, wxLEFT | wxRIGHT, border);
 
-               _certificates = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (400, 150), wxLC_REPORT | wxLC_SINGLE_SEL);
+               _certificates = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (440, 150), wxLC_REPORT | wxLC_SINGLE_SEL);
 
                {
                        wxListItem ip;
@@ -648,7 +655,7 @@ public:
                        wxListItem ip;
                        ip.SetId (1);
                        ip.SetText (_("Thumbprint"));
-                       ip.SetWidth (300);
+                       ip.SetWidth (340);
 
                        wxFont font = ip.GetFont ();
                        font.SetFamily (wxFONTFAMILY_TELETYPE);
@@ -682,6 +689,8 @@ public:
                table->Add (_private_key, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
                _load_private_key = new wxButton (this, wxID_ANY, _("Load..."));
                table->Add (_load_private_key, wxGBPosition (r, 2));
+               _export_private_key = new wxButton (this, wxID_ANY, _("Export..."));
+               table->Add (_export_private_key, wxGBPosition (r, 3));
                ++r;
 
                _button_sizer = new wxBoxSizer (wxHORIZONTAL);
@@ -697,6 +706,7 @@ public:
                _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));
                _load_private_key->Bind    (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&CertificateChainEditor::load_private_key, this));
+               _export_private_key->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&CertificateChainEditor::export_private_key, this));
 
                SetSizerAndFit (_sizer);
        }
@@ -902,6 +912,31 @@ private:
                update_sensitivity ();
        }
 
+       void export_private_key ()
+       {
+               optional<string> key = _chain->key ();
+               if (!key) {
+                       return;
+               }
+
+               wxFileDialog* d = new wxFileDialog (
+                       this, _("Select Key File"), wxEmptyString, wxEmptyString, wxT ("PEM files (*.pem)|*.pem"),
+                       wxFD_SAVE | wxFD_OVERWRITE_PROMPT
+                       );
+
+               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 = _chain->key().get ();
+                       fwrite (s.c_str(), 1, s.length(), f);
+                       fclose (f);
+               }
+               d->Destroy ();
+       }
+
        wxListCtrl* _certificates;
        wxButton* _add_certificate;
        wxButton* _export_certificate;
@@ -909,6 +944,7 @@ private:
        wxButton* _remake_certificates;
        wxStaticText* _private_key;
        wxButton* _load_private_key;
+       wxButton* _export_private_key;
        wxSizer* _sizer;
        wxBoxSizer* _button_sizer;
        shared_ptr<dcp::CertificateChain> _chain;
@@ -1278,6 +1314,7 @@ public:
                , _log_timing (0)
                , _log_debug_decode (0)
                , _log_debug_encode (0)
+               , _log_debug_email (0)
        {}
 
 private:
@@ -1326,6 +1363,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);
                }
 
@@ -1345,6 +1384,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
@@ -1357,12 +1397,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
@@ -1387,22 +1428,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);
        }
@@ -1423,6 +1467,7 @@ private:
        wxCheckBox* _log_timing;
        wxCheckBox* _log_debug_decode;
        wxCheckBox* _log_debug_encode;
+       wxCheckBox* _log_debug_email;
 #ifdef DCPOMATIC_WINDOWS
        wxCheckBox* _win32_console;
 #endif