Add some missing test stuff; split server discovery off into ServerFinder.
[dcpomatic.git] / src / lib / content.cc
index 44b52a4715597a68025a9052f939756573d2f5ba..e3ad42560edf82ef0e1870003f46eaa04c5cbfad 100644 (file)
 #include "ui_signaller.h"
 
 using std::string;
+using std::stringstream;
 using std::set;
 using boost::shared_ptr;
 using boost::lexical_cast;
 
-int const ContentProperty::POSITION = 400;
-int const ContentProperty::LENGTH = 401;
-int const ContentProperty::TRIM_START = 402;
-int const ContentProperty::TRIM_END = 403;
+int const ContentProperty::PATH = 400;
+int const ContentProperty::POSITION = 401;
+int const ContentProperty::LENGTH = 402;
+int const ContentProperty::TRIM_START = 403;
+int const ContentProperty::TRIM_END = 404;
 
 Content::Content (shared_ptr<const Film> f, Time p)
        : _film (f)
@@ -80,7 +82,7 @@ Content::as_xml (xmlpp::Node* node) const
 }
 
 void
-Content::examine (shared_ptr<Job>)
+Content::examine (shared_ptr<Job> job)
 {
        boost::mutex::scoped_lock lm (_mutex);
        boost::filesystem::path p = _path;
@@ -90,7 +92,7 @@ Content::examine (shared_ptr<Job>)
        if (boost::filesystem::is_regular_file (p)) {
                d = md5_digest (p);
        } else {
-               d = md5_digest_directory (p);
+               d = md5_digest_directory (p, job);
        }
 
        lm.lock ();
@@ -174,3 +176,34 @@ Content::trimmed (Time t) const
 {
        return (t < trim_start() || t > (full_length() - trim_end ()));
 }
+
+/** @return string which includes everything about how this content affects
+ *  its playlist.
+ */
+string
+Content::identifier () const
+{
+       stringstream s;
+       
+       s << Content::digest()
+         << "_" << position()
+         << "_" << trim_start()
+         << "_" << trim_end();
+
+       return s.str ();
+}
+
+bool
+Content::path_valid () const
+{
+       return boost::filesystem::exists (_path);
+}
+
+void
+Content::set_path (boost::filesystem::path path)
+{
+       _path = path;
+       signal_changed (ContentProperty::PATH);
+}
+
+