Take the leaf of a certificate chain if one is provided
[dcpomatic.git] / src / wx / config_dialog.cc
index 6006ba782bf336373e2d3604da7af6fc9d96628a..0369070a7c32edd900588ec56a6b5568e775a33b 100644 (file)
@@ -41,7 +41,7 @@
 #include "lib/util.h"
 #include "lib/cross.h"
 #include "lib/exceptions.h"
-#include "lib/locale_convert.h"
+#include <dcp/locale_convert.h>
 #include <dcp/exceptions.h>
 #include <dcp/certificate_chain.h>
 #include <wx/stdpaths.h>
@@ -63,6 +63,7 @@ using boost::bind;
 using boost::shared_ptr;
 using boost::function;
 using boost::optional;
+using dcp::locale_convert;
 
 class Page
 {
@@ -772,8 +773,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. "
@@ -828,7 +830,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);
@@ -976,7 +978,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 ();
@@ -1059,7 +1061,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);
@@ -1079,7 +1081,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();
@@ -1439,13 +1441,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);
                }
 
@@ -1453,17 +1453,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);
                }