ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_away.c
Revision: 4588
Committed: Tue Aug 26 15:59:07 2014 UTC (11 years ago) by michael
Content type: text/x-csrc
File size: 5231 byte(s)
Log Message:
- Renamed 'localClient' Client structure member to just 'connection'

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18 michael 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_away.c
23     * \brief Includes required functions for processing the AWAY command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "irc_string.h"
30     #include "ircd.h"
31     #include "numeric.h"
32     #include "send.h"
33     #include "parse.h"
34     #include "modules.h"
35 michael 1309 #include "conf.h"
36 michael 3347 #include "server.h"
37 adx 30 #include "packet.h"
38 michael 3347 #include "user.h"
39 adx 30
40    
41 michael 3300 /*! \brief AWAY command handler
42     *
43     * \param source_p Pointer to allocated Client struct from which the message
44     * originally comes from. This can be a local or remote client.
45     * \param parc Integer holding the number of supplied arguments.
46     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
47     * pointers.
48     * \note Valid arguments for this command are:
49     * - parv[0] = command
50     * - parv[1] = away message
51 adx 30 */
52 michael 2820 static int
53 michael 3156 m_away(struct Client *source_p, int parc, char *parv[])
54 adx 30 {
55     if (!IsFloodDone(source_p))
56     flood_endgrace(source_p);
57    
58     if (parc < 2 || EmptyString(parv[1]))
59     {
60     /* Marking as not away */
61 michael 1483 if (source_p->away[0])
62 adx 30 {
63 michael 1734 source_p->away[0] = '\0';
64 michael 3875
65     /* We now send this only if they were away before --is */
66 michael 3186 sendto_server(source_p, NOCAPS, NOCAPS, ":%s AWAY", source_p->id);
67 michael 3875 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY, ":%s!%s@%s AWAY",
68 michael 1734 source_p->name, source_p->username,
69     source_p->host);
70 adx 30 }
71    
72 michael 3109 sendto_one_numeric(source_p, &me, RPL_UNAWAY);
73 michael 2820 return 0;
74 adx 30 }
75    
76 michael 4588 if ((source_p->connection->away.last_attempt + ConfigGeneral.away_time) < CurrentTime)
77     source_p->connection->away.count = 0;
78 michael 4313
79 michael 4588 if (source_p->connection->away.count > ConfigGeneral.away_count)
80 michael 1484 {
81 michael 4313 sendto_one_numeric(source_p, &me, ERR_TOOMANYAWAY);
82 michael 2820 return 0;
83 michael 1484 }
84    
85 michael 4588 source_p->connection->away.last_attempt = CurrentTime;
86     source_p->connection->away.count++;
87 michael 1734
88 michael 1483 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
89 adx 30
90 michael 4313 sendto_one_numeric(source_p, &me, RPL_NOWAWAY);
91 michael 3875 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY, ":%s!%s@%s AWAY :%s",
92 michael 1734 source_p->name, source_p->username,
93     source_p->host, source_p->away);
94 michael 3156 sendto_server(source_p, NOCAPS, NOCAPS, ":%s AWAY :%s",
95 michael 3186 source_p->id, source_p->away);
96 michael 2820 return 0;
97 adx 30 }
98    
99 michael 3300 /*! \brief AWAY command handler
100     *
101     * \param source_p Pointer to allocated Client struct from which the message
102     * originally comes from. This can be a local or remote client.
103     * \param parc Integer holding the number of supplied arguments.
104     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
105     * pointers.
106     * \note Valid arguments for this command are:
107     * - parv[0] = command
108     * - parv[1] = away message
109     */
110 michael 2820 static int
111 michael 3156 ms_away(struct Client *source_p, int parc, char *parv[])
112 adx 30 {
113     if (parc < 2 || EmptyString(parv[1]))
114     {
115     /* Marking as not away */
116 michael 1483 if (source_p->away[0])
117 adx 30 {
118 michael 1734 source_p->away[0] = '\0';
119 michael 3875
120     /* We now send this only if they were away before --is */
121 michael 3186 sendto_server(source_p, NOCAPS, NOCAPS, ":%s AWAY", source_p->id);
122 michael 3875 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY, ":%s!%s@%s AWAY",
123 michael 1734 source_p->name, source_p->username,
124     source_p->host);
125 adx 30 }
126    
127 michael 2820 return 0;
128 adx 30 }
129    
130 michael 1483 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
131 adx 30
132 michael 3875 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY, ":%s!%s@%s AWAY :%s",
133 michael 1734 source_p->name, source_p->username,
134     source_p->host, source_p->away);
135 michael 3156 sendto_server(source_p, NOCAPS, NOCAPS, ":%s AWAY :%s",
136 michael 3186 source_p->id, source_p->away);
137 michael 2820 return 0;
138 adx 30 }
139 michael 1230
140 michael 2820 static struct Message away_msgtab =
141     {
142 michael 4545 "AWAY", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
143 michael 1449 { m_unregistered, m_away, ms_away, m_ignore, m_away, m_ignore }
144 michael 1230 };
145    
146     static void
147     module_init(void)
148     {
149     mod_add_cmd(&away_msgtab);
150     add_isupport("AWAYLEN", NULL, AWAYLEN);
151     }
152    
153     static void
154     module_exit(void)
155     {
156     mod_del_cmd(&away_msgtab);
157     delete_isupport("AWAYLEN");
158     }
159    
160 michael 2820 struct module module_entry =
161     {
162 michael 1230 .node = { NULL, NULL, NULL },
163     .name = NULL,
164     .version = "$Revision$",
165     .handle = NULL,
166     .modinit = module_init,
167     .modexit = module_exit,
168     .flags = 0
169     };

Properties

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