From a1f47d0627f1911258ddb653f704bb2053b96dfa Mon Sep 17 00:00:00 2001
From: George Kiagiadakis <george.kiagiadakis@collabora.com>
Date: Tue, 31 Mar 2020 19:26:05 +0300
Subject: [PATCH] session-item: add _get_associated_proxy_id method

To ease the use case where we are only interested in the id
and not the proxy object itself
---
 lib/wp/session-item.c | 19 +++++++++++++++++++
 lib/wp/session-item.h |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/lib/wp/session-item.c b/lib/wp/session-item.c
index 10aef8a9..5d5db7bc 100644
--- a/lib/wp/session-item.c
+++ b/lib/wp/session-item.c
@@ -498,6 +498,25 @@ wp_session_item_get_associated_proxy (WpSessionItem * self, GType proxy_type)
   return WP_SESSION_ITEM_GET_CLASS (self)->get_associated_proxy (self, proxy_type);
 }
 
+/**
+ * wp_session_item_get_associated_proxy_id:
+ * @self: the session item
+ * @proxy_type: a #WpProxy subclass #GType
+ *
+ * Returns: the bound id of the associated proxy of the specified @proxy_type,
+ *   or `SPA_ID_INVALID` if there is no association to such a proxy
+ */
+guint32
+wp_session_item_get_associated_proxy_id (WpSessionItem * self, GType proxy_type)
+{
+  g_autoptr (WpProxy) proxy = wp_session_item_get_associated_proxy (self,
+      proxy_type);
+  if (!proxy)
+    return SPA_ID_INVALID;
+
+  return wp_proxy_get_bound_id (proxy);
+}
+
 /**
  * wp_session_item_configure: (virtual configure)
  * @self: the session item
diff --git a/lib/wp/session-item.h b/lib/wp/session-item.h
index 96cf638c..92efd2cb 100644
--- a/lib/wp/session-item.h
+++ b/lib/wp/session-item.h
@@ -117,6 +117,10 @@ WP_API
 gpointer wp_session_item_get_associated_proxy (WpSessionItem * self,
     GType proxy_type);
 
+WP_API
+guint32 wp_session_item_get_associated_proxy_id (WpSessionItem * self,
+    GType proxy_type);
+
 /* configuration */
 
 WP_API
-- 
GitLab