void hsep_timer(time_t now) { const GSList *sl; bool scanning_shared; static time_t last_sent = 0; /* update number of shared files and KiB */ gnet_prop_get_boolean_val(PROP_LIBRARY_REBUILDING, &scanning_shared); if (!scanning_shared) { if (upload_is_enabled()) hsep_notify_shared(shared_files_scanned(), shared_kbytes_scanned()); else hsep_notify_shared(0UL, 0UL); } for (sl = node_all_nodes(); sl; sl = g_slist_next(sl)) { struct gnutella_node *n = sl->data; int diff; /* only consider established connections here */ if (!NODE_IS_ESTABLISHED(n)) continue; if (!(n->attrs & NODE_A_CAN_HSEP)) continue; /* check how many seconds ago the last message was sent */ diff = n->hsep->random_skew + delta_time(now, n->hsep->last_sent); /* the -900 is used to react to changes in system time */ if (diff >= HSEP_MSG_INTERVAL || diff < -900) hsep_send_msg(n, now); } /* * Quick'n dirty hack to update the horizon stats in the * statusbar at least once every 3 seconds. * * TODO: remove this and implement it properly in the * statusbar code. */ if (delta_time(now, last_sent) >= 3) { hsep_fire_global_table_changed(now); last_sent = now; } }
void search_gui_download_files(struct search *search) { GSList *sl = NULL; struct selection_ctx ctx; gboolean clear; g_return_if_fail(search); /* FIXME: This has to be GUI (not a core) property! */ gnet_prop_get_boolean_val(PROP_SEARCH_REMOVE_DOWNLOADED, &clear); ctx.tv = GTK_TREE_VIEW(search->tree); ctx.iters = clear ? &sl : NULL; gtk_tree_selection_selected_foreach(gtk_tree_view_get_selection(ctx.tv), download_selected_all_files, &ctx); if (sl) { g_slist_foreach(sl, remove_selected_file, search); g_slist_free(sl); } }