[epiphany/wip/ephy-sync: 62/126] Discard sync-utils module



commit a84e6eaa91ba5dc26047e5f4d116508d2f2175bd
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date:   Fri Jul 22 18:55:14 2016 +0300

    Discard sync-utils module

 src/Makefile.am         |    2 -
 src/ephy-sync-crypto.c  |    1 -
 src/ephy-sync-crypto.h  |    2 +
 src/ephy-sync-service.c |   50 ++++++++++++++++++++++++++++++++++++++----
 src/ephy-sync-utils.c   |   55 -----------------------------------------------
 src/ephy-sync-utils.h   |   34 -----------------------------
 6 files changed, 47 insertions(+), 97 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index c42111e..2f92f9f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -75,8 +75,6 @@ libephymain_la_SOURCES = \
        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-crypto.c b/src/ephy-sync-crypto.c
index 5c3818f..ce9d87c 100644
--- a/src/ephy-sync-crypto.c
+++ b/src/ephy-sync-crypto.c
@@ -17,7 +17,6 @@
  */
 
 #include "ephy-sync-crypto.h"
-#include "ephy-sync-utils.h"
 
 #include <glib/gstdio.h>
 #include <libsoup/soup.h>
diff --git a/src/ephy-sync-crypto.h b/src/ephy-sync-crypto.h
index f1ac01d..f9a6580 100644
--- a/src/ephy-sync-crypto.h
+++ b/src/ephy-sync-crypto.h
@@ -24,6 +24,8 @@
 
 G_BEGIN_DECLS
 
+#define EPHY_SYNC_TOKEN_LENGTH 32
+
 typedef struct {
   gchar *app;
   gchar *dlg;
diff --git a/src/ephy-sync-service.c b/src/ephy-sync-service.c
index 45b8e96..bfffef2 100644
--- a/src/ephy-sync-service.c
+++ b/src/ephy-sync-service.c
@@ -22,7 +22,6 @@
 #include "ephy-sync-crypto.h"
 #include "ephy-sync-secret.h"
 #include "ephy-sync-service.h"
-#include "ephy-sync-utils.h"
 
 #include <glib/gi18n.h>
 #include <json-glib/json-glib.h>
@@ -59,6 +58,11 @@ struct _EphySyncService {
 
 G_DEFINE_TYPE (EphySyncService, ephy_sync_service, G_TYPE_OBJECT);
 
+static gchar *
+build_json_string (const gchar *first_key,
+                   const gchar *first_value,
+                   ...) G_GNUC_NULL_TERMINATED;
+
 static guint
 synchronous_hawk_post_request (EphySyncService  *self,
                               const gchar       *endpoint,
@@ -179,6 +183,42 @@ session_destroyed_cb (SoupSession *session,
 }
 
 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;
@@ -708,10 +748,10 @@ ephy_sync_service_sign_certificate (EphySyncService *self)
 
   n_str = mpz_get_str (NULL, 10, keypair->public.n);
   e_str = mpz_get_str (NULL, 10, keypair->public.e);
-  public_key_json = ephy_sync_utils_build_json_string ("algorithm", "RS",
-                                                       "n", n_str,
-                                                       "e", e_str,
-                                                       NULL);
+  public_key_json = build_json_string ("algorithm", "RS",
+                                       "n", n_str,
+                                       "e", e_str,
+                                       NULL);
   /* The server allows a maximum certificate lifespan of 24 hours == 86400000 ms */
   request_body = g_strdup_printf ("{\"publicKey\": %s, \"duration\": 86400000}",
                                   public_key_json);


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