changeset 201:75bc436b8b3f

Irccd: do not test WITH_JS since plugins have been generalized
author David Demelier <markand@malikania.fr>
date Wed, 08 Jun 2016 20:58:21 +0200
parents 1099568ef450
children 786559f1937f
files lib/irccd/cmd-plugin-info.cpp lib/irccd/cmd-plugin-list.cpp lib/irccd/cmd-plugin-load.cpp lib/irccd/cmd-plugin-reload.cpp lib/irccd/cmd-plugin-unload.cpp lib/irccd/service-server.cpp
diffstat 6 files changed, 0 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/lib/irccd/cmd-plugin-info.cpp	Wed Jun 08 20:26:00 2016 +0200
+++ b/lib/irccd/cmd-plugin-info.cpp	Wed Jun 08 20:58:21 2016 +0200
@@ -22,7 +22,6 @@
 #include "irccd.hpp"
 #include "plugin.hpp"
 #include "service-plugin.hpp"
-#include "sysconfig.hpp"
 #include "util.hpp"
 
 namespace irccd {
@@ -51,7 +50,6 @@
 
 json::Value PluginInfo::exec(Irccd &irccd, const json::Value &request) const
 {
-#if defined(WITH_JS)
 	auto plugin = irccd.pluginService().require(request.at("plugin").toString());
 	
 	return json::object({
@@ -60,11 +58,6 @@
 		{ "summary",	plugin->summary()	},
 		{ "version",	plugin->version()	}
 	});
-#else
-	util::unused(irccd, object);
-
-	throw std::runtime_error("JavaScript disabled");
-#endif
 }
 
 void PluginInfo::result(Irccdctl &irccdctl, const json::Value &result) const
--- a/lib/irccd/cmd-plugin-list.cpp	Wed Jun 08 20:26:00 2016 +0200
+++ b/lib/irccd/cmd-plugin-list.cpp	Wed Jun 08 20:58:21 2016 +0200
@@ -22,7 +22,6 @@
 #include "irccd.hpp"
 #include "plugin.hpp"
 #include "service-plugin.hpp"
-#include "sysconfig.hpp"
 #include "util.hpp"
 
 namespace irccd {
@@ -41,7 +40,6 @@
 
 json::Value PluginList::exec(Irccd &irccd, const json::Value &request) const
 {
-#if defined(WITH_JS)
 	json::Value response = RemoteCommand::exec(irccd, request);
 	json::Value list = json::array({});
 
@@ -51,11 +49,6 @@
 	response.insert("list", std::move(list));
 
 	return response;
-#else
-	util::unused(irccd, tc);
-
-	throw std::runtime_error("JavaScript disabled");
-#endif
 }
 
 void PluginList::result(Irccdctl &irccdctl, const json::Value &object) const
--- a/lib/irccd/cmd-plugin-load.cpp	Wed Jun 08 20:26:00 2016 +0200
+++ b/lib/irccd/cmd-plugin-load.cpp	Wed Jun 08 20:58:21 2016 +0200
@@ -19,7 +19,6 @@
 #include "cmd-plugin-load.hpp"
 #include "irccd.hpp"
 #include "service-plugin.hpp"
-#include "sysconfig.hpp"
 #include "util.hpp"
 
 namespace irccd {
@@ -43,17 +42,11 @@
 
 json::Value PluginLoad::exec(Irccd &irccd, const json::Value &request) const
 {
-#if defined(WITH_JS)
 	auto name = request.at("plugin").toString();
 
 	irccd.pluginService().load(name);
 
 	return RemoteCommand::exec(irccd, request);
-#else
-	util::unused(irccd, request);
-
-	throw std::runtime_error("JavaScript disabled");
-#endif
 }
 
 } // !command
--- a/lib/irccd/cmd-plugin-reload.cpp	Wed Jun 08 20:26:00 2016 +0200
+++ b/lib/irccd/cmd-plugin-reload.cpp	Wed Jun 08 20:58:21 2016 +0200
@@ -20,7 +20,6 @@
 #include "irccd.hpp"
 #include "plugin.hpp"
 #include "service-plugin.hpp"
-#include "sysconfig.hpp"
 #include "util.hpp"
 
 namespace irccd {
@@ -44,15 +43,9 @@
 
 json::Value PluginReload::exec(Irccd &irccd, const json::Value &request) const
 {
-#if defined(WITH_JS)
 	irccd.pluginService().require(request.at("plugin").toString())->onReload(irccd);
 
 	return RemoteCommand::exec(irccd, request);
-#else
-	util::unused(irccd, request);
-
-	throw std::runtime_error("JavaScript disabled");
-#endif
 }
 
 } // !command
--- a/lib/irccd/cmd-plugin-unload.cpp	Wed Jun 08 20:26:00 2016 +0200
+++ b/lib/irccd/cmd-plugin-unload.cpp	Wed Jun 08 20:58:21 2016 +0200
@@ -19,7 +19,6 @@
 #include "cmd-plugin-unload.hpp"
 #include "irccd.hpp"
 #include "service-plugin.hpp"
-#include "sysconfig.hpp"
 #include "util.hpp"
 
 namespace irccd {
@@ -43,15 +42,9 @@
 
 json::Value PluginUnload::exec(Irccd &irccd, const json::Value &request) const
 {
-#if defined(WITH_JS)
 	irccd.pluginService().unload(request.at("plugin").toString());
 
 	return RemoteCommand::exec(irccd, request);
-#else
-	util::unused(irccd, request);
-
-	throw std::runtime_error("JavaScript disabled");
-#endif
 }
 
 } // !command
--- a/lib/irccd/service-server.cpp	Wed Jun 08 20:26:00 2016 +0200
+++ b/lib/irccd/service-server.cpp	Wed Jun 08 20:58:21 2016 +0200
@@ -28,7 +28,6 @@
 #include "server-event.hpp"
 #include "service-server.hpp"
 #include "service-transport.hpp"
-#include "sysconfig.hpp"
 #include "util.hpp"
 
 using namespace fmt::literals;
@@ -57,7 +56,6 @@
 		{ "argument",	arg			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, channel,
 		[=] (Plugin &) -> std::string {
 			return "onChannelMode";
@@ -67,7 +65,6 @@
 					     std::move(arg));
 		}
 	));
