aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_handle.c')
-rw-r--r--src/gnunet_chat_handle.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c
index 11b57ac..7556987 100644
--- a/src/gnunet_chat_handle.c
+++ b/src/gnunet_chat_handle.c
@@ -28,7 +28,8 @@
28 28
29struct GNUNET_CHAT_Handle* 29struct GNUNET_CHAT_Handle*
30handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg, 30handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
31 const char* name, 31 const char *directory,
32 const char *name,
32 GNUNET_CHAT_ContextMessageCallback msg_cb, 33 GNUNET_CHAT_ContextMessageCallback msg_cb,
33 void *msg_cls, 34 void *msg_cls,
34 GNUNET_CHAT_WarningCallback warn_cb, 35 GNUNET_CHAT_WarningCallback warn_cb,
@@ -38,6 +39,12 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
38 39
39 handle->cfg = cfg; 40 handle->cfg = cfg;
40 41
42 if ((directory) &&
43 (GNUNET_YES == GNUNET_DISK_directory_test(directory, GNUNET_YES)))
44 handle->directory = GNUNET_strdup(directory);
45 else
46 handle->directory = NULL;
47
41 handle->msg_cb = msg_cb; 48 handle->msg_cb = msg_cb;
42 handle->msg_cls = msg_cls; 49 handle->msg_cls = msg_cls;
43 50
@@ -58,7 +65,7 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
58 on_handle_arm_connection(handle, GNUNET_NO); 65 on_handle_arm_connection(handle, GNUNET_NO);
59 66
60 handle->fs = GNUNET_FS_start( 67 handle->fs = GNUNET_FS_start(
61 handle->cfg, name, // TODO: raw name? 68 handle->cfg, name, // TODO: raw name? (NULL?)
62 notify_handle_fs_progress, handle, 69 notify_handle_fs_progress, handle,
63 GNUNET_FS_FLAGS_NONE, 70 GNUNET_FS_FLAGS_NONE,
64 GNUNET_FS_OPTIONS_END 71 GNUNET_FS_OPTIONS_END
@@ -85,10 +92,29 @@ handle_destroy (struct GNUNET_CHAT_Handle* handle)
85 if (handle->arm) 92 if (handle->arm)
86 GNUNET_ARM_disconnect(handle->arm); 93 GNUNET_ARM_disconnect(handle->arm);
87 94
95 GNUNET_CONTAINER_multihashmap_iterate(
96 handle->groups, it_destroy_handle_groups, NULL
97 );
98
99 GNUNET_CONTAINER_multishortmap_iterate(
100 handle->contacts, it_destroy_handle_contacts, NULL
101 );
102
103 GNUNET_CONTAINER_multihashmap_iterate(
104 handle->contexts, it_destroy_handle_contexts, NULL
105 );
106
107 GNUNET_CONTAINER_multihashmap_iterate(
108 handle->files, it_destroy_handle_files, NULL
109 );
110
88 GNUNET_CONTAINER_multihashmap_destroy(handle->groups); 111 GNUNET_CONTAINER_multihashmap_destroy(handle->groups);
89 GNUNET_CONTAINER_multishortmap_destroy(handle->contacts); 112 GNUNET_CONTAINER_multishortmap_destroy(handle->contacts);
90 GNUNET_CONTAINER_multihashmap_destroy(handle->contexts); 113 GNUNET_CONTAINER_multihashmap_destroy(handle->contexts);
91 GNUNET_CONTAINER_multihashmap_destroy(handle->files); 114 GNUNET_CONTAINER_multihashmap_destroy(handle->files);
92 115
116 if (handle->directory)
117 GNUNET_free(handle->directory);
118
93 GNUNET_free(handle); 119 GNUNET_free(handle);
94} 120}