Hand-apply 62f8054d65a8bd31689fc0c977c1bb2385e71afa from master; config of encryption...
authorCarl Hetherington <cth@carlh.net>
Wed, 29 Apr 2015 21:53:52 +0000 (22:53 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 29 Apr 2015 21:53:52 +0000 (22:53 +0100)
ChangeLog
TO_PORT
src/lib/film.cc
src/lib/film.h
src/wx/dcp_panel.cc
src/wx/dcp_panel.h
src/wx/key_dialog.cc [new file with mode: 0644]
src/wx/key_dialog.h [new file with mode: 0644]
src/wx/timeline.cc
src/wx/wscript

index 5c352286996ba8c76ce09c5fd3e69f73c0d74413..c989f549f8cb4636afc981e5c8bf5e4834975f15 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2015-04-29  Carl Hetherington  <cth@carlh.net>
 
 2015-04-29  Carl Hetherington  <cth@carlh.net>
 
+       * Allow configuration of the encryption key (from master).
+
        * Various fixes to bad timeline drag behaviour when
        snapping (from master).
 
        * Various fixes to bad timeline drag behaviour when
        snapping (from master).
 
diff --git a/TO_PORT b/TO_PORT
index 6b91701ad2e3ebc5e11ac11c59705c0327f1dfbd..d36b16b744d4c0fb71e54657c88ba9b95bbba37a 100644 (file)
--- a/TO_PORT
+++ b/TO_PORT
@@ -1,3 +1,2 @@
-8471ccb29ff258722ea27405dc10312e625c132d
 4156be8147c324623b266bd59366ff8accb34778
 937b382efbeb9b7151359b8feb535e95f99f397c
 4156be8147c324623b266bd59366ff8accb34778
 937b382efbeb9b7151359b8feb535e95f99f397c
index 7dbeaafe9a58bf1b6cde5d0dfb5f46469863efc3..5e08ed9979844500c9e16b6f979c93c4edb32919 100644 (file)
@@ -881,6 +881,13 @@ Film::set_encrypted (bool e)
        signal_changed (ENCRYPTED);
 }
 
        signal_changed (ENCRYPTED);
 }
 
+void
+Film::set_key (dcp::Key key)
+{
+       _key = key;
+       signal_changed (KEY);
+}
+
 shared_ptr<Playlist>
 Film::playlist () const
 {
 shared_ptr<Playlist>
 Film::playlist () const
 {
index cca31d3061ce3e116581fc7612e129beb4788648..5eb4f17ed40be1681feb8819f2ffddd4935979c2 100644 (file)
@@ -133,10 +133,6 @@ public:
                dcp::Formulation formulation
                ) const;
 
                dcp::Formulation formulation
                ) const;
 
-       dcp::Key key () const {
-               return _key;
-       }
-
        int state_version () const {
                return _state_version;
        }
        int state_version () const {
                return _state_version;
        }
@@ -157,6 +153,7 @@ public:
                RESOLUTION,
                SIGNED,
                ENCRYPTED,
                RESOLUTION,
                SIGNED,
                ENCRYPTED,
+               KEY,
                J2K_BANDWIDTH,
                ISDCF_METADATA,
                VIDEO_FRAME_RATE,
                J2K_BANDWIDTH,
                ISDCF_METADATA,
                VIDEO_FRAME_RATE,
@@ -205,6 +202,10 @@ public:
                return _encrypted;
        }
 
                return _encrypted;
        }
 
+       dcp::Key key () const {
+               return _key;
+       }
+
        int j2k_bandwidth () const {
                return _j2k_bandwidth;
        }
        int j2k_bandwidth () const {
                return _j2k_bandwidth;
        }
@@ -255,6 +256,7 @@ public:
        void set_resolution (Resolution);
        void set_signed (bool);
        void set_encrypted (bool);
        void set_resolution (Resolution);
        void set_signed (bool);
        void set_encrypted (bool);
+       void set_key (dcp::Key key);
        void set_j2k_bandwidth (int);
        void set_isdcf_metadata (ISDCFMetadata);
        void set_video_frame_rate (int);
        void set_j2k_bandwidth (int);
        void set_isdcf_metadata (ISDCFMetadata);
        void set_video_frame_rate (int);
