Exemplo n.º 1
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            bool success = false;

            // Register a handler for the appearance event
            AutoResetEvent appearanceEvent = new AutoResetEvent(false);

            AppearanceManager.AppearanceUpdatedCallback callback =
                delegate(LLObject.TextureEntry te) { appearanceEvent.Set(); };
            Client.Appearance.OnAppearanceUpdated += callback;

            // Start the appearance setting process (with baking enabled or disabled)
            Client.Appearance.SetPreviousAppearance(!(args.Length > 0 && args[0].Equals("nobake")));

            // Wait for the process to complete or time out
            if (appearanceEvent.WaitOne(1000 * 120, false))
            {
                success = true;
            }

            // Unregister the handler
            Client.Appearance.OnAppearanceUpdated -= callback;

            // Return success or failure message
            if (success)
            {
                return("Successfully set appearance");
            }
            else
            {
                return("Timed out while setting appearance");
            }
        }
 public DownloadRequest_Folder(LLUUID folderID, bool fetchFolders, bool fetchItems)
 {
     FolderID = folderID;
         FetchFolders = fetchFolders;
         FetchItems = fetchItems;
         LastReceivedAtTick = Environment.TickCount;
 }
Exemplo n.º 3
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            string name = Client.ToString();

            TestClient.ClientManager.Logout(TestClient);
            return("Logged " + name + " out");
        }
Exemplo n.º 4
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            LLUUID target;

            if (args.Length != 1)
            {
                return("Usage: touch UUID");
            }

            if (LLUUID.TryParse(args[0], out target))
            {
                Primitive targetPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
                    delegate(Primitive prim)
                {
                    return(prim.ID == target);
                }
                    );

                if (targetPrim != null)
                {
                    Client.Self.Touch(targetPrim.LocalID);
                    return("Touched prim " + targetPrim.LocalID);
                }
            }

            return("Couldn't find a prim to touch with UUID " + args[0]);
        }
Exemplo n.º 5
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            string target = String.Empty;

            for (int ct = 0; ct < args.Length; ct++)
            {
                target = target + args[ct] + " ";
            }
            target = target.TrimEnd();

            if (target.Length == 0)
            {
                target = TestClient.Master;
            }

            if (target.Length > 0)
            {
                if (Follow(target))
                {
                    return("Following " + target);
                }
                else
                {
                    return("Unable to follow " + target + ".  Client may not be able to see that avatar.");
                }
            }
            else
            {
                return("No target specified and no master is set. usage: follow [FirstName LastName])");
            }
        }
