public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
                return "Usage: findsim [Simulator Name]";

            // Build the simulator name from the args list
            string simName = string.Empty;
            for (int i = 0; i < args.Length; i++)
                simName += args[i] + " ";
            simName = simName.TrimEnd().ToLower();

            //if (!GridDataCached[Client])
            //{
            //    Client.Grid.RequestAllSims(GridManager.MapLayerType.Objects);
            //    System.Threading.Thread.Sleep(5000);
            //    GridDataCached[Client] = true;
            //}

            GridRegion region;

            if (Client.Grid.GetGridRegion(simName, GridLayerType.Objects, out region))
                return String.Format("{0}: handle={1} ({2},{3})", region.Name, region.RegionHandle, region.X, region.Y);
            else
                return "Lookup of " + simName + " failed";
        }
Exemple #2
0
        public override string Execute(string[] args, LLUUID fromAgentID)
		{
            Primitive closest = null;
		    double closestDistance = Double.MaxValue;

		    lock (Client.SimPrims)
		    {
                if (Client.SimPrims.ContainsKey(Client.Network.CurrentSim))
                {
                    foreach (Primitive p in Client.SimPrims[Client.Network.CurrentSim].Values)
                    {
                        float distance = Helpers.VecDist(Client.Self.Position, p.Position);

                        if (closest == null || distance < closestDistance)
                        {
                            closest = p;
                            closestDistance = distance;
                        }
                    }
                }
		    }

            if (closest != null)
            {
                Client.Self.RequestSit(closest.ID, LLVector3.Zero);
                Client.Self.Sit();

                return "Sat on " + closest.ID + ". Distance: " + closestDistance;
            }
            else
            {
                return "Couldn't find a nearby prim to sit on";
            }
		}
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
                return "Usage: debug [level] where level is one of None, Debug, Error, Info, Warn";

            if (args[0].ToLower() == "debug")
            {
                Settings.LOG_LEVEL = Helpers.LogLevel.Debug;
                return "Logging is set to Debug";
            }
            else if (args[0].ToLower() == "none")
            {
                Settings.LOG_LEVEL = Helpers.LogLevel.None;
                return "Logging is set to None";
            }
            else if (args[0].ToLower() == "warn")
            {
                Settings.LOG_LEVEL = Helpers.LogLevel.Warning;
                return "Logging is set to level Warning";
            }
            else if (args[0].ToLower() == "info")
            {
                Settings.LOG_LEVEL = Helpers.LogLevel.Info;
                return "Logging is set to level Info";
            }
            else if (args[0].ToLower() == "error")
            {
                Settings.LOG_LEVEL = Helpers.LogLevel.Error;
                return "Logging is set to level Error";
            }
            else
            {
                return "Usage: debug [level] where level is one of None, Debug, Error, Info, Warn";
            }
        }