index 0146a14f4a4d37e5b4d0015ffcdb6f80e88df42d..82872ad8477d46f8277c450a768b8e6571350bc8 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "dcp_panel.h"
 #include "wx_util.h"
 
 #include "dcp_panel.h"
 #include "wx_util.h"
+#include "key_dialog.h"
 #include "isdcf_metadata_dialog.h"
 #include "lib/ratio.h"
 #include "lib/config.h"
 #include "isdcf_metadata_dialog.h"
 #include "lib/ratio.h"
 #include "lib/config.h"
@@ -26,6 +27,7 @@
 #include "lib/util.h"
 #include "lib/film.h"
 #include "lib/ffmpeg_content.h"
 #include "lib/util.h"
 #include "lib/film.h"
 #include "lib/ffmpeg_content.h"
+#include <dcp/key.h>
 #include <wx/wx.h>
 #include <wx/notebook.h>
 #include <wx/gbsizer.h>
 #include <wx/wx.h>
 #include <wx/notebook.h>
 #include <wx/gbsizer.h>
@@ -99,6 +101,21 @@ DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr<Film> f)
        grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
        ++r;
 
        grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
        ++r;
 
+        wxClientDC dc (_panel);
+        wxSize size = dc.GetTextExtent (wxT ("GGGGGGGG..."));
+        size.SetHeight (-1);
+
+       {
+               add_label_to_grid_bag_sizer (grid, _panel, _("Key"), true, wxGBPosition (r, 0));
+               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               _key = new wxStaticText (_panel, wxID_ANY, "", wxDefaultPosition, size);
+               s->Add (_key, 1, wxALIGN_CENTER_VERTICAL);
+               _edit_key = new wxButton (_panel, wxID_ANY, _("Edit..."));
+               s->Add (_edit_key);
+               grid->Add (s, wxGBPosition (r, 1));
+               ++r;
+       }
+       
        add_label_to_grid_bag_sizer (grid, _panel, _("Standard"), true, wxGBPosition (r, 0));
        _standard = new wxChoice (_panel, wxID_ANY);
        grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
        add_label_to_grid_bag_sizer (grid, _panel, _("Standard"), true, wxGBPosition (r, 0));
        _standard = new wxChoice (_panel, wxID_ANY);
        grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
@@ -111,6 +128,7 @@ DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr<Film> f)
        _dcp_content_type->Bind  (wxEVT_COMMAND_CHOICE_SELECTED,      boost::bind (&DCPPanel::dcp_content_type_changed, this));
        _signed->Bind            (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::signed_toggled, this));
        _encrypted->Bind         (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::encrypted_toggled, this));
        _dcp_content_type->Bind  (wxEVT_COMMAND_CHOICE_SELECTED,      boost::bind (&DCPPanel::dcp_content_type_changed, this));
        _signed->Bind            (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::signed_toggled, this));
        _encrypted->Bind         (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::encrypted_toggled, this));
+       _edit_key->Bind          (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&DCPPanel::edit_key_clicked, this));
        _standard->Bind          (wxEVT_COMMAND_CHOICE_SELECTED,      boost::bind (&DCPPanel::standard_changed, this));
 
        vector<DCPContentType const *> const ct = DCPContentType::all ();
        _standard->Bind          (wxEVT_COMMAND_CHOICE_SELECTED,      boost::bind (&DCPPanel::standard_changed, this));
 
        vector<DCPContentType const *> const ct = DCPContentType::all ();
@@ -124,6 +142,16 @@ DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr<Film> f)
        Config::instance()->Changed.connect (boost::bind (&DCPPanel::config_changed, this));
 }
 
        Config::instance()->Changed.connect (boost::bind (&DCPPanel::config_changed, this));
 }
 
