Left: | ||
Right: |
OLD | NEW |
---|---|
1 #include <AdblockPlus.h> | 1 #include <AdblockPlus.h> |
2 #include <functional> | 2 #include <functional> |
3 #include <vector> | 3 #include <vector> |
4 #include <Windows.h> | 4 #include <Windows.h> |
5 | 5 |
6 #include "../shared/AutoHandle.h" | 6 #include "../shared/AutoHandle.h" |
7 #include "../shared/Communication.h" | 7 #include "../shared/Communication.h" |
8 #include "../shared/Dictionary.h" | 8 #include "../shared/Dictionary.h" |
9 #include "../shared/Utils.h" | 9 #include "../shared/Utils.h" |
10 #include "../shared/Version.h" | 10 #include "../shared/Version.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 for (int32_t i = 0; i < count; i++) | 33 for (int32_t i = 0; i < count; i++) |
34 { | 34 { |
35 AdblockPlus::SubscriptionPtr subscription = subscriptions[i]; | 35 AdblockPlus::SubscriptionPtr subscription = subscriptions[i]; |
36 response << subscription->GetProperty("url")->AsString() | 36 response << subscription->GetProperty("url")->AsString() |
37 << subscription->GetProperty("title")->AsString() | 37 << subscription->GetProperty("title")->AsString() |
38 << subscription->GetProperty("specialization")->AsString() | 38 << subscription->GetProperty("specialization")->AsString() |
39 << subscription->IsListed(); | 39 << subscription->IsListed(); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 CriticalSection firstRunLock; | 43 bool updateAvailable; |
Felix Dahlke
2013/08/06 10:40:12
I think you should explicitly initialise this to f
Wladimir Palant
2013/08/13 09:19:51
Not sure why but this variable is again not being
| |
44 bool firstRunActionExecuted = false; | |
45 | |
46 void UpdateCallback(const std::string res) | 44 void UpdateCallback(const std::string res) |
47 { | 45 { |
48 //TODO: Display UI here | 46 if (updateAvailable) |
47 return; | |
48 Dictionary* dictionary = Dictionary::GetInstance(); | |
49 if (res.length() == 0) | |
50 { | |
51 std::wstring upToDateText = dictionary->Lookup("updater", "update-already- up-to-date-text"); | |
52 std::wstring upToDateTitle = dictionary->Lookup("updater", "update-already -up-to-date-title"); | |
53 MessageBox(NULL, upToDateText.c_str(), upToDateTitle.c_str(), MB_OK); | |
Felix Dahlke
2013/08/06 10:40:12
How about MB_ICONINFORMATION?
Felix Dahlke
2013/08/09 07:09:27
Will it still have the OK button? What I meant was
Wladimir Palant
2013/08/13 09:19:51
Please use MessageBoxW explicitly, you are using w
| |
54 } | |
55 else | |
56 { | |
57 std::wstring errorText = dictionary->Lookup("updater", "update-error-text" ); | |
58 std::wstring errorTitle = dictionary->Lookup("updater", "update-error-titl e"); | |
59 ReplaceString(errorText, L"?1?", ToUtf16String(res)); | |
60 MessageBox(NULL, errorText.c_str(), errorTitle.c_str(), MB_OK); | |
Felix Dahlke
2013/08/06 10:40:12
How about MB_ICONEXCLAMATION?
Felix Dahlke
2013/08/09 07:09:27
As above, will this still show the OK button?
Wladimir Palant
2013/08/13 09:19:51
Please use MessageBoxW explicitly, you are using w
| |
61 } | |
49 return; | 62 return; |
Felix Dahlke
2013/08/06 10:40:12
That's not really necessary.
| |
50 } | 63 } |
51 | 64 |
65 | |
66 CriticalSection firstRunLock; | |
67 bool firstRunActionExecuted = false; | |
52 Communication::OutputBuffer HandleRequest(Communication::InputBuffer& request) | 68 Communication::OutputBuffer HandleRequest(Communication::InputBuffer& request) |
53 { | 69 { |
54 Communication::OutputBuffer response; | 70 Communication::OutputBuffer response; |
55 | 71 |
56 Communication::ProcType procedure; | 72 Communication::ProcType procedure; |
57 request >> procedure; | 73 request >> procedure; |
58 switch (procedure) | 74 switch (procedure) |
59 { | 75 { |
60 case Communication::PROC_MATCHES: | 76 case Communication::PROC_MATCHES: |
61 { | 77 { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 } | 241 } |
226 else | 242 else |
227 { | 243 { |
228 // Report failure | 244 // Report failure |
229 response << false; | 245 response << false; |
230 } | 246 } |
231 break; | 247 break; |
232 } | 248 } |
233 case Communication::PROC_CHECK_FOR_UPDATES: | 249 case Communication::PROC_CHECK_FOR_UPDATES: |
234 { | 250 { |
251 updateAvailable = false; | |
235 filterEngine->ForceUpdateCheck(UpdateCallback); | 252 filterEngine->ForceUpdateCheck(UpdateCallback); |
236 break; | 253 break; |
237 } | 254 } |
238 case Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED: | 255 case Communication::PROC_IS_FIRST_RUN_ACTION_NEEDED: |
239 { | 256 { |
240 CriticalSection::Lock lock(firstRunLock); | 257 CriticalSection::Lock lock(firstRunLock); |
241 if (!firstRunActionExecuted && filterEngine->IsFirstRun()) | 258 if (!firstRunActionExecuted && filterEngine->IsFirstRun()) |
242 { | 259 { |
243 response << true; | 260 response << true; |
244 firstRunActionExecuted = true; | 261 firstRunActionExecuted = true; |
245 } | 262 } |
246 else | 263 else |
247 { | 264 { |
248 response << false; | 265 response << false; |
249 } | 266 } |
250 break; | 267 break; |
251 } | 268 } |
252 case Communication::PROC_GET_APP_LOCALE: | |
253 { | |
254 response << ToUtf16String(filterEngine->GetAppLocale()); | |
255 break; | |
256 } | |
257 case Communication::PROC_GET_DOCUMENTATION_LINK: | 269 case Communication::PROC_GET_DOCUMENTATION_LINK: |
258 { | 270 { |
259 response << ToUtf16String(filterEngine->GetDocumentationLink()); | 271 response << ToUtf16String(filterEngine->GetPref("documentation_link")->A sString()); |
260 break; | 272 break; |
261 } | 273 } |
262 | 274 |
263 } | 275 } |
264 return response; | 276 return response; |
265 } | 277 } |
266 | 278 |
267 DWORD WINAPI ClientThread(LPVOID param) | 279 DWORD WINAPI ClientThread(LPVOID param) |
268 { | 280 { |
269 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa ram)); | 281 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa ram)); |
270 | 282 |
271 try | 283 try |
272 { | 284 { |
273 Communication::InputBuffer message = pipe->ReadMessage(); | 285 Communication::InputBuffer message = pipe->ReadMessage(); |
274 Communication::OutputBuffer response = HandleRequest(message); | 286 Communication::OutputBuffer response = HandleRequest(message); |
275 pipe->WriteMessage(response); | 287 pipe->WriteMessage(response); |
276 } | 288 } |
277 catch (const std::exception& e) | 289 catch (const std::exception& e) |
278 { | 290 { |
279 DebugException(e); | 291 DebugException(e); |
280 } | 292 } |
281 | 293 |
282 // TODO: Keep the pipe open until the client disconnects | 294 // TODO: Keep the pipe open until the client disconnects |
283 | 295 |
284 return 0; | 296 return 0; |
285 } | 297 } |
286 | 298 |
287 void OnUpdateAvailable(AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValue List& params) | 299 void OnUpdateAvailable(AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValue List& params) |
288 { | 300 { |
301 updateAvailable = true; | |
Felix Dahlke
2013/08/06 10:40:12
What about the error below? Shouldn't we try to do
Oleksandr
2013/08/08 14:19:34
hm.. When would be the next time? On automatic upd
Felix Dahlke
2013/08/08 14:29:54
I got this a bit wrong, it'll check for updates an
Oleksandr
2013/08/08 17:06:12
It is empty in what I've seen and based on updater
Felix Dahlke
2013/08/09 07:09:27
Then we should set updateAvailable to true after w
Oleksandr
2013/08/09 07:14:49
Hm. But it is set to true at one line above.. What
Felix Dahlke
2013/08/09 07:18:41
Um, the idea was to move that line below the error
| |
289 if (params.size() < 1) | 302 if (params.size() < 1) |
290 { | 303 { |
291 Debug("updateAvailable event missing URL"); | 304 Debug("updateAvailable event missing URL"); |
292 return; | 305 return; |
293 } | 306 } |
294 | 307 |
295 Updater updater(jsEngine, params[0]->AsString()); | 308 Updater updater(jsEngine, params[0]->AsString()); |
296 updater.Update(); | 309 updater.Update(); |
297 } | 310 } |
298 } | 311 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 } | 377 } |
365 catch (std::runtime_error e) | 378 catch (std::runtime_error e) |
366 { | 379 { |
367 DebugException(e); | 380 DebugException(e); |
368 return 1; | 381 return 1; |
369 } | 382 } |
370 } | 383 } |
371 | 384 |
372 return 0; | 385 return 0; |
373 } | 386 } |
OLD | NEW |