void Groups_OnGroupJoined(LLUUID groupID, bool success)
        {
            Console.WriteLine(Client.ToString() + (success ? " joined " : " failed to join ") +
                              groupID.ToString());

            if (success)
            {
                Console.WriteLine(Client.ToString() + " setting " + groupID.ToString() +
                                  " as the active group");
                Client.Groups.ActivateGroup(groupID);
            }
        }
示例#2
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]");
            }
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 2)
            {
                return("Usage: exportoutfit avataruuid outputfile.xml");
            }

            LLUUID id;

            try
            {
                id = new LLUUID(args[0]);
            }
            catch (Exception)
            {
                return("Usage: exportoutfit avataruuid outputfile.xml");
            }

            lock (TestClient.Appearances)
            {
                if (TestClient.Appearances.ContainsKey(id))
                {
                    try
                    {
                        XmlWriterSettings settings = new XmlWriterSettings();
                        settings.Indent = true;
                        XmlWriter writer = XmlWriter.Create(args[1], settings);
                        try
                        {
                            TestClient.Appearances[id].ToXml(writer);
                        }
                        finally
                        {
                            writer.Close();
                        }
                    }
                    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());
                }
            }
        }
示例#4
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");
            }
        }
示例#5
0
        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);
        }
示例#6
0
        bool clone(LLUUID target)
        {
            if (appearances.ContainsKey(target))
            {
                #region AvatarAppearance to AgentSetAppearance

                AvatarAppearancePacket appearance = appearances[target];

                AgentSetAppearancePacket set = new AgentSetAppearancePacket();
                set.AgentData.AgentID   = Self.AgentID;
                set.AgentData.SessionID = Self.SessionID;
                set.AgentData.SerialNum = SerialNum++;
                set.AgentData.Size      = new LLVector3(2f, 2f, 2f); // HACK

                set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
                set.VisualParam  = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];

                for (int i = 0; i < appearance.VisualParam.Length; i++)
                {
                    set.VisualParam[i]            = new AgentSetAppearancePacket.VisualParamBlock();
                    set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
                }

                set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;

                #endregion AvatarAppearance to AgentSetAppearance

                // Detach everything we are currently wearing
                Appearance.AddAttachments(new List <InventoryBase>(), true);

                // Send the new appearance packet
                Network.SendPacket(set);

                #if DEBUG
                Console.Out.WriteLine("Cloned {0}", target.ToString());
                #endif

                return(true);
            }
            else
            {
                #if DEBUG
                Console.Out.WriteLine("Don't know the appearance of avatar {0}", target.ToString());
                #endif
                return(false);
            }
        }
示例#7
0
        private void BtnPrintKeyClick(object sender, System.EventArgs e)
        {
            string key = target.ToString();

            key = key.Insert(8, "-");
            key = key.Insert(13, "-");
            key = key.Insert(18, "-");
            key = key.Insert(23, "-");
            textManager.PrintProgramMessage("Program: " + toName + " == " + key);
        }
示例#8
0
        public void LLUUIDs()
        {
            // Creation
            LLUUID a = new LLUUID();

            byte[] bytes = a.GetBytes();
            for (int i = 0; i < 16; i++)
            {
                Assert.IsTrue(bytes[i] == 0x00);
            }

            // Comparison
            a = new LLUUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
                                        0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF }, 0);
            LLUUID b = new LLUUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
                                               0x0B, 0x0C, 0x0D, 0x0E, 0x0F }, 0);

            Assert.IsTrue(a == b, "LLUUID comparison operator failed, " + a.ToString() + " should equal " +
                          b.ToString());

            // From string
            a = new LLUUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
                                        0x0B, 0x0C, 0x0D, 0x0E, 0x0F }, 0);
            string zeroonetwo = "00010203-0405-0607-0809-0a0b0c0d0e0f";

            b = new LLUUID(zeroonetwo);

            Assert.IsTrue(a == b, "LLUUID hyphenated string constructor failed, should have " + a.ToString() +
                          " but we got " + b.ToString());

            // ToString()
            string one = a.ToString();
            string two = b.ToString();

            Assert.IsTrue(a == b);
            one = a.ToString();
            two = b.ToString();
            Assert.IsTrue(a == b);
            Assert.IsTrue(a == zeroonetwo);

            // TODO: CRC test
        }
