Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

downloads.c File Reference

#include "gtk/gui.h"
#include "gtk/downloads.h"
#include "gtk/downloads_common.h"
#include "downloads_cb.h"
#include "gtk/statusbar.h"
#include "gtk/columns.h"
#include "gtk/notebooks.h"
#include "if/core/pproxy.h"
#include "if/core/bsched.h"
#include "if/bridge/ui2c.h"
#include "lib/atoms.h"
#include "lib/glib-missing.h"
#include "lib/tm.h"
#include "lib/utf8.h"
#include "lib/override.h"

Defines

#define IO_STALLED   60 /**< If nothing exchanged after that many secs */
 If nothing exchanged after that many secs.

#define DL_GUI_TREE_SPACE   5 /**< Space between a child node and a parent */
 Space between a child node and a parent.

#define DL_VISIBLE_MAX   MAX(DOWNLOADS_VISIBLE_COLUMNS, DOWNLOAD_QUEUE_VISIBLE_COLUMNS)

Functions

 RCSID ("$Id:downloads.c, v 1.31 2006/02/04 21:32:37 rmanfredi Exp $")
const gchar * download_progress_to_string (const struct download *d)
const gchar * source_progress_to_string (const struct download *d)
void add_parent_with_fi_handle (GHashTable *ht, gpointer key, GtkCTreeNode *data)
 Add the given tree node to the hashtable.

void remove_parent_with_fi_handle (GHashTable *ht, const gnet_fi_t fi_handle)
 Removes the treenode matching the given fi_handle from the hash table and frees the original key used to store it.

GtkCTreeNode * find_parent_with_fi_handle (GHashTable *ht, gpointer key)
void record_parent_gui_update (gpointer key, time_t when)
 Remember when we did the last GUI update of the parent.

