aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_context.c')
-rw-r--r--src/gnunet_chat_context.c25
1 files changed, 25 insertions, 0 deletions
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 @@
28 28
29struct GNUNET_CHAT_Context* 29struct GNUNET_CHAT_Context*
30context_create (struct GNUNET_CHAT_Handle *handle, 30context_create (struct GNUNET_CHAT_Handle *handle,
31 enum GNUNET_CHAT_ContextType type,
31 const struct GNUNET_HashCode *key) 32 const struct GNUNET_HashCode *key)
32{ 33{
33 struct GNUNET_MESSENGER_Handle *messenger = handle->handles.messenger; 34 struct GNUNET_MESSENGER_Handle *messenger = handle->handles.messenger;
@@ -60,7 +61,9 @@ context_create (struct GNUNET_CHAT_Handle *handle,
60 context->handle = handle; 61 context->handle = handle;
61 context->room = room; 62 context->room = room;
62 63
64 context->type = type;
63 GNUNET_memcpy(&(context->key), room_key, sizeof(_room_key)); 65 GNUNET_memcpy(&(context->key), room_key, sizeof(_room_key));
66 context->nick = NULL;
64 67
65 return context; 68 return context;
66} 69}
@@ -71,12 +74,34 @@ context_destroy (struct GNUNET_CHAT_Context* context)
71 GNUNET_free(context); 74 GNUNET_free(context);
72} 75}
73 76
77enum GNUNET_CHAT_ContextType
78context_get_type (struct GNUNET_CHAT_Context* context)
79{
80 return context->type;
81}
82
74const struct GNUNET_HashCode* 83const struct GNUNET_HashCode*
75context_get_key (struct GNUNET_CHAT_Context* context) 84context_get_key (struct GNUNET_CHAT_Context* context)
76{ 85{
77 return &(context->key); 86 return &(context->key);
78} 87}
79 88
89const char*
90context_get_nick (struct GNUNET_CHAT_Context* context)
91{
92 return context->nick;
93}
94
95void
96context_set_nick (struct GNUNET_CHAT_Context* context,
97 const char *nick)
98{
99 if (context->nick)
100 GNUNET_free(context->nick);
101
102 context->nick = nick? GNUNET_strdup(nick) : NULL;
103}
104
80void 105void
81GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context, 106GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context,
82 const char *text) 107 const char *text)