Ejemplo n.º 1
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
            {
                return("Usage: siton UUID");
            }

            LLUUID target;

            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.RequestSit(targetPrim.ID, LLVector3.Zero);
                    Client.Self.Sit();
                    return("Requested to sit on prim " + targetPrim.ID.ToString() +
                           " (" + targetPrim.LocalID + ")");
                }
            }

            return("Couldn't find a prim to sit on with UUID " + args[0]);
        }
Ejemplo n.º 2
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
            {
                return("Usage: goto_landmark [UUID]");
            }

            LLUUID landmark = new LLUUID();

            if (!LLUUID.TryParse(args[0], out landmark))
            {
                return("Invalid LLUID");
            }
            else
            {
                Console.WriteLine("Teleporting to " + landmark.ToString());
            }
            if (Client.Self.Teleport(landmark))
            {
                return("Teleport Succesful");
            }
            else
            {
                return("Teleport Failed");
            }
        }
Ejemplo n.º 3
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.Objects.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]);
        }
Ejemplo n.º 4
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            int    faceIndex;
            LLUUID textureID;

            if (args.Length != 2)
            {
                return("Usage: findtexture [face-index] [texture-uuid]");
            }

            if (Int32.TryParse(args[0], out faceIndex) &&
                LLUUID.TryParse(args[1], out textureID))
            {
                Client.Network.CurrentSim.Objects.ForEach(
                    delegate(Primitive prim)
                {
                    if (prim.Textures != null && prim.Textures.FaceTextures[faceIndex] != null)
                    {
                        if (prim.Textures.FaceTextures[faceIndex].TextureID == textureID)
                        {
                            Client.Log(String.Format("Primitive {0} ({1}) has face index {2} set to {3}",
                                                     prim.ID.ToString(), prim.LocalID, faceIndex, textureID.ToString()),
                                       Helpers.LogLevel.Info);
                        }
                    }
                }
                    );

                return("Done searching");
            }
            else
            {
                return("Usage: findtexture [face-index] [texture-uuid]");
            }
        }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
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]");
            }
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
            {
                return("Usage: objectinventory [objectID]");
            }

            uint   objectLocalID;
            LLUUID objectID;

            if (!LLUUID.TryParse(args[0], out objectID))
            {
                return("Usage: objectinventory [objectID]");
            }

            Primitive found = Client.Network.CurrentSim.ObjectsPrimitives.Find(delegate(Primitive prim) { return(prim.ID == objectID); });

            if (found != null)
            {
                objectLocalID = found.LocalID;
            }
            else
            {
                return("Couldn't find prim " + objectID.ToString());
            }

            List <InventoryBase> items = Client.Inventory.GetTaskInventory(objectID, objectLocalID, 1000 * 30);

            if (items != null)
            {
                string result = String.Empty;

                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i] is InventoryFolder)
                    {
                        result += String.Format("[Folder] Name: {0}", items[i].Name) + Environment.NewLine;
                    }
                    else
                    {
                        InventoryItem item = (InventoryItem)items[i];
                        result += String.Format("[Item] Name: {0} Desc: {1} Type: {2}", item.Name, item.Description,
                                                item.AssetType) + Environment.NewLine;
                    }
                }

                return(result);
            }
            else
            {
                return("Failed to download task inventory for " + objectLocalID);
            }
        }
Ejemplo n.º 8
0
        public override LLUUID AsUUID()
        {
            LLUUID uuid;

            if (LLUUID.TryParse(value, out uuid))
            {
                return(uuid);
            }
            else
            {
                return(LLUUID.Zero);
            }
        }
Ejemplo n.º 9
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
            {
                return("Usage: downloadtexture [texture-uuid]");
            }

            TextureID = LLUUID.Zero;
            DownloadHandle.Reset();
            Image = null;
            Asset = null;

            if (LLUUID.TryParse(args[0], out TextureID))
            {
                Client.Assets.RequestImage(TextureID, ImageType.Normal);
                if (DownloadHandle.WaitOne(120 * 1000, false))
                {
                    if (Image != null && Image.Success)
                    {
                        if (Asset != null && Asset.Decode())
                        {
                            try { File.WriteAllBytes(Image.ID.ToString() + ".jp2", Asset.AssetData); }
                            catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); }

                            return(String.Format("Saved {0}.jp2 ({1}x{2})", Image.ID, Asset.Image.Width, Asset.Image.Height));
                        }
                        else
                        {
                            return("Failed to decode texture " + TextureID.ToString());
                        }
                    }
                    else if (Image != null && Image.NotFound)
                    {
                        return("Simulator reported texture not found: " + TextureID.ToString());
                    }
                    else
                    {
                        return("Download failed for texture " + TextureID.ToString());
                    }
                }
                else
                {
                    return("Timed out waiting for texture download");
                }
            }
            else
            {
                return("Usage: downloadtexture [texture-uuid]");
            }
        }