-#endif
 }
 
 void ServerService::handleChannelNotice(std::weak_ptr<Server> ptr, std::string origin, std::string channel, std::string message)
@@ -90,7 +87,6 @@
 		{ "message",	message			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, channel,
 		[=] (Plugin &) -> std::string {
 			return "onChannelNotice";
@@ -99,7 +95,6 @@
 			plugin.onChannelNotice(m_irccd, std::move(server), std::move(origin), std::move(channel), std::move(message));
 		}
 	));
-#endif
 }
 
 void ServerService::handleConnect(std::weak_ptr<Server> ptr)
@@ -116,7 +111,6 @@
 		{ "server",	server->name()		}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), /* origin */ "", /* channel */ "",
 		[=] (Plugin &) -> std::string {
 			return "onConnect";
@@ -125,7 +119,6 @@
 			plugin.onConnect(m_irccd, std::move(server));
 		}
 	));
-#endif
 }
 
 void ServerService::handleInvite(std::weak_ptr<Server> ptr, std::string origin, std::string channel, std::string target)
@@ -147,7 +140,6 @@
 		{ "channel",	channel			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, channel,
 		[=] (Plugin &) -> std::string {
 			return "onInvite";
@@ -156,7 +148,6 @@
 			plugin.onInvite(m_irccd, std::move(server), std::move(origin), std::move(channel));
 		}
 	));
-#endif
 }
 
 void ServerService::handleJoin(std::weak_ptr<Server> ptr, std::string origin, std::string channel)
@@ -177,7 +168,6 @@
 		{ "channel",	channel			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, channel,
 		[=] (Plugin &) -> std::string {
 			return "onJoin";
@@ -186,7 +176,6 @@
 			plugin.onJoin(m_irccd, std::move(server), std::move(origin), std::move(channel));
 		}
 	));
-#endif
 }
 
 void ServerService::handleKick(std::weak_ptr<Server> ptr, std::string origin, std::string channel, std::string target, std::string reason)
@@ -211,7 +200,6 @@
 		{ "reason",	reason			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, channel,
 		[=] (Plugin &) -> std::string {
 			return "onKick";
@@ -220,7 +208,6 @@
 			plugin.onKick(m_irccd, std::move(server), std::move(origin), std::move(channel), std::move(target), std::move(reason));
 		}
 	));
-#endif
 }
 
 void ServerService::handleMessage(std::weak_ptr<Server> ptr, std::string origin, std::string channel, std::string message)
@@ -243,7 +230,6 @@
 		{ "message",	message			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, channel,
 		[=] (Plugin &plugin) -> std::string {
 			return util::parseMessage(message, server->settings().command, plugin.name()).second == util::MessageType::Command ? "onCommand" : "onMessage";
@@ -257,7 +243,6 @@
 				plugin.onMessage(m_irccd, std::move(server), std::move(origin), std::move(channel), std::move(pack.first));
 		}
 	));
