[epiphany/wip/sync: 10/13] synchronizable: Pass the key bundle as a parameter to _to_bso()
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/sync: 10/13] synchronizable: Pass the key bundle as a parameter to _to_bso()
- Date: Wed, 29 Mar 2017 17:45:00 +0000 (UTC)
commit 4dfbb40e57fb599767ff8ea6e716931b0478c180
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Wed Mar 29 15:16:10 2017 +0300
synchronizable: Pass the key bundle as a parameter to _to_bso()
src/bookmarks/ephy-bookmark.c | 8 ++------
src/sync/ephy-synchronizable.c | 8 ++++++--
src/sync/ephy-synchronizable.h | 24 +++++++++++++-----------
3 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmark.c b/src/bookmarks/ephy-bookmark.c
index 38f7723..aebfcef 100644
--- a/src/bookmarks/ephy-bookmark.c
+++ b/src/bookmarks/ephy-bookmark.c
@@ -419,19 +419,15 @@ ephy_bookmark_synchronizable_set_is_uploaded (EphySynchronizable *synchronizable
}
static char *
-ephy_bookmark_synchronizable_to_bso (EphySynchronizable *synchronizable)
+ephy_bookmark_synchronizable_to_bso (EphySynchronizable *synchronizable,
+ SyncCryptoKeyBundle *bundle)
{
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");
diff --git a/src/sync/ephy-synchronizable.c b/src/sync/ephy-synchronizable.c
index 8b2885a..3401d85 100644
--- a/src/sync/ephy-synchronizable.c
+++ b/src/sync/ephy-synchronizable.c
@@ -158,6 +158,8 @@ ephy_synchronizable_set_is_uploaded (EphySynchronizable *synchronizable,
/**
* ephy_synchronizable_to_bso:
* @synchronizable: an #EphySynchronizable
+ * @bundle: a %SyncCryptoKeyBundle holding the encryption key and the HMAC key
+ * used to validate and encrypt the Basic Storage Object
*
* Converts an #EphySynchronizable into its JSON string representation
* of a Basic Storage Object from the client's point of view
@@ -168,14 +170,16 @@ ephy_synchronizable_set_is_uploaded (EphySynchronizable *synchronizable,
* Return value: (transfer full): @synchronizable's BSO's JSON string representation
**/
char *
-ephy_synchronizable_to_bso (EphySynchronizable *synchronizable)
+ephy_synchronizable_to_bso (EphySynchronizable *synchronizable,
+ SyncCryptoKeyBundle *bundle)
{
EphySynchronizableInterface *iface;
g_return_val_if_fail (EPHY_IS_SYNCHRONIZABLE (synchronizable), NULL);
+ g_return_val_if_fail (bundle, NULL);
iface = EPHY_SYNCHRONIZABLE_GET_IFACE (synchronizable);
- return iface->to_bso (synchronizable);
+ return iface->to_bso (synchronizable, bundle);
}
/**
diff --git a/src/sync/ephy-synchronizable.h b/src/sync/ephy-synchronizable.h
index c90a19c..30dfef7 100644
--- a/src/sync/ephy-synchronizable.h
+++ b/src/sync/ephy-synchronizable.h
@@ -38,19 +38,20 @@ G_DECLARE_INTERFACE (EphySynchronizable, ephy_synchronizable, EPHY, SYNCHRONIZAB
struct _EphySynchronizableInterface {
GTypeInterface parent_iface;
- const char * (*get_id) (EphySynchronizable *synchronizable);
- void (*set_id) (EphySynchronizable *synchronizable,
- const char *id);
+ const char * (*get_id) (EphySynchronizable *synchronizable);
+ void (*set_id) (EphySynchronizable *synchronizable,
+ const char *id);
- double (*get_modification_time) (EphySynchronizable *synchronizable);
- void (*set_modification_time) (EphySynchronizable *synchronizable,
- double modified);
+ double (*get_modification_time) (EphySynchronizable *synchronizable);
+ void (*set_modification_time) (EphySynchronizable *synchronizable,
+ double modified);
- gboolean (*is_uploaded) (EphySynchronizable *synchronizable);
- void (*set_is_uploaded) (EphySynchronizable *synchronizable,
- gboolean uploaded);
+ gboolean (*is_uploaded) (EphySynchronizable *synchronizable);
+ void (*set_is_uploaded) (EphySynchronizable *synchronizable,
+ gboolean uploaded);
- char * (*to_bso) (EphySynchronizable *synchronizable);
+ char * (*to_bso) (EphySynchronizable *synchronizable,
+ SyncCryptoKeyBundle *bundle);
};
const char *ephy_synchronizable_get_id (EphySynchronizable *synchronizable);
@@ -62,7 +63,8 @@ void ephy_synchronizable_set_modification_time (EphySynchroniza
gboolean ephy_synchronizable_is_uploaded (EphySynchronizable *synchronizable);
void ephy_synchronizable_set_is_uploaded (EphySynchronizable *synchronizable,
gboolean uploaded);
-char *ephy_synchronizable_to_bso (EphySynchronizable *synchronizable);
+char *ephy_synchronizable_to_bso (EphySynchronizable *synchronizable,
+ SyncCryptoKeyBundle *bundle);
/* This can't be an interface method because we lack the EphySynchronizable object.
* Think of it as more of an utility function. */
GObject *ephy_synchronizable_from_bso (JsonObject *bso,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]