OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
GroupsServiceRemoteConnector.cs
Go to the documentation of this file.
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 
28 using System;
29 using System.Collections.Generic;
30 using System.Linq;
31 using System.Reflection;
32 using System.Text;
33 
34 using OpenSim.Framework;
35 using OpenSim.Framework.ServiceAuth;
36 using OpenSim.Server.Base;
37 
38 using OpenMetaverse;
39 using log4net;
40 using Nini.Config;
41 
42 namespace OpenSim.Groups
43 {
45  {
46  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 
48  private string m_ServerURI;
49  private IServiceAuth m_Auth;
50  private object m_Lock = new object();
51 
52  public GroupsServiceRemoteConnector(IConfigSource config)
53  {
54  IConfig groupsConfig = config.Configs["Groups"];
55  string url = groupsConfig.GetString("GroupsServerURI", string.Empty);
56  if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
57  throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url));
58 
59  m_ServerURI = url;
60  if (!m_ServerURI.EndsWith("/"))
61  m_ServerURI += "/";
62 
64  string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", "Groups" }, "None");
65 
66  switch (authType)
67  {
68  case "BasicHttpAuthentication":
69  m_Auth = new BasicHttpAuthentication(config, "Groups");
70  break;
71  }
73 
74  m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, authentication {1}",
75  m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString()));
76  }
77 
78  public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment,
79  bool allowPublish, bool maturePublish, UUID founderID, out string reason)
80  {
81  reason = string.Empty;
82 
84  rec.AllowPublish = allowPublish;
85  rec.Charter = charter;
86  rec.FounderID = founderID;
87  rec.GroupName = name;
88  rec.GroupPicture = insigniaID;
89  rec.MaturePublish = maturePublish;
90  rec.MembershipFee = membershipFee;
91  rec.OpenEnrollment = openEnrollment;
92  rec.ShowInList = showInList;
93 
94  Dictionary<string, object> sendData = GroupsDataUtils.GroupRecord(rec);
95  sendData["RequestingAgentID"] = RequestingAgentID;
96  sendData["OP"] = "ADD";
97  Dictionary<string, object> ret = MakeRequest("PUTGROUP", sendData);
98 
99  if (ret == null)
100  return null;
101 
102  if (ret["RESULT"].ToString() == "NULL")
103  {
104  reason = ret["REASON"].ToString();
105  return null;
106  }
107 
108  return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
109 
110  }
111 
112  public ExtendedGroupRecord UpdateGroup(string RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
113  {
115  rec.AllowPublish = allowPublish;
116  rec.Charter = charter;
117  rec.GroupPicture = insigniaID;
118  rec.MaturePublish = maturePublish;
119  rec.GroupID = groupID;
120  rec.MembershipFee = membershipFee;
121  rec.OpenEnrollment = openEnrollment;
122  rec.ShowInList = showInList;
123 
124  Dictionary<string, object> sendData = GroupsDataUtils.GroupRecord(rec);
125  sendData["RequestingAgentID"] = RequestingAgentID;
126  sendData["OP"] = "UPDATE";
127  Dictionary<string, object> ret = MakeRequest("PUTGROUP", sendData);
128 
129  if (ret == null || (ret != null && (!ret.ContainsKey("RESULT") || ret["RESULT"].ToString() == "NULL")))
130  return null;
131 
132  return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
133  }
134 
135  public ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string GroupName)
136  {
137  if (GroupID == UUID.Zero && (GroupName == null || (GroupName != null && GroupName == string.Empty)))
138  return null;
139 
140  Dictionary<string, object> sendData = new Dictionary<string, object>();
141  if (GroupID != UUID.Zero)
142  sendData["GroupID"] = GroupID.ToString();
143  if (!string.IsNullOrEmpty(GroupName))
144  sendData["Name"] = GroupsDataUtils.Sanitize(GroupName);
145 
146  sendData["RequestingAgentID"] = RequestingAgentID;
147 
148  Dictionary<string, object> ret = MakeRequest("GETGROUP", sendData);
149 
150  if (ret == null || (ret != null && (!ret.ContainsKey("RESULT") || ret["RESULT"].ToString() == "NULL")))
151  return null;
152 
153  return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
154  }
155 
156  public List<DirGroupsReplyData> FindGroups(string RequestingAgentID, string query)
157  {
158  List<DirGroupsReplyData> hits = new List<DirGroupsReplyData>();
159  if (string.IsNullOrEmpty(query))
160  return hits;
161 
162  Dictionary<string, object> sendData = new Dictionary<string, object>();
163  sendData["Query"] = query;
164  sendData["RequestingAgentID"] = RequestingAgentID;
165 
166  Dictionary<string, object> ret = MakeRequest("FINDGROUPS", sendData);
167 
168  if (ret == null)
169  return hits;
170 
171  if (!ret.ContainsKey("RESULT"))
172  return hits;
173 
174  if (ret["RESULT"].ToString() == "NULL")
175  return hits;
176 
177  foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
178  {
179  DirGroupsReplyData m = GroupsDataUtils.DirGroupsReplyData((Dictionary<string, object>)v);
180  hits.Add(m);
181  }
182 
183  return hits;
184  }
185 
186  public GroupMembershipData AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
187  {
188  reason = string.Empty;
189 
190  Dictionary<string, object> sendData = new Dictionary<string,object>();
191  sendData["AgentID"] = AgentID;
192  sendData["GroupID"] = GroupID.ToString();
193  sendData["RoleID"] = RoleID.ToString();
194  sendData["RequestingAgentID"] = RequestingAgentID;
195  sendData["AccessToken"] = token;
196  Dictionary<string, object> ret = MakeRequest("ADDAGENTTOGROUP", sendData);
197 
198  if (ret == null)
199  return null;
200 
201  if (!ret.ContainsKey("RESULT"))
202  return null;
203 
204  if (ret["RESULT"].ToString() == "NULL")
205  {
206  reason = ret["REASON"].ToString();
207  return null;
208  }
209 
210  return GroupsDataUtils.GroupMembershipData((Dictionary<string, object>)ret["RESULT"]);
211 
212  }
213 
214  public void RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID)
215  {
216  Dictionary<string, object> sendData = new Dictionary<string, object>();
217  sendData["AgentID"] = AgentID;
218  sendData["GroupID"] = GroupID.ToString();
219  sendData["RequestingAgentID"] = RequestingAgentID;
220  MakeRequest("REMOVEAGENTFROMGROUP", sendData);
221  }
222 
223  public ExtendedGroupMembershipData GetMembership(string RequestingAgentID, string AgentID, UUID GroupID)
224  {
225  Dictionary<string, object> sendData = new Dictionary<string, object>();
226  sendData["AgentID"] = AgentID;
227  if (GroupID != UUID.Zero)
228  sendData["GroupID"] = GroupID.ToString();
229  sendData["RequestingAgentID"] = RequestingAgentID;
230  Dictionary<string, object> ret = MakeRequest("GETMEMBERSHIP", sendData);
231 
232  if (ret == null)
233  return null;
234 
235  if (!ret.ContainsKey("RESULT"))
236  return null;
237 
238  if (ret["RESULT"].ToString() == "NULL")
239  return null;
240 
241  return GroupsDataUtils.GroupMembershipData((Dictionary<string, object>)ret["RESULT"]);
242  }
243 
244  public List<GroupMembershipData> GetMemberships(string RequestingAgentID, string AgentID)
245  {
246  List<GroupMembershipData> memberships = new List<GroupMembershipData>();
247 
248  Dictionary<string, object> sendData = new Dictionary<string, object>();
249  sendData["AgentID"] = AgentID;
250  sendData["ALL"] = "true";
251  sendData["RequestingAgentID"] = RequestingAgentID;
252  Dictionary<string, object> ret = MakeRequest("GETMEMBERSHIP", sendData);
253 
254  if (ret == null)
255  return memberships;
256 
257  if (!ret.ContainsKey("RESULT"))
258  return memberships;
259 
260  if (ret["RESULT"].ToString() == "NULL")
261  return memberships;
262 
263  foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
264  {
265  GroupMembershipData m = GroupsDataUtils.GroupMembershipData((Dictionary<string, object>)v);
266  memberships.Add(m);
267  }
268 
269  return memberships;
270  }
271 
272  public List<ExtendedGroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID)
273  {
274  List<ExtendedGroupMembersData> members = new List<ExtendedGroupMembersData>();
275 
276  Dictionary<string, object> sendData = new Dictionary<string, object>();
277  sendData["GroupID"] = GroupID.ToString();
278  sendData["RequestingAgentID"] = RequestingAgentID;
279 
280  Dictionary<string, object> ret = MakeRequest("GETGROUPMEMBERS", sendData);
281 
282  if (ret == null)
283  return members;
284 
285  if (!ret.ContainsKey("RESULT"))
286  return members;
287 
288  if (ret["RESULT"].ToString() == "NULL")
289  return members;
290 
291  foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
292  {
293  ExtendedGroupMembersData m = GroupsDataUtils.GroupMembersData((Dictionary<string, object>)v);
294  members.Add(m);
295  }
296 
297  return members;
298  }
299 
300  public bool AddGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, out string reason)
301  {
302  reason = string.Empty;
303 
304  Dictionary<string, object> sendData = new Dictionary<string, object>();
305  sendData["GroupID"] = groupID.ToString();
306  sendData["RoleID"] = roleID.ToString();
307  sendData["Name"] = GroupsDataUtils.Sanitize(name);
308  sendData["Description"] = GroupsDataUtils.Sanitize(description);
309  sendData["Title"] = GroupsDataUtils.Sanitize(title);
310  sendData["Powers"] = powers.ToString();
311  sendData["RequestingAgentID"] = RequestingAgentID;
312  sendData["OP"] = "ADD";
313  Dictionary<string, object> ret = MakeRequest("PUTROLE", sendData);
314 
315  if (ret == null)
316  return false;
317 
318  if (!ret.ContainsKey("RESULT"))
319  return false;
320 
321  if (ret["RESULT"].ToString().ToLower() != "true")
322  {
323  reason = ret["REASON"].ToString();
324  return false;
325  }
326 
327  return true;
328  }
329 
330  public bool UpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
331  {
332  Dictionary<string, object> sendData = new Dictionary<string, object>();
333  sendData["GroupID"] = groupID.ToString();
334  sendData["RoleID"] = roleID.ToString();
335  sendData["Name"] = GroupsDataUtils.Sanitize(name);
336  sendData["Description"] = GroupsDataUtils.Sanitize(description);
337  sendData["Title"] = GroupsDataUtils.Sanitize(title);
338  sendData["Powers"] = powers.ToString();
339  sendData["RequestingAgentID"] = RequestingAgentID;
340  sendData["OP"] = "UPDATE";
341  Dictionary<string, object> ret = MakeRequest("PUTROLE", sendData);
342 
343  if (ret == null)
344  return false;
345 
346  if (!ret.ContainsKey("RESULT"))
347  return false;
348 
349  if (ret["RESULT"].ToString().ToLower() != "true")
350  return false;
351 
352  return true;
353  }
354 
355  public void RemoveGroupRole(string RequestingAgentID, UUID groupID, UUID roleID)
356  {
357  Dictionary<string, object> sendData = new Dictionary<string, object>();
358  sendData["GroupID"] = groupID.ToString();
359  sendData["RoleID"] = roleID.ToString();
360  sendData["RequestingAgentID"] = RequestingAgentID;
361  MakeRequest("REMOVEROLE", sendData);
362  }
363 
364  public List<GroupRolesData> GetGroupRoles(string RequestingAgentID, UUID GroupID)
365  {
366  List<GroupRolesData> roles = new List<GroupRolesData>();
367 
368  Dictionary<string, object> sendData = new Dictionary<string, object>();
369  sendData["GroupID"] = GroupID.ToString();
370  sendData["RequestingAgentID"] = RequestingAgentID;
371  Dictionary<string, object> ret = MakeRequest("GETGROUPROLES", sendData);
372 
373  if (ret == null)
374  return roles;
375 
376  if (!ret.ContainsKey("RESULT"))
377  return roles;
378 
379  if (ret["RESULT"].ToString() == "NULL")
380  return roles;
381 
382  foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
383  {
384  GroupRolesData m = GroupsDataUtils.GroupRolesData((Dictionary<string, object>)v);
385  roles.Add(m);
386  }
387 
388  return roles;
389  }
390 
391  public List<ExtendedGroupRoleMembersData> GetGroupRoleMembers(string RequestingAgentID, UUID GroupID)
392  {
393  List<ExtendedGroupRoleMembersData> rmembers = new List<ExtendedGroupRoleMembersData>();
394 
395  Dictionary<string, object> sendData = new Dictionary<string, object>();
396  sendData["GroupID"] = GroupID.ToString();
397  sendData["RequestingAgentID"] = RequestingAgentID;
398  Dictionary<string, object> ret = MakeRequest("GETROLEMEMBERS", sendData);
399 
400  if (ret == null)
401  return rmembers;
402 
403  if (!ret.ContainsKey("RESULT"))
404  return rmembers;
405 
406  if (ret["RESULT"].ToString() == "NULL")
407  return rmembers;
408 
409  foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
410  {
411  ExtendedGroupRoleMembersData m = GroupsDataUtils.GroupRoleMembersData((Dictionary<string, object>)v);
412  rmembers.Add(m);
413  }
414 
415  return rmembers;
416  }
417 
418  public bool AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
419  {
420  Dictionary<string, object> sendData = new Dictionary<string, object>();
421  sendData["AgentID"] = AgentID.ToString();
422  sendData["GroupID"] = GroupID.ToString();
423  sendData["RoleID"] = RoleID.ToString();
424  sendData["RequestingAgentID"] = RequestingAgentID;
425  sendData["OP"] = "ADD";
426 
427  Dictionary<string, object> ret = MakeRequest("AGENTROLE", sendData);
428 
429  if (ret == null)
430  return false;
431 
432  if (!ret.ContainsKey("RESULT"))
433  return false;
434 
435  if (ret["RESULT"].ToString().ToLower() != "true")
436  return false;
437 
438  return true;
439  }
440 
441  public bool RemoveAgentFromGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
442  {
443  Dictionary<string, object> sendData = new Dictionary<string, object>();
444  sendData["AgentID"] = AgentID.ToString();
445  sendData["GroupID"] = GroupID.ToString();
446  sendData["RoleID"] = RoleID.ToString();
447  sendData["RequestingAgentID"] = RequestingAgentID;
448  sendData["OP"] = "DELETE";
449 
450  Dictionary<string, object> ret = MakeRequest("AGENTROLE", sendData);
451 
452  if (ret == null)
453  return false;
454 
455  if (!ret.ContainsKey("RESULT"))
456  return false;
457 
458  if (ret["RESULT"].ToString().ToLower() != "true")
459  return false;
460 
461  return true;
462  }
463 
464  public List<GroupRolesData> GetAgentGroupRoles(string RequestingAgentID, string AgentID, UUID GroupID)
465  {
466  List<GroupRolesData> roles = new List<GroupRolesData>();
467 
468  Dictionary<string, object> sendData = new Dictionary<string, object>();
469  sendData["AgentID"] = AgentID.ToString();
470  sendData["GroupID"] = GroupID.ToString();
471  sendData["RequestingAgentID"] = RequestingAgentID;
472  Dictionary<string, object> ret = MakeRequest("GETAGENTROLES", sendData);
473 
474  if (ret == null)
475  return roles;
476 
477  if (!ret.ContainsKey("RESULT"))
478  return roles;
479 
480  if (ret["RESULT"].ToString() == "NULL")
481  return roles;
482 
483  foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
484  {
485  GroupRolesData m = GroupsDataUtils.GroupRolesData((Dictionary<string, object>)v);
486  roles.Add(m);
487  }
488 
489  return roles;
490  }
491 
492  public GroupMembershipData SetAgentActiveGroup(string RequestingAgentID, string AgentID, UUID GroupID)
493  {
494  Dictionary<string, object> sendData = new Dictionary<string, object>();
495  sendData["AgentID"] = AgentID.ToString();
496  sendData["GroupID"] = GroupID.ToString();
497  sendData["RequestingAgentID"] = RequestingAgentID;
498  sendData["OP"] = "GROUP";
499 
500  Dictionary<string, object> ret = MakeRequest("SETACTIVE", sendData);
501 
502  if (ret == null)
503  return null;
504 
505  if (!ret.ContainsKey("RESULT"))
506  return null;
507 
508  if (ret["RESULT"].ToString() == "NULL")
509  return null;
510 
511  return GroupsDataUtils.GroupMembershipData((Dictionary<string, object>)ret["RESULT"]);
512  }
513 
514  public void SetAgentActiveGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
515  {
516  Dictionary<string, object> sendData = new Dictionary<string, object>();
517  sendData["AgentID"] = AgentID.ToString();
518  sendData["GroupID"] = GroupID.ToString();
519  sendData["RoleID"] = RoleID.ToString();
520  sendData["RequestingAgentID"] = RequestingAgentID;
521  sendData["OP"] = "ROLE";
522 
523  MakeRequest("SETACTIVE", sendData);
524  }
525 
526  public void UpdateMembership(string RequestingAgentID, string AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
527  {
528  Dictionary<string, object> sendData = new Dictionary<string, object>();
529  sendData["AgentID"] = AgentID.ToString();
530  sendData["GroupID"] = GroupID.ToString();
531  sendData["AcceptNotices"] = AcceptNotices.ToString();
532  sendData["ListInProfile"] = ListInProfile.ToString();
533  sendData["RequestingAgentID"] = RequestingAgentID;
534  MakeRequest("UPDATEMEMBERSHIP", sendData);
535  }
536 
537  public bool AddAgentToGroupInvite(string RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, string agentID)
538  {
539  Dictionary<string, object> sendData = new Dictionary<string, object>();
540  sendData["InviteID"] = inviteID.ToString();
541  sendData["GroupID"] = groupID.ToString();
542  sendData["RoleID"] = roleID.ToString();
543  sendData["AgentID"] = agentID.ToString();
544  sendData["RequestingAgentID"] = RequestingAgentID;
545  sendData["OP"] = "ADD";
546 
547  Dictionary<string, object> ret = MakeRequest("INVITE", sendData);
548 
549  if (ret == null)
550  return false;
551 
552  if (!ret.ContainsKey("RESULT"))
553  return false;
554 
555  if (ret["RESULT"].ToString().ToLower() != "true") // it may return "NULL"
556  return false;
557 
558  return true;
559  }
560 
561  public GroupInviteInfo GetAgentToGroupInvite(string RequestingAgentID, UUID inviteID)
562  {
563  Dictionary<string, object> sendData = new Dictionary<string, object>();
564  sendData["InviteID"] = inviteID.ToString();
565  sendData["RequestingAgentID"] = RequestingAgentID;
566  sendData["OP"] = "GET";
567 
568  Dictionary<string, object> ret = MakeRequest("INVITE", sendData);
569 
570  if (ret == null)
571  return null;
572 
573  if (!ret.ContainsKey("RESULT"))
574  return null;
575 
576  if (ret["RESULT"].ToString() == "NULL")
577  return null;
578 
579  return GroupsDataUtils.GroupInviteInfo((Dictionary<string, object>)ret["RESULT"]);
580  }
581 
582  public void RemoveAgentToGroupInvite(string RequestingAgentID, UUID inviteID)
583  {
584  Dictionary<string, object> sendData = new Dictionary<string, object>();
585  sendData["InviteID"] = inviteID.ToString();
586  sendData["RequestingAgentID"] = RequestingAgentID;
587  sendData["OP"] = "DELETE";
588 
589  MakeRequest("INVITE", sendData);
590  }
591 
592  public bool AddGroupNotice(string RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message,
593  bool hasAttachment, byte attType, string attName, UUID attItemID, string attOwnerID)
594  {
595  Dictionary<string, object> sendData = new Dictionary<string, object>();
596  sendData["GroupID"] = groupID.ToString();
597  sendData["NoticeID"] = noticeID.ToString();
598  sendData["FromName"] = GroupsDataUtils.Sanitize(fromName);
599  sendData["Subject"] = GroupsDataUtils.Sanitize(subject);
600  sendData["Message"] = GroupsDataUtils.Sanitize(message);
601  sendData["HasAttachment"] = hasAttachment.ToString();
602  if (hasAttachment)
603  {
604  sendData["AttachmentType"] = attType.ToString();
605  sendData["AttachmentName"] = attName.ToString();
606  sendData["AttachmentItemID"] = attItemID.ToString();
607  sendData["AttachmentOwnerID"] = attOwnerID;
608  }
609  sendData["RequestingAgentID"] = RequestingAgentID;
610 
611  Dictionary<string, object> ret = MakeRequest("ADDNOTICE", sendData);
612 
613  if (ret == null)
614  return false;
615 
616  if (!ret.ContainsKey("RESULT"))
617  return false;
618 
619  if (ret["RESULT"].ToString().ToLower() != "true")
620  return false;
621 
622  return true;
623  }
624 
625  public GroupNoticeInfo GetGroupNotice(string RequestingAgentID, UUID noticeID)
626  {
627  Dictionary<string, object> sendData = new Dictionary<string, object>();
628  sendData["NoticeID"] = noticeID.ToString();
629  sendData["RequestingAgentID"] = RequestingAgentID;
630 
631  Dictionary<string, object> ret = MakeRequest("GETNOTICES", sendData);
632 
633  if (ret == null)
634  return null;
635 
636  if (!ret.ContainsKey("RESULT"))
637  return null;
638 
639  if (ret["RESULT"].ToString() == "NULL")
640  return null;
641 
642  return GroupsDataUtils.GroupNoticeInfo((Dictionary<string, object>)ret["RESULT"]);
643  }
644 
645  public List<ExtendedGroupNoticeData> GetGroupNotices(string RequestingAgentID, UUID GroupID)
646  {
647  List<ExtendedGroupNoticeData> notices = new List<ExtendedGroupNoticeData>();
648 
649  Dictionary<string, object> sendData = new Dictionary<string, object>();
650  sendData["GroupID"] = GroupID.ToString();
651  sendData["RequestingAgentID"] = RequestingAgentID;
652  Dictionary<string, object> ret = MakeRequest("GETNOTICES", sendData);
653 
654  if (ret == null)
655  return notices;
656 
657  if (!ret.ContainsKey("RESULT"))
658  return notices;
659 
660  if (ret["RESULT"].ToString() == "NULL")
661  return notices;
662 
663  foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
664  {
665  ExtendedGroupNoticeData m = GroupsDataUtils.GroupNoticeData((Dictionary<string, object>)v);
666  notices.Add(m);
667  }
668 
669  return notices;
670  }
671 
672  #region Make Request
673 
674  private Dictionary<string, object> MakeRequest(string method, Dictionary<string, object> sendData)
675  {
676  sendData["METHOD"] = method;
677 
678  string reply = string.Empty;
679  lock (m_Lock)
680  reply = SynchronousRestFormsRequester.MakeRequest("POST",
681  m_ServerURI + "groups",
682  ServerUtils.BuildQueryString(sendData),
683  m_Auth);
684 
685  if (reply == string.Empty)
686  return null;
687 
688  Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
689  reply);
690 
691  return replyData;
692  }
693 
694  #endregion
695  }
696 }
bool AddGroupNotice(string RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, bool hasAttachment, byte attType, string attName, UUID attItemID, string attOwnerID)
void RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID)
List< GroupRolesData > GetAgentGroupRoles(string RequestingAgentID, string AgentID, UUID GroupID)
ExtendedGroupRecord UpdateGroup(string RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
GroupMembershipData SetAgentActiveGroup(string RequestingAgentID, string AgentID, UUID GroupID)
bool AddGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, out string reason)
List< DirGroupsReplyData > FindGroups(string RequestingAgentID, string query)
bool RemoveAgentFromGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
void UpdateMembership(string RequestingAgentID, string AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID, out string reason)
bool UpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
List< ExtendedGroupMembersData > GetGroupMembers(string RequestingAgentID, UUID GroupID)
List< ExtendedGroupRoleMembersData > GetGroupRoleMembers(string RequestingAgentID, UUID GroupID)
List< GroupRolesData > GetGroupRoles(string RequestingAgentID, UUID GroupID)
GroupInviteInfo GetAgentToGroupInvite(string RequestingAgentID, UUID inviteID)
void RemoveGroupRole(string RequestingAgentID, UUID groupID, UUID roleID)
bool AddAgentToGroupInvite(string RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, string agentID)
GroupMembershipData AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
bool AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
GroupNoticeInfo GetGroupNotice(string RequestingAgentID, UUID noticeID)
static string Sanitize(string s)
ExtendedGroupMembershipData GetMembership(string RequestingAgentID, string AgentID, UUID GroupID)
ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string GroupName)
void SetAgentActiveGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
List< GroupMembershipData > GetMemberships(string RequestingAgentID, string AgentID)
List< ExtendedGroupNoticeData > GetGroupNotices(string RequestingAgentID, UUID GroupID)
void RemoveAgentToGroupInvite(string RequestingAgentID, UUID inviteID)