Add FilmViewer::time_until_next_frame.
[dcpomatic.git] / src / wx / verify_dcp_dialog.cc
index b1eea0fd253b71aa50a4431b55b0982831cc1768..a61d9bf11a959f19eb37e6ee1520c8d5e3347271 100644 (file)
 
 #include "verify_dcp_dialog.h"
 #include "wx_util.h"
+#include "lib/verify_dcp_job.h"
 #include <dcp/verify.h>
 #include <wx/richtext/richtextctrl.h>
 #include <boost/foreach.hpp>
 
 using std::list;
+using boost::shared_ptr;
 
-VerifyDCPDialog::VerifyDCPDialog (wxWindow* parent, list<dcp::VerificationNote> notes)
+VerifyDCPDialog::VerifyDCPDialog (wxWindow* parent, shared_ptr<VerifyDCPJob> job)
        : wxDialog (parent, wxID_ANY, _("DCP verification"))
 {
        wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
@@ -44,35 +46,92 @@ VerifyDCPDialog::VerifyDCPDialog (wxWindow* parent, list<dcp::VerificationNote>
 
        _text->GetCaret()->Hide ();
 
-       if (notes.empty ()) {
+       if (job->finished_ok() && job->notes().empty()) {
                _text->BeginStandardBullet (N_("standard/circle"), 1, 50);
                _text->WriteText (_("DCP validates OK."));
                _text->EndStandardBullet ();
                return;
        }
 
-       BOOST_FOREACH (dcp::VerificationNote i, notes) {
+       /* We might have an error that did not come from dcp::verify; report it if so */
+       if (job->finished_in_error() && job->error_summary() != "") {
+               _text->BeginSymbolBullet (N_("!"), 1, 50);
+               _text->WriteText(std_to_wx(job->error_summary()));
+               _text->Newline();
+       }
+
+       BOOST_FOREACH (dcp::VerificationNote i, job->notes()) {
                switch (i.type()) {
-               case dcp::VerificationNote::NOTE:
-                       _text->BeginStandardBullet (N_("standard/circle"), 1, 50);
-                       break;
-               case dcp::VerificationNote::WARNING:
+               case dcp::VerificationNote::VERIFY_WARNING:
                        _text->BeginStandardBullet (N_("standard/diamond"), 1, 50);
                        break;
-               case dcp::VerificationNote::ERROR:
+               case dcp::VerificationNote::VERIFY_ERROR:
                        _text->BeginSymbolBullet (N_("!"), 1, 50);
                        break;
                }
 
-               _text->WriteText (std_to_wx (i.note()));
+               wxString text;
+               switch (i.code()) {
+               case dcp::VerificationNote::GENERAL_READ:
+                       text = std_to_wx(*i.note());
+                       break;
+               case dcp::VerificationNote::CPL_HASH_INCORRECT:
+                       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.");
+                       break;
+               case dcp::VerificationNote::INVALID_PICTURE_FRAME_RATE:
+                       text = _("The picture in a reel has an invalid frame rate");
+                       break;
+               case dcp::VerificationNote::PICTURE_HASH_INCORRECT:
+                       text = wxString::Format(
+                               _("The hash of the picture asset %s does not agree with the PKL file.  This probably means that the asset file is corrupt."),
+                               std_to_wx(i.file()->filename().string()).data()
+                               );
+                       break;
+               case dcp::VerificationNote::PKL_CPL_PICTURE_HASHES_DISAGREE:
+                       text = _("The PKL and CPL hashes disagree for a picture asset.");
+                       break;
+               case dcp::VerificationNote::SOUND_HASH_INCORRECT:
+                       text = wxString::Format(
+                               _("The hash of the sound asset %s does not agree with the PKL file.  This probably means that the asset file is corrupt."),
+                               std_to_wx(i.file()->filename().string()).data()
+                               );
+                       break;
+               case dcp::VerificationNote::PKL_CPL_SOUND_HASHES_DISAGREE:
+                       text = _("The PKL and CPL hashes disagree for a sound asset.");
+                       break;
+               case dcp::VerificationNote::EMPTY_ASSET_PATH:
+                       text = _("An asset has an empty path in the ASSETMAP.");
+                       break;
+               case dcp::VerificationNote::MISSING_ASSET:
+                       text = _("An asset is missing.");
+                       break;
+               case dcp::VerificationNote::MISMATCHED_STANDARD:
+                       text = _("Parts of the DCP are written according to the Interop standard and parts according to SMPTE.");
+                       break;
+               case dcp::VerificationNote::XML_VALIDATION_ERROR:
+                       if (i.line()) {
+                               text = wxString::Format(
+                                       _("The XML in %s is malformed on line %d."),
+                                       std_to_wx(i.file()->filename().string()).data(),
+                                       i.line().get()
+                                       );
+                       } else {
+                               text = wxString::Format(
+                                       _("The XML in %s is malformed."),
+                                       std_to_wx(i.file()->filename().string()).data()
+                                       );
+                       }
+                       break;
+               }
+
+               _text->WriteText (text);
                _text->Newline ();
 
                switch (i.type()) {
-               case dcp::VerificationNote::NOTE:
-               case dcp::VerificationNote::WARNING:
+               case dcp::VerificationNote::VERIFY_WARNING:
                        _text->EndStandardBullet ();
                        break;
-               case dcp::VerificationNote::ERROR:
+               case dcp::VerificationNote::VERIFY_ERROR:
                        _text->EndSymbolBullet ();
                        break;
                }