diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/MuteList/LocalMuteListServiceConnector.cs | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MuteList/LocalMuteListServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MuteList/LocalMuteListServiceConnector.cs new file mode 100644 index 0000000..37b30aa --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MuteList/LocalMuteListServiceConnector.cs | |||
@@ -0,0 +1,188 @@ | |||
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 log4net; | ||
29 | using Mono.Addins; | ||
30 | using Nini.Config; | ||
31 | using System; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Reflection; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MuteList | ||
42 | { | ||
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalMuteListServicesConnector")] | ||
44 | public class LocalMuteListServicesConnector : ISharedRegionModule, IMuteListService | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private List<Scene> m_Scenes = new List<Scene>(); | ||
51 | protected IMuteListService m_service = null; | ||
52 | |||
53 | private bool m_Enabled = false; | ||
54 | |||
55 | #region ISharedRegionModule | ||
56 | |||
57 | public Type ReplaceableInterface | ||
58 | { | ||
59 | get { return null; } | ||
60 | } | ||
61 | |||
62 | public string Name | ||
63 | { | ||
64 | get { return "LocalMuteListServicesConnector"; } | ||
65 | } | ||
66 | |||
67 | public void Initialise(IConfigSource source) | ||
68 | { | ||
69 | // only active for core mute lists module | ||
70 | IConfig moduleConfig = source.Configs["Messaging"]; | ||
71 | if (moduleConfig == null) | ||
72 | return; | ||
73 | |||
74 | if (moduleConfig.GetString("MuteListModule", "None") != "MuteListModuleTst") | ||
75 | return; | ||
76 | |||
77 | moduleConfig = source.Configs["Modules"]; | ||
78 | |||
79 | if (moduleConfig == null) | ||
80 | return; | ||
81 | |||
82 | string name = moduleConfig.GetString("MuteListService", ""); | ||
83 | if(name != Name) | ||
84 | return; | ||
85 | |||
86 | IConfig userConfig = source.Configs["MuteListService"]; | ||
87 | if (userConfig == null) | ||
88 | { | ||
89 | m_log.Error("[MuteList LOCALCONNECTOR]: MuteListService missing from configuration"); | ||
90 | return; | ||
91 | } | ||
92 | |||
93 | string serviceDll = userConfig.GetString("LocalServiceModule", | ||
94 | String.Empty); | ||
95 | |||
96 | if (serviceDll == String.Empty) | ||
97 | { | ||
98 | m_log.Error("[MuteList LOCALCONNECTOR]: No LocalServiceModule named in section MuteListService"); | ||
99 | return; | ||
100 | } | ||
101 | |||
102 | Object[] args = new Object[] { source }; | ||
103 | try | ||
104 | { | ||
105 | m_service = ServerUtils.LoadPlugin<IMuteListService>(serviceDll, args); | ||
106 | } | ||
107 | catch | ||
108 | { | ||
109 | m_log.Error("[MuteList LOCALCONNECTOR]: Failed to load mute service"); | ||
110 | return; | ||
111 | } | ||
112 | |||
113 | if (m_service == null) | ||
114 | { | ||
115 | m_log.Error("[MuteList LOCALCONNECTOR]: Can't load MuteList service"); | ||
116 | return; | ||
117 | } | ||
118 | |||
119 | m_Enabled = true; | ||
120 | m_log.Info("[MuteList LOCALCONNECTOR]: enabled"); | ||
121 | } | ||
122 | |||
123 | public void Close() | ||
124 | { | ||
125 | } | ||
126 | |||
127 | public void AddRegion(Scene scene) | ||
128 | { | ||
129 | if (!m_Enabled) | ||
130 | return; | ||
131 | |||
132 | lock(m_Scenes) | ||
133 | { | ||
134 | m_Scenes.Add(scene); | ||
135 | scene.RegisterModuleInterface<IMuteListService>(this); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | public void RegionLoaded(Scene scene) | ||
140 | { | ||
141 | } | ||
142 | |||
143 | public void PostInitialise() | ||
144 | { | ||
145 | } | ||
146 | |||
147 | public void RemoveRegion(Scene scene) | ||
148 | { | ||
149 | if (!m_Enabled) | ||
150 | return; | ||
151 | |||
152 | lock(m_Scenes) | ||
153 | { | ||
154 | if (m_Scenes.Contains(scene)) | ||
155 | { | ||
156 | m_Scenes.Remove(scene); | ||
157 | scene.UnregisterModuleInterface<IMuteListService>(this); | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | |||
162 | #endregion ISharedRegionModule | ||
163 | |||
164 | #region IMuteListService | ||
165 | public Byte[] MuteListRequest(UUID agentID, uint crc) | ||
166 | { | ||
167 | if (!m_Enabled) | ||
168 | return null; | ||
169 | return m_service.MuteListRequest(agentID, crc); | ||
170 | } | ||
171 | |||
172 | public bool UpdateMute(MuteData mute) | ||
173 | { | ||
174 | if (!m_Enabled) | ||
175 | return false; | ||
176 | return m_service.UpdateMute(mute); | ||
177 | } | ||
178 | |||
179 | public bool RemoveMute(UUID agentID, UUID muteID, string muteName) | ||
180 | { | ||
181 | if (!m_Enabled) | ||
182 | return false; | ||
183 | return m_service.RemoveMute(agentID, muteID, muteName); | ||
184 | } | ||
185 | |||
186 | #endregion IMuteListService | ||
187 | } | ||
188 | } | ||