Просмотр исходного кода

removed outdated suport for simianGrid. Simian was a web/php alternative to Robust (https://code.google.com/archive/p/openmetaverse)

UbitUmarov 4 лет назад
Родитель
Сommit
941b65b44a
20 измененных файлов с 4 добавлено и 6641 удалено
  1. 0 2
      OpenSim/Framework/ThrottleOutPacketType.cs
  2. 3 13
      OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
  3. 0 1439
      OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
  4. 1 10
      OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
  5. 0 100
      OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
  6. 0 693
      OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
  7. 0 313
      OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
  8. 0 345
      OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
  9. 0 180
      OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
  10. 0 236
      OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
  11. 0 147
      OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
  12. 0 266
      OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
  13. 0 501
      OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
  14. 0 936
      OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
  15. 0 459
      OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
  16. 0 478
      OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
  17. 0 347
      OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
  18. 0 2
      bin/OpenSim.ini.example
  19. 0 97
      bin/config-include/HyperSimianGrid.ini
  20. 0 77
      bin/config-include/SimianGrid.ini

+ 0 - 2
OpenSim/Framework/ThrottleOutPacketType.cs

@@ -47,8 +47,6 @@ namespace OpenSim.Framework
         Texture = 5,
         /// <summary>Non-texture assets</summary>
         Asset = 6,
-
-        HighPriority = 128,
     }
 
     [Flags]

+ 3 - 13
OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs

@@ -38,7 +38,6 @@ using OpenSim.Region.Framework.Interfaces;
 using OpenSim.Region.Framework.Scenes;
 using OpenSim.Services.Interfaces;
 using OpenSim.Services.Connectors;
-using OpenSim.Services.Connectors.SimianGrid;
 using OpenMetaverse;
 
 namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
@@ -694,18 +693,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
                 {
                     // Still not as flexible as I would like this to be,
                     // but good enough for now
-                    string connectorType = new HeloServicesConnector(url).Helo();
-                    m_log.DebugFormat("[HG INVENTORY SERVICE]: HELO returned {0}", connectorType);
-                    if (connectorType == "opensim-simian")
-                    {
-                        connector = new SimianInventoryServiceConnector(url);
-                    }
-                    else
-                    {
-                        RemoteXInventoryServicesConnector rxisc = new RemoteXInventoryServicesConnector(url);
-                        rxisc.Scene = m_Scenes[0];
-                        connector = rxisc;
-                    }
+                    RemoteXInventoryServicesConnector rxisc = new RemoteXInventoryServicesConnector(url);
+                    rxisc.Scene = m_Scenes[0];
+                    connector = rxisc;
 
                     m_connectors.Add(url, connector);
                 }

+ 0 - 1439
OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs

@@ -1,1439 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Reflection;
-using System.Threading;
-
-using Nwc.XmlRpc;
-
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Services.Interfaces;
-
-/***************************************************************************
- * Simian Data Map
- * ===============
- *
- * OwnerID -> Type -> Key
- * -----------------------
- *
- * UserID -> Group -> ActiveGroup
- * + GroupID
- *
- * UserID -> GroupSessionDropped -> GroupID
- * UserID -> GroupSessionInvited -> GroupID
- *
- * UserID -> GroupMember -> GroupID
- * + SelectedRoleID [UUID]
- * + AcceptNotices  [bool]
- * + ListInProfile  [bool]
- * + Contribution   [int]
- *
- * UserID -> GroupRole[GroupID] -> RoleID
- *
- *
- * GroupID -> Group -> GroupName
- * + Charter
- * + ShowInList
- * + InsigniaID
- * + MembershipFee
- * + OpenEnrollment
- * + AllowPublish
- * + MaturePublish
- * + FounderID
- * + EveryonePowers
- * + OwnerRoleID
- * + OwnersPowers
- *
- * GroupID -> GroupRole -> RoleID
- * + Name
- * + Description
- * + Title
- * + Powers
- *
- * GroupID -> GroupMemberInvite -> InviteID
- * + AgentID
- * + RoleID
- *
- * GroupID -> GroupNotice -> NoticeID
- * + TimeStamp      [uint]
- * + FromName       [string]
- * + Subject        [string]
- * + Message        [string]
- * + BinaryBucket   [byte[]]
- *
- * */
-
-namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
-{
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianGroupsServicesConnectorModule")]
-    public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
-    {
-        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
-        public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
-            GroupPowers.Accountable |
-            GroupPowers.JoinChat |
-            GroupPowers.AllowVoiceChat |
-            GroupPowers.ReceiveNotices |
-            GroupPowers.StartProposal |
-            GroupPowers.VoteOnProposal;
-
-        // Would this be cleaner as (GroupPowers)ulong.MaxValue;
-        public const GroupPowers m_DefaultOwnerPowers = GroupPowers.Accountable
-                                | GroupPowers.AllowEditLand
-                                | GroupPowers.AllowFly
-                                | GroupPowers.AllowLandmark
-                                | GroupPowers.AllowRez
-                                | GroupPowers.AllowSetHome
-                                | GroupPowers.AllowVoiceChat
-                                | GroupPowers.AssignMember
-                                | GroupPowers.AssignMemberLimited
-                                | GroupPowers.ChangeActions
-                                | GroupPowers.ChangeIdentity
-                                | GroupPowers.ChangeMedia
-                                | GroupPowers.ChangeOptions
-                                | GroupPowers.CreateRole
-                                | GroupPowers.DeedObject
-                                | GroupPowers.DeleteRole
-                                | GroupPowers.Eject
-                                | GroupPowers.FindPlaces
-                                | GroupPowers.Invite
-                                | GroupPowers.JoinChat
-                                | GroupPowers.LandChangeIdentity
-                                | GroupPowers.LandDeed
-                                | GroupPowers.LandDivideJoin
-                                | GroupPowers.LandEdit
-                                | GroupPowers.LandEjectAndFreeze
-                                | GroupPowers.LandGardening
-                                | GroupPowers.LandManageAllowed
-                                | GroupPowers.LandManageBanned
-                                | GroupPowers.LandManagePasses
-                                | GroupPowers.LandOptions
-                                | GroupPowers.LandRelease
-                                | GroupPowers.LandSetSale
-                                | GroupPowers.ModerateChat
-                                | GroupPowers.ObjectManipulate
-                                | GroupPowers.ObjectSetForSale
-                                | GroupPowers.ReceiveNotices
-                                | GroupPowers.RemoveMember
-                                | GroupPowers.ReturnGroupOwned
-                                | GroupPowers.ReturnGroupSet
-                                | GroupPowers.ReturnNonGroup
-                                | GroupPowers.RoleProperties
-                                | GroupPowers.SendNotices
-                                | GroupPowers.SetLandingPoint
-                                | GroupPowers.StartProposal
-                                | GroupPowers.VoteOnProposal;
-
-        private bool m_connectorEnabled = false;
-
-        private string m_groupsServerURI = string.Empty;
-
-        private bool m_debugEnabled = false;
-
-        private Dictionary<string, bool> m_pendingRequests = new Dictionary<string,bool>();
-
-        private ExpiringCache<string, OSDMap> m_memoryCache;
-        private int m_cacheTimeout = 30;
-
-        // private IUserAccountService m_accountService = null;
-
-
-        #region Region Module interfaceBase Members
-
-        public string Name
-        {
-            get { return "SimianGroupsServicesConnector"; }
-        }
-
-        // this module is not intended to be replaced, but there should only be 1 of them.
-        public Type ReplaceableInterface
-        {
-            get { return null; }
-        }
-
-        public void Initialise(IConfigSource config)
-        {
-            IConfig groupsConfig = config.Configs["Groups"];
-
-            if (groupsConfig == null)
-            {
-                // Do not run this module by default.
-                return;
-            }
-            else
-            {
-                // if groups aren't enabled, we're not needed.
-                // if we're not specified as the connector to use, then we're not wanted
-                if ((groupsConfig.GetBoolean("Enabled", false) == false)
-                    || (groupsConfig.GetString("ServicesConnectorModule", "XmlRpcGroupsServicesConnector") != Name))
-                {
-                    m_connectorEnabled = false;
-                    return;
-                }
-
-                m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
-
-                m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
-                if (string.IsNullOrEmpty(m_groupsServerURI))
-                {
-                    m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]");
-                    m_connectorEnabled = false;
-                    return;
-                }
-
-
-                m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
-                if (m_cacheTimeout == 0)
-                {
-                    m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Disabled.");
-                }
-                else
-                {
-                    m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout);
-                }
-
-
-
-                m_memoryCache = new ExpiringCache<string,OSDMap>();
-
-
-                // If we got all the config options we need, lets start'er'up
-                m_connectorEnabled = true;
-
-                m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
-
-            }
-        }
-
-        public void Close()
-        {
-        }
-
-        public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
-        {
-            if (m_connectorEnabled)
-            {
-                scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
-            }
-        }
-
-        public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
-        {
-            if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
-            {
-                scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
-            }
-        }
-
-        public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
-        {
-            // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info
-            // scene.EventManager.OnNewClient += OnNewClient;
-        }
-
-        #endregion
-
-        #region ISharedRegionModule Members
-
-        public void PostInitialise()
-        {
-            // NoOp
-        }
-
-        #endregion
-
-
-
-
-        #region IGroupsServicesConnector Members
-
-        /// <summary>
-        /// 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.
-        /// </summary>
-        public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
-                                int membershipFee, bool openEnrollment, bool allowPublish,
-                                bool maturePublish, UUID founderID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            UUID GroupID     = UUID.Random();
-            UUID OwnerRoleID = UUID.Random();
-
-            OSDMap GroupInfoMap = new OSDMap();
-            GroupInfoMap["Charter"] = OSD.FromString(charter);
-            GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList);
-            GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID);
-            GroupInfoMap["MembershipFee"] = OSD.FromInteger(0);
-            GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
-            GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish);
-            GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish);
-            GroupInfoMap["FounderID"] = OSD.FromUUID(founderID);
-            GroupInfoMap["EveryonePowers"] = OSD.FromULong((ulong)m_DefaultEveryonePowers);
-            GroupInfoMap["OwnerRoleID"] = OSD.FromUUID(OwnerRoleID);
-            GroupInfoMap["OwnersPowers"] = OSD.FromULong((ulong)m_DefaultOwnerPowers);
-
-            if (SimianAddGeneric(GroupID, "Group", name, GroupInfoMap))
-            {
-                AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers);
-                AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers);
-
-                AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID);
-
-                return GroupID;
-            }
-            else
-            {
-                return UUID.Zero;
-            }
-        }
-
-
-        public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
-                                UUID insigniaID, int membershipFee, bool openEnrollment,
-                                bool allowPublish, bool maturePublish)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-            // TODO: Check to make sure requestingAgentID has permission to update group
-
-            string GroupName;
-            OSDMap GroupInfoMap;
-            if (SimianGetFirstGenericEntry(groupID, "GroupInfo", out GroupName, out GroupInfoMap))
-            {
-                GroupInfoMap["Charter"] = OSD.FromString(charter);
-                GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList);
-                GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID);
-                GroupInfoMap["MembershipFee"] = OSD.FromInteger(0);
-                GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
-                GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish);
-                GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish);
-
-                SimianAddGeneric(groupID, "Group", GroupName, GroupInfoMap);
-            }
-
-        }
-
-
-        public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
-                                 string title, ulong powers)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap GroupRoleInfo = new OSDMap();
-            GroupRoleInfo["Name"] = OSD.FromString(name);
-            GroupRoleInfo["Description"] = OSD.FromString(description);
-            GroupRoleInfo["Title"] = OSD.FromString(title);
-            GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers);
-
-            // TODO: Add security, make sure that requestingAgentID has permision to add roles
-            SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo);
-        }
-
-        public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            // TODO: Add security
-
-            // Can't delete the Everyone Role
-            if (roleID != UUID.Zero)
-            {
-                // Remove all GroupRole Members from Role
-                Dictionary<UUID, OSDMap> GroupRoleMembers;
-                string GroupRoleMemberType = "GroupRole" + groupID.ToString();
-                if (SimianGetGenericEntries(GroupRoleMemberType, roleID.ToString(), out GroupRoleMembers))
-                {
-                    foreach (UUID UserID in GroupRoleMembers.Keys)
-                    {
-                        EnsureRoleNotSelectedByMember(groupID, roleID, UserID);
-
-                        SimianRemoveGenericEntry(UserID, GroupRoleMemberType, roleID.ToString());
-                    }
-                }
-
-                // Remove role
-                SimianRemoveGenericEntry(groupID, "GroupRole", roleID.ToString());
-            }
-        }
-
-
-        public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
-                                    string title, ulong powers)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            // TODO: Security, check that requestingAgentID is allowed to update group roles
-
-            OSDMap GroupRoleInfo;
-            if (SimianGetGenericEntry(groupID, "GroupRole", roleID.ToString(), out GroupRoleInfo))
-            {
-                if (name != null)
-                {
-                    GroupRoleInfo["Name"] = OSD.FromString(name);
-                }
-                if (description != null)
-                {
-                    GroupRoleInfo["Description"] = OSD.FromString(description);
-                }
-                if (title != null)
-                {
-                    GroupRoleInfo["Title"] = OSD.FromString(title);
-                }
-                GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers);
-
-            }
-
-
-            SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo);
-        }
-
-        public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap GroupInfoMap = null;
-            if (groupID != UUID.Zero)
-            {
-                if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out GroupInfoMap))
-                {
-                    return null;
-                }
-            }
-            else if (!string.IsNullOrEmpty(groupName))
-            {
-                if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap))
-                {
-                    return null;
-                }
-            }
-
-            GroupRecord GroupInfo = new GroupRecord();
-
-            GroupInfo.GroupID = groupID;
-            GroupInfo.GroupName = groupName;
-            GroupInfo.Charter = GroupInfoMap["Charter"].AsString();
-            GroupInfo.ShowInList = GroupInfoMap["ShowInList"].AsBoolean();
-            GroupInfo.GroupPicture = GroupInfoMap["InsigniaID"].AsUUID();
-            GroupInfo.MembershipFee = GroupInfoMap["MembershipFee"].AsInteger();
-            GroupInfo.OpenEnrollment = GroupInfoMap["OpenEnrollment"].AsBoolean();
-            GroupInfo.AllowPublish = GroupInfoMap["AllowPublish"].AsBoolean();
-            GroupInfo.MaturePublish = GroupInfoMap["MaturePublish"].AsBoolean();
-            GroupInfo.FounderID = GroupInfoMap["FounderID"].AsUUID();
-            GroupInfo.OwnerRoleID = GroupInfoMap["OwnerRoleID"].AsUUID();
-
-            return GroupInfo;
-
-        }
-
-        public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID groupID, UUID memberID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap groupProfile;
-            string groupName;
-            if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out groupProfile))
-            {
-                // GroupProfileData is not nullable
-                return new GroupProfileData();
-            }
-
-            GroupProfileData MemberGroupProfile = new GroupProfileData();
-            MemberGroupProfile.GroupID = groupID;
-            MemberGroupProfile.Name = groupName;
-
-            if (groupProfile["Charter"] != null)
-            {
-                MemberGroupProfile.Charter = groupProfile["Charter"].AsString();
-            }
-
-            MemberGroupProfile.ShowInList = groupProfile["ShowInList"].AsString() == "1";
-            MemberGroupProfile.InsigniaID = groupProfile["InsigniaID"].AsUUID();
-            MemberGroupProfile.MembershipFee = groupProfile["MembershipFee"].AsInteger();
-            MemberGroupProfile.OpenEnrollment = groupProfile["OpenEnrollment"].AsBoolean();
-            MemberGroupProfile.AllowPublish = groupProfile["AllowPublish"].AsBoolean();
-            MemberGroupProfile.MaturePublish = groupProfile["MaturePublish"].AsBoolean();
-            MemberGroupProfile.FounderID = groupProfile["FounderID"].AsUUID();;
-            MemberGroupProfile.OwnerRole = groupProfile["OwnerRoleID"].AsUUID();
-
-            Dictionary<UUID, OSDMap> Members;
-            if (SimianGetGenericEntries("GroupMember",groupID.ToString(), out Members))
-            {
-                MemberGroupProfile.GroupMembershipCount = Members.Count;
-            }
-
-            Dictionary<string, OSDMap> Roles;
-            if (SimianGetGenericEntries(groupID, "GroupRole", out Roles))
-            {
-                MemberGroupProfile.GroupRolesCount = Roles.Count;
-            }
-
-            // TODO: Get Group Money balance from somewhere
-            // group.Money = 0;
-
-            GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, memberID, groupID);
-
-            MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
-            MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
-
-            return MemberGroupProfile;
-        }
-
-        public void SetAgentActiveGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap ActiveGroup = new OSDMap();
-            ActiveGroup.Add("GroupID", OSD.FromUUID(groupID));
-            SimianAddGeneric(agentID, "Group", "ActiveGroup", ActiveGroup);
-        }
-
-        public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap GroupMemberInfo;
-            if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo))
-            {
-                GroupMemberInfo = new OSDMap();
-            }
-
-            GroupMemberInfo["SelectedRoleID"] = OSD.FromUUID(roleID);
-            SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo);
-        }
-
-        public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap GroupMemberInfo;
-            if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo))
-            {
-                GroupMemberInfo = new OSDMap();
-            }
-
-            GroupMemberInfo["AcceptNotices"] = OSD.FromBoolean(acceptNotices);
-            GroupMemberInfo["ListInProfile"] = OSD.FromBoolean(listInProfile);
-            GroupMemberInfo["Contribution"] = OSD.FromInteger(0);
-            GroupMemberInfo["SelectedRole"] = OSD.FromUUID(UUID.Zero);
-            SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo);
-        }
-
-        public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap Invite = new OSDMap();
-            Invite["AgentID"] = OSD.FromUUID(agentID);
-            Invite["RoleID"] = OSD.FromUUID(roleID);
-
-            SimianAddGeneric(groupID, "GroupMemberInvite", inviteID.ToString(), Invite);
-        }
-
-        public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap GroupMemberInvite;
-            UUID GroupID;
-            if (!SimianGetFirstGenericEntry("GroupMemberInvite", inviteID.ToString(), out GroupID, out GroupMemberInvite))
-            {
-                return null;
-            }
-
-            GroupInviteInfo inviteInfo = new GroupInviteInfo();
-            inviteInfo.InviteID = inviteID;
-            inviteInfo.GroupID = GroupID;
-            inviteInfo.AgentID = GroupMemberInvite["AgentID"].AsUUID();
-            inviteInfo.RoleID = GroupMemberInvite["RoleID"].AsUUID();
-
-            return inviteInfo;
-        }
-
-        public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            GroupInviteInfo invite = GetAgentToGroupInvite(requestingAgentID, inviteID);
-            SimianRemoveGenericEntry(invite.GroupID, "GroupMemberInvite", inviteID.ToString());
-        }
-
-        public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            // Setup Agent/Group information
-            SetAgentGroupInfo(requestingAgentID, AgentID, GroupID, true, true);
-
-            // Add agent to Everyone Group
-            AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, UUID.Zero);
-
-            // Add agent to Specified Role
-            AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
-
-            // Set selected role in this group to specified role
-            SetAgentActiveGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
-        }
-
-        public void RemoveAgentFromGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            // If current active group is the group the agent is being removed from, change their group to UUID.Zero
-            GroupMembershipData memberActiveMembership = GetAgentActiveMembership(requestingAgentID, agentID);
-            if (memberActiveMembership.GroupID == groupID)
-            {
-                SetAgentActiveGroup(agentID, agentID, UUID.Zero);
-            }
-
-            // Remove Group Member information for this group
-            SimianRemoveGenericEntry(agentID, "GroupMember", groupID.ToString());
-
-            // By using a Simian Generics Type consisting of a prefix and a groupID,
-            // combined with RoleID as key allows us to get a list of roles a particular member
-            // of a group is assigned to.
-            string GroupRoleMemberType = "GroupRole" + groupID.ToString();
-
-            // Take Agent out of all other group roles
-            Dictionary<string, OSDMap> GroupRoles;
-            if (SimianGetGenericEntries(agentID, GroupRoleMemberType, out GroupRoles))
-            {
-                foreach (string roleID in GroupRoles.Keys)
-                {
-                    SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID);
-                }
-            }
-        }
-
-        public void AddAgentToGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            SimianAddGeneric(agentID, "GroupRole" + groupID.ToString(), roleID.ToString(), new OSDMap());
-        }
-
-        public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            // Cannot remove members from the Everyone Role
-            if (roleID != UUID.Zero)
-            {
-                EnsureRoleNotSelectedByMember(groupID, roleID, agentID);
-
-                string GroupRoleMemberType = "GroupRole" + groupID.ToString();
-                SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID.ToString());
-            }
-        }
-
-        public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetGenerics" },
-                { "Type", "Group" },
-                { "Key", search },
-                { "Fuzzy", "1" }
-            };
-
-
-            OSDMap response = CachedPostRequest(requestArgs);
-            if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
-            {
-                OSDArray entryArray = (OSDArray)response["Entries"];
-                foreach (OSDMap entryMap in entryArray)
-                {
-                    DirGroupsReplyData data = new DirGroupsReplyData();
-                    data.groupID = entryMap["OwnerID"].AsUUID();
-                    data.groupName = entryMap["Key"].AsString();
-
-                    // TODO: is there a better way to do this?
-                    Dictionary<UUID, OSDMap> Members;
-                    if (SimianGetGenericEntries("GroupMember", data.groupID.ToString(), out Members))
-                    {
-                        data.members = Members.Count;
-                    }
-                    else
-                    {
-                        data.members = 0;
-                    }
-
-                    // TODO: sort results?
-                    // data.searchOrder = order;
-
-                    findings.Add(data);
-                }
-            }
-
-            return findings;
-        }
-
-        public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID agentID, UUID groupID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            GroupMembershipData data = null;
-//            bool foundData = false;
-
-            OSDMap UserGroupMemberInfo;
-            if (SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo))
-            {
-                data = new GroupMembershipData();
-                data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean();
-                data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger();
-                data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean();
-                data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID();
-
-                ///////////////////////////////
-                // Agent Specific Information:
-                //
-                OSDMap UserActiveGroup;
-                if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
-                {
-                    data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
-                }
-
-                ///////////////////////////////
-                // Role Specific Information:
-                //
-                OSDMap GroupRoleInfo;
-                if (SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo))
-                {
-                    data.GroupTitle = GroupRoleInfo["Title"].AsString();
-                    data.GroupPowers = GroupRoleInfo["Powers"].AsULong();
-                }
-
-                ///////////////////////////////
-                // Group Specific Information:
-                //
-                OSDMap GroupInfo;
-                string GroupName;
-                if (SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo))
-                {
-                    data.GroupID = groupID;
-                    data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean();
-                    data.Charter = GroupInfo["Charter"].AsString();
-                    data.FounderID = GroupInfo["FounderID"].AsUUID();
-                    data.GroupName = GroupName;
-                    data.GroupPicture = GroupInfo["InsigniaID"].AsUUID();
-                    data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean();
-                    data.MembershipFee = GroupInfo["MembershipFee"].AsInteger();
-                    data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean();
-                    data.ShowInList = GroupInfo["ShowInList"].AsBoolean();
-                }
-            }
-
-            return data;
-        }
-
-        public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID agentID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            UUID GroupID = UUID.Zero;
-            OSDMap UserActiveGroup;
-            if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
-            {
-                GroupID = UserActiveGroup["GroupID"].AsUUID();
-            }
-
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  Active GroupID : {0}", GroupID.ToString());
-            return GetAgentGroupMembership(requestingAgentID, agentID, GroupID);
-        }
-
-        public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID agentID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            List<GroupMembershipData> memberships = new List<GroupMembershipData>();
-
-            Dictionary<string,OSDMap> GroupMemberShips;
-            if (SimianGetGenericEntries(agentID, "GroupMember", out GroupMemberShips))
-            {
-                foreach (string key in GroupMemberShips.Keys)
-                {
-                    memberships.Add(GetAgentGroupMembership(requestingAgentID, agentID, UUID.Parse(key)));
-                }
-            }
-
-            return memberships;
-        }
-
-        public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID agentID, UUID groupID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            List<GroupRolesData> Roles = new List<GroupRolesData>();
-
-            Dictionary<string, OSDMap> GroupRoles;
-            if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
-            {
-                Dictionary<string, OSDMap> MemberRoles;
-                if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles))
-                {
-                    foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles)
-                    {
-                        GroupRolesData data = new GroupRolesData();
-                        data.RoleID = UUID.Parse(kvp.Key);
-                        data.Name = GroupRoles[kvp.Key]["Name"].AsString();
-                        data.Description = GroupRoles[kvp.Key]["Description"].AsString();
-                        data.Title = GroupRoles[kvp.Key]["Title"].AsString();
-                        data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong();
-
-                        Roles.Add(data);
-                    }
-                }
-            }
-            return Roles;
-        }
-
-        public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID groupID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            List<GroupRolesData> Roles = new List<GroupRolesData>();
-
-            Dictionary<string, OSDMap> GroupRoles;
-            if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
-            {
-                foreach (KeyValuePair<string, OSDMap> role in GroupRoles)
-                {
-                    GroupRolesData data = new GroupRolesData();
-
-                    data.RoleID = UUID.Parse(role.Key);
-
-                    data.Name = role.Value["Name"].AsString();
-                    data.Description = role.Value["Description"].AsString();
-                    data.Title = role.Value["Title"].AsString();
-                    data.Powers = role.Value["Powers"].AsULong();
-
-                    Dictionary<UUID, OSDMap> GroupRoleMembers;
-                    if (SimianGetGenericEntries("GroupRole" + groupID.ToString(), role.Key, out GroupRoleMembers))
-                    {
-                        data.Members = GroupRoleMembers.Count;
-                    }
-                    else
-                    {
-                        data.Members = 0;
-                    }
-
-                    Roles.Add(data);
-                }
-            }
-
-            return Roles;
-
-        }
-
-
-
-        public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            List<GroupMembersData> members = new List<GroupMembersData>();
-
-            OSDMap GroupInfo;
-            string GroupName;
-            UUID GroupOwnerRoleID = UUID.Zero;
-            if (!SimianGetFirstGenericEntry(GroupID, "Group", out GroupName, out GroupInfo))
-            {
-                return members;
-            }
-            GroupOwnerRoleID = GroupInfo["OwnerRoleID"].AsUUID();
-
-            // Locally cache group roles, since we'll be needing this data for each member
-            Dictionary<string,OSDMap> GroupRoles;
-            SimianGetGenericEntries(GroupID, "GroupRole", out GroupRoles);
-
-            // Locally cache list of group owners
-            Dictionary<UUID, OSDMap> GroupOwners;
-            SimianGetGenericEntries("GroupRole" + GroupID.ToString(), GroupOwnerRoleID.ToString(), out GroupOwners);
-
-
-            Dictionary<UUID, OSDMap> GroupMembers;
-            if (SimianGetGenericEntries("GroupMember", GroupID.ToString(), out GroupMembers))
-            {
-                foreach (KeyValuePair<UUID, OSDMap> member in GroupMembers)
-                {
-                    GroupMembersData data = new GroupMembersData();
-
-                    data.AgentID = member.Key;
-
-                    UUID SelectedRoleID = member.Value["SelectedRoleID"].AsUUID();
-
-                    data.AcceptNotices = member.Value["AcceptNotices"].AsBoolean();
-                    data.ListInProfile = member.Value["ListInProfile"].AsBoolean();
-                    data.Contribution = member.Value["Contribution"].AsInteger();
-
-                    data.IsOwner = GroupOwners.ContainsKey(member.Key);
-
-                    OSDMap GroupRoleInfo = GroupRoles[SelectedRoleID.ToString()];
-                    data.Title = GroupRoleInfo["Title"].AsString();
-                    data.AgentPowers = GroupRoleInfo["Powers"].AsULong();
-
-                    members.Add(data);
-                }
-            }
-
-            return members;
-
-        }
-
-        public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID groupID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
-
-            Dictionary<string, OSDMap> GroupRoles;
-            if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
-            {
-                foreach (KeyValuePair<string, OSDMap> Role in GroupRoles)
-                {
-                    Dictionary<UUID, OSDMap> GroupRoleMembers;
-                    if (SimianGetGenericEntries("GroupRole"+groupID.ToString(), Role.Key, out GroupRoleMembers))
-                    {
-                        foreach (KeyValuePair<UUID, OSDMap> GroupRoleMember in GroupRoleMembers)
-                        {
-                            GroupRoleMembersData data = new GroupRoleMembersData();
-
-                            data.MemberID = GroupRoleMember.Key;
-                            data.RoleID = UUID.Parse(Role.Key);
-
-                            members.Add(data);
-                        }
-                    }
-                }
-            }
-
-            return members;
-        }
-
-        public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            List<GroupNoticeData> values = new List<GroupNoticeData>();
-
-            Dictionary<string, OSDMap> Notices;
-            if (SimianGetGenericEntries(GroupID, "GroupNotice", out Notices))
-            {
-                foreach (KeyValuePair<string, OSDMap> Notice in Notices)
-                {
-                    GroupNoticeData data = new GroupNoticeData();
-                    data.NoticeID = UUID.Parse(Notice.Key);
-                    data.Timestamp = Notice.Value["TimeStamp"].AsUInteger();
-                    data.FromName = Notice.Value["FromName"].AsString();
-                    data.Subject = Notice.Value["Subject"].AsString();
-                    data.HasAttachment = Notice.Value["BinaryBucket"].AsBinary().Length > 0;
-
-                    //TODO: Figure out how to get this
-                    data.AssetType = 0;
-
-                    values.Add(data);
-                }
-            }
-
-            return values;
-
-        }
-        public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap GroupNotice;
-            UUID GroupID;
-            if (SimianGetFirstGenericEntry("GroupNotice", noticeID.ToString(), out GroupID, out GroupNotice))
-            {
-                GroupNoticeInfo data = new GroupNoticeInfo();
-                data.GroupID = GroupID;
-                data.Message = GroupNotice["Message"].AsString();
-                data.BinaryBucket = GroupNotice["BinaryBucket"].AsBinary();
-                data.noticeData.NoticeID = noticeID;
-                data.noticeData.Timestamp = GroupNotice["TimeStamp"].AsUInteger();
-                data.noticeData.FromName = GroupNotice["FromName"].AsString();
-                data.noticeData.Subject = GroupNotice["Subject"].AsString();
-                data.noticeData.HasAttachment = data.BinaryBucket.Length > 0;
-                data.noticeData.AssetType = 0;
-
-                if (data.Message == null)
-                {
-                    data.Message = string.Empty;
-                }
-
-                return data;
-            }
-            return null;
-        }
-        public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            OSDMap Notice = new OSDMap();
-            Notice["TimeStamp"] = OSD.FromUInteger((uint)Util.UnixTimeSinceEpoch());
-            Notice["FromName"] = OSD.FromString(fromName);
-            Notice["Subject"] = OSD.FromString(subject);
-            Notice["Message"] = OSD.FromString(message);
-            Notice["BinaryBucket"] = OSD.FromBinary(binaryBucket);
-
-            SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice);
-
-        }
-        #endregion
-
-        #region GroupSessionTracking
-
-        public void ResetAgentGroupChatSessions(UUID agentID)
-        {
-            Dictionary<string, OSDMap> agentSessions;
-
-            if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions))
-            {
-                foreach (string GroupID in agentSessions.Keys)
-                {
-                    SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID);
-                }
-            }
-
-            if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions))
-            {
-                foreach (string GroupID in agentSessions.Keys)
-                {
-                    SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID);
-                }
-            }
-        }
-
-        public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
-        {
-            OSDMap session;
-            return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
-        }
-
-        public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
-        {
-            SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap());
-        }
-
-        public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
-        {
-            SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap());
-        }
-
-        public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
-        {
-            OSDMap session;
-            return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
-        }
-
-        #endregion
-
-        private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
-
-            // If member's SelectedRole is roleID, change their selected role to Everyone
-            // before removing them from the role
-            OSDMap UserGroupInfo;
-            if (SimianGetGenericEntry(userID, "GroupMember", groupID.ToString(), out UserGroupInfo))
-            {
-                if (UserGroupInfo["SelectedRoleID"].AsUUID() == roleID)
-                {
-                    UserGroupInfo["SelectedRoleID"] = OSD.FromUUID(UUID.Zero);
-                }
-                SimianAddGeneric(userID, "GroupMember", groupID.ToString(), UserGroupInfo);
-            }
-        }
-
-
-        #region Simian Util Methods
-        private bool SimianAddGeneric(UUID ownerID, string type, string key, OSDMap map)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
-
-            string value = OSDParser.SerializeJsonString(map);
-
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  value: {0}", value);
-
-            NameValueCollection RequestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddGeneric" },
-                { "OwnerID", ownerID.ToString() },
-                { "Type", type },
-                { "Key", key },
-                { "Value", value}
-            };
-
-
-            OSDMap Response = CachedPostRequest(RequestArgs);
-            if (Response["Success"].AsBoolean())
-            {
-                return true;
-            }
-            else
-            {
-                m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, Response["Message"]);
-                return false;
-            }
-        }
-
-        /// <summary>
-        /// Returns the first of possibly many entries for Owner/Type pair
-        /// </summary>
-        private bool SimianGetFirstGenericEntry(UUID ownerID, string type, out string key, out OSDMap map)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type);
-
-            NameValueCollection RequestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetGenerics" },
-                { "OwnerID", ownerID.ToString() },
-                { "Type", type }
-            };
-
-
-            OSDMap Response = CachedPostRequest(RequestArgs);
-            if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
-            {
-                OSDArray entryArray = (OSDArray)Response["Entries"];
-                if (entryArray.Count >= 1)
-                {
-                    OSDMap entryMap = entryArray[0] as OSDMap;
-                    key = entryMap["Key"].AsString();
-                    map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
-
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  Generics Result {0}", entryMap["Value"].AsString());
-
-                    return true;
-                }
-                else
-                {
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  No Generics Results");
-                }
-            }
-            else
-            {
-                m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
-            }
-            key = null;
-            map = null;
-            return false;
-        }
-        private bool SimianGetFirstGenericEntry(string type, string key, out UUID ownerID, out OSDMap map)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
-
-
-            NameValueCollection RequestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetGenerics" },
-                { "Type", type },
-                { "Key", key}
-            };
-
-
-            OSDMap Response = CachedPostRequest(RequestArgs);
-            if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
-            {
-                OSDArray entryArray = (OSDArray)Response["Entries"];
-                if (entryArray.Count >= 1)
-                {
-                    OSDMap entryMap = entryArray[0] as OSDMap;
-                    ownerID = entryMap["OwnerID"].AsUUID();
-                    map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
-
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  Generics Result {0}", entryMap["Value"].AsString());
-
-                    return true;
-                }
-                else
-                {
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  No Generics Results");
-                }
-            }
-            else
-            {
-                m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
-            }
-            ownerID = UUID.Zero;
-            map = null;
-            return false;
-        }
-
-        private bool SimianGetGenericEntry(UUID ownerID, string type, string key, out OSDMap map)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
-
-            NameValueCollection RequestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetGenerics" },
-                { "OwnerID", ownerID.ToString() },
-                { "Type", type },
-                { "Key", key}
-            };
-
-
-            OSDMap Response = CachedPostRequest(RequestArgs);
-            if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
-            {
-                OSDArray entryArray = (OSDArray)Response["Entries"];
-                if (entryArray.Count == 1)
-                {
-                    OSDMap entryMap = entryArray[0] as OSDMap;
-                    key = entryMap["Key"].AsString();
-                    map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
-
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  Generics Result {0}", entryMap["Value"].AsString());
-
-                    return true;
-                }
-                else
-                {
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  No Generics Results");
-                }
-            }
-            else
-            {
-                m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
-            }
-            map = null;
-            return false;
-        }
-
-        private bool SimianGetGenericEntries(UUID ownerID, string type, out Dictionary<string, OSDMap> maps)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name,ownerID, type);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetGenerics" },
-                { "OwnerID", ownerID.ToString() },
-                { "Type", type }
-            };
-
-
-
-            OSDMap response = CachedPostRequest(requestArgs);
-            if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
-            {
-                maps = new Dictionary<string, OSDMap>();
-
-                OSDArray entryArray = (OSDArray)response["Entries"];
-                foreach (OSDMap entryMap in entryArray)
-                {
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  Generics Result {0}", entryMap["Value"].AsString());
-                    maps.Add(entryMap["Key"].AsString(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
-                }
-                if (maps.Count == 0)
-                {
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  No Generics Results");
-                }
-
-                return true;
-            }
-            else
-            {
-                maps = null;
-                m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", response["Message"]);
-            }
-            return false;
-        }
-        private bool SimianGetGenericEntries(string type, string key, out Dictionary<UUID, OSDMap> maps)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetGenerics" },
-                { "Type", type },
-                { "Key", key }
-            };
-
-
-
-            OSDMap response = CachedPostRequest(requestArgs);
-            if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
-            {
-                maps = new Dictionary<UUID, OSDMap>();
-
-                OSDArray entryArray = (OSDArray)response["Entries"];
-                foreach (OSDMap entryMap in entryArray)
-                {
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  Generics Result {0}", entryMap["Value"].AsString());
-                    maps.Add(entryMap["OwnerID"].AsUUID(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
-                }
-                if (maps.Count == 0)
-                {
-                    if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  No Generics Results");
-                }
-                return true;
-            }
-            else
-            {
-                maps = null;
-                m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR]: Error retrieving group info ({0})", response["Message"]);
-            }
-            return false;
-        }
-
-        private bool SimianRemoveGenericEntry(UUID ownerID, string type, string key)
-        {
-            if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "RemoveGeneric" },
-                { "OwnerID", ownerID.ToString() },
-                { "Type", type },
-                { "Key", key }
-            };
-
-
-            OSDMap response = CachedPostRequest(requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                return true;
-            }
-            else
-            {
-                m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, response["Message"]);
-                return false;
-            }
-        }
-        #endregion
-
-        #region CheesyCache
-        OSDMap CachedPostRequest(NameValueCollection requestArgs)
-        {
-            // Immediately forward the request if the cache is disabled.
-            if (m_cacheTimeout == 0)
-            {
-                m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: cache is disabled");
-                return WebUtil.PostToService(m_groupsServerURI, requestArgs);
-            }
-
-            // Check if this is an update or a request
-            if (requestArgs["RequestMethod"] == "RemoveGeneric"
-                || requestArgs["RequestMethod"] == "AddGeneric")
-            {
-                m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: clearing generics cache");
-
-                // Any and all updates cause the cache to clear
-                m_memoryCache.Clear();
-
-                // Send update to server, return the response without caching it
-                return WebUtil.PostToService(m_groupsServerURI, requestArgs);
-            }
-
-            // If we're not doing an update, we must be requesting data
-
-            // Create the cache key for the request and see if we have it cached
-            string CacheKey = WebUtil.BuildQueryString(requestArgs);
-
-            // This code uses a leader/follower pattern. On a cache miss, the request is added
-            // to a queue; the first thread to add it to the queue completes the request while
-            // follow on threads busy wait for the results, this situation seems to happen
-            // often when checking permissions
-            while (true)
-            {
-                OSDMap response = null;
-                bool firstRequest = false;
-
-                lock (m_memoryCache)
-                {
-                    if (m_memoryCache.TryGetValue(CacheKey, out response))
-                        return response;
-
-                    if (! m_pendingRequests.ContainsKey(CacheKey))
-                    {
-                        m_pendingRequests.Add(CacheKey,true);
-                        firstRequest = true;
-                    }
-                }
-
-                if (firstRequest)
-                {
-                    // if it wasn't in the cache, pass the request to the Simian Grid Services
-                    try
-                    {
-                        response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
-                    }
-                    catch (Exception)
-                    {
-                        m_log.ErrorFormat("[SIMIAN GROUPS CONNECTOR]: request failed {0}", CacheKey);
-                    }
-
-                    // and cache the response
-                    lock (m_memoryCache)
-                    {
-                        m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout));
-                        m_pendingRequests.Remove(CacheKey);
-                    }
-
-                    return response;
-                }
-
-                Thread.Sleep(50); // waiting for a web request to complete, 50msecs is reasonable
-            }
-
-            // if (!m_memoryCache.TryGetValue(CacheKey, out response))
-            // {
-            //     m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: query not in the cache");
-            //     Util.PrintCallStack();
-
-            //     // if it wasn't in the cache, pass the request to the Simian Grid Services
-            //     response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
-
-            //     // and cache the response
-            //     m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout));
-            // }
-
-            // // return cached response
-            // return response;
-        }
-        #endregion
-
-    }
-
-}
-