示例#9
0
 private void UpdateAssetID()
 {
     if (this.InvokeRequired)
     {
         BeginInvoke(new MethodInvoker(UpdateAssetID));
     }
     else
     {
         txtAssetID.Text = AssetID.ToString();
     }
 }
 void Avatars_OnAvatarAppearance(LLUUID avatarID, bool isTrial, LLObject.TextureEntryFace defaultTexture, LLObject.TextureEntryFace[] faceTextures, System.Collections.Generic.List <byte> visualParams)
 {
     if (IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.EyesBaked]) &&
         IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.HeadBaked]) &&
         IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.LowerBaked]) &&
         IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.SkirtBaked]) &&
         IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.UpperBaked]))
     {
         Console.WriteLine("Avatar " + avatarID.ToString() + " may be a bot");
     }
 }
 private void Avatars_OnLookAt(LLUUID sourceID, LLUUID targetID, LLVector3d targetPos,
                               LookAtType lookType, float duration, LLUUID id)
 {
     if (ShowEffects)
     {
         Console.WriteLine(
             "ViewerEffect [LookAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}",
             sourceID.ToString(), targetID.ToString(), targetPos, lookType, duration,
             id.ToString());
     }
 }
 private void Avatars_OnEffect(EffectType type, LLUUID sourceID, LLUUID targetID,
                               LLVector3d targetPos, float duration, LLUUID id)
 {
     if (ShowEffects)
     {
         Console.WriteLine(
             "ViewerEffect [{0}]: SourceID: {1} TargetID: {2} TargetPos: {3} Duration: {4} ID: {5}",
             type, sourceID.ToString(), targetID.ToString(), targetPos, duration,
             id.ToString());
     }
 }
        public string ExportString()
        {
            string typ    = "notecard";
            string result = "";

            result += "\tinv_object\t0\n\t{\n";
            result += "\t\tobj_id\t%s\n";
            result += "\t\tparent_id\t" + ItemID.ToString() + "\n";
            result += "\t\ttype\t" + typ + "\n";
            result += "\t\tname\t" + Name + "|\n";
            result += "\t}\n";
            return(result);
        }
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 1)
            {
                return(Description);
            }

            LLUUID targetID;

            ReceivedProperties = false;
            ReceivedInterests  = false;
            ReceivedGroups     = false;

            try
            {
                targetID = new LLUUID(args[0]);
            }
            catch (Exception)
            {
                return(Description);
            }

            // Request all of the packets that make up an avatar profile
            Client.Avatars.RequestAvatarProperties(targetID);

            // Wait for all the packets to arrive
            ReceivedProfileEvent.Reset();
            ReceivedProfileEvent.WaitOne(5000, false);

            // Check if everything showed up
            if (!ReceivedInterests || !ReceivedProperties || !ReceivedGroups)
            {
                return("Failed to retrieve a complete profile for that UUID");
            }

            // Synchronize our profile
            Client.Self.UpdateInterests(Interests);
            Client.Self.UpdateProfile(Properties);

            // TODO: Leave all the groups we're currently a member of? This could
            // break TestClient connectivity that might be relying on group authentication

            // Attempt to join all the groups
            foreach (LLUUID groupID in Groups)
            {
                Client.Groups.RequestJoinGroup(groupID);
            }

            return("Synchronized our profile to the profile of " + targetID.ToString());
        }
示例#15
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");
            }
        }
示例#16
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);
                return("Instant Messaged " + id.ToString() + " with message: " + message);
            }
            else
            {
                return("Name lookup for " + ToAvatarName + " failed");
            }
        }
示例#17
0
        public void LLUUIDs()
        {
            // Comparison
            LLUUID a = new LLUUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
                                               0x0B, 0x0C, 0x0D, 0x0E, 0x0F }, 0);
            LLUUID b = new LLUUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
                                               0x0B, 0x0C, 0x0D, 0x0E, 0x0F }, 0);

            Assert.IsTrue(a == b, "LLUUID comparison operator failed, " + a.ToString() + " should equal " +
                          b.ToString());

            // From string
            a = new LLUUID(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
                                        0x0B, 0x0C, 0x0D, 0x0E, 0x0F }, 0);
            b = new LLUUID("00010203-0405-0607-0809-0a0b0c0d0e0f");

            Assert.IsTrue(a == b, "LLUUID hyphenated string constructor failed, should have " + a.ToString() +
                          " but we got " + b.ToString());

            // TODO: CRC test
        }
示例#18
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();
        }
示例#19
0
        public bool sendGroupIM(string message, string groupUUID)
        {
            message = message.TrimEnd();
            if (message.Length > 1023)
            {
                message = message.Remove(1023);
            }

            Self.OnGroupChatJoin += new AgentManager.GroupChatJoined(onGroupChatJoin);
            if (!Self.GroupChatSessions.ContainsKey(toGroupID))
            {
                waitForSessionStart.Reset();
                Self.RequestJoinGroupChat(toGroupID);
            }
            else
            {
                waitForSessionStart.Set();
            }

            if (waitForSessionStart.WaitOne(10000, false))
            {
                Self.InstantMessageGroup(toGroupID, message);
            }
            else
            {
                #if DEBUG
                Console.Out.WriteLine("Timeout waiting for group session start");
                #endif

                Self.OnGroupChatJoin -= new AgentManager.GroupChatJoined(onGroupChatJoin);
                return(false);
            }

            Self.OnGroupChatJoin -= new AgentManager.GroupChatJoined(onGroupChatJoin);
            #if DEBUG
            Console.Out.WriteLine("Instant Messaged group {0} with message: {1}", toGroupID.ToString(), message);
            #endif

            return(true);
        }