Exemple #4
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.Objects.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];
        }
        void Groups_OnGroupLeft(LLUUID groupID, bool success)
        {
            Console.WriteLine(Client.ToString() + (success ? " has left group " : " failed to left group ") + groupID.ToString());

            leftGroup = success;
            GroupsEvent.Set();
        }
        public SimProfile LoadFromGrid(LLUUID UUID, string GridURL, string SendKey, string RecvKey)
        {
            try
            {
                Hashtable GridReqParams = new Hashtable();
                GridReqParams["UUID"] = UUID.ToString();
                GridReqParams["authkey"] = SendKey;
                ArrayList SendParams = new ArrayList();
                SendParams.Add(GridReqParams);
                XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);

                XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);

                Hashtable RespData = (Hashtable)GridResp.Value;
                this.UUID = new LLUUID((string)RespData["UUID"]);
                this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
                this.regionname = (string)RespData["regionname"];
                this.sim_ip = (string)RespData["sim_ip"];
                this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
                this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
                this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
                this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
                this.sendkey = SendKey;
                this.recvkey = RecvKey;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            return this;
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            ulong regionHandle;

            if (args.Length == 0)
                regionHandle = Client.Network.CurrentSim.Handle;
            else if (!(args.Length == 1 && UInt64.TryParse(args[0], out regionHandle)))
                return "Usage: agentlocations [regionhandle]";

            List<GridItem> items = Client.Grid.MapItems(regionHandle, GridItemType.AgentLocations, 
                GridLayerType.Objects, 1000 * 20);

            if (items != null)
            {
                StringBuilder ret = new StringBuilder();
                ret.AppendLine("Agent locations:");

                for (int i = 0; i < items.Count; i++)
                {
                    GridAgentLocation location = (GridAgentLocation)items[i];

                    ret.AppendLine(String.Format("{0} avatar(s) at {1},{2}", location.AvatarCount, location.LocalX,
                        location.LocalY));
                }

                return ret.ToString();
            }
            else
            {
                return "Failed to fetch agent locations";
            }
        }
        private void DoUpload(byte[] UploadData, string FileName)
        {
            if (UploadData != null)
            {
                string name = System.IO.Path.GetFileNameWithoutExtension(FileName);

                Client.Inventory.RequestCreateItemFromAsset(UploadData, name, "Uploaded with TestClient",
                    AssetType.Texture, InventoryType.Texture, Client.Inventory.FindFolderForType(AssetType.Texture),

                    delegate(CapsClient client, long bytesReceived, long bytesSent, long totalBytesToReceive, long totalBytesToSend)
                    {
                        if (bytesSent > 0)
                            Console.WriteLine(String.Format("Texture upload: {0} / {1}", bytesSent, totalBytesToSend));
                    },

                    delegate(bool success, string status, LLUUID itemID, LLUUID assetID)
                    {
                        Console.WriteLine(String.Format(
                            "RequestCreateItemFromAsset() returned: Success={0}, Status={1}, ItemID={2}, AssetID={3}",
                            success, status, itemID, assetID));

                        TextureID = assetID;
                        Console.WriteLine(String.Format("Upload took {0}", DateTime.Now.Subtract(start)));
                        UploadCompleteEvent.Set();
                    }
                );
            }
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            // parse the command line
            string target = String.Empty;
            for (int ct = 0; ct < args.Length; ct++)
                target = target + args[ct] + " ";
            target = target.TrimEnd();

            // initialize results list
            List<InventoryBase> found = new List<InventoryBase>();
            try
            {
                // find the folder
                found = Client.Inventory.LocalFind(Client.Inventory.Store.RootFolder.UUID, target.Split('/'), 0, true);
                if (found.Count.Equals(1))
                {
                    // move the folder to the trash folder
                    Client.Inventory.MoveFolder(found[0].UUID, Client.Inventory.FindFolderForType(AssetType.TrashFolder));
                    return String.Format("Moved folder {0} to Trash", found[0].Name);
                }
            }
            catch (InvalidOutfitException ex)
            {
                return "Folder Not Found: (" + ex.Message + ")";
            }
            return string.Empty;
		}
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
                return "Usage: parceldetails parcelID (use parcelinfo to get ID)";

            int parcelID;
            Parcel parcel;

            // test argument that is is a valid integer, then verify we have that parcel data stored in the dictionary
            if (Int32.TryParse(args[0], out parcelID) && Client.Network.CurrentSim.Parcels.TryGetValue(parcelID, out parcel))
            {
                // this request will update the parcels dictionary
                Client.Parcels.PropertiesRequest(Client.Network.CurrentSim, parcelID, 0);
                
                // Use reflection to dynamically get the fields from the Parcel struct
                Type t = parcel.GetType();
                System.Reflection.FieldInfo[] fields = t.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);

                StringBuilder sb = new StringBuilder();
                foreach (System.Reflection.FieldInfo field in fields)
                {
                    sb.AppendFormat("{0} = {1}" + System.Environment.NewLine, field.Name, field.GetValue(parcel));
                }
                return sb.ToString();
            }
            else
            {
                return String.Format("Unable to find Parcel {0} in Parcels Dictionary, Did you run parcelinfo to populate the dictionary first?", args[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 override string Execute(string[] args, LLUUID fromAgentID)
        {
            Client.MasterKey = LLUUID.Parse(args[0]);

            lock (Client.Network.Simulators)
            {
                for (int i = 0; i < Client.Network.Simulators.Count; i++)
                {
                    Avatar master = Client.Network.Simulators[i].ObjectsAvatars.Find(
                        delegate(Avatar avatar)
                        {
                            return avatar.ID == Client.MasterKey;
                        }
                    );

                    if (master != null)
                    {
                        Client.Self.InstantMessage(master.ID,
                            "You are now my master. IM me with \"help\" for a command list.");
                        break;
                    }
                }
            }

            return "Master set to " + Client.MasterKey.ToString();
        }
        static void Main(string[] args)
        {
            SecondLife client = new SecondLife();
            if (args.Length < 4)
            {
                Console.WriteLine("Usage: Key2Name [loginfirstname] [loginlastname] [password] [key]");
                return;
            }
            Console.WriteLine("Attempting to connect and login to Second Life.");

            // Setup Login to Second Life
            Dictionary<string, object> loginParams = client.Network.DefaultLoginValues(args[0],
                args[1], args[2], "00:00:00:00:00:00", "last", "Win", "0", "key2name",
                "*****@*****.**");
            Dictionary<string, object> loginReply = new Dictionary<string, object>();
            if (!client.Network.Login(loginParams))
            {
                // Login failed
                Console.WriteLine("Error logging in: " + client.Network.LoginError);
                return;
            }
            AvatarTracker avatarTracker = new AvatarTracker(client);
            LLUUID lookup = new LLUUID(args[3]);
            Console.WriteLine("Looking up name for " + lookup.ToStringHyphenated());
            string name = avatarTracker.GetAvatarName(lookup);
            Console.WriteLine("Name: " + name + ". Press enter to logout.");
            Console.ReadLine();
            client.Network.Logout();
        }
        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.ObjectsPrimitives.ForEach(
                    delegate(Primitive prim)
                    {
                        if (prim.Textures != null && prim.Textures.FaceTextures[faceIndex] != null)
                        {
                            if (prim.Textures.FaceTextures[faceIndex].TextureID == textureID)
                            {
                                Logger.Log(String.Format("Primitive {0} ({1}) has face index {2} set to {3}",
                                    prim.ID.ToString(), prim.LocalID, faceIndex, textureID.ToString()),
                                    Helpers.LogLevel.Info, Client);
                            }
                        }
                    }
                );

                return "Done searching";
            }
            else
            {
                return "Usage: findtexture [face-index] [texture-uuid]";
            }
        }
 public void AddUpload(LLUUID transactionID, AssetBase asset)
 {
     AssetTransaction upload = new AssetTransaction();
     lock (this.transactions)
     {
         upload.Asset = asset;
         upload.TransactionID = transactionID;
         this.transactions.Add(transactionID, upload);
     }
     if (upload.Asset.Data.Length > 2)
     {
         //is complete
         upload.UploadComplete = true;
         AssetUploadCompletePacket response = new AssetUploadCompletePacket();
         response.AssetBlock.Type = asset.Type;
         response.AssetBlock.Success = true;
         response.AssetBlock.UUID = transactionID.Combine(this.ourClient.SecureSessionID);
         this.ourClient.OutPacket(response);
         m_assetCache.AddAsset(asset);
     }
     else
     {
         upload.UploadComplete = false;
         upload.XferID = Util.GetNextXferID();
         RequestXferPacket xfer = new RequestXferPacket();
         xfer.XferID.ID = upload.XferID;
         xfer.XferID.VFileType = upload.Asset.Type;
         xfer.XferID.VFileID = transactionID.Combine(this.ourClient.SecureSessionID);
         xfer.XferID.FilePath = 0;
         xfer.XferID.Filename = new byte[0];
         this.ourClient.OutPacket(xfer);
     }
 }
Exemple #16
0
        static void Main(string[] args)
        {
            if (args.Length < 4)
            {
                Console.WriteLine("Usage: Key2Name [loginfirstname] [loginlastname] [password] [key]");
                return;
            }

            SecondLife client = new SecondLife();
            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;
            }

            AvatarTracker avatarTracker = new AvatarTracker(client);

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

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

            string name = avatarTracker.GetAvatarName(lookup);

            Console.WriteLine("Name: " + name + Environment.NewLine + "Press enter to logout.");
            Console.ReadLine();

            client.Network.Logout();
        }
        public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName, InstantMessageEventArgs e)
        {
            IMTabWindow imTab = this.AddIMTab(target, session, targetName);
            imTab.TextManager.PassIMEvent(e);

            return imTab;
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            string inventoryName;
            uint timeout;
            string fileName;

            if (args.Length != 3)
                return "Usage: uploadimage [inventoryname] [timeout] [filename]";

            TextureID = LLUUID.Zero;
            inventoryName = args[0];
            fileName = args[2];
            if (!UInt32.TryParse(args[1], out timeout))
                return "Usage: uploadimage [inventoryname] [timeout] [filename]";

            Console.WriteLine("Loading image " + fileName);
            byte[] jpeg2k = LoadImage(fileName);
            if (jpeg2k == null)
                return "Failed to compress image to JPEG2000";
            Console.WriteLine("Finished compressing image to JPEG2000, uploading...");
            start = DateTime.Now;
            DoUpload(jpeg2k, inventoryName);

            if (UploadCompleteEvent.WaitOne((int)timeout, false))
            {
                return String.Format("Texture upload {0}: {1}", (TextureID != LLUUID.Zero) ? "succeeded" : "failed",
                    TextureID);
            }
            else
            {
                return "Texture upload timed out";
            }
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
		{
		    if (args.Length == 1)
		    {
		        try
		        {
		            string treeName = args[0].Trim(new char[] { ' ' });
		            Tree tree = (Tree)Enum.Parse(typeof(Tree), treeName);

		            LLVector3 treePosition = Client.Self.SimPosition;
		            treePosition.Z += 3.0f;

		            Client.Objects.AddTree(Client.Network.CurrentSim, new LLVector3(0.5f, 0.5f, 0.5f),
		                LLQuaternion.Identity, treePosition, tree, Client.GroupID, false);

		            return "Attempted to rez a " + treeName + " tree";
		        }
		        catch (Exception)
		        {
		            return "Type !tree for usage";
		        }
		    }

		    string usage = "Usage: !tree [";
		    foreach (string value in Enum.GetNames(typeof(Tree)))
		    {
		        usage += value + ",";
		    }
		    usage = usage.TrimEnd(new char[] { ',' });
		    usage += "]";
		    return usage;
		}
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
                return "Usage: findsim [Simulator Name]";

            string simName = string.Empty;
            for (int i = 0; i < args.Length; i++)
                simName += args[i] + " ";
            simName = simName.TrimEnd().ToLower();

            if (!GridDataCached.ContainsKey(Client))
            {
                GridDataCached[Client] = false;
            }

            if (!GridDataCached[Client])
            {
                Client.Grid.AddAllSims();
                System.Threading.Thread.Sleep(5000);
                GridDataCached[Client] = true;
            }

            int attempts = 0;
            GridRegion region = null;
            while (region == null && attempts++ < 5)
            {
                region = Client.Grid.GetGridRegion(simName);
            }

            if (region != null)
                return "Found " + region.Name + ": handle=" + region.RegionHandle +
                    "(" + region.X + "," + region.Y + ")";
            else
                return "Lookup of " + simName + " failed";
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
                return "Usage: wear [outfit name] eg: 'wear /My Outfit/Dance Party";

            string target = String.Empty;
            bool bake = true;

            for (int ct = 0; ct < args.Length; ct++)
            {
                if (args[ct].Equals("nobake"))
                    bake = false;
                else
                    target = target + args[ct] + " ";
            }
            
            target = target.TrimEnd();

            try
            {
                Client.Appearance.WearOutfit(target.Split('/'), bake);
            }
            catch (InvalidOutfitException ex)
            {
                return "Invalid outfit (" + ex.Message + ")";
            }

            return String.Empty;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="fromAgentID"></param>
        /// <param name="imSessionID"></param>
        public void DoCommandAll(string cmd, LLUUID fromAgentID, LLUUID imSessionID)
        {
            string[] tokens = cmd.Trim().Split(new char[] { ' ', '\t' });
            string firstToken = tokens[0].ToLower();

            if (tokens.Length == 0)
                return;

            if (firstToken == "login")
            {
                // Special login case: Only call it once, and allow it with
                // no logged in avatars
                string[] args = new string[tokens.Length - 1];
                Array.Copy(tokens, 1, args, 0, args.Length);
                Login(args);
            }
            else if (firstToken == "quit")
            {
                Quit();
                Console.WriteLine("All clients logged out and program finished running.");
            }
            else
            {
                // make a copy of the clients list so that it can be iterated without fear of being changed during iteration
                Dictionary<LLUUID, SecondLife> clientsCopy = new Dictionary<LLUUID, SecondLife>(Clients);

                foreach (TestClient client in clientsCopy.Values)
                    client.DoCommand(cmd, fromAgentID, imSessionID);
            }
        }
Exemple #23
0
        public override string Execute(string[] args, LLUUID fromAgentID)
		{
			if (args.Length < 1)
                return "usage: Destination should be specified as sim/x/y/z";

            string destination = String.Empty;

            // Handle multi-word sim names by combining the arguments
            foreach (string arg in args)
            {
                destination += arg + " ";
            }
            destination = destination.Trim();

            string[] tokens = destination.Split(new char[] { '/' });
            if (tokens.Length != 4)
                return "usage: Destination should be specified as sim/x/y/z";

            string sim = tokens[0];
			float x = Client.Self.Position.X;
			float y = Client.Self.Position.Y;
			float z = Client.Self.Position.Z;
            float.TryParse(tokens[1], out x);
            float.TryParse(tokens[2], out y);
            float.TryParse(tokens[3], out z);

            if (Client.Self.Teleport(sim, new LLVector3(x, y, z)))
            {
                return "Teleported to " + Client.Network.CurrentSim;
            }
            else
            {
                return "Teleport failed: " + Client.Self.TeleportMessage;
            }
		}
 public override string Execute(string[] args, LLUUID fromAgentID)
 {
     if (args.Length == 0)
     {
         ShowEffects = true;
         return "Viewer effects will be shown on the console";
     }
     else if (args.Length == 1)
     {
         if (args[0] == "on")
         {
             ShowEffects = true;
             return "Viewer effects will be shown on the console";
         }
         else
         {
             ShowEffects = false;
             return "Viewer effects will not be shown";
         }
     }
     else
     {
         return "Usage: showeffects [on/off]";
     }
 }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            StringBuilder output = new StringBuilder();
            output.AppendLine(Client.Network.CurrentSim.ToString());
            output.Append("UUID: ");
            output.AppendLine(Client.Network.CurrentSim.ID.ToStringHyphenated());
            uint x, y;
            Helpers.LongToUInts(Client.Network.CurrentSim.Handle, out x, out y);
            output.AppendLine(String.Format("Handle: {0} (X: {1} Y: {2})", Client.Network.CurrentSim.Handle, x, y));
            output.Append("Access: ");
            output.AppendLine(Client.Network.CurrentSim.Access.ToString());
            output.Append("Flags: ");
            output.AppendLine(Client.Network.CurrentSim.Flags.ToString());
            output.Append("TerrainBase0: ");
            output.AppendLine(Client.Network.CurrentSim.TerrainBase0.ToStringHyphenated());
            output.Append("TerrainBase1: ");
            output.AppendLine(Client.Network.CurrentSim.TerrainBase1.ToStringHyphenated());
            output.Append("TerrainBase2: ");
            output.AppendLine(Client.Network.CurrentSim.TerrainBase2.ToStringHyphenated());
            output.Append("TerrainBase3: ");
            output.AppendLine(Client.Network.CurrentSim.TerrainBase3.ToStringHyphenated());
            output.Append("TerrainDetail0: ");
            output.AppendLine(Client.Network.CurrentSim.TerrainDetail0.ToStringHyphenated());
            output.Append("TerrainDetail1: ");
            output.AppendLine(Client.Network.CurrentSim.TerrainDetail1.ToStringHyphenated());
            output.Append("TerrainDetail2: ");
            output.AppendLine(Client.Network.CurrentSim.TerrainDetail2.ToStringHyphenated());
            output.Append("TerrainDetail3: ");
            output.AppendLine(Client.Network.CurrentSim.TerrainDetail3.ToStringHyphenated());
            output.Append("Water Height: ");
            output.AppendLine(Client.Network.CurrentSim.WaterHeight.ToString());

            return output.ToString();
        }
