Exemplo n.º 1
0
        public void Asset_Received(AssetDownload trans, Asset asset)
        {
            var  Running = ExportCommand.Exporting;
            var  item    = SourceItem;
            UUID itemID  = item.UUID;

            //if (trans.AssetID != item.AssetUUID) return;
            if (!trans.Success)
            {
                Error = "" + trans.Status;
                if (waiting != null)
                {
                    waiting.Set();
                }
                lock (Running.TaskAssetWaiting)
                {
                    ExportTaskAsset exportTaskAsset;
                    if (!Running.CompletedTaskItem.Contains(itemID))
                    {
                        Request();
                        return;
                    }
                }
            }
            Running.Assets_OnReceived(trans, asset);
            //AddRelated(item.AssetUUID, item.AssetType);
            Running.TaskItemComplete(O.ID, itemID, asset.AssetID, asset.AssetType);
            if (waiting != null)
            {
                waiting.Set();
            }
        }
Exemplo n.º 2
0
 public void Assets_OnReceived(AssetDownload transfer, Asset asset)
 {
     if (!IsExporting)
     {
         return;
     }
     if (transfer.Success)
     {
         AssetComplete(asset.AssetID);
         string sfile = SimAsset.CFileName(asset.AssetID, asset.AssetType);
         try
         {
             var data = asset.AssetData;
             if (data != null && data.Length > 1)
             {
                 lock (fileWriterLock)
                     File.WriteAllBytes(assetDumpDir + Path.GetFileName(sfile), asset.AssetData);
                 return;
             }
         }
         catch (Exception ex)
         {
             Logger.Log(ex.Message, Helpers.LogLevel.Error);
         }
     }
 }
Exemplo n.º 3
0
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                {
                    BeginInvoke(new MethodInvoker(() => Assets_OnAssetReceived(transfer, asset)));
                }
                return;
            }

            if (!transfer.Success || asset.AssetType != AssetType.LSLText)
            {
                lblScripStatus.Text = rtb.Text = "Failed to download.";
                return;
            }
            else
            {
                lblScripStatus.Text = rtb.Text = "OK";
            }

            asset.Decode();
            rtb.Text = ((AssetScriptText)asset).Source;
            lineNubersForRtb.Invalidate();
            SetTitle();
        }
Exemplo n.º 4
0
 public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset)
 {
     if (wear == "save")
     {
         SaveAsset((AssetWearable)asset);
     }
 }
Exemplo n.º 5
0
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate() { Assets_OnAssetReceived(transfer, asset); }));
                return;
            }

            if (!transfer.Success)
            {
                tlblStatus.Text = "Download failed";
                return;
            }

            tlblStatus.Text  = "OK";
            tbtnPlay.Enabled = true;

            gestureAsset = (AssetGesture)asset;
            if (gestureAsset.Decode())
            {
                for (int i = 0; i < gestureAsset.Sequence.Count; i++)
                {
                    rtbInfo.AppendText(gestureAsset.Sequence[i].ToString().Trim() + Environment.NewLine);
                }
            }
        }
Exemplo n.º 6
0
        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);
                }
            }
        }
Exemplo n.º 7
0
        //Separate thread
        private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate()
                {
                    Assets_OnAssetReceived(transfer, asset);
                }
                                              ));

                return;
            }

            //if (transfer.AssetType != AssetType.Notecard) return;

            if (!transfer.Success)
            {
                notecardContent = "Unable to download notecard.";
                SetNotecardText(notecardContent, false);
                return;
            }

            receivedAsset   = (AssetNotecard)asset;
            notecardContent = Utils.BytesToString(transfer.AssetData);

            SetNotecardText(notecardContent, false);
        }
Exemplo n.º 8
0
        public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset)
        {
            lock (Manager.AssetsReceived)
                Manager.AssetsReceived[asset.AssetID] = true;

//            if (wear == "save")
//            {
//                SaveAsset((AssetWearable) asset);
//            }
        }
