[epiphany/wip/sync: 2/3] sync: Add stub implementation of EphySyncPasswordsManager
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/sync: 2/3] sync: Add stub implementation of EphySyncPasswordsManager
- Date: Thu, 20 Apr 2017 21:23:19 +0000 (UTC)
commit 9c8938489a27a9f0a8f792622157226d350a51af
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Thu Apr 20 17:46:08 2017 +0300
sync: Add stub implementation of EphySyncPasswordsManager
data/org.gnome.epiphany.gschema.xml | 15 +++
lib/ephy-prefs.h | 3 +
src/Makefile.am | 2 +
src/sync/ephy-sync-passwords-manager.c | 147 ++++++++++++++++++++++++++++++++
src/sync/ephy-sync-passwords-manager.h | 33 +++++++
5 files changed, 200 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index 2264bbd..681827c 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -302,6 +302,21 @@
<summary>Initial sync or normal sync</summary>
<description>TRUE if bookmarks collection needs to be synced for the first time,
FALSE otherwise.</description>
</key>
+ <key type="b" name="sync-passwords-enabled">
+ <default>false</default>
+ <summary>Enable passwords sync</summary>
+ <description>TRUE if passwords collection should be synced, FALSE
otherwise.</description>
+ </key>
+ <key type="d" name="sync-passwords-time">
+ <default>0</default>
+ <summary>passwords sync timestamp</summary>
+ <description>The timestamp at which last passwords sync was made.</description>
+ </key>
+ <key type="b" name="sync-passwords-initial">
+ <default>true</default>
+ <summary>Initial sync or normal sync</summary>
+ <description>TRUE if passwords collection needs to be synced for the first time,
FALSE otherwise.</description>
+ </key>
</schema>
<enum id="org.gnome.Epiphany.Permission">
<value nick="undecided" value="-1"/>
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 3167d12..d91fdf2 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -157,6 +157,9 @@ static const char * const ephy_prefs_web_schema[] = {
#define EPHY_PREFS_SYNC_BOOKMARKS_ENABLED "sync-bookmarks-enabled"
#define EPHY_PREFS_SYNC_BOOKMARKS_TIME "sync-bookmarks-time"
#define EPHY_PREFS_SYNC_BOOKMARKS_INITIAL "sync-bookmarks-initial"
+#define EPHY_PREFS_SYNC_PASSWORDS_ENABLED "sync-passwords-enabled"
+#define EPHY_PREFS_SYNC_PASSWORDS_TIME "sync-passwords-time"
+#define EPHY_PREFS_SYNC_PASSWORDS_INITIAL "sync-passwords-initial"
static struct {
const char *schema;
diff --git a/src/Makefile.am b/src/Makefile.am
index bfb12aa..61f6e93 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -75,6 +75,8 @@ libephymain_la_SOURCES = \
window-commands.h \
sync/ephy-sync-crypto.c \
sync/ephy-sync-crypto.h \
+ sync/ephy-sync-passwords-manager.c \
+ sync/ephy-sync-passwords-manager.h \
sync/ephy-sync-passwords-record.c \
sync/ephy-sync-passwords-record.h \
sync/ephy-sync-secret.c \
diff --git a/src/sync/ephy-sync-passwords-manager.c b/src/sync/ephy-sync-passwords-manager.c
new file mode 100644
index 0000000..2ecfff1
--- /dev/null
+++ b/src/sync/ephy-sync-passwords-manager.c
@@ -0,0 +1,147 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2017 Gabriel Ivascu <ivascu gabriel59 gmail com>
+ *
+ * This file is part of Epiphany.
+ *
+ * Epiphany is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Epiphany is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Epiphany. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "ephy-sync-passwords-manager.h"
+
+#include "ephy-settings.h"
+#include "ephy-sync-passwords-record.h"
+#include "ephy-synchronizable-manager.h"
+
+struct _EphySyncPasswordsManager {
+ GObject parent_instance;
+};
+
+static void ephy_synchronizable_manager_iface_init (EphySynchronizableManagerInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (EphySyncPasswordsManager, ephy_sync_passwords_manager, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (EPHY_TYPE_SYNCHRONIZABLE_MANAGER,
+ ephy_synchronizable_manager_iface_init))
+
+static const char *
+synchronizable_manager_get_collection_name (EphySynchronizableManager *manager)
+{
+ gboolean sync_with_firefox = g_settings_get_boolean (EPHY_SETTINGS_SYNC,
+ EPHY_PREFS_SYNC_WITH_FIREFOX);
+
+ return sync_with_firefox ? "passwords" : "ephy-passwords";
+}
+
+static GType
+synchronizable_manager_get_synchronizable_type (EphySynchronizableManager *manager)
+{
+ return EPHY_TYPE_SYNC_PASSWORDS_RECORD;
+}
+
+static gboolean
+synchronizable_manager_is_initial_sync (EphySynchronizableManager *manager)
+{
+ return g_settings_get_boolean (EPHY_SETTINGS_SYNC,
+ EPHY_PREFS_SYNC_PASSWORDS_INITIAL);
+}
+
+static void
+synchronizable_manager_set_is_initial_sync (EphySynchronizableManager *manager,
+ gboolean is_initial)
+{
+ g_settings_set_boolean (EPHY_SETTINGS_SYNC,
+ EPHY_PREFS_SYNC_PASSWORDS_INITIAL,
+ is_initial);
+}
+
+static double
+synchronizable_manager_get_sync_time (EphySynchronizableManager *manager)
+{
+ return g_settings_get_double (EPHY_SETTINGS_SYNC,
+ EPHY_PREFS_SYNC_PASSWORDS_TIME);
+}
+
+static void
+synchronizable_manager_set_sync_time (EphySynchronizableManager *manager,
+ double sync_time)
+{
+ g_settings_set_double (EPHY_SETTINGS_SYNC,
+ EPHY_PREFS_SYNC_PASSWORDS_TIME,
+ sync_time);
+}
+
+static void
+synchronizable_manager_add (EphySynchronizableManager *manager,
+ EphySynchronizable *synchronizable)
+{
+ /* TODO: Implement this. */
+}
+
+static void
+synchronizable_manager_remove (EphySynchronizableManager *manager,
+ EphySynchronizable *synchronizable)
+{
+ /* TODO: Implement this. */
+}
+
+static GList *
+synchronizable_manager_merge_remotes (EphySynchronizableManager *manager,
+ gboolean is_initial,
+ GList *remotes_deleted,
+ GList *remotes_updated)
+{
+ /* TODO: Implement this. */
+ return NULL;
+}
+
+static void
+ephy_synchronizable_manager_iface_init (EphySynchronizableManagerInterface *iface)
+{
+ iface->get_collection_name = synchronizable_manager_get_collection_name;
+ iface->get_synchronizable_type = synchronizable_manager_get_synchronizable_type;
+ iface->is_initial_sync = synchronizable_manager_is_initial_sync;
+ iface->set_is_initial_sync = synchronizable_manager_set_is_initial_sync;
+ iface->get_sync_time = synchronizable_manager_get_sync_time;
+ iface->set_sync_time = synchronizable_manager_set_sync_time;
+ iface->add = synchronizable_manager_add;
+ iface->remove = synchronizable_manager_remove;
+ iface->merge_remotes = synchronizable_manager_merge_remotes;
+}
+
+static void
+ephy_sync_passwords_manager_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (ephy_sync_passwords_manager_parent_class)->finalize (object);
+}
+
+static void
+ephy_sync_passwords_manager_class_init (EphySyncPasswordsManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ephy_sync_passwords_manager_finalize;
+}
+
+static void
+ephy_sync_passwords_manager_init (EphySyncPasswordsManager *self)
+{
+}
+
+EphySyncPasswordsManager *
+ephy_sync_passwords_manager_new (void)
+{
+ return EPHY_SYNC_PASSWORDS_MANAGER (g_object_new (EPHY_TYPE_SYNC_PASSWORDS_MANAGER,
+ NULL));
+}
diff --git a/src/sync/ephy-sync-passwords-manager.h b/src/sync/ephy-sync-passwords-manager.h
new file mode 100644
index 0000000..5a25d87
--- /dev/null
+++ b/src/sync/ephy-sync-passwords-manager.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2017 Gabriel Ivascu <ivascu gabriel59 gmail com>
+ *
+ * This file is part of Epiphany.
+ *
+ * Epiphany is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Epiphany is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Epiphany. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_SYNC_PASSWORDS_MANAGER (ephy_sync_passwords_manager_get_type ())
+
+G_DECLARE_FINAL_TYPE (EphySyncPasswordsManager, ephy_sync_passwords_manager, EPHY, SYNC_PASSWORDS_MANAGER,
GObject)
+
+EphySyncPasswordsManager *ephy_sync_passwords_manager_new (void);
+
+G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]