Code Search for Developers
 
 
  

bitzi.c from Gtk-Gnutella at Krugle


Show bitzi.c syntax highlighted

/*
 * $Id: bitzi.c 14457 2007-08-14 04:23:12Z cbiere $
 *
 * Copyright (c) 2004, Alex Bennee <alex@bennee.com>
 *
 *----------------------------------------------------------------------
 * This file is part of gtk-gnutella.
 *
 *  gtk-gnutella is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  gtk-gnutella is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with gtk-gnutella; if not, write to the Free Software
 *  Foundation, Inc.:
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *----------------------------------------------------------------------
 */

/**
 * @ingroup gtk
 * @file
 *
 * Bitzi GTK+ interface code.
 *
 * @author Alex Bennee <alex@bennee.com>
 * @date 2004
 */

#include "gtk/gui.h"

RCSID("$Id: bitzi.c 14457 2007-08-14 04:23:12Z cbiere $")

#include "gtk/search.h"
#include "gtk/misc.h"			/* gui_record_sha1_eq() */

#include "if/gnet_property.h"
#include "if/bridge/ui2c.h"
#include "if/core/bitzi.h"    	/* bitzi_data_t */

#include "lib/override.h"		/* Must be the last header included */

/**
 * This table should match the encoding one in 'core/bitzi.c'.
 *
 * It assumes the enum's are in order.
 */

static const gchar * const bitzi_fj_table[] = {
	N_("Bitzi|Unknown"),				/**< UNKNOWN */
	N_("Bitzi|Bitzi lookup failure"),	/**< FAILURE */
	N_("Bitzi|Filesize mismatch"),		/**< WRONG_FILESIZE */
	N_("Bitzi|Dangerous/Misleading"),	/**< DANGEROUS_MISLEADING */
	N_("Bitzi|Incomplete/Damaged"),		/**< INCOMPLETE_DAMAGED */
	N_("Bitzi|Substandard"),			/**< SUBSTANDARD */
	N_("Bitzi|Overrated"),				/**< OVERRATED */
	N_("Bitzi|Normal"),					/**< NORMAL */
	N_("Bitzi|Underrated"),				/**< UNDERRATED */
	N_("Bitzi|Complete"),				/**< COMPLETE */
	N_("Bitzi|Recommended"),			/**< RECOMMENDED */
	N_("Bitzi|Best Version"),			/**< BEST_VERSION*/
};

const gchar *
bitzi_fj_to_string(bitzi_fj_t fj)
{
	STATIC_ASSERT(NUM_BITZI_FJ == G_N_ELEMENTS(bitzi_fj_table));
	g_assert(UNSIGNED(fj) < G_N_ELEMENTS(bitzi_fj_table));
	return Q_(bitzi_fj_table[UNSIGNED(fj)]);
}

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)
    	g_message("bitzi_gui_update: data %p, size %s\n"
			  "goodness %f, judgement %d, type %s, details %s",
			cast_to_gconstpointer(bitzi_data),
			uint64_to_string(bitzi_data->size),
			bitzi_data->goodness,
			bitzi_data->judgement,
			NULL_STRING(bitzi_data->mime_type),
			NULL_STRING(bitzi_data->mime_desc));

	/* Update the various GUI elements */

	search_gui_metadata_update(bitzi_data);
}

gchar *
bitzi_gui_get_metadata(const bitzi_data_t *data)
{
	g_assert(data != NULL);

	/*
	 * Build string
	 */

	if (
		data->judgement == BITZI_FJ_FAILURE ||
		data->judgement == BITZI_FJ_WRONG_FILESIZE
	) {
		return g_strdup(bitzi_fj_to_string(data->judgement));
	} else if (data->mime_type) {
		if (data->mime_desc) {
			return g_strdup_printf("%s (%1.1f): %s (%s)",
					bitzi_fj_to_string(data->judgement),
					data->goodness,
					data->mime_type,
					data->mime_desc);
		} else {
			return g_strdup_printf("%s (%1.1f): %s",
					bitzi_fj_to_string(data->judgement),
					data->goodness,
					data->mime_type);
		}
	} else if (data->judgement != BITZI_FJ_UNKNOWN) {
		return g_strdup_printf("%s (%1.1f): %s",
				bitzi_fj_to_string(data->judgement),
				data->goodness,
				_("No other data"));
	}

	return NULL;
}

/* -*- mode: cc-mode; tab-width:4; -*- */
/* vi: set ts=4 sw=4 cindent: */




See more files for this project here

Gtk-Gnutella

A GTK+ Gnutella client for Unix, efficient, reliable and fast, written in C. It has been optimized for speed and scalability, with low-memory consumption. It is meant to be left running 24x7, using little CPU and only the configured bandwidth.

Project homepage: http://sourceforge.net/projects/gtk-gnutella
Programming language(s): C
License: other

  gtk-shared/
    callbacks.c
    callbacks.h
  gtk1/
    Jmakefile
    Makefile.SH
    downloads.c
    downloads_cb.c
    downloads_cb.h
    fileinfo.c
    gnet_stats.c
    gtk-gnutella.glade
    hcache.c
    interface-glade.c
    interface-glade.h
    interface-glade.t
    monitor.c
    monitor_cb.c
    nodes.c
    nodes_cb.c
    nodes_cb.h
    search.c
    search_cb.c
    search_cb.h
    search_stats.c
    support-glade.c
    support-glade.h
    upload_stats.c
    uploads.c
  gtk2/
    Jmakefile
    Makefile.SH
    downloads.c
    downloads_cb.c
    downloads_cb.h
    fileinfo.c
    gnet_stats.c
    gtk-gnutella.glade
    gtk-gnutella.gladep
    hcache.c
    interface-glade.c
  Jmakefile
  Makefile.SH
  bitzi.c
  bitzi.h
  clipboard.c
  clipboard.h
  columns.h
  downloads.h
  downloads_common.c
  downloads_common.h
  drag.c
  drag.h
  drop.c
  drop.h
  fileinfo.h
  filter.c
  filter.h
  filter_cb.c
  filter_cb.h
  filter_core.c
  filter_core.h
  gnet_stats.h
  gnet_stats_common.c
  gnet_stats_common.h
  gtk-missing.c
  gtk-missing.h
  gtkcolumnchooser.c
  gtkcolumnchooser.h
  gui.h
  hcache.h
  hcache_common.c
  hcache_common.h
  html_view.c
  html_view.h
  icon.c
  icon.h
  main.c
  main.h
  main_cb.c
  main_cb.h
  misc.c
  misc.h
  monitor.h
  monitor_cb.h
  nodes.h
  nodes_common.c
  nodes_common.h
  notebooks.h
  search.h
  search_common.c
  search_common.h
  search_result.h
  search_stats.h
  search_xml.c
  search_xml.h
  settings.c
  settings.h
  settings_cb.c
  settings_cb.h
  statusbar.c
  statusbar.h
  upload_stats.h
  upload_stats_cb.c
  upload_stats_cb.h
  uploads.h
  uploads_cb.c
  uploads_cb.h
  uploads_common.c
  uploads_common.h
  visual_progress.c
  visual_progress.h