/// <summary>
        /// Request an asset download
        /// </summary>
        /// <param name="assetID">Asset UUID</param>
        /// <param name="type">Asset type, must be correct for the transfer to succeed</param>
        /// <param name="priority">Whether to give this transfer an elevated priority</param>
        /// <returns>The transaction ID generated for this transfer</returns>
        public LLUUID RequestAsset(LLUUID assetID, AssetType type, bool priority)
        {
            AssetDownload transfer = new AssetDownload();

            transfer.ID      = LLUUID.Random();
            transfer.AssetID = assetID;
            //transfer.AssetType = type; // Set in TransferInfoHandler.
            transfer.Priority  = 100.0f + (priority ? 1.0f : 0.0f);
            transfer.Channel   = ChannelType.Asset;
            transfer.Source    = SourceType.Asset;
            transfer.Simulator = Client.Network.CurrentSim;

            // Add this transfer to the dictionary
            lock (Transfers) Transfers[transfer.ID] = transfer;

            // Build the request packet and send it
            TransferRequestPacket request = new TransferRequestPacket();

            request.TransferInfo.ChannelType = (int)transfer.Channel;
            request.TransferInfo.Priority    = transfer.Priority;
            request.TransferInfo.SourceType  = (int)transfer.Source;
            request.TransferInfo.TransferID  = transfer.ID;

            byte[] paramField = new byte[20];
            Array.Copy(assetID.GetBytes(), 0, paramField, 0, 16);
            Array.Copy(Helpers.IntToBytes((int)type), 0, paramField, 16, 4);
            request.TransferInfo.Params = paramField;

            Client.Network.SendPacket(request, transfer.Simulator);
            return(transfer.ID);
        }
        private Asset WrapAsset(AssetDownload download)
        {
            Asset asset = CreateAssetWrapper(download.AssetType);

            asset.AssetID   = download.AssetID;
            asset.AssetData = download.AssetData;
            return(asset);
        }
Exemple #3
0
        //Separate thread
        private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (transfer.ID != transferID) return;

            string notecardContent;

            if (!transfer.Success)
            {
                notecardContent = "Unable to download item. You may not have the correct permissions.";
                BeginInvoke(new OnSetNotecardText(SetNotecardText), new object[] { notecardContent, true });
                return;
            }

            notecardContent = Helpers.FieldToUTF8String(transfer.AssetData);
            BeginInvoke(new OnSetNotecardText(SetNotecardText), new object[] { notecardContent, false });
        }
Exemple #4
0
        //Separate thread
        private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (transfer.ID != transferID) return;

            string scriptContent;

            if (!transfer.Success)
            {
                scriptContent = "Unable to download script. Make sure you have the proper permissions!";
                BeginInvoke(new OnSetScriptText(SetScriptText), new object[] { scriptContent, true });
                return;
            }

            receivedAsset = (AssetScriptText)asset;
            scriptContent = Helpers.FieldToUTF8String(transfer.AssetData);
            BeginInvoke(new OnSetScriptText(SetScriptText), new object[] { scriptContent, false });
        }
Exemple #5
0
 private Asset WrapAsset(AssetDownload download)
 {
     Asset asset = CreateAssetWrapper(download.AssetType);
     asset.AssetID = download.AssetID;
     asset.AssetData = download.AssetData;
     return asset;
 }
