aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
authorDiva Canto2011-05-19 16:54:46 -0700
committerDiva Canto2011-05-19 16:54:46 -0700
commitd21e9c755f004d8fe03b11bc57b810dbd401435a (patch)
tree1efd9e48308192d21ca73d8ff12d6a48c186077c /OpenSim/Services/Connectors
parentAccidentally committed too early (diff)
downloadopensim-SC_OLD-d21e9c755f004d8fe03b11bc57b810dbd401435a.zip
opensim-SC_OLD-d21e9c755f004d8fe03b11bc57b810dbd401435a.tar.gz
opensim-SC_OLD-d21e9c755f004d8fe03b11bc57b810dbd401435a.tar.bz2
opensim-SC_OLD-d21e9c755f004d8fe03b11bc57b810dbd401435a.tar.xz
HG Friends working to some extent: friendships offered and accepted correctly handled. Friends list showing correct foreign names. TODO: GrantRights.
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs13
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs175
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs2
3 files changed, 186 insertions, 4 deletions
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
index 861c475..52b80e1 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
@@ -38,7 +38,7 @@ using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39using OpenMetaverse; 39using OpenMetaverse;
40 40
41namespace OpenSim.Services.Connectors 41namespace OpenSim.Services.Connectors.Friends
42{ 42{
43 public class FriendsServicesConnector : IFriendsService 43 public class FriendsServicesConnector : IFriendsService
44 { 44 {
@@ -144,10 +144,17 @@ namespace OpenSim.Services.Connectors
144 144
145 } 145 }
146 146
147 public bool StoreFriend(UUID PrincipalID, string Friend, int flags) 147 public bool StoreFriend(string PrincipalID, string Friend, int flags)
148 { 148 {
149 FriendInfo finfo = new FriendInfo(); 149 FriendInfo finfo = new FriendInfo();
150 finfo.PrincipalID = PrincipalID; 150 try
151 {
152 finfo.PrincipalID = new UUID(PrincipalID);
153 }
154 catch
155 {
156 return false;
157 }
151 finfo.Friend = Friend; 158 finfo.Friend = Friend;
152 finfo.MyFlags = flags; 159 finfo.MyFlags = flags;
153 160
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs
new file mode 100644
index 0000000..76f5f19
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs
@@ -0,0 +1,175 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Services.Interfaces;
36using OpenSim.Services.Connectors.Friends;
37using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38using OpenSim.Server.Base;
39using OpenMetaverse;
40
41namespace OpenSim.Services.Connectors.Hypergrid
42{
43 public class HGFriendsServicesConnector
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(
47 MethodBase.GetCurrentMethod().DeclaringType);
48
49 private string m_ServerURI = String.Empty;
50 private string m_ServiceKey = String.Empty;
51 private UUID m_SessionID;
52
53 public HGFriendsServicesConnector()
54 {
55 }
56
57 public HGFriendsServicesConnector(string serverURI, UUID sessionID, string serviceKey)
58 {
59 m_ServerURI = serverURI.TrimEnd('/');
60 m_ServiceKey = serviceKey;
61 m_SessionID = sessionID;
62 }
63
64 #region IFriendsService
65
66 public FriendInfo[] GetFriends(UUID PrincipalID)
67 {
68 Dictionary<string, object> sendData = new Dictionary<string, object>();
69
70 sendData["PRINCIPALID"] = PrincipalID.ToString();
71 sendData["METHOD"] = "getfriends";
72 sendData["KEY"] = m_ServiceKey;
73 sendData["SESSIONID"] = m_SessionID.ToString();
74
75 string reqString = ServerUtils.BuildQueryString(sendData);
76
77 try
78 {
79 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
80 m_ServerURI + "/hgfriends",
81 reqString);
82 if (reply != string.Empty)
83 {
84 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
85
86 if (replyData != null)
87 {
88 if (replyData.ContainsKey("result") && (replyData["result"].ToString().ToLower() == "null"))
89 {
90 return new FriendInfo[0];
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 }
111
112 else
113 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriends {0} received null response",
114 PrincipalID);
115
116 }
117 }
118 catch (Exception e)
119 {
120 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message);
121 }
122
123 return new FriendInfo[0];
124
125 }
126
127 public bool NewFriendship(UUID PrincipalID, string Friend)
128 {
129 FriendInfo finfo = new FriendInfo();
130 finfo.PrincipalID = PrincipalID;
131 finfo.Friend = Friend;
132
133 Dictionary<string, object> sendData = finfo.ToKeyValuePairs();
134
135 sendData["METHOD"] = "newfriendship";
136 sendData["KEY"] = m_ServiceKey;
137 sendData["SESSIONID"] = m_SessionID.ToString();
138
139 string reply = string.Empty;
140 try
141 {
142 reply = SynchronousRestFormsRequester.MakeRequest("POST",
143 m_ServerURI + "/hgfriends",
144 ServerUtils.BuildQueryString(sendData));
145 }
146 catch (Exception e)
147 {
148 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server: {0}", e.Message);
149 return false;
150 }
151
152 if (reply != string.Empty)
153 {
154 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
155
156 if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
157 {
158 bool success = false;
159 Boolean.TryParse(replyData["Result"].ToString(), out success);
160 return success;
161 }
162 else
163 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: StoreFriend {0} {1} received null response",
164 PrincipalID, Friend);
165 }
166 else
167 m_log.DebugFormat("[HGFRIENDS CONNECTOR]: StoreFriend received null reply");
168
169 return false;
170
171 }
172
173 #endregion
174 }
175} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
index 6f2d735..f61ab29 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
@@ -127,7 +127,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
127 return array; 127 return array;
128 } 128 }
129 129
130 public bool StoreFriend(UUID principalID, string friend, int flags) 130 public bool StoreFriend(string principalID, string friend, int flags)
131 { 131 {
132 if (String.IsNullOrEmpty(m_serverUrl)) 132 if (String.IsNullOrEmpty(m_serverUrl))
133 return true; 133 return true;