Exemplo n.º 6
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
                return "Usage: searchevents [search text]";

            string searchText = string.Empty;
            for (int i = 0; i < args.Length; i++)
                searchText += args[i] + " ";
            searchText = searchText.TrimEnd();
            waitQuery.Reset();

            Client.Directory.OnEventsReply += new DirectoryManager.EventReplyCallback(Directory_OnEventsReply);
            Client.Directory.StartEventsSearch(searchText, true, "u", 0, DirectoryManager.EventCategories.All, LLUUID.Random());
            string result;
            if (waitQuery.WaitOne(20000, false) && Client.Network.Connected)
            {
                result =  "Your query '" + searchText + "' matched " + resultCount + " Events. ";
            }
            else
            {
                result =  "Timeout waiting for simulator to respond.";
            }            
            Client.Directory.OnEventsReply -= new DirectoryManager.EventReplyCallback(Directory_OnEventsReply);
            return result;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles the remaining Image data that did not fit in the initial ImageData packet
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="simulator"></param>
        public void ImagePacketCallbackHandler(Packet packet, Simulator simulator)
        {
#if DEBUG_PACKETS
            slClient.DebugLog(packet);
#endif

            ImagePacketPacket reply = (ImagePacketPacket)packet;

            LLUUID ImageID = reply.ImageID.ID;

            // Lookup the request for this packet
            TransferRequest tr = null;
            lock (htDownloadRequests)
            {
                if (htDownloadRequests.ContainsKey(ImageID))
                {
                    tr = (TransferRequest)htDownloadRequests[ImageID];
                }
                else
                {
                    // Received a packet that doesn't belong to any requests in our queue, strange...
                    return;
                }
            }


            // TODO: Received data should probably be put into a temporary collection that's indected by ImageID.Packet
            // then once we've received all data packets, it should be re-assembled into a complete array and marked
            // completed.

            // FIXME: Sometimes this gets called before ImageDataCallbackHandler, when that
            // happens tr.AssetData will be null.  Implimenting the above TODO should fix this.

            // Wait until we've received the header packet for this image, which creates the AssetData array
            if (!tr.ReceivedHeaderPacket.WaitOne(15000, false))
            {
                tr.Status    = false;
                tr.StatusMsg = "Failed to receive Image Header packet in a timely manor, aborting.";
                slClient.Log(tr.StatusMsg, Helpers.LogLevel.Error);
                tr.Completed.Set();
            }

            // Add this packet's data to the request.
            Buffer.BlockCopy(reply.ImageData.Data, 0, tr.AssetData, tr.BaseDataReceived + (1000 * (reply.ImageID.Packet - 1)), reply.ImageData.Data.Length);
            tr.Received += (uint)reply.ImageData.Data.Length;

            tr.TimeOfLastPacket = Helpers.GetUnixTime(); // last time we recevied a packet for this request

            // If we've gotten all the data, mark it completed.
            if (tr.Received >= tr.Size)
            {
                tr.Status = true;
                tr.Completed.Set();

                // Fire off image downloaded event
                CacheImage(ImageID, tr.AssetData);
                FireImageRetrieved(ImageID, tr.AssetData, false);
            }
        }
Exemplo n.º 8
0
        public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName, InstantMessageEventArgs e)
        {
            IMTabWindow imTab = this.AddIMTab(target, session, targetName);

            imTab.TextManager.PassIMEvent(e);

            return(imTab);
        }
Exemplo n.º 9
0
 internal InventoryFolder(InventoryManager manager, Dictionary <string, string> htData)
     : base(manager)
 {
     this._Name     = htData["name"];
     this._FolderID = new LLUUID(htData["folder_id"]);
     this._ParentID = new LLUUID(htData["parent_id"]);
     this._Type     = sbyte.Parse(htData["type_default"].ToString());
 }
Exemplo n.º 10
0
 private void processLandmark(string temp)
 {
     Console.Write(temp + "\n");
     string[] parts = temp.Split('\n');
     int.TryParse(parts[0].Substring(17, 1), out _Version);
     LLUUID.TryParse(parts[1].Substring(10, 36), out _Region);
     LLVector3.TryParse(parts[2].Substring(11, parts[2].Length - 11), out _Pos);
 }
Exemplo n.º 11
0
        public void RequestAsset(LLUUID assetID, bool isTexture)
        {
            ARequest req = new ARequest();

            req.AssetID   = assetID;
            req.IsTexture = isTexture;
            this._assetRequests.Enqueue(req);
        }
Exemplo n.º 12
0
 internal InventoryFolder(InventoryManager manager)
     : base(manager)
 {
     _Name     = "";
     _FolderID = LLUUID.Zero;
     _ParentID = LLUUID.Zero;
     _Type     = -1;
 }
Exemplo n.º 13
0
 internal InventoryFolder(InventoryManager manager, String name, LLUUID folderID, LLUUID parentID, sbyte Type)
     : base(manager)
 {
     this._Name     = name;
     this._FolderID = folderID;
     this._ParentID = parentID;
     this._Type     = Type;
 }
Exemplo n.º 14
0
 void onAvatarProperties(LLUUID avatarID, Avatar.AvatarProperties properties)
 {
     lock (ReceivedAvatarPropertiesEvent)
     {
         avatarProperties = properties;
         ReceivedAvatarPropertiesEvent.Set();
     }
 }
