2 * charybdis: an advanced ircd.
3 * m_presence.c: IRC presence protocol implementation
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 * Copyright (c) 2009 William Pitcock <nenolod@dereferenced.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 * $Id: m_away.c 3370 2007-04-03 10:15:39Z nenolod $
41 static int m_presence(struct Client
*, struct Client
*, int, const char **);
42 static int me_presence(struct Client
*, struct Client
*, int, const char **);
44 struct Message presence_msgtab
= {
45 "PRESENCE", 0, 0, 0, MFLG_SLOW
,
46 {mg_unreg
, {m_presence
, 1}, {m_presence
, 1}, mg_ignore
, {me_presence
, 1}, {m_presence
, 1}}
49 mapi_clist_av1 presence_clist
[] = { &presence_msgtab
, NULL
};
50 DECLARE_MODULE_AV1(presence
, NULL
, NULL
, presence_clist
, NULL
, NULL
, "$Revision$");
58 m_presence(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
62 if(MyClient(source_p
) && !IsFloodDone(source_p
))
63 flood_endgrace(source_p
);
65 if(!IsClient(source_p
))
68 if((parc
< 3 || EmptyString(parv
[2])) && !EmptyString(parv
[1]))
70 if ((val
= irc_dictionary_retrieve(source_p
->user
->metadata
, parv
[1])) != NULL
)
72 delete_metadata(source_p
, parv
[1]);
74 sendto_server(client_p
, NULL
, CAP_TS6
, NOCAPS
,
75 ":%s ENCAP * PRESENCE %s", use_id(source_p
), parv
[1]);
77 if (MyConnect(source_p
))
78 sendto_one_numeric(source_p
, RPL_METADATAREM
, form_str(RPL_METADATAREM
), parv
[1]);
82 if ((val
= irc_dictionary_retrieve(source_p
->user
->metadata
, parv
[1])) != NULL
)
84 if (!strcmp(parv
[2], val
))
87 delete_metadata(source_p
, parv
[1]);
90 set_metadata(source_p
, parv
[1], parv
[2]);
91 sendto_server(client_p
, NULL
, CAP_TS6
, NOCAPS
,
92 ":%s ENCAP * PRESENCE %s :%s", use_id(source_p
), parv
[1], parv
[2]);
94 if(MyConnect(source_p
))
95 sendto_one_numeric(source_p
, RPL_METADATASET
, form_str(RPL_METADATASET
), parv
[1]);
106 me_presence(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
110 if(MyClient(source_p
) && !IsFloodDone(source_p
))
111 flood_endgrace(source_p
);
113 if(!IsClient(source_p
))
116 if((parc
< 3 || EmptyString(parv
[2])) && !EmptyString(parv
[1]))
118 delete_metadata(source_p
, parv
[1]);
122 if ((val
= irc_dictionary_retrieve(source_p
->user
->metadata
, parv
[1])) != NULL
)
124 if (!strcmp(parv
[2], val
))
127 delete_metadata(source_p
, parv
[1]);
130 set_metadata(source_p
, parv
[1], parv
[2]);