示例#20
0
        public void OnFileRequested(HttpRequest request, IDirectory directory)
        {
            //request.Response.SetHeader("Content-Type", "text/plain; charset=utf-8");
            request.Response.ResponseContent = new MemoryStream();
            StreamWriter  textwriter = new StreamWriter(request.Response.ResponseContent);
            SecondLife    client;
            AvatarTracker avatars;
            Events        events;
            StreamReader  reader  = new StreamReader(request.PostData);
            string        qstring = reader.ReadToEnd();

            reader.Dispose();
            Dictionary <string, string> POST = AjaxLife.PostDecode(qstring);

            // Pull out the session.
            if (!POST.ContainsKey("sid"))
            {
                textwriter.WriteLine("Need an SID.");
                textwriter.Flush();
                return;
            }
            Guid guid = new Guid(POST["sid"]);
            User user = new User();

            lock (this.users)
            {
                if (!this.users.ContainsKey(guid))
                {
                    textwriter.WriteLine("Error: invalid SID");
                    textwriter.Flush();
                    return;
                }
                user             = this.users[guid];
                client           = user.Client;
                avatars          = user.Avatars;
                events           = user.Events;
                user.LastRequest = DateTime.Now;
            }
            // Get the message type.
            string messagetype = POST["MessageType"];

            // Check that the message is signed if it should be.
            if (Array.IndexOf(REQUIRED_SIGNATURES, messagetype) > -1)
            {
                if (!VerifySignature(user, qstring))
                {
                    textwriter.WriteLine("Error: Received hash and expected hash do not match.");
                    textwriter.Flush();
                    return;
                }
            }

            // Right. This file is fun. It takes information in POST paramaters and sends them to
            // the server in the appropriate format. Some will return data immediately, some will return
            // keys to data that will arrive in the message queue, some return nothing but you get
            // something in the message queue later, and some return nother ever.
            //
            // The joys of dealing with multiple bizarre message types.

            switch (messagetype)
            {
            case "SpatialChat":
                client.Self.Chat(POST["Message"], int.Parse(POST["Channel"]), (ChatType)((byte)int.Parse(POST["Type"])));
                break;

            case "SimpleInstantMessage":
                if (POST.ContainsKey("IMSessionID"))
                {
                    client.Self.InstantMessage(new LLUUID(POST["Target"]), POST["Message"], new LLUUID(POST["IMSessionID"]));
                }
                else
                {
                    client.Self.InstantMessage(new LLUUID(POST["Target"]), POST["Message"]);
                }
                break;

            case "GenericInstantMessage":
                client.Self.InstantMessage(
                    client.Self.FirstName + " " + client.Self.LastName,
                    new LLUUID(POST["Target"]),
                    POST["Message"],
                    new LLUUID(POST["IMSessionID"]),
                    (InstantMessageDialog)((byte)int.Parse(POST["Dialog"])),
                    (InstantMessageOnline)int.Parse(POST["Online"]),
                    client.Self.SimPosition,
                    client.Network.CurrentSim.ID,
                    new byte[0]);
                break;

            case "NameLookup":
                client.Avatars.RequestAvatarName(new LLUUID(POST["ID"]));
                break;

            case "Teleport":
            {
                Hashtable hash = new Hashtable();
                bool      status;
                if (POST.ContainsKey("Landmark"))
                {
                    status = client.Self.Teleport(new LLUUID(POST["Landmark"]));
                }
                else
                {
                    status = client.Self.Teleport(POST["Sim"], new LLVector3(float.Parse(POST["X"]), float.Parse(POST["Y"]), float.Parse(POST["Z"])));
                }
                if (status)
                {
                    hash.Add("Success", true);
                    hash.Add("Sim", client.Network.CurrentSim.Name);
                    hash.Add("Position", client.Self.SimPosition);
                }
                else
                {
                    hash.Add("Success", false);
                    hash.Add("Reason", client.Self.TeleportMessage);
                }
                textwriter.WriteLine(MakeJson.FromHashtable(hash));
            }
            break;

            case "GoHome":
                client.Self.GoHome();
                break;

            case "GetPosition":
            {
                Hashtable hash = new Hashtable();
                hash.Add("Sim", client.Network.CurrentSim.Name);
                hash.Add("Position", client.Self.SimPosition);
                textwriter.WriteLine(JavaScriptConvert.SerializeObject(hash));
            }
            break;

            case "RequestBalance":
                client.Self.RequestBalance();
                break;

            case "GetStats":
            {
                Hashtable hash = new Hashtable();
                hash.Add("FPS", client.Network.CurrentSim.Stats.FPS);
                hash.Add("TimeDilation", client.Network.CurrentSim.Stats.Dilation);
                hash.Add("LSLIPS", client.Network.CurrentSim.Stats.LSLIPS);
                hash.Add("Objects", client.Network.CurrentSim.Stats.Objects);
                hash.Add("ActiveScripts", client.Network.CurrentSim.Stats.ActiveScripts);
                hash.Add("Agents", client.Network.CurrentSim.Stats.Agents);
                hash.Add("ChildAgents", client.Network.CurrentSim.Stats.ChildAgents);
                hash.Add("AjaxLifeSessions", users.Count);
                hash.Add("TextureCacheCount", AjaxLife.TextureCacheCount);
                hash.Add("TextureCacheSize", AjaxLife.TextureCacheSize);
                textwriter.WriteLine(MakeJson.FromHashtable(hash));
            }
            break;

            case "TeleportLureRespond":
                client.Self.TeleportLureRespond(new LLUUID(POST["RequesterID"]), bool.Parse(POST["Accept"]));
                break;

            case "GodlikeTeleportLureRespond":
            {
                LLUUID lurer   = new LLUUID(POST["RequesterID"]);
                LLUUID session = new LLUUID(POST["SessionID"]);
                client.Self.InstantMessage(client.Self.Name, lurer, "", LLUUID.Random(), InstantMessageDialog.AcceptTeleport, InstantMessageOnline.Offline, client.Self.SimPosition, LLUUID.Zero, new byte[0]);
                TeleportLureRequestPacket lure = new TeleportLureRequestPacket();
                lure.Info.AgentID       = client.Self.AgentID;
                lure.Info.SessionID     = client.Self.SessionID;
                lure.Info.LureID        = session;
                lure.Info.TeleportFlags = (uint)AgentManager.TeleportFlags.ViaGodlikeLure;
                client.Network.SendPacket(lure);
            }
            break;

            case "FindPeople":
            {
                Hashtable hash = new Hashtable();
                hash.Add("QueryID", client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, POST["Search"], int.Parse(POST["Start"])));
                textwriter.WriteLine(MakeJson.FromHashtable(hash));
            }
            break;

            case "FindGroups":
            {
                Hashtable hash = new Hashtable();
                hash.Add("QueryID", client.Directory.StartGroupSearch(DirectoryManager.DirFindFlags.Groups, POST["Search"], int.Parse(POST["Start"])));
                textwriter.WriteLine(MakeJson.FromHashtable(hash));
            }
            break;

            case "GetAgentData":
                client.Avatars.RequestAvatarProperties(new LLUUID(POST["AgentID"]));
                break;

            case "StartAnimation":
                client.Self.AnimationStart(new LLUUID(POST["Animation"]), false);
                break;

            case "StopAnimation":
                client.Self.AnimationStop(new LLUUID(POST["Animation"]), true);
                break;

            case "SendAppearance":
                client.Appearance.SetPreviousAppearance(false);
                break;

            case "GetMapItems":
            {
                MapItemRequestPacket req = new MapItemRequestPacket();
                req.AgentData.AgentID   = client.Self.AgentID;
                req.AgentData.SessionID = client.Self.SessionID;
                GridRegion region;
                client.Grid.GetGridRegion(POST["Region"], GridLayerType.Objects, out region);
                req.RequestData.RegionHandle = region.RegionHandle;
                req.RequestData.ItemType     = uint.Parse(POST["ItemType"]);
                client.Network.SendPacket((Packet)req);
            }
            break;

            case "GetMapBlocks":
            {
                MapBlockRequestPacket req = new MapBlockRequestPacket();
                req.AgentData.AgentID   = client.Self.AgentID;
                req.AgentData.SessionID = client.Self.SessionID;
                req.PositionData.MinX   = 0;
                req.PositionData.MinY   = 0;
                req.PositionData.MaxX   = ushort.MaxValue;
                req.PositionData.MaxY   = ushort.MaxValue;
                client.Network.SendPacket((Packet)req);
            }
            break;

            case "GetMapBlock":
            {
                ushort x = ushort.Parse(POST["X"]);
                ushort y = ushort.Parse(POST["Y"]);
                MapBlockRequestPacket req = new MapBlockRequestPacket();
                req.AgentData.AgentID   = client.Self.AgentID;
                req.AgentData.SessionID = client.Self.SessionID;
                req.PositionData.MinX   = x;
                req.PositionData.MinY   = y;
                req.PositionData.MaxX   = x;
                req.PositionData.MaxY   = y;
                client.Network.SendPacket((Packet)req);
            }
            break;

            case "GetOfflineMessages":
            {
                RetrieveInstantMessagesPacket req = new RetrieveInstantMessagesPacket();
                req.AgentData.AgentID   = client.Self.AgentID;
                req.AgentData.SessionID = client.Self.SessionID;
                client.Network.SendPacket((Packet)req);
            }
            break;

            case "GetFriendList":
            {
                InternalDictionary <LLUUID, FriendInfo> friends = client.Friends.FriendList;
                List <Hashtable> friendlist = new List <Hashtable>();
                friends.ForEach(delegate(FriendInfo friend)
                    {
                        Hashtable friendhash = new Hashtable();
                        friendhash.Add("ID", friend.UUID.ToString());
                        friendhash.Add("Name", friend.Name);
                        friendhash.Add("Online", friend.IsOnline);
                        friendhash.Add("MyRights", friend.MyFriendRights);
                        friendhash.Add("TheirRights", friend.TheirFriendRights);
                        friendlist.Add(friendhash);
                    });
                textwriter.Write(MakeJson.FromObject(friendlist));
            }
            break;

            case "ChangeRights":
            {
                LLUUID uuid = new LLUUID(POST["Friend"]);
                client.Friends.GrantRights(uuid, (FriendRights)int.Parse(POST["Rights"]));
            }
            break;

            case "RequestLocation":
                client.Friends.MapFriend(new LLUUID(POST["Friend"]));
                break;

            case "RequestTexture":
            {
                // This one's confusing, so it gets some comments.
                // First, we get the image's UUID.
                LLUUID image = new LLUUID(POST["ID"]);
                // We prepare a query to ask if S3 has it. HEAD only to avoid wasting
                // GET requests and bandwidth.
                bool exists = false;
                // If we already know we have it, note this.
                if (AjaxLife.CachedTextures.Contains(image))
                {
                    exists = true;
                }
                else
                {
                    // If we're using S3, check the S3 bucket
                    if (AjaxLife.USE_S3)
                    {
                        // Otherwise, make that HEAD request and find out.
                        try
                        {
                            IThreeSharp query = new ThreeSharpQuery(AjaxLife.S3Config);
                            Affirma.ThreeSharp.Model.ObjectGetRequest s3request = new Affirma.ThreeSharp.Model.ObjectGetRequest(AjaxLife.TEXTURE_BUCKET, image.ToString() + ".png");
                            s3request.Method = "HEAD";
                            Affirma.ThreeSharp.Model.ObjectGetResponse s3response = query.ObjectGet(s3request);
                            if (s3response.StatusCode == System.Net.HttpStatusCode.OK)
                            {
                                exists = true;
                            }
                            s3response.DataStream.Close();
                        }
                        catch { }
                    }
                    // If we aren't using S3, just check the texture cache.
                    else
                    {
                        exists = File.Exists(AjaxLife.TEXTURE_CACHE + image.ToString() + ".png");
                    }
                }
                // If it exists, reply with Ready = true and the URL to find it at.
                if (exists)
                {
                    textwriter.Write("{Ready: true, URL: \"" + AjaxLife.TEXTURE_ROOT + image + ".png\"}");
                }
                // If it doesn't, request the image from SL and note its lack of readiness.
                // Notification will arrive later in the message queue.
                else
                {
                    client.Assets.RequestImage(image, ImageType.Normal, 125000.0f, 0);
                    textwriter.Write("{Ready: false}");
                }
            }
            break;

            case "AcceptFriendship":
                client.Friends.AcceptFriendship(client.Self.AgentID, POST["IMSessionID"]);
                break;

            case "DeclineFriendship":
                client.Friends.DeclineFriendship(client.Self.AgentID, POST["IMSessionID"]);
                break;

            case "OfferFriendship":
                client.Friends.OfferFriendship(new LLUUID(POST["Target"]));
                break;

            case "TerminateFriendship":
                client.Friends.TerminateFriendship(new LLUUID(POST["Target"]));
                break;

            case "SendAgentMoney":
                client.Self.GiveAvatarMoney(new LLUUID(POST["Target"]), int.Parse(POST["Amount"]));
                break;

            case "RequestAvatarList":
            {
                List <Hashtable> list = new List <Hashtable>();
                foreach (KeyValuePair <uint, Avatar> pair in avatars.Avatars)
                {
                    Avatar    avatar = pair.Value;
                    Hashtable hash   = new Hashtable();
                    hash.Add("Name", avatar.Name);
                    hash.Add("ID", avatar.ID);
                    hash.Add("LocalID", avatar.LocalID);
                    hash.Add("Position", avatar.Position);
                    //hash.Add("Rotation", avatar.Rotation);
                    hash.Add("Scale", avatar.Scale);
                    hash.Add("GroupName", avatar.GroupName);
                    list.Add(hash);
                }
                textwriter.Write(MakeJson.FromObject(list));
            }
            break;

            case "LoadInventoryFolder":
                client.Inventory.RequestFolderContents(new LLUUID(POST["UUID"]), client.Self.AgentID, true, true, InventorySortOrder.ByDate | InventorySortOrder.SystemFoldersToTop);
                break;

            case "RequestAsset":
            {
                try
                {
                    LLUUID transferid = client.Assets.RequestInventoryAsset(new LLUUID(POST["AssetID"]), new LLUUID(POST["InventoryID"]),
                                                                            LLUUID.Zero, new LLUUID(POST["OwnerID"]), (AssetType)int.Parse(POST["AssetType"]), false);
                    textwriter.Write("{TransferID: \"" + transferid + "\"}");
                }
                catch         // Try catching the error that sometimes gets thrown... but sometimes doesn't.
                {
                }
            }
            break;

            case "SendTeleportLure":
                client.Self.SendTeleportLure(new LLUUID(POST["Target"]), POST["Message"]);
                break;

            case "ScriptPermissionResponse":
                client.Self.ScriptQuestionReply(client.Network.CurrentSim, new LLUUID(POST["ItemID"]), new LLUUID(POST["TaskID"]), (ScriptPermission)int.Parse(POST["Permissions"]));
                break;

            case "ScriptDialogReply":
            {
                ScriptDialogReplyPacket packet = new ScriptDialogReplyPacket();
                packet.AgentData.AgentID   = client.Self.AgentID;
                packet.AgentData.SessionID = client.Self.SessionID;
                packet.Data.ButtonIndex    = int.Parse(POST["ButtonIndex"]);
                packet.Data.ButtonLabel    = Helpers.StringToField(POST["ButtonLabel"]);
                packet.Data.ChatChannel    = int.Parse(POST["ChatChannel"]);
                packet.Data.ObjectID       = new LLUUID(POST["ObjectID"]);
                client.Network.SendPacket((Packet)packet);
            }
            break;

            case "SaveNotecard":
                client.Inventory.RequestUploadNotecardAsset(Helpers.StringToField(POST["AssetData"]), new LLUUID(POST["ItemID"]), new InventoryManager.NotecardUploadedAssetCallback(events.Inventory_OnNoteUploaded));
                break;

            case "CreateInventory":
                client.Inventory.RequestCreateItem(new LLUUID(POST["Folder"]), POST["Name"], POST["Description"], (AssetType)int.Parse(POST["AssetType"]), LLUUID.Random(), (InventoryType)int.Parse(POST["InventoryType"]), PermissionMask.All, new InventoryManager.ItemCreatedCallback(events.Inventory_OnItemCreated));
                break;

            case "CreateFolder":
            {
                LLUUID folder = client.Inventory.CreateFolder(new LLUUID(POST["Parent"]), POST["Name"]);
                textwriter.Write("{FolderID: \"" + folder + "\"}");
            }
            break;

            case "EmptyTrash":
                client.Inventory.EmptyTrash();
                break;

            case "MoveItem":
                client.Inventory.MoveItem(new LLUUID(POST["Item"]), new LLUUID(POST["TargetFolder"]), POST["NewName"]);
                break;

            case "MoveFolder":
                client.Inventory.MoveFolder(new LLUUID(POST["Folder"]), new LLUUID(POST["NewParent"]));
                break;

            case "MoveItems":
            case "MoveFolders":
            {
                Dictionary <LLUUID, LLUUID> dict = new Dictionary <LLUUID, LLUUID>();
                string[] moves = POST["ToMove"].Split(',');
                for (int i = 0; i < moves.Length; ++i)
                {
                    string[] move = moves[i].Split(' ');
                    dict.Add(new LLUUID(move[0]), new LLUUID(move[1]));
                }
                if (messagetype == "MoveItems")
                {
                    client.Inventory.MoveItems(dict);
                }
                else if (messagetype == "MoveFolders")
                {
                    client.Inventory.MoveFolders(dict);
                }
            }
            break;

            case "DeleteItem":
                client.Inventory.RemoveItem(new LLUUID(POST["Item"]));
                break;

            case "DeleteFolder":
                client.Inventory.RemoveFolder(new LLUUID(POST["Folder"]));
                break;

            case "DeleteMultiple":
            {
                string[]      items    = POST["Items"].Split(',');
                List <LLUUID> itemlist = new List <LLUUID>();
                for (int i = 0; i < items.Length; ++i)
                {
                    itemlist.Add(new LLUUID(items[i]));
                }
                string[]      folders    = POST["Folders"].Split(',');
                List <LLUUID> folderlist = new List <LLUUID>();
                for (int i = 0; i < items.Length; ++i)
                {
                    folderlist.Add(new LLUUID(folders[i]));
                }
                client.Inventory.Remove(itemlist, folderlist);
            }
            break;

            case "GiveInventory":
            {
                client.Inventory.GiveItem(new LLUUID(POST["ItemID"]), POST["ItemName"], (AssetType)int.Parse(POST["AssetType"]), new LLUUID(POST["Recipient"]), true);
            }
            break;

            case "UpdateItem":
            {
                InventoryItem item = client.Inventory.FetchItem(new LLUUID(POST["ItemID"]), new LLUUID(POST["OwnerID"]), 1000);
                if (POST.ContainsKey("Name"))
                {
                    item.Name = POST["Name"];
                }
                if (POST.ContainsKey("Description"))
                {
                    item.Description = POST["Description"];
                }
                if (POST.ContainsKey("NextOwnerMask"))
                {
                    item.Permissions.NextOwnerMask = (PermissionMask)uint.Parse(POST["NextOwnerMask"]);
                }
                if (POST.ContainsKey("SalePrice"))
                {
                    item.SalePrice = int.Parse(POST["SalePrice"]);
                }
                if (POST.ContainsKey("SaleType"))
                {
                    item.SaleType = (SaleType)int.Parse(POST["SaleType"]);                                       // This should be byte.Parse, but this upsets mono's compiler (CS1002)
                }
                client.Inventory.RequestUpdateItem(item);
            }
            break;

            case "UpdateFolder":
            {
                UpdateInventoryFolderPacket packet = new UpdateInventoryFolderPacket();
                packet.AgentData.AgentID      = client.Self.AgentID;
                packet.AgentData.SessionID    = client.Self.SessionID;
                packet.FolderData             = new UpdateInventoryFolderPacket.FolderDataBlock[1];
                packet.FolderData[0]          = new UpdateInventoryFolderPacket.FolderDataBlock();
                packet.FolderData[0].FolderID = new LLUUID(POST["FolderID"]);
                packet.FolderData[0].ParentID = new LLUUID(POST["ParentID"]);
                packet.FolderData[0].Type     = sbyte.Parse(POST["Type"]);
                packet.FolderData[0].Name     = Helpers.StringToField(POST["Name"]);
                client.Network.SendPacket((Packet)packet);
            }
            break;

            case "FetchItem":
                client.Inventory.FetchItem(new LLUUID(POST["Item"]), new LLUUID(POST["Owner"]), 5000);
                break;

            case "ReRotate":
                user.Rotation = -Math.PI;
                break;

            case "StartGroupIM":
                AjaxLife.Debug("SendMessage", "RequestJoinGroupChat(" + POST["Group"] + ")");
                client.Self.RequestJoinGroupChat(new LLUUID(POST["Group"]));
                break;

            case "GroupInstantMessage":
                client.Self.InstantMessageGroup(new LLUUID(POST["Group"]), POST["Message"]);
                break;

            case "RequestGroupProfile":
                client.Groups.RequestGroupProfile(new LLUUID(POST["Group"]));
                break;

            case "RequestGroupMembers":
                client.Groups.RequestGroupMembers(new LLUUID(POST["Group"]));
                break;

            case "RequestGroupName":
                client.Groups.RequestGroupName(new LLUUID(POST["ID"]));
                break;

            case "JoinGroup":
                client.Groups.RequestJoinGroup(new LLUUID(POST["Group"]));
                break;

            case "LeaveGroup":
                client.Groups.LeaveGroup(new LLUUID(POST["Group"]));
                break;

            case "RequestCurrentGroups":
                client.Groups.RequestCurrentGroups();
                break;

            case "GetParcelID":
                textwriter.Write("{LocalID: " + client.Parcels.GetParcelLocalID(client.Network.CurrentSim, new LLVector3(float.Parse(POST["X"]), float.Parse(POST["Y"]), float.Parse(POST["Z"]))) + "}");
                break;

            case "RequestParcelProperties":
                client.Parcels.PropertiesRequest(client.Network.CurrentSim, int.Parse(POST["LocalID"]), int.Parse(POST["SequenceID"]));
                break;
            }
            textwriter.Flush();
        }
        void Groups_OnGroupJoined(LLUUID groupID, bool success)
        {
            Console.WriteLine(Client.ToString() + (success ? " joined " : " failed to join ") + groupID.ToString());

            /* A.Biondi
             * This code is not necessary because it is yet present in the
             * GroupCommand.cs as well. So the new group will be activated by
             * the mentioned command. If the GroupCommand.cs would change,
             * just uncomment the following two lines.
             *
             * if (success)
             * {
             *  Console.WriteLine(Client.ToString() + " setting " + groupID.ToString() + " as the active group");
             *  Client.Groups.ActivateGroup(groupID);
             * }
             *
             */

            joinedGroup = success;
            GetGroupsSearchEvent.Set();
        }
        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();
        }
