diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Access/AccessModule.cs | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs new file mode 100644 index 0000000..dfa8df6 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs | |||
@@ -0,0 +1,158 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Console; | ||
36 | using OpenSim.Framework.Communications.Cache; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.World | ||
42 | { | ||
43 | public class AccessModule : ISharedRegionModule | ||
44 | { | ||
45 | private static readonly ILog m_log = | ||
46 | LogManager.GetLogger( | ||
47 | MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private List<Scene> m_SceneList = new List<Scene>(); | ||
50 | |||
51 | public void Initialise(IConfigSource config) | ||
52 | { | ||
53 | MainConsole.Instance.Commands.AddCommand("access", true, | ||
54 | "login enable", | ||
55 | "login enable", | ||
56 | "Enable simulator logins", | ||
57 | String.Empty, | ||
58 | HandleLoginCommand); | ||
59 | |||
60 | MainConsole.Instance.Commands.AddCommand("access", true, | ||
61 | "login disable", | ||
62 | "login disable", | ||
63 | "Disable simulator logins", | ||
64 | String.Empty, | ||
65 | HandleLoginCommand); | ||
66 | |||
67 | MainConsole.Instance.Commands.AddCommand("access", true, | ||
68 | "login status", | ||
69 | "login status", | ||
70 | "Show login status", | ||
71 | String.Empty, | ||
72 | HandleLoginCommand); | ||
73 | } | ||
74 | |||
75 | public void PostInitialise() | ||
76 | { | ||
77 | } | ||
78 | |||
79 | public void Close() | ||
80 | { | ||
81 | } | ||
82 | |||
83 | public string Name | ||
84 | { | ||
85 | get { return "AccessModule"; } | ||
86 | } | ||
87 | |||
88 | public Type ReplaceableInterface | ||
89 | { | ||
90 | get { return null; } | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_SceneList.Contains(scene)) | ||
96 | m_SceneList.Add(scene); | ||
97 | } | ||
98 | |||
99 | public void RemoveRegion(Scene scene) | ||
100 | { | ||
101 | m_SceneList.Remove(scene); | ||
102 | } | ||
103 | |||
104 | public void RegionLoaded(Scene scene) | ||
105 | { | ||
106 | } | ||
107 | |||
108 | public void HandleLoginCommand(string module, string[] cmd) | ||
109 | { | ||
110 | if ((Scene)MainConsole.Instance.ConsoleScene == null) | ||
111 | { | ||
112 | foreach (Scene s in m_SceneList) | ||
113 | { | ||
114 | if(!ProcessCommand(s, cmd)) | ||
115 | break; | ||
116 | } | ||
117 | } | ||
118 | else | ||
119 | { | ||
120 | ProcessCommand((Scene)MainConsole.Instance.ConsoleScene, cmd); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | bool ProcessCommand(Scene scene, string[] cmd) | ||
125 | { | ||
126 | if (cmd.Length < 2) | ||
127 | { | ||
128 | MainConsole.Instance.Output("Syntax: login enable|disable|status"); | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | switch (cmd[1]) | ||
133 | { | ||
134 | case "enable": | ||
135 | if (scene.LoginsDisabled) | ||
136 | MainConsole.Instance.Output(String.Format("Enabling logins for region {0}", scene.RegionInfo.RegionName)); | ||
137 | scene.LoginsDisabled = false; | ||
138 | break; | ||
139 | case "disable": | ||
140 | if (!scene.LoginsDisabled) | ||
141 | MainConsole.Instance.Output(String.Format("Disabling logins for region {0}", scene.RegionInfo.RegionName)); | ||
142 | scene.LoginsDisabled = true; | ||
143 | break; | ||
144 | case "status": | ||
145 | if (scene.LoginsDisabled) | ||
146 | MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName)); | ||
147 | else | ||
148 | MainConsole.Instance.Output(String.Format("Login in {0} are enabled", scene.RegionInfo.RegionName)); | ||
149 | break; | ||
150 | default: | ||
151 | MainConsole.Instance.Output("Syntax: login enable|disable|status"); | ||
152 | return false; | ||
153 | } | ||
154 | |||
155 | return true; | ||
156 | } | ||
157 | } | ||
158 | } | ||