2 * Dolda Connect - Modular multiuser Direct Connect-style client
3 * Copyright (C) 2004 Fredrik Tolf <fredrik@dolda2000.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <sys/types.h>
30 #define TRNS_WAITING 0
35 #define TRNSD_UNKNOWN 0
39 #define TRNSE_NOERROR 0
40 #define TRNSE_NOTFOUND 1
41 #define TRNSE_NOSLOTS 2
47 void (*detach)(struct transfer *transfer, void *data);
48 void (*gotdata)(struct transfer *transfer, void *data);
49 void (*endofdata)(struct transfer *transfer, void *data);
50 void (*wantdata)(struct transfer *transfer, void *data);
55 struct transfer *next, *prev;
68 time_t timeout, activity, lastreq;
71 struct transferiface *iface;
72 wchar_t *peerid, *peernick;
75 int state, dir, error;
76 size_t size, curpos, endpos;
79 struct socket *localend;
82 struct authhandle *auth;
83 struct socket *filterout;
86 size_t filterbufsize, filterbufdata;
88 CBCHAIN(trans_ac, struct transfer *transfer, wchar_t *attrib);
89 CBCHAIN(trans_p, struct transfer *transfer);
90 CBCHAIN(trans_act, struct transfer *transfer);
91 CBCHAIN(trans_destroy, struct transfer *transfer);
92 CBCHAIN(trans_filterout, struct transfer *transfer, wchar_t *cmd, wchar_t *arg);
95 void freetransfer(struct transfer *transfer);
96 struct transfer *newtransfer(void);
97 void linktransfer(struct transfer *transfer);
99 void bumptransfer(struct transfer *transfer);
100 struct transfer *findtransfer(int id);
101 struct transfer *hasupload(struct fnet *fnet, wchar_t *peerid);
102 struct transfer *newupload(struct fnetnode *fn, struct fnet *fnet, wchar_t *nickid, struct transferiface *iface, void *data);
103 void transfersetnick(struct transfer *transfer, wchar_t *newnick);
104 void transfersetpath(struct transfer *transfer, wchar_t *newpath);
105 void transfersetstate(struct transfer *transfer, int newstate);
106 void transfersetsize(struct transfer *transfer, int newsize);
107 void transferseterror(struct transfer *transfer, int error);
108 void transfersetactivity(struct transfer *transfer, wchar_t *desc);
109 void transferattach(struct transfer *transfer, struct transferiface *iface, void *data);
110 void transferdetach(struct transfer *transfer);
111 void resettransfer(struct transfer *transfer);
112 void transfersetlocalend(struct transfer *transfer, struct socket *sk);
113 void *transfergetdata(struct transfer *transfer, size_t *size);
114 int forkfilter(struct transfer *transfer);
115 void transferputdata(struct transfer *transfer, void *buf, size_t size);
116 size_t transferdatasize(struct transfer *transfer);
117 void transferendofdata(struct transfer *transfer);
118 void transferprepul(struct transfer *transfer, size_t size, size_t start, size_t end, struct socket *lesk);
119 void transferstartul(struct transfer *transfer, struct socket *sk);
120 void transfersethash(struct transfer *transfer, struct hash *hash);
121 struct transfer *finddownload(wchar_t *peerid);
122 void transferstartdl(struct transfer *transfer, struct socket *sk);
123 void trytransferbypeer(struct fnet *fnet, wchar_t *peerid);
125 extern struct transfer *transfers;
126 extern unsigned long long bytesupload;
127 extern unsigned long long bytesdownload;
128 EGCBCHAIN(newtransfercb, struct transfer *);