X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=fee4a3c26aab11ac4bf094d5977d6d9c27e18e9a;hb=7c730205e50014347bd96ab9735346d0b5922798;hp=b5265519413976328254749d63cb5236caa200cd;hpb=6e5c998593842ff76f5d0ae5cab0d03cbe11b607;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index b52655194..fee4a3c26 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -44,6 +44,7 @@ #include "ffmpeg_image_proxy.h" #include "image.h" #include "text_decoder.h" +#include "job_manager.h" #include #include #include @@ -62,6 +63,7 @@ extern "C" { #include #include #include +#include #ifdef DCPOMATIC_WINDOWS #include #include @@ -80,6 +82,7 @@ extern "C" { #include "i18n.h" using std::string; +using std::wstring; using std::setfill; using std::ostream; using std::endl; @@ -104,6 +107,7 @@ using boost::scoped_array; using dcp::Size; using dcp::raw_convert; using dcp::locale_convert; +using namespace dcpomatic; /** Path to our executable, required by the stacktrace stuff and filled * in during App::onInit(). @@ -377,7 +381,7 @@ dcpomatic_setup () Pango::init (); dcp::init (); -#ifdef DCPOMATIC_WINDOWS +#if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX) /* Render something to fontconfig to create its cache */ list subs; dcp::SubtitleString ss( @@ -743,15 +747,34 @@ careful_string_filter (string s) Safety first and all that. */ + wstring ws = boost::locale::conv::utf_to_utf(s); + string out; string const allowed = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_%.+"; - for (size_t i = 0; i < s.size(); ++i) { - if (allowed.find (s[i]) != string::npos) { - out += s[i]; + for (size_t i = 0; i < ws.size(); ++i) { + + wchar_t c = ws[i]; + + /* Remove some accents */ + if (wstring(L"áàâ").find(c) != string::npos) { + c = 'a'; + } + if (wstring(L"éèêë").find(c) != string::npos) { + c = 'e'; + } + if (wstring(L"ö").find(c) != string::npos) { + c = 'o'; + } + if (wstring(L"ü").find(c) != string::npos) { + c = 'u'; + } + + if (allowed.find(c) != string::npos) { + out += c; } } - return out; + return boost::locale::conv::utf_to_utf(out); } /** @param mapped List of mapped audio channels from a Film. @@ -923,6 +946,61 @@ emit_subtitle_image (ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size decoder->emit_bitmap (period, image, rect); } +bool +show_jobs_on_console (bool progress) +{ + bool first = true; + bool error = false; + while (true) { + + dcpomatic_sleep (5); + + list > jobs = JobManager::instance()->get(); + + if (!first && progress) { + for (size_t i = 0; i < jobs.size(); ++i) { + cout << "\033[1A\033[2K"; + } + cout.flush (); + } + + first = false; + + BOOST_FOREACH (shared_ptr i, jobs) { + if (progress) { + cout << i->name(); + if (!i->sub_name().empty()) { + cout << "; " << i->sub_name(); + } + cout << ": "; + + if (i->progress ()) { + cout << i->status() << " \n"; + } else { + cout << ": Running \n"; + } + } + + if (!progress && i->finished_in_error()) { + /* We won't see this error if we haven't been showing progress, + so show it now. + */ + cout << i->status() << "\n"; + } + + if (i->finished_in_error()) { + error = true; + } + } + + if (!JobManager::instance()->work_to_do()) { + break; + } + } + + return error; +} + #ifdef DCPOMATIC_VARIANT_SWAROOP /* Make up a key from the machine UUID */