Obey DCPOMATIC_LINUX_SHARE_PREFIX in non-debug as well as debug mode.
[dcpomatic.git] / src / lib / json_server.cc
index f4aa292d7779ca8cee77af2855b489242738d6fe..1035c248fccbb3b5abc873e848765214e1c6ebc0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
 
     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
@@ -58,7 +58,7 @@ try
 {
        boost::asio::io_service io_service;
        tcp::acceptor a (io_service, tcp::endpoint (tcp::v4 (), port));
-       while (1) {
+       while (true) {
                try {
                        shared_ptr<tcp::socket> s (new tcp::socket (io_service));
                        a.accept (*s);
@@ -80,7 +80,7 @@ JSONServer::handle (shared_ptr<tcp::socket> socket)
        string url;
        State state = AWAITING_G;
 
-       while (1) {
+       while (true) {
                char data[MAX_LENGTH];
                boost::system::error_code error;
                size_t len = socket->read_some (boost::asio::buffer (data), error);
@@ -164,9 +164,13 @@ JSONServer::request (string url, shared_ptr<tcp::socket> socket)
                                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<shared_ptr<Job> >::iterator j = i;