+ 1 - 10
OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs

@@ -35,7 +35,6 @@ using System.Web;
 using OpenSim.Framework;
 using OpenSim.Services.Interfaces;
 using OpenSim.Services.Connectors.Hypergrid;
-using OpenSim.Services.Connectors.SimianGrid;
 using OpenMetaverse;
 
 namespace OpenSim.Services.Connectors
@@ -97,15 +96,7 @@ namespace OpenSim.Services.Connectors
                 {
                     // Still not as flexible as I would like this to be,
                     // but good enough for now
-                    string connectorType = new HeloServicesConnector(url).Helo();
-                    m_log.DebugFormat("[HG ASSET SERVICE]: HELO returned {0}", connectorType);
-                    if (connectorType == "opensim-simian")
-                    {
-                        connector = new SimianAssetServiceConnector(url);
-                    }
-                    else
-                        connector = new AssetServicesConnector(url);
-
+                    connector = new AssetServicesConnector(url);
                     m_connectors.Add(url, connector);
                 }
             }

+ 0 - 100
OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs

@@ -1,100 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Reflection;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-using OpenMetaverse;
-using log4net;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    public class SimianActivityDetector
-    {
-        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
-        private IGridUserService m_GridUserService;
-
-        public SimianActivityDetector(IGridUserService guService)
-        {
-            m_GridUserService = guService;
-            m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Started");
-        }
-
-        public void AddRegion(Scene scene)
-        {
-            // For now the only events we listen to are these
-            // But we could trigger the position update more often
-            scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
-            scene.EventManager.OnNewClient += OnNewClient;
-            scene.EventManager.OnAvatarEnteringNewParcel += OnEnteringNewParcel;
-        }
-
-        public void RemoveRegion(Scene scene)
-        {
-            scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent;
-            scene.EventManager.OnNewClient -= OnNewClient;
-            scene.EventManager.OnAvatarEnteringNewParcel -= OnEnteringNewParcel;
-        }
-
-        public void OnMakeRootAgent(ScenePresence sp)
-        {
-            m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
-            Util.FireAndForget(delegate(object o)
-            {
-                m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
-            }, null, "SimianActivityDetector.SetLastPositionOnMakeRootAgent");
-        }
-
-        public void OnNewClient(IClientAPI client)
-        {
-            client.OnConnectionClosed += OnConnectionClose;
-        }
-
-        public void OnConnectionClose(IClientAPI client)
-        {
-            if (client.SceneAgent.IsChildAgent)
-                return;
-
-//            m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
-            m_GridUserService.LoggedOut(
-                client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID,
-                client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat);
-        }
-
-        void OnEnteringNewParcel(ScenePresence sp, int localLandID, UUID regionID)
-        {
-            // Asynchronously update the position stored in the session table for this agent
-            Util.FireAndForget(delegate(object o)
-            {
-                m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
-            }, null, "SimianActivityDetector.SetLastPositionOnEnteringNewParcel");
-        }
-    }
-}

+ 0 - 693
OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs

