aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/fs/collection.c44
-rw-r--r--src/plugins/fs/collection.h5
-rw-r--r--src/plugins/fs/download.c144
-rw-r--r--src/plugins/fs/download.h3
-rw-r--r--src/plugins/fs/fs.c88
-rw-r--r--src/plugins/fs/fs.h1
-rw-r--r--src/plugins/fs/meta.c2
-rw-r--r--src/plugins/fs/namespace.c128
-rw-r--r--src/plugins/fs/namespace.h5
-rw-r--r--src/plugins/fs/search.c90
-rw-r--r--src/plugins/fs/search.h8
-rw-r--r--src/plugins/fs/upload.c230
-rw-r--r--src/plugins/fs/upload.h7
13 files changed, 345 insertions, 410 deletions
diff --git a/src/plugins/fs/collection.c b/src/plugins/fs/collection.c
index da25ddbc..712c777d 100644
--- a/src/plugins/fs/collection.c
+++ b/src/plugins/fs/collection.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2005 Christian Grothoff (and other contributing authors) 3 (C) 2005, 2006 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -30,12 +30,17 @@
30#include "helper.h" 30#include "helper.h"
31#include "meta.h" 31#include "meta.h"
32#include "collection.h" 32#include "collection.h"
33#include <GNUnet/gnunet_collection_lib.h>
33#include <extractor.h> 34#include <extractor.h>
34 35
35static GladeXML * metaXML; 36static GladeXML * metaXML;
36 37
37void on_collectionDialogMetaDataAddButton_clicked(gpointer dummy, 38static struct GE_Context * ectx;
38 GtkWidget * uploadButton) { 39
40static struct GC_Configuration * cfg;
41
42void on_collectionDialogMetaDataAddButton_clicked_fs(gpointer dummy,
43 GtkWidget * uploadButton) {
39 handleMetaDataListUpdate(metaXML, 44 handleMetaDataListUpdate(metaXML,
40 "collectionMetaDataTypeComboBox", 45 "collectionMetaDataTypeComboBox",
41 "collectionMetaDataValueEntry", 46 "collectionMetaDataValueEntry",
@@ -43,8 +48,8 @@ void on_collectionDialogMetaDataAddButton_clicked(gpointer dummy,
43} 48}
44 49
45 50
46void createCollection_clicked(GtkWidget * dummy1, 51void createCollection_clicked_fs(GtkWidget * dummy1,
47 GtkWidget * dummy2) { 52 GtkWidget * dummy2) {
48 const char * collectionName; 53 const char * collectionName;
49 const char * updateIntervalString; 54 const char * updateIntervalString;
50 GtkWidget * w; 55 GtkWidget * w;
@@ -109,12 +114,14 @@ void createCollection_clicked(GtkWidget * dummy1,
109 collectionName 114 collectionName
110 = gtk_entry_get_text(GTK_ENTRY(nameLine)); 115 = gtk_entry_get_text(GTK_ENTRY(nameLine));
111 root = NULL; 116 root = NULL;
112 if (OK == FSUI_startCollection(ctx, 117 if (OK == CO_startCollection(ectx,
113 gtk_spin_button_get_value_as_int 118 cfg,
114 (GTK_SPIN_BUTTON(spin)), 119 gtk_spin_button_get_value_as_int
115 updateInterval, 120 (GTK_SPIN_BUTTON(spin)),
116 collectionName, 121 1000, /* priority */
117 meta)) { 122 updateInterval,
123 collectionName,
124 meta)) {
118 w = glade_xml_get_widget(getMainXML(), 125 w = glade_xml_get_widget(getMainXML(),
119 "createCollection"); 126 "createCollection");
120 gtk_widget_set_sensitive(w, FALSE); 127 gtk_widget_set_sensitive(w, FALSE);
@@ -141,11 +148,12 @@ void createCollection_clicked(GtkWidget * dummy1,
141 metaXML = NULL; 148 metaXML = NULL;
142} 149}
143 150
144void deleteCollection_clicked(GtkWidget * dummy1, 151void deleteCollection_clicked_fs(GtkWidget * dummy1,
145 GtkWidget * dummy2) { 152 GtkWidget * dummy2) {
146 GtkWidget * w; 153 GtkWidget * w;
147 154
148 if (OK == FSUI_stopCollection(ctx)) { 155 if (OK == CO_stopCollection(ectx,
156 cfg)) {
149 w = glade_xml_get_widget(getMainXML(), 157 w = glade_xml_get_widget(getMainXML(),
150 "createCollection"); 158 "createCollection");
151 gtk_widget_set_sensitive(w, TRUE); 159 gtk_widget_set_sensitive(w, TRUE);
@@ -160,10 +168,14 @@ void deleteCollection_clicked(GtkWidget * dummy1,
160 } 168 }
161} 169}
162 170
163void fs_collection_start() { 171void fs_collection_start(struct GE_Context * e,
172 struct GC_Configuration * c) {
164 GtkWidget * w; 173 GtkWidget * w;
165 174
166 if (NULL != FSUI_getCollection(ctx)) 175 ectx = e;
176 cfg = c;
177 if (NULL != CO_getCollection(ectx,
178 cfg))
167 w = glade_xml_get_widget(getMainXML(), 179 w = glade_xml_get_widget(getMainXML(),
168 "createCollection"); 180 "createCollection");
169 else 181 else
diff --git a/src/plugins/fs/collection.h b/src/plugins/fs/collection.h
index 825db40e..2c8f712c 100644
--- a/src/plugins/fs/collection.h
+++ b/src/plugins/fs/collection.h
@@ -27,7 +27,10 @@
27#ifndef GTK_COLLECTION_H 27#ifndef GTK_COLLECTION_H
28#define GTK_COLLECTION_H 28#define GTK_COLLECTION_H
29 29
30void fs_collection_start(void); 30#include <GNUnet/gnunet_util.h>
31
32void fs_collection_start(struct GE_Context * ectx,
33 struct GC_Configuration * cfg);
31 34
32void fs_collection_stop(void); 35void fs_collection_stop(void);
33 36
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c
index cc287093..2e645738 100644
--- a/src/plugins/fs/download.c
+++ b/src/plugins/fs/download.c
@@ -44,6 +44,10 @@ static DownloadList * head;
44 44
45static GtkTreeStore * summary; 45static GtkTreeStore * summary;
46 46
47static struct GE_Context * ectx;
48
49static struct GC_Configuration * cfg;
50
47static int addFilesToDirectory 51static int addFilesToDirectory
48 (const ECRS_FileInfo * fi, 52 (const ECRS_FileInfo * fi,
49 const HashCode512 * key, 53 const HashCode512 * key,
@@ -59,7 +63,6 @@ static int addFilesToDirectory
59 if (isRoot == YES) 63 if (isRoot == YES)
60 return OK; 64 return OK;
61 DEBUG_BEGIN(); 65 DEBUG_BEGIN();
62 FSUI_trackURI(fi);
63 pos = head; 66 pos = head;
64 while (pos != NULL) { 67 while (pos != NULL) {
65 if (ECRS_equalsUri(uri, 68 if (ECRS_equalsUri(uri,
@@ -112,7 +115,7 @@ typedef struct {
112 const char * mime; 115 const char * mime;
113 char * final_download_destination; 116 char * final_download_destination;
114 unsigned int anon; 117 unsigned int anon;
115 int ret; 118 struct FSUI_SearchList * ret;
116} InitiateDownloadCls; 119} InitiateDownloadCls;
117 120
118static void * startSearch(void * cls) { 121static void * startSearch(void * cls) {
@@ -120,6 +123,8 @@ static void * startSearch(void * cls) {
120 123
121 idc->ret = FSUI_startSearch(ctx, 124 idc->ret = FSUI_startSearch(ctx,
122 idc->anon, 125 idc->anon,
126 1000, /* FIXME: max results */
127 99 * cronYEARS, /* fixme: timeout */
123 idc->uri); 128 idc->uri);
124 return NULL; 129 return NULL;
125} 130}
@@ -129,6 +134,7 @@ static void * startDownload(void * cls) {
129 134
130 FSUI_startDownload(ctx, 135 FSUI_startDownload(ctx,
131 idc->anon, 136 idc->anon,
137 NO, /* FIXME: isRecursive */
132 idc->uri, 138 idc->uri,
133 idc->final_download_destination); 139 idc->final_download_destination);
134 return NULL; 140 return NULL;
@@ -189,8 +195,8 @@ static void initiateDownload(GtkTreeModel * model,
189 we'll just add it as a new tab for now */ 195 we'll just add it as a new tab for now */
190 run_with_save_calls(&startSearch, 196 run_with_save_calls(&startSearch,
191 &idc); 197 &idc);
192 if (idc.ret == OK) 198 if (idc.ret != NULL)
193 openTabForSearch(NULL, 199 openTabForSearch(idc.ret,
194 idc.uri, 200 idc.uri,
195 idc.anon, 201 idc.anon,
196 0, 202 0,
@@ -238,11 +244,11 @@ static void initiateDownload(GtkTreeModel * model,
238 if (*cname == '\0') /* name ended in '/' - likely directory */ 244 if (*cname == '\0') /* name ended in '/' - likely directory */
239 cname = oname; 245 cname = oname;
240 idc.name = cname; 246 idc.name = cname;
241 247 GC_get_configuration_value_filename(cfg,
242 final_download_dir = getFileName("FS", 248 "FS",
243 "INCOMINGDIR", 249 "INCOMINGDIR",
244 _("You must specify a directory in the configuration" 250 "$HOME/gnunet-downloads/",
245 " in section `%s' under `%s'.")); 251 &final_download_dir);
246 if (strlen(dname) > 0) { 252 if (strlen(dname) > 0) {
247 char * tmp; 253 char * tmp;
248 tmp = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); 254 tmp = MALLOC(strlen(final_download_dir) + strlen(dname) + 2);
@@ -301,7 +307,8 @@ static void initiateDownload(GtkTreeModel * model,
301 strcat(idc.final_download_destination, 307 strcat(idc.final_download_destination,
302 DIR_SEPARATOR_STR); 308 DIR_SEPARATOR_STR);
303 strcat(idc.final_download_destination, dirPath); 309 strcat(idc.final_download_destination, dirPath);
304 mkdirp(idc.final_download_destination); 310 disk_directory_create(ectx,
311 idc.final_download_destination);
305 strcat(idc.final_download_destination, idc.name); 312 strcat(idc.final_download_destination, idc.name);
306 if ( (idc.final_download_destination[strlen(idc.final_download_destination) - 1] == '/') || 313 if ( (idc.final_download_destination[strlen(idc.final_download_destination) - 1] == '/') ||
307 (idc.final_download_destination[strlen(idc.final_download_destination) - 1] == '\\') ) 314 (idc.final_download_destination[strlen(idc.final_download_destination) - 1] == '\\') )
@@ -331,11 +338,11 @@ static void initiateDownload(GtkTreeModel * model,
331 if (final_download_dir[strlen(final_download_dir)-1] != DIR_SEPARATOR) 338 if (final_download_dir[strlen(final_download_dir)-1] != DIR_SEPARATOR)
332 strcat(list->finalName, DIR_SEPARATOR_STR); 339 strcat(list->finalName, DIR_SEPARATOR_STR);
333 strcat(list->finalName, dirPath); 340 strcat(list->finalName, dirPath);
334 mkdirp(list->finalName); 341 disk_directory_create(ectx, list->finalName);
335 strcat(list->finalName, idc.name); 342 strcat(list->finalName, idc.name);
336 head = list; 343 head = list;
337 size = ECRS_fileSize(idc.uri); 344 size = ECRS_fileSize(idc.uri);
338 size_h = getHumanSize(size); 345 size_h = string_get_fancy_byte_size(size);
339 gtk_tree_store_insert(summary, 346 gtk_tree_store_insert(summary,
340 &iiter, 347 &iiter,
341 NULL, 348 NULL,
@@ -395,7 +402,7 @@ void on_statusDownloadURIEntry_editing_done(GtkWidget * entry,
395 urid = STRDUP(uris); 402 urid = STRDUP(uris);
396 gtk_entry_set_text(GTK_ENTRY(entry), 403 gtk_entry_set_text(GTK_ENTRY(entry),
397 ECRS_URI_PREFIX); 404 ECRS_URI_PREFIX);
398 idc.uri = ECRS_stringToUri(urid); 405 idc.uri = ECRS_stringToUri(ectx, urid);
399 if (idc.uri == NULL) { 406 if (idc.uri == NULL) {
400 addLogEntry(_("Invalid URI `%s'"), urid); 407 addLogEntry(_("Invalid URI `%s'"), urid);
401 FREE(urid); 408 FREE(urid);
@@ -412,11 +419,12 @@ void on_statusDownloadURIEntry_editing_done(GtkWidget * entry,
412 ECRS_freeUri(idc.uri); 419 ECRS_freeUri(idc.uri);
413 return; 420 return;
414 } 421 }
415 final_download_dir = getFileName("FS", 422 GC_get_configuration_value_filename(cfg,
416 "INCOMINGDIR", 423 "FS",
417 _("You must specify a directory in the configuration" 424 "INCOMINGDIR",
418 " in section `%s' under `%s'.")); 425 "$HOME/gnunet-downloads/",
419 mkdirp(final_download_dir); 426 &final_download_dir);
427 disk_directory_create(ectx, final_download_dir);
420 dname = &uris[strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX)]; 428 dname = &uris[strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX)];
421 idc.final_download_destination = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); 429 idc.final_download_destination = MALLOC(strlen(final_download_dir) + strlen(dname) + 2);
422 strcpy(idc.final_download_destination, final_download_dir); 430 strcpy(idc.final_download_destination, final_download_dir);
@@ -434,7 +442,7 @@ void on_statusDownloadURIEntry_editing_done(GtkWidget * entry,
434 list->filename = idc.final_download_destination; 442 list->filename = idc.final_download_destination;
435 list->finalName = STRDUP(idc.final_download_destination); 443 list->finalName = STRDUP(idc.final_download_destination);
436 head = list; 444 head = list;
437 size_h = getHumanSize(ECRS_fileSize(idc.uri)); 445 size_h = string_get_fancy_byte_size(ECRS_fileSize(idc.uri));
438 gtk_tree_store_insert(summary, 446 gtk_tree_store_insert(summary,
439 &iiter, 447 &iiter,
440 NULL, 448 NULL,
@@ -507,7 +515,8 @@ void displayDownloadUpdate(const struct ECRS_URI * uri,
507 &iter)); 515 &iter));
508 } 516 }
509 meta = NULL; 517 meta = NULL;
510 ECRS_listDirectory(data, 518 ECRS_listDirectory(ectx,
519 data,
511 size, 520 size,
512 &meta, 521 &meta,
513 &addFilesToDirectory, 522 &addFilesToDirectory,
@@ -528,9 +537,10 @@ void displayDownloadComplete(const struct ECRS_URI * uri,
528 DownloadList * pos; 537 DownloadList * pos;
529 538
530 DEBUG_BEGIN(); 539 DEBUG_BEGIN();
531 LOG(LOG_DEBUG, 540 GE_LOG(ectx,
532 "Download '%s' complete\n", 541 GE_STATUS | GE_USER | GE_BULK,
533 filename); 542 _("Download '%s' complete.\n"),
543 filename);
534 pos = head; 544 pos = head;
535 while (pos != NULL) { 545 while (pos != NULL) {
536 if (ECRS_equalsUri(uri, 546 if (ECRS_equalsUri(uri,
@@ -544,16 +554,20 @@ void displayDownloadComplete(const struct ECRS_URI * uri,
544 if ( (pos->rr != NULL) && 554 if ( (pos->rr != NULL) &&
545 (gtk_tree_row_reference_valid(pos->rr)) ) { 555 (gtk_tree_row_reference_valid(pos->rr)) ) {
546 /* update directory view (if applicable!) */ 556 /* update directory view (if applicable!) */
547 if (OK == getFileSize(filename, &size)) { 557 if (OK == disk_file_size(ectx,
548 LOG(LOG_DEBUG, 558 filename,
549 "Updating directory view of '%s'\n", 559 &size,
550 filename); 560 YES)) {
561 GE_LOG(ectx,
562 GE_DEBUG,
563 "Updating directory view of '%s'\n",
564 filename);
551 565
552 meta = NULL; 566 meta = NULL;
553 fd = fileopen(filename, O_RDONLY); 567 fd = disk_file_open(ectx,
554 if (fd == -1) { 568 filename,
555 LOG_FILE_STRERROR(LOG_ERROR, "open", filename); 569 O_RDONLY);
556 } else { 570 if (fd != -1) {
557 data = MMAP(NULL, 571 data = MMAP(NULL,
558 size, 572 size,
559 PROT_READ, 573 PROT_READ,
@@ -561,10 +575,14 @@ void displayDownloadComplete(const struct ECRS_URI * uri,
561 fd, 575 fd,
562 0); 576 0);
563 if (data == MAP_FAILED) { 577 if (data == MAP_FAILED) {
564 LOG_FILE_STRERROR(LOG_ERROR, "mmap", filename); 578 GE_LOG_STRERROR_FILE(ectx,
579 GE_ERROR | GE_ADMIN | GE_BULK,
580 "mmap",
581 filename);
565 } else { 582 } else {
566 if (data != NULL) { 583 if (data != NULL) {
567 ECRS_listDirectory(data, 584 ECRS_listDirectory(ectx,
585 data,
568 size, 586 size,
569 &meta, 587 &meta,
570 &addFilesToDirectory, 588 &addFilesToDirectory,
@@ -622,28 +640,20 @@ static int delDownloadView(void * cls,
622} 640}
623 641
624static void * clearCompletedDownloads(void * unused) { 642static void * clearCompletedDownloads(void * unused) {
625 FSUI_clearCompletedDownloads(ctx, 643 /* FIXME */
626 &delDownloadView,
627 NULL);
628 return NULL; 644 return NULL;
629} 645}
630 646
631void on_clearCompletedDownloadsButton_clicked(void * unused, 647void on_clearCompletedDownloadsButton_clicked_fs(void * unused,
632 GtkWidget * clearButton) { 648 GtkWidget * clearButton) {
633 run_with_save_calls(&clearCompletedDownloads, 649 run_with_save_calls(&clearCompletedDownloads,
634 NULL); 650 NULL);
635} 651}
636 652
637struct aDC_closure {
638 struct ECRS_URI * u;
639 char * fn;
640};
641
642static void * shutdownCode(void * c) { 653static void * shutdownCode(void * c) {
643 struct aDC_closure * cls = c; 654 struct FSUI_DownloadList * pos = c;
644 FSUI_stopDownload(ctx, 655 FSUI_stopDownload(ctx,
645 cls->u, 656 pos);
646 cls->fn);
647 return NULL; 657 return NULL;
648} 658}
649 659
@@ -651,20 +661,21 @@ static void abortDownloadCallback(GtkTreeModel * model,
651 GtkTreePath * path, 661 GtkTreePath * path,
652 GtkTreeIter * iter, 662 GtkTreeIter * iter,
653 GtkTreeStore * tree) { 663 GtkTreeStore * tree) {
654 struct aDC_closure cls; 664 void * c;
665 struct ECRS_URI * u;
655 666
656 GNUNET_ASSERT(model == GTK_TREE_MODEL(summary)); 667 GE_ASSERT(ectx, model == GTK_TREE_MODEL(summary));
657 gtk_tree_model_get(model, 668 gtk_tree_model_get(model,
658 iter, 669 iter,
659 DOWNLOAD_URI, &cls.u, 670 DOWNLOAD_POS, &c,
660 DOWNLOAD_FILENAME, &cls.fn, 671 DOWNLOAD_URI, &u,
661 -1); 672 -1);
662 run_with_save_calls(&shutdownCode, 673 run_with_save_calls(&shutdownCode,
663 &cls); 674 c);
664 gtk_tree_store_remove(summary, 675 gtk_tree_store_remove(summary,
665 iter); 676 iter);
666 if (cls.u != NULL) 677 if (u != NULL)
667 ECRS_freeUri(cls.u); 678 ECRS_freeUri(u);
668} 679}
669 680
670void on_abortDownloadButton_clicked(void * unused, 681void on_abortDownloadButton_clicked(void * unused,
@@ -683,14 +694,14 @@ void on_abortDownloadButton_clicked(void * unused,
683 DEBUG_END(); 694 DEBUG_END();
684} 695}
685 696
686static int addDownloadView(void * cls, 697int addDownloadView(struct FSUI_DownloadList * pos,
687 const struct FSUI_DownloadList * pos, 698 struct FSUI_DownloadList * ppos,
688 const char * filename, 699 const char * filename,
689 const struct ECRS_URI * uri, 700 const struct ECRS_URI * uri,
690 unsigned long long filesize, 701 unsigned long long filesize,
691 unsigned long long bytesCompleted, 702 unsigned long long bytesCompleted,
692 int isRecursive, 703 int isRecursive,
693 unsigned int anonymityLevel) { 704 unsigned int anonymityLevel) {
694 GtkTreeIter iiter; 705 GtkTreeIter iiter;
695 int progress; 706 int progress;
696 char * uriname; 707 char * uriname;
@@ -712,7 +723,7 @@ static int addDownloadView(void * cls,
712 (sname[-1] != '/') && 723 (sname[-1] != '/') &&
713 (sname[-1] != '\\') ) 724 (sname[-1] != '\\') )
714 sname--; 725 sname--;
715 size_h = getHumanSize(filesize); 726 size_h = string_get_fancy_byte_size(filesize);
716 gtk_tree_store_set(summary, 727 gtk_tree_store_set(summary,
717 &iiter, 728 &iiter,
718 DOWNLOAD_FILENAME, filename, 729 DOWNLOAD_FILENAME, filename,
@@ -731,12 +742,15 @@ static int addDownloadView(void * cls,
731} 742}
732 743
733 744
734void fs_download_start() { 745void fs_download_start(struct GE_Context * e,
746 struct GC_Configuration * c) {
735 GtkWidget * downloadList; 747 GtkWidget * downloadList;
736 GtkCellRenderer * renderer; 748 GtkCellRenderer * renderer;
737 GtkTreeViewColumn * column; 749 GtkTreeViewColumn * column;
738 int col; 750 int col;
739 751
752 ectx = e;
753 cfg = c;
740 DEBUG_BEGIN(); 754 DEBUG_BEGIN();
741 downloadList = glade_xml_get_widget(getMainXML(), 755 downloadList = glade_xml_get_widget(getMainXML(),
742 "activeDownloadsList"); 756 "activeDownloadsList");
@@ -805,10 +819,6 @@ void fs_download_start() {
805 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList), 819 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
806 col - 1), 820 col - 1),
807 TRUE); 821 TRUE);
808 FSUI_listDownloads(ctx,
809 NULL,
810 &addDownloadView,
811 NULL);
812 DEBUG_END(); 822 DEBUG_END();
813} 823}
814 824
diff --git a/src/plugins/fs/download.h b/src/plugins/fs/download.h
index a897d458..3f194c57 100644
--- a/src/plugins/fs/download.h
+++ b/src/plugins/fs/download.h
@@ -41,7 +41,8 @@ void displayDownloadUpdate(const struct ECRS_URI * uri,
41void displayDownloadComplete(const struct ECRS_URI * uri, 41void displayDownloadComplete(const struct ECRS_URI * uri,
42 const char * filename); 42 const char * filename);
43 43
44void fs_download_start(void); 44void fs_download_start(struct GE_Context * e,
45 struct GC_Configuration * c);
45 46
46void fs_download_stop(void); 47void fs_download_stop(void);
47 48
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c
index d7889698..44008226 100644
--- a/src/plugins/fs/fs.c
+++ b/src/plugins/fs/fs.c
@@ -36,9 +36,20 @@
36 36
37struct FSUI_Context * ctx; 37struct FSUI_Context * ctx;
38 38
39static void * saveEventProcessor(void * arg) { 39static struct GE_Context * ectx;
40 const FSUI_Event * event = arg;
41 40
41static struct GC_Configuration * cfg;
42
43typedef struct {
44 const FSUI_Event * event;
45 void * ret;
46} SEP_Closure;
47
48static void saveEventProcessor(void * arg) {
49 SEP_Closure * cls = arg;
50 const FSUI_Event * event = cls->event;
51
52 cls->ret = NULL;
42 DEBUG_BEGIN(); 53 DEBUG_BEGIN();
43 switch (event->type) { 54 switch (event->type) {
44 case FSUI_search_result: 55 case FSUI_search_result:
@@ -50,10 +61,10 @@ static void * saveEventProcessor(void * arg) {
50 GE_LOG(ectx, 61 GE_LOG(ectx,
51 GE_ERROR, 62 GE_ERROR,
52 _("Error while searching: %s\n"), 63 _("Error while searching: %s\n"),
53 event->data.message); 64 event->data.SearchError.message);
54 break; 65 break;
55 case FSUI_download_aborted: 66 case FSUI_download_aborted:
56 case FSUI_download_suspending: 67 case FSUI_download_suspended:
57 /* ignore for now */ 68 /* ignore for now */
58 break; 69 break;
59 case FSUI_download_progress: 70 case FSUI_download_progress:
@@ -62,7 +73,7 @@ static void * saveEventProcessor(void * arg) {
62 event->data.DownloadProgress.last_block, 73 event->data.DownloadProgress.last_block,
63 event->data.DownloadProgress.last_size); 74 event->data.DownloadProgress.last_size);
64 break; 75 break;
65 case FSUI_download_complete: 76 case FSUI_download_completed:
66 displayDownloadComplete(event->data.DownloadProgress.uri, 77 displayDownloadComplete(event->data.DownloadProgress.uri,
67 event->data.DownloadProgress.filename); 78 event->data.DownloadProgress.filename);
68 addLogEntry(_("Download `%s' complete"), 79 addLogEntry(_("Download `%s' complete"),
@@ -76,47 +87,32 @@ static void * saveEventProcessor(void * arg) {
76 GE_LOG(ectx, 87 GE_LOG(ectx,
77 GE_ERROR, 88 GE_ERROR,
78 _("Error while downloading: %s\n"), 89 _("Error while downloading: %s\n"),
79 event->data.message); 90 event->data.DownloadError.message);
80 break; 91 break;
81 case FSUI_upload_progress: 92 case FSUI_upload_progress:
82 displayUploadUpdate(event->data.UploadProgress.main_filename, 93 displayUploadUpdate(event->data.UploadProgress.uc.cctx,
83 event->data.UploadProgress.filename, 94 event->data.UploadProgress.filename,
84 event->data.UploadProgress.completed, 95 event->data.UploadProgress.completed,
85 event->data.UploadProgress.total); 96 event->data.UploadProgress.total);
86 displayUploadUpdate(event->data.UploadProgress.main_filename,
87 event->data.UploadProgress.main_filename,
88 event->data.UploadProgress.main_completed,
89 event->data.UploadProgress.main_total);
90 break; 97 break;
91 case FSUI_upload_complete: 98 case FSUI_upload_completed:
92 displayUploadComplete(event->data.UploadComplete.main_filename, 99 displayUploadComplete(event->data.UploadCompleted.uc.cctx,
93 event->data.UploadComplete.filename, 100 event->data.UploadCompleted.filename,
94 event->data.UploadComplete.uri); 101 event->data.UploadCompleted.uri);
95 addLogEntry(_("Upload `%s' complete"), 102 addLogEntry(_("Upload `%s' complete"),
96 event->data.UploadComplete.filename); 103 event->data.UploadCompleted.filename);
97 gnunetgtk_notify(NOTIFY_NORMAL, 104 gnunetgtk_notify(NOTIFY_NORMAL,
98 _("Upload `%s' complete"), 105 _("Upload `%s' complete"),
99 event->data.UploadComplete.filename); 106 event->data.UploadCompleted.filename);
100 break; 107 break;
101 case FSUI_upload_error: 108 case FSUI_upload_error:
102 GE_LOG(ectx, 109 GE_LOG(ectx,
103 GE_ERROR, 110 GE_ERROR,
104 _("Error while uploading: %s\n"), 111 _("Error while uploading: %s\n"),
105 event->data.message); 112 event->data.UploadError.message);
106 gnunetgtk_notify(NOTIFY_NORMAL, 113 gnunetgtk_notify(NOTIFY_NORMAL,
107 _("Error while uploading `%s'"), 114 _("Error while uploading `%s'"),
108 event->data.message); 115 event->data.UploadError.message);
109 break;
110 case FSUI_gnunetd_connected:
111 GE_LOG(ectx,
112 GE_INFO,
113 _("Connected to gnunetd.\n"));
114 break;
115 case FSUI_gnunetd_disconnected:
116 GE_LOG(ectx,
117 GE_INFO,
118 _("Disconnected from gnunetd.\n"));
119 addLogEntry(_("Disconnected from gnunetd.\n"));
120 break; 116 break;
121 default: 117 default:
122 GE_BREAK(ectx, 0); 118 GE_BREAK(ectx, 0);
@@ -127,23 +123,30 @@ static void * saveEventProcessor(void * arg) {
127 break; 123 break;
128 } 124 }
129 DEBUG_END(); 125 DEBUG_END();
130 return NULL;
131} 126}
132 127
133/** 128/**
134 * FSUI event handler. 129 * FSUI event handler.
135 */ 130 */
136static void eventProcessor(void * cls, 131static void * eventProcessor(void * unused,
137 const FSUI_Event * event) { 132 const FSUI_Event * event) {
133 SEP_Closure cls;
134
135 cls.event = event;
136 cls.ret = NULL;
138 gtkSaveCall(&saveEventProcessor, 137 gtkSaveCall(&saveEventProcessor,
139 (void*) event); 138 &cls);
139 return cls.ret;
140} 140}
141 141
142void init_fs() { 142void init_fs(struct GE_Context * e,
143 struct GC_Configuration * c) {
143 GtkWidget * tab; 144 GtkWidget * tab;
144 GtkWidget * book; 145 GtkWidget * book;
145 gint num; 146 gint num;
146 147
148 ectx = e;
149 cfg = c;
147 tab 150 tab
148 = glade_xml_get_widget(getMainXML(), 151 = glade_xml_get_widget(getMainXML(),
149 "fsnotebook"); 152 "fsnotebook");
@@ -154,15 +157,18 @@ void init_fs() {
154 gtk_notebook_set_current_page(GTK_NOTEBOOK(book), 1); 157 gtk_notebook_set_current_page(GTK_NOTEBOOK(book), 1);
155 gtk_notebook_set_current_page(GTK_NOTEBOOK(book), num); 158 gtk_notebook_set_current_page(GTK_NOTEBOOK(book), num);
156 159
157 ctx = FSUI_start("gnunet-gtk", 160 ctx = FSUI_start(ectx,
161 cfg,
162 "gnunet-gtk",
163 128,
158 YES, 164 YES,
159 &eventProcessor, 165 &eventProcessor,
160 NULL); 166 NULL);
161 fs_collection_start(); 167 fs_collection_start(ectx, cfg);
162 fs_search_start(); 168 fs_search_start(ectx, cfg);
163 fs_download_start(); 169 fs_download_start(ectx, cfg);
164 fs_upload_start(); 170 fs_upload_start(ectx, cfg);
165 fs_namespace_start(); 171 fs_namespace_start(ectx, cfg);
166} 172}
167 173
168void done_fs() { 174void done_fs() {
diff --git a/src/plugins/fs/fs.h b/src/plugins/fs/fs.h
index 5121e9f8..0494a17c 100644
--- a/src/plugins/fs/fs.h
+++ b/src/plugins/fs/fs.h
@@ -68,6 +68,7 @@ enum {
68 DOWNLOAD_URI, 68 DOWNLOAD_URI,
69 DOWNLOAD_TREEPATH, 69 DOWNLOAD_TREEPATH,
70 DOWNLOAD_DIRPATH, 70 DOWNLOAD_DIRPATH,
71 DOWNLOAD_POS, // NEW!
71 DOWNLOAD_NUM 72 DOWNLOAD_NUM
72}; 73};
73 74
diff --git a/src/plugins/fs/meta.c b/src/plugins/fs/meta.c
index 686256d1..74ed7932 100644
--- a/src/plugins/fs/meta.c
+++ b/src/plugins/fs/meta.c
@@ -438,7 +438,7 @@ char * updateIntervalToString(TIME_T interval) {
438 return strdup(_("--sporadic update--")); 438 return strdup(_("--sporadic update--"));
439 if (interval == ECRS_SBLOCK_UPDATE_NONE) 439 if (interval == ECRS_SBLOCK_UPDATE_NONE)
440 return strdup(_("--no update--")); 440 return strdup(_("--no update--"));
441 return timeIntervalToFancyString(interval * cronSECONDS); 441 return string_get_fancy_time_interval(interval * cronSECONDS);
442} 442}
443 443
444int parseTimeInterval(const char * timeSpec, 444int parseTimeInterval(const char * timeSpec,
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index ac4e0ddf..4a3041e5 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -30,6 +30,9 @@
30#include "helper.h" 30#include "helper.h"
31#include "meta.h" 31#include "meta.h"
32#include "namespace.h" 32#include "namespace.h"
33#include <GNUnet/gnunet_util_crypto.h>
34#include <GNUnet/gnunet_uritrack_lib.h>
35#include <GNUnet/gnunet_namespace_lib.h>
33#include <extractor.h> 36#include <extractor.h>
34 37
35#define UPDATE_CONTENT_LIST_FREQUENCY (5 * cronMINUTES) 38#define UPDATE_CONTENT_LIST_FREQUENCY (5 * cronMINUTES)
@@ -52,6 +55,10 @@ static NamespaceList * head;
52 55
53static GladeXML * metaXML; 56static GladeXML * metaXML;
54 57
58static struct GE_Context * ectx;
59
60static struct GC_Configuration * cfg;
61
55static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview, 62static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview,
56 GtkWidget ** anonSpin) { 63 GtkWidget ** anonSpin) {
57 GtkWidget * window; 64 GtkWidget * window;
@@ -295,7 +302,7 @@ static int updateView(const ECRS_FileInfo * fi,
295 uriString = ECRS_uriToString(fi->uri); 302 uriString = ECRS_uriToString(fi->uri);
296 gtk_list_store_append(GTK_LIST_STORE(model), 303 gtk_list_store_append(GTK_LIST_STORE(model),
297 &iter); 304 &iter);
298 size_h = getHumanSize(size); 305 size_h = string_get_fancy_byte_size(size);
299 gtk_list_store_set(GTK_LIST_STORE(model), 306 gtk_list_store_set(GTK_LIST_STORE(model),
300 &iter, 307 &iter,
301 NAMESPACE_FILENAME, filename, 308 NAMESPACE_FILENAME, filename,
@@ -353,8 +360,11 @@ static void doUpdateContentList(void * unused) {
353 "availableContentList"); 360 "availableContentList");
354 model 361 model
355 = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)); 362 = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList));
356 FSUI_listURIs(&updateView, 363 URITRACK_listURIs(ectx,
357 model); 364 cfg,
365 YES,
366 &updateView,
367 model);
358 DEBUG_END(); 368 DEBUG_END();
359} 369}
360 370
@@ -451,7 +461,7 @@ static int addNamespaceContentToModel(void * cls,
451 date = GN_CTIME(&nextPublicationTime); 461 date = GN_CTIME(&nextPublicationTime);
452 462
453 freq = updateIntervalToString(publicationFrequency); 463 freq = updateIntervalToString(publicationFrequency);
454 size_h = getHumanSize(size); 464 size_h = string_get_fancy_byte_size(size);
455 gtk_list_store_append(model, 465 gtk_list_store_append(model,
456 &iter); 466 &iter);
457 gtk_list_store_set(model, 467 gtk_list_store_set(model,
@@ -518,8 +528,9 @@ static int addTabForNamespace(void * unused,
518 list->namespacepage, 528 list->namespacepage,
519 label); 529 label);
520 gtk_widget_show(notebook); 530 gtk_widget_show(notebook);
521 FSUI_listNamespaceContent 531 NS_listNamespaceContent
522 (ctx, 532 (ectx,
533 cfg,
523 namespaceName, 534 namespaceName,
524 &addNamespaceContentToModel, 535 &addNamespaceContentToModel,
525 model); 536 model);
@@ -594,10 +605,13 @@ void create_namespace_clicked(GtkWidget * dummy1,
594 nameLine = glade_xml_get_widget(metaXML, 605 nameLine = glade_xml_get_widget(metaXML,
595 "namespaceNameEntry"); 606 "namespaceNameEntry");
596 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine)); 607 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
597 root = FSUI_createNamespace(ctx, 608 root = NS_createNamespace(ectx,
598 gtk_spin_button_get_value_as_int 609 cfg,
599 (GTK_SPIN_BUTTON(spin)), 610 gtk_spin_button_get_value_as_int
600 namespaceName, 611 (GTK_SPIN_BUTTON(spin)),
612 1000, /* FIXME: priority */
613 999999, /* FIXME: expiration */
614 namespaceName,
601 meta, 615 meta,
602 keywordURI, 616 keywordURI,
603 &rootEntry); 617 &rootEntry);
@@ -677,7 +691,7 @@ void namespaceDelete_clicked(GtkWidget * dummy1,
677 list = list->next; 691 list = list->next;
678 } 692 }
679 if (list == NULL) { 693 if (list == NULL) {
680 BREAK(); 694 GE_BREAK(ectx, 0);
681 return; 695 return;
682 } 696 }
683 /* open window to ask for confirmation, 697 /* open window to ask for confirmation,
@@ -701,7 +715,9 @@ void namespaceDelete_clicked(GtkWidget * dummy1,
701 head = list->next; 715 head = list->next;
702 else 716 else
703 prev->next = list->next; 717 prev->next = list->next;
704 FSUI_deleteNamespace(list->name); 718 NS_deleteNamespace(ectx,
719 cfg,
720 list->name);
705 FREE(list->name); 721 FREE(list->name);
706 ECRS_freeMetaData(list->meta); 722 ECRS_freeMetaData(list->meta);
707 FREE(list); 723 FREE(list);
@@ -748,18 +764,21 @@ static void initiateUpload(GtkTreeModel * model,
748 metadata immediately with the dialog. */ 764 metadata immediately with the dialog. */
749 765
750 if (dst == NULL) { 766 if (dst == NULL) {
751 BREAK(); 767 GE_BREAK(ectx, 0);
752 return; 768 return;
753 } 769 }
754 resultURI = FSUI_addToNamespace(ctx, 770 resultURI = NS_addToNamespace(ectx,
755 cls->anonymityLevel, 771 cfg,
756 cls->namespaceName, 772 cls->anonymityLevel,
757 cls->updateInterval, 773 1000, /* FIXME: priority */
758 cls->lastId, 774 999999, /* FIXME: expiration */
759 &cls->thisId, 775 cls->namespaceName,
760 cls->nextId, 776 cls->updateInterval,
761 dst, 777 cls->lastId,
762 meta); 778 &cls->thisId,
779 cls->nextId,
780 dst,
781 meta);
763 if (resultURI != NULL) { 782 if (resultURI != NULL) {
764 list = head; 783 list = head;
765 while ( (list != NULL) && 784 while ( (list != NULL) &&
@@ -767,7 +786,7 @@ static void initiateUpload(GtkTreeModel * model,
767 list->name)) ) 786 list->name)) )
768 list = list->next; 787 list = list->next;
769 if (list == NULL) { 788 if (list == NULL) {
770 BREAK(); 789 GE_BREAK(ectx, 0);
771 } else { 790 } else {
772 /* update namespace content list! */ 791 /* update namespace content list! */
773 fi.uri = dst; 792 fi.uri = dst;
@@ -834,7 +853,7 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1,
834 if (FALSE == gtk_tree_selection_get_selected(selection, 853 if (FALSE == gtk_tree_selection_get_selected(selection,
835 NULL, 854 NULL,
836 &iter)) { 855 &iter)) {
837 BREAK(); 856 GE_BREAK(ectx, 0);
838 return; 857 return;
839 } 858 }
840 gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)), 859 gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)),
@@ -846,7 +865,7 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1,
846 = glade_xml_get_widget(getMainXML(), 865 = glade_xml_get_widget(getMainXML(),
847 "localNamespacesNotebook"); 866 "localNamespacesNotebook");
848 num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); 867 num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
849 GNUNET_ASSERT(num != -1); 868 GE_ASSERT(ectx, num != -1);
850 page =gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), 869 page =gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
851 num); 870 num);
852 list = head; 871 list = head;
@@ -854,7 +873,7 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1,
854 (list->namespacepage != page) ) 873 (list->namespacepage != page) )
855 list = list->next; 874 list = list->next;
856 if (list == NULL) { 875 if (list == NULL) {
857 BREAK(); 876 GE_BREAK(ectx, 0);
858 return; 877 return;
859 } 878 }
860 cls.namespaceName = list->name; 879 cls.namespaceName = list->name;
@@ -979,7 +998,7 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1,
979 if (FALSE == gtk_tree_selection_get_selected(selection, 998 if (FALSE == gtk_tree_selection_get_selected(selection,
980 NULL, 999 NULL,
981 &iter)) { 1000 &iter)) {
982 BREAK(); 1001 GE_BREAK(ectx, 0);
983 return; 1002 return;
984 } 1003 }
985 gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)), 1004 gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)),
@@ -991,7 +1010,7 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1,
991 = glade_xml_get_widget(getMainXML(), 1010 = glade_xml_get_widget(getMainXML(),
992 "localNamespacesNotebook"); 1011 "localNamespacesNotebook");
993 num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); 1012 num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
994 GNUNET_ASSERT(num != -1); 1013 GE_ASSERT(ectx, num != -1);
995 page =gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), 1014 page =gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
996 num); 1015 num);
997 list = head; 1016 list = head;
@@ -999,7 +1018,7 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1,
999 (list->namespacepage != page) ) 1018 (list->namespacepage != page) )
1000 list = list->next; 1019 list = list->next;
1001 if (list == NULL) { 1020 if (list == NULL) {
1002 BREAK(); 1021 GE_BREAK(ectx, 0);
1003 return; 1022 return;
1004 } 1023 }
1005 cls.namespaceName = list->name; 1024 cls.namespaceName = list->name;
@@ -1023,7 +1042,7 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1,
1023 if (FALSE == gtk_tree_selection_get_selected(selectionNamespace, 1042 if (FALSE == gtk_tree_selection_get_selected(selectionNamespace,
1024 NULL, 1043 NULL,
1025 &iter)) { 1044 &iter)) {
1026 BREAK(); 1045 GE_BREAK(ectx, 0);
1027 return; 1046 return;
1028 } 1047 }
1029 gtk_tree_model_get(list->model, 1048 gtk_tree_model_get(list->model,
@@ -1044,7 +1063,7 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1,
1044 next); 1063 next);
1045 if (OK != enc2hash(next, 1064 if (OK != enc2hash(next,
1046 &cls.thisId)) { 1065 &cls.thisId)) {
1047 BREAK(); 1066 GE_BREAK(ectx, 0);
1048 UNREF(metaXML); 1067 UNREF(metaXML);
1049 metaXML = NULL; 1068 metaXML = NULL;
1050 return; 1069 return;
@@ -1053,14 +1072,14 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1,
1053 &prevId)) { 1072 &prevId)) {
1054 cls.lastId = &prevId; 1073 cls.lastId = &prevId;
1055 } else { 1074 } else {
1056 BREAK(); /* should not happen, try to continue */ 1075 GE_BREAK(ectx, 0); /* should not happen, try to continue */
1057 cls.lastId = NULL; 1076 cls.lastId = NULL;
1058 } 1077 }
1059 nameLine = glade_xml_get_widget(metaXML, 1078 nameLine = glade_xml_get_widget(metaXML,
1060 "nextIdentifierEntry"); 1079 "nextIdentifierEntry");
1061 if (OK != parseTimeInterval(freq, 1080 if (OK != parseTimeInterval(freq,
1062 &cls.updateInterval)) { 1081 &cls.updateInterval)) {
1063 BREAK(); 1082 GE_BREAK(ectx, 0);
1064 cls.updateInterval = ECRS_SBLOCK_UPDATE_SPORADIC; 1083 cls.updateInterval = ECRS_SBLOCK_UPDATE_SPORADIC;
1065 } 1084 }
1066 if (cls.updateInterval == ECRS_SBLOCK_UPDATE_SPORADIC) { 1085 if (cls.updateInterval == ECRS_SBLOCK_UPDATE_SPORADIC) {
@@ -1069,12 +1088,14 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1,
1069 } else { 1088 } else {
1070 EncName updateName; 1089 EncName updateName;
1071 1090
1072 if (OK != FSUI_computeNextId(list->name, 1091 if (OK != NS_computeNextId(ectx,
1073 &prevId, 1092 cfg,
1074 &cls.thisId, 1093 list->name,
1075 cls.updateInterval, 1094 &prevId,
1076 &nextId)) { 1095 &cls.thisId,
1077 BREAK(); 1096 cls.updateInterval,
1097 &nextId)) {
1098 GE_BREAK(ectx, 0);
1078 UNREF(metaXML); 1099 UNREF(metaXML);
1079 metaXML = NULL; 1100 metaXML = NULL;
1080 return; 1101 return;
@@ -1167,7 +1188,8 @@ void on_clearAvailableContentButton_clicked(GtkWidget * dummy1,
1167 "availableContentList"); 1188 "availableContentList");
1168 model 1189 model
1169 = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)); 1190 = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList));
1170 FSUI_clearTrackedURIS(); 1191 URITRACK_clearTrackedURIS(ectx,
1192 cfg);
1171 gtkSaveCall(&clearContentList, model); 1193 gtkSaveCall(&clearContentList, model);
1172 updateContentList(NULL); 1194 updateContentList(NULL);
1173 DEBUG_END(); 1195 DEBUG_END();
@@ -1180,12 +1202,15 @@ void on_trackingCheckButton_toggled(GtkWidget * dummy1,
1180 trackCheckButton 1202 trackCheckButton
1181 = glade_xml_get_widget(getMainXML(), 1203 = glade_xml_get_widget(getMainXML(),
1182 "trackingCheckButton"); 1204 "trackingCheckButton");
1183 FSUI_trackURIS(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trackCheckButton)) == TRUE ? 1205 URITRACK_trackURIS(ectx,
1184 YES : NO); 1206 cfg,
1207 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trackCheckButton)) == TRUE ?
1208 YES : NO);
1185} 1209}
1186 1210
1187 1211
1188void fs_namespace_start() { 1212void fs_namespace_start(struct GE_Context * e,
1213 struct GC_Configuration * c) {
1189 GtkWidget * contentList; 1214 GtkWidget * contentList;
1190 GtkListStore * model; 1215 GtkListStore * model;
1191 GtkCellRenderer * renderer; 1216 GtkCellRenderer * renderer;
@@ -1193,12 +1218,15 @@ void fs_namespace_start() {
1193 GtkTreeViewColumn * column; 1218 GtkTreeViewColumn * column;
1194 int col; 1219 int col;
1195 1220
1221 ectx = e;
1222 cfg = c;
1196 DEBUG_BEGIN(); 1223 DEBUG_BEGIN();
1197 trackCheckButton 1224 trackCheckButton
1198 = glade_xml_get_widget(getMainXML(), 1225 = glade_xml_get_widget(getMainXML(),
1199 "trackingCheckButton"); 1226 "trackingCheckButton");
1200 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(trackCheckButton), 1227 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(trackCheckButton),
1201 FSUI_trackStatus() == YES ? TRUE : FALSE); 1228 URITRACK_trackStatus(ectx,
1229 cfg) == YES ? TRUE : FALSE);
1202 1230
1203 contentList 1231 contentList
1204 = glade_xml_get_widget(getMainXML(), 1232 = glade_xml_get_widget(getMainXML(),
@@ -1263,14 +1291,18 @@ void fs_namespace_start() {
1263 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(contentList), 1291 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(contentList),
1264 col - 1), 1292 col - 1),
1265 TRUE); 1293 TRUE);
1294#if 0
1295 /* FIXME: change to event based update approach! */
1266 addCronJob(&updateContentList, 1296 addCronJob(&updateContentList,
1267 0, 1297 0,
1268 UPDATE_CONTENT_LIST_FREQUENCY, 1298 UPDATE_CONTENT_LIST_FREQUENCY,
1269 NULL); 1299 NULL);
1270 FSUI_listNamespaces(ctx, 1300#endif
1271 YES, 1301 NS_listNamespaces(ectx,
1272 &addTabForNamespace, 1302 cfg,
1273 NULL); 1303 YES,
1304 &addTabForNamespace,
1305 NULL);
1274 DEBUG_END(); 1306 DEBUG_END();
1275} 1307}
1276 1308
diff --git a/src/plugins/fs/namespace.h b/src/plugins/fs/namespace.h
index c2260f29..50e1b258 100644
--- a/src/plugins/fs/namespace.h
+++ b/src/plugins/fs/namespace.h
@@ -27,7 +27,10 @@
27#ifndef GTK_NAMESPACE_H 27#ifndef GTK_NAMESPACE_H
28#define GTK_NAMESPACE_H 28#define GTK_NAMESPACE_H
29 29
30void fs_namespace_start(void); 30#include <GNUnet/gnunet_util.h>
31
32void fs_namespace_start(struct GE_Context * ectx,
33 struct GC_Configuration * cfg);
31 34
32void fs_namespace_stop(void); 35void fs_namespace_stop(void);
33 36
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index e8f08881..369eff46 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -30,7 +30,8 @@
30#include "fs.h" 30#include "fs.h"
31#include "meta.h" 31#include "meta.h"
32#include <extractor.h> 32#include <extractor.h>
33 33#include <GNUnet/gnunet_util_crypto.h>
34#include <GNUnet/gnunet_namespace_lib.h>
34 35
35 36
36/** 37/**
@@ -43,12 +44,16 @@ typedef struct SL {
43 GtkTreeModel * model; 44 GtkTreeModel * model;
44 GtkWidget * anonymityButton; 45 GtkWidget * anonymityButton;
45 struct ECRS_URI * uri; 46 struct ECRS_URI * uri;
47 struct FSUI_SearchList * fsui_list; /* FIXME: initialize! */
46} SearchList; 48} SearchList;
47 49
48static SearchList * head; 50static SearchList * head;
49 51
50static GtkListStore * summary; 52static GtkListStore * summary;
51 53
54static struct GE_Context * ectx;
55
56static struct GC_Configuration * cfg;
52 57
53/** 58/**
54 * Add an entry to the search tree. 59 * Add an entry to the search tree.
@@ -134,7 +139,7 @@ void addEntryToSearchTree(GtkTreeStore * model,
134 } else { 139 } else {
135 pixbuf = NULL; 140 pixbuf = NULL;
136 } 141 }
137 size_h = getHumanSize(size); 142 size_h = string_get_fancy_byte_size(size);
138 gtk_tree_store_set(model, 143 gtk_tree_store_set(model,
139 pos, 144 pos,
140 SEARCH_NAME, name, 145 SEARCH_NAME, name,
@@ -244,14 +249,15 @@ void on_namespaceRatingSpinButton_changed(GtkWidget * dummy,
244 } else { 249 } else {
245 if (encStr != NULL) { 250 if (encStr != NULL) {
246 newrating = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin)); 251 newrating = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
247 rating = FSUI_rankNamespace(ctx, 252 rating = NS_rankNamespace(ectx,
248 encStr, 253 cfg,
249 newrating - rating); 254 encStr,
255 newrating - rating);
250 if (rating != newrating) { 256 if (rating != newrating) {
251 /* concurrent modification? */ 257 /* concurrent modification? */
252 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), 258 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
253 rating); 259 rating);
254 BREAK(); 260 GE_BREAK(ectx, 0);
255 } 261 }
256 gtk_list_store_set(GTK_LIST_STORE(model), 262 gtk_list_store_set(GTK_LIST_STORE(model),
257 &iter, 263 &iter,
@@ -321,8 +327,10 @@ void on_searchNamespaceComboBoxEntry_changed(GtkWidget * dummy,
321 rating); 327 rating);
322 gtk_widget_set_sensitive(spin, 328 gtk_widget_set_sensitive(spin,
323 TRUE); 329 TRUE);
324 if (OK == FSUI_getNamespaceRoot(encStr, 330 if (OK == NS_getNamespaceRoot(ectx,
325 &root)) { 331 cfg,
332 encStr,
333 &root)) {
326 hash2enc(&root, 334 hash2enc(&root,
327 &enc); 335 &enc);
328 keyword 336 keyword
@@ -469,11 +477,11 @@ void displaySearchResult(const ECRS_FileInfo * info,
469} 477}
470 478
471static void * stopSearch(void * u) { 479static void * stopSearch(void * u) {
472 struct ECRS_URI * uri = u; 480 struct FSUI_SearchList * search = u;
473 481
474 DEBUG_BEGIN(); 482 DEBUG_BEGIN();
475 FSUI_stopSearch(ctx, 483 FSUI_stopSearch(ctx,
476 uri); 484 search);
477 DEBUG_END(); 485 DEBUG_END();
478 return NULL; 486 return NULL;
479} 487}
@@ -562,7 +570,7 @@ static void closeSearchPage(SearchList * list) {
562 &iter)); 570 &iter));
563 ECRS_freeUri(list->uri); 571 ECRS_freeUri(list->uri);
564 list->uri = NULL; 572 list->uri = NULL;
565 BREAK(); 573 GE_BREAK(ectx, 0);
566} 574}
567 575
568void on_closeSearchButton_clicked(GtkWidget * searchPage, 576void on_closeSearchButton_clicked(GtkWidget * searchPage,
@@ -587,7 +595,7 @@ void on_closeSearchButton_clicked(GtkWidget * searchPage,
587 prev->next = list->next; 595 prev->next = list->next;
588 596
589 run_with_save_calls(&stopSearch, 597 run_with_save_calls(&stopSearch,
590 list->uri); 598 list->fsui_list);
591 closeSearchPage(list); 599 closeSearchPage(list);
592 FREE(list); 600 FREE(list);
593 DEBUG_END(); 601 DEBUG_END();
@@ -690,9 +698,10 @@ static GtkWidget * makeResultFrame(GtkWidget ** treeview,
690 gtk_tree_view_column_set_reorderable(column, TRUE); 698 gtk_tree_view_column_set_reorderable(column, TRUE);
691 gtk_tree_view_column_set_sort_column_id(column, SEARCH_DESC); 699 gtk_tree_view_column_set_sort_column_id(column, SEARCH_DESC);
692 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ 700 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
693 if (! testConfigurationString("GNUNET-GTK", 701 if (YES != GC_get_configuration_value_yesno(cfg,
694 "DISABLE-PREVIEWS", 702 "GNUNET-GTK",
695 "YES")) { 703 "DISABLE-PREVIEWS",
704 NO)) {
696 renderer = gtk_cell_renderer_pixbuf_new(); 705 renderer = gtk_cell_renderer_pixbuf_new();
697 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), 706 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
698 -1, 707 -1,
@@ -721,14 +730,17 @@ static GtkWidget * makeResultFrame(GtkWidget ** treeview,
721typedef struct { 730typedef struct {
722 struct ECRS_URI * uri; 731 struct ECRS_URI * uri;
723 int anon; 732 int anon;
733 struct FSUI_SearchList * ret;
724} StartSearchClosure; 734} StartSearchClosure;
725 735
726static void * startSearch(void * cls) { 736static void * startSearch(void * cls) {
727 StartSearchClosure * ssc = cls; 737 StartSearchClosure * ssc = cls;
728 738
729 FSUI_startSearch(ctx, 739 ssc->ret = FSUI_startSearch(ctx,
730 ssc->anon, 740 ssc->anon,
731 ssc->uri); 741 1000, /* FIXME: max results */
742 99 * cronYEARS, /* FIXME: timeout */
743 ssc->uri);
732 return NULL; 744 return NULL;
733} 745}
734 746
@@ -815,7 +827,7 @@ void on_fssearchbutton_clicked(gpointer dummy2,
815 strcat(ustring, ns); 827 strcat(ustring, ns);
816 strcat(ustring, "/"); 828 strcat(ustring, "/");
817 strcat(ustring, ss); 829 strcat(ustring, ss);
818 uri = ECRS_stringToUri(ustring); 830 uri = ECRS_stringToUri(ectx, ustring);
819 if (uri == NULL) { 831 if (uri == NULL) {
820 GE_LOG(ectx, 832 GE_LOG(ectx,
821 GE_ERROR | GE_BULK | GE_USER, 833 GE_ERROR | GE_BULK | GE_USER,
@@ -824,14 +836,14 @@ void on_fssearchbutton_clicked(gpointer dummy2,
824 } 836 }
825 FREE(ustring); 837 FREE(ustring);
826 } else { 838 } else {
827 uri = FSUI_parseCharKeywordURI(ss); 839 uri = ECRS_parseCharKeywordURI(ectx, ss);
828 } 840 }
829 if (uri == NULL) 841 if (uri == NULL)
830 return; 842 return;
831 if (ns == NULL) { 843 if (ns == NULL) {
832 tabtxt = STRDUP(ss); 844 tabtxt = STRDUP(ss);
833 } else { 845 } else {
834 GNUNET_ASSERT(descStr != NULL); 846 GE_ASSERT(ectx, descStr != NULL);
835 tabtxt = MALLOC(strlen(ss) + strlen(descStr) + 2); 847 tabtxt = MALLOC(strlen(ss) + strlen(descStr) + 2);
836 SNPRINTF(tabtxt, 848 SNPRINTF(tabtxt,
837 strlen(ss) + strlen(descStr) + 2, 849 strlen(ss) + strlen(descStr) + 2,
@@ -899,6 +911,7 @@ void on_fssearchbutton_clicked(gpointer dummy2,
899 ssc.uri = uri; 911 ssc.uri = uri;
900 run_with_save_calls(&startSearch, 912 run_with_save_calls(&startSearch,
901 &ssc); 913 &ssc);
914 list->fsui_list = ssc.ret;
902 FREE(tabtxt); 915 FREE(tabtxt);
903 DEBUG_END(); 916 DEBUG_END();
904} 917}
@@ -963,6 +976,7 @@ static int addNamespace(void * arg,
963 return OK; 976 return OK;
964} 977}
965 978
979#if 0
966/** 980/**
967 * cron job that periodically updates the model for the 981 * cron job that periodically updates the model for the
968 * namespace selection in the search vbox. 982 * namespace selection in the search vbox.
@@ -986,10 +1000,11 @@ static void updateNCBModelSafe(void * unused) {
986 NS_SEARCH_METADATA, NULL, 1000 NS_SEARCH_METADATA, NULL,
987 NS_SEARCH_RATING, 0, 1001 NS_SEARCH_RATING, 0,
988 -1); 1002 -1);
989 FSUI_listNamespaces(ctx, 1003 NS_listNamespaces(ectx,
990 NO, 1004 cfg,
991 &addNamespace, 1005 NO,
992 model); 1006 &addNamespace,
1007 model);
993 searchNamespaceCB 1008 searchNamespaceCB
994 = glade_xml_get_widget(getMainXML(), 1009 = glade_xml_get_widget(getMainXML(),
995 "searchNamespaceComboBoxEntry"); 1010 "searchNamespaceComboBoxEntry");
@@ -1006,12 +1021,14 @@ static void updateNCBModelSafe(void * unused) {
1006static void updateNCBModel(void * dummy) { 1021static void updateNCBModel(void * dummy) {
1007 gtkSaveCall(&updateNCBModelSafe, NULL); 1022 gtkSaveCall(&updateNCBModelSafe, NULL);
1008} 1023}
1024#endif
1025
1009 1026
1010/** 1027/**
1011 * Open a tab for the given search 1028 * Open a tab for the given search
1012 * (and display the results). 1029 * (and display the results).
1013 */ 1030 */
1014int openTabForSearch(void * unused, 1031int openTabForSearch(struct FSUI_SearchList * slist,
1015 const struct ECRS_URI * uri, 1032 const struct ECRS_URI * uri,
1016 unsigned int anonymityLevel, 1033 unsigned int anonymityLevel,
1017 unsigned int resultCount, 1034 unsigned int resultCount,
@@ -1102,14 +1119,17 @@ int openTabForSearch(void * unused,
1102 return OK; 1119 return OK;
1103} 1120}
1104 1121
1105void fs_search_start() { 1122void fs_search_start(struct GE_Context * e,
1123 struct GC_Configuration * c) {
1106 GtkWidget * searchCB; 1124 GtkWidget * searchCB;
1107 GtkListStore * model; 1125 GtkListStore * model;
1108 GtkWidget * searchList; 1126 GtkWidget * searchList;
1109 GtkCellRenderer * renderer; 1127 GtkCellRenderer * renderer;
1110 GtkTreeViewColumn * column; 1128 GtkTreeViewColumn * column;
1111 int col; 1129 int col;
1112 1130
1131 ectx = e;
1132 cfg = c;
1113 DEBUG_BEGIN(); 1133 DEBUG_BEGIN();
1114 searchCB 1134 searchCB
1115 = glade_xml_get_widget(getMainXML(), 1135 = glade_xml_get_widget(getMainXML(),
@@ -1124,12 +1144,14 @@ void fs_search_start() {
1124 GTK_TREE_MODEL(model)); 1144 GTK_TREE_MODEL(model));
1125 gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(searchCB), 1145 gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(searchCB),
1126 NS_SEARCH_DESCRIPTION); 1146 NS_SEARCH_DESCRIPTION);
1147#if 0
1148 /* FIXME: replace with event callback! */
1127 cron_job_add(cron, 1149 cron_job_add(cron,
1128 &updateNCBModel, 1150 &updateNCBModel,
1129 0, 1151 0,
1130 5 * cronMINUTES, 1152 5 * cronMINUTES,
1131 NULL); 1153 NULL);
1132 1154#endif
1133 searchList = glade_xml_get_widget(getMainXML(), 1155 searchList = glade_xml_get_widget(getMainXML(),
1134 "activeSearchesSummary"); 1156 "activeSearchesSummary");
1135 summary = 1157 summary =
@@ -1173,10 +1195,6 @@ void fs_search_start() {
1173 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList), 1195 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
1174 col - 1), 1196 col - 1),
1175 TRUE); 1197 TRUE);
1176
1177 FSUI_listSearches(ctx,
1178 &openTabForSearch,
1179 NULL);
1180 DEBUG_END(); 1198 DEBUG_END();
1181} 1199}
1182 1200
@@ -1185,10 +1203,12 @@ void fs_search_stop() {
1185 GtkTreeIter iter; 1203 GtkTreeIter iter;
1186 struct ECRS_URI * u; 1204 struct ECRS_URI * u;
1187 1205
1206#if 0
1188 cron_job_del(cron, 1207 cron_job_del(cron,
1189 &updateNCBModel, 1208 &updateNCBModel,
1190 5 * cronMINUTES, 1209 5 * cronMINUTES,
1191 NULL); 1210 NULL);
1211#endif
1192 while (head != NULL) { 1212 while (head != NULL) {
1193 list = head; 1213 list = head;
1194 head = head->next; 1214 head = head->next;
@@ -1222,8 +1242,8 @@ void fs_search_stop() {
1222 * This function is a modified version of an Epiphany/Gedit code, 1242 * This function is a modified version of an Epiphany/Gedit code,
1223 * part of this work is copyrighted (GPL license) by its authors. 1243 * part of this work is copyrighted (GPL license) by its authors.
1224 */ 1244 */
1225GtkWidget *buildSearchTabLabel (GtkWidget *searchPage, const char *title) 1245GtkWidget *buildSearchTabLabel(GtkWidget *searchPage,
1226{ 1246 const char *title) {
1227 GtkWidget *hbox, *label_hbox, *label_ebox; 1247 GtkWidget *hbox, *label_hbox, *label_ebox;
1228 GtkWidget *label, *dummy_label; 1248 GtkWidget *label, *dummy_label;
1229 GtkWidget *close_button; 1249 GtkWidget *close_button;
diff --git a/src/plugins/fs/search.h b/src/plugins/fs/search.h
index 7cf46b7a..089074c3 100644
--- a/src/plugins/fs/search.h
+++ b/src/plugins/fs/search.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2005 Christian Grothoff (and other contributing authors) 3 (C) 2005, 2006 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -28,6 +28,7 @@
28#define GTK_SEARCH_H 28#define GTK_SEARCH_H
29 29
30#include <GNUnet/gnunet_ecrs_lib.h> 30#include <GNUnet/gnunet_ecrs_lib.h>
31#include <GNUnet/gnunet_fsui_lib.h>
31 32
32/** 33/**
33 * Add an entry to the search tree. 34 * Add an entry to the search tree.
@@ -59,13 +60,14 @@ void displaySearchResult(const ECRS_FileInfo * info,
59 */ 60 */
60GtkWidget * getAnonymityButtonFromTM(GtkTreeModel * model); 61GtkWidget * getAnonymityButtonFromTM(GtkTreeModel * model);
61 62
62int openTabForSearch(void * unused, 63int openTabForSearch(struct FSUI_SearchList * list,
63 const struct ECRS_URI * uri, 64 const struct ECRS_URI * uri,
64 unsigned int anonymityLevel, 65 unsigned int anonymityLevel,
65 unsigned int resultCount, 66 unsigned int resultCount,
66 const ECRS_FileInfo * results); 67 const ECRS_FileInfo * results);
67 68
68void fs_search_start(void); 69void fs_search_start(struct GE_Context * e,
70 struct GC_Configuration * c);
69 71
70void fs_search_stop(void); 72void fs_search_stop(void);
71 73
diff --git a/src/plugins/fs/upload.c b/src/plugins/fs/upload.c
index a0fa0e14..6cf8b153 100644
--- a/src/plugins/fs/upload.c
+++ b/src/plugins/fs/upload.c
@@ -49,16 +49,17 @@ static GtkTreeStore * summary;
49 */ 49 */
50static GladeXML * metaXML; 50static GladeXML * metaXML;
51 51
52static struct GE_Context * ectx;
53
54static struct GC_Configuration * cfg;
55
52/** 56/**
53 */ 57 */
54void displayUploadUpdate(const char * mainName, 58void displayUploadUpdate(struct FSUI_UploadList * list,
55 const char * filename, 59 const char * filename,
56 unsigned long long completed, 60 unsigned long long completed,
57 unsigned long long total) { 61 unsigned long long total) {
58 GtkTreeIter iter;
59 GtkTreeIter child;
60 int progress; 62 int progress;
61 char * name;
62 63
63 DEBUG_BEGIN(); 64 DEBUG_BEGIN();
64 if (total != 0) 65 if (total != 0)
@@ -66,184 +67,22 @@ void displayUploadUpdate(const char * mainName,
66 else 67 else
67 progress = 100; 68 progress = 100;
68 69
69 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(summary), 70 /* FIXME! */
70 &iter)) {
71 do {
72 gtk_tree_model_get(GTK_TREE_MODEL(summary),
73 &iter,
74 UPLOAD_FILENAME, &name,
75 -1);
76 if (0 == strcmp(name, filename)) {
77 gtk_tree_store_set(GTK_TREE_STORE(summary),
78 &iter,
79 UPLOAD_PROGRESS, progress,
80 -1);
81 return;
82 }
83 if (0 == strcmp(name, mainName)) {
84 if (gtk_tree_model_iter_children(GTK_TREE_MODEL(summary),
85 &child,
86 &iter)) {
87 do {
88 gtk_tree_model_get(GTK_TREE_MODEL(summary),
89 &child,
90 UPLOAD_FILENAME, &name,
91 -1);
92 if (0 == strcmp(name, filename)) {
93 gtk_tree_store_set(GTK_TREE_STORE(summary),
94 &child,
95 UPLOAD_PROGRESS, progress,
96 -1);
97 return;
98 }
99 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
100 &child));
101 }
102 gtk_tree_store_append(GTK_TREE_STORE(summary),
103 &child,
104 &iter);
105 gtk_tree_store_set(GTK_TREE_STORE(summary),
106 &child,
107 UPLOAD_FILENAME, filename,
108 UPLOAD_PROGRESS, progress,
109 UPLOAD_URISTRING, NULL,
110 -1);
111 return;
112 }
113 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
114 &iter));
115 }
116 if (0 != strcmp(mainName,
117 filename)) {
118 gtk_tree_store_append(GTK_TREE_STORE(summary),
119 &iter,
120 NULL);
121 gtk_tree_store_set(GTK_TREE_STORE(summary),
122 &iter,
123 UPLOAD_FILENAME, mainName,
124 UPLOAD_PROGRESS, 0,
125 UPLOAD_URISTRING, NULL,
126 -1);
127 gtk_tree_store_append(GTK_TREE_STORE(summary),
128 &child,
129 &iter);
130 gtk_tree_store_set(GTK_TREE_STORE(summary),
131 &child,
132 UPLOAD_FILENAME, filename,
133 UPLOAD_PROGRESS, progress,
134 UPLOAD_URISTRING, NULL,
135 -1);
136 } else {
137 gtk_tree_store_append(GTK_TREE_STORE(summary),
138 &iter,
139 NULL);
140 gtk_tree_store_set(GTK_TREE_STORE(summary),
141 &iter,
142 UPLOAD_FILENAME, filename,
143 UPLOAD_PROGRESS, progress,
144 UPLOAD_URISTRING, NULL,
145 -1);
146 }
147 DEBUG_END(); 71 DEBUG_END();
148} 72}
149 73
150/** 74/**
151 */ 75 */
152void displayUploadComplete(const char * mainName, 76void displayUploadComplete(struct FSUI_UploadList * list,
153 const char * filename, 77 const char * filename,
154 const struct ECRS_URI * uri) { 78 const struct ECRS_URI * uri) {
155 GtkTreeIter iter;
156 GtkTreeIter child;
157 char * name;
158 char * us; 79 char * us;
159 80
160 DEBUG_BEGIN(); 81 DEBUG_BEGIN();
161 GE_ASSERT(ectx, uri != NULL); 82 GE_ASSERT(ectx, uri != NULL);
162 us = ECRS_uriToString(uri); 83 us = ECRS_uriToString(uri);
163 GE_ASSERT(ectx, us != NULL); 84 GE_ASSERT(ectx, us != NULL);
164 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(summary), 85 /* FIXME */
165 &iter)) {
166 do {
167 gtk_tree_model_get(GTK_TREE_MODEL(summary),
168 &iter,
169 UPLOAD_FILENAME, &name,
170 -1);
171 if (0 == strcmp(name, filename)) {
172 gtk_tree_store_set(GTK_TREE_STORE(summary),
173 &iter,
174 UPLOAD_PROGRESS, 100,
175 UPLOAD_URISTRING, us,
176 -1);
177 FREE(us);
178 return;
179 }
180 if (0 == strcmp(name, mainName)) {
181 if (gtk_tree_model_iter_children(GTK_TREE_MODEL(summary),
182 &child,
183 &iter)) {
184 do {
185 gtk_tree_model_get(GTK_TREE_MODEL(summary),
186 &child,
187 UPLOAD_FILENAME, &name,
188 -1);
189 if (0 == strcmp(name, filename)) {
190 gtk_tree_store_set(GTK_TREE_STORE(summary),
191 &child,
192 UPLOAD_PROGRESS, 100,
193 UPLOAD_URISTRING, us,
194 -1);
195 FREE(us);
196 return;
197 }
198 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
199 &child));
200 }
201 gtk_tree_store_append(GTK_TREE_STORE(summary),
202 &child,
203 &iter);
204 gtk_tree_store_set(GTK_TREE_STORE(summary),
205 &child,
206 UPLOAD_FILENAME, filename,
207 UPLOAD_PROGRESS, 100,
208 UPLOAD_URISTRING, us,
209 -1);
210 FREE(us);
211 return;
212 }
213 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
214 &iter));
215 }
216 if (0 != strcmp(mainName,
217 filename)) {
218 gtk_tree_store_append(GTK_TREE_STORE(summary),
219 &iter,
220 NULL);
221 gtk_tree_store_set(GTK_TREE_STORE(summary),
222 &iter,
223 UPLOAD_FILENAME, mainName,
224 UPLOAD_PROGRESS, 0,
225 UPLOAD_URISTRING, NULL,
226 -1);
227 gtk_tree_store_append(GTK_TREE_STORE(summary),
228 &child,
229 &iter);
230 gtk_tree_store_set(GTK_TREE_STORE(summary),
231 &iter,
232 UPLOAD_FILENAME, filename,
233 UPLOAD_PROGRESS, 100,
234 UPLOAD_URISTRING, NULL,
235 -1);
236 } else {
237 gtk_tree_store_append(GTK_TREE_STORE(summary),
238 &iter,
239 NULL);
240 gtk_tree_store_set(GTK_TREE_STORE(summary),
241 &iter,
242 UPLOAD_FILENAME, filename,
243 UPLOAD_PROGRESS, 100,
244 UPLOAD_URISTRING, us,
245 -1);
246 }
247 FREE(us); 86 FREE(us);
248 DEBUG_END(); 87 DEBUG_END();
249} 88}
@@ -293,29 +132,24 @@ typedef struct {
293 struct ECRS_URI * keywordURI; 132 struct ECRS_URI * keywordURI;
294 struct ECRS_URI * gkeywordURI; 133 struct ECRS_URI * gkeywordURI;
295 struct ECRS_MetaData * meta; 134 struct ECRS_MetaData * meta;
135 struct FSUI_UploadList * fsui_list; // FIXME: use this!
296} UploadClosure; 136} UploadClosure;
297 137
298static void * doUpload(void * cls) { 138static void * doUpload(void * cls) {
299 UploadClosure * uc = cls; 139 UploadClosure * uc = cls;
300 140
301 if (uc->doRec) { 141 uc->fsui_list = FSUI_startUpload(ctx,
302 FSUI_uploadAll(ctx, 142 uc->filename,
303 uc->filename, 143 (DirectoryScanCallback) &disk_directory_scan,
304 uc->anon, 144 ectx,
305 uc->doIndex, 145 uc->anon,
306 uc->deepIndex, 146 1000, /* FIXME: priority */
307 uc->meta, 147 uc->doIndex,
308 uc->gkeywordURI, 148 YES, /* FIXME: do extract */
309 uc->keywordURI); 149 uc->deepIndex,
310 } else { 150 uc->meta,
311 FSUI_upload(ctx, 151 uc->gkeywordURI,
312 uc->filename, 152 uc->keywordURI);
313 uc->anon,
314 uc->doIndex,
315 NO,
316 uc->meta,
317 uc->keywordURI);
318 }
319 return NULL; 153 return NULL;
320} 154}
321 155
@@ -334,8 +168,12 @@ void on_fsinsertuploadbutton_clicked(gpointer dummy,
334 168
335 DEBUG_BEGIN(); 169 DEBUG_BEGIN();
336 extractors = EXTRACTOR_loadDefaultLibraries(); 170 extractors = EXTRACTOR_loadDefaultLibraries();
337 config = getConfigurationString("FS", 171 config = NULL;
338 "EXTRACTORS"); 172 GC_get_configuration_value_string(cfg,
173 "FS",
174 "EXTRACTORS",
175 NULL,
176 &config);
339 if (config != NULL) { 177 if (config != NULL) {
340 extractors = EXTRACTOR_loadConfigLibraries(extractors, 178 extractors = EXTRACTOR_loadConfigLibraries(extractors,
341 config); 179 config);
@@ -354,7 +192,8 @@ void on_fsinsertuploadbutton_clicked(gpointer dummy,
354 dialog = glade_xml_get_widget(metaXML, 192 dialog = glade_xml_get_widget(metaXML,
355 "metaDataDialog"); 193 "metaDataDialog");
356 uc.meta = ECRS_createMetaData(); 194 uc.meta = ECRS_createMetaData();
357 ECRS_extractMetaData(uc.meta, 195 ECRS_extractMetaData(ectx,
196 uc.meta,
358 uc.filename, 197 uc.filename,
359 extractors); 198 extractors);
360 EXTRACTOR_removeAll(extractors); 199 EXTRACTOR_removeAll(extractors);
@@ -405,7 +244,8 @@ void on_fsinsertuploadbutton_clicked(gpointer dummy,
405 deepIndex = glade_xml_get_widget(getMainXML(), 244 deepIndex = glade_xml_get_widget(getMainXML(),
406 "deepIndexCheckButton"); 245 "deepIndexCheckButton");
407 uc.deepIndex = (TRUE == gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(deepIndex))) ? YES : NO; 246 uc.deepIndex = (TRUE == gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(deepIndex))) ? YES : NO;
408 uc.gkeywordURI = ECRS_stringToUri(ECRS_URI_PREFIX 247 uc.gkeywordURI = ECRS_stringToUri(ectx,
248 ECRS_URI_PREFIX
409 ECRS_SEARCH_INFIX); 249 ECRS_SEARCH_INFIX);
410 run_with_save_calls(&doUpload, 250 run_with_save_calls(&doUpload,
411 &uc); 251 &uc);
@@ -476,7 +316,8 @@ static char * selectFile(const char *oldfilename) {
476 316
477void on_mainFileSharingInsertBrowseButton_clicked(GtkWidget * browseButton, 317void on_mainFileSharingInsertBrowseButton_clicked(GtkWidget * browseButton,
478 gpointer dummy) { 318 gpointer dummy) {
479 char *filename, *oldfilename; 319 char * filename;
320 const char *oldfilename;
480 GtkWidget * uploadLine; 321 GtkWidget * uploadLine;
481 GtkWidget * entry; 322 GtkWidget * entry;
482 GtkListStore * model; 323 GtkListStore * model;
@@ -502,13 +343,16 @@ void on_mainFileSharingInsertBrowseButton_clicked(GtkWidget * browseButton,
502} 343}
503 344
504 345
505void fs_upload_start() { 346void fs_upload_start(struct GE_Context * e,
347 struct GC_Configuration * c) {
506 GtkWidget * uploadList; 348 GtkWidget * uploadList;
507 GtkWidget * uploadEntry; 349 GtkWidget * uploadEntry;
508 GtkCellRenderer * renderer; 350 GtkCellRenderer * renderer;
509 GtkListStore * model; 351 GtkListStore * model;
510 int col; 352 int col;
511 353
354 ectx = e;
355 cfg = c;
512 uploadList = glade_xml_get_widget(getMainXML(), 356 uploadList = glade_xml_get_widget(getMainXML(),
513 "activeUploadsList"); 357 "activeUploadsList");
514 summary = 358 summary =
diff --git a/src/plugins/fs/upload.h b/src/plugins/fs/upload.h
index 1f34b118..d3b418cc 100644
--- a/src/plugins/fs/upload.h
+++ b/src/plugins/fs/upload.h
@@ -29,14 +29,14 @@
29 29
30/** 30/**
31 */ 31 */
32void displayUploadUpdate(const char * mainName, 32void displayUploadUpdate(struct FSUI_UploadList * list,
33 const char * filename, 33 const char * filename,
34 unsigned long long completed, 34 unsigned long long completed,
35 unsigned long long total); 35 unsigned long long total);
36 36
37/** 37/**
38 */ 38 */
39void displayUploadComplete(const char * mainName, 39void displayUploadComplete(struct FSUI_UploadList * list,
40 const char * filename, 40 const char * filename,
41 const struct ECRS_URI * uri); 41 const struct ECRS_URI * uri);
42 42
@@ -54,7 +54,8 @@ void displayUploadResult(const ECRS_FileInfo * info,
54 const struct ECRS_URI * uri, 54 const struct ECRS_URI * uri,
55 GtkTreeRowReference * row); 55 GtkTreeRowReference * row);
56 56
57void fs_upload_start(void); 57void fs_upload_start(struct GE_Context * e,
58 struct GC_Configuration * c);
58 59
59void fs_upload_stop(void); 60void fs_upload_stop(void);
60 61