ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_away.c
Revision: 1028
Committed: Sun Nov 8 13:03:38 2009 UTC (14 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 7008 byte(s)
Log Message:
- move ircd-hybrid-7.2 to trunk

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_away.c: Sets/removes away status on a user.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "handlers.h"
27 #include "client.h"
28 #include "irc_string.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "send.h"
32 #include "msg.h"
33 #include "parse.h"
34 #include "modules.h"
35 #include "s_conf.h"
36 #include "s_serv.h"
37 #include "packet.h"
38 #include "s_user.h"
39
40 static void m_away(struct Client *, struct Client *, int, char *[]);
41 static void mo_away(struct Client *, struct Client *, int, char *[]);
42 static void ms_away(struct Client *, struct Client *, int, char *[]);
43
44 struct Message away_msgtab = {
45 "AWAY", 0, 0, 0, 0, MFLG_SLOW, 0,
46 {m_unregistered, m_away, ms_away, m_ignore, mo_away, m_ignore}
47 };
48
49 #ifndef STATIC_MODULES
50 void
51 _modinit(void)
52 {
53 mod_add_cmd(&away_msgtab);
54 add_isupport("AWAYLEN", NULL, AWAYLEN);
55 }
56
57 void
58 _moddeinit(void)
59 {
60 mod_del_cmd(&away_msgtab);
61 delete_isupport("AWAYLEN");
62 }
63
64 const char *_version = "$Revision$";
65 #endif
66
67 /***********************************************************************
68 * m_away() - Added 14 Dec 1988 by jto.
69 * Not currently really working, I don't like this
70 * call at all...
71 *
72 * ...trying to make it work. I don't like it either,
73 * but perhaps it's worth the load it causes to net.
74 * This requires flooding of the whole net like NICK,
75 * USER, MODE, etc messages... --msa
76 ***********************************************************************/
77
78 /*
79 * m_away
80 * parv[0] = sender prefix
81 * parv[1] = away message
82 */
83 static void
84 m_away(struct Client *client_p, struct Client *source_p,
85 int parc, char *parv[])
86 {
87 char *cur_away_msg = source_p->away;
88 char *new_away_msg = NULL;
89 size_t nbytes = 0;
90
91 if (!IsFloodDone(source_p))
92 flood_endgrace(source_p);
93
94 if (parc < 2 || EmptyString(parv[1]))
95 {
96 /* Marking as not away */
97 if (cur_away_msg)
98 {
99 /* we now send this only if they were away before --is */
100 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
101 ":%s AWAY", ID(source_p));
102 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
103 ":%s AWAY", source_p->name);
104
105 MyFree(cur_away_msg);
106 source_p->away = NULL;
107 }
108
109 sendto_one(source_p, form_str(RPL_UNAWAY),
110 me.name, source_p->name);
111 return;
112 }
113
114 /* Marking as away */
115 if ((CurrentTime - source_p->localClient->last_away) < ConfigFileEntry.pace_wait)
116 {
117 sendto_one(source_p, form_str(RPL_LOAD2HI),
118 me.name, source_p->name);
119 return;
120 }
121
122 source_p->localClient->last_away = CurrentTime;
123 new_away_msg = parv[1];
124
125 nbytes = strlen(new_away_msg);
126 if (nbytes > (size_t)AWAYLEN) {
127 new_away_msg[AWAYLEN] = '\0';
128 nbytes = AWAYLEN;
129 }
130
131 /* we now send this only if they
132 * weren't away already --is */
133 if (!cur_away_msg)
134 {
135 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
136 ":%s AWAY :%s", ID(source_p), new_away_msg);
137 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
138 ":%s AWAY :%s", source_p->name, new_away_msg);
139 }
140 else
141 MyFree(cur_away_msg);
142
143 cur_away_msg = MyMalloc(nbytes + 1);
144 strcpy(cur_away_msg, new_away_msg);
145 source_p->away = cur_away_msg;
146
147 sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, source_p->name);
148 }
149
150 static void
151 mo_away(struct Client *client_p, struct Client *source_p,
152 int parc, char *parv[])
153 {
154 char *cur_away_msg = source_p->away;
155 char *new_away_msg = NULL;
156 size_t nbytes = 0;
157
158 if (!IsFloodDone(source_p))
159 flood_endgrace(source_p);
160
161 if (parc < 2 || EmptyString(parv[1]))
162 {
163 /* Marking as not away */
164 if (cur_away_msg)
165 {
166 /* we now send this only if they were away before --is */
167 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
168 ":%s AWAY", ID(source_p));
169 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
170 ":%s AWAY", source_p->name);
171
172 MyFree(cur_away_msg);
173 source_p->away = NULL;
174 }
175
176 sendto_one(source_p, form_str(RPL_UNAWAY),
177 me.name, source_p->name);
178 return;
179 }
180
181 new_away_msg = parv[1];
182
183 nbytes = strlen(new_away_msg);
184 if (nbytes > (size_t)AWAYLEN) {
185 new_away_msg[AWAYLEN] = '\0';
186 nbytes = AWAYLEN;
187 }
188
189 /* we now send this only if they
190 * weren't away already --is */
191 if (!cur_away_msg)
192 {
193 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
194 ":%s AWAY :%s", ID(source_p), new_away_msg);
195 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
196 ":%s AWAY :%s", source_p->name, new_away_msg);
197 }
198 else
199 MyFree(cur_away_msg);
200
201 cur_away_msg = MyMalloc(nbytes + 1);
202 strcpy(cur_away_msg, new_away_msg);
203 source_p->away = cur_away_msg;
204
205 sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, source_p->name);
206 }
207
208 static void
209 ms_away(struct Client *client_p, struct Client *source_p,
210 int parc, char *parv[])
211 {
212 char *cur_away_msg = NULL;
213 char *new_away_msg = NULL;
214 size_t nbytes = 0;
215
216 if (!IsClient(source_p))
217 return;
218
219 cur_away_msg = source_p->away;
220
221 if (parc < 2 || EmptyString(parv[1]))
222 {
223 /* Marking as not away */
224 if (cur_away_msg)
225 {
226 /* we now send this only if they were away before --is */
227 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
228 ":%s AWAY", ID(source_p));
229 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
230 ":%s AWAY", source_p->name);
231
232 MyFree(cur_away_msg);
233 source_p->away = NULL;
234 }
235
236 return;
237 }
238
239 new_away_msg = parv[1];
240
241 nbytes = strlen(new_away_msg);
242 if (nbytes > (size_t)AWAYLEN) {
243 new_away_msg[AWAYLEN] = '\0';
244 nbytes = AWAYLEN;
245 }
246
247 /* we now send this only if they
248 * weren't away already --is */
249 if (!cur_away_msg)
250 {
251 sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
252 ":%s AWAY :%s", ID(source_p), new_away_msg);
253 sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
254 ":%s AWAY :%s", source_p->name, new_away_msg);
255 }
256 else
257 MyFree(cur_away_msg);
258
259 cur_away_msg = MyMalloc(nbytes + 1);
260 strcpy(cur_away_msg, new_away_msg);
261 source_p->away = cur_away_msg;
262 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision