From 48d7c44fd4cac8fac3f657e1621e570f5d80324a Mon Sep 17 00:00:00 2001
From: George Kiagiadakis <george.kiagiadakis@collabora.com>
Date: Tue, 5 May 2020 16:29:17 +0300
Subject: [PATCH] link: add method to get object ids

---
 lib/wp/link.c | 29 +++++++++++++++++++++++++++++
 lib/wp/link.h |  5 +++++
 2 files changed, 34 insertions(+)

diff --git a/lib/wp/link.c b/lib/wp/link.c
index 5ea9e1be..157cb155 100644
--- a/lib/wp/link.c
+++ b/lib/wp/link.c
@@ -146,3 +146,32 @@ wp_link_new_from_factory (WpCore * core,
           props ? wp_properties_peek_dict (props) : NULL, 0));
   return self;
 }
+
+/**
+ * wp_link_get_linked_object_ids:
+ * @self: the link
+ * @output_node: (out) (optional): the bound id of the output (source) node
+ * @output_port: (out) (optional): the bound id of the output (source) port
+ * @input_node: (out) (optional): the bound id of the input (sink) node
+ * @input_port: (out) (optional): the bound id of the input (sink) port
+ *
+ * Retrieves the ids of the objects that are linked by this link
+ *
+ * Note: Using this method requires %WP_PROXY_FEATURE_INFO
+ */
+void
+wp_link_get_linked_object_ids (WpLink * self,
+    guint32 * output_node, guint32 * output_port,
+    guint32 * input_node, guint32 * input_port)
+{
+  g_return_if_fail (WP_IS_LINK (self));
+
+  if (output_node)
+    *output_node = self->info->output_node_id;
+  if (output_port)
+    *output_port = self->info->output_port_id;
+  if (input_node)
+    *input_node = self->info->input_node_id;
+  if (input_port)
+    *input_port = self->info->input_port_id;
+}
diff --git a/lib/wp/link.h b/lib/wp/link.h
index f0d5cb3c..a9b294d0 100644
--- a/lib/wp/link.h
+++ b/lib/wp/link.h
@@ -26,6 +26,11 @@ WP_API
 WpLink * wp_link_new_from_factory (WpCore * core,
     const gchar * factory_name, WpProperties * properties);
 
+WP_API
+void wp_link_get_linked_object_ids (WpLink * self,
+    guint32 * output_node, guint32 * output_port,
+    guint32 * input_node, guint32 * input_port);
+
 G_END_DECLS
 
 #endif
-- 
GitLab