@@ -1,693 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.IO;
-using System.Net;
-using System.Reflection;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// Connects to the SimianGrid asset service
-    /// </summary>
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianAssetServiceConnector")]
-    public class SimianAssetServiceConnector : IAssetService, ISharedRegionModule
-    {
-        private static readonly ILog m_log =
-                LogManager.GetLogger(
-                MethodBase.GetCurrentMethod().DeclaringType);
-        private static string ZeroID = UUID.Zero.ToString();
-
-        private string m_serverUrl = String.Empty;
-        private IAssetCache m_cache;
-        private bool m_Enabled = false;
-
-        #region ISharedRegionModule
-
-        public Type ReplaceableInterface { get { return null; } }
-        public void RegionLoaded(Scene scene)
-        {
-            if (m_cache == null)
-            {
-                IAssetCache cache = scene.RequestModuleInterface<IAssetCache>();
-                if (cache is ISharedRegionModule)
-                    m_cache = cache;
-            }
-        }
-        public void PostInitialise() { }
-        public void Close() { }
-
-        public SimianAssetServiceConnector() { }
-        public string Name { get { return "SimianAssetServiceConnector"; } }
-        public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAssetService>(this); } }
-        public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAssetService>(this); } }
-
-        #endregion ISharedRegionModule
-
-        public SimianAssetServiceConnector(IConfigSource source)
-        {
-            CommonInit(source);
-        }
-
-        public SimianAssetServiceConnector(string url)
-        {
-            if (!url.EndsWith("/") && !url.EndsWith("="))
-                url = url + '/';
-            m_serverUrl = url;
-        }
-
-        public void Initialise(IConfigSource source)
-        {
-            IConfig moduleConfig = source.Configs["Modules"];
-            if (moduleConfig != null)
-            {
-                string name = moduleConfig.GetString("AssetServices", "");
-                if (name == Name)
-                    CommonInit(source);
-            }
-        }
-
-        private void CommonInit(IConfigSource source)
-        {
-            IConfig gridConfig = source.Configs["AssetService"];
-            if (gridConfig != null)
-            {
-                string serviceUrl = gridConfig.GetString("AssetServerURI");
-                if (!String.IsNullOrEmpty(serviceUrl))
-                {
-                    if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
-                        serviceUrl = serviceUrl + '/';
-                    m_serverUrl = serviceUrl;
-                }
-            }
-
-            if (String.IsNullOrEmpty(m_serverUrl))
-                m_log.Info("[SIMIAN ASSET CONNECTOR]: No AssetServerURI specified, disabling connector");
-            else
-                m_Enabled = true;
-        }
-
-#region IAssetService
-
-        public AssetBase Get(string id)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-            {
-                m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
-                throw new InvalidOperationException();
-            }
-
-            // Cache fetch
-            if (m_cache != null)
-            {
-                AssetBase asset;
-                if (!m_cache.Get(id, out asset))
-                    return null;
-                if (asset != null)
-                    return asset;
-            }
-
-            return SimianGetOperation(id);
-        }
-
-
-        public AssetBase GetCached(string id)
-        {
-            AssetBase asset;
-            if (m_cache != null)
-                m_cache.Get(id, out asset);
-
-            return null;
-        }
-
-        /// <summary>
-        /// Get an asset's metadata
-        /// </summary>
-        /// <param name="id"></param>
-        /// <returns></returns>
-        public AssetMetadata GetMetadata(string id)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-            {
-                m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
-                throw new InvalidOperationException();
-            }
-
-            // Cache fetch
-            if (m_cache != null)
-            {
-                AssetBase asset;
-                if (!m_cache.Get(id, out asset))
-                    return null;
-                if (asset != null)
-                    return asset.Metadata;
-            }
-
-            // return GetRemoteMetadata(id);
-            return SimianGetMetadataOperation(id);
-        }
-
-        public byte[] GetData(string id)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-            {
-                m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
-                throw new InvalidOperationException();
-            }
-
-            AssetBase asset = Get(id);
-
-            if (asset != null)
-                return asset.Data;
-
-            return null;
-        }
-
-        /// <summary>
-        /// Get an asset asynchronously
-        /// </summary>
-        /// <param name="id">The asset id</param>
-        /// <param name="sender">Represents the requester.  Passed back via the handler</param>
-        /// <param name="handler">The handler to call back once the asset has been retrieved</param>
-        /// <returns>True if the id was parseable, false otherwise</returns>
-        public bool Get(string id, Object sender, AssetRetrieved handler)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-            {
-                m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
-                throw new InvalidOperationException();
-            }
-
-            // Cache fetch
-            if (m_cache != null)
-            {
-                AssetBase asset;
-                if (!m_cache.Get(id, out asset))
-                    return false;
-
-                if (asset != null)
-                {
-                    handler(id, sender, asset);
-                    return true;
-                }
-            }
-
-            Util.FireAndForget(
-                delegate(object o)
-                {
-                    AssetBase asset = SimianGetOperation(id);
-                    handler(id, sender, asset);
-                }, null, "SimianAssetServiceConnector.GetFromService"
-            );
-
-            return true;
-        }
-
-        public bool[] AssetsExist(string[] ids)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-            {
-                m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
-                throw new InvalidOperationException();
-            }
-
-            bool[] exist = new bool[ids.Length];
-
-            for (int i = 0; i < ids.Length; i++)
-            {
-                AssetMetadata metadata = GetMetadata(ids[i]);
-                if (metadata != null)
-                    exist[i] = true;
-            }
-
-            return exist;
-        }
-
-        /// <summary>
-        /// Creates a new asset
-        /// </summary>
-        /// Returns a random ID if none is passed into it
-        /// <param name="asset"></param>
-        /// <returns></returns>
-        public string Store(AssetBase asset)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-            {
-                m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
-                throw new InvalidOperationException();
-            }
-
-            bool storedInCache = false;
-
-            // AssetID handling
-            if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID)
-            {
-                asset.FullID = UUID.Random();
-                asset.ID = asset.FullID.ToString();
-            }
-
-            // Cache handling
-            if (m_cache != null)
-            {
-                m_cache.Cache(asset);
-                storedInCache = true;
-            }
-
-            // Local asset handling
-            if (asset.Local)
-            {
-                if (!storedInCache)
-                {
-                    m_log.Error("Cannot store local " + asset.Metadata.ContentType + " asset without an asset cache");
-                    asset.ID = null;
-                    asset.FullID = UUID.Zero;
-                }
-
-                return asset.ID;
-            }
-
-            return SimianStoreOperation(asset);
-        }
-
-        /// <summary>
-        /// Update an asset's content
-        /// </summary>
-        /// Attachments and bare scripts need this!!
-        /// <param name="id"> </param>
-        /// <param name="data"></param>
-        /// <returns></returns>
-        public bool UpdateContent(string id, byte[] data)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-            {
-                m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
-                throw new InvalidOperationException();
-            }
-
-            AssetBase asset = Get(id);
-
-            if (asset == null)
-            {
-                m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset {0} for updating", id);
-                return false;
-            }
-
-            asset.Data = data;
-
-            string result = Store(asset);
-            return !String.IsNullOrEmpty(result);
-        }
-
-        /// <summary>
-        /// Delete an asset
-        /// </summary>
-        /// <param name="id"></param>
-        /// <returns></returns>
-        public bool Delete(string id)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-            {
-                m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
-                throw new InvalidOperationException();
-            }
-
-            if (m_cache != null)
-                m_cache.Expire(id);
-
-            return SimianDeleteOperation(id);
-        }
-
-#endregion IAssetService
-
-#region SimianOperations
-        /// <summary>
-        /// Invokes the xRemoveAsset operation on the simian server to delete an asset
-        /// </summary>
-        /// <param name="id"></param>
-        /// <returns></returns>
-        private bool SimianDeleteOperation(string id)
-        {
-            try
-            {
-                NameValueCollection requestArgs = new NameValueCollection
-                    {
-                            { "RequestMethod", "xRemoveAsset" },
-                            { "AssetID", id }
-                    };
-
-                OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
-                if (! response["Success"].AsBoolean())
-                {
-                    m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString());
-                    return false;
-                }
-
-                return true;
-
-            }
-            catch (Exception ex)
-            {
-                m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset {0}; {1}", id, ex.Message);
-            }
-
-            return false;
-        }
-
-        /// <summary>
-        /// Invokes the xAddAsset operation on the simian server to create or update an asset
-        /// </summary>
-        /// <param name="id"></param>
-        /// <returns></returns>
-        private string SimianStoreOperation(AssetBase asset)
-        {
-            try
-            {
-                NameValueCollection requestArgs = new NameValueCollection
-                    {
-                            { "RequestMethod", "xAddAsset" },
-                            { "ContentType", asset.Metadata.ContentType },
-                            { "EncodedData", Convert.ToBase64String(asset.Data) },
-                            { "AssetID", asset.FullID.ToString() },
-                            { "CreatorID", asset.Metadata.CreatorID },
-                            { "Temporary", asset.Temporary ? "1" : "0" },
-                            { "Name", asset.Name }
-                    };
-
-                OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
-                if (! response["Success"].AsBoolean())
-                {
-                    m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",response["Message"].AsString());
-                    return null;
-                }
-
-                // asset.ID is always set before calling this function
-                return asset.ID;
-
-            }
-            catch (Exception ex)
-            {
-                m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message);
-            }
-
-            return null;
-        }
-
-        /// <summary>
-        /// Invokes the xGetAsset operation on the simian server to get data associated with an asset
-        /// </summary>
-        /// <param name="id"></param>
-        /// <returns></returns>
-        private AssetBase SimianGetOperation(string id)
-        {
-            try
-            {
-                NameValueCollection requestArgs = new NameValueCollection
-                    {
-                            { "RequestMethod", "xGetAsset" },
-                            { "ID", id }
-                    };
-
-                OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
-                if (! response["Success"].AsBoolean())
-                {
-                    m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString());
-                    return null;
-                }
-
-                AssetBase asset = new AssetBase();
-
-                asset.ID = id;
-                asset.Name = String.Empty;
-                asset.Metadata.ContentType = response["ContentType"].AsString(); // this will also set the asset Type property
-                asset.CreatorID = response["CreatorID"].AsString();
-                asset.Data = System.Convert.FromBase64String(response["EncodedData"].AsString());
-                asset.Local = false;
-                asset.Temporary = response["Temporary"];
-
-                return asset;
-            }
-            catch (Exception ex)
-            {
-                m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to retrieve asset {0}; {1}", id, ex.Message);
-            }
-
-            return null;
-        }
-
-        /// <summary>
-        /// Invokes the xGetAssetMetadata operation on the simian server to retrieve metadata for an asset
-        /// This operation is generally used to determine if an asset exists in the database
-        /// </summary>
-        /// <param name="id"></param>
-        /// <returns></returns>
-        private AssetMetadata SimianGetMetadataOperation(string id)
-        {
-            try
-            {
-                NameValueCollection requestArgs = new NameValueCollection
-                    {
-                            { "RequestMethod", "xGetAssetMetadata" },
-                            { "ID", id }
-                    };
-
-                OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
-                if (! response["Success"].AsBoolean())
-                {
-                    // this is not really an error, this call is used to test existence
-                    // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString());
-                    return null;
-                }
-
-                AssetMetadata metadata = new AssetMetadata();
-                metadata.ID = id;
-                metadata.ContentType = response["ContentType"].AsString();
-                metadata.CreatorID = response["CreatorID"].AsString();
-                metadata.Local = false;
-                metadata.Temporary = response["Temporary"];
-
-                string lastModifiedStr = response["Last-Modified"].AsString();
-                if (! String.IsNullOrEmpty(lastModifiedStr))
-                {
-                    DateTime lastModified;
-                    if (DateTime.TryParse(lastModifiedStr, out lastModified))
-                        metadata.CreationDate = lastModified;
-                }
-
-                return metadata;
-            }
-            catch (Exception ex)
-            {
-                m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to get asset metadata; {0}", ex.Message);
-            }
-
-            return null;
-        }
-#endregion
-
-        // private AssetMetadata GetRemoteMetadata(string id)
-        // {
-        //     Uri url;
-        //     AssetMetadata metadata = null;
-
-        //     // Determine if id is an absolute URL or a grid-relative UUID
-        //     if (!Uri.TryCreate(id, UriKind.Absolute, out url))
-        //         url = new Uri(m_serverUrl + id);
-
-        //     try
-        //     {
-        //         HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
-        //         request.Method = "HEAD";
-
-        //         using (WebResponse response = request.GetResponse())
-        //         {
-        //             using (Stream responseStream = response.GetResponseStream())
-        //             {
-        //                 // Create the metadata object
-        //                 metadata = new AssetMetadata();
-        //                 metadata.ContentType = response.ContentType;
-        //                 metadata.ID = id;
-
-        //                 UUID uuid;
-        //                 if (UUID.TryParse(id, out uuid))
-        //                     metadata.FullID = uuid;
-
-        //                 string lastModifiedStr = response.Headers.Get("Last-Modified");
-        //                 if (!String.IsNullOrEmpty(lastModifiedStr))
-        //                 {
-        //                     DateTime lastModified;
-        //                     if (DateTime.TryParse(lastModifiedStr, out lastModified))
-        //                         metadata.CreationDate = lastModified;
-        //                 }
-        //             }
-        //         }
-        //     }
-        //     catch (Exception ex)
-        //     {
-        //         m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message);
-        //     }
-
-        //     return metadata;
-        // }
-
-        // private AssetBase GetRemote(string id)
-        // {
-        //     AssetBase asset = null;
-        //     Uri url;
-
-        //     // Determine if id is an absolute URL or a grid-relative UUID
-        //     if (!Uri.TryCreate(id, UriKind.Absolute, out url))
-        //         url = new Uri(m_serverUrl + id);
-
-        //     try
-        //     {
-        //         HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
-
-        //         using (WebResponse response = request.GetResponse())
-        //         {
-        //             using (Stream responseStream = response.GetResponseStream())
-        //             {
-        //                 string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty;
-
-        //                 // Create the asset object
-        //                 asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID);
-
-        //                 UUID assetID;
-        //                 if (UUID.TryParse(id, out assetID))
-        //                     asset.FullID = assetID;
-
-        //                 // Grab the asset data from the response stream
-        //                 using (MemoryStream stream = new MemoryStream())
-        //                 {
-        //                     responseStream.CopyStream(stream, Int32.MaxValue);
-        //                     asset.Data = stream.ToArray();
-        //                 }
-        //             }
-        //         }
-
-        //         // Cache store
-        //         if (m_cache != null && asset != null)
-        //             m_cache.Cache(asset);
-
-        //         return asset;
-        //     }
-        //     catch (Exception ex)
-        //     {
-        //         m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message);
-        //         return null;
-        //     }
-        // }
-
-        // private string StoreRemote(AssetBase asset)
-        // {
-        //     // Distinguish public and private assets
-        //     bool isPublic = true;
-        //     switch ((AssetType)asset.Type)
-        //     {
-        //         case AssetType.CallingCard:
-        //         case AssetType.Gesture:
-        //         case AssetType.LSLBytecode:
-        //         case AssetType.LSLText:
-        //             isPublic = false;
-        //             break;
-        //     }
-
-        //     string errorMessage = null;
-
-        //     // Build the remote storage request
-        //     List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
-        //     {
-        //         new MultipartForm.Parameter("AssetID", asset.FullID.ToString()),
-        //         new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID),
-        //         new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"),
-        //         new MultipartForm.Parameter("Public", isPublic ? "1" : "0"),
-        //         new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data)
-        //     };
-
-        //     // Make the remote storage request
-        //     try
-        //     {
-        //         // Simian does not require the asset ID to be in the URL because it's in the post data.
-        //         // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
-        //         HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
-
-        //         using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
-        //         {
-        //             using (Stream responseStream = response.GetResponseStream())
-        //             {
-        //                 string responseStr = null;
-
-        //                 try
-        //                 {
-        //                     responseStr = responseStream.GetStreamString();
-        //                     OSD responseOSD = OSDParser.Deserialize(responseStr);
-        //                     if (responseOSD.Type == OSDType.Map)
-        //                     {
-        //                         OSDMap responseMap = (OSDMap)responseOSD;
-        //                         if (responseMap["Success"].AsBoolean())
-        //                             return asset.ID;
-        //                         else
-        //                             errorMessage = "Upload failed: " + responseMap["Message"].AsString();
-        //                     }
-        //                     else
-        //                     {
-        //                         errorMessage = "Response format was invalid:\n" + responseStr;
-        //                     }
-        //                 }
-        //                 catch (Exception ex)
-        //                 {
-        //                     if (!String.IsNullOrEmpty(responseStr))
-        //                         errorMessage = "Failed to parse the response:\n" + responseStr;
-        //                     else
-        //                         errorMessage = "Failed to retrieve the response: " + ex.Message;
-        //                 }
-        //             }
-        //         }
-        //     }
-        //     catch (WebException ex)
-        //     {
-        //         errorMessage = ex.Message;
-        //     }
-
-        //     m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
-        //         asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
-
-        //     return null;
-        // }
-    }
-}

+ 0 - 313
OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs

@@ -1,313 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Specialized;
-using System.Reflection;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// Connects authentication/authorization to the SimianGrid backend
-    /// </summary>
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianAuthenticationServiceConnector")]
-    public class SimianAuthenticationServiceConnector : IAuthenticationService, ISharedRegionModule
-    {
-        private static readonly ILog m_log =
-                LogManager.GetLogger(
-                MethodBase.GetCurrentMethod().DeclaringType);
-
-        private string m_serverUrl = String.Empty;
-        private bool m_Enabled = false;
-
-        #region ISharedRegionModule
-
-        public Type ReplaceableInterface { get { return null; } }
-        public void RegionLoaded(Scene scene) { }
-        public void PostInitialise() { }
-        public void Close() { }
-
-        public SimianAuthenticationServiceConnector() { }
-        public string Name { get { return "SimianAuthenticationServiceConnector"; } }
-        public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAuthenticationService>(this); } }
-        public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAuthenticationService>(this); } }
-
-        #endregion ISharedRegionModule
-
-        public SimianAuthenticationServiceConnector(IConfigSource source)
-        {
-            CommonInit(source);
-        }
-
-        public void Initialise(IConfigSource source)
-        {
-            IConfig moduleConfig = source.Configs["Modules"];
-            if (moduleConfig != null)
-            {
-                string name = moduleConfig.GetString("AuthenticationServices", "");
-                if (name == Name)
-                    CommonInit(source);
-            }
-        }
-
-        private void CommonInit(IConfigSource source)
-        {
-            IConfig gridConfig = source.Configs["AuthenticationService"];
-            if (gridConfig != null)
-            {
-                string serviceUrl = gridConfig.GetString("AuthenticationServerURI");
-                if (!String.IsNullOrEmpty(serviceUrl))
-                {
-                    if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
-                        serviceUrl = serviceUrl + '/';
-                    m_serverUrl = serviceUrl;
-                    m_Enabled = true;
-                }
-            }
-
-            if (String.IsNullOrEmpty(m_serverUrl))
-                m_log.Info("[SIMIAN AUTH CONNECTOR]: No AuthenticationServerURI specified, disabling connector");
-        }
-
-        public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
-        {
-            realID = UUID.Zero;
-            return Authenticate(principalID, password, lifetime);
-        }
-
-        public string Authenticate(UUID principalID, string password, int lifetime)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetIdentities" },
-                { "UserID", principalID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Identities"] is OSDArray)
-            {
-                bool md5hashFound = false;
-
-                OSDArray identities = (OSDArray)response["Identities"];
-                for (int i = 0; i < identities.Count; i++)
-                {
-                    OSDMap identity = identities[i] as OSDMap;
-                    if (identity != null)
-                    {
-                        if (identity["Type"].AsString() == "md5hash")
-                        {
-                            string authorizeResult;
-                            if (CheckPassword(principalID, password, identity["Credential"].AsString(), out authorizeResult))
-                                return authorizeResult;
-
-                            md5hashFound = true;
-                            break;
-                        }
-                    }
-                }
-
-                if (!md5hashFound)
-                    m_log.Warn("[SIMIAN AUTH CONNECTOR]: Authentication failed for " + principalID + ", no md5hash identity found");
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN AUTH CONNECTOR]: Failed to retrieve identities for " + principalID + ": "  +
-                    response["Message"].AsString());
-            }
-
-            return String.Empty;
-        }
-
-        public bool Verify(UUID principalID, string token, int lifetime)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetSession" },
-                { "SessionID", token }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                return true;
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN AUTH CONNECTOR]: Could not verify session for " + principalID + ": " +
-                    response["Message"].AsString());
-            }
-
-            return false;
-        }
-
-        public bool Release(UUID principalID, string token)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "RemoveSession" },
-                { "UserID", principalID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                return true;
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN AUTH CONNECTOR]: Failed to remove session for " + principalID + ": " +
-                    response["Message"].AsString());
-            }
-
-            return false;
-        }
-
-        public bool SetPassword(UUID principalID, string passwd)
-        {
-            // Fetch the user name first
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUser" },
-                { "UserID", principalID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["User"] is OSDMap)
-            {
-                OSDMap userMap = (OSDMap)response["User"];
-                string identifier = userMap["Name"].AsString();
-
-                if (!String.IsNullOrEmpty(identifier))
-                {
-                    // Add/update the md5hash identity
-                    // TODO: Support salts when AddIdentity does
-                    // TODO: Create an a1hash too for WebDAV logins
-                    requestArgs = new NameValueCollection
-                    {
-                        { "RequestMethod", "AddIdentity" },
-                        { "Identifier", identifier },
-                        { "Credential", "$1$" + Utils.MD5String(passwd) },
-                        { "Type", "md5hash" },
-                        { "UserID", principalID.ToString() }
-                    };
-
-                    response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-                    bool success = response["Success"].AsBoolean();
-
-                    if (!success)
-                        m_log.WarnFormat("[SIMIAN AUTH CONNECTOR]: Failed to set password for {0} ({1})", identifier, principalID);
-
-                    return success;
-                }
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN AUTH CONNECTOR]: Failed to retrieve identities for " + principalID + ": " +
-                    response["Message"].AsString());
-            }
-
-            return false;
-        }
-
-        public AuthInfo GetAuthInfo(UUID principalID)
-        {
-            throw new NotImplementedException();
-        }
-
-        public bool SetAuthInfo(AuthInfo info)
-        {
-            throw new NotImplementedException();
-        }
-
-        private bool CheckPassword(UUID userID, string password, string simianGridCredential, out string authorizeResult)
-        {
-            if (simianGridCredential.Contains(":"))
-            {
-                // Salted version
-                int idx = simianGridCredential.IndexOf(':');
-                string finalhash = simianGridCredential.Substring(0, idx);
-                string salt = simianGridCredential.Substring(idx + 1);
-
-                if (finalhash == Utils.MD5String(password + ":" + salt))
-                {
-                    authorizeResult = Authorize(userID);
-                    return true;
-                }
-                else
-                {
-                    m_log.Warn("[SIMIAN AUTH CONNECTOR]: Authentication failed for " + userID +
-                        " using md5hash " + Utils.MD5String(password) + ":" + salt);
-                }
-            }
-            else
-            {
-                // Unsalted version
-                if (password == simianGridCredential ||
-                    "$1$" + password == simianGridCredential ||
-                    "$1$" + Utils.MD5String(password) == simianGridCredential ||
-                    Utils.MD5String(password) == simianGridCredential ||
-                    "$1$" + Utils.MD5String(password + ":") == simianGridCredential)
-                {
-                    authorizeResult = Authorize(userID);
-                    return true;
-                }
-                else
-                {
-                    m_log.Warn("[SIMIAN AUTH CONNECTOR]: Authentication failed for " + userID +
-                        " using md5hash $1$" + Utils.MD5String(password));
-                }
-            }
-
-            authorizeResult = null;
-            return false;
-        }
-
-        private string Authorize(UUID userID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddSession" },
-                { "UserID", userID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean())
-                return response["SessionID"].AsUUID().ToString();
-            else
-                return String.Empty;
-        }
-    }
-}

