[glib: 1/2] gdbusproxy: Add G_DBUS_DEBUG=proxy support



commit cd7bba985e6afd08f0cfcbc603b53df5402fa2cd
Author: Richard Hughes <richard hughsie com>
Date:   Fri Jan 25 14:30:32 2019 +0000

    gdbusproxy: Add G_DBUS_DEBUG=proxy support
    
    (Turned into a merge request by Philip Withnall; unmodified from
    original patch on https://bugzilla.gnome.org/show_bug.cgi?id=654905.)
    
    https://gitlab.gnome.org/GNOME/glib/issues/424

 gio/gdbusprivate.c | 11 ++++++++++-
 gio/gdbusprivate.h |  1 +
 gio/gdbusproxy.c   | 22 ++++++++++++++--------
 3 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index b5f8b6509..c2a04ae12 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -1817,6 +1817,7 @@ _g_dbus_worker_flush_sync (GDBusWorker    *worker,
 #define G_DBUS_DEBUG_RETURN         (1<<7)
 #define G_DBUS_DEBUG_EMISSION       (1<<8)
 #define G_DBUS_DEBUG_ADDRESS        (1<<9)
+#define G_DBUS_DEBUG_PROXY          (1<<10)
 
 static gint _gdbus_debug_flags = 0;
 
@@ -1890,6 +1891,13 @@ _g_dbus_debug_address (void)
   return (_gdbus_debug_flags & G_DBUS_DEBUG_ADDRESS) != 0;
 }
 
+gboolean
+_g_dbus_debug_proxy (void)
+{
+  _g_dbus_initialize ();
+  return (_gdbus_debug_flags & G_DBUS_DEBUG_PROXY) != 0;
+}
+
 G_LOCK_DEFINE_STATIC (print_lock);
 
 void
@@ -1938,7 +1946,8 @@ _g_dbus_initialize (void)
             { "incoming",       G_DBUS_DEBUG_INCOMING       },
             { "return",         G_DBUS_DEBUG_RETURN         },
             { "emission",       G_DBUS_DEBUG_EMISSION       },
-            { "address",        G_DBUS_DEBUG_ADDRESS        }
+            { "address",        G_DBUS_DEBUG_ADDRESS        },
+            { "proxy",          G_DBUS_DEBUG_PROXY          }
           };
 
           _gdbus_debug_flags = g_parse_debug_string (debug, keys, G_N_ELEMENTS (keys));
diff --git a/gio/gdbusprivate.h b/gio/gdbusprivate.h
index 0d85c1d85..a319166ee 100644
--- a/gio/gdbusprivate.h
+++ b/gio/gdbusprivate.h
@@ -91,6 +91,7 @@ gboolean _g_dbus_debug_incoming (void);
 gboolean _g_dbus_debug_return (void);
 gboolean _g_dbus_debug_emission (void);
 gboolean _g_dbus_debug_address (void);
+gboolean _g_dbus_debug_proxy (void);
 
 void     _g_dbus_debug_print_lock (void);
 void     _g_dbus_debug_print_unlock (void);
diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c
index 6a1be4220..0ab117854 100644
--- a/gio/gdbusproxy.c
+++ b/gio/gdbusproxy.c
@@ -1235,11 +1235,14 @@ on_name_owner_changed_get_all_cb (GDBusConnection *connection,
        *
        * Either way, apps can know about this by using
        * get_cached_property_names() or get_cached_property().
-       *
-       * TODO: handle G_DBUS_DEBUG flag 'proxy' and, if enabled, log the
-       * fact that GetAll() failed
        */
-      //g_debug ("error: %d %d %s", error->domain, error->code, error->message);
+      if (G_UNLIKELY (_g_dbus_debug_proxy ()))
+        {
+          g_debug ("error: %d %d %s",
+                   error->domain,
+                   error->code,
+                   error->message);
+        }
       g_error_free (error);
     }
 
@@ -1432,11 +1435,14 @@ async_init_get_all_cb (GDBusConnection *connection,
        *
        * Either way, apps can know about this by using
        * get_cached_property_names() or get_cached_property().
-       *
-       * TODO: handle G_DBUS_DEBUG flag 'proxy' and, if enabled, log the
-       * fact that GetAll() failed
        */
-      //g_debug ("error: %d %d %s", error->domain, error->code, error->message);
+      if (G_UNLIKELY (_g_dbus_debug_proxy ()))
+        {
+          g_debug ("error: %d %d %s",
+                   error->domain,
+                   error->code,
+                   error->message);
+        }
       g_error_free (error);
     }
 


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