Missing texts for some new verification failures.
[dcpomatic.git] / src / wx / verify_dcp_dialog.cc
1 /*
2     Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "verify_dcp_dialog.h"
22 #include "wx_util.h"
23 #include "lib/verify_dcp_job.h"
24 #include <dcp/verify.h>
25 #include <wx/richtext/richtextctrl.h>
26 #include <boost/foreach.hpp>
27
28 using std::list;
29 using boost::shared_ptr;
30
31 VerifyDCPDialog::VerifyDCPDialog (wxWindow* parent, shared_ptr<VerifyDCPJob> job)
32         : wxDialog (parent, wxID_ANY, _("DCP verification"))
33 {
34         wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
35         _text = new wxRichTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (400, 300), wxRE_READONLY);
36         sizer->Add (_text, 1, wxEXPAND | wxALL, 6);
37
38         wxStdDialogButtonSizer* buttons = CreateStdDialogButtonSizer (0);
39         sizer->Add (CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
40         buttons->SetAffirmativeButton (new wxButton (this, wxID_OK));
41         buttons->Realize ();
42
43         SetSizer (sizer);
44         sizer->Layout ();
45         sizer->SetSizeHints (this);
46
47         _text->GetCaret()->Hide ();
48
49         if (job->finished_ok() && job->notes().empty()) {
50                 _text->BeginStandardBullet (N_("standard/circle"), 1, 50);
51                 _text->WriteText (_("DCP validates OK."));
52                 _text->EndStandardBullet ();
53                 return;
54         }
55
56         /* We might have an error that did not come from dcp::verify; report it if so */
57         if (job->finished_in_error() && job->error_summary() != "") {
58                 _text->BeginSymbolBullet (N_("!"), 1, 50);
59                 _text->WriteText(std_to_wx(job->error_summary()));
60                 _text->Newline();
61         }
62
63         BOOST_FOREACH (dcp::VerificationNote i, job->notes()) {
64                 switch (i.type()) {
65                 case dcp::VerificationNote::VERIFY_WARNING:
66                         _text->BeginStandardBullet (N_("standard/diamond"), 1, 50);
67                         break;
68                 case dcp::VerificationNote::VERIFY_ERROR:
69                         _text->BeginSymbolBullet (N_("!"), 1, 50);
70                         break;
71                 }
72
73                 wxString text;
74                 switch (i.code()) {
75                 case dcp::VerificationNote::GENERAL_READ:
76                         text = std_to_wx(*i.note());
77                         break;
78                 case dcp::VerificationNote::CPL_HASH_INCORRECT:
79                         text = _("The hash of the CPL in the PKL does not agree with the CPL file.  This probably means that the CPL file is corrupt.");
80                         break;
81                 case dcp::VerificationNote::INVALID_PICTURE_FRAME_RATE:
82                         text = _("The picture in a reel has an invalid frame rate");
83                         break;
84                 case dcp::VerificationNote::PICTURE_HASH_INCORRECT:
85                         text = wxString::Format(
86                                 _("The hash of the picture asset %s does not agree with the PKL file.  This probably means that the asset file is corrupt."),
87                                 std_to_wx(i.file()->filename().string())
88                                 );
89                         break;
90                 case dcp::VerificationNote::PKL_CPL_PICTURE_HASHES_DISAGREE:
91                         text = _("The PKL and CPL hashes disagree for a picture asset.");
92                         break;
93                 case dcp::VerificationNote::SOUND_HASH_INCORRECT:
94                         text = wxString::Format(
95                                 _("The hash of the sound asset %s does not agree with the PKL file.  This probably means that the asset file is corrupt."),
96                                 std_to_wx(i.file()->filename().string())
97                                 );
98                         break;
99                 case dcp::VerificationNote::PKL_CPL_SOUND_HASHES_DISAGREE:
100                         text = _("The PKL and CPL hashes disagree for a sound asset.");
101                         break;
102                 case dcp::VerificationNote::EMPTY_ASSET_PATH:
103                         text = _("An asset has an empty path in the ASSETMAP.");
104                         break;
105                 case dcp::VerificationNote::MISSING_ASSET:
106                         text = _("An asset is missing.");
107                         break;
108                 case dcp::VerificationNote::MISMATCHED_STANDARD:
109                         text = _("Parts of the DCP are written according to the Interop standard and parts according to SMPTE.");
110                         break;
111                 case dcp::VerificationNote::XML_VALIDATION_ERROR:
112                         if (i.line()) {
113                                 text = wxString::Format(
114                                         _("The XML in %s is malformed on line %" PRIu64 "."),
115                                         std_to_wx(i.file()->filename().string()),
116                                         i.line().get()
117                                         );
118                         } else {
119                                 text = wxString::Format(
120                                         _("The XML in %s is malformed."),
121                                         std_to_wx(i.file()->filename().string())
122                                         );
123                         }
124                         break;
125                 case dcp::VerificationNote::MISSING_ASSETMAP:
126                         text = _("No ASSETMAP or ASSETMAP.xml file was found.");
127                         break;
128                 case dcp::VerificationNote::INTRINSIC_DURATION_TOO_SMALL:
129                         text = _("An asset has an instrinsic duration of less than 1 second, which is invalid.");
130                         break;
131                 case dcp::VerificationNote::DURATION_TOO_SMALL:
132                         text = _("An asset has a duration of less than 1 second, which is invalid.");
133                         break;
134                 }
135
136                 _text->WriteText (text);
137                 _text->Newline ();
138
139                 switch (i.type()) {
140                 case dcp::VerificationNote::VERIFY_WARNING:
141                         _text->EndStandardBullet ();
142                         break;
143                 case dcp::VerificationNote::VERIFY_ERROR:
144                         _text->EndSymbolBullet ();
145                         break;
146                 }
147         }
148 }