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 cb9f4669b8c7a0cfa7057b2606e7a73c9f10d969..5b7dc1cc41390e5f63406c201857e0b8f5d7ce08 100644 (file)
@@ -624,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)
                        );
 
@@ -773,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. "
@@ -829,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);
@@ -977,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 ();
@@ -1060,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);
@@ -1080,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();
@@ -1275,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);
@@ -1440,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);
                }
 
@@ -1454,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);
                }