time_t get_last_parent_gui_update (gpointer key)
gboolean parent_gui_needs_update (struct download *d, time_t now)
gint parent_children_add (GtkCTree *ctree, gpointer key, gint x)
 Add (arithmetically) `x' to the amount of children of the parent, identified by its fileifo hande.

GList * downloads_gui_collect_ctree_data (GtkCTree *ctree, GList *node_list, gboolean unselect, gboolean add_children)
 Given a GList of GtkCTreeNodes, return a new list pointing to the row data If unselect is TRUE, unselect all nodes in the list If children is TRUE, check and strip out header nodes.

gboolean downloads_gui_any_status (struct download *d, download_status_t status)
gboolean downloads_gui_all_aborted (struct download *d)
gboolean downloads_gui_update_parent_status (struct download *d, time_t now, gchar *new_status)
 Finds parent of given download in the active download tree and changes the status column to the given string.

void downloads_gui_init (void)
 Initialize local data structures.

void downloads_gui_shutdown (void)
 Cleanup local data structures.

void download_gui_add (struct download *d)
 Adds a download to the gui.

void gui_update_download_server (struct download *d)
void gui_update_download_range (struct download *d)
void gui_update_download_size (struct download *d)
void gui_update_download_host (struct download *d)
void gui_update_download (struct download *d, gboolean force)
void gui_update_download_abort_resume (void)
void download_gui_remove (struct download *d)
 Remove a download from the GUI.

void downloads_gui_expand_all (GtkCTree *ctree)
 Collapse all nodes in given, tree either downloads or downloads_queue.

void downloads_gui_collapse_all (GtkCTree *ctree)
 Collapse all nodes in given, tree either downloads or downloads_queue.

void downloads_update_active_pane (void)
 Update "active" pane if needed.

void downloads_update_queue_pane (void)
 Update "queue" pane if needed.

void downloads_gui_update_display (time_t unused_now)
 Periodically called to update downloads display.


Variables

gchar tmpstr [4096]
GHashTable * parents
 table of parent download iterators

GHashTable * parents_queue
 table of parent queued dl iterators

GHashTable * parents_gui_time
 Time at which parent was updated.

GHashTable * parents_children
GHashTable * parents_queue_children
GtkCTree * ctree_downloads = NULL
GtkCTree * ctree_downloads_queue = NULL
GtkNotebook * notebook = NULL
gboolean ctree_downloads_frozen = FALSE
gboolean ctree_downloads_queue_frozen = FALSE


Define Documentation

#define DL_GUI_TREE_SPACE   5 /**< Space between a child node and a parent */
 

Space between a child node and a parent.

#define DL_VISIBLE_MAX   MAX(DOWNLOADS_VISIBLE_COLUMNS, DOWNLOAD_QUEUE_VISIBLE_COLUMNS)
 

#define IO_STALLED   60 /**< If nothing exchanged after that many secs */
 

If nothing exchanged after that many secs.


Function Documentation

void add_parent_with_fi_handle GHashTable *  ht,
gpointer  key,
GtkCTreeNode *  data
[inline, static]
 

Add the given tree node to the hashtable.

The key is an int ref on the fi_handle for a given download.

void download_gui_add struct download d  ) 
 

Adds a download to the gui.

All parenting (grouping) is done here

void download_gui_remove struct download d  ) 
 

Remove a download from the GUI.

const gchar* download_progress_to_string const struct download d  )  [inline, static]
 

gboolean downloads_gui_all_aborted struct download d  ) 
 

Returns:
true if all the active downloads in the same tree as the given download are aborted (status is GTA_DL_ABORTED or GTA_DL_ERROR).

gboolean downloads_gui_any_status struct download d,
download_status_t  status
[static]
 

Returns:
true if any of the active downloads in the same tree as the given download are in the specified status.

void downloads_gui_collapse_all GtkCTree *  ctree  ) 
 

Collapse all nodes in given, tree either downloads or downloads_queue.

GList* downloads_gui_collect_ctree_data GtkCTree *  ctree,
GList *  node_list,
gboolean  unselect,
gboolean  add_children
 

Given a GList of GtkCTreeNodes, return a new list pointing to the row data If unselect is TRUE, unselect all nodes in the list If children is TRUE, check and strip out header nodes.

Instead of adding the headers, add all of their children. List will have to be freed later on.

FIXME: Worst case approaches O(n*n) ensuring no duplicate children are added FIXME: There are a lot of glist "appends" in here => unneccesary O(n)

void downloads_gui_expand_all GtkCTree *  ctree  ) 
 

Collapse all nodes in given, tree either downloads or downloads_queue.

void downloads_gui_init void   ) 
 

Initialize local data structures.

void downloads_gui_shutdown void   ) 
 

Cleanup local data structures.

void downloads_gui_update_display time_t  unused_now  ) 
 

Periodically called to update downloads display.

gboolean downloads_gui_update_parent_status struct download d,
time_t  now,
gchar *  new_status
 

Finds parent of given download in the active download tree and changes the status column to the given string.

Returns true if status is changed.

void downloads_update_active_pane void   ) 
 

Update "active" pane if needed.

void downloads_update_queue_pane void   ) 
 

Update "queue" pane if needed.

GtkCTreeNode* find_parent_with_fi_handle GHashTable *  ht,
gpointer  key
[inline, static]
 

Returns:
the tree iterator corresponding to the given key, an atomized fi_handle.

time_t get_last_parent_gui_update gpointer  key  )  [inline, static]
 

Returns:
the last time we updated the GUI of the parent.

void gui_update_download struct download d,
gboolean  force
 

void gui_update_download_abort_resume void   ) 
 

void gui_update_download_host struct download d  ) 
 

void gui_update_download_range struct download d  ) 
 

void gui_update_download_server struct download d  ) 
 

void gui_update_download_size struct download d  ) 
 

gint parent_children_add GtkCTree *  ctree,
gpointer  key,
gint  x
[static]
 

Add (arithmetically) `x' to the amount of children of the parent, identified by its fileifo hande.

The `ctree' is used to determine whether we're managing a parent from the active downlods or the queue downlaods.

Returns:
the new amount of children (use x=0 to get the current count).

gboolean parent_gui_needs_update struct download d,
time_t  now
[inline, static]
 

Returns:
whether the parent of download `d', if any, needs a GUI update.

RCSID "$Id:downloads.  c,
v 1.31 2006/02/04 21:32:37 rmanfredi Exp $" 
 

void record_parent_gui_update gpointer  key,
time_t  when
[inline, static]
 

Remember when we did the last GUI update of the parent.

void remove_parent_with_fi_handle GHashTable *  ht,
const gnet_fi_t  fi_handle
[inline, static]
 

Removes the treenode matching the given fi_handle from the hash table and frees the original key used to store it.

const gchar* source_progress_to_string const struct download d  )  [inline, static]
 


Variable Documentation

GtkCTree* ctree_downloads = NULL [static]
 

gboolean ctree_downloads_frozen = FALSE [static]
 

GtkCTree* ctree_downloads_queue = NULL [static]
 

gboolean ctree_downloads_queue_frozen = FALSE [static]
 

GtkNotebook* notebook = NULL [static]
 

GHashTable* parents [static]
 

table of parent download iterators

GHashTable* parents_children [static]
 

GHashTable* parents_gui_time [static]
 

Time at which parent was updated.

GHashTable* parents_queue [static]
 

table of parent queued dl iterators

GHashTable* parents_queue_children [static]
 

gchar tmpstr[4096] [static]
 


Generated on Sun Feb 12 10:50:00 2006 for Gtk-Gnutella by doxygen 1.3.6