Compensate for pipeline buffering in upload presentation.
[doldaconnect.git] / daemon / transfer.h
CommitLineData
d3372da9 1/*
2 * Dolda Connect - Modular multiuser Direct Connect-style client
302a2600 3 * Copyright (C) 2004 Fredrik Tolf <fredrik@dolda2000.com>
d3372da9 4 *
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.
9 *
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.
14 *
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
18*/
19#ifndef _TRANSFER_H
20#define _TRANSFER_H
21
22#include <wchar.h>
23#include <sys/types.h>
24
25#include "net.h"
26#include "filenet.h"
27#include "utils.h"
28#include "auth.h"
29
30#define TRNS_WAITING 0
31#define TRNS_HS 1
32#define TRNS_MAIN 2
33#define TRNS_DONE 3
34
35#define TRNSD_UNKNOWN 0
36#define TRNSD_UP 1
37#define TRNSD_DOWN 2
38
39#define TRNSE_NOERROR 0
40#define TRNSE_NOTFOUND 1
41#define TRNSE_NOSLOTS 2
42
d3372da9 43struct transfer
44{
45 struct transfer *next, *prev;
46 int id, close;
47 union
48 {
49 int w;
50 struct
51 {
52 int byop:1;
53 int sgranted:1;
54 int minislot:1;
55 } b;
56 } flags;
57 struct timer *etimer;
58 time_t timeout, activity, lastreq;
59 wchar_t *actdesc;
60 struct fnet *fnet;
d3372da9 61 wchar_t *peerid, *peernick;
62 wchar_t *path;
63 uid_t owner;
64 int state, dir, error;
284e199a 65 off_t size, curpos, endpos, localpos;
d3372da9 66 struct fnetnode *fn;
705b7486 67 struct socket *localend, *datapipe;
9ec790e8 68 struct wcspair *args;
d3372da9 69 pid_t filter;
70 struct authhandle *auth;
71 struct socket *filterout;
72 char *filterbuf;
8a87f29d 73 struct hash *hash;
d3372da9 74 size_t filterbufsize, filterbufdata;
70628d22 75 wchar_t *exitstatus;
d3372da9 76 CBCHAIN(trans_ac, struct transfer *transfer, wchar_t *attrib);
77 CBCHAIN(trans_p, struct transfer *transfer);
78 CBCHAIN(trans_act, struct transfer *transfer);
79 CBCHAIN(trans_destroy, struct transfer *transfer);
80 CBCHAIN(trans_filterout, struct transfer *transfer, wchar_t *cmd, wchar_t *arg);
81};
82
83void freetransfer(struct transfer *transfer);
84struct transfer *newtransfer(void);
85void linktransfer(struct transfer *transfer);
86int slotsleft(void);
87void bumptransfer(struct transfer *transfer);
88struct transfer *findtransfer(int id);
6e37d33d 89struct transfer *hasupload(struct fnet *fnet, wchar_t *peerid);
705b7486 90struct transfer *newupload(struct fnetnode *fn, struct fnet *fnet, wchar_t *nickid, struct socket *dpipe);
d3372da9 91void transfersetnick(struct transfer *transfer, wchar_t *newnick);
92void transfersetpath(struct transfer *transfer, wchar_t *newpath);
93void transfersetstate(struct transfer *transfer, int newstate);
dcf7a1a2 94void transfersetsize(struct transfer *transfer, off_t newsize);
d3372da9 95void transferseterror(struct transfer *transfer, int error);
96void transfersetactivity(struct transfer *transfer, wchar_t *desc);
705b7486 97void transferattach(struct transfer *transfer, struct socket *dpipe);
d3372da9 98void transferdetach(struct transfer *transfer);
99void resettransfer(struct transfer *transfer);
100void transfersetlocalend(struct transfer *transfer, struct socket *sk);
d3372da9 101int forkfilter(struct transfer *transfer);
dcf7a1a2 102void transferprepul(struct transfer *transfer, off_t size, off_t start, off_t end, struct socket *lesk);
d3372da9 103void transferstartul(struct transfer *transfer, struct socket *sk);
668d96ab 104void transfersethash(struct transfer *transfer, struct hash *hash);
105struct transfer *finddownload(wchar_t *peerid);
106void transferstartdl(struct transfer *transfer, struct socket *sk);
b218e88e 107void trytransferbypeer(struct fnet *fnet, wchar_t *peerid);
d3372da9 108
109extern struct transfer *transfers;
d5aa6bdc 110extern unsigned long long bytesupload;
111extern unsigned long long bytesdownload;
d3372da9 112EGCBCHAIN(newtransfercb, struct transfer *);
113
114#endif