aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gnunet_chat_handle.c38
-rw-r--r--src/gnunet_chat_handle.h1
-rw-r--r--src/gnunet_chat_lib.c9
3 files changed, 36 insertions, 12 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;
diff --git a/src/gnunet_chat_handle.h b/src/gnunet_chat_handle.h
index 28cfacc..5702206 100644
--- a/src/gnunet_chat_handle.h
+++ b/src/gnunet_chat_handle.h
@@ -122,7 +122,6 @@ struct GNUNET_CHAT_Handle
122 122
123struct GNUNET_CHAT_Handle* 123struct GNUNET_CHAT_Handle*
124handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg, 124handle_create_from_config (const struct GNUNET_CONFIGURATION_Handle* cfg,
125 const char *directory,
126 GNUNET_CHAT_ContextMessageCallback msg_cb, 125 GNUNET_CHAT_ContextMessageCallback msg_cb,
127 void *msg_cls); 126 void *msg_cls);
128 127
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index 1fcc419..72db7cd 100644
--- a/src/gnunet_chat_lib.c
+++ b/src/gnunet_chat_lib.c
@@ -47,7 +47,6 @@
47 47
48struct GNUNET_CHAT_Handle* 48struct GNUNET_CHAT_Handle*
49GNUNET_CHAT_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 49GNUNET_CHAT_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
50 const char *directory,
51 GNUNET_CHAT_ContextMessageCallback msg_cb, void *msg_cls) 50 GNUNET_CHAT_ContextMessageCallback msg_cb, void *msg_cls)
52{ 51{
53 GNUNET_CHAT_VERSION_ASSERT(); 52 GNUNET_CHAT_VERSION_ASSERT();
@@ -56,8 +55,9 @@ GNUNET_CHAT_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
56 return NULL; 55 return NULL;
57 56
58 return handle_create_from_config( 57 return handle_create_from_config(
59 cfg, directory, 58 cfg,
60 msg_cb, msg_cls 59 msg_cb,
60 msg_cls
61 ); 61 );
62} 62}
63 63
@@ -1094,9 +1094,6 @@ GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context,
1094 if ((!context) || (!path) || (!(context->room))) 1094 if ((!context) || (!path) || (!(context->room)))
1095 return NULL; 1095 return NULL;
1096 1096
1097 if (!(context->handle->directory))
1098 return NULL;
1099
1100 struct GNUNET_HashCode hash; 1097 struct GNUNET_HashCode hash;
1101 if (GNUNET_OK != util_hash_file(path, &hash)) 1098 if (GNUNET_OK != util_hash_file(path, &hash))
1102 return NULL; 1099 return NULL;