commit f1b39ac37e9215dfff1c6a3a68325bda8f790dbe
parent 0cdae5ab6c61f15f0dfb745d2322578438b300c5
Author: Jacki <jacki@thejackimonster.de>
Date: Thu, 20 Jun 2024 02:24:14 +0200
Add user pointers to discourse handles
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
4 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/include/gnunet/gnunet_chat_lib.h b/include/gnunet/gnunet_chat_lib.h
@@ -1844,6 +1844,27 @@ enum GNUNET_GenericReturnValue
GNUNET_CHAT_discourse_is_open (const struct GNUNET_CHAT_Discourse *discourse);
/**
+ * Sets a custom <i>user pointer</i> to a given chat <i>discourse</i> so it can
+ * be accessed in chat discourse related callbacks.
+ *
+ * @param[in,out] discourse Chat discourse
+ * @param[in] user_pointer Custom user pointer
+ */
+void
+GNUNET_CHAT_discourse_set_user_pointer (struct GNUNET_CHAT_Discourse *discourse,
+ void *user_pointer);
+
+/**
+ * Returns the custom user pointer of a given chat <i>discourse</i> or NULL if it
+ * was not set any.
+ *
+ * @param[in] discourse Chat discourse
+ * @return Custom user pointer or NULL
+ */
+void*
+GNUNET_CHAT_discourse_get_user_pointer (const struct GNUNET_CHAT_Discourse *discourse);
+
+/**
* Closes a given chat <i>discourse</i> to stop receiving any data messages
* from the specific discourse.
*
diff --git a/src/gnunet_chat_discourse.c b/src/gnunet_chat_discourse.c
@@ -42,6 +42,8 @@ discourse_create (struct GNUNET_CHAT_Context *context,
discourse->head = NULL;
discourse->tail = NULL;
+ discourse->user_pointer = NULL;
+
return discourse;
}
diff --git a/src/gnunet_chat_discourse.h b/src/gnunet_chat_discourse.h
@@ -57,6 +57,8 @@ struct GNUNET_CHAT_Discourse
struct GNUNET_CHAT_DiscourseSubscription *head;
struct GNUNET_CHAT_DiscourseSubscription *tail;
+
+ void *user_pointer;
};
/**
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
@@ -2932,6 +2932,31 @@ GNUNET_CHAT_discourse_is_open (const struct GNUNET_CHAT_Discourse *discourse)
void
+GNUNET_CHAT_discourse_set_user_pointer (struct GNUNET_CHAT_Discourse *discourse,
+ void *user_pointer)
+{
+ GNUNET_CHAT_VERSION_ASSERT();
+
+ if (!discourse)
+ return;
+
+ discourse->user_pointer = user_pointer;
+}
+
+
+void*
+GNUNET_CHAT_discourse_get_user_pointer (const struct GNUNET_CHAT_Discourse *discourse)
+{
+ GNUNET_CHAT_VERSION_ASSERT();
+
+ if (!discourse)
+ return NULL;
+
+ return discourse->user_pointer;
+}
+
+
+void
GNUNET_CHAT_discourse_close (struct GNUNET_CHAT_Discourse *discourse)
{
GNUNET_CHAT_VERSION_ASSERT();