Exemplo n.º 9
0
 void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
 {
     if (transfer.Success && asset.AssetType == AssetType.Landmark)
     {
         decodedLandmark = (AssetLandmark)asset;
         decodedLandmark.Decode();
         localPosition = decodedLandmark.Position;
         client.Grid.RequestRegionHandle(decodedLandmark.RegionID);
     }
 }
Exemplo n.º 10
0
        public void SetAsset(AssetDownload download)
        {
            bool xferFailed = !download.Success;

            PullServerAsset = xferFailed;
            NeedsRequest    = xferFailed;
            if (download.Success)
            {
                AssetType = download.AssetType;
                AssetData = download.AssetData;
                AssetID   = UUIDNonZero(AssetID, download.AssetID, download.ID);
            }
        }
Exemplo n.º 11
0
        private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            AssetTransferAction action;

            if (this.AssetTransfers.TryGetValue(transfer.ID, out action))
            {
                if (asset != null)
                {
                    action(asset);
                }
                else
                {
                    Console.WriteLine("Asset transfer failed: {0}", transfer.Status);
                }
                this.AssetTransfers.Remove(transfer.ID);
            }
        }
Exemplo n.º 12
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 });
        }
Exemplo n.º 13
0
        private void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (transfer.AssetID == AssetID)
            {
                if (transfer.Success)
                {
                    try
                    {
                        File.WriteAllBytes(String.Format("{0}.{1}", AssetID,
                                                         assetType.ToString().ToLower()), asset.AssetData);
                        Success = true;
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(ex.Message, Helpers.LogLevel.Error, ex);
                    }
                }

                DownloadHandle.Set();
            }
        }
Exemplo n.º 14
0
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(() => Assets_OnAssetReceived(transfer, asset)));
                return;
            }

            if (transfer.Success)
            {
                Logger.Log("Animation " + anim + " download success " + asset.AssetData.Length + " bytes.", Helpers.LogLevel.Debug);
                pnlSave.Visible = true;
                animData        = asset.AssetData;
            }
            else
            {
                Logger.Log("Animation " + anim + " download failed.", Helpers.LogLevel.Debug);
                Visible = false;
                Dispose();
            }
        }
            public void OnDownloaded(AssetDownload transfer, Asset asset)
            {
                if (transfer.AssetID != NewID)
                {
                    return;
                }
                if (assetType == AssetType.Texture && !asset.Decode())
                {
                    Difference(asset.AssetData, AssetData);
                    asset.AssetData = AssetData;
                    if (false)
                    {
                        Inventory.RemoveItem(NewItemID);
                        NewItemID = UUID.Zero;
                        NewID     = UUID.Zero;
                        UploadAssetData(false);

                        /*Inventory.RequestCreateItemFromAsset(AssetData, "" + OldID, ProgressString,
                         *                                   assetType, inventoryType,
                         *                                   GetAssetUploadsFolder(),
                         *                                   Permissions.FullPermissions,
                         *                                   InvItemCreated);*/
                        //UpdateAsset(AssetData);
                        return;
                    }
                }
                if (!transfer.Success)
                {
                    Importing.Error(ExportCommand.Exporting.LocalFailure, "bad transfer on " + this);
                }
                else
                {
                    WriteProgress();
                }
                _NewItem = asset;
                NewUUID2OBJECT[NewID] = this;
                UUID2OBJECT[OldID]    = this;
                AssetUploaded.Set();
            }
Exemplo n.º 16
0
        void Assets_OnNotecardReceived(AssetDownload transfer, Asset asset)
        {
            if (transfer.Success)
            {
                AssetNotecard n = (AssetNotecard)asset;
                n.Decode();
                AssetNotecard recievedNotecard = n;

                text = string.Empty;

                for (int i = 0; i < n.BodyText.Length; i++)
                {
                    char c = n.BodyText[i];

                    // Special marker for embedded things.
                    if ((int)c == 0xdbc0)
                    {
                        int           index = (int)n.BodyText[++i] - 0xdc00;
                        InventoryItem e     = n.EmbeddedItems[index];
                        text += " (embedded) ";
                    }
                    else
                    {
                        text += c;
                    }
                }

                // TODO put in controls to stop, back up etc
                StopPosition = 0;
                NextSection();
                control.instance.MainForm.KeyDown +=
                    new System.Windows.Forms.KeyEventHandler(MainForm_KeyPress);
            }
            else
            {
                Talker.Say("Failed to download the notecard.", Talk.BeepType.Bad);
            }
        }
