From 9f6b3e2357e76b9b85b447da189b4bf4163edd3c Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 13 Nov 2007 22:48:19 +0000 Subject: * Added AvatarPicker in Standalone mode. Works for finding avatar to ban, manually trying to add a friend (with the add button) or useful to those who are curious which usernames have visited your standalone sim. Important for future development :D. * Grid mode always returns 0 results until the Grid Communications portion is done. --- .../Communications/CommunicationsManager.cs | 10 +++ OpenSim/Framework/Communications/IGridServices.cs | 1 + .../Framework/Communications/UserManagerBase.cs | 19 +++++ OpenSim/Framework/Data.DB4o/DB4oGridData.cs | 10 +++ OpenSim/Framework/Data.DB4o/DB4oUserData.cs | 8 +- OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs | 13 ++++ OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 85 ++++++++++++++++++++++ OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 81 ++++++++++++++++++++- OpenSim/Framework/Data.SQLite/SQLiteGridData.cs | 11 ++- OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 53 ++++++++++++++ OpenSim/Framework/Data/GridData.cs | 12 +++ OpenSim/Framework/IClientAPI.cs | 3 + OpenSim/Framework/IUserData.cs | 12 +++ OpenSim/Framework/IUserService.cs | 2 + OpenSim/Framework/UserProfileData.cs | 13 ++++ OpenSim/Region/ClientStack/ClientView.API.cs | 5 ++ .../ClientStack/ClientView.ProcessPackets.cs | 11 ++- OpenSim/Region/ClientStack/ClientView.cs | 15 ++-- .../Region/Communications/OGS1/OGS1UserServices.cs | 8 ++ .../Environment/Scenes/Scene.PacketHandlers.cs | 39 ++++++++++ OpenSim/Region/Environment/Scenes/Scene.cs | 5 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 4 + .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 4 + 23 files changed, 413 insertions(+), 11 deletions(-) diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 77c7261..7b1a97e 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -28,6 +28,7 @@ using System; using libsecondlife; using OpenSim.Framework.Communications.Cache; +using System.Collections.Generic; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; @@ -173,6 +174,15 @@ namespace OpenSim.Framework.Communications } } } + public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) + { + + + List pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); + + + return pickerlist; + } #endregion } diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index ce6205f..3d0af09 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -36,5 +36,6 @@ namespace OpenSim.Framework.Communications List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); + } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 408f37c..3a32ba9 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -105,6 +105,25 @@ namespace OpenSim.Framework.UserManagement return null; } + public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) + { + List pickerlist = new List(); + foreach (KeyValuePair plugin in _plugins) + { + try + { + pickerlist = plugin.Value.GeneratePickerResults(queryID, query); + + } + catch (Exception e) + { + MainLog.Instance.Verbose("Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); + return new List(); + } + } + return pickerlist; + } + /// /// Loads a user profile by name diff --git a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs index a96d9bd..a071543 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs @@ -27,6 +27,7 @@ */ using System; +using System.Collections.Generic; using libsecondlife; namespace OpenSim.Framework.Data.DB4o @@ -139,7 +140,16 @@ namespace OpenSim.Framework.Data.DB4o { manager = null; } + /// + /// // Returns a list of avatar and UUIDs that match the query + /// + public List GeneratePickerResults(LLUUID queryID, string query) + { + //Do nothing yet + List returnlist = new List(); + return returnlist; + } /// /// Returns the providers name /// diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs index c7113bf..4c6d4b0 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs @@ -27,6 +27,7 @@ */ using System; using System.IO; +using System.Collections.Generic; using libsecondlife; namespace OpenSim.Framework.Data.DB4o @@ -131,7 +132,12 @@ namespace OpenSim.Framework.Data.DB4o return null; } } - + public List GeneratePickerResults(LLUUID queryID, string query) + { + //Do nothing yet + List returnlist = new List(); + return returnlist; + } /// /// Creates a new user profile /// diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs index 1946790..1516fec 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs @@ -28,10 +28,12 @@ using System; using System.Collections.Generic; using System.Data; +using OpenSim.Framework; using System.Security.Cryptography; using System.Text; using libsecondlife; + namespace OpenSim.Framework.Data.MSSQL { /// @@ -130,7 +132,16 @@ namespace OpenSim.Framework.Data.MSSQL return row; } + /// + /// // Returns a list of avatar and UUIDs that match the query + /// + public List GeneratePickerResults(LLUUID queryID, string query) + { + //Do nothing yet + List returnlist = new List(); + return returnlist; + } /// /// Adds a new specified region to the database /// @@ -190,5 +201,7 @@ namespace OpenSim.Framework.Data.MSSQL { return null; } + // This is here because MSSQL GridData only seems to know about itself o.O + } } \ No newline at end of file diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index fdfc61c..930b3f4 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs @@ -169,6 +169,91 @@ namespace OpenSim.Framework.Data.MySQL return null; } } + /// + /// // Returns a list of avatar and UUIDs that match the query + /// + + public List GeneratePickerResults(LLUUID queryID, string query) + { + List returnlist = new List(); + string[] querysplit; + querysplit = query.Split(' '); + if (querysplit.Length == 2) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?first"] = querysplit[0]; + param["?second"] = querysplit[1]; + + IDbCommand result = + database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first AND lastname = ?second", param); + IDataReader reader = result.ExecuteReader(); + + + while (reader.Read()) + { + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string)reader["UUID"]); + user.firstName = (string)reader["username"]; + user.lastName = (string)reader["surname"]; + returnlist.Add(user); + + } + reader.Close(); + result.Dispose(); + } + } + catch (Exception e) + { + database.Reconnect(); + MainLog.Instance.Error(e.ToString()); + return returnlist; + } + + + + } + else if (querysplit.Length == 1) + { + + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?first"] = querysplit[0]; + param["?second"] = querysplit[1]; + + IDbCommand result = + database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first OR lastname = ?second", param); + IDataReader reader = result.ExecuteReader(); + + + while (reader.Read()) + { + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string)reader["UUID"]); + user.firstName = (string)reader["username"]; + user.lastName = (string)reader["surname"]; + returnlist.Add(user); + + } + reader.Close(); + result.Dispose(); + } + } + catch (Exception e) + { + database.Reconnect(); + MainLog.Instance.Error(e.ToString()); + return returnlist; + } + } + return returnlist; + } /// /// Returns a sim profile from it's UUID diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 8846650..3ae1fba 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -97,7 +97,6 @@ namespace OpenSim.Framework.Data.MySQL reader.Close(); result.Dispose(); - return row; } } @@ -108,7 +107,87 @@ namespace OpenSim.Framework.Data.MySQL return null; } } + public List GeneratePickerResults(LLUUID queryID, string query) + { + List returnlist = new List(); + string[] querysplit; + querysplit = query.Split(' '); + if (querysplit.Length == 2) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?first"] = querysplit[0]; + param["?second"] = querysplit[1]; + + IDbCommand result = + database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first AND lastname = ?second", param); + IDataReader reader = result.ExecuteReader(); + + + while (reader.Read()) + { + OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string)reader["UUID"]); + user.firstName = (string)reader["username"]; + user.lastName = (string)reader["surname"]; + returnlist.Add(user); + + } + reader.Close(); + result.Dispose(); + } + } + catch (Exception e) + { + database.Reconnect(); + MainLog.Instance.Error(e.ToString()); + return returnlist; + } + + + } + else if (querysplit.Length == 1) + { + + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?first"] = querysplit[0]; + param["?second"] = querysplit[1]; + + IDbCommand result = + database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first OR lastname = ?second", param); + IDataReader reader = result.ExecuteReader(); + + + while (reader.Read()) + { + OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string)reader["UUID"]); + user.firstName = (string)reader["username"]; + user.lastName = (string)reader["surname"]; + returnlist.Add(user); + + } + reader.Close(); + result.Dispose(); + } + } + catch (Exception e) + { + database.Reconnect(); + MainLog.Instance.Error(e.ToString()); + return returnlist; + } + } + return returnlist; + } /// /// Searches the database for a specified user profile by UUID /// diff --git a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs index 8f3e8aa..b8fc639 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs @@ -130,7 +130,16 @@ namespace OpenSim.Framework.Data.SQLite return row; } - + /// + /// // Returns a list of avatar and UUIDs that match the query + /// + + public List GeneratePickerResults(LLUUID queryID, string query) + { + //Do nothing yet + List returnlist = new List(); + return returnlist; + } /// /// Adds a new specified region to the database /// diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs index d7a6b39..1385ffc 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs @@ -26,16 +26,22 @@ * */ using System; +using System.Collections.Generic; using System.Data; using libsecondlife; using Mono.Data.SqliteClient; +using OpenSim.Framework; using OpenSim.Framework.Console; + namespace OpenSim.Framework.Data.SQLite { /// /// A User storage interface for the DB4o database system /// + /// + + public class SQLiteUserData : SQLiteBase, IUserData { /// @@ -135,6 +141,53 @@ namespace OpenSim.Framework.Data.SQLite } } + public List GeneratePickerResults(LLUUID queryID, string query) + { + List returnlist = new List(); + string[] querysplit; + querysplit = query.Split(' '); + if (querysplit.Length == 2) + { + string select = "username like '" + querysplit[0] + "%' and surname like '" + querysplit[1] + "%'"; + lock(ds) + { + DataRow[] rows = ds.Tables["users"].Select(select); + if (rows.Length > 0) + { + for (int i = 0; i < rows.Length; i++) + { + OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); + DataRow row = rows[i]; + user.AvatarID = new LLUUID((string)row["UUID"]); + user.firstName = (string)row["username"]; + user.lastName = (string)row["surname"]; + returnlist.Add(user); + } + } + } + } + else if (querysplit.Length == 1) + { + + string select = "username like '" + querysplit[0] + "%' OR surname like '" + querysplit[0] + "%'"; + lock(ds) + { + DataRow[] rows = ds.Tables["users"].Select(select); + if (rows.Length > 0) + { + for (int i = 0;i /// Returns a user by UUID direct /// diff --git a/OpenSim/Framework/Data/GridData.cs b/OpenSim/Framework/Data/GridData.cs index b3b6ed7..23e7bf6 100644 --- a/OpenSim/Framework/Data/GridData.cs +++ b/OpenSim/Framework/Data/GridData.cs @@ -26,9 +26,19 @@ * */ using libsecondlife; +using System.Collections.Generic; namespace OpenSim.Framework.Data { + public class AvatarPickerAvatar + { + public LLUUID AvatarID; + public string firstName; + public string lastName; + public AvatarPickerAvatar() + { + } + } public enum DataResponse { RESPONSE_OK, @@ -66,6 +76,8 @@ namespace OpenSim.Framework.Data /// An array containing all the sim profiles in the specified range RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); + + List GeneratePickerResults(LLUUID queryID, string query); /// /// Authenticates a sim by use of it's recv key. /// WARNING: Insecure diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index ab5dbb6..d577a20 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -228,6 +228,7 @@ namespace OpenSim.Framework public delegate void AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset); public delegate void AgentSit(IClientAPI remoteClient, LLUUID agentID); + public delegate void AvatarPickerRequest(IClientAPI remoteClient, LLUUID agentdata, LLUUID queryID, string UserQuery); public delegate void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 grapPos, IClientAPI remoteClient); @@ -305,6 +306,7 @@ namespace OpenSim.Framework event UpdateAgent OnAgentUpdate; event AgentRequestSit OnAgentRequestSit; event AgentSit OnAgentSit; + event AvatarPickerRequest OnAvatarPickerRequest; event Action OnRequestAvatarsData; event AddNewPrim OnAddPrim; event ObjectDuplicate OnObjectDuplicate; @@ -423,6 +425,7 @@ namespace OpenSim.Framework void SendRemoveInventoryItem(LLUUID itemID); void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName); void SendXferPacket(ulong xferID, uint packet, byte[] data); + void SendAvatarPickerReply(AvatarPickerReplyPacket Pack); void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID); void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags); diff --git a/OpenSim/Framework/IUserData.cs b/OpenSim/Framework/IUserData.cs index cb2502a..6de9e08 100644 --- a/OpenSim/Framework/IUserData.cs +++ b/OpenSim/Framework/IUserData.cs @@ -26,6 +26,7 @@ * */ using libsecondlife; +using System.Collections.Generic; namespace OpenSim.Framework { @@ -56,6 +57,8 @@ namespace OpenSim.Framework /// The user data profile UserProfileData GetUserByName(string fname, string lname); + List GeneratePickerResults(LLUUID queryID, string query); + /// /// Returns the current agent for a user searching by it's UUID /// @@ -131,4 +134,13 @@ namespace OpenSim.Framework /// void Initialise(); } + public class AvatarPickerAvatar + { + public LLUUID AvatarID; + public string firstName; + public string lastName; + public AvatarPickerAvatar() + { + } + } } \ No newline at end of file diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs index 6465a48..de9865a 100644 --- a/OpenSim/Framework/IUserService.cs +++ b/OpenSim/Framework/IUserService.cs @@ -26,6 +26,7 @@ * */ using libsecondlife; +using System.Collections.Generic; namespace OpenSim.Framework.Interfaces { @@ -35,6 +36,7 @@ namespace OpenSim.Framework.Interfaces UserProfileData GetUserProfile(string name); UserProfileData GetUserProfile(LLUUID userId); void clearUserAgent(LLUUID avatarID); + List GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query); UserProfileData SetupMasterUser(string firstName, string lastName); UserProfileData SetupMasterUser(string firstName, string lastName, string password); diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs index d10aa36..9bd1ad1 100644 --- a/OpenSim/Framework/UserProfileData.cs +++ b/OpenSim/Framework/UserProfileData.cs @@ -146,6 +146,19 @@ namespace OpenSim.Framework } /// + /// Minimal User Data required to service the AvatarPickerReply + /// + //public class AvatarPickerAvatar + //{ + //public LLUUID AvatarID; + //public string firstName; + //public string lastName; + //public AvatarPickerAvatar() + //{ + //} + //} + + /// /// Information about a users session /// public class UserAgentData diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index b24b207..77c1701 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -55,6 +55,7 @@ namespace OpenSim.Region.ClientStack public event UpdateAgent OnAgentUpdate; public event AgentRequestSit OnAgentRequestSit; public event AgentSit OnAgentSit; + public event AvatarPickerRequest OnAvatarPickerRequest; public event StartAnim OnStartAnim; public event Action OnRequestAvatarsData; public event LinkObjects OnLinkObjects; @@ -705,6 +706,10 @@ namespace OpenSim.Region.ClientStack sendXfer.DataPacket.Data = data; OutPacket(sendXfer); } + public void SendAvatarPickerReply(AvatarPickerReplyPacket replyPacket) + { + OutPacket(replyPacket); + } /// /// diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 82ad1c8..1383ad9 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -217,7 +217,16 @@ namespace OpenSim.Region.ClientStack OnAgentSit(this, agentSit.AgentData.AgentID); } break; - + case PacketType.AvatarPickerRequest: + AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; + AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; + AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; + //System.Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name)); + if (OnAvatarPickerRequest != null) + { + OnAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, Helpers.FieldToUTF8String(querydata.Name)); + } + break; #endregion #region Objects/m_sceneObjects diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 839556d..353a24c 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -295,11 +295,16 @@ namespace OpenSim.Region.ClientStack queuedLast = false; // TODO: May be a bit expensive doing this twice. - throttleSentPeriod += nextPacket.Packet.ToBytes().Length; - - //is a out going packet - DebugPacket("OUT", nextPacket.Packet); - ProcessOutPacket(nextPacket.Packet); + + //Don't throttle AvatarPickerReplies!, they return a null .ToBytes()! + if (nextPacket.Packet.Type != PacketType.AvatarPickerReply) + throttleSentPeriod += nextPacket.Packet.ToBytes().Length; + + + //is a out going packet + DebugPacket("OUT", nextPacket.Packet); + ProcessOutPacket(nextPacket.Packet); + } } } diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 990998e..cd60ac2 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -28,6 +28,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Net; using libsecondlife; using Nwc.XmlRpc; @@ -85,6 +86,13 @@ namespace OpenSim.Region.Communications.OGS1 return GetUserProfile(firstName + " " + lastName); } + + public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) + { + List pickerlist = new List(); + + return pickerlist; + } public UserProfileData GetUserProfile(string name) { try diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 74e9a43..435022b 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -29,6 +29,7 @@ using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; +using OpenSim.Framework.UserManagement; using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes @@ -155,5 +156,43 @@ namespace OpenSim.Region.Environment.Scenes } } } + public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query) + { + //EventManager.TriggerAvatarPickerRequest(); + + + List AvatarResponses = new List(); + AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query); + + AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); + AvatarPickerReplyPacket.DataBlock[] searchData = new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; + AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); + + agentData.AgentID = avatarID; + agentData.QueryID = RequestID; + replyPacket.AgentData = agentData; + byte[] bytes = new byte[AvatarResponses.Count * 32]; + + int i = 0; + foreach (AvatarPickerAvatar item in AvatarResponses) + { + LLUUID translatedIDtem = item.AvatarID; + searchData[i] = new AvatarPickerReplyPacket.DataBlock(); + searchData[i].AvatarID = translatedIDtem; + searchData[i].FirstName = Helpers.StringToField((string)item.firstName); + searchData[i].LastName = Helpers.StringToField((string)item.lastName); + i++; + + } + if (AvatarResponses.Count == 0) + { + searchData = new AvatarPickerReplyPacket.DataBlock[0]; + } + replyPacket.Data = searchData; + client.SendAvatarPickerReply(replyPacket); + + + } + } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index bf56fe8..d7e36c5 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -38,10 +38,10 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; +using OpenSim.Region.Environment.LandManagement; using OpenSim.Framework.Servers; using OpenSim.Region.Capabilities; using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Modules; using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Types; @@ -732,7 +732,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnRemoveTaskItem += RemoveTaskInventory; client.OnGrabObject += ProcessObjectGrab; - + client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; + EventManager.TriggerOnNewClient(client); } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index c9c24fe..3c6cad8 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -32,9 +32,11 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Communications; using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; + namespace OpenSim.Region.Environment.Scenes { public partial class ScenePresence : EntityBase @@ -274,6 +276,7 @@ namespace OpenSim.Region.Environment.Scenes m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; m_controllingClient.OnAgentSit += HandleAgentSit; m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; + // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); @@ -1227,5 +1230,6 @@ namespace OpenSim.Region.Environment.Scenes { m_controllingClient.SendWearables(m_wearables, m_wearablesSerial++); } + } } diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 86bb532..61402be 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -71,6 +71,7 @@ namespace SimpleApp public event UpdateAgent OnAgentUpdate; public event AgentRequestSit OnAgentRequestSit; public event AgentSit OnAgentSit; + public event AvatarPickerRequest OnAvatarPickerRequest; public event Action OnRequestAvatarsData; public event AddNewPrim OnAddPrim; public event ObjectDuplicate OnObjectDuplicate; @@ -179,7 +180,10 @@ namespace SimpleApp public virtual void SendStartPingCheck(byte seq) { } + public virtual void SendAvatarPickerReply(AvatarPickerReplyPacket response) + { + } public virtual void SendKillObject(ulong regionHandle, uint localID) { } -- cgit v1.1