X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fupdate.h;h=b82be7808f7fa0c957a98c02a7ad69a3685e8b5d;hb=e60bb3e51bd1508b149e6b8f6608f09b5196ae26;hp=c86adb8736adad074625f8b7a73dd47ae1eb666e;hpb=40b654453c2ce0b266f43c36f1b9a5d1705f983c;p=dcpomatic.git diff --git a/src/lib/update.h b/src/lib/update.h index c86adb873..b82be7808 100644 --- a/src/lib/update.h +++ b/src/lib/update.h @@ -21,14 +21,17 @@ * @brief UpdateChecker class. */ +#include "signaller.h" +#include #include #include #include #include -#include + +struct update_checker_test; /** Class to check for the existance of an update for DCP-o-matic on a remote server */ -class UpdateChecker +class UpdateChecker : public Signaller, public boost::noncopyable { public: UpdateChecker (); @@ -48,19 +51,19 @@ public: boost::mutex::scoped_lock lm (_data_mutex); return _state; } - - /** @return the version string of the latest stable version (if _state == YES or NO) */ - std::string stable () { + + /** @return new stable version, if there is one */ + boost::optional stable () { boost::mutex::scoped_lock lm (_data_mutex); return _stable; } - /** @return the version string of the latest test version (if _state == YES or NO) */ - std::string test () { + /** @return new test version, if there is one and Config is set to look for it */ + boost::optional test () { boost::mutex::scoped_lock lm (_data_mutex); return _test; } - + /** @return true if the last signal emission was the first */ bool last_emit_was_first () const { boost::mutex::scoped_lock lm (_data_mutex); @@ -73,9 +76,13 @@ public: static UpdateChecker* instance (); -private: +private: + friend struct update_checker_test; + static UpdateChecker* _instance; + static bool version_less_than (std::string const & a, std::string const & b); + void set_state (State); void thread (); @@ -86,8 +93,8 @@ private: /** mutex to protect _state, _stable, _test and _emits */ mutable boost::mutex _data_mutex; State _state; - std::string _stable; - std::string _test; + boost::optional _stable; + boost::optional _test; int _emits; boost::thread* _thread;