aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_lib.c')
-rw-r--r--src/gnunet_chat_lib.c108
1 files changed, 106 insertions, 2 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index 044a1be..f455549 100644
--- a/src/gnunet_chat_lib.c
+++ b/src/gnunet_chat_lib.c
@@ -55,6 +55,7 @@ GNUNET_CHAT_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
55 ); 55 );
56} 56}
57 57
58
58void 59void
59GNUNET_CHAT_stop (struct GNUNET_CHAT_Handle *handle) 60GNUNET_CHAT_stop (struct GNUNET_CHAT_Handle *handle)
60{ 61{
@@ -64,6 +65,7 @@ GNUNET_CHAT_stop (struct GNUNET_CHAT_Handle *handle)
64 handle_destroy(handle); 65 handle_destroy(handle);
65} 66}
66 67
68
67int 69int
68GNUNET_CHAT_update (struct GNUNET_CHAT_Handle *handle) 70GNUNET_CHAT_update (struct GNUNET_CHAT_Handle *handle)
69{ 71{
@@ -73,6 +75,7 @@ GNUNET_CHAT_update (struct GNUNET_CHAT_Handle *handle)
73 return GNUNET_MESSENGER_update(handle->messenger); 75 return GNUNET_MESSENGER_update(handle->messenger);
74} 76}
75 77
78
76int 79int
77GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle, 80GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle,
78 const char *name) 81 const char *name)
@@ -86,6 +89,7 @@ GNUNET_CHAT_set_name (struct GNUNET_CHAT_Handle *handle,
86 return GNUNET_MESSENGER_set_name(handle->messenger, name); 89 return GNUNET_MESSENGER_set_name(handle->messenger, name);
87} 90}
88 91
92
89const char* 93const char*
90GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle) 94GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle)
91{ 95{
@@ -95,6 +99,7 @@ GNUNET_CHAT_get_name (const struct GNUNET_CHAT_Handle *handle)
95 return GNUNET_MESSENGER_get_name(handle->messenger); 99 return GNUNET_MESSENGER_get_name(handle->messenger);
96} 100}
97 101
102
98const struct GNUNET_IDENTITY_PublicKey* 103const struct GNUNET_IDENTITY_PublicKey*
99GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle) 104GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle)
100{ 105{
@@ -104,6 +109,28 @@ GNUNET_CHAT_get_key (const struct GNUNET_CHAT_Handle *handle)
104 return GNUNET_MESSENGER_get_key(handle->messenger); 109 return GNUNET_MESSENGER_get_key(handle->messenger);
105} 110}
106 111
112
113void
114GNUNET_CHAT_set_user_pointer (struct GNUNET_CHAT_Handle *handle,
115 void *user_pointer)
116{
117 if (!handle)
118 return;
119
120 handle->user_pointer = user_pointer;
121}
122
123
124void*
125GNUNET_CHAT_get_user_pointer (const struct GNUNET_CHAT_Handle *handle)
126{
127 if (!handle)
128 return NULL;
129
130 return handle->user_pointer;
131}
132
133
107int 134int
108GNUNET_CHAT_iterate_contacts (struct GNUNET_CHAT_Handle *handle, 135GNUNET_CHAT_iterate_contacts (struct GNUNET_CHAT_Handle *handle,
109 GNUNET_CHAT_ContactCallback callback, 136 GNUNET_CHAT_ContactCallback callback,
@@ -122,6 +149,7 @@ GNUNET_CHAT_iterate_contacts (struct GNUNET_CHAT_Handle *handle,
122 ); 149 );
123} 150}
124 151
152
125struct GNUNET_CHAT_Group * 153struct GNUNET_CHAT_Group *
126GNUNET_CHAT_group_create (struct GNUNET_CHAT_Handle *handle, 154GNUNET_CHAT_group_create (struct GNUNET_CHAT_Handle *handle,
127 const char* topic) 155 const char* topic)
@@ -174,6 +202,7 @@ destroy_context:
174 return NULL; 202 return NULL;
175} 203}
176 204
205
177int 206int
178GNUNET_CHAT_iterate_groups (struct GNUNET_CHAT_Handle *handle, 207GNUNET_CHAT_iterate_groups (struct GNUNET_CHAT_Handle *handle,
179 GNUNET_CHAT_GroupCallback callback, 208 GNUNET_CHAT_GroupCallback callback,
@@ -192,6 +221,7 @@ GNUNET_CHAT_iterate_groups (struct GNUNET_CHAT_Handle *handle,
192 ); 221 );
193} 222}
194 223
224
195int 225int
196GNUNET_CHAT_contact_delete (struct GNUNET_CHAT_Contact *contact) 226GNUNET_CHAT_contact_delete (struct GNUNET_CHAT_Contact *contact)
197{ 227{
@@ -220,6 +250,7 @@ GNUNET_CHAT_contact_delete (struct GNUNET_CHAT_Contact *contact)
220 return GNUNET_OK; 250 return GNUNET_OK;
221} 251}
222 252
253
223void 254void
224GNUNET_CHAT_contact_set_name (struct GNUNET_CHAT_Contact *contact, 255GNUNET_CHAT_contact_set_name (struct GNUNET_CHAT_Contact *contact,
225 const char *name) 256 const char *name)
@@ -264,6 +295,27 @@ GNUNET_CHAT_contact_get_context (struct GNUNET_CHAT_Contact *contact)
264} 295}
265 296
266 297
298void
299GNUNET_CHAT_contact_set_user_pointer (struct GNUNET_CHAT_Contact *contact,
300 void *user_pointer)
301{
302 if (!contact)
303 return;
304
305 contact->user_pointer = user_pointer;
306}
307
308
309void*
310GNUNET_CHAT_contact_get_user_pointer (struct GNUNET_CHAT_Contact *contact)
311{
312 if (!contact)
313 return NULL;
314
315 return contact->user_pointer;
316}
317
318
267int 319int
268GNUNET_CHAT_group_leave (struct GNUNET_CHAT_Group *group) 320GNUNET_CHAT_group_leave (struct GNUNET_CHAT_Group *group)
269{ 321{
@@ -312,6 +364,27 @@ GNUNET_CHAT_group_get_name (const struct GNUNET_CHAT_Group *group)
312 364
313 365
314void 366void
367GNUNET_CHAT_group_set_user_pointer (struct GNUNET_CHAT_Group *group,
368 void *user_pointer)
369{
370 if (!group)
371 return;
372
373 group->user_pointer = user_pointer;
374}
375
376
377void*
378GNUNET_CHAT_group_get_user_pointer (struct GNUNET_CHAT_Group *group)
379{
380 if (!group)
381 return NULL;
382
383 return group->user_pointer;
384}
385
386
387void
315GNUNET_CHAT_group_invite_contact (struct GNUNET_CHAT_Group *group, 388GNUNET_CHAT_group_invite_contact (struct GNUNET_CHAT_Group *group,
316 struct GNUNET_CHAT_Contact *contact) 389 struct GNUNET_CHAT_Contact *contact)
317{ 390{
@@ -362,6 +435,27 @@ GNUNET_CHAT_group_get_context (struct GNUNET_CHAT_Group *group)
362} 435}
363 436
364 437
438void
439GNUNET_CHAT_context_set_user_pointer (struct GNUNET_CHAT_Context *context,
440 void *user_pointer)
441{
442 if (!context)
443 return;
444
445 context->user_pointer = user_pointer;
446}
447
448
449void*
450GNUNET_CHAT_context_get_user_pointer (const struct GNUNET_CHAT_Context *context)
451{
452 if (!context)
453 return NULL;
454
455 return context->user_pointer;
456}
457
458
365int 459int
366GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context, 460GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context,
367 const char *text) 461 const char *text)
@@ -521,12 +615,22 @@ GNUNET_CHAT_message_get_kind (const struct GNUNET_CHAT_Message *message)
521 615
522 switch (message->msg->header.kind) 616 switch (message->msg->header.kind)
523 { 617 {
618 case GNUNET_MESSENGER_KIND_JOIN:
619 return GNUNET_CHAT_KIND_JOIN;
620 case GNUNET_MESSENGER_KIND_LEAVE:
621 return GNUNET_CHAT_KIND_LEAVE;
622 case GNUNET_MESSENGER_KIND_NAME:
623 case GNUNET_MESSENGER_KIND_KEY:
624 case GNUNET_MESSENGER_KIND_ID:
625 return GNUNET_CHAT_KIND_CONTACT;
524 case GNUNET_MESSENGER_KIND_INVITE: 626 case GNUNET_MESSENGER_KIND_INVITE:
525 return GNUNET_CHAT_KIND_INVITATION; 627 return GNUNET_CHAT_KIND_INVITATION;
526 case GNUNET_MESSENGER_KIND_TEXT: 628 case GNUNET_MESSENGER_KIND_TEXT:
527 return GNUNET_CHAT_KIND_TEXT; 629 return GNUNET_CHAT_KIND_TEXT;
528 case GNUNET_MESSENGER_KIND_FILE: 630 case GNUNET_MESSENGER_KIND_FILE:
529 return GNUNET_CHAT_KIND_FILE; 631 return GNUNET_CHAT_KIND_FILE;
632 case GNUNET_MESSENGER_KIND_DELETE:
633 return GNUNET_CHAT_KIND_DELETION;
530 default: 634 default:
531 return GNUNET_CHAT_KIND_UNKNOWN; 635 return GNUNET_CHAT_KIND_UNKNOWN;
532 } 636 }
@@ -633,8 +737,8 @@ GNUNET_CHAT_message_delete (const struct GNUNET_CHAT_Message *message,
633 737
634 struct GNUNET_MESSENGER_Message msg; 738 struct GNUNET_MESSENGER_Message msg;
635 msg.header.kind = GNUNET_MESSENGER_KIND_DELETE; 739 msg.header.kind = GNUNET_MESSENGER_KIND_DELETE;
636 GNUNET_memcpy(&(msg.body.delete.hash), &(message->hash), sizeof(message->hash)); 740 GNUNET_memcpy(&(msg.body.deletion.hash), &(message->hash), sizeof(message->hash));
637 msg.body.delete.delay = GNUNET_TIME_relative_hton(delay); 741 msg.body.deletion.delay = GNUNET_TIME_relative_hton(delay);
638 742
639 GNUNET_MESSENGER_send_message(message->context->room, &msg, NULL); 743 GNUNET_MESSENGER_send_message(message->context->room, &msg, NULL);
640 return GNUNET_OK; 744 return GNUNET_OK;