Ejemplo n.º 10
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 2)
            {
                return("Usage: imgroup [group_uuid] [message]");
            }



            if (LLUUID.TryParse(args[0], out ToGroupID))
            {
                string message = String.Empty;
                for (int ct = 1; ct < args.Length; ct++)
                {
                    message += args[ct] + " ";
                }
                message = message.TrimEnd();
                if (message.Length > 1023)
                {
                    message = message.Remove(1023);
                }

                Client.Self.OnGroupChatJoin += new AgentManager.GroupChatJoined(Self_OnGroupChatJoin);
                if (!Client.Self.GroupChatSessions.ContainsKey(ToGroupID))
                {
                    WaitForSessionStart.Reset();
                    Client.Self.RequestJoinGroupChat(ToGroupID);
                }
                else
                {
                    WaitForSessionStart.Set();
                }

                if (WaitForSessionStart.WaitOne(10000, false))
                {
                    Client.Self.InstantMessageGroup(ToGroupID, message);
                }
                else
                {
                    return("Timeout waiting for group session start");
                }

                Client.Self.OnGroupChatJoin -= new AgentManager.GroupChatJoined(Self_OnGroupChatJoin);
                return("Instant Messaged group " + ToGroupID.ToString() + " with message: " + message);
            }
            else
            {
                return("failed to instant message group");
            }
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            LLUUID id;
            string path;

            if (args.Length == 1)
            {
                id   = Client.Self.AgentID;
                path = args[0];
            }
            else if (args.Length == 2)
            {
                if (!LLUUID.TryParse(args[0], out id))
                {
                    return("Usage: exportoutfit [avataruuid] outputfile.xml");
                }
                path = args[1];
            }
            else
            {
                return("Usage: exportoutfit [avataruuid] outputfile.xml");
            }

            lock (Client.Appearances)
            {
                if (Client.Appearances.ContainsKey(id))
                {
                    try
                    {
                        File.WriteAllText(path, Packet.ToXmlString(Client.Appearances[id]));
                    }
                    catch (Exception e)
                    {
                        return(e.ToString());
                    }

                    return("Exported appearance for avatar " + id.ToString() + " to " + args[1]);
                }
                else
                {
                    return("Couldn't find an appearance for avatar " + id.ToString());
                }
            }
        }
Ejemplo n.º 13
0
        private string AddTestScript(string request, string path, string param)
        {
            int index = path.LastIndexOf('/');

            string lluidStr = path.Substring(index + 1);

            LLUUID id;

            if (LLUUID.TryParse(lluidStr, out id))
            {
                // This is just here for concept purposes... Remove!
                m_world.AddScript(m_world.Entities[id], new FollowRandomAvatar());
                return(String.Format("Added new script to object [{0}]", id));
            }
            else
            {
                return(String.Format("Couldn't parse [{0}]", lluidStr));
            }
        }
Ejemplo n.º 14
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
            {
                return(Description);
            }

            LLUUID targetID;

            if (!LLUUID.TryParse(args[0], out targetID))
            {
                return(Description);
            }

            StringBuilder sb = new StringBuilder();

            FriendsManager.FriendFoundEvent del =
                delegate(LLUUID agentID, ulong regionHandle, LLVector3 location)
            {
                if (!regionHandle.Equals(0))
                {
                    sb.AppendFormat("Found Friend {0} in {1} at {2}/{3}", agentID, regionHandle, location.X, location.Y);
                }
                else
                {
                    sb.AppendFormat("Found Friend {0}, But they appear to be offline", agentID);
                }

                WaitforFriend.Set();
            };

            Client.Friends.OnFriendFound += del;
            WaitforFriend.Reset();
            Client.Friends.MapFriend(targetID);
            if (!WaitforFriend.WaitOne(10000, false))
            {
                sb.AppendFormat("Timeout waiting for reply, Do you have mapping rights on {0}?", targetID);
            }
            Client.Friends.OnFriendFound -= del;
            return(sb.ToString());
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            if (args.Length < 4)
            {
                Console.WriteLine("Usage: Key2Name [loginfirstname] [loginlastname] [password] [key]");
                return;
            }

            SecondLife client = new SecondLife();

            client.Avatars.OnAvatarNames += new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames);

            Console.WriteLine("Attempting to connect and login to Second Life.");

            // Login to Second Life
            if (!client.Network.Login(args[0], args[1], args[2], "key2name", "*****@*****.**"))
            {
                // Login failed
                Console.WriteLine("Error logging in: " + client.Network.LoginMessage);
                return;
            }

            LLUUID lookup = new LLUUID();

            LLUUID.TryParse(args[3], out lookup);

            Console.WriteLine("Looking up name for " + lookup.ToString());

            client.Avatars.RequestAvatarName(lookup);

            if (!NameEvent.WaitOne(15 * 1000, false))
            {
                Console.WriteLine("Name lookup timed out.");
            }

            Console.WriteLine("Press enter to logout.");
            Console.ReadLine();

            client.Network.Logout();
        }
Ejemplo n.º 16
0
        // synchronous
        // Only works with non-LUUID-recipients if these recipients are logged in!!
        // if recipientLastName == "LLUUID", recipientFirstName is expected to contain a valid LLUUID
        // for instant messagin while avatar isn't online
        public bool sendIM(string message, string recipientFirstName, string recipientLastName)
        {
            LLUUID id = LLUUID.Zero;

            // passed LLUUID directly
            if (recipientLastName.Equals("LLUUID"))
            {
                if (!LLUUID.TryParse(recipientFirstName, out id))
                {
                    #if DEBUG
                    Console.Out.WriteLine("LLUUID parsing for {0} failed", recipientFirstName);
                    #endif

                    return(false);
                }
            }

            // get LLUUID by friedship list lookup
            else if (Friends.FriendList.Count > 0)
            {
                Friends.FriendList.ForEach(delegate(FriendInfo friend)
                {
                    #if DEBUG
                    Console.Out.WriteLine(friend.Name);
                    #endif

                    String tmpAvatarName = recipientFirstName + " " + recipientLastName;

                    if (friend.Name.ToLower() == tmpAvatarName.ToLower())
                    {
                        id = friend.UUID;
                    }
                });
            }

            // lookup LLUUID through system, only works if recipients are logged in!!
            if (id == LLUUID.Zero)
            {
                lock (toAvatarName)
                {
                    toAvatarName = recipientFirstName + " " + recipientLastName;

                    if (!name2Key.ContainsKey(toAvatarName.ToLower()))
                    {
                        // Send the Query
                        Avatars.RequestAvatarNameSearch(toAvatarName, LLUUID.Random());

                        nameSearchEvent.WaitOne(6000, false);
                    }

                    if (name2Key.ContainsKey(toAvatarName.ToLower()))
                    {
                        id = name2Key[toAvatarName.ToLower()];
                    }
                    else
                    {
                        #if DEBUG
                        Console.Out.WriteLine("Name lookup for {0} failed", toAvatarName);
                        #endif

                        return(false);
                    }
                }
            }

            // Build the message
            message = message.TrimEnd();
            if (message.Length > 1023)
            {
                message = message.Remove(1023);
            }

            Self.InstantMessage(id, message);

            #if DEBUG
            Console.Out.WriteLine("Instant Messaged {0} with message: {1}", id.ToString(), message);
            #endif

            return(true);
        }
