MCPcopy Create free account
hub / github.com/BlueMatthew/WechatExporter / CUpdateHandler

Class CUpdateHandler

vcproject/View.h:116–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114 };
115
116 class CUpdateHandler : public CIdleHandler
117 {
118 protected:
119 HWND m_hWnd;
120 std::future<bool> m_task;
121 Updater m_updater;
122 public:
123
124 CUpdateHandler(HWND hWnd, const std::string& currentVersion, const std::string& userAgent) : m_hWnd(hWnd), m_updater(currentVersion)
125 {
126 m_updater.setUserAgent(userAgent);
127 }
128
129 ~CUpdateHandler()
130 {
131 }
132
133 void startTask()
134 {
135 m_task = std::async(std::launch::async, &Updater::checkUpdate, &m_updater);
136 }
137
138 virtual BOOL OnIdle()
139 {
140 std::future_status status = m_task.wait_for(std::chrono::seconds(0));
141 if (status == std::future_status::ready)
142 {
143 ::PostMessage(m_hWnd, WM_CHKUPDATE, 1, reinterpret_cast<LPARAM>(this));
144 return FALSE;
145 }
146
147 return TRUE;
148 }
149
150 bool hasNewVersion()
151 {
152 return m_task.get();
153 }
154
155 CString getNewVersion() const
156 {
157 CW2T pszT(CA2W(m_updater.getNewVersion().c_str(), CP_UTF8));
158 return CString(pszT);
159 }
160
161 CString getUpdateUrl() const
162 {
163 CW2T pszT(CA2W(m_updater.getUpdateUrl().c_str(), CP_UTF8));
164 return CString(pszT);
165 }
166
167 };
168
169public:
170 enum { IDD = IDD_WECHATEXPORTER_FORM };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected