summaryrefslogtreecommitdiff
path: root/modules/webcpanel/webcpanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/webcpanel/webcpanel.cpp')
-rw-r--r--modules/webcpanel/webcpanel.cpp95
1 files changed, 60 insertions, 35 deletions
diff --git a/modules/webcpanel/webcpanel.cpp b/modules/webcpanel/webcpanel.cpp
index 947248cb8..ba879a98f 100644
--- a/modules/webcpanel/webcpanel.cpp
+++ b/modules/webcpanel/webcpanel.cpp
@@ -1,8 +1,20 @@
/*
- * (C) 2003-2017 Anope Team
- * Contact us at team@anope.org
+ * Anope IRC Services
*
- * Please read COPYING and README for further details.
+ * Copyright (C) 2012-2017 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
#include "webcpanel.h"
@@ -14,7 +26,7 @@ class ModuleWebCPanel : public Module
{
ServiceReference<HTTPProvider> provider;
Panel panel;
- PrimitiveExtensibleItem<Anope::string> id, ip;
+ ExtensibleItem<Anope::string> id, ip;
StaticFileServer style_css, logo_png, cubes_png, favicon_ico;
@@ -43,25 +55,42 @@ class ModuleWebCPanel : public Module
public:
- ModuleWebCPanel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR),
- panel(this, "webcpanel"), id(this, "webcpanel_id"), ip(this, "webcpanel_ip"),
- style_css("style.css", "/static/style.css", "text/css"), logo_png("logo.png", "/static/logo.png", "image/png"), cubes_png("cubes.png", "/static/cubes.png", "image/png"), favicon_ico("favicon.ico", "/favicon.ico", "image/x-icon"),
- index("/"), logout("/logout"), _register("/register"), confirm("/confirm"),
- nickserv_info("NickServ", "/nickserv/info"), nickserv_cert("NickServ", "/nickserv/cert"), nickserv_access("NickServ", "/nickserv/access"), nickserv_alist("NickServ", "/nickserv/alist"),
- chanserv_info("ChanServ", "/chanserv/info"), chanserv_set("ChanServ", "/chanserv/set"), chanserv_access("ChanServ", "/chanserv/access"), chanserv_akick("ChanServ", "/chanserv/akick"),
- chanserv_modes("ChanServ", "/chanserv/modes"), chanserv_drop("ChanServ", "/chanserv/drop"), memoserv_memos("MemoServ", "/memoserv/memos"), hostserv_request("HostServ", "/hostserv/request"),
- operserv_akill("OperServ", "/operserv/akill")
+ ModuleWebCPanel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ , panel(this, "webcpanel")
+ , id(this, "webcpanel_id")
+ , ip(this, "webcpanel_ip")
+ , style_css("style.css", "/static/style.css", "text/css")
+ , logo_png("logo.png", "/static/logo.png", "image/png")
+ , cubes_png("cubes.png", "/static/cubes.png", "image/png")
+ , favicon_ico("favicon.ico", "/favicon.ico", "image/x-icon")
+ , index("/")
+ , logout("/logout")
+ , _register("/register")
+ , confirm("/confirm")
+ , nickserv_info("NickServ", "/nickserv/info")
+ , nickserv_cert("NickServ", "/nickserv/cert")
+ , nickserv_access("NickServ", "/nickserv/access")
+ , nickserv_alist("NickServ", "/nickserv/alist")
+ , chanserv_info("ChanServ", "/chanserv/info")
+ , chanserv_set("ChanServ", "/chanserv/set")
+ , chanserv_access("ChanServ", "/chanserv/access")
+ , chanserv_akick("ChanServ", "/chanserv/akick")
+ , chanserv_modes("ChanServ", "/chanserv/modes")
+ , chanserv_drop("ChanServ", "/chanserv/drop")
+ , memoserv_memos("MemoServ", "/memoserv/memos")
+ , hostserv_request("HostServ", "/hostserv/request")
+ , operserv_akill("OperServ", "/operserv/akill")
{
me = this;
Configuration::Block *block = Config->GetModule(this);
- provider_name = block->Get<const Anope::string>("server", "httpd/main");
- template_name = block->Get<const Anope::string>("template", "default");
+ provider_name = block->Get<Anope::string>("server", "httpd/main");
+ template_name = block->Get<Anope::string>("template", "default");
template_base = Anope::DataDir + "/modules/webcpanel/templates/" + template_name;
- page_title = block->Get<const Anope::string>("title", "Anope IRC Services");
+ page_title = block->Get<Anope::string>("title", "Anope IRC Services");
- provider = ServiceReference<HTTPProvider>("HTTPProvider", provider_name);
+ provider = ServiceReference<HTTPProvider>(provider_name);
if (!provider)
throw ModuleException("Unable to find HTTPD provider. Is m_httpd loaded?");
@@ -75,7 +104,7 @@ class ModuleWebCPanel : public Module
provider->RegisterPage(&this->_register);
provider->RegisterPage(&this->confirm);
- BotInfo *NickServ = Config->GetClient("NickServ");
+ ServiceBot *NickServ = Config->GetClient("NickServ");
if (NickServ)
{
Section s;
@@ -108,7 +137,7 @@ class ModuleWebCPanel : public Module
panel.sections.push_back(s);
}
- BotInfo *ChanServ = Config->GetClient("ChanServ");
+ ServiceBot *ChanServ = Config->GetClient("ChanServ");
if (ChanServ)
{
Section s;
@@ -148,7 +177,7 @@ class ModuleWebCPanel : public Module
panel.sections.push_back(s);
}
- BotInfo *MemoServ = Config->GetClient("MemoServ");
+ ServiceBot *MemoServ = Config->GetClient("MemoServ");
if (MemoServ)
{
Section s;
@@ -163,7 +192,7 @@ class ModuleWebCPanel : public Module
panel.sections.push_back(s);
}
- BotInfo *HostServ = Config->GetClient("HostServ");
+ ServiceBot *HostServ = Config->GetClient("HostServ");
if (HostServ)
{
Section s;
@@ -178,7 +207,7 @@ class ModuleWebCPanel : public Module
panel.sections.push_back(s);
}
- BotInfo *OperServ = Config->GetClient("OperServ");
+ ServiceBot *OperServ = Config->GetClient("OperServ");
if (OperServ)
{
Section s;
@@ -231,9 +260,9 @@ class ModuleWebCPanel : public Module
namespace WebPanel
{
- void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector<Anope::string> &params, TemplateFileServer::Replacements &r, const Anope::string &key)
+ void RunCommand(const Anope::string &user, NickServ::Account *nc, const Anope::string &service, const Anope::string &c, std::vector<Anope::string> &params, TemplateFileServer::Replacements &r, const Anope::string &key)
{
- ServiceReference<Command> cmd("Command", c);
+ ServiceReference<Command> cmd(c);
if (!cmd)
{
r[key] = "Unable to find command " + c;
@@ -243,13 +272,9 @@ namespace WebPanel
if (params.size() < cmd->min_params)
return;
- BotInfo *bi = Config->GetClient(service);
+ ServiceBot *bi = Config->GetClient(service);
if (!bi)
- {
- if (BotListByNick->empty())
- return;
- bi = BotListByNick->begin()->second; // Pick one...
- }
+ return;
struct MyComandReply : CommandReply
{
@@ -258,7 +283,7 @@ namespace WebPanel
MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { }
- void SendMessage(BotInfo *source, const Anope::string &msg) anope_override
+ void SendMessage(const MessageSource &, const Anope::string &msg) override
{
re[k] = msg;
}
@@ -271,16 +296,16 @@ namespace WebPanel
cmd->Run(source, "", info, params);
}
- void RunCommandWithName(NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector<Anope::string> &params, TemplateFileServer::Replacements &r, const Anope::string &key)
+ void RunCommandWithName(NickServ::Account *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector<Anope::string> &params, TemplateFileServer::Replacements &r, const Anope::string &key)
{
- ServiceReference<Command> cmd("Command", c);
+ ServiceReference<Command> cmd(c);
if (!cmd)
{
r[key] = "Unable to find command " + c;
return;
}
- BotInfo *bi = Config->GetClient(service);
+ ServiceBot *bi = Config->GetClient(service);
if (!bi)
return;
@@ -295,14 +320,14 @@ namespace WebPanel
MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { }
- void SendMessage(BotInfo *source, const Anope::string &msg) anope_override
+ void SendMessage(const MessageSource &, const Anope::string &msg) override
{
re[k] = msg;
}
}
my_reply(r, key);
- CommandSource source(nc->display, NULL, nc, &my_reply, bi);
+ CommandSource source(nc->GetDisplay(), NULL, nc, &my_reply, bi);
cmd->Run(source, cmdname, *info, params);
}