Exemplo n.º 15
0
 public bool HasFolder(LLUUID folderID)
 {
     if (this.InventoryFolders.ContainsKey(folderID))
     {
         return(true);
     }
     return(false);
 }
 public Packet MoveInventoryItem(
     LLUUID itemID
     , LLUUID folderID
     )
 {
     Console.WriteLine("WARNING: Using the new MoveInventoryItem packet, without specifying new folder name has unknown results.");
     return(MoveInventoryItem(itemID, folderID, null));
 }
Exemplo n.º 17
0
        protected virtual LLUUID GetAgentId(string firstName, string lastName)
        {
            LLUUID Agent;
            int    AgentRand = this.RandomClass.Next(1, 9999);

            Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
            return(Agent);
        }
Exemplo n.º 18
0
 void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type,
                  ChatSourceType sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position)
 {
     if (message.Length > 0 && Client.MasterKey == id)
     {
         Client.Self.Chat(message, 0, ChatType.Normal);
     }
 }
Exemplo n.º 19
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            LLUUID primID;

            if (args.Length != 1)
            {
                return("Usage: priminfo [prim-uuid]");
            }

            if (LLUUID.TryParse(args[0], out primID))
            {
                Primitive target = Client.Network.CurrentSim.ObjectsPrimitives.Find(
                    delegate(Primitive prim) { return(prim.ID == primID); }
                    );

                if (target != null)
                {
                    Logger.Log("Light: " + target.Light.ToString(), Helpers.LogLevel.Info, Client);

                    if (target.ParticleSys.CRC != 0)
                    {
                        Logger.Log("Particles: " + target.ParticleSys.ToString(), Helpers.LogLevel.Info, Client);
                    }

                    Logger.Log("TextureEntry:", Helpers.LogLevel.Info, Client);
                    if (target.Textures != null)
                    {
                        Logger.Log(String.Format("Default texure: {0}",
                                                 target.Textures.DefaultTexture.TextureID.ToString()),
                                   Helpers.LogLevel.Info);

                        for (int i = 0; i < target.Textures.FaceTextures.Length; i++)
                        {
                            if (target.Textures.FaceTextures[i] != null)
                            {
                                Logger.Log(String.Format("Face {0}: {1}", i,
                                                         target.Textures.FaceTextures[i].TextureID.ToString()),
                                           Helpers.LogLevel.Info, Client);
                            }
                        }
                    }
                    else
                    {
                        Logger.Log("null", Helpers.LogLevel.Info, Client);
                    }

                    return("Done.");
                }
                else
                {
                    return("Could not find prim " + primID.ToString());
                }
            }
            else
            {
                return("Usage: priminfo [prim-uuid]");
            }
        }
Exemplo n.º 20
0
        public Packet DetachAttachmentIntoInv(LLUUID ItemID)
        {
            DetachAttachmentIntoInvPacket p = new DetachAttachmentIntoInvPacket();

            p.ObjectData.AgentID = AgentID;
            p.ObjectData.ItemID  = ItemID;

            return(p);
        }
Exemplo n.º 21
0
        public AgentInventory GetAgentsInventory(LLUUID agentID)
        {
            if (this._agentsInventory.ContainsKey(agentID))
            {
                return(this._agentsInventory[agentID]);
            }

            return(null);
        }
Exemplo n.º 22
0
        public AssetBase GetUpload(LLUUID transactionID)
        {
            if (this.transactions.ContainsKey(transactionID))
            {
                return(this.transactions[transactionID].Asset);
            }

            return(null);
        }
Exemplo n.º 23
0
 void Avatars_OnPointAt(LLUUID sourceID, LLUUID targetID, LLVector3d targetPos,
                        PointAtType pointType, float duration, LLUUID id)
 {
     if (sourceID == Client.MasterKey)
     {
         //Client.DebugLog("Master is now selecting " + targetID.ToString());
         SelectedObject = targetID;
     }
 }
Exemplo n.º 24
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            //if (args.Length < 1)
            //    return "";

            Client.Grid.RequestMainlandSims(GridLayerType.Objects);

            return("Sent.");
        }
