[epiphany] uri-tester: Update HTTPS Everywhere rulesets every once in a while



commit fe4e310651f1f4b6fd3b3c6e68960133674d74c7
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Mon Oct 24 19:34:15 2016 -0500

    uri-tester: Update HTTPS Everywhere rulesets every once in a while

 configure.ac            |    2 +-
 embed/ephy-uri-tester.c |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fd3acfe..aa424f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,7 +109,7 @@ PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $GLIB_REQUIRED])
 PKG_CHECK_MODULES([GNOME_DESKTOP], [gnome-desktop-3.0 >= 2.91.2])
 PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_REQUIRED])
 PKG_CHECK_MODULES([GTK_UNIX_PRINT], [gtk+-unix-print-3.0 >= $GTK_REQUIRED])
-PKG_CHECK_MODULES([HTTPSEVERYWHERE], [httpseverywhere-0.2 >= 0.2])
+PKG_CHECK_MODULES([HTTPSEVERYWHERE], [httpseverywhere-0.2 >= 0.2.1])
 PKG_CHECK_MODULES([JSON_GLIB], [json-glib-1.0 >= 1.2.0])
 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify >= 0.5.1])
 PKG_CHECK_MODULES([LIBSECRET], [libsecret-1 >= 0.14])
diff --git a/embed/ephy-uri-tester.c b/embed/ephy-uri-tester.c
index b63dd1c..4df4d76 100644
--- a/embed/ephy-uri-tester.c
+++ b/embed/ephy-uri-tester.c
@@ -977,6 +977,41 @@ handle_deferred_request (DeferredRequest *request,
 }
 
 static void
+https_everywhere_update_cb (HTTPSEverywhereUpdater *updater,
+                            GAsyncResult *result)
+{
+  GError *error = NULL;
+
+  https_everywhere_updater_update_finish (updater, result, &error);
+
+  if (error) {
+    if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+      g_warning ("Failed to update HTTPS Everywhere rulesets: %s", error->message);
+    g_error_free (error);
+  }
+
+  g_object_unref (updater);
+}
+
+static void
+ephy_uri_tester_update_https_everywhere_rulesets (EphyUriTester *tester)
+{
+  HTTPSEverywhereUpdater *updater;
+
+  /* We might want to be smarter about this in the future. For now,
+   * trigger an update of the rulesets once each time an EphyUriTester
+   * is created. The new rulesets will get used the next time a new
+   * EphyUriTester is created. Since EphyUriTester is only intended to
+   * be created once, that means the new rulesets will be used the next
+   * time Epiphany is restarted. */
+  updater = https_everywhere_updater_new (tester->https_everywhere_context);
+  https_everywhere_updater_update (updater,
+                                   tester->cancellable,
+                                   (GAsyncReadyCallback)https_everywhere_update_cb,
+                                   NULL);
+}
+
+static void
 https_everywhere_context_init_cb (HTTPSEverywhereContext *context,
                                   GAsyncResult           *res,
                                   EphyUriTester          *tester)
@@ -994,6 +1029,8 @@ https_everywhere_context_init_cb (HTTPSEverywhereContext *context,
 
   g_list_foreach (tester->deferred_requests, (GFunc)handle_deferred_request, tester);
   g_list_free_full (tester->deferred_requests, (GDestroyNotify)deferred_request_free);
+
+  ephy_uri_tester_update_https_everywhere_rulesets (tester);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]