00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00039 #ifndef _core_uploads_h_
00040 #define _core_uploads_h_
00041
00042 #include "common.h"
00043 #include "bsched.h"
00044 #include "bh_upload.h"
00045
00046 #include "if/core/uploads.h"
00047
00048 struct gnutella_node;
00049 struct dl_file_info;
00050
00051 typedef struct upload {
00052 gnet_upload_t upload_handle;
00053 guint32 flags;
00054 upload_stage_t status;
00055 struct gnutella_socket *socket;
00056 gint error_sent;
00057 gpointer io_opaque;
00058 gpointer parq_opaque;
00060 gint file_desc;
00061 bio_source_t *bio;
00062 sendfile_ctx_t sendfile_ctx;
00063 struct special_ctx *special;
00065 gchar *buffer;
00066 gint bpos;
00067 gint bsize;
00068 gint buf_size;
00069
00070 guint index;
00071 gchar *name;
00072 filesize_t file_size;
00073
00074 time_t start_date;
00075 time_t last_update;
00076
00077 struct dl_file_info *file_info;
00079 host_addr_t addr;
00080 gchar *user_agent;
00081 gint country;
00082 filesize_t skip;
00083 filesize_t end;
00084 filesize_t pos;
00085 filesize_t sent;
00087 host_addr_t gnet_addr;
00088 guint16 gnet_port;
00090 guint32 last_dmesh;
00091 gchar *sha1;
00092 filesize_t total_requested;
00093 gint http_major;
00094 gint http_minor;
00096 gboolean keep_alive;
00097 gboolean push;
00098 gboolean queue;
00099 gboolean accounted;
00100 gboolean unavailable_range;
00101 gboolean n2r;
00102 gboolean browse_host;
00103 gboolean from_browser;
00105 gboolean parq_status;
00106 } gnutella_upload_t;
00107
00108 #define upload_vendor_str(u) ((u)->user_agent ? (u)->user_agent : "")
00109
00110
00111
00112
00113
00114 #define UPLOAD_F_STALLED 0x00000001
00115 #define UPLOAD_F_EARLY_STALL 0x00000002
00120 struct upload_http_cb {
00121 gnutella_upload_t *u;
00122 time_t now;
00123 time_t mtime;
00124 struct shared_file *sf;
00125 };
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 gboolean upload_is_enabled(void);
00136 void upload_timer(time_t now);
00137 void upload_remove(struct upload *, const gchar *, ...) G_GNUC_PRINTF(2, 3);
00138 void handle_push_request(struct gnutella_node *);
00139 void upload_add(struct gnutella_socket *s);
00140 void upload_connect_conf(struct upload *u);
00141 void upload_init(void);
00142 void upload_close(void);
00143 void upload_stop_all(struct dl_file_info *fi, const gchar *reason);
00144 void upload_send_giv(const host_addr_t addr, guint16 port, guint8 hops,
00145 guint8 ttl, guint32 file_index, const gchar *file_name,
00146 gboolean banning, guint32 flags);
00147 gnutella_upload_t *upload_create(struct gnutella_socket *s, gboolean push);
00148 void upload_fire_upload_info_changed(gnutella_upload_t *n);
00149 void expect_http_header(gnutella_upload_t *u, upload_stage_t new_status);
00150
00151 #endif
00152
00153