diff options
Diffstat (limited to 'OpenSim/Region')
5 files changed, 218 insertions, 8 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index b65b3f9..7d9efa6 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -8700,6 +8700,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8700 | OutPacket(useCachedMuteList, ThrottleOutPacketType.Task); | 8700 | OutPacket(useCachedMuteList, ThrottleOutPacketType.Task); |
8701 | } | 8701 | } |
8702 | 8702 | ||
8703 | public void SendMuteListUpdate(string filename) | ||
8704 | { | ||
8705 | MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate); | ||
8706 | |||
8707 | muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock(); | ||
8708 | muteListUpdate.MuteData.AgentID = AgentId; | ||
8709 | muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename); | ||
8710 | |||
8711 | OutPacket(muteListUpdate, ThrottleOutPacketType.Task); | ||
8712 | } | ||
8713 | |||
8703 | public string Report() | 8714 | public string Report() |
8704 | { | 8715 | { |
8705 | LLPacketHandler handler = (LLPacketHandler) m_PacketHandler; | 8716 | LLPacketHandler handler = (LLPacketHandler) m_PacketHandler; |
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 | |||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 77bc9d7..814b2de 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -24,12 +24,15 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | ||
27 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
28 | using System.Reflection; | 29 | using System.Reflection; |
29 | using log4net; | 30 | using log4net; |
30 | using Nini.Config; | 31 | using Nini.Config; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | ||
35 | using OpenSim.Framework.Servers; | ||
33 | using OpenSim.Framework.Client; | 36 | using OpenSim.Framework.Client; |
34 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
@@ -40,21 +43,36 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
40 | { | 43 | { |
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 45 | ||
43 | private bool enabled = false; | 46 | private bool enabled = true; |
44 | private List<Scene> m_SceneList = new List<Scene>(); | 47 | private List<Scene> m_SceneList = new List<Scene>(); |
48 | private string m_RestURL = String.Empty; | ||
45 | 49 | ||
46 | public void Initialise(Scene scene, IConfigSource config) | 50 | public void Initialise(Scene scene, IConfigSource config) |
47 | { | 51 | { |
52 | if (!enabled) | ||
53 | return; | ||
54 | |||
48 | IConfig cnf = config.Configs["Messaging"]; | 55 | IConfig cnf = config.Configs["Messaging"]; |
49 | if (cnf != null && cnf.GetString( | 56 | if (cnf != null && cnf.GetString( |
50 | "OfflineMessageModule", "None") != | 57 | "OfflineMessageModule", "None") != |
51 | "OfflineMessageModule") | 58 | "OfflineMessageModule") |
59 | { | ||
60 | enabled = false; | ||
52 | return; | 61 | return; |
53 | 62 | } | |
54 | enabled = true; | ||
55 | 63 | ||
56 | lock (m_SceneList) | 64 | lock (m_SceneList) |
57 | { | 65 | { |
66 | if (m_SceneList.Count == 0) | ||
67 | { | ||
68 | m_RestURL = cnf.GetString("OfflineMessageURL", ""); | ||
69 | if (m_RestURL == "") | ||
70 | { | ||
71 | m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); | ||
72 | enabled = false; | ||
73 | return; | ||
74 | } | ||
75 | } | ||
58 | if (!m_SceneList.Contains(scene)) | 76 | if (!m_SceneList.Contains(scene)) |
59 | m_SceneList.Add(scene); | 77 | m_SceneList.Add(scene); |
60 | 78 | ||
@@ -64,6 +82,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
64 | 82 | ||
65 | public void PostInitialise() | 83 | public void PostInitialise() |
66 | { | 84 | { |
85 | if (!enabled) | ||
86 | return; | ||
87 | |||
67 | if (m_SceneList.Count == 0) | 88 | if (m_SceneList.Count == 0) |
68 | return; | 89 | return; |
69 | 90 | ||
@@ -80,6 +101,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
80 | m_SceneList.Clear(); | 101 | m_SceneList.Clear(); |
81 | } | 102 | } |
82 | 103 | ||
104 | m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); | ||
83 | return; | 105 | return; |
84 | } | 106 | } |
85 | 107 | ||
@@ -107,7 +129,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
107 | foreach (Scene s in m_SceneList) | 129 | foreach (Scene s in m_SceneList) |
108 | { | 130 | { |
109 | ScenePresence presence = s.GetScenePresence(agentID); | 131 | ScenePresence presence = s.GetScenePresence(agentID); |
110 | if (!presence.IsChildAgent) | 132 | if (presence != null && !presence.IsChildAgent) |
111 | return presence.ControllingClient; | 133 | return presence.ControllingClient; |
112 | } | 134 | } |
113 | return null; | 135 | return null; |
@@ -116,18 +138,49 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
116 | private void OnNewClient(IClientAPI client) | 138 | private void OnNewClient(IClientAPI client) |
117 | { | 139 | { |
118 | client.OnRetrieveInstantMessages += RetrieveInstantMessages; | 140 | client.OnRetrieveInstantMessages += RetrieveInstantMessages; |
141 | // TODO:: Remove when mute lists are supported | ||
142 | // | ||
143 | //client.OnEconomyDataRequest += OnEconomyDataRequest; | ||
119 | } | 144 | } |
120 | 145 | ||
146 | // TODO: Remove method when mute lists are supported | ||
147 | // | ||
148 | //private void OnEconomyDataRequest(UUID agentID) | ||
149 | //{ | ||
150 | // IClientAPI client = FindClient(agentID); | ||
151 | // if (client == null) | ||
152 | // { | ||
153 | // m_log.ErrorFormat("[OFFLINE MESSAGING] Can't find client {0}", agentID.ToString()); | ||
154 | // return; | ||
155 | // } | ||
156 | // RetrieveInstantMessages(client); | ||
157 | //} | ||
158 | |||
121 | private void RetrieveInstantMessages(IClientAPI client) | 159 | private void RetrieveInstantMessages(IClientAPI client) |
122 | { | 160 | { |
123 | m_log.Debug("[OFFLINE MESSAGING] RetrieveInstantMessages called"); | 161 | m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId); |
162 | |||
163 | List<GridInstantMessage>msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( | ||
164 | "POST", m_RestURL+"/RetrieveMessages/", client.AgentId); | ||
165 | |||
166 | foreach (GridInstantMessage im in msglist) | ||
167 | { | ||
168 | DateTime saved = Util.ToDateTime((uint)im.timestamp); | ||
169 | |||
170 | client.SendInstantMessage(new UUID(im.toAgentID), | ||
171 | "(saved " + saved.ToString() + ") " + im.message, | ||
172 | new UUID(im.fromAgentID), im.fromAgentName, | ||
173 | (byte)im.dialog, | ||
174 | (uint)im.timestamp); | ||
175 | } | ||
124 | } | 176 | } |
125 | 177 | ||
126 | private void UndeliveredMessage(GridInstantMessage im) | 178 | private void UndeliveredMessage(GridInstantMessage im) |
127 | { | 179 | { |
128 | if (im.offline != 0) | 180 | if (im.offline != 0) |
129 | { | 181 | { |
130 | // TODO: Actually save it | 182 | bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>( |
183 | "POST", m_RestURL+"/SaveMessage/", im); | ||
131 | 184 | ||
132 | if(im.dialog == (byte)InstantMessageDialog.MessageFromAgent) | 185 | if(im.dialog == (byte)InstantMessageDialog.MessageFromAgent) |
133 | { | 186 | { |
@@ -137,9 +190,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
137 | 190 | ||
138 | client.SendInstantMessage(new UUID(im.fromAgentID), | 191 | client.SendInstantMessage(new UUID(im.fromAgentID), |
139 | "User is not logged in. "+ | 192 | "User is not logged in. "+ |
140 | "Message saved.", | 193 | (success ? "Message saved." : "Message not saved"), |
141 | new UUID(im.toAgentID), "System", | 194 | new UUID(im.toAgentID), "System", |
142 | (byte)InstantMessageDialog.BusyAutoResponse, | 195 | (byte)InstantMessageDialog.MessageFromAgent, |
143 | (uint)Util.UnixTimeSinceEpoch()); | 196 | (uint)Util.UnixTimeSinceEpoch()); |
144 | } | 197 | } |
145 | } | 198 | } |
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index fa01a42..82d84fa 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs | |||
@@ -1068,6 +1068,10 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
1068 | { | 1068 | { |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | public void SendMuteListUpdate(string filename) | ||
1072 | { | ||
1073 | } | ||
1074 | |||
1071 | #endregion | 1075 | #endregion |
1072 | } | 1076 | } |
1073 | } | 1077 | } |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 4bf4341..415a24a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -1068,6 +1068,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
1068 | { | 1068 | { |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | public void SendMuteListUpdate(string filename) | ||
1072 | { | ||
1073 | } | ||
1074 | |||
1071 | #endregion | 1075 | #endregion |
1072 | } | 1076 | } |
1073 | } | 1077 | } |