Exemplo n.º 25
0
 internal DownloadRequest_Folder(LLUUID folderID, bool recurse, bool fetchFolders, bool fetchItems, string requestName)
 {
     FolderID           = folderID;
     Recurse            = recurse;
     FetchFolders       = fetchFolders;
     FetchItems         = fetchItems;
     LastReceivedAtTick = Environment.TickCount;
     Name = requestName;
 }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length > 1)
            {
                return("Usage: ls [-l]");
            }
            bool longDisplay = false;

            if (args.Length > 0 && args[0] == "-l")
            {
                longDisplay = true;
            }

            Manager   = Client.Inventory;
            Inventory = Manager.Store;
            // WARNING: Uses local copy of inventory contents, need to download them first.
            List <InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
            string displayString          = "";
            string nl = "\n"; // New line character

            // Pretty simple, just print out the contents.
            foreach (InventoryBase b in contents)
            {
                if (longDisplay)
                {
                    // Generate a nicely formatted description of the item.
                    // It kinda looks like the output of the unix ls.
                    // starts with 'd' if the inventory is a folder, '-' if not.
                    // 9 character permissions string
                    // UUID of object
                    // Name of object
                    if (b is InventoryFolder)
                    {
                        InventoryFolder folder = b as InventoryFolder;
                        displayString += "d--------- ";
                        displayString += folder.UUID;
                        displayString += " " + folder.Name;
                    }
                    else if (b is InventoryItem)
                    {
                        InventoryItem item = b as InventoryItem;
                        displayString += "-";
                        displayString += PermMaskString(item.Permissions.OwnerMask);
                        displayString += PermMaskString(item.Permissions.GroupMask);
                        displayString += PermMaskString(item.Permissions.EveryoneMask);
                        displayString += " " + item.UUID;
                        displayString += " " + item.Name;
                    }
                }
                else
                {
                    displayString += b.Name;
                }
                displayString += nl;
            }
            return(displayString);
        }
Exemplo n.º 27
0
        // CALLBACKS

        // These are all assigned to LibSL callbacks in Connect.cs. This determines their argument order.
        // The if(!active) check is to ensure they don't get called after we've logged off. This is a
        // LibSL bug.

        // These almost all perform the same task:
        // 1) Create a hashtable
        // 2) Place various passed-in arguments in the hashtable
        // 3) Optionally, loop through one of the arguments if necessary, and add this to the hashtable
        //    as a bunch more hashtables.
        // 4) Enqueue the hashtable in the message queue. This is periodically emptied by the client.

        public void Avatars_OnAvatarGroups(LLUUID avatarID, List <AvatarGroup> groups)
        {
            Hashtable item = new Hashtable();

            item.Add("MessageType", "AvatarGroups");
            item.Add("AvatarID", avatarID);
            item.Add("Groups", groups);
            enqueue(item);
        }
Exemplo n.º 28
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 2)
            {
                return("Usage: packetlog 10 tenpackets.xml");
            }

            return("This function is currently unimplemented");
        }
Exemplo n.º 29
0
        protected virtual void AuthUser()
        {
            AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);

            if (!sessionInfo.Authorised)
            {
                //session/circuit not authorised
                OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
                ClientThread.Abort();
            }
            else
            {
                OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
                //session is authorised
                this.AgentID     = cirpack.CircuitCode.ID;
                this.SessionID   = cirpack.CircuitCode.SessionID;
                this.CircuitCode = cirpack.CircuitCode.Code;
                InitNewClient(); //shouldn't be called here as we might be a child agent and not want a full avatar
                this.ClientAvatar.firstname = sessionInfo.LoginInfo.First;
                this.ClientAvatar.lastname  = sessionInfo.LoginInfo.Last;
                if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
                {
                    this.SecureSessionID = sessionInfo.LoginInfo.SecureSession;
                }

                // Create Inventory, currently only works for sandbox mode
                if (m_sandboxMode)
                {
                    AgentInventory inventory = null;
                    if (sessionInfo.LoginInfo.InventoryFolder != null)
                    {
                        inventory = this.CreateInventory(sessionInfo.LoginInfo.InventoryFolder);
                        if (sessionInfo.LoginInfo.BaseFolder != null)
                        {
                            if (!inventory.HasFolder(sessionInfo.LoginInfo.BaseFolder))
                            {
                                m_inventoryCache.CreateNewInventoryFolder(this, sessionInfo.LoginInfo.BaseFolder);
                            }
                            this.newAssetFolder = sessionInfo.LoginInfo.BaseFolder;
                            AssetBase[] inventorySet = m_assetCache.CreateNewInventorySet(this.AgentID);
                            if (inventorySet != null)
                            {
                                for (int i = 0; i < inventorySet.Length; i++)
                                {
                                    if (inventorySet[i] != null)
                                    {
                                        m_inventoryCache.AddNewInventoryItem(this, sessionInfo.LoginInfo.BaseFolder, inventorySet[i]);
                                    }
                                }
                            }
                        }
                    }
                }

                ClientLoop();
            }
        }
