// See the file "COPYING" for licence details.
#include <cassert>
+#include <cstring>
#include <exception>
#include <fstream>
#include <iomanip>
video_paths_.size() + 1)))
.second)
{
- // FIXME: Should accept some slightly different URI prefixes
- // (e.g. file://localhost/) and decode any URI-escaped
- // characters in the path.
- assert(uri.compare(0, 8, "file:///") == 0);
- video_paths_.push_back(uri.substr(7));
+ Glib::ustring hostname;
+ video_paths_.push_back(Glib::filename_from_uri(uri, hostname));
+ // FIXME: Should check the hostname
}
}
{
video::frame_params frame_params = video::pal_params;
bool preview_mode = false;
+ std::string menu_url;
+ std::string output_dir;
- // Do initial argument parsing. We have to do this before
+ // Do initial option parsing. We have to do this before
// letting Gtk parse the arguments since we may need to spawn
// Xvfb first.
int argi = 1;
// Initialise Gtk
Gtk::Main kit(argc, argv);
- // Complete argument parsing with Gtk's options out of the way.
+ // Complete option parsing with Gtk's options out of the way.
argi = 1;
while (argi != argc)
{
break;
}
}
- if (argc - argi != (preview_mode ? 1 : 2))
+
+ // Look for a starting URL or filename and (except in preview
+ // mode) an output directory after the options.
+ if (argc - argi != (preview_mode ? 1 : 2))
{
print_usage(std::cerr, argv[0]);
return EXIT_FAILURE;
}
+ if (std::strstr(argv[argi], "://"))
+ {
+ // It appears to be an absolute URL, so use it as-is.
+ menu_url = argv[argi];
+ }
+ else
+ {
+ // Assume it's a filename. Resolve it to an absolute URL.
+ std::string path(argv[argi]);
+ if (!Glib::path_is_absolute(path))
+ path = Glib::build_filename(Glib::get_current_dir(), path);
+ menu_url = Glib::filename_to_uri(path);
+ }
+ if (!preview_mode)
+ output_dir = argv[argi + 1];
// Initialise Mozilla
BrowserWidget::init();
- WebDvdWindow window(frame_params,
- argv[argi],
- preview_mode ? "" : argv[argi + 1]);
+ // Run the browser/converter
+ WebDvdWindow window(frame_params, menu_url, output_dir);
Gtk::Main::run(window);
}
catch (std::exception & e)