+ 0 - 345
OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs

@@ -1,345 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-// DEBUG ON
-using System.Diagnostics;
-// DEBUG OFF
-using System.Reflection;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// Connects avatar appearance data to the SimianGrid backend
-    /// </summary>
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianAvatarServiceConnector")]
-    public class SimianAvatarServiceConnector : IAvatarService, ISharedRegionModule
-    {
-        private static readonly ILog m_log =
-                LogManager.GetLogger(
-                MethodBase.GetCurrentMethod().DeclaringType);
-//        private static string ZeroID = UUID.Zero.ToString();
-
-        private string m_serverUrl = String.Empty;
-        private bool m_Enabled = false;
-
-        #region ISharedRegionModule
-
-        public Type ReplaceableInterface { get { return null; } }
-        public void RegionLoaded(Scene scene) { }
-        public void PostInitialise() { }
-        public void Close() { }
-
-        public SimianAvatarServiceConnector() { }
-        public string Name { get { return "SimianAvatarServiceConnector"; } }
-        public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAvatarService>(this); } }
-        public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAvatarService>(this); } }
-
-        #endregion ISharedRegionModule
-
-        public SimianAvatarServiceConnector(IConfigSource source)
-        {
-            CommonInit(source);
-        }
-
-        public void Initialise(IConfigSource source)
-        {
-            IConfig moduleConfig = source.Configs["Modules"];
-            if (moduleConfig != null)
-            {
-                string name = moduleConfig.GetString("AvatarServices", "");
-                if (name == Name)
-                    CommonInit(source);
-            }
-        }
-
-        private void CommonInit(IConfigSource source)
-        {
-            IConfig gridConfig = source.Configs["AvatarService"];
-            if (gridConfig != null)
-            {
-                string serviceUrl = gridConfig.GetString("AvatarServerURI");
-                if (!String.IsNullOrEmpty(serviceUrl))
-                {
-                    if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
-                        serviceUrl = serviceUrl + '/';
-                    m_serverUrl = serviceUrl;
-                    m_Enabled = true;
-                }
-            }
-
-            if (String.IsNullOrEmpty(m_serverUrl))
-                m_log.Info("[SIMIAN AVATAR CONNECTOR]: No AvatarServerURI specified, disabling connector");
-        }
-
-        #region IAvatarService
-
-        // <summary>
-        // Retrieves the LLPackedAppearance field from user data and unpacks
-        // it into an AvatarAppearance structure
-        // </summary>
-        // <param name="userID"></param>
-        public AvatarAppearance GetAppearance(UUID userID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUser" },
-                { "UserID", userID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                OSDMap map = null;
-                try { map = OSDParser.DeserializeJson(response["LLPackedAppearance"].AsString()) as OSDMap; }
-                catch { }
-
-                if (map != null)
-                {
-                    AvatarAppearance appearance = new AvatarAppearance(map);
-// DEBUG ON
-                    m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR] retrieved appearance for {0}:\n{1}",userID,appearance.ToString());
-// DEBUG OFF
-                    return appearance;
-                }
-
-                m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to decode appearance for {0}",userID);
-                return null;
-            }
-
-            m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to get appearance for {0}: {1}",
-                             userID,response["Message"].AsString());
-            return null;
-        }
-
-        // <summary>
-        // </summary>
-        // <param name=""></param>
-        public bool SetAppearance(UUID userID, AvatarAppearance appearance)
-        {
-            EntityTransferContext ctx = new EntityTransferContext();
-            OSDMap map = appearance.Pack(ctx);
-            if (map == null)
-            {
-                m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to encode appearance for {0}",userID);
-                return false;
-            }
-
-            // m_log.DebugFormat("[SIMIAN AVATAR CONNECTOR] save appearance for {0}",userID);
-
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                        { "RequestMethod", "AddUserData" },
-                        { "UserID", userID.ToString() },
-                        { "LLPackedAppearance", OSDParser.SerializeJsonString(map) }
-                };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (! success)
-                m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to save appearance for {0}: {1}",
-                                 userID,response["Message"].AsString());
-
-            return success;
-        }
-
-        // <summary>
-        // </summary>
-        // <param name=""></param>
-        public AvatarData GetAvatar(UUID userID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUser" },
-                { "UserID", userID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                OSDMap map = null;
-                try { map = OSDParser.DeserializeJson(response["LLAppearance"].AsString()) as OSDMap; }
-                catch { }
-
-                if (map != null)
-                {
-                    AvatarWearable[] wearables = new AvatarWearable[13];
-                    wearables[0] = new AvatarWearable(map["ShapeItem"].AsUUID(), map["ShapeAsset"].AsUUID());
-                    wearables[1] = new AvatarWearable(map["SkinItem"].AsUUID(), map["SkinAsset"].AsUUID());
-                    wearables[2] = new AvatarWearable(map["HairItem"].AsUUID(), map["HairAsset"].AsUUID());
-                    wearables[3] = new AvatarWearable(map["EyesItem"].AsUUID(), map["EyesAsset"].AsUUID());
-                    wearables[4] = new AvatarWearable(map["ShirtItem"].AsUUID(), map["ShirtAsset"].AsUUID());
-                    wearables[5] = new AvatarWearable(map["PantsItem"].AsUUID(), map["PantsAsset"].AsUUID());
-                    wearables[6] = new AvatarWearable(map["ShoesItem"].AsUUID(), map["ShoesAsset"].AsUUID());
-                    wearables[7] = new AvatarWearable(map["SocksItem"].AsUUID(), map["SocksAsset"].AsUUID());
-                    wearables[8] = new AvatarWearable(map["JacketItem"].AsUUID(), map["JacketAsset"].AsUUID());
-                    wearables[9] = new AvatarWearable(map["GlovesItem"].AsUUID(), map["GlovesAsset"].AsUUID());
-                    wearables[10] = new AvatarWearable(map["UndershirtItem"].AsUUID(), map["UndershirtAsset"].AsUUID());
-                    wearables[11] = new AvatarWearable(map["UnderpantsItem"].AsUUID(), map["UnderpantsAsset"].AsUUID());
-                    wearables[12] = new AvatarWearable(map["SkirtItem"].AsUUID(), map["SkirtAsset"].AsUUID());
-
-                    AvatarAppearance appearance = new AvatarAppearance();
-                    appearance.Wearables = wearables;
-                    appearance.AvatarHeight = (float)map["Height"].AsReal();
-
-                    AvatarData avatar = new AvatarData(appearance);
-
-                    // Get attachments
-                    map = null;
-                    try { map = OSDParser.DeserializeJson(response["LLAttachments"].AsString()) as OSDMap; }
-                    catch { }
-
-                    if (map != null)
-                    {
-                        foreach (KeyValuePair<string, OSD> kvp in map)
-                            avatar.Data[kvp.Key] = kvp.Value.AsString();
-                    }
-
-                    return avatar;
-                }
-                else
-                {
-                    m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed to get user appearance for " + userID +
-                        ", LLAppearance is missing or invalid");
-                    return null;
-                }
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed to get user appearance for " + userID + ": " +
-                    response["Message"].AsString());
-            }
-
-            return null;
-        }
-
-        // <summary>
-        // </summary>
-        // <param name=""></param>
-        public bool SetAvatar(UUID userID, AvatarData avatar)
-        {
-            m_log.Debug("[SIMIAN AVATAR CONNECTOR]: SetAvatar called for " + userID);
-
-            if (avatar.AvatarType == 1) // LLAvatar
-            {
-                AvatarAppearance appearance = avatar.ToAvatarAppearance();
-
-                OSDMap map = new OSDMap();
-
-                map["Height"] = OSD.FromReal(appearance.AvatarHeight);
-
-                map["BodyItem"] = appearance.Wearables[AvatarWearable.BODY][0].ItemID.ToString();
-                map["EyesItem"] = appearance.Wearables[AvatarWearable.EYES][0].ItemID.ToString();
-                map["GlovesItem"] = appearance.Wearables[AvatarWearable.GLOVES][0].ItemID.ToString();
-                map["HairItem"] = appearance.Wearables[AvatarWearable.HAIR][0].ItemID.ToString();
-                map["JacketItem"] = appearance.Wearables[AvatarWearable.JACKET][0].ItemID.ToString();
-                map["PantsItem"] = appearance.Wearables[AvatarWearable.PANTS][0].ItemID.ToString();
-                map["ShirtItem"] = appearance.Wearables[AvatarWearable.SHIRT][0].ItemID.ToString();
-                map["ShoesItem"] = appearance.Wearables[AvatarWearable.SHOES][0].ItemID.ToString();
-                map["SkinItem"] = appearance.Wearables[AvatarWearable.SKIN][0].ItemID.ToString();
-                map["SkirtItem"] = appearance.Wearables[AvatarWearable.SKIRT][0].ItemID.ToString();
-                map["SocksItem"] = appearance.Wearables[AvatarWearable.SOCKS][0].ItemID.ToString();
-                map["UnderPantsItem"] = appearance.Wearables[AvatarWearable.UNDERPANTS][0].ItemID.ToString();
-                map["UnderShirtItem"] = appearance.Wearables[AvatarWearable.UNDERSHIRT][0].ItemID.ToString();
-                map["BodyAsset"] = appearance.Wearables[AvatarWearable.BODY][0].AssetID.ToString();
-                map["EyesAsset"] = appearance.Wearables[AvatarWearable.EYES][0].AssetID.ToString();
-                map["GlovesAsset"] = appearance.Wearables[AvatarWearable.GLOVES][0].AssetID.ToString();
-                map["HairAsset"] = appearance.Wearables[AvatarWearable.HAIR][0].AssetID.ToString();
-                map["JacketAsset"] = appearance.Wearables[AvatarWearable.JACKET][0].AssetID.ToString();
-                map["PantsAsset"] = appearance.Wearables[AvatarWearable.PANTS][0].AssetID.ToString();
-                map["ShirtAsset"] = appearance.Wearables[AvatarWearable.SHIRT][0].AssetID.ToString();
-                map["ShoesAsset"] = appearance.Wearables[AvatarWearable.SHOES][0].AssetID.ToString();
-                map["SkinAsset"] = appearance.Wearables[AvatarWearable.SKIN][0].AssetID.ToString();
-                map["SkirtAsset"] = appearance.Wearables[AvatarWearable.SKIRT][0].AssetID.ToString();
-                map["SocksAsset"] = appearance.Wearables[AvatarWearable.SOCKS][0].AssetID.ToString();
-                map["UnderPantsAsset"] = appearance.Wearables[AvatarWearable.UNDERPANTS][0].AssetID.ToString();
-                map["UnderShirtAsset"] = appearance.Wearables[AvatarWearable.UNDERSHIRT][0].AssetID.ToString();
-
-
-                OSDMap items = new OSDMap();
-                foreach (KeyValuePair<string, string> kvp in avatar.Data)
-                {
-                    if (kvp.Key.StartsWith("_ap_"))
-                        items.Add(kvp.Key, OSD.FromString(kvp.Value));
-                }
-
-                NameValueCollection requestArgs = new NameValueCollection
-                {
-                    { "RequestMethod", "AddUserData" },
-                    { "UserID", userID.ToString() },
-                    { "LLAppearance", OSDParser.SerializeJsonString(map) },
-                    { "LLAttachments", OSDParser.SerializeJsonString(items) }
-                };
-
-                OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-                bool success = response["Success"].AsBoolean();
-
-                if (!success)
-                    m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed saving appearance for " + userID + ": " + response["Message"].AsString());
-
-                return success;
-            }
-            else
-            {
-                m_log.Error("[SIMIAN AVATAR CONNECTOR]: Can't save appearance for " + userID + ". Unhandled avatar type " + avatar.AvatarType);
-                return false;
-            }
-        }
-
-        public bool ResetAvatar(UUID userID)
-        {
-            m_log.Error("[SIMIAN AVATAR CONNECTOR]: ResetAvatar called for " + userID + ", implement this");
-            return false;
-        }
-
-        public bool SetItems(UUID userID, string[] names, string[] values)
-        {
-            m_log.Error("[SIMIAN AVATAR CONNECTOR]: SetItems called for " + userID + " with " + names.Length + " names and " + values.Length + " values, implement this");
-            return false;
-        }
-
-        public bool RemoveItems(UUID userID, string[] names)
-        {
-            m_log.Error("[SIMIAN AVATAR CONNECTOR]: RemoveItems called for " + userID + " with " + names.Length + " names, implement this");
-            return false;
-        }
-
-        #endregion IAvatarService
-    }
-}

+ 0 - 180
OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs

@@ -1,180 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Reflection;
-using System.IO;
-using System.Web;
-
-using log4net;
-using Nini.Config;
-using Mono.Addins;
-
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-using Caps = OpenSim.Framework.Capabilities.Caps;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")]
-    public class SimianExternalCapsModule : INonSharedRegionModule, IExternalCapsModule
-    {
-        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
-        private bool m_enabled = true;
-        private Scene m_scene;
-        private String m_simianURL;
-
-#region IRegionModule Members
-
-        public string Name
-        {
-            get { return this.GetType().Name; }
-        }
-
-        public void Initialise(IConfigSource config)
-        {
-            try
-            {
-                IConfig m_config;
-
-                if ((m_config = config.Configs["SimianExternalCaps"]) != null)
-                {
-                    m_enabled = m_config.GetBoolean("Enabled", m_enabled);
-                    if ((m_config = config.Configs["SimianGrid"]) != null)
-                    {
-                        m_simianURL = m_config.GetString("SimianServiceURL");
-                        if (String.IsNullOrEmpty(m_simianURL))
-                        {
-                            //m_log.DebugFormat("[SimianGrid] service URL is not defined");
-                            m_enabled = false;
-                            return;
-                        }
-                    }
-                }
-                else
-                    m_enabled = false;
-            }
-            catch (Exception e)
-            {
-                m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
-                return;
-            }
-        }
-
-        public void PostInitialise() { }
-        public void Close() { }
-
-        public void AddRegion(Scene scene)
-        {
-            if (! m_enabled)
-                return;
-
-            m_scene = scene;
-            m_scene.RegisterModuleInterface<IExternalCapsModule>(this);
-        }
-
-        public void RemoveRegion(Scene scene)
-        {
-            if (! m_enabled)
-                return;
-
-            m_scene.EventManager.OnRegisterCaps -= RegisterCapsEventHandler;
-            m_scene.EventManager.OnDeregisterCaps -= DeregisterCapsEventHandler;
-        }
-
-        public void RegionLoaded(Scene scene)
-        {
-            if (! m_enabled)
-                return;
-
-            m_scene.EventManager.OnRegisterCaps += RegisterCapsEventHandler;
-            m_scene.EventManager.OnDeregisterCaps += DeregisterCapsEventHandler;
-        }
-
-        public Type ReplaceableInterface
-        {
-            get { return null; }
-        }
-
-#endregion
-
-#region IExternalCapsModule
-        // Eg http://grid.sciencesim.com/GridPublic/%CAP%/%OP%/"
-        public bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel)
-        {
-            UUID cap = UUID.Random();
-
-            // Call to simian to register the cap we generated
-            // NameValueCollection requestArgs = new NameValueCollection
-            // {
-            //     { "RequestMethod", "AddCapability" },
-            //     { "Resource", "user" },
-            //     { "Expiration", 0 },
-            //     { "OwnerID", agentID.ToString() },
-            //     { "CapabilityID", cap.ToString() }
-            // };
-
-            // OSDMap response = SimianGrid.PostToService(m_simianURL, requestArgs);
-
-            Dictionary<String,String> subs = new Dictionary<String,String>();
-            subs["%OP%"] = capName;
-            subs["%USR%"] = agentID.ToString();
-            subs["%CAP%"] = cap.ToString();
-            subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString();
-
-            caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs));
-            return true;
-        }
-
-#endregion
-
-#region EventHandlers
-        public void RegisterCapsEventHandler(UUID agentID, Caps caps) { }
-        public void DeregisterCapsEventHandler(UUID agentID, Caps caps) { }
-#endregion
-
-        private String ExpandSkeletonURL(String urlSkel, Dictionary<String,String> subs)
-        {
-            String result = urlSkel;
-
-            foreach (KeyValuePair<String,String> kvp in subs)
-            {
-                result = result.Replace(kvp.Key,kvp.Value);
-            }
-
-            return result;
-        }
-    }
-}

+ 0 - 236
OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs

@@ -1,236 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Reflection;
-using log4net;
-using Nini.Config;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-using OpenSim.Framework;
-using OpenSim.Services.Interfaces;
-
-using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// Stores and retrieves friend lists from the SimianGrid backend
-    /// </summary>
-    public class SimianFriendsServiceConnector : IFriendsService
-    {
-        private static readonly ILog m_log =
-                LogManager.GetLogger(
-                MethodBase.GetCurrentMethod().DeclaringType);
-
-        private string m_serverUrl = String.Empty;
-
-        public SimianFriendsServiceConnector(IConfigSource source)
-        {
-            Initialise(source);
-        }
-
-        public void Initialise(IConfigSource source)
-        {
-            IConfig gridConfig = source.Configs["FriendsService"];
-            if (gridConfig != null)
-            {
-                string serviceUrl = gridConfig.GetString("FriendsServerURI");
-                if (!String.IsNullOrEmpty(serviceUrl))
-                {
-                    if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
-                        serviceUrl = serviceUrl + '/';
-                    m_serverUrl = serviceUrl;
-                }
-            }
-
-            if (String.IsNullOrEmpty(m_serverUrl))
-                m_log.Info("[SIMIAN FRIENDS CONNECTOR]: No FriendsServerURI specified, disabling connector");
-        }
-
-        #region IFriendsService
-
-        public FriendInfo[] GetFriends(UUID principalID)
-        {
-            return GetFriends(principalID.ToString());
-        }
-
-        public FriendInfo[] GetFriends(string principalID)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-                return new FriendInfo[0];
-
-            Dictionary<UUID, FriendInfo> friends = new Dictionary<UUID, FriendInfo>();
-
-            OSDArray friendsArray = GetFriended(principalID);
-            OSDArray friendedMeArray = GetFriendedBy(principalID);
-
-            // Load the list of friends and their granted permissions
-            for (int i = 0; i < friendsArray.Count; i++)
-            {
-                OSDMap friendEntry = friendsArray[i] as OSDMap;
-                if (friendEntry != null)
-                {
-                    UUID friendID = friendEntry["Key"].AsUUID();
-
-                    FriendInfo friend = new FriendInfo();
-                    if (!UUID.TryParse(principalID, out friend.PrincipalID))
-                    {
-                        string tmp = string.Empty;
-                        if (!Util.ParseUniversalUserIdentifier(principalID, out friend.PrincipalID, out tmp, out tmp, out tmp, out tmp))
-                            // bad record. ignore this entry
-                            continue;
-                    }
-
-                    friend.Friend = friendID.ToString();
-                    friend.MyFlags = friendEntry["Value"].AsInteger();
-                    friend.TheirFlags = -1;
-
-                    friends[friendID] = friend;
-                }
-            }
-
-            // Load the permissions those friends have granted to this user
-            for (int i = 0; i < friendedMeArray.Count; i++)
-            {
-                OSDMap friendedMeEntry = friendedMeArray[i] as OSDMap;
-                if (friendedMeEntry != null)
-                {
-                    UUID friendID = friendedMeEntry["OwnerID"].AsUUID();
-
-                    FriendInfo friend;
-                    if (friends.TryGetValue(friendID, out friend))
-                        friend.TheirFlags = friendedMeEntry["Value"].AsInteger();
-                }
-            }
-
-            // Convert the dictionary of friends to an array and return it
-            FriendInfo[] array = new FriendInfo[friends.Count];
-            int j = 0;
-            foreach (FriendInfo friend in friends.Values)
-                array[j++] = friend;
-
-            return array;
-        }
-
-        public bool StoreFriend(string principalID, string friend, int flags)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-                return true;
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddGeneric" },
-                { "OwnerID", principalID.ToString() },
-                { "Type", "Friend" },
-                { "Key", friend },
-                { "Value", flags.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Error("[SIMIAN FRIENDS CONNECTOR]: Failed to store friend " + friend + " for user " + principalID + ": " + response["Message"].AsString());
-
-            return success;
-        }
-
-        public bool Delete(UUID principalID, string friend)
-        {
-            return Delete(principalID.ToString(), friend);
-        }
-
-        public bool Delete(string principalID, string friend)
-        {
-            if (String.IsNullOrEmpty(m_serverUrl))
-                return true;
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "RemoveGeneric" },
-                { "OwnerID", principalID.ToString() },
-                { "Type", "Friend" },
-                { "Key", friend }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Error("[SIMIAN FRIENDS CONNECTOR]: Failed to remove friend " + friend + " for user " + principalID + ": " + response["Message"].AsString());
-
-            return success;
-        }
-
-        #endregion IFriendsService
-
-        private OSDArray GetFriended(string ownerID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetGenerics" },
-                { "OwnerID", ownerID.ToString() },
-                { "Type", "Friend" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
-            {
-                return (OSDArray)response["Entries"];
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN FRIENDS CONNECTOR]: Failed to retrieve friends for user " + ownerID + ": " + response["Message"].AsString());
-                return new OSDArray(0);
-            }
-        }
-
-        private OSDArray GetFriendedBy(string ownerID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetGenerics" },
-                { "Key", ownerID.ToString() },
-                { "Type", "Friend" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
-            {
-                return (OSDArray)response["Entries"];
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN FRIENDS CONNECTOR]: Failed to retrieve reverse friends for user " + ownerID + ": " + response["Message"].AsString());
-                return new OSDArray(0);
-            }
-        }
-    }
-}

+ 0 - 147
OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs

