aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs162
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModuleTst.cs229
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/XMuteModule.cs239
3 files changed, 123 insertions, 507 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
index 2d57193..d3c7751 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs
@@ -27,86 +27,95 @@
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30using System.Text;
30using log4net; 31using log4net;
31using Nini.Config; 32using Nini.Config;
32using Mono.Addins;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Client; 36using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using Mono.Addins;
40
41using OpenSim.Server.Base;
42using OpenSim.Services.Interfaces;
39 43
40namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 44namespace 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;
50 55
51 public void Initialise(IConfigSource config) 56 public void Initialise(IConfigSource config)
52 { 57 {
53 IConfig cnf = config.Configs["Messaging"]; 58 IConfig cnf = config.Configs["Messaging"];
54 if (cnf == null) 59 if (cnf == null)
55 {
56 enabled = false;
57 return; 60 return;
58 }
59 61
60 if (cnf != null && cnf.GetString("MuteListModule", "None") != 62 if (cnf.GetString("MuteListModule", "None") != "MuteListModule")
61 "MuteListModule")
62 {
63 enabled = false;
64 return; 63 return;
65 }
66 64
67 m_RestURL = cnf.GetString("MuteListURL", ""); 65 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 } 66 }
75 67
76 public void AddRegion(Scene scene) 68 public void AddRegion(Scene scene)
77 { 69 {
78 if (!enabled) 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("[MuteListModule]: Xfer not availble in region {0}. Module Disabled", scene.Name);
81 m_Enabled = false;
79 return; 82 return;
83 }
80 84
85 IMuteListService srv = scene.RequestModuleInterface<IMuteListService>();
86 if(srv == null)
87 {
88 m_log.ErrorFormat("[MuteListModule]: MuteListService not availble in region {0}. Module Disabled", scene.Name);
89 m_Enabled = false;
90 return;
91 }
81 lock (m_SceneList) 92 lock (m_SceneList)
82 { 93 {
94 if(m_service == null)
95 m_service = srv;
83 m_SceneList.Add(scene); 96 m_SceneList.Add(scene);
84
85 scene.EventManager.OnNewClient += OnNewClient; 97 scene.EventManager.OnNewClient += OnNewClient;
86 } 98 }
87 } 99 }
88 100
89 public void RegionLoaded(Scene scene)
90 {
91 }
92
93 public void RemoveRegion(Scene scene) 101 public void RemoveRegion(Scene scene)
94 { 102 {
95 if (!enabled)
96 return;
97
98 lock (m_SceneList) 103 lock (m_SceneList)
99 { 104 {
100 m_SceneList.Remove(scene); 105 if(m_SceneList.Contains(scene))
106 {
107 m_SceneList.Remove(scene);
108 scene.EventManager.OnNewClient -= OnNewClient;
109 }
101 } 110 }
102 } 111 }
103 112
104 public void PostInitialise() 113 public void PostInitialise()
105 { 114 {
106 if (!enabled) 115 if (!m_Enabled)
107 return; 116 return;
108 117
109 m_log.Debug("[MUTE LIST] Mute list enabled"); 118 m_log.Debug("[MuteListModule]: enabled");
110 } 119 }
111 120
112 public string Name 121 public string Name
@@ -118,27 +127,102 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
118 { 127 {
119 get { return null; } 128 get { return null; }
120 } 129 }
121 130
122 public void Close() 131 public void Close()
123 { 132 {
124 } 133 }
125 134
126 private void OnNewClient(IClientAPI client) 135 private void OnNewClient(IClientAPI client)
127 { 136 {
128 client.OnMuteListRequest += OnMuteListRequest; 137 client.OnMuteListRequest += OnMuteListRequest;
138 client.OnUpdateMuteListEntry += OnUpdateMuteListEntry;
139 client.OnRemoveMuteListEntry += OnRemoveMuteListEntry;
129 } 140 }
130 141
131 private void OnMuteListRequest(IClientAPI client, uint crc) 142 private void OnMuteListRequest(IClientAPI client, uint crc)
132 { 143 {
133 m_log.DebugFormat("[MUTE LIST] Got mute list request for crc {0}", crc); 144 if (!m_Enabled)
134 string filename = "mutes"+client.AgentId.ToString(); 145 {
146 if(crc == 0)
147 client.SendEmpytMuteList();
148 else
149 client.SendUseCachedMuteList();
150 return;
151 }
135 152
136 IXfer xfer = client.Scene.RequestModuleInterface<IXfer>(); 153 IXfer xfer = client.Scene.RequestModuleInterface<IXfer>();
137 if (xfer != null) 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)
138 { 180 {
139 xfer.AddNewFile(filename, new Byte[0]); 181 if(crc == 0)
140 client.SendMuteListUpdate(filename); 182 client.SendEmpytMuteList();
183 else
184 client.SendUseCachedMuteList();
185 return;
141 } 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);
142 } 226 }
143 } 227 }
144} 228}
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 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using System.Text;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using Mono.Addins;
40
41using OpenSim.Server.Base;
42using OpenSim.Services.Interfaces;
43
44namespace 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 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using System.Text;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using Mono.Addins;
38using OpenSim.Data.MySQL;
39using MySql.Data.MySqlClient;
40
41
42namespace 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