29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
41 using OpenMetaverse.StructuredData;
43 using OpenSim.Framework;
44 using OpenSim.Region.Framework.Interfaces;
45 using OpenSim.Services.Interfaces;
47 namespace OpenSim.
Region.OptionalModules.
Avatar.XmlRpcGroups
49 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"XmlRpcGroupsServicesConnectorModule")]
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 private bool m_debugEnabled =
false;
56 public const GroupPowers DefaultEveryonePowers
57 = GroupPowers.AllowSetHome
58 | GroupPowers.Accountable
59 | GroupPowers.JoinChat
60 | GroupPowers.AllowVoiceChat
61 | GroupPowers.ReceiveNotices
62 | GroupPowers.StartProposal
63 | GroupPowers.VoteOnProposal;
66 public const GroupPowers DefaultOwnerPowers
67 = GroupPowers.Accountable
68 | GroupPowers.AllowEditLand
69 | GroupPowers.AllowFly
70 | GroupPowers.AllowLandmark
71 | GroupPowers.AllowRez
72 | GroupPowers.AllowSetHome
73 | GroupPowers.AllowVoiceChat
74 | GroupPowers.AssignMember
75 | GroupPowers.AssignMemberLimited
76 | GroupPowers.ChangeActions
77 | GroupPowers.ChangeIdentity
78 | GroupPowers.ChangeMedia
79 | GroupPowers.ChangeOptions
80 | GroupPowers.CreateRole
81 | GroupPowers.DeedObject
82 | GroupPowers.DeleteRole
84 | GroupPowers.FindPlaces
86 | GroupPowers.JoinChat
87 | GroupPowers.LandChangeIdentity
88 | GroupPowers.LandDeed
89 | GroupPowers.LandDivideJoin
90 | GroupPowers.LandEdit
91 | GroupPowers.LandEjectAndFreeze
92 | GroupPowers.LandGardening
93 | GroupPowers.LandManageAllowed
94 | GroupPowers.LandManageBanned
95 | GroupPowers.LandManagePasses
96 | GroupPowers.LandOptions
97 | GroupPowers.LandRelease
98 | GroupPowers.LandSetSale
99 | GroupPowers.ModerateChat
100 | GroupPowers.ObjectManipulate
101 | GroupPowers.ObjectSetForSale
102 | GroupPowers.ReceiveNotices
103 | GroupPowers.RemoveMember
104 | GroupPowers.ReturnGroupOwned
105 | GroupPowers.ReturnGroupSet
106 | GroupPowers.ReturnNonGroup
107 | GroupPowers.RoleProperties
108 | GroupPowers.SendNotices
109 | GroupPowers.SetLandingPoint
110 | GroupPowers.StartProposal
111 | GroupPowers.VoteOnProposal;
113 private bool m_connectorEnabled =
false;
115 private string m_groupsServerURI = string.Empty;
117 private bool m_disableKeepAlive =
true;
119 private string m_groupReadKey = string.Empty;
120 private string m_groupWriteKey = string.Empty;
124 private ExpiringCache<string, XmlRpcResponse> m_memoryCache;
125 private int m_cacheTimeout = 30;
131 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession =
new Dictionary<UUID, List<UUID>>();
132 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession =
new Dictionary<UUID, List<UUID>>();
134 #region Region Module interfaceBase Members
138 get {
return "XmlRpcGroupsServicesConnector"; }
142 public Type ReplaceableInterface
149 IConfig groupsConfig = config.Configs[
"Groups"];
151 if (groupsConfig == null)
160 if ((groupsConfig.GetBoolean(
"Enabled",
false) ==
false)
161 || (groupsConfig.GetString(
"ServicesConnectorModule",
"XmlRpcGroupsServicesConnector") != Name))
163 m_connectorEnabled =
false;
167 m_log.DebugFormat(
"[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
169 m_groupsServerURI = groupsConfig.GetString(
"GroupsServerURI", string.Empty);
170 if (
string.IsNullOrEmpty(m_groupsServerURI))
172 m_log.ErrorFormat(
"Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
173 m_connectorEnabled =
false;
177 m_disableKeepAlive = groupsConfig.GetBoolean(
"XmlRpcDisableKeepAlive",
true);
179 m_groupReadKey = groupsConfig.GetString(
"XmlRpcServiceReadKey", string.Empty);
180 m_groupWriteKey = groupsConfig.GetString(
"XmlRpcServiceWriteKey", string.Empty);
182 m_cacheTimeout = groupsConfig.GetInt(
"GroupsCacheTimeout", 30);
183 if (m_cacheTimeout == 0)
185 m_log.WarnFormat(
"[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled.");
189 m_log.InfoFormat(
"[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout);
192 m_debugEnabled = groupsConfig.GetBoolean(
"DebugEnabled",
false);
195 m_memoryCache =
new ExpiringCache<string, XmlRpcResponse>();
196 m_connectorEnabled =
true;
202 m_log.DebugFormat(
"[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name);
207 if (m_connectorEnabled)
210 if (m_accountService == null)
212 m_accountService = scene.UserAccountService;
236 #region ISharedRegionModule Members
245 #region IGroupsServicesConnector Members
250 public UUID CreateGroup(UUID requestingAgentID,
string name,
string charter,
bool showInList, UUID insigniaID,
251 int membershipFee,
bool openEnrollment,
bool allowPublish,
252 bool maturePublish, UUID founderID)
254 UUID GroupID = UUID.Random();
255 UUID OwnerRoleID = UUID.Random();
257 Hashtable param =
new Hashtable();
258 param[
"GroupID"] = GroupID.ToString();
259 param[
"Name"] = name;
260 param[
"Charter"] = charter;
261 param[
"ShowInList"] = showInList ==
true ? 1 : 0;
262 param[
"InsigniaID"] = insigniaID.ToString();
263 param[
"MembershipFee"] = membershipFee;
264 param[
"OpenEnrollment"] = openEnrollment ==
true ? 1 : 0;
265 param[
"AllowPublish"] = allowPublish ==
true ? 1 : 0;
266 param[
"MaturePublish"] = maturePublish ==
true ? 1 : 0;
267 param[
"FounderID"] = founderID.ToString();
268 param[
"EveryonePowers"] = ((ulong)DefaultEveryonePowers).ToString();
269 param[
"OwnerRoleID"] = OwnerRoleID.ToString();
270 param[
"OwnersPowers"] = ((ulong)DefaultOwnerPowers).ToString();
272 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.createGroup", param);
274 if (respData.Contains(
"error"))
281 return UUID.Parse((string)respData[
"GroupID"]);
284 public void UpdateGroup(UUID requestingAgentID, UUID groupID,
string charter,
bool showInList,
285 UUID insigniaID,
int membershipFee,
bool openEnrollment,
286 bool allowPublish,
bool maturePublish)
288 Hashtable param =
new Hashtable();
289 param[
"GroupID"] = groupID.ToString();
290 param[
"Charter"] = charter;
291 param[
"ShowInList"] = showInList ==
true ? 1 : 0;
292 param[
"InsigniaID"] = insigniaID.ToString();
293 param[
"MembershipFee"] = membershipFee;
294 param[
"OpenEnrollment"] = openEnrollment ==
true ? 1 : 0;
295 param[
"AllowPublish"] = allowPublish ==
true ? 1 : 0;
296 param[
"MaturePublish"] = maturePublish ==
true ? 1 : 0;
298 XmlRpcCall(requestingAgentID,
"groups.updateGroup", param);
301 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID,
string name,
string description,
302 string title, ulong powers)
304 Hashtable param =
new Hashtable();
305 param[
"GroupID"] = groupID.ToString();
306 param[
"RoleID"] = roleID.ToString();
307 param[
"Name"] = name;
308 param[
"Description"] = description;
309 param[
"Title"] = title;
310 param[
"Powers"] = powers.ToString();
312 XmlRpcCall(requestingAgentID,
"groups.addRoleToGroup", param);
317 Hashtable param =
new Hashtable();
318 param[
"GroupID"] = groupID.ToString();
319 param[
"RoleID"] = roleID.ToString();
321 XmlRpcCall(requestingAgentID,
"groups.removeRoleFromGroup", param);
324 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID,
string name,
string description,
325 string title, ulong powers)
327 Hashtable param =
new Hashtable();
328 param[
"GroupID"] = groupID.ToString();
329 param[
"RoleID"] = roleID.ToString();
332 param[
"Name"] = name;
334 if (description != null)
336 param[
"Description"] = description;
340 param[
"Title"] = title;
342 param[
"Powers"] = powers.ToString();
344 XmlRpcCall(requestingAgentID,
"groups.updateGroupRole", param);
349 Hashtable param =
new Hashtable();
350 if (GroupID !=
UUID.Zero)
352 param[
"GroupID"] = GroupID.ToString();
354 if (!
string.IsNullOrEmpty(GroupName))
356 param[
"Name"] = GroupName.ToString();
359 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getGroup", param);
361 if (respData.Contains(
"error"))
366 return GroupProfileHashtableToGroupRecord(respData);
372 Hashtable param =
new Hashtable();
373 param[
"GroupID"] = GroupID.ToString();
375 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getGroup", param);
377 if (respData.Contains(
"error"))
383 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID);
384 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
386 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
387 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
389 return MemberGroupProfile;
394 Hashtable param =
new Hashtable();
395 param[
"AgentID"] = AgentID.ToString();
396 param[
"GroupID"] = GroupID.ToString();
398 XmlRpcCall(requestingAgentID,
"groups.setAgentActiveGroup", param);
403 Hashtable param =
new Hashtable();
404 param[
"AgentID"] = AgentID.ToString();
405 param[
"GroupID"] = GroupID.ToString();
406 param[
"SelectedRoleID"] = RoleID.ToString();
408 XmlRpcCall(requestingAgentID,
"groups.setAgentGroupInfo", param);
411 public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID,
bool AcceptNotices,
bool ListInProfile)
413 Hashtable param =
new Hashtable();
414 param[
"AgentID"] = AgentID.ToString();
415 param[
"GroupID"] = GroupID.ToString();
416 param[
"AcceptNotices"] = AcceptNotices ?
"1" :
"0";
417 param[
"ListInProfile"] = ListInProfile ?
"1" :
"0";
419 XmlRpcCall(requestingAgentID,
"groups.setAgentGroupInfo", param);
425 Hashtable param =
new Hashtable();
426 param[
"InviteID"] = inviteID.ToString();
427 param[
"AgentID"] = agentID.ToString();
428 param[
"RoleID"] = roleID.ToString();
429 param[
"GroupID"] = groupID.ToString();
431 XmlRpcCall(requestingAgentID,
"groups.addAgentToGroupInvite", param);
437 Hashtable param =
new Hashtable();
438 param[
"InviteID"] = inviteID.ToString();
440 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getAgentToGroupInvite", param);
442 if (respData.Contains(
"error"))
448 inviteInfo.InviteID = inviteID;
449 inviteInfo.GroupID = UUID.Parse((string)respData[
"GroupID"]);
450 inviteInfo.RoleID = UUID.Parse((string)respData[
"RoleID"]);
451 inviteInfo.AgentID = UUID.Parse((string)respData[
"AgentID"]);
458 Hashtable param =
new Hashtable();
459 param[
"InviteID"] = inviteID.ToString();
461 XmlRpcCall(requestingAgentID,
"groups.removeAgentToGroupInvite", param);
464 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
466 Hashtable param =
new Hashtable();
467 param[
"AgentID"] = AgentID.ToString();
468 param[
"GroupID"] = GroupID.ToString();
469 param[
"RoleID"] = RoleID.ToString();
471 XmlRpcCall(requestingAgentID,
"groups.addAgentToGroup", param);
476 Hashtable param =
new Hashtable();
477 param[
"AgentID"] = AgentID.ToString();
478 param[
"GroupID"] = GroupID.ToString();
480 XmlRpcCall(requestingAgentID,
"groups.removeAgentFromGroup", param);
485 Hashtable param =
new Hashtable();
486 param[
"AgentID"] = AgentID.ToString();
487 param[
"GroupID"] = GroupID.ToString();
488 param[
"RoleID"] = RoleID.ToString();
490 XmlRpcCall(requestingAgentID,
"groups.addAgentToGroupRole", param);
495 Hashtable param =
new Hashtable();
496 param[
"AgentID"] = AgentID.ToString();
497 param[
"GroupID"] = GroupID.ToString();
498 param[
"RoleID"] = RoleID.ToString();
500 XmlRpcCall(requestingAgentID,
"groups.removeAgentFromGroupRole", param);
503 public List<DirGroupsReplyData>
FindGroups(UUID requestingAgentID,
string search)
505 Hashtable param =
new Hashtable();
506 param[
"Search"] = search;
508 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.findGroups", param);
510 List<DirGroupsReplyData> findings =
new List<DirGroupsReplyData>();
512 if (!respData.Contains(
"error"))
514 Hashtable results = (Hashtable)respData[
"results"];
515 foreach (Hashtable groupFind
in results.Values)
518 data.groupID =
new UUID((
string)groupFind[
"GroupID"]); ;
519 data.groupName = (string)groupFind[
"Name"];
520 data.members = int.Parse((string)groupFind[
"Members"]);
532 Hashtable param =
new Hashtable();
533 param[
"AgentID"] = AgentID.ToString();
534 param[
"GroupID"] = GroupID.ToString();
536 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getAgentGroupMembership", param);
538 if (respData.Contains(
"error"))
550 Hashtable param =
new Hashtable();
551 param[
"AgentID"] = AgentID.ToString();
553 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getAgentActiveMembership", param);
555 if (respData.Contains(
"error"))
560 return HashTableToGroupMembershipData(respData);
565 Hashtable param =
new Hashtable();
566 param[
"AgentID"] = AgentID.ToString();
568 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getAgentGroupMemberships", param);
570 List<GroupMembershipData> memberships =
new List<GroupMembershipData>();
572 if (!respData.Contains(
"error"))
574 foreach (
object membership
in respData.Values)
576 memberships.Add(HashTableToGroupMembershipData((Hashtable)membership));
585 Hashtable param =
new Hashtable();
586 param[
"AgentID"] = AgentID.ToString();
587 param[
"GroupID"] = GroupID.ToString();
589 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getAgentRoles", param);
591 List<GroupRolesData> Roles =
new List<GroupRolesData>();
593 if (respData.Contains(
"error"))
598 foreach (Hashtable role
in respData.Values)
601 data.RoleID =
new UUID((
string)role[
"RoleID"]);
602 data.Name = (string)role[
"Name"];
603 data.Description = (string)role[
"Description"];
604 data.Powers = ulong.Parse((string)role[
"Powers"]);
605 data.Title = (string)role[
"Title"];
613 public List<GroupRolesData>
GetGroupRoles(UUID requestingAgentID, UUID GroupID)
615 Hashtable param =
new Hashtable();
616 param[
"GroupID"] = GroupID.ToString();
618 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getGroupRoles", param);
620 List<GroupRolesData> Roles =
new List<GroupRolesData>();
622 if (respData.Contains(
"error"))
627 foreach (Hashtable role
in respData.Values)
630 data.Description = (string)role[
"Description"];
631 data.Members = int.Parse((string)role[
"Members"]);
632 data.Name = (string)role[
"Name"];
633 data.Powers = ulong.Parse((string)role[
"Powers"]);
634 data.RoleID =
new UUID((
string)role[
"RoleID"]);
635 data.Title = (string)role[
"Title"];
645 Hashtable param =
new Hashtable();
646 param[
"GroupID"] = GroupID.ToString();
648 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getGroupMembers", param);
650 List<GroupMembersData> members =
new List<GroupMembersData>();
652 if (respData.Contains(
"error"))
657 foreach (Hashtable membership
in respData.Values)
661 data.AcceptNotices = ((string)membership[
"AcceptNotices"]) ==
"1";
662 data.AgentID =
new UUID((
string)membership[
"AgentID"]);
663 data.Contribution = int.Parse((string)membership[
"Contribution"]);
664 data.IsOwner = ((string)membership[
"IsOwner"]) ==
"1";
665 data.ListInProfile = ((string)membership[
"ListInProfile"]) ==
"1";
666 data.AgentPowers = ulong.Parse((string)membership[
"AgentPowers"]);
667 data.Title = (string)membership[
"Title"];
677 Hashtable param =
new Hashtable();
678 param[
"GroupID"] = GroupID.ToString();
680 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getGroupRoleMembers", param);
682 List<GroupRoleMembersData> members =
new List<GroupRoleMembersData>();
684 if (!respData.Contains(
"error"))
686 foreach (Hashtable membership
in respData.Values)
690 data.MemberID =
new UUID((
string)membership[
"AgentID"]);
691 data.RoleID =
new UUID((
string)membership[
"RoleID"]);
701 Hashtable param =
new Hashtable();
702 param[
"GroupID"] = GroupID.ToString();
704 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getGroupNotices", param);
706 List<GroupNoticeData> values =
new List<GroupNoticeData>();
708 if (!respData.Contains(
"error"))
710 foreach (Hashtable value
in respData.Values)
713 data.NoticeID = UUID.Parse((string)value[
"NoticeID"]);
714 data.Timestamp = uint.Parse((string)value[
"Timestamp"]);
715 data.FromName = (string)value[
"FromName"];
716 data.Subject = (string)value[
"Subject"];
717 data.HasAttachment =
false;
729 Hashtable param =
new Hashtable();
730 param[
"NoticeID"] = noticeID.ToString();
732 Hashtable respData = XmlRpcCall(requestingAgentID,
"groups.getGroupNotice", param);
734 if (respData.Contains(
"error"))
740 data.GroupID = UUID.Parse((string)respData[
"GroupID"]);
741 data.Message = (string)respData[
"Message"];
742 data.BinaryBucket = Utils.HexStringToBytes((string)respData[
"BinaryBucket"],
true);
743 data.noticeData.NoticeID = UUID.Parse((string)respData[
"NoticeID"]);
744 data.noticeData.Timestamp = uint.Parse((string)respData[
"Timestamp"]);
745 data.noticeData.FromName = (string)respData[
"FromName"];
746 data.noticeData.Subject = (string)respData[
"Subject"];
747 data.noticeData.HasAttachment =
false;
748 data.noticeData.AssetType = 0;
752 data.Message = string.Empty;
758 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID,
string fromName,
string subject,
string message, byte[] binaryBucket)
760 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket,
"");
762 Hashtable param =
new Hashtable();
763 param[
"GroupID"] = groupID.ToString();
764 param[
"NoticeID"] = noticeID.ToString();
765 param[
"FromName"] = fromName;
766 param[
"Subject"] = subject;
767 param[
"Message"] = message;
768 param[
"BinaryBucket"] = binBucket;
769 param[
"TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
771 XmlRpcCall(requestingAgentID,
"groups.addGroupNotice", param);
776 #region GroupSessionTracking
780 foreach (List<UUID> agentList
in m_groupsAgentsDroppedFromChatSession.Values)
782 agentList.Remove(agentID);
789 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
790 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
797 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
798 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
803 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
806 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
808 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
816 CreateGroupChatSessionTracking(groupID);
819 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
821 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
825 private void CreateGroupChatSessionTracking(UUID groupID)
827 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
829 m_groupsAgentsDroppedFromChatSession.Add(groupID,
new List<UUID>());
830 m_groupsAgentsInvitedToChatSession.Add(groupID,
new List<UUID>());
836 #region XmlRpcHashtableMarshalling
837 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile)
840 group.GroupID = UUID.Parse((string)groupProfile[
"GroupID"]);
841 group.Name = (string)groupProfile[
"Name"];
843 if (groupProfile[
"Charter"] != null)
845 group.Charter = (string)groupProfile[
"Charter"];
848 group.ShowInList = ((string)groupProfile[
"ShowInList"]) ==
"1";
849 group.InsigniaID = UUID.Parse((string)groupProfile[
"InsigniaID"]);
850 group.MembershipFee = int.Parse((string)groupProfile[
"MembershipFee"]);
851 group.OpenEnrollment = ((string)groupProfile[
"OpenEnrollment"]) ==
"1";
852 group.AllowPublish = ((string)groupProfile[
"AllowPublish"]) ==
"1";
853 group.MaturePublish = ((string)groupProfile[
"MaturePublish"]) ==
"1";
854 group.FounderID = UUID.Parse((string)groupProfile[
"FounderID"]);
855 group.OwnerRole = UUID.Parse((string)groupProfile[
"OwnerRoleID"]);
857 group.GroupMembershipCount = int.Parse((string)groupProfile[
"GroupMembershipCount"]);
858 group.GroupRolesCount = int.Parse((string)groupProfile[
"GroupRolesCount"]);
863 private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
866 group.GroupID = UUID.Parse((string)groupProfile[
"GroupID"]);
867 group.GroupName = groupProfile[
"Name"].ToString();
868 if (groupProfile[
"Charter"] != null)
870 group.Charter = (string)groupProfile[
"Charter"];
872 group.ShowInList = ((string)groupProfile[
"ShowInList"]) ==
"1";
873 group.GroupPicture = UUID.Parse((string)groupProfile[
"InsigniaID"]);
874 group.MembershipFee = int.Parse((string)groupProfile[
"MembershipFee"]);
875 group.OpenEnrollment = ((string)groupProfile[
"OpenEnrollment"]) ==
"1";
876 group.AllowPublish = ((string)groupProfile[
"AllowPublish"]) ==
"1";
877 group.MaturePublish = ((string)groupProfile[
"MaturePublish"]) ==
"1";
878 group.FounderID = UUID.Parse((string)groupProfile[
"FounderID"]);
879 group.OwnerRoleID = UUID.Parse((string)groupProfile[
"OwnerRoleID"]);
887 data.AcceptNotices = ((string)respData[
"AcceptNotices"] ==
"1");
888 data.Contribution = int.Parse((string)respData[
"Contribution"]);
889 data.ListInProfile = ((string)respData[
"ListInProfile"] ==
"1");
891 data.ActiveRole =
new UUID((
string)respData[
"SelectedRoleID"]);
892 data.GroupTitle = (string)respData[
"Title"];
894 data.GroupPowers = ulong.Parse((string)respData[
"GroupPowers"]);
898 data.GroupID =
new UUID((
string)respData[
"GroupID"]);
900 UUID ActiveGroup =
new UUID((
string)respData[
"ActiveGroupID"]);
901 data.Active = data.GroupID.Equals(ActiveGroup);
903 data.AllowPublish = ((string)respData[
"AllowPublish"] ==
"1");
904 if (respData[
"Charter"] != null)
906 data.Charter = (string)respData[
"Charter"];
908 data.FounderID =
new UUID((
string)respData[
"FounderID"]);
909 data.GroupID =
new UUID((
string)respData[
"GroupID"]);
910 data.GroupName = (string)respData[
"GroupName"];
911 data.GroupPicture =
new UUID((
string)respData[
"InsigniaID"]);
912 data.MaturePublish = ((string)respData[
"MaturePublish"] ==
"1");
913 data.MembershipFee = int.Parse((string)respData[
"MembershipFee"]);
914 data.OpenEnrollment = ((string)respData[
"OpenEnrollment"] ==
"1");
915 data.ShowInList = ((string)respData[
"ShowInList"] ==
"1");
925 private Hashtable XmlRpcCall(UUID requestingAgentID,
string function, Hashtable param)
927 XmlRpcResponse resp = null;
928 string CacheKey = null;
931 if (m_cacheTimeout > 0)
933 if (!
function.StartsWith(
"groups.get"))
936 m_memoryCache.Clear();
940 StringBuilder sb =
new StringBuilder(requestingAgentID +
function);
941 foreach (
object key in param.Keys)
943 if (param[key] != null)
945 sb.AppendFormat(
",{0}:{1}", key.ToString(), param[key].ToString());
949 CacheKey = sb.ToString();
950 m_memoryCache.TryGetValue(CacheKey, out resp);
957 m_log.DebugFormat(
"[XMLRPC-GROUPS-CONNECTOR]: Cache miss for key {0}", CacheKey);
961 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
963 param.Add(
"RequestingAgentID", requestingAgentID.ToString());
964 param.Add(
"RequestingAgentUserService", UserService);
965 param.Add(
"RequestingSessionID", SessionID.ToString());
966 param.Add(
"ReadKey", m_groupReadKey);
967 param.Add(
"WriteKey", m_groupWriteKey);
969 IList parameters =
new ArrayList();
970 parameters.Add(param);
977 resp = req.Send(m_groupsServerURI, 10000);
979 if ((m_cacheTimeout > 0) && (CacheKey != null))
981 m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
987 "[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method {0} at {1}: {2}",
988 function, m_groupsServerURI, e.Message);
992 m_log.ErrorFormat(
"[XMLRPC-GROUPS-CONNECTOR]: {0}", e.StackTrace);
994 foreach (
string ResponseLine
in req.RequestResponse.Split(
new string[] { Environment.NewLine }, StringSplitOptions.None))
996 m_log.ErrorFormat(
"[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine);
999 foreach (
string key
in param.Keys)
1001 m_log.WarnFormat(
"[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}",
key, param[
key].ToString());
1004 Hashtable respData =
new Hashtable();
1005 respData.Add(
"error", e.ToString());
1010 if (resp.Value is Hashtable)
1012 Hashtable respData = (Hashtable)resp.Value;
1013 if (respData.Contains(
"error") && !respData.Contains(
"succeed"))
1015 LogRespDataToConsoleError(requestingAgentID,
function, param, respData);
1021 m_log.ErrorFormat(
"[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}",
function, resp.Value.GetType().ToString());
1023 if (resp.Value is ArrayList)
1025 ArrayList al = (ArrayList)resp.Value;
1026 m_log.ErrorFormat(
"[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count);
1028 foreach (
object o
in al)
1030 m_log.ErrorFormat(
"[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString());
1035 m_log.ErrorFormat(
"[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString());
1038 Hashtable error =
new Hashtable();
1039 error.Add(
"error",
"invalid return value");
1043 private void LogRespDataToConsoleError(UUID requestingAgentID,
string function, Hashtable param, Hashtable respData)
1046 "[XMLRPC-GROUPS-CONNECTOR]: Error when calling {0} for {1} with params {2}. Response params are {3}",
1047 function, requestingAgentID, Util.PrettyFormatToSingleLine(param), Util.PrettyFormatToSingleLine(respData));
1057 private void GetClientGroupRequestID(UUID AgentID, out
string UserServiceURL, out UUID SessionID)
1059 UserServiceURL =
"";
1060 SessionID = UUID.Zero;
1095 namespace Nwc.XmlRpc
1098 using System.Collections;
1103 using System.Reflection;
1108 private XmlRpcRequestSerializer _serializer =
new XmlRpcRequestSerializer();
1109 private XmlRpcResponseDeserializer _deserializer =
new XmlRpcResponseDeserializer();
1110 private bool _disableKeepAlive =
true;
1112 public string RequestResponse = String.Empty;
1120 MethodName = methodName;
1121 _params = parameters;
1122 _disableKeepAlive = disableKeepAlive;
1128 public XmlRpcResponse
Send(String url)
1130 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
1131 if (request == null)
1132 throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR,
1133 XmlRpcErrorCodes.TRANSPORT_ERROR_MSG +
": Could not create request with " + url);
1134 request.Method =
"POST";
1135 request.ContentType =
"text/xml";
1136 request.AllowWriteStreamBuffering =
true;
1137 request.KeepAlive = !_disableKeepAlive;
1139 using (Stream stream = request.GetRequestStream())
1141 using (XmlTextWriter xml =
new XmlTextWriter(stream, Encoding.ASCII))
1143 _serializer.Serialize(xml,
this);
1148 XmlRpcResponse resp;
1150 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
1152 using (Stream s = response.GetResponseStream())
1154 using (StreamReader input =
new StreamReader(s))
1156 string inputXml = input.ReadToEnd();
1160 resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
1164 RequestResponse = inputXml;
GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
Class supporting the request side of an XML-RPC transaction.
bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
List< DirGroupsReplyData > FindGroups(UUID requestingAgentID, string search)
List< GroupMembershipData > GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
Get information about the groups to which a user belongs.
void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
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.
void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
void Initialise(IConfigSource config)
This is called to initialize the region module. For shared modules, this is called exactly once...
List< GroupNoticeData > GetGroupNotices(UUID requestingAgentID, UUID GroupID)
void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
XmlRpcResponse Send(String url)
Send the request to the server.
List< GroupRoleMembersData > GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
Get the group record.
void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
void ResetAgentGroupChatSessions(UUID agentID)
Interactive OpenSim region server
GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
List< GroupRolesData > GetGroupRoles(UUID requestingAgentID, UUID GroupID)
void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
List< GroupMembersData > GetGroupMembers(UUID requestingAgentID, UUID GroupID)
GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
Get information about a specific group to which the user belongs.
bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
List< GroupRolesData > GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
ConfigurableKeepAliveXmlRpcRequest(String methodName, IList parameters, bool disableKeepAlive)
Instantiate an XmlRpcRequest for a specified method and parameters.