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.c94
1 files changed, 29 insertions, 65 deletions
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index 88d9ec86..57520198 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -35,8 +35,6 @@
35#include <GNUnet/gnunet_namespace_lib.h> 35#include <GNUnet/gnunet_namespace_lib.h>
36#include <extractor.h> 36#include <extractor.h>
37 37
38#define UPDATE_CONTENT_LIST_FREQUENCY (5 * cronMINUTES)
39
40/** 38/**
41 * @brief linked list of pages in the search notebook 39 * @brief linked list of pages in the search notebook
42 */ 40 */
@@ -241,32 +239,21 @@ static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview,
241 * content model. Check that it is not already 239 * content model. Check that it is not already
242 * present! 240 * present!
243 */ 241 */
244static int updateView(const ECRS_FileInfo * fi, 242static void * updateView(void * cls) {
245 const HashCode512 * key, 243 const ECRS_FileInfo * fi = cls;
246 int isRoot,
247 void * closure) {
248 GtkTreeModel * model = GTK_TREE_MODEL(closure);
249 struct ECRS_URI * euri;
250 GtkTreeIter iter; 244 GtkTreeIter iter;
251 char * filename; 245 char * filename;
252 char * uriString; 246 char * uriString;
253 unsigned long long size; 247 unsigned long long size;
254 char * size_h; 248 char * size_h;
249 GtkWidget * contentList;
250 GtkTreeModel * model;
255 251
256 DEBUG_BEGIN(); 252 contentList
257 if (gtk_tree_model_get_iter_first(model, 253 = glade_xml_get_widget(getMainXML(),
258 &iter)) { 254 "availableContentList");
259 do { 255 model
260 gtk_tree_model_get(model, 256 = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList));
261 &iter,
262 NAMESPACE_URI, &euri,
263 -1);
264 if (ECRS_equalsUri(euri,
265 fi->uri))
266 return OK; /* already listed */
267 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model),
268 &iter));
269 }
270 filename = ECRS_getFirstFromMetaData(fi->meta, 257 filename = ECRS_getFirstFromMetaData(fi->meta,
271 EXTRACTOR_FILENAME, 258 EXTRACTOR_FILENAME,
272 EXTRACTOR_TITLE, 259 EXTRACTOR_TITLE,
@@ -309,10 +296,23 @@ static int updateView(const ECRS_FileInfo * fi,
309 FREE(size_h); 296 FREE(size_h);
310 FREE(filename); 297 FREE(filename);
311 FREE(uriString); 298 FREE(uriString);
312 DEBUG_END(); 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);
313 return OK; 312 return OK;
314} 313}
315 314
315
316static void * clearContentList(void * mdl) { 316static void * clearContentList(void * mdl) {
317 GtkTreeModel * model = GTK_TREE_MODEL(mdl); 317 GtkTreeModel * model = GTK_TREE_MODEL(mdl);
318 struct ECRS_URI * uri; 318 struct ECRS_URI * uri;
@@ -343,37 +343,6 @@ static void * clearContentList(void * mdl) {
343} 343}
344 344
345/** 345/**
346 * Update the list of the globally available content.
347 */
348static void * doUpdateContentList(void * unused) {
349 GtkWidget * contentList;
350 GtkTreeModel * model;
351
352 DEBUG_BEGIN();
353 contentList
354 = glade_xml_get_widget(getMainXML(),
355 "availableContentList");
356 model
357 = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList));
358 URITRACK_listURIs(ectx,
359 cfg,
360 YES,
361 &updateView,
362 model);
363 DEBUG_END();
364 return NULL;
365}
366
367static void updateContentList(void * unused) {
368 gtkSaveCall(&doUpdateContentList, NULL);
369}
370
371void on_refreshContentListButton_clicked_fs(gpointer dummy,
372 gpointer dummy1) {
373 updateContentList(NULL);
374}
375
376/**
377 * Update the model that lists the content of a namespace: 346 * Update the model that lists the content of a namespace:
378 * add this content. 347 * add this content.
379 * 348 *
@@ -1187,7 +1156,6 @@ void on_clearAvailableContentButton_clicked_fs(GtkWidget * dummy1,
1187 URITRACK_clearTrackedURIS(ectx, 1156 URITRACK_clearTrackedURIS(ectx,
1188 cfg); 1157 cfg);
1189 gtkSaveCall(&clearContentList, model); 1158 gtkSaveCall(&clearContentList, model);
1190 updateContentList(NULL);
1191 DEBUG_END(); 1159 DEBUG_END();
1192} 1160}
1193 1161
@@ -1428,13 +1396,10 @@ void fs_namespace_start() {
1428 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(contentList), 1396 gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(contentList),
1429 col - 1), 1397 col - 1),
1430 TRUE); 1398 TRUE);
1431#if 0 1399 URITRACK_registerTrackCallback(ectx,
1432 /* FIXME: change to event based update approach! */ 1400 cfg,
1433 addCronJob(&updateContentList, 1401 &updateViewSave,
1434 0, 1402 NULL);
1435 UPDATE_CONTENT_LIST_FREQUENCY,
1436 NULL);
1437#endif
1438 NS_listNamespaces(ectx, 1403 NS_listNamespaces(ectx,
1439 cfg, 1404 cfg,
1440 YES, 1405 YES,
@@ -1449,9 +1414,6 @@ void on_availableContentList_destroy_fs(GtkWidget * dummy1,
1449 GtkWidget * contentList; 1414 GtkWidget * contentList;
1450 GtkTreeModel * model; 1415 GtkTreeModel * model;
1451 1416
1452 delCronJob(&updateContentList,
1453 UPDATE_CONTENT_LIST_FREQUENCY,
1454 NULL);
1455 contentList 1417 contentList
1456 = glade_xml_get_widget(getMainXML(), 1418 = glade_xml_get_widget(getMainXML(),
1457 "availableContentList"); 1419 "availableContentList");
@@ -1499,6 +1461,8 @@ void on_localNamespacesNotebook_destroy_fs(GtkWidget * dummy1,
1499#endif 1461#endif
1500 1462
1501void fs_namespace_stop() { 1463void fs_namespace_stop() {
1464 URITRACK_unregisterTrackCallback(&updateViewSave,
1465 NULL);
1502 /* FIXME: free resources! */ 1466 /* FIXME: free resources! */
1503} 1467}
1504 1468