Exemplo n.º 1
0
/*	settings interface functions (UI -> Core)*/
guint16
guc_listen_port(void)
{
    guint32 port;
    gnet_prop_get_guint32_val(PROP_LISTEN_PORT, &port);
    return port;
}
Exemplo n.º 2
0
static void
icon_timer(time_t unused_now)
{
    GdkRectangle rect;
    guint con_old, up_old, down_old;

	(void) unused_now;

    /*   don't do anything if icon isn't even visible or the
       application is closing   */
    if (!icon_visible_fg || icon_close_fg)
        return;

    /*   this may be useful someday   */
    if (icon_just_mapped_fg) {
        icon_just_mapped_fg = FALSE;
    }

    /*   get current values   */
    con_old = leaf_cnt + norm_cnt + ultra_cnt;
    up_old = up_cnt;
    down_old = down_cnt;
    gnet_prop_get_guint32_val(PROP_NODE_LEAF_COUNT, &leaf_cnt);
    gnet_prop_get_guint32_val(PROP_NODE_NORMAL_COUNT, &norm_cnt);
    gnet_prop_get_guint32_val(PROP_NODE_ULTRA_COUNT, &ultra_cnt);
    gnet_prop_get_guint32_val(PROP_MAX_CONNECTIONS, &con_max);
    gnet_prop_get_guint32_val(PROP_UL_RUNNING, &up_cnt);
    gnet_prop_get_guint32_val(PROP_MAX_UPLOADS, &up_max);
    gnet_prop_get_guint32_val(PROP_DL_RUNNING_COUNT, &down_cnt);
    gnet_prop_get_guint32_val(PROP_MAX_DOWNLOADS, &down_max);

    /*   if nothing has changed, then don't redraw   */
    if (con_old == leaf_cnt + norm_cnt + ultra_cnt)
        if (up_old == up_cnt && down_old == down_cnt)
            return;

    /*
     * For some reason, gtk_widget_queue_draw(canvas) will
     * not work in either GTK 1 or GTK 2, probably an issue
     * with the fact that the icon window is an icon.  Whatever
     * the reason, to get the canvas widget to redraw, it
     * has to be done that hard way.
     */
    rect.x = rect.y = 0;
    rect.width = canvas->allocation.width;
    rect.height = canvas->allocation.height;
    gdk_window_invalidate_rect(canvas->window, &rect, FALSE);
}
Exemplo n.º 3
0
/**
 * Queue a bitzi queries from the search context menu
 */
void
on_popup_search_metadata_activate(GtkMenuItem *unused_menuitem,
	gpointer unused_udata)
{
    GList *node_list;
	GSList *data_list;
    search_t *search;
	guint32 bitzi_debug;

	(void) unused_menuitem;
	(void) unused_udata;

    search = search_gui_get_current_search();
    g_assert(search != NULL);

    gtk_clist_freeze(GTK_CLIST(search->tree));

	node_list = g_list_copy(GTK_CLIST(search->tree)->selection);
	data_list = search_cb_collect_ctree_data(GTK_CTREE(search->tree),
					node_list, gui_record_sha1_eq);

	/* Make sure the column is actually visible. */
	{
		static const gint min_width = 80;
		GtkCList *clist = GTK_CLIST(search->tree);

    	gtk_clist_set_column_visibility(clist, c_sr_meta, TRUE);
		if (clist->column[c_sr_meta].width < min_width)
    		gtk_clist_set_column_width(clist, c_sr_meta, min_width);
	}
	
	/* Queue up our requests */
    gnet_prop_get_guint32_val(PROP_BITZI_DEBUG, &bitzi_debug);
	if (bitzi_debug > 10)
		g_debug("on_popup_search_metadata_activate: %d items, %p",
			  g_slist_position(data_list, g_slist_last(data_list)) + 1,
			  cast_to_gconstpointer(data_list));

	G_SLIST_FOREACH(data_list, search_gui_queue_bitzi_by_sha1);

	gtk_clist_thaw(GTK_CLIST(search->tree));
	g_slist_free(data_list);
	g_list_free(node_list);
}
Exemplo n.º 4
0
/**
 * @return whether the entry for the upload `ul' should be removed
 * from the UI with respect to the configured behaviour.
 */
gboolean
upload_should_remove(time_t now, const upload_row_data_t *ul)
{
	property_t prop = 0;

	g_assert(NULL != ul);

	switch (ul->status) {
	case GTA_UL_COMPLETE:
		prop = PROP_AUTOCLEAR_COMPLETED_UPLOADS;
		break;
	case GTA_UL_CLOSED:
	case GTA_UL_ABORTED:
		prop = PROP_AUTOCLEAR_FAILED_UPLOADS;
		break;
	case GTA_UL_PUSH_RECEIVED:
	case GTA_UL_SENDING:
	case GTA_UL_HEADERS:
	case GTA_UL_WAITING:
	case GTA_UL_EXPECTING:
	case GTA_UL_QUEUED:
	case GTA_UL_QUEUE:
	case GTA_UL_QUEUE_WAITING:
		break;
	}

	if (0 != prop) {
		guint32 val;
		time_delta_t grace;

		gnet_prop_get_guint32_val(PROP_ENTRY_REMOVAL_TIMEOUT, &val);
		grace = val;

		if (delta_time(now, ul->last_update) > grace) {
			gboolean auto_remove;

			gui_prop_get_boolean_val(prop, &auto_remove);
			return auto_remove;
		}
	}

	return FALSE;
}
Exemplo n.º 5
0
void
bitzi_gui_update(const bitzi_data_t *bitzi_data)
{
	guint32 bitzi_debug;

	g_assert(bitzi_data != NULL);

    gnet_prop_get_guint32_val(PROP_BITZI_DEBUG, &bitzi_debug);
	if (bitzi_debug > 10)
    	g_debug("bitzi_gui_update: data %p, size %s, "
			  "goodness %f, judgment %d, type %s, details %s",
			cast_to_gconstpointer(bitzi_data),
			uint64_to_string(bitzi_data->size),
			bitzi_data->goodness,
			bitzi_data->judgment,
			NULL_STRING(bitzi_data->mime_type),
			NULL_STRING(bitzi_data->mime_desc));

	/* Update the various GUI elements */

	search_gui_metadata_update(bitzi_data);
}
Exemplo n.º 6
0
/**
 * @return a pointer to a static buffer containing a string which
 * describes the current status of the upload.
 */
