diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-07 15:06:15 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-07 15:06:15 +0000 |
| commit | 4983b57d7ccba4ea0b393cf3a40043c1ed5c6b77 (patch) | |
| tree | 485144028325765093e2268d779ea23eb42eaa38 /src/lib/update.h | |
| parent | 95faa6568854b5f861db07e9b8697169aaceec3c (diff) | |
Basic dialog reporting of manual update checks.
Diffstat (limited to 'src/lib/update.h')
| -rw-r--r-- | src/lib/update.h | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/src/lib/update.h b/src/lib/update.h index 2063dd484..b879e9026 100644 --- a/src/lib/update.h +++ b/src/lib/update.h @@ -17,23 +17,63 @@ */ +#include <boost/signals2.hpp> +#include <boost/thread/mutex.hpp> +#include <curl/curl.h> + class UpdateChecker { public: UpdateChecker (); ~UpdateChecker (); - enum Result { + void run (bool); + + enum State { YES, - MAYBE, - NO + FAILED, + NO, + NOT_RUN }; - Result run (); + State state () { + boost::mutex::scoped_lock lm (_data_mutex); + return _state; + } + + std::string stable () { + boost::mutex::scoped_lock lm (_data_mutex); + return _stable; + } + + /** @return true if this check was run at startup, otherwise false */ + bool startup () const { + boost::mutex::scoped_lock lm (_data_mutex); + return _startup; + } size_t write_callback (void *, size_t, size_t); + boost::signals2::signal<void (void)> StateChanged; + + static UpdateChecker* instance (); + private: + static UpdateChecker* _instance; + + void set_state (State); + char* _buffer; int _offset; + CURL* _curl; + + /** mutex to protect _state, _stable and _startup */ + mutable boost::mutex _data_mutex; + State _state; + std::string _stable; + /** true if this check was run at startup, otherwise false */ + bool _startup; + + /** mutex to ensure that only one query runs at once */ + boost::mutex _single_thread_mutex; }; |
