示例#1
0
        public override string Execute(string[] args, UUID fromAgentID)
		{
			string masterName = String.Empty;
			for (int ct = 0; ct < args.Length;ct++)
				masterName = masterName + args[ct] + " ";
            masterName = masterName.TrimEnd();

            if (masterName.Length == 0)
                return "Usage: setmaster [name]";

            DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler);
            Client.Directory.OnDirPeopleReply += callback;

            query = Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, masterName, 0);

            if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false))
            {
                Client.MasterKey = resolvedMasterKey;
                keyResolution.Reset();
                Client.Directory.OnDirPeopleReply -= callback;
            }
            else
            {
                keyResolution.Reset();
                Client.Directory.OnDirPeopleReply -= callback;
                return "Unable to obtain UUID for \"" + masterName + "\". Master unchanged.";
            }
            
            // Send an Online-only IM to the new master
            Client.Self.InstantMessage(
                Client.MasterKey, "You are now my master.  IM me with \"help\" for a command list.");

            return String.Format("Master set to {0} ({1})", masterName, Client.MasterKey.ToString());
		}
示例#2
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            string masterName = String.Empty;

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

            if (masterName.Length == 0)
            {
                return("Usage: setmaster [name]");
            }

            DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler);
            Client.Directory.OnDirPeopleReply += callback;

            query = Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, masterName, 0);

            if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false))
            {
                Client.MasterKey = resolvedMasterKey;
                keyResolution.Reset();
                Client.Directory.OnDirPeopleReply -= callback;
            }
            else
            {
                keyResolution.Reset();
                Client.Directory.OnDirPeopleReply -= callback;
                return("Unable to obtain UUID for \"" + masterName + "\". Master unchanged.");
            }

            // Send an Online-only IM to the new master
            Client.Self.InstantMessage(
                Client.MasterKey, "You are now my master.  IM me with \"help\" for a command list.");

            return(String.Format("Master set to {0} ({1})", masterName, Client.MasterKey.ToString()));
        }
示例#3
0
        public override string Execute(string[] args, LLUUID fromAgentID)
		{
			string masterName = String.Empty;
			for (int ct = 0; ct < args.Length;ct++)
				masterName = masterName + args[ct] + " ";
            masterName = masterName.TrimEnd();

            if (masterName.Length == 0)
                return "Usage setMaster name";

            DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler);
            Client.Directory.OnDirPeopleReply += callback;
            query = Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, masterName, 0);
            if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false))
            {
                Client.MasterKey = resolvedMasterKey;
                keyResolution.Reset();
                Client.Directory.OnDirPeopleReply -= callback;
            }
            else
            {
                keyResolution.Reset();
                Client.Directory.OnDirPeopleReply -= callback;
                return "Unable to obtain UUID for \"" + masterName + "\". Master unchanged.";
            }
            

			foreach (Avatar av in Client.AvatarList.Values)
			{
			    if (av.ID == Client.MasterKey)
			    {
			        Client.Self.InstantMessage(av.ID, "You are now my master.  IM me with \"help\" for a command list.");
			        break;
			    }
			}

            return "Master set to " + masterName + " (" + Client.MasterKey.ToStringHyphenated() + ")";
		}
