Add some default filenames to the advanced certificate/key export dialogues (#1888).
authorCarl Hetherington <cth@carlh.net>
Sat, 6 Feb 2021 19:39:08 +0000 (20:39 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 6 Feb 2021 19:44:37 +0000 (20:44 +0100)
src/wx/config_dialog.cc

index 14abc286b115f616cbf4a786cd9770be4e012d30..9e630195fa740a91ace897d03f72838cdd04d86d 100644 (file)
@@ -436,11 +436,23 @@ CertificateChainEditor::export_certificate ()
 
        wxFileDialog* d = new wxFileDialog (
                this, _("Select Certificate File"), wxEmptyString, wxEmptyString, wxT ("PEM files (*.pem)|*.pem"),
+       auto all = _get()->root_to_leaf();
+
+       wxString default_name;
+       if (i == 0) {
+               default_name = "root.pem";
+       } else if (i == static_cast<int>(all.size() - 1)) {
+               default_name = "leaf.pem";
+       } else {
+               default_name = "intermediate.pem";
+       }
+
+       auto d = new wxFileDialog(
+               this, _("Select Certificate File"), wxEmptyString, default_name, wxT ("PEM files (*.pem)|*.pem"),
                wxFD_SAVE | wxFD_OVERWRITE_PROMPT
                );
 
-       dcp::CertificateChain::List all = _get()->root_to_leaf ();
-       dcp::CertificateChain::List::iterator j = all.begin ();
+       auto j = all.begin ();
        for (int k = 0; k < i; ++k) {
                ++j;
        }
@@ -462,8 +474,8 @@ CertificateChainEditor::export_certificate ()
 void
 CertificateChainEditor::export_chain ()
 {
-       wxFileDialog* d = new wxFileDialog (
-               this, _("Select Chain File"), wxEmptyString, wxEmptyString, wxT("PEM files (*.pem)|*.pem"),
+       auto d = new wxFileDialog (
+               this, _("Select Chain File"), wxEmptyString, _("certificate_chain.pem"), wxT("PEM files (*.pem)|*.pem"),
                wxFD_SAVE | wxFD_OVERWRITE_PROMPT
                );
 
@@ -636,8 +648,8 @@ CertificateChainEditor::export_private_key ()
                return;
        }
 
-       wxFileDialog* d = new wxFileDialog (
-               this, _("Select Key File"), wxEmptyString, wxEmptyString, wxT ("PEM files (*.pem)|*.pem"),
+       auto d = new wxFileDialog (
+               this, _("Select Key File"), wxEmptyString, _("private_key.pem"), wxT ("PEM files (*.pem)|*.pem"),
                wxFD_SAVE | wxFD_OVERWRITE_PROMPT
                );