@@ -1,147 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Reflection;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-[assembly: Addin("SimianGrid", OpenSim.VersionInfo.VersionNumber)]
-[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")]
-    public class SimianGrid : ISharedRegionModule
-    {
-        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
-        private IConfig m_config = null;
-
-        private String m_simianURL;
-
-#region IRegionModule Members
-
-        public string Name
-        {
-            get { return this.GetType().Name; }
-        }
-
-        public void Initialise(IConfigSource config)
-        {
-            try
-            {
-                m_config = config.Configs["SimianGrid"];
-
-                if (m_config != null)
-                {
-                    m_simianURL = m_config.GetString("SimianServiceURL");
-                    if (String.IsNullOrEmpty(m_simianURL))
-                    {
-                        // m_log.DebugFormat("[SimianGrid] service URL is not defined");
-                        return;
-                    }
-
-                    InitialiseSimCap();
-                    SimulatorCapability = SimulatorCapability.Trim();
-                    m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability);
-                }
-            }
-            catch (Exception e)
-            {
-                m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
-                return;
-            }
-        }
-
-        public void PostInitialise() { }
-        public void Close() { }
-        public void AddRegion(Scene scene) { }
-        public void RemoveRegion(Scene scene) { }
-        public void RegionLoaded(Scene scene) { }
-
-        public Type ReplaceableInterface
-        {
-            get { return null; }
-        }
-
-        ///<summary>
-        /// Try a variety of methods for finding the simian simulator capability; first check the
-        /// configuration itself, then look for a file that contains the cap, then finally look
-        /// for an environment variable that contains it.
-        ///</summary>
-        private void InitialiseSimCap()
-        {
-            if (m_config.Contains("SimulatorCapability"))
-            {
-                SimulatorCapability = m_config.GetString("SimulatorCapability");
-                return;
-            }
-
-            if (m_config.Contains("SimulatorCapabilityFile"))
-            {
-                String filename = m_config.GetString("SimulatorCapabilityFile");
-                if (System.IO.File.Exists(filename))
-                {
-                    SimulatorCapability = System.IO.File.ReadAllText(filename);
-                    return;
-                }
-            }
-
-            if (m_config.Contains("SimulatorCapabilityVariable"))
-            {
-                String envname = m_config.GetString("SimulatorCapabilityVariable");
-                String envvalue = System.Environment.GetEnvironmentVariable(envname);
-                if (envvalue != null)
-                {
-                    SimulatorCapability = envvalue;
-                    return;
-                }
-            }
-
-            m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability");
-        }
-
-#endregion
-
-        public static String SimulatorCapability = UUID.Zero.ToString();
-        public static OSDMap PostToService(string url, NameValueCollection data)
-        {
-            data["cap"] = SimulatorCapability;
-            return WebUtil.PostToService(url, data);
-        }
-    }
-}

+ 0 - 266
OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs

@@ -1,266 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Reflection;
-using System.Net;
-using System.IO;
-using System.Timers;
-using System.Drawing;
-using System.Drawing.Imaging;
-
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-//namespace OpenSim.Region.OptionalModules.Simian
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// </summary>
-    /// <remarks>
-    /// </remarks>
-
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianGridMaptile")]
-    public class SimianGridMaptile : ISharedRegionModule
-    {
-        private static readonly ILog m_log =
-            LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
-        private bool m_enabled = false;
-        private string m_serverUrl = String.Empty;
-        private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
-
-        private int m_refreshtime = 0;
-        private int m_lastrefresh = 0;
-        private System.Timers.Timer m_refreshTimer = new System.Timers.Timer();
-
-        #region ISharedRegionModule
-
-        public Type ReplaceableInterface { get { return null; } }
-        public string Name { get { return "SimianGridMaptile"; } }
-        public void RegionLoaded(Scene scene) { }
-        public void Close() { }
-
-        ///<summary>
-        ///
-        ///</summary>
-        public void Initialise(IConfigSource source)
-        {
-            IConfig config = source.Configs["SimianGridMaptiles"];
-            if (config == null)
-                return;
-
-            if (! config.GetBoolean("Enabled", false))
-                return;
-
-            m_serverUrl = config.GetString("MaptileURL");
-            if (String.IsNullOrEmpty(m_serverUrl))
-                return;
-
-            int refreshseconds = Convert.ToInt32(config.GetString("RefreshTime"));
-            if (refreshseconds <= 0)
-                return;
-
-            m_refreshtime = refreshseconds * 1000; // convert from seconds to ms
-            m_log.InfoFormat("[SIMIAN MAPTILE] enabled with refresh timeout {0} and URL {1}",
-                             m_refreshtime,m_serverUrl);
-
-            m_enabled = true;
-        }
-
-        ///<summary>
-        ///
-        ///</summary>
-        public void PostInitialise()
-        {
-            if (m_enabled)
-            {
-                m_refreshTimer.Enabled = true;
-                m_refreshTimer.AutoReset = true;
-                m_refreshTimer.Interval = 5 * 60 * 1000; // every 5 minutes
-                m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh);
-            }
-        }
-
-
-        ///<summary>
-        ///
-        ///</summary>
-        public void AddRegion(Scene scene)
-        {
-            if (! m_enabled)
-                return;
-
-            // Every shared region module has to maintain an indepedent list of
-            // currently running regions
-            lock (m_scenes)
-                m_scenes[scene.RegionInfo.RegionID] = scene;
-        }
-
-        ///<summary>
-        ///
-        ///</summary>
-        public void RemoveRegion(Scene scene)
-        {
-            if (! m_enabled)
-                return;
-
-            lock (m_scenes)
-                m_scenes.Remove(scene.RegionInfo.RegionID);
-        }
-
-        #endregion ISharedRegionModule
-
-        ///<summary>
-        ///
-        ///</summary>
-        private void HandleMaptileRefresh(object sender, EventArgs ea)
-        {
-            // this approach is a bit convoluted becase we want to wait for the
-            // first upload to happen on startup but after all the objects are
-            // loaded and initialized
-            if (m_lastrefresh > 0 && Util.EnvironmentTickCountSubtract(m_lastrefresh) < m_refreshtime)
-                return;
-
-            m_log.DebugFormat("[SIMIAN MAPTILE] map refresh fired");
-            lock (m_scenes)
-            {
-                foreach (IScene scene in m_scenes.Values)
-                {
-                    try
-                    {
-                        UploadMapTile(scene);
-                    }
-                    catch (Exception ex)
-                    {
-                        m_log.WarnFormat("[SIMIAN MAPTILE] something bad happened {0}",ex.Message);
-                    }
-                }
-            }
-
-            m_lastrefresh = Util.EnvironmentTickCount();
-        }
-
-        ///<summary>
-        ///
-        ///</summary>
-        private void UploadMapTile(IScene scene)
-        {
-            m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName);
-
-            // Create a PNG map tile and upload it to the AddMapTile API
-            IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
-            if (tileGenerator == null)
-            {
-                m_log.Warn("[SIMIAN MAPTILE]: Cannot upload PNG map tile without an ImageGenerator");
-                return;
-            }
-
-            using (Bitmap mapTile = tileGenerator.CreateMapTile())
-            {
-                if (mapTile != null)
-                {
-                    // If the region/maptile is legacy sized, just upload the one tile like it has always been done
-                    if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
-                    {
-                        ConvertAndUploadMaptile(mapTile, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY);
-                    }
-                    else
-                    {
-                        // For larger regions (varregion) we must cut the region image into legacy sized
-                        //    pieces since that is how the maptile system works.
-                        // Note the assumption that varregions are always a multiple of legacy size.
-                        for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize)
-                        {
-                            for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize)
-                            {
-                                // Images are addressed from the upper left corner so have to do funny
-                                //     math to pick out the sub-tile since regions are numbered from
-                                //     the lower left.
-                                Rectangle rect = new Rectangle(
-                                            (int)xx,
-                                            mapTile.Height - (int)yy - (int)Constants.RegionSize,
-                                            (int)Constants.RegionSize, (int)Constants.RegionSize);
-
-                                using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat))
-                                {
-                                    uint locX = scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize);
-                                    uint locY = scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize);
-
-                                    ConvertAndUploadMaptile(subMapTile, locX, locY);
-                                }
-                            }
-                        }
-                    }
-                }
-                else
-                {
-                    m_log.WarnFormat("[SIMIAN MAPTILE] Tile image generation failed");
-                }
-            }
-
-        }
-
-        ///<summary>
-        ///
-        ///</summary>
-        private void ConvertAndUploadMaptile(Image mapTile, uint locX, uint locY)
-        {
-            //m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for location {0}, {1}", locX, locY);
-
-            byte[] pngData = Utils.EmptyBytes;
-            using (MemoryStream stream = new MemoryStream())
-            {
-                mapTile.Save(stream, ImageFormat.Png);
-                pngData = stream.ToArray();
-            }
-
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                    { "RequestMethod", "xAddMapTile" },
-                    { "X", locX.ToString() },
-                    { "Y", locY.ToString() },
-                    { "ContentType", "image/png" },
-                    { "EncodedData", System.Convert.ToBase64String(pngData) }
-                };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
-            if (! response["Success"].AsBoolean())
-            {
-                m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}",response["Message"].AsString());
-            }
-        }
-    }
-}

+ 0 - 501
OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs

@@ -1,501 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Net;
-using System.Reflection;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-using GridRegion = OpenSim.Services.Interfaces.GridRegion;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// Connects region registration and neighbor lookups to the SimianGrid
-    /// backend
-    /// </summary>
-    public class SimianGridServiceConnector : IGridService
-    {
-        private static readonly ILog m_log =
-                LogManager.GetLogger(
-                MethodBase.GetCurrentMethod().DeclaringType);
-
-        private string m_ServerURI = String.Empty;
-//        private bool m_Enabled = false;
-
-        public SimianGridServiceConnector() { }
-        public SimianGridServiceConnector(string serverURI)
-        {
-            m_ServerURI = serverURI.TrimEnd('/');
-        }
-
-        public SimianGridServiceConnector(IConfigSource source)
-        {
-            CommonInit(source);
-        }
-
-        public void Initialise(IConfigSource source)
-        {
-            CommonInit(source);
-        }
-
-        private void CommonInit(IConfigSource source)
-        {
-            IConfig gridConfig = source.Configs["GridService"];
-            if (gridConfig == null)
-            {
-                m_log.Error("[SIMIAN GRID CONNECTOR]: GridService missing from OpenSim.ini");
-                throw new Exception("Grid connector init error");
-            }
-
-            string serviceUrl = gridConfig.GetString("GridServerURI");
-            if (String.IsNullOrEmpty(serviceUrl))
-            {
-                m_log.Error("[SIMIAN GRID CONNECTOR]: No Server URI named in section GridService");
-                throw new Exception("Grid connector init error");
-            }
-
-            if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
-                serviceUrl = serviceUrl + '/';
-            m_ServerURI = serviceUrl;
-//            m_Enabled = true;
-        }
-
-        #region IGridService
-
-        public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
-        {
-            IPEndPoint ext = regionInfo.ExternalEndPoint;
-            if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint";
-            // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service
-//            Scene scene;
-//            if (m_scenes.TryGetValue(regionInfo.RegionID, out scene))
-//                UploadMapTile(scene);
-//            else
-//                m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking");
-
-            Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
-            Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight);
-
-            OSDMap extraData = new OSDMap
-            {
-                { "ServerURI", OSD.FromString(regionInfo.ServerURI) },
-                { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) },
-                { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) },
-                { "ExternalAddress", OSD.FromString(ext.Address.ToString()) },
-                { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) },
-                { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) },
-                { "Access", OSD.FromInteger(regionInfo.Access) },
-                { "RegionSecret", OSD.FromString(regionInfo.RegionSecret) },
-                { "EstateOwner", OSD.FromUUID(regionInfo.EstateOwner) },
-                { "Token", OSD.FromString(regionInfo.Token) }
-            };
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddScene" },
-                { "SceneID", regionInfo.RegionID.ToString() },
-                { "Name", regionInfo.RegionName },
-                { "MinPosition", minPosition.ToString() },
-                { "MaxPosition", maxPosition.ToString() },
-                { "Address", regionInfo.ServerURI },
-                { "Enabled", "1" },
-                { "ExtraData", OSDParser.SerializeJsonString(extraData) }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
-            if (response["Success"].AsBoolean())
-                return String.Empty;
-            else
-                return "Region registration for " + regionInfo.RegionName + " failed: " + response["Message"].AsString();
-        }
-
-        public bool DeregisterRegion(UUID regionID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddScene" },
-                { "SceneID", regionID.ToString() },
-                { "Enabled", "0" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Warn("[SIMIAN GRID CONNECTOR]: Region deregistration for " + regionID + " failed: " + response["Message"].AsString());
-
-            return success;
-        }
-
-        public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
-        {
-            GridRegion region = GetRegionByUUID(scopeID, regionID);
-
-            int NEIGHBOR_RADIUS = Math.Max(region.RegionSizeX, region.RegionSizeY) / 2;
-
-            if (region != null)
-            {
-                List<GridRegion> regions = GetRegionRange(scopeID,
-                    region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + region.RegionSizeX + NEIGHBOR_RADIUS,
-                    region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + region.RegionSizeY + NEIGHBOR_RADIUS);
-
-                for (int i = 0; i < regions.Count; i++)
-                {
-                    if (regions[i].RegionID == regionID)
-                    {
-                        regions.RemoveAt(i);
-                        break;
-                    }
-                }
-
-//                m_log.Debug("[SIMIAN GRID CONNECTOR]: Found " + regions.Count + " neighbors for region " + regionID);
-                return regions;
-            }
-
-            return new List<GridRegion>(0);
-        }
-
-        public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetScene" },
-                { "SceneID", regionID.ToString() }
-            };
-
-            // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString());
-
-            OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString());
-                return ResponseToGridRegion(response);
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region " + regionID);
-                return null;
-            }
-        }
-
-        public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
-        {
-            // Go one meter in from the requested x/y coords to avoid requesting a position
-            // that falls on the border of two sims
-            Vector3d position = new Vector3d(x + 1, y + 1, 0.0);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetScene" },
-                { "Position", position.ToString() },
-                { "Enabled", "1" }
-            };
-
-            // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString());
-
-            OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString());
-                return ResponseToGridRegion(response);
-            }
-            else
-            {
-                // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}",
-                //     Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
-                return null;
-            }
-        }
-
-        public GridRegion GetRegionByNameSpecific(UUID scopeID, string regionName)
-        {
-
-            return null;
-        }
-
-        public GridRegion GetRegionByName(UUID scopeID, string regionName)
-        {
-            List<GridRegion> regions = GetRegionsByName(scopeID, regionName, 1);
-
-            m_log.Debug("[SIMIAN GRID CONNECTOR]: Got " + regions.Count + " matches for region name " + regionName);
-
-            if (regions.Count > 0)
-                return regions[0];
-
-            return null;
-        }
-
-        public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
-        {
-            List<GridRegion> foundRegions = new List<GridRegion>();
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetScenes" },
-                { "NameQuery", name },
-                { "Enabled", "1" }
-            };
-            if (maxNumber > 0)
-                requestArgs["MaxNumber"] = maxNumber.ToString();
-
-            // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name);
-
-            OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
-
-                OSDArray array = response["Scenes"] as OSDArray;
-                if (array != null)
-                {
-                    for (int i = 0; i < array.Count; i++)
-                    {
-                        GridRegion region = ResponseToGridRegion(array[i] as OSDMap);
-                        if (region != null)
-                            foundRegions.Add(region);
-                    }
-                }
-            }
-
-            return foundRegions;
-        }
-
-        public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
-        {
-            List<GridRegion> foundRegions = new List<GridRegion>();
-
-            Vector3d minPosition = new Vector3d(xmin, ymin, 0.0);
-            Vector3d maxPosition = new Vector3d(xmax, ymax, Constants.RegionHeight);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetScenes" },
-                { "MinPosition", minPosition.ToString() },
-                { "MaxPosition", maxPosition.ToString() },
-                { "Enabled", "1" }
-            };
-
-            //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString());
-
-
-            OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                OSDArray array = response["Scenes"] as OSDArray;
-                if (array != null)
-                {
-                    for (int i = 0; i < array.Count; i++)
-                    {
-                        GridRegion region = ResponseToGridRegion(array[i] as OSDMap);
-                        if (region != null)
-                            foundRegions.Add(region);
-                    }
-                }
-            }
-
-            return foundRegions;
-        }
-
-        public List<GridRegion> GetDefaultRegions(UUID scopeID)
-        {
-            // TODO: Allow specifying the default grid location
-            const int DEFAULT_X = 1000 * 256;
-            const int DEFAULT_Y = 1000 * 256;
-
-            GridRegion defRegion = GetNearestRegion(new Vector3d(DEFAULT_X, DEFAULT_Y, 0.0), true);
-            if (defRegion != null)
-                return new List<GridRegion>(1) { defRegion };
-            else
-                return new List<GridRegion>(0);
-        }
-
-        public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
-        {
-            // TODO: Allow specifying the default grid location
-            return GetDefaultRegions(scopeID);
-        }
-
-        public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
-        {
-            GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true);
-            if (defRegion != null)
-                return new List<GridRegion>(1) { defRegion };
-            else
-                return new List<GridRegion>(0);
-        }
-
-        public List<GridRegion> GetHyperlinks(UUID scopeID)
-        {
-            List<GridRegion> foundRegions = new List<GridRegion>();
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetScenes" },
-                { "HyperGrid", "true" },
-                { "Enabled", "1" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
-
-                OSDArray array = response["Scenes"] as OSDArray;
-                if (array != null)
-                {
-                    for (int i = 0; i < array.Count; i++)
-                    {
-                        GridRegion region = ResponseToGridRegion(array[i] as OSDMap);
-                        if (region != null)
-                            foundRegions.Add(region);
-                    }
-                }
-            }
-
-            return foundRegions;
-        }
-
-        public int GetRegionFlags(UUID scopeID, UUID regionID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetScene" },
-                { "SceneID", regionID.ToString() }
-            };
-
-            m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString());
-
-            OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                OSDMap extraData = response["ExtraData"] as OSDMap;
-                int enabled = response["Enabled"].AsBoolean() ? (int)OpenSim.Framework.RegionFlags.RegionOnline : 0;
-                int hypergrid = extraData["HyperGrid"].AsBoolean() ? (int)OpenSim.Framework.RegionFlags.Hyperlink : 0;
-                int flags =  enabled | hypergrid;
-                m_log.DebugFormat("[SGGC] enabled - {0} hg - {1} flags - {2}", enabled, hypergrid, flags);
-                return flags;
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region " + regionID + " during region flags check");
-                return -1;
-            }
-        }
-
-        public Dictionary<string, object> GetExtraFeatures()
-        {
-            /// See SimulatorFeaturesModule - Need to get map, search and destination guide
-            Dictionary<string, object> extraFeatures = new Dictionary<string, object>();
-            return extraFeatures;
-        }
-
-        #endregion IGridService
-
-        private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetScene" },
-                { "Position", position.ToString() },
-                { "FindClosest", "1" }
-            };
-            if (onlyEnabled)
-                requestArgs["Enabled"] = "1";
-
-            OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                return ResponseToGridRegion(response);
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at " + position);
-                return null;
-            }
-        }
-
-        private GridRegion ResponseToGridRegion(OSDMap response)
-        {
-            if (response == null)
-                return null;
-
-            OSDMap extraData = response["ExtraData"] as OSDMap;
-            if (extraData == null)
-                return null;
-
-            GridRegion region = new GridRegion();
-
-            region.RegionID = response["SceneID"].AsUUID();
-            region.RegionName = response["Name"].AsString();
-
-            Vector3d minPosition = response["MinPosition"].AsVector3d();
-            Vector3d maxPosition = response["MaxPosition"].AsVector3d();
-            region.RegionLocX = (int)minPosition.X;
-            region.RegionLocY = (int)minPosition.Y;
-
-            region.RegionSizeX = (int)maxPosition.X - (int)minPosition.X;
-            region.RegionSizeY = (int)maxPosition.Y - (int)minPosition.Y;
-
-            if ( ! extraData["HyperGrid"] ) {
-                Uri httpAddress = response["Address"].AsUri();
-                region.ExternalHostName = httpAddress.Host;
-                region.HttpPort = (uint)httpAddress.Port;
-
-                IPAddress internalAddress;
-                IPAddress.TryParse(extraData["InternalAddress"].AsString(), out internalAddress);
-                if (internalAddress == null)
-                    internalAddress = IPAddress.Any;
-
-                region.InternalEndPoint = new IPEndPoint(internalAddress, extraData["InternalPort"].AsInteger());
-                region.TerrainImage = extraData["MapTexture"].AsUUID();
-                region.Access = (byte)extraData["Access"].AsInteger();
-                region.RegionSecret = extraData["RegionSecret"].AsString();
-                region.EstateOwner = extraData["EstateOwner"].AsUUID();
-                region.Token = extraData["Token"].AsString();
-                region.ServerURI = extraData["ServerURI"].AsString();
-            } else {
-                region.ServerURI = response["Address"];
-            }
-
-            return region;
-        }
-    }
-}

+ 0 - 936
OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs

