diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
6 files changed, 162 insertions, 511 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 9f52a14..39443c3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -306,7 +306,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
306 | m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name); | 306 | m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name); |
307 | 307 | ||
308 | XmlDocument doc = new XmlDocument(); | 308 | XmlDocument doc = new XmlDocument(); |
309 | doc.XmlResolver=null; | ||
310 | string stateData = String.Empty; | 309 | string stateData = String.Empty; |
311 | 310 | ||
312 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | 311 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); |
@@ -369,11 +368,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
369 | { | 368 | { |
370 | string xmlData; | 369 | string xmlData; |
371 | XmlDocument d = null; | 370 | XmlDocument d = null; |
372 | UUID asset; | 371 | |
373 | if (itemData.TryGetValue(attach.ItemID, out xmlData)) | 372 | if (itemData.TryGetValue(attach.ItemID, out xmlData)) |
374 | { | 373 | { |
375 | d = new XmlDocument(); | 374 | d = new XmlDocument(); |
376 | d.XmlResolver=null; | ||
377 | d.LoadXml(xmlData); | 375 | d.LoadXml(xmlData); |
378 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID); | 376 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID); |
379 | } | 377 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs index 61e461a..cfa9581 100644 --- a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs | |||
@@ -124,8 +124,6 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
124 | { | 124 | { |
125 | using(XmlTextReader sr = new XmlTextReader(s)) | 125 | using(XmlTextReader sr = new XmlTextReader(s)) |
126 | { | 126 | { |
127 | sr.ProhibitDtd = true; | ||
128 | |||
129 | sr.ReadStartElement("BakedAppearance"); | 127 | sr.ReadStartElement("BakedAppearance"); |
130 | while(sr.LocalName == "BakedTexture") | 128 | while(sr.LocalName == "BakedTexture") |
131 | { | 129 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs index 2d57193..9cbfd4a 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs | |||
@@ -27,86 +27,99 @@ | |||
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Text; | ||
30 | using log4net; | 31 | using log4net; |
31 | using Nini.Config; | 32 | using Nini.Config; |
32 | using Mono.Addins; | ||
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
36 | using OpenSim.Framework.Client; | 36 | 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; | ||
40 | |||
41 | using OpenSim.Server.Base; | ||
42 | using OpenSim.Services.Interfaces; | ||
39 | 43 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 44 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
41 | { | 45 | { |
42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MuteListModule")] | 46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MuteListModule")] |
43 | public class MuteListModule : ISharedRegionModule | 47 | public class MuteListModule : ISharedRegionModule |
44 | { | 48 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger( |
50 | MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | 51 | ||
47 | private bool enabled = true; | 52 | protected bool m_Enabled = false; |
48 | private List<Scene> m_SceneList = new List<Scene>(); | 53 | protected List<Scene> m_SceneList = new List<Scene>(); |
49 | private string m_RestURL = String.Empty; | 54 | protected IMuteListService m_service = null; |
55 | private IUserManagement m_userManagementModule; | ||
50 | 56 | ||
51 | public void Initialise(IConfigSource config) | 57 | public void Initialise(IConfigSource config) |
52 | { | 58 | { |
53 | IConfig cnf = config.Configs["Messaging"]; | 59 | IConfig cnf = config.Configs["Messaging"]; |
54 | if (cnf == null) | 60 | if (cnf == null) |
55 | { | ||
56 | enabled = false; | ||
57 | return; | 61 | return; |
58 | } | ||
59 | 62 | ||
60 | if (cnf != null && cnf.GetString("MuteListModule", "None") != | 63 | if (cnf.GetString("MuteListModule", "None") != "MuteListModule") |
61 | "MuteListModule") | ||
62 | { | ||
63 | enabled = false; | ||
64 | return; | 64 | return; |
65 | } | ||
66 | 65 | ||
67 | m_RestURL = cnf.GetString("MuteListURL", ""); | 66 | m_Enabled = true; |
68 | if (m_RestURL == "") | ||
69 | { | ||
70 | m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); | ||
71 | enabled = false; | ||
72 | return; | ||
73 | } | ||
74 | } | 67 | } |
75 | 68 | ||
76 | public void AddRegion(Scene scene) | 69 | public void AddRegion(Scene scene) |
77 | { | 70 | { |
78 | if (!enabled) | 71 | } |
72 | |||
73 | public void RegionLoaded(Scene scene) | ||
74 | { | ||
75 | if (!m_Enabled) | ||
76 | return; | ||
77 | |||
78 | IXfer xfer = scene.RequestModuleInterface<IXfer>(); | ||
79 | if (xfer == null) | ||
80 | { | ||
81 | m_log.ErrorFormat("[MuteListModule]: Xfer not availble in region {0}. Module Disabled", scene.Name); | ||
82 | m_Enabled = false; | ||
83 | return; | ||
84 | } | ||
85 | |||
86 | IMuteListService srv = scene.RequestModuleInterface<IMuteListService>(); | ||
87 | if(srv == null) | ||
88 | { | ||
89 | m_log.ErrorFormat("[MuteListModule]: MuteListService not availble in region {0}. Module Disabled", scene.Name); | ||
90 | m_Enabled = false; | ||
79 | return; | 91 | return; |
92 | } | ||
80 | 93 | ||
81 | lock (m_SceneList) | 94 | lock (m_SceneList) |
82 | { | 95 | { |
96 | if(m_service == null) | ||
97 | m_service = srv; | ||
98 | if(m_userManagementModule == null) | ||
99 | m_userManagementModule = scene.RequestModuleInterface<IUserManagement>(); | ||
83 | m_SceneList.Add(scene); | 100 | m_SceneList.Add(scene); |
84 | |||
85 | scene.EventManager.OnNewClient += OnNewClient; | 101 | scene.EventManager.OnNewClient += OnNewClient; |
86 | } | 102 | } |
87 | } | 103 | } |
88 | 104 | ||
89 | public void RegionLoaded(Scene scene) | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void RemoveRegion(Scene scene) | 105 | public void RemoveRegion(Scene scene) |
94 | { | 106 | { |
95 | if (!enabled) | ||
96 | return; | ||
97 | |||
98 | lock (m_SceneList) | 107 | lock (m_SceneList) |
99 | { | 108 | { |
100 | m_SceneList.Remove(scene); | 109 | if(m_SceneList.Contains(scene)) |
110 | { | ||
111 | m_SceneList.Remove(scene); | ||
112 | scene.EventManager.OnNewClient -= OnNewClient; | ||
113 | } | ||
101 | } | 114 | } |
102 | } | 115 | } |
103 | 116 | ||
104 | public void PostInitialise() | 117 | public void PostInitialise() |
105 | { | 118 | { |
106 | if (!enabled) | 119 | if (!m_Enabled) |
107 | return; | 120 | return; |
108 | 121 | ||
109 | m_log.Debug("[MUTE LIST] Mute list enabled"); | 122 | m_log.Debug("[MuteListModule]: enabled"); |
110 | } | 123 | } |
111 | 124 | ||
112 | public string Name | 125 | public string Name |
@@ -118,27 +131,110 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
118 | { | 131 | { |
119 | get { return null; } | 132 | get { return null; } |
120 | } | 133 | } |
121 | 134 | ||
122 | public void Close() | 135 | public void Close() |
123 | { | 136 | { |
124 | } | 137 | } |
125 | 138 | ||
139 | private bool IsForeign(IClientAPI client) | ||
140 | { | ||
141 | if(m_userManagementModule == null) | ||
142 | return false; // we can't check | ||
143 | |||
144 | return !m_userManagementModule.IsLocalGridUser(client.AgentId); | ||
145 | } | ||
146 | |||
126 | private void OnNewClient(IClientAPI client) | 147 | private void OnNewClient(IClientAPI client) |
127 | { | 148 | { |
128 | client.OnMuteListRequest += OnMuteListRequest; | 149 | client.OnMuteListRequest += OnMuteListRequest; |
150 | client.OnUpdateMuteListEntry += OnUpdateMuteListEntry; | ||
151 | client.OnRemoveMuteListEntry += OnRemoveMuteListEntry; | ||
129 | } | 152 | } |
130 | 153 | ||
131 | private void OnMuteListRequest(IClientAPI client, uint crc) | 154 | private void OnMuteListRequest(IClientAPI client, uint crc) |
132 | { | 155 | { |
133 | m_log.DebugFormat("[MUTE LIST] Got mute list request for crc {0}", crc); | 156 | if (!m_Enabled || IsForeign(client)) |
134 | string filename = "mutes"+client.AgentId.ToString(); | 157 | { |
158 | if(crc == 0) | ||
159 | client.SendEmpytMuteList(); | ||
160 | else | ||
161 | client.SendUseCachedMuteList(); | ||
162 | return; | ||
163 | } | ||
135 | 164 | ||
136 | IXfer xfer = client.Scene.RequestModuleInterface<IXfer>(); | 165 | IXfer xfer = client.Scene.RequestModuleInterface<IXfer>(); |
137 | if (xfer != null) | 166 | if (xfer == null) |
167 | { | ||
168 | if(crc == 0) | ||
169 | client.SendEmpytMuteList(); | ||
170 | else | ||
171 | client.SendUseCachedMuteList(); | ||
172 | return; | ||
173 | } | ||
174 | |||
175 | Byte[] data = m_service.MuteListRequest(client.AgentId, crc); | ||
176 | if (data == null) | ||
177 | { | ||
178 | if(crc == 0) | ||
179 | client.SendEmpytMuteList(); | ||
180 | else | ||
181 | client.SendUseCachedMuteList(); | ||
182 | return; | ||
183 | } | ||
184 | |||
185 | if (data.Length == 0) | ||
186 | { | ||
187 | client.SendEmpytMuteList(); | ||
188 | return; | ||
189 | } | ||
190 | |||
191 | if (data.Length == 1) | ||
192 | { | ||
193 | if(crc == 0) | ||
194 | client.SendEmpytMuteList(); | ||
195 | else | ||
196 | client.SendUseCachedMuteList(); | ||
197 | return; | ||
198 | } | ||
199 | |||
200 | string filename = "mutes" + client.AgentId.ToString(); | ||
201 | xfer.AddNewFile(filename, data); | ||
202 | client.SendMuteListUpdate(filename); | ||
203 | } | ||
204 | |||
205 | private void OnUpdateMuteListEntry(IClientAPI client, UUID muteID, string muteName, int muteType, uint muteFlags) | ||
206 | { | ||
207 | if (!m_Enabled || IsForeign(client)) | ||
208 | return; | ||
209 | |||
210 | UUID agentID = client.AgentId; | ||
211 | if(muteType == 1) // agent | ||
138 | { | 212 | { |
139 | xfer.AddNewFile(filename, new Byte[0]); | 213 | if(agentID == muteID) |
140 | client.SendMuteListUpdate(filename); | 214 | return; |
215 | if(m_SceneList[0].Permissions.IsAdministrator(muteID)) | ||
216 | { | ||
217 | OnMuteListRequest(client, 0); | ||
218 | return; | ||
219 | } | ||
141 | } | 220 | } |
221 | |||
222 | MuteData mute = new MuteData(); | ||
223 | mute.AgentID = agentID; | ||
224 | mute.MuteID = muteID; | ||
225 | mute.MuteName = muteName; | ||
226 | mute.MuteType = muteType; | ||
227 | mute.MuteFlags = (int)muteFlags; | ||
228 | mute.Stamp = Util.UnixTimeSinceEpoch(); | ||
229 | |||
230 | m_service.UpdateMute(mute); | ||
231 | } | ||
232 | |||
233 | private void OnRemoveMuteListEntry(IClientAPI client, UUID muteID, string muteName) | ||
234 | { | ||
235 | if (!m_Enabled || IsForeign(client)) | ||
236 | return; | ||
237 | m_service.RemoveMute(client.AgentId, muteID, muteName); | ||
142 | } | 238 | } |
143 | } | 239 | } |
144 | } | 240 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs deleted file mode 100644 index 6857f35..0000000 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs +++ /dev/null | |||
@@ -1,229 +0,0 @@ | |||
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 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using System.Text; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Framework.Client; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using Mono.Addins; | ||
40 | |||
41 | using OpenSim.Server.Base; | ||
42 | using OpenSim.Services.Interfaces; | ||
43 | |||
44 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | ||
45 | { | ||
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MuteListModuleTst")] | ||
47 | public class MuteListModuleTst : ISharedRegionModule | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger( | ||
50 | MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | protected bool m_Enabled = false; | ||
53 | protected List<Scene> m_SceneList = new List<Scene>(); | ||
54 | protected IMuteListService m_service = null; | ||
55 | |||
56 | public void Initialise(IConfigSource config) | ||
57 | { | ||
58 | IConfig cnf = config.Configs["Messaging"]; | ||
59 | if (cnf == null) | ||
60 | return; | ||
61 | |||
62 | if (cnf.GetString("MuteListModule", "None") != "MuteListModuleTst") | ||
63 | return; | ||
64 | |||
65 | m_Enabled = true; | ||
66 | } | ||
67 | |||
68 | public void AddRegion(Scene scene) | ||
69 | { | ||
70 | } | ||
71 | |||
72 | public void RegionLoaded(Scene scene) | ||
73 | { | ||
74 | if (!m_Enabled) | ||
75 | return; | ||
76 | |||
77 | IXfer xfer = scene.RequestModuleInterface<IXfer>(); | ||
78 | if (xfer == null) | ||
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 | } | ||
99 | } | ||
100 | |||
101 | public void RemoveRegion(Scene scene) | ||
102 | { | ||
103 | lock (m_SceneList) | ||
104 | { | ||
105 | if(m_SceneList.Contains(scene)) | ||
106 | { | ||
107 | m_SceneList.Remove(scene); | ||
108 | scene.EventManager.OnNewClient -= OnNewClient; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | public void PostInitialise() | ||
114 | { | ||
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | m_log.Debug("[MuteListModuleTst]: enabled"); | ||
119 | } | ||
120 | |||
121 | public string Name | ||
122 | { | ||
123 | get { return "MuteListModuleTst"; } | ||
124 | } | ||
125 | |||
126 | public Type ReplaceableInterface | ||
127 | { | ||
128 | get { return null; } | ||
129 | } | ||
130 | |||
131 | public void Close() | ||
132 | { | ||
133 | } | ||
134 | |||
135 | private void OnNewClient(IClientAPI client) | ||
136 | { | ||
137 | client.OnMuteListRequest += OnMuteListRequest; | ||
138 | client.OnUpdateMuteListEntry += OnUpdateMuteListEntry; | ||
139 | client.OnRemoveMuteListEntry += OnRemoveMuteListEntry; | ||
140 | } | ||
141 | |||
142 | private void OnMuteListRequest(IClientAPI client, uint crc) | ||
143 | { | ||
144 | if (!m_Enabled) | ||
145 | { | ||
146 | if(crc == 0) | ||
147 | client.SendEmpytMuteList(); | ||
148 | else | ||
149 | client.SendUseCachedMuteList(); | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | IXfer xfer = client.Scene.RequestModuleInterface<IXfer>(); | ||
154 | if (xfer == null) | ||
155 | { | ||
156 | if(crc == 0) | ||
157 | client.SendEmpytMuteList(); | ||
158 | else | ||
159 | client.SendUseCachedMuteList(); | ||
160 | return; | ||
161 | } | ||
162 | |||
163 | Byte[] data = m_service.MuteListRequest(client.AgentId, crc); | ||
164 | if (data == null) | ||
165 | { | ||
166 | if(crc == 0) | ||
167 | client.SendEmpytMuteList(); | ||
168 | else | ||
169 | client.SendUseCachedMuteList(); | ||
170 | return; | ||
171 | } | ||
172 | |||
173 | if (data.Length == 0) | ||
174 | { | ||
175 | client.SendEmpytMuteList(); | ||
176 | return; | ||
177 | } | ||
178 | |||
179 | if (data.Length == 1) | ||
180 | { | ||
181 | if(crc == 0) | ||
182 | client.SendEmpytMuteList(); | ||
183 | else | ||
184 | client.SendUseCachedMuteList(); | ||
185 | return; | ||
186 | } | ||
187 | |||
188 | string filename = "mutes" + client.AgentId.ToString(); | ||
189 | xfer.AddNewFile(filename, data); | ||
190 | client.SendMuteListUpdate(filename); | ||
191 | } | ||
192 | |||
193 | private void OnUpdateMuteListEntry(IClientAPI client, UUID muteID, string muteName, int muteType, uint muteFlags) | ||
194 | { | ||
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 | } | ||
209 | |||
210 | MuteData mute = new MuteData(); | ||
211 | mute.AgentID = agentID; | ||
212 | mute.MuteID = muteID; | ||
213 | mute.MuteName = muteName; | ||
214 | mute.MuteType = muteType; | ||
215 | mute.MuteFlags = (int)muteFlags; | ||
216 | mute.Stamp = Util.UnixTimeSinceEpoch(); | ||
217 | |||
218 | m_service.UpdateMute(mute); | ||
219 | } | ||
220 | |||
221 | private void OnRemoveMuteListEntry(IClientAPI client, UUID muteID, string muteName) | ||
222 | { | ||
223 | if (!m_Enabled) | ||
224 | return; | ||
225 | m_service.RemoveMute(client.AgentId, muteID, muteName); | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs deleted file mode 100644 index b61e848..0000000 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs +++ /dev/null | |||
@@ -1,239 +0,0 @@ | |||
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 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using System.Text; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using Mono.Addins; | ||
38 | using OpenSim.Data.MySQL; | ||
39 | using MySql.Data.MySqlClient; | ||
40 | |||
41 | |||
42 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | ||
43 | { | ||
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XMute")] | ||
45 | public class XMuteModule : ISharedRegionModule | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | protected bool m_Enabled = true; | ||
51 | protected List<Scene> m_SceneList = new List<Scene>(); | ||
52 | protected MuteTableHandler m_MuteTable; | ||
53 | protected string m_DatabaseConnect; | ||
54 | |||
55 | public void Initialise(IConfigSource config) | ||
56 | { | ||
57 | IConfig cnf = config.Configs["Messaging"]; | ||
58 | if (cnf == null) | ||
59 | { | ||
60 | m_Enabled = false; | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | if (cnf.GetString("MuteListModule", "None") != | ||
65 | "XMute") | ||
66 | { | ||
67 | m_Enabled = false; | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | m_DatabaseConnect = cnf.GetString("MuteDatabaseConnect", String.Empty); | ||
72 | if (m_DatabaseConnect == String.Empty) | ||
73 | { | ||
74 | m_log.Debug("[XMute]: MuteDatabaseConnect missing or empty"); | ||
75 | m_Enabled = false; | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | m_MuteTable = new MuteTableHandler( | ||
80 | m_DatabaseConnect, "XMute", String.Empty); | ||
81 | } | ||
82 | |||
83 | public void AddRegion(Scene scene) | ||
84 | { | ||
85 | if (!m_Enabled) | ||
86 | return; | ||
87 | |||
88 | lock (m_SceneList) | ||
89 | { | ||
90 | m_SceneList.Add(scene); | ||
91 | |||
92 | scene.EventManager.OnNewClient += OnNewClient; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public void RegionLoaded(Scene scene) | ||
97 | { | ||
98 | } | ||
99 | |||
100 | public void RemoveRegion(Scene scene) | ||
101 | { | ||
102 | if (!m_Enabled) | ||
103 | return; | ||
104 | |||
105 | lock (m_SceneList) | ||
106 | { | ||
107 | m_SceneList.Remove(scene); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | public void PostInitialise() | ||
112 | { | ||
113 | if (!m_Enabled) | ||
114 | return; | ||
115 | |||
116 | m_log.Debug("[XMute]: Mute list enabled"); | ||
117 | } | ||
118 | |||
119 | public string Name | ||
120 | { | ||
121 | get { return "XMuteModule"; } | ||
122 | } | ||
123 | |||
124 | public Type ReplaceableInterface | ||
125 | { | ||
126 | get { return null; } | ||
127 | } | ||
128 | |||
129 | public void Close() | ||
130 | { | ||
131 | } | ||
132 | |||
133 | private void OnNewClient(IClientAPI client) | ||
134 | { | ||
135 | client.OnMuteListRequest += OnMuteListRequest; | ||
136 | client.OnUpdateMuteListEntry += OnUpdateMuteListEntry; | ||
137 | client.OnRemoveMuteListEntry += OnRemoveMuteListEntry; | ||
138 | } | ||
139 | |||
140 | private void OnMuteListRequest(IClientAPI client, uint crc) | ||
141 | { | ||
142 | string filename = "mutes"+client.AgentId.ToString(); | ||
143 | |||
144 | IXfer xfer = client.Scene.RequestModuleInterface<IXfer>(); | ||
145 | if (xfer != null) | ||
146 | { | ||
147 | MuteData[] data = m_MuteTable.Get("AgentID", client.AgentId.ToString()); | ||
148 | if (data == null || data.Length == 0) | ||
149 | { | ||
150 | xfer.AddNewFile(filename, new Byte[0]); | ||
151 | } | ||
152 | else | ||
153 | { | ||
154 | StringBuilder sb = new StringBuilder(1024); | ||
155 | |||
156 | foreach (MuteData d in data) | ||
157 | sb.AppendFormat("{0} {1} {2}|{3}\n", | ||
158 | d.MuteType, | ||
159 | d.MuteID.ToString(), | ||
160 | d.MuteName, | ||
161 | d.MuteFlags); | ||
162 | |||
163 | Byte[] filedata = Util.UTF8.GetBytes(sb.ToString()); | ||
164 | |||
165 | uint dataCrc = Crc32.Compute(filedata); | ||
166 | |||
167 | if (dataCrc == crc) | ||
168 | { | ||
169 | client.SendUseCachedMuteList(); | ||
170 | return; | ||
171 | } | ||
172 | |||
173 | xfer.AddNewFile(filename, filedata); | ||
174 | } | ||
175 | |||
176 | client.SendMuteListUpdate(filename); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | private void OnUpdateMuteListEntry(IClientAPI client, UUID muteID, string muteName, int muteType, uint muteFlags) | ||
181 | { | ||
182 | MuteData mute = new MuteData(); | ||
183 | |||
184 | mute.AgentID = client.AgentId; | ||
185 | mute.MuteID = muteID; | ||
186 | mute.MuteName = muteName; | ||
187 | mute.MuteType = muteType; | ||
188 | mute.MuteFlags = (int)muteFlags; | ||
189 | mute.Stamp = Util.UnixTimeSinceEpoch(); | ||
190 | |||
191 | m_MuteTable.Store(mute); | ||
192 | } | ||
193 | |||
194 | private void OnRemoveMuteListEntry(IClientAPI client, UUID muteID, string muteName) | ||
195 | { | ||
196 | m_MuteTable.Delete(new string[] { "AgentID", | ||
197 | "MuteID", | ||
198 | "MuteName" }, | ||
199 | new string[] { client.AgentId.ToString(), | ||
200 | muteID.ToString(), | ||
201 | muteName }); | ||
202 | } | ||
203 | } | ||
204 | |||
205 | public class MuteTableHandler : MySQLGenericTableHandler<MuteData> | ||
206 | { | ||
207 | public MuteTableHandler(string conn, string realm, string m) : base(conn, realm, m) | ||
208 | { | ||
209 | } | ||
210 | |||
211 | public bool Delete(string[] fields, string[] val) | ||
212 | { | ||
213 | if (fields.Length != val.Length) | ||
214 | return false; | ||
215 | |||
216 | using (MySqlCommand cmd = new MySqlCommand()) | ||
217 | { | ||
218 | string text = String.Format("delete from {0} where ", m_Realm); | ||
219 | |||
220 | List<string> terms = new List<string>(); | ||
221 | |||
222 | for (int i = 0 ; i < fields.Length ; i++) | ||
223 | { | ||
224 | terms.Add(String.Format("{0} = ?{0}", fields[i])); | ||
225 | cmd.Parameters.AddWithValue("?" + fields[i], val[i]); | ||
226 | } | ||
227 | |||
228 | text += string.Join(" and ", terms.ToArray()); | ||
229 | |||
230 | cmd.CommandText = text; | ||
231 | |||
232 | if (ExecuteNonQuery(cmd) > 0) | ||
233 | return true; | ||
234 | return false; | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | |||
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index e02ca49..22984ef 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | |||
@@ -71,6 +71,9 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
71 | ExpiringCache<UUID, UserProfileCacheEntry> m_profilesCache = new ExpiringCache<UUID, UserProfileCacheEntry>(); | 71 | ExpiringCache<UUID, UserProfileCacheEntry> m_profilesCache = new ExpiringCache<UUID, UserProfileCacheEntry>(); |
72 | IAssetCache m_assetCache; | 72 | IAssetCache m_assetCache; |
73 | 73 | ||
74 | static readonly UUID m_MrOpenSimID = new UUID("11111111-1111-0000-0000-000100bba000"); | ||
75 | static readonly DateTime m_MrOpenSimBorn = new DateTime(2007,1,1,0,0,0,DateTimeKind.Utc); | ||
76 | |||
74 | private JsonRpcRequestManager rpc = new JsonRpcRequestManager(); | 77 | private JsonRpcRequestManager rpc = new JsonRpcRequestManager(); |
75 | private bool m_allowUserProfileWebURLs = true; | 78 | private bool m_allowUserProfileWebURLs = true; |
76 | 79 | ||
@@ -355,6 +358,12 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
355 | if(!UUID.TryParse(args[0], out targetID) || targetID == UUID.Zero) | 358 | if(!UUID.TryParse(args[0], out targetID) || targetID == UUID.Zero) |
356 | return; | 359 | return; |
357 | 360 | ||
361 | if (targetID == m_MrOpenSimID) | ||
362 | { | ||
363 | remoteClient.SendAvatarClassifiedReply(targetID, classifieds); | ||
364 | return; | ||
365 | } | ||
366 | |||
358 | ScenePresence p = FindPresence(targetID); | 367 | ScenePresence p = FindPresence(targetID); |
359 | if (p != null && p.IsNPC) | 368 | if (p != null && p.IsNPC) |
360 | { | 369 | { |
@@ -750,6 +759,12 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
750 | 759 | ||
751 | Dictionary<UUID, string> picks = new Dictionary<UUID, string>(); | 760 | Dictionary<UUID, string> picks = new Dictionary<UUID, string>(); |
752 | 761 | ||
762 | if (targetId == m_MrOpenSimID) | ||
763 | { | ||
764 | remoteClient.SendAvatarPicksReply(targetId, picks); | ||
765 | return; | ||
766 | } | ||
767 | |||
753 | ScenePresence p = FindPresence(targetId); | 768 | ScenePresence p = FindPresence(targetId); |
754 | if (p != null && p.IsNPC) | 769 | if (p != null && p.IsNPC) |
755 | { | 770 | { |
@@ -1164,6 +1179,9 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1164 | /// </param> | 1179 | /// </param> |
1165 | public void NotesUpdate(IClientAPI remoteClient, UUID queryTargetID, string queryNotes) | 1180 | public void NotesUpdate(IClientAPI remoteClient, UUID queryTargetID, string queryNotes) |
1166 | { | 1181 | { |
1182 | if (queryTargetID == m_MrOpenSimID) | ||
1183 | return; | ||
1184 | |||
1167 | ScenePresence p = FindPresence(queryTargetID); | 1185 | ScenePresence p = FindPresence(queryTargetID); |
1168 | if (p != null && p.IsNPC) | 1186 | if (p != null && p.IsNPC) |
1169 | { | 1187 | { |
@@ -1328,6 +1346,15 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1328 | return; | 1346 | return; |
1329 | } | 1347 | } |
1330 | 1348 | ||
1349 | if (avatarID == m_MrOpenSimID) | ||
1350 | { | ||
1351 | remoteClient.SendAvatarProperties(avatarID, "Creator of OpenSimulator shared assets library", m_MrOpenSimBorn.ToString(), | ||
1352 | Utils.StringToBytes("System agent"), "MrOpenSim has no life", 0x10, | ||
1353 | UUID.Zero, UUID.Zero, "", UUID.Zero); | ||
1354 | remoteClient.SendAvatarInterestsReply(avatarID, 0, "", | ||
1355 | 0, "Getting into trouble", "Droidspeak"); | ||
1356 | return; | ||
1357 | } | ||
1331 | ScenePresence p = FindPresence(avatarID); | 1358 | ScenePresence p = FindPresence(avatarID); |
1332 | if (p != null && p.IsNPC) | 1359 | if (p != null && p.IsNPC) |
1333 | { | 1360 | { |