Try to hide join/leave messages.
[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;
a3a4a3a7 105 wchar_t *owner;
d3372da9 106 struct fnet *fnet;
107 struct socket *sk;
108 struct fnetpeerdatum *peerdata;
109 struct fnetpeer *peers;
3ea7528f 110 struct wcspair *args;
111 int numpeers;
112 void *data;
d3372da9 113 CBCHAIN(fnetnode_ac, struct fnetnode *fn, wchar_t *attrib);
114 CBCHAIN(fnetnode_chat, struct fnetnode *fn, int public, wchar_t *name, wchar_t *peer, wchar_t *string);
115 CBCHAIN(fnetnode_unlink, struct fnetnode *fn);
116 CBCHAIN(fnetnode_destroy, struct fnetnode *fn);
61483336 117 CBCHAIN(fnetpeer_new, struct fnetnode *fn, struct fnetpeer *peer);
118 CBCHAIN(fnetpeer_del, struct fnetnode *fn, struct fnetpeer *peer);
119 CBCHAIN(fnetpeer_chdi, struct fnetnode *fn, struct fnetpeer *peer, struct fnetpeerdi *di);
d3372da9 120};
121
122void regfnet(struct fnet *fnet);
123void fnetsetname(struct fnetnode *fn, wchar_t *newname);
124void fnetsetstate(struct fnetnode *fn, int newstate);
125int fnetsetnick(struct fnetnode *fn, wchar_t *newnick);
126struct fnet *findfnet(wchar_t *name);
a3a4a3a7 127struct fnetnode *fnetinitconnect(wchar_t *name, wchar_t *owner, char *addr, struct wcspair *args);
d3372da9 128void linkfnetnode(struct fnetnode *fn);
129void unlinkfnetnode(struct fnetnode *fn);
cab0b442 130void getfnetnode(struct fnetnode *fn);
d3372da9 131void putfnetnode(struct fnetnode *fn);
132void killfnetnode(struct fnetnode *fn);
133struct fnetpeer *fnetaddpeer(struct fnetnode *fn, wchar_t *id, wchar_t *nick);
134void fnetdelpeer(struct fnetpeer *peer);
135struct fnetpeer *fnetfindpeer(struct fnetnode *fn, wchar_t *id);
136void fnetpeersetstr(struct fnetpeer *peer, wchar_t *id, wchar_t *value);
137void fnetpeersetnum(struct fnetpeer *peer, wchar_t *id, int value);
138void fnetpeersetlnum(struct fnetpeer *peer, wchar_t *id, long long value);
139void fnetpeerunset(struct fnetpeer *peer, wchar_t *id);
140struct fnetnode *findfnetnode(int id);
141void fnethandlechat(struct fnetnode *fn, int public, wchar_t *name, wchar_t *peer, wchar_t *chat);
142int fnetsendchat(struct fnetnode *fn, int public, wchar_t *to, wchar_t *string);
143int fnetsearch(struct fnetnode *fn, struct search *srch, struct srchfnnlist *ln);
144
145extern struct fnetnode *fnetnodes;
146EGCBCHAIN(newfncb, struct fnetnode *);
147
148#endif