[epiphany/wip/ephy-sync] Use LOG instead of g_printf



commit 75b3a16c7ec9f702ea73314ee548e1dcd7b06dc4
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date:   Fri Jun 10 00:18:52 2016 +0300

    Use LOG instead of g_printf

 src/ephy-sync-crypto.c  |   13 +++++--------
 src/ephy-sync-crypto.h  |    1 +
 src/ephy-sync-service.c |   25 +++++++++++--------------
 src/ephy-sync-window.c  |   21 ++++++++++-----------
 4 files changed, 27 insertions(+), 33 deletions(-)
---
diff --git a/src/ephy-sync-crypto.c b/src/ephy-sync-crypto.c
index edddf8f..056c7ce 100644
--- a/src/ephy-sync-crypto.c
+++ b/src/ephy-sync-crypto.c
@@ -16,9 +16,9 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "ephy-debug.h"
 #include "ephy-sync-crypto.h"
 
-#include <glib/gstdio.h>
 #include <nettle/hmac.h>
 #include <nettle/pbkdf2.h>
 #include <string.h>
@@ -129,16 +129,13 @@ ephy_sync_crypto_hkdf (guint8 *in,
   g_free (prk);
 }
 
+/* FIXME: Only for debugging, remove when no longer needed */
 void
 ephy_sync_crypto_display_hex (guint8      *data,
                               gsize        data_length,
                               const gchar *data_name)
 {
-  g_printf ("%s:\n", data_name);
-  for (gsize i = 0; i < data_length; i++) {
-    g_printf ("%02x", data[i]);
-    if ((i + 1) % 8 == 0)
-      g_printf ("\n");
-  }
-  g_printf ("\n");
+LOG ("%s:", data_name);
+for (gsize i = 0; i < data_length; i++)
+  LOG ("%02x", data[i]);
 }
diff --git a/src/ephy-sync-crypto.h b/src/ephy-sync-crypto.h
index 7b7d1d0..7b4cb06 100644
--- a/src/ephy-sync-crypto.h
+++ b/src/ephy-sync-crypto.h
@@ -42,6 +42,7 @@ void   ephy_sync_crypto_hkdf        (guint8 *in,
                                      gsize   info_length,
                                      guint8 *out,
                                      gsize   out_length);
+/* FIXME: Only for debugging, remove when no longer needed */
 void   ephy_sync_crypto_display_hex (guint8      *data,
                                      gsize        data_length,
                                      const gchar *data_name);
diff --git a/src/ephy-sync-service.c b/src/ephy-sync-service.c
index a2d28af..d4b8bf9 100644
--- a/src/ephy-sync-service.c
+++ b/src/ephy-sync-service.c
@@ -1,12 +1,10 @@
+#include "ephy-debug.h"
 #include "ephy-sync-crypto.h"
 #include "ephy-sync-service.h"
 
-#include <string.h>
-#include <glib/gstdio.h>
 #include <json-glib/json-glib.h>
 #include <libsoup/soup.h>