Ejemplo n.º 17
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
            {
                return("Usage: exportparticles [prim-uuid]");
            }

            LLUUID id;

            if (!LLUUID.TryParse(args[0], out id))
            {
                return("Usage: exportparticles [prim-uuid]");
            }

            lock (Client.Network.Simulators)
            {
                for (int i = 0; i < Client.Network.Simulators.Count; i++)
                {
                    Primitive exportPrim = Client.Network.Simulators[i].Objects.Find(
                        delegate(Primitive prim)
                    {
                        return(prim.ID == id);
                    }
                        );

                    if (exportPrim != null)
                    {
                        if (exportPrim.ParticleSys.CRC != 0)
                        {
                            StringBuilder lsl = new StringBuilder();

                            #region Particle System to LSL

                            lsl.Append("default" + Environment.NewLine);
                            lsl.Append("{" + Environment.NewLine);
                            lsl.Append("    state_entry()" + Environment.NewLine);
                            lsl.Append("    {" + Environment.NewLine);
                            lsl.Append("         llParticleSystem([" + Environment.NewLine);

                            lsl.Append("         PSYS_PART_FLAGS, 0");

                            if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.InterpColor) != 0)
                            {
                                lsl.Append(" | PSYS_PART_INTERP_COLOR_MASK");
                            }
                            if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.InterpScale) != 0)
                            {
                                lsl.Append(" | PSYS_PART_INTERP_SCALE_MASK");
                            }
                            if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Bounce) != 0)
                            {
                                lsl.Append(" | PSYS_PART_BOUNCE_MASK");
                            }
                            if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Wind) != 0)
                            {
                                lsl.Append(" | PSYS_PART_WIND_MASK");
                            }
                            if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.FollowSrc) != 0)
                            {
                                lsl.Append(" | PSYS_PART_FOLLOW_SRC_MASK");
                            }
                            if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.FollowVelocity) != 0)
                            {
                                lsl.Append(" | PSYS_PART_FOLLOW_VELOCITY_MASK");
                            }
                            if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.TargetPos) != 0)
                            {
                                lsl.Append(" | PSYS_PART_TARGET_POS_MASK");
                            }
                            if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.TargetLinear) != 0)
                            {
                                lsl.Append(" | PSYS_PART_TARGET_LINEAR_MASK");
                            }
                            if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Emissive) != 0)
                            {
                                lsl.Append(" | PSYS_PART_EMISSIVE_MASK");
                            }

                            lsl.Append(","); lsl.Append(Environment.NewLine);
                            lsl.Append("         PSYS_SRC_PATTERN, 0");

                            if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Drop) != 0)
                            {
                                lsl.Append(" | PSYS_SRC_PATTERN_DROP");
                            }
                            if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Explode) != 0)
                            {
                                lsl.Append(" | PSYS_SRC_PATTERN_EXPLODE");
                            }
                            if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Angle) != 0)
                            {
                                lsl.Append(" | PSYS_SRC_PATTERN_ANGLE");
                            }
                            if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.AngleCone) != 0)
                            {
                                lsl.Append(" | PSYS_SRC_PATTERN_ANGLE_CONE");
                            }
                            if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.AngleConeEmpty) != 0)
                            {
                                lsl.Append(" | PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY");
                            }

                            lsl.Append("," + Environment.NewLine);

                            lsl.Append("         PSYS_PART_START_ALPHA, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartColor.A) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_PART_END_ALPHA, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndColor.A) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_PART_START_COLOR, " + exportPrim.ParticleSys.PartStartColor.ToStringRGB() + "," + Environment.NewLine);
                            lsl.Append("         PSYS_PART_END_COLOR, " + exportPrim.ParticleSys.PartEndColor.ToStringRGB() + "," + Environment.NewLine);
                            lsl.Append("         PSYS_PART_START_SCALE, <" + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartScaleX) + ", " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartScaleY) + ", 0>, " + Environment.NewLine);
                            lsl.Append("         PSYS_PART_END_SCALE, <" + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndScaleX) + ", " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndScaleY) + ", 0>, " + Environment.NewLine);
                            lsl.Append("         PSYS_PART_MAX_AGE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartMaxAge) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_MAX_AGE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.MaxAge) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_ACCEL, " + exportPrim.ParticleSys.PartAcceleration.ToString() + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_BURST_PART_COUNT, " + String.Format("{0:0}", exportPrim.ParticleSys.BurstPartCount) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_BURST_RADIUS, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstRadius) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_BURST_RATE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstRate) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_BURST_SPEED_MIN, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstSpeedMin) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_BURST_SPEED_MAX, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstSpeedMax) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_INNERANGLE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.InnerAngle) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_OUTERANGLE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.OuterAngle) + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_OMEGA, " + exportPrim.ParticleSys.AngularVelocity.ToString() + "," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_TEXTURE, (key)\"" + exportPrim.ParticleSys.Texture.ToString() + "\"," + Environment.NewLine);
                            lsl.Append("         PSYS_SRC_TARGET_KEY, (key)\"" + exportPrim.ParticleSys.Target.ToString() + "\"" + Environment.NewLine);

                            lsl.Append("         ]);" + Environment.NewLine);
                            lsl.Append("    }" + Environment.NewLine);
                            lsl.Append("}" + Environment.NewLine);

                            #endregion Particle System to LSL

                            return(lsl.ToString());
                        }
                        else
                        {
                            return("Prim " + exportPrim.LocalID + " does not have a particle system");
                        }
                    }
                }
            }

            return("Couldn't find prim " + id.ToString());
        }