@@ -1,936 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Reflection;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-using PermissionMask = OpenSim.Framework.PermissionMask;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// Permissions bitflags
-    /// </summary>
-    /*
-    [Flags]
-    public enum PermissionMask : uint
-    {
-        None = 0,
-        Transfer = 1 << 13,
-        Modify = 1 << 14,
-        Copy = 1 << 15,
-        Move = 1 << 19,
-        Damage = 1 << 20,
-        All = 0x7FFFFFFF
-    }
-    */
-
-    /// <summary>
-    /// Connects avatar inventories to the SimianGrid backend
-    /// </summary>
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianInventoryServiceConnector")]
-    public class SimianInventoryServiceConnector : IInventoryService, ISharedRegionModule
-    {
-        private static readonly ILog m_log =
-                LogManager.GetLogger(
-                MethodBase.GetCurrentMethod().DeclaringType);
-
-        private string m_serverUrl = String.Empty;
-        private string m_userServerUrl = String.Empty;
-//        private object m_gestureSyncRoot = new object();
-        private bool m_Enabled = false;
-
-        private const double CACHE_EXPIRATION_SECONDS = 20.0;
-        private static ExpiringCache<UUID, InventoryItemBase> m_ItemCache;
-
-        #region ISharedRegionModule
-
-        public Type ReplaceableInterface { get { return null; } }
-        public void RegionLoaded(Scene scene) { }
-        public void PostInitialise() { }
-        public void Close() { }
-
-        public SimianInventoryServiceConnector() { }
-        public string Name { get { return "SimianInventoryServiceConnector"; } }
-        public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IInventoryService>(this); } }
-        public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IInventoryService>(this); } }
-
-        #endregion ISharedRegionModule
-
-        public SimianInventoryServiceConnector(IConfigSource source)
-        {
-            CommonInit(source);
-        }
-
-        public SimianInventoryServiceConnector(string url)
-        {
-            if (!url.EndsWith("/") && !url.EndsWith("="))
-                url = url + '/';
-            m_serverUrl = url;
-
-            if (m_ItemCache == null)
-                m_ItemCache = new ExpiringCache<UUID, InventoryItemBase>();
-
-        }
-
-        public void Initialise(IConfigSource source)
-        {
-            IConfig moduleConfig = source.Configs["Modules"];
-            if (moduleConfig != null)
-            {
-                string name = moduleConfig.GetString("InventoryServices", "");
-                if (name == Name)
-                    CommonInit(source);
-            }
-        }
-
-        private void CommonInit(IConfigSource source)
-        {
-            IConfig gridConfig = source.Configs["InventoryService"];
-            if (gridConfig != null)
-            {
-                string serviceUrl = gridConfig.GetString("InventoryServerURI");
-                if (!String.IsNullOrEmpty(serviceUrl))
-                {
-                    if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
-                        serviceUrl = serviceUrl + '/';
-                    m_serverUrl = serviceUrl;
-
-                    gridConfig = source.Configs["UserAccountService"];
-                    if (gridConfig != null)
-                    {
-                        serviceUrl = gridConfig.GetString("UserAccountServerURI");
-                        if (!String.IsNullOrEmpty(serviceUrl))
-                        {
-                            m_userServerUrl = serviceUrl;
-                            m_Enabled = true;
-                            if (m_ItemCache == null)
-                                m_ItemCache = new ExpiringCache<UUID, InventoryItemBase>();
-                        }
-                    }
-                }
-            }
-
-            if (String.IsNullOrEmpty(m_serverUrl))
-                m_log.Info("[SIMIAN INVENTORY CONNECTOR]: No InventoryServerURI specified, disabling connector");
-            else if (String.IsNullOrEmpty(m_userServerUrl))
-                m_log.Info("[SIMIAN INVENTORY CONNECTOR]: No UserAccountServerURI specified, disabling connector");
-        }
-
-        /// <summary>
-        /// Create the entire inventory for a given user
-        /// </summary>
-        /// <param name="user"></param>
-        /// <returns></returns>
-        public bool CreateUserInventory(UUID userID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddInventory" },
-                { "OwnerID", userID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Inventory creation for " + userID + " failed: " + response["Message"].AsString());
-
-            return success;
-        }
-
-        /// <summary>
-        /// Gets the skeleton of the inventory -- folders only
-        /// </summary>
-        /// <param name="userID"></param>
-        /// <returns></returns>
-        public List<InventoryFolderBase> GetInventorySkeleton(UUID userID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetInventoryNode" },
-                { "ItemID", userID.ToString() },
-                { "OwnerID", userID.ToString() },
-                { "IncludeFolders", "1" },
-                { "IncludeItems", "0" },
-                { "ChildrenOnly", "0" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
-            {
-                OSDArray items = (OSDArray)response["Items"];
-                return GetFoldersFromResponse(items, userID, true);
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to retrieve inventory skeleton for " + userID + ": " +
-                    response["Message"].AsString());
-                return new List<InventoryFolderBase>(0);
-            }
-        }
-
-        /// <summary>
-        /// Retrieve the root inventory folder for the given user.
-        /// </summary>
-        /// <param name="userID"></param>
-        /// <returns>null if no root folder was found</returns>
-        public InventoryFolderBase GetRootFolder(UUID userID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetInventoryNode" },
-                { "ItemID", userID.ToString() },
-                { "OwnerID", userID.ToString() },
-                { "IncludeFolders", "1" },
-                { "IncludeItems", "0" },
-                { "ChildrenOnly", "1" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
-            {
-                OSDArray items = (OSDArray)response["Items"];
-                List<InventoryFolderBase> folders = GetFoldersFromResponse(items, userID, true);
-
-                if (folders.Count > 0)
-                    return folders[0];
-            }
-
-            return null;
-        }
-
-        /// <summary>
-        /// Gets the user folder for the given folder-type
-        /// </summary>
-        /// <param name="userID"></param>
-        /// <param name="type"></param>
-        /// <returns></returns>
-        public InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
-        {
-            string contentType = SLUtil.SLAssetTypeToContentType((int)type);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetFolderForType" },
-                { "ContentType", contentType },
-                { "OwnerID", userID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Folder"] is OSDMap)
-            {
-                OSDMap folder = (OSDMap)response["Folder"];
-
-                return new InventoryFolderBase(
-                    folder["ID"].AsUUID(),
-                    folder["Name"].AsString(),
-                    folder["OwnerID"].AsUUID(),
-                    (short)SLUtil.ContentTypeToSLAssetType(folder["ContentType"].AsString()),
-                    folder["ParentID"].AsUUID(),
-                    (ushort)folder["Version"].AsInteger()
-                );
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Default folder not found for content type " + contentType + ": " + response["Message"].AsString());
-                return GetRootFolder(userID);
-            }
-        }
-
-        /// <summary>
-        /// Get an item, given by its UUID
-        /// </summary>
-        /// <param name="item"></param>
-        /// <returns></returns>
-        public InventoryItemBase GetItem(UUID principalID, UUID itemID)
-        {
-            InventoryItemBase retrieved = null;
-            if (m_ItemCache.TryGetValue(itemID, out retrieved))
-                return retrieved;
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetInventoryNode" },
-                { "ItemID", itemID.ToString() },
-                { "OwnerID", principalID.ToString() },
-                { "IncludeFolders", "1" },
-                { "IncludeItems", "1" },
-                { "ChildrenOnly", "1" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
-            {
-                List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]);
-                if (items.Count > 0)
-                {
-                    // The requested item should be the first in this list, but loop through
-                    // and sanity check just in case
-                    for (int i = 0; i < items.Count; i++)
-                    {
-                        if (items[i].ID == itemID)
-                        {
-                            retrieved = items[i];
-                            m_ItemCache.AddOrUpdate(itemID, retrieved, CACHE_EXPIRATION_SECONDS);
-                            return retrieved;
-                        }
-                    }
-                }
-            }
-
-            m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Item " + itemID + " owned by " + principalID + " not found");
-            return null;
-        }
-
-        public InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
-        {
-            InventoryItemBase[] result = new InventoryItemBase[itemIDs.Length];
-            int i = 0;
-            foreach (UUID id in itemIDs)
-                result[i++] = GetItem(principalID, id);
-
-            return result;
-        }
-
-        /// <summary>
-        /// Get a folder, given by its UUID
-        /// </summary>
-        /// <param name="folder"></param>
-        /// <returns></returns>
-        public InventoryFolderBase GetFolder(UUID principalID, UUID folderID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetInventoryNode" },
-                { "ItemID", folderID.ToString() },
-                { "OwnerID", principalID.ToString() },
-                { "IncludeFolders", "1" },
-                { "IncludeItems", "0" },
-                { "ChildrenOnly", "1" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
-            {
-                OSDArray items = (OSDArray)response["Items"];
-                List<InventoryFolderBase> folders = GetFoldersFromResponse(items, folderID, true);
-
-                if (folders.Count > 0)
-                    return folders[0];
-            }
-
-            return null;
-        }
-
-        /// <summary>
-        /// Gets everything (folders and items) inside a folder
-        /// </summary>
-        /// <param name="userID"></param>
-        /// <param name="folderID"></param>
-        /// <returns></returns>
-        public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
-        {
-            InventoryCollection inventory = new InventoryCollection();
-            inventory.OwnerID = userID;
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetInventoryNode" },
-                { "ItemID", folderID.ToString() },
-                { "OwnerID", userID.ToString() },
-                { "IncludeFolders", "1" },
-                { "IncludeItems", "1" },
-                { "ChildrenOnly", "1" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
-            {
-                OSDArray items = (OSDArray)response["Items"];
-
-                inventory.Folders = GetFoldersFromResponse(items, folderID, false);
-                inventory.Items = GetItemsFromResponse(items);
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error fetching folder " + folderID + " content for " + userID + ": " +
-                    response["Message"].AsString());
-                inventory.Folders = new List<InventoryFolderBase>(0);
-                inventory.Items = new List<InventoryItemBase>(0);
-            }
-
-            return inventory;
-        }
-
-        public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
-        {
-            InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
-            int i = 0;
-            foreach (UUID fid in folderIDs)
-            {
-                invColl[i++] = GetFolderContent(principalID, fid);
-            }
-
-            return invColl;
-        }
-
-        /// <summary>
-        /// Gets the items inside a folder
-        /// </summary>
-        /// <param name="userID"></param>
-        /// <param name="folderID"></param>
-        /// <returns></returns>
-        public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
-        {
-            InventoryCollection inventory = new InventoryCollection();
-            inventory.OwnerID = userID;
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetInventoryNode" },
-                { "ItemID", folderID.ToString() },
-                { "OwnerID", userID.ToString() },
-                { "IncludeFolders", "0" },
-                { "IncludeItems", "1" },
-                { "ChildrenOnly", "1" }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
-            {
-                OSDArray items = (OSDArray)response["Items"];
-                return GetItemsFromResponse(items);
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error fetching folder " + folderID + " for " + userID + ": " +
-                    response["Message"].AsString());
-                return new List<InventoryItemBase>(0);
-            }
-        }
-
-        /// <summary>
-        /// Add a new folder to the user's inventory
-        /// </summary>
-        /// <param name="folder"></param>
-        /// <returns>true if the folder was successfully added</returns>
-        public bool AddFolder(InventoryFolderBase folder)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddInventoryFolder" },
-                { "FolderID", folder.ID.ToString() },
-                { "ParentID", folder.ParentID.ToString() },
-                { "OwnerID", folder.Owner.ToString() },
-                { "Name", folder.Name },
-                { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error creating folder " + folder.Name + " for " + folder.Owner + ": " +
-                    response["Message"].AsString());
-            }
-
-            return success;
-        }
-
-        /// <summary>
-        /// Update a folder in the user's inventory
-        /// </summary>
-        /// <param name="folder"></param>
-        /// <returns>true if the folder was successfully updated</returns>
-        public bool UpdateFolder(InventoryFolderBase folder)
-        {
-            return AddFolder(folder);
-        }
-
-        /// <summary>
-        /// Move an inventory folder to a new location
-        /// </summary>
-        /// <param name="folder">A folder containing the details of the new location</param>
-        /// <returns>true if the folder was successfully moved</returns>
-        public bool MoveFolder(InventoryFolderBase folder)
-        {
-            return AddFolder(folder);
-        }
-
-        /// <summary>
-        /// Delete an item from the user's inventory
-        /// </summary>
-        /// <param name="item"></param>
-        /// <returns>true if the item was successfully deleted</returns>
-        //bool DeleteItem(InventoryItemBase item);
-        public bool DeleteFolders(UUID userID, List<UUID> folderIDs)
-        {
-            return DeleteItems(userID, folderIDs);
-        }
-
-        /// <summary>
-        /// Delete an item from the user's inventory
-        /// </summary>
-        /// <param name="item"></param>
-        /// <returns>true if the item was successfully deleted</returns>
-        public bool DeleteItems(UUID userID, List<UUID> itemIDs)
-        {
-            // TODO: RemoveInventoryNode should be replaced with RemoveInventoryNodes
-            bool allSuccess = true;
-
-            for (int i = 0; i < itemIDs.Count; i++)
-            {
-                UUID itemID = itemIDs[i];
-
-                NameValueCollection requestArgs = new NameValueCollection
-                {
-                    { "RequestMethod", "RemoveInventoryNode" },
-                    { "OwnerID", userID.ToString() },
-                    { "ItemID", itemID.ToString() }
-                };
-
-                OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-                bool success = response["Success"].AsBoolean();
-
-                if (!success)
-                {
-                    m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error removing item " + itemID + " for " + userID + ": " +
-                        response["Message"].AsString());
-                    allSuccess = false;
-                }
-            }
-
-            return allSuccess;
-        }
-
-        /// <summary>
-        /// Purge an inventory folder of all its items and subfolders.
-        /// </summary>
-        /// <param name="folder"></param>
-        /// <returns>true if the folder was successfully purged</returns>
-        public bool PurgeFolder(InventoryFolderBase folder)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "PurgeInventoryFolder" },
-                { "OwnerID", folder.Owner.ToString() },
-                { "FolderID", folder.ID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error purging folder " + folder.ID + " for " + folder.Owner + ": " +
-                    response["Message"].AsString());
-            }
-
-            return success;
-        }
-
-        /// <summary>
-        /// Add a new item to the user's inventory
-        /// </summary>
-        /// <param name="item"></param>
-        /// <returns>true if the item was successfully added</returns>
-        public bool AddItem(InventoryItemBase item)
-        {
-            // A folder of UUID.Zero means we need to find the most appropriate home for this item
-            if (item.Folder == UUID.Zero)
-            {
-                InventoryFolderBase folder = null;
-                if (Enum.IsDefined(typeof(FolderType), (sbyte)item.AssetType))
-                    folder = GetFolderForType(item.Owner, (FolderType)item.AssetType);
-                if (folder != null && folder.ID != UUID.Zero)
-                    item.Folder = folder.ID;
-                else
-                    item.Folder = item.Owner; // Root folder
-            }
-
-            if ((AssetType)item.AssetType == AssetType.Gesture)
-                UpdateGesture(item.Owner, item.ID, item.Flags == 1);
-
-            if (item.BasePermissions == 0)
-                m_log.WarnFormat("[SIMIAN INVENTORY CONNECTOR]: Adding inventory item {0} ({1}) with no base permissions", item.Name, item.ID);
-
-            OSDMap permissions = new OSDMap
-            {
-                { "BaseMask", OSD.FromInteger(item.BasePermissions) },
-                { "EveryoneMask", OSD.FromInteger(item.EveryOnePermissions) },
-                { "GroupMask", OSD.FromInteger(item.GroupPermissions) },
-                { "NextOwnerMask", OSD.FromInteger(item.NextPermissions) },
-                { "OwnerMask", OSD.FromInteger(item.CurrentPermissions) }
-            };
-
-            OSDMap extraData = new OSDMap()
-            {
-                { "Flags", OSD.FromInteger(item.Flags) },
-                { "GroupID", OSD.FromUUID(item.GroupID) },
-                { "GroupOwned", OSD.FromBoolean(item.GroupOwned) },
-                { "SalePrice", OSD.FromInteger(item.SalePrice) },
-                { "SaleType", OSD.FromInteger(item.SaleType) },
-                { "Permissions", permissions }
-            };
-
-            // Add different asset type only if it differs from inventory type
-            // (needed for links)
-            string invContentType = SLUtil.SLInvTypeToContentType(item.InvType);
-            string assetContentType = SLUtil.SLAssetTypeToContentType(item.AssetType);
-
-            if (invContentType != assetContentType)
-                extraData["LinkedItemType"] = OSD.FromString(assetContentType);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddInventoryItem" },
-                { "ItemID", item.ID.ToString() },
-                { "AssetID", item.AssetID.ToString() },
-                { "ParentID", item.Folder.ToString() },
-                { "OwnerID", item.Owner.ToString() },
-                { "Name", item.Name },
-                { "Description", item.Description },
-                { "CreatorID", item.CreatorId },
-                { "CreatorData", item.CreatorData },
-                { "ContentType", invContentType },
-                { "ExtraData", OSDParser.SerializeJsonString(extraData) }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error creating item " + item.Name + " for " + item.Owner + ": " +
-                    response["Message"].AsString());
-            }
-
-            return success;
-        }
-
-        /// <summary>
-        /// Update an item in the user's inventory
-        /// </summary>
-        /// <param name="item"></param>
-        /// <returns>true if the item was successfully updated</returns>
-        public bool UpdateItem(InventoryItemBase item)
-        {
-            if (item.AssetID != UUID.Zero)
-            {
-                return AddItem(item);
-            }
-            else
-            {
-                // This is actually a folder update
-                InventoryFolderBase folder = new InventoryFolderBase(item.ID, item.Name, item.Owner, (short)item.AssetType, item.Folder, 0);
-                return UpdateFolder(folder);
-            }
-        }
-
-        public bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
-        {
-            bool success = true;
-
-            while (items.Count > 0)
-            {
-                List<InventoryItemBase> currentItems = new List<InventoryItemBase>();
-                UUID destFolderID = items[0].Folder;
-
-                // Find all of the items being moved to the current destination folder
-                for (int i = 0; i < items.Count; i++)
-                {
-                    InventoryItemBase item = items[i];
-                    if (item.Folder == destFolderID)
-                        currentItems.Add(item);
-                }
-
-                // Do the inventory move for the current items
-                success &= MoveItems(ownerID, items, destFolderID);
-
-                // Remove the processed items from the list
-                for (int i = 0; i < currentItems.Count; i++)
-                    items.Remove(currentItems[i]);
-            }
-
-            return success;
-        }
-
-        /// <summary>
-        /// Does the given user have an inventory structure?
-        /// </summary>
-        /// <param name="userID"></param>
-        /// <returns></returns>
-        public bool HasInventoryForUser(UUID userID)
-        {
-            return GetRootFolder(userID) != null;
-        }
-
-        /// <summary>
-        /// Get the active gestures of the agent.
-        /// </summary>
-        /// <param name="userID"></param>
-        /// <returns></returns>
-        public List<InventoryItemBase> GetActiveGestures(UUID userID)
-        {
-            OSDArray items = FetchGestures(userID);
-
-            string[] itemIDs = new string[items.Count];
-            for (int i = 0; i < items.Count; i++)
-                itemIDs[i] = items[i].AsUUID().ToString();
-
-//            NameValueCollection requestArgs = new NameValueCollection
-//            {
-//                { "RequestMethod", "GetInventoryNodes" },
-//                { "OwnerID", userID.ToString() },
-//                { "Items", String.Join(",", itemIDs) }
-//            };
-
-            // FIXME: Implement this in SimianGrid
-            return new List<InventoryItemBase>(0);
-        }
-
-        /// <summary>
-        /// Get the union of permissions of all inventory items
-        /// that hold the given assetID.
-        /// </summary>
-        /// <param name="userID"></param>
-        /// <param name="assetID"></param>
-        /// <returns>The permissions or 0 if no such asset is found in
-        /// the user's inventory</returns>
-        public int GetAssetPermissions(UUID userID, UUID assetID)
-        {
-//            NameValueCollection requestArgs = new NameValueCollection
-//            {
-//                { "RequestMethod", "GetInventoryNodes" },
-//                { "OwnerID", userID.ToString() },
-//                { "AssetID", assetID.ToString() }
-//            };
-
-            // FIXME: Implement this in SimianGrid
-            return (int)PermissionMask.All;
-        }
-
-        private List<InventoryFolderBase> GetFoldersFromResponse(OSDArray items, UUID baseFolder, bool includeBaseFolder)
-        {
-            List<InventoryFolderBase> invFolders = new List<InventoryFolderBase>(items.Count);
-
-            for (int i = 0; i < items.Count; i++)
-            {
-                OSDMap item = items[i] as OSDMap;
-
-                if (item != null && item["Type"].AsString() == "Folder")
-                {
-                    UUID folderID = item["ID"].AsUUID();
-
-                    if (folderID == baseFolder && !includeBaseFolder)
-                        continue;
-
-                    invFolders.Add(new InventoryFolderBase(
-                        folderID,
-                        item["Name"].AsString(),
-                        item["OwnerID"].AsUUID(),
-                        (short)SLUtil.ContentTypeToSLAssetType(item["ContentType"].AsString()),
-                        item["ParentID"].AsUUID(),
-                        (ushort)item["Version"].AsInteger()
-                    ));
-                }
-            }
-
-//            m_log.Debug("[SIMIAN INVENTORY CONNECTOR]: Parsed " + invFolders.Count + " folders from SimianGrid response");
-            return invFolders;
-        }
-
-        private List<InventoryItemBase> GetItemsFromResponse(OSDArray items)
-        {
-            List<InventoryItemBase> invItems = new List<InventoryItemBase>(items.Count);
-
-            for (int i = 0; i < items.Count; i++)
-            {
-                OSDMap item = items[i] as OSDMap;
-
-                if (item != null && item["Type"].AsString() == "Item")
-                {
-                    InventoryItemBase invItem = new InventoryItemBase();
-
-                    invItem.AssetID = item["AssetID"].AsUUID();
-                    invItem.AssetType = SLUtil.ContentTypeToSLAssetType(item["ContentType"].AsString());
-                    invItem.CreationDate = item["CreationDate"].AsInteger();
-                    invItem.CreatorId = item["CreatorID"].AsString();
-                    invItem.CreatorData = item["CreatorData"].AsString();
-                    invItem.Description = item["Description"].AsString();
-                    invItem.Folder = item["ParentID"].AsUUID();
-                    invItem.ID = item["ID"].AsUUID();
-                    invItem.InvType = SLUtil.ContentTypeToSLInvType(item["ContentType"].AsString());
-                    invItem.Name = item["Name"].AsString();
-                    invItem.Owner = item["OwnerID"].AsUUID();
-
-                    OSDMap extraData = item["ExtraData"] as OSDMap;
-                    if (extraData != null && extraData.Count > 0)
-                    {
-                        invItem.Flags = extraData["Flags"].AsUInteger();
-                        invItem.GroupID = extraData["GroupID"].AsUUID();
-                        invItem.GroupOwned = extraData["GroupOwned"].AsBoolean();
-                        invItem.SalePrice = extraData["SalePrice"].AsInteger();
-                        invItem.SaleType = (byte)extraData["SaleType"].AsInteger();
-
-                        OSDMap perms = extraData["Permissions"] as OSDMap;
-                        if (perms != null)
-                        {
-                            invItem.BasePermissions = perms["BaseMask"].AsUInteger();
-                            invItem.CurrentPermissions = perms["OwnerMask"].AsUInteger();
-                            invItem.EveryOnePermissions = perms["EveryoneMask"].AsUInteger();
-                            invItem.GroupPermissions = perms["GroupMask"].AsUInteger();
-                            invItem.NextPermissions = perms["NextOwnerMask"].AsUInteger();
-                        }
-
-                        if (extraData.ContainsKey("LinkedItemType"))
-                            invItem.AssetType = SLUtil.ContentTypeToSLAssetType(extraData["LinkedItemType"].AsString());
-                    }
-
-                    if (invItem.BasePermissions == 0)
-                    {
-                        m_log.InfoFormat("[SIMIAN INVENTORY CONNECTOR]: Forcing item permissions to full for item {0} ({1})",
-                            invItem.Name, invItem.ID);
-                        invItem.BasePermissions = (uint)PermissionMask.All;
-                        invItem.CurrentPermissions = (uint)PermissionMask.All;
-                        invItem.EveryOnePermissions = (uint)PermissionMask.All;
-                        invItem.GroupPermissions = (uint)PermissionMask.All;
-                        invItem.NextPermissions = (uint)PermissionMask.All;
-                    }
-
-                    invItems.Add(invItem);
-                }
-            }
-
-//            m_log.Debug("[SIMIAN INVENTORY CONNECTOR]: Parsed " + invItems.Count + " items from SimianGrid response");
-            return invItems;
-        }
-
-        private bool MoveItems(UUID ownerID, List<InventoryItemBase> items, UUID destFolderID)
-        {
-            string[] itemIDs = new string[items.Count];
-            for (int i = 0; i < items.Count; i++)
-                itemIDs[i] = items[i].ID.ToString();
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "MoveInventoryNodes" },
-                { "OwnerID", ownerID.ToString() },
-                { "FolderID", destFolderID.ToString() },
-                { "Items", String.Join(",", itemIDs) }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to move " + items.Count + " items to " +
-                    destFolderID + ": " + response["Message"].AsString());
-            }
-
-            return success;
-        }
-
-        private void UpdateGesture(UUID userID, UUID itemID, bool enabled)
-        {
-            OSDArray gestures = FetchGestures(userID);
-            OSDArray newGestures = new OSDArray();
-
-            for (int i = 0; i < gestures.Count; i++)
-            {
-                UUID gesture = gestures[i].AsUUID();
-                if (gesture != itemID)
-                    newGestures.Add(OSD.FromUUID(gesture));
-            }
-
-            if (enabled)
-                newGestures.Add(OSD.FromUUID(itemID));
-
-            SaveGestures(userID, newGestures);
-        }
-
-        private OSDArray FetchGestures(UUID userID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUser" },
-                { "UserID", userID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                OSDMap user = response["User"] as OSDMap;
-                if (user != null && response.ContainsKey("Gestures"))
-                {
-                    OSD gestures = OSDParser.DeserializeJson(response["Gestures"].AsString());
-                    if (gestures != null && gestures is OSDArray)
-                        return (OSDArray)gestures;
-                    else
-                        m_log.Error("[SIMIAN INVENTORY CONNECTOR]: Unrecognized active gestures data for " + userID);
-                }
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to fetch active gestures for " + userID + ": " +
-                    response["Message"].AsString());
-            }
-
-            return new OSDArray();
-        }
-
-        private void SaveGestures(UUID userID, OSDArray gestures)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddUserData" },
-                { "UserID", userID.ToString() },
-                { "Gestures", OSDParser.SerializeJsonString(gestures) }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
-            if (!response["Success"].AsBoolean())
-            {
-                m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " +
-                    response["Message"].AsString());
-            }
-        }
-    }
-}

