diff options
author | Snoopy Pfeffer | 2012-03-27 22:30:02 +0200 |
---|---|---|
committer | Snoopy Pfeffer | 2012-03-27 22:30:02 +0200 |
commit | 19837ff4dd8b01cf1f0a458cafc02c56be48bf66 (patch) | |
tree | d9e8bf835e92442c0020a653a4a4e6c2ba325c76 /OpenSim/Region/OptionalModules/Avatar | |
parent | Merge branch 'master' of ssh://snoopy@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-19837ff4dd8b01cf1f0a458cafc02c56be48bf66.zip opensim-SC_OLD-19837ff4dd8b01cf1f0a458cafc02c56be48bf66.tar.gz opensim-SC_OLD-19837ff4dd8b01cf1f0a458cafc02c56be48bf66.tar.bz2 opensim-SC_OLD-19837ff4dd8b01cf1f0a458cafc02c56be48bf66.tar.xz |
Two new scripting functions osInviteToGroup(userID) and osEjectFromGroup(userID) that invite/eject users to/from groups the object containing the script is set to. These functions also work for closed groups.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | 122 |
1 files changed, 99 insertions, 23 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index ea5d805..2a15e5d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -957,17 +957,55 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
957 | 957 | ||
958 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) | 958 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) |
959 | { | 959 | { |
960 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 960 | EjectGroupMember(remoteClient, GetRequestingAgentID(remoteClient), groupID, ejecteeID); |
961 | } | ||
961 | 962 | ||
963 | public void EjectGroupMember(IClientAPI remoteClient, UUID agentID, UUID groupID, UUID ejecteeID) | ||
964 | { | ||
965 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
962 | 966 | ||
963 | // Todo: Security check? | 967 | // Todo: Security check? |
964 | m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID); | 968 | m_groupData.RemoveAgentFromGroup(agentID, ejecteeID, groupID); |
965 | 969 | ||
966 | remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true); | 970 | string agentName; |
971 | RegionInfo regionInfo; | ||
967 | 972 | ||
968 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); | 973 | // remoteClient provided or just agentID? |
974 | if (remoteClient != null) | ||
975 | { | ||
976 | agentName = remoteClient.Name; | ||
977 | regionInfo = remoteClient.Scene.RegionInfo; | ||
978 | remoteClient.SendEjectGroupMemberReply(agentID, groupID, true); | ||
979 | } | ||
980 | else | ||
981 | { | ||
982 | IClientAPI client = GetActiveClient(agentID); | ||
983 | |||
984 | if (client != null) | ||
985 | { | ||
986 | agentName = client.Name; | ||
987 | regionInfo = client.Scene.RegionInfo; | ||
988 | client.SendEjectGroupMemberReply(agentID, groupID, true); | ||
989 | } | ||
990 | else | ||
991 | { | ||
992 | regionInfo = m_sceneList[0].RegionInfo; | ||
993 | UserAccount acc = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, agentID); | ||
994 | |||
995 | if (acc != null) | ||
996 | { | ||
997 | agentName = acc.FirstName + " " + acc.LastName; | ||
998 | } | ||
999 | else | ||
1000 | { | ||
1001 | agentName = "Unknown member"; | ||
1002 | } | ||
1003 | } | ||
1004 | } | ||
1005 | |||
1006 | GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null); | ||
969 | 1007 | ||
970 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); | 1008 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, ejecteeID); |
971 | if ((groupInfo == null) || (account == null)) | 1009 | if ((groupInfo == null) || (account == null)) |
972 | { | 1010 | { |
973 | return; | 1011 | return; |
@@ -977,23 +1015,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
977 | GridInstantMessage msg = new GridInstantMessage(); | 1015 | GridInstantMessage msg = new GridInstantMessage(); |
978 | 1016 | ||
979 | msg.imSessionID = UUID.Zero.Guid; | 1017 | msg.imSessionID = UUID.Zero.Guid; |
980 | msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; | 1018 | msg.fromAgentID = agentID.Guid; |
981 | // msg.fromAgentID = info.GroupID; | 1019 | // msg.fromAgentID = info.GroupID; |
982 | msg.toAgentID = ejecteeID.Guid; | 1020 | msg.toAgentID = ejecteeID.Guid; |
983 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 1021 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
984 | msg.timestamp = 0; | 1022 | msg.timestamp = 0; |
985 | msg.fromAgentName = remoteClient.Name; | 1023 | msg.fromAgentName = agentName; |
986 | msg.message = string.Format("You have been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName); | 1024 | msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName); |
987 | msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; | 1025 | msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; |
988 | msg.fromGroup = false; | 1026 | msg.fromGroup = false; |
989 | msg.offline = (byte)0; | 1027 | msg.offline = (byte)0; |
990 | msg.ParentEstateID = 0; | 1028 | msg.ParentEstateID = 0; |
991 | msg.Position = Vector3.Zero; | 1029 | msg.Position = Vector3.Zero; |
992 | msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; | 1030 | msg.RegionID = regionInfo.RegionID.Guid; |
993 | msg.binaryBucket = new byte[0]; | 1031 | msg.binaryBucket = new byte[0]; |
994 | OutgoingInstantMessage(msg, ejecteeID); | 1032 | OutgoingInstantMessage(msg, ejecteeID); |
995 | 1033 | ||
996 | |||
997 | // Message to ejector | 1034 | // Message to ejector |
998 | // Interop, received special 210 code for ejecting a group member | 1035 | // Interop, received special 210 code for ejecting a group member |
999 | // this only works within the comms servers domain, and won't work hypergrid | 1036 | // this only works within the comms servers domain, and won't work hypergrid |
@@ -1003,26 +1040,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1003 | 1040 | ||
1004 | msg = new GridInstantMessage(); | 1041 | msg = new GridInstantMessage(); |
1005 | msg.imSessionID = UUID.Zero.Guid; | 1042 | msg.imSessionID = UUID.Zero.Guid; |
1006 | msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; | 1043 | msg.fromAgentID = agentID.Guid; |
1007 | msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; | 1044 | msg.toAgentID = agentID.Guid; |
1008 | msg.timestamp = 0; | 1045 | msg.timestamp = 0; |
1009 | msg.fromAgentName = remoteClient.Name; | 1046 | msg.fromAgentName = agentName; |
1010 | if (account != null) | 1047 | if (account != null) |
1011 | { | 1048 | { |
1012 | msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, account.FirstName + " " + account.LastName); | 1049 | msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, account.FirstName + " " + account.LastName); |
1013 | } | 1050 | } |
1014 | else | 1051 | else |
1015 | { | 1052 | { |
1016 | msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, "Unknown member"); | 1053 | msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, "Unknown member"); |
1017 | } | 1054 | } |
1018 | msg.dialog = (byte)210; //interop | 1055 | msg.dialog = (byte)210; //interop |
1019 | msg.fromGroup = false; | 1056 | msg.fromGroup = false; |
1020 | msg.offline = (byte)0; | 1057 | msg.offline = (byte)0; |
1021 | msg.ParentEstateID = 0; | 1058 | msg.ParentEstateID = 0; |
1022 | msg.Position = Vector3.Zero; | 1059 | msg.Position = Vector3.Zero; |
1023 | msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; | 1060 | msg.RegionID = regionInfo.RegionID.Guid; |
1024 | msg.binaryBucket = new byte[0]; | 1061 | msg.binaryBucket = new byte[0]; |
1025 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); | 1062 | OutgoingInstantMessage(msg, agentID); |
1026 | 1063 | ||
1027 | 1064 | ||
1028 | // SL sends out messages to everyone in the group | 1065 | // SL sends out messages to everyone in the group |
@@ -1032,16 +1069,55 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1032 | 1069 | ||
1033 | public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) | 1070 | public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) |
1034 | { | 1071 | { |
1072 | InviteGroup(remoteClient, GetRequestingAgentID(remoteClient), groupID, invitedAgentID, roleID); | ||
1073 | } | ||
1074 | |||
1075 | public void InviteGroup(IClientAPI remoteClient, UUID agentID, UUID groupID, UUID invitedAgentID, UUID roleID) | ||
1076 | { | ||
1035 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 1077 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
1036 | 1078 | ||
1079 | string agentName; | ||
1080 | RegionInfo regionInfo; | ||
1081 | |||
1082 | // remoteClient provided or just agentID? | ||
1083 | if (remoteClient != null) | ||
1084 | { | ||
1085 | agentName = remoteClient.Name; | ||
1086 | regionInfo = remoteClient.Scene.RegionInfo; | ||
1087 | } | ||
1088 | else | ||
1089 | { | ||
1090 | IClientAPI client = GetActiveClient(agentID); | ||
1091 | |||
1092 | if (client != null) | ||
1093 | { | ||
1094 | agentName = client.Name; | ||
1095 | regionInfo = client.Scene.RegionInfo; | ||
1096 | } | ||
1097 | else | ||
1098 | { | ||
1099 | regionInfo = m_sceneList[0].RegionInfo; | ||
1100 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, agentID); | ||
1101 | |||
1102 | if (account != null) | ||
1103 | { | ||
1104 | agentName = account.FirstName + " " + account.LastName; | ||
1105 | } | ||
1106 | else | ||
1107 | { | ||
1108 | agentName = "Unknown member"; | ||
1109 | } | ||
1110 | } | ||
1111 | } | ||
1112 | |||
1037 | // Todo: Security check, probably also want to send some kind of notification | 1113 | // Todo: Security check, probably also want to send some kind of notification |
1038 | UUID InviteID = UUID.Random(); | 1114 | UUID InviteID = UUID.Random(); |
1039 | 1115 | ||
1040 | m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID); | 1116 | m_groupData.AddAgentToGroupInvite(agentID, InviteID, groupID, roleID, invitedAgentID); |
1041 | 1117 | ||
1042 | // Check to see if the invite went through, if it did not then it's possible | 1118 | // Check to see if the invite went through, if it did not then it's possible |
1043 | // the remoteClient did not validate or did not have permission to invite. | 1119 | // the remoteClient did not validate or did not have permission to invite. |
1044 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID); | 1120 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(agentID, InviteID); |
1045 | 1121 | ||
1046 | if (inviteInfo != null) | 1122 | if (inviteInfo != null) |
1047 | { | 1123 | { |
@@ -1053,19 +1129,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1053 | 1129 | ||
1054 | msg.imSessionID = inviteUUID; | 1130 | msg.imSessionID = inviteUUID; |
1055 | 1131 | ||
1056 | // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; | 1132 | // msg.fromAgentID = agentID.Guid; |
1057 | msg.fromAgentID = groupID.Guid; | 1133 | msg.fromAgentID = groupID.Guid; |
1058 | msg.toAgentID = invitedAgentID.Guid; | 1134 | msg.toAgentID = invitedAgentID.Guid; |
1059 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 1135 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
1060 | msg.timestamp = 0; | 1136 | msg.timestamp = 0; |
1061 | msg.fromAgentName = remoteClient.Name; | 1137 | msg.fromAgentName = agentName; |
1062 | msg.message = string.Format("{0} has invited you to join a group. There is no cost to join this group.", remoteClient.Name); | 1138 | msg.message = string.Format("{0} has invited you to join a group. There is no cost to join this group.", agentName); |
1063 | msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupInvitation; | 1139 | msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupInvitation; |
1064 | msg.fromGroup = true; | 1140 | msg.fromGroup = true; |
1065 | msg.offline = (byte)0; | 1141 | msg.offline = (byte)0; |
1066 | msg.ParentEstateID = 0; | 1142 | msg.ParentEstateID = 0; |
1067 | msg.Position = Vector3.Zero; | 1143 | msg.Position = Vector3.Zero; |
1068 | msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; | 1144 | msg.RegionID = regionInfo.RegionID.Guid; |
1069 | msg.binaryBucket = new byte[20]; | 1145 | msg.binaryBucket = new byte[20]; |
1070 | 1146 | ||
1071 | OutgoingInstantMessage(msg, invitedAgentID); | 1147 | OutgoingInstantMessage(msg, invitedAgentID); |