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

downloads.h File Reference


Detailed Description

Needs brief description here.

Author:
Raphael Manfredi
Date:
2001-2003

#include "lib/header.h"
#include "fileinfo.h"
#include "if/core/downloads.h"
#include "if/core/search.h"

Go to the source code of this file.

Functions

void download_init (void)
 Initialize downloading data structures.

void download_restore_state (void)
 Initialize downloading data structures.

void download_store_if_dirty (void)
 Store pending download if needed.

void download_timer (time_t now)
 Download heartbeat timer.

void download_info_change_all (fileinfo_t *old_fi, fileinfo_t *new_fi)
 Change all the fileinfo of downloads from `old_fi' to `new_fi'.

void download_orphan_new (gchar *file, filesize_t size, gchar *sha1, fileinfo_t *fi)
 Fake a new download for an existing file that is marked complete in its fileinfo trailer.

void download_queue (struct download *d, const gchar *fmt,...) G_GNUC_PRINTF(2
void download_stop (struct download *, guint32, const gchar *,...) G_GNUC_PRINTF(3
void download_stop_v (struct download *d, guint32 new_status, const gchar *reason, va_list ap)
 Vectorized version common to download_stop() and download_unavailable().

void download_push_ack (struct gnutella_socket *)
 Initiate download on the remotely initiated connection.

void download_fallback_to_push (struct download *, gboolean, gboolean)
 Direct download failed, let's try it with a push request.

void download_pickup_queued (void)
 Pick up new downloads from the queue as needed.

void download_forget (struct download *, gboolean unavailable)
 Forget about download: stop it if running.

gboolean download_start_prepare (struct download *d)
 Make download a "running" one (in running list, unqueued), then call download_start_prepare_running().

gboolean download_start_prepare_running (struct download *d)
 Setup the download structure with proper range offset, and check that the download is not otherwise completed.

void download_send_request (struct download *)
 Send the HTTP request for a download, then prepare I/O reading callbacks to read the incoming status line and following headers.

void download_retry (struct download *)
void download_close (void)
 Terminating processing, cleanup data structures.

gboolean download_server_nopush (gchar *guid, const host_addr_t addr, guint16 port)
 Check whether we can safely ignore Push indication for this server, identified by its GUID, IP and port.

void download_free_removed (void)
 Free all downloads listed in the `sl_removed' list.

void download_redirect_to_server (struct download *d, const host_addr_t addr, guint16 port)
 Move download from a server to another when the IP:port changed due to a Location: redirection for instance, or because of a QUEUE callback.

void download_actively_queued (struct download *d, gboolean queued)
 Mark a download as being actively queued.

void download_verify_start (struct download *d)
 Called when the verification daemon task starts processing a download.

void download_verify_progress (struct download *d, guint32 hashed)
 Called to register the current verification progress.

void download_verify_done (struct download *d, gchar *digest, guint elapsed)
 Called when download verification is finished and digest is known.

void download_verify_error (struct download *d)
 Called when we cannot verify the SHA1 for the file (I/O error, etc...).

void download_move_start (struct download *d)
 Called when the moving daemon task starts processing a download.

void download_move_progress (struct download *d, filesize_t copied)
 Called to register the current moving progress.

void download_move_done (struct download *d, guint elapsed)
 Called when file has been moved/renamed with its fileinfo trailer stripped.

void download_move_error (struct download *d)
 Called when we cannot move the file (I/O error, etc...).

guint extract_retry_after (struct download *d, const header_t *header)
 Extract Retry-After delay from header, returning 0 if none.

gboolean is_faked_download (const struct download *d)
downloaddownload_find_waiting_unparq (const host_addr_t addr, guint16 port)
 Find a waiting download on the specified server, identified by its IP:port for which we have no PARQ information yet.

void download_set_socket_rx_size (gint rx_size)
 Change the socket RX buffer size for all the currently connected downloads.

void download_proxy_newstate (struct download *d)
 Called when the status of the HTTP request made by the client push-proxy code changes.

void download_proxy_sent (struct download *d)
 Called by client push-proxy side when we got indication that the PUSH has been sent.

void download_proxy_failed (struct download *d)
 Called by client push-proxy side to indicate that it could not send a PUSH.

downloaddownload_browse_start (const gchar *name, const gchar *hostname, host_addr_t addr, guint16 port, const gchar *guid, gboolean push, const gnet_host_vec_t *proxies, gnet_search_t search)
 Create special non-persisted download that will request "/" on the remote host and expect a stream of Gnutella query hits back.

void download_abort_browse_host (gpointer download, gnet_search_t sh)
 Abort browse-hosst download when corresponding search is closed.

void download_got_eof (struct download *d)
 Called when an EOF is received during data reception.

void download_rx_done (struct download *d)
 Called when all data has been received.

void download_browse_received (struct download *d, ssize_t received)
 Called when more data has been received.

void download_browse_maybe_finished (struct download *d)
 Called when all the received data so far have been processed to check whether we are done.


Variables

GSList * sl_unqueued
 Global Data.


Function Documentation

void download_abort_browse_host gpointer  download,
gnet_search_t  sh
 

Abort browse-hosst download when corresponding search is closed.

void download_actively_queued struct download d,
gboolean  queued
 

Mark a download as being actively queued.

void download_browse_maybe_finished struct download d  ) 
 

Called when all the received data so far have been processed to check whether we are done.

void download_browse_received struct download d,
ssize_t  received
 

Called when more data has been received.

struct download* download_browse_start const gchar *  name,
const gchar *  hostname,
host_addr_t  addr,
guint16  port,
const gchar *  guid,
gboolean  push,
const gnet_host_vec_t proxies,
gnet_search_t  search
 

Create special non-persisted download that will request "/" on the remote host and expect a stream of Gnutella query hits back.

Those query hits will be feed back to the search given as parameter for display.

Parameters:
name the stringified "addr:port" of the host.
hostname the DNS name of the host, or NULL if none known
addr the IP address of the host to browse
port the port to contact
guid the GUID of the remote host
push whether a PUSH request is neeed to reach remote host
proxies vector holding known push-proxies
search the search we have to send back query hits to.
Returns:
created download, or NULL on error.

void download_close void   ) 
 

Terminating processing, cleanup data structures.

void download_fallback_to_push struct download ,
gboolean  ,
gboolean 
 

Direct download failed, let's try it with a push request.

struct download* download_find_waiting_unparq const host_addr_t  addr,
guint16  port
 

Find a waiting download on the specified server, identified by its IP:port for which we have no PARQ information yet.

Returns:
NULL if none, the download we found otherwise.

void download_forget struct download d,
gboolean  unavailable
 

Forget about download: stop it if running.

When `unavailable' is TRUE, mark the download as unavailable.

void download_free_removed void   ) 
 

Free all downloads listed in the `sl_removed' list.

void download_got_eof struct download d  ) 
 

Called when an EOF is received during data reception.

void download_info_change_all fileinfo_t old_fi,
fileinfo_t new_fi
 

Change all the fileinfo of downloads from `old_fi' to `new_fi'.

All running downloads are requeued immediately, since a change means the underlying file we're writing to can change.

void download_init void   ) 
 

