std::shared_ptr
[dcpomatic.git] / src / wx / content_menu.cc
index ec966b81a5ac9e95bcfa4e32a15eb590d3da19b6..57c6afeb3eaa3166f13aa8104e846a77860f8916 100644 (file)
@@ -40,6 +40,7 @@
 #include "lib/copy_dcp_details_to_film.h"
 #include <dcp/cpl.h>
 #include <dcp/exceptions.h>
+#include <dcp/decrypted_kdm.h>
 #include <wx/wx.h>
 #include <wx/dirdlg.h>
 #include <boost/foreach.hpp>
@@ -49,10 +50,14 @@ using std::cout;
 using std::vector;
 using std::exception;
 using std::list;
-using boost::shared_ptr;
-using boost::weak_ptr;
-using boost::dynamic_pointer_cast;
+using std::shared_ptr;
+using std::weak_ptr;
+using std::dynamic_pointer_cast;
 using boost::optional;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
+
 
 enum {
        /* Start at 256 so we can have IDs on _cpl_menu from 1 to 255 */
@@ -352,9 +357,9 @@ ContentMenu::find_missing ()
                        bind (
                                &ContentMenu::maybe_found_missing,
                                this,
-                               boost::weak_ptr<Job> (j),
-                               boost::weak_ptr<Content> (_content.front ()),
-                               boost::weak_ptr<Content> (i)
+                               std::weak_ptr<Job> (j),
+                               std::weak_ptr<Content> (_content.front ()),
+                               std::weak_ptr<Content> (i)
                                )
                        );
 
@@ -415,6 +420,17 @@ ContentMenu::kdm ()
                        return;
                }
 
+               /* Try to decrypt it to get an early preview of any errors */
+               try {
+                       decrypt_kdm_with_helpful_error (*kdm);
+               } catch (KDMError& e) {
+                       error_dialog (_parent, std_to_wx(e.summary()), std_to_wx(e.detail()));
+                       return;
+               } catch (exception& e) {
+                       error_dialog (_parent, e.what());
+                       return;
+               }
+
                DCPExaminer ex (dcp, true);
 
                bool kdm_matches_any_cpl = false;
@@ -424,7 +440,6 @@ ContentMenu::kdm ()
                        }
                }
 
-
                bool kdm_matches_selected_cpl = dcp->cpl() || kdm->cpl_id() == dcp->cpl().get();
 
                if (!kdm_matches_any_cpl) {