diff --git a/Programs/PrimWorkshop/frmBrowser.cs b/Programs/PrimWorkshop/frmBrowser.cs index 59c5adb2..42532675 100644 --- a/Programs/PrimWorkshop/frmBrowser.cs +++ b/Programs/PrimWorkshop/frmBrowser.cs @@ -1590,8 +1590,10 @@ StartRender: // Start the login LoginParams loginParams = Client.Network.DefaultLoginParams(txtFirst.Text, txtLast.Text, txtPass.Text, "Prim Preview", "0.0.1"); - if (!String.IsNullOrEmpty((string)cboServer.Items[cboServer.SelectedIndex])) - loginParams.URI = (string)cboServer.Items[cboServer.SelectedIndex]; + + if (!String.IsNullOrEmpty(cboServer.Text)) + loginParams.URI = cboServer.Text; + Client.Network.BeginLogin(loginParams); } else diff --git a/Programs/examples/TestClient/ClientManager.cs b/Programs/examples/TestClient/ClientManager.cs index a3ec9f98..e31de55a 100644 --- a/Programs/examples/TestClient/ClientManager.cs +++ b/Programs/examples/TestClient/ClientManager.cs @@ -94,6 +94,7 @@ namespace OpenMetaverse.TestClient client.GroupCommands = account.GroupCommands; client.MasterName = account.MasterName; client.MasterKey = account.MasterKey; + client.AllowObjectMaster = client.MasterKey != UUID.Zero; // Require UUID for object master. LoginParams loginParams = client.Network.DefaultLoginParams( account.FirstName, account.LastName, account.Password, "TestClient", version); @@ -106,96 +107,22 @@ namespace OpenMetaverse.TestClient if (client.Network.Login(loginParams)) { - if (account.MasterKey == UUID.Zero && !String.IsNullOrEmpty(account.MasterName)) - { - // To prevent security issues, we must resolve the specified master name to a key. - ManualResetEvent keyResolution = new ManualResetEvent(false); - List masterMatches = new List(); - - // Set up the callback that handles the search results: - DirectoryManager.DirPeopleReplyCallback callback = - delegate (UUID queryID, List matches) { - // This may be called several times with additional search results. - if (matches.Count > 0) - { - lock (masterMatches) - { - masterMatches.AddRange(matches); - } - } - else - { - // No results to show. - keyResolution.Set(); - } - }; - // Find master's key from name - Console.WriteLine("Resolving {0}'s UUID", account.MasterName); - client.Directory.OnDirPeopleReply += callback; - client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, account.MasterName, 0); - keyResolution.WaitOne(TimeSpan.FromSeconds(30), false); - client.Directory.OnDirPeopleReply -= callback; - - UUID masterKey = UUID.Zero; - string masterName = account.MasterName; - lock (masterMatches) { - if (masterMatches.Count == 1) { - masterKey = masterMatches[0].AgentID; - masterName = masterMatches[0].FirstName + " " + masterMatches[0].LastName; - } else if (masterMatches.Count > 0) { - // Print out numbered list of masters: - Console.WriteLine("Possible masters:"); - for (int i = 0; i < masterMatches.Count; ++i) - { - Console.WriteLine("{0}: {1}", i, masterMatches[i].FirstName + " " + masterMatches[i].LastName); - } - Console.Write("Ambiguous master, choose one: "); - // Read number from the console: - string read = null; - do - { - read = Console.ReadLine(); - int choice = 0; - if (int.TryParse(read, out choice)) - { - if (choice == -1) - { - break; - } - else if (choice < masterMatches.Count) - { - masterKey = masterMatches[choice].AgentID; - masterName = masterMatches[choice].FirstName + " " + masterMatches[choice].LastName; - break; - } - else - { - Console.WriteLine("Please type a number from the above list, -1 to cancel."); - } - } - else - { - Console.WriteLine("You didn't type a number."); - Console.WriteLine("Please type a number from the above list, -1 to cancel."); - } - } while (read != null); // Do it until the user selects a master. - } - } - if (masterKey != UUID.Zero) - { - Console.WriteLine("\"{0}\" resolved to {1} ({2})", account.MasterName, masterName, masterKey); - account.MasterName = masterName; - account.MasterKey = masterKey; - } - else - { - Console.WriteLine("Unable to obtain UUID for \"{0}\". No master will be used. Try specifying a key with --masterkey.", account.MasterName); - } - } - - client.MasterKey = account.MasterKey; Clients[client.Self.AgentID] = client; - + if (client.MasterKey == UUID.Zero) + { + UUID query = UUID.Random(); + client.Directory.OnDirPeopleReply += + delegate(UUID queryID, List matchedPeople) + { + if (queryID != query) + return; + if (matchedPeople.Count != 1) + Console.WriteLine("Unable to resolve master key."); + else + client.MasterKey = matchedPeople[0].AgentID; + }; + client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, client.MasterName, 0, query); + } Console.WriteLine("Logged in " + client.ToString()); } else diff --git a/Programs/examples/TestClient/Commands/Communication/EchoMasterCommand.cs b/Programs/examples/TestClient/Commands/Communication/EchoMasterCommand.cs index 279c95f3..683c7c66 100644 --- a/Programs/examples/TestClient/Commands/Communication/EchoMasterCommand.cs +++ b/Programs/examples/TestClient/Commands/Communication/EchoMasterCommand.cs @@ -34,7 +34,7 @@ namespace OpenMetaverse.TestClient void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype, string fromName, UUID id, UUID ownerid, Vector3 position) { - if (message.Length > 0 && Client.MasterKey == id) + if (message.Length > 0 && (Client.MasterKey == id || (Client.MasterName == fromName && !Client.AllowObjectMaster))) Client.Self.Chat(message, 0, ChatType.Normal); } } diff --git a/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs b/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs index 5f35eeb1..fb37d002 100644 --- a/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs +++ b/Programs/examples/TestClient/Commands/Movement/FollowCommand.cs @@ -33,10 +33,24 @@ namespace OpenMetaverse.TestClient } else { - if (Follow(Client.MasterKey)) - return "Following " + Client.MasterKey; + if (Client.MasterKey != UUID.Zero) + { + if (Follow(Client.MasterKey)) + return "Following UUID " + Client.MasterKey; + else + return "Unable to follow UUID " + Client.MasterKey; + } + else if (Client.MasterName != String.Empty) + { + if (Follow(Client.MasterName)) + return "Following " + Client.MasterName; + else + return "Unable to follow " + Client.MasterName; + } else - return "No target specified and no master not found. usage: follow [FirstName LastName])"; + { + return "No master specified. Usage: follow "; + } } } diff --git a/Programs/examples/TestClient/TestClient.cs b/Programs/examples/TestClient/TestClient.cs index a971e772..af544fa8 100644 --- a/Programs/examples/TestClient/TestClient.cs +++ b/Programs/examples/TestClient/TestClient.cs @@ -18,6 +18,7 @@ namespace OpenMetaverse.TestClient public bool GroupCommands = false; public string MasterName = String.Empty; public UUID MasterKey = UUID.Zero; + public bool AllowObjectMaster = false; public ClientManager ClientManager; public VoiceManager VoiceManager; // Shell-like inventory commands need to be aware of the 'current' inventory folder. @@ -221,7 +222,10 @@ namespace OpenMetaverse.TestClient bool groupIM = im.GroupIM && GroupMembers != null && GroupMembers.ContainsKey(im.FromAgentID) ? true : false; - if (im.FromAgentID == MasterKey || (GroupCommands && groupIM)) + if ((im.Dialog == InstantMessageDialog.MessageFromObject) && !AllowObjectMaster) + return; + + if (im.FromAgentID == MasterKey || im.FromAgentName == MasterName || (GroupCommands && groupIM)) { // Received an IM from someone that is authenticated Console.WriteLine("<{0} ({1})> {2}: {3} (@{4}:{5})", im.GroupIM ? "GroupIM" : "IM", im.Dialog, im.FromAgentName, im.Message, im.RegionID, im.Position); @@ -246,7 +250,6 @@ namespace OpenMetaverse.TestClient im.RegionID, im.Position); return; } - } private UUID Inventory_OnInventoryObjectReceived(InstantMessage offer, AssetType type, @@ -261,6 +264,15 @@ namespace OpenMetaverse.TestClient { return UUID.Zero; } + else if (MasterName != String.Empty) + { + if (offer.FromAgentName != MasterName) + return UUID.Zero; + } + else if (fromTask && !AllowObjectMaster) + { + return UUID.Zero; + } return Inventory.FindFolderForType(type); }