mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
try to improve profiles online indication. This ofc just fais on HG
This commit is contained in:
@@ -169,11 +169,12 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
|
||||
m_profilesCache.AddOrUpdate(props.UserId, uce, PROFILECACHEEXPIRE);
|
||||
}
|
||||
|
||||
// if on same region force online
|
||||
if (p != null && !p.IsDeleted)
|
||||
flags |= 0x10;
|
||||
if (IsFriendOnline(req.client.AgentId, req.agent))
|
||||
flags |= (uint)ProfileFlags.Online;
|
||||
else
|
||||
flags &= (uint)~ProfileFlags.Online;
|
||||
|
||||
if(clients == null)
|
||||
if (clients == null)
|
||||
{
|
||||
client.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType, props.FirstLifeText, flags,
|
||||
props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId);
|
||||
@@ -1502,9 +1503,11 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
|
||||
{
|
||||
props = uce.props;
|
||||
uint cflags = uce.flags;
|
||||
// if on same region force online
|
||||
if(p != null && !p.IsDeleted)
|
||||
cflags |= 0x10;
|
||||
|
||||
if (IsFriendOnline(remoteClient.AgentId, avatarID))
|
||||
cflags = (uint)ProfileFlags.Online;
|
||||
else
|
||||
cflags &= (uint)~ProfileFlags.Online;
|
||||
|
||||
remoteClient.SendAvatarProperties(props.UserId, props.AboutText,
|
||||
uce.born, uce.membershipType , props.FirstLifeText, cflags,
|
||||
@@ -1552,113 +1555,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
|
||||
}
|
||||
Monitor.Exit(m_asyncRequestsLock);
|
||||
}
|
||||
|
||||
/*
|
||||
string serverURI = string.Empty;
|
||||
bool foreign = GetUserProfileServerURI(avatarID, out serverURI);
|
||||
|
||||
UserAccount account = null;
|
||||
Dictionary<string,object> userInfo;
|
||||
|
||||
if (!foreign)
|
||||
{
|
||||
account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, avatarID);
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfo = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
Byte[] membershipType = new Byte[1];
|
||||
string born = string.Empty;
|
||||
uint flags = 0x00;
|
||||
|
||||
if (null != account)
|
||||
{
|
||||
if (account.UserTitle.Length == 0)
|
||||
membershipType[0] = (Byte)((account.UserFlags & 0xf00) >> 8);
|
||||
else
|
||||
membershipType = Utils.StringToBytes(account.UserTitle);
|
||||
|
||||
born = Util.ToDateTime(account.Created).ToString(
|
||||
"M/d/yyyy", CultureInfo.InvariantCulture);
|
||||
flags = (uint)(account.UserFlags & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetUserAccountData(avatarID, out userInfo) == true)
|
||||
{
|
||||
if ((string)userInfo["user_title"].Length == 0)
|
||||
membershipType[0] = (Byte)(((Byte)userInfo["user_flags"] & 0xf00) >> 8);
|
||||
else
|
||||
membershipType = Utils.StringToBytes((string)userInfo["user_title"]);
|
||||
|
||||
int val_born = (int)userInfo["user_created"];
|
||||
if(val_born != 0)
|
||||
born = Util.ToDateTime(val_born).ToString(
|
||||
"M/d/yyyy", CultureInfo.InvariantCulture);
|
||||
|
||||
// picky, picky
|
||||
int val_flags = (int)userInfo["user_flags"];
|
||||
flags = (uint)(val_flags & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
props = new UserProfileProperties();
|
||||
props.UserId = avatarID;
|
||||
|
||||
string result = string.Empty;
|
||||
if(!GetProfileData(ref props, foreign, serverURI, out result))
|
||||
{
|
||||
props.AboutText ="Profile not available at this time. User may still be unknown to this grid";
|
||||
}
|
||||
|
||||
if(!m_allowUserProfileWebURLs)
|
||||
props.WebUrl ="";
|
||||
|
||||
HashSet<IClientAPI> clients;
|
||||
lock(m_profilesCache)
|
||||
{
|
||||
if(!m_profilesCache.TryGetValue(props.UserId, out uce) || uce == null)
|
||||
uce = new UserProfileCacheEntry();
|
||||
uce.props = props;
|
||||
uce.born = born;
|
||||
uce.membershipType = membershipType;
|
||||
uce.flags = flags;
|
||||
clients = uce.ClientsWaitingProps;
|
||||
uce.ClientsWaitingProps = null;
|
||||
m_profilesCache.AddOrUpdate(props.UserId, uce, PROFILECACHEEXPIRE);
|
||||
}
|
||||
|
||||
// if on same region force online
|
||||
if(p != null && !p.IsDeleted)
|
||||
flags |= 0x10;
|
||||
|
||||
if(clients == null)
|
||||
{
|
||||
remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType , props.FirstLifeText, flags,
|
||||
props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId);
|
||||
|
||||
remoteClient.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText,
|
||||
(uint)props.SkillsMask, props.SkillsText, props.Language);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!clients.Contains(remoteClient))
|
||||
clients.Add(remoteClient);
|
||||
foreach(IClientAPI cli in clients)
|
||||
{
|
||||
if(!cli.IsActive)
|
||||
continue;
|
||||
cli.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType , props.FirstLifeText, flags,
|
||||
props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId);
|
||||
|
||||
cli.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText,
|
||||
(uint)props.SkillsMask, props.SkillsText, props.Language);
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1881,6 +1777,26 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual bool IsFriendOnline(UUID client, UUID agent)
|
||||
{
|
||||
// if on same region force online
|
||||
ScenePresence p = Scene.GetScenePresence(agent);
|
||||
if (p != null && !p.IsDeleted)
|
||||
return true;
|
||||
|
||||
IFriendsModule friendsModule = Scene.RequestModuleInterface<IFriendsModule>();
|
||||
if (friendsModule != null)
|
||||
{
|
||||
int friendPerms = friendsModule.GetRightsGrantedByFriend(client, agent);
|
||||
if((friendPerms & (int) FriendRights.CanSeeOnline) != 0);
|
||||
{
|
||||
Services.Interfaces.PresenceInfo[] pi = Scene.PresenceService?.GetAgents(new string[] { agent.ToString() });
|
||||
return pi != null && pi.Length > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion Util
|
||||
|
||||
#region Web Util
|
||||
|
||||
Reference in New Issue
Block a user