Exemple #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="assetID">Use LLUUID.Zero if you do not have the 
        /// asset ID but have all the necessary permissions</param>
        /// <param name="itemID">The item ID of this asset in the inventory</param>
        /// <param name="taskID">Use LLUUID.Zero if you are not requesting an 
        /// asset from an object inventory</param>
        /// <param name="ownerID">The owner of this asset</param>
        /// <param name="type">Asset type</param>
        /// <param name="priority">Whether to prioritize this asset download or not</param>
        public LLUUID RequestInventoryAsset(LLUUID assetID, LLUUID itemID, LLUUID taskID, LLUUID ownerID, AssetType type, bool priority)
        {
            AssetDownload transfer = new AssetDownload();
            transfer.ID = LLUUID.Random();
            transfer.AssetID = assetID;
            //transfer.AssetType = type; // Set in TransferInfoHandler.
            transfer.Priority = 100.0f + (priority ? 1.0f : 0.0f);
            transfer.Channel = ChannelType.Asset;
            transfer.Source = SourceType.SimInventoryItem;
            transfer.Simulator = Client.Network.CurrentSim;

            // Add this transfer to the dictionary
            lock (Transfers) Transfers[transfer.ID] = transfer;

            // Build the request packet and send it
            TransferRequestPacket request = new TransferRequestPacket();
            request.TransferInfo.ChannelType = (int)transfer.Channel;
            request.TransferInfo.Priority = transfer.Priority;
            request.TransferInfo.SourceType = (int)transfer.Source;
            request.TransferInfo.TransferID = transfer.ID;

            byte[] paramField = new byte[100];
            Buffer.BlockCopy(Client.Self.AgentID.GetBytes(), 0, paramField, 0, 16);
            Buffer.BlockCopy(Client.Self.SessionID.GetBytes(), 0, paramField, 16, 16);
            Buffer.BlockCopy(ownerID.GetBytes(), 0, paramField, 32, 16);
            Buffer.BlockCopy(taskID.GetBytes(), 0, paramField, 48, 16);
            Buffer.BlockCopy(itemID.GetBytes(), 0, paramField, 64, 16);
            Buffer.BlockCopy(assetID.GetBytes(), 0, paramField, 80, 16);
            Buffer.BlockCopy(Helpers.IntToBytes((int)type), 0, paramField, 96, 4);
            request.TransferInfo.Params = paramField;

            Client.Network.SendPacket(request, transfer.Simulator);
            return transfer.ID;
        }
        private void Assets_OnAssetReceived(AssetDownload asset, Asset blah)
        {
            lock (CurrentDownloads)
            {
                // see if we have this in our transfer list
                QueuedDownloadInfo r = CurrentDownloads.Find(delegate(QueuedDownloadInfo q)
                {
                    return q.TransferID == asset.ID;
                });

                if (r != null && r.TransferID == asset.ID)
                {
                    if (asset.Success)
                    {
                        // create the directory to put this in
                        Directory.CreateDirectory(Path.GetDirectoryName(r.FileName));

                        // write out the file
                        File.WriteAllBytes(r.FileName, asset.AssetData);
                        Logger.DebugLog(Name + " Wrote: " + r.FileName, Client);
                        TextItemsTransferred++;
                    }
                    else
                    {
                        TextItemErrors++;
                        Console.WriteLine("{0}: Download of asset {1} ({2}) failed with status {3}", Name, r.FileName, 
                            r.AssetID.ToString(), asset.Status.ToString());
                    }

                    // remove the entry
                    CurrentDownloads.Remove(r);
                }
            }
        }
Exemple #8
0
        //Separate thread
        private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (transfer.ID != transferID)
            {
                Console.WriteLine("[SLMIV]: Assets_OnAssetReceived=transfer:" + transfer.AssetID.ToStringHyphenated() + " != transferID:" + transferID.ToString());//Debug
                return;
            }

            if (!transfer.Success)
            {
                notecardContent = "Unable to download item. You may not have the correct permissions.";
                client.Log("[SLMIV] Unable to download AssetID: " + transferID.ToString() + " You may not have the correct permissions.", Helpers.LogLevel.Info);
                return;
            }
            else
            {
                notecardContent = Helpers.FieldToUTF8String(transfer.AssetData);
                //client.Log("[SLMIV] Received AssetID: " + transfer.AssetID.UUID.ToString(), Helpers.LogLevel.Info);//NO:asset.AssetID.UUID.ToString(),asset.AssetID.ToStringHyphenated()NO:transfer.ID.ToStringHyphenated(), NO:transferID.ToString()
                Console.WriteLine("[SLMIV]: Received AssetID: " + transfer.AssetID.UUID.ToString());//Debug
            }
        }
        private void Assets_OnAssetReceived(AssetDownload download, Asset asset)
        {
            lock (Wearables.Dictionary)
            {
                // Check if this is a wearable we were waiting on
                foreach (KeyValuePair<WearableType,WearableData> kvp in Wearables.Dictionary)
                {
                    if (kvp.Value.Item.AssetUUID == download.AssetID)
                    {
                        // Make sure the download succeeded
                        if (download.Success)
                        {
                            kvp.Value.Asset = (AssetWearable)asset;

                            Client.DebugLog("Downloaded wearable asset " + kvp.Value.Asset.Name);

                            if (!kvp.Value.Asset.Decode())
                            {
                                Client.Log("Failed to decode asset:" + Environment.NewLine +
                                    Helpers.FieldToUTF8String(asset.AssetData), Helpers.LogLevel.Error);
                            }

                            lock (AgentTextures)
                            {
                                foreach (KeyValuePair<AppearanceManager.TextureIndex, LLUUID> texture in kvp.Value.Asset.Textures)
                                {
                                    if (texture.Value != DEFAULT_AVATAR_TEXTURE) // this texture is not meant to be displayed
                                    {
                                        Client.DebugLog("Setting " + texture.Key + " to " + texture.Value);
                                        AgentTextures[(int)texture.Key] = texture.Value;
                                    }
                                }
                            }
                        }
                        else
                        {
                            Client.Log("Wearable " + kvp.Key + "(" + download.AssetID.ToString() + ") failed to download, " + download.Status.ToString(),Helpers.LogLevel.Warning);
                        }

                        break;
                    }
                }
            }

            if (AssetDownloads.Count > 0)
            {
                // Dowload the next wearable in line
                PendingAssetDownload pad = AssetDownloads.Dequeue();
                Assets.RequestAsset(pad.Id, pad.Type, true);
            }
            else
            {
                // Everything is downloaded
                WearablesDownloadedEvent.Set();
            }
        }
