aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/ServiceConnectorsOut/MuteList/LocalMuteListServiceConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/MuteList/LocalMuteListServiceConnector.cs')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/MuteList/LocalMuteListServiceConnector.cs180
1 files changed, 180 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..833d883
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MuteList/LocalMuteListServiceConnector.cs
@@ -0,0 +1,180 @@
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 log4net;
29using Mono.Addins;
30using Nini.Config;
31using System;
32using System.Collections.Generic;
33using System.Reflection;
34using OpenSim.Framework;
35using OpenSim.Server.Base;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces;
39using OpenMetaverse;
40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
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 IConfig moduleConfig = source.Configs["Modules"];
70
71 if (moduleConfig == null)
72 return;
73
74 string name = moduleConfig.GetString("MuteListService", "");
75 if(name != Name)
76 return;
77
78 IConfig userConfig = source.Configs["MuteListService"];
79 if (userConfig == null)
80 {
81 m_log.Error("[MuteList LOCALCONNECTOR]: MuteListService missing from configuration");
82 return;
83 }
84
85 string serviceDll = userConfig.GetString("LocalServiceModule",
86 String.Empty);
87
88 if (serviceDll == String.Empty)
89 {
90 m_log.Error("[MuteList LOCALCONNECTOR]: No LocalServiceModule named in section MuteListService");
91 return;
92 }
93
94 Object[] args = new Object[] { source };
95 try
96 {
97 m_service = ServerUtils.LoadPlugin<IMuteListService>(serviceDll, args);
98 }
99 catch
100 {
101 m_log.Error("[MuteList LOCALCONNECTOR]: Failed to load mute service");
102 return;
103 }
104
105 if (m_service == null)
106 {
107 m_log.Error("[MuteList LOCALCONNECTOR]: Can't load MuteList service");
108 return;
109 }
110
111 m_Enabled = true;
112 m_log.Info("[MuteList LOCALCONNECTOR]: enabled");
113 }
114
115 public void Close()
116 {
117 }
118
119 public void AddRegion(Scene scene)
120 {
121 if (!m_Enabled)
122 return;
123
124 lock(m_Scenes)
125 {
126 m_Scenes.Add(scene);
127 scene.RegisterModuleInterface<IMuteListService>(this);
128 }
129 }
130
131 public void RegionLoaded(Scene scene)
132 {
133 }
134
135 public void PostInitialise()
136 {
137 }
138
139 public void RemoveRegion(Scene scene)
140 {
141 if (!m_Enabled)
142 return;
143
144 lock(m_Scenes)
145 {
146 if (m_Scenes.Contains(scene))
147 {
148 m_Scenes.Remove(scene);
149 scene.UnregisterModuleInterface<IMuteListService>(this);
150 }
151 }
152 }
153
154 #endregion ISharedRegionModule
155
156 #region IMuteListService
157 public Byte[] MuteListRequest(UUID agentID, uint crc)
158 {
159 if (!m_Enabled)
160 return null;
161 return m_service.MuteListRequest(agentID, crc);
162 }
163
164 public bool UpdateMute(MuteData mute)
165 {
166 if (!m_Enabled)
167 return false;
168 return m_service.UpdateMute(mute);
169 }
170
171 public bool RemoveMute(UUID agentID, UUID muteID, string muteName)
172 {
173 if (!m_Enabled)
174 return false;
175 return m_service.RemoveMute(agentID, muteID, muteName);
176 }
177
178 #endregion IMuteListService
179 }
180}