aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/helper.c22
-rw-r--r--src/common/logging.c88
-rw-r--r--src/core/main.c3
-rw-r--r--src/include/gnunetgtk_common.h8
-rw-r--r--src/plugins/daemon/daemon.c75
-rw-r--r--src/plugins/fs/Makefile.am1
-rw-r--r--src/plugins/fs/collection.c6
-rw-r--r--src/plugins/fs/download.c1
-rw-r--r--src/plugins/fs/fs.c97
-rw-r--r--src/plugins/fs/fs.h7
-rw-r--r--src/plugins/fs/namespace.c3
-rw-r--r--src/plugins/fs/namespace_search.c65
-rw-r--r--src/plugins/fs/search.c33
-rw-r--r--src/plugins/fs/status.c79
-rw-r--r--src/plugins/fs/status.h38
-rw-r--r--src/plugins/stats/functions.c21
16 files changed, 294 insertions, 253 deletions
diff --git a/src/common/helper.c b/src/common/helper.c
index 28518fae..01a26825 100644
--- a/src/common/helper.c
+++ b/src/common/helper.c
@@ -90,8 +90,6 @@ static Plugin *plugin;
90 90
91static void *shutdown_function; 91static void *shutdown_function;
92 92
93static struct GNUNET_GE_Context *ectx;
94
95static struct GNUNET_GC_Configuration *cfg; 93static struct GNUNET_GC_Configuration *cfg;
96 94
97static struct GNUNET_CronManager *cron; 95static struct GNUNET_CronManager *cron;
@@ -234,7 +232,7 @@ connector (const gchar * handler_name,
234 if ((module == NULL) || 232 if ((module == NULL) ||
235 (TRUE != g_module_symbol (module, handler_name, &method))) 233 (TRUE != g_module_symbol (module, handler_name, &method)))
236 { 234 {
237 GNUNET_GE_LOG (ectx, 235 GNUNET_GE_LOG (NULL,
238 GNUNET_GE_WARNING | GNUNET_GE_DEVELOPER | 236 GNUNET_GE_WARNING | GNUNET_GE_DEVELOPER |
239 GNUNET_GE_IMMEDIATE, 237 GNUNET_GE_IMMEDIATE,
240 _("Failed to find handler for `%s'\n"), 238 _("Failed to find handler for `%s'\n"),
@@ -265,7 +263,7 @@ loadPlugin (const char *name)
265 struct GNUNET_PluginHandle *lib; 263 struct GNUNET_PluginHandle *lib;
266 InitCall init; 264 InitCall init;
267 265
268 lib = GNUNET_plugin_load (ectx, "libgnunetgtkmodule_", name); 266 lib = GNUNET_plugin_load (NULL, "libgnunetgtkmodule_", name);
269 if (lib == NULL) 267 if (lib == NULL)
270 return; 268 return;
271 p = GNUNET_malloc (sizeof (Plugin)); 269 p = GNUNET_malloc (sizeof (Plugin));
@@ -275,7 +273,7 @@ loadPlugin (const char *name)
275 plugin = p; 273 plugin = p;
276 init = GNUNET_plugin_resolve_function (lib, "init_", GNUNET_NO); 274 init = GNUNET_plugin_resolve_function (lib, "init_", GNUNET_NO);
277 if (init != NULL) 275 if (init != NULL)
278 init (ectx, cfg); 276 init (NULL, cfg);
279} 277}
280 278
281static void 279static void
@@ -330,21 +328,19 @@ unloadPlugin (void *p)
330} 328}
331 329
332void 330void
333GNUNET_GTK_initialize_common_library (struct GNUNET_GE_Context *e, 331GNUNET_GTK_initialize_common_library (struct GNUNET_GC_Configuration *c,
334 struct GNUNET_GC_Configuration *c,
335 void *callback) 332 void *callback)
336{ 333{
337 char *load; 334 char *load;
338 char *path; 335 char *path;
339 char *filename; 336 char *filename;
340 337
341 ectx = e;
342 cfg = c; 338 cfg = c;
343 shutdown_function = callback; 339 shutdown_function = callback;
344 sclock = GNUNET_mutex_create (GNUNET_YES); 340 sclock = GNUNET_mutex_create (GNUNET_YES);
345 mainThread = GNUNET_thread_get_self (); 341 mainThread = GNUNET_thread_get_self ();
346 saveCallsUp = GNUNET_YES; 342 saveCallsUp = GNUNET_YES;
347 cron = GNUNET_cron_create (ectx); 343 cron = GNUNET_cron_create (NULL);
348 344
349 /* load the interface */ 345 /* load the interface */
350 path = GNUNET_get_installation_path (GNUNET_IPK_DATADIR); 346 path = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
@@ -364,7 +360,7 @@ GNUNET_GTK_initialize_common_library (struct GNUNET_GE_Context *e,
364 360
365 mainXML = glade_xml_new (gladeFile, "mainWindow", PACKAGE_NAME); 361 mainXML = glade_xml_new (gladeFile, "mainWindow", PACKAGE_NAME);
366 if (mainXML == NULL) 362 if (mainXML == NULL)
367 GNUNET_GE_DIE_STRERROR_FILE (ectx, 363 GNUNET_GE_DIE_STRERROR_FILE (NULL,
368 GNUNET_GE_FATAL | GNUNET_GE_USER | 364 GNUNET_GE_FATAL | GNUNET_GE_USER |
369 GNUNET_GE_IMMEDIATE, "glade_xml_new", 365 GNUNET_GE_IMMEDIATE, "glade_xml_new",
370 gladeFile); 366 gladeFile);
@@ -463,7 +459,7 @@ GNUNET_GTK_run_with_save_calls (GNUNET_ThreadMainFunction cb, void *arg)
463 cls.arg = arg; 459 cls.arg = arg;
464 doneThread = GNUNET_thread_create (&shutdownCode, &cls, 64 * 1024); 460 doneThread = GNUNET_thread_create (&shutdownCode, &cls, 64 * 1024);
465 if (doneThread == NULL) 461 if (doneThread == NULL)
466 GNUNET_GE_DIE_STRERROR (ectx, 462 GNUNET_GE_DIE_STRERROR (NULL,
467 GNUNET_GE_FATAL | GNUNET_GE_ADMIN | 463 GNUNET_GE_FATAL | GNUNET_GE_ADMIN |
468 GNUNET_GE_BULK, "pthread_create"); 464 GNUNET_GE_BULK, "pthread_create");
469 if (!GNUNET_thread_test_self (mainThread)) 465 if (!GNUNET_thread_test_self (mainThread))
@@ -521,7 +517,7 @@ GNUNET_GTK_notify (int type, const char *message, ...)
521 if (!notify_init ("gnunet-gtk")) 517 if (!notify_init ("gnunet-gtk"))
522 { 518 {
523 once = 1; 519 once = 1;
524 GNUNET_GE_LOG (ectx, 520 GNUNET_GE_LOG (NULL,
525 GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER | 521 GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER |
526 GNUNET_GE_ADMIN, 522 GNUNET_GE_ADMIN,
527 _("Could not initialize libnotify\n")); 523 _("Could not initialize libnotify\n"));
@@ -557,7 +553,7 @@ GNUNET_GTK_notify (int type, const char *message, ...)
557 if (!notify_notification_show (libnotify, NULL)) 553 if (!notify_notification_show (libnotify, NULL))
558 { 554 {
559 once = 1; 555 once = 1;
560 GNUNET_GE_LOG (ectx, 556 GNUNET_GE_LOG (NULL,
561 GNUNET_GE_WARNING | GNUNET_GE_USER | GNUNET_GE_ADMIN 557 GNUNET_GE_WARNING | GNUNET_GE_USER | GNUNET_GE_ADMIN
562 | GNUNET_GE_BULK, 558 | GNUNET_GE_BULK,
563 _("Could not send notification via libnotify\n")); 559 _("Could not send notification via libnotify\n"));
diff --git a/src/common/logging.c b/src/common/logging.c
index 1777e45d..355b4f3b 100644
--- a/src/common/logging.c
+++ b/src/common/logging.c
@@ -30,48 +30,17 @@
30#include <glib.h> 30#include <glib.h>
31#include <gmodule.h> 31#include <gmodule.h>
32 32
33static GtkWidget *infoWindow;
34
35static GtkWidget *infoWindowTextView; 33static GtkWidget *infoWindowTextView;
36 34
37static GladeXML *statusXML;
38
39static void 35static void
40init () 36init ()
41{ 37{
42 GtkWidget *button; 38 if (infoWindowTextView != NULL)
43
44 if (statusXML != NULL)
45 return; 39 return;
46 statusXML
47 =
48 glade_xml_new (GNUNET_GTK_get_glade_filename (), "statusWindow",
49 PACKAGE_NAME);
50 infoWindow = glade_xml_get_widget (statusXML, "statusWindow");
51 infoWindowTextView 40 infoWindowTextView
52 = glade_xml_get_widget (statusXML, "messageWindowTextView"); 41 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML(),
53 button = glade_xml_get_widget (statusXML, "messageWindowCloseButton"); 42 "messageWindowTextView");
54 GNUNET_GTK_connect_glade_with_plugins (statusXML);
55
56 g_signal_connect_data (infoWindow,
57 "delete-event",
58 G_CALLBACK (&gtk_widget_hide_on_delete),
59 NULL, NULL, 0);
60 g_signal_connect_data (button,
61 "clicked",
62 G_CALLBACK (&gtk_widget_hide_on_delete),
63 infoWindow, NULL, G_CONNECT_SWAPPED);
64} 43}
65
66/**
67 * Closure for doInfoMessage.
68 */
69typedef struct
70{
71 int doPopup;
72 char *note;
73} InfoMessage;
74
75/** 44/**
76 * Do not track more than MAX messages 45 * Do not track more than MAX messages
77 */ 46 */
@@ -83,49 +52,40 @@ typedef struct
83static void * 52static void *
84doInfoMessage (void *args) 53doInfoMessage (void *args)
85{ 54{
86 const InfoMessage *info = args; 55 char * note = args;
87 GtkTextIter iter; 56 GtkTextIter iter;
88 GtkTextBuffer *buffer; 57 GtkTextBuffer *buffer;
89 GtkTextIter end; 58 GtkTextIter end;
90 59
91 init (); 60 init ();
92 if (info->doPopup == GNUNET_YES)
93 gtk_widget_show (infoWindow);
94 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (infoWindowTextView)); 61 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (infoWindowTextView));
95 gtk_text_buffer_get_iter_at_offset (buffer, &iter, -1); 62 gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
96 gtk_text_buffer_insert (buffer, &iter, info->note, -1); 63 gtk_text_buffer_insert (buffer, &iter, note, -1);
97 if (gtk_text_buffer_get_line_count (buffer) >= MAX_LINES) 64 if (gtk_text_buffer_get_line_count (buffer) >= MAX_LINES)
98 { 65 {
99 gtk_text_buffer_get_iter_at_line (buffer, &iter, MAX_LINES - 1); 66 gtk_text_buffer_get_iter_at_line (buffer, &iter, MAX_LINES-1);
100 gtk_text_buffer_get_iter_at_line (buffer, &end, MAX_LINES); 67 gtk_text_buffer_get_iter_at_line (buffer, &end, -1);
101 gtk_text_buffer_delete (buffer, &iter, &end); 68 gtk_text_buffer_delete (buffer, &iter, &end);
102 } 69 }
103 return NULL; 70 return NULL;
104} 71}
105 72
106void
107GNUNET_GTK_hide_info_window()
108{
109 gtk_widget_hide (infoWindow);
110}
111
112/** 73/**
113 * Appends a message to the info window 74 * Appends a message to the info window
114 * 75 *
115 * @param doPopup do we open the window, GNUNET_YES or GNUNET_NO 76 * @param doPopup do we open the window, GNUNET_YES or GNUNET_NO
116 */ 77 */
117void 78void
118GNUNET_GTK_show_info_message (int doPopup, const char *format, ...) 79GNUNET_GTK_show_info_message (const char *format, ...)
119{ 80{
120 va_list args; 81 va_list args;
121 InfoMessage info; 82 gchar * note;
122 83
123 va_start (args, format); 84 va_start (args, format);
124 info.note = g_strdup_vprintf (format, args); 85 note = g_strdup_vprintf (format, args);
125 va_end (args); 86 va_end (args);
126 info.doPopup = doPopup; 87 GNUNET_GTK_save_call (&doInfoMessage, note);
127 GNUNET_GTK_save_call (&doInfoMessage, &info); 88 g_free (note);
128 g_free (info.note);
129} 89}
130 90
131static void * 91static void *
@@ -169,8 +129,8 @@ GNUNET_GTK_add_log_entry (const char *txt, ...)
169 va_start (args, txt); 129 va_start (args, txt);
170 note = g_strdup_vprintf (txt, args); 130 note = g_strdup_vprintf (txt, args);
171 va_end (args); 131 va_end (args);
172 GNUNET_GTK_show_info_message (GNUNET_NO, note); 132 GNUNET_GTK_save_call (&doInfoMessage, note);
173 GNUNET_GTK_save_call (&saveAddLogEntry, (void *) note); 133 GNUNET_GTK_save_call (&saveAddLogEntry, note);
174 g_free (note); 134 g_free (note);
175} 135}
176 136
@@ -178,12 +138,7 @@ static void
178ge_gtk_log_handler (void *ctx, 138ge_gtk_log_handler (void *ctx,
179 GNUNET_GE_KIND kind, const char *date, const char *msg) 139 GNUNET_GE_KIND kind, const char *date, const char *msg)
180{ 140{
181 int popUp; 141 GNUNET_GTK_show_info_message ("%s: %s", date, msg);
182
183 popUp = GNUNET_NO;
184 if ((kind & (GNUNET_GE_FATAL | GNUNET_GE_ERROR | GNUNET_GE_WARNING)) > 0)
185 popUp = GNUNET_YES;
186 GNUNET_GTK_show_info_message (popUp, "%s: %s", date, msg);
187} 142}
188 143
189struct GNUNET_GE_Context * 144struct GNUNET_GE_Context *
@@ -197,13 +152,4 @@ GNUNET_GTK_create_gtk_logger (GNUNET_GE_KIND mask)
197 return myLog; 152 return myLog;
198} 153}
199 154
200void __attribute__ ((destructor)) GNUNET_GTK_common_ltdl_fini () 155/* end of logging.c */
201{
202 if (statusXML != NULL)
203 {
204 gtk_widget_destroy (infoWindow);
205 infoWindow = NULL;
206 UNREF (statusXML);
207 statusXML = NULL;
208 }
209}
diff --git a/src/core/main.c b/src/core/main.c
index 5eedb1e8..78e29adf 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -119,7 +119,7 @@ main (int argc, char *const *argv)
119 bind_textdomain_codeset ("GNUnet", "UTF-8"); 119 bind_textdomain_codeset ("GNUnet", "UTF-8");
120 bind_textdomain_codeset ("gnunet-gtk", "UTF-8"); 120 bind_textdomain_codeset ("gnunet-gtk", "UTF-8");
121#endif 121#endif
122 GNUNET_GTK_initialize_common_library (ectx, cfg, &GNUNET_GTK_main_quit); 122 GNUNET_GTK_initialize_common_library (cfg, &GNUNET_GTK_main_quit);
123 /* configure GTK logging */ 123 /* configure GTK logging */
124 GNUNET_GC_get_configuration_value_string (cfg, 124 GNUNET_GC_get_configuration_value_string (cfg,
125 "LOGGING", 125 "LOGGING",
@@ -140,7 +140,6 @@ main (int argc, char *const *argv)
140 dataDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR); 140 dataDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
141 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), dataDir); 141 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), dataDir);
142 GNUNET_free (dataDir); 142 GNUNET_free (dataDir);
143 GNUNET_GTK_hide_info_window();
144 gtk_window_maximize (GTK_WINDOW (root)); 143 gtk_window_maximize (GTK_WINDOW (root));
145 gtk_widget_show (root); 144 gtk_widget_show (root);
146 gtk_window_present (GTK_WINDOW (root)); 145 gtk_window_present (GTK_WINDOW (root));
diff --git a/src/include/gnunetgtk_common.h b/src/include/gnunetgtk_common.h
index d95f8cec..d70009f6 100644
--- a/src/include/gnunetgtk_common.h
+++ b/src/include/gnunetgtk_common.h
@@ -44,8 +44,7 @@
44#endif 44#endif
45 45
46 46
47void GNUNET_GTK_initialize_common_library (struct GNUNET_GE_Context *ectx, 47void GNUNET_GTK_initialize_common_library (struct GNUNET_GC_Configuration
48 struct GNUNET_GC_Configuration
49 *cfg, void *callback); 48 *cfg, void *callback);
50 49
51void GNUNET_GTK_shutdown_plugins (void); 50void GNUNET_GTK_shutdown_plugins (void);
@@ -79,7 +78,7 @@ GtkStatusIcon *GNUNET_GTK_get_trayIcon (void);
79 * @param doPopup if GNUNET_YES, the info window will 78 * @param doPopup if GNUNET_YES, the info window will
80 * be opened 79 * be opened
81 */ 80 */
82void GNUNET_GTK_show_info_message (int doPopup, const char *format, ...); 81void GNUNET_GTK_show_info_message (const char *format, ...);
83 82
84/** 83/**
85 * Appends a log entry to the info window 84 * Appends a log entry to the info window
@@ -90,9 +89,6 @@ void GNUNET_GTK_show_info_message (int doPopup, const char *format, ...);
90 */ 89 */
91void GNUNET_GTK_add_log_entry (const char *txt, ...); 90void GNUNET_GTK_add_log_entry (const char *txt, ...);
92 91
93void
94GNUNET_GTK_hide_info_window(void);
95
96struct GNUNET_GE_Context *GNUNET_GTK_create_gtk_logger (GNUNET_GE_KIND mask); 92struct GNUNET_GE_Context *GNUNET_GTK_create_gtk_logger (GNUNET_GE_KIND mask);
97 93
98#define GNUNET_GTK_NOTIFY_LEVEL_LOW 0 94#define GNUNET_GTK_NOTIFY_LEVEL_LOW 0
diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c
index 1c3b4538..0cab7e52 100644
--- a/src/plugins/daemon/daemon.c
+++ b/src/plugins/daemon/daemon.c
@@ -47,21 +47,38 @@ static struct GNUNET_GE_Context *ectx;
47static struct GNUNET_GC_Configuration *cfg; 47static struct GNUNET_GC_Configuration *cfg;
48 48
49/** 49/**
50 * Do the actual update (in event thread).
51 */
52static void *
53updateAppModelSafe (void *arg)
54{
55 GtkWidget *w;
56 GtkListStore *model = arg;
57
58 w =
59 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
60 "applicationList");
61 gtk_tree_view_set_model (GTK_TREE_VIEW (w), GTK_TREE_MODEL (model));
62 gtk_tree_selection_set_mode (gtk_tree_view_get_selection
63 (GTK_TREE_VIEW (w)), GTK_SELECTION_NONE);
64 return NULL;
65}
66
67/**
50 * cron job that periodically updates the model for the 68 * cron job that periodically updates the model for the
51 * application list. 69 * application list.
52 */ 70 */
53static void * 71static void
54updateAppModelSafe (void *unused) 72updateAppModel (void *dummy)
55{ 73{
56 struct GNUNET_ClientServerConnection *sock; 74 struct GNUNET_ClientServerConnection *sock;
57 GtkWidget *w;
58 GtkListStore *model;
59 GtkTreeIter iter; 75 GtkTreeIter iter;
60 char *apps; 76 char *apps;
61 char *next; 77 char *next;
62 char *pos; 78 char *pos;
63 char *desc; 79 char *desc;
64 80 GtkListStore *model;
81
65 model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); 82 model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
66 apps = NULL; 83 apps = NULL;
67 sock = GNUNET_client_connection_create (ectx, cfg); 84 sock = GNUNET_client_connection_create (ectx, cfg);
@@ -102,21 +119,9 @@ updateAppModelSafe (void *unused)
102 while (next != NULL); 119 while (next != NULL);
103 GNUNET_free (apps); 120 GNUNET_free (apps);
104 } 121 }
105 w =
106 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
107 "applicationList");
108 gtk_tree_view_set_model (GTK_TREE_VIEW (w), GTK_TREE_MODEL (model));
109 gtk_tree_selection_set_mode (gtk_tree_view_get_selection
110 (GTK_TREE_VIEW (w)), GTK_SELECTION_NONE);
111 g_object_unref (model);
112 GNUNET_client_connection_destroy (sock); 122 GNUNET_client_connection_destroy (sock);
113 return NULL; 123 GNUNET_GTK_save_call (&updateAppModelSafe, model);
114} 124 g_object_unref (model);
115
116static void
117updateAppModel (void *dummy)
118{
119 GNUNET_GTK_save_call (&updateAppModelSafe, NULL);
120} 125}
121 126
122 127
@@ -166,7 +171,6 @@ doUpdateMenus (void *arg)
166 isLocal = FALSE; 171 isLocal = FALSE;
167 GNUNET_free (host); 172 GNUNET_free (host);
168 } 173 }
169 updateAppModelSafe (NULL);
170 if (ret == 0) 174 if (ret == 0)
171 { 175 {
172 canStart = 0; 176 canStart = 0;
@@ -238,15 +242,24 @@ doUpdateMenus (void *arg)
238 return NULL; 242 return NULL;
239} 243}
240 244
245/**
246 * Cron job that checks if the daemon is running.
247 */
241static void 248static void
242cronCheckDaemon (void *dummy) 249cronCheckDaemon (void *dummy)
243{ 250{
251 static int last = -1;
244 int ret; 252 int ret;
245 253
246 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg)) 254 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg))
247 ret = 1; 255 ret = 1;
248 else 256 else
249 ret = 0; 257 ret = 0;
258 if (last != ret)
259 {
260 updateAppModel(NULL);
261 last = ret;
262 }
250 GNUNET_GTK_save_call (&doUpdateMenus, &ret); 263 GNUNET_GTK_save_call (&doUpdateMenus, &ret);
251} 264}
252 265
@@ -269,7 +282,10 @@ on_startDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
269 gtk_widget_set_sensitive (launchEntry, FALSE); 282 gtk_widget_set_sensitive (launchEntry, FALSE);
270 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg)) 283 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg))
271 { 284 {
272 cronCheckDaemon (NULL); 285 GNUNET_cron_advance_job(GNUNET_GTK_get_cron_manager (),
286 &cronCheckDaemon,
287 15 * GNUNET_CRON_SECONDS,
288 NULL);
273 return; 289 return;
274 } 290 }
275 else 291 else
@@ -309,7 +325,10 @@ on_startDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
309 GNUNET_GTK_add_log_entry (_("Launched gnunetd\n")); 325 GNUNET_GTK_add_log_entry (_("Launched gnunetd\n"));
310 } 326 }
311 g_free (fn); 327 g_free (fn);
312 cronCheckDaemon (NULL); 328 GNUNET_cron_advance_job(GNUNET_GTK_get_cron_manager (),
329 &cronCheckDaemon,
330 15 * GNUNET_CRON_SECONDS,
331 NULL);
313 return; 332 return;
314 } 333 }
315 else 334 else
@@ -329,7 +348,10 @@ on_startDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
329 } 348 }
330 if (fn != NULL) 349 if (fn != NULL)
331 g_free (fn); 350 g_free (fn);
332 cronCheckDaemon (NULL); 351 GNUNET_cron_advance_job(GNUNET_GTK_get_cron_manager (),
352 &cronCheckDaemon,
353 15 * GNUNET_CRON_SECONDS,
354 NULL);
333 } 355 }
334} 356}
335 357
@@ -368,7 +390,10 @@ on_stopDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
368 } 390 }
369 GNUNET_client_connection_destroy (sock); 391 GNUNET_client_connection_destroy (sock);
370 } 392 }
371 cronCheckDaemon (NULL); 393 GNUNET_cron_advance_job(GNUNET_GTK_get_cron_manager (),
394 &cronCheckDaemon,
395 15 * GNUNET_CRON_SECONDS,
396 NULL);
372} 397}
373 398
374void 399void
@@ -449,7 +474,7 @@ init_daemon (struct GNUNET_GE_Context *e, struct GNUNET_GC_Configuration *c)
449 GNUNET_free (daemon_config); 474 GNUNET_free (daemon_config);
450 475
451 cron = GNUNET_GTK_get_cron_manager (); 476 cron = GNUNET_GTK_get_cron_manager ();
452 GNUNET_cron_add_job (cron, &cronCheckDaemon, 0, 15 * GNUNET_CRON_SECONDS, 477 GNUNET_cron_add_job (cron, &cronCheckDaemon, 2 * GNUNET_CRON_SECONDS, 15 * GNUNET_CRON_SECONDS,
453 NULL); 478 NULL);
454 GNUNET_cron_add_job (cron, &updateAppModel, 5 * GNUNET_CRON_MINUTES, 479 GNUNET_cron_add_job (cron, &updateAppModel, 5 * GNUNET_CRON_MINUTES,
455 5 * GNUNET_CRON_MINUTES, NULL); 480 5 * GNUNET_CRON_MINUTES, NULL);
diff --git a/src/plugins/fs/Makefile.am b/src/plugins/fs/Makefile.am
index b00f8dcf..c8050b53 100644
--- a/src/plugins/fs/Makefile.am
+++ b/src/plugins/fs/Makefile.am
@@ -21,6 +21,7 @@ libgnunetgtkmodule_fs_la_SOURCES = \
21 namespace_create.c \ 21 namespace_create.c \
22 namespace_search.c namespace_search.h \ 22 namespace_search.c namespace_search.h \
23 search.c search.h \ 23 search.c search.h \
24 status.c status.h \
24 download.c download.h \ 25 download.c download.h \
25 upload.c upload.h 26 upload.c upload.h
26libgnunetgtkmodule_fs_la_LIBADD = \ 27libgnunetgtkmodule_fs_la_LIBADD = \
diff --git a/src/plugins/fs/collection.c b/src/plugins/fs/collection.c
index 838d7644..067dce3c 100644
--- a/src/plugins/fs/collection.c
+++ b/src/plugins/fs/collection.c
@@ -133,13 +133,11 @@ deleteCollection_clicked_fs (GtkWidget * dummy1, GtkWidget * dummy2)
133 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 133 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
134 "deleteCollection"); 134 "deleteCollection");
135 gtk_widget_set_sensitive (w, FALSE); 135 gtk_widget_set_sensitive (w, FALSE);
136 GNUNET_GTK_show_info_message (GNUNET_NO, _("Collection stopped.\n")); 136 GNUNET_GTK_show_info_message (_("Collection stopped.\n"));
137 } 137 }
138 else 138 else
139 { 139 {
140 GNUNET_GTK_show_info_message (GNUNET_YES, 140 GNUNET_GTK_show_info_message (_("Failed to stop collection (consult logs).\n"));
141 _
142 ("Failed to stop collection (consult logs).\n"));
143 } 141 }
144} 142}
145 143
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c
index aa32c8f8..b60578bb 100644
--- a/src/plugins/fs/download.c
+++ b/src/plugins/fs/download.c
@@ -28,6 +28,7 @@
28#include "platform.h" 28#include "platform.h"
29#include "fs.h" 29#include "fs.h"
30#include "search.h" 30#include "search.h"
31#include "status.h"
31#include "meta.h" 32#include "meta.h"
32 33
33/* ****************** FSUI download events ****************** */ 34/* ****************** FSUI download events ****************** */
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c
index 163d103c..e00668a0 100644
--- a/src/plugins/fs/fs.c
+++ b/src/plugins/fs/fs.c
@@ -676,102 +676,59 @@ fs_summary_stop ()
676 676
677} 677}
678 678
679static void
680init_cron_job(void * arg)
681{
682 GtkWidget * tab = arg;
683
684 ctx = GNUNET_FSUI_start (ectx, cfg, "gnunet-gtk",
685 8, /* FIXME: allow user to configure download parallelism */
686 GNUNET_YES, &eventProcessor, NULL);
687 GNUNET_GTK_save_call((GNUNET_ThreadMainFunction) &gtk_widget_show,
688 tab);
689}
690
679void 691void
680init_fs (struct GNUNET_GE_Context *e, struct GNUNET_GC_Configuration *c) 692init_fs (struct GNUNET_GE_Context *e, struct GNUNET_GC_Configuration *c)
681{ 693{
682 GtkWidget *tab; 694 GtkWidget *tab;
683 GtkWidget *book; 695 struct GNUNET_CronManager * cron;
684 gint num;
685 696
686 ectx = e; 697 ectx = e;
687 cfg = c; 698 cfg = c;
688 GNUNET_CO_init (ectx, cfg); 699 GNUNET_CO_init (ectx, cfg);
689 tab = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "fsnotebook");
690 gtk_widget_show (tab);
691 book =
692 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "mainnotebook");
693 num = gtk_notebook_get_current_page (GTK_NOTEBOOK (book));
694 gtk_notebook_set_current_page (GTK_NOTEBOOK (book), 1);
695 gtk_notebook_set_current_page (GTK_NOTEBOOK (book), num);
696 fs_summary_start (); 700 fs_summary_start ();
697 fs_collection_start (); 701 fs_collection_start ();
698 fs_namespace_start (); 702 fs_namespace_start ();
699 ctx = GNUNET_FSUI_start (ectx, cfg, "gnunet-gtk", 8, /* FIXME: allow user to configure download parallelism */
700 GNUNET_YES, &eventProcessor, NULL);
701}
702
703static void *
704hide_save_call (void *arg)
705{
706 GtkWidget *tab;
707
708 tab = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "fsnotebook"); 703 tab = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "fsnotebook");
709 gtk_widget_hide (tab); 704 cron = GNUNET_GTK_get_cron_manager();
710 return NULL; 705 GNUNET_cron_add_job(cron, &init_cron_job, 0, 0, tab);
711} 706}
712 707
713static void * 708static void *
714cleanup_save_call (void *arg) 709cleanup_save_call (void *arg)
715{ 710{
711 GtkWidget *tab = arg;
712
716 fs_summary_stop (); 713 fs_summary_stop ();
717 fs_namespace_stop (); 714 fs_namespace_stop ();
715 gtk_widget_hide(tab);
718 return NULL; 716 return NULL;
719} 717}
720 718
721void 719void
722done_fs () 720done_fs ()
723{ 721{
724 GNUNET_GTK_save_call (&hide_save_call, NULL); 722 struct GNUNET_CronManager * cron;
725 GNUNET_FSUI_stop (ctx); 723 GtkWidget *tab;
726 GNUNET_GTK_save_call (&cleanup_save_call, NULL);
727 GNUNET_CO_done ();
728}
729
730
731const char *
732getColorCode (enum GNUNET_URITRACK_STATE state)
733{
734 if (state & (GNUNET_URITRACK_DIRECTORY_ADDED))
735 return "blue";
736 if (state & (GNUNET_URITRACK_INSERTED || GNUNET_URITRACK_INDEXED))
737 return "cyan";
738 if ((state & GNUNET_URITRACK_DOWNLOAD_STARTED) &&
739 (0 == (state &
740 (GNUNET_URITRACK_DOWNLOAD_COMPLETED |
741 GNUNET_URITRACK_DOWNLOAD_ABORTED))))
742 return "yellow";
743 if (state & GNUNET_URITRACK_DOWNLOAD_COMPLETED)
744 return "springgreen";
745 if (state & GNUNET_URITRACK_DOWNLOAD_ABORTED)
746 return "red";
747 if (state &
748 (GNUNET_URITRACK_SEARCH_RESULT | GNUNET_URITRACK_DIRECTORY_FOUND))
749 return "gray";
750 return NULL;
751}
752
753 724
754const char * 725 tab = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "fsnotebook");
755getStatusName (enum GNUNET_URITRACK_STATE state) 726 cron = GNUNET_GTK_get_cron_manager();
756{ 727 GNUNET_cron_del_job(cron, &init_cron_job, 0, tab);
757 if (state & (GNUNET_URITRACK_DIRECTORY_ADDED)) 728 if (ctx != NULL)
758 return _("added"); 729 GNUNET_FSUI_stop (ctx);
759 if (state & (GNUNET_URITRACK_INSERTED || GNUNET_URITRACK_INDEXED)) 730 GNUNET_GTK_save_call (&cleanup_save_call, tab);
760 return _("shared"); 731 GNUNET_CO_done ();
761 if ((state & GNUNET_URITRACK_DOWNLOAD_STARTED) &&
762 (0 == (state &
763 (GNUNET_URITRACK_DOWNLOAD_COMPLETED |
764 GNUNET_URITRACK_DOWNLOAD_ABORTED))))
765 return _("started");
766 if (state & GNUNET_URITRACK_DOWNLOAD_COMPLETED)
767 return _("completed");
768 if (state & GNUNET_URITRACK_DOWNLOAD_ABORTED)
769 return _("aborted");
770 if (state &
771 (GNUNET_URITRACK_SEARCH_RESULT | GNUNET_URITRACK_DIRECTORY_FOUND))
772 return "";
773 return "";
774} 732}
775 733
776
777/* end of fs.c */ 734/* end of fs.c */
diff --git a/src/plugins/fs/fs.h b/src/plugins/fs/fs.h
index 2c38246d..3c978ff3 100644
--- a/src/plugins/fs/fs.h
+++ b/src/plugins/fs/fs.h
@@ -40,7 +40,7 @@
40enum 40enum
41{ 41{
42 NS_SEARCH_DESCRIPTION = 0, 42 NS_SEARCH_DESCRIPTION = 0,
43 NS_SEARCH_ENCNAME, 43 NS_SEARCH_NAME,
44 NS_SEARCH_METADATA, 44 NS_SEARCH_METADATA,
45 NS_SEARCH_RATING, 45 NS_SEARCH_RATING,
46 NS_SEARCH_NUM, 46 NS_SEARCH_NUM,
@@ -348,9 +348,4 @@ extern GtkTreeStore *download_summary;
348 348
349extern GtkTreeStore *upload_summary; 349extern GtkTreeStore *upload_summary;
350 350
351const char *getColorCode (enum GNUNET_URITRACK_STATE state);
352
353const char *getStatusName (enum GNUNET_URITRACK_STATE state);
354
355
356#endif 351#endif
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index ad04505d..9aec5622 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -566,8 +566,7 @@ addToNamespaceCB (GtkTreeModel * model,
566 } 566 }
567 else 567 else
568 { 568 {
569 GNUNET_GTK_show_info_message (GNUNET_YES, 569 GNUNET_GTK_show_info_message (_
570 _
571 ("Failed to insert content into namespace " 570 ("Failed to insert content into namespace "
572 "(consult logs).\n")); 571 "(consult logs).\n"));
573 } 572 }
diff --git a/src/plugins/fs/namespace_search.c b/src/plugins/fs/namespace_search.c
index d81b27c5..ed134192 100644
--- a/src/plugins/fs/namespace_search.c
+++ b/src/plugins/fs/namespace_search.c
@@ -48,7 +48,7 @@ on_namespaceRatingSpinButton_changed_fs (GtkWidget * dummy,
48 GtkWidget *ncbe; 48 GtkWidget *ncbe;
49 GtkTreeModel *model; 49 GtkTreeModel *model;
50 GtkTreeIter iter; 50 GtkTreeIter iter;
51 char *encStr; 51 char *nsName;
52 char *description; 52 char *description;
53 int rating; 53 int rating;
54 int newrating; 54 int newrating;
@@ -63,24 +63,27 @@ on_namespaceRatingSpinButton_changed_fs (GtkWidget * dummy,
63 "searchNamespaceComboBoxEntry"); 63 "searchNamespaceComboBoxEntry");
64 model = gtk_combo_box_get_model (GTK_COMBO_BOX (ncbe)); 64 model = gtk_combo_box_get_model (GTK_COMBO_BOX (ncbe));
65 description = NULL; 65 description = NULL;
66 encStr = NULL; 66 nsName = NULL;
67 if (TRUE == gtk_combo_box_get_active_iter (GTK_COMBO_BOX (ncbe), &iter)) 67 if (TRUE == gtk_combo_box_get_active_iter (GTK_COMBO_BOX (ncbe), &iter))
68 { 68 {
69 gtk_tree_model_get (model, 69 gtk_tree_model_get (model,
70 &iter, 70 &iter,
71 NS_SEARCH_DESCRIPTION, &description, 71 NS_SEARCH_DESCRIPTION, &description,
72 NS_SEARCH_ENCNAME, &encStr, 72 NS_SEARCH_NAME, &nsName,
73 NS_SEARCH_RATING, &rating, -1); 73 NS_SEARCH_RATING, &rating, -1);
74 if ((description != NULL) && (0 == strcmp (description, _("globally")))) 74 if ((description != NULL) && (0 == strcmp (description, "")))
75 { 75 {
76 /* just to be sure */ 76 /* just to be sure */
77 gtk_widget_set_sensitive (spin, FALSE); 77 gtk_widget_set_sensitive (spin, FALSE);
78 } 78 }
79 else 79 else
80 { 80 {
81 if (encStr != NULL) 81 if (nsName != NULL)
82 { 82 {
83 GNUNET_enc_to_hash (encStr, &nsid); 83 GNUNET_GE_ASSERT(NULL,
84 GNUNET_OK ==
85 GNUNET_pseudonym_name_to_id(ectx, cfg,
86 nsName, &nsid));
84 newrating = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin)); 87 newrating = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin));
85 rating = GNUNET_pseudonym_rank (ectx, 88 rating = GNUNET_pseudonym_rank (ectx,
86 cfg, &nsid, newrating - rating); 89 cfg, &nsid, newrating - rating);
@@ -104,8 +107,8 @@ on_namespaceRatingSpinButton_changed_fs (GtkWidget * dummy,
104 } 107 }
105 if (description != NULL) 108 if (description != NULL)
106 free (description); 109 free (description);
107 if (encStr != NULL) 110 if (nsName != NULL)
108 free (encStr); 111 free (nsName);
109 GNUNET_GTK_DEBUG_END (); 112 GNUNET_GTK_DEBUG_END ();
110} 113}
111 114
@@ -125,7 +128,7 @@ on_searchNamespaceComboBoxEntry_changed_fs (GtkWidget * dummy,
125 GtkTreeModel *model; 128 GtkTreeModel *model;
126 GtkTreeIter iter; 129 GtkTreeIter iter;
127 int rating; 130 int rating;
128 char *encStr; 131 char *nsName;
129 char *descStr; 132 char *descStr;
130 GNUNET_HashCode ns; 133 GNUNET_HashCode ns;
131 char *root; 134 char *root;
@@ -139,22 +142,25 @@ on_searchNamespaceComboBoxEntry_changed_fs (GtkWidget * dummy,
139 "searchNamespaceComboBoxEntry"); 142 "searchNamespaceComboBoxEntry");
140 model = gtk_combo_box_get_model (GTK_COMBO_BOX (ncbe)); 143 model = gtk_combo_box_get_model (GTK_COMBO_BOX (ncbe));
141 descStr = NULL; 144 descStr = NULL;
142 encStr = NULL; 145 nsName = NULL;
143 if (TRUE == gtk_combo_box_get_active_iter (GTK_COMBO_BOX (ncbe), &iter)) 146 if (TRUE == gtk_combo_box_get_active_iter (GTK_COMBO_BOX (ncbe), &iter))
144 { 147 {
145 gtk_tree_model_get (model, 148 gtk_tree_model_get (model,
146 &iter, 149 &iter,
147 NS_SEARCH_DESCRIPTION, &descStr, 150 NS_SEARCH_DESCRIPTION, &descStr,
148 NS_SEARCH_ENCNAME, &encStr, 151 NS_SEARCH_NAME, &nsName,
149 NS_SEARCH_RATING, &rating, -1); 152 NS_SEARCH_RATING, &rating, -1);
150 if ((descStr != NULL) && (0 == strcmp (descStr, _("globally")))) 153 if ((descStr != NULL) && (0 == strcmp (descStr, "")))
151 { 154 {
152 gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 0); 155 gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 0);
153 gtk_widget_set_sensitive (spin, FALSE); 156 gtk_widget_set_sensitive (spin, FALSE);
154 } 157 }
155 else if (encStr != NULL) 158 else if (nsName != NULL)
156 { 159 {
157 GNUNET_enc_to_hash (encStr, &ns); 160 GNUNET_GE_ASSERT(NULL,
161 GNUNET_OK ==
162 GNUNET_pseudonym_name_to_id(ectx, cfg,
163 nsName, &ns));
158 gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), rating); 164 gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), rating);
159 gtk_widget_set_sensitive (spin, TRUE); 165 gtk_widget_set_sensitive (spin, TRUE);
160 keyword 166 keyword
@@ -183,8 +189,8 @@ on_searchNamespaceComboBoxEntry_changed_fs (GtkWidget * dummy,
183 } 189 }
184 if (descStr != NULL) 190 if (descStr != NULL)
185 free (descStr); 191 free (descStr);
186 if (encStr != NULL) 192 if (nsName != NULL)
187 free (encStr); 193 free (nsName);
188 GNUNET_GTK_DEBUG_END (); 194 GNUNET_GTK_DEBUG_END ();
189} 195}
190 196
@@ -200,24 +206,19 @@ static void *
200saveDiscovery (void *cls) 206saveDiscovery (void *cls)
201{ 207{
202 struct NewNamespaceInfo *nni = cls; 208 struct NewNamespaceInfo *nni = cls;
203
204 GtkListStore *model; 209 GtkListStore *model;
205 GtkTreeIter iter; 210 GtkTreeIter iter;
206 GNUNET_EncName enc;
207 char *name;
208 struct GNUNET_MetaData *dmd; 211 struct GNUNET_MetaData *dmd;
209 GtkWidget *ncbe; 212 GtkWidget *ncbe;
210 char *desc; 213 char *desc;
211 size_t n; 214 char *haveName;
212 int found; 215 int found;
213 char *encName;
214 216
215 GNUNET_GTK_DEBUG_BEGIN (); 217 GNUNET_GTK_DEBUG_BEGIN ();
216 ncbe = 218 ncbe =
217 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 219 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
218 "searchNamespaceComboBoxEntry"); 220 "searchNamespaceComboBoxEntry");
219 model = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (ncbe))); 221 model = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (ncbe)));
220 GNUNET_hash_to_enc (nni->namespaceId, &enc);
221 if (nni->md == NULL) 222 if (nni->md == NULL)
222 { 223 {
223 dmd = NULL; 224 dmd = NULL;
@@ -242,9 +243,6 @@ saveDiscovery (void *cls)
242 desc = GNUNET_strdup (""); 243 desc = GNUNET_strdup ("");
243 } 244 }
244 245
245 n = strlen (desc) + 64;
246 name = GNUNET_malloc (n);
247 GNUNET_snprintf (name, n, "%s: %.*s", desc, 20, &enc);
248 /* check if present! */ 246 /* check if present! */
249 found = GNUNET_NO; 247 found = GNUNET_NO;
250 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) 248 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
@@ -252,30 +250,27 @@ saveDiscovery (void *cls)
252 do 250 do
253 { 251 {
254 gtk_tree_model_get (GTK_TREE_MODEL (model), 252 gtk_tree_model_get (GTK_TREE_MODEL (model),
255 &iter, NS_SEARCH_ENCNAME, &encName, -1); 253 &iter, NS_SEARCH_NAME, &haveName, -1);
256 if ((encName != NULL) && 254 if ((haveName != NULL) &&
257 (0 == strcmp (encName, (const char *) &enc))) 255 (0 == strcmp (haveName, nni->namespaceName)))
258 found = GNUNET_YES; 256 found = GNUNET_YES;
259 GNUNET_free_non_null (encName); 257 GNUNET_free_non_null (haveName);
260 } 258 }
261 while ((found == GNUNET_NO) && 259 while ((found == GNUNET_NO) &&
262 (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter))); 260 (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter)));
263 } 261 }
264 if (found == GNUNET_NO) 262 if (found == GNUNET_NO)
265 { 263 {
266 GNUNET_GTK_show_info_message (GNUNET_YES, 264 GNUNET_GTK_show_info_message (_("Namespace `%s' found: %s.\n"), nni->namespaceName, desc);
267 _("Namespace found: %s - %.*s\n"), desc,
268 20, &enc);
269 gtk_list_store_append (model, &iter); 265 gtk_list_store_append (model, &iter);
270 gtk_list_store_set (model, 266 gtk_list_store_set (model,
271 &iter, 267 &iter,
272 NS_SEARCH_DESCRIPTION, name, 268 NS_SEARCH_DESCRIPTION, desc,
273 NS_SEARCH_ENCNAME, &enc, 269 NS_SEARCH_NAME, nni->namespaceName,
274 NS_SEARCH_METADATA, dmd, 270 NS_SEARCH_METADATA, dmd,
275 NS_SEARCH_RATING, nni->rating, -1); 271 NS_SEARCH_RATING, nni->rating, -1);
276 } 272 }
277 GNUNET_free (desc); 273 GNUNET_free (desc);
278 GNUNET_free (name);
279 GNUNET_GTK_DEBUG_END (); 274 GNUNET_GTK_DEBUG_END ();
280 275
281 return NULL; 276 return NULL;
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index 26e3844a..92329cb9 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -27,6 +27,7 @@
27#include "platform.h" 27#include "platform.h"
28#include "gnunetgtk_common.h" 28#include "gnunetgtk_common.h"
29#include "search.h" 29#include "search.h"
30#include "status.h"
30#include "helper.h" 31#include "helper.h"
31#include "fs.h" 32#include "fs.h"
32#include "meta.h" 33#include "meta.h"
@@ -1164,27 +1165,35 @@ on_fssearchbutton_clicked_fs (gpointer dummy2, GtkWidget * searchButton)
1164 &iter)) 1165 &iter))
1165 { 1166 {
1166 char *descStr; 1167 char *descStr;
1167 char *ns; 1168 char *nsName;
1168 1169
1169 ns = NULL; 1170 nsName = NULL;
1170 descStr = NULL; 1171 descStr = NULL;
1171 gtk_tree_model_get (gtk_combo_box_get_model 1172 gtk_tree_model_get (gtk_combo_box_get_model
1172 (GTK_COMBO_BOX (searchNamespaceGtkCB)), &iter, 1173 (GTK_COMBO_BOX (searchNamespaceGtkCB)), &iter,
1173 NS_SEARCH_DESCRIPTION, &descStr, NS_SEARCH_ENCNAME, 1174 NS_SEARCH_DESCRIPTION, &descStr, NS_SEARCH_NAME,
1174 &ns, -1); 1175 &nsName, -1);
1175 1176
1176 if ((descStr != NULL) && (0 == strcmp (descStr, _("globally")))) 1177 if ((descStr != NULL) && (0 == strcmp (descStr, "")))
1177 { 1178 {
1178 ns = NULL; 1179 nsName = NULL;
1179 } 1180 }
1180 else 1181 else
1181 { 1182 {
1182 if ((descStr == NULL) && (ns != NULL)) 1183 if ((descStr == NULL) && (nsName != NULL))
1183 descStr = GNUNET_strdup (ns); 1184 descStr = GNUNET_strdup (nsName);
1184 } 1185 }
1185 if (ns != NULL) 1186 if (nsName != NULL)
1186 { 1187 {
1187 char *ustring; 1188 char *ustring;
1189 GNUNET_EncName enc;
1190 GNUNET_HashCode nsid;
1191
1192 GNUNET_GE_ASSERT(NULL,
1193 GNUNET_OK ==
1194 GNUNET_pseudonym_name_to_id(ectx, cfg,
1195 nsName, &nsid));
1196 GNUNET_hash_to_enc(&nsid, &enc);
1188 1197
1189 ustring = 1198 ustring =
1190 GNUNET_malloc (strlen (searchString) + sizeof (GNUNET_EncName) + 1199 GNUNET_malloc (strlen (searchString) + sizeof (GNUNET_EncName) +
@@ -1192,7 +1201,7 @@ on_fssearchbutton_clicked_fs (gpointer dummy2, GtkWidget * searchButton)
1192 strlen (GNUNET_ECRS_SUBSPACE_INFIX) + 10); 1201 strlen (GNUNET_ECRS_SUBSPACE_INFIX) + 10);
1193 strcpy (ustring, GNUNET_ECRS_URI_PREFIX); 1202 strcpy (ustring, GNUNET_ECRS_URI_PREFIX);
1194 strcat (ustring, GNUNET_ECRS_SUBSPACE_INFIX); 1203 strcat (ustring, GNUNET_ECRS_SUBSPACE_INFIX);
1195 strcat (ustring, ns); 1204 strcat (ustring, (const char*)&enc);
1196 strcat (ustring, "/"); 1205 strcat (ustring, "/");
1197 strcat (ustring, searchString); 1206 strcat (ustring, searchString);
1198 fsss.uri = GNUNET_ECRS_string_to_uri (ectx, ustring); 1207 fsss.uri = GNUNET_ECRS_string_to_uri (ectx, ustring);
@@ -1208,8 +1217,8 @@ on_fssearchbutton_clicked_fs (gpointer dummy2, GtkWidget * searchButton)
1208 } 1217 }
1209 if (descStr != NULL) 1218 if (descStr != NULL)
1210 free (descStr); 1219 free (descStr);
1211 if (ns != NULL) 1220 if (nsName != NULL)
1212 free (ns); 1221 free (nsName);
1213 } 1222 }
1214 if (fsss.uri == NULL) 1223 if (fsss.uri == NULL)
1215 fsss.uri = GNUNET_ECRS_keyword_string_to_uri (ectx, searchString); 1224 fsss.uri = GNUNET_ECRS_keyword_string_to_uri (ectx, searchString);
diff --git a/src/plugins/fs/status.c b/src/plugins/fs/status.c
new file mode 100644
index 00000000..1ce858d3
--- /dev/null
+++ b/src/plugins/fs/status.c
@@ -0,0 +1,79 @@
1/*
2 This file is part of GNUnet.
3 (C) 2007, 2008 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/status.c
23 * @brief status codes for files
24 * @author Christian Grothoff
25 */
26
27#include "platform.h"
28#include <GNUnet/gnunet_uritrack_lib.h>
29#include "status.h"
30
31
32
33const char *
34getColorCode (enum GNUNET_URITRACK_STATE state)
35{
36 if (state & (GNUNET_URITRACK_DIRECTORY_ADDED))
37 return "blue";
38 if (state & (GNUNET_URITRACK_INSERTED || GNUNET_URITRACK_INDEXED))
39 return "cyan";
40 if ((state & GNUNET_URITRACK_DOWNLOAD_STARTED) &&
41 (0 == (state &
42 (GNUNET_URITRACK_DOWNLOAD_COMPLETED |
43 GNUNET_URITRACK_DOWNLOAD_ABORTED))))
44 return "yellow";
45 if (state & GNUNET_URITRACK_DOWNLOAD_COMPLETED)
46 return "springgreen";
47 if (state & GNUNET_URITRACK_DOWNLOAD_ABORTED)
48 return "red";
49 if (state &
50 (GNUNET_URITRACK_SEARCH_RESULT | GNUNET_URITRACK_DIRECTORY_FOUND))
51 return "gray";
52 return NULL;
53}
54
55
56const char *
57getStatusName (enum GNUNET_URITRACK_STATE state)
58{
59 if (state & (GNUNET_URITRACK_DIRECTORY_ADDED))
60 return _("added");
61 if (state & (GNUNET_URITRACK_INSERTED || GNUNET_URITRACK_INDEXED))
62 return _("shared");
63 if ((state & GNUNET_URITRACK_DOWNLOAD_STARTED) &&
64 (0 == (state &
65 (GNUNET_URITRACK_DOWNLOAD_COMPLETED |
66 GNUNET_URITRACK_DOWNLOAD_ABORTED))))
67 return _("started");
68 if (state & GNUNET_URITRACK_DOWNLOAD_COMPLETED)
69 return _("completed");
70 if (state & GNUNET_URITRACK_DOWNLOAD_ABORTED)
71 return _("aborted");
72 if (state &
73 (GNUNET_URITRACK_SEARCH_RESULT | GNUNET_URITRACK_DIRECTORY_FOUND))
74 return "";
75 return "";
76}
77
78
79/* end of status.c */
diff --git a/src/plugins/fs/status.h b/src/plugins/fs/status.h
new file mode 100644
index 00000000..b2db5f4f
--- /dev/null
+++ b/src/plugins/fs/status.h
@@ -0,0 +1,38 @@
1/*
2 This file is part of GNUnet.
3 (C) 2007, 2008 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/status.h
23 * @brief status codes for files
24 * @author Christian Grothoff
25 */
26
27#ifndef FS_STATUS_H
28#define FS_STATUS_H
29
30#include "platform.h"
31#include <GNUnet/gnunet_uritrack_lib.h>
32#include "status.h"
33
34const char *getColorCode (enum GNUNET_URITRACK_STATE state);
35
36const char *getStatusName (enum GNUNET_URITRACK_STATE state);
37
38#endif
diff --git a/src/plugins/stats/functions.c b/src/plugins/stats/functions.c
index 79145fb6..4c179dd0 100644
--- a/src/plugins/stats/functions.c
+++ b/src/plugins/stats/functions.c
@@ -478,12 +478,18 @@ statsProcessor (const char *optName, unsigned long long value, void *data)
478 return GNUNET_OK; 478 return GNUNET_OK;
479} 479}
480 480
481struct UpdateClosure {
482 GNUNET_CronTime delta;
483 int is_running;
484};
485
481/* 486/*
482 * Update the status bar indicator about daemon and connexions status 487 * Update the status bar indicator about daemon and connexions status
483 */ 488 */
484static void * 489static void *
485updateDaemonStatus (void *delta) 490updateDaemonStatus (void *cls)
486{ 491{
492 struct UpdateClosure * uc = cls;
487 static gboolean once = TRUE; 493 static gboolean once = TRUE;
488 static int last_status = -5; 494 static int last_status = -5;
489 unsigned long long connected_peers; 495 unsigned long long connected_peers;
@@ -567,10 +573,10 @@ updateDaemonStatus (void *delta)
567 573
568 once = FALSE; 574 once = FALSE;
569 } 575 }
570 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg)) 576 if (uc->is_running)
571 { 577 {
572 if (GNUNET_OK != 578 if (GNUNET_OK !=
573 getStatValue (&connected_peers, (GNUNET_CronTime *) delta, NULL, 579 getStatValue (&connected_peers, NULL, NULL,
574 "# of connected peers", GNUNET_NO)) 580 "# of connected peers", GNUNET_NO))
575 { 581 {
576 if (last_status != -1) 582 if (last_status != -1)
@@ -665,15 +671,16 @@ updateStatValues (void *unused)
665{ 671{
666 static GNUNET_CronTime lastUpdate; 672 static GNUNET_CronTime lastUpdate;
667 GNUNET_CronTime now; 673 GNUNET_CronTime now;
668 GNUNET_CronTime delta; 674 struct UpdateClosure uc;
669 675
670 now = GNUNET_get_time (); 676 now = GNUNET_get_time ();
671 delta = now - lastUpdate; 677 uc.delta = now - lastUpdate;
678 uc.is_running = GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg);
672 GNUNET_mutex_lock (lock); 679 GNUNET_mutex_lock (lock);
673 if (GNUNET_OK == 680 if (GNUNET_OK ==
674 GNUNET_STATS_get_statistics (ectx, sock, &statsProcessor, &delta)) 681 GNUNET_STATS_get_statistics (ectx, sock, &statsProcessor, &uc.delta))
675 lastUpdate = now; 682 lastUpdate = now;
676 GNUNET_GTK_save_call (&updateDaemonStatus, (void *) &delta); 683 GNUNET_GTK_save_call (&updateDaemonStatus, (void *) &uc);
677 GNUNET_mutex_unlock (lock); 684 GNUNET_mutex_unlock (lock);
678} 685}
679 686