[epiphany/wip/ephy-sync: 77/86] ephy-sync: Add sync-bookmarks and sync-utils modules



commit db40065dbf6c532dbe65b3c2be5ed83f40c95ff6
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date:   Fri Jul 29 16:51:34 2016 +0300

    ephy-sync: Add sync-bookmarks and sync-utils modules

 src/Makefile.am           |    4 +
 src/ephy-sync-bookmarks.c |   83 +++++++++++++++++++
 src/ephy-sync-bookmarks.h |   32 +++++++
 src/ephy-sync-service.c   |  199 ++++++++++++---------------------------------
 src/ephy-sync-service.h   |   52 +++++++-----
 src/ephy-sync-utils.c     |   56 +++++++++++++
 src/ephy-sync-utils.h     |   35 ++++++++
 src/prefs-dialog.c        |    3 +-
 8 files changed, 293 insertions(+), 171 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index c8fbe71..388b4ed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,12 +69,16 @@ libephymain_la_SOURCES = \
        ephy-session.h                          \
        ephy-shell.c                            \
        ephy-shell.h                            \
+       ephy-sync-bookmarks.c                   \
+       ephy-sync-bookmarks.h                   \
        ephy-sync-crypto.c                      \
        ephy-sync-crypto.h                      \
        ephy-sync-secret.c                      \
        ephy-sync-secret.h                      \
        ephy-sync-service.c                     \
        ephy-sync-service.h                     \
+       ephy-sync-utils.c                       \
+       ephy-sync-utils.h                       \
        ephy-title-box.c                        \
        ephy-title-box.h                        \
        ephy-toolbar.c                          \
diff --git a/src/ephy-sync-bookmarks.c b/src/ephy-sync-bookmarks.c
new file mode 100644
index 0000000..876dcbf
--- /dev/null
+++ b/src/ephy-sync-bookmarks.c
@@ -0,0 +1,83 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ *  Copyright © 2016 Gabriel Ivascu <ivascu gabriel59 gmail com>
+ *
+ *  This program 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 2, or (at your option)
+ *  any later version.
+ *
+ *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "ephy-sync-bookmarks.h"
+
+#include "ephy-sync-utils.h"
+
+#define EPHY_BOOKMARKS_DUMMY_BSO       "000000000000"
+#define EPHY_BOOKMARKS_BSO_COLLECTION  "ephy-bookmarks"
+
+static void
+create_bso_collection_response_cb (SoupSession *session,
+                                   SoupMessage *message,
+                                   gpointer     user_data)
+{
+  EphySyncService *service;
+  gchar *endpoint;
+
+  service = EPHY_SYNC_SERVICE (user_data);
+
+  /* Status code 412 means the BSO already exists. Since we will delete it
+   * anyway, we don't treat this as an error.
+   */
+  if (message->status_code != 200 && message->status_code != 412) {
+    g_warning ("Failed to add dummy BSO to collection, status code: %u, response: %s",
+               message->status_code, message->response_body->data);
+    return;
+  }
+
+  /* The EPHY_BOOKMARKS_BSO_COLLECTION collection is now created. We can safely
+   * delete the dummy BSO that we've uploaded. No need to check for response.
+   */
+  endpoint = g_strdup_printf ("storage/%s/%s",
+                              EPHY_BOOKMARKS_BSO_COLLECTION,
+                              EPHY_BOOKMARKS_DUMMY_BSO);
+  ephy_sync_service_send_storage_message (service,
+                                          endpoint, SOUP_METHOD_DELETE,
+                                          NULL, -1, -1,
+                                          NULL, NULL);
+  g_free (endpoint);
+}
+
+void
+ephy_sync_bookmarks_create_bso_collection (EphySyncService *service)
+{
+  gchar *endpoint;
+  gchar *bso_json;
+
+  endpoint = g_strdup_printf ("storage/%s/%s",
+                              EPHY_BOOKMARKS_BSO_COLLECTION,
+                              EPHY_BOOKMARKS_DUMMY_BSO);
+  bso_json = ephy_sync_utils_create_bso_json (EPHY_BOOKMARKS_DUMMY_BSO,
+                                              EPHY_BOOKMARKS_DUMMY_BSO);
+
+  /* Send a dummy BSO to the Storage Server so it will create the
+   * EPHY_BOOKMARKS_BSO_COLLECTION collection if it doesn't exist already.
+   * In the response callback we will delete the dummy BSO.
+   */
+  ephy_sync_service_send_storage_message (service,
+                                          endpoint, SOUP_METHOD_PUT,
+                                          bso_json, -1, 0,
+                                          create_bso_collection_response_cb,
+                                          service);
+
+  g_free (endpoint);
+  g_free (bso_json);
+}
diff --git a/src/ephy-sync-bookmarks.h b/src/ephy-sync-bookmarks.h
new file mode 100644
index 0000000..266c026
--- /dev/null
+++ b/src/ephy-sync-bookmarks.h
@@ -0,0 +1,32 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ *  Copyright © 2016 Gabriel Ivascu <ivascu gabriel59 gmail com>
+ *
+ *  This program 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 2, or (at your option)
+ *  any later version.
+ *
+ *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef EPHY_SYNC_BOOKMARKS_H
+#define EPHY_SYNC_BOOKMARKS_H
+
+#include "ephy-sync-service.h"
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+void ephy_sync_bookmarks_create_bso_collection (EphySyncService *service);
+
+G_END_DECLS
+
+#endif
diff --git a/src/ephy-sync-service.c b/src/ephy-sync-service.c
index 425ce28..0e9fbf6 100644
--- a/src/ephy-sync-service.c
+++ b/src/ephy-sync-service.c
@@ -23,21 +23,17 @@
 #include "ephy-settings.h"
 #include "ephy-sync-crypto.h"
 #include "ephy-sync-secret.h"
