Display thumbprint rather than whole certificate in screen dialogue.
[dcpomatic.git] / src / wx / download_certificate_panel.cc
1 /*
2     Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "wx_util.h"
21 #include "download_certificate_panel.h"
22 #include <dcp/util.h>
23 #include <dcp/exceptions.h>
24 #include <boost/bind.hpp>
25
26 using boost::function;
27 using boost::optional;
28
29 DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog)
30         : wxPanel (parent, wxID_ANY)
31         , _dialog (dialog)
32 {
33         _overall_sizer = new wxBoxSizer (wxVERTICAL);
34         SetSizer (_overall_sizer);
35
36         _table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
37         _table->AddGrowableCol (1, 1);
38
39         _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
40 }
41
42 void
43 DownloadCertificatePanel::layout ()
44 {
45         _overall_sizer->Layout ();
46         _overall_sizer->SetSizeHints (this);
47 }
48
49 void
50 DownloadCertificatePanel::load (boost::filesystem::path file)
51 {
52         try {
53                 _certificate = dcp::Certificate (dcp::file_to_string (file));
54         } catch (dcp::MiscError& e) {
55                 error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), std_to_wx(e.what()).data()));
56         }
57 }
58
59 optional<dcp::Certificate>
60 DownloadCertificatePanel::certificate () const
61 {
62         return _certificate;
63 }