* 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.
afrisby
Teravus Ovares 2007-11-13 22:48:19 +00:00
parent eb41ec00c9
commit 9f6b3e2357
23 changed files with 412 additions and 10 deletions

View File

@ -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<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
{
List<AvatarPickerAvatar> pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query);
return pickerlist;
}
#endregion
}

View File

@ -36,5 +36,6 @@ namespace OpenSim.Framework.Communications
List<SimpleRegionInfo> RequestNeighbours(uint x, uint y);
RegionInfo RequestNeighbourInfo(ulong regionHandle);
List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
}
}

View File

@ -105,6 +105,25 @@ namespace OpenSim.Framework.UserManagement
return null;
}
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
{
List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
foreach (KeyValuePair<string, IUserData> 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<AvatarPickerAvatar>();
}
}
return pickerlist;
}
/// <summary>
/// Loads a user profile by name

View File

@ -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;
}
/// <summary>
/// // Returns a list of avatar and UUIDs that match the query
/// </summary>
public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
//Do nothing yet
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
return returnlist;
}
/// <summary>
/// Returns the providers name
/// </summary>

View File

@ -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<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
//Do nothing yet
List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>();
return returnlist;
}
/// <summary>
/// Creates a new user profile
/// </summary>

View File

@ -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
{
/// <summary>
@ -130,7 +132,16 @@ namespace OpenSim.Framework.Data.MSSQL
return row;
}
/// <summary>
/// // Returns a list of avatar and UUIDs that match the query
/// </summary>
public List<OpenSim.Framework.Data.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
//Do nothing yet
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
return returnlist;
}
/// <summary>
/// Adds a new specified region to the database
/// </summary>
@ -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
}
}

View File

@ -169,6 +169,91 @@ namespace OpenSim.Framework.Data.MySQL
return null;
}
}
/// <summary>
/// // Returns a list of avatar and UUIDs that match the query
/// </summary>
public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
string[] querysplit;
querysplit = query.Split(' ');
if (querysplit.Length == 2)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
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<string, string> param = new Dictionary<string, string>();
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;
}
/// <summary>
/// Returns a sim profile from it's UUID

View File

@ -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<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>();
string[] querysplit;
querysplit = query.Split(' ');
if (querysplit.Length == 2)
{
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
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<string, string> param = new Dictionary<string, string>();
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;
}
/// <summary>
/// Searches the database for a specified user profile by UUID
/// </summary>

View File

@ -130,7 +130,16 @@ namespace OpenSim.Framework.Data.SQLite
return row;
}
/// <summary>
/// // Returns a list of avatar and UUIDs that match the query
/// </summary>
public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
//Do nothing yet
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
return returnlist;
}
/// <summary>
/// Adds a new specified region to the database
/// </summary>

View File

@ -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
{
/// <summary>
/// A User storage interface for the DB4o database system
/// </summary>
///
public class SQLiteUserData : SQLiteBase, IUserData
{
/// <summary>
@ -135,6 +141,53 @@ namespace OpenSim.Framework.Data.SQLite
}
}
public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{
List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>();
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<rows.Length;i++) {
OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar();
DataRow row = rows[i];
user.AvatarID = new LLUUID((string)row[0]);
user.firstName = (string)row[1];
user.lastName = (string)row[2];
returnlist.Add(user);
}
}
}
}
return returnlist;
}
/// <summary>
/// Returns a user by UUID direct
/// </summary>

View File

@ -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
/// <returns>An array containing all the sim profiles in the specified range</returns>
RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query);
/// <summary>
/// Authenticates a sim by use of it's recv key.
/// WARNING: Insecure

View File

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

View File

@ -26,6 +26,7 @@
*
*/
using libsecondlife;
using System.Collections.Generic;
namespace OpenSim.Framework
{
@ -56,6 +57,8 @@ namespace OpenSim.Framework
/// <returns>The user data profile</returns>
UserProfileData GetUserByName(string fname, string lname);
List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query);
/// <summary>
/// Returns the current agent for a user searching by it's UUID
/// </summary>
@ -131,4 +134,13 @@ namespace OpenSim.Framework
/// </summary>
void Initialise();
}
public class AvatarPickerAvatar
{
public LLUUID AvatarID;
public string firstName;
public string lastName;
public AvatarPickerAvatar()
{
}
}
}

View File

@ -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<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query);
UserProfileData SetupMasterUser(string firstName, string lastName);
UserProfileData SetupMasterUser(string firstName, string lastName, string password);

View File

@ -145,6 +145,19 @@ namespace OpenSim.Framework
public UserAgentData currentAgent;
}
/// <summary>
/// Minimal User Data required to service the AvatarPickerReply
/// </summary>
//public class AvatarPickerAvatar
//{
//public LLUUID AvatarID;
//public string firstName;
//public string lastName;
//public AvatarPickerAvatar()
//{
//}
//}
/// <summary>
/// Information about a users session
/// </summary>

View File

@ -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<IClientAPI> 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);
}
/// <summary>
///

View File

@ -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

View File

@ -295,11 +295,16 @@ namespace OpenSim.Region.ClientStack
queuedLast = false;
// TODO: May be a bit expensive doing this twice.
throttleSentPeriod += nextPacket.Packet.ToBytes().Length;
//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);
//is a out going packet
DebugPacket("OUT", nextPacket.Packet);
ProcessOutPacket(nextPacket.Packet);
}
}
}

View File

@ -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<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
{
List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
return pickerlist;
}
public UserProfileData GetUserProfile(string name)
{
try

View File

@ -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<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
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);
}
}
}

View File

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

View File

@ -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++);
}
}
}

View File

@ -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<IClientAPI> 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)
{
}