[epiphany] Move sync support behind --enable-firefox-sync flag
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Move sync support behind --enable-firefox-sync flag
- Date: Wed, 7 Dec 2016 00:26:54 +0000 (UTC)
commit 36a40cbb98e312649fce93a2002b026c44f57210
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Tue Dec 6 12:48:01 2016 -0600
Move sync support behind --enable-firefox-sync flag
We'll most likely leave it disabled for 3.24 so it has more time to bake
until 3.26.
https://bugzilla.gnome.org/show_bug.cgi?id=775147
configure.ac | 23 ++++++++++++++++--
src/Makefile.am | 10 +++++--
src/bookmarks/ephy-bookmark-properties-grid.c | 9 ++++++-
src/bookmarks/ephy-bookmark.c | 31 +++++++++++++++++++++++-
src/bookmarks/ephy-bookmark.h | 2 +
src/ephy-shell.c | 10 ++++++++
src/ephy-shell.h | 7 +++++-
src/prefs-dialog.c | 27 +++++++++++++++++++++-
src/resources/prefs-dialog.ui | 3 +-
9 files changed, 109 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 640ec0b..053a387 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,18 +107,20 @@ 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([HOGWEED], [hogweed >= 3.2])
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])
PKG_CHECK_MODULES([LIBSOUP], [libsoup-2.4 >= 2.48.0])
PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.6.12])
PKG_CHECK_MODULES([LIBXSLT], [libxslt >= 1.1.7])
-PKG_CHECK_MODULES([NETTLE], [nettle >= 3.2])
PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0])
PKG_CHECK_MODULES([WEBKIT2GTK], [webkit2gtk-4.0 >= $WEBKITGTK_REQUIRED])
PKG_CHECK_MODULES([WEBKIT2GTK_WEB_EXTENSION], [webkit2gtk-web-extension-4.0 >= $WEBKITGTK_REQUIRED])
+# *********************
+# Experimental features
+# *********************
+
# libhttpseverywhere is disabled by default for now. See tracker bug #775575.
AC_ARG_WITH([libhttpseverywhere],
[AS_HELP_STRING([--with-libhttpseverywhere], [Enable experimental HTTPS Everywhere support])],
@@ -127,9 +129,23 @@ AC_ARG_WITH([libhttpseverywhere],
)
AS_IF([test "x$with_libhttpseverywhere" = "xyes"],
[PKG_CHECK_MODULES([HTTPSEVERYWHERE], [httpseverywhere-0.2 >= 0.2.2])
- AC_DEFINE([HAVE_LIBHTTPSEVERYWHERE], [1], [Define if libhttpseverywhere is available])]
+ AC_DEFINE([HAVE_LIBHTTPSEVERYWHERE], [1], [Define if libhttpseverywhere is available])]
+)
+
+# Firefox sync is not quite ready yet either.
+AC_ARG_ENABLE([firefox-sync],
+ [AS_HELP_STRING([--enable-firefox-sync], [Enable experimental Firefox Sync support])],
+ [],
+ [enable_firefox_sync=no]
+)
+AS_IF([test "x$enable_firefox_sync" = "xyes"],
+ [PKG_CHECK_MODULES([HOGWEED], [hogweed >= 3.2])
+ PKG_CHECK_MODULES([NETTLE], [nettle >= 3.2])
+ AC_DEFINE([ENABLE_SYNC], [1], [Define if Firefox Sync support is enabled])]
)
+AM_CONDITIONAL([ENABLE_SYNC], [test "x$enable_firefox_sync" = "xyes"])
+
# ******************
# Portability checks
# ******************
@@ -231,4 +247,5 @@ Epiphany was configured with the following options:
Build tests : $enable_tests
Code coverage : $enable_code_coverage
HTTPS Everywhere (unstable): $with_libhttpseverywhere
+ Firefox Sync (unstable) : $enable_firefox_sync
"
diff --git a/src/Makefile.am b/src/Makefile.am
index 4085571..ea316e7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,6 +71,11 @@ libephymain_la_SOURCES = \
popup-commands.h \
prefs-dialog.c \
prefs-dialog.h \
+ window-commands.c \
+ window-commands.h
+
+if ENABLE_SYNC
+libephymain_la_SOURCES += \
sync/ephy-sync-crypto.c \
sync/ephy-sync-crypto.h \
sync/ephy-sync-secret.c \
@@ -78,9 +83,8 @@ libephymain_la_SOURCES = \
sync/ephy-sync-service.c \
sync/ephy-sync-service.h \
sync/ephy-sync-utils.c \
- sync/ephy-sync-utils.h \
- window-commands.c \
- window-commands.h
+ sync/ephy-sync-utils.h
+endif
nodist_libephymain_la_SOURCES = \
$(TYPES_SOURCE)
diff --git a/src/bookmarks/ephy-bookmark-properties-grid.c b/src/bookmarks/ephy-bookmark-properties-grid.c
index 760f982..bfacfbb 100644
--- a/src/bookmarks/ephy-bookmark-properties-grid.c
+++ b/src/bookmarks/ephy-bookmark-properties-grid.c
@@ -25,13 +25,16 @@
#include "ephy-bookmarks-manager.h"
#include "ephy-debug.h"
#include "ephy-shell.h"
-#include "ephy-sync-service.h"
#include "ephy-type-builtins.h"
#include "ephy-uri-helpers.h"
#include <libsoup/soup.h>
#include <string.h>
+#ifdef ENABLE_SYNC
+#include "ephy-sync-service.h"
+#endif
+
struct _EphyBookmarkPropertiesGrid {
GtkGrid parent_instance;
@@ -243,13 +246,17 @@ ephy_bookmarks_properties_grid_actions_remove_bookmark (GSimpleAction *action,
GVariant *value,
gpointer user_data)
{
+#ifdef ENABLE_SYNC
EphySyncService *service;
+#endif
EphyBookmarkPropertiesGrid *self = user_data;
g_assert (EPHY_IS_BOOKMARK_PROPERTIES_GRID (self));
+#ifdef ENABLE_SYNC
service = ephy_shell_get_sync_service (ephy_shell_get_default ());
ephy_sync_service_delete_bookmark (service, self->bookmark, FALSE);
+#endif
ephy_bookmarks_manager_remove_bookmark (self->manager, self->bookmark);
if (self->type == EPHY_BOOKMARK_PROPERTIES_GRID_TYPE_DIALOG)
diff --git a/src/bookmarks/ephy-bookmark.c b/src/bookmarks/ephy-bookmark.c
index 74320bb..75d3ca6 100644
--- a/src/bookmarks/ephy-bookmark.c
+++ b/src/bookmarks/ephy-bookmark.c
@@ -23,11 +23,14 @@
#include "ephy-bookmark.h"
#include "ephy-shell.h"
-#include "ephy-sync-crypto.h"
-#include "ephy-sync-utils.h"
#include <string.h>
+#ifdef ENABLE_SYNC
+#include "ephy-sync-crypto.h"
+#include "ephy-sync-utils.h"
+#endif
+
#define ID_LEN 32
struct _EphyBookmark {
@@ -200,8 +203,30 @@ ephy_bookmark_class_init (EphyBookmarkClass *klass)
static void
ephy_bookmark_init (EphyBookmark *self)
{
+#ifdef ENABLE_SYNC
self->id = g_malloc0 (ID_LEN + 1);
ephy_sync_crypto_random_hex_gen (NULL, ID_LEN, (guint8 *)self->id);
+#else
+ static const char hex_digits[] = "0123456789abcdef";
+ FILE *fp;
+ gsize num_bytes;
+ guint8 *bytes;
+
+ num_bytes = (ID_LEN + 1) / 2;
+ bytes = g_malloc (num_bytes);
+
+ fp = fopen ("/dev/urandom", "r");
+ fread (bytes, sizeof (guint8), num_bytes, fp);
+
+ self->id = g_malloc0 (ID_LEN + 1);
+ for (gsize i = 0; i < num_bytes; i++) {
+ self->id[2 * i] = hex_digits[bytes[i] >> 4];
+ self->id[2 * i + 1] = hex_digits[bytes[i] & 0xf];
+ }
+
+ g_free (bytes);
+ fclose (fp);
+#endif
}
static JsonNode *
@@ -500,6 +525,7 @@ ephy_bookmark_tags_compare (const char *tag1, const char *tag2)
return result;
}
+#ifdef ENABLE_SYNC
char *
ephy_bookmark_to_bso (EphyBookmark *self)
{
@@ -587,6 +613,7 @@ out:
return bookmark;
}
+#endif
gboolean
ephy_bookmark_is_smart (EphyBookmark *bookmark)
diff --git a/src/bookmarks/ephy-bookmark.h b/src/bookmarks/ephy-bookmark.h
index cc7be4a..7f159e3 100644
--- a/src/bookmarks/ephy-bookmark.h
+++ b/src/bookmarks/ephy-bookmark.h
@@ -70,8 +70,10 @@ int ephy_bookmark_bookmarks_sort_func (EphyBookmark *bookmark
int ephy_bookmark_tags_compare (const char *tag1,
const char *tag2);
+#ifdef ENABLE_SYNC
char *ephy_bookmark_to_bso (EphyBookmark *self);
EphyBookmark *ephy_bookmark_from_bso (JsonObject *bso);
+#endif
gboolean ephy_bookmark_is_smart (EphyBookmark *self);
char *ephy_bookmark_resolve_smart_url (EphyBookmark *self,
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index f821876..3e29127 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -51,7 +51,9 @@ struct _EphyShell {
EphyEmbedShell parent_instance;
EphySession *session;
+#ifdef ENABLE_SYNC
EphySyncService *sync_service;
+#endif
GList *windows;
GObject *lockdown;
EphyBookmarksManager *bookmarks_manager;
@@ -329,7 +331,9 @@ ephy_shell_startup (GApplication *application)
mode = ephy_embed_shell_get_mode (embed_shell);
if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION) {
+#ifdef ENABLE_SYNC
EphySyncService *service;
+#endif
g_action_map_add_action_entries (G_ACTION_MAP (application),
app_entries, G_N_ELEMENTS (app_entries),
@@ -347,10 +351,12 @@ ephy_shell_startup (GApplication *application)
G_BINDING_SYNC_CREATE);
}
+#ifdef ENABLE_SYNC
/* Start the periodical sync now. */
service = ephy_sync_service_new ();
ephy_sync_service_start_periodical_sync (service, TRUE);
ephy_shell->sync_service = service;
+#endif
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder,
@@ -620,7 +626,9 @@ ephy_shell_dispose (GObject *object)
g_clear_pointer (&shell->history_window, gtk_widget_destroy);
g_clear_object (&shell->prefs_dialog);
g_clear_object (&shell->network_monitor);
+#ifdef ENABLE_SYNC
g_clear_object (&shell->sync_service);
+#endif
g_clear_object (&shell->bookmarks_manager);
g_slist_free_full (shell->open_uris_idle_ids, remove_open_uris_idle_cb);
@@ -767,6 +775,7 @@ ephy_shell_get_session (EphyShell *shell)
return shell->session;
}
+#ifdef ENABLE_SYNC
/**
* ephy_shell_get_sync_service:
* @shell: the #EphyShell
@@ -782,6 +791,7 @@ ephy_shell_get_sync_service (EphyShell *shell)
return shell->sync_service;
}
+#endif
/**
* ephy_shell_get_bookmarks_manager:
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index 19f180d..7cbe0ee 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -26,13 +26,16 @@
#include "ephy-embed-shell.h"
#include "ephy-embed.h"
#include "ephy-session.h"
-#include "ephy-sync-service.h"
#include "ephy-window.h"
#include <webkit2/webkit2.h>
#include <glib-object.h>
#include <glib.h>
+#ifdef ENABLE_SYNC
+#include "ephy-sync-service.h"
+#endif
+
G_BEGIN_DECLS
#define EPHY_TYPE_SHELL (ephy_shell_get_type ())
@@ -102,7 +105,9 @@ GNetworkMonitor *ephy_shell_get_net_monitor (EphyShell *shell);
EphyBookmarksManager *ephy_shell_get_bookmarks_manager (EphyShell *shell);
+#ifdef ENABLE_SYNC
EphySyncService *ephy_shell_get_sync_service (EphyShell *shell);
+#endif
GtkWidget *ephy_shell_get_history_window (EphyShell *shell);
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 3dd038e..0c05415 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -103,6 +103,7 @@ struct _PrefsDialog {
GHashTable *iso_639_table;
GHashTable *iso_3166_table;
+#ifdef ENABLE_SYNC
/* sync */
GtkWidget *sync_authenticate_box;
GtkWidget *sync_sign_in_box;
@@ -115,8 +116,12 @@ struct _PrefsDialog {
WebKitUserContentManager *fxa_manager;
WebKitUserScript *fxa_script;
guint fxa_id;
+#else
+ GtkWidget *notebook;
+#endif
};
+#ifdef ENABLE_SYNC
typedef struct {
PrefsDialog *dialog;
char *email;
@@ -129,6 +134,7 @@ typedef struct {
guint8 *respHMACkey;
guint8 *respXORkey;
} FxACallbackData;
+#endif
enum {
SEARCH_ENGINE_COL_NAME,
@@ -139,6 +145,7 @@ enum {
G_DEFINE_TYPE (PrefsDialog, prefs_dialog, GTK_TYPE_DIALOG)
+#ifdef ENABLE_SYNC
static FxACallbackData *
fxa_callback_data_new (PrefsDialog *dialog,
const char *email,
@@ -189,6 +196,7 @@ fxa_callback_data_free (FxACallbackData *data)
g_slice_free (FxACallbackData, data);
}
+#endif
static void
prefs_dialog_finalize (GObject *object)
@@ -206,6 +214,7 @@ prefs_dialog_finalize (GObject *object)
g_hash_table_destroy (dialog->iso_639_table);
g_hash_table_destroy (dialog->iso_3166_table);
+#ifdef ENABLE_SYNC
if (dialog->fxa_web_view != NULL) {
webkit_user_content_manager_unregister_script_message_handler (dialog->fxa_manager,
"accountsCommandHandler");
@@ -217,10 +226,12 @@ prefs_dialog_finalize (GObject *object)
g_source_remove (dialog->fxa_id);
dialog->fxa_id = 0;
}
+#endif
G_OBJECT_CLASS (prefs_dialog_parent_class)->finalize (object);
}
+#ifdef ENABLE_SYNC
static void
hide_fxa_iframe (PrefsDialog *dialog,
const char *email)
@@ -481,6 +492,7 @@ on_sync_sign_out_button_clicked (GtkWidget *button,
TRUE, TRUE, 0);
gtk_widget_set_visible (dialog->sync_sign_in_details, FALSE);
}
+#endif
static void
on_manage_cookies_button_clicked (GtkWidget *button,
@@ -553,6 +565,7 @@ prefs_dialog_class_init (PrefsDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, lang_down_button);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, enable_spell_checking_checkbutton);
+#ifdef ENABLE_SYNC
/* sync */
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, sync_authenticate_box);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, sync_sign_in_box);
@@ -560,10 +573,12 @@ prefs_dialog_class_init (PrefsDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, sync_sign_out_box);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, sync_sign_out_details);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, sync_sign_out_button);
+#else
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, notebook);
+#endif
gtk_widget_class_bind_template_callback (widget_class, on_manage_cookies_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_manage_passwords_button_clicked);
- gtk_widget_class_bind_template_callback (widget_class, on_sync_sign_out_button_clicked);
}
static void
@@ -1553,6 +1568,7 @@ setup_language_page (PrefsDialog *dialog)
create_language_section (dialog);
}
+#ifdef ENABLE_SYNC
static void
setup_sync_page (PrefsDialog *dialog)
{
@@ -1579,6 +1595,7 @@ setup_sync_page (PrefsDialog *dialog)
g_free (account);
}
}
+#endif
static void
prefs_dialog_init (PrefsDialog *dialog)
@@ -1589,8 +1606,16 @@ prefs_dialog_init (PrefsDialog *dialog)
setup_fonts_page (dialog);
setup_privacy_page (dialog);
setup_language_page (dialog);
+#ifdef ENABLE_SYNC
setup_sync_page (dialog);
+ /* TODO: Switch back to using a template callback in class_init once sync is unconditionally enabled. */
+ g_signal_connect (dialog->sync_sign_out_button, "clicked",
+ G_CALLBACK (on_sync_sign_out_button_clicked), dialog);
+#else
+ gtk_notebook_remove_page (GTK_NOTEBOOK (dialog->notebook), -1);
+#endif
+
ephy_gui_ensure_window_group (GTK_WINDOW (dialog));
g_signal_connect (dialog, "response",
G_CALLBACK (prefs_dialog_response_cb), dialog);
diff --git a/src/resources/prefs-dialog.ui b/src/resources/prefs-dialog.ui
index 4a63db3..a7f94d7 100644
--- a/src/resources/prefs-dialog.ui
+++ b/src/resources/prefs-dialog.ui
@@ -31,7 +31,7 @@
<property name="spacing">2</property>
<property name="border_width">0</property>
<child>
- <object class="GtkNotebook">
+ <object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="show_border">False</property>
<child>
@@ -816,7 +816,6 @@
<property name="use-underline">True</property>
<property name="halign">start</property>
<property name="width-request">100</property>
- <signal name="clicked" handler="on_sync_sign_out_button_clicked"/>
<style>
<class name="destructive-action"/>
<class name="text-button"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]