Exemplo n.º 30
0
 internal DownloadRequest_Folder(LLUUID folderID, bool recurse, bool fetchFolders, bool fetchItems, string requestName)
 {
     FolderID = folderID;
     Recurse = recurse;
     FetchFolders = fetchFolders;
     FetchItems = fetchItems;
     LastReceivedAtTick = Environment.TickCount;
     Name = requestName;
 }
Exemplo n.º 31
0
        public void Friends_OnFriendFound(LLUUID agentID, ulong regionHandle, LLVector3 location)
        {
            Hashtable item = new Hashtable();

            item.Add("MessageType", "FriendFound");
            item.Add("Location", location);
            item.Add("RegionHandle", regionHandle.ToString()); // String to avoid upsetting JavaScript.
            enqueue(item);
        }
Exemplo n.º 32
0
        public void Avatars_OnFriendNotification(LLUUID agentID, bool online)
        {
            Hashtable item = new Hashtable();

            item.Add("MessageType", "FriendNotification");
            item.Add("AgentID", agentID);
            item.Add("Online", online);
            enqueue(item);
        }
Exemplo n.º 33
0
        public bool CreateNewFolder(LLUUID folderID, ushort type)
        {
            InventoryFolder Folder = new InventoryFolder();

            Folder.FolderID    = folderID;
            Folder.OwnerID     = this.AgentID;
            Folder.DefaultType = type;
            this.InventoryFolders.Add(Folder.FolderID, Folder);
            return(true);
        }
Exemplo n.º 34
0
 public override string Execute(string[] args, LLUUID fromAgentID) {
     if (args.Length != 3)
         return "usage: moveto x y z";
     float x = Client.Self.Position.X + Client.regionX;
     float y = Client.Self.Position.Y + Client.regionY;
     float z = Client.Self.Position.Z;
     float.TryParse(args[0], out x);
     float.TryParse(args[1], out y);
     float.TryParse(args[2], out z);
     Client.Self.AutoPilot((ulong)x, (ulong)y, z);
     return "Attempting to move to <" + x + ", " + y + ", " + z + ">";
 }
Exemplo n.º 35
0
 void Directory_OnEventsReply(LLUUID queryID, List<DirectoryManager.EventsSearchData> matchedEvents)
 {
     if (matchedEvents[0].ID == 0 && matchedEvents.Count == 1)
     {
         Console.WriteLine("No Results matched your search string");
     }
     else
     {
         foreach (DirectoryManager.EventsSearchData ev in matchedEvents)
         {
             Console.WriteLine("Event ID: {0} Event Name: {1} Event Date: {2}", ev.ID, ev.Name, ev.Date);
         }
     }
     resultCount = matchedEvents.Count;
     waitQuery.Set();
 }
Exemplo n.º 36
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 3)
                return "Usage: moveto x y z";

            uint regionX, regionY;
            Helpers.LongToUInts(Client.Network.CurrentSim.Handle, out regionX, out regionY);

            double x, y, z;
            Double.TryParse(args[0], out x);
            Double.TryParse(args[1], out y);
            Double.TryParse(args[2], out z);

            Client.Self.AutoPilot(x, y, z);

            return String.Format("Attempting to move to <{0},{1},{2}>", x, y, z);
        }
