XmlRpcGroupsServicesConnectorModule.cs 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Reflection;
  31. using System.Text;
  32. using Nwc.XmlRpc;
  33. using log4net;
  34. using Mono.Addins;
  35. using Nini.Config;
  36. using OpenMetaverse;
  37. using OpenMetaverse.StructuredData;
  38. using OpenSim.Framework;
  39. using OpenSim.Region.Framework.Interfaces;
  40. using OpenSim.Services.Interfaces;
  41. namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
  42. {
  43. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcGroupsServicesConnectorModule")]
  44. public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
  45. {
  46. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  47. private bool m_debugEnabled = false;
  48. public const GroupPowers DefaultEveryonePowers
  49. = GroupPowers.AllowSetHome
  50. | GroupPowers.Accountable
  51. | GroupPowers.JoinChat
  52. | GroupPowers.AllowVoiceChat
  53. | GroupPowers.ReceiveNotices
  54. | GroupPowers.StartProposal
  55. | GroupPowers.VoteOnProposal;
  56. // Would this be cleaner as (GroupPowers)ulong.MaxValue?
  57. public const GroupPowers DefaultOwnerPowers
  58. = GroupPowers.Accountable
  59. | GroupPowers.AllowEditLand
  60. | GroupPowers.AllowFly
  61. | GroupPowers.AllowLandmark
  62. | GroupPowers.AllowRez
  63. | GroupPowers.AllowSetHome
  64. | GroupPowers.AllowVoiceChat
  65. | GroupPowers.AssignMember
  66. | GroupPowers.AssignMemberLimited
  67. | GroupPowers.ChangeActions
  68. | GroupPowers.ChangeIdentity
  69. | GroupPowers.ChangeMedia
  70. | GroupPowers.ChangeOptions
  71. | GroupPowers.CreateRole
  72. | GroupPowers.DeedObject
  73. | GroupPowers.DeleteRole
  74. | GroupPowers.Eject
  75. | GroupPowers.FindPlaces
  76. | GroupPowers.Invite
  77. | GroupPowers.JoinChat
  78. | GroupPowers.LandChangeIdentity
  79. | GroupPowers.LandDeed
  80. | GroupPowers.LandDivideJoin
  81. | GroupPowers.LandEdit
  82. | GroupPowers.LandEjectAndFreeze
  83. | GroupPowers.LandGardening
  84. | GroupPowers.LandManageAllowed
  85. | GroupPowers.LandManageBanned
  86. | GroupPowers.LandManagePasses
  87. | GroupPowers.LandOptions
  88. | GroupPowers.LandRelease
  89. | GroupPowers.LandSetSale
  90. | GroupPowers.ModerateChat
  91. | GroupPowers.ObjectManipulate
  92. | GroupPowers.ObjectSetForSale
  93. | GroupPowers.ReceiveNotices
  94. | GroupPowers.RemoveMember
  95. | GroupPowers.ReturnGroupOwned
  96. | GroupPowers.ReturnGroupSet
  97. | GroupPowers.ReturnNonGroup
  98. | GroupPowers.RoleProperties
  99. | GroupPowers.SendNotices
  100. | GroupPowers.SetLandingPoint
  101. | GroupPowers.StartProposal
  102. | GroupPowers.VoteOnProposal;
  103. private bool m_connectorEnabled = false;
  104. private string m_groupsServerURI = string.Empty;
  105. private bool m_disableKeepAlive = true;
  106. private string m_groupReadKey = string.Empty;
  107. private string m_groupWriteKey = string.Empty;
  108. private IUserAccountService m_accountService = null;
  109. private ExpiringCache<string, XmlRpcResponse> m_memoryCache;
  110. private int m_cacheTimeout = 30;
  111. // Used to track which agents are have dropped from a group chat session
  112. // Should be reset per agent, on logon
  113. // TODO: move this to Flotsam XmlRpc Service
  114. // SessionID, List<AgentID>
  115. private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
  116. private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
  117. #region Region Module interfaceBase Members
  118. public string Name
  119. {
  120. get { return "XmlRpcGroupsServicesConnector"; }
  121. }
  122. // this module is not intended to be replaced, but there should only be 1 of them.
  123. public Type ReplaceableInterface
  124. {
  125. get { return null; }
  126. }
  127. public void Initialise(IConfigSource config)
  128. {
  129. IConfig groupsConfig = config.Configs["Groups"];
  130. if (groupsConfig == null)
  131. {
  132. // Do not run this module by default.
  133. return;
  134. }
  135. else
  136. {
  137. // if groups aren't enabled, we're not needed.
  138. // if we're not specified as the connector to use, then we're not wanted
  139. if ((groupsConfig.GetBoolean("Enabled", false) == false)
  140. || (groupsConfig.GetString("ServicesConnectorModule", "XmlRpcGroupsServicesConnector") != Name))
  141. {
  142. m_connectorEnabled = false;
  143. return;
  144. }
  145. m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
  146. m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
  147. if (string.IsNullOrEmpty(m_groupsServerURI))
  148. {
  149. m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
  150. m_connectorEnabled = false;
  151. return;
  152. }
  153. m_disableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", true);
  154. m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
  155. m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
  156. m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
  157. if (m_cacheTimeout == 0)
  158. {
  159. m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled.");
  160. }
  161. else
  162. {
  163. m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout);
  164. }
  165. m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", false);
  166. // If we got all the config options we need, lets start'er'up
  167. m_memoryCache = new ExpiringCache<string, XmlRpcResponse>();
  168. m_connectorEnabled = true;
  169. }
  170. }
  171. public void Close()
  172. {
  173. }
  174. public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
  175. {
  176. if (m_connectorEnabled)
  177. {
  178. if (m_accountService == null)
  179. {
  180. m_accountService = scene.UserAccountService;
  181. }
  182. scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
  183. }
  184. }
  185. public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
  186. {
  187. if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
  188. {
  189. scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
  190. }
  191. }
  192. public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
  193. {
  194. // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info
  195. // scene.EventManager.OnNewClient += OnNewClient;
  196. }
  197. #endregion
  198. #region ISharedRegionModule Members
  199. public void PostInitialise()
  200. {
  201. // NoOp
  202. }
  203. #endregion
  204. #region IGroupsServicesConnector Members
  205. /// <summary>
  206. /// 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.
  207. /// </summary>
  208. public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
  209. int membershipFee, bool openEnrollment, bool allowPublish,
  210. bool maturePublish, UUID founderID)
  211. {
  212. UUID GroupID = UUID.Random();
  213. UUID OwnerRoleID = UUID.Random();
  214. Hashtable param = new Hashtable();
  215. param["GroupID"] = GroupID.ToString();
  216. param["Name"] = name;
  217. param["Charter"] = charter;
  218. param["ShowInList"] = showInList == true ? 1 : 0;
  219. param["InsigniaID"] = insigniaID.ToString();
  220. param["MembershipFee"] = membershipFee;
  221. param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
  222. param["AllowPublish"] = allowPublish == true ? 1 : 0;
  223. param["MaturePublish"] = maturePublish == true ? 1 : 0;
  224. param["FounderID"] = founderID.ToString();
  225. param["EveryonePowers"] = ((ulong)DefaultEveryonePowers).ToString();
  226. param["OwnerRoleID"] = OwnerRoleID.ToString();
  227. param["OwnersPowers"] = ((ulong)DefaultOwnerPowers).ToString();
  228. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param);
  229. if (respData.Contains("error"))
  230. {
  231. // UUID is not nullable
  232. return UUID.Zero;
  233. }
  234. return UUID.Parse((string)respData["GroupID"]);
  235. }
  236. public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
  237. UUID insigniaID, int membershipFee, bool openEnrollment,
  238. bool allowPublish, bool maturePublish)
  239. {
  240. Hashtable param = new Hashtable();
  241. param["GroupID"] = groupID.ToString();
  242. param["Charter"] = charter;
  243. param["ShowInList"] = showInList == true ? 1 : 0;
  244. param["InsigniaID"] = insigniaID.ToString();
  245. param["MembershipFee"] = membershipFee;
  246. param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
  247. param["AllowPublish"] = allowPublish == true ? 1 : 0;
  248. param["MaturePublish"] = maturePublish == true ? 1 : 0;
  249. XmlRpcCall(requestingAgentID, "groups.updateGroup", param);
  250. }
  251. public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
  252. string title, ulong powers)
  253. {
  254. Hashtable param = new Hashtable();
  255. param["GroupID"] = groupID.ToString();
  256. param["RoleID"] = roleID.ToString();
  257. param["Name"] = name;
  258. param["Description"] = description;
  259. param["Title"] = title;
  260. param["Powers"] = powers.ToString();
  261. XmlRpcCall(requestingAgentID, "groups.addRoleToGroup", param);
  262. }
  263. public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
  264. {
  265. Hashtable param = new Hashtable();
  266. param["GroupID"] = groupID.ToString();
  267. param["RoleID"] = roleID.ToString();
  268. XmlRpcCall(requestingAgentID, "groups.removeRoleFromGroup", param);
  269. }
  270. public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
  271. string title, ulong powers)
  272. {
  273. Hashtable param = new Hashtable();
  274. param["GroupID"] = groupID.ToString();
  275. param["RoleID"] = roleID.ToString();
  276. if (name != null)
  277. {
  278. param["Name"] = name;
  279. }
  280. if (description != null)
  281. {
  282. param["Description"] = description;
  283. }
  284. if (title != null)
  285. {
  286. param["Title"] = title;
  287. }
  288. param["Powers"] = powers.ToString();
  289. XmlRpcCall(requestingAgentID, "groups.updateGroupRole", param);
  290. }
  291. public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
  292. {
  293. Hashtable param = new Hashtable();
  294. if (GroupID != UUID.Zero)
  295. {
  296. param["GroupID"] = GroupID.ToString();
  297. }
  298. if (!string.IsNullOrEmpty(GroupName))
  299. {
  300. param["Name"] = GroupName.ToString();
  301. }
  302. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
  303. if (respData.Contains("error"))
  304. {
  305. return null;
  306. }
  307. return GroupProfileHashtableToGroupRecord(respData);
  308. }
  309. public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
  310. {
  311. Hashtable param = new Hashtable();
  312. param["GroupID"] = GroupID.ToString();
  313. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
  314. if (respData.Contains("error"))
  315. {
  316. // GroupProfileData is not nullable
  317. return new GroupProfileData();
  318. }
  319. GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID);
  320. GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
  321. if(MemberInfo != null)
  322. {
  323. MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
  324. MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
  325. }
  326. return MemberGroupProfile;
  327. }
  328. public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  329. {
  330. Hashtable param = new Hashtable();
  331. param["AgentID"] = AgentID.ToString();
  332. param["GroupID"] = GroupID.ToString();
  333. XmlRpcCall(requestingAgentID, "groups.setAgentActiveGroup", param);
  334. }
  335. public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  336. {
  337. Hashtable param = new Hashtable();
  338. param["AgentID"] = AgentID.ToString();
  339. param["GroupID"] = GroupID.ToString();
  340. param["SelectedRoleID"] = RoleID.ToString();
  341. XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
  342. }
  343. public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
  344. {
  345. Hashtable param = new Hashtable();
  346. param["AgentID"] = AgentID.ToString();
  347. param["GroupID"] = GroupID.ToString();
  348. param["AcceptNotices"] = AcceptNotices ? "1" : "0";
  349. param["ListInProfile"] = ListInProfile ? "1" : "0";
  350. XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
  351. }
  352. public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
  353. {
  354. Hashtable param = new Hashtable();
  355. param["InviteID"] = inviteID.ToString();
  356. param["AgentID"] = agentID.ToString();
  357. param["RoleID"] = roleID.ToString();
  358. param["GroupID"] = groupID.ToString();
  359. XmlRpcCall(requestingAgentID, "groups.addAgentToGroupInvite", param);
  360. }
  361. public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
  362. {
  363. Hashtable param = new Hashtable();
  364. param["InviteID"] = inviteID.ToString();
  365. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentToGroupInvite", param);
  366. if (respData.Contains("error"))
  367. {
  368. return null;
  369. }
  370. GroupInviteInfo inviteInfo = new GroupInviteInfo();
  371. inviteInfo.InviteID = inviteID;
  372. inviteInfo.GroupID = UUID.Parse((string)respData["GroupID"]);
  373. inviteInfo.RoleID = UUID.Parse((string)respData["RoleID"]);
  374. inviteInfo.AgentID = UUID.Parse((string)respData["AgentID"]);
  375. return inviteInfo;
  376. }
  377. public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
  378. {
  379. Hashtable param = new Hashtable();
  380. param["InviteID"] = inviteID.ToString();
  381. XmlRpcCall(requestingAgentID, "groups.removeAgentToGroupInvite", param);
  382. }
  383. public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  384. {
  385. Hashtable param = new Hashtable();
  386. param["AgentID"] = AgentID.ToString();
  387. param["GroupID"] = GroupID.ToString();
  388. param["RoleID"] = RoleID.ToString();
  389. XmlRpcCall(requestingAgentID, "groups.addAgentToGroup", param);
  390. }
  391. public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  392. {
  393. Hashtable param = new Hashtable();
  394. param["AgentID"] = AgentID.ToString();
  395. param["GroupID"] = GroupID.ToString();
  396. XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroup", param);
  397. }
  398. public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  399. {
  400. Hashtable param = new Hashtable();
  401. param["AgentID"] = AgentID.ToString();
  402. param["GroupID"] = GroupID.ToString();
  403. param["RoleID"] = RoleID.ToString();
  404. XmlRpcCall(requestingAgentID, "groups.addAgentToGroupRole", param);
  405. }
  406. public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  407. {
  408. Hashtable param = new Hashtable();
  409. param["AgentID"] = AgentID.ToString();
  410. param["GroupID"] = GroupID.ToString();
  411. param["RoleID"] = RoleID.ToString();
  412. XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroupRole", param);
  413. }
  414. public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
  415. {
  416. Hashtable param = new Hashtable();
  417. param["Search"] = search;
  418. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param);
  419. List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
  420. if (!respData.Contains("error"))
  421. {
  422. Hashtable results = (Hashtable)respData["results"];
  423. foreach (Hashtable groupFind in results.Values)
  424. {
  425. DirGroupsReplyData data = new DirGroupsReplyData();
  426. data.groupID = new UUID((string)groupFind["GroupID"]); ;
  427. data.groupName = (string)groupFind["Name"];
  428. data.members = int.Parse((string)groupFind["Members"]);
  429. // data.searchOrder = order;
  430. findings.Add(data);
  431. }
  432. }
  433. return findings;
  434. }
  435. public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  436. {
  437. Hashtable param = new Hashtable();
  438. param["AgentID"] = AgentID.ToString();
  439. param["GroupID"] = GroupID.ToString();
  440. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMembership", param);
  441. if (respData.Contains("error"))
  442. {
  443. return null;
  444. }
  445. GroupMembershipData data = HashTableToGroupMembershipData(respData);
  446. return data;
  447. }
  448. public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
  449. {
  450. Hashtable param = new Hashtable();
  451. param["AgentID"] = AgentID.ToString();
  452. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentActiveMembership", param);
  453. if (respData.Contains("error"))
  454. {
  455. return null;
  456. }
  457. return HashTableToGroupMembershipData(respData);
  458. }
  459. public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
  460. {
  461. Hashtable param = new Hashtable();
  462. param["AgentID"] = AgentID.ToString();
  463. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMemberships", param);
  464. List<GroupMembershipData> memberships = new List<GroupMembershipData>();
  465. if (!respData.Contains("error"))
  466. {
  467. foreach (object membership in respData.Values)
  468. {
  469. memberships.Add(HashTableToGroupMembershipData((Hashtable)membership));
  470. }
  471. }
  472. return memberships;
  473. }
  474. public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  475. {
  476. Hashtable param = new Hashtable();
  477. param["AgentID"] = AgentID.ToString();
  478. param["GroupID"] = GroupID.ToString();
  479. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param);
  480. List<GroupRolesData> Roles = new List<GroupRolesData>();
  481. if (respData.Contains("error"))
  482. {
  483. return Roles;
  484. }
  485. foreach (Hashtable role in respData.Values)
  486. {
  487. GroupRolesData data = new GroupRolesData();
  488. data.RoleID = new UUID((string)role["RoleID"]);
  489. data.Name = (string)role["Name"];
  490. data.Description = (string)role["Description"];
  491. data.Powers = ulong.Parse((string)role["Powers"]);
  492. data.Title = (string)role["Title"];
  493. Roles.Add(data);
  494. }
  495. return Roles;
  496. }
  497. public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID)
  498. {
  499. Hashtable param = new Hashtable();
  500. param["GroupID"] = GroupID.ToString();
  501. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoles", param);
  502. List<GroupRolesData> Roles = new List<GroupRolesData>();
  503. if (respData.Contains("error"))
  504. {
  505. return Roles;
  506. }
  507. foreach (Hashtable role in respData.Values)
  508. {
  509. GroupRolesData data = new GroupRolesData();
  510. data.Description = (string)role["Description"];
  511. data.Members = int.Parse((string)role["Members"]);
  512. data.Name = (string)role["Name"];
  513. data.Powers = ulong.Parse((string)role["Powers"]);
  514. data.RoleID = new UUID((string)role["RoleID"]);
  515. data.Title = (string)role["Title"];
  516. Roles.Add(data);
  517. }
  518. return Roles;
  519. }
  520. public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
  521. {
  522. Hashtable param = new Hashtable();
  523. param["GroupID"] = GroupID.ToString();
  524. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupMembers", param);
  525. List<GroupMembersData> members = new List<GroupMembersData>();
  526. if (respData.Contains("error"))
  527. {
  528. return members;
  529. }
  530. foreach (Hashtable membership in respData.Values)
  531. {
  532. GroupMembersData data = new GroupMembersData();
  533. data.AcceptNotices = ((string)membership["AcceptNotices"]) == "1";
  534. data.AgentID = new UUID((string)membership["AgentID"]);
  535. data.Contribution = int.Parse((string)membership["Contribution"]);
  536. data.IsOwner = ((string)membership["IsOwner"]) == "1";
  537. data.ListInProfile = ((string)membership["ListInProfile"]) == "1";
  538. data.AgentPowers = ulong.Parse((string)membership["AgentPowers"]);
  539. data.Title = (string)membership["Title"];
  540. members.Add(data);
  541. }
  542. return members;
  543. }
  544. public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
  545. {
  546. Hashtable param = new Hashtable();
  547. param["GroupID"] = GroupID.ToString();
  548. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param);
  549. List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
  550. if (!respData.Contains("error"))
  551. {
  552. foreach (Hashtable membership in respData.Values)
  553. {
  554. GroupRoleMembersData data = new GroupRoleMembersData();
  555. data.MemberID = new UUID((string)membership["AgentID"]);
  556. data.RoleID = new UUID((string)membership["RoleID"]);
  557. members.Add(data);
  558. }
  559. }
  560. return members;
  561. }
  562. public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
  563. {
  564. Hashtable param = new Hashtable();
  565. param["GroupID"] = GroupID.ToString();
  566. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param);
  567. List<GroupNoticeData> values = new List<GroupNoticeData>();
  568. if (!respData.Contains("error"))
  569. {
  570. foreach (Hashtable value in respData.Values)
  571. {
  572. GroupNoticeData data = new GroupNoticeData();
  573. data.NoticeID = UUID.Parse((string)value["NoticeID"]);
  574. data.Timestamp = uint.Parse((string)value["Timestamp"]);
  575. data.FromName = (string)value["FromName"];
  576. data.Subject = (string)value["Subject"];
  577. data.HasAttachment = false;
  578. data.AssetType = 0;
  579. values.Add(data);
  580. }
  581. }
  582. return values;
  583. }
  584. public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
  585. {
  586. Hashtable param = new Hashtable();
  587. param["NoticeID"] = noticeID.ToString();
  588. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param);
  589. if (respData.Contains("error"))
  590. {
  591. return null;
  592. }
  593. GroupNoticeInfo data = new GroupNoticeInfo();
  594. data.GroupID = UUID.Parse((string)respData["GroupID"]);
  595. data.Message = (string)respData["Message"];
  596. data.BinaryBucket = Utils.HexStringToBytes((string)respData["BinaryBucket"], true);
  597. data.noticeData.NoticeID = UUID.Parse((string)respData["NoticeID"]);
  598. data.noticeData.Timestamp = uint.Parse((string)respData["Timestamp"]);
  599. data.noticeData.FromName = (string)respData["FromName"];
  600. data.noticeData.Subject = (string)respData["Subject"];
  601. data.noticeData.HasAttachment = false;
  602. data.noticeData.AssetType = 0;
  603. if (data.Message == null)
  604. {
  605. data.Message = string.Empty;
  606. }
  607. return data;
  608. }
  609. public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
  610. {
  611. string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");
  612. Hashtable param = new Hashtable();
  613. param["GroupID"] = groupID.ToString();
  614. param["NoticeID"] = noticeID.ToString();
  615. param["FromName"] = fromName;
  616. param["Subject"] = subject;
  617. param["Message"] = message;
  618. param["BinaryBucket"] = binBucket;
  619. param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
  620. XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param);
  621. }
  622. #endregion
  623. #region GroupSessionTracking
  624. public void ResetAgentGroupChatSessions(UUID agentID)
  625. {
  626. foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
  627. {
  628. agentList.Remove(agentID);
  629. }
  630. }
  631. public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
  632. {
  633. // If we're tracking this group, and we can find them in the tracking, then they've been invited
  634. return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
  635. && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
  636. }
  637. public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
  638. {
  639. // If we're tracking drops for this group,
  640. // and we find them, well... then they've dropped
  641. return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
  642. && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
  643. }
  644. public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
  645. {
  646. if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
  647. {
  648. if (m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID))
  649. m_groupsAgentsInvitedToChatSession[groupID].Remove(agentID);
  650. // If not in dropped list, add
  651. if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
  652. m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
  653. }
  654. }
  655. public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
  656. {
  657. // Add Session Status if it doesn't exist for this session
  658. CreateGroupChatSessionTracking(groupID);
  659. // If nessesary, remove from dropped list
  660. if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
  661. m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
  662. if (!m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID))
  663. m_groupsAgentsInvitedToChatSession[groupID].Add(agentID);
  664. }
  665. private void CreateGroupChatSessionTracking(UUID groupID)
  666. {
  667. if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
  668. {
  669. m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
  670. m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
  671. }
  672. }
  673. #endregion
  674. #region XmlRpcHashtableMarshalling
  675. private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile)
  676. {
  677. GroupProfileData group = new GroupProfileData();
  678. group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
  679. group.Name = (string)groupProfile["Name"];
  680. if (groupProfile["Charter"] != null)
  681. {
  682. group.Charter = (string)groupProfile["Charter"];
  683. }
  684. group.ShowInList = ((string)groupProfile["ShowInList"]) == "1";
  685. group.InsigniaID = UUID.Parse((string)groupProfile["InsigniaID"]);
  686. group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]);
  687. group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1";
  688. group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1";
  689. group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1";
  690. group.FounderID = UUID.Parse((string)groupProfile["FounderID"]);
  691. group.OwnerRole = UUID.Parse((string)groupProfile["OwnerRoleID"]);
  692. group.GroupMembershipCount = int.Parse((string)groupProfile["GroupMembershipCount"]);
  693. group.GroupRolesCount = int.Parse((string)groupProfile["GroupRolesCount"]);
  694. return group;
  695. }
  696. private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
  697. {
  698. GroupRecord group = new GroupRecord();
  699. group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
  700. group.GroupName = groupProfile["Name"].ToString();
  701. if (groupProfile["Charter"] != null)
  702. {
  703. group.Charter = (string)groupProfile["Charter"];
  704. }
  705. group.ShowInList = ((string)groupProfile["ShowInList"]) == "1";
  706. group.GroupPicture = UUID.Parse((string)groupProfile["InsigniaID"]);
  707. group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]);
  708. group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1";
  709. group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1";
  710. group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1";
  711. group.FounderID = UUID.Parse((string)groupProfile["FounderID"]);
  712. group.OwnerRoleID = UUID.Parse((string)groupProfile["OwnerRoleID"]);
  713. return group;
  714. }
  715. private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
  716. {
  717. GroupMembershipData data = new GroupMembershipData();
  718. data.AcceptNotices = ((string)respData["AcceptNotices"] == "1");
  719. data.Contribution = int.Parse((string)respData["Contribution"]);
  720. data.ListInProfile = ((string)respData["ListInProfile"] == "1");
  721. data.ActiveRole = new UUID((string)respData["SelectedRoleID"]);
  722. data.GroupTitle = (string)respData["Title"];
  723. data.GroupPowers = ulong.Parse((string)respData["GroupPowers"]);
  724. // Is this group the agent's active group
  725. data.GroupID = new UUID((string)respData["GroupID"]);
  726. UUID ActiveGroup = new UUID((string)respData["ActiveGroupID"]);
  727. data.Active = data.GroupID.Equals(ActiveGroup);
  728. data.AllowPublish = ((string)respData["AllowPublish"] == "1");
  729. if (respData["Charter"] != null)
  730. {
  731. data.Charter = (string)respData["Charter"];
  732. }
  733. data.FounderID = new UUID((string)respData["FounderID"]);
  734. data.GroupID = new UUID((string)respData["GroupID"]);
  735. data.GroupName = (string)respData["GroupName"];
  736. data.GroupPicture = new UUID((string)respData["InsigniaID"]);
  737. data.MaturePublish = ((string)respData["MaturePublish"] == "1");
  738. data.MembershipFee = int.Parse((string)respData["MembershipFee"]);
  739. data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1");
  740. data.ShowInList = ((string)respData["ShowInList"] == "1");
  741. return data;
  742. }
  743. #endregion
  744. /// <summary>
  745. /// Encapsulate the XmlRpc call to standardize security and error handling.
  746. /// </summary>
  747. private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
  748. {
  749. XmlRpcResponse resp = null;
  750. string CacheKey = null;
  751. // Only bother with the cache if it isn't disabled.
  752. if (m_cacheTimeout > 0)
  753. {
  754. if (!function.StartsWith("groups.get"))
  755. {
  756. // Any and all updates cause the cache to clear
  757. m_memoryCache.Clear();
  758. }
  759. else
  760. {
  761. StringBuilder sb = new StringBuilder(requestingAgentID + function);
  762. foreach (object key in param.Keys)
  763. {
  764. if (param[key] != null)
  765. {
  766. sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString());
  767. }
  768. }
  769. CacheKey = sb.ToString();
  770. m_memoryCache.TryGetValue(CacheKey, out resp);
  771. }
  772. }
  773. if (resp == null)
  774. {
  775. if (m_debugEnabled)
  776. m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Cache miss for key {0}", CacheKey);
  777. string UserService;
  778. UUID SessionID;
  779. GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
  780. param.Add("RequestingAgentID", requestingAgentID.ToString());
  781. param.Add("RequestingAgentUserService", UserService);
  782. param.Add("RequestingSessionID", SessionID.ToString());
  783. param.Add("ReadKey", m_groupReadKey);
  784. param.Add("WriteKey", m_groupWriteKey);
  785. IList parameters = new ArrayList();
  786. parameters.Add(param);
  787. ConfigurableKeepAliveXmlRpcRequest req;
  788. req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
  789. try
  790. {
  791. resp = req.Send(m_groupsServerURI);
  792. }
  793. catch (Exception e)
  794. {
  795. m_log.ErrorFormat(
  796. "[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method {0} at {1}: {2}",
  797. function, m_groupsServerURI, e.Message);
  798. if(m_debugEnabled)
  799. {
  800. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", e.StackTrace);
  801. foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
  802. {
  803. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine);
  804. }
  805. foreach (string key in param.Keys)
  806. {
  807. m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString());
  808. }
  809. }
  810. if ((m_cacheTimeout > 0) && (CacheKey != null))
  811. {
  812. m_memoryCache.AddOrUpdate(CacheKey, resp, 10.0);
  813. }
  814. Hashtable respData = new Hashtable();
  815. respData.Add("error", e.ToString());
  816. return respData;
  817. }
  818. if ((m_cacheTimeout > 0) && (CacheKey != null))
  819. {
  820. m_memoryCache.AddOrUpdate(CacheKey, resp, 10.0);
  821. }
  822. }
  823. if (resp.Value is Hashtable)
  824. {
  825. Hashtable respData = (Hashtable)resp.Value;
  826. if (respData.Contains("error") && !respData.Contains("succeed"))
  827. {
  828. LogRespDataToConsoleError(requestingAgentID, function, param, respData);
  829. }
  830. return respData;
  831. }
  832. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString());
  833. if (resp.Value is ArrayList)
  834. {
  835. ArrayList al = (ArrayList)resp.Value;
  836. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count);
  837. foreach (object o in al)
  838. {
  839. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString());
  840. }
  841. }
  842. else
  843. {
  844. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString());
  845. }
  846. Hashtable error = new Hashtable();
  847. error.Add("error", "invalid return value");
  848. return error;
  849. }
  850. private void LogRespDataToConsoleError(UUID requestingAgentID, string function, Hashtable param, Hashtable respData)
  851. {
  852. m_log.ErrorFormat(
  853. "[XMLRPC-GROUPS-CONNECTOR]: Error when calling {0} for {1} with params {2}. Response params are {3}",
  854. function, requestingAgentID, Util.PrettyFormatToSingleLine(param), Util.PrettyFormatToSingleLine(respData));
  855. }
  856. /// <summary>
  857. /// Group Request Tokens are an attempt to allow the groups service to authenticate
  858. /// requests.
  859. /// TODO: This broke after the big grid refactor, either find a better way, or discard this
  860. /// </summary>
  861. /// <param name="client"></param>
  862. /// <returns></returns>
  863. private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
  864. {
  865. UserServiceURL = "";
  866. SessionID = UUID.Zero;
  867. // Need to rework this based on changes to User Services
  868. /*
  869. UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID);
  870. if (userAccount == null)
  871. {
  872. // This should be impossible. If I've been passed a reference to a client
  873. // that client should be registered with the UserService. So something
  874. // is horribly wrong somewhere.
  875. m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID);
  876. }
  877. else if (userProfile is ForeignUserProfileData)
  878. {
  879. // They aren't from around here
  880. ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
  881. UserServiceURL = fupd.UserServerURI;
  882. SessionID = fupd.CurrentAgent.SessionID;
  883. }
  884. else
  885. {
  886. // They're a local user, use this:
  887. UserServiceURL = m_commManager.NetworkServersInfo.UserURL;
  888. SessionID = userProfile.CurrentAgent.SessionID;
  889. }
  890. */
  891. }
  892. }
  893. }
  894. namespace Nwc.XmlRpc
  895. {
  896. using System;
  897. using System.Collections;
  898. using System.IO;
  899. using System.Xml;
  900. using System.Net;
  901. using System.Text;
  902. using System.Reflection;
  903. /// <summary>Class supporting the request side of an XML-RPC transaction.</summary>
  904. public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest
  905. {
  906. private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
  907. private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
  908. private bool _disableKeepAlive = true;
  909. public string RequestResponse = String.Empty;
  910. /// <summary>Instantiate an <c>XmlRpcRequest</c> for a specified method and parameters.</summary>
  911. /// <param name="methodName"><c>String</c> designating the <i>object.method</i> on the server the request
  912. /// should be directed to.</param>
  913. /// <param name="parameters"><c>ArrayList</c> of XML-RPC type parameters to invoke the request with.</param>
  914. public ConfigurableKeepAliveXmlRpcRequest(String methodName, IList parameters, bool disableKeepAlive)
  915. {
  916. MethodName = methodName;
  917. _params = parameters;
  918. _disableKeepAlive = disableKeepAlive;
  919. }
  920. /// <summary>Send the request to the server.</summary>
  921. /// <param name="url"><c>String</c> The url of the XML-RPC server.</param>
  922. /// <returns><c>XmlRpcResponse</c> The response generated.</returns>
  923. public XmlRpcResponse Send(String url)
  924. {
  925. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  926. if (request == null)
  927. throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR,
  928. XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url);
  929. request.Method = "POST";
  930. request.ContentType = "text/xml";
  931. request.AllowWriteStreamBuffering = true;
  932. request.KeepAlive = !_disableKeepAlive;
  933. request.Timeout = 30000;
  934. using (Stream stream = request.GetRequestStream())
  935. {
  936. using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII))
  937. {
  938. _serializer.Serialize(xml, this);
  939. xml.Flush();
  940. }
  941. }
  942. XmlRpcResponse resp;
  943. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  944. {
  945. using (Stream s = response.GetResponseStream())
  946. {
  947. using (StreamReader input = new StreamReader(s))
  948. {
  949. string inputXml = input.ReadToEnd();
  950. try
  951. {
  952. resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
  953. }
  954. catch (Exception e)
  955. {
  956. RequestResponse = inputXml;
  957. throw e;
  958. }
  959. }
  960. }
  961. }
  962. return resp;
  963. }
  964. }
  965. }