aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fs/download.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/fs/download.c')
-rw-r--r--src/plugins/fs/download.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c
index 19b2f73a..c7ed4d18 100644
--- a/src/plugins/fs/download.c
+++ b/src/plugins/fs/download.c
@@ -33,12 +33,12 @@
33/* ****************** FSUI download events ****************** */ 33/* ****************** FSUI download events ****************** */
34 34
35/** 35/**
36 * We are iterating over the contents of a 36 * We are iterating over the contents of a
37 * directory. Add the list of entries to 37 * directory. Add the list of entries to
38 * the search page at the position indicated 38 * the search page at the position indicated
39 * by the download list. 39 * by the download list.
40 */ 40 */
41static int 41static int
42addFilesToDirectory(const ECRS_FileInfo * fi, 42addFilesToDirectory(const ECRS_FileInfo * fi,
43 const HashCode512 * key, 43 const HashCode512 * key,
44 int isRoot, 44 int isRoot,
@@ -50,7 +50,7 @@ addFilesToDirectory(const ECRS_FileInfo * fi,
50 GtkTreePath * path; 50 GtkTreePath * path;
51 GtkTreeModel * model; 51 GtkTreeModel * model;
52 52
53 if (isRoot == YES) 53 if (isRoot == YES)
54 return OK; 54 return OK;
55 if (! gtk_tree_row_reference_valid(list->searchViewRowReference)) 55 if (! gtk_tree_row_reference_valid(list->searchViewRowReference))
56 return SYSERR; 56 return SYSERR;
@@ -91,7 +91,7 @@ addFilesToDirectory(const ECRS_FileInfo * fi,
91 return OK; 91 return OK;
92} 92}
93 93
94static void 94static void
95refreshDirectoryViewFromDisk(DownloadList * list) { 95refreshDirectoryViewFromDisk(DownloadList * list) {
96 unsigned long long size; 96 unsigned long long size;
97 char * data; 97 char * data;
@@ -101,18 +101,18 @@ refreshDirectoryViewFromDisk(DownloadList * list) {
101 if ( (list->is_directory != YES) || 101 if ( (list->is_directory != YES) ||
102 (list->searchList == NULL) || 102 (list->searchList == NULL) ||
103 (list->searchViewRowReference == NULL) || 103 (list->searchViewRowReference == NULL) ||
104 (! gtk_tree_row_reference_valid(list->searchViewRowReference)) ) 104 (! gtk_tree_row_reference_valid(list->searchViewRowReference)) )
105 return; 105 return;
106 106
107 if (OK != disk_file_size(ectx, 107 if (OK != disk_file_size(ectx,
108 list->filename, 108 list->filename,
109 &size, 109 &size,
110 YES)) 110 YES))
111 return; 111 return;
112 fd = disk_file_open(ectx, 112 fd = disk_file_open(ectx,
113 list->filename, 113 list->filename,
114 O_RDONLY); 114 O_RDONLY);
115 if (fd == -1) 115 if (fd == -1)
116 return; 116 return;
117 data = MMAP(NULL, 117 data = MMAP(NULL,
118 size, 118 size,
@@ -168,7 +168,7 @@ fs_download_started(struct FSUI_DownloadList * fsui_dl,
168 char * uri_name; 168 char * uri_name;
169 gboolean valid; 169 gboolean valid;
170 struct ECRS_URI * u; 170 struct ECRS_URI * u;
171 171
172 /* setup visualization */ 172 /* setup visualization */
173 list = MALLOC(sizeof(DownloadList)); 173 list = MALLOC(sizeof(DownloadList));
174 memset(list, 174 memset(list,
@@ -201,7 +201,7 @@ fs_download_started(struct FSUI_DownloadList * fsui_dl,
201 DOWNLOAD_HSIZE, size_h, 201 DOWNLOAD_HSIZE, size_h,
202 DOWNLOAD_PROGRESS, progress, 202 DOWNLOAD_PROGRESS, progress,
203 DOWNLOAD_URISTRING, uri_name, 203 DOWNLOAD_URISTRING, uri_name,
204 DOWNLOAD_INTERNAL, list, 204 DOWNLOAD_INTERNAL, list,
205 -1); 205 -1);
206 FREE(uri_name); 206 FREE(uri_name);
207 FREE(size_h); 207 FREE(size_h);
@@ -221,16 +221,16 @@ fs_download_started(struct FSUI_DownloadList * fsui_dl,
221 path = gtk_tree_row_reference_get_path(dl_parent->searchViewRowReference); 221 path = gtk_tree_row_reference_get_path(dl_parent->searchViewRowReference);
222 valid = gtk_tree_model_get_iter(GTK_TREE_MODEL(sl_parent->tree), 222 valid = gtk_tree_model_get_iter(GTK_TREE_MODEL(sl_parent->tree),
223 &piter, 223 &piter,
224 path); 224 path);
225 if (valid == TRUE) 225 if (valid == TRUE)
226 valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(sl_parent->tree), 226 valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(sl_parent->tree),
227 &iter, 227 &iter,
228 &piter); 228 &piter);
229 } else { 229 } else {
230 /* must be top-level entry in search */ 230 /* must be top-level entry in search */
231 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sl_parent->tree), 231 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sl_parent->tree),
232 &iter); 232 &iter);
233 } 233 }
234 if (valid == TRUE) { 234 if (valid == TRUE) {
235 valid = FALSE; 235 valid = FALSE;
236 /* find matching entry */ 236 /* find matching entry */
@@ -271,7 +271,7 @@ fs_download_started(struct FSUI_DownloadList * fsui_dl,
271 list->next = download_head; 271 list->next = download_head;
272 download_head = list; 272 download_head = list;
273 if ( (list->is_directory == YES) && 273 if ( (list->is_directory == YES) &&
274 (completed != 0) ) 274 (completed != 0) )
275 refreshDirectoryViewFromDisk(list); 275 refreshDirectoryViewFromDisk(list);
276 return list; 276 return list;
277} 277}
@@ -306,7 +306,7 @@ void fs_download_update(DownloadList * list,
306 (list->searchList != NULL) && 306 (list->searchList != NULL) &&
307 (list->searchViewRowReference != NULL) ) { 307 (list->searchViewRowReference != NULL) ) {
308 struct ECRS_MetaData * meta; 308 struct ECRS_MetaData * meta;
309 309
310 meta = NULL; 310 meta = NULL;
311 ECRS_listDirectory(ectx, 311 ECRS_listDirectory(ectx,
312 data, 312 data,
@@ -353,17 +353,17 @@ void fs_download_stopped(DownloadList * list) {
353 &iter, 353 &iter,
354 path); 354 path);
355 gtk_tree_path_free(path); 355 gtk_tree_path_free(path);
356 gtk_tree_row_reference_free(list->summaryViewRowReference); 356 gtk_tree_row_reference_free(list->summaryViewRowReference);
357 list->summaryViewRowReference = NULL; 357 list->summaryViewRowReference = NULL;
358 gtk_tree_store_remove(download_summary, 358 gtk_tree_store_remove(download_summary,
359 &iter); 359 &iter);
360 if (list->searchViewRowReference != NULL) { 360 if (list->searchViewRowReference != NULL) {
361 gtk_tree_row_reference_free(list->searchViewRowReference); 361 gtk_tree_row_reference_free(list->searchViewRowReference);
362 list->searchViewRowReference = NULL; 362 list->searchViewRowReference = NULL;
363 } 363 }
364 FREE(list->filename); 364 FREE(list->filename);
365 ECRS_freeUri(list->uri); 365 ECRS_freeUri(list->uri);
366 366
367 if (download_head == list) 367 if (download_head == list)
368 download_head = list->next; 368 download_head = list->next;
369 else { 369 else {
@@ -388,7 +388,7 @@ void fs_download_stopped(DownloadList * list) {
388 * 388 *
389 * @return OK if no download is pending, SYSERR if 389 * @return OK if no download is pending, SYSERR if
390 * such a download is already active. 390 * such a download is already active.
391 */ 391 */
392static int 392static int
393check_pending(const char * filename, 393check_pending(const char * filename,
394 GtkTreeIter * parent) { 394 GtkTreeIter * parent) {
@@ -421,7 +421,7 @@ check_pending(const char * filename,
421 * The user clicked the download button. 421 * The user clicked the download button.
422 * Start the download of the selected entry. 422 * Start the download of the selected entry.
423 */ 423 */
424static void 424static void
425initiateDownload(GtkTreeModel * model, 425initiateDownload(GtkTreeModel * model,
426 GtkTreePath * path, 426 GtkTreePath * path,
427 GtkTreeIter * iter, 427 GtkTreeIter * iter,
@@ -485,7 +485,7 @@ initiateDownload(GtkTreeModel * model,
485#else 485#else
486 idc_name = uri_name; 486 idc_name = uri_name;
487#endif 487#endif
488 } 488 }
489 cname = idc_name; 489 cname = idc_name;
490 oname = idc_name; 490 oname = idc_name;
491 dname = MALLOC(strlen(idc_name)+1); 491 dname = MALLOC(strlen(idc_name)+1);
@@ -570,12 +570,12 @@ initiateDownload(GtkTreeModel * model,
570 strcat(idc_final_download_destination, idc_name); 570 strcat(idc_final_download_destination, idc_name);
571 if ( (idc_final_download_destination[strlen(idc_final_download_destination) - 1] == '/') || 571 if ( (idc_final_download_destination[strlen(idc_final_download_destination) - 1] == '/') ||
572 (idc_final_download_destination[strlen(idc_final_download_destination) - 1] == '\\') ) 572 (idc_final_download_destination[strlen(idc_final_download_destination) - 1] == '\\') )
573 idc_final_download_destination[strlen(idc_final_download_destination) - 1] = '\0'; 573 idc_final_download_destination[strlen(idc_final_download_destination) - 1] = '\0';
574 /* append ".gnd" if needed (== directory and .gnd not present) */ 574 /* append ".gnd" if needed (== directory and .gnd not present) */
575 if ( (idc_mime != NULL) && 575 if ( (idc_mime != NULL) &&
576 (0 == strcmp(idc_mime, GNUNET_DIRECTORY_MIME)) && 576 (0 == strcmp(idc_mime, GNUNET_DIRECTORY_MIME)) &&
577 ( (strlen(idc_final_download_destination) < strlen(GNUNET_DIRECTORY_EXT)) || 577 ( (strlen(idc_final_download_destination) < strlen(GNUNET_DIRECTORY_EXT)) ||
578 (0 != strcmp(&idc_final_download_destination[strlen(idc_final_download_destination) 578 (0 != strcmp(&idc_final_download_destination[strlen(idc_final_download_destination)
579 - strlen(GNUNET_DIRECTORY_EXT)], 579 - strlen(GNUNET_DIRECTORY_EXT)],
580 GNUNET_DIRECTORY_EXT)) ) ) 580 GNUNET_DIRECTORY_EXT)) ) )
581 strcat(idc_final_download_destination, GNUNET_DIRECTORY_EXT); 581 strcat(idc_final_download_destination, GNUNET_DIRECTORY_EXT);
@@ -626,7 +626,7 @@ void on_downloadButton_clicked_fs(GtkWidget * treeview,
626 * that is NOT rooted within a search or directory. 626 * that is NOT rooted within a search or directory.
627 * 627 *
628 * TODO: 628 * TODO:
629 * - support for recursive downloads 629 * - support for recursive downloads
630 * - support for showing directories (if downloaded like this) 630 * - support for showing directories (if downloaded like this)
631 * - support for user-specified filename 631 * - support for user-specified filename
632 */ 632 */
@@ -639,7 +639,7 @@ void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry,
639 char * urid; 639 char * urid;
640 char * final_download_dir; 640 char * final_download_dir;
641 const char * dname; 641 const char * dname;
642 642
643 uris = gtk_entry_get_text(GTK_ENTRY(entry)); 643 uris = gtk_entry_get_text(GTK_ENTRY(entry));
644 urid = STRDUP(uris); 644 urid = STRDUP(uris);
645 gtk_entry_set_text(GTK_ENTRY(entry), 645 gtk_entry_set_text(GTK_ENTRY(entry),
@@ -703,7 +703,7 @@ static void * fsui_callback(void * cls) {
703 return NULL; 703 return NULL;
704} 704}
705 705
706static gboolean 706static gboolean
707clearCompletedDownloadCallback(GtkTreeModel * model, 707clearCompletedDownloadCallback(GtkTreeModel * model,
708 GtkTreePath * path, 708 GtkTreePath * path,
709 GtkTreeIter * iter, 709 GtkTreeIter * iter,
@@ -727,13 +727,13 @@ clearCompletedDownloadCallback(GtkTreeModel * model,
727} 727}
728 728
729void on_clearCompletedDownloadsButton_clicked_fs(void * unused, 729void on_clearCompletedDownloadsButton_clicked_fs(void * unused,
730 GtkWidget * clearButton) { 730 GtkWidget * clearButton) {
731 gtk_tree_model_foreach(GTK_TREE_MODEL(download_summary), 731 gtk_tree_model_foreach(GTK_TREE_MODEL(download_summary),
732 &clearCompletedDownloadCallback, 732 &clearCompletedDownloadCallback,
733 NULL); 733 NULL);
734} 734}
735 735
736static void 736static void
737fsuiCallDownloadCallback(GtkTreeModel * model, 737fsuiCallDownloadCallback(GtkTreeModel * model,
738 GtkTreePath * path, 738 GtkTreePath * path,
739 GtkTreeIter * iter, 739 GtkTreeIter * iter,