Index: src/FilterEngine.cpp |
=================================================================== |
--- a/src/FilterEngine.cpp |
+++ b/src/FilterEngine.cpp |
@@ -129,31 +129,38 @@ bool Subscription::IsUpdating() |
} |
bool Subscription::operator==(const Subscription& subscription) const |
{ |
return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsString(); |
} |
FilterEngine::FilterEngine(JsEnginePtr jsEngine) |
- : jsEngine(jsEngine), initialized(false) |
+ : jsEngine(jsEngine), initialized(false), firstRun(false) |
{ |
- jsEngine->SetEventCallback("init", std::tr1::bind(&FilterEngine::InitDone, this)); |
+ jsEngine->SetEventCallback("init", std::tr1::bind(&FilterEngine::InitDone, |
+ this, std::tr1::placeholders::_1)); |
for (int i = 0; !jsSources[i].empty(); i += 2) |
jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); |
// TODO: This should really be implemented via a conditional variable |
while (!initialized) |
::Sleep(10); |
} |
-void FilterEngine::InitDone() |
+void FilterEngine::InitDone(JsValueList& params) |
{ |
jsEngine->RemoveEventCallback("init"); |
initialized = true; |
+ firstRun = params.size() && params[0]->AsBool(); |
+} |
+ |
+bool FilterEngine::IsFirstRun() const |
+{ |
+ return firstRun; |
} |
FilterPtr FilterEngine::GetFilter(const std::string& text) |
{ |
JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText"); |
JsValueList params; |
params.push_back(jsEngine->NewValue(text)); |
return FilterPtr(new Filter(func->Call(params))); |