aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2006-10-26 03:29:34 +0000
committerChristian Grothoff <christian@grothoff.org>2006-10-26 03:29:34 +0000
commit1373e4418f858eb91a513fec64e160dc7ae79295 (patch)
tree1dd2283436e4b262e25bdce976c3a7a75f27efe8
parent3ea2348ed08cfe631d528c6c3c706a667033363a (diff)
downloadgnunet-gtk-1373e4418f858eb91a513fec64e160dc7ae79295.tar.gz
gnunet-gtk-1373e4418f858eb91a513fec64e160dc7ae79295.zip
fsui api fix
-rw-r--r--TODO28
-rw-r--r--gnunet-gtk.glade6
-rw-r--r--src/plugins/fs/fs.c93
-rw-r--r--src/plugins/fs/fs.h3
-rw-r--r--src/plugins/fs/helper.c5
-rw-r--r--src/plugins/fs/search.c701
-rw-r--r--src/plugins/fs/search.h6
7 files changed, 435 insertions, 407 deletions
diff --git a/TODO b/TODO
index c970ead5..f8134666 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,12 @@
10.7.1:; 10.7.1:;
2- support new FSUI apis 2- support new FSUI apis:
3- namespace content list: 3 * linking of search and downloads
4 avoid repeatedly calling slow gnunet-gtk iterator (see drupal) 4 * update event managements for upload
5- support abort of search (without killing it) 5 * complete UI options processing for search and download and upload;
6- fix custom gtk logger (via memory logger?) 6 including recursive download!
7 * test, test, test!
8 * support abort of search/download/upload (without killing it)
9 * check memory leaks!
7- create directory from known file IDs [ medium ] 10- create directory from known file IDs [ medium ]
8 in Assemble Directory's Files Available/Selected 11 in Assemble Directory's Files Available/Selected
9 + have sortability 12 + have sortability
@@ -11,16 +14,21 @@
11 + print filenames as well 14 + print filenames as well
12- disable inactive buttons (if no search/download 15- disable inactive buttons (if no search/download
13 is selected to operate on) [ medium ] 16 is selected to operate on) [ medium ]
14- more help-texts (glade) [ easy ]
15- highlight active downloads in search list [ easy ] 17- highlight active downloads in search list [ easy ]
18- highlight completed downloads [ easy ]
19- more help-texts (glade) [ easy ]
20- disable advanced/namespace menus for now!
16 21
170.7.2: 220.7.2:
18- various minor memory leaks (see 23- various minor memory leaks (see #if 0 code in namespace.c)
19 #if 0 code in namespace.c) 24- proper namespace/collection support:
25 * avoid repeatedly calling slow gnunet-gtk iterator (see drupal)
26 * use new namespace APIs
27 * clean, short namespace search URIs
28- fix custom gtk logger (via memory logger?)
29- show content of current collection
20 30
210.7.3: 310.7.3:
22- show content of current collection
23- highlight completed downloads [ easy ]
24- pop-up dialogs / context menus (show extra information, 32- pop-up dialogs / context menus (show extra information,
25 in particular full metadata) [ medium ] 33 in particular full metadata) [ medium ]
26- add right button popup menu operations for 34- add right button popup menu operations for
diff --git a/gnunet-gtk.glade b/gnunet-gtk.glade
index 6d353f69..77962a31 100644
--- a/gnunet-gtk.glade
+++ b/gnunet-gtk.glade
@@ -915,7 +915,7 @@ This release fixes downloads of files from directories. The previous version ha
915 <property name="use_stock">True</property> 915 <property name="use_stock">True</property>
916 <property name="relief">GTK_RELIEF_NORMAL</property> 916 <property name="relief">GTK_RELIEF_NORMAL</property>
917 <property name="focus_on_click">True</property> 917 <property name="focus_on_click">True</property>
918 <signal name="clicked" handler="on_abortSearchButton_clicked_" last_modification_time="Sun, 22 Oct 2006 06:07:10 GMT"/> 918 <signal name="clicked" handler="on_abortSearchSummaryButton_clicked_" last_modification_time="Sun, 22 Oct 2006 06:07:10 GMT"/>
919 </widget> 919 </widget>
920 <packing> 920 <packing>
921 <property name="padding">0</property> 921 <property name="padding">0</property>
@@ -933,7 +933,7 @@ This release fixes downloads of files from directories. The previous version ha
933 <property name="use_stock">True</property> 933 <property name="use_stock">True</property>
934 <property name="relief">GTK_RELIEF_NORMAL</property> 934 <property name="relief">GTK_RELIEF_NORMAL</property>
935 <property name="focus_on_click">True</property> 935 <property name="focus_on_click">True</property>
936 <signal name="clicked" handler="on_stopSearchButton_clicked_" last_modification_time="Sun, 22 Oct 2006 06:07:31 GMT"/> 936 <signal name="clicked" handler="on_closeSearchSummaryButton_clicked_" last_modification_time="Sun, 22 Oct 2006 06:07:31 GMT"/>
937 </widget> 937 </widget>
938 <packing> 938 <packing>
939 <property name="padding">0</property> 939 <property name="padding">0</property>
@@ -4357,7 +4357,7 @@ Press ENTER to add the data.</atkproperty>
4357 <property name="fixed_height_mode">False</property> 4357 <property name="fixed_height_mode">False</property>
4358 <property name="hover_selection">False</property> 4358 <property name="hover_selection">False</property>
4359 <property name="hover_expand">False</property> 4359 <property name="hover_expand">False</property>
4360 <signal name="destroy" handler="on_searchResults_destroy_" object="searchResults" last_modification_time="Sat, 28 May 2005 13:55:09 GMT"/> 4360 <signal name="destroy" handler="on_closeSearchButton_clicked_" object="searchResults" last_modification_time="Sat, 28 May 2005 13:55:09 GMT"/>
4361 </widget> 4361 </widget>
4362 </child> 4362 </child>
4363 </widget> 4363 </widget>
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c
index cbe76150..ee67ccaa 100644
--- a/src/plugins/fs/fs.c
+++ b/src/plugins/fs/fs.c
@@ -51,43 +51,86 @@ static void saveEventProcessor(void * arg) {
51 cls->ret = NULL; 51 cls->ret = NULL;
52 DEBUG_BEGIN(); 52 DEBUG_BEGIN();
53 switch (event->type) { 53 switch (event->type) {
54 /* search events */
55 case FSUI_search_started:
56 cls->ret = fs_search_started(event->data.SearchStarted.sc.pos,
57 event->data.SearchStarted.searchURI,
58 event->data.SearchStarted.anonymityLevel,
59 0,
60 NULL);
61 break;
54 case FSUI_search_result: 62 case FSUI_search_result:
55 displaySearchResult(&event->data.SearchResult.fi, 63 fs_search_result_received(event->data.SearchResult.sc.cctx,
56 event->data.SearchResult.searchURI, 64 &event->data.SearchResult.fi,
57 NULL); 65 event->data.SearchResult.searchURI);
58 break; 66 break;
59 case FSUI_search_error: 67 case FSUI_search_error:
60 GE_LOG(ectx, 68 fs_search_aborted(event->data.SearchError.sc.cctx);
61 GE_ERROR, 69 break;
62 _("Error while searching: %s\n"), 70 case FSUI_search_aborted:
63 event->data.SearchError.message); 71 fs_search_aborted(event->data.SearchAborted.sc.cctx);
72 break;
73 case FSUI_search_completed:
74 // FIXME...
75 fs_search_aborted(event->data.SearchCompleted.sc.cctx);
76 break;
77 case FSUI_search_suspended:
78 fs_search_aborted(event->data.SearchSuspended.sc.cctx);
64 break; 79 break;
80 case FSUI_search_resumed:
81 cls->ret = fs_search_started(event->data.SearchResumed.sc.pos,
82 event->data.SearchResumed.searchURI,
83 event->data.SearchResumed.anonymityLevel,
84 event->data.SearchResumed.fisSize,
85 event->data.SearchResumed.fis);
86 case FSUI_search_stopped:
87 fs_search_aborted(event->data.SearchError.sc.cctx);
88 break;
89
90
91 /* download events */
65 case FSUI_download_aborted: 92 case FSUI_download_aborted:
93 fs_download_aborted(event->data.DownloadAborted.dc.cctx);
94 break;
95 case FSUI_download_error:
96 fs_download_aborted(event->data.DownloadAborted.dc.cctx);
97 break;
66 case FSUI_download_suspended: 98 case FSUI_download_suspended:
67 /* ignore for now */ 99 fs_download_stopped(event->data.DownloadAborted.dc.cctx);
68 break; 100 break;
69 case FSUI_download_progress: 101 case FSUI_download_progress:
70 displayDownloadUpdate(event->data.DownloadProgress.uri, 102 fs_download_update(event->data.DownloadProgress.dc.cctx,
71 event->data.DownloadProgress.completed, 103 event->data.DownloadProgress.completed,
72 event->data.DownloadProgress.last_block, 104 event->data.DownloadProgress.last_block,
73 event->data.DownloadProgress.last_size); 105 event->data.DownloadProgress.last_size);
74 break; 106 break;
75 case FSUI_download_completed: 107 case FSUI_download_completed:
76 displayDownloadComplete(event->data.DownloadProgress.uri, 108 fs_download_completed(event->data.DownloadCompleted.dc.cctx);
77 event->data.DownloadProgress.filename);
78 addLogEntry(_("Download `%s' complete"),
79 event->data.DownloadProgress.filename);
80 gnunetgtk_notify(NOTIFY_NORMAL,
81 _("Download `%s' complete"),
82 event->data.DownloadProgress.filename);
83 break; 109 break;
84 case FSUI_download_error: 110 case FSUI_download_stopped:
85 GE_BREAK(ectx, 0); 111 fs_download_stopped(event->data.DownloadCompleted.dc.cctx);
86 GE_LOG(ectx, 112 break;
87 GE_ERROR, 113 case FSUI_download_started:
88 _("Error while downloading: %s\n"), 114 cls->ret = fs_download_started(event->data.DownloadStarted.dc.pos,
89 event->data.DownloadError.message); 115 event->data.DownloadStarted.total,
116 event->data.DownloadStarted.anonymityLevel,
117 &event->data.DownloadStarted.fi,
118 event->data.DownloadStarted.filename,
119 0,
120 get_time());
121 break;
122 case FSUI_download_resumed:
123 cls->ret = fs_download_started(event->data.DownloadResumed.dc.pos,
124 event->data.DownloadResumed.total,
125 event->data.DownloadResumed.anonymityLevel,
126 &event->data.DownloadResumed.fi,
127 event->data.DownloadResumed.filename,
128 event->data.DownloadResumed.completed,
129 event->data.DownloadResumed.eta);
90 break; 130 break;
131
132
133 /* upload */
91 case FSUI_upload_progress: 134 case FSUI_upload_progress:
92 displayUploadUpdate(event->data.UploadProgress.uc.cctx, 135 displayUploadUpdate(event->data.UploadProgress.uc.cctx,
93 event->data.UploadProgress.filename, 136 event->data.UploadProgress.filename,
diff --git a/src/plugins/fs/fs.h b/src/plugins/fs/fs.h
index 6ff4b5b3..3b691cf1 100644
--- a/src/plugins/fs/fs.h
+++ b/src/plugins/fs/fs.h
@@ -69,8 +69,7 @@ enum {
69 DOWNLOAD_URISTRING, 69 DOWNLOAD_URISTRING,
70 DOWNLOAD_URI, 70 DOWNLOAD_URI,
71 DOWNLOAD_TREEPATH, 71 DOWNLOAD_TREEPATH,
72 DOWNLOAD_DIRPATH, 72 DOWNLOAD_POS, /* struct DL */
73 DOWNLOAD_POS, // NEW!
74 DOWNLOAD_NUM 73 DOWNLOAD_NUM
75}; 74};
76 75
diff --git a/src/plugins/fs/helper.c b/src/plugins/fs/helper.c
index 6c2a70c0..db35ea03 100644
--- a/src/plugins/fs/helper.c
+++ b/src/plugins/fs/helper.c
@@ -25,7 +25,10 @@
25 */ 25 */
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunetgtk_common.h"
28#include "helper.h" 29#include "helper.h"
30#include "fs.h"
31#include "search.h"
29 32
30/** 33/**
31 * Parse a time given in the form 34 * Parse a time given in the form
@@ -220,7 +223,6 @@ GtkWidget * makeSearchResultFrame(struct GC_Configuration * cfg,
220 GladeXML * searchXML; 223 GladeXML * searchXML;
221 int col; 224 int col;
222 225
223 DEBUG_BEGIN();
224 searchXML 226 searchXML
225 = glade_xml_new(getGladeFileName(), 227 = glade_xml_new(getGladeFileName(),
226 "searchResultsFrame", 228 "searchResultsFrame",
@@ -331,6 +333,5 @@ GtkWidget * makeSearchResultFrame(struct GC_Configuration * cfg,
331 child); 333 child);
332 gtk_widget_destroy(window); 334 gtk_widget_destroy(window);
333 UNREF(searchXML); 335 UNREF(searchXML);
334 DEBUG_END();
335 return child; 336 return child;
336} 337}
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index 6436eb34..fde09856 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -22,11 +22,18 @@
22 * @file src/plugins/fs/search.c 22 * @file src/plugins/fs/search.c
23 * @brief code for searching with gnunet-gtk 23 * @brief code for searching with gnunet-gtk
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 *
26 *
27 * TODO:
28 * - figure out how to handle directories displayed on the
29 * search page (and how to communicate for downloads that
30 * they do or do not hang in the search page!)
25 */ 31 */
26 32
27#include "platform.h" 33#include "platform.h"
28#include "gnunetgtk_common.h" 34#include "gnunetgtk_common.h"
29#include "search.h" 35#include "search.h"
36#include "helper.h"
30#include "fs.h" 37#include "fs.h"
31#include "meta.h" 38#include "meta.h"
32#include <extractor.h> 39#include <extractor.h>
@@ -46,14 +53,6 @@ typedef struct SL {
46 struct FSUI_SearchList * fsui_list; /* FIXME: initialize! */ 53 struct FSUI_SearchList * fsui_list; /* FIXME: initialize! */
47} SearchList; 54} SearchList;
48 55
49static SearchList * search_head;
50
51static GtkListStore * search_summary;
52
53static struct GE_Context * ectx;
54
55static struct GC_Configuration * cfg;
56
57typedef struct DL { 56typedef struct DL {
58 struct DL * next; 57 struct DL * next;
59 struct ECRS_URI * uri; 58 struct ECRS_URI * uri;
@@ -63,10 +62,18 @@ typedef struct DL {
63 struct FSUI_DownloadList * fsui_list; 62 struct FSUI_DownloadList * fsui_list;
64} DownloadList; 63} DownloadList;
65 64
65static SearchList * search_head;
66
66static DownloadList * download_head; 67static DownloadList * download_head;
67 68
69static GtkListStore * search_summary;
70
68static GtkTreeStore * download_summary; 71static GtkTreeStore * download_summary;
69 72
73static struct GE_Context * ectx;
74
75static struct GC_Configuration * cfg;
76
70 77
71void on_fssearchbutton_clicked_fs(gpointer dummy2, 78void on_fssearchbutton_clicked_fs(gpointer dummy2,
72 GtkWidget * searchButton) { 79 GtkWidget * searchButton) {
@@ -74,12 +81,18 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
74 const char * ss; 81 const char * ss;
75 const char * ns; 82 const char * ns;
76 gint pages; 83 gint pages;
77 char * tabtxt;
78 const char * descStr; 84 const char * descStr;
79 char * ustring; 85 char * ustring;
80 gint i; 86 gint i;
81 gint pages;
82 SearchList * list; 87 SearchList * list;
88 GtkListStore * model;
89 GtkTreeModel * tmodel;
90 GtkTreeIter iter;
91 GtkWidget * searchKeywordGtkCB;
92 GtkWidget * searchNamespaceGtkCB;
93 GtkWidget * entry;
94 GtkWidget * notebook;
95 GtkWidget * page;
83 96
84 DEBUG_BEGIN(); 97 DEBUG_BEGIN();
85 searchKeywordGtkCB 98 searchKeywordGtkCB
@@ -152,6 +165,9 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
152 if (uri == NULL) 165 if (uri == NULL)
153 return; 166 return;
154 /* check if search is already running */ 167 /* check if search is already running */
168 notebook
169 = glade_xml_get_widget(getMainXML(),
170 "downloadNotebook");
155 pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); 171 pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
156 list = search_head; 172 list = search_head;
157 while (list != NULL) { 173 while (list != NULL) {
@@ -171,42 +187,14 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
171 } 187 }
172 list = list->next; 188 list = list->next;
173 } 189 }
174 if (ns == NULL) {
175 tabtxt = STRDUP(ss);
176 } else {
177 GE_ASSERT(ectx, descStr != NULL);
178 tabtxt = MALLOC(strlen(ss) + strlen(descStr) + 2);
179 SNPRINTF(tabtxt,
180 strlen(ss) + strlen(descStr) + 2,
181 "%s/%s",
182 descStr,
183 ss);
184 }
185 FSUI_startSearch(ctx, 190 FSUI_startSearch(ctx,
186 getAnonymityLevel(getMainXML(), 191 getAnonymityLevel(getMainXML(),
187 "searchAnonymitySelectionSpinButton"); 192 "searchAnonymitySelectionSpinButton"),
188 1000, /* FIXME: max results */ 193 1000, /* FIXME: max results */
189 99 * cronYEARS, /* FIXME: timeout */ 194 99 * cronYEARS, /* FIXME: timeout */
190 uri); 195 uri);
191} 196}
192 197
193void on_searchResults_destroy_fs(GtkWidget * dummy,
194 GtkWidget * treeview) {
195 SearchList * list;
196
197 DEBUG_BEGIN();
198 list = search_head;
199 while (list != NULL) {
200 if (list->treeview == treeview)
201 break;
202 list = list->next;
203 }
204 GE_ASSERT(ectx, list != NULL);
205 FSUI_stopSearch(ctx,
206 list->fsui_list);
207 DEBUG_END();
208}
209
210void on_closeSearchButton_clicked_fs(GtkWidget * searchPage, 198void on_closeSearchButton_clicked_fs(GtkWidget * searchPage,
211 GtkWidget * closeButton) { 199 GtkWidget * closeButton) {
212 SearchList * list; 200 SearchList * list;
@@ -241,6 +229,60 @@ void on_abortSearchButton_clicked_fs(GtkWidget * searchPage,
241 DEBUG_END(); 229 DEBUG_END();
242} 230}
243 231
232static void stopSearch(GtkTreeModel * model,
233 GtkTreePath * path,
234 GtkTreeIter * iter,
235 gpointer unused) {
236 struct FSUI_SearchList * s;
237
238 s = NULL;
239 gtk_tree_model_get(model,
240 iter,
241 SER_SUM_FSUI, &s,
242 -1);
243 if (s != NULL)
244 FSUI_stopSearch(ctx,
245 s);
246}
247
248void on_closeSearchSummaryButton_clicked_fs(GtkWidget * treeview,
249 GtkWidget * closeButton) {
250 GtkTreeSelection * selection;
251
252 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
253 gtk_tree_selection_selected_foreach
254 (selection,
255 &stopSearch,
256 NULL);
257}
258
259static void abortSearch(GtkTreeModel * model,
260 GtkTreePath * path,
261 GtkTreeIter * iter,
262 gpointer unused) {
263 struct FSUI_SearchList * s;
264
265 s = NULL;
266 gtk_tree_model_get(model,
267 iter,
268 SER_SUM_FSUI, &s,
269 -1);
270 if (s != NULL)
271 FSUI_abortSearch(ctx,
272 s);
273}
274
275void on_abortSearchSummaryButton_clicked_fs(GtkWidget * treeview,
276 GtkWidget * closeButton) {
277 GtkTreeSelection * selection;
278
279 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
280 gtk_tree_selection_selected_foreach
281 (selection,
282 &abortSearch,
283 NULL);
284}
285
244/** 286/**
245 * Add the given result to the model (search result 287 * Add the given result to the model (search result
246 * list). 288 * list).
@@ -263,22 +305,22 @@ void fs_search_result_received(struct SL * searchContext,
263 char * size_h; 305 char * size_h;
264 GtkTreeStore * model; 306 GtkTreeStore * model;
265 GtkTreeIter iter; 307 GtkTreeIter iter;
266 GtkTreeIter parent; 308 unsigned int * file_count;
267 GtkTreeIter * pparent; 309 GtkWidget * tab_label;
310 const char * tab_title;
311 char * new_title;
312 struct ECRS_URI * euri;
268 313
269 DEBUG_BEGIN(); 314 DEBUG_BEGIN();
270 model = GTK_TREE_STORE 315 model = GTK_TREE_STORE
271 (gtk_tree_view_get_model 316 (gtk_tree_view_get_model
272 (GTK_TREE_VIEW(searchContext->treeview))); 317 (GTK_TREE_VIEW(searchContext->treeview)));
273 gtk_tree_store_append(model,
274 &iter,
275 NULL);
276 mime = ECRS_getFromMetaData(info->meta, 318 mime = ECRS_getFromMetaData(info->meta,
277 EXTRACTOR_MIMETYPE); 319 EXTRACTOR_MIMETYPE);
278 if (mime == NULL) 320 if (mime == NULL)
279 mime = STRDUP(_("unknown")); 321 mime = STRDUP(_("unknown"));
280 mime = validate_utf8(mime); 322 mime = validate_utf8(mime);
281 desc = ECRS_getFirstFromMetaData(meta, 323 desc = ECRS_getFirstFromMetaData(info->meta,
282 EXTRACTOR_DESCRIPTION, 324 EXTRACTOR_DESCRIPTION,
283 EXTRACTOR_GENRE, 325 EXTRACTOR_GENRE,
284 EXTRACTOR_ALBUM, 326 EXTRACTOR_ALBUM,
@@ -291,7 +333,7 @@ void fs_search_result_received(struct SL * searchContext,
291 if (desc == NULL) 333 if (desc == NULL)
292 desc = STRDUP(""); 334 desc = STRDUP("");
293 desc = validate_utf8(desc); 335 desc = validate_utf8(desc);
294 name = ECRS_getFirstFromMetaData(meta, 336 name = ECRS_getFirstFromMetaData(info->meta,
295 EXTRACTOR_FILENAME, 337 EXTRACTOR_FILENAME,
296 EXTRACTOR_TITLE, 338 EXTRACTOR_TITLE,
297 EXTRACTOR_ARTIST, 339 EXTRACTOR_ARTIST,
@@ -316,7 +358,7 @@ void fs_search_result_received(struct SL * searchContext,
316 else 358 else
317 size = 0; 359 size = 0;
318 thumb = NULL; 360 thumb = NULL;
319 ts = ECRS_getThumbnailFromMetaData(meta, 361 ts = ECRS_getThumbnailFromMetaData(info->meta,
320 &thumb); 362 &thumb);
321 if (ts != 0) { 363 if (ts != 0) {
322 loader = gdk_pixbuf_loader_new(); 364 loader = gdk_pixbuf_loader_new();
@@ -334,8 +376,11 @@ void fs_search_result_received(struct SL * searchContext,
334 pixbuf = NULL; 376 pixbuf = NULL;
335 } 377 }
336 size_h = string_get_fancy_byte_size(size); 378 size_h = string_get_fancy_byte_size(size);
379 gtk_tree_store_append(model,
380 &iter,
381 NULL);
337 gtk_tree_store_set(model, 382 gtk_tree_store_set(model,
338 pos, 383 &iter,
339 SEARCH_NAME, name, 384 SEARCH_NAME, name,
340 SEARCH_SIZE, size, 385 SEARCH_SIZE, size,
341 SEARCH_HSIZE, size_h, 386 SEARCH_HSIZE, size_h,
@@ -354,12 +399,12 @@ void fs_search_result_received(struct SL * searchContext,
354 399
355 /* update tab title with the number of results */ 400 /* update tab title with the number of results */
356 file_count = (unsigned int *) 401 file_count = (unsigned int *)
357 g_object_get_data(G_OBJECT(list->searchpage), "file_count"); 402 g_object_get_data(G_OBJECT(searchContext->searchpage), "file_count");
358 (*file_count)++; 403 (*file_count)++;
359 tab_label = (GtkWidget *) 404 tab_label = (GtkWidget *)
360 g_object_get_data(G_OBJECT(list->searchpage), "label"); 405 g_object_get_data(G_OBJECT(searchContext->searchpage), "label");
361 tab_title = (char *) 406 tab_title = (const char *)
362 g_object_get_data(G_OBJECT(list->searchpage), "title"); 407 g_object_get_data(G_OBJECT(searchContext->searchpage), "title");
363 new_title = 408 new_title =
364 g_strdup_printf("%s%s%u%s", 409 g_strdup_printf("%s%s%u%s",
365 tab_title, " (", *file_count, ")"); 410 tab_title, " (", *file_count, ")");
@@ -391,7 +436,7 @@ void fs_search_result_received(struct SL * searchContext,
391 &iter)); 436 &iter));
392} 437}
393 438
394static SearchList * 439SearchList *
395fs_search_started(struct FSUI_SearchList * fsui_list, 440fs_search_started(struct FSUI_SearchList * fsui_list,
396 const struct ECRS_URI * uri, 441 const struct ECRS_URI * uri,
397 unsigned int anonymityLevel, 442 unsigned int anonymityLevel,
@@ -404,6 +449,8 @@ fs_search_started(struct FSUI_SearchList * fsui_list,
404 char * tabtxt; 449 char * tabtxt;
405 int i; 450 int i;
406 const char * dhead; 451 const char * dhead;
452 gint pages;
453 char * description;
407 454
408 notebook 455 notebook
409 = glade_xml_get_widget(getMainXML(), 456 = glade_xml_get_widget(getMainXML(),
@@ -411,7 +458,8 @@ fs_search_started(struct FSUI_SearchList * fsui_list,
411 list 458 list
412 = MALLOC(sizeof(SearchList)); 459 = MALLOC(sizeof(SearchList));
413 list->searchpage 460 list->searchpage
414 = makeSearchResultFrame(&list->treeview, 461 = makeSearchResultFrame(cfg,
462 &list->treeview,
415 &list->anonymityButton); 463 &list->anonymityButton);
416 list->uri 464 list->uri
417 = ECRS_dupUri(uri); 465 = ECRS_dupUri(uri);
@@ -424,7 +472,7 @@ fs_search_started(struct FSUI_SearchList * fsui_list,
424 description = ECRS_uriToString(uri); 472 description = ECRS_uriToString(uri);
425 if (description == NULL) { 473 if (description == NULL) {
426 GE_BREAK(ectx, 0); 474 GE_BREAK(ectx, 0);
427 return SYSERR; 475 return NULL;
428 } 476 }
429 GE_ASSERT(ectx, 477 GE_ASSERT(ectx,
430 strlen(description) >= strlen(ECRS_URI_PREFIX)); 478 strlen(description) >= strlen(ECRS_URI_PREFIX));
@@ -449,6 +497,7 @@ fs_search_started(struct FSUI_SearchList * fsui_list,
449 -1); 497 -1);
450 label = buildSearchTabLabel(list->searchpage, 498 label = buildSearchTabLabel(list->searchpage,
451 dhead); 499 dhead);
500 pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
452 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), 501 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
453 list->searchpage, 502 list->searchpage,
454 label); 503 label);
@@ -457,7 +506,7 @@ fs_search_started(struct FSUI_SearchList * fsui_list,
457 gtk_widget_show(notebook); 506 gtk_widget_show(notebook);
458 FREE(description); 507 FREE(description);
459 for (i=0;i<resultCount;i++) 508 for (i=0;i<resultCount;i++)
460 fs_search_result_received(ret, 509 fs_search_result_received(list,
461 &results[i], 510 &results[i],
462 uri); 511 uri);
463 DEBUG_END(); 512 DEBUG_END();
@@ -526,12 +575,13 @@ void fs_search_stopped(SearchList * list) {
526 index = i; 575 index = i;
527 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), 576 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook),
528 index); 577 index);
578#if 0
529 /* recursively free download tree */ 579 /* recursively free download tree */
530 if (gtk_tree_model_get_iter_first(list->model, 580 if (gtk_tree_model_get_iter_first(list->model,
531 &iter)) 581 &iter))
532 freeIterSubtree(list->model, 582 freeIterSubtree(list->model,
533 &iter); 583 &iter);
534 freeSearchModel(list->model, NULL); 584#endif
535 if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(search_summary), 585 if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(search_summary),
536 &iter)) { 586 &iter)) {
537 GE_BREAK(ectx, 0); 587 GE_BREAK(ectx, 0);
@@ -559,150 +609,6 @@ void fs_search_stopped(SearchList * list) {
559 DEBUG_END(); 609 DEBUG_END();
560} 610}
561 611
562void fs_search_start(struct GE_Context * e,
563 struct GC_Configuration * c) {
564 GtkWidget * searchCB;
565 GtkWidget * searchList;
566 GtkListStore * model;
567 GtkCellRenderer * renderer;
568 GtkTreeViewColumn * column;
569 int col;
570 GtkWidget * downloadList;
571
572 ectx = e;
573 cfg = c;
574 DEBUG_BEGIN();
575 searchCB
576 = glade_xml_get_widget(getMainXML(),
577 "fssearchKeywordComboBoxEntry");
578
579 model = gtk_list_store_new(NS_SEARCH_NUM,
580 G_TYPE_STRING, /* what we show */
581 G_TYPE_STRING, /* EncName of namespace */
582 G_TYPE_POINTER, /* ECRS MetaData */
583 G_TYPE_POINTER, /* FSUI search list */
584 G_TYPE_INT); /* Meta-data about namespace */
585 gtk_combo_box_set_model(GTK_COMBO_BOX(searchCB),
586 GTK_TREE_MODEL(model));
587 gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(searchCB),
588 NS_SEARCH_DESCRIPTION);
589 searchList = glade_xml_get_widget(getMainXML(),
590 "activeSearchesSummary");
591 search_summary =
592 gtk_list_store_new(SER_SUM_NUM,
593 G_TYPE_STRING, /* name */
594 G_TYPE_INT, /* # results */
595 G_TYPE_POINTER, /* internal: FSUI search list */
596 G_TYPE_POINTER); /* internal: uri */
597 gtk_tree_view_set_model(GTK_TREE_VIEW(searchList),
598 GTK_TREE_MODEL(search_summary));
599 renderer = gtk_cell_renderer_text_new();
600 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(searchList),
601 -1,
602 _("Query"),
603 renderer,
604 "text", SER_SUM_NAME,
605 NULL);
606 column = gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
607 col - 1);
608 gtk_tree_view_column_set_resizable(column, TRUE);
609 gtk_tree_view_column_set_clickable(column, TRUE);
610 gtk_tree_view_column_set_reorderable(column, TRUE);
611 gtk_tree_view_column_set_sort_column_id(column, SER_SUM_NAME);
612 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
613 col - 1),
614 TRUE);
615 renderer = gtk_cell_renderer_text_new();
616 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(searchList),
617 -1,
618 _("Results"),
619 renderer,
620 "text", SER_SUM_COUNT,
621 NULL);
622 column = gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
623 col - 1);
624 gtk_tree_view_column_set_resizable(column, TRUE);
625 gtk_tree_view_column_set_clickable(column, TRUE);
626 gtk_tree_view_column_set_reorderable(column, TRUE);
627 gtk_tree_view_column_set_sort_column_id(column, SER_SUM_COUNT);
628 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
629 col - 1),
630 TRUE);
631
632
633 downloadList = glade_xml_get_widget(getMainXML(),
634 "activeDownloadsList");
635 download_summary =
636 gtk_tree_store_new(DOWNLOAD_NUM,
637 G_TYPE_STRING, /* name (full-path file name) */
638 G_TYPE_STRING, /* name (user-friendly name) */
639 G_TYPE_UINT64, /* size */
640 G_TYPE_STRING, /* human readable size */
641 G_TYPE_INT, /* progress */
642 G_TYPE_STRING, /* uri */
643 G_TYPE_POINTER, /* url */
644 G_TYPE_POINTER, /* internal: gtk tree path / NULL */
645 G_TYPE_STRING); /* directory path if file is inside a dir */
646 gtk_tree_view_set_model(GTK_TREE_VIEW(downloadList),
647 GTK_TREE_MODEL(download_summary));
648 renderer = gtk_cell_renderer_progress_new();
649 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
650 -1,
651 _("Name"),
652 renderer,
653 "value", DOWNLOAD_PROGRESS,
654 "text", DOWNLOAD_SHORTNAME,
655 NULL);
656 column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
657 col - 1);
658 gtk_tree_view_column_set_resizable(column, TRUE);
659 gtk_tree_view_column_set_clickable(column, TRUE);
660 gtk_tree_view_column_set_reorderable(column, TRUE);
661 gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_PROGRESS);
662 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
663 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
664 col - 1),
665 TRUE);
666 renderer = gtk_cell_renderer_text_new();
667 g_object_set (renderer, "xalign", 1.00, NULL);
668 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
669 -1,
670 _("Size"),
671 renderer,
672 "text", DOWNLOAD_HSIZE,
673 NULL);
674
675 column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
676 col - 1);
677 gtk_tree_view_column_set_resizable(column, TRUE);
678 gtk_tree_view_column_set_clickable(column, TRUE);
679 gtk_tree_view_column_set_reorderable(column, TRUE);
680 gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_SIZE);
681 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
682 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
683 col - 1),
684 TRUE);
685 renderer = gtk_cell_renderer_text_new();
686 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
687 -1,
688 _("URI"),
689 renderer,
690 "text", DOWNLOAD_URISTRING,
691 NULL);
692 column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
693 col - 1);
694 gtk_tree_view_column_set_resizable(column, TRUE);
695 gtk_tree_view_column_set_reorderable(column, TRUE);
696 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
697 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
698 col - 1),
699 TRUE);
700 DEBUG_END();
701}
702
703void fs_search_stop() {
704}
705
706 612
707 613
708 614
@@ -780,46 +686,59 @@ struct DL *
780fs_download_started(struct FSUI_DownloadList * fsui_dl, 686fs_download_started(struct FSUI_DownloadList * fsui_dl,
781 unsigned long long total, 687 unsigned long long total,
782 unsigned int anonymityLevel, 688 unsigned int anonymityLevel,
783 const struct ECRS_FileInfo * fi, 689 const ECRS_FileInfo * fi,
784 const char * filename, 690 const char * filename,
785 unsigned long long completed, 691 unsigned long long completed,
786 cron_t eta) { 692 cron_t eta) {
787 DownloadList * list; 693 DownloadList * list;
788 GtkTreeIter iiter; 694 GtkTreeIter iiter;
789 GtkTreePath *dirTreePath;
790 unsigned long long size; 695 unsigned long long size;
791 char * size_h; 696 char * size_h;
792 const char * idc_name; 697 const char * sname;
698 int progress;
699 char * uri_name;
793 700
794 /* setup visualization */ 701 /* setup visualization */
795 list = MALLOC(sizeof(DownloadList)); 702 list = MALLOC(sizeof(DownloadList));
796 list->download_list = fsui_dl; 703 list->fsui_list = fsui_dl;
797 list->rr = NULL; 704 list->rr = NULL;
798 list->model = NULL; 705 list->model = NULL;
706#if 0
799 if (YES == ECRS_isDirectory(fi->meta)) { 707 if (YES == ECRS_isDirectory(fi->meta)) {
800 list->rr = gtk_tree_row_reference_new(model, path); 708 list->rr = gtk_tree_row_reference_new(model, path);
801 list->model = model; 709 list->model = model;
802 } 710 }
711#endif
803 list->uri = ECRS_dupUri(fi->uri); 712 list->uri = ECRS_dupUri(fi->uri);
804 list->filename = STRDUP(filename); 713 list->filename = STRDUP(filename);
805 size = ECRS_fileSize(fi->uri); 714 size = ECRS_fileSize(fi->uri);
806 size_h = string_get_fancy_byte_size(size); 715 size_h = string_get_fancy_byte_size(size);
807 idc_name = "FIXME"; 716 sname = &filename[strlen(filename)-1];
717 while ( (sname > filename) &&
718 (sname[-1] != '/') &&
719 (sname[-1] != '\\') )
720 sname--;
721 if (size != 0)
722 progress = completed * 100 / size;
723 else
724 progress = 100;
725 uri_name = ECRS_uriToString(fi->uri);
808 gtk_tree_store_append(download_summary, 726 gtk_tree_store_append(download_summary,
809 &iiter, 727 &iiter,
810 NULL); 728 NULL);
811 gtk_tree_store_set(download_summary, 729 gtk_tree_store_set(download_summary,
812 &iiter, 730 &iiter,
813 DOWNLOAD_FILENAME, filename, 731 DOWNLOAD_FILENAME, filename,
814 DOWNLOAD_SHORTNAME, idc_name, 732 DOWNLOAD_SHORTNAME, sname,
815 DOWNLOAD_SIZE, size, 733 DOWNLOAD_SIZE, size,
816 DOWNLOAD_HSIZE, size_h, 734 DOWNLOAD_HSIZE, size_h,
817 DOWNLOAD_PROGRESS, 0, /* progress */ 735 DOWNLOAD_PROGRESS, progress,
818 DOWNLOAD_URISTRING, uri_name, 736 DOWNLOAD_URISTRING, uri_name,
819 DOWNLOAD_URI, ECRS_dupUri(fi->uri), 737 DOWNLOAD_URI, ECRS_dupUri(fi->uri),
820 DOWNLOAD_TREEPATH, list->rr, /* internal: row reference! */ 738 DOWNLOAD_TREEPATH, list->rr, /* internal: row reference! */
821 DOWNLOAD_DIRPATH, dirPath, 739 DOWNLOAD_POS, list,
822 -1); 740 -1);
741 FREE(uri_name);
823 FREE(size_h); 742 FREE(size_h);
824 list->next = download_head; 743 list->next = download_head;
825 download_head = list; 744 download_head = list;
@@ -836,7 +755,6 @@ static void initiateDownload(GtkTreeModel * model,
836 gpointer unused) { 755 gpointer unused) {
837 char * uri_name; 756 char * uri_name;
838 char * final_download_dir; 757 char * final_download_dir;
839 DownloadList * list;
840 GtkTreeIter iiter; 758 GtkTreeIter iiter;
841 GtkWidget * spin; 759 GtkWidget * spin;
842 const char * oname; 760 const char * oname;
@@ -845,16 +763,12 @@ static void initiateDownload(GtkTreeModel * model,
845 GtkTreePath *dirTreePath; 763 GtkTreePath *dirTreePath;
846 char *dirPath; 764 char *dirPath;
847 unsigned int dirPathLen; 765 unsigned int dirPathLen;
848 char * size_h;
849 unsigned long long size;
850
851 struct ECRS_URI * idc_uri; 766 struct ECRS_URI * idc_uri;
852 struct ECRS_MetaData * idc_meta; 767 struct ECRS_MetaData * idc_meta;
853 const char * idc_name; 768 const char * idc_name;
854 const char * idc_mime; 769 const char * idc_mime;
855 char * idc_final_download_destination; 770 char * idc_final_download_destination;
856 unsigned int idc_anon; 771 unsigned int idc_anon;
857 struct FSUI_SearchList * idc_ret;
858 struct SL * searchContext; 772 struct SL * searchContext;
859 773
860#ifdef WINDOWS 774#ifdef WINDOWS
@@ -1020,9 +934,10 @@ static void initiateDownload(GtkTreeModel * model,
1020 934
1021 addLogEntry(_("Downloading `%s'"), idc_name); 935 addLogEntry(_("Downloading `%s'"), idc_name);
1022 FSUI_startDownload(ctx, 936 FSUI_startDownload(ctx,
1023 idc->anon, 937 idc_anon,
1024 NO, /* FIXME: isRecursive */ 938 NO, /* FIXME: isRecursive */
1025 idc_uri, 939 idc_uri,
940 idc_meta,
1026 idc_final_download_destination); 941 idc_final_download_destination);
1027 FREE(uri_name); 942 FREE(uri_name);
1028 FREE(dirPath); 943 FREE(dirPath);
@@ -1048,19 +963,13 @@ void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry,
1048 GtkWidget * downloadButton) { 963 GtkWidget * downloadButton) {
1049 struct ECRS_URI * idc_uri; 964 struct ECRS_URI * idc_uri;
1050 struct ECRS_MetaData * idc_meta; 965 struct ECRS_MetaData * idc_meta;
1051 const char * idc_name;
1052 const char * idc_mime;
1053 char * idc_final_download_destination; 966 char * idc_final_download_destination;
1054 unsigned int idc_anon; 967 unsigned int idc_anon;
1055 struct FSUI_SearchList * idc_ret;
1056 const char * uris; 968 const char * uris;
1057 char * urid; 969 char * urid;
1058 GtkWidget * spin; 970 GtkWidget * spin;
1059 char * final_download_dir; 971 char * final_download_dir;
1060 const char * dname; 972 const char * dname;
1061 DownloadList * list;
1062 GtkTreeIter iiter;
1063 char * size_h;
1064 973
1065 uris = gtk_entry_get_text(GTK_ENTRY(entry)); 974 uris = gtk_entry_get_text(GTK_ENTRY(entry));
1066 urid = STRDUP(uris); 975 urid = STRDUP(uris);
@@ -1097,33 +1006,6 @@ void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry,
1097 strcat(idc_final_download_destination, DIR_SEPARATOR_STR); 1006 strcat(idc_final_download_destination, DIR_SEPARATOR_STR);
1098 strcat(idc_final_download_destination, dname); 1007 strcat(idc_final_download_destination, dname);
1099 1008
1100 /* setup visualization */
1101 list = MALLOC(sizeof(DownloadList));
1102 list->next = download_head;
1103 list->rr = NULL;
1104 list->model = NULL;
1105 list->uri = idc_uri;
1106 list->filename = idc_final_download_destination;
1107 list->finalName = STRDUP(idc_final_download_destination);
1108 download_head = list;
1109 size_h = string_get_fancy_byte_size(ECRS_fileSize(idc_uri));
1110 gtk_tree_store_insert(download_summary,
1111 &iiter,
1112 NULL,
1113 0);
1114 gtk_tree_store_set(download_summary,
1115 &iiter,
1116 DOWNLOAD_FILENAME, idc_final_download_destination,
1117 DOWNLOAD_SHORTNAME, uris,
1118 DOWNLOAD_SIZE, ECRS_fileSize(idc_uri),
1119 DOWNLOAD_HSIZE, size_h,
1120 DOWNLOAD_PROGRESS, 0, /* progress */
1121 DOWNLOAD_URISTRING, uris,
1122 DOWNLOAD_URI, ECRS_dupUri(idc_uri),
1123 DOWNLOAD_TREEPATH, NULL, /* internal: row reference! */
1124 DOWNLOAD_DIRPATH, "",
1125 -1);
1126 FREE(size_h);
1127 /* get anonymity level */ 1009 /* get anonymity level */
1128 spin = glade_xml_get_widget(getMainXML(), 1010 spin = glade_xml_get_widget(getMainXML(),
1129 "fsstatusAnonymitySpin"); 1011 "fsstatusAnonymitySpin");
@@ -1135,11 +1017,14 @@ void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry,
1135 (GTK_SPIN_BUTTON(spin)); 1017 (GTK_SPIN_BUTTON(spin));
1136 } 1018 }
1137 addLogEntry(_("Downloading `%s'"), uris); 1019 addLogEntry(_("Downloading `%s'"), uris);
1020 idc_meta = ECRS_createMetaData();
1138 FSUI_startDownload(ctx, 1021 FSUI_startDownload(ctx,
1139 idc_anon, 1022 idc_anon,
1140 NO, /* FIXME: isRecursive */ 1023 NO, /* FIXME: isRecursive */
1141 idc_uri, 1024 idc_uri,
1025 idc_meta,
1142 idc_final_download_destination); 1026 idc_final_download_destination);
1027 ECRS_freeMetaData(idc_meta);
1143 FREE(urid); 1028 FREE(urid);
1144} 1029}
1145 1030
@@ -1151,7 +1036,7 @@ void fs_download_update(struct DL * downloadContext,
1151 GtkTreeIter iter; 1036 GtkTreeIter iter;
1152 unsigned int val; 1037 unsigned int val;
1153 unsigned long long total; 1038 unsigned long long total;
1154 struct ECRS_URI * u; 1039 struct DL * p;
1155 struct ECRS_MetaData * meta; 1040 struct ECRS_MetaData * meta;
1156 1041
1157 DEBUG_BEGIN(); 1042 DEBUG_BEGIN();
@@ -1161,11 +1046,9 @@ void fs_download_update(struct DL * downloadContext,
1161 gtk_tree_model_get(GTK_TREE_MODEL(download_summary), 1046 gtk_tree_model_get(GTK_TREE_MODEL(download_summary),
1162 &iter, 1047 &iter,
1163 DOWNLOAD_SIZE, &total, 1048 DOWNLOAD_SIZE, &total,
1164 DOWNLOAD_URI, &u, 1049 DOWNLOAD_POS, &p,
1165 -1); 1050 -1);
1166 if (u == NULL) 1051 if (p == downloadContext) {
1167 return;
1168 if (ECRS_equalsUri(u, uri)) {
1169 if (total != 0) 1052 if (total != 0)
1170 val = completed * 100 / total; 1053 val = completed * 100 / total;
1171 else 1054 else
@@ -1179,15 +1062,17 @@ void fs_download_update(struct DL * downloadContext,
1179 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(download_summary), 1062 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(download_summary),
1180 &iter)); 1063 &iter));
1181 } 1064 }
1065#if 0
1182 meta = NULL; 1066 meta = NULL;
1183 ECRS_listDirectory(ectx, 1067 ECRS_listDirectory(ectx,
1184 data, 1068 data,
1185 size, 1069 size,
1186 &meta, 1070 &meta,
1187 &addFilesToDirectory, 1071 &addFilesToDirectory,
1188 (void*)uri); 1072 downloadContext->uri);
1189 if (meta != NULL) 1073 if (meta != NULL)
1190 ECRS_freeMetaData(meta); 1074 ECRS_freeMetaData(meta);
1075#endif
1191 DEBUG_END(); 1076 DEBUG_END();
1192} 1077}
1193 1078
@@ -1196,67 +1081,58 @@ void fs_download_completed(struct DL * downloadContext) {
1196 char * data; 1081 char * data;
1197 int fd; 1082 int fd;
1198 struct ECRS_MetaData * meta; 1083 struct ECRS_MetaData * meta;
1199 DownloadList * pos;
1200 1084
1201 DEBUG_BEGIN(); 1085 DEBUG_BEGIN();
1202 GE_LOG(ectx, 1086 GE_LOG(ectx,
1203 GE_STATUS | GE_USER | GE_BULK, 1087 GE_STATUS | GE_USER | GE_BULK,
1204 _("Download '%s' complete.\n"), 1088 _("Download '%s' complete.\n"),
1205 filename); 1089 downloadContext->filename);
1206 pos = download_head;
1207 while (pos != NULL) {
1208 if (ECRS_equalsUri(uri,
1209 pos->uri))
1210 break;
1211 pos = pos->next;
1212 }
1213
1214 /* Not available for resumed downloads */ 1090 /* Not available for resumed downloads */
1215 if (pos != NULL) { 1091 if ( (downloadContext->rr != NULL) &&
1216 if ( (pos->rr != NULL) && 1092 (gtk_tree_row_reference_valid(downloadContext->rr)) ) {
1217 (gtk_tree_row_reference_valid(pos->rr)) ) { 1093 /* update directory view (if applicable!) */
1218 /* update directory view (if applicable!) */ 1094 if (OK == disk_file_size(ectx,
1219 if (OK == disk_file_size(ectx, 1095 downloadContext->filename,
1220 filename, 1096 &size,
1221 &size, 1097 YES)) {
1222 YES)) { 1098 GE_LOG(ectx,
1223 GE_LOG(ectx, 1099 GE_DEBUG,
1224 GE_DEBUG, 1100 "Updating directory view of '%s'\n",
1225 "Updating directory view of '%s'\n", 1101 downloadContext->filename);
1226 filename); 1102
1227 1103 meta = NULL;
1228 meta = NULL; 1104 fd = disk_file_open(ectx,
1229 fd = disk_file_open(ectx, 1105 downloadContext->filename,
1230 filename, 1106 O_RDONLY);
1231 O_RDONLY); 1107 if (fd != -1) {
1232 if (fd != -1) { 1108 data = MMAP(NULL,
1233 data = MMAP(NULL, 1109 size,
1234 size, 1110 PROT_READ,
1235 PROT_READ, 1111 MAP_SHARED,
1236 MAP_SHARED, 1112 fd,
1237 fd, 1113 0);
1238 0); 1114 if (data == MAP_FAILED) {
1239 if (data == MAP_FAILED) { 1115 GE_LOG_STRERROR_FILE(ectx,
1240 GE_LOG_STRERROR_FILE(ectx, 1116 GE_ERROR | GE_ADMIN | GE_BULK,
1241 GE_ERROR | GE_ADMIN | GE_BULK, 1117 "mmap",
1242 "mmap", 1118 downloadContext->filename);
1243 filename); 1119 } else {
1244 } else { 1120#if 0
1245 if (data != NULL) { 1121 if (data != NULL) {
1246 ECRS_listDirectory(ectx, 1122 ECRS_listDirectory(ectx,
1247 data, 1123 data,
1248 size, 1124 size,
1249 &meta, 1125 &meta,
1250 &addFilesToDirectory, 1126 &addFilesToDirectory,
1251 (void*)uri); 1127 downloadContext->uri);
1252 MUNMAP(data, size); 1128 MUNMAP(data, size);
1253 }
1254 } 1129 }
1255 CLOSE(fd); 1130#endif
1256 } 1131 }
1257 if (meta != NULL) 1132 CLOSE(fd);
1258 ECRS_freeMetaData(meta);
1259 } 1133 }
1134 if (meta != NULL)
1135 ECRS_freeMetaData(meta);
1260 } 1136 }
1261 } 1137 }
1262 DEBUG_END(); 1138 DEBUG_END();
@@ -1264,9 +1140,7 @@ void fs_download_completed(struct DL * downloadContext) {
1264 1140
1265void fs_download_stopped(struct DL * downloadContext) { 1141void fs_download_stopped(struct DL * downloadContext) {
1266 GtkTreeIter iter; 1142 GtkTreeIter iter;
1267 char * f; 1143 struct DL * d;
1268 char * fn;
1269 struct ECRS_URI * u;
1270 1144
1271 DEBUG_BEGIN(); 1145 DEBUG_BEGIN();
1272 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(download_summary), 1146 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(download_summary),
@@ -1274,15 +1148,9 @@ void fs_download_stopped(struct DL * downloadContext) {
1274 do { 1148 do {
1275 gtk_tree_model_get(GTK_TREE_MODEL(download_summary), 1149 gtk_tree_model_get(GTK_TREE_MODEL(download_summary),
1276 &iter, 1150 &iter,
1277 DOWNLOAD_FILENAME, &f, 1151 DOWNLOAD_POS, &d,
1278 DOWNLOAD_URI, &u,
1279 -1); 1152 -1);
1280 1153 if (d == downloadContext) {
1281 f = strrchr(f, DIR_SEPARATOR);
1282 fn = strrchr(filename, DIR_SEPARATOR);
1283
1284 if ( (ECRS_equalsUri(u, uri)) &&
1285 (0 == strcmp(f, fn)) ) {
1286 gtk_tree_store_remove(download_summary, 1154 gtk_tree_store_remove(download_summary,
1287 &iter); 1155 &iter);
1288 break; 1156 break;
@@ -1291,7 +1159,7 @@ void fs_download_stopped(struct DL * downloadContext) {
1291 &iter)); 1159 &iter));
1292 } 1160 }
1293 DEBUG_END(); 1161 DEBUG_END();
1294 return OK; 1162 /* FIXME: free dl downloadContext! */
1295} 1163}
1296 1164
1297void on_clearCompletedDownloadsButton_clicked_fs(void * unused, 1165void on_clearCompletedDownloadsButton_clicked_fs(void * unused,
@@ -1302,7 +1170,7 @@ void on_clearCompletedDownloadsButton_clicked_fs(void * unused,
1302static void abortDownloadCallback(GtkTreeModel * model, 1170static void abortDownloadCallback(GtkTreeModel * model,
1303 GtkTreePath * path, 1171 GtkTreePath * path,
1304 GtkTreeIter * iter, 1172 GtkTreeIter * iter,
1305 GtkTreeStore * tree) { 1173 gpointer unused) {
1306 struct DL * dl; 1174 struct DL * dl;
1307 1175
1308 GE_ASSERT(ectx, model == GTK_TREE_MODEL(download_summary)); 1176 GE_ASSERT(ectx, model == GTK_TREE_MODEL(download_summary));
@@ -1331,53 +1199,158 @@ void on_abortDownloadButton_clicked_fs(void * unused,
1331} 1199}
1332 1200
1333 1201
1334struct DL *
1335fs_download_started(struct FSUI_DownloadList * fsui_dl,
1336 unsigned long long total,
1337 unsigned int anonymityLevel,
1338 const struct ECRS_FileInfo * fi,
1339 const char * filename,
1340 unsigned long long completed,
1341 cron_t eta) {
1342 GtkTreeIter iiter;
1343 int progress;
1344 char * uriname;
1345 const char * sname;
1346 char * size_h;
1347 struct DL * list;
1348 1202
1203
1204
1205
1206
1207
1208
1209
1210
1211void fs_search_start(struct GE_Context * e,
1212 struct GC_Configuration * c) {
1213 GtkWidget * searchCB;
1214 GtkWidget * searchList;
1215 GtkListStore * model;
1216 GtkCellRenderer * renderer;
1217 GtkTreeViewColumn * column;
1218 int col;
1219 GtkWidget * downloadList;
1220
1221 ectx = e;
1222 cfg = c;
1349 DEBUG_BEGIN(); 1223 DEBUG_BEGIN();
1350 if (filesize != 0) 1224 searchCB
1351 progress = bytesCompleted * 100 / filesize; 1225 = glade_xml_get_widget(getMainXML(),
1352 else 1226 "fssearchKeywordComboBoxEntry");
1353 progress = 100; 1227
1354 uriname = ECRS_uriToString(uri); 1228 model = gtk_list_store_new(NS_SEARCH_NUM,
1355 gtk_tree_store_insert(download_summary, 1229 G_TYPE_STRING, /* what we show */
1356 &iiter, 1230 G_TYPE_STRING, /* EncName of namespace */
1357 NULL, 1231 G_TYPE_POINTER, /* ECRS MetaData */
1358 0); 1232 G_TYPE_POINTER, /* FSUI search list */
1359 sname = &filename[strlen(filename)-1]; 1233 G_TYPE_INT); /* Meta-data about namespace */
1360 while ( (sname > filename) && 1234 gtk_combo_box_set_model(GTK_COMBO_BOX(searchCB),
1361 (sname[-1] != '/') && 1235 GTK_TREE_MODEL(model));
1362 (sname[-1] != '\\') ) 1236 gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(searchCB),
1363 sname--; 1237 NS_SEARCH_DESCRIPTION);
1364 size_h = string_get_fancy_byte_size(filesize); 1238 searchList = glade_xml_get_widget(getMainXML(),
1365 gtk_tree_store_set(download_summary, 1239 "activeSearchesSummary");
1366 &iiter, 1240 search_summary =
1367 DOWNLOAD_FILENAME, filename, 1241 gtk_list_store_new(SER_SUM_NUM,
1368 DOWNLOAD_SHORTNAME, sname, 1242 G_TYPE_STRING, /* name */
1369 DOWNLOAD_SIZE, filesize, 1243 G_TYPE_INT, /* # results */
1370 DOWNLOAD_HSIZE, size_h, 1244 G_TYPE_POINTER, /* internal: FSUI search list */
1371 DOWNLOAD_PROGRESS, progress, 1245 G_TYPE_POINTER); /* internal: uri */
1372 DOWNLOAD_URISTRING, uriname, 1246 gtk_tree_view_set_model(GTK_TREE_VIEW(searchList),
1373 DOWNLOAD_URI, ECRS_dupUri(uri), 1247 GTK_TREE_MODEL(search_summary));
1374 DOWNLOAD_TREEPATH, NULL, 1248 renderer = gtk_cell_renderer_text_new();
1375 DOWNLOAD_POS, list, 1249 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(searchList),
1376 -1); 1250 -1,
1377 FREE(size_h); 1251 _("Query"),
1378 FREE(uriname); 1252 renderer,
1253 "text", SER_SUM_NAME,
1254 NULL);
1255 column = gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
1256 col - 1);
1257 gtk_tree_view_column_set_resizable(column, TRUE);
1258 gtk_tree_view_column_set_clickable(column, TRUE);
1259 gtk_tree_view_column_set_reorderable(column, TRUE);
1260 gtk_tree_view_column_set_sort_column_id(column, SER_SUM_NAME);
1261 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
1262 col - 1),
1263 TRUE);
1264 renderer = gtk_cell_renderer_text_new();
1265 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(searchList),
1266 -1,
1267 _("Results"),
1268 renderer,
1269 "text", SER_SUM_COUNT,
1270 NULL);
1271 column = gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
1272 col - 1);
1273 gtk_tree_view_column_set_resizable(column, TRUE);
1274 gtk_tree_view_column_set_clickable(column, TRUE);
1275 gtk_tree_view_column_set_reorderable(column, TRUE);
1276 gtk_tree_view_column_set_sort_column_id(column, SER_SUM_COUNT);
1277 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(searchList),
1278 col - 1),
1279 TRUE);
1280
1281
1282 downloadList = glade_xml_get_widget(getMainXML(),
1283 "activeDownloadsList");
1284 download_summary =
1285 gtk_tree_store_new(DOWNLOAD_NUM,
1286 G_TYPE_STRING, /* name (full-path file name) */
1287 G_TYPE_STRING, /* name (user-friendly name) */
1288 G_TYPE_UINT64, /* size */
1289 G_TYPE_STRING, /* human readable size */
1290 G_TYPE_INT, /* progress */
1291 G_TYPE_STRING, /* uri */
1292 G_TYPE_POINTER, /* url */
1293 G_TYPE_POINTER, /* internal: gtk tree path / NULL */
1294 G_TYPE_POINTER); /* directory path if file is inside a dir */
1295 gtk_tree_view_set_model(GTK_TREE_VIEW(downloadList),
1296 GTK_TREE_MODEL(download_summary));
1297 renderer = gtk_cell_renderer_progress_new();
1298 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
1299 -1,
1300 _("Name"),
1301 renderer,
1302 "value", DOWNLOAD_PROGRESS,
1303 "text", DOWNLOAD_SHORTNAME,
1304 NULL);
1305 column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
1306 col - 1);
1307 gtk_tree_view_column_set_resizable(column, TRUE);
1308 gtk_tree_view_column_set_clickable(column, TRUE);
1309 gtk_tree_view_column_set_reorderable(column, TRUE);
1310 gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_PROGRESS);
1311 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
1312 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
1313 col - 1),
1314 TRUE);
1315 renderer = gtk_cell_renderer_text_new();
1316 g_object_set (renderer, "xalign", 1.00, NULL);
1317 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
1318 -1,
1319 _("Size"),
1320 renderer,
1321 "text", DOWNLOAD_HSIZE,
1322 NULL);
1323
1324 column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
1325 col - 1);
1326 gtk_tree_view_column_set_resizable(column, TRUE);
1327 gtk_tree_view_column_set_clickable(column, TRUE);
1328 gtk_tree_view_column_set_reorderable(column, TRUE);
1329 gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_SIZE);
1330 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
1331 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
1332 col - 1),
1333 TRUE);
1334 renderer = gtk_cell_renderer_text_new();
1335 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
1336 -1,
1337 _("URI"),
1338 renderer,
1339 "text", DOWNLOAD_URISTRING,
1340 NULL);
1341 column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
1342 col - 1);
1343 gtk_tree_view_column_set_resizable(column, TRUE);
1344 gtk_tree_view_column_set_reorderable(column, TRUE);
1345 /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/
1346 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
1347 col - 1),
1348 TRUE);
1379 DEBUG_END(); 1349 DEBUG_END();
1380 return list;
1381} 1350}
1382 1351
1352void fs_search_stop() {
1353}
1354
1355
1383/* end of search.c */ 1356/* end of search.c */
diff --git a/src/plugins/fs/search.h b/src/plugins/fs/search.h
index f3678982..8b7a7f48 100644
--- a/src/plugins/fs/search.h
+++ b/src/plugins/fs/search.h
@@ -38,7 +38,7 @@ struct DL *
38fs_download_started(struct FSUI_DownloadList * fsui_dl, 38fs_download_started(struct FSUI_DownloadList * fsui_dl,
39 unsigned long long total, 39 unsigned long long total,
40 unsigned int anonymityLevel, 40 unsigned int anonymityLevel,
41 const struct ECRS_FileInfo * fi, 41 const ECRS_FileInfo * fi,
42 const char * filename, 42 const char * filename,
43 unsigned long long completed, 43 unsigned long long completed,
44 cron_t eta); 44 cron_t eta);
@@ -102,4 +102,8 @@ void fs_search_start(struct GE_Context * e,
102void fs_search_stop(void); 102void fs_search_stop(void);
103 103
104 104
105void on_closeSearchButton_clicked_fs(GtkWidget * searchPage,
106 GtkWidget * closeButton);
107
108
105#endif 109#endif