From efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Dec 2007 21:41:48 +0000 Subject: * Optimized usings * shortened references * Removed redundant 'this' * Normalized EOF --- .../Grid/InventoryServer/GridInventoryService.cs | 45 +++++++++++----------- OpenSim/Grid/InventoryServer/InventoryManager.cs | 43 +++++++++++---------- OpenSim/Grid/InventoryServer/Main.cs | 34 +++++++--------- 3 files changed, 59 insertions(+), 63 deletions(-) (limited to 'OpenSim/Grid/InventoryServer') diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs index ca2e526..d36a915 100644 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -28,23 +28,22 @@ using System; using System.Collections.Generic; -using System.Text; +using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Console; -using libsecondlife; namespace OpenSim.Grid.InventoryServer { public class GridInventoryService : InventoryServiceBase { public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, - InventoryItemInfo itemCallBack) + InventoryItemInfo itemCallBack) { - } - private bool TryGetUsersInventory(LLUUID userID, out List folderList, out List itemsList) + private bool TryGetUsersInventory(LLUUID userID, out List folderList, + out List itemsList) { List rootFolders = RequestFirstLevelFolders(userID); List allItems = new List(); @@ -107,10 +106,10 @@ namespace OpenSim.Grid.InventoryServer public InventoryCollection GetUserInventory(Guid rawUserID) { LLUUID userID = new LLUUID(rawUserID); - + // We get enough verbose messages later on for diagnostics //MainLog.Instance.Verbose("INVENTORY", "Request for inventory for " + userID.ToString()); - + InventoryCollection invCollection = new InventoryCollection(); List folders; List allItems; @@ -126,14 +125,14 @@ namespace OpenSim.Grid.InventoryServer public bool CreateUsersInventory(Guid rawUserID) { LLUUID userID = new LLUUID(rawUserID); - + MainLog.Instance.Verbose( "INVENTORY", "Creating new set of inventory folders for " + userID.ToString()); - + CreateNewUserInventory(userID); return true; } - + public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) { @@ -156,30 +155,30 @@ namespace OpenSim.Grid.InventoryServer MainLog.Instance.Verbose( "INVENTORY", "Updating in " + folder.parentID.ToString() - + ", folder " + folder.name); - + + ", folder " + folder.name); + AddNewInventoryFolder(folder.agentID, folder); return true; } public bool MoveInventoryFolder(InventoryFolderBase folder) - { + { MainLog.Instance.Verbose( "INVENTORY", "Moving folder " + folder.folderID - + " to " + folder.parentID.ToString()); - + + " to " + folder.parentID.ToString()); + MoveExistingInventoryFolder(folder); return true; } - public bool AddInventoryItem( InventoryItemBase item) + public bool AddInventoryItem(InventoryItemBase item) { // Right now, this actions act more like an update/insert combination than a simple create. MainLog.Instance.Verbose( - "INVENTORY", + "INVENTORY", "Updating in " + item.parentFolderID.ToString() - + ", item " + item.inventoryName); + + ", item " + item.inventoryName); AddNewInventoryItem(item.avatarID, item); return true; @@ -191,15 +190,15 @@ namespace OpenSim.Grid.InventoryServer MainLog.Instance.Verbose( "INVENTORY", "Deleting in " + item.parentFolderID.ToString() - + ", item " + item.inventoryName); - + + ", item " + item.inventoryName); + DeleteItem(item); } - public bool DeleteInvItem( InventoryItemBase item) + public bool DeleteInvItem(InventoryItemBase item) { DeleteInventoryItem(item.avatarID, item); return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs index 1070bcf..a003ce3 100644 --- a/OpenSim/Grid/InventoryServer/InventoryManager.cs +++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs @@ -25,26 +25,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; using System.IO; -using System.Text; using System.Reflection; -using System.Collections; -using System.Collections.Generic; +using System.Text; using System.Xml; using System.Xml.Serialization; using libsecondlife; - using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; namespace OpenSim.Grid.InventoryServer { - public class InventoryManager { - IInventoryData _databasePlugin; + private IInventoryData _databasePlugin; /// /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded. @@ -55,7 +52,8 @@ namespace OpenSim.Grid.InventoryServer MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); - MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + MainLog.Instance.Verbose(OpenInventory_Main.LogName, + "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); foreach (Type pluginType in pluginAssembly.GetTypes()) { if (!pluginType.IsAbstract) @@ -64,10 +62,12 @@ namespace OpenSim.Grid.InventoryServer if (typeInterface != null) { - IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IInventoryData plug = + (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); _databasePlugin = plug; - MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Added IInventoryData Interface"); + MainLog.Instance.Verbose(OpenInventory_Main.LogName, + "Invenstorage: Added IInventoryData Interface"); break; } @@ -82,8 +82,8 @@ namespace OpenSim.Grid.InventoryServer { FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); XmlReader reader = new XmlTextReader(fs); - XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); - SerializableInventory inventory = (SerializableInventory)x.Deserialize(reader); + XmlSerializer x = new XmlSerializer(typeof (SerializableInventory)); + SerializableInventory inventory = (SerializableInventory) x.Deserialize(reader); fs.Close(); fs.Dispose(); return inventory; @@ -93,11 +93,12 @@ namespace OpenSim.Grid.InventoryServer { XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8); writer.Formatting = Formatting.Indented; - XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); + XmlSerializer x = new XmlSerializer(typeof (SerializableInventory)); x.Serialize(writer, inventory); } - protected static bool fixupFolder(SerializableInventory.SerializableFolder f, SerializableInventory.SerializableFolder parent) + protected static bool fixupFolder(SerializableInventory.SerializableFolder f, + SerializableInventory.SerializableFolder parent) { bool modified = false; @@ -142,6 +143,7 @@ namespace OpenSim.Grid.InventoryServer { private SerializableInventory _inventory; private InventoryManager _manager; + public GetInventory(InventoryManager manager) : base("GET", "/inventory") { @@ -165,23 +167,24 @@ namespace OpenSim.Grid.InventoryServer private byte[] GetUserInventory(LLUUID userID) { MainLog.Instance.Notice(OpenInventory_Main.LogName, "Getting Inventory for user {0}", userID.ToString()); - byte[] result = new byte[] { }; + byte[] result = new byte[] {}; InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID); if (fb == null) { - MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new", userID.ToString()); + MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new", + userID.ToString()); CreateDefaultInventory(userID); } return result; } - override public byte[] Handle(string path, Stream request) + public override byte[] Handle(string path, Stream request) { - byte[] result = new byte[] { }; + byte[] result = new byte[] {}; - string[] parms = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); if (parms.Length > 1) { if (string.Compare(parms[1], "library", true) == 0) @@ -190,7 +193,7 @@ namespace OpenSim.Grid.InventoryServer saveInventoryToStream(_inventory, ms); result = ms.GetBuffer(); - Array.Resize(ref result, (int)ms.Length); + Array.Resize(ref result, (int) ms.Length); } else if (string.Compare(parms[1], "user", true) == 0) { @@ -204,4 +207,4 @@ namespace OpenSim.Grid.InventoryServer } } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index df854f9..ce371bf 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs @@ -25,29 +25,23 @@ * 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.Text; - using libsecondlife; - using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; -using InventoryManager = OpenSim.Grid.InventoryServer.InventoryManager; - namespace OpenSim.Grid.InventoryServer { public class OpenInventory_Main : conscmd_callback { - LogBase m_console; - InventoryManager m_inventoryManager; - InventoryConfig m_config; - GridInventoryService m_inventoryService; + private LogBase m_console; + private InventoryManager m_inventoryManager; + private InventoryConfig m_config; + private GridInventoryService m_inventoryService; public const string LogName = "INVENTORY"; @@ -72,20 +66,20 @@ namespace OpenSim.Grid.InventoryServer m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); m_inventoryService = new GridInventoryService(); - // m_inventoryManager = new InventoryManager(); + // m_inventoryManager = new InventoryManager(); m_inventoryService.AddPlugin(m_config.DatabaseProvider); MainLog.Instance.Notice(LogName, "Starting HTTP server ..."); BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); httpServer.AddStreamHandler( new RestDeserialisehandler("POST", "/GetInventory/", - m_inventoryService.GetUserInventory)); + m_inventoryService.GetUserInventory)); httpServer.AddStreamHandler( new RestDeserialisehandler("POST", "/CreateInventory/", - m_inventoryService.CreateUsersInventory)); + m_inventoryService.CreateUsersInventory)); httpServer.AddStreamHandler( new RestDeserialisehandler("POST", "/NewFolder/", - m_inventoryService.AddInventoryFolder)); + m_inventoryService.AddInventoryFolder)); httpServer.AddStreamHandler( new RestDeserialisehandler("POST", "/MoveFolder/", @@ -93,16 +87,16 @@ namespace OpenSim.Grid.InventoryServer httpServer.AddStreamHandler( new RestDeserialisehandler("POST", "/NewItem/", - m_inventoryService.AddInventoryItem)); + m_inventoryService.AddInventoryItem)); httpServer.AddStreamHandler( new RestDeserialisehandler("POST", "/DeleteItem/", - m_inventoryService.DeleteInvItem)); + m_inventoryService.DeleteInvItem)); httpServer.AddStreamHandler( new RestDeserialisehandler>("POST", "/RootFolders/", - m_inventoryService.RequestFirstLevelFolders)); + m_inventoryService.RequestFirstLevelFolders)); - // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); + // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); httpServer.Start(); MainLog.Instance.Notice(LogName, "Started HTTP server"); @@ -137,4 +131,4 @@ namespace OpenSim.Grid.InventoryServer { } } -} +} \ No newline at end of file -- cgit v1.1