示例#23
0
 public override string AsString()
 {
     return(value.ToString());
 }
示例#24
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 2)
            {
                return("Usage: export uuid outputfile.xml");
            }

            LLUUID id;
            uint   localid = 0;
            int    count   = 0;
            string file    = args[1];

            try
            {
                id = new LLUUID(args[0]);
            }
            catch (Exception)
            {
                return("Usage: export uuid outputfile.xml");
            }

            lock (TestClient.SimPrims)
            {
                if (TestClient.SimPrims.ContainsKey(Client.Network.CurrentSim))
                {
                    foreach (PrimObject prim in TestClient.SimPrims[Client.Network.CurrentSim].Values)
                    {
                        if (prim.ID == id)
                        {
                            if (prim.ParentID != 0)
                            {
                                localid = prim.ParentID;
                            }
                            else
                            {
                                localid = prim.LocalID;
                            }

                            break;
                        }
                    }
                }
            }

            if (localid != 0)
            {
                // Check for export permission first
                Client.Objects.RequestObjectPropertiesFamily(Client.Network.CurrentSim, id);
                GotPermissionsEvent.WaitOne(5000, false);

                if (!GotPermissions)
                {
                    return("Couldn't fetch permissions for the requested object, try again");
                }
                else
                {
                    GotPermissions = false;

                    if (Properties == null)
                    {
                        return("Null object properties returned, may be a bug. Try again");
                    }

                    if (Properties.OwnerID != Client.Network.AgentID)
                    {
                        // We need a MasterID field, those exports should be allowed as well
                        return("That object is owned by " + Properties.OwnerID + ", we don't have permission " +
                               "to export it");
                    }
                }

                try
                {
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;
                    XmlWriter writer = XmlWriter.Create(file, settings);

                    try
                    {
                        List <PrimObject> prims = new List <PrimObject>();

                        lock (TestClient.SimPrims)
                        {
                            if (TestClient.SimPrims.ContainsKey(Client.Network.CurrentSim))
                            {
                                foreach (PrimObject prim in TestClient.SimPrims[Client.Network.CurrentSim].Values)
                                {
                                    if (prim.LocalID == localid || prim.ParentID == localid)
                                    {
                                        prims.Add(prim);
                                        count++;
                                    }
                                }
                            }
                        }
                        //Serialize it!
                        Helpers.PrimListToXml(prims, writer);
                    }
                    finally
                    {
                        writer.Close();
                    }
                }
                catch (Exception e)
                {
                    string ret = "Failed to write to " + file + ":" + e.ToString();
                    if (ret.Length > 1000)
                    {
                        ret = ret.Remove(1000);
                    }
                    return(ret);
                }

                return("Exported " + count + " prims to " + file);
            }
            else
            {
                return("Couldn't find UUID " + id.ToString() + " in the " +
                       TestClient.SimPrims[Client.Network.CurrentSim].Count +
                       "objects currently indexed in the current simulator");
            }
        }
