aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Access/AccessModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Access/AccessModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/Access/AccessModule.cs157
1 files changed, 157 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..8b5a413
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs
@@ -0,0 +1,157 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces;
39
40namespace OpenSim.Region.CoreModules.World
41{
42 public class AccessModule : ISharedRegionModule
43 {
44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47
48 private List<Scene> m_SceneList = new List<Scene>();
49
50 public void Initialise(IConfigSource config)
51 {
52 MainConsole.Instance.Commands.AddCommand("access", true,
53 "login enable",
54 "login enable",
55 "Enable simulator logins",
56 String.Empty,
57 HandleLoginCommand);
58
59 MainConsole.Instance.Commands.AddCommand("access", true,
60 "login disable",
61 "login disable",
62 "Disable simulator logins",
63 String.Empty,
64 HandleLoginCommand);
65
66 MainConsole.Instance.Commands.AddCommand("access", true,
67 "login status",
68 "login status",
69 "Show login status",
70 String.Empty,
71 HandleLoginCommand);
72 }
73
74 public void PostInitialise()
75 {
76 }
77
78 public void Close()
79 {
80 }
81
82 public string Name
83 {
84 get { return "AccessModule"; }
85 }
86
87 public Type ReplaceableInterface
88 {
89 get { return null; }
90 }
91
92 public void AddRegion(Scene scene)
93 {
94 if (!m_SceneList.Contains(scene))
95 m_SceneList.Add(scene);
96 }
97
98 public void RemoveRegion(Scene scene)
99 {
100 m_SceneList.Remove(scene);
101 }
102
103 public void RegionLoaded(Scene scene)
104 {
105 }
106
107 public void HandleLoginCommand(string module, string[] cmd)
108 {
109 if ((Scene)MainConsole.Instance.ConsoleScene == null)
110 {
111 foreach (Scene s in m_SceneList)
112 {
113 if(!ProcessCommand(s, cmd))
114 break;
115 }
116 }
117 else
118 {
119 ProcessCommand((Scene)MainConsole.Instance.ConsoleScene, cmd);
120 }
121 }
122
123 bool ProcessCommand(Scene scene, string[] cmd)
124 {
125 if (cmd.Length < 2)
126 {
127 MainConsole.Instance.Output("Syntax: login enable|disable|status");
128 return false;
129 }
130
131 switch (cmd[1])
132 {
133 case "enable":
134 if (scene.LoginsDisabled)
135 MainConsole.Instance.Output(String.Format("Enabling logins for region {0}", scene.RegionInfo.RegionName));
136 scene.LoginsDisabled = false;
137 break;
138 case "disable":
139 if (!scene.LoginsDisabled)
140 MainConsole.Instance.Output(String.Format("Disabling logins for region {0}", scene.RegionInfo.RegionName));
141 scene.LoginsDisabled = true;
142 break;
143 case "status":
144 if (scene.LoginsDisabled)
145 MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName));
146 else
147 MainConsole.Instance.Output(String.Format("Login in {0} are enabled", scene.RegionInfo.RegionName));
148 break;
149 default:
150 MainConsole.Instance.Output("Syntax: login enable|disable|status");
151 return false;
152 }
153
154 return true;
155 }
156 }
157}