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 | |
parent | increase sample rate of WaitGetScenePresence() (diff) | |
download | opensim-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
Diffstat (limited to 'OpenSim/Region/CoreModules')
3 files changed, 251 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 | { |
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 | |||
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.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 | } | ||