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