aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_file.c')
-rw-r--r--src/gnunet_chat_file.c84
1 files changed, 21 insertions, 63 deletions
diff --git a/src/gnunet_chat_file.c b/src/gnunet_chat_file.c
index b5f480c..d472551 100644
--- a/src/gnunet_chat_file.c
+++ b/src/gnunet_chat_file.c
@@ -22,81 +22,39 @@
22 * @file gnunet_chat_file.c 22 * @file gnunet_chat_file.c
23 */ 23 */
24 24
25#include "gnunet_chat_lib.h"
26#include "gnunet_chat_file.h" 25#include "gnunet_chat_file.h"
27 26
28const struct GNUNET_HashCode* 27#include <limits.h>
29GNUNET_CHAT_file_get_hash (const struct GNUNET_CHAT_File *file)
30{
31 return &(file->hash);
32}
33 28
34uint64_t 29struct GNUNET_CHAT_File*
35GNUNET_CHAT_file_get_size (const struct GNUNET_CHAT_File *file) 30file_create_from_message (struct GNUNET_CHAT_Handle *handle,
31 const struct GNUNET_MESSENGER_MessageFile* message)
36{ 32{
37 return 0; 33 struct GNUNET_CHAT_File* file = GNUNET_new(struct GNUNET_CHAT_File);
38}
39 34
40int 35 file->handle = handle;
41GNUNET_CHAT_file_is_local (const struct GNUNET_CHAT_File *file)
42{
43 return GNUNET_NO;
44}
45 36
46int 37 file->name = GNUNET_strndup(message->name, NAME_MAX);
47GNUNET_CHAT_file_start_download (struct GNUNET_CHAT_File *file,
48 GNUNET_CHAT_MessageFileDownloadCallback callback,
49 void *cls)
50{
51 if (!file)
52 return GNUNET_SYSERR;
53 38
54 struct GNUNET_FS_Handle *handle; 39 GNUNET_memcpy(&(file->key), &(message->key), sizeof(file->key));
55 const char *path = ""; // TODO: path = download_directory + filename 40 GNUNET_memcpy(&(file->hash), &(message->hash), sizeof(file->hash));
56 41
57 GNUNET_FS_download_start( 42 file->uri = GNUNET_FS_uri_parse(message->uri, NULL);
58 handle, 43 file->download = NULL;
59 file->uri, 44 file->publish = NULL;
60 NULL, 45 file->unindex = NULL;
61 path,
62 NULL,
63 0,
64 0,
65 0,
66 GNUNET_FS_DOWNLOAD_OPTION_NONE,
67 NULL,
68 NULL
69 );
70 46
71 return GNUNET_OK; 47 return file;
72} 48}
73 49
74int 50void
75GNUNET_CHAT_file_pause_download (struct GNUNET_CHAT_File *file) 51file_destroy (struct GNUNET_CHAT_File* file)
76{ 52{
77 if (!file) 53 if (file->uri)
78 return GNUNET_SYSERR; 54 GNUNET_FS_uri_destroy(file->uri);
79 55
80 GNUNET_FS_download_suspend(file->context); 56 if (file->name)
81 return GNUNET_OK; 57 GNUNET_free(file->name);
82}
83
84int
85GNUNET_CHAT_file_resume_download (struct GNUNET_CHAT_File *file)
86{
87 if (!file)
88 return GNUNET_SYSERR;
89
90 GNUNET_FS_download_resume(file->context);
91 return GNUNET_OK;
92}
93
94int
95GNUNET_CHAT_file_stop_download (struct GNUNET_CHAT_File *file)
96{
97 if (!file)
98 return GNUNET_SYSERR;
99 58
100 GNUNET_FS_download_stop(file->context, GNUNET_YES); 59 GNUNET_free(file);
101 return GNUNET_OK;
102} 60}