aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs325
1 files changed, 146 insertions, 179 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 1565da9..8d587b9 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
79 private IMessageTransferModule m_msgTransferModule; 79 private IMessageTransferModule m_msgTransferModule;
80 80
81 private IGroupsMessagingModule m_groupsMessagingModule; 81 private IGroupsMessagingModule m_groupsMessagingModule;
82 82
83 private IGroupsServicesConnector m_groupData; 83 private IGroupsServicesConnector m_groupData;
84 84
85 // Configuration settings 85 // Configuration settings
@@ -205,10 +205,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
205 } 205 }
206 206
207 scene.EventManager.OnNewClient += OnNewClient; 207 scene.EventManager.OnNewClient += OnNewClient;
208 scene.EventManager.OnMakeRootAgent += OnMakeRoot;
209 scene.EventManager.OnMakeChildAgent += OnMakeChild;
208 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 210 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
209 // The InstantMessageModule itself doesn't do this, 211 scene.EventManager.OnClientClosed += OnClientClosed;
210 // so lets see if things explode if we don't do it
211 // scene.EventManager.OnClientClosed += OnClientClosed;
212 212
213 } 213 }
214 214
@@ -233,7 +233,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
233 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); 233 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
234 } 234 }
235 235
236 public Type ReplaceableInterface 236 public Type ReplaceableInterface
237 { 237 {
238 get { return null; } 238 get { return null; }
239 } 239 }
@@ -255,84 +255,121 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
255 #endregion 255 #endregion
256 256
257 #region EventHandlers 257 #region EventHandlers
258
259 private void OnMakeRoot(ScenePresence sp)
260 {
261 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
262
263 sp.ControllingClient.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
264 // Used for Notices and Group Invites/Accept/Reject
265 sp.ControllingClient.OnInstantMessage += OnInstantMessage;
266
267 // comented out because some viewers no longer suport it
268 // sp.ControllingClient.AddGenericPacketHandler("avatargroupsrequest", AvatarGroupsRequest);
269
270 // we should send a DataUpdate here for compatibility,
271 // but this is a bad place and a bad thread to do it
272 // also current viewers do ignore it and ask later on a much nicer thread
273 }
274
275 private void OnMakeChild(ScenePresence sp)
276 {
277 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
278
279 sp.ControllingClient.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
280 sp.ControllingClient.OnInstantMessage -= OnInstantMessage;
281 }
282
258 private void OnNewClient(IClientAPI client) 283 private void OnNewClient(IClientAPI client)
259 { 284 {
260 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 285 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
261 286
262 client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
263 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; 287 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
264 client.OnRequestAvatarProperties += OnRequestAvatarProperties; 288 client.OnRequestAvatarProperties += OnRequestAvatarProperties;
265 289
266 // Used for Notices and Group Invites/Accept/Reject
267 client.OnInstantMessage += OnInstantMessage;
268 290
269 // Send client their groups information.
270 SendAgentGroupDataUpdate(client, client.AgentId);
271 } 291 }
272 292
293/* this should be the right message to ask for other avatars groups
294
295 private void AvatarGroupsRequest(Object sender, string method, List<String> args)
296 {
297 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
298
299 if (!(sender is IClientAPI))
300 return;
301
302 IClientAPI remoteClient = (IClientAPI)sender;
303
304 UUID avatarID;
305 UUID.TryParse(args[0], out avatarID);
306
307 if (avatarID != UUID.Zero)
308 {
309 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
310 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
311 }
312 }
313*/
314
315 // this should not be used to send groups memberships, but some viewers do expect it
316 // it does send unnecessary memberships, when viewers just want other properties information
273 private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) 317 private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
274 { 318 {
275 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 319 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
276 320
277 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
278 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 321 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
279 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 322 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
280 } 323 }
281 324
282 /* 325
283 * This becomes very problematic in a shared module. In a shared module you may have more then one 326 private void OnClientClosed(UUID AgentId, Scene scene)
284 * reference to IClientAPI's, one for 0 or 1 root connections, and 0 or more child connections.
285 * The OnClientClosed event does not provide anything to indicate which one of those should be closed
286 * nor does it provide what scene it was from so that the specific reference can be looked up.
287 * The InstantMessageModule.cs does not currently worry about unregistering the handles,
288 * and it should be an issue, since it's the client that references us not the other way around
289 * , so as long as we don't keep a reference to the client laying around, the client can still be GC'ed
290 private void OnClientClosed(UUID AgentId)
291 { 327 {
292 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 328 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
329 if (scene == null)
330 return;
293 331
294 lock (m_ActiveClients) 332 ScenePresence sp = scene.GetScenePresence(AgentId);
333 IClientAPI client = sp.ControllingClient;
334 if (client != null)
295 { 335 {
296 if (m_ActiveClients.ContainsKey(AgentId)) 336 client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest;
337 client.OnRequestAvatarProperties -= OnRequestAvatarProperties;
338 // make child possible not called?
339 client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
340 client.OnInstantMessage -= OnInstantMessage;
341 }
342
343/*
344 lock (m_ActiveClients)
297 { 345 {
298 IClientAPI client = m_ActiveClients[AgentId]; 346 if (m_ActiveClients.ContainsKey(AgentId))
299 client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest; 347 {
300 client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest; 348 IClientAPI client = m_ActiveClients[AgentId];
301 client.OnDirFindQuery -= OnDirFindQuery; 349 client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
302 client.OnInstantMessage -= OnInstantMessage; 350 client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest;
351 client.OnDirFindQuery -= OnDirFindQuery;
352 client.OnInstantMessage -= OnInstantMessage;
303 353
304 m_ActiveClients.Remove(AgentId); 354 m_ActiveClients.Remove(AgentId);
305 } 355 }
306 else 356 else
307 { 357 {
308 if (m_debugEnabled) m_log.WarnFormat("[GROUPS]: Client closed that wasn't registered here."); 358 if (m_debugEnabled) m_log.WarnFormat("[GROUPS]: Client closed that wasn't registered here.");
359 }
309 } 360 }
310 361*/
311
312 }
313 } 362 }
314 */
315 363
316 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) 364 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
317 { 365 {
318 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 366 // this a private message for own agent only
319 367 if (dataForAgentID != GetRequestingAgentID(remoteClient))
320 UUID activeGroupID = UUID.Zero; 368 return;
321 string activeGroupTitle = string.Empty;
322 string activeGroupName = string.Empty;
323 ulong activeGroupPowers = (ulong)GroupPowers.None;
324
325 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID);
326 if (membership != null)
327 {
328 activeGroupID = membership.GroupID;
329 activeGroupTitle = membership.GroupTitle;
330 activeGroupPowers = membership.GroupPowers;
331 }
332
333 SendAgentDataUpdate(remoteClient, dataForAgentID, activeGroupID, activeGroupName, activeGroupPowers, activeGroupTitle);
334 369
335 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 370 SendAgentGroupDataUpdate(remoteClient, false);
371 // its a info request not a change, so nothing is sent to others
372 // they do get the group title with the avatar object update on arrivel to a region
336 } 373 }
337 374
338 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient) 375 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient)
@@ -403,7 +440,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
403 440
404 OutgoingInstantMessage(msg, inviteInfo.AgentID); 441 OutgoingInstantMessage(msg, inviteInfo.AgentID);
405 442
406 UpdateAllClientsWithGroupInfo(inviteInfo.AgentID); 443 IClientAPI client = GetActiveClient(inviteInfo.AgentID);
444 if (client != null)
445 SendDataUpdate(remoteClient, true);
407 446
408 // TODO: If the inviter is still online, they need an agent dataupdate 447 // TODO: If the inviter is still online, they need an agent dataupdate
409 // and maybe group membership updates for the invitee 448 // and maybe group membership updates for the invitee
@@ -656,13 +695,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
656 { 695 {
657 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 696 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
658 697
659 m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 698 UUID agentID = GetRequestingAgentID(remoteClient);
699 m_groupData.SetAgentActiveGroup(agentID, agentID, groupID);
660 700
661 // Changing active group changes title, active powers, all kinds of things 701 // llClientView does this
662 // anyone who is in any region that can see this client, should probably be 702 SendAgentGroupDataUpdate(remoteClient, true);
663 // updated with new group info. At a minimum, they should get ScenePresence
664 // updated with new title.
665 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
666 } 703 }
667 704
668 /// <summary> 705 /// <summary>
@@ -672,7 +709,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
672 { 709 {
673 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 710 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
674 711
675
676 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 712 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
677 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 713 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
678 714
@@ -710,7 +746,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
710 } 746 }
711 747
712 return data; 748 return data;
713
714 } 749 }
715 750
716 public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID) 751 public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID)
@@ -848,7 +883,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
848 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 883 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
849 884
850 // Update the founder with new group information. 885 // Update the founder with new group information.
851 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 886 SendAgentGroupDataUpdate(remoteClient, false);
852 887
853 return groupID; 888 return groupID;
854 } 889 }
@@ -889,10 +924,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
889 // TODO: Not sure what all is needed here, but if the active group role change is for the group 924 // TODO: Not sure what all is needed here, but if the active group role change is for the group
890 // the client currently has set active, then we need to do a scene presence update too 925 // the client currently has set active, then we need to do a scene presence update too
891 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) 926 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
892
893 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
894 }
895 927
928 SendDataUpdate(remoteClient, true);
929 }
896 930
897 public void GroupRoleUpdate(IClientAPI remoteClient, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, byte updateType) 931 public void GroupRoleUpdate(IClientAPI remoteClient, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, byte updateType)
898 { 932 {
@@ -929,7 +963,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
929 } 963 }
930 964
931 // TODO: This update really should send out updates for everyone in the role that just got changed. 965 // TODO: This update really should send out updates for everyone in the role that just got changed.
932 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 966 SendAgentGroupDataUpdate(remoteClient, false);
933 } 967 }
934 968
935 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 969 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -955,7 +989,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
955 } 989 }
956 990
957 // TODO: This update really should send out updates for everyone in the role that just got changed. 991 // TODO: This update really should send out updates for everyone in the role that just got changed.
958 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 992 SendAgentGroupDataUpdate(remoteClient, false);
959 } 993 }
960 994
961 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 995 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
@@ -983,7 +1017,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
983 msg.toAgentID = agentID.Guid; 1017 msg.toAgentID = agentID.Guid;
984 msg.dialog = dialog; 1018 msg.dialog = dialog;
985 msg.fromGroup = true; 1019 msg.fromGroup = true;
986 msg.offline = (byte)0; 1020 msg.offline = (byte)1; // Allow this message to be stored for offline use
987 msg.ParentEstateID = 0; 1021 msg.ParentEstateID = 0;
988 msg.Position = Vector3.Zero; 1022 msg.Position = Vector3.Zero;
989 msg.RegionID = UUID.Zero.Guid; 1023 msg.RegionID = UUID.Zero.Guid;
@@ -1035,14 +1069,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1035 return msg; 1069 return msg;
1036 } 1070 }
1037 1071
1038 public void SendAgentGroupDataUpdate(IClientAPI remoteClient)
1039 {
1040 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1041
1042 // Send agent information about his groups
1043 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
1044 }
1045
1046 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 1072 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
1047 { 1073 {
1048 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1074 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -1052,8 +1078,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1052 1078
1053 remoteClient.SendJoinGroupReply(groupID, true); 1079 remoteClient.SendJoinGroupReply(groupID, true);
1054 1080
1055 // Should this send updates to everyone in the group? 1081 SendAgentGroupDataUpdate(remoteClient, true);
1056 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
1057 } 1082 }
1058 1083
1059 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 1084 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
@@ -1068,7 +1093,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1068 1093
1069 // SL sends out notifcations to the group messaging session that the person has left 1094 // SL sends out notifcations to the group messaging session that the person has left
1070 // Should this also update everyone who is in the group? 1095 // Should this also update everyone who is in the group?
1071 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 1096 SendAgentGroupDataUpdate(remoteClient, true);
1072 } 1097 }
1073 1098
1074 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 1099 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
@@ -1177,10 +1202,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1177 msg.binaryBucket = new byte[0]; 1202 msg.binaryBucket = new byte[0];
1178 OutgoingInstantMessage(msg, agentID); 1203 OutgoingInstantMessage(msg, agentID);
1179 1204
1180
1181 // SL sends out messages to everyone in the group 1205 // SL sends out messages to everyone in the group
1182 // Who all should receive updates and what should they be updated with? 1206 // Who all should receive updates and what should they be updated with?
1183 UpdateAllClientsWithGroupInfo(ejecteeID); 1207 // just tell this the group change
1208 SendAgentGroupDataUpdate(remoteClient, false);
1209 // TODO fix the rest of sends
1184 } 1210 }
1185 1211
1186 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) 1212 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID)
@@ -1303,67 +1329,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1303 return child; 1329 return child;
1304 } 1330 }
1305 1331
1306 /// <summary>
1307 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1308 /// </summary>
1309 private void SendGroupMembershipInfoViaCaps(IClientAPI remoteClient, UUID dataForAgentID, GroupMembershipData[] data)
1310 {
1311 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1312
1313 OSDArray AgentData = new OSDArray(1);
1314 OSDMap AgentDataMap = new OSDMap(1);
1315 AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID));
1316 AgentData.Add(AgentDataMap);
1317
1318 OSDArray GroupData = new OSDArray(data.Length);
1319 OSDArray NewGroupData = new OSDArray(data.Length);
1320
1321 foreach (GroupMembershipData membership in data)
1322 {
1323 if (GetRequestingAgentID(remoteClient) != dataForAgentID)
1324 {
1325 if (!membership.ListInProfile)
1326 {
1327 // If we're sending group info to remoteclient about another agent,
1328 // filter out groups the other agent doesn't want to share.
1329 continue;
1330 }
1331 }
1332
1333 OSDMap GroupDataMap = new OSDMap(6);
1334 OSDMap NewGroupDataMap = new OSDMap(1);
1335
1336 GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID));
1337 GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers));
1338 GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices));
1339 GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture));
1340 GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution));
1341 GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName));
1342 NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile));
1343
1344 GroupData.Add(GroupDataMap);
1345 NewGroupData.Add(NewGroupDataMap);
1346 }
1347
1348 OSDMap llDataStruct = new OSDMap(3);
1349 llDataStruct.Add("AgentData", AgentData);
1350 llDataStruct.Add("GroupData", GroupData);
1351 llDataStruct.Add("NewGroupData", NewGroupData);
1352
1353 if (m_debugEnabled)
1354 {
1355 m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1356 }
1357
1358 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1359
1360 if (queue != null)
1361 {
1362 queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient));
1363 }
1364
1365 }
1366
1367 private void SendScenePresenceUpdate(UUID AgentID, string Title) 1332 private void SendScenePresenceUpdate(UUID AgentID, string Title)
1368 { 1333 {
1369 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Updating scene title for {0} with title: {1}", AgentID, Title); 1334 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Updating scene title for {0} with title: {1}", AgentID, Title);
@@ -1380,54 +1345,35 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1380 presence.Grouptitle = Title; 1345 presence.Grouptitle = Title;
1381 1346
1382 if (! presence.IsChildAgent) 1347 if (! presence.IsChildAgent)
1383 presence.SendAvatarDataToAllClients(); 1348 presence.SendAvatarDataToAllAgents();
1384 } 1349 }
1385 } 1350 }
1386 } 1351 }
1387 } 1352 }
1388 1353
1389 /// <summary> 1354 public void SendAgentGroupDataUpdate(IClientAPI remoteClient)
1390 /// Send updates to all clients who might be interested in groups data for dataForClientID
1391 /// </summary>
1392 private void UpdateAllClientsWithGroupInfo(UUID dataForClientID)
1393 { 1355 {
1394 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1356 SendAgentGroupDataUpdate(remoteClient, true);
1395
1396 // TODO: Probably isn't nessesary to update every client in every scene.
1397 // Need to examine client updates and do only what's nessesary.
1398 lock (m_sceneList)
1399 {
1400 foreach (Scene scene in m_sceneList)
1401 {
1402 scene.ForEachClient(delegate(IClientAPI client) { SendAgentGroupDataUpdate(client, dataForClientID); });
1403 }
1404 }
1405 } 1357 }
1406 1358
1407 /// <summary> 1359 /// <summary>
1408 /// Update remoteClient with group information about dataForAgentID 1360 /// Tell remoteClient about its agent groups, and optionally send title to others
1409 /// </summary> 1361 /// </summary>
1410 private void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForAgentID) 1362 private void SendAgentGroupDataUpdate(IClientAPI remoteClient, bool tellOthers)
1411 { 1363 {
1412 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name); 1364 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name);
1413 1365
1414 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1366 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
1415 1367
1416 OnAgentDataUpdateRequest(remoteClient, dataForAgentID, UUID.Zero); 1368 UUID agentID = GetRequestingAgentID(remoteClient);
1417 1369
1418 // Need to send a group membership update to the client 1370 SendDataUpdate(remoteClient, tellOthers);
1419 // UDP version doesn't seem to behave nicely. But we're going to send it out here
1420 // with an empty group membership to hopefully remove groups being displayed due
1421 // to the core Groups Stub
1422 remoteClient.SendGroupMembership(new GroupMembershipData[0]);
1423 1371
1424 GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, dataForAgentID); 1372 GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, agentID);
1425 SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray); 1373 remoteClient.SendAgentGroupDataUpdate(agentID, membershipArray);
1426 remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray);
1427 1374
1428 if (remoteClient.AgentId == dataForAgentID) 1375 remoteClient.RefreshGroupMembership();
1429 remoteClient.RefreshGroupMembership(); 1376 }
1430 }
1431 1377
1432 /// <summary> 1378 /// <summary>
1433 /// Get a list of groups memberships for the agent that are marked "ListInProfile" 1379 /// Get a list of groups memberships for the agent that are marked "ListInProfile"
@@ -1478,13 +1424,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1478 return membershipArray; 1424 return membershipArray;
1479 } 1425 }
1480 1426
1481 1427 //tell remoteClient about its agent group info, and optionally send title to others
1482 private void SendAgentDataUpdate(IClientAPI remoteClient, UUID dataForAgentID, UUID activeGroupID, string activeGroupName, ulong activeGroupPowers, string activeGroupTitle) 1428 private void SendDataUpdate(IClientAPI remoteClient, bool tellOthers)
1483 { 1429 {
1484 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1430 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1485 1431
1486 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1432 UUID activeGroupID = UUID.Zero;
1487 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID); 1433 string activeGroupTitle = string.Empty;
1434 string activeGroupName = string.Empty;
1435 ulong activeGroupPowers = (ulong)GroupPowers.None;
1436
1437 UUID agentID = GetRequestingAgentID(remoteClient);
1438 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(agentID, agentID);
1439 if (membership != null)
1440 {
1441 activeGroupID = membership.GroupID;
1442 activeGroupTitle = membership.GroupTitle;
1443 activeGroupPowers = membership.GroupPowers;
1444 activeGroupName = membership.GroupName;
1445 }
1446
1447 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, agentID);
1488 string firstname, lastname; 1448 string firstname, lastname;
1489 if (account != null) 1449 if (account != null)
1490 { 1450 {
@@ -1497,9 +1457,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1497 lastname = "Unknown"; 1457 lastname = "Unknown";
1498 } 1458 }
1499 1459
1500 remoteClient.SendAgentDataUpdate(dataForAgentID, activeGroupID, firstname, 1460 remoteClient.SendAgentDataUpdate(agentID, activeGroupID, firstname,
1501 lastname, activeGroupPowers, activeGroupName, 1461 lastname, activeGroupPowers, activeGroupName,
1502 activeGroupTitle); 1462 activeGroupTitle);
1463
1464 if (tellOthers)
1465 SendScenePresenceUpdate(agentID, activeGroupTitle);
1466
1467 ScenePresence sp = (ScenePresence)remoteClient.SceneAgent;
1468 if (sp != null)
1469 sp.Grouptitle = activeGroupTitle;
1503 } 1470 }
1504 1471
1505 #endregion 1472 #endregion