1 // Aseprite
2 // Copyright (C) 2001-2015  David Capello
3 //
4 // This program is distributed under the terms of
5 // the End-User License Agreement for Aseprite.
6 
7 #ifndef APP_CHECK_UPDATE_H_INCLUDED
8 #define APP_CHECK_UPDATE_H_INCLUDED
9 #pragma once
10 
11 #ifdef ENABLE_UPDATER
12 
13 #include "base/thread.h"
14 #include "base/unique_ptr.h"
15 #include "ui/timer.h"
16 #include "updater/check_update.h"
17 
18 namespace app {
19 
20   class CheckUpdateDelegate;
21   class CheckUpdateBackgroundJob;
22   class Preferences;
23 
24   class CheckUpdateThreadLauncher {
25   public:
26     CheckUpdateThreadLauncher(CheckUpdateDelegate* delegate);
27     ~CheckUpdateThreadLauncher();
28 
29     void launch();
30 
31     bool isReceived() const;
32 
getResponse()33     const updater::CheckUpdateResponse& getResponse() const
34     {
35       return m_response;
36     }
37 
38   private:
39     void onMonitoringTick();
40     void checkForUpdates();
41     void showUI();
42 
43     CheckUpdateDelegate* m_delegate;
44     Preferences& m_preferences;
45     updater::Uuid m_uuid;
46     base::UniquePtr<base::thread> m_thread;
47     base::UniquePtr<CheckUpdateBackgroundJob> m_bgJob;
48     bool m_doCheck;
49     bool m_received;
50 
51     // Mini-stats
52     int m_inits;
53     int m_exits;
54 
55     // True if this is a developer
56     bool m_isDeveloper;
57 
58     updater::CheckUpdateResponse m_response;
59     ui::Timer m_timer;
60   };
61 
62 } // namespace app
63 
64 #endif // ENABLE_UPDATER
65 
66 #endif // APP_CHECK_UPDATE_H_INCLUDED
67