aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2017-12-11 23:58:27 +0000
committerUbitUmarov2017-12-11 23:58:27 +0000
commitd32debe6184b1d6575b97541b98c520a8c4360c1 (patch)
tree5a11f277b6f7d45b859a3868379c517de590e0d2
parentincrease sample rate of WaitGetScenePresence() (diff)
downloadopensim-SC_OLD-d32debe6184b1d6575b97541b98c520a8c4360c1.zip
opensim-SC_OLD-d32debe6184b1d6575b97541b98c520a8c4360c1.tar.gz
opensim-SC_OLD-d32debe6184b1d6575b97541b98c520a8c4360c1.tar.bz2
opensim-SC_OLD-d32debe6184b1d6575b97541b98c520a8c4360c1.tar.xz
commit what i did so far for core mutes module, befere i lose it
-rw-r--r--OpenSim/Data/IMuteListData.cs44
-rw-r--r--OpenSim/Data/MySQL/MySQLMuteListData.cs67
-rw-r--r--OpenSim/Data/MySQL/Resources/MuteListStore.migrations16
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs135
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/MuteList/LocalMuteListServiceConnector.cs180
-rw-r--r--OpenSim/Services/Interfaces/IMuteLIstService.cs41
-rw-r--r--OpenSim/Services/MuteListService/MuteListService.cs127
8 files changed, 546 insertions, 69 deletions
diff --git a/OpenSim/Data/IMuteListData.cs b/OpenSim/Data/IMuteListData.cs
new file mode 100644
index 0000000..b0235b2
--- /dev/null
+++ b/OpenSim/Data/IMuteListData.cs
@@ -0,0 +1,44 @@
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 OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Data
34{
35 /// <summary>
36 /// An interface for connecting to the Mute List datastore
37 /// </summary>
38 public interface IMuteListData
39 {
40 bool Store(MuteData data);
41 MuteData[] Get(UUID agentID);
42 bool Delete(UUID agentID, UUID muteID, string muteName);
43 }
44}
diff --git a/OpenSim/Data/MySQL/MySQLMuteListData.cs b/OpenSim/Data/MySQL/MySQLMuteListData.cs
new file mode 100644
index 0000000..a5935a3
--- /dev/null
+++ b/OpenSim/Data/MySQL/MySQLMuteListData.cs
@@ -0,0 +1,67 @@
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;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34using MySql.Data.MySqlClient;
35
36namespace OpenSim.Data.MySQL
37{
38 public class MySqlMuteListData : MySQLGenericTableHandler<MuteData>, IMuteListData
39 {
40 public MySqlMuteListData(string connectionString)
41 : base(connectionString, "MuteList", "MuteListStore")
42 {
43 }
44
45 public MuteData[] Get(UUID agentID)
46 {
47 MuteData[] data = base.Get("AgentID", agentID.ToString());
48 return data;
49 }
50
51 public bool Delete(UUID agentID, UUID muteID, string muteName)
52 {
53 string cmnd ="delete from MuteList where AgentID = ?AgentID and MuteID = ?MuteID and MuteName = ?MuteName";
54
55 using (MySqlCommand cmd = new MySqlCommand(cmnd))
56 {
57 cmd.Parameters.AddWithValue("?AgentID", agentID.ToString());
58 cmd.Parameters.AddWithValue("?MuteID", muteID.ToString());
59 cmd.Parameters.AddWithValue("?MuteName", muteName);
60
61 if (ExecuteNonQuery(cmd) > 0)
62 return true;
63 return false;
64 }
65 }
66 }
67} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/Resources/MuteListStore.migrations b/OpenSim/Data/MySQL/Resources/MuteListStore.migrations
new file mode 100644
index 0000000..5bde63e
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/MuteListStore.migrations
@@ -0,0 +1,16 @@
1:VERSION 1
2
3BEGIN;
4
5CREATE TABLE `MuteList` (
6 `AgentID` char(36) NOT NULL,
7 `MuteID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
8 `MuteName` varchar(64) NOT NULL DEFAULT '',
9 `MuteType` int(11) NOT NULL DEFAULT '1',
10 `MuteFlags` int(11) NOT NULL DEFAULT '0',
11 `Stamp` int(11) NOT NULL,
12 UNIQUE KEY `AgentID_2` (`AgentID`,`MuteID`,`MuteName`),
13 KEY `AgentID` (`AgentID`)
14);
15
16COMMIT;
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs
index 7ade511..6857f35 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs
@@ -37,23 +37,21 @@ using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using Mono.Addins; 39using Mono.Addins;
40using OpenSim.Data; 40
41using OpenSim.Data.MySQL; 41using OpenSim.Server.Base;
42using MySql.Data.MySqlClient; 42using OpenSim.Services.Interfaces;
43using System.Security.Cryptography;
44 43
45namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 44namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
46{ 45{
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MuteListModuleTst")] 46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MuteListModuleTst")]
48 public class MuteModuleTst : ISharedRegionModule 47 public class MuteListModuleTst : ISharedRegionModule
49 { 48 {
50 private static readonly ILog m_log = LogManager.GetLogger( 49 private static readonly ILog m_log = LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType); 50 MethodBase.GetCurrentMethod().DeclaringType);
52 51
53 protected bool m_Enabled = false; 52 protected bool m_Enabled = false;
54 protected List<Scene> m_SceneList = new List<Scene>(); 53 protected List<Scene> m_SceneList = new List<Scene>();
55 protected MuteTableHandler m_MuteTable; 54 protected IMuteListService m_service = null;
56 protected string m_DatabaseConnect;
57 55
58 public void Initialise(IConfigSource config) 56 public void Initialise(IConfigSource config)
59 { 57 {
@@ -64,37 +62,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
64 if (cnf.GetString("MuteListModule", "None") != "MuteListModuleTst") 62 if (cnf.GetString("MuteListModule", "None") != "MuteListModuleTst")
65 return; 63 return;
66 64
67 m_DatabaseConnect = cnf.GetString("MuteDatabaseConnect", String.Empty);
68 if (m_DatabaseConnect == String.Empty)
69 {
70 m_log.Debug("[MuteModuleTst]: MuteDatabaseConnect missing or empty");
71 return;
72 }
73
74 try
75 {
76 m_MuteTable = new MuteTableHandler(m_DatabaseConnect, "XMute", String.Empty);
77 }
78 catch
79 {
80 m_log.Error("[MuteListModuleTst]: Failed to open/create database table");
81 return;
82 }
83
84 m_Enabled = true; 65 m_Enabled = true;
85 } 66 }
86 67
87 public void AddRegion(Scene scene) 68 public void AddRegion(Scene scene)
88 { 69 {
89 if (!m_Enabled)
90 return;
91
92 lock (m_SceneList)
93 {
94 m_SceneList.Add(scene);
95
96 scene.EventManager.OnNewClient += OnNewClient;
97 }
98 } 70 }
99 71
100 public void RegionLoaded(Scene scene) 72 public void RegionLoaded(Scene scene)
@@ -104,17 +76,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
104 76
105 IXfer xfer = scene.RequestModuleInterface<IXfer>(); 77 IXfer xfer = scene.RequestModuleInterface<IXfer>();
106 if (xfer == null) 78 if (xfer == null)
107 m_log.ErrorFormat("[MuteListModuleTst]: Xfer not availble in region {0}", scene.Name); 79 {
80 m_log.ErrorFormat("[MuteListModuleTst]: Xfer not availble in region {0}. Module Disabled", scene.Name);
81 m_Enabled = false;
82 return;
83 }
84
85 IMuteListService srv = scene.RequestModuleInterface<IMuteListService>();
86 if(srv == null)
87 {
88 m_log.ErrorFormat("[MuteListModuleTst]: MuteListService not availble in region {0}. Module Disabled", scene.Name);
89 m_Enabled = false;
90 return;
91 }
92 lock (m_SceneList)
93 {
94 if(m_service == null)
95 m_service = srv;
96 m_SceneList.Add(scene);
97 scene.EventManager.OnNewClient += OnNewClient;
98 }
108 } 99 }
109 100
110 public void RemoveRegion(Scene scene) 101 public void RemoveRegion(Scene scene)
111 { 102 {
112 if (!m_Enabled)
113 return;
114
115 lock (m_SceneList) 103 lock (m_SceneList)
116 { 104 {
117 m_SceneList.Remove(scene); 105 if(m_SceneList.Contains(scene))
106 {
107 m_SceneList.Remove(scene);
108 scene.EventManager.OnNewClient -= OnNewClient;
109 }
118 } 110 }
119 } 111 }
120 112
@@ -123,7 +115,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
123 if (!m_Enabled) 115 if (!m_Enabled)
124 return; 116 return;
125 117
126 m_log.Debug("[MuteListModuleTst]: Mute list enabled"); 118 m_log.Debug("[MuteListModuleTst]: enabled");
127 } 119 }
128 120
129 public string Name 121 public string Name
@@ -149,6 +141,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
149 141
150 private void OnMuteListRequest(IClientAPI client, uint crc) 142 private void OnMuteListRequest(IClientAPI client, uint crc)
151 { 143 {
144 if (!m_Enabled)
145 {
146 if(crc == 0)
147 client.SendEmpytMuteList();
148 else
149 client.SendUseCachedMuteList();
150 return;
151 }
152
152 IXfer xfer = client.Scene.RequestModuleInterface<IXfer>(); 153 IXfer xfer = client.Scene.RequestModuleInterface<IXfer>();
153 if (xfer == null) 154 if (xfer == null)
154 { 155 {
@@ -159,8 +160,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
159 return; 160 return;
160 } 161 }
161 162
162 MuteData[] data = m_MuteTable.Get("AgentID", client.AgentId.ToString()); 163 Byte[] data = m_service.MuteListRequest(client.AgentId, crc);
163 if (data == null || data.Length == 0) 164 if (data == null)
164 { 165 {
165 if(crc == 0) 166 if(crc == 0)
166 client.SendEmpytMuteList(); 167 client.SendEmpytMuteList();
@@ -169,20 +170,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
169 return; 170 return;
170 } 171 }
171 172
172 StringBuilder sb = new StringBuilder(16384); 173 if (data.Length == 0)
173 174 {
174 foreach (MuteData d in data) 175 client.SendEmpytMuteList();
175 sb.AppendFormat("{0} {1} {2}|{3}\n", 176 return;
176 d.MuteType, 177 }
177 d.MuteID.ToString(),
178 d.MuteName,
179 d.MuteFlags);
180
181 Byte[] filedata = Util.UTF8.GetBytes(sb.ToString());
182
183 uint dataCrc = Crc32.Compute(filedata);
184 178
185 if (dataCrc == crc) 179 if (data.Length == 1)
186 { 180 {
187 if(crc == 0) 181 if(crc == 0)
188 client.SendEmpytMuteList(); 182 client.SendEmpytMuteList();
@@ -191,33 +185,44 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
191 return; 185 return;
192 } 186 }
193 187
194 string filename = "mutes"+client.AgentId.ToString(); 188 string filename = "mutes" + client.AgentId.ToString();
195 xfer.AddNewFile(filename, filedata); 189 xfer.AddNewFile(filename, data);
196 client.SendMuteListUpdate(filename); 190 client.SendMuteListUpdate(filename);
197 } 191 }
198 192
199 private void OnUpdateMuteListEntry(IClientAPI client, UUID muteID, string muteName, int muteType, uint muteFlags) 193 private void OnUpdateMuteListEntry(IClientAPI client, UUID muteID, string muteName, int muteType, uint muteFlags)
200 { 194 {
201 MuteData mute = new MuteData(); 195 if (!m_Enabled)
196 return;
197
198 UUID agentID = client.AgentId;
199 if(muteType == 1) // agent
200 {
201 if(agentID == muteID)
202 return;
203 if(m_SceneList[0].Permissions.IsAdministrator(muteID))
204 {
205 OnMuteListRequest(client, 0);
206 return;
207 }
208 }
202 209
203 mute.AgentID = client.AgentId; 210 MuteData mute = new MuteData();
211 mute.AgentID = agentID;
204 mute.MuteID = muteID; 212 mute.MuteID = muteID;
205 mute.MuteName = muteName; 213 mute.MuteName = muteName;
206 mute.MuteType = muteType; 214 mute.MuteType = muteType;
207 mute.MuteFlags = (int)muteFlags; 215 mute.MuteFlags = (int)muteFlags;
208 mute.Stamp = Util.UnixTimeSinceEpoch(); 216 mute.Stamp = Util.UnixTimeSinceEpoch();
209 217
210 m_MuteTable.Store(mute); 218 m_service.UpdateMute(mute);
211 } 219 }
212 220
213 private void OnRemoveMuteListEntry(IClientAPI client, UUID muteID, string muteName) 221 private void OnRemoveMuteListEntry(IClientAPI client, UUID muteID, string muteName)
214 { 222 {
215 m_MuteTable.Delete(new string[] { "AgentID", 223 if (!m_Enabled)
216 "MuteID", 224 return;
217 "MuteName" }, 225 m_service.RemoveMute(client.AgentId, muteID, muteName);
218 new string[] { client.AgentId.ToString(),
219 muteID.ToString(),
220 muteName });
221 } 226 }
222 } 227 }
223} 228}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs
index ac542c2..b61e848 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs
@@ -32,15 +32,12 @@ using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
39using Mono.Addins; 37using Mono.Addins;
40using OpenSim.Data;
41using OpenSim.Data.MySQL; 38using OpenSim.Data.MySQL;
42using MySql.Data.MySqlClient; 39using MySql.Data.MySqlClient;
43using System.Security.Cryptography; 40
44 41
45namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 42namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
46{ 43{
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}
diff --git a/OpenSim/Services/Interfaces/IMuteLIstService.cs b/OpenSim/Services/Interfaces/IMuteLIstService.cs
new file mode 100644
index 0000000..9ffd47f
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IMuteLIstService.cs
@@ -0,0 +1,41 @@
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 OpenSim.Framework;
31using OpenMetaverse;
32
33namespace OpenSim.Services.Interfaces
34{
35 public interface IMuteListService
36 {
37 Byte[] MuteListRequest(UUID agent, uint crc);
38 bool UpdateMute(MuteData mute);
39 bool RemoveMute(UUID agentID, UUID muteID, string muteName);
40 }
41} \ No newline at end of file
diff --git a/OpenSim/Services/MuteListService/MuteListService.cs b/OpenSim/Services/MuteListService/MuteListService.cs
new file mode 100644
index 0000000..7e5ded1
--- /dev/null
+++ b/OpenSim/Services/MuteListService/MuteListService.cs
@@ -0,0 +1,127 @@
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.Text;
30using OpenMetaverse;
31using log4net;
32using Nini.Config;
33using OpenSim.Services.Base;
34using OpenSim.Services.Interfaces;
35using OpenSim.Data;
36using OpenSim.Framework;
37
38namespace OpenSim.Services.EstateService
39{
40 public class MuteListService : ServiceBase, IMuteListService
41 {
42// private static readonly ILog m_log =
43// LogManager.GetLogger(
44// MethodBase.GetCurrentMethod().DeclaringType);
45
46 protected IMuteListData m_database;
47
48 public MuteListService(IConfigSource config)
49 : base(config)
50 {
51 string dllName = String.Empty;
52 string connString = String.Empty;
53
54 // Try reading the [DatabaseService] section, if it exists
55 IConfig dbConfig = config.Configs["DatabaseService"];
56 if (dbConfig != null)
57 {
58 dllName = dbConfig.GetString("StorageProvider", String.Empty);
59 connString = dbConfig.GetString("ConnectionString", String.Empty);
60 connString = dbConfig.GetString("MuteConnectionString", connString);
61 }
62
63 // Try reading the [MuteListStore] section, if it exists
64 IConfig muteConfig = config.Configs["MuteListStore"];
65 if (muteConfig != null)
66 {
67 dllName = muteConfig.GetString("StorageProvider", dllName);
68 connString = muteConfig.GetString("ConnectionString", connString);
69 }
70
71 // We tried, but this doesn't exist. We can't proceed
72 if (dllName == String.Empty)
73 throw new Exception("No StorageProvider configured");
74
75 m_database = LoadPlugin<IMuteListData>(dllName, new Object[] { connString });
76 if (m_database == null)
77 throw new Exception("Could not find a storage interface in the given module");
78 }
79
80 public Byte[] MuteListRequest(UUID agentID, uint crc)
81 {
82 if(m_database == null)
83 return null;
84
85 MuteData[] data = m_database.Get(agentID);
86 if (data == null || data.Length == 0)
87 return new Byte[0];
88
89 StringBuilder sb = new StringBuilder(16384);
90 foreach (MuteData d in data)
91 sb.AppendFormat("{0} {1} {2}|{3}\n",
92 d.MuteType,
93 d.MuteID.ToString(),
94 d.MuteName,
95 d.MuteFlags);
96
97 Byte[] filedata = Util.UTF8.GetBytes(sb.ToString());
98
99 uint dataCrc = Crc32.Compute(filedata);
100
101 if (dataCrc == crc)
102 {
103 if(crc == 0)
104 return new Byte[0];
105
106 Byte[] ret = new Byte[1] {1};
107 return ret;
108 }
109
110 return filedata;
111 }
112
113 public bool UpdateMute(MuteData mute)
114 {
115 if(m_database == null)
116 return false;
117 return m_database.Store(mute);
118 }
119
120 public bool RemoveMute(UUID agentID, UUID muteID, string muteName)
121 {
122 if(m_database == null)
123 return false;
124 return m_database.Delete(agentID, muteID, muteName);
125 }
126 }
127}