From 5cf6d6fa79dada85bd56530551409809d338b7d2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 20:17:37 -0800 Subject: All grid servers deleted, including user server. They served us well. --- .../UserServer.Modules/AvatarCreationModule.cs | 550 ---------------- .../UserServer.Modules/MessageServersConnector.cs | 514 --------------- .../Grid/UserServer.Modules/UserDataBaseService.cs | 100 --- .../Grid/UserServer.Modules/UserLoginService.cs | 416 ------------ OpenSim/Grid/UserServer.Modules/UserManager.cs | 718 --------------------- .../UserServerAvatarAppearanceModule.cs | 132 ---- .../UserServer.Modules/UserServerFriendsModule.cs | 176 ----- 7 files changed, 2606 deletions(-) delete mode 100644 OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs delete mode 100644 OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs delete mode 100644 OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs delete mode 100644 OpenSim/Grid/UserServer.Modules/UserLoginService.cs delete mode 100644 OpenSim/Grid/UserServer.Modules/UserManager.cs delete mode 100644 OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs delete mode 100644 OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs (limited to 'OpenSim/Grid/UserServer.Modules') diff --git a/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs b/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs deleted file mode 100644 index 923b06c..0000000 --- a/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs +++ /dev/null @@ -1,550 +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.Threading; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Console; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Grid.Framework; - - -namespace OpenSim.Grid.UserServer.Modules -{ - public class AvatarCreationModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private UserDataBaseService m_userDataBaseService; - // private BaseHttpServer m_httpServer; - // TODO: unused: private UserConfig m_config; - - private string m_inventoryServerUrl; - private IInterServiceInventoryServices m_inventoryService; - - public AvatarCreationModule(UserDataBaseService userDataBaseService, UserConfig config, IInterServiceInventoryServices inventoryService) - { - // TODO: unused: m_config = config; - m_userDataBaseService = userDataBaseService; - m_inventoryService = inventoryService; - m_inventoryServerUrl = config.InventoryUrl.OriginalString; - } - - public void Initialise(IGridServiceCore core) - { - CommandConsole console; - if (core.TryGet(out console)) - { - console.Commands.AddCommand("userserver", false, "clone avatar", - "clone avatar ", - "Clone the template avatar's inventory into a target avatar", RunCommand); - } - } - - public void PostInitialise() - { - - } - - public void RegisterHandlers(BaseHttpServer httpServer) - { - } - - public void RunCommand(string module, string[] cmd) - { - if ((cmd.Length == 6) && (cmd[0] == "clone") && (cmd[1] == "avatar")) - { - try - { - string tFirst = cmd[2]; - string tLast = cmd[3]; - - string nFirst = cmd[4]; - string nLast = cmd[5]; - - UserProfileData templateAvatar = m_userDataBaseService.GetUserProfile(tFirst, tLast); - UserProfileData newAvatar = m_userDataBaseService.GetUserProfile(nFirst, nLast); - - if (templateAvatar == null) - { - m_log.ErrorFormat("[AvatarAppearance] Clone Avatar: Could not find template avatar {0} , {1}", tFirst, tLast); - return; - } - - if (newAvatar == null) - { - m_log.ErrorFormat("[AvatarAppearance] Clone Avatar: Could not find target avatar {0} , {1}", nFirst, nLast); - return; - } - Guid avatar = newAvatar.ID.Guid; - Guid template = templateAvatar.ID.Guid; - CloneAvatar(avatar, template, true, true); - - } - catch (Exception e) - { - m_log.Error("Error: " + e.ToString()); - } - } - } - #region Avatar Appearance Creation - - public bool CloneAvatar(Guid avatarID, Guid templateID, bool modifyPermissions, bool removeTargetsClothes) - { - m_log.InfoFormat("[AvatarAppearance] Starting to clone avatar {0} inventory to avatar {1}", templateID.ToString(), avatarID.ToString()); - // TODO: unused: Guid bodyFolder = Guid.Empty; - // TODO: unused: Guid clothesFolder = Guid.Empty; - bool success = false; - - UUID avID = new UUID(avatarID); - List avatarInventory = m_inventoryService.GetInventorySkeleton(avID); - if ((avatarInventory == null) || (avatarInventory.Count == 0)) - { - m_log.InfoFormat("[AvatarAppearance] No inventory found for user {0} , so creating it", avID.ToString()); - m_inventoryService.CreateNewUserInventory(avID); - Thread.Sleep(5000); - avatarInventory = m_inventoryService.GetInventorySkeleton(avID); - } - - if ((avatarInventory != null) && (avatarInventory.Count > 0)) - { - UUID tempOwnID = new UUID(templateID); - AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(tempOwnID); - - if (removeTargetsClothes) - { - //remove clothes and attachments from target avatar so that the end result isn't a merger of its existing clothes - // and the clothes from the template avatar. - RemoveClothesAndAttachments(avID); - } - - List templateInventory = m_inventoryService.GetInventorySkeleton(tempOwnID); - if ((templateInventory != null) && (templateInventory.Count != 0)) - { - for (int i = 0; i < templateInventory.Count; i++) - { - if (templateInventory[i].ParentID == UUID.Zero) - { - success = CloneFolder(avatarInventory, avID, UUID.Zero, appearance, templateInventory[i], templateInventory, modifyPermissions); - break; - } - } - } - else - { - m_log.InfoFormat("[AvatarAppearance] Failed to find the template owner's {0} inventory", tempOwnID); - } - } - m_log.InfoFormat("[AvatarAppearance] finished cloning avatar with result: {0}", success); - return success; - } - - private bool CloneFolder(List avatarInventory, UUID avID, UUID parentFolder, AvatarAppearance appearance, InventoryFolderBase templateFolder, List templateFolders, bool modifyPermissions) - { - bool success = false; - UUID templateFolderId = templateFolder.ID; - if (templateFolderId != UUID.Zero) - { - InventoryFolderBase toFolder = FindFolder(templateFolder.Name, parentFolder.Guid, avatarInventory); - if (toFolder == null) - { - //create new folder - toFolder = new InventoryFolderBase(); - toFolder.ID = UUID.Random(); - toFolder.Name = templateFolder.Name; - toFolder.Owner = avID; - toFolder.Type = templateFolder.Type; - toFolder.Version = 1; - toFolder.ParentID = parentFolder; - if (!SynchronousRestObjectRequester.MakeRequest( - "POST", m_inventoryServerUrl + "CreateFolder/", toFolder)) - { - m_log.InfoFormat("[AvatarApperance] Couldn't make new folder {0} in users inventory", toFolder.Name); - return false; - } - else - { - // m_log.InfoFormat("made new folder {0} in users inventory", toFolder.Name); - } - } - - List templateItems = SynchronousRestObjectRequester.MakeRequest>( - "POST", m_inventoryServerUrl + "GetItems/", templateFolderId.Guid); - if ((templateItems != null) && (templateItems.Count > 0)) - { - List wornClothes = new List(); - List attachedItems = new List(); - - foreach (InventoryItemBase item in templateItems) - { - - UUID clonedItemId = CloneInventoryItem(avID, toFolder.ID, item, modifyPermissions); - if (clonedItemId != UUID.Zero) - { - int appearanceType = ItemIsPartOfAppearance(item, appearance); - if (appearanceType >= 0) - { - // UpdateAvatarAppearance(avID, appearanceType, clonedItemId, item.AssetID); - wornClothes.Add(new ClothesAttachment(appearanceType, clonedItemId, item.AssetID)); - } - - if (appearance != null) - { - int attachment = appearance.GetAttachpoint(item.ID); - if (attachment > 0) - { - //UpdateAvatarAttachment(avID, attachment, clonedItemId, item.AssetID); - attachedItems.Add(new ClothesAttachment(attachment, clonedItemId, item.AssetID)); - } - } - success = true; - } - } - - if ((wornClothes.Count > 0) || (attachedItems.Count > 0)) - { - //Update the worn clothes and attachments - AvatarAppearance targetAppearance = GetAppearance(avID); - if (targetAppearance != null) - { - foreach (ClothesAttachment wornItem in wornClothes) - { - targetAppearance.Wearables[wornItem.Type].AssetID = wornItem.AssetID; - targetAppearance.Wearables[wornItem.Type].ItemID = wornItem.ItemID; - } - - foreach (ClothesAttachment wornItem in attachedItems) - { - targetAppearance.SetAttachment(wornItem.Type, wornItem.ItemID, wornItem.AssetID); - } - - m_userDataBaseService.UpdateUserAppearance(avID, targetAppearance); - wornClothes.Clear(); - attachedItems.Clear(); - } - } - } - else if ((templateItems != null) && (templateItems.Count == 0)) - { - // m_log.Info("[AvatarAppearance]Folder being cloned was empty"); - success = true; - } - - List subFolders = FindSubFolders(templateFolder.ID.Guid, templateFolders); - foreach (InventoryFolderBase subFolder in subFolders) - { - if (subFolder.Name.ToLower() != "trash") - { - success = CloneFolder(avatarInventory, avID, toFolder.ID, appearance, subFolder, templateFolders, modifyPermissions); - } - } - } - else - { - m_log.Info("[AvatarAppearance] Failed to find the template folder"); - } - return success; - } - - private UUID CloneInventoryItem(UUID avatarID, UUID avatarFolder, InventoryItemBase item, bool modifyPerms) - { - if (avatarFolder != UUID.Zero) - { - InventoryItemBase clonedItem = new InventoryItemBase(); - clonedItem.Owner = avatarID; - clonedItem.AssetID = item.AssetID; - clonedItem.AssetType = item.AssetType; - clonedItem.BasePermissions = item.BasePermissions; - clonedItem.CreationDate = item.CreationDate; - clonedItem.CreatorId = item.CreatorId; - clonedItem.CreatorIdAsUuid = item.CreatorIdAsUuid; - clonedItem.CurrentPermissions = item.CurrentPermissions; - clonedItem.Description = item.Description; - clonedItem.EveryOnePermissions = item.EveryOnePermissions; - clonedItem.Flags = item.Flags; - clonedItem.Folder = avatarFolder; - clonedItem.GroupID = item.GroupID; - clonedItem.GroupOwned = item.GroupOwned; - clonedItem.GroupPermissions = item.GroupPermissions; - clonedItem.ID = UUID.Random(); - clonedItem.InvType = item.InvType; - clonedItem.Name = item.Name; - clonedItem.NextPermissions = item.NextPermissions; - clonedItem.SalePrice = item.SalePrice; - clonedItem.SaleType = item.SaleType; - - if (modifyPerms) - { - ModifyPermissions(ref clonedItem); - } - - SynchronousRestObjectRequester.MakeRequest( - "POST", m_inventoryServerUrl + "AddNewItem/", clonedItem); - - return clonedItem.ID; - } - - return UUID.Zero; - } - - // TODO: unused - // private void UpdateAvatarAppearance(UUID avatarID, int wearableType, UUID itemID, UUID assetID) - // { - // AvatarAppearance appearance = GetAppearance(avatarID); - // appearance.Wearables[wearableType].AssetID = assetID; - // appearance.Wearables[wearableType].ItemID = itemID; - // m_userDataBaseService.UpdateUserAppearance(avatarID, appearance); - // } - - // TODO: unused - // private void UpdateAvatarAttachment(UUID avatarID, int attachmentPoint, UUID itemID, UUID assetID) - // { - // AvatarAppearance appearance = GetAppearance(avatarID); - // appearance.SetAttachment(attachmentPoint, itemID, assetID); - // m_userDataBaseService.UpdateUserAppearance(avatarID, appearance); - // } - - private void RemoveClothesAndAttachments(UUID avatarID) - { - AvatarAppearance appearance = GetAppearance(avatarID); - - appearance.ClearWearables(); - appearance.ClearAttachments(); - m_userDataBaseService.UpdateUserAppearance(avatarID, appearance); - - } - - private AvatarAppearance GetAppearance(UUID avatarID) - { - AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(avatarID); - if (appearance == null) - { - appearance = CreateDefaultAppearance(avatarID); - } - return appearance; - } - - // TODO: unused - // private UUID FindFolderID(string name, List folders) - // { - // foreach (InventoryFolderBase folder in folders) - // { - // if (folder.Name == name) - // { - // return folder.ID; - // } - // } - // return UUID.Zero; - // } - - // TODO: unused - // private InventoryFolderBase FindFolder(string name, List folders) - // { - // foreach (InventoryFolderBase folder in folders) - // { - // if (folder.Name == name) - // { - // return folder; - // } - // } - // return null; - // } - - private InventoryFolderBase FindFolder(string name, Guid parentFolderID, List folders) - { - foreach (InventoryFolderBase folder in folders) - { - if ((folder.Name == name) && (folder.ParentID.Guid == parentFolderID)) - { - return folder; - } - } - return null; - } - - // TODO: unused - // private InventoryItemBase GetItem(string itemName, List items) - // { - // foreach (InventoryItemBase item in items) - // { - // if (item.Name.ToLower() == itemName.ToLower()) - // { - // return item; - // } - // } - // return null; - // } - - private List FindSubFolders(Guid parentFolderID, List folders) - { - List subFolders = new List(); - foreach (InventoryFolderBase folder in folders) - { - if (folder.ParentID.Guid == parentFolderID) - { - subFolders.Add(folder); - } - } - return subFolders; - } - - protected virtual void ModifyPermissions(ref InventoryItemBase item) - { - // Propagate Permissions - item.BasePermissions = item.BasePermissions & item.NextPermissions; - item.CurrentPermissions = item.BasePermissions; - item.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions; - item.GroupPermissions = item.GroupPermissions & item.NextPermissions; - - } - - private AvatarAppearance CreateDefaultAppearance(UUID avatarId) - { - AvatarAppearance appearance = null; - AvatarWearable[] wearables; - byte[] visualParams; - GetDefaultAvatarAppearance(out wearables, out visualParams); - appearance = new AvatarAppearance(avatarId, wearables, visualParams); - - return appearance; - } - - private static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) - { - visualParams = GetDefaultVisualParams(); - wearables = AvatarWearable.DefaultWearables; - } - - private static byte[] GetDefaultVisualParams() - { - byte[] visualParams; - visualParams = new byte[218]; - for (int i = 0; i < 218; i++) - { - visualParams[i] = 100; - } - return visualParams; - } - - private int ItemIsPartOfAppearance(InventoryItemBase item, AvatarAppearance appearance) - { - if (appearance != null) - { - if (appearance.BodyItem == item.ID) - return (int)WearableType.Shape; - - if (appearance.EyesItem == item.ID) - return (int)WearableType.Eyes; - - if (appearance.GlovesItem == item.ID) - return (int)WearableType.Gloves; - - if (appearance.HairItem == item.ID) - return (int)WearableType.Hair; - - if (appearance.JacketItem == item.ID) - return (int)WearableType.Jacket; - - if (appearance.PantsItem == item.ID) - return (int)WearableType.Pants; - - if (appearance.ShirtItem == item.ID) - return (int)WearableType.Shirt; - - if (appearance.ShoesItem == item.ID) - return (int)WearableType.Shoes; - - if (appearance.SkinItem == item.ID) - return (int)WearableType.Skin; - - if (appearance.SkirtItem == item.ID) - return (int)WearableType.Skirt; - - if (appearance.SocksItem == item.ID) - return (int)WearableType.Socks; - - if (appearance.UnderPantsItem == item.ID) - return (int)WearableType.Underpants; - - if (appearance.UnderShirtItem == item.ID) - return (int)WearableType.Undershirt; - } - return -1; - } - #endregion - - public enum PermissionMask - { - None = 0, - Transfer = 8192, - Modify = 16384, - Copy = 32768, - Move = 524288, - Damage = 1048576, - All = 2147483647, - } - - public enum WearableType - { - Shape = 0, - Skin = 1, - Hair = 2, - Eyes = 3, - Shirt = 4, - Pants = 5, - Shoes = 6, - Socks = 7, - Jacket = 8, - Gloves = 9, - Undershirt = 10, - Underpants = 11, - Skirt = 12, - } - - public class ClothesAttachment - { - public int Type; - public UUID ItemID; - public UUID AssetID; - - public ClothesAttachment(int type, UUID itemID, UUID assetID) - { - Type = type; - ItemID = itemID; - AssetID = assetID; - } - } - } -} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs deleted file mode 100644 index 3384952..0000000 --- a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs +++ /dev/null @@ -1,514 +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.Collections; -using System.Collections.Generic; -using System.Net; -using System.Reflection; -using System.Threading; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Grid.Framework; - -namespace OpenSim.Grid.UserServer.Modules -{ - public enum NotificationRequest : int - { - Login = 0, - Logout = 1, - Shutdown = 2 - } - - public struct PresenceNotification - { - public NotificationRequest request; - public UUID agentID; - public UUID sessionID; - public UUID RegionID; - public ulong regionhandle; - public float positionX; - public float positionY; - public float positionZ; - public string firstname; - public string lastname; - } - - public delegate void AgentLocationDelegate(UUID agentID, UUID regionID, ulong regionHandle); - public delegate void AgentLeavingDelegate(UUID agentID, UUID regionID, ulong regionHandle); - public delegate void RegionStartupDelegate(UUID regionID); - public delegate void RegionShutdownDelegate(UUID regionID); - - - public class MessageServersConnector - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public Dictionary MessageServers; - - private BaseHttpServer m_httpServer; - - private OpenSim.Framework.BlockingQueue m_NotifyQueue = - new OpenSim.Framework.BlockingQueue(); - - private IGridServiceCore m_core; - - public event AgentLocationDelegate OnAgentLocation; - public event AgentLeavingDelegate OnAgentLeaving; - public event RegionStartupDelegate OnRegionStartup; - public event RegionShutdownDelegate OnRegionShutdown; - - public MessageServersConnector() - { - MessageServers = new Dictionary(); - } - - public void Initialise(IGridServiceCore core) - { - m_core = core; - m_core.RegisterInterface(this); - - Watchdog.StartThread(NotifyQueueRunner, "NotifyQueueRunner", ThreadPriority.Normal, true); - } - - public void PostInitialise() - { - } - - public void RegisterHandlers(BaseHttpServer httpServer) - { - m_httpServer = httpServer; - - m_httpServer.AddXmlRPCHandler("region_startup", RegionStartup); - m_httpServer.AddXmlRPCHandler("region_shutdown", RegionShutdown); - m_httpServer.AddXmlRPCHandler("agent_location", AgentLocation); - m_httpServer.AddXmlRPCHandler("agent_leaving", AgentLeaving); - // Message Server ---> User Server - m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer); - m_httpServer.AddXmlRPCHandler("agent_change_region", XmlRPCUserMovedtoRegion); - m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); - } - - public void RegisterMessageServer(string URI, MessageServerInfo serverData) - { - lock (MessageServers) - { - if (!MessageServers.ContainsKey(URI)) - MessageServers.Add(URI, serverData); - } - } - - public void DeRegisterMessageServer(string URI) - { - lock (MessageServers) - { - if (MessageServers.ContainsKey(URI)) - MessageServers.Remove(URI); - } - } - - public void AddResponsibleRegion(string URI, ulong regionhandle) - { - if (!MessageServers.ContainsKey(URI)) - { - m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered"); - } - else - { - MessageServerInfo msginfo = MessageServers["URI"]; - msginfo.responsibleForRegions.Add(regionhandle); - MessageServers["URI"] = msginfo; - } - } - public void RemoveResponsibleRegion(string URI, ulong regionhandle) - { - if (!MessageServers.ContainsKey(URI)) - { - m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered"); - } - else - { - MessageServerInfo msginfo = MessageServers["URI"]; - if (msginfo.responsibleForRegions.Contains(regionhandle)) - { - msginfo.responsibleForRegions.Remove(regionhandle); - MessageServers["URI"] = msginfo; - } - } - - } - public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData = new Hashtable(); - - if (requestData.Contains("uri")) - { - string URI = (string)requestData["uri"]; - string sendkey=(string)requestData["sendkey"]; - string recvkey=(string)requestData["recvkey"]; - MessageServerInfo m = new MessageServerInfo(); - m.URI = URI; - m.sendkey = sendkey; - m.recvkey = recvkey; - RegisterMessageServer(URI, m); - responseData["responsestring"] = "TRUE"; - response.Value = responseData; - } - return response; - } - public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData = new Hashtable(); - - if (requestData.Contains("uri")) - { - string URI = (string)requestData["uri"]; - - DeRegisterMessageServer(URI); - responseData["responsestring"] = "TRUE"; - response.Value = responseData; - } - return response; - } - - public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData = new Hashtable(); - - if (requestData.Contains("fromuri")) - { - // string sURI = (string)requestData["fromuri"]; - // string sagentID = (string)requestData["agentid"]; - // string ssessionID = (string)requestData["sessionid"]; - // string scurrentRegionID = (string)requestData["regionid"]; - // string sregionhandle = (string)requestData["regionhandle"]; - // string scurrentpos = (string)requestData["currentpos"]; - //Vector3.TryParse((string)reader["currentPos"], out retval.currentPos); - // TODO: Okay now raise event so the user server can pass this data to the Usermanager - - responseData["responsestring"] = "TRUE"; - response.Value = responseData; - } - return response; - } - - public void TellMessageServersAboutUser(UUID agentID, UUID sessionID, UUID RegionID, - ulong regionhandle, float positionX, float positionY, - float positionZ, string firstname, string lastname) - { - PresenceNotification notification = new PresenceNotification(); - - notification.request = NotificationRequest.Login; - notification.agentID = agentID; - notification.sessionID = sessionID; - notification.RegionID = RegionID; - notification.regionhandle = regionhandle; - notification.positionX = positionX; - notification.positionY = positionY; - notification.positionZ = positionZ; - notification.firstname = firstname; - notification.lastname = lastname; - - m_NotifyQueue.Enqueue(notification); - } - - private void TellMessageServersAboutUserInternal(UUID agentID, UUID sessionID, UUID RegionID, - ulong regionhandle, float positionX, float positionY, - float positionZ, string firstname, string lastname) - { - // Loop over registered Message Servers (AND THERE WILL BE MORE THEN ONE :D) - lock (MessageServers) - { - if (MessageServers.Count > 0) - { - m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers"); - } -// else -// { -// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); -// } - foreach (MessageServerInfo serv in MessageServers.Values) - { - NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, - regionhandle, positionX, positionY, positionZ, - firstname, lastname); - } - } - } - - private void TellMessageServersAboutUserLogoffInternal(UUID agentID) - { - lock (MessageServers) - { - if (MessageServers.Count > 0) - { - m_log.Info("[MSGCONNECTOR]: Sending logoff notice to registered message servers"); - } - else - { -// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); - } - foreach (MessageServerInfo serv in MessageServers.Values) - { - NotifyMessageServerAboutUserLogoff(serv,agentID); - } - } - } - - private void TellMessageServersAboutRegionShutdownInternal(UUID regionID) - { - lock (MessageServers) - { - if (MessageServers.Count > 0) - { - m_log.Info("[MSGCONNECTOR]: Sending region down notice to registered message servers"); - } - else - { -// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); - } - foreach (MessageServerInfo serv in MessageServers.Values) - { - NotifyMessageServerAboutRegionShutdown(serv,regionID); - } - } - } - - public void TellMessageServersAboutUserLogoff(UUID agentID) - { - PresenceNotification notification = new PresenceNotification(); - - notification.request = NotificationRequest.Logout; - notification.agentID = agentID; - - m_NotifyQueue.Enqueue(notification); - } - - public void TellMessageServersAboutRegionShutdown(UUID regionID) - { - PresenceNotification notification = new PresenceNotification(); - - notification.request = NotificationRequest.Shutdown; - notification.RegionID = regionID; - - m_NotifyQueue.Enqueue(notification); - } - - private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID) - { - Hashtable reqparams = new Hashtable(); - reqparams["sendkey"] = serv.sendkey; - reqparams["agentid"] = agentID.ToString(); - ArrayList SendParams = new ArrayList(); - SendParams.Add(reqparams); - - XmlRpcRequest GridReq = new XmlRpcRequest("logout_of_simulator", SendParams); - try - { - GridReq.Send(serv.URI, 6000); - } - catch (WebException) - { - m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about log out. Other users might still think this user is online"); - } - m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout"); - } - - private void NotifyMessageServerAboutRegionShutdown(MessageServerInfo serv, UUID regionID) - { - Hashtable reqparams = new Hashtable(); - reqparams["sendkey"] = serv.sendkey; - reqparams["regionid"] = regionID.ToString(); - ArrayList SendParams = new ArrayList(); - SendParams.Add(reqparams); - - XmlRpcRequest GridReq = new XmlRpcRequest("process_region_shutdown", SendParams); - try - { - GridReq.Send(serv.URI, 6000); - } - catch (WebException) - { - m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about region shutdown."); - } - m_log.Info("[REGION UPDOWN]: Notified : " + serv.URI + " about region state change"); - } - - private void NotifyMessageServerAboutUser(MessageServerInfo serv, - UUID agentID, UUID sessionID, UUID RegionID, - ulong regionhandle, float positionX, float positionY, float positionZ, - string firstname, string lastname) - { - Hashtable reqparams = new Hashtable(); - reqparams["sendkey"] = serv.sendkey; - reqparams["agentid"] = agentID.ToString(); - reqparams["sessionid"] = sessionID.ToString(); - reqparams["regionid"] = RegionID.ToString(); - reqparams["regionhandle"] = regionhandle.ToString(); - reqparams["positionx"] = positionX.ToString(); - reqparams["positiony"] = positionY.ToString(); - reqparams["positionz"] = positionZ.ToString(); - reqparams["firstname"] = firstname; - reqparams["lastname"] = lastname; - - //reqparams["position"] = Position.ToString(); - - ArrayList SendParams = new ArrayList(); - SendParams.Add(reqparams); - - XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams); - try - { - GridReq.Send(serv.URI, 6000); - m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login"); - } - catch (WebException) - { - m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user"); - } - - } - - private void NotifyQueueRunner() - { - while (true) - { - PresenceNotification presence = m_NotifyQueue.Dequeue(); - - if (presence.request == NotificationRequest.Shutdown) - { - TellMessageServersAboutRegionShutdownInternal(presence.RegionID); - } - - if (presence.request == NotificationRequest.Login) - { - TellMessageServersAboutUserInternal(presence.agentID, - presence.sessionID, presence.RegionID, - presence.regionhandle, presence.positionX, - presence.positionY, presence.positionZ, - presence.firstname, presence.lastname); - } - - if (presence.request == NotificationRequest.Logout) - { - TellMessageServersAboutUserLogoffInternal(presence.agentID); - } - - Watchdog.UpdateThread(); - } - } - - public XmlRpcResponse RegionStartup(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable result = new Hashtable(); - - UUID regionID; - if (UUID.TryParse((string)requestData["RegionUUID"], out regionID)) - { - if (OnRegionStartup != null) - OnRegionStartup(regionID); - - result["responsestring"] = "TRUE"; - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = result; - return response; - } - - public XmlRpcResponse RegionShutdown(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable result = new Hashtable(); - - UUID regionID; - if (UUID.TryParse((string)requestData["RegionUUID"], out regionID)) - { - if (OnRegionShutdown != null) - OnRegionShutdown(regionID); - - result["responsestring"] = "TRUE"; - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = result; - return response; - } - - public XmlRpcResponse AgentLocation(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable result = new Hashtable(); - - UUID agentID; - UUID regionID; - ulong regionHandle; - if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle)) - { - if (OnAgentLocation != null) - OnAgentLocation(agentID, regionID, regionHandle); - - result["responsestring"] = "TRUE"; - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = result; - return response; - } - - public XmlRpcResponse AgentLeaving(XmlRpcRequest request, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable result = new Hashtable(); - - UUID agentID; - UUID regionID; - ulong regionHandle; - if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle)) - { - if (OnAgentLeaving != null) - OnAgentLeaving(agentID, regionID, regionHandle); - - result["responsestring"] = "TRUE"; - } - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = result; - return response; - } - } -} diff --git a/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs b/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs deleted file mode 100644 index 10d6f80..0000000 --- a/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs +++ /dev/null @@ -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.Collections; -using System.Collections.Generic; -using System.Reflection; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Grid.Framework; - -namespace OpenSim.Grid.UserServer.Modules -{ - public class UserDataBaseService : UserManagerBase - { - protected IGridServiceCore m_core; - - public UserDataBaseService(CommunicationsManager commsManager) - : base(commsManager) - { - } - - public void Initialise(IGridServiceCore core) - { - m_core = core; - - UserConfig cfg; - if (m_core.TryGet(out cfg)) - { - AddPlugin(cfg.DatabaseProvider, cfg.DatabaseConnect); - } - - m_core.RegisterInterface(this); - } - - public void PostInitialise() - { - } - - public void RegisterHandlers(BaseHttpServer httpServer) - { - } - - public UserAgentData GetUserAgentData(UUID AgentID) - { - UserProfileData userProfile = GetUserProfile(AgentID); - - if (userProfile != null) - { - return userProfile.CurrentAgent; - } - - return null; - } - - public override UserProfileData SetupMasterUser(string firstName, string lastName) - { - throw new Exception("The method or operation is not implemented."); - } - - public override UserProfileData SetupMasterUser(string firstName, string lastName, string password) - { - throw new Exception("The method or operation is not implemented."); - } - - public override UserProfileData SetupMasterUser(UUID uuid) - { - throw new Exception("The method or operation is not implemented."); - } - } -} diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs deleted file mode 100644 index 97a919f..0000000 --- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs +++ /dev/null @@ -1,416 +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.Net; -using System.Reflection; -using System.Text.RegularExpressions; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using Nini.Config; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Services; -using LoginResponse = OpenSim.Framework.Communications.Services.LoginResponse; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Capabilities; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Connectors; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -namespace OpenSim.Grid.UserServer.Modules -{ - public delegate void UserLoggedInAtLocation(UUID agentID, UUID sessionID, UUID RegionID, - ulong regionhandle, float positionX, float positionY, float positionZ, - string firstname, string lastname); - - /// - /// Login service used in grid mode. - /// - public class UserLoginService : LoginService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public event UserLoggedInAtLocation OnUserLoggedInAtLocation; - - private UserLoggedInAtLocation handlerUserLoggedInAtLocation; - - public UserConfig m_config; - private readonly IRegionProfileRouter m_regionProfileService; - - private IGridService m_GridService; - - protected BaseHttpServer m_httpServer; - - public UserLoginService( - UserManagerBase userManager, IInterServiceInventoryServices inventoryService, - LibraryRootFolder libraryRootFolder, - UserConfig config, string welcomeMess, IRegionProfileRouter regionProfileService) - : base(userManager, libraryRootFolder, welcomeMess) - { - m_config = config; - m_defaultHomeX = m_config.DefaultX; - m_defaultHomeY = m_config.DefaultY; - m_interInventoryService = inventoryService; - m_regionProfileService = regionProfileService; - - m_GridService = new GridServicesConnector(config.GridServerURL.ToString()); - } - - public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers) - { - m_httpServer = httpServer; - - m_httpServer.AddXmlRPCHandler("login_to_simulator", XmlRpcLoginMethod); - m_httpServer.AddHTTPHandler("login", ProcessHTMLLogin); - m_httpServer.AddXmlRPCHandler("set_login_params", XmlRPCSetLoginParams); - m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession, false); - - if (registerLLSDHandler) - { - m_httpServer.SetDefaultLLSDHandler(LLSDLoginMethod); - } - - } - - public void setloginlevel(int level) - { - m_minLoginLevel = level; - m_log.InfoFormat("[GRID]: Login Level set to {0} ", level); - } - public void setwelcometext(string text) - { - m_welcomeMessage = text; - m_log.InfoFormat("[GRID]: Login text set to {0} ", text); - } - - public override void LogOffUser(UserProfileData theUser, string message) - { - RegionProfileData SimInfo; - try - { - SimInfo = m_regionProfileService.RequestSimProfileData( - theUser.CurrentAgent.Handle, m_config.GridServerURL, - m_config.GridSendKey, m_config.GridRecvKey); - - if (SimInfo == null) - { - m_log.Error("[GRID]: Region user was in isn't currently logged in"); - return; - } - } - catch (Exception) - { - m_log.Error("[GRID]: Unable to look up region to log user off"); - return; - } - - // Prepare notification - Hashtable SimParams = new Hashtable(); - SimParams["agent_id"] = theUser.ID.ToString(); - SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString(); - SimParams["region_secret2"] = SimInfo.regionSecret; - //m_log.Info(SimInfo.regionSecret); - SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); - SimParams["message"] = message; - ArrayList SendParams = new ArrayList(); - SendParams.Add(SimParams); - - m_log.InfoFormat( - "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", - SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, - theUser.FirstName + " " + theUser.SurName); - - try - { - XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); - XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); - - if (GridResp.IsFault) - { - m_log.ErrorFormat( - "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", - SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); - } - } - catch (Exception) - { - m_log.Error("[LOGIN]: Error telling region to logout user!"); - } - - // Prepare notification - SimParams = new Hashtable(); - SimParams["agent_id"] = theUser.ID.ToString(); - SimParams["region_secret"] = SimInfo.regionSecret; - //m_log.Info(SimInfo.regionSecret); - SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); - SimParams["message"] = message; - SendParams = new ArrayList(); - SendParams.Add(SimParams); - - m_log.InfoFormat( - "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", - SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, - theUser.FirstName + " " + theUser.SurName); - - try - { - XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); - XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); - - if (GridResp.IsFault) - { - m_log.ErrorFormat( - "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", - SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); - } - } - catch (Exception) - { - m_log.Error("[LOGIN]: Error telling region to logout user!"); - } - //base.LogOffUser(theUser); - } - - protected override RegionInfo RequestClosestRegion(string region) - { - return GridRegionToRegionInfo(m_GridService.GetRegionByName(UUID.Zero, region)); - } - - protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) - { - uint x = 0, y = 0; - Utils.LongToUInts(homeRegionHandle, out x, out y); - return GridRegionToRegionInfo(m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y)); - } - - protected override RegionInfo GetRegionInfo(UUID homeRegionId) - { - return GridRegionToRegionInfo(m_GridService.GetRegionByUUID(UUID.Zero, homeRegionId)); - } - - private RegionInfo GridRegionToRegionInfo(GridRegion gregion) - { - if (gregion == null) - return null; - - RegionInfo rinfo = new RegionInfo(); - rinfo.ExternalHostName = gregion.ExternalHostName; - rinfo.HttpPort = gregion.HttpPort; - rinfo.InternalEndPoint = gregion.InternalEndPoint; - rinfo.RegionID = gregion.RegionID; - rinfo.RegionLocX = (uint)(gregion.RegionLocX / Constants.RegionSize); - rinfo.RegionLocY = (uint)(gregion.RegionLocY / Constants.RegionSize); - rinfo.RegionName = gregion.RegionName; - rinfo.ScopeID = gregion.ScopeID; - rinfo.ServerURI = gregion.ServerURI; - - return rinfo; - } - - protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) - { - return PrepareLoginToRegion(RegionProfileData.FromRegionInfo(regionInfo), user, response, remoteClient); - } - - /// - /// Prepare a login to the given region. This involves both telling the region to expect a connection - /// and appropriately customising the response to the user. - /// - /// - /// - /// - /// true if the region was successfully contacted, false otherwise - private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) - { - try - { - response.SimAddress = Util.GetHostFromURL(regionInfo.serverURI).ToString(); - response.SimPort = uint.Parse(regionInfo.serverURI.Split(new char[] { '/', ':' })[4]); - response.RegionX = regionInfo.regionLocX; - response.RegionY = regionInfo.regionLocY; - - string capsPath = CapsUtil.GetRandomCapsObjectPath(); - - // Adam's working code commented for now -- Diva 5/25/2009 - //// For NAT - ////string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ServerIP); - //string host = response.SimAddress; - //// TODO: This doesnt support SSL. -Adam - //string serverURI = "http://" + host + ":" + regionInfo.ServerPort; - - //response.SeedCapability = serverURI + CapsUtil.GetCapsSeedPath(capsPath); - - // Take off trailing / so that the caps path isn't //CAPS/someUUID - string uri = regionInfo.httpServerURI.Trim(new char[] { '/' }); - response.SeedCapability = uri + CapsUtil.GetCapsSeedPath(capsPath); - - - // Notify the target of an incoming user - m_log.InfoFormat( - "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", - regionInfo.regionName, response.RegionX, response.RegionY, regionInfo.httpServerURI); - - // Update agent with target sim - user.CurrentAgent.Region = regionInfo.UUID; - user.CurrentAgent.Handle = regionInfo.regionHandle; - - // Prepare notification - Hashtable loginParams = new Hashtable(); - loginParams["session_id"] = user.CurrentAgent.SessionID.ToString(); - loginParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString(); - loginParams["firstname"] = user.FirstName; - loginParams["lastname"] = user.SurName; - loginParams["agent_id"] = user.ID.ToString(); - loginParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); - loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString(); - loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString(); - loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString(); - loginParams["regionhandle"] = user.CurrentAgent.Handle.ToString(); - loginParams["caps_path"] = capsPath; - - // Get appearance - AvatarAppearance appearance = m_userManager.GetUserAppearance(user.ID); - if (appearance != null) - { - loginParams["appearance"] = appearance.ToHashTable(); - m_log.DebugFormat("[LOGIN]: Found appearance for {0} {1}", user.FirstName, user.SurName); - } - else - { - m_log.DebugFormat("[LOGIN]: Appearance not for {0} {1}. Creating default.", user.FirstName, user.SurName); - appearance = new AvatarAppearance(user.ID); - loginParams["appearance"] = appearance.ToHashTable(); - } - - ArrayList SendParams = new ArrayList(); - SendParams.Add(loginParams); - - // Send - XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); - XmlRpcResponse GridResp = GridReq.Send(regionInfo.httpServerURI, 6000); - - if (!GridResp.IsFault) - { - bool responseSuccess = true; - - if (GridResp.Value != null) - { - Hashtable resp = (Hashtable)GridResp.Value; - if (resp.ContainsKey("success")) - { - if ((string)resp["success"] == "FALSE") - { - responseSuccess = false; - } - } - } - - if (responseSuccess) - { - handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; - if (handlerUserLoggedInAtLocation != null) - { - handlerUserLoggedInAtLocation(user.ID, user.CurrentAgent.SessionID, - user.CurrentAgent.Region, - user.CurrentAgent.Handle, - user.CurrentAgent.Position.X, - user.CurrentAgent.Position.Y, - user.CurrentAgent.Position.Z, - user.FirstName, user.SurName); - } - } - else - { - m_log.ErrorFormat("[LOGIN]: Region responded that it is not available to receive clients"); - return false; - } - } - else - { - m_log.ErrorFormat("[LOGIN]: XmlRpc request to region failed with message {0}, code {1} ", GridResp.FaultString, GridResp.FaultCode); - return false; - } - } - catch (Exception e) - { - m_log.ErrorFormat("[LOGIN]: Region not available for login, {0}", e); - return false; - } - - return true; - } - - public XmlRpcResponse XmlRPCSetLoginParams(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - UserProfileData userProfile; - Hashtable responseData = new Hashtable(); - - UUID uid; - string pass = requestData["password"].ToString(); - - if (!UUID.TryParse((string)requestData["avatar_uuid"], out uid)) - { - responseData["error"] = "No authorization"; - response.Value = responseData; - return response; - } - - userProfile = m_userManager.GetUserProfile(uid); - - if (userProfile == null || - (!AuthenticateUser(userProfile, pass)) || - userProfile.GodLevel < 200) - { - responseData["error"] = "No authorization"; - response.Value = responseData; - return response; - } - - if (requestData.ContainsKey("login_level")) - { - m_minLoginLevel = Convert.ToInt32(requestData["login_level"]); - } - - if (requestData.ContainsKey("login_motd")) - { - m_welcomeMessage = requestData["login_motd"].ToString(); - } - - response.Value = responseData; - return response; - } - } -} diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs deleted file mode 100644 index 36c6297..0000000 --- a/OpenSim/Grid/UserServer.Modules/UserManager.cs +++ /dev/null @@ -1,718 +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.Net; -using System.Reflection; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Grid.Framework; - -namespace OpenSim.Grid.UserServer.Modules -{ - public delegate void logOffUser(UUID AgentID); - - public class UserManager - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public event logOffUser OnLogOffUser; - private logOffUser handlerLogOffUser; - - private UserDataBaseService m_userDataBaseService; - private BaseHttpServer m_httpServer; - - /// - /// - /// - /// - public UserManager(UserDataBaseService userDataBaseService) - { - m_userDataBaseService = userDataBaseService; - } - - public void Initialise(IGridServiceCore core) - { - - } - - public void PostInitialise() - { - - } - - private string RESTGetUserProfile(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - UUID id; - UserProfileData userProfile; - - try - { - id = new UUID(param); - } - catch (Exception) - { - httpResponse.StatusCode = 500; - return "Malformed Param [" + param + "]"; - } - - userProfile = m_userDataBaseService.GetUserProfile(id); - - if (userProfile == null) - { - httpResponse.StatusCode = 404; - return "Not Found."; - } - - return ProfileToXmlRPCResponse(userProfile).ToString(); - } - - public void RegisterHandlers(BaseHttpServer httpServer) - { - m_httpServer = httpServer; - - m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/users/", RESTGetUserProfile)); - - m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName); - m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); - m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); - - // Used by IAR module to do password checks - m_httpServer.AddXmlRPCHandler("authenticate_user_by_password", XmlRPCAuthenticateUserMethodPassword); - - m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion); - m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID); - m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID); - - m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile); - - m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod)); - } - - /// - /// Deletes an active agent session - /// - /// The request - /// The path (eg /bork/narf/test) - /// Parameters sent - /// HTTP request header object - /// HTTP response header object - /// Success "OK" else error - public string RestDeleteUserSessionMethod(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - // TODO! Important! - - return "OK"; - } - - public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(UUID queryID, List returnUsers) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable(); - // Query Result Information - responseData["queryid"] = queryID.ToString(); - responseData["avcount"] = returnUsers.Count.ToString(); - - for (int i = 0; i < returnUsers.Count; i++) - { - responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString(); - responseData["firstname" + i] = returnUsers[i].firstName; - responseData["lastname" + i] = returnUsers[i].lastName; - } - response.Value = responseData; - - return response; - } - - /// - /// Converts a user profile to an XML element which can be returned - /// - /// The user profile - /// A string containing an XML Document of the user profile - public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable(); - - // Account information - responseData["firstname"] = profile.FirstName; - responseData["lastname"] = profile.SurName; - responseData["email"] = profile.Email; - responseData["uuid"] = profile.ID.ToString(); - // Server Information - responseData["server_inventory"] = profile.UserInventoryURI; - responseData["server_asset"] = profile.UserAssetURI; - // Profile Information - responseData["profile_about"] = profile.AboutText; - responseData["profile_firstlife_about"] = profile.FirstLifeAboutText; - responseData["profile_firstlife_image"] = profile.FirstLifeImage.ToString(); - responseData["profile_can_do"] = profile.CanDoMask.ToString(); - responseData["profile_want_do"] = profile.WantDoMask.ToString(); - responseData["profile_image"] = profile.Image.ToString(); - responseData["profile_created"] = profile.Created.ToString(); - responseData["profile_lastlogin"] = profile.LastLogin.ToString(); - // Home region information - responseData["home_coordinates_x"] = profile.HomeLocation.X.ToString(); - responseData["home_coordinates_y"] = profile.HomeLocation.Y.ToString(); - responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString(); - - responseData["home_region"] = profile.HomeRegion.ToString(); - responseData["home_region_id"] = profile.HomeRegionID.ToString(); - - responseData["home_look_x"] = profile.HomeLookAt.X.ToString(); - responseData["home_look_y"] = profile.HomeLookAt.Y.ToString(); - responseData["home_look_z"] = profile.HomeLookAt.Z.ToString(); - - responseData["user_flags"] = profile.UserFlags.ToString(); - responseData["god_level"] = profile.GodLevel.ToString(); - responseData["custom_type"] = profile.CustomType; - responseData["partner"] = profile.Partner.ToString(); - response.Value = responseData; - - return response; - } - - #region XMLRPC User Methods - - /// - /// Authenticate a user using their password - /// - /// Must contain values for "user_uuid" and "password" keys - /// - /// - public XmlRpcResponse XmlRPCAuthenticateUserMethodPassword(XmlRpcRequest request, IPEndPoint remoteClient) - { -// m_log.DebugFormat("[USER MANAGER]: Received authenticated user by password request from {0}", remoteClient); - - Hashtable requestData = (Hashtable)request.Params[0]; - string userUuidRaw = (string)requestData["user_uuid"]; - string password = (string)requestData["password"]; - - if (null == userUuidRaw) - return Util.CreateUnknownUserErrorResponse(); - - UUID userUuid; - if (!UUID.TryParse(userUuidRaw, out userUuid)) - return Util.CreateUnknownUserErrorResponse(); - - UserProfileData userProfile = m_userDataBaseService.GetUserProfile(userUuid); - if (null == userProfile) - return Util.CreateUnknownUserErrorResponse(); - - string authed; - - if (null == password) - { - authed = "FALSE"; - } - else - { - if (m_userDataBaseService.AuthenticateUserByPassword(userUuid, password)) - authed = "TRUE"; - else - authed = "FALSE"; - } - -// m_log.DebugFormat( -// "[USER MANAGER]: Authentication by password result from {0} for {1} is {2}", -// remoteClient, userUuid, authed); - - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable(); - responseData["auth_user"] = authed; - response.Value = responseData; - - return response; - } - - public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request, IPEndPoint remoteClient) - { - // XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - List returnAvatar = new List(); - UUID queryID = new UUID(UUID.Zero.ToString()); - - if (requestData.Contains("avquery") && requestData.Contains("queryid")) - { - queryID = new UUID((string)requestData["queryid"]); - returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string)requestData["avquery"]); - } - - m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string)requestData["avquery"]); - return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); - } - - public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData = new Hashtable(); - string returnstring = "FALSE"; - - if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") && - requestData.Contains("region_uuid")) - { - // ulong cregionhandle = 0; - UUID regionUUID; - UUID avatarUUID; - - UUID.TryParse((string)requestData["avatar_id"], out avatarUUID); - UUID.TryParse((string)requestData["region_uuid"], out regionUUID); - - if (avatarUUID != UUID.Zero) - { - UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID); - userProfile.CurrentAgent.Region = regionUUID; - userProfile.CurrentAgent.Handle = (ulong)Convert.ToInt64((string)requestData["region_handle"]); - //userProfile.CurrentAgent. - m_userDataBaseService.CommitAgent(ref userProfile); - //setUserProfile(userProfile); - - returnstring = "TRUE"; - } - } - - responseData.Add("returnString", returnstring); - response.Value = responseData; - return response; - } - - public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request, IPEndPoint remoteClient) - { - // XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - UserProfileData userProfile; - if (requestData.Contains("avatar_name")) - { - string query = (string)requestData["avatar_name"]; - - if (null == query) - return Util.CreateUnknownUserErrorResponse(); - - // Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); - - string[] querysplit = query.Split(' '); - - if (querysplit.Length == 2) - { - userProfile = m_userDataBaseService.GetUserProfile(querysplit[0], querysplit[1]); - if (userProfile == null) - { - return Util.CreateUnknownUserErrorResponse(); - } - } - else - { - return Util.CreateUnknownUserErrorResponse(); - } - } - else - { - return Util.CreateUnknownUserErrorResponse(); - } - - return ProfileToXmlRPCResponse(userProfile); - } - - public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient) - { - // XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - UserProfileData userProfile; - //CFK: this clogs the UserServer log and is not necessary at this time. - //CFK: m_log.Debug("METHOD BY UUID CALLED"); - if (requestData.Contains("avatar_uuid")) - { - try - { - UUID guess = new UUID((string)requestData["avatar_uuid"]); - - userProfile = m_userDataBaseService.GetUserProfile(guess); - } - catch (FormatException) - { - return Util.CreateUnknownUserErrorResponse(); - } - - if (userProfile == null) - { - return Util.CreateUnknownUserErrorResponse(); - } - } - else - { - return Util.CreateUnknownUserErrorResponse(); - } - - return ProfileToXmlRPCResponse(userProfile); - } - - public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - UserProfileData userProfile; - //CFK: this clogs the UserServer log and is not necessary at this time. - //CFK: m_log.Debug("METHOD BY UUID CALLED"); - if (requestData.Contains("avatar_uuid")) - { - UUID guess; - - UUID.TryParse((string)requestData["avatar_uuid"], out guess); - - if (guess == UUID.Zero) - { - return Util.CreateUnknownUserErrorResponse(); - } - - userProfile = m_userDataBaseService.GetUserProfile(guess); - - if (userProfile == null) - { - return Util.CreateUnknownUserErrorResponse(); - } - - // no agent??? - if (userProfile.CurrentAgent == null) - { - return Util.CreateUnknownUserErrorResponse(); - } - Hashtable responseData = new Hashtable(); - - responseData["handle"] = userProfile.CurrentAgent.Handle.ToString(); - responseData["session"] = userProfile.CurrentAgent.SessionID.ToString(); - if (userProfile.CurrentAgent.AgentOnline) - responseData["agent_online"] = "TRUE"; - else - responseData["agent_online"] = "FALSE"; - - response.Value = responseData; - } - else - { - return Util.CreateUnknownUserErrorResponse(); - } - - return response; - } - - public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request, IPEndPoint remoteClient) - { - m_log.Debug("[UserManager]: Got request to update user profile"); - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData = new Hashtable(); - - if (!requestData.Contains("avatar_uuid")) - { - return Util.CreateUnknownUserErrorResponse(); - } - - UUID UserUUID = new UUID((string)requestData["avatar_uuid"]); - UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID); - if (null == userProfile) - { - return Util.CreateUnknownUserErrorResponse(); - } - // don't know how yet. - if (requestData.Contains("AllowPublish")) - { - } - if (requestData.Contains("FLImageID")) - { - userProfile.FirstLifeImage = new UUID((string)requestData["FLImageID"]); - } - if (requestData.Contains("ImageID")) - { - userProfile.Image = new UUID((string)requestData["ImageID"]); - } - // dont' know how yet - if (requestData.Contains("MaturePublish")) - { - } - if (requestData.Contains("AboutText")) - { - userProfile.AboutText = (string)requestData["AboutText"]; - } - if (requestData.Contains("FLAboutText")) - { - userProfile.FirstLifeAboutText = (string)requestData["FLAboutText"]; - } - // not in DB yet. - if (requestData.Contains("ProfileURL")) - { - } - if (requestData.Contains("home_region")) - { - try - { - userProfile.HomeRegion = Convert.ToUInt64((string)requestData["home_region"]); - } - catch (ArgumentException) - { - m_log.Error("[PROFILE]:Failed to set home region, Invalid Argument"); - } - catch (FormatException) - { - m_log.Error("[PROFILE]:Failed to set home region, Invalid Format"); - } - catch (OverflowException) - { - m_log.Error("[PROFILE]:Failed to set home region, Value was too large"); - } - } - if (requestData.Contains("home_region_id")) - { - UUID regionID; - UUID.TryParse((string)requestData["home_region_id"], out regionID); - userProfile.HomeRegionID = regionID; - } - if (requestData.Contains("home_pos_x")) - { - try - { - userProfile.HomeLocationX = (float)Convert.ToDecimal((string)requestData["home_pos_x"]); - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set home postion x"); - } - } - if (requestData.Contains("home_pos_y")) - { - try - { - userProfile.HomeLocationY = (float)Convert.ToDecimal((string)requestData["home_pos_y"]); - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set home postion y"); - } - } - if (requestData.Contains("home_pos_z")) - { - try - { - userProfile.HomeLocationZ = (float)Convert.ToDecimal((string)requestData["home_pos_z"]); - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set home postion z"); - } - } - if (requestData.Contains("home_look_x")) - { - try - { - userProfile.HomeLookAtX = (float)Convert.ToDecimal((string)requestData["home_look_x"]); - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set home lookat x"); - } - } - if (requestData.Contains("home_look_y")) - { - try - { - userProfile.HomeLookAtY = (float)Convert.ToDecimal((string)requestData["home_look_y"]); - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set home lookat y"); - } - } - if (requestData.Contains("home_look_z")) - { - try - { - userProfile.HomeLookAtZ = (float)Convert.ToDecimal((string)requestData["home_look_z"]); - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set home lookat z"); - } - } - if (requestData.Contains("user_flags")) - { - try - { - userProfile.UserFlags = Convert.ToInt32((string)requestData["user_flags"]); - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set user flags"); - } - } - if (requestData.Contains("god_level")) - { - try - { - userProfile.GodLevel = Convert.ToInt32((string)requestData["god_level"]); - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set god level"); - } - } - if (requestData.Contains("custom_type")) - { - try - { - userProfile.CustomType = (string)requestData["custom_type"]; - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set custom type"); - } - } - if (requestData.Contains("partner")) - { - try - { - userProfile.Partner = new UUID((string)requestData["partner"]); - } - catch (InvalidCastException) - { - m_log.Error("[PROFILE]:Failed to set partner"); - } - } - else - { - userProfile.Partner = UUID.Zero; - } - - // call plugin! - bool ret = m_userDataBaseService.UpdateUserProfile(userProfile); - responseData["returnString"] = ret.ToString(); - response.Value = responseData; - return response; - } - - public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - - if (requestData.Contains("avatar_uuid")) - { - try - { - UUID userUUID = new UUID((string)requestData["avatar_uuid"]); - UUID RegionID = new UUID((string)requestData["region_uuid"]); - ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]); - Vector3 position = new Vector3( - (float)Convert.ToDecimal((string)requestData["region_pos_x"]), - (float)Convert.ToDecimal((string)requestData["region_pos_y"]), - (float)Convert.ToDecimal((string)requestData["region_pos_z"])); - Vector3 lookat = new Vector3( - (float)Convert.ToDecimal((string)requestData["lookat_x"]), - (float)Convert.ToDecimal((string)requestData["lookat_y"]), - (float)Convert.ToDecimal((string)requestData["lookat_z"])); - - handlerLogOffUser = OnLogOffUser; - if (handlerLogOffUser != null) - handlerLogOffUser(userUUID); - - m_userDataBaseService.LogOffUser(userUUID, RegionID, regionhandle, position, lookat); - } - catch (FormatException) - { - m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params"); - return response; - } - } - else - { - return Util.CreateUnknownUserErrorResponse(); - } - - return response; - } - - #endregion - - - public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle) - { - UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); - if (userProfile != null) - { - userProfile.CurrentAgent.Region = regionID; - userProfile.CurrentAgent.Handle = regionHandle; - m_userDataBaseService.CommitAgent(ref userProfile); - } - } - - public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle) - { - UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); - if (userProfile != null) - { - if (userProfile.CurrentAgent.Region == regionID) - { - UserAgentData userAgent = userProfile.CurrentAgent; - if (userAgent != null && userAgent.AgentOnline) - { - userAgent.AgentOnline = false; - userAgent.LogoutTime = Util.UnixTimeSinceEpoch(); - if (regionID != UUID.Zero) - { - userAgent.Region = regionID; - } - userAgent.Handle = regionHandle; - userProfile.LastLogin = userAgent.LogoutTime; - - m_userDataBaseService.CommitAgent(ref userProfile); - - handlerLogOffUser = OnLogOffUser; - if (handlerLogOffUser != null) - handlerLogOffUser(agentID); - } - } - } - } - - public void HandleRegionStartup(UUID regionID) - { - m_userDataBaseService.LogoutUsers(regionID); - } - - public void HandleRegionShutdown(UUID regionID) - { - m_userDataBaseService.LogoutUsers(regionID); - } - } -} diff --git a/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs b/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs deleted file mode 100644 index 88918d1..0000000 --- a/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs +++ /dev/null @@ -1,132 +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.Net; -using System.Reflection; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Grid.Framework; - -namespace OpenSim.Grid.UserServer.Modules -{ - public class UserServerAvatarAppearanceModule - { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private UserDataBaseService m_userDataBaseService; - private BaseHttpServer m_httpServer; - - public UserServerAvatarAppearanceModule(UserDataBaseService userDataBaseService) - { - m_userDataBaseService = userDataBaseService; - } - - public void Initialise(IGridServiceCore core) - { - - } - - public void PostInitialise() - { - - } - - public void RegisterHandlers(BaseHttpServer httpServer) - { - m_httpServer = httpServer; - - m_httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance); - m_httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance); - } - - public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - AvatarAppearance appearance; - Hashtable responseData; - if (requestData.Contains("owner")) - { - appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"])); - if (appearance == null) - { - responseData = new Hashtable(); - responseData["error_type"] = "no appearance"; - responseData["error_desc"] = "There was no appearance found for this avatar"; - } - else - { - responseData = appearance.ToHashTable(); - } - } - else - { - responseData = new Hashtable(); - responseData["error_type"] = "unknown_avatar"; - responseData["error_desc"] = "The avatar appearance requested is not in the database"; - } - - response.Value = responseData; - return response; - } - - public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData; - if (requestData.Contains("owner")) - { - AvatarAppearance appearance = new AvatarAppearance(requestData); - - // TODO: Sometime in the future we may have a database layer that is capable of updating appearance when - // the TextureEntry is null. When that happens, this check can be removed - if (appearance.Texture != null) - m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance); - - responseData = new Hashtable(); - responseData["returnString"] = "TRUE"; - } - else - { - responseData = new Hashtable(); - responseData["error_type"] = "unknown_avatar"; - responseData["error_desc"] = "The avatar appearance requested is not in the database"; - } - response.Value = responseData; - return response; - } - } -} diff --git a/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs b/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs deleted file mode 100644 index 56e52a0..0000000 --- a/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs +++ /dev/null @@ -1,176 +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.Net; -using System.Reflection; -using log4net; -using Nwc.XmlRpc; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Grid.Framework; - -namespace OpenSim.Grid.UserServer.Modules -{ - public class UserServerFriendsModule - { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private UserDataBaseService m_userDataBaseService; - - private BaseHttpServer m_httpServer; - - public UserServerFriendsModule(UserDataBaseService userDataBaseService) - { - m_userDataBaseService = userDataBaseService; - } - - public void Initialise(IGridServiceCore core) - { - - } - - public void PostInitialise() - { - - } - - public void RegisterHandlers(BaseHttpServer httpServer) - { - m_httpServer = httpServer; - - m_httpServer.AddXmlRPCHandler("add_new_user_friend", XmlRpcResponseXmlRPCAddUserFriend); - m_httpServer.AddXmlRPCHandler("remove_user_friend", XmlRpcResponseXmlRPCRemoveUserFriend); - m_httpServer.AddXmlRPCHandler("update_user_friend_perms", XmlRpcResponseXmlRPCUpdateUserFriendPerms); - m_httpServer.AddXmlRPCHandler("get_user_friend_list", XmlRpcResponseXmlRPCGetUserFriendList); - } - - public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List returnUsers) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable(); - // Query Result Information - - responseData["avcount"] = returnUsers.Count.ToString(); - - for (int i = 0; i < returnUsers.Count; i++) - { - responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString(); - responseData["friendID" + i] = returnUsers[i].Friend.ToString(); - responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString(); - responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString(); - } - response.Value = responseData; - - return response; - } - - public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData = new Hashtable(); - string returnString = "FALSE"; - // Query Result Information - - if (requestData.Contains("ownerID") && requestData.Contains("friendID") && - requestData.Contains("friendPerms")) - { - // UserManagerBase.AddNewuserFriend - m_userDataBaseService.AddNewUserFriend(new UUID((string)requestData["ownerID"]), - new UUID((string)requestData["friendID"]), - (uint)Convert.ToInt32((string)requestData["friendPerms"])); - returnString = "TRUE"; - } - responseData["returnString"] = returnString; - response.Value = responseData; - return response; - } - - public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData = new Hashtable(); - string returnString = "FALSE"; - // Query Result Information - - if (requestData.Contains("ownerID") && requestData.Contains("friendID")) - { - // UserManagerBase.AddNewuserFriend - m_userDataBaseService.RemoveUserFriend(new UUID((string)requestData["ownerID"]), - new UUID((string)requestData["friendID"])); - returnString = "TRUE"; - } - responseData["returnString"] = returnString; - response.Value = responseData; - return response; - } - - public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData = new Hashtable(); - string returnString = "FALSE"; - - if (requestData.Contains("ownerID") && requestData.Contains("friendID") && - requestData.Contains("friendPerms")) - { - m_userDataBaseService.UpdateUserFriendPerms(new UUID((string)requestData["ownerID"]), - new UUID((string)requestData["friendID"]), - (uint)Convert.ToInt32((string)requestData["friendPerms"])); - // UserManagerBase. - returnString = "TRUE"; - } - responseData["returnString"] = returnString; - response.Value = responseData; - return response; - } - - public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request, IPEndPoint remoteClient) - { - // XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - // Hashtable responseData = new Hashtable(); - - List returndata = new List(); - - if (requestData.Contains("ownerID")) - { - returndata = m_userDataBaseService.GetUserFriendList(new UUID((string)requestData["ownerID"])); - } - - return FriendListItemListtoXmlRPCResponse(returndata); - } - } -} -- cgit v1.1