mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 19:36:07 +08:00
Fixed permissions bug related to friends in PermissionsModule. Added FriendsData[] GetFriends(string principalID) to IFriendsData and FriendInfo[] GetFriends(string PrincipalID) to IFriendsService. Refactored some more in the FriendsModule. Made client get notification of local friends permissions upon HGLogin. HG Friends object permissions work.
This commit is contained in:
@@ -84,7 +84,7 @@ namespace OpenSim.Services.Connectors.Friends
|
||||
|
||||
|
||||
#region IFriendsService
|
||||
|
||||
|
||||
public FriendInfo[] GetFriends(UUID PrincipalID)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
@@ -92,6 +92,21 @@ namespace OpenSim.Services.Connectors.Friends
|
||||
sendData["PRINCIPALID"] = PrincipalID.ToString();
|
||||
sendData["METHOD"] = "getfriends";
|
||||
|
||||
return GetFriends(sendData, PrincipalID.ToString());
|
||||
}
|
||||
|
||||
public FriendInfo[] GetFriends(string PrincipalID)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
|
||||
sendData["PRINCIPALID"] = PrincipalID;
|
||||
sendData["METHOD"] = "getfriends_string";
|
||||
|
||||
return GetFriends(sendData, PrincipalID);
|
||||
}
|
||||
|
||||
protected FriendInfo[] GetFriends(Dictionary<string, object> sendData, string PrincipalID)
|
||||
{
|
||||
string reqString = ServerUtils.BuildQueryString(sendData);
|
||||
|
||||
try
|
||||
|
||||
@@ -63,12 +63,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
|
||||
#region IFriendsService
|
||||
|
||||
public FriendInfo[] GetFriends(UUID PrincipalID)
|
||||
public uint GetFriendPerms(UUID PrincipalID, UUID friendID)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
|
||||
sendData["PRINCIPALID"] = PrincipalID.ToString();
|
||||
sendData["METHOD"] = "getfriends";
|
||||
sendData["FRIENDID"] = friendID.ToString();
|
||||
sendData["METHOD"] = "getfriendperms";
|
||||
sendData["KEY"] = m_ServiceKey;
|
||||
sendData["SESSIONID"] = m_SessionID.ToString();
|
||||
|
||||
@@ -83,34 +84,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
{
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||
|
||||
if (replyData != null)
|
||||
if ((replyData != null) && replyData.ContainsKey("Value") && (replyData["Value"] != null))
|
||||
{
|
||||
if (replyData.ContainsKey("result") && (replyData["result"].ToString().ToLower() == "null"))
|
||||
{
|
||||
return new FriendInfo[0];
|
||||
}
|
||||
|
||||
List<FriendInfo> finfos = new List<FriendInfo>();
|
||||
Dictionary<string, object>.ValueCollection finfosList = replyData.Values;
|
||||
//m_log.DebugFormat("[FRIENDS CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
|
||||
foreach (object f in finfosList)
|
||||
{
|
||||
if (f is Dictionary<string, object>)
|
||||
{
|
||||
FriendInfo finfo = new FriendInfo((Dictionary<string, object>)f);
|
||||
finfos.Add(finfo);
|
||||
}
|
||||
else
|
||||
m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriends {0} received invalid response type {1}",
|
||||
PrincipalID, f.GetType());
|
||||
}
|
||||
|
||||
// Success
|
||||
return finfos.ToArray();
|
||||
uint perms = 0;
|
||||
uint.TryParse(replyData["Value"].ToString(), out perms);
|
||||
return perms;
|
||||
}
|
||||
|
||||
else
|
||||
m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriends {0} received null response",
|
||||
m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriendPerms {0} received null response",
|
||||
PrincipalID);
|
||||
|
||||
}
|
||||
@@ -120,7 +101,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message);
|
||||
}
|
||||
|
||||
return new FriendInfo[0];
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||
#region IFriendsService
|
||||
|
||||
public FriendInfo[] GetFriends(UUID principalID)
|
||||
{
|
||||
return GetFriends(principalID.ToString());
|
||||
}
|
||||
|
||||
public FriendInfo[] GetFriends(string principalID)
|
||||
{
|
||||
if (String.IsNullOrEmpty(m_serverUrl))
|
||||
return new FriendInfo[0];
|
||||
@@ -95,7 +100,14 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||
UUID friendID = friendEntry["Key"].AsUUID();
|
||||
|
||||
FriendInfo friend = new FriendInfo();
|
||||
friend.PrincipalID = principalID;
|
||||
if (!UUID.TryParse(principalID, out friend.PrincipalID))
|
||||
{
|
||||
string tmp = string.Empty;
|
||||
if (!Util.ParseUniversalUserIdentifier(principalID, out friend.PrincipalID, out tmp, out tmp, out tmp))
|
||||
// bad record. ignore this entry
|
||||
continue;
|
||||
}
|
||||
|
||||
friend.Friend = friendID.ToString();
|
||||
friend.MyFlags = friendEntry["Value"].AsInteger();
|
||||
friend.TheirFlags = -1;
|
||||
@@ -174,7 +186,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||
|
||||
#endregion IFriendsService
|
||||
|
||||
private OSDArray GetFriended(UUID ownerID)
|
||||
private OSDArray GetFriended(string ownerID)
|
||||
{
|
||||
NameValueCollection requestArgs = new NameValueCollection
|
||||
{
|
||||
@@ -195,7 +207,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||
}
|
||||
}
|
||||
|
||||
private OSDArray GetFriendedBy(UUID ownerID)
|
||||
private OSDArray GetFriendedBy(string ownerID)
|
||||
{
|
||||
NameValueCollection requestArgs = new NameValueCollection
|
||||
{
|
||||
|
||||
@@ -63,6 +63,32 @@ namespace OpenSim.Services.Friends
|
||||
return info.ToArray();
|
||||
}
|
||||
|
||||
public virtual FriendInfo[] GetFriends(string PrincipalID)
|
||||
{
|
||||
FriendsData[] data = m_Database.GetFriends(PrincipalID);
|
||||
List<FriendInfo> info = new List<FriendInfo>();
|
||||
|
||||
foreach (FriendsData d in data)
|
||||
{
|
||||
FriendInfo i = new FriendInfo();
|
||||
|
||||
if (!UUID.TryParse(d.PrincipalID, out i.PrincipalID))
|
||||
{
|
||||
string tmp = string.Empty;
|
||||
if (!Util.ParseUniversalUserIdentifier(d.PrincipalID, out i.PrincipalID, out tmp, out tmp, out tmp))
|
||||
// bad record. ignore this entry
|
||||
continue;
|
||||
}
|
||||
i.Friend = d.Friend;
|
||||
i.MyFlags = Convert.ToInt32(d.Data["Flags"]);
|
||||
i.TheirFlags = Convert.ToInt32(d.Data["TheirFlags"]);
|
||||
|
||||
info.Add(i);
|
||||
}
|
||||
|
||||
return info.ToArray();
|
||||
}
|
||||
|
||||
public virtual bool StoreFriend(string PrincipalID, string Friend, int flags)
|
||||
{
|
||||
FriendsData d = new FriendsData();
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace OpenSim.Services.HypergridService
|
||||
UUID userID;
|
||||
if (UUID.TryParse(PrincipalID, out userID))
|
||||
{
|
||||
FriendsData[] friendsData = m_Database.GetFriends(userID);
|
||||
FriendsData[] friendsData = m_Database.GetFriends(userID.ToString());
|
||||
List<FriendsData> fList = new List<FriendsData>(friendsData);
|
||||
if (fList.Find(delegate(FriendsData fdata)
|
||||
{
|
||||
@@ -70,6 +70,8 @@ namespace OpenSim.Services.HypergridService
|
||||
}) != null)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
FriendsData d = new FriendsData();
|
||||
d.PrincipalID = PrincipalID;
|
||||
|
||||
@@ -74,6 +74,7 @@ namespace OpenSim.Services.Interfaces
|
||||
public interface IFriendsService
|
||||
{
|
||||
FriendInfo[] GetFriends(UUID PrincipalID);
|
||||
FriendInfo[] GetFriends(string PrincipalID);
|
||||
bool StoreFriend(string PrincipalID, string Friend, int flags);
|
||||
bool Delete(UUID PrincipalID, string Friend);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user