diff options
author | root | 2013-09-07 17:58:32 +0200 |
---|---|---|
committer | root | 2013-09-07 17:58:32 +0200 |
commit | 844ae7720e02d01b839986e0ba8fab93f9c93c05 (patch) | |
tree | 8d8f4c2628261fd75922af215bcf609ad62fa577 /OpenSim/Addons/Groups/GroupsModule.cs | |
parent | Add two argument constructor to GridInstantMessage (diff) | |
download | opensim-SC-844ae7720e02d01b839986e0ba8fab93f9c93c05.zip opensim-SC-844ae7720e02d01b839986e0ba8fab93f9c93c05.tar.gz opensim-SC-844ae7720e02d01b839986e0ba8fab93f9c93c05.tar.bz2 opensim-SC-844ae7720e02d01b839986e0ba8fab93f9c93c05.tar.xz |
Bring Core Groups up to current version
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Addons/Groups/GroupsModule.cs | 109 |
1 files changed, 55 insertions, 54 deletions
diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs index f805d69..b0493fa 100644 --- a/OpenSim/Addons/Groups/GroupsModule.cs +++ b/OpenSim/Addons/Groups/GroupsModule.cs | |||
@@ -141,6 +141,8 @@ namespace OpenSim.Groups | |||
141 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 141 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
142 | 142 | ||
143 | scene.EventManager.OnNewClient += OnNewClient; | 143 | scene.EventManager.OnNewClient += OnNewClient; |
144 | scene.EventManager.OnMakeRootAgent += OnMakeRoot; | ||
145 | scene.EventManager.OnMakeChildAgent += OnMakeChild; | ||
144 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 146 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; |
145 | // The InstantMessageModule itself doesn't do this, | 147 | // The InstantMessageModule itself doesn't do this, |
146 | // so lets see if things explode if we don't do it | 148 | // so lets see if things explode if we don't do it |
@@ -194,6 +196,8 @@ namespace OpenSim.Groups | |||
194 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 196 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
195 | 197 | ||
196 | scene.EventManager.OnNewClient -= OnNewClient; | 198 | scene.EventManager.OnNewClient -= OnNewClient; |
199 | scene.EventManager.OnMakeRootAgent -= OnMakeRoot; | ||
200 | scene.EventManager.OnMakeChildAgent -= OnMakeChild; | ||
197 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | 201 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; |
198 | 202 | ||
199 | lock (m_sceneList) | 203 | lock (m_sceneList) |
@@ -232,16 +236,29 @@ namespace OpenSim.Groups | |||
232 | { | 236 | { |
233 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 237 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
234 | 238 | ||
235 | client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; | ||
236 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; | 239 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; |
237 | client.OnDirFindQuery += OnDirFindQuery; | ||
238 | client.OnRequestAvatarProperties += OnRequestAvatarProperties; | 240 | client.OnRequestAvatarProperties += OnRequestAvatarProperties; |
241 | } | ||
239 | 242 | ||
243 | private void OnMakeRoot(ScenePresence sp) | ||
244 | { | ||
245 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
246 | |||
247 | sp.ControllingClient.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; | ||
240 | // Used for Notices and Group Invites/Accept/Reject | 248 | // Used for Notices and Group Invites/Accept/Reject |
241 | client.OnInstantMessage += OnInstantMessage; | 249 | sp.ControllingClient.OnInstantMessage += OnInstantMessage; |
242 | 250 | ||
243 | // Send client their groups information. | 251 | // Send client their groups information. |
244 | SendAgentGroupDataUpdate(client, client.AgentId); | 252 | SendAgentGroupDataUpdate(sp.ControllingClient, sp.UUID); |
253 | } | ||
254 | |||
255 | private void OnMakeChild(ScenePresence sp) | ||
256 | { | ||
257 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
258 | |||
259 | sp.ControllingClient.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest; | ||
260 | // Used for Notices and Group Invites/Accept/Reject | ||
261 | sp.ControllingClient.OnInstantMessage -= OnInstantMessage; | ||
245 | } | 262 | } |
246 | 263 | ||
247 | private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) | 264 | private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) |
@@ -287,21 +304,6 @@ namespace OpenSim.Groups | |||
287 | } | 304 | } |
288 | */ | 305 | */ |
289 | 306 | ||
290 | void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) | ||
291 | { | ||
292 | if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) | ||
293 | { | ||
294 | if (m_debugEnabled) | ||
295 | m_log.DebugFormat( | ||
296 | "[Groups]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", | ||
297 | System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); | ||
298 | |||
299 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order | ||
300 | remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentIDStr(remoteClient), queryText).ToArray()); | ||
301 | } | ||
302 | |||
303 | } | ||
304 | |||
305 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) | 307 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) |
306 | { | 308 | { |
307 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 309 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
@@ -347,7 +349,7 @@ namespace OpenSim.Groups | |||
347 | { | 349 | { |
348 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 350 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
349 | 351 | ||
350 | m_log.DebugFormat("[Groups]: IM From {0} to {1} msg {2} type {3}", im.fromAgentID, im.toAgentID, im.message, (InstantMessageDialog)im.dialog); | 352 | //m_log.DebugFormat("[Groups]: IM From {0} to {1} msg {2} type {3}", im.fromAgentID, im.toAgentID, im.message, (InstantMessageDialog)im.dialog); |
351 | // Group invitations | 353 | // Group invitations |
352 | if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) | 354 | if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) |
353 | { | 355 | { |
@@ -465,12 +467,12 @@ namespace OpenSim.Groups | |||
465 | } | 467 | } |
466 | 468 | ||
467 | // Send notice out to everyone that wants notices | 469 | // Send notice out to everyone that wants notices |
468 | // Build notice IIM | ||
469 | GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice); | ||
470 | foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), GroupID)) | 470 | foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), GroupID)) |
471 | { | 471 | { |
472 | if (member.AcceptNotices) | 472 | if (member.AcceptNotices) |
473 | { | 473 | { |
474 | // Build notice IIM, one of reach, because the sending may be async | ||
475 | GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice); | ||
474 | msg.toAgentID = member.AgentID.Guid; | 476 | msg.toAgentID = member.AgentID.Guid; |
475 | OutgoingInstantMessage(msg, member.AgentID); | 477 | OutgoingInstantMessage(msg, member.AgentID); |
476 | } | 478 | } |
@@ -485,7 +487,7 @@ namespace OpenSim.Groups | |||
485 | return; | 487 | return; |
486 | 488 | ||
487 | //// 16 bytes are the UUID. Maybe. | 489 | //// 16 bytes are the UUID. Maybe. |
488 | UUID folderID = new UUID(im.binaryBucket, 0); | 490 | // UUID folderID = new UUID(im.binaryBucket, 0); |
489 | UUID noticeID = new UUID(im.imSessionID); | 491 | UUID noticeID = new UUID(im.imSessionID); |
490 | 492 | ||
491 | GroupNoticeInfo notice = m_groupData.GetGroupNotice(remoteClient.AgentId.ToString(), noticeID); | 493 | GroupNoticeInfo notice = m_groupData.GetGroupNotice(remoteClient.AgentId.ToString(), noticeID); |
@@ -766,14 +768,17 @@ namespace OpenSim.Groups | |||
766 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "Insufficient funds to create a group."); | 768 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "Insufficient funds to create a group."); |
767 | return UUID.Zero; | 769 | return UUID.Zero; |
768 | } | 770 | } |
769 | money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate); | ||
770 | } | 771 | } |
772 | |||
771 | string reason = string.Empty; | 773 | string reason = string.Empty; |
772 | UUID groupID = m_groupData.CreateGroup(remoteClient.AgentId, name, charter, showInList, insigniaID, membershipFee, openEnrollment, | 774 | UUID groupID = m_groupData.CreateGroup(remoteClient.AgentId, name, charter, showInList, insigniaID, membershipFee, openEnrollment, |
773 | allowPublish, maturePublish, remoteClient.AgentId, out reason); | 775 | allowPublish, maturePublish, remoteClient.AgentId, out reason); |
774 | 776 | ||
775 | if (groupID != UUID.Zero) | 777 | if (groupID != UUID.Zero) |
776 | { | 778 | { |
779 | if (money != null) | ||
780 | money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate); | ||
781 | |||
777 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); | 782 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); |
778 | 783 | ||
779 | // Update the founder with new group information. | 784 | // Update the founder with new group information. |
@@ -904,23 +909,7 @@ namespace OpenSim.Groups | |||
904 | { | 909 | { |
905 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called for notice {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, groupNoticeID); | 910 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called for notice {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, groupNoticeID); |
906 | 911 | ||
907 | //GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null); | ||
908 | |||
909 | GridInstantMessage msg = CreateGroupNoticeIM(remoteClient.AgentId, groupNoticeID, (byte)InstantMessageDialog.GroupNoticeRequested); | 912 | GridInstantMessage msg = CreateGroupNoticeIM(remoteClient.AgentId, groupNoticeID, (byte)InstantMessageDialog.GroupNoticeRequested); |
910 | //GridInstantMessage msg = new GridInstantMessage(); | ||
911 | //msg.imSessionID = UUID.Zero.Guid; | ||
912 | //msg.fromAgentID = data.GroupID.Guid; | ||
913 | //msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; | ||
914 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
915 | //msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; | ||
916 | //msg.message = data.noticeData.Subject + "|" + data.Message; | ||
917 | //msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNoticeRequested; | ||
918 | //msg.fromGroup = true; | ||
919 | //msg.offline = (byte)0; | ||
920 | //msg.ParentEstateID = 0; | ||
921 | //msg.Position = Vector3.Zero; | ||
922 | //msg.RegionID = UUID.Zero.Guid; | ||
923 | //msg.binaryBucket = data.BinaryBucket; | ||
924 | 913 | ||
925 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); | 914 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); |
926 | } | 915 | } |
@@ -1002,6 +991,10 @@ namespace OpenSim.Groups | |||
1002 | 991 | ||
1003 | // Should this send updates to everyone in the group? | 992 | // Should this send updates to everyone in the group? |
1004 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); | 993 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
994 | |||
995 | if (reason != string.Empty) | ||
996 | // A warning | ||
997 | remoteClient.SendAlertMessage("Warning: " + reason); | ||
1005 | } | 998 | } |
1006 | else | 999 | else |
1007 | remoteClient.SendJoinGroupReply(groupID, false); | 1000 | remoteClient.SendJoinGroupReply(groupID, false); |
@@ -1186,6 +1179,11 @@ namespace OpenSim.Groups | |||
1186 | } | 1179 | } |
1187 | } | 1180 | } |
1188 | 1181 | ||
1182 | public List<DirGroupsReplyData> FindGroups(IClientAPI remoteClient, string query) | ||
1183 | { | ||
1184 | return m_groupData.FindGroups(GetRequestingAgentIDStr(remoteClient), query); | ||
1185 | } | ||
1186 | |||
1189 | #endregion | 1187 | #endregion |
1190 | 1188 | ||
1191 | #region Client/Update Tools | 1189 | #region Client/Update Tools |
@@ -1225,12 +1223,16 @@ namespace OpenSim.Groups | |||
1225 | { | 1223 | { |
1226 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 1224 | if (m_debugEnabled) m_log.InfoFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
1227 | 1225 | ||
1226 | // NPCs currently don't have a CAPs structure or event queues. There is a strong argument for conveying this information | ||
1227 | // to them anyway since it makes writing server-side bots a lot easier, but for now we don't do anything. | ||
1228 | if (remoteClient.SceneAgent.PresenceType == PresenceType.Npc) | ||
1229 | return; | ||
1230 | |||
1228 | OSDArray AgentData = new OSDArray(1); | 1231 | OSDArray AgentData = new OSDArray(1); |
1229 | OSDMap AgentDataMap = new OSDMap(1); | 1232 | OSDMap AgentDataMap = new OSDMap(1); |
1230 | AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID)); | 1233 | AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID)); |
1231 | AgentData.Add(AgentDataMap); | 1234 | AgentData.Add(AgentDataMap); |
1232 | 1235 | ||
1233 | |||
1234 | OSDArray GroupData = new OSDArray(data.Length); | 1236 | OSDArray GroupData = new OSDArray(data.Length); |
1235 | OSDArray NewGroupData = new OSDArray(data.Length); | 1237 | OSDArray NewGroupData = new OSDArray(data.Length); |
1236 | 1238 | ||
@@ -1276,8 +1278,7 @@ namespace OpenSim.Groups | |||
1276 | if (queue != null) | 1278 | if (queue != null) |
1277 | { | 1279 | { |
1278 | queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); | 1280 | queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); |
1279 | } | 1281 | } |
1280 | |||
1281 | } | 1282 | } |
1282 | 1283 | ||
1283 | private void SendScenePresenceUpdate(UUID AgentID, string Title) | 1284 | private void SendScenePresenceUpdate(UUID AgentID, string Title) |
@@ -1339,6 +1340,7 @@ namespace OpenSim.Groups | |||
1339 | 1340 | ||
1340 | GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, dataForAgentID); | 1341 | GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, dataForAgentID); |
1341 | SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray); | 1342 | SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray); |
1343 | |||
1342 | //remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray); | 1344 | //remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray); |
1343 | if (remoteClient.AgentId == dataForAgentID) | 1345 | if (remoteClient.AgentId == dataForAgentID) |
1344 | remoteClient.RefreshGroupMembership(); | 1346 | remoteClient.RefreshGroupMembership(); |
@@ -1399,19 +1401,18 @@ namespace OpenSim.Groups | |||
1399 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 1401 | if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
1400 | 1402 | ||
1401 | // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff | 1403 | // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff |
1402 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID); | 1404 | string firstname = "Unknown", lastname = "Unknown"; |
1403 | string firstname, lastname; | 1405 | string name = m_UserManagement.GetUserName(dataForAgentID); |
1404 | if (account != null) | 1406 | if (!string.IsNullOrEmpty(name)) |
1405 | { | ||
1406 | firstname = account.FirstName; | ||
1407 | lastname = account.LastName; | ||
1408 | } | ||
1409 | else | ||
1410 | { | 1407 | { |
1411 | firstname = "Unknown"; | 1408 | string[] parts = name.Split(new char[] { ' ' }); |
1412 | lastname = "Unknown"; | 1409 | if (parts.Length >= 2) |
1410 | { | ||
1411 | firstname = parts[0]; | ||
1412 | lastname = parts[1]; | ||
1413 | } | ||
1413 | } | 1414 | } |
1414 | 1415 | ||
1415 | remoteClient.SendAgentDataUpdate(dataForAgentID, activeGroupID, firstname, | 1416 | remoteClient.SendAgentDataUpdate(dataForAgentID, activeGroupID, firstname, |
1416 | lastname, activeGroupPowers, activeGroupName, | 1417 | lastname, activeGroupPowers, activeGroupName, |
1417 | activeGroupTitle); | 1418 | activeGroupTitle); |