X-Git-Url: https://git.decadent.org.uk/gitweb/?p=videolink.git;a=blobdiff_plain;f=webdvd.cpp;h=43f54c7021a703b8be936cb8280548239dfee6f0;hp=8019007deb4fda978bc7533328dbbdcd28bfb169;hb=c13714f6498df33e02635421354f5fb88a60eb3d;hpb=d8d5c01a14ab3808a9c823996eb1b72d5c624807 diff --git a/webdvd.cpp b/webdvd.cpp index 8019007..43f54c7 100644 --- a/webdvd.cpp +++ b/webdvd.cpp @@ -1,4 +1,4 @@ -// Copyright 2005 Ben Hutchings . +// Copyright 2005-6 Ben Hutchings . // See the file "COPYING" for licence details. #include @@ -60,6 +60,7 @@ #include "temp_file.hpp" #include "video.hpp" #include "x_frame_buffer.hpp" +#include "xml_utils.hpp" #include "xpcom_support.hpp" using xpcom_support::check; @@ -144,35 +145,6 @@ namespace } - std::string xml_escape(const std::string & str) - { - std::string result; - std::size_t begin = 0; - - for (;;) - { - std::size_t end = str.find_first_of("\"&'<>", begin); - result.append(str, begin, end - begin); - if (end == std::string::npos) - return result; - - const char * entity = NULL; - switch (str[end]) - { - case '"': entity = """; break; - case '&': entity = "&"; break; - case '\'': entity = "'"; break; - case '<': entity = "<"; break; - case '>': entity = ">"; break; - } - assert(entity); - result.append(entity); - - begin = end + 1; - } - } - - class webdvd_window : public Gtk::Window { public: @@ -270,32 +242,30 @@ namespace else { Glib::ustring hostname; - std::string filename(Glib::filename_from_uri(uri, hostname)); + std::string path(Glib::filename_from_uri(uri, hostname)); // FIXME: Should check the hostname - std::string vob_list; + vob_list list; // Store a reference to a linked VOB file, or the contents // of a linked VOB list file. - if (filename.compare(filename.size() - 4, 4, ".vob") == 0) + if (path.compare(path.size() - 4, 4, ".vob") == 0) { - if (!Glib::file_test(filename, Glib::FILE_TEST_IS_REGULAR)) + if (!Glib::file_test(path, Glib::FILE_TEST_IS_REGULAR)) throw std::runtime_error( - filename + " is missing or not a regular file"); - vob_list - .append("\n"); + path + " is missing or not a regular file"); + vob_ref ref; + ref.file = path; + list.push_back(ref); } else { - assert(filename.compare(filename.size() - 8, 8, ".voblist") - == 0); - // TODO: Validate the file contents - vob_list.assign(Glib::file_get_contents(filename)); + assert(path.compare(path.size() - 8, 8, ".voblist") == 0); + read_vob_list(path).swap(list); } - contents_.titles.push_back(dvd_contents::title(vob_list)); + contents_.titles.resize(contents_.titles.size() + 1); + contents_.titles.back().swap(list); return next_title; } }