aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs1278
1 files changed, 1278 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
new file mode 100644
index 0000000..590753e
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -0,0 +1,1278 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Collections.Specialized;
32using System.Reflection;
33
34using Nwc.XmlRpc;
35
36using log4net;
37using Mono.Addins;
38using Nini.Config;
39
40using OpenMetaverse;
41using OpenMetaverse.StructuredData;
42
43using OpenSim.Framework;
44using OpenSim.Framework.Communications;
45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Services.Interfaces;
47
48/***************************************************************************
49 * Simian Data Map
50 * ===============
51 *
52 * OwnerID -> Type -> Key
53 * -----------------------
54 *
55 * UserID -> Group -> ActiveGroup
56 * + GroupID
57 *
58 * UserID -> GroupMember -> GroupID
59 * + SelectedRoleID [UUID]
60 * + AcceptNotices [bool]
61 * + ListInProfile [bool]
62 * + Contribution [int]
63 *
64 * UserID -> GroupRole[GroupID] -> RoleID
65 *
66 * GroupID -> Group -> GroupName
67 * + Charter
68 * + ShowInList
69 * + InsigniaID
70 * + MembershipFee
71 * + OpenEnrollment
72 * + AllowPublish
73 * + MaturePublish
74 * + FounderID
75 * + EveryonePowers
76 * + OwnerRoleID
77 * + OwnersPowers
78 *
79 * GroupID -> GroupRole -> RoleID
80 * + Name
81 * + Description
82 * + Title
83 * + Powers
84 *
85 * GroupID -> GroupMemberInvite -> InviteID
86 * + AgentID
87 * + RoleID
88 *
89 * GroupID -> GroupNotice -> NoticeID
90 * + TimeStamp [uint]
91 * + FromName [string]
92 * + Subject [string]
93 * + Message [string]
94 * + BinaryBucket [byte[]]
95 *
96 * */
97
98namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
99{
100 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
101 public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
102 {
103 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
104
105 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
106 GroupPowers.Accountable |
107 GroupPowers.JoinChat |
108 GroupPowers.AllowVoiceChat |
109 GroupPowers.ReceiveNotices |
110 GroupPowers.StartProposal |
111 GroupPowers.VoteOnProposal;
112
113 // Would this be cleaner as (GroupPowers)ulong.MaxValue;
114 public const GroupPowers m_DefaultOwnerPowers = GroupPowers.Accountable
115 | GroupPowers.AllowEditLand
116 | GroupPowers.AllowFly
117 | GroupPowers.AllowLandmark
118 | GroupPowers.AllowRez
119 | GroupPowers.AllowSetHome
120 | GroupPowers.AllowVoiceChat
121 | GroupPowers.AssignMember
122 | GroupPowers.AssignMemberLimited
123 | GroupPowers.ChangeActions
124 | GroupPowers.ChangeIdentity
125 | GroupPowers.ChangeMedia
126 | GroupPowers.ChangeOptions
127 | GroupPowers.CreateRole
128 | GroupPowers.DeedObject
129 | GroupPowers.DeleteRole
130 | GroupPowers.Eject
131 | GroupPowers.FindPlaces
132 | GroupPowers.Invite
133 | GroupPowers.JoinChat
134 | GroupPowers.LandChangeIdentity
135 | GroupPowers.LandDeed
136 | GroupPowers.LandDivideJoin
137 | GroupPowers.LandEdit
138 | GroupPowers.LandEjectAndFreeze
139 | GroupPowers.LandGardening
140 | GroupPowers.LandManageAllowed
141 | GroupPowers.LandManageBanned
142 | GroupPowers.LandManagePasses
143 | GroupPowers.LandOptions
144 | GroupPowers.LandRelease
145 | GroupPowers.LandSetSale
146 | GroupPowers.ModerateChat
147 | GroupPowers.ObjectManipulate
148 | GroupPowers.ObjectSetForSale
149 | GroupPowers.ReceiveNotices
150 | GroupPowers.RemoveMember
151 | GroupPowers.ReturnGroupOwned
152 | GroupPowers.ReturnGroupSet
153 | GroupPowers.ReturnNonGroup
154 | GroupPowers.RoleProperties
155 | GroupPowers.SendNotices
156 | GroupPowers.SetLandingPoint
157 | GroupPowers.StartProposal
158 | GroupPowers.VoteOnProposal;
159
160 private bool m_connectorEnabled = false;
161
162 private string m_serviceURL = string.Empty;
163
164 private bool m_debugEnabled = false;
165
166 // private IUserAccountService m_accountService = null;
167
168
169 #region IRegionModuleBase Members
170
171 public string Name
172 {
173 get { return "SimianGroupsServicesConnector"; }
174 }
175
176 // this module is not intended to be replaced, but there should only be 1 of them.
177 public Type ReplaceableInterface
178 {
179 get { return null; }
180 }
181
182 public void Initialise(IConfigSource config)
183 {
184 IConfig groupsConfig = config.Configs["Groups"];
185
186 if (groupsConfig == null)
187 {
188 // Do not run this module by default.
189 return;
190 }
191 else
192 {
193 // if groups aren't enabled, we're not needed.
194 // if we're not specified as the connector to use, then we're not wanted
195 if ((groupsConfig.GetBoolean("Enabled", false) == false)
196 || (groupsConfig.GetString("ServicesConnectorModule", "Default") != Name))
197 {
198 m_connectorEnabled = false;
199 return;
200 }
201
202 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name);
203
204 m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty);
205 if ((m_serviceURL == null) ||
206 (m_serviceURL == string.Empty))
207 {
208 m_log.ErrorFormat("Please specify a valid Simian Server URL for XmlRpcServiceURL in OpenSim.ini, [Groups]");
209 m_connectorEnabled = false;
210 return;
211 }
212
213 // If we got all the config options we need, lets start'er'up
214 m_connectorEnabled = true;
215
216 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
217
218 }
219 }
220
221 public void Close()
222 {
223 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name);
224 }
225
226 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
227 {
228 if (m_connectorEnabled)
229 {
230 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
231 }
232 }
233
234 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
235 {
236 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
237 {
238 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
239 }
240 }
241
242 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
243 {
244 // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info
245 // scene.EventManager.OnNewClient += OnNewClient;
246 }
247
248 #endregion
249
250 #region ISharedRegionModule Members
251
252 public void PostInitialise()
253 {
254 // NoOp
255 }
256
257 #endregion
258
259
260
261
262 #region IGroupsServicesConnector Members
263
264 /// <summary>
265 /// 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.
266 /// </summary>
267 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
268 int membershipFee, bool openEnrollment, bool allowPublish,
269 bool maturePublish, UUID founderID)
270 {
271 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
272
273 UUID GroupID = UUID.Random();
274 UUID OwnerRoleID = UUID.Random();
275
276 OSDMap GroupInfoMap = new OSDMap();
277 GroupInfoMap["Charter"] = OSD.FromString(charter);
278 GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList);
279 GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID);
280 GroupInfoMap["MembershipFee"] = OSD.FromInteger(0);
281 GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
282 GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish);
283 GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish);
284 GroupInfoMap["FounderID"] = OSD.FromUUID(founderID);
285 GroupInfoMap["EveryonePowers"] = OSD.FromULong((ulong)m_DefaultEveryonePowers);
286 GroupInfoMap["OwnerRoleID"] = OSD.FromUUID(OwnerRoleID);
287 GroupInfoMap["OwnersPowers"] = OSD.FromULong((ulong)m_DefaultOwnerPowers);
288
289 if(SimianAddGeneric(GroupID, "Group", name, GroupInfoMap))
290 {
291 AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers);
292 AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers);
293
294 AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID);
295
296 return GroupID;
297 }
298 else
299 {
300 return UUID.Zero;
301 }
302 }
303
304
305 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
306 UUID insigniaID, int membershipFee, bool openEnrollment,
307 bool allowPublish, bool maturePublish)
308 {
309 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
310 // TODO: Check to make sure requestingAgentID has permission to update group
311
312 string GroupName;
313 OSDMap GroupInfoMap;
314 if( SimianGetFirstGenericEntry(groupID, "GroupInfo", out GroupName, out GroupInfoMap) )
315 {
316 GroupInfoMap["Charter"] = OSD.FromString(charter);
317 GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList);
318 GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID);
319 GroupInfoMap["MembershipFee"] = OSD.FromInteger(0);
320 GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
321 GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish);
322 GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish);
323
324 SimianAddGeneric(groupID, "Group", GroupName, GroupInfoMap);
325 }
326
327 }
328
329
330 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
331 string title, ulong powers)
332 {
333 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
334
335 OSDMap GroupRoleInfo = new OSDMap();
336 GroupRoleInfo["Name"] = OSD.FromString(name);
337 GroupRoleInfo["Description"] = OSD.FromString(description);
338 GroupRoleInfo["Title"] = OSD.FromString(title);
339 GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers);
340
341 // TODO: Add security, make sure that requestingAgentID has permision to add roles
342 SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo);
343 }
344
345 public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
346 {
347 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
348
349 // TODO: Add security
350
351 // Can't delete the Everyone Role
352 if (roleID != UUID.Zero)
353 {
354 // Remove all GroupRole Members from Role
355 Dictionary<UUID, OSDMap> GroupRoleMembers;
356 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
357 if (SimianGetGenericEntries(GroupRoleMemberType, roleID.ToString(), out GroupRoleMembers))
358 {
359 foreach(UUID UserID in GroupRoleMembers.Keys)
360 {
361 EnsureRoleNotSelectedByMember(groupID, roleID, UserID);
362
363 SimianRemoveGenericEntry(UserID, GroupRoleMemberType, roleID.ToString());
364 }
365 }
366
367 // Remove role
368 SimianRemoveGenericEntry(groupID, "GroupRole", roleID.ToString());
369 }
370 }
371
372
373 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
374 string title, ulong powers)
375 {
376 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
377
378 // TODO: Security, check that requestingAgentID is allowed to update group roles
379
380 OSDMap GroupRoleInfo;
381 if (SimianGetGenericEntry(groupID, "GroupRole", roleID.ToString(), out GroupRoleInfo))
382 {
383 if (name != null)
384 {
385 GroupRoleInfo["Name"] = OSD.FromString(name);
386 }
387 if (description != null)
388 {
389 GroupRoleInfo["Description"] = OSD.FromString(description);
390 }
391 if (title != null)
392 {
393 GroupRoleInfo["Title"] = OSD.FromString(title);
394 }
395 GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers);
396
397 }
398
399
400 SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo);
401 }
402
403 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
404 {
405 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
406
407 OSDMap GroupInfoMap = null;
408 if (groupID != UUID.Zero)
409 {
410 if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out GroupInfoMap))
411 {
412 return null;
413 }
414 }
415 else if ((groupName != null) && (groupName != string.Empty))
416 {
417 if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap))
418 {
419 return null;
420 }
421 }
422
423 GroupRecord GroupInfo = new GroupRecord();
424
425 GroupInfo.GroupID = groupID;
426 GroupInfo.GroupName = groupName;
427 GroupInfo.Charter = GroupInfoMap["Charter"].AsString();
428 GroupInfo.ShowInList = GroupInfoMap["ShowInList"].AsBoolean();
429 GroupInfo.GroupPicture = GroupInfoMap["InsigniaID"].AsUUID();
430 GroupInfo.MembershipFee = GroupInfoMap["MembershipFee"].AsInteger();
431 GroupInfo.OpenEnrollment = GroupInfoMap["OpenEnrollment"].AsBoolean();
432 GroupInfo.AllowPublish = GroupInfoMap["AllowPublish"].AsBoolean();
433 GroupInfo.MaturePublish = GroupInfoMap["MaturePublish"].AsBoolean();
434 GroupInfo.FounderID = GroupInfoMap["FounderID"].AsUUID();
435 GroupInfo.OwnerRoleID = GroupInfoMap["OwnerRoleID"].AsUUID();
436
437 return GroupInfo;
438
439 }
440
441 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID groupID, UUID memberID)
442 {
443 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
444
445 OSDMap groupProfile;
446 string groupName;
447 if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out groupProfile))
448 {
449 // GroupProfileData is not nullable
450 return new GroupProfileData();
451 }
452
453 GroupProfileData MemberGroupProfile = new GroupProfileData();
454 MemberGroupProfile.GroupID = groupID;
455 MemberGroupProfile.Name = groupName;
456
457 if (groupProfile["Charter"] != null)
458 {
459 MemberGroupProfile.Charter = groupProfile["Charter"].AsString();
460 }
461
462 MemberGroupProfile.ShowInList = groupProfile["ShowInList"].AsString() == "1";
463 MemberGroupProfile.InsigniaID = groupProfile["InsigniaID"].AsUUID();
464 MemberGroupProfile.MembershipFee = groupProfile["MembershipFee"].AsInteger();
465 MemberGroupProfile.OpenEnrollment = groupProfile["OpenEnrollment"].AsBoolean();
466 MemberGroupProfile.AllowPublish = groupProfile["AllowPublish"].AsBoolean();
467 MemberGroupProfile.MaturePublish = groupProfile["MaturePublish"].AsBoolean();
468 MemberGroupProfile.FounderID = groupProfile["FounderID"].AsUUID();;
469 MemberGroupProfile.OwnerRole = groupProfile["OwnerRoleID"].AsUUID();
470
471 Dictionary<UUID, OSDMap> Members;
472 if (SimianGetGenericEntries("GroupMember",groupID.ToString(), out Members))
473 {
474 MemberGroupProfile.GroupMembershipCount = Members.Count;
475 }
476
477 Dictionary<string, OSDMap> Roles;
478 if (SimianGetGenericEntries(groupID, "GroupRole", out Roles))
479 {
480 MemberGroupProfile.GroupRolesCount = Roles.Count;
481 }
482
483 // TODO: Get Group Money balance from somewhere
484 // group.Money = 0;
485
486 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, memberID, groupID);
487
488 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
489 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
490
491 return MemberGroupProfile;
492 }
493
494 public void SetAgentActiveGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
495 {
496 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
497
498 OSDMap ActiveGroup = new OSDMap();
499 ActiveGroup.Add("GroupID", OSD.FromUUID(groupID));
500 SimianAddGeneric(agentID, "Group", "ActiveGroup", ActiveGroup);
501 }
502
503 public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
504 {
505 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
506
507 OSDMap GroupMemberInfo;
508 if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo))
509 {
510 GroupMemberInfo = new OSDMap();
511 }
512
513 GroupMemberInfo["SelectedRoleID"] = OSD.FromUUID(roleID);
514 SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo);
515 }
516
517 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
518 {
519 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
520
521 OSDMap GroupMemberInfo;
522 if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo))
523 {
524 GroupMemberInfo = new OSDMap();
525 }
526
527 GroupMemberInfo["AcceptNotices"] = OSD.FromBoolean(acceptNotices);
528 GroupMemberInfo["ListInProfile"] = OSD.FromBoolean(listInProfile);
529 GroupMemberInfo["Contribution"] = OSD.FromInteger(0);
530 GroupMemberInfo["SelectedRole"] = OSD.FromUUID(UUID.Zero);
531 SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo);
532 }
533
534 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
535 {
536 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
537
538 OSDMap Invite = new OSDMap();
539 Invite["AgentID"] = OSD.FromUUID(agentID);
540 Invite["RoleID"] = OSD.FromUUID(roleID);
541
542 SimianAddGeneric(groupID, "GroupMemberInvite", inviteID.ToString(), Invite);
543 }
544
545 public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
546 {
547 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
548
549 OSDMap GroupMemberInvite;
550 UUID GroupID;
551 if (!SimianGetFirstGenericEntry("GroupMemberInvite", inviteID.ToString(), out GroupID, out GroupMemberInvite))
552 {
553 return null;
554 }
555
556 GroupInviteInfo inviteInfo = new GroupInviteInfo();
557 inviteInfo.InviteID = inviteID;
558 inviteInfo.GroupID = GroupID;
559 inviteInfo.AgentID = GroupMemberInvite["AgentID"].AsUUID();
560 inviteInfo.RoleID = GroupMemberInvite["RoleID"].AsUUID();
561
562 return inviteInfo;
563 }
564
565 public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
566 {
567 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
568
569 GroupInviteInfo invite = GetAgentToGroupInvite(requestingAgentID, inviteID);
570 SimianRemoveGenericEntry(invite.GroupID, "GroupMemberInvite", inviteID.ToString());
571 }
572
573 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
574 {
575 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
576
577 // Setup Agent/Group information
578 SetAgentGroupInfo(requestingAgentID, AgentID, GroupID, true, true);
579
580 // Add agent to Everyone Group
581 AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, UUID.Zero);
582
583 // Add agent to Specified Role
584 AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
585
586 // Set selected role in this group to specified role
587 SetAgentActiveGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
588 }
589
590 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
591 {
592 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
593
594 // If current active group is the group the agent is being removed from, change their group to UUID.Zero
595 GroupMembershipData memberActiveMembership = GetAgentActiveMembership(requestingAgentID, agentID);
596 if (memberActiveMembership.GroupID == groupID)
597 {
598 SetAgentActiveGroup(agentID, agentID, UUID.Zero);
599 }
600
601 // Remove Group Member information for this group
602 SimianRemoveGenericEntry(agentID, "GroupMember", groupID.ToString());
603
604 // By using a Simian Generics Type consisting of a prefix and a groupID,
605 // combined with RoleID as key allows us to get a list of roles a particular member
606 // of a group is assigned to.
607 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
608
609 // Take Agent out of all other group roles
610 Dictionary<string, OSDMap> GroupRoles;
611 if (SimianGetGenericEntries(agentID, GroupRoleMemberType, out GroupRoles))
612 {
613 foreach (string roleID in GroupRoles.Keys)
614 {
615 SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID);
616 }
617 }
618 }
619
620 public void AddAgentToGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
621 {
622 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
623
624 SimianAddGeneric(agentID, "GroupRole" + groupID.ToString(), roleID.ToString(), new OSDMap());
625 }
626
627 public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
628 {
629 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
630
631 // Cannot remove members from the Everyone Role
632 if (roleID != UUID.Zero)
633 {
634 EnsureRoleNotSelectedByMember(groupID, roleID, agentID);
635
636 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
637 SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID.ToString());
638 }
639 }
640
641 public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
642 {
643 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
644
645 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
646
647 NameValueCollection requestArgs = new NameValueCollection
648 {
649 { "RequestMethod", "GetGenerics" },
650 { "Type", "Group" },
651 { "Key", search },
652 { "Fuzzy", "1" }
653 };
654
655
656 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
657 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
658 {
659 OSDArray entryArray = (OSDArray)response["Entries"];
660 foreach (OSDMap entryMap in entryArray)
661 {
662 DirGroupsReplyData data = new DirGroupsReplyData();
663 data.groupID = entryMap["OwnerID"].AsUUID();
664 data.groupName = entryMap["Key"].AsString();
665
666 // TODO: is there a better way to do this?
667 Dictionary<UUID, OSDMap> Members;
668 if (SimianGetGenericEntries("GroupMember", data.groupID.ToString(), out Members))
669 {
670 data.members = Members.Count;
671 }
672 else
673 {
674 data.members = 0;
675 }
676
677 // TODO: sort results?
678 // data.searchOrder = order;
679
680 findings.Add(data);
681 }
682 }
683
684
685 return findings;
686 }
687
688 public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID agentID, UUID groupID)
689 {
690 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
691
692 GroupMembershipData data = new GroupMembershipData();
693
694 ///////////////////////////////
695 // Agent Specific Information:
696 //
697 OSDMap UserActiveGroup;
698 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
699 {
700 data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
701 }
702
703 OSDMap UserGroupMemberInfo;
704 if( SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo) )
705 {
706 data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean();
707 data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger();
708 data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean();
709 data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID();
710
711 ///////////////////////////////
712 // Role Specific Information:
713 //
714
715 OSDMap GroupRoleInfo;
716 if( SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo) )
717 {
718 data.GroupTitle = GroupRoleInfo["Title"].AsString();
719 data.GroupPowers = GroupRoleInfo["Powers"].AsULong();
720 }
721 }
722
723 ///////////////////////////////
724 // Group Specific Information:
725 //
726 OSDMap GroupInfo;
727 string GroupName;
728 if( SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo) )
729 {
730 data.GroupID = groupID;
731 data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean();
732 data.Charter = GroupInfo["Charter"].AsString();
733 data.FounderID = GroupInfo["FounderID"].AsUUID();
734 data.GroupName = GroupName;
735 data.GroupPicture = GroupInfo["InsigniaID"].AsUUID();
736 data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean();
737 data.MembershipFee = GroupInfo["MembershipFee"].AsInteger();
738 data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean();
739 data.ShowInList = GroupInfo["ShowInList"].AsBoolean();
740 }
741
742 return data;
743 }
744
745 public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID agentID)
746 {
747 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
748
749 UUID GroupID = UUID.Zero;
750 OSDMap UserActiveGroup;
751 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
752 {
753 GroupID = UserActiveGroup["GroupID"].AsUUID();
754 }
755
756 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString());
757 return GetAgentGroupMembership(requestingAgentID, agentID, GroupID);
758 }
759
760 public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID agentID)
761 {
762 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
763
764 List<GroupMembershipData> memberships = new List<GroupMembershipData>();
765
766 Dictionary<string,OSDMap> GroupMemberShips;
767 if (SimianGetGenericEntries(agentID, "GroupMember", out GroupMemberShips))
768 {
769 foreach (string key in GroupMemberShips.Keys)
770 {
771 memberships.Add(GetAgentGroupMembership(requestingAgentID, agentID, UUID.Parse(key)));
772 }
773 }
774
775 return memberships;
776 }
777
778 public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID agentID, UUID groupID)
779 {
780 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
781
782 List<GroupRolesData> Roles = new List<GroupRolesData>();
783
784 Dictionary<string, OSDMap> GroupRoles;
785 if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
786 {
787 Dictionary<string, OSDMap> MemberRoles;
788 if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles))
789 {
790 foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles)
791 {
792 GroupRolesData data = new GroupRolesData();
793 data.RoleID = UUID.Parse(kvp.Key);
794 data.Name = GroupRoles[kvp.Key]["Name"].AsString();
795 data.Description = GroupRoles[kvp.Key]["Description"].AsString();
796 data.Title = GroupRoles[kvp.Key]["Title"].AsString();
797 data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong();
798
799 Roles.Add(data);
800 }
801 }
802 }
803 return Roles;
804 }
805
806 public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID groupID)
807 {
808 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
809
810 List<GroupRolesData> Roles = new List<GroupRolesData>();
811
812 Dictionary<string, OSDMap> GroupRoles;
813 if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
814 {
815 foreach (KeyValuePair<string, OSDMap> role in GroupRoles)
816 {
817 GroupRolesData data = new GroupRolesData();
818
819 data.RoleID = UUID.Parse(role.Key);
820
821 data.Name = role.Value["Name"].AsString();
822 data.Description = role.Value["Description"].AsString();
823 data.Title = role.Value["Title"].AsString();
824 data.Powers = role.Value["Powers"].AsULong();
825
826 Dictionary<UUID, OSDMap> GroupRoleMembers;
827 if (SimianGetGenericEntries("GroupRole" + groupID.ToString(), role.Key, out GroupRoleMembers))
828 {
829 data.Members = GroupRoleMembers.Count;
830 }
831 else
832 {
833 data.Members = 0;
834 }
835
836 Roles.Add(data);
837 }
838 }
839
840 return Roles;
841
842 }
843
844
845
846 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
847 {
848 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
849
850 List<GroupMembersData> members = new List<GroupMembersData>();
851
852 OSDMap GroupInfo;
853 string GroupName;
854 UUID GroupOwnerRoleID = UUID.Zero;
855 if (!SimianGetFirstGenericEntry(GroupID, "Group", out GroupName, out GroupInfo))
856 {
857 return members;
858 }
859 GroupOwnerRoleID = GroupInfo["OwnerRoleID"].AsUUID();
860
861 // Locally cache group roles, since we'll be needing this data for each member
862 Dictionary<string,OSDMap> GroupRoles;
863 SimianGetGenericEntries(GroupID, "GroupRole", out GroupRoles);
864
865 // Locally cache list of group owners
866 Dictionary<UUID, OSDMap> GroupOwners;
867 SimianGetGenericEntries("GroupRole" + GroupID.ToString(), GroupOwnerRoleID.ToString(), out GroupOwners);
868
869
870 Dictionary<UUID, OSDMap> GroupMembers;
871 if (SimianGetGenericEntries("GroupMember", GroupID.ToString(), out GroupMembers))
872 {
873 foreach (KeyValuePair<UUID, OSDMap> member in GroupMembers)
874 {
875 GroupMembersData data = new GroupMembersData();
876
877 data.AgentID = member.Key;
878
879 UUID SelectedRoleID = member.Value["SelectedRoleID"].AsUUID();
880
881 data.AcceptNotices = member.Value["AcceptNotices"].AsBoolean();
882 data.ListInProfile = member.Value["ListInProfile"].AsBoolean();
883 data.Contribution = member.Value["Contribution"].AsInteger();
884
885 data.IsOwner = GroupOwners.ContainsKey(member.Key);
886
887 OSDMap GroupRoleInfo = GroupRoles[SelectedRoleID.ToString()];
888 data.Title = GroupRoleInfo["Title"].AsString();
889 data.AgentPowers = GroupRoleInfo["Powers"].AsULong();
890
891 members.Add(data);
892 }
893 }
894
895 return members;
896
897 }
898
899 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID groupID)
900 {
901 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
902
903 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
904
905 Dictionary<string, OSDMap> GroupRoles;
906 if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
907 {
908 foreach( KeyValuePair<string, OSDMap> Role in GroupRoles )
909 {
910 Dictionary<UUID, OSDMap> GroupRoleMembers;
911 if( SimianGetGenericEntries("GroupRole"+groupID.ToString(), Role.Key, out GroupRoleMembers) )
912 {
913 foreach( KeyValuePair<UUID, OSDMap> GroupRoleMember in GroupRoleMembers )
914 {
915 GroupRoleMembersData data = new GroupRoleMembersData();
916
917 data.MemberID = GroupRoleMember.Key;
918 data.RoleID = UUID.Parse(Role.Key);
919
920 members.Add(data);
921 }
922 }
923 }
924 }
925
926 return members;
927 }
928
929 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
930 {
931 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
932
933 List<GroupNoticeData> values = new List<GroupNoticeData>();
934
935 Dictionary<string, OSDMap> Notices;
936 if (SimianGetGenericEntries(GroupID, "GroupNotice", out Notices))
937 {
938 foreach (KeyValuePair<string, OSDMap> Notice in Notices)
939 {
940 GroupNoticeData data = new GroupNoticeData();
941 data.NoticeID = UUID.Parse(Notice.Key);
942 data.Timestamp = Notice.Value["TimeStamp"].AsUInteger();
943 data.FromName = Notice.Value["FromName"].AsString();
944 data.Subject = Notice.Value["Subject"].AsString();
945 data.HasAttachment = Notice.Value["BinaryBucket"].AsBinary().Length > 0;
946
947 //TODO: Figure out how to get this
948 data.AssetType = 0;
949
950 values.Add(data);
951 }
952 }
953
954 return values;
955
956 }
957 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
958 {
959 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
960
961 OSDMap GroupNotice;
962 UUID GroupID;
963 if (SimianGetFirstGenericEntry("GroupNotice", noticeID.ToString(), out GroupID, out GroupNotice))
964 {
965 GroupNoticeInfo data = new GroupNoticeInfo();
966 data.GroupID = GroupID;
967 data.Message = GroupNotice["Message"].AsString();
968 data.BinaryBucket = GroupNotice["BinaryBucket"].AsBinary();
969 data.noticeData.NoticeID = noticeID;
970 data.noticeData.Timestamp = GroupNotice["TimeStamp"].AsUInteger();
971 data.noticeData.FromName = GroupNotice["FromName"].AsString();
972 data.noticeData.Subject = GroupNotice["Subject"].AsString();
973 data.noticeData.HasAttachment = data.BinaryBucket.Length > 0;
974 data.noticeData.AssetType = 0;
975
976 if (data.Message == null)
977 {
978 data.Message = string.Empty;
979 }
980
981 return data;
982 }
983 return null;
984 }
985 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
986 {
987 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
988
989 OSDMap Notice = new OSDMap();
990 Notice["TimeStamp"] = OSD.FromUInteger((uint)Util.UnixTimeSinceEpoch());
991 Notice["FromName"] = OSD.FromString(fromName);
992 Notice["Subject"] = OSD.FromString(subject);
993 Notice["Message"] = OSD.FromString(message);
994 Notice["BinaryBucket"] = OSD.FromBinary(binaryBucket);
995
996 SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice);
997
998 }
999 #endregion
1000
1001
1002 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID)
1003 {
1004 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1005
1006 // If member's SelectedRole is roleID, change their selected role to Everyone
1007 // before removing them from the role
1008 OSDMap UserGroupInfo;
1009 if (SimianGetGenericEntry(userID, "GroupMember", groupID.ToString(), out UserGroupInfo))
1010 {
1011 if (UserGroupInfo["SelectedRoleID"].AsUUID() == roleID)
1012 {
1013 UserGroupInfo["SelectedRoleID"] = OSD.FromUUID(UUID.Zero);
1014 }
1015 SimianAddGeneric(userID, "GroupMember", groupID.ToString(), UserGroupInfo);
1016 }
1017 }
1018
1019
1020 #region Simian Util Methods
1021 private bool SimianAddGeneric(UUID ownerID, string type, string key, OSDMap map)
1022 {
1023 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1024
1025 string value = OSDParser.SerializeJsonString(map);
1026
1027 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] value: {0}", value);
1028
1029 NameValueCollection RequestArgs = new NameValueCollection
1030 {
1031 { "RequestMethod", "AddGeneric" },
1032 { "OwnerID", ownerID.ToString() },
1033 { "Type", type },
1034 { "Key", key },
1035 { "Value", value}
1036 };
1037
1038
1039 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
1040 if (Response["Success"].AsBoolean())
1041 {
1042 return true;
1043 }
1044 else
1045 {
1046 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, Response["Message"]);
1047 return false;
1048 }
1049 }
1050
1051 /// <summary>
1052 /// Returns the first of possibly many entries for Owner/Type pair
1053 /// </summary>
1054 private bool SimianGetFirstGenericEntry(UUID ownerID, string type, out string key, out OSDMap map)
1055 {
1056 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type);
1057
1058 NameValueCollection RequestArgs = new NameValueCollection
1059 {
1060 { "RequestMethod", "GetGenerics" },
1061 { "OwnerID", ownerID.ToString() },
1062 { "Type", type }
1063 };
1064
1065
1066 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
1067 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1068 {
1069 OSDArray entryArray = (OSDArray)Response["Entries"];
1070 if (entryArray.Count >= 1)
1071 {
1072 OSDMap entryMap = entryArray[0] as OSDMap;
1073 key = entryMap["Key"].AsString();
1074 map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
1075
1076 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1077
1078 return true;
1079 }
1080 else
1081 {
1082 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1083 }
1084 }
1085 else
1086 {
1087 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
1088 }
1089 key = null;
1090 map = null;
1091 return false;
1092 }
1093 private bool SimianGetFirstGenericEntry(string type, string key, out UUID ownerID, out OSDMap map)
1094 {
1095 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
1096
1097
1098 NameValueCollection RequestArgs = new NameValueCollection
1099 {
1100 { "RequestMethod", "GetGenerics" },
1101 { "Type", type },
1102 { "Key", key}
1103 };
1104
1105
1106 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
1107 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1108 {
1109 OSDArray entryArray = (OSDArray)Response["Entries"];
1110 if (entryArray.Count >= 1)
1111 {
1112 OSDMap entryMap = entryArray[0] as OSDMap;
1113 ownerID = entryMap["OwnerID"].AsUUID();
1114 map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
1115
1116 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1117
1118 return true;
1119 }
1120 else
1121 {
1122 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1123 }
1124 }
1125 else
1126 {
1127 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
1128 }
1129 ownerID = UUID.Zero;
1130 map = null;
1131 return false;
1132 }
1133
1134 private bool SimianGetGenericEntry(UUID ownerID, string type, string key, out OSDMap map)
1135 {
1136 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1137
1138 NameValueCollection RequestArgs = new NameValueCollection
1139 {
1140 { "RequestMethod", "GetGenerics" },
1141 { "OwnerID", ownerID.ToString() },
1142 { "Type", type },
1143 { "Key", key}
1144 };
1145
1146
1147 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs);
1148 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1149 {
1150 OSDArray entryArray = (OSDArray)Response["Entries"];
1151 if (entryArray.Count == 1)
1152 {
1153 OSDMap entryMap = entryArray[0] as OSDMap;
1154 key = entryMap["Key"].AsString();
1155 map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
1156
1157 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1158
1159 return true;
1160 }
1161 else
1162 {
1163 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1164 }
1165 }
1166 else
1167 {
1168 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
1169 }
1170 map = null;
1171 return false;
1172 }
1173
1174 private bool SimianGetGenericEntries(UUID ownerID, string type, out Dictionary<string, OSDMap> maps)
1175 {
1176 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name,ownerID, type);
1177
1178 NameValueCollection requestArgs = new NameValueCollection
1179 {
1180 { "RequestMethod", "GetGenerics" },
1181 { "OwnerID", ownerID.ToString() },
1182 { "Type", type }
1183 };
1184
1185
1186
1187 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
1188 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1189 {
1190 maps = new Dictionary<string, OSDMap>();
1191
1192 OSDArray entryArray = (OSDArray)response["Entries"];
1193 foreach (OSDMap entryMap in entryArray)
1194 {
1195 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1196 maps.Add(entryMap["Key"].AsString(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
1197 }
1198 if(maps.Count == 0)
1199 {
1200 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1201 }
1202
1203 return true;
1204 }
1205 else
1206 {
1207 maps = null;
1208 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", response["Message"]);
1209 }
1210 return false;
1211 }
1212 private bool SimianGetGenericEntries(string type, string key, out Dictionary<UUID, OSDMap> maps)
1213 {
1214 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
1215
1216 NameValueCollection requestArgs = new NameValueCollection
1217 {
1218 { "RequestMethod", "GetGenerics" },
1219 { "Type", type },
1220 { "Key", key }
1221 };
1222
1223
1224
1225 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
1226 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1227 {
1228 maps = new Dictionary<UUID, OSDMap>();
1229
1230 OSDArray entryArray = (OSDArray)response["Entries"];
1231 foreach (OSDMap entryMap in entryArray)
1232 {
1233 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1234 maps.Add(entryMap["OwnerID"].AsUUID(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
1235 }
1236 if (maps.Count == 0)
1237 {
1238 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1239 }
1240 return true;
1241 }
1242 else
1243 {
1244 maps = null;
1245 m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR]: Error retrieving group info ({0})", response["Message"]);
1246 }
1247 return false;
1248 }
1249
1250 private bool SimianRemoveGenericEntry(UUID ownerID, string type, string key)
1251 {
1252 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1253
1254 NameValueCollection requestArgs = new NameValueCollection
1255 {
1256 { "RequestMethod", "RemoveGeneric" },
1257 { "OwnerID", ownerID.ToString() },
1258 { "Type", type },
1259 { "Key", key }
1260 };
1261
1262
1263 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs);
1264 if (response["Success"].AsBoolean())
1265 {
1266 return true;
1267 }
1268 else
1269 {
1270 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, response["Message"]);
1271 return false;
1272 }
1273 }
1274 #endregion
1275 }
1276
1277}
1278