X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fupdate.cc;fp=src%2Flib%2Fupdate.cc;h=44ecbb232c26b03214f23d3191c54fedd9a9071a;hp=af3e46f0e7d14ea1abb8d64c4c4e467143588547;hb=05654d0e1799746a9df3ccab040c92e0ed825cac;hpb=6bc83f72f12c8513a1e9e9b6fd880697a73f968f diff --git a/src/lib/update.cc b/src/lib/update.cc index af3e46f0e..44ecbb232 100644 --- a/src/lib/update.cc +++ b/src/lib/update.cc @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include "update.h" #include "version.h" #include "ui_signaller.h" @@ -33,8 +33,9 @@ using std::cout; using std::min; using std::string; using std::stringstream; -using libdcp::raw_convert; +using dcp::raw_convert; +/** Singleton instance */ UpdateChecker* UpdateChecker::_instance = 0; static size_t @@ -43,6 +44,9 @@ write_callback_wrapper (void* data, size_t size, size_t nmemb, void* user) return reinterpret_cast(user)->write_callback (data, size, nmemb); } +/** Construct an UpdateChecker. This sets things up and starts a thread to + * do the work. + */ UpdateChecker::UpdateChecker () : _buffer (new char[BUFFER_SIZE]) , _offset (0) @@ -74,6 +78,7 @@ UpdateChecker::~UpdateChecker () delete[] _buffer; } +/** Start running the update check */ void UpdateChecker::run () { @@ -86,6 +91,7 @@ void UpdateChecker::thread () { while (true) { + /* Block until there is something to do */ boost::mutex::scoped_lock lock (_process_mutex); while (_to_do == 0) { _condition.wait (lock); @@ -95,12 +101,16 @@ UpdateChecker::thread () try { _offset = 0; + + /* Perform the request */ int r = curl_easy_perform (_curl); if (r != CURLE_OK) { set_state (FAILED); return; } + + /* Parse the reply */ _buffer[_offset] = '\0'; stringstream s;