Initialize downloading data structures.

void download_move_done struct download d,
guint  elapsed
 

Called when file has been moved/renamed with its fileinfo trailer stripped.

void download_move_error struct download d  ) 
 

Called when we cannot move the file (I/O error, etc...).

void download_move_progress struct download d,
filesize_t  copied
 

Called to register the current moving progress.

void download_move_start struct download d  ) 
 

Called when the moving daemon task starts processing a download.

void download_orphan_new gchar *  file,
filesize_t  size,
gchar *  sha1,
fileinfo_t fi
 

Fake a new download for an existing file that is marked complete in its fileinfo trailer.

void download_pickup_queued void   ) 
 

Pick up new downloads from the queue as needed.

void download_proxy_failed struct download d  ) 
 

Called by client push-proxy side to indicate that it could not send a PUSH.

void download_proxy_newstate struct download d  ) 
 

Called when the status of the HTTP request made by the client push-proxy code changes.

void download_proxy_sent struct download d  ) 
 

Called by client push-proxy side when we got indication that the PUSH has been sent.

void download_push_ack struct gnutella_socket s  ) 
 

Initiate download on the remotely initiated connection.

This is called when an incoming "GIV" request is received in answer to some of our pushes.

void download_queue struct download d,
const gchar *  fmt,
... 
 

void download_redirect_to_server struct download d,
const host_addr_t  addr,
guint16  port
 

Move download from a server to another when the IP:port changed due to a Location: redirection for instance, or because of a QUEUE callback.

void download_restore_state void   ) 
 

Initialize downloading data structures.

void download_retry struct download  ) 
 

void download_rx_done struct download d  ) 
 

Called when all data has been received.

void download_send_request struct download d  ) 
 

Send the HTTP request for a download, then prepare I/O reading callbacks to read the incoming status line and following headers.

Attention:
NB: can stop the download, but does not return anything.

gboolean download_server_nopush gchar *  guid,
const host_addr_t  addr,
guint16  port
 

Check whether we can safely ignore Push indication for this server, identified by its GUID, IP and port.

void download_set_socket_rx_size gint  rx_size  ) 
 

Change the socket RX buffer size for all the currently connected downloads.

gboolean download_start_prepare struct download d  ) 
 

Make download a "running" one (in running list, unqueued), then call download_start_prepare_running().

Returns:
TRUE if we may continue with the download, FALSE if it has been stopped due to a problem.

gboolean download_start_prepare_running struct download d  ) 
 

Setup the download structure with proper range offset, and check that the download is not otherwise completed.

Returns:
TRUE if we may continue with the download, FALSE if it has been stopped due to a problem.

void download_stop struct download ,
guint32  ,
const gchar *  ,
... 
 

void download_stop_v struct download d,
guint32  new_status,
const gchar *  reason,
va_list  ap
 

Vectorized version common to download_stop() and download_unavailable().

void download_store_if_dirty void   ) 
 

Store pending download if needed.

The fileinfo database is also flushed if dirty, but only when the downloads themselves are stored. Since both are linked via SHA1 and name, it's best to try to keep them in sync.

void download_timer time_t  now  ) 
 

Download heartbeat timer.

void download_verify_done struct download d,
gchar *  digest,
guint  elapsed
 

Called when download verification is finished and digest is known.

void download_verify_error struct download d  ) 
 

Called when we cannot verify the SHA1 for the file (I/O error, etc...).

void download_verify_progress struct download d,
guint32  hashed
 

Called to register the current verification progress.

void download_verify_start struct download d  ) 
 

Called when the verification daemon task starts processing a download.

guint extract_retry_after struct download d,
const header_t header
 

Extract Retry-After delay from header, returning 0 if none.

gboolean is_faked_download const struct download d  ) 
 

Returns:
whether download was faked to reparent a complete orphaned file.


Variable Documentation

GSList* sl_unqueued
 

Global Data.


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