Ejemplo n.º 18
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 2 && !(args.Length == 1 && SelectedObject != LLUUID.Zero))
            {
                return("Usage: export uuid outputfile.xml");
            }

            LLUUID id;
            uint   localid;
            string file;

            if (args.Length == 2)
            {
                file = args[1];
                if (!LLUUID.TryParse(args[0], out id))
                {
                    return("Usage: export uuid outputfile.xml");
                }
            }
            else
            {
                file = args[0];
                id   = SelectedObject;
            }

            Primitive exportPrim;

            exportPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
                delegate(Primitive prim) { return(prim.ID == id); }
                );

            if (exportPrim != null)
            {
                if (exportPrim.ParentID != 0)
                {
                    localid = exportPrim.ParentID;
                }
                else
                {
                    localid = exportPrim.LocalID;
                }

                // Check for export permission first
                Client.Objects.RequestObjectPropertiesFamily(Client.Network.CurrentSim, id);
                GotPermissionsEvent.WaitOne(1000 * 10, false);

                if (!GotPermissions)
                {
                    return("Couldn't fetch permissions for the requested object, try again");
                }
                else
                {
                    GotPermissions = false;
                    if (Properties.OwnerID != Client.Self.AgentID &&
                        Properties.OwnerID != Client.MasterKey &&
                        Client.Self.AgentID != Client.Self.AgentID)
                    {
                        return("That object is owned by " + Properties.OwnerID + ", we don't have permission " +
                               "to export it");
                    }
                }

                List <Primitive> prims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(
                    delegate(Primitive prim)
                {
                    return(prim.LocalID == localid || prim.ParentID == localid);
                }
                    );

                bool complete = RequestObjectProperties(prims, 250);

                if (!complete)
                {
                    Logger.Log("Warning: Unable to retrieve full properties for:", Helpers.LogLevel.Warning, Client);
                    foreach (LLUUID uuid in PrimsWaiting.Keys)
                    {
                        Logger.Log(uuid.ToString(), Helpers.LogLevel.Warning, Client);
                    }
                }

                string output = LLSDParser.SerializeXmlString(Helpers.PrimListToLLSD(prims));
                try { File.WriteAllText(file, output); }
                catch (Exception e) { return(e.Message); }

                Logger.Log("Exported " + prims.Count + " prims to " + file, Helpers.LogLevel.Info, Client);

                // Create a list of all of the textures to download
                List <ImageRequest> textureRequests = new List <ImageRequest>();

                lock (Textures)
                {
                    for (int i = 0; i < prims.Count; i++)
                    {
                        Primitive prim = prims[i];

                        if (prim.Textures.DefaultTexture.TextureID != LLObject.TextureEntry.WHITE_TEXTURE &&
                            !Textures.Contains(prim.Textures.DefaultTexture.TextureID))
                        {
                            Textures.Add(prim.Textures.DefaultTexture.TextureID);
                        }

                        for (int j = 0; j < prim.Textures.FaceTextures.Length; j++)
                        {
                            if (prim.Textures.FaceTextures[j] != null &&
                                prim.Textures.FaceTextures[j].TextureID != LLObject.TextureEntry.WHITE_TEXTURE &&
                                !Textures.Contains(prim.Textures.FaceTextures[j].TextureID))
                            {
                                Textures.Add(prim.Textures.FaceTextures[j].TextureID);
                            }
                        }

                        if (prim.Sculpt.SculptTexture != LLUUID.Zero && !Textures.Contains(prim.Sculpt.SculptTexture))
                        {
                            Textures.Add(prim.Sculpt.SculptTexture);
                        }
                    }

                    // Create a request list from all of the images
                    for (int i = 0; i < Textures.Count; i++)
                    {
                        textureRequests.Add(new ImageRequest(Textures[i], ImageType.Normal, 1013000.0f, 0));
                    }
                }

                // Download all of the textures in the export list
                Client.Assets.RequestImages(textureRequests);

                return("XML exported, began downloading " + Textures.Count + " textures");
            }
            else
            {
                return("Couldn't find UUID " + id.ToString() + " in the " +
                       Client.Network.CurrentSim.ObjectsPrimitives.Count +
                       "objects currently indexed in the current simulator");
            }
        }
