From 070047ce1bc74cceebd5e817a0e042a7390c5f24 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 26 Oct 2007 14:08:36 +0000 Subject: * Added prototypical AvatarFactory module interface to load avatar parameters * Added dump_assets_to_file option to enable asset dumping for debug * normalized some namespaces * InventoryFolder renamed to InventoryFolderImpl to --- .../Cache/AssetTransactionManager.cs | 14 +++++------ .../Communications/Cache/AssetTransactions.cs | 28 +++++++++++++++------- .../Communications/Cache/CachedUserInfo.cs | 9 ++++--- .../Communications/Cache/InventoryFolder.cs | 26 ++++++++++---------- .../Communications/Cache/LibraryRootFolder.cs | 10 ++++---- .../Communications/Cache/UserProfileCache.cs | 23 +++++++++--------- 6 files changed, 59 insertions(+), 51 deletions(-) (limited to 'OpenSim/Framework/Communications/Cache') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 42c0a8e..2c1e5c8 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -36,17 +36,19 @@ using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Framework.Data; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { public class AssetTransactionManager { // Fields public CommunicationsManager CommsManager; public Dictionary AgentTransactions = new Dictionary(); + private bool m_dumpAssetsToFile; - public AssetTransactionManager(CommunicationsManager commsManager) + public AssetTransactionManager(CommunicationsManager commsManager, bool dumpAssetsToFile) { CommsManager = commsManager; + m_dumpAssetsToFile = dumpAssetsToFile; } // Methods @@ -54,7 +56,7 @@ namespace OpenSim.Framework.Communications.Caches { if (!this.AgentTransactions.ContainsKey(userID)) { - AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this); + AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); this.AgentTransactions.Add(userID, transactions); return transactions; } @@ -82,7 +84,7 @@ namespace OpenSim.Framework.Communications.Caches public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) { - // Console.WriteLine("asset upload of " + assetID); + // Console.WriteLine("asset upload of " + assetID); AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); if (transactions != null) { @@ -103,6 +105,4 @@ namespace OpenSim.Framework.Communications.Caches } } } -} - - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 51fc462..581e300 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -39,7 +39,7 @@ using OpenSim.Framework.Utilities; using OpenSim.Region.Capabilities; using OpenSim.Framework.Servers; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { public class AgentAssetTransactions { @@ -49,12 +49,14 @@ namespace OpenSim.Framework.Communications.Caches public LLUUID UserID; public Dictionary XferUploaders = new Dictionary(); public AssetTransactionManager Manager; + private bool m_dumpAssetsToFile; // Methods - public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager) + public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile) { this.UserID = agentID; Manager = manager; + m_dumpAssetsToFile = dumpAssetsToFile; } public AssetCapsUploader RequestCapsUploader() @@ -75,7 +77,7 @@ namespace OpenSim.Framework.Communications.Caches { if (!this.XferUploaders.ContainsKey(transactionID)) { - AssetXferUploader uploader = new AssetXferUploader(this); + AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); this.XferUploaders.Add(transactionID, uploader); return uploader; @@ -122,14 +124,14 @@ namespace OpenSim.Framework.Communications.Caches private string m_assetName = ""; private LLUUID m_folderID; private LLUUID newAssetID; - private bool SaveImages = false; + private bool m_dumpImageToFile; private string uploaderPath = ""; // Events public event UpLoadedAsset OnUpLoad; // Methods - public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer) + public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) { this.m_assetName = assetName; this.m_assetDescription = assetDescription; @@ -138,6 +140,7 @@ namespace OpenSim.Framework.Communications.Caches this.inventoryItemID = inventoryItem; this.uploaderPath = path; this.httpListener = httpServer; + m_dumpImageToFile = dumpImageToFile; } private void SaveImageToFile(string filename, byte[] data) @@ -159,7 +162,7 @@ namespace OpenSim.Framework.Communications.Caches complete.state = "complete"; text = LLSDHelpers.SerialiseLLSDReply(complete); this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); - if (this.SaveImages) + if (this.m_dumpImageToFile) { this.SaveImageToFile(this.m_assetName + ".jp2", data); } @@ -190,10 +193,12 @@ namespace OpenSim.Framework.Communications.Caches private bool m_createItem = false; private AgentAssetTransactions m_userTransactions; private bool m_storeLocal; + private bool m_dumpAssetToFile; - public AssetXferUploader(AgentAssetTransactions transactions) + public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) { this.m_userTransactions = transactions; + m_dumpAssetToFile = dumpAssetToFile; } // Methods @@ -278,9 +283,14 @@ namespace OpenSim.Framework.Communications.Caches this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); } - // Console.WriteLine("upload complete "+ this.TransactionID); - //SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); + // Console.WriteLine("upload complete "+ this.TransactionID); + + if (m_dumpAssetToFile) + { + SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); + } } + private void SaveAssetToFile(string filename, byte[] data) { FileStream fs = File.Create(filename); diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index b1432ff..92b21a8 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -27,7 +27,6 @@ */ using libsecondlife; using OpenSim.Framework.Types; -using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder; namespace OpenSim.Framework.Communications.Cache { @@ -35,7 +34,7 @@ namespace OpenSim.Framework.Communications.Cache { private readonly CommunicationsManager m_parentCommsManager; // Fields - public InventoryFolder RootFolder = null; + public InventoryFolderImpl RootFolder = null; public UserProfileData UserProfile = null; public CachedUserInfo(CommunicationsManager commsManager) @@ -44,7 +43,7 @@ namespace OpenSim.Framework.Communications.Cache } // Methods - public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) + public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) { if (userID == this.UserProfile.UUID) { @@ -61,7 +60,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolder folder = this.RootFolder.HasSubFolder(folderInfo.parentID); + InventoryFolderImpl folder = this.RootFolder.HasSubFolder(folderInfo.parentID); if (folder != null) { folder.SubFolders.Add(folderInfo.folderID, folderInfo); @@ -80,7 +79,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); + InventoryFolderImpl folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); if (folder != null) { folder.Items.Add(itemInfo.inventoryID, itemInfo); diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index fbe1bd0..af3346f 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -35,15 +35,15 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { - public class InventoryFolder : InventoryFolderBase + public class InventoryFolderImpl : InventoryFolderBase { // Fields public Dictionary Items = new Dictionary(); - public Dictionary SubFolders = new Dictionary(); + public Dictionary SubFolders = new Dictionary(); - public InventoryFolder(InventoryFolderBase folderbase) + public InventoryFolderImpl(InventoryFolderBase folderbase) { this.agentID = folderbase.agentID; this.folderID = folderbase.folderID; @@ -53,15 +53,15 @@ namespace OpenSim.Framework.Communications.Caches this.version = folderbase.version; } - public InventoryFolder() + public InventoryFolderImpl() { } // Methods - public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) + public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) { - InventoryFolder subFold = new InventoryFolder(); + InventoryFolderImpl subFold = new InventoryFolderImpl(); subFold.name = folderName; subFold.folderID = folderID; subFold.type = (short) type; @@ -78,7 +78,7 @@ namespace OpenSim.Framework.Communications.Caches { return this.Items[itemID]; } - foreach (InventoryFolder folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in this.SubFolders.Values) { base2 = folder.HasItem(itemID); if (base2 != null) @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Caches Items.Remove(itemID); return true; } - foreach (InventoryFolder folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in this.SubFolders.Values) { found = folder.DeleteItem(itemID); if (found == true) @@ -109,16 +109,16 @@ namespace OpenSim.Framework.Communications.Caches } - public InventoryFolder HasSubFolder(LLUUID folderID) + public InventoryFolderImpl HasSubFolder(LLUUID folderID) { - InventoryFolder returnFolder = null; + InventoryFolderImpl returnFolder = null; if (this.SubFolders.ContainsKey(folderID)) { returnFolder = this.SubFolders[folderID]; } else { - foreach (InventoryFolder folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in this.SubFolders.Values) { returnFolder = folder.HasSubFolder(folderID); if (returnFolder != null) @@ -140,4 +140,4 @@ namespace OpenSim.Framework.Communications.Caches return itemList; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 13ce39e..86e26f0 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -35,16 +35,16 @@ using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using Nini.Config; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { /// /// Basically a hack to give us a Inventory library while we don't have a inventory server /// once the server is fully implemented then should read the data from that /// - public class LibraryRootFolder : InventoryFolder + public class LibraryRootFolder : Cache.InventoryFolderImpl { private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - private InventoryFolder m_textureFolder; + private Cache.InventoryFolderImpl m_textureFolder; public LibraryRootFolder() { @@ -55,7 +55,7 @@ namespace OpenSim.Framework.Communications.Caches this.type = (short)-1; this.version = (ushort)1; - InventoryFolder folderInfo = new InventoryFolder(); + Cache.InventoryFolderImpl folderInfo = new InventoryFolderImpl(); folderInfo.agentID = libOwner; folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); folderInfo.name = "Texture Library"; @@ -242,4 +242,4 @@ namespace OpenSim.Framework.Communications.Caches } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 362ab17..bd7aeef 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -36,7 +36,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -namespace OpenSim.Framework.Communications.Caches +namespace OpenSim.Framework.Communications.Cache { public class UserProfileCache { @@ -107,15 +107,15 @@ namespace OpenSim.Framework.Communications.Caches CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; if (info.RootFolder.folderID == parentID) { - InventoryFolder createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); - if (createdFolder != null) - { - this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); - } + InventoryFolderImpl createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + if (createdFolder != null) + { + this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); + } } else { - InventoryFolder folder = info.RootFolder.HasSubFolder(parentID); + InventoryFolderImpl folder = info.RootFolder.HasSubFolder(parentID); if (folder != null) { folder.CreateNewSubFolder(folderID, folderName, folderType); @@ -127,7 +127,7 @@ namespace OpenSim.Framework.Communications.Caches public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { - InventoryFolder fold = null; + InventoryFolderImpl fold = null; if (folderID == libraryRoot.folderID ) { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); @@ -150,7 +150,7 @@ namespace OpenSim.Framework.Communications.Caches } else { - InventoryFolder folder = info.RootFolder.HasSubFolder(folderID); + InventoryFolderImpl folder = info.RootFolder.HasSubFolder(folderID); if ((folder != null) && fetchItems) { remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); @@ -185,7 +185,7 @@ namespace OpenSim.Framework.Communications.Caches /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } /// @@ -223,5 +223,4 @@ namespace OpenSim.Framework.Communications.Caches { } } -} - +} \ No newline at end of file -- cgit v1.1