]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/idle.cpp
Whitespace and empty destructor removal, minor coding style changes
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / idle.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2011 Adam <Adam@anope.org>
5  *
6  * This file is part of InspIRCd.  InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #include "inspircd.h"
21 #include "socket.h"
22 #include "xline.h"
23 #include "socketengine.h"
24
25 #include "main.h"
26 #include "utils.h"
27 #include "treeserver.h"
28 #include "treesocket.h"
29
30 bool TreeSocket::Whois(const std::string &prefix, parameterlist &params)
31 {
32         if (params.size() < 1)
33                 return true;
34         User* u = ServerInstance->FindNick(prefix);
35         if (u)
36         {
37                 // an incoming request
38                 if (params.size() == 1)
39                 {
40                         User* x = ServerInstance->FindNick(params[0]);
41                         if ((x) && (IS_LOCAL(x)))
42                         {
43                                 LocalUser* lu = IS_LOCAL(x);
44                                 long idle = abs((long)((lu->idle_lastmsg) - ServerInstance->Time()));
45                                 parameterlist par;
46                                 par.push_back(prefix);
47                                 par.push_back(ConvToStr(x->signon));
48                                 par.push_back(ConvToStr(idle));
49                                 // ours, we're done, pass it BACK
50                                 Utils->DoOneToOne(params[0], "IDLE", par, u->server);
51                         }
52                         else
53                         {
54                                 // not ours pass it on
55                                 if (x)
56                                         Utils->DoOneToOne(prefix, "IDLE", params, x->server);
57                         }
58                 }
59                 else if (params.size() == 3)
60                 {
61                         std::string who_did_the_whois = params[0];
62                         User* who_to_send_to = ServerInstance->FindNick(who_did_the_whois);
63                         if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
64                         {
65                                 // an incoming reply to a whois we sent out
66                                 std::string nick_whoised = prefix;
67                                 unsigned long signon = atoi(params[1].c_str());
68                                 unsigned long idle = atoi(params[2].c_str());
69                                 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
70                                 {
71                                         ServerInstance->DoWhois(who_to_send_to, u, signon, idle, nick_whoised.c_str());
72                                 }
73                         }
74                         else
75                         {
76                                 // not ours, pass it on
77                                 if (who_to_send_to)
78                                         Utils->DoOneToOne(prefix, "IDLE", params, who_to_send_to->server);
79                         }
80                 }
81         }
82         return true;
83 }
84
85