diff options
Diffstat (limited to 'src/plugins/fs/namespace_create.c')
-rw-r--r-- | src/plugins/fs/namespace_create.c | 280 |
1 files changed, 0 insertions, 280 deletions
diff --git a/src/plugins/fs/namespace_create.c b/src/plugins/fs/namespace_create.c deleted file mode 100644 index 9738c7ea..00000000 --- a/src/plugins/fs/namespace_create.c +++ /dev/null | |||
@@ -1,280 +0,0 @@ | |||
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 | |||
40 | static GladeXML *metaXML; | ||
41 | |||
42 | |||
43 | void | ||
44 | on_namespacemetaDataDialogKeywordRemoveButton_clicked_fs (gpointer dummy, | ||
45 | GtkWidget * | ||
46 | uploadButton) | ||
47 | { | ||
48 | handleListRemove (metaXML, "namespaceMetaDataDialogKeywordList"); | ||
49 | } | ||
50 | |||
51 | void | ||
52 | on_namespacemetaDataDialogMetaDataRemoveButton_clicked_fs (gpointer dummy, | ||
53 | GtkWidget * | ||
54 | uploadButton) | ||
55 | { | ||
56 | handleListRemove (metaXML, "namespaceMetaDataDialogMetaDataList"); | ||
57 | } | ||
58 | |||
59 | void | ||
60 | on_namespacemetaDataDialogKeywordAddButton_clicked_fs (gpointer dummy, | ||
61 | GtkWidget * | ||
62 | uploadButton) | ||
63 | { | ||
64 | handleKeywordListUpdate (metaXML, | ||
65 | "namespaceKeywordEntry", | ||
66 | "namespaceMetaDataDialogKeywordList"); | ||
67 | } | ||
68 | |||
69 | void | ||
70 | on_namespacemetaDataDialogMetaDataAddButton_clicked_fs (gpointer dummy, | ||
71 | GtkWidget * | ||
72 | uploadButton) | ||
73 | { | ||
74 | handleMetaDataListUpdate (metaXML, | ||
75 | "namespaceMetaDataDialogMetaTypeComboBox", | ||
76 | "namespaceMetaDataValueEntry", | ||
77 | "namespaceMetaDataDialogMetaDataList"); | ||
78 | } | ||
79 | |||
80 | void | ||
81 | on_namespaceKeywordEntry_activate_fs (GtkWidget * | ||
82 | namespaceKeywordEntry, gpointer dummy) | ||
83 | { | ||
84 | const char *input; | ||
85 | |||
86 | input = gtk_entry_get_text (GTK_ENTRY (namespaceKeywordEntry)); | ||
87 | if ((input == NULL) || (strlen (input) == 0)) | ||
88 | return; | ||
89 | handleKeywordListUpdate (metaXML, | ||
90 | "namespaceKeywordEntry", | ||
91 | "namespaceMetaDataDialogKeywordList"); | ||
92 | } | ||
93 | |||
94 | void | ||
95 | on_namespaceMetaDataEntry_activate_fs (GtkWidget * | ||
96 | namespaceMetaDataEntry, gpointer dummy) | ||
97 | { | ||
98 | const char *input; | ||
99 | |||
100 | input = gtk_entry_get_text (GTK_ENTRY (namespaceMetaDataEntry)); | ||
101 | if ((input == NULL) || (strlen (input) == 0)) | ||
102 | return; | ||
103 | handleMetaDataListUpdate (metaXML, | ||
104 | "namespaceMetaDataDialogMetaTypeComboBox", | ||
105 | "namespaceMetaDataValueEntry", | ||
106 | "namespaceMetaDataDialogMetaDataList"); | ||
107 | } | ||
108 | |||
109 | |||
110 | /** | ||
111 | * The selection of the keyword list changed. | ||
112 | * Update button status. | ||
113 | */ | ||
114 | static void | ||
115 | on_keyword_list_selection_changed (gpointer signal, gpointer cls) | ||
116 | { | ||
117 | GtkTreeSelection *selection; | ||
118 | GtkWidget *button; | ||
119 | |||
120 | selection = | ||
121 | gtk_tree_view_get_selection (GTK_TREE_VIEW | ||
122 | (glade_xml_get_widget | ||
123 | (metaXML, | ||
124 | "namespaceMetaDataDialogKeywordList"))); | ||
125 | button = | ||
126 | glade_xml_get_widget (metaXML, "nsMetaDataDialogKeywordRemoveButton"); | ||
127 | gtk_widget_set_sensitive (button, | ||
128 | gtk_tree_selection_count_selected_rows (selection) | ||
129 | > 0); | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * The selection of the metadata list changed. | ||
134 | * Update button status. | ||
135 | */ | ||
136 | static void | ||
137 | on_metadata_list_selection_changed (gpointer signal, gpointer cls) | ||
138 | { | ||
139 | GtkTreeSelection *selection; | ||
140 | GtkWidget *button; | ||
141 | |||
142 | selection = | ||
143 | gtk_tree_view_get_selection (GTK_TREE_VIEW | ||
144 | (glade_xml_get_widget | ||
145 | (metaXML, | ||
146 | "namespaceMetaDataDialogMetaDataList"))); | ||
147 | button = | ||
148 | glade_xml_get_widget (metaXML, "nsMetaDataDialogMetaDataRemoveButton"); | ||
149 | gtk_widget_set_sensitive (button, | ||
150 | gtk_tree_selection_count_selected_rows (selection) | ||
151 | > 0); | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * The user has edited the metadata entry. | ||
156 | * Update add button status. | ||
157 | */ | ||
158 | void | ||
159 | on_namespaceMetaDataValueEntry_changed_fs (gpointer dummy2, | ||
160 | GtkWidget * searchEntry) | ||
161 | { | ||
162 | const char *input; | ||
163 | GtkWidget *button; | ||
164 | |||
165 | input = gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (metaXML, | ||
166 | "namespaceMetaDataValueEntry"))); | ||
167 | if (input == NULL) | ||
168 | return; | ||
169 | button | ||
170 | = glade_xml_get_widget (metaXML, "nsMetaDataDialogMetaDataAddButton"); | ||
171 | gtk_widget_set_sensitive (button, strlen (input) > 0); | ||
172 | } | ||
173 | |||
174 | /** | ||
175 | * The user has edited the keyword entry. | ||
176 | * Update add button status. | ||
177 | */ | ||
178 | void | ||
179 | on_namespaceKeywordEntry_changed_fs (gpointer dummy2, GtkWidget * searchEntry) | ||
180 | { | ||
181 | const char *input; | ||
182 | GtkWidget *button; | ||
183 | |||
184 | input = gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (metaXML, | ||
185 | "namespaceKeywordEntry"))); | ||
186 | if (input == NULL) | ||
187 | return; | ||
188 | button = glade_xml_get_widget (metaXML, "nsMetaDataDialogKeywordAddButton"); | ||
189 | gtk_widget_set_sensitive (button, strlen (input) > 0); | ||
190 | } | ||
191 | |||
192 | |||
193 | void | ||
194 | create_namespace_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2) | ||
195 | { | ||
196 | const char *rootName; | ||
197 | GtkWidget *nameLine; | ||
198 | GtkWidget *dialog; | ||
199 | GtkWidget *spin; | ||
200 | struct GNUNET_MetaData *meta; | ||
201 | struct GNUNET_ECRS_URI *keywordURI; | ||
202 | struct GNUNET_ECRS_URI *root; | ||
203 | GNUNET_HashCode namespaceId; | ||
204 | |||
205 | GNUNET_GTK_DEBUG_BEGIN (); | ||
206 | metaXML | ||
207 | = glade_xml_new (GNUNET_GTK_get_glade_filename (), | ||
208 | "namespaceMetaDataDialog", PACKAGE_NAME); | ||
209 | GNUNET_GTK_connect_glade_with_plugins (metaXML); | ||
210 | dialog = glade_xml_get_widget (metaXML, "namespaceMetaDataDialog"); | ||
211 | createMetaDataListTreeView (metaXML, | ||
212 | "namespaceMetaDataDialogMetaDataList", | ||
213 | NULL, NULL); | ||
214 | g_signal_connect_data (gtk_tree_view_get_selection | ||
215 | (GTK_TREE_VIEW | ||
216 | (glade_xml_get_widget | ||
217 | (metaXML, "namespaceMetaDataDialogMetaDataList"))), | ||
218 | "changed", | ||
219 | G_CALLBACK (&on_metadata_list_selection_changed), | ||
220 | NULL, NULL, 0); | ||
221 | createKeywordListTreeView (metaXML, "namespaceMetaDataDialogKeywordList", | ||
222 | NULL); | ||
223 | g_signal_connect_data (gtk_tree_view_get_selection | ||
224 | (GTK_TREE_VIEW | ||
225 | (glade_xml_get_widget | ||
226 | (metaXML, "namespaceMetaDataDialogKeywordList"))), | ||
227 | "changed", | ||
228 | G_CALLBACK (&on_keyword_list_selection_changed), | ||
229 | NULL, NULL, 0); | ||
230 | |||
231 | createMetaTypeComboBox (metaXML, "namespaceMetaDataDialogMetaTypeComboBox"); | ||
232 | gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); | ||
233 | if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) | ||
234 | { | ||
235 | meta | ||
236 | = getMetaDataFromList (metaXML, | ||
237 | "namespaceMetaDataDialogMetaDataList", NULL); | ||
238 | keywordURI | ||
239 | = getKeywordURIFromList (metaXML, | ||
240 | "namespaceMetaDataDialogKeywordList"); | ||
241 | spin = glade_xml_get_widget (metaXML, "namespaceAnonymityspinbutton"); | ||
242 | nameLine = glade_xml_get_widget (metaXML, "namespaceRootEntry"); | ||
243 | rootName = gtk_entry_get_text (GTK_ENTRY (nameLine)); | ||
244 | if (rootName == NULL) | ||
245 | rootName = "root"; /* do NOT translate "root"! */ | ||
246 | root = GNUNET_NS_namespace_create (ectx, cfg, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)), 1000, /* FIXME: priority */ | ||
247 | GNUNET_get_time () + 2 * GNUNET_CRON_YEARS, /* FIXME: expiration */ | ||
248 | meta, keywordURI, rootName); | ||
249 | if (root != NULL) | ||
250 | { | ||
251 | GNUNET_ECRS_uri_get_namespace_from_sks (root, &namespaceId); | ||
252 | addTabForNamespace (NULL, &namespaceId, meta, 0); | ||
253 | GNUNET_ECRS_uri_destroy (root); | ||
254 | } | ||
255 | else | ||
256 | { | ||
257 | GtkWidget *dialog; | ||
258 | |||
259 | /* IMPROVE-ME: we could check if the | ||
260 | namespace exists as the user | ||
261 | enters its name and disable the | ||
262 | "Ok" button unless the name is unique */ | ||
263 | dialog = gtk_message_dialog_new | ||
264 | (NULL, | ||
265 | GTK_DIALOG_MODAL, | ||
266 | GTK_MESSAGE_ERROR, | ||
267 | GTK_BUTTONS_CLOSE, | ||
268 | _("Failed to create namespace." "Consult logs.")); | ||
269 | gtk_dialog_run (GTK_DIALOG (dialog)); | ||
270 | gtk_widget_destroy (dialog); | ||
271 | } | ||
272 | GNUNET_meta_data_destroy (meta); | ||
273 | if (keywordURI != NULL) | ||
274 | GNUNET_ECRS_uri_destroy (keywordURI); | ||
275 | } | ||
276 | gtk_widget_destroy (dialog); | ||
277 | UNREF (metaXML); | ||
278 | metaXML = NULL; | ||
279 | GNUNET_GTK_DEBUG_END (); | ||
280 | } | ||