2
* $Id: fileinfo.h,v 1.12 2005/06/25 01:37:42 daichik Exp $
4
* Copyright (c) 2001-2003, Raphael Manfredi, Richard Eckart
6
*----------------------------------------------------------------------
7
* This file is part of gtk-gnutella.
9
* gtk-gnutella is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* gtk-gnutella is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with gtk-gnutella; if not, write to the Free Software
22
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
*----------------------------------------------------------------------
26
#ifndef _if_core_fileinfo_h_
27
#define _if_core_fileinfo_h_
31
#include "if/core/downloads.h" /* For gnet_srt_t */
37
* These used to be in fileinfo.h, but we need them now at several places.
39
enum dl_chunk_status {
45
typedef guint32 gnet_fi_t;
47
typedef struct gnet_fi_info {
49
gchar *path; /**< Path of the directory of the file on disk */
50
gchar *file_name; /**< Name of the file on disk */
51
gchar *sha1; /**< SHA1 (binary) of the file or NULL */
52
GSList *aliases; /**< List of aliases (NULL if none) */
55
typedef struct gnet_fi_status {
61
guint32 recv_last_rate;
62
guint32 aqueued_count;
63
guint32 pqueued_count;
66
typedef struct gnet_fi_chunks {
69
enum dl_chunk_status status;
74
gnet_fi_t fi_handle; /**< Handle */
76
guint32 flags; /**< Operating flags */
77
gchar *file_name; /**< Output file name (atom) */
78
gchar *path; /**< Output file path (atom) */
79
GSList *alias; /**< List of file name aliases (atoms) */
80
filesize_t size; /**< File size */
81
guint64 *size_atom; /**< File size (atom -- points to value in memory) */
82
gchar *sha1; /**< server SHA1 (atom) if known, NULL if not. */
83
gchar *cha1; /**< computed SHA1 (atom) if known, NULL if not. */
84
gint32 refcount; /**< Reference count of file (number of sources)*/
85
GSList *sources; /**< list of sources (struct download *) */
86
gint32 lifecount; /**< Amount of "alive" downloads referencing us */
87
time_t stamp; /**< Time stamp */
88
time_t ctime; /**< Creation time stamp */
89
time_t ntime; /**< Last time a new source was added */
90
time_t last_flush; /**< When last flush to disk occurred */
91
time_t last_dmesh; /**< When last dmesh query was used */
92
filesize_t done; /**< Total number of bytes completed */
93
GSList *chunklist; /**< List of ranges within file */
94
GSList *seen_on_network; /**< List of ranges available on network */
95
guint32 generation; /**< Generation number, incremented on disk update */
96
struct shared_file *sf; /**< When PFSP-server is enabled, share this file */
97
gboolean file_size_known; /**< File size known? */
98
gboolean use_swarming; /**< Use swarming? */
99
gboolean dirty; /**< Does it need saving? */
100
gboolean dirty_status; /**< Notify about status change on next interval */
101
gboolean hashed; /**< In hash tables? */
102
guint32 aqueued_count; /**< Actively queued sources */
103
guint32 pqueued_count; /**< Passively queued sources */
107
* The following group is used to compute the aggregated reception rate.
110
gint32 recvcount; /**< Amount of "receiving" downloads referencing us */
111
guint32 recv_last_rate; /**< Last amount of bytes/sec received */
112
guint32 recv_amount; /**< Amount of bytes received this period */
113
time_t recv_last_time; /**< When did we last compute recv_last_rate? */
116
* This group of fields is used by the background SHA1 and moving daemons.
119
guint cha1_elapsed; /**< Time spent to compute the SHA1 */
120
filesize_t cha1_hashed; /**< Amount of bytes hashed so far */
121
guint copy_elapsed; /**< Time spent to copy the file */
122
filesize_t copied; /**< Amount of bytes copied so far */
125
#define FILE_INFO_COMPLETE(x) ((x)->done == (x)->size && (x)->file_size_known)
127
typedef void (*fi_listener_t) (gnet_fi_t);
128
typedef void (*fi_src_listener_t) (gnet_fi_t, gnet_src_t);
131
EV_FI_ADDED = 0, /**< fi_listener */
132
EV_FI_REMOVED, /**< fi_listener */
133
EV_FI_INFO_CHANGED, /**< fi_listener */
134
EV_FI_STATUS_CHANGED, /**< fi_listener */
135
EV_FI_STATUS_CHANGED_TRANSIENT, /**< fi_listener */
136
EV_FI_SRC_ADDED, /**< fi_src_listener */
137
EV_FI_SRC_REMOVED, /**< fi_src_listener */
138
EV_FI_RANGES_CHANGED, /**< fi_listener */
140
EV_FI_EVENTS /**< Number of events in this domain */
144
* Public interface, visible only from the bridge.
149
void fi_add_listener(fi_listener_t, gnet_fi_ev_t, frequency_t, guint32);
150
void fi_remove_listener(fi_listener_t, gnet_fi_ev_t);
152
gnet_fi_info_t *fi_get_info(gnet_fi_t);
153
void fi_free_info(gnet_fi_info_t *);
154
void fi_get_status(gnet_fi_t, gnet_fi_status_t *);
155
GSList *fi_get_chunks(gnet_fi_t);
156
void fi_free_chunks(GSList *chunks);
157
GSList *fi_get_ranges(gnet_fi_t);
158
void fi_free_ranges(GSList *ranges);
159
gchar **fi_get_aliases(gnet_fi_t fih);
161
void fi_purge_by_handle_list(GSList *list);
162
gboolean fi_purge(gnet_fi_t fih);
164
const gchar *file_info_readable_filename(const struct dl_file_info *fi);
166
#endif /* CORE_SOURCES */
167
#endif /* _if_core_fileinfo_h_ */
169
/* vi: set ts=4 sw=4 cindent: */