Index: src/engine/main.cpp |
=================================================================== |
--- a/src/engine/main.cpp |
+++ b/src/engine/main.cpp |
@@ -1,12 +1,13 @@ |
#include "stdafx.h" |
#include "../shared/AutoHandle.h" |
#include "../shared/Communication.h" |
+#include "../shared/Version.h" |
#include "Debug.h" |
#include "Utils.h" |
namespace |
{ |
std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; |
std::string ToUtf8String(std::wstring str) |
@@ -157,36 +158,46 @@ namespace |
} |
// TODO: Keep the pipe open until the client disconnects |
return 0; |
} |
} |
-std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine() |
+std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine(const std::wstring& locale) |
{ |
- // TODO: Pass appInfo in, which should be sent by the client |
- AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(); |
+ AdblockPlus::AppInfo appInfo; |
+ appInfo.version = ToUtf8String(IEPLUGIN_VERSION); |
+ appInfo.name = "adblockplusie"; |
+ appInfo.platform = "msie"; |
+ appInfo.locale = ToUtf8String(locale); |
+ |
+ AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); |
std::string dataPath = ToUtf8String(GetAppDataPath()); |
dynamic_cast<AdblockPlus::DefaultFileSystem*>(jsEngine->GetFileSystem().get())->SetBasePath(dataPath); |
std::auto_ptr<AdblockPlus::FilterEngine> filterEngine(new AdblockPlus::FilterEngine(jsEngine)); |
return filterEngine; |
} |
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) |
{ |
// TODO: Attempt to create the pipe first, and exit immediately if this |
// fails. Since multiple instances of the engine could be running, |
// this may need named mutices to avoid race conditions. |
// Note that as soon as the pipe is created first, we can reduce the |
// client timeout after CreateProcess(), but should increase the one |
// in WaitNamedPipe(). |
- filterEngine = CreateFilterEngine(); |
+ int argc; |
+ LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); |
+ std::wstring locale(argc >= 1 ? argv[0] : L""); |
+ LocalFree(argv); |
+ |
+ filterEngine = CreateFilterEngine(locale); |
for (;;) |
{ |
try |
{ |
Communication::Pipe* pipe = new Communication::Pipe(Communication::pipeName, |
Communication::Pipe::MODE_CREATE); |