opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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 Mono.Addins; |
||
33 | using Nini.Config; |
||
34 | using OpenMetaverse; |
||
35 | using OpenSim.Framework; |
||
36 | using OpenSim.Framework.Console; |
||
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 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AccessModule")] |
||
44 | public class AccessModule : ISharedRegionModule |
||
45 | { |
||
46 | // private static readonly ILog m_log = LogManager.GetLogger(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("Users", true, |
||
53 | "login enable", |
||
54 | "login enable", |
||
55 | "Enable simulator logins", |
||
56 | String.Empty, |
||
57 | HandleLoginCommand); |
||
58 | |||
59 | MainConsole.Instance.Commands.AddCommand("Users", true, |
||
60 | "login disable", |
||
61 | "login disable", |
||
62 | "Disable simulator logins", |
||
63 | String.Empty, |
||
64 | HandleLoginCommand); |
||
65 | |||
66 | MainConsole.Instance.Commands.AddCommand("Users", 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 | scene.LoginsEnabled = true; |
||
135 | MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName)); |
||
136 | break; |
||
137 | case "disable": |
||
138 | scene.LoginsEnabled = false; |
||
139 | MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName)); |
||
140 | break; |
||
141 | case "status": |
||
142 | if (scene.LoginsEnabled) |
||
143 | MainConsole.Instance.Output(String.Format("Login in {0} are enabled", scene.RegionInfo.RegionName)); |
||
144 | else |
||
145 | MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName)); |
||
146 | break; |
||
147 | default: |
||
148 | MainConsole.Instance.Output("Syntax: login enable|disable|status"); |
||
149 | return false; |
||
150 | } |
||
151 | |||
152 | return true; |
||
153 | } |
||
154 | } |
||
155 | } |