]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/time.cpp
Fire every debug.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / time.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
17 #include "socket.h"
18 #include "xline.h"
19 #include "transport.h"
20 #include "socketengine.h"
21
22 #include "m_spanningtree/main.h"
23 #include "m_spanningtree/utils.h"
24 #include "m_spanningtree/treeserver.h"
25 #include "m_spanningtree/treesocket.h"
26
27 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
28
29 bool TreeSocket::Time(const std::string &prefix, std::deque<std::string> &params)
30 {
31         // :source.server TIME remote.server sendernick
32         // :remote.server TIME source.server sendernick TS
33         if (params.size() == 2)
34         {
35                 // someone querying our time?
36                 if (this->ServerInstance->Config->ServerName == params[0] || this->ServerInstance->Config->GetSID() == params[0])
37                 {
38                         User* u = this->ServerInstance->FindNick(params[1]);
39                         if (u)
40                         {
41                                 params.push_back(ConvToStr(ServerInstance->Time()));
42                                 params[0] = prefix;
43                                 Utils->DoOneToOne(this->ServerInstance->Config->GetSID(),"TIME",params,params[0]);
44                         }
45                 }
46                 else
47                 {
48                         // not us, pass it on
49                         User* u = this->ServerInstance->FindNick(params[1]);
50                         if (u)
51                                 Utils->DoOneToOne(prefix,"TIME",params,params[0]);
52                 }
53         }
54         else if (params.size() == 3)
55         {
56                 // a response to a previous TIME
57                 User* u = this->ServerInstance->FindNick(params[1]);
58                 if ((u) && (IS_LOCAL(u)))
59                 {
60                         time_t rawtime = atol(params[2].c_str());
61                         struct tm * timeinfo;
62                         timeinfo = localtime(&rawtime);
63                         char tms[26];
64                         snprintf(tms,26,"%s",asctime(timeinfo));
65                         tms[24] = 0;
66                         u->WriteNumeric(RPL_TIME, "%s %s :%s",u->nick.c_str(),prefix.c_str(),tms);
67                 }
68                 else
69                 {
70                         if (u)
71                                 Utils->DoOneToOne(prefix,"TIME",params,u->server);
72                 }
73         }
74         return true;
75 }
76