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/Services/MuteListService | |
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/Services/MuteListService')
-rw-r--r-- | OpenSim/Services/MuteListService/MuteListService.cs | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/OpenSim/Services/MuteListService/MuteListService.cs b/OpenSim/Services/MuteListService/MuteListService.cs new file mode 100644 index 0000000..7e5ded1 --- /dev/null +++ b/OpenSim/Services/MuteListService/MuteListService.cs | |||
@@ -0,0 +1,127 @@ | |||
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 System; | ||
29 | using System.Text; | ||
30 | using OpenMetaverse; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Services.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | ||
37 | |||
38 | namespace OpenSim.Services.EstateService | ||
39 | { | ||
40 | public class MuteListService : ServiceBase, IMuteListService | ||
41 | { | ||
42 | // private static readonly ILog m_log = | ||
43 | // LogManager.GetLogger( | ||
44 | // MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | protected IMuteListData m_database; | ||
47 | |||
48 | public MuteListService(IConfigSource config) | ||
49 | : base(config) | ||
50 | { | ||
51 | string dllName = String.Empty; | ||
52 | string connString = String.Empty; | ||
53 | |||
54 | // Try reading the [DatabaseService] section, if it exists | ||
55 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
56 | if (dbConfig != null) | ||
57 | { | ||
58 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
59 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
60 | connString = dbConfig.GetString("MuteConnectionString", connString); | ||
61 | } | ||
62 | |||
63 | // Try reading the [MuteListStore] section, if it exists | ||
64 | IConfig muteConfig = config.Configs["MuteListStore"]; | ||
65 | if (muteConfig != null) | ||
66 | { | ||
67 | dllName = muteConfig.GetString("StorageProvider", dllName); | ||
68 | connString = muteConfig.GetString("ConnectionString", connString); | ||
69 | } | ||
70 | |||
71 | // We tried, but this doesn't exist. We can't proceed | ||
72 | if (dllName == String.Empty) | ||
73 | throw new Exception("No StorageProvider configured"); | ||
74 | |||
75 | m_database = LoadPlugin<IMuteListData>(dllName, new Object[] { connString }); | ||
76 | if (m_database == null) | ||
77 | throw new Exception("Could not find a storage interface in the given module"); | ||
78 | } | ||
79 | |||
80 | public Byte[] MuteListRequest(UUID agentID, uint crc) | ||
81 | { | ||
82 | if(m_database == null) | ||
83 | return null; | ||
84 | |||
85 | MuteData[] data = m_database.Get(agentID); | ||
86 | if (data == null || data.Length == 0) | ||
87 | return new Byte[0]; | ||
88 | |||
89 | StringBuilder sb = new StringBuilder(16384); | ||
90 | foreach (MuteData d in data) | ||
91 | sb.AppendFormat("{0} {1} {2}|{3}\n", | ||
92 | d.MuteType, | ||
93 | d.MuteID.ToString(), | ||
94 | d.MuteName, | ||
95 | d.MuteFlags); | ||
96 | |||
97 | Byte[] filedata = Util.UTF8.GetBytes(sb.ToString()); | ||
98 | |||
99 | uint dataCrc = Crc32.Compute(filedata); | ||
100 | |||
101 | if (dataCrc == crc) | ||
102 | { | ||
103 | if(crc == 0) | ||
104 | return new Byte[0]; | ||
105 | |||
106 | Byte[] ret = new Byte[1] {1}; | ||
107 | return ret; | ||
108 | } | ||
109 | |||
110 | return filedata; | ||
111 | } | ||
112 | |||
113 | public bool UpdateMute(MuteData mute) | ||
114 | { | ||
115 | if(m_database == null) | ||
116 | return false; | ||
117 | return m_database.Store(mute); | ||
118 | } | ||
119 | |||
120 | public bool RemoveMute(UUID agentID, UUID muteID, string muteName) | ||
121 | { | ||
122 | if(m_database == null) | ||
123 | return false; | ||
124 | return m_database.Delete(agentID, muteID, muteName); | ||
125 | } | ||
126 | } | ||
127 | } | ||