aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fs/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/fs/namespace.c')
-rw-r--r--src/plugins/fs/namespace.c600
1 files changed, 109 insertions, 491 deletions
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index c81cbaa6..4baff68d 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2005, 2006 Christian Grothoff (and other contributing authors) 3 (C) 2005, 2006, 2007 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
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file src/plugins/fs/namespace.c 22 * @file src/plugins/fs/namespace.c
23 * @brief code for operations with namespaces 23 * @brief operations creating/deleting and adding to/updating namespaces
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
@@ -30,31 +30,34 @@
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 "content_tracking.h"
33#include <GNUnet/gnunet_util_crypto.h> 34#include <GNUnet/gnunet_util_crypto.h>
34#include <GNUnet/gnunet_uritrack_lib.h> 35#include <GNUnet/gnunet_uritrack_lib.h>
35#include <GNUnet/gnunet_namespace_lib.h> 36#include <GNUnet/gnunet_namespace_lib.h>
36#include <extractor.h> 37#include <extractor.h>
37 38
38/** 39/**
39 * @brief linked list of pages in the search notebook 40 * @brief linked list of pages in the namespace notebook
40 */ 41 */
41typedef struct NL { 42typedef struct NL {
42 struct NL * next; 43 struct NL * next;
43 GtkWidget * treeview; 44 GtkWidget * treeview;
44 GtkWidget * namespacepage; 45 GtkWidget * namespacepage;
46 GtkWidget * addButton;
45 GtkTreeModel * model; 47 GtkTreeModel * model;
46 GtkWidget * anonymityButton;
47 char * name; 48 char * name;
48 HashCode512 id; 49 HashCode512 id;
49 struct ECRS_MetaData * meta; 50 struct ECRS_MetaData * meta;
50} NamespaceList; 51} NamespaceList;
51 52
53static GtkTreeSelection * content_selection;
54
52static NamespaceList * head; 55static NamespaceList * head;
53 56
54static GladeXML * metaXML; 57static GladeXML * metaXML;
55 58
56static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview, 59static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview,
57 GtkWidget ** anonSpin) { 60 GtkWidget ** addButton) {
58 GtkWidget * child; 61 GtkWidget * child;
59 GtkWidget * resultList; 62 GtkWidget * resultList;
60 GtkCellRenderer * renderer; 63 GtkCellRenderer * renderer;
@@ -73,8 +76,8 @@ static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview,
73 "namespaceContentFrame"); 76 "namespaceContentFrame");
74 resultList = glade_xml_get_widget(namespaceXML, 77 resultList = glade_xml_get_widget(namespaceXML,
75 "namespaceContentFrameTreeView"); 78 "namespaceContentFrameTreeView");
76 *anonSpin = glade_xml_get_widget(namespaceXML, 79 *addButton = glade_xml_get_widget(namespaceXML,
77 "namespaceAnonymitySpinButton"); 80 "addButton");
78 if (treeview != NULL) 81 if (treeview != NULL)
79 (*treeview) = GTK_WIDGET(GTK_TREE_VIEW(resultList)); 82 (*treeview) = GTK_WIDGET(GTK_TREE_VIEW(resultList));
80 model = 83 model =
@@ -94,6 +97,9 @@ static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview,
94 GTK_TREE_MODEL(model)); 97 GTK_TREE_MODEL(model));
95 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(resultList)), 98 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(resultList)),
96 GTK_SELECTION_MULTIPLE); 99 GTK_SELECTION_MULTIPLE);
100
101
102
97 renderer = gtk_cell_renderer_text_new(); 103 renderer = gtk_cell_renderer_text_new();
98 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), 104 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
99 -1, 105 -1,
@@ -234,113 +240,7 @@ static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview,
234 return child; 240 return child;
235} 241}
236 242
237/**
238 * Add the given content to the globally available
239 * content model. Check that it is not already
240 * present!
241 */
242static void * updateView(void * cls) {
243 const ECRS_FileInfo * fi = cls;
244 GtkTreeIter iter;
245 char * filename;
246 char * uriString;
247 unsigned long long size;
248 char * size_h;
249 GtkWidget * contentList;
250 GtkTreeModel * model;
251
252 contentList
253 = glade_xml_get_widget(getMainXML(),
254 "availableContentList");
255 model
256 = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList));
257 filename = ECRS_getFirstFromMetaData(fi->meta,
258 EXTRACTOR_FILENAME,
259 EXTRACTOR_TITLE,
260 EXTRACTOR_DESCRIPTION,
261 EXTRACTOR_SUBJECT,
262 EXTRACTOR_ARTIST,
263 EXTRACTOR_AUTHOR,
264 EXTRACTOR_PUBLISHER,
265 EXTRACTOR_CREATOR,
266 EXTRACTOR_PRODUCER,
267 EXTRACTOR_UNKNOWN,
268 -1);
269 if (filename == NULL) {
270 filename = STRDUP(_("no name given"));
271 } else {
272 char * dotdot;
273 243
274 while (NULL != (dotdot = strstr(filename, "..")))
275 dotdot[0] = dotdot[1] = '_';
276 filename = validate_utf8(filename);
277 }
278
279 if (ECRS_isFileUri(fi->uri))
280 size = ECRS_fileSize(fi->uri);
281 else
282 size = 0;
283 uriString = ECRS_uriToString(fi->uri);
284 gtk_list_store_append(GTK_LIST_STORE(model),
285 &iter);
286 size_h = string_get_fancy_byte_size(size);
287 gtk_list_store_set(GTK_LIST_STORE(model),
288 &iter,
289 NAMESPACE_FILENAME, filename,
290 NAMESPACE_SIZE, size,
291 NAMESPACE_HSIZE, size_h,
292 NAMESPACE_URISTRING, uriString,
293 NAMESPACE_URI, ECRS_dupUri(fi->uri),
294 NAMESPACE_META, ECRS_dupMetaData(fi->meta),
295 -1);
296 FREE(size_h);
297 FREE(filename);
298 FREE(uriString);
299 return NULL;
300}
301
302/**
303 * Add the given content to the globally available
304 * content model. Check that it is not already
305 * present!
306 */
307static int updateViewSave(const ECRS_FileInfo * fi,
308 const HashCode512 * key,
309 int isRoot,
310 void * closure) {
311 gtkSaveCall(&updateView, (void*) fi);
312 return OK;
313}
314
315
316static void * clearContentList(void * mdl) {
317 GtkTreeModel * model = GTK_TREE_MODEL(mdl);
318 struct ECRS_URI * uri;
319 struct ECRS_MetaData * meta;
320 GtkTreeIter iter;
321
322 DEBUG_BEGIN();
323 if (gtk_tree_model_get_iter_first(model,
324 &iter)) {
325 do {
326 gtk_tree_model_get(model,
327 &iter,
328 NAMESPACE_URI, &uri,
329 NAMESPACE_META, &meta,
330 -1);
331 ECRS_freeUri(uri);
332 ECRS_freeMetaData(meta);
333 gtk_list_store_set(GTK_LIST_STORE(model),
334 &iter,
335 NAMESPACE_URI, NULL,
336 NAMESPACE_META, NULL,
337 -1);
338 } while (gtk_list_store_remove(GTK_LIST_STORE(model),
339 &iter));
340 }
341 DEBUG_END();
342 return NULL;
343}
344 244
345/** 245/**
346 * Update the model that lists the content of a namespace: 246 * Update the model that lists the content of a namespace:
@@ -454,6 +354,22 @@ static int addNamespaceContentToModel(void * cls,
454} 354}
455 355
456/** 356/**
357 * The user has edited the search entry.
358 * Update search button status.
359 */
360static void on_namespaceContentSelectionChanged(gpointer signal,
361 gpointer cls) {
362 NamespaceList * list = head;
363
364 while (list != NULL) {
365 gtk_widget_set_sensitive(list->addButton,
366 gtk_tree_selection_count_selected_rows(content_selection) > 0);
367 list = list->next;
368 }
369}
370
371
372/**
457 * Add a tab for the given namespace. 373 * Add a tab for the given namespace.
458 */ 374 */
459static int addTabForNamespace(void * unused, 375static int addTabForNamespace(void * unused,
@@ -463,7 +379,7 @@ static int addTabForNamespace(void * unused,
463 int rating) { 379 int rating) {
464 NamespaceList * list; 380 NamespaceList * list;
465 GtkWidget * label; 381 GtkWidget * label;
466 GtkWidget * spin; 382 GtkWidget * addButton;
467 GtkWidget * notebook; 383 GtkWidget * notebook;
468 GtkListStore * model; 384 GtkListStore * model;
469 385
@@ -475,9 +391,9 @@ static int addTabForNamespace(void * unused,
475 list->meta = ECRS_dupMetaData(md); 391 list->meta = ECRS_dupMetaData(md);
476 list->namespacepage 392 list->namespacepage
477 = makeNamespaceFrame(&list->treeview, 393 = makeNamespaceFrame(&list->treeview,
478 &spin); 394 &addButton);
479 list->anonymityButton 395 list->addButton
480 = spin; 396 = addButton;
481 model = GTK_LIST_STORE 397 model = GTK_LIST_STORE
482 (gtk_tree_view_get_model 398 (gtk_tree_view_get_model
483 (GTK_TREE_VIEW(list->treeview))); 399 (GTK_TREE_VIEW(list->treeview)));
@@ -486,6 +402,8 @@ static int addTabForNamespace(void * unused,
486 list->next 402 list->next
487 = head; 403 = head;
488 head = list; 404 head = list;
405 /* update sensitivity of add button */
406 on_namespaceContentSelectionChanged(NULL, NULL);
489 notebook 407 notebook
490 = glade_xml_get_widget(getMainXML(), 408 = glade_xml_get_widget(getMainXML(),
491 "localNamespacesNotebook"); 409 "localNamespacesNotebook");
@@ -673,19 +591,11 @@ void namespaceDelete_clicked_fs(GtkWidget * dummy1,
673 gtk_widget_destroy(dialog); 591 gtk_widget_destroy(dialog);
674 if (GTK_RESPONSE_YES != ret) 592 if (GTK_RESPONSE_YES != ret)
675 return; 593 return;
676
677 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), 594 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook),
678 num); 595 num);
679 if (prev == NULL)
680 head = list->next;
681 else
682 prev->next = list->next;
683 NS_deleteNamespace(ectx, 596 NS_deleteNamespace(ectx,
684 cfg, 597 cfg,
685 list->name); 598 list->name);
686 FREE(list->name);
687 ECRS_freeMetaData(list->meta);
688 FREE(list);
689 DEBUG_END(); 599 DEBUG_END();
690} 600}
691 601
@@ -696,7 +606,6 @@ typedef struct {
696 HashCode512 * lastId; 606 HashCode512 * lastId;
697 HashCode512 thisId; 607 HashCode512 thisId;
698 HashCode512 * nextId; 608 HashCode512 * nextId;
699 struct ECRS_MetaData * meta;
700} IUC; 609} IUC;
701 610
702/** 611/**
@@ -710,24 +619,17 @@ static void initiateUpload(GtkTreeModel * model,
710 IUC * cls = data; 619 IUC * cls = data;
711 struct ECRS_URI * resultURI; 620 struct ECRS_URI * resultURI;
712 struct ECRS_URI * dst; 621 struct ECRS_URI * dst;
713 struct ECRS_MetaData * ometa;
714 struct ECRS_MetaData * meta; 622 struct ECRS_MetaData * meta;
715 NamespaceList * list; 623 NamespaceList * list;
716 ECRS_FileInfo fi; 624 ECRS_FileInfo fi;
717 625
718 DEBUG_BEGIN(); 626 DEBUG_BEGIN();
719 dst = NULL; 627 dst = NULL;
720 meta = cls->meta;
721 gtk_tree_model_get(model, 628 gtk_tree_model_get(model,
722 iter, 629 iter,
723 NAMESPACE_URI, &dst, 630 NAMESPACE_URI, &dst,
724 NAMESPACE_META, &ometa, 631 NAMESPACE_META, &meta,
725 -1); 632 -1);
726 /* FIXME: we may want to optionally combine the metadata from the
727 original file ID (ometa) with the new metadata (cls->meta) here;
728 or if we limit us to one file at a time, show the original
729 metadata immediately with the dialog. */
730
731 if (dst == NULL) { 633 if (dst == NULL) {
732 GE_BREAK(ectx, 0); 634 GE_BREAK(ectx, 0);
733 return; 635 return;
@@ -780,51 +682,23 @@ void on_namespaceInsertMetaDataDialogMetaDataAddButton_clicked_fs(GtkWidget * du
780 "metaDataTreeView"); 682 "metaDataTreeView");
781} 683}
782 684
685/**
686 * User clicked the "add" button, add content from
687 * available content list to the currently selected
688 * namespace.
689 */
783void on_namespaceInsertButton_clicked_fs(GtkWidget * dummy1, 690void on_namespaceInsertButton_clicked_fs(GtkWidget * dummy1,
784 GtkWidget * dummy2) { 691 GtkWidget * dummy2) {
692
785 const char * identifierName; 693 const char * identifierName;
786 NamespaceList * list; 694 NamespaceList * list;
787 GtkWidget * nameLine; 695 GtkWidget * nameLine;
788 GtkWidget * page; 696 GtkWidget * page;
789 GtkWidget * notebook; 697 GtkWidget * notebook;
790 GtkWidget * dialog; 698 GtkWidget * dialog;
791 struct ECRS_MetaData * meta;
792 HashCode512 nextId; 699 HashCode512 nextId;
793 GtkWidget * contentList;
794 GtkTreeSelection * selection;
795 IUC cls; 700 IUC cls;
796 gint num; 701 gint num;
797 GtkTreeIter iter;
798
799 DEBUG_BEGIN();
800 contentList
801 = glade_xml_get_widget(getMainXML(),
802 "availableContentList");
803 selection
804 = gtk_tree_view_get_selection(GTK_TREE_VIEW(contentList));
805 if (0 == gtk_tree_selection_count_selected_rows(selection)) {
806 /* IMPROVE-ME: disable the menu item
807 as long as this may happen! */
808 dialog = gtk_message_dialog_new
809 (NULL,
810 GTK_DIALOG_MODAL,
811 GTK_MESSAGE_ERROR,
812 GTK_BUTTONS_CLOSE,
813 _("You must select some available content for publication first!"));
814 gtk_dialog_run(GTK_DIALOG(dialog));
815 gtk_widget_destroy(dialog);
816 return;
817 }
818 if (FALSE == gtk_tree_selection_get_selected(selection,
819 NULL,
820 &iter)) {
821 GE_BREAK(ectx, 0);
822 return;
823 }
824 gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)),
825 &iter,
826 NAMESPACE_META, &meta,
827 -1);
828 702
829 notebook 703 notebook
830 = glade_xml_get_widget(getMainXML(), 704 = glade_xml_get_widget(getMainXML(),
@@ -848,12 +722,6 @@ void on_namespaceInsertButton_clicked_fs(GtkWidget * dummy1,
848 "namespaceInsertDialog", 722 "namespaceInsertDialog",
849 PACKAGE_NAME); 723 PACKAGE_NAME);
850 connectGladeWithPlugins(metaXML); 724 connectGladeWithPlugins(metaXML);
851 createMetaDataListTreeView(metaXML,
852 "metaDataTreeView",
853 "namespaceInsertPreview",
854 meta);
855 createMetaTypeComboBox(metaXML,
856 "namespaceInsertMetaTypeComboBox");
857 dialog = glade_xml_get_widget(metaXML, 725 dialog = glade_xml_get_widget(metaXML,
858 "namespaceInsertDialog"); 726 "namespaceInsertDialog");
859 gtk_dialog_set_default_response(GTK_DIALOG(dialog), 727 gtk_dialog_set_default_response(GTK_DIALOG(dialog),
@@ -875,10 +743,6 @@ void on_namespaceInsertButton_clicked_fs(GtkWidget * dummy1,
875 gtk_widget_destroy(dialog); 743 gtk_widget_destroy(dialog);
876 return; 744 return;
877 } 745 }
878
879 meta = getMetaDataFromList(metaXML,
880 "metaDataTreeView",
881 "namespaceInsertPreview");
882 cls.anonymityLevel 746 cls.anonymityLevel
883 = getSpinButtonValue(metaXML, 747 = getSpinButtonValue(metaXML,
884 "anonymitySpinButton"); 748 "anonymitySpinButton");
@@ -904,27 +768,25 @@ void on_namespaceInsertButton_clicked_fs(GtkWidget * dummy1,
904 &nextId); 768 &nextId);
905 cls.nextId = &nextId; 769 cls.nextId = &nextId;
906 } 770 }
907 cls.meta = meta;
908 ggc_tree_selection_selected_foreach 771 ggc_tree_selection_selected_foreach
909 (selection, 772 (content_selection,
910 &initiateUpload, 773 &initiateUpload,
911 &cls); 774 &cls);
912
913 ECRS_freeMetaData(meta);
914 } 775 }
915 gtk_widget_destroy(dialog); 776 gtk_widget_destroy(dialog);
916 UNREF(metaXML); 777 UNREF(metaXML);
917 metaXML = NULL; 778 metaXML = NULL;
918 DEBUG_END();
919} 779}
920 780
781
782/**
783 * FIXME!!!
784 */
921void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1, 785void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
922 GtkWidget * dummy2) { 786 GtkWidget * dummy2) {
923 const char * identifierName; 787 const char * identifierName;
924 NamespaceList * list; 788 NamespaceList * list;
925 GtkWidget * nameLine; 789 GtkWidget * nameLine;
926 GtkWidget * page;
927 GtkWidget * notebook;
928 GtkWidget * dialog; 790 GtkWidget * dialog;
929 GtkWidget * spin; 791 GtkWidget * spin;
930 GtkWidget * update; 792 GtkWidget * update;
@@ -932,84 +794,14 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
932 struct ECRS_MetaData * meta; 794 struct ECRS_MetaData * meta;
933 HashCode512 nextId; 795 HashCode512 nextId;
934 HashCode512 prevId; 796 HashCode512 prevId;
935 GtkWidget * contentList;
936 GtkTreeSelection * selection; 797 GtkTreeSelection * selection;
937 GtkTreeSelection * selectionNamespace;
938 IUC cls; 798 IUC cls;
939 gint num;
940 char * last; 799 char * last;
941 char * next; 800 char * next;
942 char * freq; 801 char * freq;
943 802
944 DEBUG_BEGIN(); 803 DEBUG_BEGIN();
945 contentList
946 = glade_xml_get_widget(getMainXML(),
947 "availableContentList");
948 selection
949 = gtk_tree_view_get_selection(GTK_TREE_VIEW(contentList));
950 if (0 == gtk_tree_selection_count_selected_rows(selection)) {
951 /* IMPROVE-ME: disable the menu item
952 as long as this may happen! */
953 dialog = gtk_message_dialog_new
954 (NULL,
955 GTK_DIALOG_MODAL,
956 GTK_MESSAGE_ERROR,
957 GTK_BUTTONS_CLOSE,
958 _("You must select some available content for publication first!"));
959 gtk_dialog_run(GTK_DIALOG(dialog));
960 gtk_widget_destroy(dialog);
961 return;
962 }
963 if (FALSE == gtk_tree_selection_get_selected(selection,
964 NULL,
965 &iter)) {
966 GE_BREAK(ectx, 0);
967 return;
968 }
969 gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(contentList)),
970 &iter,
971 NAMESPACE_META, &meta,
972 -1);
973
974 notebook
975 = glade_xml_get_widget(getMainXML(),
976 "localNamespacesNotebook");
977 num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
978 GE_ASSERT(ectx, num != -1);
979 page =gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
980 num);
981 list = head;
982 while ( (list != NULL) &&
983 (list->namespacepage != page) )
984 list = list->next;
985 if (list == NULL) {
986 GE_BREAK(ectx, 0);
987 return;
988 }
989 cls.namespaceName = list->name;
990 804
991 /* check that in namespace (updateable) content is selected! */
992 selectionNamespace
993 = gtk_tree_view_get_selection(GTK_TREE_VIEW(list->treeview));
994 if (0 == gtk_tree_selection_count_selected_rows(selectionNamespace)) {
995 /* IMPROVE-ME: disable the menu item
996 as long as this may happen! */
997 dialog = gtk_message_dialog_new
998 (NULL,
999 GTK_DIALOG_MODAL,
1000 GTK_MESSAGE_ERROR,
1001 GTK_BUTTONS_CLOSE,
1002 _("You must select some existing namespace content to be updated first!"));
1003 gtk_dialog_run(GTK_DIALOG(dialog));
1004 gtk_widget_destroy(dialog);
1005 return;
1006 }
1007 if (FALSE == gtk_tree_selection_get_selected(selectionNamespace,
1008 NULL,
1009 &iter)) {
1010 GE_BREAK(ectx, 0);
1011 return;
1012 }
1013 gtk_tree_model_get(list->model, 805 gtk_tree_model_get(list->model,
1014 &iter, 806 &iter,
1015 IN_NAMESPACE_LAST_STRING, &last, 807 IN_NAMESPACE_LAST_STRING, &last,
@@ -1022,6 +814,8 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1022 PACKAGE_NAME); 814 PACKAGE_NAME);
1023 connectGladeWithPlugins(metaXML); 815 connectGladeWithPlugins(metaXML);
1024 816
817
818
1025 nameLine = glade_xml_get_widget(metaXML, 819 nameLine = glade_xml_get_widget(metaXML,
1026 "identifierLabel"); 820 "identifierLabel");
1027 gtk_label_set_text(GTK_LABEL(nameLine), 821 gtk_label_set_text(GTK_LABEL(nameLine),
@@ -1137,9 +931,6 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1137 strlen(identifierName), 931 strlen(identifierName),
1138 &nextId); 932 &nextId);
1139 cls.nextId = &nextId; 933 cls.nextId = &nextId;
1140 cls.meta = getMetaDataFromList(metaXML,
1141 "namespaceUpdateMetaDataTreeView",
1142 "namespaceUpdatePreviewImage");
1143 spin = glade_xml_get_widget(metaXML, 934 spin = glade_xml_get_widget(metaXML,
1144 "namespaceUpdateAnonymitySpinButton"); 935 "namespaceUpdateAnonymitySpinButton");
1145 cls.anonymityLevel 936 cls.anonymityLevel
@@ -1149,7 +940,6 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1149 (selection, 940 (selection,
1150 &initiateUpload, 941 &initiateUpload,
1151 &cls); 942 &cls);
1152 ECRS_freeMetaData(cls.meta);
1153 } 943 }
1154 gtk_widget_destroy(dialog); 944 gtk_widget_destroy(dialog);
1155 UNREF(metaXML); 945 UNREF(metaXML);
@@ -1163,187 +953,6 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1163 DEBUG_END(); 953 DEBUG_END();
1164} 954}
1165 955
1166void on_clearAvailableContentButton_clicked_fs(GtkWidget * dummy1,
1167 GtkWidget * dummy2) {
1168 GtkWidget * contentList;
1169 GtkTreeModel * model;
1170
1171 DEBUG_BEGIN();
1172 contentList
1173 = glade_xml_get_widget(getMainXML(),
1174 "availableContentList");
1175 model
1176 = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList));
1177 URITRACK_clearTrackedURIS(ectx,
1178 cfg);
1179 gtkSaveCall(&clearContentList, model);
1180 DEBUG_END();
1181}
1182
1183void on_trackingCheckButton_toggled_fs(GtkWidget * dummy1,
1184 GtkWidget * dummy2) {
1185 GtkWidget * trackCheckButton;
1186
1187 trackCheckButton
1188 = glade_xml_get_widget(getMainXML(),
1189 "trackingCheckButton");
1190 URITRACK_trackURIS(ectx,
1191 cfg,
1192 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trackCheckButton)) == TRUE ?
1193 YES : NO);
1194}
1195
1196/**
1197 * The spin button giving the rating for a particular namespace
1198 * has been changed. Store the new rating for the namespace.
1199 */
1200void on_namespaceRatingSpinButton_changed_fs(GtkWidget * dummy,
1201 GtkWidget * dummy2) {
1202 GtkWidget * spin;
1203 GtkWidget * ncbe;
1204 GtkTreeModel * model;
1205 GtkTreeIter iter;
1206 char * encStr;
1207 char * description;
1208 int rating;
1209 int newrating;
1210
1211 DEBUG_BEGIN();
1212 spin
1213 = glade_xml_get_widget(getMainXML(),
1214 "namespaceRatingSpinButton");
1215 ncbe
1216 = glade_xml_get_widget(getMainXML(),
1217 "searchNamespaceComboBoxEntry");
1218 model = gtk_combo_box_get_model(GTK_COMBO_BOX(ncbe));
1219 description = NULL;
1220 encStr = NULL;
1221 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(ncbe),
1222 &iter)) {
1223 gtk_tree_model_get(model,
1224 &iter,
1225 NS_SEARCH_DESCRIPTION, &description,
1226 NS_SEARCH_ENCNAME, &encStr,
1227 NS_SEARCH_RATING, &rating,
1228 -1);
1229 if ( (description != NULL) &&
1230 (0 == strcmp(description,
1231 _("globally"))) ) {
1232 /* just to be sure */
1233 gtk_widget_set_sensitive(spin,
1234 FALSE);
1235 } else {
1236 if (encStr != NULL) {
1237 newrating = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
1238 rating = NS_rankNamespace(ectx,
1239 cfg,
1240 encStr,
1241 newrating - rating);
1242 if (rating != newrating) {
1243 /* concurrent modification? */
1244 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1245 rating);
1246 GE_BREAK(ectx, 0);
1247 }
1248 gtk_list_store_set(GTK_LIST_STORE(model),
1249 &iter,
1250 NS_SEARCH_RATING, rating,
1251 -1);
1252 }
1253 }
1254 } else {
1255 /* FIXME: if enc2hash succeeds, we may want to keep this
1256 active */
1257 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1258 0);
1259 gtk_widget_set_sensitive(spin,
1260 FALSE);
1261 }
1262 if (description != NULL)
1263 free(description);
1264 if (encStr != NULL)
1265 free(encStr);
1266 DEBUG_END();
1267}
1268
1269
1270/**
1271 * The namespace in the search window has changed.
1272 * Update the trust level (possibly changing sensitivity)
1273 * and set the search string to the root (if available).
1274 */
1275void on_searchNamespaceComboBoxEntry_changed_fs(GtkWidget * dummy,
1276 GtkWidget * dummy2) {
1277 GtkWidget * keyword;
1278 GtkWidget * spin;
1279 GtkWidget * ncbe;
1280 GtkTreeModel * model;
1281 GtkTreeIter iter;
1282 int rating;
1283 char * encStr;
1284 char * descStr;
1285 HashCode512 ns;
1286 HashCode512 root;
1287 EncName enc;
1288
1289 DEBUG_BEGIN();
1290 spin
1291 = glade_xml_get_widget(getMainXML(),
1292 "namespaceRatingSpinButton");
1293 ncbe
1294 = glade_xml_get_widget(getMainXML(),
1295 "searchNamespaceComboBoxEntry");
1296 model = gtk_combo_box_get_model(GTK_COMBO_BOX(ncbe));
1297 descStr = NULL;
1298 encStr = NULL;
1299 if (TRUE == gtk_combo_box_get_active_iter(GTK_COMBO_BOX(ncbe),
1300 &iter)) {
1301 gtk_tree_model_get(model,
1302 &iter,
1303 NS_SEARCH_DESCRIPTION, &descStr,
1304 NS_SEARCH_ENCNAME, &encStr,
1305 NS_SEARCH_RATING, &rating,
1306 -1);
1307 if ( (descStr != NULL) &&
1308 (0 == strcmp(descStr,
1309 _("globally"))) ) {
1310 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1311 0);
1312 gtk_widget_set_sensitive(spin,
1313 FALSE);
1314 } else if (encStr != NULL) {
1315 enc2hash(encStr,
1316 &ns);
1317 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1318 rating);
1319 gtk_widget_set_sensitive(spin,
1320 TRUE);
1321 if (OK == NS_getNamespaceRoot(ectx,
1322 cfg,
1323 encStr,
1324 &root)) {
1325 hash2enc(&root,
1326 &enc);
1327 keyword
1328 = glade_xml_get_widget(getMainXML(),
1329 "fssearchKeywordComboBoxEntry");
1330 gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(keyword))),
1331 (const gchar*) &enc);
1332 }
1333 }
1334 } else {
1335 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
1336 0);
1337 gtk_widget_set_sensitive(spin,
1338 FALSE);
1339 }
1340 if (descStr != NULL)
1341 free(descStr);
1342 if (encStr != NULL)
1343 free(encStr);
1344 DEBUG_END();
1345}
1346
1347 956
1348 957
1349void fs_namespace_start() { 958void fs_namespace_start() {
@@ -1375,8 +984,18 @@ void fs_namespace_start() {
1375 G_TYPE_POINTER); /* uri */ 984 G_TYPE_POINTER); /* uri */
1376 gtk_tree_view_set_model(GTK_TREE_VIEW(contentList), 985 gtk_tree_view_set_model(GTK_TREE_VIEW(contentList),
1377 GTK_TREE_MODEL(model)); 986 GTK_TREE_MODEL(model));
1378 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(contentList)), 987 content_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(contentList));
988 gtk_tree_selection_set_mode(content_selection,
1379 GTK_SELECTION_MULTIPLE); 989 GTK_SELECTION_MULTIPLE);
990
991 g_signal_connect_data(content_selection,
992 "changed",
993 G_CALLBACK(&on_namespaceContentSelectionChanged),
994 NULL,
995 NULL,
996 0);
997
998
1380 renderer = gtk_cell_renderer_text_new(); 999 renderer = gtk_cell_renderer_text_new();
1381 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(contentList), 1000 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(contentList),
1382 -1, 1001 -1,
@@ -1398,11 +1017,11 @@ void fs_namespace_start() {
1398 renderer = gtk_cell_renderer_text_new(); 1017 renderer = gtk_cell_renderer_text_new();
1399 g_object_set (renderer, "xalign", 1.00, NULL); 1018 g_object_set (renderer, "xalign", 1.00, NULL);
1400 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(contentList), 1019 col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(contentList),
1401 -1, 1020 -1,
1402 _("Filesize"), 1021 _("Filesize"),
1403 renderer, 1022 renderer,
1404 "text", NAMESPACE_HSIZE, 1023 "text", NAMESPACE_HSIZE,
1405 NULL); 1024 NULL);
1406 column = gtk_tree_view_get_column(GTK_TREE_VIEW(contentList), 1025 column = gtk_tree_view_get_column(GTK_TREE_VIEW(contentList),
1407 col - 1); 1026 col - 1);
1408 gtk_tree_view_column_set_resizable(column, TRUE); 1027 gtk_tree_view_column_set_resizable(column, TRUE);
@@ -1439,57 +1058,56 @@ void fs_namespace_start() {
1439 DEBUG_END(); 1058 DEBUG_END();
1440} 1059}
1441 1060
1442#if 0
1443void on_availableContentList_destroy_fs(GtkWidget * dummy1,
1444 GtkWidget * dummy2) {
1445 GtkWidget * contentList;
1446 GtkTreeModel * model;
1447 1061
1448 contentList 1062void on_localNamespaceContentFrameTreeView_destroy_fs(GtkWidget * tree,
1449 = glade_xml_get_widget(getMainXML(), 1063 GtkWidget * dummy2) {
1450 "availableContentList");
1451 model
1452 = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList));
1453 clearContentList(model);
1454}
1455
1456void on_localNamespacesNotebook_destroy_fs(GtkWidget * dummy1,
1457 GtkWidget * dummy2) {
1458 NamespaceList * pos;
1459 GtkTreeIter iter; 1064 GtkTreeIter iter;
1460 struct ECRS_URI * u; 1065 struct ECRS_URI * u;
1461 struct ECRS_MetaData * m; 1066 struct ECRS_MetaData * m;
1462 1067 NamespaceList * prev;
1463 while (head != NULL) { 1068 NamespaceList * pos;
1464 pos = head->next; 1069 NamespaceList * next;
1465 FREE(head->name); 1070
1466 ECRS_freeMetaData(head->meta); 1071 pos = head;
1467 1072 while (pos != NULL) {
1468 if (gtk_tree_model_get_iter_first(head->model, 1073 next = pos->next;
1469 &iter)) { 1074 if (pos->treeview == tree)
1470 do { 1075 break;
1471 gtk_tree_model_get(head->model, 1076 prev = pos;
1472 &iter, 1077 pos = next;
1473 IN_NAMESPACE_URI, &u, 1078 }
1474 IN_NAMESPACE_META, &m, 1079 if (pos == NULL) {
1475 -1); 1080 GE_BREAK(NULL, 0);
1476 gtk_list_store_set(GTK_LIST_STORE(head->model), 1081 return;
1477 &iter, 1082 }
1478 IN_NAMESPACE_URI, NULL, 1083 if (prev == NULL)
1479 IN_NAMESPACE_META, NULL, 1084 head = pos->next;
1480 -1); 1085 else
1481 if (u != NULL) 1086 prev->next = pos->next;
1482 ECRS_freeUri(u); 1087 FREE(pos->name);
1483 if (m != NULL) 1088 ECRS_freeMetaData(pos->meta);
1484 ECRS_freeMetaData(m); 1089 if (gtk_tree_model_get_iter_first(pos->model,
1485 } while (gtk_tree_model_iter_next(head->model, 1090 &iter)) {
1486 &iter)); 1091 do {
1487 } 1092 gtk_tree_model_get(pos->model,
1488 FREE(head); 1093 &iter,
1489 head = pos; 1094 IN_NAMESPACE_URI, &u,
1095 IN_NAMESPACE_META, &m,
1096 -1);
1097 gtk_list_store_set(GTK_LIST_STORE(pos->model),
1098 &iter,
1099 IN_NAMESPACE_URI, NULL,
1100 IN_NAMESPACE_META, NULL,
1101 -1);
1102 if (u != NULL)
1103 ECRS_freeUri(u);
1104 if (m != NULL)
1105 ECRS_freeMetaData(m);
1106 } while (gtk_tree_model_iter_next(pos->model,
1107 &iter));
1490 } 1108 }
1109 FREE(pos);
1491} 1110}
1492#endif
1493 1111
1494void fs_namespace_stop() { 1112void fs_namespace_stop() {
1495 URITRACK_unregisterTrackCallback(&updateViewSave, 1113 URITRACK_unregisterTrackCallback(&updateViewSave,