Exemplo n.º 17
0
 public void SetAsset(AssetDownload download, Asset asset)
 {
     SetAsset(download);
     SetAsset(asset);
 }
Exemplo n.º 18
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 { }
        }
Exemplo n.º 19
0
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                {
                    BeginInvoke(new MethodInvoker(() => Assets_OnAssetReceived(transfer, asset)));
                }
                return;
            }

            if (transfer.Success)
            {
                AssetNotecard n = (AssetNotecard)asset;
                n.Decode();
                receivedNotecard = n;

                string noteText = string.Empty;
                rtbContent.Clear();

                for (int i = 0; i < n.BodyText.Length; i++)
                {
                    char c = n.BodyText[i];

                    if ((int)c == 0xdbc0)
                    {
                        int           index = (int)n.BodyText[++i] - 0xdc00;
                        InventoryItem e     = n.EmbeddedItems[index];
                        rtbContent.AppendText(noteText);
                        rtbContent.InsertLink(e.Name, string.Format("radegast://embeddedasset/{0}", index));
                        noteText = string.Empty;
                    }
                    else
                    {
                        noteText += c;
                    }
                }

                rtbContent.Text += noteText;

                if (n.EmbeddedItems != null && n.EmbeddedItems.Count > 0)
                {
                    tbtnAttachments.Enabled = true;
                    tbtnAttachments.Visible = true;
                    foreach (InventoryItem item in n.EmbeddedItems)
                    {
                        int ix = InventoryConsole.GetItemImageIndex(item.AssetType.ToString().ToLower());
                        ToolStripMenuItem titem = new ToolStripMenuItem(item.Name);

                        if (ix != -1)
                        {
                            titem.Image        = frmMain.ResourceImages.Images[ix];
                            titem.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                        }
                        else
                        {
                            titem.DisplayStyle = ToolStripItemDisplayStyle.Text;
                        }

                        titem.Name   = item.UUID.ToString();
                        titem.Tag    = item;
                        titem.Click += new EventHandler(attachmentMenuItem_Click);

                        var saveToInv = new ToolStripMenuItem("Save to inventory");
                        saveToInv.Click += (xsender, xe) =>
                        {
                            client.Inventory.RequestCopyItemFromNotecard(UUID.Zero,
                                                                         notecard.UUID,
                                                                         client.Inventory.FindFolderForType(item.AssetType),
                                                                         item.UUID,
                                                                         Inventory_OnInventoryItemCopied);
                        };

                        titem.DropDownItems.Add(saveToInv);
                        tbtnAttachments.DropDownItems.Add(titem);
                    }
                }
                UpdateStatus("OK");
                rtbContent.Focus();
            }
            else
            {
                UpdateStatus("Failed");
                rtbContent.Text = "Failed to download notecard. " + transfer.Status;
            }
        }
