aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/daemon/daemon.c12
-rw-r--r--src/plugins/fs/fs.c1
-rw-r--r--src/plugins/fs/fs.h20
-rw-r--r--src/plugins/fs/search.c133
-rw-r--r--src/plugins/stats/functions.c92
-rw-r--r--src/plugins/stats/functions.h4
6 files changed, 187 insertions, 75 deletions
diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c
index 721f28bd..304a6cbb 100644
--- a/src/plugins/daemon/daemon.c
+++ b/src/plugins/daemon/daemon.c
@@ -240,18 +240,6 @@ doUpdateMenus (void *arg)
240 return NULL; 240 return NULL;
241} 241}
242 242
243static int
244statsProcessor (const char *optName, unsigned long long value, void *data)
245{
246 unsigned long long * ret = data;
247
248 if (0 == strcmp ("# of connected peers",
249 optName))
250 *ret = value;
251 return GNUNET_OK;
252}
253
254
255static void 243static void
256cronCheckDaemon (void *dummy) 244cronCheckDaemon (void *dummy)
257{ 245{
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c
index 1eda8a50..4fea764b 100644
--- a/src/plugins/fs/fs.c
+++ b/src/plugins/fs/fs.c
@@ -145,7 +145,6 @@ saveEventProcessor (void *cls)
145 fs_search_aborted (event->data.SearchAborted.sc.cctx); 145 fs_search_aborted (event->data.SearchAborted.sc.cctx);
146 break; 146 break;
147 case GNUNET_FSUI_search_completed: 147 case GNUNET_FSUI_search_completed:
148 // FIXME...
149 fs_search_aborted (event->data.SearchCompleted.sc.cctx); 148 fs_search_aborted (event->data.SearchCompleted.sc.cctx);
150 break; 149 break;
151 case GNUNET_FSUI_search_suspended: 150 case GNUNET_FSUI_search_suspended:
diff --git a/src/plugins/fs/fs.h b/src/plugins/fs/fs.h
index 9a00a24f..1bfadc42 100644
--- a/src/plugins/fs/fs.h
+++ b/src/plugins/fs/fs.h
@@ -210,6 +210,11 @@ typedef struct SL
210 struct GNUNET_FSUI_SearchList *fsui_list; 210 struct GNUNET_FSUI_SearchList *fsui_list;
211 211
212 /** 212 /**
213 * Maximum runtime for the search.
214 */
215 GNUNET_CronTime max_delay;
216
217 /**
213 * Number of results received so far. 218 * Number of results received so far.
214 */ 219 */
215 unsigned int resultsReceived; 220 unsigned int resultsReceived;
@@ -224,6 +229,21 @@ typedef struct SL
224 */ 229 */
225 unsigned int last_y; 230 unsigned int last_y;
226 231
232 /**
233 * Did the user just ask to pause the search?
234 */
235 int is_paused;
236
237 /**
238 * Desired anonymity level.
239 */
240 unsigned int anonymityLevel;
241
242 /**
243 * Maximum number of results.
244 */
245 unsigned int max_results;
246
227} SearchList; 247} SearchList;
228 248
229 249
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index ea21c639..a78dd430 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/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, 2007 Christian Grothoff (and other contributing authors) 3 (C) 2005, 2006, 2007, 2008 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
@@ -164,6 +164,7 @@ fs_search_result_received (SearchList * searchContext,
164 GtkTreeStore *model; 164 GtkTreeStore *model;
165 GtkTreeIter iter; 165 GtkTreeIter iter;
166 enum GNUNET_URITRACK_STATE state; 166 enum GNUNET_URITRACK_STATE state;
167 struct GNUNET_ECRS_URI * have;
167 168
168 state = GNUNET_URITRACK_get_state (ectx, cfg, info->uri); 169 state = GNUNET_URITRACK_get_state (ectx, cfg, info->uri);
169 if ((state & (GNUNET_URITRACK_INSERTED | 170 if ((state & (GNUNET_URITRACK_INSERTED |
@@ -174,6 +175,20 @@ fs_search_result_received (SearchList * searchContext,
174 GNUNET_YES))) 175 GNUNET_YES)))
175 return; 176 return;
176 model = GTK_TREE_STORE (gtk_tree_view_get_model (searchContext->treeview)); 177 model = GTK_TREE_STORE (gtk_tree_view_get_model (searchContext->treeview));
178 /* Check that the entry does not already exist (for resume!) */
179 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
180 {
181 do
182 {
183 have = NULL;
184 gtk_tree_model_get (GTK_TREE_MODEL(model),
185 &iter, SEARCH_URI, &have, -1);
186 if ( (have != NULL) &&
187 (GNUNET_ECRS_uri_test_equal(have, uri)) )
188 return; /* duplicate */
189 }
190 while (gtk_tree_model_iter_next (GTK_TREE_MODEL(model), &iter));
191 }
177 gtk_tree_store_append (model, &iter, NULL); 192 gtk_tree_store_append (model, &iter, NULL);
178 addEntryToSearchTree (searchContext, NULL, info, &iter); 193 addEntryToSearchTree (searchContext, NULL, info, &iter);
179 searchContext->resultsReceived++; 194 searchContext->resultsReceived++;
@@ -384,6 +399,28 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list,
384 int col; 399 int col;
385 int i; 400 int i;
386 401
402 /* check that search does not already exist
403 with fsui_list == NULL;
404 (and if so, hijack!) */
405 list = search_head;
406 while (list != NULL)
407 {
408 if ( (list->fsui_list == NULL) &&
409 (list->uri != NULL) &&
410 (GNUNET_ECRS_uri_test_equal(list->uri,
411 uri)) )
412 {
413 list->fsui_list = fsui_list;
414 for (i = 0; i < resultCount; i++)
415 fs_search_result_received (list, &results[i], uri);
416 if (resultCount == 0) /* otherwise already done! */
417 updateSearchSummary (list);
418 return list;
419 }
420 list = list->next;
421 }
422
423 /* build new entry */
387 description = GNUNET_ECRS_uri_to_string (uri); 424 description = GNUNET_ECRS_uri_to_string (uri);
388 if (description == NULL) 425 if (description == NULL)
389 { 426 {
@@ -407,6 +444,8 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list,
407 list->uri = GNUNET_ECRS_uri_duplicate (uri); 444 list->uri = GNUNET_ECRS_uri_duplicate (uri);
408 list->fsui_list = fsui_list; 445 list->fsui_list = fsui_list;
409 list->next = search_head; 446 list->next = search_head;
447 list->anonymityLevel = anonymityLevel;
448
410 search_head = list; 449 search_head = list;
411 list->searchXML 450 list->searchXML
412 = 451 =
@@ -604,7 +643,12 @@ freeIterSubtree (GtkTreeModel * tree, GtkTreeIter * iter)
604void 643void
605fs_search_aborted (SearchList * list) 644fs_search_aborted (SearchList * list)
606{ 645{
607 /* FIXME: show aborted status somehow! */ 646 gtk_widget_show(glade_xml_get_widget(list->searchXML,
647 "searchResumeButton"));
648 gtk_widget_show(glade_xml_get_widget(list->searchXML,
649 "searchAbortButton"));
650 gtk_widget_show(glade_xml_get_widget(list->searchXML,
651 "searchPauseButton"));
608} 652}
609 653
610/** 654/**
@@ -622,6 +666,14 @@ fs_search_stopped (SearchList * list)
622 int index; 666 int index;
623 int i; 667 int i;
624 668
669 if (list->is_paused == GNUNET_YES)
670 {
671 /* if this was just a request to pause,
672 then simply ignore the FS-stopped event */
673 list->fsui_list = NULL;
674 list->is_paused = GNUNET_NO;
675 return;
676 }
625 /* remove from linked list */ 677 /* remove from linked list */
626 if (search_head == list) 678 if (search_head == list)
627 { 679 {
@@ -701,8 +753,6 @@ on_fssearchKeywordComboBoxEntry_changed_fs (gpointer dummy2,
701typedef struct 753typedef struct
702{ 754{
703 unsigned int anonymity; 755 unsigned int anonymity;
704 unsigned int max;
705 GNUNET_CronTime delay;
706 struct GNUNET_ECRS_URI *uri; 756 struct GNUNET_ECRS_URI *uri;
707} FSSS; 757} FSSS;
708 758
@@ -710,7 +760,7 @@ static void *
710search_start_helper (void *cls) 760search_start_helper (void *cls)
711{ 761{
712 FSSS *fsss = cls; 762 FSSS *fsss = cls;
713 GNUNET_FSUI_search_start (ctx, fsss->anonymity, fsss->max, fsss->delay, 763 GNUNET_FSUI_search_start (ctx, fsss->anonymity,
714 fsss->uri); 764 fsss->uri);
715 return NULL; 765 return NULL;
716} 766}
@@ -846,13 +896,7 @@ on_fssearchbutton_clicked_fs (gpointer dummy2, GtkWidget * searchButton)
846 list = list->next; 896 list = list->next;
847 } 897 }
848 fsss.anonymity = getSpinButtonValue (GNUNET_GTK_get_main_glade_XML (), 898 fsss.anonymity = getSpinButtonValue (GNUNET_GTK_get_main_glade_XML (),
849 "searchAnonymitySelectionSpinButton"); 899 "searchAnonymitySelectionSpinButton");
850 fsss.max =
851 getSpinButtonValue (GNUNET_GTK_get_main_glade_XML (),
852 "maxResultsSpinButton");
853 fsss.delay =
854 getSpinButtonValue (GNUNET_GTK_get_main_glade_XML (),
855 "searchDelaySpinButton") * GNUNET_CRON_SECONDS;
856 GNUNET_GTK_run_with_save_calls (search_start_helper, &fsss); 900 GNUNET_GTK_run_with_save_calls (search_start_helper, &fsss);
857 GNUNET_ECRS_uri_destroy (fsss.uri); 901 GNUNET_ECRS_uri_destroy (fsss.uri);
858} 902}
@@ -897,7 +941,8 @@ on_closeSearchButton_clicked_fs (GtkWidget * searchPage,
897 GNUNET_GE_ASSERT (ectx, list != NULL); 941 GNUNET_GE_ASSERT (ectx, list != NULL);
898 if (list->fsui_list == NULL) 942 if (list->fsui_list == NULL)
899 { 943 {
900 /* open directory - close directly */ 944 /* open directory or paused search;
945 close directly */
901 fs_search_stopped (list); 946 fs_search_stopped (list);
902 } 947 }
903 else 948 else
@@ -911,12 +956,70 @@ on_closeSearchButton_clicked_fs (GtkWidget * searchPage,
911 } 956 }
912} 957}
913 958
959
960/**
961 * The abort button in the search summary was clicked.
962 */
963void
964on_searchPauseButton_clicked_fs (GtkWidget * searchPage,
965 GtkWidget * pauseButton)
966{
967 SearchList *list;
968 struct FCBC fcbc;
969
970 list = search_head;
971 while (list != NULL)
972 {
973 if (list->searchpage == searchPage)
974 break;
975 list = list->next;
976 }
977 GNUNET_GE_ASSERT (ectx, list != NULL);
978 gtk_widget_hide(pauseButton);
979 gtk_widget_show(glade_xml_get_widget(list->searchXML,
980 "searchResumeButton"));
981 if (list->fsui_list != NULL)
982 {
983 list->is_paused = GNUNET_YES;
984 fcbc.method = &GNUNET_FSUI_search_stop;
985 fcbc.argument = list->fsui_list;
986 GNUNET_GTK_run_with_save_calls (&fsui_callback, &fcbc);
987 }
988}
989
990/**
991 * The abort button in the search summary was clicked.
992 */
993void
994on_searchResumeButton_clicked_fs (GtkWidget * searchPage,
995 GtkWidget * resumeButton)
996{
997 FSSS fsss;
998 SearchList *list;
999
1000 list = search_head;
1001 while (list != NULL)
1002 {
1003 if (list->searchpage == searchPage)
1004 break;
1005 list = list->next;
1006 }
1007 GNUNET_GE_ASSERT (ectx, list != NULL);
1008 gtk_widget_hide(resumeButton);
1009 gtk_widget_show(glade_xml_get_widget(list->searchXML,
1010 "searchPauseButton"));
1011 fsss.anonymity = getSpinButtonValue (GNUNET_GTK_get_main_glade_XML (),
1012 "searchAnonymitySelectionSpinButton");
1013 fsss.uri = list->uri;
1014 GNUNET_GTK_run_with_save_calls (search_start_helper, &fsss);
1015}
1016
914/** 1017/**
915 * The abort button was clicked. Abort the search. 1018 * The abort button was clicked. Abort the search.
916 */ 1019 */
917void 1020void
918on_abortSearchButton_clicked_fs (GtkWidget * searchPage, 1021on_abortSearchButton_clicked_fs (GtkWidget * searchPage,
919 GtkWidget * closeButton) 1022 GtkWidget * abortButton)
920{ 1023{
921 SearchList *list; 1024 SearchList *list;
922 struct FCBC fcbc; 1025 struct FCBC fcbc;
@@ -929,6 +1032,7 @@ on_abortSearchButton_clicked_fs (GtkWidget * searchPage,
929 list = list->next; 1032 list = list->next;
930 } 1033 }
931 GNUNET_GE_ASSERT (ectx, list != NULL); 1034 GNUNET_GE_ASSERT (ectx, list != NULL);
1035 gtk_widget_hide(abortButton);
932 if (list->fsui_list != NULL) 1036 if (list->fsui_list != NULL)
933 { 1037 {
934 fcbc.method = &GNUNET_FSUI_search_abort; 1038 fcbc.method = &GNUNET_FSUI_search_abort;
@@ -1007,4 +1111,5 @@ on_abortSearchSummaryButton_clicked_fs (GtkWidget * treeview,
1007 GNUNET_GTK_tree_selection_selected_foreach (selection, &abortSearch, NULL); 1111 GNUNET_GTK_tree_selection_selected_foreach (selection, &abortSearch, NULL);
1008} 1112}
1009 1113
1114
1010/* end of search.c */ 1115/* end of search.c */
diff --git a/src/plugins/stats/functions.c b/src/plugins/stats/functions.c
index f566f45e..f7faaf0e 100644
--- a/src/plugins/stats/functions.c
+++ b/src/plugins/stats/functions.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors) 3 (C) 2004, 2005, 2006, 2008 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
@@ -39,9 +39,9 @@ static struct GNUNET_Mutex *lock;
39 39
40static long connectionGoal; 40static long connectionGoal;
41 41
42static long long banddown; 42static unsigned long long banddown;
43 43
44static long long bandup; 44static unsigned long long bandup;
45 45
46static struct GNUNET_GE_Context *ectx; 46static struct GNUNET_GE_Context *ectx;
47 47
@@ -50,8 +50,8 @@ static struct GNUNET_GC_Configuration *cfg;
50static struct GNUNET_CronManager *cron; 50static struct GNUNET_CronManager *cron;
51 51
52static int 52static int
53getStatValue (long long *value, 53getStatValue (unsigned long long *value,
54 long long *lvalue, 54 unsigned long long *lvalue,
55 GNUNET_CronTime * dtime, const char *optName, int monotone) 55 GNUNET_CronTime * dtime, const char *optName, int monotone)
56{ 56{
57 unsigned int i; 57 unsigned int i;
@@ -120,8 +120,8 @@ updateConnectionGoal (void *unused)
120static int 120static int
121getConnectedNodesStat (const void *closure, gfloat ** data) 121getConnectedNodesStat (const void *closure, gfloat ** data)
122{ 122{
123 long long val; 123 unsigned long long val;
124 124
125 if (connectionGoal == 0) 125 if (connectionGoal == 0)
126 return GNUNET_SYSERR; 126 return GNUNET_SYSERR;
127 if (GNUNET_OK != 127 if (GNUNET_OK !=
@@ -134,10 +134,10 @@ getConnectedNodesStat (const void *closure, gfloat ** data)
134static int 134static int
135getLoadStat (const void *closure, gfloat ** data) 135getLoadStat (const void *closure, gfloat ** data)
136{ 136{
137 long long valc; 137 unsigned long long valc;
138 long long vali; 138 unsigned long long vali;
139 long long valu; 139 unsigned long long valu;
140 long long vald; 140 unsigned long long vald;
141 141
142 if (GNUNET_OK != 142 if (GNUNET_OK !=
143 getStatValue (&valc, NULL, NULL, "% of allowed cpu load", GNUNET_NO)) 143 getStatValue (&valc, NULL, NULL, "% of allowed cpu load", GNUNET_NO))
@@ -164,8 +164,8 @@ getLoadStat (const void *closure, gfloat ** data)
164static int 164static int
165getQuotaStat (const void *closure, gfloat ** data) 165getQuotaStat (const void *closure, gfloat ** data)
166{ 166{
167 long long allowed; 167 unsigned long long allowed;
168 long long have; 168 unsigned long long have;
169 169
170 if (GNUNET_OK != getStatValue (&allowed, 170 if (GNUNET_OK != getStatValue (&allowed,
171 NULL, NULL, "# bytes allowed in datastore", 171 NULL, NULL, "# bytes allowed in datastore",
@@ -183,18 +183,18 @@ getQuotaStat (const void *closure, gfloat ** data)
183static int 183static int
184getTrafficRecvStats (const void *closure, gfloat ** data) 184getTrafficRecvStats (const void *closure, gfloat ** data)
185{ 185{
186 long long total; 186 unsigned long long total;
187 long long noise; 187 unsigned long long noise;
188 long long content; 188 unsigned long long content;
189 long long queries; 189 unsigned long long queries;
190 long long hellos; 190 unsigned long long hellos;
191 long long rlimit; 191 unsigned long long rlimit;
192 long long ltotal; 192 unsigned long long ltotal;
193 long long lnoise; 193 unsigned long long lnoise;
194 long long lcontent; 194 unsigned long long lcontent;
195 long long lqueries; 195 unsigned long long lqueries;
196 long long lhellos; 196 unsigned long long lhellos;
197 long long lrlimit; 197 unsigned long long lrlimit;
198 GNUNET_CronTime dtime; 198 GNUNET_CronTime dtime;
199 char *buffer; 199 char *buffer;
200 200
@@ -272,18 +272,18 @@ getTrafficRecvStats (const void *closure, gfloat ** data)
272static int 272static int
273getTrafficSendStats (const void *closure, gfloat ** data) 273getTrafficSendStats (const void *closure, gfloat ** data)
274{ 274{
275 long long total; 275 unsigned long long total;
276 long long noise; 276 unsigned long long noise;
277 long long content; 277 unsigned long long content;
278 long long queries; 278 unsigned long long queries;
279 long long hellos; 279 unsigned long long hellos;
280 long long slimit; 280 unsigned long long slimit;
281 long long ltotal; 281 unsigned long long ltotal;
282 long long lnoise; 282 unsigned long long lnoise;
283 long long lcontent; 283 unsigned long long lcontent;
284 long long lqueries; 284 unsigned long long lqueries;
285 long long lhellos; 285 unsigned long long lhellos;
286 long long lslimit; 286 unsigned long long lslimit;
287 GNUNET_CronTime dtime; 287 GNUNET_CronTime dtime;
288 char *buffer; 288 char *buffer;
289 289
@@ -365,12 +365,12 @@ getEffectivenessStats (const void *closure, gfloat ** data)
365 static GNUNET_CronTime last; 365 static GNUNET_CronTime last;
366 static double lastdata; 366 static double lastdata;
367 static double lastavg; 367 static double lastavg;
368 long long total; 368 unsigned long long total;
369 long long success; 369 unsigned long long success;
370 long long local; 370 unsigned long long local;
371 long long ltotal; 371 unsigned long long ltotal;
372 long long lsuccess; 372 unsigned long long lsuccess;
373 long long llocal; 373 unsigned long long llocal;
374 GNUNET_CronTime now; 374 GNUNET_CronTime now;
375 375
376 now = GNUNET_get_time (); 376 now = GNUNET_get_time ();
@@ -474,7 +474,7 @@ updateDaemonStatus (void *delta)
474{ 474{
475 static gboolean once = TRUE; 475 static gboolean once = TRUE;
476 static int last_status = -5; 476 static int last_status = -5;
477 long long connected_peers; 477 unsigned long long connected_peers;
478 char *label; 478 char *label;
479 static GtkWidget *statusConnexionsLabel; 479 static GtkWidget *statusConnexionsLabel;
480 static GtkWidget *statusConnexionsPic; 480 static GtkWidget *statusConnexionsPic;
@@ -522,8 +522,8 @@ updateDaemonStatus (void *delta)
522 } 522 }
523 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg)) 523 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg))
524 { 524 {
525 if (GNUNET_OK != getStatValue (&connected_peers, (GNUNET_CronTime *) delta, 525 if (GNUNET_OK != getStatValue (&connected_peers, (GNUNET_CronTime *) delta,
526 NULL, "# of connected peers", GNUNET_NO)) 526 NULL, "# of connected peers", GNUNET_NO))
527 { 527 {
528 if (last_status != -1) 528 if (last_status != -1)
529 { 529 {
diff --git a/src/plugins/stats/functions.h b/src/plugins/stats/functions.h
index 6c3b2c24..6d05ce26 100644
--- a/src/plugins/stats/functions.h
+++ b/src/plugins/stats/functions.h
@@ -27,8 +27,8 @@
27typedef struct 27typedef struct
28{ 28{
29 char *statName; 29 char *statName;
30 long long value; 30 unsigned long long value;
31 long long lvalue; 31 unsigned long long lvalue;
32 GNUNET_CronTime delta; 32 GNUNET_CronTime delta;
33} StatPair; 33} StatPair;
34 34