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