@@ -187,7 +187,6 @@ namespace AdblockPlus
187187 * It handles:
188188 * - Filter management and matching.
189189 * - Subscription management and synchronization.
190- * - Update checks for the application.
191190 */
192191 class FilterEngine
193192 {
@@ -225,18 +224,6 @@ namespace AdblockPlus
225224 */
226225 typedef int32_t ContentTypeMask;
227226
228- /* *
229- * Callback type invoked when an update becomes available.
230- * The parameter is the download URL of the update.
231- */
232- typedef std::function<void (const std::string&)> UpdateAvailableCallback;
233-
234- /* *
235- * Callback type invoked when a manually triggered update check finishes.
236- * The parameter is an optional error message.
237- */
238- typedef std::function<void (const std::string&)> UpdateCheckDoneCallback;
239-
240227 /* *
241228 * Callback type invoked when the filters change.
242229 * The first parameter is the action event code (see
@@ -296,6 +283,7 @@ namespace AdblockPlus
296283 * @param parameters optional creation parameters.
297284 */
298285 static void CreateAsync (const JsEnginePtr& jsEngine,
286+ const JsEngine::EvaluateCallback& evaluateCallback,
299287 const OnCreatedCallback& onCreated,
300288 const CreationParameters& parameters = CreationParameters());
301289
@@ -476,32 +464,6 @@ namespace AdblockPlus
476464 */
477465 std::string GetHostFromURL (const std::string& url) const ;
478466
479- /* *
480- * Sets the callback invoked when an application update becomes available.
481- * @param callback Callback to invoke.
482- */
483- void SetUpdateAvailableCallback (const UpdateAvailableCallback& callback);
484-
485- /* *
486- * Removes the callback invoked when an application update becomes
487- * available.
488- */
489- void RemoveUpdateAvailableCallback ();
490-
491- /* *
492- * Forces an immediate update check.
493- * `FilterEngine` will automatically check for updates in regular intervals,
494- * so applications should only call this when the user triggers an update
495- * check manually.
496- * @param callback Optional callback to invoke when the update check is
497- * finished. The string parameter will be empty when the update check
498- * succeeded, or contain an error message if it failed.
499- * Note that the callback will be invoked whether updates are
500- * available or not - to react to updates being available, use
501- * `FilterEngine::SetUpdateAvailableCallback()`.
502- */
503- void ForceUpdateCheck (const UpdateCheckDoneCallback& callback = UpdateCheckDoneCallback());
504-
505467 /* *
506468 * Sets the callback invoked when the filters change.
507469 * @param callback Callback to invoke.
@@ -558,7 +520,6 @@ namespace AdblockPlus
558520 private:
559521 JsEnginePtr jsEngine;
560522 bool firstRun;
561- int updateCheckId;
562523 static const std::map<ContentType, std::string> contentTypes;
563524
564525 explicit FilterEngine (const JsEnginePtr& jsEngine);
@@ -573,6 +534,57 @@ namespace AdblockPlus
573534 ContentTypeMask contentTypeMask,
574535 const std::vector<std::string>& documentUrls) const ;
575536 };
537+
538+ /* *
539+ * Component of libadblockplus responsible for Update checks for the application.
540+ */
541+ class Updater
542+ {
543+ public:
544+ explicit Updater (const JsEnginePtr& jsEngine, const JsEngine::EvaluateCallback& callback);
545+
546+ /* *
547+ * Callback type invoked when an update becomes available.
548+ * The parameter is the download URL of the update.
549+ */
550+ typedef std::function<void (const std::string&)> UpdateAvailableCallback;
551+
552+ /* *
553+ * Callback type invoked when a manually triggered update check finishes.
554+ * The parameter is an optional error message.
555+ */
556+ typedef std::function<void (const std::string&)> UpdateCheckDoneCallback;
557+
558+ /* *
559+ * Sets the callback invoked when an application update becomes available.
560+ * @param callback Callback to invoke.
561+ */
562+ void SetUpdateAvailableCallback (const UpdateAvailableCallback& callback);
563+
564+ /* *
565+ * Removes the callback invoked when an application update becomes
566+ * available.
567+ */
568+ void RemoveUpdateAvailableCallback ();
569+
570+ /* *
571+ * Forces an immediate update check.
572+ * `Updater` will automatically check for updates in regular intervals,
573+ * so applications should only call this when the user triggers an update
574+ * check manually.
575+ * @param callback Optional callback to invoke when the update check is
576+ * finished. The string parameter will be empty when the update check
577+ * succeeded, or contain an error message if it failed.
578+ * Note that the callback will be invoked whether updates are
579+ * available or not - to react to updates being available, use
580+ * `Updater::SetUpdateAvailableCallback()`.
581+ */
582+ void ForceUpdateCheck (const UpdateCheckDoneCallback& callback = UpdateCheckDoneCallback());
583+
584+ private:
585+ JsEnginePtr jsEngine;
586+ int updateCheckId;
587+ };
576588}
577589
578590#endif
0 commit comments