diff options
author | Melanie Thielker | 2009-03-29 00:48:34 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-03-29 00:48:34 +0000 |
commit | 404bfdc9a6828638b7b4f7851602e3fe77044025 (patch) | |
tree | 9fd740bfab5967e70b9997c082f1dfd7fcecd2e2 /OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs | |
parent | Minor bug fix in UpdateItem (meta data). (diff) | |
download | opensim-SC_OLD-404bfdc9a6828638b7b4f7851602e3fe77044025.zip opensim-SC_OLD-404bfdc9a6828638b7b4f7851602e3fe77044025.tar.gz opensim-SC_OLD-404bfdc9a6828638b7b4f7851602e3fe77044025.tar.bz2 opensim-SC_OLD-404bfdc9a6828638b7b4f7851602e3fe77044025.tar.xz |
Finish the offline IM module (still needs a server). Add rudimentary
support for the mute list (no functionality yet, but allows the
RetrieveInstantMessages event to fire now).
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs new file mode 100644 index 0000000..41441b3 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs | |||
@@ -0,0 +1,138 @@ | |||
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 OpenSim 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 log4net; | ||
31 | using Nini.Config; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Framework.Client; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.Avatar.MuteList | ||
41 | { | ||
42 | public class MuteListModule : IRegionModule | ||
43 | { | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private bool enabled = true; | ||
47 | private List<Scene> m_SceneList = new List<Scene>(); | ||
48 | private string m_RestURL = String.Empty; | ||
49 | |||
50 | public void Initialise(Scene scene, IConfigSource config) | ||
51 | { | ||
52 | if (!enabled) | ||
53 | return; | ||
54 | |||
55 | IConfig cnf = config.Configs["Messaging"]; | ||
56 | if (cnf != null && cnf.GetString( | ||
57 | "MuteListModule", "None") != | ||
58 | "MuteListModule") | ||
59 | { | ||
60 | enabled = false; | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | lock (m_SceneList) | ||
65 | { | ||
66 | if (m_SceneList.Count == 0) | ||
67 | { | ||
68 | m_RestURL = cnf.GetString("MuteListURL", ""); | ||
69 | if (m_RestURL == "") | ||
70 | { | ||
71 | m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); | ||
72 | enabled = false; | ||
73 | return; | ||
74 | } | ||
75 | } | ||
76 | if (!m_SceneList.Contains(scene)) | ||
77 | m_SceneList.Add(scene); | ||
78 | |||
79 | scene.EventManager.OnNewClient += OnNewClient; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | public void PostInitialise() | ||
84 | { | ||
85 | if (!enabled) | ||
86 | return; | ||
87 | |||
88 | if (m_SceneList.Count == 0) | ||
89 | return; | ||
90 | |||
91 | m_log.Debug("[MUTE LIST] Mute list enabled"); | ||
92 | } | ||
93 | |||
94 | public string Name | ||
95 | { | ||
96 | get { return "MuteListModule"; } | ||
97 | } | ||
98 | |||
99 | public bool IsSharedModule | ||
100 | { | ||
101 | get { return true; } | ||
102 | } | ||
103 | |||
104 | public void Close() | ||
105 | { | ||
106 | } | ||
107 | |||
108 | private IClientAPI FindClient(UUID agentID) | ||
109 | { | ||
110 | foreach (Scene s in m_SceneList) | ||
111 | { | ||
112 | ScenePresence presence = s.GetScenePresence(agentID); | ||
113 | if (presence != null && !presence.IsChildAgent) | ||
114 | return presence.ControllingClient; | ||
115 | } | ||
116 | return null; | ||
117 | } | ||
118 | |||
119 | private void OnNewClient(IClientAPI client) | ||
120 | { | ||
121 | client.OnMuteListRequest += OnMuteListRequest; | ||
122 | } | ||
123 | |||
124 | private void OnMuteListRequest(IClientAPI client, uint crc) | ||
125 | { | ||
126 | m_log.DebugFormat("[MUTE LIST] Got mute list requestg for crc {0}", crc); | ||
127 | string filename = "mutes"+client.AgentId.ToString(); | ||
128 | |||
129 | IXfer xfer = client.Scene.RequestModuleInterface<IXfer>(); | ||
130 | if (xfer != null) | ||
131 | { | ||
132 | xfer.AddNewFile(filename, new Byte[0]); | ||
133 | client.SendMuteListUpdate(filename); | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | } | ||
138 | |||