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

uploads.h

Go to the documentation of this file.
00001 /*
00002  * $Id: uploads.h,v 1.17 2005/12/11 13:52:51 rmanfredi Exp $
00003  *
00004  * Copyright (c) 2001-2003, Raphael Manfredi, Richard Eckart
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *----------------------------------------------------------------------
00024  */
00025 
00026 #ifndef _if_core_uploads_h_
00027 #define _if_core_uploads_h_
00028 
00029 #include "common.h"
00030 #include "lib/host_addr.h"
00031 
00032 typedef guint32 gnet_upload_t;
00033 
00038 typedef enum {
00039     GTA_UL_PUSH_RECEIVED    = 1,    
00040     GTA_UL_COMPLETE         = 2,    
00041     GTA_UL_SENDING          = 3,    
00042     GTA_UL_HEADERS          = 4,    
00043     GTA_UL_WAITING          = 5,    
00044     GTA_UL_ABORTED          = 6,    
00045     GTA_UL_CLOSED           = 7,    
00046     GTA_UL_QUEUED           = 8,    
00047     GTA_UL_QUEUE            = 9,    
00048     GTA_UL_QUEUE_WAITING    = 10,   
00050     GTA_UL_PFSP_WAITING     = 11    
00051 } upload_stage_t;
00052 
00053 typedef struct gnet_upload_status {
00054     upload_stage_t status;
00055     filesize_t  pos;     
00056     guint32 bps;         
00057     guint32 avg_bps;     
00058     time_t  last_update;
00059 
00060     gboolean parq_quick;
00061     guint   parq_position;
00062     guint   parq_size;
00063     guint32 parq_lifetime;
00064     guint32 parq_retry;
00065     guint   parq_queue_no;
00066 } gnet_upload_status_t;
00067 
00068 typedef struct gnet_upload_info {
00069     gnet_upload_t upload_handle;
00070 
00071     gchar  *name;        
00073     host_addr_t addr;       
00075     filesize_t file_size;   
00076     filesize_t range_start; 
00077     filesize_t range_end;   
00079     time_t  start_date;
00080 
00081     gchar  *user_agent; 
00082     gint   country;     
00083     gboolean push;      
00084     gboolean partial;   
00085     gboolean encrypted; 
00086 } gnet_upload_info_t;
00087 
00088 /*
00089  * State inspection macros.
00090  */
00091 
00092 #define UPLOAD_IS_CONNECTING(u)                     \
00093     (   (u)->status == GTA_UL_HEADERS               \
00094     ||  (u)->status == GTA_UL_PUSH_RECEIVED         \
00095     ||  (u)->status == GTA_UL_QUEUE                 \
00096     ||  (u)->status == GTA_UL_QUEUE_WAITING         \
00097     ||  (u)->status == GTA_UL_PFSP_WAITING          \
00098     ||  (u)->status == GTA_UL_WAITING   )
00099 
00100 #define UPLOAD_IS_COMPLETE(u)   \
00101     ((u)->status == GTA_UL_COMPLETE)
00102 
00103 #define UPLOAD_IS_SENDING(u)    \
00104     ((u)->status == GTA_UL_SENDING)
00105 
00106 
00107 struct ul_stats {
00108     gchar  *filename;
00109     filesize_t size;
00110     guint32 attempts;
00111     guint32 complete;
00112     guint64 bytes_sent;
00113     gfloat  norm;       
00114 };
00115 
00116 /*
00117  * Uploads callback definitions
00118  */
00119 typedef void (*upload_added_listener_t) (
00120     gnet_upload_t, guint32, guint32);
00121 typedef void (*upload_removed_listener_t) (
00122     gnet_upload_t, const gchar *, guint32, guint32);
00123 typedef void (*upload_info_changed_listener_t) (
00124     gnet_upload_t, guint32, guint32);
00125 
00126 #define upload_add_listener(signal, callback) \
00127     CAT3(upload_add_,signal,_listener)(callback);
00128 
00129 #define upload_remove_listener(signal, callback) \
00130     CAT3(upload_remove_,signal,_listener)(callback);
00131 
00132 /*
00133  * Public interface, visible from the bridge.
00134  */
00135 
00136 #ifdef CORE_SOURCES
00137 
00138 gnet_upload_info_t *upload_get_info(gnet_upload_t uh);
00139 void upload_free_info(gnet_upload_info_t *info);
00140 void upload_get_status(gnet_upload_t uh, gnet_upload_status_t *si);
00141 void upload_kill_addr(const host_addr_t addr);
00142 void upload_add_upload_added_listener(upload_added_listener_t l);
00143 void upload_remove_upload_added_listener(upload_added_listener_t l);
00144 void upload_add_upload_removed_listener(upload_removed_listener_t l);
00145 void upload_remove_upload_removed_listener(upload_removed_listener_t l);
00146 void upload_add_upload_info_changed_listener(
00147     upload_info_changed_listener_t l);
00148 void upload_remove_upload_info_changed_listener(
00149     upload_info_changed_listener_t l);
00150 void upload_kill(gnet_upload_t upload);
00151 void upload_stats_prune_nonexistent(void);
00152 
00153 #endif /* CORE_SOURCES */
00154 #endif /* _if_core_uploads_h_ */
00155 
00156 /* vi: set ts=4 sw=4 cindent: */

Generated on Sun Feb 12 10:49:58 2006 for Gtk-Gnutella by doxygen 1.3.6