aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fs/namespace_search.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/fs/namespace_search.c')
-rw-r--r--src/plugins/fs/namespace_search.c100
1 files changed, 99 insertions, 1 deletions
diff --git a/src/plugins/fs/namespace_search.c b/src/plugins/fs/namespace_search.c
index f5f7b1d8..92c15d73 100644
--- a/src/plugins/fs/namespace_search.c
+++ b/src/plugins/fs/namespace_search.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
@@ -185,3 +185,101 @@ void on_searchNamespaceComboBoxEntry_changed_fs(GtkWidget * dummy,
185 free(encStr); 185 free(encStr);
186 DEBUG_END(); 186 DEBUG_END();
187} 187}
188
189struct NewNamespaceInfo {
190 const char * namespaceName;
191 const HashCode512 * namespaceId;
192 const struct ECRS_MetaData * md;
193 int rating;
194};
195
196static void * saveDiscovery(void * cls) {
197 struct NewNamespaceInfo * nni = cls;
198
199 GtkListStore * model;
200 GtkTreeIter iter;
201 EncName enc;
202 char * name;
203 struct ECRS_MetaData * dmd;
204 GtkWidget * ncbe;
205 char * desc;
206 size_t n;
207
208 DEBUG_BEGIN();
209 ncbe
210 = glade_xml_get_widget(getMainXML(),
211 "searchNamespaceComboBoxEntry");
212 model = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(ncbe)));
213 hash2enc(nni->namespaceId,
214 &enc);
215 if (nni->md == NULL) {
216 dmd = NULL;
217 desc = STRDUP("");
218 } else {
219 dmd = ECRS_dupMetaData(nni->md);
220 desc = ECRS_getFirstFromMetaData(dmd,
221 EXTRACTOR_DESCRIPTION,
222 EXTRACTOR_TITLE,
223 EXTRACTOR_AUTHOR,
224 EXTRACTOR_GENRE,
225 EXTRACTOR_SUBJECT,
226 EXTRACTOR_CREATOR,
227 EXTRACTOR_PRODUCER,
228 EXTRACTOR_GROUP,
229 EXTRACTOR_CREATED_FOR,
230 EXTRACTOR_SUMMARY,
231 EXTRACTOR_OWNER,
232 -1);
233 if (desc == NULL)
234 desc = STRDUP("");
235 }
236
237 n = strlen(desc) + 64;
238 name = MALLOC(n);
239 SNPRINTF(name,
240 n,
241 "%s: %.*s",
242 desc,
243 20,
244 &enc);
245 gtk_list_store_append(model,
246 &iter);
247 gtk_list_store_set(model,
248 &iter,
249 NS_SEARCH_DESCRIPTION, name,
250 NS_SEARCH_ENCNAME, &enc,
251 NS_SEARCH_METADATA, dmd,
252 NS_SEARCH_RATING, nni->rating,
253 -1);
254 FREE(name);
255 DEBUG_END();
256
257 return NULL;
258}
259
260
261
262/**
263 * Call this function to inform the user about
264 * newly found namespaces and to add them to the
265 * list of available namespaces in the search
266 * dialog.
267 *
268 * @param cls pass NULL
269 * @param rating the local rating of the namespace
270 * @return OK (always)
271 */
272int namespace_discovered_cb(void * cls,
273 const char * namespaceName,
274 const HashCode512 * namespaceId,
275 const struct ECRS_MetaData * md,
276 int rating) {
277 struct NewNamespaceInfo nni;
278 nni.namespaceName = namespaceName;
279 nni.namespaceId = namespaceId;
280 nni.md = md;
281 nni.rating = rating;
282 gtkSaveCall(&saveDiscovery,
283 &nni);
284 return OK;
285}