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.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c
index 45f7861..d23741b 100644
--- a/src/gnunet_chat_handle.c
+++ b/src/gnunet_chat_handle.c
@@ -28,7 +28,6 @@
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 *directory,
32 GNUNET_CHAT_ContextMessageCallback msg_cb, 31 GNUNET_CHAT_ContextMessageCallback msg_cb,
33 void *msg_cls) 32 void *msg_cls)
34{ 33{
@@ -44,11 +43,40 @@ handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
44 handle->internal_head = NULL; 43 handle->internal_head = NULL;
45 handle->internal_tail = NULL; 44 handle->internal_tail = NULL;
46 45
47 if ((directory) && 46 handle->directory = NULL;
48 (GNUNET_YES == GNUNET_DISK_directory_test(directory, GNUNET_YES))) 47
49 handle->directory = GNUNET_strdup(directory); 48 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(cfg,
50 else 49 GNUNET_MESSENGER_SERVICE_NAME,
50 "MESSENGER_DIR",
51 &(handle->directory)))
52 {
53 if (handle->directory)
54 GNUNET_free(handle->directory);
55
56 handle->directory = NULL;
57 }
58 else if ((GNUNET_YES != GNUNET_DISK_directory_test(handle->directory, GNUNET_YES)) &&
59 (GNUNET_OK != GNUNET_DISK_directory_create(handle->directory)))
60 {
61 GNUNET_free(handle->directory);
62
51 handle->directory = NULL; 63 handle->directory = NULL;
64 }
65
66 if (handle->directory)
67 {
68 char *chat_directory = NULL;
69 util_get_dirname(handle->directory, "chat", &chat_directory);
70
71 if ((GNUNET_YES != GNUNET_DISK_directory_test(chat_directory, GNUNET_YES)) &&
72 (GNUNET_OK != GNUNET_DISK_directory_create(chat_directory)))
73 GNUNET_free(chat_directory);
74 else
75 {
76 GNUNET_free(handle->directory);
77 handle->directory = chat_directory;
78 }
79 }
52 80
53 handle->msg_cb = msg_cb; 81 handle->msg_cb = msg_cb;
54 handle->msg_cls = msg_cls; 82 handle->msg_cls = msg_cls;