[epiphany/wip/sync: 62/83] bookmark: Implement _to_bso() interface method



commit 651c2036c4a5d4b68f2f0b610ed2bc3c739a36d5
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date:   Tue Mar 21 17:33:55 2017 +0200

    bookmark: Implement _to_bso() interface method

 src/bookmarks/ephy-bookmark.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmark.c b/src/bookmarks/ephy-bookmark.c
index 7480f10..1cb9c75 100644
--- a/src/bookmarks/ephy-bookmark.c
+++ b/src/bookmarks/ephy-bookmark.c
@@ -348,7 +348,33 @@ ephy_bookmark_synchronizable_set_is_uploaded (EphySynchronizable *synchronizable
 static char *
 ephy_bookmark_synchronizable_to_bso (EphySynchronizable *synchronizable)
 {
-  return NULL;
+  EphyBookmark *bookmark = EPHY_BOOKMARK (synchronizable);
+  EphySyncService *service;
+  SyncCryptoKeyBundle *bundle;
+  char *bso = NULL;
+  char *serialized;
+  char *payload;
+
+  service = ephy_shell_get_sync_service (ephy_shell_get_default ());
+  bundle = ephy_sync_service_get_key_bundle (service, "bookmarks");
+  serialized = json_gobject_to_data (G_OBJECT (bookmark), NULL);
+
+  payload = ephy_sync_crypto_encrypt_record (serialized, bundle);
+  if (!payload) {
+    g_warning ("Failed to encrypt bookmark");
+    goto free_serialized;
+  }
+
+  bso = ephy_sync_utils_build_json_string (FALSE,
+                                           "id", bookmark->id,
+                                           "payload", payload,
+                                           NULL);
+
+  g_free (payload);
+free_serialized:
+  g_free (serialized);
+
+  return bso;
 }
 
 static void


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