X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=webdvd.cpp;h=5eca6c87eafe5a43d865241cff4e83df9b6df3e8;hb=15072d864fc8f74ffd40a6d966622bcf55d8a44b;hp=5b3cd9b998b65375f1139d58ad9fa0e1d92f269a;hpb=355c6bfe3cb41adf8b34f0ebf8f2cd3759ce1002;p=videolink.git diff --git a/webdvd.cpp b/webdvd.cpp index 5b3cd9b..5eca6c8 100644 --- a/webdvd.cpp +++ b/webdvd.cpp @@ -42,8 +42,11 @@ #include #include // required before nsILink.h #include +#include +#include #include #include +#include #include #include @@ -219,8 +222,12 @@ namespace .second) { Glib::ustring hostname; - video_paths_.push_back(Glib::filename_from_uri(uri, hostname)); + std::string filename(Glib::filename_from_uri(uri, hostname)); // FIXME: Should check the hostname + if (!Glib::file_test(filename, Glib::FILE_TEST_IS_REGULAR)) + throw std::runtime_error( + filename + " is missing or not a regular file"); + video_paths_.push_back(filename); } } @@ -240,6 +247,45 @@ namespace void WebDvdWindow::on_net_state_change(const char * uri, gint flags, guint status) { +# ifdef DEBUG_ON_NET_STATE_CHANGE + std::cout << "WebDvdWindow::on_net_state_change("; + if (uri) + std::cout << '"' << uri << '"'; + else + std::cout << "NULL"; + std::cout << ", "; + { + gint flags_left = flags; + static const struct { + gint value; + const char * name; + } flag_names[] = { + { GTK_MOZ_EMBED_FLAG_START, "STATE_START" }, + { GTK_MOZ_EMBED_FLAG_REDIRECTING, "STATE_REDIRECTING" }, + { GTK_MOZ_EMBED_FLAG_TRANSFERRING, "STATE_TRANSFERRING" }, + { GTK_MOZ_EMBED_FLAG_NEGOTIATING, "STATE_NEGOTIATING" }, + { GTK_MOZ_EMBED_FLAG_STOP, "STATE_STOP" }, + { GTK_MOZ_EMBED_FLAG_IS_REQUEST, "STATE_IS_REQUEST" }, + { GTK_MOZ_EMBED_FLAG_IS_DOCUMENT, "STATE_IS_DOCUMENT" }, + { GTK_MOZ_EMBED_FLAG_IS_NETWORK, "STATE_IS_NETWORK" }, + { GTK_MOZ_EMBED_FLAG_IS_WINDOW, "STATE_IS_WINDOW" } + }; + for (int i = 0; i != sizeof(flag_names)/sizeof(flag_names[0]); ++i) + { + if (flags & flag_names[i].value) + { + std::cout << flag_names[i].name; + flags_left -= flag_names[i].value; + if (flags_left) + std::cout << " | "; + } + } + if (flags_left) + std::cout << "0x" << std::setbase(16) << flags_left; + } + std::cout << ", " << "0x" << std::setbase(16) << status << ")\n"; +# endif // DEBUG_ON_NET_STATE_CHANGE + if (flags & GTK_MOZ_EMBED_FLAG_IS_REQUEST) { if (flags & GTK_MOZ_EMBED_FLAG_START) @@ -498,8 +544,11 @@ namespace check(uri->GetPath(path)); // FIXME: This is a bit of a hack. Perhaps we could decide // later based on the MIME type determined by Mozilla? - if (path.Length() > 4 - && std::strcmp(path.EndReading() - 4, ".vob") == 0) + if ((path.Length() > 4 + && std::strcmp(path.EndReading() - 4, ".vob") == 0) + || (path.Length() > 8 + && std::strcmp(path.EndReading() - 8, ".voblist") + == 0)) { PRBool is_file; check(uri->SchemeIs("file", &is_file)); @@ -806,10 +855,25 @@ namespace " \n" " \n" // Record calling page/menu. - "
 g12 = g1; 
\n" + "
 g12 = g1; 
\n"; + + // Write a reference to a linked VOB file, or the contents + // of a linked VOB list file. + const std::string & video_path = video_paths_[video_num - 1]; + if (video_path.compare(video_path.size() - 4, 4, ".vob") == 0) + { // FIXME: Should XML-escape the path - " \n" + file << " \n"; + } + else + { + assert(video_path.compare(video_path.size() - 8, 8, + ".voblist") == 0); + // TODO: Validate the file contents; + file << Glib::file_get_contents(video_path); + } + + file << // If page/menu location has not been changed during the // video, change the location to be the following // link/button when returning to it. In any case, @@ -914,6 +978,30 @@ namespace " [--preview] menu-url [output-dir]\n"); } + void set_browser_preferences() + { + // Disable IE-compatibility kluge that causes backgrounds to + // sometimes/usually be missing from snapshots. This is only + // effective from Mozilla 1.8 onward. +# if MOZ_VERSION_MAJOR > 1 \ + || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8) + nsCOMPtr pref_service; + static const nsCID pref_service_cid = NS_PREFSERVICE_CID; + check(CallGetService(pref_service_cid, + getter_AddRefs(pref_service))); + nsCOMPtr pref_branch; + check(pref_service->GetDefaultBranch("layout", + getter_AddRefs(pref_branch))); + check(pref_branch->SetBoolPref( + "fire_onload_after_image_background_loads", + true)); +# endif + + // TODO: Set display resolution? Unfortunately Mozilla doesn't + // support non-square pixels (and neither do fontconfig or Xft + // anyway). + } + } // namespace int main(int argc, char ** argv) @@ -1030,7 +1118,8 @@ int main(int argc, char ** argv) output_dir = argv[argi + 1]; // Initialise Mozilla - BrowserWidget::init(); + BrowserWidget::Initialiser browser_init; + set_browser_preferences(); // Run the browser/converter WebDvdWindow window(frame_params, menu_url, output_dir);