aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie Thielker2009-03-29 00:48:34 +0000
committerMelanie Thielker2009-03-29 00:48:34 +0000
commit404bfdc9a6828638b7b4f7851602e3fe77044025 (patch)
tree9fd740bfab5967e70b9997c082f1dfd7fcecd2e2 /OpenSim
parentMinor bug fix in UpdateItem (meta data). (diff)
downloadopensim-SC-404bfdc9a6828638b7b4f7851602e3fe77044025.zip
opensim-SC-404bfdc9a6828638b7b4f7851602e3fe77044025.tar.gz
opensim-SC-404bfdc9a6828638b7b4f7851602e3fe77044025.tar.bz2
opensim-SC-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')
-rw-r--r--OpenSim/Client/MXP/ClientStack/MXPClientView.cs4
-rw-r--r--OpenSim/Framework/IClientAPI.cs1
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs138
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs69
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs4
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs4
8 files changed, 227 insertions, 8 deletions
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
index 548c657..f3eb2b6 100644
--- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
+++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
@@ -1601,5 +1601,9 @@ namespace OpenSim.Client.MXP.ClientStack
1601 public void SendUseCachedMuteList() 1601 public void SendUseCachedMuteList()
1602 { 1602 {
1603 } 1603 }
1604
1605 public void SendMuteListUpdate(string filename)
1606 {
1607 }
1604 } 1608 }
1605} 1609}
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 6d9ed79..bef1bfc 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -1133,6 +1133,7 @@ namespace OpenSim.Framework
1133 void SendUserInfoReply(bool imViaEmail, bool visible, string email); 1133 void SendUserInfoReply(bool imViaEmail, bool visible, string email);
1134 1134
1135 void SendUseCachedMuteList(); 1135 void SendUseCachedMuteList();
1136 void SendMuteListUpdate(string filename);
1136 1137
1137 void KillEndDone(); 1138 void KillEndDone();
1138 1139
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 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using log4net;
31using Nini.Config;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39
40namespace 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 */
27using System;
27using System.Collections.Generic; 28using System.Collections.Generic;
28using System.Reflection; 29using System.Reflection;
29using log4net; 30using log4net;
30using Nini.Config; 31using Nini.Config;
31using OpenMetaverse; 32using OpenMetaverse;
32using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Servers;
33using OpenSim.Framework.Client; 36using OpenSim.Framework.Client;
34using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 38using 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}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index f96057c..b2c1423 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -1109,5 +1109,9 @@ namespace OpenSim.Tests.Common.Mock
1109 public void SendUseCachedMuteList() 1109 public void SendUseCachedMuteList()
1110 { 1110 {
1111 } 1111 }
1112
1113 public void SendMuteListUpdate(string filename)
1114 {
1115 }
1112 } 1116 }
1113} 1117}