[epiphany/wip/sync: 79/86] sync: Add EphySynchronizableManager interface
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/sync: 79/86] sync: Add EphySynchronizableManager interface
- Date: Tue, 28 Mar 2017 21:00:33 +0000 (UTC)
commit d493994c66310a22976055699da5f7ba0a49bce2
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Wed Mar 22 17:22:30 2017 +0200
sync: Add EphySynchronizableManager interface
src/Makefile.am | 2 +
src/sync/ephy-synchronizable-manager.c | 124 ++++++++++++++++++++++++++++++++
src/sync/ephy-synchronizable-manager.h | 70 ++++++++++++++++++
3 files changed, 196 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 478f7b6..91eda27 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -78,6 +78,8 @@ if ENABLE_SYNC
libephymain_la_SOURCES += \
sync/ephy-synchronizable.c \
sync/ephy-synchronizable.h \
+ sync/ephy-synchronizable-manager.c \
+ sync/ephy-synchronizable-manager.h \
sync/ephy-sync-crypto.c \
sync/ephy-sync-crypto.h \
sync/ephy-sync-secret.c \
diff --git a/src/sync/ephy-synchronizable-manager.c b/src/sync/ephy-synchronizable-manager.c
new file mode 100644
index 0000000..099e1a0
--- /dev/null
+++ b/src/sync/ephy-synchronizable-manager.c
@@ -0,0 +1,124 @@
+/* -*- 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-synchronizable-manager.h"
+
+G_DEFINE_INTERFACE (EphySynchronizableManager, ephy_synchronizable_manager, G_TYPE_OBJECT);
+
+static void
+ephy_synchronizable_manager_default_init (EphySynchronizableManagerInterface *iface)
+{
+ iface->get_collection_name = ephy_synchronizable_manager_get_collection_name;
+ iface->get_synchronizable_type = ephy_synchronizable_manager_get_synchronizable_type;
+ iface->get_sync_time = ephy_synchronizable_manager_get_sync_time;
+ iface->set_sync_time = ephy_synchronizable_manager_set_sync_time;
+ iface->add = ephy_synchronizable_manager_add;
+ iface->remove = ephy_synchronizable_manager_remove;
+ iface->merge_remotes = ephy_synchronizable_manager_merge_remotes;
+}
+
+const char *
+ephy_synchronizable_manager_get_collection_name (EphySynchronizableManager *manager)
+{
+ EphySynchronizableManagerInterface *iface;
+
+ g_return_val_if_fail (EPHY_IS_SYNCHRONIZABLE_MANAGER (manager), NULL);
+
+ iface = EPHY_SYNCHRONIZABLE_MANAGER_GET_IFACE (manager);
+ return iface->get_collection_name (manager);
+}
+
+GType
+ephy_synchronizable_manager_get_synchronizable_type (EphySynchronizableManager *manager)
+{
+ EphySynchronizableManagerInterface *iface;
+
+ g_return_val_if_fail (EPHY_IS_SYNCHRONIZABLE_MANAGER (manager), 0);
+
+ iface = EPHY_SYNCHRONIZABLE_MANAGER_GET_IFACE (manager);
+ return iface->get_synchronizable_type (manager);
+}
+
+double
+ephy_synchronizable_manager_get_sync_time (EphySynchronizableManager *manager)
+{
+ EphySynchronizableManagerInterface *iface;
+
+ g_return_val_if_fail (EPHY_IS_SYNCHRONIZABLE_MANAGER (manager), 0);
+
+ iface = EPHY_SYNCHRONIZABLE_MANAGER_GET_IFACE (manager);
+ return iface->get_sync_time (manager);
+}
+
+void
+ephy_synchronizable_manager_set_sync_time (EphySynchronizableManager *manager,
+ double sync_time)
+{
+ EphySynchronizableManagerInterface *iface;
+
+ g_return_if_fail (EPHY_IS_SYNCHRONIZABLE_MANAGER (manager));
+
+ iface = EPHY_SYNCHRONIZABLE_MANAGER_GET_IFACE (manager);
+ iface->set_sync_time (manager, sync_time);
+}
+
+void
+ephy_synchronizable_manager_add (EphySynchronizableManager *manager,
+ EphySynchronizable *synchronizable)
+{
+ EphySynchronizableManagerInterface *iface;
+
+ g_return_if_fail (EPHY_IS_SYNCHRONIZABLE_MANAGER (manager));
+ g_return_if_fail (EPHY_IS_SYNCHRONIZABLE (synchronizable));
+
+ iface = EPHY_SYNCHRONIZABLE_MANAGER_GET_IFACE (manager);
+ iface->add (manager, synchronizable);
+}
+
+void
+ephy_synchronizable_manager_remove (EphySynchronizableManager *manager,
+ EphySynchronizable *synchronizable)
+{
+ EphySynchronizableManagerInterface *iface;
+
+ g_return_if_fail (EPHY_IS_SYNCHRONIZABLE_MANAGER (manager));
+ g_return_if_fail (EPHY_IS_SYNCHRONIZABLE (synchronizable));
+
+ iface = EPHY_SYNCHRONIZABLE_MANAGER_GET_IFACE (manager);
+ iface->remove (manager, synchronizable);
+}
+
+void
+ephy_synchronizable_manager_merge_remotes (EphySynchronizableManager *manager,
+ gboolean first_time,
+ GList *remotes,
+ GList **to_updload,
+ GList **to_test)
+{
+ EphySynchronizableManagerInterface *iface;
+
+ g_return_if_fail (EPHY_IS_SYNCHRONIZABLE_MANAGER (manager));
+ g_return_if_fail (to_updload);
+ g_return_if_fail (to_test);
+
+ iface = EPHY_SYNCHRONIZABLE_MANAGER_GET_IFACE (manager);
+ iface->merge_remotes (manager, first_time, remotes, to_updload, to_test);
+}
diff --git a/src/sync/ephy-synchronizable-manager.h b/src/sync/ephy-synchronizable-manager.h
new file mode 100644
index 0000000..766d4f2
--- /dev/null
+++ b/src/sync/ephy-synchronizable-manager.h
@@ -0,0 +1,70 @@
+/* -*- 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 "ephy-synchronizable.h"
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_SYNCHRONIZABLE_MANAGER (ephy_synchronizable_manager_get_type ())
+
+G_DECLARE_INTERFACE (EphySynchronizableManager, ephy_synchronizable_manager, EPHY, SYNCHRONIZABLE_MANAGER,
GObject)
+
+struct _EphySynchronizableManagerInterface {
+ GTypeInterface parent_iface;
+
+ const char * (*get_collection_name) (EphySynchronizableManager *manager);
+ GType (*get_synchronizable_type) (EphySynchronizableManager *manager);
+
+ double (*get_sync_time) (EphySynchronizableManager *manager);
+ void (*set_sync_time) (EphySynchronizableManager *manager,
+ double sync_time);
+
+ void (*add) (EphySynchronizableManager *manager,
+ EphySynchronizable *synchronizable);
+ void (*remove) (EphySynchronizableManager *manager,
+ EphySynchronizable *synchronizable);
+
+ void (*merge_remotes) (EphySynchronizableManager *manager,
+ gboolean first_time,
+ GList *remotes,
+ GList **to_upload,
+ GList **to_test);
+};
+
+const char *ephy_synchronizable_manager_get_collection_name (EphySynchronizableManager
*manager);
+GType ephy_synchronizable_manager_get_synchronizable_type (EphySynchronizableManager
*manager);
+double ephy_synchronizable_manager_get_sync_time (EphySynchronizableManager
*manager);
+void ephy_synchronizable_manager_set_sync_time (EphySynchronizableManager *manager,
+ double
sync_time);
+void ephy_synchronizable_manager_add (EphySynchronizableManager *manager,
+ EphySynchronizable
*synchronizable);
+void ephy_synchronizable_manager_remove (EphySynchronizableManager *manager,
+ EphySynchronizable
*synchronizable);
+void ephy_synchronizable_manager_merge_remotes (EphySynchronizableManager *manager,
+ gboolean
first_time,
+ GList *remotes,
+ GList
**to_upload,
+ GList
**to_test);
+
+G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]