diff options
author | Diva Canto | 2012-03-20 17:14:19 -0700 |
---|---|---|
committer | Diva Canto | 2012-03-20 17:14:19 -0700 |
commit | d08ad6459a03a6a5a6a551fd2b275f1c7da94d8e (patch) | |
tree | 62075048f4773a00593c658285b269459e9fcdfb /OpenSim/Services/Connectors | |
parent | Added GetUUID(first, last) on UserAgentsService so that we can finally make d... (diff) | |
download | opensim-SC-d08ad6459a03a6a5a6a551fd2b275f1c7da94d8e.zip opensim-SC-d08ad6459a03a6a5a6a551fd2b275f1c7da94d8e.tar.gz opensim-SC-d08ad6459a03a6a5a6a551fd2b275f1c7da94d8e.tar.bz2 opensim-SC-d08ad6459a03a6a5a6a551fd2b275f1c7da94d8e.tar.xz |
HG Friends: allow the establishment of HG friendships without requiring co-presence in the same sim. Using avatar picker, users can now search for names such as "first.last@grid.com:9000", find them, and request friendship. Friendship requests are stored if target user is offline. TESTED ON STANDALONE ONLY.
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r-- | OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs | 20 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs | 67 |
2 files changed, 76 insertions, 11 deletions
diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs index eea9853..3fd0c53 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs | |||
@@ -43,8 +43,18 @@ namespace OpenSim.Services.Connectors.Friends | |||
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | protected virtual string ServicePath() | ||
47 | { | ||
48 | return "friends"; | ||
49 | } | ||
50 | |||
46 | public bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message) | 51 | public bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message) |
47 | { | 52 | { |
53 | return FriendshipOffered(region, userID, friendID, message, String.Empty); | ||
54 | } | ||
55 | |||
56 | public virtual bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message, string userName) | ||
57 | { | ||
48 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 58 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
49 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | 59 | //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); |
50 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | 60 | //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); |
@@ -53,9 +63,10 @@ namespace OpenSim.Services.Connectors.Friends | |||
53 | sendData["FromID"] = userID.ToString(); | 63 | sendData["FromID"] = userID.ToString(); |
54 | sendData["ToID"] = friendID.ToString(); | 64 | sendData["ToID"] = friendID.ToString(); |
55 | sendData["Message"] = message; | 65 | sendData["Message"] = message; |
66 | if (userName != String.Empty) | ||
67 | sendData["FromName"] = userName; | ||
56 | 68 | ||
57 | return Call(region, sendData); | 69 | return Call(region, sendData); |
58 | |||
59 | } | 70 | } |
60 | 71 | ||
61 | public bool FriendshipApproved(GridRegion region, UUID userID, string userName, UUID friendID) | 72 | public bool FriendshipApproved(GridRegion region, UUID userID, string userName, UUID friendID) |
@@ -138,8 +149,11 @@ namespace OpenSim.Services.Connectors.Friends | |||
138 | if (region == null) | 149 | if (region == null) |
139 | return false; | 150 | return false; |
140 | 151 | ||
141 | m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: region: {0}", region.ExternalHostName + ":" + region.HttpPort); | 152 | string path = ServicePath(); |
142 | string uri = "http://" + region.ExternalHostName + ":" + region.HttpPort + "/friends"; | 153 | if (!region.ServerURI.EndsWith("/")) |
154 | path = "/" + path; | ||
155 | string uri = region.ServerURI + path; | ||
156 | m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri); | ||
143 | 157 | ||
144 | try | 158 | try |
145 | { | 159 | { |
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs index af4b0da..e3f3260 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs | |||
@@ -40,7 +40,7 @@ using OpenMetaverse; | |||
40 | 40 | ||
41 | namespace OpenSim.Services.Connectors.Hypergrid | 41 | namespace OpenSim.Services.Connectors.Hypergrid |
42 | { | 42 | { |
43 | public class HGFriendsServicesConnector | 43 | public class HGFriendsServicesConnector : FriendsSimConnector |
44 | { | 44 | { |
45 | private static readonly ILog m_log = | 45 | private static readonly ILog m_log = |
46 | LogManager.GetLogger( | 46 | LogManager.GetLogger( |
@@ -66,6 +66,11 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
66 | m_SessionID = sessionID; | 66 | m_SessionID = sessionID; |
67 | } | 67 | } |
68 | 68 | ||
69 | protected override string ServicePath() | ||
70 | { | ||
71 | return "hgfriends"; | ||
72 | } | ||
73 | |||
69 | #region IFriendsService | 74 | #region IFriendsService |
70 | 75 | ||
71 | public uint GetFriendPerms(UUID PrincipalID, UUID friendID) | 76 | public uint GetFriendPerms(UUID PrincipalID, UUID friendID) |
@@ -187,23 +192,69 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
187 | { | 192 | { |
188 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 193 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
189 | 194 | ||
190 | if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null)) | 195 | if (replyData.ContainsKey("RESULT")) |
191 | { | 196 | { |
192 | bool success = false; | 197 | if (replyData["RESULT"].ToString().ToLower() == "true") |
193 | Boolean.TryParse(replyData["Result"].ToString(), out success); | 198 | return true; |
194 | return success; | 199 | else |
200 | return false; | ||
195 | } | 201 | } |
196 | else | 202 | else |
197 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Delete {0} {1} received null response", | 203 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: reply data does not contain result field"); |
198 | PrincipalID, Friend); | 204 | |
199 | } | 205 | } |
200 | else | 206 | else |
201 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: DeleteFriend received null reply"); | 207 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: received empty reply"); |
202 | 208 | ||
203 | return false; | 209 | return false; |
204 | 210 | ||
205 | } | 211 | } |
206 | 212 | ||
213 | public bool ValidateFriendshipOffered(UUID fromID, UUID toID) | ||
214 | { | ||
215 | FriendInfo finfo = new FriendInfo(); | ||
216 | finfo.PrincipalID = fromID; | ||
217 | finfo.Friend = toID.ToString(); | ||
218 | |||
219 | Dictionary<string, object> sendData = finfo.ToKeyValuePairs(); | ||
220 | |||
221 | sendData["METHOD"] = "validate_friendship_offered"; | ||
222 | |||
223 | string reply = string.Empty; | ||
224 | string uri = m_ServerURI + "/hgfriends"; | ||
225 | try | ||
226 | { | ||
227 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
228 | uri, | ||
229 | ServerUtils.BuildQueryString(sendData)); | ||
230 | } | ||
231 | catch (Exception e) | ||
232 | { | ||
233 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message); | ||
234 | return false; | ||
235 | } | ||
236 | |||
237 | if (reply != string.Empty) | ||
238 | { | ||
239 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
240 | |||
241 | if (replyData.ContainsKey("RESULT")) | ||
242 | { | ||
243 | if (replyData["RESULT"].ToString().ToLower() == "true") | ||
244 | return true; | ||
245 | else | ||
246 | return false; | ||
247 | } | ||
248 | else | ||
249 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: reply data does not contain result field"); | ||
250 | |||
251 | } | ||
252 | else | ||
253 | m_log.DebugFormat("[HGFRIENDS CONNECTOR]: received empty reply"); | ||
254 | |||
255 | return false; | ||
256 | |||
257 | } | ||
207 | #endregion | 258 | #endregion |
208 | } | 259 | } |
209 | } \ No newline at end of file | 260 | } \ No newline at end of file |