Try to hide join/leave messages.
[doldaconnect.git] / daemon / transfer.h
CommitLineData
d3372da9 1/*
2 * Dolda Connect - Modular multiuser Direct Connect-style client
3 * Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com)
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
43struct transfer;
44
45struct transferiface
46{
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);
51};
52
d3372da9 53struct transfer
54{
55 struct transfer *next, *prev;
56 int id, close;
57 union
58 {
59 int w;
60 struct
61 {
62 int byop:1;
63 int sgranted:1;
64 int minislot:1;
65 } b;
66 } flags;
67 struct timer *etimer;
68 time_t timeout, activity, lastreq;
69 wchar_t *actdesc;
70 struct fnet *fnet;
71 struct transferiface *iface;
72 wchar_t *peerid, *peernick;
73 wchar_t *path;
74 uid_t owner;
75 int state, dir, error;
76 size_t size, curpos, endpos;
77 struct fnetnode *fn;
78 void *ifacedata;
79 struct socket *localend;
9ec790e8 80 struct wcspair *args;
d3372da9 81 pid_t filter;
82 struct authhandle *auth;
83 struct socket *filterout;
84 char *filterbuf;
8a87f29d 85 struct hash *hash;
d3372da9 86 size_t filterbufsize, filterbufdata;
70628d22 87 wchar_t *exitstatus;
d3372da9 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);
93};
94
95void freetransfer(struct transfer *transfer);
96struct transfer *newtransfer(void);
97void linktransfer(struct transfer *transfer);
98int slotsleft(void);
99void bumptransfer(struct transfer *transfer);
100struct transfer *findtransfer(int id);
6e37d33d 101struct transfer *hasupload(struct fnet *fnet, wchar_t *peerid);
d3372da9 102struct transfer *newupload(struct fnetnode *fn, struct fnet *fnet, wchar_t *nickid, struct transferiface *iface, void *data);
103void transfersetnick(struct transfer *transfer, wchar_t *newnick);
104void transfersetpath(struct transfer *transfer, wchar_t *newpath);
105void transfersetstate(struct transfer *transfer, int newstate);
106void transfersetsize(struct transfer *transfer, int newsize);
107void transferseterror(struct transfer *transfer, int error);
108void transfersetactivity(struct transfer *transfer, wchar_t *desc);
109void transferattach(struct transfer *transfer, struct transferiface *iface, void *data);
110void transferdetach(struct transfer *transfer);
111void resettransfer(struct transfer *transfer);
112void transfersetlocalend(struct transfer *transfer, struct socket *sk);
113void *transfergetdata(struct transfer *transfer, size_t *size);
d3372da9 114int forkfilter(struct transfer *transfer);
115void transferputdata(struct transfer *transfer, void *buf, size_t size);
116size_t transferdatasize(struct transfer *transfer);
117void transferendofdata(struct transfer *transfer);
118void transferprepul(struct transfer *transfer, size_t size, size_t start, size_t end, struct socket *lesk);
119void transferstartul(struct transfer *transfer, struct socket *sk);
668d96ab 120void transfersethash(struct transfer *transfer, struct hash *hash);
121struct transfer *finddownload(wchar_t *peerid);
122void transferstartdl(struct transfer *transfer, struct socket *sk);
b218e88e 123void trytransferbypeer(struct fnet *fnet, wchar_t *peerid);
d3372da9 124
125extern struct transfer *transfers;
d5aa6bdc 126extern unsigned long long bytesupload;
127extern unsigned long long bytesdownload;
d3372da9 128EGCBCHAIN(newtransfercb, struct transfer *);
129
130#endif