+void
+UpdateChecker::thread ()
+{
+ while (1) {
+ boost::mutex::scoped_lock lock (_process_mutex);
+ while (_to_do == 0) {
+ _condition.wait (lock);
+ }
+ --_to_do;
+ lock.unlock ();
+
+ try {
+ _offset = 0;
+
+ int r = curl_easy_perform (_curl);
+ if (r != CURLE_OK) {
+ set_state (FAILED);
+ return;
+ }
+
+ _buffer[_offset] = '\0';
+ stringstream s;
+ s << _buffer;
+ cxml::Document doc ("Update");
+ doc.read_stream (s);
+
+ {
+ boost::mutex::scoped_lock lm (_data_mutex);
+ _stable = doc.string_child ("Stable");
+ _test = doc.string_child ("Test");
+ }
+
+ string current = string (dcpomatic_version);
+ bool current_pre = false;
+ if (boost::algorithm::ends_with (current, "pre")) {
+ current = current.substr (0, current.length() - 3);
+ current_pre = true;
+ }
+
+ float current_float = raw_convert<float> (current);
+ if (current_pre) {
+ current_float -= 0.005;
+ }
+
+ if (current_float < raw_convert<float> (_stable)) {
+ set_state (YES);
+ } else {
+ set_state (NO);
+ }
+ } catch (...) {
+ set_state (FAILED);
+ }