Mercurial > prosody-hg
comparison plugins/mod_console.lua @ 3718:f25b94ae645d
mod_console: Removed redundant code for host:activate() and host:deactivate(), now that hostmanager has error checking.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Thu, 09 Dec 2010 22:17:28 +0500 |
| parents | b7d5fe8eb829 |
| children | 26571a99f6e6 |
comparison
equal
deleted
inserted
replaced
| 3717:135128fdf565 | 3718:f25b94ae645d |
|---|---|
| 706 | 706 |
| 707 return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s"); | 707 return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s"); |
| 708 end | 708 end |
| 709 | 709 |
| 710 def_env.host = {}; def_env.hosts = def_env.host; | 710 def_env.host = {}; def_env.hosts = def_env.host; |
| 711 | |
| 711 function def_env.host:activate(hostname, config) | 712 function def_env.host:activate(hostname, config) |
| 712 local hostmanager_activate = require "core.hostmanager".activate; | 713 return hostmanager.activate(hostname, config); |
| 713 if hosts[hostname] then | 714 end |
| 714 return false, "The host "..tostring(hostname).." is already activated"; | |
| 715 end | |
| 716 | |
| 717 local defined_hosts = config or configmanager.getconfig(); | |
| 718 if not config and not defined_hosts[hostname] then | |
| 719 return false, "Couldn't find "..tostring(hostname).." defined in the config, perhaps you need to config:reload()?"; | |
| 720 end | |
| 721 hostmanager_activate(hostname, config or defined_hosts[hostname]); | |
| 722 return true, "Host "..tostring(hostname).." activated"; | |
| 723 end | |
| 724 | |
| 725 function def_env.host:deactivate(hostname, reason) | 715 function def_env.host:deactivate(hostname, reason) |
| 726 local hostmanager_deactivate = require "core.hostmanager".deactivate; | 716 return hostmanager.deactivate(hostname, reason); |
| 727 local host = hosts[hostname]; | |
| 728 if not host then | |
| 729 return false, "The host "..tostring(hostname).." is not activated"; | |
| 730 end | |
| 731 if reason then | |
| 732 reason = { condition = "host-gone", text = reason }; | |
| 733 end | |
| 734 hostmanager_deactivate(hostname, reason); | |
| 735 return true, "Host "..tostring(hostname).." deactivated"; | |
| 736 end | 717 end |
| 737 | 718 |
| 738 function def_env.host:list() | 719 function def_env.host:list() |
| 739 local print = self.session.print; | 720 local print = self.session.print; |
| 740 local i = 0; | 721 local i = 0; |
