Missing files.
[dcpomatic.git] / src / wx / make_chain_dialog.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 "make_chain_dialog.h"
21 #include <boost/algorithm/string.hpp>
22
23 using std::string;
24
25 MakeChainDialog::MakeChainDialog (
26         wxWindow* parent,
27         string organisation,
28         string organisational_unit_name,
29         string root_common_name,
30         string intermediate_common_name,
31         string leaf_common_name
32         )
33         : TableDialog (parent, _("Make certificate chain"), 2, true)
34 {
35         wxTextValidator validator (wxFILTER_EXCLUDE_CHAR_LIST);
36         validator.SetCharExcludes (wxT ("/"));
37
38         if (boost::algorithm::starts_with (root_common_name, ".")) {
39                 root_common_name = root_common_name.substr (1);
40         }
41
42         if (boost::algorithm::starts_with (intermediate_common_name, ".")) {
43                 intermediate_common_name = intermediate_common_name.substr (1);
44         }
45
46         if (boost::algorithm::starts_with (leaf_common_name, "CS.")) {
47                 leaf_common_name = leaf_common_name.substr (3);
48         }
49
50         add (_("Organisation"), true);
51         add (_organisation = new wxTextCtrl (this, wxID_ANY, std_to_wx (organisation), wxDefaultPosition, wxSize (480, -1), 0, validator));
52         add (_("Organisational unit"), true);
53         add (_organisational_unit = new wxTextCtrl (this, wxID_ANY, std_to_wx (organisational_unit_name), wxDefaultPosition, wxDefaultSize, 0, validator));
54
55         add (_("Root common name"), true);
56
57         {
58                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
59                 s->Add (new wxStaticText (this, wxID_ANY, wxT (".")), 0, wxALIGN_CENTER_VERTICAL);
60                 s->Add (_root_common_name = new wxTextCtrl (
61                                 this, wxID_ANY, std_to_wx (root_common_name), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL
62                         );
63                 add (s);
64         }
65
66         add (_("Intermediate common name"), true);
67
68         {
69                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
70                 s->Add (new wxStaticText (this, wxID_ANY, wxT (".")), 0, wxALIGN_CENTER_VERTICAL);
71                 s->Add (_intermediate_common_name = new wxTextCtrl (
72                                 this, wxID_ANY, std_to_wx (intermediate_common_name), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL
73                         );
74                 add (s);
75         }
76
77         add (_("Leaf common name"), true);
78
79         {
80                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
81                 s->Add (new wxStaticText (this, wxID_ANY, wxT ("CS.")), 0, wxALIGN_CENTER_VERTICAL);
82                 s->Add (_leaf_common_name = new wxTextCtrl (
83                                 this, wxID_ANY, std_to_wx (leaf_common_name), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL
84                         );
85                 add (s);
86         }
87
88         layout ();
89 }