XmlRpcGroupsServicesConnectorModule.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  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. if(membership.ContainsKey("OnlineStatus"))
  541. data.OnlineStatus = (string)membership["OnlineStatus"];
  542. members.Add(data);
  543. }
  544. return members;
  545. }
  546. public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
  547. {
  548. Hashtable param = new Hashtable();
  549. param["GroupID"] = GroupID.ToString();
  550. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param);
  551. List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
  552. if (!respData.Contains("error"))
  553. {
  554. foreach (Hashtable membership in respData.Values)
  555. {
  556. GroupRoleMembersData data = new GroupRoleMembersData();
  557. data.MemberID = new UUID((string)membership["AgentID"]);
  558. data.RoleID = new UUID((string)membership["RoleID"]);
  559. members.Add(data);
  560. }
  561. }
  562. return members;
  563. }
  564. public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
  565. {
  566. Hashtable param = new Hashtable();
  567. param["GroupID"] = GroupID.ToString();
  568. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param);
  569. List<GroupNoticeData> values = new List<GroupNoticeData>();
  570. if (!respData.Contains("error"))
  571. {
  572. foreach (Hashtable value in respData.Values)
  573. {
  574. GroupNoticeData data = new GroupNoticeData();
  575. data.NoticeID = UUID.Parse((string)value["NoticeID"]);
  576. data.Timestamp = uint.Parse((string)value["Timestamp"]);
  577. data.FromName = (string)value["FromName"];
  578. data.Subject = (string)value["Subject"];
  579. data.HasAttachment = false;
  580. data.AssetType = 0;
  581. values.Add(data);
  582. }
  583. }
  584. return values;
  585. }
  586. public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
  587. {
  588. Hashtable param = new Hashtable();
  589. param["NoticeID"] = noticeID.ToString();
  590. Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param);
  591. if (respData.Contains("error"))
  592. {
  593. return null;
  594. }
  595. GroupNoticeInfo data = new GroupNoticeInfo();
  596. data.GroupID = UUID.Parse((string)respData["GroupID"]);
  597. data.Message = (string)respData["Message"];
  598. data.BinaryBucket = Utils.HexStringToBytes((string)respData["BinaryBucket"], true);
  599. data.noticeData.NoticeID = UUID.Parse((string)respData["NoticeID"]);
  600. data.noticeData.Timestamp = uint.Parse((string)respData["Timestamp"]);
  601. data.noticeData.FromName = (string)respData["FromName"];
  602. data.noticeData.Subject = (string)respData["Subject"];
  603. data.noticeData.HasAttachment = false;
  604. data.noticeData.AssetType = 0;
  605. if (data.Message == null)
  606. {
  607. data.Message = string.Empty;
  608. }
  609. return data;
  610. }
  611. public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
  612. {
  613. string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");
  614. Hashtable param = new Hashtable();
  615. param["GroupID"] = groupID.ToString();
  616. param["NoticeID"] = noticeID.ToString();
  617. param["FromName"] = fromName;
  618. param["Subject"] = subject;
  619. param["Message"] = message;
  620. param["BinaryBucket"] = binBucket;
  621. param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
  622. XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param);
  623. }
  624. #endregion
  625. #region GroupSessionTracking
  626. public void ResetAgentGroupChatSessions(UUID agentID)
  627. {
  628. foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
  629. {
  630. agentList.Remove(agentID);
  631. }
  632. }
  633. public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
  634. {
  635. // If we're tracking this group, and we can find them in the tracking, then they've been invited
  636. return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
  637. && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
  638. }
  639. public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
  640. {
  641. // If we're tracking drops for this group,
  642. // and we find them, well... then they've dropped
  643. return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
  644. && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
  645. }
  646. public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
  647. {
  648. if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
  649. {
  650. if (m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID))
  651. m_groupsAgentsInvitedToChatSession[groupID].Remove(agentID);
  652. // If not in dropped list, add
  653. if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
  654. m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
  655. }
  656. }
  657. public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
  658. {
  659. // Add Session Status if it doesn't exist for this session
  660. CreateGroupChatSessionTracking(groupID);
  661. // If nessesary, remove from dropped list
  662. if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
  663. m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
  664. if (!m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID))
  665. m_groupsAgentsInvitedToChatSession[groupID].Add(agentID);
  666. }
  667. private void CreateGroupChatSessionTracking(UUID groupID)
  668. {
  669. if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
  670. {
  671. m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
  672. m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
  673. }
  674. }
  675. #endregion
  676. #region XmlRpcHashtableMarshalling
  677. private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile)
  678. {
  679. GroupProfileData group = new GroupProfileData();
  680. group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
  681. group.Name = (string)groupProfile["Name"];
  682. if (groupProfile["Charter"] != null)
  683. {
  684. group.Charter = (string)groupProfile["Charter"];
  685. }
  686. group.ShowInList = ((string)groupProfile["ShowInList"]) == "1";
  687. group.InsigniaID = UUID.Parse((string)groupProfile["InsigniaID"]);
  688. group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]);
  689. group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1";
  690. group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1";
  691. group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1";
  692. group.FounderID = UUID.Parse((string)groupProfile["FounderID"]);
  693. group.OwnerRole = UUID.Parse((string)groupProfile["OwnerRoleID"]);
  694. group.GroupMembershipCount = int.Parse((string)groupProfile["GroupMembershipCount"]);
  695. group.GroupRolesCount = int.Parse((string)groupProfile["GroupRolesCount"]);
  696. return group;
  697. }
  698. private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
  699. {
  700. GroupRecord group = new GroupRecord();
  701. group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
  702. group.GroupName = groupProfile["Name"].ToString();
  703. if (groupProfile["Charter"] != null)
  704. {
  705. group.Charter = (string)groupProfile["Charter"];
  706. }
  707. group.ShowInList = ((string)groupProfile["ShowInList"]) == "1";
  708. group.GroupPicture = UUID.Parse((string)groupProfile["InsigniaID"]);
  709. group.MembershipFee = int.Parse((string)groupProfile["MembershipFee"]);
  710. group.OpenEnrollment = ((string)groupProfile["OpenEnrollment"]) == "1";
  711. group.AllowPublish = ((string)groupProfile["AllowPublish"]) == "1";
  712. group.MaturePublish = ((string)groupProfile["MaturePublish"]) == "1";
  713. group.FounderID = UUID.Parse((string)groupProfile["FounderID"]);
  714. group.OwnerRoleID = UUID.Parse((string)groupProfile["OwnerRoleID"]);
  715. return group;
  716. }
  717. private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
  718. {
  719. GroupMembershipData data = new GroupMembershipData();
  720. data.AcceptNotices = ((string)respData["AcceptNotices"] == "1");
  721. data.Contribution = int.Parse((string)respData["Contribution"]);
  722. data.ListInProfile = ((string)respData["ListInProfile"] == "1");
  723. data.ActiveRole = new UUID((string)respData["SelectedRoleID"]);
  724. data.GroupTitle = (string)respData["Title"];
  725. data.GroupPowers = ulong.Parse((string)respData["GroupPowers"]);
  726. // Is this group the agent's active group
  727. data.GroupID = new UUID((string)respData["GroupID"]);
  728. UUID ActiveGroup = new UUID((string)respData["ActiveGroupID"]);
  729. data.Active = data.GroupID.Equals(ActiveGroup);
  730. data.AllowPublish = ((string)respData["AllowPublish"] == "1");
  731. if (respData["Charter"] != null)
  732. {
  733. data.Charter = (string)respData["Charter"];
  734. }
  735. data.FounderID = new UUID((string)respData["FounderID"]);
  736. data.GroupID = new UUID((string)respData["GroupID"]);
  737. data.GroupName = (string)respData["GroupName"];
  738. data.GroupPicture = new UUID((string)respData["InsigniaID"]);
  739. data.MaturePublish = ((string)respData["MaturePublish"] == "1");
  740. data.MembershipFee = int.Parse((string)respData["MembershipFee"]);
  741. data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1");
  742. data.ShowInList = ((string)respData["ShowInList"] == "1");
  743. return data;
  744. }
  745. #endregion
  746. /// <summary>
  747. /// Encapsulate the XmlRpc call to standardize security and error handling.
  748. /// </summary>
  749. private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
  750. {
  751. XmlRpcResponse resp = null;
  752. string CacheKey = null;
  753. // Only bother with the cache if it isn't disabled.
  754. if (m_cacheTimeout > 0)
  755. {
  756. if (!function.StartsWith("groups.get"))
  757. {
  758. // Any and all updates cause the cache to clear
  759. m_memoryCache.Clear();
  760. }
  761. else
  762. {
  763. StringBuilder sb = new StringBuilder(requestingAgentID + function);
  764. foreach (object key in param.Keys)
  765. {
  766. if (param[key] != null)
  767. {
  768. sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString());
  769. }
  770. }
  771. CacheKey = sb.ToString();
  772. m_memoryCache.TryGetValue(CacheKey, out resp);
  773. }
  774. }
  775. if (resp == null)
  776. {
  777. if (m_debugEnabled)
  778. m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Cache miss for key {0}", CacheKey);
  779. string UserService;
  780. UUID SessionID;
  781. GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
  782. param.Add("RequestingAgentID", requestingAgentID.ToString());
  783. param.Add("RequestingAgentUserService", UserService);
  784. param.Add("RequestingSessionID", SessionID.ToString());
  785. param.Add("ReadKey", m_groupReadKey);
  786. param.Add("WriteKey", m_groupWriteKey);
  787. IList parameters = new ArrayList();
  788. parameters.Add(param);
  789. ConfigurableKeepAliveXmlRpcRequest req;
  790. req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
  791. try
  792. {
  793. resp = req.Send(m_groupsServerURI);
  794. }
  795. catch (Exception e)
  796. {
  797. m_log.ErrorFormat(
  798. "[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method {0} at {1}: {2}",
  799. function, m_groupsServerURI, e.Message);
  800. if(m_debugEnabled)
  801. {
  802. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", e.StackTrace);
  803. foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
  804. {
  805. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine);
  806. }
  807. foreach (string key in param.Keys)
  808. {
  809. m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString());
  810. }
  811. }
  812. if ((m_cacheTimeout > 0) && (CacheKey != null))
  813. {
  814. m_memoryCache.AddOrUpdate(CacheKey, resp, 10.0);
  815. }
  816. Hashtable respData = new Hashtable();
  817. respData.Add("error", e.ToString());
  818. return respData;
  819. }
  820. if ((m_cacheTimeout > 0) && (CacheKey != null))
  821. {
  822. m_memoryCache.AddOrUpdate(CacheKey, resp, 10.0);
  823. }
  824. }
  825. if (resp.Value is Hashtable)
  826. {
  827. Hashtable respData = (Hashtable)resp.Value;
  828. if (respData.Contains("error") && !respData.Contains("succeed"))
  829. {
  830. LogRespDataToConsoleError(requestingAgentID, function, param, respData);
  831. }
  832. return respData;
  833. }
  834. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString());
  835. if (resp.Value is ArrayList)
  836. {
  837. ArrayList al = (ArrayList)resp.Value;
  838. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count);
  839. foreach (object o in al)
  840. {
  841. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString());
  842. }
  843. }
  844. else
  845. {
  846. m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString());
  847. }
  848. Hashtable error = new Hashtable();
  849. error.Add("error", "invalid return value");
  850. return error;
  851. }
  852. private void LogRespDataToConsoleError(UUID requestingAgentID, string function, Hashtable param, Hashtable respData)
  853. {
  854. m_log.ErrorFormat(
  855. "[XMLRPC-GROUPS-CONNECTOR]: Error when calling {0} for {1} with params {2}. Response params are {3}",
  856. function, requestingAgentID, Util.PrettyFormatToSingleLine(param), Util.PrettyFormatToSingleLine(respData));
  857. }
  858. /// <summary>
  859. /// Group Request Tokens are an attempt to allow the groups service to authenticate
  860. /// requests.
  861. /// TODO: This broke after the big grid refactor, either find a better way, or discard this
  862. /// </summary>
  863. /// <param name="client"></param>
  864. /// <returns></returns>
  865. private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
  866. {
  867. UserServiceURL = "";
  868. SessionID = UUID.Zero;
  869. // Need to rework this based on changes to User Services
  870. /*
  871. UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID);
  872. if (userAccount == null)
  873. {
  874. // This should be impossible. If I've been passed a reference to a client
  875. // that client should be registered with the UserService. So something
  876. // is horribly wrong somewhere.
  877. m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID);
  878. }
  879. else if (userProfile is ForeignUserProfileData)
  880. {
  881. // They aren't from around here
  882. ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
  883. UserServiceURL = fupd.UserServerURI;
  884. SessionID = fupd.CurrentAgent.SessionID;
  885. }
  886. else
  887. {
  888. // They're a local user, use this:
  889. UserServiceURL = m_commManager.NetworkServersInfo.UserURL;
  890. SessionID = userProfile.CurrentAgent.SessionID;
  891. }
  892. */
  893. }
  894. }
  895. }
  896. namespace Nwc.XmlRpc
  897. {
  898. using System;
  899. using System.Collections;
  900. using System.IO;
  901. using System.Xml;
  902. using System.Net;
  903. using System.Text;
  904. using System.Reflection;
  905. /// <summary>Class supporting the request side of an XML-RPC transaction.</summary>
  906. public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest
  907. {
  908. private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
  909. private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
  910. private bool _disableKeepAlive = true;
  911. public string RequestResponse = String.Empty;
  912. /// <summary>Instantiate an <c>XmlRpcRequest</c> for a specified method and parameters.</summary>
  913. /// <param name="methodName"><c>String</c> designating the <i>object.method</i> on the server the request
  914. /// should be directed to.</param>
  915. /// <param name="parameters"><c>ArrayList</c> of XML-RPC type parameters to invoke the request with.</param>
  916. public ConfigurableKeepAliveXmlRpcRequest(String methodName, IList parameters, bool disableKeepAlive)
  917. {
  918. MethodName = methodName;
  919. _params = parameters;
  920. _disableKeepAlive = disableKeepAlive;
  921. }
  922. /// <summary>Send the request to the server.</summary>
  923. /// <param name="url"><c>String</c> The url of the XML-RPC server.</param>
  924. /// <returns><c>XmlRpcResponse</c> The response generated.</returns>
  925. public XmlRpcResponse Send(String url)
  926. {
  927. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  928. if (request == null)
  929. throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR,
  930. XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url);
  931. request.Method = "POST";
  932. request.ContentType = "text/xml";
  933. request.AllowWriteStreamBuffering = true;
  934. request.KeepAlive = !_disableKeepAlive;
  935. request.Timeout = 30000;
  936. using (Stream stream = request.GetRequestStream())
  937. {
  938. using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII))
  939. {
  940. _serializer.Serialize(xml, this);
  941. xml.Flush();
  942. }
  943. }
  944. XmlRpcResponse resp;
  945. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  946. {
  947. using (Stream s = response.GetResponseStream())
  948. {
  949. using (StreamReader input = new StreamReader(s))
  950. {
  951. string inputXml = input.ReadToEnd();
  952. try
  953. {
  954. resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
  955. }
  956. catch (Exception e)
  957. {
  958. RequestResponse = inputXml;
  959. throw e;
  960. }
  961. }
  962. }
  963. }
  964. return resp;
  965. }
  966. }
  967. }