示例#25
0
        private void Self_OnInstantMessage(LLUUID fromAgentID, string fromAgentName, LLUUID toAgentID, uint parentEstateID,
                                           LLUUID regionID, LLVector3 position, byte dialog, bool groupIM, LLUUID imSessionID, DateTime timestamp,
                                           string message, byte offline, byte[] binaryBucket)
        {
            if (Master.Length > 0)
            {
                if (fromAgentName.ToLower().Trim() != Master.ToLower().Trim())
                {
                    // Received an IM from someone that is not the bot's master, ignore
                    Console.WriteLine("<IM>" + fromAgentName + " (not master): " + message + "@" + regionID.ToString() + ":" + position.ToString());
                    return;
                }
            }
            else
            {
                if (GroupMembers != null && !GroupMembers.ContainsKey(fromAgentID))
                {
                    // Received an IM from someone outside the bot's group, ignore
                    Console.WriteLine("<IM>" + fromAgentName + " (not in group): " + message + "@" + regionID.ToString() + ":" + position.ToString());
                    return;
                }
            }

            Console.WriteLine("<IM>" + fromAgentName + ": " + message);

            if (Self.ID == toAgentID)
            {
                if (dialog == 22)
                {
                    Console.WriteLine("Accepting teleport lure");
                    Self.TeleportLureRespond(fromAgentID, true);
                }
                else
                {
                    DoCommand(message, fromAgentID, imSessionID);
                }
            }
            else
            {
                // This shouldn't happen
                Console.WriteLine("A bot that we aren't tracking received an IM?");
            }
        }
