Commit dd0ace0a authored by Gabriel Ivașcu's avatar Gabriel Ivașcu Committed by Michael Catanzaro

sync: Fix issues pointed in the code review

parent 2e0a15b0
......@@ -23,6 +23,7 @@
#include "ephy-embed-shell.h"
#include "ephy-embed-prefs.h"
#include "ephy-embed-utils.h"
#include "ephy-file-helpers.h"
#include "ephy-history-service.h"
#include "ephy-prefs.h"
......@@ -454,7 +455,7 @@ history_service_query_urls_cb (EphyHistoryService *history,
"<body>\n",
lang, lang,
((gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) ? "rtl" : "ltr"),
_("Most Visited"));
_(OVERVIEW_PAGE_TITLE));
g_free (lang);
if (g_list_length (urls) == 0 || !success) {
......
......@@ -341,7 +341,7 @@ ephy_embed_utils_get_title_from_address (const char *address)
if (!strcmp (address, EPHY_ABOUT_SCHEME ":overview") ||
!strcmp (address, "about:overview"))
return g_strdup (_("Most Visited"));
return g_strdup (_(OVERVIEW_PAGE_TITLE));
return ephy_string_get_host_name (address);
}
......
......@@ -28,6 +28,9 @@
G_BEGIN_DECLS
#define BLANK_PAGE_TITLE N_("Blank page") /* Title for the blank page */
#define OVERVIEW_PAGE_TITLE N_("Most Visited") /* Title for the overview page */
#define EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED(embed) (WEBKIT_WEB_VIEW (ephy_embed_get_web_view (embed)))
#define EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW(view) (EPHY_EMBED (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent ((GTK_WIDGET (view)))))))
......
......@@ -46,7 +46,6 @@ static void ephy_embed_restored_window_cb (EphyEmbedShell *shell,
#define EPHY_EMBED_STATUSBAR_TAB_MESSAGE_CONTEXT_DESCRIPTION "tab_message"
#define MAX_TITLE_LENGTH 512 /* characters */
#define EMPTY_PAGE_TITLE _("Blank page") /* Title for the empty page */
typedef struct {
gchar *text;
......@@ -263,7 +262,7 @@ ephy_embed_set_title (EphyEmbed *embed,
if (new_title == NULL || new_title[0] == '\0') {
g_free (new_title);
new_title = g_strdup (EMPTY_PAGE_TITLE);
new_title = g_strdup (_(BLANK_PAGE_TITLE));
}
}
......
......@@ -84,7 +84,10 @@ base64_to_base64_urlsafe (char *text)
{
g_assert (text);
/* Replace '+' with '-' and '/' with '_' */
/* / and + are inappropriate for URLs and file systems paths, so they have to
* be omitted to make the base64 string safe. / is replaced with _ and + is
* replaced with -.
*/
g_strcanon (text, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789=/", '-');
g_strcanon (text, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789=-", '_');
}
......@@ -265,7 +268,7 @@ ephy_sync_utils_get_device_name (void)
name = g_settings_get_string (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_DEVICE_NAME);
if (!g_strcmp0 (name, "")) {
g_free (name);
name = g_strdup_printf ("%s's Epiphany on %s",
name = g_strdup_printf ("%s's GNOME Web on %s",
g_get_user_name (), g_get_host_name ());
}
......
......@@ -118,7 +118,8 @@ ephy_history_manager_set_property (GObject *object,
switch (prop_id) {
case PROP_HISTORY_SERVICE:
g_clear_object (&self->service);
if (self->service)
g_object_unref (self->service);
self->service = g_object_ref (g_value_get_object (value));
break;
default:
......
......@@ -156,7 +156,9 @@ ephy_history_record_finalize (GObject *object)
g_free (self->id);
g_free (self->title);
g_free (self->uri);
g_sequence_free (self->visits);
if (self->visits)
g_sequence_free (self->visits);
G_OBJECT_CLASS (ephy_history_record_parent_class)->finalize (object);
}
......
......@@ -23,6 +23,7 @@
#include "ephy-embed-container.h"
#include "ephy-embed-shell.h"
#include "ephy-embed-utils.h"
#include "ephy-settings.h"
#include "ephy-sync-utils.h"
#include "ephy-synchronizable-manager.h"
......@@ -99,7 +100,7 @@ ephy_open_tabs_manager_get_local_tabs (EphyOpenTabsManager *self)
for (GList *t = tabs; t && t->data; t = t->next) {
title = ephy_embed_get_title (t->data);
if (!g_strcmp0 (title, "Blank page") || !g_strcmp0 (title, "Most Visited"))
if (!g_strcmp0 (title, _(BLANK_PAGE_TITLE)) || !g_strcmp0 (title, _(OVERVIEW_PAGE_TITLE)))
continue;
url = ephy_web_view_get_display_address (ephy_embed_get_web_view (t->data));
......
......@@ -32,7 +32,7 @@
#include <json-glib/json-glib.h>
#include <string.h>
#define STORAGE_VERSION 5
#define EPHY_STORAGE_VERSION 5
struct _EphySyncService {
GObject parent_instance;
......@@ -641,7 +641,8 @@ ephy_sync_service_forget_secrets (EphySyncService *self)
g_assert (self->secrets);
user = ephy_sync_utils_get_sync_user ();
g_assert (user);
g_return_if_fail (user);
attributes = secret_attributes_build (EPHY_SYNC_SECRET_SCHEMA,
ACCOUNT_KEY, user,
NULL);
......@@ -1900,7 +1901,7 @@ ephy_sync_service_upload_meta_global (EphySyncService *self)
json_object_set_object_member (engines, "passwords", make_engine_object (1));
json_object_set_object_member (engines, "forms", make_engine_object (1));
json_object_set_object_member (payload, "engines", engines);
json_object_set_int_member (payload, "storageVersion", STORAGE_VERSION);
json_object_set_int_member (payload, "storageVersion", EPHY_STORAGE_VERSION);
sync_id = ephy_sync_utils_get_random_sync_id ();
json_object_set_string_member (payload, "syncID", sync_id);
json_node_set_object (node, payload);
......@@ -1978,11 +1979,11 @@ verify_storage_version_cb (SoupSession *session,
goto out_error;
}
storage_version = json_object_get_int_member (json, "storageVersion");
if (storage_version != STORAGE_VERSION) {
if (storage_version != EPHY_STORAGE_VERSION) {
/* Translators: the %d is the storage version, the \n is a newline character. */
message = g_strdup_printf (_("Your Firefox Account uses storage version %d "
"which Epiphany does not support.\n"
"Create a new account to use the latest storage version."),
message = g_strdup_printf (_("Your Firefox Account uses storage version %d. "
"Web only supports version %d."),
EPHY_STORAGE_VERSION,
storage_version);
goto out_error;
}
......@@ -2273,7 +2274,7 @@ ephy_sync_service_register_device (EphySyncService *self,
g_return_if_fail (EPHY_IS_SYNC_SERVICE (self));
/* Make protocol. */
protocol = g_strdup_printf ("1.%d", STORAGE_VERSION);
protocol = g_strdup_printf ("1.%d", EPHY_STORAGE_VERSION);
array = json_array_new ();
json_array_add_string_element (array, protocol);
......
......@@ -8,6 +8,7 @@ embed/ephy-download.c
embed/ephy-embed.c
embed/ephy-embed-shell.c
embed/ephy-embed-utils.c
embed/ephy-embed-utils.h
embed/ephy-encodings.c
embed/ephy-find-toolbar.c
embed/ephy-web-view.c
......
......@@ -118,13 +118,13 @@ ephy_add_bookmark_popover_closed_cb (GtkPopover *popover,
g_assert (EPHY_IS_ADD_BOOKMARK_POPOVER (popover));
self = EPHY_ADD_BOOKMARK_POPOVER (popover);
manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
ephy_bookmarks_manager_save_to_file_async (manager, NULL,
ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
NULL);
self = EPHY_ADD_BOOKMARK_POPOVER (popover);
g_clear_pointer (&self->address, g_free);
g_clear_pointer (&self->grid, gtk_widget_destroy);
}
......
......@@ -33,27 +33,21 @@ EphyBookmark *ephy_bookmark_new (const char *url,
const char *title,
GSequence *tags,
const char *id);
void ephy_bookmark_set_time_added (EphyBookmark *self,
gint64 time_added);
gint64 ephy_bookmark_get_time_added (EphyBookmark *self);
void ephy_bookmark_set_url (EphyBookmark *self,
const char *url);
const char *ephy_bookmark_get_url (EphyBookmark *self);
void ephy_bookmark_set_title (EphyBookmark *self,
const char *title);
const char *ephy_bookmark_get_title (EphyBookmark *self);
void ephy_bookmark_set_id (EphyBookmark *self,
const char *id);
const char *ephy_bookmark_get_id (EphyBookmark *self);
void ephy_bookmark_set_is_uploaded (EphyBookmark *self,
gboolean uploaded);
gboolean ephy_bookmark_is_uploaded (EphyBookmark *self);
void ephy_bookmark_add_tag (EphyBookmark *self,
const char *tag);
void ephy_bookmark_remove_tag (EphyBookmark *self,
......@@ -61,7 +55,6 @@ void ephy_bookmark_remove_tag (EphyBookmark *self,
gboolean ephy_bookmark_has_tag (EphyBookmark *self,
const char *tag);
GSequence *ephy_bookmark_get_tags (EphyBookmark *self);
int ephy_bookmark_bookmarks_compare_func (EphyBookmark *bookmark1,
EphyBookmark *bookmark2);
int ephy_bookmark_tags_compare (const char *tag1,
......
......@@ -80,7 +80,8 @@ ephy_passwords_dialog_set_property (GObject *object,
switch (prop_id) {
case PROP_PASSWORD_MANAGER:
g_clear_object (&dialog->manager);
if (dialog->manager)
g_object_unref (dialog->manager);
dialog->manager = g_object_ref (g_value_get_object (value));
break;
default:
......
......@@ -1983,10 +1983,10 @@ prefs_dialog_init (PrefsDialog *dialog)
setup_stored_data_page (dialog);
setup_language_page (dialog);
if (mode == EPHY_EMBED_SHELL_MODE_APPLICATION || mode == EPHY_EMBED_SHELL_MODE_INCOGNITO)
gtk_notebook_remove_page (GTK_NOTEBOOK (dialog->notebook), -1);
else
if (mode == EPHY_EMBED_SHELL_MODE_BROWSER)
setup_sync_page (dialog);
else
gtk_notebook_remove_page (GTK_NOTEBOOK (dialog->notebook), -1);
ephy_gui_ensure_window_group (GTK_WINDOW (dialog));
g_signal_connect (dialog, "response",
......
......@@ -1005,7 +1005,7 @@ migrate_passwords_to_firefox_sync_passwords (void)
GError *error = NULL;
int default_profile_migration_version;
/* Similar to the insecure passowrds migration, we want to migrate passwords
/* Similar to the insecure passwords migration, we want to migrate passwords
* to Firefox Sync passwords only once since saved passwords are stored
* globally and not per profile. This won't affect password lookup for web
* apps because this migration only adds a couple of new fields to the
......
......@@ -235,7 +235,8 @@ synced_tabs_dialog_set_property (GObject *object,
switch (prop_id) {
case PROP_OPEN_TABS_MANAGER:
g_clear_object (&dialog->manager);
if (dialog->manager)
g_object_unref (dialog->manager);
dialog->manager = g_object_ref (g_value_get_object (value));
break;
default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment