[epiphany/wip/sync: 51/52] sync: Make sure sync starts after all the managers are registered
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/sync: 51/52] sync: Make sure sync starts after all the managers are registered
- Date: Wed, 5 Jul 2017 13:37:18 +0000 (UTC)
commit a1ecb91bcbd25f34b971193d1ba13f8dc4c7587c
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Wed Jul 5 15:33:22 2017 +0300
sync: Make sure sync starts after all the managers are registered
lib/sync/ephy-sync-service.c | 11 ++++++-
src/ephy-shell.c | 58 +++++++++++++++++++++++++++--------------
2 files changed, 47 insertions(+), 22 deletions(-)
---
diff --git a/lib/sync/ephy-sync-service.c b/lib/sync/ephy-sync-service.c
index 0ff4cc4..e04892e 100644
--- a/lib/sync/ephy-sync-service.c
+++ b/lib/sync/ephy-sync-service.c
@@ -86,6 +86,7 @@ static GParamSpec *obj_properties[LAST_PROP];
enum {
STORE_FINISHED,
+ LOAD_FINISHED,
SIGN_IN_ERROR,
SYNC_FINISHED,
LAST_SIGNAL
@@ -1469,8 +1470,7 @@ load_secrets_cb (SecretService *service,
ephy_sync_service_set_secret (self, l->data,
json_object_get_string_member (object, l->data));
- if (self->sync_periodically)
- ephy_sync_service_start_sync (self);
+ g_signal_emit (self, signals[LOAD_FINISHED], 0);
goto out_no_error;
out_error:
@@ -1653,6 +1653,13 @@ ephy_sync_service_class_init (EphySyncServiceClass *klass)
G_TYPE_NONE, 1,
G_TYPE_ERROR);
+ signals[LOAD_FINISHED] =
+ g_signal_new ("sync-secrets-load-finished",
+ EPHY_TYPE_SYNC_SERVICE,
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
signals[SIGN_IN_ERROR] =
g_signal_new ("sync-sign-in-error",
EPHY_TYPE_SYNC_SERVICE,
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index e6e26eb..979683f 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -312,12 +312,44 @@ download_started_cb (WebKitWebContext *web_context,
}
static void
+sync_secrets_load_finished_cb (EphySyncService *service,
+ EphyShell *shell)
+{
+ EphySynchronizableManager *manager;
+
+ g_assert (EPHY_IS_SYNC_SERVICE (service));
+ g_assert (EPHY_IS_SHELL (shell));
+
+ if (ephy_sync_utils_bookmarks_sync_is_enabled ()) {
+ manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_bookmarks_manager (shell));
+ ephy_sync_service_register_manager (service, manager);
+ }
+
+ if (ephy_sync_utils_passwords_sync_is_enabled ()) {
+ manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_password_manager (shell));
+ ephy_sync_service_register_manager (service, manager);
+ }
+
+ if (ephy_sync_utils_history_sync_is_enabled ()) {
+ manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_history_manager (shell));
+ ephy_sync_service_register_manager (service, manager);
+ }
+
+ if (ephy_sync_utils_open_tabs_sync_is_enabled ()) {
+ manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_open_tabs_manager (shell));
+ ephy_sync_service_register_manager (service, manager);
+ }
+
+ ephy_sync_service_start_sync (service);
+}
+
+static void
ephy_shell_startup (GApplication *application)
{
EphyEmbedShell *embed_shell = EPHY_EMBED_SHELL (application);
EphyShell *shell = EPHY_SHELL (application);
- EphySynchronizableManager *manager;
EphyEmbedShellMode mode;
+ EphySyncService *service;
GtkBuilder *builder;
G_APPLICATION_CLASS (ephy_shell_parent_class)->startup (application);
@@ -350,25 +382,11 @@ ephy_shell_startup (GApplication *application)
"enabled",
G_BINDING_SYNC_CREATE);
- /* Register the synchronizable managers. */
- if (ephy_sync_utils_bookmarks_sync_is_enabled ()) {
- manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_bookmarks_manager (shell));
- ephy_sync_service_register_manager (ephy_shell_get_sync_service (shell), manager);
- }
-
- if (ephy_sync_utils_passwords_sync_is_enabled ()) {
- manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_password_manager (shell));
- ephy_sync_service_register_manager (ephy_shell_get_sync_service (shell), manager);
- }
-
- if (ephy_sync_utils_history_sync_is_enabled ()) {
- manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_history_manager (shell));
- ephy_sync_service_register_manager (ephy_shell_get_sync_service (shell), manager);
- }
-
- if (ephy_sync_utils_open_tabs_sync_is_enabled ()) {
- manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_open_tabs_manager (shell));
- ephy_sync_service_register_manager (ephy_shell_get_sync_service (shell), manager);
+ if (ephy_sync_utils_user_is_signed_in ()) {
+ service = ephy_shell_get_sync_service (shell);
+ g_signal_connect_object (service, "sync-secrets-load-finished",
+ G_CALLBACK (sync_secrets_load_finished_cb),
+ shell, 0);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]