+void
+DCPPanel::edit_key_clicked ()
+{
+       KeyDialog* d = new KeyDialog (_panel, _film->key ());
+       if (d->ShowModal () == wxID_OK) {
+               _film->set_key (d->key ());
+       }
+       d->Destroy ();
+}
+
 void
 DCPPanel::name_changed ()
 {
 void
 DCPPanel::name_changed ()
 {
@@ -258,10 +286,17 @@ DCPPanel::film_changed (int p)
                if (_film->encrypted ()) {
                        _film->set_signed (true);
                        _signed->Enable (false);
                if (_film->encrypted ()) {
                        _film->set_signed (true);
                        _signed->Enable (false);
+                       _key->Enable (_generally_sensitive);
+                       _edit_key->Enable (_generally_sensitive);
                } else {
                        _signed->Enable (_generally_sensitive);
                } else {
                        _signed->Enable (_generally_sensitive);
+                       _key->Enable (false);
+                       _edit_key->Enable (false);
                }
                break;
                }
                break;
+       case Film::KEY:
+               checked_set (_key, _film->key().hex().substr (0, 8) + "...");
+               break;
        case Film::RESOLUTION:
                checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
                setup_dcp_name ();
        case Film::RESOLUTION:
                checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
                setup_dcp_name ();
@@ -390,6 +425,7 @@ DCPPanel::set_film (shared_ptr<Film> film)
        film_changed (Film::SIGNED);
        film_changed (Film::BURN_SUBTITLES);
        film_changed (Film::ENCRYPTED);
        film_changed (Film::SIGNED);
        film_changed (Film::BURN_SUBTITLES);
        film_changed (Film::ENCRYPTED);
+       film_changed (Film::KEY);
        film_changed (Film::J2K_BANDWIDTH);
        film_changed (Film::ISDCF_METADATA);
        film_changed (Film::VIDEO_FRAME_RATE);
        film_changed (Film::J2K_BANDWIDTH);
        film_changed (Film::ISDCF_METADATA);
        film_changed (Film::VIDEO_FRAME_RATE);
@@ -416,6 +452,8 @@ DCPPanel::set_general_sensitivity (bool s)
        _signed->Enable (si);
        
        _encrypted->Enable (s);
        _signed->Enable (si);
        
        _encrypted->Enable (s);
+       _key->Enable (s && _film && _film->encrypted ());
+       _edit_key->Enable (s && _film && _film->encrypted ());
        _frame_rate_choice->Enable (s);
        _frame_rate_spin->Enable (s);
        _audio_channels->Enable (s);
        _frame_rate_choice->Enable (s);
        _frame_rate_spin->Enable (s);
        _audio_channels->Enable (s);
index c5c76f27a112bbb7264e1eb047f8a408eb60932c..96786d8a1d93ef912881498e796fc2654b4c2501 100644 (file)
@@ -67,6 +67,7 @@ private:
        void signed_toggled ();
        void burn_subtitles_toggled ();
        void encrypted_toggled ();
        void signed_toggled ();
        void burn_subtitles_toggled ();
        void encrypted_toggled ();
+       void edit_key_clicked ();
 
        void setup_frame_rate_widget ();
        void setup_container ();
 
        void setup_frame_rate_widget ();
        void setup_container ();
@@ -101,6 +102,8 @@ private:
        wxCheckBox* _signed;
        wxCheckBox* _burn_subtitles;
        wxCheckBox* _encrypted;
        wxCheckBox* _signed;
        wxCheckBox* _burn_subtitles;
        wxCheckBox* _encrypted;
+       wxStaticText* _key;
+       wxButton* _edit_key;
 
        boost::shared_ptr<Film> _film;
        bool _generally_sensitive;
 
        boost::shared_ptr<Film> _film;
        bool _generally_sensitive;
diff --git a/src/wx/key_dialog.cc b/src/wx/key_dialog.cc
new file mode 100644 (file)
index 0000000..d7c8096
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "key_dialog.h"
+#include "wx_util.h"
+
+using std::cout;
+
+KeyDialog::KeyDialog (wxWindow* parent, dcp::Key key)
+       : TableDialog (parent, _("Key"), 3, true)
+{
+       add (_("Key"), true);
+
+        wxClientDC dc (parent);
+        wxSize size = dc.GetTextExtent (wxT ("0123456790ABCDEF0123456790ABCDEF"));
+        size.SetHeight (-1);
+
+        wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
+        wxArrayString list;
+
+        wxString n (wxT ("0123456789abcdefABCDEF"));
+        for (size_t i = 0; i < n.Length(); ++i) {
+                list.Add (n[i]);
+        }
+
+        validator.SetIncludes (list);
+       
+       _key = add (new wxTextCtrl (this, wxID_ANY, _(""), wxDefaultPosition, size, 0, validator));
+       _key->SetValue (std_to_wx (key.hex ()));
+       _key->SetMaxLength (32);
+
+       _random = add (new wxButton (this, wxID_ANY, _("Random")));
+
+       _key->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KeyDialog::key_changed, this));
+       _random->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&KeyDialog::random, this));
+
+       layout ();
+}
+
+dcp::Key
+KeyDialog::key () const
+{
+       return dcp::Key (wx_to_std (_key->GetValue ()));
+}
+
+void
+KeyDialog::key_changed ()
+{
+       wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK));
+       ok->Enable (_key->GetValue().Length() == 32);
+}
+
+void
+KeyDialog::random ()
+{
+       _key->SetValue (dcp::Key().hex ());
+}
diff --git a/src/wx/key_dialog.h b/src/wx/key_dialog.h
new file mode 100644 (file)
index 0000000..81402d4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "table_dialog.h"
+#include <dcp/key.h>
+
+class KeyDialog : public TableDialog
+{
+public:
+       KeyDialog (wxWindow *, dcp::Key);
+
+       dcp::Key key () const;
+
+private:
+       void key_changed ();
+       void random ();
+       
+       wxTextCtrl* _key;
+       wxButton* _random;
+};
index 9c70a001e0bc2709ebfea53cfe91fa02568056a6..f1c6e30f342c981f2dc307228e4929fdadc35e2a 100644 (file)
@@ -363,7 +363,7 @@ Timeline::set_position_from_event (wxMouseEvent& ev)
        
        if (_snap) {
 
        
        if (_snap) {
 
-               DCPTime const new_end = new_position + _down_view->content()->length_after_trim () - 1;
+               DCPTime const new_end = new_position + _down_view->content()->length_after_trim () - DCPTime (1);
                /* Signed `distance' to nearest thing (i.e. negative is left on the timeline,
                   positive is right).
                */
                /* Signed `distance' to nearest thing (i.e. negative is left on the timeline,
                   positive is right).
                */
@@ -377,9 +377,9 @@ Timeline::set_position_from_event (wxMouseEvent& ev)
                        }
 
                        maybe_snap (cv->content()->position(), new_position, nearest_distance);
                        }
 
                        maybe_snap (cv->content()->position(), new_position, nearest_distance);
-                       maybe_snap (cv->content()->position(), new_end + 1, nearest_distance);
-                       maybe_snap (cv->content()->end() + 1, new_position, nearest_distance);
-                       maybe_snap (cv->content()->end() + 1, new_end, nearest_distance);
+                       maybe_snap (cv->content()->position(), new_end + DCPTime (1), nearest_distance);
+                       maybe_snap (cv->content()->end() + DCPTime (1), new_position, nearest_distance);
+                       maybe_snap (cv->content()->end() + DCPTime (1), new_end, nearest_distance);
                }
                
                if (nearest_distance) {
                }
                
                if (nearest_distance) {
index aa5487f5fa4dbbe561f9cd1b25bd35a8b056da74..1b701bb074bec3d1aba88536a0d9be42264c1cab 100644 (file)
@@ -33,6 +33,7 @@ sources = """
           hints_dialog.cc
           job_manager_view.cc
           kdm_dialog.cc
           hints_dialog.cc
           job_manager_view.cc
           kdm_dialog.cc
+          key_dialog.cc
           make_signer_chain_dialog.cc
           new_film_dialog.cc
           preset_colour_conversion_dialog.cc
           make_signer_chain_dialog.cc
           new_film_dialog.cc
           preset_colour_conversion_dialog.cc