From 58c53c41de2cae0bb041a2e8121792e136d1edb2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 21 May 2011 16:48:00 -0700 Subject: 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. --- .../Connectors/Friends/FriendsServiceConnector.cs | 17 +++++++++- .../Hypergrid/HGFriendsServiceConnector.cs | 37 ++++++---------------- .../SimianGrid/SimianFriendsServiceConnector.cs | 18 +++++++++-- 3 files changed, 40 insertions(+), 32 deletions(-) (limited to 'OpenSim/Services/Connectors') diff --git a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs index 52b80e1..d1afea2 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs @@ -84,7 +84,7 @@ namespace OpenSim.Services.Connectors.Friends #region IFriendsService - + public FriendInfo[] GetFriends(UUID PrincipalID) { Dictionary sendData = new Dictionary(); @@ -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 sendData = new Dictionary(); + + sendData["PRINCIPALID"] = PrincipalID; + sendData["METHOD"] = "getfriends_string"; + + return GetFriends(sendData, PrincipalID); + } + + protected FriendInfo[] GetFriends(Dictionary sendData, string PrincipalID) + { string reqString = ServerUtils.BuildQueryString(sendData); try diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs index 76f5f19..f823889 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs @@ -63,12 +63,13 @@ namespace OpenSim.Services.Connectors.Hypergrid #region IFriendsService - public FriendInfo[] GetFriends(UUID PrincipalID) + public uint GetFriendPerms(UUID PrincipalID, UUID friendID) { Dictionary sendData = new Dictionary(); 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 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 finfos = new List(); - Dictionary.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) - { - FriendInfo finfo = new FriendInfo((Dictionary)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; } diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs index f61ab29..b1c34dd 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs @@ -78,6 +78,11 @@ namespace OpenSim.Services.Connectors.SimianGrid 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 { -- cgit v1.1