diff options
author | UbitUmarov | 2017-12-11 23:58:27 +0000 |
---|---|---|
committer | UbitUmarov | 2017-12-11 23:58:27 +0000 |
commit | d32debe6184b1d6575b97541b98c520a8c4360c1 (patch) | |
tree | 5a11f277b6f7d45b859a3868379c517de590e0d2 /OpenSim/Region/CoreModules/Avatar/InstantMessage | |
parent | increase sample rate of WaitGetScenePresence() (diff) | |
download | opensim-SC-d32debe6184b1d6575b97541b98c520a8c4360c1.zip opensim-SC-d32debe6184b1d6575b97541b98c520a8c4360c1.tar.gz opensim-SC-d32debe6184b1d6575b97541b98c520a8c4360c1.tar.bz2 opensim-SC-d32debe6184b1d6575b97541b98c520a8c4360c1.tar.xz |
commit what i did so far for core mutes module, befere i lose it
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/InstantMessage')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs | 135 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs | 5 |
2 files changed, 71 insertions, 69 deletions
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; | |||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using Mono.Addins; | 39 | using Mono.Addins; |
40 | using OpenSim.Data; | 40 | |
41 | using OpenSim.Data.MySQL; | 41 | using OpenSim.Server.Base; |
42 | using MySql.Data.MySqlClient; | 42 | using OpenSim.Services.Interfaces; |
43 | using System.Security.Cryptography; | ||
44 | 43 | ||
45 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 44 | namespace 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; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Framework.Client; | ||
37 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
39 | using Mono.Addins; | 37 | using Mono.Addins; |
40 | using OpenSim.Data; | ||
41 | using OpenSim.Data.MySQL; | 38 | using OpenSim.Data.MySQL; |
42 | using MySql.Data.MySqlClient; | 39 | using MySql.Data.MySqlClient; |
43 | using System.Security.Cryptography; | 40 | |
44 | 41 | ||
45 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 42 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
46 | { | 43 | { |