aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/FriendsModule.cs79
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs7
2 files changed, 73 insertions, 13 deletions
diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs
index 9a03aaf..53ed74a 100644
--- a/OpenSim/Region/Environment/Modules/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
37using libsecondlife; 37using libsecondlife;
38using Nwc.XmlRpc;
38 39
39namespace OpenSim.Region.Environment.Modules 40namespace OpenSim.Region.Environment.Modules
40{ 41{
@@ -42,17 +43,31 @@ namespace OpenSim.Region.Environment.Modules
42 { 43 {
43 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
44 45
45 private Scene m_scene; 46 private List<Scene> m_scene = new List<Scene>();
46 47
47 Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>(); 48 Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
48 49
49 public void Initialise(Scene scene, IConfigSource config) 50 public void Initialise(Scene scene, IConfigSource config)
50 { 51 {
51 m_scene = scene; 52 lock (m_scene)
53 {
54 if (m_scene.Count == 0)
55 {
56 scene.AddXmlRPCHandler("presence_update", processPresenceUpdate);
57 }
58
59 if (!m_scene.Contains(scene))
60 m_scene.Add(scene);
61 }
52 scene.EventManager.OnNewClient += OnNewClient; 62 scene.EventManager.OnNewClient += OnNewClient;
53 scene.EventManager.OnGridInstantMessageToFriendsModule += OnGridInstantMessage; 63 scene.EventManager.OnGridInstantMessageToFriendsModule += OnGridInstantMessage;
64
65 }
66 public XmlRpcResponse processPresenceUpdate(XmlRpcRequest req)
67 {
68 m_log.Info("[FRIENDS]: Got Notification about a user! OMG");
69 return new XmlRpcResponse();
54 } 70 }
55
56 private void OnNewClient(IClientAPI client) 71 private void OnNewClient(IClientAPI client)
57 { 72 {
58 // All friends establishment protocol goes over instant message 73 // All friends establishment protocol goes over instant message
@@ -112,7 +127,8 @@ namespace OpenSim.Region.Environment.Modules
112 msg.Position = new sLLVector3(Position); 127 msg.Position = new sLLVector3(Position);
113 msg.RegionID = RegionID.UUID; 128 msg.RegionID = RegionID.UUID;
114 msg.binaryBucket = binaryBucket; 129 msg.binaryBucket = binaryBucket;
115 m_scene.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); 130 // We don't really care which scene we pipe it through.
131 m_scene[0].TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
116 } 132 }
117 133
118 // 39 == Accept Friendship 134 // 39 == Accept Friendship
@@ -133,6 +149,14 @@ namespace OpenSim.Region.Environment.Modules
133 if (m_pendingFriendRequests.ContainsKey(transactionID)) 149 if (m_pendingFriendRequests.ContainsKey(transactionID))
134 { 150 {
135 // Found Pending Friend Request with that Transaction.. 151 // Found Pending Friend Request with that Transaction..
152 Scene SceneAgentIn = m_scene[0];
153
154 // Found Pending Friend Request with that Transaction..
155 ScenePresence agentpresence = GetPresenceFromAgentID(agentID);
156 if (agentpresence != null)
157 {
158 SceneAgentIn = agentpresence.Scene;
159 }
136 160
137 // Compose response to other agent. 161 // Compose response to other agent.
138 GridInstantMessage msg = new GridInstantMessage(); 162 GridInstantMessage msg = new GridInstantMessage();
@@ -145,13 +169,15 @@ namespace OpenSim.Region.Environment.Modules
145 msg.message = agentID.UUID.ToString(); 169 msg.message = agentID.UUID.ToString();
146 msg.ParentEstateID = 0; 170 msg.ParentEstateID = 0;
147 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 171 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
148 msg.RegionID = m_scene.RegionInfo.RegionID.UUID; 172 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
149 msg.dialog = (byte)39;// Approved friend request 173 msg.dialog = (byte)39;// Approved friend request
150 msg.Position = new sLLVector3(); 174 msg.Position = new sLLVector3();
151 msg.offline = (byte)0; 175 msg.offline = (byte)0;
152 msg.binaryBucket = new byte[0]; 176 msg.binaryBucket = new byte[0];
153 m_scene.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); 177 // We don't really care which scene we pipe it through, it goes to the shared IM Module and/or the database
154 m_scene.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint)1); 178
179 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
180 SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint)1);
155 m_pendingFriendRequests.Remove(transactionID); 181 m_pendingFriendRequests.Remove(transactionID);
156 182
157 // TODO: Inform agent that the friend is online 183 // TODO: Inform agent that the friend is online
@@ -162,8 +188,14 @@ namespace OpenSim.Region.Environment.Modules
162 { 188 {
163 if (m_pendingFriendRequests.ContainsKey(transactionID)) 189 if (m_pendingFriendRequests.ContainsKey(transactionID))
164 { 190 {
165 // Found Pending Friend Request with that Transaction.. 191 Scene SceneAgentIn = m_scene[0];
166 192
193 // Found Pending Friend Request with that Transaction..
194 ScenePresence agentpresence = GetPresenceFromAgentID(agentID);
195 if (agentpresence != null)
196 {
197 SceneAgentIn = agentpresence.Scene;
198 }
167 // Compose response to other agent. 199 // Compose response to other agent.
168 GridInstantMessage msg = new GridInstantMessage(); 200 GridInstantMessage msg = new GridInstantMessage();
169 msg.toAgentID = m_pendingFriendRequests[transactionID].UUID; 201 msg.toAgentID = m_pendingFriendRequests[transactionID].UUID;
@@ -175,19 +207,19 @@ namespace OpenSim.Region.Environment.Modules
175 msg.message = agentID.UUID.ToString(); 207 msg.message = agentID.UUID.ToString();
176 msg.ParentEstateID = 0; 208 msg.ParentEstateID = 0;
177 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 209 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
178 msg.RegionID = m_scene.RegionInfo.RegionID.UUID; 210 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
179 msg.dialog = (byte)40;// Deny friend request 211 msg.dialog = (byte)40;// Deny friend request
180 msg.Position = new sLLVector3(); 212 msg.Position = new sLLVector3();
181 msg.offline = (byte)0; 213 msg.offline = (byte)0;
182 msg.binaryBucket = new byte[0]; 214 msg.binaryBucket = new byte[0];
183 m_scene.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); 215 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
184 m_pendingFriendRequests.Remove(transactionID); 216 m_pendingFriendRequests.Remove(transactionID);
185 } 217 }
186 } 218 }
187 219
188 private void OnTerminateFriendship(IClientAPI client, LLUUID agent, LLUUID exfriendID) 220 private void OnTerminateFriendship(IClientAPI client, LLUUID agent, LLUUID exfriendID)
189 { 221 {
190 m_scene.StoreRemoveFriendship(agent, exfriendID); 222 m_scene[0].StoreRemoveFriendship(agent, exfriendID);
191 // TODO: Inform the client that the ExFriend is offline 223 // TODO: Inform the client that the ExFriend is offline
192 } 224 }
193 225
@@ -201,6 +233,29 @@ namespace OpenSim.Region.Environment.Modules
201 msg.binaryBucket); 233 msg.binaryBucket);
202 } 234 }
203 235
236 private ScenePresence GetPresenceFromAgentID(LLUUID AgentID)
237 {
238 ScenePresence returnAgent = null;
239 lock (m_scene)
240 {
241 ScenePresence queryagent = null;
242 for (int i = 0; i < m_scene.Count; i++)
243 {
244 queryagent = m_scene[i].GetScenePresence(AgentID);
245 if (queryagent != null)
246 {
247 if (!queryagent.IsChildAgent)
248 {
249 returnAgent = queryagent;
250 break;
251 }
252 }
253 }
254 }
255 return returnAgent;
256
257 }
258
204 public void PostInitialise() 259 public void PostInitialise()
205 { 260 {
206 } 261 }
@@ -216,7 +271,7 @@ namespace OpenSim.Region.Environment.Modules
216 271
217 public bool IsSharedModule 272 public bool IsSharedModule
218 { 273 {
219 get { return false; } 274 get { return true; }
220 } 275 }
221 } 276 }
222} 277}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 32136be..f6e3d82 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1466,7 +1466,12 @@ namespace OpenSim.Region.Environment.Scenes
1466 /// <param name="agentID"></param> 1466 /// <param name="agentID"></param>
1467 public override void RemoveClient(LLUUID agentID) 1467 public override void RemoveClient(LLUUID agentID)
1468 { 1468 {
1469 bool childagentYN = false;
1469 ScenePresence avatar = GetScenePresence(agentID); 1470 ScenePresence avatar = GetScenePresence(agentID);
1471 if (avatar != null)
1472 {
1473 childagentYN = avatar.IsChildAgent;
1474 }
1470 try 1475 try
1471 { 1476 {
1472 if (avatar.IsChildAgent) 1477 if (avatar.IsChildAgent)
@@ -1555,7 +1560,7 @@ namespace OpenSim.Region.Environment.Scenes
1555 } 1560 }
1556 1561
1557 // Remove client agent from profile, so new logins will work 1562 // Remove client agent from profile, so new logins will work
1558 if (!avatar.IsChildAgent) 1563 if (!childagentYN)
1559 { 1564 {
1560 m_sceneGridService.ClearUserAgent(agentID); 1565 m_sceneGridService.ClearUserAgent(agentID);
1561 } 1566 }