diff options
Diffstat (limited to 'src/gnunet_chat_file.c')
-rw-r--r-- | src/gnunet_chat_file.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gnunet_chat_file.c b/src/gnunet_chat_file.c index d472551..fdfbe4c 100644 --- a/src/gnunet_chat_file.c +++ b/src/gnunet_chat_file.c | |||
@@ -39,6 +39,12 @@ file_create_from_message (struct GNUNET_CHAT_Handle *handle, | |||
39 | GNUNET_memcpy(&(file->key), &(message->key), sizeof(file->key)); | 39 | GNUNET_memcpy(&(file->key), &(message->key), sizeof(file->key)); |
40 | GNUNET_memcpy(&(file->hash), &(message->hash), sizeof(file->hash)); | 40 | GNUNET_memcpy(&(file->hash), &(message->hash), sizeof(file->hash)); |
41 | 41 | ||
42 | file->published = 0; | ||
43 | file->downloaded = 0; | ||
44 | file->unindexed = 0; | ||
45 | |||
46 | file->meta = GNUNET_CONTAINER_meta_data_create(); | ||
47 | |||
42 | file->uri = GNUNET_FS_uri_parse(message->uri, NULL); | 48 | file->uri = GNUNET_FS_uri_parse(message->uri, NULL); |
43 | file->download = NULL; | 49 | file->download = NULL; |
44 | file->publish = NULL; | 50 | file->publish = NULL; |
@@ -47,12 +53,43 @@ file_create_from_message (struct GNUNET_CHAT_Handle *handle, | |||
47 | return file; | 53 | return file; |
48 | } | 54 | } |
49 | 55 | ||
56 | struct GNUNET_CHAT_File* | ||
57 | file_create_from_disk (struct GNUNET_CHAT_Handle *handle, | ||
58 | const char *name, const struct GNUNET_HashCode *hash, | ||
59 | const struct GNUNET_CRYPTO_SymmetricSessionKey *key) | ||
60 | { | ||
61 | struct GNUNET_CHAT_File* file = GNUNET_new(struct GNUNET_CHAT_File); | ||
62 | |||
63 | file->handle = handle; | ||
64 | |||
65 | file->name = GNUNET_strndup(name, NAME_MAX); | ||
66 | |||
67 | GNUNET_memcpy(&(file->key), key, sizeof(file->key)); | ||
68 | GNUNET_memcpy(&(file->hash), hash, sizeof(file->hash)); | ||
69 | |||
70 | file->published = 0; | ||
71 | file->downloaded = 0; | ||
72 | file->unindexed = 0; | ||
73 | |||
74 | file->meta = GNUNET_CONTAINER_meta_data_create(); | ||
75 | |||
76 | file->uri = NULL; | ||
77 | file->download = NULL; | ||
78 | file->publish = NULL; | ||
79 | file->unindex = NULL; | ||
80 | |||
81 | return file; | ||
82 | } | ||
83 | |||
50 | void | 84 | void |
51 | file_destroy (struct GNUNET_CHAT_File* file) | 85 | file_destroy (struct GNUNET_CHAT_File* file) |
52 | { | 86 | { |
53 | if (file->uri) | 87 | if (file->uri) |
54 | GNUNET_FS_uri_destroy(file->uri); | 88 | GNUNET_FS_uri_destroy(file->uri); |
55 | 89 | ||
90 | if (file->meta) | ||
91 | GNUNET_CONTAINER_meta_data_destroy(file->meta); | ||
92 | |||
56 | if (file->name) | 93 | if (file->name) |
57 | GNUNET_free(file->name); | 94 | GNUNET_free(file->name); |
58 | 95 | ||