aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorDiva Canto2011-05-21 16:48:00 -0700
committerDiva Canto2011-05-21 16:48:00 -0700
commit58c53c41de2cae0bb041a2e8121792e136d1edb2 (patch)
treeb792158cd178f88234f86ab4d72c4224b45fe6ba /OpenSim/Services
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-58c53c41de2cae0bb041a2e8121792e136d1edb2.zip
opensim-SC-58c53c41de2cae0bb041a2e8121792e136d1edb2.tar.gz
opensim-SC-58c53c41de2cae0bb041a2e8121792e136d1edb2.tar.bz2
opensim-SC-58c53c41de2cae0bb041a2e8121792e136d1edb2.tar.xz
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.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs17
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs37
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs18
-rw-r--r--OpenSim/Services/Friends/FriendsService.cs26
-rw-r--r--OpenSim/Services/HypergridService/HGFriendsService.cs4
-rw-r--r--OpenSim/Services/Interfaces/IFriendsService.cs1
6 files changed, 70 insertions, 33 deletions
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
84 84
85 85
86 #region IFriendsService 86 #region IFriendsService
87 87
88 public FriendInfo[] GetFriends(UUID PrincipalID) 88 public FriendInfo[] GetFriends(UUID PrincipalID)
89 { 89 {
90 Dictionary<string, object> sendData = new Dictionary<string, object>(); 90 Dictionary<string, object> sendData = new Dictionary<string, object>();
@@ -92,6 +92,21 @@ namespace OpenSim.Services.Connectors.Friends
92 sendData["PRINCIPALID"] = PrincipalID.ToString(); 92 sendData["PRINCIPALID"] = PrincipalID.ToString();
93 sendData["METHOD"] = "getfriends"; 93 sendData["METHOD"] = "getfriends";
94 94
95 return GetFriends(sendData, PrincipalID.ToString());
96 }
97
98 public FriendInfo[] GetFriends(string PrincipalID)
99 {
100 Dictionary<string, object> sendData = new Dictionary<string, object>();
101
102 sendData["PRINCIPALID"] = PrincipalID;
103 sendData["METHOD"] = "getfriends_string";
104
105 return GetFriends(sendData, PrincipalID);
106 }
107
108 protected FriendInfo[] GetFriends(Dictionary<string, object> sendData, string PrincipalID)
109 {
95 string reqString = ServerUtils.BuildQueryString(sendData); 110 string reqString = ServerUtils.BuildQueryString(sendData);
96 111
97 try 112 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
63 63
64 #region IFriendsService 64 #region IFriendsService
65 65
66 public FriendInfo[] GetFriends(UUID PrincipalID) 66 public uint GetFriendPerms(UUID PrincipalID, UUID friendID)
67 { 67 {
68 Dictionary<string, object> sendData = new Dictionary<string, object>(); 68 Dictionary<string, object> sendData = new Dictionary<string, object>();
69 69
70 sendData["PRINCIPALID"] = PrincipalID.ToString(); 70 sendData["PRINCIPALID"] = PrincipalID.ToString();
71 sendData["METHOD"] = "getfriends"; 71 sendData["FRIENDID"] = friendID.ToString();
72 sendData["METHOD"] = "getfriendperms";
72 sendData["KEY"] = m_ServiceKey; 73 sendData["KEY"] = m_ServiceKey;
73 sendData["SESSIONID"] = m_SessionID.ToString(); 74 sendData["SESSIONID"] = m_SessionID.ToString();
74 75
@@ -83,34 +84,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
83 { 84 {
84 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 85 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
85 86
86 if (replyData != null) 87 if ((replyData != null) && replyData.ContainsKey("Value") && (replyData["Value"] != null))
87 { 88 {
88 if (replyData.ContainsKey("result") && (replyData["result"].ToString().ToLower() == "null")) 89 uint perms = 0;
89 { 90 uint.TryParse(replyData["Value"].ToString(), out perms);
90 return new FriendInfo[0]; 91 return perms;
91 }
92
93 List<FriendInfo> finfos = new List<FriendInfo>();
94 Dictionary<string, object>.ValueCollection finfosList = replyData.Values;
95 //m_log.DebugFormat("[FRIENDS CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
96 foreach (object f in finfosList)
97 {
98 if (f is Dictionary<string, object>)
99 {
100 FriendInfo finfo = new FriendInfo((Dictionary<string, object>)f);
101 finfos.Add(finfo);
102 }
103 else
104 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriends {0} received invalid response type {1}",
105 PrincipalID, f.GetType());
106 }
107
108 // Success
109 return finfos.ToArray();
110 } 92 }
111
112 else 93 else
113 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriends {0} received null response", 94 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriendPerms {0} received null response",
114 PrincipalID); 95 PrincipalID);
115 96
116 } 97 }
@@ -120,7 +101,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
120 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message); 101 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message);
121 } 102 }
122 103
123 return new FriendInfo[0]; 104 return 0;
124 105
125 } 106 }
126 107
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
78 78
79 public FriendInfo[] GetFriends(UUID principalID) 79 public FriendInfo[] GetFriends(UUID principalID)
80 { 80 {
81 return GetFriends(principalID.ToString());
82 }
83
84 public FriendInfo[] GetFriends(string principalID)
85 {
81 if (String.IsNullOrEmpty(m_serverUrl)) 86 if (String.IsNullOrEmpty(m_serverUrl))
82 return new FriendInfo[0]; 87 return new FriendInfo[0];
83 88
@@ -95,7 +100,14 @@ namespace OpenSim.Services.Connectors.SimianGrid
95 UUID friendID = friendEntry["Key"].AsUUID(); 100 UUID friendID = friendEntry["Key"].AsUUID();
96 101
97 FriendInfo friend = new FriendInfo(); 102 FriendInfo friend = new FriendInfo();
98 friend.PrincipalID = principalID; 103 if (!UUID.TryParse(principalID, out friend.PrincipalID))
104 {
105 string tmp = string.Empty;
106 if (!Util.ParseUniversalUserIdentifier(principalID, out friend.PrincipalID, out tmp, out tmp, out tmp))
107 // bad record. ignore this entry
108 continue;
109 }
110
99 friend.Friend = friendID.ToString(); 111 friend.Friend = friendID.ToString();
100 friend.MyFlags = friendEntry["Value"].AsInteger(); 112 friend.MyFlags = friendEntry["Value"].AsInteger();
101 friend.TheirFlags = -1; 113 friend.TheirFlags = -1;
@@ -174,7 +186,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
174 186
175 #endregion IFriendsService 187 #endregion IFriendsService
176 188
177 private OSDArray GetFriended(UUID ownerID) 189 private OSDArray GetFriended(string ownerID)
178 { 190 {
179 NameValueCollection requestArgs = new NameValueCollection 191 NameValueCollection requestArgs = new NameValueCollection
180 { 192 {
@@ -195,7 +207,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
195 } 207 }
196 } 208 }
197 209
198 private OSDArray GetFriendedBy(UUID ownerID) 210 private OSDArray GetFriendedBy(string ownerID)
199 { 211 {
200 NameValueCollection requestArgs = new NameValueCollection 212 NameValueCollection requestArgs = new NameValueCollection
201 { 213 {
diff --git a/OpenSim/Services/Friends/FriendsService.cs b/OpenSim/Services/Friends/FriendsService.cs
index 039dc0b..4664cb3 100644
--- a/OpenSim/Services/Friends/FriendsService.cs
+++ b/OpenSim/Services/Friends/FriendsService.cs
@@ -63,6 +63,32 @@ namespace OpenSim.Services.Friends
63 return info.ToArray(); 63 return info.ToArray();
64 } 64 }
65 65
66 public virtual FriendInfo[] GetFriends(string PrincipalID)
67 {
68 FriendsData[] data = m_Database.GetFriends(PrincipalID);
69 List<FriendInfo> info = new List<FriendInfo>();
70
71 foreach (FriendsData d in data)
72 {
73 FriendInfo i = new FriendInfo();
74
75 if (!UUID.TryParse(d.PrincipalID, out i.PrincipalID))
76 {
77 string tmp = string.Empty;
78 if (!Util.ParseUniversalUserIdentifier(d.PrincipalID, out i.PrincipalID, out tmp, out tmp, out tmp))
79 // bad record. ignore this entry
80 continue;
81 }
82 i.Friend = d.Friend;
83 i.MyFlags = Convert.ToInt32(d.Data["Flags"]);
84 i.TheirFlags = Convert.ToInt32(d.Data["TheirFlags"]);
85
86 info.Add(i);
87 }
88
89 return info.ToArray();
90 }
91
66 public virtual bool StoreFriend(string PrincipalID, string Friend, int flags) 92 public virtual bool StoreFriend(string PrincipalID, string Friend, int flags)
67 { 93 {
68 FriendsData d = new FriendsData(); 94 FriendsData d = new FriendsData();
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
index fa4ec5d..3ffe889 100644
--- a/OpenSim/Services/HypergridService/HGFriendsService.cs
+++ b/OpenSim/Services/HypergridService/HGFriendsService.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Services.HypergridService
62 UUID userID; 62 UUID userID;
63 if (UUID.TryParse(PrincipalID, out userID)) 63 if (UUID.TryParse(PrincipalID, out userID))
64 { 64 {
65 FriendsData[] friendsData = m_Database.GetFriends(userID); 65 FriendsData[] friendsData = m_Database.GetFriends(userID.ToString());
66 List<FriendsData> fList = new List<FriendsData>(friendsData); 66 List<FriendsData> fList = new List<FriendsData>(friendsData);
67 if (fList.Find(delegate(FriendsData fdata) 67 if (fList.Find(delegate(FriendsData fdata)
68 { 68 {
@@ -70,6 +70,8 @@ namespace OpenSim.Services.HypergridService
70 }) != null) 70 }) != null)
71 return false; 71 return false;
72 } 72 }
73 else
74 return false;
73 75
74 FriendsData d = new FriendsData(); 76 FriendsData d = new FriendsData();
75 d.PrincipalID = PrincipalID; 77 d.PrincipalID = PrincipalID;
diff --git a/OpenSim/Services/Interfaces/IFriendsService.cs b/OpenSim/Services/Interfaces/IFriendsService.cs
index 05e85f2..0a8efad 100644
--- a/OpenSim/Services/Interfaces/IFriendsService.cs
+++ b/OpenSim/Services/Interfaces/IFriendsService.cs
@@ -74,6 +74,7 @@ namespace OpenSim.Services.Interfaces
74 public interface IFriendsService 74 public interface IFriendsService
75 { 75 {
76 FriendInfo[] GetFriends(UUID PrincipalID); 76 FriendInfo[] GetFriends(UUID PrincipalID);
77 FriendInfo[] GetFriends(string PrincipalID);
77 bool StoreFriend(string PrincipalID, string Friend, int flags); 78 bool StoreFriend(string PrincipalID, string Friend, int flags);
78 bool Delete(UUID PrincipalID, string Friend); 79 bool Delete(UUID PrincipalID, string Friend);
79 } 80 }