X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fjson_server.cc;h=e06ee22c3d0b75f44fd82a5b5293cb0970941646;hb=bf85b207298bc90b5d1559ce0f292f1c6b1696ee;hp=1be3c7d0e9d894698534d84d6df4aaeaea265c30;hpb=05654d0e1799746a9df3ccab040c92e0ed825cac;p=dcpomatic.git diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc index 1be3c7d0e..e06ee22c3 100644 --- a/src/lib/json_server.cc +++ b/src/lib/json_server.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -139,22 +139,22 @@ void JSONServer::request (string url, shared_ptr socket) { cout << "request: " << url << "\n"; - + map r = split_get_request (url); for (map::iterator i = r.begin(); i != r.end(); ++i) { cout << i->first << " => " << i->second << "\n"; } - + string action; if (r.find ("action") != r.end ()) { action = r["action"]; } - + stringstream json; if (action == "status") { - + list > jobs = JobManager::instance()->get (); - + json << "{ \"jobs\": ["; for (list >::iterator i = jobs.begin(); i != jobs.end(); ++i) { @@ -163,12 +163,16 @@ JSONServer::request (string url, shared_ptr socket) if ((*i)->film()) { json << "\"dcp\": \"" << (*i)->film()->dcp_name() << "\", "; } - - json << "\"name\": \"" << (*i)->json_name() << "\", " - << "\"progress\": " << (*i)->progress () << ", " - << "\"status\": \"" << (*i)->json_status() << "\""; + + json << "\"name\": \"" << (*i)->json_name() << "\", "; + if ((*i)->progress ()) { + json << "\"progress\": " << (*i)->progress().get() << ", "; + } else { + json << "\"progress\": unknown, "; + } + json << "\"status\": \"" << (*i)->json_status() << "\""; json << " }"; - + list >::iterator j = i; ++j; if (j != jobs.end ()) { @@ -176,12 +180,12 @@ JSONServer::request (string url, shared_ptr socket) } } json << "] }"; - + if (json.str().empty ()) { json << "{ }"; } } - + stringstream reply; reply << "HTTP/1.1 200 OK\r\n" << "Content-Length: " << json.str().length() << "\r\n"