Exemple #26
0
        /// <summary>
        /// Get a list of current friends
        /// </summary>
        /// <param name="args">optional testClient command arguments</param>
        /// <param name="fromAgentID">The <seealso cref="libsecondlife.LLUUID"/> 
        /// of the agent making the request</param>
        /// <returns></returns>
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            // initialize a StringBuilder object used to return the results
            StringBuilder sb = new StringBuilder();

            // Only iterate the Friends dictionary if we actually have friends!
            if (Client.Friends.FriendList.Count > 0)
            {
                // iterate over the InternalDictionary using a delegate to populate
                // our StringBuilder output string
                Client.Friends.FriendList.ForEach(delegate(FriendInfo friend)
                {
                    // append the name of the friend to our output
                    sb.AppendLine(friend.Name);
                });
            }
            else
            {
                // we have no friends :(
                sb.AppendLine("No Friends");   
            }

            // return the result
            return sb.ToString();
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            int channel = 0;
            int startIndex = 0;

            if (args.Length < 1)
            {
                return "usage: say (optional channel) whatever";
            }
            else if (args.Length > 1)
            {
                if (Int32.TryParse(args[0], out channel))
                    startIndex = 1;
            }

            StringBuilder message = new StringBuilder();

            for (int i = startIndex; i < args.Length; i++)
            {
                message.Append(args[i]);
                if (i != args.Length - 1) message.Append(" ");
            }

            libsecondlife.Utilities.Realism.Chat(Client, message.ToString(), ChatType.Normal, 5);

            return "Said " + message.ToString();
        }
        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();
        }