+ 0 - 459
OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs

@@ -1,459 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Reflection;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// Connects avatar presence information (for tracking current location and
-    /// message routing) to the SimianGrid backend
-    /// </summary>
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianPresenceServiceConnector")]
-    public class SimianPresenceServiceConnector : IPresenceService, IGridUserService, ISharedRegionModule
-    {
-        private static readonly ILog m_log =
-                LogManager.GetLogger(
-                MethodBase.GetCurrentMethod().DeclaringType);
-
-        private string m_serverUrl = String.Empty;
-        private SimianActivityDetector m_activityDetector;
-        private bool m_Enabled = false;
-
-        #region ISharedRegionModule
-
-        public Type ReplaceableInterface { get { return null; } }
-        public void RegionLoaded(Scene scene) { }
-        public void PostInitialise() { }
-        public void Close() { }
-
-        public SimianPresenceServiceConnector() { }
-        public string Name { get { return "SimianPresenceServiceConnector"; } }
-        public void AddRegion(Scene scene)
-        {
-            if (m_Enabled)
-            {
-                scene.RegisterModuleInterface<IPresenceService>(this);
-                scene.RegisterModuleInterface<IGridUserService>(this);
-
-                m_activityDetector.AddRegion(scene);
-
-                LogoutRegionAgents(scene.RegionInfo.RegionID);
-            }
-        }
-        public void RemoveRegion(Scene scene)
-        {
-            if (m_Enabled)
-            {
-                scene.UnregisterModuleInterface<IPresenceService>(this);
-                scene.UnregisterModuleInterface<IGridUserService>(this);
-
-                m_activityDetector.RemoveRegion(scene);
-
-                LogoutRegionAgents(scene.RegionInfo.RegionID);
-            }
-        }
-
-        #endregion ISharedRegionModule
-
-        public SimianPresenceServiceConnector(IConfigSource source)
-        {
-            CommonInit(source);
-        }
-
-        public void Initialise(IConfigSource source)
-        {
-            IConfig moduleConfig = source.Configs["Modules"];
-            if (moduleConfig != null)
-            {
-                string name = moduleConfig.GetString("PresenceServices", "");
-                if (name == Name)
-                    CommonInit(source);
-            }
-        }
-
-        private void CommonInit(IConfigSource source)
-        {
-            IConfig gridConfig = source.Configs["PresenceService"];
-            if (gridConfig != null)
-            {
-                string serviceUrl = gridConfig.GetString("PresenceServerURI");
-                if (!String.IsNullOrEmpty(serviceUrl))
-                {
-                    if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
-                        serviceUrl = serviceUrl + '/';
-                    m_serverUrl = serviceUrl;
-                    m_activityDetector = new SimianActivityDetector(this);
-                    m_Enabled = true;
-                }
-            }
-
-            if (String.IsNullOrEmpty(m_serverUrl))
-                m_log.Info("[SIMIAN PRESENCE CONNECTOR]: No PresenceServerURI specified, disabling connector");
-        }
-
-        #region IPresenceService
-
-        public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID)
-        {
-            m_log.ErrorFormat("[SIMIAN PRESENCE CONNECTOR]: Login requested, UserID={0}, SessionID={1}, SecureSessionID={2}",
-                userID, sessionID, secureSessionID);
-
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                        { "RequestMethod", "AddSession" },
-                        { "UserID", userID.ToString() }
-                };
-
-            if (sessionID != UUID.Zero)
-            {
-                requestArgs["SessionID"] = sessionID.ToString();
-                requestArgs["SecureSessionID"] = secureSessionID.ToString();
-            }
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to login agent " + userID + ": " + response["Message"].AsString());
-
-            return success;
-        }
-
-        public bool LogoutAgent(UUID sessionID)
-        {
-            // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID);
-
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                        { "RequestMethod", "RemoveSession" },
-                        { "SessionID", sessionID.ToString() }
-                };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to logout agent with sessionID " + sessionID + ": " + response["Message"].AsString());
-
-            return success;
-        }
-
-        public bool LogoutRegionAgents(UUID regionID)
-        {
-            // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID);
-
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                        { "RequestMethod", "RemoveSessions" },
-                        { "SceneID", regionID.ToString() }
-                };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to logout agents from region " + regionID + ": " + response["Message"].AsString());
-
-            return success;
-        }
-
-        public bool ReportAgent(UUID sessionID, UUID regionID)
-        {
-            // Not needed for SimianGrid
-            return true;
-        }
-
-        public PresenceInfo GetAgent(UUID sessionID)
-        {
-            OSDMap sessionResponse = GetSessionDataFromSessionID(sessionID);
-            if (sessionResponse == null)
-            {
-                m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString());
-                return null;
-            }
-
-            UUID userID = sessionResponse["UserID"].AsUUID();
-            OSDMap userResponse = GetUserData(userID);
-            if (userResponse == null)
-            {
-                m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID.ToString(),userResponse["Message"].AsString());
-                return null;
-            }
-
-            return ResponseToPresenceInfo(sessionResponse);
-        }
-
-        public PresenceInfo[] GetAgents(string[] userIDs)
-        {
-            List<PresenceInfo> presences = new List<PresenceInfo>();
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetSessions" },
-                { "UserIDList", String.Join(",",userIDs) }
-            };
-
-            OSDMap sessionListResponse = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (! sessionListResponse["Success"].AsBoolean())
-            {
-                m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString());
-                return null;
-            }
-
-            OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray;
-            for (int i = 0; i < sessionList.Count; i++)
-            {
-                OSDMap sessionInfo = sessionList[i] as OSDMap;
-                presences.Add(ResponseToPresenceInfo(sessionInfo));
-            }
-
-            return presences.ToArray();
-        }
-
-        #endregion IPresenceService
-
-        #region IGridUserService
-
-        public GridUserInfo LoggedIn(string userID)
-        {
-            // Never implemented at the sim
-            return null;
-        }
-
-        public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
-        {
-            // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID);
-
-            // Remove the session to mark this user offline
-            if (!LogoutAgent(sessionID))
-                return false;
-
-            // Save our last position as user data
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                        { "RequestMethod", "AddUserData" },
-                        { "UserID", userID.ToString() },
-                        { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) }
-                };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to set last location for " + userID + ": " + response["Message"].AsString());
-
-            return success;
-        }
-
-        public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
-        {
-            // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user  " + userID);
-
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                        { "RequestMethod", "AddUserData" },
-                        { "UserID", userID.ToString() },
-                        { "HomeLocation", SerializeLocation(regionID, position, lookAt) }
-                };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to set home location for " + userID + ": " + response["Message"].AsString());
-
-            return success;
-        }
-
-        public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
-        {
-            return UpdateSession(sessionID, regionID, lastPosition, lastLookAt);
-        }
-
-        public GridUserInfo GetGridUserInfo(string user)
-        {
-            // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
-
-            UUID userID = new UUID(user);
-            OSDMap userResponse = GetUserData(userID);
-
-            if (userResponse == null)
-            {
-                m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}", userID);
-            }
-
-            // Note that ResponseToGridUserInfo properly checks for and returns a null if passed a null.
-            return ResponseToGridUserInfo(userResponse);
-
-        }
-
-        #endregion
-
-        #region Helpers
-
-        private OSDMap GetUserData(UUID userID)
-        {
-            // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
-
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                        { "RequestMethod", "GetUser" },
-                        { "UserID", userID.ToString() }
-                };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["User"] is OSDMap)
-                return response;
-
-            m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}; {1}",userID.ToString(),response["Message"].AsString());
-            return null;
-        }
-
-        private OSDMap GetSessionDataFromSessionID(UUID sessionID)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                        { "RequestMethod", "GetSession" },
-                        { "SessionID", sessionID.ToString() }
-                };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean())
-                return response;
-
-            m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session data for {0}; {1}",sessionID.ToString(),response["Message"].AsString());
-            return null;
-        }
-
-        private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
-        {
-            // Save our current location as session data
-            NameValueCollection requestArgs = new NameValueCollection
-                {
-                        { "RequestMethod", "UpdateSession" },
-                        { "SessionID", sessionID.ToString() },
-                        { "SceneID", regionID.ToString() },
-                        { "ScenePosition", lastPosition.ToString() },
-                        { "SceneLookAt", lastLookAt.ToString() }
-                };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to update agent session " + sessionID + ": " + response["Message"].AsString());
-
-            return success;
-        }
-
-        private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse)
-        {
-            if (sessionResponse == null)
-                return null;
-
-            PresenceInfo info = new PresenceInfo();
-
-            info.UserID = sessionResponse["UserID"].AsUUID().ToString();
-            info.RegionID = sessionResponse["SceneID"].AsUUID();
-
-            return info;
-        }
-
-        private GridUserInfo ResponseToGridUserInfo(OSDMap userResponse)
-        {
-            if (userResponse != null && userResponse["User"] is OSDMap)
-            {
-                GridUserInfo info = new GridUserInfo();
-
-                info.Online = true;
-                info.UserID = userResponse["UserID"].AsUUID().ToString();
-                info.LastRegionID = userResponse["SceneID"].AsUUID();
-                info.LastPosition = userResponse["ScenePosition"].AsVector3();
-                info.LastLookAt = userResponse["SceneLookAt"].AsVector3();
-
-                OSDMap user = (OSDMap)userResponse["User"];
-
-                info.Login = user["LastLoginDate"].AsDate();
-                info.Logout = user["LastLogoutDate"].AsDate();
-                DeserializeLocation(user["HomeLocation"].AsString(), out info.HomeRegionID, out info.HomePosition, out info.HomeLookAt);
-
-                return info;
-            }
-
-            return null;
-        }
-
-        private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt)
-        {
-            return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}";
-        }
-
-        private bool DeserializeLocation(string location, out UUID regionID, out Vector3 position, out Vector3 lookAt)
-        {
-            OSDMap map = null;
-
-            try { map = OSDParser.DeserializeJson(location) as OSDMap; }
-            catch { }
-
-            if (map != null)
-            {
-                regionID = map["SceneID"].AsUUID();
-                if (Vector3.TryParse(map["Position"].AsString(), out position) &&
-                    Vector3.TryParse(map["LookAt"].AsString(), out lookAt))
-                {
-                    return true;
-                }
-            }
-
-            regionID = UUID.Zero;
-            position = Vector3.Zero;
-            lookAt = Vector3.Zero;
-            return false;
-        }
-
-        public GridUserInfo[] GetGridUserInfo(string[] userIDs)
-        {
-            return new GridUserInfo[0];
-         }
-        #endregion Helpers
-    }
-}

+ 0 - 478
OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs

@@ -1,478 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Reflection;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-using OpenSim.Framework;
-using OpenSim.Framework.Client;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// Avatar profile flags
-    /// </summary>
-    [Flags]
-    public enum ProfileFlags : uint
-    {
-        AllowPublish = 1,
-        MaturePublish = 2,
-        Identified = 4,
-        Transacted = 8,
-        Online = 16
-    }
-
-    /// <summary>
-    /// Connects avatar profile and classified queries to the SimianGrid
-    /// backend
-    /// </summary>
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianProfiles")]
-    public class SimianProfiles : INonSharedRegionModule
-    {
-        private static readonly ILog m_log =
-                LogManager.GetLogger(
-                MethodBase.GetCurrentMethod().DeclaringType);
-
-        private string m_serverUrl = String.Empty;
-        private bool m_Enabled = false;
-
-        #region INonSharedRegionModule
-
-        public Type ReplaceableInterface { get { return null; } }
-        public void RegionLoaded(Scene scene) { }
-        public void Close() { }
-
-        public SimianProfiles() { }
-        public string Name { get { return "SimianProfiles"; } }
-
-        public void AddRegion(Scene scene)
-        {
-            if (m_Enabled)
-            {
-                CheckEstateManager(scene);
-                scene.EventManager.OnClientConnect += ClientConnectHandler;
-            }
-        }
-
-        public void RemoveRegion(Scene scene)
-        {
-            if (m_Enabled)
-            {
-                scene.EventManager.OnClientConnect -= ClientConnectHandler;
-            }
-        }
-
-        #endregion INonSharedRegionModule
-
-        public SimianProfiles(IConfigSource source)
-        {
-            Initialise(source);
-        }
-
-        public void Initialise(IConfigSource source)
-        {
-            IConfig profileConfig = source.Configs["Profiles"];
-            if (profileConfig == null)
-                return;
-
-            if (profileConfig.GetString("Module", String.Empty) != Name)
-                return;
-
-            m_log.DebugFormat("[SIMIAN PROFILES] module enabled");
-            m_Enabled = true;
-
-            IConfig gridConfig = source.Configs["UserAccountService"];
-            if (gridConfig != null)
-            {
-                string serviceUrl = gridConfig.GetString("UserAccountServerURI");
-                if (!String.IsNullOrEmpty(serviceUrl))
-                {
-                    if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
-                        serviceUrl = serviceUrl + '/';
-                    m_serverUrl = serviceUrl;
-                }
-            }
-
-            if (String.IsNullOrEmpty(m_serverUrl))
-                m_log.Info("[SIMIAN PROFILES]: No UserAccountServerURI specified, disabling connector");
-        }
-
-        private void ClientConnectHandler(IClientCore clientCore)
-        {
-            if (clientCore is IClientAPI)
-            {
-                IClientAPI client = (IClientAPI)clientCore;
-
-                // Classifieds
-                client.AddGenericPacketHandler("avatarclassifiedsrequest", AvatarClassifiedsRequestHandler);
-                client.OnClassifiedInfoRequest += ClassifiedInfoRequestHandler;
-                client.OnClassifiedInfoUpdate += ClassifiedInfoUpdateHandler;
-                client.OnClassifiedDelete += ClassifiedDeleteHandler;
-
-                // Picks
-                client.AddGenericPacketHandler("avatarpicksrequest", HandleAvatarPicksRequest);
-                client.AddGenericPacketHandler("pickinforequest", HandlePickInfoRequest);
-                client.OnPickInfoUpdate += PickInfoUpdateHandler;
-                client.OnPickDelete += PickDeleteHandler;
-
-                // Notes
-                client.AddGenericPacketHandler("avatarnotesrequest", HandleAvatarNotesRequest);
-                client.OnAvatarNotesUpdate += AvatarNotesUpdateHandler;
-
-                // Profiles
-                client.OnRequestAvatarProperties += RequestAvatarPropertiesHandler;
-
-                client.OnUpdateAvatarProperties += UpdateAvatarPropertiesHandler;
-                client.OnAvatarInterestUpdate += AvatarInterestUpdateHandler;
-                client.OnUserInfoRequest += UserInfoRequestHandler;
-                client.OnUpdateUserInfo += UpdateUserInfoHandler;
-            }
-        }
-
-        #region Classifieds
-
-        private void AvatarClassifiedsRequestHandler(Object sender, string method, List<String> args)
-        {
-            if (!(sender is IClientAPI))
-                return;
-            IClientAPI client = (IClientAPI)sender;
-
-            UUID targetAvatarID;
-            if (args.Count < 1 || !UUID.TryParse(args[0], out targetAvatarID))
-            {
-                m_log.Error("[SIMIAN PROFILES]: Unrecognized arguments for " + method);
-                return;
-            }
-
-            // FIXME: Query the generic key/value store for classifieds
-            client.SendAvatarClassifiedReply(targetAvatarID, new Dictionary<UUID, string>(0));
-        }
-
-        private void ClassifiedInfoRequestHandler(UUID classifiedID, IClientAPI client)
-        {
-            // FIXME: Fetch this info
-            client.SendClassifiedInfoReply(classifiedID, UUID.Zero, 0, Utils.DateTimeToUnixTime(DateTime.UtcNow + TimeSpan.FromDays(1)),
-                0, String.Empty, String.Empty, UUID.Zero, 0, UUID.Zero, String.Empty, Vector3.Zero, String.Empty, 0, 0);
-        }
-
-        private void ClassifiedInfoUpdateHandler(UUID classifiedID, uint category, string name, string description,
-            UUID parcelID, uint parentEstate, UUID snapshotID, Vector3 globalPos, byte classifiedFlags, int price,
-            IClientAPI client)
-        {
-            // FIXME: Save this info
-        }
-
-        private void ClassifiedDeleteHandler(UUID classifiedID, IClientAPI client)
-        {
-            // FIXME: Delete the specified classified ad
-        }
-
-        #endregion Classifieds
-
-        #region Picks
-
-        private void HandleAvatarPicksRequest(Object sender, string method, List<String> args)
-        {
-            if (!(sender is IClientAPI))
-                return;
-            IClientAPI client = (IClientAPI)sender;
-
-            UUID targetAvatarID;
-            if (args.Count < 1 || !UUID.TryParse(args[0], out targetAvatarID))
-            {
-                m_log.Error("[SIMIAN PROFILES]: Unrecognized arguments for " + method);
-                return;
-            }
-
-            // FIXME: Fetch these
-            client.SendAvatarPicksReply(targetAvatarID, new Dictionary<UUID, string>(0));
-        }
-
-        private void HandlePickInfoRequest(Object sender, string method, List<String> args)
-        {
-            if (!(sender is IClientAPI))
-                return;
-            IClientAPI client = (IClientAPI)sender;
-
-            UUID avatarID;
-            UUID pickID;
-            if (args.Count < 2 || !UUID.TryParse(args[0], out avatarID) || !UUID.TryParse(args[1], out pickID))
-            {
-                m_log.Error("[SIMIAN PROFILES]: Unrecognized arguments for " + method);
-                return;
-            }
-
-            // FIXME: Fetch this
-            client.SendPickInfoReply(pickID, avatarID, false, UUID.Zero, String.Empty, String.Empty, UUID.Zero, String.Empty,
-                String.Empty, String.Empty, Vector3.Zero, 0, false);
-        }
-
-        private void PickInfoUpdateHandler(IClientAPI client, UUID pickID, UUID creatorID, bool topPick, string name,
-            string desc, UUID snapshotID, int sortOrder, bool enabled)
-        {
-            // FIXME: Save this
-        }
-
-        private void PickDeleteHandler(IClientAPI client, UUID pickID)
-        {
-            // FIXME: Delete
-        }
-
-        #endregion Picks
-
-        #region Notes
-
-        private void HandleAvatarNotesRequest(Object sender, string method, List<String> args)
-        {
-            if (!(sender is IClientAPI))
-                return;
-            IClientAPI client = (IClientAPI)sender;
-
-            UUID targetAvatarID;
-            if (args.Count < 1 || !UUID.TryParse(args[0], out targetAvatarID))
-            {
-                m_log.Error("[SIMIAN PROFILES]: Unrecognized arguments for " + method);
-                return;
-            }
-
-            // FIXME: Fetch this
-            client.SendAvatarNotesReply(targetAvatarID, String.Empty);
-        }
-
-        private void AvatarNotesUpdateHandler(IClientAPI client, UUID targetID, string notes)
-        {
-            // FIXME: Save this
-        }
-
-        #endregion Notes
-
-        #region Profiles
-
-        private void RequestAvatarPropertiesHandler(IClientAPI client, UUID avatarID)
-        {
-            m_log.DebugFormat("[SIMIAN PROFILES]: Request avatar properties for {0}",avatarID);
-
-            OSDMap user = FetchUserData(avatarID);
-
-            ProfileFlags flags = ProfileFlags.AllowPublish | ProfileFlags.MaturePublish;
-
-            if (user != null)
-            {
-                OSDMap about = null;
-                if (user.ContainsKey("LLAbout"))
-                {
-                    try
-                    {
-                        about = OSDParser.DeserializeJson(user["LLAbout"].AsString()) as OSDMap;
-                    }
-                    catch
-                    {
-                        m_log.WarnFormat("[SIMIAN PROFILES]: Unable to decode LLAbout");
-                    }
-                }
-
-                if (about == null)
-                    about = new OSDMap(0);
-
-                // Check if this user is a grid operator
-                byte[] membershipType;
-                if (user["AccessLevel"].AsInteger() >= 200)
-                    membershipType = Utils.StringToBytes("Operator");
-                else
-                    membershipType = Utils.EmptyBytes;
-
-                // Check if the user is online
-                if (client.Scene is Scene)
-                {
-                    OpenSim.Services.Interfaces.PresenceInfo[] presences = ((Scene)client.Scene).PresenceService.GetAgents(new string[] { avatarID.ToString() });
-                    if (presences != null && presences.Length > 0)
-                        flags |= ProfileFlags.Online;
-                }
-
-                // Check if the user is identified
-                if (user["Identified"].AsBoolean())
-                    flags |= ProfileFlags.Identified;
-
-                client.SendAvatarProperties(avatarID, about["About"].AsString(), user["CreationDate"].AsDate().ToString("M/d/yyyy",
-                    System.Globalization.CultureInfo.InvariantCulture), membershipType, about["FLAbout"].AsString(), (uint)flags,
-                    about["FLImage"].AsUUID(), about["Image"].AsUUID(), about["URL"].AsString(), user["Partner"].AsUUID());
-
-                OSDMap interests = null;
-                if (user.ContainsKey("LLInterests"))
-                {
-                    try
-                    {
-                        interests = OSDParser.DeserializeJson(user["LLInterests"].AsString()) as OSDMap;
-                        client.SendAvatarInterestsReply(avatarID, interests["WantMask"].AsUInteger(), interests["WantText"].AsString(), interests["SkillsMask"].AsUInteger(), interests["SkillsText"].AsString(), interests["Languages"].AsString());
-                    }
-                    catch { }
-                }
-
-                if (about == null)
-                    about = new OSDMap(0);
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN PROFILES]: Failed to fetch profile information for " + client.Name + ", returning default values");
-                client.SendAvatarProperties(avatarID, String.Empty, "1/1/1970", Utils.EmptyBytes,
-                        String.Empty, (uint)flags, UUID.Zero, UUID.Zero, String.Empty, UUID.Zero);
-            }
-        }
-
-        private void UpdateAvatarPropertiesHandler(IClientAPI client, UserProfileData profileData)
-        {
-            OSDMap map = new OSDMap
-            {
-                { "About", OSD.FromString(profileData.AboutText) },
-                { "Image", OSD.FromUUID(profileData.Image) },
-                { "FLAbout", OSD.FromString(profileData.FirstLifeAboutText) },
-                { "FLImage", OSD.FromUUID(profileData.FirstLifeImage) },
-                { "URL", OSD.FromString(profileData.ProfileUrl) }
-            };
-
-            AddUserData(client.AgentId, "LLAbout", map);
-        }
-
-        private void AvatarInterestUpdateHandler(IClientAPI client, uint wantmask, string wanttext, uint skillsmask,
-            string skillstext, string languages)
-        {
-            OSDMap map = new OSDMap
-            {
-                { "WantMask", OSD.FromInteger(wantmask) },
-                { "WantText", OSD.FromString(wanttext) },
-                { "SkillsMask", OSD.FromInteger(skillsmask) },
-                { "SkillsText", OSD.FromString(skillstext) },
-                { "Languages", OSD.FromString(languages) }
-            };
-
-            AddUserData(client.AgentId, "LLInterests", map);
-        }
-
-        private void UserInfoRequestHandler(IClientAPI client)
-        {
-            m_log.Error("[SIMIAN PROFILES]: UserInfoRequestHandler");
-
-            // Fetch this user's e-mail address
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUser" },
-                { "UserID", client.AgentId.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            string email = response["Email"].AsString();
-
-            if (!response["Success"].AsBoolean())
-                m_log.Warn("[SIMIAN PROFILES]: GetUser failed during a user info request for " + client.Name);
-
-            client.SendUserInfoReply(false, true, email);
-        }
-
-        private void UpdateUserInfoHandler(bool imViaEmail, bool visible, IClientAPI client)
-        {
-            m_log.Info("[SIMIAN PROFILES]: Ignoring user info update from " + client.Name);
-        }
-
-        #endregion Profiles
-
-        /// <summary>
-        /// Sanity checks regions for a valid estate owner at startup
-        /// </summary>
-        private void CheckEstateManager(Scene scene)
-        {
-            EstateSettings estate = scene.RegionInfo.EstateSettings;
-
-            if (estate.EstateOwner == UUID.Zero)
-            {
-                // Attempt to lookup the grid admin
-                UserAccount admin = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, UUID.Zero);
-                if (admin != null)
-                {
-                    m_log.InfoFormat("[SIMIAN PROFILES]: Setting estate {0} (ID: {1}) owner to {2}", estate.EstateName,
-                        estate.EstateID, admin.Name);
-
-                    estate.EstateOwner = admin.PrincipalID;
-                    scene.EstateDataService.StoreEstateSettings(estate);
-                }
-                else
-                {
-                    m_log.WarnFormat("[SIMIAN PROFILES]: Estate {0} (ID: {1}) does not have an owner", estate.EstateName, estate.EstateID);
-                }
-            }
-        }
-
-        private bool AddUserData(UUID userID, string key, OSDMap value)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddUserData" },
-                { "UserID", userID.ToString() },
-                { key, OSDParser.SerializeJsonString(value) }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            bool success = response["Success"].AsBoolean();
-
-            if (!success)
-                m_log.WarnFormat("[SIMIAN PROFILES]: Failed to add user data with key {0} for {1}: {2}", key, userID, response["Message"].AsString());
-
-            return success;
-        }
-
-        private OSDMap FetchUserData(UUID userID)
-        {
-            m_log.DebugFormat("[SIMIAN PROFILES]: Fetch information about {0}",userID);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUser" },
-                { "UserID", userID.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean() && response["User"] is OSDMap)
-            {
-                return (OSDMap)response["User"];
-            }
-            else
-            {
-                m_log.Error("[SIMIAN PROFILES]: Failed to fetch user data for " + userID + ": " + response["Message"].AsString());
-            }
-
-            return null;
-        }
-    }
-}