Ejemplo n.º 19
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
            {
                return("Usage: dumpoutfit [avatar-uuid]");
            }

            LLUUID target;

            if (!LLUUID.TryParse(args[0], out target))
            {
                return("Usage: dumpoutfit [avatar-uuid]");
            }

            lock (Client.Network.Simulators)
            {
                for (int i = 0; i < Client.Network.Simulators.Count; i++)
                {
                    Avatar targetAv;

                    targetAv = Client.Network.Simulators[i].Objects.Find(
                        delegate(Avatar avatar)
                    {
                        return(avatar.ID == target);
                    }
                        );

                    if (targetAv != null)
                    {
                        StringBuilder output = new StringBuilder("Downloading ");

                        lock (OutfitAssets) OutfitAssets.Clear();
                        Client.Assets.OnImageReceived += ImageReceivedHandler;

                        for (int j = 0; j < targetAv.Textures.FaceTextures.Length; j++)
                        {
                            LLObject.TextureEntryFace face = targetAv.Textures.FaceTextures[j];

                            if (face != null)
                            {
                                ImageType type = ImageType.Normal;

                                switch ((AppearanceManager.TextureIndex)j)
                                {
                                case AppearanceManager.TextureIndex.HeadBaked:
                                case AppearanceManager.TextureIndex.EyesBaked:
                                case AppearanceManager.TextureIndex.UpperBaked:
                                case AppearanceManager.TextureIndex.LowerBaked:
                                case AppearanceManager.TextureIndex.SkirtBaked:
                                    type = ImageType.Baked;
                                    break;
                                }

                                OutfitAssets.Add(face.TextureID);
                                Client.Assets.RequestImage(face.TextureID, type, 100000.0f, 0);

                                output.Append(((AppearanceManager.TextureIndex)j).ToString());
                                output.Append(" ");
                            }
                        }

                        return(output.ToString());
                    }
                }
            }

            return("Couldn't find avatar " + target.ToString());
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Converts byte[] data from a data transfer into a bodypart class
        /// </summary>
        /// <returns></returns>
        internal void UpdateFromAssetData()
        {
            if (AssetData == null || AssetData.Length == 0)
            {
                return;
            }

            string wearableData = Helpers.FieldToUTF8String(this._AssetData);

            int version = -1;
            int n       = -1;

            try
            {
                n            = wearableData.IndexOf('\n');
                version      = Int32.Parse(wearableData.Substring(19, n - 18));
                wearableData = wearableData.Remove(0, n);

                if (version != 22)
                {
                    Console.WriteLine("** WARNING ** : Wearable asset has unrecognized version " + version);
                    return;
                }

                n            = wearableData.IndexOf('\n');
                Name         = wearableData.Substring(0, n);
                wearableData = wearableData.Remove(0, n);

                n            = wearableData.IndexOf('\n');
                Description  = wearableData.Substring(0, n);
                wearableData = wearableData.Remove(0, n);

                // Split in to an upper and lower half
                string[] parts = wearableData.Split(new string[] { "parameters" }, StringSplitOptions.None);
                parts[1] = "parameters" + parts[1];

                // Parse the upper half
                string[] lines = parts[0].Split('\n');
                foreach (string thisline in lines)
                {
                    string   line   = thisline.Trim();
                    string[] fields = line.Split('\t');

                    if (fields.Length == 2)
                    {
                        if (fields[0] == "creator_mask")
                        {
                            // Deprecated, apply this as the base mask
                            _Permission_Base_Mask = UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (fields[0] == "base_mask")
                        {
                            _Permission_Base_Mask = UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (fields[0] == "owner_mask")
                        {
                            _Permission_Owner_Mask = UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (fields[0] == "group_mask")
                        {
                            _Permission_Group_Mask = UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (fields[0] == "everyone_mask")
                        {
                            _Permission_Everyone_Mask = UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (fields[0] == "next_owner_mask")
                        {
                            _Permission_Next_Owner_Mask = UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (fields[0] == "creator_id")
                        {
                            _Creator_ID = new LLUUID(fields[1]);
                        }
                        else if (fields[0] == "owner_id")
                        {
                            _Owner_ID = new LLUUID(fields[1]);
                        }
                        else if (fields[0] == "last_owner_id")
                        {
                            _Last_Owner_ID = new LLUUID(fields[1]);
                        }
                        else if (fields[0] == "group_id")
                        {
                            _Group_ID = new LLUUID(fields[1]);
                        }
                        else if (fields[0] == "group_owned")
                        {
                            _Group_Owned = (Int32.Parse(fields[1]) != 0);
                        }
                        else if (fields[0] == "sale_type")
                        {
                            for (int i = 0; i < _ForSaleNames.Length; i++)
                            {
                                if (fields[1] == _ForSaleNames[i])
                                {
                                    _Sale = (_ForSale)i;
                                    break;
                                }
                            }
                        }
                        else if (fields[0] == "sale_price")
                        {
                            _Sale_Price = UInt32.Parse(fields[1]);
                        }
                        else if (fields[0] == "perm_mask")
                        {
                            Console.WriteLine("** WARNING ** : Wearable asset has deprecated perm_mask field, ignoring");
                        }
                    }
                    else if (line.StartsWith("type "))
                    {
                        AppearanceLayer = (AppearanceLayerType)Int32.Parse(line.Substring(5));
                        break;
                    }
                }

                // Break up the lower half in to parameters and textures
                string[] lowerparts = parts[1].Split(new string[] { "textures" }, StringSplitOptions.None);
                lowerparts[1] = "textures" + lowerparts[1];

                // Parse the parameters
                lines = lowerparts[0].Split('\n');
                foreach (string line in lines)
                {
                    string[] fields = line.Split(' ');

                    int id;
                    if (Int32.TryParse(fields[0], out id) == false)
                    {
                        continue; // Not interested in this line
                    }

                    float weight = 0.0f;
                    Single.TryParse(fields[1], System.Globalization.NumberStyles.Float,
                                    Helpers.EnUsCulture.NumberFormat, out weight);
                    _Parameters[id] = weight;
                }

                // Parse the textures
                lines = lowerparts[1].Split('\n');
                foreach (string line in lines)
                {
                    string[] fields = line.Split(' ');

                    uint id;
                    if (UInt32.TryParse(fields[0], out id) == false)
                    {
                        continue; // Not interested in this line
                    }

                    LLUUID texture;

                    if (LLUUID.TryParse(fields[1], out texture) == false)
                    {
                        continue; // if it won't parse, ignore and continue
                    }

                    _Textures[id] = texture;
                }

                return;
            }
            catch (Exception e)
            {
                Console.WriteLine("** WARNING **", "Failed to parse wearable asset: " + e.ToString());
            }

            return;
        }
Ejemplo n.º 21
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 2 && !(args.Length == 1 && SelectedObject != LLUUID.Zero))
            {
                return("Usage: export uuid outputfile.xml");
            }

            LLUUID id;
            uint   localid;
            string file;

            if (args.Length == 2)
            {
                file = args[1];
                if (!LLUUID.TryParse(args[0], out id))
                {
                    return("Usage: export uuid outputfile.xml");
                }
            }
            else
            {
                file = args[0];
                id   = SelectedObject;
            }

            Primitive exportPrim;

            exportPrim = Client.Network.CurrentSim.Objects.Find(
                delegate(Primitive prim) { return(prim.ID == id); }
                );

            if (exportPrim != null)
            {
                if (exportPrim.ParentID != 0)
                {
                    localid = exportPrim.ParentID;
                }
                else
                {
                    localid = exportPrim.LocalID;
                }

                // Check for export permission first
                Client.Objects.RequestObjectPropertiesFamily(Client.Network.CurrentSim, id);
                GotPermissionsEvent.WaitOne(1000 * 10, false);

                if (!GotPermissions)
                {
                    return("Couldn't fetch permissions for the requested object, try again");
                }
                else
                {
                    GotPermissions = false;
                    if (Properties.OwnerID != Client.Self.AgentID &&
                        Properties.OwnerID != Client.MasterKey &&
                        Client.Self.AgentID != Client.Self.AgentID)
                    {
                        return("That object is owned by " + Properties.OwnerID + ", we don't have permission " +
                               "to export it");
                    }
                }

                List <Primitive> prims = Client.Network.CurrentSim.Objects.FindAll(
                    delegate(Primitive prim)
                {
                    return(prim.LocalID == localid || prim.ParentID == localid);
                }
                    );

                bool complete = RequestObjectProperties(prims, 250);

                if (!complete)
                {
                    Console.WriteLine("Warning: Unable to retrieve full properties for:");
                    foreach (LLUUID uuid in PrimsWaiting.Keys)
                    {
                        Console.WriteLine(uuid);
                    }
                }

                string output = LLSDParser.SerializeXmlString(Helpers.PrimListToLLSD(prims));
                try { File.WriteAllText(file, output); }
                catch (Exception e) { return(e.Message); }

                return("Exported " + prims.Count + " prims to " + file);
            }
            else
            {
                return("Couldn't find UUID " + id.ToString() + " in the " +
                       Client.Network.CurrentSim.Objects.PrimCount +
                       "objects currently indexed in the current simulator");
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private static LLSD DeserializeNotationElement(StringReader reader)
        {
            int character = ReadAndSkipWhitespace(reader);

            if (character < 0)
            {
                return(new LLSD()); // server returned an empty file, so we're going to pass along a null LLSD object
            }
            LLSD llsd;
            int  matching;

            switch ((char)character)
            {
            case undefNotationValue:
                llsd = new LLSD();
                break;

            case trueNotationValueOne:
                llsd = LLSD.FromBoolean(true);
                break;

            case trueNotationValueTwo:
                matching = BufferCharactersEqual(reader, trueNotationValueTwoFull, 1);
                if (matching > 1 && matching < trueNotationValueTwoFull.Length)
                {
                    throw new LLSDException("Notation LLSD parsing: True value parsing error:");
                }
                llsd = LLSD.FromBoolean(true);
                break;

            case trueNotationValueThree:
                matching = BufferCharactersEqual(reader, trueNotationValueThreeFull, 1);
                if (matching > 1 && matching < trueNotationValueThreeFull.Length)
                {
                    throw new LLSDException("Notation LLSD parsing: True value parsing error:");
                }
                llsd = LLSD.FromBoolean(true);
                break;

            case falseNotationValueOne:
                llsd = LLSD.FromBoolean(false);
                break;

            case falseNotationValueTwo:
                matching = BufferCharactersEqual(reader, falseNotationValueTwoFull, 1);
                if (matching > 1 && matching < falseNotationValueTwoFull.Length)
                {
                    throw new LLSDException("Notation LLSD parsing: True value parsing error:");
                }
                llsd = LLSD.FromBoolean(false);
                break;

            case falseNotationValueThree:
                matching = BufferCharactersEqual(reader, falseNotationValueThreeFull, 1);
                if (matching > 1 && matching < falseNotationValueThreeFull.Length)
                {
                    throw new LLSDException("Notation LLSD parsing: True value parsing error:");
                }
                llsd = LLSD.FromBoolean(false);
                break;

            case integerNotationMarker:
                llsd = DeserializeNotationInteger(reader);
                break;

            case realNotationMarker:
                llsd = DeserializeNotationReal(reader);
                break;

            case uuidNotationMarker:
                char[] uuidBuf = new char[36];
                if (reader.Read(uuidBuf, 0, 36) < 36)
                {
                    throw new LLSDException("Notation LLSD parsing: Unexpected end of stream in UUID.");
                }
                LLUUID lluuid;
                if (!LLUUID.TryParse(new String(uuidBuf), out lluuid))
                {
                    throw new LLSDException("Notation LLSD parsing: Invalid UUID discovered.");
                }
                llsd = LLSD.FromUUID(lluuid);
                break;

            case binaryNotationMarker:
                byte[] bytes = new byte[0];
                int    bChar = reader.Peek();
                if (bChar < 0)
                {
                    throw new LLSDException("Notation LLSD parsing: Unexpected end of stream in binary.");
                }
                if ((char)bChar == sizeBeginNotationMarker)
                {
                    throw new LLSDException("Notation LLSD parsing: Raw binary encoding not supported.");
                }
                else if (Char.IsDigit((char)bChar))
                {
                    char[] charsBaseEncoding = new char[2];
                    if (reader.Read(charsBaseEncoding, 0, 2) < 2)
                    {
                        throw new LLSDException("Notation LLSD parsing: Unexpected end of stream in binary.");
                    }
                    int baseEncoding;
                    if (!Int32.TryParse(new String(charsBaseEncoding), out baseEncoding))
                    {
                        throw new LLSDException("Notation LLSD parsing: Invalid binary encoding base.");
                    }
                    if (baseEncoding == 64)
                    {
                        if (reader.Read() < 0)
                        {
                            throw new LLSDException("Notation LLSD parsing: Unexpected end of stream in binary.");
                        }
                        string bytes64 = GetStringDelimitedBy(reader, doubleQuotesNotationMarker);
                        bytes = Convert.FromBase64String(bytes64);
                    }
                    else
                    {
                        throw new LLSDException("Notation LLSD parsing: Encoding base" + baseEncoding + " + not supported.");
                    }
                }
                llsd = LLSD.FromBinary(bytes);
                break;

            case stringNotationMarker:
                int numChars = GetLengthInBrackets(reader);
                if (reader.Read() < 0)
                {
                    throw new LLSDException("Notation LLSD parsing: Unexpected end of stream in string.");
                }
                char[] chars = new char[numChars];
                if (reader.Read(chars, 0, numChars) < numChars)
                {
                    throw new LLSDException("Notation LLSD parsing: Unexpected end of stream in string.");
                }
                if (reader.Read() < 0)
                {
                    throw new LLSDException("Notation LLSD parsing: Unexpected end of stream in string.");
                }
                llsd = LLSD.FromString(new String(chars));
                break;

            case singleQuotesNotationMarker:
                string sOne = GetStringDelimitedBy(reader, singleQuotesNotationMarker);
                llsd = LLSD.FromString(sOne);
                break;

            case doubleQuotesNotationMarker:
                string sTwo = GetStringDelimitedBy(reader, doubleQuotesNotationMarker);
                llsd = LLSD.FromString(sTwo);
                break;

            case uriNotationMarker:
                if (reader.Read() < 0)
                {
                    throw new LLSDException("Notation LLSD parsing: Unexpected end of stream in string.");
                }
                string sUri = GetStringDelimitedBy(reader, doubleQuotesNotationMarker);

                Uri uri;
                try
                {
                    uri = new Uri(sUri, UriKind.RelativeOrAbsolute);
                }
                catch
                {
                    throw new LLSDException("Notation LLSD parsing: Invalid Uri format detected.");
                }
                llsd = LLSD.FromUri(uri);
                break;

            case dateNotationMarker:
                if (reader.Read() < 0)
                {
                    throw new LLSDException("Notation LLSD parsing: Unexpected end of stream in date.");
                }
                string   date = GetStringDelimitedBy(reader, doubleQuotesNotationMarker);
                DateTime dt;
                if (!Helpers.TryParse(date, out dt))
                {
                    throw new LLSDException("Notation LLSD parsing: Invalid date discovered.");
                }
                llsd = LLSD.FromDate(dt);
                break;

            case arrayBeginNotationMarker:
                llsd = DeserializeNotationArray(reader);
                break;

            case mapBeginNotationMarker:
                llsd = DeserializeNotationMap(reader);
                break;

            default:
                throw new LLSDException("Notation LLSD parsing: Unknown type marker '" + (char)character + "'.");
            }
            return(llsd);
        }
Ejemplo n.º 23
0
        private static LLSD ParseXmlElement(XmlTextReader reader)
        {
            SkipWhitespace(reader);

            if (reader.NodeType != XmlNodeType.Element)
            {
                throw new LLSDException("Expected an element");
            }

            string type = reader.LocalName;
            LLSD   ret;

            switch (type)
            {
            case "undef":
                if (reader.IsEmptyElement)
                {
                    reader.Read();
                    return(new LLSD());
                }

                reader.Read();
                SkipWhitespace(reader);
                ret = new LLSD();
                break;

            case "boolean":
                if (reader.IsEmptyElement)
                {
                    reader.Read();
                    return(LLSD.FromBoolean(false));
                }

                if (reader.Read())
                {
                    string s = reader.ReadString().Trim();

                    if (!String.IsNullOrEmpty(s) && (s == "true" || s == "1"))
                    {
                        ret = LLSD.FromBoolean(true);
                        break;
                    }
                }

                ret = LLSD.FromBoolean(false);
                break;

            case "integer":
                if (reader.IsEmptyElement)
                {
                    reader.Read();
                    return(LLSD.FromInteger(0));
                }

                if (reader.Read())
                {
                    int value = 0;
                    Helpers.TryParse(reader.ReadString().Trim(), out value);
                    ret = LLSD.FromInteger(value);
                    break;
                }

                ret = LLSD.FromInteger(0);
                break;

            case "real":
                if (reader.IsEmptyElement)
                {
                    reader.Read();
                    return(LLSD.FromReal(0d));
                }

                if (reader.Read())
                {
                    double value = 0d;
                    string str   = reader.ReadString().Trim().ToLower();

                    if (str == "nan")
                    {
                        value = Double.NaN;
                    }
                    else
                    {
                        Helpers.TryParse(str, out value);
                    }

                    ret = LLSD.FromReal(value);
                    break;
                }

                ret = LLSD.FromReal(0d);
                break;

            case "uuid":
                if (reader.IsEmptyElement)
                {
                    reader.Read();
                    return(LLSD.FromUUID(LLUUID.Zero));
                }

                if (reader.Read())
                {
                    LLUUID value = LLUUID.Zero;
                    LLUUID.TryParse(reader.ReadString().Trim(), out value);
                    ret = LLSD.FromUUID(value);
                    break;
                }

                ret = LLSD.FromUUID(LLUUID.Zero);
                break;

            case "date":
                if (reader.IsEmptyElement)
                {
                    reader.Read();
                    return(LLSD.FromDate(Helpers.Epoch));
                }

                if (reader.Read())
                {
                    DateTime value = Helpers.Epoch;
                    Helpers.TryParse(reader.ReadString().Trim(), out value);
                    ret = LLSD.FromDate(value);
                    break;
                }

                ret = LLSD.FromDate(Helpers.Epoch);
                break;

            case "string":
                if (reader.IsEmptyElement)
                {
                    reader.Read();
                    return(LLSD.FromString(String.Empty));
                }

                if (reader.Read())
                {
                    ret = LLSD.FromString(reader.ReadString());
                    break;
                }

                ret = LLSD.FromString(String.Empty);
                break;

            case "binary":
                if (reader.IsEmptyElement)
                {
                    reader.Read();
                    return(LLSD.FromBinary(new byte[0]));
                }

                if (reader.GetAttribute("encoding") != null && reader.GetAttribute("encoding") != "base64")
                {
                    throw new LLSDException("Unsupported binary encoding: " + reader.GetAttribute("encoding"));
                }

                if (reader.Read())
                {
                    try
                    {
                        ret = LLSD.FromBinary(Convert.FromBase64String(reader.ReadString().Trim()));
                        break;
                    }
                    catch (FormatException ex)
                    {
                        throw new LLSDException("Binary decoding exception: " + ex.Message);
                    }
                }

                ret = LLSD.FromBinary(new byte[0]);
                break;

            case "uri":
                if (reader.IsEmptyElement)
                {
                    reader.Read();
                    return(LLSD.FromUri(new Uri(String.Empty, UriKind.RelativeOrAbsolute)));
                }

                if (reader.Read())
                {
                    ret = LLSD.FromUri(new Uri(reader.ReadString(), UriKind.RelativeOrAbsolute));
                    break;
                }

                ret = LLSD.FromUri(new Uri(String.Empty, UriKind.RelativeOrAbsolute));
                break;

            case "map":
                return(ParseXmlMap(reader));

            case "array":
                return(ParseXmlArray(reader));

            default:
                reader.Read();
                ret = null;
                break;
            }

            if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != type)
            {
                throw new LLSDException("Expected </" + type + ">");
            }
            else
            {
                reader.Read();
                return(ret);
            }
        }
Ejemplo n.º 24
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");
        }
Ejemplo n.º 25
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
            {
                return(Description);
            }

            groupName         = String.Empty;
            resolvedGroupID   = LLUUID.Zero;
            resolvedGroupName = String.Empty;

            if (args[0].ToLower() == "uuid")
            {
                if (args.Length < 2)
                {
                    return(Description);
                }

                if (!LLUUID.TryParse((resolvedGroupName = groupName = args[1]), out resolvedGroupID))
                {
                    return(resolvedGroupName + " doesn't seem a valid UUID");
                }
            }
            else
            {
                for (int i = 0; i < args.Length; i++)
                {
                    groupName += args[i] + " ";
                }
                groupName = groupName.Trim();
                DirectoryManager.DirGroupsReplyCallback callback = new DirectoryManager.DirGroupsReplyCallback(Directory_OnDirGroupsReply);
                Client.Directory.OnDirGroupsReply += callback;
                queryID = Client.Directory.StartGroupSearch(DirectoryManager.DirFindFlags.Groups, groupName, 0);

                GetGroupsSearchEvent.WaitOne(60000, false);

                Client.Directory.OnDirGroupsReply -= callback;
                GetGroupsSearchEvent.Reset();
            }

            if (resolvedGroupID == LLUUID.Zero)
            {
                if (string.IsNullOrEmpty(resolvedGroupName))
                {
                    return("Unable to obtain UUID for group " + groupName);
                }
                else
                {
                    return(resolvedGroupName);
                }
            }

            GroupManager.GroupJoinedCallback gcallback = new GroupManager.GroupJoinedCallback(Groups_OnGroupJoined);
            Client.Groups.OnGroupJoined += gcallback;
            Client.Groups.RequestJoinGroup(resolvedGroupID);

            /* A.Biondi
             * TODO: implement the pay to join procedure.
             */

            GetGroupsSearchEvent.WaitOne(60000, false);

            Client.Groups.OnGroupJoined -= gcallback;
            GetGroupsSearchEvent.Reset();

            if (joinedGroup)
            {
                return("Joined the group " + resolvedGroupName);
            }
            return("Unable to join the group " + resolvedGroupName);
        }