Exemplo n.º 37
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
                return "Usage: showevent [eventID] (use searchevents to get ID)";

            Client.Directory.OnEventInfo += new DirectoryManager.EventInfoCallback(Directory_OnEventInfo);
            uint eventID;

            if (UInt32.TryParse(args[0], out eventID))
            {
                Client.Directory.EventInfoRequest(eventID);
                return "Query Sent";
            }
            else
            {
                return "Usage: showevent [eventID] (use searchevents to get ID)";
            }
        }
Exemplo n.º 38
0
 public override string Execute(string[] args, LLUUID fromAgentID)
 {
     if (args.Length < 2)
     {
         return "Usage: give <agent uuid> <item1> [item2] [item3] [...]";
     }
     LLUUID dest;
     if (!LLUUID.TryParse(args[0], out dest))
     {
         return "First argument expected agent UUID.";
     }
     Manager = Client.Inventory;
     Inventory = Manager.Store;
     string ret = "";
     string nl = "\n";
     for (int i = 1; i < args.Length; ++i)
     {
         string inventoryName = args[i];
         // WARNING: Uses local copy of inventory contents, need to download them first.
         List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
         bool found = false;
         foreach (InventoryBase b in contents) {
             if (inventoryName == b.Name || inventoryName == b.UUID.ToString())
             {
                 found = true;
                 if (b is InventoryItem)
                 {
                     InventoryItem item = b as InventoryItem;
                     Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true);
                     ret += "Gave " + item.Name + nl;
                 }
                 else
                 {
                     ret += "Unable to give folder " + b.Name + nl;
                 }
             }
         }
         if (!found)
             ret += "No inventory item named " + inventoryName + " found." + nl;
     }
     return ret;
 }
Exemplo n.º 39
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 3)
                return "Usage: moveto x y z";

            uint regionX, regionY;
            Helpers.LongToUInts(Client.Network.CurrentSim.Handle, out regionX, out regionY);

            double x, y, z;
            if (!Double.TryParse(args[0], out x) ||
                !Double.TryParse(args[1], out y) ||
                !Double.TryParse(args[2], out z))
            {
                return "Usage: moveto x y z";
            }

            // Convert the local coordinates to global ones by adding the region handle parts to x and y
            x += (double)regionX;
            y += (double)regionY;
            Client.Self.AutoPilot(x, y, z);

            return String.Format("Attempting to move to <{0},{1},{2}>", x, y, z);
        }
 public DownloadRequest_Folder(LLUUID folderID, bool recurse)
 {
     FolderID = folderID;
         LastReceivedAtTick = Environment.TickCount;
         Recurse = recurse;
 }
 public DownloadRequest_Folder(LLUUID folderID)
 {
     FolderID = folderID;
         LastReceivedAtTick = Environment.TickCount;
 }
Exemplo n.º 42
0
 public AssetScript(LLUUID assetID, string source)
     : base(assetID, (sbyte)Asset.AssetType.LSLText, false, null)
 {
     _Source = source;
     setAsset(source);
 }
Exemplo n.º 43
0
 public AssetScript(LLUUID assetID, byte[] assetData)
     : base(assetID, (sbyte)Asset.AssetType.LSLText, false, assetData)
 {
     _Source = System.Text.Encoding.UTF8.GetString(assetData).Trim();
 }
Exemplo n.º 44
0
 public InventoryScript(InventoryManager manager, string name, string description, LLUUID folderID, LLUUID uuidOwnerCreater)
     : base(manager, name, description, folderID, 10, 10, uuidOwnerCreater)
 {
 }