-#endif
 }
 
 void ServerService::handleMe(std::weak_ptr<Server> ptr, std::string origin, std::string target, std::string message)
@@ -280,7 +265,6 @@
 		{ "message",	message			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, target,
 		[=] (Plugin &) -> std::string {
 			return "onMe";
@@ -289,7 +273,6 @@
 			plugin.onMe(m_irccd, std::move(server), std::move(origin), std::move(target), std::move(message));
 		}
 	));
-#endif
 }
 
 void ServerService::handleMode(std::weak_ptr<Server> ptr, std::string origin, std::string mode)
@@ -310,7 +293,6 @@
 		{ "mode",	mode			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, /* channel */ "",
 		[=] (Plugin &) -> std::string {
 			return "onMode";
@@ -319,7 +301,6 @@
 			plugin.onMode(m_irccd, std::move(server), std::move(origin), std::move(mode));
 		}
 	));
-#endif
 }
 
 void ServerService::handleNames(std::weak_ptr<Server> ptr, std::string channel, std::set<std::string> nicknames)
@@ -342,7 +323,6 @@
 		{ "names",	std::move(names)	}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), /* origin */ "", channel,
 		[=] (Plugin &) -> std::string {
 			return "onNames";
@@ -351,7 +331,6 @@
 			plugin.onNames(m_irccd, std::move(server), std::move(channel), std::vector<std::string>(nicknames.begin(), nicknames.end()));
 		}
 	));
-#endif
 }
 
 void ServerService::handleNick(std::weak_ptr<Server> ptr, std::string origin, std::string nickname)
@@ -372,7 +351,6 @@
 		{ "nickname",	nickname		}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, /* channel */ "",
 		[=] (Plugin &) -> std::string {
 			return "onNick";
@@ -381,7 +359,6 @@
 			plugin.onNick(m_irccd, std::move(server), std::move(origin), std::move(nickname));
 		}
 	));
-#endif
 }
 
 void ServerService::handleNotice(std::weak_ptr<Server> ptr, std::string origin, std::string message)
@@ -402,7 +379,6 @@
 		{ "message",	message			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, /* channel */ "",
 		[=] (Plugin &) -> std::string {
 			return "onNotice";
@@ -411,7 +387,6 @@
 			plugin.onNotice(m_irccd, std::move(server), std::move(origin), std::move(message));
 		}
 	));
-#endif
 }
 
 void ServerService::handlePart(std::weak_ptr<Server> ptr, std::string origin, std::string channel, std::string reason)
@@ -434,7 +409,6 @@
 		{ "reason",	reason			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, channel,
 		[=] (Plugin &) -> std::string {
 			return "onPart";
@@ -443,7 +417,6 @@
 			plugin.onPart(m_irccd, std::move(server), std::move(origin), std::move(channel), std::move(reason));
 		}
 	));
-#endif
 }
 
 void ServerService::handleQuery(std::weak_ptr<Server> ptr, std::string origin, std::string message)
@@ -464,7 +437,6 @@
 		{ "message",	message			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, /* channel */ "",
 		[=] (Plugin &plugin) -> std::string {
 			return util::parseMessage(message, server->settings().command, plugin.name()).second == util::MessageType::Command ? "onQueryCommand" : "onQuery";
@@ -478,7 +450,6 @@
 				plugin.onQuery(m_irccd, std::move(server), std::move(origin), std::move(pack.first));
 		}
 	));
-#endif
 }
 
 void ServerService::handleTopic(std::weak_ptr<Server> ptr, std::string origin, std::string channel, std::string topic)
@@ -501,7 +472,6 @@
 		{ "topic",	topic			}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), origin, channel,
 		[=] (Plugin &) -> std::string {
 			return "onTopic";
@@ -510,7 +480,6 @@
 			plugin.onTopic(m_irccd, std::move(server), std::move(origin), std::move(channel), std::move(topic));
 		}
 	));
-#endif
 }
 
 void ServerService::handleWhois(std::weak_ptr<Server> ptr, ServerWhois whois)
@@ -535,7 +504,6 @@
 		{ "realname",	whois.realname		}
 	}).toJson(0));
 
-#if defined(WITH_JS)
 	m_irccd.post(ServerEvent(server->name(), /* origin */ "", /* channel */ "",
 		[=] (Plugin &) -> std::string {
 			return "onWhois";
@@ -544,7 +512,6 @@
 			plugin.onWhois(m_irccd, std::move(server), std::move(whois));
 		}
 	));
-#endif
 }
 
 ServerService::ServerService(Irccd &irccd)