aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Addons/Groups
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Addons/Groups')
-rw-r--r--OpenSim/Addons/Groups/GroupsModule.cs273
1 files changed, 96 insertions, 177 deletions
diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs
index d121d1a..da8c9ea 100644
--- a/OpenSim/Addons/Groups/GroupsModule.cs
+++ b/OpenSim/Addons/Groups/GroupsModule.cs
@@ -137,13 +137,6 @@ namespace OpenSim.Groups
137 137
138 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 138 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
139 139
140 scene.EventManager.OnNewClient += OnNewClient;
141 scene.EventManager.OnMakeRootAgent += OnMakeRoot;
142 scene.EventManager.OnMakeChildAgent += OnMakeChild;
143 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
144 // The InstantMessageModule itself doesn't do this,
145 // so lets see if things explode if we don't do it
146 // scene.EventManager.OnClientClosed += OnClientClosed;
147 140
148 if (m_groupData == null) 141 if (m_groupData == null)
149 { 142 {
@@ -182,6 +175,13 @@ namespace OpenSim.Groups
182 m_sceneList.Add(scene); 175 m_sceneList.Add(scene);
183 } 176 }
184 177
178 scene.EventManager.OnNewClient += OnNewClient;
179 scene.EventManager.OnMakeRootAgent += OnMakeRoot;
180 scene.EventManager.OnMakeChildAgent += OnMakeChild;
181 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
182 // The InstantMessageModule itself doesn't do this,
183 // so lets see if things explode if we don't do it
184 // scene.EventManager.OnClientClosed += OnClientClosed;
185 185
186 } 186 }
187 187
@@ -237,6 +237,7 @@ namespace OpenSim.Groups
237 client.OnRequestAvatarProperties += OnRequestAvatarProperties; 237 client.OnRequestAvatarProperties += OnRequestAvatarProperties;
238 } 238 }
239 239
240
240 private void OnMakeRoot(ScenePresence sp) 241 private void OnMakeRoot(ScenePresence sp)
241 { 242 {
242 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 243 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -245,8 +246,9 @@ namespace OpenSim.Groups
245 // Used for Notices and Group Invites/Accept/Reject 246 // Used for Notices and Group Invites/Accept/Reject
246 sp.ControllingClient.OnInstantMessage += OnInstantMessage; 247 sp.ControllingClient.OnInstantMessage += OnInstantMessage;
247 248
248 // Send client their groups information. 249 // we should send a DataUpdate here for compatibility,
249 SendAgentGroupDataUpdate(sp.ControllingClient, sp.UUID); 250 // but this is a bad place and a bad thread to do it
251 // also current viewers do ignore it and ask later on a much nicer thread
250 } 252 }
251 253
252 private void OnMakeChild(ScenePresence sp) 254 private void OnMakeChild(ScenePresence sp)
@@ -262,23 +264,28 @@ namespace OpenSim.Groups
262 { 264 {
263 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 265 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
264 266
265 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
266 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 267 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
267 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 268 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
268 } 269 }
269 270
270 /* 271 private void OnClientClosed(UUID AgentId, Scene scene)
271 * This becomes very problematic in a shared module. In a shared module you may have more then one
272 * reference to IClientAPI's, one for 0 or 1 root connections, and 0 or more child connections.
273 * The OnClientClosed event does not provide anything to indicate which one of those should be closed
274 * nor does it provide what scene it was from so that the specific reference can be looked up.
275 * The InstantMessageModule.cs does not currently worry about unregistering the handles,
276 * and it should be an issue, since it's the client that references us not the other way around
277 * , so as long as we don't keep a reference to the client laying around, the client can still be GC'ed
278 private void OnClientClosed(UUID AgentId)
279 { 272 {
280 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 273 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
274 if (scene == null)
275 return;
281 276
277 ScenePresence sp = scene.GetScenePresence(AgentId);
278 IClientAPI client = sp.ControllingClient;
279 if (client != null)
280 {
281 client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest;
282 client.OnRequestAvatarProperties -= OnRequestAvatarProperties;
283 // make child possible not called?
284 client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
285 client.OnInstantMessage -= OnInstantMessage;
286 }
287
288 /*
282 lock (m_ActiveClients) 289 lock (m_ActiveClients)
283 { 290 {
284 if (m_ActiveClients.ContainsKey(AgentId)) 291 if (m_ActiveClients.ContainsKey(AgentId))
@@ -296,31 +303,20 @@ namespace OpenSim.Groups
296 if (m_debugEnabled) m_log.WarnFormat("[Groups]: Client closed that wasn't registered here."); 303 if (m_debugEnabled) m_log.WarnFormat("[Groups]: Client closed that wasn't registered here.");
297 } 304 }
298 305
299
300 }
301 } 306 }
302 */ 307 */
303 308
309 }
310
304 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) 311 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
305 { 312 {
306 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 313 // this a private message for own agent only
307 314 if (dataForAgentID != GetRequestingAgentID(remoteClient))
308 UUID activeGroupID = UUID.Zero; 315 return;
309 string activeGroupTitle = string.Empty;
310 string activeGroupName = string.Empty;
311 ulong activeGroupPowers = (ulong)GroupPowers.None;
312
313 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentIDStr(remoteClient), dataForAgentID.ToString());
314 if (membership != null)
315 {
316 activeGroupID = membership.GroupID;
317 activeGroupTitle = membership.GroupTitle;
318 activeGroupPowers = membership.GroupPowers;
319 }
320
321 SendAgentDataUpdate(remoteClient, dataForAgentID, activeGroupID, activeGroupName, activeGroupPowers, activeGroupTitle);
322 316
323 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 317 SendAgentGroupDataUpdate(remoteClient, false);
318 // its a info request not a change, so nothing is sent to others
319 // they do get the group title with the avatar object update on arrivel to a region
324 } 320 }
325 321
326 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient) 322 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient)
@@ -395,11 +391,12 @@ namespace OpenSim.Groups
395 391
396 OutgoingInstantMessage(msg, invitee); 392 OutgoingInstantMessage(msg, invitee);
397 393
398 UpdateAllClientsWithGroupInfo(invitee); 394 IClientAPI client = GetActiveClient(invitee);
395 if (client != null)
396 SendDataUpdate(remoteClient, true);
399 } 397 }
400 398
401 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentIDStr(remoteClient), inviteID); 399 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentIDStr(remoteClient), inviteID);
402
403 } 400 }
404 401
405 // Reject 402 // Reject
@@ -462,7 +459,6 @@ namespace OpenSim.Groups
462 { 459 {
463 OnNewGroupNotice(GroupID, NoticeID); 460 OnNewGroupNotice(GroupID, NoticeID);
464 } 461 }
465
466 462
467 // Send notice out to everyone that wants notices 463 // Send notice out to everyone that wants notices
468 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), GroupID)) 464 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), GroupID))
@@ -508,7 +504,6 @@ namespace OpenSim.Groups
508 504
509 remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0); 505 remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0);
510 } 506 }
511
512 } 507 }
513 508
514 // Interop, received special 210 code for ejecting a group member 509 // Interop, received special 210 code for ejecting a group member
@@ -583,11 +578,7 @@ namespace OpenSim.Groups
583 578
584 m_groupData.SetAgentActiveGroup(GetRequestingAgentIDStr(remoteClient), GetRequestingAgentIDStr(remoteClient), groupID); 579 m_groupData.SetAgentActiveGroup(GetRequestingAgentIDStr(remoteClient), GetRequestingAgentIDStr(remoteClient), groupID);
585 580
586 // Changing active group changes title, active powers, all kinds of things 581 SendAgentGroupDataUpdate(remoteClient, true);
587 // anyone who is in any region that can see this client, should probably be
588 // updated with new group info. At a minimum, they should get ScenePresence
589 // updated with new title.
590 UpdateAllClientsWithGroupInfo(remoteClient.AgentId);
591 } 582 }
592 583
593 /// <summary> 584 /// <summary>
@@ -634,7 +625,6 @@ namespace OpenSim.Groups
634 } 625 }
635 626
636 return data; 627 return data;
637
638 } 628 }
639 629
640 public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID) 630 public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID)
@@ -781,7 +771,7 @@ namespace OpenSim.Groups
781 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 771 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
782 772
783 // Update the founder with new group information. 773 // Update the founder with new group information.
784 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 774 SendAgentGroupDataUpdate(remoteClient, false);
785 } 775 }
786 else 776 else
787 remoteClient.SendCreateGroupReply(groupID, false, reason); 777 remoteClient.SendCreateGroupReply(groupID, false, reason);
@@ -834,7 +824,7 @@ namespace OpenSim.Groups
834 // the client currently has set active, then we need to do a scene presence update too 824 // the client currently has set active, then we need to do a scene presence update too
835 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) 825 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
836 826
837 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); 827 SendDataUpdate(remoteClient, true);
838 } 828 }
839 829
840 830
@@ -875,7 +865,7 @@ namespace OpenSim.Groups
875 } 865 }
876 866
877 // TODO: This update really should send out updates for everyone in the role that just got changed. 867 // TODO: This update really should send out updates for everyone in the role that just got changed.
878 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 868 SendDataUpdate(remoteClient, true);
879 } 869 }
880 870
881 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 871 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -901,7 +891,7 @@ namespace OpenSim.Groups
901 } 891 }
902 892
903 // TODO: This update really should send out updates for everyone in the role that just got changed. 893 // TODO: This update really should send out updates for everyone in the role that just got changed.
904 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 894 SendDataUpdate(remoteClient, true);
905 } 895 }
906 896
907 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 897 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
@@ -969,14 +959,6 @@ namespace OpenSim.Groups
969 return msg; 959 return msg;
970 } 960 }
971 961
972 public void SendAgentGroupDataUpdate(IClientAPI remoteClient)
973 {
974 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
975
976 // Send agent information about his groups
977 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
978 }
979
980 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 962 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
981 { 963 {
982 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 964 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -989,7 +971,7 @@ namespace OpenSim.Groups
989 remoteClient.SendJoinGroupReply(groupID, true); 971 remoteClient.SendJoinGroupReply(groupID, true);
990 972
991 // Should this send updates to everyone in the group? 973 // Should this send updates to everyone in the group?
992 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 974 SendAgentGroupDataUpdate(remoteClient, true);
993 975
994 if (reason != string.Empty) 976 if (reason != string.Empty)
995 // A warning 977 // A warning
@@ -1011,7 +993,7 @@ namespace OpenSim.Groups
1011 993
1012 // SL sends out notifcations to the group messaging session that the person has left 994 // SL sends out notifcations to the group messaging session that the person has left
1013 // Should this also update everyone who is in the group? 995 // Should this also update everyone who is in the group?
1014 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 996 SendAgentGroupDataUpdate(remoteClient, true);
1015 } 997 }
1016 998
1017 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 999 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
@@ -1123,7 +1105,7 @@ namespace OpenSim.Groups
1123 1105
1124 // SL sends out messages to everyone in the group 1106 // SL sends out messages to everyone in the group
1125 // Who all should receive updates and what should they be updated with? 1107 // Who all should receive updates and what should they be updated with?
1126 UpdateAllClientsWithGroupInfo(ejecteeID); 1108 SendAgentGroupDataUpdate(remoteClient, false);
1127 } 1109 }
1128 1110
1129 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) 1111 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID)
@@ -1215,71 +1197,6 @@ namespace OpenSim.Groups
1215 return child; 1197 return child;
1216 } 1198 }
1217 1199
1218 /// <summary>
1219 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1220 /// </summary>
1221 private void SendGroupMembershipInfoViaCaps(IClientAPI remoteClient, UUID dataForAgentID, GroupMembershipData[] data)
1222 {
1223 if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1224
1225 // NPCs currently don't have a CAPs structure or event queues. There is a strong argument for conveying this information
1226 // to them anyway since it makes writing server-side bots a lot easier, but for now we don't do anything.
1227 if (remoteClient.SceneAgent.PresenceType == PresenceType.Npc)
1228 return;
1229
1230 OSDArray AgentData = new OSDArray(1);
1231 OSDMap AgentDataMap = new OSDMap(1);
1232 AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID));
1233 AgentData.Add(AgentDataMap);
1234
1235 OSDArray GroupData = new OSDArray(data.Length);
1236 OSDArray NewGroupData = new OSDArray(data.Length);
1237
1238 foreach (GroupMembershipData membership in data)
1239 {
1240 if (GetRequestingAgentID(remoteClient) != dataForAgentID)
1241 {
1242 if (!membership.ListInProfile)
1243 {
1244 // If we're sending group info to remoteclient about another agent,
1245 // filter out groups the other agent doesn't want to share.
1246 continue;
1247 }
1248 }
1249
1250 OSDMap GroupDataMap = new OSDMap(6);
1251 OSDMap NewGroupDataMap = new OSDMap(1);
1252
1253 GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID));
1254 GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers));
1255 GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices));
1256 GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture));
1257 GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution));
1258 GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName));
1259 NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile));
1260
1261 GroupData.Add(GroupDataMap);
1262 NewGroupData.Add(NewGroupDataMap);
1263 }
1264
1265 OSDMap llDataStruct = new OSDMap(3);
1266 llDataStruct.Add("AgentData", AgentData);
1267 llDataStruct.Add("GroupData", GroupData);
1268 llDataStruct.Add("NewGroupData", NewGroupData);
1269
1270 if (m_debugEnabled)
1271 {
1272 m_log.InfoFormat("[Groups]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1273 }
1274
1275 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1276
1277 if (queue != null)
1278 {
1279 queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient));
1280 }
1281 }
1282
1283 private void SendScenePresenceUpdate(UUID AgentID, string Title) 1200 private void SendScenePresenceUpdate(UUID AgentID, string Title)
1284 { 1201 {
1285 if (m_debugEnabled) m_log.DebugFormat("[Groups]: Updating scene title for {0} with title: {1}", AgentID, Title); 1202 if (m_debugEnabled) m_log.DebugFormat("[Groups]: Updating scene title for {0} with title: {1}", AgentID, Title);
@@ -1296,53 +1213,34 @@ namespace OpenSim.Groups
1296 presence.Grouptitle = Title; 1213 presence.Grouptitle = Title;
1297 1214
1298 if (! presence.IsChildAgent) 1215 if (! presence.IsChildAgent)
1299 presence.SendAvatarDataToAllClients(); 1216 presence.SendAvatarDataToAllAgents();
1300 } 1217 }
1301 } 1218 }
1302 } 1219 }
1303 } 1220 }
1304 1221
1305 /// <summary> 1222 public void SendAgentGroupDataUpdate(IClientAPI remoteClient)
1306 /// Send updates to all clients who might be interested in groups data for dataForClientID
1307 /// </summary>
1308 private void UpdateAllClientsWithGroupInfo(UUID dataForClientID)
1309 { 1223 {
1310 if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1224 SendAgentGroupDataUpdate(remoteClient, true);
1311
1312 // TODO: Probably isn't nessesary to update every client in every scene.
1313 // Need to examine client updates and do only what's nessesary.
1314 lock (m_sceneList)
1315 {
1316 foreach (Scene scene in m_sceneList)
1317 {
1318 scene.ForEachClient(delegate(IClientAPI client) { SendAgentGroupDataUpdate(client, dataForClientID); });
1319 }
1320 }
1321 } 1225 }
1322 1226
1323 /// <summary> 1227 /// <summary>
1324 /// Update remoteClient with group information about dataForAgentID 1228 /// Tell remoteClient about its agent groups, and optionally send title to others
1325 /// </summary> 1229 /// </summary>
1326 private void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForAgentID) 1230 private void SendAgentGroupDataUpdate(IClientAPI remoteClient, bool tellOthers)
1327 { 1231 {
1328 if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name); 1232 if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name);
1329 1233
1330 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1234 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
1331 1235
1332 OnAgentDataUpdateRequest(remoteClient, dataForAgentID, UUID.Zero); 1236 UUID agentID = GetRequestingAgentID(remoteClient);
1333 1237
1334 // Need to send a group membership update to the client 1238 SendDataUpdate(remoteClient, tellOthers);
1335 // UDP version doesn't seem to behave nicely. But we're going to send it out here
1336 // with an empty group membership to hopefully remove groups being displayed due
1337 // to the core Groups Stub
1338 //remoteClient.SendGroupMembership(new GroupMembershipData[0]);
1339 1239
1340 GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, dataForAgentID); 1240 GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, agentID);
1341 SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray); 1241 remoteClient.SendAgentGroupDataUpdate(agentID, membershipArray);
1342 1242
1343 //remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray); 1243 remoteClient.RefreshGroupMembership();
1344 if (remoteClient.AgentId == dataForAgentID)
1345 remoteClient.RefreshGroupMembership();
1346 } 1244 }
1347 1245
1348 /// <summary> 1246 /// <summary>
@@ -1394,27 +1292,49 @@ namespace OpenSim.Groups
1394 return membershipArray; 1292 return membershipArray;
1395 } 1293 }
1396 1294
1397 1295 //tell remoteClient about its agent group info, and optionally send title to others
1398 private void SendAgentDataUpdate(IClientAPI remoteClient, UUID dataForAgentID, UUID activeGroupID, string activeGroupName, ulong activeGroupPowers, string activeGroupTitle) 1296 private void SendDataUpdate(IClientAPI remoteClient, bool tellOthers)
1399 { 1297 {
1400 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1298 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1401 1299
1402 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1300 UUID activeGroupID = UUID.Zero;
1403 string firstname = "Unknown", lastname = "Unknown"; 1301 string activeGroupTitle = string.Empty;
1404 string name = m_UserManagement.GetUserName(dataForAgentID); 1302 string activeGroupName = string.Empty;
1405 if (!string.IsNullOrEmpty(name)) 1303 ulong activeGroupPowers = (ulong)GroupPowers.None;
1304
1305 UUID agentID = GetRequestingAgentID(remoteClient);
1306 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(agentID.ToString(), agentID.ToString());
1307 if (membership != null)
1406 { 1308 {
1407 string[] parts = name.Split(new char[] { ' ' }); 1309 activeGroupID = membership.GroupID;
1408 if (parts.Length >= 2) 1310 activeGroupTitle = membership.GroupTitle;
1409 { 1311 activeGroupPowers = membership.GroupPowers;
1410 firstname = parts[0]; 1312 activeGroupName = membership.GroupName;
1411 lastname = parts[1];
1412 }
1413 } 1313 }
1414 1314
1415 remoteClient.SendAgentDataUpdate(dataForAgentID, activeGroupID, firstname, 1315 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, agentID);
1316 string firstname, lastname;
1317 if (account != null)
1318 {
1319 firstname = account.FirstName;
1320 lastname = account.LastName;
1321 }
1322 else
1323 {
1324 firstname = "Unknown";
1325 lastname = "Unknown";
1326 }
1327
1328 remoteClient.SendAgentDataUpdate(agentID, activeGroupID, firstname,
1416 lastname, activeGroupPowers, activeGroupName, 1329 lastname, activeGroupPowers, activeGroupName,
1417 activeGroupTitle); 1330 activeGroupTitle);
1331
1332 if (tellOthers)
1333 SendScenePresenceUpdate(agentID, activeGroupTitle);
1334
1335 ScenePresence sp = (ScenePresence)remoteClient.SceneAgent;
1336 if (sp != null)
1337 sp.Grouptitle = activeGroupTitle;
1418 } 1338 }
1419 1339
1420 #endregion 1340 #endregion
@@ -1463,5 +1383,4 @@ namespace OpenSim.Groups
1463 } 1383 }
1464 1384
1465 } 1385 }
1466
1467} 1386}