示例#4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public TestClient Login(LoginDetails account)
        {
            // Check if this client is already logged in
            foreach (TestClient c in Clients.Values)
            {
                if (c.Self.FirstName == account.FirstName && c.Self.LastName == account.LastName)
                {
                    Logout(c);
                    break;
                }
            }

            TestClient client = new TestClient(this);

            // Optimize the throttle
            client.Throttle.Wind = 0;
            client.Throttle.Cloud = 0;
            client.Throttle.Land = 1000000;
            client.Throttle.Task = 1000000;

			client.MasterName = account.MasterName;
            client.MasterKey = account.MasterKey;

            NetworkManager.LoginParams loginParams = client.Network.DefaultLoginParams(
                    account.FirstName, account.LastName, account.Password, "TestClient", contactPerson);

            if (!String.IsNullOrEmpty(account.StartLocation))
                loginParams.Start = account.StartLocation;

            if (!String.IsNullOrEmpty(account.URI))
                loginParams.URI = account.URI;
            
            if (!client.Network.Login(loginParams))
            {
                Console.WriteLine("Failed to login " + account.FirstName + " " + account.LastName + ": " +
                    client.Network.LoginMessage);
            }

            if (client.Network.Connected)
            {
                if (account.MasterKey == LLUUID.Zero && !String.IsNullOrEmpty(account.MasterName))
                {
                    Console.WriteLine("Resolving {0}'s UUID", account.MasterName);
                    // Find master's key from name
                    DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler);
                    client.Directory.OnDirPeopleReply += callback;
                    client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, account.MasterName, 0);
                    if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false))
                    {
                        account.MasterKey = resolvedMasterKey;
                        Console.WriteLine("\"{0}\" resolved to {1}", account.MasterName, account.MasterKey);
                    }
                    else
                    {
                        Console.WriteLine("Unable to obtain UUID for \"{0}\". No master will be used. Try specifying a key with --masterkey.", account.MasterName);
                    }
                    client.Directory.OnDirPeopleReply -= callback;
                    keyResolution.Reset();
                }

                client.MasterKey = account.MasterKey;

                Clients[client.Self.AgentID] = client;

                Console.WriteLine("Logged in " + client.ToString());
            }

            return client;
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public TestClient Login(LoginDetails account)
        {
            // Check if this client is already logged in
            foreach (TestClient c in Clients.Values)
            {
                if (c.Self.FirstName == account.FirstName && c.Self.LastName == account.LastName)
                {
                    Logout(c);
                    break;
                }
            }

            TestClient client = new TestClient(this);

            // Optimize the throttle
            client.Throttle.Wind  = 0;
            client.Throttle.Cloud = 0;
            client.Throttle.Land  = 1000000;
            client.Throttle.Task  = 1000000;

            client.GroupCommands = account.GroupCommands;
            client.MasterName    = account.MasterName;
            client.MasterKey     = account.MasterKey;

            LoginParams loginParams = client.Network.DefaultLoginParams(
                account.FirstName, account.LastName, account.Password, "TestClient", version);

            if (!String.IsNullOrEmpty(account.StartLocation))
            {
                loginParams.Start = account.StartLocation;
            }

            if (!String.IsNullOrEmpty(account.URI))
            {
                loginParams.URI = account.URI;
            }

            if (client.Network.Login(loginParams))
            {
                if (account.MasterKey == LLUUID.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 <DirectoryManager.AgentSearchData> masterMatches = new List <DirectoryManager.AgentSearchData>();

                    // Set up the callback that handles the search results:
                    DirectoryManager.DirPeopleReplyCallback callback =
                        delegate(LLUUID queryID, List <DirectoryManager.AgentSearchData> 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;

                    LLUUID masterKey  = LLUUID.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 != LLUUID.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;

                Console.WriteLine("Logged in " + client.ToString());
            }
            else
            {
                Console.WriteLine("Failed to login " + account.FirstName + " " + account.LastName + ": " +
                                  client.Network.LoginMessage);
            }

            return(client);
        }
示例#6
0
        private void cmdUpload_Click(object sender, EventArgs e)
        {
            SendToID = UUID.Zero;
            string sendTo = txtSendtoName.Text.Trim();

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

                DirectoryManager.DirPeopleReplyCallback callback =
                    delegate(UUID 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)
                {
                    Logger.Log("Will send uploaded image to avatar " + SendToID.ToString(), Helpers.LogLevel.Info, Client);
                }
                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(CapsClient client, long bytesReceived, long bytesSent, long totalBytesToReceive, long totalBytesToSend)
                {
                    if (bytesSent > 0)
                    {
                        Transferred = (int)bytesSent;
                        BeginInvoke((MethodInvoker) delegate() { SetProgress(); });
                    }
                },

                                                            delegate(bool success, string status, UUID itemID, UUID 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);

                        Transferred = UploadData.Length;
                        BeginInvoke((MethodInvoker) delegate() { SetProgress(); });

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

                            Logger.Log("Created inventory item " + itemID.ToString(), Helpers.LogLevel.Info, Client);
                            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 != UUID.Zero)
                            {
                                Logger.Log("Sending item to " + SendToID.ToString(), Helpers.LogLevel.Info, Client);
                                Client.Inventory.GiveItem(itemID, name, AssetType.Texture, SendToID, true);
                                MessageBox.Show("Sent item to " + SendToID.ToString());
                            }
                        }
                        else
                        {
                            Logger.DebugLog("Created inventory item " + itemID.ToString() + " but failed to fetch it," +
                                            " cannot update permissions or send to another avatar", Client);
                            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);
                    }
                }
                                                            );
            }
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public TestClient Login(LoginDetails account)
        {
            // Check if this client is already logged in
            foreach (TestClient c in Clients.Values)
            {
                if (c.Self.FirstName == account.FirstName && c.Self.LastName == account.LastName)
                {
                    Logout(c);
                    break;
                }
            }

            TestClient client = new TestClient(this);

            // Optimize the throttle
            client.Throttle.Wind  = 0;
            client.Throttle.Cloud = 0;
            client.Throttle.Land  = 1000000;
            client.Throttle.Task  = 1000000;

            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);

            if (!String.IsNullOrEmpty(account.StartLocation))
            {
                loginParams.Start = account.StartLocation;
            }

            if (!String.IsNullOrEmpty(account.URI))
            {
                loginParams.URI = account.URI;
            }

            if (client.Network.Login(loginParams))
            {
                Clients[client.Self.AgentID] = client;

                if (client.MasterKey == UUID.Zero)
                {
                    UUID query = UUID.Random();
                    DirectoryManager.DirPeopleReplyCallback peopleDirCallback =
                        delegate(UUID queryID, List <DirectoryManager.AgentSearchData> matchedPeople)
                    {
                        if (queryID == query)
                        {
                            if (matchedPeople.Count != 1)
                            {
                                Logger.Log("Unable to resolve master key from " + client.MasterName, Helpers.LogLevel.Warning);
                            }
                            else
                            {
                                client.MasterKey = matchedPeople[0].AgentID;
                                Logger.Log("Master key resolved to " + client.MasterKey, Helpers.LogLevel.Info);
                            }
                        }
                    };

                    client.Directory.OnDirPeopleReply += peopleDirCallback;
                    client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, client.MasterName, 0, query);
                }

                Logger.Log("Logged in " + client.ToString(), Helpers.LogLevel.Info);
            }
            else
            {
                Logger.Log("Failed to login " + account.FirstName + " " + account.LastName + ": " +
                           client.Network.LoginMessage, Helpers.LogLevel.Warning);
            }

            return(client);
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public TestClient Login(LoginDetails account)
        {
            // Check if this client is already logged in
            foreach (TestClient c in Clients.Values)
            {
                if (c.Self.FirstName == account.FirstName && c.Self.LastName == account.LastName)
                {
                    Logout(c);
                    break;
                }
            }

            TestClient client = new TestClient(this);

            // Optimize the throttle
            client.Throttle.Wind  = 0;
            client.Throttle.Cloud = 0;
            client.Throttle.Land  = 1000000;
            client.Throttle.Task  = 1000000;

            client.MasterName = account.MasterName;
            client.MasterKey  = account.MasterKey;

            LoginParams loginParams = client.Network.DefaultLoginParams(
                account.FirstName, account.LastName, account.Password, "TestClient", version);

            if (!String.IsNullOrEmpty(account.StartLocation))
            {
                loginParams.Start = account.StartLocation;
            }

            if (!String.IsNullOrEmpty(account.URI))
            {
                loginParams.URI = account.URI;
            }

            if (!client.Network.Login(loginParams))
            {
                Console.WriteLine("Failed to login " + account.FirstName + " " + account.LastName + ": " +
                                  client.Network.LoginMessage);
            }

            if (client.Network.Connected)
            {
                if (account.MasterKey == LLUUID.Zero && !String.IsNullOrEmpty(account.MasterName))
                {
                    Console.WriteLine("Resolving {0}'s UUID", account.MasterName);
                    // Find master's key from name
                    DirectoryManager.DirPeopleReplyCallback callback = new DirectoryManager.DirPeopleReplyCallback(KeyResolvHandler);
                    client.Directory.OnDirPeopleReply += callback;
                    client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, account.MasterName, 0);
                    if (keyResolution.WaitOne(TimeSpan.FromMinutes(1), false))
                    {
                        account.MasterKey = resolvedMasterKey;
                        Console.WriteLine("\"{0}\" resolved to {1}", account.MasterName, account.MasterKey);
                    }
                    else
                    {
                        Console.WriteLine("Unable to obtain UUID for \"{0}\". No master will be used. Try specifying a key with --masterkey.", account.MasterName);
                    }
                    client.Directory.OnDirPeopleReply -= callback;
                    keyResolution.Reset();
                }

                client.MasterKey = account.MasterKey;

                Clients[client.Self.AgentID] = client;

                Console.WriteLine("Logged in " + client.ToString());
            }

            return(client);
        }