aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2012-11-10 17:34:42 -0800
committerDiva Canto2012-11-10 17:34:42 -0800
commit562c585bc6fb1e659ab395089cf497a390f03b33 (patch)
treea09062e84e1844ee0140f617b9b4f987db21081b /OpenSim
parentOne more module converted: GesturesModule. (diff)
downloadopensim-SC-562c585bc6fb1e659ab395089cf497a390f03b33.zip
opensim-SC-562c585bc6fb1e659ab395089cf497a390f03b33.tar.gz
opensim-SC-562c585bc6fb1e659ab395089cf497a390f03b33.tar.bz2
opensim-SC-562c585bc6fb1e659ab395089cf497a390f03b33.tar.xz
One more module converted: GodsModule.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs68
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs6
2 files changed, 52 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 81ce268..2d3585a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using Nini.Config; 30using Nini.Config;
30using OpenMetaverse; 31using OpenMetaverse;
@@ -32,29 +33,59 @@ using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
34 35
36using Mono.Addins;
37
35namespace OpenSim.Region.CoreModules.Avatar.Gods 38namespace OpenSim.Region.CoreModules.Avatar.Gods
36{ 39{
37 public class GodsModule : IRegionModule, IGodsModule 40 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
41 public class GodsModule : INonSharedRegionModule, IGodsModule
38 { 42 {
39 /// <summary>Special UUID for actions that apply to all agents</summary> 43 /// <summary>Special UUID for actions that apply to all agents</summary>
40 private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); 44 private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb");
41 45
42 protected Scene m_scene; 46 protected Scene m_scene;
43 protected IDialogModule m_dialogModule; 47 protected IDialogModule m_dialogModule;
44 48 protected IDialogModule DialogModule
45 public void Initialise(Scene scene, IConfigSource source) 49 {
50 get
51 {
52 if (m_dialogModule == null)
53 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
54
55 return m_dialogModule;
56 }
57 }
58
59 public void Initialise(IConfigSource source)
60 {
61 }
62
63 public void AddRegion(Scene scene)
46 { 64 {
47 m_scene = scene; 65 m_scene = scene;
48 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
49 m_scene.RegisterModuleInterface<IGodsModule>(this); 66 m_scene.RegisterModuleInterface<IGodsModule>(this);
50 m_scene.EventManager.OnNewClient += SubscribeToClientEvents; 67 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
51 } 68 }
52 69
53 public void PostInitialise() {} 70 public void RemoveRegion(Scene scene)
71 {
72 m_scene.UnregisterModuleInterface<IGodsModule>(this);
73 m_scene.EventManager.OnNewClient -= SubscribeToClientEvents;
74 m_scene = null;
75 }
76
77 public void RegionLoaded(Scene scene)
78 {
79 }
80
54 public void Close() {} 81 public void Close() {}
55 public string Name { get { return "Gods Module"; } } 82 public string Name { get { return "Gods Module"; } }
56 public bool IsSharedModule { get { return false; } } 83
57 84 public Type ReplaceableInterface
85 {
86 get { return null; }
87 }
88
58 public void SubscribeToClientEvents(IClientAPI client) 89 public void SubscribeToClientEvents(IClientAPI client)
59 { 90 {
60 client.OnGodKickUser += KickUser; 91 client.OnGodKickUser += KickUser;
@@ -96,8 +127,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
96 } 127 }
97 else 128 else
98 { 129 {
99 if (m_dialogModule != null) 130 if (DialogModule != null)
100 m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied"); 131 DialogModule.SendAlertToUser(agentID, "Request for god powers denied");
101 } 132 }
102 } 133 }
103 } 134 }
@@ -121,7 +152,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
121 152
122 if (sp != null || agentID == kickUserID) 153 if (sp != null || agentID == kickUserID)
123 { 154 {
124 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
125 if (m_scene.Permissions.IsGod(godID)) 155 if (m_scene.Permissions.IsGod(godID))
126 { 156 {
127 if (kickflags == 0) 157 if (kickflags == 0)
@@ -163,27 +193,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
163 if (kickflags == 1) 193 if (kickflags == 1)
164 { 194 {
165 sp.AllowMovement = false; 195 sp.AllowMovement = false;
166 if (m_dialogModule != null) 196 if (DialogModule != null)
167 { 197 {
168 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); 198 DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
169 m_dialogModule.SendAlertToUser(godID, "User Frozen"); 199 DialogModule.SendAlertToUser(godID, "User Frozen");
170 } 200 }
171 } 201 }
172 202
173 if (kickflags == 2) 203 if (kickflags == 2)
174 { 204 {
175 sp.AllowMovement = true; 205 sp.AllowMovement = true;
176 if (m_dialogModule != null) 206 if (DialogModule != null)
177 { 207 {
178 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); 208 DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
179 m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); 209 DialogModule.SendAlertToUser(godID, "User Unfrozen");
180 } 210 }
181 } 211 }
182 } 212 }
183 else 213 else
184 { 214 {
185 if (m_dialogModule != null) 215 if (DialogModule != null)
186 m_dialogModule.SendAlertToUser(godID, "Kick request denied"); 216 DialogModule.SendAlertToUser(godID, "Kick request denied");
187 } 217 }
188 } 218 }
189 } 219 }
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 6d67b67..f9c1ac2 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -141,9 +141,9 @@ namespace OpenSim.Tests.Common
141 TestScene testScene = new TestScene( 141 TestScene testScene = new TestScene(
142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null); 142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null);
143 143
144 IRegionModule godsModule = new GodsModule(); 144 INonSharedRegionModule godsModule = new GodsModule();
145 godsModule.Initialise(testScene, new IniConfigSource()); 145 godsModule.Initialise(new IniConfigSource());
146 testScene.AddModule(godsModule.Name, godsModule); 146 godsModule.AddRegion(testScene);
147 147
148 // Add scene to services 148 // Add scene to services
149 m_assetService.AddRegion(testScene); 149 m_assetService.AddRegion(testScene);