示例#26
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);
        }
示例#27
0
        public override int GetHashCode()
        {
            string Compound = FolderID.ToString() + Recurse + Received + FetchFolders + Expected + FetchItems;

            return(Compound.GetHashCode());
        }
示例#28
0
        private void DirPeopleHandler(Packet packet, Simulator simulator)
        {
            lstFindMutex.WaitOne();

            foreach (Block block in packet.Blocks())
            {
                if (block.Layout.Name == "QueryReplies")
                {
                    LLUUID id        = null;
                    string firstName = "";
                    string lastName  = "";
                    bool   online    = false;

                    foreach (Field field in block.Fields)
                    {
                        if (field.Layout.Name == "AgentID")
                        {
                            id = (LLUUID)field.Data;
                        }
                        else if (field.Layout.Name == "LastName")
                        {
                            lastName = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", "");
                        }
                        else if (field.Layout.Name == "FirstName")
                        {
                            firstName = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", "");
                        }
                        else if (field.Layout.Name == "Online")
                        {
                            online = (bool)field.Data;
                        }
                    }

                    if (id != null)
                    {
                        ListViewItem listItem = new ListViewItem(new string[]
                                                                 { firstName + " " + lastName, (online ? "Yes" : "No"), id.ToString() });
                        lstFind.Items.Add(listItem);
                    }
                }
            }

            lstFindMutex.ReleaseMutex();
        }
