- CertificateChainEditor (
- wxWindow* parent,
- wxString title,
- int border,
- function<void (shared_ptr<dcp::CertificateChain>)> set,
- function<shared_ptr<const dcp::CertificateChain> (void)> get,
- function<void (void)> nag_remake
- )
- : wxPanel (parent)
- , _set (set)
- , _get (get)
- , _nag_remake (nag_remake)
- {
- wxFont subheading_font (*wxNORMAL_FONT);
- subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
-
- _sizer = new wxBoxSizer (wxVERTICAL);
-
- {
- wxStaticText* m = new wxStaticText (this, wxID_ANY, title);
- m->SetFont (subheading_font);
- _sizer->Add (m, 0, wxALL, border);
- }
-
- wxBoxSizer* certificates_sizer = new wxBoxSizer (wxHORIZONTAL);
- _sizer->Add (certificates_sizer, 0, wxLEFT | wxRIGHT, border);
-
- _certificates = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (440, 150), wxLC_REPORT | wxLC_SINGLE_SEL);
-
- {
- wxListItem ip;
- ip.SetId (0);
- ip.SetText (_("Type"));
- ip.SetWidth (100);
- _certificates->InsertColumn (0, ip);
- }
-
- {
- wxListItem ip;
- ip.SetId (1);
- ip.SetText (_("Thumbprint"));
- ip.SetWidth (340);
-
- wxFont font = ip.GetFont ();
- font.SetFamily (wxFONTFAMILY_TELETYPE);
- ip.SetFont (font);
-
- _certificates->InsertColumn (1, ip);
- }
-
- certificates_sizer->Add (_certificates, 1, wxEXPAND);
-
- {
- wxSizer* s = new wxBoxSizer (wxVERTICAL);
- _add_certificate = new wxButton (this, wxID_ANY, _("Add..."));
- s->Add (_add_certificate, 0, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
- _remove_certificate = new wxButton (this, wxID_ANY, _("Remove"));
- s->Add (_remove_certificate, 0, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
- _export_certificate = new wxButton (this, wxID_ANY, _("Export"));
- s->Add (_export_certificate, 0, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
- certificates_sizer->Add (s, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP);
- }
-
- wxGridBagSizer* table = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
- _sizer->Add (table, 1, wxALL | wxEXPAND, border);
- int r = 0;
-
- add_label_to_sizer (table, this, _("Leaf private key"), true, wxGBPosition (r, 0));
- _private_key = new wxStaticText (this, wxID_ANY, wxT (""));
- wxFont font = _private_key->GetFont ();
- font.SetFamily (wxFONTFAMILY_TELETYPE);
- _private_key->SetFont (font);
- table->Add (_private_key, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
- _load_private_key = new wxButton (this, wxID_ANY, _("Load..."));
- table->Add (_load_private_key, wxGBPosition (r, 2));
- _export_private_key = new wxButton (this, wxID_ANY, _("Export..."));
- table->Add (_export_private_key, wxGBPosition (r, 3));
- ++r;
-
- _button_sizer = new wxBoxSizer (wxHORIZONTAL);
- _remake_certificates = new wxButton (this, wxID_ANY, _("Re-make certificates\nand key..."));
- _button_sizer->Add (_remake_certificates, 1, wxRIGHT, border);
- table->Add (_button_sizer, wxGBPosition (r, 0), wxGBSpan (1, 4));
- ++r;
-
- _private_key_bad = new wxStaticText (this, wxID_ANY, _("Leaf private key does not match leaf certificate!"));
- font = *wxSMALL_FONT;
- font.SetWeight (wxFONTWEIGHT_BOLD);
- _private_key_bad->SetFont (font);
- table->Add (_private_key_bad, wxGBPosition (r, 0), wxGBSpan (1, 3));
- ++r;
-
- _add_certificate->Bind (wxEVT_BUTTON, boost::bind (&CertificateChainEditor::add_certificate, this));
- _remove_certificate->Bind (wxEVT_BUTTON, boost::bind (&CertificateChainEditor::remove_certificate, this));
- _export_certificate->Bind (wxEVT_BUTTON, boost::bind (&CertificateChainEditor::export_certificate, this));
- _certificates->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind (&CertificateChainEditor::update_sensitivity, this));
- _certificates->Bind (wxEVT_LIST_ITEM_DESELECTED, boost::bind (&CertificateChainEditor::update_sensitivity, this));
- _remake_certificates->Bind (wxEVT_BUTTON, boost::bind (&CertificateChainEditor::remake_certificates, this));
- _load_private_key->Bind (wxEVT_BUTTON, boost::bind (&CertificateChainEditor::load_private_key, this));
- _export_private_key->Bind (wxEVT_BUTTON, boost::bind (&CertificateChainEditor::export_private_key, this));
-
- SetSizerAndFit (_sizer);
- }