Give a better error if the user tries to load a non-KDM as a DKDM into the KDM creator.
[dcpomatic.git] / src / wx / config_dialog.cc
index 0098ecb2bb9e7dfd82d8d0bbb2a5b716c7e8d305..5b7dc1cc41390e5f63406c201857e0b8f5d7ce08 100644 (file)
@@ -41,7 +41,7 @@
 #include "lib/util.h"
 #include "lib/cross.h"
 #include "lib/exceptions.h"
-#include <dcp/raw_convert.h>
+#include <dcp/locale_convert.h>
 #include <dcp/exceptions.h>
 #include <dcp/certificate_chain.h>
 #include <wx/stdpaths.h>
@@ -63,7 +63,7 @@ using boost::bind;
 using boost::shared_ptr;
 using boost::function;
 using boost::optional;
-using dcp::raw_convert;
+using dcp::locale_convert;
 
 class Page
 {
@@ -517,7 +517,7 @@ private:
                _directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()));
                checked_set (_j2k_bandwidth, config->default_j2k_bandwidth() / 1000000);
                _j2k_bandwidth->SetRange (50, config->maximum_j2k_bandwidth() / 1000000);
-               checked_set (_dcp_audio_channels, raw_convert<string> (config->default_dcp_audio_channels()));
+               checked_set (_dcp_audio_channels, locale_convert<string> (config->default_dcp_audio_channels()));
                checked_set (_audio_delay, config->default_audio_delay ());
                checked_set (_standard, config->default_interop() ? 1 : 0);
        }
@@ -536,7 +536,9 @@ private:
        {
                int const s = _dcp_audio_channels->GetSelection ();
                if (s != wxNOT_FOUND) {
-                       Config::instance()->set_default_dcp_audio_channels (dcp::raw_convert<int> (string_client_data (_dcp_audio_channels->GetClientObject (s))));
+                       Config::instance()->set_default_dcp_audio_channels (
+                               locale_convert<int> (string_client_data (_dcp_audio_channels->GetClientObject (s)))
+                               );
                }
        }
 
@@ -622,7 +624,6 @@ private:
                        columns,
                        boost::bind (&Config::servers, Config::instance()),
                        boost::bind (&Config::set_servers, Config::instance(), _1),
-                       boost::bind (&always_valid),
                        boost::bind (&EncodingServersPage::server_column, this, _1)
                        );
 
@@ -771,8 +772,9 @@ private:
 
                if (d->ShowModal() == wxID_OK) {
                        try {
-                               dcp::Certificate c (dcp::file_to_string (wx_to_std (d->GetPath ())));
-                               if (c.extra_data ()) {
+                               dcp::Certificate c;
+                               string const extra = c.read_string (dcp::file_to_string (wx_to_std (d->GetPath ())));
+                               if (!extra.empty ()) {
                                        message_dialog (
                                                this,
                                                _("This file contains other certificates (or other data) after its first certificate. "
@@ -827,7 +829,7 @@ private:
                if (d->ShowModal () == wxID_OK) {
                        FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
                        if (!f) {
-                               throw OpenFileError (wx_to_std (d->GetPath ()));
+                               throw OpenFileError (wx_to_std (d->GetPath ()), errno, false);
                        }
 
                        string const s = j->certificate (true);
@@ -975,7 +977,7 @@ private:
                if (d->ShowModal () == wxID_OK) {
                        FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
                        if (!f) {
-                               throw OpenFileError (wx_to_std (d->GetPath ()));
+                               throw OpenFileError (wx_to_std (d->GetPath ()), errno, false);
                        }
 
                        string const s = _chain->key().get ();
@@ -1058,7 +1060,7 @@ private:
                if (d->ShowModal () == wxID_OK) {
                        FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
                        if (!f) {
-                               throw OpenFileError (wx_to_std (d->GetPath ()));
+                               throw OpenFileError (wx_to_std (d->GetPath ()), errno, false);
                        }
 
                        string const s = Config::instance()->decryption_chain()->leaf().certificate (true);
@@ -1078,7 +1080,7 @@ private:
                if (d->ShowModal () == wxID_OK) {
                        FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
                        if (!f) {
-                               throw OpenFileError (wx_to_std (d->GetPath ()));
+                               throw OpenFileError (wx_to_std (d->GetPath ()), errno, false);
                        }
 
                        string const s = Config::instance()->decryption_chain()->chain();
@@ -1273,7 +1275,6 @@ private:
                        columns,
                        bind (&Config::kdm_cc, Config::instance()),
                        bind (&Config::set_kdm_cc, Config::instance(), _1),
-                       bind (&string_not_empty, _1),
                        bind (&column, _1)
                        );
                table->Add (_kdm_cc, 1, wxEXPAND | wxALL);
@@ -1438,13 +1439,11 @@ private:
                        add_top_aligned_label_to_sizer (table, _panel, _("DCP metadata filename format"));
                        dcp::NameFormat::Map titles;
                        titles['t'] = "type (cpl/pkl)";
-                       titles['i'] = "unique ID";
-                       titles['c'] = "content filename";
                        dcp::NameFormat::Map examples;
                        examples['t'] = "cpl";
-                       examples['i'] = "eb1c112c-ca3c-4ae6-9263-c6714ff05d64";
-                       examples['c'] = "myfile.mp4";
-                       _dcp_metadata_filename_format = new NameFormatEditor (_panel, Config::instance()->dcp_metadata_filename_format(), titles, examples);
+                       _dcp_metadata_filename_format = new NameFormatEditor (
+                               _panel, Config::instance()->dcp_metadata_filename_format(), titles, examples, "_eb1c112c-ca3c-4ae6-9263-c6714ff05d64.xml"
+                               );
                        table->Add (_dcp_metadata_filename_format->panel(), 1, wxEXPAND | wxALL);
                }
 
@@ -1452,17 +1451,17 @@ private:
                        add_top_aligned_label_to_sizer (table, _panel, _("DCP asset filename format"));
                        dcp::NameFormat::Map titles;
                        titles['t'] = "type (j2c/pcm/sub)";
-                       titles['i'] = "unique ID";
                        titles['r'] = "reel number";
                        titles['n'] = "number of reels";
                        titles['c'] = "content filename";
                        dcp::NameFormat::Map examples;
                        examples['t'] = "j2c";
-                       examples['i'] = "eb1c112c-ca3c-4ae6-9263-c6714ff05d64";
                        examples['r'] = "1";
                        examples['n'] = "4";
                        examples['c'] = "myfile.mp4";
-                       _dcp_asset_filename_format = new NameFormatEditor (_panel, Config::instance()->dcp_asset_filename_format(), titles, examples);
+                       _dcp_asset_filename_format = new NameFormatEditor (
+                               _panel, Config::instance()->dcp_asset_filename_format(), titles, examples, "_eb1c112c-ca3c-4ae6-9263-c6714ff05d64.mxf"
+                               );
                        table->Add (_dcp_asset_filename_format->panel(), 1, wxEXPAND | wxALL);
                }