From cd9b2cef2a5945158740316a112e41fa75eaa2a6 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 30 Jul 2007 08:10:05 +0000 Subject: [PATCH] Changed the AssetManager.RequestUpload function signature to more closely resemble the RequestAsset function, and added an overload to simplify the call git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1336 52acb1d6-8a22-11de-b505-999d5b087335 --- SLImageUpload/frmSLImageUpload.cs | 8 +-- SLProxy/SLProxyLoader.cs | 4 +- importprimscript/importprimscript.cs | 2 +- libsecondlife/AppearanceManager.cs | 9 +-- libsecondlife/AssetManager.cs | 104 +++++++++++++-------------- 5 files changed, 60 insertions(+), 67 deletions(-) diff --git a/SLImageUpload/frmSLImageUpload.cs b/SLImageUpload/frmSLImageUpload.cs index f7e2ea5a..0a46a0a5 100644 --- a/SLImageUpload/frmSLImageUpload.cs +++ b/SLImageUpload/frmSLImageUpload.cs @@ -140,11 +140,9 @@ namespace SLImageUpload cmdUpload.Enabled = false; grpLogin.Enabled = false; - // Generate the Transaction ID and Asset ID - LLUUID transactionid = LLUUID.Random(); - txtAssetID.Text = transactionid.Combine(Client.Network.SecureSessionID).ToStringHyphenated(); - - Assets.RequestUpload(transactionid, AssetType.Texture, UploadData, false, false, true); + LLUUID assetID; + LLUUID transactionid = Assets.RequestUpload(out assetID, AssetType.Texture, UploadData, false, false, true); + txtAssetID.Text = assetID.ToStringHyphenated(); } } diff --git a/SLProxy/SLProxyLoader.cs b/SLProxy/SLProxyLoader.cs index 6e4260a1..ced46909 100644 --- a/SLProxy/SLProxyLoader.cs +++ b/SLProxy/SLProxyLoader.cs @@ -48,7 +48,7 @@ namespace SLProxy public ProxyFrame(string[] args) { - bool externalPlugin = false; + //bool externalPlugin = false; this.args = args; ProxyConfig proxyConfig = new ProxyConfig("SLProxy", "Austin Jennings / Andrew Ortman", args); @@ -75,7 +75,7 @@ namespace SLProxy Console.WriteLine("arg '" + sw + "' val '" + val + "'"); if (sw == "--load") { - externalPlugin = true; + //externalPlugin = true; LoadPlugin(val); } } diff --git a/importprimscript/importprimscript.cs b/importprimscript/importprimscript.cs index d78be734..03eccdec 100644 --- a/importprimscript/importprimscript.cs +++ b/importprimscript/importprimscript.cs @@ -186,7 +186,7 @@ namespace importprimscript } CurrentUpload = null; - Assets.RequestUpload(LLUUID.Random(), AssetType.Texture, jp2data, false, false, true); + LLUUID transactionID = Assets.RequestUpload(AssetType.Texture, jp2data, false, false, true); // The textures are small, 60 seconds should be plenty UploadEvent.WaitOne(1000 * 60, false); diff --git a/libsecondlife/AppearanceManager.cs b/libsecondlife/AppearanceManager.cs index 400d4320..1d6bda90 100644 --- a/libsecondlife/AppearanceManager.cs +++ b/libsecondlife/AppearanceManager.cs @@ -1435,15 +1435,12 @@ namespace libsecondlife private void UploadBake(Baker bake) { - // Create a transactionID and assetID for this upload - LLUUID transactionID = LLUUID.Random(); - LLUUID assetID = transactionID.Combine(Client.Network.SecureSessionID); + // Upload the completed layer data + LLUUID assetID; + LLUUID transactionID = Assets.RequestUpload(out assetID, AssetType.Texture, bake.EncodedBake, true, true, false); Client.DebugLog("Bake " + bake.BakeType.ToString() + " completed. Uploading asset " + assetID.ToStringHyphenated()); - // Upload the completed layer data - Assets.RequestUpload(transactionID, AssetType.Texture, bake.EncodedBake, true, true, false); - // Add it to a pending uploads list lock (PendingUploads) PendingUploads.Add(assetID, BakeTypeToAgentTextureIndex(bake.BakeType)); } diff --git a/libsecondlife/AssetManager.cs b/libsecondlife/AssetManager.cs index 36bdfc80..374a0456 100644 --- a/libsecondlife/AssetManager.cs +++ b/libsecondlife/AssetManager.cs @@ -398,78 +398,76 @@ namespace libsecondlife } } + public LLUUID RequestUpload(AssetType type, byte[] data, bool tempFile, bool storeLocal, + bool isPriority) + { + LLUUID assetID; + return RequestUpload(out assetID, type, data, tempFile, storeLocal, isPriority); + } + /// /// Initiate an asset upload /// - /// Usually a randomly generated UUID + /// The ID this asset will have if the + /// upload succeeds /// Asset type to upload this data as /// Raw asset data to upload /// Whether this is a temporary file or not /// Whether to store this asset on the local /// simulator or the grid-wide asset server /// Give this upload a higher priority - /// The asset ID the new file will have once the upload is - /// complete - public LLUUID RequestUpload(LLUUID transactionID, AssetType type, byte[] data, bool tempFile, bool storeLocal, + /// The transaction ID of this transfer + public LLUUID RequestUpload(out LLUUID assetID, AssetType type, byte[] data, bool tempFile, bool storeLocal, bool isPriority) { - if (!Transfers.ContainsKey(transactionID)) + AssetUpload upload = new AssetUpload(); + upload.AssetData = data; + upload.AssetType = type; + upload.ID = LLUUID.Random(); + assetID = upload.ID.Combine(Client.Network.SecureSessionID); + upload.AssetID = assetID; + upload.Size = data.Length; + upload.XferID = 0; + + // Build and send the upload packet + AssetUploadRequestPacket request = new AssetUploadRequestPacket(); + request.AssetBlock.StoreLocal = storeLocal; + request.AssetBlock.Tempfile = tempFile; + request.AssetBlock.TransactionID = upload.ID; + request.AssetBlock.Type = (sbyte)type; + + if (data.Length + 100 < Settings.MAX_PACKET_SIZE) { - AssetUpload upload = new AssetUpload(); - upload.AssetData = data; - upload.AssetType = type; - upload.ID = transactionID; - upload.AssetID = ((transactionID == LLUUID.Zero) ? transactionID : transactionID.Combine(Client.Network.SecureSessionID)); - upload.Size = data.Length; - upload.XferID = 0; + Client.Log( + String.Format("Beginning asset upload [Single Packet], ID: {0}, AssetID: {1}, Size: {2}", + upload.ID.ToStringHyphenated(), upload.AssetID.ToStringHyphenated(), upload.Size), + Helpers.LogLevel.Info); - // Build and send the upload packet - AssetUploadRequestPacket request = new AssetUploadRequestPacket(); - request.AssetBlock.StoreLocal = storeLocal; - request.AssetBlock.Tempfile = tempFile; - request.AssetBlock.TransactionID = upload.ID; - request.AssetBlock.Type = (sbyte)type; - - if (data.Length + 100 < Settings.MAX_PACKET_SIZE) - { - Client.Log( - String.Format("Beginning asset upload [Single Packet], ID: {0}, AssetID: {1}, Size: {2}", - upload.ID.ToStringHyphenated(), upload.AssetID.ToStringHyphenated(), upload.Size), - Helpers.LogLevel.Info); - - // The whole asset will fit in this packet, makes things easy - request.AssetBlock.AssetData = data; - upload.Transferred = data.Length; - } - else - { - Client.Log( - String.Format("Beginning asset upload [Multiple Packets], ID: {0}, AssetID: {1}, Size: {2}", - upload.ID.ToStringHyphenated(), upload.AssetID.ToStringHyphenated(), upload.Size), - Helpers.LogLevel.Info); - - // Asset is too big, send in multiple packets - request.AssetBlock.AssetData = new byte[0]; - } - - //Client.DebugLog(request.ToString()); - - // Add this upload to the Transfers dictionary using the assetID as the key. - // Once the simulator assigns an actual identifier for this upload it will be - // removed from Transfers and reinserted with the proper identifier - lock (Transfers) Transfers[upload.AssetID] = upload; - - Client.Network.SendPacket(request); - - return upload.AssetID; + // The whole asset will fit in this packet, makes things easy + request.AssetBlock.AssetData = data; + upload.Transferred = data.Length; } else { - Client.Log("RequestUpload() called for an asset we are already uploading, ignoring", + Client.Log( + String.Format("Beginning asset upload [Multiple Packets], ID: {0}, AssetID: {1}, Size: {2}", + upload.ID.ToStringHyphenated(), upload.AssetID.ToStringHyphenated(), upload.Size), Helpers.LogLevel.Info); - return LLUUID.Zero; + // Asset is too big, send in multiple packets + request.AssetBlock.AssetData = new byte[0]; } + + //Client.DebugLog(request.ToString()); + + // Add this upload to the Transfers dictionary using the assetID as the key. + // Once the simulator assigns an actual identifier for this upload it will be + // removed from Transfers and reinserted with the proper identifier + lock (Transfers) Transfers[upload.AssetID] = upload; + + Client.Network.SendPacket(request); + + return upload.ID; } private void SendNextUploadPacket(AssetUpload upload)