| 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" |
| 11 #include "../shared/CriticalSection.h" | 11 #include "../shared/CriticalSection.h" |
| 12 #include "Debug.h" | 12 #include "Debug.h" |
| 13 #include "Updater.h" | 13 #include "Updater.h" |
| 14 | 14 |
| 15 | 15 |
| 16 | |
| 17 namespace | 16 namespace |
| 18 { | 17 { |
| 19 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; | 18 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; |
| 20 std::auto_ptr<Updater> updater; | 19 std::auto_ptr<Updater> updater; |
| 21 int activeConnections = 0; | 20 int activeConnections = 0; |
| 22 CriticalSection activeConnectionsLock; | 21 CriticalSection activeConnectionsLock; |
| 23 HWND callbackWindow; | 22 HWND callbackWindow; |
| 24 | 23 |
| 25 void WriteStrings(Communication::OutputBuffer& response, | 24 void WriteStrings(Communication::OutputBuffer& response, |
| 26 const std::vector<std::string>& strings) | 25 const std::vector<std::string>& strings) |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 #endif | 376 #endif |
| 378 | 377 |
| 379 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); | 378 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); |
| 380 jsEngine->SetEventCallback("updateAvailable", &OnUpdateAvailable); | 379 jsEngine->SetEventCallback("updateAvailable", &OnUpdateAvailable); |
| 381 | 380 |
| 382 std::string dataPath = ToUtf8String(GetAppDataPath()); | 381 std::string dataPath = ToUtf8String(GetAppDataPath()); |
| 383 dynamic_cast<AdblockPlus::DefaultFileSystem*>(jsEngine->GetFileSystem().get()) ->SetBasePath(dataPath); | 382 dynamic_cast<AdblockPlus::DefaultFileSystem*>(jsEngine->GetFileSystem().get()) ->SetBasePath(dataPath); |
| 384 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine(new AdblockPlus::FilterE ngine(jsEngine)); | 383 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine(new AdblockPlus::FilterE ngine(jsEngine)); |
| 385 return filterEngine; | 384 return filterEngine; |
| 386 } | 385 } |
| 387 | 386 |
|
Felix Dahlke
2013/09/16 16:30:12
Why this extra whitespace?
| |
| 387 | |
| 388 | |
| 388 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) | 389 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) |
| 389 { | 390 { |
| 390 AutoHandle mutex(CreateMutexW(0, false, L"AdblockPlusEngine")); | 391 AutoHandle mutex(CreateMutexW(0, false, L"AdblockPlusEngine")); |
| 391 if (!mutex) | 392 if (!mutex) |
| 392 { | 393 { |
| 393 DebugLastError("CreateMutex failed"); | 394 DebugLastError("CreateMutex failed"); |
| 394 return 1; | 395 return 1; |
| 395 } | 396 } |
| 396 | 397 |
| 397 if (GetLastError() == ERROR_ALREADY_EXISTS) | 398 if (GetLastError() == ERROR_ALREADY_EXISTS) |
| 398 { | 399 { |
| 399 DebugLastError("Named pipe exists, another engine instance appears to be run ning"); | 400 DebugLastError("Named pipe exists, another engine instance appears to be run ning"); |
| 400 return 1; | 401 return 1; |
| 401 } | 402 } |
| 402 | 403 |
| 403 int argc; | 404 int argc; |
| 404 LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); | 405 LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); |
| 405 std::wstring locale(argc >= 2 ? argv[1] : L""); | 406 std::wstring locale(argc >= 2 ? argv[1] : L""); |
| 407 Communication::browserSID = argv[2]; | |
|
Wladimir Palant
2013/09/16 13:45:07
This will cause a crash if too few parameters are
Felix Dahlke
2013/09/16 16:30:12
What if argc is <3?
Oleksandr
2013/09/17 03:11:37
<3. Teehee :)
| |
| 406 LocalFree(argv); | 408 LocalFree(argv); |
| 407 Dictionary::Create(locale); | 409 Dictionary::Create(locale); |
| 408 filterEngine = CreateFilterEngine(locale); | 410 filterEngine = CreateFilterEngine(locale); |
| 409 updater.reset(new Updater(filterEngine->GetJsEngine())); | 411 updater.reset(new Updater(filterEngine->GetJsEngine())); |
| 410 | 412 |
| 411 for (;;) | 413 for (;;) |
| 412 { | 414 { |
| 413 try | 415 try |
| 414 { | 416 { |
| 415 Communication::Pipe* pipe = new Communication::Pipe(Communication::pipeNam e, | 417 Communication::Pipe* pipe = new Communication::Pipe(Communication::pipeNam e, |
| 416 Communication::Pipe::MODE_CREATE); | 418 Communication::Pipe::MODE_CREATE); |
| 417 | 419 |
| 418 AutoHandle thread(CreateThread(0, 0, ClientThread, static_cast<LPVOID>(pip e), 0, 0)); | 420 AutoHandle thread(CreateThread(0, 0, ClientThread, static_cast<LPVOID>(pip e), 0, 0)); |
| 419 if (!thread) | 421 if (!thread) |
| 420 { | 422 { |
| 421 delete pipe; | 423 delete pipe; |
| 422 DebugLastError("CreateThread failed"); | 424 DebugLastError("CreateThread failed"); |
| 423 return 1; | 425 return 1; |
| 424 } | 426 } |
| 425 } | 427 } |
| 426 catch (std::runtime_error e) | 428 catch (std::runtime_error e) |
| 427 { | 429 { |
| 428 DebugException(e); | 430 DebugException(e); |
| 429 return 1; | 431 return 1; |
| 430 } | 432 } |
| 431 } | 433 } |
| 432 | 434 |
| 433 return 0; | 435 return 0; |
| 434 } | 436 } |
| OLD | NEW |