+ 0 - 347
OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs

@@ -1,347 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the OpenSimulator Project nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Reflection;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Services.Interfaces;
-using log4net;
-using Mono.Addins;
-using Nini.Config;
-using OpenMetaverse;
-using OpenMetaverse.StructuredData;
-
-namespace OpenSim.Services.Connectors.SimianGrid
-{
-    /// <summary>
-    /// Connects user account data (creating new users, looking up existing
-    /// users) to the SimianGrid backend
-    /// </summary>
-    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianUserAccountServiceConnector")]
-    public class SimianUserAccountServiceConnector : IUserAccountService, ISharedRegionModule
-    {
-        private const double CACHE_EXPIRATION_SECONDS = 120.0;
-
-        private static readonly ILog m_log =
-                LogManager.GetLogger(
-                MethodBase.GetCurrentMethod().DeclaringType);
-
-        private string m_serverUrl = String.Empty;
-        private ExpiringCache<UUID, UserAccount> m_accountCache = new ExpiringCache<UUID,UserAccount>();
-        private bool m_Enabled;
-
-        #region ISharedRegionModule
-
-        public Type ReplaceableInterface { get { return null; } }
-        public void RegionLoaded(Scene scene) { }
-        public void PostInitialise() { }
-        public void Close() { }
-
-        public SimianUserAccountServiceConnector() { }
-        public string Name { get { return "SimianUserAccountServiceConnector"; } }
-        public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IUserAccountService>(this); } }
-        public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IUserAccountService>(this); } }
-
-        #endregion ISharedRegionModule
-
-        public SimianUserAccountServiceConnector(IConfigSource source)
-        {
-            CommonInit(source);
-        }
-
-        public void Initialise(IConfigSource source)
-        {
-            IConfig moduleConfig = source.Configs["Modules"];
-            if (moduleConfig != null)
-            {
-                string name = moduleConfig.GetString("UserAccountServices", "");
-                if (name == Name)
-                    CommonInit(source);
-            }
-        }
-
-        private void CommonInit(IConfigSource source)
-        {
-            IConfig gridConfig = source.Configs["UserAccountService"];
-            if (gridConfig != null)
-            {
-                string serviceUrl = gridConfig.GetString("UserAccountServerURI");
-                if (!String.IsNullOrEmpty(serviceUrl))
-                {
-                    if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
-                        serviceUrl = serviceUrl + '/';
-                    m_serverUrl = serviceUrl;
-                    m_Enabled = true;
-                }
-            }
-
-            if (String.IsNullOrEmpty(m_serverUrl))
-                m_log.Info("[SIMIAN ACCOUNT CONNECTOR]: No UserAccountServerURI specified, disabling connector");
-        }
-
-        public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUser" },
-                { "Name", firstName + ' ' + lastName }
-            };
-
-            return GetUser(requestArgs);
-        }
-
-        public UserAccount GetUserAccount(UUID scopeID, string email)
-        {
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUser" },
-                { "Email", email }
-            };
-
-            return GetUser(requestArgs);
-        }
-
-        public UserAccount GetUserAccount(UUID scopeID, UUID userID)
-        {
-            // Cache check
-            UserAccount account;
-            if (m_accountCache.TryGetValue(userID, out account))
-                return account;
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUser" },
-                { "UserID", userID.ToString() }
-            };
-
-            account = GetUser(requestArgs);
-
-            if (account == null)
-            {
-                // Store null responses too, to avoid repeated lookups for missing accounts
-                m_accountCache.AddOrUpdate(userID, null, CACHE_EXPIRATION_SECONDS);
-            }
-
-            return account;
-        }
-
-        public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
-        {
-            List<UserAccount> accounts = new List<UserAccount>();
-
-//            m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Searching for user accounts with name query " + query);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "GetUsers" },
-                { "NameQuery", query }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                OSDArray array = response["Users"] as OSDArray;
-                if (array != null && array.Count > 0)
-                {
-                    for (int i = 0; i < array.Count; i++)
-                    {
-                        UserAccount account = ResponseToUserAccount(array[i] as OSDMap);
-                        if (account != null)
-                            accounts.Add(account);
-                    }
-                }
-                else
-                {
-                    m_log.Warn("[SIMIAN ACCOUNT CONNECTOR]: Account search failed, response data was in an invalid format");
-                }
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN ACCOUNT CONNECTOR]: Failed to search for account data by name " + query);
-            }
-
-            return accounts;
-        }
-
-        public void InvalidateCache(UUID userID)
-        {
-            m_accountCache.Remove(userID);
-        }
-
-        public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
-        {
-            return null;
-        }
-
-        public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs)
-        {
-            return null;
-        }
-
-        public bool StoreUserAccount(UserAccount data)
-        {
-//            m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name);
-
-            NameValueCollection requestArgs = new NameValueCollection
-            {
-                { "RequestMethod", "AddUser" },
-                { "UserID", data.PrincipalID.ToString() },
-                { "Name", data.Name },
-                { "Email", data.Email },
-                { "AccessLevel", data.UserLevel.ToString() }
-            };
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-
-            if (response["Success"].AsBoolean())
-            {
-                m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account data for " + data.Name);
-
-                requestArgs = new NameValueCollection
-                {
-                    { "RequestMethod", "AddUserData" },
-                    { "UserID", data.PrincipalID.ToString() },
-                    { "CreationDate", data.Created.ToString() },
-                    { "UserFlags", data.UserFlags.ToString() },
-                    { "UserTitle", data.UserTitle }
-                };
-
-                response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-                bool success = response["Success"].AsBoolean();
-
-                if (success)
-                {
-                    // Cache the user account info
-                    m_accountCache.AddOrUpdate(data.PrincipalID, data, CACHE_EXPIRATION_SECONDS);
-                }
-                else
-                {
-                    m_log.Warn("[SIMIAN ACCOUNT CONNECTOR]: Failed to store user account data for " + data.Name + ": " + response["Message"].AsString());
-                }
-
-                return success;
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN ACCOUNT CONNECTOR]: Failed to store user account for " + data.Name + ": " + response["Message"].AsString());
-            }
-
-            return false;
-        }
-
-        /// <summary>
-        /// Helper method for the various ways of retrieving a user account
-        /// </summary>
-        /// <param name="requestArgs">Service query parameters</param>
-        /// <returns>A UserAccount object on success, null on failure</returns>
-        private UserAccount GetUser(NameValueCollection requestArgs)
-        {
-            string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)";
-//            m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue);
-
-            OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
-            if (response["Success"].AsBoolean())
-            {
-                OSDMap user = response["User"] as OSDMap;
-                if (user != null)
-                    return ResponseToUserAccount(user);
-                else
-                    m_log.Warn("[SIMIAN ACCOUNT CONNECTOR]: Account search failed, response data was in an invalid format");
-            }
-            else
-            {
-                m_log.Warn("[SIMIAN ACCOUNT CONNECTOR]: Failed to lookup user account with query: " + lookupValue);
-            }
-
-            return null;
-        }
-
-        /// <summary>
-        /// Convert a User object in LLSD format to a UserAccount
-        /// </summary>
-        /// <param name="response">LLSD containing user account data</param>
-        /// <returns>A UserAccount object on success, null on failure</returns>
-        private UserAccount ResponseToUserAccount(OSDMap response)
-        {
-            if (response == null)
-                return null;
-
-            UserAccount account = new UserAccount();
-            account.PrincipalID = response["UserID"].AsUUID();
-            account.Created = response["CreationDate"].AsInteger();
-            account.Email = response["Email"].AsString();
-            account.ServiceURLs = new Dictionary<string, object>(0);
-            account.UserFlags = response["UserFlags"].AsInteger();
-            account.UserLevel = response["AccessLevel"].AsInteger();
-            account.UserTitle = response["UserTitle"].AsString();
-            account.LocalToGrid = true;
-            if (response.ContainsKey("LocalToGrid"))
-                account.LocalToGrid = (response["LocalToGrid"].AsString() == "true" ? true : false);
-
-            GetFirstLastName(response["Name"].AsString(), out account.FirstName, out account.LastName);
-
-            // Cache the user account info
-            m_accountCache.AddOrUpdate(account.PrincipalID, account, CACHE_EXPIRATION_SECONDS);
-
-            return account;
-        }
-
-        /// <summary>
-        /// Convert a name with a single space in it to a first and last name
-        /// </summary>
-        /// <param name="name">A full name such as "John Doe"</param>
-        /// <param name="firstName">First name</param>
-        /// <param name="lastName">Last name (surname)</param>
-        private static void GetFirstLastName(string name, out string firstName, out string lastName)
-        {
-            if (String.IsNullOrEmpty(name))
-            {
-                firstName = String.Empty;
-                lastName = String.Empty;
-            }
-            else
-            {
-                string[] names = name.Split(' ');
-
-                if (names.Length == 2)
-                {
-                    firstName = names[0];
-                    lastName = names[1];
-                }
-                else
-                {
-                    firstName = String.Empty;
-                    lastName = name;
-                }
-            }
-        }
-    }
-}

+ 0 - 2
bin/OpenSim.ini.example

@@ -1249,5 +1249,3 @@
     ; Include-Architecture = "config-include/StandaloneHypergrid.ini"
     ; Include-Architecture = "config-include/Grid.ini"
     ; Include-Architecture = "config-include/GridHypergrid.ini"
-    ; Include-Architecture = "config-include/SimianGrid.ini"
-    ; Include-Architecture = "config-include/HyperSimianGrid.ini"

+ 0 - 97
bin/config-include/HyperSimianGrid.ini

@@ -1,97 +0,0 @@
-;;
-;; Please don't change this file.
-;; All optional settings are in GridCommon.ini.example,
-;; which you can copy and change.
-;;
-
-;;
-;; In GridCommon.ini, these are the URLs you would use if SimianGrid is
-;; installed at http://www.mygrid.com/Grid/
-;;
-; AssetServerURI = "http://www.mygrid.com/Grid/?id="
-; InventoryServerURI = "http://www.mygrid.com/Grid/"
-; AvatarServerURI = "http://www.mygrid.com/Grid/"
-; PresenceServerURI = "http://www.mygrid.com/Grid/"
-; UserAccountServerURI = "http://www.mygrid.com/Grid/"
-; AuthenticationServerURI = "http://www.mygrid.com/Grid/"
-; FriendsServerURI = "http://www.mygrid.com/Grid/"
-; GroupsServerURI = "http://www.mygrid.com/Grid/"
-
-[Includes]
-    Include-Common = "config-include/GridCommon.ini"
-
-[Modules]
-    GridServices = "RemoteGridServicesConnector"
-    PresenceServices = "SimianPresenceServiceConnector"
-    UserAccountServices = "SimianUserAccountServiceConnector"
-    AuthenticationServices = "SimianAuthenticationServiceConnector"
-    AssetServices = "HGAssetBroker"
-    InventoryServices = "HGInventoryBroker"
-    AvatarServices = "SimianAvatarServiceConnector"
-
-    NeighbourServices = "NeighbourServicesOutConnector"
-    SimulationServices = "RemoteSimulationConnectorModule"
-    EntityTransferModule = "HGEntityTransferModule"
-    InventoryAccessModule = "HGInventoryAccessModule"
-
-    LandServiceInConnector = true
-    NeighbourServiceInConnector = true
-    SimulationServiceInConnector = true
-    LibraryModule = false
-
-    AssetCaching = "FlotsamAssetCache"
-
-[SimulationDataStore]
-    LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService"
-
-[EstateDataStore]
-    LocalServiceModule = "OpenSim.Services.Connectors.dll:EstateDataService"
-
-[Friends]
-    Connector = "OpenSim.Services.Connectors.dll:SimianFriendsServiceConnector"
-
-[GridService]
-    LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
-    StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"
-    NetworkConnector = "OpenSim.Services.Connectors.dll:SimianGridServiceConnector"
-
-    HypergridLinker = true
-    AllowHypergridMapSearch = true
-
-[LibraryService]
-    LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService"
-    LibraryName = "OpenSim Library"
-    DefaultLibrary = "./inventory/Libraries.xml"
-
-[AssetService]
-    DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll"
-    LocalGridAssetService = "OpenSim.Services.Connectors.dll:SimianAssetServiceConnector"
-    HypergridAssetService = "OpenSim.Services.Connectors.dll:HGAssetServiceConnector"
-    AssetLoaderArgs = "assets/AssetSets.xml"
-
-[InventoryService]
-    LocalGridInventoryService = "OpenSim.Services.Connectors.dll:SimianInventoryServiceConnector"
-
-[Groups]
-    Enabled = true
-    Module  = GroupsModule
-    DebugEnabled     = false
-    NoticesEnabled   = true
-    MessagingModule = GroupsMessagingModule
-    MessagingEnabled = true
-    ServicesConnectorModule = SimianGroupsServicesConnector
-
-[Profiles]
-    Module = "SimianProfiles"
-
-[HGInventoryAccessModule]
-    ;
-    ; === HG ONLY ===
-    ; Change this to your profile server
-    ; accessible from other grids
-    ;
-    ProfileServerURI = "http://mygridserver.com:8002/user"
-
-    ;; If you want to protect your assets from being copied by foreign visitors
-    ;; uncomment the next line. You may want to do this on sims that have licensed content.
-    ; OutboundPermission = False

+ 0 - 77
bin/config-include/SimianGrid.ini

@@ -1,77 +0,0 @@
-;;
-;; Please don't change this file.
-;; All optional settings are in GridCommon.ini.example,
-;; which you can copy and change.
-;;
-
-;;
-;; In GridCommon.ini, these are the URLs you would use if SimianGrid is
-;; installed at http://www.mygrid.com/Grid/
-;;
-; AssetServerURI = "http://www.mygrid.com/Grid/?id="
-; InventoryServerURI = "http://www.mygrid.com/Grid/"
-; AvatarServerURI = "http://www.mygrid.com/Grid/"
-; PresenceServerURI = "http://www.mygrid.com/Grid/"
-; UserAccountServerURI = "http://www.mygrid.com/Grid/"
-; AuthenticationServerURI = "http://www.mygrid.com/Grid/"
-; FriendsServerURI = "http://www.mygrid.com/Grid/"
-; GroupsServerURI = "http://www.mygrid.com/Grid/"
-
-[Includes]
-    Include-Common = "config-include/GridCommon.ini"
-
-[Modules]
-    GridServices = "RemoteGridServicesConnector"
-    PresenceServices = "SimianPresenceServiceConnector"
-    UserAccountServices = "SimianUserAccountServiceConnector"
-    AuthenticationServices = "SimianAuthenticationServiceConnector"
-    AssetServices = "SimianAssetServiceConnector"
-    InventoryServices = "SimianInventoryServiceConnector"
-    AvatarServices = "SimianAvatarServiceConnector"
-
-    NeighbourServices = "NeighbourServicesOutConnector"
-    SimulationServices = "RemoteSimulationConnectorModule"
-    EntityTransferModule = "BasicEntityTransferModule"
-    InventoryAccessModule = "BasicInventoryAccessModule"
-
-    LandServiceInConnector = true
-    NeighbourServiceInConnector = true
-    SimulationServiceInConnector = true
-    LibraryModule = false
-
-    AssetCaching = "FlotsamAssetCache"
-
-[SimulationDataStore]
-    LocalServiceModule = "OpenSim.Services.SimulationService.dll:SimulationDataService"
-
-[EstateDataStore]
-    LocalServiceModule = "OpenSim.Services.EstateService.dll:EstateDataService"
-
-[Friends]
-    Connector = "OpenSim.Services.Connectors.dll:SimianFriendsServiceConnector"
-
-[GridService]
-    LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
-    StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"
-    NetworkConnector = "OpenSim.Services.Connectors.dll:SimianGridServiceConnector"
-
-[LibraryService]
-    LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService"
-    LibraryName = "OpenSim Library"
-    DefaultLibrary = "./inventory/Libraries.xml"
-
-[AssetService]
-    DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll"
-    AssetLoaderArgs = "assets/AssetSets.xml"
-
-[Groups]
-    Enabled = true
-    Module  = GroupsModule
-    DebugEnabled     = false
-    NoticesEnabled   = true
-    MessagingModule = GroupsMessagingModule
-    MessagingEnabled = true
-    ServicesConnectorModule = SimianGroupsServicesConnector
-
-[Profiles]
-    Module = "SimianProfiles"