diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs similarity index 100% rename from OpenSim/Framework/Communications/Cache/InventoryFolder.cs rename to OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 62251bce97..33b4281207 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -49,8 +49,8 @@ namespace OpenSim.Framework.Communications.Cache folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); name = "OpenSim Library"; parentID = LLUUID.Zero; - type = (short) -1; - version = (ushort) 1; + type = (short)-1; + version = (ushort)1; InventoryFolderImpl folderInfo = new InventoryFolderImpl(); folderInfo.agentID = libOwner; @@ -67,7 +67,7 @@ namespace OpenSim.Framework.Communications.Cache string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); if (File.Exists(filePath)) { - try + try { XmlConfigSource source = new XmlConfigSource(filePath); ReadItemsFromFile(source); @@ -80,142 +80,60 @@ namespace OpenSim.Framework.Communications.Cache } private void CreateLibraryItems() + { + InventoryItemBase item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000002"), "Plywood", "Plywood texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); + m_textureFolder.Items.Add(item.inventoryID, item); + + item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000003"), "Rocks", "Rocks texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); + m_textureFolder.Items.Add(item.inventoryID, item); + + item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000001"), "Bricks", "Bricks texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); + m_textureFolder.Items.Add(item.inventoryID, item); + + item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000004"), "Granite", "Granite texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); + m_textureFolder.Items.Add(item.inventoryID, item); + + item = CreateItem(LLUUID.Random(), new LLUUID("00000000-0000-0000-9999-000000000005"), "Hardwood", "Hardwood texture", (int)AssetType.Texture, (int)InventoryType.Texture, m_textureFolder.folderID); + m_textureFolder.Items.Add(item.inventoryID, item); + + item = CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); + item.inventoryCurrentPermissions = 0; + item.inventoryNextPermissions = 0; + Items.Add(item.inventoryID, item); + + item = CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"), new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); + item.inventoryCurrentPermissions = 0; + item.inventoryNextPermissions = 0; + Items.Add(item.inventoryID, item); + + item = CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"), new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", (int)AssetType.Clothing, (int)InventoryType.Wearable, folderID); + item.inventoryCurrentPermissions = 0; + item.inventoryNextPermissions = 0; + Items.Add(item.inventoryID, item); + + item = CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"), new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", (int)AssetType.Clothing, (int)InventoryType.Wearable, folderID); + item.inventoryCurrentPermissions = 0; + item.inventoryNextPermissions = 0; + Items.Add(item.inventoryID, item); + } + + private InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, int assetType, int invType, LLUUID parentFolderID) { InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000002"); - item.inventoryDescription = "Plywood texture"; - item.inventoryName = "Plywood"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; + item.assetID = assetID; + item.inventoryDescription = description; + item.inventoryName = name; + item.assetType = assetType; + item.invType = invType; + item.parentFolderID = parentFolderID; item.inventoryBasePermissions = 0x7FFFFFFF; item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - m_textureFolder.Items.Add(item.inventoryID, item); - - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000003"); - item.inventoryDescription = "Rocks texture"; - item.inventoryName = "Rocks"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; - m_textureFolder.Items.Add(item.inventoryID, item); - - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000001"); - item.inventoryDescription = "Bricks texture"; - item.inventoryName = "Bricks"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; - m_textureFolder.Items.Add(item.inventoryID, item); - - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000004"); - item.inventoryDescription = "Granite texture"; - item.inventoryName = "Granite"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; - m_textureFolder.Items.Add(item.inventoryID, item); - - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = LLUUID.Random(); - item.assetID = new LLUUID("00000000-0000-0000-9999-000000000005"); - item.inventoryDescription = "Hardwood texture"; - item.inventoryName = "Hardwood"; - item.assetType = (int) AssetType.Texture; - item.invType = (int) InventoryType.Texture; - item.parentFolderID = m_textureFolder.folderID; - item.inventoryBasePermissions = 0x7FFFFFFF; - item.inventoryEveryOnePermissions = 0x7FFFFFFF; - item.inventoryCurrentPermissions = 0x7FFFFFFF; - item.inventoryNextPermissions = 0x7FFFFFFF; - m_textureFolder.Items.Add(item.inventoryID, item); - - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"); - item.assetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - item.inventoryDescription = "Default Shape"; - item.inventoryName = "Default Shape"; - item.assetType = (int) AssetType.Bodypart; - item.invType = (int) InventoryType.Wearable; - item.parentFolderID = folderID; - item.inventoryCurrentPermissions = 0; - item.inventoryNextPermissions = 0; - Items.Add(item.inventoryID, item); - - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"); - item.assetID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); - item.inventoryDescription = "Default Skin"; - item.inventoryName = "Default Skin"; - item.assetType = (int) AssetType.Bodypart; - item.invType = (int) InventoryType.Wearable; - item.parentFolderID = folderID; - item.inventoryCurrentPermissions = 0; - item.inventoryNextPermissions = 0; - Items.Add(item.inventoryID, item); - - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"); - item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111110"); - item.inventoryDescription = "Default Shirt"; - item.inventoryName = "Default Shirt"; - item.assetType = (int) AssetType.Clothing; - item.invType = (int) InventoryType.Wearable; - item.parentFolderID = folderID; - item.inventoryCurrentPermissions = 0; - item.inventoryNextPermissions = 0; - Items.Add(item.inventoryID, item); - - item = new InventoryItemBase(); - item.avatarID = libOwner; - item.creatorsID = libOwner; - item.inventoryID = new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"); - item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111120"); - item.inventoryDescription = "Default Pants"; - item.inventoryName = "Default Pants"; - item.assetType = (int) AssetType.Clothing; - item.invType = (int) InventoryType.Wearable; - item.parentFolderID = folderID; - item.inventoryCurrentPermissions = 0; - item.inventoryNextPermissions = 0; - Items.Add(item.inventoryID, item); + return item; } private void ReadItemsFromFile(IConfigSource source) @@ -232,10 +150,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = source.Configs[i].GetString("name", ""); item.assetType = source.Configs[i].GetInt("assetType", 0); item.invType = source.Configs[i].GetInt("inventoryType", 0); - item.inventoryCurrentPermissions = (uint) source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); - item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); - item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); - item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); + item.inventoryCurrentPermissions = (uint)source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); + item.inventoryNextPermissions = (uint)source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); + item.inventoryEveryOnePermissions = (uint)source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); + item.inventoryBasePermissions = (uint)source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); if (item.assetType == 0) { item.parentFolderID = m_textureFolder.folderID; diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs similarity index 98% rename from OpenSim/Framework/Communications/Cache/UserProfileCache.cs rename to OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 3c8ab512ea..b24d763ca1 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -30,7 +30,7 @@ using libsecondlife; namespace OpenSim.Framework.Communications.Cache { - public class UserProfileCache + public class UserProfileCacheService { // Fields private readonly CommunicationsManager m_parent; @@ -39,7 +39,7 @@ namespace OpenSim.Framework.Communications.Cache public LibraryRootFolder libraryRoot = new LibraryRootFolder(); // Methods - public UserProfileCache(CommunicationsManager parent) + public UserProfileCacheService(CommunicationsManager parent) { m_parent = parent; } diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index a7280aa6cb..d4ddeadfd9 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -64,9 +64,9 @@ namespace OpenSim.Framework.Communications get { return m_interRegion; } } - protected UserProfileCache m_userProfileCache; + protected UserProfileCacheService m_userProfileCache; - public UserProfileCache UserProfileCache + public UserProfileCacheService UserProfileCache { get { return m_userProfileCache; } } @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications { m_networkServersInfo = serversInfo; m_assetCache = assetCache; - m_userProfileCache = new UserProfileCache(this); + m_userProfileCache = new UserProfileCacheService(this); m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile); } diff --git a/OpenSim/Framework/Servers/RestObjectPoster.cs b/OpenSim/Framework/Servers/RestObjectPoster.cs index 07095f3793..9bcfcca87e 100644 --- a/OpenSim/Framework/Servers/RestObjectPoster.cs +++ b/OpenSim/Framework/Servers/RestObjectPoster.cs @@ -5,14 +5,10 @@ using System.Text; using System.Xml; using System.Xml.Serialization; - namespace OpenSim.Framework.Servers { - public delegate void ReturnResponse(T reponse); - public class RestObjectPoster { - public static void BeginPostObject(string requestUrl, TRequest obj) { Type type = typeof(TRequest); @@ -49,93 +45,4 @@ namespace OpenSim.Framework.Servers } } } - - public class RestObjectPosterResponse - { - public ReturnResponse ReturnResponseVal; - - public void BeginPostObject(string requestUrl, TRequest obj) - { - Type type = typeof(TRequest); - - WebRequest request = WebRequest.Create(requestUrl); - request.Method = "POST"; - request.ContentType = "text/xml"; - - MemoryStream buffer = new MemoryStream(); - - XmlWriterSettings settings = new XmlWriterSettings(); - settings.Encoding = Encoding.UTF8; - - using (XmlWriter writer = XmlWriter.Create(buffer, settings)) - { - XmlSerializer serializer = new XmlSerializer(type); - serializer.Serialize(writer, obj); - writer.Flush(); - } - - int length = (int)buffer.Length; - request.ContentLength = length; - - Stream requestStream = request.GetRequestStream(); - requestStream.Write(buffer.ToArray(), 0, length); - IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); - } - - private void AsyncCallback(IAsyncResult result) - { - WebRequest request = (WebRequest)result.AsyncState; - using (WebResponse resp = request.EndGetResponse(result)) - { - TResponse deserial; - XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); - deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); - - if (deserial != null && ReturnResponseVal != null) - { - ReturnResponseVal(deserial); - } - } - } - } - - public class SyncRestObjectPoster - { - - public static TResponse BeginPostObject(string requestUrl, TRequest obj) - { - Type type = typeof(TRequest); - - WebRequest request = WebRequest.Create(requestUrl); - request.Method = "POST"; - request.ContentType = "text/xml"; - - MemoryStream buffer = new MemoryStream(); - - XmlWriterSettings settings = new XmlWriterSettings(); - settings.Encoding = Encoding.UTF8; - - using (XmlWriter writer = XmlWriter.Create(buffer, settings)) - { - XmlSerializer serializer = new XmlSerializer(type); - serializer.Serialize(writer, obj); - writer.Flush(); - } - - int length = (int)buffer.Length; - request.ContentLength = length; - - Stream requestStream = request.GetRequestStream(); - requestStream.Write(buffer.ToArray(), 0, length); - TResponse deserial = default(TResponse); - using (WebResponse resp = request.GetResponse()) - { - - XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); - deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); - } - return deserial; - } - - } } \ No newline at end of file diff --git a/OpenSim/Framework/Servers/RestObjectPosterResponse.cs b/OpenSim/Framework/Servers/RestObjectPosterResponse.cs new file mode 100644 index 0000000000..eeae285a84 --- /dev/null +++ b/OpenSim/Framework/Servers/RestObjectPosterResponse.cs @@ -0,0 +1,60 @@ +using System; +using System.IO; +using System.Net; +using System.Text; +using System.Xml; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Servers +{ + public delegate void ReturnResponse(T reponse); + + public class RestObjectPosterResponse + { + public ReturnResponse ResponseCallback; + + public void BeginPostObject(string requestUrl, TRequest obj) + { + Type type = typeof(TRequest); + + WebRequest request = WebRequest.Create(requestUrl); + request.Method = "POST"; + request.ContentType = "text/xml"; + + MemoryStream buffer = new MemoryStream(); + + XmlWriterSettings settings = new XmlWriterSettings(); + settings.Encoding = Encoding.UTF8; + + using (XmlWriter writer = XmlWriter.Create(buffer, settings)) + { + XmlSerializer serializer = new XmlSerializer(type); + serializer.Serialize(writer, obj); + writer.Flush(); + } + + int length = (int)buffer.Length; + request.ContentLength = length; + + Stream requestStream = request.GetRequestStream(); + requestStream.Write(buffer.ToArray(), 0, length); + IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); + } + + private void AsyncCallback(IAsyncResult result) + { + WebRequest request = (WebRequest)result.AsyncState; + using (WebResponse resp = request.EndGetResponse(result)) + { + TResponse deserial; + XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); + deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); + + if (deserial != null && ResponseCallback != null) + { + ResponseCallback(deserial); + } + } + } + } +} diff --git a/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs b/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs new file mode 100644 index 0000000000..dde4c02662 --- /dev/null +++ b/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs @@ -0,0 +1,48 @@ +using System; +using System.IO; +using System.Net; +using System.Text; +using System.Xml; +using System.Xml.Serialization; + +namespace OpenSim.Framework.Servers +{ + public class SynchronousRestObjectPoster + { + public static TResponse BeginPostObject(string requestUrl, TRequest obj) + { + Type type = typeof(TRequest); + + WebRequest request = WebRequest.Create(requestUrl); + request.Method = "POST"; + request.ContentType = "text/xml"; + + MemoryStream buffer = new MemoryStream(); + + XmlWriterSettings settings = new XmlWriterSettings(); + settings.Encoding = Encoding.UTF8; + + using (XmlWriter writer = XmlWriter.Create(buffer, settings)) + { + XmlSerializer serializer = new XmlSerializer(type); + serializer.Serialize(writer, obj); + writer.Flush(); + } + + int length = (int)buffer.Length; + request.ContentLength = length; + + Stream requestStream = request.GetRequestStream(); + requestStream.Write(buffer.ToArray(), 0, length); + TResponse deserial = default(TResponse); + using (WebResponse resp = request.GetResponse()) + { + + XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); + deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); + } + return deserial; + } + + } +} diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index b00bb76f76..c03c4f058e 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -155,7 +155,7 @@ namespace OpenSim.Grid.UserServer // RestObjectPosterResponse> requester = new RestObjectPosterResponse>(); // requester.ReturnResponseVal = TestResponse; // requester.BeginPostObject(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); - List folders = SyncRestObjectPoster.BeginPostObject>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); + List folders = SynchronousRestObjectPoster.BeginPostObject>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); break; } } diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 1df4d9ad4d..13f8350a13 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -197,12 +197,12 @@ namespace OpenSim.Grid.UserServer protected override InventoryData CreateInventoryData(LLUUID userID) { - List folders = SyncRestObjectPoster.BeginPostObject>(m_config.InventoryUrl + "RootFolders/", userID); + List folders = SynchronousRestObjectPoster.BeginPostObject>(m_config.InventoryUrl + "RootFolders/", userID); if (folders ==null | folders.Count == 0) { RestObjectPoster.BeginPostObject(m_config.InventoryUrl + "CreateInventory/", userID); Thread.Sleep(1000); - folders = SyncRestObjectPoster.BeginPostObject>(m_config.InventoryUrl + "RootFolders/", userID); + folders = SynchronousRestObjectPoster.BeginPostObject>(m_config.InventoryUrl + "RootFolders/", userID); } if(folders.Count >0) diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs index 934a814aa5..612930d9bd 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs @@ -64,7 +64,7 @@ namespace OpenSim.Region.Communications.OGS1 try { RestObjectPosterResponse requester = new RestObjectPosterResponse(); - requester.ReturnResponseVal = InventoryResponse; + requester.ResponseCallback = InventoryResponse; requester.BeginPostObject(_inventoryServerUrl + "/GetInventory/", userID); } catch (Exception)