Exemple #29
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 3)
                return "Usage: im [firstname] [lastname] [message]";

            ToAvatarName = args[0] + " " + args[1];

            // Build the message
            string message = String.Empty;
            for (int ct = 2; ct < args.Length; ct++)
                message += args[ct] + " ";
            message = message.TrimEnd();
            if (message.Length > 1023) message = message.Remove(1023);

            if (!Name2Key.ContainsKey(ToAvatarName.ToLower()))
            {
                // Send the Query
                Client.Avatars.RequestAvatarNameSearch(ToAvatarName, LLUUID.Random());

                NameSearchEvent.WaitOne(6000, false);
            }

            if (Name2Key.ContainsKey(ToAvatarName.ToLower()))
            {
                LLUUID id = Name2Key[ToAvatarName.ToLower()];

                Client.Self.InstantMessage(id, message, id);
                return "Instant Messaged " + id.ToStringHyphenated() + " with message: " + message;
            }
            else
            {
                return "Name lookup for " + ToAvatarName + " failed";
            }
        }
        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];
		}
        /// <summary>
        /// Send an avatar back to their home location
        /// </summary>
        /// <param name="pest">Key of avatar to send home</param>
        public void TeleportHomeUser(LLUUID pest)
        {
            List <string> listParams = new List <string>();

            listParams.Add(Client.Self.AgentID.ToString());
            listParams.Add(pest.ToString());
            EstateOwnerMessage("teleporthomeuser", listParams);
        }
 public InventoryNode this[LLUUID key]
 {
     get { return((InventoryNode)this.Dictionary[key]); }
     set
     {
         value.Parent = parent;
         lock (syncRoot) this.Dictionary[key] = value;
     }
 }
        /// <summary>
        /// Use to map a friends location on the grid.
        /// </summary>
        /// <param name="friendID">Friends UUID to find</param>
        /// <remarks><seealso cref="E:OnFriendFound"/></remarks>
        public void MapFriend(LLUUID friendID)
        {
            FindAgentPacket stalk = new FindAgentPacket();

            stalk.AgentBlock.Hunter = Client.Self.AgentID;
            stalk.AgentBlock.Prey   = friendID;

            Client.Network.SendPacket(stalk);
        }
        /// <summary>Tracks the specified avatar on your map</summary>
        /// <param name="preyID">Avatar ID to track</param>
        public void TrackAvatar(LLUUID preyID)
        {
            TrackAgentPacket p = new TrackAgentPacket();

            p.AgentData.AgentID   = Client.Self.AgentID;
            p.AgentData.SessionID = Client.Self.SessionID;
            p.TargetData.PreyID   = preyID;
            Client.Network.SendPacket(p);
        }
        /// <summary>
        /// Use to track a friends movement on the grid
        /// </summary>
        /// <param name="friendID">Friends Key</param>
        public void TrackFriend(LLUUID friendID)
        {
            TrackAgentPacket stalk = new TrackAgentPacket();

            stalk.AgentData.AgentID   = Client.Self.AgentID;
            stalk.AgentData.SessionID = Client.Self.SessionID;
            stalk.TargetData.PreyID   = friendID;

            Client.Network.SendPacket(stalk);
        }
        /// <summary>
        /// Start a request for Avatar Properties
        /// </summary>
        /// <param name="avatarid"></param>
        public void RequestAvatarProperties(LLUUID avatarid)
        {
            AvatarPropertiesRequestPacket aprp = new AvatarPropertiesRequestPacket();

            aprp.AgentData.AgentID   = Client.Self.AgentID;
            aprp.AgentData.SessionID = Client.Self.SessionID;
            aprp.AgentData.AvatarID  = avatarid;

            Client.Network.SendPacket(aprp);
        }
        /// <summary>
        /// Request a single avatar name
        /// </summary>
        /// <param name="id">The avatar key to retrieve a name for</param>
        public void RequestAvatarName(LLUUID id)
        {
            UUIDNameRequestPacket request = new UUIDNameRequestPacket();

            request.UUIDNameBlock       = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
            request.UUIDNameBlock[0]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
            request.UUIDNameBlock[0].ID = id;

            Client.Network.SendPacket(request);
        }
