From 5200796f0fe43ba498eaa7ea5c81e46cdc2d8116 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Mon, 21 Jun 2021 14:22:07 +0200 Subject: First refinements of the overall API Signed-off-by: TheJackiMonster --- src/gnunet_chat_context.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/gnunet_chat_context.c') diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c index e4bbe45..3124ded 100644 --- a/src/gnunet_chat_context.c +++ b/src/gnunet_chat_context.c @@ -28,6 +28,7 @@ struct GNUNET_CHAT_Context* context_create (struct GNUNET_CHAT_Handle *handle, + enum GNUNET_CHAT_ContextType type, const struct GNUNET_HashCode *key) { struct GNUNET_MESSENGER_Handle *messenger = handle->handles.messenger; @@ -60,7 +61,9 @@ context_create (struct GNUNET_CHAT_Handle *handle, context->handle = handle; context->room = room; + context->type = type; GNUNET_memcpy(&(context->key), room_key, sizeof(_room_key)); + context->nick = NULL; return context; } @@ -71,12 +74,34 @@ context_destroy (struct GNUNET_CHAT_Context* context) GNUNET_free(context); } +enum GNUNET_CHAT_ContextType +context_get_type (struct GNUNET_CHAT_Context* context) +{ + return context->type; +} + const struct GNUNET_HashCode* context_get_key (struct GNUNET_CHAT_Context* context) { return &(context->key); } +const char* +context_get_nick (struct GNUNET_CHAT_Context* context) +{ + return context->nick; +} + +void +context_set_nick (struct GNUNET_CHAT_Context* context, + const char *nick) +{ + if (context->nick) + GNUNET_free(context->nick); + + context->nick = nick? GNUNET_strdup(nick) : NULL; +} + void GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context, const char *text) -- cgit v1.2.3