mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
more cosmetics
This commit is contained in:
@@ -26,14 +26,10 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using Nwc.XmlRpc;
|
||||
using OpenMetaverse;
|
||||
using Mono.Addins;
|
||||
using OpenSim.Framework;
|
||||
@@ -75,9 +71,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
}
|
||||
}
|
||||
|
||||
protected static readonly FriendInfo[] EMPTY_FRIENDS = new FriendInfo[0];
|
||||
protected static readonly FriendInfo[] EMPTY_FRIENDS = Array.Empty<FriendInfo>();
|
||||
|
||||
protected List<Scene> m_Scenes = new List<Scene>();
|
||||
protected List<Scene> m_Scenes = new();
|
||||
|
||||
protected IPresenceService m_PresenceService = null;
|
||||
protected IFriendsService m_FriendsService = null;
|
||||
@@ -90,25 +86,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
/// This is a complex and error-prone thing to do. At the moment, we assume that the efficiency gained in
|
||||
/// permissions checks outweighs the disadvantages of that complexity.
|
||||
/// </remarks>
|
||||
protected Dictionary<UUID, UserFriendData> m_Friends = new Dictionary<UUID, UserFriendData>();
|
||||
protected Dictionary<UUID, UserFriendData> m_Friends = new();
|
||||
|
||||
/// <summary>
|
||||
/// Maintain a record of clients that need to notify about their online status. This only
|
||||
/// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism.
|
||||
/// </summary>
|
||||
protected HashSet<UUID> m_NeedsToNotifyStatus = new HashSet<UUID>();
|
||||
protected HashSet<UUID> m_NeedsToNotifyStatus = new();
|
||||
|
||||
/// <summary>
|
||||
/// Maintain a record of viewers that need to be sent notifications for friends that are online. This only
|
||||
/// needs to be done on login. Subsequent online/offline friend changes are sent by a different mechanism.
|
||||
/// </summary>
|
||||
protected HashSet<UUID> m_NeedsListOfOnlineFriends = new HashSet<UUID>();
|
||||
protected HashSet<UUID> m_NeedsListOfOnlineFriends = new();
|
||||
|
||||
protected IPresenceService PresenceService
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_PresenceService == null)
|
||||
if (m_PresenceService is null)
|
||||
{
|
||||
if (m_Scenes.Count > 0)
|
||||
m_PresenceService = m_Scenes[0].RequestModuleInterface<IPresenceService>();
|
||||
@@ -122,7 +118,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_FriendsService == null)
|
||||
if (m_FriendsService is null)
|
||||
{
|
||||
if (m_Scenes.Count > 0)
|
||||
m_FriendsService = m_Scenes[0].RequestModuleInterface<IFriendsService>();
|
||||
@@ -186,11 +182,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
// Instantiate the request handler
|
||||
IHttpServer server = MainServer.GetHttpServer((uint)mPort);
|
||||
|
||||
if (server != null)
|
||||
server.AddSimpleStreamHandler(new FriendsSimpleRequestHandler(this));
|
||||
server?.AddSimpleStreamHandler(new FriendsSimpleRequestHandler(this));
|
||||
}
|
||||
|
||||
if (m_FriendsService == null)
|
||||
if (m_FriendsService is null)
|
||||
{
|
||||
m_log.Error("[FRIENDS]: No Connector defined in section Friends, or failed to load, cannot continue");
|
||||
throw new Exception("Connector load error");
|
||||
@@ -247,7 +242,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
{
|
||||
FriendInfo[] friends = GetFriendsFromCache(principalID);
|
||||
FriendInfo finfo = GetFriend(friends, friendID);
|
||||
if (finfo != null && finfo.TheirFlags != -1)
|
||||
if (finfo is not null && finfo.TheirFlags != -1)
|
||||
{
|
||||
return finfo.TheirFlags;
|
||||
}
|
||||
@@ -307,18 +302,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
UUID agentID = client.AgentId;
|
||||
lock (m_Friends)
|
||||
{
|
||||
UserFriendData friendsData;
|
||||
if (m_Friends.TryGetValue(agentID, out friendsData))
|
||||
if (m_Friends.TryGetValue(agentID, out UserFriendData friendsData))
|
||||
{
|
||||
friendsData.Refcount++;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
friendsData = new UserFriendData();
|
||||
friendsData.PrincipalID = agentID;
|
||||
friendsData.Friends = GetFriendsFromService(client);
|
||||
friendsData.Refcount = 1;
|
||||
friendsData = new UserFriendData
|
||||
{
|
||||
PrincipalID = agentID,
|
||||
Friends = GetFriendsFromService(client),
|
||||
Refcount = 1
|
||||
};
|
||||
|
||||
m_Friends[agentID] = friendsData;
|
||||
return true;
|
||||
@@ -337,8 +333,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
|
||||
lock (m_Friends)
|
||||
{
|
||||
UserFriendData friendsData;
|
||||
if (m_Friends.TryGetValue(agentID, out friendsData))
|
||||
if (m_Friends.TryGetValue(agentID, out UserFriendData friendsData))
|
||||
{
|
||||
friendsData.Refcount--;
|
||||
if (friendsData.Refcount <= 0)
|
||||
@@ -389,7 +384,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
client.SendAgentOnline(online.ToArray());
|
||||
|
||||
// Send outstanding friendship offers
|
||||
List<string> outstanding = new List<string>();
|
||||
List<string> outstanding = new();
|
||||
FriendInfo[] friends = GetFriendsFromCache(client.AgentId);
|
||||
foreach (FriendInfo fi in friends)
|
||||
{
|
||||
@@ -397,7 +392,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
outstanding.Add(fi.Friend);
|
||||
}
|
||||
|
||||
GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, String.Empty, client.AgentId, (byte)InstantMessageDialog.FriendshipOffered,
|
||||
GridInstantMessage im = new(client.Scene, UUID.Zero, string.Empty, client.AgentId, (byte)InstantMessageDialog.FriendshipOffered,
|
||||
"Will you be my friend?", true, Vector3.Zero);
|
||||
|
||||
foreach (string fid in outstanding)
|
||||
@@ -443,7 +438,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
|
||||
List<UUID> GetOnlineFriends(UUID userID)
|
||||
{
|
||||
List<string> friendList = new List<string>();
|
||||
List<string> friendList = new();
|
||||
|
||||
FriendInfo[] friends = GetFriendsFromCache(userID);
|
||||
foreach (FriendInfo fi in friends)
|
||||
@@ -452,27 +447,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
friendList.Add(fi.Friend);
|
||||
}
|
||||
|
||||
List<UUID> online = new List<UUID>();
|
||||
List<UUID> online = new();
|
||||
|
||||
if (friendList.Count > 0)
|
||||
GetOnlineFriends(userID, friendList, online);
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[FRIENDS MODULE]: User {0} has {1} friends online", userID, online.Count);
|
||||
//m_log.DebugFormat(
|
||||
// "[FRIENDS MODULE]: User {0} has {1} friends online", userID, online.Count);
|
||||
|
||||
return online;
|
||||
}
|
||||
|
||||
protected virtual void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[FRIENDS MODULE]: Looking for online presence of {0} users for {1}", friendList.Count, userID);
|
||||
//m_log.DebugFormat(
|
||||
// "[FRIENDS MODULE]: Looking for online presence of {0} users for {1}", friendList.Count, userID);
|
||||
|
||||
PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray());
|
||||
foreach (PresenceInfo pi in presence)
|
||||
{
|
||||
UUID presenceID;
|
||||
if (UUID.TryParse(pi.UserID, out presenceID))
|
||||
if (UUID.TryParse(pi.UserID, out UUID presenceID))
|
||||
online.Add(presenceID);
|
||||
}
|
||||
}
|
||||
@@ -487,7 +481,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
foreach (Scene scene in m_Scenes)
|
||||
{
|
||||
ScenePresence presence = scene.GetScenePresence(agentID);
|
||||
if (presence != null && !presence.IsDeleted && !presence.IsChildAgent)
|
||||
if (presence is not null && !presence.IsDeleted && !presence.IsChildAgent)
|
||||
return presence.ControllingClient;
|
||||
}
|
||||
}
|
||||
@@ -503,67 +497,67 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
private void StatusChange(UUID agentID, bool online)
|
||||
{
|
||||
FriendInfo[] friends = GetFriendsFromCache(agentID);
|
||||
if (friends.Length > 0)
|
||||
{
|
||||
List<FriendInfo> friendList = new List<FriendInfo>();
|
||||
foreach (FriendInfo fi in friends)
|
||||
{
|
||||
if (((fi.MyFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1))
|
||||
friendList.Add(fi);
|
||||
}
|
||||
if(friendList.Count > 0)
|
||||
{
|
||||
Util.FireAndForget(
|
||||
delegate
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[FRIENDS MODULE]: Notifying {0} friends of {1} of online status {2}",
|
||||
// friendList.Count, agentID, online);
|
||||
if (friends.Length == 0)
|
||||
return;
|
||||
|
||||
// Notify about this user status
|
||||
StatusNotify(friendList, agentID, online);
|
||||
}, null, "FriendsModule.StatusChange"
|
||||
);
|
||||
}
|
||||
List<FriendInfo> friendList = new(friends.Length);
|
||||
foreach (FriendInfo fi in friends)
|
||||
{
|
||||
if (fi.TheirFlags != -1 && (fi.MyFlags & (int)FriendRights.CanSeeOnline) != 0)
|
||||
friendList.Add(fi);
|
||||
}
|
||||
|
||||
if(friendList.Count > 0)
|
||||
{
|
||||
Util.FireAndForget(
|
||||
delegate
|
||||
{
|
||||
//m_log.DebugFormat(
|
||||
// "[FRIENDS MODULE]: Notifying {0} friends of {1} of online status {2}",
|
||||
// friendList.Count, agentID, online);
|
||||
|
||||
// Notify about this user status
|
||||
StatusNotify(friendList, agentID, online);
|
||||
}, null, "FriendsModule.StatusChange"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online)
|
||||
{
|
||||
//m_log.DebugFormat("[FRIENDS]: Entering StatusNotify for {0}", userID);
|
||||
|
||||
List<string> friendStringIds = friendList.ConvertAll<string>(friend => friend.Friend);
|
||||
List<string> remoteFriendStringIds = new List<string>();
|
||||
foreach (string friendStringId in friendStringIds)
|
||||
List<string> remoteFriendStringIds = new(friendList.Count);
|
||||
foreach (FriendInfo friend in friendList)
|
||||
{
|
||||
UUID friendUuid;
|
||||
if (UUID.TryParse(friendStringId, out friendUuid))
|
||||
if (UUID.TryParse(friend.Friend, out UUID friendUuid))
|
||||
{
|
||||
if (LocalStatusNotification(userID, friendUuid, online))
|
||||
continue;
|
||||
|
||||
remoteFriendStringIds.Add(friendStringId);
|
||||
remoteFriendStringIds.Add(friend.Friend);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friendStringId);
|
||||
m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friend.Friend);
|
||||
}
|
||||
}
|
||||
|
||||
if (remoteFriendStringIds.Count == 0)
|
||||
return;
|
||||
|
||||
// We do this regrouping so that we can efficiently send a single request rather than one for each
|
||||
// friend in what may be a very large friends list.
|
||||
PresenceInfo[] friendSessions = PresenceService.GetAgents(remoteFriendStringIds.ToArray());
|
||||
if(friendSessions == null)
|
||||
if(friendSessions is null)
|
||||
return;
|
||||
|
||||
foreach (PresenceInfo friendSession in friendSessions)
|
||||
{
|
||||
// let's guard against sessions-gone-bad
|
||||
if (friendSession != null && !friendSession.RegionID.IsZero())
|
||||
if (friendSession is not null && friendSession.RegionID.IsNotZero())
|
||||
{
|
||||
//m_log.DebugFormat("[FRIENDS]: Get region {0}", friendSession.RegionID);
|
||||
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
|
||||
if (region != null)
|
||||
if (region is not null)
|
||||
{
|
||||
m_FriendsSimConnector.StatusNotify(region, userID, friendSession.UserID, online);
|
||||
}
|
||||
@@ -578,17 +572,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered)
|
||||
{
|
||||
// we got a friendship offer
|
||||
UUID principalID = new UUID(im.fromAgentID);
|
||||
UUID friendID = new UUID(im.toAgentID);
|
||||
UUID principalID = new(im.fromAgentID);
|
||||
UUID friendID = new(im.toAgentID);
|
||||
|
||||
m_log.DebugFormat("[FRIENDS]: {0} ({1}) offered friendship to {2} ({3})", principalID, client.FirstName + client.LastName, friendID, im.fromAgentName);
|
||||
|
||||
// Check that the friendship doesn't exist yet
|
||||
FriendInfo[] finfos = GetFriendsFromCache(principalID);
|
||||
if (finfos != null)
|
||||
if (finfos is not null)
|
||||
{
|
||||
FriendInfo f = GetFriend(finfos, friendID);
|
||||
if (f != null)
|
||||
if (f is not null)
|
||||
{
|
||||
client.SendAgentAlertMessage("This person is already your friend. Please delete it first if you want to reestablish the friendship.", false);
|
||||
return;
|
||||
@@ -617,13 +611,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
|
||||
// The prospective friend is not here [as root]. Let's forward.
|
||||
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
|
||||
if (friendSessions != null && friendSessions.Length > 0)
|
||||
if (friendSessions is not null && friendSessions.Length > 0)
|
||||
{
|
||||
PresenceInfo friendSession = friendSessions[0];
|
||||
if (friendSession != null)
|
||||
if (friendSession is not null)
|
||||
{
|
||||
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
|
||||
if(region != null)
|
||||
if(region is not null)
|
||||
{
|
||||
m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message);
|
||||
return true;
|
||||
@@ -637,7 +631,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
protected virtual string GetFriendshipRequesterName(UUID agentID)
|
||||
{
|
||||
UserAccount account = UserAccountService.GetUserAccount(UUID.Zero, agentID);
|
||||
return (account == null) ? "Unknown" : account.FirstName + " " + account.LastName;
|
||||
return (account is null) ? "Unknown" : account.FirstName + " " + account.LastName;
|
||||
}
|
||||
|
||||
protected virtual void OnApproveFriendRequest(IClientAPI client, UUID friendID, List<UUID> callingCardFolders)
|
||||
@@ -651,10 +645,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
StoreFriendships(client.AgentId, friendID);
|
||||
|
||||
ICallingCardModule ccm = client.Scene.RequestModuleInterface<ICallingCardModule>();
|
||||
if (ccm != null)
|
||||
{
|
||||
ccm.CreateCallingCard(client.AgentId, friendID, UUID.Zero);
|
||||
}
|
||||
ccm?.CreateCallingCard(client.AgentId, friendID, UUID.Zero);
|
||||
|
||||
// Update the local cache.
|
||||
RecacheFriends(client);
|
||||
@@ -672,10 +663,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
|
||||
// The friend is not here
|
||||
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
|
||||
if (friendSessions != null && friendSessions.Length > 0)
|
||||
if (friendSessions is not null && friendSessions.Length > 0)
|
||||
{
|
||||
PresenceInfo friendSession = friendSessions[0];
|
||||
if (friendSession != null)
|
||||
if (friendSession is not null)
|
||||
{
|
||||
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
|
||||
m_FriendsSimConnector.FriendshipApproved(region, client.AgentId, client.Name, friendID);
|
||||
@@ -699,13 +690,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
return;
|
||||
|
||||
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
|
||||
if (friendSessions != null && friendSessions.Length > 0)
|
||||
if (friendSessions is not null && friendSessions.Length > 0)
|
||||
{
|
||||
PresenceInfo friendSession = friendSessions[0];
|
||||
if (friendSession != null)
|
||||
if (friendSession is not null)
|
||||
{
|
||||
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
|
||||
if (region != null)
|
||||
if (region is not null)
|
||||
m_FriendsSimConnector.FriendshipDenied(region, client.AgentId, client.Name, friendID);
|
||||
else
|
||||
m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID);
|
||||
@@ -732,10 +723,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
return;
|
||||
|
||||
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() });
|
||||
if (friendSessions != null && friendSessions.Length > 0)
|
||||
if (friendSessions is not null && friendSessions.Length > 0)
|
||||
{
|
||||
PresenceInfo friendSession = friendSessions[0];
|
||||
if (friendSession != null)
|
||||
if (friendSession is not null)
|
||||
{
|
||||
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
|
||||
m_FriendsSimConnector.FriendshipTerminated(region, client.AgentId, exfriendID);
|
||||
@@ -754,7 +745,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
return;
|
||||
|
||||
FriendInfo friend = GetFriend(friends, PreyID);
|
||||
if (friend == null)
|
||||
if (friend is null)
|
||||
return;
|
||||
|
||||
if(friend.TheirFlags == -1 || (friend.TheirFlags & (int)FriendRights.CanSeeOnMap) == 0)
|
||||
@@ -762,14 +753,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
|
||||
Scene hunterScene = (Scene)remoteClient.Scene;
|
||||
|
||||
if(hunterScene == null)
|
||||
if(hunterScene is null)
|
||||
return;
|
||||
|
||||
// check local
|
||||
ScenePresence sp;
|
||||
double px;
|
||||
double py;
|
||||
if(hunterScene.TryGetScenePresence(PreyID, out sp))
|
||||
if(hunterScene.TryGetScenePresence(PreyID, out ScenePresence sp))
|
||||
{
|
||||
if(sp == null)
|
||||
return;
|
||||
@@ -782,16 +772,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
|
||||
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { PreyID.ToString() });
|
||||
|
||||
if (friendSessions == null || friendSessions.Length == 0)
|
||||
if (friendSessions is null || friendSessions.Length == 0)
|
||||
return;
|
||||
|
||||
PresenceInfo friendSession = friendSessions[0];
|
||||
if (friendSession == null)
|
||||
if (friendSession is null)
|
||||
return;
|
||||
|
||||
GridRegion region = GridService.GetRegionByUUID(hunterScene.RegionInfo.ScopeID, friendSession.RegionID);
|
||||
|
||||
if(region == null)
|
||||
if(region is null)
|
||||
return;
|
||||
|
||||
// we don't have presence location so point to a standard region center for now
|
||||
@@ -811,14 +801,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
|
||||
FriendInfo[] friends = GetFriendsFromCache(requester);
|
||||
if (friends.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's find the friend in this user's friend list
|
||||
FriendInfo friend = GetFriend(friends, friendID);
|
||||
|
||||
if (friend != null) // Found it
|
||||
if (friend is not null) // Found it
|
||||
{
|
||||
// Store it on service
|
||||
if (!StoreRights(requester, friendID, rights))
|
||||
@@ -843,10 +830,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
return;
|
||||
|
||||
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
|
||||
if (friendSessions != null && friendSessions.Length > 0)
|
||||
if (friendSessions is not null && friendSessions.Length > 0)
|
||||
{
|
||||
PresenceInfo friendSession = friendSessions[0];
|
||||
if (friendSession != null)
|
||||
if (friendSession is not null)
|
||||
{
|
||||
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
|
||||
// TODO: You might want to send the delta to save the lookup
|
||||
@@ -876,7 +863,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
public virtual bool LocalFriendshipOffered(UUID toID, GridInstantMessage im)
|
||||
{
|
||||
IClientAPI friendClient = LocateClientObject(toID);
|
||||
if (friendClient != null)
|
||||
if (friendClient is not null)
|
||||
{
|
||||
// the prospective friend in this sim as root agent
|
||||
friendClient.SendInstantMessage(im);
|
||||
@@ -889,18 +876,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
public bool LocalFriendshipApproved(UUID userID, string userName, UUID friendID)
|
||||
{
|
||||
IClientAPI friendClient = LocateClientObject(friendID);
|
||||
if (friendClient != null)
|
||||
if (friendClient is not null)
|
||||
{
|
||||
// the prospective friend in this sim as root agent
|
||||
GridInstantMessage im = new GridInstantMessage(Scene, userID, userName, friendID,
|
||||
GridInstantMessage im = new(Scene, userID, userName, friendID,
|
||||
(byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero);
|
||||
friendClient.SendInstantMessage(im);
|
||||
|
||||
ICallingCardModule ccm = friendClient.Scene.RequestModuleInterface<ICallingCardModule>();
|
||||
if (ccm != null)
|
||||
{
|
||||
ccm.CreateCallingCard(friendID, userID, UUID.Zero);
|
||||
}
|
||||
ccm?.CreateCallingCard(friendID, userID, UUID.Zero);
|
||||
|
||||
// Update the local cache
|
||||
RecacheFriends(friendClient);
|
||||
@@ -915,10 +899,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
public bool LocalFriendshipDenied(UUID userID, string userName, UUID friendID)
|
||||
{
|
||||
IClientAPI friendClient = LocateClientObject(friendID);
|
||||
if (friendClient != null)
|
||||
if (friendClient is not null)
|
||||
{
|
||||
// the prospective friend in this sim as root agent
|
||||
GridInstantMessage im = new GridInstantMessage(Scene, userID, userName, friendID,
|
||||
GridInstantMessage im = new(Scene, userID, userName, friendID,
|
||||
(byte)OpenMetaverse.InstantMessageDialog.FriendshipDeclined, userID.ToString(), false, Vector3.Zero);
|
||||
friendClient.SendInstantMessage(im);
|
||||
// we're done
|
||||
@@ -931,7 +915,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
public bool LocalFriendshipTerminated(UUID userID, UUID exfriendID)
|
||||
{
|
||||
IClientAPI friendClient = LocateClientObject(exfriendID);
|
||||
if (friendClient != null)
|
||||
if (friendClient is not null)
|
||||
{
|
||||
// the friend in this sim as root agent
|
||||
friendClient.SendTerminateFriend(userID);
|
||||
@@ -947,7 +931,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
public bool LocalGrantRights(UUID userID, UUID friendID, int oldRights, int newRights)
|
||||
{
|
||||
IClientAPI friendClient = LocateClientObject(friendID);
|
||||
if (friendClient != null)
|
||||
if (friendClient is not null)
|
||||
{
|
||||
int changedRights = newRights ^ oldRights;
|
||||
bool onlineBitChanged = (changedRights & (int)FriendRights.CanSeeOnline) != 0;
|
||||
@@ -976,7 +960,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
{
|
||||
//m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online);
|
||||
IClientAPI friendClient = LocateClientObject(friendID);
|
||||
if (friendClient != null)
|
||||
if (friendClient is not null)
|
||||
{
|
||||
// the friend in this sim as root agent
|
||||
if (online)
|
||||
@@ -996,11 +980,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
|
||||
public FriendInfo[] GetFriendsFromCache(UUID userID)
|
||||
{
|
||||
UserFriendData friendsData;
|
||||
|
||||
lock (m_Friends)
|
||||
{
|
||||
if (m_Friends.TryGetValue(userID, out friendsData))
|
||||
if (m_Friends.TryGetValue(userID, out UserFriendData friendsData))
|
||||
return friendsData.Friends;
|
||||
}
|
||||
|
||||
@@ -1022,7 +1004,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
if(friends != EMPTY_FRIENDS)
|
||||
{
|
||||
FriendInfo finfo = GetFriend(friends, userID);
|
||||
if(finfo!= null)
|
||||
if(finfo is not null)
|
||||
finfo.TheirFlags = rights;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -844,9 +844,9 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
else
|
||||
userflags = m_scene.GetUserFlags(avatar);
|
||||
|
||||
if(adults && ((userflags & 32) == 0))
|
||||
if(adults && ((userflags & (int)ProfileFlags.AgeVerified) == 0))
|
||||
return true;
|
||||
if(anonymous && ((userflags & 4) == 0))
|
||||
if(anonymous && ((userflags & (int)ProfileFlags.Identified) == 0))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -54,26 +54,29 @@ namespace OpenSim.Services.Interfaces
|
||||
public FriendInfo(Dictionary<string, object> kvp)
|
||||
{
|
||||
PrincipalID = UUID.Zero;
|
||||
if (kvp.ContainsKey("PrincipalID") && kvp["PrincipalID"] != null)
|
||||
UUID.TryParse(kvp["PrincipalID"].ToString(), out PrincipalID);
|
||||
object tmpo;
|
||||
if (kvp.TryGetValue("PrincipalID", out tmpo) && tmpo is not null)
|
||||
UUID.TryParse(tmpo.ToString(), out PrincipalID);
|
||||
Friend = string.Empty;
|
||||
if (kvp.ContainsKey("Friend") && kvp["Friend"] != null)
|
||||
Friend = kvp["Friend"].ToString();
|
||||
if (kvp.TryGetValue("Friend", out tmpo) && tmpo is not null)
|
||||
Friend = tmpo.ToString();
|
||||
MyFlags = (int)FriendRights.None;
|
||||
if (kvp.ContainsKey("MyFlags") && kvp["MyFlags"] != null)
|
||||
Int32.TryParse(kvp["MyFlags"].ToString(), out MyFlags);
|
||||
if (kvp.TryGetValue("MyFlags", out tmpo) && tmpo is not null)
|
||||
Int32.TryParse(tmpo.ToString(), out MyFlags);
|
||||
TheirFlags = 0;
|
||||
if (kvp.ContainsKey("TheirFlags") && kvp["TheirFlags"] != null)
|
||||
Int32.TryParse(kvp["TheirFlags"].ToString(), out TheirFlags);
|
||||
if (kvp.TryGetValue("TheirFlags", out tmpo) && tmpo is not null)
|
||||
Int32.TryParse(tmpo.ToString(), out TheirFlags);
|
||||
}
|
||||
|
||||
public Dictionary<string, object> ToKeyValuePairs()
|
||||
{
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
result["PrincipalID"] = PrincipalID.ToString();
|
||||
result["Friend"] = Friend;
|
||||
result["MyFlags"] = MyFlags.ToString();
|
||||
result["TheirFlags"] = TheirFlags.ToString();
|
||||
Dictionary<string, object> result = new()
|
||||
{
|
||||
["PrincipalID"] = PrincipalID.ToString(),
|
||||
["Friend"] = Friend,
|
||||
["MyFlags"] = MyFlags.ToString(),
|
||||
["TheirFlags"] = TheirFlags.ToString()
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -42,9 +42,7 @@ namespace OpenSim.Services.ProfilesService
|
||||
{
|
||||
public class UserProfilesService: UserProfilesServiceBase, IUserProfilesService
|
||||
{
|
||||
static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
IUserAccountService userAccounts;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user