[epiphany/wip/sync] sync: Set a periodical sync at startup
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/sync] sync: Set a periodical sync at startup
- Date: Thu, 30 Mar 2017 21:42:04 +0000 (UTC)
commit d8d4aa64efd47868296ab3972b182013aab41b0e
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Thu Mar 30 14:05:35 2017 +0300
sync: Set a periodical sync at startup
src/ephy-shell.c | 4 ++++
src/prefs-dialog.c | 1 +
src/sync/ephy-sync-service.c | 24 ++++++++++++++++++++++--
3 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index d580831..8ee786a 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -379,6 +379,10 @@ ephy_shell_startup (GApplication *application)
g_signal_connect (ephy_shell->sync_service,
"sync-tokens-load-finished",
G_CALLBACK (sync_tokens_load_finished_cb), NULL);
+
+ /* Register the bookmarks collection. */
+ ephy_sync_service_register_manager (ephy_shell->sync_service,
+ EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_bookmarks_manager
(ephy_shell)));
#endif
gtk_application_set_app_menu (GTK_APPLICATION (application),
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index f05471f..e2df30a 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -238,6 +238,7 @@ sync_tokens_store_finished_cb (EphySyncService *service,
TRUE);
/* Start syncing. */
+ /* TODO: Register the synchronizable managers before calling this. */
ephy_sync_service_start_periodical_sync (service);
} else {
/* Destroy the current session. */
diff --git a/src/sync/ephy-sync-service.c b/src/sync/ephy-sync-service.c
index fa5c6ba..a614058 100644
--- a/src/sync/ephy-sync-service.c
+++ b/src/sync/ephy-sync-service.c
@@ -1539,6 +1539,22 @@ ephy_sync_service_sync_collection (EphySyncService *self,
g_free (endpoint);
}
+static gboolean
+ephy_sync_service_do_sync (gpointer user_data)
+{
+ EphySyncService *service;
+ GHashTableIter it;
+ gpointer key;
+ gpointer value;
+
+ service = EPHY_SYNC_SERVICE (user_data);
+ g_hash_table_iter_init (&it, service->managers);
+ while (g_hash_table_iter_next (&it, &key, &value))
+ ephy_sync_service_sync_collection (service, EPHY_SYNCHRONIZABLE_MANAGER (value));
+
+ return G_SOURCE_CONTINUE;
+}
+
static void
obtain_sync_key_bundles_cb (SoupSession *session,
SoupMessage *msg,
@@ -1648,7 +1664,11 @@ obtain_sync_key_bundles_cb (SoupSession *session,
}
}
- /* TODO: Successfully retrieved key bundles, do sync. */
+ /* Successfully retrieved key bundles, do sync. */
+ ephy_sync_service_do_sync (service);
+ service->source_id = g_timeout_add_seconds (SYNC_FREQUENCY,
+ ephy_sync_service_do_sync,
+ service);
free_record:
g_free (record);
@@ -1678,7 +1698,7 @@ ephy_sync_service_start_periodical_sync (EphySyncService *self)
g_return_if_fail (EPHY_IS_SYNC_SERVICE (self));
g_return_if_fail (ephy_sync_service_is_signed_in (self));
- /* TODO: Re-implement this. */
+ ephy_sync_service_obtain_sync_key_bundles (self);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]