diff options
Diffstat (limited to 'src/gnunet_chat_handle.c')
-rw-r--r-- | src/gnunet_chat_handle.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c index 732dfbd..5205aa9 100644 --- a/src/gnunet_chat_handle.c +++ b/src/gnunet_chat_handle.c | |||
@@ -58,6 +58,7 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg, | |||
58 | 58 | ||
59 | handle->current = NULL; | 59 | handle->current = NULL; |
60 | handle->creation_op = NULL; | 60 | handle->creation_op = NULL; |
61 | handle->monitor = NULL; | ||
61 | 62 | ||
62 | handle->files = NULL; | 63 | handle->files = NULL; |
63 | handle->contexts = NULL; | 64 | handle->contexts = NULL; |
@@ -78,6 +79,10 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg, | |||
78 | handle | 79 | handle |
79 | ); | 80 | ); |
80 | 81 | ||
82 | handle->namestore = GNUNET_NAMESTORE_connect( | ||
83 | handle->cfg | ||
84 | ); | ||
85 | |||
81 | handle->fs = NULL; | 86 | handle->fs = NULL; |
82 | handle->messenger = NULL; | 87 | handle->messenger = NULL; |
83 | 88 | ||
@@ -114,12 +119,18 @@ handle_destroy (struct GNUNET_CHAT_Handle *handle) | |||
114 | if (handle->shutdown_hook) | 119 | if (handle->shutdown_hook) |
115 | GNUNET_SCHEDULER_cancel(handle->shutdown_hook); | 120 | GNUNET_SCHEDULER_cancel(handle->shutdown_hook); |
116 | 121 | ||
122 | if (handle->monitor) | ||
123 | GNUNET_NAMESTORE_zone_monitor_stop(handle->monitor); | ||
124 | |||
117 | if (handle->creation_op) | 125 | if (handle->creation_op) |
118 | GNUNET_IDENTITY_cancel(handle->creation_op); | 126 | GNUNET_IDENTITY_cancel(handle->creation_op); |
119 | 127 | ||
120 | if (handle->current) | 128 | if (handle->current) |
121 | handle_disconnect(handle); | 129 | handle_disconnect(handle); |
122 | 130 | ||
131 | if (handle->namestore) | ||
132 | GNUNET_NAMESTORE_disconnect(handle->namestore); | ||
133 | |||
123 | if (handle->identity) | 134 | if (handle->identity) |
124 | GNUNET_IDENTITY_disconnect(handle->identity); | 135 | GNUNET_IDENTITY_disconnect(handle->identity); |
125 | 136 | ||
@@ -177,6 +188,12 @@ handle_connect (struct GNUNET_CHAT_Handle *handle, | |||
177 | (!(handle->contexts)) && | 188 | (!(handle->contexts)) && |
178 | (!(handle->files))); | 189 | (!(handle->files))); |
179 | 190 | ||
191 | if (handle->monitor) | ||
192 | { | ||
193 | GNUNET_NAMESTORE_zone_monitor_stop(handle->monitor); | ||
194 | handle->monitor = NULL; | ||
195 | } | ||
196 | |||
180 | handle->files = GNUNET_CONTAINER_multihashmap_create(8, GNUNET_NO); | 197 | handle->files = GNUNET_CONTAINER_multihashmap_create(8, GNUNET_NO); |
181 | handle->contexts = GNUNET_CONTAINER_multihashmap_create(8, GNUNET_NO); | 198 | handle->contexts = GNUNET_CONTAINER_multihashmap_create(8, GNUNET_NO); |
182 | handle->contacts = GNUNET_CONTAINER_multishortmap_create(8, GNUNET_NO); | 199 | handle->contacts = GNUNET_CONTAINER_multishortmap_create(8, GNUNET_NO); |
@@ -274,6 +291,19 @@ handle_get_directory (const struct GNUNET_CHAT_Handle *handle) | |||
274 | return handle->current->directory; | 291 | return handle->current->directory; |
275 | } | 292 | } |
276 | 293 | ||
294 | const struct GNUNET_IDENTITY_PrivateKey* | ||
295 | handle_get_key (const struct GNUNET_CHAT_Handle *handle) | ||
296 | { | ||
297 | GNUNET_assert(handle); | ||
298 | |||
299 | if ((!(handle->current)) || (!(handle->current->ego))) | ||
300 | return NULL; | ||
301 | |||
302 | return GNUNET_IDENTITY_ego_get_private_key( | ||
303 | handle->current->ego | ||
304 | ); | ||
305 | } | ||
306 | |||
277 | void | 307 | void |
278 | handle_send_internal_message (struct GNUNET_CHAT_Handle *handle, | 308 | handle_send_internal_message (struct GNUNET_CHAT_Handle *handle, |
279 | struct GNUNET_CHAT_Context *context, | 309 | struct GNUNET_CHAT_Context *context, |
@@ -351,7 +381,6 @@ handle_request_context_by_room (struct GNUNET_CHAT_Handle *handle, | |||
351 | return GNUNET_OK; | 381 | return GNUNET_OK; |
352 | 382 | ||
353 | context = context_create_from_room(handle, room); | 383 | context = context_create_from_room(handle, room); |
354 | context_load_config(context); | ||
355 | 384 | ||
356 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( | 385 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( |
357 | handle->contexts, key, context, | 386 | handle->contexts, key, context, |
@@ -376,9 +405,14 @@ check_type: | |||
376 | (GNUNET_OK == intern_provide_contact_for_member(handle, | 405 | (GNUNET_OK == intern_provide_contact_for_member(handle, |
377 | check.contact, | 406 | check.contact, |
378 | context))) | 407 | context))) |
408 | { | ||
409 | context_delete_records(context); | ||
379 | context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT; | 410 | context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT; |
411 | context_write_records(context); | ||
412 | } | ||
380 | else if (checks >= 2) | 413 | else if (checks >= 2) |
381 | { | 414 | { |
415 | context_delete_records(context); | ||
382 | context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP; | 416 | context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP; |
383 | 417 | ||
384 | if (context->contact) | 418 | if (context->contact) |
@@ -405,9 +439,7 @@ setup_group: | |||
405 | handle, context | 439 | handle, context |
406 | ); | 440 | ); |
407 | 441 | ||
408 | group_load_config(group); | 442 | if (context->topic) |
409 | |||
410 | if (group->topic) | ||
411 | group_publish(group); | 443 | group_publish(group); |
412 | 444 | ||
413 | if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put( | 445 | if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put( |
@@ -421,6 +453,7 @@ setup_group: | |||
421 | NULL | 453 | NULL |
422 | ); | 454 | ); |
423 | 455 | ||
456 | context_write_records(context); | ||
424 | return GNUNET_OK; | 457 | return GNUNET_OK; |
425 | } | 458 | } |
426 | 459 | ||