aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/fs')
-rw-r--r--src/plugins/fs/Makefile.am1
-rw-r--r--src/plugins/fs/namespace.c228
-rw-r--r--src/plugins/fs/namespace.h10
-rw-r--r--src/plugins/fs/namespace_create.c260
4 files changed, 357 insertions, 142 deletions
diff --git a/src/plugins/fs/Makefile.am b/src/plugins/fs/Makefile.am
index 7e3b4dfe..b29d3115 100644
--- a/src/plugins/fs/Makefile.am
+++ b/src/plugins/fs/Makefile.am
@@ -17,6 +17,7 @@ libgnunetgtkmodule_fs_la_SOURCES = \
17 helper.c helper.h \ 17 helper.c helper.h \
18 meta.c meta.h \ 18 meta.c meta.h \
19 namespace.c namespace.h \ 19 namespace.c namespace.h \
20 namespace_create.c \
20 namespace_search.c \ 21 namespace_search.c \
21 search.c search.h \ 22 search.c search.h \
22 download.c download.h \ 23 download.c download.h \
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index d0cfa1cb..3144f1b4 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file src/plugins/fs/namespace.c 22 * @file src/plugins/fs/namespace.c
23 * @brief operations creating/deleting and adding to/updating namespaces 23 * @brief operations for deleting and adding to/updating namespaces
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
@@ -51,13 +51,61 @@ typedef struct NL {
51 struct ECRS_MetaData * meta; 51 struct ECRS_MetaData * meta;
52} NamespaceList; 52} NamespaceList;
53 53
54/**
55 * Content selection in main list of available content.
56 */
54static GtkTreeSelection * content_selection; 57static GtkTreeSelection * content_selection;
55 58
56static NamespaceList * head; 59static NamespaceList * head;
57 60
58static GladeXML * metaXML; 61static GladeXML * metaXML;
59 62
60void makeNamespaceFrame(NamespaceList * entry) { 63/**
64 * The user has changed the selection either in the
65 * namespace content list or the global content list.
66 * Update search button status values (add/change).
67 */
68static void on_namespaceContentSelectionChanged(gpointer signal,
69 gpointer cls) {
70 NamespaceList * list = head;
71 int count;
72 int ncount;
73 GtkTreeSelection * ns;
74 GtkTreeIter iter;
75 char * freq;
76 int ok;
77
78 count = gtk_tree_selection_count_selected_rows(content_selection);
79 while (list != NULL) {
80 ns = gtk_tree_view_get_selection(GTK_TREE_VIEW(list->treeview));
81 ncount = gtk_tree_selection_count_selected_rows(ns);
82 gtk_widget_set_sensitive(list->addButton,
83 count > 0);
84 /* now check if update is legal */
85 ok = 0;
86 if ( (count == 1) &&
87 (ncount == 1) &&
88 (TRUE == gtk_tree_selection_get_selected(ns,
89 NULL,
90 &iter)) ) {
91
92 gtk_tree_model_get(list->model,
93 &iter,
94 IN_NAMESPACE_PUB_FREQ_STRING, &freq,
95 -1);
96 if ( (freq != NULL) &&
97 (0 != strcmp(freq, _("never"))) )
98 ok = 1;
99 FREENONNULL(freq);
100 }
101 gtk_widget_set_sensitive(list->updateButton,
102 ok);
103 list = list->next;
104 }
105}
106
107
108static void makeNamespaceFrame(NamespaceList * entry) {
61 GtkWidget * child; 109 GtkWidget * child;
62 GtkWidget * resultList; 110 GtkWidget * resultList;
63 GtkCellRenderer * renderer; 111 GtkCellRenderer * renderer;
@@ -79,7 +127,7 @@ void makeNamespaceFrame(NamespaceList * entry) {
79 entry->addButton = glade_xml_get_widget(namespaceXML, 127 entry->addButton = glade_xml_get_widget(namespaceXML,
80 "addButton"); 128 "addButton");
81 entry->updateButton = glade_xml_get_widget(namespaceXML, 129 entry->updateButton = glade_xml_get_widget(namespaceXML,
82 "updateButton"); 130 "namespaceUpdateButton");
83 entry->treeview = GTK_WIDGET(GTK_TREE_VIEW(resultList)); 131 entry->treeview = GTK_WIDGET(GTK_TREE_VIEW(resultList));
84 model = 132 model =
85 gtk_list_store_new(IN_NAMESPACE_NUM, 133 gtk_list_store_new(IN_NAMESPACE_NUM,
@@ -98,7 +146,13 @@ void makeNamespaceFrame(NamespaceList * entry) {
98 gtk_tree_view_set_model(GTK_TREE_VIEW(resultList), 146 gtk_tree_view_set_model(GTK_TREE_VIEW(resultList),
99 GTK_TREE_MODEL(model)); 147 GTK_TREE_MODEL(model));
100 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(resultList)), 148 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(resultList)),
101 GTK_SELECTION_MULTIPLE); 149 GTK_SELECTION_SINGLE);
150 g_signal_connect_data(content_selection,
151 "changed",
152 G_CALLBACK(&on_namespaceContentSelectionChanged),
153 NULL,
154 NULL,
155 0);
102 156
103 157
104 158
@@ -356,32 +410,17 @@ static int addNamespaceContentToModel(void * cls,
356} 410}
357 411
358/** 412/**
359 * The user has edited the search entry.
360 * Update search button status.
361 */
362static void on_namespaceContentSelectionChanged(gpointer signal,
363 gpointer cls) {
364 NamespaceList * list = head;
365
366 while (list != NULL) {
367 gtk_widget_set_sensitive(list->addButton,
368 gtk_tree_selection_count_selected_rows(content_selection) > 0);
369 list = list->next;
370 }
371}
372
373
374/**
375 * Add a tab for the given namespace. 413 * Add a tab for the given namespace.
376 */ 414 */
377static int addTabForNamespace(void * unused, 415int addTabForNamespace(void * unused,
378 const char * namespaceName, 416 const char * namespaceName,
379 const HashCode512 * namespaceId, 417 const HashCode512 * namespaceId,
380 const struct ECRS_MetaData * md, 418 const struct ECRS_MetaData * md,
381 int rating) { 419 int rating) {
382 NamespaceList * list; 420 NamespaceList * list;
383 GtkWidget * label; 421 GtkWidget * label;
384 GtkWidget * notebook; 422 GtkWidget * notebook;
423 GtkWidget * del_menu;
385 424
386 DEBUG_BEGIN(); 425 DEBUG_BEGIN();
387 label = gtk_label_new(namespaceName); 426 label = gtk_label_new(namespaceName);
@@ -409,119 +448,15 @@ static int addTabForNamespace(void * unused,
409 &addNamespaceContentToModel, 448 &addNamespaceContentToModel,
410 list->model); 449 list->model);
411 DEBUG_END(); 450 DEBUG_END();
412 return OK; 451 /* enable "delete" menu entry */
413}
414 452
415void on_namespacemetaDataDialogKeywordAddButton_clicked_fs(gpointer dummy, 453 del_menu = glade_xml_get_widget(getMainXML(),
416 GtkWidget * uploadButton) { 454 "namespaceDelete");
417 handleKeywordListUpdate(metaXML, 455 gtk_widget_set_sensitive(del_menu,
418 "namespaceKeywordEntry", 456 TRUE);
419 "namespaceMetaDataDialogKeywordList"); 457 return OK;
420}
421
422void on_namespacemetaDataDialogMetaDataAddButton_clicked_fs(gpointer dummy,
423 GtkWidget * uploadButton) {
424 handleMetaDataListUpdate(metaXML,
425 "namespaceMetaDataDialogMetaTypeComboBox",
426 "namespaceMetaDataValueEntry",
427 "namespaceMetaDataDialogMetaDataList");
428} 458}
429 459
430void create_namespace_clicked_fs(GtkWidget * dummy1,
431 GtkWidget * dummy2) {
432 const char * namespaceName;
433 GtkWidget * nameLine;
434 GtkWidget * dialog;
435 GtkWidget * spin;
436 struct ECRS_MetaData * meta;
437 struct ECRS_URI * keywordURI;
438 struct ECRS_URI * root;
439 HashCode512 namespaceId;
440 HashCode512 rootEntry;
441
442 DEBUG_BEGIN();
443 metaXML
444 = glade_xml_new(getGladeFileName(),
445 "namespaceMetaDataDialog",
446 PACKAGE_NAME);
447 connectGladeWithPlugins(metaXML);
448 dialog = glade_xml_get_widget(metaXML,
449 "namespaceMetaDataDialog");
450 createMetaDataListTreeView(metaXML,
451 "namespaceMetaDataDialogMetaDataList",
452 NULL,
453 NULL);
454 createKeywordListTreeView(metaXML,
455 "namespaceMetaDataDialogKeywordList",
456 NULL);
457 createMetaTypeComboBox(metaXML,
458 "namespaceMetaDataDialogMetaTypeComboBox");
459 gtk_dialog_set_default_response(GTK_DIALOG(dialog),
460 GTK_RESPONSE_OK);
461 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
462 meta
463 = getMetaDataFromList(metaXML,
464 "namespaceMetaDataDialogMetaDataList",
465 NULL);
466 keywordURI
467 = getKeywordURIFromList(metaXML,
468 "namespaceMetaDataDialogKeywordList");
469 spin = glade_xml_get_widget(metaXML,
470 "namespaceAnonymityspinbutton");
471 nameLine = glade_xml_get_widget(metaXML,
472 "namespaceRootEntry");
473 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
474 if (namespaceName == NULL)
475 namespaceName = "root"; /* do NOT translate "root"! */
476 hash(namespaceName,
477 strlen(namespaceName),
478 &rootEntry);
479 nameLine = glade_xml_get_widget(metaXML,
480 "namespaceNameEntry");
481 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
482 root = NS_createNamespace(ectx,
483 cfg,
484 gtk_spin_button_get_value_as_int
485 (GTK_SPIN_BUTTON(spin)),
486 1000, /* FIXME: priority */
487 999999, /* FIXME: expiration */
488 namespaceName,
489 meta,
490 keywordURI,
491 &rootEntry);
492 if (root != NULL) {
493 ECRS_getNamespaceId(root,
494 &namespaceId);
495 addTabForNamespace(NULL,
496 namespaceName,
497 &namespaceId,
498 meta,
499 0);
500 ECRS_freeUri(root);
501 } else {
502 GtkWidget * dialog;
503
504 dialog = gtk_message_dialog_new
505 (NULL,
506 GTK_DIALOG_MODAL,
507 GTK_MESSAGE_ERROR,
508 GTK_BUTTONS_CLOSE,
509 _("Failed to create namespace `%s'."
510 "Consult logs, most likely error is"
511 " that a namespace with that name "
512 "already exists."),
513 namespaceName);
514 gtk_dialog_run(GTK_DIALOG(dialog));
515 gtk_widget_destroy(dialog);
516 }
517 ECRS_freeMetaData(meta);
518 ECRS_freeUri(keywordURI);
519 }
520 gtk_widget_destroy(dialog);
521 UNREF(metaXML);
522 metaXML = NULL;
523 DEBUG_END();
524}
525 460
526void namespaceDelete_clicked_fs(GtkWidget * dummy1, 461void namespaceDelete_clicked_fs(GtkWidget * dummy1,
527 GtkWidget * dummy2) { 462 GtkWidget * dummy2) {
@@ -587,6 +522,7 @@ void namespaceDelete_clicked_fs(GtkWidget * dummy1,
587 NS_deleteNamespace(ectx, 522 NS_deleteNamespace(ectx,
588 cfg, 523 cfg,
589 list->name); 524 list->name);
525
590 DEBUG_END(); 526 DEBUG_END();
591} 527}
592 528
@@ -603,10 +539,10 @@ typedef struct {
603 * Publish the selected file in the 539 * Publish the selected file in the
604 * selected namespace. 540 * selected namespace.
605 */ 541 */
606static void initiateUpload(GtkTreeModel * model, 542static void addToNamespaceCB(GtkTreeModel * model,
607 GtkTreePath * path, 543 GtkTreePath * path,
608 GtkTreeIter * iter, 544 GtkTreeIter * iter,
609 gpointer data) { 545 gpointer data) {
610 IUC * cls = data; 546 IUC * cls = data;
611 struct ECRS_URI * resultURI; 547 struct ECRS_URI * resultURI;
612 struct ECRS_URI * dst; 548 struct ECRS_URI * dst;
@@ -761,7 +697,7 @@ void on_namespaceInsertButton_clicked_fs(GtkWidget * dummy1,
761 } 697 }
762 ggc_tree_selection_selected_foreach 698 ggc_tree_selection_selected_foreach
763 (content_selection, 699 (content_selection,
764 &initiateUpload, 700 &addToNamespaceCB,
765 &cls); 701 &cls);
766 } 702 }
767 gtk_widget_destroy(dialog); 703 gtk_widget_destroy(dialog);
@@ -929,7 +865,7 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
929 865
930 ggc_tree_selection_selected_foreach 866 ggc_tree_selection_selected_foreach
931 (selection, 867 (selection,
932 &initiateUpload, 868 &addToNamespaceCB,
933 &cls); 869 &cls);
934 } 870 }
935 gtk_widget_destroy(dialog); 871 gtk_widget_destroy(dialog);
@@ -1058,7 +994,10 @@ void on_localNamespaceContentFrameTreeView_destroy_fs(GtkWidget * tree,
1058 NamespaceList * prev; 994 NamespaceList * prev;
1059 NamespaceList * pos; 995 NamespaceList * pos;
1060 NamespaceList * next; 996 NamespaceList * next;
997 GtkWidget * del_menu;
1061 998
999 fprintf(stderr,
1000 "DESTROYING!\n");
1062 pos = head; 1001 pos = head;
1063 while (pos != NULL) { 1002 while (pos != NULL) {
1064 next = pos->next; 1003 next = pos->next;
@@ -1098,12 +1037,17 @@ void on_localNamespaceContentFrameTreeView_destroy_fs(GtkWidget * tree,
1098 &iter)); 1037 &iter));
1099 } 1038 }
1100 FREE(pos); 1039 FREE(pos);
1040 fprintf(stderr,
1041 "DESTROYED %p!\n", head);
1042 del_menu = glade_xml_get_widget(getMainXML(),
1043 "namespaceDelete");
1044 gtk_widget_set_sensitive(del_menu,
1045 head != NULL);
1101} 1046}
1102 1047
1103void fs_namespace_stop() { 1048void fs_namespace_stop() {
1104 URITRACK_unregisterTrackCallback(&updateViewSave, 1049 URITRACK_unregisterTrackCallback(&updateViewSave,
1105 NULL); 1050 NULL);
1106 /* FIXME: free resources! */
1107} 1051}
1108 1052
1109/* end of namespace.c */ 1053/* end of namespace.c */
diff --git a/src/plugins/fs/namespace.h b/src/plugins/fs/namespace.h
index c2260f29..f0a251f5 100644
--- a/src/plugins/fs/namespace.h
+++ b/src/plugins/fs/namespace.h
@@ -27,6 +27,16 @@
27#ifndef GTK_NAMESPACE_H 27#ifndef GTK_NAMESPACE_H
28#define GTK_NAMESPACE_H 28#define GTK_NAMESPACE_H
29 29
30/**
31 * Add a tab for the given namespace.
32 */
33int addTabForNamespace(void * unused,
34 const char * namespaceName,
35 const HashCode512 * namespaceId,
36 const struct ECRS_MetaData * md,
37 int rating);
38
39
30void fs_namespace_start(void); 40void fs_namespace_start(void);
31 41
32void fs_namespace_stop(void); 42void fs_namespace_stop(void);
diff --git a/src/plugins/fs/namespace_create.c b/src/plugins/fs/namespace_create.c
new file mode 100644
index 00000000..6b6e3f86
--- /dev/null
+++ b/src/plugins/fs/namespace_create.c
@@ -0,0 +1,260 @@
1/*
2 This file is part of GNUnet.
3 (C) 2005, 2006, 2007 Christian Grothoff (and other contributing authors)
4
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
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/plugins/fs/namespace.c
23 * @brief operations creating namespaces
24 * @author Christian Grothoff
25 */
26
27#include "platform.h"
28#include "gnunetgtk_common.h"
29#include "fs.h"
30#include "helper.h"
31#include "meta.h"
32#include "namespace.h"
33#include "content_tracking.h"
34#include <GNUnet/gnunet_util_crypto.h>
35#include <GNUnet/gnunet_uritrack_lib.h>
36#include <GNUnet/gnunet_namespace_lib.h>
37#include <extractor.h>
38
39
40static GladeXML * metaXML;
41
42
43void on_namespacemetaDataDialogKeywordRemoveButton_clicked_fs(gpointer dummy,
44 GtkWidget * uploadButton) {
45 handleListRemove(metaXML,
46 "namespaceMetaDataDialogKeywordList");
47}
48
49void on_namespacemetaDataDialogMetaDataRemoveButton_clicked_fs(gpointer dummy,
50 GtkWidget * uploadButton) {
51 handleListRemove(metaXML,
52 "namespaceMetaDataDialogMetaDataList");
53}
54
55void on_namespacemetaDataDialogKeywordAddButton_clicked_fs(gpointer dummy,
56 GtkWidget * uploadButton) {
57 handleKeywordListUpdate(metaXML,
58 "namespaceKeywordEntry",
59 "namespaceMetaDataDialogKeywordList");
60}
61
62void on_namespacemetaDataDialogMetaDataAddButton_clicked_fs(gpointer dummy,
63 GtkWidget * uploadButton) {
64 handleMetaDataListUpdate(metaXML,
65 "namespaceMetaDataDialogMetaTypeComboBox",
66 "namespaceMetaDataValueEntry",
67 "namespaceMetaDataDialogMetaDataList");
68}
69
70/**
71 * The selection of the keyword list changed.
72 * Update button status.
73 */
74static void on_keyword_list_selection_changed(gpointer signal,
75 gpointer cls) {
76 GtkTreeSelection * selection;
77 GtkWidget * button;
78
79 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
80 "namespaceMetaDataDialogKeywordList")));
81 button
82 = glade_xml_get_widget(metaXML,
83 "nsMetaDataDialogKeywordRemoveButton");
84 gtk_widget_set_sensitive(button,
85 gtk_tree_selection_count_selected_rows(selection) > 0);
86}
87
88/**
89 * The selection of the metadata list changed.
90 * Update button status.
91 */
92static void on_metadata_list_selection_changed(gpointer signal,
93 gpointer cls) {
94 GtkTreeSelection * selection;
95 GtkWidget * button;
96
97 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
98 "namespaceMetaDataDialogMetaDataList")));
99 button
100 = glade_xml_get_widget(metaXML,
101 "nsMetaDataDialogMetaDataRemoveButton");
102 gtk_widget_set_sensitive(button,
103 gtk_tree_selection_count_selected_rows(selection) > 0);
104}
105
106/**
107 * The user has edited the metadata entry.
108 * Update add button status.
109 */
110void on_namespaceMetaDataValueEntry_changed_fs(gpointer dummy2,
111 GtkWidget * searchEntry) {
112 const char * input;
113 GtkWidget * button;
114
115 input = gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(metaXML,
116 "namespaceMetaDataValueEntry")));
117 if (input == NULL)
118 return;
119 button
120 = glade_xml_get_widget(metaXML,
121 "nsMetaDataDialogMetaDataAddButton");
122 gtk_widget_set_sensitive(button,
123 strlen(input) > 0);
124}
125
126/**
127 * The user has edited the keyword entry.
128 * Update add button status.
129 */
130void on_namespaceKeywordEntry_changed_fs(gpointer dummy2,
131 GtkWidget * searchEntry) {
132 const char * input;
133 GtkWidget * button;
134
135 input = gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(metaXML,
136 "namespaceKeywordEntry")));
137 if (input == NULL)
138 return;
139 button
140 = glade_xml_get_widget(metaXML,
141 "nsMetaDataDialogKeywordAddButton");
142 gtk_widget_set_sensitive(button,
143 strlen(input) > 0);
144}
145
146
147void create_namespace_clicked_fs(GtkWidget * dummy1,
148 GtkWidget * dummy2) {
149 const char * namespaceName;
150 GtkWidget * nameLine;
151 GtkWidget * dialog;
152 GtkWidget * spin;
153 struct ECRS_MetaData * meta;
154 struct ECRS_URI * keywordURI;
155 struct ECRS_URI * root;
156 HashCode512 namespaceId;
157 HashCode512 rootEntry;
158
159 DEBUG_BEGIN();
160 metaXML
161 = glade_xml_new(getGladeFileName(),
162 "namespaceMetaDataDialog",
163 PACKAGE_NAME);
164 connectGladeWithPlugins(metaXML);
165 dialog = glade_xml_get_widget(metaXML,
166 "namespaceMetaDataDialog");
167 createMetaDataListTreeView(metaXML,
168 "namespaceMetaDataDialogMetaDataList",
169 NULL,
170 NULL);
171 g_signal_connect_data(gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
172 "namespaceMetaDataDialogMetaDataList"))),
173 "changed",
174 G_CALLBACK(&on_metadata_list_selection_changed),
175 NULL,
176 NULL,
177 0);
178 createKeywordListTreeView(metaXML,
179 "namespaceMetaDataDialogKeywordList",
180 NULL);
181 g_signal_connect_data(gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
182 "namespaceMetaDataDialogKeywordList"))),
183 "changed",
184 G_CALLBACK(&on_keyword_list_selection_changed),
185 NULL,
186 NULL,
187 0);
188
189 createMetaTypeComboBox(metaXML,
190 "namespaceMetaDataDialogMetaTypeComboBox");
191 gtk_dialog_set_default_response(GTK_DIALOG(dialog),
192 GTK_RESPONSE_OK);
193 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
194 meta
195 = getMetaDataFromList(metaXML,
196 "namespaceMetaDataDialogMetaDataList",
197 NULL);
198 keywordURI
199 = getKeywordURIFromList(metaXML,
200 "namespaceMetaDataDialogKeywordList");
201 spin = glade_xml_get_widget(metaXML,
202 "namespaceAnonymityspinbutton");
203 nameLine = glade_xml_get_widget(metaXML,
204 "namespaceRootEntry");
205 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
206 if (namespaceName == NULL)
207 namespaceName = "root"; /* do NOT translate "root"! */
208 hash(namespaceName,
209 strlen(namespaceName),
210 &rootEntry);
211 nameLine = glade_xml_get_widget(metaXML,
212 "namespaceNameEntry");
213 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
214 root = NS_createNamespace(ectx,
215 cfg,
216 gtk_spin_button_get_value_as_int
217 (GTK_SPIN_BUTTON(spin)),
218 1000, /* FIXME: priority */
219 999999, /* FIXME: expiration */
220 namespaceName,
221 meta,
222 keywordURI,
223 &rootEntry);
224 if (root != NULL) {
225 ECRS_getNamespaceId(root,
226 &namespaceId);
227 addTabForNamespace(NULL,
228 namespaceName,
229 &namespaceId,
230 meta,
231 0);
232 ECRS_freeUri(root);
233 } else {
234 GtkWidget * dialog;
235
236 /* IMPROVE-ME: we could check if the
237 namespace exists as the user
238 enters its name and disable the
239 "Ok" button unless the name is unique */
240 dialog = gtk_message_dialog_new
241 (NULL,
242 GTK_DIALOG_MODAL,
243 GTK_MESSAGE_ERROR,
244 GTK_BUTTONS_CLOSE,
245 _("Failed to create namespace `%s'."
246 "Consult logs, most likely error is"
247 " that a namespace with that name "
248 "already exists."),
249 namespaceName);
250 gtk_dialog_run(GTK_DIALOG(dialog));
251 gtk_widget_destroy(dialog);
252 }
253 ECRS_freeMetaData(meta);
254 ECRS_freeUri(keywordURI);
255 }
256 gtk_widget_destroy(dialog);
257 UNREF(metaXML);
258 metaXML = NULL;
259 DEBUG_END();
260}