sendbuf(cl);
} while (trie_findnext(&f) == 1);
}
+void sendbuf_chan_caps(struct channel *chan, unsigned positive, unsigned negative) {
+ struct trie_find *f = NULL;
+ if (trie_findfirst(&f, &chan->members) == 1)
+ do {
+ struct client_data *cl = f->n->value;
+ if (!(~cl->caps & positive) && !(cl->caps & negative))
+ sendbuf(cl);
+ } while (trie_findnext(&f) == 1);
+}
void sendbuf_list_sans_self(struct client_data *client, struct trie_node **ls, int cookie) {
struct trie_find *f = NULL;
if (trie_findfirst(&f, ls) == 1)
const char *name;
unsigned caps;
} caps[] = {
- { "multi-prefix", CAP_MULTIPREFIX },
{ "cap-notify", 0 },
+ { "multi-prefix", CAP_MULTIPREFIX },
+ { "extended-join", CAP_EXTENDEDJOIN },
{ 0, 0 }
};
if (strcmp(args[0], "LS") == 0) {
if (args[1] && atoi(args[1]) >= 302)
client->caps |= CAP_302;
- copy_strf(&databuf, ":%s CAP * LS :multi-prefix\r\n", hostname);
+ copy_strf(&databuf, ":%s CAP * LS :multi-prefix extended-join\r\n", hostname);
sendbuf(client);
if (!is_registered(client)) {
client->regstate = REG_CAPLS;
const struct cap *c;
for (c = caps; c->name; c++) {
if (strcmp(p, c->name) == 0) {
+ // FIXME: it's preferrable to send these in one line
copy_strf(&databuf, ":%s CAP * ACK :%s%s\r\n", hostname, invert?"-":"", c->name);
if (!invert)
client->caps |= c->caps;
newUser(client);
}
} else {
+ // FIXME: error 410
goto unknown;
}
} else if(strcmp(command, "NICK") == 0) {
msg_join(client, chan);
if (newchan)
chanlog_time(chan->creation);
- sendbuf_chan(chan);
+ sendbuf_chan_caps(chan, 0, CAP_EXTENDEDJOIN);
+ msg_join_extended(client, chan);
+ sendbuf_chan_caps(chan, CAP_EXTENDEDJOIN, 0);
// TODO: send channel modes to the joining client
// apply +w modes
if (match_list(client, &chan->listwo)) {
copy_strf(&databuf, ":%s!%s@%s JOIN %s\r\n",
src->nick, src->username, src->hostname, chan->name);
}
+void msg_join_extended(struct client_data *src, struct channel *chan)
+{
+ copy_strf(&databuf, ":%s!%s@%s JOIN %s %s :%s\r\n",
+ src->nick, src->username, src->hostname, chan->name,
+ src->username[0] != '~' ? src->username : "*", src->realname);
+}
void msg_part(struct client_data *src, struct channel *chan, const char *reason)
{
if (reason)
void msg_quit(struct client_data *src, const char *prefix, const char *reason);
void msg_error(const char *reason);
void msg_join(struct client_data *src, struct channel *chan);
+void msg_join_extended(struct client_data *src, struct channel *chan);
void msg_part(struct client_data *src, struct channel *chan, const char *reason);
void msg_topic(struct client_data *src, struct channel *chan);
void msg_invite(struct client_data *src, struct client_data *dst, struct channel *chan);