Exemplo n.º 45
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            LLUUID rootID;
            Primitive rootPrim;
            List<Primitive> childPrims;
            List<uint> localIDs = new List<uint>();

            // Reset class-wide variables
            PermsSent = false;
            Objects.Clear();
            Perms = PermissionMask.None;
            PermCount = 0;

            if (args.Length < 1 || args.Length > 4)
                return "Usage prim-uuid [copy] [mod] [xfer]";

            if (!LLUUID.TryParse(args[0], out rootID))
                return "Usage prim-uuid [copy] [mod] [xfer]";

            for (int i = 1; i < args.Length; i++)
            {
                switch (args[i].ToLower())
                {
                    case "copy":
                        Perms |= PermissionMask.Copy;
                        break;
                    case "mod":
                        Perms |= PermissionMask.Modify;
                        break;
                    case "xfer":
                        Perms |= PermissionMask.Transfer;
                        break;
                    default:
                        return "Usage prim-uuid [copy] [mod] [xfer]";
                }
            }

            Client.DebugLog("Using PermissionMask: " + Perms.ToString());

            // Find the requested prim
            rootPrim = Client.Network.CurrentSim.Objects.Find(delegate(Primitive prim) { return prim.ID == rootID; });
            if (rootPrim == null)
                return "Cannot find requested prim " + rootID.ToString();
            else
                Client.DebugLog("Found requested prim " + rootPrim.ID.ToString());

            if (rootPrim.ParentID != 0)
            {
                // This is not actually a root prim, find the root
                if (!Client.Network.CurrentSim.Objects.TryGetPrimitive(rootPrim.ParentID, out rootPrim))
                    return "Cannot find root prim for requested object";
                else
                    Client.DebugLog("Set root prim to " + rootPrim.ID.ToString());
            }

            // Find all of the child objects linked to this root
            childPrims = Client.Network.CurrentSim.Objects.FindAll(delegate(Primitive prim) { return prim.ParentID == rootPrim.LocalID; });

            // Build a dictionary of primitives for referencing later
            Objects[rootPrim.ID] = rootPrim;
            for (int i = 0; i < childPrims.Count; i++)
                Objects[childPrims[i].ID] = childPrims[i];

            // Build a list of all the localIDs to set permissions for
            localIDs.Add(rootPrim.LocalID);
            for (int i = 0; i < childPrims.Count; i++)
                localIDs.Add(childPrims[i].LocalID);

            // Go through each of the three main permissions and enable or disable them
            #region Set Linkset Permissions

            PermCount = 0;
            if ((Perms & PermissionMask.Modify) == PermissionMask.Modify)
                Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Modify, true);
            else
                Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Modify, false);
            PermsSent = true;

            if (!GotPermissionsEvent.WaitOne(1000 * 30, false))
                return "Failed to set the modify bit, permissions in an unknown state";

            PermCount = 0;
            if ((Perms & PermissionMask.Copy) == PermissionMask.Copy)
                Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Copy, true);
            else
                Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Copy, false);
            PermsSent = true;

            if (!GotPermissionsEvent.WaitOne(1000 * 30, false))
                return "Failed to set the copy bit, permissions in an unknown state";

            PermCount = 0;
            if ((Perms & PermissionMask.Transfer) == PermissionMask.Transfer)
                Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Transfer, true);
            else
                Client.Objects.SetPermissions(Client.Network.CurrentSim, localIDs, PermissionWho.NextOwner, PermissionMask.Transfer, false);
            PermsSent = true;

            if (!GotPermissionsEvent.WaitOne(1000 * 30, false))
                return "Failed to set the transfer bit, permissions in an unknown state";

            #endregion Set Linkset Permissions

            // Check each prim for task inventory and set permissions on the task inventory
            int taskItems = 0;
            foreach (Primitive prim in Objects.Values)
            {
                if ((prim.Flags & LLObject.ObjectFlags.InventoryEmpty) == 0)
                {
                    List<InventoryBase> items = Client.Inventory.GetTaskInventory(prim.ID, prim.LocalID, 1000 * 30);

                    if (items != null)
                    {
                        for (int i = 0; i < items.Count; i++)
                        {
                            if (!(items[i] is InventoryFolder))
                            {
                                InventoryItem item = (InventoryItem)items[i];
                                item.Permissions.NextOwnerMask = Perms;

                                Client.Inventory.UpdateTaskInventory(prim.LocalID, item);
                                ++taskItems;
                            }
                        }
                    }
                }
            }

            return "Set permissions to " + Perms.ToString() + " on " + localIDs.Count + " objects and " + taskItems + " inventory items";
        }