29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Collections.Specialized;
32 using System.Reflection;
33 using System.Threading;
42 using OpenMetaverse.StructuredData;
44 using OpenSim.Framework;
45 using OpenSim.Region.Framework.Interfaces;
46 using OpenSim.Services.Interfaces;
102 namespace OpenSim.
Region.OptionalModules.
Avatar.XmlRpcGroups
104 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"SimianGroupsServicesConnectorModule")]
107 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
109 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
110 GroupPowers.Accountable |
111 GroupPowers.JoinChat |
112 GroupPowers.AllowVoiceChat |
113 GroupPowers.ReceiveNotices |
114 GroupPowers.StartProposal |
115 GroupPowers.VoteOnProposal;
118 public const GroupPowers m_DefaultOwnerPowers = GroupPowers.Accountable
119 | GroupPowers.AllowEditLand
120 | GroupPowers.AllowFly
121 | GroupPowers.AllowLandmark
122 | GroupPowers.AllowRez
123 | GroupPowers.AllowSetHome
124 | GroupPowers.AllowVoiceChat
125 | GroupPowers.AssignMember
126 | GroupPowers.AssignMemberLimited
127 | GroupPowers.ChangeActions
128 | GroupPowers.ChangeIdentity
129 | GroupPowers.ChangeMedia
130 | GroupPowers.ChangeOptions
131 | GroupPowers.CreateRole
132 | GroupPowers.DeedObject
133 | GroupPowers.DeleteRole
135 | GroupPowers.FindPlaces
137 | GroupPowers.JoinChat
138 | GroupPowers.LandChangeIdentity
139 | GroupPowers.LandDeed
140 | GroupPowers.LandDivideJoin
141 | GroupPowers.LandEdit
142 | GroupPowers.LandEjectAndFreeze
143 | GroupPowers.LandGardening
144 | GroupPowers.LandManageAllowed
145 | GroupPowers.LandManageBanned
146 | GroupPowers.LandManagePasses
147 | GroupPowers.LandOptions
148 | GroupPowers.LandRelease
149 | GroupPowers.LandSetSale
150 | GroupPowers.ModerateChat
151 | GroupPowers.ObjectManipulate
152 | GroupPowers.ObjectSetForSale
153 | GroupPowers.ReceiveNotices
154 | GroupPowers.RemoveMember
155 | GroupPowers.ReturnGroupOwned
156 | GroupPowers.ReturnGroupSet
157 | GroupPowers.ReturnNonGroup
158 | GroupPowers.RoleProperties
159 | GroupPowers.SendNotices
160 | GroupPowers.SetLandingPoint
161 | GroupPowers.StartProposal
162 | GroupPowers.VoteOnProposal;
164 private bool m_connectorEnabled =
false;
166 private string m_groupsServerURI = string.Empty;
168 private bool m_debugEnabled =
false;
170 private Dictionary<string, bool> m_pendingRequests =
new Dictionary<string,bool>();
172 private ExpiringCache<string, OSDMap> m_memoryCache;
173 private int m_cacheTimeout = 30;
178 #region Region Module interfaceBase Members
182 get {
return "SimianGroupsServicesConnector"; }
186 public Type ReplaceableInterface
193 IConfig groupsConfig = config.Configs[
"Groups"];
195 if (groupsConfig == null)
204 if ((groupsConfig.GetBoolean(
"Enabled",
false) ==
false)
205 || (groupsConfig.GetString(
"ServicesConnectorModule",
"XmlRpcGroupsServicesConnector") != Name))
207 m_connectorEnabled =
false;
211 m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
213 m_groupsServerURI = groupsConfig.GetString(
"GroupsServerURI", string.Empty);
214 if (
string.IsNullOrEmpty(m_groupsServerURI))
216 m_log.ErrorFormat(
"Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]");
217 m_connectorEnabled =
false;
222 m_cacheTimeout = groupsConfig.GetInt(
"GroupsCacheTimeout", 30);
223 if (m_cacheTimeout == 0)
225 m_log.WarnFormat(
"[SIMIAN-GROUPS-CONNECTOR] Groups Cache Disabled.");
229 m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout);
234 m_memoryCache =
new ExpiringCache<string,OSDMap>();
238 m_connectorEnabled =
true;
240 m_debugEnabled = groupsConfig.GetBoolean(
"DebugEnabled",
true);
247 m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR]: Closing {0}", this.Name);
252 if (m_connectorEnabled)
274 #region ISharedRegionModule Members
286 #region IGroupsServicesConnector Members
291 public UUID CreateGroup(UUID requestingAgentID,
string name,
string charter,
bool showInList, UUID insigniaID,
292 int membershipFee,
bool openEnrollment,
bool allowPublish,
293 bool maturePublish, UUID founderID)
295 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
297 UUID GroupID = UUID.Random();
298 UUID OwnerRoleID = UUID.Random();
301 GroupInfoMap[
"Charter"] = OSD.FromString(charter);
302 GroupInfoMap[
"ShowInList"] = OSD.FromBoolean(showInList);
303 GroupInfoMap[
"InsigniaID"] = OSD.FromUUID(insigniaID);
304 GroupInfoMap[
"MembershipFee"] = OSD.FromInteger(0);
305 GroupInfoMap[
"OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
306 GroupInfoMap[
"AllowPublish"] = OSD.FromBoolean(allowPublish);
307 GroupInfoMap[
"MaturePublish"] = OSD.FromBoolean(maturePublish);
308 GroupInfoMap[
"FounderID"] = OSD.FromUUID(founderID);
309 GroupInfoMap[
"EveryonePowers"] = OSD.FromULong((ulong)m_DefaultEveryonePowers);
310 GroupInfoMap[
"OwnerRoleID"] = OSD.FromUUID(OwnerRoleID);
311 GroupInfoMap[
"OwnersPowers"] = OSD.FromULong((ulong)m_DefaultOwnerPowers);
313 if (SimianAddGeneric(GroupID,
"Group", name, GroupInfoMap))
315 AddGroupRole(requestingAgentID, GroupID,
UUID.Zero,
"Everyone",
"Members of " + name,
"Member of " + name, (ulong)m_DefaultEveryonePowers);
316 AddGroupRole(requestingAgentID, GroupID, OwnerRoleID,
"Owners",
"Owners of " + name,
"Owner of " + name, (ulong)m_DefaultOwnerPowers);
318 AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID);
329 public void UpdateGroup(UUID requestingAgentID, UUID groupID,
string charter,
bool showInList,
330 UUID insigniaID,
int membershipFee,
bool openEnrollment,
331 bool allowPublish,
bool maturePublish)
333 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
338 if (SimianGetFirstGenericEntry(groupID,
"GroupInfo", out GroupName, out GroupInfoMap))
340 GroupInfoMap[
"Charter"] = OSD.FromString(charter);
341 GroupInfoMap[
"ShowInList"] = OSD.FromBoolean(showInList);
342 GroupInfoMap[
"InsigniaID"] = OSD.FromUUID(insigniaID);
343 GroupInfoMap[
"MembershipFee"] = OSD.FromInteger(0);
344 GroupInfoMap[
"OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
345 GroupInfoMap[
"AllowPublish"] = OSD.FromBoolean(allowPublish);
346 GroupInfoMap[
"MaturePublish"] = OSD.FromBoolean(maturePublish);
348 SimianAddGeneric(groupID,
"Group", GroupName, GroupInfoMap);
354 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID,
string name,
string description,
355 string title, ulong powers)
357 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
360 GroupRoleInfo[
"Name"] = OSD.FromString(name);
361 GroupRoleInfo[
"Description"] = OSD.FromString(description);
362 GroupRoleInfo[
"Title"] = OSD.FromString(title);
363 GroupRoleInfo[
"Powers"] = OSD.FromULong((ulong)powers);
366 SimianAddGeneric(groupID,
"GroupRole", roleID.ToString(), GroupRoleInfo);
371 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
376 if (roleID !=
UUID.Zero)
379 Dictionary<UUID, OSDMap> GroupRoleMembers;
380 string GroupRoleMemberType =
"GroupRole" + groupID.ToString();
381 if (SimianGetGenericEntries(GroupRoleMemberType, roleID.ToString(), out GroupRoleMembers))
383 foreach (
UUID UserID
in GroupRoleMembers.Keys)
385 EnsureRoleNotSelectedByMember(groupID, roleID, UserID);
387 SimianRemoveGenericEntry(UserID, GroupRoleMemberType, roleID.ToString());
392 SimianRemoveGenericEntry(groupID,
"GroupRole", roleID.ToString());
397 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID,
string name,
string description,
398 string title, ulong powers)
400 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
405 if (SimianGetGenericEntry(groupID,
"GroupRole", roleID.ToString(), out GroupRoleInfo))
409 GroupRoleInfo[
"Name"] = OSD.FromString(name);
411 if (description != null)
413 GroupRoleInfo[
"Description"] = OSD.FromString(description);
417 GroupRoleInfo[
"Title"] = OSD.FromString(title);
419 GroupRoleInfo[
"Powers"] = OSD.FromULong((ulong)powers);
424 SimianAddGeneric(groupID,
"GroupRole", roleID.ToString(), GroupRoleInfo);
429 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
431 OSDMap GroupInfoMap = null;
432 if (groupID !=
UUID.Zero)
434 if (!SimianGetFirstGenericEntry(groupID,
"Group", out groupName, out GroupInfoMap))
439 else if (!
string.IsNullOrEmpty(groupName))
441 if (!SimianGetFirstGenericEntry(
"Group", groupName, out groupID, out GroupInfoMap))
449 GroupInfo.GroupID = groupID;
450 GroupInfo.GroupName = groupName;
451 GroupInfo.Charter = GroupInfoMap[
"Charter"].AsString();
452 GroupInfo.ShowInList = GroupInfoMap[
"ShowInList"].AsBoolean();
453 GroupInfo.GroupPicture = GroupInfoMap[
"InsigniaID"].AsUUID();
454 GroupInfo.MembershipFee = GroupInfoMap[
"MembershipFee"].AsInteger();
455 GroupInfo.OpenEnrollment = GroupInfoMap[
"OpenEnrollment"].AsBoolean();
456 GroupInfo.AllowPublish = GroupInfoMap[
"AllowPublish"].AsBoolean();
457 GroupInfo.MaturePublish = GroupInfoMap[
"MaturePublish"].AsBoolean();
458 GroupInfo.FounderID = GroupInfoMap[
"FounderID"].AsUUID();
459 GroupInfo.OwnerRoleID = GroupInfoMap[
"OwnerRoleID"].AsUUID();
467 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
471 if (!SimianGetFirstGenericEntry(groupID,
"Group", out groupName, out groupProfile))
478 MemberGroupProfile.GroupID = groupID;
479 MemberGroupProfile.Name = groupName;
481 if (groupProfile[
"Charter"] != null)
483 MemberGroupProfile.Charter = groupProfile[
"Charter"].AsString();
486 MemberGroupProfile.ShowInList = groupProfile[
"ShowInList"].AsString() ==
"1";
487 MemberGroupProfile.InsigniaID = groupProfile[
"InsigniaID"].AsUUID();
488 MemberGroupProfile.MembershipFee = groupProfile[
"MembershipFee"].AsInteger();
489 MemberGroupProfile.OpenEnrollment = groupProfile[
"OpenEnrollment"].AsBoolean();
490 MemberGroupProfile.AllowPublish = groupProfile[
"AllowPublish"].AsBoolean();
491 MemberGroupProfile.MaturePublish = groupProfile[
"MaturePublish"].AsBoolean();
492 MemberGroupProfile.FounderID = groupProfile[
"FounderID"].AsUUID();;
493 MemberGroupProfile.OwnerRole = groupProfile[
"OwnerRoleID"].AsUUID();
495 Dictionary<UUID, OSDMap> Members;
496 if (SimianGetGenericEntries(
"GroupMember",groupID.ToString(), out Members))
498 MemberGroupProfile.GroupMembershipCount = Members.Count;
501 Dictionary<string, OSDMap> Roles;
502 if (SimianGetGenericEntries(groupID,
"GroupRole", out Roles))
504 MemberGroupProfile.GroupRolesCount = Roles.Count;
510 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, memberID, groupID);
512 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
513 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
515 return MemberGroupProfile;
520 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
523 ActiveGroup.Add(
"GroupID", OSD.FromUUID(groupID));
524 SimianAddGeneric(agentID,
"Group",
"ActiveGroup", ActiveGroup);
529 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
532 if (!SimianGetGenericEntry(agentID,
"GroupMember", groupID.ToString(), out GroupMemberInfo))
534 GroupMemberInfo =
new OSDMap();
537 GroupMemberInfo[
"SelectedRoleID"] = OSD.FromUUID(roleID);
538 SimianAddGeneric(agentID,
"GroupMember", groupID.ToString(), GroupMemberInfo);
541 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID,
bool acceptNotices,
bool listInProfile)
543 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
546 if (!SimianGetGenericEntry(agentID,
"GroupMember", groupID.ToString(), out GroupMemberInfo))
548 GroupMemberInfo =
new OSDMap();
551 GroupMemberInfo[
"AcceptNotices"] = OSD.FromBoolean(acceptNotices);
552 GroupMemberInfo[
"ListInProfile"] = OSD.FromBoolean(listInProfile);
553 GroupMemberInfo[
"Contribution"] = OSD.FromInteger(0);
554 GroupMemberInfo[
"SelectedRole"] = OSD.FromUUID(UUID.Zero);
555 SimianAddGeneric(agentID,
"GroupMember", groupID.ToString(), GroupMemberInfo);
560 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
563 Invite[
"AgentID"] = OSD.FromUUID(agentID);
564 Invite[
"RoleID"] = OSD.FromUUID(roleID);
566 SimianAddGeneric(groupID,
"GroupMemberInvite", inviteID.ToString(), Invite);
571 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
575 if (!SimianGetFirstGenericEntry(
"GroupMemberInvite", inviteID.ToString(), out GroupID, out GroupMemberInvite))
581 inviteInfo.InviteID = inviteID;
582 inviteInfo.GroupID = GroupID;
583 inviteInfo.AgentID = GroupMemberInvite[
"AgentID"].AsUUID();
584 inviteInfo.RoleID = GroupMemberInvite[
"RoleID"].AsUUID();
591 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
593 GroupInviteInfo invite = GetAgentToGroupInvite(requestingAgentID, inviteID);
594 SimianRemoveGenericEntry(invite.
GroupID,
"GroupMemberInvite", inviteID.ToString());
597 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
599 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
602 SetAgentGroupInfo(requestingAgentID, AgentID, GroupID,
true,
true);
605 AddAgentToGroupRole(requestingAgentID, AgentID, GroupID,
UUID.Zero);
608 AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
611 SetAgentActiveGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
616 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
619 GroupMembershipData memberActiveMembership = GetAgentActiveMembership(requestingAgentID, agentID);
620 if (memberActiveMembership.
GroupID == groupID)
622 SetAgentActiveGroup(agentID, agentID,
UUID.Zero);
626 SimianRemoveGenericEntry(agentID,
"GroupMember", groupID.ToString());
631 string GroupRoleMemberType =
"GroupRole" + groupID.ToString();
634 Dictionary<string, OSDMap> GroupRoles;
635 if (SimianGetGenericEntries(agentID, GroupRoleMemberType, out GroupRoles))
637 foreach (
string roleID
in GroupRoles.Keys)
639 SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID);
646 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
648 SimianAddGeneric(agentID,
"GroupRole" + groupID.ToString(), roleID.ToString(),
new OSDMap());
653 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
656 if (roleID !=
UUID.Zero)
658 EnsureRoleNotSelectedByMember(groupID, roleID, agentID);
660 string GroupRoleMemberType =
"GroupRole" + groupID.ToString();
661 SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID.ToString());
665 public List<DirGroupsReplyData>
FindGroups(UUID requestingAgentID,
string search)
667 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
669 List<DirGroupsReplyData> findings =
new List<DirGroupsReplyData>();
671 NameValueCollection requestArgs =
new NameValueCollection
673 {
"RequestMethod",
"GetGenerics" },
680 OSDMap response = CachedPostRequest(requestArgs);
681 if (response[
"Success"].AsBoolean() && response[
"Entries"] is
OSDArray)
683 OSDArray entryArray = (
OSDArray)response[
"Entries"];
684 foreach (
OSDMap entryMap
in entryArray)
687 data.groupID = entryMap[
"OwnerID"].AsUUID();
688 data.groupName = entryMap[
"Key"].AsString();
691 Dictionary<UUID, OSDMap> Members;
692 if (SimianGetGenericEntries(
"GroupMember", data.
groupID.ToString(), out Members))
694 data.members = Members.Count;
713 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
718 OSDMap UserGroupMemberInfo;
719 if (SimianGetGenericEntry(agentID,
"GroupMember", groupID.ToString(), out UserGroupMemberInfo))
722 data.AcceptNotices = UserGroupMemberInfo[
"AcceptNotices"].AsBoolean();
723 data.Contribution = UserGroupMemberInfo[
"Contribution"].AsInteger();
724 data.ListInProfile = UserGroupMemberInfo[
"ListInProfile"].AsBoolean();
725 data.ActiveRole = UserGroupMemberInfo[
"SelectedRoleID"].AsUUID();
731 if (SimianGetGenericEntry(agentID,
"Group",
"ActiveGroup", out UserActiveGroup))
733 data.Active = UserActiveGroup[
"GroupID"].AsUUID().Equals(groupID);
740 if (SimianGetGenericEntry(groupID,
"GroupRole", data.
ActiveRole.ToString(), out GroupRoleInfo))
742 data.GroupTitle = GroupRoleInfo[
"Title"].AsString();
743 data.GroupPowers = GroupRoleInfo[
"Powers"].AsULong();
751 if (SimianGetFirstGenericEntry(groupID,
"Group", out GroupName, out GroupInfo))
753 data.GroupID = groupID;
754 data.AllowPublish = GroupInfo[
"AllowPublish"].AsBoolean();
755 data.Charter = GroupInfo[
"Charter"].AsString();
756 data.FounderID = GroupInfo[
"FounderID"].AsUUID();
757 data.GroupName = GroupName;
758 data.GroupPicture = GroupInfo[
"InsigniaID"].AsUUID();
759 data.MaturePublish = GroupInfo[
"MaturePublish"].AsBoolean();
760 data.MembershipFee = GroupInfo[
"MembershipFee"].AsInteger();
761 data.OpenEnrollment = GroupInfo[
"OpenEnrollment"].AsBoolean();
762 data.ShowInList = GroupInfo[
"ShowInList"].AsBoolean();
771 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
773 UUID GroupID = UUID.Zero;
775 if (SimianGetGenericEntry(agentID,
"Group",
"ActiveGroup", out UserActiveGroup))
777 GroupID = UserActiveGroup[
"GroupID"].AsUUID();
780 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString());
781 return GetAgentGroupMembership(requestingAgentID, agentID, GroupID);
786 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
788 List<GroupMembershipData> memberships =
new List<GroupMembershipData>();
790 Dictionary<string,OSDMap> GroupMemberShips;
791 if (SimianGetGenericEntries(agentID,
"GroupMember", out GroupMemberShips))
793 foreach (
string key in GroupMemberShips.Keys)
795 memberships.Add(GetAgentGroupMembership(requestingAgentID, agentID,
UUID.Parse(key)));
804 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
806 List<GroupRolesData> Roles =
new List<GroupRolesData>();
808 Dictionary<string, OSDMap> GroupRoles;
809 if (SimianGetGenericEntries(groupID,
"GroupRole", out GroupRoles))
811 Dictionary<string, OSDMap> MemberRoles;
812 if (SimianGetGenericEntries(agentID,
"GroupRole" + groupID.ToString(), out MemberRoles))
814 foreach (KeyValuePair<string, OSDMap> kvp
in MemberRoles)
817 data.RoleID = UUID.Parse(kvp.Key);
818 data.Name = GroupRoles[kvp.Key][
"Name"].AsString();
819 data.Description = GroupRoles[kvp.Key][
"Description"].AsString();
820 data.Title = GroupRoles[kvp.Key][
"Title"].AsString();
821 data.Powers = GroupRoles[kvp.Key][
"Powers"].AsULong();
830 public List<GroupRolesData>
GetGroupRoles(UUID requestingAgentID, UUID groupID)
832 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
834 List<GroupRolesData> Roles =
new List<GroupRolesData>();
836 Dictionary<string, OSDMap> GroupRoles;
837 if (SimianGetGenericEntries(groupID,
"GroupRole", out GroupRoles))
839 foreach (KeyValuePair<string, OSDMap> role
in GroupRoles)
843 data.RoleID = UUID.Parse(role.Key);
845 data.Name = role.Value[
"Name"].AsString();
846 data.Description = role.Value[
"Description"].AsString();
847 data.Title = role.Value[
"Title"].AsString();
848 data.Powers = role.Value[
"Powers"].AsULong();
850 Dictionary<UUID, OSDMap> GroupRoleMembers;
851 if (SimianGetGenericEntries(
"GroupRole" + groupID.ToString(), role.Key, out GroupRoleMembers))
853 data.Members = GroupRoleMembers.Count;
872 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
874 List<GroupMembersData> members =
new List<GroupMembersData>();
878 UUID GroupOwnerRoleID = UUID.Zero;
879 if (!SimianGetFirstGenericEntry(GroupID,
"Group", out GroupName, out GroupInfo))
883 GroupOwnerRoleID = GroupInfo[
"OwnerRoleID"].AsUUID();
886 Dictionary<string,OSDMap> GroupRoles;
887 SimianGetGenericEntries(GroupID,
"GroupRole", out GroupRoles);
890 Dictionary<UUID, OSDMap> GroupOwners;
891 SimianGetGenericEntries(
"GroupRole" + GroupID.ToString(), GroupOwnerRoleID.ToString(), out GroupOwners);
894 Dictionary<UUID, OSDMap> GroupMembers;
895 if (SimianGetGenericEntries(
"GroupMember", GroupID.ToString(), out GroupMembers))
897 foreach (KeyValuePair<UUID, OSDMap> member
in GroupMembers)
901 data.AgentID = member.Key;
903 UUID SelectedRoleID = member.Value[
"SelectedRoleID"].AsUUID();
905 data.AcceptNotices = member.Value[
"AcceptNotices"].AsBoolean();
906 data.ListInProfile = member.Value[
"ListInProfile"].AsBoolean();
907 data.Contribution = member.Value[
"Contribution"].AsInteger();
909 data.IsOwner = GroupOwners.ContainsKey(member.Key);
911 OSDMap GroupRoleInfo = GroupRoles[SelectedRoleID.ToString()];
912 data.Title = GroupRoleInfo[
"Title"].AsString();
913 data.AgentPowers = GroupRoleInfo[
"Powers"].AsULong();
925 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
927 List<GroupRoleMembersData> members =
new List<GroupRoleMembersData>();
929 Dictionary<string, OSDMap> GroupRoles;
930 if (SimianGetGenericEntries(groupID,
"GroupRole", out GroupRoles))
932 foreach (KeyValuePair<string, OSDMap> Role
in GroupRoles)
934 Dictionary<UUID, OSDMap> GroupRoleMembers;
935 if (SimianGetGenericEntries(
"GroupRole"+groupID.ToString(), Role.Key, out GroupRoleMembers))
937 foreach (KeyValuePair<UUID, OSDMap> GroupRoleMember
in GroupRoleMembers)
941 data.MemberID = GroupRoleMember.Key;
942 data.RoleID = UUID.Parse(Role.Key);
955 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
957 List<GroupNoticeData> values =
new List<GroupNoticeData>();
959 Dictionary<string, OSDMap> Notices;
960 if (SimianGetGenericEntries(GroupID,
"GroupNotice", out Notices))
962 foreach (KeyValuePair<string, OSDMap> Notice
in Notices)
965 data.NoticeID = UUID.Parse(Notice.Key);
966 data.Timestamp = Notice.Value[
"TimeStamp"].AsUInteger();
967 data.FromName = Notice.Value[
"FromName"].AsString();
968 data.Subject = Notice.Value[
"Subject"].AsString();
969 data.HasAttachment = Notice.Value[
"BinaryBucket"].AsBinary().Length > 0;
983 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
987 if (SimianGetFirstGenericEntry(
"GroupNotice", noticeID.ToString(), out GroupID, out GroupNotice))
990 data.GroupID = GroupID;
991 data.Message = GroupNotice[
"Message"].AsString();
992 data.BinaryBucket = GroupNotice[
"BinaryBucket"].AsBinary();
993 data.noticeData.NoticeID = noticeID;
994 data.noticeData.Timestamp = GroupNotice[
"TimeStamp"].AsUInteger();
995 data.noticeData.FromName = GroupNotice[
"FromName"].AsString();
996 data.noticeData.Subject = GroupNotice[
"Subject"].AsString();
997 data.noticeData.HasAttachment = data.BinaryBucket.Length > 0;
998 data.noticeData.AssetType = 0;
1002 data.Message = string.Empty;
1009 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID,
string fromName,
string subject,
string message, byte[] binaryBucket)
1011 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1014 Notice[
"TimeStamp"] = OSD.FromUInteger((uint)Util.UnixTimeSinceEpoch());
1015 Notice[
"FromName"] = OSD.FromString(fromName);
1016 Notice[
"Subject"] = OSD.FromString(subject);
1017 Notice[
"Message"] = OSD.FromString(message);
1018 Notice[
"BinaryBucket"] = OSD.FromBinary(binaryBucket);
1020 SimianAddGeneric(groupID,
"GroupNotice", noticeID.ToString(), Notice);
1025 #region GroupSessionTracking
1029 Dictionary<string, OSDMap> agentSessions;
1031 if (SimianGetGenericEntries(agentID,
"GroupSessionDropped", out agentSessions))
1033 foreach (
string GroupID
in agentSessions.Keys)
1035 SimianRemoveGenericEntry(agentID,
"GroupSessionDropped", GroupID);
1039 if (SimianGetGenericEntries(agentID,
"GroupSessionInvited", out agentSessions))
1041 foreach (
string GroupID
in agentSessions.Keys)
1043 SimianRemoveGenericEntry(agentID,
"GroupSessionInvited", GroupID);
1051 return SimianGetGenericEntry(agentID,
"GroupSessionDropped", groupID.ToString(), out session);
1056 SimianAddGeneric(agentID,
"GroupSessionDropped", groupID.ToString(),
new OSDMap());
1061 SimianAddGeneric(agentID,
"GroupSessionInvited", groupID.ToString(),
new OSDMap());
1067 return SimianGetGenericEntry(agentID,
"GroupSessionDropped", groupID.ToString(), out session);
1072 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID)
1074 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1079 if (SimianGetGenericEntry(userID,
"GroupMember", groupID.ToString(), out UserGroupInfo))
1081 if (UserGroupInfo[
"SelectedRoleID"].AsUUID() == roleID)
1083 UserGroupInfo[
"SelectedRoleID"] = OSD.FromUUID(UUID.Zero);
1085 SimianAddGeneric(userID,
"GroupMember", groupID.ToString(), UserGroupInfo);
1090 #region Simian Util Methods
1091 private bool SimianAddGeneric(UUID ownerID,
string type,
string key,
OSDMap map)
1093 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1095 string value = OSDParser.SerializeJsonString(map);
1097 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] value: {0}", value);
1099 NameValueCollection RequestArgs =
new NameValueCollection
1101 {
"RequestMethod",
"AddGeneric" },
1102 {
"OwnerID", ownerID.ToString() },
1109 OSDMap Response = CachedPostRequest(RequestArgs);
1110 if (Response[
"Success"].AsBoolean())
1116 m_log.WarnFormat(
"[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type,
key, Response[
"Message"]);
1124 private bool SimianGetFirstGenericEntry(UUID ownerID,
string type, out
string key, out
OSDMap map)
1126 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type);
1128 NameValueCollection RequestArgs =
new NameValueCollection
1130 {
"RequestMethod",
"GetGenerics" },
1131 {
"OwnerID", ownerID.ToString() },
1136 OSDMap Response = CachedPostRequest(RequestArgs);
1137 if (Response[
"Success"].AsBoolean() && Response[
"Entries"] is
OSDArray)
1139 OSDArray entryArray = (
OSDArray)Response[
"Entries"];
1140 if (entryArray.Count >= 1)
1143 key = entryMap[
"Key"].AsString();
1144 map = (
OSDMap)OSDParser.DeserializeJson(entryMap[
"Value"].AsString());
1146 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap[
"Value"].AsString());
1152 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1157 m_log.WarnFormat(
"[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response[
"Message"]);
1163 private bool SimianGetFirstGenericEntry(
string type,
string key, out UUID ownerID, out
OSDMap map)
1165 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
1168 NameValueCollection RequestArgs =
new NameValueCollection
1170 {
"RequestMethod",
"GetGenerics" },
1176 OSDMap Response = CachedPostRequest(RequestArgs);
1177 if (Response[
"Success"].AsBoolean() && Response[
"Entries"] is OSDArray)
1179 OSDArray entryArray = (
OSDArray)Response[
"Entries"];
1180 if (entryArray.Count >= 1)
1183 ownerID = entryMap[
"OwnerID"].AsUUID();
1184 map = (
OSDMap)OSDParser.DeserializeJson(entryMap[
"Value"].AsString());
1186 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap[
"Value"].AsString());
1192 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1197 m_log.WarnFormat(
"[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response[
"Message"]);
1199 ownerID = UUID.Zero;
1204 private bool SimianGetGenericEntry(UUID ownerID,
string type,
string key, out
OSDMap map)
1206 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1208 NameValueCollection RequestArgs =
new NameValueCollection
1210 {
"RequestMethod",
"GetGenerics" },
1211 {
"OwnerID", ownerID.ToString() },
1217 OSDMap Response = CachedPostRequest(RequestArgs);
1218 if (Response[
"Success"].AsBoolean() && Response[
"Entries"] is OSDArray)
1220 OSDArray entryArray = (
OSDArray)Response[
"Entries"];
1221 if (entryArray.Count == 1)
1224 key = entryMap[
"Key"].AsString();
1225 map = (
OSDMap)OSDParser.DeserializeJson(entryMap[
"Value"].AsString());
1227 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap[
"Value"].AsString());
1233 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1238 m_log.WarnFormat(
"[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response[
"Message"]);
1244 private bool SimianGetGenericEntries(UUID ownerID,
string type, out Dictionary<string, OSDMap> maps)
1246 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name,ownerID, type);
1248 NameValueCollection requestArgs =
new NameValueCollection
1250 {
"RequestMethod",
"GetGenerics" },
1251 {
"OwnerID", ownerID.ToString() },
1257 OSDMap response = CachedPostRequest(requestArgs);
1258 if (response[
"Success"].AsBoolean() && response[
"Entries"] is OSDArray)
1260 maps =
new Dictionary<string, OSDMap>();
1262 OSDArray entryArray = (
OSDArray)response[
"Entries"];
1263 foreach (
OSDMap entryMap
in entryArray)
1265 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap[
"Value"].AsString());
1266 maps.Add(entryMap[
"Key"].AsString(), (
OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
1268 if (maps.Count == 0)
1270 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1278 m_log.WarnFormat(
"[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", response[
"Message"]);
1282 private bool SimianGetGenericEntries(
string type,
string key, out Dictionary<UUID, OSDMap> maps)
1284 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
1286 NameValueCollection requestArgs =
new NameValueCollection
1288 {
"RequestMethod",
"GetGenerics" },
1295 OSDMap response = CachedPostRequest(requestArgs);
1296 if (response[
"Success"].AsBoolean() && response[
"Entries"] is OSDArray)
1298 maps =
new Dictionary<UUID, OSDMap>();
1300 OSDArray entryArray = (
OSDArray)response[
"Entries"];
1301 foreach (
OSDMap entryMap
in entryArray)
1303 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap[
"Value"].AsString());
1304 maps.Add(entryMap[
"OwnerID"].AsUUID(), (
OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
1306 if (maps.Count == 0)
1308 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1315 m_log.WarnFormat(
"[SIMIAN-GROUPS-CONNECTOR]: Error retrieving group info ({0})", response[
"Message"]);
1320 private bool SimianRemoveGenericEntry(UUID ownerID,
string type,
string key)
1322 if (m_debugEnabled) m_log.InfoFormat(
"[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1324 NameValueCollection requestArgs =
new NameValueCollection
1326 {
"RequestMethod",
"RemoveGeneric" },
1327 {
"OwnerID", ownerID.ToString() },
1333 OSDMap response = CachedPostRequest(requestArgs);
1334 if (response[
"Success"].AsBoolean())
1340 m_log.WarnFormat(
"[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type,
key, response[
"Message"]);
1347 OSDMap CachedPostRequest(NameValueCollection requestArgs)
1350 if (m_cacheTimeout == 0)
1352 m_log.WarnFormat(
"[SIMIAN GROUPS CONNECTOR]: cache is disabled");
1353 return WebUtil.PostToService(m_groupsServerURI, requestArgs);
1357 if (requestArgs[
"RequestMethod"] ==
"RemoveGeneric"
1358 || requestArgs[
"RequestMethod"] ==
"AddGeneric")
1360 m_log.WarnFormat(
"[SIMIAN GROUPS CONNECTOR]: clearing generics cache");
1363 m_memoryCache.Clear();
1366 return WebUtil.PostToService(m_groupsServerURI, requestArgs);
1372 string CacheKey = WebUtil.BuildQueryString(requestArgs);
1381 bool firstRequest =
false;
1383 lock (m_memoryCache)
1385 if (m_memoryCache.TryGetValue(CacheKey, out response))
1388 if (! m_pendingRequests.ContainsKey(CacheKey))
1390 m_pendingRequests.Add(CacheKey,
true);
1391 firstRequest =
true;
1400 response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
1404 m_log.ErrorFormat(
"[SIMIAN GROUPS CONNECTOR]: request failed {0}", CacheKey);
1408 lock (m_memoryCache)
1410 m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout));
1411 m_pendingRequests.Remove(CacheKey);
GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
void Initialise(IConfigSource config)
This is called to initialize the region module. For shared modules, this is called exactly once...
OpenMetaverse.StructuredData.OSDArray OSDArray
void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
void RemoveAgentFromGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
List< GroupRoleMembersData > GetGroupRoleMembers(UUID requestingAgentID, UUID groupID)
OpenMetaverse.StructuredData.OSDMap OSDMap
GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID groupID, UUID memberID)
List< GroupNoticeData > GetGroupNotices(UUID requestingAgentID, UUID GroupID)
GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID agentID)
void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
void SetAgentActiveGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
List< DirGroupsReplyData > FindGroups(UUID requestingAgentID, string search)
GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
Get the group record.
void ResetAgentGroupChatSessions(UUID agentID)
void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
Interactive OpenSim region server
void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
List< GroupRolesData > GetAgentGroupRoles(UUID requestingAgentID, UUID agentID, UUID groupID)
void SetAgentActiveGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
void AddAgentToGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
List< GroupMembersData > GetGroupMembers(UUID requestingAgentID, UUID GroupID)
List< GroupRolesData > GetGroupRoles(UUID requestingAgentID, UUID groupID)
void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID agentID, UUID groupID)
Get information about a specific group to which the user belongs.
UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID)
Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role.
GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
List< GroupMembershipData > GetAgentGroupMemberships(UUID requestingAgentID, UUID agentID)
Get information about the groups to which a user belongs.