Exemplo n.º 20
0
        public override void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            bool xfrFailed    = !transfer.Success;
            bool decodeFailed = false;

            if (transfer.Success)
            {
                try
                {
                    try
                    {
                        bool tf = asset.Decode();
                        decodeFailed = !tf;
                        if (decodeFailed)
                        {
                            Debug("Asset decoded " + tf + " as " + asset.AssetType);
                        }
                    }
                    catch (Exception ex)
                    {
                        decodeFailed = true;
                        Debug("Asset not decoded: " + ex);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message, Helpers.LogLevel.Error, ex);
                }
            }

            if (asset == null)
            {
                lock (AssetRequestType)
                    if (AssetRequestType.ContainsKey(transfer.AssetID))
                    {
                        Debug("Failed transfer for " + AssetRequestType[transfer.AssetID] +
                              " " + transfer.ID + " ");
                    }
                    else
                    {
                        Debug("Unknown transfer Failed for " + transfer.AssetType + " " + transfer.ID + " ");
                    }
                return;
            }
            lock (AssetRequestType)
            {
                EnsureCached(asset, asset.AssetID);
                if (AssetRequestType.ContainsKey(asset.AssetID))
                {
                    AssetType assetRequestType = AssetRequestType[transfer.AssetID];
                    if (assetRequestType == asset.AssetType)
                    {
                        if (false)
                        {
                            Debug("Transfer succeeded for " + assetRequestType + " " + transfer.AssetID + " ");
                        }
                    }
                    else
                    {
                        Debug("Transfer succeeded weirdly as " + asset.AssetType + " for " + assetRequestType +
                              " " + transfer.AssetID + " ");
                    }
                }
                else
                {
                    Debug("Unknown transfer succeeded for " + asset.AssetType + " " + transfer.ID + " ");
                }
                OnAssetDownloaded(asset.AssetID, asset);
            }
        }
Exemplo n.º 21
0
        /**
         * Handle arrival of a sound resource.
         */
        void Assets_OnSoundReceived(AssetDownload transfer, Asset asset)
        {
            if (transfer.Success)
            {
                // If this was a Prefetch, just stop here.
                if (prefetchOnly)
                {
                    return;
                }

                //                Logger.Log("Opening sound " + Id.ToString(), Helpers.LogLevel.Debug);

                // Decode the Ogg Vorbis buffer.
                if (!(asset is AssetSound s))
                {
                    return;
                }

                s.Decode();
                var data = s.AssetData;

                // Describe the data to FMOD
                extraInfo.length = (uint)data.Length;
                extraInfo.cbsize = Marshal.SizeOf(extraInfo);

                invoke(delegate
                {
                    try
                    {
                        // Create an FMOD sound of this Ogg data.
                        FMODExec(system.createSound(
                                     data,
                                     mode,
                                     ref extraInfo,
                                     out sound));

                        // Register for callbacks.
                        RegisterSound(sound);


                        // If looping is requested, loop the entire thing.
                        if (loopSound)
                        {
                            uint soundlen = 0;
                            FMODExec(sound.getLength(out soundlen, TIMEUNIT.PCM));
                            FMODExec(sound.setLoopPoints(0, TIMEUNIT.PCM, soundlen - 1, TIMEUNIT.PCM));
                            FMODExec(sound.setLoopCount(-1));
                        }

                        // Allocate a channel and set initial volume.  Initially paused.
                        ChannelGroup masterChannelGroup;
                        system.getMasterChannelGroup(out masterChannelGroup);
                        FMODExec(system.playSound(sound, masterChannelGroup, true, out channel));
#if TRACE_SOUND
                        Logger.Log(
                            String.Format("Channel {0} for {1} assigned to {2}",
                                          channel.getRaw().ToString("X"),
                                          sound.getRaw().ToString("X"),
                                          Id),
                            Helpers.LogLevel.Debug);
#endif
                        RegisterChannel(channel);

                        FMODExec(channel.setVolume(volumeSetting * AllObjectVolume));

                        // Take note of when the sound is finished playing.
                        FMODExec(channel.setCallback(endCallback));

                        // Set attenuation limits.
                        FMODExec(sound.set3DMinMaxDistance(
                                     1.2f,     // Any closer than this gets no louder
                                     100.0f)); // Further than this gets no softer.

                        // Set the sound point of origin.  This is in SIM coordinates.
                        FMODExec(channel.set3DAttributes(ref position, ref ZeroVector));

                        // Turn off pause mode.  The sound will start playing now.
                        FMODExec(channel.setPaused(false));
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Error playing sound: ", Helpers.LogLevel.Error, ex);
                    }
                });
            }
            else
            {
                Logger.Log("Failed to download sound: " + transfer.Status,
                           Helpers.LogLevel.Error);
            }
        }