1
0

GroupsServiceRemoteConnector.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  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.Generic;
  29. using System.Linq;
  30. using System.Reflection;
  31. using System.Text;
  32. using OpenSim.Framework;
  33. using OpenSim.Server.Base;
  34. using OpenMetaverse;
  35. using log4net;
  36. namespace OpenSim.Groups
  37. {
  38. public class GroupsServiceRemoteConnector
  39. {
  40. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  41. private string m_ServerURI;
  42. private object m_Lock = new object();
  43. public GroupsServiceRemoteConnector(string url)
  44. {
  45. m_ServerURI = url;
  46. if (!m_ServerURI.EndsWith("/"))
  47. m_ServerURI += "/";
  48. m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}", m_ServerURI);
  49. }
  50. public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment,
  51. bool allowPublish, bool maturePublish, UUID founderID, out string reason)
  52. {
  53. reason = string.Empty;
  54. ExtendedGroupRecord rec = new ExtendedGroupRecord();
  55. rec.AllowPublish = allowPublish;
  56. rec.Charter = charter;
  57. rec.FounderID = founderID;
  58. rec.GroupName = name;
  59. rec.GroupPicture = insigniaID;
  60. rec.MaturePublish = maturePublish;
  61. rec.MembershipFee = membershipFee;
  62. rec.OpenEnrollment = openEnrollment;
  63. rec.ShowInList = showInList;
  64. Dictionary<string, object> sendData = GroupsDataUtils.GroupRecord(rec);
  65. sendData["RequestingAgentID"] = RequestingAgentID;
  66. sendData["OP"] = "ADD";
  67. Dictionary<string, object> ret = MakeRequest("PUTGROUP", sendData);
  68. if (ret == null)
  69. return null;
  70. if (ret["RESULT"].ToString() == "NULL")
  71. {
  72. reason = ret["REASON"].ToString();
  73. return null;
  74. }
  75. return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
  76. }
  77. public ExtendedGroupRecord UpdateGroup(string RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
  78. {
  79. ExtendedGroupRecord rec = new ExtendedGroupRecord();
  80. rec.AllowPublish = allowPublish;
  81. rec.Charter = charter;
  82. rec.GroupPicture = insigniaID;
  83. rec.MaturePublish = maturePublish;
  84. rec.GroupID = groupID;
  85. rec.MembershipFee = membershipFee;
  86. rec.OpenEnrollment = openEnrollment;
  87. rec.ShowInList = showInList;
  88. Dictionary<string, object> sendData = GroupsDataUtils.GroupRecord(rec);
  89. sendData["RequestingAgentID"] = RequestingAgentID;
  90. sendData["OP"] = "UPDATE";
  91. Dictionary<string, object> ret = MakeRequest("PUTGROUP", sendData);
  92. if (ret == null || (ret != null && (!ret.ContainsKey("RESULT") || ret["RESULT"].ToString() == "NULL")))
  93. return null;
  94. return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
  95. }
  96. public ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string GroupName)
  97. {
  98. if (GroupID == UUID.Zero && (GroupName == null || (GroupName != null && GroupName == string.Empty)))
  99. return null;
  100. Dictionary<string, object> sendData = new Dictionary<string, object>();
  101. if (GroupID != UUID.Zero)
  102. sendData["GroupID"] = GroupID.ToString();
  103. if (!string.IsNullOrEmpty(GroupName))
  104. sendData["Name"] = GroupsDataUtils.Sanitize(GroupName);
  105. sendData["RequestingAgentID"] = RequestingAgentID;
  106. Dictionary<string, object> ret = MakeRequest("GETGROUP", sendData);
  107. if (ret == null || (ret != null && (!ret.ContainsKey("RESULT") || ret["RESULT"].ToString() == "NULL")))
  108. return null;
  109. return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
  110. }
  111. public List<DirGroupsReplyData> FindGroups(string RequestingAgentID, string query)
  112. {
  113. List<DirGroupsReplyData> hits = new List<DirGroupsReplyData>();
  114. if (string.IsNullOrEmpty(query))
  115. return hits;
  116. Dictionary<string, object> sendData = new Dictionary<string, object>();
  117. sendData["Query"] = query;
  118. sendData["RequestingAgentID"] = RequestingAgentID;
  119. Dictionary<string, object> ret = MakeRequest("FINDGROUPS", sendData);
  120. if (ret == null)
  121. return hits;
  122. if (!ret.ContainsKey("RESULT"))
  123. return hits;
  124. if (ret["RESULT"].ToString() == "NULL")
  125. return hits;
  126. foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
  127. {
  128. DirGroupsReplyData m = GroupsDataUtils.DirGroupsReplyData((Dictionary<string, object>)v);
  129. hits.Add(m);
  130. }
  131. return hits;
  132. }
  133. public GroupMembershipData AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
  134. {
  135. reason = string.Empty;
  136. Dictionary<string, object> sendData = new Dictionary<string,object>();
  137. sendData["AgentID"] = AgentID;
  138. sendData["GroupID"] = GroupID.ToString();
  139. sendData["RoleID"] = RoleID.ToString();
  140. sendData["RequestingAgentID"] = RequestingAgentID;
  141. sendData["AccessToken"] = token;
  142. Dictionary<string, object> ret = MakeRequest("ADDAGENTTOGROUP", sendData);
  143. if (ret == null)
  144. return null;
  145. if (!ret.ContainsKey("RESULT"))
  146. return null;
  147. if (ret["RESULT"].ToString() == "NULL")
  148. {
  149. reason = ret["REASON"].ToString();
  150. return null;
  151. }
  152. return GroupsDataUtils.GroupMembershipData((Dictionary<string, object>)ret["RESULT"]);
  153. }
  154. public void RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID)
  155. {
  156. Dictionary<string, object> sendData = new Dictionary<string, object>();
  157. sendData["AgentID"] = AgentID;
  158. sendData["GroupID"] = GroupID.ToString();
  159. sendData["RequestingAgentID"] = RequestingAgentID;
  160. MakeRequest("REMOVEAGENTFROMGROUP", sendData);
  161. }
  162. public ExtendedGroupMembershipData GetMembership(string RequestingAgentID, string AgentID, UUID GroupID)
  163. {
  164. Dictionary<string, object> sendData = new Dictionary<string, object>();
  165. sendData["AgentID"] = AgentID;
  166. if (GroupID != UUID.Zero)
  167. sendData["GroupID"] = GroupID.ToString();
  168. sendData["RequestingAgentID"] = RequestingAgentID;
  169. Dictionary<string, object> ret = MakeRequest("GETMEMBERSHIP", sendData);
  170. if (ret == null)
  171. return null;
  172. if (!ret.ContainsKey("RESULT"))
  173. return null;
  174. if (ret["RESULT"].ToString() == "NULL")
  175. return null;
  176. return GroupsDataUtils.GroupMembershipData((Dictionary<string, object>)ret["RESULT"]);
  177. }
  178. public List<GroupMembershipData> GetMemberships(string RequestingAgentID, string AgentID)
  179. {
  180. List<GroupMembershipData> memberships = new List<GroupMembershipData>();
  181. Dictionary<string, object> sendData = new Dictionary<string, object>();
  182. sendData["AgentID"] = AgentID;
  183. sendData["ALL"] = "true";
  184. sendData["RequestingAgentID"] = RequestingAgentID;
  185. Dictionary<string, object> ret = MakeRequest("GETMEMBERSHIP", sendData);
  186. if (ret == null)
  187. return memberships;
  188. if (!ret.ContainsKey("RESULT"))
  189. return memberships;
  190. if (ret["RESULT"].ToString() == "NULL")
  191. return memberships;
  192. foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
  193. {
  194. GroupMembershipData m = GroupsDataUtils.GroupMembershipData((Dictionary<string, object>)v);
  195. memberships.Add(m);
  196. }
  197. return memberships;
  198. }
  199. public List<ExtendedGroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID)
  200. {
  201. List<ExtendedGroupMembersData> members = new List<ExtendedGroupMembersData>();
  202. Dictionary<string, object> sendData = new Dictionary<string, object>();
  203. sendData["GroupID"] = GroupID.ToString();
  204. sendData["RequestingAgentID"] = RequestingAgentID;
  205. Dictionary<string, object> ret = MakeRequest("GETGROUPMEMBERS", sendData);
  206. if (ret == null)
  207. return members;
  208. if (!ret.ContainsKey("RESULT"))
  209. return members;
  210. if (ret["RESULT"].ToString() == "NULL")
  211. return members;
  212. foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
  213. {
  214. ExtendedGroupMembersData m = GroupsDataUtils.GroupMembersData((Dictionary<string, object>)v);
  215. members.Add(m);
  216. }
  217. return members;
  218. }
  219. public bool AddGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, out string reason)
  220. {
  221. reason = string.Empty;
  222. Dictionary<string, object> sendData = new Dictionary<string, object>();
  223. sendData["GroupID"] = groupID.ToString();
  224. sendData["RoleID"] = roleID.ToString();
  225. sendData["Name"] = GroupsDataUtils.Sanitize(name);
  226. sendData["Description"] = GroupsDataUtils.Sanitize(description);
  227. sendData["Title"] = GroupsDataUtils.Sanitize(title);
  228. sendData["Powers"] = powers.ToString();
  229. sendData["RequestingAgentID"] = RequestingAgentID;
  230. sendData["OP"] = "ADD";
  231. Dictionary<string, object> ret = MakeRequest("PUTROLE", sendData);
  232. if (ret == null)
  233. return false;
  234. if (!ret.ContainsKey("RESULT"))
  235. return false;
  236. if (ret["RESULT"].ToString().ToLower() != "true")
  237. {
  238. reason = ret["REASON"].ToString();
  239. return false;
  240. }
  241. return true;
  242. }
  243. public bool UpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
  244. {
  245. Dictionary<string, object> sendData = new Dictionary<string, object>();
  246. sendData["GroupID"] = groupID.ToString();
  247. sendData["RoleID"] = roleID.ToString();
  248. sendData["Name"] = GroupsDataUtils.Sanitize(name);
  249. sendData["Description"] = GroupsDataUtils.Sanitize(description);
  250. sendData["Title"] = GroupsDataUtils.Sanitize(title);
  251. sendData["Powers"] = powers.ToString();
  252. sendData["RequestingAgentID"] = RequestingAgentID;
  253. sendData["OP"] = "UPDATE";
  254. Dictionary<string, object> ret = MakeRequest("PUTROLE", sendData);
  255. if (ret == null)
  256. return false;
  257. if (!ret.ContainsKey("RESULT"))
  258. return false;
  259. if (ret["RESULT"].ToString().ToLower() != "true")
  260. return false;
  261. return true;
  262. }
  263. public void RemoveGroupRole(string RequestingAgentID, UUID groupID, UUID roleID)
  264. {
  265. Dictionary<string, object> sendData = new Dictionary<string, object>();
  266. sendData["GroupID"] = groupID.ToString();
  267. sendData["RoleID"] = roleID.ToString();
  268. sendData["RequestingAgentID"] = RequestingAgentID;
  269. MakeRequest("REMOVEROLE", sendData);
  270. }
  271. public List<GroupRolesData> GetGroupRoles(string RequestingAgentID, UUID GroupID)
  272. {
  273. List<GroupRolesData> roles = new List<GroupRolesData>();
  274. Dictionary<string, object> sendData = new Dictionary<string, object>();
  275. sendData["GroupID"] = GroupID.ToString();
  276. sendData["RequestingAgentID"] = RequestingAgentID;
  277. Dictionary<string, object> ret = MakeRequest("GETGROUPROLES", sendData);
  278. if (ret == null)
  279. return roles;
  280. if (!ret.ContainsKey("RESULT"))
  281. return roles;
  282. if (ret["RESULT"].ToString() == "NULL")
  283. return roles;
  284. foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
  285. {
  286. GroupRolesData m = GroupsDataUtils.GroupRolesData((Dictionary<string, object>)v);
  287. roles.Add(m);
  288. }
  289. return roles;
  290. }
  291. public List<ExtendedGroupRoleMembersData> GetGroupRoleMembers(string RequestingAgentID, UUID GroupID)
  292. {
  293. List<ExtendedGroupRoleMembersData> rmembers = new List<ExtendedGroupRoleMembersData>();
  294. Dictionary<string, object> sendData = new Dictionary<string, object>();
  295. sendData["GroupID"] = GroupID.ToString();
  296. sendData["RequestingAgentID"] = RequestingAgentID;
  297. Dictionary<string, object> ret = MakeRequest("GETROLEMEMBERS", sendData);
  298. if (ret == null)
  299. return rmembers;
  300. if (!ret.ContainsKey("RESULT"))
  301. return rmembers;
  302. if (ret["RESULT"].ToString() == "NULL")
  303. return rmembers;
  304. foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
  305. {
  306. ExtendedGroupRoleMembersData m = GroupsDataUtils.GroupRoleMembersData((Dictionary<string, object>)v);
  307. rmembers.Add(m);
  308. }
  309. return rmembers;
  310. }
  311. public bool AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
  312. {
  313. Dictionary<string, object> sendData = new Dictionary<string, object>();
  314. sendData["AgentID"] = AgentID.ToString();
  315. sendData["GroupID"] = GroupID.ToString();
  316. sendData["RoleID"] = RoleID.ToString();
  317. sendData["RequestingAgentID"] = RequestingAgentID;
  318. sendData["OP"] = "ADD";
  319. Dictionary<string, object> ret = MakeRequest("AGENTROLE", sendData);
  320. if (ret == null)
  321. return false;
  322. if (!ret.ContainsKey("RESULT"))
  323. return false;
  324. if (ret["RESULT"].ToString().ToLower() != "true")
  325. return false;
  326. return true;
  327. }
  328. public bool RemoveAgentFromGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
  329. {
  330. Dictionary<string, object> sendData = new Dictionary<string, object>();
  331. sendData["AgentID"] = AgentID.ToString();
  332. sendData["GroupID"] = GroupID.ToString();
  333. sendData["RoleID"] = RoleID.ToString();
  334. sendData["RequestingAgentID"] = RequestingAgentID;
  335. sendData["OP"] = "DELETE";
  336. Dictionary<string, object> ret = MakeRequest("AGENTROLE", sendData);
  337. if (ret == null)
  338. return false;
  339. if (!ret.ContainsKey("RESULT"))
  340. return false;
  341. if (ret["RESULT"].ToString().ToLower() != "true")
  342. return false;
  343. return true;
  344. }
  345. public List<GroupRolesData> GetAgentGroupRoles(string RequestingAgentID, string AgentID, UUID GroupID)
  346. {
  347. List<GroupRolesData> roles = new List<GroupRolesData>();
  348. Dictionary<string, object> sendData = new Dictionary<string, object>();
  349. sendData["AgentID"] = AgentID.ToString();
  350. sendData["GroupID"] = GroupID.ToString();
  351. sendData["RequestingAgentID"] = RequestingAgentID;
  352. Dictionary<string, object> ret = MakeRequest("GETAGENTROLES", sendData);
  353. if (ret == null)
  354. return roles;
  355. if (!ret.ContainsKey("RESULT"))
  356. return roles;
  357. if (ret["RESULT"].ToString() == "NULL")
  358. return roles;
  359. foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
  360. {
  361. GroupRolesData m = GroupsDataUtils.GroupRolesData((Dictionary<string, object>)v);
  362. roles.Add(m);
  363. }
  364. return roles;
  365. }
  366. public GroupMembershipData SetAgentActiveGroup(string RequestingAgentID, string AgentID, UUID GroupID)
  367. {
  368. Dictionary<string, object> sendData = new Dictionary<string, object>();
  369. sendData["AgentID"] = AgentID.ToString();
  370. sendData["GroupID"] = GroupID.ToString();
  371. sendData["RequestingAgentID"] = RequestingAgentID;
  372. sendData["OP"] = "GROUP";
  373. Dictionary<string, object> ret = MakeRequest("SETACTIVE", sendData);
  374. if (ret == null)
  375. return null;
  376. if (!ret.ContainsKey("RESULT"))
  377. return null;
  378. if (ret["RESULT"].ToString() == "NULL")
  379. return null;
  380. return GroupsDataUtils.GroupMembershipData((Dictionary<string, object>)ret["RESULT"]);
  381. }
  382. public void SetAgentActiveGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
  383. {
  384. Dictionary<string, object> sendData = new Dictionary<string, object>();
  385. sendData["AgentID"] = AgentID.ToString();
  386. sendData["GroupID"] = GroupID.ToString();
  387. sendData["RoleID"] = RoleID.ToString();
  388. sendData["RequestingAgentID"] = RequestingAgentID;
  389. sendData["OP"] = "ROLE";
  390. MakeRequest("SETACTIVE", sendData);
  391. }
  392. public void UpdateMembership(string RequestingAgentID, string AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
  393. {
  394. Dictionary<string, object> sendData = new Dictionary<string, object>();
  395. sendData["AgentID"] = AgentID.ToString();
  396. sendData["GroupID"] = GroupID.ToString();
  397. sendData["AcceptNotices"] = AcceptNotices.ToString();
  398. sendData["ListInProfile"] = ListInProfile.ToString();
  399. sendData["RequestingAgentID"] = RequestingAgentID;
  400. MakeRequest("UPDATEMEMBERSHIP", sendData);
  401. }
  402. public bool AddAgentToGroupInvite(string RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, string agentID)
  403. {
  404. Dictionary<string, object> sendData = new Dictionary<string, object>();
  405. sendData["InviteID"] = inviteID.ToString();
  406. sendData["GroupID"] = groupID.ToString();
  407. sendData["RoleID"] = roleID.ToString();
  408. sendData["AgentID"] = agentID.ToString();
  409. sendData["RequestingAgentID"] = RequestingAgentID;
  410. sendData["OP"] = "ADD";
  411. Dictionary<string, object> ret = MakeRequest("INVITE", sendData);
  412. if (ret == null)
  413. return false;
  414. if (!ret.ContainsKey("RESULT"))
  415. return false;
  416. if (ret["RESULT"].ToString().ToLower() != "true") // it may return "NULL"
  417. return false;
  418. return true;
  419. }
  420. public GroupInviteInfo GetAgentToGroupInvite(string RequestingAgentID, UUID inviteID)
  421. {
  422. Dictionary<string, object> sendData = new Dictionary<string, object>();
  423. sendData["InviteID"] = inviteID.ToString();
  424. sendData["RequestingAgentID"] = RequestingAgentID;
  425. sendData["OP"] = "GET";
  426. Dictionary<string, object> ret = MakeRequest("INVITE", sendData);
  427. if (ret == null)
  428. return null;
  429. if (!ret.ContainsKey("RESULT"))
  430. return null;
  431. if (ret["RESULT"].ToString() == "NULL")
  432. return null;
  433. return GroupsDataUtils.GroupInviteInfo((Dictionary<string, object>)ret["RESULT"]);
  434. }
  435. public void RemoveAgentToGroupInvite(string RequestingAgentID, UUID inviteID)
  436. {
  437. Dictionary<string, object> sendData = new Dictionary<string, object>();
  438. sendData["InviteID"] = inviteID.ToString();
  439. sendData["RequestingAgentID"] = RequestingAgentID;
  440. sendData["OP"] = "DELETE";
  441. MakeRequest("INVITE", sendData);
  442. }
  443. public bool AddGroupNotice(string RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message,
  444. bool hasAttachment, byte attType, string attName, UUID attItemID, string attOwnerID)
  445. {
  446. Dictionary<string, object> sendData = new Dictionary<string, object>();
  447. sendData["GroupID"] = groupID.ToString();
  448. sendData["NoticeID"] = noticeID.ToString();
  449. sendData["FromName"] = GroupsDataUtils.Sanitize(fromName);
  450. sendData["Subject"] = GroupsDataUtils.Sanitize(subject);
  451. sendData["Message"] = GroupsDataUtils.Sanitize(message);
  452. sendData["HasAttachment"] = hasAttachment.ToString();
  453. if (hasAttachment)
  454. {
  455. sendData["AttachmentType"] = attType.ToString();
  456. sendData["AttachmentName"] = attName.ToString();
  457. sendData["AttachmentItemID"] = attItemID.ToString();
  458. sendData["AttachmentOwnerID"] = attOwnerID;
  459. }
  460. sendData["RequestingAgentID"] = RequestingAgentID;
  461. Dictionary<string, object> ret = MakeRequest("ADDNOTICE", sendData);
  462. if (ret == null)
  463. return false;
  464. if (!ret.ContainsKey("RESULT"))
  465. return false;
  466. if (ret["RESULT"].ToString().ToLower() != "true")
  467. return false;
  468. return true;
  469. }
  470. public GroupNoticeInfo GetGroupNotice(string RequestingAgentID, UUID noticeID)
  471. {
  472. Dictionary<string, object> sendData = new Dictionary<string, object>();
  473. sendData["NoticeID"] = noticeID.ToString();
  474. sendData["RequestingAgentID"] = RequestingAgentID;
  475. Dictionary<string, object> ret = MakeRequest("GETNOTICES", sendData);
  476. if (ret == null)
  477. return null;
  478. if (!ret.ContainsKey("RESULT"))
  479. return null;
  480. if (ret["RESULT"].ToString() == "NULL")
  481. return null;
  482. return GroupsDataUtils.GroupNoticeInfo((Dictionary<string, object>)ret["RESULT"]);
  483. }
  484. public List<ExtendedGroupNoticeData> GetGroupNotices(string RequestingAgentID, UUID GroupID)
  485. {
  486. List<ExtendedGroupNoticeData> notices = new List<ExtendedGroupNoticeData>();
  487. Dictionary<string, object> sendData = new Dictionary<string, object>();
  488. sendData["GroupID"] = GroupID.ToString();
  489. sendData["RequestingAgentID"] = RequestingAgentID;
  490. Dictionary<string, object> ret = MakeRequest("GETNOTICES", sendData);
  491. if (ret == null)
  492. return notices;
  493. if (!ret.ContainsKey("RESULT"))
  494. return notices;
  495. if (ret["RESULT"].ToString() == "NULL")
  496. return notices;
  497. foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
  498. {
  499. ExtendedGroupNoticeData m = GroupsDataUtils.GroupNoticeData((Dictionary<string, object>)v);
  500. notices.Add(m);
  501. }
  502. return notices;
  503. }
  504. #region Make Request
  505. private Dictionary<string, object> MakeRequest(string method, Dictionary<string, object> sendData)
  506. {
  507. sendData["METHOD"] = method;
  508. string reply = string.Empty;
  509. lock (m_Lock)
  510. reply = SynchronousRestFormsRequester.MakeRequest("POST",
  511. m_ServerURI + "groups",
  512. ServerUtils.BuildQueryString(sendData));
  513. if (reply == string.Empty)
  514. return null;
  515. Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
  516. reply);
  517. return replyData;
  518. }
  519. #endregion
  520. }
  521. }