1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
|
/*
This file is part of GNUnet.
(C) 2005, 2006, 2007 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
* @file src/plugins/fs/fs.c
* @brief main file-sharing code of gnunet-gtk
* @author Christian Grothoff
*/
#include "platform.h"
#include <GNUnet/gnunet_collection_lib.h>
#include <gdk/gdk.h>
#include "fs.h"
#include "meta.h"
#include "download.h"
#include "search.h"
#include "upload.h"
#include "collection.h"
#include "namespace.h"
struct GNUNET_FSUI_Context *ctx;
struct GNUNET_GE_Context *ectx;
struct GNUNET_GC_Configuration *cfg;
SearchList *search_head;
DownloadList *download_head;
UploadList *upload_head;
GtkListStore *search_summary;
GtkTreeStore *download_summary;
GtkTreeStore *upload_summary;
/**
* Last right-click event coordinates in summary.
*/
static unsigned int last_x;
/**
* Last right-click event coordinates in summary.
*/
static unsigned int last_y;
void
on_updateIntervalComboEntry_changed_fs (GtkWidget * button,
GtkWidget * entryBox)
{
const char *time;
GNUNET_Int32Time t;
GtkEntry *entry;
entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (entryBox)));
time = gtk_entry_get_text (entry);
if (GNUNET_OK != parseTimeInterval (time, &t))
{
gtk_widget_set_sensitive (button, FALSE);
}
else
{
gtk_widget_set_sensitive (button, TRUE);
}
}
/**
* The selection of the download summary changed.
* Update button status.
*/
void
on_anonymity_spin_changed_fs (GtkWidget * w, gpointer dummy)
{
gint val;
GdkColor color;
GtkSpinButton *spin;
spin = GTK_SPIN_BUTTON (w);
if (spin == NULL)
{
GNUNET_GE_BREAK (NULL, 0);
return;
}
val = gtk_spin_button_get_value_as_int (spin);
if (val == 0)
{
if ((TRUE == gdk_color_parse ("red",
&color)) &&
(TRUE == gdk_colormap_alloc_color (gdk_colormap_get_system (),
&color, FALSE, TRUE)))
gtk_widget_modify_base (w, GTK_STATE_NORMAL, &color);
}
else
gtk_widget_modify_base (w, GTK_STATE_NORMAL, NULL);
}
static void *
saveEventProcessor (void *cls)
{
const GNUNET_FSUI_Event *event = cls;
void *ret;
ret = NULL;
switch (event->type)
{
/* search events */
case GNUNET_FSUI_search_started:
ret = fs_search_started (event->data.SearchStarted.sc.pos,
event->data.SearchStarted.searchURI,
event->data.SearchStarted.anonymityLevel,
0, NULL, GNUNET_FSUI_ACTIVE);
break;
case GNUNET_FSUI_search_result:
fs_search_result_received (event->data.SearchResult.sc.cctx,
&event->data.SearchResult.fi,
event->data.SearchResult.searchURI);
break;
case GNUNET_FSUI_search_error:
fs_search_aborted (event->data.SearchError.sc.cctx);
break;
case GNUNET_FSUI_search_aborted:
fs_search_aborted (event->data.SearchAborted.sc.cctx);
break;
case GNUNET_FSUI_search_paused:
fs_search_paused (event->data.SearchPaused.sc.cctx);
break;
case GNUNET_FSUI_search_restarted:
fs_search_restarted (event->data.SearchRestarted.sc.cctx);
break;
case GNUNET_FSUI_search_completed:
fs_search_aborted (event->data.SearchCompleted.sc.cctx);
break;
case GNUNET_FSUI_search_suspended:
fs_search_aborted (event->data.SearchSuspended.sc.cctx);
break;
case GNUNET_FSUI_search_resumed:
ret = fs_search_started (event->data.SearchResumed.sc.pos,
event->data.SearchResumed.searchURI,
event->data.SearchResumed.anonymityLevel,
event->data.SearchResumed.fisSize,
event->data.SearchResumed.fis,
event->data.SearchResumed.state);
break;
case GNUNET_FSUI_search_stopped:
fs_search_stopped (event->data.SearchStopped.sc.cctx);
break;
/* download events */
case GNUNET_FSUI_download_aborted:
fs_download_aborted (event->data.DownloadAborted.dc.cctx);
break;
case GNUNET_FSUI_download_error:
fs_download_aborted (event->data.DownloadError.dc.cctx);
break;
case GNUNET_FSUI_download_suspended:
fs_download_stopped (event->data.DownloadSuspended.dc.cctx);
break;
case GNUNET_FSUI_download_progress:
fs_download_update (event->data.DownloadProgress.dc.cctx,
event->data.DownloadProgress.completed,
event->data.DownloadProgress.last_block,
event->data.DownloadProgress.last_size);
break;
case GNUNET_FSUI_download_completed:
fs_download_completed (event->data.DownloadCompleted.dc.cctx);
break;
case GNUNET_FSUI_download_stopped:
fs_download_stopped (event->data.DownloadStopped.dc.cctx);
break;
case GNUNET_FSUI_download_started:
ret = fs_download_started (event->data.DownloadStarted.dc.pos,
event->data.DownloadStarted.dc.pcctx,
event->data.DownloadStarted.dc.sctx,
event->data.DownloadStarted.total,
event->data.DownloadStarted.anonymityLevel,
&event->data.DownloadStarted.fi,
event->data.DownloadStarted.filename,
0, GNUNET_get_time (), GNUNET_FSUI_ACTIVE);
break;
case GNUNET_FSUI_download_resumed:
ret = fs_download_started (event->data.DownloadResumed.dc.pos,
event->data.DownloadResumed.dc.pcctx,
event->data.DownloadResumed.dc.sctx,
event->data.DownloadResumed.total,
event->data.DownloadResumed.anonymityLevel,
&event->data.DownloadResumed.fi,
event->data.DownloadResumed.filename,
event->data.DownloadResumed.completed,
event->data.DownloadResumed.eta,
event->data.DownloadResumed.state);
break;
/* upload events */
case GNUNET_FSUI_upload_progress:
fs_upload_update (event->data.UploadProgress.uc.cctx,
event->data.UploadProgress.completed,
event->data.UploadProgress.total);
break;
case GNUNET_FSUI_upload_completed:
fs_upload_complete (event->data.UploadCompleted.uc.cctx,
event->data.UploadCompleted.uri);
break;
case GNUNET_FSUI_upload_error:
fs_upload_error (event->data.UploadError.uc.cctx);
break;
case GNUNET_FSUI_upload_aborted:
fs_upload_error (event->data.UploadAborted.uc.cctx);
break;
case GNUNET_FSUI_upload_stopped:
fs_upload_stopped (event->data.UploadStopped.uc.cctx);
break;
case GNUNET_FSUI_upload_suspended:
fs_upload_stopped (event->data.UploadSuspended.uc.cctx);
break;
case GNUNET_FSUI_upload_started:
ret = fs_upload_started (event->data.UploadStarted.uc.pos,
event->data.UploadStarted.uc.pcctx,
event->data.UploadStarted.filename,
NULL,
event->data.UploadStarted.total,
0, GNUNET_FSUI_ACTIVE);
break;
case GNUNET_FSUI_upload_resumed:
ret = fs_upload_started (event->data.UploadResumed.uc.pos,
event->data.UploadResumed.uc.pcctx,
event->data.UploadResumed.filename,
event->data.UploadResumed.uri,
event->data.UploadResumed.total,
event->data.UploadResumed.completed,
event->data.UploadResumed.state);
break;
/* TODO: unindex events */
default:
GNUNET_GE_BREAK (ectx, 0);
GNUNET_GE_LOG (ectx,
GNUNET_GE_ERROR,
_("Unhandled (unknown) FSUI event: %u.\n"), event->type);
break;
}
return ret;
}
static void *
eventProcessor (void *unused, const GNUNET_FSUI_Event * event)
{
return GNUNET_GTK_save_call (&saveEventProcessor, (void *) event);
}
/**
* The selection of the upload summary changed.
* Update button status.
*/
static void
on_upload_summary_selection_changed (gpointer signal, gpointer cls)
{
GtkTreeSelection *selection;
GtkWidget *button;
selection =
gtk_tree_view_get_selection (GTK_TREE_VIEW
(glade_xml_get_widget
(GNUNET_GTK_get_main_glade_XML (),
"activeUploadsList")));
button =
glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
"cancelUploadButton");
gtk_widget_set_sensitive (button,
gtk_tree_selection_count_selected_rows (selection)
> 0);
button =
glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
"stopUploadButton");
gtk_widget_set_sensitive (button,
gtk_tree_selection_count_selected_rows (selection)
> 0);
}
/**
* The selection of the download summary changed.
* Update button status.
*/
static void
on_download_summary_selection_changed (gpointer signal, gpointer cls)
{
GtkTreeSelection *selection;
GtkWidget *button;
selection =
gtk_tree_view_get_selection (GTK_TREE_VIEW
(glade_xml_get_widget
(GNUNET_GTK_get_main_glade_XML (),
"activeDownloadsList")));
button =
glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
"abortDownloadButton");
gtk_widget_set_sensitive (button,
gtk_tree_selection_count_selected_rows (selection)
> 0);
button =
glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
"stopDownloadButton");
gtk_widget_set_sensitive (button,
gtk_tree_selection_count_selected_rows (selection)
> 0);
}
/**
* The selection of the download summary changed.
* Update button status.
*/
static void
on_search_summary_selection_changed (gpointer signal, gpointer cls)
{
GtkTreeSelection *selection;
GtkWidget *button;
selection =
gtk_tree_view_get_selection (GTK_TREE_VIEW
(glade_xml_get_widget
(GNUNET_GTK_get_main_glade_XML (),
"activeSearchesSummary")));
button =
glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
"cancelSearchButton");
gtk_widget_set_sensitive (button,
gtk_tree_selection_count_selected_rows (selection)
> 0);
button =
glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
"stopSearchButton");
gtk_widget_set_sensitive (button,
gtk_tree_selection_count_selected_rows (selection)
> 0);
}
static int
on_upload_copy_uri_activate (void *cls, GtkWidget * searchEntry)
{
GtkTreeView *uploadList = cls;
GtkTreePath *path;
GtkTreeIter iter;
struct GNUNET_ECRS_URI *uri;
char *str;
GtkClipboard *clip;
path = NULL;
if (FALSE == gtk_tree_view_get_path_at_pos (uploadList,
last_x,
last_y,
&path, NULL, NULL, NULL))
{
GNUNET_GE_BREAK (NULL, 0);
return FALSE;
}
if (FALSE == gtk_tree_model_get_iter (GTK_TREE_MODEL (upload_summary),
&iter, path))
{
GNUNET_GE_BREAK (NULL, 0);
gtk_tree_path_free (path);
return FALSE;
}
gtk_tree_path_free (path);
uri = NULL;
gtk_tree_model_get (GTK_TREE_MODEL (upload_summary),
&iter, UPLOAD_URISTRING, &str, -1);
clip = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clip, str, strlen (str));
GNUNET_free (str);
return FALSE;
}
static gint
upload_click_handler (void *cls, GdkEvent * event)
{
GtkTreeView *uploadList = cls;
GtkMenu *menu;
GtkWidget *entry;
GdkEventButton *event_button;
g_return_val_if_fail (event != NULL, FALSE);
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
event_button = (GdkEventButton *) event;
if (event_button->button != 3)
return FALSE;
last_x = event_button->x;
last_y = event_button->y;
entry = gtk_menu_item_new_with_label (_("_Copy URI to Clipboard"));
g_signal_connect_swapped (entry,
"activate",
G_CALLBACK (on_upload_copy_uri_activate),
uploadList);
gtk_label_set_use_underline (GTK_LABEL
(gtk_bin_get_child (GTK_BIN (entry))), TRUE);
gtk_widget_show (entry);
menu = GTK_MENU (gtk_menu_new ());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), entry);
gtk_menu_popup (menu,
NULL,
NULL, NULL, NULL, event_button->button, event_button->time);
return TRUE;
}
/**
* Setup the summary views (in particular the models
* and the renderers).
*/
static void
fs_summary_start ()
{
GtkComboBoxEntry *searchCB;
GtkWidget *uploadEntry;
GtkTreeView *searchList;
GtkTreeView *downloadList;
GtkTreeView *uploadList;
GtkListStore *model;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
int col;
/* keyword list setup */
searchCB
=
GTK_COMBO_BOX_ENTRY (glade_xml_get_widget
(GNUNET_GTK_get_main_glade_XML (),
"fssearchKeywordComboBoxEntry"));
model = gtk_list_store_new (1, G_TYPE_STRING /* search string */ );
gtk_combo_box_set_model (GTK_COMBO_BOX (searchCB), GTK_TREE_MODEL (model));
gtk_combo_box_entry_set_text_column (searchCB, 0);
/* search namespace selection setup */
searchCB
=
GTK_COMBO_BOX_ENTRY (glade_xml_get_widget
(GNUNET_GTK_get_main_glade_XML (),
"searchNamespaceComboBoxEntry"));
model = gtk_list_store_new (NS_SEARCH_NUM, G_TYPE_STRING, /* what we show */
G_TYPE_STRING, /* GNUNET_EncName of namespace */
G_TYPE_POINTER, /* ECRS MetaData */
G_TYPE_INT); /* Meta-data about namespace */
gtk_combo_box_set_model (GTK_COMBO_BOX (searchCB), GTK_TREE_MODEL (model));
gtk_combo_box_entry_set_text_column (searchCB, NS_SEARCH_DESCRIPTION);
/* search summary setup */
searchList =
GTK_TREE_VIEW (glade_xml_get_widget
(GNUNET_GTK_get_main_glade_XML (),
"activeSearchesSummary"));
search_summary = gtk_list_store_new (SEARCH_SUMMARY_NUM, G_TYPE_STRING, /* name */
G_TYPE_INT, /* # results */
G_TYPE_POINTER); /* internal: search list */
gtk_tree_view_set_model (searchList, GTK_TREE_MODEL (search_summary));
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (searchList),
GTK_SELECTION_MULTIPLE);
g_signal_connect_data (gtk_tree_view_get_selection (searchList),
"changed",
G_CALLBACK (&on_search_summary_selection_changed),
NULL, NULL, 0);
renderer = gtk_cell_renderer_text_new ();
col = gtk_tree_view_insert_column_with_attributes (searchList,
-1,
_("Query"),
renderer,
"text",
SEARCH_SUMMARY_NAME,
NULL);
column = gtk_tree_view_get_column (searchList, col - 1);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_clickable (column, TRUE);
gtk_tree_view_column_set_reorderable (column, TRUE);
gtk_tree_view_column_set_sort_column_id (column, SEARCH_SUMMARY_NAME);
gtk_tree_view_column_set_resizable (column, TRUE);
renderer = gtk_cell_renderer_text_new ();
col = gtk_tree_view_insert_column_with_attributes (searchList,
-1,
_("Results"),
renderer,
"text",
SEARCH_SUMMARY_RESULT_COUNT,
NULL);
column = gtk_tree_view_get_column (searchList, col - 1);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_clickable (column, TRUE);
gtk_tree_view_column_set_reorderable (column, TRUE);
gtk_tree_view_column_set_sort_column_id (column,
SEARCH_SUMMARY_RESULT_COUNT);
gtk_tree_view_column_set_resizable (column, TRUE);
/* download summary setup */
downloadList =
GTK_TREE_VIEW (glade_xml_get_widget
(GNUNET_GTK_get_main_glade_XML (), "activeDownloadsList"));
download_summary = gtk_tree_store_new (DOWNLOAD_NUM, G_TYPE_STRING, /* name (full-path file name) */
G_TYPE_STRING, /* name (user-friendly name) */
G_TYPE_UINT64, /* size */
G_TYPE_STRING, /* human readable size */
G_TYPE_INT, /* progress */
G_TYPE_STRING, /* uri as string */
G_TYPE_POINTER); /* internal download list ptr */
gtk_tree_view_set_model (downloadList, GTK_TREE_MODEL (download_summary));
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (downloadList),
GTK_SELECTION_MULTIPLE);
g_signal_connect_data (gtk_tree_view_get_selection (downloadList),
"changed",
G_CALLBACK (&on_download_summary_selection_changed),
NULL, NULL, 0);
renderer = gtk_cell_renderer_text_new ();
g_object_set (renderer, "xalign", 1.00, NULL);
col = gtk_tree_view_insert_column_with_attributes (downloadList,
-1,
_("Size"),
renderer,
"text", DOWNLOAD_HSIZE,
NULL);
column = gtk_tree_view_get_column (downloadList, col - 1);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_clickable (column, TRUE);
gtk_tree_view_column_set_reorderable (column, TRUE);
gtk_tree_view_column_set_sort_column_id (column, DOWNLOAD_SIZE);
gtk_tree_view_column_set_resizable (column, TRUE);
renderer = gtk_cell_renderer_progress_new ();
col = gtk_tree_view_insert_column_with_attributes (downloadList,
-1,
_("Name"),
renderer,
"value",
DOWNLOAD_PROGRESS,
"text",
DOWNLOAD_SHORTNAME,
NULL);
g_object_set (G_OBJECT (renderer), "width", 400, NULL);
column = gtk_tree_view_get_column (downloadList, col - 1);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_clickable (column, TRUE);
gtk_tree_view_column_set_reorderable (column, TRUE);
gtk_tree_view_column_set_sort_column_id (column, DOWNLOAD_PROGRESS);
gtk_tree_view_column_set_resizable (column, TRUE);
renderer = gtk_cell_renderer_text_new ();
col = gtk_tree_view_insert_column_with_attributes (downloadList,
-1,
_("URI"),
renderer,
"text",
DOWNLOAD_URISTRING,
NULL);
g_object_set (G_OBJECT (renderer), "wrap-width", 30, "width-chars", 30,
"ellipsize", PANGO_ELLIPSIZE_END, NULL);
column = gtk_tree_view_get_column (downloadList, col - 1);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_reorderable (column, TRUE);
gtk_tree_view_column_set_resizable (column, TRUE);
/* upload summary setup */
uploadList =
GTK_TREE_VIEW (glade_xml_get_widget
(GNUNET_GTK_get_main_glade_XML (), "activeUploadsList"));
g_signal_connect_swapped (uploadList, "button-press-event",
G_CALLBACK (upload_click_handler), uploadList);
upload_summary = gtk_tree_store_new (UPLOAD_NUM, G_TYPE_STRING, /* filename */
G_TYPE_INT, /* progress */
G_TYPE_STRING, /* URI as string */
G_TYPE_POINTER); /* UploadList */
gtk_tree_view_set_model (uploadList, GTK_TREE_MODEL (upload_summary));
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (uploadList),
GTK_SELECTION_MULTIPLE);
g_signal_connect_data (gtk_tree_view_get_selection (uploadList),
"changed",
G_CALLBACK (&on_upload_summary_selection_changed),
NULL, NULL, 0);
renderer = gtk_cell_renderer_progress_new ();
col = gtk_tree_view_insert_column_with_attributes (uploadList,
-1,
_("Filename"),
renderer,
"text", UPLOAD_FILENAME,
"value", UPLOAD_PROGRESS,
NULL);
gtk_tree_view_column_set_resizable (gtk_tree_view_get_column (uploadList,
col - 1),
TRUE);
renderer = gtk_cell_renderer_text_new ();
col = gtk_tree_view_insert_column_with_attributes (uploadList,
-1,
_("URI"),
renderer,
"text", UPLOAD_URISTRING,
NULL);
gtk_tree_view_column_set_resizable (gtk_tree_view_get_column (uploadList,
col - 1),
TRUE);
/* upload entry setup */
uploadEntry
=
glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
"uploadFilenameComboBoxEntry");
model = gtk_list_store_new (1, G_TYPE_STRING);
gtk_combo_box_set_model (GTK_COMBO_BOX (uploadEntry),
GTK_TREE_MODEL (model));
gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (uploadEntry), 0);
}
/**
* Shutdown the summary dialogs.
*/
static void
fs_summary_stop ()
{
struct GNUNET_ECRS_MetaData *meta;
GtkComboBox *searchCB;
GtkTreeModel *model;
GtkTreeIter iter;
searchCB
= GTK_COMBO_BOX (glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
"searchNamespaceComboBoxEntry"));
model = gtk_combo_box_get_model (searchCB);
if (gtk_tree_model_get_iter_first (model, &iter))
{
do
{
gtk_tree_model_get (model, &iter, NS_SEARCH_METADATA, &meta, -1);
gtk_list_store_set (GTK_LIST_STORE (model),
&iter, NS_SEARCH_METADATA, NULL, -1);
if (meta != NULL)
GNUNET_ECRS_meta_data_destroy (meta);
}
while (gtk_list_store_remove (GTK_LIST_STORE (model), &iter));
}
}
void
init_fs (struct GNUNET_GE_Context *e, struct GNUNET_GC_Configuration *c)
{
GtkWidget *tab;
GtkWidget *book;
gint num;
ectx = e;
cfg = c;
GNUNET_CO_init (ectx, cfg);
tab = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "fsnotebook");
gtk_widget_show (tab);
book =
glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "mainnotebook");
num = gtk_notebook_get_current_page (GTK_NOTEBOOK (book));
gtk_notebook_set_current_page (GTK_NOTEBOOK (book), 1);
gtk_notebook_set_current_page (GTK_NOTEBOOK (book), num);
fs_summary_start ();
fs_collection_start ();
fs_namespace_start ();
ctx = GNUNET_FSUI_start (ectx, cfg, "gnunet-gtk", 8, /* FIXME: allow user to configure download parallelism */
GNUNET_YES, &eventProcessor, NULL);
}
static void *
hide_save_call (void *arg)
{
GtkWidget *tab;
tab = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "fsnotebook");
gtk_widget_hide (tab);
return NULL;
}
static void *
cleanup_save_call (void *arg)
{
fs_summary_stop ();
fs_namespace_stop ();
return NULL;
}
void
done_fs ()
{
GNUNET_GTK_save_call (&hide_save_call, NULL);
GNUNET_FSUI_stop (ctx);
GNUNET_GTK_save_call (&cleanup_save_call, NULL);
GNUNET_CO_done ();
}
const char *
getColorCode (enum GNUNET_URITRACK_STATE state)
{
if (state & (GNUNET_URITRACK_DIRECTORY_ADDED))
return "blue";
if (state & (GNUNET_URITRACK_INSERTED || GNUNET_URITRACK_INDEXED))
return "cyan";
if ((state & GNUNET_URITRACK_DOWNLOAD_STARTED) &&
(0 == (state &
(GNUNET_URITRACK_DOWNLOAD_COMPLETED |
GNUNET_URITRACK_DOWNLOAD_ABORTED))))
return "yellow";
if (state & GNUNET_URITRACK_DOWNLOAD_COMPLETED)
return "springgreen";
if (state & GNUNET_URITRACK_DOWNLOAD_ABORTED)
return "red";
if (state &
(GNUNET_URITRACK_SEARCH_RESULT | GNUNET_URITRACK_DIRECTORY_FOUND))
return "gray";
return "white";
}
/* end of fs.c */
|