break userprofiles a bit more

melanie
UbitUmarov 2016-12-17 20:11:34 +00:00
parent b4bbf4f95d
commit 389a1652fb
1 changed files with 112 additions and 74 deletions

View File

@ -161,7 +161,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
return; return;
} }
m_allowUserProfileWebURLs = profileConfig.GetBoolean("AllowUserProfileWebURLs", m_allowUserProfileWebURLs); m_allowUserProfileWebURLs = profileConfig.GetBoolean("AllowUserProfileWebURLs", m_allowUserProfileWebURLs);
m_log.Debug("[PROFILES]: Full Profiles Enabled"); m_log.Debug("[PROFILES]: Full Profiles Enabled");
ReplaceableInterface = null; ReplaceableInterface = null;
Enabled = true; Enabled = true;
@ -318,37 +319,46 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
return; return;
IClientAPI remoteClient = (IClientAPI)sender; IClientAPI remoteClient = (IClientAPI)sender;
Dictionary<UUID, string> classifieds = new Dictionary<UUID, string>();
UUID targetID; UUID targetID;
UUID.TryParse(args[0], out targetID); if(!UUID.TryParse(args[0], out targetID) || targetID == UUID.Zero)
return;
ScenePresence p = FindPresence(targetID); ScenePresence p = FindPresence(targetID);
if (p != null && p.isNPC) if (p != null && p.isNPC)
{ {
remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), new Dictionary<UUID, string>()); remoteClient.SendAvatarClassifiedReply(targetID, classifieds);
return; return;
} }
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(targetID, out serverURI); GetUserProfileServerURI(targetID, out serverURI);
UUID creatorId = UUID.Zero; if(string.IsNullOrWhiteSpace(serverURI))
Dictionary<UUID, string> classifieds = new Dictionary<UUID, string>(); {
remoteClient.SendAvatarClassifiedReply(targetID, classifieds);
return;
}
OSDMap parameters= new OSDMap(); OSDMap parameters= new OSDMap();
UUID.TryParse(args[0], out creatorId);
parameters.Add("creatorId", OSD.FromUUID(creatorId)); parameters.Add("creatorId", OSD.FromUUID(targetID));
OSD Params = (OSD)parameters; OSD Params = (OSD)parameters;
if(!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString())) if(!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString()))
{ {
remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds); remoteClient.SendAvatarClassifiedReply(targetID, classifieds);
return; return;
} }
parameters = (OSDMap)Params; parameters = (OSDMap)Params;
OSDArray list = (OSDArray)parameters["result"]; if(!parameters.ContainsKey("result") || parameters["result"] == null)
{
remoteClient.SendAvatarClassifiedReply(targetID, classifieds);
return;
}
OSDArray list = (OSDArray)parameters["result"];
foreach(OSD map in list) foreach(OSD map in list)
{ {
@ -362,7 +372,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
{ {
if (!m_classifiedCache.ContainsKey(cid)) if (!m_classifiedCache.ContainsKey(cid))
{ {
m_classifiedCache.Add(cid,creatorId); m_classifiedCache.Add(cid,targetID);
m_classifiedInterest.Add(cid, 0); m_classifiedInterest.Add(cid, 0);
} }
@ -370,7 +380,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
} }
} }
remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), classifieds); remoteClient.SendAvatarClassifiedReply(targetID, classifieds);
} }
public void ClassifiedInfoRequest(UUID queryClassifiedID, IClientAPI remoteClient) public void ClassifiedInfoRequest(UUID queryClassifiedID, IClientAPI remoteClient)
@ -397,6 +407,10 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(target, out serverURI); GetUserProfileServerURI(target, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
{
return;
}
object Ad = (object)ad; object Ad = (object)ad;
if(!rpc.JsonRpcRequest(ref Ad, "classifieds_info_query", serverURI, UUID.Random().ToString())) if(!rpc.JsonRpcRequest(ref Ad, "classifieds_info_query", serverURI, UUID.Random().ToString()))
@ -467,6 +481,10 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(remoteClient.AgentId, out serverURI); GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
{
return;
}
OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}}; OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}};
OSD Params = (OSD)parameters; OSD Params = (OSD)parameters;
@ -533,10 +551,14 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
{ {
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(remoteClient.AgentId, out serverURI); GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
return;
UUID classifiedId; UUID classifiedId;
if(!UUID.TryParse(queryClassifiedID.ToString(), out classifiedId))
return;
OSDMap parameters= new OSDMap(); OSDMap parameters= new OSDMap();
UUID.TryParse(queryClassifiedID.ToString(), out classifiedId);
parameters.Add("classifiedId", OSD.FromUUID(classifiedId)); parameters.Add("classifiedId", OSD.FromUUID(classifiedId));
OSD Params = (OSD)parameters; OSD Params = (OSD)parameters;
if(!rpc.JsonRpcRequest(ref Params, "classified_delete", serverURI, UUID.Random().ToString())) if(!rpc.JsonRpcRequest(ref Params, "classified_delete", serverURI, UUID.Random().ToString()))
@ -571,33 +593,41 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
IClientAPI remoteClient = (IClientAPI)sender; IClientAPI remoteClient = (IClientAPI)sender;
UUID targetId; UUID targetId;
UUID.TryParse(args[0], out targetId); if(!UUID.TryParse(args[0], out targetId))
return;
Dictionary<UUID, string> picks = new Dictionary<UUID, string>();
// Can't handle NPC yet...
ScenePresence p = FindPresence(targetId); ScenePresence p = FindPresence(targetId);
if (p != null && p.isNPC) if (p != null && p.isNPC)
{ {
remoteClient.SendAvatarPicksReply(new UUID(args[0]), new Dictionary<UUID, string>()); remoteClient.SendAvatarPicksReply(targetId, picks);
return; return;
} }
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(targetId, out serverURI); GetUserProfileServerURI(targetId, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
Dictionary<UUID, string> picks = new Dictionary<UUID, string>(); {
remoteClient.SendAvatarPicksReply(targetId, picks);
return;
}
OSDMap parameters= new OSDMap(); OSDMap parameters= new OSDMap();
parameters.Add("creatorId", OSD.FromUUID(targetId)); parameters.Add("creatorId", OSD.FromUUID(targetId));
OSD Params = (OSD)parameters; OSD Params = (OSD)parameters;
if(!rpc.JsonRpcRequest(ref Params, "avatarpicksrequest", serverURI, UUID.Random().ToString())) if(!rpc.JsonRpcRequest(ref Params, "avatarpicksrequest", serverURI, UUID.Random().ToString()))
{ {
remoteClient.SendAvatarPicksReply(new UUID(args[0]), picks); remoteClient.SendAvatarPicksReply(targetId, picks);
return; return;
} }
parameters = (OSDMap)Params; parameters = (OSDMap)Params;
if(!parameters.ContainsKey("result") || parameters["result"] == null)
{
remoteClient.SendAvatarPicksReply(targetId, picks);
return;
}
OSDArray list = (OSDArray)parameters["result"]; OSDArray list = (OSDArray)parameters["result"];
foreach(OSD map in list) foreach(OSD map in list)
@ -605,12 +635,9 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
OSDMap m = (OSDMap)map; OSDMap m = (OSDMap)map;
UUID cid = m["pickuuid"].AsUUID(); UUID cid = m["pickuuid"].AsUUID();
string name = m["name"].AsString(); string name = m["name"].AsString();
m_log.DebugFormat("[PROFILES]: PicksRequest {0}", name);
picks[cid] = name; picks[cid] = name;
} }
remoteClient.SendAvatarPicksReply(new UUID(args[0]), picks); remoteClient.SendAvatarPicksReply(targetId, picks);
} }
/// <summary> /// <summary>
@ -630,20 +657,27 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if (!(sender is IClientAPI)) if (!(sender is IClientAPI))
return; return;
UserProfilePick pick = new UserProfilePick ();
UUID targetID; UUID targetID;
UUID.TryParse (args [0], out targetID); if(!UUID.TryParse(args [0], out targetID))
return;
pick.CreatorId = targetID;
if(!UUID.TryParse (args [1], out pick.PickId))
return;
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI (targetID, out serverURI); GetUserProfileServerURI (targetID, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
{
return;
}
string theirGatekeeperURI; string theirGatekeeperURI;
GetUserGatekeeperURI (targetID, out theirGatekeeperURI); GetUserGatekeeperURI(targetID, out theirGatekeeperURI);
IClientAPI remoteClient = (IClientAPI)sender; IClientAPI remoteClient = (IClientAPI)sender;
UserProfilePick pick = new UserProfilePick ();
UUID.TryParse (args [0], out pick.CreatorId);
UUID.TryParse (args [1], out pick.PickId);
object Pick = (object)pick; object Pick = (object)pick;
if (!rpc.JsonRpcRequest (ref Pick, "pickinforequest", serverURI, UUID.Random ().ToString ())) { if (!rpc.JsonRpcRequest (ref Pick, "pickinforequest", serverURI, UUID.Random ().ToString ())) {
@ -654,13 +688,9 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
pick = (UserProfilePick)Pick; pick = (UserProfilePick)Pick;
Vector3 globalPos = new Vector3(Vector3.Zero); Vector3 globalPos = new Vector3(Vector3.Zero);
Vector3.TryParse(pick.GlobalPos, out globalPos);
// Smoke and mirrors if (!string.IsNullOrWhiteSpace(MyGatekeeper) && pick.Gatekeeper != MyGatekeeper)
if (pick.Gatekeeper == MyGatekeeper)
{
Vector3.TryParse(pick.GlobalPos,out globalPos);
}
else
{ {
// Setup the illusion // Setup the illusion
string region = string.Format("{0} {1}",pick.Gatekeeper,pick.SimName); string region = string.Format("{0} {1}",pick.Gatekeeper,pick.SimName);
@ -668,21 +698,19 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if(target == null) if(target == null)
{ {
// This is a dead or unreachable region // This is a unreachable region
} }
else else
{ {
// Work our slight of hand // we have a proxy on map
int x = target.RegionLocX; // this is a fail on large regions
int y = target.RegionLocY; uint gtmp = (uint)globalPos.X >> 8;
globalPos.X -= (gtmp << 8);
globalPos.X += target.RegionLocX;
dynamic synthX = globalPos.X - (globalPos.X/Constants.RegionSize) * Constants.RegionSize; gtmp = (uint)globalPos.Y >> 8;
synthX += x; globalPos.Y -= (gtmp << 8);
globalPos.X = synthX; globalPos.Y += target.RegionLocY;
dynamic synthY = globalPos.Y - (globalPos.Y/Constants.RegionSize) * Constants.RegionSize;
synthY += y;
globalPos.Y = synthY;
} }
} }
@ -732,6 +760,11 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
UserProfilePick pick = new UserProfilePick(); UserProfilePick pick = new UserProfilePick();
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(remoteClient.AgentId, out serverURI); GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
{
return;
}
ScenePresence p = FindPresence(remoteClient.AgentId); ScenePresence p = FindPresence(remoteClient.AgentId);
Vector3 avaPos = p.AbsolutePosition; Vector3 avaPos = p.AbsolutePosition;
@ -797,6 +830,10 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
{ {
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(remoteClient.AgentId, out serverURI); GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
{
return;
}
OSDMap parameters= new OSDMap(); OSDMap parameters= new OSDMap();
parameters.Add("pickId", OSD.FromUUID(queryPickID)); parameters.Add("pickId", OSD.FromUUID(queryPickID));
@ -830,11 +867,19 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if (!(sender is IClientAPI)) if (!(sender is IClientAPI))
return; return;
if(!UUID.TryParse(args[0], out note.TargetId))
return;
IClientAPI remoteClient = (IClientAPI)sender; IClientAPI remoteClient = (IClientAPI)sender;
note.UserId = remoteClient.AgentId;
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(remoteClient.AgentId, out serverURI); GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
note.UserId = remoteClient.AgentId; if(string.IsNullOrWhiteSpace(serverURI))
UUID.TryParse(args[0], out note.TargetId); {
remoteClient.SendAvatarNotesReply(note.TargetId, note.Notes);
return;
}
object Note = (object)note; object Note = (object)note;
if(!rpc.JsonRpcRequest(ref Note, "avatarnotesrequest", serverURI, UUID.Random().ToString())) if(!rpc.JsonRpcRequest(ref Note, "avatarnotesrequest", serverURI, UUID.Random().ToString()))
@ -842,8 +887,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
remoteClient.SendAvatarNotesReply(note.TargetId, note.Notes); remoteClient.SendAvatarNotesReply(note.TargetId, note.Notes);
return; return;
} }
note = (UserProfileNotes) Note; note = (UserProfileNotes) Note;
remoteClient.SendAvatarNotesReply(note.TargetId, note.Notes); remoteClient.SendAvatarNotesReply(note.TargetId, note.Notes);
} }
@ -877,6 +921,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(remoteClient.AgentId, out serverURI); GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
return;
object Note = note; object Note = note;
if(!rpc.JsonRpcRequest(ref Note, "avatar_notes_update", serverURI, UUID.Random().ToString())) if(!rpc.JsonRpcRequest(ref Note, "avatar_notes_update", serverURI, UUID.Random().ToString()))
@ -912,6 +958,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
string serverURI = string.Empty; string serverURI = string.Empty;
bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI); bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
return;
object Pref = pref; object Pref = pref;
if(!rpc.JsonRpcRequest(ref Pref, "user_preferences_update", serverURI, UUID.Random().ToString())) if(!rpc.JsonRpcRequest(ref Pref, "user_preferences_update", serverURI, UUID.Random().ToString()))
@ -936,7 +984,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
string serverURI = string.Empty; string serverURI = string.Empty;
bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI); bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
return;
object Pref = (object)pref; object Pref = (object)pref;
if(!rpc.JsonRpcRequest(ref Pref, "user_preferences_request", serverURI, UUID.Random().ToString())) if(!rpc.JsonRpcRequest(ref Pref, "user_preferences_request", serverURI, UUID.Random().ToString()))
@ -987,6 +1036,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(remoteClient.AgentId, out serverURI); GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
if(string.IsNullOrWhiteSpace(serverURI))
return;
object Param = prop; object Param = prop;
if(!rpc.JsonRpcRequest(ref Param, "avatar_interests_update", serverURI, UUID.Random().ToString())) if(!rpc.JsonRpcRequest(ref Param, "avatar_interests_update", serverURI, UUID.Random().ToString()))
@ -1006,9 +1057,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
return; return;
} }
// Can't handle NPC yet...
ScenePresence p = FindPresence(avatarID); ScenePresence p = FindPresence(avatarID);
if (p != null && p.isNPC) if (p != null && p.isNPC)
{ {
remoteClient.SendAvatarProperties(avatarID, ((INPC)(p.ControllingClient)).profileAbout, ((INPC)(p.ControllingClient)).Born, remoteClient.SendAvatarProperties(avatarID, ((INPC)(p.ControllingClient)).profileAbout, ((INPC)(p.ControllingClient)).Born,
@ -1035,19 +1084,15 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
} }
Byte[] membershipType = new Byte[1]; Byte[] membershipType = new Byte[1];
string born = String.Empty; string born = string.Empty;
uint flags = 0x00; uint flags = 0x00;
if (null != account) if (null != account)
{ {
if (account.UserTitle == "") if (account.UserTitle == "")
{
membershipType[0] = (Byte)((account.UserFlags & 0xf00) >> 8); membershipType[0] = (Byte)((account.UserFlags & 0xf00) >> 8);
}
else else
{
membershipType = Utils.StringToBytes(account.UserTitle); membershipType = Utils.StringToBytes(account.UserTitle);
}
born = Util.ToDateTime(account.Created).ToString( born = Util.ToDateTime(account.Created).ToString(
"M/d/yyyy", CultureInfo.InvariantCulture); "M/d/yyyy", CultureInfo.InvariantCulture);
@ -1058,16 +1103,13 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if (GetUserAccountData(avatarID, out userInfo) == true) if (GetUserAccountData(avatarID, out userInfo) == true)
{ {
if ((string)userInfo["user_title"] == "") if ((string)userInfo["user_title"] == "")
{
membershipType[0] = (Byte)(((Byte)userInfo["user_flags"] & 0xf00) >> 8); membershipType[0] = (Byte)(((Byte)userInfo["user_flags"] & 0xf00) >> 8);
}
else else
{
membershipType = Utils.StringToBytes((string)userInfo["user_title"]); membershipType = Utils.StringToBytes((string)userInfo["user_title"]);
}
int val_born = (int)userInfo["user_created"]; int val_born = (int)userInfo["user_created"];
born = Util.ToDateTime(val_born).ToString( if(val_born != 0)
born = Util.ToDateTime(val_born).ToString(
"M/d/yyyy", CultureInfo.InvariantCulture); "M/d/yyyy", CultureInfo.InvariantCulture);
// picky, picky // picky, picky
@ -1077,20 +1119,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
} }
UserProfileProperties props = new UserProfileProperties(); UserProfileProperties props = new UserProfileProperties();
string result = string.Empty;
props.UserId = avatarID; props.UserId = avatarID;
if (!GetProfileData(ref props, foreign, out result)) string result = string.Empty;
if(!GetProfileData(ref props, foreign, out result))
{ {
// m_log.DebugFormat("Error getting profile for {0}: {1}", avatarID, result); props.AboutText ="Profile not avaible at this time. User may still be unknown to this grid";
return;
} }
// if on same region force online // if on same region force online
if(p != null && !p.IsDeleted) if(p != null && !p.IsDeleted)
flags |= 0x10; flags |= 0x10;
if(!m_allowUserProfileWebURLs) if(!m_allowUserProfileWebURLs)
props.WebUrl =""; props.WebUrl ="";
@ -1166,12 +1205,11 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
string serverURI = string.Empty; string serverURI = string.Empty;
GetUserProfileServerURI(properties.UserId, out serverURI); GetUserProfileServerURI(properties.UserId, out serverURI);
// This is checking a friend on the home grid // This is checking a friend on the home grid
// Not HG friend // Not HG friend
if (String.IsNullOrEmpty(serverURI)) if (String.IsNullOrEmpty(serverURI))
{ {
message = "No Presence - foreign friend"; message = "User profile service unknown at this time";
return false; return false;
} }