+#include "ephy-sync-utils.h"
 
 #include <json-glib/json-glib.h>
-#include <libsoup/soup.h>
 #include <string.h>
 
-#define EPHY_BOOKMARKS_DUMMY_BSO       "000000000000"
-#define EPHY_BOOKMARKS_BSO_COLLECTION  "ephy-bookmarks"
-
 #define MOZILLA_TOKEN_SERVER_URL           "https://token.services.mozilla.com/1.0/sync/1.5";
 #define MOZILLA_FIREFOX_ACCOUNTS_BASE_URL  "https://api.accounts.firefox.com/";
 #define MOZILLA_FIREFOX_ACCOUNTS_VERSION   "v1/"
 
 #define EMAIL_REGEX              "^[a-z0-9]([a-z0-9.]+[a-z0-9])?@[a-z0-9.-]+$"
 #define CURRENT_TIME_IN_SECONDS  (g_get_real_time () / 1000000)
-#define HTTP_STATUS_OK           200
 
 struct _EphySyncService {
   GObject parent_instance;
@@ -78,11 +74,6 @@ typedef struct {
   gpointer user_data;
 } StorageServerRequestAsyncData;
 
-static gchar *
-build_json_string (const gchar *first_key,
-                   const gchar *first_value,
-                   ...) G_GNUC_NULL_TERMINATED;
-
 static StorageServerRequestAsyncData *
 storage_server_request_async_data_new (EphySyncService     *service,
                                        gchar               *endpoint,
@@ -121,35 +112,6 @@ storage_server_request_async_data_free (StorageServerRequestAsyncData *data)
 }
 
 static gchar *
-build_json_string (const gchar *first_key,
-                   const gchar *first_value,
-                   ...)
-{
-  va_list args;
-  gchar *json;
-  gchar *key;
-  gchar *value;
-  gchar *tmp;
-
-  json = g_strconcat ("{\"", first_key, "\": \"", first_value, "\"", NULL);
-  va_start (args, first_value);
-
-  while ((key = va_arg (args, gchar *)) != NULL) {
-    value = va_arg (args, gchar *);
-    tmp = json;
-    json = g_strconcat (json, ", \"", key, "\": \"", value, "\"", NULL);
-    g_free (tmp);
-  }
-
-  va_end (args);
-  tmp = json;
-  json = g_strconcat (json, "}", NULL);
-  g_free (tmp);
-
-  return json;
-}
-
-static gchar *
 get_audience_for_url (const gchar *url)
 {
   SoupURI *uri;
@@ -210,7 +172,7 @@ destroy_session_response_cb (SoupSession *session,
   JsonParser *parser;
   JsonObject *json;
 
-  if (message->status_code == HTTP_STATUS_OK) {
+  if (message->status_code == 200) {
     LOG ("Session destroyed");
     return;
   }
@@ -485,7 +447,7 @@ obtain_storage_credentials_response_cb (SoupSession *session,
    * password since the last time he signed in. If this happens, the user needs
    * to be asked to sign in again with the new password.
    */
-  if (message->status_code == HTTP_STATUS_OK) {
+  if (message->status_code == 200) {
     service->storage_endpoint = g_strdup (json_object_get_string_member (json, "api_endpoint"));
     service->storage_credentials_id = g_strdup (json_object_get_string_member (json, "id"));
     service->storage_credentials_key = g_strdup (json_object_get_string_member (json, "key"));
@@ -580,7 +542,7 @@ obtain_signed_certificate_response_cb (SoupSession *session,
   json_parser_load_from_data (parser, message->response_body->data, -1, NULL);
   json = json_node_get_object (json_parser_get_root (parser));
 
-  if (message->status_code != HTTP_STATUS_OK) {
+  if (message->status_code != 200) {
     g_warning ("FxA server errno: %ld, errmsg: %s",
                json_object_get_int_member (json, "errno"),
                json_object_get_string_member (json, "message"));
@@ -629,10 +591,10 @@ ephy_sync_service_obtain_signed_certificate (EphySyncService *self,
 
   n_str = mpz_get_str (NULL, 10, self->keypair->public.n);
   e_str = mpz_get_str (NULL, 10, self->keypair->public.e);
-  public_key_json = build_json_string ("algorithm", "RS",
-                                       "n", n_str,
-                                       "e", e_str,
-                                       NULL);
+  public_key_json = ephy_sync_utils_build_json_string ("algorithm", "RS",
+                                                       "n", n_str,
+                                                       "e", e_str,
+                                                       NULL);
   /* Duration is the lifetime of the certificate in milliseconds. The FxA server
    * limits the duration to 24 hours. For our purposes, a duration of 30 minutes
    * will suffice.
@@ -657,88 +619,6 @@ ephy_sync_service_obtain_signed_certificate (EphySyncService *self,
 }
 
 static void
-ephy_sync_service_send_storage_message (EphySyncService     *self,
-                                        gchar               *endpoint,
-                                        const gchar         *method,
-                                        gchar               *request_body,
-                                        gint64               modified_since,
-                                        gint64               unmodified_since,
-                                        SoupSessionCallback  callback,
-                                        gpointer             user_data)
-{
-  StorageServerRequestAsyncData *data;
-
-  data = storage_server_request_async_data_new (self, endpoint,
-                                                method, request_body,
-                                                modified_since, unmodified_since,
-                                                callback, user_data);
-
-  if (ephy_sync_service_storage_credentials_is_expired (self) == FALSE) {
-    ephy_sync_service_send_storage_request (self, data);
-    return;
-  }
-
-  /* If we are currently obtaining the storage credentials for another message,
-   * then the new message is enqueued and will be sent after the credentials are
-   * retrieved.
-   */
-  if (self->is_obtaining_storage_credentials == TRUE) {
-    g_queue_push_tail (self->storage_message_queue, data);
-    return;
-  }
-
-  /* This message is the one that will obtain the storage credentials. */
-  self->is_obtaining_storage_credentials = TRUE;
-
-  /* Drop the old certificate and storage credentials. */
-  g_clear_pointer (&self->certificate, g_free);
-  g_clear_pointer (&self->storage_credentials_id, g_free);
-  g_clear_pointer (&self->storage_credentials_key, g_free);
-  self->storage_credentials_expiry_time = 0;
-
-  /* The only purpose of certificates is to obtain a signed BrowserID that is
-   * needed to talk to the Token Server. From the Token Server we will obtain
-   * the credentials needed to talk to the Storage Server. Since both
-   * ephy_sync_service_obtain_signed_certificate() and
-   * ephy_sync_service_obtain_storage_credentials() complete asynchronously, we
-   * need to entrust them the task of sending the request to the Storage Server.
-   */
-  ephy_sync_service_obtain_signed_certificate (self, data);
-}
-
-static void
-create_bookmarks_bso_collection_response_cb (SoupSession *session,
-                                             SoupMessage *message,
-                                             gpointer     user_data)
-{
-  EphySyncService *service;
-  gchar *endpoint;
-
-  service = EPHY_SYNC_SERVICE (user_data);
-
-  /* Status code 412 means the BSO already exists. Since we will delete it
-   * anyway, we don't treat this as an error.
-   */
-  if (message->status_code != HTTP_STATUS_OK && message->status_code != 412) {
-    g_warning ("Failed to add dummy BSO to collection, status code: %u, response: %s",
-               message->status_code, message->response_body->data);
-    return;
-  }
-
-  /* The EPHY_BOOKMARKS_BSO_COLLECTION collection is now created. We can safely
-   * delete the dummy BSO that we've uploaded. No need to check for response.
-   */
-  endpoint = g_strdup_printf ("storage/%s/%s",
-                              EPHY_BOOKMARKS_BSO_COLLECTION,
-                              EPHY_BOOKMARKS_DUMMY_BSO);
-  ephy_sync_service_send_storage_message (service,
-                                          endpoint, SOUP_METHOD_DELETE,
-                                          NULL, -1, -1,
-                                          NULL, NULL);
-  g_free (endpoint);
-}
-
-static void
 ephy_sync_service_finalize (GObject *object)
 {
   EphySyncService *self = EPHY_SYNC_SERVICE (object);
@@ -1004,7 +884,7 @@ ephy_sync_service_fetch_sync_keys (EphySyncService *self,
                                                      &node);
   json = json_node_get_object (node);
 
-  if (status_code != HTTP_STATUS_OK) {
+  if (status_code != 200) {
     g_warning ("FxA server errno: %ld, errmsg: %s",
                json_object_get_int_member (json, "errno"),
                json_object_get_string_member (json, "message"));
@@ -1040,28 +920,51 @@ out:
 }
 
 void
-ephy_sync_service_create_bookmarks_bso_collection (EphySyncService *self)
+ephy_sync_service_send_storage_message (EphySyncService     *self,
+                                        gchar               *endpoint,
+                                        const gchar         *method,
+                                        gchar               *request_body,
+                                        gint64               modified_since,
+                                        gint64               unmodified_since,
+                                        SoupSessionCallback  callback,
+                                        gpointer             user_data)
 {
-  gchar *endpoint;
-  gchar *request_body;
+  StorageServerRequestAsyncData *data;
 
-  endpoint = g_strdup_printf ("storage/%s/%s",
-                              EPHY_BOOKMARKS_BSO_COLLECTION,
-                              EPHY_BOOKMARKS_DUMMY_BSO);
-  request_body = build_json_string ("id", EPHY_BOOKMARKS_DUMMY_BSO,
-                                    "payload", EPHY_BOOKMARKS_DUMMY_BSO,
-                                    NULL);
+  data = storage_server_request_async_data_new (self, endpoint,
+                                                method, request_body,
+                                                modified_since, unmodified_since,
+                                                callback, user_data);
 
-  /* Send a dummy BSO to the Storage Server so it will create the
-   * EPHY_BOOKMARKS_BSO_COLLECTION collection if it doesn't exist already.
-   * In the response callback we will delete the dummy BSO.
+  if (ephy_sync_service_storage_credentials_is_expired (self) == FALSE) {
+    ephy_sync_service_send_storage_request (self, data);
+    return;
+  }
+
+  /* If we are currently obtaining the storage credentials for another message,
+   * then the new message is enqueued and will be sent after the credentials are
+   * retrieved.
    */
-  ephy_sync_service_send_storage_message (self,
-                                          endpoint, SOUP_METHOD_PUT,
-                                          request_body, -1, 0,
-                                          create_bookmarks_bso_collection_response_cb,
-                                          self);
+  if (self->is_obtaining_storage_credentials == TRUE) {
+    g_queue_push_tail (self->storage_message_queue, data);
+    return;
+  }
 
-  g_free (endpoint);
-  g_free (request_body);
+  /* This message is the one that will obtain the storage credentials. */
+  self->is_obtaining_storage_credentials = TRUE;
+
+  /* Drop the old certificate and storage credentials. */
+  g_clear_pointer (&self->certificate, g_free);
+  g_clear_pointer (&self->storage_credentials_id, g_free);
+  g_clear_pointer (&self->storage_credentials_key, g_free);
+  self->storage_credentials_expiry_time = 0;
+
+  /* The only purpose of certificates is to obtain a signed BrowserID that is
+   * needed to talk to the Token Server. From the Token Server we will obtain
+   * the credentials needed to talk to the Storage Server. Since both
+   * ephy_sync_service_obtain_signed_certificate() and
+   * ephy_sync_service_obtain_storage_credentials() complete asynchronously, we
+   * need to entrust them the task of sending the request to the Storage Server.
+   */
+  ephy_sync_service_obtain_signed_certificate (self, data);
 }
diff --git a/src/ephy-sync-service.h b/src/ephy-sync-service.h
index 0cbcf63..5d6027d 100644
--- a/src/ephy-sync-service.h
+++ b/src/ephy-sync-service.h
@@ -20,6 +20,7 @@
 #define EPHY_SYNC_SERVICE_H
 
 #include <glib-object.h>
+#include <libsoup/soup.h>
 
 G_BEGIN_DECLS
 
@@ -36,38 +37,45 @@ typedef enum {
   TOKEN_KB
 } EphySyncServiceTokenType;
 
-EphySyncService *ephy_sync_service_new                             (void);
+EphySyncService *ephy_sync_service_new                  (void);
 
-const gchar     *ephy_sync_service_token_name_from_type            (EphySyncServiceTokenType token_type);
+const gchar     *ephy_sync_service_token_name_from_type (EphySyncServiceTokenType token_type);
 
-gchar           *ephy_sync_service_get_user_email                  (EphySyncService *self);
+gchar           *ephy_sync_service_get_user_email       (EphySyncService *self);
 
-void             ephy_sync_service_set_user_email                  (EphySyncService *self,
-                                                                    const gchar     *email);
+void             ephy_sync_service_set_user_email       (EphySyncService *self,
+                                                         const gchar     *email);
 
-gchar           *ephy_sync_service_get_token                       (EphySyncService          *self,
-                                                                    EphySyncServiceTokenType  token_type);
+gchar           *ephy_sync_service_get_token            (EphySyncService          *self,
+                                                         EphySyncServiceTokenType  token_type);
 
-void             ephy_sync_service_set_token                       (EphySyncService          *self,
-                                                                    gchar                    *token_value,
-                                                                    EphySyncServiceTokenType  token_type);
+void             ephy_sync_service_set_token            (EphySyncService          *self,
+                                                         gchar                    *token_value,
+                                                         EphySyncServiceTokenType  token_type);
 
-void             ephy_sync_service_set_and_store_tokens            (EphySyncService          *self,
-                                                                    gchar                    *token_value,
-                                                                    EphySyncServiceTokenType  token_type,
-                                                                    ...) G_GNUC_NULL_TERMINATED;
+void             ephy_sync_service_set_and_store_tokens (EphySyncService          *self,
+                                                         gchar                    *token_value,
+                                                         EphySyncServiceTokenType  token_type,
+                                                         ...) G_GNUC_NULL_TERMINATED;
 
-void             ephy_sync_service_delete_all_tokens               (EphySyncService *self);
+void             ephy_sync_service_delete_all_tokens    (EphySyncService *self);
 
-void             ephy_sync_service_destroy_session                 (EphySyncService *self,
-                                                                    const gchar     *sessionToken);
+void             ephy_sync_service_destroy_session      (EphySyncService *self,
+                                                         const gchar     *sessionToken);
 
-gboolean         ephy_sync_service_fetch_sync_keys                 (EphySyncService *self,
-                                                                    const gchar     *email,
-                                                                    const gchar     *keyFetchToken,
-                                                                    const gchar     *unwrapBKey);
+gboolean         ephy_sync_service_fetch_sync_keys      (EphySyncService *self,
+                                                         const gchar     *email,
+                                                         const gchar     *keyFetchToken,
+                                                         const gchar     *unwrapBKey);
 
-void             ephy_sync_service_create_bookmarks_bso_collection (EphySyncService *self);
+void             ephy_sync_service_send_storage_message (EphySyncService     *self,
+                                                         gchar               *endpoint,
+                                                         const gchar         *method,
+                                                         gchar               *request_body,
+                                                         gint64               modified_since,
+                                                         gint64               unmodified_since,
+                                                         SoupSessionCallback  callback,
+                                                         gpointer             user_data);
 
 G_END_DECLS
 
diff --git a/src/ephy-sync-utils.c b/src/ephy-sync-utils.c
new file mode 100644
index 0000000..c37f885
--- /dev/null
+++ b/src/ephy-sync-utils.c
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ *  Copyright © 2016 Gabriel Ivascu <ivascu gabriel59 gmail com>
+ *
+ *  This program 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 2, or (at your option)
+ *  any later version.
+ *
+ *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "ephy-sync-utils.h"
+
+gchar *
+ephy_sync_utils_build_json_string (const gchar *first_key,
+                                   const gchar *first_value,
+                                   ...)
+{
+  va_list args;
+  gchar *json;
+  gchar *key;
+  gchar *value;
+  gchar *tmp;
+
+  json = g_strconcat ("{\"", first_key, "\": \"", first_value, "\"", NULL);
+  va_start (args, first_value);
+
+  while ((key = va_arg (args, gchar *)) != NULL) {
+    value = va_arg (args, gchar *);
+    tmp = json;
+    json = g_strconcat (json, ", \"", key, "\": \"", value, "\"", NULL);
+    g_free (tmp);
+  }
+
+  va_end (args);
+  tmp = json;
+  json = g_strconcat (json, "}", NULL);
+  g_free (tmp);
+
+  return json;
+}
+
+gchar *
+ephy_sync_utils_create_bso_json (const gchar *id,
+                                 const gchar *payload)
+{
+  return ephy_sync_utils_build_json_string ("id", id, "payload", payload, NULL);
+}
diff --git a/src/ephy-sync-utils.h b/src/ephy-sync-utils.h
new file mode 100644
index 0000000..8cf72df
--- /dev/null
+++ b/src/ephy-sync-utils.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ *  Copyright © 2016 Gabriel Ivascu <ivascu gabriel59 gmail com>
+ *
+ *  This program 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 2, or (at your option)
+ *  any later version.
+ *
+ *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef EPHY_SYNC_UTILS_H
+#define EPHY_SYNC_UTILS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+gchar *ephy_sync_utils_build_json_string (const gchar *first_key,
+                                          const gchar *first_value,
+                                          ...) G_GNUC_NULL_TERMINATED;
+
+gchar *ephy_sync_utils_create_bso_json   (const gchar *id,
+                                          const gchar *payload);
+
+G_END_DECLS
+
+#endif
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index cfd97a3..acf748d 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -35,6 +35,7 @@
 #include "ephy-session.h"
 #include "ephy-settings.h"
 #include "ephy-shell.h"
+#include "ephy-sync-bookmarks.h"
 #include "ephy-sync-secret.h"
 #include "ephy-sync-service.h"
 #include "clear-data-dialog.h"
@@ -296,7 +297,7 @@ server_message_received_cb (WebKitUserContentManager *manager,
                                             NULL);
 
     /* Create our own bookmarks BSO collection on the Storage Server. */
-    ephy_sync_service_create_bookmarks_bso_collection (service);
+    ephy_sync_bookmarks_create_bso_collection (service);
 
     /* Translators: the %s refers to the email of the currently logged in user. */
     gtk_label_set_markup (GTK_LABEL (dialog->sync_sign_out_details),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]