Exemple #10
0
 public void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
 {
     if (asset == null && transfer != null)
     {
         Hashtable hash = new Hashtable();
         hash.Add("MessageType", "AssetReceived");
         hash.Add("Success", false);
         if (transfer != null)
         {
             hash.Add("TransferID", transfer.ID);
             hash.Add("AssetID", transfer.AssetID);
             hash.Add("Error", transfer.Status.ToString());
             hash.Add("AssetType", transfer.AssetType);
         }
         enqueue(hash);
         return;
     }
     if (transfer == null)
     {
         Hashtable hash = new Hashtable();
         hash.Add("MessageType", "NullTransfer");
         enqueue(hash);
         return;
     }
     try
     {
         Hashtable hash = new Hashtable();
         hash.Add("MessageType", "AssetReceived");
         hash.Add("Success", transfer.Success);
         if (!transfer.Success)
         {
             hash.Add("AssetData", "Could not download asset: " + transfer.Status.ToString());
         }
         else
         {
             switch (asset.AssetType)
             {
                 case AssetType.Notecard:
                 case AssetType.LSLText:
                     hash.Add("AssetData", Helpers.FieldToUTF8String(asset.AssetData));
                     break;
                 case AssetType.Bodypart:
                     {
                         AssetBodypart part = (AssetBodypart)asset;
                         hash.Add("Creator", part.Creator);
                         hash.Add("Description", part.Description);
                         hash.Add("Textures", part.Textures);
                         hash.Add("Params", part.Params);
                         hash.Add("Permissions", part.Permissions);
                         hash.Add("Owner", part.Owner);
                     }
                     break;
             }
         }
         hash.Add("AssetType", transfer.AssetType);
         hash.Add("AssetID", transfer.AssetID);
         hash.Add("TransferID", transfer.ID);
         enqueue(hash);
     }
     catch { }
 }
Exemple #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="assetID"></param>
        /// <param name="type"></param>
        /// <param name="priority"></param>
        public void RequestAsset(LLUUID assetID, AssetType type, bool priority)
        {
            AssetDownload transfer = new AssetDownload();
            transfer.ID = LLUUID.Random();
            transfer.AssetID = assetID;
            transfer.Priority = 100.0f + (priority ? 1.0f : 0.0f);
            transfer.Channel = ChannelType.Asset;
            transfer.Source = SourceType.Asset;
            transfer.Simulator = Client.Network.CurrentSim;

            // Add this transfer to the dictionary
            lock (Transfers) Transfers[transfer.ID] = transfer;

            // Build the request packet and send it
            TransferRequestPacket request = new TransferRequestPacket();
            request.TransferInfo.ChannelType = (int)transfer.Channel;
            request.TransferInfo.Priority = transfer.Priority;
            request.TransferInfo.SourceType = (int)transfer.Source;
            request.TransferInfo.TransferID = transfer.ID;

            byte[] paramField = new byte[20];
            Array.Copy(assetID.GetBytes(), 0, paramField, 0, 16);
            Array.Copy(Helpers.IntToBytes((int)type), 0, paramField, 16, 4);
            request.TransferInfo.Params = paramField;

            Client.Network.SendPacket(request, transfer.Simulator);
        }