diff options
Diffstat (limited to 'src/plugins/fs/fs.c')
-rw-r--r-- | src/plugins/fs/fs.c | 176 |
1 files changed, 168 insertions, 8 deletions
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c index 654d8c82..edd2e045 100644 --- a/src/plugins/fs/fs.c +++ b/src/plugins/fs/fs.c | |||
@@ -25,19 +25,26 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunetgtk_common.h" | ||
29 | #include "fs.h" | 28 | #include "fs.h" |
29 | #include "download.h" | ||
30 | #include "search.h" | 30 | #include "search.h" |
31 | #include "upload.h" | 31 | #include "upload.h" |
32 | #include "collection.h" | 32 | #include "collection.h" |
33 | #include "namespace.h" | 33 | #include "namespace.h" |
34 | #include <GNUnet/gnunet_fsui_lib.h> | ||
35 | 34 | ||
36 | struct FSUI_Context * ctx; | 35 | struct FSUI_Context * ctx; |
37 | 36 | ||
38 | static struct GE_Context * ectx; | 37 | struct GE_Context * ectx; |
39 | 38 | ||
40 | static struct GC_Configuration * cfg; | 39 | struct GC_Configuration * cfg; |
40 | |||
41 | SearchList * search_head; | ||
42 | |||
43 | DownloadList * download_head; | ||
44 | |||
45 | GtkListStore * search_summary; | ||
46 | |||
47 | GtkTreeStore * download_summary; | ||
41 | 48 | ||
42 | typedef struct { | 49 | typedef struct { |
43 | const FSUI_Event * event; | 50 | const FSUI_Event * event; |
@@ -112,7 +119,7 @@ static void saveEventProcessor(void * arg) { | |||
112 | break; | 119 | break; |
113 | case FSUI_download_started: | 120 | case FSUI_download_started: |
114 | cls->ret = fs_download_started(event->data.DownloadStarted.dc.pos, | 121 | cls->ret = fs_download_started(event->data.DownloadStarted.dc.pos, |
115 | event->data.DownloadStarted.dc.pctx, | 122 | event->data.DownloadStarted.dc.pcctx, |
116 | event->data.DownloadStarted.dc.sctx, | 123 | event->data.DownloadStarted.dc.sctx, |
117 | event->data.DownloadStarted.total, | 124 | event->data.DownloadStarted.total, |
118 | event->data.DownloadStarted.anonymityLevel, | 125 | event->data.DownloadStarted.anonymityLevel, |
@@ -123,7 +130,7 @@ static void saveEventProcessor(void * arg) { | |||
123 | break; | 130 | break; |
124 | case FSUI_download_resumed: | 131 | case FSUI_download_resumed: |
125 | cls->ret = fs_download_started(event->data.DownloadResumed.dc.pos, | 132 | cls->ret = fs_download_started(event->data.DownloadResumed.dc.pos, |
126 | event->data.DownloadStarted.dc.pctx, | 133 | event->data.DownloadStarted.dc.pcctx, |
127 | event->data.DownloadStarted.dc.sctx, | 134 | event->data.DownloadStarted.dc.sctx, |
128 | event->data.DownloadResumed.total, | 135 | event->data.DownloadResumed.total, |
129 | event->data.DownloadResumed.anonymityLevel, | 136 | event->data.DownloadResumed.anonymityLevel, |
@@ -185,6 +192,159 @@ static void * eventProcessor(void * unused, | |||
185 | return cls.ret; | 192 | return cls.ret; |
186 | } | 193 | } |
187 | 194 | ||
195 | |||
196 | |||
197 | /** | ||
198 | * Setup the summary views (in particular the models | ||
199 | * and the renderers). | ||
200 | */ | ||
201 | static void fs_summary_start() { | ||
202 | GtkComboBoxEntry * searchCB; | ||
203 | GtkTreeView * searchList; | ||
204 | GtkTreeView * downloadList; | ||
205 | GtkListStore * model; | ||
206 | GtkCellRenderer * renderer; | ||
207 | GtkTreeViewColumn * column; | ||
208 | int col; | ||
209 | |||
210 | searchCB | ||
211 | = GTK_COMBO_BOX_ENTRY(glade_xml_get_widget(getMainXML(), | ||
212 | "fssearchKeywordComboBoxEntry")); | ||
213 | |||
214 | model = gtk_list_store_new(NS_SEARCH_NUM, | ||
215 | G_TYPE_STRING, /* what we show */ | ||
216 | G_TYPE_STRING, /* EncName of namespace */ | ||
217 | G_TYPE_POINTER, /* ECRS MetaData */ | ||
218 | G_TYPE_POINTER, /* FSUI search list */ | ||
219 | G_TYPE_INT); /* Meta-data about namespace */ | ||
220 | gtk_combo_box_set_model(GTK_COMBO_BOX(searchCB), | ||
221 | GTK_TREE_MODEL(model)); | ||
222 | gtk_combo_box_entry_set_text_column(searchCB, | ||
223 | NS_SEARCH_DESCRIPTION); | ||
224 | searchList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), | ||
225 | "activeSearchesSummary")); | ||
226 | search_summary = | ||
227 | gtk_list_store_new(SEARCH_SUMMARY_NUM, | ||
228 | G_TYPE_STRING, /* name */ | ||
229 | G_TYPE_INT, /* # results */ | ||
230 | G_TYPE_POINTER); /* internal: search list */ | ||
231 | gtk_tree_view_set_model(searchList, | ||
232 | GTK_TREE_MODEL(search_summary)); | ||
233 | gtk_tree_selection_set_mode(gtk_tree_view_get_selection(searchList), | ||
234 | GTK_SELECTION_MULTIPLE); | ||
235 | |||
236 | renderer = gtk_cell_renderer_text_new(); | ||
237 | col = gtk_tree_view_insert_column_with_attributes(searchList, | ||
238 | -1, | ||
239 | _("Query"), | ||
240 | renderer, | ||
241 | "text", SEARCH_SUMMARY_NAME, | ||
242 | NULL); | ||
243 | column = gtk_tree_view_get_column(searchList, | ||
244 | col - 1); | ||
245 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
246 | gtk_tree_view_column_set_clickable(column, TRUE); | ||
247 | gtk_tree_view_column_set_reorderable(column, TRUE); | ||
248 | gtk_tree_view_column_set_sort_column_id(column, SEARCH_SUMMARY_NAME); | ||
249 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
250 | renderer = gtk_cell_renderer_text_new(); | ||
251 | col = gtk_tree_view_insert_column_with_attributes(searchList, | ||
252 | -1, | ||
253 | _("Results"), | ||
254 | renderer, | ||
255 | "text", SEARCH_SUMMARY_RESULT_COUNT, | ||
256 | NULL); | ||
257 | column = gtk_tree_view_get_column(searchList, | ||
258 | col - 1); | ||
259 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
260 | gtk_tree_view_column_set_clickable(column, TRUE); | ||
261 | gtk_tree_view_column_set_reorderable(column, TRUE); | ||
262 | gtk_tree_view_column_set_sort_column_id(column, SEARCH_SUMMARY_RESULT_COUNT); | ||
263 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
264 | |||
265 | |||
266 | downloadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), | ||
267 | "activeDownloadsList")); | ||
268 | download_summary = | ||
269 | gtk_tree_store_new(DOWNLOAD_NUM, | ||
270 | G_TYPE_STRING, /* name (full-path file name) */ | ||
271 | G_TYPE_STRING, /* name (user-friendly name) */ | ||
272 | G_TYPE_UINT64, /* size */ | ||
273 | G_TYPE_STRING, /* human readable size */ | ||
274 | G_TYPE_INT, /* progress */ | ||
275 | G_TYPE_STRING, /* uri as string */ | ||
276 | G_TYPE_POINTER); /* internal download list ptr */ | ||
277 | gtk_tree_view_set_model(downloadList, | ||
278 | GTK_TREE_MODEL(download_summary)); | ||
279 | gtk_tree_selection_set_mode(gtk_tree_view_get_selection(downloadList), | ||
280 | GTK_SELECTION_MULTIPLE); | ||
281 | renderer = gtk_cell_renderer_progress_new(); | ||
282 | col = gtk_tree_view_insert_column_with_attributes(downloadList, | ||
283 | -1, | ||
284 | _("Name"), | ||
285 | renderer, | ||
286 | "value", DOWNLOAD_PROGRESS, | ||
287 | "text", DOWNLOAD_SHORTNAME, | ||
288 | NULL); | ||
289 | column = gtk_tree_view_get_column(downloadList, | ||
290 | col - 1); | ||
291 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
292 | gtk_tree_view_column_set_clickable(column, TRUE); | ||
293 | gtk_tree_view_column_set_reorderable(column, TRUE); | ||
294 | gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_PROGRESS); | ||
295 | /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ | ||
296 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
297 | renderer = gtk_cell_renderer_text_new(); | ||
298 | g_object_set (renderer, "xalign", 1.00, NULL); | ||
299 | col = gtk_tree_view_insert_column_with_attributes(downloadList, | ||
300 | -1, | ||
301 | _("Size"), | ||
302 | renderer, | ||
303 | "text", DOWNLOAD_HSIZE, | ||
304 | NULL); | ||
305 | |||
306 | column = gtk_tree_view_get_column(downloadList, | ||
307 | col - 1); | ||
308 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
309 | gtk_tree_view_column_set_clickable(column, TRUE); | ||
310 | gtk_tree_view_column_set_reorderable(column, TRUE); | ||
311 | gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_SIZE); | ||
312 | /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ | ||
313 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
314 | renderer = gtk_cell_renderer_text_new(); | ||
315 | col = gtk_tree_view_insert_column_with_attributes(downloadList, | ||
316 | -1, | ||
317 | _("URI"), | ||
318 | renderer, | ||
319 | "text", DOWNLOAD_URISTRING, | ||
320 | NULL); | ||
321 | column = gtk_tree_view_get_column(downloadList, | ||
322 | col - 1); | ||
323 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
324 | gtk_tree_view_column_set_reorderable(column, TRUE); | ||
325 | /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ | ||
326 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
327 | } | ||
328 | |||
329 | /** | ||
330 | * Shutdown. | ||
331 | */ | ||
332 | static void fs_summary_stop() { | ||
333 | GtkComboBox * searchCB; | ||
334 | GtkListStore * model; | ||
335 | |||
336 | searchCB | ||
337 | = GTK_COMBO_BOX(glade_xml_get_widget(getMainXML(), | ||
338 | "fssearchKeywordComboBoxEntry")); | ||
339 | model = GTK_LIST_STORE(gtk_combo_box_get_model(searchCB)); | ||
340 | /* FIXME: iterate over model entries | ||
341 | and free URIs and MetaData! */ | ||
342 | } | ||
343 | |||
344 | |||
345 | |||
346 | |||
347 | |||
188 | void init_fs(struct GE_Context * e, | 348 | void init_fs(struct GE_Context * e, |
189 | struct GC_Configuration * c) { | 349 | struct GC_Configuration * c) { |
190 | GtkWidget * tab; | 350 | GtkWidget * tab; |
@@ -211,7 +371,7 @@ void init_fs(struct GE_Context * e, | |||
211 | &eventProcessor, | 371 | &eventProcessor, |
212 | NULL); | 372 | NULL); |
213 | fs_collection_start(ectx, cfg); | 373 | fs_collection_start(ectx, cfg); |
214 | fs_search_start(ectx, cfg); | 374 | fs_summary_start(); |
215 | fs_upload_start(ectx, cfg); | 375 | fs_upload_start(ectx, cfg); |
216 | fs_namespace_start(ectx, cfg); | 376 | fs_namespace_start(ectx, cfg); |
217 | } | 377 | } |
@@ -223,7 +383,7 @@ void done_fs() { | |||
223 | = glade_xml_get_widget(getMainXML(), | 383 | = glade_xml_get_widget(getMainXML(), |
224 | "fsnotebook"); | 384 | "fsnotebook"); |
225 | gtk_widget_hide(tab); | 385 | gtk_widget_hide(tab); |
226 | fs_search_stop(); | 386 | fs_summary_stop(); |
227 | fs_collection_stop(); | 387 | fs_collection_stop(); |
228 | fs_namespace_stop(); | 388 | fs_namespace_stop(); |
229 | fs_upload_stop(); | 389 | fs_upload_stop(); |