No-op: remove all trailing whitespace.
[dcpomatic.git] / src / lib / update.h
index c19173911e52fbd302794e01a933f22fc6c53f16..b82be7808f7fa0c957a98c02a7ad69a3685e8b5d 100644 (file)
 
 */
 
+/** @file  src/lib/update.h
+ *  @brief UpdateChecker class.
+ */
+
+#include "signaller.h"
+#include <curl/curl.h>
 #include <boost/signals2.hpp>
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/condition.hpp>
-#include <curl/curl.h>
+#include <boost/thread.hpp>
+
+struct update_checker_test;
 
-class UpdateChecker
+/** Class to check for the existance of an update for DCP-o-matic on a remote server */
+class UpdateChecker : public Signaller, public boost::noncopyable
 {
 public:
        UpdateChecker ();
@@ -31,28 +40,31 @@ public:
        void run ();
 
        enum State {
-               YES,
-               FAILED,
-               NO,
-               NOT_RUN
+               YES,    ///< there is an update
+               FAILED, ///< the check failed, so we don't know
+               NO,     ///< there is no update
+               NOT_RUN ///< the check has not been run (yet)
        };
 
+       /** @return state of the checker */
        State state () {
                boost::mutex::scoped_lock lm (_data_mutex);
                return _state;
        }
-       
-       std::string stable () {
+
+       /** @return new stable version, if there is one */
+       boost::optional<std::string> stable () {
                boost::mutex::scoped_lock lm (_data_mutex);
                return _stable;
        }
 
-       std::string test () {
+       /** @return new test version, if there is one and Config is set to look for it */
+       boost::optional<std::string> test () {
                boost::mutex::scoped_lock lm (_data_mutex);
                return _test;
        }
-       
-       /** @return true if the list signal emission was the first */
+
+       /** @return true if the last signal emission was the first */
        bool last_emit_was_first () const {
                boost::mutex::scoped_lock lm (_data_mutex);
                return _emits == 1;
@@ -64,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 ();
 
@@ -77,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<std::string> _stable;
+       boost::optional<std::string> _test;
        int _emits;
 
        boost::thread* _thread;