Tidy up handling of content-modified checks when using the dcpomatic_cli.
[dcpomatic.git] / src / lib / film.cc
index 0b2b67801c28ec7adca2775ba53e8d5bcaecb400..687033908db186257f93b2d84cf958796b10edf4 100644 (file)
@@ -99,6 +99,7 @@ using boost::dynamic_pointer_cast;
 using boost::optional;
 using boost::is_any_of;
 using dcp::raw_convert;
+using namespace dcpomatic;
 
 string const Film::metadata_file = "metadata.xml";
 
@@ -298,7 +299,7 @@ Film::audio_analysis_path (shared_ptr<const Playlist> playlist) const
 
 /** Add suitable Jobs to the JobManager to create a DCP for this Film */
 void
-Film::make_dcp ()
+Film::make_dcp (bool gui)
 {
        if (dcp_name().find ("/") != string::npos) {
                throw BadSettingError (_("name"), _("Cannot contain slashes"));
@@ -352,7 +353,7 @@ Film::make_dcp ()
 
        shared_ptr<TranscodeJob> tj (new TranscodeJob (shared_from_this()));
        tj->set_encoder (shared_ptr<Encoder> (new DCPEncoder (shared_from_this(), tj)));
-       shared_ptr<CheckContentChangeJob> cc (new CheckContentChangeJob (shared_from_this(), tj));
+       shared_ptr<CheckContentChangeJob> cc (new CheckContentChangeJob(shared_from_this(), tj, gui));
        JobManager::instance()->add (cc);
 }
 
@@ -408,6 +409,9 @@ Film::metadata (bool with_content_paths) const
                m->set_attribute("Type", dcp::marker_to_string(i->first));
                m->add_child_text(raw_convert<string>(i->second.get()));
        }
+       BOOST_FOREACH (dcp::Rating i, _ratings) {
+               i.as_xml (root->add_child("Rating"));
+       }
        _playlist->as_xml (root->add_child ("Playlist"), with_content_paths);
 
        return doc;
@@ -540,8 +544,11 @@ Film::read_metadata (optional<boost::filesystem::path> path)
                _markers[dcp::marker_from_string(i->string_attribute("Type"))] = DCPTime(dcp::raw_convert<DCPTime::Type>(i->content()));
        }
 
+       BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("Rating")) {
+               _ratings.push_back (dcp::Rating(i));
+       }
+
        list<string> notes;
-       /* This method is the only one that can return notes (so far) */
        _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes);
 
        /* Write backtraces to this film's directory, until another film is loaded */
@@ -1413,7 +1420,7 @@ Film::make_kdm (
  *  @param disable_forensic_marking_audio if not set, don't disable forensic marking of audio.  If set to 0,
  *  disable all forensic marking; if set above 0, disable forensic marking above that channel.
  */
-list<ScreenKDM>
+list<shared_ptr<ScreenKDM> >
 Film::make_kdms (
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path cpl_file,
@@ -1424,7 +1431,7 @@ Film::make_kdms (
        optional<int> disable_forensic_marking_audio
        ) const
 {
-       list<ScreenKDM> kdms;
+       list<shared_ptr<ScreenKDM> > kdms;
 
        BOOST_FOREACH (shared_ptr<Screen> i, screens) {
                if (i->recipient) {
@@ -1439,7 +1446,7 @@ Film::make_kdms (
                                disable_forensic_marking_audio
                                );
 
-                       kdms.push_back (ScreenKDM (i, kdm));
+                       kdms.push_back (shared_ptr<ScreenKDM>(new DCPScreenKDM(i, kdm)));
                }
        }
 
@@ -1709,6 +1716,13 @@ Film::unset_marker (dcp::Marker type)
        _markers.erase (type);
 }
 
+void
+Film::set_ratings (vector<dcp::Rating> r)
+{
+       ChangeSignaller<Film> ch (this, RATINGS);
+       _ratings = r;
+}
+
 optional<DCPTime>
 Film::marker (dcp::Marker type) const
 {