-#include <nettle/hmac.h>
-#include <nettle/pbkdf2.h>
+#include <string.h>
 
 struct _EphySyncService {
   GObject parent_instance;
@@ -20,7 +18,7 @@ ephy_sync_service_class_init (EphySyncServiceClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   object_class = object_class; // suppress warnings
 
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+LOG ("%s:%d", __func__, __LINE__);
 
   // TODO: Set finalize, dispose, set/get property methods
 }
@@ -28,7 +26,7 @@ ephy_sync_service_class_init (EphySyncServiceClass *klass)
 static void
 ephy_sync_service_init (EphySyncService *self)
 {
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+LOG ("%s:%d", __func__, __LINE__);
 }
 
 static void
@@ -36,20 +34,18 @@ server_response_cb (SoupSession *session,
                     SoupMessage *message,
                     gpointer user_data)
 {
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
-
   if (message->status_code == 200) {
-    g_printf ("response body: %s\n", message->response_body->data);
+LOG ("response body: %s", message->response_body->data);
     // TODO: parse response data using JsonParser
   } else {
-    g_printerr ("Error response from server: [%u] %s\n", message->status_code, message->reason_phrase);
+LOG ("Error response from server: [%u] %s", message->status_code, message->reason_phrase);
   }
 }
 
 EphySyncService *
 ephy_sync_service_new (void)
 {
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+LOG ("%s:%d", __func__, __LINE__);
 
   return EPHY_SYNC_SERVICE (g_object_new (EPHY_TYPE_SYNC_SERVICE,
                                           NULL));
@@ -69,7 +65,8 @@ ephy_sync_service_try_login (EphySyncService *self,
   char *authPW_hex;
 
   g_return_if_fail (EPHY_IS_SYNC_SERVICE (self));
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+
+LOG ("%s:%d", __func__, __LINE__);
 
   session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT,
                                            "test-json",
@@ -111,7 +108,7 @@ ephy_sync_service_stretch (EphySyncService *self,
 
   g_return_if_fail (EPHY_IS_SYNC_SERVICE (self));
 
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+LOG ("%s:%d", __func__, __LINE__);
 
   salt_stretch = ephy_sync_crypto_kwe ("quickStretch", emailUTF8);
   quickStretchedPW = g_malloc (EPHY_SYNC_SERVICE_TOKEN_LENGTH);
@@ -122,7 +119,7 @@ ephy_sync_service_stretch (EphySyncService *self,
                               quickStretchedPW,
                               EPHY_SYNC_SERVICE_TOKEN_LENGTH);
 
-  ephy_sync_crypto_display_hex (quickStretchedPW, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "quickStretchedPW");
+ephy_sync_crypto_display_hex (quickStretchedPW, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "quickStretchedPW");
 
   info_auth = ephy_sync_crypto_kw ("authPW");
   ephy_sync_crypto_hkdf (quickStretchedPW,
diff --git a/src/ephy-sync-window.c b/src/ephy-sync-window.c
index 0e9d2d8..7be85b0 100644
--- a/src/ephy-sync-window.c
+++ b/src/ephy-sync-window.c
@@ -1,9 +1,9 @@
+#include "ephy-debug.h"
 #include "ephy-gui.h"
 #include "ephy-sync-crypto.h"
 #include "ephy-sync-service.h"
 #include "ephy-sync-window.h"
 
-#include <glib/gstdio.h>
 #include <gtk/gtk.h>
 #include <string.h>
 
@@ -42,12 +42,11 @@ submit_action (GSimpleAction *action,
   guint8 *sessionToken;
   guint8 *keyFetchToken;
   EphySyncWindow *self = EPHY_SYNC_WINDOW (user_data);
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
 
   emailUTF8 = gtk_entry_get_text (GTK_ENTRY (self->entry_email));
+LOG ("email: %s", emailUTF8);
   passwordUTF8 = gtk_entry_get_text (GTK_ENTRY (self->entry_password));
-  g_printf ("email: %s\n", emailUTF8);
-  g_printf ("password: %s\n", passwordUTF8);
+LOG ("password: %s", passwordUTF8);
 
   /* Only for easy testing */
   if (!strlen (emailUTF8) && !strlen (passwordUTF8)) {
@@ -62,8 +61,8 @@ submit_action (GSimpleAction *action,
                              passwordUTF8,
                              authPW,
                              unwrapBKey);
-  ephy_sync_crypto_display_hex (authPW, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "authPW");
-  ephy_sync_crypto_display_hex (unwrapBKey, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "unwrapBKey");
+ephy_sync_crypto_display_hex (authPW, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "authPW");
+ephy_sync_crypto_display_hex (unwrapBKey, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "unwrapBKey");
 
   sessionToken = g_malloc (EPHY_SYNC_SERVICE_TOKEN_LENGTH);
   keyFetchToken = g_malloc (EPHY_SYNC_SERVICE_TOKEN_LENGTH);
@@ -73,8 +72,8 @@ submit_action (GSimpleAction *action,
                                authPW,
                                sessionToken,
                                keyFetchToken);
-  ephy_sync_crypto_display_hex (sessionToken, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "sessionToken");
-  ephy_sync_crypto_display_hex (keyFetchToken, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "keyFetchToken");
+ephy_sync_crypto_display_hex (sessionToken, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "sessionToken");
+ephy_sync_crypto_display_hex (keyFetchToken, EPHY_SYNC_SERVICE_TOKEN_LENGTH, "keyFetchToken");
 
   g_free (authPW);
   g_free (unwrapBKey);
@@ -157,7 +156,7 @@ ephy_sync_window_class_init (EphySyncWindowClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+LOG ("%s:%d", __func__, __LINE__);
 
   object_class->set_property = ephy_sync_window_set_property;
   object_class->get_property = ephy_sync_window_get_property;
@@ -183,7 +182,7 @@ ephy_sync_window_class_init (EphySyncWindowClass *klass)
 static void
 ephy_sync_window_init (EphySyncWindow *self)
 {
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+LOG ("%s:%d", __func__, __LINE__);
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
@@ -200,7 +199,7 @@ ephy_sync_window_new (EphySyncService *sync_service)
 {
   EphySyncWindow *self;
 
-  g_printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+LOG ("%s:%d", __func__, __LINE__);
 
   self = g_object_new (EPHY_TYPE_SYNC_WINDOW,
                        "use-header-bar", TRUE,


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