示例#29
0
        private void cmdUpload_Click(object sender, EventArgs e)
        {
            SendToID = LLUUID.Zero;
            string sendTo = txtSendtoName.Text.Trim();

            if (sendTo.Length > 0)
            {
                AutoResetEvent lookupEvent   = new AutoResetEvent(false);
                LLUUID         thisQueryID   = LLUUID.Random();
                bool           lookupSuccess = false;

                DirectoryManager.DirPeopleReplyCallback callback =
                    delegate(LLUUID queryID, List <DirectoryManager.AgentSearchData> matchedPeople)
                {
                    if (queryID == thisQueryID)
                    {
                        if (matchedPeople.Count > 0)
                        {
                            SendToID      = matchedPeople[0].AgentID;
                            lookupSuccess = true;
                        }

                        lookupEvent.Set();
                    }
                };

                Client.Directory.OnDirPeopleReply += callback;
                Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, sendTo, 0, thisQueryID);

                bool eventSuccess = lookupEvent.WaitOne(10 * 1000, false);
                Client.Directory.OnDirPeopleReply -= callback;

                if (eventSuccess && lookupSuccess)
                {
                    Client.Log("Will send uploaded image to avatar " + SendToID.ToString(), Helpers.LogLevel.Info);
                }
                else
                {
                    MessageBox.Show("Could not find avatar \"" + sendTo + "\", upload cancelled");
                    return;
                }
            }

            if (UploadData != null)
            {
                prgUpload.Value   = 0;
                cmdLoad.Enabled   = false;
                cmdUpload.Enabled = false;
                grpLogin.Enabled  = false;

                string name = System.IO.Path.GetFileNameWithoutExtension(FileName);

                Client.Inventory.RequestCreateItemFromAsset(UploadData, name, "Uploaded with SL Image Upload", AssetType.Texture,
                                                            InventoryType.Texture, Client.Inventory.FindFolderForType(AssetType.Texture),
                                                            delegate(bool success, string status, LLUUID itemID, LLUUID assetID)
                {
                    if (this.InvokeRequired)
                    {
                        BeginInvoke(new MethodInvoker(EnableControls));
                    }
                    else
                    {
                        EnableControls();
                    }

                    if (success)
                    {
                        AssetID = assetID;
                        UpdateAssetID();

                        // Fix the permissions on the new upload since they are fscked by default
                        InventoryItem item = Client.Inventory.FetchItem(itemID, Client.Self.AgentID, 1000 * 15);

                        if (item != null)
                        {
                            item.Permissions.EveryoneMask  = PermissionMask.All;
                            item.Permissions.NextOwnerMask = PermissionMask.All;
                            Client.Inventory.RequestUpdateItem(item);

                            Client.Log("Created inventory item " + itemID.ToString(), Helpers.LogLevel.Info);
                            MessageBox.Show("Created inventory item " + itemID.ToString());

                            // FIXME: We should be watching the callback for RequestUpdateItem instead of a dumb sleep
                            System.Threading.Thread.Sleep(2000);

                            if (SendToID != LLUUID.Zero)
                            {
                                Client.Log("Sending item to " + SendToID.ToString(), Helpers.LogLevel.Info);
                                Client.Inventory.GiveItem(itemID, name, AssetType.Texture, SendToID, true);
                                MessageBox.Show("Sent item to " + SendToID.ToString());
                            }
                        }
                        else
                        {
                            Client.DebugLog("Created inventory item " + itemID.ToString() + " but failed to fetch it," +
                                            " cannot update permissions or send to another avatar");
                            MessageBox.Show("Created inventory item " + itemID.ToString() + " but failed to fetch it," +
                                            " cannot update permissions or send to another avatar");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Asset upload failed: " + status);
                    }
                }
                                                            );
            }
        }