Add subject/issuer details to the screen dialog (#2422).
[dcpomatic.git] / src / wx / screen_dialog.cc
index 1f1fc2fad7ae746170dad7d2088c776e6a2d78fc..b985888ea75972ec194f433fd64bccd00f6f4ee3 100644 (file)
@@ -25,6 +25,7 @@
 #include "screen_dialog.h"
 #include "static_text.h"
 #include "table_dialog.h"
+#include "wx_ptr.h"
 #include "wx_util.h"
 #include "lib/compose.hpp"
 #include "lib/scope_guard.h"
@@ -64,8 +65,7 @@ public:
 
        void load_certificate ()
        {
-               auto dialog = new FileDialog(this, _("Trusted Device certificate"), wxEmptyString, wxFD_DEFAULT_STYLE, "SelectCertificatePath");
-               ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+               auto dialog = make_wx<FileDialog>(this, _("Trusted Device certificate"), wxEmptyString, wxFD_DEFAULT_STYLE, "SelectCertificatePath");
                if (!dialog->show()) {
                        return;
                }
@@ -143,7 +143,6 @@ ScreenDialog::ScreenDialog (
        auto s = new wxBoxSizer (wxHORIZONTAL);
        _recipient_thumbprint = new StaticText (this, wxT (""), wxDefaultPosition, size);
        _recipient_thumbprint->SetFont (font);
-       set_recipient (recipient);
 
        _get_recipient_from_file = new Button (this, _("Get from file..."));
        _download_recipient = new Button (this, _("Download..."));
@@ -154,11 +153,33 @@ ScreenDialog::ScreenDialog (
        ++r;
 
        add_label_to_sizer (_sizer, this, _("Filename"), true, wxGBPosition(r, 0));
-       _recipient_file = new wxStaticText (this, wxID_ANY, wxT(""));
-       checked_set (_recipient_file, recipient_file.get_value_or(""));
+       _recipient_file = new wxStaticText(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(600, -1), wxST_ELLIPSIZE_MIDDLE | wxST_NO_AUTORESIZE);
+       set_recipient_file(recipient_file.get_value_or(""));
        _sizer->Add (_recipient_file, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP);
        ++r;
 
+       add_label_to_sizer(_sizer, this, _("Subject common name"), true, wxGBPosition(r, 0));
+       _subject_common_name = new wxStaticText(this, wxID_ANY, wxT(""));
+       _sizer->Add(_subject_common_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP);
+       ++r;
+
+       add_label_to_sizer(_sizer, this, _("Subject organization name"), true, wxGBPosition(r, 0));
+       _subject_organization_name = new wxStaticText(this, wxID_ANY, wxT(""));
+       _sizer->Add(_subject_organization_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP);
+       ++r;
+
+       add_label_to_sizer(_sizer, this, _("Issuer common name"), true, wxGBPosition(r, 0));
+       _issuer_common_name = new wxStaticText(this, wxID_ANY, wxT(""));
+       _sizer->Add(_issuer_common_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP);
+       ++r;
+
+       add_label_to_sizer(_sizer, this, _("Issuer organization name"), true, wxGBPosition(r, 0));
+       _issuer_organization_name = new wxStaticText(this, wxID_ANY, wxT(""));
+       _sizer->Add(_issuer_organization_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_Y_GAP);
+       ++r;
+
+       set_recipient (recipient);
+
        {
                int flags = wxALIGN_CENTER_VERTICAL | wxTOP;
 #ifdef __WXOSX__
@@ -194,7 +215,7 @@ ScreenDialog::ScreenDialog (
 
        overall_sizer->Add (_sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
 
-       wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+       auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
        if (buttons) {
                overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
        }
@@ -249,7 +270,7 @@ ScreenDialog::load_recipient (boost::filesystem::path file)
                        return;
                }
                set_recipient (c.leaf ());
-               checked_set (_recipient_file, file.string());
+               set_recipient_file(file.string());
        } catch (dcp::MiscError& e) {
                error_dialog (this, _("Could not read certificate file."), std_to_wx(e.what()));
        }
@@ -259,8 +280,7 @@ ScreenDialog::load_recipient (boost::filesystem::path file)
 void
 ScreenDialog::get_recipient_from_file ()
 {
-       auto dialog = new FileDialog(this, _("Select Certificate File"), wxEmptyString, wxFD_DEFAULT_STYLE , "SelectCertificatePath");
-       ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+       auto dialog = make_wx<FileDialog>(this, _("Select Certificate File"), wxEmptyString, wxFD_DEFAULT_STYLE , "SelectCertificatePath");
        if (dialog->show()) {
                load_recipient(dialog->paths()[0]);
        }
@@ -272,12 +292,11 @@ ScreenDialog::get_recipient_from_file ()
 void
 ScreenDialog::download_recipient ()
 {
-       auto d = new DownloadCertificateDialog (this);
-       if (d->ShowModal() == wxID_OK) {
-               set_recipient (d->certificate());
-               checked_set (_recipient_file, d->url());
+       auto dialog = make_wx<DownloadCertificateDialog>(this);
+       if (dialog->ShowModal() == wxID_OK) {
+               set_recipient(dialog->certificate());
+               set_recipient_file(dialog->url());
        }
-       d->Destroy ();
        setup_sensitivity ();
 }
 
@@ -299,6 +318,19 @@ ScreenDialog::set_recipient (optional<dcp::Certificate> r)
 
        if (_recipient) {
                _recipient_thumbprint->SetLabel (std_to_wx (_recipient->thumbprint ()));
+               _subject_common_name->SetLabel(std_to_wx(_recipient->subject_common_name()));
+               _subject_organization_name->SetLabel(std_to_wx(_recipient->subject_organization_name()));
+               _issuer_common_name->SetLabel(std_to_wx(_recipient->issuer_common_name()));
+               _issuer_organization_name->SetLabel(std_to_wx(_recipient->issuer_organization_name()));
                _sizer->Layout ();
        }
 }
+
+
+void
+ScreenDialog::set_recipient_file(string file)
+{
+       checked_set(_recipient_file, file);
+       _recipient_file->SetToolTip(std_to_wx(file));
+}
+