const gchar *
uploads_gui_status_str(const gnet_upload_status_t *u,
	const upload_row_data_t *data)
{
	static gchar tmpstr[256];

	if (u->pos < data->range_start)
		return _("No output yet..."); /* Never wrote anything yet */

    switch (u->status) {
    case GTA_UL_PUSH_RECEIVED:
        return _("Got push, connecting back...");

    case GTA_UL_COMPLETE:
		{
			time_delta_t d = delta_time(data->last_update, data->start_date);
	        filesize_t requested = data->range_end - data->range_start + 1;
			size_t rw;

			rw = str_bprintf(tmpstr, sizeof(tmpstr),
				"%s (%s) %s %s#%u", _("Completed"),
				d > 0 ? short_rate(requested / d, show_metric_units())
						: _("< 1s"),
				d > 0 ? short_time(d) : "",
				u->parq_quick ? _("(quick) ") : "",
				u->reqnum);

			if (u->error_count)
				rw += str_bprintf(&tmpstr[rw], sizeof(tmpstr)-rw,
					_(" E=%u"), u->error_count);
		}
        break;

    case GTA_UL_SENDING:
		{
			/* Time Remaining at the current rate, in seconds  */
			filesize_t tr = (data->range_end + 1 - u->pos) / MAX(1, u->avg_bps);
			gdouble p = uploads_gui_progress(u, data);
			time_t now = tm_time();
			gboolean stalled = delta_time(now, data->last_update) > IO_STALLED;
			gchar pbuf[32];
			size_t rw;

			str_bprintf(pbuf, sizeof pbuf, "%5.02f%% ", p * 100.0);
			rw = str_bprintf(tmpstr, sizeof tmpstr, _("%s(%s) TR: %s %s#%u"),
				p > 1.0 ? pbuf : "",
				stalled ? _("stalled")
					: short_rate(u->bps, show_metric_units()),
				short_time(tr),
				u->parq_quick ? _("(quick) ") : "",
				u->reqnum);

			if (u->error_count)
				rw += str_bprintf(&tmpstr[rw], sizeof(tmpstr)-rw,
					_(" E=%u"), u->error_count);
		}
		break;

    case GTA_UL_HEADERS:
        return _("Waiting for headers...");

    case GTA_UL_EXPECTING:
		if (u->error_count)
			str_bprintf(tmpstr, sizeof(tmpstr),
				_("%s %s#%u E=%u"), _("Waiting for further request..."),
				u->parq_quick ? _("(quick) ") : "", u->reqnum, u->error_count);
		else
			str_bprintf(tmpstr, sizeof(tmpstr),
				"%s %s#%u", _("Waiting for further request..."),
				u->parq_quick ? _("(quick) ") : "", u->reqnum);
		break;

    case GTA_UL_WAITING:
        return _("Reading follow-up request...");

    case GTA_UL_ABORTED:
        return _("Transmission aborted");

    case GTA_UL_CLOSED:
        return _("Transmission complete");

	case GTA_UL_QUEUED:		/* Actively queued */
		{
			guint32 max_up, cur_up;
			gboolean queued;
			guint available = 0;
			gchar tbuf[64];
			size_t rw;

			gnet_prop_get_guint32_val(PROP_MAX_UPLOADS, &max_up);
			gnet_prop_get_guint32_val(PROP_UL_RUNNING, &cur_up);

			if (cur_up < max_up)
				available = max_up - cur_up;

			/*
			 * We'll flag as "Waiting" instead of "Queued" uploads
			 * that are actively queued and whose position is low
			 * enough to possibly get scheduled at the next request,
			 * given the amount of free slots.
			 *		--RAM, 2007-08-21
			 */

			queued = u->parq_position > available;

			if (u->parq_retry > 0) {
				str_bprintf(tbuf, sizeof tbuf,
							" %s,", short_time(u->parq_retry));
			} else {
				tbuf[0] = '\0';
			}

			rw = str_bprintf(tmpstr, sizeof tmpstr,
						_("%s [%d] (slot %d/%d)%s %s %s"),
						u->parq_frozen ? _("Frozen") :
						queued ? _("Queued") : _("Waiting"),
						u->parq_queue_no,
						u->parq_position,
						u->parq_size,
						tbuf,
						_("lifetime:"),
						short_time(u->parq_lifetime));

			if (u->error_count)
				rw += str_bprintf(&tmpstr[rw], sizeof(tmpstr)-rw,
					_(" E=%u"), u->error_count);
		}
		break;

    case GTA_UL_QUEUE:
        /*
         * PARQ wants to inform a client that action from the client its side
         * is wanted. So it is trying to connect back.
         *      -- JA, 15/04/2003
         */
        return _("Sending QUEUE, connecting back...");

    case GTA_UL_QUEUE_WAITING:
        /*
         * PARQ made a connect back because some action from the client is
         * wanted. The connection is established and now waiting for some action
         *      -- JA, 15/04/2003
         */
		return _("Sent QUEUE, waiting for headers...");
	}

    return tmpstr;
}