The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ftopic.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #include "inspircd.h"
00015 #include "xline.h"
00016 
00017 #include "m_spanningtree/treesocket.h"
00018 #include "m_spanningtree/treeserver.h"
00019 #include "m_spanningtree/utils.h"
00020 
00021 /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
00022 
00023 
00025 bool TreeSocket::ForceTopic(const std::string &source, std::deque<std::string> &params)
00026 {
00027         if (params.size() != 4)
00028                 return true;
00029         time_t ts = atoi(params[1].c_str());
00030         Channel* c = this->ServerInstance->FindChan(params[0]);
00031         if (c)
00032         {
00033                 if ((ts >= c->topicset) || (c->topic.empty()))
00034                 {
00035                         if (c->topic != params[3])
00036                         {
00037                                 User* user = this->ServerInstance->FindNick(source);
00038                                 // Update topic only when it differs from current topic
00039                                 c->topic.assign(params[3], 0, ServerInstance->Config->Limits.MaxTopic);
00040                                 if (!user)
00041                                 {
00042                                         c->WriteChannelWithServ(ServerInstance->Config->ServerName, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
00043                                 }
00044                                 else
00045                                 {
00046                                         c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
00047                                 }
00048                         }
00049 
00050                         // Always update setter and settime.
00051                         c->setby.assign(params[2], 0, 127);
00052                         c->topicset = ts;
00053 
00054                         /* all done, send it on its way */
00055                         params[3] = ":" + params[3];
00056                         Utils->DoOneToAllButSender(source,"FTOPIC",params,source);
00057                 }
00058 
00059         }
00060         return true;
00061 }
00062