[glib: 1/3] gdbusconnection: add a getter for the flags property



commit 7d02e326441bed7fcf03a4e51f4046ea22256a82
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Dec 19 16:33:50 2018 -0800

    gdbusconnection: add a getter for the flags property
    
    Right now this can only be set at construction but not read back.
    That seems unnecessarily restrictive, and we'll need to read these
    flags from outside of gdbusconnection.c in the next commit, so let's
    just make it public.
    
    https://gitlab.gnome.org/GNOME/glib/issues/1620

 docs/reference/gio/gio-sections.txt |  1 +
 gio/gdbusconnection.c               | 27 +++++++++++++++++++++++++++
 gio/gdbusconnection.h               |  2 ++
 3 files changed, 30 insertions(+)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index e795b3cf3..1fe37e488 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -2967,6 +2967,7 @@ g_dbus_connection_flush_sync
 g_dbus_connection_get_exit_on_close
 g_dbus_connection_set_exit_on_close
 g_dbus_connection_get_stream
+g_dbus_connection_get_flags
 g_dbus_connection_get_guid
 g_dbus_connection_get_unique_name
 GDBusCapabilityFlags
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index 31c827b15..677fa76f9 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -728,6 +728,10 @@ g_dbus_connection_get_property (GObject    *object,
       g_value_set_flags (value, g_dbus_connection_get_capabilities (connection));
       break;
 
+    case PROP_FLAGS:
+      g_value_set_flags (value, g_dbus_connection_get_flags (connection));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -874,6 +878,7 @@ g_dbus_connection_class_init (GDBusConnectionClass *klass)
                                                        P_("Flags"),
                                                        G_TYPE_DBUS_CONNECTION_FLAGS,
                                                        G_DBUS_CONNECTION_FLAGS_NONE,
+                                                       G_PARAM_READABLE |
                                                        G_PARAM_WRITABLE |
                                                        G_PARAM_CONSTRUCT_ONLY |
                                                        G_PARAM_STATIC_NAME |
@@ -1186,6 +1191,28 @@ g_dbus_connection_get_capabilities (GDBusConnection *connection)
   return connection->capabilities;
 }
 
+/**
+ * g_dbus_connection_get_flags:
+ * @connection: a #GDBusConnection
+ *
+ * Gets the flags used to construct this connection
+ *
+ * Returns: zero or more flags from the #GDBusConnectionFlags enumeration
+ *
+ * Since: 2.60
+ */
+GDBusConnectionFlags
+g_dbus_connection_get_flags (GDBusConnection *connection)
+{
+  g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), G_DBUS_CONNECTION_FLAGS_NONE);
+
+  /* do not use g_return_val_if_fail(), we want the memory barrier */
+  if (!check_initialized (connection))
+    return G_DBUS_CONNECTION_FLAGS_NONE;
+
+  return connection->flags;
+}
+
 /* ---------------------------------------------------------------------------------------------------- */
 
 /* Called in a temporary thread without holding locks. */
diff --git a/gio/gdbusconnection.h b/gio/gdbusconnection.h
index b2c50354d..c37363c0d 100644
--- a/gio/gdbusconnection.h
+++ b/gio/gdbusconnection.h
@@ -114,6 +114,8 @@ void             g_dbus_connection_set_exit_on_close          (GDBusConnection
                                                                gboolean            exit_on_close);
 GLIB_AVAILABLE_IN_ALL
 GDBusCapabilityFlags  g_dbus_connection_get_capabilities      (GDBusConnection    *connection);
+GLIB_AVAILABLE_IN_2_60
+GDBusConnectionFlags  g_dbus_connection_get_flags             (GDBusConnection    *connection);
 
 /* ---------------------------------------------------------------------------------------------------- */
 


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