diff options
author | UbitUmarov | 2017-12-12 22:19:31 +0000 |
---|---|---|
committer | UbitUmarov | 2017-12-12 22:19:31 +0000 |
commit | ab0f866087f1565863ac516820761cb48386f96e (patch) | |
tree | e15b415a9feee5f042f4ca7f8d9eb05f536fddad /OpenSim/Region/CoreModules | |
parent | Merge branch 'master' into httptests (diff) | |
parent | commit what i did so far for core mutes module, befere i lose it (diff) | |
download | opensim-SC-ab0f866087f1565863ac516820761cb48386f96e.zip opensim-SC-ab0f866087f1565863ac516820761cb48386f96e.tar.gz opensim-SC-ab0f866087f1565863ac516820761cb48386f96e.tar.bz2 opensim-SC-ab0f866087f1565863ac516820761cb48386f96e.tar.xz |
Merge branch 'master' into httptests
# Conflicts:
# prebuild.xml
Diffstat (limited to 'OpenSim/Region/CoreModules')
5 files changed, 680 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs new file mode 100644 index 0000000..6857f35 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs | |||
@@ -0,0 +1,229 @@ | |||
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 new file mode 100644 index 0000000..b61e848 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs | |||
@@ -0,0 +1,239 @@ | |||
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/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 | } | ||
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs index 708286c..0b37179 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs | |||
@@ -38,18 +38,20 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
38 | { | 38 | { |
39 | public class ShadedMapTileRenderer : IMapTileTerrainRenderer | 39 | public class ShadedMapTileRenderer : IMapTileTerrainRenderer |
40 | { | 40 | { |
41 | private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95); | ||
42 | |||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | private static readonly string LogHeader = "[SHADED MAPTILE RENDERER]"; | 42 | private static readonly string LogHeader = "[SHADED MAPTILE RENDERER]"; |
45 | 43 | ||
46 | private Scene m_scene; | 44 | private Scene m_scene; |
47 | //private IConfigSource m_config; // not used currently | 45 | private IConfigSource m_config; |
46 | private Color m_color_water; | ||
48 | 47 | ||
49 | public void Initialise(Scene scene, IConfigSource config) | 48 | public void Initialise(Scene scene, IConfigSource config) |
50 | { | 49 | { |
51 | m_scene = scene; | 50 | m_scene = scene; |
52 | // m_config = config; // not used currently | 51 | m_config = config; |
52 | |||
53 | string[] configSections = new string[] { "Map", "Startup" }; | ||
54 | m_color_water = System.Drawing.ColorTranslator.FromHtml(Util.GetConfigVarFromSections<string>(m_config, "MapColorWater", configSections, "#1D475F")); | ||
53 | } | 55 | } |
54 | 56 | ||
55 | public void TerrainToBitmap(Bitmap mapbmp) | 57 | public void TerrainToBitmap(Bitmap mapbmp) |
@@ -231,7 +233,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
231 | 233 | ||
232 | try | 234 | try |
233 | { | 235 | { |
234 | mapbmp.SetPixel(x, yr, WATER_COLOR); | 236 | mapbmp.SetPixel(x, yr, m_color_water); |
235 | } | 237 | } |
236 | catch (ArgumentException) | 238 | catch (ArgumentException) |
237 | { | 239 | { |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index 4b3ee18..c71f5c0 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | |||
@@ -130,21 +130,19 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
130 | // some hardcoded terrain UUIDs that work with SL 1.20 (the four default textures and "Blank"). | 130 | // some hardcoded terrain UUIDs that work with SL 1.20 (the four default textures and "Blank"). |
131 | // The color-values were choosen because they "look right" (at least to me) ;-) | 131 | // The color-values were choosen because they "look right" (at least to me) ;-) |
132 | private static readonly UUID defaultTerrainTexture1 = new UUID("0bc58228-74a0-7e83-89bc-5c23464bcec5"); | 132 | private static readonly UUID defaultTerrainTexture1 = new UUID("0bc58228-74a0-7e83-89bc-5c23464bcec5"); |
133 | private static readonly Color defaultColor1 = Color.FromArgb(165, 137, 118); | ||
134 | private static readonly UUID defaultTerrainTexture2 = new UUID("63338ede-0037-c4fd-855b-015d77112fc8"); | 133 | private static readonly UUID defaultTerrainTexture2 = new UUID("63338ede-0037-c4fd-855b-015d77112fc8"); |
135 | private static readonly Color defaultColor2 = Color.FromArgb(69, 89, 49); | ||
136 | private static readonly UUID defaultTerrainTexture3 = new UUID("303cd381-8560-7579-23f1-f0a880799740"); | 134 | private static readonly UUID defaultTerrainTexture3 = new UUID("303cd381-8560-7579-23f1-f0a880799740"); |
137 | private static readonly Color defaultColor3 = Color.FromArgb(162, 154, 141); | ||
138 | private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c"); | 135 | private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c"); |
139 | private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200); | ||
140 | |||
141 | private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95); | ||
142 | 136 | ||
143 | #endregion | 137 | #endregion |
144 | 138 | ||
145 | |||
146 | private Scene m_scene; | 139 | private Scene m_scene; |
147 | // private IConfigSource m_config; // not used currently | 140 | private IConfigSource m_config; |
141 | private Color m_color_water; | ||
142 | private Color m_color_1; | ||
143 | private Color m_color_2; | ||
144 | private Color m_color_3; | ||
145 | private Color m_color_4; | ||
148 | 146 | ||
149 | // mapping from texture UUIDs to averaged color. This will contain 5-9 values, in general; new values are only | 147 | // mapping from texture UUIDs to averaged color. This will contain 5-9 values, in general; new values are only |
150 | // added when the terrain textures are changed in the estate dialog and a new map is generated (and will stay in | 148 | // added when the terrain textures are changed in the estate dialog and a new map is generated (and will stay in |
@@ -156,12 +154,21 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
156 | public void Initialise(Scene scene, IConfigSource source) | 154 | public void Initialise(Scene scene, IConfigSource source) |
157 | { | 155 | { |
158 | m_scene = scene; | 156 | m_scene = scene; |
159 | // m_config = source; // not used currently | 157 | m_config = source; |
158 | |||
159 | string[] configSections = new string[] { "Map", "Startup" }; | ||
160 | |||
161 | m_color_water = System.Drawing.ColorTranslator.FromHtml(Util.GetConfigVarFromSections<string>(m_config, "MapColorWater", configSections, "#1D475F")); | ||
162 | m_color_1 = System.Drawing.ColorTranslator.FromHtml(Util.GetConfigVarFromSections<string>(m_config, "MapColor1", configSections, "#A58976")); | ||
163 | m_color_2 = System.Drawing.ColorTranslator.FromHtml(Util.GetConfigVarFromSections<string>(m_config, "MapColor2", configSections, "#455931")); | ||
164 | m_color_3 = System.Drawing.ColorTranslator.FromHtml(Util.GetConfigVarFromSections<string>(m_config, "MapColor3", configSections, "#A29A8D")); | ||
165 | m_color_4 = System.Drawing.ColorTranslator.FromHtml(Util.GetConfigVarFromSections<string>(m_config, "MapColor4", configSections, "#C8C8C8")); | ||
166 | |||
160 | m_mapping = new Dictionary<UUID,Color>(); | 167 | m_mapping = new Dictionary<UUID,Color>(); |
161 | m_mapping.Add(defaultTerrainTexture1, defaultColor1); | 168 | m_mapping.Add(defaultTerrainTexture1, m_color_1); |
162 | m_mapping.Add(defaultTerrainTexture2, defaultColor2); | 169 | m_mapping.Add(defaultTerrainTexture2, m_color_2); |
163 | m_mapping.Add(defaultTerrainTexture3, defaultColor3); | 170 | m_mapping.Add(defaultTerrainTexture3, m_color_3); |
164 | m_mapping.Add(defaultTerrainTexture4, defaultColor4); | 171 | m_mapping.Add(defaultTerrainTexture4, m_color_4); |
165 | m_mapping.Add(Util.BLANK_TEXTURE_UUID, Color.White); | 172 | m_mapping.Add(Util.BLANK_TEXTURE_UUID, Color.White); |
166 | } | 173 | } |
167 | 174 | ||
@@ -298,10 +305,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
298 | RegionSettings settings = m_scene.RegionInfo.RegionSettings; | 305 | RegionSettings settings = m_scene.RegionInfo.RegionSettings; |
299 | 306 | ||
300 | // the four terrain colors as HSVs for interpolation | 307 | // the four terrain colors as HSVs for interpolation |
301 | HSV hsv1 = new HSV(computeAverageColor(settings.TerrainTexture1, defaultColor1)); | 308 | HSV hsv1 = new HSV(computeAverageColor(settings.TerrainTexture1, m_color_1)); |
302 | HSV hsv2 = new HSV(computeAverageColor(settings.TerrainTexture2, defaultColor2)); | 309 | HSV hsv2 = new HSV(computeAverageColor(settings.TerrainTexture2, m_color_2)); |
303 | HSV hsv3 = new HSV(computeAverageColor(settings.TerrainTexture3, defaultColor3)); | 310 | HSV hsv3 = new HSV(computeAverageColor(settings.TerrainTexture3, m_color_3)); |
304 | HSV hsv4 = new HSV(computeAverageColor(settings.TerrainTexture4, defaultColor4)); | 311 | HSV hsv4 = new HSV(computeAverageColor(settings.TerrainTexture4, m_color_4)); |
305 | 312 | ||
306 | float levelNElow = (float)settings.Elevation1NE; | 313 | float levelNElow = (float)settings.Elevation1NE; |
307 | float levelNEhigh = (float)settings.Elevation2NE; | 314 | float levelNEhigh = (float)settings.Elevation2NE; |
@@ -417,7 +424,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
417 | 424 | ||
418 | heightvalue = 100f - (heightvalue * 100f) / 19f; // 0 - 19 => 100 - 0 | 425 | heightvalue = 100f - (heightvalue * 100f) / 19f; // 0 - 19 => 100 - 0 |
419 | 426 | ||
420 | mapbmp.SetPixel(x, yr, WATER_COLOR); | 427 | mapbmp.SetPixel(x, yr, m_color_water); |
421 | } | 428 | } |
422 | } | 429 | } |
423 | } | 430 | } |