 Issue 5653480979038208:
  Issue 2325 - Add a way to set settings in libadblockplus for FRP and automatic updates  (Closed)
    
  
    Issue 5653480979038208:
  Issue 2325 - Add a way to set settings in libadblockplus for FRP and automatic updates  (Closed) 
  | Index: src/FilterEngine.cpp | 
| =================================================================== | 
| --- a/src/FilterEngine.cpp | 
| +++ b/src/FilterEngine.cpp | 
| @@ -134,7 +134,7 @@ | 
| return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsString(); | 
| } | 
| -FilterEngine::FilterEngine(JsEnginePtr jsEngine) | 
| +FilterEngine::FilterEngine(JsEnginePtr jsEngine, std::map<std::string, std::string> preconfiguredPrefs) | 
| : jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0) | 
| { | 
| jsEngine->SetEventCallback("init", std::tr1::bind(&FilterEngine::InitDone, | 
| @@ -144,6 +144,14 @@ | 
| // Lock the JS engine while we are loading scripts, no timeouts should fire | 
| // until we are done. | 
| const JsContext context(jsEngine); | 
| + | 
| + // Set the precongiured prefs | 
| + jsEngine->Evaluate(std::string("var Preconfig = {};")); | 
| 
Felix Dahlke
2015/06/09 19:40:51
1. _preconfiguredPrefs would be a better name. We
 
Oleksandr
2015/06/10 08:40:30
I agree it was hacky, but it had it's advantages.
 | 
| + for (auto it = preconfiguredPrefs.begin(); it != preconfiguredPrefs.end(); it++) | 
| 
Felix Dahlke
2015/06/09 19:40:51
It's still C++03 here.
 | 
| + { | 
| + jsEngine->Evaluate(std::string("Preconfig.") + it->first + std::string(" = ") + it->second); | 
| + } | 
| + | 
| for (int i = 0; !jsSources[i].empty(); i += 2) | 
| jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); | 
| } |