Exemple #38
0
 /// <summary>
 /// Creates a new Entity (should not occur on it's own)
 /// </summary>
 public Entity()
 {
     uuid     = new libsecondlife.LLUUID();
     localid  = 0;
     m_pos    = new LLVector3();
     velocity = new LLVector3();
     rotation = new Quaternion();
     m_name   = "(basic entity)";
     children = new List <Entity>();
 }
        /// <summary>Unban an avatar from an estate</summary>
        /// <param name="userID">Key of Agent to remove</param>
        public void UnbanUser(LLUUID userID)
        {
            List <string> listParams = new List <string>();
            uint          flag       = (uint)EstateAccessDelta.UnbanUser;

            listParams.Add(Client.Self.AgentID.ToString());
            listParams.Add(flag.ToString());
            listParams.Add(userID.ToString());
            EstateOwnerMessage("estateaccessdelta", listParams);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        public void BeginGetAvatarName(LLUUID id, AgentNamesCallback anc)
        {
            // TODO: BeginGetAvatarNames is pretty bulky, rewrite a simple version here

            List <LLUUID> ids = new List <LLUUID>();

            ids.Add(id);

            BeginGetAvatarNames(ids, anc);
        }
Exemple #41
0
        /// <summary>
        /// Used by the libsecondlife framework when building the initial list of friends
        /// at login time.  This constructor should not be called by consummer of this class.
        /// </summary>
        /// <param name="id">System ID of the avatar being prepesented</param>
        /// <param name="theirRights">Rights the friend has to see you online and to modify your objects</param>
        /// <param name="myRights">Rights you have to see your friend online and to modify their objects</param>
        public FriendInfo(LLUUID id, FriendRights theirRights, FriendRights myRights)
        {
            m_id                 = id;
            m_canSeeMeOnline     = (theirRights & FriendRights.CanSeeOnline) != 0;
            m_canSeeMeOnMap      = (theirRights & FriendRights.CanSeeOnMap) != 0;
            m_canModifyMyObjects = (theirRights & FriendRights.CanModifyObjects) != 0;

            m_canSeeThemOnline      = (myRights & FriendRights.CanSeeOnline) != 0;
            m_canSeeThemOnMap       = (myRights & FriendRights.CanSeeOnMap) != 0;
            m_canModifyTheirObjects = (myRights & FriendRights.CanModifyObjects) != 0;
        }
Exemple #42
0
 public Inventory(SecondLife client, InventoryManager manager, LLUUID owner)
 {
     Client  = client;
     Manager = manager;
     _Owner  = owner;
     if (owner == LLUUID.Zero)
     {
         Logger.Log("Inventory owned by nobody!", Helpers.LogLevel.Warning, Client);
     }
     Items = new Dictionary <LLUUID, InventoryNode>();
 }
Exemple #43
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        public void PackUUID(LLUUID data)
        {
            byte[] bytes = data.GetBytes();

            // Not sure if our PackBitArray function can handle 128-bit byte
            //arrays, so using this for now
            for (int i = 0; i < 16; i++)
            {
                PackBits(bytes[i], 8);
            }
        }
        /// <summary>
        /// Search for an avatar (first name, last name, and uuid)
        /// </summary>
        /// <param name="name">The name to search for</param>
        /// <param name="queryID">An ID to associate with this query</param>
        public void RequestAvatarNameSearch(string name, LLUUID queryID)
        {
            AvatarPickerRequestPacket aprp = new AvatarPickerRequestPacket();

            aprp.AgentData.AgentID   = Client.Self.AgentID;
            aprp.AgentData.SessionID = Client.Self.SessionID;
            aprp.AgentData.QueryID   = queryID;
            aprp.Data.Name           = Helpers.StringToField(name);

            Client.Network.SendPacket(aprp);
        }
Exemple #45
0
        /// <summary>
        /// XOR operator
        /// </summary>
        /// <param name="lhs">First LLUUID</param>
        /// <param name="rhs">Second LLUUID</param>
        /// <returns>A UUID that is a XOR combination of the two input UUIDs</returns>
        public static LLUUID operator ^(LLUUID lhs, LLUUID rhs)
        {
            LLUUID returnUUID = new LLUUID();

            for (int count = 0; count < returnUUID.Data.Length; count++)
            {
                returnUUID.Data[count] = (byte)(lhs.Data[count] ^ rhs.Data[count]);
            }

            return(returnUUID);
        }
Exemple #46
0
        public LLUUID UnpackUUID()
        {
            if (bitPos != 0)
            {
                throw new IndexOutOfRangeException();
            }

            LLUUID val = new LLUUID(Data, bytePos);

            bytePos += 16;
            return(val);
        }
Exemple #47
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="group"></param>
        /// <param name="gpc"></param>
        public void BeginGetGroupProfile(LLUUID group, GroupProfileCallback gpc)
        {
            GroupProfileCallbacks[group] = gpc;

            GroupProfileRequestPacket request = new GroupProfileRequestPacket();

            request.AgentData.AgentID   = Client.Network.AgentID;
            request.AgentData.SessionID = Client.Network.SessionID;
            request.GroupData.GroupID   = group;

            Client.Network.SendPacket(request);
        }
Exemple #48
0
        public LLUUID UnpackUUID()
        {
            if (bitPos != 0)
            {
                return(LLUUID.Zero);
            }

            LLUUID val = new LLUUID(Data, bytePos);

            bytePos += 16;
            return(val);
        }
Exemple #49
0
 private void init()
 {
     OwnerID      = LLUUID.Zero;
     AABBMin      = LLVector3.Zero;
     AABBMax      = LLVector3.Zero;
     Bitmap       = new byte[512];
     MediaID      = LLUUID.Zero;
     GroupID      = LLUUID.Zero;
     AuthBuyerID  = LLUUID.Zero;
     SnapshotID   = LLUUID.Zero;
     UserLocation = LLVector3.Zero;
     UserLookAt   = LLVector3.Zero;
 }
Exemple #50
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="groupID"></param>
        /// <returns></returns>
        public bool Deed(SecondLife client, LLUUID groupID)
        {
            ParcelDeedToGroupPacket request = new ParcelDeedToGroupPacket();

            request.AgentData.AgentID   = client.Network.AgentID;
            request.AgentData.SessionID = client.Network.SessionID;

            request.Data.LocalID = this.LocalID;
            request.Data.GroupID = groupID;

            client.Network.SendPacket((Packet)request, Sim);
            return(true);
        }
        /// <summary>
        /// Change the rights of a friend avatar.
        /// </summary>
        /// <param name="friendID">the <seealso cref="LLUUID"/> of the friend</param>
        /// <param name="rights">the new rights to give the friend</param>
        /// <remarks>This method will implicitly set the rights to those passed in the rights parameter.</remarks>
        public void GrantRights(LLUUID friendID, FriendRights rights)
        {
            GrantUserRightsPacket request = new GrantUserRightsPacket();

            request.AgentData.AgentID   = Client.Self.AgentID;
            request.AgentData.SessionID = Client.Self.SessionID;
            request.Rights    = new GrantUserRightsPacket.RightsBlock[1];
            request.Rights[0] = new GrantUserRightsPacket.RightsBlock();
            request.Rights[0].AgentRelated  = friendID;
            request.Rights[0].RelatedRights = (int)rights;

            Client.Network.SendPacket(request);
        }
Exemple #52
0
        /// <summary>
        /// Change the rights of a friend avatar.  To use this routine, first change the right of the
        /// avatar stored in the item property.
        /// </summary>
        /// <param name="agentID">System ID of the avatar you are changing the rights of</param>
        public void GrantRights(LLUUID agentID)
        {
            GrantUserRightsPacket request = new GrantUserRightsPacket();

            request.AgentData.AgentID   = Client.Self.AgentID;
            request.AgentData.SessionID = Client.Self.SessionID;
            request.Rights    = new GrantUserRightsPacket.RightsBlock[1];
            request.Rights[0] = new GrantUserRightsPacket.RightsBlock();
            request.Rights[0].AgentRelated  = agentID;
            request.Rights[0].RelatedRights = (int)(_Friends[agentID].TheirFriendRights);

            Client.Network.SendPacket(request);
        }
Exemple #53
0
        public LLUUID RequestUpload(Asset asset, bool tempFile, bool storeLocal, bool isPriority)
        {
            if (asset.AssetData == null)
            {
                throw new ArgumentException("Can't upload an asset with no data (did you forget to call Encode?)");
            }

            LLUUID assetID;
            LLUUID transferID = RequestUpload(out assetID, asset.AssetType, asset.AssetData, tempFile, storeLocal, isPriority);

            asset.AssetID = assetID;
            return(transferID);
        }
Exemple #54
0
 private void init()
 {
     OwnerID      = new LLUUID();
     AABBMin      = new LLVector3();
     AABBMax      = new LLVector3();
     Bitmap       = new byte[512];
     MediaID      = new LLUUID();
     GroupID      = new LLUUID();
     AuthBuyerID  = new LLUUID();
     SnapshotID   = new LLUUID();
     UserLocation = new LLVector3();
     UserLookAt   = new LLVector3();
 }
Exemple #55
0
 public SculptData(byte[] data, int pos)
 {
     if (data.Length >= 17)
     {
         SculptTexture = new LLUUID(data, pos);
         Type          = (SculptType)data[pos + 16];
     }
     else
     {
         SculptTexture = LLUUID.Zero;
         Type          = SculptType.None;
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="prey"></param>
        public void KickUser(LLUUID prey)
        {
            EstateOwnerMessagePacket estate = new EstateOwnerMessagePacket();

            estate.AgentData.AgentID      = Client.Network.AgentID;
            estate.AgentData.SessionID    = Client.Network.SessionID;
            estate.MethodData.Invoice     = LLUUID.GenerateUUID();
            estate.MethodData.Method      = Helpers.StringToField("kick");
            estate.ParamList              = new EstateOwnerMessagePacket.ParamListBlock[2];
            estate.ParamList[0].Parameter = Helpers.StringToField(Client.Network.AgentID.ToStringHyphenated());
            estate.ParamList[1].Parameter = Helpers.StringToField(prey.ToStringHyphenated());

            Client.Network.SendPacket((Packet)estate);
        }
Exemple #57
0
        public           InventoryFolder[] ParseSkeleton(NetworkManager.InventorySkeletonEntry[] skeleton, LLUUID owner)
        {
            Dictionary <LLUUID, InventoryFolder>         Folders         = new Dictionary <LLUUID, InventoryFolder>();
            Dictionary <LLUUID, List <InventoryFolder> > FoldersChildren = new Dictionary <LLUUID, List <InventoryFolder> >(skeleton.Length);

            foreach (NetworkManager.InventorySkeletonEntry entry in skeleton)
            {
                InventoryFolder folder = new InventoryFolder(entry.folder_id);
                if (entry.type_default != -1)
                {
                    folder.PreferredType = (AssetType)entry.type_default;
                }
                folder.Version    = entry.version;
                folder.OwnerID    = owner;
                folder.ParentUUID = LLUUID.Parse(entry.parent_id);
                folder.Name       = entry.name;
                Folders.Add(entry.folder_id, folder);

                if (entry.parent_id != LLUUID.Zero)
                {
                    List <InventoryFolder> parentChildren;
                    if (!FoldersChildren.TryGetValue(entry.parent_id, out parentChildren))
                    {
                        parentChildren = new List <InventoryFolder>();
                        FoldersChildren.Add(entry.parent_id, parentChildren);
                    }
                    parentChildren.Add(folder);
                }
            }

            foreach (KeyValuePair <LLUUID, List <InventoryFolder> > pair in FoldersChildren)
            {
                if (Folders.ContainsKey(pair.Key))
                {
                    InventoryFolder parentFolder = Folders[pair.Key];
                    parentFolder.DescendentCount = pair.Value.Count; // Should we set this here? it's just the folders, not the items!
                }
            }

            // Should we do this or just return an IEnumerable?
            InventoryFolder[] ret = new InventoryFolder[Folders.Count];
            int index             = 0;

            foreach (InventoryFolder folder in Folders.Values)
            {
                ret[index] = folder;
                ++index;
            }
            return(ret);
        }
        /// <summary>
        /// This function will only check if the avatar name exists locally,
        /// it will not do any networking calls to fetch the name
        /// </summary>
        /// <returns>The avatar name, or an empty string if it's not found</returns>
        public string LocalAvatarNameLookup(LLUUID id)
        {
            string name = "";

            lock (Avatars)
            {
                if (Avatars.ContainsKey(id))
                {
                    name = Avatars[id].Name;
                }
            }

            return(name);
        }
Exemple #59
0
        /// <summary>
        /// Plays a sound
        /// </summary>
        /// <param name="soundID">UUID of the sound to be played.</param>
        /// <param name="handle">handle id for the sim to be played in.</param>
        /// <param name="position">position for the sound to be played at. Normally the avatar.</param>
        /// <param name="gain">volume of the sound, from 0.0 to 1.0</param>
        public void SoundTrigger(LLUUID soundID, ulong handle, LLVector3 position, float gain)
        {
            SoundTriggerPacket soundtrigger = new SoundTriggerPacket();

            soundtrigger.SoundData          = new SoundTriggerPacket.SoundDataBlock();
            soundtrigger.SoundData.SoundID  = soundID;
            soundtrigger.SoundData.ObjectID = LLUUID.Zero;
            soundtrigger.SoundData.OwnerID  = LLUUID.Zero;
            soundtrigger.SoundData.ParentID = LLUUID.Zero;
            soundtrigger.SoundData.Handle   = handle;
            soundtrigger.SoundData.Position = position;
            soundtrigger.SoundData.Gain     = gain;
            Client.Network.SendPacket(soundtrigger);
        }
Exemple #60
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="prim"></param>
        /// <param name="position"></param>
        /// <param name="avatarPosition"></param>
        public void RezObject(PrimObject prim, LLVector3 position, LLVector3 rayStart,
                              LLUUID groupID)
        {
            ObjectAddPacket add = new ObjectAddPacket();

            add.AgentData.AgentID   = Client.Network.AgentID;
            add.AgentData.SessionID = Client.Network.SessionID;
            add.AgentData.GroupID   = groupID;
            // TODO: Why 2?
            add.ObjectData.AddFlags             = 2;
            add.ObjectData.BypassRaycast        = 1;
            add.ObjectData.Material             = (byte)prim.Material;
            add.ObjectData.PathBegin            = PrimObject.PathBeginByte(prim.PathBegin);
            add.ObjectData.PathCurve            = (byte)prim.PathCurve;
            add.ObjectData.PathEnd              = PrimObject.PathEndByte(prim.PathEnd);
            add.ObjectData.PathRadiusOffset     = PrimObject.PathRadiusOffsetByte(prim.PathRadiusOffset);
            add.ObjectData.PathRevolutions      = PrimObject.PathRevolutionsByte(prim.PathRevolutions);
            add.ObjectData.PathScaleX           = PrimObject.PathScaleByte(prim.PathScaleX);
            add.ObjectData.PathScaleY           = PrimObject.PathScaleByte(prim.PathScaleY);
            add.ObjectData.PathShearX           = PrimObject.PathShearByte(prim.PathShearX);
            add.ObjectData.PathShearY           = PrimObject.PathShearByte(prim.PathShearY);
            add.ObjectData.PathSkew             = PrimObject.PathSkewByte(prim.PathSkew);
            add.ObjectData.PathTaperX           = PrimObject.PathTaperByte(prim.PathTaperX);
            add.ObjectData.PathTaperY           = PrimObject.PathTaperByte(prim.PathTaperY);
            add.ObjectData.PathTwist            = PrimObject.PathTwistByte(prim.PathTwist);
            add.ObjectData.PathTwistBegin       = PrimObject.PathTwistByte(prim.PathTwistBegin);
            add.ObjectData.PCode                = (byte)prim.PCode;
            add.ObjectData.ProfileBegin         = PrimObject.ProfileBeginByte(prim.ProfileBegin);
            add.ObjectData.ProfileCurve         = (byte)prim.ProfileCurve;
            add.ObjectData.ProfileEnd           = PrimObject.ProfileEndByte(prim.ProfileEnd);
            add.ObjectData.ProfileHollow        = (byte)prim.ProfileHollow;
            add.ObjectData.RayEnd               = position;
            add.ObjectData.RayEndIsIntersection = 0;
            add.ObjectData.RayStart             = rayStart;
            add.ObjectData.RayTargetID          = LLUUID.GenerateUUID();
            add.ObjectData.Rotation             = prim.Rotation;
            add.ObjectData.Scale                = prim.Scale;
            add.ObjectData.State                = (byte)prim.State;
            if (prim.Textures != null)
            {
                add.ObjectData.TextureEntry = prim.Textures.ToBytes();
            }
            else
            {
                add.ObjectData.TextureEntry = new byte[0];
            }

            Client.Network.SendPacket(add);
        }