More translations.
[doldaconnect.git] / daemon / filenet.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 _FILENET_H
20#define _FILENET_H
21
22#include <wchar.h>
23#include "net.h"
24#include "utils.h"
25#include "search.h"
26
27#define FNN_SYN 0
28#define FNN_HS 1
29#define FNN_EST 2
30#define FNN_DEAD 3
31
fcd0627b 32#define FNNS_PUB 0
33#define FNNS_REG 1
34#define FNNS_OP 2
35
d3372da9 36#define FNPD_INT 0
37#define FNPD_LL 1
38#define FNPD_STR 2
39
40struct fnetnode;
41struct fnetpeer;
42
43struct fnet
44{
45 struct fnet *next;
46 wchar_t *name;
47 void (*connect)(struct fnetnode *fn);
48 void (*destroy)(struct fnetnode *fn);
49 int (*setnick)(struct fnetnode *fn, wchar_t *newnick);
50 int (*reqconn)(struct fnetpeer *peer);
51 int (*sendchat)(struct fnetnode *fn, int public, wchar_t *to, wchar_t *string);
52 int (*search)(struct fnetnode *fn, struct search *srch, struct srchfnnlist *ln);
53 wchar_t *(*filebasename)(wchar_t *filename);
54};
55
56struct fnetpeerdatum
57{
58 struct fnetpeerdatum *next, *prev;
59 int refcount;
60 wchar_t *id;
61 int datatype;
62};
63
64struct fnetpeerdi
65{
66 struct fnetpeerdatum *datum;
67 union
68 {
69 int num;
70 long long lnum;
71 wchar_t *str;
72 } data;
73};
74
75struct fnetpeer
76{
77 struct fnetpeer *next, *prev;
78 struct fnetnode *fn;
79 wchar_t *id;
80 wchar_t *nick;
81 union
82 {
83 struct
84 {
85 int delete:1;
86 int op:1;
87 } b;
88 int w;
89 } flags;
90 int dinum;
91 struct fnetpeerdi *peerdi;
92};
93
94struct fnetnode
95{
96 struct fnetnode *next, *prev;
97 int refcount;
98 int id;
99 int state;
100 int linked;
fcd0627b 101 int regstatus;
d3372da9 102 time_t srchwait, lastsrch;
d1e8b9fd 103 wchar_t *name, *pubid;
d3372da9 104 wchar_t *mynick;
105 struct fnet *fnet;
106 struct socket *sk;
107 struct fnetpeerdatum *peerdata;
108 struct fnetpeer *peers;
3ea7528f 109 struct wcspair *args;
110 int numpeers;
111 void *data;
d3372da9 112 CBCHAIN(fnetnode_ac, struct fnetnode *fn, wchar_t *attrib);
113 CBCHAIN(fnetnode_chat, struct fnetnode *fn, int public, wchar_t *name, wchar_t *peer, wchar_t *string);
114 CBCHAIN(fnetnode_unlink, struct fnetnode *fn);
115 CBCHAIN(fnetnode_destroy, struct fnetnode *fn);
61483336 116 CBCHAIN(fnetpeer_new, struct fnetnode *fn, struct fnetpeer *peer);
117 CBCHAIN(fnetpeer_del, struct fnetnode *fn, struct fnetpeer *peer);
118 CBCHAIN(fnetpeer_chdi, struct fnetnode *fn, struct fnetpeer *peer, struct fnetpeerdi *di);
d3372da9 119};
120
121void regfnet(struct fnet *fnet);
122void fnetsetname(struct fnetnode *fn, wchar_t *newname);
123void fnetsetstate(struct fnetnode *fn, int newstate);
124int fnetsetnick(struct fnetnode *fn, wchar_t *newnick);
125struct fnet *findfnet(wchar_t *name);
efc05613 126struct fnetnode *fnetinitconnect(wchar_t *name, char *addr, struct wcspair *args);
d3372da9 127void linkfnetnode(struct fnetnode *fn);
128void unlinkfnetnode(struct fnetnode *fn);
129void getfnetnode(struct fnetnode *fn);
130void putfnetnode(struct fnetnode *fn);
131void killfnetnode(struct fnetnode *fn);
132struct fnetpeer *fnetaddpeer(struct fnetnode *fn, wchar_t *id, wchar_t *nick);
133void fnetdelpeer(struct fnetpeer *peer);
134struct fnetpeer *fnetfindpeer(struct fnetnode *fn, wchar_t *id);
135void fnetpeersetstr(struct fnetpeer *peer, wchar_t *id, wchar_t *value);
136void fnetpeersetnum(struct fnetpeer *peer, wchar_t *id, int value);
137void fnetpeersetlnum(struct fnetpeer *peer, wchar_t *id, long long value);
138void fnetpeerunset(struct fnetpeer *peer, wchar_t *id);
139struct fnetnode *findfnetnode(int id);
140void fnethandlechat(struct fnetnode *fn, int public, wchar_t *name, wchar_t *peer, wchar_t *chat);
141int fnetsendchat(struct fnetnode *fn, int public, wchar_t *to, wchar_t *string);
142int fnetsearch(struct fnetnode *fn, struct search *srch, struct srchfnnlist *ln);
143
144extern struct fnetnode *fnetnodes;
145EGCBCHAIN(newfncb, struct fnetnode *);
146
147#endif