diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs (renamed from OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupData.cs) | 275 |
1 files changed, 183 insertions, 92 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupData.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index 1d4cde5..03fe109 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupData.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs | |||
@@ -29,27 +29,25 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | //using System.Text; | ||
33 | 32 | ||
34 | using Nwc.XmlRpc; | 33 | using Nwc.XmlRpc; |
35 | 34 | ||
36 | using log4net; | 35 | using log4net; |
37 | // using Nini.Config; | 36 | using Nini.Config; |
38 | 37 | ||
39 | using OpenMetaverse; | 38 | using OpenMetaverse; |
40 | using OpenMetaverse.StructuredData; | 39 | using OpenMetaverse.StructuredData; |
41 | 40 | ||
42 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
43 | //using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
44 | 43 | ||
45 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 44 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
46 | { | 45 | { |
47 | public class XmlRpcGroupDataProvider : IGroupDataProvider | 46 | public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector |
48 | { | 47 | { |
49 | private static readonly ILog m_log = | 48 | private static readonly ILog m_log = |
50 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 50 | ||
52 | private string m_serviceURL = string.Empty; | ||
53 | 51 | ||
54 | public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | | 52 | public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | |
55 | GroupPowers.Accountable | | 53 | GroupPowers.Accountable | |
@@ -59,26 +57,108 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
59 | GroupPowers.StartProposal | | 57 | GroupPowers.StartProposal | |
60 | GroupPowers.VoteOnProposal; | 58 | GroupPowers.VoteOnProposal; |
61 | 59 | ||
60 | private bool m_connectorEnabled = false; | ||
61 | |||
62 | private string m_serviceURL = string.Empty; | ||
63 | |||
62 | private bool m_disableKeepAlive = false; | 64 | private bool m_disableKeepAlive = false; |
63 | 65 | ||
64 | private string m_groupReadKey = string.Empty; | 66 | private string m_groupReadKey = string.Empty; |
65 | private string m_groupWriteKey = string.Empty; | 67 | private string m_groupWriteKey = string.Empty; |
66 | 68 | ||
67 | public XmlRpcGroupDataProvider(string serviceURL, bool disableKeepAlive, string groupReadKey, string groupWriteKey) | 69 | |
70 | #region IRegionModuleBase Members | ||
71 | |||
72 | public string Name | ||
73 | { | ||
74 | get { return "XmlRpcGroupsServicesConnector"; } | ||
75 | } | ||
76 | |||
77 | // this module is not intended to be replaced, but there should only be 1 of them. | ||
78 | public Type ReplacableInterface | ||
68 | { | 79 | { |
69 | m_serviceURL = serviceURL.Trim(); | 80 | get { return null; } |
70 | m_disableKeepAlive = disableKeepAlive; | 81 | } |
71 | 82 | ||
72 | if ((serviceURL == null) || | 83 | public void Initialise(IConfigSource config) |
73 | (serviceURL == string.Empty)) | 84 | { |
85 | IConfig groupsConfig = config.Configs["Groups"]; | ||
86 | |||
87 | if (groupsConfig == null) | ||
74 | { | 88 | { |
75 | throw new Exception("Please specify a valid ServiceURL for XmlRpcGroupDataProvider in OpenSim.ini, [Groups], XmlRpcServiceURL"); | 89 | // Do not run this module by default. |
90 | return; | ||
76 | } | 91 | } |
92 | else | ||
93 | { | ||
94 | // if groups aren't enabled, we're not needed. | ||
95 | // if we're not specified as the connector to use, then we're not wanted | ||
96 | if ( (groupsConfig.GetBoolean("Enabled", false) == false) | ||
97 | || (groupsConfig.GetString("GroupsServicesConnectorModule", "Default") != Name)) | ||
98 | { | ||
99 | m_connectorEnabled = false; | ||
100 | return; | ||
101 | } | ||
102 | |||
103 | m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); | ||
104 | |||
105 | m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); | ||
106 | if ((m_serviceURL == null) || | ||
107 | (m_serviceURL == string.Empty)) | ||
108 | { | ||
109 | m_log.ErrorFormat("Please specify a valid URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); | ||
110 | m_connectorEnabled = false; | ||
111 | return; | ||
112 | } | ||
113 | |||
114 | m_disableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", false); | ||
77 | 115 | ||
78 | m_groupReadKey = groupReadKey; | 116 | m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); |
79 | m_groupWriteKey = groupWriteKey; | 117 | m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); |
118 | |||
119 | // If we got all the config options we need, lets start'er'up | ||
120 | m_connectorEnabled = true; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | public void Close() | ||
125 | { | ||
126 | m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); | ||
80 | } | 127 | } |
81 | 128 | ||
129 | public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) | ||
130 | { | ||
131 | if (m_connectorEnabled) | ||
132 | scene.RegisterModuleInterface<IGroupsServicesConnector>(this); | ||
133 | } | ||
134 | |||
135 | public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) | ||
136 | { | ||
137 | if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) | ||
138 | scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); | ||
139 | } | ||
140 | |||
141 | public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) | ||
142 | { | ||
143 | // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info | ||
144 | // scene.EventManager.OnNewClient += OnNewClient; | ||
145 | } | ||
146 | |||
147 | #endregion | ||
148 | |||
149 | #region ISharedRegionModule Members | ||
150 | |||
151 | public void PostInitialise() | ||
152 | { | ||
153 | // NoOp | ||
154 | } | ||
155 | |||
156 | #endregion | ||
157 | |||
158 | |||
159 | |||
160 | #region IGroupsServicesConnector Members | ||
161 | |||
82 | /// <summary> | 162 | /// <summary> |
83 | /// 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. | 163 | /// 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. |
84 | /// </summary> | 164 | /// </summary> |
@@ -275,53 +355,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
275 | 355 | ||
276 | } | 356 | } |
277 | 357 | ||
278 | private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile) | ||
279 | { | ||
280 | GroupProfileData group = new GroupProfileData(); | ||
281 | group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); | ||
282 | group.Name = (string)groupProfile["Name"]; | ||
283 | 358 | ||
284 | if (groupProfile["Charter"] != null) | ||
285 | { | ||
286 | group.Charter = (string)groupProfile["Charter"]; | ||
287 | } | ||
288 | |||
289 | group.ShowInList = ((string)groupProfile["ShowInList"]) == "1"; | ||
290 | group.InsigniaID = UUID.Parse((string)groupProfile["InsigniaID"]); | ||
291 | group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]); | ||
292 | group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1"; | ||
293 | group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1"; | ||
294 | group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1"; | ||
295 | group.FounderID = UUID.Parse((string)groupProfile["FounderID"]); | ||
296 | group.OwnerRole = UUID.Parse((string)groupProfile["OwnerRoleID"]); | ||
297 | |||
298 | group.GroupMembershipCount = int.Parse((string)groupProfile["GroupMembershipCount"]); | ||
299 | group.GroupRolesCount = int.Parse((string)groupProfile["GroupRolesCount"]); | ||
300 | |||
301 | return group; | ||
302 | } | ||
303 | |||
304 | private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile) | ||
305 | { | ||
306 | |||
307 | GroupRecord group = new GroupRecord(); | ||
308 | group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); | ||
309 | group.GroupName = groupProfile["Name"].ToString(); | ||
310 | if (groupProfile["Charter"] != null) | ||
311 | { | ||
312 | group.Charter = (string)groupProfile["Charter"]; | ||
313 | } | ||
314 | group.ShowInList = ((string)groupProfile["ShowInList"]) == "1"; | ||
315 | group.GroupPicture = UUID.Parse((string)groupProfile["InsigniaID"]); | ||
316 | group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]); | ||
317 | group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1"; | ||
318 | group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1"; | ||
319 | group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1"; | ||
320 | group.FounderID = UUID.Parse((string)groupProfile["FounderID"]); | ||
321 | group.OwnerRoleID = UUID.Parse((string)groupProfile["OwnerRoleID"]); | ||
322 | |||
323 | return group; | ||
324 | } | ||
325 | 359 | ||
326 | public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) | 360 | public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) |
327 | { | 361 | { |
@@ -579,40 +613,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
579 | 613 | ||
580 | } | 614 | } |
581 | 615 | ||
582 | private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) | ||
583 | { | ||
584 | GroupMembershipData data = new GroupMembershipData(); | ||
585 | data.AcceptNotices = ((string)respData["AcceptNotices"] == "1"); | ||
586 | data.Contribution = int.Parse((string)respData["Contribution"]); | ||
587 | data.ListInProfile = ((string)respData["ListInProfile"] == "1"); | ||
588 | |||
589 | data.ActiveRole = new UUID((string)respData["SelectedRoleID"]); | ||
590 | data.GroupTitle = (string)respData["Title"]; | ||
591 | 616 | ||
592 | data.GroupPowers = ulong.Parse((string)respData["GroupPowers"]); | ||
593 | |||
594 | // Is this group the agent's active group | ||
595 | |||
596 | data.GroupID = new UUID((string)respData["GroupID"]); | ||
597 | |||
598 | UUID ActiveGroup = new UUID((string)respData["ActiveGroupID"]); | ||
599 | data.Active = data.GroupID.Equals(ActiveGroup); | ||
600 | |||
601 | data.AllowPublish = ((string)respData["AllowPublish"] == "1"); | ||
602 | if (respData["Charter"] != null) | ||
603 | { | ||
604 | data.Charter = (string)respData["Charter"]; | ||
605 | } | ||
606 | data.FounderID = new UUID((string)respData["FounderID"]); | ||
607 | data.GroupID = new UUID((string)respData["GroupID"]); | ||
608 | data.GroupName = (string)respData["GroupName"]; | ||
609 | data.GroupPicture = new UUID((string)respData["InsigniaID"]); | ||
610 | data.MaturePublish = ((string)respData["MaturePublish"] == "1"); | ||
611 | data.MembershipFee = int.Parse((string)respData["MembershipFee"]); | ||
612 | data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1"); | ||
613 | data.ShowInList = ((string)respData["ShowInList"] == "1"); | ||
614 | return data; | ||
615 | } | ||
616 | 617 | ||
617 | public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID) | 618 | public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID) |
618 | { | 619 | { |
@@ -744,7 +745,96 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
744 | 745 | ||
745 | XmlRpcCall(requestID, "groups.addGroupNotice", param); | 746 | XmlRpcCall(requestID, "groups.addGroupNotice", param); |
746 | } | 747 | } |
748 | #endregion | ||
749 | |||
750 | #region XmlRpcHashtableMarshalling | ||
751 | private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile) | ||
752 | { | ||
753 | GroupProfileData group = new GroupProfileData(); | ||
754 | group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); | ||
755 | group.Name = (string)groupProfile["Name"]; | ||
756 | |||
757 | if (groupProfile["Charter"] != null) | ||
758 | { | ||
759 | group.Charter = (string)groupProfile["Charter"]; | ||
760 | } | ||
761 | |||
762 | group.ShowInList = ((string)groupProfile["ShowInList"]) == "1"; | ||
763 | group.InsigniaID = UUID.Parse((string)groupProfile["InsigniaID"]); | ||
764 | group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]); | ||
765 | group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1"; | ||
766 | group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1"; | ||
767 | group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1"; | ||
768 | group.FounderID = UUID.Parse((string)groupProfile["FounderID"]); | ||
769 | group.OwnerRole = UUID.Parse((string)groupProfile["OwnerRoleID"]); | ||
770 | |||
771 | group.GroupMembershipCount = int.Parse((string)groupProfile["GroupMembershipCount"]); | ||
772 | group.GroupRolesCount = int.Parse((string)groupProfile["GroupRolesCount"]); | ||
773 | |||
774 | return group; | ||
775 | } | ||
776 | |||
777 | private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile) | ||
778 | { | ||
779 | |||
780 | GroupRecord group = new GroupRecord(); | ||
781 | group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); | ||
782 | group.GroupName = groupProfile["Name"].ToString(); | ||
783 | if (groupProfile["Charter"] != null) | ||
784 | { | ||
785 | group.Charter = (string)groupProfile["Charter"]; | ||
786 | } | ||
787 | group.ShowInList = ((string)groupProfile["ShowInList"]) == "1"; | ||
788 | group.GroupPicture = UUID.Parse((string)groupProfile["InsigniaID"]); | ||
789 | group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]); | ||
790 | group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1"; | ||
791 | group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1"; | ||
792 | group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1"; | ||
793 | group.FounderID = UUID.Parse((string)groupProfile["FounderID"]); | ||
794 | group.OwnerRoleID = UUID.Parse((string)groupProfile["OwnerRoleID"]); | ||
795 | |||
796 | return group; | ||
797 | } | ||
798 | private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) | ||
799 | { | ||
800 | GroupMembershipData data = new GroupMembershipData(); | ||
801 | data.AcceptNotices = ((string)respData["AcceptNotices"] == "1"); | ||
802 | data.Contribution = int.Parse((string)respData["Contribution"]); | ||
803 | data.ListInProfile = ((string)respData["ListInProfile"] == "1"); | ||
804 | |||
805 | data.ActiveRole = new UUID((string)respData["SelectedRoleID"]); | ||
806 | data.GroupTitle = (string)respData["Title"]; | ||
807 | |||
808 | data.GroupPowers = ulong.Parse((string)respData["GroupPowers"]); | ||
809 | |||
810 | // Is this group the agent's active group | ||
811 | |||
812 | data.GroupID = new UUID((string)respData["GroupID"]); | ||
813 | |||
814 | UUID ActiveGroup = new UUID((string)respData["ActiveGroupID"]); | ||
815 | data.Active = data.GroupID.Equals(ActiveGroup); | ||
816 | |||
817 | data.AllowPublish = ((string)respData["AllowPublish"] == "1"); | ||
818 | if (respData["Charter"] != null) | ||
819 | { | ||
820 | data.Charter = (string)respData["Charter"]; | ||
821 | } | ||
822 | data.FounderID = new UUID((string)respData["FounderID"]); | ||
823 | data.GroupID = new UUID((string)respData["GroupID"]); | ||
824 | data.GroupName = (string)respData["GroupName"]; | ||
825 | data.GroupPicture = new UUID((string)respData["InsigniaID"]); | ||
826 | data.MaturePublish = ((string)respData["MaturePublish"] == "1"); | ||
827 | data.MembershipFee = int.Parse((string)respData["MembershipFee"]); | ||
828 | data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1"); | ||
829 | data.ShowInList = ((string)respData["ShowInList"] == "1"); | ||
830 | return data; | ||
831 | } | ||
832 | |||
833 | #endregion | ||
747 | 834 | ||
835 | /// <summary> | ||
836 | /// Encapsulate the XmlRpc call to standardize security and error handling. | ||
837 | /// </summary> | ||
748 | private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param) | 838 | private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param) |
749 | { | 839 | { |
750 | if (requestID == null) | 840 | if (requestID == null) |
@@ -846,6 +936,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
846 | } | 936 | } |
847 | } | 937 | } |
848 | 938 | ||
939 | |||
849 | } | 940 | } |
850 | 941 | ||
851 | public class GroupNoticeInfo | 942 | public class GroupNoticeInfo |